shithub: soundpipe

Download patch

ref: 42bc0e304eef602cd288728a1dbe0b98694f5681
parent: dd88a3bf36323b1917aad54943766529bcfbe9d0
author: Paul Batchelor <thisispaulbatchelor@gmail.com>
date: Fri Sep 25 13:29:09 EDT 2020

updates to fmpair

--- a/tangled/fmpair.c
+++ b/tangled/fmpair.c
@@ -1,26 +1,18 @@
-#line 130 "fmpair.org"
 #include <math.h>
 #define SK_FMPAIR_PRIV
 #include "fmpair.h"
-#line 178 "fmpair.org"
 #define SK_FMPAIR_MAXLEN 0x1000000L
 #define SK_FMPAIR_PHASEMASK 0x0FFFFFFL
-#line 130 "fmpair.org"
-#line 303 "fmpair.org"
 void sk_fmpair_init(sk_fmpair *fmp, int sr,
                     SKFLT *ctab, int csz, SKFLT ciphs,
                     SKFLT *mtab, int msz, SKFLT miphs)
 {
-#line 198 "fmpair.org"
 fmp->ctab = ctab;
 fmp->csz = msz;
-#line 214 "fmpair.org"
 fmp->mtab = mtab;
 fmp->msz = msz;
-#line 226 "fmpair.org"
 fmp->clphs = floor(ciphs * SK_FMPAIR_MAXLEN);
 fmp->mlphs = floor(miphs * SK_FMPAIR_MAXLEN);
-#line 253 "fmpair.org"
 {
     int tmp;
 
@@ -49,21 +41,15 @@
 /* used to convert cycles-per-second units to cycles */
 
 fmp->maxlens = 1.0 * SK_FMPAIR_MAXLEN / sr;
-#line 336 "fmpair.org"
 sk_fmpair_freq(fmp, 440);
-#line 370 "fmpair.org"
 sk_fmpair_carrier(fmp, 1);
 sk_fmpair_modulator(fmp, 1);
-#line 399 "fmpair.org"
 sk_fmpair_modindex(fmp, 1);
-#line 308 "fmpair.org"
 }
-#line 321 "fmpair.org"
 void sk_fmpair_freq(sk_fmpair *fmp, SKFLT freq)
 {
     fmp->freq = freq;
 }
-#line 349 "fmpair.org"
 void sk_fmpair_modulator(sk_fmpair *fmp, SKFLT mod)
 {
     fmp->mod = mod;
@@ -73,12 +59,10 @@
 {
     fmp->car = car;
 }
-#line 383 "fmpair.org"
 void sk_fmpair_modindex(sk_fmpair *fmp, SKFLT index)
 {
     fmp->index = index;
 }
-#line 411 "fmpair.org"
 SKFLT sk_fmpair_tick(sk_fmpair *fmp)
 {
     SKFLT out;
@@ -88,11 +72,8 @@
     SKFLT frac;
     SKFLT x[2];
     out = 0;
-#line 436 "fmpair.org"
 cfreq = fmp->freq * fmp->car;
 mfreq = fmp->freq * fmp->mod;
-#line 411 "fmpair.org"
-#line 446 "fmpair.org"
 fmp->mlphs &= SK_FMPAIR_PHASEMASK;
 ipos = fmp->mlphs >> fmp->mnlb;
 x[0] = fmp->mtab[ipos];
@@ -105,14 +86,8 @@
 
 frac = (fmp->mlphs & fmp->mmask) * fmp->minlb;
 modout = (x[0] + (x[1] - x[0]) * frac);
-#line 411 "fmpair.org"
-#line 467 "fmpair.org"
 modout *= mfreq * fmp->index;
-#line 411 "fmpair.org"
-#line 476 "fmpair.org"
 cfreq += modout;
-#line 411 "fmpair.org"
-#line 485 "fmpair.org"
 fmp->clphs &= SK_FMPAIR_PHASEMASK;
 ipos = (fmp->clphs) >> fmp->cnlb;
 x[0] = fmp->ctab[ipos];
@@ -125,14 +100,10 @@
 
 frac = (fmp->clphs & fmp->cmask) * fmp->cinlb;
 out = (x[0] + (x[1] - x[0]) * frac);
-#line 411 "fmpair.org"
-#line 512 "fmpair.org"
 fmp->clphs += floor(cfreq * fmp->maxlens);
 fmp->mlphs += floor(mfreq * fmp->maxlens);
-#line 426 "fmpair.org"
     return out;
 }
-#line 555 "fmpair.org"
 void sk_fmpair_fdbk_init(sk_fmpair_fdbk *fmp, int sr,
                          SKFLT *ctab, int csz, SKFLT ciphs,
                          SKFLT *mtab, int msz, SKFLT miphs)
@@ -143,12 +114,10 @@
     fmp->prev = 0;
     fmp->feedback = 0;
 }
-#line 576 "fmpair.org"
 void sk_fmpair_fdbk_amt(sk_fmpair_fdbk *f, SKFLT amt)
 {
     f->feedback = amt;
 }
-#line 599 "fmpair.org"
 SKFLT sk_fmpair_fdbk_tick(sk_fmpair_fdbk *f)
 {
     SKFLT out;
@@ -161,11 +130,8 @@
     out = 0;
     fmp = &f->fmpair;
 
-#line 436 "fmpair.org"
 cfreq = fmp->freq * fmp->car;
 mfreq = fmp->freq * fmp->mod;
-#line 599 "fmpair.org"
-#line 446 "fmpair.org"
 fmp->mlphs &= SK_FMPAIR_PHASEMASK;
 ipos = fmp->mlphs >> fmp->mnlb;
 x[0] = fmp->mtab[ipos];
@@ -178,21 +144,14 @@
 
 frac = (fmp->mlphs & fmp->mmask) * fmp->minlb;
 modout = (x[0] + (x[1] - x[0]) * frac);
-#line 599 "fmpair.org"
-#line 467 "fmpair.org"
-modout *= mfreq * fmp->index;
-#line 614 "fmpair.org"
 
     /* feedback-oscillator specific */
-#line 632 "fmpair.org"
 modout += f->prev * f->feedback;
 f->prev = modout;
-#line 617 "fmpair.org"
 
-#line 476 "fmpair.org"
+modout *= mfreq * fmp->index;
+
 cfreq += modout;
-#line 617 "fmpair.org"
-#line 485 "fmpair.org"
 fmp->clphs &= SK_FMPAIR_PHASEMASK;
 ipos = (fmp->clphs) >> fmp->cnlb;
 x[0] = fmp->ctab[ipos];
@@ -205,11 +164,7 @@
 
 frac = (fmp->clphs & fmp->cmask) * fmp->cinlb;
 out = (x[0] + (x[1] - x[0]) * frac);
-#line 617 "fmpair.org"
-#line 512 "fmpair.org"
 fmp->clphs += floor(cfreq * fmp->maxlens);
 fmp->mlphs += floor(mfreq * fmp->maxlens);
-#line 621 "fmpair.org"
     return out;
 }
-#line 130 "fmpair.org"
--- a/tangled/fmpair.h
+++ b/tangled/fmpair.h
@@ -1,48 +1,31 @@
-#line 143 "fmpair.org"
 #ifndef SK_FMPAIR_H
 #define SK_FMPAIR_H
 #ifndef SKFLT
 #define SKFLT float
 #endif
-#line 160 "fmpair.org"
 typedef struct sk_fmpair sk_fmpair;
-#line 526 "fmpair.org"
 typedef struct sk_fmpair_fdbk sk_fmpair_fdbk;
-#line 143 "fmpair.org"
-#line 296 "fmpair.org"
 void sk_fmpair_init(sk_fmpair *fmp, int sr,
                     SKFLT *ctab, int csz, SKFLT ciphs,
                     SKFLT *mtab, int msz, SKFLT miphs);
-#line 316 "fmpair.org"
 void sk_fmpair_freq(sk_fmpair *fmp, SKFLT freq);
-#line 343 "fmpair.org"
 void sk_fmpair_modulator(sk_fmpair *fmp, SKFLT mod);
 void sk_fmpair_carrier(sk_fmpair *fmp, SKFLT car);
-#line 378 "fmpair.org"
 void sk_fmpair_modindex(sk_fmpair *fmp, SKFLT index);
-#line 406 "fmpair.org"
 SKFLT sk_fmpair_tick(sk_fmpair *fmp);
-#line 548 "fmpair.org"
 void sk_fmpair_fdbk_init(sk_fmpair_fdbk *fmp, int sr,
                          SKFLT *ctab, int csz, SKFLT ciphs,
                          SKFLT *mtab, int msz, SKFLT miphs);
-#line 571 "fmpair.org"
 void sk_fmpair_fdbk_amt(sk_fmpair_fdbk *f, SKFLT amt);
-#line 587 "fmpair.org"
 SKFLT sk_fmpair_fdbk_tick(sk_fmpair_fdbk *fmp);
-#line 150 "fmpair.org"
 #ifdef SK_FMPAIR_PRIV
-#line 165 "fmpair.org"
 struct sk_fmpair {
-#line 191 "fmpair.org"
 SKFLT *ctab;
 int csz;
 int clphs;
-#line 207 "fmpair.org"
 SKFLT *mtab;
 int msz;
 int mlphs;
-#line 238 "fmpair.org"
 /* carrier constants */
 int cnlb;
 SKFLT cinlb;
@@ -54,21 +37,15 @@
 unsigned long mmask;
 
 SKFLT maxlens;
-#line 329 "fmpair.org"
 SKFLT freq;
-#line 362 "fmpair.org"
 SKFLT car;
 SKFLT mod;
-#line 391 "fmpair.org"
 SKFLT index;
-#line 167 "fmpair.org"
 };
-#line 536 "fmpair.org"
 struct sk_fmpair_fdbk {
     sk_fmpair fmpair;
     SKFLT prev;
     SKFLT feedback;
 };
-#line 152 "fmpair.org"
 #endif
 #endif