History

fixed a few float/double issues found by setting more agressive warning flags

spiricom committed 6 years ago

Commit ef901ea1 parent f9bde6c13 files · +757 −748Browse files

Unified · Split

13 files
  1. leaf/Inc/leaf-effects.h +24 −24
  2. leaf/Inc/leaf-math.h +4 −2
  3. leaf/Inc/leaf-physical.h +3 −3
  4. leaf/Src/leaf-analysis.c +21 −21
  5. leaf/Src/leaf-delay.c +38 −38
  6. leaf/Src/leaf-effects.c +103 −103
  7. leaf/Src/leaf-envelopes.c +90 −88
  8. leaf/Src/leaf-filters.c +309 −309
  9. leaf/Src/leaf-math.c +12 −7
  10. leaf/Src/leaf-oscillators.c +24 −24
  11. leaf/Src/leaf-physical.c +9 −9
  12. leaf/Src/leaf-reverb.c +105 −105
  13. leaf/Src/leaf-sampling.c +15 −15
leaf/Inc/leaf-effects.h+24−24
@@ -125,16 +125,16 @@ extern "C" { · 124 unmodified lines
125125 void tTalkbox_free (tTalkbox* const);
126126
127127 float tTalkbox_tick (tTalkbox* const, float synth, float voice);
128− float tTalkbox_tickFrozen (tTalkbox* const voc, float synth, float voice);
128+ float tTalkbox_tickFrozen (tTalkbox* const voc, float synth, float voice);
129129 void tTalkbox_update (tTalkbox* const);
130130 void tTalkbox_suspend (tTalkbox* const);
131131 void tTalkbox_lpcDurbin (float *r, int p, float *k, float *g);
132− void tTalkbox_lpc (float *buf, float *car, double* dl, double* Rt, int32_t n, int32_t o, float warp, int warpOn, float *k, int freeze, float *G);
132+ void tTalkbox_lpc (float *buf, float *car, double* dl, double* Rt, int32_t n, int32_t o, float warp, int warpOn, float *k, int freeze, float *G);
133133 void tTalkbox_setQuality (tTalkbox* const, float quality);
134− void tTalkbox_setWarpFactor (tTalkbox* const voc, float warp);
135− void tTalkbox_setWarpOn (tTalkbox* const voc, float warpOn);
136− void tTalkbox_setFreeze (tTalkbox* const voc, float freeze);
137− void tTalkbox_warpedAutocorrelate (float * x, double* dl, double* Rt, unsigned int L, float * R, unsigned int P, float lambda);
134+ void tTalkbox_setWarpFactor (tTalkbox* const voc, float warp);
135+ void tTalkbox_setWarpOn (tTalkbox* const voc, float warpOn);
136+ void tTalkbox_setFreeze (tTalkbox* const voc, float freeze);
137+ void tTalkbox_warpedAutocorrelate (float * x, double* dl, double* Rt, unsigned int L, float * R, unsigned int P, float lambda);
138138
139139
140140 //==============================================================================
@@ -238,16 +238,16 @@ extern "C" { · 97 unmodified lines
238238 void tTalkboxFloat_free (tTalkboxFloat* const);
239239
240240 float tTalkboxFloat_tick (tTalkboxFloat* const, float synth, float voice);
241− float tTalkboxFloat_tickFrozen (tTalkboxFloat* const voc, float synth, float voice);
241+ float tTalkboxFloat_tickFrozen (tTalkboxFloat* const voc, float synth, float voice);
242242 void tTalkboxFloat_update (tTalkboxFloat* const);
243243 void tTalkboxFloat_suspend (tTalkboxFloat* const);
244244 void tTalkboxFloat_lpcDurbin (float *r, int p, float *k, float *g);
245− void tTalkboxFloat_lpc (float *buf, float *car, float* dl, float* Rt, int32_t n, int32_t o, float warp, int warpOn, float *k, int freeze, float *G);
245+ void tTalkboxFloat_lpc (float *buf, float *car, float* dl, float* Rt, int32_t n, int32_t o, float warp, int warpOn, float *k, int freeze, float *G);
246246 void tTalkboxFloat_setQuality (tTalkboxFloat* const, float quality);
247− void tTalkboxFloat_setWarpFactor (tTalkboxFloat* const voc, float warp);
248− void tTalkboxFloat_setWarpOn (tTalkboxFloat* const voc, float warpOn);
249− void tTalkboxFloat_setFreeze (tTalkboxFloat* const voc, float freeze);
250− void tTalkboxFloat_warpedAutocorrelate (float * x, float* dl, float* Rt, unsigned int L, float * R, unsigned int P, float lambda);
247+ void tTalkboxFloat_setWarpFactor (tTalkboxFloat* const voc, float warp);
248+ void tTalkboxFloat_setWarpOn (tTalkboxFloat* const voc, int warpOn);
249+ void tTalkboxFloat_setFreeze (tTalkboxFloat* const voc, int freeze);
250+ void tTalkboxFloat_warpedAutocorrelate (float * x, float* dl, float* Rt, unsigned int L, float * R, unsigned int P, float lambda);
251251 //==============================================================================
252252
253253
@@ -359,8 +359,8 @@ extern "C" { · 105 unmodified lines
359359
360360 @} */
361361
362− typedef struct _tRosenbergGlottalPulse
363− {
362+ typedef struct _tRosenbergGlottalPulse
363+ {
364364 tMempool mempool;
365365 float phase;
366366 float openLength;
@@ -368,21 +368,21 @@ extern "C" { · 1 unmodified line
368368 float invPulseLengthMinusOpenLength;
369369 float freq;
370370 float inc;
371− } _tRosenbergGlottalPulse;
371+ } _tRosenbergGlottalPulse;
372372
373− typedef _tRosenbergGlottalPulse* tRosenbergGlottalPulse;
373+ typedef _tRosenbergGlottalPulse* tRosenbergGlottalPulse;
374374
375− void tRosenbergGlottalPulse_init (tRosenbergGlottalPulse* const);
376− void tRosenbergGlottalPulse_initToPool (tRosenbergGlottalPulse* const, tMempool* const);
377− void tRosenbergGlottalPulse_free (tRosenbergGlottalPulse* const);
375+ void tRosenbergGlottalPulse_init (tRosenbergGlottalPulse* const);
376+ void tRosenbergGlottalPulse_initToPool (tRosenbergGlottalPulse* const, tMempool* const);
377+ void tRosenbergGlottalPulse_free (tRosenbergGlottalPulse* const);
378378
379− float tRosenbergGlottalPulse_tick (tRosenbergGlottalPulse* const);
380− float tRosenbergGlottalPulse_tickHQ (tRosenbergGlottalPulse* const gp);
381− void tRosenbergGlottalPulse_setFreq (tRosenbergGlottalPulse* const, float freq);
379+ float tRosenbergGlottalPulse_tick (tRosenbergGlottalPulse* const);
380+ float tRosenbergGlottalPulse_tickHQ (tRosenbergGlottalPulse* const gp);
381+ void tRosenbergGlottalPulse_setFreq (tRosenbergGlottalPulse* const, float freq);
382382
383− void tRosenbergGlottalPulse_setOpenLength (tRosenbergGlottalPulse* const, float openLength);
383+ void tRosenbergGlottalPulse_setOpenLength (tRosenbergGlottalPulse* const, float openLength);
384384
385− void tRosenbergGlottalPulse_setPulseLength (tRosenbergGlottalPulse* const, float pulseLength);
385+ void tRosenbergGlottalPulse_setPulseLength (tRosenbergGlottalPulse* const, float pulseLength);
386386 void tRosenbergGlottalPulse_setOpenLengthAndPulseLength (tRosenbergGlottalPulse* const gp, float openLength, float pulseLength);
387387 //==============================================================================
388388
leaf/Inc/leaf-math.h+4−2
@@ -38,7 +38,7 @@ extern "C" { · 37 unmodified lines
3838 #define WSCALE 1.30612244898f
3939 #define PI (3.14159265358979f)
4040 #define TWO_PI (6.28318530717958f)
41−#define HALF_PI (1.570796326794897f)
41+#define HALF_PI (1.570796326794897f)
4242
4343 #define VSF 1.0e-38f
4444
@@ -91,9 +91,11 @@ extern "C" { · 46 unmodified lines
9191 #define TWO_TO_32 4294967296.0f
9292 #define INV_TWO_TO_32 0.000000000232831f
9393
94−#define ONE_OVER_SQRT2 0.707106781186548f
94+#define ONE_OVER_SQRT2 0.707106781186548f
9595
9696 #define LOGTEN 2.302585092994
97+ float log2f_approx(float X);
98+ float log2f_approx2(float x);
9799
98100 // Jones shaper
99101 float LEAF_shaper (float input, float m_drive);
leaf/Inc/leaf-physical.h+3−3
@@ -291,7 +291,7 @@ extern "C" { · 290 unmodified lines
291291 float freq, waveLengthInSamples; // the frequency of the string, determining delay length
292292 float dampFreq; // frequency for the bridge LP filter, in Hz
293293 float decay; // amplitude damping factor for the string (only active in mode 0)
294− float levMode;
294+ int levMode;
295295 float curr;
296296 tLinearDelay delayLine;
297297 tOnePole bridgeFilter;
@@ -399,7 +399,7 @@ extern "C" { · 101 unmodified lines
399399 float prepIndex; // the amount of pressure on the pickpoint of the string (near 0=soft obj, near 1=hard obj)
400400 float dampFreq; // frequency for the bridge LP filter, in Hz
401401 float decay; // amplitude damping factor for the string (only active in mode 0)
402− float levMode;
402+ int levMode;
403403 float curr;
404404 tLinearDelay delLF,delUF,delUB,delLB; // delay for lower/upper/forward/backward part of the waveguide model
405405 tOnePole bridgeFilter, nutFilter, prepFilterU, prepFilterL;
@@ -517,7 +517,7 @@ extern "C" { · 111 unmodified lines
517517 float prepIndex; // the amount of pressure on the pickpoint of the string (near 0=soft obj, near 1=hard obj)
518518 float dampFreq; // frequency for the bridge LP filter, in Hz
519519 float decay; // amplitude damping factor for the string (only active in mode 0)
520− float levMode;
520+ int levMode;
521521 float curr;
522522 tLinearDelay delLF,delUF, delMF, delMB, delUB,delLB; // delay for lower/upper/forward/backward part of the waveguide model
523523 tOnePole bridgeFilter, nutFilter, prepFilterU, prepFilterL;
leaf/Src/leaf-analysis.c+21−21
@@ -96,7 +96,7 @@ void tZeroCrossing_initToPool (tZeroCrossing* const zc, int maxWindowSize, · 95 unmodified lines
9696 z->count = 0;
9797 z->maxWindowSize = maxWindowSize;
9898 z->currentWindowSize = maxWindowSize;
99− z->invCurrentWindowSize = 1.0f / maxWindowSize;
99+ z->invCurrentWindowSize = 1.0f / (float)maxWindowSize;
100100 z->position = 0;
101101 z->prevPosition = maxWindowSize;
102102 z->inBuffer = (float*) mpool_calloc(sizeof(float) * maxWindowSize, m);
@@ -392,14 +392,14 @@ void tAttackDetection_setAttack(tAttackDetection* const ad, int inAtk) · 289 unmodified lines
392392 {
393393 _tAttackDetection* a = *ad;
394394 a->atk = inAtk;
395− a->atk_coeff = pow(0.01, 1.0/(a->atk * a->samplerate * 0.001));
395+ a->atk_coeff = powf(0.01f, 1.0f/(a->atk * a->samplerate * 0.001f));
396396 }
397397
398398 void tAttackDetection_setRelease(tAttackDetection* const ad, int inRel)
399399 {
400400 _tAttackDetection* a = *ad;
401401 a->rel = inRel;
402− a->rel_coeff = pow(0.01, 1.0/(a->rel * a->samplerate * 0.001));
402+ a->rel_coeff = powf(0.01f, 1.0f/(a->rel * a->samplerate * 0.001f));
403403 }
404404
405405
@@ -602,7 +602,7 @@ static void snac_analyzeframe(tSNAC* const snac) · 196 unmodified lines
602602 int n, tindex = s->timeindex;
603603 int framesize = s->framesize;
604604 int mask = framesize - 1;
605− float norm = 1. / sqrt((float)(framesize * 2));
605+ float norm = 1.f / sqrtf((float)(framesize * 2));
606606
607607 float *inputbuf = s->inputbuf;
608608 float *processbuf = s->processbuf;
@@ -646,7 +646,7 @@ static void snac_autocorrelation(tSNAC* const snac) · 37 unmodified lines
646646 {
647647 processbuf[n] = processbuf[n] * processbuf[n]
648648 + processbuf[fftsize-n] * processbuf[fftsize-n]; // imag coefficients appear reversed
649− processbuf[fftsize-n] = 0.;
649+ processbuf[fftsize-n] = 0.f;
650650 }
651651
652652 // store power spectrum up to SR/4 for possible later use
@@ -677,7 +677,7 @@ static void snac_normalize(tSNAC* const snac) · 24 unmodified lines
677677
678678 // minimum RMS implemented as minimum autocorrelation at index 0
679679 // functionally equivalent to white noise floor
680− float rms = s->minrms / sqrt(1.0f / (float)framesize);
680+ float rms = s->minrms / sqrtf(1.0f / (float)framesize);
681681 float minrzero = rms * rms;
682682 float rzero = processbuf[0];
683683 if(rzero < minrzero) rzero = minrzero;
@@ -689,7 +689,7 @@ static void snac_normalize(tSNAC* const snac) · 5 unmodified lines
689689 for(n=1, m=s->timeindex+1; n<seek; n++, m++)
690690 {
691691 signal1 = inputbuf[(n + timeindexminusone)&mask];
692− signal2 = inputbuf[(framesizeplustimeindex - n)&mask];
692+ signal2 = inputbuf[(framesizeplustimeindex - n)&mask]; //could this be switched to float resolution without issue? -JS
693693 normintegral -= (double)(signal1 * signal1 + signal2 * signal2);
694694 processbuf[n] /= (float)normintegral * 0.5f;
695695 }
@@ -824,7 +824,7 @@ static void snac_biasbuf(tSNAC* const snac) · 128 unmodified lines
824824
825825 for(n=5; n<maxperiod; n++)
826826 {
827− biasbuf[n] = 1.0f - (float)logf(n - 4) * bias;
827+ biasbuf[n] = 1.0f - (float)logf(n - 4.f) * bias;
828828 }
829829 }
830830
@@ -864,7 +864,7 @@ void tPeriodDetection_initToPool (tPeriodDetection* const pd, float* in, float* · 33 unmodified lines
864864 p->tolerance = 1.0f;
865865 p->timeConstant = DEFTIMECONSTANT;
866866 p->radius = expf(-1000.0f * p->hopSize * leaf.invSampleRate / p->timeConstant);
867− p->fidelityThreshold = 0.95;
867+ p->fidelityThreshold = 0.95f;
868868 }
869869
870870 void tPeriodDetection_free (tPeriodDetection* const pd)
@@ -903,7 +903,7 @@ float tPeriodDetection_tick (tPeriodDetection* pd, float sample) · 32 unmodified lines
903903 // Fidelity threshold recommended by Katja Vetters is 0.95 for most instruments/voices http://www.katjaas.nl/helmholtz/helmholtz.html
904904 if (fidelity > p->fidelityThreshold)
905905 {
906− p->period = tSNAC_getPeriod(&p->snac);
906+ p->period = tSNAC_getPeriod(&p->snac);
907907 }
908908
909909 p->curBlock++;
@@ -979,7 +979,7 @@ void tZeroCrossing2_updatePeak(tZeroCrossing2* const zc, float s, int pos) · 69 unmodified lines
979979 {
980980 _tZeroCrossing2* z = *zc;
981981
982− z->_peak = fmax(s, z->_peak);
982+ z->_peak = fmaxf(s, z->_peak);
983983 if ((z->_width == 0.0f) && (s < (z->_peak * 0.3f)))
984984 z->_width = pos - z->_leading_edge;
985985 }
@@ -1056,11 +1056,11 @@ void tZeroCrossings_initToPool (tZeroCrossings* const zc, int windowSize, · 70 unmodified lines
10561056 int size = z->_window_size / 2;
10571057
10581058 // Ensure size is a power of 2
1059− z->_size = pow(2, ceil(log2(size)));
1059+ z->_size = pow(2.0, ceil(log2((double)size)));
10601060 z->_mask = z->_size - 1;
10611061
10621062 z->_info = (tZeroCrossing2*) mpool_alloc(sizeof(tZeroCrossing2) * z->_size, m);
1063− for (int i = 0; i < z->_size; i++)
1063+ for (uint i = 0; i < z->_size; i++)
10641064 tZeroCrossing2_initToPool(&z->_info[i], mp);
10651065 z->_pos = 0;
10661066
@@ -1088,7 +1088,7 @@ int tZeroCrossings_tick(tZeroCrossings* const zc, float s) · 21 unmodified lines
10881088 // centered on the actual zero.
10891089 s += z->_hysteresis * 0.5f;
10901090
1091− if (z->_num_edges >= z->_size)
1091+ if (z->_num_edges >= (int)z->_size)
10921092 reset(zc);
10931093
10941094 if ((z->_frame == z->_window_size/2) && (z->_num_edges == 0))
@@ -1137,7 +1137,7 @@ int tZeroCrossings_getCapacity(tZeroCrossings* const zc) · 42 unmodified lines
11371137 {
11381138 _tZeroCrossings* z = *zc;
11391139
1140− return z->_size;
1140+ return (int)z->_size;
11411141 }
11421142
11431143 int tZeroCrossings_getFrame(tZeroCrossings* const zc)
@@ -1165,7 +1165,7 @@ float tZeroCrossings_getPeak(tZeroCrossings* const zc) · 21 unmodified lines
11651165 {
11661166 _tZeroCrossings* z = *zc;
11671167
1168− return fmax(z->_peak, z->_peak_update);
1168+ return fmaxf(z->_peak, z->_peak_update);
11691169 }
11701170
11711171 int tZeroCrossings_isReset(tZeroCrossings* const zc)
@@ -1187,7 +1187,7 @@ static inline void update_state(tZeroCrossings* const zc, float s) · 15 unmodified lines
11871187 z->_peak_update = 0.0f;
11881188 }
11891189
1190− if (z->_num_edges >= z->_size)
1190+ if (z->_num_edges >= (int)z->_size)
11911191 reset(zc);
11921192
11931193 if (s > 0.0f)
@@ -1444,7 +1444,7 @@ int tBACF_getCorrelation (tBACF* const bacf, int pos) · 250 unmodified lines
14441444
14451445 if (shift == 0)
14461446 {
1447− for (int i = 0; i != b->_mid_array; ++i)
1447+ for (uint i = 0; i != b->_mid_array; ++i)
14481448 // built in compiler popcount functions should be faster but we want this to be portable
14491449 // could try to add some define that call the correct function depending on compiler
14501450 // or let the user pointer popcount() to whatever they want
@@ -1454,7 +1454,7 @@ int tBACF_getCorrelation (tBACF* const bacf, int pos) · 3 unmodified lines
14541454 else
14551455 {
14561456 const int shift2 = value_size - shift;
1457− for (int i = 0; i != b->_mid_array; ++i)
1457+ for (uint i = 0; i != b->_mid_array; ++i)
14581458 {
14591459 unsigned int v = *p2++ >> shift;
14601460 v |= *p2 << shift2;
@@ -1721,7 +1721,7 @@ static inline void autocorrelate(tPeriodDetector* const detector) · 260 unmodified lines
17211721 static inline void sub_collector_init(_sub_collector* collector, tZeroCrossings* const crossings, float pdt, int range)
17221722 {
17231723 collector->_zc = *crossings;
1724− collector->_harmonic_threshold = HARMONIC_PERIODICITY_FACTOR * 2.0f / collector->_zc->_window_size;
1724+ collector->_harmonic_threshold = HARMONIC_PERIODICITY_FACTOR * 2.0f / (float)collector->_zc->_window_size;
17251725 collector->_periodicity_diff_threshold = pdt;
17261726 collector->_range = range;
17271727 collector->_fundamental._i1 = -1;
@@ -1756,7 +1756,7 @@ static inline int sub_collector_try_sub_harmonic(_sub_collector* collector, int · 28 unmodified lines
17561756 if (info._periodicity > collector->_fundamental._periodicity &&
17571757 harmonic != collector->_fundamental._harmonic)
17581758 {
1759− float periodicity_diff = fabs(info._periodicity - collector->_fundamental._periodicity);
1759+ float periodicity_diff = fabsf(info._periodicity - collector->_fundamental._periodicity);
17601760
17611761 // If incoming periodicity is within the harmonic
17621762 // periodicity threshold, then replace _fundamental with
leaf/Src/leaf-delay.c+38−38
@@ -58,7 +58,7 @@ void tDelay_free (tDelay* const dl) · 57 unmodified lines
5858 void tDelay_clear(tDelay* const dl)
5959 {
6060 _tDelay* d = *dl;
61− for (int i = 0; i < d->maxDelay; i++)
61+ for (uint i = 0; i < d->maxDelay; i++)
6262 {
6363 d->buff[i] = 0;
6464 }
@@ -202,11 +202,11 @@ void tLinearDelay_free (tLinearDelay* const dl) · 137 unmodified lines
202202
203203 void tLinearDelay_clear(tLinearDelay* const dl)
204204 {
205− _tLinearDelay* d = *dl;
206− for (int i = 0; i < d->maxDelay; i++)
207− {
208− d->buff[i] = 0;
209− }
205+ _tLinearDelay* d = *dl;
206+ for (uint i = 0; i < d->maxDelay; i++)
207+ {
208+ d->buff[i] = 0;
209+ }
210210 }
211211
212212 float tLinearDelay_tick (tLinearDelay* const dl, float input)
@@ -247,19 +247,19 @@ float tLinearDelay_tickOut (tLinearDelay* const dl) · 34 unmodified lines
247247 {
248248 _tLinearDelay* d = *dl;
249249
250− uint32_t idx = (uint32_t) d->outPoint;
251− // First 1/2 of interpolation
252− d->lastOut = d->buff[idx] * d->omAlpha;
253− // Second 1/2 of interpolation
254− if ((idx + 1) < d->maxDelay)
255− d->lastOut += d->buff[idx+1] * d->alpha;
256− else
257− d->lastOut += d->buff[0] * d->alpha;
250+ uint32_t idx = (uint32_t) d->outPoint;
251+ // First 1/2 of interpolation
252+ d->lastOut = d->buff[idx] * d->omAlpha;
253+ // Second 1/2 of interpolation
254+ if ((idx + 1) < d->maxDelay)
255+ d->lastOut += d->buff[idx+1] * d->alpha;
256+ else
257+ d->lastOut += d->buff[0] * d->alpha;
258258
259− // Increment output pointer modulo length
260− if ( (++d->outPoint) >= d->maxDelay ) d->outPoint = 0;
259+ // Increment output pointer modulo length
260+ if ( (++d->outPoint) >= d->maxDelay ) d->outPoint = 0;
261261
262− return d->lastOut;
262+ return d->lastOut;
263263 }
264264
265265 int tLinearDelay_setDelay (tLinearDelay* const dl, float delay)
@@ -287,7 +287,7 @@ float tLinearDelay_tapOut (tLinearDelay* const dl, uint32_t tapDelay) · 21 unmodified lines
287287 {
288288 _tLinearDelay* d = *dl;
289289
290− uint32_t tap = d->inPoint - tapDelay - 1;
290+ int32_t tap = d->inPoint - tapDelay - 1;
291291 // Check for wraparound.
292292 while ( tap < 0 ) tap += d->maxDelay;
293293
@@ -298,7 +298,7 @@ void tLinearDelay_tapIn (tLinearDelay* const dl, float value, uint32_t tapDelay) · 4 unmodified lines
298298 {
299299 _tLinearDelay* d = *dl;
300300
301− uint32_t tap = d->inPoint - tapDelay - 1;
301+ int32_t tap = d->inPoint - tapDelay - 1;
302302
303303 // Check for wraparound.
304304 while ( tap < 0 ) tap += d->maxDelay;
@@ -396,16 +396,16 @@ void tHermiteDelay_free (tHermiteDelay* const dl) · 91 unmodified lines
396396
397397 void tHermiteDelay_clear(tHermiteDelay* const dl)
398398 {
399− _tHermiteDelay* d = *dl;
400− for (int i = 0; i < d->maxDelay; i++)
401− {
402− d->buff[i] = 0;
403− }
399+ _tHermiteDelay* d = *dl;
400+ for (uint i = 0; i < d->maxDelay; i++)
401+ {
402+ d->buff[i] = 0;
403+ }
404404 }
405405
406406 float tHermiteDelay_tick (tHermiteDelay* const dl, float input)
407407 {
408− _tHermiteDelay* d = *dl;
408+ _tHermiteDelay* d = *dl;
409409
410410 d->buff[d->inPoint] = input * d->gain;
411411
@@ -428,7 +428,7 @@ float tHermiteDelay_tick (tHermiteDelay* const dl, float input) · 16 unmodified lines
428428
429429 void tHermiteDelay_tickIn (tHermiteDelay* const dl, float input)
430430 {
431− _tHermiteDelay* d = *dl;
431+ _tHermiteDelay* d = *dl;
432432
433433 d->buff[d->inPoint] = input * d->gain;
434434
@@ -438,7 +438,7 @@ void tHermiteDelay_tickIn (tHermiteDelay* const dl, float input) · 3 unmodified lines
438438
439439 float tHermiteDelay_tickOut (tHermiteDelay* const dl)
440440 {
441− _tHermiteDelay* d = *dl;
441+ _tHermiteDelay* d = *dl;
442442
443443 uint32_t idx = (uint32_t) d->outPoint;
444444
@@ -458,7 +458,7 @@ float tHermiteDelay_tickOut (tHermiteDelay* const dl) · 13 unmodified lines
458458
459459 int tHermiteDelay_setDelay (tHermiteDelay* const dl, float delay)
460460 {
461− _tHermiteDelay* d = *dl;
461+ _tHermiteDelay* d = *dl;
462462
463463 d->delay = LEAF_clip(0.0f, delay, d->maxDelay);
464464
@@ -479,9 +479,9 @@ int tHermiteDelay_setDelay (tHermiteDelay* const dl, float delay) · 14 unmodified lines
479479
480480 float tHermiteDelay_tapOut (tHermiteDelay* const dl, uint32_t tapDelay)
481481 {
482− _tHermiteDelay* d = *dl;
482+ _tHermiteDelay* d = *dl;
483483
484− uint32_t tap = d->inPoint - tapDelay - 1;
484+ int32_t tap = d->inPoint - tapDelay - 1;
485485
486486 // Check for wraparound.
487487 while ( tap < 0 ) tap += d->maxDelay;
@@ -492,7 +492,7 @@ float tHermiteDelay_tapOut (tHermiteDelay* const dl, uint32_t tapDelay) · 4 unmodified lines
492492
493493 void tHermiteDelay_tapIn (tHermiteDelay* const dl, float value, uint32_t tapDelay)
494494 {
495− _tHermiteDelay* d = *dl;
495+ _tHermiteDelay* d = *dl;
496496
497497 int32_t tap = d->inPoint - tapDelay - 1;
498498
@@ -504,7 +504,7 @@ void tHermiteDelay_tapIn (tHermiteDelay* const dl, float value, uint32_t tapDela · 5 unmodified lines
504504
505505 float tHermiteDelay_addTo (tHermiteDelay* const dl, float value, uint32_t tapDelay)
506506 {
507− _tHermiteDelay* d = *dl;
507+ _tHermiteDelay* d = *dl;
508508
509509 int32_t tap = d->inPoint - tapDelay - 1;
510510
@@ -522,26 +522,26 @@ float tHermiteDelay_getDelay (tHermiteDelay* const dl) · 11 unmodified lines
522522
523523 float tHermiteDelay_getLastOut (tHermiteDelay* const dl)
524524 {
525− _tHermiteDelay* d = *dl;
525+ _tHermiteDelay* d = *dl;
526526 return d->lastOut;
527527 }
528528
529529 float tHermiteDelay_getLastIn (tHermiteDelay* const dl)
530530 {
531− _tHermiteDelay* d = *dl;
531+ _tHermiteDelay* d = *dl;
532532 return d->lastIn;
533533 }
534534
535535 void tHermiteDelay_setGain (tHermiteDelay* const dl, float gain)
536536 {
537− _tHermiteDelay* d = *dl;
537+ _tHermiteDelay* d = *dl;
538538 if (gain < 0.0f) d->gain = 0.0f;
539539 else d->gain = gain;
540540 }
541541
542542 float tHermiteDelay_getGain (tHermiteDelay* const dl)
543543 {
544− _tHermiteDelay* d = *dl;
544+ _tHermiteDelay* d = *dl;
545545 return d->gain;
546546 }
547547
@@ -593,7 +593,7 @@ void tAllpassDelay_free (tAllpassDelay* const dl) · 45 unmodified lines
593593 void tAllpassDelay_clear(tAllpassDelay* const dl)
594594 {
595595 _tAllpassDelay* d = *dl;
596− for (int i = 0; i < d->maxDelay; i++)
596+ for (uint i = 0; i < d->maxDelay; i++)
597597 {
598598 d->buff[i] = 0;
599599 }
@@ -763,7 +763,7 @@ void tTapeDelay_free (tTapeDelay* const dl) · 163 unmodified lines
763763 void tTapeDelay_clear(tTapeDelay* const dl)
764764 {
765765 _tTapeDelay* d = *dl;
766− for (int i = 0; i < d->maxDelay; i++)
766+ for (uint i = 0; i < d->maxDelay; i++)
767767 {
768768 d->buff[i] = 0;
769769 }
leaf/Src/leaf-effects.c+103−103
@@ -180,9 +180,9 @@ void tTalkbox_lpcDurbin(float *r, int p, float *k, float *g) · 179 unmodified lines
180180
181181 for(i=0; i<=p; i++)
182182 {
183− a[i] = 0.0f; //probably don't need to clear at[] or k[]
183+ a[i] = 0.0f; //probably don't need to clear at[] or k[]
184184 }
185− k[0] = 0.0f;
185+ k[0] = 0.0f;
186186 at[0] = 0.0f;
187187 for(i=1; i<=p; i++)
188188 {
@@ -261,45 +261,45 @@ void tTalkbox_lpc(float *buf, float *car, double* dl, double* Rt, int32_t n, int · 72 unmodified lines
261261 int32_t i, j, nn=n;
262262
263263
264− if (warpOn == 0)
265− {
266− for(j=0; j<=o; j++, nn--) //buf[] is already emphasized and windowed
267− {
268− z[j] = r[j] = 0.0f;
269− for(i=0; i<nn; i++) r[j] += buf[i] * buf[i+j]; //autocorrelation
270− }
271− }
272− else
273− {
274− for(j=0; j<=o; j++, nn--) //buf[] is already emphasized and windowed
275− {
276− z[j] = r[j] = 0.0f;
277− }
278− tTalkbox_warpedAutocorrelate(buf, dl, Rt, n, r, o, warp);
279− }
280−
281− r[0] *= 1.001f; //stability fix
282−
283− float min = 0.000001f;
284− if (!freeze)
285− {
286− if(r[0] < min)
287− {
288−// for(i=0; i<n; i++)
289−// {
290− buf[i] = 0.0f;
291− return;
292−// }
293− }
294−
295− tTalkbox_lpcDurbin(r, o, k, G); //calc reflection coeffs
296−
297− //this is for stability to keep reflection coefficients inside the unit circle
298− //in mda's code it's .995 but in Harma's papers I've seen 0.998. just needs to be less than 1 it seems but maybe some wiggle room to avoid instability from floating point precision -JS
299− for(i=0; i<=o; i++)
300− {
301− if(k[i] > 0.998f) k[i] = 0.998f; else if(k[i] < -0.998f) k[i] = -.998f;
302− }
264+ if (warpOn == 0)
265+ {
266+ for(j=0; j<=o; j++, nn--) //buf[] is already emphasized and windowed
267+ {
268+ z[j] = r[j] = 0.0f;
269+ for(i=0; i<nn; i++) r[j] += buf[i] * buf[i+j]; //autocorrelation
270+ }
271+ }
272+ else
273+ {
274+ for(j=0; j<=o; j++, nn--) //buf[] is already emphasized and windowed
275+ {
276+ z[j] = r[j] = 0.0f;
277+ }
278+ tTalkbox_warpedAutocorrelate(buf, dl, Rt, n, r, o, warp);
279+ }
280+
281+ r[0] *= 1.001f; //stability fix
282+
283+ float min = 0.000001f;
284+ if (!freeze)
285+ {
286+ if(r[0] < min)
287+ {
288+ for(i=0; i<n; i++)
289+ {
290+ buf[i] = 0.0f;
291+ return;
292+ }
293+ }
294+
295+ tTalkbox_lpcDurbin(r, o, k, G); //calc reflection coeffs
296+
297+ //this is for stability to keep reflection coefficients inside the unit circle
298+ //in mda's code it's .995 but in Harma's papers I've seen 0.998. just needs to be less than 1 it seems but maybe some wiggle room to avoid instability from floating point precision -JS
299+ for(i=0; i<=o; i++)
300+ {
301+ if(k[i] > 0.998f) k[i] = 0.998f; else if(k[i] < -0.998f) k[i] = -.998f;
302+ }
303303 }
304304 for(i=0; i<n; i++)
305305 {
@@ -320,7 +320,7 @@ void tTalkbox_setQuality(tTalkbox* const voc, float quality) · 14 unmodified lines
320320 v->O = (int32_t)((0.0001f + 0.0004f * v->param[3]) * leaf.sampleRate);
321321 if (v->O >= ORD_MAX)
322322 {
323− v->O = ORD_MAX-1;
323+ v->O = ORD_MAX-1;
324324 }
325325 }
326326
@@ -506,10 +506,10 @@ void tTalkboxFloat_lpcDurbin(float *r, int p, float *k, float *g) · 179 unmodified lines
506506
507507 for(i=0; i<=p; i++)
508508 {
509− a[i] = 0.0f; //probably don't need to clear at[]
509+ a[i] = 0.0f; //probably don't need to clear at[]
510510
511511 }
512− k[0] = 0.0f;
512+ k[0] = 0.0f;
513513 at[0] = 0.0f;
514514 for(i=1; i<=p; i++)
515515 {
@@ -588,45 +588,45 @@ void tTalkboxFloat_lpc(float *buf, float *car, float* dl, float* Rt, int32_t n, · 72 unmodified lines
588588 int32_t i, j, nn=n;
589589
590590
591− if (warpOn == 0)
592− {
593− for(j=0; j<=o; j++, nn--) //buf[] is already emphasized and windowed
594− {
595− z[j] = r[j] = 0.0f;
596− for(i=0; i<nn; i++) r[j] += buf[i] * buf[i+j]; //autocorrelation
597− }
598− }
599− else
600− {
601− for(j=0; j<=o; j++, nn--) //buf[] is already emphasized and windowed
602− {
603− z[j] = r[j] = 0.0f;
604− }
605− tTalkboxFloat_warpedAutocorrelate(buf, dl, Rt, n, r, o, warp);
606− }
607−
608− r[0] *= 1.001f; //stability fix
609−
610− float min = 0.000001f;
611− if (!freeze)
612− {
613− if(r[0] < min)
614− {
615−// for(i=0; i<n; i++)
616−// {
617− buf[i] = 0.0f;
618− return;
619−// }
620− }
621−
622− tTalkbox_lpcDurbin(r, o, k, G); //calc reflection coeffs
623−
624− //this is for stability to keep reflection coefficients inside the unit circle
625− //but in Harma's papers I've seen 0.998. just needs to be less than 1 it seems but maybe some wiggle room to avoid instability from floating point precision -JS
626− for(i=0; i<=o; i++)
627− {
628− if(k[i] > 0.998f) k[i] = 0.998f; else if(k[i] < -0.998f) k[i] = -.998f;
629− }
591+ if (warpOn == 0)
592+ {
593+ for(j=0; j<=o; j++, nn--) //buf[] is already emphasized and windowed
594+ {
595+ z[j] = r[j] = 0.0f;
596+ for(i=0; i<nn; i++) r[j] += buf[i] * buf[i+j]; //autocorrelation
597+ }
598+ }
599+ else
600+ {
601+ for(j=0; j<=o; j++, nn--) //buf[] is already emphasized and windowed
602+ {
603+ z[j] = r[j] = 0.0f;
604+ }
605+ tTalkboxFloat_warpedAutocorrelate(buf, dl, Rt, n, r, o, warp);
606+ }
607+
608+ r[0] *= 1.001f; //stability fix
609+
610+ float min = 0.000001f;
611+ if (!freeze)
612+ {
613+ if(r[0] < min)
614+ {
615+ for(i=0; i<n; i++)
616+ {
617+ buf[i] = 0.0f;
618+ return;
619+ }
620+ }
621+
622+ tTalkbox_lpcDurbin(r, o, k, G); //calc reflection coeffs
623+
624+ //this is for stability to keep reflection coefficients inside the unit circle
625+ //but in Harma's papers I've seen 0.998. just needs to be less than 1 it seems but maybe some wiggle room to avoid instability from floating point precision -JS
626+ for(i=0; i<=o; i++)
627+ {
628+ if(k[i] > 0.998f) k[i] = 0.998f; else if(k[i] < -0.998f) k[i] = -.998f;
629+ }
630630 }
631631 for(i=0; i<n; i++)
632632 {
@@ -647,7 +647,7 @@ void tTalkboxFloat_setQuality(tTalkboxFloat* const voc, float quality) · 14 unmodified lines
647647 v->O = (int32_t)((0.0001f + 0.0004f * v->param[3]) * leaf.sampleRate);
648648 if (v->O >= ORD_MAX)
649649 {
650− v->O = ORD_MAX-1;
650+ v->O = ORD_MAX-1;
651651 }
652652 }
653653
@@ -658,14 +658,14 @@ void tTalkboxFloat_setWarpFactor(tTalkboxFloat* const voc, float warpFactor) · 4 unmodified lines
658658 v->warpFactor = warpFactor;
659659 }
660660
661−void tTalkboxFloat_setWarpOn(tTalkboxFloat* const voc, float warpOn)
661+void tTalkboxFloat_setWarpOn(tTalkboxFloat* const voc, int warpOn)
662662 {
663663 _tTalkboxFloat* v = *voc;
664664
665665 v->warpOn = warpOn;
666666 }
667667
668−void tTalkboxFloat_setFreeze(tTalkboxFloat* const voc, float freeze)
668+void tTalkboxFloat_setFreeze(tTalkboxFloat* const voc, int freeze)
669669 {
670670 _tTalkboxFloat* v = *voc;
671671
@@ -764,30 +764,30 @@ void tVocoder_update (tVocoder* const voc) · 92 unmodified lines
764764 }
765765 else
766766 {
767− v->f[0][12] = (float)pow(10.0, -1.7 - 2.7f * v->param[4]); //envelope speed
767+ v->f[0][12] = powf(10.0f, -1.7f - 2.7f * v->param[4]); //envelope speed
768768
769769 rr = 0.022f / (float)v->nbnd; //minimum proportional to frequency to stop distortion
770770 for(i=1;i<v->nbnd;i++)
771771 {
772− v->f[i][12] = (float)(0.025 - rr * (double)i);
772+ v->f[i][12] = (float)(0.025f - rr * (float)i);
773773 if(v->f[0][12] < v->f[i][12]) v->f[i][12] = v->f[0][12];
774774 }
775775 v->f[0][12] = 0.5f * v->f[0][12]; //only top band is at full rate
776776 }
777777
778− rr = 1.0 - pow(10.0f, -1.0f - 1.2f * v->param[5]);
778+ rr = 1.0f - powf(10.0f, -1.0f - 1.2f * v->param[5]);
779779 sh = (float)pow(2.0f, 3.0f * v->param[6] - 1.0f); //filter bank range shift
780780
781781 for(i=1;i<v->nbnd;i++)
782782 {
783783 v->f[i][2] *= sh;
784− th = acos((2.0 * rr * cos(tpofs * v->f[i][2])) / (1.0 + rr * rr));
785− v->f[i][0] = (float)(2.0 * rr * cos(th)); //a0
786− v->f[i][1] = (float)(-rr * rr); //a1
784+ th = acosf((2.0f * rr * cosf(tpofs * v->f[i][2])) / (1.0f + rr * rr));
785+ v->f[i][0] = (2.0f * rr * cosf(th)); //a0
786+ v->f[i][1] = (-rr * rr); //a1
787787 //was .98
788788 v->f[i][2] *= 0.96f; //shift 2nd stage slightly to stop high resonance peaks
789− th = acos((2.0 * rr * cos(tpofs * v->f[i][2])) / (1.0 + rr * rr));
790− v->f[i][2] = (float)(2.0 * rr * cos(th));
789+ th = acosf((2.0f * rr * cosf(tpofs * v->f[i][2])) / (1.0f + rr * rr));
790+ v->f[i][2] = (2.0f * rr * cosf(th));
791791 }
792792 }
793793
@@ -1733,14 +1733,14 @@ float* tAutotune_tick(tAutotune* const rt, float sample) · 939 unmodified lines
17331733
17341734 float tempPeriod = tPeriodDetection_tick(&r->pd, sample);
17351735 if (tempPeriod < 1000.0f) //to avoid trying to follow consonants JS
1736− {
1737− r->inputPeriod = tempPeriod;
1738− }
1736+ {
1737+ r->inputPeriod = tempPeriod;
1738+ }
17391739
1740− for (int v = 0; v < r->numVoices; ++v)
1741− {
1742− r->tickOutput[v] = tPitchShift_shiftToFreq(&r->ps[v], r->freq[v]);
1743− }
1740+ for (int v = 0; v < r->numVoices; ++v)
1741+ {
1742+ r->tickOutput[v] = tPitchShift_shiftToFreq(&r->ps[v], r->freq[v]);
1743+ }
17441744
17451745 return r->tickOutput;
17461746 }
@@ -2057,11 +2057,11 @@ void tFormantShifter_setIntensity(tFormantShifter* const fsr, float intensity) · 310 unmodified lines
20572057 //make sure you don't divide by zero, doofies
20582058 if (fs->intensity != 0.0f)
20592059 {
2060− fs->invIntensity = 1.0f/fs->intensity;
2060+ fs->invIntensity = 1.0f/fs->intensity;
20612061 }
20622062 else
20632063 {
2064− fs->invIntensity = 1.0f;
2064+ fs->invIntensity = 1.0f;
20652065 }
20662066
20672067 }
leaf/Src/leaf-envelopes.c+90−88
@@ -544,7 +544,7 @@ void tADSR2_setAttack(tADSR2* const adsrenv, float attack) · 543 unmodified lines
544544 {
545545 _tADSR2* adsr = *adsrenv;
546546 adsr->attack = LEAF_clip(0.0f, attack * 0.001f, 1.0f);
547− adsr->attackLambda = fastPow(ADSR2_LAMBDA_BASE, -adsr->attack) * ADSR2_INV_MIN_TIME;
547+ adsr->attackLambda = fastPowf(ADSR2_LAMBDA_BASE, -adsr->attack) * ADSR2_INV_MIN_TIME;
548548
549549 }
550550
@@ -552,7 +552,7 @@ void tADSR2_setDecay(tADSR2* const adsrenv, float decay) · 1 unmodified line
552552 {
553553 _tADSR2* adsr = *adsrenv;
554554 adsr->decay = LEAF_clip(0.0f, decay * 0.001f, 1.0f);
555− adsr->decayLambda = fastPow(ADSR2_LAMBDA_BASE, -adsr->decay) * ADSR2_INV_MIN_TIME;
555+ adsr->decayLambda = fastPowf(ADSR2_LAMBDA_BASE, -adsr->decay) * ADSR2_INV_MIN_TIME;
556556
557557 }
558558
@@ -574,7 +574,7 @@ void tADSR2_setRelease(tADSR2* const adsrenv, float release) · 15 unmodified lines
574574 {
575575 _tADSR2* adsr = *adsrenv;
576576 adsr->release = LEAF_clip(0.0f, release * 0.001f, 1.0f);
577− adsr->releaseLambda = fastPow(ADSR2_LAMBDA_BASE, -adsr->release) * ADSR2_INV_MIN_TIME;
577+ adsr->releaseLambda = fastPowf(ADSR2_LAMBDA_BASE, -adsr->release) * ADSR2_INV_MIN_TIME;
578578 }
579579
580580 // 0.999999 is slow leak, 0.9 is fast leak
@@ -644,9 +644,9 @@ float tADSR2_tick(tADSR2* const adsrenv) · 63 unmodified lines
644644 //This one doesn't use any lookup table - by Nigel Redmon from his blog. Thanks, Nigel!
645645 //-JS
646646
647−float calcADSR3Coef(double rate, double targetRatio)
647+float calcADSR3Coef(float rate, float targetRatio)
648648 {
649− return (rate <= 0.0f) ? 0.0f : exp(-log((1.0 + targetRatio) / targetRatio) / rate);
649+ return (rate <= 0.0f) ? 0.0f : expf(-logf((1.0f + targetRatio) / targetRatio) / rate);
650650 }
651651
652652
@@ -725,7 +725,7 @@ void tADSR3_setRelease(tADSR3* const adsrenv, float release) · 72 unmodified lines
725725 _tADSR3* adsr = *adsrenv;
726726
727727 adsr->releaseRate = release * adsr->sampleRateInMs;
728− adsr->releaseCoef = calcADSR3Coef(adsr->releaseRate, adsr->targetRatioDR);
728+ adsr->releaseCoef = calcADSR3Coef(adsr->releaseRate, (float)adsr->targetRatioDR);
729729 adsr->releaseBase = -adsr->targetRatioDR * (1.0f - adsr->releaseCoef);
730730 }
731731
@@ -785,6 +785,8 @@ float tADSR3_tick(tADSR3* const adsrenv) · 53 unmodified lines
785785 adsr->output = 0.0f;
786786 adsr->state = env_idle;
787787 }
788+ default:
789+ break;
788790 }
789791 //smooth the gain value -- this is not ideal, a retrigger while the envelope is still going with a new gain will cause a jump, although it will be smoothed quickly. Maybe doing the math so the range is computed based on the gain rather than 0.->1. is preferable? But that's harder to get the exponential curve right without a lookup.
790792 adsr->gain = (adsr->factor*adsr->targetGainSquared)+(adsr->oneMinusFactor*adsr->gain);
@@ -1182,14 +1184,14 @@ void tRamp_setTime(tRamp* const ramp, float time) · 391 unmodified lines
11821184 {
11831185 _tRamp* r = *ramp;
11841186
1185− if (time < r->minimum_time)
1186− {
1187− r->time = r->minimum_time;
1188− }
1189− else
1190− {
1191− r->time = time;
1192− }
1187+ if (time < r->minimum_time)
1188+ {
1189+ r->time = r->minimum_time;
1190+ }
1191+ else
1192+ {
1193+ r->time = time;
1194+ }
11931195 r->factor = (1.0f / r->time) * r->inv_sr_ms * (float)r->samples_per_tick;
11941196 r->inc = (r->dest - r->curr) * r->factor;
11951197
@@ -1216,10 +1218,10 @@ float tRamp_tick(tRamp* const ramp) · 20 unmodified lines
12161218 r->curr += r->inc;
12171219
12181220 if (((r->curr >= r->dest) && (r->inc > 0.0f)) || ((r->curr <= r->dest) && (r->inc < 0.0f)))
1219− {
1220− r->inc = 0.0f;
1221− r->curr=r->dest;
1222− }
1221+ {
1222+ r->inc = 0.0f;
1223+ r->curr=r->dest;
1224+ }
12231225
12241226 return r->curr;
12251227 }
@@ -1243,7 +1245,7 @@ void tRampSampleRateChanged(tRamp* const ramp) · 17 unmodified lines
12431245 /* RampUpDown */
12441246 void tRampUpDown_init(tRampUpDown* const r, float upTime, float downTime, int samples_per_tick)
12451247 {
1246− tRampUpDown_initToPool(r, upTime, downTime, samples_per_tick, &leaf.mempool);
1248+ tRampUpDown_initToPool(r, upTime, downTime, samples_per_tick, &leaf.mempool);
12471249 }
12481250
12491251 void tRampUpDown_initToPool(tRampUpDown* const r, float upTime, float downTime, int samples_per_tick, tMempool* const mp)
@@ -1341,29 +1343,29 @@ float tRampUpDown_tick(tRampUpDown* const ramp) · 91 unmodified lines
13411343
13421344 if (r->dest < r->curr)
13431345 {
1344− test = r->curr + r->downInc;
1345− if (test > r->dest)
1346− {
1347− r->curr = test;
1348− }
1349− else
1350− {
1351− r->downInc = 0.0f;
1352− r->curr = r->dest;
1353− }
1346+ test = r->curr + r->downInc;
1347+ if (test > r->dest)
1348+ {
1349+ r->curr = test;
1350+ }
1351+ else
1352+ {
1353+ r->downInc = 0.0f;
1354+ r->curr = r->dest;
1355+ }
13541356 }
13551357 else if (r->dest > r->curr)
13561358 {
1357− test = r->curr + r->upInc;
1358− if (test < r->dest)
1359− {
1360− r->curr = test;
1361− }
1362− else
1363− {
1364− r->upInc = 0.0f;
1365− r->curr = r->dest;
1366− }
1359+ test = r->curr + r->upInc;
1360+ if (test < r->dest)
1361+ {
1362+ r->curr = test;
1363+ }
1364+ else
1365+ {
1366+ r->upInc = 0.0f;
1367+ r->curr = r->dest;
1368+ }
13671369 }
13681370 return r->curr;
13691371 }
@@ -1381,7 +1383,7 @@ float tRampUpDown_sample(tRampUpDown* const ramp) · 11 unmodified lines
13811383
13821384 /* Exponential Smoother */
13831385 void tExpSmooth_init(tExpSmooth* const expsmooth, float val, float factor)
1384−{ // factor is usually a value between 0 and 0.1. Lower value is slower. 0.01 for example gives you a smoothing time of about 10ms
1386+{ // factor is usually a value between 0 and 0.1. Lower value is slower. 0.01 for example gives you a smoothing time of about 10ms
13851387 tExpSmooth_initToPool(expsmooth, val, factor, &leaf.mempool);
13861388 }
13871389
@@ -1407,34 +1409,34 @@ void tExpSmooth_free (tExpSmooth* const expsmooth) · 19 unmodified lines
14071409 }
14081410
14091411 void tExpSmooth_setFactor(tExpSmooth* const expsmooth, float factor)
1410−{ // factor is usually a value between 0 and 0.1. Lower value is slower. 0.01 for example gives you a smoothing time of about 10ms
1412+{ // factor is usually a value between 0 and 0.1. Lower value is slower. 0.01 for example gives you a smoothing time of about 10ms
14111413 _tExpSmooth* smooth = *expsmooth;
14121414
1413− if (factor<0)
1414− factor=0;
1415− else
1416− if (factor>1) factor=1;
1417− smooth->factor=factor;
1418− smooth->oneminusfactor=1.0f-factor;
1415+ if (factor<0)
1416+ factor=0;
1417+ else
1418+ if (factor>1) factor=1;
1419+ smooth->factor=factor;
1420+ smooth->oneminusfactor=1.0f-factor;
14191421 }
14201422
14211423 void tExpSmooth_setDest(tExpSmooth* const expsmooth, float dest)
14221424 {
14231425 _tExpSmooth* smooth = *expsmooth;
1424− smooth->dest=dest;
1426+ smooth->dest=dest;
14251427 }
14261428
14271429 void tExpSmooth_setVal(tExpSmooth* const expsmooth, float val)
14281430 {
14291431 _tExpSmooth* smooth = *expsmooth;
1430− smooth->curr=val;
1432+ smooth->curr=val;
14311433 }
14321434
14331435 void tExpSmooth_setValAndDest(tExpSmooth* const expsmooth, float val)
14341436 {
14351437 _tExpSmooth* smooth = *expsmooth;
1436− smooth->curr=val;
1437− smooth->dest=val;
1438+ smooth->curr=val;
1439+ smooth->dest=val;
14381440 }
14391441
14401442 float tExpSmooth_tick(tExpSmooth* const expsmooth)
@@ -1455,7 +1457,7 @@ float tExpSmooth_sample(tExpSmooth* const expsmooth) · 14 unmodified lines
14551457
14561458 void tSlide_init (tSlide* const sl, float upSlide, float downSlide)
14571459 {
1458− tSlide_initToPool (sl, upSlide, downSlide, &leaf.mempool);
1460+ tSlide_initToPool (sl, upSlide, downSlide, &leaf.mempool);
14591461 }
14601462
14611463 void tSlide_initToPool (tSlide* const sl, float upSlide, float downSlide, tMempool* const mp)
@@ -1470,12 +1472,12 @@ void tSlide_initToPool (tSlide* const sl, float upSlide, float downSlide, · 8 unmodified lines
14701472 s->dest = 0.0f;
14711473 if (upSlide < 1.0f)
14721474 {
1473− upSlide = 1.0f;
1475+ upSlide = 1.0f;
14741476 }
14751477
14761478 if (downSlide < 1.0f)
14771479 {
1478− downSlide = 1.0f;
1480+ downSlide = 1.0f;
14791481 }
14801482 s->invUpSlide = 1.0f / upSlide;
14811483 s->invDownSlide = 1.0f / downSlide;
@@ -1490,63 +1492,63 @@ void tSlide_free (tSlide* const sl) · 8 unmodified lines
14901492
14911493 void tSlide_setUpSlide(tSlide* const sl, float upSlide)
14921494 {
1493− _tSlide* s = *sl;
1494− s->invUpSlide = 1.0f / upSlide;
1495+ _tSlide* s = *sl;
1496+ s->invUpSlide = 1.0f / upSlide;
14951497 }
14961498
14971499 void tSlide_setDownSlide(tSlide* const sl, float downSlide)
14981500 {
1499− _tSlide* s = *sl;
1500− s->invDownSlide = 1.0f / downSlide;
1501+ _tSlide* s = *sl;
1502+ s->invDownSlide = 1.0f / downSlide;
15011503 }
15021504
15031505 void tSlide_setDest(tSlide* const sl, float dest)
15041506 {
1505− _tSlide* s = *sl;
1506− s->dest = dest;
1507+ _tSlide* s = *sl;
1508+ s->dest = dest;
15071509 }
15081510
15091511 float tSlide_tickNoInput(tSlide* const sl)
15101512 {
1511− _tSlide* s = *sl;
1512− float in = s->dest;
1513−
1514− if (in >= s->prevOut)
1515− {
1516− s->currentOut = s->prevOut + ((in - s->prevOut) * s->invUpSlide);
1517− }
1518− else
1519− {
1520− s->currentOut = s->prevOut + ((in - s->prevOut) * s->invDownSlide);
1521− }
1513+ _tSlide* s = *sl;
1514+ float in = s->dest;
1515+
1516+ if (in >= s->prevOut)
1517+ {
1518+ s->currentOut = s->prevOut + ((in - s->prevOut) * s->invUpSlide);
1519+ }
1520+ else
1521+ {
1522+ s->currentOut = s->prevOut + ((in - s->prevOut) * s->invDownSlide);
1523+ }
15221524 #ifdef NO_DENORMAL_CHECK
15231525 #else
1524− if (s->currentOut < VSF) s->currentOut = 0.0f;
1526+ if (s->currentOut < VSF) s->currentOut = 0.0f;
15251527 #endif
1526− s->prevIn = in;
1527− s->prevOut = s->currentOut;
1528− return s->currentOut;
1528+ s->prevIn = in;
1529+ s->prevOut = s->currentOut;
1530+ return s->currentOut;
15291531 }
15301532
15311533 float tSlide_tick(tSlide* const sl, float in)
15321534 {
1533− _tSlide* s = *sl;
1535+ _tSlide* s = *sl;
15341536
15351537
1536− if (in >= s->prevOut)
1537− {
1538− s->currentOut = s->prevOut + ((in - s->prevOut) * s->invUpSlide);
1539− }
1540− else
1541− {
1542− s->currentOut = s->prevOut + ((in - s->prevOut) * s->invDownSlide);
1543− }
1538+ if (in >= s->prevOut)
1539+ {
1540+ s->currentOut = s->prevOut + ((in - s->prevOut) * s->invUpSlide);
1541+ }
1542+ else
1543+ {
1544+ s->currentOut = s->prevOut + ((in - s->prevOut) * s->invDownSlide);
1545+ }
15441546 #ifdef NO_DENORMAL_CHECK
15451547 #else
1546− if (s->currentOut < VSF) s->currentOut = 0.0f;
1548+ if (s->currentOut < VSF) s->currentOut = 0.0f;
15471549 #endif
1548− s->prevIn = in;
1549− s->prevOut = s->currentOut;
1550− return s->currentOut;
1550+ s->prevIn = in;
1551+ s->prevOut = s->currentOut;
1552+ return s->currentOut;
15511553 }
15521554
leaf/Src/leaf-filters.c+309−309
@@ -1075,7 +1075,7 @@ void tButterworth_setFreqs(tButterworth* const ft, float f1, float f2) · 1074 unmodified lines
10751075 }
10761076 }
10771077
1078−void tFIR_init(tFIR* const firf, float* coeffs, int numTaps)
1078+void tFIR_init(tFIR* const firf, float* coeffs, int numTaps)
10791079 {
10801080 tFIR_initToPool(firf, coeffs, numTaps, &leaf.mempool);
10811081 }
@@ -1100,15 +1100,15 @@ void tFIR_free (tFIR* const firf) · 18 unmodified lines
11001100 mpool_free((char*)fir, fir->mempool);
11011101 }
11021102
1103−float tFIR_tick(tFIR* const firf, float input)
1103+float tFIR_tick(tFIR* const firf, float input)
11041104 {
11051105 _tFIR* fir = *firf;
11061106
1107− fir->past[0] = input;
1108− float y = 0.0f;
1109− for (int i = 0; i < fir->numTaps; ++i) y += fir->past[i]*fir->coeff[i];
1110− for (int i = fir->numTaps-1; i > 0; --i) fir->past[i] = fir->past[i-1];
1111− return y;
1107+ fir->past[0] = input;
1108+ float y = 0.0f;
1109+ for (int i = 0; i < fir->numTaps; ++i) y += fir->past[i]*fir->coeff[i];
1110+ for (int i = fir->numTaps-1; i > 0; --i) fir->past[i] = fir->past[i-1];
1111+ return y;
11121112 }
11131113
11141114 //---------------------------------------------
@@ -1119,7 +1119,7 @@ float tFIR_tick(tFIR* const firf, float input) · 4 unmodified lines
11191119
11201120 void tMedianFilter_init (tMedianFilter* const f, int size)
11211121 {
1122− tMedianFilter_initToPool(f, size, &leaf.mempool);
1122+ tMedianFilter_initToPool(f, size, &leaf.mempool);
11231123 }
11241124
11251125 void tMedianFilter_initToPool (tMedianFilter* const mf, int size, tMempool* const mp)
@@ -1130,15 +1130,15 @@ void tMedianFilter_initToPool (tMedianFilter* const mf, int size, tMempoo · 4 unmodified lines
11301130
11311131 f->size = size;
11321132 f->middlePosition = size / 2;
1133− f->last = size - 1;
1134− f->pos = -1;
1133+ f->last = size - 1;
1134+ f->pos = -1;
11351135 f->val = (float*) mpool_alloc(sizeof(float) * size, m);
11361136 f->age = (int*) mpool_alloc(sizeof(int) * size, m);
11371137 for (int i = 0; i < f->size; ++i)
1138− {
1139− f->val[i] = 0.0f;
1140− f->age[i] = i;
1141− }
1138+ {
1139+ f->val[i] = 0.0f;
1140+ f->age[i] = i;
1141+ }
11421142
11431143 }
11441144 void tMedianFilter_free (tMedianFilter* const mf)
@@ -1152,48 +1152,48 @@ void tMedianFilter_free (tMedianFilter* const mf) · 7 unmodified lines
11521152
11531153 float tMedianFilter_tick (tMedianFilter* const mf, float input)
11541154 {
1155− _tMedianFilter* f = *mf;
1156−
1157− for(int i=0; i<f->size; i++) {
1158− int thisAge = f->age[i];
1159− if(thisAge == f->last) {
1160− f->pos = i;
1161− }
1162− else {
1163− thisAge++;
1164− f->age[i] = thisAge;
1165− }
1166− }
1167−
1168− while( f->pos!=0 ) {
1169− float test = f->val[f->pos-1];
1170− if(input < test) {
1171− f->val[f->pos]=test;
1172− f->age[f->pos]=f->age[f->pos-1];
1173− f->pos -= 1;
1174− } else {break;}
1175− }
1176−
1177− while(f->pos != f->last) {
1178− float test = f->val[f->pos+1];
1179− if( input > test) {
1180− f->val[f->pos] = test;
1181− f->age[f->pos] = f->age[f->pos+1];
1182− f->pos += 1;
1183− } else {break;}
1184− }
1185−
1186− f->val[f->pos] = input;
1187− f->age[f->pos] = 0;
1188−
1189− return f->val[f->middlePosition];
1155+ _tMedianFilter* f = *mf;
1156+
1157+ for(int i=0; i<f->size; i++) {
1158+ int thisAge = f->age[i];
1159+ if(thisAge == f->last) {
1160+ f->pos = i;
1161+ }
1162+ else {
1163+ thisAge++;
1164+ f->age[i] = thisAge;
1165+ }
1166+ }
1167+
1168+ while( f->pos!=0 ) {
1169+ float test = f->val[f->pos-1];
1170+ if(input < test) {
1171+ f->val[f->pos]=test;
1172+ f->age[f->pos]=f->age[f->pos-1];
1173+ f->pos -= 1;
1174+ } else {break;}
1175+ }
1176+
1177+ while(f->pos != f->last) {
1178+ float test = f->val[f->pos+1];
1179+ if( input > test) {
1180+ f->val[f->pos] = test;
1181+ f->age[f->pos] = f->age[f->pos+1];
1182+ f->pos += 1;
1183+ } else {break;}
1184+ }
1185+
1186+ f->val[f->pos] = input;
1187+ f->age[f->pos] = 0;
1188+
1189+ return f->val[f->middlePosition];
11901190 }
11911191
11921192 /////
11931193
11941194 void tVZFilter_init (tVZFilter* const vf, VZFilterType type, float freq, float bandWidth)
11951195 {
1196− tVZFilter_initToPool(vf, type, freq, bandWidth, &leaf.mempool);
1196+ tVZFilter_initToPool(vf, type, freq, bandWidth, &leaf.mempool);
11971197 }
11981198
11991199 void tVZFilter_initToPool (tVZFilter* const vf, VZFilterType type, float freq, float bandWidth, tMempool* const mp)
@@ -1202,17 +1202,17 @@ void tVZFilter_initToPool (tVZFilter* const vf, VZFilterType type, float · 2 unmodified lines
12021202 _tVZFilter* f = *vf = (_tVZFilter*) mpool_alloc(sizeof(_tVZFilter), m);
12031203 f->mempool = m;
12041204
1205− f->fc = freq;
1206− f->type = type;
1207− f->G = ONE_OVER_SQRT2;
1208− f->invG = 1.0f/ONE_OVER_SQRT2;
1209− f->B = bandWidth;
1210− f->m = 0.0f;
1211− f->s1 = 0.0f;
1212− f->s2 = 0.0f;
1213− f->sr = leaf.sampleRate;
1214− f->inv_sr = leaf.invSampleRate;
1215− tVZFilter_calcCoeffs(vf);
1205+ f->fc = freq;
1206+ f->type = type;
1207+ f->G = ONE_OVER_SQRT2;
1208+ f->invG = 1.0f/ONE_OVER_SQRT2;
1209+ f->B = bandWidth;
1210+ f->m = 0.0f;
1211+ f->s1 = 0.0f;
1212+ f->s2 = 0.0f;
1213+ f->sr = leaf.sampleRate;
1214+ f->inv_sr = leaf.invSampleRate;
1215+ tVZFilter_calcCoeffs(vf);
12161216 }
12171217
12181218 void tVZFilter_free (tVZFilter* const vf)
@@ -1221,103 +1221,103 @@ void tVZFilter_free (tVZFilter* const vf) · 2 unmodified lines
12211221 mpool_free((char*)f, f->mempool);
12221222 }
12231223
1224−void tVZFilter_setSampleRate (tVZFilter* const vf, float sampleRate)
1224+void tVZFilter_setSampleRate (tVZFilter* const vf, float sampleRate)
12251225 {
1226− _tVZFilter* f = *vf;
1227− f->sr = sampleRate;
1228− f->inv_sr = 1.0f/sampleRate;
1226+ _tVZFilter* f = *vf;
1227+ f->sr = sampleRate;
1228+ f->inv_sr = 1.0f/sampleRate;
12291229 }
12301230
1231−float tVZFilter_tick (tVZFilter* const vf, float in)
1231+float tVZFilter_tick (tVZFilter* const vf, float in)
12321232 {
1233− _tVZFilter* f = *vf;
1233+ _tVZFilter* f = *vf;
12341234
1235− float yL, yB, yH;
1235+ float yL, yB, yH;
12361236
1237− // compute highpass output via Eq. 5.1:
1238− yH = (in - f->R2*f->s1 - f->g*f->s1 - f->s2) * f->h;
1237+ // compute highpass output via Eq. 5.1:
1238+ yH = (in - f->R2*f->s1 - f->g*f->s1 - f->s2) * f->h;
12391239
1240− // compute bandpass output by applying 1st integrator to highpass output:
1241− yB = tanhf(f->g*yH) + f->s1;
1242− f->s1 = f->g*yH + yB; // state update in 1st integrator
1240+ // compute bandpass output by applying 1st integrator to highpass output:
1241+ yB = tanhf(f->g*yH) + f->s1;
1242+ f->s1 = f->g*yH + yB; // state update in 1st integrator
12431243
1244− // compute lowpass output by applying 2nd integrator to bandpass output:
1245− yL = tanhf(f->g*yB) + f->s2;
1246− f->s2 = f->g*yB + yL; // state update in 2nd integrator
1244+ // compute lowpass output by applying 2nd integrator to bandpass output:
1245+ yL = tanhf(f->g*yB) + f->s2;
1246+ f->s2 = f->g*yB + yL; // state update in 2nd integrator
12471247
1248− //according to the Vadim paper, we could add saturation to this model by adding a tanh in the integration stage.
1249− //
1250− //seems like that might look like this:
1248+ //according to the Vadim paper, we could add saturation to this model by adding a tanh in the integration stage.
1249+ //
1250+ //seems like that might look like this:
12511251 // y = tanh(g*x) + s; // output computation
12521252 // s = g*x + y; // state update
12531253
1254− //instead of this:
1254+ //instead of this:
12551255 // y = g*x + s; // output computation
12561256 // s = g*x + y; // state update
12571257
1258− return f->cL*yL + f->cB*yB + f->cH*yH;
1258+ return f->cL*yL + f->cB*yB + f->cH*yH;
12591259
12601260 }
12611261
1262−float tVZFilter_tickEfficient (tVZFilter* const vf, float in)
1262+float tVZFilter_tickEfficient (tVZFilter* const vf, float in)
12631263 {
1264− _tVZFilter* f = *vf;
1264+ _tVZFilter* f = *vf;
12651265
1266− float yL, yB, yH;
1266+ float yL, yB, yH;
12671267
1268− // compute highpass output via Eq. 5.1:
1269− yH = (in - f->R2*f->s1 - f->g*f->s1 - f->s2) * f->h;
1268+ // compute highpass output via Eq. 5.1:
1269+ yH = (in - f->R2*f->s1 - f->g*f->s1 - f->s2) * f->h;
12701270
1271− // compute bandpass output by applying 1st integrator to highpass output:
1272− yB = (f->g*yH) + f->s1;
1273− f->s1 = f->g*yH + yB; // state update in 1st integrator
1271+ // compute bandpass output by applying 1st integrator to highpass output:
1272+ yB = (f->g*yH) + f->s1;
1273+ f->s1 = f->g*yH + yB; // state update in 1st integrator
12741274
1275− // compute lowpass output by applying 2nd integrator to bandpass output:
1276− yL = (f->g*yB) + f->s2;
1277− f->s2 = f->g*yB + yL; // state update in 2nd integrator
1275+ // compute lowpass output by applying 2nd integrator to bandpass output:
1276+ yL = (f->g*yB) + f->s2;
1277+ f->s2 = f->g*yB + yL; // state update in 2nd integrator
12781278
1279− //according to the Vadim paper, we could add saturation to this model by adding a tanh in the integration stage.
1280− //
1281− //seems like that might look like this:
1279+ //according to the Vadim paper, we could add saturation to this model by adding a tanh in the integration stage.
1280+ //
1281+ //seems like that might look like this:
12821282 // y = tanh(g*x) + s; // output computation
12831283 // s = g*x + y; // state update
12841284
1285− //instead of this:
1285+ //instead of this:
12861286 // y = g*x + s; // output computation
12871287 // s = g*x + y; // state update
12881288
1289− return f->cL*yL + f->cB*yB + f->cH*yH;
1289+ return f->cL*yL + f->cB*yB + f->cH*yH;
12901290
12911291 }
12921292
1293−float tVZFilter_tickEfficientBP (tVZFilter* const vf, float in)
1293+float tVZFilter_tickEfficientBP (tVZFilter* const vf, float in)
12941294 {
1295− _tVZFilter* f = *vf;
1295+ _tVZFilter* f = *vf;
12961296
1297− float yL, yB, yH;
1297+ float yL, yB, yH;
12981298
1299− // compute highpass output via Eq. 5.1:
1300− yH = (in - f->R2*f->s1 - f->g*f->s1 - f->s2) * f->h;
1299+ // compute highpass output via Eq. 5.1:
1300+ yH = (in - f->R2*f->s1 - f->g*f->s1 - f->s2) * f->h;
13011301
1302− // compute bandpass output by applying 1st integrator to highpass output:
1303− yB = (f->g*yH) + f->s1;
1304− f->s1 = f->g*yH + yB; // state update in 1st integrator
1302+ // compute bandpass output by applying 1st integrator to highpass output:
1303+ yB = (f->g*yH) + f->s1;
1304+ f->s1 = f->g*yH + yB; // state update in 1st integrator
13051305
1306− // compute lowpass output by applying 2nd integrator to bandpass output:
1307− yL = (f->g*yB) + f->s2;
1308− f->s2 = f->g*yB + yL; // state update in 2nd integrator
1306+ // compute lowpass output by applying 2nd integrator to bandpass output:
1307+ yL = (f->g*yB) + f->s2;
1308+ f->s2 = f->g*yB + yL; // state update in 2nd integrator
13091309
1310− //according to the Vadim paper, we could add saturation to this model by adding a tanh in the integration stage.
1311− //
1312− //seems like that might look like this:
1310+ //according to the Vadim paper, we could add saturation to this model by adding a tanh in the integration stage.
1311+ //
1312+ //seems like that might look like this:
13131313 // y = tanh(g*x) + s; // output computation
13141314 // s = g*x + y; // state update
13151315
1316− //instead of this:
1316+ //instead of this:
13171317 // y = g*x + s; // output computation
13181318 // s = g*x + y; // state update
13191319
1320− return f->cL*yL + f->cB*yB + f->cH*yH;
1320+ return f->cL*yL + f->cB*yB + f->cH*yH;
13211321
13221322 }
13231323
@@ -1325,159 +1325,159 @@ float tVZFilter_tickEfficientBP (tVZFilter* const vf, float in) · 1 unmodified line
13251325 void tVZFilter_calcCoeffs (tVZFilter* const vf)
13261326 {
13271327
1328− _tVZFilter* f = *vf;
1329− f->g = tanf(PI * f->fc * f->inv_sr); // embedded integrator gain (Fig 3.11)
1330−
1331− switch( f->type )
1332− {
1333− case Bypass:
1334− {
1335− f->R2 = f->invG; // can we use an arbitrary value here, for example R2 = 1?
1336− f->cL = 1.0f;
1337− f->cB = f->R2;
1338− f->cH = 1.0f;
1339− }
1340− break;
1341− case Lowpass:
1342− {
1343− f->R2 = f->invG;
1344− f->cL = 1.0f; f->cB = 0.0f; f->cH = 0.0f;
1345− }
1346− break;
1347− case Highpass:
1348− {
1349− f->R2 = f->invG;
1350− f->cL = 0.0f; f->cB = 0.0f; f->cH = 1.0f;
1351− }
1352− break;
1353− case BandpassSkirt:
1354− {
1355− f->R2 = f->invG;
1356− f->cL = 0.0f; f->cB = 1.0f; f->cH = 0.0f;
1357− }
1358− break;
1359− case BandpassPeak:
1360− {
1361− f->R2 = 2.0f*tVZFilter_BandwidthToR(vf, f->B);
1362− f->cL = 0.0f; f->cB = f->R2; f->cH = 0.0f;
1363− }
1364− break;
1365− case BandReject:
1366− {
1367− f->R2 = 2.0f*tVZFilter_BandwidthToR(vf, f->B);
1368− f->cL = 1.0f; f->cB = 0.0f; f->cH = 1.0f;
1369− }
1370− break;
1371− case Bell:
1372− {
1373− float fl = f->fc*powf(2.0f, (-f->B)*0.5f); // lower bandedge frequency (in Hz)
1374− float wl = tanf(PI*fl*f->inv_sr); // warped radian lower bandedge frequency /(2*fs)
1375− float r = f->g/wl;
1376− r *= r; // warped frequency ratio wu/wl == (wc/wl)^2 where wu is the
1377− // warped upper bandedge, wc the center
1378− f->R2 = 2.0f*sqrtf(((r*r+1.0f)/r-2.0f)/(4.0f*f->G));
1379− f->cL = 1.0f; f->cB = f->R2*f->G; f->cH = 1.0f;
1380− }
1381− break;
1382− case Lowshelf:
1383− {
1384− float A = sqrtf(f->G);
1385− f->g /= sqrtf(A); // scale SVF-cutoff frequency for shelvers
1386− f->R2 = 2*sinhf(f->B*logf(2.0f)*0.5f);
1387− f->cL = f->G; f->cB = f->R2*A; f->cH = 1.0f;
1388− }
1389− break;
1390− case Highshelf:
1391− {
1392− float A = sqrtf(f->G);
1393− f->g *= sqrtf(A); // scale SVF-cutoff frequency for shelvers
1394− f->R2 = 2.0f*sinhf(f->B*logf(2.0f)*0.5f);
1395− f->cL = 1.0f; f->cB = f->R2*A; f->cH = f->G;
1396− }
1397− break;
1398− case Allpass:
1399− {
1400− f->R2 = 2.0f*tVZFilter_BandwidthToR(vf, f->B);
1401− f->cL = 1.0f; f->cB = -f->R2; f->cH = 1.0f;
1402− }
1403− break;
1404−
1405− // experimental - maybe we must find better curves for cL, cB, cH:
1406− case Morph:
1407− {
1408− f->R2 = f->invG;
1409− float x = 2.0f*f->m-1.0f;
1410−
1411− f->cL = maximum(-x, 0.0f); /*cL *= cL;*/
1412− f->cH = minimum( x, 0.0f); /*cH *= cH;*/
1413− f->cB = 1.0f-x*x;
1414−
1415− // bottom line: we need to test different versions for how they feel when tweaking the
1416− // morph parameter
1417−
1418− // this scaling ensures constant magnitude at the cutoff point (we divide the coefficients by
1419− // the magnitude response value at the cutoff frequency and scale back by the gain):
1420− float s = f->G * sqrtf((f->R2*f->R2) / (f->cL*f->cL + f->cB*f->cB + f->cH*f->cH - 2.0f*f->cL*f->cH));
1421− f->cL *= s; f->cB *= s; f->cH *= s;
1422− }
1423− break;
1424−
1425− }
1426−
1427− f->h = 1.0f / (1.0f + f->R2*f->g + f->g*f->g); // factor for feedback precomputation
1428−}
1429−
1430−
1431−void tVZFilter_setBandwidth (tVZFilter* const vf, float B)
1432−{
1433− _tVZFilter* f = *vf;
1434− f->B = LEAF_clip(0.0f, B, 100.0f);
1435− tVZFilter_calcCoeffs(vf);
1328+ _tVZFilter* f = *vf;
1329+ f->g = tanf(PI * f->fc * f->inv_sr); // embedded integrator gain (Fig 3.11)
1330+
1331+ switch( f->type )
1332+ {
1333+ case Bypass:
1334+ {
1335+ f->R2 = f->invG; // can we use an arbitrary value here, for example R2 = 1?
1336+ f->cL = 1.0f;
1337+ f->cB = f->R2;
1338+ f->cH = 1.0f;
1339+ }
1340+ break;
1341+ case Lowpass:
1342+ {
1343+ f->R2 = f->invG;
1344+ f->cL = 1.0f; f->cB = 0.0f; f->cH = 0.0f;
1345+ }
1346+ break;
1347+ case Highpass:
1348+ {
1349+ f->R2 = f->invG;
1350+ f->cL = 0.0f; f->cB = 0.0f; f->cH = 1.0f;
1351+ }
1352+ break;
1353+ case BandpassSkirt:
1354+ {
1355+ f->R2 = f->invG;
1356+ f->cL = 0.0f; f->cB = 1.0f; f->cH = 0.0f;
1357+ }
1358+ break;
1359+ case BandpassPeak:
1360+ {
1361+ f->R2 = 2.0f*tVZFilter_BandwidthToR(vf, f->B);
1362+ f->cL = 0.0f; f->cB = f->R2; f->cH = 0.0f;
1363+ }
1364+ break;
1365+ case BandReject:
1366+ {
1367+ f->R2 = 2.0f*tVZFilter_BandwidthToR(vf, f->B);
1368+ f->cL = 1.0f; f->cB = 0.0f; f->cH = 1.0f;
1369+ }
1370+ break;
1371+ case Bell:
1372+ {
1373+ float fl = f->fc*powf(2.0f, (-f->B)*0.5f); // lower bandedge frequency (in Hz)
1374+ float wl = tanf(PI*fl*f->inv_sr); // warped radian lower bandedge frequency /(2*fs)
1375+ float r = f->g/wl;
1376+ r *= r; // warped frequency ratio wu/wl == (wc/wl)^2 where wu is the
1377+ // warped upper bandedge, wc the center
1378+ f->R2 = 2.0f*sqrtf(((r*r+1.0f)/r-2.0f)/(4.0f*f->G));
1379+ f->cL = 1.0f; f->cB = f->R2*f->G; f->cH = 1.0f;
1380+ }
1381+ break;
1382+ case Lowshelf:
1383+ {
1384+ float A = sqrtf(f->G);
1385+ f->g /= sqrtf(A); // scale SVF-cutoff frequency for shelvers
1386+ f->R2 = 2*sinhf(f->B*logf(2.0f)*0.5f);
1387+ f->cL = f->G; f->cB = f->R2*A; f->cH = 1.0f;
1388+ }
1389+ break;
1390+ case Highshelf:
1391+ {
1392+ float A = sqrtf(f->G);
1393+ f->g *= sqrtf(A); // scale SVF-cutoff frequency for shelvers
1394+ f->R2 = 2.0f*sinhf(f->B*logf(2.0f)*0.5f);
1395+ f->cL = 1.0f; f->cB = f->R2*A; f->cH = f->G;
1396+ }
1397+ break;
1398+ case Allpass:
1399+ {
1400+ f->R2 = 2.0f*tVZFilter_BandwidthToR(vf, f->B);
1401+ f->cL = 1.0f; f->cB = -f->R2; f->cH = 1.0f;
1402+ }
1403+ break;
1404+
1405+ // experimental - maybe we must find better curves for cL, cB, cH:
1406+ case Morph:
1407+ {
1408+ f->R2 = f->invG;
1409+ float x = 2.0f*f->m-1.0f;
1410+
1411+ f->cL = maximum(-x, 0.0f); /*cL *= cL;*/
1412+ f->cH = minimum( x, 0.0f); /*cH *= cH;*/
1413+ f->cB = 1.0f-x*x;
1414+
1415+ // bottom line: we need to test different versions for how they feel when tweaking the
1416+ // morph parameter
1417+
1418+ // this scaling ensures constant magnitude at the cutoff point (we divide the coefficients by
1419+ // the magnitude response value at the cutoff frequency and scale back by the gain):
1420+ float s = f->G * sqrtf((f->R2*f->R2) / (f->cL*f->cL + f->cB*f->cB + f->cH*f->cH - 2.0f*f->cL*f->cH));
1421+ f->cL *= s; f->cB *= s; f->cH *= s;
1422+ }
1423+ break;
1424+
1425+ }
1426+
1427+ f->h = 1.0f / (1.0f + f->R2*f->g + f->g*f->g); // factor for feedback precomputation
1428+}
1429+
1430+
1431+void tVZFilter_setBandwidth (tVZFilter* const vf, float B)
1432+{
1433+ _tVZFilter* f = *vf;
1434+ f->B = LEAF_clip(0.0f, B, 100.0f);
1435+ tVZFilter_calcCoeffs(vf);
14361436 }
14371437 void tVZFilter_setFreq (tVZFilter* const vf, float freq)
14381438 {
1439− _tVZFilter* f = *vf;
1440− f->fc = LEAF_clip(0.0f, freq, 0.5f*leaf.sampleRate);
1441− tVZFilter_calcCoeffs(vf);
1439+ _tVZFilter* f = *vf;
1440+ f->fc = LEAF_clip(0.0f, freq, 0.5f*leaf.sampleRate);
1441+ tVZFilter_calcCoeffs(vf);
14421442 }
14431443 void tVZFilter_setFreqAndBandwidth (tVZFilter* const vf, float freq, float bw)
14441444 {
1445− _tVZFilter* f = *vf;
1446− f->B = LEAF_clip(0.0f,bw, 100.0f);
1447− f->fc = LEAF_clip(0.0f, freq, 0.5f*leaf.sampleRate);
1448− tVZFilter_calcCoeffs(vf);
1445+ _tVZFilter* f = *vf;
1446+ f->B = LEAF_clip(0.0f,bw, 100.0f);
1447+ f->fc = LEAF_clip(0.0f, freq, 0.5f*leaf.sampleRate);
1448+ tVZFilter_calcCoeffs(vf);
14491449 }
14501450
1451−void tVZFilter_setGain (tVZFilter* const vf, float gain)
1451+void tVZFilter_setGain (tVZFilter* const vf, float gain)
14521452 {
1453− _tVZFilter* f = *vf;
1454− f->G = LEAF_clip(0.000001f, gain, 100.0f);
1455− f->invG = 1.0f/f->G;
1456− tVZFilter_calcCoeffs(vf);
1453+ _tVZFilter* f = *vf;
1454+ f->G = LEAF_clip(0.000001f, gain, 100.0f);
1455+ f->invG = 1.0f/f->G;
1456+ tVZFilter_calcCoeffs(vf);
14571457 }
14581458
1459−void tVZFilter_setMorph (tVZFilter* const vf, float morph)
1459+void tVZFilter_setMorph (tVZFilter* const vf, float morph)
14601460 {
1461− _tVZFilter* f = *vf;
1462− f->m = LEAF_clip(0.0f, morph, 1.0f);
1463− tVZFilter_calcCoeffs(vf);
1461+ _tVZFilter* f = *vf;
1462+ f->m = LEAF_clip(0.0f, morph, 1.0f);
1463+ tVZFilter_calcCoeffs(vf);
14641464 }
14651465
1466−void tVZFilter_setType (tVZFilter* const vf, VZFilterType type)
1466+void tVZFilter_setType (tVZFilter* const vf, VZFilterType type)
14671467 {
1468− _tVZFilter* f = *vf;
1469− f->type = type;
1470− tVZFilter_calcCoeffs(vf);
1468+ _tVZFilter* f = *vf;
1469+ f->type = type;
1470+ tVZFilter_calcCoeffs(vf);
14711471 }
14721472
14731473 float tVZFilter_BandwidthToR(tVZFilter* const vf, float B)
14741474 {
1475− _tVZFilter* f = *vf;
1475+ _tVZFilter* f = *vf;
14761476 float fl = f->fc*powf(2.0f, -B*0.5f); // lower bandedge frequency (in Hz)
14771477 float gl = tanf(PI*fl*f->inv_sr); // warped radian lower bandedge frequency /(2*fs)
14781478 float r = gl/f->g; // ratio between warped lower bandedge- and center-frequencies
1479− // unwarped: r = pow(2, -B/2) -> approximation for low
1480− // center-frequencies
1479+ // unwarped: r = pow(2, -B/2) -> approximation for low
1480+ // center-frequencies
14811481 return sqrtf((1.0f-r*r)*(1.0f-r*r)/(4.0f*r*r));
14821482 }
14831483
@@ -1485,29 +1485,29 @@ float tVZFilter_BandwidthToR(tVZFilter* const vf, float B) · 1 unmodified line
14851485
14861486 void tDiodeFilter_init (tDiodeFilter* const vf, float cutoff, float resonance)
14871487 {
1488− tDiodeFilter_initToPool(vf, cutoff, resonance, &leaf.mempool);
1488+ tDiodeFilter_initToPool(vf, cutoff, resonance, &leaf.mempool);
14891489 }
14901490
14911491 void tDiodeFilter_initToPool (tDiodeFilter* const vf, float cutoff, float resonance, tMempool* const mp)
14921492 {
1493− _tMempool* m = *mp;
1494− _tDiodeFilter* f = *vf = (_tDiodeFilter*) mpool_alloc(sizeof(_tDiodeFilter), m);
1493+ _tMempool* m = *mp;
1494+ _tDiodeFilter* f = *vf = (_tDiodeFilter*) mpool_alloc(sizeof(_tDiodeFilter), m);
14951495 f->mempool = m;
14961496
1497− // initialization (the resonance factor is between 0 and 8 according to the article)
1498− f->f = tan(PI * cutoff/leaf.sampleRate);
1499− f->r = (7.f * resonance + 0.5f);
1500− f->Vt = 0.5f;
1501− f->n = 1.836f;
1502− f->zi = 0.0f; //previous input value
1503− f->gamma = f->Vt*f->n;
1504− f->s0 = 0.01f;
1505− f->s1 = 0.02f;
1506− f->s2 = 0.03f;
1507− f->s3 = 0.04f;
1508− f->g0inv = 1.f/(2.f*f->Vt);
1509− f->g1inv = 1.f/(2.f*f->gamma);
1510− f->g2inv = 1.f/(6.f*f->gamma);
1497+ // initialization (the resonance factor is between 0 and 8 according to the article)
1498+ f->f = (float)tan((double)(PI * cutoff/leaf.sampleRate));
1499+ f->r = (7.f * resonance + 0.5f);
1500+ f->Vt = 0.5f;
1501+ f->n = 1.836f;
1502+ f->zi = 0.0f; //previous input value
1503+ f->gamma = f->Vt*f->n;
1504+ f->s0 = 0.01f;
1505+ f->s1 = 0.02f;
1506+ f->s2 = 0.03f;
1507+ f->s3 = 0.04f;
1508+ f->g0inv = 1.f/(2.f*f->Vt);
1509+ f->g1inv = 1.f/(2.f*f->gamma);
1510+ f->g2inv = 1.f/(6.f*f->gamma);
15111511 }
15121512
15131513 void tDiodeFilter_free (tDiodeFilter* const vf)
@@ -1523,63 +1523,63 @@ float tanhXdX(float x) · 9 unmodified lines
15231523 return ((a + 105.0f)*a + 945.0f) / ((15.0f*a + 420.0f)*a + 945.0f);
15241524 }
15251525
1526−float tDiodeFilter_tick (tDiodeFilter* const vf, float in)
1526+float tDiodeFilter_tick (tDiodeFilter* const vf, float in)
15271527 {
1528− _tDiodeFilter* f = *vf;
1528+ _tDiodeFilter* f = *vf;
15291529
1530− // the input x[n+1] is given by 'in', and x[n] by zi
1531− // input with half delay
1532− float ih = 0.5f * (in + f->zi);
1530+ // the input x[n+1] is given by 'in', and x[n] by zi
1531+ // input with half delay
1532+ float ih = 0.5f * (in + f->zi);
15331533
1534− // evaluate the non-linear factors
1535− float t0 = f->f*tanhXdX((ih - f->r * f->s3)*f->g0inv)*f->g0inv;
1536− float t1 = f->f*tanhXdX((f->s1-f->s0)*f->g1inv)*f->g1inv;
1537− float t2 = f->f*tanhXdX((f->s2-f->s1)*f->g1inv)*f->g1inv;
1538− float t3 = f->f*tanhXdX((f->s3-f->s2)*f->g1inv)*f->g1inv;
1539− float t4 = f->f*tanhXdX((f->s3)*f->g2inv)*f->g2inv;
1534+ // evaluate the non-linear factors
1535+ float t0 = f->f*tanhXdX((ih - f->r * f->s3)*f->g0inv)*f->g0inv;
1536+ float t1 = f->f*tanhXdX((f->s1-f->s0)*f->g1inv)*f->g1inv;
1537+ float t2 = f->f*tanhXdX((f->s2-f->s1)*f->g1inv)*f->g1inv;
1538+ float t3 = f->f*tanhXdX((f->s3-f->s2)*f->g1inv)*f->g1inv;
1539+ float t4 = f->f*tanhXdX((f->s3)*f->g2inv)*f->g2inv;
15401540
15411541
15421542
1543− // This formula gives the result for y3 thanks to MATLAB
1544− float y3 = (f->s2 + f->s3 + t2*(f->s1 + f->s2 + f->s3 + t1*(f->s0 + f->s1 + f->s2 + f->s3 + t0*in)) + t1*(2.0f*f->s2 + 2.0f*f->s3))*t3 + f->s3 + 2.0f*f->s3*t1 + t2*(2.0f*f->s3 + 3.0f*f->s3*t1);
1543+ // This formula gives the result for y3 thanks to MATLAB
1544+ float y3 = (f->s2 + f->s3 + t2*(f->s1 + f->s2 + f->s3 + t1*(f->s0 + f->s1 + f->s2 + f->s3 + t0*in)) + t1*(2.0f*f->s2 + 2.0f*f->s3))*t3 + f->s3 + 2.0f*f->s3*t1 + t2*(2.0f*f->s3 + 3.0f*f->s3*t1);
15451545 // if (isnan(y3))
15461546 // {
15471547 // __HAL_TIM_SET_COMPARE(&htim3, TIM_CHANNEL_2, 400);
15481548 // }
1549− float tempy3denom = (t4 + t1*(2.0f*t4 + 4.0f) + t2*(t4 + t1*(t4 + f->r*t0 + 4.0f) + 3.0f) + 2.0f)*t3 + t4 + t1*(2.0f*t4 + 2.0f) + t2*(2.0f*t4 + t1*(3.0f*t4 + 3.0f) + 2.0f) + 1.0f;
1549+ float tempy3denom = (t4 + t1*(2.0f*t4 + 4.0f) + t2*(t4 + t1*(t4 + f->r*t0 + 4.0f) + 3.0f) + 2.0f)*t3 + t4 + t1*(2.0f*t4 + 2.0f) + t2*(2.0f*t4 + t1*(3.0f*t4 + 3.0f) + 2.0f) + 1.0f;
15501550 // if (isnan(tempy3denom))
15511551 // {
15521552 // __HAL_TIM_SET_COMPARE(&htim3, TIM_CHANNEL_2, 400);
15531553 // }
1554− if (tempy3denom == 0.0f)
1555− {
1556− tempy3denom = 0.000001f;
1557− }
1558− y3 = y3 / tempy3denom;
1554+ if (tempy3denom == 0.0f)
1555+ {
1556+ tempy3denom = 0.000001f;
1557+ }
1558+ y3 = y3 / tempy3denom;
15591559 // if (isnan(y3))
15601560 // {
15611561 // __HAL_TIM_SET_COMPARE(&htim3, TIM_CHANNEL_2, 400);
15621562 // }
1563− if (t1 == 0.0f)
1564− {
1565− t1 = 0.000001f;
1566− }
1567− if (t2 == 0.0f)
1568− {
1569− t2 = 0.000001f;
1570− }
1571− if (t3 == 0.0f)
1572− {
1573− t3 = 0.000001f;
1574− }
1575− // Other outputs
1576− float y2 = (f->s3 - (1+t4+t3)*y3) / (-t3);
1577− float y1 = (f->s2 - (1+t3+t2)*y2 + t3*y3) / (-t2);
1578− float y0 = (f->s1 - (1+t2+t1)*y1 + t2*y2) / (-t1);
1579− float xx = (in - f->r*y3);
1580−
1581− // update state
1582− f->s0 += 2.0f * (t0*xx + t1*(y1-y0));
1563+ if (t1 == 0.0f)
1564+ {
1565+ t1 = 0.000001f;
1566+ }
1567+ if (t2 == 0.0f)
1568+ {
1569+ t2 = 0.000001f;
1570+ }
1571+ if (t3 == 0.0f)
1572+ {
1573+ t3 = 0.000001f;
1574+ }
1575+ // Other outputs
1576+ float y2 = (f->s3 - (1+t4+t3)*y3) / (-t3);
1577+ float y1 = (f->s2 - (1+t3+t2)*y2 + t3*y3) / (-t2);
1578+ float y0 = (f->s1 - (1+t2+t1)*y1 + t2*y2) / (-t1);
1579+ float xx = (in - f->r*y3);
1580+
1581+ // update state
1582+ f->s0 += 2.0f * (t0*xx + t1*(y1-y0));
15831583 // if (isnan(f->s0))
15841584 // {
15851585 // __HAL_TIM_SET_COMPARE(&htim3, TIM_CHANNEL_2, 400);
@@ -1589,12 +1589,12 @@ float tDiodeFilter_tick (tDiodeFilter* const vf, float in) · 3 unmodified lines
15891589 // {
15901590 // __HAL_TIM_SET_COMPARE(&htim3, TIM_CHANNEL_2, 400);
15911591 // }
1592− f->s1 += 2.0f * (t2*(y2-y1) - t1*(y1-y0));
1593− f->s2 += 2.0f * (t3*(y3-y2) - t2*(y2-y1));
1594− f->s3 += 2.0f * (-t4*(y3) - t3*(y3-y2));
1592+ f->s1 += 2.0f * (t2*(y2-y1) - t1*(y1-y0));
1593+ f->s2 += 2.0f * (t3*(y3-y2) - t2*(y2-y1));
1594+ f->s3 += 2.0f * (-t4*(y3) - t3*(y3-y2));
15951595
1596− f->zi = in;
1597− return y3*f->r;
1596+ f->zi = in;
1597+ return y3*f->r;
15981598
15991599 }
16001600
@@ -1602,15 +1602,15 @@ float tDiodeFilter_tick (tDiodeFilter* const vf, float in) · 1 unmodified line
16021602
16031603 void tDiodeFilter_setFreq (tDiodeFilter* const vf, float cutoff)
16041604 {
1605− _tDiodeFilter* f = *vf;
1606− f->f = tanf(PI * LEAF_clip(10.0f, cutoff, 20000.0f)*leaf.invSampleRate);
1605+ _tDiodeFilter* f = *vf;
1606+ f->f = tanf(PI * LEAF_clip(10.0f, cutoff, 20000.0f)*leaf.invSampleRate);
16071607 }
16081608
16091609
16101610 void tDiodeFilter_setQ (tDiodeFilter* const vf, float resonance)
16111611 {
1612− _tDiodeFilter* f = *vf;
1613− f->r = LEAF_clip(0.5, (7.f * resonance + 0.5f), 8.0f);
1612+ _tDiodeFilter* f = *vf;
1613+ f->r = LEAF_clip(0.5, (7.f * resonance + 0.5f), 8.0f);
16141614
16151615 }
16161616
leaf/Src/leaf-math.c+12−7
@@ -2,7 +2,6 @@ · 1 unmodified line
22
33 leaf-math.c
44 Created: 22 Jan 2017 7:02:56pm
5− Author: Michael R Mulshine
65
76 ==============================================================================*/
87
@@ -40,6 +39,12 @@ float log2f_approx(float X) { · 31 unmodified lines
4039 return(Y);
4140 }
4241
42+//another log2Approximation
43+float log2f_approx2(float x)
44+{
45+ return (0.1640425613334452f * x*x*x) + (-1.098865286222744f * x*x) + (3.148297929334117f * x) + -2.213475204444817f;
46+}
47+
4348 float interpolate3max(float *buf, const int peakindex)
4449 {
4550 float a = buf[peakindex-1];
@@ -472,12 +477,12 @@ void LEAF_generate_square(float* buffer, float basefreq, int size) · 426 unmodified lines
472477 //0.001 base gives a good curve that goes from 1 to near zero
473478 void LEAF_generate_exp(float* buffer, float base, float start, float end, float offset, int size)
474479 {
475− float increment = (end - start) / (float)size;
476− float x = start;
477− for (int i = 0; i < size; i++)
478− {
479− buffer[i] = powf(base, x) + offset;
480− x += increment;
480+ float increment = (end - start) / (float)size;
481+ float x = start;
482+ for (int i = 0; i < size; i++)
483+ {
484+ buffer[i] = powf(base, x) + offset;
485+ x += increment;
481486 }
482487 }
483488
leaf/Src/leaf-oscillators.c+24−24
@@ -132,12 +132,12 @@ float tCycle_tick(tCycle* const cy) · 131 unmodified lines
132132
133133 // Wavetable synthesis
134134
135− temp = SINE_TABLE_SIZE * c->phase;
136− intPart = (int)temp;
137− fracPart = temp - (float)intPart;
138− samp0 = __leaf_table_sinewave[intPart];
139− if (++intPart >= SINE_TABLE_SIZE) intPart = 0;
140− samp1 = __leaf_table_sinewave[intPart];
135+ temp = SINE_TABLE_SIZE * c->phase;
136+ intPart = (int)temp;
137+ fracPart = temp - (float)intPart;
138+ samp0 = __leaf_table_sinewave[intPart];
139+ if (++intPart >= SINE_TABLE_SIZE) intPart = 0;
140+ samp1 = __leaf_table_sinewave[intPart];
141141
142142 return (samp0 + (samp1 - samp0) * fracPart);
143143 }
@@ -400,7 +400,7 @@ float tTri_tick (tTri* const osc) · 256 unmodified lines
400400 }
401401
402402 out += LEAF_poly_blep(c->phase, c->inc);
403− out -= LEAF_poly_blep(fmod(c->phase + (1.0f - c->skew), 1.0f), c->inc);
403+ out -= LEAF_poly_blep(fmodf(c->phase + (1.0f - c->skew), 1.0f), c->inc);
404404
405405 out = (skew * c->inc * out) + ((1 - c->inc) * c->lastOut);
406406 c->lastOut = out;
@@ -463,7 +463,7 @@ float tPulse_tick (tPulse* const osc) · 56 unmodified lines
463463 if (c->phase < c->width) out = 1.0f;
464464 else out = -1.0f;
465465 out += LEAF_poly_blep(c->phase, c->inc);
466− out -= LEAF_poly_blep(fmod(c->phase + (1.0f - c->width), 1.0f), c->inc);
466+ out -= LEAF_poly_blep(fmodf(c->phase + (1.0f - c->width), 1.0f), c->inc);
467467
468468 c->phase += c->inc;
469469 if (c->phase >= 1.0f)
@@ -962,9 +962,9 @@ float tMBPulse_tick(tMBPulse* const osc) · 492 unmodified lines
962962 p = 0.0f;
963963
964964 w = freq / leaf.sampleRate;
965− if (w < 1e-5) w = 1e-5;
966− if (w > 0.5) w = 0.5;
967− b = 0.5 * (1.0 + c->waveform );
965+ if (w < 1e-5f) w = 1e-5f;
966+ if (w > 0.5f) w = 0.5f;
967+ b = 0.5f * (1.0f + c->waveform );
968968 if (b < w) b = w;
969969 if (b > 1.0f - w) b = 1.0f - w;
970970 /* for variable-width rectangular wave, we could do DC compensation with:
@@ -983,10 +983,10 @@ float tMBPulse_tick(tMBPulse* const osc) · 12 unmodified lines
983983 a = 0.5f; // when a = 1, LPfilter is disabled
984984
985985 t = freq / leaf.sampleRate;
986− if (t < 1e-5) t = 1e-5;
987− if (t > 0.5) t = 0.5;
986+ if (t < 1e-5f) t = 1e-5f;
987+ if (t > 0.5f) t = 0.5f;
988988 dw = (t - w) ;
989− t = 0.5 * (1.0 + c->waveform );
989+ t = 0.5f * (1.0f + c->waveform );
990990 if (t < w) t = w;
991991 if (t > 1.0f - w) t = 1.0f - w;
992992 db = (t - b) ;
@@ -1173,9 +1173,9 @@ float tMBTriangle_tick(tMBTriangle* const osc) · 180 unmodified lines
11731173 // w = (exp2ap (freq[1] + vco->_port[OCTN] + vco->_port[TUNE] + expm[1] * vco->_port[EXPG] + 8.03136)
11741174 // + 1e3 * linm[1] * vco->_port[LING]) / SAMPLERATE;
11751175 w = freq / leaf.sampleRate;
1176− if (w < 1e-5) w = 1e-5;
1177− if (w > 0.5) w = 0.5;
1178− b = 0.5 * (1.0 + c->waveform);
1176+ if (w < 1e-5f) w = 1e-5f;
1177+ if (w > 0.5f) w = 0.5f;
1178+ b = 0.5f * (1.0f + c->waveform);
11791179 if (b < w) b = w;
11801180 if (b > 1.0f - w) b = 1.0f - w;
11811181 p = 0.5f * b;
@@ -1190,10 +1190,10 @@ float tMBTriangle_tick(tMBTriangle* const osc) · 8 unmodified lines
11901190 a = 0.5f; // when a = 1, LPfilter is disabled
11911191
11921192 t = freq / leaf.sampleRate;
1193− if (t < 1e-5) t = 1e-5;
1194− if (t > 0.5) t = 0.5;
1193+ if (t < 1e-5f) t = 1e-5f;
1194+ if (t > 0.5f) t = 0.5f;
11951195 dw = (t - w) ;
1196− t = 0.5 * (1.0 + c->waveform );
1196+ t = 0.5f * (1.0f + c->waveform );
11971197 if (t < w) t = w;
11981198 if (t > 1.0f - w) t = 1.0f - w;
11991199 db = (t - b) ;
@@ -1380,8 +1380,8 @@ float tMBSaw_tick(tMBSaw* const osc) · 180 unmodified lines
13801380 if (c->_init) {
13811381 p = 0.5f;
13821382 w = freq / leaf.sampleRate;
1383− if (w < 1e-5) w = 1e-5;
1384− if (w > 0.5) w = 0.5;
1383+ if (w < 1e-5f) w = 1e-5f;
1384+ if (w > 0.5f) w = 0.5f;
13851385 /* if we valued alias-free startup over low startup time, we could do:
13861386 * p -= w;
13871387 * place_slope_dd(_f, j, 0.0f, w, -1.0f); */
@@ -1392,8 +1392,8 @@ float tMBSaw_tick(tMBSaw* const osc) · 4 unmodified lines
13921392 a = 0.5f; // when a = 1, LPfilter is disabled
13931393
13941394 t = freq / leaf.sampleRate;
1395− if (t < 1e-5) t = 1e-5;
1396− if (t > 0.5) t = 0.5;
1395+ if (t < 1e-5f) t = 1e-5f;
1396+ if (t > 0.5f) t = 0.5f;
13971397 dw = (t - w); // n= 1
13981398 w += dw;
13991399 p += w;
leaf/Src/leaf-physical.c+9−9
@@ -360,7 +360,7 @@ void tSimpleLivingString_initToPool (tSimpleLivingString* const pl, float fr · 359 unmodified lines
360360 p->mempool = m;
361361
362362 p->curr=0.0f;
363− tExpSmooth_initToPool(&p->wlSmooth, leaf.sampleRate/freq, 0.01, mp); // smoother for string wavelength (not freq, to avoid expensive divisions)
363+ tExpSmooth_initToPool(&p->wlSmooth, leaf.sampleRate/freq, 0.01f, mp); // smoother for string wavelength (not freq, to avoid expensive divisions)
364364 tSimpleLivingString_setFreq(pl, freq);
365365 tLinearDelay_initToPool(&p->delayLine,p->waveLengthInSamples, 2400, mp);
366366 tLinearDelay_clear(&p->delayLine);
@@ -398,7 +398,7 @@ void tSimpleLivingString_setWaveLength(tSimpleLivingString* const pl, float · 31 unmodified lines
398398 {
399399 _tSimpleLivingString* p = *pl;
400400
401− if (waveLength<4.8) waveLength=4.8;
401+ if (waveLength<4.8) waveLength=4.8f;
402402 else if (waveLength>2400) waveLength=2400;
403403 p->waveLengthInSamples = waveLength;
404404 tExpSmooth_setDest(&p->wlSmooth, p->waveLengthInSamples);
@@ -477,10 +477,10 @@ void tLivingString_initToPool (tLivingString* const pl, float freq, float · 72 unmodified lines
477477 p->mempool = m;
478478
479479 p->curr=0.0f;
480− tExpSmooth_initToPool(&p->wlSmooth, leaf.sampleRate/freq, 0.01, mp); // smoother for string wavelength (not freq, to avoid expensive divisions)
480+ tExpSmooth_initToPool(&p->wlSmooth, leaf.sampleRate/freq, 0.01f, mp); // smoother for string wavelength (not freq, to avoid expensive divisions)
481481 tLivingString_setFreq(pl, freq);
482482 p->freq = freq;
483− tExpSmooth_initToPool(&p->ppSmooth, pickPos, 0.01, mp); // smoother for pick position
483+ tExpSmooth_initToPool(&p->ppSmooth, pickPos, 0.01f, mp); // smoother for pick position
484484 tLivingString_setPickPos(pl, pickPos);
485485 p->prepIndex=prepIndex;
486486 tLinearDelay_initToPool(&p->delLF,p->waveLengthInSamples, 2400, mp);
@@ -530,8 +530,8 @@ void tLivingString_free (tLivingString* const pl) · 43 unmodified lines
530530 void tLivingString_setFreq(tLivingString* const pl, float freq)
531531 { // NOTE: It is faster to set wavelength in samples directly
532532 _tLivingString* p = *pl;
533− if (freq<20) freq=20;
534− else if (freq>10000) freq=10000;
533+ if (freq<20.f) freq=20.f;
534+ else if (freq>10000.f) freq=10000.f;
535535 p->waveLengthInSamples = leaf.sampleRate/freq;
536536 tExpSmooth_setDest(&p->wlSmooth, p->waveLengthInSamples);
537537 }
@@ -539,8 +539,8 @@ void tLivingString_setFreq(tLivingString* const pl, float freq) · 1 unmodified line
539539 void tLivingString_setWaveLength(tLivingString* const pl, float waveLength)
540540 {
541541 _tLivingString* p = *pl;
542− if (waveLength<4.8) waveLength=4.8;
543− else if (waveLength>2400) waveLength=2400;
542+ if (waveLength<4.8f) waveLength=4.8f;
543+ else if (waveLength>2400.f) waveLength=2400.f;
544544 p->waveLengthInSamples = waveLength;
545545 tExpSmooth_setDest(&p->wlSmooth, p->waveLengthInSamples);
546546 }
@@ -669,7 +669,7 @@ void tComplexLivingString_initToPool (tComplexLivingString* const pl, floa · 122 unmodified lines
669669 p->mempool = m;
670670
671671 p->curr=0.0f;
672− tExpSmooth_initToPool(&p->wlSmooth, leaf.sampleRate/freq, 0.01, mp); // smoother for string wavelength (not freq, to avoid expensive divisions)
672+ tExpSmooth_initToPool(&p->wlSmooth, leaf.sampleRate/freq, 0.01f, mp); // smoother for string wavelength (not freq, to avoid expensive divisions)
673673 tComplexLivingString_setFreq(pl, freq);
674674 p->freq = freq;
675675 tExpSmooth_initToPool(&p->pickPosSmooth, pickPos, 0.01f, mp); // smoother for pick position
leaf/Src/leaf-reverb.c+105−105
@@ -89,7 +89,7 @@ void tPRCReverb_setT60(tPRCReverb* const rev, float t60) · 88 unmodified lines
8989
9090 r->t60 = t60;
9191
92− r->combCoeff = pow(10.0f, (-3.0f * tDelay_getDelay(&r->combDelay) * leaf.invSampleRate / t60 ));
92+ r->combCoeff = powf(10.0f, (-3.0f * tDelay_getDelay(&r->combDelay) * leaf.invSampleRate / t60 ));
9393
9494 }
9595
@@ -136,7 +136,7 @@ float tPRCReverb_tick(tPRCReverb* const rev, float input) · 40 unmodified lines
136136 void tPRCReverbSampleRateChanged (tPRCReverb* const rev)
137137 {
138138 _tPRCReverb* r = *rev;
139− r->combCoeff = pow(10.0f, (-3.0f * tDelay_getDelay(&r->combDelay) * leaf.invSampleRate / r->t60 ));
139+ r->combCoeff = powf(10.0f, (-3.0f * tDelay_getDelay(&r->combDelay) * leaf.invSampleRate / r->t60 ));
140140 }
141141
142142 /* ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ NReverb ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */
@@ -172,14 +172,14 @@ void tNReverb_initToPool (tNReverb* const rev, float t60, tMempool* const · 29 unmodified lines
172172
173173 for ( i=0; i<6; i++ )
174174 {
175− tLinearDelay_initToPool(&r->combDelays[i], lengths[i], lengths[i] * 2.0f, mp);
175+ tLinearDelay_initToPool(&r->combDelays[i], lengths[i], lengths[i] * 2, mp);
176176 tLinearDelay_clear(&r->combDelays[i]);
177− r->combCoeffs[i] = pow(10.0, (-3 * lengths[i] * leaf.invSampleRate / t60));
177+ r->combCoeffs[i] = powf(10.0f, (-3.0f * (float)lengths[i] * leaf.invSampleRate / t60));
178178 }
179179
180180 for ( i=0; i<8; i++ )
181181 {
182− tLinearDelay_initToPool(&r->allpassDelays[i], lengths[i+6], lengths[i+6] * 2.0f, mp);
182+ tLinearDelay_initToPool(&r->allpassDelays[i], lengths[i+6], lengths[i+6] * 2, mp);
183183 tLinearDelay_clear(&r->allpassDelays[i]);
184184 }
185185
@@ -214,7 +214,7 @@ void tNReverb_setT60(tNReverb* const rev, float t60) · 28 unmodified lines
214214
215215 r->t60 = t60;
216216
217− for (int i=0; i<6; i++) r->combCoeffs[i] = pow(10.0, (-3.0 * tLinearDelay_getDelay(&r->combDelays[i]) * leaf.invSampleRate / t60 ));
217+ for (int i=0; i<6; i++) r->combCoeffs[i] = powf(10.0f, (-3.0f * tLinearDelay_getDelay(&r->combDelays[i]) * leaf.invSampleRate / t60 ));
218218
219219 }
220220
@@ -351,7 +351,7 @@ void tNReverb_tickStereo(tNReverb* const rev, float input, float* output) · 130 unmodified lines
351351 void tNReverbSampleRateChanged (tNReverb* const rev)
352352 {
353353 _tNReverb* r = *rev;
354− for (int i=0; i<6; i++) r->combCoeffs[i] = pow(10.0, (-3.0 * tLinearDelay_getDelay(&r->combDelays[i]) * leaf.invSampleRate / r->t60 ));
354+ for (int i=0; i<6; i++) r->combCoeffs[i] = powf(10.0f, (-3.0f * tLinearDelay_getDelay(&r->combDelays[i]) * leaf.invSampleRate / r->t60 ));
355355 }
356356
357357 // ======================================DATTORRO=========================================
@@ -494,69 +494,69 @@ float tDattorroReverb_tick (tDattorroReverb* const rev, float inp · 136 unmodified lines
494494
495495 if (r->frozen)
496496 {
497− input = 0.0f;
498− //r->f1_last = 0.0f;
499− //r->f2_last = 0.0f;
500− }
501− // INPUT
502− in_sample = tTapeDelay_tick(&r->in_delay, input);
497+ input = 0.0f;
498+ //r->f1_last = 0.0f;
499+ //r->f2_last = 0.0f;
500+ }
501+ // INPUT
502+ in_sample = tTapeDelay_tick(&r->in_delay, input);
503503
504− in_sample = tOnePole_tick(&r->in_filter, in_sample);
504+ in_sample = tOnePole_tick(&r->in_filter, in_sample);
505505
506− for (int i = 0; i < 4; i++)
507− {
508− in_sample = tAllpass_tick(&r->in_allpass[i], in_sample);
509− }
506+ for (int i = 0; i < 4; i++)
507+ {
508+ in_sample = tAllpass_tick(&r->in_allpass[i], in_sample);
509+ }
510510
511− // FEEDBACK 1
512− f1_sample = in_sample + r->f2_last; // + f2_last_out;
511+ // FEEDBACK 1
512+ f1_sample = in_sample + r->f2_last; // + f2_last_out;
513513
514− tAllpass_setDelay(&r->f1_allpass, SAMP(30.51f) + tCycle_tick(&r->f1_lfo) * SAMP(4.0f));
514+ tAllpass_setDelay(&r->f1_allpass, SAMP(30.51f) + tCycle_tick(&r->f1_lfo) * SAMP(4.0f));
515515
516− f1_sample = tAllpass_tick(&r->f1_allpass, f1_sample);
516+ f1_sample = tAllpass_tick(&r->f1_allpass, f1_sample);
517517
518− f1_sample = tTapeDelay_tick(&r->f1_delay_1, f1_sample);
518+ f1_sample = tTapeDelay_tick(&r->f1_delay_1, f1_sample);
519519
520− f1_sample = tOnePole_tick(&r->f1_filter, f1_sample);
520+ f1_sample = tOnePole_tick(&r->f1_filter, f1_sample);
521521
522− f1_sample = f1_sample + r->f1_delay_2_last * 0.5f;
522+ f1_sample = f1_sample + r->f1_delay_2_last * 0.5f;
523523
524− f1_delay_2_sample = tTapeDelay_tick(&r->f1_delay_2, f1_sample * 0.5f);
524+ f1_delay_2_sample = tTapeDelay_tick(&r->f1_delay_2, f1_sample * 0.5f);
525525
526− r->f1_delay_2_last = f1_delay_2_sample;
526+ r->f1_delay_2_last = f1_delay_2_sample;
527527
528− f1_sample = r->f1_delay_2_last + f1_sample;
528+ f1_sample = r->f1_delay_2_last + f1_sample;
529529
530− f1_sample = tHighpass_tick(&r->f1_hp, f1_sample);
530+ f1_sample = tHighpass_tick(&r->f1_hp, f1_sample);
531531
532− f1_sample *= r->feedback_gain;
532+ f1_sample *= r->feedback_gain;
533533
534− r->f1_last = tTapeDelay_tick(&r->f1_delay_3, f1_sample);
534+ r->f1_last = tTapeDelay_tick(&r->f1_delay_3, f1_sample);
535535
536− // FEEDBACK 2
537− f2_sample = in_sample + r->f1_last;
536+ // FEEDBACK 2
537+ f2_sample = in_sample + r->f1_last;
538538
539− tAllpass_setDelay(&r->f2_allpass, SAMP(22.58f) + tCycle_tick(&r->f2_lfo) * SAMP(4.0f));
539+ tAllpass_setDelay(&r->f2_allpass, SAMP(22.58f) + tCycle_tick(&r->f2_lfo) * SAMP(4.0f));
540540
541− f2_sample = tAllpass_tick(&r->f2_allpass, f2_sample);
541+ f2_sample = tAllpass_tick(&r->f2_allpass, f2_sample);
542542
543− f2_sample = tTapeDelay_tick(&r->f2_delay_1, f2_sample);
543+ f2_sample = tTapeDelay_tick(&r->f2_delay_1, f2_sample);
544544
545− f2_sample = tOnePole_tick(&r->f2_filter, f2_sample);
545+ f2_sample = tOnePole_tick(&r->f2_filter, f2_sample);
546546
547− f2_sample = f2_sample + r->f2_delay_2_last * 0.5f;
547+ f2_sample = f2_sample + r->f2_delay_2_last * 0.5f;
548548
549− f2_delay_2_sample = tTapeDelay_tick(&r->f2_delay_2, f2_sample * 0.5f);
549+ f2_delay_2_sample = tTapeDelay_tick(&r->f2_delay_2, f2_sample * 0.5f);
550550
551− r->f2_delay_2_last = f2_delay_2_sample;
551+ r->f2_delay_2_last = f2_delay_2_sample;
552552
553− f2_sample = r->f2_delay_2_last + f2_sample;
553+ f2_sample = r->f2_delay_2_last + f2_sample;
554554
555− f2_sample = tHighpass_tick(&r->f2_hp, f2_sample);
555+ f2_sample = tHighpass_tick(&r->f2_hp, f2_sample);
556556
557− f2_sample *= r->feedback_gain;
557+ f2_sample *= r->feedback_gain;
558558
559− r->f2_last = tTapeDelay_tick(&r->f2_delay_3, f2_sample);
559+ r->f2_last = tTapeDelay_tick(&r->f2_delay_3, f2_sample);
560560
561561 // TAP OUT 1
562562 f1_sample = tTapeDelay_tapOut(&r->f1_delay_1, SAMP(8.9f)) +
@@ -602,79 +602,79 @@ void tDattorroReverb_tickStereo (tDattorroReverb* const rev, floa · 39 unmodified lines
602602
603603 if (r->frozen)
604604 {
605− input = 0.0f;
606− //r->f1_last = 0.0f;
607− //r->f2_last = 0.0f;
605+ input = 0.0f;
606+ //r->f1_last = 0.0f;
607+ //r->f2_last = 0.0f;
608608 }
609− // INPUT
610− in_sample = tTapeDelay_tick(&r->in_delay, input);
609+ // INPUT
610+ in_sample = tTapeDelay_tick(&r->in_delay, input);
611611
612− in_sample = tOnePole_tick(&r->in_filter, in_sample);
612+ in_sample = tOnePole_tick(&r->in_filter, in_sample);
613613
614− for (int i = 0; i < 4; i++)
615− {
616− in_sample = tAllpass_tick(&r->in_allpass[i], in_sample);
617− }
614+ for (int i = 0; i < 4; i++)
615+ {
616+ in_sample = tAllpass_tick(&r->in_allpass[i], in_sample);
617+ }
618618
619619
620− // FEEDBACK 1
621− f1_sample = in_sample + r->f2_last; // + f2_last_out;
620+ // FEEDBACK 1
621+ f1_sample = in_sample + r->f2_last; // + f2_last_out;
622622
623− tAllpass_setDelay(&r->f1_allpass, SAMP(30.51f) + tCycle_tick(&r->f1_lfo) * SAMP(4.0f));
623+ tAllpass_setDelay(&r->f1_allpass, SAMP(30.51f) + tCycle_tick(&r->f1_lfo) * SAMP(4.0f));
624624
625− f1_sample = tAllpass_tick(&r->f1_allpass, f1_sample);
625+ f1_sample = tAllpass_tick(&r->f1_allpass, f1_sample);
626626
627− f1_sample = tTapeDelay_tick(&r->f1_delay_1, f1_sample);
627+ f1_sample = tTapeDelay_tick(&r->f1_delay_1, f1_sample);
628628
629− f1_sample = tOnePole_tick(&r->f1_filter, f1_sample);
629+ f1_sample = tOnePole_tick(&r->f1_filter, f1_sample);
630630
631− f1_sample = f1_sample + r->f1_delay_2_last * 0.5f;
631+ f1_sample = f1_sample + r->f1_delay_2_last * 0.5f;
632632
633− f1_delay_2_sample = tTapeDelay_tick(&r->f1_delay_2, f1_sample * 0.5f);
633+ f1_delay_2_sample = tTapeDelay_tick(&r->f1_delay_2, f1_sample * 0.5f);
634634
635− r->f1_delay_2_last = f1_delay_2_sample;
635+ r->f1_delay_2_last = f1_delay_2_sample;
636636
637− f1_sample = r->f1_delay_2_last + f1_sample;
637+ f1_sample = r->f1_delay_2_last + f1_sample;
638638
639− f1_sample = tHighpass_tick(&r->f1_hp, f1_sample);
639+ f1_sample = tHighpass_tick(&r->f1_hp, f1_sample);
640640
641− f1_sample *= r->feedback_gain;
641+ f1_sample *= r->feedback_gain;
642642
643− if (r->frozen)
644− {
645− f1_sample = 0.0f;
646− }
643+ if (r->frozen)
644+ {
645+ f1_sample = 0.0f;
646+ }
647647
648− r->f1_last = tTapeDelay_tick(&r->f1_delay_3, f1_sample);
648+ r->f1_last = tTapeDelay_tick(&r->f1_delay_3, f1_sample);
649649
650− // FEEDBACK 2
651− f2_sample = in_sample + r->f1_last;
650+ // FEEDBACK 2
651+ f2_sample = in_sample + r->f1_last;
652652
653− tAllpass_setDelay(&r->f2_allpass, SAMP(22.58f) + tCycle_tick(&r->f2_lfo) * SAMP(4.0f));
653+ tAllpass_setDelay(&r->f2_allpass, SAMP(22.58f) + tCycle_tick(&r->f2_lfo) * SAMP(4.0f));
654654
655− f2_sample = tAllpass_tick(&r->f2_allpass, f2_sample);
655+ f2_sample = tAllpass_tick(&r->f2_allpass, f2_sample);
656656
657− f2_sample = tTapeDelay_tick(&r->f2_delay_1, f2_sample);
657+ f2_sample = tTapeDelay_tick(&r->f2_delay_1, f2_sample);
658658
659− f2_sample = tOnePole_tick(&r->f2_filter, f2_sample);
659+ f2_sample = tOnePole_tick(&r->f2_filter, f2_sample);
660660
661− f2_sample = f2_sample + r->f2_delay_2_last * 0.5f;
661+ f2_sample = f2_sample + r->f2_delay_2_last * 0.5f;
662662
663− f2_delay_2_sample = tTapeDelay_tick(&r->f2_delay_2, f2_sample * 0.5f);
663+ f2_delay_2_sample = tTapeDelay_tick(&r->f2_delay_2, f2_sample * 0.5f);
664664
665− r->f2_delay_2_last = f2_delay_2_sample;
665+ r->f2_delay_2_last = f2_delay_2_sample;
666666
667− f2_sample = r->f2_delay_2_last + f2_sample;
667+ f2_sample = r->f2_delay_2_last + f2_sample;
668668
669− f2_sample = tHighpass_tick(&r->f2_hp, f2_sample);
669+ f2_sample = tHighpass_tick(&r->f2_hp, f2_sample);
670670
671− f2_sample *= r->feedback_gain;
671+ f2_sample *= r->feedback_gain;
672672
673− if (r->frozen)
674− {
675− f2_sample = 0.0f;
676− }
677− r->f2_last = tTapeDelay_tick(&r->f2_delay_3, f2_sample);
673+ if (r->frozen)
674+ {
675+ f2_sample = 0.0f;
676+ }
677+ r->f2_last = tTapeDelay_tick(&r->f2_delay_3, f2_sample);
678678
679679
680680
@@ -727,26 +727,26 @@ void tDattorroReverb_setFreeze (tDattorroReverb* const rev, uint32 · 46 unmodified lines
727727 r->frozen = freeze;
728728 if (freeze)
729729 {
730− tAllpass_setGain(&r->f2_allpass, 1.0f);
731− tAllpass_setGain(&r->f1_allpass, 1.0f);
732− for (int i = 0; i < 4; i++)
733− {
734−
735− //tAllpass_setGain(&r->in_allpass[i], 1.0f);
736− }
737− tCycle_setFreq(&r->f1_lfo, 0.0f);
738− tCycle_setFreq(&r->f2_lfo, 0.0f);
730+ tAllpass_setGain(&r->f2_allpass, 1.0f);
731+ tAllpass_setGain(&r->f1_allpass, 1.0f);
732+ for (int i = 0; i < 4; i++)
733+ {
734+
735+ //tAllpass_setGain(&r->in_allpass[i], 1.0f);
736+ }
737+ tCycle_setFreq(&r->f1_lfo, 0.0f);
738+ tCycle_setFreq(&r->f2_lfo, 0.0f);
739739 }
740740 else
741741 {
742− tAllpass_setGain(&r->f2_allpass, 0.7f);
743− tAllpass_setGain(&r->f1_allpass, 0.7f);
744− for (int i = 0; i < 4; i++)
745− {
746− //tAllpass_setGain(&r->in_allpass[i], in_allpass_gains[i]);
747− }
748− tCycle_setFreq(&r->f1_lfo, 0.1f);
749− tCycle_setFreq(&r->f2_lfo, 0.07f);
742+ tAllpass_setGain(&r->f2_allpass, 0.7f);
743+ tAllpass_setGain(&r->f1_allpass, 0.7f);
744+ for (int i = 0; i < 4; i++)
745+ {
746+ //tAllpass_setGain(&r->in_allpass[i], in_allpass_gains[i]);
747+ }
748+ tCycle_setFreq(&r->f1_lfo, 0.1f);
749+ tCycle_setFreq(&r->f2_lfo, 0.07f);
750750 }
751751 }
752752
leaf/Src/leaf-sampling.c+15−15
@@ -80,7 +80,7 @@ void tBuffer_tick (tBuffer* const sb, float sample) · 79 unmodified lines
8080 void tBuffer_read(tBuffer* const sb, float* buff, uint32_t len)
8181 {
8282 _tBuffer* s = *sb;
83− for (int i = 0; i < s->bufferLength; i++)
83+ for (uint i = 0; i < s->bufferLength; i++)
8484 {
8585 if (i < len) s->buff[i] = buff[i];
8686 else s->buff[i] = 0.f;
@@ -91,7 +91,7 @@ void tBuffer_read(tBuffer* const sb, float* buff, uint32_t len) · 4 unmodified lines
9191 float tBuffer_get (tBuffer* const sb, int idx)
9292 {
9393 _tBuffer* s = *sb;
94− if ((idx < 0) || (idx >= s->bufferLength)) return 0.f;
94+ if ((idx < 0) || (idx >= (int) s->bufferLength)) return 0.f;
9595 return s->buff[idx];
9696 }
9797
@@ -129,7 +129,7 @@ void tBuffer_setRecordMode (tBuffer* const sb, RecordMode mode) · 31 unmodified lines
129129 void tBuffer_clear (tBuffer* const sb)
130130 {
131131 _tBuffer* s = *sb;
132− for (int i = 0; i < s->bufferLength; i++)
132+ for (uint i = 0; i < s->bufferLength; i++)
133133 {
134134 s->buff[i] = 0.f;
135135 }
@@ -263,8 +263,8 @@ float tSampler_tick (tSampler* const sp) · 127 unmodified lines
263263 int myEnd = p->end;
264264 if (p->flip < 0)
265265 {
266− myStart = p->end;
267− myEnd = p->start;
266+ myStart = p->end;
267+ myEnd = p->start;
268268 }
269269
270270 // Get the direction and a reverse flag for some calcs
@@ -442,16 +442,16 @@ float tSampler_tick (tSampler* const sp) · 171 unmodified lines
442442
443443 if (p->mode == PlayNormal)
444444 {
445− if (p->idx < myStart)
446− {
447− p->idx = myStart;
448− }
449− else if (p->idx > myEnd)
450− {
451− p->idx = myEnd;
452− }
453− float ticksToEnd = rev ? ((idx - myStart) * p->iinc) : ((myEnd - idx) * p->iinc);
454− if (ticksToEnd < (0.007f * leaf.sampleRate))
445+ if (p->idx < myStart)
446+ {
447+ p->idx = myStart;
448+ }
449+ else if (p->idx > myEnd)
450+ {
451+ p->idx = myEnd;
452+ }
453+ float ticksToEnd = rev ? ((idx - myStart) * p->iinc) : ((myEnd - idx) * p->iinc);
454+ if (ticksToEnd < (0.007f * leaf.sampleRate))
455455 {
456456 tRamp_setDest(&p->gain, 0.f);
457457 p->active = -1;

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