History

oscmorph tweaks

Paul Batchelor committed 6 years ago

Commit 96de5811 parent 6a7c3841 file · +12 −4Browse files

Showing the changes to modules (1 of 1 file). Show all

Unified · Split

modules/oscmorph.c+12−4
@@ -1,3 +1,5 @@
1/* This code is placed in the public domain */
2
1#include <stdlib.h>3#include <stdlib.h>
2#include <math.h>4#include <math.h>
3#include "soundpipe.h"5#include "soundpipe.h"
@@ -26,6 +28,7 @@ int sp_oscmorph_init(sp_data *sp, sp_oscmorph *osc, sp_ftbl **ft, int nft, SPFLO · 22 unmodified lines
26 osc->wtpos = 0.0;28 osc->wtpos = 0.0;
27 osc->nft = nft;29 osc->nft = nft;
28 uint32_t prev = (uint32_t)ft[0]->size;30 uint32_t prev = (uint32_t)ft[0]->size;
31
29 for (i = 0; i < nft; i++) {32 for (i = 0; i < nft; i++) {
30 if (prev != ft[i]->size) {33 if (prev != ft[i]->size) {
31 fprintf(stderr, "sp_oscmorph: size mismatch\n");34 fprintf(stderr, "sp_oscmorph: size mismatch\n");
@@ -42,15 +45,20 @@ int sp_oscmorph_compute(sp_data *sp, sp_oscmorph *osc, SPFLOAT *in, SPFLOAT *out · 10 unmodified lines
42 SPFLOAT amp, cps, fract, v1, v2;45 SPFLOAT amp, cps, fract, v1, v2;
43 SPFLOAT *ft1, *ft2;46 SPFLOAT *ft1, *ft2;
44 int32_t phs, lobits, pos;47 int32_t phs, lobits, pos;
45 SPFLOAT sicvt = osc->tbl[0]->sicvt;48 SPFLOAT sicvt;
49 SPFLOAT findex;
50 int index;
51 SPFLOAT wtfrac;
46 52
47 /* Use only the fractional part of the position or 1 */53 /* Use only the fractional part of the position or 1 */
48 if (osc->wtpos > 1.0) {54 if (osc->wtpos > 1.0) {
49 osc->wtpos -= (int)osc->wtpos;55 osc->wtpos -= (int)osc->wtpos;
50 }56 }
51 SPFLOAT findex = osc->wtpos * (osc->nft - 1);57
52 int index = floor(findex);58 sicvt = osc->tbl[0]->sicvt;
53 SPFLOAT wtfrac = findex - index;59 findex = osc->wtpos * (osc->nft - 1);
60 wtfrac = findex - index;
61 index = floor(findex);
54 62
55 lobits = osc->tbl[0]->lobits;63 lobits = osc->tbl[0]->lobits;
56 amp = osc->amp;64 amp = osc->amp;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t