History

fix init bugs in poly and feedbackLeveler

Matthew Wang committed 6 years ago

Commit b0581561 parent 9cb36a15 files · +28 −31Browse files

Unified · Split

5 files
  1. LEAF/Src/leaf-dynamics.c +5 −5
  2. LEAF/Src/leaf-effects.c +0 −1
  3. LEAF/Src/leaf-envelopes.c +6 −6
  4. LEAF/Src/leaf-midi.c +10 −10
  5. LEAF/Src/leaf-physical.c +7 −9
LEAF/Src/leaf-dynamics.c+5−5
@@ -114,10 +114,10 @@ static void feedbackleveler_init(tFeedbackLeveler* const fb, float targetLeve · 113 unmodified lines
114114 {
115115 _tFeedbackLeveler* p = *fb;
116116
117− p->curr=0.0f;
118− p->targetLevel=targetLevel;
119− p->mode=mode;
120− p->strength=strength;
117+ p->curr = 0.0f;
118+ p->targetLevel = targetLevel;
119+ p->mode = mode;
120+ p->strength = strength;
121121 }
122122
123123 void tFeedbackLeveler_init(tFeedbackLeveler* const fb, float targetLevel, float factor, float strength, int mode)
@@ -139,7 +139,7 @@ void tFeedbackLeveler_initToPool (tFeedbackLeveler* const fb, float targe · 15 unmodified lines
139139 _tMempool* m = *mp;
140140 _tFeedbackLeveler* p = *fb = (_tFeedbackLeveler*) mpool_alloc(sizeof(_tFeedbackLeveler), &m->pool);
141141 feedbackleveler_init(fb, targetLevel, factor, strength, mode);
142− tPowerFollower_init(&p->pwrFlw,factor);
142+ tPowerFollower_initToPool(&p->pwrFlw, factor, mp);
143143 }
144144
145145 void tFeedbackLeveler_freeFromPool (tFeedbackLeveler* const fb, tMempool* const mp)
LEAF/Src/leaf-effects.c+0−1
@@ -1273,7 +1273,6 @@ void tAutotune_free(tAutotune* const rt) · 1272 unmodified lines
12731273 tPitchShift_free(&r->ps[i]);
12741274 leaf_free(r->outBuffers[i]);
12751275 }
1276− tPeriodDetection_free(&r->pd);
12771276 leaf_free(r->tickOutput);
12781277 leaf_free(r->freq);
12791278 leaf_free(r->ps);
LEAF/Src/leaf-envelopes.c+6−6
@@ -603,12 +603,12 @@ static void expsmooth_init(tExpSmooth* const expsmooth, float val, float fact · 602 unmodified lines
603603 { // 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
604604 _tExpSmooth* smooth = *expsmooth;
605605
606− smooth->curr=val;
607− smooth->dest=val;
608− if (factor<0) factor=0;
609− if (factor>1) factor=1;
610− smooth->factor=factor;
611− smooth->oneminusfactor=1.0f-factor;
606+ smooth->curr = val;
607+ smooth->dest = val;
608+ if (factor < 0) factor = 0;
609+ if (factor > 1) factor = 1;
610+ smooth->factor = factor;
611+ smooth->oneminusfactor = 1.0f - factor;
612612 }
613613
614614 void tExpSmooth_init(tExpSmooth* const expsmooth, float val, float factor)
LEAF/Src/leaf-midi.c+10−10
@@ -301,17 +301,17 @@ static void poly_init(tPoly* const polyh, int maxNumVoices) · 300 unmodified lines
301301 void tPoly_init(tPoly* const polyh, int maxNumVoices)
302302 {
303303 _tPoly* poly = *polyh = (_tPoly*) leaf_alloc(sizeof(_tPoly));
304+
305+ poly->ramps = (tRamp*) leaf_alloc(sizeof(tRamp) * maxNumVoices);
306+ poly->rampVals = (float*) leaf_alloc(sizeof(float) * maxNumVoices);
307+ poly->firstReceived = (oBool*) leaf_alloc(sizeof(oBool) * maxNumVoices);
308+ poly->voices = (int**) leaf_alloc(sizeof(int*) * maxNumVoices);
304309 for (int i = 0; i < maxNumVoices; ++i)
305310 {
306311 poly->voices[i] = (int*) leaf_alloc(sizeof(int) * 2);
307312 }
308313 poly_init(polyh, maxNumVoices);
309314
310− poly->ramps = (tRamp*) leaf_alloc(sizeof(tRamp) * poly->maxNumVoices);
311− poly->rampVals = (float*) leaf_alloc(sizeof(float) * poly->maxNumVoices);
312− poly->firstReceived = (oBool*) leaf_alloc(sizeof(oBool) * poly->maxNumVoices);
313− poly->voices = (int**) leaf_alloc(sizeof(int*) * poly->maxNumVoices);
314−
315315 for (int i = 0; i < poly->maxNumVoices; ++i)
316316 {
317317 tRamp_init(&poly->ramps[i], poly->glideTime, 1);
@@ -346,17 +346,17 @@ void tPoly_initToPool (tPoly* const polyh, int maxNumVoices, tMemp · 28 unmodified lines
346346 {
347347 _tMempool* m = *mp;
348348 _tPoly* poly = *polyh = (_tPoly*) mpool_alloc(sizeof(_tPoly), &m->pool);
349+
350+ poly->ramps = (tRamp*) mpool_alloc(sizeof(tRamp) * maxNumVoices, &m->pool);
351+ poly->rampVals = (float*) mpool_alloc(sizeof(float) * maxNumVoices, &m->pool);
352+ poly->firstReceived = (oBool*) mpool_alloc(sizeof(oBool) * maxNumVoices, &m->pool);
353+ poly->voices = (int**) mpool_alloc(sizeof(int*) * maxNumVoices, &m->pool);
349354 for (int i = 0; i < maxNumVoices; ++i)
350355 {
351356 poly->voices[i] = (int*) mpool_alloc(sizeof(int) * 2, &m->pool);
352357 }
353358 poly_init(polyh, maxNumVoices);
354359
355− poly->ramps = (tRamp*) mpool_alloc(sizeof(tRamp) * poly->maxNumVoices, &m->pool);
356− poly->rampVals = (float*) mpool_alloc(sizeof(float) * poly->maxNumVoices, &m->pool);
357− poly->firstReceived = (oBool*) mpool_alloc(sizeof(oBool) * poly->maxNumVoices, &m->pool);
358− poly->voices = (int**) mpool_alloc(sizeof(int*) * poly->maxNumVoices, &m->pool);
359−
360360 for (int i = 0; i < poly->maxNumVoices; ++i)
361361 {
362362 tRamp_initToPool(&poly->ramps[i], poly->glideTime, 1, mp);
LEAF/Src/leaf-physical.c+7−9
@@ -19,8 +19,6 @@ · 18 unmodified lines
1919 /* ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ tPluck ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */
2020 static void pluck_init (tPluck* const pl, float lowestFrequency)
2121 {
22− _tPluck* p = *pl;
23−
2422 if ( lowestFrequency <= 0.0f ) lowestFrequency = 10.0f;
2523
2624 tPluck_setFrequency(pl, 220.0f);
@@ -548,7 +546,7 @@ static void livingstring_init(tLivingString* const pl, float freq, float pick · 521 unmodified lines
548546 {
549547 _tLivingString* p = *pl;
550548
551− p->curr=0.0f;
549+ p->curr = 0.0f;
552550 p->freq = freq;
553551 p->prepIndex = prepIndex;
554552 p->dampFreq = dampFreq;
@@ -658,8 +656,8 @@ void tLivingString_freeFromPool (tLivingString* const pl, tMempool* const mp · 103 unmodified lines
658656 void tLivingString_setFreq(tLivingString* const pl, float freq)
659657 { // NOTE: It is faster to set wavelength in samples directly
660658 _tLivingString* p = *pl;
661− if (freq<20) freq=20;
662− else if (freq>10000) freq=10000;
659+ if (freq < 20) freq = 20;
660+ else if (freq > 10000) freq = 10000;
663661 p->waveLengthInSamples = leaf.sampleRate/freq;
664662 tExpSmooth_setDest(&p->wlSmooth, p->waveLengthInSamples);
665663 }
@@ -667,8 +665,8 @@ void tLivingString_setFreq(tLivingString* const pl, float freq) · 1 unmodified line
667665 void tLivingString_setWaveLength(tLivingString* const pl, float waveLength)
668666 {
669667 _tLivingString* p = *pl;
670− if (waveLength<4.8) waveLength=4.8;
671− else if (waveLength>2400) waveLength=2400;
668+ if (waveLength < 4.8) waveLength = 4.8;
669+ else if (waveLength > 2400) waveLength = 2400;
672670 p->waveLengthInSamples = waveLength;
673671 tExpSmooth_setDest(&p->wlSmooth, p->waveLengthInSamples);
674672 }
@@ -787,7 +785,7 @@ static void reedtable_init (tReedTable* const pm, float offset, float sl · 112 unmodified lines
787785
788786 void tReedTable_init (tReedTable* const pm, float offset, float slope)
789787 {
790− _tReedTable* p = *pm = (_tReedTable*) leaf_alloc(sizeof(_tReedTable));
788+ *pm = (_tReedTable*) leaf_alloc(sizeof(_tReedTable));
791789 reedtable_init(pm, offset, slope);
792790 }
793791
@@ -800,7 +798,7 @@ void tReedTable_free (tReedTable* const pm) · 6 unmodified lines
800798 void tReedTable_initToPool (tReedTable* const pm, float offset, float slope, tMempool* const mp)
801799 {
802800 _tMempool* m = *mp;
803− _tReedTable* p = *pm = (_tReedTable*) mpool_alloc(sizeof(_tReedTable), &m->pool);
801+ *pm = (_tReedTable*) mpool_alloc(sizeof(_tReedTable), &m->pool);
804802 reedtable_init(pm, offset, slope);
805803 }
806804

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