ref: 214d58fca21ffd1b44f504d0c48f8cc60f54c52d
parent: 8eb793224654456f4a219abb4be6d434bd247c51
author: spiricom <jeff@snyderphonics.com>
date: Sat Jan 25 15:53:15 EST 2020
working formant correction, only tested with filtered noise so far
binary files a/.DS_Store b/.DS_Store differ
--- a/LEAF/Inc/leaf-effects.h
+++ b/LEAF/Inc/leaf-effects.h
@@ -261,7 +261,6 @@
typedef struct _tFormantShifter
{
int ford;
- int bufsize;
float falph;
float flamb;
float* fk;
@@ -274,7 +273,7 @@
float fhp;
float flp;
float flpa;
- float** fbuff;
+ float* fbuff;
float* ftvec;
float fmute;
float fmutealph;
--- a/LEAF/Inc/leaf-mempool.h
+++ b/LEAF/Inc/leaf-mempool.h
@@ -74,13 +74,10 @@
} mpool_t;
void mpool_create (char* memory, size_t size, mpool_t* pool);
-
-<<<<<<< HEAD
+
void* mpool_alloc(size_t size, mpool_t* pool);
void* mpool_allocAndClear(size_t asize, mpool_t* pool);
-=======
- void *mpool_alloc(size_t size, mpool_t* pool);
->>>>>>> b8628af4ceadb4749cd557e6bd3057c2639f3c97
+
void mpool_free(void* ptr, mpool_t* pool);
size_t mpool_get_size(mpool_t* pool);
@@ -89,10 +86,8 @@
void leaf_pool_init(char* memory, size_t size);
void* leaf_alloc(size_t size);
-<<<<<<< HEAD
void* leaf_allocAndClear(size_t size);
-=======
->>>>>>> b8628af4ceadb4749cd557e6bd3057c2639f3c97
+
void leaf_free(void* ptr);
size_t leaf_pool_get_size(void);
@@ -106,7 +101,7 @@
typedef struct _tMempool
{
- mpool_t* pool;
+ mpool_t pool;
} _tMempool;
typedef _tMempool* tMempool;
--- a/LEAF/Src/leaf-analysis.c
+++ b/LEAF/Src/leaf-analysis.c
@@ -41,7 +41,7 @@
void tEnvelopeFollower_initToPool (tEnvelopeFollower* const ef, float attackThreshold, float decayCoeff, tMempool* const mp)
{
_tMempool* m = *mp;
- _tEnvelopeFollower* e = *ef = (_tEnvelopeFollower*) mpool_alloc(sizeof(_tEnvelopeFollower), m->pool);
+ _tEnvelopeFollower* e = *ef = (_tEnvelopeFollower*) mpool_alloc(sizeof(_tEnvelopeFollower), &m->pool);
e->y = 0.0f;
e->a_thresh = attackThreshold;
@@ -53,7 +53,7 @@
_tMempool* m = *mp;
_tEnvelopeFollower* e = *ef;
- mpool_free(e, m->pool);
+ mpool_free(e, &m->pool);
}
float tEnvelopeFollower_tick(tEnvelopeFollower* const ef, float x)
@@ -108,7 +108,7 @@
void tPowerFollower_initToPool (tPowerFollower* const pf, float factor, tMempool* const mp)
{
_tMempool* m = *mp;
- _tPowerFollower* p = *pf = (_tPowerFollower*) mpool_alloc(sizeof(_tPowerFollower), m->pool);
+ _tPowerFollower* p = *pf = (_tPowerFollower*) mpool_alloc(sizeof(_tPowerFollower), &m->pool);
p->curr=0.0f;
p->factor=factor;
@@ -120,7 +120,7 @@
_tMempool* m = *mp;
_tPowerFollower* p = *pf;
- mpool_free(p, m->pool);
+ mpool_free(p, &m->pool);
}
int tPowerFollower_setFactor(tPowerFollower* const pf, float factor)
@@ -206,7 +206,7 @@
void tEnvPD_initToPool (tEnvPD* const xpd, int ws, int hs, int bs, tMempool* const mp)
{
_tMempool* m = *mp;
- _tEnvPD* x = *xpd = (_tEnvPD*) mpool_alloc(sizeof(_tEnvPD), m->pool);
+ _tEnvPD* x = *xpd = (_tEnvPD*) mpool_allocAndClear(sizeof(_tEnvPD), &m->pool);
int period = hs, npoints = ws;
@@ -251,60 +251,9 @@
_tMempool* m = *mp;
_tEnvPD* x = *xpd;
- mpool_free(x, m->pool);
+ mpool_free(x, &m->pool);
}
-void tEnvPD_initToPool (tEnvPD* const xpd, int ws, int hs, int bs, tMempool* const mp)
-{
- _tMempool* m = *mp;
- _tEnvPD* x = *xpd = (_tEnvPD*) mpool_alloc(sizeof(_tEnvPD), m->pool);
-
- int period = hs, npoints = ws;
-
- int i;
-
- if (npoints < 1) npoints = 1024;
- if (period < 1) period = npoints/2;
- if (period < npoints / MAXOVERLAP + 1)
- period = npoints / MAXOVERLAP + 1;
-
- x->x_npoints = npoints;
- x->x_phase = 0;
- x->x_period = period;
-
- x->windowSize = npoints;
- x->hopSize = period;
- x->blockSize = bs;
-
- for (i = 0; i < MAXOVERLAP; i++) x->x_sumbuf[i] = 0;
- for (i = 0; i < npoints; i++)
- x->buf[i] = (1.0f - cosf((2 * PI * i) / npoints))/npoints;
- for (; i < npoints+INITVSTAKEN; i++) x->buf[i] = 0;
-
- x->x_f = 0;
-
- x->x_allocforvs = INITVSTAKEN;
-
- // ~ ~ ~ dsp ~ ~ ~
- if (x->x_period % x->blockSize)
- {
- x->x_realperiod = x->x_period + x->blockSize - (x->x_period % x->blockSize);
- }
- else
- {
- x->x_realperiod = x->x_period;
- }
- // ~ ~ ~ ~ ~ ~ ~ ~
-}
-
-void tEnvPD_freeFromPool (tEnvPD* const xpd, tMempool* const mp)
-{
- _tMempool* m = *mp;
- _tEnvPD* x = *xpd;
-
- mpool_free(x, m->pool);
-}
-
float tEnvPD_tick (tEnvPD* const xpd)
{
_tEnvPD* x = *xpd;
@@ -374,7 +323,7 @@
void tAttackDetection_initToPool (tAttackDetection* const ad, int blocksize, int atk, int rel, tMempool* const mp)
{
_tMempool* m = *mp;
- *ad = (_tAttackDetection*) mpool_alloc(sizeof(_tAttackDetection), m->pool);
+ *ad = (_tAttackDetection*) mpool_alloc(sizeof(_tAttackDetection), &m->pool);
atkdtk_init(ad, blocksize, atk, rel);
}
@@ -384,7 +333,7 @@
_tMempool* m = *mp;
_tAttackDetection* a = *ad;
- mpool_free(a, m->pool);
+ mpool_free(a, &m->pool);
}
/*******Public Functions***********/
@@ -546,7 +495,7 @@
void tSNAC_initToPool (tSNAC* const snac, int overlaparg, tMempool* const mp)
{
_tMempool* m = *mp;
- _tSNAC* s = *snac = (_tSNAC*) mpool_alloc(sizeof(_tSNAC), m->pool);
+ _tSNAC* s = *snac = (_tSNAC*) mpool_alloc(sizeof(_tSNAC), &m->pool);
s->biasfactor = DEFBIAS;
s->timeindex = 0;
@@ -555,19 +504,12 @@
s->fidelity = 0.;
s->minrms = DEFMINRMS;
s->framesize = SNAC_FRAME_SIZE;
+
+ s->inputbuf = (float*) mpool_allocAndClear(sizeof(float) * SNAC_FRAME_SIZE, &m->pool);
+ s->processbuf = (float*) mpool_allocAndClear(sizeof(float) * (SNAC_FRAME_SIZE * 2), &m->pool);
+ s->spectrumbuf = (float*) mpool_allocAndClear(sizeof(float) * (SNAC_FRAME_SIZE / 2), &m->pool);
+ s->biasbuf = (float*) mpool_allocAndClear(sizeof(float) * SNAC_FRAME_SIZE, &m->pool);
-<<<<<<< HEAD
- s->inputbuf = (float*) mpool_allocAndClear(sizeof(float) * SNAC_FRAME_SIZE, m->pool);
- s->processbuf = (float*) mpool_allocAndClear(sizeof(float) * (SNAC_FRAME_SIZE * 2), m->pool);
- s->spectrumbuf = (float*) mpool_allocAndClear(sizeof(float) * (SNAC_FRAME_SIZE / 2), m->pool);
- s->biasbuf = (float*) mpool_allocAndClear(sizeof(float) * SNAC_FRAME_SIZE, m->pool);
-=======
- s->inputbuf = (float*) mpool_alloc(sizeof(float) * SNAC_FRAME_SIZE, m->pool);
- s->processbuf = (float*) mpool_alloc(sizeof(float) * (SNAC_FRAME_SIZE * 2), m->pool);
- s->spectrumbuf = (float*) mpool_alloc(sizeof(float) * (SNAC_FRAME_SIZE / 2), m->pool);
- s->biasbuf = (float*) mpool_alloc(sizeof(float) * SNAC_FRAME_SIZE, m->pool);
->>>>>>> b8628af4ceadb4749cd557e6bd3057c2639f3c97
-
snac_biasbuf(snac);
tSNAC_setOverlap(snac, overlaparg);
}
@@ -577,11 +519,11 @@
_tMempool* m = *mp;
_tSNAC* s = *snac;
- mpool_free(s->inputbuf, m->pool);
- mpool_free(s->processbuf, m->pool);
- mpool_free(s->spectrumbuf, m->pool);
- mpool_free(s->biasbuf, m->pool);
- mpool_free(s, m->pool);
+ mpool_free(s->inputbuf, &m->pool);
+ mpool_free(s->processbuf, &m->pool);
+ mpool_free(s->spectrumbuf, &m->pool);
+ mpool_free(s->biasbuf, &m->pool);
+ mpool_free(s, &m->pool);
}
/******************************************************************************/
@@ -933,7 +875,7 @@
void tPeriodDetection_initToPool (tPeriodDetection* const pd, float* in, float* out, int bufSize, int frameSize, tMempool* const mp)
{
_tMempool* m = *mp;
- _tPeriodDetection* p = *pd = (_tPeriodDetection*) mpool_alloc(sizeof(_tPeriodDetection), m->pool);
+ _tPeriodDetection* p = *pd = (_tPeriodDetection*) mpool_allocAndClear(sizeof(_tPeriodDetection), &m->pool);
p->inBuffer = in;
p->outBuffer = out;
@@ -963,7 +905,7 @@
tEnvPD_freeFromPool(&p->env, mp);
tSNAC_freeFromPool(&p->snac, mp);
- mpool_free(p, m->pool);
+ mpool_free(p, &m->pool);
}
float tPeriodDetection_findPeriod (tPeriodDetection* pd, float sample)
@@ -1012,124 +954,3 @@
_tPeriodDetection* p = *pd;
p->windowSize = ws;
}
-
-//===========================================================================
-// PERIODDETECTION
-//===========================================================================
-void tPeriodDetection_init (tPeriodDetection* const pd, float* in, float* out, int bufSize, int frameSize)
-{
- _tPeriodDetection* p = *pd = (_tPeriodDetection*) leaf_alloc(sizeof(_tPeriodDetection));
-
- p->inBuffer = in;
- p->outBuffer = out;
- p->bufSize = bufSize;
- p->frameSize = frameSize;
- p->framesPerBuffer = p->bufSize / p->frameSize;
- p->curBlock = 1;
- p->lastBlock = 0;
- p->index = 0;
-
- p->hopSize = DEFHOPSIZE;
- p->windowSize = DEFWINDOWSIZE;
- p->fba = FBA;
-
- tEnvPD_init(&p->env, p->windowSize, p->hopSize, p->frameSize);
-
- tSNAC_init(&p->snac, DEFOVERLAP);
-
- p->timeConstant = DEFTIMECONSTANT;
- p->radius = expf(-1000.0f * p->hopSize * leaf.invSampleRate / p->timeConstant);
-}
-
-void tPeriodDetection_free (tPeriodDetection* const pd)
-{
- _tPeriodDetection* p = *pd;
-
- tEnvPD_free(&p->env);
- tSNAC_free(&p->snac);
- leaf_free(p);
-}
-
-void tPeriodDetection_initToPool (tPeriodDetection* const pd, float* in, float* out, int bufSize, int frameSize, tMempool* const mp)
-{
- _tMempool* m = *mp;
- _tPeriodDetection* p = *pd = (_tPeriodDetection*) mpool_alloc(sizeof(_tPeriodDetection), m->pool);
-
- p->inBuffer = in;
- p->outBuffer = out;
- p->bufSize = bufSize;
- p->frameSize = frameSize;
- p->framesPerBuffer = p->bufSize / p->frameSize;
- p->curBlock = 1;
- p->lastBlock = 0;
- p->index = 0;
-
- p->hopSize = DEFHOPSIZE;
- p->windowSize = DEFWINDOWSIZE;
- p->fba = FBA;
-
- tEnvPD_initToPool(&p->env, p->windowSize, p->hopSize, p->frameSize, mp);
-
- tSNAC_initToPool(&p->snac, DEFOVERLAP, mp);
-
- p->timeConstant = DEFTIMECONSTANT;
- p->radius = expf(-1000.0f * p->hopSize * leaf.invSampleRate / p->timeConstant);
-}
-
-void tPeriodDetection_freeFromPool (tPeriodDetection* const pd, tMempool* const mp)
-{
- _tMempool* m = *mp;
- _tPeriodDetection* p = *pd;
-
- tEnvPD_freeFromPool(&p->env, mp);
- tSNAC_freeFromPool(&p->snac, mp);
- mpool_free(p, m->pool);
-}
-
-float tPeriodDetection_findPeriod (tPeriodDetection* pd, float sample)
-{
- _tPeriodDetection* p = *pd;
-
- int i, iLast;
-
- i = (p->curBlock*p->frameSize);
- iLast = (p->lastBlock*p->frameSize)+p->index;
-
- p->i = i;
- p->iLast = iLast;
-
- p->inBuffer[i+p->index] = sample;
-
- p->index++;
- p->indexstore = p->index;
- if (p->index >= p->frameSize)
- {
- p->index = 0;
-
- tEnvPD_processBlock(&p->env, &(p->inBuffer[i]));
-
- tSNAC_ioSamples(&p->snac, &(p->inBuffer[i]), &(p->outBuffer[i]), p->frameSize);
- p->period = tSNAC_getPeriod(&p->snac);
-
- p->curBlock++;
- if (p->curBlock >= p->framesPerBuffer) p->curBlock = 0;
- p->lastBlock++;
- if (p->lastBlock >= p->framesPerBuffer) p->lastBlock = 0;
- }
-
- // changed from period to p->period
- return p->period;
-}
-
-void tPeriodDetection_setHopSize(tPeriodDetection* pd, int hs)
-{
- _tPeriodDetection* p = *pd;
- p->hopSize = hs;
-}
-
-void tPeriodDetection_setWindowSize(tPeriodDetection* pd, int ws)
-{
- _tPeriodDetection* p = *pd;
- p->windowSize = ws;
-}
-
--- a/LEAF/Src/leaf-delay.c
+++ b/LEAF/Src/leaf-delay.c
@@ -51,13 +51,13 @@
void tDelay_initToPool (tDelay* const dl, uint32_t delay, uint32_t maxDelay, tMempool* const mp)
{
_tMempool* m = *mp;
- _tDelay* d = *dl = (_tDelay*) mpool_alloc(sizeof(_tDelay), m->pool);
+ _tDelay* d = *dl = (_tDelay*) mpool_alloc(sizeof(_tDelay), &m->pool);
d->maxDelay = maxDelay;
d->delay = delay;
- d->buff = (float*) mpool_alloc(sizeof(float) * maxDelay, m->pool);
+ d->buff = (float*) mpool_alloc(sizeof(float) * maxDelay, &m->pool);
d->inPoint = 0;
d->outPoint = 0;
@@ -75,8 +75,8 @@
_tMempool* m = *mp;
_tDelay* d = *dl;
- mpool_free(d->buff, m->pool);
- mpool_free(d, m->pool);
+ mpool_free(d->buff, &m->pool);
+ mpool_free(d, &m->pool);
}
float tDelay_tick (tDelay* const dl, float input)
@@ -211,7 +211,7 @@
void tLinearDelay_initToPool (tLinearDelay* const dl, float delay, uint32_t maxDelay, tMempool* const mp)
{
_tMempool* m = *mp;
- _tLinearDelay* d = *dl = (_tLinearDelay*) mpool_alloc(sizeof(_tLinearDelay), m->pool);
+ _tLinearDelay* d = *dl = (_tLinearDelay*) mpool_alloc(sizeof(_tLinearDelay), &m->pool);
d->maxDelay = maxDelay;
@@ -219,7 +219,7 @@
else if (delay < 0.0f) d->delay = 0.0f;
else d->delay = delay;
- d->buff = (float*) mpool_alloc(sizeof(float) * maxDelay, m->pool);
+ d->buff = (float*) mpool_alloc(sizeof(float) * maxDelay, &m->pool);
d->gain = 1.0f;
@@ -237,12 +237,10 @@
_tMempool* m = *mp;
_tLinearDelay* d = *dl;
- mpool_free(d->buff, m->pool);
- mpool_free(d, m->pool);
+ mpool_free(d->buff, &m->pool);
+ mpool_free(d, &m->pool);
}
-<<<<<<< HEAD
-
void tLinearDelay_clear(tLinearDelay* const dl)
{
_tLinearDelay* d = *dl;
@@ -254,8 +252,6 @@
}
-=======
->>>>>>> b8628af4ceadb4749cd557e6bd3057c2639f3c97
float tLinearDelay_tick (tLinearDelay* const dl, float input)
{
_tLinearDelay* d = *dl;
@@ -436,7 +432,7 @@
void tHermiteDelay_initToPool (tHermiteDelay* const dl, float delay, uint32_t maxDelay, tMempool* const mp)
{
_tMempool* m = *mp;
- _tHermiteDelay* d = *dl = (_tHermiteDelay*) mpool_alloc(sizeof(_tHermiteDelay), m->pool);
+ _tHermiteDelay* d = *dl = (_tHermiteDelay*) mpool_alloc(sizeof(_tHermiteDelay), &m->pool);
d->maxDelay = maxDelay;
@@ -444,7 +440,7 @@
else if (delay < 0.0f) d->delay = 0.0f;
else d->delay = delay;
- d->buff = (float*) mpool_alloc(sizeof(float) * maxDelay, m->pool);
+ d->buff = (float*) mpool_alloc(sizeof(float) * maxDelay, &m->pool);
d->gain = 1.0f;
@@ -462,8 +458,8 @@
_tMempool* m = *mp;
_tHermiteDelay* d = *dl;
- mpool_free(d->buff, m->pool);
- mpool_free(d, m->pool);
+ mpool_free(d->buff, &m->pool);
+ mpool_free(d, &m->pool);
}
@@ -661,7 +657,7 @@
void tAllpassDelay_initToPool (tAllpassDelay* const dl, float delay, uint32_t maxDelay, tMempool* const mp)
{
_tMempool* m = *mp;
- _tAllpassDelay* d = *dl = (_tAllpassDelay*) mpool_alloc(sizeof(_tAllpassDelay), m->pool);
+ _tAllpassDelay* d = *dl = (_tAllpassDelay*) mpool_alloc(sizeof(_tAllpassDelay), &m->pool);
d->maxDelay = maxDelay;
@@ -669,7 +665,7 @@
else if (delay < 0.0f) d->delay = 0.0f;
else d->delay = delay;
- d->buff = (float*) mpool_alloc(sizeof(float) * maxDelay, m->pool);
+ d->buff = (float*) mpool_alloc(sizeof(float) * maxDelay, &m->pool);
d->gain = 1.0f;
@@ -689,8 +685,8 @@
_tMempool* m = *mp;
_tAllpassDelay* d = *dl;
- mpool_free(d->buff, m->pool);
- mpool_free(d, m->pool);
+ mpool_free(d->buff, &m->pool);
+ mpool_free(d, &m->pool);
}
float tAllpassDelay_tick (tAllpassDelay* const dl, float input)
@@ -850,11 +846,11 @@
void tTapeDelay_initToPool (tTapeDelay* const dl, float delay, uint32_t maxDelay, tMempool* const mp)
{
_tMempool* m = *mp;
- _tTapeDelay* d = *dl = (_tTapeDelay*) mpool_alloc(sizeof(_tTapeDelay), m->pool);
+ _tTapeDelay* d = *dl = (_tTapeDelay*) mpool_alloc(sizeof(_tTapeDelay), &m->pool);
d->maxDelay = maxDelay;
- d->buff = (float*) mpool_alloc(sizeof(float) * maxDelay, m->pool);
+ d->buff = (float*) mpool_alloc(sizeof(float) * maxDelay, &m->pool);
d->gain = 1.0f;
@@ -873,8 +869,8 @@
_tMempool* m = *mp;
_tTapeDelay* d = *dl;
- mpool_free(d->buff, m->pool);
- mpool_free(d, m->pool);
+ mpool_free(d->buff, &m->pool);
+ mpool_free(d, &m->pool);
}
//#define SMOOTH_FACTOR 10.f
--- a/LEAF/Src/leaf-distortion.c
+++ b/LEAF/Src/leaf-distortion.c
@@ -45,7 +45,7 @@
void tSampleReducer_initToPool (tSampleReducer* const sr, tMempool* const mp)
{
_tMempool* m = *mp;
- _tSampleReducer* s = *sr = (_tSampleReducer*) mpool_alloc(sizeof(_tSampleReducer), m->pool);
+ _tSampleReducer* s = *sr = (_tSampleReducer*) mpool_alloc(sizeof(_tSampleReducer), &m->pool);
s->invRatio = 1.0f;
s->hold = 0.0f;
@@ -57,7 +57,7 @@
_tMempool* m = *mp;
_tSampleReducer* s = *sr;
- mpool_free(s, m->pool);
+ mpool_free(s, &m->pool);
}
float tSampleReducer_tick(tSampleReducer* const sr, float input)
@@ -117,7 +117,7 @@
void tOversampler_initToPool (tOversampler* const osr, int ratio, oBool extraQuality, tMempool* const mp)
{
_tMempool* m = *mp;
- _tOversampler* os = *osr = (_tOversampler*) mpool_alloc(sizeof(_tOversampler), m->pool);
+ _tOversampler* os = *osr = (_tOversampler*) mpool_alloc(sizeof(_tOversampler), &m->pool);
uint8_t offset = 0;
if (extraQuality) offset = 6;
@@ -129,8 +129,8 @@
os->numTaps = firNumTaps[idx];
os->phaseLength = os->numTaps / os->ratio;
os->pCoeffs = (float*) firCoeffs[idx];
- os->upState = mpool_alloc(sizeof(float) * os->numTaps * 2, m->pool);
- os->downState = mpool_alloc(sizeof(float) * os->numTaps * 2, m->pool);
+ os->upState = mpool_alloc(sizeof(float) * os->numTaps * 2, &m->pool);
+ os->downState = mpool_alloc(sizeof(float) * os->numTaps * 2, &m->pool);
}
}
@@ -139,9 +139,9 @@
_tMempool* m = *mp;
_tOversampler* os = *osr;
- mpool_free(os->upState, m->pool);
- mpool_free(os->downState, m->pool);
- mpool_free(os, m->pool);
+ mpool_free(os->upState, &m->pool);
+ mpool_free(os->downState, &m->pool);
+ mpool_free(os, &m->pool);
}
float tOversampler_tick(tOversampler* const osr, float input, float (*effectTick)(float))
@@ -385,7 +385,7 @@
void tLockhartWavefolder_initToPool (tLockhartWavefolder* const wf, tMempool* const mp)
{
_tMempool* m = *mp;
- _tLockhartWavefolder* w = *wf = (_tLockhartWavefolder*) mpool_alloc(sizeof(_tLockhartWavefolder), m->pool);
+ _tLockhartWavefolder* w = *wf = (_tLockhartWavefolder*) mpool_alloc(sizeof(_tLockhartWavefolder), &m->pool);
w->Ln1 = 0.0;
w->Fn1 = 0.0;
@@ -412,7 +412,7 @@
_tMempool* m = *mp;
_tLockhartWavefolder* w = *wf;
- mpool_free(w, m->pool);
+ mpool_free(w, &m->pool);
}
double tLockhartWavefolderLambert(double x, double ln)
@@ -511,7 +511,7 @@
void tCrusher_initToPool (tCrusher* const cr, tMempool* const mp)
{
_tMempool* m = *mp;
- _tCrusher* c = *cr = (_tCrusher*) mpool_alloc(sizeof(_tCrusher), m->pool);
+ _tCrusher* c = *cr = (_tCrusher*) mpool_alloc(sizeof(_tCrusher), &m->pool);
c->op = 4;
c->div = SCALAR;
@@ -526,7 +526,7 @@
_tMempool* m = *mp;
_tCrusher* c = *cr;
tSampleReducer_freeFromPool(&c->sReducer, mp);
- mpool_free(c, m->pool);
+ mpool_free(c, &m->pool);
}
float tCrusher_tick (tCrusher* const cr, float input)
--- a/LEAF/Src/leaf-dynamics.c
+++ b/LEAF/Src/leaf-dynamics.c
@@ -66,7 +66,7 @@
void tCompressor_initToPool (tCompressor* const comp, tMempool* const mp)
{
_tMempool* m = *mp;
- _tCompressor* c = *comp = (_tCompressor*) mpool_alloc(sizeof(_tCompressor), m->pool);
+ _tCompressor* c = *comp = (_tCompressor*) mpool_alloc(sizeof(_tCompressor), &m->pool);
c->tauAttack = 100;
c->tauRelease = 100;
@@ -84,7 +84,7 @@
_tMempool* m = *mp;
_tCompressor* c = *comp;
- mpool_free(c, m->pool);
+ mpool_free(c, &m->pool);
}
float tCompressor_tick(tCompressor* const comp, float in)
@@ -160,7 +160,7 @@
void tFeedbackLeveler_initToPool (tFeedbackLeveler* const fb, float targetLevel, float factor, float strength, int mode, tMempool* const mp)
{
_tMempool* m = *mp;
- _tFeedbackLeveler* p = *fb = (_tFeedbackLeveler*) mpool_alloc(sizeof(_tFeedbackLeveler), m->pool);
+ _tFeedbackLeveler* p = *fb = (_tFeedbackLeveler*) mpool_alloc(sizeof(_tFeedbackLeveler), &m->pool);
p->curr=0.0f;
p->targetLevel=targetLevel;
@@ -175,7 +175,7 @@
_tFeedbackLeveler* p = *fb;
tPowerFollower_freeFromPool(&p->pwrFlw, mp);
- mpool_free(p, m->pool);
+ mpool_free(p, &m->pool);
}
void tFeedbackLeveler_setStrength(tFeedbackLeveler* const fb, float strength)
--- a/LEAF/Src/leaf-effects.c
+++ b/LEAF/Src/leaf-effects.c
@@ -62,7 +62,7 @@
void tTalkbox_initToPool (tTalkbox* const voc, int bufsize, tMempool* const mp)
{
_tMempool* m = *mp;
- _tTalkbox* v = *voc = (_tTalkbox*) mpool_alloc(sizeof(_tTalkbox), m->pool);
+ _tTalkbox* v = *voc = (_tTalkbox*) mpool_alloc(sizeof(_tTalkbox), &m->pool);
v->param[0] = 0.5f; //wet
v->param[1] = 0.0f; //dry
@@ -71,11 +71,11 @@
v->bufsize = bufsize;
- v->car0 = (float*) mpool_alloc(sizeof(float) * v->bufsize, m->pool);
- v->car1 = (float*) mpool_alloc(sizeof(float) * v->bufsize, m->pool);
- v->window = (float*) mpool_alloc(sizeof(float) * v->bufsize, m->pool);
- v->buf0 = (float*) mpool_alloc(sizeof(float) * v->bufsize, m->pool);
- v->buf1 = (float*) mpool_alloc(sizeof(float) * v->bufsize, m->pool);
+ v->car0 = (float*) mpool_alloc(sizeof(float) * v->bufsize, &m->pool);
+ v->car1 = (float*) mpool_alloc(sizeof(float) * v->bufsize, &m->pool);
+ v->window = (float*) mpool_alloc(sizeof(float) * v->bufsize, &m->pool);
+ v->buf0 = (float*) mpool_alloc(sizeof(float) * v->bufsize, &m->pool);
+ v->buf1 = (float*) mpool_alloc(sizeof(float) * v->bufsize, &m->pool);
tTalkbox_update(voc);
tTalkbox_suspend(voc);
@@ -86,13 +86,13 @@
_tMempool* m = *mp;
_tTalkbox* v = *voc;
- mpool_free(v->buf1, m->pool);
- mpool_free(v->buf0, m->pool);
- mpool_free(v->window, m->pool);
- mpool_free(v->car1, m->pool);
- mpool_free(v->car0, m->pool);
+ mpool_free(v->buf1, &m->pool);
+ mpool_free(v->buf0, &m->pool);
+ mpool_free(v->window, &m->pool);
+ mpool_free(v->car1, &m->pool);
+ mpool_free(v->car0, &m->pool);
- mpool_free(v, m->pool);
+ mpool_free(v, &m->pool);
}
void tTalkbox_update(tTalkbox* const voc) ///update internal parameters...
@@ -305,7 +305,7 @@
void tVocoder_initToPool (tVocoder* const voc, tMempool* const mp)
{
_tMempool* m = *mp;
- _tVocoder* v = *voc = (_tVocoder*) mpool_alloc(sizeof(_tVocoder), m->pool);
+ _tVocoder* v = *voc = (_tVocoder*) mpool_alloc(sizeof(_tVocoder), &m->pool);
v->param[0] = 0.33f; //input select
v->param[1] = 0.50f; //output dB
@@ -324,7 +324,7 @@
_tMempool* m = *mp;
_tVocoder* v = *voc;
- mpool_free(v, m->pool);
+ mpool_free(v, &m->pool);
}
void tVocoder_update (tVocoder* const voc)
@@ -506,17 +506,11 @@
// init
void tSOLAD_init(tSOLAD* const wp)
{
-<<<<<<< HEAD
_tSOLAD* w = *wp = (_tSOLAD*) leaf_allocAndClear(sizeof(_tSOLAD));
w->pitchfactor = 1.;
w->delaybuf = (float*) leaf_allocAndClear(sizeof(float) * (LOOPSIZE+16));
-=======
- _tSOLAD* w = *wp = (_tSOLAD*) leaf_alloc(sizeof(_tSOLAD));
- w->pitchfactor = 1.;
- w->delaybuf = (float*) leaf_alloc(sizeof(float) * (LOOPSIZE+16));
->>>>>>> b8628af4ceadb4749cd557e6bd3057c2639f3c97
solad_init(w);
}
@@ -531,17 +525,12 @@
void tSOLAD_initToPool (tSOLAD* const wp, tMempool* const mp)
{
_tMempool* m = *mp;
-<<<<<<< HEAD
- _tSOLAD* w = *wp = (_tSOLAD*) mpool_allocAndClear(sizeof(_tSOLAD), m->pool);
+
+ _tSOLAD* w = *wp = (_tSOLAD*) mpool_allocAndClear(sizeof(_tSOLAD), &m->pool);
w->pitchfactor = 1.;
- w->delaybuf = (float*) mpool_allocAndClear(sizeof(float) * (LOOPSIZE+16), m->pool);
-=======
- _tSOLAD* w = *wp = (_tSOLAD*) mpool_alloc(sizeof(_tSOLAD), m->pool);
-
- w->pitchfactor = 1.;
- w->delaybuf = (float*) mpool_alloc(sizeof(float) * (LOOPSIZE+16), m->pool);
->>>>>>> b8628af4ceadb4749cd557e6bd3057c2639f3c97
+ w->delaybuf = (float*) mpool_allocAndClear(sizeof(float) * (LOOPSIZE+16), &m->pool);
+
solad_init(w);
}
@@ -550,8 +539,8 @@
_tMempool* m = *mp;
_tSOLAD* w = *wp;
- mpool_free(w->delaybuf, m->pool);
- mpool_free(w, m->pool);
+ mpool_free(w->delaybuf, &m->pool);
+ mpool_free(w, &m->pool);
}
// send one block of input samples, receive one block of output samples
@@ -919,11 +908,9 @@
void tPitchShift_initToPool (tPitchShift* const psr, tPeriodDetection* const pd, float* out, int bufSize, tMempool* const mp)
{
_tMempool* m = *mp;
-<<<<<<< HEAD
- _tPitchShift* ps = *psr = (_tPitchShift*) mpool_allocAndClear(sizeof(_tPitchShift), m->pool);
-=======
- _tPitchShift* ps = *psr = (_tPitchShift*) mpool_alloc(sizeof(_tPitchShift), m->pool);
->>>>>>> b8628af4ceadb4749cd557e6bd3057c2639f3c97
+
+ _tPitchShift* ps = *psr = (_tPitchShift*) mpool_allocAndClear(sizeof(_tPitchShift), &m->pool);
+
_tPeriodDetection* p = *pd;
ps->p = pd;
@@ -951,7 +938,7 @@
tSOLAD_freeFromPool(&ps->sola, mp);
tHighpass_freeFromPool(&ps->hp, mp);
- mpool_free(ps, m->pool);
+ mpool_free(ps, &m->pool);
}
void tPitchShift_setPitchFactor(tPitchShift* psr, float pf)
@@ -1073,23 +1060,14 @@
void tRetune_init(tRetune* const rt, int numVoices, int bufSize, int frameSize)
{
-<<<<<<< HEAD
_tRetune* r = *rt = (_tRetune*) leaf_allocAndClear(sizeof(_tRetune));
-=======
- _tRetune* r = *rt = (_tRetune*) leaf_alloc(sizeof(_tRetune));
->>>>>>> b8628af4ceadb4749cd557e6bd3057c2639f3c97
r->bufSize = bufSize;
r->frameSize = frameSize;
r->numVoices = numVoices;
-<<<<<<< HEAD
r->inBuffer = (float*) leaf_allocAndClear(sizeof(float) * r->bufSize);
r->outBuffers = (float**) leaf_allocAndClear(sizeof(float*) * r->numVoices);
-=======
- r->inBuffer = (float*) leaf_alloc(sizeof(float) * r->bufSize);
- r->outBuffers = (float**) leaf_alloc(sizeof(float*) * r->numVoices);
->>>>>>> b8628af4ceadb4749cd557e6bd3057c2639f3c97
r->hopSize = DEFHOPSIZE;
r->windowSize = DEFWINDOWSIZE;
@@ -1098,7 +1076,6 @@
r->inputPeriod = 0.0f;
-<<<<<<< HEAD
r->ps = (tPitchShift*) leaf_allocAndClear(sizeof(tPitchShift) * r->numVoices);
r->pitchFactor = (float*) leaf_allocAndClear(sizeof(float) * r->numVoices);
r->tickOutput = (float*) leaf_allocAndClear(sizeof(float) * r->numVoices);
@@ -1105,14 +1082,6 @@
for (int i = 0; i < r->numVoices; ++i)
{
r->outBuffers[i] = (float*) leaf_allocAndClear(sizeof(float) * r->bufSize);
-=======
- r->ps = (tPitchShift*) leaf_alloc(sizeof(tPitchShift) * r->numVoices);
- r->pitchFactor = (float*) leaf_alloc(sizeof(float) * r->numVoices);
- r->tickOutput = (float*) leaf_alloc(sizeof(float) * r->numVoices);
- for (int i = 0; i < r->numVoices; ++i)
- {
- r->outBuffers[i] = (float*) leaf_alloc(sizeof(float) * r->bufSize);
->>>>>>> b8628af4ceadb4749cd557e6bd3057c2639f3c97
}
tPeriodDetection_init(&r->pd, r->inBuffer, r->outBuffers[0], r->bufSize, r->frameSize);
@@ -1144,19 +1113,14 @@
void tRetune_initToPool (tRetune* const rt, int numVoices, int bufSize, int frameSize, tMempool* const mp)
{
_tMempool* m = *mp;
- _tRetune* r = *rt = (_tRetune*) mpool_alloc(sizeof(_tRetune), m->pool);
+ _tRetune* r = *rt = (_tRetune*) mpool_alloc(sizeof(_tRetune), &m->pool);
r->bufSize = bufSize;
r->frameSize = frameSize;
r->numVoices = numVoices;
-<<<<<<< HEAD
- r->inBuffer = (float*) mpool_allocAndClear(sizeof(float) * r->bufSize, m->pool);
- r->outBuffers = (float**) mpool_allocAndClear(sizeof(float*) * r->numVoices, m->pool);
-=======
- r->inBuffer = (float*) mpool_alloc(sizeof(float) * r->bufSize, m->pool);
- r->outBuffers = (float**) mpool_alloc(sizeof(float*) * r->numVoices, m->pool);
->>>>>>> b8628af4ceadb4749cd557e6bd3057c2639f3c97
+ r->inBuffer = (float*) mpool_allocAndClear(sizeof(float) * r->bufSize, &m->pool);
+ r->outBuffers = (float**) mpool_allocAndClear(sizeof(float*) * r->numVoices, &m->pool);
r->hopSize = DEFHOPSIZE;
r->windowSize = DEFWINDOWSIZE;
@@ -1164,22 +1128,13 @@
tRetune_setTimeConstant(rt, DEFTIMECONSTANT);
r->inputPeriod = 0.0f;
-
-<<<<<<< HEAD
- r->ps = (tPitchShift*) mpool_allocAndClear(sizeof(tPitchShift) * r->numVoices, m->pool);
- r->pitchFactor = (float*) mpool_allocAndClear(sizeof(float) * r->numVoices, m->pool);
- r->tickOutput = (float*) mpool_allocAndClear(sizeof(float) * r->numVoices, m->pool);
+
+ r->ps = (tPitchShift*) mpool_allocAndClear(sizeof(tPitchShift) * r->numVoices, &m->pool);
+ r->pitchFactor = (float*) mpool_allocAndClear(sizeof(float) * r->numVoices, &m->pool);
+ r->tickOutput = (float*) mpool_allocAndClear(sizeof(float) * r->numVoices, &m->pool);
for (int i = 0; i < r->numVoices; ++i)
{
- r->outBuffers[i] = (float*) mpool_allocAndClear(sizeof(float) * r->bufSize, m->pool);
-=======
- r->ps = (tPitchShift*) mpool_alloc(sizeof(tPitchShift) * r->numVoices, m->pool);
- r->pitchFactor = (float*) mpool_alloc(sizeof(float) * r->numVoices, m->pool);
- r->tickOutput = (float*) mpool_alloc(sizeof(float) * r->numVoices, m->pool);
- for (int i = 0; i < r->numVoices; ++i)
- {
- r->outBuffers[i] = (float*) mpool_alloc(sizeof(float) * r->bufSize, m->pool);
->>>>>>> b8628af4ceadb4749cd557e6bd3057c2639f3c97
+ r->outBuffers[i] = (float*) mpool_allocAndClear(sizeof(float) * r->bufSize, &m->pool);
}
tPeriodDetection_initToPool(&r->pd, r->inBuffer, r->outBuffers[0], r->bufSize, r->frameSize, mp);
@@ -1199,14 +1154,14 @@
for (int i = 0; i < r->numVoices; ++i)
{
tPitchShift_freeFromPool(&r->ps[i], mp);
- mpool_free(r->outBuffers[i], m->pool);
+ mpool_free(r->outBuffers[i], &m->pool);
}
- mpool_free(r->tickOutput, m->pool);
- mpool_free(r->pitchFactor, m->pool);
- mpool_free(r->ps, m->pool);
- mpool_free(r->inBuffer, m->pool);
- mpool_free(r->outBuffers, m->pool);
- mpool_free(r, m->pool);
+ mpool_free(r->tickOutput, &m->pool);
+ mpool_free(r->pitchFactor, &m->pool);
+ mpool_free(r->ps, &m->pool);
+ mpool_free(r->inBuffer, &m->pool);
+ mpool_free(r->outBuffers, &m->pool);
+ mpool_free(r, &m->pool);
}
float* tRetune_tick(tRetune* const rt, float sample)
@@ -1337,7 +1292,6 @@
for (int i = 0; i < r->numVoices; ++i)
{
r->outBuffers[i] = (float*) leaf_alloc(sizeof(float) * r->bufSize);
-<<<<<<< HEAD
}
tPeriodDetection_init(&r->pd, r->inBuffer, r->outBuffers[0], r->bufSize, r->frameSize);
@@ -1347,17 +1301,6 @@
tPitchShift_init(&r->ps[i], &r->pd, r->outBuffers[i], r->bufSize);
}
-=======
- }
-
- tPeriodDetection_init(&r->pd, r->inBuffer, r->outBuffers[0], r->bufSize, r->frameSize);
-
- for (int i = 0; i < r->numVoices; ++i)
- {
- tPitchShift_init(&r->ps[i], &r->pd, r->outBuffers[i], r->bufSize);
- }
-
->>>>>>> b8628af4ceadb4749cd557e6bd3057c2639f3c97
r->inputPeriod = 0.0f;
}
@@ -1382,14 +1325,14 @@
void tAutotune_initToPool (tAutotune* const rt, int numVoices, int bufSize, int frameSize, tMempool* const mp)
{
_tMempool* m = *mp;
- _tAutotune* r = *rt = (_tAutotune*) mpool_alloc(sizeof(_tAutotune), m->pool);
+ _tAutotune* r = *rt = (_tAutotune*) mpool_alloc(sizeof(_tAutotune), &m->pool);
r->bufSize = bufSize;
r->frameSize = frameSize;
r->numVoices = numVoices;
- r->inBuffer = (float*) mpool_alloc(sizeof(float) * r->bufSize, m->pool);
- r->outBuffers = (float**) mpool_alloc(sizeof(float*) * r->numVoices, m->pool);
+ r->inBuffer = (float*) mpool_alloc(sizeof(float) * r->bufSize, &m->pool);
+ r->outBuffers = (float**) mpool_alloc(sizeof(float*) * r->numVoices, &m->pool);
r->hopSize = DEFHOPSIZE;
r->windowSize = DEFWINDOWSIZE;
@@ -1398,12 +1341,12 @@
- r->ps = (tPitchShift*) mpool_alloc(sizeof(tPitchShift) * r->numVoices, m->pool);
- r->freq = (float*) mpool_alloc(sizeof(float) * r->numVoices, m->pool);
- r->tickOutput = (float*) mpool_alloc(sizeof(float) * r->numVoices, m->pool);
+ r->ps = (tPitchShift*) mpool_alloc(sizeof(tPitchShift) * r->numVoices, &m->pool);
+ r->freq = (float*) mpool_alloc(sizeof(float) * r->numVoices, &m->pool);
+ r->tickOutput = (float*) mpool_alloc(sizeof(float) * r->numVoices, &m->pool);
for (int i = 0; i < r->numVoices; ++i)
{
- r->outBuffers[i] = (float*) mpool_alloc(sizeof(float) * r->bufSize, m->pool);
+ r->outBuffers[i] = (float*) mpool_alloc(sizeof(float) * r->bufSize, &m->pool);
}
tPeriodDetection_initToPool(&r->pd, r->inBuffer, r->outBuffers[0], r->bufSize, r->frameSize, mp);
@@ -1425,14 +1368,14 @@
for (int i = 0; i < r->numVoices; ++i)
{
tPitchShift_freeFromPool(&r->ps[i], mp);
- mpool_free(r->outBuffers[i], m->pool);
+ mpool_free(r->outBuffers[i], &m->pool);
}
- mpool_free(r->tickOutput, m->pool);
- mpool_free(r->freq, m->pool);
- mpool_free(r->ps, m->pool);
- mpool_free(r->inBuffer, m->pool);
- mpool_free(r->outBuffers, m->pool);
- mpool_free(r, m->pool);
+ mpool_free(r->tickOutput, &m->pool);
+ mpool_free(r->freq, &m->pool);
+ mpool_free(r->ps, &m->pool);
+ mpool_free(r->inBuffer, &m->pool);
+ mpool_free(r->outBuffers, &m->pool);
+ mpool_free(r, &m->pool);
}
float* tAutotune_tick(tAutotune* const rt, float sample)
@@ -1547,7 +1490,6 @@
_tFormantShifter* fs = *fsr = (_tFormantShifter*) leaf_alloc(sizeof(_tFormantShifter));
fs->ford = order;
- fs->bufsize = bufsize;
fs->fk = (float*) leaf_alloc(sizeof(float) * fs->ford);
fs->fb = (float*) leaf_alloc(sizeof(float) * fs->ford);
fs->fc = (float*) leaf_alloc(sizeof(float) * fs->ford);
@@ -1556,15 +1498,9 @@
fs->fsig = (float*) leaf_alloc(sizeof(float) * fs->ford);
fs->fsmooth = (float*) leaf_alloc(sizeof(float) * fs->ford);
fs->ftvec = (float*) leaf_alloc(sizeof(float) * fs->ford);
-
- fs->fbuff = (float**) leaf_alloc(sizeof(float*) * fs->ford);
- for (int i = 0; i < fs->ford; i++)
- {
- fs->fbuff[i] = (float*) leaf_alloc(sizeof(float) * fs->bufsize);
- }
-
-
- fs->falph = powf(0.001f, 80.0f / (leaf.sampleRate));
+ fs->fbuff = (float*) leaf_alloc(sizeof(float*) * fs->ford);
+
+ fs->falph = powf(0.001f, 10.0f / (leaf.sampleRate));
fs->flamb = -(0.8517f*sqrtf(atanf(0.06583f*leaf.sampleRate))-0.1916f);
fs->fhp = 0.0f;
fs->flp = 0.0f;
@@ -1574,10 +1510,10 @@
fs->cbi = 0;
fs->intensity = 1.0f;
fs->invIntensity = 1.0f;
- tHighpass_init(&fs->hp, 20.0f);
- tHighpass_init(&fs->hp2, 20.0f);
- tFeedbackLeveler_init(&fs->fbl1, 0.8f, 0.01f, 0.125f, 0);
- tFeedbackLeveler_init(&fs->fbl2, 0.8f, 0.01f, 0.125f, 0);
+ tHighpass_init(&fs->hp, 10.0f);
+ tHighpass_init(&fs->hp2, 10.0f);
+ tFeedbackLeveler_init(&fs->fbl1, 0.8f, 0.005f, 0.125f, 0);
+ tFeedbackLeveler_init(&fs->fbl2, 0.8f, 0.005f, 0.125f, 0);
}
void tFormantShifter_free(tFormantShifter* const fsr)
@@ -1592,10 +1528,6 @@
leaf_free(fs->fsig);
leaf_free(fs->fsmooth);
leaf_free(fs->ftvec);
- for (int i = 0; i < fs->ford; i++)
- {
- leaf_free(fs->fbuff[i]);
- }
leaf_free(fs->fbuff);
tHighpass_free(&fs->hp);
tHighpass_free(&fs->hp2);
@@ -1607,26 +1539,22 @@
void tFormantShifter_initToPool (tFormantShifter* const fsr, int bufsize, int order, tMempool* const mp)
{
_tMempool* m = *mp;
- _tFormantShifter* fs = *fsr = (_tFormantShifter*) mpool_alloc(sizeof(_tFormantShifter), m->pool);
+ _tFormantShifter* fs = *fsr = (_tFormantShifter*) mpool_alloc(sizeof(_tFormantShifter), &m->pool);
fs->ford = order;
- fs->bufsize = bufsize;
- fs->fk = (float*) mpool_alloc(sizeof(float) * fs->ford, m->pool);
- fs->fb = (float*) mpool_alloc(sizeof(float) * fs->ford, m->pool);
- fs->fc = (float*) mpool_alloc(sizeof(float) * fs->ford, m->pool);
- fs->frb = (float*) mpool_alloc(sizeof(float) * fs->ford, m->pool);
- fs->frc = (float*) mpool_alloc(sizeof(float) * fs->ford, m->pool);
- fs->fsig = (float*) mpool_alloc(sizeof(float) * fs->ford, m->pool);
- fs->fsmooth = (float*) mpool_alloc(sizeof(float) * fs->ford, m->pool);
- fs->ftvec = (float*) mpool_alloc(sizeof(float) * fs->ford, m->pool);
+ fs->fk = (float*) mpool_alloc(sizeof(float) * fs->ford, &m->pool);
+ fs->fb = (float*) mpool_alloc(sizeof(float) * fs->ford, &m->pool);
+ fs->fc = (float*) mpool_alloc(sizeof(float) * fs->ford, &m->pool);
+ fs->frb = (float*) mpool_alloc(sizeof(float) * fs->ford, &m->pool);
+ fs->frc = (float*) mpool_alloc(sizeof(float) * fs->ford, &m->pool);
+ fs->fsig = (float*) mpool_alloc(sizeof(float) * fs->ford, &m->pool);
+ fs->fsmooth = (float*) mpool_alloc(sizeof(float) * fs->ford, &m->pool);
+ fs->ftvec = (float*) mpool_alloc(sizeof(float) * fs->ford, &m->pool);
- fs->fbuff = (float**) mpool_alloc(sizeof(float*) * fs->ford, m->pool);
- for (int i = 0; i < fs->ford; i++)
- {
- fs->fbuff[i] = (float*) mpool_alloc(sizeof(float) * fs->bufsize, m->pool);
- }
+ fs->fbuff = (float*) mpool_alloc(sizeof(float*) * fs->ford, &m->pool);
+
- fs->falph = powf(0.001f, 80.0f / (leaf.sampleRate));
+ fs->falph = powf(0.001f, 10.0f / (leaf.sampleRate));
fs->flamb = -(0.8517f*sqrtf(atanf(0.06583f*leaf.sampleRate))-0.1916f);
fs->fhp = 0.0f;
fs->flp = 0.0f;
@@ -1647,24 +1575,20 @@
_tMempool* m = *mp;
_tFormantShifter* fs = *fsr;
- mpool_free(fs->fk, m->pool);
- mpool_free(fs->fb, m->pool);
- mpool_free(fs->fc, m->pool);
- mpool_free(fs->frb, m->pool);
- mpool_free(fs->frc, m->pool);
- mpool_free(fs->fsig, m->pool);
- mpool_free(fs->fsmooth, m->pool);
- mpool_free(fs->ftvec, m->pool);
- for (int i = 0; i < fs->ford; i++)
- {
- mpool_free(fs->fbuff[i], m->pool);
- }
- mpool_free(fs->fbuff, m->pool);
+ mpool_free(fs->fk, &m->pool);
+ mpool_free(fs->fb, &m->pool);
+ mpool_free(fs->fc, &m->pool);
+ mpool_free(fs->frb, &m->pool);
+ mpool_free(fs->frc, &m->pool);
+ mpool_free(fs->fsig, &m->pool);
+ mpool_free(fs->fsmooth, &m->pool);
+ mpool_free(fs->ftvec, &m->pool);
+ mpool_free(fs->fbuff, &m->pool);
tHighpass_freeFromPool(&fs->hp, mp);
tHighpass_freeFromPool(&fs->hp2, mp);
tFeedbackLeveler_freeFromPool(&fs->fbl1, mp);
tFeedbackLeveler_freeFromPool(&fs->fbl2, mp);
- mpool_free(fs, m->pool);
+ mpool_free(fs, &m->pool);
}
float tFormantShifter_tick(tFormantShifter* const fsr, float in)
@@ -1676,11 +1600,11 @@
{
_tFormantShifter* fs = *fsr;
in = tFeedbackLeveler_tick(&fs->fbl1, in * fs->intensity);
- in = tHighpass_tick(&fs->hp, in);
+ in = tHighpass_tick(&fs->hp, in * 100.0f);
float fa, fb, fc, foma, falph, ford, flamb, tf, fk;
- int ti4;
+
ford = fs->ford;
falph = fs->falph;
foma = (1.0f - falph);
@@ -1687,7 +1611,6 @@
flamb = fs->flamb;
tf = in;
- ti4 = fs->cbi;
fa = tf - fs->fhp;
fs->fhp = tf;
@@ -1703,16 +1626,12 @@
tf = fk/(fs->fsig[i] + 0.000001f);
tf = tf*foma + fs->fsmooth[i]*falph;
fs->fsmooth[i] = tf;
- fs->fbuff[i][ti4] = tf;
+ fs->fbuff[i] = tf;
fb = fc - tf*fa;
fa = fa - tf*fc;
}
- fs->cbi++;
- if(fs->cbi >= fs->bufsize)
- {
- fs->cbi = 0;
- }
- return fa;
+
+ return fa / 100.f;
//return fa * fs->invIntensity;
}
@@ -1721,14 +1640,12 @@
_tFormantShifter* fs = *fsr;
float fa, fb, fc, ford, flpa, flamb, tf, tf2, f0resp, f1resp, frlamb;
- int ti4;
ford = fs->ford;
flpa = fs->flpa;
flamb = fs->flamb;
- tf = fs->shiftFactor * (1+flamb)/(1-flamb);
- frlamb = (tf-1)/(tf+1);
- ti4 = fs->cbi;
+ tf = fs->shiftFactor * (1.0f+flamb)/(1.0f-flamb);
+ frlamb = (tf-1.0f)/(tf+1.0f);
tf2 = in;
fa = 0.0f;
@@ -1736,7 +1653,7 @@
for (int i=0; i<ford; i++)
{
fc = (fb-fs->frc[i])*frlamb + fs->frb[i];
- tf = fs->fbuff[i][ti4];
+ tf = fs->fbuff[i];
fb = fc - tf*fa;
fs->ftvec[i] = tf*fc;
fa = fa - fs->ftvec[i];
@@ -1749,12 +1666,12 @@
f0resp = tf;
// second time: compute 1-response
- fa = 1;
+ fa = 1.0f;
fb = fa;
for (int i=0; i<ford; i++)
{
fc = (fb-fs->frc[i])*frlamb + fs->frb[i];
- tf = fs->fbuff[i][ti4];
+ tf = fs->fbuff[i];
fb = fc - tf*fa;
fs->ftvec[i] = tf*fc;
fa = fa - fs->ftvec[i];
@@ -1787,7 +1704,7 @@
fc = (fb-fs->frc[i])*frlamb + fs->frb[i];
fs->frc[i] = fc;
fs->frb[i] = fb;
- tf = fs->fbuff[i][ti4];
+ tf = fs->fbuff[i];
fb = fc - tf*fa;
fa = fa - tf*fc;
}
--- a/LEAF/Src/leaf-electrical.c
+++ b/LEAF/Src/leaf-electrical.c
@@ -181,7 +181,7 @@
void tWDF_initToPool (tWDF* const wdf, WDFComponentType type, float value, tWDF* const rL, tWDF* const rR, tMempool* const mp)
{
_tMempool* m = *mp;
- *wdf = (_tWDF*) mpool_alloc(sizeof(_tWDF), m->pool);
+ *wdf = (_tWDF*) mpool_alloc(sizeof(_tWDF), &m->pool);
wdf_init(wdf, type, value, rL, rR);
}
@@ -191,7 +191,7 @@
_tMempool* m = *mp;
_tWDF* r = *wdf;
- mpool_free(r, m->pool);
+ mpool_free(r, &m->pool);
}
float tWDF_tick(tWDF* const wdf, float sample, tWDF* const outputPoint, uint8_t paramsChanged)
--- a/LEAF/Src/leaf-envelopes.c
+++ b/LEAF/Src/leaf-envelopes.c
@@ -73,7 +73,7 @@
void tEnvelope_initToPool (tEnvelope* const envlp, float attack, float decay, oBool loop, tMempool* const mp)
{
_tMempool* m = *mp;
- _tEnvelope* env = *envlp = (_tEnvelope*) mpool_alloc(sizeof(_tEnvelope), m->pool);
+ _tEnvelope* env = *envlp = (_tEnvelope*) mpool_alloc(sizeof(_tEnvelope), &m->pool);
env->exp_buff = exp_decay;
env->inc_buff = attack_decay_inc;
@@ -115,7 +115,7 @@
{
_tMempool* m = *mp;
_tEnvelope* env = *envlp;
- mpool_free(env, m->pool);
+ mpool_free(env, &m->pool);
}
void tEnvelope_setAttack(tEnvelope* const envlp, float attack)
@@ -320,7 +320,7 @@
void tADSR_initToPool (tADSR* const adsrenv, float attack, float decay, float sustain, float release, tMempool* const mp)
{
_tMempool* m = *mp;
- _tADSR* adsr = *adsrenv = (_tADSR*) mpool_alloc(sizeof(_tADSR), m->pool);
+ _tADSR* adsr = *adsrenv = (_tADSR*) mpool_alloc(sizeof(_tADSR), &m->pool);
adsr->exp_buff = exp_decay;
adsr->inc_buff = attack_decay_inc;
@@ -379,7 +379,7 @@
_tMempool* m = *mp;
_tADSR* adsr = *adsrenv;
- mpool_free(adsr, m->pool);
+ mpool_free(adsr, &m->pool);
}
void tADSR_setAttack(tADSR* const adsrenv, float attack)
@@ -594,7 +594,7 @@
void tRamp_initToPool (tRamp* const r, float time, int samples_per_tick, tMempool* const mp)
{
_tMempool* m = *mp;
- _tRamp* ramp = *r = (_tRamp*) mpool_alloc(sizeof(_tRamp), m->pool);
+ _tRamp* ramp = *r = (_tRamp*) mpool_alloc(sizeof(_tRamp), &m->pool);
ramp->inv_sr_ms = 1.0f/(leaf.sampleRate*0.001f);
ramp->minimum_time = ramp->inv_sr_ms * samples_per_tick;
@@ -619,7 +619,7 @@
_tMempool* m = *mp;
_tRamp* ramp = *r;
- mpool_free(ramp, m->pool);
+ mpool_free(ramp, &m->pool);
}
void tRamp_setTime(tRamp* const ramp, float time)
@@ -706,7 +706,7 @@
void tExpSmooth_initToPool (tExpSmooth* const expsmooth, float val, float factor, tMempool* const mp)
{
_tMempool* m = *mp;
- _tExpSmooth* smooth = *expsmooth = (_tExpSmooth*) mpool_alloc(sizeof(_tExpSmooth), m->pool);
+ _tExpSmooth* smooth = *expsmooth = (_tExpSmooth*) mpool_alloc(sizeof(_tExpSmooth), &m->pool);
smooth->curr=val;
smooth->dest=val;
@@ -721,7 +721,7 @@
_tMempool* m = *mp;
_tExpSmooth* smooth = *expsmooth;
- mpool_free(smooth, m->pool);
+ mpool_free(smooth, &m->pool);
}
void tExpSmooth_setFactor(tExpSmooth* const expsmooth, float factor)
--- a/LEAF/Src/leaf-filters.c
+++ b/LEAF/Src/leaf-filters.c
@@ -43,7 +43,7 @@
void tAllpass_initToPool (tAllpass* const ft, float initDelay, uint32_t maxDelay, tMempool* const mp)
{
_tMempool* m = *mp;
- _tAllpass* f = *ft = (_tAllpass*) mpool_alloc(sizeof(_tAllpass), m->pool);
+ _tAllpass* f = *ft = (_tAllpass*) mpool_alloc(sizeof(_tAllpass), &m->pool);
f->gain = 0.7f;
@@ -58,7 +58,7 @@
_tAllpass* f = *ft;
tLinearDelay_freeFromPool(&f->delay, mp);
- mpool_free(f, m->pool);
+ mpool_free(f, &m->pool);
}
void tAllpass_setDelay(tAllpass* const ft, float delay)
@@ -112,7 +112,7 @@
void tOnePole_initToPool (tOnePole* const ft, float freq, tMempool* const mp)
{
_tMempool* m = *mp;
- _tOnePole* f = *ft = (_tOnePole*) mpool_alloc(sizeof(_tOnePole), m->pool);
+ _tOnePole* f = *ft = (_tOnePole*) mpool_alloc(sizeof(_tOnePole), &m->pool);
f->gain = 1.0f;
f->a0 = 1.0;
@@ -128,7 +128,7 @@
_tMempool* m = *mp;
_tOnePole* f = *ft;
- mpool_free(f, m->pool);
+ mpool_free(f, &m->pool);
}
void tOnePole_setB0(tOnePole* const ft, float b0)
@@ -215,7 +215,7 @@
void tTwoPole_initToPool (tTwoPole* const ft, tMempool* const mp)
{
_tMempool* m = *mp;
- _tTwoPole* f = *ft = (_tTwoPole*) mpool_alloc(sizeof(_tTwoPole), m->pool);
+ _tTwoPole* f = *ft = (_tTwoPole*) mpool_alloc(sizeof(_tTwoPole), &m->pool);
f->gain = 1.0f;
f->a0 = 1.0;
@@ -230,7 +230,7 @@
_tMempool* m = *mp;
_tTwoPole* f = *ft;
- mpool_free(f, m->pool);
+ mpool_free(f, &m->pool);
}
float tTwoPole_tick(tTwoPole* const ft, float input)
@@ -341,7 +341,7 @@
void tOneZero_initToPool (tOneZero* const ft, float theZero, tMempool* const mp)
{
_tMempool* m = *mp;
- _tOneZero* f = *ft = (_tOneZero*) mpool_alloc(sizeof(_tOneZero), m->pool);
+ _tOneZero* f = *ft = (_tOneZero*) mpool_alloc(sizeof(_tOneZero), &m->pool);
f->gain = 1.0f;
f->lastIn = 0.0f;
@@ -354,7 +354,7 @@
_tMempool* m = *mp;
_tOneZero* f = *ft;
- mpool_free(f, m->pool);
+ mpool_free(f, &m->pool);
}
float tOneZero_tick(tOneZero* const ft, float input)
@@ -456,7 +456,7 @@
void tTwoZero_initToPool (tTwoZero* const ft, tMempool* const mp)
{
_tMempool* m = *mp;
- _tTwoZero* f = *ft = (_tTwoZero*) mpool_alloc(sizeof(_tTwoZero), m->pool);
+ _tTwoZero* f = *ft = (_tTwoZero*) mpool_alloc(sizeof(_tTwoZero), &m->pool);
f->gain = 1.0f;
f->lastIn[0] = 0.0f;
@@ -468,7 +468,7 @@
_tMempool* m = *mp;
_tTwoZero* f = *ft;
- mpool_free(f, m->pool);
+ mpool_free(f, &m->pool);
}
float tTwoZero_tick(tTwoZero* const ft, float input)
@@ -564,7 +564,7 @@
void tPoleZero_initToPool (tPoleZero* const pzf, tMempool* const mp)
{
_tMempool* m = *mp;
- _tPoleZero* f = *pzf = (_tPoleZero*) mpool_alloc(sizeof(_tPoleZero), m->pool);
+ _tPoleZero* f = *pzf = (_tPoleZero*) mpool_alloc(sizeof(_tPoleZero), &m->pool);
f->gain = 1.0f;
f->b0 = 1.0;
@@ -579,7 +579,7 @@
_tMempool* m = *mp;
_tPoleZero* f = *pzf;
- mpool_free(f, m->pool);
+ mpool_free(f, &m->pool);
}
void tPoleZero_setB0(tPoleZero* const pzf, float b0)
@@ -695,7 +695,7 @@
void tBiQuad_initToPool (tBiQuad* const ft, tMempool* const mp)
{
_tMempool* m = *mp;
- _tBiQuad* f = *ft = (_tBiQuad*) mpool_alloc(sizeof(_tBiQuad), m->pool);
+ _tBiQuad* f = *ft = (_tBiQuad*) mpool_alloc(sizeof(_tBiQuad), &m->pool);
f->gain = 1.0f;
@@ -713,7 +713,7 @@
_tMempool* m = *mp;
_tBiQuad* f = *ft;
- mpool_free(f, m->pool);
+ mpool_free(f, &m->pool);
}
float tBiQuad_tick(tBiQuad* const ft, float input)
@@ -867,7 +867,7 @@
void tSVF_initToPool (tSVF* const svff, SVFType type, float freq, float Q, tMempool* const mp)
{
_tMempool* m = *mp;
- _tSVF* svf = *svff = (_tSVF*) mpool_alloc(sizeof(_tSVF), m->pool);
+ _tSVF* svf = *svff = (_tSVF*) mpool_alloc(sizeof(_tSVF), &m->pool);
svf->type = type;
@@ -886,7 +886,7 @@
_tMempool* m = *mp;
_tSVF* svf = *svff;
- mpool_free(svf, m->pool);
+ mpool_free(svf, &m->pool);
}
float tSVF_tick(tSVF* const svff, float v0)
@@ -956,7 +956,7 @@
void tEfficientSVF_initToPool (tEfficientSVF* const svff, SVFType type, uint16_t input, float Q, tMempool* const mp)
{
_tMempool* m = *mp;
- _tEfficientSVF* svf = *svff = (_tEfficientSVF*) mpool_alloc(sizeof(_tEfficientSVF), m->pool);
+ _tEfficientSVF* svf = *svff = (_tEfficientSVF*) mpool_alloc(sizeof(_tEfficientSVF), &m->pool);
svf->type = type;
@@ -975,7 +975,7 @@
_tMempool* m = *mp;
_tEfficientSVF* svf = *svff;
- mpool_free(svf, m->pool);
+ mpool_free(svf, &m->pool);
}
float tEfficientSVF_tick(tEfficientSVF* const svff, float v0)
@@ -1040,7 +1040,7 @@
void tHighpass_initToPool (tHighpass* const ft, float freq, tMempool* const mp)
{
_tMempool* m = *mp;
- _tHighpass* f = *ft = (_tHighpass*) mpool_alloc(sizeof(_tHighpass), m->pool);
+ _tHighpass* f = *ft = (_tHighpass*) mpool_alloc(sizeof(_tHighpass), &m->pool);
f->R = (1.0f - (freq * leaf.twoPiTimesInvSampleRate));
f->ys = 0.0f;
@@ -1054,7 +1054,7 @@
_tMempool* m = *mp;
_tHighpass* f = *ft;
- mpool_free(f, m->pool);
+ mpool_free(f, &m->pool);
}
void tHighpass_setFreq(tHighpass* const ft, float freq)
@@ -1121,7 +1121,7 @@
void tButterworth_initToPool (tButterworth* const ft, int N, float f1, float f2, tMempool* const mp)
{
_tMempool* m = *mp;
- _tButterworth* f = *ft = (_tButterworth*) mpool_alloc(sizeof(_tButterworth), m->pool);
+ _tButterworth* f = *ft = (_tButterworth*) mpool_alloc(sizeof(_tButterworth), &m->pool);
f->f1 = f1;
f->f2 = f2;
@@ -1149,7 +1149,7 @@
tSVF_freeFromPool(&f->high[i], mp);
}
- mpool_free(f, m->pool);
+ mpool_free(f, &m->pool);
}
float tButterworth_tick(tButterworth* const ft, float samp)
@@ -1214,11 +1214,11 @@
void tFIR_initToPool (tFIR* const firf, float* coeffs, int numTaps, tMempool* const mp)
{
_tMempool* m = *mp;
- _tFIR* fir = *firf = (_tFIR*) mpool_alloc(sizeof(_tFIR), m->pool);
+ _tFIR* fir = *firf = (_tFIR*) mpool_alloc(sizeof(_tFIR), &m->pool);
fir->numTaps = numTaps;
fir->coeff = coeffs;
- fir->past = (float*) mpool_alloc(sizeof(float) * fir->numTaps, m->pool);
+ fir->past = (float*) mpool_alloc(sizeof(float) * fir->numTaps, &m->pool);
for (int i = 0; i < fir->numTaps; ++i) fir->past[i] = 0.0f;
}
@@ -1227,8 +1227,8 @@
_tMempool* m = *mp;
_tFIR* fir = *firf;
- mpool_free(fir->past, m->pool);
- mpool_free(fir, m->pool);
+ mpool_free(fir->past, &m->pool);
+ mpool_free(fir, &m->pool);
}
float tFIR_tick(tFIR* const firf, float input)
--- a/LEAF/Src/leaf-instruments.c
+++ b/LEAF/Src/leaf-instruments.c
@@ -66,7 +66,7 @@
void t808Cowbell_initToPool (t808Cowbell* const cowbellInst, int useStick, tMempool* const mp)
{
_tMempool* m = *mp;
- _t808Cowbell* cowbell = *cowbellInst = (_t808Cowbell*) mpool_alloc(sizeof(_t808Cowbell), m->pool);
+ _t808Cowbell* cowbell = *cowbellInst = (_t808Cowbell*) mpool_alloc(sizeof(_t808Cowbell), &m->pool);
tSquare_initToPool(&cowbell->p[0], mp);
tSquare_setFreq(&cowbell->p[0], 540.0f);
@@ -107,7 +107,7 @@
tHighpass_freeFromPool(&cowbell->highpass, mp);
tNoise_freeFromPool(&cowbell->stick, mp);
tEnvelope_freeFromPool(&cowbell->envStick, mp);
- mpool_free(cowbell, m->pool);
+ mpool_free(cowbell, &m->pool);
}
void t808Cowbell_on(t808Cowbell* const cowbellInst, float vel)
@@ -242,7 +242,7 @@
void t808Hihat_initToPool (t808Hihat* const hihatInst, tMempool* const mp)
{
_tMempool* m = *mp;
- _t808Hihat* hihat = *hihatInst = (_t808Hihat*) mpool_alloc(sizeof(_t808Hihat), m->pool);
+ _t808Hihat* hihat = *hihatInst = (_t808Hihat*) mpool_alloc(sizeof(_t808Hihat), &m->pool);
for (int i = 0; i < 6; i++)
{
@@ -294,7 +294,7 @@
tHighpass_freeFromPool(&hihat->highpass, mp);
- mpool_free(hihat, m->pool);
+ mpool_free(hihat, &m->pool);
}
void t808Hihat_on(t808Hihat* const hihatInst, float vel)
@@ -454,7 +454,7 @@
void t808Snare_initToPool (t808Snare* const snareInst, tMempool* const mp)
{
_tMempool* m = *mp;
- _t808Snare* snare = *snareInst = (_t808Snare*) mpool_alloc(sizeof(_t808Snare), m->pool);
+ _t808Snare* snare = *snareInst = (_t808Snare*) mpool_alloc(sizeof(_t808Snare), &m->pool);
float ratio[2] = {1.0, 1.5};
for (int i = 0; i < 2; i++)
@@ -499,7 +499,7 @@
tEnvelope_freeFromPool(&snare->noiseEnvGain, mp);
tEnvelope_freeFromPool(&snare->noiseEnvFilter, mp);
- mpool_free(snare, m->pool);
+ mpool_free(snare, &m->pool);
}
void t808Snare_on(t808Snare* const snareInst, float vel)
@@ -629,7 +629,7 @@
void t808Kick_initToPool (t808Kick* const kickInst, tMempool* const mp)
{
_tMempool* m = *mp;
- _t808Kick* kick = *kickInst = (_t808Kick*) mpool_alloc(sizeof(_t808Kick), m->pool);
+ _t808Kick* kick = *kickInst = (_t808Kick*) mpool_alloc(sizeof(_t808Kick), &m->pool);
tCycle_initToPool(&kick->tone, mp);
kick->toneInitialFreq = 40.0f;
@@ -658,7 +658,7 @@
tNoise_freeFromPool(&kick->noiseOsc, mp);
tEnvelope_freeFromPool(&kick->noiseEnvGain, mp);
- mpool_free(kick, m->pool);
+ mpool_free(kick, &m->pool);
}
float t808Kick_tick (t808Kick* const kickInst)
--- a/LEAF/Src/leaf-mempool.c
+++ b/LEAF/Src/leaf-mempool.c
@@ -364,7 +364,7 @@
{
_tMempool* m = *mp = (_tMempool*) leaf_alloc(sizeof(_tMempool));
- mpool_create (memory, size, m->pool);
+ mpool_create (memory, size, &m->pool);
}
void tMempool_free(tMempool* const mp)
@@ -377,9 +377,9 @@
void tMempool_initToPool (tMempool* const mp, char* memory, size_t size, tMempool* const mem)
{
_tMempool* mm = *mem;
- _tMempool* m = *mp = (_tMempool*) mpool_alloc(sizeof(_tMempool), mm->pool);
+ _tMempool* m = *mp = (_tMempool*) mpool_alloc(sizeof(_tMempool), &mm->pool);
- mpool_create (memory, size, m->pool);
+ mpool_create (memory, size, &m->pool);
}
void tMempool_freeFromPool (tMempool* const mp, tMempool* const mem)
@@ -387,5 +387,5 @@
_tMempool* mm = *mem;
_tMempool* m = *mp;
- mpool_free(m, mm->pool);
+ mpool_free(m, &mm->pool);
}
--- a/LEAF/Src/leaf-midi.c
+++ b/LEAF/Src/leaf-midi.c
@@ -42,7 +42,7 @@
void tStack_initToPool (tStack* const stack, tMempool* const mp)
{
_tMempool* m = *mp;
- _tStack* ns = *stack = (_tStack*) mpool_alloc(sizeof(_tStack), m->pool);
+ _tStack* ns = *stack = (_tStack*) mpool_alloc(sizeof(_tStack), &m->pool);
ns->ordered = OFALSE;
ns->size = 0;
@@ -57,7 +57,7 @@
_tMempool* m = *mp;
_tStack* ns = *stack;
- mpool_free(ns, m->pool);
+ mpool_free(ns, &m->pool);
}
// If stack contains note, returns index. Else returns -1;
@@ -339,7 +339,7 @@
void tPoly_initToPool (tPoly* const polyh, int maxNumVoices, tMempool* const mp)
{
_tMempool* m = *mp;
- _tPoly* poly = *polyh = (_tPoly*) mpool_alloc(sizeof(_tPoly), m->pool);
+ _tPoly* poly = *polyh = (_tPoly*) mpool_alloc(sizeof(_tPoly), &m->pool);
poly->numVoices = maxNumVoices;
poly->maxNumVoices = maxNumVoices;
@@ -359,14 +359,14 @@
poly->glideTime = 5.0f;
- poly->ramps = (tRamp*) mpool_alloc(sizeof(tRamp) * poly->maxNumVoices, m->pool);
- poly->rampVals = (float*) mpool_alloc(sizeof(float) * poly->maxNumVoices, m->pool);
- poly->firstReceived = (oBool*) mpool_alloc(sizeof(oBool) * poly->maxNumVoices, m->pool);
- poly->voices = (int**) mpool_alloc(sizeof(int*) * poly->maxNumVoices, m->pool);
+ poly->ramps = (tRamp*) mpool_alloc(sizeof(tRamp) * poly->maxNumVoices, &m->pool);
+ poly->rampVals = (float*) mpool_alloc(sizeof(float) * poly->maxNumVoices, &m->pool);
+ poly->firstReceived = (oBool*) mpool_alloc(sizeof(oBool) * poly->maxNumVoices, &m->pool);
+ poly->voices = (int**) mpool_alloc(sizeof(int*) * poly->maxNumVoices, &m->pool);
for (int i = 0; i < poly->maxNumVoices; ++i)
{
- poly->voices[i] = (int*) mpool_alloc(sizeof(int) * 2, m->pool);
+ poly->voices[i] = (int*) mpool_alloc(sizeof(int) * 2, &m->pool);
poly->voices[i][0] = -1;
poly->firstReceived[i] = OFALSE;
@@ -390,18 +390,18 @@
for (int i = 0; i < poly->maxNumVoices; i++)
{
tRamp_freeFromPool(&poly->ramps[i], mp);
- mpool_free(poly->voices[i], m->pool);
+ mpool_free(poly->voices[i], &m->pool);
}
tRamp_freeFromPool(&poly->pitchBendRamp, mp);
tStack_freeFromPool(&poly->stack, mp);
tStack_freeFromPool(&poly->orderStack, mp);
- mpool_free(poly->voices, m->pool);
- mpool_free(poly->ramps, m->pool);
- mpool_free(poly->rampVals, m->pool);
- mpool_free(poly->firstReceived, m->pool);
+ mpool_free(poly->voices, &m->pool);
+ mpool_free(poly->ramps, &m->pool);
+ mpool_free(poly->rampVals, &m->pool);
+ mpool_free(poly->firstReceived, &m->pool);
- mpool_free(poly, m->pool);
+ mpool_free(poly, &m->pool);
}
void tPoly_tickPitch(tPoly* polyh)
--- a/LEAF/Src/leaf-oscillators.c
+++ b/LEAF/Src/leaf-oscillators.c
@@ -37,7 +37,7 @@
void tCycle_initToPool (tCycle* const cy, tMempool* const mp)
{
_tMempool* m = *mp;
- _tCycle* c = *cy = (_tCycle*) mpool_alloc(sizeof(_tCycle), m->pool);
+ _tCycle* c = *cy = (_tCycle*) mpool_alloc(sizeof(_tCycle), &m->pool);
c->inc = 0.0f;
c->phase = 0.0f;
@@ -48,7 +48,7 @@
_tMempool* m = *mp;
_tCycle* c = *cy;
- mpool_free(c, m->pool);
+ mpool_free(c, &m->pool);
}
int tCycle_setFreq(tCycle* const cy, float freq)
@@ -108,7 +108,7 @@
void tTriangle_initToPool (tTriangle* const cy, tMempool* const mp)
{
_tMempool* m = *mp;
- _tTriangle* c = *cy = (_tTriangle*) mpool_alloc(sizeof(_tTriangle), m->pool);
+ _tTriangle* c = *cy = (_tTriangle*) mpool_alloc(sizeof(_tTriangle), &m->pool);
c->inc = 0.0f;
c->phase = 0.0f;
@@ -119,7 +119,7 @@
_tMempool* m = *mp;
_tTriangle* c = *cy;
- mpool_free(c, m->pool);
+ mpool_free(c, &m->pool);
}
int tTriangle_setFreq(tTriangle* const cy, float freq)
@@ -239,7 +239,7 @@
void tSquare_initToPool (tSquare* const cy, tMempool* const mp)
{
_tMempool* m = *mp;
- _tSquare* c = *cy = (_tSquare*) mpool_alloc(sizeof(_tSquare), m->pool);
+ _tSquare* c = *cy = (_tSquare*) mpool_alloc(sizeof(_tSquare), &m->pool);
c->inc = 0.0f;
c->phase = 0.0f;
@@ -250,7 +250,7 @@
_tMempool* m = *mp;
_tSquare* c = *cy;
- mpool_free(c, m->pool);
+ mpool_free(c, &m->pool);
}
int tSquare_setFreq(tSquare* const cy, float freq)
@@ -368,7 +368,7 @@
void tSawtooth_initToPool (tSawtooth* const cy, tMempool* const mp)
{
_tMempool* m = *mp;
- _tSawtooth* c = *cy = (_tSawtooth*) mpool_alloc(sizeof(_tSawtooth), m->pool);
+ _tSawtooth* c = *cy = (_tSawtooth*) mpool_alloc(sizeof(_tSawtooth), &m->pool);
c->inc = 0.0f;
c->phase = 0.0f;
@@ -379,7 +379,7 @@
_tMempool* m = *mp;
_tSawtooth* c = *cy;
- mpool_free(c, m->pool);
+ mpool_free(c, &m->pool);
}
int tSawtooth_setFreq(tSawtooth* const cy, float freq)
@@ -505,7 +505,7 @@
void tPhasor_initToPool (tPhasor* const ph, tMempool* const mp)
{
_tMempool* m = *mp;
- _tPhasor* p = *ph = (_tPhasor*) mpool_alloc(sizeof(_tPhasor), m->pool);
+ _tPhasor* p = *ph = (_tPhasor*) mpool_alloc(sizeof(_tPhasor), &m->pool);
p->phase = 0.0f;
p->inc = 0.0f;
@@ -516,7 +516,7 @@
_tMempool* m = *mp;
_tPhasor* p = *ph;
- mpool_free(p, m->pool);
+ mpool_free(p, &m->pool);
}
int tPhasor_setFreq(tPhasor* const ph, float freq)
@@ -561,7 +561,7 @@
void tNoise_initToPool (tNoise* const ns, NoiseType type, tMempool* const mp)
{
_tMempool* m = *mp;
- _tNoise* n = *ns = (_tNoise*) mpool_alloc(sizeof(_tNoise), m->pool);
+ _tNoise* n = *ns = (_tNoise*) mpool_alloc(sizeof(_tNoise), &m->pool);
n->type = type;
n->rand = leaf.random;
@@ -572,7 +572,7 @@
_tMempool* m = *mp;
_tNoise* n = *ns;
- mpool_free(n, m->pool);
+ mpool_free(n, &m->pool);
}
float tNoise_tick(tNoise* const ns)
@@ -646,7 +646,7 @@
void tNeuron_initToPool (tNeuron* const nr, tMempool* const mp)
{
_tMempool* m = *mp;
- _tNeuron* n = *nr = (_tNeuron*) mpool_alloc(sizeof(_tNeuron), m->pool);
+ _tNeuron* n = *nr = (_tNeuron*) mpool_alloc(sizeof(_tNeuron), &m->pool);
tPoleZero_initToPool(&n->f, mp);
@@ -681,7 +681,7 @@
_tNeuron* n = *nr;
tPoleZero_free(&n->f);
- mpool_free(n, m->pool);
+ mpool_free(n, &m->pool);
}
void tNeuron_reset(tNeuron* const nr)
--- a/LEAF/Src/leaf-physical.c
+++ b/LEAF/Src/leaf-physical.c
@@ -49,7 +49,7 @@
void tPluck_initToPool (tPluck* const pl, float lowestFrequency, tMempool* const mp)
{
_tMempool* m = *mp;
- _tPluck* p = *pl = (_tPluck*) mpool_alloc(sizeof(_tPluck), m->pool);
+ _tPluck* p = *pl = (_tPluck*) mpool_alloc(sizeof(_tPluck), &m->pool);
if ( lowestFrequency <= 0.0f ) lowestFrequency = 10.0f;
@@ -74,7 +74,7 @@
tOneZero_freeFromPool(&p->loopFilter, mp);
tAllpassDelay_freeFromPool(&p->delayLine, mp);
- mpool_free(p, m->pool);
+ mpool_free(p, &m->pool);
}
float tPluck_getLastOut (tPluck* const pl)
@@ -204,7 +204,7 @@
void tKarplusStrong_initToPool (tKarplusStrong* const pl, float lowestFrequency, tMempool* const mp)
{
_tMempool* m = *mp;
- _tKarplusStrong* p = *pl = (_tKarplusStrong*) mpool_alloc(sizeof(_tKarplusStrong), m->pool);
+ _tKarplusStrong* p = *pl = (_tKarplusStrong*) mpool_alloc(sizeof(_tKarplusStrong), &m->pool);
if ( lowestFrequency <= 0.0f ) lowestFrequency = 8.0f;
@@ -246,7 +246,7 @@
tBiQuad_freeFromPool(&p->biquad[i], mp);
}
- mpool_free(p, m->pool);
+ mpool_free(p, &m->pool);
}
float tKarplusStrong_getLastOut (tKarplusStrong* const pl)
@@ -441,7 +441,7 @@
float levStrength, int levMode, tMempool* const mp)
{
_tMempool* m = *mp;
- _tSimpleLivingString* p = *pl = (_tSimpleLivingString*) mpool_alloc(sizeof(_tSimpleLivingString), m->pool);
+ _tSimpleLivingString* p = *pl = (_tSimpleLivingString*) mpool_alloc(sizeof(_tSimpleLivingString), &m->pool);
p->curr=0.0f;
tExpSmooth_initToPool(&p->wlSmooth, leaf.sampleRate/freq, 0.01, mp); // smoother for string wavelength (not freq, to avoid expensive divisions)
@@ -465,7 +465,7 @@
tHighpass_freeFromPool(&p->DCblocker, mp);
tFeedbackLeveler_freeFromPool(&p->fbLev, mp);
- mpool_free(p, m->pool);
+ mpool_free(p, &m->pool);
}
void tSimpleLivingString_setFreq(tSimpleLivingString* const pl, float freq)
@@ -603,7 +603,7 @@
float levStrength, int levMode, tMempool* const mp)
{
_tMempool* m = *mp;
- _tLivingString* p = *pl = (_tLivingString*) mpool_alloc(sizeof(_tLivingString), m->pool);
+ _tLivingString* p = *pl = (_tLivingString*) mpool_alloc(sizeof(_tLivingString), &m->pool);
p->curr=0.0f;
tExpSmooth_initToPool(&p->wlSmooth, leaf.sampleRate/freq, 0.01, mp); // smoother for string wavelength (not freq, to avoid expensive divisions)
@@ -650,7 +650,7 @@
tFeedbackLeveler_freeFromPool(&p->fbLevU, mp);
tFeedbackLeveler_freeFromPool(&p->fbLevL, mp);
- mpool_free(p, m->pool);
+ mpool_free(p, &m->pool);
}
void tLivingString_setFreq(tLivingString* const pl, float freq)
@@ -795,7 +795,7 @@
void tReedTable_initToPool (tReedTable* const pm, float offset, float slope, tMempool* const mp)
{
_tMempool* m = *mp;
- _tReedTable* p = *pm = (_tReedTable*) mpool_alloc(sizeof(_tReedTable), m->pool);
+ _tReedTable* p = *pm = (_tReedTable*) mpool_alloc(sizeof(_tReedTable), &m->pool);
p->offset = offset;
p->slope = slope;
@@ -806,7 +806,7 @@
_tMempool* m = *mp;
_tReedTable* p = *pm;
- mpool_free(p, m->pool);
+ mpool_free(p, &m->pool);
}
float tReedTable_tick (tReedTable* const pm, float input)
--- a/LEAF/Src/leaf-reverb.c
+++ b/LEAF/Src/leaf-reverb.c
@@ -68,7 +68,7 @@
void tPRCReverb_initToPool (tPRCReverb* const rev, float t60, tMempool* const mp)
{
_tMempool* m = *mp;
- _tPRCReverb* r = *rev = (_tPRCReverb*) mpool_alloc(sizeof(_tPRCReverb), m->pool);
+ _tPRCReverb* r = *rev = (_tPRCReverb*) mpool_alloc(sizeof(_tPRCReverb), &m->pool);
if (t60 <= 0.0f) t60 = 0.001f;
@@ -110,7 +110,7 @@
tDelay_freeFromPool(&r->allpassDelays[0], mp);
tDelay_freeFromPool(&r->allpassDelays[1], mp);
tDelay_freeFromPool(&r->combDelay, mp);
- mpool_free(r, m->pool);
+ mpool_free(r, &m->pool);
}
void tPRCReverb_setT60(tPRCReverb* const rev, float t60)
@@ -234,7 +234,7 @@
void tNReverb_initToPool (tNReverb* const rev, float t60, tMempool* const mp)
{
_tMempool* m = *mp;
- _tNReverb* r = *rev = (_tNReverb*) mpool_alloc(sizeof(_tNReverb), m->pool);
+ _tNReverb* r = *rev = (_tNReverb*) mpool_alloc(sizeof(_tNReverb), &m->pool);
if (t60 <= 0.0f) t60 = 0.001f;
@@ -287,7 +287,7 @@
tLinearDelay_freeFromPool(&r->allpassDelays[i], mp);
}
- mpool_free(r, m->pool);
+ mpool_free(r, &m->pool);
}
void tNReverb_setT60(tNReverb* const rev, float t60)
@@ -537,7 +537,7 @@
void tDattorroReverb_initToPool (tDattorroReverb* const rev, tMempool* const mp)
{
_tMempool* m = *mp;
- _tDattorroReverb* r = *rev = (_tDattorroReverb*) mpool_alloc(sizeof(_tDattorroReverb), m->pool);
+ _tDattorroReverb* r = *rev = (_tDattorroReverb*) mpool_alloc(sizeof(_tDattorroReverb), &m->pool);
r->size_max = 2.0f;
r->size = 1.f;
@@ -636,7 +636,7 @@
tCycle_freeFromPool(&r->f2_lfo, mp);
- mpool_free(r, m->pool);
+ mpool_free(r, &m->pool);
}
float tDattorroReverb_tick (tDattorroReverb* const rev, float input)
--- a/LEAF/Src/leaf-sampling.c
+++ b/LEAF/Src/leaf-sampling.c
@@ -48,9 +48,9 @@
void tBuffer_initToPool (tBuffer* const sb, uint32_t length, tMempool* const mp)
{
_tMempool* m = *mp;
- _tBuffer* s = *sb = (_tBuffer*) mpool_alloc(sizeof(_tBuffer), m->pool);
+ _tBuffer* s = *sb = (_tBuffer*) mpool_alloc(sizeof(_tBuffer), &m->pool);
- s->buff = (float*) mpool_alloc( sizeof(float) * length, m->pool);
+ s->buff = (float*) mpool_alloc( sizeof(float) * length, &m->pool);
s->bufferLength = length;
s->recordedLength = 0;
@@ -63,8 +63,8 @@
_tMempool* m = *mp;
_tBuffer* s = *sb;
- mpool_free(s->buff, m->pool);
- mpool_free(s, m->pool);
+ mpool_free(s->buff, &m->pool);
+ mpool_free(s, &m->pool);
}
void tBuffer_tick (tBuffer* const sb, float sample)