Skip to content
This repository has been archived by the owner on Jan 14, 2024. It is now read-only.

Commit

Permalink
oscmorph tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulBatchelor committed Oct 8, 2020
1 parent 6a7c384 commit 96de581
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions modules/oscmorph.c
@@ -1,3 +1,5 @@
/* This code is placed in the public domain */

#include <stdlib.h>
#include <math.h>
#include "soundpipe.h"
Expand Down Expand Up @@ -26,6 +28,7 @@ int sp_oscmorph_init(sp_data *sp, sp_oscmorph *osc, sp_ftbl **ft, int nft, SPFLO
osc->wtpos = 0.0;
osc->nft = nft;
uint32_t prev = (uint32_t)ft[0]->size;

for (i = 0; i < nft; i++) {
if (prev != ft[i]->size) {
fprintf(stderr, "sp_oscmorph: size mismatch\n");
Expand All @@ -42,15 +45,20 @@ int sp_oscmorph_compute(sp_data *sp, sp_oscmorph *osc, SPFLOAT *in, SPFLOAT *out
SPFLOAT amp, cps, fract, v1, v2;
SPFLOAT *ft1, *ft2;
int32_t phs, lobits, pos;
SPFLOAT sicvt = osc->tbl[0]->sicvt;
SPFLOAT sicvt;
SPFLOAT findex;
int index;
SPFLOAT wtfrac;

/* Use only the fractional part of the position or 1 */
if (osc->wtpos > 1.0) {
osc->wtpos -= (int)osc->wtpos;
}
SPFLOAT findex = osc->wtpos * (osc->nft - 1);
int index = floor(findex);
SPFLOAT wtfrac = findex - index;

sicvt = osc->tbl[0]->sicvt;
findex = osc->wtpos * (osc->nft - 1);
wtfrac = findex - index;
index = floor(findex);

lobits = osc->tbl[0]->lobits;
amp = osc->amp;
Expand Down

0 comments on commit 96de581

Please sign in to comment.