ref: 5fecc41865392548c21ede07943560b33f42b3eb
parent: cea72f68780d2770d2407681ce1ee077ca31909e
author: Matthew Wang <mjw7@princeton.edu>
date: Fri Mar 6 12:12:15 EST 2020
move default mempool into leaf struct instead of being a global
--- a/LEAF/Inc/leaf-global.h
+++ b/LEAF/Inc/leaf-global.h
@@ -15,6 +15,8 @@
extern "C" {
#endif
+#include "leaf-mempool.h"
+
/*!
* @internal
* @defgroup LEAF LEAF
@@ -30,6 +32,9 @@
float twoPiTimesInvSampleRate; //!< Two-pi times the inverse of the current sample rate.
float (*random)(void); //!< A pointer to a random() function provided on initialization.
int clearOnAllocation; //!< A flag that determines whether memory allocated from the LEAF memory pool will be cleared.
+ tMempool mempool;
+ _tMempool _mempool;
+ size_t header_size;
///@}
} LEAF;
--- a/LEAF/Inc/leaf-mempool.h
+++ b/LEAF/Inc/leaf-mempool.h
@@ -54,6 +54,12 @@
//#define size_t unsigned long
+ /**
+ * @defgroup TMEMPOOL tMempool
+ * An object that can contain an additional mempool for the allocation of LEAF objects.
+ * @{
+ */
+
// node of free list
typedef struct mpool_node_t {
void *pool; // memory pool field
@@ -62,49 +68,12 @@
size_t size;
} mpool_node_t;
- typedef struct mpool_t {
+ typedef struct _tMempool
+ {
void* mpool; // start of the mpool
size_t usize; // used size of the pool
size_t msize; // max size of the pool
mpool_node_t* head; // first node of memory pool free list
- } mpool_t;
-
- void mpool_create (char* memory, size_t size, mpool_t* pool);
-
- void* mpool_alloc(size_t size, mpool_t* pool);
- void* mpool_calloc(size_t asize, mpool_t* pool);
-
- void mpool_free(void* ptr, mpool_t* pool);
-
- size_t mpool_get_size(mpool_t* pool);
- size_t mpool_get_used(mpool_t* pool);
-
- void leaf_pool_init(char* memory, size_t size);
-
- void* leaf_alloc(size_t size);
- void* leaf_calloc(size_t size);
-
- void leaf_free(void* ptr);
-
- size_t leaf_pool_get_size(void);
- size_t leaf_pool_get_used(void);
-
- void* leaf_pool_get_pool(void);
-
- void leaf_mempool_overrun(void);
-
-
-
-
- /**
- * @defgroup TMEMPOOL tMempool
- * An object that can contain an additional mempool for the allocation of LEAF objects.
- * @{
- */
-
- typedef struct _tMempool
- {
- mpool_t pool;
} _tMempool;
typedef _tMempool* tMempool;
@@ -145,8 +114,37 @@
/*! @} */
//==============================================================================
+
+ // typedef struct mpool_t {
+ // void* mpool; // start of the mpool
+ // size_t usize; // used size of the pool
+ // size_t msize; // max size of the pool
+ // mpool_node_t* head; // first node of memory pool free list
+ // } mpool_t;
- extern tMempool leaf_mempool;
+ void mpool_create (char* memory, size_t size, _tMempool* pool);
+
+ void* mpool_alloc(size_t size, _tMempool* pool);
+ void* mpool_calloc(size_t asize, _tMempool* pool);
+
+ void mpool_free(void* ptr, _tMempool* pool);
+
+ size_t mpool_get_size(_tMempool* pool);
+ size_t mpool_get_used(_tMempool* pool);
+
+ void leaf_pool_init(char* memory, size_t size);
+
+ void* leaf_alloc(size_t size);
+ void* leaf_calloc(size_t size);
+
+ void leaf_free(void* ptr);
+
+ size_t leaf_pool_get_size(void);
+ size_t leaf_pool_get_used(void);
+
+ void* leaf_pool_get_pool(void);
+
+ void leaf_mempool_overrun(void);
#ifdef __cplusplus
}
--- 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);
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);
}
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);
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);
}
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_calloc(sizeof(_tEnvPD), &m->pool);
+ _tEnvPD* x = *xpd = (_tEnvPD*) mpool_calloc(sizeof(_tEnvPD), m);
int period = hs, npoints = ws;
@@ -251,7 +251,7 @@
_tMempool* m = *mp;
_tEnvPD* x = *xpd;
- mpool_free(x, &m->pool);
+ mpool_free(x, m);
}
float tEnvPD_tick (tEnvPD* const xpd)
@@ -323,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);
atkdtk_init(ad, blocksize, atk, rel);
}
@@ -333,7 +333,7 @@
_tMempool* m = *mp;
_tAttackDetection* a = *ad;
- mpool_free(a, &m->pool);
+ mpool_free(a, m);
}
/*******Public Functions***********/
@@ -495,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);
s->biasfactor = DEFBIAS;
s->timeindex = 0;
@@ -505,10 +505,10 @@
s->minrms = DEFMINRMS;
s->framesize = SNAC_FRAME_SIZE;
- s->inputbuf = (float*) mpool_calloc(sizeof(float) * SNAC_FRAME_SIZE, &m->pool);
- s->processbuf = (float*) mpool_calloc(sizeof(float) * (SNAC_FRAME_SIZE * 2), &m->pool);
- s->spectrumbuf = (float*) mpool_calloc(sizeof(float) * (SNAC_FRAME_SIZE / 2), &m->pool);
- s->biasbuf = (float*) mpool_calloc(sizeof(float) * SNAC_FRAME_SIZE, &m->pool);
+ s->inputbuf = (float*) mpool_calloc(sizeof(float) * SNAC_FRAME_SIZE, m);
+ s->processbuf = (float*) mpool_calloc(sizeof(float) * (SNAC_FRAME_SIZE * 2), m);
+ s->spectrumbuf = (float*) mpool_calloc(sizeof(float) * (SNAC_FRAME_SIZE / 2), m);
+ s->biasbuf = (float*) mpool_calloc(sizeof(float) * SNAC_FRAME_SIZE, m);
snac_biasbuf(snac);
tSNAC_setOverlap(snac, overlaparg);
@@ -519,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);
+ mpool_free(s->processbuf, m);
+ mpool_free(s->spectrumbuf, m);
+ mpool_free(s->biasbuf, m);
+ mpool_free(s, m);
}
/******************************************************************************/
@@ -840,18 +840,18 @@
//===========================================================================
void tPeriodDetection_init (tPeriodDetection* const pd, float* in, float* out, int bufSize, int frameSize)
{
- tPeriodDetection_initToPool(pd, in, out, bufSize, frameSize, &leaf_mempool);
+ tPeriodDetection_initToPool(pd, in, out, bufSize, frameSize, &leaf.mempool);
}
void tPeriodDetection_free (tPeriodDetection* const pd)
{
- tPeriodDetection_freeFromPool(pd, &leaf_mempool);
+ tPeriodDetection_freeFromPool(pd, &leaf.mempool);
}
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_calloc(sizeof(_tPeriodDetection), &m->pool);
+ _tPeriodDetection* p = *pd = (_tPeriodDetection*) mpool_calloc(sizeof(_tPeriodDetection), m);
p->inBuffer = in;
p->outBuffer = out;
@@ -882,7 +882,7 @@
tEnvPD_freeFromPool(&p->env, mp);
tSNAC_freeFromPool(&p->snac, mp);
- mpool_free(p, &m->pool);
+ mpool_free(p, m);
}
float tPeriodDetection_tick (tPeriodDetection* pd, float sample)
--- a/LEAF/Src/leaf-delay.c
+++ b/LEAF/Src/leaf-delay.c
@@ -21,24 +21,24 @@
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Delay ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
void tDelay_init (tDelay* const dl, uint32_t delay, uint32_t maxDelay)
{
- tDelay_initToPool(dl, delay, maxDelay, &leaf_mempool);
+ tDelay_initToPool(dl, delay, maxDelay, &leaf.mempool);
}
void tDelay_free(tDelay* const dl)
{
- tDelay_freeFromPool(dl, &leaf_mempool);
+ tDelay_freeFromPool(dl, &leaf.mempool);
}
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);
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);
d->inPoint = 0;
d->outPoint = 0;
@@ -56,8 +56,8 @@
_tMempool* m = *mp;
_tDelay* d = *dl;
- mpool_free(d->buff, &m->pool);
- mpool_free(d, &m->pool);
+ mpool_free(d->buff, m);
+ mpool_free(d, m);
}
void tDelay_clear(tDelay* const dl)
@@ -169,18 +169,18 @@
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ LinearDelay ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
void tLinearDelay_init (tLinearDelay* const dl, float delay, uint32_t maxDelay)
{
- tLinearDelay_initToPool(dl, delay, maxDelay, &leaf_mempool);
+ tLinearDelay_initToPool(dl, delay, maxDelay, &leaf.mempool);
}
void tLinearDelay_free(tLinearDelay* const dl)
{
- tLinearDelay_freeFromPool(dl, &leaf_mempool);
+ tLinearDelay_freeFromPool(dl, &leaf.mempool);
}
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);
d->maxDelay = maxDelay;
@@ -188,7 +188,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);
d->gain = 1.0f;
@@ -206,8 +206,8 @@
_tMempool* m = *mp;
_tLinearDelay* d = *dl;
- mpool_free(d->buff, &m->pool);
- mpool_free(d, &m->pool);
+ mpool_free(d->buff, m);
+ mpool_free(d, m);
}
void tLinearDelay_clear(tLinearDelay* const dl)
@@ -367,18 +367,18 @@
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ LinearDelay ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
void tHermiteDelay_init (tHermiteDelay* const dl, float delay, uint32_t maxDelay)
{
- tHermiteDelay_initToPool(dl, delay, maxDelay, &leaf_mempool);
+ tHermiteDelay_initToPool(dl, delay, maxDelay, &leaf.mempool);
}
void tHermiteDelay_free(tHermiteDelay* const dl)
{
- tHermiteDelay_freeFromPool(dl, &leaf_mempool);
+ tHermiteDelay_freeFromPool(dl, &leaf.mempool);
}
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);
d->maxDelay = maxDelay;
@@ -386,7 +386,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);
d->gain = 1.0f;
@@ -404,8 +404,8 @@
_tMempool* m = *mp;
_tHermiteDelay* d = *dl;
- mpool_free(d->buff, &m->pool);
- mpool_free(d, &m->pool);
+ mpool_free(d->buff, m);
+ mpool_free(d, m);
}
@@ -567,18 +567,18 @@
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ AllpassDelay ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
void tAllpassDelay_init (tAllpassDelay* const dl, float delay, uint32_t maxDelay)
{
- tAllpassDelay_initToPool(dl, delay, maxDelay, &leaf_mempool);
+ tAllpassDelay_initToPool(dl, delay, maxDelay, &leaf.mempool);
}
void tAllpassDelay_free(tAllpassDelay* const dl)
{
- tAllpassDelay_freeFromPool(dl, &leaf_mempool);
+ tAllpassDelay_freeFromPool(dl, &leaf.mempool);
}
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);
d->maxDelay = maxDelay;
@@ -586,7 +586,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);
d->gain = 1.0f;
@@ -606,8 +606,8 @@
_tMempool* m = *mp;
_tAllpassDelay* d = *dl;
- mpool_free(d->buff, &m->pool);
- mpool_free(d, &m->pool);
+ mpool_free(d->buff, m);
+ mpool_free(d, m);
}
void tAllpassDelay_clear(tAllpassDelay* const dl)
@@ -747,22 +747,22 @@
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ TapeDelay ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //
void tTapeDelay_init (tTapeDelay* const dl, float delay, uint32_t maxDelay)
{
- tTapeDelay_initToPool(dl, delay, maxDelay, &leaf_mempool);
+ tTapeDelay_initToPool(dl, delay, maxDelay, &leaf.mempool);
}
void tTapeDelay_free(tTapeDelay* const dl)
{
- tTapeDelay_freeFromPool(dl, &leaf_mempool);
+ tTapeDelay_freeFromPool(dl, &leaf.mempool);
}
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);
d->maxDelay = maxDelay;
- d->buff = (float*) mpool_alloc(sizeof(float) * maxDelay, &m->pool);
+ d->buff = (float*) mpool_alloc(sizeof(float) * maxDelay, m);
d->gain = 1.0f;
@@ -781,8 +781,8 @@
_tMempool* m = *mp;
_tTapeDelay* d = *dl;
- mpool_free(d->buff, &m->pool);
- mpool_free(d, &m->pool);
+ mpool_free(d->buff, m);
+ mpool_free(d, m);
}
void tTapeDelay_clear(tTapeDelay* const dl)
--- 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);
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);
}
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);
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);
+ os->downState = mpool_alloc(sizeof(float) * os->numTaps * 2, m);
}
}
@@ -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);
+ mpool_free(os->downState, m);
+ mpool_free(os, m);
}
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);
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);
}
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);
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);
}
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);
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);
}
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);
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);
}
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);
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);
+ v->car1 = (float*) mpool_alloc(sizeof(float) * v->bufsize, m);
+ v->window = (float*) mpool_alloc(sizeof(float) * v->bufsize, m);
+ v->buf0 = (float*) mpool_alloc(sizeof(float) * v->bufsize, m);
+ v->buf1 = (float*) mpool_alloc(sizeof(float) * v->bufsize, m);
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);
+ mpool_free(v->buf0, m);
+ mpool_free(v->window, m);
+ mpool_free(v->car1, m);
+ mpool_free(v->car0, m);
- mpool_free(v, &m->pool);
+ mpool_free(v, m);
}
void tTalkbox_update(tTalkbox* const voc) ///update internal parameters...
@@ -297,7 +297,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);
v->param[0] = 0.33f; //input select
v->param[1] = 0.50f; //output dB
@@ -316,7 +316,7 @@
_tMempool* m = *mp;
_tVocoder* v = *voc;
- mpool_free(v, &m->pool);
+ mpool_free(v, m);
}
void tVocoder_update (tVocoder* const voc)
@@ -518,10 +518,10 @@
{
_tMempool* m = *mp;
- _tSOLAD* w = *wp = (_tSOLAD*) mpool_calloc(sizeof(_tSOLAD), &m->pool);
+ _tSOLAD* w = *wp = (_tSOLAD*) mpool_calloc(sizeof(_tSOLAD), m);
w->pitchfactor = 1.;
- w->delaybuf = (float*) mpool_calloc(sizeof(float) * (LOOPSIZE+16), &m->pool);
+ w->delaybuf = (float*) mpool_calloc(sizeof(float) * (LOOPSIZE+16), m);
solad_init(w);
}
@@ -531,8 +531,8 @@
_tMempool* m = *mp;
_tSOLAD* w = *wp;
- mpool_free(w->delaybuf, &m->pool);
- mpool_free(w, &m->pool);
+ mpool_free(w->delaybuf, m);
+ mpool_free(w, m);
}
// send one block of input samples, receive one block of output samples
@@ -901,7 +901,7 @@
{
_tMempool* m = *mp;
- _tPitchShift* ps = *psr = (_tPitchShift*) mpool_calloc(sizeof(_tPitchShift), &m->pool);
+ _tPitchShift* ps = *psr = (_tPitchShift*) mpool_calloc(sizeof(_tPitchShift), m);
_tPeriodDetection* p = *pd;
@@ -930,7 +930,7 @@
tSOLAD_freeFromPool(&ps->sola, mp);
tHighpass_freeFromPool(&ps->hp, mp);
- mpool_free(ps, &m->pool);
+ mpool_free(ps, m);
}
void tPitchShift_setPitchFactor(tPitchShift* psr, float pf)
@@ -1052,25 +1052,25 @@
void tRetune_init(tRetune* const rt, int numVoices, int bufSize, int frameSize)
{
- tRetune_initToPool(rt, numVoices, bufSize, frameSize, &leaf_mempool);
+ tRetune_initToPool(rt, numVoices, bufSize, frameSize, &leaf.mempool);
}
void tRetune_free(tRetune* const rt)
{
- tRetune_freeFromPool(rt, &leaf_mempool);
+ tRetune_freeFromPool(rt, &leaf.mempool);
}
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);
r->bufSize = bufSize;
r->frameSize = frameSize;
r->numVoices = numVoices;
- r->inBuffer = (float*) mpool_calloc(sizeof(float) * r->bufSize, &m->pool);
- r->outBuffers = (float**) mpool_calloc(sizeof(float*) * r->numVoices, &m->pool);
+ r->inBuffer = (float*) mpool_calloc(sizeof(float) * r->bufSize, m);
+ r->outBuffers = (float**) mpool_calloc(sizeof(float*) * r->numVoices, m);
r->hopSize = DEFHOPSIZE;
r->windowSize = DEFWINDOWSIZE;
@@ -1079,12 +1079,12 @@
r->inputPeriod = 0.0f;
- r->ps = (tPitchShift*) mpool_calloc(sizeof(tPitchShift) * r->numVoices, &m->pool);
- r->pitchFactor = (float*) mpool_calloc(sizeof(float) * r->numVoices, &m->pool);
- r->tickOutput = (float*) mpool_calloc(sizeof(float) * r->numVoices, &m->pool);
+ r->ps = (tPitchShift*) mpool_calloc(sizeof(tPitchShift) * r->numVoices, m);
+ r->pitchFactor = (float*) mpool_calloc(sizeof(float) * r->numVoices, m);
+ r->tickOutput = (float*) mpool_calloc(sizeof(float) * r->numVoices, m);
for (int i = 0; i < r->numVoices; ++i)
{
- r->outBuffers[i] = (float*) mpool_calloc(sizeof(float) * r->bufSize, &m->pool);
+ r->outBuffers[i] = (float*) mpool_calloc(sizeof(float) * r->bufSize, m);
}
tPeriodDetection_initToPool(&r->pd, r->inBuffer, r->outBuffers[0], r->bufSize, r->frameSize, mp);
@@ -1104,14 +1104,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);
}
- 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);
+ mpool_free(r->pitchFactor, m);
+ mpool_free(r->ps, m);
+ mpool_free(r->inBuffer, m);
+ mpool_free(r->outBuffers, m);
+ mpool_free(r, m);
}
float* tRetune_tick(tRetune* const rt, float sample)
@@ -1225,25 +1225,25 @@
void tAutotune_init(tAutotune* const rt, int numVoices, int bufSize, int frameSize)
{
- tAutotune_initToPool(rt, numVoices, bufSize, frameSize, &leaf_mempool);
+ tAutotune_initToPool(rt, numVoices, bufSize, frameSize, &leaf.mempool);
}
void tAutotune_free(tAutotune* const rt)
{
- tAutotune_freeFromPool(rt, &leaf_mempool);
+ tAutotune_freeFromPool(rt, &leaf.mempool);
}
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);
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);
+ r->outBuffers = (float**) mpool_alloc(sizeof(float*) * r->numVoices, m);
r->hopSize = DEFHOPSIZE;
r->windowSize = DEFWINDOWSIZE;
@@ -1250,12 +1250,12 @@
r->fba = FBA;
tAutotune_setTimeConstant(rt, DEFTIMECONSTANT);
- 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);
+ r->freq = (float*) mpool_alloc(sizeof(float) * r->numVoices, m);
+ r->tickOutput = (float*) mpool_alloc(sizeof(float) * r->numVoices, m);
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);
}
tPeriodDetection_initToPool(&r->pd, r->inBuffer, r->outBuffers[0], r->bufSize, r->frameSize, mp);
@@ -1277,14 +1277,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);
}
- 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);
+ mpool_free(r->freq, m);
+ mpool_free(r->ps, m);
+ mpool_free(r->inBuffer, m);
+ mpool_free(r->outBuffers, m);
+ mpool_free(r, m);
}
float* tAutotune_tick(tAutotune* const rt, float sample)
@@ -1453,19 +1453,19 @@
void tFormantShifter_initToPool (tFormantShifter* const fsr, 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);
fs->ford = order;
- fs->fk = (float*) mpool_calloc(sizeof(float) * fs->ford, &m->pool);
- fs->fb = (float*) mpool_calloc(sizeof(float) * fs->ford, &m->pool);
- fs->fc = (float*) mpool_calloc(sizeof(float) * fs->ford, &m->pool);
- fs->frb = (float*) mpool_calloc(sizeof(float) * fs->ford, &m->pool);
- fs->frc = (float*) mpool_calloc(sizeof(float) * fs->ford, &m->pool);
- fs->fsig = (float*) mpool_calloc(sizeof(float) * fs->ford, &m->pool);
- fs->fsmooth = (float*) mpool_calloc(sizeof(float) * fs->ford, &m->pool);
- fs->ftvec = (float*) mpool_calloc(sizeof(float) * fs->ford, &m->pool);
+ fs->fk = (float*) mpool_calloc(sizeof(float) * fs->ford, m);
+ fs->fb = (float*) mpool_calloc(sizeof(float) * fs->ford, m);
+ fs->fc = (float*) mpool_calloc(sizeof(float) * fs->ford, m);
+ fs->frb = (float*) mpool_calloc(sizeof(float) * fs->ford, m);
+ fs->frc = (float*) mpool_calloc(sizeof(float) * fs->ford, m);
+ fs->fsig = (float*) mpool_calloc(sizeof(float) * fs->ford, m);
+ fs->fsmooth = (float*) mpool_calloc(sizeof(float) * fs->ford, m);
+ fs->ftvec = (float*) mpool_calloc(sizeof(float) * fs->ford, m);
- fs->fbuff = (float*) mpool_calloc(sizeof(float*) * fs->ford, &m->pool);
+ fs->fbuff = (float*) mpool_calloc(sizeof(float*) * fs->ford, m);
fs->falph = powf(0.001f, 10.0f * leaf.invSampleRate);
@@ -1489,20 +1489,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);
- mpool_free(fs->fbuff, &m->pool);
+ mpool_free(fs->fk, m);
+ mpool_free(fs->fb, m);
+ mpool_free(fs->fc, m);
+ mpool_free(fs->frb, m);
+ mpool_free(fs->frc, m);
+ mpool_free(fs->fsig, m);
+ mpool_free(fs->fsmooth, m);
+ mpool_free(fs->ftvec, m);
+ mpool_free(fs->fbuff, m);
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);
}
float tFormantShifter_tick(tFormantShifter* const fsr, float in)
--- 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);
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);
}
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);
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);
}
void tEnvelope_setAttack(tEnvelope* const envlp, float attack)
@@ -323,7 +323,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);
adsr->exp_buff = exp_decay;
adsr->inc_buff = attack_decay_inc;
@@ -383,7 +383,7 @@
{
_tMempool* m = *mp;
_tADSR* adsr = *adsrenv;
- mpool_free(adsr, &m->pool);
+ mpool_free(adsr, m);
}
void tADSR_setAttack(tADSR* const adsrenv, float attack)
@@ -614,7 +614,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);
ramp->inv_sr_ms = 1.0f/(leaf.sampleRate*0.001f);
ramp->minimum_time = ramp->inv_sr_ms * samples_per_tick;
@@ -639,7 +639,7 @@
_tMempool* m = *mp;
_tRamp* ramp = *r;
- mpool_free(ramp, &m->pool);
+ mpool_free(ramp, m);
}
void tRamp_setTime(tRamp* const ramp, float time)
@@ -723,7 +723,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);
smooth->curr=val;
smooth->dest=val;
@@ -738,7 +738,7 @@
_tMempool* m = *mp;
_tExpSmooth* smooth = *expsmooth;
- mpool_free(smooth, &m->pool);
+ mpool_free(smooth, m);
}
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);
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);
}
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);
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);
}
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);
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);
}
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);
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);
}
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);
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);
}
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);
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);
}
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);
f->gain = 1.0f;
@@ -713,7 +713,7 @@
_tMempool* m = *mp;
_tBiQuad* f = *ft;
- mpool_free(f, &m->pool);
+ mpool_free(f, m);
}
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);
svf->type = type;
@@ -886,7 +886,7 @@
_tMempool* m = *mp;
_tSVF* svf = *svff;
- mpool_free(svf, &m->pool);
+ mpool_free(svf, m);
}
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);
svf->type = type;
@@ -975,7 +975,7 @@
_tMempool* m = *mp;
_tEfficientSVF* svf = *svff;
- mpool_free(svf, &m->pool);
+ mpool_free(svf, m);
}
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_calloc(sizeof(_tHighpass), &m->pool);
+ _tHighpass* f = *ft = (_tHighpass*) mpool_calloc(sizeof(_tHighpass), m);
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);
}
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);
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);
}
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);
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);
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);
+ mpool_free(fir, m);
}
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);
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);
}
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);
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);
}
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);
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);
}
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);
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);
}
float t808Kick_tick (t808Kick* const kickInst)
--- a/LEAF/Src/leaf-mempool.c
+++ b/LEAF/Src/leaf-mempool.c
@@ -48,11 +48,6 @@
#endif
-_tMempool leaf_pool;
-tMempool leaf_mempool;
-size_t header_size;
-
-
/**
* private function
*/
@@ -63,33 +58,33 @@
/**
* create memory pool
*/
-void mpool_create (char* memory, size_t size, mpool_t* pool)
+void mpool_create (char* memory, size_t size, _tMempool* pool)
{
- header_size = mpool_align(sizeof(mpool_node_t));
+ leaf.header_size = mpool_align(sizeof(mpool_node_t));
pool->mpool = (void*)memory;
pool->usize = 0;
pool->msize = size;
- pool->head = create_node(pool->mpool, NULL, NULL, pool->msize-header_size);
+ pool->head = create_node(pool->mpool, NULL, NULL, pool->msize-leaf.header_size);
for (int i = 0; i < pool->head->size; i++)
{
- memory[i+header_size]=0;
+ memory[i+leaf.header_size]=0;
}
}
void leaf_pool_init(char* memory, size_t size)
{
- mpool_create(memory, size, &leaf_pool.pool);
+ mpool_create(memory, size, &leaf._mempool);
- leaf_mempool = &leaf_pool;
+ leaf.mempool = &leaf._mempool;
}
/**
* allocate memory from memory pool
*/
-void* mpool_alloc(size_t asize, mpool_t* pool)
+void* mpool_alloc(size_t asize, _tMempool* pool)
{
// If the head is NULL, the mempool is full
if (pool->head == NULL) return NULL;
@@ -112,14 +107,14 @@
mpool_node_t* new_node;
size_t leftover = node_to_alloc->size - size_to_alloc;
node_to_alloc->size = size_to_alloc;
- if (leftover > header_size)
+ if (leftover > leaf.header_size)
{
long offset = (char*) node_to_alloc - (char*) pool->mpool;
- offset += header_size + node_to_alloc->size;
+ offset += leaf.header_size + node_to_alloc->size;
new_node = create_node(&pool->mpool[offset],
node_to_alloc->next,
node_to_alloc->prev,
- leftover - header_size);
+ leftover - leaf.header_size);
}
else
{
@@ -139,7 +134,7 @@
// Remove the allocated node from the free list
delink_node(node_to_alloc);
- pool->usize += header_size + node_to_alloc->size;
+ pool->usize += leaf.header_size + node_to_alloc->size;
if (leaf.clearOnAllocation > 0)
{
@@ -155,7 +150,7 @@
/**
* allocate memory from memory pool and also clear that memory to be blank
*/
-void* mpool_calloc(size_t asize, mpool_t* pool)
+void* mpool_calloc(size_t asize, _tMempool* pool)
{
// If the head is NULL, the mempool is full
if (pool->head == NULL) return NULL;
@@ -178,14 +173,14 @@
mpool_node_t* new_node;
size_t leftover = node_to_alloc->size - size_to_alloc;
node_to_alloc->size = size_to_alloc;
- if (leftover > header_size)
+ if (leftover > leaf.header_size)
{
long offset = (char*) node_to_alloc - (char*) pool->mpool;
- offset += header_size + node_to_alloc->size;
+ offset += leaf.header_size + node_to_alloc->size;
new_node = create_node(&pool->mpool[offset],
node_to_alloc->next,
node_to_alloc->prev,
- leftover - header_size);
+ leftover - leaf.header_size);
}
else
{
@@ -205,7 +200,7 @@
// Remove the allocated node from the free list
delink_node(node_to_alloc);
- pool->usize += header_size + node_to_alloc->size;
+ pool->usize += leaf.header_size + node_to_alloc->size;
// Format the new pool
char* new_pool = (char*)node_to_alloc->pool;
for (int i = 0; i < node_to_alloc->size; i++) new_pool[i] = 0;
@@ -216,7 +211,7 @@
void* leaf_alloc(size_t size)
{
//printf("alloc %i\n", size);
- void* block = mpool_alloc(size, &leaf_pool.pool);
+ void* block = mpool_alloc(size, &leaf._mempool);
if (block == NULL) leaf_mempool_overrun();
@@ -226,7 +221,7 @@
void* leaf_calloc(size_t size)
{
//printf("alloc %i\n", size);
- void* block = mpool_calloc(size, &leaf_pool.pool);
+ void* block = mpool_calloc(size, &leaf._mempool);
if (block == NULL) leaf_mempool_overrun();
@@ -234,13 +229,13 @@
return block;
}
-void mpool_free(void* ptr, mpool_t* pool)
+void mpool_free(void* ptr, _tMempool* pool)
{
//if (ptr < pool->mpool || ptr >= pool->mpool + pool->msize)
// Get the node at the freed space
- mpool_node_t* freed_node = (mpool_node_t*) (ptr - header_size);
+ mpool_node_t* freed_node = (mpool_node_t*) (ptr - leaf.header_size);
- pool->usize -= header_size + freed_node->size;
+ pool->usize -= leaf.header_size + freed_node->size;
// Check each node in the list against the newly freed one to see if it's adjacent in memory
mpool_node_t* other_node = pool->head;
@@ -249,10 +244,10 @@
{
next_node = other_node->next;
// Check if a node is directly after the freed node
- if ((long) freed_node + (header_size + freed_node->size) == (long) other_node)
+ if ((long) freed_node + (leaf.header_size + freed_node->size) == (long) other_node)
{
// Increase freed node's size
- freed_node->size += header_size + other_node->size;
+ freed_node->size += leaf.header_size + other_node->size;
// If we are merging with the head, move the head forward
if (other_node == pool->head) pool->head = pool->head->next;
// Delink the merged node
@@ -260,10 +255,10 @@
}
// Check if a node is directly before the freed node
- else if ((long) other_node + (header_size + other_node->size) == (long) freed_node)
+ else if ((long) other_node + (leaf.header_size + other_node->size) == (long) freed_node)
{
// Increase the merging node's size
- other_node->size += header_size + freed_node->size;
+ other_node->size += leaf.header_size + freed_node->size;
if (other_node != pool->head)
{
@@ -298,15 +293,15 @@
void leaf_free(void* ptr)
{
- mpool_free(ptr, &leaf_pool.pool);
+ mpool_free(ptr, &leaf._mempool);
}
-size_t mpool_get_size(mpool_t* pool)
+size_t mpool_get_size(_tMempool* pool)
{
return pool->msize;
}
-size_t mpool_get_used(mpool_t* pool)
+size_t mpool_get_used(_tMempool* pool)
{
return pool->usize;
}
@@ -313,17 +308,17 @@
size_t leaf_pool_get_size(void)
{
- return mpool_get_size(&leaf_pool.pool);
+ return mpool_get_size(&leaf._mempool);
}
size_t leaf_pool_get_used(void)
{
- return mpool_get_used(&leaf_pool.pool);
+ return mpool_get_used(&leaf._mempool);
}
void* leaf_pool_get_pool(void)
{
- float* buff = (float*)leaf_pool.pool.mpool;
+ float* buff = (float*)leaf._mempool.mpool;
return buff;
}
@@ -338,7 +333,7 @@
static inline mpool_node_t* create_node(void* block_location, mpool_node_t* next, mpool_node_t* prev, size_t size)
{
mpool_node_t* node = (mpool_node_t*)block_location;
- node->pool = block_location + header_size;
+ node->pool = block_location + leaf.header_size;
node->next = next;
node->prev = prev;
node->size = size;
@@ -372,20 +367,20 @@
void tMempool_init(tMempool* const mp, char* memory, size_t size)
{
- tMempool_initToPool(mp, memory, size, &leaf_mempool);
+ tMempool_initToPool(mp, memory, size, &leaf.mempool);
}
void tMempool_free(tMempool* const mp)
{
- tMempool_freeFromPool(mp, &leaf_mempool);
+ tMempool_freeFromPool(mp, &leaf.mempool);
}
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);
- mpool_create (memory, size, &m->pool);
+ mpool_create (memory, size, m);
}
void tMempool_freeFromPool (tMempool* const mp, tMempool* const mem)
@@ -393,5 +388,5 @@
_tMempool* mm = *mem;
_tMempool* m = *mp;
- mpool_free(m, &mm->pool);
+ mpool_free(m, mm);
}
--- 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);
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);
}
// 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);
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);
+ poly->rampVals = (float*) mpool_alloc(sizeof(float) * poly->maxNumVoices, m);
+ poly->firstReceived = (oBool*) mpool_alloc(sizeof(oBool) * poly->maxNumVoices, m);
+ poly->voices = (int**) mpool_alloc(sizeof(int*) * poly->maxNumVoices, m);
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);
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);
}
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);
+ mpool_free(poly->ramps, m);
+ mpool_free(poly->rampVals, m);
+ mpool_free(poly->firstReceived, m);
- mpool_free(poly, &m->pool);
+ mpool_free(poly, m);
}
void tPoly_tickPitch(tPoly* polyh)
--- a/LEAF/Src/leaf-oscillators.c
+++ b/LEAF/Src/leaf-oscillators.c
@@ -21,11 +21,7 @@
// Cycle
void tCycle_init(tCycle* const cy)
{
- _tCycle* c = *cy = (_tCycle*) leaf_alloc(sizeof(_tCycle));
-
- c->inc = 0.0f;
- c->phase = 0.0f;
-
+ tCycle_initToPool(cy, &leaf.mempool);
}
void tCycle_free(tCycle* const cy)
@@ -38,7 +34,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);
c->inc = 0.0f;
c->phase = 0.0f;
@@ -50,7 +46,7 @@
_tMempool* m = *mp;
_tCycle* c = *cy;
- mpool_free(c, &m->pool);
+ mpool_free(c, m);
}
void tCycle_setFreq(tCycle* const cy, float freq)
@@ -116,7 +112,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);
c->inc = 0.0f;
c->phase = 0.0f;
@@ -127,7 +123,7 @@
_tMempool* m = *mp;
_tTriangle* c = *cy;
- mpool_free(c, &m->pool);
+ mpool_free(c, m);
}
int tTriangle_setFreq(tTriangle* const cy, float freq)
@@ -247,7 +243,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);
c->inc = 0.0f;
c->phase = 0.0f;
@@ -258,7 +254,7 @@
_tMempool* m = *mp;
_tSquare* c = *cy;
- mpool_free(c, &m->pool);
+ mpool_free(c, m);
}
int tSquare_setFreq(tSquare* const cy, float freq)
@@ -376,7 +372,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);
c->inc = 0.0f;
c->phase = 0.0f;
@@ -387,7 +383,7 @@
_tMempool* m = *mp;
_tSawtooth* c = *cy;
- mpool_free(c, &m->pool);
+ mpool_free(c, m);
}
int tSawtooth_setFreq(tSawtooth* const cy, float freq)
@@ -513,7 +509,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);
p->phase = 0.0f;
p->inc = 0.0f;
@@ -524,7 +520,7 @@
_tMempool* m = *mp;
_tPhasor* p = *ph;
- mpool_free(p, &m->pool);
+ mpool_free(p, m);
}
int tPhasor_setFreq(tPhasor* const ph, float freq)
@@ -569,7 +565,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);
n->type = type;
n->rand = leaf.random;
@@ -580,7 +576,7 @@
_tMempool* m = *mp;
_tNoise* n = *ns;
- mpool_free(n, &m->pool);
+ mpool_free(n, m);
}
float tNoise_tick(tNoise* const ns)
@@ -654,7 +650,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);
tPoleZero_initToPool(&n->f, mp);
@@ -689,7 +685,7 @@
_tNeuron* n = *nr;
tPoleZero_free(&n->f);
- mpool_free(n, &m->pool);
+ mpool_free(n, m);
}
void tNeuron_reset(tNeuron* const nr)
--- a/LEAF/Src/leaf-physical.c
+++ b/LEAF/Src/leaf-physical.c
@@ -19,18 +19,18 @@
/* ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ tPluck ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */
void tPluck_init (tPluck* const pl, float lowestFrequency)
{
- tPluck_initToPool(pl, lowestFrequency, &leaf_mempool);
+ tPluck_initToPool(pl, lowestFrequency, &leaf.mempool);
}
void tPluck_free (tPluck* const pl)
{
- tPluck_freeFromPool(pl, &leaf_mempool);
+ tPluck_freeFromPool(pl, &leaf.mempool);
}
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);
if ( lowestFrequency <= 0.0f ) lowestFrequency = 10.0f;
@@ -56,7 +56,7 @@
tOneZero_freeFromPool(&p->loopFilter, mp);
tAllpassDelay_freeFromPool(&p->delayLine, mp);
- mpool_free(p, &m->pool);
+ mpool_free(p, m);
}
float tPluck_getLastOut (tPluck* const pl)
@@ -139,18 +139,18 @@
/* ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ tKarplusStrong ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */
void tKarplusStrong_init (tKarplusStrong* const pl, float lowestFrequency)
{
- tKarplusStrong_initToPool(pl, lowestFrequency, &leaf_mempool);
+ tKarplusStrong_initToPool(pl, lowestFrequency, &leaf.mempool);
}
void tKarplusStrong_free (tKarplusStrong* const pl)
{
- tKarplusStrong_freeFromPool(pl, &leaf_mempool);
+ tKarplusStrong_freeFromPool(pl, &leaf.mempool);
}
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);
if ( lowestFrequency <= 0.0f ) lowestFrequency = 8.0f;
@@ -194,7 +194,7 @@
tBiQuad_freeFromPool(&p->biquad[i], mp);
}
- mpool_free(p, &m->pool);
+ mpool_free(p, m);
}
float tKarplusStrong_getLastOut (tKarplusStrong* const pl)
@@ -358,12 +358,12 @@
float decay, float targetLev, float levSmoothFactor,
float levStrength, int levMode)
{
- tSimpleLivingString_initToPool(pl, freq, dampFreq, decay, targetLev, levSmoothFactor, levStrength, levMode, &leaf_mempool);
+ tSimpleLivingString_initToPool(pl, freq, dampFreq, decay, targetLev, levSmoothFactor, levStrength, levMode, &leaf.mempool);
}
void tSimpleLivingString_free(tSimpleLivingString* const pl)
{
- tSimpleLivingString_freeFromPool(pl, &leaf_mempool);
+ tSimpleLivingString_freeFromPool(pl, &leaf.mempool);
}
void tSimpleLivingString_initToPool (tSimpleLivingString* const pl, float freq, float dampFreq,
@@ -371,7 +371,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);
p->curr=0.0f;
tExpSmooth_initToPool(&p->wlSmooth, leaf.sampleRate/freq, 0.01, mp); // smoother for string wavelength (not freq, to avoid expensive divisions)
@@ -396,7 +396,7 @@
tHighpass_freeFromPool(&p->DCblocker, mp);
tFeedbackLeveler_freeFromPool(&p->fbLev, mp);
- mpool_free(p, &m->pool);
+ mpool_free(p, m);
}
void tSimpleLivingString_setFreq(tSimpleLivingString* const pl, float freq)
@@ -480,12 +480,12 @@
float dampFreq, float decay, float targetLev, float levSmoothFactor,
float levStrength, int levMode)
{
- tLivingString_initToPool(pl, freq, pickPos, prepIndex, dampFreq, decay, targetLev, levSmoothFactor, levStrength, levMode, &leaf_mempool);
+ tLivingString_initToPool(pl, freq, pickPos, prepIndex, dampFreq, decay, targetLev, levSmoothFactor, levStrength, levMode, &leaf.mempool);
}
void tLivingString_free(tLivingString* const pl)
{
- tLivingString_freeFromPool(pl, &leaf_mempool);
+ tLivingString_freeFromPool(pl, &leaf.mempool);
}
void tLivingString_initToPool (tLivingString* const pl, float freq, float pickPos, float prepIndex,
@@ -493,7 +493,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);
p->curr=0.0f;
tExpSmooth_initToPool(&p->wlSmooth, leaf.sampleRate/freq, 0.01, mp); // smoother for string wavelength (not freq, to avoid expensive divisions)
@@ -544,7 +544,7 @@
tFeedbackLeveler_freeFromPool(&p->fbLevU, mp);
tFeedbackLeveler_freeFromPool(&p->fbLevL, mp);
- mpool_free(p, &m->pool);
+ mpool_free(p, m);
}
void tLivingString_setFreq(tLivingString* const pl, float freq)
@@ -689,7 +689,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);
p->offset = offset;
p->slope = slope;
@@ -700,7 +700,7 @@
_tMempool* m = *mp;
_tReedTable* p = *pm;
- mpool_free(p, &m->pool);
+ mpool_free(p, m);
}
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);
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);
}
void tPRCRevert_clear(tPRCReverb* const rev)
@@ -243,7 +243,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);
if (t60 <= 0.0f) t60 = 0.001f;
@@ -296,7 +296,7 @@
tLinearDelay_freeFromPool(&r->allpassDelays[i], mp);
}
- mpool_free(r, &m->pool);
+ mpool_free(r, m);
}
void tNReverb_setT60(tNReverb* const rev, float t60)
@@ -457,18 +457,18 @@
void tDattorroReverb_init (tDattorroReverb* const rev)
{
- tDattorroReverb_initToPool(rev, &leaf_mempool);
+ tDattorroReverb_initToPool(rev, &leaf.mempool);
}
void tDattorroReverb_free (tDattorroReverb* const rev)
{
- tDattorroReverb_freeFromPool(rev, &leaf_mempool);
+ tDattorroReverb_freeFromPool(rev, &leaf.mempool);
}
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);
r->size_max = 2.0f;
r->size = 1.f;
@@ -567,7 +567,7 @@
tCycle_freeFromPool(&r->f2_lfo, mp);
- mpool_free(r, &m->pool);
+ mpool_free(r, m);
}
void tDattorroReverb_clear (tDattorroReverb* const rev)
--- a/LEAF/Src/leaf-sampling.c
+++ b/LEAF/Src/leaf-sampling.c
@@ -26,20 +26,20 @@
void tBuffer_init (tBuffer* const sb, uint32_t length)
{
- tBuffer_initToPool(sb, length, &leaf_mempool);
+ tBuffer_initToPool(sb, length, &leaf.mempool);
}
void tBuffer_free (tBuffer* const sb)
{
- tBuffer_freeFromPool(sb, &leaf_mempool);
+ tBuffer_freeFromPool(sb, &leaf.mempool);
}
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);
- s->buff = (float*) mpool_alloc( sizeof(float) * length, &m->pool);
+ s->buff = (float*) mpool_alloc( sizeof(float) * length, m);
s->bufferLength = length;
s->recordedLength = 0;
@@ -53,8 +53,8 @@
_tMempool* m = *mp;
_tBuffer* s = *sb;
- mpool_free(s->buff, &m->pool);
- mpool_free(s, &m->pool);
+ mpool_free(s->buff, m);
+ mpool_free(s, m);
}
void tBuffer_tick (tBuffer* const sb, float sample)
@@ -154,18 +154,18 @@
void tSampler_init(tSampler* const sp, tBuffer* const b)
{
- tSampler_initToPool(sp, b, &leaf_mempool);
+ tSampler_initToPool(sp, b, &leaf.mempool);
}
void tSampler_free (tSampler* const sp)
{
- tSampler_freeFromPool(sp, &leaf_mempool);
+ tSampler_freeFromPool(sp, &leaf.mempool);
}
void tSampler_initToPool(tSampler* const sp, tBuffer* const b, tMempool* const mp)
{
_tMempool* m = *mp;
- _tSampler* p = *sp = (_tSampler*) mpool_alloc(sizeof(_tSampler), &m->pool);
+ _tSampler* p = *sp = (_tSampler*) mpool_alloc(sizeof(_tSampler), m);
_tBuffer* s = *b;
p->samp = s;
@@ -202,7 +202,7 @@
_tSampler* p = *sp;
tRamp_freeFromPool(&p->gain, mp);
- mpool_free(p, &m->pool);
+ mpool_free(p, m);
}
void tSampler_setSample (tSampler* const sp, tBuffer* const b)
@@ -709,18 +709,18 @@
void tAutoSampler_init (tAutoSampler* const as, tBuffer* const b)
{
- tAutoSampler_initToPool(as, b, &leaf_mempool);
+ tAutoSampler_initToPool(as, b, &leaf.mempool);
}
void tAutoSampler_free (tAutoSampler* const as)
{
- tAutoSampler_freeFromPool(as, &leaf_mempool);
+ tAutoSampler_freeFromPool(as, &leaf.mempool);
}
void tAutoSampler_initToPool (tAutoSampler* const as, tBuffer* const b, tMempool* const mp)
{
_tMempool* m = *mp;
- _tAutoSampler* a = *as = (_tAutoSampler*) mpool_alloc(sizeof(_tAutoSampler), &m->pool);
+ _tAutoSampler* a = *as = (_tAutoSampler*) mpool_alloc(sizeof(_tAutoSampler), m);
tBuffer_setRecordMode(b, RecordOneShot);
tSampler_initToPool(&a->sampler, b, mp);
@@ -736,7 +736,7 @@
tEnvelopeFollower_freeFromPool(&a->ef, mp);
tSampler_freeFromPool(&a->sampler, mp);
- mpool_free(a, &m->pool);
+ mpool_free(a, m);
}
float tAutoSampler_tick (tAutoSampler* const as, float input)