From 239db70018ed05d5ae645abe918a518f36c5113d Mon Sep 17 00:00:00 2001 From: Sean Xue Date: Thu, 29 May 2025 22:48:48 -0400 Subject: [PATCH 01/14] commit message --- leaf/Inc/leaf-analysis.h | 366 ++++++++++---------- leaf/Inc/leaf-delay.h | 266 +++++++-------- leaf/Inc/leaf-distortion.h | 108 +++--- leaf/Inc/leaf-dynamics.h | 71 ++-- leaf/Inc/leaf-effects.h | 250 +++++++------- leaf/Inc/leaf-electrical.h | 5 +- leaf/Inc/leaf-envelopes.h | 226 ++++++------- leaf/Inc/leaf-filters.h | 648 ++++++++++++++++------------------- leaf/Inc/leaf-global.h | 11 +- leaf/Inc/leaf-instruments.h | 216 ++++++------ leaf/Inc/leaf-midi copy.h | 443 ------------------------ leaf/Inc/leaf-midi.h | 122 ++++--- leaf/Inc/leaf-oscillators.h | 658 ++++++++++++++++-------------------- leaf/Inc/leaf-physical.h | 655 +++++++++++++++++------------------ leaf/Inc/leaf-reverb.h | 88 +++-- leaf/Inc/leaf-sampling.h | 158 ++++----- leaf/Inc/leaf-tables.h | 9 +- leaf/Inc/leaf-vocal.h | 14 +- leaf/Src/leaf-analysis.c | 422 +++++++++++------------ leaf/Src/leaf-delay.c | 218 ++++++------ leaf/Src/leaf-distortion.c | 88 ++--- leaf/Src/leaf-dynamics.c | 58 ++-- leaf/Src/leaf-effects.c | 236 ++++++------- leaf/Src/leaf-electrical.c | 84 ++--- leaf/Src/leaf-envelopes.c | 182 +++++----- leaf/Src/leaf-filters.c | 582 +++++++++++++++---------------- leaf/Src/leaf-instruments.c | 396 +++++++++++----------- leaf/Src/leaf-midi.c | 182 +++++----- leaf/Src/leaf-oscillators.c | 450 ++++++++++++------------ leaf/Src/leaf-sampling.c | 32 +- 30 files changed, 3265 insertions(+), 3979 deletions(-) delete mode 100644 leaf/Inc/leaf-midi copy.h diff --git a/leaf/Inc/leaf-analysis.h b/leaf/Inc/leaf-analysis.h index 5ed7a22..3e9b177 100644 --- a/leaf/Inc/leaf-analysis.h +++ b/leaf/Inc/leaf-analysis.h @@ -75,7 +75,7 @@ extern "C" {  @} */ - typedef struct _tEnvelopeFollower + typedef struct tEnvelopeFollower { tMempool mempool; @@ -83,18 +83,16 @@ extern "C" { Lfloat a_thresh; Lfloat d_coeff; - } _tEnvelopeFollower; - - typedef _tEnvelopeFollower* tEnvelopeFollower; - - void tEnvelopeFollower_init (tEnvelopeFollower* const follower, Lfloat attackThreshold, Lfloat decayCoefficient, LEAF* const leaf); - void tEnvelopeFollower_initToPool (tEnvelopeFollower* const follower, Lfloat attackThreshold, Lfloat decayCoefficient, tMempool* const mempool); - void tEnvelopeFollower_free (tEnvelopeFollower* const follower); + } tEnvelopeFollower; + + void tEnvelopeFollower_init (tEnvelopeFollower** const follower, Lfloat attackThreshold, Lfloat decayCoefficient, LEAF* const leaf); + void tEnvelopeFollower_initToPool (tEnvelopeFollower** const follower, Lfloat attackThreshold, Lfloat decayCoefficient, tMempool* const mempool); + void tEnvelopeFollower_free (tEnvelopeFollower** const follower); - Lfloat tEnvelopeFollower_tick (tEnvelopeFollower const follower, Lfloat sample); + Lfloat tEnvelopeFollower_tick (tEnvelopeFollower* const follower, Lfloat sample); - void tEnvelopeFollower_setDecayCoefficient (tEnvelopeFollower const follower, Lfloat decayCoefficient); - void tEnvelopeFollower_setAttackThreshold (tEnvelopeFollower const follower, Lfloat attackThreshold); + void tEnvelopeFollower_setDecayCoefficient (tEnvelopeFollower* const follower, Lfloat decayCoefficient); + void tEnvelopeFollower_setAttackThreshold (tEnvelopeFollower* const follower, Lfloat attackThreshold); /*! @defgroup tzerocrossingcounter tZeroCrossingCounter @@ -132,7 +130,7 @@ extern "C" { @} */ /* Zero Crossing Detector */ - typedef struct _tZeroCrossingCounter + typedef struct tZeroCrossingCounter { tMempool mempool; @@ -144,17 +142,15 @@ extern "C" { uint16_t* countBuffer; int prevPosition; int position; - } _tZeroCrossingCounter; - - typedef _tZeroCrossingCounter* tZeroCrossingCounter; - - void tZeroCrossingCounter_init (tZeroCrossingCounter* const, int maxWindowSize, LEAF* const leaf); - void tZeroCrossingCounter_initToPool (tZeroCrossingCounter* const, int maxWindowSize, tMempool* const mempool); - void tZeroCrossingCounter_free (tZeroCrossingCounter* const); + } tZeroCrossingCounter; + + void tZeroCrossingCounter_init (tZeroCrossingCounter** const, int maxWindowSize, LEAF* const leaf); + void tZeroCrossingCounter_initToPool (tZeroCrossingCounter** const, int maxWindowSize, tMempool* const mempool); + void tZeroCrossingCounter_free (tZeroCrossingCounter** const); - Lfloat tZeroCrossingCounter_tick (tZeroCrossingCounter const, Lfloat input); + Lfloat tZeroCrossingCounter_tick (tZeroCrossingCounter* const, Lfloat input); - void tZeroCrossingCounter_setWindowSize (tZeroCrossingCounter const, Lfloat windowSize); + void tZeroCrossingCounter_setWindowSize (tZeroCrossingCounter* const, Lfloat windowSize); // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ @@ -199,25 +195,23 @@ extern "C" { @} */ /* PowerEnvelopeFollower */ - typedef struct _tPowerFollower + typedef struct tPowerFollower { tMempool mempool; Lfloat factor, oneminusfactor; Lfloat curr; - } _tPowerFollower; - - typedef _tPowerFollower* tPowerFollower; - - void tPowerFollower_init (tPowerFollower* const, Lfloat factor, LEAF* const leaf); - void tPowerFollower_initToPool (tPowerFollower* const, Lfloat factor, tMempool* const); - void tPowerFollower_free (tPowerFollower* const); + } tPowerFollower; + + void tPowerFollower_init (tPowerFollower** const, Lfloat factor, LEAF* const leaf); + void tPowerFollower_initToPool (tPowerFollower** const, Lfloat factor, tMempool* const); + void tPowerFollower_free (tPowerFollower** const); - Lfloat tPowerFollower_tick (tPowerFollower const, Lfloat input); + Lfloat tPowerFollower_tick (tPowerFollower* const, Lfloat input); - Lfloat tPowerFollower_getPower (tPowerFollower const); - void tPowerFollower_setFactor (tPowerFollower const, Lfloat factor); + Lfloat tPowerFollower_getPower (tPowerFollower* const); + void tPowerFollower_setFactor (tPowerFollower* const, Lfloat factor); // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ @@ -263,7 +257,7 @@ extern "C" { #define ENV_WINDOW_SIZE 1024 #define ENV_HOP_SIZE 256 - typedef struct _tEnvPD + typedef struct tEnvPD { tMempool mempool; @@ -277,17 +271,16 @@ extern "C" { Lfloat x_f; int windowSize, hopSize, blockSize; int x_allocforvs; /* extra buffer for DSP vector size */ - } _tEnvPD; + } tEnvPD; - typedef _tEnvPD* tEnvPD; - - void tEnvPD_init (tEnvPD* const, int windowSize, int hopSize, int blockSize, LEAF* const leaf); - void tEnvPD_initToPool (tEnvPD* const, int windowSize, int hopSize, int blockSize, tMempool* const); - void tEnvPD_free (tEnvPD* const); + + void tEnvPD_init (tEnvPD** const, int windowSize, int hopSize, int blockSize, LEAF* const leaf); + void tEnvPD_initToPool (tEnvPD** const, int windowSize, int hopSize, int blockSize, tMempool* const); + void tEnvPD_free (tEnvPD** const); - Lfloat tEnvPD_tick (tEnvPD const); + Lfloat tEnvPD_tick (tEnvPD* const); - void tEnvPD_processBlock (tEnvPD const, Lfloat* in); + void tEnvPD_processBlock (tEnvPD* const, Lfloat* in); // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ @@ -355,7 +348,7 @@ extern "C" { #define DEFATTACK 10 #define DEFRELEASE 10 - typedef struct _tAttackDetection + typedef struct tAttackDetection { tMempool mempool; Lfloat env; @@ -375,21 +368,20 @@ extern "C" { Lfloat prevAmp; Lfloat threshold; - } _tAttackDetection; + } tAttackDetection; - typedef _tAttackDetection* tAttackDetection; - - void tAttackDetection_init (tAttackDetection* const, int blocksize, int atk, int rel, LEAF* const leaf); - void tAttackDetection_initToPool (tAttackDetection* const, int blocksize, int atk, int rel, tMempool* const); - void tAttackDetection_free (tAttackDetection* const); - - void tAttackDetection_setBlocksize (tAttackDetection const, int size); - void tAttackDetection_setSamplerate (tAttackDetection const, int inRate); - void tAttackDetection_setAttack (tAttackDetection const, int inAtk); - void tAttackDetection_setRelease (tAttackDetection const, int inRel); - void tAttackDetection_setThreshold (tAttackDetection const, Lfloat thres); - int tAttackDetection_detect (tAttackDetection const, Lfloat *in); - void tAttackDetection_setSampleRate (tAttackDetection const, Lfloat sr); + + void tAttackDetection_init (tAttackDetection** const, int blocksize, int atk, int rel, LEAF* const leaf); + void tAttackDetection_initToPool (tAttackDetection** const, int blocksize, int atk, int rel, tMempool* const); + void tAttackDetection_free (tAttackDetection** const); + + void tAttackDetection_setBlocksize (tAttackDetection* const, int size); + void tAttackDetection_setSamplerate (tAttackDetection* const, int inRate); + void tAttackDetection_setAttack (tAttackDetection* const, int inAtk); + void tAttackDetection_setRelease (tAttackDetection* const, int inRel); + void tAttackDetection_setThreshold (tAttackDetection* const, Lfloat thres); + int tAttackDetection_detect (tAttackDetection* const, Lfloat *in); + void tAttackDetection_setSampleRate (tAttackDetection* const, Lfloat sr); //============================================================================== @@ -455,7 +447,7 @@ extern "C" { #define DEFMINRMS 0.003f // default minimum RMS #define SEEK 0.85f // seek-length as ratio of framesize - typedef struct _tSNAC + typedef struct tSNAC { tMempool mempool; @@ -473,22 +465,20 @@ extern "C" { Lfloat biasfactor; Lfloat minrms; - } _tSNAC; - - typedef _tSNAC* tSNAC; - - void tSNAC_init (tSNAC* const, int overlaparg, LEAF* const leaf); - void tSNAC_initToPool (tSNAC* const, int overlaparg, tMempool* const); - void tSNAC_free (tSNAC* const); + } tSNAC; + + void tSNAC_init (tSNAC** const, int overlaparg, LEAF* const leaf); + void tSNAC_initToPool (tSNAC** const, int overlaparg, tMempool* const); + void tSNAC_free (tSNAC** const); - void tSNAC_ioSamples (tSNAC s, Lfloat *in, int size); - void tSNAC_setOverlap (tSNAC s, int lap); - void tSNAC_setBias (tSNAC s, Lfloat bias); - void tSNAC_setMinRMS (tSNAC s, Lfloat rms); + void tSNAC_ioSamples (tSNAC* s, Lfloat *in, int size); + void tSNAC_setOverlap (tSNAC* s, int lap); + void tSNAC_setBias (tSNAC* s, Lfloat bias); + void tSNAC_setMinRMS (tSNAC* s, Lfloat rms); /*To get freq, perform SAMPLE_RATE/snac_getperiod() */ - Lfloat tSNAC_getPeriod (tSNAC s); - Lfloat tSNAC_getFidelity (tSNAC s); + Lfloat tSNAC_getPeriod (tSNAC* s); + Lfloat tSNAC_getFidelity (tSNAC* s); /*! @defgroup tperioddetection tPeriodDetection @@ -563,7 +553,7 @@ extern "C" { #define FBA 20 #define HPFREQ 20.0f - typedef struct _tPeriodDetection + typedef struct tPeriodDetection { tMempool mempool; @@ -599,29 +589,27 @@ extern "C" { Lfloat tolerance; Lfloat invSampleRate; - } _tPeriodDetection; - - typedef _tPeriodDetection* tPeriodDetection; - - void tPeriodDetection_init (tPeriodDetection* const, Lfloat* in, int bufSize, int frameSize, LEAF* const leaf); - void tPeriodDetection_initToPool (tPeriodDetection* const, Lfloat* in, int bufSize, int frameSize, tMempool* const); - void tPeriodDetection_free (tPeriodDetection* const); + } tPeriodDetection; + + void tPeriodDetection_init (tPeriodDetection** const, Lfloat* in, int bufSize, int frameSize, LEAF* const leaf); + void tPeriodDetection_initToPool (tPeriodDetection** const, Lfloat* in, int bufSize, int frameSize, tMempool* const); + void tPeriodDetection_free (tPeriodDetection** const); - Lfloat tPeriodDetection_tick (tPeriodDetection const, Lfloat sample); + Lfloat tPeriodDetection_tick (tPeriodDetection* const, Lfloat sample); - Lfloat tPeriodDetection_getPeriod (tPeriodDetection const); - Lfloat tPeriodDetection_getFidelity (tPeriodDetection const); - void tPeriodDetection_setHopSize (tPeriodDetection const, int hs); - void tPeriodDetection_setWindowSize (tPeriodDetection const, int ws); - void tPeriodDetection_setFidelityThreshold (tPeriodDetection const, Lfloat threshold); - void tPeriodDetection_setAlpha (tPeriodDetection const, Lfloat alpha); - void tPeriodDetection_setTolerance (tPeriodDetection const, Lfloat tolerance); - void tPeriodDetection_setSampleRate (tPeriodDetection const, Lfloat sr); + Lfloat tPeriodDetection_getPeriod (tPeriodDetection* const); + Lfloat tPeriodDetection_getFidelity (tPeriodDetection* const); + void tPeriodDetection_setHopSize (tPeriodDetection* const, int hs); + void tPeriodDetection_setWindowSize (tPeriodDetection* const, int ws); + void tPeriodDetection_setFidelityThreshold (tPeriodDetection* const, Lfloat threshold); + void tPeriodDetection_setAlpha (tPeriodDetection* const, Lfloat alpha); + void tPeriodDetection_setTolerance (tPeriodDetection* const, Lfloat tolerance); + void tPeriodDetection_setSampleRate (tPeriodDetection* const, Lfloat sr); //============================================================================== // Maybe keep from here to tPeriodDetector internal? - typedef struct _tZeroCrossingInfo + typedef struct tZeroCrossingInfo { tMempool mempool; @@ -633,25 +621,23 @@ extern "C" { int _leading_edge;// = undefined_edge; int_min int _trailing_edge;// = undefined_edge; Lfloat _width;// = 0.0f; - } _tZeroCrossingInfo; - - typedef _tZeroCrossingInfo* tZeroCrossingInfo; - - void tZeroCrossingInfo_init (tZeroCrossingInfo* const, LEAF* const leaf); - void tZeroCrossingInfo_initToPool (tZeroCrossingInfo* const, tMempool* const); - void tZeroCrossingInfo_free (tZeroCrossingInfo* const); + } tZeroCrossingInfo; + + void tZeroCrossingInfo_init (tZeroCrossingInfo** const, LEAF* const leaf); + void tZeroCrossingInfo_initToPool (tZeroCrossingInfo** const, tMempool* const); + void tZeroCrossingInfo_free (tZeroCrossingInfo** const); - int tZeroCrossingInfo_tick (tZeroCrossingInfo const, Lfloat s); + int tZeroCrossingInfo_tick (tZeroCrossingInfo* const, Lfloat s); - int tZeroCrossingInfo_getState (tZeroCrossingInfo const); - void tZeroCrossingInfo_updatePeak (tZeroCrossingInfo const, Lfloat s, int pos); - int tZeroCrossingInfo_period (tZeroCrossingInfo const, tZeroCrossingInfo* const next); - Lfloat tZeroCrossingInfo_fractionalPeriod (tZeroCrossingInfo const, tZeroCrossingInfo* const next); - int tZeroCrossingInfo_getWidth (tZeroCrossingInfo const); + int tZeroCrossingInfo_getState (tZeroCrossingInfo* const); + void tZeroCrossingInfo_updatePeak (tZeroCrossingInfo* const, Lfloat s, int pos); + int tZeroCrossingInfo_period (tZeroCrossingInfo* const, tZeroCrossingInfo* const next); + Lfloat tZeroCrossingInfo_fractionalPeriod (tZeroCrossingInfo* const, tZeroCrossingInfo* const next); + int tZeroCrossingInfo_getWidth (tZeroCrossingInfo* const); //============================================================================== - typedef struct _tZeroCrossingCollector + typedef struct tZeroCrossingCollector { tMempool mempool; @@ -669,32 +655,30 @@ extern "C" { int _ready;// = false; Lfloat _peak_update;// = 0.0f; Lfloat _peak;// = 0.0f; - } _tZeroCrossingCollector; - - typedef _tZeroCrossingCollector* tZeroCrossingCollector; - - void tZeroCrossingCollector_init (tZeroCrossingCollector* const, int windowSize, Lfloat hysteresis, LEAF* const leaf); - void tZeroCrossingCollector_initToPool (tZeroCrossingCollector* const, int windowSize, Lfloat hysteresis, tMempool* const); - void tZeroCrossingCollector_free (tZeroCrossingCollector* const); - - int tZeroCrossingCollector_tick (tZeroCrossingCollector const, Lfloat s); - int tZeroCrossingCollector_getState (tZeroCrossingCollector const); + } tZeroCrossingCollector; + + void tZeroCrossingCollector_init (tZeroCrossingCollector** const, int windowSize, Lfloat hysteresis, LEAF* const leaf); + void tZeroCrossingCollector_initToPool (tZeroCrossingCollector** const, int windowSize, Lfloat hysteresis, tMempool* const); + void tZeroCrossingCollector_free (tZeroCrossingCollector** const); - int tZeroCrossingCollector_getNumEdges (tZeroCrossingCollector const zc); - int tZeroCrossingCollector_getCapacity (tZeroCrossingCollector const zc); - int tZeroCrossingCollector_getFrame (tZeroCrossingCollector const zc); - int tZeroCrossingCollector_getWindowSize (tZeroCrossingCollector const zc); + int tZeroCrossingCollector_tick (tZeroCrossingCollector* const, Lfloat s); + int tZeroCrossingCollector_getState (tZeroCrossingCollector* const); - int tZeroCrossingCollector_isReady (tZeroCrossingCollector const zc); - Lfloat tZeroCrossingCollector_getPeak (tZeroCrossingCollector const zc); - int tZeroCrossingCollector_isReset (tZeroCrossingCollector const zc); + int tZeroCrossingCollector_getNumEdges (tZeroCrossingCollector* const zc); + int tZeroCrossingCollector_getCapacity (tZeroCrossingCollector* const zc); + int tZeroCrossingCollector_getFrame (tZeroCrossingCollector* const zc); + int tZeroCrossingCollector_getWindowSize (tZeroCrossingCollector* const zc); + + int tZeroCrossingCollector_isReady (tZeroCrossingCollector* const zc); + Lfloat tZeroCrossingCollector_getPeak (tZeroCrossingCollector* const zc); + int tZeroCrossingCollector_isReset (tZeroCrossingCollector* const zc); - tZeroCrossingInfo const tZeroCrossingCollector_getCrossing (tZeroCrossingCollector const zc, int index); - void tZeroCrossingCollector_setHysteresis (tZeroCrossingCollector const zc, Lfloat hysteresis); + tZeroCrossingInfo const tZeroCrossingCollector_getCrossing (tZeroCrossingCollector* const zc, int index); + void tZeroCrossingCollector_setHysteresis (tZeroCrossingCollector* const zc, Lfloat hysteresis); //============================================================================== - typedef struct _tBitset + typedef struct tBitset { tMempool mempool; @@ -702,41 +686,37 @@ extern "C" { unsigned int _size; unsigned int _bit_size; unsigned int* _bits; - } _tBitset; - - typedef _tBitset* tBitset; - - void tBitset_init (tBitset* const bitset, int numBits, LEAF* const leaf); - void tBitset_initToPool (tBitset* const bitset, int numBits, tMempool* const mempool); - void tBitset_free (tBitset* const bitset); - - int tBitset_get (tBitset const bitset, int index); - void tBitset_set (tBitset const bitset, int index, unsigned int val); - void tBitset_setMultiple (tBitset const bitset, int index, int n, unsigned int val); - int tBitset_getSize (tBitset const bitset); - void tBitset_clear (tBitset const bitset); + } tBitset; - unsigned int* tBitset_getData (tBitset const bitset); + void tBitset_init (tBitset** const bitset, int numBits, LEAF* const leaf); + void tBitset_initToPool (tBitset** const bitset, int numBits, tMempool* const mempool); + void tBitset_free (tBitset** const bitset); + + int tBitset_get (tBitset* const bitset, int index); + void tBitset_set (tBitset* const bitset, int index, unsigned int val); + void tBitset_setMultiple (tBitset* const bitset, int index, int n, unsigned int val); + int tBitset_getSize (tBitset* const bitset); + void tBitset_clear (tBitset* const bitset); + + unsigned int* tBitset_getData (tBitset* const bitset); //============================================================================== - typedef struct _tBACF + typedef struct tBACF { tMempool mempool; tBitset _bitset; unsigned int _mid_array; - } _tBACF; - - typedef _tBACF* tBACF; - - void tBACF_init (tBACF* const bacf, tBitset* const bitset, LEAF* const leaf); - void tBACF_initToPool (tBACF* const bacf, tBitset* const bitset, tMempool* const mempool); - void tBACF_free (tBACF* const bacf); + } tBACF; + + void tBACF_init (tBACF** const bacf, tBitset* const bitset, LEAF* const leaf); + void tBACF_initToPool (tBACF** const bacf, tBitset* const bitset, tMempool* const mempool); + void tBACF_free (tBACF** const bacf); - int tBACF_getCorrelation (tBACF const bacf, int pos); - void tBACF_set (tBACF const bacf, tBitset* const bitset); + int tBACF_getCorrelation (tBACF* const bacf, int pos); + void tBACF_set (tBACF* const bacf, tBitset* const bitset); //============================================================================== @@ -830,7 +810,7 @@ extern "C" { Lfloat periodicity; } _period_info; - typedef struct _tPeriodDetector + typedef struct tPeriodDetector { tMempool mempool; @@ -854,25 +834,23 @@ extern "C" { tBACF _bacf; - } _tPeriodDetector; - - typedef _tPeriodDetector* tPeriodDetector; - - void tPeriodDetector_init (tPeriodDetector* const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat hysteresis, LEAF* const leaf); - void tPeriodDetector_initToPool (tPeriodDetector* const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat hysteresis, tMempool* const mempool); - void tPeriodDetector_free (tPeriodDetector* const detector); + } tPeriodDetector; + + void tPeriodDetector_init (tPeriodDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat hysteresis, LEAF* const leaf); + void tPeriodDetector_initToPool (tPeriodDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat hysteresis, tMempool* const mempool); + void tPeriodDetector_free (tPeriodDetector** const detector); - int tPeriodDetector_tick (tPeriodDetector const detector, Lfloat sample); + int tPeriodDetector_tick (tPeriodDetector* const detector, Lfloat sample); // get the periodicity for a given harmonic - Lfloat tPeriodDetector_getPeriod (tPeriodDetector const detector); - Lfloat tPeriodDetector_getPeriodicity (tPeriodDetector const detector); - Lfloat tPeriodDetector_harmonic (tPeriodDetector const detector, int harmonicIndex); - Lfloat tPeriodDetector_predictPeriod (tPeriodDetector const detector); - int tPeriodDetector_isReady (tPeriodDetector const detector); - int tPeriodDetector_isReset (tPeriodDetector const detector); - void tPeriodDetector_setHysteresis (tPeriodDetector const detector, Lfloat hysteresis); - void tPeriodDetector_setSampleRate (tPeriodDetector const detector, Lfloat sr); + Lfloat tPeriodDetector_getPeriod (tPeriodDetector* const detector); + Lfloat tPeriodDetector_getPeriodicity (tPeriodDetector* const detector); + Lfloat tPeriodDetector_harmonic (tPeriodDetector* const detector, int harmonicIndex); + Lfloat tPeriodDetector_predictPeriod (tPeriodDetector* const detector); + int tPeriodDetector_isReady (tPeriodDetector* const detector); + int tPeriodDetector_isReset (tPeriodDetector* const detector); + void tPeriodDetector_setHysteresis (tPeriodDetector* const detector, Lfloat hysteresis); + void tPeriodDetector_setSampleRate (tPeriodDetector* const detector, Lfloat sr); //============================================================================== @@ -940,7 +918,7 @@ extern "C" { Lfloat periodicity; } _pitch_info; - typedef struct _tPitchDetector + typedef struct tPitchDetector { tMempool mempool; @@ -951,24 +929,22 @@ extern "C" { Lfloat sampleRate; - } _tPitchDetector; - - typedef _tPitchDetector* tPitchDetector; - - void tPitchDetector_init (tPitchDetector* const detector, Lfloat lowestFreq, Lfloat highestFreq, LEAF* const leaf); - void tPitchDetector_initToPool (tPitchDetector* const detector, Lfloat lowestFreq, Lfloat highestFreq, tMempool* const mempool); - void tPitchDetector_free (tPitchDetector* const detector); + } tPitchDetector; + + void tPitchDetector_init (tPitchDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, LEAF* const leaf); + void tPitchDetector_initToPool (tPitchDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, tMempool* const mempool); + void tPitchDetector_free (tPitchDetector** const detector); - int tPitchDetector_tick (tPitchDetector const detector, Lfloat sample); + int tPitchDetector_tick (tPitchDetector* const detector, Lfloat sample); - Lfloat tPitchDetector_getFrequency (tPitchDetector const detector); - Lfloat tPitchDetector_getPeriodicity (tPitchDetector const detector); - Lfloat tPitchDetector_harmonic (tPitchDetector const detector, int harmonicIndex); - Lfloat tPitchDetector_predictFrequency (tPitchDetector const detector); - int tPitchDetector_indeterminate (tPitchDetector const detector); + Lfloat tPitchDetector_getFrequency (tPitchDetector* const detector); + Lfloat tPitchDetector_getPeriodicity (tPitchDetector* const detector); + Lfloat tPitchDetector_harmonic (tPitchDetector* const detector, int harmonicIndex); + Lfloat tPitchDetector_predictFrequency (tPitchDetector* const detector); + int tPitchDetector_indeterminate (tPitchDetector* const detector); - void tPitchDetector_setHysteresis (tPitchDetector const detector, Lfloat hysteresis); - void tPitchDetector_setSampleRate (tPitchDetector const detector, Lfloat sr); + void tPitchDetector_setHysteresis (tPitchDetector* const detector, Lfloat hysteresis); + void tPitchDetector_setSampleRate (tPitchDetector* const detector, Lfloat sr); //============================================================================== @@ -1038,7 +1014,7 @@ extern "C" {  @} */ - typedef struct _tDualPitchDetector + typedef struct tDualPitchDetector { tMempool mempool; @@ -1054,24 +1030,22 @@ extern "C" { Lfloat sampleRate; - } _tDualPitchDetector; - - typedef _tDualPitchDetector* tDualPitchDetector; - - void tDualPitchDetector_init (tDualPitchDetector* const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat* inBuffer, int bufSize, LEAF* const leaf); - void tDualPitchDetector_initToPool (tDualPitchDetector* const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat* inBuffer, int bufSize, tMempool* const mempool); - void tDualPitchDetector_free (tDualPitchDetector* const detector); + } tDualPitchDetector; + + void tDualPitchDetector_init (tDualPitchDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat* inBuffer, int bufSize, LEAF* const leaf); + void tDualPitchDetector_initToPool (tDualPitchDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat* inBuffer, int bufSize, tMempool* const mempool); + void tDualPitchDetector_free (tDualPitchDetector** const detector); - int tDualPitchDetector_tick (tDualPitchDetector const detector, Lfloat sample); + int tDualPitchDetector_tick (tDualPitchDetector* const detector, Lfloat sample); - Lfloat tDualPitchDetector_getFrequency (tDualPitchDetector const detector); - Lfloat tDualPitchDetector_getPeriodicity (tDualPitchDetector const detector); - Lfloat tDualPitchDetector_harmonic (tDualPitchDetector const detector, int harmonicIndex); - Lfloat tDualPitchDetector_predictFrequency (tDualPitchDetector const detector); - - void tDualPitchDetector_setHysteresis (tDualPitchDetector const detector, Lfloat hysteresis); - void tDualPitchDetector_setPeriodicityThreshold (tDualPitchDetector const detector, Lfloat thresh); - void tDualPitchDetector_setSampleRate (tDualPitchDetector const detector, Lfloat sr); + Lfloat tDualPitchDetector_getFrequency (tDualPitchDetector* const detector); + Lfloat tDualPitchDetector_getPeriodicity (tDualPitchDetector* const detector); + Lfloat tDualPitchDetector_harmonic (tDualPitchDetector* const detector, int harmonicIndex); + Lfloat tDualPitchDetector_predictFrequency (tDualPitchDetector* const detector); + + void tDualPitchDetector_setHysteresis (tDualPitchDetector* const detector, Lfloat hysteresis); + void tDualPitchDetector_setPeriodicityThreshold (tDualPitchDetector* const detector, Lfloat thresh); + void tDualPitchDetector_setSampleRate (tDualPitchDetector* const detector, Lfloat sr); #ifdef __cplusplus } diff --git a/leaf/Inc/leaf-delay.h b/leaf/Inc/leaf-delay.h index 5548105..aac4ff2 100644 --- a/leaf/Inc/leaf-delay.h +++ b/leaf/Inc/leaf-delay.h @@ -103,7 +103,7 @@ extern "C" {  @} */ - typedef struct _tDelay + typedef struct tDelay { tMempool mempool; @@ -116,24 +116,22 @@ extern "C" { uint32_t delay, maxDelay; - } _tDelay; - - typedef _tDelay* tDelay; - - void tDelay_init (tDelay* const, uint32_t delay, uint32_t maxDelay, LEAF* const leaf); - void tDelay_initToPool (tDelay* const, uint32_t delay, uint32_t maxDelay, tMempool* const); - void tDelay_free (tDelay* const); - - Lfloat tDelay_tick (tDelay const, Lfloat sample); - - void tDelay_clear (tDelay const); - void tDelay_setDelay (tDelay const, uint32_t delay); - uint32_t tDelay_getDelay (tDelay const); - void tDelay_tapIn (tDelay const, Lfloat in, uint32_t tapDelay); - Lfloat tDelay_tapOut (tDelay const, uint32_t tapDelay); - Lfloat tDelay_addTo (tDelay const, Lfloat value, uint32_t tapDelay); - Lfloat tDelay_getLastOut (tDelay const); - Lfloat tDelay_getLastIn (tDelay const); + } tDelay; + + void tDelay_init (tDelay** const, uint32_t delay, uint32_t maxDelay, LEAF* const leaf); + void tDelay_initToPool (tDelay** const, uint32_t delay, uint32_t maxDelay, tMempool* const); + void tDelay_free (tDelay** const); + + Lfloat tDelay_tick (tDelay* const, Lfloat sample); + + void tDelay_clear (tDelay* const); + void tDelay_setDelay (tDelay* const, uint32_t delay); + uint32_t tDelay_getDelay (tDelay* const); + void tDelay_tapIn (tDelay* const, Lfloat in, uint32_t tapDelay); + Lfloat tDelay_tapOut (tDelay* const, uint32_t tapDelay); + Lfloat tDelay_addTo (tDelay* const, Lfloat value, uint32_t tapDelay); + Lfloat tDelay_getLastOut (tDelay* const); + Lfloat tDelay_getLastIn (tDelay* const); //============================================================================== @@ -222,7 +220,7 @@ extern "C" {  @} */ - typedef struct _tLinearDelay + typedef struct tLinearDelay { tMempool mempool; @@ -239,27 +237,25 @@ extern "C" { Lfloat alpha, omAlpha; - } _tLinearDelay; - - typedef _tLinearDelay* tLinearDelay; - - void tLinearDelay_init (tLinearDelay* const, Lfloat delay, uint32_t maxDelay, LEAF* const leaf); - void tLinearDelay_initToPool (tLinearDelay* const, Lfloat delay, uint32_t maxDelay, tMempool* const); - void tLinearDelay_free (tLinearDelay* const); - - Lfloat tLinearDelay_tick (tLinearDelay const, Lfloat sample); - void tLinearDelay_tickIn (tLinearDelay const, Lfloat input); - Lfloat tLinearDelay_tickOut (tLinearDelay const); - - void tLinearDelay_clear (tLinearDelay const dl); - void tLinearDelay_setDelay (tLinearDelay const, Lfloat delay); - Lfloat tLinearDelay_getDelay (tLinearDelay const); - void tLinearDelay_tapIn (tLinearDelay const, Lfloat in, uint32_t tapDelay); - Lfloat tLinearDelay_tapOut (tLinearDelay const, uint32_t tapDelay); - Lfloat tLinearDelay_tapOutInterpolated (tLinearDelay const dl, Lfloat tapDelay); - Lfloat tLinearDelay_addTo (tLinearDelay const, Lfloat value, uint32_t tapDelay); - Lfloat tLinearDelay_getLastOut (tLinearDelay const); - Lfloat tLinearDelay_getLastIn (tLinearDelay const); + } tLinearDelay; + + void tLinearDelay_init (tLinearDelay** const, Lfloat delay, uint32_t maxDelay, LEAF* const leaf); + void tLinearDelay_initToPool (tLinearDelay** const, Lfloat delay, uint32_t maxDelay, tMempool* const); + void tLinearDelay_free (tLinearDelay** const); + + Lfloat tLinearDelay_tick (tLinearDelay* const, Lfloat sample); + void tLinearDelay_tickIn (tLinearDelay* const, Lfloat input); + Lfloat tLinearDelay_tickOut (tLinearDelay* const); + + void tLinearDelay_clear (tLinearDelay* const dl); + void tLinearDelay_setDelay (tLinearDelay* const, Lfloat delay); + Lfloat tLinearDelay_getDelay (tLinearDelay* const); + void tLinearDelay_tapIn (tLinearDelay* const, Lfloat in, uint32_t tapDelay); + Lfloat tLinearDelay_tapOut (tLinearDelay* const, uint32_t tapDelay); + Lfloat tLinearDelay_tapOutInterpolated (tLinearDelay* const dl, Lfloat tapDelay); + Lfloat tLinearDelay_addTo (tLinearDelay* const, Lfloat value, uint32_t tapDelay); + Lfloat tLinearDelay_getLastOut (tLinearDelay* const); + Lfloat tLinearDelay_getLastIn (tLinearDelay* const); @@ -367,7 +363,7 @@ extern "C" {  @} */ - typedef struct _tHermiteDelay + typedef struct tHermiteDelay { tMempool mempool; @@ -382,29 +378,27 @@ extern "C" { Lfloat delay; Lfloat alpha, omAlpha; - } _tHermiteDelay; - - typedef _tHermiteDelay* tHermiteDelay; - - void tHermiteDelay_init (tHermiteDelay* const dl, Lfloat delay, uint32_t maxDelay, LEAF* const leaf); - void tHermiteDelay_initToPool (tHermiteDelay* const dl, Lfloat delay, uint32_t maxDelay, tMempool* const mp); - void tHermiteDelay_free (tHermiteDelay* const dl); - - Lfloat tHermiteDelay_tick (tHermiteDelay const dl, Lfloat input); - void tHermiteDelay_tickIn (tHermiteDelay const dl, Lfloat input); - Lfloat tHermiteDelay_tickOut (tHermiteDelay const dl); - - void tHermiteDelay_clear (tHermiteDelay const dl); - void tHermiteDelay_setDelay (tHermiteDelay const dl, Lfloat delay); - Lfloat tHermiteDelay_tapOut (tHermiteDelay const dl, uint32_t tapDelay); - Lfloat tHermiteDelay_tapOutInterpolated (tHermiteDelay const dl, uint32_t tapDelay, Lfloat alpha); - void tHermiteDelay_tapIn (tHermiteDelay const dl, Lfloat value, uint32_t tapDelay); - Lfloat tHermiteDelay_addTo (tHermiteDelay const dl, Lfloat value, uint32_t tapDelay); - Lfloat tHermiteDelay_getDelay (tHermiteDelay const dl); - Lfloat tHermiteDelay_getLastOut (tHermiteDelay const dl); - Lfloat tHermiteDelay_getLastIn (tHermiteDelay const dl); - void tHermiteDelay_setGain (tHermiteDelay const dl, Lfloat gain); - Lfloat tHermiteDelay_getGain (tHermiteDelay const dl); + } tHermiteDelay; + + void tHermiteDelay_init (tHermiteDelay** const dl, Lfloat delay, uint32_t maxDelay, LEAF* const leaf); + void tHermiteDelay_initToPool (tHermiteDelay** const dl, Lfloat delay, uint32_t maxDelay, tMempool* const mp); + void tHermiteDelay_free (tHermiteDelay** const dl); + + Lfloat tHermiteDelay_tick (tHermiteDelay* const dl, Lfloat input); + void tHermiteDelay_tickIn (tHermiteDelay* const dl, Lfloat input); + Lfloat tHermiteDelay_tickOut (tHermiteDelay* const dl); + + void tHermiteDelay_clear (tHermiteDelay* const dl); + void tHermiteDelay_setDelay (tHermiteDelay* const dl, Lfloat delay); + Lfloat tHermiteDelay_tapOut (tHermiteDelay* const dl, uint32_t tapDelay); + Lfloat tHermiteDelay_tapOutInterpolated (tHermiteDelay* const dl, uint32_t tapDelay, Lfloat alpha); + void tHermiteDelay_tapIn (tHermiteDelay* const dl, Lfloat value, uint32_t tapDelay); + Lfloat tHermiteDelay_addTo (tHermiteDelay* const dl, Lfloat value, uint32_t tapDelay); + Lfloat tHermiteDelay_getDelay (tHermiteDelay* const dl); + Lfloat tHermiteDelay_getLastOut (tHermiteDelay* const dl); + Lfloat tHermiteDelay_getLastIn (tHermiteDelay* const dl); + void tHermiteDelay_setGain (tHermiteDelay* const dl, Lfloat gain); + Lfloat tHermiteDelay_getGain (tHermiteDelay* const dl); //============================================================================== @@ -504,7 +498,7 @@ extern "C" {  @} */ - typedef struct _tLagrangeDelay + typedef struct tLagrangeDelay { tMempool mempool; @@ -522,28 +516,26 @@ extern "C" { Lfloat h1; Lfloat h2; Lfloat h3; - } _tLagrangeDelay; - - typedef _tLagrangeDelay* tLagrangeDelay; - - void tLagrangeDelay_init (tLagrangeDelay* const dl, Lfloat delay, uint32_t maxDelay, LEAF* const leaf); - void tLagrangeDelay_initToPool (tLagrangeDelay* const dl, Lfloat delay, uint32_t maxDelay, tMempool* const mp); - void tLagrangeDelay_free (tLagrangeDelay* const dl); - - Lfloat tLagrangeDelay_tick (tLagrangeDelay const dl, Lfloat input); - void tLagrangeDelay_tickIn (tLagrangeDelay const dl, Lfloat input); - Lfloat tLagrangeDelay_tickOut (tLagrangeDelay const dl); - - void tLagrangeDelay_clear (tLagrangeDelay const dl); - void tLagrangeDelay_setDelay (tLagrangeDelay const dl, Lfloat delay); - Lfloat tLagrangeDelay_tapOut (tLagrangeDelay const dl, uint32_t tapDelay); - Lfloat tLagrangeDelay_tapOutInterpolated (tLagrangeDelay const dl, uint32_t tapDelay, Lfloat alpha); - void tLagrangeDelay_tapIn (tLagrangeDelay const dl, Lfloat value, uint32_t tapDelay); - Lfloat tLagrangeDelay_addTo (tLagrangeDelay const dl, Lfloat value, uint32_t tapDelay); - Lfloat tLagrangeDelay_getDelay (tLagrangeDelay const dl); - Lfloat tLagrangeDelay_getMaxDelay (tLagrangeDelay const dl); - Lfloat tLagrangeDelay_getLastOut (tLagrangeDelay const dl); - Lfloat tLagrangeDelay_getLastIn (tLagrangeDelay const dl); + } tLagrangeDelay; + + void tLagrangeDelay_init (tLagrangeDelay** const dl, Lfloat delay, uint32_t maxDelay, LEAF* const leaf); + void tLagrangeDelay_initToPool (tLagrangeDelay** const dl, Lfloat delay, uint32_t maxDelay, tMempool* const mp); + void tLagrangeDelay_free (tLagrangeDelay** const dl); + + Lfloat tLagrangeDelay_tick (tLagrangeDelay* const dl, Lfloat input); + void tLagrangeDelay_tickIn (tLagrangeDelay* const dl, Lfloat input); + Lfloat tLagrangeDelay_tickOut (tLagrangeDelay* const dl); + + void tLagrangeDelay_clear (tLagrangeDelay* const dl); + void tLagrangeDelay_setDelay (tLagrangeDelay* const dl, Lfloat delay); + Lfloat tLagrangeDelay_tapOut (tLagrangeDelay* const dl, uint32_t tapDelay); + Lfloat tLagrangeDelay_tapOutInterpolated (tLagrangeDelay* const dl, uint32_t tapDelay, Lfloat alpha); + void tLagrangeDelay_tapIn (tLagrangeDelay* const dl, Lfloat value, uint32_t tapDelay); + Lfloat tLagrangeDelay_addTo (tLagrangeDelay* const dl, Lfloat value, uint32_t tapDelay); + Lfloat tLagrangeDelay_getDelay (tLagrangeDelay* const dl); + Lfloat tLagrangeDelay_getMaxDelay (tLagrangeDelay* const dl); + Lfloat tLagrangeDelay_getLastOut (tLagrangeDelay* const dl); + Lfloat tLagrangeDelay_getLastIn (tLagrangeDelay* const dl); //============================================================================== @@ -622,7 +614,7 @@ extern "C" {  @} */ - typedef struct _tAllpassDelay + typedef struct tAllpassDelay { tMempool mempool; @@ -641,24 +633,22 @@ extern "C" { Lfloat apInput; - } _tAllpassDelay; - - typedef _tAllpassDelay* tAllpassDelay; - - void tAllpassDelay_init (tAllpassDelay* const, Lfloat delay, uint32_t maxDelay, LEAF* const leaf); - void tAllpassDelay_initToPool (tAllpassDelay* const, Lfloat delay, uint32_t maxDelay, tMempool* const); - void tAllpassDelay_free (tAllpassDelay* const); - - Lfloat tAllpassDelay_tick (tAllpassDelay const, Lfloat sample); - - void tAllpassDelay_clear (tAllpassDelay const); - void tAllpassDelay_setDelay (tAllpassDelay const, Lfloat delay); - Lfloat tAllpassDelay_getDelay (tAllpassDelay const); - void tAllpassDelay_tapIn (tAllpassDelay const, Lfloat in, uint32_t tapDelay); - Lfloat tAllpassDelay_tapOut (tAllpassDelay const, uint32_t tapDelay); - Lfloat tAllpassDelay_addTo (tAllpassDelay const, Lfloat value, uint32_t tapDelay); - Lfloat tAllpassDelay_getLastOut (tAllpassDelay const); - Lfloat tAllpassDelay_getLastIn (tAllpassDelay const); + } tAllpassDelay; + + void tAllpassDelay_init (tAllpassDelay** const, Lfloat delay, uint32_t maxDelay, LEAF* const leaf); + void tAllpassDelay_initToPool (tAllpassDelay** const, Lfloat delay, uint32_t maxDelay, tMempool* const); + void tAllpassDelay_free (tAllpassDelay** const); + + Lfloat tAllpassDelay_tick (tAllpassDelay* const, Lfloat sample); + + void tAllpassDelay_clear (tAllpassDelay* const); + void tAllpassDelay_setDelay (tAllpassDelay* const, Lfloat delay); + Lfloat tAllpassDelay_getDelay (tAllpassDelay* const); + void tAllpassDelay_tapIn (tAllpassDelay* const, Lfloat in, uint32_t tapDelay); + Lfloat tAllpassDelay_tapOut (tAllpassDelay* const, uint32_t tapDelay); + Lfloat tAllpassDelay_addTo (tAllpassDelay* const, Lfloat value, uint32_t tapDelay); + Lfloat tAllpassDelay_getLastOut (tAllpassDelay* const); + Lfloat tAllpassDelay_getLastIn (tAllpassDelay* const); //============================================================================== @@ -741,7 +731,7 @@ extern "C" {  @} */ - typedef struct _tTapeDelay + typedef struct tTapeDelay { tMempool mempool; @@ -758,25 +748,23 @@ extern "C" { Lfloat apInput; - } _tTapeDelay; - - typedef _tTapeDelay* tTapeDelay; - - void tTapeDelay_init (tTapeDelay* const, Lfloat delay, uint32_t maxDelay, LEAF* const leaf); - void tTapeDelay_initToPool (tTapeDelay* const, Lfloat delay, uint32_t maxDelay, tMempool* const); - void tTapeDelay_free (tTapeDelay* const); - - Lfloat tTapeDelay_tick (tTapeDelay const, Lfloat sample); - - void tTapeDelay_clear (tTapeDelay const); - void tTapeDelay_setDelay (tTapeDelay const, Lfloat delay); - Lfloat tTapeDelay_getDelay (tTapeDelay const); - void tTapeDelay_tapIn (tTapeDelay const, Lfloat in, uint32_t tapDelay); - Lfloat tTapeDelay_tapOut (tTapeDelay const d, Lfloat tapDelay); - Lfloat tTapeDelay_addTo (tTapeDelay const, Lfloat value, uint32_t tapDelay); - void tTapeDelay_incrementInPoint (tTapeDelay const dl); - Lfloat tTapeDelay_getLastOut (tTapeDelay const); - Lfloat tTapeDelay_getLastIn (tTapeDelay const); + } tTapeDelay; + + void tTapeDelay_init (tTapeDelay** const, Lfloat delay, uint32_t maxDelay, LEAF* const leaf); + void tTapeDelay_initToPool (tTapeDelay** const, Lfloat delay, uint32_t maxDelay, tMempool* const); + void tTapeDelay_free (tTapeDelay** const); + + Lfloat tTapeDelay_tick (tTapeDelay* const, Lfloat sample); + + void tTapeDelay_clear (tTapeDelay* const); + void tTapeDelay_setDelay (tTapeDelay* const, Lfloat delay); + Lfloat tTapeDelay_getDelay (tTapeDelay* const); + void tTapeDelay_tapIn (tTapeDelay* const, Lfloat in, uint32_t tapDelay); + Lfloat tTapeDelay_tapOut (tTapeDelay* const d, Lfloat tapDelay); + Lfloat tTapeDelay_addTo (tTapeDelay* const, Lfloat value, uint32_t tapDelay); + void tTapeDelay_incrementInPoint (tTapeDelay* const dl); + Lfloat tTapeDelay_getLastOut (tTapeDelay* const); + Lfloat tTapeDelay_getLastIn (tTapeDelay* const); //============================================================================== @@ -829,7 +817,7 @@ extern "C" { @return The size of the buffer.  @} */ - typedef struct _tRingBuffer + typedef struct tRingBuffer { tMempool mempool; @@ -838,19 +826,17 @@ extern "C" { unsigned int size; unsigned int pos; unsigned int mask; - } _tRingBuffer; - - typedef _tRingBuffer* tRingBuffer; - - void tRingBuffer_init (tRingBuffer* const ring, int size, LEAF* const leaf); - void tRingBuffer_initToPool (tRingBuffer* const ring, int size, tMempool* const mempool); - void tRingBuffer_free (tRingBuffer* const ring); + } tRingBuffer; + + void tRingBuffer_init (tRingBuffer** const ring, int size, LEAF* const leaf); + void tRingBuffer_initToPool (tRingBuffer** const ring, int size, tMempool* const mempool); + void tRingBuffer_free (tRingBuffer** const ring); - void tRingBuffer_push (tRingBuffer const ring, Lfloat val); - Lfloat tRingBuffer_getNewest (tRingBuffer const ring); - Lfloat tRingBuffer_getOldest (tRingBuffer const ring); - Lfloat tRingBuffer_get (tRingBuffer const ring, int index); - int tRingBuffer_getSize (tRingBuffer const ring); + void tRingBuffer_push (tRingBuffer* const ring, Lfloat val); + Lfloat tRingBuffer_getNewest (tRingBuffer* const ring); + Lfloat tRingBuffer_getOldest (tRingBuffer* const ring); + Lfloat tRingBuffer_get (tRingBuffer* const ring, int index); + int tRingBuffer_getSize (tRingBuffer* const ring); #ifdef __cplusplus } diff --git a/leaf/Inc/leaf-distortion.h b/leaf/Inc/leaf-distortion.h index 91eed7f..c558ae8 100644 --- a/leaf/Inc/leaf-distortion.h +++ b/leaf/Inc/leaf-distortion.h @@ -60,22 +60,20 @@ extern "C" {  @} */ - typedef struct _tSampleReducer + typedef struct tSampleReducer { tMempool mempool; Lfloat invRatio; Lfloat hold; uint32_t count; - } _tSampleReducer; - - typedef _tSampleReducer* tSampleReducer; - - void tSampleReducer_init (tSampleReducer* const, LEAF* const leaf); - void tSampleReducer_initToPool (tSampleReducer* const, tMempool* const); - void tSampleReducer_free (tSampleReducer* const); + } tSampleReducer; + + void tSampleReducer_init (tSampleReducer** const, LEAF* const leaf); + void tSampleReducer_initToPool (tSampleReducer** const, tMempool* const); + void tSampleReducer_free (tSampleReducer** const); - Lfloat tSampleReducer_tick (tSampleReducer const, Lfloat input); - void tSampleReducer_setRatio (tSampleReducer const, Lfloat ratio); + Lfloat tSampleReducer_tick (tSampleReducer* const, Lfloat input); + void tSampleReducer_setRatio (tSampleReducer* const, Lfloat ratio); //============================================================================== @@ -122,7 +120,7 @@ extern "C" {  @} */ - typedef struct _tOversampler + typedef struct tOversampler { tMempool mempool; uint32_t maxRatio; @@ -134,21 +132,19 @@ extern "C" { Lfloat* downState; uint32_t numTaps; uint32_t phaseLength; - } _tOversampler; - - typedef _tOversampler* tOversampler; - - void tOversampler_init (tOversampler* const, int order, int extraQuality, LEAF* const leaf); - void tOversampler_initToPool (tOversampler* const, int order, int extraQuality, tMempool* const); - void tOversampler_free (tOversampler* const); + } tOversampler; + + void tOversampler_init (tOversampler** const, int order, int extraQuality, LEAF* const leaf); + void tOversampler_initToPool (tOversampler** const, int order, int extraQuality, tMempool* const); + void tOversampler_free (tOversampler** const); - Lfloat tOversampler_tick (tOversampler const, Lfloat input, Lfloat* oversample, Lfloat (*effectTick)(Lfloat)); + Lfloat tOversampler_tick (tOversampler* const, Lfloat input, Lfloat* oversample, Lfloat (*effectTick)(Lfloat)); - void tOversampler_upsample (tOversampler const, Lfloat input, Lfloat* output); - Lfloat tOversampler_downsample (tOversampler const, Lfloat* input); - void tOversampler_setRatio (tOversampler const, int ratio); - void tOversampler_setQuality (tOversampler const, int quality); - int tOversampler_getLatency (tOversampler const); + void tOversampler_upsample (tOversampler* const, Lfloat input, Lfloat* output); + Lfloat tOversampler_downsample (tOversampler* const, Lfloat* input); + void tOversampler_setRatio (tOversampler* const, int ratio); + void tOversampler_setQuality (tOversampler* const, int quality); + int tOversampler_getLatency (tOversampler* const); //============================================================================== /*! @@ -177,7 +173,7 @@ extern "C" {  @} */ -typedef struct _tWavefolder +typedef struct tWavefolder { tMempool mempool; @@ -190,21 +186,19 @@ typedef struct _tWavefolder Lfloat invFBAmount; Lfloat FFAmount; tHighpass dcBlock; -} _tWavefolder; - -typedef _tWavefolder* tWavefolder; +} tWavefolder; -void tWavefolder_init (tWavefolder* const, Lfloat ffAmount, Lfloat fbAmount, Lfloat foldDepth, LEAF* const leaf); -void tWavefolder_initToPool (tWavefolder* const, Lfloat ffAmount, Lfloat fbAmount, Lfloat foldDepth, tMempool* const); -void tWavefolder_free (tWavefolder* const); +void tWavefolder_init (tWavefolder** const, Lfloat ffAmount, Lfloat fbAmount, Lfloat foldDepth, LEAF* const leaf); +void tWavefolder_initToPool (tWavefolder** const, Lfloat ffAmount, Lfloat fbAmount, Lfloat foldDepth, tMempool* const); +void tWavefolder_free (tWavefolder** const); -Lfloat tWavefolder_tick (tWavefolder const, Lfloat samp); +Lfloat tWavefolder_tick (tWavefolder* const, Lfloat samp); -void tWavefolder_setFFAmount (tWavefolder const wf, Lfloat ffAmount); -void tWavefolder_setFBAmount (tWavefolder const wf, Lfloat fbAmount); -void tWavefolder_setFoldDepth (tWavefolder const wf, Lfloat foldDepth); -void tWavefolder_setOffset (tWavefolder const wf, Lfloat offset); -void tWavefolder_setGain (tWavefolder const wf, Lfloat gain); +void tWavefolder_setFFAmount (tWavefolder* const wf, Lfloat ffAmount); +void tWavefolder_setFBAmount (tWavefolder* const wf, Lfloat fbAmount); +void tWavefolder_setFoldDepth (tWavefolder* const wf, Lfloat foldDepth); +void tWavefolder_setOffset (tWavefolder* const wf, Lfloat offset); +void tWavefolder_setGain (tWavefolder* const wf, Lfloat gain); //============================================================================== @@ -235,7 +229,7 @@ void tWavefolder_setGain (tWavefolder const wf, Lfloat gain);  @} */ - typedef struct _tLockhartWavefolder + typedef struct tLockhartWavefolder { tMempool mempool; @@ -265,15 +259,13 @@ void tWavefolder_setGain (tWavefolder const wf, Lfloat gain); double tempErrDenom; double tempOutDenom; - } _tLockhartWavefolder; - - typedef _tLockhartWavefolder* tLockhartWavefolder; - - void tLockhartWavefolder_init (tLockhartWavefolder* const, LEAF* const leaf); - void tLockhartWavefolder_initToPool (tLockhartWavefolder* const, tMempool* const); - void tLockhartWavefolder_free (tLockhartWavefolder* const); + } tLockhartWavefolder; + + void tLockhartWavefolder_init (tLockhartWavefolder** const, LEAF* const leaf); + void tLockhartWavefolder_initToPool (tLockhartWavefolder** const, tMempool* const); + void tLockhartWavefolder_free (tLockhartWavefolder** const); - Lfloat tLockhartWavefolder_tick (tLockhartWavefolder const, Lfloat samp); + Lfloat tLockhartWavefolder_tick (tLockhartWavefolder* const, Lfloat samp); //============================================================================== @@ -323,7 +315,7 @@ void tWavefolder_setGain (tWavefolder const wf, Lfloat gain);  @} */ - typedef struct _tCrusher + typedef struct tCrusher { tMempool mempool; @@ -337,20 +329,18 @@ void tWavefolder_setGain (tWavefolder const wf, Lfloat gain); Lfloat gain; tSampleReducer sReducer; - } _tCrusher; - - typedef _tCrusher* tCrusher; - - void tCrusher_init (tCrusher* const, LEAF* const leaf); - void tCrusher_initToPool (tCrusher* const, tMempool* const); - void tCrusher_free (tCrusher* const); + } tCrusher; + + void tCrusher_init (tCrusher** const, LEAF* const leaf); + void tCrusher_initToPool (tCrusher** const, tMempool* const); + void tCrusher_free (tCrusher** const); - Lfloat tCrusher_tick (tCrusher const, Lfloat input); + Lfloat tCrusher_tick (tCrusher* const, Lfloat input); - void tCrusher_setOperation (tCrusher const, Lfloat op); - void tCrusher_setQuality (tCrusher const, Lfloat val); - void tCrusher_setRound (tCrusher const, Lfloat rnd); - void tCrusher_setSamplingRatio (tCrusher const, Lfloat ratio); + void tCrusher_setOperation (tCrusher* const, Lfloat op); + void tCrusher_setQuality (tCrusher* const, Lfloat val); + void tCrusher_setRound (tCrusher* const, Lfloat rnd); + void tCrusher_setSamplingRatio (tCrusher* const, Lfloat ratio); //============================================================================== diff --git a/leaf/Inc/leaf-dynamics.h b/leaf/Inc/leaf-dynamics.h index fca1bf6..614fc4f 100644 --- a/leaf/Inc/leaf-dynamics.h +++ b/leaf/Inc/leaf-dynamics.h @@ -57,7 +57,7 @@ extern "C" { @} */ - typedef struct _tCompressor + typedef struct tCompressor { tMempool mempool; @@ -80,21 +80,19 @@ extern "C" { int atodbTableSizeMinus1; int dbtoaTableSizeMinus1; - } _tCompressor; - - typedef _tCompressor* tCompressor; - - void tCompressor_init (tCompressor* const, LEAF* const leaf); - void tCompressor_initToPool (tCompressor* const, tMempool* const); - void tCompressor_free (tCompressor* const); + } tCompressor; + + void tCompressor_init (tCompressor** const, LEAF* const leaf); + void tCompressor_initToPool (tCompressor** const, tMempool* const); + void tCompressor_free (tCompressor** const); - Lfloat tCompressor_tick (tCompressor const, Lfloat input); - Lfloat tCompressor_tickWithTable (tCompressor const comp, Lfloat in); - Lfloat tCompressor_tickWithTableHardKnee (tCompressor const comp, Lfloat in); + Lfloat tCompressor_tick (tCompressor* const, Lfloat input); + Lfloat tCompressor_tickWithTable (tCompressor* const comp, Lfloat in); + Lfloat tCompressor_tickWithTableHardKnee (tCompressor* const comp, Lfloat in); - void tCompressor_setTables (tCompressor const comp, Lfloat* atodb, Lfloat* dbtoa, Lfloat atodbMinIn, Lfloat atodbMaxIn, Lfloat dbtoaMinIn, Lfloat dbtoaMaxIn, int atodbTableSize, int dbtoaTableSize); - void tCompressor_setParams (tCompressor const comp, Lfloat thresh, Lfloat ratio, Lfloat knee, Lfloat makeup, Lfloat attack, Lfloat release); - void tCompressor_setSampleRate (tCompressor const comp, Lfloat sampleRate); + void tCompressor_setTables (tCompressor* const comp, Lfloat* atodb, Lfloat* dbtoa, Lfloat atodbMinIn, Lfloat atodbMaxIn, Lfloat dbtoaMinIn, Lfloat dbtoaMaxIn, int atodbTableSize, int dbtoaTableSize); + void tCompressor_setParams (tCompressor* const comp, Lfloat thresh, Lfloat ratio, Lfloat knee, Lfloat makeup, Lfloat attack, Lfloat release); + void tCompressor_setSampleRate (tCompressor* const comp, Lfloat sampleRate); /*! @defgroup tfeedbackleveler tFeedbackLeveler @@ -144,7 +142,7 @@ extern "C" { @} */ - typedef struct _tFeedbackLeveler + typedef struct tFeedbackLeveler { tMempool mempool; @@ -154,21 +152,19 @@ extern "C" { Lfloat curr; tPowerFollower pwrFlw; // internal power follower needed for level tracking - } _tFeedbackLeveler; - - typedef _tFeedbackLeveler* tFeedbackLeveler; - - void tFeedbackLeveler_init (tFeedbackLeveler* const, Lfloat targetLevel, Lfloat factor, Lfloat strength, int mode, LEAF* const leaf); - void tFeedbackLeveler_initToPool (tFeedbackLeveler* const, Lfloat targetLevel, Lfloat factor, Lfloat strength, int mode, tMempool* const); - void tFeedbackLeveler_free (tFeedbackLeveler* const); + } tFeedbackLeveler; + + void tFeedbackLeveler_init (tFeedbackLeveler** const, Lfloat targetLevel, Lfloat factor, Lfloat strength, int mode, LEAF* const leaf); + void tFeedbackLeveler_initToPool (tFeedbackLeveler** const, Lfloat targetLevel, Lfloat factor, Lfloat strength, int mode, tMempool* const); + void tFeedbackLeveler_free (tFeedbackLeveler** const); - Lfloat tFeedbackLeveler_tick (tFeedbackLeveler const, Lfloat input); + Lfloat tFeedbackLeveler_tick (tFeedbackLeveler* const, Lfloat input); - Lfloat tFeedbackLeveler_sample (tFeedbackLeveler const); - void tFeedbackLeveler_setTargetLevel (tFeedbackLeveler const, Lfloat TargetLevel); - void tFeedbackLeveler_setFactor (tFeedbackLeveler const, Lfloat factor); - void tFeedbackLeveler_setMode (tFeedbackLeveler const, int mode); // 0 for upwards limiting only, 1 for biderctional limiting - void tFeedbackLeveler_setStrength (tFeedbackLeveler const, Lfloat strength); + Lfloat tFeedbackLeveler_sample (tFeedbackLeveler* const); + void tFeedbackLeveler_setTargetLevel (tFeedbackLeveler* const, Lfloat TargetLevel); + void tFeedbackLeveler_setFactor (tFeedbackLeveler* const, Lfloat factor); + void tFeedbackLeveler_setMode (tFeedbackLeveler* const, int mode); // 0 for upwards limiting only, 1 for biderctional limiting + void tFeedbackLeveler_setStrength (tFeedbackLeveler* const, Lfloat strength); //============================================================================== @@ -207,25 +203,22 @@ extern "C" { @} */ - typedef struct _tThreshold + typedef struct tThreshold { tMempool mempool; Lfloat highThresh, lowThresh; int currentValue; - } _tThreshold; - - typedef _tThreshold* tThreshold; - - void tThreshold_init (tThreshold* const, Lfloat low, Lfloat high, LEAF* const leaf); - void tThreshold_initToPool (tThreshold* const, Lfloat low, Lfloat high, tMempool* const); - void tThreshold_free (tThreshold* const); + } tThreshold; - int tThreshold_tick (tThreshold const, Lfloat input); + void tThreshold_init (tThreshold** const, Lfloat low, Lfloat high, LEAF* const leaf); + void tThreshold_initToPool (tThreshold** const, Lfloat low, Lfloat high, tMempool* const); + void tThreshold_free (tThreshold** const); - void tThreshold_setLow (tThreshold const, Lfloat low); - void tThreshold_setHigh (tThreshold const, Lfloat high); + int tThreshold_tick (tThreshold* const, Lfloat input); + void tThreshold_setLow (tThreshold* const, Lfloat low); + void tThreshold_setHigh (tThreshold* const, Lfloat high); //////====================================================================== diff --git a/leaf/Inc/leaf-effects.h b/leaf/Inc/leaf-effects.h index 7841197..006ac29 100644 --- a/leaf/Inc/leaf-effects.h +++ b/leaf/Inc/leaf-effects.h @@ -92,7 +92,7 @@ extern "C" { #define NUM_TALKBOX_PARAM 4 - typedef struct _tTalkbox + typedef struct tTalkbox { tMempool mempool; @@ -120,24 +120,22 @@ extern "C" { Lfloat sampleRate; - } _tTalkbox; - - typedef _tTalkbox* tTalkbox; - - void tTalkbox_init (tTalkbox* const, int bufsize, LEAF* const leaf); - void tTalkbox_initToPool (tTalkbox* const, int bufsize, tMempool* const); - void tTalkbox_free (tTalkbox* const); + } tTalkbox; - Lfloat tTalkbox_tick (tTalkbox const, Lfloat synth, Lfloat voice); - Lfloat tTalkbox_tickFrozen (tTalkbox const voc, Lfloat synth, Lfloat voice); + void tTalkbox_init (tTalkbox** const, int bufsize, LEAF* const leaf); + void tTalkbox_initToPool (tTalkbox** const, int bufsize, tMempool* const); + void tTalkbox_free (tTalkbox** const); - void tTalkbox_update (tTalkbox const); - void tTalkbox_suspend (tTalkbox const); - void tTalkbox_setSampleRate (tTalkbox const voc, Lfloat sr); - void tTalkbox_setQuality (tTalkbox const, Lfloat quality); - void tTalkbox_setWarpFactor (tTalkbox const voc, Lfloat warp); - void tTalkbox_setWarpOn (tTalkbox const voc, Lfloat warpOn); - void tTalkbox_setFreeze (tTalkbox const voc, Lfloat freeze); + Lfloat tTalkbox_tick (tTalkbox* const, Lfloat synth, Lfloat voice); + Lfloat tTalkbox_tickFrozen (tTalkbox* const voc, Lfloat synth, Lfloat voice); + + void tTalkbox_update (tTalkbox* const); + void tTalkbox_suspend (tTalkbox* const); + void tTalkbox_setSampleRate (tTalkbox* const voc, Lfloat sr); + void tTalkbox_setQuality (tTalkbox* const, Lfloat quality); + void tTalkbox_setWarpFactor (tTalkbox* const voc, Lfloat warp); + void tTalkbox_setWarpOn (tTalkbox*const voc, Lfloat warpOn); + void tTalkbox_setFreeze (tTalkbox* const voc, Lfloat freeze); void tTalkbox_lpcDurbin (Lfloat *r, int p, Lfloat *k, Lfloat *g); void tTalkbox_lpc (Lfloat *buf, Lfloat *car, double* dl, double* Rt, int32_t n, int32_t o, Lfloat warp, int warpOn, Lfloat *k, int freeze, Lfloat *G); void tTalkbox_warpedAutocorrelate (Lfloat * x, double* dl, double* Rt, unsigned int L, Lfloat * R, unsigned int P, Lfloat lambda); @@ -212,7 +210,7 @@ extern "C" { @} */ - typedef struct _tTalkboxLfloat + typedef struct tTalkboxLfloat { tMempool mempool; @@ -240,24 +238,22 @@ extern "C" { Lfloat sampleRate; - } _tTalkboxLfloat; - - typedef _tTalkboxLfloat* tTalkboxLfloat; - - void tTalkboxLfloat_init (tTalkboxLfloat* const, int bufsize, LEAF* const leaf); - void tTalkboxLfloat_initToPool (tTalkboxLfloat* const, int bufsize, tMempool* const); - void tTalkboxLfloat_free (tTalkboxLfloat* const); + } tTalkboxLfloat; + + void tTalkboxLfloat_init (tTalkboxLfloat** const, int bufsize, LEAF* const leaf); + void tTalkboxLfloat_initToPool (tTalkboxLfloat** const, int bufsize, tMempool* const); + void tTalkboxLfloat_free (tTalkboxLfloat** const); - Lfloat tTalkboxLfloat_tick (tTalkboxLfloat const, Lfloat synth, Lfloat voice); - Lfloat tTalkboxLfloat_tickFrozen (tTalkboxLfloat const voc, Lfloat synth, Lfloat voice); + Lfloat tTalkboxLfloat_tick (tTalkboxLfloat* const, Lfloat synth, Lfloat voice); + Lfloat tTalkboxLfloat_tickFrozen (tTalkboxLfloat* const voc, Lfloat synth, Lfloat voice); - void tTalkboxLfloat_update (tTalkboxLfloat const); - void tTalkboxLfloat_suspend (tTalkboxLfloat const); - void tTalkboxLfloat_setQuality (tTalkboxLfloat const, Lfloat quality); - void tTalkboxLfloat_setWarpFactor (tTalkboxLfloat const voc, Lfloat warp); - void tTalkboxLfloat_setWarpOn (tTalkboxLfloat const voc, int warpOn); - void tTalkboxLfloat_setFreeze (tTalkboxLfloat const voc, int freeze); - void tTalkboxLfloat_setSampleRate (tTalkboxLfloat const voc, Lfloat sr); + void tTalkboxLfloat_update (tTalkboxLfloat* const); + void tTalkboxLfloat_suspend (tTalkboxLfloat* const); + void tTalkboxLfloat_setQuality (tTalkboxLfloat* const, Lfloat quality); + void tTalkboxLfloat_setWarpFactor (tTalkboxLfloat* const voc, Lfloat warp); + void tTalkboxLfloat_setWarpOn (tTalkboxLfloat* const voc, int warpOn); + void tTalkboxLfloat_setFreeze (tTalkboxLfloat* const voc, int freeze); + void tTalkboxLfloat_setSampleRate (tTalkboxLfloat* const voc, Lfloat sr); void tTalkboxLfloat_lpcDurbin (Lfloat *r, int p, Lfloat *k, Lfloat *g); void tTalkboxLfloat_lpc (Lfloat *buf, Lfloat *car, Lfloat* dl, Lfloat* Rt, int32_t n, int32_t o, Lfloat warp, int warpOn, Lfloat *k, int freeze, Lfloat *G); void tTalkboxLfloat_warpedAutocorrelate (Lfloat * x, Lfloat* dl, Lfloat* Rt, unsigned int L, Lfloat * R, unsigned int P, Lfloat lambda); @@ -302,7 +298,7 @@ extern "C" { #define NUM_VOCODER_PARAM 8 #define NBANDS 16 - typedef struct _tVocoder + typedef struct tVocoder { tMempool mempool; @@ -319,19 +315,17 @@ extern "C" { Lfloat f[NBANDS][13]; //[0-8][0 1 2 | 0 1 2 3 | 0 1 2 3 | val rate] Lfloat invSampleRate; - } _tVocoder; - - typedef _tVocoder* tVocoder; - - void tVocoder_init (tVocoder* const, LEAF* const leaf); - void tVocoder_initToPool (tVocoder* const, tMempool* const); - void tVocoder_free (tVocoder* const); + } tVocoder; + + void tVocoder_init (tVocoder** const, LEAF* const leaf); + void tVocoder_initToPool (tVocoder** const, tMempool* const); + void tVocoder_free (tVocoder** const); - Lfloat tVocoder_tick (tVocoder const, Lfloat synth, Lfloat voice); + Lfloat tVocoder_tick (tVocoder* const, Lfloat synth, Lfloat voice); - void tVocoder_update (tVocoder const); - void tVocoder_suspend (tVocoder const); - void tVocoder_setSampleRate (tVocoder const, Lfloat sr); + void tVocoder_update (tVocoder* const); + void tVocoder_suspend (tVocoder* const); + void tVocoder_setSampleRate (tVocoder* const, Lfloat sr); //============================================================================== @@ -381,7 +375,7 @@ extern "C" { @} */ - typedef struct _tRosenbergGlottalPulse + typedef struct tRosenbergGlottalPulse { tMempool mempool; @@ -392,22 +386,20 @@ extern "C" { Lfloat freq; Lfloat inc; Lfloat invSampleRate; - } _tRosenbergGlottalPulse; - - typedef _tRosenbergGlottalPulse* tRosenbergGlottalPulse; - - void tRosenbergGlottalPulse_init (tRosenbergGlottalPulse* const, LEAF* const leaf); - void tRosenbergGlottalPulse_initToPool (tRosenbergGlottalPulse* const, tMempool* const); - void tRosenbergGlottalPulse_free (tRosenbergGlottalPulse* const); + } tRosenbergGlottalPulse; - Lfloat tRosenbergGlottalPulse_tick (tRosenbergGlottalPulse const); - Lfloat tRosenbergGlottalPulse_tickHQ (tRosenbergGlottalPulse const gp); + void tRosenbergGlottalPulse_init (tRosenbergGlottalPulse** const, LEAF* const leaf); + void tRosenbergGlottalPulse_initToPool (tRosenbergGlottalPulse** const, tMempool* const); + void tRosenbergGlottalPulse_free (tRosenbergGlottalPulse** const); - void tRosenbergGlottalPulse_setFreq (tRosenbergGlottalPulse const, Lfloat freq); - void tRosenbergGlottalPulse_setOpenLength (tRosenbergGlottalPulse const, Lfloat openLength); - void tRosenbergGlottalPulse_setPulseLength (tRosenbergGlottalPulse const, Lfloat pulseLength); - void tRosenbergGlottalPulse_setOpenLengthAndPulseLength (tRosenbergGlottalPulse const, Lfloat openLength, Lfloat pulseLength); - void tRosenbergGlottalPulse_setSampleRate (tRosenbergGlottalPulse const, Lfloat sr); + Lfloat tRosenbergGlottalPulse_tick (tRosenbergGlottalPulse* const); + Lfloat tRosenbergGlottalPulse_tickHQ (tRosenbergGlottalPulse* const gp); + + void tRosenbergGlottalPulse_setFreq (tRosenbergGlottalPulse* const, Lfloat freq); + void tRosenbergGlottalPulse_setOpenLength (tRosenbergGlottalPulse* const, Lfloat openLength); + void tRosenbergGlottalPulse_setPulseLength (tRosenbergGlottalPulse* const, Lfloat pulseLength); + void tRosenbergGlottalPulse_setOpenLengthAndPulseLength (tRosenbergGlottalPulse* const, Lfloat openLength, Lfloat pulseLength); + void tRosenbergGlottalPulse_setSampleRate (tRosenbergGlottalPulse* const, Lfloat sr); //============================================================================== @@ -460,7 +452,7 @@ extern "C" { //#define MAXPERIOD (Lfloat)((LOOPSIZE - w->blocksize) * 0.8f) #define MINPERIOD 8.0f - typedef struct _tSOLAD + typedef struct tSOLAD { tMempool mempool; @@ -479,25 +471,23 @@ extern "C" { Lfloat* delaybuf; - } _tSOLAD; - - typedef _tSOLAD* tSOLAD; - - void tSOLAD_init (tSOLAD* const, int loopSize, LEAF* const leaf); - void tSOLAD_initToPool (tSOLAD* const, int loopSize, tMempool* const); - void tSOLAD_free (tSOLAD* const); + } tSOLAD; + + void tSOLAD_init (tSOLAD** const, int loopSize, LEAF* const leaf); + void tSOLAD_initToPool (tSOLAD** const, int loopSize, tMempool* const); + void tSOLAD_free (tSOLAD** const); // send one block of input samples, receive one block of output samples - void tSOLAD_ioSamples (tSOLAD w, Lfloat* in, Lfloat* out, int blocksize); + void tSOLAD_ioSamples (tSOLAD* w, Lfloat* in, Lfloat* out, int blocksize); // set periodicity analysis data - void tSOLAD_setPeriod (tSOLAD w, Lfloat period); + void tSOLAD_setPeriod (tSOLAD* w, Lfloat period); // set pitch factor between 0.25 and 4 - void tSOLAD_setPitchFactor (tSOLAD w, Lfloat pitchfactor); + void tSOLAD_setPitchFactor (tSOLAD* w, Lfloat pitchfactor); // force readpointer lag - void tSOLAD_setReadLag (tSOLAD w, Lfloat readlag); + void tSOLAD_setReadLag (tSOLAD* w, Lfloat readlag); // reset state variables - void tSOLAD_resetState (tSOLAD w); - void tSOLAD_setSampleRate (tSOLAD const, Lfloat sr); + void tSOLAD_resetState (tSOLAD* w); + void tSOLAD_setSampleRate (tSOLAD* const, Lfloat sr); /*! @defgroup tpitchshift tPitchShift @@ -537,7 +527,7 @@ extern "C" { @} */ - typedef struct _tPitchShift + typedef struct tPitchShift { tMempool mempool; @@ -552,18 +542,16 @@ extern "C" { Lfloat pickiness; Lfloat sampleRate; - } _tPitchShift; - - typedef _tPitchShift* tPitchShift; - - void tPitchShift_init (tPitchShift* const, tDualPitchDetector* const, int bufSize, LEAF* const leaf); - void tPitchShift_initToPool (tPitchShift* const, tDualPitchDetector* const, int bufSize, tMempool* const); - void tPitchShift_free (tPitchShift* const); + } tPitchShift; + + void tPitchShift_init (tPitchShift** const, tDualPitchDetector* const, int bufSize, LEAF* const leaf); + void tPitchShift_initToPool (tPitchShift** const, tDualPitchDetector* const, int bufSize, tMempool* const); + void tPitchShift_free (tPitchShift** const); - void tPitchShift_shiftBy (tPitchShift const, Lfloat factor, Lfloat* in, Lfloat* out); - void tPitchShift_shiftTo (tPitchShift const, Lfloat freq, Lfloat* in, Lfloat* out); - void tPitchShift_setPickiness (tPitchShift const, Lfloat p); - void tPitchShift_setSampleRate (tPitchShift const, Lfloat sr); + void tPitchShift_shiftBy (tPitchShift* const, Lfloat factor, Lfloat* in, Lfloat* out); + void tPitchShift_shiftTo (tPitchShift* const, Lfloat freq, Lfloat* in, Lfloat* out); + void tPitchShift_setPickiness (tPitchShift* const, Lfloat p); + void tPitchShift_setSampleRate (tPitchShift* const, Lfloat sr); /*! @defgroup tsimpleretune tSimpleRetune @@ -603,7 +591,7 @@ extern "C" { @} */ - typedef struct _tSimpleRetune + typedef struct tSimpleRetune { tMempool mempool; @@ -622,23 +610,21 @@ extern "C" { Lfloat* shiftValues; int numVoices; - } _tSimpleRetune; - - typedef _tSimpleRetune* tSimpleRetune; - - void tSimpleRetune_init (tSimpleRetune* const, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, LEAF* const leaf); - void tSimpleRetune_initToPool (tSimpleRetune* const, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, tMempool* const); - void tSimpleRetune_free (tSimpleRetune* const); + } tSimpleRetune; + + void tSimpleRetune_init (tSimpleRetune** const, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, LEAF* const leaf); + void tSimpleRetune_initToPool (tSimpleRetune** const, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, tMempool* const); + void tSimpleRetune_free (tSimpleRetune** const); - Lfloat tSimpleRetune_tick (tSimpleRetune const, Lfloat sample); + Lfloat tSimpleRetune_tick (tSimpleRetune* const, Lfloat sample); - void tSimpleRetune_setMode (tSimpleRetune const, int mode); - void tSimpleRetune_setNumVoices (tSimpleRetune const, int numVoices); - void tSimpleRetune_setPickiness (tSimpleRetune const, Lfloat p); - void tSimpleRetune_tuneVoices (tSimpleRetune const, Lfloat* t); - void tSimpleRetune_tuneVoice (tSimpleRetune const, int voice, Lfloat t); - Lfloat tSimpleRetune_getInputFrequency (tSimpleRetune const); - void tSimpleRetune_setSampleRate (tSimpleRetune const, Lfloat sr); + void tSimpleRetune_setMode (tSimpleRetune* const, int mode); + void tSimpleRetune_setNumVoices (tSimpleRetune* const, int numVoices); + void tSimpleRetune_setPickiness (tSimpleRetune* const, Lfloat p); + void tSimpleRetune_tuneVoices (tSimpleRetune* const, Lfloat* t); + void tSimpleRetune_tuneVoice (tSimpleRetune* const, int voice, Lfloat t); + Lfloat tSimpleRetune_getInputFrequency (tSimpleRetune* const); + void tSimpleRetune_setSampleRate (tSimpleRetune* const, Lfloat sr); /*! @defgroup tretune tRetune @@ -678,7 +664,7 @@ extern "C" { @} */ - typedef struct _tRetune + typedef struct tRetune { tMempool mempool; @@ -699,23 +685,21 @@ extern "C" { Lfloat* shiftValues; int numVoices; - } _tRetune; - - typedef _tRetune* tRetune; - - void tRetune_init (tRetune* const, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, LEAF* const leaf); - void tRetune_initToPool (tRetune* const, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, tMempool* const); - void tRetune_free (tRetune* const); + } tRetune; + + void tRetune_init (tRetune** const, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, LEAF* const leaf); + void tRetune_initToPool (tRetune** const, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, tMempool* const); + void tRetune_free (tRetune** const); - Lfloat* tRetune_tick (tRetune const, Lfloat sample); + Lfloat* tRetune_tick (tRetune* const, Lfloat sample); - void tRetune_setMode (tRetune const, int mode); - void tRetune_setNumVoices (tRetune const, int numVoices); - void tRetune_setPickiness (tRetune const, Lfloat p); - void tRetune_tuneVoices (tRetune const, Lfloat* t); - void tRetune_tuneVoice (tRetune const, int voice, Lfloat t); - Lfloat tRetune_getInputFrequency (tRetune const); - void tRetune_setSampleRate (tRetune const, Lfloat sr); + void tRetune_setMode (tRetune* const, int mode); + void tRetune_setNumVoices (tRetune* const, int numVoices); + void tRetune_setPickiness (tRetune* const, Lfloat p); + void tRetune_tuneVoices (tRetune* const, Lfloat* t); + void tRetune_tuneVoice (tRetune* const, int voice, Lfloat t); + Lfloat tRetune_getInputFrequency (tRetune* const); + void tRetune_setSampleRate (tRetune* const, Lfloat sr); //============================================================================== @@ -765,7 +749,7 @@ extern "C" { @} */ - typedef struct _tFormantShifter + typedef struct tFormantShifter { tMempool mempool; @@ -795,22 +779,20 @@ extern "C" { tFeedbackLeveler fbl2; Lfloat sampleRate; Lfloat invSampleRate; - } _tFormantShifter; - - typedef _tFormantShifter* tFormantShifter; - - void tFormantShifter_init (tFormantShifter* const, int order, LEAF* const leaf); - void tFormantShifter_initToPool (tFormantShifter* const, int order, tMempool* const); - void tFormantShifter_free (tFormantShifter* const); + } tFormantShifter; + + void tFormantShifter_init (tFormantShifter** const, int order, LEAF* const leaf); + void tFormantShifter_initToPool (tFormantShifter** const, int order, tMempool* const); + void tFormantShifter_free (tFormantShifter** const); - Lfloat tFormantShifter_tick (tFormantShifter const, Lfloat input); + Lfloat tFormantShifter_tick (tFormantShifter* const, Lfloat input); - Lfloat tFormantShifter_remove (tFormantShifter const, Lfloat input); - Lfloat tFormantShifter_add (tFormantShifter const, Lfloat input); - void tFormantShifter_ioSamples (tFormantShifter const, Lfloat* in, Lfloat* out, int size, Lfloat fwarp); - void tFormantShifter_setShiftFactor (tFormantShifter const, Lfloat shiftFactor); - void tFormantShifter_setIntensity (tFormantShifter const, Lfloat intensity); - void tFormantShifter_setSampleRate (tFormantShifter const fsr, Lfloat sr); + Lfloat tFormantShifter_remove (tFormantShifter* const, Lfloat input); + Lfloat tFormantShifter_add (tFormantShifter* const, Lfloat input); + void tFormantShifter_ioSamples (tFormantShifter* const, Lfloat* in, Lfloat* out, int size, Lfloat fwarp); + void tFormantShifter_setShiftFactor (tFormantShifter* const, Lfloat shiftFactor); + void tFormantShifter_setIntensity (tFormantShifter* const, Lfloat intensity); + void tFormantShifter_setSampleRate (tFormantShifter* const fsr, Lfloat sr); //============================================================================== diff --git a/leaf/Inc/leaf-electrical.h b/leaf/Inc/leaf-electrical.h index 38c652a..9609030 100644 --- a/leaf/Inc/leaf-electrical.h +++ b/leaf/Inc/leaf-electrical.h @@ -106,9 +106,8 @@ extern "C" { WDFComponentNil } WDFComponentType; - typedef struct _tWDF _tWDF; // needed to allow tWDF pointers in struct - typedef _tWDF* tWDF; - struct _tWDF + typedef struct tWDF tWDF; // needed to allow tWDF pointers in struct + struct tWDF { tMempool mempool; diff --git a/leaf/Inc/leaf-envelopes.h b/leaf/Inc/leaf-envelopes.h index c3a5798..df34e6a 100644 --- a/leaf/Inc/leaf-envelopes.h +++ b/leaf/Inc/leaf-envelopes.h @@ -76,7 +76,7 @@ extern "C" { @} */ - typedef struct _tEnvelope + typedef struct tEnvelope { tMempool mempool; @@ -97,20 +97,18 @@ extern "C" { Lfloat attackPhase, decayPhase, rampPhase; - } _tEnvelope; - - typedef _tEnvelope* tEnvelope; - - void tEnvelope_init (tEnvelope* const, Lfloat attack, Lfloat decay, int loop, LEAF* const leaf); - void tEnvelope_initToPool (tEnvelope* const, Lfloat attack, Lfloat decay, int loop, tMempool* const); - void tEnvelope_free (tEnvelope* const); + } tEnvelope; + + void tEnvelope_init (tEnvelope** const, Lfloat attack, Lfloat decay, int loop, LEAF* const leaf); + void tEnvelope_initToPool (tEnvelope** const, Lfloat attack, Lfloat decay, int loop, tMempool* const); + void tEnvelope_free (tEnvelope** const); - Lfloat tEnvelope_tick (tEnvelope const); + Lfloat tEnvelope_tick (tEnvelope* const); - void tEnvelope_setAttack (tEnvelope const, Lfloat attack); - void tEnvelope_setDecay (tEnvelope const, Lfloat decay); - void tEnvelope_loop (tEnvelope const, int loop); - void tEnvelope_on (tEnvelope const, Lfloat velocity); + void tEnvelope_setAttack (tEnvelope* const, Lfloat attack); + void tEnvelope_setDecay (tEnvelope* const, Lfloat decay); + void tEnvelope_loop (tEnvelope* const, int loop); + void tEnvelope_on (tEnvelope* const, Lfloat velocity); // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ @@ -161,20 +159,18 @@ extern "C" { @} */ - typedef struct _tExpSmooth + typedef struct tExpSmooth { tMempool mempool; Lfloat factor, oneminusfactor; Lfloat curr,dest; //Lfloat invSampleRate; - } _tExpSmooth; - - typedef _tExpSmooth* tExpSmooth; - - void tExpSmooth_init (tExpSmooth* const, Lfloat val, Lfloat factor, LEAF* const leaf); - void tExpSmooth_initToPool (tExpSmooth* const, Lfloat val, Lfloat factor, tMempool* const); - void tExpSmooth_free (tExpSmooth* const); + } tExpSmooth; + + void tExpSmooth_init (tExpSmooth** const, Lfloat val, Lfloat factor, LEAF* const leaf); + void tExpSmooth_initToPool (tExpSmooth** const, Lfloat val, Lfloat factor, tMempool* const); + void tExpSmooth_free (tExpSmooth** const); #ifdef ITCMRAM @@ -255,7 +251,7 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); @} */ /* ADSR */ - typedef struct _tADSR + typedef struct tADSR { tMempool mempool; @@ -279,23 +275,21 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); Lfloat baseLeakFactor, leakFactor; Lfloat invSampleRate; - } _tADSR; - - typedef _tADSR* tADSR; - - void tADSR_init (tADSR* const adsrenv, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, LEAF* const leaf); - void tADSR_initToPool (tADSR* const adsrenv, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, tMempool* const mp); - void tADSR_free (tADSR* const); - - Lfloat tADSR_tick (tADSR const); - void tADSR_setAttack (tADSR const, Lfloat attack); - void tADSR_setDecay (tADSR const, Lfloat decay); - void tADSR_setSustain (tADSR const, Lfloat sustain); - void tADSR_setRelease (tADSR const, Lfloat release); - void tADSR_setLeakFactor (tADSR const, Lfloat leakFactor); - void tADSR_on (tADSR const, Lfloat velocity); - void tADSR_off (tADSR const); - void tADSR_setSampleRate (tADSR const, Lfloat sr); + } tADSR; + + void tADSR_init (tADSR** const adsrenv, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, LEAF* const leaf); + void tADSR_initToPool (tADSR** const adsrenv, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, tMempool* const mp); + void tADSR_free (tADSR** const); + + Lfloat tADSR_tick (tADSR* const); + void tADSR_setAttack (tADSR* const, Lfloat attack); + void tADSR_setDecay (tADSR* const, Lfloat decay); + void tADSR_setSustain (tADSR* const, Lfloat sustain); + void tADSR_setRelease (tADSR* const, Lfloat release); + void tADSR_setLeakFactor (tADSR* const, Lfloat leakFactor); + void tADSR_on (tADSR* const, Lfloat velocity); + void tADSR_off (tADSR* const); + void tADSR_setSampleRate (tADSR* const, Lfloat sr); // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ @@ -357,7 +351,7 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); @} */ - typedef struct _tADSRT + typedef struct tADSRT { tMempool mempool; @@ -381,25 +375,23 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); Lfloat baseLeakFactor, leakFactor; Lfloat invSampleRate; - } _tADSRT; - - typedef _tADSRT* tADSRT; - - void tADSRT_init (tADSRT* const, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, Lfloat* expBuffer, int bufferSize, LEAF* const leaf); - void tADSRT_initToPool (tADSRT* const, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, Lfloat* expBuffer, int bufferSize, tMempool* const); - void tADSRT_free (tADSRT* const); - - Lfloat tADSRT_tick (tADSRT const); - Lfloat tADSRT_tickNoInterp (tADSRT const adsrenv); - void tADSRT_setAttack (tADSRT const, Lfloat attack); - void tADSRT_setDecay (tADSRT const, Lfloat decay); - void tADSRT_setSustain (tADSRT const, Lfloat sustain); - void tADSRT_setRelease (tADSRT const, Lfloat release); - void tADSRT_setLeakFactor (tADSRT const, Lfloat leakFactor); - void tADSRT_on (tADSRT const, Lfloat velocity); - void tADSRT_off (tADSRT const); - void tADSRT_clear (tADSRT const adsrenv); - void tADSRT_setSampleRate (tADSRT const, Lfloat sr); + } tADSRT; + + void tADSRT_init (tADSRT** const, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, Lfloat* expBuffer, int bufferSize, LEAF* const leaf); + void tADSRT_initToPool (tADSRT** const, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, Lfloat* expBuffer, int bufferSize, tMempool* const); + void tADSRT_free (tADSRT** const); + + Lfloat tADSRT_tick (tADSRT* const); + Lfloat tADSRT_tickNoInterp (tADSRT* const adsrenv); + void tADSRT_setAttack (tADSRT* const, Lfloat attack); + void tADSRT_setDecay (tADSRT* const, Lfloat decay); + void tADSRT_setSustain (tADSRT* const, Lfloat sustain); + void tADSRT_setRelease (tADSRT* const, Lfloat release); + void tADSRT_setLeakFactor (tADSRT* const, Lfloat leakFactor); + void tADSRT_on (tADSRT* const, Lfloat velocity); + void tADSRT_off (tADSRT* const); + void tADSRT_clear (tADSRT* const adsrenv); + void tADSRT_setSampleRate (tADSRT* const, Lfloat sr); // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ @@ -466,7 +458,7 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); env_ramp }; - typedef struct _tADSRS + typedef struct tADSRS { tMempool mempool; @@ -495,23 +487,21 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); Lfloat oneMinusFactor; Lfloat gain; Lfloat invSampleRate; - } _tADSRS; - - typedef _tADSRS* tADSRS; - - void tADSRS_init (tADSRS* const, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, LEAF* const leaf); - void tADSRS_initToPool (tADSRS* const, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, tMempool* const); - void tADSRS_free (tADSRS* const); - - Lfloat tADSRS_tick (tADSRS const); - void tADSRS_setAttack (tADSRS const, Lfloat attack); - void tADSRS_setDecay (tADSRS const, Lfloat decay); - void tADSRS_setSustain (tADSRS const, Lfloat sustain); - void tADSRS_setRelease (tADSRS const, Lfloat release); - void tADSRS_setLeakFactor (tADSRS const, Lfloat leakFactor); - void tADSRS_on (tADSRS const, Lfloat velocity); - void tADSRS_off (tADSRS const); - void tADSRS_setSampleRate (tADSRS const, Lfloat sr); + } tADSRS; + + void tADSRS_init (tADSRS** const, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, LEAF* const leaf); + void tADSRS_initToPool (tADSRS** const, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, tMempool* const); + void tADSRS_free (tADSRS** const); + + Lfloat tADSRS_tick (tADSRS* const); + void tADSRS_setAttack (tADSRS* const, Lfloat attack); + void tADSRS_setDecay (tADSRS* const, Lfloat decay); + void tADSRS_setSustain (tADSRS* const, Lfloat sustain); + void tADSRS_setRelease (tADSRS* const, Lfloat release); + void tADSRS_setLeakFactor (tADSRS* const, Lfloat leakFactor); + void tADSRS_on (tADSRS* const, Lfloat velocity); + void tADSRS_off (tADSRS* const); + void tADSRS_setSampleRate (tADSRS* const, Lfloat sr); // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ @@ -557,7 +547,7 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); @} */ - typedef struct _tRamp + typedef struct tRamp { tMempool mempool; Lfloat inc; @@ -568,20 +558,18 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); Lfloat time; Lfloat factor; int samples_per_tick; - } _tRamp; - - typedef _tRamp* tRamp; - - void tRamp_init (tRamp* const, Lfloat time, int samplesPerTick, LEAF* const leaf); - void tRamp_initToPool (tRamp* const, Lfloat time, int samplesPerTick, tMempool* const); - void tRamp_free (tRamp* const); + } tRamp; + + void tRamp_init (tRamp** const, Lfloat time, int samplesPerTick, LEAF* const leaf); + void tRamp_initToPool (tRamp** const, Lfloat time, int samplesPerTick, tMempool* const); + void tRamp_free (tRamp** const); - Lfloat tRamp_tick (tRamp const); - Lfloat tRamp_sample (tRamp const); - void tRamp_setTime (tRamp const, Lfloat time); - void tRamp_setDest (tRamp const, Lfloat dest); - void tRamp_setVal (tRamp const, Lfloat val); - void tRamp_setSampleRate (tRamp const, Lfloat sr); + Lfloat tRamp_tick (tRamp* const); + Lfloat tRamp_sample (tRamp* const); + void tRamp_setTime (tRamp* const, Lfloat time); + void tRamp_setDest (tRamp* const, Lfloat dest); + void tRamp_setVal (tRamp* const, Lfloat val); + void tRamp_setSampleRate (tRamp* const, Lfloat sr); /*! @defgroup trampupdown tRampUpDown @@ -629,7 +617,7 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); @} */ - typedef struct _tRampUpDown + typedef struct tRampUpDown { tMempool mempool; Lfloat upInc; @@ -641,21 +629,19 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); Lfloat upTime; Lfloat downTime; int samples_per_tick; - } _tRampUpDown; - - typedef _tRampUpDown* tRampUpDown; - - void tRampUpDown_init (tRampUpDown* const, Lfloat upTime, Lfloat downTime, int samplesPerTick, LEAF* const leaf); - void tRampUpDown_initToPool (tRampUpDown* const, Lfloat upTime, Lfloat downTime, int samplesPerTick, tMempool* const); - void tRampUpDown_free (tRampUpDown* const); - - Lfloat tRampUpDown_tick (tRampUpDown const); - Lfloat tRampUpDown_sample (tRampUpDown const); - void tRampUpDown_setUpTime (tRampUpDown const, Lfloat upTime); - void tRampUpDown_setDownTime (tRampUpDown const, Lfloat downTime); - void tRampUpDown_setDest (tRampUpDown const, Lfloat dest); - void tRampUpDown_setVal (tRampUpDown const, Lfloat val); - void tRampUpDown_setSampleRate (tRampUpDown const, Lfloat sr); + } tRampUpDown; + + void tRampUpDown_init (tRampUpDown** const, Lfloat upTime, Lfloat downTime, int samplesPerTick, LEAF* const leaf); + void tRampUpDown_initToPool (tRampUpDown** const, Lfloat upTime, Lfloat downTime, int samplesPerTick, tMempool* const); + void tRampUpDown_free (tRampUpDown** const); + + Lfloat tRampUpDown_tick (tRampUpDown* const); + Lfloat tRampUpDown_sample (tRampUpDown* const); + void tRampUpDown_setUpTime (tRampUpDown* const, Lfloat upTime); + void tRampUpDown_setDownTime (tRampUpDown* const, Lfloat downTime); + void tRampUpDown_setDest (tRampUpDown* const, Lfloat dest); + void tRampUpDown_setVal (tRampUpDown* const, Lfloat val); + void tRampUpDown_setSampleRate (tRampUpDown* const, Lfloat sr); /*! @defgroup tslide tSlide @@ -699,7 +685,7 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); @} */ - typedef struct _tSlide + typedef struct tSlide { tMempool mempool; Lfloat prevOut; @@ -708,19 +694,17 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); Lfloat invUpSlide; Lfloat invDownSlide; Lfloat dest; - } _tSlide; - - typedef _tSlide* tSlide; - - void tSlide_init (tSlide* const, Lfloat upSlide, Lfloat downSlide, LEAF* const leaf); - void tSlide_initToPool (tSlide* const, Lfloat upSlide, Lfloat downSlide, tMempool* const); - void tSlide_free (tSlide* const); - - Lfloat tSlide_tick (tSlide const, Lfloat in); - Lfloat tSlide_tickNoInput (tSlide const sl); - void tSlide_setUpSlide (tSlide const sl, Lfloat upSlide); - void tSlide_setDownSlide (tSlide const sl, Lfloat downSlide); - void tSlide_setDest (tSlide const sl, Lfloat dest); + } tSlide; + + void tSlide_init (tSlide** const, Lfloat upSlide, Lfloat downSlide, LEAF* const leaf); + void tSlide_initToPool (tSlide** const, Lfloat upSlide, Lfloat downSlide, tMempool* const); + void tSlide_free (tSlide** const); + + Lfloat tSlide_tick (tSlide* const, Lfloat in); + Lfloat tSlide_tickNoInput (tSlide* const sl); + void tSlide_setUpSlide (tSlide* const sl, Lfloat upSlide); + void tSlide_setDownSlide (tSlide* const sl, Lfloat downSlide); + void tSlide_setDest (tSlide* const sl, Lfloat dest); #ifdef __cplusplus } diff --git a/leaf/Inc/leaf-filters.h b/leaf/Inc/leaf-filters.h index a708b3d..9a1b541 100644 --- a/leaf/Inc/leaf-filters.h +++ b/leaf/Inc/leaf-filters.h @@ -64,7 +64,7 @@ extern "C" {  @} */ - typedef struct _tAllpass + typedef struct tAllpass { tMempool mempool; @@ -74,21 +74,19 @@ extern "C" { tLinearDelay delay; Lfloat lastOut; - } _tAllpass; - - typedef _tAllpass* tAllpass; + } tAllpass; // Memory handlers for `tAllpass` - void tAllpass_init (tAllpass* const, Lfloat initDelay, uint32_t maxDelay, LEAF* const leaf); - void tAllpass_initToPool (tAllpass* const, Lfloat initDelay, uint32_t maxDelay, tMempool* const); - void tAllpass_free (tAllpass* const); + void tAllpass_init (tAllpass** const, Lfloat initDelay, uint32_t maxDelay, LEAF* const leaf); + void tAllpass_initToPool (tAllpass** const, Lfloat initDelay, uint32_t maxDelay, tMempool* const); + void tAllpass_free (tAllpass** const); // Tick function for `tAllpass` - Lfloat tAllpass_tick (tAllpass const, Lfloat input); + Lfloat tAllpass_tick (tAllpass* const, Lfloat input); // Setter functions for `tAllpass` - void tAllpass_setGain (tAllpass const, Lfloat gain); - void tAllpass_setDelay (tAllpass const, Lfloat delay); + void tAllpass_setGain (tAllpass* const, Lfloat gain); + void tAllpass_setDelay (tAllpass* const, Lfloat delay); //============================================================================== @@ -126,7 +124,7 @@ extern "C" {  @} */ - typedef struct _tAllpassSO + typedef struct tAllpassSO { tMempool mempool; @@ -138,24 +136,22 @@ extern "C" { Lfloat a1; Lfloat a2; - } _tAllpassSO; - - typedef _tAllpassSO* tAllpassSO; + } tAllpassSO; // Memory handlers for `tAllpassSO` - void tAllpassSO_init (tAllpassSO* const, LEAF* const leaf); - void tAllpassSO_initToPool (tAllpassSO* const, tMempool* const); - void tAllpassSO_free (tAllpassSO* const); + void tAllpassSO_init (tAllpassSO** const, LEAF* const leaf); + void tAllpassSO_initToPool (tAllpassSO** const, tMempool* const); + void tAllpassSO_free (tAllpassSO** const); // Tick function for `tAllpassSO` - Lfloat tAllpassSO_tick (tAllpassSO const, Lfloat input); + Lfloat tAllpassSO_tick (tAllpassSO* const, Lfloat input); // Setter functions for `tAllpassSO` - void tAllpassSO_setCoeff (tAllpassSO const ft, Lfloat a1, Lfloat a2); + void tAllpassSO_setCoeff (tAllpassSO* const ft, Lfloat a1, Lfloat a2); //============================================================================== - typedef struct _tThiranAllpassSOCascade + typedef struct tThiranAllpassSOCascade { tMempool mempool; @@ -175,21 +171,19 @@ extern "C" { int numFiltsMap[2]; int isHigh; Lfloat D; - } _tThiranAllpassSOCascade; - - typedef _tThiranAllpassSOCascade* tThiranAllpassSOCascade; + } tThiranAllpassSOCascade; // Memory handlers for `tThiranAllpassSOCascade` - void tThiranAllpassSOCascade_init (tThiranAllpassSOCascade* const, int order, LEAF* const leaf); - void tThiranAllpassSOCascade_initToPool (tThiranAllpassSOCascade* const, int order, tMempool* const); - void tThiranAllpassSOCascade_free (tThiranAllpassSOCascade* const); + void tThiranAllpassSOCascade_init (tThiranAllpassSOCascade** const, int order, LEAF* const leaf); + void tThiranAllpassSOCascade_initToPool (tThiranAllpassSOCascade** const, int order, tMempool* const); + void tThiranAllpassSOCascade_free (tThiranAllpassSOCascade** const); // Tick function for `tThiranAllpassSOCascade` - Lfloat tThiranAllpassSOCascade_tick (tThiranAllpassSOCascade const, Lfloat input); + Lfloat tThiranAllpassSOCascade_tick (tThiranAllpassSOCascade* const, Lfloat input); // Setter functions for `tThiranAllpassSOCascade` - Lfloat tThiranAllpassSOCascade_setCoeff (tThiranAllpassSOCascade const ft, Lfloat dispersionCoeff, Lfloat freq, Lfloat invOversampling); - void tThiranAllpassSOCascade_clear (tThiranAllpassSOCascade const ft); + Lfloat tThiranAllpassSOCascade_setCoeff (tThiranAllpassSOCascade* const ft, Lfloat dispersionCoeff, Lfloat freq, Lfloat invOversampling); + void tThiranAllpassSOCascade_clear (tThiranAllpassSOCascade* const ft); //============================================================================== /*! @@ -242,7 +236,7 @@ extern "C" {  @} */ - typedef struct _tOnePole + typedef struct tOnePole { tMempool mempool; @@ -252,26 +246,24 @@ extern "C" { Lfloat b0,b1; Lfloat lastIn, lastOut; Lfloat twoPiTimesInvSampleRate; - } _tOnePole; - - typedef _tOnePole* tOnePole; + } tOnePole; // Memory handlers for `tOnePole` - void tOnePole_init (tOnePole* const, Lfloat freq, LEAF* const leaf); - void tOnePole_initToPool (tOnePole* const, Lfloat freq, tMempool* const); - void tOnePole_free (tOnePole* const); + void tOnePole_init (tOnePole** const, Lfloat freq, LEAF* const leaf); + void tOnePole_initToPool (tOnePole** const, Lfloat freq, tMempool* const); + void tOnePole_free (tOnePole** const); // Tick function for `tOnePole` - Lfloat tOnePole_tick (tOnePole const, Lfloat input); + Lfloat tOnePole_tick (tOnePole* const, Lfloat input); // Setter functions for `tOnePole` - void tOnePole_setB0 (tOnePole const, Lfloat b0); - void tOnePole_setA1 (tOnePole const, Lfloat a1); - void tOnePole_setPole (tOnePole const, Lfloat thePole); - void tOnePole_setFreq (tOnePole const, Lfloat freq); - void tOnePole_setCoefficients (tOnePole const, Lfloat b0, Lfloat a1); - void tOnePole_setGain (tOnePole const, Lfloat gain); - void tOnePole_setSampleRate (tOnePole const, Lfloat sr); + void tOnePole_setB0 (tOnePole* const, Lfloat b0); + void tOnePole_setA1 (tOnePole* const, Lfloat a1); + void tOnePole_setPole (tOnePole* const, Lfloat thePole); + void tOnePole_setFreq (tOnePole* const, Lfloat freq); + void tOnePole_setCoefficients (tOnePole* const, Lfloat b0, Lfloat a1); + void tOnePole_setGain (tOnePole* const, Lfloat gain); + void tOnePole_setSampleRate (tOnePole* const, Lfloat sr); //============================================================================== @@ -325,30 +317,28 @@ extern "C" {  @} */ - typedef struct _tCookOnePole + typedef struct tCookOnePole { tMempool mempool; Lfloat poleCoeff, sgain, output; Lfloat twoPiTimesInvSampleRate; Lfloat gain; - } _tCookOnePole; - - typedef _tCookOnePole* tCookOnePole; + } tCookOnePole; // Memory handlers for `tCookOnePole` - void tCookOnePole_init (tCookOnePole* const, LEAF* const leaf); - void tCookOnePole_initToPool (tCookOnePole* const, tMempool* const); - void tCookOnePole_free (tCookOnePole* const); + void tCookOnePole_init (tCookOnePole** const, LEAF* const leaf); + void tCookOnePole_initToPool (tCookOnePole** const, tMempool* const); + void tCookOnePole_free (tCookOnePole** const); // Tick function for `tCookOnePole` - Lfloat tCookOnePole_tick (tCookOnePole const, Lfloat input); + Lfloat tCookOnePole_tick (tCookOnePole* const, Lfloat input); // Setter functions for `tCookOnePole` - void tCookOnePole_setPole (tCookOnePole const, Lfloat thePole); - void tCookOnePole_setGain (tCookOnePole const, Lfloat gain); - void tCookOnePole_setGainAndPole (tCookOnePole const ft, Lfloat gain, Lfloat pole); - void tCookOnePole_setSampleRate (tCookOnePole const, Lfloat sr); + void tCookOnePole_setPole (tCookOnePole* const, Lfloat thePole); + void tCookOnePole_setGain (tCookOnePole* const, Lfloat gain); + void tCookOnePole_setGainAndPole (tCookOnePole* const ft, Lfloat gain, Lfloat pole); + void tCookOnePole_setSampleRate (tCookOnePole* const, Lfloat sr); //============================================================================== @@ -402,7 +392,7 @@ extern "C" {  @} */ - typedef struct _tTwoPole + typedef struct tTwoPole { tMempool mempool; @@ -418,26 +408,24 @@ extern "C" { Lfloat sampleRate; Lfloat twoPiTimesInvSampleRate; - } _tTwoPole; - - typedef _tTwoPole* tTwoPole; + } tTwoPole; // Memory handlers for `tTwoPole` - void tTwoPole_init (tTwoPole* const, LEAF* const leaf); - void tTwoPole_initToPool (tTwoPole* const, tMempool* const); - void tTwoPole_free (tTwoPole* const); + void tTwoPole_init (tTwoPole** const, LEAF* const leaf); + void tTwoPole_initToPool (tTwoPole** const, tMempool* const); + void tTwoPole_free (tTwoPole** const); // Tick function for `tTwoPole` - Lfloat tTwoPole_tick (tTwoPole const, Lfloat input); + Lfloat tTwoPole_tick (tTwoPole* const, Lfloat input); // Setter functions for `tTwoPole` - void tTwoPole_setB0 (tTwoPole const, Lfloat b0); - void tTwoPole_setA1 (tTwoPole const, Lfloat a1); - void tTwoPole_setA2 (tTwoPole const, Lfloat a2); - void tTwoPole_setResonance (tTwoPole const, Lfloat freq, Lfloat radius, int normalize); - void tTwoPole_setCoefficients (tTwoPole const, Lfloat b0, Lfloat a1, Lfloat a2); - void tTwoPole_setGain (tTwoPole const, Lfloat gain); - void tTwoPole_setSampleRate (tTwoPole const, Lfloat sr); + void tTwoPole_setB0 (tTwoPole* const, Lfloat b0); + void tTwoPole_setA1 (tTwoPole* const, Lfloat a1); + void tTwoPole_setA2 (tTwoPole* const, Lfloat a2); + void tTwoPole_setResonance (tTwoPole* const, Lfloat freq, Lfloat radius, int normalize); + void tTwoPole_setCoefficients (tTwoPole* const, Lfloat b0, Lfloat a1, Lfloat a2); + void tTwoPole_setGain (tTwoPole* const, Lfloat gain); + void tTwoPole_setSampleRate (tTwoPole* const, Lfloat sr); //============================================================================== @@ -491,33 +479,31 @@ extern "C" {  @} */ - typedef struct _tOneZero + typedef struct tOneZero { tMempool mempool; Lfloat gain; Lfloat b0,b1; Lfloat lastIn, lastOut, frequency; Lfloat invSampleRate; - } _tOneZero; - - typedef _tOneZero* tOneZero; + } tOneZero; // Memory handlers for `tOneZero` - void tOneZero_init (tOneZero* const, Lfloat theZero, LEAF* const leaf); - void tOneZero_initToPool (tOneZero* const, Lfloat theZero, tMempool* const); - void tOneZero_free (tOneZero* const); + void tOneZero_init (tOneZero** const, Lfloat theZero, LEAF* const leaf); + void tOneZero_initToPool (tOneZero** const, Lfloat theZero, tMempool* const); + void tOneZero_free (tOneZero** const); // Tick function for `tOneZero` - Lfloat tOneZero_tick (tOneZero const, Lfloat input); + Lfloat tOneZero_tick (tOneZero* const, Lfloat input); // Setter functions for `tOneZero` - void tOneZero_setB0 (tOneZero const, Lfloat b0); - void tOneZero_setB1 (tOneZero const, Lfloat b1); - void tOneZero_setZero (tOneZero const, Lfloat theZero); - void tOneZero_setCoefficients (tOneZero const, Lfloat b0, Lfloat b1); - void tOneZero_setGain (tOneZero const, Lfloat gain); - Lfloat tOneZero_getPhaseDelay (tOneZero const, Lfloat frequency); - void tOneZero_setSampleRate (tOneZero const, Lfloat sr); + void tOneZero_setB0 (tOneZero* const, Lfloat b0); + void tOneZero_setB1 (tOneZero* const, Lfloat b1); + void tOneZero_setZero (tOneZero* const, Lfloat theZero); + void tOneZero_setCoefficients (tOneZero* const, Lfloat b0, Lfloat b1); + void tOneZero_setGain (tOneZero* const, Lfloat gain); + Lfloat tOneZero_getPhaseDelay (tOneZero* const, Lfloat frequency); + void tOneZero_setSampleRate (tOneZero* const, Lfloat sr); //============================================================================== @@ -572,7 +558,7 @@ extern "C" {  @} */ - typedef struct _tTwoZero + typedef struct tTwoZero { tMempool mempool; @@ -581,26 +567,24 @@ extern "C" { Lfloat frequency, radius; Lfloat lastIn[2]; Lfloat twoPiTimesInvSampleRate; - } _tTwoZero; - - typedef _tTwoZero* tTwoZero; + } tTwoZero; // Memory handlers for `tTwoZero` - void tTwoZero_init (tTwoZero* const, LEAF* const leaf); - void tTwoZero_initToPool (tTwoZero* const, tMempool* const); - void tTwoZero_free (tTwoZero* const); + void tTwoZero_init (tTwoZero** const, LEAF* const leaf); + void tTwoZero_initToPool (tTwoZero** const, tMempool* const); + void tTwoZero_free (tTwoZero** const); // Tick function for `tTwoZero` - Lfloat tTwoZero_tick (tTwoZero const, Lfloat input); + Lfloat tTwoZero_tick (tTwoZero* const, Lfloat input); // Setter functions for `tTwoZero` - void tTwoZero_setB0 (tTwoZero const, Lfloat b0); - void tTwoZero_setB1 (tTwoZero const, Lfloat b1); - void tTwoZero_setB2 (tTwoZero const, Lfloat b2); - void tTwoZero_setNotch (tTwoZero const, Lfloat frequency, Lfloat radius); - void tTwoZero_setCoefficients(tTwoZero const, Lfloat b0, Lfloat b1, Lfloat b2); - void tTwoZero_setGain (tTwoZero const, Lfloat gain); - void tTwoZero_setSampleRate (tTwoZero const, Lfloat sr); + void tTwoZero_setB0 (tTwoZero* const, Lfloat b0); + void tTwoZero_setB1 (tTwoZero* const, Lfloat b1); + void tTwoZero_setB2 (tTwoZero* const, Lfloat b2); + void tTwoZero_setNotch (tTwoZero* const, Lfloat frequency, Lfloat radius); + void tTwoZero_setCoefficients(tTwoZero* const, Lfloat b0, Lfloat b1, Lfloat b2); + void tTwoZero_setGain (tTwoZero* const, Lfloat gain); + void tTwoZero_setSampleRate (tTwoZero* const, Lfloat sr); //============================================================================== @@ -660,7 +644,7 @@ extern "C" {  @} */ - typedef struct _tPoleZero + typedef struct tPoleZero { tMempool mempool; @@ -670,26 +654,24 @@ extern "C" { Lfloat b0,b1; Lfloat lastIn, lastOut; - } _tPoleZero; - - typedef _tPoleZero* tPoleZero; + } tPoleZero; // Memory handlers for `tPoleZero` - void tPoleZero_init (tPoleZero* const, LEAF* const leaf); - void tPoleZero_initToPool (tPoleZero* const, tMempool* const); - void tPoleZero_free (tPoleZero* const); + void tPoleZero_init (tPoleZero** const, LEAF* const leaf); + void tPoleZero_initToPool (tPoleZero** const, tMempool* const); + void tPoleZero_free (tPoleZero** const); // Tick function for `tPoleZero` - Lfloat tPoleZero_tick (tPoleZero const, Lfloat input); + Lfloat tPoleZero_tick (tPoleZero* const, Lfloat input); // Setter functions for `tPoleZero` - void tPoleZero_setB0 (tPoleZero const, Lfloat b0); - void tPoleZero_setB1 (tPoleZero const, Lfloat b1); - void tPoleZero_setA1 (tPoleZero const, Lfloat a1); - void tPoleZero_setCoefficients (tPoleZero const, Lfloat b0, Lfloat b1, Lfloat a1); - void tPoleZero_setAllpass (tPoleZero const, Lfloat coeff); - void tPoleZero_setBlockZero (tPoleZero const, Lfloat thePole); - void tPoleZero_setGain (tPoleZero const, Lfloat gain); + void tPoleZero_setB0 (tPoleZero* const, Lfloat b0); + void tPoleZero_setB1 (tPoleZero* const, Lfloat b1); + void tPoleZero_setA1 (tPoleZero* const, Lfloat a1); + void tPoleZero_setCoefficients (tPoleZero* const, Lfloat b0, Lfloat b1, Lfloat a1); + void tPoleZero_setAllpass (tPoleZero* const, Lfloat coeff); + void tPoleZero_setBlockZero (tPoleZero* const, Lfloat thePole); + void tPoleZero_setGain (tPoleZero* const, Lfloat gain); //============================================================================== @@ -757,7 +739,7 @@ extern "C" {  @} */ - typedef struct _tBiQuad + typedef struct tBiQuad { tMempool mempool; @@ -773,29 +755,27 @@ extern "C" { Lfloat sampleRate; Lfloat twoPiTimesInvSampleRate; - } _tBiQuad; - - typedef _tBiQuad* tBiQuad; + } tBiQuad; // Memory handlers for `tBiQuad` - void tBiQuad_init (tBiQuad* const, LEAF* const leaf); - void tBiQuad_initToPool (tBiQuad* const, tMempool* const); - void tBiQuad_free (tBiQuad* const); + void tBiQuad_init (tBiQuad** const, LEAF* const leaf); + void tBiQuad_initToPool (tBiQuad** const, tMempool* const); + void tBiQuad_free (tBiQuad** const); // Tick function for `tBiQuad` - Lfloat tBiQuad_tick (tBiQuad const, Lfloat input); + Lfloat tBiQuad_tick (tBiQuad* const, Lfloat input); // Setter functions for `tBiQuad` - void tBiQuad_setB0 (tBiQuad const, Lfloat b0); - void tBiQuad_setB1 (tBiQuad const, Lfloat b1); - void tBiQuad_setB2 (tBiQuad const, Lfloat b2); - void tBiQuad_setA1 (tBiQuad const, Lfloat a1); - void tBiQuad_setA2 (tBiQuad const, Lfloat a2); - void tBiQuad_setNotch (tBiQuad const, Lfloat freq, Lfloat radius); - void tBiQuad_setResonance (tBiQuad const, Lfloat freq, Lfloat radius, int normalize); - void tBiQuad_setCoefficients(tBiQuad const, Lfloat b0, Lfloat b1, Lfloat b2, Lfloat a1, Lfloat a2); - void tBiQuad_setGain (tBiQuad const, Lfloat gain); - void tBiQuad_setSampleRate (tBiQuad const, Lfloat sr); + void tBiQuad_setB0 (tBiQuad* const, Lfloat b0); + void tBiQuad_setB1 (tBiQuad* const, Lfloat b1); + void tBiQuad_setB2 (tBiQuad* const, Lfloat b2); + void tBiQuad_setA1 (tBiQuad* const, Lfloat a1); + void tBiQuad_setA2 (tBiQuad* const, Lfloat a2); + void tBiQuad_setNotch (tBiQuad* const, Lfloat freq, Lfloat radius); + void tBiQuad_setResonance (tBiQuad* const, Lfloat freq, Lfloat radius, int normalize); + void tBiQuad_setCoefficients(tBiQuad* const, Lfloat b0, Lfloat b1, Lfloat b2, Lfloat a1, Lfloat a2); + void tBiQuad_setGain (tBiQuad* const, Lfloat gain); + void tBiQuad_setSampleRate (tBiQuad* const, Lfloat sr); //============================================================================== @@ -852,7 +832,7 @@ extern "C" { SVFTypeHighShelf } SVFType; - typedef struct _tSVF + typedef struct tSVF { tMempool mempool; SVFType type; @@ -864,34 +844,32 @@ extern "C" { Lfloat phaseComp; Lfloat sampleRatio; const Lfloat *table; - } _tSVF; - - typedef _tSVF* tSVF; + } tSVF; // Memory handlers for `tSVF` - void tSVF_init (tSVF* const, SVFType type, Lfloat freq, Lfloat Q, LEAF* const leaf); - void tSVF_initToPool (tSVF* const, SVFType type, Lfloat freq, Lfloat Q, tMempool* const); - void tSVF_free (tSVF* const); + void tSVF_init (tSVF** const, SVFType type, Lfloat freq, Lfloat Q, LEAF* const leaf); + void tSVF_initToPool (tSVF** const, SVFType type, Lfloat freq, Lfloat Q, tMempool* const); + void tSVF_free (tSVF** const); // Tick functions for `tSVF` - Lfloat tSVF_tick (tSVF const, Lfloat v0); - Lfloat tSVF_tickLP (tSVF const, Lfloat v0); - Lfloat tSVF_tickHP (tSVF const, Lfloat v0); - Lfloat tSVF_tickBP (tSVF const, Lfloat v0); + Lfloat tSVF_tick (tSVF* const, Lfloat v0); + Lfloat tSVF_tickLP (tSVF* const, Lfloat v0); + Lfloat tSVF_tickHP (tSVF* const, Lfloat v0); + Lfloat tSVF_tickBP (tSVF* const, Lfloat v0); // Setter functions for `tSVF` - void tSVF_setFreq (tSVF const, Lfloat freq); - void tSVF_setFreqFast (tSVF const vf, Lfloat cutoff); - void tSVF_setQ (tSVF const, Lfloat Q); - void tSVF_setFreqAndQ (tSVF const svff, Lfloat freq, Lfloat Q); - void tSVF_setFreqAndQFast (tSVF const svff, Lfloat cutoff, Lfloat Q); - void tSVF_setFilterType (tSVF const svff, SVFType type); - void tSVF_setSampleRate (tSVF const svff, Lfloat sr); - Lfloat tSVF_getPhaseAtFrequency (tSVF const svff, Lfloat freq); + void tSVF_setFreq (tSVF* const, Lfloat freq); + void tSVF_setFreqFast (tSVF* const vf, Lfloat cutoff); + void tSVF_setQ (tSVF* const, Lfloat Q); + void tSVF_setFreqAndQ (tSVF* const svff, Lfloat freq, Lfloat Q); + void tSVF_setFreqAndQFast (tSVF* const svff, Lfloat cutoff, Lfloat Q); + void tSVF_setFilterType (tSVF* const svff, SVFType type); + void tSVF_setSampleRate (tSVF* const svff, Lfloat sr); + Lfloat tSVF_getPhaseAtFrequency (tSVF* const svff, Lfloat freq); //============================================================================== - typedef struct _tSVF_LP + typedef struct tSVF_LP { tMempool mempool; Lfloat ic1eq,ic2eq; @@ -902,26 +880,24 @@ extern "C" { Lfloat sampleRatio; uint32_t nan; const Lfloat *table; - } _tSVF_LP; - - typedef _tSVF_LP* tSVF_LP; + } tSVF_LP; // Memory handlers for `tSVF_LP` - void tSVF_LP_init (tSVF_LP* const, Lfloat freq, Lfloat Q, LEAF* const leaf); - void tSVF_LP_initToPool (tSVF_LP* const, Lfloat freq, Lfloat Q, tMempool* const); - void tSVF_LP_free (tSVF_LP* const); + void tSVF_LP_init (tSVF_LP** const, Lfloat freq, Lfloat Q, LEAF* const leaf); + void tSVF_LP_initToPool (tSVF_LP** const, Lfloat freq, Lfloat Q, tMempool* const); + void tSVF_LP_free (tSVF_LP** const); // Tick function for `tSVF_LP` - Lfloat tSVF_LP_tick (tSVF_LP const, Lfloat v0); + Lfloat tSVF_LP_tick (tSVF_LP* const, Lfloat v0); // Setter functions for `tSVF_LP` - void tSVF_LP_setFreq (tSVF_LP const, Lfloat freq); - void tSVF_LP_setFreqFast (tSVF_LP const vf, Lfloat cutoff); - void tSVF_LP_setQ (tSVF_LP const, Lfloat Q); - void tSVF_LP_setFreqAndQ (tSVF_LP const svff, Lfloat freq, Lfloat Q); - void tSVF_LP_setFreqAndQFast (tSVF_LP const svff, Lfloat cutoff, Lfloat Q); - void tSVF_LP_setSampleRate (tSVF_LP const svff, Lfloat sr); - Lfloat tSVF_LP_getPhaseAtFrequency (tSVF_LP const svff, Lfloat freq); + void tSVF_LP_setFreq (tSVF_LP* const, Lfloat freq); + void tSVF_LP_setFreqFast (tSVF_LP* const vf, Lfloat cutoff); + void tSVF_LP_setQ (tSVF_LP* const, Lfloat Q); + void tSVF_LP_setFreqAndQ (tSVF_LP* const svff, Lfloat freq, Lfloat Q); + void tSVF_LP_setFreqAndQFast (tSVF_LP* const svff, Lfloat cutoff, Lfloat Q); + void tSVF_LP_setSampleRate (tSVF_LP* const svff, Lfloat sr); + Lfloat tSVF_LP_getPhaseAtFrequency (tSVF_LP* const svff, Lfloat freq); //============================================================================== /*! @@ -958,7 +934,7 @@ extern "C" {  @} */ - typedef struct _tEfficientSVF + typedef struct tEfficientSVF { tMempool mempool; @@ -967,23 +943,21 @@ extern "C" { Lfloat ic1eq,ic2eq; Lfloat g,k,a1,a2,a3; const Lfloat *table; - } _tEfficientSVF; - - typedef _tEfficientSVF* tEfficientSVF; + } tEfficientSVF; // Memory handlers for `tEfficientSVF` - void tEfficientSVF_init (tEfficientSVF* const, SVFType type, uint16_t input, Lfloat Q, LEAF* const leaf); - void tEfficientSVF_initToPool (tEfficientSVF* const, SVFType type, uint16_t input, Lfloat Q, tMempool* const); - void tEfficientSVF_free (tEfficientSVF* const); + void tEfficientSVF_init (tEfficientSVF** const, SVFType type, uint16_t input, Lfloat Q, LEAF* const leaf); + void tEfficientSVF_initToPool (tEfficientSVF** const, SVFType type, uint16_t input, Lfloat Q, tMempool* const); + void tEfficientSVF_free (tEfficientSVF** const); // Tick function for `tEfficientSVF` - Lfloat tEfficientSVF_tick (tEfficientSVF const, Lfloat v0); + Lfloat tEfficientSVF_tick (tEfficientSVF* const, Lfloat v0); // Setter functions for `tEfficientSVF` - void tEfficientSVF_setFreq (tEfficientSVF const svff, Lfloat cutoff); - void tEfficientSVF_setQ (tEfficientSVF const, Lfloat Q); - void tEfficientSVF_setFreqAndQ (tEfficientSVF const, uint16_t controlFreq, Lfloat Q); - void tEfficientSVF_setSampleRate (tEfficientSVF const, Lfloat sampleRate); + void tEfficientSVF_setFreq (tEfficientSVF* const svff, Lfloat cutoff); + void tEfficientSVF_setQ (tEfficientSVF* const, Lfloat Q); + void tEfficientSVF_setFreqAndQ (tEfficientSVF* const, uint16_t controlFreq, Lfloat Q); + void tEfficientSVF_setSampleRate (tEfficientSVF* const, Lfloat sampleRate); //============================================================================== /*! @@ -1020,28 +994,26 @@ extern "C" {  @} */ - typedef struct _tHighpass + typedef struct tHighpass { tMempool mempool; Lfloat xs, ys, R; Lfloat frequency; Lfloat twoPiTimesInvSampleRate; - } _tHighpass; - - typedef _tHighpass* tHighpass; + } tHighpass; // Memory handlers for `tHighpass` - void tHighpass_init (tHighpass* const, Lfloat freq, LEAF* const leaf); - void tHighpass_initToPool (tHighpass* const, Lfloat freq, tMempool* const); - void tHighpass_free (tHighpass* const); + void tHighpass_init (tHighpass** const, Lfloat freq, LEAF* const leaf); + void tHighpass_initToPool (tHighpass** const, Lfloat freq, tMempool* const); + void tHighpass_free (tHighpass** const); // Tick function for `tHighpass` - Lfloat tHighpass_tick (tHighpass const, Lfloat x); + Lfloat tHighpass_tick (tHighpass* const, Lfloat x); // Setter functions for `tHighpass` - void tHighpass_setFreq (tHighpass const, Lfloat freq); - Lfloat tHighpass_getFreq (tHighpass const); - void tHighpass_setSampleRate (tHighpass const, Lfloat sr); + void tHighpass_setFreq (tHighpass* const, Lfloat freq); + Lfloat tHighpass_getFreq (tHighpass* const); + void tHighpass_setSampleRate (tHighpass* const, Lfloat sr); //============================================================================== @@ -1090,7 +1062,7 @@ extern "C" { @} */ #define NUM_SVF_BW 16 - typedef struct _tButterworth + typedef struct tButterworth { tMempool mempool; @@ -1101,23 +1073,21 @@ extern "C" { tSVF* svf; Lfloat f1,f2; - } _tButterworth; - - typedef _tButterworth* tButterworth; + } tButterworth; // Memory handlers for `tButterworth` - void tButterworth_init (tButterworth* const, int N, Lfloat f1, Lfloat f2, LEAF* const leaf); - void tButterworth_initToPool (tButterworth* const, int N, Lfloat f1, Lfloat f2, tMempool* const); - void tButterworth_free (tButterworth* const); + void tButterworth_init (tButterworth** const, int N, Lfloat f1, Lfloat f2, LEAF* const leaf); + void tButterworth_initToPool (tButterworth** const, int N, Lfloat f1, Lfloat f2, tMempool* const); + void tButterworth_free (tButterworth** const); // Tick function for `tButterworth` - Lfloat tButterworth_tick (tButterworth const, Lfloat input); + Lfloat tButterworth_tick (tButterworth* const, Lfloat input); // Setter functions for `tButterworth` - void tButterworth_setF1 (tButterworth const, Lfloat in); - void tButterworth_setF2 (tButterworth const, Lfloat in); - void tButterworth_setFreqs (tButterworth const, Lfloat f1, Lfloat f2); - void tButterworth_setSampleRate (tButterworth const, Lfloat sr); + void tButterworth_setF1 (tButterworth* const, Lfloat in); + void tButterworth_setF2 (tButterworth* const, Lfloat in); + void tButterworth_setFreqs (tButterworth* const, Lfloat f1, Lfloat f2); + void tButterworth_setSampleRate (tButterworth* const, Lfloat sr); //============================================================================== @@ -1147,24 +1117,22 @@ extern "C" {  @} */ - typedef struct _tFIR + typedef struct tFIR { tMempool mempool; Lfloat* past; Lfloat* coeff; int numTaps; - } _tFIR; - - typedef _tFIR* tFIR; + } tFIR; // Memory handlers for `tFIR` - void tFIR_init (tFIR* const, Lfloat* coeffs, int numTaps, LEAF* const leaf); - void tFIR_initToPool (tFIR* const, Lfloat* coeffs, int numTaps, tMempool* const); - void tFIR_free (tFIR* const); + void tFIR_init (tFIR** const, Lfloat* coeffs, int numTaps, LEAF* const leaf); + void tFIR_initToPool (tFIR** const, Lfloat* coeffs, int numTaps, tMempool* const); + void tFIR_free (tFIR** const); // Tick function for `tFIR` - Lfloat tFIR_tick (tFIR const, Lfloat input); + Lfloat tFIR_tick (tFIR* const, Lfloat input); //============================================================================== @@ -1195,7 +1163,7 @@ extern "C" {  @} */ - typedef struct _tMedianFilter + typedef struct tMedianFilter { tMempool mempool; @@ -1206,17 +1174,15 @@ extern "C" { int middlePosition; int last; int pos; - } _tMedianFilter; - - typedef _tMedianFilter* tMedianFilter; + } tMedianFilter; // Memory handlers for `tMedianFilter` - void tMedianFilter_init (tMedianFilter* const, int size, LEAF* const leaf); - void tMedianFilter_initToPool (tMedianFilter* const, int size, tMempool* const); - void tMedianFilter_free (tMedianFilter* const); + void tMedianFilter_init (tMedianFilter** const, int size, LEAF* const leaf); + void tMedianFilter_initToPool (tMedianFilter** const, int size, tMempool* const); + void tMedianFilter_free (tMedianFilter** const); // Tick function for `tMedianFilter` - Lfloat tMedianFilter_tick (tMedianFilter const, Lfloat input); + Lfloat tMedianFilter_tick (tMedianFilter* const, Lfloat input); /*! @@ -1297,7 +1263,7 @@ extern "C" { } VZFilterType; - typedef struct _tVZFilter + typedef struct tVZFilter { tMempool mempool; @@ -1324,45 +1290,43 @@ extern "C" { Lfloat sampRatio; Lfloat cutoffMIDI; const Lfloat *table; - } _tVZFilter; - - typedef _tVZFilter* tVZFilter; + } tVZFilter; // Memory handlers for `tVZFilter` - void tVZFilter_init (tVZFilter* const, VZFilterType type, Lfloat freq, Lfloat Q, + void tVZFilter_init (tVZFilter** const, VZFilterType type, Lfloat freq, Lfloat Q, LEAF* const leaf); - void tVZFilter_initToPool (tVZFilter* const, VZFilterType type, Lfloat freq, Lfloat Q, + void tVZFilter_initToPool (tVZFilter** const, VZFilterType type, Lfloat freq, Lfloat Q, tMempool* const); - void tVZFilter_free (tVZFilter* const); + void tVZFilter_free (tVZFilter** const); // Tick functions for `tVZFilter` - Lfloat tVZFilter_tick (tVZFilter const, Lfloat input); - Lfloat tVZFilter_tickEfficient (tVZFilter const vf, Lfloat in); + Lfloat tVZFilter_tick (tVZFilter* const, Lfloat input); + Lfloat tVZFilter_tickEfficient (tVZFilter* const vf, Lfloat in); // Setter functions for `tVZFilter` - void tVZFilter_setSampleRate (tVZFilter const, Lfloat sampleRate); - void tVZFilter_calcCoeffs (tVZFilter const); - void tVZFilter_calcCoeffsEfficientBP (tVZFilter const); - void tVZFilter_setBandwidth (tVZFilter const, Lfloat bandWidth); - void tVZFilter_setFreq (tVZFilter const, Lfloat freq); - void tVZFilter_setFreqFast (tVZFilter const vf, Lfloat cutoff); - void tVZFilter_setFreqAndBandwidth (tVZFilter const vf, Lfloat freq, Lfloat bw); - void tVZFilter_setFreqAndBandwidthEfficientBP (tVZFilter const vf, Lfloat freq, Lfloat bw); - void tVZFilter_setGain (tVZFilter const, Lfloat gain); - void tVZFilter_setResonance (tVZFilter const vf, Lfloat res); - void tVZFilter_setFrequencyAndResonance (tVZFilter const vf, Lfloat freq, Lfloat res); - void tVZFilter_setFrequencyAndResonanceAndGain (tVZFilter const vf, Lfloat freq, Lfloat res, Lfloat gains); - void tVZFilter_setFastFrequencyAndResonanceAndGain (tVZFilter const vf, Lfloat freq, Lfloat res, Lfloat gain); - void tVZFilter_setFrequencyAndBandwidthAndGain (tVZFilter const vf, Lfloat freq, Lfloat BW, Lfloat gain); - void tVZFilter_setFrequencyAndResonanceAndMorph (tVZFilter const vf, Lfloat freq, Lfloat res, Lfloat morph); - void tVZFilter_setMorphOnly (tVZFilter const vf, Lfloat morph); - void tVZFilter_setMorph (tVZFilter const vf, Lfloat morph); - void tVZFilter_setType (tVZFilter const, VZFilterType type); - Lfloat tVZFilter_BandwidthToR (tVZFilter const vf, Lfloat B); - Lfloat tVZFilter_BandwidthToREfficientBP (tVZFilter const vf, Lfloat B); - - - typedef struct _tVZFilterLS + void tVZFilter_setSampleRate (tVZFilter* const, Lfloat sampleRate); + void tVZFilter_calcCoeffs (tVZFilter* const); + void tVZFilter_calcCoeffsEfficientBP (tVZFilter* const); + void tVZFilter_setBandwidth (tVZFilter* const, Lfloat bandWidth); + void tVZFilter_setFreq (tVZFilter* const, Lfloat freq); + void tVZFilter_setFreqFast (tVZFilter* const vf, Lfloat cutoff); + void tVZFilter_setFreqAndBandwidth (tVZFilter* const vf, Lfloat freq, Lfloat bw); + void tVZFilter_setFreqAndBandwidthEfficientBP (tVZFilter* const vf, Lfloat freq, Lfloat bw); + void tVZFilter_setGain (tVZFilter* const, Lfloat gain); + void tVZFilter_setResonance (tVZFilter* const vf, Lfloat res); + void tVZFilter_setFrequencyAndResonance (tVZFilter* const vf, Lfloat freq, Lfloat res); + void tVZFilter_setFrequencyAndResonanceAndGain (tVZFilter* const vf, Lfloat freq, Lfloat res, Lfloat gains); + void tVZFilter_setFastFrequencyAndResonanceAndGain (tVZFilter* const vf, Lfloat freq, Lfloat res, Lfloat gain); + void tVZFilter_setFrequencyAndBandwidthAndGain (tVZFilter* const vf, Lfloat freq, Lfloat BW, Lfloat gain); + void tVZFilter_setFrequencyAndResonanceAndMorph (tVZFilter* const vf, Lfloat freq, Lfloat res, Lfloat morph); + void tVZFilter_setMorphOnly (tVZFilter* const vf, Lfloat morph); + void tVZFilter_setMorph (tVZFilter* const vf, Lfloat morph); + void tVZFilter_setType (tVZFilter* const, VZFilterType type); + Lfloat tVZFilter_BandwidthToR (tVZFilter* const vf, Lfloat B); + Lfloat tVZFilter_BandwidthToREfficientBP (tVZFilter* const vf, Lfloat B); + + + typedef struct tVZFilterLS { tMempool mempool; // state: @@ -1386,31 +1350,29 @@ extern "C" { Lfloat sampRatio; // ratio of the sample rate to 48000 (which is what the tanf table was calculated for) const Lfloat *table; Lfloat cutoffMIDI; - } _tVZFilterLS; - - typedef _tVZFilterLS* tVZFilterLS; + } tVZFilterLS; // Memory handlers for `tVZFilterLS` - void tVZFilterLS_init (tVZFilterLS* const,Lfloat freq, Lfloat Q, Lfloat gain, + void tVZFilterLS_init (tVZFilterLS** const,Lfloat freq, Lfloat Q, Lfloat gain, LEAF* const leaf); - void tVZFilterLS_initToPool (tVZFilterLS* const, Lfloat freq, Lfloat Q, Lfloat gain, + void tVZFilterLS_initToPool (tVZFilterLS** const, Lfloat freq, Lfloat Q, Lfloat gain, tMempool* const); - void tVZFilterLS_free (tVZFilterLS* const); + void tVZFilterLS_free (tVZFilterLS** const); // Tick function for `tVZFilterLS` - Lfloat tVZFilterLS_tick (tVZFilterLS const, Lfloat input); + Lfloat tVZFilterLS_tick (tVZFilterLS* const, Lfloat input); // Setter functions for `tVZFilterLS` - void tVZFilterLS_setSampleRate (tVZFilterLS const, Lfloat sampleRate); - void tVZFilterLS_setBandwidthSlow (tVZFilterLS const, Lfloat bandWidth); - void tVZFilterLS_setFreq (tVZFilterLS const, Lfloat freq); - void tVZFilterLS_setFreqFast (tVZFilterLS const vf, Lfloat cutoff); - void tVZFilterLS_setGain (tVZFilterLS const, Lfloat gain); - void tVZFilterLS_setResonance (tVZFilterLS const vf, Lfloat res); - void tVZFilterLS_setFreqFastAndResonanceAndGain (tVZFilterLS const vf, Lfloat cutoff, Lfloat res, Lfloat gain); + void tVZFilterLS_setSampleRate (tVZFilterLS* const, Lfloat sampleRate); + void tVZFilterLS_setBandwidthSlow (tVZFilterLS* const, Lfloat bandWidth); + void tVZFilterLS_setFreq (tVZFilterLS* const, Lfloat freq); + void tVZFilterLS_setFreqFast (tVZFilterLS* const vf, Lfloat cutoff); + void tVZFilterLS_setGain (tVZFilterLS* const, Lfloat gain); + void tVZFilterLS_setResonance (tVZFilterLS* const vf, Lfloat res); + void tVZFilterLS_setFreqFastAndResonanceAndGain (tVZFilterLS* const vf, Lfloat cutoff, Lfloat res, Lfloat gain); - typedef struct _tVZFilterHS + typedef struct tVZFilterHS { tMempool mempool; // state: @@ -1435,30 +1397,28 @@ extern "C" { Lfloat sampRatio; // ratio of the sample rate to 48000 (which is what the tanf table was calculated for) const Lfloat *table; Lfloat cutoffMIDI; - } _tVZFilterHS; - - typedef _tVZFilterHS* tVZFilterHS; + } tVZFilterHS; // Memory handlers for `tVZFilterHS` - void tVZFilterHS_init (tVZFilterHS* const,Lfloat freq, Lfloat Q, Lfloat gain, + void tVZFilterHS_init (tVZFilterHS** const,Lfloat freq, Lfloat Q, Lfloat gain, LEAF* const leaf); - void tVZFilterHS_initToPool (tVZFilterHS* const, Lfloat freq, Lfloat Q, Lfloat gain, + void tVZFilterHS_initToPool (tVZFilterHS** const, Lfloat freq, Lfloat Q, Lfloat gain, tMempool* const); - void tVZFilterHS_free (tVZFilterHS* const); + void tVZFilterHS_free (tVZFilterHS** const); // Tick function for `tVZFilterHS` - Lfloat tVZFilterHS_tick (tVZFilterHS const, Lfloat input); + Lfloat tVZFilterHS_tick (tVZFilterHS* const, Lfloat input); // Setter functions for `tVZFilterHS` - void tVZFilterHS_setSampleRate (tVZFilterHS const, Lfloat sampleRate); - void tVZFilterHS_setBandwidthSlow (tVZFilterHS const, Lfloat bandWidth); - void tVZFilterHS_setFreq (tVZFilterHS const, Lfloat freq); - void tVZFilterHS_setFreqFast (tVZFilterHS const vf, Lfloat cutoff); - void tVZFilterHS_setGain (tVZFilterHS const, Lfloat gain); - void tVZFilterHS_setResonance (tVZFilterHS const vf, Lfloat res); - void tVZFilterHS_setFreqFastAndResonanceAndGain (tVZFilterHS const vf, Lfloat cutoff, Lfloat res, Lfloat gain); - - typedef struct _tVZFilterBell + void tVZFilterHS_setSampleRate (tVZFilterHS* const, Lfloat sampleRate); + void tVZFilterHS_setBandwidthSlow (tVZFilterHS* const, Lfloat bandWidth); + void tVZFilterHS_setFreq (tVZFilterHS* const, Lfloat freq); + void tVZFilterHS_setFreqFast (tVZFilterHS* const vf, Lfloat cutoff); + void tVZFilterHS_setGain (tVZFilterHS* const, Lfloat gain); + void tVZFilterHS_setResonance (tVZFilterHS* const vf, Lfloat res); + void tVZFilterHS_setFreqFastAndResonanceAndGain (tVZFilterHS* const vf, Lfloat cutoff, Lfloat res, Lfloat gain); + + typedef struct tVZFilterBell { tMempool mempool; // state: @@ -1481,32 +1441,30 @@ extern "C" { Lfloat sampRatio; // ratio of the sample rate to 48000 (which is what the tanf table was calculated for) const Lfloat *table; Lfloat cutoffMIDI; - } _tVZFilterBell; - - typedef _tVZFilterBell* tVZFilterBell; + } tVZFilterBell; // Memory handlers for `tVZFilterBell` - void tVZFilterBell_init (tVZFilterBell* const,Lfloat freq, Lfloat BW, Lfloat gain, + void tVZFilterBell_init (tVZFilterBell** const,Lfloat freq, Lfloat BW, Lfloat gain, LEAF* const leaf); - void tVZFilterBell_initToPool (tVZFilterBell* const, Lfloat freq, Lfloat BW, Lfloat gain, + void tVZFilterBell_initToPool (tVZFilterBell** const, Lfloat freq, Lfloat BW, Lfloat gain, tMempool* const); - void tVZFilterBell_free (tVZFilterBell* const); + void tVZFilterBell_free (tVZFilterBell** const); // Tick function for `tVZFilterBell` - Lfloat tVZFilterBell_tick (tVZFilterBell const, Lfloat input); + Lfloat tVZFilterBell_tick (tVZFilterBell* const, Lfloat input); // Setter functions for `tVZFilterBell` - void tVZFilterBell_setSampleRate (tVZFilterBell const, Lfloat sampleRate); - void tVZFilterBell_setBandwidth (tVZFilterBell const, Lfloat bandWidth); - void tVZFilterBell_setFreq (tVZFilterBell const, Lfloat freq); - void tVZFilterBell_setFreqFast (tVZFilterBell const vf, Lfloat cutoff); - void tVZFilterBell_setFreqAndGainFast (tVZFilterBell const, Lfloat freq, Lfloat gain); - void tVZFilterBell_setFrequencyAndGain (tVZFilterBell const, Lfloat freq, Lfloat gain); - void tVZFilterBell_setFrequencyAndBandwidthAndGain (tVZFilterBell const vf, Lfloat freq, Lfloat bandwidth, Lfloat gain); - void tVZFilterBell_setFreqAndBWAndGainFast (tVZFilterBell const vf, Lfloat cutoff, Lfloat BW, Lfloat gain); - void tVZFilterBell_setGain (tVZFilterBell const, Lfloat gain); - - typedef struct _tVZFilterBR + void tVZFilterBell_setSampleRate (tVZFilterBell* const, Lfloat sampleRate); + void tVZFilterBell_setBandwidth (tVZFilterBell* const, Lfloat bandWidth); + void tVZFilterBell_setFreq (tVZFilterBell* const, Lfloat freq); + void tVZFilterBell_setFreqFast (tVZFilterBell* const vf, Lfloat cutoff); + void tVZFilterBell_setFreqAndGainFast (tVZFilterBell* const, Lfloat freq, Lfloat gain); + void tVZFilterBell_setFrequencyAndGain (tVZFilterBell* const, Lfloat freq, Lfloat gain); + void tVZFilterBell_setFrequencyAndBandwidthAndGain (tVZFilterBell* const vf, Lfloat freq, Lfloat bandwidth, Lfloat gain); + void tVZFilterBell_setFreqAndBWAndGainFast (tVZFilterBell* const vf, Lfloat cutoff, Lfloat BW, Lfloat gain); + void tVZFilterBell_setGain (tVZFilterBell* const, Lfloat gain); + + typedef struct tVZFilterBR { tMempool mempool; // state: @@ -1524,25 +1482,23 @@ extern "C" { Lfloat invSampleRate; Lfloat sampRatio; // ratio of the sample rate to 48000 (which is what the tanf table was calculated for) const Lfloat *table; - } _tVZFilterBR; - - typedef _tVZFilterBR* tVZFilterBR; + } tVZFilterBR; // Memory handlers for `tVZFilterBR` - void tVZFilterBR_init (tVZFilterBR* const,Lfloat freq, Lfloat Q, LEAF* const leaf); - void tVZFilterBR_initToPool (tVZFilterBR* const, Lfloat freq, Lfloat Q, tMempool* const); - void tVZFilterBR_free (tVZFilterBR* const); + void tVZFilterBR_init (tVZFilterBR** const,Lfloat freq, Lfloat Q, LEAF* const leaf); + void tVZFilterBR_initToPool (tVZFilterBR** const, Lfloat freq, Lfloat Q, tMempool* const); + void tVZFilterBR_free (tVZFilterBR** const); // Tick function for `tVZFilterBR` - Lfloat tVZFilterBR_tick (tVZFilterBR const, Lfloat input); + Lfloat tVZFilterBR_tick (tVZFilterBR* const, Lfloat input); // Setter functions for `tVZFilterBR` - void tVZFilterBR_setSampleRate (tVZFilterBR const, Lfloat sampleRate); - void tVZFilterBR_setGain (tVZFilterBR const, Lfloat gain); - void tVZFilterBR_setFreq (tVZFilterBR const, Lfloat freq); - void tVZFilterBR_setFreqFast (tVZFilterBR const vf, Lfloat cutoff); - void tVZFilterBR_setResonance (tVZFilterBR const vf, Lfloat res); - void tVZFilterBR_setFreqAndResonanceFast (tVZFilterBR const vf, Lfloat cutoff, Lfloat res); + void tVZFilterBR_setSampleRate (tVZFilterBR* const, Lfloat sampleRate); + void tVZFilterBR_setGain (tVZFilterBR* const, Lfloat gain); + void tVZFilterBR_setFreq (tVZFilterBR* const, Lfloat freq); + void tVZFilterBR_setFreqFast (tVZFilterBR* const vf, Lfloat cutoff); + void tVZFilterBR_setResonance (tVZFilterBR* const vf, Lfloat res); + void tVZFilterBR_setFreqAndResonanceFast (tVZFilterBR* const vf, Lfloat cutoff, Lfloat res); /*! @defgroup tdiodefilter tDiodeFilter @@ -1579,7 +1535,7 @@ extern "C" { @} */ //diode ladder filter by Ivan C, based on mystran's method - typedef struct _tDiodeFilter + typedef struct tDiodeFilter { tMempool mempool; Lfloat cutoff; @@ -1597,29 +1553,27 @@ extern "C" { Lfloat sampRatio; const Lfloat *table; Lfloat cutoffMIDI; - } _tDiodeFilter; - - typedef _tDiodeFilter* tDiodeFilter; + } tDiodeFilter; // Memory handlers for `tDiodeFilter` - void tDiodeFilter_init (tDiodeFilter* const, Lfloat freq, Lfloat Q, LEAF* const leaf); - void tDiodeFilter_initToPool (tDiodeFilter* const, Lfloat freq, Lfloat Q, tMempool* const); - void tDiodeFilter_free (tDiodeFilter* const); + void tDiodeFilter_init (tDiodeFilter** const, Lfloat freq, Lfloat Q, LEAF* const leaf); + void tDiodeFilter_initToPool (tDiodeFilter** const, Lfloat freq, Lfloat Q, tMempool* const); + void tDiodeFilter_free (tDiodeFilter** const); // Tick functions for `tDiodeFilter` - Lfloat tDiodeFilter_tick (tDiodeFilter const, Lfloat input); - Lfloat tDiodeFilter_tickEfficient (tDiodeFilter const vf, Lfloat in); + Lfloat tDiodeFilter_tick (tDiodeFilter* const, Lfloat input); + Lfloat tDiodeFilter_tickEfficient (tDiodeFilter* const vf, Lfloat in); // Setter functions for `tDiodeFilter` - void tDiodeFilter_setFreq (tDiodeFilter const vf, Lfloat cutoff); - void tDiodeFilter_setFreqFast (tDiodeFilter const vf, Lfloat cutoff); - void tDiodeFilter_setQ (tDiodeFilter const vf, Lfloat resonance); - void tDiodeFilter_setSampleRate (tDiodeFilter const vf, Lfloat sr); + void tDiodeFilter_setFreq (tDiodeFilter* const vf, Lfloat cutoff); + void tDiodeFilter_setFreqFast (tDiodeFilter* const vf, Lfloat cutoff); + void tDiodeFilter_setQ (tDiodeFilter* const vf, Lfloat resonance); + void tDiodeFilter_setSampleRate (tDiodeFilter* const vf, Lfloat sr); //transistor ladder filter by aciddose, based on mystran's method, KVR forums - typedef struct _tLadderFilter + typedef struct tLadderFilter { tMempool mempool; Lfloat cutoff; @@ -1636,28 +1590,26 @@ extern "C" { Lfloat b[4]; // stored states const Lfloat *table; Lfloat cutoffMIDI; - } _tLadderFilter; - - typedef _tLadderFilter* tLadderFilter; + } tLadderFilter; // Memory handlers for `tLadderFilter` - void tLadderFilter_init (tLadderFilter* const, Lfloat freq, Lfloat Q, LEAF* const leaf); - void tLadderFilter_initToPool (tLadderFilter* const, Lfloat freq, Lfloat Q, tMempool* const); - void tLadderFilter_free (tLadderFilter* const); + void tLadderFilter_init (tLadderFilter** const, Lfloat freq, Lfloat Q, LEAF* const leaf); + void tLadderFilter_initToPool (tLadderFilter** const, Lfloat freq, Lfloat Q, tMempool* const); + void tLadderFilter_free (tLadderFilter** const); // Tick function for `tLadderFilter` - Lfloat tLadderFilter_tick (tLadderFilter const, Lfloat input); + Lfloat tLadderFilter_tick (tLadderFilter* const, Lfloat input); // Setter functions for `tLadderFilter` - void tLadderFilter_setFreq (tLadderFilter const vf, Lfloat cutoff); - void tLadderFilter_setFreqFast (tLadderFilter const vf, Lfloat cutoff); - void tLadderFilter_setQ (tLadderFilter const vf, Lfloat resonance); - void tLadderFilter_setSampleRate (tLadderFilter const vf, Lfloat sr); - void tLadderFilter_setOversampling (tLadderFilter const vf, int os); + void tLadderFilter_setFreq (tLadderFilter* const vf, Lfloat cutoff); + void tLadderFilter_setFreqFast (tLadderFilter* const vf, Lfloat cutoff); + void tLadderFilter_setQ (tLadderFilter* const vf, Lfloat resonance); + void tLadderFilter_setSampleRate (tLadderFilter* const vf, Lfloat sr); + void tLadderFilter_setOversampling (tLadderFilter* const vf, int os); //tilt filter - typedef struct _tTiltFilter + typedef struct tTiltFilter { tMempool mempool; Lfloat cutoff; @@ -1669,21 +1621,19 @@ extern "C" { Lfloat lgain; Lfloat hgain; Lfloat invAmp; - } _tTiltFilter; - - typedef _tTiltFilter* tTiltFilter; + } tTiltFilter; // Memory handlers for `tTiltFilter` - void tTiltFilter_init (tTiltFilter* const, Lfloat freq, LEAF* const leaf); - void tTiltFilter_initToPool (tTiltFilter* const, Lfloat freq, tMempool* const); - void tTiltFilter_free (tTiltFilter* const); + void tTiltFilter_init (tTiltFilter** const, Lfloat freq, LEAF* const leaf); + void tTiltFilter_initToPool (tTiltFilter** const, Lfloat freq, tMempool* const); + void tTiltFilter_free (tTiltFilter** const); // Tick function for `tTiltFilter` - Lfloat tTiltFilter_tick (tTiltFilter const, Lfloat input); + Lfloat tTiltFilter_tick (tTiltFilter* const, Lfloat input); // Setter functions for `tTiltFilter` - void tTiltFilter_setTilt (tTiltFilter const vf, Lfloat tilt); - void tTiltFilter_setSampleRate (tTiltFilter const vf, Lfloat sr); + void tTiltFilter_setTilt (tTiltFilter* const vf, Lfloat tilt); + void tTiltFilter_setSampleRate (tTiltFilter* const vf, Lfloat sr); #ifdef __cplusplus diff --git a/leaf/Inc/leaf-global.h b/leaf/Inc/leaf-global.h index ad8463a..76cf691 100644 --- a/leaf/Inc/leaf-global.h +++ b/leaf/Inc/leaf-global.h @@ -22,9 +22,8 @@ extern "C" { #else #include "../leaf-config.h" #endif + typedef struct tLookupTable tLookupTable; - - typedef struct _tLookupTable* tLookupTable; /*! * @ingroup leaf * @brief Struct for an instance of LEAF. @@ -32,7 +31,7 @@ extern "C" { struct LEAF { - ///@{ + ///@{ Lfloat sampleRate; //!< The current audio sample rate. Set with LEAF_setSampleRate(). Lfloat invSampleRate; //!< The inverse of the current sample rate. Lfloat twoPiTimesInvSampleRate; //!< Two-pi times the inverse of the current sample rate. @@ -46,9 +45,9 @@ extern "C" { unsigned int allocCount; //!< A count of LEAF memory allocations. unsigned int freeCount; //!< A count of LEAF memory frees. unsigned int uuid; - tLookupTable lfoRateTable; - tLookupTable envTimeTable; - tLookupTable resTable; + tLookupTable* lfoRateTable; + tLookupTable* envTimeTable; + tLookupTable* resTable; ///@} }; diff --git a/leaf/Inc/leaf-instruments.h b/leaf/Inc/leaf-instruments.h index 782b2e6..4152907 100644 --- a/leaf/Inc/leaf-instruments.h +++ b/leaf/Inc/leaf-instruments.h @@ -85,7 +85,7 @@ extern "C" { @} */ - typedef struct _t808Cowbell + typedef struct t808Cowbell { tMempool mempool; tSquare p[2]; @@ -99,24 +99,22 @@ extern "C" { Lfloat oscMix; Lfloat filterCutoff; uint8_t useStick; - } _t808Cowbell; - - typedef _t808Cowbell* t808Cowbell; - - void t808Cowbell_init (t808Cowbell* const, int useStick, LEAF* const leaf); - void t808Cowbell_initToPool (t808Cowbell* const, int useStick, tMempool* const); - void t808Cowbell_free (t808Cowbell* const); + } t808Cowbell; + + void t808Cowbell_init (t808Cowbell** const, int useStick, LEAF* const leaf); + void t808Cowbell_initToPool (t808Cowbell** const, int useStick, tMempool* const); + void t808Cowbell_free (t808Cowbell** const); - Lfloat t808Cowbell_tick (t808Cowbell const); + Lfloat t808Cowbell_tick (t808Cowbell* const); - void t808Cowbell_on (t808Cowbell const, Lfloat vel); - void t808Cowbell_setDecay (t808Cowbell const, Lfloat decay); - void t808Cowbell_setHighpassFreq (t808Cowbell const, Lfloat freq); - void t808Cowbell_setBandpassFreq (t808Cowbell const, Lfloat freq); - void t808Cowbell_setFreq (t808Cowbell const, Lfloat freq); - void t808Cowbell_setOscMix (t808Cowbell const, Lfloat oscMix); - void t808Cowbell_setStick (t808Cowbell const, int useStick); - void t808Cowbell_setSampleRate (t808Cowbell const, Lfloat sr); + void t808Cowbell_on (t808Cowbell* const, Lfloat vel); + void t808Cowbell_setDecay (t808Cowbell* const, Lfloat decay); + void t808Cowbell_setHighpassFreq (t808Cowbell* const, Lfloat freq); + void t808Cowbell_setBandpassFreq (t808Cowbell* const, Lfloat freq); + void t808Cowbell_setFreq (t808Cowbell* const, Lfloat freq); + void t808Cowbell_setOscMix (t808Cowbell* const, Lfloat oscMix); + void t808Cowbell_setStick (t808Cowbell* const, int useStick); + void t808Cowbell_setSampleRate (t808Cowbell* const, Lfloat sr); //============================================================================== @@ -190,7 +188,7 @@ extern "C" { @} */ - typedef struct _t808Hihat + typedef struct t808Hihat { tMempool mempool; @@ -209,28 +207,26 @@ extern "C" { Lfloat stretch; Lfloat FM_amount; Lfloat oscNoiseMix; - } _t808Hihat; - - typedef _t808Hihat* t808Hihat; - - void t808Hihat_init (t808Hihat* const, LEAF* const leaf); - void t808Hihat_initToPool (t808Hihat* const, tMempool* const); - void t808Hihat_free (t808Hihat* const); + } t808Hihat; + + void t808Hihat_init (t808Hihat** const, LEAF* const leaf); + void t808Hihat_initToPool (t808Hihat** const, tMempool* const); + void t808Hihat_free (t808Hihat** const); - Lfloat t808Hihat_tick (t808Hihat const); + Lfloat t808Hihat_tick (t808Hihat* const); - void t808Hihat_on (t808Hihat const, Lfloat vel); - void t808Hihat_setOscNoiseMix (t808Hihat const, Lfloat oscNoiseMix); - void t808Hihat_setDecay (t808Hihat const, Lfloat decay); - void t808Hihat_setHighpassFreq (t808Hihat const, Lfloat freq); - void t808Hihat_setOscBandpassFreq (t808Hihat const, Lfloat freq); - void t808Hihat_setOscBandpassQ (t808Hihat const hihat, Lfloat Q); - void t808Hihat_setStickBandPassFreq (t808Hihat const, Lfloat freq); - void t808Hihat_setStickBandPassQ (t808Hihat const hihat, Lfloat Q); - void t808Hihat_setOscFreq (t808Hihat const, Lfloat freq); - void t808Hihat_setStretch (t808Hihat const hihat, Lfloat stretch); - void t808Hihat_setFM (t808Hihat const hihat, Lfloat FM_amount); - void t808Hihat_setSampleRate (t808Hihat const, Lfloat sr); + void t808Hihat_on (t808Hihat* const, Lfloat vel); + void t808Hihat_setOscNoiseMix (t808Hihat* const, Lfloat oscNoiseMix); + void t808Hihat_setDecay (t808Hihat* const, Lfloat decay); + void t808Hihat_setHighpassFreq (t808Hihat* const, Lfloat freq); + void t808Hihat_setOscBandpassFreq (t808Hihat* const, Lfloat freq); + void t808Hihat_setOscBandpassQ (t808Hihat* const hihat, Lfloat Q); + void t808Hihat_setStickBandPassFreq (t808Hihat* const, Lfloat freq); + void t808Hihat_setStickBandPassQ (t808Hihat* const hihat, Lfloat Q); + void t808Hihat_setOscFreq (t808Hihat* const, Lfloat freq); + void t808Hihat_setStretch (t808Hihat* const hihat, Lfloat stretch); + void t808Hihat_setFM (t808Hihat* const hihat, Lfloat FM_amount); + void t808Hihat_setSampleRate (t808Hihat* const, Lfloat sr); //============================================================================== @@ -296,7 +292,7 @@ extern "C" { @} */ - typedef struct _t808Snare + typedef struct t808Snare { tMempool mempool; @@ -319,26 +315,24 @@ extern "C" { Lfloat tone1Freq, tone2Freq; Lfloat noiseFilterFreq; - } _t808Snare; - - typedef _t808Snare* t808Snare; - - void t808Snare_init (t808Snare* const, LEAF* const leaf); - void t808Snare_initToPool (t808Snare* const, tMempool* const); - void t808Snare_free (t808Snare* const); + } t808Snare; + + void t808Snare_init (t808Snare** const, LEAF* const leaf); + void t808Snare_initToPool (t808Snare** const, tMempool* const); + void t808Snare_free (t808Snare** const); - Lfloat t808Snare_tick (t808Snare const); + Lfloat t808Snare_tick (t808Snare* const); - void t808Snare_on (t808Snare const, Lfloat vel); - void t808Snare_setTone1Freq (t808Snare const, Lfloat freq); - void t808Snare_setTone2Freq (t808Snare const, Lfloat freq); - void t808Snare_setTone1Decay (t808Snare const, Lfloat decay); - void t808Snare_setTone2Decay (t808Snare const, Lfloat decay); - void t808Snare_setNoiseDecay (t808Snare const, Lfloat decay); - void t808Snare_setToneNoiseMix (t808Snare const, Lfloat toneNoiseMix); - void t808Snare_setNoiseFilterFreq (t808Snare const, Lfloat noiseFilterFreq); - void t808Snare_setNoiseFilterQ (t808Snare const, Lfloat noiseFilterQ); - void t808Snare_setSampleRate (t808Snare const, Lfloat sr); + void t808Snare_on (t808Snare* const, Lfloat vel); + void t808Snare_setTone1Freq (t808Snare* const, Lfloat freq); + void t808Snare_setTone2Freq (t808Snare* const, Lfloat freq); + void t808Snare_setTone1Decay (t808Snare* const, Lfloat decay); + void t808Snare_setTone2Decay (t808Snare* const, Lfloat decay); + void t808Snare_setNoiseDecay (t808Snare* const, Lfloat decay); + void t808Snare_setToneNoiseMix (t808Snare* const, Lfloat toneNoiseMix); + void t808Snare_setNoiseFilterFreq (t808Snare* const, Lfloat noiseFilterFreq); + void t808Snare_setNoiseFilterQ (t808Snare* const, Lfloat noiseFilterQ); + void t808Snare_setSampleRate (t808Snare* const, Lfloat sr); //============================================================================== //============================================================================== @@ -405,7 +399,7 @@ extern "C" { @} */ - typedef struct _t808SnareSmall + typedef struct t808SnareSmall { tMempool mempool; @@ -428,26 +422,24 @@ extern "C" { Lfloat tone1Freq, tone2Freq; Lfloat noiseFilterFreq; - } _t808SnareSmall; - - typedef _t808SnareSmall* t808SnareSmall; - - void t808SnareSmall_init (t808SnareSmall* const, LEAF* const leaf); - void t808SnareSmall_initToPool (t808SnareSmall* const, tMempool* const); - void t808SnareSmall_free (t808SnareSmall* const); + } t808SnareSmall; + + void t808SnareSmall_init (t808SnareSmall** const, LEAF* const leaf); + void t808SnareSmall_initToPool (t808SnareSmall** const, tMempool* const); + void t808SnareSmall_free (t808SnareSmall** const); - Lfloat t808SnareSmall_tick (t808SnareSmall const); + Lfloat t808SnareSmall_tick (t808SnareSmall* const); - void t808SnareSmall_on (t808SnareSmall const, Lfloat vel); - void t808SnareSmall_setTone1Freq (t808SnareSmall const, Lfloat freq); - void t808SnareSmall_setTone2Freq (t808SnareSmall const, Lfloat freq); - void t808SnareSmall_setTone1Decay (t808SnareSmall const, Lfloat decay); - void t808SnareSmall_setTone2Decay (t808SnareSmall const, Lfloat decay); - void t808SnareSmall_setNoiseDecay (t808SnareSmall const, Lfloat decay); - void t808SnareSmall_setToneNoiseMix (t808SnareSmall const, Lfloat toneNoiseMix); - void t808SnareSmall_setNoiseFilterFreq (t808SnareSmall const, Lfloat noiseFilterFreq); - void t808SnareSmall_setNoiseFilterQ (t808SnareSmall const, Lfloat noiseFilterQ); - void t808SnareSmall_setSampleRate (t808SnareSmall const, Lfloat sr); + void t808SnareSmall_on (t808SnareSmall* const, Lfloat vel); + void t808SnareSmall_setTone1Freq (t808SnareSmall* const, Lfloat freq); + void t808SnareSmall_setTone2Freq (t808SnareSmall* const, Lfloat freq); + void t808SnareSmall_setTone1Decay (t808SnareSmall* const, Lfloat decay); + void t808SnareSmall_setTone2Decay (t808SnareSmall* const, Lfloat decay); + void t808SnareSmall_setNoiseDecay (t808SnareSmall* const, Lfloat decay); + void t808SnareSmall_setToneNoiseMix (t808SnareSmall* const, Lfloat toneNoiseMix); + void t808SnareSmall_setNoiseFilterFreq (t808SnareSmall* const, Lfloat noiseFilterFreq); + void t808SnareSmall_setNoiseFilterQ (t808SnareSmall* const, Lfloat noiseFilterQ); + void t808SnareSmall_setSampleRate (t808SnareSmall* const, Lfloat sr); //============================================================================== /*! @@ -512,7 +504,7 @@ extern "C" { @} */ - typedef struct _t808Kick + typedef struct t808Kick { tMempool mempool; @@ -533,26 +525,24 @@ extern "C" { Lfloat sighAmountInHz; Lfloat chirpRatioMinusOne; Lfloat noiseFilterFreq; - } _t808Kick; - - typedef _t808Kick* t808Kick; - - void t808Kick_init (t808Kick* const, LEAF* const leaf); - void t808Kick_initToPool (t808Kick* const, tMempool* const); - void t808Kick_free (t808Kick* const); + } t808Kick; + + void t808Kick_init (t808Kick** const, LEAF* const leaf); + void t808Kick_initToPool (t808Kick** const, tMempool* const); + void t808Kick_free (t808Kick** const); - Lfloat t808Kick_tick (t808Kick const); + Lfloat t808Kick_tick (t808Kick* const); - void t808Kick_on (t808Kick const, Lfloat vel); - void t808Kick_setToneFreq (t808Kick const, Lfloat freq); - void t808Kick_setToneDecay (t808Kick const, Lfloat decay); - void t808Kick_setNoiseDecay (t808Kick const, Lfloat decay); - void t808Kick_setSighAmount (t808Kick const, Lfloat sigh); - void t808Kick_setChirpAmount (t808Kick const, Lfloat chirp); - void t808Kick_setToneNoiseMix (t808Kick const, Lfloat toneNoiseMix); - void t808Kick_setNoiseFilterFreq (t808Kick const, Lfloat noiseFilterFreq); - void t808Kick_setNoiseFilterQ (t808Kick const, Lfloat noiseFilterQ); - void t808kick_setSampleRate (t808Kick const, Lfloat sr); + void t808Kick_on (t808Kick* const, Lfloat vel); + void t808Kick_setToneFreq (t808Kick* const, Lfloat freq); + void t808Kick_setToneDecay (t808Kick* const, Lfloat decay); + void t808Kick_setNoiseDecay (t808Kick* const, Lfloat decay); + void t808Kick_setSighAmount (t808Kick* const, Lfloat sigh); + void t808Kick_setChirpAmount (t808Kick* const, Lfloat chirp); + void t808Kick_setToneNoiseMix (t808Kick* const, Lfloat toneNoiseMix); + void t808Kick_setNoiseFilterFreq (t808Kick* const, Lfloat noiseFilterFreq); + void t808Kick_setNoiseFilterQ (t808Kick* const, Lfloat noiseFilterQ); + void t808kick_setSampleRate (t808Kick* const, Lfloat sr); //============================================================================== @@ -619,7 +609,7 @@ extern "C" { @} */ - typedef struct _t808KickSmall + typedef struct t808KickSmall { tMempool mempool; @@ -640,26 +630,24 @@ extern "C" { Lfloat sighAmountInHz; Lfloat chirpRatioMinusOne; Lfloat noiseFilterFreq; - } _t808KickSmall; - - typedef _t808KickSmall* t808KickSmall; - - void t808KickSmall_init (t808KickSmall* const, LEAF* const leaf); - void t808KickSmall_initToPool (t808KickSmall* const, tMempool* const); - void t808KickSmall_free (t808KickSmall* const); + } t808KickSmall; + + void t808KickSmall_init (t808KickSmall** const, LEAF* const leaf); + void t808KickSmall_initToPool (t808KickSmall** const, tMempool* const); + void t808KickSmall_free (t808KickSmall** const); - Lfloat t808KickSmall_tick (t808KickSmall const); + Lfloat t808KickSmall_tick (t808KickSmall* const); - void t808KickSmall_on (t808KickSmall const, Lfloat vel); - void t808KickSmall_setToneFreq (t808KickSmall const, Lfloat freq); - void t808KickSmall_setToneDecay (t808KickSmall const, Lfloat decay); - void t808KickSmall_setNoiseDecay (t808KickSmall const, Lfloat decay); - void t808KickSmall_setSighAmount (t808KickSmall const, Lfloat sigh); - void t808KickSmall_setChirpAmount (t808KickSmall const, Lfloat chirp); - void t808KickSmall_setToneNoiseMix (t808KickSmall const, Lfloat toneNoiseMix); - void t808KickSmall_setNoiseFilterFreq (t808KickSmall const, Lfloat noiseFilterFreq); - void t808KickSmall_setNoiseFilterQ (t808KickSmall const, Lfloat noiseFilterQ); - void t808KickSmall_setSampleRate (t808KickSmall const, Lfloat sr); + void t808KickSmall_on (t808KickSmall* const, Lfloat vel); + void t808KickSmall_setToneFreq (t808KickSmall* const, Lfloat freq); + void t808KickSmall_setToneDecay (t808KickSmall* const, Lfloat decay); + void t808KickSmall_setNoiseDecay (t808KickSmall* const, Lfloat decay); + void t808KickSmall_setSighAmount (t808KickSmall* const, Lfloat sigh); + void t808KickSmall_setChirpAmount (t808KickSmall* const, Lfloat chirp); + void t808KickSmall_setToneNoiseMix (t808KickSmall* const, Lfloat toneNoiseMix); + void t808KickSmall_setNoiseFilterFreq (t808KickSmall* const, Lfloat noiseFilterFreq); + void t808KickSmall_setNoiseFilterQ (t808KickSmall* const, Lfloat noiseFilterQ); + void t808KickSmall_setSampleRate (t808KickSmall* const, Lfloat sr); //============================================================================== diff --git a/leaf/Inc/leaf-midi copy.h b/leaf/Inc/leaf-midi copy.h deleted file mode 100644 index 735da46..0000000 --- a/leaf/Inc/leaf-midi copy.h +++ /dev/null @@ -1,443 +0,0 @@ -/*============================================================================== - - leaf-midi.h - Created: 30 Nov 2018 11:29:26am - Author: airship - - ==============================================================================*/ - -#ifndef LEAF_MIDI_H_INCLUDED -#define LEAF_MIDI_H_INCLUDED - -#ifdef __cplusplus -extern "C" { -#endif - - //============================================================================== - -#include "leaf-global.h" -#include "leaf-mempool.h" -#include "leaf-math.h" -#include "leaf-envelopes.h" - - /*! - * @internal - * Header. - * @include basic-oscillators.h - * @example basic-oscillators.c - * An example. - */ - - //============================================================================== - - // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - - /*! - @defgroup tstack tStack - @ingroup midi - @brief A basic stack of integers with a fixed capacity of 128, used by tPoly to keep track of MIDI notes. - @{ - - @fn void tStack_init (tStack* const stack, LEAF* const leaf) - @brief Initialize a tStack to the default mempool of a LEAF instance. - @param stack A pointer to the tStack to initialize. - @param leaf A pointer to the leaf instance. - - @fn void tStack_initToPool (tStack* const stack, tMempool* const mempool) - @brief Initialize a tStack to a specified mempool. - @param stack A pointer to the tStack to initialize. - @param mempool A pointer to the tMempool to use. - - @fn void tStack_free (tStack* const stack) - @brief Free a tStack from its mempool. - @param stack A pointer to the tStack to free. - - @fn void tStack_setCapacity (tStack* const stack, uint16_t cap) - @brief Set the capacity of the stack. - @param stack A pointer to the relevant tStack. - @param cap The new capacity. - - @fn int tStack_addIfNotAlreadyThere (tStack* const stack, uint16_t item) - @brief Add a value to the stack only if that value is not already in the stack. - @param stack A pointer to the relevant tStack. - @param item The value to be added. - - @fn void tStack_add (tStack* const stack, uint16_t item) - @brief Add a value to the stack. - @param stack A pointer to the relevant tStack. - @param item The value to be added. - - @fn int tStack_remove (tStack* const stack, uint16_t item) - @brief Remove a single instance of a value from the stack. - @param stack A pointer to the relevant tStack. - @param item The value to be removed. - - @fn void tStack_clear (tStack* const stack) - @brief Clear the stack. - @param stack A pointer to the relevant tStack. - - @fn int tStack_first (tStack* const stack) - @brief Get the first value in the stack. - @param stack A pointer to the relevant tStack. - @return The first value in the stack. - - @fn int tStack_getSize (tStack* const stack) - @brief Get the current size of the stack. - @param stack A pointer to the relevant tStack. - @return The current size of the stack. - - @fn int tStack_contains (tStack* const stack, uint16_t item) - @brief Check if the stack contains a value, and if it does, get the index of that value. - @param stack A pointer to the relevant tStack. - @param item The value to check against the stack. - @return The index of the value or -1 if the stack does not contain the value. - - @fn int tStack_next (tStack* const stack) - @brief Get the next value in the stack, starting from the earliest added values. - @param stack A pointer to the relevant tStack. - @return The next value in the stack or -1 if there are no values in the stack. - - @fn int tStack_get (tStack* const stack, int index) - @brief Get the value at a given index of the stack. - @param stack A pointer to the relevant tStack. - @param index The index of the stack from which to get a value. - @return The value at the given index. - - @} */ - -#define STACK_SIZE 128 - typedef struct _tStack - { - - tMempool mempool; - int data[STACK_SIZE]; - uint16_t pos; - uint16_t size; - uint16_t capacity; - int ordered; - } _tStack; - - typedef _tStack* tStack; - - void tStack_init (tStack* const stack, LEAF* const leaf); - void tStack_initToPool (tStack* const stack, tMempool* const pool); - void tStack_free (tStack* const stack); - - void tStack_setCapacity (tStack* const stack, uint16_t cap); - int tStack_addIfNotAlreadyThere (tStack* const stack, uint16_t item); - void tStack_add (tStack* const stack, uint16_t item); - int tStack_remove (tStack* const stack, uint16_t item); - void tStack_clear (tStack* const stack); - int tStack_first (tStack* const stack); - int tStack_getSize (tStack* const stack); - int tStack_contains (tStack* const stack, uint16_t item); - int tStack_next (tStack* const stack); - int tStack_get (tStack* const stack, int index); - - /*! @} - @defgroup tpoly tPoly - @ingroup midi - @brief Polyphony handler with glide and pitch bend options. - @{ - - @fn void tPoly_init (tPoly* const poly, int maxNumVoices, LEAF* const leaf) - @brief Initialize a tPoly to the default mempool of a LEAF instance. - @param poly A pointer to the tPoly to initialize. - @param maxNumVoices The maximum number of voices this tPoly can handle at once. - @param leaf A pointer to the leaf instance. - - @fn void tPoly_initToPool (tPoly* const poly, int maxNumVoices, tMempool* const pool) - @brief Initialize a tPoly to a specified mempool. - @param poly A pointer to the tPoly to initialize. - @param mempool A pointer to the tMempool to use. - - @fn void tPoly_free (tPoly* const poly) - @brief Free a tPoly from its mempool. - @param poly A pointer to the tPoly to free. - - @fn int tPoly_noteOn (tPoly* const poly, int note, uint8_t vel) - @brief Add a note with a given velocity to the poly handler. - @param poly A pointer to the relevant tPoly. - @param note The MIDI note number to add. - @param vel The MIDI velocity of the note to add. - @return The voice that will play the note. - - @fn int tPoly_noteOff (tPoly* const poly, uint8_t note) - @brief Remove a note from the poly handler. - @param poly A pointer to the relevant tPoly. - @param note The MIDI note number to remove. - @return The voice that was playing the removed note. - - @fn void tPoly_orderedAddToStack (tPoly* const poly, uint8_t note) - @brief - @param - - @fn void tPoly_setNumVoices (tPoly* const poly, uint8_t numVoices) - @brief Set the number of voices available to play notes. - @param poly A pointer to the relevant tPoly. - @param numVoices The new number of available voices. Cannot be greater than the max number voices given in tPoly_init(). - - @fn void tPoly_setPitchGlideActive (tPoly* const poly, int isActive) - @brief Set whether pitch glide over note changes in voices is active. - @param poly A pointer to the relevant tPoly. - @param isActive Whether pitch glide should be active or not. - - @fn void tPoly_setPitchGlideTime (tPoly* const poly, Lfloat t) - @brief Set how long pitch glide over note changes in voices takes. - @param poly A pointer to the relevant tPoly. - @param t The time to glide in milliseconds. - - @fn void tPoly_setPitchBend (tPoly* const poly, Lfloat pitchBend) - @brief Set the amount of pitch bend - @param poly A pointer to the relevant tPoly. - @param pitchBend The new amount of pitch bend. - - @fn void tPoly_setBendGlideTime (tPoly* const poly, Lfloat t) - @brief - @param - - @fn void tPoly_setBendSamplesPerTick (tPoly* const poly, Lfloat t) - @brief - @param - - @fn void tPoly_tickPitch (tPoly* const poly) - @brief Execute all tick-rate changes in the poly handler's pitch, including glide and bend. - @param poly A pointer to the relevant tPoly. - - @fn void tPoly_tickPitchGlide (tPoly* const poly) - @brief Execute the tick-rate change of the poly handler's pitch glide. - @param poly A pointer to the relevant tPoly. - - @fn void tPoly_tickPitchBend (tPoly* const poly) - @brief Execute the tick-rate change of the poly handler's pitch bend. - @param poly A pointer to the relevant tPoly. - - @fn int tPoly_getNumVoices (tPoly* const poly) - @brief Get the current number of voices available to play notes. - @param poly A pointer to the relevant tPoly. - @return The current number of voices available to play notes. - - @fn int tPoly_getNumActiveVoices (tPoly* const poly) - @brief Get the number of voices currently playing notes. - @param poly A pointer to the relevant tPoly. - @return The number of voices currently playing notes. - - @fn Lfloat tPoly_getPitch (tPoly* const poly, uint8_t voice) - @brief Get the current pitch of a given voice. - @param poly A pointer to the relevant tPoly. - @param voice The voice to get the pitch of. - @return The current pitch of the given voice as a fractional MIDI note number. - - @fn int tPoly_getKey (tPoly* const poly, uint8_t voice) - @brief Get the current MIDI note number of a given voice. - @param poly A pointer to the relevant tPoly. - @param voice The voice to get the MIDI note number of. - @return The MIDI note number of the given voice. - - @fn int tPoly_getVelocity (tPoly* const poly, uint8_t voice) - @brief Get the current MIDI velocity of a given voice. - @param poly A pointer to the relevant tPoly. - @param voice The voice to get the MIDI velocity of. - @return The current MIDI velocity of the given voice. - - @fn int tPoly_isOn (tPoly* const poly, uint8_t voice) - @brief Get the current play state of a given voice. - @param poly A pointer to the relevant tPoly. - @param voice The voice to get the state of. - @return The current play state of the given voice. - - @} */ - - typedef struct _tPoly - { - - tMempool mempool; - - tStack stack; - tStack orderStack; - - tRamp* ramps; - Lfloat* rampVals; - int* firstReceived; - Lfloat glideTime; - int pitchGlideIsActive; - - int numVoices; - int maxNumVoices; - - //int voices[POLY_NUM_MAX_VOICES][2]; - int** voices; - - int notes[128][2]; - - int CCs[128]; - - uint8_t CCsRaw[128]; - - int lastVoiceToChange; - - Lfloat pitchBend; - tRamp pitchBendRamp; - - int currentNote; - int currentVoice; - int currentVelocity; - int maxLength; - } _tPoly; - - typedef _tPoly* tPoly; - - void tPoly_init (tPoly* const poly, int maxNumVoices, LEAF* const leaf); - void tPoly_initToPool (tPoly* const poly, int maxNumVoices, tMempool* const pool); - void tPoly_free (tPoly* const poly); - - int tPoly_noteOn (tPoly* const poly, int note, uint8_t vel); - int tPoly_noteOff (tPoly* const poly, uint8_t note); - void tPoly_orderedAddToStack (tPoly* const poly, uint8_t note); - void tPoly_setNumVoices (tPoly* const poly, uint8_t numVoices); - void tPoly_setPitchGlideActive (tPoly* const poly, int isActive); - void tPoly_setPitchGlideTime (tPoly* const poly, Lfloat t); - void tPoly_setPitchBend (tPoly* const poly, Lfloat pitchBend); - void tPoly_setBendGlideTime (tPoly* const poly, Lfloat t); - void tPoly_setBendSamplesPerTick (tPoly* const poly, Lfloat t); - void tPoly_tickPitch (tPoly* const poly); - void tPoly_tickPitchGlide (tPoly* const poly); - void tPoly_tickPitchBend (tPoly* const poly); - int tPoly_getNumVoices (tPoly* const poly); - int tPoly_getNumActiveVoices (tPoly* const poly); - Lfloat tPoly_getPitch (tPoly* const poly, uint8_t voice); - int tPoly_getKey (tPoly* const poly, uint8_t voice); - int tPoly_getVelocity (tPoly* const poly, uint8_t voice); - int tPoly_isOn (tPoly* const poly, uint8_t voice); - void tPoly_setSampleRate (tPoly* const poly, Lfloat sr); - - //============================================================================== - - /*! @} - @defgroup tsimplepoly tSimplePoly - @ingroup midi - @brief Polyphony handler. - @{ - - @fn void tSimplePoly_init (tSimplePoly* const poly, int maxNumVoices, LEAF* const leaf) - @brief Initialize a tSimplePoly to the default mempool of a LEAF instance. - @param poly A pointer to the tSimplePoly to initialize. - @param maxNumVoices The maximum number of voices this tSimplePoly can handle at once. - @param leaf A pointer to the leaf instance. - - @fn void tSimplePoly_initToPool (tSimplePoly* const poly, int maxNumVoices, tMempool* const pool) - @brief Initialize a tSimplePoly to a specified mempool. - @param poly A pointer to the tSimplePoly to initialize. - @param mempool A pointer to the tMempool to use. - - @fn void tSimplePoly_free (tSimplePoly* const poly) - @brief Free a tSimplePoly from its mempool. - @param poly A pointer to the tSimplePoly to free. - - @fn int tSimplePoly_noteOn (tSimplePoly* const poly, int note, uint8_t vel) - @brief Add a note with a given velocity to the poly handler. - @param poly A pointer to the relevant tSimplePoly. - @param note The MIDI note number to add. - @param vel The MIDI velocity of the note to add. - @return The voice that will play the note. - - @fn int tSimplePoly_noteOff (tSimplePoly* const poly, uint8_t note) - @brief Remove a note from the poly handler. - @param poly A pointer to the relevant tSimplePoly. - @param note The MIDI note number to remove. - @return The voice that was playing the removed note. - - @fn void tSimplePoly_deactivateVoice(tSimplePoly* const polyh, uint8_t voice) - @brief - @param - - @fn int tSimplePoly_markPendingNoteOff(tSimplePoly* const polyh, uint8_t note) - @brief - @param - - @fn int tSimplePoly_findVoiceAssignedToNote(tSimplePoly* const polyh, uint8_t note) - @brief Find if there is a voice with that note -- useful for note offs where you want to wait to remove it from the poly until the release phase of the envelope is finished - @param - - @fn void tSimplePoly_setNumVoices (tSimplePoly* const poly, uint8_t numVoices) - @brief Set the number of voices available to play notes. - @param poly A pointer to the relevant tSimplePoly. - @param numVoices The new number of available voices. Cannot be greater than the max number voices given on initialization. - - @fn int tSimplePoly_getNumVoices (tSimplePoly* const poly) - @brief Get the current number of voices available to play notes. - @param poly A pointer to the relevant tSimplePoly. - @return The current number of voices available to play notes. - - @fn int tSimplePoly_getNumActiveVoices (tSimplePoly* const poly) - @brief Get the number of voices currently playing notes. - @param poly A pointer to the relevant tSimplePoly. - @return The number of voices currently playing notes. - - @fn int tSimplePoly_getPitch (tSimplePoly* const poly, uint8_t voice) - @brief Get the current MIDI note number of a given voice. - @param poly A pointer to the relevant tSimplePoly. - @param voice The voice to get the MIDI note number of. - @return The MIDI note number of the given voice. - - @fn int tSimplePoly_getPitchAndCheckActive(tSimplePoly* const polyh, uint8_t voice) - @brief Returns negative one if the voice is inactive - - @fn int tSimplePoly_getVelocity (tSimplePoly* const poly, uint8_t voice) - @brief Get the current MIDI velocity of a given voice. - @param poly A pointer to the relevant tSimplePoly. - @param voice The voice to get the MIDI velocity of. - @return The current MIDI velocity of the given voice. - - @fn int tSimplePoly_isOn (tSimplePoly* const poly, uint8_t voice) - @brief Get the current play state of a given voice. - @param poly A pointer to the relevant tSimplePoly. - @param voice The voice to get the state of. - @return The current play state of the given voice. - - @} */ - typedef struct _tSimplePoly - { - tMempool mempool; - - tStack stack; - - int numVoices; - int maxNumVoices; - int** voices; - int stealing_on; - int recover_stolen; - - int notes[128][2]; - } _tSimplePoly; - - typedef _tSimplePoly* tSimplePoly; - - void tSimplePoly_init (tSimplePoly* const poly, int maxNumVoices, LEAF* const leaf); - void tSimplePoly_initToPool (tSimplePoly* const poly, int maxNumVoices, tMempool* const pool); - void tSimplePoly_free (tSimplePoly* const poly); - - int tSimplePoly_noteOn (tSimplePoly* const poly, int note, uint8_t vel); - int tSimplePoly_noteOff (tSimplePoly* const poly, uint8_t note); - void tSimplePoly_deactivateVoice (tSimplePoly* const polyh, uint8_t voice); - int tSimplePoly_markPendingNoteOff (tSimplePoly* const polyh, uint8_t note); - int tSimplePoly_findVoiceAssignedToNote (tSimplePoly* const polyh, uint8_t note); - void tSimplePoly_setNumVoices (tSimplePoly* const poly, uint8_t numVoices); - int tSimplePoly_getNumVoices (tSimplePoly* const poly); - int tSimplePoly_getNumActiveVoices (tSimplePoly* const poly); - int tSimplePoly_getPitch (tSimplePoly* const poly, uint8_t voice); - int tSimplePoly_getPitchAndCheckActive(tSimplePoly* const polyh, uint8_t voice); - int tSimplePoly_getVelocity (tSimplePoly* const poly, uint8_t voice); - int tSimplePoly_isOn (tSimplePoly* const poly, uint8_t voice); - - //============================================================================== - -#ifdef __cplusplus -} -#endif - -#endif // LEAF_MIDI_H_INCLUDED - -//============================================================================== - - diff --git a/leaf/Inc/leaf-midi.h b/leaf/Inc/leaf-midi.h index cda9115..4ee4a9f 100644 --- a/leaf/Inc/leaf-midi.h +++ b/leaf/Inc/leaf-midi.h @@ -106,7 +106,7 @@ extern "C" { @} */ #define STACK_SIZE 128 - typedef struct _tStack + typedef struct tStack { tMempool mempool; @@ -115,24 +115,22 @@ extern "C" { uint16_t size; uint16_t capacity; int ordered; - } _tStack; - - typedef _tStack* tStack; - - void tStack_init (tStack* const stack, LEAF* const leaf); - void tStack_initToPool (tStack* const stack, tMempool* const pool); - void tStack_free (tStack* const stack); + } tStack; + + void tStack_init (tStack** const stack, LEAF* const leaf); + void tStack_initToPool (tStack** const stack, tMempool* const pool); + void tStack_free (tStack** const stack); - void tStack_setCapacity (tStack const stack, uint16_t cap); - int tStack_addIfNotAlreadyThere (tStack const stack, uint16_t item); - void tStack_add (tStack const stack, uint16_t item); - int tStack_remove (tStack const stack, uint16_t item); - void tStack_clear (tStack const stack); - int tStack_first (tStack const stack); - int tStack_getSize (tStack const stack); - int tStack_contains (tStack const stack, uint16_t item); - int tStack_next (tStack const stack); - int tStack_get (tStack const stack, int index); + void tStack_setCapacity (tStack* const stack, uint16_t cap); + int tStack_addIfNotAlreadyThere (tStack* const stack, uint16_t item); + void tStack_add (tStack* const stack, uint16_t item); + int tStack_remove (tStack* const stack, uint16_t item); + void tStack_clear (tStack* const stack); + int tStack_first (tStack* const stack); + int tStack_getSize (tStack* const stack); + int tStack_contains (tStack* const stack, uint16_t item); + int tStack_next (tStack* const stack); + int tStack_get (tStack* const stack, int index); /*! @} @defgroup tpoly tPoly @@ -248,7 +246,7 @@ extern "C" { @} */ - typedef struct _tPoly + typedef struct tPoly { tMempool mempool; @@ -283,34 +281,32 @@ extern "C" { int currentVoice; int currentVelocity; int maxLength; - } _tPoly; - - typedef _tPoly* tPoly; - - void tPoly_init (tPoly* const poly, int maxNumVoices, LEAF* const leaf); - void tPoly_initToPool (tPoly* const poly, int maxNumVoices, tMempool* const pool); - void tPoly_free (tPoly* const poly); + } tPoly; + + void tPoly_init (tPoly** const poly, int maxNumVoices, LEAF* const leaf); + void tPoly_initToPool (tPoly** const poly, int maxNumVoices, tMempool* const pool); + void tPoly_free (tPoly** const poly); - void tPoly_tickPitch (tPoly const poly); - void tPoly_tickPitchGlide (tPoly const poly); - void tPoly_tickPitchBend (tPoly const poly); + void tPoly_tickPitch (tPoly* const poly); + void tPoly_tickPitchGlide (tPoly* const poly); + void tPoly_tickPitchBend (tPoly* const poly); - int tPoly_noteOn (tPoly const poly, int note, uint8_t vel); - int tPoly_noteOff (tPoly const poly, uint8_t note); - void tPoly_orderedAddToStack (tPoly const poly, uint8_t note); - void tPoly_setNumVoices (tPoly const poly, uint8_t numVoices); - void tPoly_setPitchGlideActive (tPoly const poly, int isActive); - void tPoly_setPitchGlideTime (tPoly const poly, Lfloat t); - void tPoly_setPitchBend (tPoly const poly, Lfloat pitchBend); - void tPoly_setBendGlideTime (tPoly const poly, Lfloat t); - void tPoly_setBendSamplesPerTick (tPoly const poly, Lfloat t); - int tPoly_getNumVoices (tPoly const poly); - int tPoly_getNumActiveVoices (tPoly const poly); - Lfloat tPoly_getPitch (tPoly const poly, uint8_t voice); - int tPoly_getKey (tPoly const poly, uint8_t voice); - int tPoly_getVelocity (tPoly const poly, uint8_t voice); - int tPoly_isOn (tPoly const poly, uint8_t voice); - void tPoly_setSampleRate (tPoly const poly, Lfloat sr); + int tPoly_noteOn (tPoly* const poly, int note, uint8_t vel); + int tPoly_noteOff (tPoly* const poly, uint8_t note); + void tPoly_orderedAddToStack (tPoly* const poly, uint8_t note); + void tPoly_setNumVoices (tPoly* const poly, uint8_t numVoices); + void tPoly_setPitchGlideActive (tPoly* const poly, int isActive); + void tPoly_setPitchGlideTime (tPoly* const poly, Lfloat t); + void tPoly_setPitchBend (tPoly* const poly, Lfloat pitchBend); + void tPoly_setBendGlideTime (tPoly* const poly, Lfloat t); + void tPoly_setBendSamplesPerTick (tPoly* const poly, Lfloat t); + int tPoly_getNumVoices (tPoly* const poly); + int tPoly_getNumActiveVoices (tPoly* const poly); + Lfloat tPoly_getPitch (tPoly* const poly, uint8_t voice); + int tPoly_getKey (tPoly* const poly, uint8_t voice); + int tPoly_getVelocity (tPoly* const poly, uint8_t voice); + int tPoly_isOn (tPoly* const poly, uint8_t voice); + void tPoly_setSampleRate (tPoly* const poly, Lfloat sr); //============================================================================== @@ -397,7 +393,7 @@ extern "C" { @return The current play state of the given voice. @} */ - typedef struct _tSimplePoly + typedef struct tSimplePoly { tMempool mempool; @@ -410,26 +406,24 @@ extern "C" { int recover_stolen; int notes[128][2]; - } _tSimplePoly; - - typedef _tSimplePoly* tSimplePoly; + } tSimplePoly; - void tSimplePoly_init (tSimplePoly* const poly, int maxNumVoices, LEAF* const leaf); - void tSimplePoly_initToPool (tSimplePoly* const poly, int maxNumVoices, tMempool* const pool); - void tSimplePoly_free (tSimplePoly* const poly); + void tSimplePoly_init (tSimplePoly** const poly, int maxNumVoices, LEAF* const leaf); + void tSimplePoly_initToPool (tSimplePoly** const poly, int maxNumVoices, tMempool* const pool); + void tSimplePoly_free (tSimplePoly** const poly); - int tSimplePoly_noteOn (tSimplePoly const poly, int note, uint8_t vel); - int tSimplePoly_noteOff (tSimplePoly const poly, uint8_t note); - void tSimplePoly_deactivateVoice (tSimplePoly const polyh, uint8_t voice); - int tSimplePoly_markPendingNoteOff (tSimplePoly const polyh, uint8_t note); - int tSimplePoly_findVoiceAssignedToNote (tSimplePoly const polyh, uint8_t note); - void tSimplePoly_setNumVoices (tSimplePoly const poly, uint8_t numVoices); - int tSimplePoly_getNumVoices (tSimplePoly const poly); - int tSimplePoly_getNumActiveVoices (tSimplePoly const poly); - int tSimplePoly_getPitch (tSimplePoly const poly, uint8_t voice); - int tSimplePoly_getPitchAndCheckActive (tSimplePoly const polyh, uint8_t voice); - int tSimplePoly_getVelocity (tSimplePoly const poly, uint8_t voice); - int tSimplePoly_isOn (tSimplePoly const poly, uint8_t voice); + int tSimplePoly_noteOn (tSimplePoly* const poly, int note, uint8_t vel); + int tSimplePoly_noteOff (tSimplePoly* const poly, uint8_t note); + void tSimplePoly_deactivateVoice (tSimplePoly* const polyh, uint8_t voice); + int tSimplePoly_markPendingNoteOff (tSimplePoly* const polyh, uint8_t note); + int tSimplePoly_findVoiceAssignedToNote (tSimplePoly* const polyh, uint8_t note); + void tSimplePoly_setNumVoices (tSimplePoly* const poly, uint8_t numVoices); + int tSimplePoly_getNumVoices (tSimplePoly* const poly); + int tSimplePoly_getNumActiveVoices (tSimplePoly* const poly); + int tSimplePoly_getPitch (tSimplePoly* const poly, uint8_t voice); + int tSimplePoly_getPitchAndCheckActive (tSimplePoly* const polyh, uint8_t voice); + int tSimplePoly_getVelocity (tSimplePoly* const poly, uint8_t voice); + int tSimplePoly_isOn (tSimplePoly* const poly, uint8_t voice); //============================================================================== diff --git a/leaf/Inc/leaf-oscillators.h b/leaf/Inc/leaf-oscillators.h index e00312d..d97c73e 100644 --- a/leaf/Inc/leaf-oscillators.h +++ b/leaf/Inc/leaf-oscillators.h @@ -61,7 +61,7 @@ extern "C" {  @} */ - typedef struct _tCycle + typedef struct tCycle { tMempool mempool; // Underlying phasor @@ -70,22 +70,20 @@ extern "C" { Lfloat freq; Lfloat invSampleRateTimesTwoTo32; uint32_t mask; - } _tCycle; - - typedef _tCycle* tCycle; + } tCycle; // Memory handlers for `tCycle` - void tCycle_init (tCycle* const osc, LEAF* const leaf); - void tCycle_initToPool (tCycle* const osc, tMempool* const mempool); - void tCycle_free (tCycle* const osc); + void tCycle_init (tCycle** const osc, LEAF* const leaf); + void tCycle_initToPool (tCycle** const osc, tMempool* const mempool); + void tCycle_free (tCycle** const osc); // Tick function for `tCycle` - Lfloat tCycle_tick (tCycle const osc); + Lfloat tCycle_tick (tCycle* const osc); // Setter functions for `tCycle` - void tCycle_setFreq (tCycle const osc, Lfloat freq); - void tCycle_setPhase (tCycle const osc, Lfloat phase); - void tCycle_setSampleRate (tCycle const osc, Lfloat sr); + void tCycle_setFreq (tCycle* const osc, Lfloat freq); + void tCycle_setPhase (tCycle* const osc, Lfloat phase); + void tCycle_setSampleRate (tCycle* const osc, Lfloat sr); //============================================================================== @@ -121,7 +119,7 @@ extern "C" { @} */ - typedef struct _tTriangle + typedef struct tTriangle { tMempool mempool; // Underlying phasor @@ -133,22 +131,20 @@ extern "C" { Lfloat invSampleRate; Lfloat invSampleRateTimesTwoTo32; uint32_t mask; - } _tTriangle; - - typedef _tTriangle* tTriangle; + } tTriangle; // Memory handlers for `tTriangle` - void tTriangle_init (tTriangle* const osc, LEAF* const leaf); - void tTriangle_initToPool (tTriangle* const osc, tMempool* const mempool); - void tTriangle_free (tTriangle* const osc); + void tTriangle_init (tTriangle** const osc, LEAF* const leaf); + void tTriangle_initToPool (tTriangle** const osc, tMempool* const mempool); + void tTriangle_free (tTriangle** const osc); // Tick function for `tTriangle` - Lfloat tTriangle_tick (tTriangle const osc); + Lfloat tTriangle_tick (tTriangle* const osc); // Setter functions for `tTriangle` - void tTriangle_setFreq (tTriangle const osc, Lfloat freq); - void tTriangle_setPhase (tTriangle const osc, Lfloat phase); - void tTriangle_setSampleRate (tTriangle const osc, Lfloat sr); + void tTriangle_setFreq (tTriangle* const osc, Lfloat freq); + void tTriangle_setPhase (tTriangle* const osc, Lfloat phase); + void tTriangle_setSampleRate (tTriangle* const osc, Lfloat sr); //============================================================================== @@ -184,7 +180,7 @@ extern "C" {  @} */ - typedef struct _tSquare + typedef struct tSquare { tMempool mempool; // Underlying phasor @@ -196,22 +192,20 @@ extern "C" { Lfloat invSampleRate; Lfloat invSampleRateTimesTwoTo32; uint32_t mask; - } _tSquare; - - typedef _tSquare* tSquare; + } tSquare; // Memory handlers for `tSquare` - void tSquare_init (tSquare* const osc, LEAF* const leaf); - void tSquare_initToPool (tSquare* const osc, tMempool* const mempool); - void tSquare_free (tSquare* const osc); + void tSquare_init (tSquare** const osc, LEAF* const leaf); + void tSquare_initToPool (tSquare** const osc, tMempool* const mempool); + void tSquare_free (tSquare** const osc); // Tick function for `tSquare` - Lfloat tSquare_tick (tSquare const osc); + Lfloat tSquare_tick (tSquare* const osc); // Setter functions for `tSquare` - void tSquare_setFreq (tSquare const osc, Lfloat freq); - void tSquare_setPhase (tSquare const osc, Lfloat phase); - void tSquare_setSampleRate (tSquare const osc, Lfloat sr); + void tSquare_setFreq (tSquare* const osc, Lfloat freq); + void tSquare_setPhase (tSquare* const osc, Lfloat phase); + void tSquare_setSampleRate (tSquare* const osc, Lfloat sr); /*! @} */ @@ -250,7 +244,7 @@ extern "C" {  @} */ - typedef struct _tSawtooth + typedef struct tSawtooth { tMempool mempool; // Underlying phasor @@ -262,22 +256,20 @@ extern "C" { Lfloat invSampleRate; Lfloat invSampleRateTimesTwoTo32; uint32_t mask; - } _tSawtooth; - - typedef _tSawtooth* tSawtooth; + } tSawtooth; // Memory handlers for `tSawtooth` - void tSawtooth_init (tSawtooth* const osc, LEAF* const leaf); - void tSawtooth_initToPool (tSawtooth* const osc, tMempool* const mempool); - void tSawtooth_free (tSawtooth* const osc); + void tSawtooth_init (tSawtooth** const osc, LEAF* const leaf); + void tSawtooth_initToPool (tSawtooth** const osc, tMempool* const mempool); + void tSawtooth_free (tSawtooth** const osc); // Tick function for `tSawtooth` - Lfloat tSawtooth_tick (tSawtooth const osc); + Lfloat tSawtooth_tick (tSawtooth* const osc); // Setter functions for `tSawtooth` - void tSawtooth_setFreq (tSawtooth const osc, Lfloat freq); - void tSawtooth_setPhase (tSawtooth const osc, Lfloat phase); - void tSawtooth_setSampleRate (tSawtooth const osc, Lfloat sr); + void tSawtooth_setFreq (tSawtooth* const osc, Lfloat freq); + void tSawtooth_setPhase (tSawtooth* const osc, Lfloat phase); + void tSawtooth_setSampleRate (tSawtooth* const osc, Lfloat sr); //============================================================================== @@ -315,7 +307,7 @@ extern "C" {  @} */ - typedef struct _tPBSineTriangle + typedef struct tPBSineTriangle { tMempool mempool; uint32_t phase; @@ -326,35 +318,33 @@ extern "C" { Lfloat oneMinusShape; Lfloat invSampleRate; Lfloat invSampleRateTimesTwoTo32; - } _tPBSineTriangle; - - typedef _tPBSineTriangle* tPBSineTriangle; + } tPBSineTriangle; // Memory handlers for `tPBSineTriangle` - void tPBSineTriangle_init (tPBSineTriangle* const osc, LEAF* const leaf); - void tPBSineTriangle_initToPool (tPBSineTriangle* const osc, tMempool* const mempool); - void tPBSineTriangle_free (tPBSineTriangle* const osc); + void tPBSineTriangle_init (tPBSineTriangle** const osc, LEAF* const leaf); + void tPBSineTriangle_initToPool (tPBSineTriangle** const osc, tMempool* const mempool); + void tPBSineTriangle_free (tPBSineTriangle** const osc); #ifdef ITCMRAM Lfloat __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tPBSineTriangle_tick (tPBSineTriangle* const osc); #else // Tick function for `tPBSineTriangle` - Lfloat tPBSineTriangle_tick (tPBSineTriangle const osc); + Lfloat tPBSineTriangle_tick (tPBSineTriangle* const osc); #endif #ifdef ITCMRAM void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tPBSineTriangle_setFreq (tPBSineTriangle* const osc, Lfloat freq); #else // Setter functions for `tPBSineTriangle` - void tPBSineTriangle_setFreq (tPBSineTriangle const osc, Lfloat freq); + void tPBSineTriangle_setFreq (tPBSineTriangle* const osc, Lfloat freq); #endif - void tPBSineTriangle_setShape (tPBSineTriangle const osc, Lfloat shape); - void tPBSineTriangle_setSampleRate (tPBSineTriangle const osc, Lfloat sr); + void tPBSineTriangle_setShape (tPBSineTriangle* const osc, Lfloat shape); + void tPBSineTriangle_setSampleRate (tPBSineTriangle* const osc, Lfloat sr); //============================================================================== - typedef struct _tPBTriangle + typedef struct tPBTriangle { tMempool mempool; uint32_t phase; @@ -365,29 +355,27 @@ extern "C" { Lfloat lastOutput; Lfloat invSampleRate; Lfloat invSampleRateTimesTwoTo32; - } _tPBTriangle; - - typedef _tPBTriangle* tPBTriangle; + } tPBTriangle; // Memory handlers for `tPBTriangle` - void tPBTriangle_init (tPBTriangle* const osc, LEAF* const leaf); - void tPBTriangle_initToPool (tPBTriangle* const osc, tMempool* const mempool); - void tPBTriangle_free (tPBTriangle* const osc); + void tPBTriangle_init (tPBTriangle** const osc, LEAF* const leaf); + void tPBTriangle_initToPool (tPBTriangle** const osc, tMempool* const mempool); + void tPBTriangle_free (tPBTriangle** const osc); #ifdef ITCMRAM Lfloat __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tPBTriangle_tick (tPBTriangle* const osc); #else // Tick function for `tPBTriangle` - Lfloat tPBTriangle_tick (tPBTriangle const osc); + Lfloat tPBTriangle_tick (tPBTriangle* const osc); #endif #ifdef ITCMRAM void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tPBTriangle_setFreq (tPBTriangle* const osc, Lfloat freq); #else // Setter functions for `tPBTriangle` - void tPBTriangle_setFreq (tPBTriangle const osc, Lfloat freq); + void tPBTriangle_setFreq (tPBTriangle* const osc, Lfloat freq); #endif - void tPBTriangle_setSkew (tPBTriangle const osc, Lfloat skew); - void tPBTriangle_setSampleRate (tPBTriangle const osc, Lfloat sr); + void tPBTriangle_setSkew (tPBTriangle* const osc, Lfloat skew); + void tPBTriangle_setSampleRate (tPBTriangle* const osc, Lfloat sr); //============================================================================== /*! @@ -424,7 +412,7 @@ extern "C" {  @} */ - typedef struct _tPBPulse + typedef struct tPBPulse { tMempool mempool; uint32_t phase; @@ -434,29 +422,27 @@ extern "C" { uint32_t oneMinusWidth; Lfloat invSampleRate; Lfloat invSampleRateTimesTwoTo32; - } _tPBPulse; - - typedef _tPBPulse* tPBPulse; + } tPBPulse; // Memory handlers for `tPBPulse` - void tPBPulse_init (tPBPulse* const osc, LEAF* const leaf); - void tPBPulse_initToPool (tPBPulse* const osc, tMempool* const); - void tPBPulse_free (tPBPulse* const osc); + void tPBPulse_init (tPBPulse** const osc, LEAF* const leaf); + void tPBPulse_initToPool (tPBPulse** const osc, tMempool* const); + void tPBPulse_free (tPBPulse** const osc); #ifdef ITCMRAM Lfloat __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tPBPulse_tick (tPBPulse* const osc); #else // Tick function for `tPBPulse` - Lfloat tPBPulse_tick (tPBPulse const osc); + Lfloat tPBPulse_tick (tPBPulse* const osc); #endif #ifdef ITCMRAM void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tPBPulse_setFreq (tPBPulse* const osc, Lfloat freq); #else // Setter functions for `tPBPulse` - void tPBPulse_setFreq (tPBPulse const osc, Lfloat freq); + void tPBPulse_setFreq (tPBPulse* const osc, Lfloat freq); #endif - void tPBPulse_setWidth (tPBPulse const osc, Lfloat width); - void tPBPulse_setSampleRate (tPBPulse const osc, Lfloat sr); + void tPBPulse_setWidth (tPBPulse* const osc, Lfloat width); + void tPBPulse_setSampleRate (tPBPulse* const osc, Lfloat sr); //============================================================================== @@ -490,7 +476,7 @@ extern "C" {  @} */ - typedef struct _tPBSaw + typedef struct tPBSaw { tMempool mempool; uint32_t phase; @@ -500,32 +486,30 @@ extern "C" { Lfloat invSampleRateTimesTwoTo32; Lfloat lastsyncin; Lfloat sync; - } _tPBSaw; - - typedef _tPBSaw* tPBSaw; + } tPBSaw; // Memory handlers for `tPBSaw` - void tPBSaw_init (tPBSaw* const osc, LEAF* const leaf); - void tPBSaw_initToPool (tPBSaw* const osc, tMempool* const mempool); - void tPBSaw_free (tPBSaw* const osc); + void tPBSaw_init (tPBSaw** const osc, LEAF* const leaf); + void tPBSaw_initToPool (tPBSaw** const osc, tMempool* const mempool); + void tPBSaw_free (tPBSaw** const osc); #ifdef ITCMRAM Lfloat __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tPBSaw_tick (tPBSaw* const osc); #else // Tick function for `tPBSaw` - Lfloat tPBSaw_tick (tPBSaw const osc); + Lfloat tPBSaw_tick (tPBSaw* const osc); #endif #ifdef ITCMRAM void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tPBSaw_setFreq (tPBSaw* const osc, Lfloat freq); #else // Setter functions for `tPBSaw` - void tPBSaw_setFreq (tPBSaw const osc, Lfloat freq); + void tPBSaw_setFreq (tPBSaw* const osc, Lfloat freq); #endif - void tPBSaw_setSampleRate (tPBSaw const osc, Lfloat sr); + void tPBSaw_setSampleRate (tPBSaw* const osc, Lfloat sr); //============================================================================== -typedef struct _tPBSawSquare +typedef struct tPBSawSquare { tMempool mempool; uint32_t phase; @@ -538,32 +522,30 @@ typedef struct _tPBSawSquare Lfloat shape; Lfloat oneMinusShape; -} _tPBSawSquare; - - typedef _tPBSawSquare* tPBSawSquare; +} tPBSawSquare; // Memory handlers for `tPBSawSquare` - void tPBSawSquare_init (tPBSawSquare* const osc, LEAF* const leaf); - void tPBSawSquare_initToPool (tPBSawSquare* const osc, tMempool* const mempool); - void tPBSawSquare_free (tPBSawSquare* const osc); + void tPBSawSquare_init (tPBSawSquare** const osc, LEAF* const leaf); + void tPBSawSquare_initToPool (tPBSawSquare** const osc, tMempool* const mempool); + void tPBSawSquare_free (tPBSawSquare** const osc); #ifdef ITCMRAM Lfloat __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tPBSawSquare_tick (tPBSawSquare* const osc); #else // Tick function for `tPBSawSquare` - Lfloat tPBSawSquare_tick (tPBSawSquare const osc); + Lfloat tPBSawSquare_tick (tPBSawSquare* const osc); #endif #ifdef ITCMRAM void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tPBSawSquare_setFreq (tPBSawSquare* const osc, Lfloat freq); #else // Setter functions for `tPBSawSquare` - void tPBSawSquare_setFreq (tPBSawSquare const osc, Lfloat freq); + void tPBSawSquare_setFreq (tPBSawSquare* const osc, Lfloat freq); #endif - void tPBSawSquare_setShape (tPBSawSquare const osc, Lfloat shape); - void tPBSawSquare_setSampleRate (tPBSawSquare const osc, Lfloat sr); + void tPBSawSquare_setShape (tPBSawSquare* const osc, Lfloat shape); + void tPBSawSquare_setSampleRate (tPBSawSquare* const osc, Lfloat sr); //============================================================================== - typedef struct _tSawOS + typedef struct tSawOS { tMempool mempool; uint32_t phase; @@ -576,21 +558,19 @@ typedef struct _tPBSawSquare uint32_t invSampleRateTimesTwoTo32OS; tSVF* aaFilter; uint8_t filterOrder; - } _tSawOS; - - typedef _tSawOS* tSawOS; + } tSawOS; // Memory handlers for `tSawOS` - void tSawOS_init (tSawOS* const osc, uint8_t OS_ratio, uint8_t filterOrder, LEAF* const leaf); - void tSawOS_initToPool (tSawOS* const osc, uint8_t OS_ratio, uint8_t filterOrder, tMempool* const mp); - void tSawOS_free (tSawOS* const osc); + void tSawOS_init (tSawOS** const osc, uint8_t OS_ratio, uint8_t filterOrder, LEAF* const leaf); + void tSawOS_initToPool (tSawOS** const osc, uint8_t OS_ratio, uint8_t filterOrder, tMempool* const mp); + void tSawOS_free (tSawOS** const osc); // Tick function for `tSawOS` - Lfloat tSawOS_tick (tSawOS const osc); + Lfloat tSawOS_tick (tSawOS* const osc); // Setter functions for `tSawOS` - void tSawOS_setFreq (tSawOS const osc, Lfloat freq); - void tSawOS_setSampleRate (tSawOS const osc, Lfloat sr); + void tSawOS_setFreq (tSawOS* const osc, Lfloat freq); + void tSawOS_setSampleRate (tSawOS* const osc, Lfloat sr); //============================================================================== @@ -625,7 +605,7 @@ typedef struct _tPBSawSquare  @} */ - typedef struct _tPhasor + typedef struct tPhasor { tMempool mempool; @@ -634,21 +614,19 @@ typedef struct _tPBSawSquare Lfloat freq; Lfloat invSampleRate; Lfloat invSampleRateTimesTwoTo32; - } _tPhasor; - - typedef _tPhasor* tPhasor; + } tPhasor; // Memory handlers for `tPhasor` - void tPhasor_init (tPhasor* const osc, LEAF* const leaf); - void tPhasor_initToPool (tPhasor* const osc, tMempool* const); - void tPhasor_free (tPhasor* const osc); + void tPhasor_init (tPhasor** const osc, LEAF* const leaf); + void tPhasor_initToPool (tPhasor** const osc, tMempool* const); + void tPhasor_free (tPhasor** const osc); // Tick function for `tPhasor` - Lfloat tPhasor_tick (tPhasor const osc); + Lfloat tPhasor_tick (tPhasor* const osc); // Setter functions for `tPhasor` - void tPhasor_setFreq (tPhasor const osc, Lfloat freq); - void tPhasor_setSampleRate (tPhasor const osc, Lfloat sr); + void tPhasor_setFreq (tPhasor* const osc, Lfloat freq); + void tPhasor_setSampleRate (tPhasor* const osc, Lfloat sr); //============================================================================== @@ -691,23 +669,21 @@ typedef struct _tPBSawSquare /*! @} */ - typedef struct _tNoise + typedef struct tNoise { tMempool mempool; NoiseType type; Lfloat pinkb0, pinkb1, pinkb2; Lfloat(*rand)(void); - } _tNoise; - - typedef _tNoise* tNoise; + } tNoise; // Memory handlers for `tNoise` - void tNoise_init (tNoise* const noise, NoiseType type, LEAF* const leaf); - void tNoise_initToPool (tNoise* const noise, NoiseType type, tMempool* const); - void tNoise_free (tNoise* const noise); + void tNoise_init (tNoise** const noise, NoiseType type, LEAF* const leaf); + void tNoise_initToPool (tNoise** const noise, NoiseType type, tMempool* const); + void tNoise_free (tNoise** const noise); // Tick function for `tNoise` - Lfloat tNoise_tick (tNoise const noise); + Lfloat tNoise_tick (tNoise* const noise); //============================================================================== @@ -802,7 +778,7 @@ typedef struct _tPBSawSquare /*! @} */ - typedef struct _tNeuron + typedef struct tNeuron { tMempool mempool; @@ -819,31 +795,29 @@ typedef struct _tPBSawSquare Lfloat V[3]; Lfloat P[3]; Lfloat gK, gN, gL, C; - } _tNeuron; - - typedef _tNeuron* tNeuron; + } tNeuron; // Memory handlers for `tNeuron` - void tNeuron_init (tNeuron* const neuron, LEAF* const leaf); - void tNeuron_initToPool (tNeuron* const neuron, tMempool* const mempool); - void tNeuron_free (tNeuron* const neuron); + void tNeuron_init (tNeuron** const neuron, LEAF* const leaf); + void tNeuron_initToPool (tNeuron** const neuron, tMempool* const mempool); + void tNeuron_free (tNeuron** const neuron); // Tick function for `tNeuron` - Lfloat tNeuron_tick (tNeuron const neuron); + Lfloat tNeuron_tick (tNeuron* const neuron); // Setter functions for `tNeuron` - void tNeuron_reset (tNeuron const neuron); - void tNeuron_setMode (tNeuron const neuron, NeuronMode mode); - void tNeuron_setCurrent (tNeuron const neuron, Lfloat current); - void tNeuron_setK (tNeuron const neuron, Lfloat K); - void tNeuron_setL (tNeuron const neuron, Lfloat L); - void tNeuron_setN (tNeuron const neuron, Lfloat N); - void tNeuron_setC (tNeuron const neuron, Lfloat C); - void tNeuron_setV1 (tNeuron const neuron, Lfloat V1); - void tNeuron_setV2 (tNeuron const neuron, Lfloat V2); - void tNeuron_setV3 (tNeuron const neuron, Lfloat V3); - void tNeuron_setTimeStep (tNeuron const neuron, Lfloat timestep); - void tNeuron_setSampleRate (tNeuron const neuron, Lfloat sr); + void tNeuron_reset (tNeuron* const neuron); + void tNeuron_setMode (tNeuron* const neuron, NeuronMode mode); + void tNeuron_setCurrent (tNeuron* const neuron, Lfloat current); + void tNeuron_setK (tNeuron* const neuron, Lfloat K); + void tNeuron_setL (tNeuron* const neuron, Lfloat L); + void tNeuron_setN (tNeuron* const neuron, Lfloat N); + void tNeuron_setC (tNeuron* const neuron, Lfloat C); + void tNeuron_setV1 (tNeuron* const neuron, Lfloat V1); + void tNeuron_setV2 (tNeuron* const neuron, Lfloat V2); + void tNeuron_setV3 (tNeuron* const neuron, Lfloat V3); + void tNeuron_setTimeStep (tNeuron* const neuron, Lfloat timestep); + void tNeuron_setSampleRate (tNeuron* const neuron, Lfloat sr); //============================================================================== @@ -892,7 +866,7 @@ typedef struct _tPBSawSquare  @} */ - typedef struct _tMBPulse + typedef struct tMBPulse { tMempool mempool; @@ -914,30 +888,28 @@ typedef struct _tPBSawSquare Lfloat BLEPproperties[64][2]; Lfloat invSampleRate; - } _tMBPulse; - - typedef _tMBPulse* tMBPulse; + } tMBPulse; // Memory handlers for `tMBPulse` - void tMBPulse_init (tMBPulse* const osc, LEAF* const leaf); - void tMBPulse_initToPool (tMBPulse* const osc, tMempool* const mempool); - void tMBPulse_free (tMBPulse* const osc); + void tMBPulse_init (tMBPulse** const osc, LEAF* const leaf); + void tMBPulse_initToPool (tMBPulse** const osc, tMempool* const mempool); + void tMBPulse_free (tMBPulse** const osc); #ifdef ITCMRAM void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBPulse_place_step_dd_noBuffer(tMBPulse* const osc, int index, Lfloat phase, Lfloat inv_w, Lfloat scale); #else void tMBPulse_place_step_dd_noBuffer (tMBPulse const osc, int index, Lfloat phase, Lfloat inv_w, Lfloat scale); #endif // Tick function for `tMBPulse` - Lfloat tMBPulse_tick (tMBPulse const osc); + Lfloat tMBPulse_tick (tMBPulse* const osc); // Setter functions for `tMBPulse` - Lfloat tMBPulse_sync (tMBPulse const osc, Lfloat sync); - void tMBPulse_setFreq (tMBPulse const osc, Lfloat f); - void tMBPulse_setWidth (tMBPulse const osc, Lfloat w); - void tMBPulse_setPhase (tMBPulse const osc, Lfloat phase); - void tMBPulse_setSyncMode (tMBPulse const osc, int hardOrSoft); - void tMBPulse_setBufferOffset (tMBPulse const osc, uint32_t offset); - void tMBPulse_setSampleRate (tMBPulse const osc, Lfloat sr); + Lfloat tMBPulse_sync (tMBPulse* const osc, Lfloat sync); + void tMBPulse_setFreq (tMBPulse* const osc, Lfloat f); + void tMBPulse_setWidth (tMBPulse* const osc, Lfloat w); + void tMBPulse_setPhase (tMBPulse* const osc, Lfloat phase); + void tMBPulse_setSyncMode (tMBPulse* const osc, int hardOrSoft); + void tMBPulse_setBufferOffset (tMBPulse* const osc, uint32_t offset); + void tMBPulse_setSampleRate (tMBPulse* const osc, Lfloat sr); /*! @defgroup tmbtriangle tMBTriangle @@ -979,7 +951,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBPul @} */ - typedef struct _tMBTriangle + typedef struct tMBTriangle { tMempool mempool; @@ -1002,38 +974,36 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBPul uint16_t BLEPindices[64]; Lfloat BLEPproperties[64][3]; Lfloat invSampleRate; - } _tMBTriangle; - - typedef _tMBTriangle* tMBTriangle; + } tMBTriangle; // Memory handlers for `tMBTriangle` - void tMBTriangle_init (tMBTriangle* const osc, LEAF* const leaf); - void tMBTriangle_initToPool (tMBTriangle* const osc, tMempool* const mempool); - void tMBTriangle_free (tMBTriangle* const osc); + void tMBTriangle_init (tMBTriangle** const osc, LEAF* const leaf); + void tMBTriangle_initToPool (tMBTriangle** const osc, tMempool* const mempool); + void tMBTriangle_free (tMBTriangle** const osc); #ifdef ITCMRAM void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBTriangle_place_dd_noBuffer(tMBTriangle* const osc, int index, Lfloat phase, Lfloat inv_w, Lfloat scale, Lfloat stepOrSlope, Lfloat w); #else - void tMBTriangle_place_dd_noBuffer (tMBTriangle const osc, int index, Lfloat phase, Lfloat inv_w, Lfloat scale, + void tMBTriangle_place_dd_noBuffer (tMBTriangle* const osc, int index, Lfloat phase, Lfloat inv_w, Lfloat scale, Lfloat stepOrSlope, Lfloat w); #endif // Tick function for `tMBTriangle` - Lfloat tMBTriangle_tick (tMBTriangle const osc); + Lfloat tMBTriangle_tick (tMBTriangle* const osc); // Setter functions for `tMBTriangle` - Lfloat tMBTriangle_sync (tMBTriangle const osc, Lfloat sync); - void tMBTriangle_setFreq (tMBTriangle const osc, Lfloat f); - void tMBTriangle_setWidth (tMBTriangle const osc, Lfloat w); - void tMBTriangle_setPhase (tMBTriangle const osc, Lfloat phase); - void tMBTriangle_setSyncMode (tMBTriangle const osc, int hardOrSoft); - void tMBTriangle_setBufferOffset (tMBTriangle const osc, uint32_t offset); - void tMBTriangle_setSampleRate (tMBTriangle const osc, Lfloat sr); + Lfloat tMBTriangle_sync (tMBTriangle* const osc, Lfloat sync); + void tMBTriangle_setFreq (tMBTriangle* const osc, Lfloat f); + void tMBTriangle_setWidth (tMBTriangle* const osc, Lfloat w); + void tMBTriangle_setPhase (tMBTriangle* const osc, Lfloat phase); + void tMBTriangle_setSyncMode (tMBTriangle* const osc, int hardOrSoft); + void tMBTriangle_setBufferOffset (tMBTriangle* const osc, uint32_t offset); + void tMBTriangle_setSampleRate (tMBTriangle* const osc, Lfloat sr); - typedef struct _tMBSineTri + typedef struct tMBSineTri { tMempool mempool; Lfloat out; @@ -1057,32 +1027,30 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBTri Lfloat BLEPproperties[64][3]; Lfloat invSampleRate; uint32_t sineMask; - } _tMBSineTri; - - typedef _tMBSineTri* tMBSineTri; + } tMBSineTri; // Memory handlers for `tMBSineTri` - void tMBSineTri_init (tMBSineTri* const osc, LEAF* const leaf); - void tMBSineTri_initToPool (tMBSineTri* const osc, tMempool* const mempool); - void tMBSineTri_free (tMBSineTri* const osc); + void tMBSineTri_init (tMBSineTri** const osc, LEAF* const leaf); + void tMBSineTri_initToPool (tMBSineTri** const osc, tMempool* const mempool); + void tMBSineTri_free (tMBSineTri** const osc); #ifdef ITCMRAM void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSineTri_place_dd_noBuffer(tMBSineTri* const osc, int index, Lfloat phase, Lfloat inv_w, Lfloat scale, Lfloat stepOrSlope, Lfloat w); #else - void tMBSineTri_place_dd_noBuffer (tMBSineTri const osc, int index, Lfloat phase, Lfloat inv_w, Lfloat scale, + void tMBSineTri_place_dd_noBuffer (tMBSineTri* const osc, int index, Lfloat phase, Lfloat inv_w, Lfloat scale, Lfloat stepOrSlope, Lfloat w); #endif // Tick function for `tMBSineTri` - Lfloat tMBSineTri_tick (tMBSineTri const osc); + Lfloat tMBSineTri_tick (tMBSineTri* const osc); // Setter functions for `tMBSineTri` - Lfloat tMBSineTri_sync (tMBSineTri const osc, Lfloat sync); - void tMBSineTri_setFreq (tMBSineTri const osc, Lfloat f); - void tMBSineTri_setWidth (tMBSineTri const osc, Lfloat w); - void tMBSineTri_setPhase (tMBSineTri const osc, Lfloat phase); - void tMBSineTri_setShape (tMBSineTri const osc, Lfloat shape); - void tMBSineTri_setSyncMode (tMBSineTri const osc, int hardOrSoft); - void tMBSineTri_setBufferOffset (tMBSineTri const osc, uint32_t offset); - void tMBSineTri_setSampleRate (tMBSineTri const osc, Lfloat sr); + Lfloat tMBSineTri_sync (tMBSineTri* const osc, Lfloat sync); + void tMBSineTri_setFreq (tMBSineTri* const osc, Lfloat f); + void tMBSineTri_setWidth (tMBSineTri* const osc, Lfloat w); + void tMBSineTri_setPhase (tMBSineTri* const osc, Lfloat phase); + void tMBSineTri_setShape (tMBSineTri* const osc, Lfloat shape); + void tMBSineTri_setSyncMode (tMBSineTri* const osc, int hardOrSoft); + void tMBSineTri_setBufferOffset (tMBSineTri* const osc, uint32_t offset); + void tMBSineTri_setSampleRate (tMBSineTri* const osc, Lfloat sr); /*! @@ -1125,7 +1093,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSin  @} */ - typedef struct _tMBSaw + typedef struct tMBSaw { tMempool mempool; Lfloat out; @@ -1144,27 +1112,25 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSin uint16_t BLEPindices[64]; Lfloat BLEPproperties[64][2]; Lfloat invSampleRate; - } _tMBSaw; - - typedef _tMBSaw* tMBSaw; + } tMBSaw; // Memory handlers for `tMBSaw` - void tMBSaw_init (tMBSaw* const osc, LEAF* const leaf); - void tMBSaw_initToPool (tMBSaw* const osc, tMempool* const mempool); - void tMBSaw_free (tMBSaw* const osc); + void tMBSaw_init (tMBSaw** const osc, LEAF* const leaf); + void tMBSaw_initToPool (tMBSaw** const osc, tMempool* const mempool); + void tMBSaw_free (tMBSaw** const osc); - void tMBSaw_place_step_dd_noBuffer (tMBSaw const osc, int index, Lfloat phase, Lfloat w, Lfloat scale); + void tMBSaw_place_step_dd_noBuffer (tMBSaw* const osc, int index, Lfloat phase, Lfloat w, Lfloat scale); // Tick function for `tMBSaw` - Lfloat tMBSaw_tick (tMBSaw const osc); + Lfloat tMBSaw_tick (tMBSaw* const osc); // Setter functions for `tMBSaw` - Lfloat tMBSaw_sync (tMBSaw const osc, Lfloat sync); - void tMBSaw_setFreq (tMBSaw const osc, Lfloat f); - void tMBSaw_setPhase (tMBSaw const osc, Lfloat phase); - void tMBSaw_setSyncMode (tMBSaw const osc, int hardOrSoft); - void tMBSaw_setBufferOffset (tMBSaw const osc, uint32_t offset); - void tMBSaw_setSampleRate (tMBSaw const osc, Lfloat sr); + Lfloat tMBSaw_sync (tMBSaw* const osc, Lfloat sync); + void tMBSaw_setFreq (tMBSaw* const osc, Lfloat f); + void tMBSaw_setPhase (tMBSaw* const osc, Lfloat phase); + void tMBSaw_setSyncMode (tMBSaw* const osc, int hardOrSoft); + void tMBSaw_setBufferOffset (tMBSaw* const osc, uint32_t offset); + void tMBSaw_setSampleRate (tMBSaw* const osc, Lfloat sr); //============================================================================== /*! @@ -1207,7 +1173,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSin  @} */ - typedef struct _tMBSawPulse + typedef struct tMBSawPulse { tMempool mempool; Lfloat out; @@ -1231,31 +1197,29 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSin Lfloat gain; int active; - } _tMBSawPulse; - - typedef _tMBSawPulse* tMBSawPulse; + } tMBSawPulse; // Memory handlers for `tMBSawPulse` - void tMBSawPulse_init (tMBSawPulse* const osc, LEAF* const leaf); - void tMBSawPulse_initToPool (tMBSawPulse* const osc, tMempool* const mempool); - void tMBSawPulse_free (tMBSawPulse* const osc); + void tMBSawPulse_init (tMBSawPulse** const osc, LEAF* const leaf); + void tMBSawPulse_initToPool (tMBSawPulse** const osc, tMempool* const mempool); + void tMBSawPulse_free (tMBSawPulse** const osc); #ifdef ITCMRAM void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSawPulse_place_step_dd_noBuffer(tMBSawPulse* const osc, int index, Lfloat phase, Lfloat inv_w, Lfloat scale); #else - void tMBSawPulse_place_step_dd_noBuffer (tMBSawPulse const osc, int index, Lfloat phase, Lfloat inv_w, + void tMBSawPulse_place_step_dd_noBuffer (tMBSawPulse* const osc, int index, Lfloat phase, Lfloat inv_w, Lfloat scale); #endif // Tick function for `tMBSawPulse` - Lfloat tMBSawPulse_tick (tMBSawPulse const osc); + Lfloat tMBSawPulse_tick (tMBSawPulse* const osc); // Setter functions for `tMBSawPulse` - Lfloat tMBSawPulse_sync (tMBSawPulse const osc, Lfloat sync); - void tMBSawPulse_setFreq (tMBSawPulse const osc, Lfloat f); - void tMBSawPulse_setPhase (tMBSawPulse const osc, Lfloat phase); - void tMBSawPulse_setShape (tMBSawPulse const osc, Lfloat shape); - void tMBSawPulse_setSyncMode (tMBSawPulse const osc, int hardOrSoft); - void tMBSawPulse_setBufferOffset (tMBSawPulse const osc, uint32_t offset); - void tMBSawPulse_setSampleRate (tMBSawPulse const osc, Lfloat sr); + Lfloat tMBSawPulse_sync (tMBSawPulse* const osc, Lfloat sync); + void tMBSawPulse_setFreq (tMBSawPulse* const osc, Lfloat f); + void tMBSawPulse_setPhase (tMBSawPulse* const osc, Lfloat phase); + void tMBSawPulse_setShape (tMBSawPulse* const osc, Lfloat shape); + void tMBSawPulse_setSyncMode (tMBSawPulse* const osc, int hardOrSoft); + void tMBSawPulse_setBufferOffset (tMBSawPulse* const osc, uint32_t offset); + void tMBSawPulse_setSampleRate (tMBSawPulse* const osc, Lfloat sr); //============================================================================== /*! @@ -1294,7 +1258,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw @} */ - typedef struct _tTable + typedef struct tTable { tMempool mempool; @@ -1303,21 +1267,19 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw Lfloat inc, freq; Lfloat phase; Lfloat invSampleRate; - } _tTable; - - typedef _tTable* tTable; + } tTable; // Memory handlers for `tTable` - void tTable_init (tTable* const osc, Lfloat* table, int size, LEAF* const leaf); - void tTable_initToPool (tTable* const osc, Lfloat* table, int size, tMempool* const mempool); - void tTable_free (tTable* const osc); + void tTable_init (tTable** const osc, Lfloat* table, int size, LEAF* const leaf); + void tTable_initToPool (tTable** const osc, Lfloat* table, int size, tMempool* const mempool); + void tTable_free (tTable** const osc); // Tick function for `tTable` - Lfloat tTable_tick (tTable const osc); + Lfloat tTable_tick (tTable* const osc); // Setter functions for `tTable` - void tTable_setFreq (tTable const osc, Lfloat freq); - void tTable_setSampleRate (tTable const osc, Lfloat sr); + void tTable_setFreq (tTable* const osc, Lfloat freq); + void tTable_setSampleRate (tTable* const osc, Lfloat sr); //============================================================================== @@ -1351,7 +1313,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw #define LEAF_NUM_WAVETABLE_FILTER_PASSES 5 - typedef struct _tWaveTable + typedef struct tWaveTable { tMempool mempool; @@ -1364,18 +1326,16 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw Lfloat baseFreq, invBaseFreq; tButterworth bl; Lfloat sampleRate; - } _tWaveTable; - - typedef _tWaveTable* tWaveTable; + } tWaveTable; // Memory handlers for `tWaveTable` - void tWaveTable_init (tWaveTable* const osc, Lfloat* table, int size, Lfloat maxFreq, LEAF* const leaf); - void tWaveTable_initToPool (tWaveTable* const osc, Lfloat* table, int size, Lfloat maxFreq, + void tWaveTable_init (tWaveTable** const osc, Lfloat* table, int size, Lfloat maxFreq, LEAF* const leaf); + void tWaveTable_initToPool (tWaveTable** const osc, Lfloat* table, int size, Lfloat maxFreq, tMempool* const mempool); - void tWaveTable_free (tWaveTable* const osc); + void tWaveTable_free (tWaveTable** const osc); // Setter functions for `tWaveTable` - void tWaveTable_setSampleRate (tWaveTable const osc, Lfloat sr); + void tWaveTable_setSampleRate (tWaveTable* const osc, Lfloat sr); //============================================================================== @@ -1421,10 +1381,10 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw @} */ - typedef struct _tWaveOsc + typedef struct tWaveOsc { tMempool mempool; - tWaveTable* tables; + tWaveTable** tables; int numTables; Lfloat index; Lfloat maxFreq; @@ -1446,24 +1406,22 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw Lfloat aa; int numSubTables; - } _tWaveOsc; - - typedef _tWaveOsc* tWaveOsc; + } tWaveOsc; // Memory handlers for `tWaveOsc` - void tWaveOsc_init (tWaveOsc* const cy, tWaveTable* tables, int numTables, LEAF* const leaf); - void tWaveOsc_initToPool (tWaveOsc* const cy, tWaveTable* tables, int numTables, tMempool* const mp); - void tWaveOsc_free (tWaveOsc* const osc); + void tWaveOsc_init (tWaveOsc** const cy, tWaveTable* tables, int numTables, LEAF* const leaf); + void tWaveOsc_initToPool (tWaveOsc** const cy, tWaveTable* tables, int numTables, tMempool* const mp); + void tWaveOsc_free (tWaveOsc** const osc); // Tick function for `tWaveOsc` - Lfloat tWaveOsc_tick (tWaveOsc const osc); + Lfloat tWaveOsc_tick (tWaveOsc* const osc); // Setter functions for `tWaveOsc` - void tWaveOsc_setFreq (tWaveOsc const cy, Lfloat freq); - void tWaveOsc_setAntiAliasing (tWaveOsc const osc, Lfloat aa); - void tWaveOsc_setIndex (tWaveOsc const osc, Lfloat index); - void tWaveOsc_setTables (tWaveOsc const cy, tWaveTable* tables, int numTables); - void tWaveOsc_setSampleRate (tWaveOsc const osc, Lfloat sr); + void tWaveOsc_setFreq (tWaveOsc* const cy, Lfloat freq); + void tWaveOsc_setAntiAliasing (tWaveOsc* const osc, Lfloat aa); + void tWaveOsc_setIndex (tWaveOsc* const osc, Lfloat index); + void tWaveOsc_setTables (tWaveOsc* const cy, tWaveTable* tables, int numTables); + void tWaveOsc_setSampleRate (tWaveOsc* const osc, Lfloat sr); //============================================================================== @@ -1495,7 +1453,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw @} */ - typedef struct _tWaveTableS + typedef struct tWaveTableS { tMempool mempool; @@ -1510,19 +1468,17 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw Lfloat dsBuffer[2]; tOversampler ds; Lfloat sampleRate; - } _tWaveTableS; - - typedef _tWaveTableS* tWaveTableS; + } tWaveTableS; // Memory handlers for `tWaveTableS` - void tWaveTableS_init (tWaveTableS* const osc, Lfloat* table, int size, Lfloat maxFreq, + void tWaveTableS_init (tWaveTableS** const osc, Lfloat* table, int size, Lfloat maxFreq, LEAF* const leaf); - void tWaveTableS_initToPool (tWaveTableS* const osc, Lfloat* table, int size, Lfloat maxFreq, + void tWaveTableS_initToPool (tWaveTableS** const osc, Lfloat* table, int size, Lfloat maxFreq, tMempool* const mempool); - void tWaveTableS_free (tWaveTableS* const osc); + void tWaveTableS_free (tWaveTableS** const osc); // Setter functions for `tWaveTableS` - void tWaveTableS_setSampleRate (tWaveTableS const osc, Lfloat sr); + void tWaveTableS_setSampleRate (tWaveTableS* const osc, Lfloat sr); //============================================================================== @@ -1568,7 +1524,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw @} */ - typedef struct _tWaveOscS + typedef struct tWaveOscS { tMempool mempool; @@ -1597,24 +1553,22 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw Lfloat aa; int numSubTables; - } _tWaveOscS; - - typedef _tWaveOscS* tWaveOscS; + } tWaveOscS; // Memory handlers for `tWaveOscS` - void tWaveOscS_init (tWaveOscS* const cy, tWaveTableS* tables, int numTables, LEAF* const leaf); - void tWaveOscS_initToPool (tWaveOscS* const osc, tWaveTableS* tables, int numTables, + void tWaveOscS_init (tWaveOscS** const cy, tWaveTableS* tables, int numTables, LEAF* const leaf); + void tWaveOscS_initToPool (tWaveOscS** const osc, tWaveTableS* tables, int numTables, tMempool* const mempool); - void tWaveOscS_free (tWaveOscS* const osc); + void tWaveOscS_free (tWaveOscS** const osc); // Tick function for `tWaveOscS` - Lfloat tWaveOscS_tick (tWaveOscS const osc); + Lfloat tWaveOscS_tick (tWaveOscS* const osc); // Setter functions for `tWaveOscS` - void tWaveOscS_setFreq (tWaveOscS const osc, Lfloat freq); - void tWaveOscS_setAntiAliasing (tWaveOscS const osc, Lfloat aa); - void tWaveOscS_setIndex (tWaveOscS const osc, Lfloat index); - void tWaveOscS_setSampleRate (tWaveOscS const osc, Lfloat sr); + void tWaveOscS_setFreq (tWaveOscS* const osc, Lfloat freq); + void tWaveOscS_setAntiAliasing (tWaveOscS* const osc, Lfloat aa); + void tWaveOscS_setIndex (tWaveOscS* const osc, Lfloat index); + void tWaveOscS_setSampleRate (tWaveOscS* const osc, Lfloat sr); @@ -1651,7 +1605,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw  @} */ - typedef struct _tIntPhasor + typedef struct tIntPhasor { tMempool mempool; @@ -1661,22 +1615,20 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw int32_t mask; uint8_t phaseDidReset; Lfloat invSampleRateTimesTwoTo32; - } _tIntPhasor; - - typedef _tIntPhasor* tIntPhasor; + } tIntPhasor; // Memory handlers for `tIntPhasor` - void tIntPhasor_init (tIntPhasor* const osc, LEAF* const leaf); - void tIntPhasor_initToPool (tIntPhasor* const osc, tMempool* const); - void tIntPhasor_free (tIntPhasor* const osc); + void tIntPhasor_init (tIntPhasor** const osc, LEAF* const leaf); + void tIntPhasor_initToPool (tIntPhasor** const osc, tMempool* const); + void tIntPhasor_free (tIntPhasor** const osc); // Tick function for `tIntPhasor` - Lfloat tIntPhasor_tick (tIntPhasor const osc); - Lfloat tIntPhasor_tickBiPolar (tIntPhasor const osc); + Lfloat tIntPhasor_tick (tIntPhasor* const osc); + Lfloat tIntPhasor_tickBiPolar (tIntPhasor* const osc); // Setter functions for `tIntPhasor` - void tIntPhasor_setFreq (tIntPhasor const osc, Lfloat freq); - void tIntPhasor_setSampleRate (tIntPhasor const osc, Lfloat sr); - void tIntPhasor_setPhase (tIntPhasor const cy, Lfloat phase); + void tIntPhasor_setFreq (tIntPhasor* const osc, Lfloat freq); + void tIntPhasor_setSampleRate (tIntPhasor* const osc, Lfloat sr); + void tIntPhasor_setPhase (tIntPhasor* const cy, Lfloat phase); //============================================================================== @@ -1710,54 +1662,50 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw  @} */ - typedef struct _tSquareLFO + typedef struct tSquareLFO { tMempool mempool; Lfloat pulsewidth; tIntPhasor phasor; tIntPhasor invPhasor; - } _tSquareLFO; - - typedef _tSquareLFO* tSquareLFO; + } tSquareLFO; // Memory handlers for `tSquareLFO` - void tSquareLFO_init (tSquareLFO* const osc, LEAF* const leaf); - void tSquareLFO_initToPool (tSquareLFO* const osc, tMempool* const); - void tSquareLFO_free (tSquareLFO* const osc); + void tSquareLFO_init (tSquareLFO** const osc, LEAF* const leaf); + void tSquareLFO_initToPool (tSquareLFO** const osc, tMempool* const); + void tSquareLFO_free (tSquareLFO** const osc); // Tick function for `tSquareLFO` - Lfloat tSquareLFO_tick (tSquareLFO const osc); + Lfloat tSquareLFO_tick (tSquareLFO* const osc); // Setter functions for `tSquareLFO` - void tSquareLFO_setFreq (tSquareLFO const osc, Lfloat freq); - void tSquareLFO_setSampleRate (tSquareLFO const osc, Lfloat sr); - void tSquareLFO_setPulseWidth (tSquareLFO const cy, Lfloat pw); - void tSquareLFO_setPhase (tSquareLFO const cy, Lfloat phase); + void tSquareLFO_setFreq (tSquareLFO* const osc, Lfloat freq); + void tSquareLFO_setSampleRate (tSquareLFO* const osc, Lfloat sr); + void tSquareLFO_setPulseWidth (tSquareLFO* const cy, Lfloat pw); + void tSquareLFO_setPhase (tSquareLFO* const cy, Lfloat phase); - typedef struct _tSawSquareLFO + typedef struct tSawSquareLFO { tMempool mempool; Lfloat shape; tIntPhasor saw; tSquareLFO square; - } _tSawSquareLFO; - - typedef _tSawSquareLFO* tSawSquareLFO; + } tSawSquareLFO; // Memory handlers for `tSawSquareLFO` - void tSawSquareLFO_init (tSawSquareLFO* const osc, LEAF* const leaf); - void tSawSquareLFO_initToPool (tSawSquareLFO* const osc, tMempool* const); - void tSawSquareLFO_free (tSawSquareLFO* const osc); + void tSawSquareLFO_init (tSawSquareLFO** const osc, LEAF* const leaf); + void tSawSquareLFO_initToPool (tSawSquareLFO** const osc, tMempool* const); + void tSawSquareLFO_free (tSawSquareLFO** const osc); // Tick function for `tSawSquareLFO` - Lfloat tSawSquareLFO_tick (tSawSquareLFO const osc); + Lfloat tSawSquareLFO_tick (tSawSquareLFO* const osc); // Setter functions for `tSawSquareLFO` - void tSawSquareLFO_setFreq (tSawSquareLFO const osc, Lfloat freq); - void tSawSquareLFO_setSampleRate (tSawSquareLFO const osc, Lfloat sr); - void tSawSquareLFO_setPhase (tSawSquareLFO const cy, Lfloat phase); - void tSawSquareLFO_setShape (tSawSquareLFO const cy, Lfloat shape); + void tSawSquareLFO_setFreq (tSawSquareLFO* const osc, Lfloat freq); + void tSawSquareLFO_setSampleRate (tSawSquareLFO* const osc, Lfloat sr); + void tSawSquareLFO_setPhase (tSawSquareLFO* const cy, Lfloat phase); + void tSawSquareLFO_setShape (tSawSquareLFO* const cy, Lfloat shape); //============================================================================== /*! @@ -1790,7 +1738,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw  @} */ - typedef struct _tTriLFO + typedef struct tTriLFO { tMempool mempool; @@ -1799,50 +1747,46 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw Lfloat freq; Lfloat invSampleRate; Lfloat invSampleRateTimesTwoTo32; - } _tTriLFO; - - typedef _tTriLFO* tTriLFO; + } tTriLFO; // Memory handlers for `tTriLFO` - void tTriLFO_init (tTriLFO* const osc, LEAF* const leaf); - void tTriLFO_initToPool (tTriLFO* const osc, tMempool* const); - void tTriLFO_free (tTriLFO* const osc); + void tTriLFO_init (tTriLFO** const osc, LEAF* const leaf); + void tTriLFO_initToPool (tTriLFO** const osc, tMempool* const); + void tTriLFO_free (tTriLFO** const osc); // Tick function for `tTriLFO` - Lfloat tTriLFO_tick (tTriLFO const osc); + Lfloat tTriLFO_tick (tTriLFO* const osc); // Setter functions for `tTriLFO` - void tTriLFO_setFreq (tTriLFO const osc, Lfloat freq); - void tTriLFO_setSampleRate (tTriLFO const osc, Lfloat sr); - void tTriLFO_setPhase (tTriLFO const cy, Lfloat phase); + void tTriLFO_setFreq (tTriLFO* const osc, Lfloat freq); + void tTriLFO_setSampleRate (tTriLFO* const osc, Lfloat sr); + void tTriLFO_setPhase (tTriLFO* const cy, Lfloat phase); - typedef struct _tSineTriLFO + typedef struct tSineTriLFO { tMempool mempool; Lfloat shape; tTriLFO tri; tCycle sine; - } _tSineTriLFO; - - typedef _tSineTriLFO* tSineTriLFO; + } tSineTriLFO; // Memory handlers for `tSineTriLFO` - void tSineTriLFO_init (tSineTriLFO* const osc, LEAF* const leaf); - void tSineTriLFO_initToPool (tSineTriLFO* const osc, tMempool* const); - void tSineTriLFO_free (tSineTriLFO* const osc); + void tSineTriLFO_init (tSineTriLFO** const osc, LEAF* const leaf); + void tSineTriLFO_initToPool (tSineTriLFO** const osc, tMempool* const); + void tSineTriLFO_free (tSineTriLFO** const osc); // Tick function for `tSineTriLFO` - Lfloat tSineTriLFO_tick (tSineTriLFO const osc); + Lfloat tSineTriLFO_tick (tSineTriLFO* const osc); // Setter functions for `tSineTriLFO` - void tSineTriLFO_setFreq (tSineTriLFO const osc, Lfloat freq); - void tSineTriLFO_setSampleRate (tSineTriLFO const osc, Lfloat sr); - void tSineTriLFO_setPhase (tSineTriLFO const cy, Lfloat phase); - void tSineTriLFO_setShape (tSineTriLFO const cy, Lfloat shape); + void tSineTriLFO_setFreq (tSineTriLFO* const osc, Lfloat freq); + void tSineTriLFO_setSampleRate (tSineTriLFO* const osc, Lfloat sr); + void tSineTriLFO_setPhase (tSineTriLFO* const cy, Lfloat phase); + void tSineTriLFO_setShape (tSineTriLFO* const cy, Lfloat shape); -typedef struct _tDampedOscillator +typedef struct tDampedOscillator { tMempool mempool; @@ -1853,26 +1797,24 @@ typedef struct _tDampedOscillator Lfloat turns_ratio_; Lfloat x_; Lfloat y_; - } _tDampedOscillator; - - typedef _tDampedOscillator* tDampedOscillator; + } tDampedOscillator; // Memory handlers for `tDampedOscillator` - void tDampedOscillator_init (tDampedOscillator* const osc, LEAF* const leaf); - void tDampedOscillator_initToPool (tDampedOscillator* const osc, tMempool* const mempool); - void tDampedOscillator_free (tDampedOscillator* const osc); + void tDampedOscillator_init (tDampedOscillator** const osc, LEAF* const leaf); + void tDampedOscillator_initToPool (tDampedOscillator** const osc, tMempool* const mempool); + void tDampedOscillator_free (tDampedOscillator** const osc); // Tick function for `tDampedOscillator` - Lfloat tDampedOscillator_tick (tDampedOscillator const osc); + Lfloat tDampedOscillator_tick (tDampedOscillator* const osc); // Setter functions for `tDampedOscillator` - void tDampedOscillator_setFreq (tDampedOscillator const osc, Lfloat freq); - void tDampedOscillator_setSampleRate (tDampedOscillator const osc, Lfloat sr); - void tDampedOscillator_setDecay (tDampedOscillator const osc, Lfloat decay); - void tDampedOscillator_reset (tDampedOscillator const osc); + void tDampedOscillator_setFreq (tDampedOscillator* const osc, Lfloat freq); + void tDampedOscillator_setSampleRate (tDampedOscillator* const osc, Lfloat sr); + void tDampedOscillator_setDecay (tDampedOscillator* const osc, Lfloat decay); + void tDampedOscillator_reset (tDampedOscillator* const osc); - typedef struct _tPlutaQuadOsc + typedef struct tPlutaQuadOsc { tMempool mempool; uint32_t oversamplingRatio; @@ -1885,20 +1827,18 @@ typedef struct _tDampedOscillator tButterworth lowpass; int32_t mask; Lfloat invSampleRateTimesTwoTo32; - } _tPlutaQuadOsc; - - typedef _tPlutaQuadOsc* tPlutaQuadOsc; + } tPlutaQuadOsc; // Memory handlers for `tDampedOscillator` - void tPlutaQuadOsc_init (tPlutaQuadOsc* const osc, uint32_t oversamplingRatio, LEAF* const leaf); - void tPlutaQuadOsc_initToPool (tPlutaQuadOsc* const cy, uint32_t oversamplingRatio, tMempool* const mp); - void tPlutaQuadOsc_free (tPlutaQuadOsc* const osc); + void tPlutaQuadOsc_init (tPlutaQuadOsc** const osc, uint32_t oversamplingRatio, LEAF* const leaf); + void tPlutaQuadOsc_initToPool (tPlutaQuadOsc** const cy, uint32_t oversamplingRatio, tMempool* const mp); + void tPlutaQuadOsc_free (tPlutaQuadOsc** const osc); // Tick function for `tDampedOscillator` - Lfloat tPlutaQuadOsc_tick (tPlutaQuadOsc const osc); - void tPlutaQuadOsc_setFreq (tPlutaQuadOsc const c, uint32_t whichOsc, Lfloat freq); - void tPlutaQuadOsc_setFmAmount (tPlutaQuadOsc const c, uint32_t const whichCarrier, uint32_t const whichModulator, Lfloat const amount); - void tPlutaQuadOsc_setOutputAmplitude (tPlutaQuadOsc const c, uint32_t const whichOsc, Lfloat const amplitude); + Lfloat tPlutaQuadOsc_tick (tPlutaQuadOsc* const osc); + void tPlutaQuadOsc_setFreq (tPlutaQuadOsc* const c, uint32_t whichOsc, Lfloat freq); + void tPlutaQuadOsc_setFmAmount (tPlutaQuadOsc* const c, uint32_t const whichCarrier, uint32_t const whichModulator, Lfloat const amount); + void tPlutaQuadOsc_setOutputAmplitude (tPlutaQuadOsc* const c, uint32_t const whichOsc, Lfloat const amplitude); #ifdef __cplusplus } #endif diff --git a/leaf/Inc/leaf-physical.h b/leaf/Inc/leaf-physical.h index 1015acc..4420a34 100644 --- a/leaf/Inc/leaf-physical.h +++ b/leaf/Inc/leaf-physical.h @@ -27,20 +27,18 @@ extern "C" { #include "leaf-dynamics.h" -typedef struct _tPickupNonLinearity +typedef struct tPickupNonLinearity { tMempool mempool; Lfloat prev; -} _tPickupNonLinearity; +} tPickupNonLinearity; -typedef _tPickupNonLinearity* tPickupNonLinearity; +void tPickupNonLinearity_init (tPickupNonLinearity** const p, LEAF* const leaf); +void tPickupNonLinearity_initToPool (tPickupNonLinearity** const p, tMempool* const mp); +void tPickupNonLinearity_free (tPickupNonLinearity** const p); -void tPickupNonLinearity_init (tPickupNonLinearity* const p, LEAF* const leaf); -void tPickupNonLinearity_initToPool (tPickupNonLinearity* const p, tMempool* const mp); -void tPickupNonLinearity_free (tPickupNonLinearity* const p); - -Lfloat tPickupNonLinearity_tick (tPickupNonLinearity const p, Lfloat in); +Lfloat tPickupNonLinearity_tick (tPickupNonLinearity* const p, Lfloat in); //============================================================================== @@ -94,7 +92,7 @@ Lfloat tPickupNonLinearity_tick (tPickupNonLinearity const p, Lfloat in @} */ - typedef struct _tPluck + typedef struct tPluck { tMempool mempool; @@ -109,23 +107,21 @@ Lfloat tPickupNonLinearity_tick (tPickupNonLinearity const p, Lfloat in Lfloat lastFreq; Lfloat sampleRate; - } _tPluck; - - typedef _tPluck* tPluck; - - void tPluck_init (tPluck* const, Lfloat lowestFrequency, LEAF* const leaf); //Lfloat delayBuff[DELAY_LENGTH]); - void tPluck_initToPool (tPluck* const, Lfloat lowestFrequency, tMempool* const); - void tPluck_free (tPluck* const); + } tPluck; + + void tPluck_init (tPluck** const, Lfloat lowestFrequency, LEAF* const leaf); //Lfloat delayBuff[DELAY_LENGTH]); + void tPluck_initToPool (tPluck** const, Lfloat lowestFrequency, tMempool* const); + void tPluck_free (tPluck** const); - Lfloat tPluck_tick (tPluck const); - - void tPluck_pluck (tPluck const, Lfloat amplitude); - void tPluck_noteOn (tPluck const, Lfloat frequency, Lfloat amplitude ); - void tPluck_noteOff (tPluck const, Lfloat amplitude ); - void tPluck_setFrequency (tPluck const, Lfloat frequency ); - void tPluck_controlChange (tPluck const, int number, Lfloat value); - Lfloat tPluck_getLastOut (tPluck const); - void tPluck_setSampleRate (tPluck const, Lfloat sr); + Lfloat tPluck_tick (tPluck* const); + + void tPluck_pluck (tPluck* const, Lfloat amplitude); + void tPluck_noteOn (tPluck* const, Lfloat frequency, Lfloat amplitude ); + void tPluck_noteOff (tPluck* const, Lfloat amplitude ); + void tPluck_setFrequency (tPluck* const, Lfloat frequency ); + void tPluck_controlChange (tPluck* const, int number, Lfloat value); + Lfloat tPluck_getLastOut (tPluck* const); + void tPluck_setSampleRate (tPluck* const, Lfloat sr); //============================================================================== @@ -199,7 +195,7 @@ Lfloat tPickupNonLinearity_tick (tPickupNonLinearity const p, Lfloat in SKControlTypeNil } SKControlType; - typedef struct _tKarplusStrong + typedef struct tKarplusStrong { tMempool mempool; @@ -222,25 +218,23 @@ Lfloat tPickupNonLinearity_tick (tPickupNonLinearity const p, Lfloat in Lfloat lastOut; Lfloat sampleRate; - } _tKarplusStrong; - - typedef _tKarplusStrong* tKarplusStrong; - - void tKarplusStrong_init (tKarplusStrong* const, Lfloat lowestFrequency, LEAF* const leaf); // Lfloat delayBuff[2][DELAY_LENGTH]); - void tKarplusStrong_initToPool (tKarplusStrong* const, Lfloat lowestFrequency, tMempool* const); - void tKarplusStrong_free (tKarplusStrong* const); + } tKarplusStrong; + + void tKarplusStrong_init (tKarplusStrong** const, Lfloat lowestFrequency, LEAF* const leaf); // Lfloat delayBuff[2][DELAY_LENGTH]); + void tKarplusStrong_initToPool (tKarplusStrong** const, Lfloat lowestFrequency, tMempool* const); + void tKarplusStrong_free (tKarplusStrong** const); - Lfloat tKarplusStrong_tick (tKarplusStrong const); - - void tKarplusStrong_pluck (tKarplusStrong const, Lfloat amplitude); - void tKarplusStrong_noteOn (tKarplusStrong const, Lfloat frequency, Lfloat amplitude ); - void tKarplusStrong_noteOff (tKarplusStrong const, Lfloat amplitude ); - void tKarplusStrong_setFrequency (tKarplusStrong const, Lfloat frequency ); - void tKarplusStrong_controlChange (tKarplusStrong const, SKControlType type, Lfloat value); - void tKarplusStrong_setStretch (tKarplusStrong const, Lfloat stretch ); - void tKarplusStrong_setPickupPosition (tKarplusStrong const, Lfloat position ); - void tKarplusStrong_setBaseLoopGain (tKarplusStrong const, Lfloat aGain ); - Lfloat tKarplusStrong_getLastOut (tKarplusStrong const); + Lfloat tKarplusStrong_tick (tKarplusStrong* const); + + void tKarplusStrong_pluck (tKarplusStrong* const, Lfloat amplitude); + void tKarplusStrong_noteOn (tKarplusStrong* const, Lfloat frequency, Lfloat amplitude ); + void tKarplusStrong_noteOff (tKarplusStrong* const, Lfloat amplitude ); + void tKarplusStrong_setFrequency (tKarplusStrong* const, Lfloat frequency ); + void tKarplusStrong_controlChange (tKarplusStrong* const, SKControlType type, Lfloat value); + void tKarplusStrong_setStretch (tKarplusStrong* const, Lfloat stretch ); + void tKarplusStrong_setPickupPosition (tKarplusStrong* const, Lfloat position ); + void tKarplusStrong_setBaseLoopGain (tKarplusStrong* const, Lfloat aGain ); + Lfloat tKarplusStrong_getLastOut (tKarplusStrong* const); // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ @@ -306,7 +300,7 @@ Lfloat tPickupNonLinearity_tick (tPickupNonLinearity const p, Lfloat in @} */ - typedef struct _tSimpleLivingString + typedef struct tSimpleLivingString { tMempool mempool; @@ -321,37 +315,35 @@ Lfloat tPickupNonLinearity_tick (tPickupNonLinearity const p, Lfloat in tFeedbackLeveler fbLev; tExpSmooth wlSmooth; Lfloat sampleRate; - } _tSimpleLivingString; - - typedef _tSimpleLivingString* tSimpleLivingString; - - void tSimpleLivingString_init (tSimpleLivingString* const, Lfloat freq, Lfloat dampFreq, + } tSimpleLivingString; + + void tSimpleLivingString_init (tSimpleLivingString** const, Lfloat freq, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, LEAF* const leaf); - void tSimpleLivingString_initToPool (tSimpleLivingString* const, Lfloat freq, Lfloat dampFreq, + void tSimpleLivingString_initToPool (tSimpleLivingString** const, Lfloat freq, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, tMempool* const); - void tSimpleLivingString_free (tSimpleLivingString* const); + void tSimpleLivingString_free (tSimpleLivingString** const); - Lfloat tSimpleLivingString_tick (tSimpleLivingString const, Lfloat input); - - Lfloat tSimpleLivingString_sample (tSimpleLivingString const); - void tSimpleLivingString_setFreq (tSimpleLivingString const, Lfloat freq); - void tSimpleLivingString_setWaveLength (tSimpleLivingString const, Lfloat waveLength); // in samples - void tSimpleLivingString_setDampFreq (tSimpleLivingString const, Lfloat dampFreq); - void tSimpleLivingString_setDecay (tSimpleLivingString const, Lfloat decay); // should be near 1.0 - void tSimpleLivingString_setTargetLev (tSimpleLivingString const, Lfloat targetLev); - void tSimpleLivingString_setLevSmoothFactor (tSimpleLivingString const, Lfloat levSmoothFactor); - void tSimpleLivingString_setLevStrength (tSimpleLivingString const, Lfloat levStrength); - void tSimpleLivingString_setLevMode (tSimpleLivingString const, int levMode); - void tSimpleLivingString_setSampleRate (tSimpleLivingString const, Lfloat sr); + Lfloat tSimpleLivingString_tick (tSimpleLivingString* const, Lfloat input); + + Lfloat tSimpleLivingString_sample (tSimpleLivingString* const); + void tSimpleLivingString_setFreq (tSimpleLivingString* const, Lfloat freq); + void tSimpleLivingString_setWaveLength (tSimpleLivingString* const, Lfloat waveLength); // in samples + void tSimpleLivingString_setDampFreq (tSimpleLivingString* const, Lfloat dampFreq); + void tSimpleLivingString_setDecay (tSimpleLivingString* const, Lfloat decay); // should be near 1.0 + void tSimpleLivingString_setTargetLev (tSimpleLivingString* const, Lfloat targetLev); + void tSimpleLivingString_setLevSmoothFactor (tSimpleLivingString* const, Lfloat levSmoothFactor); + void tSimpleLivingString_setLevStrength (tSimpleLivingString* const, Lfloat levStrength); + void tSimpleLivingString_setLevMode (tSimpleLivingString* const, int levMode); + void tSimpleLivingString_setSampleRate (tSimpleLivingString* const, Lfloat sr); // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - typedef struct _tSimpleLivingString2 + typedef struct tSimpleLivingString2 { tMempool mempool; @@ -366,35 +358,33 @@ Lfloat tPickupNonLinearity_tick (tPickupNonLinearity const p, Lfloat in tFeedbackLeveler fbLev; tExpSmooth wlSmooth; Lfloat sampleRate; - } _tSimpleLivingString2; + } tSimpleLivingString2; - typedef _tSimpleLivingString2* tSimpleLivingString2; - - void tSimpleLivingString2_init (tSimpleLivingString2* const, Lfloat freq, Lfloat brightness, + void tSimpleLivingString2_init (tSimpleLivingString2** const, Lfloat freq, Lfloat brightness, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, LEAF* const leaf); - void tSimpleLivingString2_initToPool (tSimpleLivingString2* const, Lfloat freq, Lfloat brightness, + void tSimpleLivingString2_initToPool (tSimpleLivingString2** const, Lfloat freq, Lfloat brightness, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, tMempool* const); - void tSimpleLivingString2_free (tSimpleLivingString2* const); + void tSimpleLivingString2_free (tSimpleLivingString2** const); - Lfloat tSimpleLivingString2_tick (tSimpleLivingString2 const, Lfloat input); + Lfloat tSimpleLivingString2_tick (tSimpleLivingString2* const, Lfloat input); - Lfloat tSimpleLivingString2_sample (tSimpleLivingString2 const); - void tSimpleLivingString2_setFreq (tSimpleLivingString2 const, Lfloat freq); - void tSimpleLivingString2_setWaveLength (tSimpleLivingString2 const, Lfloat waveLength); // in samples - void tSimpleLivingString2_setBrightness (tSimpleLivingString2 const, Lfloat brightness); - void tSimpleLivingString2_setDecay (tSimpleLivingString2 const, Lfloat decay); // should be near 1.0 - void tSimpleLivingString2_setTargetLev (tSimpleLivingString2 const, Lfloat targetLev); - void tSimpleLivingString2_setLevSmoothFactor (tSimpleLivingString2 const, Lfloat levSmoothFactor); - void tSimpleLivingString2_setLevStrength (tSimpleLivingString2 const, Lfloat levStrength); - void tSimpleLivingString2_setLevMode (tSimpleLivingString2 const, int levMode); - void tSimpleLivingString2_setSampleRate (tSimpleLivingString2 const, Lfloat sr); + Lfloat tSimpleLivingString2_sample (tSimpleLivingString2* const); + void tSimpleLivingString2_setFreq (tSimpleLivingString2* const, Lfloat freq); + void tSimpleLivingString2_setWaveLength (tSimpleLivingString2* const, Lfloat waveLength); // in samples + void tSimpleLivingString2_setBrightness (tSimpleLivingString2* const, Lfloat brightness); + void tSimpleLivingString2_setDecay (tSimpleLivingString2* const, Lfloat decay); // should be near 1.0 + void tSimpleLivingString2_setTargetLev (tSimpleLivingString2* const, Lfloat targetLev); + void tSimpleLivingString2_setLevSmoothFactor (tSimpleLivingString2* const, Lfloat levSmoothFactor); + void tSimpleLivingString2_setLevStrength (tSimpleLivingString2* const, Lfloat levStrength); + void tSimpleLivingString2_setLevMode (tSimpleLivingString2* const, int levMode); + void tSimpleLivingString2_setSampleRate (tSimpleLivingString2* const, Lfloat sr); // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ -typedef struct _tSimpleLivingString3 +typedef struct tSimpleLivingString3 { tMempool mempool; @@ -423,35 +413,33 @@ typedef struct _tSimpleLivingString3 Lfloat rippleGain; Lfloat rippleDelay; Lfloat invOnePlusr; -} _tSimpleLivingString3; - -typedef _tSimpleLivingString3* tSimpleLivingString3; +} tSimpleLivingString3; -void tSimpleLivingString3_init (tSimpleLivingString3* const, int oversampling, Lfloat freq, Lfloat dam, +void tSimpleLivingString3_init (tSimpleLivingString3** const, int oversampling, Lfloat freq, Lfloat dam, Lfloat decay, Lfloat targetLev, Lfloat levSmoothF, Lfloat levStrength, int levMode, LEAF* const leaf); -void tSimpleLivingString3_initToPool (tSimpleLivingString3* const pl, int oversampling, Lfloat freq, Lfloat dam, +void tSimpleLivingString3_initToPool (tSimpleLivingString3** const pl, int oversampling, Lfloat freq, Lfloat dam, Lfloat decay, Lfloat targetLev, Lfloat levSmoothF, Lfloat levStrength, int levMode, tMempool* const mp); -void tSimpleLivingString3_free (tSimpleLivingString3* const); - -Lfloat tSimpleLivingString3_tick (tSimpleLivingString3 const, Lfloat input); - -void tSimpleLivingString3_pluck (tSimpleLivingString3 const pl, Lfloat input, Lfloat position); -void tSimpleLivingString3_setPickupPoint (tSimpleLivingString3 const pl, Lfloat pickupPoint); -Lfloat tSimpleLivingString3_sample (tSimpleLivingString3 const); -void tSimpleLivingString3_setFreq (tSimpleLivingString3 const, Lfloat freq); -void tSimpleLivingString3_setWaveLength (tSimpleLivingString3 const, Lfloat waveLength); // in samples -void tSimpleLivingString3_setDampFreq (tSimpleLivingString3 const, Lfloat dampFreq); -void tSimpleLivingString3_setDecay (tSimpleLivingString3 const, Lfloat decay); // should be near 1.0 -void tSimpleLivingString3_setTargetLev (tSimpleLivingString3 const, Lfloat targetLev); -void tSimpleLivingString3_setLevSmoothFactor (tSimpleLivingString3 const, Lfloat levSmoothFactor); -void tSimpleLivingString3_setLevStrength (tSimpleLivingString3 const, Lfloat levStrength); -void tSimpleLivingString3_setLevMode (tSimpleLivingString3 const, int levMode); -void tSimpleLivingString3_setSampleRate (tSimpleLivingString3 const, Lfloat sr); +void tSimpleLivingString3_free (tSimpleLivingString3** const); + +Lfloat tSimpleLivingString3_tick (tSimpleLivingString3* const, Lfloat input); + +void tSimpleLivingString3_pluck (tSimpleLivingString3* const pl, Lfloat input, Lfloat position); +void tSimpleLivingString3_setPickupPoint (tSimpleLivingString3* const pl, Lfloat pickupPoint); +Lfloat tSimpleLivingString3_sample (tSimpleLivingString3* const); +void tSimpleLivingString3_setFreq (tSimpleLivingString3* const, Lfloat freq); +void tSimpleLivingString3_setWaveLength (tSimpleLivingString3* const, Lfloat waveLength); // in samples +void tSimpleLivingString3_setDampFreq (tSimpleLivingString3* const, Lfloat dampFreq); +void tSimpleLivingString3_setDecay (tSimpleLivingString3* const, Lfloat decay); // should be near 1.0 +void tSimpleLivingString3_setTargetLev (tSimpleLivingString3* const, Lfloat targetLev); +void tSimpleLivingString3_setLevSmoothFactor (tSimpleLivingString3* const, Lfloat levSmoothFactor); +void tSimpleLivingString3_setLevStrength (tSimpleLivingString3* const, Lfloat levStrength); +void tSimpleLivingString3_setLevMode (tSimpleLivingString3* const, int levMode); +void tSimpleLivingString3_setSampleRate (tSimpleLivingString3* const, Lfloat sr); // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ -typedef struct _tSimpleLivingString4 +typedef struct tSimpleLivingString4 { tMempool mempool; @@ -480,38 +468,36 @@ typedef struct _tSimpleLivingString4 Lfloat sampleRate; Lfloat rippleGain; Lfloat rippleDelay; -} _tSimpleLivingString4; +} tSimpleLivingString4; -typedef _tSimpleLivingString4* tSimpleLivingString4; - -void tSimpleLivingString4_init (tSimpleLivingString4* const, int oversampling, Lfloat freq, Lfloat dampFreq, +void tSimpleLivingString4_init (tSimpleLivingString4** const, int oversampling, Lfloat freq, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor,Lfloat levStrength, int levMode, LEAF* const leaf); -void tSimpleLivingString4_initToPool (tSimpleLivingString4* const pl, int oversampling, Lfloat freq, Lfloat dampFreq, +void tSimpleLivingString4_initToPool (tSimpleLivingString4** const pl, int oversampling, Lfloat freq, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, tMempool* const mp); -void tSimpleLivingString4_free (tSimpleLivingString4* const); - -Lfloat tSimpleLivingString4_tick (tSimpleLivingString4 const, Lfloat input); - -void tSimpleLivingString4_pluck (tSimpleLivingString4 const pl, Lfloat input, Lfloat position); -void tSimpleLivingString4_pluckNoPosition (tSimpleLivingString4 const pl, Lfloat input); -void tSimpleLivingString4_setPluckPosition (tSimpleLivingString4 const pl, Lfloat position); -void tSimpleLivingString4_setPickupPoint (tSimpleLivingString4 const pl, Lfloat pickupPoint); -Lfloat tSimpleLivingString4_sample (tSimpleLivingString4 const); -void tSimpleLivingString4_setFreq (tSimpleLivingString4 const, Lfloat freq); -void tSimpleLivingString4_setWaveLength (tSimpleLivingString4 const, Lfloat waveLength); // in samples -void tSimpleLivingString4_setDampFreq (tSimpleLivingString4 const, Lfloat dampFreq); -void tSimpleLivingString4_setDecay (tSimpleLivingString4 const, Lfloat decay); // should be near 1.0 -void tSimpleLivingString4_setTargetLev (tSimpleLivingString4 const, Lfloat targetLev); -void tSimpleLivingString4_setLevSmoothFactor (tSimpleLivingString4 const, Lfloat levSmoothFactor); -void tSimpleLivingString4_setLevStrength (tSimpleLivingString4 const, Lfloat levStrength); -void tSimpleLivingString4_setLevMode (tSimpleLivingString4 const, int levMode); -void tSimpleLivingString4_setSampleRate (tSimpleLivingString4 const, Lfloat sr); +void tSimpleLivingString4_free (tSimpleLivingString4** const); + +Lfloat tSimpleLivingString4_tick (tSimpleLivingString4* const, Lfloat input); + +void tSimpleLivingString4_pluck (tSimpleLivingString4* const pl, Lfloat input, Lfloat position); +void tSimpleLivingString4_pluckNoPosition (tSimpleLivingString4* const pl, Lfloat input); +void tSimpleLivingString4_setPluckPosition (tSimpleLivingString4* const pl, Lfloat position); +void tSimpleLivingString4_setPickupPoint (tSimpleLivingString4* const pl, Lfloat pickupPoint); +Lfloat tSimpleLivingString4_sample (tSimpleLivingString4* const); +void tSimpleLivingString4_setFreq (tSimpleLivingString4* const, Lfloat freq); +void tSimpleLivingString4_setWaveLength (tSimpleLivingString4* const, Lfloat waveLength); // in samples +void tSimpleLivingString4_setDampFreq (tSimpleLivingString4* const, Lfloat dampFreq); +void tSimpleLivingString4_setDecay (tSimpleLivingString4* const, Lfloat decay); // should be near 1.0 +void tSimpleLivingString4_setTargetLev (tSimpleLivingString4* const, Lfloat targetLev); +void tSimpleLivingString4_setLevSmoothFactor (tSimpleLivingString4* const, Lfloat levSmoothFactor); +void tSimpleLivingString4_setLevStrength (tSimpleLivingString4* const, Lfloat levStrength); +void tSimpleLivingString4_setLevMode (tSimpleLivingString4* const, int levMode); +void tSimpleLivingString4_setSampleRate (tSimpleLivingString4* const, Lfloat sr); // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ -typedef struct _tSimpleLivingString5 +typedef struct tSimpleLivingString5 { tMempool mempool; @@ -545,37 +531,35 @@ typedef struct _tSimpleLivingString5 Lfloat rippleDelay; Lfloat ff; Lfloat fb; -} _tSimpleLivingString5; - -typedef _tSimpleLivingString5* tSimpleLivingString5; +} tSimpleLivingString5; -void tSimpleLivingString5_init (tSimpleLivingString5* const, int oversampling, Lfloat freq, Lfloat dampFreq, +void tSimpleLivingString5_init (tSimpleLivingString5** const, int oversampling, Lfloat freq, Lfloat dampFreq, Lfloat decay, Lfloat prepPos, Lfloat prepIndex, Lfloat pluckPos, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, LEAF* const leaf); -void tSimpleLivingString5_initToPool (tSimpleLivingString5* const pl, int oversampling, Lfloat freq, Lfloat dampFreq, +void tSimpleLivingString5_initToPool (tSimpleLivingString5** const pl, int oversampling, Lfloat freq, Lfloat dampFreq, Lfloat decay, Lfloat prepPos, Lfloat prepIndex, Lfloat pluckPos, Lfloat targetLev, Lfloat levSmoothFactor,Lfloat levStrength, int levMode, tMempool* const mp); -void tSimpleLivingString5_free (tSimpleLivingString5* const); - -Lfloat tSimpleLivingString5_tick (tSimpleLivingString5 const, Lfloat input); - -void tSimpleLivingString5_pluck (tSimpleLivingString5 const pl, Lfloat input, Lfloat position); -void tSimpleLivingString5_pluckNoPosition (tSimpleLivingString5 const pl, Lfloat input); -void tSimpleLivingString5_setPluckPosition (tSimpleLivingString5 const pl, Lfloat position); -void tSimpleLivingString5_setPrepPosition (tSimpleLivingString5 const pl, Lfloat prepPosition); -void tSimpleLivingString5_setPrepIndex (tSimpleLivingString5 const pl, Lfloat prepIndex); -void tSimpleLivingString5_setPickupPoint (tSimpleLivingString5 const pl, Lfloat pickupPoint); -Lfloat tSimpleLivingString5_sample (tSimpleLivingString5 const); -void tSimpleLivingString5_setFreq (tSimpleLivingString5 const, Lfloat freq); -void tSimpleLivingString5_setWaveLength (tSimpleLivingString5 const, Lfloat waveLength); // in samples -void tSimpleLivingString5_setDampFreq (tSimpleLivingString5 const, Lfloat dampFreq); -void tSimpleLivingString5_setDecay (tSimpleLivingString5 const, Lfloat decay); // should be near 1.0 -void tSimpleLivingString5_setTargetLev (tSimpleLivingString5 const, Lfloat targetLev); -void tSimpleLivingString5_setLevSmoothFactor (tSimpleLivingString5 const, Lfloat levSmoothFactor); -void tSimpleLivingString5_setLevStrength (tSimpleLivingString5 const, Lfloat levStrength); -void tSimpleLivingString5_setLevMode (tSimpleLivingString5 const, int levMode); -void tSimpleLivingString5_setSampleRate (tSimpleLivingString5 const, Lfloat sr); -void tSimpleLivingString5_setFFAmount (tSimpleLivingString5 const pl, Lfloat ff); +void tSimpleLivingString5_free (tSimpleLivingString5** const); + +Lfloat tSimpleLivingString5_tick (tSimpleLivingString5* const, Lfloat input); + +void tSimpleLivingString5_pluck (tSimpleLivingString5* const pl, Lfloat input, Lfloat position); +void tSimpleLivingString5_pluckNoPosition (tSimpleLivingString5* const pl, Lfloat input); +void tSimpleLivingString5_setPluckPosition (tSimpleLivingString5* const pl, Lfloat position); +void tSimpleLivingString5_setPrepPosition (tSimpleLivingString5* const pl, Lfloat prepPosition); +void tSimpleLivingString5_setPrepIndex (tSimpleLivingString5* const pl, Lfloat prepIndex); +void tSimpleLivingString5_setPickupPoint (tSimpleLivingString5* const pl, Lfloat pickupPoint); +Lfloat tSimpleLivingString5_sample (tSimpleLivingString5* const); +void tSimpleLivingString5_setFreq (tSimpleLivingString5* const, Lfloat freq); +void tSimpleLivingString5_setWaveLength (tSimpleLivingString5* const, Lfloat waveLength); // in samples +void tSimpleLivingString5_setDampFreq (tSimpleLivingString5* const, Lfloat dampFreq); +void tSimpleLivingString5_setDecay (tSimpleLivingString5* const, Lfloat decay); // should be near 1.0 +void tSimpleLivingString5_setTargetLev (tSimpleLivingString5* const, Lfloat targetLev); +void tSimpleLivingString5_setLevSmoothFactor (tSimpleLivingString5* const, Lfloat levSmoothFactor); +void tSimpleLivingString5_setLevStrength (tSimpleLivingString5* const, Lfloat levStrength); +void tSimpleLivingString5_setLevMode (tSimpleLivingString5* const, int levMode); +void tSimpleLivingString5_setSampleRate (tSimpleLivingString5* const, Lfloat sr); +void tSimpleLivingString5_setFFAmount (tSimpleLivingString5* const pl, Lfloat ff); // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ @@ -653,7 +637,7 @@ void tSimpleLivingString5_setFFAmount (tSimpleLivingString5 const pl, @} */ - typedef struct _tLivingString + typedef struct tLivingString { tMempool mempool; Lfloat freq, waveLengthInSamples; // the frequency of the whole string, determining delay length @@ -669,32 +653,30 @@ void tSimpleLivingString5_setFFAmount (tSimpleLivingString5 const pl, tFeedbackLeveler fbLevU, fbLevL; tExpSmooth wlSmooth, ppSmooth; Lfloat sampleRate; - } _tLivingString; - - typedef _tLivingString* tLivingString; - - void tLivingString_init (tLivingString* const, Lfloat freq, Lfloat pickPos, Lfloat prepIndex, + } tLivingString; + + void tLivingString_init (tLivingString** const, Lfloat freq, Lfloat pickPos, Lfloat prepIndex, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, LEAF* const leaf); - void tLivingString_initToPool (tLivingString* const, Lfloat freq, Lfloat pickPos, Lfloat prepIndex, + void tLivingString_initToPool (tLivingString** const, Lfloat freq, Lfloat pickPos, Lfloat prepIndex, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, tMempool* const); - void tLivingString_free (tLivingString* const); + void tLivingString_free (tLivingString** const); - Lfloat tLivingString_tick (tLivingString const, Lfloat input); - - Lfloat tLivingString_sample (tLivingString const); - void tLivingString_setFreq (tLivingString const, Lfloat freq); - void tLivingString_setWaveLength (tLivingString const, Lfloat waveLength); // in samples - void tLivingString_setPickPos (tLivingString const, Lfloat pickPos); - void tLivingString_setPrepIndex (tLivingString const, Lfloat prepIndex); - void tLivingString_setDampFreq (tLivingString const, Lfloat dampFreq); - void tLivingString_setDecay (tLivingString const, Lfloat decay); // should be near 1.0 - void tLivingString_setTargetLev (tLivingString const, Lfloat targetLev); - void tLivingString_setLevSmoothFactor (tLivingString const, Lfloat levSmoothFactor); - void tLivingString_setLevStrength (tLivingString const, Lfloat levStrength); - void tLivingString_setLevMode (tLivingString const, int levMode); - void tLivingString_setSampleRate (tLivingString const, Lfloat sr); + Lfloat tLivingString_tick (tLivingString* const, Lfloat input); + + Lfloat tLivingString_sample (tLivingString* const); + void tLivingString_setFreq (tLivingString* const, Lfloat freq); + void tLivingString_setWaveLength (tLivingString* const, Lfloat waveLength); // in samples + void tLivingString_setPickPos (tLivingString* const, Lfloat pickPos); + void tLivingString_setPrepIndex (tLivingString* const, Lfloat prepIndex); + void tLivingString_setDampFreq (tLivingString* const, Lfloat dampFreq); + void tLivingString_setDecay (tLivingString* const, Lfloat decay); // should be near 1.0 + void tLivingString_setTargetLev (tLivingString* const, Lfloat targetLev); + void tLivingString_setLevSmoothFactor (tLivingString* const, Lfloat levSmoothFactor); + void tLivingString_setLevStrength (tLivingString* const, Lfloat levStrength); + void tLivingString_setLevMode (tLivingString* const, int levMode); + void tLivingString_setSampleRate (tLivingString* const, Lfloat sr); // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ @@ -775,7 +757,7 @@ void tSimpleLivingString5_setFFAmount (tSimpleLivingString5 const pl, @param string A pointer to the relevant tLivingString2. @} */ - typedef struct _tLivingString2 + typedef struct tLivingString2 { tMempool mempool; Lfloat freq, waveLengthInSamples; // the frequency of the whole string, determining delay length @@ -793,36 +775,34 @@ void tSimpleLivingString5_setFFAmount (tSimpleLivingString5 const pl, tFeedbackLeveler fbLevU, fbLevL; tExpSmooth wlSmooth, ppSmooth, prpSmooth, puSmooth; Lfloat sampleRate; - } _tLivingString2; - - typedef _tLivingString2* tLivingString2; - - void tLivingString2_init (tLivingString2* const, Lfloat freq, Lfloat pickPos, Lfloat prepPos, Lfloat pickupPos, + } tLivingString2; + + void tLivingString2_init (tLivingString2** const, Lfloat freq, Lfloat pickPos, Lfloat prepPos, Lfloat pickupPos, Lfloat prepIndex, Lfloat brightness, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, LEAF* const leaf); - void tLivingString2_initToPool (tLivingString2* const, Lfloat freq, Lfloat pickPos, Lfloat prepPos, Lfloat pickupPos, + void tLivingString2_initToPool (tLivingString2** const, Lfloat freq, Lfloat pickPos, Lfloat prepPos, Lfloat pickupPos, Lfloat prepIndex, Lfloat brightness, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, tMempool* const); - void tLivingString2_free (tLivingString2* const); + void tLivingString2_free (tLivingString2** const); - Lfloat tLivingString2_tick (tLivingString2 const, Lfloat input); - Lfloat tLivingString2_tickEfficient (tLivingString2 const, Lfloat input); - - void tLivingString2_updateDelays (tLivingString2 const pl); //necessary if using tickEfficient (so that parameter setting can be put in a slower process). included in standard tick. - Lfloat tLivingString2_sample (tLivingString2 const); - void tLivingString2_setFreq (tLivingString2 const, Lfloat freq); - void tLivingString2_setWaveLength (tLivingString2 const, Lfloat waveLength); // in samples - void tLivingString2_setPickPos (tLivingString2 const, Lfloat pickPos); - void tLivingString2_setPrepPos (tLivingString2 const, Lfloat prepPos); - void tLivingString2_setPickupPos (tLivingString2 const, Lfloat pickupPos); - void tLivingString2_setPrepIndex (tLivingString2 const, Lfloat prepIndex); - void tLivingString2_setBrightness (tLivingString2 const, Lfloat brightness); - void tLivingString2_setDecay (tLivingString2 const, Lfloat decay); // from 0 to 1, gets converted to real decay factor - void tLivingString2_setTargetLev (tLivingString2 const, Lfloat targetLev); - void tLivingString2_setLevSmoothFactor (tLivingString2 const, Lfloat levSmoothFactor); - void tLivingString2_setLevStrength (tLivingString2 const, Lfloat levStrength); - void tLivingString2_setLevMode (tLivingString2 const, int levMode); - void tLivingString2_setSampleRate (tLivingString2 const, Lfloat sr); + Lfloat tLivingString2_tick (tLivingString2* const, Lfloat input); + Lfloat tLivingString2_tickEfficient (tLivingString2* const, Lfloat input); + + void tLivingString2_updateDelays (tLivingString2* const pl); //necessary if using tickEfficient (so that parameter setting can be put in a slower process). included in standard tick. + Lfloat tLivingString2_sample (tLivingString2* const); + void tLivingString2_setFreq (tLivingString2* const, Lfloat freq); + void tLivingString2_setWaveLength (tLivingString2* const, Lfloat waveLength); // in samples + void tLivingString2_setPickPos (tLivingString2* const, Lfloat pickPos); + void tLivingString2_setPrepPos (tLivingString2* const, Lfloat prepPos); + void tLivingString2_setPickupPos (tLivingString2* const, Lfloat pickupPos); + void tLivingString2_setPrepIndex (tLivingString2* const, Lfloat prepIndex); + void tLivingString2_setBrightness (tLivingString2* const, Lfloat brightness); + void tLivingString2_setDecay (tLivingString2* const, Lfloat decay); // from 0 to 1, gets converted to real decay factor + void tLivingString2_setTargetLev (tLivingString2* const, Lfloat targetLev); + void tLivingString2_setLevSmoothFactor (tLivingString2* const, Lfloat levSmoothFactor); + void tLivingString2_setLevStrength (tLivingString2* const, Lfloat levStrength); + void tLivingString2_setLevMode (tLivingString2* const, int levMode); + void tLivingString2_setSampleRate (tLivingString2* const, Lfloat sr); // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ @@ -901,7 +881,7 @@ void tSimpleLivingString5_setFFAmount (tSimpleLivingString5 const pl, @} */ - typedef struct _tComplexLivingString + typedef struct tComplexLivingString { tMempool mempool; Lfloat freq, waveLengthInSamples; // the frequency of the whole string, determining delay length @@ -919,55 +899,51 @@ void tSimpleLivingString5_setFFAmount (tSimpleLivingString5 const pl, tFeedbackLeveler fbLevU, fbLevL; tExpSmooth wlSmooth, pickPosSmooth, prepPosSmooth; Lfloat sampleRate; - } _tComplexLivingString; - - typedef _tComplexLivingString* tComplexLivingString; - - void tComplexLivingString_init (tComplexLivingString* const, Lfloat freq, Lfloat pickPos, + } tComplexLivingString; + + void tComplexLivingString_init (tComplexLivingString** const, Lfloat freq, Lfloat pickPos, Lfloat prepPos, Lfloat prepIndex, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, LEAF* const leaf); - void tComplexLivingString_initToPool (tComplexLivingString* const, Lfloat freq, Lfloat pickPos, + void tComplexLivingString_initToPool (tComplexLivingString** const, Lfloat freq, Lfloat pickPos, Lfloat prepPos, Lfloat prepIndex, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, tMempool* const); - void tComplexLivingString_free (tComplexLivingString* const); + void tComplexLivingString_free (tComplexLivingString** const); - Lfloat tComplexLivingString_tick (tComplexLivingString const, Lfloat input); - - Lfloat tComplexLivingString_sample (tComplexLivingString const); - void tComplexLivingString_setFreq (tComplexLivingString const, Lfloat freq); - void tComplexLivingString_setWaveLength (tComplexLivingString const, Lfloat waveLength); // in samples - void tComplexLivingString_setPickPos (tComplexLivingString const, Lfloat pickPos); - void tComplexLivingString_setPrepPos (tComplexLivingString const, Lfloat prepPos); - void tComplexLivingString_setPrepIndex (tComplexLivingString const, Lfloat prepIndex); - void tComplexLivingString_setDampFreq (tComplexLivingString const, Lfloat dampFreq); - void tComplexLivingString_setDecay (tComplexLivingString const, Lfloat decay); // should be near 1.0 - void tComplexLivingString_setTargetLev (tComplexLivingString const, Lfloat targetLev); - void tComplexLivingString_setLevSmoothFactor (tComplexLivingString const, Lfloat levSmoothFactor); - void tComplexLivingString_setLevStrength (tComplexLivingString const, Lfloat levStrength); - void tComplexLivingString_setLevMode (tComplexLivingString const, int levMode); - void tComplexLivingString_setSampleRate (tComplexLivingString const, Lfloat sr); + Lfloat tComplexLivingString_tick (tComplexLivingString* const, Lfloat input); + + Lfloat tComplexLivingString_sample (tComplexLivingString* const); + void tComplexLivingString_setFreq (tComplexLivingString* const, Lfloat freq); + void tComplexLivingString_setWaveLength (tComplexLivingString* const, Lfloat waveLength); // in samples + void tComplexLivingString_setPickPos (tComplexLivingString* const, Lfloat pickPos); + void tComplexLivingString_setPrepPos (tComplexLivingString* const, Lfloat prepPos); + void tComplexLivingString_setPrepIndex (tComplexLivingString* const, Lfloat prepIndex); + void tComplexLivingString_setDampFreq (tComplexLivingString* const, Lfloat dampFreq); + void tComplexLivingString_setDecay (tComplexLivingString* const, Lfloat decay); // should be near 1.0 + void tComplexLivingString_setTargetLev (tComplexLivingString* const, Lfloat targetLev); + void tComplexLivingString_setLevSmoothFactor (tComplexLivingString* const, Lfloat levSmoothFactor); + void tComplexLivingString_setLevStrength (tComplexLivingString* const, Lfloat levStrength); + void tComplexLivingString_setLevMode (tComplexLivingString* const, int levMode); + void tComplexLivingString_setSampleRate (tComplexLivingString* const, Lfloat sr); // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //Bow Table -typedef struct _tBowTable { +typedef struct tBowTable { tMempool mempool; Lfloat offSet; Lfloat slope; Lfloat lastOutput; -} _tBowTable; - -typedef _tBowTable* tBowTable; +} tBowTable; -void tBowTable_init (tBowTable* const bt, LEAF* const leaf); -void tBowTable_initToPool (tBowTable* const bt, tMempool* const mp); -void tBowTable_free (tBowTable* const bt); +void tBowTable_init (tBowTable** const bt, LEAF* const leaf); +void tBowTable_initToPool (tBowTable** const bt, tMempool* const mp); +void tBowTable_free (tBowTable** const bt); -Lfloat tBowTable_lookup (tBowTable const bt, Lfloat sample); +Lfloat tBowTable_lookup (tBowTable* const bt, Lfloat sample); -typedef struct _tBowed +typedef struct tBowed { tMempool mempool; int oversampling; @@ -994,25 +970,23 @@ typedef struct _tBowed Lfloat invSampleRate; tSVF lowpass; Lfloat output; -} _tBowed; +} tBowed; -typedef _tBowed* tBowed; +void tBowed_init (tBowed** const, int oversampling, LEAF* const leaf); +void tBowed_initToPool (tBowed** const, int oversampling, tMempool* const); +void tBowed_free (tBowed** const); -void tBowed_init (tBowed* const, int oversampling, LEAF* const leaf); -void tBowed_initToPool (tBowed* const, int oversampling, tMempool* const); -void tBowed_free (tBowed* const); +Lfloat tBowed_tick (tBowed* const); -Lfloat tBowed_tick (tBowed const); - -void tBowed_setFreq (tBowed const, Lfloat freq); -void tBowed_setWaveLength (tBowed const, Lfloat waveLength); // in samples -void tBowed_setSampleRate (tBowed const, Lfloat sr); +void tBowed_setFreq (tBowed* const, Lfloat freq); +void tBowed_setWaveLength (tBowed* const, Lfloat waveLength); // in samples +void tBowed_setSampleRate (tBowed* const, Lfloat sr); // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //from Plucked-string synthesis algorithms with tension modulation nonlinearity //by Vesa Valimaki -typedef struct _tTString +typedef struct tTString { tMempool mempool; int oversampling; @@ -1118,49 +1092,47 @@ typedef struct _tTString tSVF peakFilt; Lfloat pickupAmount; tPickupNonLinearity p; -} _tTString; - -typedef _tTString* tTString; - -void tTString_init (tTString* const, int oversampling, Lfloat lowestFreq, LEAF* const leaf); -void tTString_initToPool (tTString* const, int oversampling, Lfloat lowestFreq, tMempool* const); -void tTString_free (tTString* const); - -Lfloat tTString_tick (tTString const); - -void tTString_setDecay (tTString const bw, Lfloat decay); -void tTString_mute (tTString const bw); -void tTString_setFilter (tTString const bw, Lfloat filter); -void tTString_setTensionGain (tTString const bw, Lfloat tensionGain); -void tTString_setTensionSpeed (tTString const bw, Lfloat tensionSpeed); -void tTString_setFreq (tTString const, Lfloat freq); -void tTString_pluck (tTString const bw, Lfloat position, Lfloat amplitude); -void tTString_setWavelength (tTString const, uint32_t waveLength); // in samples -void tTString_setSampleRate (tTString const, Lfloat sr); -void tTString_setHarmonicity (tTString const, Lfloat B, Lfloat freq); -void tTString_setRippleDepth (tTString const bw, Lfloat depth); -void tTString_setHarmonic (tTString const bw, Lfloat harmonic); -void tTString_setPhantomHarmonicsGain (tTString const bw, Lfloat gain); -void tTString_setSlideGain (tTString const bw, Lfloat gain); -void tTString_setPickupPos (tTString const bw, Lfloat pos); -void tTString_setPickupModAmp (tTString const bw, Lfloat amp); -void tTString_setPickupModFreq (tTString const bw, Lfloat freq); -void tTString_setBarPosition (tTString const bw, Lfloat barPosition); -void tTString_setOpenStringFrequency (tTString const bw, Lfloat openStringFrequency); -void tTString_setPickupRatio (tTString const bw, Lfloat ratio); -void tTString_setBarDrive (tTString const bw, Lfloat drive); -void tTString_setFeedbackStrength (tTString const bw, Lfloat strength); -void tTString_setFeedbackReactionSpeed (tTString const bw, Lfloat speed); -void tTString_setInharmonic (tTString const bw, uint32_t onOrOff); -void tTString_setWoundOrUnwound (tTString const bw, uint32_t wound); -void tTString_setWindingsPerInch (tTString const bw, uint32_t windings); -void tTString_setPickupFilterFreq (tTString const bw, Lfloat cutoff); -void tTString_setPickupFilterQ (tTString const bw, Lfloat Q); -void tTString_setPeakFilterFreq (tTString const bw, Lfloat freq); -void tTString_setPeakFilterQ (tTString const bw, Lfloat Q); -void tTString_setFilterFreqDirectly (tTString const bw, Lfloat freq); -void tTString_setDecayInSeconds (tTString const bw, Lfloat decay); -void tTString_setPickupAmount (tTString const bw, Lfloat amount); +} tTString; + +void tTString_init (tTString** const, int oversampling, Lfloat lowestFreq, LEAF* const leaf); +void tTString_initToPool (tTString** const, int oversampling, Lfloat lowestFreq, tMempool* const); +void tTString_free (tTString** const); + +Lfloat tTString_tick (tTString* const); + +void tTString_setDecay (tTString* const bw, Lfloat decay); +void tTString_mute (tTString* const bw); +void tTString_setFilter (tTString* const bw, Lfloat filter); +void tTString_setTensionGain (tTString* const bw, Lfloat tensionGain); +void tTString_setTensionSpeed (tTString* const bw, Lfloat tensionSpeed); +void tTString_setFreq (tTString* const, Lfloat freq); +void tTString_pluck (tTString* const bw, Lfloat position, Lfloat amplitude); +void tTString_setWavelength (tTString* const, uint32_t waveLength); // in samples +void tTString_setSampleRate (tTString* const, Lfloat sr); +void tTString_setHarmonicity (tTString* const, Lfloat B, Lfloat freq); +void tTString_setRippleDepth (tTString* const bw, Lfloat depth); +void tTString_setHarmonic (tTString* const bw, Lfloat harmonic); +void tTString_setPhantomHarmonicsGain (tTString* const bw, Lfloat gain); +void tTString_setSlideGain (tTString* const bw, Lfloat gain); +void tTString_setPickupPos (tTString* const bw, Lfloat pos); +void tTString_setPickupModAmp (tTString* const bw, Lfloat amp); +void tTString_setPickupModFreq (tTString* const bw, Lfloat freq); +void tTString_setBarPosition (tTString* const bw, Lfloat barPosition); +void tTString_setOpenStringFrequency (tTString* const bw, Lfloat openStringFrequency); +void tTString_setPickupRatio (tTString* const bw, Lfloat ratio); +void tTString_setBarDrive (tTString* const bw, Lfloat drive); +void tTString_setFeedbackStrength (tTString* const bw, Lfloat strength); +void tTString_setFeedbackReactionSpeed (tTString* const bw, Lfloat speed); +void tTString_setInharmonic (tTString* const bw, uint32_t onOrOff); +void tTString_setWoundOrUnwound (tTString* const bw, uint32_t wound); +void tTString_setWindingsPerInch (tTString* const bw, uint32_t windings); +void tTString_setPickupFilterFreq (tTString* const bw, Lfloat cutoff); +void tTString_setPickupFilterQ (tTString* const bw, Lfloat Q); +void tTString_setPeakFilterFreq (tTString* const bw, Lfloat freq); +void tTString_setPeakFilterQ (tTString* const bw, Lfloat Q); +void tTString_setFilterFreqDirectly (tTString* const bw, Lfloat freq); +void tTString_setDecayInSeconds (tTString* const bw, Lfloat decay); +void tTString_setPickupAmount (tTString* const bw, Lfloat amount); /*! * * @defgroup treedtable tReedTable @@ -1200,28 +1172,26 @@ void tTString_setPickupAmount (tTString const bw, Lfloat amount); @} */ - typedef struct _tReedTable + typedef struct tReedTable { tMempool mempool; Lfloat offset, slope; - } _tReedTable; - - typedef _tReedTable* tReedTable; - - void tReedTable_init (tReedTable* const, Lfloat offset, Lfloat slope, LEAF* const leaf); - void tReedTable_initToPool (tReedTable* const, Lfloat offset, Lfloat slope, tMempool* const); - void tReedTable_free (tReedTable* const); + } tReedTable; + + void tReedTable_init (tReedTable** const, Lfloat offset, Lfloat slope, LEAF* const leaf); + void tReedTable_initToPool (tReedTable** const, Lfloat offset, Lfloat slope, tMempool* const); + void tReedTable_free (tReedTable** const); - Lfloat tReedTable_tick (tReedTable const, Lfloat input); - Lfloat tReedTable_tanh_tick (tReedTable const, Lfloat input); //tanh softclip version of reed table - replacing the hard clip in original stk code + Lfloat tReedTable_tick (tReedTable* const, Lfloat input); + Lfloat tReedTable_tanh_tick (tReedTable* const, Lfloat input); //tanh softclip version of reed table - replacing the hard clip in original stk code - void tReedTable_setOffset (tReedTable const, Lfloat offset); - void tReedTable_setSlope (tReedTable const, Lfloat slope); + void tReedTable_setOffset (tReedTable* const, Lfloat offset); + void tReedTable_setSlope (tReedTable* const, Lfloat slope); //============================================================================== -typedef struct _tStiffString +typedef struct tStiffString { tMempool mempool; int numModes; @@ -1245,38 +1215,36 @@ typedef struct _tStiffString Lfloat muteDecay; Lfloat amp; Lfloat gainComp; - } _tStiffString; - - typedef _tStiffString* tStiffString; + } tStiffString; - void tStiffString_init (tStiffString* const, int numModes, LEAF* const leaf); - void tStiffString_initToPool (tStiffString* const, int numModes, tMempool* const); - void tStiffString_free (tStiffString* const); + void tStiffString_init (tStiffString** const, int numModes, LEAF* const leaf); + void tStiffString_initToPool (tStiffString** const, int numModes, tMempool* const); + void tStiffString_free (tStiffString** const); - Lfloat tStiffString_tick (tStiffString const); - void tStiffString_setStiffness (tStiffString const, Lfloat newValue); - void tStiffString_setFreq (tStiffString const, Lfloat newFreq); - void tStiffString_pluck (tStiffString const, Lfloat amp); - void tStiffString_setPickupPos (tStiffString const, Lfloat pickuppos); - void tStiffString_setPluckPos (tStiffString const, Lfloat pluckpos); - void tStiffString_setDecay (tStiffString const, Lfloat decay); - void tStiffString_setDecayHighFreq (tStiffString const, Lfloat decayHF); - void tStiffString_updateOscillators (tStiffString const pm); - void tStiffString_updateOutputWeights (tStiffString const pm); - void tStiffString_mute (tStiffString const pm); - void tStiffString_setStiffnessNoUpdate (tStiffString const, Lfloat newValue); - void tStiffString_setFreqNoUpdate (tStiffString const, Lfloat newFreq); - void tStiffString_pluckNoUpdate (tStiffString const, Lfloat amp); - void tStiffString_setPickupPosNoUpdate (tStiffString const, Lfloat pickuppos); - void tStiffString_setPluckPosNoUpdate (tStiffString const, Lfloat pluckpos); - void tStiffString_setDecayNoUpdate (tStiffString const, Lfloat decay); - void tStiffString_setDecayHighFreqNoUpdate (tStiffString const, Lfloat decayHF); + Lfloat tStiffString_tick (tStiffString* const); + void tStiffString_setStiffness (tStiffString* const, Lfloat newValue); + void tStiffString_setFreq (tStiffString* const, Lfloat newFreq); + void tStiffString_pluck (tStiffString* const, Lfloat amp); + void tStiffString_setPickupPos (tStiffString* const, Lfloat pickuppos); + void tStiffString_setPluckPos (tStiffString* const, Lfloat pluckpos); + void tStiffString_setDecay (tStiffString* const, Lfloat decay); + void tStiffString_setDecayHighFreq (tStiffString* const, Lfloat decayHF); + void tStiffString_updateOscillators (tStiffString* const pm); + void tStiffString_updateOutputWeights (tStiffString* const pm); + void tStiffString_mute (tStiffString* const pm); + void tStiffString_setStiffnessNoUpdate (tStiffString* const, Lfloat newValue); + void tStiffString_setFreqNoUpdate (tStiffString* const, Lfloat newFreq); + void tStiffString_pluckNoUpdate (tStiffString* const, Lfloat amp); + void tStiffString_setPickupPosNoUpdate (tStiffString* const, Lfloat pickuppos); + void tStiffString_setPluckPosNoUpdate (tStiffString* const, Lfloat pluckpos); + void tStiffString_setDecayNoUpdate (tStiffString* const, Lfloat decay); + void tStiffString_setDecayHighFreqNoUpdate (tStiffString* const, Lfloat decayHF); - typedef struct _tStereoRotation + typedef struct tStereoRotation { tMempool mempool; Lfloat angle; @@ -1291,23 +1259,22 @@ typedef struct _tStiffString tOnePole filty; Lfloat feedbackFactorx; Lfloat feedbackFactory; - } _tStereoRotation; - - typedef _tStereoRotation* tStereoRotation; - - void tStereoRotation_init (tStereoRotation* const, LEAF* const leaf); - void tStereoRotation_initToPool (tStereoRotation* const rr, tMempool* const mp); - void tStereoRotation_tick (tStereoRotation const r, float* samples); - void tStereoRotation_tickIn (tStereoRotation const r, float* samples); - void tStereoRotation_tickOut (tStereoRotation const r, float* samples); - void tStereoRotation_setAngle (tStereoRotation const r, float input); - void tStereoRotation_setDelayX (tStereoRotation const r, float time); - void tStereoRotation_setDelayY (tStereoRotation const r, float time); - void tStereoRotation_setFeedbackX (tStereoRotation const r, float feedbackx); - void tStereoRotation_setFeedbackY (tStereoRotation const r, float feedbacky); - void tStereoRotation_setFilterX (tStereoRotation const r, float freq); - void tStereoRotation_setFilterY (tStereoRotation const r, float freq); - void tStereoRotation_setGain (tStereoRotation const r, float gain); + } tStereoRotation; + + void tStereoRotation_init (tStereoRotation** const, LEAF* const leaf); + void tStereoRotation_initToPool (tStereoRotation** const rr, tMempool* const mp); + + void tStereoRotation_tick (tStereoRotation* const r, float* samples); + void tStereoRotation_tickIn (tStereoRotation* const r, float* samples); + void tStereoRotation_tickOut (tStereoRotation* const r, float* samples); + void tStereoRotation_setAngle (tStereoRotation* const r, float input); + void tStereoRotation_setDelayX (tStereoRotation* const r, float time); + void tStereoRotation_setDelayY (tStereoRotation* const r, float time); + void tStereoRotation_setFeedbackX (tStereoRotation* const r, float feedbackx); + void tStereoRotation_setFeedbackY (tStereoRotation* const r, float feedbacky); + void tStereoRotation_setFilterX (tStereoRotation* const r, float freq); + void tStereoRotation_setFilterY (tStereoRotation* const r, float freq); + void tStereoRotation_setGain (tStereoRotation* const r, float gain); #ifdef __cplusplus diff --git a/leaf/Inc/leaf-reverb.h b/leaf/Inc/leaf-reverb.h index e0b7923..09b576e 100644 --- a/leaf/Inc/leaf-reverb.h +++ b/leaf/Inc/leaf-reverb.h @@ -70,7 +70,7 @@ extern "C" { @} */ - typedef struct _tPRCReverb + typedef struct tPRCReverb { tMempool mempool; @@ -86,20 +86,18 @@ extern "C" { Lfloat combCoeff; Lfloat lastIn, lastOut; - } _tPRCReverb; - - typedef _tPRCReverb* tPRCReverb; - - void tPRCReverb_init (tPRCReverb* const, Lfloat t60, LEAF* const leaf); - void tPRCReverb_initToPool (tPRCReverb* const, Lfloat t60, tMempool* const); - void tPRCReverb_free (tPRCReverb* const); + } tPRCReverb; + + void tPRCReverb_init (tPRCReverb** const, Lfloat t60, LEAF* const leaf); + void tPRCReverb_initToPool (tPRCReverb** const, Lfloat t60, tMempool* const); + void tPRCReverb_free (tPRCReverb** const); - Lfloat tPRCReverb_tick (tPRCReverb const, Lfloat input); + Lfloat tPRCReverb_tick (tPRCReverb* const, Lfloat input); - void tPRCReverb_clear (tPRCReverb const); - void tPRCReverb_setT60 (tPRCReverb const, Lfloat t60); - void tPRCReverb_setMix (tPRCReverb const, Lfloat mix); - void tPRCReverb_setSampleRate (tPRCReverb const, Lfloat sr); + void tPRCReverb_clear (tPRCReverb* const); + void tPRCReverb_setT60 (tPRCReverb* const, Lfloat t60); + void tPRCReverb_setMix (tPRCReverb* const, Lfloat mix); + void tPRCReverb_setSampleRate (tPRCReverb* const, Lfloat sr); //============================================================================== @@ -145,7 +143,7 @@ extern "C" { @} */ - typedef struct _tNReverb + typedef struct tNReverb { tMempool mempool; @@ -162,21 +160,19 @@ extern "C" { Lfloat lowpassState; Lfloat lastIn, lastOut; - } _tNReverb; - - typedef _tNReverb* tNReverb; - - void tNReverb_init (tNReverb* const, Lfloat t60, LEAF* const leaf); - void tNReverb_initToPool (tNReverb* const, Lfloat t60, tMempool* const); - void tNReverb_free (tNReverb* const); + } tNReverb; - Lfloat tNReverb_tick (tNReverb const, Lfloat input); - void tNReverb_tickStereo (tNReverb const rev, Lfloat input, Lfloat* output); + void tNReverb_init (tNReverb** const, Lfloat t60, LEAF* const leaf); + void tNReverb_initToPool (tNReverb** const, Lfloat t60, tMempool* const); + void tNReverb_free (tNReverb** const); - void tNReverb_clear (tNReverb const); - void tNReverb_setT60 (tNReverb const, Lfloat t60); - void tNReverb_setMix (tNReverb const, Lfloat mix); - void tNReverb_setSampleRate (tNReverb const, Lfloat sr); + Lfloat tNReverb_tick (tNReverb* const, Lfloat input); + void tNReverb_tickStereo (tNReverb* const rev, Lfloat input, Lfloat* output); + + void tNReverb_clear (tNReverb* const); + void tNReverb_setT60 (tNReverb* const, Lfloat t60); + void tNReverb_setMix (tNReverb* const, Lfloat mix); + void tNReverb_setSampleRate (tNReverb* const, Lfloat sr); //============================================================================== @@ -246,7 +242,7 @@ extern "C" { @} */ - typedef struct _tDattorroReverb + typedef struct tDattorroReverb { tMempool mempool; @@ -291,27 +287,25 @@ extern "C" { tHighpass f2_hp; tCycle f2_lfo; - } _tDattorroReverb; - - typedef _tDattorroReverb* tDattorroReverb; - - void tDattorroReverb_init (tDattorroReverb* const, LEAF* const leaf); - void tDattorroReverb_initToPool (tDattorroReverb* const, tMempool* const); - void tDattorroReverb_free (tDattorroReverb* const); + } tDattorroReverb; + + void tDattorroReverb_init (tDattorroReverb** const, LEAF* const leaf); + void tDattorroReverb_initToPool (tDattorroReverb** const, tMempool* const); + void tDattorroReverb_free (tDattorroReverb** const); - Lfloat tDattorroReverb_tick (tDattorroReverb const, Lfloat input); - void tDattorroReverb_tickStereo (tDattorroReverb const rev, Lfloat input, Lfloat* output); + Lfloat tDattorroReverb_tick (tDattorroReverb* const, Lfloat input); + void tDattorroReverb_tickStereo (tDattorroReverb* const rev, Lfloat input, Lfloat* output); - void tDattorroReverb_clear (tDattorroReverb const); - void tDattorroReverb_setMix (tDattorroReverb const, Lfloat mix); - void tDattorroReverb_setFreeze (tDattorroReverb const rev, int freeze); - void tDattorroReverb_setHP (tDattorroReverb const, Lfloat freq); - void tDattorroReverb_setSize (tDattorroReverb const, Lfloat size); - void tDattorroReverb_setInputDelay (tDattorroReverb const, Lfloat preDelay); - void tDattorroReverb_setInputFilter (tDattorroReverb const, Lfloat freq); - void tDattorroReverb_setFeedbackFilter (tDattorroReverb const, Lfloat freq); - void tDattorroReverb_setFeedbackGain (tDattorroReverb const, Lfloat gain); - void tDattorroReverb_setSampleRate (tDattorroReverb const, Lfloat sr); + void tDattorroReverb_clear (tDattorroReverb* const); + void tDattorroReverb_setMix (tDattorroReverb* const, Lfloat mix); + void tDattorroReverb_setFreeze (tDattorroReverb* const rev, int freeze); + void tDattorroReverb_setHP (tDattorroReverb* const, Lfloat freq); + void tDattorroReverb_setSize (tDattorroReverb* const, Lfloat size); + void tDattorroReverb_setInputDelay (tDattorroReverb* const, Lfloat preDelay); + void tDattorroReverb_setInputFilter (tDattorroReverb* const, Lfloat freq); + void tDattorroReverb_setFeedbackFilter (tDattorroReverb* const, Lfloat freq); + void tDattorroReverb_setFeedbackGain (tDattorroReverb* const, Lfloat gain); + void tDattorroReverb_setSampleRate (tDattorroReverb* const, Lfloat sr); #ifdef __cplusplus } diff --git a/leaf/Inc/leaf-sampling.h b/leaf/Inc/leaf-sampling.h index 9a8649f..e20bf33 100644 --- a/leaf/Inc/leaf-sampling.h +++ b/leaf/Inc/leaf-sampling.h @@ -129,7 +129,7 @@ extern "C" RecordModeNil } RecordMode; - typedef struct _tBuffer + typedef struct tBuffer { tMempool mempool; @@ -144,29 +144,27 @@ extern "C" RecordMode mode; int active; - } _tBuffer; - - typedef _tBuffer *tBuffer; - - void tBuffer_init (tBuffer *const, uint32_t length, LEAF *const leaf); - void tBuffer_initToPool (tBuffer *const sb, uint32_t length, tMempool *const mp); - void tBuffer_free (tBuffer *const); - - void tBuffer_tick (tBuffer const, Lfloat sample); - - void tBuffer_read (tBuffer const, Lfloat *buff, uint32_t len); - Lfloat tBuffer_get (tBuffer const, int idx); - void tBuffer_record (tBuffer const); - void tBuffer_stop (tBuffer const); - void tBuffer_setBuffer (tBuffer const sb, Lfloat *externalBuffer, int length, int channels, int sampleRate); - int tBuffer_getRecordPosition (tBuffer const); - void tBuffer_setRecordPosition (tBuffer const, int pos); - void tBuffer_setRecordMode (tBuffer const, RecordMode mode); - void tBuffer_clear (tBuffer const); - uint32_t tBuffer_getBufferLength (tBuffer const); - uint32_t tBuffer_getRecordedLength (tBuffer const sb); - void tBuffer_setRecordedLength (tBuffer const sb, int length); - int tBuffer_isActive (tBuffer const sb); + } tBuffer; + + void tBuffer_init (tBuffer**const, uint32_t length, LEAF *const leaf); + void tBuffer_initToPool (tBuffer**const sb, uint32_t length, tMempool *const mp); + void tBuffer_free (tBuffer**const); + + void tBuffer_tick (tBuffer* const, Lfloat sample); + + void tBuffer_read (tBuffer* const, Lfloat *buff, uint32_t len); + Lfloat tBuffer_get (tBuffer* const, int idx); + void tBuffer_record (tBuffer* const); + void tBuffer_stop (tBuffer* const); + void tBuffer_setBuffer (tBuffer* const sb, Lfloat *externalBuffer, int length, int channels, int sampleRate); + int tBuffer_getRecordPosition (tBuffer* const); + void tBuffer_setRecordPosition (tBuffer* const, int pos); + void tBuffer_setRecordMode (tBuffer* const, RecordMode mode); + void tBuffer_clear (tBuffer* const); + uint32_t tBuffer_getBufferLength (tBuffer* const); + uint32_t tBuffer_getRecordedLength (tBuffer* const sb); + void tBuffer_setRecordedLength (tBuffer* const sb, int length); + int tBuffer_isActive (tBuffer* const sb); //============================================================================== @@ -242,7 +240,7 @@ extern "C" PlayModeNil } PlayMode; - typedef struct _tSampler + typedef struct tSampler { tMempool mempool; @@ -279,28 +277,26 @@ extern "C" Lfloat flipStart; Lfloat flipIdx; - } _tSampler; - - typedef _tSampler *tSampler; - - void tSampler_init (tSampler *const, tBuffer *const, LEAF *const leaf); - void tSampler_initToPool (tSampler *const sp, tBuffer *const b, tMempool *const mp, LEAF *const leaf); - void tSampler_free (tSampler *const); - - Lfloat tSampler_tick (tSampler const); - Lfloat tSampler_tickStereo (tSampler const sp, Lfloat *outputArray); - - void tSampler_setSample (tSampler const, tBuffer const); - void tSampler_setMode (tSampler const, PlayMode mode); - void tSampler_play (tSampler const); - void tSampler_stop (tSampler const); - void tSampler_setStart (tSampler const, int32_t start); - void tSampler_setEnd (tSampler const, int32_t end); - void tSampler_setEndUnsafe (tSampler const, int32_t end); - void tSampler_setLength (tSampler const, int32_t length); - void tSampler_setCrossfadeLength (tSampler const, uint32_t length); - void tSampler_setRate (tSampler const, Lfloat rate); - void tSampler_setSampleRate (tSampler const, Lfloat sr); + } tSampler; + + void tSampler_init (tSampler**const, tBuffer *const, LEAF *const leaf); + void tSampler_initToPool (tSampler**const sp, tBuffer *const b, tMempool *const mp, LEAF *const leaf); + void tSampler_free (tSampler**const); + + Lfloat tSampler_tick (tSampler* const); + Lfloat tSampler_tickStereo (tSampler* const sp, Lfloat *outputArray); + + void tSampler_setSample (tSampler* const, tBuffer const); + void tSampler_setMode (tSampler* const, PlayMode mode); + void tSampler_play (tSampler* const); + void tSampler_stop (tSampler* const); + void tSampler_setStart (tSampler* const, int32_t start); + void tSampler_setEnd (tSampler* const, int32_t end); + void tSampler_setEndUnsafe (tSampler* const, int32_t end); + void tSampler_setLength (tSampler* const, int32_t length); + void tSampler_setCrossfadeLength (tSampler* const, uint32_t length); + void tSampler_setRate (tSampler* const, Lfloat rate); + void tSampler_setSampleRate (tSampler* const, Lfloat sr); //============================================================================== @@ -362,7 +358,7 @@ extern "C" @} */ - typedef struct _tAutoSampler + typedef struct tAutoSampler { tMempool mempool; @@ -374,25 +370,23 @@ extern "C" uint32_t sampleCounter; uint32_t powerCounter; uint8_t sampleTriggered; - } _tAutoSampler; - - typedef _tAutoSampler *tAutoSampler; + } tAutoSampler; - void tAutoSampler_init (tAutoSampler *const, tBuffer *const, LEAF *const leaf); - void tAutoSampler_initToPool (tAutoSampler *const as, tBuffer *const b, tMempool *const mp, LEAF *const leaf); - void tAutoSampler_free (tAutoSampler *const); + void tAutoSampler_init (tAutoSampler**const, tBuffer *const, LEAF *const leaf); + void tAutoSampler_initToPool (tAutoSampler**const as, tBuffer *const b, tMempool *const mp, LEAF *const leaf); + void tAutoSampler_free (tAutoSampler**const); - Lfloat AutoSampler_tick (tAutoSampler const, Lfloat input); + Lfloat AutoSampler_tick (tAutoSampler* const, Lfloat input); - void tAutoSampler_setBuffer (tAutoSampler const, tBuffer const); - void tAutoSampler_setMode (tAutoSampler const, PlayMode mode); - void tAutoSampler_play (tAutoSampler const); - void tAutoSampler_stop (tAutoSampler const); - void tAutoSampler_setThreshold (tAutoSampler const, Lfloat thresh); - void tAutoSampler_setWindowSize (tAutoSampler const, uint32_t size); - void tAutoSampler_setCrossfadeLength (tAutoSampler const, uint32_t length); - void tAutoSampler_setRate (tAutoSampler const, Lfloat rate); - void tAutoSampler_setSampleRate (tAutoSampler const, Lfloat sr); + void tAutoSampler_setBuffer (tAutoSampler* const, tBuffer const); + void tAutoSampler_setMode (tAutoSampler* const, PlayMode mode); + void tAutoSampler_play (tAutoSampler* const); + void tAutoSampler_stop (tAutoSampler* const); + void tAutoSampler_setThreshold (tAutoSampler* const, Lfloat thresh); + void tAutoSampler_setWindowSize (tAutoSampler* const, uint32_t size); + void tAutoSampler_setCrossfadeLength (tAutoSampler* const, uint32_t length); + void tAutoSampler_setRate (tAutoSampler* const, Lfloat rate); + void tAutoSampler_setSampleRate (tAutoSampler* const, Lfloat sr); /*! @defgroup tmbsampler tMBSampler @@ -459,7 +453,7 @@ extern "C" #define FILLEN 128 #endif - typedef struct _tMBSampler + typedef struct tMBSampler { tMempool mempool; @@ -482,24 +476,22 @@ extern "C" int start, end; int currentLoopLength; - } _tMBSampler; - - typedef _tMBSampler *tMBSampler; - - void tMBSampler_init (tMBSampler *const, tBuffer *const, LEAF *const leaf); - void tMBSampler_initToPool (tMBSampler *const, tBuffer *const, tMempool *const); - void tMBSampler_free (tMBSampler *const); - - Lfloat tMBSampler_tick (tMBSampler const); - - void tMBSampler_setSample (tMBSampler const, tBuffer *const); - void tMBSampler_setMode (tMBSampler const, PlayMode mode); - void tMBSampler_play (tMBSampler const); - void tMBSampler_stop (tMBSampler const); - void tMBSampler_setStart (tMBSampler const, int32_t start); - void tMBSampler_setEnd (tMBSampler const, int32_t end); - void tMBSampler_setLength (tMBSampler const, int32_t length); - void tMBSampler_setRate (tMBSampler const, Lfloat rate); + } tMBSampler; + + void tMBSampler_init (tMBSampler**const, tBuffer *const, LEAF *const leaf); + void tMBSampler_initToPool (tMBSampler**const, tBuffer *const, tMempool *const); + void tMBSampler_free (tMBSampler**const); + + Lfloat tMBSampler_tick (tMBSampler* const); + + void tMBSampler_setSample (tMBSampler* const, tBuffer *const); + void tMBSampler_setMode (tMBSampler* const, PlayMode mode); + void tMBSampler_play (tMBSampler* const); + void tMBSampler_stop (tMBSampler* const); + void tMBSampler_setStart (tMBSampler* const, int32_t start); + void tMBSampler_setEnd (tMBSampler* const, int32_t end); + void tMBSampler_setLength (tMBSampler* const, int32_t length); + void tMBSampler_setRate (tMBSampler* const, Lfloat rate); #ifdef __cplusplus } diff --git a/leaf/Inc/leaf-tables.h b/leaf/Inc/leaf-tables.h index f133e0d..915c575 100644 --- a/leaf/Inc/leaf-tables.h +++ b/leaf/Inc/leaf-tables.h @@ -19,17 +19,16 @@ extern "C" { //============================================================================== -typedef struct _tLookupTable +typedef struct tLookupTable { uint32_t tableSize; float* table; tMempool mempool; -} _tLookupTable; -typedef _tLookupTable* tLookupTable; +} tLookupTable; -void tLookupTable_init(tLookupTable* const tLookupTable, float start, float end, float center, int size, LEAF* const leaf); +void tLookupTable_init(tLookupTable** const tLookupTable, float start, float end, float center, int size, LEAF* const leaf); -void tLookupTable_initToPool(tLookupTable* const tLookupTable, float start, float end, float center, int size, tMempool* const mempool); +void tLookupTable_initToPool(tLookupTable** const tLookupTable, float start, float end, float center, int size, tMempool* const mempool); /*! @ingroup tables diff --git a/leaf/Inc/leaf-vocal.h b/leaf/Inc/leaf-vocal.h index 5f059e9..a314a26 100644 --- a/leaf/Inc/leaf-vocal.h +++ b/leaf/Inc/leaf-vocal.h @@ -19,7 +19,7 @@ -typedef struct _glottis +typedef struct glottis { tMempool mempool; Lfloat freq; @@ -38,15 +38,13 @@ typedef struct _glottis Lfloat Again; Lfloat T; -} _glottis; +} glottis; -typedef _glottis* glottis; +void glottis_init (glottis**glo, LEAF* const leaf); +void glottis_initToPool (glottis**glo, tMempool* const mp); -void glottis_init (glottis *glo, LEAF* const leaf); -void glottis_initToPool (glottis *glo, tMempool* const mp); - -Lfloat glottis_compute (glottis glo); -void glottis_setup_waveform (glottis glo); +Lfloat glottis_compute (glottis* glo); +void glottis_setup_waveform (glottis* glo); diff --git a/leaf/Src/leaf-analysis.c b/leaf/Src/leaf-analysis.c index efd8a95..c5f464b 100644 --- a/leaf/Src/leaf-analysis.c +++ b/leaf/Src/leaf-analysis.c @@ -31,11 +31,11 @@ void tEnvelopeFollower_init (tEnvelopeFollower* const ef, Lfloat attackThreshold tEnvelopeFollower_initToPool(ef, attackThreshold, decayCoeff, &leaf->mempool); } -void tEnvelopeFollower_initToPool (tEnvelopeFollower* const ef, Lfloat attackThreshold, Lfloat decayCoeff, +void tEnvelopeFollower_initToPool (tEnvelopeFollower** const ef, Lfloat attackThreshold, Lfloat decayCoeff, tMempool* const mp) { _tMempool* m = *mp; - _tEnvelopeFollower* e = *ef = (_tEnvelopeFollower*) mpool_alloc(sizeof(_tEnvelopeFollower), m); + tEnvelopeFollower* e = *ef = (tEnvelopeFollower*) mpool_alloc(sizeof(tEnvelopeFollower), m); e->mempool = m; e->y = 0.0f; @@ -43,14 +43,14 @@ void tEnvelopeFollower_initToPool (tEnvelopeFollower* const ef, Lfloat attackThr e->d_coeff = decayCoeff; } -void tEnvelopeFollower_free (tEnvelopeFollower* const ef) +void tEnvelopeFollower_free (tEnvelopeFollower** const ef) { - _tEnvelopeFollower* e = *ef; + tEnvelopeFollower* e = *ef; mpool_free((char*)e, e->mempool); } -Lfloat tEnvelopeFollower_tick (tEnvelopeFollower const e, Lfloat x) +Lfloat tEnvelopeFollower_tick (tEnvelopeFollower* const e, Lfloat x) { if (x < 0.0f ) x = -x; /* Absolute value. */ @@ -68,12 +68,12 @@ Lfloat tEnvelopeFollower_tick (tEnvelopeFollower const e, Lfloat x) return e->y; } -void tEnvelopeFollower_setDecayCoefficient (tEnvelopeFollower const e, Lfloat decayCoeff) +void tEnvelopeFollower_setDecayCoefficient (tEnvelopeFollower* const e, Lfloat decayCoeff) { e->d_coeff = decayCoeff; } -void tEnvelopeFollower_setAttackThreshold (tEnvelopeFollower const e, Lfloat attackThresh) +void tEnvelopeFollower_setAttackThreshold (tEnvelopeFollower* const e, Lfloat attackThresh) { e->a_thresh = attackThresh; } @@ -89,10 +89,10 @@ void tZeroCrossingCounter_init (tZeroCrossingCounter* const zc, int maxWindowSiz tZeroCrossingCounter_initToPool (zc, maxWindowSize, &leaf->mempool); } -void tZeroCrossingCounter_initToPool (tZeroCrossingCounter* const zc, int maxWindowSize, tMempool* const mp) +void tZeroCrossingCounter_initToPool (tZeroCrossingCounter** const zc, int maxWindowSize, tMempool* const mp) { _tMempool* m = *mp; - _tZeroCrossingCounter* z = *zc = (_tZeroCrossingCounter*) mpool_alloc(sizeof(_tZeroCrossingCounter), m); + tZeroCrossingCounter* z = *zc = (tZeroCrossingCounter*) mpool_alloc(sizeof(tZeroCrossingCounter), m); z->mempool = m; z->count = 0; @@ -105,9 +105,9 @@ void tZeroCrossingCounter_initToPool (tZeroCrossingCounter* const zc, int maxWin z->countBuffer = (uint16_t*) mpool_calloc(sizeof(uint16_t) * maxWindowSize, m); } -void tZeroCrossingCounter_free (tZeroCrossingCounter* const zc) +void tZeroCrossingCounter_free (tZeroCrossingCounter** const zc) { - _tZeroCrossingCounter* z = *zc; + tZeroCrossingCounter* z = *zc; mpool_free((char*)z->inBuffer, z->mempool); mpool_free((char*)z->countBuffer, z->mempool); @@ -115,7 +115,7 @@ void tZeroCrossingCounter_free (tZeroCrossingCounter* const zc) } //returns proportion of zero crossings within window size (0.0 would be none in window, 1.0 would be all zero crossings) -Lfloat tZeroCrossingCounter_tick (tZeroCrossingCounter const z, Lfloat input) +Lfloat tZeroCrossingCounter_tick (tZeroCrossingCounter* const z, Lfloat input) { z->inBuffer[z->position] = input; int futurePosition = ((z->position + 1) % z->currentWindowSize); @@ -151,7 +151,7 @@ Lfloat tZeroCrossingCounter_tick (tZeroCrossingCounter const z, Lfloat input) return output; } -void tZeroCrossingCounter_setWindowSize (tZeroCrossingCounter const z, Lfloat windowSize) +void tZeroCrossingCounter_setWindowSize (tZeroCrossingCounter* const z, Lfloat windowSize) { if (windowSize <= z->maxWindowSize) { @@ -175,10 +175,10 @@ void tPowerFollower_init (tPowerFollower* const pf, Lfloat factor, LEAF* const l tPowerFollower_initToPool(pf, factor, &leaf->mempool); } -void tPowerFollower_initToPool (tPowerFollower* const pf, Lfloat factor, tMempool* const mp) +void tPowerFollower_initToPool (tPowerFollower** const pf, Lfloat factor, tMempool* const mp) { _tMempool* m = *mp; - _tPowerFollower* p = *pf = (_tPowerFollower*) mpool_alloc(sizeof(_tPowerFollower), m); + tPowerFollower* p = *pf = (tPowerFollower*) mpool_alloc(sizeof(tPowerFollower), m); p->mempool = m; p->curr=0.0f; @@ -186,14 +186,14 @@ void tPowerFollower_initToPool (tPowerFollower* const pf, Lfloat factor, tMempoo p->oneminusfactor=1.0f-factor; } -void tPowerFollower_free (tPowerFollower* const pf) +void tPowerFollower_free (tPowerFollower** const pf) { - _tPowerFollower* p = *pf; + tPowerFollower* p = *pf; mpool_free((char*)p, p->mempool); } -void tPowerFollower_setFactor (tPowerFollower const p, Lfloat factor) +void tPowerFollower_setFactor (tPowerFollower* const p, Lfloat factor) { if (factor<0.0f) factor=0.0f; if (factor>1.0f) factor=1.0f; @@ -201,13 +201,13 @@ void tPowerFollower_setFactor (tPowerFollower const p, Lfloat factor) p->oneminusfactor=1.0f-factor; } -Lfloat tPowerFollower_tick (tPowerFollower const p, Lfloat input) +Lfloat tPowerFollower_tick (tPowerFollower* const p, Lfloat input) { p->curr = p->factor*input*input+p->oneminusfactor*p->curr; return p->curr; } -Lfloat tPowerFollower_getPower (tPowerFollower const p) +Lfloat tPowerFollower_getPower (tPowerFollower* const p) { return p->curr; } @@ -223,10 +223,10 @@ void tEnvPD_init (tEnvPD* const xpd, int ws, int hs, int bs, LEAF* const leaf) tEnvPD_initToPool(xpd, ws, hs, bs, &leaf->mempool); } -void tEnvPD_initToPool (tEnvPD* const xpd, int ws, int hs, int bs, tMempool* const mp) +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); + tEnvPD* x = *xpd = (tEnvPD*) mpool_calloc(sizeof(tEnvPD), m); x->mempool = m; int period = hs, npoints = ws; @@ -265,19 +265,19 @@ void tEnvPD_initToPool (tEnvPD* const xpd, int ws, int hs, int bs, tMempool* con } } -void tEnvPD_free (tEnvPD* const xpd) +void tEnvPD_free (tEnvPD** const xpd) { - _tEnvPD* x = *xpd; + tEnvPD* x = *xpd; mpool_free((char*)x, x->mempool); } -Lfloat tEnvPD_tick (tEnvPD const x) +Lfloat tEnvPD_tick (tEnvPD* const x) { return powtodb(x->x_result); } -void tEnvPD_processBlock(tEnvPD const x, Lfloat* in) +void tEnvPD_processBlock(tEnvPD* const x, Lfloat* in) { int n = x->blockSize; @@ -328,49 +328,49 @@ void tAttackDetection_init (tAttackDetection* const ad, int blocksize, int atk, tAttackDetection_initToPool(ad, blocksize, atk, rel, &leaf->mempool); } -void tAttackDetection_initToPool (tAttackDetection* const ad, int blocksize, int atk, int rel, tMempool* const mp) +void tAttackDetection_initToPool (tAttackDetection** const ad, int blocksize, int atk, int rel, tMempool* const mp) { _tMempool* m = *mp; - _tAttackDetection* a = *ad = (_tAttackDetection*) mpool_alloc(sizeof(_tAttackDetection), m); + tAttackDetection* a = *ad = (tAttackDetection*) mpool_alloc(sizeof(tAttackDetection), m); a->mempool = m; - atkdtk_init(a, blocksize, atk, rel); + atkdtk_init(*a, blocksize, atk, rel); } -void tAttackDetection_free (tAttackDetection* const ad) +void tAttackDetection_free (tAttackDetection** const ad) { - _tAttackDetection* a = *ad; + tAttackDetection* a = *ad; mpool_free((char*)a, a->mempool); } -void tAttackDetection_setBlocksize (tAttackDetection const a, int size) +void tAttackDetection_setBlocksize (tAttackDetection* const a, int size) { a->blockSize = size; } -void tAttackDetection_setThreshold (tAttackDetection const a, Lfloat thres) +void tAttackDetection_setThreshold (tAttackDetection* const a, Lfloat thres) { a->threshold = thres; } -void tAttackDetection_setAttack (tAttackDetection const a, int inAtk) +void tAttackDetection_setAttack (tAttackDetection* const a, int inAtk) { a->atk = inAtk; a->atk_coeff = powf(0.01f, 1.0f/(a->atk * a->sampleRate * 0.001f)); } -void tAttackDetection_setRelease (tAttackDetection const a, int inRel) +void tAttackDetection_setRelease (tAttackDetection* const a, int inRel) { a->rel = inRel; a->rel_coeff = powf(0.01f, 1.0f/(a->rel * a->sampleRate * 0.001f)); } -int tAttackDetection_detect (tAttackDetection const a, Lfloat *in) +int tAttackDetection_detect (tAttackDetection* const a, Lfloat *in) { int result; - atkdtk_envelope(a, in); + atkdtk_envelope(*a, in); if(a->env >= a->prevAmp*2) //2 times greater = 6dB increase result = 1; @@ -382,7 +382,7 @@ int tAttackDetection_detect (tAttackDetection const a, Lfloat *in) return result; } -void tAttackDetection_setSampleRate (tAttackDetection const a, Lfloat sr) +void tAttackDetection_setSampleRate (tAttackDetection* const a, Lfloat sr) { a->sampleRate = sr; @@ -392,7 +392,7 @@ void tAttackDetection_setSampleRate (tAttackDetection const a, Lfloat sr) /************************ Static Function Definitions *************************/ -static void atkdtk_init (tAttackDetection const a, int blocksize, int atk, int rel) +static void atkdtk_init (tAttackDetection* const a, int blocksize, int atk, int rel) { LEAF* leaf = a->mempool->leaf; @@ -408,7 +408,7 @@ static void atkdtk_init (tAttackDetection const a, int blocksize, int atk, int r tAttackDetection_setRelease(a, rel); } -static void atkdtk_envelope(tAttackDetection const a, Lfloat *in) +static void atkdtk_envelope(tAttackDetection* const a, Lfloat *in) { int i = 0; @@ -448,10 +448,10 @@ void tSNAC_init(tSNAC* const snac, int overlaparg, LEAF* const leaf) tSNAC_initToPool(snac, overlaparg, &leaf->mempool); } -void tSNAC_initToPool (tSNAC* const snac, int overlaparg, tMempool* const mp) +void tSNAC_initToPool (tSNAC** const snac, int overlaparg, tMempool* const mp) { _tMempool* m = *mp; - _tSNAC* s = *snac = (_tSNAC*) mpool_alloc(sizeof(_tSNAC), m); + tSNAC* s = *snac = (tSNAC*) mpool_alloc(sizeof(tSNAC), m); s->mempool = m; s->biasfactor = DEFBIAS; @@ -471,9 +471,9 @@ void tSNAC_initToPool (tSNAC* const snac, int overlaparg, tMempool* const tSNAC_setOverlap(s, overlaparg); } -void tSNAC_free (tSNAC* const snac) +void tSNAC_free (tSNAC** const snac) { - _tSNAC* s = *snac; + tSNAC* s = *snac; mpool_free((char*)s->inputbuf, s->mempool); mpool_free((char*)s->processbuf, s->mempool); @@ -483,7 +483,7 @@ void tSNAC_free (tSNAC* const snac) } //void tSNAC_ioSamples(tSNAC* const snac, Lfloat *in, Lfloat *out, int size) -void tSNAC_ioSamples (tSNAC const s, Lfloat *in, int size) +void tSNAC_ioSamples (tSNAC* const s, Lfloat *in, int size) { int timeindex = s->timeindex; int mask = s->framesize - 1; @@ -504,22 +504,22 @@ void tSNAC_ioSamples (tSNAC const s, Lfloat *in, int size) s->timeindex = timeindex; } -void tSNAC_setOverlap (tSNAC const s, int lap) +void tSNAC_setOverlap (tSNAC* const s, int lap) { if(!((lap==1)|(lap==2)|(lap==4)|(lap==8))) lap = DEFOVERLAP; s->overlap = lap; } -void tSNAC_setBias (tSNAC const s, Lfloat bias) +void tSNAC_setBias (tSNAC* const s, Lfloat bias) { if(bias > 1.) bias = 1.; if(bias < 0.) bias = 0.; s->biasfactor = bias; - snac_biasbuf(s); + snac_biasbuf(*s); return; } -void tSNAC_setMinRMS (tSNAC const s, Lfloat rms) +void tSNAC_setMinRMS (tSNAC* const s, Lfloat rms) { if(rms > 1.) rms = 1.; if(rms < 0.) rms = 0.; @@ -527,12 +527,12 @@ void tSNAC_setMinRMS (tSNAC const s, Lfloat rms) return; } -Lfloat tSNAC_getPeriod (tSNAC const s) +Lfloat tSNAC_getPeriod (tSNAC* const s) { return(s->periodlength); } -Lfloat tSNAC_getFidelity (tSNAC const s) +Lfloat tSNAC_getFidelity (tSNAC* const s) { return(s->fidelity); } @@ -541,7 +541,7 @@ Lfloat tSNAC_getFidelity (tSNAC const s) /************************ Static Function Definitions *************************/ // main analysis function -static void snac_analyzeframe(tSNAC const s) +static void snac_analyzeframe(tSNAC* const s) { int n, tindex = s->timeindex; int framesize = s->framesize; @@ -569,7 +569,7 @@ static void snac_analyzeframe(tSNAC const s) snac_periodandfidelity(s); } -static void snac_autocorrelation(tSNAC const s) +static void snac_autocorrelation(tSNAC* const s) { int n, m; int framesize = s->framesize; @@ -601,7 +601,7 @@ static void snac_autocorrelation(tSNAC const s) return; } -static void snac_normalize (tSNAC const s) +static void snac_normalize (tSNAC* const s) { int framesize = s->framesize; int framesizeplustimeindex = s->framesize + s->timeindex; @@ -637,7 +637,7 @@ static void snac_normalize (tSNAC const s) return; } -static void snac_periodandfidelity (tSNAC const s) +static void snac_periodandfidelity (tSNAC* const s) { Lfloat periodlength; @@ -653,7 +653,7 @@ static void snac_periodandfidelity (tSNAC const s) } // select the peak which most probably represents period length -static void snac_pickpeak (tSNAC const s) +static void snac_pickpeak (tSNAC* const s) { int n, peakindex=0; int seek = s->framesize * SEEK; @@ -694,7 +694,7 @@ static void snac_pickpeak (tSNAC const s) // verify period length via frequency domain (up till SR/4) // frequency domain is more precise than lag domain for period lengths < 8 // argument 'periodlength' is initial estimation from autocorrelation -static Lfloat snac_spectralpeak (tSNAC const s, Lfloat periodlength) +static Lfloat snac_spectralpeak (tSNAC* const s, Lfloat periodlength) { if(periodlength < 4.0f) return periodlength; @@ -738,7 +738,7 @@ static Lfloat snac_spectralpeak (tSNAC const s, Lfloat periodlength) // modified logarithmic bias function -static void snac_biasbuf (tSNAC const s) +static void snac_biasbuf (tSNAC* const s) { int n; int maxperiod = (int)(s->framesize * (Lfloat)SEEK); @@ -765,10 +765,10 @@ void tPeriodDetection_init (tPeriodDetection* const pd, Lfloat* in, int bufSize, tPeriodDetection_initToPool(pd, in, bufSize, frameSize, &leaf->mempool); } -void tPeriodDetection_initToPool (tPeriodDetection* const pd, Lfloat* in, int bufSize, int frameSize, tMempool* const mp) +void tPeriodDetection_initToPool (tPeriodDetection** const pd, Lfloat* in, int bufSize, int frameSize, tMempool* const mp) { _tMempool* m = *mp; - _tPeriodDetection* p = *pd = (_tPeriodDetection*) mpool_calloc(sizeof(_tPeriodDetection), m); + tPeriodDetection* p = *pd = (tPeriodDetection*) mpool_calloc(sizeof(tPeriodDetection), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -797,16 +797,16 @@ void tPeriodDetection_initToPool (tPeriodDetection* const pd, Lfloat* in, int bu p->fidelityThreshold = 0.95f; } -void tPeriodDetection_free (tPeriodDetection* const pd) +void tPeriodDetection_free (tPeriodDetection** const pd) { - _tPeriodDetection* p = *pd; + tPeriodDetection* p = *pd; tEnvPD_free(&p->env); tSNAC_free(&p->snac); mpool_free((char*)p, p->mempool); } -Lfloat tPeriodDetection_tick (tPeriodDetection const p, Lfloat sample) +Lfloat tPeriodDetection_tick (tPeriodDetection* const p, Lfloat sample) { int i, iLast; @@ -824,12 +824,12 @@ Lfloat tPeriodDetection_tick (tPeriodDetection const p, Lfloat sample) { p->index = 0; - tEnvPD_processBlock(p->env, &(p->inBuffer[i])); + tEnvPD_processBlock(&p->env, &(p->inBuffer[i])); - tSNAC_ioSamples(p->snac, &(p->inBuffer[i]), p->frameSize); + tSNAC_ioSamples(&p->snac, &(p->inBuffer[i]), p->frameSize); // Fidelity threshold recommended by Katja Vetters is 0.95 for most instruments/voices http://www.katjaas.nl/helmholtz/helmholtz.html - p->period = tSNAC_getPeriod(p->snac); + p->period = tSNAC_getPeriod(&p->snac); p->curBlock++; if (p->curBlock >= p->framesPerBuffer) p->curBlock = 0; @@ -839,43 +839,43 @@ Lfloat tPeriodDetection_tick (tPeriodDetection const p, Lfloat sample) return p->period; } -Lfloat tPeriodDetection_getPeriod(tPeriodDetection const p) +Lfloat tPeriodDetection_getPeriod(tPeriodDetection* const p) { return p->period; } -Lfloat tPeriodDetection_getFidelity(tPeriodDetection const p) +Lfloat tPeriodDetection_getFidelity(tPeriodDetection* const p) { - return tSNAC_getFidelity(p->snac); + return tSNAC_getFidelity(&p->snac); } -void tPeriodDetection_setHopSize(tPeriodDetection const p, int hs) +void tPeriodDetection_setHopSize(tPeriodDetection* const p, int hs) { p->hopSize = hs; } -void tPeriodDetection_setWindowSize(tPeriodDetection const p, int ws) +void tPeriodDetection_setWindowSize(tPeriodDetection* const p, int ws) { p->windowSize = ws; } -void tPeriodDetection_setFidelityThreshold(tPeriodDetection const p, Lfloat threshold) +void tPeriodDetection_setFidelityThreshold(tPeriodDetection* const p, Lfloat threshold) { p->fidelityThreshold = threshold; } -void tPeriodDetection_setAlpha (tPeriodDetection const p, Lfloat alpha) +void tPeriodDetection_setAlpha (tPeriodDetection* const p, Lfloat alpha) { p->alpha = LEAF_clip(0.0f, alpha, 1.0f); } -void tPeriodDetection_setTolerance (tPeriodDetection const p, Lfloat tolerance) +void tPeriodDetection_setTolerance (tPeriodDetection* const p, Lfloat tolerance) { if (tolerance < 0.0f) p->tolerance = 0.0f; else p->tolerance = tolerance; } -void tPeriodDetection_setSampleRate (tPeriodDetection const p, Lfloat sr) +void tPeriodDetection_setSampleRate (tPeriodDetection* const p, Lfloat sr) { p->invSampleRate = 1.0f/sr; p->radius = expf(-1000.0f * p->hopSize * p->invSampleRate / p->timeConstant); @@ -890,10 +890,10 @@ void tZeroCrossingInfo_init (tZeroCrossingInfo* const zc, LEAF* const leaf) tZeroCrossingInfo_initToPool(zc, &leaf->mempool); } -void tZeroCrossingInfo_initToPool (tZeroCrossingInfo* const zc, tMempool* const mp) +void tZeroCrossingInfo_initToPool (tZeroCrossingInfo** const zc, tMempool* const mp) { _tMempool* m = *mp; - _tZeroCrossingInfo* z = *zc = (_tZeroCrossingInfo*) mpool_calloc(sizeof(_tZeroCrossingInfo), m); + tZeroCrossingInfo* z = *zc = (tZeroCrossingInfo*) mpool_calloc(sizeof(tZeroCrossingInfo), m); z->mempool = m; z->_leading_edge = INT_MIN; @@ -901,30 +901,30 @@ void tZeroCrossingInfo_initToPool (tZeroCrossingInfo* const zc, tMempool* z->_width = 0.0f; } -void tZeroCrossingInfo_free (tZeroCrossingInfo* const zc) +void tZeroCrossingInfo_free (tZeroCrossingInfo** const zc) { - _tZeroCrossingInfo* z = *zc; + tZeroCrossingInfo* z = *zc; mpool_free((char*)z, z->mempool); } -void tZeroCrossingInfo_updatePeak(tZeroCrossingInfo const z, Lfloat s, int pos) +void tZeroCrossingInfo_updatePeak(tZeroCrossingInfo* const z, Lfloat s, int pos) { z->_peak = fmaxf(s, z->_peak); if ((z->_width == 0.0f) && (s < (z->_peak * 0.3f))) z->_width = pos - z->_leading_edge; } -int tZeroCrossingInfo_period(tZeroCrossingInfo const z, tZeroCrossingInfo* const next) +int tZeroCrossingInfo_period(tZeroCrossingInfo* const z, tZeroCrossingInfo* const next) { - _tZeroCrossingInfo* n = *next; + tZeroCrossingInfo* n = *next; return n->_leading_edge - z->_leading_edge; } -Lfloat tZeroCrossingInfo_fractionalPeriod(tZeroCrossingInfo const z, tZeroCrossingInfo* const next) +Lfloat tZeroCrossingInfo_fractionalPeriod(tZeroCrossingInfo* const z, tZeroCrossingInfo* const next) { - _tZeroCrossingInfo* n = *next; + tZeroCrossingInfo* n = *next; // Get the start edge Lfloat prev1 = z->_before_crossing; @@ -943,7 +943,7 @@ Lfloat tZeroCrossingInfo_fractionalPeriod(tZeroCrossingInfo const z, tZeroCros return result + (dx2 - dx1); } -int tZeroCrossingInfo_getWidth(tZeroCrossingInfo const z) +int tZeroCrossingInfo_getWidth(tZeroCrossingInfo* const z) { return z->_width; } @@ -957,10 +957,10 @@ void tZeroCrossingCollector_init (tZeroCrossingCollector* const zc, int wind tZeroCrossingCollector_initToPool(zc, windowSize, hysteresis, &leaf->mempool); } -void tZeroCrossingCollector_initToPool (tZeroCrossingCollector* const zc, int windowSize, Lfloat hysteresis, tMempool* const mp) +void tZeroCrossingCollector_initToPool (tZeroCrossingCollector** const zc, int windowSize, Lfloat hysteresis, tMempool* const mp) { _tMempool* m = *mp; - _tZeroCrossingCollector* z = *zc = (_tZeroCrossingCollector*) mpool_alloc(sizeof(_tZeroCrossingCollector), m); + tZeroCrossingCollector* z = *zc = (tZeroCrossingCollector*) mpool_alloc(sizeof(tZeroCrossingCollector), m); z->mempool = m; z->_hysteresis = -dbtoa(hysteresis); @@ -991,9 +991,9 @@ void tZeroCrossingCollector_initToPool (tZeroCrossingCollector* const zc, z->_peak = 0.0f; } -void tZeroCrossingCollector_free (tZeroCrossingCollector* const zc) +void tZeroCrossingCollector_free (tZeroCrossingCollector** const zc) { - _tZeroCrossingCollector* z = *zc; + tZeroCrossingCollector* z = *zc; for (unsigned i = 0; i < z->_size; i++) { @@ -1004,7 +1004,7 @@ void tZeroCrossingCollector_free (tZeroCrossingCollector* const zc) mpool_free((char*)z, z->mempool); } -int tZeroCrossingCollector_tick(tZeroCrossingCollector const z, Lfloat s) +int tZeroCrossingCollector_tick(tZeroCrossingCollector* const z, Lfloat s) { // Offset s by half of hysteresis, so that zero cross detection is @@ -1012,12 +1012,12 @@ int tZeroCrossingCollector_tick(tZeroCrossingCollector const z, Lfloat s) s += z->_hysteresis * 0.5f; if (z->_num_edges >= (int)z->_size) - reset(z); + reset(*z); if ((z->_frame == z->_window_size/2) && (z->_num_edges == 0)) - reset(z); + reset(*z); - update_state(z, s); + update_state(*z, s); if ((++z->_frame >= z->_window_size) && !z->_state) { @@ -1028,64 +1028,64 @@ int tZeroCrossingCollector_tick(tZeroCrossingCollector const z, Lfloat s) if (z->_num_edges > 1) z->_ready = 1; else - reset(z); + reset(*z); } return z->_state; } -int tZeroCrossingCollector_getState(tZeroCrossingCollector const z) +int tZeroCrossingCollector_getState(tZeroCrossingCollector* const z) { return z->_state; } -tZeroCrossingInfo const tZeroCrossingCollector_getCrossing(tZeroCrossingCollector const z, int index) +tZeroCrossingInfo const tZeroCrossingCollector_getCrossing(tZeroCrossingCollector* const z, int index) { int i = (z->_num_edges - 1) - index; return z->_info[(z->_pos + i) & z->_mask]; } -int tZeroCrossingCollector_getNumEdges(tZeroCrossingCollector const z) +int tZeroCrossingCollector_getNumEdges(tZeroCrossingCollector* const z) { return z->_num_edges; } -int tZeroCrossingCollector_getCapacity(tZeroCrossingCollector const z) +int tZeroCrossingCollector_getCapacity(tZeroCrossingCollector* const z) { return (int)z->_size; } -int tZeroCrossingCollector_getFrame(tZeroCrossingCollector const z) +int tZeroCrossingCollector_getFrame(tZeroCrossingCollector* const z) { return z->_frame; } -int tZeroCrossingCollector_getWindowSize(tZeroCrossingCollector const z) +int tZeroCrossingCollector_getWindowSize(tZeroCrossingCollector* const z) { return z->_window_size; } -int tZeroCrossingCollector_isReady(tZeroCrossingCollector const z) +int tZeroCrossingCollector_isReady(tZeroCrossingCollector* const z) { return z->_ready; } -Lfloat tZeroCrossingCollector_getPeak(tZeroCrossingCollector const z) +Lfloat tZeroCrossingCollector_getPeak(tZeroCrossingCollector* const z) { return fmaxf(z->_peak, z->_peak_update); } -int tZeroCrossingCollector_isReset(tZeroCrossingCollector const z) +int tZeroCrossingCollector_isReset(tZeroCrossingCollector* const z) { return z->_frame == 0; } -void tZeroCrossingCollector_setHysteresis(tZeroCrossingCollector const z, Lfloat hysteresis) +void tZeroCrossingCollector_setHysteresis(tZeroCrossingCollector* const z, Lfloat hysteresis) { z->_hysteresis = -dbtoa(hysteresis); } -static inline void update_state(tZeroCrossingCollector const z, Lfloat s) +static inline void update_state(tZeroCrossingCollector* const z, Lfloat s) { if (z->_ready) { @@ -1116,7 +1116,7 @@ static inline void update_state(tZeroCrossingCollector const z, Lfloat s) } else { - tZeroCrossingInfo_updatePeak(z->_info[z->_pos & z->_mask], s, z->_frame); + tZeroCrossingInfo_updatePeak(&z->_info[z->_pos & z->_mask], s, z->_frame); } if (s > z->_peak_update) { @@ -1132,12 +1132,12 @@ static inline void update_state(tZeroCrossingCollector const z, Lfloat s) } if (z->_frame > z->_window_size * 2) - reset(z); + reset(*z); z->_prev = s; } -static inline void shift(tZeroCrossingCollector const z, int n) +static inline void shift(tZeroCrossingCollector* const z, int n) { tZeroCrossingInfo crossing = z->_info[z->_pos & z->_mask]; @@ -1156,7 +1156,7 @@ static inline void shift(tZeroCrossingCollector const z, int n) z->_num_edges = i; } -static inline void reset(tZeroCrossingCollector const z) +static inline void reset(tZeroCrossingCollector* const z) { z->_num_edges = 0; z->_state = 0; @@ -1170,10 +1170,10 @@ void tBitset_init (tBitset* const bitset, int numBits, LEAF* const leaf) tBitset_initToPool(bitset, numBits, &leaf->mempool); } -void tBitset_initToPool (tBitset* const bitset, int numBits, tMempool* const mempool) +void tBitset_initToPool (tBitset** const bitset, int numBits, tMempool* const mempool) { _tMempool* m = *mempool; - _tBitset* b = *bitset = (_tBitset*) mpool_alloc(sizeof(_tBitset), m); + tBitset* b = *bitset = (tBitset*) mpool_alloc(sizeof(tBitset), m); b->mempool = m; // Size of the array value in bits @@ -1188,15 +1188,15 @@ void tBitset_initToPool (tBitset* const bitset, int numBits, tMempool* const b->_bits = (unsigned int*) mpool_calloc(sizeof(unsigned int) * b->_size, m); } -void tBitset_free (tBitset* const bitset) +void tBitset_free (tBitset** const bitset) { - _tBitset* b = *bitset; + tBitset* b = *bitset; mpool_free((char*) b->_bits, b->mempool); mpool_free((char*) b, b->mempool); } -int tBitset_get (tBitset const b, int index) +int tBitset_get (tBitset* const b, int index) { // Check we don't get past the storage if (index > b->_bit_size) @@ -1206,12 +1206,12 @@ int tBitset_get (tBitset const b, int index) return (b->_bits[index / b->_value_size] & mask) != 0; } -unsigned int* tBitset_getData (tBitset const b) +unsigned int* tBitset_getData (tBitset* const b) { return b->_bits; } -void tBitset_set (tBitset const b, int index, unsigned int val) +void tBitset_set (tBitset* const b, int index, unsigned int val) { if (index > b->_bit_size) return; @@ -1221,7 +1221,7 @@ void tBitset_set (tBitset const b, int index, unsigned int val) b->_bits[i] ^= (-val ^ b->_bits[i]) & mask; } -void tBitset_setMultiple (tBitset const b, int index, int n, unsigned int val) +void tBitset_setMultiple (tBitset* const b, int index, int n, unsigned int val) { // Check that the index (i) does not get past size if (index > b->_bit_size) @@ -1308,24 +1308,24 @@ void tBACF_init (tBACF* const bacf, tBitset* const bitset, LEAF* const leaf) tBACF_initToPool(bacf, bitset, &leaf->mempool); } -void tBACF_initToPool (tBACF* const bacf, tBitset* const bitset, tMempool* const mempool) +void tBACF_initToPool (tBACF** const bacf, tBitset* const bitset, tMempool* const mempool) { _tMempool* m = *mempool; - _tBACF* b = *bacf = (_tBACF*) mpool_alloc(sizeof(_tBACF), m); + tBACF* b = *bacf = (tBACF*) mpool_alloc(sizeof(tBACF), m); b->mempool = m; b->_bitset = *bitset; b->_mid_array = ((b->_bitset->_bit_size / b->_bitset->_value_size) / 2) - 1; } -void tBACF_free (tBACF* const bacf) +void tBACF_free (tBACF** const bacf) { - _tBACF* b = *bacf; + tBACF* b = *bacf; mpool_free((char*) b, b->mempool); } -int tBACF_getCorrelation (tBACF const b, int pos) +int tBACF_getCorrelation (tBACF* const b, int pos) { int value_size = b->_bitset->_value_size; const int index = pos / value_size; @@ -1371,7 +1371,7 @@ int tBACF_getCorrelation (tBACF const b, int pos) return count; } -void tBACF_set (tBACF const b, tBitset* const bitset) +void tBACF_set (tBACF* const b, tBitset* const bitset) { b->_bitset = *bitset; b->_mid_array = ((b->_bitset->_bit_size / b->_bitset->_value_size) / 2) - 1; @@ -1393,10 +1393,10 @@ void tPeriodDetector_init (tPeriodDetector* const detector, Lfloat lowestF tPeriodDetector_initToPool(detector, lowestFreq, highestFreq, hysteresis, &leaf->mempool); } -void tPeriodDetector_initToPool (tPeriodDetector* const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat hysteresis, tMempool* const mempool) +void tPeriodDetector_initToPool (tPeriodDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat hysteresis, tMempool* const mempool) { _tMempool* m = *mempool; - _tPeriodDetector* p = *detector = (_tPeriodDetector*) mpool_alloc(sizeof(_tPeriodDetector), m); + tPeriodDetector* p = *detector = (tPeriodDetector*) mpool_alloc(sizeof(tPeriodDetector), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -1409,7 +1409,7 @@ void tPeriodDetector_initToPool (tPeriodDetector* const detector, Lfloat low p->_min_period = (1.0f / highestFreq) * p->sampleRate; p->_range = highestFreq / lowestFreq; - int windowSize = tZeroCrossingCollector_getWindowSize(p->_zc); + int windowSize = tZeroCrossingCollector_getWindowSize(&p->_zc); tBitset_initToPool(&p->_bits, windowSize, mempool); p->_weight = 2.0f / windowSize; p->_mid_point = windowSize / 2; @@ -1424,9 +1424,9 @@ void tPeriodDetector_initToPool (tPeriodDetector* const detector, Lfloat low tBACF_initToPool(&p->_bacf, &p->_bits, mempool); } -void tPeriodDetector_free (tPeriodDetector* const detector) +void tPeriodDetector_free (tPeriodDetector** const detector) { - _tPeriodDetector* p = *detector; + tPeriodDetector* p = *detector; tZeroCrossingCollector_free(&p->_zc); tBitset_free(&p->_bits); @@ -1435,11 +1435,11 @@ void tPeriodDetector_free (tPeriodDetector* const detector) mpool_free((char*) p, p->mempool); } -int tPeriodDetector_tick (tPeriodDetector const p, Lfloat s) +int tPeriodDetector_tick (tPeriodDetector* const p, Lfloat s) { // Zero crossing - int prev = tZeroCrossingCollector_getState(p->_zc); - int zc = tZeroCrossingCollector_tick(p->_zc, s); + int prev = tZeroCrossingCollector_getState(&p->_zc); + int zc = tZeroCrossingCollector_tick(&p->_zc, s); if (!zc && prev != zc) { @@ -1447,13 +1447,13 @@ int tPeriodDetector_tick (tPeriodDetector const p, Lfloat s) p->_predicted_period = -1.0f; } - if (tZeroCrossingCollector_isReset(p->_zc)) + if (tZeroCrossingCollector_isReset(&p->_zc)) { p->_fundamental.period = -1.0f; p->_fundamental.periodicity = 0.0f; } - if (tZeroCrossingCollector_isReady(p->_zc)) + if (tZeroCrossingCollector_isReady(&p->_zc)) { set_bitstream(p); autocorrelate(p); @@ -1462,17 +1462,17 @@ int tPeriodDetector_tick (tPeriodDetector const p, Lfloat s) return 0; } -Lfloat tPeriodDetector_getPeriod (tPeriodDetector const p) +Lfloat tPeriodDetector_getPeriod (tPeriodDetector* const p) { return p->_fundamental.period; } -Lfloat tPeriodDetector_getPeriodicity (tPeriodDetector const p) +Lfloat tPeriodDetector_getPeriodicity (tPeriodDetector* const p) { return p->_fundamental.periodicity; } -Lfloat tPeriodDetector_harmonic (tPeriodDetector const p, int harmonicIndex) +Lfloat tPeriodDetector_harmonic (tPeriodDetector* const p, int harmonicIndex) { if (harmonicIndex > 0) { @@ -1482,7 +1482,7 @@ Lfloat tPeriodDetector_harmonic (tPeriodDetector const p, int harmonicIndex Lfloat target_period = p->_fundamental.period / (Lfloat) harmonicIndex; if (target_period >= p->_min_period && target_period < p->_mid_point) { - int count = tBACF_getCorrelation(p->_bacf, roundf(target_period)); + int count = tBACF_getCorrelation(&p->_bacf, roundf(target_period)); Lfloat periodicity = 1.0f - (count * p->_weight); return periodicity; } @@ -1490,26 +1490,26 @@ Lfloat tPeriodDetector_harmonic (tPeriodDetector const p, int harmonicIndex return 0.0f; } -Lfloat tPeriodDetector_predictPeriod (tPeriodDetector const p) +Lfloat tPeriodDetector_predictPeriod (tPeriodDetector* const p) { if (p->_predicted_period == -1.0f && p->_edge_mark != p->_predict_edge) { p->_predict_edge = p->_edge_mark; - int n = tZeroCrossingCollector_getNumEdges(p->_zc); + int n = tZeroCrossingCollector_getNumEdges(&p->_zc); if (n > 1) { - Lfloat threshold = tZeroCrossingCollector_getPeak(p->_zc) * PULSE_THRESHOLD; + Lfloat threshold = tZeroCrossingCollector_getPeak(&p->_zc) * PULSE_THRESHOLD; for (int i = n - 1; i > 0; --i) { - tZeroCrossingInfo edge2 = tZeroCrossingCollector_getCrossing(p->_zc, i); + tZeroCrossingInfo edge2 = tZeroCrossingCollector_getCrossing(&p->_zc, i); if (edge2->_peak >= threshold) { for (int j = i-1; j >= 0; --j) { - tZeroCrossingInfo edge1 = tZeroCrossingCollector_getCrossing(p->_zc, j); + tZeroCrossingInfo edge1 = tZeroCrossingCollector_getCrossing(&p->_zc, j); if (edge1->_peak >= threshold) { - Lfloat period = tZeroCrossingInfo_fractionalPeriod(edge1, &edge2); + Lfloat period = tZeroCrossingInfo_fractionalPeriod(&edge1, &edge2); if (period > p->_min_period) return (p->_predicted_period = period); } @@ -1522,22 +1522,22 @@ Lfloat tPeriodDetector_predictPeriod (tPeriodDetector const p) return p->_predicted_period; } -int tPeriodDetector_isReady (tPeriodDetector const p) +int tPeriodDetector_isReady (tPeriodDetector* const p) { - return tZeroCrossingCollector_isReady(p->_zc); + return tZeroCrossingCollector_isReady(&p->_zc); } -int tPeriodDetector_isReset (tPeriodDetector const p) +int tPeriodDetector_isReset (tPeriodDetector* const p) { - return tZeroCrossingCollector_isReset(p->_zc); + return tZeroCrossingCollector_isReset(&p->_zc); } -void tPeriodDetector_setHysteresis (tPeriodDetector const p, Lfloat hysteresis) +void tPeriodDetector_setHysteresis (tPeriodDetector* const p, Lfloat hysteresis) { - return tZeroCrossingCollector_setHysteresis(p->_zc, hysteresis); + return tZeroCrossingCollector_setHysteresis(&p->_zc, hysteresis); } -void tPeriodDetector_setSampleRate (tPeriodDetector const p, Lfloat sr) +void tPeriodDetector_setSampleRate (tPeriodDetector* const p, Lfloat sr) { _tMempool* m = p->mempool; p->sampleRate = sr; @@ -1548,18 +1548,18 @@ void tPeriodDetector_setSampleRate (tPeriodDetector const p, Lfloat sr) p->_min_period = (1.0f / p->highestFreq) * p->sampleRate; } -static inline void set_bitstream(tPeriodDetector const p) +static inline void set_bitstream(tPeriodDetector* const p) { - Lfloat threshold = tZeroCrossingCollector_getPeak(p->_zc) * PULSE_THRESHOLD; - unsigned int leading_edge = tZeroCrossingCollector_getWindowSize(p->_zc); + Lfloat threshold = tZeroCrossingCollector_getPeak(&p->_zc) * PULSE_THRESHOLD; + unsigned int leading_edge = tZeroCrossingCollector_getWindowSize(&p->_zc); unsigned int trailing_edge = 0; p->_num_pulses = 0; tBitset_clear(p->_bits); - for (int i = 0; i != tZeroCrossingCollector_getNumEdges(p->_zc); ++i) + for (int i = 0; i != tZeroCrossingCollector_getNumEdges(&p->_zc); ++i) { - tZeroCrossingInfo info = tZeroCrossingCollector_getCrossing(p->_zc, i); + tZeroCrossingInfo info = tZeroCrossingCollector_getCrossing(&p->_zc, i); if (info->_peak >= threshold) { ++p->_num_pulses; @@ -1569,15 +1569,15 @@ static inline void set_bitstream(tPeriodDetector const p) trailing_edge = info->_trailing_edge; int pos = fmax(info->_leading_edge, 0); int n = info->_trailing_edge - pos; - tBitset_setMultiple(p->_bits, pos, n, 1); + tBitset_setMultiple(&p->_bits, pos, n, 1); } } p->_half_empty = (leading_edge > p->_mid_point) || (trailing_edge < p->_mid_point); } -static inline void autocorrelate(tPeriodDetector const p) +static inline void autocorrelate(tPeriodDetector* const p) { - Lfloat threshold = tZeroCrossingCollector_getPeak(p->_zc) * PULSE_THRESHOLD; + Lfloat threshold = tZeroCrossingCollector_getPeak(&p->_zc) * PULSE_THRESHOLD; _sub_collector collect; sub_collector_init(&collect, &p->_zc, p->_periodicity_diff_threshold, p->_range); @@ -1590,24 +1590,24 @@ static inline void autocorrelate(tPeriodDetector const p) else { int shouldBreak = 0; - int n = tZeroCrossingCollector_getNumEdges(p->_zc); + int n = tZeroCrossingCollector_getNumEdges(&p->_zc); for (int i = 0; i != n - 1; ++i) { - tZeroCrossingInfo curr = tZeroCrossingCollector_getCrossing(p->_zc, i); + tZeroCrossingInfo curr = tZeroCrossingCollector_getCrossing(&p->_zc, i); if (curr->_peak >= threshold) { for (int j = i + 1; j != n; ++j) { - tZeroCrossingInfo next = tZeroCrossingCollector_getCrossing(p->_zc, j); + tZeroCrossingInfo next = tZeroCrossingCollector_getCrossing(&p->_zc, j); if (next->_peak >= threshold) { - int period = tZeroCrossingInfo_period(curr, &next); + int period = tZeroCrossingInfo_period(&curr, &next); if (period > p->_mid_point) break; if (period >= p->_min_period) { - int count = tBACF_getCorrelation(p->_bacf, period); + int count = tBACF_getCorrelation(&p->_bacf, period); int mid = p->_bacf->_mid_array * CHAR_BIT * sizeof(unsigned int); @@ -1615,7 +1615,7 @@ static inline void autocorrelate(tPeriodDetector const p) if ((collect._fundamental._period == -1.0f) && count == 0) { - if (tBACF_getCorrelation(p->_bacf, period / 2.0f) == 0) + if (tBACF_getCorrelation(&p->_bacf, period / 2.0f) == 0) count = -1; } else if (period < 32) // Search minimum if the resolution is low @@ -1623,7 +1623,7 @@ static inline void autocorrelate(tPeriodDetector const p) // Search upwards for the minimum autocorrelation count for (int d = start + 1; d < mid; ++d) { - int c = tBACF_getCorrelation(p->_bacf, d); + int c = tBACF_getCorrelation(&p->_bacf, d); if (c > count) break; count = c; @@ -1632,7 +1632,7 @@ static inline void autocorrelate(tPeriodDetector const p) // Search downwards for the minimum autocorrelation count for (int d = start - 1; d > p->_min_period; --d) { - int c = tBACF_getCorrelation(p->_bacf, d); + int c = tBACF_getCorrelation(&p->_bacf, d); if (c > count) break; count = c; @@ -1681,9 +1681,9 @@ static inline void sub_collector_init(_sub_collector* collector, tZeroCrossingCo static inline Lfloat sub_collector_period_of(_sub_collector* collector, _auto_correlation_info info) { - tZeroCrossingInfo first = tZeroCrossingCollector_getCrossing(collector->_zc, info._i1); - tZeroCrossingInfo next = tZeroCrossingCollector_getCrossing(collector->_zc, info._i2); - return tZeroCrossingInfo_fractionalPeriod(first, &next); + tZeroCrossingInfo first = tZeroCrossingCollector_getCrossing(&collector->_zc, info._i1); + tZeroCrossingInfo next = tZeroCrossingCollector_getCrossing(&collector->_zc, info._i2); + return tZeroCrossingInfo_fractionalPeriod(&first, &next); } static inline void sub_collector_save(_sub_collector* collector, _auto_correlation_info info) @@ -1771,10 +1771,10 @@ void tPitchDetector_init (tPitchDetector* const detector, Lfloat lowestFreq, tPitchDetector_initToPool(detector, lowestFreq, highestFreq, &leaf->mempool); } -void tPitchDetector_initToPool (tPitchDetector* const detector, Lfloat lowestFreq, Lfloat highestFreq, tMempool* const mempool) +void tPitchDetector_initToPool (tPitchDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, tMempool* const mempool) { _tMempool* m = *mempool; - _tPitchDetector* p = *detector = (_tPitchDetector*) mpool_alloc(sizeof(_tPitchDetector), m); + tPitchDetector* p = *detector = (tPitchDetector*) mpool_alloc(sizeof(tPitchDetector), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -1785,15 +1785,15 @@ void tPitchDetector_initToPool (tPitchDetector* const detector, Lfloat lowe p->sampleRate = leaf->sampleRate; } -void tPitchDetector_free (tPitchDetector* const detector) +void tPitchDetector_free (tPitchDetector** const detector) { - _tPitchDetector* p = *detector; + tPitchDetector* p = *detector; tPeriodDetector_free(&p->_pd); mpool_free((char*) p, p->mempool); } -int tPitchDetector_tick (tPitchDetector const p, Lfloat s) +int tPitchDetector_tick (tPitchDetector* const p, Lfloat s) { tPeriodDetector_tick(p->_pd, s); @@ -1843,46 +1843,46 @@ int tPitchDetector_tick (tPitchDetector const p, Lfloat s) return ready; } -Lfloat tPitchDetector_getFrequency (tPitchDetector const p) +Lfloat tPitchDetector_getFrequency (tPitchDetector* const p) { return p->_current.frequency; } -Lfloat tPitchDetector_getPeriodicity (tPitchDetector const p) +Lfloat tPitchDetector_getPeriodicity (tPitchDetector* const p) { return p->_current.periodicity; } -Lfloat tPitchDetector_harmonic (tPitchDetector const p, int harmonicIndex) +Lfloat tPitchDetector_harmonic (tPitchDetector* const p, int harmonicIndex) { - return tPeriodDetector_harmonic(p->_pd, harmonicIndex); + return tPeriodDetector_harmonic(&p->_pd, harmonicIndex); } -Lfloat tPitchDetector_predictFrequency (tPitchDetector const p) +Lfloat tPitchDetector_predictFrequency (tPitchDetector* const p) { - Lfloat period = tPeriodDetector_predictPeriod(p->_pd); + Lfloat period = tPeriodDetector_predictPeriod(&p->_pd); if (period > 0.0f) return p->sampleRate / period; return 0.0f; } -int tPitchDetector_indeterminate (tPitchDetector const p) +int tPitchDetector_indeterminate (tPitchDetector* const p) { return p->_current.frequency == 0.0f; } -void tPitchDetector_setHysteresis (tPitchDetector const p, Lfloat hysteresis) +void tPitchDetector_setHysteresis (tPitchDetector* const p, Lfloat hysteresis) { - tPeriodDetector_setHysteresis(p->_pd, hysteresis); + tPeriodDetector_setHysteresis(&p->_pd, hysteresis); } -void tPitchDetector_setSampleRate (tPitchDetector const p, Lfloat sr) +void tPitchDetector_setSampleRate (tPitchDetector* const p, Lfloat sr) { p->sampleRate = sr; - tPeriodDetector_setSampleRate(p->_pd, p->sampleRate); + tPeriodDetector_setSampleRate(&p->_pd, p->sampleRate); } -static inline Lfloat calculate_frequency(tPitchDetector const p) +static inline Lfloat calculate_frequency(tPitchDetector* const p) { Lfloat period = p->_pd->_fundamental.period; if (period > 0.0f) @@ -1890,7 +1890,7 @@ static inline Lfloat calculate_frequency(tPitchDetector const p) return 0.0f; } -static inline void bias(tPitchDetector const p, _pitch_info incoming) +static inline void bias(tPitchDetector* const p, _pitch_info incoming) { ++p->_frames_after_shift; int shifted = 0; @@ -1990,10 +1990,10 @@ void tDualPitchDetector_init (tDualPitchDetector* const detector, Lfloat lowe tDualPitchDetector_initToPool(detector, lowestFreq, highestFreq, inBuffer, bufSize, &leaf->mempool); } -void tDualPitchDetector_initToPool (tDualPitchDetector* const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat* inBuffer, int bufSize, tMempool* const mempool) +void tDualPitchDetector_initToPool (tDualPitchDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat* inBuffer, int bufSize, tMempool* const mempool) { _tMempool* m = *mempool; - _tDualPitchDetector* p = *detector = (_tDualPitchDetector*) mpool_alloc(sizeof(_tDualPitchDetector), m); + tDualPitchDetector* p = *detector = (tDualPitchDetector*) mpool_alloc(sizeof(tDualPitchDetector), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -2013,9 +2013,9 @@ void tDualPitchDetector_initToPool (tDualPitchDetector* const detector, Lfl p->highest = highestFreq; } -void tDualPitchDetector_free (tDualPitchDetector* const detector) +void tDualPitchDetector_free (tDualPitchDetector** const detector) { - _tDualPitchDetector* p = *detector; + tDualPitchDetector* p = *detector; tPeriodDetection_free(&p->_pd1); tPitchDetector_free(&p->_pd2); @@ -2023,21 +2023,21 @@ void tDualPitchDetector_free (tDualPitchDetector* const detector) mpool_free((char*) p, p->mempool); } -int tDualPitchDetector_tick (tDualPitchDetector const p, Lfloat sample) +int tDualPitchDetector_tick (tDualPitchDetector* const p, Lfloat sample) { - tPeriodDetection_tick(p->_pd1, sample); - int ready = tPitchDetector_tick(p->_pd2, sample); + tPeriodDetection_tick(&p->_pd1, sample); + int ready = tPitchDetector_tick(&p->_pd2, sample); if (ready) { - int pd2_indeterminate = tPitchDetector_indeterminate(p->_pd2); + int pd2_indeterminate = tPitchDetector_indeterminate(&p->_pd2); int disagreement = 0; - Lfloat period = tPeriodDetection_getPeriod(p->_pd1); + Lfloat period = tPeriodDetection_getPeriod(&p->_pd1); if (!pd2_indeterminate && period != 0.0f) { _pitch_info _i1; - _i1.frequency = p->sampleRate / tPeriodDetection_getPeriod(p->_pd1); - _i1.periodicity = tPeriodDetection_getFidelity(p->_pd1); + _i1.frequency = p->sampleRate / tPeriodDetection_getPeriod(&p->_pd1); + _i1.periodicity = tPeriodDetection_getFidelity(&p->_pd1); _pitch_info _i2 = p->_pd2->_current; Lfloat pd1_diff = fabsf(_i1.frequency - p->_mean); @@ -2103,44 +2103,44 @@ int tDualPitchDetector_tick (tDualPitchDetector const p, Lfloat sample) return ready; } -Lfloat tDualPitchDetector_getFrequency (tDualPitchDetector const p) +Lfloat tDualPitchDetector_getFrequency (tDualPitchDetector* const p) { return p->_current.frequency; } -Lfloat tDualPitchDetector_getPeriodicity (tDualPitchDetector const p) +Lfloat tDualPitchDetector_getPeriodicity (tDualPitchDetector* const p) { return p->_current.periodicity; } -Lfloat tDualPitchDetector_predictFrequency (tDualPitchDetector const p) +Lfloat tDualPitchDetector_predictFrequency (tDualPitchDetector* const p) { if (p->_predicted_frequency == 0.0f) - compute_predicted_frequency(p); + compute_predicted_frequency(*p); return p->_predicted_frequency; } -void tDualPitchDetector_setHysteresis (tDualPitchDetector const p, Lfloat hysteresis) +void tDualPitchDetector_setHysteresis (tDualPitchDetector* const p, Lfloat hysteresis) { - tPitchDetector_setHysteresis(p->_pd2, hysteresis); + tPitchDetector_setHysteresis(&p->_pd2, hysteresis); } -void tDualPitchDetector_setPeriodicityThreshold (tDualPitchDetector const p, Lfloat thresh) +void tDualPitchDetector_setPeriodicityThreshold (tDualPitchDetector* const p, Lfloat thresh) { p->thresh = thresh; } -void tDualPitchDetector_setSampleRate (tDualPitchDetector const p, Lfloat sr) +void tDualPitchDetector_setSampleRate (tDualPitchDetector* const p, Lfloat sr) { p->sampleRate = sr; - tPeriodDetection_setSampleRate(p->_pd1, p->sampleRate); - tPitchDetector_setSampleRate(p->_pd2, p->sampleRate); + tPeriodDetection_setSampleRate(&p->_pd1, p->sampleRate); + tPitchDetector_setSampleRate(&p->_pd2, p->sampleRate); } -static inline void compute_predicted_frequency(tDualPitchDetector const p) +static inline void compute_predicted_frequency(tDualPitchDetector* const p) { - Lfloat f1 = 1.0f / tPeriodDetection_getPeriod(p->_pd1); - Lfloat f2 = tPitchDetector_predictFrequency(p->_pd2); + Lfloat f1 = 1.0f / tPeriodDetection_getPeriod(&p->_pd1); + Lfloat f2 = tPitchDetector_predictFrequency(&p->_pd2); if (f2 > 0.0f) { Lfloat error = f1 * 0.1f; diff --git a/leaf/Src/leaf-delay.c b/leaf/Src/leaf-delay.c index a3a46a0..d3e2ee3 100644 --- a/leaf/Src/leaf-delay.c +++ b/leaf/Src/leaf-delay.c @@ -24,10 +24,10 @@ void tDelay_init (tDelay* const dl, uint32_t delay, uint32_t maxDelay, LEAF* tDelay_initToPool(dl, delay, maxDelay, &leaf->mempool); } -void tDelay_initToPool (tDelay* const dl, uint32_t delay, uint32_t maxDelay, tMempool* const mp) +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); + tDelay* d = *dl = (tDelay*) mpool_alloc(sizeof(tDelay), m); d->mempool = m; d->maxDelay = maxDelay; @@ -47,14 +47,14 @@ void tDelay_initToPool (tDelay* const dl, uint32_t delay, uint32_t maxDelay tDelay_setDelay(*dl, d->delay); } -void tDelay_free (tDelay* const dl) +void tDelay_free (tDelay** const dl) { - _tDelay* d = *dl; + tDelay* d = *dl; mpool_free((char*)d->buff, d->mempool); mpool_free((char*)d, d->mempool); } -void tDelay_clear(tDelay const d) +void tDelay_clear(tDelay* const d) { for (unsigned i = 0; i < d->maxDelay; i++) { @@ -62,7 +62,7 @@ void tDelay_clear(tDelay const d) } } -Lfloat tDelay_tick (tDelay const d, Lfloat input) +Lfloat tDelay_tick (tDelay* const d, Lfloat input) { // Input d->lastIn = input; @@ -76,7 +76,7 @@ Lfloat tDelay_tick (tDelay const d, Lfloat input) return d->lastOut; } -void tDelay_setDelay (tDelay const d, uint32_t delay) +void tDelay_setDelay (tDelay* const d, uint32_t delay) { d->delay = LEAF_clip(0.0f, delay, d->maxDelay); @@ -85,7 +85,7 @@ void tDelay_setDelay (tDelay const d, uint32_t delay) else d->outPoint = d->maxDelay + d->inPoint - d->delay; } -Lfloat tDelay_tapOut (tDelay const d, uint32_t tapDelay) +Lfloat tDelay_tapOut (tDelay* const d, uint32_t tapDelay) { int32_t tap = d->inPoint - tapDelay - 1; @@ -96,7 +96,7 @@ Lfloat tDelay_tapOut (tDelay const d, uint32_t tapDelay) } -void tDelay_tapIn (tDelay const d, Lfloat value, uint32_t tapDelay) +void tDelay_tapIn (tDelay* const d, Lfloat value, uint32_t tapDelay) { int32_t tap = d->inPoint - tapDelay - 1; @@ -106,7 +106,7 @@ void tDelay_tapIn (tDelay const d, Lfloat value, uint32_t tapDelay) d->buff[tap] = value; } -Lfloat tDelay_addTo (tDelay const d, Lfloat value, uint32_t tapDelay) +Lfloat tDelay_addTo (tDelay* const d, Lfloat value, uint32_t tapDelay) { int32_t tap = d->inPoint - tapDelay - 1; @@ -116,28 +116,28 @@ Lfloat tDelay_addTo (tDelay const d, Lfloat value, uint32_t tapDelay) return (d->buff[tap] += value); } -uint32_t tDelay_getDelay (tDelay const d) +uint32_t tDelay_getDelay (tDelay* const d) { return d->delay; } -Lfloat tDelay_getLastOut (tDelay const d) +Lfloat tDelay_getLastOut (tDelay* const d) { return d->lastOut; } -Lfloat tDelay_getLastIn (tDelay const d) +Lfloat tDelay_getLastIn (tDelay* const d) { return d->lastIn; } -void tDelay_setGain (tDelay const d, Lfloat gain) +void tDelay_setGain (tDelay* const d, Lfloat gain) { if (gain < 0.0f) d->gain = 0.0f; else d->gain = gain; } -Lfloat tDelay_getGain (tDelay const d) +Lfloat tDelay_getGain (tDelay* const d) { return d->gain; } @@ -148,10 +148,10 @@ void tLinearDelay_init (tLinearDelay* const dl, Lfloat delay, uint32_t maxDela tLinearDelay_initToPool(dl, delay, maxDelay, &leaf->mempool); } -void tLinearDelay_initToPool (tLinearDelay* const dl, Lfloat delay, uint32_t maxDelay, tMempool* const mp) +void tLinearDelay_initToPool (tLinearDelay** const dl, Lfloat delay, uint32_t maxDelay, tMempool* const mp) { _tMempool* m = *mp; - _tLinearDelay* d = *dl = (_tLinearDelay*) mpool_alloc(sizeof(_tLinearDelay), m); + tLinearDelay* d = *dl = (tLinearDelay*) mpool_alloc(sizeof(tLinearDelay), m); d->mempool = m; d->maxDelay = maxDelay; @@ -173,15 +173,15 @@ void tLinearDelay_initToPool (tLinearDelay* const dl, Lfloat delay, uint32_t ma tLinearDelay_setDelay(*dl, d->delay); } -void tLinearDelay_free (tLinearDelay* const dl) +void tLinearDelay_free (tLinearDelay** const dl) { - _tLinearDelay* d = *dl; + tLinearDelay* d = *dl; mpool_free((char*)d->buff, d->mempool); mpool_free((char*)d, d->mempool); } -void tLinearDelay_clear(tLinearDelay const d) +void tLinearDelay_clear(tLinearDelay* const d) { for (unsigned i = 0; i < d->maxDelay; i++) { @@ -189,7 +189,7 @@ void tLinearDelay_clear(tLinearDelay const d) } } -Lfloat tLinearDelay_tick (tLinearDelay const d, Lfloat input) +Lfloat tLinearDelay_tick (tLinearDelay* const d, Lfloat input) { d->buff[d->inPoint] = input * d->gain; @@ -211,7 +211,7 @@ Lfloat tLinearDelay_tick (tLinearDelay const d, Lfloat input) return d->lastOut; } -void tLinearDelay_tickIn (tLinearDelay const d, Lfloat input) +void tLinearDelay_tickIn (tLinearDelay* const d, Lfloat input) { d->buff[d->inPoint] = input * d->gain; d->lastIn = input; @@ -219,7 +219,7 @@ void tLinearDelay_tickIn (tLinearDelay const d, Lfloat input) if (++(d->inPoint) == d->maxDelay ) d->inPoint = 0; } -Lfloat tLinearDelay_tickOut (tLinearDelay const d) +Lfloat tLinearDelay_tickOut (tLinearDelay* const d) { uint32_t idx = (uint32_t) d->outPoint; // First 1/2 of interpolation @@ -237,7 +237,7 @@ Lfloat tLinearDelay_tickOut (tLinearDelay const d) return d->lastOut; } -void tLinearDelay_setDelay (tLinearDelay const d, Lfloat delay) +void tLinearDelay_setDelay (tLinearDelay* const d, Lfloat delay) { d->delay = LEAF_clip(2.0f, delay, d->maxDelay); @@ -254,7 +254,7 @@ void tLinearDelay_setDelay (tLinearDelay const d, Lfloat delay) if ( d->outPoint == d->maxDelay ) d->outPoint = 0; } -Lfloat tLinearDelay_tapOut (tLinearDelay const d, uint32_t tapDelay) +Lfloat tLinearDelay_tapOut (tLinearDelay* const d, uint32_t tapDelay) { int32_t tap = d->inPoint - tapDelay - 1; // Check for wraparound. @@ -263,7 +263,7 @@ Lfloat tLinearDelay_tapOut (tLinearDelay const d, uint32_t tapDelay) return d->buff[tap]; } -Lfloat tLinearDelay_tapOutInterpolated (tLinearDelay const d, Lfloat tapDelay) +Lfloat tLinearDelay_tapOutInterpolated (tLinearDelay* const d, Lfloat tapDelay) { Lfloat tap = (float)d->inPoint - tapDelay - 1.0f; while ( tap < 0.0f ) tap += d->maxDelay; @@ -284,7 +284,7 @@ Lfloat tLinearDelay_tapOutInterpolated (tLinearDelay const d, Lfloat tapDelay) return tapOut; } -void tLinearDelay_tapIn (tLinearDelay const d, Lfloat value, uint32_t tapDelay) +void tLinearDelay_tapIn (tLinearDelay* const d, Lfloat value, uint32_t tapDelay) { int32_t tap = d->inPoint - tapDelay - 1; @@ -294,7 +294,7 @@ void tLinearDelay_tapIn (tLinearDelay const d, Lfloat value, uint32_t tapDelay) d->buff[tap] = value; } -Lfloat tLinearDelay_addTo (tLinearDelay const d, Lfloat value, uint32_t tapDelay) +Lfloat tLinearDelay_addTo (tLinearDelay* const d, Lfloat value, uint32_t tapDelay) { int32_t tap = d->inPoint - tapDelay - 1; @@ -304,28 +304,28 @@ Lfloat tLinearDelay_addTo (tLinearDelay const d, Lfloat value, uint32_t tapDelay return (d->buff[tap] += value); } -Lfloat tLinearDelay_getDelay (tLinearDelay const d) +Lfloat tLinearDelay_getDelay (tLinearDelay* const d) { return d->delay; } -Lfloat tLinearDelay_getLastOut (tLinearDelay const d) +Lfloat tLinearDelay_getLastOut (tLinearDelay* const d) { return d->lastOut; } -Lfloat tLinearDelay_getLastIn (tLinearDelay const d) +Lfloat tLinearDelay_getLastIn (tLinearDelay* const d) { return d->lastIn; } -void tLinearDelay_setGain (tLinearDelay const d, Lfloat gain) +void tLinearDelay_setGain (tLinearDelay* const d, Lfloat gain) { if (gain < 0.0f) d->gain = 0.0f; else d->gain = gain; } -Lfloat tLinearDelay_getGain (tLinearDelay const d) +Lfloat tLinearDelay_getGain (tLinearDelay* const d) { return d->gain; } @@ -338,10 +338,10 @@ void tHermiteDelay_init (tHermiteDelay* const dl, Lfloat delay, uint32_t maxDela tHermiteDelay_initToPool(dl, delay, maxDelay, &leaf->mempool); } -void tHermiteDelay_initToPool (tHermiteDelay* const dl, Lfloat delay, uint32_t maxDelay, tMempool* const mp) +void tHermiteDelay_initToPool (tHermiteDelay** const dl, Lfloat delay, uint32_t maxDelay, tMempool* const mp) { _tMempool* m = *mp; - _tHermiteDelay* d = *dl = (_tHermiteDelay*) mpool_alloc(sizeof(_tHermiteDelay), m); + tHermiteDelay* d = *dl = (tHermiteDelay*) mpool_alloc(sizeof(tHermiteDelay), m); d->mempool = m; d->maxDelay = maxDelay; @@ -382,16 +382,16 @@ void tHermiteDelay_initToPool (tHermiteDelay* const dl, Lfloat delay, uint32_t tHermiteDelay_setDelay(*dl, d->delay); } -void tHermiteDelay_free (tHermiteDelay* const dl) +void tHermiteDelay_free (tHermiteDelay** const dl) { - _tHermiteDelay* d = *dl; + tHermiteDelay* d = *dl; mpool_free((char*)d->buff, d->mempool); mpool_free((char*)d, d->mempool); } -void tHermiteDelay_clear(tHermiteDelay const d) +void tHermiteDelay_clear(tHermiteDelay* const d) { for (unsigned i = 0; i < d->maxDelay; i++) { @@ -399,7 +399,7 @@ void tHermiteDelay_clear(tHermiteDelay const d) } } -Lfloat tHermiteDelay_tick (tHermiteDelay const d, Lfloat input) +Lfloat tHermiteDelay_tick (tHermiteDelay* const d, Lfloat input) { d->buff[d->inPoint] = input * d->gain; @@ -421,7 +421,7 @@ Lfloat tHermiteDelay_tick (tHermiteDelay const d, Lfloat input) return d->lastOut; } -void tHermiteDelay_tickIn (tHermiteDelay const d, Lfloat input) +void tHermiteDelay_tickIn (tHermiteDelay* const d, Lfloat input) { d->buff[d->inPoint] = input; @@ -429,7 +429,7 @@ void tHermiteDelay_tickIn (tHermiteDelay const d, Lfloat input) d->inPoint = (d->inPoint + 1) & d->bufferMask; } -Lfloat tHermiteDelay_tickOut (tHermiteDelay const d) +Lfloat tHermiteDelay_tickOut (tHermiteDelay* const d) { uint32_t idx = (uint32_t) d->outPoint; @@ -447,7 +447,7 @@ Lfloat tHermiteDelay_tickOut (tHermiteDelay const d) return d->lastOut; } -void tHermiteDelay_setDelay (tHermiteDelay const d, Lfloat delay) +void tHermiteDelay_setDelay (tHermiteDelay* const d, Lfloat delay) { //d->delay = LEAF_clip(0.0f, delay, d->maxDelay); d->delay = delay; // not safe but faster @@ -463,14 +463,14 @@ void tHermiteDelay_setDelay (tHermiteDelay const d, Lfloat delay) d->outPoint &= d->bufferMask; } -Lfloat tHermiteDelay_tapOut (tHermiteDelay const d, uint32_t tapDelay) +Lfloat tHermiteDelay_tapOut (tHermiteDelay* const d, uint32_t tapDelay) { int32_t tap = (d->inPoint - tapDelay - 1) & d->bufferMask; return d->buff[tap]; } -Lfloat tHermiteDelay_tapOutInterpolated (tHermiteDelay const d, uint32_t tapDelay, Lfloat alpha) +Lfloat tHermiteDelay_tapOutInterpolated (tHermiteDelay* const d, uint32_t tapDelay, Lfloat alpha) { int32_t idx = (d->inPoint - tapDelay - 1) & d->bufferMask; @@ -481,42 +481,42 @@ Lfloat tHermiteDelay_tapOutInterpolated (tHermiteDelay const d, uint32_t tapDe alpha); } -void tHermiteDelay_tapIn (tHermiteDelay const d, Lfloat value, uint32_t tapDelay) +void tHermiteDelay_tapIn (tHermiteDelay* const d, Lfloat value, uint32_t tapDelay) { int32_t tap = (d->inPoint - tapDelay - 1) & d->bufferMask; d->buff[tap] = value; } -Lfloat tHermiteDelay_addTo (tHermiteDelay const d, Lfloat value, uint32_t tapDelay) +Lfloat tHermiteDelay_addTo (tHermiteDelay* const d, Lfloat value, uint32_t tapDelay) { int32_t tap = (d->inPoint - tapDelay - 1) & d->bufferMask; return (d->buff[tap] += value); } -Lfloat tHermiteDelay_getDelay (tHermiteDelay const d) +Lfloat tHermiteDelay_getDelay (tHermiteDelay* const d) { return d->delay; } -Lfloat tHermiteDelay_getLastOut (tHermiteDelay const d) +Lfloat tHermiteDelay_getLastOut (tHermiteDelay* const d) { return d->lastOut; } -Lfloat tHermiteDelay_getLastIn (tHermiteDelay const d) +Lfloat tHermiteDelay_getLastIn (tHermiteDelay* const d) { return d->lastIn; } -void tHermiteDelay_setGain (tHermiteDelay const d, Lfloat gain) +void tHermiteDelay_setGain (tHermiteDelay* const d, Lfloat gain) { if (gain < 0.0f) d->gain = 0.0f; else d->gain = gain; } -Lfloat tHermiteDelay_getGain (tHermiteDelay const d) +Lfloat tHermiteDelay_getGain (tHermiteDelay* const d) { return d->gain; } @@ -529,10 +529,10 @@ void tLagrangeDelay_init (tLagrangeDelay* const dl, Lfloat delay, uint32_t maxDe tLagrangeDelay_initToPool(dl, delay, maxDelay, &leaf->mempool); } -void tLagrangeDelay_initToPool (tLagrangeDelay* const dl, Lfloat delay, uint32_t maxDelay, tMempool* const mp) +void tLagrangeDelay_initToPool (tLagrangeDelay** const dl, Lfloat delay, uint32_t maxDelay, tMempool* const mp) { _tMempool* m = *mp; - _tLagrangeDelay* d = *dl = (_tLagrangeDelay*) mpool_alloc(sizeof(_tLagrangeDelay), m); + tLagrangeDelay* d = *dl = (tLagrangeDelay*) mpool_alloc(sizeof(tLagrangeDelay), m); d->mempool = m; d->maxDelay = maxDelay; @@ -572,16 +572,16 @@ void tLagrangeDelay_initToPool (tLagrangeDelay* const dl, Lfloat delay, uint32_ tLagrangeDelay_setDelay(*dl, d->delay); } -void tLagrangeDelay_free (tLagrangeDelay* const dl) +void tLagrangeDelay_free (tLagrangeDelay** const dl) { - _tLagrangeDelay* d = *dl; + tLagrangeDelay* d = *dl; mpool_free((char*)d->buff, d->mempool); mpool_free((char*)d, d->mempool); } -void tLagrangeDelay_clear(tLagrangeDelay const d) +void tLagrangeDelay_clear(tLagrangeDelay* const d) { for (unsigned i = 0; i < d->maxDelay; i++) { @@ -589,7 +589,7 @@ void tLagrangeDelay_clear(tLagrangeDelay const d) } } -Lfloat tLagrangeDelay_tick (tLagrangeDelay const d, Lfloat input) +Lfloat tLagrangeDelay_tick (tLagrangeDelay* const d, Lfloat input) { d->buff[d->inPoint] = input; @@ -613,7 +613,7 @@ Lfloat tLagrangeDelay_tick (tLagrangeDelay const d, Lfloat input) return d->lastOut; } -void tLagrangeDelay_tickIn (tLagrangeDelay const d, Lfloat input) +void tLagrangeDelay_tickIn (tLagrangeDelay* const d, Lfloat input) { d->buff[d->inPoint] = input; @@ -621,7 +621,7 @@ void tLagrangeDelay_tickIn (tLagrangeDelay const d, Lfloat input) d->inPoint = (d->inPoint + 1) & d->bufferMask; } -Lfloat tLagrangeDelay_tickOut (tLagrangeDelay const d) +Lfloat tLagrangeDelay_tickOut (tLagrangeDelay* const d) { uint32_t idx = (uint32_t) d->outPoint; @@ -639,7 +639,7 @@ Lfloat tLagrangeDelay_tickOut (tLagrangeDelay const d) return d->lastOut; } -void tLagrangeDelay_setDelay (tLagrangeDelay const d, Lfloat delay) +void tLagrangeDelay_setDelay (tLagrangeDelay* const d, Lfloat delay) { //d->delay = LEAF_clip(0.0f, delay, d->maxDelay); d->delay = delay; // not safe but faster @@ -668,7 +668,7 @@ void tLagrangeDelay_setDelay (tLagrangeDelay const d, Lfloat delay) d->outPoint &= d->bufferMask; } -Lfloat tLagrangeDelay_tapOut (tLagrangeDelay const d, uint32_t tapDelay) +Lfloat tLagrangeDelay_tapOut (tLagrangeDelay* const d, uint32_t tapDelay) { uint32_t tap = (d->inPoint - tapDelay - 1) & d->bufferMask; @@ -676,7 +676,7 @@ Lfloat tLagrangeDelay_tapOut (tLagrangeDelay const d, uint32_t tapDelay) } -Lfloat tLagrangeDelay_tapOutInterpolated (tLagrangeDelay const d, uint32_t tapDelay, Lfloat alpha) +Lfloat tLagrangeDelay_tapOutInterpolated (tLagrangeDelay* const d, uint32_t tapDelay, Lfloat alpha) { uint32_t idx = ((d->inPoint - tapDelay - 2)) & d->bufferMask; @@ -701,37 +701,37 @@ Lfloat tLagrangeDelay_tapOutInterpolated (tLagrangeDelay const d, uint32_t tap } -void tLagrangeDelay_tapIn (tLagrangeDelay const d, Lfloat value, uint32_t tapDelay) +void tLagrangeDelay_tapIn (tLagrangeDelay* const d, Lfloat value, uint32_t tapDelay) { int32_t tap = (d->inPoint - tapDelay - 1) & d->bufferMask; d->buff[tap] = value; } -Lfloat tLagrangeDelay_addTo (tLagrangeDelay const d, Lfloat value, uint32_t tapDelay) +Lfloat tLagrangeDelay_addTo (tLagrangeDelay* const d, Lfloat value, uint32_t tapDelay) { int32_t tap = (d->inPoint - tapDelay - 1) & d->bufferMask; return (d->buff[tap] += value); } -Lfloat tLagrangeDelay_getDelay (tLagrangeDelay const d) +Lfloat tLagrangeDelay_getDelay (tLagrangeDelay* const d) { return d->delay; } -Lfloat tLagrangeDelay_getMaxDelay (tLagrangeDelay const d) +Lfloat tLagrangeDelay_getMaxDelay (tLagrangeDelay* const d) { return d->maxDelay; } -Lfloat tLagrangeDelay_getLastOut (tLagrangeDelay const d) +Lfloat tLagrangeDelay_getLastOut (tLagrangeDelay* const d) { return d->lastOut; } -Lfloat tLagrangeDelay_getLastIn (tLagrangeDelay const d) +Lfloat tLagrangeDelay_getLastIn (tLagrangeDelay* const d) { return d->lastIn; } @@ -746,10 +746,10 @@ void tAllpassDelay_init (tAllpassDelay* const dl, Lfloat delay, uint32_t maxDela tAllpassDelay_initToPool(dl, delay, maxDelay, &leaf->mempool); } -void tAllpassDelay_initToPool (tAllpassDelay* const dl, Lfloat delay, uint32_t maxDelay, tMempool* const mp) +void tAllpassDelay_initToPool (tAllpassDelay** const dl, Lfloat delay, uint32_t maxDelay, tMempool* const mp) { _tMempool* m = *mp; - _tAllpassDelay* d = *dl = (_tAllpassDelay*) mpool_alloc(sizeof(_tAllpassDelay), m); + tAllpassDelay* d = *dl = (tAllpassDelay*) mpool_alloc(sizeof(tAllpassDelay), m); d->mempool = m; d->maxDelay = maxDelay; @@ -773,15 +773,15 @@ void tAllpassDelay_initToPool (tAllpassDelay* const dl, Lfloat delay, uint32_t d->apInput = 0.0f; } -void tAllpassDelay_free (tAllpassDelay* const dl) +void tAllpassDelay_free (tAllpassDelay** const dl) { - _tAllpassDelay* d = *dl; + tAllpassDelay* d = *dl; mpool_free((char*)d->buff, d->mempool); mpool_free((char*)d, d->mempool); } -void tAllpassDelay_clear(tAllpassDelay const d) +void tAllpassDelay_clear(tAllpassDelay* const d) { for (unsigned i = 0; i < d->maxDelay; i++) { @@ -789,7 +789,7 @@ void tAllpassDelay_clear(tAllpassDelay const d) } } -Lfloat tAllpassDelay_tick (tAllpassDelay const d, Lfloat input) +Lfloat tAllpassDelay_tick (tAllpassDelay* const d, Lfloat input) { d->buff[d->inPoint] = input * d->gain; @@ -810,7 +810,7 @@ Lfloat tAllpassDelay_tick (tAllpassDelay const d, Lfloat input) return d->lastOut; } -void tAllpassDelay_setDelay (tAllpassDelay const d, Lfloat delay) +void tAllpassDelay_setDelay (tAllpassDelay* const d, Lfloat delay) { d->delay = LEAF_clip(0.5f, delay, d->maxDelay); @@ -840,7 +840,7 @@ void tAllpassDelay_setDelay (tAllpassDelay const d, Lfloat delay) d->coeff = (1.0f - d->alpha) / (1.0f + d->alpha); // coefficient for allpass } -Lfloat tAllpassDelay_tapOut (tAllpassDelay const d, uint32_t tapDelay) +Lfloat tAllpassDelay_tapOut (tAllpassDelay* const d, uint32_t tapDelay) { int32_t tap = d->inPoint - tapDelay - 1; @@ -851,7 +851,7 @@ Lfloat tAllpassDelay_tapOut (tAllpassDelay const d, uint32_t tapDelay) } -void tAllpassDelay_tapIn (tAllpassDelay const d, Lfloat value, uint32_t tapDelay) +void tAllpassDelay_tapIn (tAllpassDelay* const d, Lfloat value, uint32_t tapDelay) { int32_t tap = d->inPoint - tapDelay - 1; @@ -861,7 +861,7 @@ void tAllpassDelay_tapIn (tAllpassDelay const d, Lfloat value, uint32_t tapDelay d->buff[tap] = value; } -Lfloat tAllpassDelay_addTo (tAllpassDelay const d, Lfloat value, uint32_t tapDelay) +Lfloat tAllpassDelay_addTo (tAllpassDelay* const d, Lfloat value, uint32_t tapDelay) { int32_t tap = d->inPoint - tapDelay - 1; @@ -871,28 +871,28 @@ Lfloat tAllpassDelay_addTo (tAllpassDelay const d, Lfloat value, uint32_t tapDel return (d->buff[tap] += value); } -Lfloat tAllpassDelay_getDelay (tAllpassDelay const d) +Lfloat tAllpassDelay_getDelay (tAllpassDelay* const d) { return d->delay; } -Lfloat tAllpassDelay_getLastOut (tAllpassDelay const d) +Lfloat tAllpassDelay_getLastOut (tAllpassDelay* const d) { return d->lastOut; } -Lfloat tAllpassDelay_getLastIn (tAllpassDelay const d) +Lfloat tAllpassDelay_getLastIn (tAllpassDelay* const d) { return d->lastIn; } -void tAllpassDelay_setGain (tAllpassDelay const d, Lfloat gain) +void tAllpassDelay_setGain (tAllpassDelay* const d, Lfloat gain) { if (gain < 0.0f) d->gain = 0.0f; else d->gain = gain; } -Lfloat tAllpassDelay_getGain (tAllpassDelay const d) +Lfloat tAllpassDelay_getGain (tAllpassDelay* const d) { return d->gain; } @@ -903,10 +903,10 @@ void tTapeDelay_init (tTapeDelay* const dl, Lfloat delay, uint32_t maxDelay, LEA tTapeDelay_initToPool(dl, delay, maxDelay, &leaf->mempool); } -void tTapeDelay_initToPool (tTapeDelay* const dl, Lfloat delay, uint32_t maxDelay, tMempool* const mp) +void tTapeDelay_initToPool (tTapeDelay** const dl, Lfloat delay, uint32_t maxDelay, tMempool* const mp) { _tMempool* m = *mp; - _tTapeDelay* d = *dl = (_tTapeDelay*) mpool_alloc(sizeof(_tTapeDelay), m); + tTapeDelay* d = *dl = (tTapeDelay*) mpool_alloc(sizeof(tTapeDelay), m); d->mempool = m; d->maxDelay = maxDelay; @@ -925,15 +925,15 @@ void tTapeDelay_initToPool (tTapeDelay* const dl, Lfloat delay, uint32_t maxDela tTapeDelay_setDelay(*dl, delay); } -void tTapeDelay_free (tTapeDelay* const dl) +void tTapeDelay_free (tTapeDelay** const dl) { - _tTapeDelay* d = *dl; + tTapeDelay* d = *dl; mpool_free((char*)d->buff, d->mempool); mpool_free((char*)d, d->mempool); } -void tTapeDelay_clear(tTapeDelay const d) +void tTapeDelay_clear(tTapeDelay* const d) { for (unsigned i = 0; i < d->maxDelay; i++) { @@ -943,7 +943,7 @@ void tTapeDelay_clear(tTapeDelay const d) //#define SMOOTH_FACTOR 10.f -Lfloat tTapeDelay_tick (tTapeDelay const d, Lfloat input) +Lfloat tTapeDelay_tick (tTapeDelay* const d, Lfloat input) { d->buff[d->inPoint] = input * d->gain; @@ -973,24 +973,24 @@ Lfloat tTapeDelay_tick (tTapeDelay const d, Lfloat input) return 0.0f; } -void tTapeDelay_incrementInPoint(tTapeDelay const d) +void tTapeDelay_incrementInPoint(tTapeDelay* const d) { // Increment input pointer modulo length. if (++(d->inPoint) == d->maxDelay ) d->inPoint = 0; } -void tTapeDelay_setRate(tTapeDelay const d, Lfloat rate) +void tTapeDelay_setRate(tTapeDelay* const d, Lfloat rate) { d->inc = rate; } -void tTapeDelay_setDelay (tTapeDelay const d, Lfloat delay) +void tTapeDelay_setDelay (tTapeDelay* const d, Lfloat delay) { d->delay = LEAF_clip(1.f, delay, d->maxDelay); } -Lfloat tTapeDelay_tapOut (tTapeDelay const d, Lfloat tapDelay) +Lfloat tTapeDelay_tapOut (tTapeDelay* const d, Lfloat tapDelay) { Lfloat tap = (Lfloat) d->inPoint - tapDelay - 1.f; @@ -1011,7 +1011,7 @@ Lfloat tTapeDelay_tapOut (tTapeDelay const d, Lfloat tapDelay) } -void tTapeDelay_tapIn (tTapeDelay const d, Lfloat value, uint32_t tapDelay) +void tTapeDelay_tapIn (tTapeDelay* const d, Lfloat value, uint32_t tapDelay) { int32_t tap = d->inPoint - tapDelay - 1; @@ -1021,7 +1021,7 @@ void tTapeDelay_tapIn (tTapeDelay const d, Lfloat value, uint32_t tapDelay) d->buff[tap] = value; } -Lfloat tTapeDelay_addTo (tTapeDelay const d, Lfloat value, uint32_t tapDelay) +Lfloat tTapeDelay_addTo (tTapeDelay* const d, Lfloat value, uint32_t tapDelay) { int32_t tap = d->inPoint - tapDelay - 1; @@ -1031,28 +1031,28 @@ Lfloat tTapeDelay_addTo (tTapeDelay const d, Lfloat value, uint32_t tapDelay) return (d->buff[tap] += value); } -Lfloat tTapeDelay_getDelay (tTapeDelay d) +Lfloat tTapeDelay_getDelay (tTapeDelay* d) { return d->delay; } -Lfloat tTapeDelay_getLastOut (tTapeDelay const d) +Lfloat tTapeDelay_getLastOut (tTapeDelay* const d) { return d->lastOut; } -Lfloat tTapeDelay_getLastIn (tTapeDelay const d) +Lfloat tTapeDelay_getLastIn (tTapeDelay* const d) { return d->lastIn; } -void tTapeDelay_setGain (tTapeDelay const d, Lfloat gain) +void tTapeDelay_setGain (tTapeDelay* const d, Lfloat gain) { if (gain < 0.0f) d->gain = 0.0f; else d->gain = gain; } -Lfloat tTapeDelay_getGain (tTapeDelay const d) +Lfloat tTapeDelay_getGain (tTapeDelay* const d) { return d->gain; } @@ -1065,10 +1065,10 @@ void tRingBuffer_init (tRingBuffer* const ring, int size, LEAF* const lea tRingBuffer_initToPool(ring, size, &leaf->mempool); } -void tRingBuffer_initToPool (tRingBuffer* const ring, int size, tMempool* const mempool) +void tRingBuffer_initToPool (tRingBuffer** const ring, int size, tMempool* const mempool) { _tMempool* m = *mempool; - _tRingBuffer* r = *ring = (_tRingBuffer*) mpool_alloc(sizeof(_tRingBuffer), m); + tRingBuffer* r = *ring = (tRingBuffer*) mpool_alloc(sizeof(tRingBuffer), m); r->mempool = m; // Ensure size is a power of 2 @@ -1080,37 +1080,37 @@ void tRingBuffer_initToPool (tRingBuffer* const ring, int size, tMempool* c r->pos = 0; } -void tRingBuffer_free (tRingBuffer* const ring) +void tRingBuffer_free (tRingBuffer** const ring) { - _tRingBuffer* r = *ring; + tRingBuffer* r = *ring; mpool_free((char*) r->buffer, r->mempool); mpool_free((char*) r, r->mempool); } -void tRingBuffer_push (tRingBuffer const r, Lfloat val) +void tRingBuffer_push (tRingBuffer* const r, Lfloat val) { --r->pos; r->pos &= r->mask; r->buffer[r->pos] = val; } -Lfloat tRingBuffer_getNewest (tRingBuffer const r) +Lfloat tRingBuffer_getNewest (tRingBuffer* const r) { return r->buffer[r->pos]; } -Lfloat tRingBuffer_getOldest (tRingBuffer const r) +Lfloat tRingBuffer_getOldest (tRingBuffer* const r) { return r->buffer[(r->pos + r->size - 1) & r->mask]; } -Lfloat tRingBuffer_get (tRingBuffer const r, int index) +Lfloat tRingBuffer_get (tRingBuffer* const r, int index) { return r->buffer[(r->pos + index) & r->mask]; } -int tRingBuffer_getSize (tRingBuffer const r) +int tRingBuffer_getSize (tRingBuffer* const r) { return r->size; } diff --git a/leaf/Src/leaf-distortion.c b/leaf/Src/leaf-distortion.c index 0a7ea15..b82657f 100644 --- a/leaf/Src/leaf-distortion.c +++ b/leaf/Src/leaf-distortion.c @@ -33,10 +33,10 @@ void tSampleReducer_init (tSampleReducer* const sr, LEAF* const leaf) tSampleReducer_initToPool(sr, &leaf->mempool); } -void tSampleReducer_initToPool (tSampleReducer* const sr, tMempool* const mp) +void tSampleReducer_initToPool (tSampleReducer** const sr, tMempool** const mp) { _tMempool* m = *mp; - _tSampleReducer* s = *sr = (_tSampleReducer*) mpool_alloc(sizeof(_tSampleReducer), m); + tSampleReducer* s = *sr = (tSampleReducer*) mpool_alloc(sizeof(tSampleReducer), m); s->mempool = m; s->invRatio = 1.0f; @@ -44,14 +44,14 @@ void tSampleReducer_initToPool (tSampleReducer* const sr, tMempool* const mp) s->count = 0; } -void tSampleReducer_free (tSampleReducer* const sr) +void tSampleReducer_free (tSampleReducer** const sr) { - _tSampleReducer* s = *sr; + tSampleReducer* s = *sr; mpool_free((char*)s, s->mempool); } -Lfloat tSampleReducer_tick(tSampleReducer const s, Lfloat input) +Lfloat tSampleReducer_tick(tSampleReducer* const s, Lfloat input) { if (s->count > s->invRatio) { @@ -64,7 +64,7 @@ Lfloat tSampleReducer_tick(tSampleReducer const s, Lfloat input) } -void tSampleReducer_setRatio(tSampleReducer const s, Lfloat ratio) +void tSampleReducer_setRatio(tSampleReducer* const s, Lfloat ratio) { if ((ratio <= 1.0f) && (ratio >= 0.0f)) s->invRatio = 1.0f / ratio; @@ -81,7 +81,7 @@ void tOversampler_init (tOversampler* const osr, int ratio, int extraQuality, LE tOversampler_initToPool(osr, ratio, extraQuality, &leaf->mempool); } -void tOversampler_initToPool (tOversampler* const osr, int maxRatio, int extraQuality, tMempool* const mp) +void tOversampler_initToPool (tOversampler** const osr, int maxRatio, int extraQuality, tMempool* const mp) { _tMempool* m = *mp; int offset = 0; @@ -89,7 +89,7 @@ void tOversampler_initToPool (tOversampler* const osr, int maxRatio, int extraQu if (maxRatio == 2 || maxRatio == 4 || maxRatio == 8 || maxRatio == 16 || maxRatio == 32 || maxRatio == 64) { - _tOversampler* os = *osr = (_tOversampler*) mpool_alloc(sizeof(_tOversampler), m); + tOversampler* os = *osr = (tOversampler*) mpool_alloc(sizeof(tOversampler), m); os->mempool = m; os->offset = offset; @@ -105,16 +105,16 @@ void tOversampler_initToPool (tOversampler* const osr, int maxRatio, int extraQu } } -void tOversampler_free (tOversampler* const osr) +void tOversampler_free (tOversampler** const osr) { - _tOversampler* os = *osr; + tOversampler* os = *osr; mpool_free((char*)os->upState, os->mempool); mpool_free((char*)os->downState, os->mempool); mpool_free((char*)os, os->mempool); } -Lfloat tOversampler_tick(tOversampler const os, Lfloat input, Lfloat* oversample, Lfloat (*effectTick)(Lfloat)) +Lfloat tOversampler_tick(tOversampler* const os, Lfloat input, Lfloat* oversample, Lfloat (*effectTick)(Lfloat)) { tOversampler_upsample(os, input, oversample); @@ -129,7 +129,7 @@ Lfloat tOversampler_tick(tOversampler const os, Lfloat input, Lfloat* oversample #ifdef ITCMRAM void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tOversampler_upsample(tOversampler* const osr, Lfloat input, Lfloat* output) #else -void tOversampler_upsample(tOversampler const os, Lfloat input, Lfloat* output) +void tOversampler_upsample(tOversampler* const os, Lfloat input, Lfloat* output) #endif { if (os->ratio == 1) @@ -230,7 +230,7 @@ void tOversampler_upsample(tOversampler const os, Lfloat input, Lfloat* output) #ifdef ITCMRAM Lfloat __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tOversampler_downsample(tOversampler *const osr, Lfloat* input) #else -Lfloat tOversampler_downsample(tOversampler const os, Lfloat* input) +Lfloat tOversampler_downsample(tOversampler* const os, Lfloat* input) #endif { if (os->ratio == 1) return input[0]; @@ -315,7 +315,7 @@ Lfloat tOversampler_downsample(tOversampler const os, Lfloat* input) return output; } -void tOversampler_setRatio (tOversampler const os, int ratio) +void tOversampler_setRatio (tOversampler* const os, int ratio) { if (ratio == os->ratio) return; if (ratio > os->maxRatio) ratio = os->maxRatio; @@ -331,7 +331,7 @@ void tOversampler_setRatio (tOversampler const os, int ratio) } } -void tOversampler_setQuality (tOversampler const os, int quality) +void tOversampler_setQuality (tOversampler* const os, int quality) { if (!os->allowHighQuality) return; int offset = 0; @@ -346,7 +346,7 @@ void tOversampler_setQuality (tOversampler const os, int quality) os->pCoeffs = (Lfloat*) __leaf_tableref_firCoeffs[idx]; } -int tOversampler_getLatency(tOversampler const os) +int tOversampler_getLatency(tOversampler* const os) { return os->phaseLength; } @@ -361,10 +361,10 @@ void tWavefolder_init (tWavefolder* const wf, Lfloat ffAmount, Lfloat fbAmount, tWavefolder_initToPool (wf, ffAmount, fbAmount, foldDepth, &leaf->mempool); } -void tWavefolder_initToPool (tWavefolder* const wf, Lfloat ffAmount, Lfloat fbAmount, Lfloat foldDepth, tMempool* const mp) +void tWavefolder_initToPool (tWavefolder** const wf, Lfloat ffAmount, Lfloat fbAmount, Lfloat foldDepth, tMempool* const mp) { _tMempool* m = *mp; - _tWavefolder* w = *wf = (_tWavefolder*) mpool_alloc(sizeof(_tWavefolder), m); + tWavefolder* w = *wf = (tWavefolder*) mpool_alloc(sizeof(tWavefolder), m); w->mempool = m; tHighpass_initToPool(&w->dcBlock, 1.0f, mp); w->FBsample = 0.0f; @@ -376,40 +376,40 @@ void tWavefolder_initToPool (tWavefolder* const wf, Lfloat ffAmount, Lfloat fbAm w->invFBAmount = 1.0f / (1.0f + fbAmount); } -void tWavefolder_free (tWavefolder* const wf) +void tWavefolder_free (tWavefolder** const wf) { - _tWavefolder* w = *wf; + tWavefolder* w = *wf; mpool_free((char*)w, w->mempool); } -void tWavefolder_setFFAmount(tWavefolder const w, Lfloat ffAmount) +void tWavefolder_setFFAmount(tWavefolder* const w, Lfloat ffAmount) { w->FFAmount = ffAmount; } -void tWavefolder_setFBAmount(tWavefolder const w, Lfloat fbAmount) +void tWavefolder_setFBAmount(tWavefolder* const w, Lfloat fbAmount) { w->FBAmount = fbAmount; w->invFBAmount = 1.0f / (1.0f + fbAmount); } -void tWavefolder_setFoldDepth(tWavefolder const w, Lfloat foldDepth) +void tWavefolder_setFoldDepth(tWavefolder* const w, Lfloat foldDepth) { w->foldDepth = foldDepth; } -void tWavefolder_setOffset(tWavefolder const w, Lfloat offset) +void tWavefolder_setOffset(tWavefolder* const w, Lfloat offset) { w->offset = offset; } -void tWavefolder_setGain(tWavefolder const w, Lfloat gain) +void tWavefolder_setGain(tWavefolder* const w, Lfloat gain) { w->gain = gain; } -Lfloat tWavefolder_tick(tWavefolder const w, Lfloat in) +Lfloat tWavefolder_tick(tWavefolder* const w, Lfloat in) { //Lfloat sample = in * w->offset + (w->gain * w->offset); Lfloat sample = in; @@ -450,7 +450,7 @@ Lfloat tWavefolder_tick(tWavefolder const w, Lfloat in) #endif w->FBsample = (ff + fb) - w->foldDepth * tempVal; sample = w->FBsample * w->invFBAmount; - sample = tHighpass_tick(w->dcBlock, sample); + sample = tHighpass_tick(&w->dcBlock, sample); return sample; } @@ -467,10 +467,10 @@ void tLockhartWavefolder_init (tLockhartWavefolder* const wf, LEAF* const leaf) tLockhartWavefolder_initToPool (wf, &leaf->mempool); } -void tLockhartWavefolder_initToPool (tLockhartWavefolder* const wf, tMempool* const mp) +void tLockhartWavefolder_initToPool (tLockhartWavefolder** const wf, tMempool* const mp) { _tMempool* m = *mp; - _tLockhartWavefolder* w = *wf = (_tLockhartWavefolder*) mpool_alloc(sizeof(_tLockhartWavefolder), m); + tLockhartWavefolder* w = *wf = (tLockhartWavefolder*) mpool_alloc(sizeof(tLockhartWavefolder), m); w->mempool = m; w->Ln1 = 0.0; @@ -512,16 +512,16 @@ void tLockhartWavefolder_initToPool (tLockhartWavefolder* const wf, tMempool* co } -void tLockhartWavefolder_free (tLockhartWavefolder* const wf) +void tLockhartWavefolder_free (tLockhartWavefolder** const wf) { - _tLockhartWavefolder* w = *wf; + tLockhartWavefolder* w = *wf; mpool_free((char*)w, w->mempool); } -double tLockhartWavefolderLambert(tLockhartWavefolder const mwf, double x, double ln) +double tLockhartWavefolderLambert(tLockhartWavefolder* const mwf, double x, double ln) { // Initial guess (use previous value) mwf->w = ln; @@ -601,7 +601,7 @@ double tLockhartWavefolderLambert(tLockhartWavefolder const mwf, double x, doubl return mwf->w; } -Lfloat tLockhartWavefolder_tick(tLockhartWavefolder const w, Lfloat in) +Lfloat tLockhartWavefolder_tick(tLockhartWavefolder* const w, Lfloat in) { Lfloat out = 0.0f; @@ -718,10 +718,10 @@ void tCrusher_init (tCrusher* const cr, LEAF* const leaf) tCrusher_initToPool(cr, &leaf->mempool); } -void tCrusher_initToPool (tCrusher* const cr, tMempool* const mp) +void tCrusher_initToPool (tCrusher** const cr, tMempool* const mp) { _tMempool* m = *mp; - _tCrusher* c = *cr = (_tCrusher*) mpool_alloc(sizeof(_tCrusher), m); + tCrusher* c = *cr = (tCrusher*) mpool_alloc(sizeof(tCrusher), m); c->mempool = m; c->op = 4; @@ -732,15 +732,15 @@ void tCrusher_initToPool (tCrusher* const cr, tMempool* const mp) c->gain = (c->div / SCALAR) * 0.7f + 0.3f; } -void tCrusher_free (tCrusher* const cr) +void tCrusher_free (tCrusher** const cr) { - _tCrusher* c = *cr; + tCrusher* c = *cr; tSampleReducer_free(&c->sReducer); mpool_free((char*)c, c->mempool); } -Lfloat tCrusher_tick (tCrusher const c, Lfloat input) +Lfloat tCrusher_tick (tCrusher* const c, Lfloat input) { Lfloat sample = input; @@ -756,19 +756,19 @@ Lfloat tCrusher_tick (tCrusher const c, Lfloat input) sample = LEAF_round(sample, c->rnd); - sample = tSampleReducer_tick(c->sReducer, sample); + sample = tSampleReducer_tick(&c->sReducer, sample); return sample * c->gain; } -void tCrusher_setOperation (tCrusher const c, Lfloat op) +void tCrusher_setOperation (tCrusher* const c, Lfloat op) { c->op = (uint32_t) (op * 8.0f); } // 0.0 - 1.0 -void tCrusher_setQuality (tCrusher const c, Lfloat val) +void tCrusher_setQuality (tCrusher* const c, Lfloat val) { val = LEAF_clip(0.0f, val, 1.0f); @@ -778,13 +778,13 @@ void tCrusher_setQuality (tCrusher const c, Lfloat val) } // what decimal to round to -void tCrusher_setRound (tCrusher const c, Lfloat rnd) +void tCrusher_setRound (tCrusher* const c, Lfloat rnd) { c->rnd = rnd; } -void tCrusher_setSamplingRatio (tCrusher const c, Lfloat ratio) +void tCrusher_setSamplingRatio (tCrusher* const c, Lfloat ratio) { c->srr = ratio; - tSampleReducer_setRatio(c->sReducer, ratio); + tSampleReducer_setRatio(&c->sReducer, ratio); } diff --git a/leaf/Src/leaf-dynamics.c b/leaf/Src/leaf-dynamics.c index 13cea85..8c7465c 100644 --- a/leaf/Src/leaf-dynamics.c +++ b/leaf/Src/leaf-dynamics.c @@ -41,15 +41,15 @@ return c; } */ -void tCompressor_init (tCompressor* const comp, LEAF* const leaf) +void tCompressor_init (tCompressor** const comp, LEAF* const leaf) { tCompressor_initToPool(comp, &leaf->mempool); } -void tCompressor_initToPool (tCompressor* const comp, tMempool* const mp) +void tCompressor_initToPool (tCompressor** const comp, tMempool* const mp) { _tMempool* m = *mp; - _tCompressor* c = *comp = (_tCompressor*) mpool_alloc(sizeof(_tCompressor), m); + tCompressor* c = *comp = (tCompressor*) mpool_alloc(sizeof(tCompressor), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; c->sampleRate = leaf->sampleRate; @@ -78,12 +78,12 @@ void tCompressor_initToPool (tCompressor* const comp, tMempool* const mp) void tCompressor_free (tCompressor* const comp) { - _tCompressor* c = *comp; + tCompressor* c = &*comp; mpool_free((char*)c, c->mempool); } -Lfloat tCompressor_tick(tCompressor const c, Lfloat in) +Lfloat tCompressor_tick(tCompressor* const c, Lfloat in) { Lfloat slope, overshoot; @@ -136,7 +136,7 @@ Lfloat tCompressor_tick(tCompressor const c, Lfloat in) //requires tables to be set with set function //more efficient without soft knee calculation -Lfloat tCompressor_tickWithTable(tCompressor const c, Lfloat in) +Lfloat tCompressor_tickWithTable(tCompressor* const c, Lfloat in) { Lfloat slope, overshoot; @@ -182,7 +182,7 @@ Lfloat tCompressor_tickWithTable(tCompressor const c, Lfloat in) } //requires tables to be set with set function -Lfloat tCompressor_tickWithTableHardKnee(tCompressor const c, Lfloat in) +Lfloat tCompressor_tickWithTableHardKnee(tCompressor* const c, Lfloat in) { Lfloat slope, overshoot; @@ -221,7 +221,7 @@ Lfloat tCompressor_tickWithTableHardKnee(tCompressor const c, Lfloat in) return attenuation * in; } -void tCompressor_setTables(tCompressor const c, Lfloat* atodb, Lfloat* dbtoa, Lfloat atodbMinIn, Lfloat atodbMaxIn, Lfloat dbtoaMinIn, Lfloat dbtoaMaxIn, int atodbTableSize, int dbtoaTableSize) +void tCompressor_setTables(tCompressor* const c, Lfloat* atodb, Lfloat* dbtoa, Lfloat atodbMinIn, Lfloat atodbMaxIn, Lfloat dbtoaMinIn, Lfloat dbtoaMaxIn, int atodbTableSize, int dbtoaTableSize) { c->atodbTable = atodb; c->dbtoaTable = dbtoa; @@ -247,7 +247,7 @@ void tCompressor_setTables(tCompressor const c, Lfloat* atodb, Lfloat* dbtoa, Lf //c->R = 0.5f; // compression Ratio //c->W = 3.0f; // decibel Width of knee transition //c->M = 1.0f; // decibel Make-up gain -void tCompressor_setParams(tCompressor const c, Lfloat thresh, Lfloat ratio, Lfloat knee, Lfloat makeup, Lfloat attack, Lfloat release) +void tCompressor_setParams(tCompressor* const c, Lfloat thresh, Lfloat ratio, Lfloat knee, Lfloat makeup, Lfloat attack, Lfloat release) { c->T = thresh; c->R = ratio; @@ -259,7 +259,7 @@ void tCompressor_setParams(tCompressor const c, Lfloat thresh, Lfloat ratio, Lfl c->tauRelease = fastExp4(-1.0f/(0.001f * release * c->sampleRate)); } -void tCompressor_setSampleRate(tCompressor const c, Lfloat sampleRate) +void tCompressor_setSampleRate(tCompressor* const c, Lfloat sampleRate) { c->sampleRate = sampleRate; } @@ -270,10 +270,10 @@ void tFeedbackLeveler_init (tFeedbackLeveler* const fb, Lfloat targetLevel, Lflo tFeedbackLeveler_initToPool(fb, targetLevel, factor, strength, mode, &leaf->mempool); } -void tFeedbackLeveler_initToPool (tFeedbackLeveler* const fb, Lfloat targetLevel, Lfloat factor, Lfloat strength, int mode, tMempool* const mp) +void tFeedbackLeveler_initToPool (tFeedbackLeveler** const fb, Lfloat targetLevel, Lfloat factor, Lfloat strength, int mode, tMempool* const mp) { _tMempool* m = *mp; - _tFeedbackLeveler* p = *fb = (_tFeedbackLeveler*) mpool_alloc(sizeof(_tFeedbackLeveler), m); + tFeedbackLeveler* p = *fb = (tFeedbackLeveler*) mpool_alloc(sizeof(tFeedbackLeveler), m); p->mempool = m; p->curr=0.0f; @@ -283,45 +283,45 @@ void tFeedbackLeveler_initToPool (tFeedbackLeveler* const fb, Lfloat targetLevel p->strength=strength; } -void tFeedbackLeveler_free (tFeedbackLeveler* const fb) +void tFeedbackLeveler_free (tFeedbackLeveler** const fb) { - _tFeedbackLeveler* p = *fb; + tFeedbackLeveler* p = *fb; tPowerFollower_free(&p->pwrFlw); mpool_free((char*)p, p->mempool); } -void tFeedbackLeveler_setStrength(tFeedbackLeveler const p, Lfloat strength) +void tFeedbackLeveler_setStrength(tFeedbackLeveler* const p, Lfloat strength) { // strength is how strongly level diff is affecting the amp ratio // try 0.125 for a start p->strength=strength; } -void tFeedbackLeveler_setFactor(tFeedbackLeveler const p, Lfloat factor) +void tFeedbackLeveler_setFactor(tFeedbackLeveler* const p, Lfloat factor) { - tPowerFollower_setFactor(p->pwrFlw,factor); + tPowerFollower_setFactor(&p->pwrFlw,factor); } -void tFeedbackLeveler_setMode(tFeedbackLeveler const p, int mode) +void tFeedbackLeveler_setMode(tFeedbackLeveler* const p, int mode) { // 0 for decaying with upwards lev limiting, 1 for constrained absolute level (also downwards limiting) p->mode=mode; } -Lfloat tFeedbackLeveler_tick(tFeedbackLeveler const p, Lfloat input) +Lfloat tFeedbackLeveler_tick(tFeedbackLeveler* const p, Lfloat input) { - Lfloat levdiff=(tPowerFollower_tick(p->pwrFlw, input)-p->targetLevel); + Lfloat levdiff=(tPowerFollower_tick(&p->pwrFlw, input)-p->targetLevel); if (p->mode==0 && levdiff<0.0f) levdiff=0.0f; p->curr=input*(1.0f-p->strength*levdiff); return p->curr; } -Lfloat tFeedbackLeveler_sample(tFeedbackLeveler const p) +Lfloat tFeedbackLeveler_sample(tFeedbackLeveler* const p) { return p->curr; } -void tFeedbackLeveler_setTargetLevel (tFeedbackLeveler const p, Lfloat TargetLevel) +void tFeedbackLeveler_setTargetLevel (tFeedbackLeveler* const p, Lfloat TargetLevel) { p->targetLevel=TargetLevel; } @@ -332,10 +332,10 @@ void tThreshold_init (tThreshold* const th, Lfloat low, Lfloat high, LEAF* const tThreshold_initToPool(th, low, high, &leaf->mempool); } -void tThreshold_initToPool (tThreshold* const th, Lfloat low, Lfloat high, tMempool* const mp) +void tThreshold_initToPool (tThreshold** const th, Lfloat low, Lfloat high, tMempool* const mp) { _tMempool* m = *mp; - _tThreshold* t = *th = (_tThreshold*) mpool_alloc(sizeof(_tThreshold), m); + tThreshold* t = *th = (tThreshold*) mpool_alloc(sizeof(tThreshold), m); t->mempool = m; t->highThresh = high; @@ -344,14 +344,14 @@ void tThreshold_initToPool (tThreshold* const th, Lfloat low, Lfloat high, tMemp t->currentValue = 0; } -void tThreshold_free (tThreshold* const th) +void tThreshold_free (tThreshold** const th) { - _tThreshold* t = *th; + tThreshold* t = *th; mpool_free((char*)t, t->mempool); } -int tThreshold_tick(tThreshold const t, Lfloat in) +int tThreshold_tick(tThreshold* const t, Lfloat in) { if (in >= t->highThresh) { @@ -365,12 +365,12 @@ int tThreshold_tick(tThreshold const t, Lfloat in) return t->currentValue; } -void tThreshold_setLow(tThreshold const t, Lfloat low) +void tThreshold_setLow(tThreshold* const t, Lfloat low) { t->lowThresh = low; } -void tThreshold_setHigh(tThreshold const t, Lfloat high) +void tThreshold_setHigh(tThreshold* const t, Lfloat high) { t->highThresh = high; } diff --git a/leaf/Src/leaf-effects.c b/leaf/Src/leaf-effects.c index e3fdd03..0a6e6cd 100644 --- a/leaf/Src/leaf-effects.c +++ b/leaf/Src/leaf-effects.c @@ -37,10 +37,10 @@ void tTalkbox_init (tTalkbox* const voc, int bufsize, LEAF* const leaf) tTalkbox_initToPool(voc, bufsize, &leaf->mempool); } -void tTalkbox_initToPool (tTalkbox* const voc, int bufsize, tMempool* const mp) +void tTalkbox_initToPool (tTalkbox** const voc, int bufsize, tMempool* const mp) { _tMempool* m = *mp; - _tTalkbox* v = *voc = (_tTalkbox*) mpool_alloc(sizeof(_tTalkbox), m); + tTalkbox* v = *voc = (tTalkbox*) mpool_alloc(sizeof(tTalkbox), m); v->mempool = m; LEAF* leaf = v->mempool->leaf; @@ -72,7 +72,7 @@ void tTalkbox_initToPool (tTalkbox* const voc, int bufsize, tMempool* const mp) void tTalkbox_free (tTalkbox* const voc) { - _tTalkbox* v = *voc; + tTalkbox* v = &*voc; mpool_free((char*)v->buf1, v->mempool); mpool_free((char*)v->buf0, v->mempool); @@ -86,7 +86,7 @@ void tTalkbox_free (tTalkbox* const voc) mpool_free((char*)v, v->mempool); } -void tTalkbox_update(tTalkbox const v) ///update internal parameters... +void tTalkbox_update(tTalkbox* const v) ///update internal parameters... { Lfloat fs = v->sampleRate; // if(fs < 8000.0f) fs = 8000.0f; @@ -117,7 +117,7 @@ void tTalkbox_update(tTalkbox const v) ///update internal parameters... v->dry = 2.0f * v->param[1] * v->param[1]; } -void tTalkbox_suspend(tTalkbox const v) ///clear any buffers... +void tTalkbox_suspend(tTalkbox* const v) ///clear any buffers... { v->pos = v->K = 0; v->emphasis = 0.0f; @@ -209,7 +209,7 @@ void tTalkbox_lpcDurbin(Lfloat *r, int p, Lfloat *k, Lfloat *g) *g = sqrtf(e); } -Lfloat tTalkbox_tick(tTalkbox const v, Lfloat synth, Lfloat voice) +Lfloat tTalkbox_tick(tTalkbox* const v, Lfloat synth, Lfloat voice) { int32_t p0=v->pos, p1 = (v->pos + v->N/2) % v->N; Lfloat e=v->emphasis, w, o, x, fx=v->FX; @@ -313,7 +313,7 @@ void tTalkbox_lpc(Lfloat *buf, Lfloat *car, double* dl, double* Rt, int32_t n, i } } -void tTalkbox_setQuality(tTalkbox const v, Lfloat quality) +void tTalkbox_setQuality(tTalkbox* const v, Lfloat quality) { v->param[3] = quality; v->O = (int32_t)((0.0001f + 0.0004f * v->param[3]) * v->sampleRate); @@ -323,22 +323,22 @@ void tTalkbox_setQuality(tTalkbox const v, Lfloat quality) } } -void tTalkbox_setWarpFactor(tTalkbox const v, Lfloat warpFactor) +void tTalkbox_setWarpFactor(tTalkbox* const v, Lfloat warpFactor) { v->warpFactor = warpFactor; } -void tTalkbox_setWarpOn(tTalkbox const v, Lfloat warpOn) +void tTalkbox_setWarpOn(tTalkbox* const v, Lfloat warpOn) { v->warpOn = warpOn; } -void tTalkbox_setFreeze(tTalkbox const v, Lfloat freeze) +void tTalkbox_setFreeze(tTalkbox* const v, Lfloat freeze) { v->freeze = freeze; } -void tTalkbox_setSampleRate(tTalkbox const v, Lfloat sr) +void tTalkbox_setSampleRate(tTalkbox* const v, Lfloat sr) { v->sampleRate = sr; tTalkbox_update(v); @@ -360,10 +360,10 @@ void tTalkboxLfloat_init (tTalkboxLfloat* const voc, int bufsize, LEAF* const le tTalkboxLfloat_initToPool(voc, bufsize, &leaf->mempool); } -void tTalkboxLfloat_initToPool (tTalkboxLfloat* const voc, int bufsize, tMempool* const mp) +void tTalkboxLfloat_initToPool (tTalkboxLfloat** const voc, int bufsize, tMempool* const mp) { _tMempool* m = *mp; - _tTalkboxLfloat* v = *voc = (_tTalkboxLfloat*) mpool_alloc(sizeof(_tTalkboxLfloat), m); + tTalkboxLfloat* v = *voc = (tTalkboxLfloat*) mpool_alloc(sizeof(tTalkboxLfloat), m); v->mempool = m; LEAF* leaf = v->mempool->leaf; @@ -389,13 +389,13 @@ void tTalkboxLfloat_initToPool (tTalkboxLfloat* const voc, int bufsize, tMempool v->sampleRate = leaf->sampleRate; - tTalkboxLfloat_update(*voc); - tTalkboxLfloat_suspend(*voc); + tTalkboxLfloat_update(&*voc); + tTalkboxLfloat_suspend(&*voc); } -void tTalkboxLfloat_free (tTalkboxLfloat* const voc) +void tTalkboxLfloat_free (tTalkboxLfloat** const voc) { - _tTalkboxLfloat* v = *voc; + tTalkboxLfloat* v = *voc; mpool_free((char*)v->buf1, v->mempool); mpool_free((char*)v->buf0, v->mempool); @@ -409,7 +409,7 @@ void tTalkboxLfloat_free (tTalkboxLfloat* const voc) mpool_free((char*)v, v->mempool); } -void tTalkboxLfloat_update(tTalkboxLfloat const v) ///update internal parameters... +void tTalkboxLfloat_update(tTalkboxLfloat* const v) ///update internal parameters... { Lfloat fs = v->sampleRate; // if(fs < 8000.0f) fs = 8000.0f; @@ -440,7 +440,7 @@ void tTalkboxLfloat_update(tTalkboxLfloat const v) ///update internal parameters v->dry = 2.0f * v->param[1] * v->param[1]; } -void tTalkboxLfloat_suspend(tTalkboxLfloat const v) ///clear any buffers... +void tTalkboxLfloat_suspend(tTalkboxLfloat* const v) ///clear any buffers... { v->pos = v->K = 0; v->emphasis = 0.0f; @@ -533,7 +533,7 @@ void tTalkboxLfloat_lpcDurbin(Lfloat *r, int p, Lfloat *k, Lfloat *g) *g = sqrtf(e); } -Lfloat tTalkboxLfloat_tick(tTalkboxLfloat const v, Lfloat synth, Lfloat voice) +Lfloat tTalkboxLfloat_tick(tTalkboxLfloat* const v, Lfloat synth, Lfloat voice) { int32_t p0=v->pos, p1 = (v->pos + v->N/2) % v->N; Lfloat e=v->emphasis, w, o, x, fx=v->FX; @@ -640,7 +640,7 @@ void tTalkboxLfloat_lpc(Lfloat *buf, Lfloat *car, Lfloat* dl, Lfloat* Rt, int32_ } } -void tTalkboxLfloat_setQuality(tTalkboxLfloat const v, Lfloat quality) +void tTalkboxLfloat_setQuality(tTalkboxLfloat* const v, Lfloat quality) { v->param[3] = quality; v->O = (int32_t)((0.0001f + 0.0004f * v->param[3]) * v->sampleRate); @@ -650,22 +650,22 @@ void tTalkboxLfloat_setQuality(tTalkboxLfloat const v, Lfloat quality) } } -void tTalkboxLfloat_setWarpFactor(tTalkboxLfloat const v, Lfloat warpFactor) +void tTalkboxLfloat_setWarpFactor(tTalkboxLfloat* const v, Lfloat warpFactor) { v->warpFactor = warpFactor; } -void tTalkboxLfloat_setWarpOn(tTalkboxLfloat const v, int warpOn) +void tTalkboxLfloat_setWarpOn(tTalkboxLfloat* const v, int warpOn) { v->warpOn = warpOn; } -void tTalkboxLfloat_setFreeze(tTalkboxLfloat const v, int freeze) +void tTalkboxLfloat_setFreeze(tTalkboxLfloat* const v, int freeze) { v->freeze = freeze; } -void tTalkboxLfloat_setSampleRate(tTalkboxLfloat const v, Lfloat sr) +void tTalkboxLfloat_setSampleRate(tTalkboxLfloat* const v, Lfloat sr) { v->sampleRate = sr; tTalkboxLfloat_update(v); @@ -680,10 +680,10 @@ void tVocoder_init (tVocoder* const voc, LEAF* const leaf) tVocoder_initToPool(voc, &leaf->mempool); } -void tVocoder_initToPool (tVocoder* const voc, tMempool* const mp) +void tVocoder_initToPool (tVocoder** const voc, tMempool* const mp) { _tMempool* m = *mp; - _tVocoder* v = *voc = (_tVocoder*) mpool_alloc(sizeof(_tVocoder), m); + tVocoder* v = *voc = (tVocoder*) mpool_alloc(sizeof(tVocoder), m); v->mempool = m; LEAF* leaf = v->mempool->leaf; @@ -701,14 +701,14 @@ void tVocoder_initToPool (tVocoder* const voc, tMempool* const mp) tVocoder_update(*voc); } -void tVocoder_free (tVocoder* const voc) +void tVocoder_free (tVocoder** const voc) { - _tVocoder* v = *voc; + tVocoder* v = *voc; mpool_free((char*)v, v->mempool); } -void tVocoder_update (tVocoder const v) +void tVocoder_update (tVocoder* const v) { Lfloat tpofs = 6.2831853f * v->invSampleRate; @@ -790,7 +790,7 @@ void tVocoder_update (tVocoder const v) } } -Lfloat tVocoder_tick (tVocoder const v, Lfloat synth, Lfloat voice) +Lfloat tVocoder_tick (tVocoder* const v, Lfloat synth, Lfloat voice) { Lfloat a, b, o=0.0f, aa, bb, oo = v->kout, g = v->gain, ht = v->thru, hh = v->high, tmp; uint32_t i, k = v->kval, nb = v->nbnd; @@ -854,7 +854,7 @@ Lfloat tVocoder_tick (tVocoder const v, Lfloat synth, Lfloat voice) return o; } -void tVocoder_suspend (tVocoder const v) +void tVocoder_suspend (tVocoder* const v) { int32_t i, j; @@ -863,7 +863,7 @@ void tVocoder_suspend (tVocoder const v) v->kval = 0; } -void tVocoder_setSampleRate (tVocoder const v, Lfloat sr) +void tVocoder_setSampleRate (tVocoder* const v, Lfloat sr) { v->invSampleRate = 1.0f/sr; tVocoder_update(v); @@ -877,10 +877,10 @@ void tRosenbergGlottalPulse_init (tRosenbergGlottalPulse* const gp, LEAF* const tRosenbergGlottalPulse_initToPool(gp, &leaf->mempool); } -void tRosenbergGlottalPulse_initToPool (tRosenbergGlottalPulse* const gp, tMempool* const mp) +void tRosenbergGlottalPulse_initToPool (tRosenbergGlottalPulse** const gp, tMempool* const mp) { _tMempool* m = *mp; - _tRosenbergGlottalPulse* g = *gp = (_tRosenbergGlottalPulse*) mpool_alloc(sizeof(_tRosenbergGlottalPulse), m); + tRosenbergGlottalPulse* g = *gp = (tRosenbergGlottalPulse*) mpool_alloc(sizeof(tRosenbergGlottalPulse), m); g->mempool = m; LEAF* leaf = g->mempool->leaf; @@ -893,13 +893,13 @@ void tRosenbergGlottalPulse_initToPool (tRosenbergGlottalPulse* const gp, tMempo g->inc = 0.0f; } -void tRosenbergGlottalPulse_free (tRosenbergGlottalPulse* const gp) +void tRosenbergGlottalPulse_free (tRosenbergGlottalPulse** const gp) { - _tRosenbergGlottalPulse* g = *gp; + tRosenbergGlottalPulse* g = *gp; mpool_free((char*)g, g->mempool); } -Lfloat tRosenbergGlottalPulse_tick (tRosenbergGlottalPulse const g) +Lfloat tRosenbergGlottalPulse_tick (tRosenbergGlottalPulse* const g) { Lfloat output = 0.0f; @@ -926,7 +926,7 @@ Lfloat tRosenbergGlottalPulse_tick (tRosenbergGlottalPulse const g) } -Lfloat tRosenbergGlottalPulse_tickHQ (tRosenbergGlottalPulse const g) +Lfloat tRosenbergGlottalPulse_tickHQ (tRosenbergGlottalPulse* const g) { Lfloat output = 0.0f; @@ -952,33 +952,33 @@ Lfloat tRosenbergGlottalPulse_tickHQ (tRosenbergGlottalPulse const g return output; } -void tRosenbergGlottalPulse_setFreq (tRosenbergGlottalPulse const g, Lfloat freq) +void tRosenbergGlottalPulse_setFreq (tRosenbergGlottalPulse* const g, Lfloat freq) { g->freq = freq; g->inc = freq * g->invSampleRate; g->inc -= (int) g->inc; } -void tRosenbergGlottalPulse_setOpenLength (tRosenbergGlottalPulse const g, Lfloat openLength) +void tRosenbergGlottalPulse_setOpenLength (tRosenbergGlottalPulse* const g, Lfloat openLength) { g->openLength = openLength; g->invPulseLengthMinusOpenLength = 1.0f / (g->pulseLength - g->openLength); } -void tRosenbergGlottalPulse_setPulseLength (tRosenbergGlottalPulse const g, Lfloat pulseLength) +void tRosenbergGlottalPulse_setPulseLength (tRosenbergGlottalPulse* const g, Lfloat pulseLength) { g->pulseLength = pulseLength; g->invPulseLengthMinusOpenLength = 1.0f / (g->pulseLength - g->openLength); } -void tRosenbergGlottalPulse_setOpenLengthAndPulseLength (tRosenbergGlottalPulse const g, Lfloat openLength, Lfloat pulseLength) +void tRosenbergGlottalPulse_setOpenLengthAndPulseLength (tRosenbergGlottalPulse* const g, Lfloat openLength, Lfloat pulseLength) { g->openLength = openLength; g->pulseLength = pulseLength; g->invPulseLengthMinusOpenLength = 1.0f / (g->pulseLength - g->openLength); } -void tRosenbergGlottalPulse_setSampleRate(tRosenbergGlottalPulse const g, Lfloat sr) +void tRosenbergGlottalPulse_setSampleRate(tRosenbergGlottalPulse* const g, Lfloat sr) { g->invSampleRate = 1.0f/sr; tRosenbergGlottalPulse_setFreq(g, g->freq); @@ -992,9 +992,9 @@ void tRosenbergGlottalPulse_setSampleRate(tRosenbergGlottalPulse const g, Lflo /***************** static function declarations *******************************/ /******************************************************************************/ -static inline Lfloat read_sample(_tSOLAD *w, Lfloat Lfloatindex); -static void pitchdown(_tSOLAD *w, Lfloat *out); -static void pitchup(_tSOLAD *w, Lfloat *out); +static inline Lfloat read_sample(tSOLAD *w, Lfloat Lfloatindex); +static void pitchdown(tSOLAD *w, Lfloat *out); +static void pitchup(tSOLAD *w, Lfloat *out); /******************************************************************************/ /***************** public access functions ************************************/ @@ -1006,10 +1006,10 @@ void tSOLAD_init (tSOLAD* const wp, int loopSize, LEAF* const leaf) tSOLAD_initToPool(wp, loopSize, &leaf->mempool); } -void tSOLAD_initToPool (tSOLAD* const wp, int loopSize, tMempool* const mp) +void tSOLAD_initToPool (tSOLAD** const wp, int loopSize, tMempool* const mp) { _tMempool* m = *mp; - _tSOLAD* w = *wp = (_tSOLAD*) mpool_calloc(sizeof(_tSOLAD), m); + tSOLAD* w = *wp = (tSOLAD*) mpool_calloc(sizeof(tSOLAD), m); w->mempool = m; w->loopSize = loopSize; @@ -1026,9 +1026,9 @@ void tSOLAD_initToPool (tSOLAD* const wp, int loopSize, tMempool* const mp) tHighpass_initToPool(&w->hp, 20.0f, mp); } -void tSOLAD_free (tSOLAD* const wp) +void tSOLAD_free (tSOLAD** const wp) { - _tSOLAD* w = *wp; + tSOLAD* w = *wp; tAttackDetection_free(&w->ad); tHighpass_free(&w->hp); @@ -1037,7 +1037,7 @@ void tSOLAD_free (tSOLAD* const wp) } // send one block of input samples, receive one block of output samples -void tSOLAD_ioSamples(tSOLAD const w, Lfloat* in, Lfloat* out, int blocksize) +void tSOLAD_ioSamples(tSOLAD* const w, Lfloat* in, Lfloat* out, int blocksize) { int i = w->timeindex; int n = w->blocksize = blocksize; @@ -1067,7 +1067,7 @@ void tSOLAD_ioSamples(tSOLAD const w, Lfloat* in, Lfloat* out, int blocksize) } // set periodicity analysis data -void tSOLAD_setPeriod(tSOLAD const w, Lfloat period) +void tSOLAD_setPeriod(tSOLAD* const w, Lfloat period) { Lfloat maxPeriod = (Lfloat)((w->loopSize - w->blocksize) * 0.8f); if(period > maxPeriod) period = maxPeriod; @@ -1075,7 +1075,7 @@ void tSOLAD_setPeriod(tSOLAD const w, Lfloat period) } // set pitch factor between 0.25 and 4 -void tSOLAD_setPitchFactor(tSOLAD const w, Lfloat pitchfactor) +void tSOLAD_setPitchFactor(tSOLAD* const w, Lfloat pitchfactor) { if (pitchfactor <= 0.0f || pitchfactor > 1000.0f) { @@ -1085,7 +1085,7 @@ void tSOLAD_setPitchFactor(tSOLAD const w, Lfloat pitchfactor) } // force readpointer lag -void tSOLAD_setReadLag(tSOLAD const w, Lfloat readlag) +void tSOLAD_setReadLag(tSOLAD* const w, Lfloat readlag) { if(readlag < 0) readlag = 0; if(readlag < w->readlag) // do not jump backward, only forward @@ -1098,7 +1098,7 @@ void tSOLAD_setReadLag(tSOLAD const w, Lfloat readlag) } // reset state variables -void tSOLAD_resetState(tSOLAD const w) +void tSOLAD_resetState(tSOLAD* const w) { int n = w->loopSize; Lfloat *buf = w->delaybuf; @@ -1112,10 +1112,10 @@ void tSOLAD_resetState(tSOLAD const w) w->blocksize = INITPERIOD; } -void tSOLAD_setSampleRate(tSOLAD const w, Lfloat sr) +void tSOLAD_setSampleRate(tSOLAD* const w, Lfloat sr) { - tAttackDetection_setSampleRate(w->ad, sr); - tHighpass_setSampleRate(w->hp, sr); + tAttackDetection_setSampleRate(&w->ad, sr); + tHighpass_setSampleRate(&w->hp, sr); } /******************************************************************************/ @@ -1150,7 +1150,7 @@ void tSOLAD_setSampleRate(tSOLAD const w, Lfloat sr) */ -static void pitchdown(_tSOLAD* const w, Lfloat *out) +static void pitchdown(tSOLAD* const w, Lfloat *out) { int n = w->blocksize; Lfloat refindex = (Lfloat)(w->timeindex + w->loopSize); // no negative values! @@ -1268,7 +1268,7 @@ static void pitchdown(_tSOLAD* const w, Lfloat *out) possibility is done. A previous crossfade must be completed before a forward jump is allowed. */ -static void pitchup(_tSOLAD* const w, Lfloat *out) +static void pitchup(tSOLAD* const w, Lfloat *out) { int n = w->blocksize; Lfloat refindex = (Lfloat)(w->timeindex + w->loopSize); // no negative values @@ -1334,7 +1334,7 @@ static void pitchup(_tSOLAD* const w, Lfloat *out) } // read one sample from delay buffer, with linear interpolation -static inline Lfloat read_sample(_tSOLAD* const w, Lfloat Lfloatindex) +static inline Lfloat read_sample(tSOLAD* const w, Lfloat Lfloatindex) { int index = (int)Lfloatindex; Lfloat fraction = Lfloatindex - (Lfloat)index; @@ -1353,10 +1353,10 @@ void tPitchShift_init (tPitchShift* const psr, tDualPitchDetector* const dpd, in tPitchShift_initToPool(psr, dpd, bufSize, &leaf->mempool); } -void tPitchShift_initToPool (tPitchShift* const psr, tDualPitchDetector* const dpd, int bufSize, tMempool* const mp) +void tPitchShift_initToPool (tPitchShift** const psr, tDualPitchDetector* const dpd, int bufSize, tMempool* const mp) { _tMempool* m = *mp; - _tPitchShift* ps = *psr = (_tPitchShift*) mpool_alloc(sizeof(_tPitchShift), m); + tPitchShift* ps = *psr = (tPitchShift*) mpool_alloc(sizeof(tPitchShift), m); ps->mempool = m; LEAF* leaf = ps->mempool->leaf; @@ -1370,15 +1370,15 @@ void tPitchShift_initToPool (tPitchShift* const psr, tDualPitchDetector* const d tSOLAD_setPitchFactor(ps->sola, DEFPITCHRATIO); } -void tPitchShift_free (tPitchShift* const psr) +void tPitchShift_free (tPitchShift** const psr) { - _tPitchShift* ps = *psr; + tPitchShift* ps = *psr; tSOLAD_free(&ps->sola); mpool_free((char*)ps, ps->mempool); } -void tPitchShift_shiftBy (tPitchShift const ps, Lfloat factor, Lfloat* in, Lfloat* out) +void tPitchShift_shiftBy (tPitchShift* const ps, Lfloat factor, Lfloat* in, Lfloat* out) { Lfloat detected = tDualPitchDetector_getFrequency(ps->pd); Lfloat periodicity = tDualPitchDetector_getPeriodicity(ps->pd); @@ -1392,29 +1392,29 @@ void tPitchShift_shiftBy (tPitchShift const ps, Lfloat factor, Lfloat* in, Lfloa tSOLAD_ioSamples(ps->sola, in, out, ps->bufSize); } -void tPitchShift_shiftTo (tPitchShift const ps, Lfloat freq, Lfloat* in, Lfloat* out) +void tPitchShift_shiftTo (tPitchShift* const ps, Lfloat freq, Lfloat* in, Lfloat* out) { - Lfloat detected = tDualPitchDetector_getFrequency(ps->pd); - Lfloat periodicity = tDualPitchDetector_getPeriodicity(ps->pd); + Lfloat detected = tDualPitchDetector_getFrequency(&ps->pd); + Lfloat periodicity = tDualPitchDetector_getPeriodicity(&ps->pd); if (detected > 0.0f && periodicity > ps->pickiness) { Lfloat period = 1.0f / detected; Lfloat factor = freq * period; - tSOLAD_setPeriod(ps->sola, ps->sampleRate * period); - tSOLAD_setPitchFactor(ps->sola, factor); + tSOLAD_setPeriod(&ps->sola, ps->sampleRate * period); + tSOLAD_setPitchFactor(&ps->sola, factor); } - tSOLAD_ioSamples(ps->sola, in, out, ps->bufSize); + tSOLAD_ioSamples(&ps->sola, in, out, ps->bufSize); } -void tPitchShift_setPickiness (tPitchShift const ps, Lfloat p) +void tPitchShift_setPickiness (tPitchShift* const ps, Lfloat p) { ps->pickiness = p; } -void tPitchShift_setSampleRate(tPitchShift const ps, Lfloat sr) +void tPitchShift_setSampleRate(tPitchShift* const ps, Lfloat sr) { - tSOLAD_setSampleRate(ps->sola, sr); + tSOLAD_setSampleRate(&ps->sola, sr); } @@ -1427,10 +1427,10 @@ void tSimpleRetune_init (tSimpleRetune* const rt, int numVoices, Lfloat minInput tSimpleRetune_initToPool(rt, numVoices, minInputFreq, maxInputFreq, bufSize, &leaf->mempool); } -void tSimpleRetune_initToPool (tSimpleRetune* const rt, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, tMempool* const mp) +void tSimpleRetune_initToPool (tSimpleRetune** const rt, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, tMempool* const mp) { _tMempool* m = *mp; - _tSimpleRetune* r = *rt = (_tSimpleRetune*) mpool_calloc(sizeof(_tSimpleRetune), m); + tSimpleRetune* r = *rt = (tSimpleRetune*) mpool_calloc(sizeof(tSimpleRetune), m); r->mempool = *mp; r->bufSize = bufSize; @@ -1457,9 +1457,9 @@ void tSimpleRetune_initToPool (tSimpleRetune* const rt, int numVoices, Lfloat mi r->shiftFunction = &tPitchShift_shiftBy; } -void tSimpleRetune_free (tSimpleRetune* const rt) +void tSimpleRetune_free (tSimpleRetune** const rt) { - _tSimpleRetune* r = *rt; + tSimpleRetune* r = *rt; tDualPitchDetector_free(&r->dp); for (int i = 0; i < r->numVoices; ++i) @@ -1474,9 +1474,9 @@ void tSimpleRetune_free (tSimpleRetune* const rt) mpool_free((char*)r, r->mempool); } -Lfloat tSimpleRetune_tick(tSimpleRetune const r, Lfloat sample) +Lfloat tSimpleRetune_tick(tSimpleRetune* const r, Lfloat sample) { - tDualPitchDetector_tick(r->dp, sample); + tDualPitchDetector_tick(&r->dp, sample); r->inBuffer[r->index] = sample; Lfloat out = r->outBuffer[r->index]; @@ -1495,14 +1495,14 @@ Lfloat tSimpleRetune_tick(tSimpleRetune const r, Lfloat sample) return out; } -void tSimpleRetune_setMode (tSimpleRetune const r, int mode) +void tSimpleRetune_setMode (tSimpleRetune* const r, int mode) { if (mode > 0) r->shiftFunction = &tPitchShift_shiftTo; else r->shiftFunction = &tPitchShift_shiftBy; } //currently broken -void tSimpleRetune_setNumVoices(tSimpleRetune const r, int numVoices) +void tSimpleRetune_setNumVoices(tSimpleRetune* const r, int numVoices) { int bufSize = r->bufSize; Lfloat minInputFreq = r->minInputFreq; @@ -1514,15 +1514,15 @@ void tSimpleRetune_setNumVoices(tSimpleRetune const r, int numVoices) //tSimpleRetune_initToPool(r, minInputFreq, maxInputFreq, numVoices, bufSize, &mempool); } -void tSimpleRetune_setPickiness (tSimpleRetune const r, Lfloat p) +void tSimpleRetune_setPickiness (tSimpleRetune* const r, Lfloat p) { for (int i = 0; i < r->numVoices; ++i) { - tPitchShift_setPickiness(r->ps[i], p); + tPitchShift_setPickiness(&r->ps[i], p); } } -void tSimpleRetune_tuneVoices(tSimpleRetune const r, Lfloat* t) +void tSimpleRetune_tuneVoices(tSimpleRetune* const r, Lfloat* t) { for (int i = 0; i < r->numVoices; ++i) { @@ -1530,22 +1530,22 @@ void tSimpleRetune_tuneVoices(tSimpleRetune const r, Lfloat* t) } } -void tSimpleRetune_tuneVoice(tSimpleRetune const r, int voice, Lfloat t) +void tSimpleRetune_tuneVoice(tSimpleRetune* const r, int voice, Lfloat t) { r->shiftValues[voice] = t; } -Lfloat tSimpleRetune_getInputFrequency (tSimpleRetune const r) +Lfloat tSimpleRetune_getInputFrequency (tSimpleRetune* const r) { - return tDualPitchDetector_getFrequency(r->dp); + return tDualPitchDetector_getFrequency(&r->dp); } -void tSimpleRetune_setSampleRate (tSimpleRetune const r, Lfloat sr) +void tSimpleRetune_setSampleRate (tSimpleRetune* const r, Lfloat sr) { - tDualPitchDetector_setSampleRate(r->dp, sr); + tDualPitchDetector_setSampleRate(&r->dp, sr); for (int i = 0; i < r->numVoices; ++i) { - tPitchShift_setSampleRate(r->ps[i], sr); + tPitchShift_setSampleRate(&r->ps[i], sr); } } @@ -1558,10 +1558,10 @@ void tRetune_init(tRetune* const rt, int numVoices, Lfloat minInputFreq, Lfloat tRetune_initToPool(rt, numVoices, minInputFreq, maxInputFreq, bufSize, &leaf->mempool); } -void tRetune_initToPool (tRetune* const rt, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, tMempool* const mp) +void tRetune_initToPool (tRetune** const rt, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, tMempool* const mp) { _tMempool* m = *mp; - _tRetune* r = *rt = (_tRetune*) mpool_calloc(sizeof(_tRetune), m); + tRetune* r = *rt = (tRetune*) mpool_calloc(sizeof(tRetune), m); r->mempool = *mp; r->bufSize = bufSize; @@ -1590,9 +1590,9 @@ void tRetune_initToPool (tRetune* const rt, int numVoices, Lfloat minInputFreq, r->shiftFunction = &tPitchShift_shiftBy; } -void tRetune_free (tRetune* const rt) +void tRetune_free (tRetune** const rt) { - _tRetune* r = *rt; + tRetune* r = *rt; tDualPitchDetector_free(r->dp); for (int i = 0; i < r->numVoices; ++i) @@ -1609,7 +1609,7 @@ void tRetune_free (tRetune* const rt) mpool_free((char*)r, r->mempool); } -Lfloat* tRetune_tick(tRetune const r, Lfloat sample) +Lfloat* tRetune_tick(tRetune* const r, Lfloat sample) { tDualPitchDetector_tick(*r->dp, sample); @@ -1633,18 +1633,18 @@ Lfloat* tRetune_tick(tRetune const r, Lfloat sample) return r->output; } -void tRetune_setMode (tRetune const r, int mode) +void tRetune_setMode (tRetune* const r, int mode) { if (mode > 0) r->shiftFunction = &tPitchShift_shiftTo; else r->shiftFunction = &tPitchShift_shiftBy; } -void tRetune_setPickiness (tRetune const r, Lfloat p) +void tRetune_setPickiness (tRetune* const r, Lfloat p) { tDualPitchDetector_setPeriodicityThreshold(*r->dp, p); } //currently broken -void tRetune_setNumVoices(tRetune const r, int numVoices) +void tRetune_setNumVoices(tRetune* const r, int numVoices) { int bufSize = r->bufSize; Lfloat minInputFreq = r->minInputFreq; @@ -1656,7 +1656,7 @@ void tRetune_setNumVoices(tRetune const r, int numVoices) //tRetune_initToPool(r, minInputFreq, maxInputFreq, numVoices, bufSize, &mempool); } -void tRetune_tuneVoices(tRetune const r, Lfloat* t) +void tRetune_tuneVoices(tRetune* const r, Lfloat* t) { for (int i = 0; i < r->numVoices; ++i) { @@ -1664,7 +1664,7 @@ void tRetune_tuneVoices(tRetune const r, Lfloat* t) } } -void tRetune_tuneVoice(tRetune const r, int voice, Lfloat t) +void tRetune_tuneVoice(tRetune* const r, int voice, Lfloat t) { r->shiftValues[voice] = t; } @@ -1693,10 +1693,10 @@ void tFormantShifter_init (tFormantShifter* const fsr, int order, LEAF* const le tFormantShifter_initToPool(fsr, order, &leaf->mempool); } -void tFormantShifter_initToPool (tFormantShifter* const fsr, int order, tMempool* const mp) +void tFormantShifter_initToPool (tFormantShifter** const fsr, int order, tMempool* const mp) { _tMempool* m = *mp; - _tFormantShifter* fs = *fsr = (_tFormantShifter*) mpool_alloc(sizeof(_tFormantShifter), m); + tFormantShifter* fs = *fsr = (tFormantShifter*) mpool_alloc(sizeof(tFormantShifter), m); fs->mempool = m; LEAF* leaf = fs->mempool->leaf; @@ -1732,9 +1732,9 @@ void tFormantShifter_initToPool (tFormantShifter* const fsr, int order, tMempool tFeedbackLeveler_initToPool(&fs->fbl2, 0.8f, .005f, 0.125, 1, mp); } -void tFormantShifter_free (tFormantShifter* const fsr) +void tFormantShifter_free (tFormantShifter** const fsr) { - _tFormantShifter* fs = *fsr; + tFormantShifter* fs = *fsr; mpool_free((char*)fs->fk, fs->mempool); mpool_free((char*)fs->fb, fs->mempool); @@ -1752,15 +1752,15 @@ void tFormantShifter_free (tFormantShifter* const fsr) mpool_free((char*)fs, fs->mempool); } -Lfloat tFormantShifter_tick(tFormantShifter const fsr, Lfloat in) +Lfloat tFormantShifter_tick(tFormantShifter* const fsr, Lfloat in) { return tFormantShifter_add(fsr, tFormantShifter_remove(fsr, in)); } -Lfloat tFormantShifter_remove(tFormantShifter const fs, Lfloat in) +Lfloat tFormantShifter_remove(tFormantShifter* const fs, Lfloat in) { - in = tFeedbackLeveler_tick(fs->fbl1, in); - in = tHighpass_tick(fs->hp, in * fs->intensity); + in = tFeedbackLeveler_tick(&fs->fbl1, in); + in = tHighpass_tick(&fs->hp, in * fs->intensity); Lfloat fa, fb, fc, foma, falph, ford, flamb, tf, fk; @@ -1795,7 +1795,7 @@ Lfloat tFormantShifter_remove(tFormantShifter const fs, Lfloat in) return fa; } -Lfloat tFormantShifter_add(tFormantShifter const fs, Lfloat in) +Lfloat tFormantShifter_add(tFormantShifter* const fs, Lfloat in) { Lfloat fa, fb, fc, ford, flpa, flamb, tf, tf2, f0resp, f1resp, frlamb; ford = fs->ford; @@ -1885,18 +1885,18 @@ Lfloat tFormantShifter_add(tFormantShifter const fs, Lfloat in) // now tf is signal output // ...and we're done messing with formants //tf = tFeedbackLeveler_tick(&fs->fbl2, tf); - tf = tHighpass_tick(fs->hp2, tanhf(tf)); + tf = tHighpass_tick(&fs->hp2, tanhf(tf)); return tf * fs->invIntensity; } // 1.0f is no change, 2.0f is an octave up, 0.5f is an octave down -void tFormantShifter_setShiftFactor(tFormantShifter const fs, Lfloat shiftFactor) +void tFormantShifter_setShiftFactor(tFormantShifter* const fs, Lfloat shiftFactor) { fs->shiftFactor = shiftFactor; } -void tFormantShifter_setIntensity(tFormantShifter const fs, Lfloat intensity) +void tFormantShifter_setIntensity(tFormantShifter* const fs, Lfloat intensity) { fs->intensity = LEAF_clip(1.0f, intensity, 100.0f); @@ -1913,7 +1913,7 @@ void tFormantShifter_setIntensity(tFormantShifter const fs, Lfloat intensity) } } -void tFormantShifter_setSampleRate(tFormantShifter const fs, Lfloat sr) +void tFormantShifter_setSampleRate(tFormantShifter* const fs, Lfloat sr) { fs->sampleRate = sr; fs->invSampleRate = 1.0f/fs->sampleRate; @@ -1921,6 +1921,6 @@ void tFormantShifter_setSampleRate(tFormantShifter const fs, Lfloat sr) fs->flamb = -(0.8517f*sqrtf(atanf(0.06583f * fs->sampleRate)) - 0.1916f); fs->flpa = powf(0.001f, 10.0f * fs->invSampleRate); fs->fmutealph = powf(0.001f, 1.0f * fs->invSampleRate); - tHighpass_setSampleRate(fs->hp, fs->sampleRate); - tHighpass_setSampleRate(fs->hp2, fs->sampleRate); + tHighpass_setSampleRate(&fs->hp, fs->sampleRate); + tHighpass_setSampleRate(&fs->hp2, fs->sampleRate); } diff --git a/leaf/Src/leaf-electrical.c b/leaf/Src/leaf-electrical.c index 7fbae6e..f21acd9 100644 --- a/leaf/Src/leaf-electrical.c +++ b/leaf/Src/leaf-electrical.c @@ -49,7 +49,7 @@ static Lfloat get_reflected_wave_for_diode_pair (tWDF const n, Lfloat input, Lfl static void wdf_init(tWDF* const wdf, WDFComponentType type, Lfloat value, tWDF* const rL, tWDF* const rR) { - _tWDF* r = *wdf; + tWDF* r = &*wdf; LEAF* leaf = r->mempool->leaf; r->type = type; @@ -172,29 +172,29 @@ void tWDF_init(tWDF* const wdf, WDFComponentType type, Lfloat value, tWDF* const tWDF_initToPool(wdf, type, value, rL, rR, &leaf->mempool); } -void tWDF_initToPool(tWDF* const wdf, WDFComponentType type, Lfloat value, tWDF* const rL, tWDF* const rR, tMempool* const mp) +void tWDF_initToPool(tWDF** const wdf, WDFComponentType type, Lfloat value, tWDF* const rL, tWDF* const rR, tMempool* const mp) { _tMempool* m = *mp; - *wdf = (_tWDF*) mpool_alloc(sizeof(_tWDF), m); + *wdf = (tWDF*) mpool_alloc(sizeof(tWDF), m); wdf_init(wdf, type, value, rL, rR); } -void tWDF_free (tWDF* const wdf) +void tWDF_free (tWDF** const wdf) { - _tWDF* r = *wdf; + tWDF* r = *wdf; mpool_free((char*)r, r->mempool); } -Lfloat tWDF_tick(tWDF const r, Lfloat sample, tWDF* const outputPoint, uint8_t paramsChanged) +Lfloat tWDF_tick(tWDF* const r, Lfloat sample, tWDF* const outputPoint, uint8_t paramsChanged) { tWDF* child; if (r->child_left != NULL) child = &r->child_left; else child = &r->child_right; //step 0 : update port resistances if something changed - if (paramsChanged) tWDF_getPortResistance(r); + if (paramsChanged) tWDF_getPortResistance(*r); //step 1 : set inputs to what they should be Lfloat input = sample; @@ -203,7 +203,7 @@ Lfloat tWDF_tick(tWDF const r, Lfloat sample, tWDF* const outputPoint, uint8_t p r->incident_wave_up = tWDF_getReflectedWaveUp(*child, input); //step 3 : do root scattering computation - r->reflected_wave_up = tWDF_getReflectedWaveDown(r, input, r->incident_wave_up); + r->reflected_wave_up = tWDF_getReflectedWaveDown(*r, input, r->incident_wave_up); //step 4 : propogate waves down the tree tWDF_setIncidentWave(*child, r->reflected_wave_up, input); @@ -212,12 +212,12 @@ Lfloat tWDF_tick(tWDF const r, Lfloat sample, tWDF* const outputPoint, uint8_t p return tWDF_getVoltage(*outputPoint); } -void tWDF_setValue(tWDF const r, Lfloat value) +void tWDF_setValue(tWDF* const r, Lfloat value) { r->value = value; } -void tWDF_setSampleRate(tWDF const r, Lfloat sample_rate) +void tWDF_setSampleRate(tWDF* const r, Lfloat sample_rate) { r->sample_rate = sample_rate; if (r->type == Capacitor) @@ -232,38 +232,38 @@ void tWDF_setSampleRate(tWDF const r, Lfloat sample_rate) } } -uint8_t tWDF_isLeaf(tWDF const r) +uint8_t tWDF_isLeaf(tWDF* const r) { if (r->child_left == NULL && r->child_right == NULL) return 1; return 0; } -Lfloat tWDF_getPortResistance(tWDF const r) +Lfloat tWDF_getPortResistance(tWDF* const r) { - return r->get_port_resistance(r); + return r->get_port_resistance(*r); } -void tWDF_setIncidentWave(tWDF const r, Lfloat incident_wave, Lfloat input) +void tWDF_setIncidentWave(tWDF* const r, Lfloat incident_wave, Lfloat input) { - r->set_incident_wave(r, incident_wave, input); + r->set_incident_wave(*r, incident_wave, input); } -Lfloat tWDF_getReflectedWaveUp(tWDF const r, Lfloat input) +Lfloat tWDF_getReflectedWaveUp(tWDF* const r, Lfloat input) { - return r->get_reflected_wave_up(r, input); + return r->get_reflected_wave_up(*r, input); } -Lfloat tWDF_getReflectedWaveDown(tWDF const r, Lfloat input, Lfloat incident_wave) +Lfloat tWDF_getReflectedWaveDown(tWDF* const r, Lfloat input, Lfloat incident_wave) { - return r->get_reflected_wave_down(r, input, incident_wave); + return r->get_reflected_wave_down(*r, input, incident_wave); } -Lfloat tWDF_getVoltage(tWDF const r) +Lfloat tWDF_getVoltage(tWDF* const r) { return ((r->incident_wave_up * 0.5f) + (r->reflected_wave_up * 0.5f)); } -Lfloat tWDF_getCurrent(tWDF const r) +Lfloat tWDF_getCurrent(tWDF* const r) { return (((r->incident_wave_up * 0.5f) - (r->reflected_wave_up * 0.5f)) * r->port_conductance_up); } @@ -272,7 +272,7 @@ Lfloat tWDF_getCurrent(tWDF const r) //=================================================================== //============ Get and Calculate Port Resistances =================== -static Lfloat get_port_resistance_for_resistor(tWDF const r) +static Lfloat get_port_resistance_for_resistor(tWDF* const r) { r->port_resistance_up = r->value; r->port_conductance_up = 1.0f / r->value; @@ -280,7 +280,7 @@ static Lfloat get_port_resistance_for_resistor(tWDF const r) return r->port_resistance_up; } -static Lfloat get_port_resistance_for_capacitor(tWDF const r) +static Lfloat get_port_resistance_for_capacitor(tWDF* const r) { r->port_conductance_up = r->sample_rate * 2.0f * r->value; //based on trapezoidal discretization r->port_resistance_up = (1.0f / r->port_conductance_up); @@ -288,7 +288,7 @@ static Lfloat get_port_resistance_for_capacitor(tWDF const r) return r->port_resistance_up; } -static Lfloat get_port_resistance_for_inductor(tWDF const r) +static Lfloat get_port_resistance_for_inductor(tWDF* const r) { r->port_resistance_up = r->sample_rate * 2.0f * r->value; //based on trapezoidal discretization r->port_conductance_up = (1.0f / r->port_resistance_up); @@ -296,7 +296,7 @@ static Lfloat get_port_resistance_for_inductor(tWDF const r) return r->port_resistance_up; } -static Lfloat get_port_resistance_for_resistive(tWDF const r) +static Lfloat get_port_resistance_for_resistive(tWDF* const r) { r->port_resistance_up = r->value; r->port_conductance_up = 1.0f / r->port_resistance_up; @@ -304,7 +304,7 @@ static Lfloat get_port_resistance_for_resistive(tWDF const r) return r->port_resistance_up; } -static Lfloat get_port_resistance_for_inverter(tWDF const r) +static Lfloat get_port_resistance_for_inverter(tWDF* const r) { r->port_resistance_up = tWDF_getPortResistance(r->child_left); r->port_conductance_up = 1.0f / r->port_resistance_up; @@ -312,7 +312,7 @@ static Lfloat get_port_resistance_for_inverter(tWDF const r) return r->port_resistance_up; } -static Lfloat get_port_resistance_for_series(tWDF const r) +static Lfloat get_port_resistance_for_series(tWDF* const r) { r->port_resistance_left = tWDF_getPortResistance(r->child_left); r->port_resistance_right = tWDF_getPortResistance(r->child_right); @@ -325,7 +325,7 @@ static Lfloat get_port_resistance_for_series(tWDF const r) return r->port_resistance_up; } -static Lfloat get_port_resistance_for_parallel(tWDF const r) +static Lfloat get_port_resistance_for_parallel(tWDF* const r) { r->port_resistance_left = tWDF_getPortResistance(r->child_left); r->port_resistance_right = tWDF_getPortResistance(r->child_right); @@ -338,7 +338,7 @@ static Lfloat get_port_resistance_for_parallel(tWDF const r) return r->port_resistance_up; } -static Lfloat get_port_resistance_for_root(tWDF const r) +static Lfloat get_port_resistance_for_root(tWDF* const r) { tWDF child; if (r->child_left != NULL) child = r->child_left; @@ -353,23 +353,23 @@ static Lfloat get_port_resistance_for_root(tWDF const r) //=================================================================== //================ Set Incident Waves =============================== -static void set_incident_wave_for_leaf(tWDF const r, Lfloat incident_wave, Lfloat input) +static void set_incident_wave_for_leaf(tWDF* const r, Lfloat incident_wave, Lfloat input) { r->incident_wave_up = incident_wave; } -static void set_incident_wave_for_leaf_inverted(tWDF const r, Lfloat incident_wave, Lfloat input) +static void set_incident_wave_for_leaf_inverted(tWDF* const r, Lfloat incident_wave, Lfloat input) { r->incident_wave_up = -1.0f * incident_wave; } -static void set_incident_wave_for_inverter(tWDF const r, Lfloat incident_wave, Lfloat input) +static void set_incident_wave_for_inverter(tWDF* const r, Lfloat incident_wave, Lfloat input) { r->incident_wave_up = incident_wave; tWDF_setIncidentWave(r->child_left, -1.0f * incident_wave, input); } -static void set_incident_wave_for_series(tWDF const r, Lfloat incident_wave, Lfloat input) +static void set_incident_wave_for_series(tWDF* const r, Lfloat incident_wave, Lfloat input) { r->incident_wave_up = incident_wave; Lfloat gamma_left = r->port_resistance_left * r->gamma_zero; @@ -386,7 +386,7 @@ static void set_incident_wave_for_series(tWDF const r, Lfloat incident_wave, Lfl } -static void set_incident_wave_for_parallel(tWDF const r, Lfloat incident_wave, Lfloat input) +static void set_incident_wave_for_parallel(tWDF* const r, Lfloat incident_wave, Lfloat input) { r->incident_wave_up = incident_wave; Lfloat gamma_left = r->port_conductance_left * r->gamma_zero; @@ -402,38 +402,38 @@ static void set_incident_wave_for_parallel(tWDF const r, Lfloat incident_wave, L //=================================================================== //================ Get Reflected Waves ============================== -static Lfloat get_reflected_wave_for_resistor(tWDF const r, Lfloat input) +static Lfloat get_reflected_wave_for_resistor(tWDF* const r, Lfloat input) { r->reflected_wave_up = 0.0f; return r->reflected_wave_up; } -static Lfloat get_reflected_wave_for_capacitor(tWDF const r, Lfloat input) +static Lfloat get_reflected_wave_for_capacitor(tWDF* const r, Lfloat input) { r->reflected_wave_up = r->incident_wave_up; return r->reflected_wave_up; } -static Lfloat get_reflected_wave_for_resistive(tWDF const r, Lfloat input) +static Lfloat get_reflected_wave_for_resistive(tWDF* const r, Lfloat input) { r->reflected_wave_up = input; return r->reflected_wave_up; } -static Lfloat get_reflected_wave_for_inverter(tWDF const r, Lfloat input) +static Lfloat get_reflected_wave_for_inverter(tWDF* const r, Lfloat input) { r->reflected_wave_up = -1.0f * tWDF_getReflectedWaveUp(r->child_left, input); return r->reflected_wave_up; } -static Lfloat get_reflected_wave_for_series(tWDF const r, Lfloat input) +static Lfloat get_reflected_wave_for_series(tWDF* const r, Lfloat input) { //-( downPorts[0]->a + downPorts[1]->a ); r->reflected_wave_up = (-1.0f * (tWDF_getReflectedWaveUp(r->child_left, input) + tWDF_getReflectedWaveUp(r->child_right, input))); return r->reflected_wave_up; } -static Lfloat get_reflected_wave_for_parallel(tWDF const r, Lfloat input) +static Lfloat get_reflected_wave_for_parallel(tWDF* const r, Lfloat input) { Lfloat gamma_left = r->port_conductance_left * r->gamma_zero; Lfloat gamma_right = r->port_conductance_right * r->gamma_zero; @@ -483,14 +483,14 @@ static Lfloat lambertW(Lfloat a, Lfloat r, Lfloat I, Lfloat iVT) #define Is_DIODE 2.52e-9f #define VT_DIODE 0.02585f -static Lfloat get_reflected_wave_for_diode(tWDF const n, Lfloat input, Lfloat incident_wave) +static Lfloat get_reflected_wave_for_diode(tWDF* const n, Lfloat input, Lfloat incident_wave) { Lfloat a = incident_wave; Lfloat r = n->port_resistance_up; return a + 2.0f*r*Is_DIODE - 2.0f*VT_DIODE*lambertW(a, r, Is_DIODE, 1.0f/VT_DIODE); } -static Lfloat get_reflected_wave_for_diode_pair(tWDF const n, Lfloat input, Lfloat incident_wave) +static Lfloat get_reflected_wave_for_diode_pair(tWDF* const n, Lfloat input, Lfloat incident_wave) { Lfloat a = incident_wave; Lfloat sgn = 0.0f; diff --git a/leaf/Src/leaf-envelopes.c b/leaf/Src/leaf-envelopes.c index fdd07f1..50f61da 100644 --- a/leaf/Src/leaf-envelopes.c +++ b/leaf/Src/leaf-envelopes.c @@ -31,10 +31,10 @@ void tEnvelope_init (tEnvelope *const envlp, Lfloat attack, Lfloat decay, int lo tEnvelope_initToPool(envlp, attack, decay, loop, &leaf->mempool); } -void tEnvelope_initToPool (tEnvelope *const envlp, Lfloat attack, Lfloat decay, int loop, tMempool *const mp) +void tEnvelope_initToPool (tEnvelope** const envlp, Lfloat attack, Lfloat decay, int loop, tMempool *const mp) { _tMempool *m = *mp; - _tEnvelope *env = *envlp = (_tEnvelope *) mpool_alloc(sizeof(_tEnvelope), m); + tEnvelope *env = *envlp = (tEnvelope *) mpool_alloc(sizeof(tEnvelope), m); env->mempool = m; env->exp_buff = __leaf_table_exp_decay; @@ -73,13 +73,13 @@ void tEnvelope_initToPool (tEnvelope *const envlp, Lfloat attack, Lfloat decay, env->rampInc = env->inc_buff[rampIndex]; } -void tEnvelope_free (tEnvelope *const envlp) +void tEnvelope_free (tEnvelope** const envlp) { - _tEnvelope *env = *envlp; + tEnvelope *env = *envlp; mpool_free((char *) env, env->mempool); } -void tEnvelope_setAttack (tEnvelope const env, Lfloat attack) +void tEnvelope_setAttack (tEnvelope* const env, Lfloat attack) { int32_t attackIndex; @@ -94,7 +94,7 @@ void tEnvelope_setAttack (tEnvelope const env, Lfloat attack) env->attackInc = env->inc_buff[attackIndex]; } -void tEnvelope_setDecay (tEnvelope const env, Lfloat decay) +void tEnvelope_setDecay (tEnvelope* const env, Lfloat decay) { int32_t decayIndex; @@ -109,12 +109,12 @@ void tEnvelope_setDecay (tEnvelope const env, Lfloat decay) env->decayInc = env->inc_buff[decayIndex]; } -void tEnvelope_loop (tEnvelope const env, int loop) +void tEnvelope_loop (tEnvelope* const env, int loop) { env->loop = loop; } -void tEnvelope_on (tEnvelope const env, Lfloat velocity) +void tEnvelope_on (tEnvelope* const env, Lfloat velocity) { if (env->inAttack || env->inDecay) // In case envelope retriggered while it is still happening. { @@ -133,7 +133,7 @@ void tEnvelope_on (tEnvelope const env, Lfloat velocity) env->gain = velocity; } -Lfloat tEnvelope_tick (tEnvelope const env) +Lfloat tEnvelope_tick (tEnvelope* const env) { if (env->inRamp) { if (env->rampPhase > UINT16_MAX) { @@ -202,11 +202,11 @@ void tADSR_init (tADSR *const adsrenv, Lfloat attack, Lfloat decay, Lfloat susta tADSR_initToPool(adsrenv, attack, decay, sustain, release, &leaf->mempool); } -void tADSR_initToPool (tADSR *const adsrenv, Lfloat attack, Lfloat decay, +void tADSR_initToPool (tADSR** const adsrenv, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, tMempool *const mp) { _tMempool *m = *mp; - _tADSR *adsr = *adsrenv = (_tADSR *) mpool_alloc(sizeof(_tADSR), m); + tADSR *adsr = *adsrenv = (tADSR *) mpool_alloc(sizeof(tADSR), m); adsr->mempool = m; adsr->exp_buff = __leaf_table_exp_decay; @@ -270,13 +270,13 @@ void tADSR_initToPool (tADSR *const adsrenv, Lfloat attack, Lfloat decay, adsr->invSampleRate = adsr->mempool->leaf->invSampleRate; } -void tADSR_free (tADSR *const adsrenv) +void tADSR_free (tADSR** const adsrenv) { - _tADSR *adsr = *adsrenv; + tADSR *adsr = *adsrenv; mpool_free((char *) adsr, adsr->mempool); } -void tADSR_setAttack (tADSR const adsr, Lfloat attack) +void tADSR_setAttack (tADSR* const adsr, Lfloat attack) { int32_t attackIndex; @@ -293,7 +293,7 @@ void tADSR_setAttack (tADSR const adsr, Lfloat attack) adsr->attackInc = adsr->inc_buff[attackIndex] * (44100.f * adsr->invSampleRate); } -void tADSR_setDecay (tADSR const adsr, Lfloat decay) +void tADSR_setDecay (tADSR* const adsr, Lfloat decay) { int32_t decayIndex; @@ -310,14 +310,14 @@ void tADSR_setDecay (tADSR const adsr, Lfloat decay) adsr->decayInc = adsr->inc_buff[decayIndex] * (44100.f * adsr->invSampleRate); } -void tADSR_setSustain (tADSR const adsr, Lfloat sustain) +void tADSR_setSustain (tADSR* const adsr, Lfloat sustain) { if (sustain > 1.0f) adsr->sustain = 1.0f; else if (sustain < 0.0f) adsr->sustain = 0.0f; else adsr->sustain = sustain; } -void tADSR_setRelease (tADSR const adsr, Lfloat release) +void tADSR_setRelease (tADSR* const adsr, Lfloat release) { int32_t releaseIndex; @@ -335,13 +335,13 @@ void tADSR_setRelease (tADSR const adsr, Lfloat release) } // 0.999999 is slow leak, 0.9 is fast leak -void tADSR_setLeakFactor (tADSR const adsr, Lfloat leakFactor) +void tADSR_setLeakFactor (tADSR* const adsr, Lfloat leakFactor) { adsr->baseLeakFactor = leakFactor; adsr->leakFactor = powf(leakFactor, 44100.0f * adsr->invSampleRate); } -void tADSR_on (tADSR const adsr, Lfloat velocity) +void tADSR_on (tADSR* const adsr, Lfloat velocity) { if ((adsr->inAttack || adsr->inDecay) || (adsr->inSustain || adsr->inRelease)) // In case ADSR retriggered while it is still happening. @@ -363,7 +363,7 @@ void tADSR_on (tADSR const adsr, Lfloat velocity) adsr->gain = velocity; } -void tADSR_off (tADSR const adsr) +void tADSR_off (tADSR* const adsr) { if (adsr->inRelease) return; @@ -375,7 +375,7 @@ void tADSR_off (tADSR const adsr) adsr->releasePeak = adsr->next; } -Lfloat tADSR_tick(tADSR const adsr) +Lfloat tADSR_tick(tADSR* const adsr) { if (adsr->inRamp) { if (adsr->rampPhase > UINT16_MAX) { @@ -446,7 +446,7 @@ Lfloat tADSR_tick(tADSR const adsr) return adsr->next; } -void tADSR_setSampleRate (tADSR const adsr, Lfloat sr) +void tADSR_setSampleRate (tADSR* const adsr, Lfloat sr) { adsr->invSampleRate = 1.0f / sr; @@ -474,12 +474,12 @@ void tADSRS_init (tADSRS *const adsrenv, Lfloat attack, Lfloat decay, Lfloat sus tADSRS_initToPool(adsrenv, attack, decay, sustain, release, &leaf->mempool); } -void tADSRS_initToPool (tADSRS *const adsrenv, Lfloat attack, Lfloat decay, +void tADSRS_initToPool (tADSRS** const adsrenv, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, tMempool *const mp) { _tMempool *m = *mp; - _tADSRS *adsr = *adsrenv = (_tADSRS *) mpool_alloc(sizeof(_tADSRS), m); + tADSRS *adsr = *adsrenv = (tADSRS *) mpool_alloc(sizeof(tADSRS), m); adsr->mempool = m; LEAF *leaf = adsr->mempool->leaf; @@ -519,12 +519,12 @@ void tADSRS_initToPool (tADSRS *const adsrenv, Lfloat attack, Lfloat decay, adsr->invSampleRate = leaf->invSampleRate; } -void tADSRS_free(tADSRS *const adsrenv) { - _tADSRS *adsr = *adsrenv; +void tADSRS_free(tADSRS** const adsrenv) { + tADSRS *adsr = *adsrenv; mpool_free((char *) adsr, adsr->mempool); } -void tADSRS_setAttack(tADSRS const adsr, Lfloat attack) +void tADSRS_setAttack(tADSRS* const adsr, Lfloat attack) { adsr->attack = attack; adsr->attackRate = attack * adsr->sampleRateInMs; @@ -532,7 +532,7 @@ void tADSRS_setAttack(tADSRS const adsr, Lfloat attack) adsr->attackBase = (1.0f + adsr->targetRatioA) * (1.0f - adsr->attackCoef); } -void tADSRS_setDecay (tADSRS const adsr, Lfloat decay) +void tADSRS_setDecay (tADSRS* const adsr, Lfloat decay) { adsr->decay = decay; adsr->decayRate = decay * adsr->sampleRateInMs; @@ -540,13 +540,13 @@ void tADSRS_setDecay (tADSRS const adsr, Lfloat decay) adsr->decayBase = (adsr->sustainLevel - adsr->targetRatioDR) * (1.0f - adsr->decayCoef); } -void tADSRS_setSustain (tADSRS const adsr, Lfloat sustain) +void tADSRS_setSustain (tADSRS* const adsr, Lfloat sustain) { adsr->sustainLevel = sustain; adsr->decayBase = (adsr->sustainLevel - adsr->targetRatioDR) * (1.0f - adsr->decayCoef); } -void tADSRS_setRelease(tADSRS const adsr, Lfloat release) +void tADSRS_setRelease(tADSRS* const adsr, Lfloat release) { adsr->release = release; adsr->releaseRate = release * adsr->sampleRateInMs; @@ -555,26 +555,26 @@ void tADSRS_setRelease(tADSRS const adsr, Lfloat release) } // 0.999999 is slow leak, 0.9 is fast leak -void tADSRS_setLeakFactor (tADSRS const adsr, Lfloat leakFactor) +void tADSRS_setLeakFactor (tADSRS* const adsr, Lfloat leakFactor) { adsr->baseLeakFactor = leakFactor; adsr->leakFactor = powf(leakFactor, 44100.0f * adsr->invSampleRate); } -void tADSRS_on (tADSRS const adsr, Lfloat velocity) +void tADSRS_on (tADSRS* const adsr, Lfloat velocity) { adsr->state = env_attack; adsr->targetGainSquared = velocity * velocity; } -void tADSRS_off (tADSRS const adsr) +void tADSRS_off (tADSRS* const adsr) { if (adsr->state != env_idle) { adsr->state = env_release; } } -Lfloat tADSRS_tick (tADSRS const adsr) +Lfloat tADSRS_tick (tADSRS* const adsr) { switch (adsr->state) { case env_idle: @@ -610,7 +610,7 @@ Lfloat tADSRS_tick (tADSRS const adsr) return adsr->output * adsr->gain; } -void tADSRS_setSampleRate (tADSRS const adsr, Lfloat sr) +void tADSRS_setSampleRate (tADSRS* const adsr, Lfloat sr) { adsr->sampleRate = sr; adsr->sampleRateInMs = adsr->sampleRate * 0.001f; @@ -636,11 +636,11 @@ void tADSRT_init (tADSRT *const adsrenv, Lfloat attack, Lfloat decay, Lfloat sus //initialize with an exponential function that decays -- i.e. a call to LEAF_generate_exp(expBuffer, 0.001f, 0.0f, 1.0f, -0.0008f, EXP_BUFFER_SIZE); //times are in ms void -tADSRT_initToPool(tADSRT *const adsrenv, Lfloat attack, Lfloat decay, Lfloat sustain, +tADSRT_initToPool(tADSRT** const adsrenv, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, Lfloat *expBuffer, int bufferSize, tMempool *const mp) { _tMempool *m = *mp; - _tADSRT *adsr = *adsrenv = (_tADSRT *) mpool_alloc(sizeof(_tADSRT), m); + tADSRT *adsr = *adsrenv = (tADSRT *) mpool_alloc(sizeof(tADSRT), m); adsr->mempool = m; LEAF *leaf = adsr->mempool->leaf; @@ -685,9 +685,9 @@ tADSRT_initToPool(tADSRT *const adsrenv, Lfloat attack, Lfloat decay, Lfloat sus adsr->invSampleRate = leaf->invSampleRate; } -void tADSRT_free (tADSRT *const adsrenv) +void tADSRT_free (tADSRT** const adsrenv) { - _tADSRT *adsr = *adsrenv; + tADSRT *adsr = *adsrenv; mpool_free((char *) adsr, adsr->mempool); } @@ -695,7 +695,7 @@ void tADSRT_free (tADSRT *const adsrenv) void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tADSRT_setAttack(tADSRT* const adsrenv, Lfloat attack) #else -void tADSRT_setAttack (tADSRT const adsr, Lfloat attack) +void tADSRT_setAttack (tADSRT* const adsr, Lfloat attack) #endif { if (attack < 0.0f) { @@ -709,7 +709,7 @@ void tADSRT_setAttack (tADSRT const adsr, Lfloat attack) void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tADSRT_setDecay(tADSRT* const adsrenv, Lfloat decay) #else -void tADSRT_setDecay (tADSRT const adsr, Lfloat decay) +void tADSRT_setDecay (tADSRT* const adsr, Lfloat decay) #endif { if (decay < 0.0f) { @@ -723,7 +723,7 @@ void tADSRT_setDecay (tADSRT const adsr, Lfloat decay) void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tADSRT_setSustain(tADSRT* const adsrenv, Lfloat sustain) #else -void tADSRT_setSustain (tADSRT const adsr, Lfloat sustain) +void tADSRT_setSustain (tADSRT* const adsr, Lfloat sustain) #endif { if (sustain > 1.0f) adsr->sustain = 1.0f; @@ -735,7 +735,7 @@ void tADSRT_setSustain (tADSRT const adsr, Lfloat sustain) void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tADSRT_setRelease(tADSRT* const adsrenv, Lfloat release) #else -void tADSRT_setRelease (tADSRT const adsr, Lfloat release) +void tADSRT_setRelease (tADSRT* const adsr, Lfloat release) #endif { @@ -751,7 +751,7 @@ void tADSRT_setRelease (tADSRT const adsr, Lfloat release) void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tADSRT_setLeakFactor(tADSRT* const adsrenv, Lfloat leakFactor) #else -void tADSRT_setLeakFactor (tADSRT const adsr, Lfloat leakFactor) +void tADSRT_setLeakFactor (tADSRT* const adsr, Lfloat leakFactor) #endif { adsr->baseLeakFactor = leakFactor; @@ -762,7 +762,7 @@ void tADSRT_setLeakFactor (tADSRT const adsr, Lfloat leakFactor) void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tADSRT_on(tADSRT* const adsrenv, Lfloat velocity) #else -void tADSRT_on (tADSRT const adsr, Lfloat velocity) +void tADSRT_on (tADSRT* const adsr, Lfloat velocity) #endif { if (adsr->whichStage != env_idle) // In case ADSR retriggered while it is still happening. @@ -785,7 +785,7 @@ void tADSRT_on (tADSRT const adsr, Lfloat velocity) void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tADSRT_off(tADSRT* const adsrenv) #else -void tADSRT_off (tADSRT const adsr) +void tADSRT_off (tADSRT* const adsr) #endif { if (adsr->whichStage == env_idle) { @@ -800,7 +800,7 @@ void tADSRT_off (tADSRT const adsr) void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tADSRT_clear(tADSRT* const adsrenv) #else -void tADSRT_clear (tADSRT const adsr) +void tADSRT_clear (tADSRT* const adsr) #endif { adsr->whichStage = env_idle; @@ -811,7 +811,7 @@ void tADSRT_clear (tADSRT const adsr) Lfloat __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tADSRT_tick(tADSRT* const adsrenv) #else -Lfloat tADSRT_tick (tADSRT const adsr) +Lfloat tADSRT_tick (tADSRT* const adsr) #endif { switch (adsr->whichStage) { @@ -919,7 +919,7 @@ Lfloat tADSRT_tick (tADSRT const adsr) Lfloat __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tADSRT_tickNoInterp(tADSRT* const adsrenv) #else -Lfloat tADSRT_tickNoInterp (tADSRT const adsr) +Lfloat tADSRT_tickNoInterp (tADSRT* const adsr) #endif { switch (adsr->whichStage) { @@ -992,7 +992,7 @@ Lfloat tADSRT_tickNoInterp (tADSRT const adsr) void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tADSRT_setSampleRate(tADSRT* const adsrenv, Lfloat sr) #else -void tADSRT_setSampleRate (tADSRT const adsr, Lfloat sr) +void tADSRT_setSampleRate (tADSRT* const adsr, Lfloat sr) #endif { adsr->sampleRate = sr; @@ -1007,16 +1007,16 @@ void tADSRT_setSampleRate (tADSRT const adsr, Lfloat sr) /////----------------- /* Ramp */ -void tRamp_init (tRamp *const r, Lfloat time, int samples_per_tick, LEAF *const leaf) +void tRamp_init (tRamp* const r, Lfloat time, int samples_per_tick, LEAF *const leaf) { tRamp_initToPool(r, time, samples_per_tick, &leaf->mempool); } -void tRamp_initToPool (tRamp *const r, Lfloat time, int samples_per_tick, +void tRamp_initToPool (tRamp** const r, Lfloat time, int samples_per_tick, tMempool *const mp) { _tMempool *m = *mp; - _tRamp *ramp = *r = (_tRamp *) mpool_alloc(sizeof(_tRamp), m); + tRamp *ramp = *r = (tRamp *) mpool_alloc(sizeof(tRamp), m); ramp->mempool = m; LEAF *leaf = ramp->mempool->leaf; @@ -1037,13 +1037,13 @@ void tRamp_initToPool (tRamp *const r, Lfloat time, int samples_per_tick, ramp->inc = (ramp->dest - ramp->curr) * ramp->factor; } -void tRamp_free (tRamp *const r) +void tRamp_free (tRamp** const r) { - _tRamp *ramp = *r; + tRamp *ramp = *r; mpool_free((char *) ramp, ramp->mempool); } -void tRamp_setTime (tRamp const r, Lfloat time) +void tRamp_setTime (tRamp* const r, Lfloat time) { if (time < r->minimum_time) { r->time = r->minimum_time; @@ -1055,19 +1055,19 @@ void tRamp_setTime (tRamp const r, Lfloat time) } -void tRamp_setDest (tRamp const r, Lfloat dest) +void tRamp_setDest (tRamp* const r, Lfloat dest) { r->dest = dest; r->inc = (r->dest - r->curr) * r->factor; } -void tRamp_setVal (tRamp const r, Lfloat val) +void tRamp_setVal (tRamp* const r, Lfloat val) { r->curr = val; r->inc = (r->dest - r->curr) * r->factor; } -Lfloat tRamp_tick (tRamp const r) +Lfloat tRamp_tick (tRamp* const r) { r->curr += r->inc; @@ -1079,12 +1079,12 @@ Lfloat tRamp_tick (tRamp const r) return r->curr; } -Lfloat tRamp_sample (tRamp const r) +Lfloat tRamp_sample (tRamp* const r) { return r->curr; } -void tRamp_setSampleRate (tRamp const r, Lfloat sr) +void tRamp_setSampleRate (tRamp* const r, Lfloat sr) { r->sampleRate = sr; r->inv_sr_ms = 1.0f / (r->sampleRate * 0.001f); @@ -1101,11 +1101,11 @@ void tRampUpDown_init (tRampUpDown *const r, Lfloat upTime, Lfloat downTime, tRampUpDown_initToPool(r, upTime, downTime, samples_per_tick, &leaf->mempool); } -void tRampUpDown_initToPool (tRampUpDown *const r, Lfloat upTime, Lfloat downTime, +void tRampUpDown_initToPool (tRampUpDown** const r, Lfloat upTime, Lfloat downTime, int samples_per_tick, tMempool *const mp) { _tMempool *m = *mp; - _tRampUpDown *ramp = *r = (_tRampUpDown *) mpool_alloc(sizeof(_tRampUpDown), m); + tRampUpDown *ramp = *r = (tRampUpDown *) mpool_alloc(sizeof(tRampUpDown), m); ramp->mempool = m; LEAF *leaf = ramp->mempool->leaf; @@ -1133,13 +1133,13 @@ void tRampUpDown_initToPool (tRampUpDown *const r, Lfloat upTime, Lfloat downTim ramp->downInc = ((ramp->dest - ramp->curr) / ramp->downTime * ramp->inv_sr_ms) * (Lfloat) ramp->samples_per_tick; } -void tRampUpDown_free (tRampUpDown *const r) +void tRampUpDown_free (tRampUpDown** const r) { - _tRampUpDown *ramp = *r; + tRampUpDown *ramp = *r; mpool_free((char *) ramp, ramp->mempool); } -void tRampUpDown_setUpTime (tRampUpDown const r, Lfloat upTime) +void tRampUpDown_setUpTime (tRampUpDown* const r, Lfloat upTime) { if (upTime < r->minimum_time) { r->upTime = r->minimum_time; @@ -1150,7 +1150,7 @@ void tRampUpDown_setUpTime (tRampUpDown const r, Lfloat upTime) } -void tRampUpDown_setDownTime (tRampUpDown const r, Lfloat downTime) +void tRampUpDown_setDownTime (tRampUpDown* const r, Lfloat downTime) { if (downTime < r->minimum_time) { r->downTime = r->minimum_time; @@ -1160,21 +1160,21 @@ void tRampUpDown_setDownTime (tRampUpDown const r, Lfloat downTime) r->downInc = ((r->dest - r->curr) / r->downTime * r->inv_sr_ms) * (Lfloat) r->samples_per_tick; } -void tRampUpDown_setDest (tRampUpDown const r, Lfloat dest) +void tRampUpDown_setDest (tRampUpDown* const r, Lfloat dest) { r->dest = dest; r->upInc = ((r->dest - r->curr) / r->upTime * r->inv_sr_ms) * (Lfloat) r->samples_per_tick; r->downInc = ((r->dest - r->curr) / r->downTime * r->inv_sr_ms) * (Lfloat) r->samples_per_tick; } -void tRampUpDown_setVal (tRampUpDown const r, Lfloat val) +void tRampUpDown_setVal (tRampUpDown* const r, Lfloat val) { r->curr = val; r->upInc = ((r->dest - r->curr) / r->upTime * r->inv_sr_ms) * (Lfloat) r->samples_per_tick; r->downInc = ((r->dest - r->curr) / r->downTime * r->inv_sr_ms) * (Lfloat) r->samples_per_tick; } -Lfloat tRampUpDown_tick (tRampUpDown const r) +Lfloat tRampUpDown_tick (tRampUpDown* const r) { Lfloat test; @@ -1198,7 +1198,7 @@ Lfloat tRampUpDown_tick (tRampUpDown const r) return r->curr; } -Lfloat tRampUpDown_sample (tRampUpDown const r) +Lfloat tRampUpDown_sample (tRampUpDown* const r) { return r->curr; } @@ -1211,11 +1211,11 @@ void tExpSmooth_init (tExpSmooth *const expsmooth, Lfloat val, Lfloat factor, tExpSmooth_initToPool(expsmooth, val, factor, &leaf->mempool); } -void tExpSmooth_initToPool(tExpSmooth *const expsmooth, Lfloat val, Lfloat factor, +void tExpSmooth_initToPool(tExpSmooth** const expsmooth, Lfloat val, Lfloat factor, tMempool *const mp) { _tMempool *m = *mp; - _tExpSmooth *smooth = *expsmooth = (_tExpSmooth *) mpool_alloc(sizeof(_tExpSmooth), m); + tExpSmooth *smooth = *expsmooth = (tExpSmooth *) mpool_alloc(sizeof(tExpSmooth), m); smooth->mempool = m; smooth->curr = val; @@ -1228,14 +1228,14 @@ void tExpSmooth_initToPool(tExpSmooth *const expsmooth, Lfloat val, Lfloat facto //smooth->invSampleRate = smooth->mempool->leaf->invSampleRate; } -void tExpSmooth_free (tExpSmooth *const expsmooth) +void tExpSmooth_free (tExpSmooth** const expsmooth) { - _tExpSmooth *smooth = *expsmooth; + tExpSmooth *smooth = *expsmooth; mpool_free((char *) smooth, smooth->mempool); } // factor is usually a value between 0 and 0.1. Lower value is slower. 0.01 for example gives you a smoothing time of about 10ms -void tExpSmooth_setFactor (tExpSmooth const smooth, Lfloat factor) +void tExpSmooth_setFactor (tExpSmooth* const smooth, Lfloat factor) { if (factor < 0.0f) factor = 0.0f; @@ -1250,18 +1250,18 @@ void tExpSmooth_setFactor (tExpSmooth const smooth, Lfloat factor) void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tExpSmooth_setDest(tExpSmooth* const expsmooth, Lfloat dest) #else -void tExpSmooth_setDest (tExpSmooth const smooth, Lfloat dest) +void tExpSmooth_setDest (tExpSmooth* const smooth, Lfloat dest) #endif { smooth->dest = dest; } -void tExpSmooth_setVal (tExpSmooth const smooth, Lfloat val) +void tExpSmooth_setVal (tExpSmooth* const smooth, Lfloat val) { smooth->curr = val; } -void tExpSmooth_setValAndDest (tExpSmooth const smooth, Lfloat val) +void tExpSmooth_setValAndDest (tExpSmooth* const smooth, Lfloat val) { smooth->curr = val; smooth->dest = val; @@ -1271,19 +1271,19 @@ void tExpSmooth_setValAndDest (tExpSmooth const smooth, Lfloat val) Lfloat __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tExpSmooth_tick(tExpSmooth* const expsmooth) #else -Lfloat tExpSmooth_tick (tExpSmooth const smooth) +Lfloat tExpSmooth_tick (tExpSmooth* const smooth) #endif { smooth->curr = smooth->factor * smooth->dest + smooth->oneminusfactor * smooth->curr; return smooth->curr; } -Lfloat tExpSmooth_sample (tExpSmooth const smooth) +Lfloat tExpSmooth_sample (tExpSmooth* const smooth) { return smooth->curr; } -void tExpSmooth_setSampleRate (tExpSmooth const smooth, Lfloat sr) +void tExpSmooth_setSampleRate (tExpSmooth* const smooth, Lfloat sr) { //smooth->invSampleRate = 1.0f/sr; //smooth->factor = powf(smooth->baseFactor, 44100.f * smooth->invSampleRate); @@ -1299,10 +1299,10 @@ void tSlide_init (tSlide *const sl, Lfloat upSlide, Lfloat downSlide, LEAF *cons } //upslide and downslide are in samples -void tSlide_initToPool (tSlide *const sl, Lfloat upSlide, Lfloat downSlide, tMempool *const mp) +void tSlide_initToPool (tSlide** const sl, Lfloat upSlide, Lfloat downSlide, tMempool *const mp) { _tMempool *m = *mp; - _tSlide *s = *sl = (_tSlide *) mpool_alloc(sizeof(_tSlide), m); + tSlide *s = *sl = (tSlide *) mpool_alloc(sizeof(tSlide), m); s->mempool = m; s->prevIn = 0.0f; @@ -1320,28 +1320,28 @@ void tSlide_initToPool (tSlide *const sl, Lfloat upSlide, Lfloat downSlide, tMem s->invDownSlide = 1.0f / downSlide; } -void tSlide_free (tSlide *const sl) +void tSlide_free (tSlide** const sl) { - _tSlide *s = *sl; + tSlide *s = *sl; mpool_free((char *) s, s->mempool); } -void tSlide_setUpSlide (tSlide const s, Lfloat upSlide) +void tSlide_setUpSlide (tSlide* const s, Lfloat upSlide) { s->invUpSlide = 1.0f / upSlide; } -void tSlide_setDownSlide (tSlide const s, Lfloat downSlide) +void tSlide_setDownSlide (tSlide* const s, Lfloat downSlide) { s->invDownSlide = 1.0f / downSlide; } -void tSlide_setDest (tSlide const s, Lfloat dest) +void tSlide_setDest (tSlide* const s, Lfloat dest) { s->dest = dest; } -Lfloat tSlide_tickNoInput (tSlide const s) +Lfloat tSlide_tickNoInput (tSlide* const s) { Lfloat in = s->dest; @@ -1359,7 +1359,7 @@ Lfloat tSlide_tickNoInput (tSlide const s) return s->currentOut; } -Lfloat tSlide_tick (tSlide const s, Lfloat in) +Lfloat tSlide_tick (tSlide* const s, Lfloat in) { if (in >= s->prevOut) { s->currentOut = s->prevOut + ((in - s->prevOut) * s->invUpSlide); diff --git a/leaf/Src/leaf-filters.c b/leaf/Src/leaf-filters.c index b415ba3..3580ce8 100644 --- a/leaf/Src/leaf-filters.c +++ b/leaf/Src/leaf-filters.c @@ -37,11 +37,11 @@ void tAllpass_init (tAllpass *const ft, Lfloat initDelay, uint32_t maxDelay, tAllpass_initToPool(ft, initDelay, maxDelay, &leaf->mempool); } -void tAllpass_initToPool (tAllpass *const ft, Lfloat initDelay, +void tAllpass_initToPool (tAllpass** const ft, Lfloat initDelay, uint32_t maxDelay, tMempool *const mp) { _tMempool *m = *mp; - _tAllpass *f = *ft = (_tAllpass *) mpool_alloc(sizeof(_tAllpass), m); + tAllpass *f = *ft = (tAllpass *) mpool_alloc(sizeof(tAllpass), m); f->mempool = m; f->gain = 0.7f; @@ -50,28 +50,28 @@ void tAllpass_initToPool (tAllpass *const ft, Lfloat initDelay, tLinearDelay_initToPool(&f->delay, initDelay, maxDelay, mp); } -void tAllpass_free (tAllpass *const ft) +void tAllpass_free (tAllpass** const ft) { - _tAllpass *f = *ft; + tAllpass *f = *ft; tLinearDelay_free(&f->delay); mpool_free((char *) f, f->mempool); } -void tAllpass_setDelay (tAllpass const f, Lfloat delay) +void tAllpass_setDelay (tAllpass* const f, Lfloat delay) { - tLinearDelay_setDelay(f->delay, delay); + tLinearDelay_setDelay(&f->delay, delay); } -void tAllpass_setGain (tAllpass const f, Lfloat gain) +void tAllpass_setGain (tAllpass* const f, Lfloat gain) { f->gain = gain; } -Lfloat tAllpass_tick (tAllpass const f, Lfloat input) +Lfloat tAllpass_tick (tAllpass* const f, Lfloat input) { Lfloat s1 = (-f->gain) * f->lastOut + input; - Lfloat s2 = tLinearDelay_tick(f->delay, s1) + (f->gain) * input; + Lfloat s2 = tLinearDelay_tick(&f->delay, s1) + (f->gain) * input; f->lastOut = s2; @@ -88,10 +88,10 @@ void tAllpassSO_init (tAllpassSO *const ft, LEAF *const leaf) tAllpassSO_initToPool(ft, &leaf->mempool); } -void tAllpassSO_initToPool (tAllpassSO *const ft, tMempool *const mp) +void tAllpassSO_initToPool (tAllpassSO** const ft, tMempool *const mp) { _tMempool *m = *mp; - _tAllpassSO *f = *ft = (_tAllpassSO *) mpool_alloc(sizeof(_tAllpassSO), m); + tAllpassSO *f = *ft = (tAllpassSO *) mpool_alloc(sizeof(tAllpassSO), m); f->mempool = m; f->prevSamp = 0.0f; @@ -100,13 +100,13 @@ void tAllpassSO_initToPool (tAllpassSO *const ft, tMempool *const mp) f->a2 = 0.0f; } -void tAllpassSO_free (tAllpassSO *const ft) +void tAllpassSO_free (tAllpassSO** const ft) { - _tAllpassSO *f = *ft; + tAllpassSO *f = *ft; mpool_free((char *) f, f->mempool); } -void tAllpassSO_setCoeff (tAllpassSO const f, Lfloat a1, Lfloat a2) +void tAllpassSO_setCoeff (tAllpassSO* const f, Lfloat a1, Lfloat a2) { //Lfloat prevSum = f->a1 + f->a2; //Lfloat newSum = a1+a2; @@ -122,7 +122,7 @@ void tAllpassSO_setCoeff (tAllpassSO const f, Lfloat a1, Lfloat a2) //f->prevPrevSamp *= ratio; } -Lfloat tAllpassSO_tick (tAllpassSO const f, Lfloat input) +Lfloat tAllpassSO_tick (tAllpassSO* const f, Lfloat input) { //DFII version, efficient but causes issues with coefficient changes happening fast (due to high gain of state variables) /* @@ -173,12 +173,12 @@ void tThiranAllpassSOCascade_init (tThiranAllpassSOCascade *const ft, tThiranAllpassSOCascade_initToPool(ft, numFilts, &leaf->mempool); } -void tThiranAllpassSOCascade_initToPool (tThiranAllpassSOCascade *const ft, +void tThiranAllpassSOCascade_initToPool (tThiranAllpassSOCascade** const ft, int numFilts, tMempool *const mp) { _tMempool *m = *mp; - _tThiranAllpassSOCascade *f = *ft = (_tThiranAllpassSOCascade *) mpool_alloc( - sizeof(_tThiranAllpassSOCascade), m); + tThiranAllpassSOCascade *f = *ft = (tThiranAllpassSOCascade *) mpool_alloc( + sizeof(tThiranAllpassSOCascade), m); f->mempool = m; f->numFilts = numFilts; f->filters = (tAllpassSO *) mpool_calloc(sizeof(tAllpassSO) * numFilts, m); @@ -201,9 +201,9 @@ void tThiranAllpassSOCascade_initToPool (tThiranAllpassSOCascade *const ft, } } -void tThiranAllpassSOCascade_free (tThiranAllpassSOCascade *const ft) +void tThiranAllpassSOCascade_free (tThiranAllpassSOCascade** const ft) { - _tThiranAllpassSOCascade *f = *ft; + tThiranAllpassSOCascade *f = *ft; for (int i = 0; i < f->numFilts; i++) { tAllpassSO_free(&f->filters[i]); } @@ -213,7 +213,7 @@ void tThiranAllpassSOCascade_free (tThiranAllpassSOCascade *const ft) volatile Lfloat binTest; -float tThiranAllpassSOCascade_setCoeff (tThiranAllpassSOCascade const f, +float tThiranAllpassSOCascade_setCoeff (tThiranAllpassSOCascade* const f, Lfloat dispersionCoeff, Lfloat freq, Lfloat oversampling) { @@ -274,7 +274,7 @@ float tThiranAllpassSOCascade_setCoeff (tThiranAllpassSOCascade const f, //f->a[1] = LEAF_clip(-1.999999f, f->a[1], 2.0f); for (int i = 0; i < f->numActiveFilters; i++) { - tAllpassSO_setCoeff(f->filters[i], f->a[0], f->a[1]); + tAllpassSO_setCoeff(&f->filters[i], f->a[0], f->a[1]); //f->filters[i]->prevSamp = 0.0f; //f->filters[i]->prevPrevSamp = 0.0f; //probably should adjust the gain of the internal state variables @@ -286,16 +286,16 @@ float tThiranAllpassSOCascade_setCoeff (tThiranAllpassSOCascade const f, return D * f->numActiveFilters; } -Lfloat tThiranAllpassSOCascade_tick (tThiranAllpassSOCascade const f, Lfloat input) +Lfloat tThiranAllpassSOCascade_tick (tThiranAllpassSOCascade* const f, Lfloat input) { Lfloat sample = input; for (int i = 0; i < f->numActiveFilters; i++) { - sample = tAllpassSO_tick(f->filters[i], sample); + sample = tAllpassSO_tick(&f->filters[i], sample); } return sample; } -void tThiranAllpassSOCascade_clear (tThiranAllpassSOCascade const f) +void tThiranAllpassSOCascade_clear (tThiranAllpassSOCascade* const f) { for (int i = 0; i < f->numFilts; i++) { //tAllpassSO_setCoeff(&f->filters[i], f->a[1], f->a[2]); @@ -316,10 +316,10 @@ void tOnePole_init (tOnePole *const ft, Lfloat freq, LEAF *const leaf) tOnePole_initToPool(ft, freq, &leaf->mempool); } -void tOnePole_initToPool (tOnePole *const ft, Lfloat freq, tMempool *const mp) +void tOnePole_initToPool (tOnePole** const ft, Lfloat freq, tMempool *const mp) { _tMempool *m = *mp; - _tOnePole *f = *ft = (_tOnePole *) mpool_alloc(sizeof(_tOnePole), m); + tOnePole *f = *ft = (tOnePole *) mpool_alloc(sizeof(tOnePole), m); f->mempool = m; LEAF *leaf = f->mempool->leaf; @@ -334,25 +334,25 @@ void tOnePole_initToPool (tOnePole *const ft, Lfloat freq, tMempool *const mp) tOnePole_setFreq(*ft, freq); } -void tOnePole_free (tOnePole *const ft) +void tOnePole_free (tOnePole** const ft) { - _tOnePole *f = *ft; + tOnePole *f = *ft; mpool_free((char *) f, f->mempool); } -void tOnePole_setB0 (tOnePole const f, Lfloat b0) +void tOnePole_setB0 (tOnePole* const f, Lfloat b0) { f->b0 = b0; } -void tOnePole_setA1 (tOnePole const f, Lfloat a1) +void tOnePole_setA1 (tOnePole* const f, Lfloat a1) { if (a1 >= 1.0f) a1 = 0.999999f; f->a1 = a1; } -void tOnePole_setPole (tOnePole const f, Lfloat thePole) +void tOnePole_setPole (tOnePole* const f, Lfloat thePole) { if (thePole >= 1.0f) thePole = 0.999999f; @@ -363,7 +363,7 @@ void tOnePole_setPole (tOnePole const f, Lfloat thePole) f->a1 = -thePole; } -void tOnePole_setFreq (tOnePole const f, Lfloat freq) +void tOnePole_setFreq (tOnePole* const f, Lfloat freq) { f->freq = freq; f->b0 = f->freq * f->twoPiTimesInvSampleRate; @@ -371,19 +371,19 @@ void tOnePole_setFreq (tOnePole const f, Lfloat freq) f->a1 = 1.0f - f->b0; } -void tOnePole_setCoefficients (tOnePole const f, Lfloat b0, Lfloat a1) +void tOnePole_setCoefficients (tOnePole* const f, Lfloat b0, Lfloat a1) { if (b0 >= 1.0f) b0 = 0.999999f; f->b0 = b0; f->a1 = a1; } -void tOnePole_setGain (tOnePole const f, Lfloat gain) +void tOnePole_setGain (tOnePole* const f, Lfloat gain) { f->gain = gain; } -Lfloat tOnePole_tick (tOnePole const f, Lfloat input) +Lfloat tOnePole_tick (tOnePole* const f, Lfloat input) { Lfloat in = input * f->gain; Lfloat out = (f->b0 * in) + (f->a1 * f->lastOut); @@ -394,7 +394,7 @@ Lfloat tOnePole_tick (tOnePole const f, Lfloat input) return out; } -void tOnePole_setSampleRate (tOnePole const f, Lfloat sr) +void tOnePole_setSampleRate (tOnePole* const f, Lfloat sr) { f->twoPiTimesInvSampleRate = (1.0f / sr) * TWO_PI; f->b0 = f->freq * f->twoPiTimesInvSampleRate; @@ -413,10 +413,10 @@ void tCookOnePole_init (tCookOnePole *const ft, LEAF *const leaf) tCookOnePole_initToPool(ft, &leaf->mempool); } -void tCookOnePole_initToPool (tCookOnePole *const ft, tMempool *const mp) +void tCookOnePole_initToPool (tCookOnePole** const ft, tMempool *const mp) { _tMempool *m = *mp; - _tCookOnePole *f = *ft = (_tCookOnePole *) mpool_alloc(sizeof(_tCookOnePole), m); + tCookOnePole *f = *ft = (tCookOnePole *) mpool_alloc(sizeof(tCookOnePole), m); f->mempool = m; LEAF *leaf = f->mempool->leaf; @@ -427,15 +427,15 @@ void tCookOnePole_initToPool (tCookOnePole *const ft, tMempool *const mp) f->twoPiTimesInvSampleRate = leaf->twoPiTimesInvSampleRate; } -void tCookOnePole_free (tCookOnePole *const ft) +void tCookOnePole_free (tCookOnePole** const ft) { - _tCookOnePole *f = *ft; + tCookOnePole *f = *ft; mpool_free((char *) f, f->mempool); } -void tCookOnePole_setPole (tCookOnePole const onepole, Lfloat aValue) +void tCookOnePole_setPole (tCookOnePole* const onepole, Lfloat aValue) { onepole->poleCoeff = aValue; if (onepole->poleCoeff > 0.0f) // Normalize gain to 1.0 max @@ -444,7 +444,7 @@ void tCookOnePole_setPole (tCookOnePole const onepole, Lfloat aValue) onepole->sgain = (1.0f + onepole->poleCoeff); } -void tCookOnePole_setGain (tCookOnePole const onepole, Lfloat gain) +void tCookOnePole_setGain (tCookOnePole* const onepole, Lfloat gain) { onepole->gain = gain; if (onepole->poleCoeff > 0.0f) // Normalize gain to 1.0 max @@ -453,19 +453,19 @@ void tCookOnePole_setGain (tCookOnePole const onepole, Lfloat gain) onepole->sgain = ((1.0f + onepole->poleCoeff) * gain); } -void tCookOnePole_setGainAndPole (tCookOnePole const onepole, Lfloat gain, Lfloat pole) +void tCookOnePole_setGainAndPole (tCookOnePole* const onepole, Lfloat gain, Lfloat pole) { onepole->poleCoeff = pole; onepole->sgain = gain; } -Lfloat tCookOnePole_tick (tCookOnePole const onepole, Lfloat sample) +Lfloat tCookOnePole_tick (tCookOnePole* const onepole, Lfloat sample) { onepole->output = (onepole->sgain * sample) + (onepole->poleCoeff * onepole->output); return onepole->output; } -void tCookOnePole_setSampleRate (tCookOnePole const f, Lfloat sr) +void tCookOnePole_setSampleRate (tCookOnePole* const f, Lfloat sr) { f->twoPiTimesInvSampleRate = (1.0f / sr) * TWO_PI; } @@ -481,10 +481,10 @@ void tTwoPole_init (tTwoPole *const ft, LEAF *const leaf) tTwoPole_initToPool(ft, &leaf->mempool); } -void tTwoPole_initToPool (tTwoPole *const ft, tMempool *const mp) +void tTwoPole_initToPool (tTwoPole** const ft, tMempool *const mp) { _tMempool *m = *mp; - _tTwoPole *f = *ft = (_tTwoPole *) mpool_alloc(sizeof(_tTwoPole), m); + tTwoPole *f = *ft = (tTwoPole *) mpool_alloc(sizeof(tTwoPole), m); f->mempool = m; LEAF *leaf = f->mempool->leaf; @@ -499,13 +499,13 @@ void tTwoPole_initToPool (tTwoPole *const ft, tMempool *const mp) f->twoPiTimesInvSampleRate = leaf->twoPiTimesInvSampleRate; } -void tTwoPole_free (tTwoPole *const ft) +void tTwoPole_free (tTwoPole** const ft) { - _tTwoPole *f = *ft; + tTwoPole *f = *ft; mpool_free((char *) f, f->mempool); } -Lfloat tTwoPole_tick (tTwoPole const f, Lfloat input) +Lfloat tTwoPole_tick (tTwoPole* const f, Lfloat input) { Lfloat in = input * f->gain; Lfloat out = (f->b0 * in) - (f->a1 * f->lastOut[0]) - (f->a2 * f->lastOut[1]); @@ -516,22 +516,22 @@ Lfloat tTwoPole_tick (tTwoPole const f, Lfloat input) return out; } -void tTwoPole_setB0 (tTwoPole const f, Lfloat b0) +void tTwoPole_setB0 (tTwoPole* const f, Lfloat b0) { f->b0 = b0; } -void tTwoPole_setA1 (tTwoPole const f, Lfloat a1) +void tTwoPole_setA1 (tTwoPole* const f, Lfloat a1) { f->a1 = a1; } -void tTwoPole_setA2 (tTwoPole const f, Lfloat a2) +void tTwoPole_setA2 (tTwoPole* const f, Lfloat a2) { f->a2 = a2; } -void tTwoPole_setResonance (tTwoPole const f, Lfloat frequency, Lfloat radius, +void tTwoPole_setResonance (tTwoPole* const f, Lfloat frequency, Lfloat radius, int normalize) { Lfloat sampleRate = f->sampleRate; @@ -557,19 +557,19 @@ void tTwoPole_setResonance (tTwoPole const f, Lfloat frequency, Lfloat radius, } } -void tTwoPole_setCoefficients (tTwoPole const f, Lfloat b0, Lfloat a1, Lfloat a2) +void tTwoPole_setCoefficients (tTwoPole* const f, Lfloat b0, Lfloat a1, Lfloat a2) { f->b0 = b0; f->a1 = a1; f->a2 = a2; } -void tTwoPole_setGain (tTwoPole const f, Lfloat gain) +void tTwoPole_setGain (tTwoPole* const f, Lfloat gain) { f->gain = gain; } -void tTwoPole_setSampleRate (tTwoPole const f, Lfloat sr) +void tTwoPole_setSampleRate (tTwoPole* const f, Lfloat sr) { f->twoPiTimesInvSampleRate = (1.0f / sr) * TWO_PI; @@ -595,10 +595,10 @@ void tOneZero_init (tOneZero *const ft, Lfloat theZero, LEAF *const leaf) tOneZero_initToPool(ft, theZero, &leaf->mempool); } -void tOneZero_initToPool (tOneZero *const ft, Lfloat theZero, tMempool *const mp) +void tOneZero_initToPool (tOneZero** const ft, Lfloat theZero, tMempool *const mp) { _tMempool *m = *mp; - _tOneZero *f = *ft = (_tOneZero *) mpool_alloc(sizeof(_tOneZero), m); + tOneZero *f = *ft = (tOneZero *) mpool_alloc(sizeof(tOneZero), m); f->mempool = m; LEAF *leaf = f->mempool->leaf; @@ -609,13 +609,13 @@ void tOneZero_initToPool (tOneZero *const ft, Lfloat theZero, tMempool *const mp tOneZero_setZero(*ft, theZero); } -void tOneZero_free (tOneZero *const ft) +void tOneZero_free (tOneZero** const ft) { - _tOneZero *f = *ft; + tOneZero *f = *ft; mpool_free((char *) f, f->mempool); } -Lfloat tOneZero_tick (tOneZero const f, Lfloat input) +Lfloat tOneZero_tick (tOneZero* const f, Lfloat input) { Lfloat in = input * f->gain; Lfloat out = f->b1 * f->lastIn + f->b0 * in; @@ -625,7 +625,7 @@ Lfloat tOneZero_tick (tOneZero const f, Lfloat input) return out; } -void tOneZero_setZero (tOneZero const f, Lfloat theZero) +void tOneZero_setZero (tOneZero* const f, Lfloat theZero) { if (theZero > 0.0f) f->b0 = 1.0f / (1.0f + theZero); else f->b0 = 1.0f / (1.0f - theZero); @@ -634,28 +634,28 @@ void tOneZero_setZero (tOneZero const f, Lfloat theZero) } -void tOneZero_setB0 (tOneZero const f, Lfloat b0) +void tOneZero_setB0 (tOneZero* const f, Lfloat b0) { f->b0 = b0; } -void tOneZero_setB1 (tOneZero const f, Lfloat b1) +void tOneZero_setB1 (tOneZero* const f, Lfloat b1) { f->b1 = b1; } -void tOneZero_setCoefficients (tOneZero const f, Lfloat b0, Lfloat b1) +void tOneZero_setCoefficients (tOneZero* const f, Lfloat b0, Lfloat b1) { f->b0 = b0; f->b1 = b1; } -void tOneZero_setGain (tOneZero f, Lfloat gain) +void tOneZero_setGain (tOneZero* f, Lfloat gain) { f->gain = gain; } -Lfloat tOneZero_getPhaseDelay (tOneZero const f, Lfloat frequency) +Lfloat tOneZero_getPhaseDelay (tOneZero* const f, Lfloat frequency) { if (frequency <= 0.0f) frequency = 0.05f; @@ -684,7 +684,7 @@ Lfloat tOneZero_getPhaseDelay (tOneZero const f, Lfloat frequency) return phase / omegaT; } -void tOneZero_setSampleRate (tOneZero const f, Lfloat sr) +void tOneZero_setSampleRate (tOneZero* const f, Lfloat sr) { f->invSampleRate = 1.0f / sr; } @@ -695,15 +695,15 @@ void tOneZero_setSampleRate (tOneZero const f, Lfloat sr) /******************************************************************************/ -void tTwoZero_init (tTwoZero *const ft, LEAF *const leaf) +void tTwoZero_init (tTwoZero* const ft, LEAF *const leaf) { tTwoZero_initToPool(ft, &leaf->mempool); } -void tTwoZero_initToPool (tTwoZero *const ft, tMempool *const mp) +void tTwoZero_initToPool (tTwoZero** const ft, tMempool *const mp) { _tMempool *m = *mp; - _tTwoZero *f = *ft = (_tTwoZero *) mpool_alloc(sizeof(_tTwoZero), m); + tTwoZero *f = *ft = (tTwoZero *) mpool_alloc(sizeof(tTwoZero), m); f->mempool = m; LEAF *leaf = f->mempool->leaf; @@ -713,13 +713,13 @@ void tTwoZero_initToPool (tTwoZero *const ft, tMempool *const mp) f->lastIn[1] = 0.0f; } -void tTwoZero_free (tTwoZero *const ft) +void tTwoZero_free (tTwoZero** const ft) { - _tTwoZero *f = *ft; + tTwoZero *f = *ft; mpool_free((char *) f, f->mempool); } -Lfloat tTwoZero_tick (tTwoZero const f, Lfloat input) +Lfloat tTwoZero_tick (tTwoZero* const f, Lfloat input) { Lfloat in = input * f->gain; Lfloat out = f->b2 * f->lastIn[1] + f->b1 * f->lastIn[0] + f->b0 * in; @@ -730,7 +730,7 @@ Lfloat tTwoZero_tick (tTwoZero const f, Lfloat input) return out; } -void tTwoZero_setNotch (tTwoZero const f, Lfloat freq, Lfloat radius) +void tTwoZero_setNotch (tTwoZero* const f, Lfloat freq, Lfloat radius) { // Should also deal with frequency being > half sample rate / nyquist. See STK if (freq < 0.0f) freq = 0.0f; @@ -752,29 +752,29 @@ void tTwoZero_setNotch (tTwoZero const f, Lfloat freq, Lfloat radius) } -void tTwoZero_setB0 (tTwoZero const f, Lfloat b0) +void tTwoZero_setB0 (tTwoZero* const f, Lfloat b0) { f->b0 = b0; } -void tTwoZero_setB1 (tTwoZero const f, Lfloat b1) +void tTwoZero_setB1 (tTwoZero* const f, Lfloat b1) { f->b1 = b1; } -void tTwoZero_setCoefficients (tTwoZero const f, Lfloat b0, Lfloat b1, Lfloat b2) +void tTwoZero_setCoefficients (tTwoZero* const f, Lfloat b0, Lfloat b1, Lfloat b2) { f->b0 = b0; f->b1 = b1; f->b2 = b2; } -void tTwoZero_setGain (tTwoZero const f, Lfloat gain) +void tTwoZero_setGain (tTwoZero* const f, Lfloat gain) { f->gain = gain; } -void tTwoZero_setSampleRate (tTwoZero const f, Lfloat sr) +void tTwoZero_setSampleRate (tTwoZero* const f, Lfloat sr) { f->twoPiTimesInvSampleRate = TWO_PI * (1.0f / sr); tTwoZero_setNotch(f, f->frequency, f->radius); @@ -785,15 +785,15 @@ void tTwoZero_setSampleRate (tTwoZero const f, Lfloat sr) /******************************************************************************/ -void tPoleZero_init (tPoleZero *const pzf, LEAF *const leaf) +void tPoleZero_init (tPoleZero* const pzf, LEAF *const leaf) { tPoleZero_initToPool(pzf, &leaf->mempool); } -void tPoleZero_initToPool (tPoleZero *const pzf, tMempool *const mp) +void tPoleZero_initToPool (tPoleZero** const pzf, tMempool *const mp) { _tMempool *m = *mp; - _tPoleZero *f = *pzf = (_tPoleZero *) mpool_alloc(sizeof(_tPoleZero), m); + tPoleZero *f = *pzf = (tPoleZero *) mpool_alloc(sizeof(tPoleZero), m); f->mempool = m; f->gain = 1.0f; @@ -803,23 +803,23 @@ void tPoleZero_initToPool (tPoleZero *const pzf, tMempool *const mp) f->lastOut = 0.0f; } -void tPoleZero_free (tPoleZero *const pzf) +void tPoleZero_free (tPoleZero** const pzf) { - _tPoleZero *f = *pzf; + tPoleZero *f = *pzf; mpool_free((char *) f, f->mempool); } -void tPoleZero_setB0 (tPoleZero const f, Lfloat b0) +void tPoleZero_setB0 (tPoleZero* const f, Lfloat b0) { f->b0 = b0; } -void tPoleZero_setB1 (tPoleZero const f, Lfloat b1) +void tPoleZero_setB1 (tPoleZero* const f, Lfloat b1) { f->b1 = b1; } -void tPoleZero_setA1 (tPoleZero const f, Lfloat a1) +void tPoleZero_setA1 (tPoleZero* const f, Lfloat a1) { if (a1 >= 1.0f) // a1 should be less than 1.0 { @@ -829,7 +829,7 @@ void tPoleZero_setA1 (tPoleZero const f, Lfloat a1) f->a1 = a1; } -void tPoleZero_setCoefficients (tPoleZero const f, Lfloat b0, Lfloat b1, Lfloat a1) +void tPoleZero_setCoefficients (tPoleZero* const f, Lfloat b0, Lfloat b1, Lfloat a1) { if (a1 >= 1.0f) // a1 should be less than 1.0 { @@ -841,7 +841,7 @@ void tPoleZero_setCoefficients (tPoleZero const f, Lfloat b0, Lfloat b1, Lfloat f->a1 = a1; } -void tPoleZero_setThiranAllpassSOCascade (tPoleZero const f, Lfloat coeff) +void tPoleZero_setThiranAllpassSOCascade (tPoleZero* const f, Lfloat coeff) { if (coeff >= 1.0f) // allpass coefficient >= 1.0 makes filter unstable { @@ -853,7 +853,7 @@ void tPoleZero_setThiranAllpassSOCascade (tPoleZero const f, Lfloat coeff) f->a1 = coeff; } -void tPoleZero_setBlockZero (tPoleZero const f, Lfloat thePole) +void tPoleZero_setBlockZero (tPoleZero* const f, Lfloat thePole) { if (thePole >= 1.0f) // allpass coefficient >= 1.0 makes filter unstable { @@ -865,12 +865,12 @@ void tPoleZero_setBlockZero (tPoleZero const f, Lfloat thePole) f->a1 = -thePole; } -void tPoleZero_setGain (tPoleZero const f, Lfloat gain) +void tPoleZero_setGain (tPoleZero* const f, Lfloat gain) { f->gain = gain; } -Lfloat tPoleZero_tick (tPoleZero const f, Lfloat input) +Lfloat tPoleZero_tick (tPoleZero* const f, Lfloat input) { Lfloat in = input * f->gain; Lfloat out = (f->b0 * in) + (f->b1 * f->lastIn) - (f->a1 * f->lastOut); @@ -891,10 +891,10 @@ void tBiQuad_init (tBiQuad *const ft, LEAF *const leaf) tBiQuad_initToPool(ft, &leaf->mempool); } -void tBiQuad_initToPool (tBiQuad *const ft, tMempool *const mp) +void tBiQuad_initToPool (tBiQuad** const ft, tMempool *const mp) { _tMempool *m = *mp; - _tBiQuad *f = *ft = (_tBiQuad *) mpool_alloc(sizeof(_tBiQuad), m); + tBiQuad *f = *ft = (tBiQuad *) mpool_alloc(sizeof(tBiQuad), m); f->mempool = m; LEAF *leaf = f->mempool->leaf; @@ -911,13 +911,13 @@ void tBiQuad_initToPool (tBiQuad *const ft, tMempool *const mp) f->twoPiTimesInvSampleRate = leaf->twoPiTimesInvSampleRate; } -void tBiQuad_free (tBiQuad *const ft) +void tBiQuad_free (tBiQuad** const ft) { - _tBiQuad *f = *ft; + tBiQuad *f = *ft; mpool_free((char *) f, f->mempool); } -Lfloat tBiQuad_tick (tBiQuad const f, Lfloat input) +Lfloat tBiQuad_tick (tBiQuad* const f, Lfloat input) { Lfloat in = input * f->gain; Lfloat out = f->b0 * in + f->b1 * f->lastIn[0] + f->b2 * f->lastIn[1]; @@ -932,7 +932,7 @@ Lfloat tBiQuad_tick (tBiQuad const f, Lfloat input) return out; } -void tBiQuad_setResonance (tBiQuad const f, Lfloat freq, Lfloat radius, int normalize) +void tBiQuad_setResonance (tBiQuad* const f, Lfloat freq, Lfloat radius, int normalize) { if (freq < 0.0f) freq = 0.0f; if (freq > (f->sampleRate * 0.49f)) @@ -954,7 +954,7 @@ void tBiQuad_setResonance (tBiQuad const f, Lfloat freq, Lfloat radius, int norm } } -void tBiQuad_setNotch (tBiQuad const f, Lfloat freq, Lfloat radius) +void tBiQuad_setNotch (tBiQuad* const f, Lfloat freq, Lfloat radius) { if (freq < 0.0f) freq = 0.0f; if (freq > (f->sampleRate * 0.49f)) @@ -967,40 +967,40 @@ void tBiQuad_setNotch (tBiQuad const f, Lfloat freq, Lfloat radius) // Does not attempt to normalize filter gain. } -void tBiQuad_setEqualGainZeros (tBiQuad *const ft) +void tBiQuad_setEqualGainZeros (tBiQuad** const ft) { - _tBiQuad *f = *ft; + tBiQuad *f = *ft; f->b0 = 1.0f; f->b1 = 0.0f; f->b2 = -1.0f; } -void tBiQuad_setB0 (tBiQuad const f, Lfloat b0) +void tBiQuad_setB0 (tBiQuad* const f, Lfloat b0) { f->b0 = b0; } -void tBiQuad_setB1 (tBiQuad const f, Lfloat b1) +void tBiQuad_setB1 (tBiQuad* const f, Lfloat b1) { f->b1 = b1; } -void tBiQuad_setB2 (tBiQuad const f, Lfloat b2) +void tBiQuad_setB2 (tBiQuad* const f, Lfloat b2) { f->b2 = b2; } -void tBiQuad_setA1 (tBiQuad const f, Lfloat a1) +void tBiQuad_setA1 (tBiQuad* const f, Lfloat a1) { f->a1 = a1; } -void tBiQuad_setA2 (tBiQuad const f, Lfloat a2) +void tBiQuad_setA2 (tBiQuad* const f, Lfloat a2) { f->a2 = a2; } -void tBiQuad_setCoefficients (tBiQuad const f, Lfloat b0, Lfloat b1, Lfloat b2, +void tBiQuad_setCoefficients (tBiQuad* const f, Lfloat b0, Lfloat b1, Lfloat b2, Lfloat a1, Lfloat a2) { f->b0 = b0; @@ -1010,12 +1010,12 @@ void tBiQuad_setCoefficients (tBiQuad const f, Lfloat b0, Lfloat b1, Lfloat b2, f->a2 = a2; } -void tBiQuad_setGain (tBiQuad const f, Lfloat gain) +void tBiQuad_setGain (tBiQuad* const f, Lfloat gain) { f->gain = gain; } -void tBiQuad_setSampleRate (tBiQuad const f, Lfloat sr) +void tBiQuad_setSampleRate (tBiQuad* const f, Lfloat sr) { f->sampleRate = sr; f->twoPiTimesInvSampleRate = TWO_PI * (1.0f / f->sampleRate); @@ -1048,11 +1048,11 @@ void tSVF_init (tSVF *const svff, SVFType type, Lfloat freq, Lfloat Q, */ } -void tSVF_initToPool (tSVF *const svff, SVFType type, Lfloat freq, Lfloat Q, +void tSVF_initToPool (tSVF** const svff, SVFType type, Lfloat freq, Lfloat Q, tMempool *const mp) { _tMempool *m = *mp; - _tSVF *svf = *svff = (_tSVF *) mpool_alloc(sizeof(_tSVF), m); + tSVF *svf = *svff = (tSVF *) mpool_alloc(sizeof(tSVF), m); svf->mempool = m; LEAF *leaf = svf->mempool->leaf; @@ -1110,13 +1110,13 @@ void tSVF_initToPool (tSVF *const svff, SVFType type, Lfloat freq, Lfloat Q, } } -void tSVF_free (tSVF *const svff) +void tSVF_free (tSVF** const svff) { - _tSVF *svf = *svff; + tSVF *svf = *svff; mpool_free((char *) svf, svf->mempool); } -Lfloat tSVF_tick (tSVF const svf, Lfloat v0) +Lfloat tSVF_tick (tSVF* const svf, Lfloat v0) { Lfloat v1, v2, v3; v3 = v0 - svf->ic2eq; @@ -1129,7 +1129,7 @@ Lfloat tSVF_tick (tSVF const svf, Lfloat v0) (v2 * svf->cL); } -Lfloat tSVF_tickHP (tSVF const svf, Lfloat v0) +Lfloat tSVF_tickHP (tSVF* const svf, Lfloat v0) { Lfloat v1, v2; v1 = svf->a1 * svf->ic1eq + svf->a2 * (v0 - svf->ic2eq); @@ -1139,7 +1139,7 @@ Lfloat tSVF_tickHP (tSVF const svf, Lfloat v0) return v0 - (svf->k * v1) - (v2); } -Lfloat tSVF_tickBP (tSVF const svf, Lfloat v0) +Lfloat tSVF_tickBP (tSVF* const svf, Lfloat v0) { Lfloat v1, v2; v1 = svf->a1 * svf->ic1eq + svf->a2 * (v0 - svf->ic2eq); @@ -1150,7 +1150,7 @@ Lfloat tSVF_tickBP (tSVF const svf, Lfloat v0) return v1; } -Lfloat tSVF_tickLP (tSVF const svf, Lfloat v0) +Lfloat tSVF_tickLP (tSVF* const svf, Lfloat v0) { Lfloat v1, v2; v1 = svf->a1 * svf->ic1eq + svf->a2 * (v0 - svf->ic2eq); @@ -1160,7 +1160,7 @@ Lfloat tSVF_tickLP (tSVF const svf, Lfloat v0) return v2; } -void tSVF_setFreq (tSVF const svf, Lfloat freq) +void tSVF_setFreq (tSVF* const svf, Lfloat freq) { svf->cutoff = LEAF_clip(0.0f, freq, svf->sampleRate * 0.5f); svf->g = tanf(PI * svf->cutoff * svf->invSampleRate); @@ -1169,7 +1169,7 @@ void tSVF_setFreq (tSVF const svf, Lfloat freq) svf->a3 = svf->g * svf->a2; } -void tSVF_setFreqFast (tSVF const svf, Lfloat cutoff) +void tSVF_setFreqFast (tSVF* const svf, Lfloat cutoff) { svf->cutoffMIDI = cutoff; cutoff *= 30.567164179104478f; //get 0-134 midi range to 0-4095 @@ -1189,7 +1189,7 @@ void tSVF_setFreqFast (tSVF const svf, Lfloat cutoff) svf->a3 = svf->g * svf->a2; } -void tSVF_setQ (tSVF const svf, Lfloat Q) +void tSVF_setQ (tSVF* const svf, Lfloat Q) { svf->Q = Q; svf->k = 1.0f / Q; @@ -1199,7 +1199,7 @@ void tSVF_setQ (tSVF const svf, Lfloat Q) svf->a3 = svf->g * svf->a2; } -void tSVF_setFreqAndQ (tSVF const svf, Lfloat freq, Lfloat Q) +void tSVF_setFreqAndQ (tSVF* const svf, Lfloat freq, Lfloat Q) { svf->cutoff = LEAF_clip(0.0f, freq, svf->sampleRate * 0.5f); svf->k = 1.0f / Q; @@ -1209,7 +1209,7 @@ void tSVF_setFreqAndQ (tSVF const svf, Lfloat freq, Lfloat Q) svf->a3 = svf->g * svf->a2; } -void tSVF_setFreqAndQFast (tSVF const svf, Lfloat cutoff, Lfloat Q) +void tSVF_setFreqAndQFast (tSVF* const svf, Lfloat cutoff, Lfloat Q) { svf->cutoffMIDI = cutoff; cutoff *= 30.567164179104478f; //get 0-134 midi range to 0-4095 @@ -1229,7 +1229,7 @@ void tSVF_setFreqAndQFast (tSVF const svf, Lfloat cutoff, Lfloat Q) svf->a3 = svf->g * svf->a2; } -void tSVF_setFilterType (tSVF const svf, SVFType type) +void tSVF_setFilterType (tSVF* const svf, SVFType type) { if (type == SVFTypeLowpass) { svf->cH = 0.0f; @@ -1259,7 +1259,7 @@ void tSVF_setFilterType (tSVF const svf, SVFType type) } } -void tSVF_setSampleRate (tSVF const svf, Lfloat sr) +void tSVF_setSampleRate (tSVF* const svf, Lfloat sr) { svf->sampleRate = sr; svf->invSampleRate = 1.0f / svf->sampleRate; @@ -1273,7 +1273,7 @@ void tSVF_setSampleRate (tSVF const svf, Lfloat sr) //only works for lowpass right now //actually doesn't work at all yet! -Lfloat tSVF_getPhaseAtFrequency (tSVF const svf, Lfloat freq) +Lfloat tSVF_getPhaseAtFrequency (tSVF* const svf, Lfloat freq) { Lfloat w = svf->invSampleRate * freq * TWO_PI; Lfloat c = 0.0f; @@ -1292,15 +1292,15 @@ Lfloat tSVF_getPhaseAtFrequency (tSVF const svf, Lfloat freq) // Less efficient, more accurate version of SVF, in which cutoff frequency is taken as Lfloating point Hz value and tanf // is calculated when frequency changes. -void tSVF_LP_init (tSVF_LP *const svff, Lfloat freq, Lfloat Q, LEAF *const leaf) +void tSVF_LP_init (tSVF_LP* const svff, Lfloat freq, Lfloat Q, LEAF *const leaf) { tSVF_LP_initToPool(svff, freq, Q, &leaf->mempool); } -void tSVF_LP_initToPool (tSVF_LP *const svff, Lfloat freq, Lfloat Q, tMempool *const mp) +void tSVF_LP_initToPool (tSVF_LP** const svff, Lfloat freq, Lfloat Q, tMempool *const mp) { _tMempool *m = *mp; - _tSVF_LP *svf = *svff = (_tSVF_LP *) mpool_alloc(sizeof(_tSVF_LP), m); + tSVF_LP *svf = *svff = (tSVF_LP *) mpool_alloc(sizeof(tSVF_LP), m); svf->mempool = m; LEAF *leaf = svf->mempool->leaf; @@ -1332,13 +1332,13 @@ void tSVF_LP_initToPool (tSVF_LP *const svff, Lfloat freq, Lfloat Q, tMempool *c } } -void tSVF_LP_free (tSVF_LP* const svff) +void tSVF_LP_free (tSVF_LP** const svff) { - _tSVF_LP *svf = *svff; + tSVF_LP *svf = *svff; mpool_free((char *) svf, svf->mempool); } -Lfloat tSVF_LP_tick (tSVF_LP const svf, Lfloat v0) +Lfloat tSVF_LP_tick (tSVF_LP* const svf, Lfloat v0) { Lfloat v1, v2; v1 = svf->a1 * svf->ic2eq + svf->a2 * svf->ic1eq + svf->a3 * v0; @@ -1348,7 +1348,7 @@ Lfloat tSVF_LP_tick (tSVF_LP const svf, Lfloat v0) return v2; } -void tSVF_LP_setFreq (tSVF_LP const svf, Lfloat freq) +void tSVF_LP_setFreq (tSVF_LP* const svf, Lfloat freq) { Lfloat cutoff = LEAF_clip(0.0f, freq, svf->sampleRate * 0.5f); svf->g = tanf(PI * cutoff * svf->invSampleRate); @@ -1363,7 +1363,7 @@ void tSVF_LP_setFreq (tSVF_LP const svf, Lfloat freq) } -void tSVF_LP_setFreqFast (tSVF_LP const svf, Lfloat cutoff) +void tSVF_LP_setFreqFast (tSVF_LP* const svf, Lfloat cutoff) { //svf->cutoffMIDI = cutoff; cutoff *= 30.567164179104478f; //get 0-134 midi range to 0-4095 @@ -1386,7 +1386,7 @@ void tSVF_LP_setFreqFast (tSVF_LP const svf, Lfloat cutoff) svf->a5 = svf->g * svf->a4; } -void tSVF_LP_setQ (tSVF_LP const svf, Lfloat Q) +void tSVF_LP_setQ (tSVF_LP* const svf, Lfloat Q) { if (Q > 0.99f) { Q = 0.99f; @@ -1400,7 +1400,7 @@ void tSVF_LP_setQ (tSVF_LP const svf, Lfloat Q) svf->a5 = svf->g * svf->a4; } -void tSVF_LP_setFreqAndQ (tSVF_LP const svf, Lfloat freq, Lfloat Q) +void tSVF_LP_setFreqAndQ (tSVF_LP* const svf, Lfloat freq, Lfloat Q) { Lfloat cutoff = LEAF_clip(0.0f, freq, svf->sampleRate * 0.5f); if (Q > 0.99f) { @@ -1417,7 +1417,7 @@ void tSVF_LP_setFreqAndQ (tSVF_LP const svf, Lfloat freq, Lfloat Q) svf->a5 = svf->g * svf->a4; } -void tSVF_LP_setFreqAndQFast (tSVF_LP const svf, Lfloat cutoff, Lfloat Q) +void tSVF_LP_setFreqAndQFast (tSVF_LP* const svf, Lfloat cutoff, Lfloat Q) { // svf->cutoffMIDI = cutoff; cutoff *= 30.567164179104478f; //get 0-134 midi range to 0-4095 @@ -1444,7 +1444,7 @@ void tSVF_LP_setFreqAndQFast (tSVF_LP const svf, Lfloat cutoff, Lfloat Q) svf->a5 = svf->g * svf->a4; } -void tSVF_LP_setSampleRate (tSVF_LP const svf, Lfloat sr) +void tSVF_LP_setSampleRate (tSVF_LP* const svf, Lfloat sr) { svf->sampleRate = sr; svf->invSampleRate = 1.0f / svf->sampleRate; @@ -1458,7 +1458,7 @@ void tSVF_LP_setSampleRate (tSVF_LP const svf, Lfloat sr) //only works for lowpass right now //actually doesn't work at all yet! -Lfloat tSVF_LP_getPhaseAtFrequency (tSVF_LP const svf, Lfloat freq) +Lfloat tSVF_LP_getPhaseAtFrequency (tSVF_LP* const svf, Lfloat freq) { Lfloat w = svf->invSampleRate * freq * TWO_PI; Lfloat c = 0.0f; @@ -1482,11 +1482,11 @@ void tEfficientSVF_init(tEfficientSVF *const svff, SVFType type, uint16_t input, tEfficientSVF_initToPool(svff, type, input, Q, &leaf->mempool); } -void tEfficientSVF_initToPool (tEfficientSVF *const svff, SVFType type, +void tEfficientSVF_initToPool (tEfficientSVF** const svff, SVFType type, uint16_t input, Lfloat Q, tMempool *const mp) { _tMempool *m = *mp; - _tEfficientSVF *svf = *svff = (_tEfficientSVF *) mpool_alloc(sizeof(_tEfficientSVF), m); + tEfficientSVF *svf = *svff = (tEfficientSVF *) mpool_alloc(sizeof(tEfficientSVF), m); svf->mempool = m; svf->type = type; @@ -1507,13 +1507,13 @@ void tEfficientSVF_initToPool (tEfficientSVF *const svff, SVFType type, svf->a3 = svf->g * svf->a2; } -void tEfficientSVF_free (tEfficientSVF *const svff) +void tEfficientSVF_free (tEfficientSVF** const svff) { - _tEfficientSVF *svf = *svff; + tEfficientSVF *svf = *svff; mpool_free((char *) svf, svf->mempool); } -Lfloat tEfficientSVF_tick (tEfficientSVF const svf, Lfloat v0) +Lfloat tEfficientSVF_tick (tEfficientSVF* const svf, Lfloat v0) { Lfloat v1, v2, v3; v3 = v0 - svf->ic2eq; @@ -1531,7 +1531,7 @@ Lfloat tEfficientSVF_tick (tEfficientSVF const svf, Lfloat v0) } -void tEfficientSVF_setFreq (tEfficientSVF const svf, Lfloat cutoff) +void tEfficientSVF_setFreq (tEfficientSVF* const svf, Lfloat cutoff) { cutoff *= 30.567164179104478f; int32_t intVer = (int32_t) cutoff; @@ -1547,7 +1547,7 @@ void tEfficientSVF_setFreq (tEfficientSVF const svf, Lfloat cutoff) svf->a3 = svf->g * svf->a2; } -void tEfficientSVF_setQ (tEfficientSVF const svf, Lfloat Q) +void tEfficientSVF_setQ (tEfficientSVF* const svf, Lfloat Q) { svf->k = 1.0f / Q; svf->a1 = 1.0f / (1.0f + svf->g * (svf->g + svf->k)); @@ -1555,7 +1555,7 @@ void tEfficientSVF_setQ (tEfficientSVF const svf, Lfloat Q) svf->a3 = svf->g * svf->a2; } -void tEfficientSVF_setFreqAndQ (tEfficientSVF const svf, uint16_t input, Lfloat Q) +void tEfficientSVF_setFreqAndQ (tEfficientSVF* const svf, uint16_t input, Lfloat Q) { svf->g = svf->table[input]; svf->k = 1.0f / Q; @@ -1564,7 +1564,7 @@ void tEfficientSVF_setFreqAndQ (tEfficientSVF const svf, uint16_t input, Lfloat svf->a3 = svf->g * svf->a2; } -void tEfficientSVF_setSampleRate (tEfficientSVF const svf, Lfloat sampleRate) +void tEfficientSVF_setSampleRate (tEfficientSVF* const svf, Lfloat sampleRate) { if (sampleRate > 80000) { svf->table = __filterTanhTable_96000; @@ -1581,15 +1581,15 @@ void tEfficientSVF_setSampleRate (tEfficientSVF const svf, Lfloat sampleRate) /******************************************************************************/ -void tHighpass_init (tHighpass *const ft, Lfloat freq, LEAF *const leaf) +void tHighpass_init (tHighpass* const ft, Lfloat freq, LEAF *const leaf) { tHighpass_initToPool(ft, freq, &leaf->mempool); } -void tHighpass_initToPool (tHighpass *const ft, Lfloat freq, tMempool *const mp) +void tHighpass_initToPool (tHighpass** const ft, Lfloat freq, tMempool *const mp) { _tMempool *m = *mp; - _tHighpass *f = *ft = (_tHighpass *) mpool_calloc(sizeof(_tHighpass), m); + tHighpass *f = *ft = (tHighpass *) mpool_calloc(sizeof(tHighpass), m); f->mempool = m; LEAF *leaf = f->mempool->leaf; @@ -1601,32 +1601,32 @@ void tHighpass_initToPool (tHighpass *const ft, Lfloat freq, tMempool *const mp) f->frequency = freq; } -void tHighpass_free (tHighpass *const ft) +void tHighpass_free (tHighpass** const ft) { - _tHighpass *f = *ft; + tHighpass *f = *ft; mpool_free((char *) f, f->mempool); } -void tHighpass_setFreq (tHighpass const f, Lfloat freq) +void tHighpass_setFreq (tHighpass* const f, Lfloat freq) { f->frequency = freq; f->R = (1.0f - (freq * f->twoPiTimesInvSampleRate)); } -Lfloat tHighpass_getFreq (tHighpass const f) +Lfloat tHighpass_getFreq (tHighpass* const f) { return f->frequency; } // From JOS DC Blocker -Lfloat tHighpass_tick (tHighpass const f, Lfloat x) +Lfloat tHighpass_tick (tHighpass* const f, Lfloat x) { f->ys = x - f->xs + f->R * f->ys; f->xs = x; return f->ys; } -void tHighpass_setSampleRate (tHighpass const f, Lfloat sr) +void tHighpass_setSampleRate (tHighpass* const f, Lfloat sr) { f->twoPiTimesInvSampleRate = TWO_PI * (1.0f / sr); f->R = (1.0f - (f->frequency * f->twoPiTimesInvSampleRate)); @@ -1638,17 +1638,17 @@ void tHighpass_setSampleRate (tHighpass const f, Lfloat sr) /******************************************************************************/ -void tButterworth_init (tButterworth *const ft, int order, Lfloat f1, Lfloat f2, +void tButterworth_init (tButterworth* const ft, int order, Lfloat f1, Lfloat f2, LEAF *const leaf) { tButterworth_initToPool(ft, order, f1, f2, &leaf->mempool); } -void tButterworth_initToPool (tButterworth *const ft, int order, Lfloat f1, +void tButterworth_initToPool (tButterworth** const ft, int order, Lfloat f1, Lfloat f2, tMempool *const mp) { _tMempool *m = *mp; - _tButterworth *f = *ft = (_tButterworth *) mpool_alloc(sizeof(_tButterworth), m); + tButterworth *f = *ft = (tButterworth *) mpool_alloc(sizeof(tButterworth), m); f->mempool = m; f->f1 = f1; @@ -1671,9 +1671,9 @@ void tButterworth_initToPool (tButterworth *const ft, int order, Lfloat f1, } } -void tButterworth_free (tButterworth *const ft) +void tButterworth_free (tButterworth** const ft) { - _tButterworth *f = *ft; + tButterworth *f = *ft; for (int i = 0; i < f->numSVF; ++i) tSVF_free(&f->svf[i]); @@ -1681,41 +1681,41 @@ void tButterworth_free (tButterworth *const ft) mpool_free((char *) f, f->mempool); } -Lfloat tButterworth_tick (tButterworth const f, Lfloat samp) +Lfloat tButterworth_tick (tButterworth* const f, Lfloat samp) { for (int i = 0; i < f->numSVF; ++i) - samp = tSVF_tick(f->svf[i], samp); + samp = tSVF_tick(&f->svf[i], samp); return samp; } -void tButterworth_setF1 (tButterworth const f, Lfloat f1) +void tButterworth_setF1 (tButterworth* const f, Lfloat f1) { if (f->f1 < 0.0f || f1 < 0.0f) return; f->f1 = f1; - for (int i = 0; i < f->order; ++i) tSVF_setFreq(f->svf[i], f1); + for (int i = 0; i < f->order; ++i) tSVF_setFreq(&f->svf[i], f1); } -void tButterworth_setF2 (tButterworth const f, Lfloat f2) +void tButterworth_setF2 (tButterworth* const f, Lfloat f2) { if (f->f2 < 0.0f || f2 < 0.0f) return; int o = 0; if (f->f1 >= 0.0f) o = f->order; f->f2 = f2; - for (int i = 0; i < f->order; ++i) tSVF_setFreq(f->svf[i + o], f2); + for (int i = 0; i < f->order; ++i) tSVF_setFreq(&f->svf[i + o], f2); } -void tButterworth_setFreqs (tButterworth const f, Lfloat f1, Lfloat f2) +void tButterworth_setFreqs (tButterworth* const f, Lfloat f1, Lfloat f2) { tButterworth_setF1(f, f1); tButterworth_setF2(f, f2); } -void tButterworth_setSampleRate (tButterworth const f, Lfloat sr) +void tButterworth_setSampleRate (tButterworth* const f, Lfloat sr) { - for (int i = 0; i < f->numSVF; ++i) tSVF_setSampleRate(f->svf[i], sr); + for (int i = 0; i < f->numSVF; ++i) tSVF_setSampleRate(&f->svf[i], sr); } @@ -1729,10 +1729,10 @@ void tFIR_init (tFIR *const firf, Lfloat *coeffs, int numTaps, LEAF *const leaf) tFIR_initToPool(firf, coeffs, numTaps, &leaf->mempool); } -void tFIR_initToPool (tFIR *const firf, Lfloat *coeffs, int numTaps, tMempool *const mp) +void tFIR_initToPool (tFIR** const firf, Lfloat *coeffs, int numTaps, tMempool *const mp) { _tMempool *m = *mp; - _tFIR *fir = *firf = (_tFIR *) mpool_alloc(sizeof(_tFIR), m); + tFIR *fir = *firf = (tFIR *) mpool_alloc(sizeof(tFIR), m); fir->mempool = m; fir->numTaps = numTaps; @@ -1741,15 +1741,15 @@ void tFIR_initToPool (tFIR *const firf, Lfloat *coeffs, int numTaps, tMempool *c for (int i = 0; i < fir->numTaps; ++i) fir->past[i] = 0.0f; } -void tFIR_free (tFIR *const firf) +void tFIR_free (tFIR** const firf) { - _tFIR *fir = *firf; + tFIR *fir = *firf; mpool_free((char *) fir->past, fir->mempool); mpool_free((char *) fir, fir->mempool); } -Lfloat tFIR_tick (tFIR const fir, Lfloat input) +Lfloat tFIR_tick (tFIR* const fir, Lfloat input) { fir->past[0] = input; Lfloat y = 0.0f; @@ -1775,10 +1775,10 @@ void tMedianFilter_init (tMedianFilter *const f, int size, LEAF *const leaf) tMedianFilter_initToPool(f, size, &leaf->mempool); } -void tMedianFilter_initToPool (tMedianFilter *const mf, int size, tMempool *const mp) +void tMedianFilter_initToPool (tMedianFilter** const mf, int size, tMempool *const mp) { _tMempool *m = *mp; - _tMedianFilter *f = *mf = (_tMedianFilter *) mpool_alloc(sizeof(_tMedianFilter), m); + tMedianFilter *f = *mf = (tMedianFilter *) mpool_alloc(sizeof(tMedianFilter), m); f->mempool = m; f->size = size; @@ -1794,16 +1794,16 @@ void tMedianFilter_initToPool (tMedianFilter *const mf, int size, tMempool *cons } -void tMedianFilter_free (tMedianFilter *const mf) +void tMedianFilter_free (tMedianFilter** const mf) { - _tMedianFilter *f = *mf; + tMedianFilter *f = *mf; mpool_free((char *) f->val, f->mempool); mpool_free((char *) f->age, f->mempool); mpool_free((char *) f, f->mempool); } -Lfloat tMedianFilter_tick (tMedianFilter const f, Lfloat input) +Lfloat tMedianFilter_tick (tMedianFilter* const f, Lfloat input) { for (int i = 0; i < f->size; i++) { int thisAge = f->age[i]; @@ -1845,17 +1845,17 @@ Lfloat tMedianFilter_tick (tMedianFilter const f, Lfloat input) /******************************************************************************/ -void tVZFilter_init (tVZFilter *const vf, VZFilterType type, Lfloat freq, +void tVZFilter_init (tVZFilter* const vf, VZFilterType type, Lfloat freq, Lfloat bandWidth, LEAF *const leaf) { tVZFilter_initToPool(vf, type, freq, bandWidth, &leaf->mempool); } -void tVZFilter_initToPool (tVZFilter *const vf, VZFilterType type, Lfloat freq, +void tVZFilter_initToPool (tVZFilter** const vf, VZFilterType type, Lfloat freq, Lfloat bandWidth, tMempool *const mp) { _tMempool *m = *mp; - _tVZFilter *f = *vf = (_tVZFilter *) mpool_alloc(sizeof(_tVZFilter), m); + tVZFilter *f = *vf = (tVZFilter *) mpool_alloc(sizeof(tVZFilter), m); f->mempool = m; LEAF *leaf = f->mempool->leaf; @@ -1886,13 +1886,13 @@ void tVZFilter_initToPool (tVZFilter *const vf, VZFilterType type, Lfloat freq, } } -void tVZFilter_free (tVZFilter *const vf) +void tVZFilter_free (tVZFilter** const vf) { - _tVZFilter *f = *vf; + tVZFilter *f = *vf; mpool_free((char *) f, f->mempool); } -Lfloat tVZFilter_tick (tVZFilter const f, Lfloat in) +Lfloat tVZFilter_tick (tVZFilter* const f, Lfloat in) { Lfloat yL, yB, yH, v1, v2; @@ -1924,7 +1924,7 @@ Lfloat tVZFilter_tick (tVZFilter const f, Lfloat in) return f->cL * yL + f->cB * yB + f->cH * yH; } -Lfloat tVZFilter_tickEfficient (tVZFilter const f, Lfloat in) +Lfloat tVZFilter_tickEfficient (tVZFilter* const f, Lfloat in) { Lfloat yL, yB, yH, v1, v2; @@ -1944,7 +1944,7 @@ Lfloat tVZFilter_tickEfficient (tVZFilter const f, Lfloat in) return f->cL * yL + f->cB * yB + f->cH * yH; } -void tVZFilter_calcCoeffs (tVZFilter const f) +void tVZFilter_calcCoeffs (tVZFilter* const f) { f->g = tanf(PI * f->fc * f->invSampleRate); // embedded integrator gain (Fig 3.11) @@ -2073,7 +2073,7 @@ void tVZFilter_calcCoeffs (tVZFilter const f) f->h = 1.0f / (1.0f + (f->R2 * f->g) + (f->g * f->g)); // factor for feedback precomputation } -void tVZFilter_calcCoeffsEfficientBP (tVZFilter const f) +void tVZFilter_calcCoeffsEfficientBP (tVZFilter* const f) { f->g = LEAF_clip(0.001f, fabsf(fastertanf(PI * f->fc * f->invSampleRate)), 1000.0f); // embedded integrator gain (Fig 3.11) // added absolute value because g can't be <=0 @@ -2082,20 +2082,20 @@ void tVZFilter_calcCoeffsEfficientBP (tVZFilter const f) f->h = 1.0f / (1.0f + f->R2 * f->g + f->g * f->g); // factor for feedback precomputation } -void tVZFilter_setBandwidth (tVZFilter const f, Lfloat B) +void tVZFilter_setBandwidth (tVZFilter* const f, Lfloat B) { f->B = LEAF_clip(0.0f, B, 100.0f); f->R2 = 2.0f * tVZFilter_BandwidthToR(f, f->B); tVZFilter_calcCoeffs(f); } -void tVZFilter_setFreq (tVZFilter const f, Lfloat freq) +void tVZFilter_setFreq (tVZFilter* const f, Lfloat freq) { f->fc = LEAF_clip(1.0f, freq, 0.5f * f->sampleRate); tVZFilter_calcCoeffs(f); } -void tVZFilter_setFreqFast (tVZFilter const f, Lfloat cutoff) +void tVZFilter_setFreqFast (tVZFilter* const f, Lfloat cutoff) { f->cutoffMIDI = cutoff; cutoff *= 30.567164179104478f; @@ -2235,35 +2235,35 @@ void tVZFilter_setFreqFast (tVZFilter const f, Lfloat cutoff) } -void tVZFilter_setFreqAndBandwidth (tVZFilter const f, Lfloat freq, Lfloat bw) +void tVZFilter_setFreqAndBandwidth (tVZFilter* const f, Lfloat freq, Lfloat bw) { f->B = LEAF_clip(0.0f, bw, 100.0f); f->fc = LEAF_clip(0.0f, freq, 0.5f * f->sampleRate); tVZFilter_calcCoeffs(f); } -void tVZFilter_setFreqAndBandwidthEfficientBP (tVZFilter const f, Lfloat freq, Lfloat bw) +void tVZFilter_setFreqAndBandwidthEfficientBP (tVZFilter* const f, Lfloat freq, Lfloat bw) { f->B = LEAF_clip(0.0f, bw, 100.0f); f->fc = LEAF_clip(0.0f, freq, 0.5f * f->sampleRate); tVZFilter_calcCoeffsEfficientBP(f); } -void tVZFilter_setGain (tVZFilter const f, Lfloat gain) +void tVZFilter_setGain (tVZFilter* const f, Lfloat gain) { f->G = LEAF_clip(0.000001f, gain, 4000.0f); f->invG = 1.0f / f->G; tVZFilter_calcCoeffs(f); } -void tVZFilter_setResonance (tVZFilter const f, Lfloat res) +void tVZFilter_setResonance (tVZFilter* const f, Lfloat res) { f->Q = LEAF_clip(0.01f, res, 100.0f); f->R2 = 1.0f / f->Q; tVZFilter_calcCoeffs(f); } -void tVZFilter_setFrequencyAndResonance (tVZFilter const f, Lfloat freq, Lfloat res) +void tVZFilter_setFrequencyAndResonance (tVZFilter* const f, Lfloat freq, Lfloat res) { f->fc = LEAF_clip(0.1f, freq, 0.4f * f->sampleRate); f->Q = LEAF_clip(0.01f, res, 100.0f); @@ -2271,7 +2271,7 @@ void tVZFilter_setFrequencyAndResonance (tVZFilter const f, Lfloat freq, Lfloat tVZFilter_calcCoeffs(f); } -void tVZFilter_setFrequencyAndResonanceAndGain ( tVZFilter const f, Lfloat freq, +void tVZFilter_setFrequencyAndResonanceAndGain (tVZFilter* const f, Lfloat freq, Lfloat res, Lfloat gain) { f->fc = LEAF_clip(0.1f, freq, 0.4f * f->sampleRate); @@ -2282,7 +2282,7 @@ void tVZFilter_setFrequencyAndResonanceAndGain ( tVZFilter const f, Lfloat freq, tVZFilter_calcCoeffs(f); } -void tVZFilter_setFastFrequencyAndResonanceAndGain (tVZFilter const f, Lfloat freq, +void tVZFilter_setFastFrequencyAndResonanceAndGain (tVZFilter* const f, Lfloat freq, Lfloat res, Lfloat gain) { f->Q = LEAF_clip(0.01f, res, 100.0f); @@ -2293,7 +2293,7 @@ void tVZFilter_setFastFrequencyAndResonanceAndGain (tVZFilter const f, Lfloat fr tVZFilter_setFreqFast(f, freq); } -void tVZFilter_setFrequencyAndBandwidthAndGain (tVZFilter const f, Lfloat freq, +void tVZFilter_setFrequencyAndBandwidthAndGain (tVZFilter* const f, Lfloat freq, Lfloat BW, Lfloat gain) { f->fc = LEAF_clip(0.1f, freq, 0.4f * f->sampleRate); @@ -2305,7 +2305,7 @@ void tVZFilter_setFrequencyAndBandwidthAndGain (tVZFilter const f, Lfloat freq, } -void tVZFilter_setFrequencyAndResonanceAndMorph (tVZFilter const f, Lfloat freq, +void tVZFilter_setFrequencyAndResonanceAndMorph (tVZFilter* const f, Lfloat freq, Lfloat res, Lfloat morph) { f->fc = LEAF_clip(0.1f, freq, 0.4f * f->sampleRate); @@ -2315,25 +2315,25 @@ void tVZFilter_setFrequencyAndResonanceAndMorph (tVZFilter const f, Lfloat freq, tVZFilter_calcCoeffs(f); } -void tVZFilter_setMorph (tVZFilter const f, Lfloat morph) +void tVZFilter_setMorph (tVZFilter* const f, Lfloat morph) { f->m = LEAF_clip(0.0f, morph, 1.0f); tVZFilter_calcCoeffs(f); } -void tVZFilter_setMorphOnly (tVZFilter const f, Lfloat morph) +void tVZFilter_setMorphOnly (tVZFilter* const f, Lfloat morph) { f->m = LEAF_clip(0.0f, morph, 1.0f); //tVZFilter_calcCoeffs(vf); } -void tVZFilter_setType (tVZFilter const f, VZFilterType type) +void tVZFilter_setType (tVZFilter* const f, VZFilterType type) { f->type = type; tVZFilter_calcCoeffs(f); } -Lfloat tVZFilter_BandwidthToR (tVZFilter const f, Lfloat B) +Lfloat tVZFilter_BandwidthToR (tVZFilter* const f, Lfloat B) { Lfloat fl = f->fc * powf(2.0f, -B * 0.5f); // lower bandedge frequency (in Hz) Lfloat gl = tanf(PI * fl * f->invSampleRate); // warped radian lower bandedge frequency /(2*fs) @@ -2343,7 +2343,7 @@ Lfloat tVZFilter_BandwidthToR (tVZFilter const f, Lfloat B) return sqrtf((1.0f - r * r) * (1.0f - r * r) / (4.0f * r * r)); } -Lfloat tVZFilter_BandwidthToREfficientBP (tVZFilter const f, Lfloat B) +Lfloat tVZFilter_BandwidthToREfficientBP (tVZFilter* const f, Lfloat B) { Lfloat fl = f->fc * fastPowf(2.0f, -B * 0.5f); // lower bandedge frequency (in Hz) Lfloat gl = fastertanf(PI * fl * f->invSampleRate); // warped radian lower bandedge frequency /(2*fs) @@ -2353,7 +2353,7 @@ Lfloat tVZFilter_BandwidthToREfficientBP (tVZFilter const f, Lfloat B) return fastsqrtf((1.0f - r * r) * (1.0f - r * r) / (4.0f * r * r)); } -void tVZFilter_setSampleRate (tVZFilter const f, Lfloat sr) +void tVZFilter_setSampleRate (tVZFilter* const f, Lfloat sr) { f->sampleRate = sr; f->invSampleRate = 1.0f / f->sampleRate; @@ -2371,17 +2371,17 @@ void tVZFilter_setSampleRate (tVZFilter const f, Lfloat sr) /******************************************************************************/ -void tVZFilterLS_init (tVZFilterLS *const vf, Lfloat freq, Lfloat Q, Lfloat gain, +void tVZFilterLS_init (tVZFilterLS* const vf, Lfloat freq, Lfloat Q, Lfloat gain, LEAF *const leaf) { tVZFilterLS_initToPool(vf, freq, Q, gain, &leaf->mempool); } -void tVZFilterLS_initToPool (tVZFilterLS *const vf, Lfloat freq, Lfloat Q, +void tVZFilterLS_initToPool (tVZFilterLS** const vf, Lfloat freq, Lfloat Q, Lfloat gain, tMempool *const mp) { _tMempool *m = *mp; - _tVZFilterLS *f = *vf = (_tVZFilterLS *) mpool_alloc(sizeof(_tVZFilterLS), m); + tVZFilterLS *f = *vf = (tVZFilterLS *) mpool_alloc(sizeof(tVZFilterLS), m); f->mempool = m; LEAF *leaf = f->mempool->leaf; @@ -2408,13 +2408,13 @@ void tVZFilterLS_initToPool (tVZFilterLS *const vf, Lfloat freq, Lfloat Q, } } -void tVZFilterLS_free (tVZFilterLS *const vf) +void tVZFilterLS_free (tVZFilterLS** const vf) { - _tVZFilterLS *f = *vf; + tVZFilterLS *f = *vf; mpool_free((char *) f, f->mempool); } -void tVZFilterLS_setSampleRate (tVZFilterLS const f, Lfloat sampleRate) +void tVZFilterLS_setSampleRate (tVZFilterLS* const f, Lfloat sampleRate) { f->sampleRate = sampleRate; f->invSampleRate = 1.0f / sampleRate; @@ -2426,7 +2426,7 @@ void tVZFilterLS_setSampleRate (tVZFilterLS const f, Lfloat sampleRate) } } -Lfloat tVZFilterLS_tick (tVZFilterLS const f, Lfloat input) +Lfloat tVZFilterLS_tick (tVZFilterLS* const f, Lfloat input) { Lfloat yL, yB, yH, v1, v2; @@ -2446,7 +2446,7 @@ Lfloat tVZFilterLS_tick (tVZFilterLS const f, Lfloat input) return f->G * yL + f->R2 * f->G * yB + yH; } -void tVZFilterLS_setFreqFast (tVZFilterLS const f, Lfloat cutoff) +void tVZFilterLS_setFreqFast (tVZFilterLS* const f, Lfloat cutoff) { f->cutoffMIDI = cutoff; cutoff *= 30.567164179104478f; @@ -2465,12 +2465,12 @@ void tVZFilterLS_setFreqFast (tVZFilterLS const f, Lfloat cutoff) f->h = 1.0f / (1.0f + (f->R2 * f->g) + (f->g * f->g)); // factor for feedback } -void tVZFilterLS_setBandwidthSlow (tVZFilterLS const f, Lfloat bandWidth) +void tVZFilterLS_setBandwidthSlow (tVZFilterLS* const f, Lfloat bandWidth) { f->R2 = 2.0f * sinhf(bandWidth * logf(2.0f) * 0.5f); } -void tVZFilterLS_setFreq (tVZFilterLS const f, Lfloat freq) +void tVZFilterLS_setFreq (tVZFilterLS* const f, Lfloat freq) { f->g = tanf(PI * freq * f->invSampleRate); f->g = f->gPreDiv * f->invSqrtA; // scale SVF-cutoff frequency for shelvers @@ -2478,7 +2478,7 @@ void tVZFilterLS_setFreq (tVZFilterLS const f, Lfloat freq) f->h = 1.0f / (1.0f + (f->R2 * f->g) + (f->g * f->g)); // factor for feedback } -void tVZFilterLS_setGain (tVZFilterLS const f, Lfloat gain) +void tVZFilterLS_setGain (tVZFilterLS* const f, Lfloat gain) { f->G = LEAF_clip(0.000001f, gain, 4000.0f); f->invSqrtA = 1.0f / (fastsqrtf(fastsqrtf(f->G))); @@ -2487,7 +2487,7 @@ void tVZFilterLS_setGain (tVZFilterLS const f, Lfloat gain) f->h = 1.0f / (1.0f + (f->R2 * f->g) + (f->g * f->g)); // factor for feedback } -void tVZFilterLS_setResonance (tVZFilterLS const f, Lfloat res) +void tVZFilterLS_setResonance (tVZFilterLS* const f, Lfloat res) { f->Q = res; f->R2 = 1.0f / res; @@ -2495,7 +2495,7 @@ void tVZFilterLS_setResonance (tVZFilterLS const f, Lfloat res) f->h = 1.0f / (1.0f + (f->R2 * f->g) + (f->g * f->g)); // factor for feedback } -void tVZFilterLS_setFreqFastAndResonanceAndGain (tVZFilterLS const f, Lfloat cutoff, +void tVZFilterLS_setFreqFastAndResonanceAndGain (tVZFilterLS* const f, Lfloat cutoff, Lfloat res, Lfloat gain) { f->cutoffMIDI = cutoff; @@ -2536,11 +2536,11 @@ void tVZFilterHS_init (tVZFilterHS *const vf, Lfloat freq, Lfloat Q, Lfloat gain tVZFilterHS_initToPool(vf, freq, Q, gain, &leaf->mempool); } -void tVZFilterHS_initToPool (tVZFilterHS *const vf, Lfloat freq, Lfloat Q, +void tVZFilterHS_initToPool (tVZFilterHS** const vf, Lfloat freq, Lfloat Q, Lfloat gain, tMempool *const mp) { _tMempool *m = *mp; - _tVZFilterHS *f = *vf = (_tVZFilterHS *) mpool_alloc(sizeof(_tVZFilterHS), m); + tVZFilterHS *f = *vf = (tVZFilterHS *) mpool_alloc(sizeof(tVZFilterHS), m); f->mempool = m; LEAF *leaf = f->mempool->leaf; @@ -2567,13 +2567,13 @@ void tVZFilterHS_initToPool (tVZFilterHS *const vf, Lfloat freq, Lfloat Q, } } -void tVZFilterHS_free (tVZFilterHS *const vf) +void tVZFilterHS_free (tVZFilterHS** const vf) { - _tVZFilterHS *f = *vf; + tVZFilterHS *f = *vf; mpool_free((char *) f, f->mempool); } -void tVZFilterHS_setSampleRate (tVZFilterHS const f, Lfloat sampleRate) +void tVZFilterHS_setSampleRate (tVZFilterHS* const f, Lfloat sampleRate) { f->sampleRate = sampleRate; f->invSampleRate = 1.0f / sampleRate; @@ -2585,7 +2585,7 @@ void tVZFilterHS_setSampleRate (tVZFilterHS const f, Lfloat sampleRate) } } -Lfloat tVZFilterHS_tick (tVZFilterHS const f, Lfloat input) +Lfloat tVZFilterHS_tick (tVZFilterHS* const f, Lfloat input) { Lfloat yL, yB, yH, v1, v2; @@ -2605,7 +2605,7 @@ Lfloat tVZFilterHS_tick (tVZFilterHS const f, Lfloat input) return yL + f->R2 * f->G * yB + f->G * yH; } -void tVZFilterHS_setFreqFast (tVZFilterHS const f, Lfloat cutoff) +void tVZFilterHS_setFreqFast (tVZFilterHS* const f, Lfloat cutoff) { f->cutoffMIDI = cutoff; cutoff *= 30.567164179104478f; @@ -2625,12 +2625,12 @@ void tVZFilterHS_setFreqFast (tVZFilterHS const f, Lfloat cutoff) f->h = 1.0f / (1.0f + (f->R2 * f->g) + (f->g * f->g)); // factor for feedback } -void tVZFilterHS_setBandwidthSlow (tVZFilterHS const f, Lfloat bandWidth) +void tVZFilterHS_setBandwidthSlow (tVZFilterHS* const f, Lfloat bandWidth) { f->R2 = 2.0f * sinhf(bandWidth * logf(2.0f) * 0.5f); } -void tVZFilterHS_setFreq (tVZFilterHS const f, Lfloat freq) +void tVZFilterHS_setFreq (tVZFilterHS* const f, Lfloat freq) { f->gPreDiv = tanf(PI * freq * f->invSampleRate); f->g = f->gPreDiv * f->sqrtA; // scale SVF-cutoff frequency for shelvers @@ -2639,7 +2639,7 @@ void tVZFilterHS_setFreq (tVZFilterHS const f, Lfloat freq) f->h = 1.0f / (1.0f + (f->R2 * f->g) + (f->g * f->g)); // factor for feedback } -void tVZFilterHS_setGain (tVZFilterHS const f, Lfloat gain) +void tVZFilterHS_setGain (tVZFilterHS* const f, Lfloat gain) { f->G = LEAF_clip(0.000001f, gain, 4000.0f); f->sqrtA = fastsqrtf(fastsqrtf(f->G)); @@ -2648,7 +2648,7 @@ void tVZFilterHS_setGain (tVZFilterHS const f, Lfloat gain) f->h = 1.0f / (1.0f + (f->R2 * f->g) + (f->g * f->g)); // factor for feedback } -void tVZFilterHS_setResonance (tVZFilterHS const f, Lfloat res) +void tVZFilterHS_setResonance (tVZFilterHS* const f, Lfloat res) { f->Q = res; f->R2 = 1.0f / res; @@ -2657,7 +2657,7 @@ void tVZFilterHS_setResonance (tVZFilterHS const f, Lfloat res) } -void tVZFilterHS_setFreqFastAndResonanceAndGain (tVZFilterHS const f, Lfloat cutoff, +void tVZFilterHS_setFreqFastAndResonanceAndGain (tVZFilterHS* const f, Lfloat cutoff, Lfloat res, Lfloat gain) { f->cutoffMIDI = cutoff; @@ -2693,17 +2693,17 @@ void tVZFilterHS_setFreqFastAndResonanceAndGain (tVZFilterHS const f, Lfloat cut /******************************************************************************/ -void tVZFilterBell_init (tVZFilterBell *const vf, Lfloat freq, Lfloat BW, +void tVZFilterBell_init (tVZFilterBell* const vf, Lfloat freq, Lfloat BW, Lfloat gain, LEAF *const leaf) { tVZFilterBell_initToPool(vf, freq, BW, gain, &leaf->mempool); } -void tVZFilterBell_initToPool (tVZFilterBell *const vf, Lfloat freq, Lfloat BW, +void tVZFilterBell_initToPool (tVZFilterBell** const vf, Lfloat freq, Lfloat BW, Lfloat gain, tMempool *const mp) { _tMempool *m = *mp; - _tVZFilterBell *f = *vf = (_tVZFilterBell *) mpool_alloc(sizeof(_tVZFilterBell), m); + tVZFilterBell *f = *vf = (tVZFilterBell *) mpool_alloc(sizeof(tVZFilterBell), m); f->mempool = m; LEAF *leaf = f->mempool->leaf; @@ -2734,13 +2734,13 @@ void tVZFilterBell_initToPool (tVZFilterBell *const vf, Lfloat freq, Lfloat BW, } } -void tVZFilterBell_free (tVZFilterBell *const vf) +void tVZFilterBell_free (tVZFilterBell** const vf) { - _tVZFilterBell *f = *vf; + tVZFilterBell *f = *vf; mpool_free((char *) f, f->mempool); } -void tVZFilterBell_setSampleRate (tVZFilterBell const f, Lfloat sampleRate) +void tVZFilterBell_setSampleRate (tVZFilterBell* const f, Lfloat sampleRate) { f->sampleRate = sampleRate; f->invSampleRate = 1.0f / sampleRate; @@ -2752,7 +2752,7 @@ void tVZFilterBell_setSampleRate (tVZFilterBell const f, Lfloat sampleRate) } } -Lfloat tVZFilterBell_tick (tVZFilterBell const f, Lfloat input) +Lfloat tVZFilterBell_tick (tVZFilterBell* const f, Lfloat input) { Lfloat yL, yB, yH, v1, v2; @@ -2774,7 +2774,7 @@ Lfloat tVZFilterBell_tick (tVZFilterBell const f, Lfloat input) //relies on a call to set Freq after -void tVZFilterBell_setBandwidth (tVZFilterBell const f, Lfloat bandWidth) +void tVZFilterBell_setBandwidth (tVZFilterBell* const f, Lfloat bandWidth) { f->B = bandWidth; //Lfloat fl = f->fc*fastPowf(2.0f, (-f->B)*0.5f); // lower bandedge frequency (in Hz) @@ -2786,7 +2786,7 @@ void tVZFilterBell_setBandwidth (tVZFilterBell const f, Lfloat bandWidth) //f->R2 = 2.0f*fastsqrtf(((r*r+1.0f)/r-2.0f)/(4.0f*f->G)); } -void tVZFilterBell_setFreq (tVZFilterBell const f, Lfloat freq) +void tVZFilterBell_setFreq (tVZFilterBell* const f, Lfloat freq) { f->fc = freq; f->g = tanf(PI * freq * f->invSampleRate); @@ -2801,7 +2801,7 @@ void tVZFilterBell_setFreq (tVZFilterBell const f, Lfloat freq) f->h = 1.0f / (1.0f + (f->R2 * f->g) + (f->g * f->g)); // factor for feedback } -void tVZFilterBell_setFreqFast (tVZFilterBell const f, Lfloat cutoff) +void tVZFilterBell_setFreqFast (tVZFilterBell* const f, Lfloat cutoff) { f->cutoffMIDI = cutoff; cutoff *= 30.567164179104478f; @@ -2834,7 +2834,7 @@ void tVZFilterBell_setFreqFast (tVZFilterBell const f, Lfloat cutoff) f->h = 1.0f / (1.0f + (f->R2 * f->g) + (f->g * f->g)); // factor for feedback } -void tVZFilterBell_setFreqAndGainFast (tVZFilterBell const f, Lfloat cutoff, +void tVZFilterBell_setFreqAndGainFast (tVZFilterBell* const f, Lfloat cutoff, Lfloat gain) { f->cutoffMIDI = cutoff; @@ -2870,7 +2870,7 @@ void tVZFilterBell_setFreqAndGainFast (tVZFilterBell const f, Lfloat cutoff, } -void tVZFilterBell_setGain (tVZFilterBell const f, Lfloat gain) +void tVZFilterBell_setGain (tVZFilterBell* const f, Lfloat gain) { f->G = LEAF_clip(0.000001f, gain, 4000.0f); f->R2 = 2.0f * fastsqrtf(((f->rToUse * f->rToUse + 1.0f) / f->rToUse - 2.0f) / (4.0f * f->G)); @@ -2878,7 +2878,7 @@ void tVZFilterBell_setGain (tVZFilterBell const f, Lfloat gain) f->h = 1.0f / (1.0f + (f->R2 * f->g) + (f->g * f->g)); // factor for feedback } -void tVZFilterBell_setFrequencyAndGain (tVZFilterBell const f, Lfloat freq, Lfloat gain) +void tVZFilterBell_setFrequencyAndGain (tVZFilterBell* const f, Lfloat freq, Lfloat gain) { f->fc = freq; f->G = LEAF_clip(0.000001f, gain, 4000.0f); @@ -2894,7 +2894,7 @@ void tVZFilterBell_setFrequencyAndGain (tVZFilterBell const f, Lfloat freq, Lflo f->h = 1.0f / (1.0f + (f->R2 * f->g) + (f->g * f->g)); // factor for feedback } -void tVZFilterBell_setFrequencyAndBandwidthAndGain (tVZFilterBell const f, Lfloat freq, Lfloat bandwidth, Lfloat gain) +void tVZFilterBell_setFrequencyAndBandwidthAndGain (tVZFilterBell* const f, Lfloat freq, Lfloat bandwidth, Lfloat gain) { f->fc = freq; f->B = bandwidth; @@ -2911,7 +2911,7 @@ void tVZFilterBell_setFrequencyAndBandwidthAndGain (tVZFilterBell const f, Lfloa f->h = 1.0f / (1.0f + (f->R2 * f->g) + (f->g * f->g)); // factor for feedback } -void tVZFilterBell_setFreqAndBWAndGainFast (tVZFilterBell const f, Lfloat cutoff, Lfloat BW, Lfloat gain) +void tVZFilterBell_setFreqAndBWAndGainFast (tVZFilterBell* const f, Lfloat cutoff, Lfloat BW, Lfloat gain) { f->cutoffMIDI = cutoff; f->B = BW; @@ -2953,15 +2953,15 @@ void tVZFilterBell_setFreqAndBWAndGainFast (tVZFilterBell const f, Lfloat cutoff /******************************************************************************/ -void tVZFilterBR_init (tVZFilterBR *const vf, Lfloat freq, Lfloat Q, LEAF *const leaf) +void tVZFilterBR_init (tVZFilterBR* const vf, Lfloat freq, Lfloat Q, LEAF *const leaf) { tVZFilterBR_initToPool(vf, freq, Q, &leaf->mempool); } -void tVZFilterBR_initToPool (tVZFilterBR *const vf, Lfloat freq, Lfloat Q, tMempool *const mp) +void tVZFilterBR_initToPool (tVZFilterBR** const vf, Lfloat freq, Lfloat Q, tMempool *const mp) { _tMempool *m = *mp; - _tVZFilterBR *f = *vf = (_tVZFilterBR *) mpool_alloc(sizeof(_tVZFilterBR), m); + tVZFilterBR *f = *vf = (tVZFilterBR *) mpool_alloc(sizeof(tVZFilterBR), m); f->mempool = m; LEAF *leaf = f->mempool->leaf; @@ -2985,13 +2985,13 @@ void tVZFilterBR_initToPool (tVZFilterBR *const vf, Lfloat freq, Lfloat Q, tMemp } } -void tVZFilterBR_free (tVZFilterBR *const vf) +void tVZFilterBR_free (tVZFilterBR** const vf) { - _tVZFilterBR *f = *vf; + tVZFilterBR *f = *vf; mpool_free((char *) f, f->mempool); } -void tVZFilterBR_setSampleRate (tVZFilterBR const f, Lfloat sampleRate) +void tVZFilterBR_setSampleRate (tVZFilterBR* const f, Lfloat sampleRate) { f->sampleRate = sampleRate; f->invSampleRate = 1.0f / sampleRate; @@ -3003,7 +3003,7 @@ void tVZFilterBR_setSampleRate (tVZFilterBR const f, Lfloat sampleRate) } } -Lfloat tVZFilterBR_tick (tVZFilterBR const f, Lfloat input) +Lfloat tVZFilterBR_tick (tVZFilterBR* const f, Lfloat input) { Lfloat yL, yB, yH, v1, v2; @@ -3023,7 +3023,7 @@ Lfloat tVZFilterBR_tick (tVZFilterBR const f, Lfloat input) return (yH + yL) * f->G; } -void tVZFilterBR_setFreqFast (tVZFilterBR const f, Lfloat cutoff) +void tVZFilterBR_setFreqFast (tVZFilterBR* const f, Lfloat cutoff) { f->cutoffMIDI = cutoff; cutoff *= 30.567164179104478f; @@ -3041,12 +3041,12 @@ void tVZFilterBR_setFreqFast (tVZFilterBR const f, Lfloat cutoff) } -void tVZFilterBR_setGain (tVZFilterBR const f, Lfloat gain) +void tVZFilterBR_setGain (tVZFilterBR* const f, Lfloat gain) { f->G = gain; } -void tVZFilterBR_setFreq (tVZFilterBR const f, Lfloat freq) +void tVZFilterBR_setFreq (tVZFilterBR* const f, Lfloat freq) { f->g = tanf(PI * freq * f->invSampleRate); f->R2Plusg = f->R2 + f->g; @@ -3054,14 +3054,14 @@ void tVZFilterBR_setFreq (tVZFilterBR const f, Lfloat freq) } -void tVZFilterBR_setResonance (tVZFilterBR const f, Lfloat res) +void tVZFilterBR_setResonance (tVZFilterBR* const f, Lfloat res) { f->R2 = 1.0f / res; f->R2Plusg = f->R2 + f->g; f->h = 1.0f / (1.0f + (f->R2 * f->g) + (f->g * f->g)); // factor for feedback } -void tVZFilterBR_setFreqAndResonanceFast (tVZFilterBR const f, Lfloat cutoff, Lfloat res) +void tVZFilterBR_setFreqAndResonanceFast (tVZFilterBR* const f, Lfloat cutoff, Lfloat res) { f->R2 = 1.0f / res; f->cutoffMIDI = cutoff; @@ -3090,17 +3090,17 @@ void tVZFilterBR_setFreqAndResonanceFast (tVZFilterBR const f, Lfloat cutoff, Lf //taken from Ivan C's model of the EMS diode ladder, based on mystran's code from KVR forums //https://www.kvraudio.com/forum/viewtopic.php?f=33&t=349859&start=255 -void tDiodeFilter_init (tDiodeFilter *const vf, Lfloat cutoff, Lfloat resonance, +void tDiodeFilter_init (tDiodeFilter* const vf, Lfloat cutoff, Lfloat resonance, LEAF *const leaf) { tDiodeFilter_initToPool(vf, cutoff, resonance, &leaf->mempool); } -void tDiodeFilter_initToPool (tDiodeFilter *const vf, Lfloat cutoff, Lfloat resonance, +void tDiodeFilter_initToPool (tDiodeFilter** const vf, Lfloat cutoff, Lfloat resonance, tMempool *const mp) { _tMempool *m = *mp; - _tDiodeFilter *f = *vf = (_tDiodeFilter *) mpool_alloc(sizeof(_tDiodeFilter), m); + tDiodeFilter *f = *vf = (tDiodeFilter *) mpool_alloc(sizeof(tDiodeFilter), m); f->mempool = m; LEAF *leaf = f->mempool->leaf; @@ -3130,9 +3130,9 @@ void tDiodeFilter_initToPool (tDiodeFilter *const vf, Lfloat cutoff, Lfloat reso } } -void tDiodeFilter_free (tDiodeFilter *const vf) +void tDiodeFilter_free (tDiodeFilter**const vf) { - _tDiodeFilter *f = *vf; + tDiodeFilter *f = *vf; mpool_free((char *) f, f->mempool); } @@ -3153,7 +3153,7 @@ Lfloat tanhXdX (Lfloat x) } -Lfloat tDiodeFilter_tick (tDiodeFilter const f, Lfloat in) +Lfloat tDiodeFilter_tick (tDiodeFilter* const f, Lfloat in) { // the input x[n+1] is given by 'in', and x[n] by zi // input with half delay @@ -3210,7 +3210,7 @@ Lfloat tDiodeFilter_tick (tDiodeFilter const f, Lfloat in) return tanhf(y3 * f->r); } -Lfloat tDiodeFilter_tickEfficient (tDiodeFilter const f, Lfloat in) +Lfloat tDiodeFilter_tickEfficient (tDiodeFilter* const f, Lfloat in) { // the input x[n+1] is given by 'in', and x[n] by zi // input with half delay @@ -3269,13 +3269,13 @@ Lfloat tDiodeFilter_tickEfficient (tDiodeFilter const f, Lfloat in) return fast_tanh5(y3 * f->r); } -void tDiodeFilter_setFreq (tDiodeFilter const f, Lfloat cutoff) +void tDiodeFilter_setFreq (tDiodeFilter* const f, Lfloat cutoff) { f->cutoff = LEAF_clip(40.0f, cutoff, 18000.0f); f->f = tanf(TWO_PI * f->cutoff * f->invSampleRate); } -void tDiodeFilter_setFreqFast (tDiodeFilter const f, Lfloat cutoff) +void tDiodeFilter_setFreqFast (tDiodeFilter* const f, Lfloat cutoff) { cutoff = LEAF_clip(10.0f, cutoff + 11.13f, 140.0f);//compensate for tuning error f->cutoffMIDI = cutoff; @@ -3292,13 +3292,13 @@ void tDiodeFilter_setFreqFast (tDiodeFilter const f, Lfloat cutoff) f->f = ((f->table[intVer] * (1.0f - LfloatVer)) + (f->table[intVer + 1] * LfloatVer)) * f->sampRatio; } -void tDiodeFilter_setQ (tDiodeFilter const f, Lfloat resonance) +void tDiodeFilter_setQ (tDiodeFilter* const f, Lfloat resonance) { //f->r = LEAF_clip(0.5f, (7.0f * resonance + 0.5f), 20.0f); f->r = LEAF_clip(0.5f, resonance * 2.0f, 20.0f); } -void tDiodeFilter_setSampleRate(tDiodeFilter const f, Lfloat sr) { +void tDiodeFilter_setSampleRate(tDiodeFilter* const f, Lfloat sr) { f->invSampleRate = 1.0f / sr; f->sampRatio = 48000.0f / sr; if (sr > 80000) { @@ -3314,17 +3314,17 @@ void tDiodeFilter_setSampleRate(tDiodeFilter const f, Lfloat sr) { /******************************************************************************/ -void tLadderFilter_init (tLadderFilter *const vf, Lfloat cutoff, Lfloat resonance, +void tLadderFilter_init (tLadderFilter* const vf, Lfloat cutoff, Lfloat resonance, LEAF *const leaf) { tLadderFilter_initToPool(vf, cutoff, resonance, &leaf->mempool); } -void tLadderFilter_initToPool (tLadderFilter *const vf, Lfloat cutoff, +void tLadderFilter_initToPool (tLadderFilter** const vf, Lfloat cutoff, Lfloat resonance, tMempool *const mp) { _tMempool *m = *mp; - _tLadderFilter *f = *vf = (_tLadderFilter *) mpool_alloc(sizeof(_tLadderFilter), m); + tLadderFilter *f = *vf = (tLadderFilter *) mpool_alloc(sizeof(tLadderFilter), m); f->mempool = m; LEAF *leaf = f->mempool->leaf; @@ -3359,9 +3359,9 @@ void tLadderFilter_initToPool (tLadderFilter *const vf, Lfloat cutoff, } } -void tLadderFilter_free (tLadderFilter *const vf) +void tLadderFilter_free (tLadderFilter** const vf) { - _tLadderFilter *f = *vf; + tLadderFilter *f = *vf; mpool_free((char *) f, f->mempool); } @@ -3394,7 +3394,7 @@ Lfloat tanhd (const Lfloat x, const Lfloat d, const Lfloat s) return 1.0f - s * (d + 1.0f) * x * x / (d + x * x); } -Lfloat tLadderFilter_tick (tLadderFilter const f, Lfloat in) +Lfloat tLadderFilter_tick (tLadderFilter* const f, Lfloat in) { Lfloat y3 = 0.0f; in += 0.015f; @@ -3455,14 +3455,14 @@ Lfloat tLadderFilter_tick (tLadderFilter const f, Lfloat in) return fast_tanh5(y3 * compensation); } -void tLadderFilter_setFreq (tLadderFilter const f, Lfloat cutoff) +void tLadderFilter_setFreq (tLadderFilter* const f, Lfloat cutoff) { f->cutoff = LEAF_clip(40.0f, cutoff, 18000.0f); f->c = tanf(PI * (f->cutoff * f->invOS) * f->invSampleRate); f->c2 = 2.0f * f->c; } -void tLadderFilter_setFreqFast (tLadderFilter const f, Lfloat cutoff) +void tLadderFilter_setFreqFast (tLadderFilter* const f, Lfloat cutoff) { cutoff += 3.0f; f->cutoffMIDI = cutoff; @@ -3481,12 +3481,12 @@ void tLadderFilter_setFreqFast (tLadderFilter const f, Lfloat cutoff) f->c2 = 2.0f * f->c; } -void tLadderFilter_setQ (tLadderFilter const f, Lfloat resonance) +void tLadderFilter_setQ (tLadderFilter* const f, Lfloat resonance) { f->fb = LEAF_clip(0.2f, resonance, 24.0f); } -void tLadderFilter_setSampleRate (tLadderFilter const f, Lfloat sr) +void tLadderFilter_setSampleRate (tLadderFilter* const f, Lfloat sr) { f->invSampleRate = 1.0f / sr; f->sampleRatio = 48000.0f / sr * f->invOS; @@ -3498,7 +3498,7 @@ void tLadderFilter_setSampleRate (tLadderFilter const f, Lfloat sr) } -void tLadderFilter_setOversampling (tLadderFilter const f, int os) +void tLadderFilter_setOversampling (tLadderFilter* const f, int os) { f->oversampling = os; f->invOS = 1.0f / ((Lfloat) os); @@ -3522,10 +3522,10 @@ void tTiltFilter_init (tTiltFilter *const vf, Lfloat cutoff, LEAF *const leaf) tTiltFilter_initToPool(vf, cutoff, &leaf->mempool); } -void tTiltFilter_initToPool (tTiltFilter *const vf, Lfloat cutoff, tMempool *const mp) +void tTiltFilter_initToPool (tTiltFilter** const vf, Lfloat cutoff, tMempool *const mp) { _tMempool *m = *mp; - _tTiltFilter *f = *vf = (_tTiltFilter *) mpool_alloc(sizeof(_tTiltFilter), m); + tTiltFilter *f = *vf = (tTiltFilter *) mpool_alloc(sizeof(tTiltFilter), m); f->mempool = m; LEAF *leaf = f->mempool->leaf; @@ -3541,20 +3541,20 @@ void tTiltFilter_initToPool (tTiltFilter *const vf, Lfloat cutoff, tMempool *con f->b1 = (f->sr3 - omega) * n; } -void tTiltFilter_free (tTiltFilter *const vf) +void tTiltFilter_free (tTiltFilter** const vf) { - _tTiltFilter *f = *vf; + tTiltFilter *f = *vf; mpool_free((char *) f, f->mempool); } -Lfloat tTiltFilter_tick (tTiltFilter const f, Lfloat in) +Lfloat tTiltFilter_tick (tTiltFilter* const f, Lfloat in) { f->lp_out = f->a0 * in + f->b1 * f->lp_out; return in + f->lgain * f->lp_out + f->hgain * (in - f->lp_out); } -void tTiltFilter_setTilt (tTiltFilter const f, Lfloat tilt) +void tTiltFilter_setTilt (tTiltFilter* const f, Lfloat tilt) { Lfloat g1; Lfloat g2; @@ -3571,7 +3571,7 @@ void tTiltFilter_setTilt (tTiltFilter const f, Lfloat tilt) f->hgain = fasterexpf(g2 * f->invAmp) - 1.0f; } -void tTiltFilter_setSampleRate (tTiltFilter const f, Lfloat sr) +void tTiltFilter_setSampleRate (tTiltFilter* const f, Lfloat sr) { f->sr3 = sr * 3.0f; Lfloat omega = TWO_PI * f->cutoff; diff --git a/leaf/Src/leaf-instruments.c b/leaf/Src/leaf-instruments.c index 54003fd..2f83d0e 100644 --- a/leaf/Src/leaf-instruments.c +++ b/leaf/Src/leaf-instruments.c @@ -23,17 +23,17 @@ void t808Cowbell_init(t808Cowbell* const cowbellInst, int useStick, LEAF* const t808Cowbell_initToPool(cowbellInst, useStick, &leaf->mempool); } -void t808Cowbell_initToPool (t808Cowbell* const cowbellInst, int useStick, tMempool* const mp) +void t808Cowbell_initToPool (t808Cowbell** const cowbellInst, int useStick, tMempool* const mp) { _tMempool* m = *mp; - _t808Cowbell* cowbell = *cowbellInst = (_t808Cowbell*) mpool_alloc(sizeof(_t808Cowbell), m); + t808Cowbell* cowbell = *cowbellInst = (t808Cowbell*) mpool_alloc(sizeof(t808Cowbell), m); cowbell->mempool = m; tSquare_initToPool(&cowbell->p[0], mp); - tSquare_setFreq(cowbell->p[0], 540.0f); + tSquare_setFreq(&cowbell->p[0], 540.0f); tSquare_initToPool(&cowbell->p[1], mp); - tSquare_setFreq(cowbell->p[1], 1.48148f * 540.0f); + tSquare_setFreq(&cowbell->p[1], 1.48148f * 540.0f); cowbell->oscMix = 0.5f; @@ -54,9 +54,9 @@ void t808Cowbell_initToPool (t808Cowbell* const cowbellInst, int use cowbell->useStick = useStick; } -void t808Cowbell_free (t808Cowbell* const cowbellInst) +void t808Cowbell_free (t808Cowbell** const cowbellInst) { - _t808Cowbell* cowbell = *cowbellInst; + t808Cowbell* cowbell = *cowbellInst; tSquare_free(&cowbell->p[0]); tSquare_free(&cowbell->p[1]); @@ -70,74 +70,74 @@ void t808Cowbell_free (t808Cowbell* const cowbellInst) mpool_free((char*)cowbell, cowbell->mempool); } -void t808Cowbell_on(t808Cowbell const cowbell, Lfloat vel) +void t808Cowbell_on(t808Cowbell* const cowbell, Lfloat vel) { - tEnvelope_on(cowbell->envGain, vel); + tEnvelope_on(&cowbell->envGain, vel); if (cowbell->useStick) - tEnvelope_on(cowbell->envStick,vel); + tEnvelope_on(&cowbell->envStick,vel); } -Lfloat t808Cowbell_tick(t808Cowbell const cowbell) +Lfloat t808Cowbell_tick(t808Cowbell* const cowbell) { Lfloat sample = 0.0f; // Mix oscillators. - sample = (cowbell->oscMix * tSquare_tick(cowbell->p[0])) + ((1.0f-cowbell->oscMix) * tSquare_tick(cowbell->p[1])); + sample = (cowbell->oscMix * tSquare_tick(&cowbell->p[0])) + ((1.0f-cowbell->oscMix) * tSquare_tick(&cowbell->p[1])); // Filter dive and filter. - tSVF_setFreq(cowbell->bandpassOsc, cowbell->filterCutoff + 1000.0f * tEnvelope_tick(cowbell->envFilter)); - sample = tSVF_tick(cowbell->bandpassOsc,sample); + tSVF_setFreq(&cowbell->bandpassOsc, cowbell->filterCutoff + 1000.0f * tEnvelope_tick(&cowbell->envFilter)); + sample = tSVF_tick(&cowbell->bandpassOsc,sample); - sample *= (0.9f * tEnvelope_tick(cowbell->envGain)); + sample *= (0.9f * tEnvelope_tick(&cowbell->envGain)); if (cowbell->useStick) - sample += (0.1f * tEnvelope_tick(cowbell->envStick) * tSVF_tick(cowbell->bandpassStick, tNoise_tick(cowbell->stick))); + sample += (0.1f * tEnvelope_tick(&cowbell->envStick) * tSVF_tick(&cowbell->bandpassStick, tNoise_tick(&cowbell->stick))); - sample = tHighpass_tick(cowbell->highpass, sample); + sample = tHighpass_tick(&cowbell->highpass, sample); return sample; } -void t808Cowbell_setDecay(t808Cowbell const cowbell, Lfloat decay) +void t808Cowbell_setDecay(t808Cowbell* const cowbell, Lfloat decay) { - tEnvelope_setDecay(cowbell->envGain,decay); + tEnvelope_setDecay(&cowbell->envGain,decay); } -void t808Cowbell_setHighpassFreq(t808Cowbell cowbell, Lfloat freq) +void t808Cowbell_setHighpassFreq(t808Cowbell* cowbell, Lfloat freq) { - tHighpass_setFreq(cowbell->highpass,freq); + tHighpass_setFreq(&cowbell->highpass,freq); } -void t808Cowbell_setBandpassFreq(t808Cowbell const cowbell, Lfloat freq) +void t808Cowbell_setBandpassFreq(t808Cowbell* const cowbell, Lfloat freq) { cowbell->filterCutoff = freq; } -void t808Cowbell_setFreq(t808Cowbell const cowbell, Lfloat freq) +void t808Cowbell_setFreq(t808Cowbell* const cowbell, Lfloat freq) { - tSquare_setFreq(cowbell->p[0],freq); - tSquare_setFreq(cowbell->p[1],1.48148f*freq); + tSquare_setFreq(&cowbell->p[0],freq); + tSquare_setFreq(&cowbell->p[1],1.48148f*freq); } -void t808Cowbell_setOscMix(t808Cowbell const cowbell, Lfloat oscMix) +void t808Cowbell_setOscMix(t808Cowbell* const cowbell, Lfloat oscMix) { cowbell->oscMix = oscMix; } -void t808Cowbell_setStick(t808Cowbell const cowbell, int useStick) +void t808Cowbell_setStick(t808Cowbell* const cowbell, int useStick) { cowbell->useStick = useStick; } -void t808Cowbell_setSampleRate(t808Cowbell const cowbell, Lfloat sr) +void t808Cowbell_setSampleRate(t808Cowbell* const cowbell, Lfloat sr) { - tSquare_setSampleRate(cowbell->p[0], sr); - tSquare_setSampleRate(cowbell->p[1], sr); - tSVF_setSampleRate(cowbell->bandpassOsc, sr); - tSVF_setSampleRate(cowbell->bandpassStick, sr); - tHighpass_setSampleRate(cowbell->highpass, sr); + tSquare_setSampleRate(&cowbell->p[0], sr); + tSquare_setSampleRate(&cowbell->p[1], sr); + tSVF_setSampleRate(&cowbell->bandpassOsc, sr); + tSVF_setSampleRate(&cowbell->bandpassStick, sr); + tHighpass_setSampleRate(&cowbell->highpass, sr); } // ----------------- HIHAT ----------------------------// @@ -147,10 +147,10 @@ void t808Hihat_init(t808Hihat* const hihatInst, LEAF* const leaf) t808Hihat_initToPool(hihatInst, &leaf->mempool); } -void t808Hihat_initToPool (t808Hihat* const hihatInst, tMempool* const mp) +void t808Hihat_initToPool (t808Hihat** const hihatInst, tMempool* const mp) { _tMempool* m = *mp; - _t808Hihat* hihat = *hihatInst = (_t808Hihat*) mpool_alloc(sizeof(_t808Hihat), m); + t808Hihat* hihat = *hihatInst = (t808Hihat*) mpool_alloc(sizeof(t808Hihat), m); hihat->mempool = m; for (int i = 0; i < 6; i++) @@ -174,17 +174,17 @@ void t808Hihat_initToPool (t808Hihat* const hihatInst, tMempool* const mp) hihat->freq = 40.0f; hihat->stretch = 0.0f; - tSquare_setFreq(hihat->p[0], 2.0f * hihat->freq); - tSquare_setFreq(hihat->p[1], 3.00f * hihat->freq); - tSquare_setFreq(hihat->p[2], 4.16f * hihat->freq); - tSquare_setFreq(hihat->p[3], 5.43f * hihat->freq); - tSquare_setFreq(hihat->p[4], 6.79f * hihat->freq); - tSquare_setFreq(hihat->p[5], 8.21f * hihat->freq); + tSquare_setFreq(&hihat->p[0], 2.0f * hihat->freq); + tSquare_setFreq(&hihat->p[1], 3.00f * hihat->freq); + tSquare_setFreq(&hihat->p[2], 4.16f * hihat->freq); + tSquare_setFreq(&hihat->p[3], 5.43f * hihat->freq); + tSquare_setFreq(&hihat->p[4], 6.79f * hihat->freq); + tSquare_setFreq(&hihat->p[5], 8.21f * hihat->freq); } -void t808Hihat_free (t808Hihat* const hihatInst) +void t808Hihat_free (t808Hihat** const hihatInst) { - _t808Hihat* hihat = *hihatInst; + t808Hihat* hihat = *hihatInst; for (int i = 0; i < 6; i++) { @@ -205,108 +205,108 @@ void t808Hihat_free (t808Hihat* const hihatInst) mpool_free((char*)hihat, hihat->mempool); } -void t808Hihat_on(t808Hihat const hihat, Lfloat vel) +void t808Hihat_on(t808Hihat* const hihat, Lfloat vel) { - tEnvelope_on(hihat->envGain, vel); - tEnvelope_on(hihat->envStick, vel); + tEnvelope_on(&hihat->envGain, vel); + tEnvelope_on(&hihat->envStick, vel); } -void t808Hihat_setOscNoiseMix(t808Hihat const hihat, Lfloat oscNoiseMix) +void t808Hihat_setOscNoiseMix(t808Hihat* const hihat, Lfloat oscNoiseMix) { hihat->oscNoiseMix = oscNoiseMix; } -Lfloat t808Hihat_tick(t808Hihat const hihat) +Lfloat t808Hihat_tick(t808Hihat* const hihat) { Lfloat sample = 0.0f; Lfloat gainScale = 0.1666f; - Lfloat myNoise = tNoise_tick(hihat->n); + Lfloat myNoise = tNoise_tick(&hihat->n); - tSquare_setFreq(hihat->p[0], ((2.0f + hihat->stretch) * hihat->freq)); - tSquare_setFreq(hihat->p[1], ((3.00f + hihat->stretch) * hihat->freq)); - tSquare_setFreq(hihat->p[2], ((4.16f + hihat->stretch) * hihat->freq)); - tSquare_setFreq(hihat->p[3], ((5.43f + hihat->stretch) * hihat->freq)); - tSquare_setFreq(hihat->p[4], ((6.79f + hihat->stretch) * hihat->freq)); - tSquare_setFreq(hihat->p[5], ((8.21f + hihat->stretch) * hihat->freq)); + tSquare_setFreq(&hihat->p[0], ((2.0f + hihat->stretch) * hihat->freq)); + tSquare_setFreq(&hihat->p[1], ((3.00f + hihat->stretch) * hihat->freq)); + tSquare_setFreq(&hihat->p[2], ((4.16f + hihat->stretch) * hihat->freq)); + tSquare_setFreq(&hihat->p[3], ((5.43f + hihat->stretch) * hihat->freq)); + tSquare_setFreq(&hihat->p[4], ((6.79f + hihat->stretch) * hihat->freq)); + tSquare_setFreq(&hihat->p[5], ((8.21f + hihat->stretch) * hihat->freq)); for (int i = 0; i < 6; i++) { - sample += tSquare_tick(hihat->p[i]); + sample += tSquare_tick(&hihat->p[i]); } sample *= gainScale; sample = (hihat->oscNoiseMix * sample) + ((1.0f-hihat->oscNoiseMix) * myNoise); - sample = tSVF_tick(hihat->bandpassOsc, sample); + sample = tSVF_tick(&hihat->bandpassOsc, sample); - Lfloat myGain = tEnvelope_tick(hihat->envGain); + Lfloat myGain = tEnvelope_tick(&hihat->envGain); sample *= (myGain*myGain);//square the output gain envelope - sample = tHighpass_tick(hihat->highpass, sample); - sample += ((0.5f * tEnvelope_tick(hihat->envStick)) * tSVF_tick(hihat->bandpassStick, tNoise_tick(hihat->stick))); + sample = tHighpass_tick(&hihat->highpass, sample); + sample += ((0.5f * tEnvelope_tick(&hihat->envStick)) * tSVF_tick(&hihat->bandpassStick, tNoise_tick(&hihat->stick))); sample = tanhf(sample * 2.0f); return sample; } -void t808Hihat_setDecay(t808Hihat const hihat, Lfloat decay) +void t808Hihat_setDecay(t808Hihat* const hihat, Lfloat decay) { - tEnvelope_setDecay(hihat->envGain,decay); + tEnvelope_setDecay(&hihat->envGain,decay); } -void t808Hihat_setHighpassFreq(t808Hihat const hihat, Lfloat freq) +void t808Hihat_setHighpassFreq(t808Hihat* const hihat, Lfloat freq) { - tHighpass_setFreq(hihat->highpass,freq); + tHighpass_setFreq(&hihat->highpass,freq); } -void t808Hihat_setStretch(t808Hihat const hihat, Lfloat stretch) +void t808Hihat_setStretch(t808Hihat* const hihat, Lfloat stretch) { hihat->stretch = stretch; } -void t808Hihat_setFM(t808Hihat const hihat, Lfloat FM_amount) +void t808Hihat_setFM(t808Hihat* const hihat, Lfloat FM_amount) { hihat->FM_amount = FM_amount; } -void t808Hihat_setOscBandpassFreq(t808Hihat const hihat, Lfloat freq) +void t808Hihat_setOscBandpassFreq(t808Hihat* const hihat, Lfloat freq) { - tSVF_setFreq(hihat->bandpassOsc,freq); + tSVF_setFreq(&hihat->bandpassOsc,freq); } -void t808Hihat_setOscBandpassQ(t808Hihat const hihat, Lfloat Q) +void t808Hihat_setOscBandpassQ(t808Hihat* const hihat, Lfloat Q) { - tSVF_setQ(hihat->bandpassOsc,Q); + tSVF_setQ(&hihat->bandpassOsc,Q); } -void t808Hihat_setStickBandPassFreq(t808Hihat const hihat, Lfloat freq) +void t808Hihat_setStickBandPassFreq(t808Hihat* const hihat, Lfloat freq) { - tSVF_setFreq(hihat->bandpassStick,freq); + tSVF_setFreq(&hihat->bandpassStick,freq); } -void t808Hihat_setStickBandPassQ(t808Hihat const hihat, Lfloat Q) +void t808Hihat_setStickBandPassQ(t808Hihat* const hihat, Lfloat Q) { - tSVF_setQ(hihat->bandpassStick,Q); + tSVF_setQ(&hihat->bandpassStick,Q); } -void t808Hihat_setOscFreq(t808Hihat const hihat, Lfloat freq) +void t808Hihat_setOscFreq(t808Hihat* const hihat, Lfloat freq) { hihat->freq = freq; } -void t808Hihat_setSampleRate(t808Hihat const hihat, Lfloat sr) +void t808Hihat_setSampleRate(t808Hihat* const hihat, Lfloat sr) { for (int i = 0; i < 6; i++) { - tSquare_setSampleRate(hihat->p[i], sr); + tSquare_setSampleRate(&hihat->p[i], sr); } // need to fix SVF to be generic - tSVF_setSampleRate(hihat->bandpassStick, sr); - tSVF_setSampleRate(hihat->bandpassOsc, sr); + tSVF_setSampleRate(&hihat->bandpassStick, sr); + tSVF_setSampleRate(&hihat->bandpassOsc, sr); - tHighpass_setSampleRate(hihat->highpass, sr); + tHighpass_setSampleRate(&hihat->highpass, sr); } // ----------------- SNARE ----------------------------// @@ -316,10 +316,10 @@ void t808Snare_init (t808Snare* const snareInst, LEAF* const leaf) t808Snare_initToPool(snareInst, &leaf->mempool); } -void t808Snare_initToPool (t808Snare* const snareInst, tMempool* const mp) +void t808Snare_initToPool (t808Snare** const snareInst, tMempool* const mp) { _tMempool* m = *mp; - _t808Snare* snare = *snareInst = (_t808Snare*) mpool_alloc(sizeof(_t808Snare), m); + t808Snare* snare = *snareInst = (t808Snare*) mpool_alloc(sizeof(t808Snare), m); snare->mempool = m; Lfloat ratio[2] = {1.0, 1.5}; @@ -327,7 +327,7 @@ void t808Snare_initToPool (t808Snare* const snareInst, tMempool* const mp) { tTriangle_initToPool(&snare->tone[i], mp); - tTriangle_setFreq(snare->tone[i], ratio[i] * 400.0f); + tTriangle_setFreq(&snare->tone[i], ratio[i] * 400.0f); tSVF_initToPool(&snare->toneLowpass[i], SVFTypeLowpass, 4000, 1.0f, mp); tEnvelope_initToPool(&snare->toneEnvOsc[i], 0.0f, 50.0f, 0, mp); tEnvelope_initToPool(&snare->toneEnvGain[i], 1.0f, 150.0f, 0, mp); @@ -346,9 +346,9 @@ void t808Snare_initToPool (t808Snare* const snareInst, tMempool* const mp) snare->noiseGain = 1.0f; } -void t808Snare_free (t808Snare* const snareInst) +void t808Snare_free (t808Snare** const snareInst) { - _t808Snare* snare = *snareInst; + t808Snare* snare = *snareInst; for (int i = 0; i < 2; i++) { @@ -367,92 +367,92 @@ void t808Snare_free (t808Snare* const snareInst) mpool_free((char*)snare, snare->mempool); } -void t808Snare_on(t808Snare const snare, Lfloat vel) +void t808Snare_on(t808Snare* const snare, Lfloat vel) { for (int i = 0; i < 2; i++) { - tEnvelope_on(snare->toneEnvOsc[i], vel); - tEnvelope_on(snare->toneEnvGain[i], vel); - tEnvelope_on(snare->toneEnvFilter[i], vel); + tEnvelope_on(&snare->toneEnvOsc[i], vel); + tEnvelope_on(&snare->toneEnvGain[i], vel); + tEnvelope_on(&snare->toneEnvFilter[i], vel); } - tEnvelope_on(snare->noiseEnvGain, vel); - tEnvelope_on(snare->noiseEnvFilter, vel); + tEnvelope_on(&snare->noiseEnvGain, vel); + tEnvelope_on(&snare->noiseEnvFilter, vel); } -void t808Snare_setTone1Freq(t808Snare const snare, Lfloat freq) +void t808Snare_setTone1Freq(t808Snare* const snare, Lfloat freq) { snare->tone1Freq = freq; - tTriangle_setFreq(snare->tone[0], freq); + tTriangle_setFreq(&snare->tone[0], freq); } -void t808Snare_setTone2Freq(t808Snare const snare, Lfloat freq) +void t808Snare_setTone2Freq(t808Snare* const snare, Lfloat freq) { snare->tone2Freq = freq; - tTriangle_setFreq(snare->tone[1],freq); + tTriangle_setFreq(&snare->tone[1],freq); } -void t808Snare_setTone1Decay(t808Snare const snare, Lfloat decay) +void t808Snare_setTone1Decay(t808Snare* const snare, Lfloat decay) { - tEnvelope_setDecay(snare->toneEnvGain[0],decay); + tEnvelope_setDecay(&snare->toneEnvGain[0],decay); } -void t808Snare_setTone2Decay(t808Snare const snare, Lfloat decay) +void t808Snare_setTone2Decay(t808Snare* const snare, Lfloat decay) { - tEnvelope_setDecay(snare->toneEnvGain[1],decay); + tEnvelope_setDecay(&snare->toneEnvGain[1],decay); } -void t808Snare_setNoiseDecay(t808Snare const snare, Lfloat decay) +void t808Snare_setNoiseDecay(t808Snare* const snare, Lfloat decay) { - tEnvelope_setDecay(snare->noiseEnvGain,decay); + tEnvelope_setDecay(&snare->noiseEnvGain,decay); } -void t808Snare_setToneNoiseMix(t808Snare const snare, Lfloat toneNoiseMix) +void t808Snare_setToneNoiseMix(t808Snare* const snare, Lfloat toneNoiseMix) { snare->toneNoiseMix = toneNoiseMix; } -void t808Snare_setNoiseFilterFreq(t808Snare const snare, Lfloat noiseFilterFreq) +void t808Snare_setNoiseFilterFreq(t808Snare* const snare, Lfloat noiseFilterFreq) { snare->noiseFilterFreq = noiseFilterFreq; } -void t808Snare_setNoiseFilterQ(t808Snare const snare, Lfloat noiseFilterQ) +void t808Snare_setNoiseFilterQ(t808Snare* const snare, Lfloat noiseFilterQ) { - tSVF_setQ(snare->noiseLowpass, noiseFilterQ); + tSVF_setQ(&snare->noiseLowpass, noiseFilterQ); } static Lfloat tone[2]; -Lfloat t808Snare_tick(t808Snare const snare) +Lfloat t808Snare_tick(t808Snare* const snare) { Lfloat tone[2]; for (int i = 0; i < 2; i++) { - tTriangle_setFreq(snare->tone[i], snare->tone1Freq + (20.0f * tEnvelope_tick(snare->toneEnvOsc[i]))); - tone[i] = tTriangle_tick(snare->tone[i]); + tTriangle_setFreq(&snare->tone[i], snare->tone1Freq + (20.0f * tEnvelope_tick(&snare->toneEnvOsc[i]))); + tone[i] = tTriangle_tick(&snare->tone[i]); - tSVF_setFreq(snare->toneLowpass[i], 2000.0f + (500.0f * tEnvelope_tick(snare->toneEnvFilter[i]))); - tone[i] = tSVF_tick(snare->toneLowpass[i], tone[i]) * tEnvelope_tick(snare->toneEnvGain[i]); + tSVF_setFreq(&snare->toneLowpass[i], 2000.0f + (500.0f * tEnvelope_tick(&snare->toneEnvFilter[i]))); + tone[i] = tSVF_tick(&snare->toneLowpass[i], tone[i]) * tEnvelope_tick(&snare->toneEnvGain[i]); } - Lfloat noise = tNoise_tick(snare->noiseOsc); - tSVF_setFreq(snare->noiseLowpass, snare->noiseFilterFreq + (1000.0f * tEnvelope_tick(snare->noiseEnvFilter))); - noise = tSVF_tick(snare->noiseLowpass, noise) * tEnvelope_tick(snare->noiseEnvGain); + Lfloat noise = tNoise_tick(&snare->noiseOsc); + tSVF_setFreq(&snare->noiseLowpass, snare->noiseFilterFreq + (1000.0f * tEnvelope_tick(&snare->noiseEnvFilter))); + noise = tSVF_tick(&snare->noiseLowpass, noise) * tEnvelope_tick(&snare->noiseEnvGain); Lfloat sample = (snare->toneNoiseMix)*(tone[0] * snare->toneGain[0] + tone[1] * snare->toneGain[1]) + (1.0f-snare->toneNoiseMix) * (noise * snare->noiseGain); sample = tanhf(sample * 2.0f); return sample; } -void t808Snare_setSampleRate(t808Snare const snare, Lfloat sr) +void t808Snare_setSampleRate(t808Snare* const snare, Lfloat sr) { for (int i = 0; i < 2; i++) { - tTriangle_setSampleRate(snare->tone[i], sr); - tSVF_setSampleRate(snare->toneLowpass[i], sr); + tTriangle_setSampleRate(&snare->tone[i], sr); + tSVF_setSampleRate(&snare->toneLowpass[i], sr); } - tSVF_setSampleRate(snare->noiseLowpass, sr); + tSVF_setSampleRate(&snare->noiseLowpass, sr); } @@ -463,17 +463,17 @@ void t808SnareSmall_init (t808SnareSmall* const snareInst, LEAF* const leaf) t808SnareSmall_initToPool(snareInst, &leaf->mempool); } -void t808SnareSmall_initToPool (t808SnareSmall* const snareInst, tMempool* const mp) +void t808SnareSmall_initToPool (t808SnareSmall** const snareInst, tMempool* const mp) { _tMempool* m = *mp; - _t808SnareSmall* snare = *snareInst = (_t808SnareSmall*) mpool_alloc(sizeof(_t808SnareSmall), m); + t808SnareSmall* snare = *snareInst = (t808SnareSmall*) mpool_alloc(sizeof(t808SnareSmall), m); snare->mempool = m; Lfloat ratio[2] = {1.0, 1.5}; for (int i = 0; i < 2; i++) { tPBTriangle_initToPool(&snare->tone[i], mp); - tPBTriangle_setFreq(snare->tone[i], ratio[i] * 400.0f); + tPBTriangle_setFreq(&snare->tone[i], ratio[i] * 400.0f); tSVF_initToPool(&snare->toneLowpass[i], SVFTypeLowpass, 4000, 1.0f, mp); tADSRS_initToPool(&snare->toneEnvOsc[i], 0.0f, 50.0f, 0.0f, 50.0f, mp); tADSRS_initToPool(&snare->toneEnvGain[i], 1.0f, 150.0f, 0.0f, 50.0f, mp); @@ -492,9 +492,9 @@ void t808SnareSmall_initToPool (t808SnareSmall* const snareInst, tMempool* snare->noiseGain = 1.0f; } -void t808SnareSmall_free (t808SnareSmall* const snareInst) +void t808SnareSmall_free (t808SnareSmall** const snareInst) { - _t808SnareSmall* snare = *snareInst; + t808SnareSmall* snare = *snareInst; for (int i = 0; i < 2; i++) { @@ -513,91 +513,91 @@ void t808SnareSmall_free (t808SnareSmall* const snareInst) mpool_free((char*)snare, snare->mempool); } -void t808SnareSmall_on(t808SnareSmall const snare, Lfloat vel) +void t808SnareSmall_on(t808SnareSmall* const snare, Lfloat vel) { for (int i = 0; i < 2; i++) { - tADSRS_on(snare->toneEnvOsc[i], vel); - tADSRS_on(snare->toneEnvGain[i], vel); - tADSRS_on(snare->toneEnvFilter[i], vel); + tADSRS_on(&snare->toneEnvOsc[i], vel); + tADSRS_on(&snare->toneEnvGain[i], vel); + tADSRS_on(&snare->toneEnvFilter[i], vel); } - tADSRS_on(snare->noiseEnvGain, vel); - tADSRS_on(snare->noiseEnvFilter, vel); + tADSRS_on(&snare->noiseEnvGain, vel); + tADSRS_on(&snare->noiseEnvFilter, vel); } -void t808SnareSmall_setTone1Freq(t808SnareSmall const snare, Lfloat freq) +void t808SnareSmall_setTone1Freq(t808SnareSmall* const snare, Lfloat freq) { snare->tone1Freq = freq; - tPBTriangle_setFreq(snare->tone[0], freq); + tPBTriangle_setFreq(&snare->tone[0], freq); } -void t808SnareSmall_setTone2Freq(t808SnareSmall const snare, Lfloat freq) +void t808SnareSmall_setTone2Freq(t808SnareSmall* const snare, Lfloat freq) { snare->tone2Freq = freq; - tPBTriangle_setFreq(snare->tone[1],freq); + tPBTriangle_setFreq(&snare->tone[1],freq); } -void t808SnareSmall_setTone1Decay(t808SnareSmall const snare, Lfloat decay) +void t808SnareSmall_setTone1Decay(t808SnareSmall* const snare, Lfloat decay) { - tADSRS_setDecay(snare->toneEnvGain[0],decay); + tADSRS_setDecay(&snare->toneEnvGain[0],decay); } -void t808SnareSmall_setTone2Decay(t808SnareSmall const snare, Lfloat decay) +void t808SnareSmall_setTone2Decay(t808SnareSmall* const snare, Lfloat decay) { - tADSRS_setDecay(snare->toneEnvGain[1],decay); + tADSRS_setDecay(&snare->toneEnvGain[1],decay); } -void t808SnareSmall_setNoiseDecay(t808SnareSmall const snare, Lfloat decay) +void t808SnareSmall_setNoiseDecay(t808SnareSmall* const snare, Lfloat decay) { - tADSRS_setDecay(snare->noiseEnvGain,decay); + tADSRS_setDecay(&snare->noiseEnvGain,decay); } -void t808SnareSmall_setToneNoiseMix(t808SnareSmall const snare, Lfloat toneNoiseMix) +void t808SnareSmall_setToneNoiseMix(t808SnareSmall* const snare, Lfloat toneNoiseMix) { snare->toneNoiseMix = toneNoiseMix; } -void t808SnareSmall_setNoiseFilterFreq(t808SnareSmall const snare, Lfloat noiseFilterFreq) +void t808SnareSmall_setNoiseFilterFreq(t808SnareSmall* const snare, Lfloat noiseFilterFreq) { snare->noiseFilterFreq = noiseFilterFreq; } -void t808SnareSmall_setNoiseFilterQ(t808SnareSmall const snare, Lfloat noiseFilterQ) +void t808SnareSmall_setNoiseFilterQ(t808SnareSmall* const snare, Lfloat noiseFilterQ) { - tSVF_setQ(snare->noiseLowpass, noiseFilterQ); + tSVF_setQ(&snare->noiseLowpass, noiseFilterQ); } -Lfloat t808SnareSmall_tick(t808SnareSmall const snare) +Lfloat t808SnareSmall_tick(t808SnareSmall* const snare) { Lfloat tone[2]; for (int i = 0; i < 2; i++) { - tPBTriangle_setFreq(snare->tone[i], snare->tone1Freq + (20.0f * tADSRS_tick(snare->toneEnvOsc[i]))); - tone[i] = tPBTriangle_tick(snare->tone[i]); + tPBTriangle_setFreq(&snare->tone[i], snare->tone1Freq + (20.0f * tADSRS_tick(&snare->toneEnvOsc[i]))); + tone[i] = tPBTriangle_tick(&snare->tone[i]); - tSVF_setFreq(snare->toneLowpass[i], 2000.0f + (500.0f * tADSRS_tick(snare->toneEnvFilter[i]))); - tone[i] = tSVF_tick(snare->toneLowpass[i], tone[i]) * tADSRS_tick(snare->toneEnvGain[i]); + tSVF_setFreq(&snare->toneLowpass[i], 2000.0f + (500.0f * tADSRS_tick(&snare->toneEnvFilter[i]))); + tone[i] = tSVF_tick(&snare->toneLowpass[i], tone[i]) * tADSRS_tick(&snare->toneEnvGain[i]); } - Lfloat noise = tNoise_tick(snare->noiseOsc); - tSVF_setFreq(snare->noiseLowpass, snare->noiseFilterFreq + (1000.0f * tADSRS_tick(snare->noiseEnvFilter))); - noise = tSVF_tick(snare->noiseLowpass, noise) * tADSRS_tick(snare->noiseEnvGain); + Lfloat noise = tNoise_tick(&snare->noiseOsc); + tSVF_setFreq(&snare->noiseLowpass, snare->noiseFilterFreq + (1000.0f * tADSRS_tick(&snare->noiseEnvFilter))); + noise = tSVF_tick(&snare->noiseLowpass, noise) * tADSRS_tick(&snare->noiseEnvGain); Lfloat sample = (snare->toneNoiseMix)*(tone[0] * snare->toneGain[0] + tone[1] * snare->toneGain[1]) + (1.0f-snare->toneNoiseMix) * (noise * snare->noiseGain); //sample = tanhf(sample * 2.0f); return sample; } -void t808SnareSmall_setSampleRate(t808SnareSmall const snare, Lfloat sr) +void t808SnareSmall_setSampleRate(t808SnareSmall* const snare, Lfloat sr) { for (int i = 0; i < 2; i++) { - tPBTriangle_setSampleRate(snare->tone[i], sr); - tSVF_setSampleRate(snare->toneLowpass[i], sr); + tPBTriangle_setSampleRate(&snare->tone[i], sr); + tSVF_setSampleRate(&snare->toneLowpass[i], sr); } - tSVF_setSampleRate(snare->noiseLowpass, sr); + tSVF_setSampleRate(&snare->noiseLowpass, sr); } // ----------------- KICK ----------------------------// @@ -607,17 +607,17 @@ void t808Kick_init (t808Kick* const kickInst, LEAF* const leaf) t808Kick_initToPool(kickInst, &leaf->mempool); } -void t808Kick_initToPool (t808Kick* const kickInst, tMempool* const mp) +void t808Kick_initToPool (t808Kick** const kickInst, tMempool* const mp) { _tMempool* m = *mp; - _t808Kick* kick = *kickInst = (_t808Kick*) mpool_alloc(sizeof(_t808Kick), m); + t808Kick* kick = *kickInst = (t808Kick*) mpool_alloc(sizeof(t808Kick), m); kick->mempool = m; tCycle_initToPool(&kick->tone, mp); kick->toneInitialFreq = 40.0f; kick->sighAmountInHz = 7.0f; kick->chirpRatioMinusOne = 3.3f; - tCycle_setFreq(kick->tone, 50.0f); + tCycle_setFreq(&kick->tone, 50.0f); tSVF_initToPool(&kick->toneLowpass, SVFTypeLowpass, 2000.0f, 0.5f, mp); tEnvelope_initToPool(&kick->toneEnvOscChirp, 0.0f, 20.0f, 0, mp); tEnvelope_initToPool(&kick->toneEnvOscSigh, 0.0f, 2500.0f, 0, mp); @@ -627,9 +627,9 @@ void t808Kick_initToPool (t808Kick* const kickInst, tMempool* const mp) kick->noiseGain = 0.3f; } -void t808Kick_free (t808Kick* const kickInst) +void t808Kick_free (t808Kick** const kickInst) { - _t808Kick* kick = *kickInst; + t808Kick* kick = *kickInst; tCycle_free(&kick->tone); tSVF_free(&kick->toneLowpass); @@ -642,43 +642,43 @@ void t808Kick_free (t808Kick* const kickInst) mpool_free((char*)kick, kick->mempool); } -Lfloat t808Kick_tick (t808Kick const kick) +Lfloat t808Kick_tick (t808Kick* const kick) { - tCycle_setFreq(kick->tone, (kick->toneInitialFreq * (1.0f + (kick->chirpRatioMinusOne * tEnvelope_tick(kick->toneEnvOscChirp)))) + (kick->sighAmountInHz * tEnvelope_tick(kick->toneEnvOscSigh))); - Lfloat sample = tCycle_tick(kick->tone) * tEnvelope_tick(kick->toneEnvGain); - sample+= tNoise_tick(kick->noiseOsc) * tEnvelope_tick(kick->noiseEnvGain); + tCycle_setFreq(&kick->tone, (kick->toneInitialFreq * (1.0f + (kick->chirpRatioMinusOne * tEnvelope_tick(&kick->toneEnvOscChirp)))) + (kick->sighAmountInHz * tEnvelope_tick(&kick->toneEnvOscSigh))); + Lfloat sample = tCycle_tick(&kick->tone) * tEnvelope_tick(&kick->toneEnvGain); + sample+= tNoise_tick(&kick->noiseOsc) * tEnvelope_tick(&kick->noiseEnvGain); //add distortion here - sample = tSVF_tick(kick->toneLowpass, sample); + sample = tSVF_tick(&kick->toneLowpass, sample); return sample; } -void t808Kick_on (t808Kick const kick, Lfloat vel) +void t808Kick_on (t808Kick* const kick, Lfloat vel) { - tEnvelope_on(kick->toneEnvOscChirp, vel); - tEnvelope_on(kick->toneEnvOscSigh, vel); - tEnvelope_on(kick->toneEnvGain, vel); - tEnvelope_on(kick->noiseEnvGain, vel); + tEnvelope_on(&kick->toneEnvOscChirp, vel); + tEnvelope_on(&kick->toneEnvOscSigh, vel); + tEnvelope_on(&kick->toneEnvGain, vel); + tEnvelope_on(&kick->noiseEnvGain, vel); } -void t808Kick_setToneFreq (t808Kick const kick, Lfloat freq) +void t808Kick_setToneFreq (t808Kick* const kick, Lfloat freq) { kick->toneInitialFreq = freq; } -void t808Kick_setToneDecay (t808Kick const kick, Lfloat decay) +void t808Kick_setToneDecay (t808Kick* const kick, Lfloat decay) { - tEnvelope_setDecay(kick->toneEnvGain,decay); - tEnvelope_setDecay(kick->toneEnvGain,decay * 3.0f); + tEnvelope_setDecay(&kick->toneEnvGain,decay); + tEnvelope_setDecay(&kick->toneEnvGain,decay * 3.0f); } -void t808Kick_setSampleRate (t808Kick* const kickInst, Lfloat sr) +void t808Kick_setSampleRate (t808Kick** const kickInst, Lfloat sr) { - _t808Kick* kick = *kickInst; + t808Kick* kick = *kickInst; - tCycle_setSampleRate(kick->tone, sr); - tSVF_setSampleRate(kick->toneLowpass, sr); + tCycle_setSampleRate(&kick->tone, sr); + tSVF_setSampleRate(&kick->toneLowpass, sr); } @@ -689,17 +689,17 @@ void t808KickSmall_init (t808KickSmall* const kickInst, LEAF* const leaf) t808KickSmall_initToPool(kickInst, &leaf->mempool); } -void t808KickSmall_initToPool (t808KickSmall* const kickInst, tMempool* const mp) +void t808KickSmall_initToPool (t808KickSmall** const kickInst, tMempool* const mp) { _tMempool* m = *mp; - _t808KickSmall* kick = *kickInst = (_t808KickSmall*) mpool_alloc(sizeof(_t808KickSmall), m); + t808KickSmall* kick = *kickInst = (t808KickSmall*) mpool_alloc(sizeof(t808KickSmall), m); kick->mempool = m; tCycle_initToPool(&kick->tone, mp); kick->toneInitialFreq = 40.0f; kick->sighAmountInHz = 7.0f; kick->chirpRatioMinusOne = 3.3f; - tCycle_setFreq(kick->tone, 50.0f); + tCycle_setFreq(&kick->tone, 50.0f); tSVF_initToPool(&kick->toneLowpass, SVFTypeLowpass, 2000.0f, 0.5f, mp); tADSRS_initToPool(&kick->toneEnvOscChirp, 0.0f, 20.0f, 0.0f, 0.0f, mp); tADSRS_initToPool(&kick->toneEnvOscSigh, 0.0f, 2500.0f, 0.0f, 0.0f, mp); @@ -709,9 +709,9 @@ void t808KickSmall_initToPool (t808KickSmall* const kickInst, tMempool* const mp kick->noiseGain = 0.3f; } -void t808KickSmall_free (t808KickSmall* const kickInst) +void t808KickSmall_free (t808KickSmall** const kickInst) { - _t808KickSmall* kick = *kickInst; + t808KickSmall* kick = *kickInst; tCycle_free(&kick->tone); tSVF_free(&kick->toneLowpass); @@ -724,41 +724,41 @@ void t808KickSmall_free (t808KickSmall* const kickInst) mpool_free((char*)kick, kick->mempool); } -Lfloat t808KickSmall_tick (t808KickSmall const kick) +Lfloat t808KickSmall_tick (t808KickSmall* const kick) { - tCycle_setFreq(kick->tone, (kick->toneInitialFreq * (1.0f + (kick->chirpRatioMinusOne * tADSRS_tick(kick->toneEnvOscChirp)))) + (kick->sighAmountInHz * tADSRS_tick(kick->toneEnvOscSigh))); - Lfloat sample = tCycle_tick(kick->tone) * tADSRS_tick(kick->toneEnvGain); - sample+= tNoise_tick(kick->noiseOsc) * tADSRS_tick(kick->noiseEnvGain); + tCycle_setFreq(&kick->tone, (kick->toneInitialFreq * (1.0f + (kick->chirpRatioMinusOne * tADSRS_tick(&kick->toneEnvOscChirp)))) + (kick->sighAmountInHz * tADSRS_tick(&kick->toneEnvOscSigh))); + Lfloat sample = tCycle_tick(&kick->tone) * tADSRS_tick(&kick->toneEnvGain); + sample+= tNoise_tick(&kick->noiseOsc) * tADSRS_tick(&kick->noiseEnvGain); //add distortion here - sample = tSVF_tick(kick->toneLowpass, sample); + sample = tSVF_tick(&kick->toneLowpass, sample); return sample; } -void t808KickSmall_on (t808KickSmall const kick, Lfloat vel) +void t808KickSmall_on (t808KickSmall* const kick, Lfloat vel) { - tADSRS_on(kick->toneEnvOscChirp, vel); - tADSRS_on(kick->toneEnvOscSigh, vel); - tADSRS_on(kick->toneEnvGain, vel); - tADSRS_on(kick->noiseEnvGain, vel); + tADSRS_on(&kick->toneEnvOscChirp, vel); + tADSRS_on(&kick->toneEnvOscSigh, vel); + tADSRS_on(&kick->toneEnvGain, vel); + tADSRS_on(&kick->noiseEnvGain, vel); } -void t808KickSmall_setToneFreq (t808KickSmall const kick, Lfloat freq) +void t808KickSmall_setToneFreq (t808KickSmall* const kick, Lfloat freq) { kick->toneInitialFreq = freq; } -void t808KickSmall_setToneDecay (t808KickSmall const kick, Lfloat decay) +void t808KickSmall_setToneDecay (t808KickSmall* const kick, Lfloat decay) { - tADSRS_setDecay(kick->toneEnvGain,decay); - tADSRS_setDecay(kick->toneEnvGain,decay * 3.0f); + tADSRS_setDecay(&kick->toneEnvGain,decay); + tADSRS_setDecay(&kick->toneEnvGain,decay * 3.0f); } -void t808KickSmall_setSampleRate (t808KickSmall const kick, Lfloat sr) +void t808KickSmall_setSampleRate (t808KickSmall* const kick, Lfloat sr) { - tCycle_setSampleRate(kick->tone, sr); - tSVF_setSampleRate(kick->toneLowpass, sr); + tCycle_setSampleRate(&kick->tone, sr); + tSVF_setSampleRate(&kick->toneLowpass, sr); } diff --git a/leaf/Src/leaf-midi.c b/leaf/Src/leaf-midi.c index d45a9d0..f5f4921 100644 --- a/leaf/Src/leaf-midi.c +++ b/leaf/Src/leaf-midi.c @@ -25,10 +25,10 @@ void tStack_init(tStack* const stack, LEAF* const leaf) tStack_initToPool(stack, &leaf->mempool); } -void tStack_initToPool (tStack* const stack, tMempool* const mp) +void tStack_initToPool (tStack** const stack, tMempool* const mp) { _tMempool* m = *mp; - _tStack* ns = *stack = (_tStack*) mpool_alloc(sizeof(_tStack), m); + tStack* ns = *stack = (tStack*) mpool_alloc(sizeof(tStack), m); ns->mempool = m; ns->ordered = 0; @@ -39,15 +39,15 @@ void tStack_initToPool (tStack* const stack, tMempool* const mp) for (int i = 0; i < STACK_SIZE; i++) ns->data[i] = -1; } -void tStack_free (tStack* const stack) +void tStack_free (tStack** const stack) { - _tStack* ns = *stack; + tStack* ns = *stack; mpool_free((char*)ns, ns->mempool); } // If stack contains note, returns index. Else returns -1; -int tStack_contains(tStack const ns, uint16_t noteVal) +int tStack_contains(tStack* const ns, uint16_t noteVal) { for (int i = 0; i < ns->size; i++) { @@ -56,7 +56,7 @@ int tStack_contains(tStack const ns, uint16_t noteVal) return -1; } -void tStack_add(tStack const ns, uint16_t noteVal) +void tStack_add(tStack* const ns, uint16_t noteVal) { uint8_t j; @@ -88,7 +88,7 @@ void tStack_add(tStack const ns, uint16_t noteVal) ns->size++; } -int tStack_addIfNotAlreadyThere(tStack const ns, uint16_t noteVal) +int tStack_addIfNotAlreadyThere(tStack* const ns, uint16_t noteVal) { uint8_t j; @@ -130,7 +130,7 @@ int tStack_addIfNotAlreadyThere(tStack const ns, uint16_t noteVal) } // Remove noteVal. return 1 if removed, 0 if not -int tStack_remove(tStack const ns, uint16_t noteVal) +int tStack_remove(tStack* const ns, uint16_t noteVal) { uint8_t k; int foundIndex = tStack_contains(ns, noteVal); @@ -164,7 +164,7 @@ int tStack_remove(tStack const ns, uint16_t noteVal) } // Doesn't change size of data types -void tStack_setCapacity(tStack const ns, uint16_t cap) +void tStack_setCapacity(tStack* const ns, uint16_t cap) { if (cap <= 0) ns->capacity = 1; @@ -188,12 +188,12 @@ void tStack_setCapacity(tStack const ns, uint16_t cap) } } -int tStack_getSize(tStack const ns) +int tStack_getSize(tStack* const ns) { return ns->size; } -void tStack_clear(tStack const ns) +void tStack_clear(tStack* const ns) { for (int i = 0; i < STACK_SIZE; i++) { @@ -204,7 +204,7 @@ void tStack_clear(tStack const ns) } // Next item in order of addition to stack. Return 0-31 if there is a next item to move to. Returns -1 otherwise. -int tStack_next(tStack const ns) +int tStack_next(tStack* const ns) { int step = 0; if (ns->size != 0) // if there is at least one note in the stack @@ -227,12 +227,12 @@ int tStack_next(tStack const ns) } } -int tStack_get(tStack const ns, int which) +int tStack_get(tStack* const ns, int which) { return ns->data[which]; } -int tStack_first(tStack const ns) +int tStack_first(tStack* const ns) { return ns->data[0]; } @@ -244,10 +244,10 @@ void tPoly_init(tPoly* const polyh, int maxNumVoices, LEAF* const leaf) tPoly_initToPool(polyh, maxNumVoices, &leaf->mempool); } -void tPoly_initToPool (tPoly* const polyh, int maxNumVoices, tMempool* const mp) +void tPoly_initToPool (tPoly** const polyh, int maxNumVoices, tMempool* const mp) { _tMempool* m = *mp; - _tPoly* poly = *polyh = (_tPoly*) mpool_alloc(sizeof(_tPoly), m); + tPoly* poly = *polyh = (tPoly*) mpool_alloc(sizeof(tPoly), m); poly->mempool = m; poly->numVoices = maxNumVoices; @@ -291,9 +291,9 @@ void tPoly_initToPool (tPoly* const polyh, int maxNumVoices, tMemp poly->pitchGlideIsActive = 0; } -void tPoly_free (tPoly* const polyh) +void tPoly_free (tPoly** const polyh) { - _tPoly* poly = *polyh; + tPoly* poly = *polyh; for (int i = 0; i < poly->maxNumVoices; i++) { @@ -312,39 +312,39 @@ void tPoly_free (tPoly* const polyh) mpool_free((char*)poly, poly->mempool); } -void tPoly_tickPitch(tPoly polyh) +void tPoly_tickPitch(tPoly* polyh) { tPoly_tickPitchGlide(polyh); tPoly_tickPitchBend(polyh); } -void tPoly_tickPitchGlide(tPoly poly) +void tPoly_tickPitchGlide(tPoly* poly) { for (int i = 0; i < poly->maxNumVoices; ++i) { - tRamp_tick(poly->ramps[i]); + tRamp_tick(&poly->ramps[i]); } } -void tPoly_tickPitchBend(tPoly poly) +void tPoly_tickPitchBend(tPoly* poly) { - tRamp_tick(poly->pitchBendRamp); + tRamp_tick(&poly->pitchBendRamp); } -void tPoly_setPitchBend(tPoly const poly, Lfloat pitchBend) +void tPoly_setPitchBend(tPoly* const poly, Lfloat pitchBend) { poly->pitchBend = pitchBend; - tRamp_setDest(poly->pitchBendRamp, poly->pitchBend); + tRamp_setDest(&poly->pitchBendRamp, poly->pitchBend); } -int tPoly_noteOn(tPoly const poly, int note, uint8_t vel) +int tPoly_noteOn(tPoly* const poly, int note, uint8_t vel) { // if not in keymap or already on stack, dont do anything. else, add that note. - if (tStack_contains(poly->stack, note) >= 0) return -1; + if (tStack_contains(&poly->stack, note) >= 0) return -1; else { tPoly_orderedAddToStack(poly, note); - tStack_add(poly->stack, note); + tStack_add(&poly->stack, note); int alteredVoice = -1; int found = 0; @@ -354,7 +354,7 @@ int tPoly_noteOn(tPoly const poly, int note, uint8_t vel) { if (!poly->firstReceived[i] || !poly->pitchGlideIsActive) { - tRamp_setVal(poly->ramps[i], note); + tRamp_setVal(&poly->ramps[i], note); poly->firstReceived[i] = 1; } @@ -366,7 +366,7 @@ int tPoly_noteOn(tPoly const poly, int note, uint8_t vel) poly->notes[note][0] = vel; poly->notes[note][1] = i; - tRamp_setDest(poly->ramps[i], poly->voices[i][0]); + tRamp_setDest(&poly->ramps[i], poly->voices[i][0]); alteredVoice = i; break; @@ -376,9 +376,9 @@ int tPoly_noteOn(tPoly const poly, int note, uint8_t vel) if (!found) //steal { int whichVoice, whichNote; - for (int j = tStack_getSize(poly->stack) - 1; j >= 0; j--) + for (int j = tStack_getSize(&poly->stack) - 1; j >= 0; j--) { - whichNote = tStack_get(poly->stack, j); + whichNote = tStack_get(&poly->stack, j); whichVoice = poly->notes[whichNote][1]; if (whichVoice >= 0) { @@ -392,13 +392,13 @@ int tPoly_noteOn(tPoly const poly, int note, uint8_t vel) if (poly->pitchGlideIsActive) { - tRamp_setTime(poly->ramps[whichVoice], poly->glideTime); + tRamp_setTime(&poly->ramps[whichVoice], poly->glideTime); } else { - tRamp_setVal(poly->ramps[whichVoice], note); + tRamp_setVal(&poly->ramps[whichVoice], note); } - tRamp_setDest(poly->ramps[whichVoice], poly->voices[whichVoice][0]); + tRamp_setDest(&poly->ramps[whichVoice], poly->voices[whichVoice][0]); alteredVoice = whichVoice; @@ -413,10 +413,10 @@ int tPoly_noteOn(tPoly const poly, int note, uint8_t vel) int16_t noteToTest = -1; -int tPoly_noteOff(tPoly const poly, uint8_t note) +int tPoly_noteOff(tPoly* const poly, uint8_t note) { - tStack_remove(poly->stack, note); - tStack_remove(poly->orderStack, note); + tStack_remove(&poly->stack, note); + tStack_remove(&poly->orderStack, note); poly->notes[note][0] = 0; poly->notes[note][1] = -1; @@ -446,22 +446,22 @@ int tPoly_noteOff(tPoly const poly, uint8_t note) //grab old notes off the stack if there are notes waiting to replace the free voice if (deactivatedVoice >= 0) { - for (int j = 0; j < tStack_getSize(poly->stack); ++j) + for (int j = 0; j < tStack_getSize(&poly->stack); ++j) { - noteToTest = tStack_get(poly->stack, j); + noteToTest = tStack_get(&poly->stack, j); if (poly->notes[noteToTest][1] < 0) //if there is a stolen note waiting (marked inactive but on the stack) { poly->voices[deactivatedVoice][0] = noteToTest; //set the newly free voice to use the old stolen note if (poly->pitchGlideIsActive) { - tRamp_setTime(poly->ramps[deactivatedVoice], poly->glideTime); + tRamp_setTime(&poly->ramps[deactivatedVoice], poly->glideTime); } else { - tRamp_setVal(poly->ramps[deactivatedVoice], noteToTest); + tRamp_setVal(&poly->ramps[deactivatedVoice], noteToTest); } - tRamp_setDest(poly->ramps[deactivatedVoice], poly->voices[deactivatedVoice][0]); + tRamp_setDest(&poly->ramps[deactivatedVoice], poly->voices[deactivatedVoice][0]); poly->voices[deactivatedVoice][1] = poly->notes[noteToTest][0]; // set the velocity of the voice to be the velocity of that note poly->notes[noteToTest][1] = deactivatedVoice; //mark that it is no longer stolen and is now active return -1; @@ -471,7 +471,7 @@ int tPoly_noteOff(tPoly const poly, uint8_t note) return deactivatedVoice; } -void tPoly_orderedAddToStack(tPoly const poly, uint8_t noteVal) +void tPoly_orderedAddToStack(tPoly* const poly, uint8_t noteVal) { uint8_t j; int myPitch, thisPitch, nextPitch; @@ -509,72 +509,72 @@ void tPoly_orderedAddToStack(tPoly const poly, uint8_t noteVal) } -void tPoly_setNumVoices(tPoly const poly, uint8_t numVoices) +void tPoly_setNumVoices(tPoly* const poly, uint8_t numVoices) { poly->numVoices = (numVoices > poly->maxNumVoices) ? poly->maxNumVoices : numVoices; } -void tPoly_setPitchGlideActive(tPoly const poly, int isActive) +void tPoly_setPitchGlideActive(tPoly* const poly, int isActive) { poly->pitchGlideIsActive = isActive; } -void tPoly_setPitchGlideTime(tPoly const poly, Lfloat t) +void tPoly_setPitchGlideTime(tPoly* const poly, Lfloat t) { poly->glideTime = t; for (int i = 0; i < poly->maxNumVoices; ++i) { - tRamp_setTime(poly->ramps[i], poly->glideTime); + tRamp_setTime(&poly->ramps[i], poly->glideTime); } } -void tPoly_setBendGlideTime(tPoly const poly, Lfloat t) +void tPoly_setBendGlideTime(tPoly* const poly, Lfloat t) { - tRamp_setTime(poly->pitchBendRamp, t); + tRamp_setTime(&poly->pitchBendRamp, t); } -void tPoly_setBendSamplesPerTick(tPoly const poly, Lfloat t) +void tPoly_setBendSamplesPerTick(tPoly* const poly, Lfloat t) { poly->pitchBendRamp->samples_per_tick = t; } -int tPoly_getNumVoices(tPoly const poly) +int tPoly_getNumVoices(tPoly* const poly) { return poly->numVoices; } -int tPoly_getNumActiveVoices(tPoly const poly) +int tPoly_getNumActiveVoices(tPoly* const poly) { - return LEAF_clip(0, tStack_getSize(poly->stack), poly->numVoices); + return LEAF_clip(0, tStack_getSize(&poly->stack), poly->numVoices); } -Lfloat tPoly_getPitch(tPoly const poly, uint8_t voice) +Lfloat tPoly_getPitch(tPoly* const poly, uint8_t voice) { - return tRamp_sample(poly->ramps[voice]) + tRamp_sample(poly->pitchBendRamp); + return tRamp_sample(&poly->ramps[voice]) + tRamp_sample(&poly->pitchBendRamp); } -int tPoly_getKey(tPoly const poly, uint8_t voice) +int tPoly_getKey(tPoly* const poly, uint8_t voice) { return poly->voices[voice][0]; } -int tPoly_getVelocity(tPoly const poly, uint8_t voice) +int tPoly_getVelocity(tPoly* const poly, uint8_t voice) { return poly->voices[voice][1]; } -int tPoly_isOn(tPoly const poly, uint8_t voice) +int tPoly_isOn(tPoly* const poly, uint8_t voice) { return (poly->voices[voice][0] > 0) ? 1 : 0; } -void tPoly_setSampleRate(tPoly const poly, Lfloat sr) +void tPoly_setSampleRate(tPoly* const poly, Lfloat sr) { for (int i = 0; i < poly->maxNumVoices; i++) { - tRamp_setSampleRate(poly->ramps[i], sr); + tRamp_setSampleRate(&poly->ramps[i], sr); } - tRamp_setSampleRate(poly->pitchBendRamp, sr); + tRamp_setSampleRate(&poly->pitchBendRamp, sr); } @@ -587,10 +587,10 @@ void tSimplePoly_init(tSimplePoly* const polyh, int maxNumVoices, LEAF* const le tSimplePoly_initToPool(polyh, maxNumVoices, &leaf->mempool); } -void tSimplePoly_initToPool (tSimplePoly* const polyh, int maxNumVoices, tMempool* const mp) +void tSimplePoly_initToPool (tSimplePoly** const polyh, int maxNumVoices, tMempool* const mp) { _tMempool* m = *mp; - _tSimplePoly* poly = *polyh = (_tSimplePoly*) mpool_alloc(sizeof(_tSimplePoly), m); + tSimplePoly* poly = *polyh = (tSimplePoly*) mpool_alloc(sizeof(tSimplePoly), m); poly->mempool = m; poly->numVoices = maxNumVoices; @@ -614,9 +614,9 @@ void tSimplePoly_initToPool (tSimplePoly* const polyh, int maxNumV } -void tSimplePoly_free (tSimplePoly* const polyh) +void tSimplePoly_free (tSimplePoly** const polyh) { - _tSimplePoly* poly = *polyh; + tSimplePoly* poly = *polyh; for (int i = 0; i < poly->maxNumVoices; i++) { @@ -627,11 +627,11 @@ void tSimplePoly_free (tSimplePoly* const polyh) mpool_free((char*)poly, poly->mempool); } -int tSimplePoly_noteOn(tSimplePoly const poly, int note, uint8_t vel) +int tSimplePoly_noteOn(tSimplePoly* const poly, int note, uint8_t vel) { int whichVoice, whichNote, oldNote, alteredVoice; // if not in keymap or already on stack, dont do anything. else, add that note. - if (tStack_contains(poly->stack, note) >= 0) return -1; + if (tStack_contains(&poly->stack, note) >= 0) return -1; else { alteredVoice = -1; @@ -650,7 +650,7 @@ int tSimplePoly_noteOn(tSimplePoly const poly, int note, uint8_t vel) poly->voices[i][2] = note; // voices[i][2] is the output midi note, (avoiding the -1 when a voice is inactive) alteredVoice = i; - tStack_add(poly->stack, note); + tStack_add(&poly->stack, note); break; } } @@ -671,16 +671,16 @@ int tSimplePoly_noteOn(tSimplePoly const poly, int note, uint8_t vel) poly->voices[i][2] = note; // voices[i][2] is the output midi note, (avoiding the -1 when a voice is inactive) alteredVoice = i; - tStack_add(poly->stack, note); + tStack_add(&poly->stack, note); break; } } } if ((!found) && (poly->stealing_on)) //steal { - for (int j = tStack_getSize(poly->stack) - 1; j >= 0; j--) + for (int j = tStack_getSize(&poly->stack) - 1; j >= 0; j--) { - whichNote = tStack_get(poly->stack, j); + whichNote = tStack_get(&poly->stack, j); whichVoice = poly->notes[whichNote][0]; if (whichVoice >= 0) { @@ -694,7 +694,7 @@ int tSimplePoly_noteOn(tSimplePoly const poly, int note, uint8_t vel) poly->voices[whichVoice][2] = note; alteredVoice = whichVoice; - tStack_add(poly->stack, note); + tStack_add(&poly->stack, note); break; } } @@ -704,11 +704,11 @@ int tSimplePoly_noteOn(tSimplePoly const poly, int note, uint8_t vel) } -int tSimplePoly_noteOff(tSimplePoly const poly, uint8_t note) +int tSimplePoly_noteOff(tSimplePoly* const poly, uint8_t note) { int16_t noteToTest = -1; - tStack_remove(poly->stack, note); + tStack_remove(&poly->stack, note); poly->notes[note][0] = -1; int deactivatedVoice = -1; @@ -728,9 +728,9 @@ int tSimplePoly_noteOff(tSimplePoly const poly, uint8_t note) //grab old notes off the stack if there are notes waiting to replace the free voice if (deactivatedVoice >= 0) { - for (int j = 0; j < tStack_getSize(poly->stack); ++j) + for (int j = 0; j < tStack_getSize(&poly->stack); ++j) { - noteToTest = tStack_get(poly->stack, j); + noteToTest = tStack_get(&poly->stack, j); if (poly->notes[noteToTest][0] == -3) //if there is a stolen note waiting (marked inactive but on the stack) { @@ -747,7 +747,7 @@ int tSimplePoly_noteOff(tSimplePoly const poly, uint8_t note) } -void tSimplePoly_deactivateVoice(tSimplePoly const poly, uint8_t voice) +void tSimplePoly_deactivateVoice(tSimplePoly* const poly, uint8_t voice) { if (poly->voices[voice][0] == -2) //only do this if the voice is waiting for deactivation (not already reassigned while waiting) { @@ -756,9 +756,9 @@ void tSimplePoly_deactivateVoice(tSimplePoly const poly, uint8_t voice) if (poly->recover_stolen) { //grab old notes off the stack if there are notes waiting to replace the free voice - for (int j = 0; j < tStack_getSize(poly->stack); ++j) + for (int j = 0; j < tStack_getSize(&poly->stack); ++j) { - noteToTest = tStack_get(poly->stack, j); //note to check if it is waiting to be recovered + noteToTest = tStack_get(&poly->stack, j); //note to check if it is waiting to be recovered if (poly->notes[noteToTest][0] == -3) //if there is a stolen note waiting (marked inactive but on the stack) { @@ -774,7 +774,7 @@ void tSimplePoly_deactivateVoice(tSimplePoly const poly, uint8_t voice) } } -int tSimplePoly_findVoiceAssignedToNote(tSimplePoly const poly, uint8_t note) +int tSimplePoly_findVoiceAssignedToNote(tSimplePoly* const poly, uint8_t note) { int voiceWithThatNote = -1; for (int i = 0; i < poly->maxNumVoices; i++) @@ -789,11 +789,11 @@ int tSimplePoly_findVoiceAssignedToNote(tSimplePoly const poly, uint8_t note) } -int tSimplePoly_markPendingNoteOff(tSimplePoly const poly, uint8_t note) +int tSimplePoly_markPendingNoteOff(tSimplePoly* const poly, uint8_t note) { int deactivatedVoice = -1; - if (tStack_remove(poly->stack, note)) + if (tStack_remove(&poly->stack, note)) { poly->notes[note][0] = -2; @@ -811,40 +811,40 @@ int tSimplePoly_markPendingNoteOff(tSimplePoly const poly, uint8_t note) return deactivatedVoice; } -void tSimplePoly_setNumVoices(tSimplePoly const poly, uint8_t numVoices) +void tSimplePoly_setNumVoices(tSimplePoly* const poly, uint8_t numVoices) { poly->numVoices = (numVoices > poly->maxNumVoices) ? poly->maxNumVoices : numVoices; } -int tSimplePoly_getNumVoices(tSimplePoly const poly) +int tSimplePoly_getNumVoices(tSimplePoly* const poly) { return poly->numVoices; } -int tSimplePoly_getNumActiveVoices(tSimplePoly const poly) +int tSimplePoly_getNumActiveVoices(tSimplePoly* const poly) { - return LEAF_clip(0, tStack_getSize(poly->stack), poly->numVoices); + return LEAF_clip(0, tStack_getSize(&poly->stack), poly->numVoices); } -int tSimplePoly_getPitch(tSimplePoly const poly, uint8_t voice) +int tSimplePoly_getPitch(tSimplePoly* const poly, uint8_t voice) { return poly->voices[voice][2]; } //this one returns negative one if the voice is inactive -int tSimplePoly_getPitchAndCheckActive(tSimplePoly const poly, uint8_t voice) +int tSimplePoly_getPitchAndCheckActive(tSimplePoly* const poly, uint8_t voice) { return poly->voices[voice][0]; } -int tSimplePoly_getVelocity(tSimplePoly const poly, uint8_t voice) +int tSimplePoly_getVelocity(tSimplePoly* const poly, uint8_t voice) { return poly->voices[voice][1]; } -int tSimplePoly_isOn(tSimplePoly const poly, uint8_t voice) +int tSimplePoly_isOn(tSimplePoly* const poly, uint8_t voice) { return (poly->voices[voice][0] > 0) ? 1 : 0; } diff --git a/leaf/Src/leaf-oscillators.c b/leaf/Src/leaf-oscillators.c index 000d935..3242d7b 100644 --- a/leaf/Src/leaf-oscillators.c +++ b/leaf/Src/leaf-oscillators.c @@ -52,10 +52,10 @@ void tCycle_init(tCycle* const cy, LEAF* const leaf) tCycle_initToPool(cy, &leaf->mempool); } -void tCycle_initToPool (tCycle* const cy, tMempool* const mp) +void tCycle_initToPool (tCycle** const cy, tMempool* const mp) { _tMempool* m = *mp; - _tCycle* c = *cy = (_tCycle*) mpool_alloc(sizeof(_tCycle), m); + tCycle* c = *cy = (tCycle*) mpool_alloc(sizeof(tCycle), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -65,15 +65,15 @@ void tCycle_initToPool (tCycle* const cy, tMempool* const mp) c->mask = SINE_TABLE_SIZE - 1; } -void tCycle_free (tCycle* const cy) +void tCycle_free (tCycle** const cy) { - _tCycle* c = *cy; + tCycle* c = *cy; mpool_free((char*)c, c->mempool); } //need to check bounds and wrap table properly to allow through-zero FM -Lfloat tCycle_tick(tCycle const c) +Lfloat tCycle_tick(tCycle* const c) { uint32_t tempFrac; uint32_t idx; @@ -93,7 +93,7 @@ Lfloat tCycle_tick(tCycle const c) return (samp0 + (samp1 - samp0) * ((Lfloat)tempFrac * 0.000000476837386f)); // 1/2097151 } -void tCycle_setFreq(tCycle const c, Lfloat freq) +void tCycle_setFreq(tCycle* const c, Lfloat freq) { //if (!isfinite(freq)) return; @@ -102,7 +102,7 @@ void tCycle_setFreq(tCycle const c, Lfloat freq) c->inc = freq * c->invSampleRateTimesTwoTo32; } -void tCycle_setPhase(tCycle const c, Lfloat phase) +void tCycle_setPhase(tCycle* const c, Lfloat phase) { int i = phase; @@ -110,7 +110,7 @@ void tCycle_setPhase(tCycle const c, Lfloat phase) c->phase = phase * TWO_TO_32; } -void tCycle_setSampleRate (tCycle const c, Lfloat sr) +void tCycle_setSampleRate (tCycle* const c, Lfloat sr) { c->invSampleRateTimesTwoTo32 = (1.0f/sr) * TWO_TO_32; @@ -126,10 +126,10 @@ void tTriangle_init(tTriangle* const cy, LEAF* const leaf) tTriangle_initToPool(cy, &leaf->mempool); } -void tTriangle_initToPool (tTriangle* const cy, tMempool* const mp) +void tTriangle_initToPool (tTriangle** const cy, tMempool* const mp) { _tMempool* m = *mp; - _tTriangle* c = *cy = (_tTriangle*) mpool_alloc(sizeof(_tTriangle), m); + tTriangle* c = *cy = (tTriangle*) mpool_alloc(sizeof(tTriangle), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -141,14 +141,14 @@ void tTriangle_initToPool (tTriangle* const cy, tMempool* const mp) tTriangle_setFreq(c, 220); } -void tTriangle_free (tTriangle* const cy) +void tTriangle_free (tTriangle** const cy) { - _tTriangle* c = *cy; + tTriangle* c = *cy; mpool_free((char*)c, c->mempool); } -Lfloat tTriangle_tick(const tTriangle c) +Lfloat tTriangle_tick(tTriangle* c) { uint32_t idx; Lfloat frac; @@ -174,7 +174,7 @@ Lfloat tTriangle_tick(const tTriangle c) return oct0 + (oct1 - oct0) * c->w; } -void tTriangle_setFreq(const tTriangle c, Lfloat freq) +void tTriangle_setFreq(tTriangle* c, Lfloat freq) { c->freq = freq; c->inc = freq * c->invSampleRateTimesTwoTo32; @@ -189,14 +189,14 @@ void tTriangle_setFreq(const tTriangle c, Lfloat freq) if (c->oct >= 10) c->oct = 9; } -void tTriangle_setPhase(const tTriangle c, Lfloat phase) +void tTriangle_setPhase(tTriangle* c, Lfloat phase) { int i = phase; phase -= i; c->phase = phase * TWO_TO_32; } -void tTriangle_setSampleRate (const tTriangle c, Lfloat sr) +void tTriangle_setSampleRate (tTriangle* c, Lfloat sr) { c->invSampleRate = 1.0f/sr; @@ -213,10 +213,10 @@ void tSquare_init(tSquare* const cy, LEAF* const leaf) tSquare_initToPool(cy, &leaf->mempool); } -void tSquare_initToPool (tSquare* const cy, tMempool* const mp) +void tSquare_initToPool (tSquare** const cy, tMempool* const mp) { _tMempool* m = *mp; - _tSquare* c = *cy = (_tSquare*) mpool_alloc(sizeof(_tSquare), m); + tSquare* c = *cy = (tSquare*) mpool_alloc(sizeof(tSquare), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -228,14 +228,14 @@ void tSquare_initToPool (tSquare* const cy, tMempool* const mp) tSquare_setFreq(*cy, 220); } -void tSquare_free (tSquare* const cy) +void tSquare_free (tSquare** const cy) { - _tSquare* c = *cy; + tSquare* c = *cy; mpool_free((char*)c, c->mempool); } -Lfloat tSquare_tick(const tSquare c) +Lfloat tSquare_tick(tSquare* c) { uint32_t idx; @@ -262,7 +262,7 @@ Lfloat tSquare_tick(const tSquare c) return oct0 + (oct1 - oct0) * c->w; } -void tSquare_setFreq(const tSquare c, Lfloat freq) +void tSquare_setFreq(tSquare* c, Lfloat freq) { c->freq = freq; @@ -278,7 +278,7 @@ void tSquare_setFreq(const tSquare c, Lfloat freq) if (c->oct >= 10) c->oct = 9; } -void tSquare_setPhase(const tSquare c, Lfloat phase) +void tSquare_setPhase(tSquare* c, Lfloat phase) { int i = phase; @@ -286,7 +286,7 @@ void tSquare_setPhase(const tSquare c, Lfloat phase) c->phase = phase * TWO_TO_32; } -void tSquare_setSampleRate (const tSquare c, Lfloat sr) +void tSquare_setSampleRate (tSquare* c, Lfloat sr) { c->invSampleRate = 1.0f/sr; @@ -303,10 +303,10 @@ void tSawtooth_init(tSawtooth* const cy, LEAF* const leaf) tSawtooth_initToPool(cy, &leaf->mempool); } -void tSawtooth_initToPool (tSawtooth* const cy, tMempool* const mp) +void tSawtooth_initToPool (tSawtooth** const cy, tMempool* const mp) { _tMempool* m = *mp; - _tSawtooth* c = *cy = (_tSawtooth*) mpool_alloc(sizeof(_tSawtooth), m); + tSawtooth* c = *cy = (tSawtooth*) mpool_alloc(sizeof(tSawtooth), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -318,14 +318,14 @@ void tSawtooth_initToPool (tSawtooth* const cy, tMempool* const mp) tSawtooth_setFreq(*cy, 220); } -void tSawtooth_free (tSawtooth* const cy) +void tSawtooth_free (tSawtooth** const cy) { - _tSawtooth* c = *cy; + tSawtooth* c = *cy; mpool_free((char*)c, c->mempool); } -Lfloat tSawtooth_tick(const tSawtooth c) +Lfloat tSawtooth_tick(tSawtooth* c) { uint32_t idx; @@ -353,7 +353,7 @@ Lfloat tSawtooth_tick(const tSawtooth c) return oct0 + (oct1 - oct0) * c->w; } -void tSawtooth_setFreq(const tSawtooth c, Lfloat freq) +void tSawtooth_setFreq(tSawtooth* c, Lfloat freq) { c->freq = freq; @@ -369,7 +369,7 @@ void tSawtooth_setFreq(const tSawtooth c, Lfloat freq) if (c->oct >= 10) c->oct = 9; } -void tSawtooth_setPhase(const tSawtooth c, Lfloat phase) +void tSawtooth_setPhase(tSawtooth* c, Lfloat phase) { int i = phase; @@ -377,7 +377,7 @@ void tSawtooth_setPhase(const tSawtooth c, Lfloat phase) c->phase = phase * TWO_TO_32; } -void tSawtooth_setSampleRate (const tSawtooth c, Lfloat sr) +void tSawtooth_setSampleRate (tSawtooth* c, Lfloat sr) { c->invSampleRate = 1.0f/sr; @@ -395,10 +395,10 @@ void tPBTriangle_init (tPBTriangle* const osc, LEAF* const leaf) tPBTriangle_initToPool(osc, &leaf->mempool); } -void tPBTriangle_initToPool (tPBTriangle* const osc, tMempool* const mp) +void tPBTriangle_initToPool (tPBTriangle** const osc, tMempool* const mp) { _tMempool* m = *mp; - _tPBTriangle* c = *osc = (_tPBTriangle*) mpool_alloc(sizeof(_tPBTriangle), m); + tPBTriangle* c = *osc = (tPBTriangle*) mpool_alloc(sizeof(tPBTriangle), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -411,9 +411,9 @@ void tPBTriangle_initToPool (tPBTriangle* const osc, tMempool* const mp) c->freq = 0.0f; } -void tPBTriangle_free (tPBTriangle* const cy) +void tPBTriangle_free (tPBTriangle** const cy) { - _tPBTriangle* c = *cy; + tPBTriangle* c = *cy; mpool_free((char*)c, c->mempool); } @@ -421,7 +421,7 @@ void tPBTriangle_free (tPBTriangle* const cy) #ifdef ITCMRAM Lfloat __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tPBTriangle_tick (tPBTriangle* const osc) #else -Lfloat tPBTriangle_tick (const tPBTriangle c) +Lfloat tPBTriangle_tick (tPBTriangle* c) #endif { @@ -457,7 +457,7 @@ Lfloat tPBTriangle_tick (const tPBTriangle c) #ifdef ITCMRAM void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tPBTriangle_setFreq (tPBTriangle* const osc, Lfloat freq) #else -void tPBTriangle_setFreq (const tPBTriangle c, Lfloat freq) +void tPBTriangle_setFreq (tPBTriangle* c, Lfloat freq) #endif { @@ -465,7 +465,7 @@ void tPBTriangle_setFreq (const tPBTriangle c, Lfloat freq) c->inc = freq * c->invSampleRateTimesTwoTo32; } -void tPBTriangle_setSkew (const tPBTriangle c, Lfloat width) +void tPBTriangle_setSkew (tPBTriangle* c, Lfloat width) { width = width*0.5f + 0.5f; width = LEAF_clip(0.01f, width, 0.99f); @@ -473,7 +473,7 @@ void tPBTriangle_setSkew (const tPBTriangle c, Lfloat width) c->width = width * TWO_TO_32; } -void tPBTriangle_setSampleRate (const tPBTriangle c, Lfloat sr) +void tPBTriangle_setSampleRate (tPBTriangle* c, Lfloat sr) { c->invSampleRate = 1.0f/sr; @@ -490,10 +490,10 @@ void tPBSineTriangle_init (tPBSineTriangle* const osc, LEAF* const l tPBSineTriangle_initToPool(osc, &leaf->mempool); } -void tPBSineTriangle_initToPool (tPBSineTriangle* const osc, tMempool* const mp) +void tPBSineTriangle_initToPool (tPBSineTriangle** const osc, tMempool* const mp) { _tMempool* m = *mp; - _tPBSineTriangle* c = *osc = (_tPBSineTriangle*) mpool_alloc(sizeof(_tPBSineTriangle), m); + tPBSineTriangle* c = *osc = (tPBSineTriangle*) mpool_alloc(sizeof(tPBSineTriangle), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; tCycle_initToPool(&c->sine, mp); @@ -506,9 +506,9 @@ void tPBSineTriangle_initToPool (tPBSineTriangle* const osc, tMempool* con c->oneMinusShape = 1.0f; } -void tPBSineTriangle_free (tPBSineTriangle* const cy) +void tPBSineTriangle_free (tPBSineTriangle** const cy) { - _tPBSineTriangle* c = *cy; + tPBSineTriangle* c = *cy; tCycle_free(&c->sine); mpool_free((char*)c, c->mempool); } @@ -516,7 +516,7 @@ void tPBSineTriangle_free (tPBSineTriangle* const cy) #ifdef ITCMRAM Lfloat __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tPBSineTriangle_tick (tPBSineTriangle* const osc) #else -Lfloat tPBSineTriangle_tick (tPBSineTriangle const c) +Lfloat tPBSineTriangle_tick (tPBSineTriangle* const c) #endif { @@ -539,7 +539,7 @@ Lfloat tPBSineTriangle_tick (tPBSineTriangle const c) y += 4.0f * incFloat * (blamp(t1F, incFloat) - blamp(t2F, incFloat)); y = y * c->shape; // shape handles the inversion so it's in phase with sine (already * -1.0f) - y = y + (tCycle_tick(c->sine) * c->oneMinusShape); + y = y + (tCycle_tick(&c->sine) * c->oneMinusShape); c->phase += c->inc; @@ -549,21 +549,21 @@ Lfloat tPBSineTriangle_tick (tPBSineTriangle const c) #ifdef ITCMRAM void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tPBSineTriangle_setFreq (tPBSineTriangle* const osc, Lfloat freq) #else -void tPBSineTriangle_setFreq (tPBSineTriangle const c, Lfloat freq) +void tPBSineTriangle_setFreq (tPBSineTriangle* const c, Lfloat freq) #endif { c->freq = freq; c->inc = freq * c->invSampleRateTimesTwoTo32; - tCycle_setFreq(c->sine, freq); + tCycle_setFreq(&c->sine, freq); } -void tPBSineTriangle_setShape (tPBSineTriangle const c, Lfloat shape) +void tPBSineTriangle_setShape (tPBSineTriangle* const c, Lfloat shape) { c->shape = 1.0f * shape; c->oneMinusShape = 1.0f - shape; } -void tPBSineTriangle_setSampleRate (tPBSineTriangle const c, Lfloat sr) +void tPBSineTriangle_setSampleRate (tPBSineTriangle* const c, Lfloat sr) { c->invSampleRate = 1.0f/sr; @@ -578,10 +578,10 @@ void tPBPulse_init (tPBPulse* const osc, LEAF* const leaf) tPBPulse_initToPool(osc, &leaf->mempool); } -void tPBPulse_initToPool (tPBPulse* const osc, tMempool* const mp) +void tPBPulse_initToPool (tPBPulse** const osc, tMempool* const mp) { _tMempool* m = *mp; - _tPBPulse* c = *osc = (_tPBPulse*) mpool_alloc(sizeof(_tPBPulse), m); + tPBPulse* c = *osc = (tPBPulse*) mpool_alloc(sizeof(tPBPulse), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -594,9 +594,9 @@ void tPBPulse_initToPool (tPBPulse* const osc, tMempool* const mp) c->freq = 0.0f; } -void tPBPulse_free (tPBPulse* const osc) +void tPBPulse_free (tPBPulse** const osc) { - _tPBPulse* c = *osc; + tPBPulse* c = *osc; mpool_free((char*)c, c->mempool); } @@ -604,7 +604,7 @@ void tPBPulse_free (tPBPulse* const osc) #ifdef ITCMRAM Lfloat __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tPBPulse_tick (tPBPulse* const osc) #else -Lfloat tPBPulse_tick (tPBPulse const c) +Lfloat tPBPulse_tick (tPBPulse* const c) #endif { @@ -626,7 +626,7 @@ Lfloat tPBPulse_tick (tPBPulse const c) #ifdef ITCMRAM void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tPBPulse_setFreq (tPBPulse* const osc, Lfloat freq) #else -void tPBPulse_setFreq (tPBPulse const c, Lfloat freq) +void tPBPulse_setFreq (tPBPulse* const c, Lfloat freq) #endif { @@ -634,7 +634,7 @@ void tPBPulse_setFreq (tPBPulse const c, Lfloat freq) c->inc = freq * c->invSampleRateTimesTwoTo32; } -void tPBPulse_setWidth (tPBPulse const c, Lfloat width) +void tPBPulse_setWidth (tPBPulse* const c, Lfloat width) { //clip width to avoid silence from pulse widths of 0 or 1 if (width < 0.05f) @@ -649,7 +649,7 @@ void tPBPulse_setWidth (tPBPulse const c, Lfloat width) c->width = width * TWO_TO_32; } -void tPBPulse_setSampleRate (tPBPulse const c, Lfloat sr) +void tPBPulse_setSampleRate (tPBPulse* const c, Lfloat sr) { c->invSampleRate = 1.0f/sr; c->invSampleRateTimesTwoTo32 = c->invSampleRate * TWO_TO_32; @@ -664,10 +664,10 @@ void tPBSaw_init (tPBSaw* const osc, LEAF* const leaf) tPBSaw_initToPool(osc, &leaf->mempool); } -void tPBSaw_initToPool (tPBSaw* const osc, tMempool* const mp) +void tPBSaw_initToPool (tPBSaw** const osc, tMempool* const mp) { _tMempool* m = *mp; - _tPBSaw* c = *osc = (_tPBSaw*) mpool_alloc(sizeof(_tPBSaw), m); + tPBSaw* c = *osc = (tPBSaw*) mpool_alloc(sizeof(tPBSaw), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -678,9 +678,9 @@ void tPBSaw_initToPool (tPBSaw* const osc, tMempool* const mp) c->freq = 0.0f; } -void tPBSaw_free (tPBSaw* const osc) +void tPBSaw_free (tPBSaw** const osc) { - _tPBSaw* c = *osc; + tPBSaw* c = *osc; mpool_free((char*)c, c->mempool); } @@ -688,7 +688,7 @@ void tPBSaw_free (tPBSaw* const osc) #ifdef ITCMRAM Lfloat __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tPBSaw_tick (tPBSaw* const osc) #else -Lfloat tPBSaw_tick (tPBSaw const c) +Lfloat tPBSaw_tick (tPBSaw* const c) #endif { Lfloat out = (c->phase * INV_TWO_TO_31) - 1.0f; @@ -703,14 +703,14 @@ Lfloat tPBSaw_tick (tPBSaw const c) #ifdef ITCMRAM void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tPBSaw_setFreq (tPBSaw* const osc, Lfloat freq) #else -void tPBSaw_setFreq (tPBSaw const c, Lfloat freq) +void tPBSaw_setFreq (tPBSaw* const c, Lfloat freq) #endif { c->freq = freq; c->inc = freq * c->invSampleRateTimesTwoTo32; } -void tPBSaw_setSampleRate (tPBSaw const c, Lfloat sr) +void tPBSaw_setSampleRate (tPBSaw* const c, Lfloat sr) { c->invSampleRate = 1.0f/sr; c->invSampleRateTimesTwoTo32 = c->invSampleRate * TWO_TO_32; @@ -726,10 +726,10 @@ void tPBSawSquare_init (tPBSawSquare* const osc, LEAF* const leaf) tPBSawSquare_initToPool(osc, &leaf->mempool); } -void tPBSawSquare_initToPool (tPBSawSquare* const osc, tMempool* const mp) +void tPBSawSquare_initToPool (tPBSawSquare** const osc, tMempool* const mp) { _tMempool* m = *mp; - _tPBSawSquare* c = *osc = (_tPBSawSquare*) mpool_alloc(sizeof(_tPBSawSquare), m); + tPBSawSquare* c = *osc = (tPBSawSquare*) mpool_alloc(sizeof(tPBSawSquare), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -743,9 +743,9 @@ void tPBSawSquare_initToPool (tPBSawSquare* const osc, tMempool* const mp) } -void tPBSawSquare_free (tPBSawSquare* const osc) +void tPBSawSquare_free (tPBSawSquare** const osc) { - _tPBSawSquare* c = *osc; + tPBSawSquare* c = *osc; mpool_free((char*)c, c->mempool); } @@ -754,7 +754,7 @@ void tPBSawSquare_free (tPBSawSquare* const osc) #ifdef ITCMRAM Lfloat __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tPBSawSquare_tick (tPBSawSquare* const osc) #else -Lfloat tPBSawSquare_tick (tPBSawSquare const c) +Lfloat tPBSawSquare_tick (tPBSawSquare* const c) #endif { //Lfloat squareOut = ((c->phase < 2147483648u) * 2.0f) - 1.0f; @@ -782,7 +782,7 @@ Lfloat tPBSawSquare_tick (tPBSawSquare const c) #ifdef ITCMRAM void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tPBSawSquare_setFreq (tPBSawSquare* const osc, Lfloat freq) #else -void tPBSawSquare_setFreq (tPBSawSquare const c, Lfloat freq) +void tPBSawSquare_setFreq (tPBSawSquare* const c, Lfloat freq) #endif { c->freq = freq; @@ -790,13 +790,13 @@ void tPBSawSquare_setFreq (tPBSawSquare const c, Lfloat freq) } -void tPBSawSquare_setShape (tPBSawSquare const c, Lfloat inputShape) +void tPBSawSquare_setShape (tPBSawSquare* const c, Lfloat inputShape) { c->shape = inputShape; c->oneMinusShape = 1.0f - inputShape; } -void tPBSawSquare_setSampleRate (tPBSawSquare const c, Lfloat sr) +void tPBSawSquare_setSampleRate (tPBSawSquare* const c, Lfloat sr) { c->invSampleRate = 1.0f/sr; c->invSampleRateTimesTwoTo32 = c->invSampleRate * TWO_TO_32; @@ -814,10 +814,10 @@ void tSawOS_init (tSawOS* const osc, uint8_t OS_ratio, uint8_t filte tSawOS_initToPool(osc, OS_ratio, filterOrder, &leaf->mempool); } -void tSawOS_initToPool (tSawOS* const osc, uint8_t OS_ratio, uint8_t filterOrder, tMempool* const mp) +void tSawOS_initToPool (tSawOS** const osc, uint8_t OS_ratio, uint8_t filterOrder, tMempool* const mp) { _tMempool* m = *mp; - _tSawOS* c = *osc = (_tSawOS*) mpool_alloc(sizeof(_tSawOS), m); + tSawOS* c = *osc = (tSawOS*) mpool_alloc(sizeof(tSawOS), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; c->OSratio = OS_ratio; @@ -837,15 +837,15 @@ void tSawOS_initToPool (tSawOS* const osc, uint8_t OS_ratio, uint8_t filte tSawOS_setFreq(c, 220.0f); } -void tSawOS_free (tSawOS* const osc) +void tSawOS_free (tSawOS** const osc) { - _tSawOS* c = *osc; + tSawOS* c = *osc; for (int i = 0; i < c->filterOrder; ++i) tSVF_free(&c->aaFilter[i]); mpool_free((char*)c->aaFilter, c->mempool); mpool_free((char*)c, c->mempool); } -Lfloat tSawOS_tick (tSawOS const c) +Lfloat tSawOS_tick (tSawOS* const c) { Lfloat tempFloat = 0.0f; for (int i = 0; i < c->OSratio; i++) @@ -854,19 +854,19 @@ Lfloat tSawOS_tick (tSawOS const c) tempFloat = (c->phase * INV_TWO_TO_16)- 1.0f; // inv 2 to 32, then multiplied by 2, same as inv 2 to 16 for (int k = 0; k < c->filterOrder; k++) { - tempFloat = tSVF_tick(c->aaFilter[k], tempFloat); + tempFloat = tSVF_tick(&c->aaFilter[k], tempFloat); } } return tempFloat; } -void tSawOS_setFreq (tSawOS const c, Lfloat freq) +void tSawOS_setFreq (tSawOS* const c, Lfloat freq) { c->freq = freq; c->inc = freq * c->invSampleRateTimesTwoTo32OS; } -void tSawOS_setSampleRate (tSawOS const c, Lfloat sr) +void tSawOS_setSampleRate (tSawOS* const c, Lfloat sr) { c->invSampleRateOS = 1.0f/(sr * c->OSratio); tSawOS_setFreq(c, c->freq); @@ -881,10 +881,10 @@ void tPhasor_init(tPhasor* const ph, LEAF* const leaf) tPhasor_initToPool(ph, &leaf->mempool); } -void tPhasor_initToPool (tPhasor* const ph, tMempool* const mp) +void tPhasor_initToPool (tPhasor** const ph, tMempool* const mp) { _tMempool* m = *mp; - _tPhasor* p = *ph = (_tPhasor*) mpool_alloc(sizeof(_tPhasor), m); + tPhasor* p = *ph = (tPhasor*) mpool_alloc(sizeof(tPhasor), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -894,26 +894,26 @@ void tPhasor_initToPool (tPhasor* const ph, tMempool* const mp) p->invSampleRateTimesTwoTo32 = p->invSampleRate * TWO_TO_32; } -void tPhasor_free (tPhasor* const ph) +void tPhasor_free (tPhasor** const ph) { - _tPhasor* p = *ph; + tPhasor* p = *ph; mpool_free((char*)p, p->mempool); } -void tPhasor_setFreq(tPhasor const p, Lfloat freq) +void tPhasor_setFreq(tPhasor* const p, Lfloat freq) { p->freq = freq; p->inc = freq * p->invSampleRateTimesTwoTo32; } -Lfloat tPhasor_tick(tPhasor const p) +Lfloat tPhasor_tick(tPhasor* const p) { p->phase += p->inc; // no need to phase wrap, since integer overflow does it for us return p->phase * INV_TWO_TO_32; //smush back to 0.0-1.0 range } -void tPhasor_setSampleRate (tPhasor const p, Lfloat sr) +void tPhasor_setSampleRate (tPhasor* const p, Lfloat sr) { p->invSampleRate = 1.0f/sr; p->invSampleRateTimesTwoTo32 = p->invSampleRate * TWO_TO_32; @@ -927,10 +927,10 @@ void tNoise_init(tNoise* const ns, NoiseType type, LEAF* const leaf) tNoise_initToPool(ns, type, &leaf->mempool); } -void tNoise_initToPool (tNoise* const ns, NoiseType type, tMempool* const mp) +void tNoise_initToPool (tNoise** const ns, NoiseType type, tMempool* const mp) { _tMempool* m = *mp; - _tNoise* n = *ns = (_tNoise*) mpool_alloc(sizeof(_tNoise), m); + tNoise* n = *ns = (tNoise*) mpool_alloc(sizeof(tNoise), m); n->mempool = m; LEAF* leaf = n->mempool->leaf; @@ -938,14 +938,14 @@ void tNoise_initToPool (tNoise* const ns, NoiseType type, tMempool* const m n->rand = leaf->random; } -void tNoise_free (tNoise* const ns) +void tNoise_free (tNoise** const ns) { - _tNoise* n = *ns; + tNoise* n = *ns; mpool_free((char*)n, n->mempool); } -Lfloat tNoise_tick(tNoise const n) +Lfloat tNoise_tick(tNoise* const n) { Lfloat rand = (n->rand() * 2.0f) - 1.0f; @@ -972,16 +972,16 @@ void tNeuron_init(tNeuron* const nr, LEAF* const leaf) tNeuron_initToPool(nr, &leaf->mempool); } -void tNeuron_initToPool (tNeuron* const nr, tMempool* const mp) +void tNeuron_initToPool (tNeuron** const nr, tMempool* const mp) { _tMempool* m = *mp; - _tNeuron* n = *nr = (_tNeuron*) mpool_alloc(sizeof(_tNeuron), m); + tNeuron* n = *nr = (tNeuron*) mpool_alloc(sizeof(tNeuron), m); n->mempool = m; LEAF* leaf = n->mempool->leaf; tPoleZero_initToPool(&n->f, mp); - tPoleZero_setBlockZero(n->f, 0.99f); + tPoleZero_setBlockZero(&n->f, 0.99f); n->invSampleRate = leaf->invSampleRate; n->timeStep = (44100.0f * n->invSampleRate) / 50.0f; @@ -1007,17 +1007,17 @@ void tNeuron_initToPool (tNeuron* const nr, tMempool* const mp) n->rate[2] = n->gL/n->C; } -void tNeuron_free (tNeuron* const nr) +void tNeuron_free (tNeuron** const nr) { - _tNeuron* n = *nr; + tNeuron* n = *nr; tPoleZero_free(&n->f); mpool_free((char*)n, n->mempool); } -void tNeuron_reset(tNeuron const n) +void tNeuron_reset(tNeuron* const n) { - tPoleZero_setBlockZero(n->f, 0.99f); + tPoleZero_setBlockZero(&n->f, 0.99f); n->timeStep = (44100.0f * n->invSampleRate) / 50.0f; @@ -1042,49 +1042,49 @@ void tNeuron_reset(tNeuron const n) n->rate[2] = n->gL/n->C; } -void tNeuron_setV1(tNeuron const n, Lfloat V1) +void tNeuron_setV1(tNeuron* const n, Lfloat V1) { n->V[0] = V1; } -void tNeuron_setV2(tNeuron const n, Lfloat V2) +void tNeuron_setV2(tNeuron* const n, Lfloat V2) { n->V[1] = V2; } -void tNeuron_setV3(tNeuron const n, Lfloat V3) +void tNeuron_setV3(tNeuron* const n, Lfloat V3) { n->V[2] = V3; } -void tNeuron_setTimeStep(tNeuron const n, Lfloat timeStep) +void tNeuron_setTimeStep(tNeuron* const n, Lfloat timeStep) { n->timeStep = (44100.0f * n->invSampleRate) * timeStep; } -void tNeuron_setK(tNeuron const n, Lfloat K) +void tNeuron_setK(tNeuron* const n, Lfloat K) { n->gK = K; } -void tNeuron_setL(tNeuron const n, Lfloat L) +void tNeuron_setL(tNeuron* const n, Lfloat L) { n->gL = L; n->rate[2] = n->gL/n->C; } -void tNeuron_setN(tNeuron const n, Lfloat N) +void tNeuron_setN(tNeuron* const n, Lfloat N) { n->gN = N; } -void tNeuron_setC(tNeuron const n, Lfloat C) +void tNeuron_setC(tNeuron* const n, Lfloat C) { n->C = C; n->rate[2] = n->gL/n->C; } -Lfloat tNeuron_tick(tNeuron const n) +Lfloat tNeuron_tick(tNeuron* const n) { Lfloat output = 0.0f; Lfloat voltage = n->voltage; @@ -1152,23 +1152,23 @@ Lfloat tNeuron_tick(tNeuron const n) //set the output voltage to the "step" ugen, which controls the DAC. output = n->voltage * 0.01f; // volts - output = tPoleZero_tick(n->f, output); + output = tPoleZero_tick(&n->f, output); return output; } -void tNeuron_setMode (tNeuron const n, NeuronMode mode) +void tNeuron_setMode (tNeuron* const n, NeuronMode mode) { n->mode = mode; } -void tNeuron_setCurrent (tNeuron const n, Lfloat current) +void tNeuron_setCurrent (tNeuron* const n, Lfloat current) { n->current = current; } -void tNeuron_setSampleRate (tNeuron const n, Lfloat sr) +void tNeuron_setSampleRate (tNeuron* const n, Lfloat sr) { n->invSampleRate = 1.0f/sr; n->timeStep = (44100.0f * n->invSampleRate) / 50.0f; @@ -1181,10 +1181,10 @@ void tMBPulse_init(tMBPulse* const osc, LEAF* const leaf) tMBPulse_initToPool(osc, &leaf->mempool); } -void tMBPulse_initToPool(tMBPulse* const osc, tMempool* const pool) +void tMBPulse_initToPool(tMBPulse** const osc, tMempool* const pool) { _tMempool* m = *pool; - _tMBPulse* c = *osc = (_tMBPulse*) mpool_alloc(sizeof(_tMBPulse), m); + tMBPulse* c = *osc = (tMBPulse*) mpool_alloc(sizeof(tMBPulse), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -1212,16 +1212,16 @@ void tMBPulse_initToPool(tMBPulse* const osc, tMempool* const pool) memset (c->_f, 0, 8 * sizeof (Lfloat)); } -void tMBPulse_free(tMBPulse* const osc) +void tMBPulse_free(tMBPulse** const osc) { - _tMBPulse* c = *osc; + tMBPulse* c = *osc; mpool_free((char*)c, c->mempool); } //#ifdef ITCMRAM //void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBPulse_place_step_dd_noBuffer(tMBPulse* const osc, int index, Lfloat phase, Lfloat inv_w, Lfloat scale) //#else -void tMBPulse_place_step_dd_noBuffer(tMBPulse const c, int index, Lfloat phase, Lfloat inv_w, Lfloat scale) +void tMBPulse_place_step_dd_noBuffer(tMBPulse* const c, int index, Lfloat phase, Lfloat inv_w, Lfloat scale) //#endif { Lfloat r; @@ -1239,7 +1239,7 @@ void tMBPulse_place_step_dd_noBuffer(tMBPulse const c, int index, Lfloat phase, } -Lfloat tMBPulse_tick(tMBPulse const c) +Lfloat tMBPulse_tick(tMBPulse* const c) { int j, k; Lfloat sync; @@ -1460,20 +1460,20 @@ Lfloat tMBPulse_tick(tMBPulse const c) return -c->out; } -void tMBPulse_setFreq(tMBPulse const c, Lfloat f) +void tMBPulse_setFreq(tMBPulse* const c, Lfloat f) { c->freq = f; c->_w = c->freq * c->invSampleRate; /* phase increment */ c->_inv_w = 1.0f / c->_w; } -void tMBPulse_setWidth(tMBPulse const c, Lfloat w) +void tMBPulse_setWidth(tMBPulse* const c, Lfloat w) { c->waveform = w; c->_b = 0.5f * (1.0f + c->waveform); } -Lfloat tMBPulse_sync(tMBPulse const c, Lfloat value) +Lfloat tMBPulse_sync(tMBPulse* const c, Lfloat value) { //based on https://github.com/VCVRack/Fundamental/blob/5799ee2a9b21492b42ebcb9b65d5395ef5c1cbe2/src/VCO.cpp#L123 Lfloat last = c->lastsyncin; @@ -1487,24 +1487,24 @@ Lfloat tMBPulse_sync(tMBPulse const c, Lfloat value) return value; } -void tMBPulse_setPhase(tMBPulse const c, Lfloat phase) +void tMBPulse_setPhase(tMBPulse* const c, Lfloat phase) { c->_p = phase; } //useful if you have several oscillators so the buffer refill is not synchronized -void tMBPulse_setBufferOffset(tMBPulse const c, uint32_t offset) +void tMBPulse_setBufferOffset(tMBPulse* const c, uint32_t offset) { offset = offset & (FILLEN-1); c->_j = offset; } -void tMBPulse_setSyncMode(tMBPulse const c, int hardOrSoft) +void tMBPulse_setSyncMode(tMBPulse* const c, int hardOrSoft) { c->softsync = hardOrSoft > 0 ? 1 : 0; } -void tMBPulse_setSampleRate(tMBPulse const c, Lfloat sr) +void tMBPulse_setSampleRate(tMBPulse* const c, Lfloat sr) { c->invSampleRate = 1.0f/sr; } @@ -1517,10 +1517,10 @@ void tMBTriangle_init(tMBTriangle* const osc, LEAF* const leaf) tMBTriangle_initToPool(osc, &leaf->mempool); } -void tMBTriangle_initToPool(tMBTriangle* const osc, tMempool* const pool) +void tMBTriangle_initToPool(tMBTriangle** const osc, tMempool* const pool) { _tMempool* m = *pool; - _tMBTriangle* c = *osc = (_tMBTriangle*) mpool_alloc(sizeof(_tMBTriangle), m); + tMBTriangle* c = *osc = (tMBTriangle*) mpool_alloc(sizeof(tMBTriangle), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -1546,16 +1546,16 @@ void tMBTriangle_initToPool(tMBTriangle* const osc, tMempool* const pool) memset (c->_f, 0, 8 * sizeof (Lfloat)); } -void tMBTriangle_free(tMBTriangle* const osc) +void tMBTriangle_free(tMBTriangle** const osc) { - _tMBTriangle* c = *osc; + tMBTriangle* c = *osc; mpool_free((char*)c, c->mempool); } //#ifdef ITCMRAM //void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBTriangle_place_dd_noBuffer(tMBTriangle* const osc, int index, Lfloat phase, Lfloat inv_w, Lfloat scale, Lfloat stepOrSlope, Lfloat w) //#else -void tMBTriangle_place_dd_noBuffer(tMBTriangle const c, int index, Lfloat phase, Lfloat inv_w, Lfloat scale, Lfloat stepOrSlope, Lfloat w) +void tMBTriangle_place_dd_noBuffer(tMBTriangle* const c, int index, Lfloat phase, Lfloat inv_w, Lfloat scale, Lfloat stepOrSlope, Lfloat w) //#endif { Lfloat r; @@ -1574,7 +1574,7 @@ void tMBTriangle_place_dd_noBuffer(tMBTriangle const c, int index, Lfloat phase, c->numBLEPs = (c->numBLEPs + 1) & 63; } -Lfloat tMBTriangle_tick(tMBTriangle const c) +Lfloat tMBTriangle_tick(tMBTriangle* const c) { int j, k; Lfloat sync; @@ -1813,7 +1813,7 @@ Lfloat tMBTriangle_tick(tMBTriangle const c) return -c->out; } -void tMBTriangle_setFreq(tMBTriangle const c, Lfloat f) +void tMBTriangle_setFreq(tMBTriangle* const c, Lfloat f) { c->freq = f; c->_w = c->freq * c->invSampleRate; /* phase increment */ @@ -1821,13 +1821,13 @@ void tMBTriangle_setFreq(tMBTriangle const c, Lfloat f) //c->quarterwaveoffset = c->_w * 0.25f; } -void tMBTriangle_setWidth(tMBTriangle const c, Lfloat w) +void tMBTriangle_setWidth(tMBTriangle* const c, Lfloat w) { w = LEAF_clip(0.0f, w, 0.99f); c->waveform = w; } -Lfloat tMBTriangle_sync(tMBTriangle const c, Lfloat value) +Lfloat tMBTriangle_sync(tMBTriangle* const c, Lfloat value) { //based on https://github.com/VCVRack/Fundamental/blob/5799ee2a9b21492b42ebcb9b65d5395ef5c1cbe2/src/VCO.cpp#L123 Lfloat last = c->lastsyncin; @@ -1841,24 +1841,24 @@ Lfloat tMBTriangle_sync(tMBTriangle const c, Lfloat value) return value; } -void tMBTriangle_setPhase(tMBTriangle const c, Lfloat phase) +void tMBTriangle_setPhase(tMBTriangle* const c, Lfloat phase) { c->_p = phase; } -void tMBTriangle_setSyncMode(tMBTriangle const c, int hardOrSoft) +void tMBTriangle_setSyncMode(tMBTriangle* const c, int hardOrSoft) { c->softsync = hardOrSoft > 0 ? 1 : 0; } //useful if you have several oscillators so the buffer refill is not synchronized -void tMBTriangle_setBufferOffset(tMBTriangle const c, uint32_t offset) +void tMBTriangle_setBufferOffset(tMBTriangle* const c, uint32_t offset) { offset = offset & (FILLEN-1); c->_j = offset; } -void tMBTriangle_setSampleRate(tMBTriangle const c, Lfloat sr) +void tMBTriangle_setSampleRate(tMBTriangle* const c, Lfloat sr) { c->invSampleRate = 1.0f/sr; } @@ -1872,10 +1872,10 @@ void tMBSineTri_init(tMBSineTri* const osc, LEAF* const leaf) tMBSineTri_initToPool(osc, &leaf->mempool); } -void tMBSineTri_initToPool(tMBSineTri* const osc, tMempool* const pool) +void tMBSineTri_initToPool(tMBSineTri** const osc, tMempool* const pool) { _tMempool* m = *pool; - _tMBSineTri* c = *osc = (_tMBSineTri*) mpool_alloc(sizeof(_tMBSineTri), m); + tMBSineTri* c = *osc = (tMBSineTri*) mpool_alloc(sizeof(tMBSineTri), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -1904,16 +1904,16 @@ void tMBSineTri_initToPool(tMBSineTri* const osc, tMempool* const pool) memset (c->_f, 0, 8 * sizeof (Lfloat)); } -void tMBSineTri_free(tMBSineTri* const osc) +void tMBSineTri_free(tMBSineTri** const osc) { - _tMBSineTri* c = *osc; + tMBSineTri* c = *osc; mpool_free((char*)c, c->mempool); } //#ifdef ITCMRAM //void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSineTri_place_dd_noBuffer(tMBSineTri* const osc, int index, Lfloat phase, Lfloat inv_w, Lfloat scale, Lfloat stepOrSlope, Lfloat w) //#else -void tMBSineTri_place_dd_noBuffer(tMBSineTri c, int index, Lfloat phase, Lfloat inv_w, Lfloat scale, Lfloat stepOrSlope, Lfloat w) +void tMBSineTri_place_dd_noBuffer(tMBSineTri* const c, int index, Lfloat phase, Lfloat inv_w, Lfloat scale, Lfloat stepOrSlope, Lfloat w) //#endif { Lfloat r; @@ -1932,7 +1932,7 @@ void tMBSineTri_place_dd_noBuffer(tMBSineTri c, int index, Lfloat phase, Lfloat c->numBLEPs = (c->numBLEPs + 1) & 63; } -Lfloat tMBSineTri_tick(tMBSineTri const c) +Lfloat tMBSineTri_tick(tMBSineTri* const c) { int j, k; Lfloat sync; @@ -2210,7 +2210,7 @@ Lfloat tMBSineTri_tick(tMBSineTri const c) return -c->out; } -void tMBSineTri_setFreq(tMBSineTri const c, Lfloat f) +void tMBSineTri_setFreq(tMBSineTri* const c, Lfloat f) { c->freq = f; c->_w = c->freq * c->invSampleRate; /* phase increment */ @@ -2218,13 +2218,13 @@ void tMBSineTri_setFreq(tMBSineTri const c, Lfloat f) //c->quarterwaveoffset = c->_w * 0.25f; } -void tMBSineTri_setWidth(tMBSineTri const c, Lfloat w) +void tMBSineTri_setWidth(tMBSineTri* const c, Lfloat w) { w = LEAF_clip(0.0f, w, 0.99f); c->waveform = w; } -Lfloat tMBSineTri_sync(tMBSineTri const c, Lfloat value) +Lfloat tMBSineTri_sync(tMBSineTri* const c, Lfloat value) { //based on https://github.com/VCVRack/Fundamental/blob/5799ee2a9b21492b42ebcb9b65d5395ef5c1cbe2/src/VCO.cpp#L123 Lfloat last = c->lastsyncin; @@ -2238,30 +2238,30 @@ Lfloat tMBSineTri_sync(tMBSineTri const c, Lfloat value) return value; } -void tMBSineTri_setPhase(tMBSineTri const c, Lfloat phase) +void tMBSineTri_setPhase(tMBSineTri* const c, Lfloat phase) { c->_p = phase; } -void tMBSineTri_setShape(tMBSineTri const c, Lfloat shape) +void tMBSineTri_setShape(tMBSineTri* const c, Lfloat shape) { c->shape = shape; } -void tMBSineTri_setSyncMode(tMBSineTri const c, int hardOrSoft) +void tMBSineTri_setSyncMode(tMBSineTri* const c, int hardOrSoft) { c->softsync = hardOrSoft > 0 ? 1 : 0; } //useful if you have several oscillators so the buffer refill is not synchronized -void tMBSineTri_setBufferOffset(tMBSineTri const c, uint32_t offset) +void tMBSineTri_setBufferOffset(tMBSineTri* const c, uint32_t offset) { offset = offset & (FILLEN-1); c->_j = offset; } -void tMBSineTri_setSampleRate(tMBSineTri const c, Lfloat sr) +void tMBSineTri_setSampleRate(tMBSineTri* const c, Lfloat sr) { c->invSampleRate = 1.0f/sr; } @@ -2273,10 +2273,10 @@ void tMBSaw_init(tMBSaw* const osc, LEAF* const leaf) tMBSaw_initToPool(osc, &leaf->mempool); } -void tMBSaw_initToPool(tMBSaw* const osc, tMempool* const pool) +void tMBSaw_initToPool(tMBSaw** const osc, tMempool* const pool) { _tMempool* m = *pool; - _tMBSaw* c = *osc = (_tMBSaw*) mpool_alloc(sizeof(_tMBSaw), m); + tMBSaw* c = *osc = (tMBSaw*) mpool_alloc(sizeof(tMBSaw), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -2298,9 +2298,9 @@ void tMBSaw_initToPool(tMBSaw* const osc, tMempool* const pool) memset (c->_f, 0, 8 * sizeof (Lfloat)); } -void tMBSaw_free(tMBSaw* const osc) +void tMBSaw_free(tMBSaw** const osc) { - _tMBSaw* c = *osc; + tMBSaw* c = *osc; mpool_free((char*)c, c->mempool); } @@ -2308,7 +2308,7 @@ void tMBSaw_free(tMBSaw* const osc) //#ifdef ITCMRAM //void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw_place_step_dd_noBuffer(tMBSaw* const osc, int index, Lfloat phase, Lfloat inv_w, Lfloat scale) //#else -void tMBSaw_place_step_dd_noBuffer(tMBSaw const c, int index, Lfloat phase, Lfloat inv_w, Lfloat scale) +void tMBSaw_place_step_dd_noBuffer(tMBSaw* const c, int index, Lfloat phase, Lfloat inv_w, Lfloat scale) //#endif { Lfloat r; @@ -2327,7 +2327,7 @@ void tMBSaw_place_step_dd_noBuffer(tMBSaw const c, int index, Lfloat phase, Lflo -Lfloat tMBSaw_tick(tMBSaw const c) +Lfloat tMBSaw_tick(tMBSaw* const c) { int j; Lfloat sync; @@ -2429,7 +2429,7 @@ Lfloat tMBSaw_tick(tMBSaw const c) return -c->out; } -void tMBSaw_setFreq(tMBSaw const c, Lfloat f) +void tMBSaw_setFreq(tMBSaw* const c, Lfloat f) { c->freq = f; @@ -2437,7 +2437,7 @@ void tMBSaw_setFreq(tMBSaw const c, Lfloat f) c->_inv_w = 1.0f / c->_w; } -Lfloat tMBSaw_sync(tMBSaw const c, Lfloat value) +Lfloat tMBSaw_sync(tMBSaw* const c, Lfloat value) { //based on https://github.com/VCVRack/Fundamental/blob/5799ee2a9b21492b42ebcb9b65d5395ef5c1cbe2/src/VCO.cpp#L123 Lfloat last = c->lastsyncin; @@ -2451,24 +2451,24 @@ Lfloat tMBSaw_sync(tMBSaw const c, Lfloat value) return value; } -void tMBSaw_setPhase(tMBSaw const c, Lfloat phase) +void tMBSaw_setPhase(tMBSaw* const c, Lfloat phase) { c->_p = phase; } -void tMBSaw_setSyncMode(tMBSaw const c, int hardOrSoft) +void tMBSaw_setSyncMode(tMBSaw* const c, int hardOrSoft) { c->softsync = hardOrSoft > 0 ? 1 : 0; } //useful if you have several oscillators so the buffer refill is not synchronized -void tMBSaw_setBufferOffset(tMBSaw const c, uint32_t offset) +void tMBSaw_setBufferOffset(tMBSaw* const c, uint32_t offset) { offset = offset & (FILLEN-1); c->_j = offset; } -void tMBSaw_setSampleRate(tMBSaw const c, Lfloat sr) +void tMBSaw_setSampleRate(tMBSaw* const c, Lfloat sr) { c->invSampleRate = 1.0f/sr; } @@ -2481,10 +2481,10 @@ void tMBSawPulse_init(tMBSawPulse* const osc, LEAF* const leaf) tMBSawPulse_initToPool(osc, &leaf->mempool); } -void tMBSawPulse_initToPool(tMBSawPulse* const osc, tMempool* const pool) +void tMBSawPulse_initToPool(tMBSawPulse** const osc, tMempool* const pool) { _tMempool* m = *pool; - _tMBSawPulse* c = *osc = (_tMBSawPulse*) mpool_alloc(sizeof(_tMBSawPulse), m); + tMBSawPulse* c = *osc = (tMBSawPulse*) mpool_alloc(sizeof(tMBSawPulse), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; c->gain = 1.0f; @@ -2512,9 +2512,9 @@ void tMBSawPulse_initToPool(tMBSawPulse* const osc, tMempool* const pool) } -void tMBSawPulse_free(tMBSawPulse* const osc) +void tMBSawPulse_free(tMBSawPulse** const osc) { - _tMBSawPulse* c = *osc; + tMBSawPulse* c = *osc; mpool_free((char*)c, c->mempool); } @@ -2522,7 +2522,7 @@ void tMBSawPulse_free(tMBSawPulse* const osc) #ifdef ITCMRAM void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSawPulse_place_step_dd_noBuffer(tMBSawPulse* const osc, int index, Lfloat phase, Lfloat inv_w, Lfloat scale) #else -void tMBSawPulse_place_step_dd_noBuffer(tMBSawPulse const c, int index, Lfloat phase, Lfloat inv_w, Lfloat scale) +void tMBSawPulse_place_step_dd_noBuffer(tMBSawPulse* const c, int index, Lfloat phase, Lfloat inv_w, Lfloat scale) #endif { if (c->active) @@ -2548,7 +2548,7 @@ void tMBSawPulse_place_step_dd_noBuffer(tMBSawPulse const c, int index, Lfloat p #ifdef ITCMRAM Lfloat __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSawPulse_tick(tMBSawPulse* const osc) #else -Lfloat tMBSawPulse_tick(tMBSawPulse const c) +Lfloat tMBSawPulse_tick(tMBSawPulse* const c) #endif { int j, k; @@ -2795,7 +2795,7 @@ Lfloat tMBSawPulse_tick(tMBSawPulse const c) #ifdef ITCMRAM void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSawPulse_setFreq(tMBSawPulse* const osc, Lfloat f) #else -void tMBSawPulse_setFreq(tMBSawPulse const c, Lfloat f) +void tMBSawPulse_setFreq(tMBSawPulse* const c, Lfloat f) #endif { c->freq = f; @@ -2816,7 +2816,7 @@ void tMBSawPulse_setFreq(tMBSawPulse const c, Lfloat f) #ifdef ITCMRAM Lfloat __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSawPulse_sync(tMBSawPulse* const osc, Lfloat value) #else -Lfloat tMBSawPulse_sync(tMBSawPulse const c, Lfloat value) +Lfloat tMBSawPulse_sync(tMBSawPulse* const c, Lfloat value) #endif { //based on https://github.com/VCVRack/Fundamental/blob/5799ee2a9b21492b42ebcb9b65d5395ef5c1cbe2/src/VCO.cpp#L123 @@ -2831,29 +2831,29 @@ Lfloat tMBSawPulse_sync(tMBSawPulse const c, Lfloat value) return value; } -void tMBSawPulse_setPhase(tMBSawPulse const c, Lfloat phase) +void tMBSawPulse_setPhase(tMBSawPulse* const c, Lfloat phase) { c->_p = phase; } -void tMBSawPulse_setShape(tMBSawPulse const c, Lfloat shape) +void tMBSawPulse_setShape(tMBSawPulse* const c, Lfloat shape) { c->shape = shape; } -void tMBSawPulse_setSyncMode(tMBSawPulse const c, int hardOrSoft) +void tMBSawPulse_setSyncMode(tMBSawPulse* const c, int hardOrSoft) { c->softsync = hardOrSoft > 0 ? 1 : 0; } //useful if you have several oscillators so the buffer refill is not synchronized -void tMBSawPulse_setBufferOffset(tMBSawPulse const c, uint32_t offset) +void tMBSawPulse_setBufferOffset(tMBSawPulse* const c, uint32_t offset) { offset = offset & (FILLEN-1); c->_j = offset; } -void tMBSawPulse_setSampleRate(tMBSawPulse const c, Lfloat sr) +void tMBSawPulse_setSampleRate(tMBSawPulse* const c, Lfloat sr) { c->invSampleRate = 1.0f/sr; } @@ -2865,10 +2865,10 @@ void tTable_init(tTable* const cy, Lfloat* waveTable, int size, LEAF* const l tTable_initToPool(cy, waveTable, size, &leaf->mempool); } -void tTable_initToPool(tTable* const cy, Lfloat* waveTable, int size, tMempool* const mp) +void tTable_initToPool(tTable** const cy, Lfloat* waveTable, int size, tMempool* const mp) { _tMempool* m = *mp; - _tTable* c = *cy = (_tTable*)mpool_alloc(sizeof(_tTable), m); + tTable* c = *cy = (tTable*)mpool_alloc(sizeof(tTable), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -2879,14 +2879,14 @@ void tTable_initToPool(tTable* const cy, Lfloat* waveTable, int size, tMempoo c->invSampleRate = leaf->invSampleRate; } -void tTable_free(tTable* const cy) +void tTable_free(tTable** const cy) { - _tTable* c = *cy; + tTable* c = *cy; mpool_free((char*)c, c->mempool); } -void tTable_setFreq(tTable const c, Lfloat freq) +void tTable_setFreq(tTable* const c, Lfloat freq) { if (!isfinite(freq)) return; @@ -2895,7 +2895,7 @@ void tTable_setFreq(tTable const c, Lfloat freq) c->inc -= (int)c->inc; } -Lfloat tTable_tick(tTable const c) +Lfloat tTable_tick(tTable* const c) { Lfloat temp; int intPart; @@ -2920,7 +2920,7 @@ Lfloat tTable_tick(tTable const c) return (samp0 + (samp1 - samp0) * fracPart); } -void tTable_setSampleRate(tTable const c, Lfloat sr) +void tTable_setSampleRate(tTable* const c, Lfloat sr) { c->invSampleRate = 1.0f/sr; tTable_setFreq(c, c->freq); @@ -2931,10 +2931,10 @@ void tWaveTable_init(tWaveTable* const cy, Lfloat* table, int size, Lfloat maxFr tWaveTable_initToPool(cy, table, size, maxFreq, &leaf->mempool); } -void tWaveTable_initToPool(tWaveTable* const cy, Lfloat* table, int size, Lfloat maxFreq, tMempool* const mp) +void tWaveTable_initToPool(tWaveTable** const cy, Lfloat* table, int size, Lfloat maxFreq, tMempool* const mp) { _tMempool* m = *mp; - _tWaveTable* c = *cy = (_tWaveTable*) mpool_alloc(sizeof(_tWaveTable), m); + tWaveTable* c = *cy = (tWaveTable*) mpool_alloc(sizeof(tWaveTable), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -2979,7 +2979,7 @@ void tWaveTable_initToPool(tWaveTable* const cy, Lfloat* table, int size, Lfloat tButterworth_initToPool(&c->bl, 8, -1.0f, f, mp); for (int t = 1; t < c->numTables; ++t) { - tButterworth_setF2(c->bl, f); + tButterworth_setF2(&c->bl, f); // Do several passes here to prevent errors at the beginning of the waveform // Not sure how many passes to do, seem to need more as the filter cutoff goes down // 12 might be excessive but seems to work for now. @@ -2987,7 +2987,7 @@ void tWaveTable_initToPool(tWaveTable* const cy, Lfloat* table, int size, Lfloat { for (int i = 0; i < c->size; ++i) { - c->tables[t][i] = tButterworth_tick(c->bl, c->tables[t-1][i]); + c->tables[t][i] = tButterworth_tick(&c->bl, c->tables[t-1][i]); } } f *= 0.5f; //halve the cutoff for next pass @@ -2995,9 +2995,9 @@ void tWaveTable_initToPool(tWaveTable* const cy, Lfloat* table, int size, Lfloat tButterworth_free(&c->bl); } -void tWaveTable_free(tWaveTable* const cy) +void tWaveTable_free(tWaveTable** const cy) { - _tWaveTable* c = *cy; + tWaveTable* c = *cy; mpool_free((char*)c->baseTable, c->mempool); for (int t = 1; t < c->numTables; ++t) @@ -3008,7 +3008,7 @@ void tWaveTable_free(tWaveTable* const cy) mpool_free((char*)c, c->mempool); } -void tWaveTable_setSampleRate(tWaveTable const c, Lfloat sr) +void tWaveTable_setSampleRate(tWaveTable* const c, Lfloat sr) { // Changing the sample rate of a wavetable requires up to partially reinitialize for (int t = 1; t < c->numTables; ++t) @@ -3045,10 +3045,10 @@ void tWaveTable_setSampleRate(tWaveTable const c, Lfloat sr) f = c->sampleRate * 0.25f; //start at half nyquist // Not worth going over order 8 I think, and even 8 is only marginally better than 4. tButterworth_initToPool(&c->bl, 8, -1.0f, f, &c->mempool); - tButterworth_setSampleRate(c->bl, c->sampleRate); + tButterworth_setSampleRate(&c->bl, c->sampleRate); for (int t = 1; t < c->numTables; ++t) { - tButterworth_setF2(c->bl, f); + tButterworth_setF2(&c->bl, f); // Do several passes here to prevent errors at the beginning of the waveform // Not sure how many passes to do, seem to need more as the filter cutoff goes down // 12 might be excessive but seems to work for now. @@ -3056,7 +3056,7 @@ void tWaveTable_setSampleRate(tWaveTable const c, Lfloat sr) { for (int i = 0; i < c->size; ++i) { - c->tables[t][i] = tButterworth_tick(c->bl, c->tables[t-1][i]); + c->tables[t][i] = tButterworth_tick(&c->bl, c->tables[t-1][i]); } } f *= 0.5f; //halve the cutoff for next pass @@ -3072,10 +3072,10 @@ void tWaveOsc_init(tWaveOsc* const cy, tWaveTable* tables, int numTables, LEAF* tWaveOsc_initToPool(cy, tables, numTables, &leaf->mempool); } -void tWaveOsc_initToPool(tWaveOsc* const cy, tWaveTable* tables, int numTables, tMempool* const mp) +void tWaveOsc_initToPool(tWaveOsc** const cy, tWaveTable* tables, int numTables, tMempool* const mp) { _tMempool* m = *mp; - _tWaveOsc* c = *cy = (_tWaveOsc*) mpool_alloc(sizeof(_tWaveOsc), m); + tWaveOsc* c = *cy = (tWaveOsc*) mpool_alloc(sizeof(tWaveOsc), m); c->mempool = m; @@ -3103,13 +3103,13 @@ void tWaveOsc_initToPool(tWaveOsc* const cy, tWaveTable* tables, int numTables, c->maxFreq = c->tables[0]->maxFreq; } -void tWaveOsc_free(tWaveOsc* const cy) +void tWaveOsc_free(tWaveOsc** const cy) { - _tWaveOsc* c = *cy; + tWaveOsc* c = *cy; mpool_free((char*)c, c->mempool); } -Lfloat tWaveOsc_tick(tWaveOsc const c) +Lfloat tWaveOsc_tick(tWaveOsc* const c) { // Phasor increment (unsigned 32bit int wraps automatically with overflow so no need for if branch checks, as you need with Lfloat) c->phase += c->inc; @@ -3176,7 +3176,7 @@ Lfloat tWaveOsc_tick(tWaveOsc const c) return s1 + (s2 - s1) * c->mix; } -void tWaveOsc_setFreq(tWaveOsc const c, Lfloat freq) +void tWaveOsc_setFreq(tWaveOsc* const c, Lfloat freq) { c->freq = freq; @@ -3185,7 +3185,7 @@ void tWaveOsc_setFreq(tWaveOsc const c, Lfloat freq) // abs for negative frequencies c->w = fabsf(c->freq * c->invBaseFreq); - // Probably ok to use a log2 approx here; won't effect tuning at all, just crossfading between octave tables + // Probably ok to use a log2 approx here; won't affect tuning at all, just crossfading between octave tables // I bet we could turn this into a lookup and save a lot of processing c->w = log2f_approx(c->w) + c->aa;//+ LEAF_SQRT2 - 1.0f; adding an offset here will shift our table selection upward, reducing aliasing but lower high freq fidelity. +1.0f should remove all aliasing if (c->w < 0.0f) c->w = 0.0f; // If c->w is < 0.0f, then freq is less than our base freq @@ -3194,12 +3194,12 @@ void tWaveOsc_setFreq(tWaveOsc const c, Lfloat freq) if (c->oct >= c->numSubTables - 1) c->oct = c->numSubTables - 2; } -void tWaveOsc_setAntiAliasing(tWaveOsc const c, Lfloat aa) +void tWaveOsc_setAntiAliasing(tWaveOsc* const c, Lfloat aa) { c->aa = aa; } -void tWaveOsc_setIndex(tWaveOsc const c, Lfloat index) +void tWaveOsc_setIndex(tWaveOsc* const c, Lfloat index) { c->index = index; Lfloat f = c->index * (c->numTables - 1); @@ -3210,7 +3210,7 @@ void tWaveOsc_setIndex(tWaveOsc const c, Lfloat index) c->mix = f - c->o1; } -void tWaveOsc_setTables(tWaveOsc const c, tWaveTable* tables, int numTables) +void tWaveOsc_setTables(tWaveOsc* const c, tWaveTable* tables, int numTables) { LEAF* leaf = c->mempool->leaf; c->tables = tables; @@ -3240,7 +3240,7 @@ void tWaveOscS_setIndexXY(tWaveOscS* const cy, Lfloat indexX, Lfloat indexY) } */ -void tWaveOsc_setSampleRate(tWaveOsc const c, Lfloat sr) +void tWaveOsc_setSampleRate(tWaveOsc* const c, Lfloat sr) { c->sampleRate = sr; // Determine base frequency @@ -3260,10 +3260,10 @@ void tWaveTableS_init(tWaveTableS* const cy, Lfloat* table, int size, Lfloat max tWaveTableS_initToPool(cy, table, size, maxFreq, &leaf->mempool); } -void tWaveTableS_initToPool(tWaveTableS* const cy, Lfloat* table, int size, Lfloat maxFreq, tMempool* const mp) +void tWaveTableS_initToPool(tWaveTableS** const cy, Lfloat* table, int size, Lfloat maxFreq, tMempool* const mp) { _tMempool* m = *mp; - _tWaveTableS* c = *cy = (_tWaveTableS*) mpool_alloc(sizeof(_tWaveTableS), m); + tWaveTableS* c = *cy = (tWaveTableS*) mpool_alloc(sizeof(tWaveTableS), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -3320,20 +3320,20 @@ void tWaveTableS_initToPool(tWaveTableS* const cy, Lfloat* table, int size, Lflo { for (int i = 0; i < c->sizes[t]; ++i) { - c->dsBuffer[0] = tButterworth_tick(c->bl, c->tables[t-1][i*2]); - c->dsBuffer[1] = tButterworth_tick(c->bl, c->tables[t-1][(i*2)+1]); - c->tables[t][i] = tOversampler_downsample(c->ds, c->dsBuffer); + c->dsBuffer[0] = tButterworth_tick(&c->bl, c->tables[t-1][i*2]); + c->dsBuffer[1] = tButterworth_tick(&c->bl, c->tables[t-1][(i*2)+1]); + c->tables[t][i] = tOversampler_downsample(&c->ds, c->dsBuffer); } } } else { - tButterworth_setF2(c->bl, f); + tButterworth_setF2(&c->bl, f); for (int p = 0; p < LEAF_NUM_WAVETABLE_FILTER_PASSES; ++p) { for (int i = 0; i < c->sizes[t]; ++i) { - c->tables[t][i] = tButterworth_tick(c->bl, c->tables[t-1][i]); + c->tables[t][i] = tButterworth_tick(&c->bl, c->tables[t-1][i]); } } f *= 0.5f; //halve the cutoff for next pass @@ -3343,9 +3343,9 @@ void tWaveTableS_initToPool(tWaveTableS* const cy, Lfloat* table, int size, Lflo tButterworth_free(&c->bl); } -void tWaveTableS_free(tWaveTableS* const cy) +void tWaveTableS_free(tWaveTableS** const cy) { - _tWaveTableS* c = *cy; + tWaveTableS* c = *cy; mpool_free((char*)c->baseTable, c->mempool); for (int t = 1; t < c->numTables; ++t) @@ -3358,7 +3358,7 @@ void tWaveTableS_free(tWaveTableS* const cy) mpool_free((char*)c, c->mempool); } -void tWaveTableS_setSampleRate(tWaveTableS const c, Lfloat sr) +void tWaveTableS_setSampleRate(tWaveTableS* const c, Lfloat sr) { int size = c->sizes[0]; @@ -3414,20 +3414,20 @@ void tWaveTableS_setSampleRate(tWaveTableS const c, Lfloat sr) { for (int i = 0; i < c->sizes[t]; ++i) { - c->dsBuffer[0] = tButterworth_tick(c->bl, c->tables[t-1][i*2]); - c->dsBuffer[1] = tButterworth_tick(c->bl, c->tables[t-1][(i*2)+1]); - c->tables[t][i] = tOversampler_downsample(c->ds, c->dsBuffer); + c->dsBuffer[0] = tButterworth_tick(&c->bl, c->tables[t-1][i*2]); + c->dsBuffer[1] = tButterworth_tick(&c->bl, c->tables[t-1][(i*2)+1]); + c->tables[t][i] = tOversampler_downsample(&c->ds, c->dsBuffer); } } } else { - tButterworth_setF2(c->bl, f); + tButterworth_setF2(&c->bl, f); for (int p = 0; p < LEAF_NUM_WAVETABLE_FILTER_PASSES; ++p) { for (int i = 0; i < c->sizes[t]; ++i) { - c->tables[t][i] = tButterworth_tick(c->bl, c->tables[t-1][i]); + c->tables[t][i] = tButterworth_tick(&c->bl, c->tables[t-1][i]); } } f *= 0.5f; //halve the cutoff for next pass @@ -3445,10 +3445,10 @@ void tWaveOscS_init(tWaveOscS* const cy, tWaveTableS* tables, int numTables, LEA tWaveOscS_initToPool(cy, tables, numTables, &leaf->mempool); } -void tWaveOscS_initToPool(tWaveOscS* const cy, tWaveTableS* tables, int numTables, tMempool* const mp) +void tWaveOscS_initToPool(tWaveOscS** const cy, tWaveTableS* tables, int numTables, tMempool* const mp) { _tMempool* m = *mp; - _tWaveOscS* c = *cy = (_tWaveOscS*) mpool_alloc(sizeof(_tWaveOscS), m); + tWaveOscS* c = *cy = (tWaveOscS*) mpool_alloc(sizeof(tWaveOscS), m); c->mempool = m; @@ -3476,9 +3476,9 @@ void tWaveOscS_initToPool(tWaveOscS* const cy, tWaveTableS* tables, int numTable c->maxFreq = c->tables[0]->maxFreq; } -void tWaveOscS_free(tWaveOscS* const cy) +void tWaveOscS_free(tWaveOscS** const cy) { - _tWaveOscS* c = *cy; + tWaveOscS* c = *cy; mpool_free((char*)c, c->mempool); } diff --git a/leaf/Src/leaf-sampling.c b/leaf/Src/leaf-sampling.c index ffec9bf..985068a 100644 --- a/leaf/Src/leaf-sampling.c +++ b/leaf/Src/leaf-sampling.c @@ -29,10 +29,10 @@ void tBuffer_init (tBuffer* const sb, uint32_t length, LEAF* const leaf) tBuffer_initToPool(sb, length, &leaf->mempool); } -void tBuffer_initToPool (tBuffer* const sb, uint32_t length, tMempool* const mp) +void tBuffer_initToPool (tBuffer** const sb, uint32_t length, tMempool* const mp) { _tMempool* m = *mp; - _tBuffer* s = *sb = (_tBuffer*) mpool_alloc(sizeof(_tBuffer), m); + tBuffer* s = *sb = (tBuffer*) mpool_alloc(sizeof(tBuffer), m); s->mempool = m; LEAF* leaf = s->mempool->leaf; @@ -46,15 +46,15 @@ void tBuffer_initToPool (tBuffer* const sb, uint32_t length, tMempool* const mp s->mode = RecordOneShot; } -void tBuffer_free (tBuffer* const sb) +void tBuffer_free (tBuffer** const sb) { - _tBuffer* s = *sb; + tBuffer* s = *sb; mpool_free((char*)s->buff, s->mempool); mpool_free((char*)s, s->mempool); } -void tBuffer_tick (tBuffer const s, Lfloat sample) +void tBuffer_tick (tBuffer* const s, Lfloat sample) { if (s->active == 1) { @@ -77,7 +77,7 @@ void tBuffer_tick (tBuffer const s, Lfloat sample) } } -void tBuffer_read(tBuffer const s, Lfloat* buff, uint32_t len) +void tBuffer_read(tBuffer* const s, Lfloat* buff, uint32_t len) { for (unsigned i = 0; i < s->bufferLength; i++) { @@ -87,34 +87,34 @@ void tBuffer_read(tBuffer const s, Lfloat* buff, uint32_t len) s->recordedLength = len; } -Lfloat tBuffer_get (tBuffer const s, int idx) +Lfloat tBuffer_get (tBuffer* const s, int idx) { if ((idx < 0) || (idx >= (int) s->bufferLength)) return 0.f; return s->buff[idx]; } -void tBuffer_record(tBuffer const s) +void tBuffer_record(tBuffer* const s) { s->active = 1; s->idx = 0; } -void tBuffer_stop(tBuffer const s) +void tBuffer_stop(tBuffer* const s) { s->active = 0; } -int tBuffer_getRecordPosition(tBuffer const s) +int tBuffer_getRecordPosition(tBuffer* const s) { return s->idx; } -void tBuffer_setRecordPosition(tBuffer const s, int pos) +void tBuffer_setRecordPosition(tBuffer* const s, int pos) { s->idx = pos; } -void tBuffer_setRecordMode (tBuffer const s, RecordMode mode) +void tBuffer_setRecordMode (tBuffer* const s, RecordMode mode) { s->mode = mode; } @@ -224,15 +224,15 @@ void tSampler_initToPool(tSampler* const sp, tBuffer* const b, tMempool* const m p->flipIdx = -1; } -void tSampler_free (tSampler* const sp) +void tSampler_free (tSampler** const sp) { - _tSampler* p = *sp; + tSampler* p = *sp; tRamp_free(&p->gain); mpool_free((char*)p, p->mempool); } -void tSampler_setSample (tSampler const p, tBuffer const s) +void tSampler_setSample (tSampler* const p, tBuffer const s) { p->samp = s; @@ -247,7 +247,7 @@ void tSampler_setSample (tSampler const p, tBuffer const s) p->idx = 0.f; } -Lfloat tSampler_tick (tSampler const p) +Lfloat tSampler_tick (tSampler* const p) { attemptStartEndChange(p); From 93d1e9a5d72b8949df9b28eb6c66a2832e0bdf3a Mon Sep 17 00:00:00 2001 From: Sean Xue Date: Fri, 30 May 2025 16:39:18 -0400 Subject: [PATCH 02/14] commit message --- leaf/Src/leaf-analysis.c | 38 +- leaf/Src/leaf-effects.c | 24 +- leaf/Src/leaf-oscillators.c | 186 ++--- leaf/Src/leaf-physical.c | 1446 +++++++++++++++++------------------ leaf/Src/leaf-reverb.c | 352 ++++----- leaf/Src/leaf-sampling.c | 168 ++-- leaf/Src/leaf-vocal.c | 24 +- 7 files changed, 1119 insertions(+), 1119 deletions(-) diff --git a/leaf/Src/leaf-analysis.c b/leaf/Src/leaf-analysis.c index c5f464b..2f538e5 100644 --- a/leaf/Src/leaf-analysis.c +++ b/leaf/Src/leaf-analysis.c @@ -467,7 +467,7 @@ void tSNAC_initToPool (tSNAC** const snac, int overlaparg, tMempool* const s->spectrumbuf = (Lfloat*) mpool_calloc(sizeof(Lfloat) * (SNAC_FRAME_SIZE / 2), m); s->biasbuf = (Lfloat*) mpool_calloc(sizeof(Lfloat) * SNAC_FRAME_SIZE, m); - snac_biasbuf(s); + snac_biasbuf(*s); tSNAC_setOverlap(s, overlaparg); } @@ -492,7 +492,7 @@ void tSNAC_ioSamples (tSNAC* const s, Lfloat *in, int size) // Lfloat *processbuf = s->processbuf; // call analysis function when it is time - if(!(timeindex & (s->framesize / s->overlap - 1))) snac_analyzeframe(s); + if(!(timeindex & (s->framesize / s->overlap - 1))) snac_analyzeframe(*s); while(size--) { @@ -563,10 +563,10 @@ static void snac_analyzeframe(tSNAC* const s) for(n=framesize; n<(framesize<<1); n++) processbuf[n] = 0.; // call analysis procedures - snac_autocorrelation(s); - snac_normalize(s); - snac_pickpeak(s); - snac_periodandfidelity(s); + snac_autocorrelation(*s); + snac_normalize(*s); + snac_pickpeak(*s); + snac_periodandfidelity(*s); } static void snac_autocorrelation(tSNAC* const s) @@ -645,7 +645,7 @@ static void snac_periodandfidelity (tSNAC* const s) { periodlength = (Lfloat)s->periodindex + interpolate3phase(s->processbuf, s->periodindex); - if(periodlength < 8) periodlength = snac_spectralpeak(s, periodlength); + if(periodlength < 8) periodlength = snac_spectralpeak(*s, periodlength); s->periodlength = periodlength; s->fidelity = interpolate3max(s->processbuf, s->periodindex); } @@ -917,14 +917,14 @@ void tZeroCrossingInfo_updatePeak(tZeroCrossingInfo* const z, Lfloat s, int p int tZeroCrossingInfo_period(tZeroCrossingInfo* const z, tZeroCrossingInfo* const next) { - tZeroCrossingInfo* n = *next; + tZeroCrossingInfo* n = &*next; return n->_leading_edge - z->_leading_edge; } Lfloat tZeroCrossingInfo_fractionalPeriod(tZeroCrossingInfo* const z, tZeroCrossingInfo* const next) { - tZeroCrossingInfo* n = *next; + tZeroCrossingInfo* n = &*next; // Get the start edge Lfloat prev1 = z->_before_crossing; @@ -1089,14 +1089,14 @@ static inline void update_state(tZeroCrossingCollector* const z, Lfloat s) { if (z->_ready) { - shift(z, z->_window_size / 2); + shift(*z, z->_window_size / 2); z->_ready = 0; z->_peak = z->_peak_update; z->_peak_update = 0.0f; } if (z->_num_edges >= (int)z->_size) - reset(z); + reset(*z); if (s > 0.0f) { @@ -1455,8 +1455,8 @@ int tPeriodDetector_tick (tPeriodDetector* const p, Lfloat s) if (tZeroCrossingCollector_isReady(&p->_zc)) { - set_bitstream(p); - autocorrelate(p); + set_bitstream(*p); + autocorrelate(*p); return 1; } return 0; @@ -1795,15 +1795,15 @@ void tPitchDetector_free (tPitchDetector** const detector) int tPitchDetector_tick (tPitchDetector* const p, Lfloat s) { - tPeriodDetector_tick(p->_pd, s); + tPeriodDetector_tick(&p->_pd, s); - if (tPeriodDetector_isReset(p->_pd)) + if (tPeriodDetector_isReset(&p->_pd)) { p->_current.frequency = 0.0f; p->_current.periodicity = 0.0f; } - int ready = tPeriodDetector_isReady(p->_pd); + int ready = tPeriodDetector_isReady(&p->_pd); if (ready) { Lfloat periodicity = p->_pd->_fundamental.periodicity; @@ -1819,7 +1819,7 @@ int tPitchDetector_tick (tPitchDetector* const p, Lfloat s) { if (periodicity >= ONSET_PERIODICITY) { - Lfloat f = calculate_frequency(p); + Lfloat f = calculate_frequency(*p); if (f > 0.0f) { p->_current.frequency = f; @@ -1832,11 +1832,11 @@ int tPitchDetector_tick (tPitchDetector* const p, Lfloat s) { if (periodicity < MIN_PERIODICITY) p->_frames_after_shift = 0; - Lfloat f = calculate_frequency(p); + Lfloat f = calculate_frequency(*p); if (f > 0.0f) { _pitch_info info = { f, periodicity }; - bias(p, info); + bias(*p, info); } } } diff --git a/leaf/Src/leaf-effects.c b/leaf/Src/leaf-effects.c index 0a6e6cd..dafd021 100644 --- a/leaf/Src/leaf-effects.c +++ b/leaf/Src/leaf-effects.c @@ -1044,17 +1044,17 @@ void tSOLAD_ioSamples(tSOLAD* const w, Lfloat* in, Lfloat* out, int blocksize) if(!i) { - Lfloat sample = tHighpass_tick(w->hp, in[0]); + Lfloat sample = tHighpass_tick(&w->hp, in[0]); w->delaybuf[0] = sample; w->delaybuf[w->loopSize] = sample; // copy one sample for interpolation n--; i++; in++; } - while(n--) w->delaybuf[i++] = tHighpass_tick(w->hp, *in++); // copy one input block to delay buffer + while(n--) w->delaybuf[i++] = tHighpass_tick(&w->hp, *in++); // copy one input block to delay buffer - tAttackDetection_setBlocksize(w->ad, n); - if (tAttackDetection_detect(w->ad, in)) + tAttackDetection_setBlocksize(&w->ad, n); + if (tAttackDetection_detect(&w->ad, in)) { tSOLAD_setReadLag(w, w->blocksize); } @@ -1367,7 +1367,7 @@ void tPitchShift_initToPool (tPitchShift** const psr, tDualPitchDetector* const ps->sampleRate = leaf->sampleRate; tSOLAD_initToPool(&ps->sola, pow(2.0, ceil(log2(ps->bufSize * 2.0))), mp); - tSOLAD_setPitchFactor(ps->sola, DEFPITCHRATIO); + tSOLAD_setPitchFactor(&ps->sola, DEFPITCHRATIO); } void tPitchShift_free (tPitchShift** const psr) @@ -1380,16 +1380,16 @@ void tPitchShift_free (tPitchShift** const psr) void tPitchShift_shiftBy (tPitchShift* const ps, Lfloat factor, Lfloat* in, Lfloat* out) { - Lfloat detected = tDualPitchDetector_getFrequency(ps->pd); - Lfloat periodicity = tDualPitchDetector_getPeriodicity(ps->pd); + Lfloat detected = tDualPitchDetector_getFrequency(&ps->pd); + Lfloat periodicity = tDualPitchDetector_getPeriodicity(&ps->pd); if (detected > 0.0f && periodicity > ps->pickiness) { Lfloat period = ps->sampleRate / detected; - tSOLAD_setPeriod(ps->sola, period); - tSOLAD_setPitchFactor(ps->sola, factor); + tSOLAD_setPeriod(&ps->sola, period); + tSOLAD_setPitchFactor(&ps->sola, factor); } - tSOLAD_ioSamples(ps->sola, in, out, ps->bufSize); + tSOLAD_ioSamples(&ps->sola, in, out, ps->bufSize); } void tPitchShift_shiftTo (tPitchShift* const ps, Lfloat freq, Lfloat* in, Lfloat* out) @@ -1611,7 +1611,7 @@ void tRetune_free (tRetune** const rt) Lfloat* tRetune_tick(tRetune* const r, Lfloat sample) { - tDualPitchDetector_tick(*r->dp, sample); + tDualPitchDetector_tick(&*r->dp, sample); r->inBuffer[r->index] = sample; for (int i = 0; i < r->numVoices; ++i) @@ -1641,7 +1641,7 @@ void tRetune_setMode (tRetune* const r, int mode) void tRetune_setPickiness (tRetune* const r, Lfloat p) { - tDualPitchDetector_setPeriodicityThreshold(*r->dp, p); + tDualPitchDetector_setPeriodicityThreshold(&*r->dp, p); } //currently broken void tRetune_setNumVoices(tRetune* const r, int numVoices) diff --git a/leaf/Src/leaf-oscillators.c b/leaf/Src/leaf-oscillators.c index 3242d7b..0863829 100644 --- a/leaf/Src/leaf-oscillators.c +++ b/leaf/Src/leaf-oscillators.c @@ -3484,7 +3484,7 @@ void tWaveOscS_free(tWaveOscS** const cy) } volatile int errorCounter = 0; -Lfloat tWaveOscS_tick(tWaveOscS const c) +Lfloat tWaveOscS_tick(tWaveOscS* const c) { // Phasor increment (unsigned 32bit int wraps automatically with overflow so no need for if branch checks, as you need with Lfloat) c->phase += c->inc; @@ -3553,7 +3553,7 @@ Lfloat tWaveOscS_tick(tWaveOscS const c) return s1 + (s2 - s1) * c->mix; } -void tWaveOscS_setFreq(tWaveOscS const c, Lfloat freq) +void tWaveOscS_setFreq(tWaveOscS* const c, Lfloat freq) { c->freq = freq; @@ -3571,12 +3571,12 @@ void tWaveOscS_setFreq(tWaveOscS const c, Lfloat freq) if (c->oct >= c->numSubTables - 1) c->oct = c->numSubTables - 2; } -void tWaveOscS_setAntiAliasing(tWaveOscS const c, Lfloat aa) +void tWaveOscS_setAntiAliasing(tWaveOscS* const c, Lfloat aa) { c->aa = aa; } -void tWaveOscS_setIndex(tWaveOscS const c, Lfloat index) +void tWaveOscS_setIndex(tWaveOscS* const c, Lfloat index) { c->index = index; Lfloat f = c->index * (c->numTables - 1); @@ -3603,7 +3603,7 @@ void tWaveOscS_setIndexXY(tWaveOscS* const cy, Lfloat indexX, Lfloat indexY) } */ -void tWaveOscS_setSampleRate(tWaveOscS const c, Lfloat sr) +void tWaveOscS_setSampleRate(tWaveOscS* const c, Lfloat sr) { if (c->sampleRate == sr) return; @@ -3633,10 +3633,10 @@ void tIntPhasor_init(tIntPhasor* const cy, LEAF* const leaf) tIntPhasor_initToPool(cy, &leaf->mempool); } -void tIntPhasor_initToPool (tIntPhasor* const cy, tMempool* const mp) +void tIntPhasor_initToPool (tIntPhasor** const cy, tMempool* const mp) { _tMempool* m = *mp; - _tIntPhasor* c = *cy = (_tIntPhasor*) mpool_alloc(sizeof(_tIntPhasor), m); + tIntPhasor* c = *cy = (tIntPhasor*) mpool_alloc(sizeof(tIntPhasor), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -3645,15 +3645,15 @@ void tIntPhasor_initToPool (tIntPhasor* const cy, tMempool* const mp) c->invSampleRateTimesTwoTo32 = (leaf->invSampleRate * TWO_TO_32); } -void tIntPhasor_free (tIntPhasor* const cy) +void tIntPhasor_free (tIntPhasor** const cy) { - _tIntPhasor* c = *cy; + tIntPhasor* c = *cy; mpool_free((char*)c, c->mempool); } -Lfloat tIntPhasor_tick(tIntPhasor const c) +Lfloat tIntPhasor_tick(tIntPhasor* const c) { // Phasor increment c->phase = (c->phase + c->inc); @@ -3661,7 +3661,7 @@ Lfloat tIntPhasor_tick(tIntPhasor const c) return c->phase * INV_TWO_TO_32; } -Lfloat tIntPhasor_tickBiPolar(tIntPhasor const c) +Lfloat tIntPhasor_tickBiPolar(tIntPhasor* const c) { // Phasor increment c->phase = (c->phase + c->inc); @@ -3669,20 +3669,20 @@ Lfloat tIntPhasor_tickBiPolar(tIntPhasor const c) return (c->phase * INV_TWO_TO_32 * 2.0f) - 1.0f; } -void tIntPhasor_setFreq(tIntPhasor const c, Lfloat freq) +void tIntPhasor_setFreq(tIntPhasor* const c, Lfloat freq) { c->freq = freq; c->inc = freq * c->invSampleRateTimesTwoTo32; } -void tIntPhasor_setPhase(tIntPhasor const c, Lfloat phase) +void tIntPhasor_setPhase(tIntPhasor* const c, Lfloat phase) { int i = phase; phase -= i; c->phase = phase * TWO_TO_32; } -void tIntPhasor_setSampleRate (tIntPhasor const c, Lfloat sr) +void tIntPhasor_setSampleRate (tIntPhasor* const c, Lfloat sr) { c->invSampleRateTimesTwoTo32 = (1.0f/sr) * TWO_TO_32; tIntPhasor_setFreq(c, c->freq); @@ -3694,58 +3694,58 @@ void tSquareLFO_init(tSquareLFO* const cy, LEAF* const leaf) tSquareLFO_initToPool(cy, &leaf->mempool); } -void tSquareLFO_initToPool (tSquareLFO* const cy, tMempool* const mp) +void tSquareLFO_initToPool (tSquareLFO** const cy, tMempool* const mp) { _tMempool* m = *mp; - _tSquareLFO* c = *cy = (_tSquareLFO*) mpool_alloc(sizeof(_tSquareLFO), m); + tSquareLFO* c = *cy = (tSquareLFO*) mpool_alloc(sizeof(tSquareLFO), m); c->mempool = m; tIntPhasor_initToPool(&c->phasor,mp); tIntPhasor_initToPool(&c->invPhasor,mp); tSquareLFO_setPulseWidth(c, 0.5f); } -void tSquareLFO_free (tSquareLFO* const cy) +void tSquareLFO_free (tSquareLFO** const cy) { - _tSquareLFO* c = *cy; - tIntPhasor_free(c->phasor); - tIntPhasor_free(c->invPhasor); + tSquareLFO* c = *cy; + tIntPhasor_free(&c->phasor); + tIntPhasor_free(&c->invPhasor); mpool_free((char*)c, c->mempool); } //need to check bounds and wrap table properly to allow through-zero FM -Lfloat tSquareLFO_tick(tSquareLFO const c) +Lfloat tSquareLFO_tick(tSquareLFO* const c) { // Phasor increment - Lfloat a = tIntPhasor_tick(c->phasor); - Lfloat b = tIntPhasor_tick(c->invPhasor); + Lfloat a = tIntPhasor_tick(&c->phasor); + Lfloat b = tIntPhasor_tick(&c->invPhasor); Lfloat tmp = ((a - b)) + c->pulsewidth - 0.5f; return 2 * tmp; } -void tSquareLFO_setFreq(tSquareLFO const c, Lfloat freq) +void tSquareLFO_setFreq(tSquareLFO* const c, Lfloat freq) { - tIntPhasor_setFreq(c->phasor,freq); - tIntPhasor_setFreq(c->invPhasor,freq); + tIntPhasor_setFreq(&c->phasor,freq); + tIntPhasor_setFreq(&c->invPhasor,freq); } -void tSquareLFO_setSampleRate (tSquareLFO const c, Lfloat sr) +void tSquareLFO_setSampleRate (tSquareLFO* const c, Lfloat sr) { - tIntPhasor_setSampleRate(c->phasor, sr); - tIntPhasor_setSampleRate(c->invPhasor, sr); + tIntPhasor_setSampleRate(&c->phasor, sr); + tIntPhasor_setSampleRate(&c->invPhasor, sr); } -void tSquareLFO_setPulseWidth(tSquareLFO const c, Lfloat pw) +void tSquareLFO_setPulseWidth(tSquareLFO* const c, Lfloat pw) { c->pulsewidth = pw; - tIntPhasor_setPhase(c->invPhasor, c->pulsewidth + (c->phasor->phase * INV_TWO_TO_32)); + tIntPhasor_setPhase(&c->invPhasor, c->pulsewidth + (c->phasor->phase * INV_TWO_TO_32)); } -void tSquareLFO_setPhase(tSquareLFO const c, Lfloat phase) +void tSquareLFO_setPhase(tSquareLFO* const c, Lfloat phase) { - tIntPhasor_setPhase(c->phasor, phase); - tIntPhasor_setPhase(c->invPhasor, c->pulsewidth + (c->phasor->phase * INV_TWO_TO_32)); + tIntPhasor_setPhase(&c->phasor, phase); + tIntPhasor_setPhase(&c->invPhasor, c->pulsewidth + (c->phasor->phase * INV_TWO_TO_32)); } void tSawSquareLFO_init (tSawSquareLFO* const cy, LEAF* const leaf) @@ -3754,46 +3754,46 @@ void tSawSquareLFO_init (tSawSquareLFO* const cy, LEAF* const leaf) } -void tSawSquareLFO_initToPool (tSawSquareLFO* const cy, tMempool* const mp) +void tSawSquareLFO_initToPool (tSawSquareLFO** const cy, tMempool* const mp) { _tMempool* m = *mp; - _tSawSquareLFO* c = *cy = (_tSawSquareLFO*) mpool_alloc(sizeof(_tSawSquareLFO), m); + tSawSquareLFO* c = *cy = (tSawSquareLFO*) mpool_alloc(sizeof(tSawSquareLFO), m); c->mempool = m; tSquareLFO_initToPool(&c->square,mp); tIntPhasor_initToPool(&c->saw,mp); } -void tSawSquareLFO_free (tSawSquareLFO* const cy) +void tSawSquareLFO_free (tSawSquareLFO** const cy) { - _tSawSquareLFO* c = *cy; + tSawSquareLFO* c = *cy; tIntPhasor_free(&c->saw); tSquareLFO_free(&c->square); mpool_free((char*)c, c->mempool); } -Lfloat tSawSquareLFO_tick (tSawSquareLFO const c) +Lfloat tSawSquareLFO_tick (tSawSquareLFO* const c) { - Lfloat a = (tIntPhasor_tick(c->saw) - 0.5f ) * 2.0f; - Lfloat b = tSquareLFO_tick(c->square); + Lfloat a = (tIntPhasor_tick(&c->saw) - 0.5f ) * 2.0f; + Lfloat b = tSquareLFO_tick(&c->square); return (1 - c->shape) * a + c->shape * b; } -void tSawSquareLFO_setFreq (tSawSquareLFO const c, Lfloat freq) +void tSawSquareLFO_setFreq (tSawSquareLFO* const c, Lfloat freq) { - tSquareLFO_setFreq(c->square, freq); - tIntPhasor_setFreq(c->saw, freq); + tSquareLFO_setFreq(&c->square, freq); + tIntPhasor_setFreq(&c->saw, freq); } -void tSawSquareLFO_setSampleRate (tSawSquareLFO const c, Lfloat sr) +void tSawSquareLFO_setSampleRate (tSawSquareLFO* const c, Lfloat sr) { - tSquareLFO_setSampleRate(c->square, sr); - tIntPhasor_setSampleRate(c->saw, sr); + tSquareLFO_setSampleRate(&c->square, sr); + tIntPhasor_setSampleRate(&c->saw, sr); } -void tSawSquareLFO_setPhase (tSawSquareLFO const c, Lfloat phase) +void tSawSquareLFO_setPhase (tSawSquareLFO* const c, Lfloat phase) { - tSquareLFO_setPhase(c->square, phase); - tIntPhasor_setPhase(c->saw, phase); + tSquareLFO_setPhase(&c->square, phase); + tIntPhasor_setPhase(&c->saw, phase); } -void tSawSquareLFO_setShape (tSawSquareLFO const c, Lfloat shape) +void tSawSquareLFO_setShape (tSawSquareLFO* const c, Lfloat shape) { c->shape = shape; } @@ -3805,10 +3805,10 @@ void tTriLFO_init(tTriLFO* const cy, LEAF* const leaf) tTriLFO_initToPool(cy, &leaf->mempool); } -void tTriLFO_initToPool (tTriLFO* const cy, tMempool* const mp) +void tTriLFO_initToPool (tTriLFO** const cy, tMempool* const mp) { _tMempool* m = *mp; - _tTriLFO* c = *cy = (_tTriLFO*) mpool_alloc(sizeof(_tTriLFO), m); + tTriLFO* c = *cy = (tTriLFO*) mpool_alloc(sizeof(tTriLFO), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -3821,13 +3821,13 @@ void tTriLFO_initToPool (tTriLFO* const cy, tMempool* const mp) void tTriLFO_free (tTriLFO* const cy) { - _tTriLFO* c = *cy; + tTriLFO* c = &*cy; mpool_free((char*)c, c->mempool); } //need to check bounds and wrap table properly to allow through-zero FM -Lfloat tTriLFO_tick(tTriLFO const c) +Lfloat tTriLFO_tick(tTriLFO* const c) { c->phase += c->inc; @@ -3841,20 +3841,20 @@ Lfloat tTriLFO_tick(tTriLFO const c) } -void tTriLFO_setFreq(tTriLFO const c, Lfloat freq) +void tTriLFO_setFreq(tTriLFO* const c, Lfloat freq) { c->freq = freq; c->inc = freq * c->invSampleRateTimesTwoTo32; } -void tTriLFO_setPhase(tTriLFO const c, Lfloat phase) +void tTriLFO_setPhase(tTriLFO* const c, Lfloat phase) { int i = phase; phase -= i; c->phase = phase * TWO_TO_32_INT; } -void tTriLFO_setSampleRate (tTriLFO const c, Lfloat sr) +void tTriLFO_setSampleRate (tTriLFO* const c, Lfloat sr) { c->invSampleRate = (1.0f/sr); c->invSampleRateTimesTwoTo32 = c->invSampleRate * TWO_TO_32; @@ -3867,46 +3867,46 @@ void tSineTriLFO_init (tSineTriLFO* const cy, LEAF* const leaf) tSineTriLFO_initToPool(cy, &leaf->mempool); } -void tSineTriLFO_initToPool (tSineTriLFO* const cy, tMempool* const mp) +void tSineTriLFO_initToPool (tSineTriLFO** const cy, tMempool* const mp) { _tMempool* m = *mp; - _tSineTriLFO* c = *cy = (_tSineTriLFO*) mpool_alloc(sizeof(_tSineTriLFO), m); + tSineTriLFO* c = *cy = (tSineTriLFO*) mpool_alloc(sizeof(tSineTriLFO), m); c->mempool = m; tTriLFO_initToPool(&c->tri,mp); tCycle_initToPool(&c->sine,mp); } -void tSineTriLFO_free (tSineTriLFO* const cy) +void tSineTriLFO_free (tSineTriLFO** const cy) { - _tSineTriLFO* c = *cy; + tSineTriLFO* c = *cy; tCycle_free(&c->sine); tTriLFO_free(&c->tri); mpool_free((char*)c, c->mempool); } -Lfloat tSineTriLFO_tick (tSineTriLFO const c) +Lfloat tSineTriLFO_tick (tSineTriLFO* const c) { - Lfloat a = tCycle_tick(c->sine); - Lfloat b = tTriLFO_tick(c->tri); + Lfloat a = tCycle_tick(&c->sine); + Lfloat b = tTriLFO_tick(&c->tri); return (1.0f - c->shape) * a + c->shape * b; } -void tSineTriLFO_setFreq (tSineTriLFO const c, Lfloat freq) +void tSineTriLFO_setFreq (tSineTriLFO* const c, Lfloat freq) { - tTriLFO_setFreq(c->tri, freq); - tCycle_setFreq(c->sine, freq); + tTriLFO_setFreq(&c->tri, freq); + tCycle_setFreq(&c->sine, freq); } -void tSineTriLFO_setSampleRate (tSineTriLFO const c, Lfloat sr) +void tSineTriLFO_setSampleRate (tSineTriLFO* const c, Lfloat sr) { - tTriLFO_setSampleRate(c->tri, sr); - tCycle_setSampleRate(c->sine, sr); + tTriLFO_setSampleRate(&c->tri, sr); + tCycle_setSampleRate(&c->sine, sr); } -void tSineTriLFO_setPhase (tSineTriLFO const c, Lfloat phase) +void tSineTriLFO_setPhase (tSineTriLFO* const c, Lfloat phase) { - tTriLFO_setPhase(c->tri, phase); - tCycle_setPhase(c->sine, phase); + tTriLFO_setPhase(&c->tri, phase); + tCycle_setPhase(&c->sine, phase); } - void tSineTriLFO_setShape (tSineTriLFO const c, Lfloat shape) + void tSineTriLFO_setShape (tSineTriLFO* const c, Lfloat shape) { c->shape = shape; @@ -3923,10 +3923,10 @@ void tSineTriLFO_setPhase (tSineTriLFO const c, Lfloat phase) - void tDampedOscillator_initToPool (tDampedOscillator* const cy, tMempool* const mp) + void tDampedOscillator_initToPool (tDampedOscillator** const cy, tMempool* const mp) { _tMempool* m = *mp; - _tDampedOscillator* c = *cy = (_tDampedOscillator*) mpool_alloc(sizeof(_tDampedOscillator), m); + tDampedOscillator* c = *cy = (tDampedOscillator*) mpool_alloc(sizeof(tDampedOscillator), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -3941,14 +3941,14 @@ void tSineTriLFO_setPhase (tSineTriLFO const c, Lfloat phase) tDampedOscillator_reset(*cy); } - void tDampedOscillator_free (tDampedOscillator* const cy) + void tDampedOscillator_free (tDampedOscillator** const cy) { - _tDampedOscillator* c = *cy; + tDampedOscillator* c = *cy; mpool_free((char*)c, c->mempool); } - Lfloat tDampedOscillator_tick (tDampedOscillator const c) + Lfloat tDampedOscillator_tick (tDampedOscillator* const c) { Lfloat w = c->decay_ * c->x_; Lfloat z = c->loop_gain_ * (c->y_ + w); @@ -3956,7 +3956,7 @@ void tSineTriLFO_setPhase (tSineTriLFO const c, Lfloat phase) c->y_ = z + w; return c->y_; } - void tDampedOscillator_setFreq (tDampedOscillator const c, Lfloat freq_hz) + void tDampedOscillator_setFreq (tDampedOscillator* const c, Lfloat freq_hz) { c->freq_ = freq_hz; @@ -3974,7 +3974,7 @@ void tSineTriLFO_setPhase (tSineTriLFO const c, Lfloat phase) } - void tDampedOscillator_setDecay (tDampedOscillator const c, Lfloat decay) + void tDampedOscillator_setDecay (tDampedOscillator* const c, Lfloat decay) { Lfloat r = fastExp4(-decay * c->two_pi_by_sample_rate_); @@ -3984,13 +3984,13 @@ void tSineTriLFO_setPhase (tSineTriLFO const c, Lfloat phase) } - void tDampedOscillator_setSampleRate (tDampedOscillator const c, Lfloat sr) + void tDampedOscillator_setSampleRate (tDampedOscillator* const c, Lfloat sr) { c->two_pi_by_sample_rate_ = TWO_PI / sr; } - void tDampedOscillator_reset (tDampedOscillator const c) + void tDampedOscillator_reset (tDampedOscillator* const c) { c->x_ = c->turns_ratio_; c->y_ = 0.0f; @@ -4002,10 +4002,10 @@ void tPlutaQuadOsc_init(tPlutaQuadOsc* const cy, uint32_t const oversamplingR tPlutaQuadOsc_initToPool(cy, oversamplingRatio, &leaf->mempool); } -void tPlutaQuadOsc_initToPool (tPlutaQuadOsc* const cy, uint32_t const oversamplingRatio, tMempool* const mp) +void tPlutaQuadOsc_initToPool (tPlutaQuadOsc** const cy, uint32_t const oversamplingRatio, tMempool* const mp) { _tMempool* m = *mp; - _tPlutaQuadOsc* c = *cy = (_tPlutaQuadOsc*) mpool_alloc(sizeof(_tPlutaQuadOsc), m); + tPlutaQuadOsc* c = *cy = (tPlutaQuadOsc*) mpool_alloc(sizeof(tPlutaQuadOsc), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; c->oversamplingRatio = oversamplingRatio; @@ -4029,9 +4029,9 @@ void tPlutaQuadOsc_initToPool (tPlutaQuadOsc* const cy, uint32_t const over //butterworth lowpass - would be better to create a butterworth object that is lowpass only and uses tSVFtickLP for efficiency tButterworth_initToPool(&c->lowpass, 8, 0.0f, nyquistFreq, mp); //correct samplerate to take into account oversampling - tButterworth_setSampleRate (c->lowpass, oversampledSamplingRate); + tButterworth_setSampleRate (&c->lowpass, oversampledSamplingRate); //now reset the frequencies with new samplerate - tButterworth_setF2 (c->lowpass, nyquistFreq); + tButterworth_setF2 (&c->lowpass, nyquistFreq); Lfloat invSampleRate = 1.0 / oversampledSamplingRate; c->invSampleRateTimesTwoTo32 = (invSampleRate * TWO_TO_32); @@ -4041,7 +4041,7 @@ void tPlutaQuadOsc_initToPool (tPlutaQuadOsc* const cy, uint32_t const over } } -Lfloat tPlutaQuadOsc_tick (tPlutaQuadOsc const c) +Lfloat tPlutaQuadOsc_tick (tPlutaQuadOsc* const c) { Lfloat outputSample = 0.0f; for (int i = 0; i < c->oversamplingRatio; i++) @@ -4062,24 +4062,24 @@ Lfloat tPlutaQuadOsc_tick (tPlutaQuadOsc const c) c->biPolarOutputs[i] = out; currentSample += out * c->outputAmplitudes[i]; } - outputSample = tButterworth_tick(c->lowpass, currentSample); //lowpass before decimation + outputSample = tButterworth_tick(&c->lowpass, currentSample); //lowpass before decimation } //only last sample of the oversampled buffer gets used (decimation step) return outputSample * 0.249f; } -void tPlutaQuadOsc_setFreq (tPlutaQuadOsc const c, uint32_t const whichOsc, Lfloat const freq) +void tPlutaQuadOsc_setFreq (tPlutaQuadOsc* const c, uint32_t const whichOsc, Lfloat const freq) { c->freq[whichOsc] = freq; c->inc[whichOsc] = (uint32_t)(freq * c->invSampleRateTimesTwoTo32); } -void tPlutaQuadOsc_setFmAmount (tPlutaQuadOsc const c, uint32_t const whichCarrier, uint32_t const whichModulator, Lfloat const amount) +void tPlutaQuadOsc_setFmAmount (tPlutaQuadOsc* const c, uint32_t const whichCarrier, uint32_t const whichModulator, Lfloat const amount) { c->fmMatrix[whichCarrier][whichModulator] = amount; } -void tPlutaQuadOsc_setOutputAmplitude (tPlutaQuadOsc const c, uint32_t const whichOsc, Lfloat const amplitude) +void tPlutaQuadOsc_setOutputAmplitude (tPlutaQuadOsc* const c, uint32_t const whichOsc, Lfloat const amplitude) { c->outputAmplitudes[whichOsc] = amplitude; } diff --git a/leaf/Src/leaf-physical.c b/leaf/Src/leaf-physical.c index 87b3e47..df4da86 100644 --- a/leaf/Src/leaf-physical.c +++ b/leaf/Src/leaf-physical.c @@ -34,19 +34,19 @@ void tPickupNonLinearity_init (tPickupNonLinearity* const pl, LEAF* c { tPickupNonLinearity_initToPool(pl, &leaf->mempool); } -void tPickupNonLinearity_initToPool (tPickupNonLinearity* const pl, tMempool* const mp) +void tPickupNonLinearity_initToPool (tPickupNonLinearity** const pl, tMempool* const mp) { _tMempool* m = *mp; - _tPickupNonLinearity* p = *pl = (_tPickupNonLinearity*) mpool_alloc(sizeof(_tPickupNonLinearity), m); + tPickupNonLinearity* p = *pl = (tPickupNonLinearity*) mpool_alloc(sizeof(tPickupNonLinearity), m); p->mempool = m; p->prev = 0.0f; } -void tPickupNonLinearity_free (tPickupNonLinearity* const pl) +void tPickupNonLinearity_free (tPickupNonLinearity** const pl) { - _tPickupNonLinearity* p = *pl; + tPickupNonLinearity* p = *pl; mpool_free((char*)p, p->mempool); } -Lfloat tPickupNonLinearity_tick (tPickupNonLinearity const p, Lfloat x) +Lfloat tPickupNonLinearity_tick (tPickupNonLinearity* const p, Lfloat x) { x = x * 2.0f; Lfloat out = (0.075f * x) + (0.00675f * x * x) +( 0.00211f * x * x * x) + (0.000475f * x * x * x * x) + (0.000831f * x * x * x * x *x); @@ -61,10 +61,10 @@ void tPluck_init (tPluck* const pl, Lfloat lowestFrequency, LEAF* con tPluck_initToPool(pl, lowestFrequency, &leaf->mempool); } -void tPluck_initToPool (tPluck* const pl, Lfloat lowestFrequency, tMempool* const mp) +void tPluck_initToPool (tPluck** const pl, Lfloat lowestFrequency, tMempool* const mp) { _tMempool* m = *mp; - _tPluck* p = *pl = (_tPluck*) mpool_alloc(sizeof(_tPluck), m); + tPluck* p = *pl = (tPluck*) mpool_alloc(sizeof(tPluck), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -79,14 +79,14 @@ void tPluck_initToPool (tPluck* const pl, Lfloat lowestFrequency, tMempool tOneZero_initToPool(&p->loopFilter, 0.0f, mp); tAllpassDelay_initToPool(&p->delayLine, 0.0f, p->sampleRate * 2, mp); - tAllpassDelay_clear(p->delayLine); + tAllpassDelay_clear(&p->delayLine); tPluck_setFrequency(p, 220.0f); } -void tPluck_free (tPluck* const pl) +void tPluck_free (tPluck** const pl) { - _tPluck* p = *pl; + tPluck* p = *pl; tNoise_free(&p->noise); tOnePole_free(&p->pickFilter); @@ -96,31 +96,31 @@ void tPluck_free (tPluck* const pl) mpool_free((char*)p, p->mempool); } -Lfloat tPluck_getLastOut (tPluck const p) +Lfloat tPluck_getLastOut (tPluck* const p) { return p->lastOut; } -Lfloat tPluck_tick (tPluck const p) +Lfloat tPluck_tick (tPluck* const p) { - return (p->lastOut = 3.0f * tAllpassDelay_tick(p->delayLine, tOneZero_tick(p->loopFilter, tAllpassDelay_getLastOut(p->delayLine) * p->loopGain ) )); + return (p->lastOut = 3.0f * tAllpassDelay_tick(&p->delayLine, tOneZero_tick(&p->loopFilter, tAllpassDelay_getLastOut(&p->delayLine) * p->loopGain ) )); } -void tPluck_pluck (tPluck const p, Lfloat amplitude) +void tPluck_pluck (tPluck* const p, Lfloat amplitude) { if ( amplitude < 0.0f) amplitude = 0.0f; else if (amplitude > 1.0f) amplitude = 1.0f; - tOnePole_setPole(p->pickFilter, 0.999f - (amplitude * 0.15f)); - tOnePole_setGain(p->pickFilter, amplitude * 0.5f ); + tOnePole_setPole(&p->pickFilter, 0.999f - (amplitude * 0.15f)); + tOnePole_setGain(&p->pickFilter, amplitude * 0.5f ); // Fill delay with noise additively with current contents. - for ( uint32_t i = 0; i < (uint32_t)tAllpassDelay_getDelay(p->delayLine); i++ ) - tAllpassDelay_tick(p->delayLine, 0.6f * tAllpassDelay_getLastOut(p->delayLine) + tOnePole_tick(p->pickFilter, tNoise_tick(p->noise) ) ); + for ( uint32_t i = 0; i < (uint32_t)tAllpassDelay_getDelay(&p->delayLine); i++ ) + tAllpassDelay_tick(&p->delayLine, 0.6f * tAllpassDelay_getLastOut(&p->delayLine) + tOnePole_tick(&p->pickFilter, tNoise_tick(&p->noise) ) ); } // Start a note with the given frequency and amplitude.; -void tPluck_noteOn (tPluck const p, Lfloat frequency, Lfloat amplitude ) +void tPluck_noteOn (tPluck* const p, Lfloat frequency, Lfloat amplitude ) { p->lastFreq = frequency; tPluck_setFrequency(p, frequency ); @@ -128,7 +128,7 @@ void tPluck_noteOn (tPluck const p, Lfloat frequency, Lfloat amplitude } // Stop a note with the given amplitude (speed of decay). -void tPluck_noteOff (tPluck const p, Lfloat amplitude ) +void tPluck_noteOff (tPluck* const p, Lfloat amplitude ) { if ( amplitude < 0.0f) amplitude = 0.0f; else if (amplitude > 1.0f) amplitude = 1.0f; @@ -137,14 +137,14 @@ void tPluck_noteOff (tPluck const p, Lfloat amplitude ) } // Set instrument parameters for a particular frequency. -void tPluck_setFrequency (tPluck const p, Lfloat frequency ) +void tPluck_setFrequency (tPluck* const p, Lfloat frequency ) { if ( frequency <= 0.0f ) frequency = 0.001f; // Delay = length - filter delay. - Lfloat delay = ( p->sampleRate / frequency ) - tOneZero_getPhaseDelay(p->loopFilter, frequency ); + Lfloat delay = ( p->sampleRate / frequency ) - tOneZero_getPhaseDelay(&p->loopFilter, frequency ); - tAllpassDelay_setDelay(p->delayLine, delay ); + tAllpassDelay_setDelay(&p->delayLine, delay ); p->loopGain = 0.99f + (frequency * 0.000005f); @@ -152,22 +152,22 @@ void tPluck_setFrequency (tPluck const p, Lfloat frequency ) } // Perform the control change specified by \e number and \e value (0.0 - 128.0). -void tPluck_controlChange (tPluck const p, int number, Lfloat value) +void tPluck_controlChange (tPluck* const p, int number, Lfloat value) { return; } -void tPluck_setSampleRate(tPluck const p, Lfloat sr) +void tPluck_setSampleRate(tPluck* const p, Lfloat sr) { p->sampleRate = sr; tAllpassDelay_free(&p->delayLine); tAllpassDelay_initToPool(&p->delayLine, 0.0f, p->sampleRate * 2, &p->mempool); - tAllpassDelay_clear(p->delayLine); + tAllpassDelay_clear(&p->delayLine); tPluck_setFrequency(p, p->lastFreq); - tOnePole_setSampleRate(p->pickFilter, p->sampleRate); - tOneZero_setSampleRate(p->loopFilter, p->sampleRate); + tOnePole_setSampleRate(&p->pickFilter, p->sampleRate); + tOneZero_setSampleRate(&p->loopFilter, p->sampleRate); } /* ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ tKarplusStrong ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ @@ -176,10 +176,10 @@ void tKarplusStrong_init (tKarplusStrong* const pl, Lfloat lowestFrequency, L tKarplusStrong_initToPool(pl, lowestFrequency, &leaf->mempool); } -void tKarplusStrong_initToPool (tKarplusStrong* const pl, Lfloat lowestFrequency, tMempool* const mp) +void tKarplusStrong_initToPool (tKarplusStrong** const pl, Lfloat lowestFrequency, tMempool* const mp) { _tMempool* m = *mp; - _tKarplusStrong* p = *pl = (_tKarplusStrong*) mpool_alloc(sizeof(_tKarplusStrong), m); + tKarplusStrong* p = *pl = (tKarplusStrong*) mpool_alloc(sizeof(tKarplusStrong), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -188,10 +188,10 @@ void tKarplusStrong_initToPool (tKarplusStrong* const pl, Lfloat lowestFreq if ( lowestFrequency <= 0.0f ) lowestFrequency = 8.0f; tAllpassDelay_initToPool(&p->delayLine, 0.0f, p->sampleRate * 2, mp); - tAllpassDelay_clear(p->delayLine); + tAllpassDelay_clear(&p->delayLine); tLinearDelay_initToPool(&p->combDelay, 0.0f, p->sampleRate * 2, mp); - tLinearDelay_clear(p->combDelay); + tLinearDelay_clear(&p->combDelay); tOneZero_initToPool(&p->filter, 0.0f, mp); @@ -212,9 +212,9 @@ void tKarplusStrong_initToPool (tKarplusStrong* const pl, Lfloat lowestFreq tKarplusStrong_setFrequency( *pl, 220.0f ); } -void tKarplusStrong_free (tKarplusStrong* const pl) +void tKarplusStrong_free (tKarplusStrong** const pl) { - _tKarplusStrong* p = *pl; + tKarplusStrong* p = *pl; tAllpassDelay_free(&p->delayLine); tLinearDelay_free(&p->combDelay); @@ -229,52 +229,52 @@ void tKarplusStrong_free (tKarplusStrong* const pl) mpool_free((char*)p, p->mempool); } -Lfloat tKarplusStrong_getLastOut (tKarplusStrong const p) +Lfloat tKarplusStrong_getLastOut (tKarplusStrong* const p) { return p->lastOut; } -Lfloat tKarplusStrong_tick (tKarplusStrong const p) +Lfloat tKarplusStrong_tick (tKarplusStrong* const p) { - Lfloat temp = tAllpassDelay_getLastOut(p->delayLine) * p->loopGain; + Lfloat temp = tAllpassDelay_getLastOut(&p->delayLine) * p->loopGain; // Calculate allpass stretching. - for (int i=0; i<4; i++) temp = tBiQuad_tick(p->biquad[i],temp); + for (int i=0; i<4; i++) temp = tBiQuad_tick(&p->biquad[i],temp); // Moving average filter. - temp = tOneZero_tick(p->filter, temp); + temp = tOneZero_tick(&p->filter, temp); - Lfloat out = tAllpassDelay_tick(p->delayLine, temp); - out = out - tLinearDelay_tick(p->combDelay, out); + Lfloat out = tAllpassDelay_tick(&p->delayLine, temp); + out = out - tLinearDelay_tick(&p->combDelay, out); p->lastOut = out; return p->lastOut; } -void tKarplusStrong_pluck (tKarplusStrong const p, Lfloat amplitude) +void tKarplusStrong_pluck (tKarplusStrong* const p, Lfloat amplitude) { if ( amplitude < 0.0f) amplitude = 0.0f; else if (amplitude > 1.0f) amplitude = 1.0f; p->pluckAmplitude = amplitude; - for ( uint32_t i=0; i < (uint32_t)tAllpassDelay_getDelay(p->delayLine); i++ ) + for ( uint32_t i=0; i < (uint32_t)tAllpassDelay_getDelay(&p->delayLine); i++ ) { // Fill delay with noise additively with current contents. - tAllpassDelay_tick(p->delayLine, (tAllpassDelay_getLastOut(p->delayLine) * 0.6f) + 0.4f * tNoise_tick(p->noise) * p->pluckAmplitude ); + tAllpassDelay_tick(&p->delayLine, (tAllpassDelay_getLastOut(&p->delayLine) * 0.6f) + 0.4f * tNoise_tick(&p->noise) * p->pluckAmplitude ); //delayLine_.tick( combDelay_.tick((delayLine_.lastOut() * 0.6) + 0.4 * noise->tick() * pluckAmplitude_) ); } } // Start a note with the given frequency and amplitude.; -void tKarplusStrong_noteOn (tKarplusStrong const p, Lfloat frequency, Lfloat amplitude ) +void tKarplusStrong_noteOn (tKarplusStrong* const p, Lfloat frequency, Lfloat amplitude ) { tKarplusStrong_setFrequency(p, frequency ); tKarplusStrong_pluck(p, amplitude ); } // Stop a note with the given amplitude (speed of decay). -void tKarplusStrong_noteOff (tKarplusStrong const p, Lfloat amplitude ) +void tKarplusStrong_noteOff (tKarplusStrong* const p, Lfloat amplitude ) { if ( amplitude < 0.0f) amplitude = 0.0f; else if (amplitude > 1.0f) amplitude = 1.0f; @@ -283,14 +283,14 @@ void tKarplusStrong_noteOff (tKarplusStrong const p, Lfloat amplitude ) } // Set instrument parameters for a particular frequency. -void tKarplusStrong_setFrequency (tKarplusStrong const p, Lfloat frequency ) +void tKarplusStrong_setFrequency (tKarplusStrong* const p, Lfloat frequency ) { if ( frequency <= 0.0f ) frequency = 0.001f; p->lastFrequency = frequency; p->lastLength = p->sampleRate / p->lastFrequency; Lfloat delay = p->lastLength - 0.5f; - tAllpassDelay_setDelay(p->delayLine, delay); + tAllpassDelay_setDelay(&p->delayLine, delay); // MAYBE MODIFY LOOP GAINS p->loopGain = p->baseLoopGain + (frequency * 0.000005f); @@ -298,11 +298,11 @@ void tKarplusStrong_setFrequency (tKarplusStrong const p, Lfloat frequency ) tKarplusStrong_setStretch(p, p->stretching); - tLinearDelay_setDelay(p->combDelay, 0.5f * p->pickupPosition * p->lastLength); + tLinearDelay_setDelay(&p->combDelay, 0.5f * p->pickupPosition * p->lastLength); } // Set the stretch "factor" of the string (0.0 - 1.0). -void tKarplusStrong_setStretch (tKarplusStrong const p, Lfloat stretch) +void tKarplusStrong_setStretch (tKarplusStrong* const p, Lfloat stretch) { p->stretching = stretch; Lfloat coefficient; @@ -314,30 +314,30 @@ void tKarplusStrong_setStretch (tKarplusStrong const p, Lfloat stretc for ( int i=0; i<4; i++ ) { coefficient = temp * temp; - tBiQuad_setA2(p->biquad[i], coefficient); - tBiQuad_setB0(p->biquad[i], coefficient); - tBiQuad_setB2(p->biquad[i], 1.0f); + tBiQuad_setA2(&p->biquad[i], coefficient); + tBiQuad_setB0(&p->biquad[i], coefficient); + tBiQuad_setB2(&p->biquad[i], 1.0f); coefficient = -2.0f * temp * cosf(TWO_PI * freq / p->sampleRate); - tBiQuad_setA1(p->biquad[i], coefficient); - tBiQuad_setB1(p->biquad[i], coefficient); + tBiQuad_setA1(&p->biquad[i], coefficient); + tBiQuad_setB1(&p->biquad[i], coefficient); freq += dFreq; } } // Set the pluck or "excitation" position along the string (0.0 - 1.0). -void tKarplusStrong_setPickupPosition (tKarplusStrong const p, Lfloat position ) +void tKarplusStrong_setPickupPosition (tKarplusStrong* const p, Lfloat position ) { if (position < 0.0f) p->pickupPosition = 0.0f; else if (position <= 1.0f) p->pickupPosition = position; else p->pickupPosition = 1.0f; - tLinearDelay_setDelay(p->combDelay, 0.5f * p->pickupPosition * p->lastLength); + tLinearDelay_setDelay(&p->combDelay, 0.5f * p->pickupPosition * p->lastLength); } // Set the base loop gain. -void tKarplusStrong_setBaseLoopGain (tKarplusStrong const p, Lfloat aGain ) +void tKarplusStrong_setBaseLoopGain (tKarplusStrong* const p, Lfloat aGain ) { p->baseLoopGain = aGain; p->loopGain = p->baseLoopGain + (p->lastFrequency * 0.000005f); @@ -345,7 +345,7 @@ void tKarplusStrong_setBaseLoopGain (tKarplusStrong const p, Lfloat aGain } // Perform the control change specified by \e number and \e value (0.0 - 128.0). -void tKarplusStrong_controlChange (tKarplusStrong const p, SKControlType type, Lfloat value) +void tKarplusStrong_controlChange (tKarplusStrong* const p, SKControlType type, Lfloat value) { if ( value < 0.0f ) value = 0.0f; else if (value > 128.0f) value = 128.0f; @@ -360,24 +360,24 @@ void tKarplusStrong_controlChange (tKarplusStrong const p, SKControlType type tKarplusStrong_setStretch(p, 0.91f + (0.09f * (1.0f - normalizedValue)) ); } -void tKarplusStrong_setSampleRate (tKarplusStrong const p, Lfloat sr) +void tKarplusStrong_setSampleRate (tKarplusStrong* const p, Lfloat sr) { p->sampleRate = sr; tAllpassDelay_free(&p->delayLine); tAllpassDelay_initToPool(&p->delayLine, 0.0f, p->sampleRate * 2, &p->mempool); - tAllpassDelay_clear(p->delayLine); + tAllpassDelay_clear(&p->delayLine); tLinearDelay_free(&p->combDelay); tLinearDelay_initToPool(&p->combDelay, 0.0f, p->sampleRate * 2, &p->mempool); - tLinearDelay_clear(p->combDelay); + tLinearDelay_clear(&p->combDelay); tKarplusStrong_setFrequency(p, p->lastFrequency); - tOneZero_setSampleRate(p->filter, p->sampleRate); + tOneZero_setSampleRate(&p->filter, p->sampleRate); for (int i = 0; i < 4; i++) { - tBiQuad_setSampleRate(p->biquad[i], p->sampleRate); + tBiQuad_setSampleRate(&p->biquad[i], p->sampleRate); } } @@ -390,12 +390,12 @@ void tSimpleLivingString_init(tSimpleLivingString* const pl, Lfloat freq, Lfl tSimpleLivingString_initToPool(pl, freq, dampFreq, decay, targetLev, levSmoothFactor, levStrength, levMode, &leaf->mempool); } -void tSimpleLivingString_initToPool (tSimpleLivingString* const pl, Lfloat freq, Lfloat dampFreq, +void tSimpleLivingString_initToPool (tSimpleLivingString** const pl, Lfloat freq, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, tMempool* const mp) { _tMempool* m = *mp; - _tSimpleLivingString* p = *pl = (_tSimpleLivingString*) mpool_alloc(sizeof(_tSimpleLivingString), m); + tSimpleLivingString* p = *pl = (tSimpleLivingString*) mpool_alloc(sizeof(tSimpleLivingString), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -404,7 +404,7 @@ void tSimpleLivingString_initToPool (tSimpleLivingString* const pl, Lfloat f tExpSmooth_initToPool(&p->wlSmooth, p->sampleRate/freq, 0.01f, mp); // smoother for string wavelength (not freq, to avoid expensive divisions) tSimpleLivingString_setFreq(*pl, freq); tLinearDelay_initToPool(&p->delayLine,p->waveLengthInSamples, 2400, mp); - tLinearDelay_clear(p->delayLine); + tLinearDelay_clear(&p->delayLine); tOnePole_initToPool(&p->bridgeFilter, dampFreq, mp); tHighpass_initToPool(&p->DCblocker,13, mp); p->decay=decay; @@ -412,9 +412,9 @@ void tSimpleLivingString_initToPool (tSimpleLivingString* const pl, Lfloat f p->levMode=levMode; } -void tSimpleLivingString_free (tSimpleLivingString* const pl) +void tSimpleLivingString_free (tSimpleLivingString** const pl) { - _tSimpleLivingString* p = *pl; + tSimpleLivingString* p = *pl; tExpSmooth_free(&p->wlSmooth); tLinearDelay_free(&p->delayLine); @@ -425,7 +425,7 @@ void tSimpleLivingString_free (tSimpleLivingString* const pl) mpool_free((char*)p, p->mempool); } -void tSimpleLivingString_setFreq(tSimpleLivingString const p, Lfloat freq) +void tSimpleLivingString_setFreq(tSimpleLivingString* const p, Lfloat freq) { if (freq<20) freq=20; else if (freq>10000) freq=10000; @@ -433,7 +433,7 @@ void tSimpleLivingString_setFreq(tSimpleLivingString const p, Lfloat freq) tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); } -void tSimpleLivingString_setWaveLength(tSimpleLivingString const p, Lfloat waveLength) +void tSimpleLivingString_setWaveLength(tSimpleLivingString* const p, Lfloat waveLength) { if (waveLength<4.8) waveLength=4.8f; else if (waveLength>2400) waveLength=2400; @@ -441,60 +441,60 @@ void tSimpleLivingString_setWaveLength(tSimpleLivingString const p, Lfloat w tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); } -void tSimpleLivingString_setDampFreq(tSimpleLivingString const p, Lfloat dampFreq) +void tSimpleLivingString_setDampFreq(tSimpleLivingString* const p, Lfloat dampFreq) { - tOnePole_setFreq(p->bridgeFilter, dampFreq); + tOnePole_setFreq(&p->bridgeFilter, dampFreq); } -void tSimpleLivingString_setDecay(tSimpleLivingString const p, Lfloat decay) +void tSimpleLivingString_setDecay(tSimpleLivingString* const p, Lfloat decay) { p->decay=decay; } -void tSimpleLivingString_setTargetLev(tSimpleLivingString const p, Lfloat targetLev) +void tSimpleLivingString_setTargetLev(tSimpleLivingString* const p, Lfloat targetLev) { - tFeedbackLeveler_setTargetLevel(p->fbLev, targetLev); + tFeedbackLeveler_setTargetLevel(&p->fbLev, targetLev); } -void tSimpleLivingString_setLevSmoothFactor(tSimpleLivingString const p, Lfloat levSmoothFactor) +void tSimpleLivingString_setLevSmoothFactor(tSimpleLivingString* const p, Lfloat levSmoothFactor) { - tFeedbackLeveler_setFactor(p->fbLev, levSmoothFactor); + tFeedbackLeveler_setFactor(&p->fbLev, levSmoothFactor); } -void tSimpleLivingString_setLevStrength(tSimpleLivingString const p, Lfloat levStrength) +void tSimpleLivingString_setLevStrength(tSimpleLivingString* const p, Lfloat levStrength) { - tFeedbackLeveler_setStrength(p->fbLev, levStrength); + tFeedbackLeveler_setStrength(&p->fbLev, levStrength); } -void tSimpleLivingString_setLevMode(tSimpleLivingString const p, int levMode) +void tSimpleLivingString_setLevMode(tSimpleLivingString* const p, int levMode) { - tFeedbackLeveler_setMode(p->fbLev, levMode); + tFeedbackLeveler_setMode(&p->fbLev, levMode); p->levMode=levMode; } -Lfloat tSimpleLivingString_tick(tSimpleLivingString const p, Lfloat input) +Lfloat tSimpleLivingString_tick(tSimpleLivingString* const p, Lfloat input) { - Lfloat stringOut=tOnePole_tick(p->bridgeFilter,tLinearDelay_tickOut(p->delayLine)); - Lfloat stringInput=tHighpass_tick(p->DCblocker, tFeedbackLeveler_tick(p->fbLev, (p->levMode==0?p->decay*stringOut:stringOut)+input)); - tLinearDelay_tickIn(p->delayLine, stringInput); - tLinearDelay_setDelay(p->delayLine, tExpSmooth_tick(p->wlSmooth)); + Lfloat stringOut=tOnePole_tick(&p->bridgeFilter,tLinearDelay_tickOut(&p->delayLine)); + Lfloat stringInput=tHighpass_tick(&p->DCblocker, tFeedbackLeveler_tick(&p->fbLev, (p->levMode==0?p->decay*stringOut:stringOut)+input)); + tLinearDelay_tickIn(&p->delayLine, stringInput); + tLinearDelay_setDelay(&p->delayLine, tExpSmooth_tick(p->wlSmooth)); p->curr = stringOut; return p->curr; } -Lfloat tSimpleLivingString_sample(tSimpleLivingString const p) +Lfloat tSimpleLivingString_sample(tSimpleLivingString* const p) { return p->curr; } -void tSimpleLivingString_setSampleRate(tSimpleLivingString const p, Lfloat sr) +void tSimpleLivingString_setSampleRate(tSimpleLivingString* const p, Lfloat sr) { Lfloat freq = p->sampleRate/p->waveLengthInSamples; p->sampleRate = sr; p->waveLengthInSamples = p->sampleRate/freq; tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); - tOnePole_setSampleRate(p->bridgeFilter, p->sampleRate); - tHighpass_setSampleRate(p->DCblocker, p->sampleRate); + tOnePole_setSampleRate(&p->bridgeFilter, p->sampleRate); + tHighpass_setSampleRate(&p->DCblocker, p->sampleRate); } @@ -507,12 +507,12 @@ void tSimpleLivingString2_init(tSimpleLivingString2* const pl, Lfloat freq, L tSimpleLivingString2_initToPool(pl, freq, brightness, decay, targetLev, levSmoothFactor, levStrength, levMode, &leaf->mempool); } -void tSimpleLivingString2_initToPool (tSimpleLivingString2* const pl, Lfloat freq, Lfloat brightness, +void tSimpleLivingString2_initToPool (tSimpleLivingString2** const pl, Lfloat freq, Lfloat brightness, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, tMempool* const mp) { _tMempool* m = *mp; - _tSimpleLivingString2* p = *pl = (_tSimpleLivingString2*) mpool_alloc(sizeof(_tSimpleLivingString2), m); + tSimpleLivingString2* p = *pl = (tSimpleLivingString2*) mpool_alloc(sizeof(tSimpleLivingString2), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -521,7 +521,7 @@ void tSimpleLivingString2_initToPool (tSimpleLivingString2* const pl, Lfloat tExpSmooth_initToPool(&p->wlSmooth, p->sampleRate/freq, 0.01f, mp); // smoother for string wavelength (not freq, to avoid expensive divisions) tSimpleLivingString2_setFreq(*pl, freq); tHermiteDelay_initToPool(&p->delayLine,p->waveLengthInSamples, 2400, mp); - tHermiteDelay_clear(p->delayLine); + tHermiteDelay_clear(&p->delayLine); tTwoZero_initToPool(&p->bridgeFilter, mp); tSimpleLivingString2_setBrightness(*pl, brightness); tHighpass_initToPool(&p->DCblocker,13, mp); @@ -530,9 +530,9 @@ void tSimpleLivingString2_initToPool (tSimpleLivingString2* const pl, Lfloat p->levMode=levMode; } -void tSimpleLivingString2_free (tSimpleLivingString2* const pl) +void tSimpleLivingString2_free (tSimpleLivingString2** const pl) { - _tSimpleLivingString2* p = *pl; + tSimpleLivingString2* p = *pl; tExpSmooth_free(&p->wlSmooth); tHermiteDelay_free(&p->delayLine); @@ -543,7 +543,7 @@ void tSimpleLivingString2_free (tSimpleLivingString2* const pl) mpool_free((char*)p, p->mempool); } -void tSimpleLivingString2_setFreq(tSimpleLivingString2 const p, Lfloat freq) +void tSimpleLivingString2_setFreq(tSimpleLivingString2* const p, Lfloat freq) { if (freq<20) freq=20; else if (freq>10000) freq=10000; @@ -551,7 +551,7 @@ void tSimpleLivingString2_setFreq(tSimpleLivingString2 const p, Lfloat freq) tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); } -void tSimpleLivingString2_setWaveLength(tSimpleLivingString2 const p, Lfloat waveLength) +void tSimpleLivingString2_setWaveLength(tSimpleLivingString2* const p, Lfloat waveLength) { if (waveLength<4.8) waveLength=4.8f; else if (waveLength>2400) waveLength=2400; @@ -559,63 +559,63 @@ void tSimpleLivingString2_setWaveLength(tSimpleLivingString2 const p, Lfloat tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); } -void tSimpleLivingString2_setBrightness(tSimpleLivingString2 const p, Lfloat brightness) +void tSimpleLivingString2_setBrightness(tSimpleLivingString2* const p, Lfloat brightness) { Lfloat h0 = (1.0f + brightness) * 0.5f; Lfloat h1 = (1.0f - brightness) * 0.25f; - tTwoZero_setCoefficients(p->bridgeFilter, h1, h0, h1); + tTwoZero_setCoefficients(&p->bridgeFilter, h1, h0, h1); } -void tSimpleLivingString2_setDecay(tSimpleLivingString2 const p, Lfloat decay) +void tSimpleLivingString2_setDecay(tSimpleLivingString2* const p, Lfloat decay) { p->decay=decay; } -void tSimpleLivingString2_setTargetLev(tSimpleLivingString2 const p, Lfloat targetLev) +void tSimpleLivingString2_setTargetLev(tSimpleLivingString2* const p, Lfloat targetLev) { - tFeedbackLeveler_setTargetLevel(p->fbLev, targetLev); + tFeedbackLeveler_setTargetLevel(&p->fbLev, targetLev); } -void tSimpleLivingString2_setLevSmoothFactor(tSimpleLivingString2 const p, Lfloat levSmoothFactor) +void tSimpleLivingString2_setLevSmoothFactor(tSimpleLivingString2* const p, Lfloat levSmoothFactor) { - tFeedbackLeveler_setFactor(p->fbLev, levSmoothFactor); + tFeedbackLeveler_setFactor(&p->fbLev, levSmoothFactor); } -void tSimpleLivingString2_setLevStrength(tSimpleLivingString2 const p, Lfloat levStrength) +void tSimpleLivingString2_setLevStrength(tSimpleLivingString2* const p, Lfloat levStrength) { - tFeedbackLeveler_setStrength(p->fbLev, levStrength); + tFeedbackLeveler_setStrength(&p->fbLev, levStrength); } -void tSimpleLivingString2_setLevMode(tSimpleLivingString2 const p, int levMode) +void tSimpleLivingString2_setLevMode(tSimpleLivingString2* const p, int levMode) { - tFeedbackLeveler_setMode(p->fbLev, levMode); + tFeedbackLeveler_setMode(&p->fbLev, levMode); p->levMode=levMode; } -Lfloat tSimpleLivingString2_tick(tSimpleLivingString2 const p, Lfloat input) +Lfloat tSimpleLivingString2_tick(tSimpleLivingString2* const p, Lfloat input) { - Lfloat stringOut=tTwoZero_tick(p->bridgeFilter,tHermiteDelay_tickOut(p->delayLine)); - Lfloat stringInput=tHighpass_tick(p->DCblocker,(tFeedbackLeveler_tick(p->fbLev, (p->levMode==0?p->decay*stringOut:stringOut)+input))); - tHermiteDelay_tickIn(p->delayLine, stringInput); - tHermiteDelay_setDelay(p->delayLine, tExpSmooth_tick(p->wlSmooth)); + Lfloat stringOut=tTwoZero_tick(&p->bridgeFilter,tHermiteDelay_tickOut(&p->delayLine)); + Lfloat stringInput=tHighpass_tick(&p->DCblocker,(tFeedbackLeveler_tick(&p->fbLev, (p->levMode==0?p->decay*stringOut:stringOut)+input))); + tHermiteDelay_tickIn(&p->delayLine, stringInput); + tHermiteDelay_setDelay(&p->delayLine, tExpSmooth_tick(p->wlSmooth)); p->curr = stringOut; return p->curr; } -Lfloat tSimpleLivingString2_sample(tSimpleLivingString2 const p) +Lfloat tSimpleLivingString2_sample(tSimpleLivingString2* const p) { return p->curr; } -void tSimpleLivingString2_setSampleRate(tSimpleLivingString2 const p, Lfloat sr) +void tSimpleLivingString2_setSampleRate(tSimpleLivingString2* const p, Lfloat sr) { Lfloat freq = p->sampleRate/p->waveLengthInSamples; p->sampleRate = sr; p->waveLengthInSamples = p->sampleRate/freq; tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); - tTwoZero_setSampleRate(p->bridgeFilter, p->sampleRate); - tHighpass_setSampleRate(p->DCblocker, p->sampleRate); + tTwoZero_setSampleRate(&p->bridgeFilter, p->sampleRate); + tHighpass_setSampleRate(&p->DCblocker, p->sampleRate); } /* Living String*/ @@ -626,12 +626,12 @@ void tLivingString_init(tLivingString* const pl, Lfloat freq, Lfloat pickPos, tLivingString_initToPool(pl, freq, pickPos, prepIndex, dampFreq, decay, targetLev, levSmoothFactor, levStrength, levMode, &leaf->mempool); } -void tLivingString_initToPool (tLivingString* const pl, Lfloat freq, Lfloat pickPos, Lfloat prepIndex, +void tLivingString_initToPool (tLivingString** const pl, Lfloat freq, Lfloat pickPos, Lfloat prepIndex, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, tMempool* const mp) { _tMempool* m = *mp; - _tLivingString* p = *pl = (_tLivingString*) mpool_alloc(sizeof(_tLivingString), m); + tLivingString* p = *pl = (tLivingString*) mpool_alloc(sizeof(tLivingString), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -647,10 +647,10 @@ void tLivingString_initToPool (tLivingString* const pl, Lfloat freq, Lfloa tLinearDelay_initToPool(&p->delUF,p->waveLengthInSamples, 2400, mp); tLinearDelay_initToPool(&p->delUB,p->waveLengthInSamples, 2400, mp); tLinearDelay_initToPool(&p->delLB,p->waveLengthInSamples, 2400, mp); - tLinearDelay_clear(p->delLF); - tLinearDelay_clear(p->delUF); - tLinearDelay_clear(p->delUB); - tLinearDelay_clear(p->delLB); + tLinearDelay_clear(&p->delLF); + tLinearDelay_clear(&p->delUF); + tLinearDelay_clear(&p->delUB); + tLinearDelay_clear(&p->delLB); p->dampFreq = dampFreq; tOnePole_initToPool(&p->bridgeFilter, dampFreq, mp); tOnePole_initToPool(&p->nutFilter, dampFreq, mp); @@ -675,12 +675,12 @@ void tSimpleLivingString3_init(tSimpleLivingString3* const pl, int oversampli tSimpleLivingString3_initToPool(pl, oversampling, freq, dampFreq, decay, targetLev, levSmoothFactor, levStrength, levMode, &leaf->mempool); } -void tSimpleLivingString3_initToPool (tSimpleLivingString3* const pl, int oversampling, Lfloat freq, Lfloat dampFreq, +void tSimpleLivingString3_initToPool (tSimpleLivingString3** const pl, int oversampling, Lfloat freq, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, tMempool* const mp) { _tMempool* m = *mp; - _tSimpleLivingString3* p = *pl = (_tSimpleLivingString3*) mpool_alloc(sizeof(_tSimpleLivingString3), m); + tSimpleLivingString3* p = *pl = (tSimpleLivingString3*) mpool_alloc(sizeof(tSimpleLivingString3), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; p->oversampling = oversampling; @@ -691,21 +691,21 @@ void tSimpleLivingString3_initToPool (tSimpleLivingString3* const pl, int ov tLinearDelay_initToPool(&p->delayLineU,p->waveLengthInSamples, p->maxLength, mp); tLinearDelay_initToPool(&p->delayLineL,p->waveLengthInSamples, p->maxLength, mp); tSimpleLivingString3_setFreq(*pl, freq); - tLinearDelay_setDelay(p->delayLineU, p->waveLengthInSamples); - tLinearDelay_setDelay(p->delayLineL, p->waveLengthInSamples); + tLinearDelay_setDelay(&p->delayLineU, p->waveLengthInSamples); + tLinearDelay_setDelay(&p->delayLineL, p->waveLengthInSamples); //tSimpleLivingString3_setWaveLength(pl, 4800); - tLinearDelay_clear(p->delayLineU); - tLinearDelay_clear(p->delayLineL); + tLinearDelay_clear(&p->delayLineU); + tLinearDelay_clear(&p->delayLineL); p->dampFreq = dampFreq; tOnePole_initToPool(&p->bridgeFilter, dampFreq, mp); - tOnePole_setSampleRate(p->bridgeFilter, p->sampleRate); - tOnePole_setFreq(p->bridgeFilter, dampFreq); + tOnePole_setSampleRate(&p->bridgeFilter, p->sampleRate); + tOnePole_setFreq(&p->bridgeFilter, dampFreq); p->rippleGain = 0.0f; p->rippleDelay = 0.5f; p->invOnePlusr = 1.0f; tHighpass_initToPool(&p->DCblocker,13, mp); - tHighpass_setSampleRate(p->DCblocker,p->sampleRate); - tHighpass_setFreq(p->DCblocker,13); + tHighpass_setSampleRate(&p->DCblocker,p->sampleRate); + tHighpass_setFreq(&p->DCblocker,13); p->userDecay = decay; tFeedbackLeveler_initToPool(&p->fbLev, targetLev, levSmoothFactor, levStrength, levMode, mp); @@ -728,9 +728,9 @@ void tSimpleLivingString3_initToPool (tSimpleLivingString3* const pl, int ov } -void tSimpleLivingString3_free (tSimpleLivingString3* const pl) +void tSimpleLivingString3_free (tSimpleLivingString3** const pl) { - _tSimpleLivingString3* p = *pl; + tSimpleLivingString3* p = *pl; tFeedbackLeveler_free(&p->fbLev); tHighpass_free(&p->DCblocker); tOnePole_free(&p->bridgeFilter); @@ -743,7 +743,7 @@ void tSimpleLivingString3_free (tSimpleLivingString3* const pl) mpool_free((char*)p, p->mempool); } -void tSimpleLivingString3_setFreq(tSimpleLivingString3 const p, Lfloat freq) +void tSimpleLivingString3_setFreq(tSimpleLivingString3* const p, Lfloat freq) { p->freq = freq; Lfloat waveLength = (p->sampleRate/freq); @@ -760,7 +760,7 @@ void tSimpleLivingString3_setFreq(tSimpleLivingString3 const p, Lfloat freq) //p->decay=powf(0.001f,1.0f/(p->freq*p->userDecay)); } -void tSimpleLivingString3_setWaveLength(tSimpleLivingString3 const p, Lfloat waveLength) +void tSimpleLivingString3_setWaveLength(tSimpleLivingString3* const p, Lfloat waveLength) { if (waveLength<4.8) waveLength=4.8f; else if (waveLength>p->maxLength*2) waveLength=p->maxLength*2; @@ -768,16 +768,16 @@ void tSimpleLivingString3_setWaveLength(tSimpleLivingString3 const p, Lfloat tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); } -void tSimpleLivingString3_setDampFreq(tSimpleLivingString3 const p, Lfloat dampFreq) +void tSimpleLivingString3_setDampFreq(tSimpleLivingString3* const p, Lfloat dampFreq) { //p->temp1 = (1.0f - brightness) * 0.25f * p->decay; //p->temp2 = (1.0f + brightness) * 0.5f * p->decay; //tBiQuad_setCoefficients(&p->bridgeFilter2, p->temp1 , p->temp2, p->temp1 , 0.0f, 0.0f); - tOnePole_setFreq(p->bridgeFilter, dampFreq); + tOnePole_setFreq(&p->bridgeFilter, dampFreq); } -void tSimpleLivingString3_setDecay(tSimpleLivingString3 const p, Lfloat decay) +void tSimpleLivingString3_setDecay(tSimpleLivingString3* const p, Lfloat decay) { p->userDecay = decay; @@ -789,28 +789,28 @@ void tSimpleLivingString3_setDecay(tSimpleLivingString3 const p, Lfloat deca //p->decay=powf(0.001f,1.0f/(p->freq*decay)); } -void tSimpleLivingString3_setTargetLev(tSimpleLivingString3 const p, Lfloat targetLev) +void tSimpleLivingString3_setTargetLev(tSimpleLivingString3* const p, Lfloat targetLev) { - tFeedbackLeveler_setTargetLevel(p->fbLev, targetLev); + tFeedbackLeveler_setTargetLevel(&p->fbLev, targetLev); } -void tSimpleLivingString3_setLevSmoothFactor(tSimpleLivingString3 const p, Lfloat levSmoothFactor) +void tSimpleLivingString3_setLevSmoothFactor(tSimpleLivingString3* const p, Lfloat levSmoothFactor) { - tFeedbackLeveler_setFactor(p->fbLev, levSmoothFactor); + tFeedbackLeveler_setFactor(&p->fbLev, levSmoothFactor); } -void tSimpleLivingString3_setLevStrength(tSimpleLivingString3 const p, Lfloat levStrength) +void tSimpleLivingString3_setLevStrength(tSimpleLivingString3* const p, Lfloat levStrength) { - tFeedbackLeveler_setStrength(p->fbLev, levStrength); + tFeedbackLeveler_setStrength(&p->fbLev, levStrength); } -void tSimpleLivingString3_setLevMode(tSimpleLivingString3 const p, int levMode) +void tSimpleLivingString3_setLevMode(tSimpleLivingString3* const p, int levMode) { - tFeedbackLeveler_setMode(p->fbLev, levMode); + tFeedbackLeveler_setMode(&p->fbLev, levMode); p->levMode=levMode; } -void tSimpleLivingString3_pluck(tSimpleLivingString3 const p, Lfloat input, Lfloat position) +void tSimpleLivingString3_pluck(tSimpleLivingString3* const p, Lfloat input, Lfloat position) { int length = p->waveLengthInSamples; int pluckPoint = (int)(length * position); @@ -847,7 +847,7 @@ void tSimpleLivingString3_pluck(tSimpleLivingString3 const p, Lfloat input, Lf } } -Lfloat tSimpleLivingString3_tick(tSimpleLivingString3 const p, Lfloat input) +Lfloat tSimpleLivingString3_tick(tSimpleLivingString3* const p, Lfloat input) { //p->changeGainCompensator = 1.0f; Lfloat wl = tExpSmooth_tick(p->wlSmooth); @@ -856,19 +856,19 @@ Lfloat tSimpleLivingString3_tick(tSimpleLivingString3 const p, Lfloat input) { // p->changeGainCompensator = sqrtf(1.0f - changeInDelayTime); } - tLinearDelay_setDelay(p->delayLineU, wl); - tLinearDelay_setDelay(p->delayLineL, wl); + tLinearDelay_setDelay(&p->delayLineU, wl); + tLinearDelay_setDelay(&p->delayLineL, wl); for (int i = 0; i < p->oversampling; i++) { - p->Uout = tHighpass_tick(p->DCblocker,tOnePole_tick(p->bridgeFilter,tLinearDelay_tickOut(p->delayLineU))* (p->decay * p->invOnePlusr)); - p->Uout = LEAF_clip(-1.0f, tFeedbackLeveler_tick(p->fbLev, p->Uout), 1.0f); + p->Uout = tHighpass_tick(&p->DCblocker,tOnePole_tick(&p->bridgeFilter,tLinearDelay_tickOut(&p->delayLineU))* (p->decay * p->invOnePlusr)); + p->Uout = LEAF_clip(-1.0f, tFeedbackLeveler_tick(&p->fbLev, p->Uout), 1.0f); //p->Uout = tLinearDelay_tickOut(&p->delayLineU) * p->decay; - p->Lout = LEAF_clip(-1.0f, tLinearDelay_tickOut(p->delayLineL), 1.0f); + p->Lout = LEAF_clip(-1.0f, tLinearDelay_tickOut(&p->delayLineL), 1.0f); - tLinearDelay_tickIn(p->delayLineU, (-1.0f * p->Lout) + input); - tLinearDelay_tickIn(p->delayLineL, -1.0f * p->Uout); - tLinearDelay_addTo (p->delayLineU, p->Lout * p->rippleGain, p->rippleDelay*wl); + tLinearDelay_tickIn(&p->delayLineU, (-1.0f * p->Lout) + input); + tLinearDelay_tickIn(&p->delayLineL, -1.0f * p->Uout); + tLinearDelay_addTo (&p->delayLineU, p->Lout * p->rippleGain, p->rippleDelay*wl); } //calculate pickup point @@ -902,27 +902,27 @@ Lfloat tSimpleLivingString3_tick(tSimpleLivingString3 const p, Lfloat input) } -void tSimpleLivingString3_setPickupPoint(tSimpleLivingString3 const p, Lfloat pickupPoint) +void tSimpleLivingString3_setPickupPoint(tSimpleLivingString3* const p, Lfloat pickupPoint) { p->pickupPoint = pickupPoint; } -Lfloat tSimpleLivingString3_sample(tSimpleLivingString3 const p) +Lfloat tSimpleLivingString3_sample(tSimpleLivingString3* const p) { return p->curr; } -void tSimpleLivingString3_setSampleRate(tSimpleLivingString3 const p, Lfloat sr) +void tSimpleLivingString3_setSampleRate(tSimpleLivingString3* const p, Lfloat sr) { p->sampleRate = sr*p->oversampling; Lfloat freq = p->sampleRate/p->waveLengthInSamples; p->waveLengthInSamples = p->sampleRate/freq; tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); - tOnePole_setSampleRate(p->bridgeFilter, p->sampleRate); - tHighpass_setSampleRate(p->DCblocker, p->sampleRate); - tBiQuad_setSampleRate(p->bridgeFilter2, p->sampleRate); + tOnePole_setSampleRate(&p->bridgeFilter, p->sampleRate); + tHighpass_setSampleRate(&p->DCblocker, p->sampleRate); + tBiQuad_setSampleRate(&p->bridgeFilter2, p->sampleRate); } @@ -935,12 +935,12 @@ void tSimpleLivingString4_init(tSimpleLivingString4* const pl, int oversampli tSimpleLivingString4_initToPool(pl, oversampling, freq, dampFreq, decay, targetLev, levSmoothFactor, levStrength, levMode, &leaf->mempool); } -void tSimpleLivingString4_initToPool (tSimpleLivingString4* const pl, int oversampling, Lfloat freq, Lfloat dampFreq, +void tSimpleLivingString4_initToPool (tSimpleLivingString4** const pl, int oversampling, Lfloat freq, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, tMempool* const mp) { _tMempool* m = *mp; - _tSimpleLivingString4* p = *pl = (_tSimpleLivingString4*) mpool_alloc(sizeof(_tSimpleLivingString4), m); + tSimpleLivingString4* p = *pl = (tSimpleLivingString4*) mpool_alloc(sizeof(tSimpleLivingString4), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; p->oversampling = oversampling; @@ -951,24 +951,24 @@ void tSimpleLivingString4_initToPool (tSimpleLivingString4* const pl, int ov tLinearDelay_initToPool(&p->delayLineU,p->waveLengthInSamples, p->maxLength, mp); tLinearDelay_initToPool(&p->delayLineL,p->waveLengthInSamples, p->maxLength, mp); tSimpleLivingString4_setFreq(p, freq); - tLinearDelay_setDelay(p->delayLineU, p->waveLengthInSamples); - tLinearDelay_setDelay(p->delayLineL, p->waveLengthInSamples); + tLinearDelay_setDelay(&p->delayLineU, p->waveLengthInSamples); + tLinearDelay_setDelay(&p->delayLineL, p->waveLengthInSamples); //tSimpleLivingString4_setWaveLength(pl, 4800); - tLinearDelay_clear(p->delayLineU); - tLinearDelay_clear(p->delayLineL); + tLinearDelay_clear(&p->delayLineU); + tLinearDelay_clear(&p->delayLineL); p->dampFreq = dampFreq; tOnePole_initToPool(&p->bridgeFilter, dampFreq, mp); - tOnePole_setSampleRate(p->bridgeFilter, p->sampleRate); - tOnePole_setFreq(p->bridgeFilter, dampFreq); + tOnePole_setSampleRate(&p->bridgeFilter, p->sampleRate); + tOnePole_setFreq(&p->bridgeFilter, dampFreq); p->rippleGain = 0.0f; p->rippleDelay = 0.5f; tBiQuad_initToPool(&p->bridgeFilter2, mp); - tBiQuad_setSampleRate(p->bridgeFilter2, p->sampleRate); + tBiQuad_setSampleRate(&p->bridgeFilter2, p->sampleRate); tHighpass_initToPool(&p->DCblocker,0.001f, mp); - tHighpass_setSampleRate(p->DCblocker,p->sampleRate); - tHighpass_setFreq(p->DCblocker,0.001f); + tHighpass_setSampleRate(&p->DCblocker,p->sampleRate); + tHighpass_setFreq(&p->DCblocker,0.001f); p->userDecay = decay; p->pluckPosition = 0.8f; tFeedbackLeveler_initToPool(&p->fbLev, targetLev, levSmoothFactor, levStrength, levMode, mp); @@ -991,9 +991,9 @@ void tSimpleLivingString4_initToPool (tSimpleLivingString4* const pl, int ov } -void tSimpleLivingString4_free (tSimpleLivingString4* const pl) +void tSimpleLivingString4_free (tSimpleLivingString4** const pl) { - _tSimpleLivingString4* p = *pl; + tSimpleLivingString4* p = *pl; tExpSmooth_free(&p->wlSmooth); tLinearDelay_free(&p->delayLineU); @@ -1006,7 +1006,7 @@ void tSimpleLivingString4_free (tSimpleLivingString4* const pl) mpool_free((char*)p, p->mempool); } -void tSimpleLivingString4_setFreq(tSimpleLivingString4 const p, Lfloat freq) +void tSimpleLivingString4_setFreq(tSimpleLivingString4* const p, Lfloat freq) { p->freq = freq; Lfloat waveLength = (p->sampleRate/freq); @@ -1023,7 +1023,7 @@ void tSimpleLivingString4_setFreq(tSimpleLivingString4 const p, Lfloat freq) //p->decay=powf(0.001f,1.0f/(p->freq*p->userDecay)); } -void tSimpleLivingString4_setWaveLength(tSimpleLivingString4 const p, Lfloat waveLength) +void tSimpleLivingString4_setWaveLength(tSimpleLivingString4* const p, Lfloat waveLength) { if (waveLength<4.8) waveLength=4.8f; else if (waveLength>p->maxLength*2) waveLength = p->maxLength*2; @@ -1031,16 +1031,16 @@ void tSimpleLivingString4_setWaveLength(tSimpleLivingString4 const p, Lfloat tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); } -void tSimpleLivingString4_setDampFreq(tSimpleLivingString4 const p, Lfloat dampFreq) +void tSimpleLivingString4_setDampFreq(tSimpleLivingString4* const p, Lfloat dampFreq) { //p->temp1 = (1.0f - brightness) * 0.25f * p->decay; //p->temp2 = (1.0f + brightness) * 0.5f * p->decay; //tBiQuad_setCoefficients(&p->bridgeFilter2, p->temp1 , p->temp2, p->temp1 , 0.0f, 0.0f); - tOnePole_setFreq(p->bridgeFilter, dampFreq); + tOnePole_setFreq(&p->bridgeFilter, dampFreq); } -void tSimpleLivingString4_setDecay(tSimpleLivingString4 const p, Lfloat decay) +void tSimpleLivingString4_setDecay(tSimpleLivingString4* const p, Lfloat decay) { p->userDecay = decay; @@ -1050,34 +1050,34 @@ void tSimpleLivingString4_setDecay(tSimpleLivingString4 const p, Lfloat deca //p->decay=powf(0.001f,1.0f/(p->freq*decay)); } -void tSimpleLivingString4_setTargetLev(tSimpleLivingString4 const p, Lfloat targetLev) +void tSimpleLivingString4_setTargetLev(tSimpleLivingString4* const p, Lfloat targetLev) { - tFeedbackLeveler_setTargetLevel(p->fbLev, targetLev); + tFeedbackLeveler_setTargetLevel(&p->fbLev, targetLev); } -void tSimpleLivingString4_setLevSmoothFactor(tSimpleLivingString4 const p, Lfloat levSmoothFactor) +void tSimpleLivingString4_setLevSmoothFactor(tSimpleLivingString4* const p, Lfloat levSmoothFactor) { - tFeedbackLeveler_setFactor(p->fbLev, levSmoothFactor); + tFeedbackLeveler_setFactor(&p->fbLev, levSmoothFactor); } -void tSimpleLivingString4_setLevStrength(tSimpleLivingString4 const p, Lfloat levStrength) +void tSimpleLivingString4_setLevStrength(tSimpleLivingString4* const p, Lfloat levStrength) { - tFeedbackLeveler_setStrength(p->fbLev, levStrength); + tFeedbackLeveler_setStrength(&p->fbLev, levStrength); } -void tSimpleLivingString4_setLevMode(tSimpleLivingString4 const p, int levMode) +void tSimpleLivingString4_setLevMode(tSimpleLivingString4* const p, int levMode) { - tFeedbackLeveler_setMode(p->fbLev, levMode); + tFeedbackLeveler_setMode(&p->fbLev, levMode); p->levMode=levMode; } -void tSimpleLivingString4_setPluckPosition(tSimpleLivingString4 const p, Lfloat position) +void tSimpleLivingString4_setPluckPosition(tSimpleLivingString4* const p, Lfloat position) { p->pluckPosition = position; } -void tSimpleLivingString4_pluck(tSimpleLivingString4 const p, Lfloat input, Lfloat position) +void tSimpleLivingString4_pluck(tSimpleLivingString4* const p, Lfloat input, Lfloat position) { int length = p->waveLengthInSamples; p->pluckPosition = position; @@ -1114,7 +1114,7 @@ void tSimpleLivingString4_pluck(tSimpleLivingString4 const p, Lfloat input, Lf } } -void tSimpleLivingString4_pluckNoPosition(tSimpleLivingString4 const p, Lfloat input) +void tSimpleLivingString4_pluckNoPosition(tSimpleLivingString4* const p, Lfloat input) { int length = p->waveLengthInSamples; Lfloat position = p->pluckPosition; @@ -1153,7 +1153,7 @@ void tSimpleLivingString4_pluckNoPosition(tSimpleLivingString4 const p, Lfloat -Lfloat tSimpleLivingString4_tick(tSimpleLivingString4 const p, Lfloat input) +Lfloat tSimpleLivingString4_tick(tSimpleLivingString4* const p, Lfloat input) { p->changeGainCompensator = 1.0f; Lfloat wl = tExpSmooth_tick(p->wlSmooth); @@ -1165,21 +1165,21 @@ Lfloat tSimpleLivingString4_tick(tSimpleLivingString4 const p, Lfloat input) else{ p->changeGainCompensator = 1.0f; } - tLinearDelay_setDelay(p->delayLineU, wl); - tLinearDelay_setDelay(p->delayLineL, wl); + tLinearDelay_setDelay(&p->delayLineU, wl); + tLinearDelay_setDelay(&p->delayLineL, wl); for (int i = 0; i < p->oversampling; i++) { - p->Uout = tHighpass_tick(p->DCblocker,tOnePole_tick(p->bridgeFilter,tLinearDelay_tickOut(p->delayLineU))* (p->decay - fabsf(p->rippleGain))); - p->Uout = LEAF_clip(-1.0f, tFeedbackLeveler_tick(p->fbLev, p->Uout), 1.0f); + p->Uout = tHighpass_tick(&p->DCblocker,tOnePole_tick(&p->bridgeFilter,tLinearDelay_tickOut(&p->delayLineU))* (p->decay - fabsf(p->rippleGain))); + p->Uout = LEAF_clip(-1.0f, tFeedbackLeveler_tick(&p->fbLev, p->Uout), 1.0f); //p->Uout = tLinearDelay_tickOut(&p->delayLineU) * p->decay; - p->Lout = LEAF_clip(-1.0f, tLinearDelay_tickOut(p->delayLineL), 1.0f); + p->Lout = LEAF_clip(-1.0f, tLinearDelay_tickOut(&p->delayLineL), 1.0f); - tLinearDelay_tickIn(p->delayLineU, (-1.0f * p->Lout)* p->changeGainCompensator); - tLinearDelay_tickIn(p->delayLineL, (-1.0f * p->Uout)); - tLinearDelay_addTo (p->delayLineU, input, p->pluckPosition*wl); - tLinearDelay_addTo (p->delayLineL, input, (1.0f - p->pluckPosition)*wl); - tLinearDelay_addTo (p->delayLineU, p->Lout * p->rippleGain, p->rippleDelay*wl); + tLinearDelay_tickIn(&p->delayLineU, (-1.0f * p->Lout)* p->changeGainCompensator); + tLinearDelay_tickIn(&p->delayLineL, (-1.0f * p->Uout)); + tLinearDelay_addTo (&p->delayLineU, input, p->pluckPosition*wl); + tLinearDelay_addTo (&p->delayLineL, input, (1.0f - p->pluckPosition)*wl); + tLinearDelay_addTo (&p->delayLineU, p->Lout * p->rippleGain, p->rippleDelay*wl); } //calculate pickup point @@ -1213,27 +1213,27 @@ Lfloat tSimpleLivingString4_tick(tSimpleLivingString4 const p, Lfloat input) } -void tSimpleLivingString4_setPickupPoint(tSimpleLivingString4 const p, Lfloat pickupPoint) +void tSimpleLivingString4_setPickupPoint(tSimpleLivingString4* const p, Lfloat pickupPoint) { p->pickupPoint = pickupPoint; } -Lfloat tSimpleLivingString4_sample(tSimpleLivingString4 const p) +Lfloat tSimpleLivingString4_sample(tSimpleLivingString4* const p) { return p->curr; } -void tSimpleLivingString4_setSampleRate(tSimpleLivingString4 const p, Lfloat sr) +void tSimpleLivingString4_setSampleRate(tSimpleLivingString4* const p, Lfloat sr) { p->sampleRate = sr*p->oversampling; Lfloat freq = p->sampleRate/p->waveLengthInSamples; p->waveLengthInSamples = p->sampleRate/freq; tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); - tOnePole_setSampleRate(p->bridgeFilter, p->sampleRate); - tHighpass_setSampleRate(p->DCblocker, p->sampleRate); - tBiQuad_setSampleRate(p->bridgeFilter2, p->sampleRate); + tOnePole_setSampleRate(&p->bridgeFilter, p->sampleRate); + tHighpass_setSampleRate(&p->DCblocker, p->sampleRate); + tBiQuad_setSampleRate(&p->bridgeFilter2, p->sampleRate); } @@ -1247,12 +1247,12 @@ void tSimpleLivingString5_init(tSimpleLivingString5* const pl, int oversampli tSimpleLivingString5_initToPool(pl, oversampling, freq, dampFreq, decay, prepPos, prepIndex, pluckPos, targetLev, levSmoothFactor, levStrength, levMode, &leaf->mempool); } -void tSimpleLivingString5_initToPool (tSimpleLivingString5* const pl, int oversampling, Lfloat freq, Lfloat dampFreq, +void tSimpleLivingString5_initToPool (tSimpleLivingString5** const pl, int oversampling, Lfloat freq, Lfloat dampFreq, Lfloat decay, Lfloat prepPos, Lfloat prepIndex, Lfloat pluckPos, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, tMempool* const mp) { _tMempool* m = *mp; - _tSimpleLivingString5* p = *pl = (_tSimpleLivingString5*) mpool_alloc(sizeof(_tSimpleLivingString5), m); + tSimpleLivingString5* p = *pl = (tSimpleLivingString5*) mpool_alloc(sizeof(tSimpleLivingString5), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; p->oversampling = oversampling; @@ -1275,23 +1275,23 @@ void tSimpleLivingString5_initToPool (tSimpleLivingString5* const pl, int ov tLagrangeDelay_initToPool(&p->delLF,p->waveLengthInSamples, p->maxLength, mp); tLagrangeDelay_initToPool(&p->delLB,p->waveLengthInSamples, p->maxLength, mp); tSimpleLivingString5_setFreq(p, freq); - tLagrangeDelay_setDelay(p->delUF, p->waveLengthInSamples-(p->prepPos*p->waveLengthInSamples)); - tLagrangeDelay_setDelay(p->delUB, p->waveLengthInSamples-((1.0f-p->prepPos)*p->waveLengthInSamples)); - tLagrangeDelay_setDelay(p->delLF, p->waveLengthInSamples-(p->prepPos*p->waveLengthInSamples)); - tLagrangeDelay_setDelay(p->delLB, p->waveLengthInSamples-((1.0f-p->prepPos)*p->waveLengthInSamples)); + tLagrangeDelay_setDelay(&p->delUF, p->waveLengthInSamples-(p->prepPos*p->waveLengthInSamples)); + tLagrangeDelay_setDelay(&p->delUB, p->waveLengthInSamples-((1.0f-p->prepPos)*p->waveLengthInSamples)); + tLagrangeDelay_setDelay(&p->delLF, p->waveLengthInSamples-(p->prepPos*p->waveLengthInSamples)); + tLagrangeDelay_setDelay(&p->delLB, p->waveLengthInSamples-((1.0f-p->prepPos)*p->waveLengthInSamples)); //tSimpleLivingString5_setWaveLength(pl, 4800); - tLagrangeDelay_clear(p->delUF); - tLagrangeDelay_clear(p->delUB); - tLagrangeDelay_clear(p->delLF); - tLagrangeDelay_clear(p->delLB); + tLagrangeDelay_clear(&p->delUF); + tLagrangeDelay_clear(&p->delUB); + tLagrangeDelay_clear(&p->delLF); + tLagrangeDelay_clear(&p->delLB); p->dampFreq = dampFreq; tOnePole_initToPool(&p->bridgeFilter, dampFreq, mp); - tOnePole_setSampleRate(p->bridgeFilter, p->sampleRate); - tOnePole_setFreq(p->bridgeFilter, dampFreq); + tOnePole_setSampleRate(&p->bridgeFilter, p->sampleRate); + tOnePole_setFreq(&p->bridgeFilter, dampFreq); tOnePole_initToPool(&p->nutFilter, dampFreq, mp); - tOnePole_setSampleRate(p->nutFilter, p->sampleRate); - tOnePole_setFreq(p->nutFilter, dampFreq); + tOnePole_setSampleRate(&p->nutFilter, p->sampleRate); + tOnePole_setFreq(&p->nutFilter, dampFreq); @@ -1301,12 +1301,12 @@ void tSimpleLivingString5_initToPool (tSimpleLivingString5* const pl, int ov tHighpass_initToPool(&p->DCblocker,0.001f, mp); - tHighpass_setSampleRate(p->DCblocker,p->sampleRate); - tHighpass_setFreq(p->DCblocker,0.001f); + tHighpass_setSampleRate(&p->DCblocker,p->sampleRate); + tHighpass_setFreq(&p->DCblocker,0.001f); tHighpass_initToPool(&p->DCblocker2,0.001f, mp); - tHighpass_setSampleRate(p->DCblocker2,p->sampleRate); - tHighpass_setFreq(p->DCblocker2,0.001f); + tHighpass_setSampleRate(&p->DCblocker2,p->sampleRate); + tHighpass_setFreq(&p->DCblocker2,0.001f); p->userDecay = decay; p->pluckPosition = 0.8f; @@ -1334,9 +1334,9 @@ void tSimpleLivingString5_initToPool (tSimpleLivingString5* const pl, int ov } -void tSimpleLivingString5_free (tSimpleLivingString5* const pl) +void tSimpleLivingString5_free (tSimpleLivingString5** const pl) { - _tSimpleLivingString5* p = *pl; + tSimpleLivingString5* p = *pl; tExpSmooth_free(&p->wlSmooth); tExpSmooth_free(&p->prepIndexSmooth); @@ -1361,7 +1361,7 @@ void tSimpleLivingString5_free (tSimpleLivingString5* const pl) mpool_free((char*)p, p->mempool); } -void tSimpleLivingString5_setFreq(tSimpleLivingString5 const p, Lfloat freq) +void tSimpleLivingString5_setFreq(tSimpleLivingString5* const p, Lfloat freq) { p->freq = freq; Lfloat waveLength = (p->sampleRate/freq); @@ -1378,7 +1378,7 @@ void tSimpleLivingString5_setFreq(tSimpleLivingString5 const p, Lfloat freq) //p->decay=powf(0.001f,1.0f/(p->freq*p->userDecay)); } -void tSimpleLivingString5_setWaveLength(tSimpleLivingString5 const p, Lfloat waveLength) +void tSimpleLivingString5_setWaveLength(tSimpleLivingString5* const p, Lfloat waveLength) { if (waveLength<4.8) waveLength=4.8f; else if (waveLength>p->maxLength*2) waveLength=p->maxLength*2; @@ -1386,17 +1386,17 @@ void tSimpleLivingString5_setWaveLength(tSimpleLivingString5 const p, Lfloat tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); } -void tSimpleLivingString5_setDampFreq(tSimpleLivingString5 const p, Lfloat dampFreq) +void tSimpleLivingString5_setDampFreq(tSimpleLivingString5* const p, Lfloat dampFreq) { //p->temp1 = (1.0f - brightness) * 0.25f * p->decay; //p->temp2 = (1.0f + brightness) * 0.5f * p->decay; //tBiQuad_setCoefficients(&p->bridgeFilter2, p->temp1 , p->temp2, p->temp1 , 0.0f, 0.0f); - tOnePole_setFreq(p->bridgeFilter, dampFreq); - tOnePole_setFreq(p->nutFilter, dampFreq); + tOnePole_setFreq(&p->bridgeFilter, dampFreq); + tOnePole_setFreq(&p->nutFilter, dampFreq); } -void tSimpleLivingString5_setDecay(tSimpleLivingString5 const p, Lfloat decay) +void tSimpleLivingString5_setDecay(tSimpleLivingString5* const p, Lfloat decay) { p->userDecay = decay; @@ -1407,43 +1407,43 @@ void tSimpleLivingString5_setDecay(tSimpleLivingString5 const p, Lfloat deca //tBiQuad_setCoefficients(&p->bridgeFilter2,p->temp1,p->temp2, p->temp1, 0.0f, 0.0f); //p->decay=powf(0.001f,1.0f/(p->freq*decay)); } -void tSimpleLivingString5_setPrepPosition(tSimpleLivingString5 const p, Lfloat prepPosition) +void tSimpleLivingString5_setPrepPosition(tSimpleLivingString5* const p, Lfloat prepPosition) { p->prepPos = prepPosition; tExpSmooth_setDest(p->prepPosSmooth, prepPosition); } -void tSimpleLivingString5_setPrepIndex(tSimpleLivingString5 const p, Lfloat prepIndex) +void tSimpleLivingString5_setPrepIndex(tSimpleLivingString5* const p, Lfloat prepIndex) { p->prepIndex = prepIndex; tExpSmooth_setDest(p->prepIndexSmooth, prepIndex); } -void tSimpleLivingString5_setTargetLev(tSimpleLivingString5 const p, Lfloat targetLev) +void tSimpleLivingString5_setTargetLev(tSimpleLivingString5* const p, Lfloat targetLev) { - tFeedbackLeveler_setTargetLevel(p->fbLev, targetLev); - tFeedbackLeveler_setTargetLevel(p->fbLev2, targetLev); + tFeedbackLeveler_setTargetLevel(&p->fbLev, targetLev); + tFeedbackLeveler_setTargetLevel(&p->fbLev2, targetLev); } -void tSimpleLivingString5_setLevSmoothFactor(tSimpleLivingString5 const p, Lfloat levSmoothFactor) +void tSimpleLivingString5_setLevSmoothFactor(tSimpleLivingString5* const p, Lfloat levSmoothFactor) { - tFeedbackLeveler_setFactor(p->fbLev, levSmoothFactor); - tFeedbackLeveler_setFactor(p->fbLev2, levSmoothFactor); + tFeedbackLeveler_setFactor(&p->fbLev, levSmoothFactor); + tFeedbackLeveler_setFactor(&p->fbLev2, levSmoothFactor); } -void tSimpleLivingString5_setLevStrength(tSimpleLivingString5 const p, Lfloat levStrength) +void tSimpleLivingString5_setLevStrength(tSimpleLivingString5* const p, Lfloat levStrength) { - tFeedbackLeveler_setStrength(p->fbLev, levStrength); - tFeedbackLeveler_setStrength(p->fbLev2, levStrength); + tFeedbackLeveler_setStrength(&p->fbLev, levStrength); + tFeedbackLeveler_setStrength(&p->fbLev2, levStrength); } -void tSimpleLivingString5_setLevMode(tSimpleLivingString5 const p, int levMode) +void tSimpleLivingString5_setLevMode(tSimpleLivingString5* const p, int levMode) { - tFeedbackLeveler_setMode(p->fbLev, levMode); - tFeedbackLeveler_setMode(p->fbLev2, levMode); + tFeedbackLeveler_setMode(&p->fbLev, levMode); + tFeedbackLeveler_setMode(&p->fbLev2, levMode); p->levMode=levMode; } -void tSimpleLivingString5_setPluckPosition(tSimpleLivingString5 const p, Lfloat position) +void tSimpleLivingString5_setPluckPosition(tSimpleLivingString5* const p, Lfloat position) { p->pluckPosition = position; tExpSmooth_setDest(p->pluckPosSmooth, position); @@ -1451,7 +1451,7 @@ void tSimpleLivingString5_setPluckPosition(tSimpleLivingString5 const p, Lfloa } -void tSimpleLivingString5_pluck(tSimpleLivingString5 const p, Lfloat input, Lfloat position) +void tSimpleLivingString5_pluck(tSimpleLivingString5* const p, Lfloat input, Lfloat position) { //p->pluckPosition = position; p->pluckPosition = 0.5f; @@ -1480,20 +1480,20 @@ void tSimpleLivingString5_pluck(tSimpleLivingString5 const p, Lfloat input, Lf } if (i < BLenInt) { - tLagrangeDelay_addTo(p->delUB, val, i); - tLagrangeDelay_addTo(p->delLB, val, BLenInt-i); + tLagrangeDelay_addTo(&p->delUB, val, i); + tLagrangeDelay_addTo(&p->delLB, val, BLenInt-i); } else if (i == BLenInt) { - tLagrangeDelay_addTo(p->delUB, val * (1.0f-BLenAlpha), i); - tLagrangeDelay_addTo(p->delLB, val * (1.0f-BLenAlpha), BLenInt-i); - tLagrangeDelay_addTo(p->delUF, val * BLenAlpha, i-BLenInt); - tLagrangeDelay_addTo(p->delLF, val * BLenAlpha, (FLenInt-1)-(i-BLenInt)); + tLagrangeDelay_addTo(&p->delUB, val * (1.0f-BLenAlpha), i); + tLagrangeDelay_addTo(&p->delLB, val * (1.0f-BLenAlpha), BLenInt-i); + tLagrangeDelay_addTo(&p->delUF, val * BLenAlpha, i-BLenInt); + tLagrangeDelay_addTo(&p->delLF, val * BLenAlpha, (FLenInt-1)-(i-BLenInt)); } else { - tLagrangeDelay_addTo(p->delUF, val, i-BLenInt); - tLagrangeDelay_addTo(p->delLF, val, (FLenInt-1)-(i-BLenInt)); + tLagrangeDelay_addTo(&p->delUF, val, i-BLenInt); + tLagrangeDelay_addTo(&p->delLF, val, (FLenInt-1)-(i-BLenInt)); } } } @@ -1502,7 +1502,7 @@ void tSimpleLivingString5_pluck(tSimpleLivingString5 const p, Lfloat input, Lf -Lfloat tSimpleLivingString5_tick(tSimpleLivingString5 const p, Lfloat input) +Lfloat tSimpleLivingString5_tick(tSimpleLivingString5* const p, Lfloat input) { //p->changeGainCompensator = 1.0f; Lfloat wl = tExpSmooth_tick(p->wlSmooth); @@ -1521,10 +1521,10 @@ Lfloat tSimpleLivingString5_tick(tSimpleLivingString5 const p, Lfloat input) uint32_t FLenInt = (uint32_t)FLen; Lfloat BLen = wl*prepPosSmoothed; uint32_t BLenInt = (uint32_t)BLen; - tLagrangeDelay_setDelay(p->delUF, FLen); - tLagrangeDelay_setDelay(p->delUB, BLen); - tLagrangeDelay_setDelay(p->delLF, FLen); - tLagrangeDelay_setDelay(p->delLB, BLen); + tLagrangeDelay_setDelay(&p->delUF, FLen); + tLagrangeDelay_setDelay(&p->delUB, BLen); + tLagrangeDelay_setDelay(&p->delLF, FLen); + tLagrangeDelay_setDelay(&p->delLB, BLen); Lfloat pluckPosSmoothed = tExpSmooth_tick(p->pluckPosSmooth); Lfloat pluckPosInSamples = pluckPosSmoothed * wl; uint32_t pluckPosInSamplesInt = (uint32_t) pluckPosInSamples; @@ -1544,30 +1544,30 @@ Lfloat tSimpleLivingString5_tick(tSimpleLivingString5 const p, Lfloat input) { if (sample1 < BLenInt) { - tLagrangeDelay_addTo(p->delUB, input * (1.0f - alpha), sample1); - tLagrangeDelay_addTo(p->delLB, input * (1.0f - alpha), BLenInt-sample1); + tLagrangeDelay_addTo(&p->delUB, input * (1.0f - alpha), sample1); + tLagrangeDelay_addTo(&p->delLB, input * (1.0f - alpha), BLenInt-sample1); } else { - tLagrangeDelay_addTo(p->delUF, input * (1.0f - alpha), sample1Front); - tLagrangeDelay_addTo(p->delLF, input * (1.0f - alpha), FLenInt-sample1Front); + tLagrangeDelay_addTo(&p->delUF, input * (1.0f - alpha), sample1Front); + tLagrangeDelay_addTo(&p->delLF, input * (1.0f - alpha), FLenInt-sample1Front); } if (sample2 < BLenInt) { - tLagrangeDelay_addTo(p->delUB, input * alpha, sample2); - tLagrangeDelay_addTo(p->delLB, input * alpha, BLenInt-sample2); + tLagrangeDelay_addTo(&p->delUB, input * alpha, sample2); + tLagrangeDelay_addTo(&p->delLB, input * alpha, BLenInt-sample2); } else { - tLagrangeDelay_addTo(p->delUF, input * alpha, sample2Front); - tLagrangeDelay_addTo(p->delLF, input * alpha, FLenInt-sample2Front); + tLagrangeDelay_addTo(&p->delUF, input * alpha, sample2Front); + tLagrangeDelay_addTo(&p->delLF, input * alpha, FLenInt-sample2Front); } - Lfloat fromUF=tLagrangeDelay_tickOut(p->delUF); - Lfloat fromLF=tLagrangeDelay_tickOut(p->delLF); - Lfloat fromLB=tLagrangeDelay_tickOut(p->delLB); - Lfloat fromUB=tLagrangeDelay_tickOut(p->delUB); + Lfloat fromUF=tLagrangeDelay_tickOut(&p->delUF); + Lfloat fromLF=tLagrangeDelay_tickOut(&p->delLF); + Lfloat fromLB=tLagrangeDelay_tickOut(&p->delLB); + Lfloat fromUB=tLagrangeDelay_tickOut(&p->delUB); //fromUF = tanhf(p->fbSample1) * p->fb + fromUF*0.1f; //fromLB = tanhf(p->fbSample2) * p->fb + fromLB*0.1f; //p->fbSample1 = fromUF; @@ -1599,21 +1599,21 @@ Lfloat tSimpleLivingString5_tick(tSimpleLivingString5 const p, Lfloat input) Lfloat fromBridge=-p->decay*fromUF;//tOnePole_tick(&p->bridgeFilter, fromUF); //Lfloat fromBridge=-tHighpass_tick(&p->DCblocker, tOnePole_tick(&p->bridgeFilter, fromUF)) * p->decay; //version with feedbackleveler //fromBridge = LEAF_clip(-1.0f, fromBridge, 1.0f); - tLagrangeDelay_tickIn(p->delLF, fromBridge); + tLagrangeDelay_tickIn(&p->delLF, fromBridge); // into back half of string, from prepPoint, going backwards (lower section) //Lfloat fromUpperPrep=-tOnePole_tick(&p->prepFilterL, fromUB); Lfloat fromUpperPrep=-fromUB; //fromUpperPrep = LEAF_clip(-1.0f, fromUpperPrep, 1.0f); Lfloat intoLower=p->prepIndex*fromUpperPrep+(1.0f - p->prepIndex)*fromLF; //used to add input here //intoLower = LEAF_clip(-1.0f, intoLower, 1.0f); - tLagrangeDelay_tickIn(p->delLB, intoLower); + tLagrangeDelay_tickIn(&p->delLB, intoLower); // into back of string, from nut going forward (upper section) //Lfloat fromNut=-tFeedbackLeveler_tick(&p->fbLev2, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(&p->DCblocker2,fromLB)); //Lfloat fromNut=-tFeedbackLeveler_tick(&p->fbLev2, (p->levMode==0?p->decay:1.0f)*fromLB); Lfloat fromNut=-p->decay*fromLB;//tOnePole_tick(&p->nutFilter, fromLB); //Lfloat fromNut=-p->decay*tHighpass_tick(&p->DCblocker2,fromLB)); //version without feedback leveler //fromNut = LEAF_clip(-1.0f, fromNut, 1.0f); - tLagrangeDelay_tickIn(p->delUB, fromNut); + tLagrangeDelay_tickIn(&p->delUB, fromNut); // into front half of string, from prepPoint, going forward (upper section) //Lfloat fromLowerPrep=-tOnePole_tick(&p->prepFilterU, fromLF); Lfloat fromLowerPrep=-fromLF; @@ -1621,7 +1621,7 @@ Lfloat tSimpleLivingString5_tick(tSimpleLivingString5 const p, Lfloat input) Lfloat intoUpperFront=p->prepIndex*fromLowerPrep+(1.0f - p->prepIndex)*fromUB; //intoUpper = tanhf(intoUpper); //intoUpperFront = LEAF_clip(-1.0f, intoUpperFront, 1.0f); - tLagrangeDelay_tickIn(p->delUF, intoUpperFront); + tLagrangeDelay_tickIn(&p->delUF, intoUpperFront); p->curr = fromBridge; } @@ -1649,13 +1649,13 @@ Lfloat tSimpleLivingString5_tick(tSimpleLivingString5 const p, Lfloat input) if (pickupPosInSamples < BLen) { - outputSample1 = tLagrangeDelay_tapOutInterpolated(p->delUB, a1, a1F); - outputSample1 += tLagrangeDelay_tapOutInterpolated(p->delLB, a2, a2F); + outputSample1 = tLagrangeDelay_tapOutInterpolated(&p->delUB, a1, a1F); + outputSample1 += tLagrangeDelay_tapOutInterpolated(&p->delLB, a2, a2F); } else { - outputSample1 = tLagrangeDelay_tapOutInterpolated(p->delUF, a3, a3F); - outputSample1 += tLagrangeDelay_tapOutInterpolated(p->delLF, a4, a4F); + outputSample1 = tLagrangeDelay_tapOutInterpolated(&p->delUF, a3, a3F); + outputSample1 += tLagrangeDelay_tapOutInterpolated(&p->delLF, a4, a4F); } p->curr = 0.5f * outputSample1; @@ -1670,39 +1670,39 @@ Lfloat tSimpleLivingString5_tick(tSimpleLivingString5 const p, Lfloat input) } -void tSimpleLivingString5_setPickupPoint(tSimpleLivingString5 const p, Lfloat pickupPoint) +void tSimpleLivingString5_setPickupPoint(tSimpleLivingString5* const p, Lfloat pickupPoint) { p->pickupPoint = pickupPoint; tExpSmooth_setDest(p->pickupPointSmooth, pickupPoint); } -Lfloat tSimpleLivingString5_sample(tSimpleLivingString5 const p) +Lfloat tSimpleLivingString5_sample(tSimpleLivingString5* const p) { return p->curr; } -void tSimpleLivingString5_setSampleRate(tSimpleLivingString5 const p, Lfloat sr) +void tSimpleLivingString5_setSampleRate(tSimpleLivingString5* const p, Lfloat sr) { p->sampleRate = sr*p->oversampling; Lfloat freq = p->sampleRate/p->waveLengthInSamples; p->waveLengthInSamples = p->sampleRate/freq; tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); - tOnePole_setSampleRate(p->bridgeFilter, p->sampleRate); - tHighpass_setSampleRate(p->DCblocker, p->sampleRate); + tOnePole_setSampleRate(&p->bridgeFilter, p->sampleRate); + tHighpass_setSampleRate(&p->DCblocker, p->sampleRate); } -void tSimpleLivingString5_setFFAmount(tSimpleLivingString5 const p, Lfloat ff) +void tSimpleLivingString5_setFFAmount(tSimpleLivingString5* const p, Lfloat ff) { p->ff = ff; } -void tLivingString_free (tLivingString* const pl) +void tLivingString_free (tLivingString** const pl) { - _tLivingString* p = *pl; + tLivingString* p = *pl; tExpSmooth_free(&p->wlSmooth); tExpSmooth_free(&p->ppSmooth); @@ -1722,7 +1722,7 @@ void tLivingString_free (tLivingString* const pl) mpool_free((char*)p, p->mempool); } -void tLivingString_setFreq(tLivingString const p, Lfloat freq) +void tLivingString_setFreq(tLivingString* const p, Lfloat freq) { // NOTE: It is faster to set wavelength in samples directly if (freq<20.f) freq=20.f; else if (freq>10000.f) freq=10000.f; @@ -1730,7 +1730,7 @@ void tLivingString_setFreq(tLivingString const p, Lfloat freq) tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); } -void tLivingString_setWaveLength(tLivingString const p, Lfloat waveLength) +void tLivingString_setWaveLength(tLivingString* const p, Lfloat waveLength) { if (waveLength<4.8f) waveLength=4.8f; else if (waveLength>2400.f) waveLength=2400.f; @@ -1738,7 +1738,7 @@ void tLivingString_setWaveLength(tLivingString const p, Lfloat waveLength) tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); } -void tLivingString_setPickPos(tLivingString const p, Lfloat pickPos) +void tLivingString_setPickPos(tLivingString* const p, Lfloat pickPos) { // between 0 and 1 if (pickPos<0.f) pickPos=0.f; else if (pickPos>1.f) pickPos=1.f; @@ -1746,102 +1746,102 @@ void tLivingString_setPickPos(tLivingString const p, Lfloat pickPos) tExpSmooth_setDest(p->ppSmooth, p->pickPos); } -void tLivingString_setPrepIndex(tLivingString const p, Lfloat prepIndex) +void tLivingString_setPrepIndex(tLivingString* const p, Lfloat prepIndex) { // between 0 and 1 if (prepIndex<0.f) prepIndex=0.f; else if (prepIndex>1.f) prepIndex=1.f; p->prepIndex = prepIndex; } -void tLivingString_setDampFreq(tLivingString const p, Lfloat dampFreq) +void tLivingString_setDampFreq(tLivingString* const p, Lfloat dampFreq) { - tOnePole_setFreq(p->bridgeFilter, dampFreq); - tOnePole_setFreq(p->nutFilter, dampFreq); - tOnePole_setFreq(p->prepFilterU, dampFreq); - tOnePole_setFreq(p->prepFilterL, dampFreq); + tOnePole_setFreq(&p->bridgeFilter, dampFreq); + tOnePole_setFreq(&p->nutFilter, dampFreq); + tOnePole_setFreq(&p->prepFilterU, dampFreq); + tOnePole_setFreq(&p->prepFilterL, dampFreq); } -void tLivingString_setDecay(tLivingString const p, Lfloat decay) +void tLivingString_setDecay(tLivingString* const p, Lfloat decay) { p->decay=decay; } -void tLivingString_setTargetLev(tLivingString const p, Lfloat targetLev) +void tLivingString_setTargetLev(tLivingString* const p, Lfloat targetLev) { - tFeedbackLeveler_setTargetLevel(p->fbLevU, targetLev); - tFeedbackLeveler_setTargetLevel(p->fbLevL, targetLev); + tFeedbackLeveler_setTargetLevel(&p->fbLevU, targetLev); + tFeedbackLeveler_setTargetLevel(&p->fbLevL, targetLev); } -void tLivingString_setLevSmoothFactor(tLivingString const p, Lfloat levSmoothFactor) +void tLivingString_setLevSmoothFactor(tLivingString* const p, Lfloat levSmoothFactor) { - tFeedbackLeveler_setFactor(p->fbLevU, levSmoothFactor); - tFeedbackLeveler_setFactor(p->fbLevL, levSmoothFactor); + tFeedbackLeveler_setFactor(&p->fbLevU, levSmoothFactor); + tFeedbackLeveler_setFactor(&p->fbLevL, levSmoothFactor); } -void tLivingString_setLevStrength(tLivingString const p, Lfloat levStrength) +void tLivingString_setLevStrength(tLivingString* const p, Lfloat levStrength) { - tFeedbackLeveler_setStrength(p->fbLevU, levStrength); - tFeedbackLeveler_setStrength(p->fbLevL, levStrength); + tFeedbackLeveler_setStrength(&p->fbLevU, levStrength); + tFeedbackLeveler_setStrength(&p->fbLevL, levStrength); } -void tLivingString_setLevMode(tLivingString const p, int levMode) +void tLivingString_setLevMode(tLivingString* const p, int levMode) { - tFeedbackLeveler_setMode(p->fbLevU, levMode); - tFeedbackLeveler_setMode(p->fbLevL, levMode); + tFeedbackLeveler_setMode(&p->fbLevU, levMode); + tFeedbackLeveler_setMode(&p->fbLevL, levMode); p->levMode=levMode; } -Lfloat tLivingString_tick(tLivingString const p, Lfloat input) +Lfloat tLivingString_tick(tLivingString *const p, Lfloat input) { // from pickPos upwards=forwards - Lfloat fromLF=tLinearDelay_tickOut(p->delLF); - Lfloat fromUF=tLinearDelay_tickOut(p->delUF); - Lfloat fromUB=tLinearDelay_tickOut(p->delUB); - Lfloat fromLB=tLinearDelay_tickOut(p->delLB); + Lfloat fromLF=tLinearDelay_tickOut(&p->delLF); + Lfloat fromUF=tLinearDelay_tickOut(&p->delUF); + Lfloat fromUB=tLinearDelay_tickOut(&p->delUB); + Lfloat fromLB=tLinearDelay_tickOut(&p->delLB); // into upper half of string, from nut, going backwards - Lfloat fromNut=-tFeedbackLeveler_tick(p->fbLevU, (p->levMode==0?p->decay:1)*tHighpass_tick(p->DCblockerU, tOnePole_tick(p->nutFilter, fromUF))); - tLinearDelay_tickIn(p->delUB, fromNut); + Lfloat fromNut=-tFeedbackLeveler_tick(&p->fbLevU, (p->levMode==0?p->decay:1)*tHighpass_tick(&p->DCblockerU, tOnePole_tick(&p->nutFilter, fromUF))); + tLinearDelay_tickIn(&p->delUB, fromNut); // into lower half of string, from pickpoint, going backwards - Lfloat fromLowerPrep=-tOnePole_tick(p->prepFilterL, fromLF); + Lfloat fromLowerPrep=-tOnePole_tick(&p->prepFilterL, fromLF); Lfloat intoLower=p->prepIndex*fromLowerPrep+(1.0f - p->prepIndex)*fromUB+input; - tLinearDelay_tickIn(p->delLB, intoLower); + tLinearDelay_tickIn(&p->delLB, intoLower); // into lower half of string, from bridge - Lfloat fromBridge=-tFeedbackLeveler_tick(p->fbLevL, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(p->DCblockerL, tOnePole_tick(p->bridgeFilter, fromLB))); - tLinearDelay_tickIn(p->delLF, fromBridge); + Lfloat fromBridge=-tFeedbackLeveler_tick(&p->fbLevL, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(&p->DCblockerL, tOnePole_tick(&p->bridgeFilter, fromLB))); + tLinearDelay_tickIn(&p->delLF, fromBridge); // into upper half of string, from pickpoint, going forwards/upwards - Lfloat fromUpperPrep=-tOnePole_tick(p->prepFilterU, fromUB); + Lfloat fromUpperPrep=-tOnePole_tick(&p->prepFilterU, fromUB); Lfloat intoUpper=p->prepIndex*fromUpperPrep+(1.0f - p->prepIndex)*fromLF+input; - tLinearDelay_tickIn(p->delUF, intoUpper); + tLinearDelay_tickIn(&p->delUF, intoUpper); // update all delay lengths Lfloat pickP=tExpSmooth_tick(p->ppSmooth); Lfloat wLen=tExpSmooth_tick(p->wlSmooth); Lfloat lowLen=pickP*wLen; Lfloat upLen=(1.0f-pickP)*wLen; - tLinearDelay_setDelay(p->delLF, lowLen); - tLinearDelay_setDelay(p->delLB, lowLen); - tLinearDelay_setDelay(p->delUF, upLen); - tLinearDelay_setDelay(p->delUB, upLen); + tLinearDelay_setDelay(&p->delLF, lowLen); + tLinearDelay_setDelay(&p->delLB, lowLen); + tLinearDelay_setDelay(&p->delUF, upLen); + tLinearDelay_setDelay(&p->delUB, upLen); p->curr = fromBridge; return p->curr; } -Lfloat tLivingString_sample(tLivingString const p) +Lfloat tLivingString_sample(tLivingString* const p) { return p->curr; } -void tLivingString_setSampleRate(tLivingString const p, Lfloat sr) +void tLivingString_setSampleRate(tLivingString* const p, Lfloat sr) { Lfloat freq = p->sampleRate/p->waveLengthInSamples; p->sampleRate = sr; p->waveLengthInSamples = p->sampleRate/freq; tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); - tOnePole_setSampleRate(p->bridgeFilter, p->sampleRate); - tOnePole_setSampleRate(p->nutFilter, p->sampleRate); - tOnePole_setSampleRate(p->prepFilterU, p->sampleRate); - tOnePole_setSampleRate(p->prepFilterL, p->sampleRate); - tHighpass_setSampleRate(p->DCblockerU, p->sampleRate); - tHighpass_setSampleRate(p->DCblockerL, p->sampleRate); + tOnePole_setSampleRate(&p->bridgeFilter, p->sampleRate); + tOnePole_setSampleRate(&p->nutFilter, p->sampleRate); + tOnePole_setSampleRate(&p->prepFilterU, p->sampleRate); + tOnePole_setSampleRate(&p->prepFilterL, p->sampleRate); + tHighpass_setSampleRate(&p->DCblockerU, p->sampleRate); + tHighpass_setSampleRate(&p->DCblockerL, p->sampleRate); } @@ -1858,12 +1858,12 @@ void tLivingString2_init(tLivingString2* const pl, Lfloat freq, Lfloat pickPo tLivingString2_initToPool(pl, freq, pickPos, prepPos, pickupPos, prepIndex, brightness, decay, targetLev, levSmoothFactor, levStrength, levMode, &leaf->mempool); } -void tLivingString2_initToPool (tLivingString2* const pl, Lfloat freq, Lfloat pickPos, Lfloat prepPos, Lfloat pickupPos, Lfloat prepIndex, +void tLivingString2_initToPool (tLivingString2** const pl, Lfloat freq, Lfloat pickPos, Lfloat prepPos, Lfloat pickupPos, Lfloat prepIndex, Lfloat brightness, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, tMempool* const mp) { _tMempool* m = *mp; - _tLivingString2* p = *pl = (_tLivingString2*) mpool_alloc(sizeof(_tLivingString2), m); + tLivingString2* p = *pl = (tLivingString2*) mpool_alloc(sizeof(tLivingString2), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -1884,10 +1884,10 @@ void tLivingString2_initToPool (tLivingString2* const pl, Lfloat freq, Lfl tHermiteDelay_initToPool(&p->delUF,p->waveLengthInSamples, 2400, mp); tHermiteDelay_initToPool(&p->delUB,p->waveLengthInSamples, 2400, mp); tHermiteDelay_initToPool(&p->delLB,p->waveLengthInSamples, 2400, mp); - tHermiteDelay_clear(p->delLF); - tHermiteDelay_clear(p->delUF); - tHermiteDelay_clear(p->delUB); - tHermiteDelay_clear(p->delLB); + tHermiteDelay_clear(&p->delLF); + tHermiteDelay_clear(&p->delUF); + tHermiteDelay_clear(&p->delUB); + tHermiteDelay_clear(&p->delLB); p->brightness = brightness; tTwoZero_initToPool(&p->bridgeFilter, mp); tTwoZero_initToPool(&p->nutFilter, mp); @@ -1903,9 +1903,9 @@ void tLivingString2_initToPool (tLivingString2* const pl, Lfloat freq, Lfl p->levMode=levMode; } -void tLivingString2_free (tLivingString2* const pl) +void tLivingString2_free (tLivingString2** const pl) { - _tLivingString2* p = *pl; + tLivingString2* p = *pl; tExpSmooth_free(&p->wlSmooth); tExpSmooth_free(&p->ppSmooth); @@ -1927,7 +1927,7 @@ void tLivingString2_free (tLivingString2* const pl) mpool_free((char*)p, p->mempool); } -void tLivingString2_setFreq(tLivingString2 const p, Lfloat freq) +void tLivingString2_setFreq(tLivingString2* const p, Lfloat freq) { // NOTE: It is faster to set wavelength in samples directly if (freq<20.f) freq=20.f; else if (freq>10000.f) freq=10000.f; @@ -1937,7 +1937,7 @@ void tLivingString2_setFreq(tLivingString2 const p, Lfloat freq) tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); } -void tLivingString2_setWaveLength(tLivingString2 const p, Lfloat waveLength) +void tLivingString2_setWaveLength(tLivingString2* const p, Lfloat waveLength) { waveLength = waveLength * 0.5f; if (waveLength<4.8f) waveLength=4.8f; @@ -1947,7 +1947,7 @@ void tLivingString2_setWaveLength(tLivingString2 const p, Lfloat waveLength) tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); } -void tLivingString2_setPickPos(tLivingString2 const p, Lfloat pickPos) +void tLivingString2_setPickPos(tLivingString2* const p, Lfloat pickPos) { // between 0 and 1 if (pickPos<0.f) pickPos=0.f; else if (pickPos>1.f) pickPos=1.f; @@ -1955,7 +1955,7 @@ void tLivingString2_setPickPos(tLivingString2 const p, Lfloat pickPos) tExpSmooth_setDest(p->ppSmooth, p->pickPos); } -void tLivingString2_setPrepPos(tLivingString2 const p, Lfloat prepPos) +void tLivingString2_setPrepPos(tLivingString2* const p, Lfloat prepPos) { // between 0 and 1 if (prepPos<0.f) prepPos=0.f; else if (prepPos>1.f) prepPos=1.f; @@ -1963,7 +1963,7 @@ void tLivingString2_setPrepPos(tLivingString2 const p, Lfloat prepPos) tExpSmooth_setDest(p->prpSmooth, p->prepPos); } -void tLivingString2_setPickupPos(tLivingString2 const p, Lfloat pickupPos) +void tLivingString2_setPickupPos(tLivingString2* const p, Lfloat pickupPos) { // between 0 and 1 if (pickupPos<0.f) pickupPos=0.f; else if (pickupPos>1.f) pickupPos=1.f; @@ -1971,55 +1971,55 @@ void tLivingString2_setPickupPos(tLivingString2 const p, Lfloat pickupPos) tExpSmooth_setDest(p->puSmooth, p->pickupPos); } -void tLivingString2_setPrepIndex(tLivingString2 const p, Lfloat prepIndex) +void tLivingString2_setPrepIndex(tLivingString2* const p, Lfloat prepIndex) { // between 0 and 1 if (prepIndex<0.f) prepIndex=0.f; else if (prepIndex>1.f) prepIndex=1.f; p->prepIndex = prepIndex; } -void tLivingString2_setBrightness(tLivingString2 const p, Lfloat brightness) +void tLivingString2_setBrightness(tLivingString2* const p, Lfloat brightness) { Lfloat h0=(1.0 + brightness) * 0.5f; Lfloat h1=(1.0 - brightness) * 0.25f; - tTwoZero_setCoefficients(p->bridgeFilter, h1, h0, h1); - tTwoZero_setCoefficients(p->nutFilter, h1, h0, h1); - tTwoZero_setCoefficients(p->prepFilterU, h1, h0, h1); - tTwoZero_setCoefficients(p->prepFilterL, h1, h0, h1); + tTwoZero_setCoefficients(&p->bridgeFilter, h1, h0, h1); + tTwoZero_setCoefficients(&p->nutFilter, h1, h0, h1); + tTwoZero_setCoefficients(&p->prepFilterU, h1, h0, h1); + tTwoZero_setCoefficients(&p->prepFilterL, h1, h0, h1); } -void tLivingString2_setDecay(tLivingString2 const p, Lfloat decay) +void tLivingString2_setDecay(tLivingString2* const p, Lfloat decay) { p->decay=powf(0.001f,1.0f/(p->freq*decay)); } -void tLivingString2_setTargetLev(tLivingString2 const p, Lfloat targetLev) +void tLivingString2_setTargetLev(tLivingString2* const p, Lfloat targetLev) { - tFeedbackLeveler_setTargetLevel(p->fbLevU, targetLev); - tFeedbackLeveler_setTargetLevel(p->fbLevL, targetLev); + tFeedbackLeveler_setTargetLevel(&p->fbLevU, targetLev); + tFeedbackLeveler_setTargetLevel(&p->fbLevL, targetLev); } -void tLivingString2_setLevSmoothFactor(tLivingString2 const p, Lfloat levSmoothFactor) +void tLivingString2_setLevSmoothFactor(tLivingString2* const p, Lfloat levSmoothFactor) { - tFeedbackLeveler_setFactor(p->fbLevU, levSmoothFactor); - tFeedbackLeveler_setFactor(p->fbLevL, levSmoothFactor); + tFeedbackLeveler_setFactor(&p->fbLevU, levSmoothFactor); + tFeedbackLeveler_setFactor(&p->fbLevL, levSmoothFactor); } -void tLivingString2_setLevStrength(tLivingString2 const p, Lfloat levStrength) +void tLivingString2_setLevStrength(tLivingString2* const p, Lfloat levStrength) { - tFeedbackLeveler_setStrength(p->fbLevU, levStrength); - tFeedbackLeveler_setStrength(p->fbLevL, levStrength); + tFeedbackLeveler_setStrength(&p->fbLevU, levStrength); + tFeedbackLeveler_setStrength(&p->fbLevL, levStrength); } -void tLivingString2_setLevMode(tLivingString2 const p, int levMode) +void tLivingString2_setLevMode(tLivingString2* const p, int levMode) { - tFeedbackLeveler_setMode(p->fbLevU, levMode); - tFeedbackLeveler_setMode(p->fbLevL, levMode); + tFeedbackLeveler_setMode(&p->fbLevU, levMode); + tFeedbackLeveler_setMode(&p->fbLevL, levMode); p->levMode=levMode; } -Lfloat tLivingString2_tick(tLivingString2 const p, Lfloat input) +Lfloat tLivingString2_tick(tLivingString2* const p, Lfloat input) { input = input * 0.5f; // drop gain by half since we'll be equally adding it at half amplitude to forward and backward waveguides // from prepPos upwards=forwards @@ -2041,10 +2041,10 @@ Lfloat tLivingString2_tick(tLivingString2 const p, Lfloat input) pickPInt = (uint32_t) fullPickPoint; // where does the input go? that's the pick point Lfloat pickPLfloat = fullPickPoint - pickPInt; - tHermiteDelay_addTo(p->delUF, input * (1.0f - pickPLfloat), pickPInt); - tHermiteDelay_addTo(p->delUF, input * pickPLfloat, pickPInt + 1); - tHermiteDelay_addTo(p->delUB, input * (1.0f - pickPLfloat), (uint32_t) (upLen - pickPInt)); - tHermiteDelay_addTo(p->delUB, input * pickPLfloat, (uint32_t) (upLen - pickPInt - 1)); + tHermiteDelay_addTo(&p->delUF, input * (1.0f - pickPLfloat), pickPInt); + tHermiteDelay_addTo(&p->delUF, input * pickPLfloat, pickPInt + 1); + tHermiteDelay_addTo(&p->delUB, input * (1.0f - pickPLfloat), (uint32_t) (upLen - pickPInt)); + tHermiteDelay_addTo(&p->delUB, input * pickPLfloat, (uint32_t) (upLen - pickPInt - 1)); } else { @@ -2052,10 +2052,10 @@ Lfloat tLivingString2_tick(tLivingString2 const p, Lfloat input) pickPInt = (uint32_t) fullPickPoint; // where does the input go? that's the pick point Lfloat pickPLfloat = fullPickPoint - pickPInt; - tHermiteDelay_addTo(p->delLF, input * (1.0f - pickPLfloat), pickPInt); - tHermiteDelay_addTo(p->delLF, input * pickPLfloat, pickPInt + 1); - tHermiteDelay_addTo(p->delLB, input * (1.0f - pickPLfloat), (uint32_t) (lowLen - pickPInt)); - tHermiteDelay_addTo(p->delLB, input * pickPLfloat, (uint32_t) (lowLen - pickPInt - 1)); + tHermiteDelay_addTo(&p->delLF, input * (1.0f - pickPLfloat), pickPInt); + tHermiteDelay_addTo(&p->delLF, input * pickPLfloat, pickPInt + 1); + tHermiteDelay_addTo(&p->delLB, input * (1.0f - pickPLfloat), (uint32_t) (lowLen - pickPInt)); + tHermiteDelay_addTo(&p->delLB, input * pickPLfloat, (uint32_t) (lowLen - pickPInt - 1)); } /* if (pickP > prepP) @@ -2075,42 +2075,42 @@ Lfloat tLivingString2_tick(tLivingString2 const p, Lfloat input) tHermiteDelay_addTo(&p->delLB, input, (uint32_t) (lowLen - pickPInt)); } */ - Lfloat fromLF=tHermiteDelay_tickOut(p->delLF); - Lfloat fromUF=tHermiteDelay_tickOut(p->delUF); - Lfloat fromUB=tHermiteDelay_tickOut(p->delUB); - Lfloat fromLB=tHermiteDelay_tickOut(p->delLB); + Lfloat fromLF=tHermiteDelay_tickOut(&p->delLF); + Lfloat fromUF=tHermiteDelay_tickOut(&p->delUF); + Lfloat fromUB=tHermiteDelay_tickOut(&p->delUB); + Lfloat fromLB=tHermiteDelay_tickOut(&p->delLB); fromLB = LEAF_clip(-1.0f, fromLB, 1.0f); fromUB = LEAF_clip(-1.0f, fromUB, 1.0f); fromUF = LEAF_clip(-1.0f, fromUF, 1.0f); fromLF = LEAF_clip(-1.0f, fromLF, 1.0f); // into upper half of string, from bridge, going backwards - Lfloat fromBridge=-tFeedbackLeveler_tick(p->fbLevU, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(p->DCblockerU, tTwoZero_tick(p->bridgeFilter, fromUF))); + Lfloat fromBridge=-tFeedbackLeveler_tick(&p->fbLevU, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(&p->DCblockerU, tTwoZero_tick(&p->bridgeFilter, fromUF))); fromBridge = LEAF_clip(-1.0f, fromBridge, 1.0f); - tHermiteDelay_tickIn(p->delUB, fromBridge); + tHermiteDelay_tickIn(&p->delUB, fromBridge); // into lower half of string, from prepPoint, going backwards - Lfloat fromLowerPrep=-tTwoZero_tick(p->prepFilterL, fromLF); + Lfloat fromLowerPrep=-tTwoZero_tick(&p->prepFilterL, fromLF); fromLowerPrep = LEAF_clip(-1.0f, fromLowerPrep, 1.0f); Lfloat intoLower=p->prepIndex*fromLowerPrep+(1.0f - p->prepIndex)*fromUB; //used to add input here intoLower = LEAF_clip(-1.0f, intoLower, 1.0f); - tHermiteDelay_tickIn(p->delLB, intoLower); + tHermiteDelay_tickIn(&p->delLB, intoLower); // into lower half of string, from nut - Lfloat fromNut=-tFeedbackLeveler_tick(p->fbLevL, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(p->DCblockerL, tTwoZero_tick(p->nutFilter, fromLB))); + Lfloat fromNut=-tFeedbackLeveler_tick(&p->fbLevL, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(&p->DCblockerL, tTwoZero_tick(&p->nutFilter, fromLB))); fromNut = LEAF_clip(-1.0f, fromNut, 1.0f); - tHermiteDelay_tickIn(p->delLF, fromNut); + tHermiteDelay_tickIn(&p->delLF, fromNut); // into upper half of string, from prepPoint, going forwards/upwards - Lfloat fromUpperPrep=-tTwoZero_tick(p->prepFilterU, fromUB); + Lfloat fromUpperPrep=-tTwoZero_tick(&p->prepFilterU, fromUB); fromUpperPrep = LEAF_clip(-1.0f, fromUpperPrep, 1.0f); Lfloat intoUpper=p->prepIndex*fromUpperPrep+(1.0f - p->prepIndex)*fromLF; //intoUpper = tanhf(intoUpper); intoUpper = LEAF_clip(-1.0f, intoUpper, 1.0f); - tHermiteDelay_tickIn(p->delUF, intoUpper); + tHermiteDelay_tickIn(&p->delUF, intoUpper); // update all delay lengths - tHermiteDelay_setDelay(p->delLF, lowLen); - tHermiteDelay_setDelay(p->delLB, lowLen); - tHermiteDelay_setDelay(p->delUF, upLen); - tHermiteDelay_setDelay(p->delUB, upLen); + tHermiteDelay_setDelay(&p->delLF, lowLen); + tHermiteDelay_setDelay(&p->delLB, lowLen); + tHermiteDelay_setDelay(&p->delUF, upLen); + tHermiteDelay_setDelay(&p->delUB, upLen); uint32_t PUPInt; Lfloat pickupOut = 0.0f; @@ -2123,10 +2123,10 @@ Lfloat tLivingString2_tick(tLivingString2 const p, Lfloat input) PUPInt = (uint32_t) fullPUPoint; // where does the input go? that's the pick point Lfloat PUPLfloat = fullPUPoint - PUPInt; - pickupOut = tHermiteDelay_tapOut(p->delUF, PUPInt) * (1.0f - PUPLfloat); - pickupOut += tHermiteDelay_tapOut(p->delUF, PUPInt + 1) * PUPLfloat; - pickupOut += tHermiteDelay_tapOut(p->delUB, (uint32_t) (upLen - PUPInt)) * (1.0f - PUPLfloat); - pickupOut += tHermiteDelay_tapOut(p->delUB, (uint32_t) (upLen - PUPInt - 1)) * PUPLfloat; + pickupOut = tHermiteDelay_tapOut(&p->delUF, PUPInt) * (1.0f - PUPLfloat); + pickupOut += tHermiteDelay_tapOut(&p->delUF, PUPInt + 1) * PUPLfloat; + pickupOut += tHermiteDelay_tapOut(&p->delUB, (uint32_t) (upLen - PUPInt)) * (1.0f - PUPLfloat); + pickupOut += tHermiteDelay_tapOut(&p->delUB, (uint32_t) (upLen - PUPInt - 1)) * PUPLfloat; } else { @@ -2134,10 +2134,10 @@ Lfloat tLivingString2_tick(tLivingString2 const p, Lfloat input) PUPInt = (uint32_t) fullPUPoint; // where does the input go? that's the pick point Lfloat PUPLfloat = fullPUPoint - PUPInt; - pickupOut = tHermiteDelay_tapOut(p->delLF, PUPInt) * (1.0f - PUPLfloat); - pickupOut += tHermiteDelay_tapOut(p->delLF, PUPInt + 1) * PUPLfloat; - pickupOut += tHermiteDelay_tapOut(p->delLB, (uint32_t) (lowLen - PUPInt)) * (1.0f - PUPLfloat); - pickupOut += tHermiteDelay_tapOut(p->delLB, (uint32_t) (lowLen - PUPInt - 1)) * PUPLfloat; + pickupOut = tHermiteDelay_tapOut(&p->delLF, PUPInt) * (1.0f - PUPLfloat); + pickupOut += tHermiteDelay_tapOut(&p->delLF, PUPInt + 1) * PUPLfloat; + pickupOut += tHermiteDelay_tapOut(&p->delLB, (uint32_t) (lowLen - PUPInt)) * (1.0f - PUPLfloat); + pickupOut += tHermiteDelay_tapOut(&p->delLB, (uint32_t) (lowLen - PUPInt - 1)) * PUPLfloat; } p->curr = pickupOut; @@ -2170,7 +2170,7 @@ Lfloat tLivingString2_tick(tLivingString2 const p, Lfloat input) return p->curr; } -Lfloat tLivingString2_tickEfficient(tLivingString2 const p, Lfloat input) +Lfloat tLivingString2_tickEfficient(tLivingString2* const p, Lfloat input) { input = input * 0.5f; // drop gain by half since we'll be equally adding it at half amplitude to forward and backward waveguides // from prepPos upwards=forwards @@ -2189,37 +2189,37 @@ Lfloat tLivingString2_tickEfficient(tLivingString2 const p, Lfloat input) Lfloat fullPickPoint = ((pickP*wLen) - lowLen); pickPInt = (uint32_t) fullPickPoint; // where does the input go? that's the pick point - tHermiteDelay_addTo(p->delUF, input, pickPInt); - tHermiteDelay_addTo(p->delUB, input, (uint32_t) (upLen - pickPInt)); + tHermiteDelay_addTo(&p->delUF, input, pickPInt); + tHermiteDelay_addTo(&p->delUB, input, (uint32_t) (upLen - pickPInt)); } else { Lfloat fullPickPoint = pickP * wLen; pickPInt = (uint32_t) fullPickPoint; // where does the input go? that's the pick point - tHermiteDelay_addTo(p->delLF, input, pickPInt); - tHermiteDelay_addTo(p->delLB, input, (uint32_t) (lowLen - pickPInt)); + tHermiteDelay_addTo(&p->delLF, input, pickPInt); + tHermiteDelay_addTo(&p->delLB, input, (uint32_t) (lowLen - pickPInt)); } - Lfloat fromLF=tHermiteDelay_tickOut(p->delLF); - Lfloat fromUF=tHermiteDelay_tickOut(p->delUF); - Lfloat fromUB=tHermiteDelay_tickOut(p->delUB); - Lfloat fromLB=tHermiteDelay_tickOut(p->delLB); + Lfloat fromLF=tHermiteDelay_tickOut(&p->delLF); + Lfloat fromUF=tHermiteDelay_tickOut(&p->delUF); + Lfloat fromUB=tHermiteDelay_tickOut(&p->delUB); + Lfloat fromLB=tHermiteDelay_tickOut(&p->delLB); // into upper half of string, from bridge, going backwards //Lfloat fromBridge=-tFeedbackLeveler_tick(&p->fbLevU, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(&p->DCblockerU, tTwoZero_tick(&p->bridgeFilter, fromUF))); - Lfloat fromBridge=-tFeedbackLeveler_tick(p->fbLevU,tHighpass_tick(p->DCblockerU, tTwoZero_tick(p->bridgeFilter, fromUF))); - tHermiteDelay_tickIn(p->delUB, fromBridge); + Lfloat fromBridge=-tFeedbackLeveler_tick(&p->fbLevU,tHighpass_tick(&p->DCblockerU, tTwoZero_tick(&p->bridgeFilter, fromUF))); + tHermiteDelay_tickIn(&p->delUB, fromBridge); // into lower half of string, from prepPoint, going backwards - Lfloat fromLowerPrep=-tTwoZero_tick(p->prepFilterL, fromLF); + Lfloat fromLowerPrep=-tTwoZero_tick(&p->prepFilterL, fromLF); Lfloat intoLower=(p->prepIndex*fromLowerPrep)+((1.0f - p->prepIndex)*fromUB); //used to add input here - tHermiteDelay_tickIn(p->delLB, intoLower); + tHermiteDelay_tickIn(&p->delLB, intoLower); // into lower half of string, from nut //Lfloat fromNut=-tFeedbackLeveler_tick(&p->fbLevL, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(&p->DCblockerL, tTwoZero_tick(&p->nutFilter, fromLB))); - Lfloat fromNut=-tFeedbackLeveler_tick(p->fbLevL,tHighpass_tick(p->DCblockerL, tTwoZero_tick(p->nutFilter, fromLB))); - tHermiteDelay_tickIn(p->delLF, fromNut); + Lfloat fromNut=-tFeedbackLeveler_tick(&p->fbLevL,tHighpass_tick(&p->DCblockerL, tTwoZero_tick(&p->nutFilter, fromLB))); + tHermiteDelay_tickIn(&p->delLF, fromNut); // into upper half of string, from prepPoint, going forwards/upwards - Lfloat fromUpperPrep=-tTwoZero_tick(p->prepFilterU, fromUB); + Lfloat fromUpperPrep=-tTwoZero_tick(&p->prepFilterU, fromUB); Lfloat intoUpper=(p->prepIndex*fromUpperPrep)+((1.0f - p->prepIndex)*fromLF); - tHermiteDelay_tickIn(p->delUF, intoUpper); + tHermiteDelay_tickIn(&p->delUF, intoUpper); // update all delay lengths p->curr = fromBridge; @@ -2231,35 +2231,35 @@ Lfloat tLivingString2_tickEfficient(tLivingString2 const p, Lfloat input) } -void tLivingString2_updateDelays(tLivingString2 const p) +void tLivingString2_updateDelays(tLivingString2* const p) { //need to determine which delay line to put it into (should be half amplitude into forward and backward lines for the correct portion of string) Lfloat lowLen=p->prpSmooth->dest*p->wlSmooth->dest; Lfloat upLen=(1.0f-p->prpSmooth->dest)*p->wlSmooth->dest; - tHermiteDelay_setDelay(p->delLF, lowLen); - tHermiteDelay_setDelay(p->delLB, lowLen); - tHermiteDelay_setDelay(p->delUF, upLen); - tHermiteDelay_setDelay(p->delUB, upLen); + tHermiteDelay_setDelay(&p->delLF, lowLen); + tHermiteDelay_setDelay(&p->delLB, lowLen); + tHermiteDelay_setDelay(&p->delUF, upLen); + tHermiteDelay_setDelay(&p->delUB, upLen); } -Lfloat tLivingString2_sample(tLivingString2 const p) +Lfloat tLivingString2_sample(tLivingString2* const p) { return p->curr; } -void tLivingString2_setSampleRate(tLivingString2 const p, Lfloat sr) +void tLivingString2_setSampleRate(tLivingString2* const p, Lfloat sr) { p->sampleRate = sr; p->waveLengthInSamples = (p->sampleRate/p->freq) - 1; tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); - tTwoZero_setSampleRate(p->bridgeFilter, p->sampleRate); - tTwoZero_setSampleRate(p->nutFilter, p->sampleRate); - tTwoZero_setSampleRate(p->prepFilterU, p->sampleRate); - tTwoZero_setSampleRate(p->prepFilterL, p->sampleRate); - tHighpass_setSampleRate(p->DCblockerU, p->sampleRate); - tHighpass_setSampleRate(p->DCblockerL, p->sampleRate); + tTwoZero_setSampleRate(&p->bridgeFilter, p->sampleRate); + tTwoZero_setSampleRate(&p->nutFilter, p->sampleRate); + tTwoZero_setSampleRate(&p->prepFilterU, p->sampleRate); + tTwoZero_setSampleRate(&p->prepFilterL, p->sampleRate); + tHighpass_setSampleRate(&p->DCblockerU, p->sampleRate); + tHighpass_setSampleRate(&p->DCblockerL, p->sampleRate); } @@ -2274,12 +2274,12 @@ void tComplexLivingString_init(tComplexLivingString* const pl, Lfloat freq, L tComplexLivingString_initToPool(pl, freq, pickPos, prepPos, prepIndex, dampFreq, decay, targetLev, levSmoothFactor, levStrength, levMode, &leaf->mempool); } -void tComplexLivingString_initToPool (tComplexLivingString* const pl, Lfloat freq, Lfloat pickPos, Lfloat prepPos, Lfloat prepIndex, +void tComplexLivingString_initToPool (tComplexLivingString** const pl, Lfloat freq, Lfloat pickPos, Lfloat prepPos, Lfloat prepIndex, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, tMempool* const mp) { _tMempool* m = *mp; - _tComplexLivingString* p = *pl = (_tComplexLivingString*) mpool_alloc(sizeof(_tComplexLivingString), m); + tComplexLivingString* p = *pl = (tComplexLivingString*) mpool_alloc(sizeof(tComplexLivingString), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -2302,12 +2302,12 @@ void tComplexLivingString_initToPool (tComplexLivingString* const pl, Lflo tLinearDelay_initToPool(&p->delUB,p->waveLengthInSamples, 2400, mp); tLinearDelay_initToPool(&p->delMB,p->waveLengthInSamples, 2400, mp); tLinearDelay_initToPool(&p->delLB,p->waveLengthInSamples, 2400, mp); - tLinearDelay_clear(p->delLF); - tLinearDelay_clear(p->delMF); - tLinearDelay_clear(p->delUF); - tLinearDelay_clear(p->delUB); - tLinearDelay_clear(p->delMB); - tLinearDelay_clear(p->delLB); + tLinearDelay_clear(&p->delLF); + tLinearDelay_clear(&p->delMF); + tLinearDelay_clear(&p->delUF); + tLinearDelay_clear(&p->delUB); + tLinearDelay_clear(&p->delMB); + tLinearDelay_clear(&p->delLB); p->dampFreq = dampFreq; tOnePole_initToPool(&p->bridgeFilter, dampFreq, mp); tOnePole_initToPool(&p->nutFilter, dampFreq, mp); @@ -2322,9 +2322,9 @@ void tComplexLivingString_initToPool (tComplexLivingString* const pl, Lflo p->levMode=levMode; } -void tComplexLivingString_free (tComplexLivingString* const pl) +void tComplexLivingString_free (tComplexLivingString** const pl) { - _tComplexLivingString* p = *pl; + tComplexLivingString* p = *pl; tExpSmooth_free(&p->wlSmooth); tExpSmooth_free(&p->pickPosSmooth); @@ -2347,7 +2347,7 @@ void tComplexLivingString_free (tComplexLivingString* const pl) mpool_free((char*)p, p->mempool); } -void tComplexLivingString_setFreq(tComplexLivingString const p, Lfloat freq) +void tComplexLivingString_setFreq(tComplexLivingString* const p, Lfloat freq) { // NOTE: It is faster to set wavelength in samples directly if (freq<20.0f) freq=20.0f; else if (freq>10000.0f) freq=10000.0f; @@ -2355,7 +2355,7 @@ void tComplexLivingString_setFreq(tComplexLivingString const p, Lfloat freq) tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); } -void tComplexLivingString_setWaveLength(tComplexLivingString const p, Lfloat waveLength) +void tComplexLivingString_setWaveLength(tComplexLivingString* const p, Lfloat waveLength) { if (waveLength<4.8f) waveLength=4.8f; else if (waveLength>2400.0f) waveLength=2400.0f; @@ -2363,7 +2363,7 @@ void tComplexLivingString_setWaveLength(tComplexLivingString const p, Lfloat tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); } -void tComplexLivingString_setPickPos(tComplexLivingString const p, Lfloat pickPos) +void tComplexLivingString_setPickPos(tComplexLivingString* const p, Lfloat pickPos) { // between 0 and 1 if (pickPos<0.5f) pickPos=0.5f; else if (pickPos>1.f) pickPos=1.f; @@ -2371,7 +2371,7 @@ void tComplexLivingString_setPickPos(tComplexLivingString const p, Lfloat pi tExpSmooth_setDest(p->pickPosSmooth, p->pickPos); } -void tComplexLivingString_setPrepPos(tComplexLivingString const p, Lfloat prepPos) +void tComplexLivingString_setPrepPos(tComplexLivingString* const p, Lfloat prepPos) { // between 0 and 1 if (prepPos<0.f) prepPos=0.f; else if (prepPos>0.5f) prepPos=0.5f; @@ -2379,86 +2379,86 @@ void tComplexLivingString_setPrepPos(tComplexLivingString const p, Lfloat pr tExpSmooth_setDest(p->prepPosSmooth, p->prepPos); } -void tComplexLivingString_setPrepIndex(tComplexLivingString const p, Lfloat prepIndex) +void tComplexLivingString_setPrepIndex(tComplexLivingString* const p, Lfloat prepIndex) { // between 0 and 1 if (prepIndex<0.f) prepIndex=0.f; else if (prepIndex>1.f) prepIndex=1.f; p->prepIndex = prepIndex; } -void tComplexLivingString_setDampFreq(tComplexLivingString const p, Lfloat dampFreq) +void tComplexLivingString_setDampFreq(tComplexLivingString* const p, Lfloat dampFreq) { - tOnePole_setFreq(p->bridgeFilter, dampFreq); - tOnePole_setFreq(p->nutFilter, dampFreq); - tOnePole_setFreq(p->prepFilterU, dampFreq); - tOnePole_setFreq(p->prepFilterL, dampFreq); + tOnePole_setFreq(&p->bridgeFilter, dampFreq); + tOnePole_setFreq(&p->nutFilter, dampFreq); + tOnePole_setFreq(&p->prepFilterU, dampFreq); + tOnePole_setFreq(&p->prepFilterL, dampFreq); } -void tComplexLivingString_setDecay(tComplexLivingString const p, Lfloat decay) +void tComplexLivingString_setDecay(tComplexLivingString* const p, Lfloat decay) { p->decay=decay; } -void tComplexLivingString_setTargetLev(tComplexLivingString const p, Lfloat targetLev) +void tComplexLivingString_setTargetLev(tComplexLivingString* const p, Lfloat targetLev) { - tFeedbackLeveler_setTargetLevel(p->fbLevU, targetLev); - tFeedbackLeveler_setTargetLevel(p->fbLevL, targetLev); + tFeedbackLeveler_setTargetLevel(&p->fbLevU, targetLev); + tFeedbackLeveler_setTargetLevel(&p->fbLevL, targetLev); } -void tComplexLivingString_setLevSmoothFactor(tComplexLivingString const p, Lfloat levSmoothFactor) +void tComplexLivingString_setLevSmoothFactor(tComplexLivingString* const p, Lfloat levSmoothFactor) { - tFeedbackLeveler_setFactor(p->fbLevU, levSmoothFactor); - tFeedbackLeveler_setFactor(p->fbLevL, levSmoothFactor); + tFeedbackLeveler_setFactor(&p->fbLevU, levSmoothFactor); + tFeedbackLeveler_setFactor(&p->fbLevL, levSmoothFactor); } -void tComplexLivingString_setLevStrength(tComplexLivingString const p, Lfloat levStrength) +void tComplexLivingString_setLevStrength(tComplexLivingString* const p, Lfloat levStrength) { - tFeedbackLeveler_setStrength(p->fbLevU, levStrength); - tFeedbackLeveler_setStrength(p->fbLevL, levStrength); + tFeedbackLeveler_setStrength(&p->fbLevU, levStrength); + tFeedbackLeveler_setStrength(&p->fbLevL, levStrength); } -void tComplexLivingString_setLevMode(tComplexLivingString const p, int levMode) +void tComplexLivingString_setLevMode(tComplexLivingString* const p, int levMode) { - tFeedbackLeveler_setMode(p->fbLevU, levMode); - tFeedbackLeveler_setMode(p->fbLevL, levMode); + tFeedbackLeveler_setMode(&p->fbLevU, levMode); + tFeedbackLeveler_setMode(&p->fbLevL, levMode); p->levMode=levMode; } -Lfloat tComplexLivingString_tick(tComplexLivingString const p, Lfloat input) +Lfloat tComplexLivingString_tick(tComplexLivingString* const p, Lfloat input) { // from pickPos upwards=forwards - Lfloat fromLF=tLinearDelay_tickOut(p->delLF); - Lfloat fromMF=tLinearDelay_tickOut(p->delMF); - Lfloat fromUF=tLinearDelay_tickOut(p->delUF); - Lfloat fromUB=tLinearDelay_tickOut(p->delUB); - Lfloat fromMB=tLinearDelay_tickOut(p->delMB); - Lfloat fromLB=tLinearDelay_tickOut(p->delLB); + Lfloat fromLF=tLinearDelay_tickOut(&p->delLF); + Lfloat fromMF=tLinearDelay_tickOut(&p->delMF); + Lfloat fromUF=tLinearDelay_tickOut(&p->delUF); + Lfloat fromUB=tLinearDelay_tickOut(&p->delUB); + Lfloat fromMB=tLinearDelay_tickOut(&p->delMB); + Lfloat fromLB=tLinearDelay_tickOut(&p->delLB); // into upper part of string, from bridge, going backwards - Lfloat fromBridge=-tFeedbackLeveler_tick(p->fbLevU, (p->levMode==0?p->decay:1)*tHighpass_tick(p->DCblockerU, tOnePole_tick(p->bridgeFilter, fromUF))); - tLinearDelay_tickIn(p->delUB, fromBridge); + Lfloat fromBridge=-tFeedbackLeveler_tick(&p->fbLevU, (p->levMode==0?p->decay:1)*tHighpass_tick(&p->DCblockerU, tOnePole_tick(&p->bridgeFilter, fromUF))); + tLinearDelay_tickIn(&p->delUB, fromBridge); // into pick position, take input and add it into the waveguide, going to come out of middle segment - tLinearDelay_tickIn(p->delMB, fromUB+input); + tLinearDelay_tickIn(&p->delMB, fromUB+input); // into lower part of string, from prepPos, going backwards - Lfloat fromLowerPrep=-tOnePole_tick(p->prepFilterL, fromLF); + Lfloat fromLowerPrep=-tOnePole_tick(&p->prepFilterL, fromLF); Lfloat intoLower=p->prepIndex*fromLowerPrep+(1.0f - p->prepIndex)*fromMB; - tLinearDelay_tickIn(p->delLB, intoLower); + tLinearDelay_tickIn(&p->delLB, intoLower); // into lower part of string, from nut, going forwards toward prep position - Lfloat fromNut=-tFeedbackLeveler_tick(p->fbLevL, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(p->DCblockerL, tOnePole_tick(p->nutFilter, fromLB))); - tLinearDelay_tickIn(p->delLF, fromNut); + Lfloat fromNut=-tFeedbackLeveler_tick(&p->fbLevL, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(&p->DCblockerL, tOnePole_tick(&p->nutFilter, fromLB))); + tLinearDelay_tickIn(&p->delLF, fromNut); // into middle part of string, from prep going toward pick position - Lfloat fromUpperPrep=-tOnePole_tick(p->prepFilterU, fromMB); + Lfloat fromUpperPrep=-tOnePole_tick(&p->prepFilterU, fromMB); Lfloat intoMiddle=p->prepIndex*fromUpperPrep+(1.0f - p->prepIndex)*fromLF; //pick position, going to come out of middle segment - tLinearDelay_tickIn(p->delMF, intoMiddle); + tLinearDelay_tickIn(&p->delMF, intoMiddle); //take output of middle segment and put it into upper segment connecting to the bridge, take input and add it into the waveguide, - tLinearDelay_tickIn(p->delUF, fromMF + input); + tLinearDelay_tickIn(&p->delUF, fromMF + input); // update all delay lengths Lfloat pickP=tExpSmooth_tick(p->pickPosSmooth); @@ -2470,37 +2470,37 @@ Lfloat tComplexLivingString_tick(tComplexLivingString const p, Lfloat input) Lfloat upLen = (1.0f-pickP)*wLen; // the length from pick to bridge - tLinearDelay_setDelay(p->delLF, lowLen); - tLinearDelay_setDelay(p->delLB, lowLen); + tLinearDelay_setDelay(&p->delLF, lowLen); + tLinearDelay_setDelay(&p->delLB, lowLen); - tLinearDelay_setDelay(p->delMF, midLen); - tLinearDelay_setDelay(p->delMB, midLen); + tLinearDelay_setDelay(&p->delMF, midLen); + tLinearDelay_setDelay(&p->delMB, midLen); - tLinearDelay_setDelay(p->delUF, upLen); - tLinearDelay_setDelay(p->delUB, upLen); + tLinearDelay_setDelay(&p->delUF, upLen); + tLinearDelay_setDelay(&p->delUB, upLen); //update this to allow pickup position variation p->curr = fromBridge; return p->curr; } -Lfloat tComplexLivingString_sample(tComplexLivingString const p) +Lfloat tComplexLivingString_sample(tComplexLivingString* const p) { return p->curr; } -void tComplexLivingString_setSampleRate(tComplexLivingString const p, Lfloat sr) +void tComplexLivingString_setSampleRate(tComplexLivingString* const p, Lfloat sr) { Lfloat freq = p->waveLengthInSamples/p->sampleRate; p->sampleRate = sr; p->waveLengthInSamples = p->sampleRate/freq; tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); - tOnePole_setSampleRate(p->bridgeFilter, p->sampleRate); - tOnePole_setSampleRate(p->nutFilter, p->sampleRate); - tOnePole_setSampleRate(p->prepFilterU, p->sampleRate); - tOnePole_setSampleRate(p->prepFilterL, p->sampleRate); - tHighpass_setSampleRate(p->DCblockerU, p->sampleRate); - tHighpass_setSampleRate(p->DCblockerL, p->sampleRate); + tOnePole_setSampleRate(&p->bridgeFilter, p->sampleRate); + tOnePole_setSampleRate(&p->nutFilter, p->sampleRate); + tOnePole_setSampleRate(&p->prepFilterU, p->sampleRate); + tOnePole_setSampleRate(&p->prepFilterL, p->sampleRate); + tHighpass_setSampleRate(&p->DCblockerU, p->sampleRate); + tHighpass_setSampleRate(&p->DCblockerL, p->sampleRate); } @@ -2508,10 +2508,10 @@ void tBowed_init (tBowed* const b, int oversampling, LEAF* c { tBowed_initToPool(b, oversampling, &leaf->mempool); } -void tBowed_initToPool (tBowed* const bw, int oversampling, tMempool* const mp) +void tBowed_initToPool (tBowed** const bw, int oversampling, tMempool* const mp) { _tMempool* m = *mp; - _tBowed* x = *bw = (_tBowed*) mpool_alloc(sizeof(_tBowed), m); + tBowed* x = *bw = (tBowed*) mpool_alloc(sizeof(tBowed), m); x->mempool = m; LEAF* leaf = x->mempool->leaf; @@ -2525,35 +2525,35 @@ void tBowed_initToPool (tBowed* const bw, int oversampling, tMempo tLinearDelay_initToPool(&x->neckDelay, 100.0f, 2400.0f, mp); tLinearDelay_initToPool(&x->bridgeDelay, 29.0f, 2400.0f, mp); - tLinearDelay_clear(x->neckDelay); - tLinearDelay_clear(x->bridgeDelay); + tLinearDelay_clear(&x->neckDelay); + tLinearDelay_clear(&x->bridgeDelay); tCookOnePole_initToPool(&x->reflFilt, mp); - tCookOnePole_setSampleRate(x->reflFilt, x->sampleRate); + tCookOnePole_setSampleRate(&x->reflFilt, x->sampleRate); - tCookOnePole_setPole(x->reflFilt, 0.6f - (0.1f * 22050.f / x->sampleRate)); - tCookOnePole_setGain(x->reflFilt, .95f); + tCookOnePole_setPole(&x->reflFilt, 0.6f - (0.1f * 22050.f / x->sampleRate)); + tCookOnePole_setGain(&x->reflFilt, .95f); tBowTable_initToPool(&x->bowTabl, mp); x->bowTabl->slope = 3.0f; tBowed_setFreq(x, x->x_fr); tSVF_initToPool(&x->lowpass, SVFTypeLowpass, 18000.0f, 0.6f, mp); - tSVF_setSampleRate(x->lowpass, x->sampleRate); - tSVF_setFreq(x->lowpass,16000.0f); + tSVF_setSampleRate(&x->lowpass, x->sampleRate); + tSVF_setFreq(&x->lowpass,16000.0f); x->betaRatio = 0.127236; x->fr_save = x->x_fr; } -void tBowed_free (tBowed* const bw) +void tBowed_free (tBowed** const bw) { - _tBowed* x = *bw; + tBowed* x = *bw; tLinearDelay_free(&x->neckDelay); tLinearDelay_free(&x->bridgeDelay); tCookOnePole_free(&x->reflFilt); mpool_free((char*)x, x->mempool); } -Lfloat tBowed_tick (tBowed const x) +Lfloat tBowed_tick (tBowed* const x) { float bp = x->x_bp; float bpos = x->x_bpos; @@ -2569,32 +2569,32 @@ Lfloat tBowed_tick (tBowed const x) if (bpos != x->betaRatio) { x->betaRatio = bpos; - tLinearDelay_setDelay(x->bridgeDelay, x->baseDelay * x->betaRatio); /* bow to bridge length */ - tLinearDelay_setDelay(x->neckDelay, x->baseDelay * (1. - x->betaRatio)); /* bow to nut (finger) length */ + tLinearDelay_setDelay(&x->bridgeDelay, x->baseDelay * x->betaRatio); /* bow to bridge length */ + tLinearDelay_setDelay(&x->neckDelay, x->baseDelay * (1. - x->betaRatio)); /* bow to nut (finger) length */ for (int i = 0; i < x->oversampling; i++) { - bridgeRefl = -tCookOnePole_tick(x->reflFilt, x->bridgeDelay->lastOut); /* Bridge Reflection */ + bridgeRefl = -tCookOnePole_tick(&x->reflFilt, x->bridgeDelay->lastOut); /* Bridge Reflection */ nutRefl = x->neckDelay->lastOut; /* Nut Reflection */ stringVel = bridgeRefl + nutRefl; /* Sum is String Velocity */ velDiff = bv - stringVel; /* Differential Velocity */ - newVel = velDiff * tBowTable_lookup(x->bowTabl, velDiff); /* Non-Lin Bow Function */ - tLinearDelay_tick(x->neckDelay, bridgeRefl + newVel); /* Do string */ - tLinearDelay_tick(x->bridgeDelay, nutRefl + newVel); /* propagations */ - x->output = tSVF_tick(x->lowpass, x->bridgeDelay->lastOut); + newVel = velDiff * tBowTable_lookup(&x->bowTabl, velDiff); /* Non-Lin Bow Function */ + tLinearDelay_tick(&x->neckDelay, bridgeRefl + newVel); /* Do string */ + tLinearDelay_tick(&x->bridgeDelay, nutRefl + newVel); /* propagations */ + x->output = tSVF_tick(&x->lowpass, x->bridgeDelay->lastOut); } return x->output; } } -void tBowed_setFreq (tBowed const x, Lfloat freq) +void tBowed_setFreq (tBowed* const x, Lfloat freq) { if (freq < 20.f) freq = 20.f; x->baseDelay = (x->sampleRate / freq) - 4.0; /* delay - approx. filter delay */ - tLinearDelay_setDelay(x->bridgeDelay, x->baseDelay * x->betaRatio); /* bow to bridge length */ - tLinearDelay_setDelay(x->neckDelay, x->baseDelay * (1. - x->betaRatio)); /* bow to nut (finger) length */ + tLinearDelay_setDelay(&x->bridgeDelay, x->baseDelay * x->betaRatio); /* bow to bridge length */ + tLinearDelay_setDelay(&x->neckDelay, x->baseDelay * (1. - x->betaRatio)); /* bow to nut (finger) length */ } @@ -2603,10 +2603,10 @@ void tTString_init (tTString* const b, int oversampling, Lfl { tTString_initToPool(b, oversampling, lowestFreq, &leaf->mempool); } -void tTString_initToPool (tTString* const bw, int oversampling, Lfloat lowestFreq, tMempool* const mp) +void tTString_initToPool (tTString** const bw, int oversampling, Lfloat lowestFreq, tMempool* const mp) { _tMempool* m = *mp; - _tTString* x = *bw = (_tTString*) mpool_alloc(sizeof(_tTString), m); + tTString* x = *bw = (tTString*) mpool_alloc(sizeof(tTString), m); x->mempool = m; LEAF* leaf = x->mempool->leaf; @@ -2638,21 +2638,21 @@ void tTString_initToPool (tTString* const bw, int oversampling, Lf x->barPulsePhasor = 0; Lfloat maxDelayTemp = x->sampleRate / lowestFreq; tLagrangeDelay_initToPool(&x->delay, 100.0f, maxDelayTemp, mp); - x->actualLowestFreq = x->sampleRate / tLagrangeDelay_getMaxDelay (x->delay); //adjusted to create a power-of-two size buffer + x->actualLowestFreq = x->sampleRate / tLagrangeDelay_getMaxDelay (&x->delay); //adjusted to create a power-of-two size buffer - tLagrangeDelay_clear(x->delay); + tLagrangeDelay_clear(&x->delay); tLagrangeDelay_initToPool(&x->delayP, 100.0f, maxDelayTemp, mp); - tLagrangeDelay_clear(x->delayP); + tLagrangeDelay_clear(&x->delayP); - x->maxDelay = tLagrangeDelay_getMaxDelay (x->delay); + x->maxDelay = tLagrangeDelay_getMaxDelay (&x->delay); tCookOnePole_initToPool(&x->reflFilt, mp); - tCookOnePole_setSampleRate(x->reflFilt, x->sampleRate); + tCookOnePole_setSampleRate(&x->reflFilt, x->sampleRate); tCookOnePole_initToPool(&x->reflFiltP, mp); - tCookOnePole_setSampleRate(x->reflFiltP, x->sampleRate); + tCookOnePole_setSampleRate(&x->reflFiltP, x->sampleRate); - tCookOnePole_setGainAndPole(x->reflFilt,0.999f, -0.0014f); - tCookOnePole_setGainAndPole(x->reflFiltP,0.999f, -0.0014f); + tCookOnePole_setGainAndPole(&x->reflFilt,0.999f, -0.0014f); + tCookOnePole_setGainAndPole(&x->reflFiltP,0.999f, -0.0014f); tTString_setFreq(x, 440.0f); @@ -2664,43 +2664,43 @@ void tTString_initToPool (tTString* const bw, int oversampling, Lf tExpSmooth_setDest(x->pickNoise, 0.0f); tThiranAllpassSOCascade_initToPool(&x->allpass, 4, mp); tThiranAllpassSOCascade_initToPool(&x->allpassP, 4, mp); - x->allpassDelay = tThiranAllpassSOCascade_setCoeff(x->allpass, 0.0001f, 100.0f, x->invOversampling); - x->allpassDelayP = tThiranAllpassSOCascade_setCoeff(x->allpassP, 0.000025f, 100.0f, x->invOversampling); + x->allpassDelay = tThiranAllpassSOCascade_setCoeff(&x->allpass, 0.0001f, 100.0f, x->invOversampling); + x->allpassDelayP = tThiranAllpassSOCascade_setCoeff(&x->allpassP, 0.000025f, 100.0f, x->invOversampling); tSVF_initToPool(&x->lowpassP, SVFTypeLowpass, 5000.0f, 0.8f, mp); - tSVF_setSampleRate(x->lowpassP, x->sampleRate); - tSVF_setFreq(x->lowpassP, 6000.0f); + tSVF_setSampleRate(&x->lowpassP, x->sampleRate); + tSVF_setFreq(&x->lowpassP, 6000.0f); tSVF_initToPool(&x->highpassP, SVFTypeHighpass, 1800.0f, 0.8f, mp); - tSVF_setSampleRate(x->highpassP, x->sampleRate); - tSVF_setFreq(x->highpassP, 1800.0f); + tSVF_setSampleRate(&x->highpassP, x->sampleRate); + tSVF_setFreq(&x->highpassP, 1800.0f); x->twoPiTimesInvSampleRate = TWO_PI * x->invSampleRate; tCycle_initToPool(&x->tensionModOsc, mp); - tCycle_setSampleRate(x->tensionModOsc, x->sampleRate); + tCycle_setSampleRate(&x->tensionModOsc, x->sampleRate); tCycle_initToPool(&x->pickupModOsc, mp); - tCycle_setSampleRate(x->pickupModOsc, x->sampleRate); + tCycle_setSampleRate(&x->pickupModOsc, x->sampleRate); x->pickupModOscFreq = 440.0f; x->pickupModOscAmp = 1.0f; tSVF_initToPool(&x->pickupFilter, SVFTypeLowpass, 2900.0f, 1.0f, mp); - tSVF_setSampleRate(x->pickupFilter, x->sampleRate); + tSVF_setSampleRate(&x->pickupFilter, x->sampleRate); - tSVF_setFreq(x->pickupFilter, 3900.0f); + tSVF_setFreq(&x->pickupFilter, 3900.0f); tSVF_initToPool(&x->pickupFilter2, SVFTypeLowpass, 3800.0f, 1.1f, mp); - tSVF_setSampleRate(x->pickupFilter2, x->sampleRate); + tSVF_setSampleRate(&x->pickupFilter2, x->sampleRate); - tSVF_setFreq(x->pickupFilter2, 4100.0f); + tSVF_setFreq(&x->pickupFilter2, 4100.0f); tSVF_initToPool(&x->peakFilt, SVFTypePeak, 1000.0f, .9f, mp); - tSVF_setSampleRate(x->peakFilt, x->sampleRate); + tSVF_setSampleRate(&x->peakFilt, x->sampleRate); - tSVF_setFreq(x->peakFilt, 1000.0f); + tSVF_setFreq(&x->peakFilt, 1000.0f); tNoise_initToPool(&x->noise, PinkNoise, mp); tHighpass_initToPool(&x->dcBlock, 1.0f, mp); - tHighpass_setSampleRate(x->dcBlock,x->sampleRate); + tHighpass_setSampleRate(&x->dcBlock,x->sampleRate); tHighpass_initToPool(&x->dcBlockP, 1.0f, mp); - tHighpass_setSampleRate(x->dcBlockP,x->sampleRate); + tHighpass_setSampleRate(&x->dcBlockP,x->sampleRate); tSlide_initToPool(&x->slide, 0, 3000, mp);//100 1400 if (x->wound) { @@ -2742,9 +2742,9 @@ void tTString_initToPool (tTString* const bw, int oversampling, Lf tPickupNonLinearity_initToPool(&x->p, mp); } -void tTString_free (tTString* const bw) +void tTString_free (tTString** const bw) { - _tTString* x = *bw; + tTString* x = *bw; tPickupNonLinearity_free(&x->p); tNoise_free(&x->pickNoiseSource); tFeedbackLeveler_free(&x->feedbackP); @@ -2780,10 +2780,10 @@ void tTString_free (tTString* const bw) mpool_free((char*)x, x->mempool); } -Lfloat tTString_tick (tTString const x) +Lfloat tTString_tick (tTString* const x) { Lfloat theOutput = 0.0f; - x->feedbackNoise = tNoise_tick(x->noise); + x->feedbackNoise = tNoise_tick(&x->noise); Lfloat barPos = x->barPosition; if ((barPos > (x->prevBarPosSmoothed + 3.0f)) || (barPos < (x->prevBarPosSmoothed - 3.0f))) @@ -2820,14 +2820,14 @@ Lfloat tTString_tick (tTString const x) x->prevBarPosSmoothed = barPosSmoothed; barDifference = LEAF_clip(0.0f, barDifference*2.0f, 1.0f); - x->slideAmount = tSlide_tick(x->slide, barDifference); + x->slideAmount = tSlide_tick(&x->slide, barDifference); if (x->wound) { if (bumpDifference > 1.0f) { tExpSmooth_setVal(x->barPulse, 1.0f); - tSlide_setDest(x->barPulseSlide, 1.0f); + tSlide_setDest(&x->barPulseSlide, 1.0f); x->lastBump = currentBump; x->timeSinceLastBump = x->sampleCount+1 / bumpDifference; @@ -2840,7 +2840,7 @@ Lfloat tTString_tick (tTString const x) x->bumpOsc = 0; } - tSlide_setDest(x->barSmooth, (x->sampleRate * x->invOversampling / x->timeSinceLastBump)); + tSlide_setDest(&x->barSmooth, (x->sampleRate * x->invOversampling / x->timeSinceLastBump)); x->sampleCount = 0; } else @@ -2853,7 +2853,7 @@ Lfloat tTString_tick (tTString const x) if (x->bumpCount > x->timeSinceLastBump) { tExpSmooth_setVal(x->barPulse, 1.0f); - tSlide_setDest(x->barPulseSlide, 1.0f); + tSlide_setDest(&x->barPulseSlide, 1.0f); x->bumpCount = 0; } x->bumpCount++; @@ -2866,19 +2866,19 @@ Lfloat tTString_tick (tTString const x) } else { - tSlide_setDest(x->barSmooth, 5.0f); + tSlide_setDest(&x->barSmooth, 5.0f); } - Lfloat barFreq = tSlide_tickNoInput(x->barSmooth); - tSVF_setFreq(x->barResonator, barFreq); + Lfloat barFreq = tSlide_tickNoInput(&x->barSmooth); + tSVF_setFreq(&x->barResonator, barFreq); Lfloat filterAmount = 0.5f; Lfloat dryAmount = 1.0f; x->slideNoise = x->feedbackNoise; - Lfloat pulseVal = tSlide_tickNoInput(x->barPulseSlide); + Lfloat pulseVal = tSlide_tickNoInput(&x->barPulseSlide); if (pulseVal > .99f) { - tSlide_setDest(x->barPulseSlide, 0.0f); + tSlide_setDest(&x->barPulseSlide, 0.0f); } @@ -2887,7 +2887,7 @@ Lfloat tTString_tick (tTString const x) x->slideNoise *= tExpSmooth_tick(x->barPulse); //x->slideNoise *= x->slideGain; Lfloat tempSlideNoise1 = x->slideNoise; - Lfloat tempSlideNoise2 = fast_tanh5(tSVF_tick(x->barResonator, tempSlideNoise1)*x->barDrive); + Lfloat tempSlideNoise2 = fast_tanh5(tSVF_tick(&x->barResonator, tempSlideNoise1)*x->barDrive); Lfloat filterFade = 1.0f; if (barFreq < 300.0f) @@ -2899,8 +2899,8 @@ Lfloat tTString_tick (tTString const x) x->slideNoise = ((tempSlideNoise1 * dryAmount) + (tempSlideNoise2 * filterAmount * filterFade));// * x->slideAmount; x->slideNoise *= x->muted; - x->slideNoise = tHighpass_tick(x->barHP, x->slideNoise); - x->slideNoise = tSVF_tick(x->barLP, x->slideNoise * x->slideGain * volCut); + x->slideNoise = tHighpass_tick(&x->barHP, x->slideNoise); + x->slideNoise = tSVF_tick(&x->barLP, x->slideNoise * x->slideGain * volCut); x->slideNoise = x->slideNoise * x->slideGain; } else @@ -2908,8 +2908,8 @@ Lfloat tTString_tick (tTString const x) //x->slideNoise = tNoise_tick(&x->pickNoiseSource)*0.3f; x->slideNoise = x->feedbackNoise; x->slideNoise *= x->muted; - x->slideNoise = tHighpass_tick(x->barHP, x->slideNoise); - x->slideNoise = tSVF_tick(x->barLP, x->slideNoise * x->slideGain * 0.5f * volCut); + x->slideNoise = tHighpass_tick(&x->barHP, x->slideNoise); + x->slideNoise = tSVF_tick(&x->barLP, x->slideNoise * x->slideGain * 0.5f * volCut); x->slideNoise = x->slideNoise * x->slideGain; } for (int i = 0; i < x->oversampling; i++) @@ -2938,16 +2938,16 @@ Lfloat tTString_tick (tTString const x) //tLagrangeDelay_setDelay(&x->delay, x->wavelength-2);//currentDelay - x->tensionAmount - (x->allpassDelay * x->inharmonicMult));// - ((x->phaseComp * INV_TWO_PI ) * currentDelay)); //tLagrangeDelay_setDelay(&x->delayP,x->wavelength-2);// currentDelay - x->tensionAmount - (x->allpassDelayP * x->inharmonicMult));// - ((x->phaseComp * INV_TWO_PI ) * currentDelay)); - tLagrangeDelay_setDelay(x->delay, currentDelay - x->tensionAmount - (x->allpassDelay * x->inharmonicMult) - ((x->phaseComp * INV_TWO_PI ) * currentDelay)); - tLagrangeDelay_setDelay(x->delayP,currentDelay - x->tensionAmount - (x->allpassDelayP * x->inharmonicMult) - ((x->phaseComp * INV_TWO_PI ) * currentDelay)); + tLagrangeDelay_setDelay(&x->delay, currentDelay - x->tensionAmount - (x->allpassDelay * x->inharmonicMult) - ((x->phaseComp * INV_TWO_PI ) * currentDelay)); + tLagrangeDelay_setDelay(&x->delayP,currentDelay - x->tensionAmount - (x->allpassDelayP * x->inharmonicMult) - ((x->phaseComp * INV_TWO_PI ) * currentDelay)); - Lfloat pickNoiseSound = tNoise_tick(x->pickNoiseSource) * tExpSmooth_tick(x->pickNoise); - tLagrangeDelay_addTo(x->delay,pickNoiseSound * 2.0f, (uint32_t)x->pluckPoint_forInput); - tLagrangeDelay_addTo(x->delayP,pickNoiseSound * 2.0f, (uint32_t)x->pluckPoint_forInput); + Lfloat pickNoiseSound = tNoise_tick(&x->pickNoiseSource) * tExpSmooth_tick(x->pickNoise); + tLagrangeDelay_addTo(&x->delay,pickNoiseSound * 2.0f, (uint32_t)x->pluckPoint_forInput); + tLagrangeDelay_addTo(&x->delayP,pickNoiseSound * 2.0f, (uint32_t)x->pluckPoint_forInput); - Lfloat filterOut = tCookOnePole_tick(x->reflFilt, x->output); - Lfloat filterOutP = tCookOnePole_tick(x->reflFiltP, x->outputP); + Lfloat filterOut = tCookOnePole_tick(&x->reflFilt, x->output); + Lfloat filterOutP = tCookOnePole_tick(&x->reflFiltP, x->outputP); //Lfloat filterOut = x->output; //Lfloat filterOutP = x->outputP; @@ -2963,10 +2963,10 @@ Lfloat tTString_tick (tTString const x) //Lfloat rippleOut = (tLagrangeDelay_tapOutInterpolated(&x->delay,rippleLengthInt,rippleLengthAlpha) * x->r); //delayOut -= (tLagrangeDelay_tapOutInterpolated(&x->delay,rippleLengthInt2,rippleLengthAlpha2) * x->r); - Lfloat delayOut = tLagrangeDelay_tickOut(x->delay); - Lfloat delayOutP = tLagrangeDelay_tickOut(x->delayP); - Lfloat rippleOut1 = (tLagrangeDelay_tapOutInterpolated(x->delay,rippleLengthInt,rippleLengthAlpha) * x->r); - Lfloat rippleOut1P = (tLagrangeDelay_tapOutInterpolated(x->delayP,rippleLengthInt,rippleLengthAlpha) * x->r); + Lfloat delayOut = tLagrangeDelay_tickOut(&x->delay); + Lfloat delayOutP = tLagrangeDelay_tickOut(&x->delayP); + Lfloat rippleOut1 = (tLagrangeDelay_tapOutInterpolated(&x->delay,rippleLengthInt,rippleLengthAlpha) * x->r); + Lfloat rippleOut1P = (tLagrangeDelay_tapOutInterpolated(&x->delayP,rippleLengthInt,rippleLengthAlpha) * x->r); //Lfloat rippleSampleP = (tLagrangeDelay_tapOutInterpolated(&x->delayP,rippleLengthInt,rippleLengthAlpha) * x->r); @@ -2985,8 +2985,8 @@ Lfloat tTString_tick (tTString const x) Lfloat allpassOutP = rippleOutP; if (x->inharmonic) { - allpassOut = tThiranAllpassSOCascade_tick(x->allpass, rippleOut); - allpassOutP = tThiranAllpassSOCascade_tick(x->allpassP, rippleOutP); + allpassOut = tThiranAllpassSOCascade_tick(&x->allpass, rippleOut); + allpassOutP = tThiranAllpassSOCascade_tick(&x->allpassP, rippleOutP); } @@ -2999,7 +2999,7 @@ Lfloat tTString_tick (tTString const x) Lfloat positionMin = (x->openStringLength * 0.104166666666667f); Lfloat positionMax = (x->openStringLength * 0.021666666666667f); - Lfloat pickupInput = x->pickupPos + (tCycle_tick(x->pickupModOsc) * x->pickupModOscAmp); + Lfloat pickupInput = x->pickupPos + (tCycle_tick(&x->pickupModOsc) * x->pickupModOscAmp); //Lfloat pickupInput = x->pickupPos; Lfloat pickupPos = LEAF_mapFromZeroToOneInput(pickupInput, positionMin, positionMax); @@ -3034,41 +3034,41 @@ Lfloat tTString_tick (tTString const x) Lfloat inversePickupPosAlpha = inversePickupPos - inversePickupPosInt; Lfloat oneMinusinversePickupPosAlpha = 1.0f - inversePickupPosAlpha; - Lfloat rightgoing = tLagrangeDelay_tapOut(x->delay, pickupPosInt) * oneMinusPickupPosAlpha; - rightgoing += tLagrangeDelay_tapOut(x->delay, pickupPosIntPlusOne) * pickupPosAlpha; - Lfloat leftgoing = tLagrangeDelay_tapOut(x->delay, inversePickupPosInt) * oneMinusinversePickupPosAlpha; - leftgoing += tLagrangeDelay_tapOut(x->delay, inversePickupPosIntPlusOne) * inversePickupPosAlpha; + Lfloat rightgoing = tLagrangeDelay_tapOut(&x->delay, pickupPosInt) * oneMinusPickupPosAlpha; + rightgoing += tLagrangeDelay_tapOut(&x->delay, pickupPosIntPlusOne) * pickupPosAlpha; + Lfloat leftgoing = tLagrangeDelay_tapOut(&x->delay, inversePickupPosInt) * oneMinusinversePickupPosAlpha; + leftgoing += tLagrangeDelay_tapOut(&x->delay, inversePickupPosIntPlusOne) * inversePickupPosAlpha; //x->pickupOut = (((volumes[1] * pickupNonLinearity(rightgoing)) + (volumes[0] * rightgoing)) - ((volumes[1] * pickupNonLinearity(leftgoing)) + (volumes[0] * leftgoing))); x->pickupOut = (pickupNonLinearity(rightgoing) - pickupNonLinearity(leftgoing)); - rightgoing = tLagrangeDelay_tapOut(x->delayP, pickupPosInt) * oneMinusPickupPosAlpha; - rightgoing += tLagrangeDelay_tapOut(x->delayP, pickupPosIntPlusOne) * pickupPosAlpha; - leftgoing = tLagrangeDelay_tapOut(x->delayP, inversePickupPosInt) * oneMinusinversePickupPosAlpha; - leftgoing += tLagrangeDelay_tapOut(x->delayP, inversePickupPosIntPlusOne) * inversePickupPosAlpha; + rightgoing = tLagrangeDelay_tapOut(&x->delayP, pickupPosInt) * oneMinusPickupPosAlpha; + rightgoing += tLagrangeDelay_tapOut(&x->delayP, pickupPosIntPlusOne) * pickupPosAlpha; + leftgoing = tLagrangeDelay_tapOut(&x->delayP, inversePickupPosInt) * oneMinusinversePickupPosAlpha; + leftgoing += tLagrangeDelay_tapOut(&x->delayP, inversePickupPosIntPlusOne) * inversePickupPosAlpha; x->pickupOutP = (pickupNonLinearity(rightgoing) - pickupNonLinearity(leftgoing)); - Lfloat inputSample = tFeedbackLeveler_tick(x->feedback, tHighpass_tick(x->dcBlock, filterOut + x->slideNoise + x->feedbackNoise * x->feedbackNoiseLevel)); - Lfloat inputSampleP = tFeedbackLeveler_tick(x->feedbackP, tHighpass_tick(x->dcBlockP, filterOutP + x->slideNoise + x->feedbackNoise * x->feedbackNoiseLevel)); - tLagrangeDelay_tickIn(x->delay, inputSample); - tLagrangeDelay_tickIn(x->delayP, inputSampleP); + Lfloat inputSample = tFeedbackLeveler_tick(&x->feedback, tHighpass_tick(&x->dcBlock, filterOut + x->slideNoise + x->feedbackNoise * x->feedbackNoiseLevel)); + Lfloat inputSampleP = tFeedbackLeveler_tick(&x->feedbackP, tHighpass_tick(&x->dcBlockP, filterOutP + x->slideNoise + x->feedbackNoise * x->feedbackNoiseLevel)); + tLagrangeDelay_tickIn(&x->delay, inputSample); + tLagrangeDelay_tickIn(&x->delayP, inputSampleP); //tLagrangeDelay_tickIn(&x->delayP, delayOutP + x->slideNoise); //Lfloat outputPfilt = 0.0f; - Lfloat outputPfilt = tSVF_tick(x->lowpassP, x->pickupOutP); - outputPfilt = tSVF_tick(x->highpassP, outputPfilt); + Lfloat outputPfilt = tSVF_tick(&x->lowpassP, x->pickupOutP); + outputPfilt = tSVF_tick(&x->highpassP, outputPfilt); Lfloat volumes[2]; LEAF_crossfade(x->pickupAmount * 2.0f - 1.0f,volumes); Lfloat prefilter = (x->pickupOut + (outputPfilt * x->phantomGain)) * 2.0f; - Lfloat prefilter2 = tSVF_tick(x->pickupFilter2, prefilter);// + x->slideNoise; - Lfloat prefilter3 = tSVF_tick(x->pickupFilter, prefilter2);// + x->slideNoise; - Lfloat prefilter4 = tSVF_tick(x->peakFilt, prefilter3);// + x->slideNoise; + Lfloat prefilter2 = tSVF_tick(&x->pickupFilter2, prefilter);// + x->slideNoise; + Lfloat prefilter3 = tSVF_tick(&x->pickupFilter, prefilter2);// + x->slideNoise; + Lfloat prefilter4 = tSVF_tick(&x->peakFilt, prefilter3);// + x->slideNoise; theOutput = (prefilter4 * 1.3f* volumes[1]) + (prefilter * 1.3f * volumes[0]); } return theOutput; } -void tTString_setFreq (tTString const x, Lfloat freq) +void tTString_setFreq (tTString* const x, Lfloat freq) { if (freq < x->actualLowestFreq) freq = x->actualLowestFreq; @@ -3091,7 +3091,7 @@ void tTString_setFreq (tTString const x, Lfloat freq) #endif } -void tTString_setDecay (tTString const x, Lfloat decay) +void tTString_setDecay (tTString* const x, Lfloat decay) { x->decayInSeconds = (decay * 20.0f) + 0.1f; if (x->decayInSeconds > 20.0f) @@ -3107,7 +3107,7 @@ void tTString_setDecay (tTString const x, Lfloat decay) } } -void tTString_setDecayInSeconds (tTString const x, Lfloat decay) +void tTString_setDecayInSeconds (tTString* const x, Lfloat decay) { x->decayInSeconds = decay; if (x->decayInSeconds > 20.0f) @@ -3123,31 +3123,31 @@ void tTString_setDecayInSeconds (tTString const x, Lfloat decay } } -void tTString_setPickupPos (tTString const x, Lfloat pos) +void tTString_setPickupPos (tTString* const x, Lfloat pos) { x->pickupPos = pos; } -void tTString_setPickupAmount (tTString const x, Lfloat amount) +void tTString_setPickupAmount (tTString* const x, Lfloat amount) { x->pickupAmount = amount; } -void tTString_setPickupModAmp (tTString const x, Lfloat amp) +void tTString_setPickupModAmp (tTString* const x, Lfloat amp) { x->pickupModOscAmp = amp; } -void tTString_setPickupModFreq (tTString const x, Lfloat freq) +void tTString_setPickupModFreq (tTString* const x, Lfloat freq) { x->pickupModOscFreq = freq; - tCycle_setFreq(x->pickupModOsc, freq); + tCycle_setFreq(&x->pickupModOsc, freq); } -void tTString_mute (tTString const x) +void tTString_mute (tTString* const x) { x->muteCoeff = fastExp3(-1.0f / (x->freq * 0.007f));; if (x->muteCoeff < 0.5f) @@ -3158,7 +3158,7 @@ void tTString_mute (tTString const x) } //0-1 -void tTString_setFilter (tTString const x, Lfloat filter) +void tTString_setFilter (tTString* const x, Lfloat filter) { //filter = ((filter * 18000.0f) + 20.0f)* x->twoPiTimesInvSampleRate; //Lfloat lowestNumOvertones = LEAF_map(x->freq, 20.0f, 3000.0f, 15.0f, 12.0f); @@ -3177,12 +3177,12 @@ void tTString_setFilter (tTString const x, Lfloat filter) //volatile Lfloat normalizedFreq = (overtone * x->freq) * x->twoPiTimesInvSampleRate; //filter = 1.0f - normalizedFreq; - tCookOnePole_setPole(x->reflFilt,filter); - tCookOnePole_setPole(x->reflFiltP,filter); + tCookOnePole_setPole(&x->reflFilt,filter); + tCookOnePole_setPole(&x->reflFiltP,filter); x->poleCoeff = filter; } -void tTString_setFilterFreqDirectly (tTString const x, Lfloat freq) +void tTString_setFilterFreqDirectly (tTString* const x, Lfloat freq) { Lfloat freqToUse = LEAF_clip(10.0f, freq, x->quarterSampleRate); x->filterFreq = freqToUse; @@ -3194,89 +3194,89 @@ void tTString_setFilterFreqDirectly (tTString const x, Lfloat fr //volatile Lfloat normalizedFreq = (overtone * x->freq) * x->twoPiTimesInvSampleRate; //filter = 1.0f - normalizedFreq; - tCookOnePole_setPole(x->reflFilt,freq); - tCookOnePole_setPole(x->reflFiltP,freq); + tCookOnePole_setPole(&x->reflFilt,freq); + tCookOnePole_setPole(&x->reflFiltP,freq); x->poleCoeff = freq; } -void tTString_setTensionGain (tTString const x, Lfloat tensionGain) +void tTString_setTensionGain (tTString* const x, Lfloat tensionGain) { x->tensionGain = tensionGain; } //0-1 -void tTString_setBarDrive (tTString const x, Lfloat drive) +void tTString_setBarDrive (tTString* const x, Lfloat drive) { x->barDrive = drive + 1.0f; } -void tTString_setBarPosition (tTString const x, Lfloat barPosition) +void tTString_setBarPosition (tTString* const x, Lfloat barPosition) { x->prevBarPosition = x->barPosition; x->barPosition = barPosition; } -void tTString_setOpenStringFrequency (tTString const x, Lfloat openStringFrequency) +void tTString_setOpenStringFrequency (tTString* const x, Lfloat openStringFrequency) { x->openStringLength = ((x->sampleRate / openStringFrequency) - 2.0f); } -void tTString_setPickupRatio (tTString const x, Lfloat ratio) +void tTString_setPickupRatio (tTString* const x, Lfloat ratio) { x->pickupRatio = ratio; } -void tTString_setPhantomHarmonicsGain (tTString const x, Lfloat gain) +void tTString_setPhantomHarmonicsGain (tTString* const x, Lfloat gain) { x->phantomGain = gain; } -void tTString_setSlideGain (tTString const x, Lfloat gain) +void tTString_setSlideGain (tTString* const x, Lfloat gain) { x->slideGain = gain; } -void tTString_setTensionSpeed (tTString const x, Lfloat tensionSpeed) +void tTString_setTensionSpeed (tTString* const x, Lfloat tensionSpeed) { tExpSmooth_setFactor(x->tensionSmoother, 0.00064f * x->invOversampling * (1.0f - tensionSpeed) + 0.00001f); //0.5 is good } -void tTString_setRippleDepth (tTString const x, Lfloat depth) +void tTString_setRippleDepth (tTString* const x, Lfloat depth) { x->r = fastExp3(-1.0f / (x->freq * (x->decayInSeconds * 0.005f + 0.0001f))) * depth * 0.5f; x->invOnePlusr = 1.0f / (1.0f + x->r); Lfloat highpassFreq = depth * 30.0f + 1.0f; - tHighpass_setFreq(x->dcBlock,highpassFreq); - tHighpass_setFreq(x->dcBlockP,highpassFreq); + tHighpass_setFreq(&x->dcBlock,highpassFreq); + tHighpass_setFreq(&x->dcBlockP,highpassFreq); } -void tTString_setHarmonic (tTString const x, Lfloat harmonic) +void tTString_setHarmonic (tTString* const x, Lfloat harmonic) { x->harmonic = harmonic; x->rippleRate = 1.0f / harmonic; } -void tTString_setFeedbackStrength (tTString const x, Lfloat strength) +void tTString_setFeedbackStrength (tTString* const x, Lfloat strength) { Lfloat strengthVal = 0.5f * strength; - tFeedbackLeveler_setStrength(x->feedback, strengthVal); - tFeedbackLeveler_setStrength(x->feedbackP, strengthVal); + tFeedbackLeveler_setStrength(&x->feedback, strengthVal); + tFeedbackLeveler_setStrength(&x->feedbackP, strengthVal); x->feedbackNoiseLevel = strength * 0.005f; } -void tTString_setFeedbackReactionSpeed (tTString const x, Lfloat speed) +void tTString_setFeedbackReactionSpeed (tTString* const x, Lfloat speed) { Lfloat speedVal = speed * 0.1f + 0.00001f; - tFeedbackLeveler_setFactor(x->feedback, speedVal); - tFeedbackLeveler_setFactor(x->feedbackP, speedVal); + tFeedbackLeveler_setFactor(&x->feedback, speedVal); + tFeedbackLeveler_setFactor(&x->feedbackP, speedVal); } -void tTString_pluck (tTString const x, Lfloat position, Lfloat amplitude) +void tTString_pluck (tTString* const x, Lfloat position, Lfloat amplitude) { x->muted = 1.0f; tExpSmooth_setVal(x->tensionSmoother, amplitude); - tFeedbackLeveler_setTargetLevel(x->feedback, amplitude * 0.25f); - tFeedbackLeveler_setTargetLevel(x->feedbackP, amplitude * 0.25f); + tFeedbackLeveler_setTargetLevel(&x->feedback, amplitude * 0.25f); + tFeedbackLeveler_setTargetLevel(&x->feedbackP, amplitude * 0.25f); tExpSmooth_setValAndDest(x->pitchSmoother, x->pitchSmoother->dest); x->baseDelay = x->pitchSmoother->dest; Lfloat currentDelay = x->baseDelay;// - x->allpassDelay; @@ -3292,7 +3292,7 @@ void tTString_pluck (tTString const x, Lfloat position, Lfloat uint32_t pluckPointInt = (uint32_t) pluckPoint; Lfloat invPluckPointInt = (1.0f / ((Lfloat)pluckPointInt+.001f)); volatile Lfloat invRemainder = 1.0f / ((halfCurrentDelay-pluckPoint)+.001f); - tLagrangeDelay_clear(x->delay); + tLagrangeDelay_clear(&x->delay); x->pluckRatio = pluckPoint / halfCurrentDelay; x->pluckPoint_forInput = pluckPoint; for (uint32_t i = 0; i < halfCurrentDelay; i++) @@ -3312,39 +3312,39 @@ void tTString_pluck (tTString const x, Lfloat position, Lfloat val = (1.0f - (((Lfloat)i-(Lfloat)pluckPointInt)*invRemainder)); } val = LEAF_tanh(val* 1.2f) * amplitude; - tLagrangeDelay_tapIn(x->delay, val, i); - tLagrangeDelay_tapIn(x->delay, -val, currentDelayInt-i); - tLagrangeDelay_tapIn(x->delayP, val, i); - tLagrangeDelay_tapIn(x->delayP, -val, currentDelayInt-i); + tLagrangeDelay_tapIn(&x->delay, val, i); + tLagrangeDelay_tapIn(&x->delay, -val, currentDelayInt-i); + tLagrangeDelay_tapIn(&x->delayP, val, i); + tLagrangeDelay_tapIn(&x->delayP, -val, currentDelayInt-i); } - tThiranAllpassSOCascade_clear(x->allpass); - tThiranAllpassSOCascade_clear(x->allpassP); + tThiranAllpassSOCascade_clear(&x->allpass); + tThiranAllpassSOCascade_clear(&x->allpassP); tExpSmooth_setVal(x->pickNoise, amplitude); } -void tTString_setWavelength (tTString const x, uint32_t waveLength) +void tTString_setWavelength (tTString* const x, uint32_t waveLength) { //tExpSmooth_setDest(&x->pitchSmoother,waveLength);; // in samples x->wavelength = waveLength; } -void tTString_setHarmonicity (tTString const x, Lfloat B, Lfloat freq) +void tTString_setHarmonicity (tTString* const x, Lfloat B, Lfloat freq) { - x->allpassDelay = tThiranAllpassSOCascade_setCoeff(x->allpass, B, freq * x->invOversampling, x->oversampling); - x->allpassDelayP = tThiranAllpassSOCascade_setCoeff(x->allpassP, B * 0.25f, freq * x->invOversampling, x->oversampling); + x->allpassDelay = tThiranAllpassSOCascade_setCoeff(&x->allpass, B, freq * x->invOversampling, x->oversampling); + x->allpassDelayP = tThiranAllpassSOCascade_setCoeff(&x->allpassP, B * 0.25f, freq * x->invOversampling, x->oversampling); } -void tTString_setInharmonic (tTString const x, uint32_t onOrOff) +void tTString_setInharmonic (tTString* const x, uint32_t onOrOff) { x->inharmonic = onOrOff; x->inharmonicMult = (Lfloat)onOrOff; } -void tTString_setWoundOrUnwound (tTString const x, uint32_t wound) +void tTString_setWoundOrUnwound (tTString* const x, uint32_t wound) { x->wound = wound; if (x->wound) @@ -3362,30 +3362,30 @@ void tTString_setWoundOrUnwound (tTString const x, uint32_t wound) } } -void tTString_setWindingsPerInch (tTString const x, uint32_t windings) +void tTString_setWindingsPerInch (tTString* const x, uint32_t windings) { x->windingsPerInch = windings; } -void tTString_setPickupFilterFreq (tTString const x, Lfloat cutoff) +void tTString_setPickupFilterFreq (tTString* const x, Lfloat cutoff) { - tSVF_setFreq(x->pickupFilter,cutoff); + tSVF_setFreq(&x->pickupFilter,cutoff); } -void tTString_setPickupFilterQ (tTString const x, Lfloat Q) +void tTString_setPickupFilterQ (tTString* const x, Lfloat Q) { - tSVF_setQ(x->pickupFilter,Q+0.5f); + tSVF_setQ(&x->pickupFilter,Q+0.5f); } -void tTString_setPeakFilterFreq (tTString const x, Lfloat cutoff) +void tTString_setPeakFilterFreq (tTString* const x, Lfloat cutoff) { - tSVF_setFreq(x->peakFilt,cutoff); + tSVF_setFreq(&x->peakFilt,cutoff); } -void tTString_setPeakFilterQ (tTString const x, Lfloat Q) +void tTString_setPeakFilterQ (tTString* const x, Lfloat Q) { - tSVF_setQ(x->peakFilt,Q+0.5f); + tSVF_setQ(&x->peakFilt,Q+0.5f); } @@ -3396,23 +3396,23 @@ void tBowTable_init (tBowTable* const bt, LEAF* const leaf) { tBowTable_initToPool(bt, &leaf->mempool); } -void tBowTable_initToPool (tBowTable* const bt, tMempool* const mp) +void tBowTable_initToPool (tBowTable** const bt, tMempool* const mp) { _tMempool* m = *mp; - _tBowTable* x = *bt = (_tBowTable*) mpool_alloc(sizeof(_tBowTable), m); + tBowTable* x = *bt = (tBowTable*) mpool_alloc(sizeof(tBowTable), m); x->mempool = m; x->offSet = 0.0f; x->slope = 0.1f; x->lastOutput = 0.0f; } -void tBowTable_free (tBowTable* const bt) +void tBowTable_free (tBowTable** const bt) { - _tBowTable* x = *bt; + tBowTable* x = *bt; mpool_free((char*)x, x->mempool); } -Lfloat tBowTable_lookup (tBowTable const x, Lfloat sample) +Lfloat tBowTable_lookup (tBowTable* const x, Lfloat sample) { Lfloat input; input = sample + x->offSet; /* add bias to sample */ @@ -3431,24 +3431,24 @@ void tReedTable_init (tReedTable* const pm, Lfloat offset, Lfloat slope, tReedTable_initToPool(pm, offset, slope, &leaf->mempool); } -void tReedTable_initToPool (tReedTable* const pm, Lfloat offset, Lfloat slope, tMempool* const mp) +void tReedTable_initToPool (tReedTable** const pm, Lfloat offset, Lfloat slope, tMempool* const mp) { _tMempool* m = *mp; - _tReedTable* p = *pm = (_tReedTable*) mpool_alloc(sizeof(_tReedTable), m); + tReedTable* p = *pm = (tReedTable*) mpool_alloc(sizeof(tReedTable), m); p->mempool = m; p->offset = offset; p->slope = slope; } -void tReedTable_free (tReedTable* const pm) +void tReedTable_free (tReedTable** const pm) { - _tReedTable* p = *pm; + tReedTable* p = *pm; mpool_free((char*)p, p->mempool); } -Lfloat tReedTable_tick (tReedTable const p, Lfloat input) +Lfloat tReedTable_tick (tReedTable* const p, Lfloat input) { // The input is differential pressure across the reed. Lfloat output = p->offset + (p->slope * input); @@ -3465,7 +3465,7 @@ Lfloat tReedTable_tick (tReedTable const p, Lfloat input) return output; } -Lfloat tReedTable_tanh_tick (tReedTable const p, Lfloat input) +Lfloat tReedTable_tanh_tick (tReedTable* const p, Lfloat input) { // The input is differential pressure across the reed. Lfloat output = p->offset + (p->slope * input); @@ -3475,12 +3475,12 @@ Lfloat tReedTable_tanh_tick (tReedTable const p, Lfloat input) return tanhf(output); } -void tReedTable_setOffset (tReedTable const p, Lfloat offset) +void tReedTable_setOffset (tReedTable* const p, Lfloat offset) { p->offset = offset; } -void tReedTable_setSlope (tReedTable const p, Lfloat slope) +void tReedTable_setSlope (tReedTable* const p, Lfloat slope) { p->slope = slope; } @@ -3492,10 +3492,10 @@ void tStiffString_init (tStiffString* const pm, int numModes, LEAF* cons tStiffString_initToPool(pm, numModes, &leaf->mempool); } -void tStiffString_initToPool (tStiffString* const pm, int numModes, tMempool* const mp) +void tStiffString_initToPool (tStiffString** const pm, int numModes, tMempool* const mp) { _tMempool* m = *mp; - _tStiffString* p = *pm = (_tStiffString*) mpool_alloc(sizeof(_tStiffString), m); + tStiffString* p = *pm = (tStiffString*) mpool_alloc(sizeof(tStiffString), m); p->mempool = m; // initialize variables @@ -3537,9 +3537,9 @@ void tStiffString_initToPool (tStiffString* const pm, int numModes, tMempoo -void tStiffString_free (tStiffString* const pm) +void tStiffString_free (tStiffString** const pm) { - _tStiffString* p = *pm; + tStiffString* p = *pm; for (int i = 0; i < p->numModes; ++i) { //tDampedOscillator_free(&p->osc[i]); @@ -3554,7 +3554,7 @@ void tStiffString_free (tStiffString* const pm) mpool_free((char *) p, p->mempool); } -void tStiffString_updateOscillators(tStiffString const p) +void tStiffString_updateOscillators(tStiffString* const p) { Lfloat kappa_sq = p->stiffness * p->stiffness; Lfloat compensation = 0.0f; @@ -3585,14 +3585,14 @@ void tStiffString_updateOscillators(tStiffString const p) Lfloat testFreq = (p->freqHz * w); Lfloat nyquistTest = (testFreq - p->nyquist) * p->nyquistScalingFactor; p->nyquistCoeff[i] = LEAF_clip(0.0f, nyquistTest, 1.0f); - tCycle_setFreq(p->osc[i], testFreq * compensation); + tCycle_setFreq(&p->osc[i], testFreq * compensation); //tDampedOscillator_setDecay(&p->osc[i],p->freqHz * sig); Lfloat val = p->freqHz * sig; Lfloat r = fastExp4(-val * p->twoPiTimesInvSampleRate); p->decayScalar[i] = r * r; } } -void tStiffString_updateOutputWeights(tStiffString const p) +void tStiffString_updateOutputWeights(tStiffString* const p) { Lfloat x0 = p->pickupPos * PI; Lfloat totalGain = 0.0f; @@ -3615,59 +3615,59 @@ void tStiffString_updateOutputWeights(tStiffString const p) p->gainComp = 1.0f / totalGain; } -Lfloat tStiffString_tick (tStiffString const p) +Lfloat tStiffString_tick (tStiffString* const p) { Lfloat sample = 0.0f; for (int i = 0; i < p->numModes; ++i) { //sample += tDampedOscillator_tick(&p->osc[i]) * p->amplitudes[i] * p->outputWeights[i]; - sample += tCycle_tick(p->osc[i]) * p->amplitudes[i] * p->outputWeights[i] * p->decayVal[i] * p->nyquistCoeff[i]; + sample += tCycle_tick(&p->osc[i]) * p->amplitudes[i] * p->outputWeights[i] * p->decayVal[i] * p->nyquistCoeff[i]; p->decayVal[i] *= p->decayScalar[i] * p->muteDecay; } return sample * p->amp * p->gainComp; } -void tStiffString_setStiffness(tStiffString const p, Lfloat newValue) +void tStiffString_setStiffness(tStiffString* const p, Lfloat newValue) { p->stiffness = LEAF_mapFromZeroToOneInput(newValue,0.00f, 0.2f); } -void tStiffString_setPickupPos(tStiffString const p, Lfloat newValue) +void tStiffString_setPickupPos(tStiffString* const p, Lfloat newValue) { p->pickupPos = LEAF_clip(0.01f, newValue, 0.99f); tStiffString_updateOutputWeights(p); } -void tStiffString_setPluckPos(tStiffString const p, Lfloat newValue) +void tStiffString_setPluckPos(tStiffString* const p, Lfloat newValue) { p->pluckPos = LEAF_clip(0.01f, newValue, 0.99f); tStiffString_updateOutputWeights(p); } -void tStiffString_setFreq(tStiffString const p, Lfloat newFreq) +void tStiffString_setFreq(tStiffString* const p, Lfloat newFreq) { p->freqHz = newFreq; tStiffString_updateOscillators(p); } -void tStiffString_setDecay(tStiffString const p, Lfloat decay) +void tStiffString_setDecay(tStiffString* const p, Lfloat decay) { p->decay = decay; tStiffString_updateOscillators(p); } -void tStiffString_setDecayHighFreq(tStiffString const p, Lfloat decayHF) +void tStiffString_setDecayHighFreq(tStiffString* const p, Lfloat decayHF) { p->decayHighFreq = decayHF; tStiffString_updateOscillators(p); } -void tStiffString_mute(tStiffString const p) +void tStiffString_mute(tStiffString* const p) { p->muteDecay = 0.99f; } -void tStiffString_pluck(tStiffString const p, Lfloat amp) +void tStiffString_pluck(tStiffString* const p, Lfloat amp) { Lfloat x0 = p->pluckPos * PI; p->muteDecay = 1.0f; @@ -3698,40 +3698,40 @@ void tStiffString_setSampleRate(tStiffString* const pm, Lfloat sr) p->twoPiTimesInvSampleRate = TWO_PI / sr; } -void tStiffString_setStiffnessNoUpdate(tStiffString const p, Lfloat newValue) +void tStiffString_setStiffnessNoUpdate(tStiffString* const p, Lfloat newValue) { p->stiffness = LEAF_mapFromZeroToOneInput(newValue,0.00f, 0.2f); } -void tStiffString_setPickupPosNoUpdate(tStiffString const p, Lfloat newValue) +void tStiffString_setPickupPosNoUpdate(tStiffString* const p, Lfloat newValue) { p->pickupPos = LEAF_clip(0.01f, newValue, 0.99f); } -void tStiffString_setPluckPosNoUpdate(tStiffString const p, Lfloat newValue) +void tStiffString_setPluckPosNoUpdate(tStiffString* const p, Lfloat newValue) { p->pluckPos = LEAF_clip(0.01f, newValue, 0.99f); } -void tStiffString_setFreqNoUpdate(tStiffString const p, Lfloat newFreq) +void tStiffString_setFreqNoUpdate(tStiffString* const p, Lfloat newFreq) { p->freqHz = newFreq; } -void tStiffString_setDecayNoUpdate(tStiffString const p, Lfloat decay) +void tStiffString_setDecayNoUpdate(tStiffString* const p, Lfloat decay) { p->decay = decay; } -void tStiffString_setDecayHighFreqNoUpdate(tStiffString const p, Lfloat decayHF) +void tStiffString_setDecayHighFreqNoUpdate(tStiffString* const p, Lfloat decayHF) { p->decayHighFreq = decayHF; } -void tStiffString_pluckNoUpdate(tStiffString const p, Lfloat amp) +void tStiffString_pluckNoUpdate(tStiffString* const p, Lfloat amp) { Lfloat x0 = p->pluckPos * 0.5f * PI; p->muteDecay = 1.0f; @@ -3760,10 +3760,10 @@ void tStereoRotation_init (tStereoRotation* const r, LEAF } -void tStereoRotation_initToPool (tStereoRotation* const rr, tMempool* const mp) +void tStereoRotation_initToPool (tStereoRotation** const rr, tMempool* const mp) { _tMempool *m = *mp; - _tStereoRotation *r = *rr = (_tStereoRotation *) mpool_alloc(sizeof(_tStereoRotation), m); + tStereoRotation *r = *rr = (tStereoRotation *) mpool_alloc(sizeof(tStereoRotation), m); r->mempool = m; LEAF *leaf = r->mempool->leaf; @@ -3784,27 +3784,27 @@ void tStereoRotation_initToPool (tStereoRotation* const r } -void tStereoRotation_tick (tStereoRotation const r, float* samples) +void tStereoRotation_tick (tStereoRotation* const r, float* samples) { float samplex = (samples[0] + r->vcaoutx); float sampley = (samples[1] + r->vcaouty); - samplex = tHighpass_tick(r->hip1, samplex * r->rotGain); - sampley = tHighpass_tick(r->hip2, sampley * r->rotGain); + samplex = tHighpass_tick(&r->hip1, samplex * r->rotGain); + sampley = tHighpass_tick(&r->hip2, sampley * r->rotGain); // float samplex = (input[0] + vcaoutx); // float sampley = (input[1] + vcaouty); float rotOutx = (samplex * cosf(r->angle)) - (sampley * sinf(r->angle)); float rotOuty = (samplex * sinf(r->angle)) + (sampley * cosf(r->angle)); - float delayoutx = tLagrangeDelay_tick(r->rotDelayx, tanhf(rotOutx)); - float delayouty = tLagrangeDelay_tick(r->rotDelayy,tanhf( rotOuty)); + float delayoutx = tLagrangeDelay_tick(&r->rotDelayx, tanhf(rotOutx)); + float delayouty = tLagrangeDelay_tick(&r->rotDelayy,tanhf( rotOuty)); - float filteroutx = tOnePole_tick(r->filtx, delayoutx); - float filterouty = tOnePole_tick(r->filty, delayouty); + float filteroutx = tOnePole_tick(&r->filtx, delayoutx); + float filterouty = tOnePole_tick(&r->filty, delayouty); r->vcaoutx = filteroutx * r->feedbackFactorx; r->vcaouty = filterouty * r->feedbackFactory; @@ -3813,33 +3813,33 @@ void tStereoRotation_tick (tStereoRotation const r, float* return; } -void tStereoRotation_tickIn (tStereoRotation const r, float* samples) +void tStereoRotation_tickIn (tStereoRotation* const r, float* samples) { float samplex = (samples[0] + r->vcaoutx); float sampley = (samples[1] + r->vcaouty); - samplex = tHighpass_tick(r->hip1, samplex * r->rotGain); - sampley = tHighpass_tick(r->hip2, sampley * r->rotGain); + samplex = tHighpass_tick(&r->hip1, samplex * r->rotGain); + sampley = tHighpass_tick(&r->hip2, sampley * r->rotGain); // float samplex = (input[0] + vcaoutx); // float sampley = (input[1] + vcaouty); float rotOutx = (samplex * cosf(r->angle)) - (sampley * sinf(r->angle)); float rotOuty = (samplex * sinf(r->angle)) + (sampley * cosf(r->angle)); - tLagrangeDelay_tickIn(r->rotDelayx, tanhf(rotOutx)); - tLagrangeDelay_tickIn(r->rotDelayy,tanhf( rotOuty)); + tLagrangeDelay_tickIn(&r->rotDelayx, tanhf(rotOutx)); + tLagrangeDelay_tickIn(&r->rotDelayy,tanhf( rotOuty)); return; } -void tStereoRotation_tickOut (tStereoRotation const r, float* samples) +void tStereoRotation_tickOut (tStereoRotation* const r, float* samples) { - float delayoutx = tLagrangeDelay_tickOut(r->rotDelayx); - float delayouty = tLagrangeDelay_tickOut(r->rotDelayy); + float delayoutx = tLagrangeDelay_tickOut(&r->rotDelayx); + float delayouty = tLagrangeDelay_tickOut(&r->rotDelayy); - float filteroutx = tOnePole_tick(r->filtx, delayoutx); - float filterouty = tOnePole_tick(r->filty, delayouty); + float filteroutx = tOnePole_tick(&r->filtx, delayoutx); + float filterouty = tOnePole_tick(&r->filty, delayouty); r->vcaoutx = filteroutx * r->feedbackFactorx; r->vcaouty = filterouty * r->feedbackFactory; @@ -3849,43 +3849,43 @@ void tStereoRotation_tickOut (tStereoRotation const r, flo } -void tStereoRotation_setAngle (tStereoRotation const r, float input) +void tStereoRotation_setAngle (tStereoRotation* const r, float input) { r->angle = input * TWO_PI; } -void tStereoRotation_setDelayX (tStereoRotation const r, float time) +void tStereoRotation_setDelayX (tStereoRotation* const r, float time) { - tLagrangeDelay_setDelay(r->rotDelayx, time); + tLagrangeDelay_setDelay(&r->rotDelayx, time); } -void tStereoRotation_setDelayY (tStereoRotation const r, float time) +void tStereoRotation_setDelayY (tStereoRotation* const r, float time) { - tLagrangeDelay_setDelay(r->rotDelayy, time); + tLagrangeDelay_setDelay(&r->rotDelayy, time); } -void tStereoRotation_setFeedbackX (tStereoRotation const r, float feedbackx) +void tStereoRotation_setFeedbackX (tStereoRotation* const r, float feedbackx) { r->feedbackFactorx = feedbackx; } -void tStereoRotation_setFeedbackY (tStereoRotation const r, float feedbacky) +void tStereoRotation_setFeedbackY (tStereoRotation* const r, float feedbacky) { r->feedbackFactory = feedbacky; } -void tStereoRotation_setFilterX (tStereoRotation const r, float freq) +void tStereoRotation_setFilterX (tStereoRotation* const r, float freq) { - tOnePole_setFreq(r->filtx, freq); + tOnePole_setFreq(&r->filtx, freq); } -void tStereoRotation_setFilterY (tStereoRotation const r, float freq) +void tStereoRotation_setFilterY (tStereoRotation* const r, float freq) { - tOnePole_setFreq(r->filty, freq); + tOnePole_setFreq(&r->filty, freq); } -void tStereoRotation_setGain (tStereoRotation const r, float gain) +void tStereoRotation_setGain (tStereoRotation* const r, float gain) { r->rotGain = gain; } \ No newline at end of file diff --git a/leaf/Src/leaf-reverb.c b/leaf/Src/leaf-reverb.c index 072e1b2..622b4eb 100644 --- a/leaf/Src/leaf-reverb.c +++ b/leaf/Src/leaf-reverb.c @@ -24,10 +24,10 @@ void tPRCReverb_init(tPRCReverb* const rev, Lfloat t60, LEAF* const leaf) tPRCReverb_initToPool(rev, t60, &leaf->mempool); } -void tPRCReverb_initToPool (tPRCReverb* const rev, Lfloat t60, tMempool* const mp) +void tPRCReverb_initToPool (tPRCReverb** const rev, Lfloat t60, tMempool* const mp) { _tMempool* m = *mp; - _tPRCReverb* r = *rev = (_tPRCReverb*) mpool_alloc(sizeof(_tPRCReverb), m); + tPRCReverb* r = *rev = (tPRCReverb*) mpool_alloc(sizeof(tPRCReverb), m); r->mempool = m; LEAF* leaf = r->mempool->leaf; @@ -64,9 +64,9 @@ void tPRCReverb_initToPool (tPRCReverb* const rev, Lfloat t60, tMempool* co r->mix = 0.5f; } -void tPRCReverb_free (tPRCReverb* const rev) +void tPRCReverb_free (tPRCReverb** const rev) { - _tPRCReverb* r = *rev; + tPRCReverb* r = *rev; tDelay_free(&r->allpassDelays[0]); tDelay_free(&r->allpassDelays[1]); @@ -74,49 +74,49 @@ void tPRCReverb_free (tPRCReverb* const rev) mpool_free((char*)r, r->mempool); } -void tPRCRevert_clear(tPRCReverb const r) +void tPRCRevert_clear(tPRCReverb* const r) { - tDelay_clear(r->allpassDelays[0]); - tDelay_clear(r->allpassDelays[1]); - tDelay_clear(r->combDelay); + tDelay_clear(&r->allpassDelays[0]); + tDelay_clear(&r->allpassDelays[1]); + tDelay_clear(&r->combDelay); } -void tPRCReverb_setT60(tPRCReverb const r, Lfloat t60) +void tPRCReverb_setT60(tPRCReverb* const r, Lfloat t60) { if ( t60 <= 0.0f ) t60 = 0.001f; r->t60 = t60; - r->combCoeff = powf(10.0f, (-3.0f * tDelay_getDelay(r->combDelay) * r->invSampleRate / t60 )); + r->combCoeff = powf(10.0f, (-3.0f * tDelay_getDelay(&r->combDelay) * r->invSampleRate / t60 )); } -void tPRCReverb_setMix(tPRCReverb const r, Lfloat mix) +void tPRCReverb_setMix(tPRCReverb* const r, Lfloat mix) { r->mix = mix; } -Lfloat tPRCReverb_tick(tPRCReverb const r, Lfloat input) +Lfloat tPRCReverb_tick(tPRCReverb* const r, Lfloat input) { Lfloat temp, temp0, temp1, temp2; Lfloat out; r->lastIn = input; - temp = tDelay_getLastOut(r->allpassDelays[0]); + temp = tDelay_getLastOut(&r->allpassDelays[0]); temp0 = r->allpassCoeff * temp; temp0 += input; - tDelay_tick(r->allpassDelays[0], temp0); - temp0 = -( r->allpassCoeff * temp0) + temp; + tDelay_tick(&r->allpassDelays[0], temp0); + temp0 = -(r->allpassCoeff * temp0) + temp; - temp = tDelay_getLastOut(r->allpassDelays[1]); + temp = tDelay_getLastOut(&r->allpassDelays[1]); temp1 = r->allpassCoeff * temp; temp1 += temp0; - tDelay_tick(r->allpassDelays[1], temp1); + tDelay_tick(&r->allpassDelays[1], temp1); temp1 = -(r->allpassCoeff * temp1) + temp; - temp2 = temp1 + ( r->combCoeff * tDelay_getLastOut(r->combDelay)); + temp2 = temp1 + ( r->combCoeff * tDelay_getLastOut(&r->combDelay)); - out = r->mix * tDelay_tick(r->combDelay, temp2); + out = r->mix * tDelay_tick(&r->combDelay, temp2); temp = (1.0f - r->mix) * input; @@ -127,7 +127,7 @@ Lfloat tPRCReverb_tick(tPRCReverb const r, Lfloat input) return out; } -void tPRCReverb_setSampleRate (tPRCReverb const r, Lfloat sr) +void tPRCReverb_setSampleRate (tPRCReverb* const r, Lfloat sr) { r->sampleRate = sr; r->invSampleRate = 1.0f/r->sampleRate; @@ -158,7 +158,7 @@ void tPRCReverb_setSampleRate (tPRCReverb const r, Lfloat sr) tDelay_initToPool(&r->allpassDelays[1], lengths[1], lengths[1] * 2, &r->mempool); tDelay_initToPool(&r->combDelay, lengths[2], lengths[2] * 2, &r->mempool); - r->combCoeff = powf(10.0f, (-3.0f * tDelay_getDelay(r->combDelay) * r->invSampleRate / r->t60 )); + r->combCoeff = powf(10.0f, (-3.0f * tDelay_getDelay(&r->combDelay) * r->invSampleRate / r->t60 )); } /* ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ NReverb ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ @@ -167,10 +167,10 @@ void tNReverb_init(tNReverb* const rev, Lfloat t60, LEAF* const leaf) tNReverb_initToPool(rev, t60, &leaf->mempool); } -void tNReverb_initToPool (tNReverb* const rev, Lfloat t60, tMempool* const mp) +void tNReverb_initToPool (tNReverb** const rev, Lfloat t60, tMempool* const mp) { _tMempool* m = *mp; - _tNReverb* r = *rev = (_tNReverb*) mpool_alloc(sizeof(_tNReverb), m); + tNReverb* r = *rev = (tNReverb*) mpool_alloc(sizeof(tNReverb), m); r->mempool = m; LEAF* leaf = r->mempool->leaf; @@ -197,14 +197,14 @@ void tNReverb_initToPool (tNReverb* const rev, Lfloat t60, tMempool* cons for ( i=0; i<6; i++ ) { tLinearDelay_initToPool(&r->combDelays[i], lengths[i], lengths[i] * 2, mp); - tLinearDelay_clear(r->combDelays[i]); + tLinearDelay_clear(&r->combDelays[i]); r->combCoeffs[i] = powf(10.0f, (-3.0f * (Lfloat)lengths[i] * r->invSampleRate / t60)); } for ( i=0; i<8; i++ ) { tLinearDelay_initToPool(&r->allpassDelays[i], lengths[i+6], lengths[i+6] * 2, mp); - tLinearDelay_clear(r->allpassDelays[i]); + tLinearDelay_clear(&r->allpassDelays[i]); } tNReverb_setT60(r, t60); @@ -212,9 +212,9 @@ void tNReverb_initToPool (tNReverb* const rev, Lfloat t60, tMempool* cons r->mix = 0.3f; } -void tNReverb_free (tNReverb* const rev) +void tNReverb_free (tNReverb** const rev) { - _tNReverb* r = *rev; + tNReverb* r = *rev; for (int i = 0; i < 6; i++) { @@ -229,34 +229,34 @@ void tNReverb_free (tNReverb* const rev) mpool_free((char*)r, r->mempool); } -void tNReverb_setT60(tNReverb const r, Lfloat t60) +void tNReverb_setT60(tNReverb* const r, Lfloat t60) { if (t60 <= 0.0f) t60 = 0.001f; r->t60 = t60; - for (int i=0; i<6; i++) r->combCoeffs[i] = powf(10.0f, (-3.0f * tLinearDelay_getDelay(r->combDelays[i]) * r->invSampleRate / t60 )); + for (int i=0; i<6; i++) r->combCoeffs[i] = powf(10.0f, (-3.0f * tLinearDelay_getDelay(&r->combDelays[i]) * r->invSampleRate / t60 )); } -void tNReverb_setMix(tNReverb const r, Lfloat mix) +void tNReverb_setMix(tNReverb* const r, Lfloat mix) { r->mix = mix; } -void tNReverb_clear (tNReverb const r) +void tNReverb_clear (tNReverb* const r) { for (int i = 0; i < 6; i++) { - tLinearDelay_clear(r->combDelays[i]); + tLinearDelay_clear(&r->combDelays[i]); } for (int i = 0; i < 8; i++) { - tLinearDelay_clear(r->allpassDelays[i]); + tLinearDelay_clear(&r->allpassDelays[i]); } } -Lfloat tNReverb_tick(tNReverb const r, Lfloat input) +Lfloat tNReverb_tick(tNReverb* const r, Lfloat input) { r->lastIn = input; @@ -266,32 +266,32 @@ Lfloat tNReverb_tick(tNReverb const r, Lfloat input) temp0 = 0.0; for ( i=0; i<6; i++ ) { - temp = input + (r->combCoeffs[i] * tLinearDelay_getLastOut(r->combDelays[i])); - temp0 += tLinearDelay_tick(r->combDelays[i],temp); + temp = input + (r->combCoeffs[i] * tLinearDelay_getLastOut(&r->combDelays[i])); + temp0 += tLinearDelay_tick(&r->combDelays[i],temp); } for ( i=0; i<3; i++ ) { - temp = tLinearDelay_getLastOut(r->allpassDelays[i]); + temp = tLinearDelay_getLastOut(&r->allpassDelays[i]); temp1 = r->allpassCoeff * temp; temp1 += temp0; - tLinearDelay_tick(r->allpassDelays[i], temp1); + tLinearDelay_tick(&r->allpassDelays[i], temp1); temp0 = -(r->allpassCoeff * temp1) + temp; } // One-pole lowpass filter. r->lowpassState = 0.7f * r->lowpassState + 0.3f * temp0; - temp = tLinearDelay_getLastOut(r->allpassDelays[3]); + temp = tLinearDelay_getLastOut(&r->allpassDelays[3]); temp1 = r->allpassCoeff * temp; temp1 += r->lowpassState; - tLinearDelay_tick(r->allpassDelays[3], temp1 ); + tLinearDelay_tick(&r->allpassDelays[3], temp1 ); temp1 = -(r->allpassCoeff * temp1) + temp; - temp = tLinearDelay_getLastOut(r->allpassDelays[4]); + temp = tLinearDelay_getLastOut(&r->allpassDelays[4]); temp2 = r->allpassCoeff * temp; temp2 += temp1; - tLinearDelay_tick(r->allpassDelays[4], temp2 ); + tLinearDelay_tick(&r->allpassDelays[4], temp2 ); out = -( r->allpassCoeff * temp2 ) + temp ; //the other channel in stereo version below @@ -312,7 +312,7 @@ Lfloat tNReverb_tick(tNReverb const r, Lfloat input) return out; } -void tNReverb_tickStereo(tNReverb const r, Lfloat input, Lfloat* output) +void tNReverb_tickStereo(tNReverb* const r, Lfloat input, Lfloat* output) { r->lastIn = input; @@ -322,47 +322,47 @@ void tNReverb_tickStereo(tNReverb const r, Lfloat input, Lfloat* output) temp0 = 0.0; for ( i=0; i<6; i++ ) { - temp = input + (r->combCoeffs[i] * tLinearDelay_getLastOut(r->combDelays[i])); - temp0 += tLinearDelay_tick(r->combDelays[i],temp); + temp = input + (r->combCoeffs[i] * tLinearDelay_getLastOut(&r->combDelays[i])); + temp0 += tLinearDelay_tick(&r->combDelays[i],temp); } for ( i=0; i<3; i++ ) { - temp = tLinearDelay_getLastOut(r->allpassDelays[i]); + temp = tLinearDelay_getLastOut(&r->allpassDelays[i]); temp1 = r->allpassCoeff * temp; temp1 += temp0; - tLinearDelay_tick(r->allpassDelays[i], temp1); + tLinearDelay_tick(&r->allpassDelays[i], temp1); temp0 = -(r->allpassCoeff * temp1) + temp; } // One-pole lowpass filter. r->lowpassState = 0.7f * r->lowpassState + 0.3f * temp0; - temp = tLinearDelay_getLastOut(r->allpassDelays[3]); + temp = tLinearDelay_getLastOut(&r->allpassDelays[3]); temp1 = r->allpassCoeff * temp; temp1 += r->lowpassState; - tLinearDelay_tick(r->allpassDelays[3], temp1 ); + tLinearDelay_tick(&r->allpassDelays[3], temp1 ); temp1 = -(r->allpassCoeff * temp1) + temp; Lfloat drymix = ( 1.0f - r->mix ) * input; - temp = tLinearDelay_getLastOut(r->allpassDelays[4]); + temp = tLinearDelay_getLastOut(&r->allpassDelays[4]); temp2 = r->allpassCoeff * temp; temp2 += temp1; - tLinearDelay_tick(r->allpassDelays[4], temp2 ); + tLinearDelay_tick(&r->allpassDelays[4], temp2 ); output[0] = -( r->allpassCoeff * temp2 ) + temp + drymix; out = output[0]; - temp = tLinearDelay_getLastOut(r->allpassDelays[5]); + temp = tLinearDelay_getLastOut(&r->allpassDelays[5]); temp3 = r->allpassCoeff * temp; temp3 += temp1; - tLinearDelay_tick(r->allpassDelays[5], temp3 ); + tLinearDelay_tick(&r->allpassDelays[5], temp3 ); output[1] = r->mix *( - ( r->allpassCoeff * temp3 ) + temp + drymix); r->lastOut = out; } -void tNReverb_setSampleRate (tNReverb const r, Lfloat sr) +void tNReverb_setSampleRate (tNReverb* const r, Lfloat sr) { r->sampleRate = sr; r->invSampleRate = 1.0f/r->sampleRate; @@ -386,7 +386,7 @@ void tNReverb_setSampleRate (tNReverb const r, Lfloat sr) { tLinearDelay_free(&r->combDelays[i]); tLinearDelay_initToPool(&r->combDelays[i], lengths[i], lengths[i] * 2, &r->mempool); - tLinearDelay_clear(r->combDelays[i]); + tLinearDelay_clear(&r->combDelays[i]); r->combCoeffs[i] = powf(10.0f, (-3.0f * (Lfloat)lengths[i] * r->invSampleRate / r->t60)); } @@ -394,7 +394,7 @@ void tNReverb_setSampleRate (tNReverb const r, Lfloat sr) { tLinearDelay_free(&r->allpassDelays[i]); tLinearDelay_initToPool(&r->allpassDelays[i], lengths[i+6], lengths[i+6] * 2, &r->mempool); - tLinearDelay_clear(r->allpassDelays[i]); + tLinearDelay_clear(&r->allpassDelays[i]); } tNReverb_setT60(r, r->t60); @@ -412,10 +412,10 @@ void tDattorroReverb_init (tDattorroReverb* const rev, LEAF* con tDattorroReverb_initToPool(rev, &leaf->mempool); } -void tDattorroReverb_initToPool (tDattorroReverb* const rev, tMempool* const mp) +void tDattorroReverb_initToPool (tDattorroReverb** const rev, tMempool* const mp) { _tMempool* m = *mp; - _tDattorroReverb* r = *rev = (_tDattorroReverb*) mpool_alloc(sizeof(_tDattorroReverb), m); + tDattorroReverb* r = *rev = (tDattorroReverb*) mpool_alloc(sizeof(tDattorroReverb), m); r->mempool = m; LEAF* leaf = r->mempool->leaf; @@ -432,12 +432,12 @@ void tDattorroReverb_initToPool (tDattorroReverb* const rev, tMempool* for (int i = 0; i < 4; i++) { tAllpass_initToPool(&r->in_allpass[i], SAMP(in_allpass_delays[i]), SAMP(20.f), mp); // * r->size_max - tAllpass_setGain(r->in_allpass[i], in_allpass_gains[i]); + tAllpass_setGain(&r->in_allpass[i], in_allpass_gains[i]); } // FEEDBACK 1 tAllpass_initToPool(&r->f1_allpass, SAMP(30.51f), SAMP(100.f), mp); // * r->size_max - tAllpass_setGain(r->f1_allpass, 0.7f); + tAllpass_setGain(&r->f1_allpass, 0.7f); tTapeDelay_initToPool(&r->f1_delay_1, SAMP(141.69f), SAMP(200.0f) * r->size_max + 1, mp); tTapeDelay_initToPool(&r->f1_delay_2, SAMP(89.24f), SAMP(100.0f) * r->size_max + 1, mp); @@ -448,11 +448,11 @@ void tDattorroReverb_initToPool (tDattorroReverb* const rev, tMempool* tHighpass_initToPool(&r->f1_hp, 20.f, mp); tCycle_initToPool(&r->f1_lfo, mp); - tCycle_setFreq(r->f1_lfo, 0.1f); + tCycle_setFreq(&r->f1_lfo, 0.1f); // FEEDBACK 2 tAllpass_initToPool(&r->f2_allpass, SAMP(22.58f), SAMP(100.f), mp); // * r->size_max - tAllpass_setGain(r->f2_allpass, 0.7f); + tAllpass_setGain(&r->f2_allpass, 0.7f); tTapeDelay_initToPool(&r->f2_delay_1, SAMP(149.62f), SAMP(200.f) * r->size_max + 1, mp); tTapeDelay_initToPool(&r->f2_delay_2, SAMP(60.48f), SAMP(100.f) * r->size_max + 1, mp); @@ -463,7 +463,7 @@ void tDattorroReverb_initToPool (tDattorroReverb* const rev, tMempool* tHighpass_initToPool(&r->f2_hp, 20.f, mp); tCycle_initToPool(&r->f2_lfo, mp); - tCycle_setFreq(r->f2_lfo, 0.07f); + tCycle_setFreq(&r->f2_lfo, 0.07f); // PARAMETERS tDattorroReverb_setMix(*rev, 0.5f); @@ -473,9 +473,9 @@ void tDattorroReverb_initToPool (tDattorroReverb* const rev, tMempool* tDattorroReverb_setFeedbackGain(*rev, 0.4f); } -void tDattorroReverb_free (tDattorroReverb* const rev) +void tDattorroReverb_free (tDattorroReverb** const rev) { - _tDattorroReverb* r = *rev; + tDattorroReverb* r = *rev; // INPUT tTapeDelay_free(&r->in_delay); @@ -515,18 +515,18 @@ void tDattorroReverb_free (tDattorroReverb* const rev) mpool_free((char*)r, r->mempool); } -void tDattorroReverb_clear (tDattorroReverb const r) +void tDattorroReverb_clear (tDattorroReverb* const r) { - tTapeDelay_clear(r->in_delay); - tTapeDelay_clear(r->f1_delay_1); - tTapeDelay_clear(r->f1_delay_2); - tTapeDelay_clear(r->f1_delay_3); - tTapeDelay_clear(r->f2_delay_1); - tTapeDelay_clear(r->f2_delay_2); - tTapeDelay_clear(r->f2_delay_3); + tTapeDelay_clear(&r->in_delay); + tTapeDelay_clear(&r->f1_delay_1); + tTapeDelay_clear(&r->f1_delay_2); + tTapeDelay_clear(&r->f1_delay_3); + tTapeDelay_clear(&r->f2_delay_1); + tTapeDelay_clear(&r->f2_delay_2); + tTapeDelay_clear(&r->f2_delay_3); } -Lfloat tDattorroReverb_tick (tDattorroReverb const r, Lfloat input) +Lfloat tDattorroReverb_tick (tDattorroReverb* const r, Lfloat input) { Lfloat in_sample, f1_sample,f1_delay_2_sample, f2_sample, f2_delay_2_sample; @@ -537,94 +537,94 @@ Lfloat tDattorroReverb_tick (tDattorroReverb const r, Lfloat inpu //r->f2_last = 0.0f; } // INPUT - in_sample = tTapeDelay_tick(r->in_delay, input); + in_sample = tTapeDelay_tick(&r->in_delay, input); - in_sample = tOnePole_tick(r->in_filter, in_sample); + in_sample = tOnePole_tick(&r->in_filter, in_sample); for (int i = 0; i < 4; i++) { - in_sample = tAllpass_tick(r->in_allpass[i], in_sample); + in_sample = tAllpass_tick(&r->in_allpass[i], in_sample); } // FEEDBACK 1 f1_sample = in_sample + r->f2_last; // + f2_last_out; - tAllpass_setDelay(r->f1_allpass, SAMP(30.51f) + tCycle_tick(r->f1_lfo) * SAMP(4.0f)); + tAllpass_setDelay(&r->f1_allpass, SAMP(30.51f) + tCycle_tick(&r->f1_lfo) * SAMP(4.0f)); - f1_sample = tAllpass_tick(r->f1_allpass, f1_sample); + f1_sample = tAllpass_tick(&r->f1_allpass, f1_sample); - f1_sample = tTapeDelay_tick(r->f1_delay_1, f1_sample); + f1_sample = tTapeDelay_tick(&r->f1_delay_1, f1_sample); - f1_sample = tOnePole_tick(r->f1_filter, f1_sample); + f1_sample = tOnePole_tick(&r->f1_filter, f1_sample); f1_sample = f1_sample + r->f1_delay_2_last * 0.5f; - f1_delay_2_sample = tTapeDelay_tick(r->f1_delay_2, f1_sample * 0.5f); + f1_delay_2_sample = tTapeDelay_tick(&r->f1_delay_2, f1_sample * 0.5f); r->f1_delay_2_last = f1_delay_2_sample; f1_sample = r->f1_delay_2_last + f1_sample; - f1_sample = tHighpass_tick(r->f1_hp, f1_sample); + f1_sample = tHighpass_tick(&r->f1_hp, f1_sample); f1_sample *= r->feedback_gain; - r->f1_last = tTapeDelay_tick(r->f1_delay_3, f1_sample); + r->f1_last = tTapeDelay_tick(&r->f1_delay_3, f1_sample); // FEEDBACK 2 f2_sample = in_sample + r->f1_last; - tAllpass_setDelay(r->f2_allpass, SAMP(22.58f) + tCycle_tick(r->f2_lfo) * SAMP(4.0f)); + tAllpass_setDelay(&r->f2_allpass, SAMP(22.58f) + tCycle_tick(&r->f2_lfo) * SAMP(4.0f)); - f2_sample = tAllpass_tick(r->f2_allpass, f2_sample); + f2_sample = tAllpass_tick(&r->f2_allpass, f2_sample); - f2_sample = tTapeDelay_tick(r->f2_delay_1, f2_sample); + f2_sample = tTapeDelay_tick(&r->f2_delay_1, f2_sample); - f2_sample = tOnePole_tick(r->f2_filter, f2_sample); + f2_sample = tOnePole_tick(&r->f2_filter, f2_sample); f2_sample = f2_sample + r->f2_delay_2_last * 0.5f; - f2_delay_2_sample = tTapeDelay_tick(r->f2_delay_2, f2_sample * 0.5f); + f2_delay_2_sample = tTapeDelay_tick(&r->f2_delay_2, f2_sample * 0.5f); r->f2_delay_2_last = f2_delay_2_sample; f2_sample = r->f2_delay_2_last + f2_sample; - f2_sample = tHighpass_tick(r->f2_hp, f2_sample); + f2_sample = tHighpass_tick(&r->f2_hp, f2_sample); f2_sample *= r->feedback_gain; - r->f2_last = tTapeDelay_tick(r->f2_delay_3, f2_sample); + r->f2_last = tTapeDelay_tick(&r->f2_delay_3, f2_sample); // TAP OUT 1 - f1_sample = tTapeDelay_tapOut(r->f1_delay_1, SAMP(8.9f)) + - tTapeDelay_tapOut(r->f1_delay_1, SAMP(99.8f)); + f1_sample = tTapeDelay_tapOut(&r->f1_delay_1, SAMP(8.9f)) + + tTapeDelay_tapOut(&r->f1_delay_1, SAMP(99.8f)); - f1_sample -= tTapeDelay_tapOut(r->f1_delay_2, SAMP(64.2f)); + f1_sample -= tTapeDelay_tapOut(&r->f1_delay_2, SAMP(64.2f)); - f1_sample += tTapeDelay_tapOut(r->f1_delay_3, SAMP(67.f)); + f1_sample += tTapeDelay_tapOut(&r->f1_delay_3, SAMP(67.f)); - f1_sample -= tTapeDelay_tapOut(r->f2_delay_1, SAMP(66.8f)); + f1_sample -= tTapeDelay_tapOut(&r->f2_delay_1, SAMP(66.8f)); - f1_sample -= tTapeDelay_tapOut(r->f2_delay_2, SAMP(6.3f)); + f1_sample -= tTapeDelay_tapOut(&r->f2_delay_2, SAMP(6.3f)); - f1_sample -= tTapeDelay_tapOut(r->f2_delay_3, SAMP(35.8f)); + f1_sample -= tTapeDelay_tapOut(&r->f2_delay_3, SAMP(35.8f)); f1_sample *= 0.14f; // TAP OUT 2 - f2_sample = tTapeDelay_tapOut(r->f2_delay_1, SAMP(11.8f)) + - tTapeDelay_tapOut(r->f2_delay_1, SAMP(121.7f)); + f2_sample = tTapeDelay_tapOut(&r->f2_delay_1, SAMP(11.8f)) + + tTapeDelay_tapOut(&r->f2_delay_1, SAMP(121.7f)); - f2_sample -= tTapeDelay_tapOut(r->f2_delay_2, SAMP(6.3f)); + f2_sample -= tTapeDelay_tapOut(&r->f2_delay_2, SAMP(6.3f)); - f2_sample += tTapeDelay_tapOut(r->f2_delay_3, SAMP(89.7f)); + f2_sample += tTapeDelay_tapOut(&r->f2_delay_3, SAMP(89.7f)); - f2_sample -= tTapeDelay_tapOut(r->f1_delay_1, SAMP(70.8f)); + f2_sample -= tTapeDelay_tapOut(&r->f1_delay_1, SAMP(70.8f)); - f2_sample -= tTapeDelay_tapOut(r->f1_delay_2, SAMP(11.2f)); + f2_sample -= tTapeDelay_tapOut(&r->f1_delay_2, SAMP(11.2f)); - f2_sample -= tTapeDelay_tapOut(r->f1_delay_3, SAMP(4.1f)); + f2_sample -= tTapeDelay_tapOut(&r->f1_delay_3, SAMP(4.1f)); f2_sample *= 0.14f; @@ -633,7 +633,7 @@ Lfloat tDattorroReverb_tick (tDattorroReverb const r, Lfloat inpu return (input * (1.0f - r->mix) + sample * r->mix); } -void tDattorroReverb_tickStereo (tDattorroReverb const r, Lfloat input, Lfloat* output) +void tDattorroReverb_tickStereo (tDattorroReverb* const r, Lfloat input, Lfloat* output) { Lfloat in_sample, f1_sample,f1_delay_2_sample, f2_sample, f2_delay_2_sample; @@ -644,35 +644,35 @@ void tDattorroReverb_tickStereo (tDattorroReverb const r, Lfloat //r->f2_last = 0.0f; } // INPUT - in_sample = tTapeDelay_tick(r->in_delay, input); + in_sample = tTapeDelay_tick(&r->in_delay, input); - in_sample = tOnePole_tick(r->in_filter, in_sample); + in_sample = tOnePole_tick(&r->in_filter, in_sample); for (int i = 0; i < 4; i++) { - in_sample = tAllpass_tick(r->in_allpass[i], in_sample); + in_sample = tAllpass_tick(&r->in_allpass[i], in_sample); } // FEEDBACK 1 f1_sample = in_sample + r->f2_last; // + f2_last_out; - tAllpass_setDelay(r->f1_allpass, SAMP(30.51f) + tCycle_tick(r->f1_lfo) * SAMP(4.0f)); + tAllpass_setDelay(&r->f1_allpass, SAMP(30.51f) + tCycle_tick(&r->f1_lfo) * SAMP(4.0f)); - f1_sample = tAllpass_tick(r->f1_allpass, f1_sample); + f1_sample = tAllpass_tick(&r->f1_allpass, f1_sample); - f1_sample = tTapeDelay_tick(r->f1_delay_1, f1_sample); + f1_sample = tTapeDelay_tick(&r->f1_delay_1, f1_sample); - f1_sample = tOnePole_tick(r->f1_filter, f1_sample); + f1_sample = tOnePole_tick(&r->f1_filter, f1_sample); f1_sample = f1_sample + r->f1_delay_2_last * 0.5f; - f1_delay_2_sample = tTapeDelay_tick(r->f1_delay_2, f1_sample * 0.5f); + f1_delay_2_sample = tTapeDelay_tick(&r->f1_delay_2, f1_sample * 0.5f); r->f1_delay_2_last = f1_delay_2_sample; f1_sample = r->f1_delay_2_last + f1_sample; - f1_sample = tHighpass_tick(r->f1_hp, f1_sample); + f1_sample = tHighpass_tick(&r->f1_hp, f1_sample); f1_sample *= r->feedback_gain; @@ -681,28 +681,28 @@ void tDattorroReverb_tickStereo (tDattorroReverb const r, Lfloat f1_sample = 0.0f; } - r->f1_last = tTapeDelay_tick(r->f1_delay_3, f1_sample); + r->f1_last = tTapeDelay_tick(&r->f1_delay_3, f1_sample); // FEEDBACK 2 f2_sample = in_sample + r->f1_last; - tAllpass_setDelay(r->f2_allpass, SAMP(22.58f) + tCycle_tick(r->f2_lfo) * SAMP(4.0f)); + tAllpass_setDelay(&r->f2_allpass, SAMP(22.58f) + tCycle_tick(&r->f2_lfo) * SAMP(4.0f)); - f2_sample = tAllpass_tick(r->f2_allpass, f2_sample); + f2_sample = tAllpass_tick(&r->f2_allpass, f2_sample); - f2_sample = tTapeDelay_tick(r->f2_delay_1, f2_sample); + f2_sample = tTapeDelay_tick(&r->f2_delay_1, f2_sample); - f2_sample = tOnePole_tick(r->f2_filter, f2_sample); + f2_sample = tOnePole_tick(&r->f2_filter, f2_sample); f2_sample = f2_sample + r->f2_delay_2_last * 0.5f; - f2_delay_2_sample = tTapeDelay_tick(r->f2_delay_2, f2_sample * 0.5f); + f2_delay_2_sample = tTapeDelay_tick(&r->f2_delay_2, f2_sample * 0.5f); r->f2_delay_2_last = f2_delay_2_sample; f2_sample = r->f2_delay_2_last + f2_sample; - f2_sample = tHighpass_tick(r->f2_hp, f2_sample); + f2_sample = tHighpass_tick(&r->f2_hp, f2_sample); f2_sample *= r->feedback_gain; @@ -710,39 +710,39 @@ void tDattorroReverb_tickStereo (tDattorroReverb const r, Lfloat { f2_sample = 0.0f; } - r->f2_last = tTapeDelay_tick(r->f2_delay_3, f2_sample); + r->f2_last = tTapeDelay_tick(&r->f2_delay_3, f2_sample); // TAP OUT 1 - f1_sample = tTapeDelay_tapOut(r->f1_delay_1, SAMP(8.9f)) + - tTapeDelay_tapOut(r->f1_delay_1, SAMP(99.8f)); + f1_sample = tTapeDelay_tapOut(&r->f1_delay_1, SAMP(8.9f)) + + tTapeDelay_tapOut(&r->f1_delay_1, SAMP(99.8f)); - f1_sample -= tTapeDelay_tapOut(r->f1_delay_2, SAMP(64.2f)); + f1_sample -= tTapeDelay_tapOut(&r->f1_delay_2, SAMP(64.2f)); - f1_sample += tTapeDelay_tapOut(r->f1_delay_3, SAMP(67.f)); + f1_sample += tTapeDelay_tapOut(&r->f1_delay_3, SAMP(67.f)); - f1_sample -= tTapeDelay_tapOut(r->f2_delay_1, SAMP(66.8f)); + f1_sample -= tTapeDelay_tapOut(&r->f2_delay_1, SAMP(66.8f)); - f1_sample -= tTapeDelay_tapOut(r->f2_delay_2, SAMP(6.3f)); + f1_sample -= tTapeDelay_tapOut(&r->f2_delay_2, SAMP(6.3f)); - f1_sample -= tTapeDelay_tapOut(r->f2_delay_3, SAMP(35.8f)); + f1_sample -= tTapeDelay_tapOut(&r->f2_delay_3, SAMP(35.8f)); f1_sample *= 0.14f; // TAP OUT 2 - f2_sample = tTapeDelay_tapOut(r->f2_delay_1, SAMP(11.8f)) + - tTapeDelay_tapOut(r->f2_delay_1, SAMP(121.7f)); + f2_sample = tTapeDelay_tapOut(&r->f2_delay_1, SAMP(11.8f)) + + tTapeDelay_tapOut(&r->f2_delay_1, SAMP(121.7f)); - f2_sample -= tTapeDelay_tapOut(r->f2_delay_2, SAMP(6.3f)); + f2_sample -= tTapeDelay_tapOut(&r->f2_delay_2, SAMP(6.3f)); - f2_sample += tTapeDelay_tapOut(r->f2_delay_3, SAMP(89.7f)); + f2_sample += tTapeDelay_tapOut(&r->f2_delay_3, SAMP(89.7f)); - f2_sample -= tTapeDelay_tapOut(r->f1_delay_1, SAMP(70.8f)); + f2_sample -= tTapeDelay_tapOut(&r->f1_delay_1, SAMP(70.8f)); - f2_sample -= tTapeDelay_tapOut(r->f1_delay_2, SAMP(11.2f)); + f2_sample -= tTapeDelay_tapOut(&r->f1_delay_2, SAMP(11.2f)); - f2_sample -= tTapeDelay_tapOut(r->f1_delay_3, SAMP(4.1f)); + f2_sample -= tTapeDelay_tapOut(&r->f1_delay_3, SAMP(4.1f)); f2_sample *= 0.14f; @@ -751,49 +751,49 @@ void tDattorroReverb_tickStereo (tDattorroReverb const r, Lfloat } -void tDattorroReverb_setMix (tDattorroReverb const r, Lfloat mix) +void tDattorroReverb_setMix (tDattorroReverb* const r, Lfloat mix) { r->mix = LEAF_clip(0.0f, mix, 1.0f); } -void tDattorroReverb_setFreeze (tDattorroReverb const r, int freeze) +void tDattorroReverb_setFreeze (tDattorroReverb* const r, int freeze) { r->frozen = freeze; if (freeze) { - tAllpass_setGain(r->f2_allpass, 1.0f); - tAllpass_setGain(r->f1_allpass, 1.0f); + tAllpass_setGain(&r->f2_allpass, 1.0f); + tAllpass_setGain(&r->f1_allpass, 1.0f); for (int i = 0; i < 4; i++) { //tAllpass_setGain(&r->in_allpass[i], 1.0f); } - tCycle_setFreq(r->f1_lfo, 0.0f); - tCycle_setFreq(r->f2_lfo, 0.0f); + tCycle_setFreq(&r->f1_lfo, 0.0f); + tCycle_setFreq(&r->f2_lfo, 0.0f); } else { - tAllpass_setGain(r->f2_allpass, 0.7f); - tAllpass_setGain(r->f1_allpass, 0.7f); + tAllpass_setGain(&r->f2_allpass, 0.7f); + tAllpass_setGain(&r->f1_allpass, 0.7f); for (int i = 0; i < 4; i++) { //tAllpass_setGain(&r->in_allpass[i], in_allpass_gains[i]); } - tCycle_setFreq(r->f1_lfo, 0.1f); - tCycle_setFreq(r->f2_lfo, 0.07f); + tCycle_setFreq(&r->f1_lfo, 0.1f); + tCycle_setFreq(&r->f2_lfo, 0.07f); } } -void tDattorroReverb_setHP (tDattorroReverb const r, Lfloat freq) +void tDattorroReverb_setHP (tDattorroReverb* const r, Lfloat freq) { Lfloat newFreq = LEAF_clip(20.0f, freq, 20000.0f); - tHighpass_setFreq(r->f1_hp, newFreq); - tHighpass_setFreq(r->f2_hp, newFreq); + tHighpass_setFreq(&r->f1_hp, newFreq); + tHighpass_setFreq(&r->f2_hp, newFreq); } -void tDattorroReverb_setSize (tDattorroReverb const r, Lfloat size) +void tDattorroReverb_setSize (tDattorroReverb* const r, Lfloat size) { r->size = LEAF_clip(0.01f, size*r->size_max, r->size_max); r->t = r->size * r->sampleRate * 0.001f; @@ -808,9 +808,9 @@ void tDattorroReverb_setSize (tDattorroReverb const r, Lfloat size) // FEEDBACK 1 //tAllpass_setDelay(&r->f1_allpass, SAMP(30.51f)); - tTapeDelay_setDelay(r->f1_delay_1, SAMP(141.69f)); - tTapeDelay_setDelay(r->f1_delay_2, SAMP(89.24f)); - tTapeDelay_setDelay(r->f1_delay_3, SAMP(125.f)); + tTapeDelay_setDelay(&r->f1_delay_1, SAMP(141.69f)); + tTapeDelay_setDelay(&r->f1_delay_2, SAMP(89.24f)); + tTapeDelay_setDelay(&r->f1_delay_3, SAMP(125.f)); // maybe change rate of SINE LFO's when size changes? //tCycle_setFreq(&r->f2_lfo, 0.07f * size * r->size_max); @@ -818,39 +818,39 @@ void tDattorroReverb_setSize (tDattorroReverb const r, Lfloat size) // FEEDBACK 2 //tAllpass_setDelay(&r->f2_allpass, SAMP(22.58f)); - tTapeDelay_setDelay(r->f2_delay_1, SAMP(149.62f)); - tTapeDelay_setDelay(r->f2_delay_2, SAMP(60.48f)); - tTapeDelay_setDelay(r->f2_delay_3, SAMP(106.28f)); + tTapeDelay_setDelay(&r->f2_delay_1, SAMP(149.62f)); + tTapeDelay_setDelay(&r->f2_delay_2, SAMP(60.48f)); + tTapeDelay_setDelay(&r->f2_delay_3, SAMP(106.28f)); } -void tDattorroReverb_setInputDelay (tDattorroReverb const r, Lfloat preDelay) +void tDattorroReverb_setInputDelay (tDattorroReverb* const r, Lfloat preDelay) { r->predelay = LEAF_clip(0.0f, preDelay, 200.0f); - tTapeDelay_setDelay(r->in_delay, SAMP(r->predelay)); + tTapeDelay_setDelay(&r->in_delay, SAMP(r->predelay)); } -void tDattorroReverb_setInputFilter (tDattorroReverb const r, Lfloat freq) +void tDattorroReverb_setInputFilter (tDattorroReverb* const r, Lfloat freq) { r->input_filter = LEAF_clip(0.0f, freq, 20000.0f); - tOnePole_setFreq(r->in_filter, r->input_filter); + tOnePole_setFreq(&r->in_filter, r->input_filter); } -void tDattorroReverb_setFeedbackFilter (tDattorroReverb const r, Lfloat freq) +void tDattorroReverb_setFeedbackFilter (tDattorroReverb* const r, Lfloat freq) { r->feedback_filter = LEAF_clip(0.0f, freq, 20000.0f); - tOnePole_setFreq(r->f1_filter, r->feedback_filter); - tOnePole_setFreq(r->f2_filter, r->feedback_filter); + tOnePole_setFreq(&r->f1_filter, r->feedback_filter); + tOnePole_setFreq(&r->f2_filter, r->feedback_filter); } -void tDattorroReverb_setFeedbackGain (tDattorroReverb const r, Lfloat gain) +void tDattorroReverb_setFeedbackGain (tDattorroReverb* const r, Lfloat gain) { r->feedback_gain = gain; } -void tDattorroReverb_setSampleRate (tDattorroReverb const r, Lfloat sr) +void tDattorroReverb_setSampleRate (tDattorroReverb* const r, Lfloat sr) { tMempool* mp = &r->mempool; @@ -885,12 +885,12 @@ void tDattorroReverb_setSampleRate (tDattorroReverb const r, Lfloat sr) for (int i = 0; i < 4; i++) { tAllpass_initToPool(&r->in_allpass[i], SAMP(in_allpass_delays[i]), SAMP(20.f), mp); // * r->size_max - tAllpass_setGain(r->in_allpass[i], in_allpass_gains[i]); + tAllpass_setGain(&r->in_allpass[i], in_allpass_gains[i]); } // FEEDBACK 1 tAllpass_initToPool(&r->f1_allpass, SAMP(30.51f), SAMP(100.f), mp); // * r->size_max - tAllpass_setGain(r->f1_allpass, 0.7f); + tAllpass_setGain(&r->f1_allpass, 0.7f); tTapeDelay_initToPool(&r->f1_delay_1, SAMP(141.69f), SAMP(200.0f) * r->size_max + 1, mp); tTapeDelay_initToPool(&r->f1_delay_2, SAMP(89.24f), SAMP(100.0f) * r->size_max + 1, mp); @@ -898,19 +898,19 @@ void tDattorroReverb_setSampleRate (tDattorroReverb const r, Lfloat sr) // FEEDBACK 2 tAllpass_initToPool(&r->f2_allpass, SAMP(22.58f), SAMP(100.f), mp); // * r->size_max - tAllpass_setGain(r->f2_allpass, 0.7f); + tAllpass_setGain(&r->f2_allpass, 0.7f); tTapeDelay_initToPool(&r->f2_delay_1, SAMP(149.62f), SAMP(200.f) * r->size_max + 1, mp); tTapeDelay_initToPool(&r->f2_delay_2, SAMP(60.48f), SAMP(100.f) * r->size_max + 1, mp); tTapeDelay_initToPool(&r->f2_delay_3, SAMP(106.28f), SAMP(200.f) * r->size_max + 1, mp); - tOnePole_setSampleRate(r->in_filter, r->sampleRate); - tOnePole_setSampleRate(r->f1_filter, r->sampleRate); - tHighpass_setSampleRate(r->f1_hp, r->sampleRate); - tCycle_setSampleRate(r->f1_lfo, r->sampleRate); - tOnePole_setSampleRate(r->f2_filter, r->sampleRate); - tHighpass_setSampleRate(r->f2_hp, r->sampleRate); - tCycle_setSampleRate(r->f2_lfo, r->sampleRate); + tOnePole_setSampleRate(&r->in_filter, r->sampleRate); + tOnePole_setSampleRate(&r->f1_filter, r->sampleRate); + tHighpass_setSampleRate(&r->f1_hp, r->sampleRate); + tCycle_setSampleRate(&r->f1_lfo, r->sampleRate); + tOnePole_setSampleRate(&r->f2_filter, r->sampleRate); + tHighpass_setSampleRate(&r->f2_hp, r->sampleRate); + tCycle_setSampleRate(&r->f2_lfo, r->sampleRate); // PARAMETERS tDattorroReverb_setSize(r, r->size*0.5f); diff --git a/leaf/Src/leaf-sampling.c b/leaf/Src/leaf-sampling.c index 985068a..21009f4 100644 --- a/leaf/Src/leaf-sampling.c +++ b/leaf/Src/leaf-sampling.c @@ -119,7 +119,7 @@ void tBuffer_setRecordMode (tBuffer* const s, RecordMode mode) s->mode = mode; } -void tBuffer_clear (tBuffer const s) +void tBuffer_clear (tBuffer* const s) { for (unsigned i = 0; i < s->bufferLength; i++) { @@ -128,7 +128,7 @@ void tBuffer_clear (tBuffer const s) } -void tBuffer_setBuffer(tBuffer const s, Lfloat* externalBuffer, int length, int channels, int sampleRate) +void tBuffer_setBuffer(tBuffer* const s, Lfloat* externalBuffer, int length, int channels, int sampleRate) { s->buff = externalBuffer; s->channels = channels; @@ -137,22 +137,22 @@ void tBuffer_setBuffer(tBuffer const s, Lfloat* externalBuffer, int length, int s->bufferLength = s->recordedLength; } -uint32_t tBuffer_getBufferLength(tBuffer const s) +uint32_t tBuffer_getBufferLength(tBuffer* const s) { return s->bufferLength; } -uint32_t tBuffer_getRecordedLength(tBuffer const s) +uint32_t tBuffer_getRecordedLength(tBuffer* const s) { return s->recordedLength; } -void tBuffer_setRecordedLength(tBuffer const s, int length) +void tBuffer_setRecordedLength(tBuffer* const s, int length) { s->recordedLength = length; } -int tBuffer_isActive(tBuffer const s) +int tBuffer_isActive(tBuffer* const s) { return s->active; } @@ -167,13 +167,13 @@ void tSampler_init(tSampler* const sp, tBuffer* const b, LEAF* const leaf) tSampler_initToPool(sp, b, &leaf->mempool, leaf); } -void tSampler_initToPool(tSampler* const sp, tBuffer* const b, tMempool* const mp, LEAF* const leaf) +void tSampler_initToPool(tSampler** const sp, tBuffer** const b, tMempool* const mp, LEAF* const leaf) { _tMempool* m = *mp; - _tSampler* p = *sp = (_tSampler*) mpool_alloc(sizeof(_tSampler), m); + tSampler* p = *sp = (tSampler*) mpool_alloc(sizeof(tSampler), m); p->mempool = m; - _tBuffer* s = *b; + tBuffer* s = *b; p->invSampleRate = leaf->invSampleRate; p->sampleRate = leaf->sampleRate; @@ -181,7 +181,7 @@ void tSampler_initToPool(tSampler* const sp, tBuffer* const b, tMempool* const m p->rateFactor = s->sampleRate * p->invSampleRate; p->channels = s->channels; - p->samp = s; + p->samp = *s; p->active = 0; @@ -214,7 +214,7 @@ void tSampler_initToPool(tSampler* const sp, tBuffer* const b, tMempool* const m p->cfxlen = 500; // default 300 sample crossfade tRamp_initToPool(&p->gain, 5.0f, 1, mp); - tRamp_setVal(p->gain, 0.f); + tRamp_setVal(&p->gain, 0.f); p->targetstart = -1; p->targetend = -1; @@ -249,7 +249,7 @@ void tSampler_setSample (tSampler* const p, tBuffer const s) Lfloat tSampler_tick (tSampler* const p) { - attemptStartEndChange(p); + attemptStartEndChange(*p); if (p->active == 0) return 0.f; @@ -416,7 +416,7 @@ Lfloat tSampler_tick (tSampler* const p) } - attemptStartEndChange(p); + attemptStartEndChange(*p); if (p->mode == PlayLoop) @@ -459,24 +459,24 @@ Lfloat tSampler_tick (tSampler* const p) Lfloat ticksToEnd = rev ? ((idx - myStart) * p->iinc) : ((myEnd - idx) * p->iinc); if ((ticksToEnd < p->ticksPerSevenMs) && (p->active == 1)) { - tRamp_setDest(p->gain, 0.f); + tRamp_setDest(&p->gain, 0.f); p->active = -1; } } sample = ((sample * (1.0f - crossfadeMix)) + (cfxsample * crossfadeMix)) * (1.0f - flipMix) + (flipsample * flipMix); - sample = sample * tRamp_tick(p->gain); + sample = sample * tRamp_tick(&p->gain); if (p->active < 0) { - if (tRamp_sample(p->gain) <= 0.00001f) + if (tRamp_sample(&p->gain) <= 0.00001f) { if (p->retrigger == 1) { p->active = 1; p->retrigger = 0; - tRamp_setDest(p->gain, 1.f); + tRamp_setDest(&p->gain, 1.f); if (p->dir > 0) { @@ -503,9 +503,9 @@ Lfloat tSampler_tick (tSampler* const p) return p->last; } -Lfloat tSampler_tickStereo (tSampler const p, Lfloat* outputArray) +Lfloat tSampler_tickStereo (tSampler* const p, Lfloat* outputArray) { - attemptStartEndChange(p); + attemptStartEndChange(*p); if (p->active == 0) return 0.f; @@ -690,7 +690,7 @@ Lfloat tSampler_tickStereo (tSampler const p, Lfloat* outputArray) } } - attemptStartEndChange(p); + attemptStartEndChange(*p); if (p->mode == PlayLoop) { @@ -732,12 +732,12 @@ Lfloat tSampler_tickStereo (tSampler const p, Lfloat* outputArray) Lfloat ticksToEnd = rev ? ((idx - myStart) * p->iinc) : ((myEnd - idx) * p->iinc); if ((ticksToEnd < p->ticksPerSevenMs) && (p->active == 1)) { - tRamp_setDest(p->gain, 0.f); + tRamp_setDest(&p->gain, 0.f); p->active = -1; } } - Lfloat sampleGain = tRamp_tick(p->gain); + Lfloat sampleGain = tRamp_tick(&p->gain); for (int i = 0; i < p->channels; i++) { outputArray[i] = ((outputArray[i] * (1.0f - crossfadeMix)) + (cfxsample[i] * crossfadeMix)) * (1.0f - flipMix) + (flipsample[i] * flipMix); @@ -747,13 +747,13 @@ Lfloat tSampler_tickStereo (tSampler const p, Lfloat* outputArray) if (p->active < 0) { //if was fading out and reached silence - if (tRamp_sample(p->gain) <= 0.0001f) + if (tRamp_sample(&p->gain) <= 0.0001f) { if (p->retrigger == 1) { p->active = 1; p->retrigger = 0; - tRamp_setDest(p->gain, 1.f); + tRamp_setDest(&p->gain, 1.f); if (p->dir > 0) { @@ -765,7 +765,7 @@ Lfloat tSampler_tickStereo (tSampler const p, Lfloat* outputArray) if (p->flip > 0) p->idx = p->end; else p->idx = p->start; } - handleStartEndChange(p); + handleStartEndChange(*p); } else { @@ -781,26 +781,26 @@ Lfloat tSampler_tickStereo (tSampler const p, Lfloat* outputArray) } -void tSampler_setMode (tSampler const p, PlayMode mode) +void tSampler_setMode (tSampler* const p, PlayMode mode) { p->mode = mode; } -void tSampler_setCrossfadeLength (tSampler const p, uint32_t length) +void tSampler_setCrossfadeLength (tSampler* const p, uint32_t length) { uint32_t cfxlen = LEAF_clip(0, length, p->len * 0.25f); p->cfxlen = cfxlen; } -void tSampler_play (tSampler const p) +void tSampler_play (tSampler* const p) { if (p->active > 0) { p->active = -1; p->retrigger = 1; - tRamp_setDest(p->gain, 0.f); + tRamp_setDest(&p->gain, 0.f); } else if (p->active < 0) @@ -816,7 +816,7 @@ void tSampler_play (tSampler const p) p->active = 1; p->retrigger = 0; - tRamp_setDest(p->gain, 1.f); + tRamp_setDest(&p->gain, 1.f); if (p->dir > 0) { @@ -828,18 +828,18 @@ void tSampler_play (tSampler const p) if (p->flip > 0) p->idx = p->end; else p->idx = p->start; } - handleStartEndChange(p); + handleStartEndChange(*p); } } -void tSampler_stop (tSampler const p) +void tSampler_stop (tSampler* const p) { p->active = -1; - tRamp_setDest(p->gain, 0.f); + tRamp_setDest(&p->gain, 0.f); } -static void handleStartEndChange(tSampler const p) +static void handleStartEndChange(tSampler* const p) { p->len = abs(p->end - p->start); @@ -855,7 +855,7 @@ static void handleStartEndChange(tSampler const p) } } -static void attemptStartEndChange(tSampler const p) +static void attemptStartEndChange(tSampler* const p) { // Try to update start/end if needed if (p->targetstart >= 0) @@ -868,7 +868,7 @@ static void attemptStartEndChange(tSampler const p) } } -void tSampler_setStart (tSampler const p, int32_t start) +void tSampler_setStart (tSampler* const p, int32_t start) { int tempflip; /* @@ -936,7 +936,7 @@ void tSampler_setStart (tSampler const p, int32_t start) } -void tSampler_setEnd (tSampler const p, int32_t end) +void tSampler_setEnd (tSampler* const p, int32_t end) { int tempflip; @@ -1004,7 +1004,7 @@ void tSampler_setEnd (tSampler const p, int32_t end) p->targetend = -1; } -void tSampler_setEndUnsafe (tSampler const p, int32_t end) +void tSampler_setEndUnsafe (tSampler* const p, int32_t end) { int tempflip; @@ -1072,13 +1072,13 @@ void tSampler_setEndUnsafe (tSampler const p, int32_t end) p->targetend = -1; } -void tSampler_setLength (tSampler const p, int32_t length) +void tSampler_setLength (tSampler* const p, int32_t length) { if (length == 0) length = 1; tSampler_setEnd(p, p->start + length); } -void tSampler_setRate (tSampler const p, Lfloat rate) +void tSampler_setRate (tSampler* const p, Lfloat rate) { rate = rate * p->rateFactor; //adjust for sampling rate of buffer (may be different from leaf.sampleRate if audio file was loaded form SD card) if (rate < 0.f) @@ -1096,14 +1096,14 @@ void tSampler_setRate (tSampler const p, Lfloat rate) } -void tSampler_setSampleRate(tSampler const p, Lfloat sr) +void tSampler_setSampleRate(tSampler* const p, Lfloat sr) { - _tBuffer* s = p->samp; + tBuffer* s = &p->samp; p->sampleRate = sr; p->invSampleRate = 1.0f/p->sampleRate; p->ticksPerSevenMs = 0.007f * p->sampleRate; p->rateFactor = s->sampleRate * p->invSampleRate; - tRamp_setSampleRate(p->gain, p->sampleRate); + tRamp_setSampleRate(&p->gain, p->sampleRate); } //============================================================================== @@ -1113,21 +1113,21 @@ void tAutoSampler_init (tAutoSampler* const as, tBuffer* const b, LEAF* con tAutoSampler_initToPool(as, b, &leaf->mempool, leaf); } -void tAutoSampler_initToPool (tAutoSampler* const as, tBuffer* const b, tMempool* const mp, LEAF* const leaf) +void tAutoSampler_initToPool (tAutoSampler** const as, tBuffer* const b, tMempool* const mp, LEAF* const leaf) { _tMempool* m = *mp; - _tAutoSampler* a = *as = (_tAutoSampler*) mpool_alloc(sizeof(_tAutoSampler), m); + tAutoSampler* a = *as = (tAutoSampler*) mpool_alloc(sizeof(tAutoSampler), m); a->mempool = m; - tBuffer_setRecordMode(*b, RecordOneShot); + tBuffer_setRecordMode(&*b, RecordOneShot); tSampler_initToPool(&a->sampler, b, mp, leaf); - tSampler_setMode(a->sampler, PlayLoop); + tSampler_setMode(&a->sampler, PlayLoop); tEnvelopeFollower_initToPool(&a->ef, 0.05f, 0.9999f, mp); } -void tAutoSampler_free (tAutoSampler* const as) +void tAutoSampler_free (tAutoSampler** const as) { - _tAutoSampler* a = *as; + tAutoSampler* a = *as; tEnvelopeFollower_free(&a->ef); tSampler_free(&a->sampler); @@ -1135,9 +1135,9 @@ void tAutoSampler_free (tAutoSampler* const as) mpool_free((char*)a, a->mempool); } -Lfloat tAutoSampler_tick (tAutoSampler const a, Lfloat input) +Lfloat tAutoSampler_tick (tAutoSampler* const a, Lfloat input) { - Lfloat currentPower = tEnvelopeFollower_tick(a->ef, input); + Lfloat currentPower = tEnvelopeFollower_tick(&a->ef, input); if ((currentPower > (a->threshold)) && (currentPower > a->previousPower + 0.001f) && @@ -1157,7 +1157,7 @@ Lfloat tAutoSampler_tick (tAutoSampler const a, Lfloat input) } - tSampler_setEnd(a->sampler, a->windowSize); + tSampler_setEnd(&a->sampler, a->windowSize); tBuffer_tick(a->sampler->samp, input); //on its way down if (currentPower <= a->previousPower) @@ -1174,56 +1174,56 @@ Lfloat tAutoSampler_tick (tAutoSampler const a, Lfloat input) a->previousPower = currentPower; - return tSampler_tick(a->sampler); + return tSampler_tick(&a->sampler); } -void tAutoSampler_setBuffer (tAutoSampler const a, tBuffer const b) +void tAutoSampler_setBuffer (tAutoSampler* const a, tBuffer const b) { - tBuffer_setRecordMode(b, RecordOneShot); - if (a->windowSize > tBuffer_getBufferLength(b)) - a->windowSize = tBuffer_getBufferLength(b); - tSampler_setSample(a->sampler, b); + tBuffer_setRecordMode(&b, RecordOneShot); + if (a->windowSize > tBuffer_getBufferLength(&b)) + a->windowSize = tBuffer_getBufferLength(&b); + tSampler_setSample(&a->sampler, b); } -void tAutoSampler_setMode (tAutoSampler const a, PlayMode mode) +void tAutoSampler_setMode (tAutoSampler* const a, PlayMode mode) { - tSampler_setMode(a->sampler, mode); + tSampler_setMode(&a->sampler, mode); } -void tAutoSampler_play (tAutoSampler const a) +void tAutoSampler_play (tAutoSampler* const a) { - tSampler_play(a->sampler); + tSampler_play(&a->sampler); } -void tAutoSampler_stop (tAutoSampler const a) +void tAutoSampler_stop (tAutoSampler* const a) { - tSampler_stop(a->sampler); + tSampler_stop(&a->sampler); } -void tAutoSampler_setThreshold (tAutoSampler const a, Lfloat thresh) +void tAutoSampler_setThreshold (tAutoSampler* const a, Lfloat thresh) { a->threshold = thresh; } -void tAutoSampler_setWindowSize (tAutoSampler const a, uint32_t size) +void tAutoSampler_setWindowSize (tAutoSampler* const a, uint32_t size) { if (size > tBuffer_getBufferLength(a->sampler->samp)) a->windowSize = tBuffer_getBufferLength(a->sampler->samp); else a->windowSize = size; } -void tAutoSampler_setCrossfadeLength (tAutoSampler const a, uint32_t length) +void tAutoSampler_setCrossfadeLength (tAutoSampler* const a, uint32_t length) { - tSampler_setCrossfadeLength(a->sampler, length); + tSampler_setCrossfadeLength(&a->sampler, length); } -void tAutoSampler_setRate (tAutoSampler const a, Lfloat rate) +void tAutoSampler_setRate (tAutoSampler* const a, Lfloat rate) { } -void tAutoSampler_setSampleRate (tAutoSampler const a, Lfloat sr) +void tAutoSampler_setSampleRate (tAutoSampler* const a, Lfloat sr) { - tSampler_setSampleRate(a->sampler, sr); + tSampler_setSampleRate(&a->sampler, sr); } @@ -1232,10 +1232,10 @@ void tMBSampler_init(tMBSampler* const sp, tBuffer* const b, LEAF* const leaf) tMBSampler_initToPool(sp, b, &leaf->mempool); } -void tMBSampler_initToPool(tMBSampler* const sp, tBuffer* const b, tMempool* const mp) +void tMBSampler_initToPool(tMBSampler** const sp, tBuffer* const b, tMempool* const mp) { _tMempool* m = *mp; - _tMBSampler* c = *sp = (_tMBSampler*) mpool_alloc(sizeof(_tMBSampler), m); + tMBSampler* c = *sp = (tMBSampler*) mpool_alloc(sizeof(tMBSampler), m); c->mempool = m; c->samp = *b; @@ -1260,16 +1260,16 @@ void tMBSampler_initToPool(tMBSampler* const sp, tBuffer* const b, tMempool* con tMBSampler_setEnd(*sp, c->samp->bufferLength); } -void tMBSampler_free (tMBSampler* const sp) +void tMBSampler_free (tMBSampler** const sp) { - _tMBSampler* p = *sp; + tMBSampler* p = *sp; tExpSmooth_free(&p->gain); mpool_free((char*)p, p->mempool); } -void tMBSampler_setSample (tMBSampler const p, tBuffer* const b) +void tMBSampler_setSample (tMBSampler* const p, tBuffer* const b) { p->samp = *b;; @@ -1279,7 +1279,7 @@ void tMBSampler_setSample (tMBSampler const p, tBuffer* const b) p->_p = 0.0f; } -Lfloat tMBSampler_tick (tMBSampler const c) +Lfloat tMBSampler_tick (tMBSampler* const c) { if ((c->gain->curr == 0.0f) && (!c->active)) return 0.0f; if (c->_w == 0.0f) @@ -1518,12 +1518,12 @@ Lfloat tMBSampler_tick (tMBSampler const c) return c->out * tExpSmooth_tick(c->gain); } -void tMBSampler_setMode (tMBSampler const p, PlayMode mode) +void tMBSampler_setMode (tMBSampler* const p, PlayMode mode) { p->mode = mode; } -void tMBSampler_play (tMBSampler const p) +void tMBSampler_play (tMBSampler* const p) { if (p->active > 0) { @@ -1536,20 +1536,20 @@ void tMBSampler_play (tMBSampler const p) p->_j = 0; } -void tMBSampler_stop (tMBSampler const p) +void tMBSampler_stop (tMBSampler* const p) { tExpSmooth_setDest(p->gain, 0.0f); p->active = 0; } -void tMBSampler_setStart (tMBSampler const p, int32_t start) +void tMBSampler_setStart (tMBSampler* const p, int32_t start) { if (start > p->end - 1) p->start = p->end - 1; else if (start < 0) p->start = 0; else p->start = start; } -void tMBSampler_setEnd (tMBSampler const p, int32_t end) +void tMBSampler_setEnd (tMBSampler* const p, int32_t end) { if (end < p->start + 1) p->end = p->start + 1; // always leave a trailing sample after the end @@ -1557,12 +1557,12 @@ void tMBSampler_setEnd (tMBSampler const p, int32_t end) else p->end = end; } -void tMBSampler_setLength (tMBSampler const p, int32_t length) +void tMBSampler_setLength (tMBSampler* const p, int32_t length) { tMBSampler_setEnd(p, p->start + length); } -void tMBSampler_setRate (tMBSampler const p, Lfloat rate) +void tMBSampler_setRate (tMBSampler* const p, Lfloat rate) { p->_w = rate; } diff --git a/leaf/Src/leaf-vocal.c b/leaf/Src/leaf-vocal.c index d010de5..0ec9d46 100644 --- a/leaf/Src/leaf-vocal.c +++ b/leaf/Src/leaf-vocal.c @@ -49,7 +49,7 @@ static inline int v_isnan(float f) return (u.x << 1) > 0xff000000u; } -void glottis_setup_waveform(glottis const glot) +void glottis_setup_waveform(glottis* const glot) { Lfloat Rd; Lfloat Ra; @@ -131,11 +131,11 @@ void glottis_init(glottis* const glo, LEAF* const leaf) glottis_initToPool(glo, &leaf->mempool); } -void glottis_initToPool(glottis* const glo, tMempool* const mp) +void glottis_initToPool(glottis** const glo, tMempool* const mp) { _tMempool* m = *mp; - _glottis* glot = *glo = (_glottis*) mpool_calloc(sizeof(_glottis), m); + glottis* glot = *glo = (glottis*) mpool_calloc(sizeof(glottis), m); glot->mempool = m; LEAF* leaf = glot->mempool->leaf; glot->mempool = m; @@ -146,14 +146,14 @@ void glottis_initToPool(glottis* const glo, tMempool* const mp) glottis_setup_waveform(glot); } -void glottis_free(glottis* const glo) +void glottis_free(glottis** const glo) { - _glottis* glot = *glo; + glottis* glot = *glo; mpool_free((char*)glot, glot->mempool); } -Lfloat glottis_compute(glottis const glot) +Lfloat glottis_compute(glottis* const glot) { LEAF* leaf = glot->mempool->leaf; Lfloat out; @@ -534,7 +534,7 @@ void tract_addTurbulenceNoise(tract const tr) { for (int i = 0; i < 2; i++) { - Lfloat turbulenceNoise = tr->TnoiseGain * tSVF_tick(tr->fricativeNoiseFilt[i], tNoise_tick(tr->whiteNoise) * 0.20f); + Lfloat turbulenceNoise = tr->TnoiseGain * tSVF_tick(&tr->fricativeNoiseFilt[i], tNoise_tick(&tr->whiteNoise) * 0.20f); tract_addTurbulenceNoiseAtPosition(tr, turbulenceNoise, tr->turbuluencePointPosition[i], tr->turbuluencePointDiameter[i]); } } @@ -587,8 +587,8 @@ void tract_compute(tract const tr, Lfloat in, Lfloat lambda) } */ - Lfloat UVnoise = tNoise_tick(tr->whiteNoise); - UVnoise = tSVF_tick(tr->aspirationNoiseFilt,UVnoise); + Lfloat UVnoise = tNoise_tick(&tr->whiteNoise); + UVnoise = tSVF_tick(&tr->aspirationNoiseFilt,UVnoise); in = fast_tanh5((UVnoise * tr->AnoiseGain) + (in * (1.0f - tr->AnoiseGain))); @@ -778,7 +778,7 @@ Lfloat tVoc_tick (tVoc const v) vocal_output = 0.0f; lambda1 = ((Lfloat) v->counter) * 0.015625f;// /64 lambda2 = (Lfloat) (v->counter + 0.5f) * 0.015625f; // /64 - glot = glottis_compute(v->glot); + glot = glottis_compute(&v->glot); tract_compute(v->tr, glot, lambda1); vocal_output += v->tr->lip_output + v->tr->nose_output; @@ -925,12 +925,12 @@ Lfloat * tVoc_get_velum_ptr(tVoc const v) //0-1 void tVoc_setAspirationNoiseFilterFreq(tVoc const v, Lfloat freq) { - tSVF_setFreqFast(v->tr->aspirationNoiseFilt,freq*30.0f + 60.0f); + tSVF_setFreqFast(&v->tr->aspirationNoiseFilt,freq*30.0f + 60.0f); } void tVoc_setAspirationNoiseFilterQ(tVoc const v, Lfloat Q) { - tSVF_setQ(v->tr->aspirationNoiseFilt,Q*0.49f + 0.5f); + tSVF_setQ(&v->tr->aspirationNoiseFilt,Q*0.49f + 0.5f); } From d2aa5aad0dd7f8306b2a0e0fb7cd1a2fbd40df37 Mon Sep 17 00:00:00 2001 From: Davis Polito Date: Fri, 30 May 2025 19:08:41 -0400 Subject: [PATCH 03/14] clean up renaming work --- CMakeLists.txt | 2 +- leaf/Inc/leaf-analysis.h | 158 ++--- leaf/Inc/leaf-delay.h | 72 +-- leaf/Inc/leaf-distortion.h | 60 +- leaf/Inc/leaf-dynamics.h | 36 +- leaf/Inc/leaf-effects.h | 130 ++-- leaf/Inc/leaf-electrical.h | 48 +- leaf/Inc/leaf-envelopes.h | 104 ++-- leaf/Inc/leaf-filters.h | 221 ++++--- leaf/Inc/leaf-global.h | 4 +- leaf/Inc/leaf-instruments.h | 172 ++--- leaf/Inc/leaf-mempool.h | 26 +- leaf/Inc/leaf-midi.h | 44 +- leaf/Inc/leaf-oscillators.h | 300 ++++----- leaf/Inc/leaf-physical.h | 322 +++++----- leaf/Inc/leaf-reverb.h | 79 ++- leaf/Inc/leaf-sampling.h | 62 +- leaf/Inc/leaf-tables.h | 4 +- leaf/Inc/leaf-vocal.h | 138 ++-- leaf/Src/leaf-analysis.c | 298 +++++---- leaf/Src/leaf-delay.c | 42 +- leaf/Src/leaf-distortion.c | 36 +- leaf/Src/leaf-dynamics.c | 24 +- leaf/Src/leaf-effects.c | 144 ++--- leaf/Src/leaf-electrical.c | 100 +-- leaf/Src/leaf-envelopes.c | 48 +- leaf/Src/leaf-filters.c | 180 +++--- leaf/Src/leaf-instruments.c | 274 ++++---- leaf/Src/leaf-mempool.c | 24 +- leaf/Src/leaf-midi.c | 96 +-- leaf/Src/leaf-oscillators.c | 288 ++++----- leaf/Src/leaf-physical.c | 1174 +++++++++++++++++------------------ leaf/Src/leaf-reverb.c | 316 +++++----- leaf/Src/leaf-sampling.c | 106 ++-- leaf/Src/leaf-tables.c | 8 +- leaf/Src/leaf-vocal.c | 122 ++-- leaf/leaf.h | 2 +- test/filters_test.cpp | 90 +-- test/oscillators_test.cpp | 62 +- 39 files changed, 2704 insertions(+), 2712 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 774ff4d..f2336c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,7 +98,7 @@ TARGET_SOURCES( ${BINARY_NAME} PRIVATE ${PRIVATE_SOURCES_FILES} ${PRIVATE_HEADE target_include_directories(${BINARY_NAME} PUBLIC "${LIBRARY_BASE_PATH}/leaf" "${LIBRARY_BASE_PATH}/leaf/Inc" "${LIBRARY_BASE_PATH}/leaf/Externals") - +target_compile_options(${BINARY_NAME} PRIVATE "-Wno-narrowing") enable_testing() list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") diff --git a/leaf/Inc/leaf-analysis.h b/leaf/Inc/leaf-analysis.h index 3e9b177..bfa41d6 100644 --- a/leaf/Inc/leaf-analysis.h +++ b/leaf/Inc/leaf-analysis.h @@ -39,21 +39,21 @@ extern "C" { @brief Detects and returns the basic envelope of incoming audio data. @{ - @fn void tEnvelopeFollower_init (tEnvelopeFollower* const follower, Lfloat attackThreshold, Lfloat decayCoeff, LEAF* const leaf) + @fn void tEnvelopeFollower_init(tEnvelopeFollower** const follower, Lfloat attackThreshold, Lfloat decayCoeff, LEAF* const leaf) @brief Initialize a tEnvelopeFollower to the default mempool of a LEAF instance. @param follower A pointer to the tEnvelopeFollower to initialize. @param attackThreshold Amplitude threshold for determining an envelope onset. 0.0 to 1.0 @param decayCoefficient Multiplier to determine the envelope rate of decay. 0.0 to 1.0, above 0.95 recommended. @param leaf A pointer to the leaf instance. - @fn void tEnvelopeFollower_initToPool (tEnvelopeFollower* const follower, Lfloat attackThreshold, Lfloat decayCoeff, tMempool* const mempool) + @fn void tEnvelopeFollower_initToPool(tEnvelopeFollower** const follower, Lfloat attackThreshold, Lfloat decayCoeff, tMempool** const mempool) @brief Initialize a tEnvelopeFollower to a specified mempool. @param follower A pointer to the tEnvelopeFollower to initialize. @param attackThreshold Amplitude threshold for determining an envelope onset. 0.0 to 1.0 @param decayCoefficient Multiplier to determine the envelope rate of decay. 0.0 to 1.0, above 0.95 recommended. @param mempool A pointer to the tMempool to use. - @fn void tEnvelopeFollower_free (tEnvelopeFollower* const follower) + @fn void tEnvelopeFollower_free(tEnvelopeFollower** const follower) @brief Free a tEnvelopeFollower from its mempool. @param follower A pointer to the tEnvelopeFollower to free. @@ -77,8 +77,8 @@ extern "C" { typedef struct tEnvelopeFollower { - - tMempool mempool; + + tMempool* mempool; Lfloat y; Lfloat a_thresh; Lfloat d_coeff; @@ -86,7 +86,7 @@ extern "C" { } tEnvelopeFollower; void tEnvelopeFollower_init (tEnvelopeFollower** const follower, Lfloat attackThreshold, Lfloat decayCoefficient, LEAF* const leaf); - void tEnvelopeFollower_initToPool (tEnvelopeFollower** const follower, Lfloat attackThreshold, Lfloat decayCoefficient, tMempool* const mempool); + void tEnvelopeFollower_initToPool (tEnvelopeFollower** const follower, Lfloat attackThreshold, Lfloat decayCoefficient, tMempool** const mempool); void tEnvelopeFollower_free (tEnvelopeFollower** const follower); Lfloat tEnvelopeFollower_tick (tEnvelopeFollower* const follower, Lfloat sample); @@ -100,19 +100,19 @@ extern "C" { @brief Count the amount of zero crossings within a window of the input audio data @{ - @fn void tZeroCrossingCounter_init (tZeroCrossingCounter* const counter, int maxWindowSize, LEAF* const leaf) + @fn void tZeroCrossingCounter_init(tZeroCrossingCounter** const counter, int maxWindowSize, LEAF* const leaf) @brief Initialize a tZeroCrossingCounter to the default mempool of a LEAF instance. @param counter A pointer to the tZeroCrossingCounter to initialize. @param maxWindowSize The max and initial size of the window. @param leaf A pointer to the leaf instance. - @fn void tZeroCrossingCounter_initToPool (tZeroCrossingCounter* const counter, int maxWindowSize, tMempool* const mempool) + @fn void tZeroCrossingCounter_initToPool(tZeroCrossingCounter** const counter, int maxWindowSize, tMempool** const mempool) @brief Initialize a tZeroCrossingCounter to a specified mempool. @param counter A pointer to the tZeroCrossingCounter to initialize. @param maxWindowSize The max and initial size of the window. @param mempool A pointer to the tMempool to use. - @fn void tZeroCrossingCounter_free (tZeroCrossingCounter* const counter) + @fn void tZeroCrossingCounter_free(tZeroCrossingCounter** const counter) @brief Free a tZeroCrossingCounter from its mempool. @param counter A pointer to the tZeroCrossingCounter to free. @@ -132,8 +132,8 @@ extern "C" { /* Zero Crossing Detector */ typedef struct tZeroCrossingCounter { - - tMempool mempool; + + tMempool* mempool; int count; int maxWindowSize; int currentWindowSize; @@ -145,7 +145,7 @@ extern "C" { } tZeroCrossingCounter; void tZeroCrossingCounter_init (tZeroCrossingCounter** const, int maxWindowSize, LEAF* const leaf); - void tZeroCrossingCounter_initToPool (tZeroCrossingCounter** const, int maxWindowSize, tMempool* const mempool); + void tZeroCrossingCounter_initToPool (tZeroCrossingCounter** const, int maxWindowSize, tMempool** const mempool); void tZeroCrossingCounter_free (tZeroCrossingCounter** const); Lfloat tZeroCrossingCounter_tick (tZeroCrossingCounter* const, Lfloat input); @@ -160,19 +160,19 @@ extern "C" { @brief Measure and follow the power of an input signal using an exponential moving average for smoothing. @{ - @fn void tPowerFollower_init (tPowerFollower* const, Lfloat factor, LEAF* const leaf) + @fn void tPowerFollower_init(tPowerFollower** const, Lfloat factor, LEAF* const leaf) @brief Initialize a tPowerFollower to the default mempool of a LEAF instance. @param follower A pointer to the tPowerFollower to initialize. @param factor Smoothing factor of the moving average. 0.0-1.0, with a higher value discounting older inputs more quickly. @param leaf A pointer to the leaf instance. - @fn void tPowerFollower_initToPool (tPowerFollower* const, Lfloat factor, tMempool* const) + @fn void tPowerFollower_initToPool(tPowerFollower** const, Lfloat factor, tMempool** const) @brief Initialize a tPowerFollower to a specified mempool. @param follower A pointer to the tPowerFollower to initialize. @param factor Smoothing factor of the moving average. 0.0-1.0, with a higher value discounting older inputs more quickly. @param mempool A pointer to the tMempool to use. - @fn void tPowerFollower_free (tPowerFollower* const) + @fn void tPowerFollower_free(tPowerFollower** const) @brief Free a tPowerFollower from its mempool. @param follower A pointer to the tPowerFollower to free. @@ -197,15 +197,15 @@ extern "C" { /* PowerEnvelopeFollower */ typedef struct tPowerFollower { - - tMempool mempool; + + tMempool* mempool; Lfloat factor, oneminusfactor; Lfloat curr; } tPowerFollower; void tPowerFollower_init (tPowerFollower** const, Lfloat factor, LEAF* const leaf); - void tPowerFollower_initToPool (tPowerFollower** const, Lfloat factor, tMempool* const); + void tPowerFollower_initToPool (tPowerFollower** const, Lfloat factor, tMempool** const); void tPowerFollower_free (tPowerFollower** const); Lfloat tPowerFollower_tick (tPowerFollower* const, Lfloat input); @@ -221,7 +221,7 @@ extern "C" { @brief ENV~ from PD, modified for LEAF @{ - @fn void tEnvPD_init (tEnvPD* const, int windowSize, int hopSize, int blockSize, LEAF* const leaf) + @fn void tEnvPD_init(tEnvPD** const, int windowSize, int hopSize, int blockSize, LEAF* const leaf) @brief Initialize a tEnvPD to the default mempool of a LEAF instance. @param env A pointer to the tEnvPD to initialize. @param windowSize @@ -229,7 +229,7 @@ extern "C" { @param blockSize @param leaf A pointer to the leaf instance. - @fn void tEnvPD_initToPool (tEnvPD* const, int windowSize, int hopSize, int blockSize, tMempool* const) + @fn void tEnvPD_initToPool(tEnvPD** const, int windowSize, int hopSize, int blockSize, tMempool** const) @brief Initialize a tEnvPD to a specified mempool. @param env A pointer to the tEnvPD to initialize. @param windowSize @@ -237,7 +237,7 @@ extern "C" { @param blockSize @param mempool A pointer to the tMempool to use. - @fn void tEnvPD_free (tEnvPD* const) + @fn void tEnvPD_free(tEnvPD** const) @brief Free a tEnvPD from its mempool. @param env A pointer to the tEnvPD to free. @@ -259,8 +259,8 @@ extern "C" { typedef struct tEnvPD { - - tMempool mempool; + + tMempool* mempool; Lfloat buf[ENV_WINDOW_SIZE + INITVSTAKEN]; int x_phase; /* number of points since last output */ int x_period; /* requested period of output */ @@ -275,7 +275,7 @@ extern "C" { void tEnvPD_init (tEnvPD** const, int windowSize, int hopSize, int blockSize, LEAF* const leaf); - void tEnvPD_initToPool (tEnvPD** const, int windowSize, int hopSize, int blockSize, tMempool* const); + void tEnvPD_initToPool (tEnvPD** const, int windowSize, int hopSize, int blockSize, tMempool** const); void tEnvPD_free (tEnvPD** const); Lfloat tEnvPD_tick (tEnvPD* const); @@ -290,7 +290,7 @@ extern "C" { @brief Detect attacks in an input signal @{ - @fn void tAttackDetection_init (tAttackDetection* const, int blocksize, int atk, int rel, LEAF* const leaf) + @fn void tAttackDetection_init(tAttackDetection** const, int blocksize, int atk, int rel, LEAF* const leaf) @brief Initialize a tAttackDetection to the default mempool of a LEAF instance. @param detection A pointer to the tAttackDetection to initialize. @param blockSize @@ -298,7 +298,7 @@ extern "C" { @param release @param leaf A pointer to the leaf instance. - @fn void tAttackDetection_initToPool (tAttackDetection* const, int blocksize, int atk, int rel, tMempool* const) + @fn void tAttackDetection_initToPool(tAttackDetection** const, int blocksize, int atk, int rel, tMempool** const) @brief Initialize a tAttackDetection to a specified mempool. @param detection A pointer to the tAttackDetection to initialize. @param blockSize @@ -306,7 +306,7 @@ extern "C" { @param release @param mempool A pointer to the tMempool to use. - @fn void tAttackDetection_free (tAttackDetection* const) + @fn void tAttackDetection_free(tAttackDetection** const) @brief Free a tAttackDetection from its mempool. @param detection A pointer to the tAttackDetection to free. @@ -350,7 +350,7 @@ extern "C" { typedef struct tAttackDetection { - tMempool mempool; + tMempool* mempool; Lfloat env; //Attack & Release times in msec @@ -372,7 +372,7 @@ extern "C" { void tAttackDetection_init (tAttackDetection** const, int blocksize, int atk, int rel, LEAF* const leaf); - void tAttackDetection_initToPool (tAttackDetection** const, int blocksize, int atk, int rel, tMempool* const); + void tAttackDetection_initToPool (tAttackDetection** const, int blocksize, int atk, int rel, tMempool** const); void tAttackDetection_free (tAttackDetection** const); void tAttackDetection_setBlocksize (tAttackDetection* const, int size); @@ -391,19 +391,19 @@ extern "C" { @brief Component of period detection algorithm from Katja Vetters http://www.katjaas.nl/helmholtz/helmholtz.html @{ - @fn void tSNAC_init (tSNAC* const, int overlaparg, LEAF* const leaf) + @fn void tSNAC_init(tSNAC** const, int overlaparg, LEAF* const leaf) @brief Initialize a tSNAC to the default mempool of a LEAF instance. @param snac A pointer to the tSNAC to initialize. @param overlap @param leaf A pointer to the leaf instance. - @fn void tSNAC_initToPool (tSNAC* const, int overlaparg, tMempool* const) + @fn void tSNAC_initToPool(tSNAC** const, int overlaparg, tMempool** const) @brief Initialize a tSNAC to a specified mempool. @param snac A pointer to the tSNAC to initialize. @param overlap @param mempool A pointer to the tMempool to use. - @fn void tSNAC_free (tSNAC* const) + @fn void tSNAC_free(tSNAC** const) @brief Free a tSNAC from its mempool. @param snac A pointer to the tSNAC to free. @@ -449,7 +449,7 @@ extern "C" { typedef struct tSNAC { - tMempool mempool; + tMempool* mempool; Lfloat* inputbuf; Lfloat* processbuf; @@ -468,7 +468,7 @@ extern "C" { } tSNAC; void tSNAC_init (tSNAC** const, int overlaparg, LEAF* const leaf); - void tSNAC_initToPool (tSNAC** const, int overlaparg, tMempool* const); + void tSNAC_initToPool (tSNAC** const, int overlaparg, tMempool** const); void tSNAC_free (tSNAC** const); void tSNAC_ioSamples (tSNAC* s, Lfloat *in, int size); @@ -486,7 +486,7 @@ extern "C" { @brief Period detection algorithm from Katja Vetters http://www.katjaas.nl/helmholtz/helmholtz.html @{ - @fn void tPeriodDetection_init (tPeriodDetection* const, Lfloat* in, Lfloat* out, int bufSize, int frameSize, LEAF* const leaf) + @fn void tPeriodDetection_init(tPeriodDetection** const, Lfloat* in, Lfloat* out, int bufSize, int frameSize, LEAF* const leaf) @brief Initialize a tPeriodDetection to the default mempool of a LEAF instance. @param detection A pointer to the tPeriodDetection to initialize. @param in @@ -495,7 +495,7 @@ extern "C" { @param frameSize @param leaf A pointer to the leaf instance. - @fn void tPeriodDetection_initToPool (tPeriodDetection* const, Lfloat* in, Lfloat* out, int bufSize, int frameSize, tMempool* const) + @fn void tPeriodDetection_initToPool(tPeriodDetection** const, Lfloat* in, Lfloat* out, int bufSize, int frameSize, tMempool** const) @brief Initialize a tPeriodDetection to a specified mempool. @param detection A pointer to the tPeriodDetection to initialize. @param in @@ -504,7 +504,7 @@ extern "C" { @param frameSize @param mempool A pointer to the tMempool to use. - @fn void tPeriodDetection_free (tPeriodDetection* const) + @fn void tPeriodDetection_free(tPeriodDetection** const) @brief Free a tPeriodDetection from its mempool. @param detection A pointer to the tPeriodDetection to free. @@ -555,10 +555,10 @@ extern "C" { typedef struct tPeriodDetection { - tMempool mempool; + tMempool* mempool; - tEnvPD env; - tSNAC snac; + tEnvPD* env; + tSNAC* snac; Lfloat* inBuffer; Lfloat* outBuffer; int frameSize; @@ -592,7 +592,7 @@ extern "C" { } tPeriodDetection; void tPeriodDetection_init (tPeriodDetection** const, Lfloat* in, int bufSize, int frameSize, LEAF* const leaf); - void tPeriodDetection_initToPool (tPeriodDetection** const, Lfloat* in, int bufSize, int frameSize, tMempool* const); + void tPeriodDetection_initToPool (tPeriodDetection** const, Lfloat* in, int bufSize, int frameSize, tMempool** const); void tPeriodDetection_free (tPeriodDetection** const); Lfloat tPeriodDetection_tick (tPeriodDetection* const, Lfloat sample); @@ -611,8 +611,8 @@ extern "C" { // Maybe keep from here to tPeriodDetector internal? typedef struct tZeroCrossingInfo { - - tMempool mempool; + + tMempool* mempool; Lfloat _before_crossing; Lfloat _after_crossing; @@ -624,7 +624,7 @@ extern "C" { } tZeroCrossingInfo; void tZeroCrossingInfo_init (tZeroCrossingInfo** const, LEAF* const leaf); - void tZeroCrossingInfo_initToPool (tZeroCrossingInfo** const, tMempool* const); + void tZeroCrossingInfo_initToPool (tZeroCrossingInfo** const, tMempool** const); void tZeroCrossingInfo_free (tZeroCrossingInfo** const); int tZeroCrossingInfo_tick (tZeroCrossingInfo* const, Lfloat s); @@ -639,9 +639,9 @@ extern "C" { typedef struct tZeroCrossingCollector { - tMempool mempool; + tMempool* mempool; - tZeroCrossingInfo* _info; + tZeroCrossingInfo** _info; unsigned int _size; unsigned int _pos; unsigned int _mask; @@ -658,7 +658,7 @@ extern "C" { } tZeroCrossingCollector; void tZeroCrossingCollector_init (tZeroCrossingCollector** const, int windowSize, Lfloat hysteresis, LEAF* const leaf); - void tZeroCrossingCollector_initToPool (tZeroCrossingCollector** const, int windowSize, Lfloat hysteresis, tMempool* const); + void tZeroCrossingCollector_initToPool (tZeroCrossingCollector** const, int windowSize, Lfloat hysteresis, tMempool** const); void tZeroCrossingCollector_free (tZeroCrossingCollector** const); int tZeroCrossingCollector_tick (tZeroCrossingCollector* const, Lfloat s); @@ -673,14 +673,14 @@ extern "C" { Lfloat tZeroCrossingCollector_getPeak (tZeroCrossingCollector* const zc); int tZeroCrossingCollector_isReset (tZeroCrossingCollector* const zc); - tZeroCrossingInfo const tZeroCrossingCollector_getCrossing (tZeroCrossingCollector* const zc, int index); + tZeroCrossingInfo* const tZeroCrossingCollector_getCrossing (tZeroCrossingCollector* const zc, int index); void tZeroCrossingCollector_setHysteresis (tZeroCrossingCollector* const zc, Lfloat hysteresis); //============================================================================== typedef struct tBitset { - tMempool mempool; + tMempool* mempool; unsigned int _value_size; unsigned int _size; @@ -689,7 +689,7 @@ extern "C" { } tBitset; void tBitset_init (tBitset** const bitset, int numBits, LEAF* const leaf); - void tBitset_initToPool (tBitset** const bitset, int numBits, tMempool* const mempool); + void tBitset_initToPool (tBitset** const bitset, int numBits, tMempool** const mempool); void tBitset_free (tBitset** const bitset); int tBitset_get (tBitset* const bitset, int index); @@ -705,18 +705,18 @@ extern "C" { typedef struct tBACF { - tMempool mempool; + tMempool* mempool; - tBitset _bitset; + tBitset* _bitset; unsigned int _mid_array; } tBACF; - void tBACF_init (tBACF** const bacf, tBitset* const bitset, LEAF* const leaf); - void tBACF_initToPool (tBACF** const bacf, tBitset* const bitset, tMempool* const mempool); + void tBACF_init (tBACF** const bacf, tBitset** const bitset, LEAF* const leaf); + void tBACF_initToPool (tBACF** const bacf, tBitset** const bitset, tMempool** const mempool); void tBACF_free (tBACF** const bacf); int tBACF_getCorrelation (tBACF* const bacf, int pos); - void tBACF_set (tBACF* const bacf, tBitset* const bitset); + void tBACF_set (tBACF* const bacf, tBitset** const bitset); //============================================================================== @@ -726,17 +726,17 @@ extern "C" { @brief Period detection algorithm from Joel de Guzman's Q Audio DSP Library @{ - @fn void tPeriodDetector_init (tPeriodDetector* const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat hysteresis, LEAF* const leaf) + @fn void tPeriodDetector_init(tPeriodDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat hysteresis, LEAF* const leaf) @brief Initialize a tPeriodDetector to the default mempool of a LEAF instance. @param @param leaf A pointer to the leaf instance. - @fn void tPeriodDetector_initToPool (tPeriodDetector* const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat hysteresis, tMempool* const mempool) + @fn void tPeriodDetector_initToPool(tPeriodDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat hysteresis, tMempool** const mempool) @brief Initialize a tPeriodDetector to a specified mempool. @param @param mempool A pointer to the tMempool to use. - @fn void tPeriodDetector_free (tPeriodDetector* const detector) + @fn void tPeriodDetector_free(tPeriodDetector** const detector) @brief Free a tPeriodDetector from its mempool. @param detector A pointer to the tPeriodDetector to free. @@ -790,14 +790,14 @@ extern "C" { typedef struct _sub_collector { - tMempool mempool; + tMempool* mempool; Lfloat _first_period; _auto_correlation_info _fundamental; // passed in, not initialized - tZeroCrossingCollector _zc; + tZeroCrossingCollector* _zc; Lfloat _harmonic_threshold; Lfloat _periodicity_diff_threshold; @@ -812,13 +812,13 @@ extern "C" { typedef struct tPeriodDetector { - tMempool mempool; + tMempool* mempool; - tZeroCrossingCollector _zc; + tZeroCrossingCollector* _zc; _period_info _fundamental; unsigned int _min_period; int _range; - tBitset _bits; + tBitset* _bits; Lfloat _weight; unsigned int _mid_point; Lfloat _periodicity_diff_threshold; @@ -832,12 +832,12 @@ extern "C" { Lfloat lowestFreq; Lfloat highestFreq; - tBACF _bacf; + tBACF* _bacf; } tPeriodDetector; void tPeriodDetector_init (tPeriodDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat hysteresis, LEAF* const leaf); - void tPeriodDetector_initToPool (tPeriodDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat hysteresis, tMempool* const mempool); + void tPeriodDetector_initToPool (tPeriodDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat hysteresis, tMempool** const mempool); void tPeriodDetector_free (tPeriodDetector** const detector); int tPeriodDetector_tick (tPeriodDetector* const detector, Lfloat sample); @@ -860,7 +860,7 @@ extern "C" { @brief Pitch detection algorithm from Joel de Guzman's Q Audio DSP Library @{ - @fn void tPitchDetector_init (tPitchDetector* const detector, Lfloat lowestFreq, Lfloat highestFreq, LEAF* const leaf) + @fn void tPitchDetector_init(tPitchDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, LEAF* const leaf) @brief Initialize a tPitchDetector to the default mempool of a LEAF instance. @param detector A pointer to the relevant tPitchDetector. @param lowestFreq @@ -868,14 +868,14 @@ extern "C" { @param leaf A pointer to the leaf instance. - @fn void tPitchDetector_initToPool (tPitchDetector* const detector, Lfloat lowestFreq, Lfloat highestFreq, tMempool* const mempool) + @fn void tPitchDetector_initToPool(tPitchDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, tMempool** const mempool) @brief Initialize a tPitchDetector to a specified mempool. @param detector A pointer to the relevant tPitchDetector. @param lowestFreq @param highestFreq @param mempool A pointer to the tMempool to use. - @fn void tPitchDetector_free (tPitchDetector* const detector) + @fn void tPitchDetector_free(tPitchDetector** const detector) @brief Free a tPitchDetector from its mempool. @param detector A pointer to the relevant tPitchDetector. @@ -920,10 +920,10 @@ extern "C" { typedef struct tPitchDetector { + + tMempool* mempool; - tMempool mempool; - - tPeriodDetector _pd; + tPeriodDetector* _pd; _pitch_info _current; int _frames_after_shift;// = 0; @@ -932,7 +932,7 @@ extern "C" { } tPitchDetector; void tPitchDetector_init (tPitchDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, LEAF* const leaf); - void tPitchDetector_initToPool (tPitchDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, tMempool* const mempool); + void tPitchDetector_initToPool (tPitchDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, tMempool** const mempool); void tPitchDetector_free (tPitchDetector** const detector); int tPitchDetector_tick (tPitchDetector* const detector, Lfloat sample); @@ -954,7 +954,7 @@ extern "C" { @brief Combined pitch detection algorithm using both Joel de Guzman's Q Audio DSP Library and Katya Vetters algorithms @{ - @fn void tDualPitchDetector_init (tDualPitchDetector* const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat* inBuffer, int bufSize, LEAF* const leaf) + @fn void tDualPitchDetector_init(tDualPitchDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat* inBuffer, int bufSize, LEAF* const leaf) @brief Initialize a tDualPitchDetector to the default mempool of a LEAF instance. @param detector A pointer to the relevant tDualPitchDetector. @param lowestFreq @@ -963,7 +963,7 @@ extern "C" { @param bufferSize Size of the input buffer. @param leaf A pointer to the leaf instance. - @fn void tDualPitchDetector_initToPool (tDualPitchDetector* const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat* inBuffer, int bufSize, tMempool* const mempool) + @fn void tDualPitchDetector_initToPool(tDualPitchDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat* inBuffer, int bufSize, tMempool** const mempool) @brief Initialize a tDualPitchDetector to a specified mempool. @param detector A pointer to the relevant tPitchDualDetector. @param lowestFreq @@ -972,7 +972,7 @@ extern "C" { @param bufferSize Size of the input buffer. @param mempool A pointer to the tMempool to use. - @fn void tDualPitchDetector_free (tDualPitchDetector* const detector) + @fn void tDualPitchDetector_free(tDualPitchDetector** const detector) @brief Free a tDualPitchDetector from its mempool. @param detector A pointer to the relevant tDualPitchDetector. @@ -1016,10 +1016,10 @@ extern "C" { typedef struct tDualPitchDetector { - tMempool mempool; + tMempool* mempool; - tPeriodDetection _pd1; - tPitchDetector _pd2; + tPeriodDetection* _pd1; + tPitchDetector* _pd2; _pitch_info _current; Lfloat _mean; Lfloat _predicted_frequency; @@ -1033,7 +1033,7 @@ extern "C" { } tDualPitchDetector; void tDualPitchDetector_init (tDualPitchDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat* inBuffer, int bufSize, LEAF* const leaf); - void tDualPitchDetector_initToPool (tDualPitchDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat* inBuffer, int bufSize, tMempool* const mempool); + void tDualPitchDetector_initToPool (tDualPitchDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat* inBuffer, int bufSize, tMempool** const mempool); void tDualPitchDetector_free (tDualPitchDetector** const detector); int tDualPitchDetector_tick (tDualPitchDetector* const detector, Lfloat sample); diff --git a/leaf/Inc/leaf-delay.h b/leaf/Inc/leaf-delay.h index aac4ff2..17c0420 100644 --- a/leaf/Inc/leaf-delay.h +++ b/leaf/Inc/leaf-delay.h @@ -34,21 +34,21 @@ extern "C" { @brief Non-interpolating delay, reimplemented from STK (Cook and Scavone). @{ - @fn void tDelay_init (tDelay* const, uint32_t delay, uint32_t maxDelay, LEAF* const leaf) + @fn void tDelay_init(tDelay** const, uint32_t delay, uint32_t maxDelay, LEAF* const leaf) @brief Initialize a tDelay to the default mempool of a LEAF instance. @param delay A pointer to the tDelay to initialize. @param initalLength @param maxLength @param leaf A pointer to the leaf instance. - @fn void tDelay_initToPool (tDelay* const, uint32_t delay, uint32_t maxDelay, tMempool* const) + @fn void tDelay_initToPool(tDelay** const, uint32_t delay, uint32_t maxDelay, tMempool** const) @brief Initialize a tDelay to a specified mempool. @param delay A pointer to the tDelay to initialize. @param initalLength @param maxLength @param mempool A pointer to the tMempool to use. - @fn void tDelay_free (tDelay* const) + @fn void tDelay_free(tDelay** const) @brief Free a tDelay from its mempool. @param delay A pointer to the tDelay to free. @@ -105,7 +105,7 @@ extern "C" { typedef struct tDelay { - tMempool mempool; + tMempool* mempool; Lfloat gain; Lfloat* buff; @@ -119,7 +119,7 @@ extern "C" { } tDelay; void tDelay_init (tDelay** const, uint32_t delay, uint32_t maxDelay, LEAF* const leaf); - void tDelay_initToPool (tDelay** const, uint32_t delay, uint32_t maxDelay, tMempool* const); + void tDelay_initToPool (tDelay** const, uint32_t delay, uint32_t maxDelay, tMempool** const); void tDelay_free (tDelay** const); Lfloat tDelay_tick (tDelay* const, Lfloat sample); @@ -141,21 +141,21 @@ extern "C" { @brief Linearly-interpolating delay, reimplemented from STK (Cook and Scavone). @{ - @fn void tLinearDelay_init (tLinearDelay* const, Lfloat delay, uint32_t maxDelay, LEAF* const leaf) + @fn void tLinearDelay_init(tLinearDelay** const, Lfloat delay, uint32_t maxDelay, LEAF* const leaf) @brief Initialize a tLinearDelay to the default mempool of a LEAF instance. @param delay A pointer to the tLinearDelay to initialize. @param initialLength @param maxLength @param leaf A pointer to the leaf instance. - @fn void tLinearDelay_initToPool (tLinearDelay* const, Lfloat delay, uint32_t maxDelay, tMempool* const) + @fn void tLinearDelay_initToPool(tLinearDelay** const, Lfloat delay, uint32_t maxDelay, tMempool** const) @brief Initialize a tLinearDelay to a specified mempool. @param delay A pointer to the tLinearDelay to initialize. @param initialLength @param maxLength @param mempool A pointer to the tMempool to use. - @fn void tLinearDelay_free (tLinearDelay* const) + @fn void tLinearDelay_free(tLinearDelay** const) @brief Free a tLinearDelay from its mempool. @param delay A pointer to the tLinearDelay to free. @@ -222,7 +222,7 @@ extern "C" { typedef struct tLinearDelay { - tMempool mempool; + tMempool* mempool; Lfloat gain; Lfloat* buff; @@ -240,7 +240,7 @@ extern "C" { } tLinearDelay; void tLinearDelay_init (tLinearDelay** const, Lfloat delay, uint32_t maxDelay, LEAF* const leaf); - void tLinearDelay_initToPool (tLinearDelay** const, Lfloat delay, uint32_t maxDelay, tMempool* const); + void tLinearDelay_initToPool (tLinearDelay** const, Lfloat delay, uint32_t maxDelay, tMempool** const); void tLinearDelay_free (tLinearDelay** const); Lfloat tLinearDelay_tick (tLinearDelay* const, Lfloat sample); @@ -267,21 +267,21 @@ extern "C" { @brief Hermite-interpolating delay, created by adapting STK linear delay with Hermite interpolation. @{ - @fn void tHermiteDelay_init (tHermiteDelay* const dl, Lfloat delay, uint32_t maxDelay, LEAF* const leaf) + @fn void tHermiteDelay_init(tHermiteDelay** const dl, Lfloat delay, uint32_t maxDelay, LEAF* const leaf) @brief Initialize a tHermiteDelay to the default mempool of a LEAF instance. @param delay A pointer to the tHermiteDelay to initialize. @param initialLength @param maxLength @param leaf A pointer to the leaf instance. - @fn void tHermiteDelay_initToPool (tHermiteDelay* const dl, Lfloat delay, uint32_t maxDelay, tMempool* const mp) + @fn void tHermiteDelay_initToPool(tHermiteDelay** const dl, Lfloat delay, uint32_t maxDelay, tMempool** const mp) @brief Initialize a tHermiteDelay to a specified mempool. @param delay A pointer to the tHermiteDelay to initialize. @param initialLength @param maxLength @param mempool A pointer to the tMempool to use. - @fn void tHermiteDelay_free (tHermiteDelay* const dl) + @fn void tHermiteDelay_free(tHermiteDelay** const dl) @brief Free a tHermiteDelay from its mempool. @param delay A pointer to the tHermiteDelay to free. @@ -365,7 +365,7 @@ extern "C" { typedef struct tHermiteDelay { - tMempool mempool; + tMempool* mempool; Lfloat* buff; uint32_t bufferMask; @@ -381,7 +381,7 @@ extern "C" { } tHermiteDelay; void tHermiteDelay_init (tHermiteDelay** const dl, Lfloat delay, uint32_t maxDelay, LEAF* const leaf); - void tHermiteDelay_initToPool (tHermiteDelay** const dl, Lfloat delay, uint32_t maxDelay, tMempool* const mp); + void tHermiteDelay_initToPool (tHermiteDelay** const dl, Lfloat delay, uint32_t maxDelay, tMempool** const mp); void tHermiteDelay_free (tHermiteDelay** const dl); Lfloat tHermiteDelay_tick (tHermiteDelay* const dl, Lfloat input); @@ -411,21 +411,21 @@ extern "C" { @brief Hermite-interpolating delay, created by adapting STK linear delay with Hermite interpolation. @{ - @fn void tHermiteDelay_init (tHermiteDelay* const dl, Lfloat delay, uint32_t maxDelay, LEAF* const leaf) + @fn void tHermiteDelay_init(tHermiteDelay** const dl, Lfloat delay, uint32_t maxDelay, LEAF* const leaf) @brief Initialize a tHermiteDelay to the default mempool of a LEAF instance. @param delay A pointer to the tHermiteDelay to initialize. @param initialLength @param maxLength @param leaf A pointer to the leaf instance. - @fn void tHermiteDelay_initToPool (tHermiteDelay* const dl, Lfloat delay, uint32_t maxDelay, tMempool* const mp) + @fn void tHermiteDelay_initToPool(tHermiteDelay** const dl, Lfloat delay, uint32_t maxDelay, tMempool** const mp) @brief Initialize a tHermiteDelay to a specified mempool. @param delay A pointer to the tHermiteDelay to initialize. @param initialLength @param maxLength @param mempool A pointer to the tMempool to use. - @fn void tHermiteDelay_free (tHermiteDelay* const dl) + @fn void tHermiteDelay_free(tHermiteDelay** const dl) @brief Free a tHermiteDelay from its mempool. @param delay A pointer to the tHermiteDelay to free. @@ -500,7 +500,7 @@ extern "C" { typedef struct tLagrangeDelay { - tMempool mempool; + tMempool* mempool; Lfloat* buff; uint32_t bufferMask; @@ -519,7 +519,7 @@ extern "C" { } tLagrangeDelay; void tLagrangeDelay_init (tLagrangeDelay** const dl, Lfloat delay, uint32_t maxDelay, LEAF* const leaf); - void tLagrangeDelay_initToPool (tLagrangeDelay** const dl, Lfloat delay, uint32_t maxDelay, tMempool* const mp); + void tLagrangeDelay_initToPool (tLagrangeDelay** const dl, Lfloat delay, uint32_t maxDelay, tMempool** const mp); void tLagrangeDelay_free (tLagrangeDelay** const dl); Lfloat tLagrangeDelay_tick (tLagrangeDelay* const dl, Lfloat input); @@ -545,21 +545,21 @@ extern "C" { @brief Allpass-interpolating delay, reimplemented from STK (Cook and Scavone). @{ - @fn void tAllpassDelay_init (tAllpassDelay* const, Lfloat delay, uint32_t maxDelay, LEAF* const leaf) + @fn void tAllpassDelay_init(tAllpassDelay** const, Lfloat delay, uint32_t maxDelay, LEAF* const leaf) @brief Initialize a tAllpassDelay to the default mempool of a LEAF instance. @param delay A pointer to the tAllpassDelay to initialize. @param initialLength @param maxLength @param leaf A pointer to the leaf instance. - @fn void tAllpassDelay_initToPool (tAllpassDelay* const, Lfloat delay, uint32_t maxDelay, tMempool* const) + @fn void tAllpassDelay_initToPool(tAllpassDelay** const, Lfloat delay, uint32_t maxDelay, tMempool** const) @brief Initialize a tAllpassDelay to a specified mempool. @param delay A pointer to the tAllpassDelay to initialize. @param initialLength @param maxLength @param mempool A pointer to the tMempool to use. - @fn void tAllpassDelay_free (tAllpassDelay* const) + @fn void tAllpassDelay_free(tAllpassDelay** const) @brief Free a tAllpassDelay from its mempool. @param delay A pointer to the tAllpassDelay to free. @@ -616,7 +616,7 @@ extern "C" { typedef struct tAllpassDelay { - tMempool mempool; + tMempool* mempool; Lfloat gain; Lfloat* buff; @@ -636,7 +636,7 @@ extern "C" { } tAllpassDelay; void tAllpassDelay_init (tAllpassDelay** const, Lfloat delay, uint32_t maxDelay, LEAF* const leaf); - void tAllpassDelay_initToPool (tAllpassDelay** const, Lfloat delay, uint32_t maxDelay, tMempool* const); + void tAllpassDelay_initToPool (tAllpassDelay** const, Lfloat delay, uint32_t maxDelay, tMempool** const); void tAllpassDelay_free (tAllpassDelay** const); Lfloat tAllpassDelay_tick (tAllpassDelay* const, Lfloat sample); @@ -658,21 +658,21 @@ extern "C" { @brief Linear interpolating delay with fixed read and write pointers, variable rate. @{ - @fn void tTapeDelay_init (tTapeDelay* const, Lfloat delay, uint32_t maxDelay, LEAF* const leaf) + @fn void tTapeDelay_init(tTapeDelay** const, Lfloat delay, uint32_t maxDelay, LEAF* const leaf) @brief Initialize a tTapeDelay to the default mempool of a LEAF instance. @param delay A pointer to the tTapeDelay to initialize. @param initialLength @param maxLength @param leaf A pointer to the leaf instance. - @fn void tTapeDelay_initToPool (tTapeDelay* const, Lfloat delay, uint32_t maxDelay, tMempool* const) + @fn void tTapeDelay_initToPool(tTapeDelay** const, Lfloat delay, uint32_t maxDelay, tMempool** const) @brief Initialize a tTapeDelay to a specified mempool. @param delay A pointer to the tTapeDelay to initialize. @param initialLength @param maxLength @param mempool A pointer to the tMempool to use. - @fn void tTapeDelay_free (tTapeDelay* const) + @fn void tTapeDelay_free(tTapeDelay** const) @brief Free a tTapeDelay from its mempool. @param delay A pointer to the tTapeDelay to free. @@ -733,7 +733,7 @@ extern "C" { typedef struct tTapeDelay { - tMempool mempool; + tMempool* mempool; Lfloat gain; Lfloat* buff; @@ -751,7 +751,7 @@ extern "C" { } tTapeDelay; void tTapeDelay_init (tTapeDelay** const, Lfloat delay, uint32_t maxDelay, LEAF* const leaf); - void tTapeDelay_initToPool (tTapeDelay** const, Lfloat delay, uint32_t maxDelay, tMempool* const); + void tTapeDelay_initToPool (tTapeDelay** const, Lfloat delay, uint32_t maxDelay, tMempool** const); void tTapeDelay_free (tTapeDelay** const); Lfloat tTapeDelay_tick (tTapeDelay* const, Lfloat sample); @@ -774,19 +774,19 @@ extern "C" { @brief Ring buffer. @{ - @fn void tRingBuffer_init (tRingBuffer* const ring, int size, LEAF* const leaf) + @fn void tRingBuffer_init(tRingBuffer** const ring, int size, LEAF* const leaf) @brief Initialize a tRingBuffer to the default mempool of a LEAF instance. @param buffer A pointer to the tRingbuffer to initialize. @param size Size of the buffer. Should be a power of 2. Will otherwise be adjusted to the nearest greater power of 2. @param leaf A pointer to the leaf instance. - @fn void tRingBuffer_initToPool (tRingBuffer* const ring, int size, tMempool* const mempool) + @fn void tRingBuffer_initToPool(tRingBuffer** const ring, int size, tMempool** const mempool) @brief Initialize a tRingBuffer to a specified mempool. @param buffer A pointer to the tRingbuffer to initialize. @param size Size of the buffer. Should be a power of 2. Will otherwise be adjusted to the nearest greater power of 2. @param mempool A pointer to the tMempool to use. - @fn void tRingBuffer_free (tRingBuffer* const ring) + @fn void tRingBuffer_free(tRingBuffer** const ring) @brief Free a tRingBuffer from its mempool. @param buffer A pointer to the tRingBuffer to free. @@ -819,8 +819,8 @@ extern "C" { @} */ typedef struct tRingBuffer { - - tMempool mempool; + + tMempool* mempool; Lfloat* buffer; unsigned int size; @@ -829,7 +829,7 @@ extern "C" { } tRingBuffer; void tRingBuffer_init (tRingBuffer** const ring, int size, LEAF* const leaf); - void tRingBuffer_initToPool (tRingBuffer** const ring, int size, tMempool* const mempool); + void tRingBuffer_initToPool (tRingBuffer** const ring, int size, tMempool** const mempool); void tRingBuffer_free (tRingBuffer** const ring); void tRingBuffer_push (tRingBuffer* const ring, Lfloat val); diff --git a/leaf/Inc/leaf-distortion.h b/leaf/Inc/leaf-distortion.h index c558ae8..bd0bc91 100644 --- a/leaf/Inc/leaf-distortion.h +++ b/leaf/Inc/leaf-distortion.h @@ -36,17 +36,17 @@ extern "C" { @brief Sample rate reducer. @{ - @fn void tSampleReducer_init (tSampleReducer* const, LEAF* const leaf) + @fn void tSampleReducer_init(tSampleReducer** const, LEAF* const leaf) @brief Initialize a tSampleReducer to the default mempool of a LEAF instance. @param reducer A pointer to the tSampleReducer to initialize. @param leaf A pointer to the leaf instance. - @fn void tSampleReducer_initToPool (tSampleReducer* const, tMempool* const) + @fn void tSampleReducer_initToPool(tSampleReducer** const, tMempool** const) @brief Initialize a tSampleReducer to a specified mempool. @param reducer A pointer to the tSampleReducer to initialize. @param mempool A pointer to the tMempool to use. - @fn void tSampleReducer_free (tSampleReducer* const) + @fn void tSampleReducer_free(tSampleReducer** const) @brief Free a tSampleReducer from its mempool. @param reducer A pointer to the tSampleReducer to free. @@ -62,14 +62,14 @@ extern "C" { typedef struct tSampleReducer { - tMempool mempool; + tMempool* mempool; Lfloat invRatio; Lfloat hold; uint32_t count; } tSampleReducer; void tSampleReducer_init (tSampleReducer** const, LEAF* const leaf); - void tSampleReducer_initToPool (tSampleReducer** const, tMempool* const); + void tSampleReducer_initToPool (tSampleReducer** const, tMempool** const); void tSampleReducer_free (tSampleReducer** const); Lfloat tSampleReducer_tick (tSampleReducer* const, Lfloat input); @@ -83,17 +83,17 @@ extern "C" { @brief Oversampler. @{ - @fn void tOversampler_init (tOversampler* const, int order, int extraQuality, LEAF* const leaf) + @fn void tOversampler_init(tOversampler** const, int order, int extraQuality, LEAF* const leaf) @brief Initialize a tOversampler to the default mempool of a LEAF instance. @param oversampler A pointer to the tOversampler to initialize. @param leaf A pointer to the leaf instance. - @fn void tOversampler_initToPool (tOversampler* const, int order, int extraQuality, tMempool* const) + @fn void tOversampler_initToPool(tOversampler** const, int order, int extraQuality, tMempool** const) @brief Initialize a tOversampler to a specified mempool. @param oversampler A pointer to the tOversampler to initialize. @param mempool A pointer to the tMempool to use. - @fn void tOversampler_free (tOversampler* const) + @fn void tOversampler_free(tOversampler** const) @brief Free a tOversampler from its mempool. @param oversampler A pointer to the tOversampler to free. @@ -122,7 +122,7 @@ extern "C" { typedef struct tOversampler { - tMempool mempool; + tMempool* mempool; uint32_t maxRatio; uint8_t allowHighQuality; uint32_t ratio; @@ -135,7 +135,7 @@ extern "C" { } tOversampler; void tOversampler_init (tOversampler** const, int order, int extraQuality, LEAF* const leaf); - void tOversampler_initToPool (tOversampler** const, int order, int extraQuality, tMempool* const); + void tOversampler_initToPool (tOversampler** const, int order, int extraQuality, tMempool** const); void tOversampler_free (tOversampler** const); Lfloat tOversampler_tick (tOversampler* const, Lfloat input, Lfloat* oversample, Lfloat (*effectTick)(Lfloat)); @@ -153,17 +153,17 @@ extern "C" { @brief more efficient and simpler wavefolder. @{ - @fn void tWavefolder_init (tWavefolder* const, LEAF* const leaf) + @fn void tWavefolder_init(tWavefolder** const, LEAF* const leaf) @brief Initialize a tWavefolder to the default mempool of a LEAF instance. @param wavefolder A pointer to the tWavefolder to initialize. @param leaf A pointer to the leaf instance. - @fn void tWavefolder_initToPool (tWavefolder* const, tMempool* const) + @fn void tWavefolder_initToPool(tWavefolder** const, tMempool** const) @brief Initialize a tWavefolder to a specified mempool. @param wavefolder A pointer to the tWavefolder to initialize. @param mempool A pointer to the tMempool to use. - @fn void tWavefolder_free (tWavefolder* const) + @fn void tWavefolder_free(tWavefolder** const) @brief Free a tWavefolder from its mempool. @param wavefolder A pointer to the tWavefolder to free. @@ -175,8 +175,8 @@ extern "C" { typedef struct tWavefolder { - - tMempool mempool; + + tMempool* mempool; Lfloat FBsample; Lfloat gain; @@ -185,11 +185,11 @@ typedef struct tWavefolder Lfloat FBAmount; Lfloat invFBAmount; Lfloat FFAmount; - tHighpass dcBlock; + tHighpass* dcBlock; } tWavefolder; void tWavefolder_init (tWavefolder** const, Lfloat ffAmount, Lfloat fbAmount, Lfloat foldDepth, LEAF* const leaf); -void tWavefolder_initToPool (tWavefolder** const, Lfloat ffAmount, Lfloat fbAmount, Lfloat foldDepth, tMempool* const); +void tWavefolder_initToPool (tWavefolder** const, Lfloat ffAmount, Lfloat fbAmount, Lfloat foldDepth, tMempool** const); void tWavefolder_free (tWavefolder** const); Lfloat tWavefolder_tick (tWavefolder* const, Lfloat samp); @@ -209,17 +209,17 @@ void tWavefolder_setGain (tWavefolder* const wf, Lfloat gain); @brief Analog model wavefolder. @{ - @fn void tLockhartWavefolder_init (tLockhartWavefolder* const, LEAF* const leaf) + @fn void tLockhartWavefolder_init(tLockhartWavefolder** const, LEAF* const leaf) @brief Initialize a tLockhartWavefolder to the default mempool of a LEAF instance. @param wavefolder A pointer to the tLockhartWavefolder to initialize. @param leaf A pointer to the leaf instance. - @fn void tLockhartWavefolder_initToPool (tLockhartWavefolder* const, tMempool* const) + @fn void tLockhartWavefolder_initToPool(tLockhartWavefolder** const, tMempool** const) @brief Initialize a tLockhartWavefolder to a specified mempool. @param wavefolder A pointer to the tLockhartWavefolder to initialize. @param mempool A pointer to the tMempool to use. - @fn void tLockhartWavefolder_free (tLockhartWavefolder* const) + @fn void tLockhartWavefolder_free(tLockhartWavefolder** const) @brief Free a tLockhartWavefolder from its mempool. @param wavefolder A pointer to the tLockhartWavefolder to free. @@ -231,8 +231,8 @@ void tWavefolder_setGain (tWavefolder* const wf, Lfloat gain); typedef struct tLockhartWavefolder { - - tMempool mempool; + + tMempool* mempool; double Ln1; double Fn1; @@ -262,7 +262,7 @@ void tWavefolder_setGain (tWavefolder* const wf, Lfloat gain); } tLockhartWavefolder; void tLockhartWavefolder_init (tLockhartWavefolder** const, LEAF* const leaf); - void tLockhartWavefolder_initToPool (tLockhartWavefolder** const, tMempool* const); + void tLockhartWavefolder_initToPool (tLockhartWavefolder** const, tMempool** const); void tLockhartWavefolder_free (tLockhartWavefolder** const); Lfloat tLockhartWavefolder_tick (tLockhartWavefolder* const, Lfloat samp); @@ -275,17 +275,17 @@ void tWavefolder_setGain (tWavefolder* const wf, Lfloat gain); @brief Bit depth and sampler rate degrader. @{ - @fn void tCrusher_init (tCrusher* const, LEAF* const leaf) + @fn void tCrusher_init(tCrusher** const, LEAF* const leaf) @brief Initialize a tCrusher to the default mempool of a LEAF instance. @param crusher A pointer to the tCrusher to initialize. @param leaf A pointer to the leaf instance.f - @fn void tCrusher_initToPool (tCrusher* const, tMempool* const) + @fn void tCrusher_initToPool(tCrusher** const, tMempool** const) @brief Initialize a tCrusher to a specified mempool. @param crusher A pointer to the tCrusher to initialize. @param mempool A pointer to the tMempool to use. - @fn void tCrusher_free (tCrusher* const) + @fn void tCrusher_free(tCrusher** const) @brief Free a tCrusher from its mempool. @param crusher A pointer to the tCrusher to free. @@ -317,8 +317,8 @@ void tWavefolder_setGain (tWavefolder* const wf, Lfloat gain); typedef struct tCrusher { - - tMempool mempool; + + tMempool* mempool; Lfloat srr; Lfloat mult, div; @@ -327,12 +327,12 @@ void tWavefolder_setGain (tWavefolder* const wf, Lfloat gain); uint32_t op; //which bitwise operation (0-7) Lfloat gain; - tSampleReducer sReducer; + tSampleReducer* sReducer; } tCrusher; void tCrusher_init (tCrusher** const, LEAF* const leaf); - void tCrusher_initToPool (tCrusher** const, tMempool* const); + void tCrusher_initToPool (tCrusher** const, tMempool** const); void tCrusher_free (tCrusher** const); Lfloat tCrusher_tick (tCrusher* const, Lfloat input); diff --git a/leaf/Inc/leaf-dynamics.h b/leaf/Inc/leaf-dynamics.h index 614fc4f..f1049ab 100644 --- a/leaf/Inc/leaf-dynamics.h +++ b/leaf/Inc/leaf-dynamics.h @@ -37,17 +37,17 @@ extern "C" { @brief Standard compressor. @{ - @fn void tCompressor_init (tCompressor* const, LEAF* const leaf) + @fn void tCompressor_init(tCompressor** const, LEAF* const leaf) @brief Initialize a tCompressor to the default mempool of a LEAF instance. @param compressor A pointer to the tCompressor to initialize. @param leaf A pointer to the leaf instance. - @fn void tCompressor_initToPool (tCompressor* const, tMempool* const) + @fn void tCompressor_initToPool(tCompressor** const, tMempool** const) @brief Initialize a tCompressor to a specified mempool. @param compressor A pointer to the tCompressor to initialize. @param mempool A pointer to the tMempool to use. - @fn void tCompressor_free (tCompressor* const) + @fn void tCompressor_free(tCompressor** const) @brief Free a tCompressor from its mempool. @param compressor A pointer to the tCompressor to free. @@ -60,7 +60,7 @@ extern "C" { typedef struct tCompressor { - tMempool mempool; + tMempool* mempool; Lfloat tauAttack, tauRelease; Lfloat T, R, W, M; // Threshold, compression Ratio, decibel Width of knee transition, decibel Make-up gain @@ -83,7 +83,7 @@ extern "C" { } tCompressor; void tCompressor_init (tCompressor** const, LEAF* const leaf); - void tCompressor_initToPool (tCompressor** const, tMempool* const); + void tCompressor_initToPool (tCompressor** const, tMempool** const); void tCompressor_free (tCompressor** const); Lfloat tCompressor_tick (tCompressor* const, Lfloat input); @@ -101,17 +101,17 @@ extern "C" { @details An auto VCA that you put into a feedback circuit to make it stay at the same level. It can enforce level bidirectionally (amplifying and attenuating as needed) or just attenutating. The former option allows for infinite sustain strings, for example, while the latter option allows for decaying strings, which can never exceed a specific level. @{ - @fn void tFeedbackLeveler_init (tFeedbackLeveler* const, Lfloat targetLevel, Lfloat factor, Lfloat strength, int mode, LEAF* const leaf) + @fn void tFeedbackLeveler_init(tFeedbackLeveler** const, Lfloat targetLevel, Lfloat factor, Lfloat strength, int mode, LEAF* const leaf) @brief Initialize a tFeedbackLeveler to the default mempool of a LEAF instance. @param leveler A pointer to the tFeedbackLeveler to initialize. @param leaf A pointer to the leaf instance. - @fn void tFeedbackLeveler_initToPool (tFeedbackLeveler* const, Lfloat targetLevel, Lfloat factor, Lfloat strength, int mode, tMempool* const) + @fn void tFeedbackLeveler_initToPool(tFeedbackLeveler** const, Lfloat targetLevel, Lfloat factor, Lfloat strength, int mode, tMempool** const) @brief Initialize a tFeedbackLeveler to a specified mempool. @param leveler A pointer to the tFeedbackLeveler to initialize. @param mempool A pointer to the tMempool to use. - @fn void tFeedbackLeveler_free (tFeedbackLeveler* const) + @fn void tFeedbackLeveler_free(tFeedbackLeveler** const) @brief Free a tFeedbackLeveler from its mempool. @param leveler A pointer to the tFeedbackLeveler to free. @@ -144,18 +144,18 @@ extern "C" { typedef struct tFeedbackLeveler { - - tMempool mempool; + + tMempool* mempool; Lfloat targetLevel; // target power level Lfloat strength; // how strongly level difference affects the VCA int mode; // 0 for upwards limiting only, 1 for biderctional limiting Lfloat curr; - tPowerFollower pwrFlw; // internal power follower needed for level tracking + tPowerFollower* pwrFlw; // internal power follower needed for level tracking } tFeedbackLeveler; void tFeedbackLeveler_init (tFeedbackLeveler** const, Lfloat targetLevel, Lfloat factor, Lfloat strength, int mode, LEAF* const leaf); - void tFeedbackLeveler_initToPool (tFeedbackLeveler** const, Lfloat targetLevel, Lfloat factor, Lfloat strength, int mode, tMempool* const); + void tFeedbackLeveler_initToPool (tFeedbackLeveler** const, Lfloat targetLevel, Lfloat factor, Lfloat strength, int mode, tMempool** const); void tFeedbackLeveler_free (tFeedbackLeveler** const); Lfloat tFeedbackLeveler_tick (tFeedbackLeveler* const, Lfloat input); @@ -175,17 +175,17 @@ extern "C" { @brief Threshold with hysteresis (like Max/MSP thresh~ object) @{ - @fn void tThreshold_init (tThreshold* const, Lfloat low, Lfloat high, LEAF* const leaf) + @fn void tThreshold_init(tThreshold** const, Lfloat low, Lfloat high, LEAF* const leaf) @brief Initialize a tThreshold to the default mempool of a LEAF instance. @param threshold A pointer to the tThreshold to initialize. @param leaf A pointer to the leaf instance. - @fn void tThreshold_initToPool (tThreshold* const, Lfloat low, Lfloat high, tMempool* const) + @fn void tThreshold_initToPool(tThreshold** const, Lfloat low, Lfloat high, tMempool** const) @brief Initialize a tThreshold to a specified mempool. @param threshold A pointer to the tThreshold to initialize. @param mempool A pointer to the tMempool to use. - @fn void tThreshold_free (tThreshold* const) + @fn void tThreshold_free(tThreshold** const) @brief Free a tThreshold from its mempool. @param threshold A pointer to the tThreshold to free. @@ -205,14 +205,14 @@ extern "C" { typedef struct tThreshold { - - tMempool mempool; + + tMempool* mempool; Lfloat highThresh, lowThresh; int currentValue; } tThreshold; void tThreshold_init (tThreshold** const, Lfloat low, Lfloat high, LEAF* const leaf); - void tThreshold_initToPool (tThreshold** const, Lfloat low, Lfloat high, tMempool* const); + void tThreshold_initToPool (tThreshold** const, Lfloat low, Lfloat high, tMempool** const); void tThreshold_free (tThreshold** const); int tThreshold_tick (tThreshold* const, Lfloat input); diff --git a/leaf/Inc/leaf-effects.h b/leaf/Inc/leaf-effects.h index 006ac29..b13d19f 100644 --- a/leaf/Inc/leaf-effects.h +++ b/leaf/Inc/leaf-effects.h @@ -30,17 +30,17 @@ extern "C" { @brief High resolution vocoder from mda using Levinson-Durbin LPC algorithm. @{ - @fn void tTalkbox_init (tTalkbox* const, int bufsize, LEAF* const leaf) + @fn void tTalkbox_init(tTalkbox** const, int bufsize, LEAF* const leaf) @brief Initialize a tTalkbox to the default mempool of a LEAF instance. @param talkbox A pointer to the tTalkbox to initialize. @param leaf A pointer to the leaf instance. - @fn void tTalkbox_initToPool (tTalkbox* const, int bufsize, tMempool* const) + @fn void tTalkbox_initToPool(tTalkbox** const, int bufsize, tMempool** const) @brief Initialize a tTalkbox to a specified mempool. @param talkbox A pointer to the tTalkbox to initialize. @param mempool A pointer to the tMempool to use. - @fn void tTalkbox_free (tTalkbox* const) + @fn void tTalkbox_free(tTalkbox** const) @brief Free a tTalkbox from its mempool. @param talkbox A pointer to the tTalkbox to free. @@ -94,8 +94,8 @@ extern "C" { typedef struct tTalkbox { - - tMempool mempool; + + tMempool* mempool; Lfloat param[NUM_TALKBOX_PARAM]; @@ -123,7 +123,7 @@ extern "C" { } tTalkbox; void tTalkbox_init (tTalkbox** const, int bufsize, LEAF* const leaf); - void tTalkbox_initToPool (tTalkbox** const, int bufsize, tMempool* const); + void tTalkbox_initToPool (tTalkbox** const, int bufsize, tMempool** const); void tTalkbox_free (tTalkbox** const); Lfloat tTalkbox_tick (tTalkbox* const, Lfloat synth, Lfloat voice); @@ -150,17 +150,17 @@ extern "C" { @brief High resolution vocoder from mda using Levinson-Durbin LPC algorithm. @{ - @fn void tTalkboxLfloat_init (tTalkboxLfloat* const, int bufsize, LEAF* const leaf) + @fn void tTalkboxLfloat_init(tTalkboxLfloat** const, int bufsize, LEAF* const leaf) @brief Initialize a tTalkboxLfloat to the default mempool of a LEAF instance. @param talkbox A pointer to the tTalkboxLfloat to initialize. @param leaf A pointer to the leaf instance. - @fn void tTalkboxLfloat_initToPool (tTalkboxLfloat* const, int bufsize, tMempool* const) + @fn void tTalkboxLfloat_initToPool(tTalkboxLfloat** const, int bufsize, tMempool** const) @brief Initialize a tTalkboxLfloat to a specified mempool. @param talkbox A pointer to the tTalkboxLfloat to initialize. @param mempool A pointer to the tMempool to use. - @fn void tTalkboxLfloat_free (tTalkboxLfloat* const) + @fn void tTalkboxLfloat_free(tTalkboxLfloat** const) @brief Free a tTalkboxLfloat from its mempool. @param talkbox A pointer to the tTalkboxLfloat to free. @@ -212,8 +212,8 @@ extern "C" { typedef struct tTalkboxLfloat { - - tMempool mempool; + + tMempool* mempool; Lfloat param[NUM_TALKBOX_PARAM]; @@ -241,7 +241,7 @@ extern "C" { } tTalkboxLfloat; void tTalkboxLfloat_init (tTalkboxLfloat** const, int bufsize, LEAF* const leaf); - void tTalkboxLfloat_initToPool (tTalkboxLfloat** const, int bufsize, tMempool* const); + void tTalkboxLfloat_initToPool (tTalkboxLfloat** const, int bufsize, tMempool** const); void tTalkboxLfloat_free (tTalkboxLfloat** const); Lfloat tTalkboxLfloat_tick (tTalkboxLfloat* const, Lfloat synth, Lfloat voice); @@ -267,17 +267,17 @@ extern "C" { @brief Channel vocoder from mda. @{ - @fn void tVocoder_init (tVocoder* const, LEAF* const leaf) + @fn void tVocoder_init(tVocoder** const, LEAF* const leaf) @brief Initialize a tVocoder to the default mempool of a LEAF instance. @param vocoder A pointer to the tVocoder to initialize. @param leaf A pointer to the leaf instance. - @fn void tVocoder_initToPool (tVocoder* const, tMempool* const) + @fn void tVocoder_initToPool(tVocoder** const, tMempool** const) @brief Initialize a tVocoder to a specified mempool. @param vocoder A pointer to the tVocoder to initialize. @param mempool A pointer to the tMempool to use. - @fn void tVocoder_free (tVocoder* const) + @fn void tVocoder_free(tVocoder** const) @brief Free a tVocoder from its mempool. @param vocoder A pointer to the tVocoder to free. @@ -300,8 +300,8 @@ extern "C" { typedef struct tVocoder { - - tMempool mempool; + + tMempool* mempool; Lfloat param[NUM_VOCODER_PARAM]; @@ -318,7 +318,7 @@ extern "C" { } tVocoder; void tVocoder_init (tVocoder** const, LEAF* const leaf); - void tVocoder_initToPool (tVocoder** const, tMempool* const); + void tVocoder_initToPool (tVocoder** const, tMempool** const); void tVocoder_free (tVocoder** const); Lfloat tVocoder_tick (tVocoder* const, Lfloat synth, Lfloat voice); @@ -335,17 +335,17 @@ extern "C" { @brief Rosenberg glottal pulse approximator. @{ - @fn void tRosenbergGlottalPulse_init (tRosenbergGlottalPulse* const, LEAF* const leaf) + @fn void tRosenbergGlottalPulse_init(tRosenbergGlottalPulse** const, LEAF* const leaf) @brief Initialize a tRosenbergGlottalPulse to the default mempool of a LEAF instance. @param pulse A pointer to the tRosenbergGlottalPulse to initialize. @param leaf A pointer to the leaf instance. - @fn void tRosenbergGlottalPulse_initToPool (tRosenbergGlottalPulse* const, tMempool* const) + @fn void tRosenbergGlottalPulse_initToPool(tRosenbergGlottalPulse** const, tMempool** const) @brief Initialize a tRosenbergGlottalPulse to a specified mempool. @param pulse A pointer to the tRosenbergGlottalPulse to initialize. @param mempool A pointer to the tMempool to use. - @fn void tRosenbergGlottalPulse_free (tRosenbergGlottalPulse* const) + @fn void tRosenbergGlottalPulse_free(tRosenbergGlottalPulse** const) @brief Free a tRosenbergGlottalPulse from its mempool. @param pulse A pointer to the tRosenbergGlottalPulse to free. @@ -377,8 +377,8 @@ extern "C" { typedef struct tRosenbergGlottalPulse { - - tMempool mempool; + + tMempool* mempool; Lfloat phase; Lfloat openLength; Lfloat pulseLength; @@ -389,7 +389,7 @@ extern "C" { } tRosenbergGlottalPulse; void tRosenbergGlottalPulse_init (tRosenbergGlottalPulse** const, LEAF* const leaf); - void tRosenbergGlottalPulse_initToPool (tRosenbergGlottalPulse** const, tMempool* const); + void tRosenbergGlottalPulse_initToPool (tRosenbergGlottalPulse** const, tMempool** const); void tRosenbergGlottalPulse_free (tRosenbergGlottalPulse** const); Lfloat tRosenbergGlottalPulse_tick (tRosenbergGlottalPulse* const); @@ -409,17 +409,17 @@ extern "C" { @brief pitch shifting algorithm that underlies tRetune etc from Katja Vetters http://www.katjaas.nl/pitchshiftlowlatency/pitchshiftlowlatency.html @{ - @fn void tSOLAD_init (tSOLAD* const, LEAF* const leaf) + @fn void tSOLAD_init(tSOLAD** const, LEAF* const leaf) @brief Initialize a tSOLAD to the default mempool of a LEAF instance. @param solad A pointer to the tSOLAD to initialize. @param leaf A pointer to the leaf instance. - @fn void tSOLAD_initToPool (tSOLAD* const, tMempool* const) + @fn void tSOLAD_initToPool(tSOLAD** const, tMempool** const) @brief Initialize a tSOLAD to a specified mempool. @param solad A pointer to the tSOLAD to initialize. @param mempool A pointer to the tMempool to use. - @fn void tSOLAD_free (tSOLAD* const) + @fn void tSOLAD_free(tSOLAD** const) @brief Free a tSOLAD from its mempool. @param solad A pointer to the tSOLAD to free. @@ -454,10 +454,10 @@ extern "C" { typedef struct tSOLAD { - tMempool mempool; + tMempool* mempool; - tAttackDetection ad; - tHighpass hp; + tAttackDetection* ad; + tHighpass* hp; int loopSize; uint16_t timeindex; // current reference time, write index @@ -474,7 +474,7 @@ extern "C" { } tSOLAD; void tSOLAD_init (tSOLAD** const, int loopSize, LEAF* const leaf); - void tSOLAD_initToPool (tSOLAD** const, int loopSize, tMempool* const); + void tSOLAD_initToPool (tSOLAD** const, int loopSize, tMempool** const); void tSOLAD_free (tSOLAD** const); // send one block of input samples, receive one block of output samples @@ -495,17 +495,17 @@ extern "C" { @brief SOLAD-based pitch shifter. @{ - @fn void tPitchShift_init (tPitchShift* const, tPeriodDetection* const, Lfloat* out, int bufSize, LEAF* const leaf) + @fn void tPitchShift_init(tPitchShift** const, tPeriodDetection* const, Lfloat* out, int bufSize, LEAF* const leaf) @brief Initialize a tPitchShift to the default mempool of a LEAF instance. @param pitchshift A pointer to the tPitchShift to initialize. @param leaf A pointer to the leaf instance. - @fn void tPitchShift_initToPool (tPitchShift* const, tPeriodDetection* const, Lfloat* out, int bufSize, tMempool* const) + @fn void tPitchShift_initToPool(tPitchShift** const, tPeriodDetection* const, Lfloat* out, int bufSize, tMempool** const) @brief Initialize a tPitchShift to a specified mempool. @param pitchshift A pointer to the tPitchShift to initialize. @param mempool A pointer to the tMempool to use. - @fn void tPitchShift_free (tPitchShift* const) + @fn void tPitchShift_free(tPitchShift** const) @brief Free a tPitchShift from its mempool. @param pitchshift A pointer to the tPitchShift to free. @@ -529,10 +529,10 @@ extern "C" { typedef struct tPitchShift { - tMempool mempool; + tMempool* mempool; - tDualPitchDetector pd; - tSOLAD sola; + tDualPitchDetector* pd; + tSOLAD* sola; Lfloat* outBuffer; Lfloat* inBuffer; @@ -544,8 +544,8 @@ extern "C" { Lfloat sampleRate; } tPitchShift; - void tPitchShift_init (tPitchShift** const, tDualPitchDetector* const, int bufSize, LEAF* const leaf); - void tPitchShift_initToPool (tPitchShift** const, tDualPitchDetector* const, int bufSize, tMempool* const); + void tPitchShift_init (tPitchShift** const, tDualPitchDetector** const, int bufSize, LEAF* const leaf); + void tPitchShift_initToPool (tPitchShift** const, tDualPitchDetector** const, int bufSize, tMempool** const); void tPitchShift_free (tPitchShift** const); void tPitchShift_shiftBy (tPitchShift* const, Lfloat factor, Lfloat* in, Lfloat* out); @@ -559,17 +559,17 @@ extern "C" { @brief Wrapper for multiple pitch shifters with single-channel output. @{ - @fn void tSimpleRetune_init (tSimpleRetune* const, int numVoices, int bufSize, int frameSize, LEAF* const leaf) + @fn void tSimpleRetune_init(tSimpleRetune** const, int numVoices, int bufSize, int frameSize, LEAF* const leaf) @brief Initialize a tSimpleRetune to the default mempool of a LEAF instance. @param retune A pointer to the tSimpleRetune to initialize. @param leaf A pointer to the leaf instance. - @fn void tSimpleRetune_initToPool (tSimpleRetune* const, int numVoices, int bufSize, int frameSize, tMempool* const) + @fn void tSimpleRetune_initToPool(tSimpleRetune** const, int numVoices, int bufSize, int frameSize, tMempool** const) @brief Initialize a tSimpleRetune to a specified mempool. @param retune A pointer to the tSimpleRetune to initialize. @param mempool A pointer to the tMempool to use. - @fn void tSimpleRetune_free (tSimpleRetune* const) + @fn void tSimpleRetune_free(tSimpleRetune** const) @brief Free a tSimpleRetune from its mempool. @param retune A pointer to the tSimpleRetune to free. @@ -593,12 +593,12 @@ extern "C" { typedef struct tSimpleRetune { - tMempool mempool; + tMempool* mempool; - tDualPitchDetector dp; + tDualPitchDetector* dp; Lfloat minInputFreq, maxInputFreq; - tPitchShift* ps; + tPitchShift** ps; Lfloat* pdBuffer; Lfloat* inBuffer; @@ -606,14 +606,14 @@ extern "C" { int bufSize; int index; - void (*shiftFunction)(tPitchShift const, Lfloat, Lfloat*, Lfloat*); + void (*shiftFunction)(tPitchShift* const, Lfloat, Lfloat*, Lfloat*); Lfloat* shiftValues; int numVoices; } tSimpleRetune; void tSimpleRetune_init (tSimpleRetune** const, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, LEAF* const leaf); - void tSimpleRetune_initToPool (tSimpleRetune** const, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, tMempool* const); + void tSimpleRetune_initToPool (tSimpleRetune** const, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, tMempool** const); void tSimpleRetune_free (tSimpleRetune** const); Lfloat tSimpleRetune_tick (tSimpleRetune* const, Lfloat sample); @@ -632,17 +632,17 @@ extern "C" { @brief Wrapper for multiple pitch shifters with multi-channel output. @{ - @fn void tRetune_init (tRetune* const, int numVoices, int bufSize, int frameSize, LEAF* const leaf) + @fn void tRetune_init(tRetune** const, int numVoices, int bufSize, int frameSize, LEAF* const leaf) @brief Initialize a tRetune to the default mempool of a LEAF instance. @param retune A pointer to the tRetune to initialize. @param leaf A pointer to the leaf instance. - @fn void tRetune_initToPool (tRetune* const, int numVoices, int bufSize, int frameSize, tMempool* const) + @fn void tRetune_initToPool(tRetune** const, int numVoices, int bufSize, int frameSize, tMempool** const) @brief Initialize a tRetune to a specified mempool. @param retune A pointer to the tRetune to initialize. @param mempool A pointer to the tMempool to use. - @fn void tRetune_free (tRetune* const) + @fn void tRetune_free(tRetune** const) @brief Free a tRetune from its mempool. @param retune A pointer to the tRetune to free. @@ -666,12 +666,12 @@ extern "C" { typedef struct tRetune { - tMempool mempool; + tMempool* mempool; - tDualPitchDetector* dp; + tDualPitchDetector** dp; Lfloat minInputFreq, maxInputFreq; - tPitchShift* ps; + tPitchShift** ps; Lfloat* pdBuffer; Lfloat* inBuffer; @@ -681,14 +681,14 @@ extern "C" { Lfloat* output; - void (*shiftFunction)(tPitchShift const, Lfloat, Lfloat*, Lfloat*); + void (*shiftFunction)(tPitchShift* const, Lfloat, Lfloat*, Lfloat*); Lfloat* shiftValues; int numVoices; } tRetune; void tRetune_init (tRetune** const, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, LEAF* const leaf); - void tRetune_initToPool (tRetune** const, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, tMempool* const); + void tRetune_initToPool (tRetune** const, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, tMempool** const); void tRetune_free (tRetune** const); Lfloat* tRetune_tick (tRetune* const, Lfloat sample); @@ -709,17 +709,17 @@ extern "C" { @brief Formant remover and adder, allowing for formant shifting. @{ - @fn void tFormantShifter_init (tFormantShifter* const, int order, LEAF* const leaf) + @fn void tFormantShifter_init(tFormantShifter** const, int order, LEAF* const leaf) @brief Initialize a tFormantShifter to the default mempool of a LEAF instance. @param formant A pointer to the tFormantShifter to initialize. @param leaf A pointer to the leaf instance. - @fn void tFormantShifter_initToPool (tFormantShifter* const, int order, tMempool* const) + @fn void tFormantShifter_initToPool(tFormantShifter** const, int order, tMempool** const) @brief Initialize a tFormantShifter to a specified mempool. @param formant A pointer to the tFormantShifter to initialize. @param mempool A pointer to the tMempool to use. - @fn void tFormantShifter_free (tFormantShifter* const) + @fn void tFormantShifter_free(tFormantShifter** const) @brief Free a tFormantShifter from its mempool. @param formant A pointer to the tFormantShifter to free. @@ -751,8 +751,8 @@ extern "C" { typedef struct tFormantShifter { - - tMempool mempool; + + tMempool* mempool; int ford; Lfloat falph; Lfloat flamb; @@ -773,16 +773,16 @@ extern "C" { unsigned int cbi; Lfloat shiftFactor; Lfloat intensity, invIntensity; - tHighpass hp; - tHighpass hp2; - tFeedbackLeveler fbl1; - tFeedbackLeveler fbl2; + tHighpass* hp; + tHighpass* hp2; + tFeedbackLeveler* fbl1; + tFeedbackLeveler* fbl2; Lfloat sampleRate; Lfloat invSampleRate; } tFormantShifter; void tFormantShifter_init (tFormantShifter** const, int order, LEAF* const leaf); - void tFormantShifter_initToPool (tFormantShifter** const, int order, tMempool* const); + void tFormantShifter_initToPool (tFormantShifter** const, int order, tMempool** const); void tFormantShifter_free (tFormantShifter** const); Lfloat tFormantShifter_tick (tFormantShifter* const, Lfloat input); diff --git a/leaf/Inc/leaf-electrical.h b/leaf/Inc/leaf-electrical.h index 9609030..cb5416a 100644 --- a/leaf/Inc/leaf-electrical.h +++ b/leaf/Inc/leaf-electrical.h @@ -34,17 +34,17 @@ extern "C" { @brief Wave digital filter component. @{ - @fn void tWDF_init (tWDF* const, WDFComponentType type, Lfloat value, tWDF* const rL, tWDF* const rR, LEAF* const leaf) + @fn void tWDF_init(tWDF** const, WDFComponentType type, Lfloat value, tWDF* const rL, tWDF* const rR, LEAF* const leaf) @brief Initialize a tWDF to the default mempool of a LEAF instance. @param wdf A pointer to the tWDF to initialize. @param leaf A pointer to the leaf instance. - @fn void tWDF_initToPool (tWDF* const, WDFComponentType type, Lfloat value, tWDF* const rL, tWDF* const rR, tMempool* const) + @fn void tWDF_initToPool(tWDF** const, WDFComponentType type, Lfloat value, tWDF* const rL, tWDF* const rR, * const) @brief Initialize a tWDF to a specified mempool. @param wdf A pointer to the tWDF to initialize. @param mempool A pointer to the tMempool to use. - @fn void tWDF_free (tWDF* const) + @fn void tWDF_free(tWDF** const) @brief Free a tWDF from its mempool. @param wdf A pointer to the tWDF to free. @@ -109,8 +109,8 @@ extern "C" { typedef struct tWDF tWDF; // needed to allow tWDF pointers in struct struct tWDF { - - tMempool mempool; + + tMempool* mempool; WDFComponentType type; Lfloat port_resistance_up; Lfloat port_resistance_left; @@ -127,30 +127,30 @@ extern "C" { Lfloat gamma_zero; Lfloat sample_rate; Lfloat value; - tWDF child_left; - tWDF child_right; - Lfloat (*get_port_resistance)(tWDF const); - Lfloat (*get_reflected_wave_up)(tWDF const, Lfloat); - Lfloat (*get_reflected_wave_down)(tWDF const, Lfloat, Lfloat); - void (*set_incident_wave)(tWDF const, Lfloat, Lfloat); + tWDF* child_left; + tWDF* child_right; + Lfloat (*get_port_resistance)(tWDF* const); + Lfloat (*get_reflected_wave_up)(tWDF* const, Lfloat); + Lfloat (*get_reflected_wave_down)(tWDF* const, Lfloat, Lfloat); + void (*set_incident_wave)(tWDF* const, Lfloat, Lfloat); }; //WDF Linear Components - void tWDF_init (tWDF* const, WDFComponentType type, Lfloat value, tWDF* const rL, tWDF* const rR, LEAF* const leaf); - void tWDF_initToPool (tWDF* const, WDFComponentType type, Lfloat value, tWDF* const rL, tWDF* const rR, tMempool* const); - void tWDF_free (tWDF* const); + void tWDF_init(tWDF** const, WDFComponentType type, Lfloat value, tWDF** const rL, tWDF** const rR, LEAF* const leaf); + void tWDF_initToPool(tWDF** const, WDFComponentType type, Lfloat value, tWDF** const rL, tWDF** const rR, tMempool** const); + void tWDF_free(tWDF** const); - Lfloat tWDF_tick (tWDF const, Lfloat sample, tWDF* const outputPoint, uint8_t paramsChanged); + Lfloat tWDF_tick (tWDF* const, Lfloat sample, tWDF* const outputPoint, uint8_t paramsChanged); - void tWDF_setValue (tWDF const, Lfloat value); - void tWDF_setSampleRate (tWDF const, Lfloat sample_rate); - uint8_t tWDF_isLeaf (tWDF const); - Lfloat tWDF_getPortResistance (tWDF const); - Lfloat tWDF_getReflectedWaveUp (tWDF const, Lfloat input); //for tree, only uses input for resistive source - Lfloat tWDF_getReflectedWaveDown (tWDF const, Lfloat input, Lfloat incident_wave); //for roots - void tWDF_setIncidentWave (tWDF const, Lfloat incident_wave, Lfloat input); - Lfloat tWDF_getVoltage (tWDF const); - Lfloat tWDF_getCurrent (tWDF const); + void tWDF_setValue (tWDF* const, Lfloat value); + void tWDF_setSampleRate (tWDF* const, Lfloat sample_rate); + uint8_t tWDF_isLeaf (tWDF* const); + Lfloat tWDF_getPortResistance (tWDF* const); + Lfloat tWDF_getReflectedWaveUp (tWDF* const, Lfloat input); //for tree, only uses input for resistive source + Lfloat tWDF_getReflectedWaveDown (tWDF* const, Lfloat input, Lfloat incident_wave); //for roots + void tWDF_setIncidentWave (tWDF* const, Lfloat incident_wave, Lfloat input); + Lfloat tWDF_getVoltage (tWDF* const); + Lfloat tWDF_getCurrent (tWDF* const); //============================================================================== diff --git a/leaf/Inc/leaf-envelopes.h b/leaf/Inc/leaf-envelopes.h index df34e6a..8a2b4ae 100644 --- a/leaf/Inc/leaf-envelopes.h +++ b/leaf/Inc/leaf-envelopes.h @@ -40,17 +40,17 @@ extern "C" { @brief Basic attack-decay envelope. @{ - @fn void tEnvelope_init (tEnvelope* const, Lfloat attack, Lfloat decay, int loop, LEAF* const leaf) + @fn void tEnvelope_init(tEnvelope** const, Lfloat attack, Lfloat decay, int loop, LEAF* const leaf) @brief Initialize a tEnvelope to the default mempool of a LEAF instance. @param envelope A pointer to the tEnvelope to initialize. @param leaf A pointer to the leaf instance. - @fn void tEnvelope_initToPool (tEnvelope* const, Lfloat attack, Lfloat decay, int loop, tMempool* const) + @fn void tEnvelope_initToPool(tEnvelope** const, Lfloat attack, Lfloat decay, int loop, tMempool** const) @brief Initialize a tEnvelope to a specified mempool. @param envelope A pointer to the tEnvelope to initialize. @param mempool A pointer to the tMempool to use. - @fn void tEnvelope_free (tEnvelope* const) + @fn void tEnvelope_free(tEnvelope** const) @brief Free a tEnvelope from its mempool. @param envelope A pointer to the tEnvelope to free. @@ -78,8 +78,8 @@ extern "C" { typedef struct tEnvelope { - - tMempool mempool; + + tMempool* mempool; const Lfloat *exp_buff; const Lfloat *inc_buff; @@ -100,7 +100,7 @@ extern "C" { } tEnvelope; void tEnvelope_init (tEnvelope** const, Lfloat attack, Lfloat decay, int loop, LEAF* const leaf); - void tEnvelope_initToPool (tEnvelope** const, Lfloat attack, Lfloat decay, int loop, tMempool* const); + void tEnvelope_initToPool (tEnvelope** const, Lfloat attack, Lfloat decay, int loop, tMempool** const); void tEnvelope_free (tEnvelope** const); Lfloat tEnvelope_tick (tEnvelope* const); @@ -119,17 +119,17 @@ extern "C" { @brief Exponential curve smoother. @{ - @fn void tExpSmooth_init (tExpSmooth* const, Lfloat val, Lfloat factor, LEAF* const leaf) + @fn void tExpSmooth_init(tExpSmooth** const, Lfloat val, Lfloat factor, LEAF* const leaf) @brief Initialize a tExpSmooth to the default mempool of a LEAF instance. @param smooth A pointer to the tExpSmooth to initialize. @param leaf A pointer to the leaf instance. - @fn void tExpSmooth_initToPool (tExpSmooth* const, Lfloat val, Lfloat factor, tMempool* const) + @fn void tExpSmooth_initToPool(tExpSmooth** const, Lfloat val, Lfloat factor, tMempool** const) @brief Initialize a tExpSmooth to a specified mempool. @param smooth A pointer to the tExpSmooth to initialize. @param mempool A pointer to the tMempool to use. - @fn void tExpSmooth_free (tExpSmooth* const) + @fn void tExpSmooth_free(tExpSmooth** const) @brief Free a tExpSmooth from its mempool. @param smooth A pointer to the tExpSmooth to free. @@ -161,35 +161,35 @@ extern "C" { typedef struct tExpSmooth { - - tMempool mempool; + + tMempool* mempool; Lfloat factor, oneminusfactor; Lfloat curr,dest; //Lfloat invSampleRate; } tExpSmooth; void tExpSmooth_init (tExpSmooth** const, Lfloat val, Lfloat factor, LEAF* const leaf); - void tExpSmooth_initToPool (tExpSmooth** const, Lfloat val, Lfloat factor, tMempool* const); + void tExpSmooth_initToPool (tExpSmooth** const, Lfloat val, Lfloat factor, tMempool** const); void tExpSmooth_free (tExpSmooth** const); #ifdef ITCMRAM Lfloat __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tExpSmooth_tick(tExpSmooth* const expsmooth); #else -Lfloat tExpSmooth_tick(tExpSmooth const expsmooth); +Lfloat tExpSmooth_tick(tExpSmooth* const expsmooth); #endif - Lfloat tExpSmooth_sample (tExpSmooth const); - void tExpSmooth_setFactor (tExpSmooth const, Lfloat factor); + Lfloat tExpSmooth_sample (tExpSmooth* const); + void tExpSmooth_setFactor (tExpSmooth* const, Lfloat factor); #ifdef ITCMRAM void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tExpSmooth_setDest (tExpSmooth* const, Lfloat dest); #else -void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); +void tExpSmooth_setDest (tExpSmooth* const, Lfloat dest); #endif - void tExpSmooth_setVal (tExpSmooth const, Lfloat val); - void tExpSmooth_setValAndDest(tExpSmooth const, Lfloat val); - void tExpSmooth_setSampleRate(tExpSmooth const, Lfloat sr); + void tExpSmooth_setVal (tExpSmooth* const, Lfloat val); + void tExpSmooth_setValAndDest(tExpSmooth* const, Lfloat val); + void tExpSmooth_setSampleRate(tExpSmooth* const, Lfloat sr); // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ @@ -202,17 +202,17 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); @brief @{ - @fn void tADSR_init (tADSR* const adsrenv, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, LEAF* const leaf) + @fn void tADSR_init(tADSR** const adsrenv, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, LEAF* const leaf) @brief Initialize a tADSR to the default mempool of a LEAF instance. @param adsr A pointer to the tADSR to initialize. @param leaf A pointer to the leaf instance. - @fn void tADSR_initToPool (tADSR* const adsrenv, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, tMempool* const mp) + @fn void tADSR_initToPool(tADSR** const adsrenv, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, tMempool** const mp) @brief Initialize a tADSR to a specified mempool. @param adsr A pointer to the tADSR to initialize. @param mempool A pointer to the tMempool to use. - @fn void tADSR_free (tADSR* const) + @fn void tADSR_free(tADSR** const) @brief Free a tADSR from its mempool. @param adsr A pointer to the tADSR to free. @@ -253,8 +253,8 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); /* ADSR */ typedef struct tADSR { - - tMempool mempool; + + tMempool* mempool; const Lfloat *exp_buff; const Lfloat *inc_buff; @@ -278,7 +278,7 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); } tADSR; void tADSR_init (tADSR** const adsrenv, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, LEAF* const leaf); - void tADSR_initToPool (tADSR** const adsrenv, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, tMempool* const mp); + void tADSR_initToPool (tADSR** const adsrenv, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, tMempool** const mp); void tADSR_free (tADSR** const); Lfloat tADSR_tick (tADSR* const); @@ -299,17 +299,17 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); @brief @{ - @fn void tADSRT_init (tADSRT* const, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, Lfloat* expBuffer, int bufferSize, LEAF* const leaf) + @fn void tADSRT_init(tADSRT** const, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, Lfloat* expBuffer, int bufferSize, LEAF* const leaf) @brief Initialize a tADSRT to the default mempool of a LEAF instance. @param adsr A pointer to the tADSRT to initialize. @param leaf A pointer to the leaf instance. - @fn void tADSRT_initToPool (tADSRT* const, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, Lfloat* expBuffer, int bufferSize, tMempool* const) + @fn void tADSRT_initToPool(tADSRT** const, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, Lfloat* expBuffer, int bufferSize, tMempool** const) @brief Initialize a tADSRT to a specified mempool. @param adsr A pointer to the tADSRT to initialize. @param mempool A pointer to the tMempool to use. - @fn void tADSRT_free (tADSRT* const) + @fn void tADSRT_free(tADSRT** const) @brief Free a tADSRT from its mempool. @param adsr A pointer to the tADSRT to free. @@ -353,8 +353,8 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); typedef struct tADSRT { - - tMempool mempool; + + tMempool* mempool; const Lfloat *exp_buff; uint32_t buff_size; uint32_t buff_sizeMinusOne; @@ -378,7 +378,7 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); } tADSRT; void tADSRT_init (tADSRT** const, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, Lfloat* expBuffer, int bufferSize, LEAF* const leaf); - void tADSRT_initToPool (tADSRT** const, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, Lfloat* expBuffer, int bufferSize, tMempool* const); + void tADSRT_initToPool (tADSRT** const, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, Lfloat* expBuffer, int bufferSize, tMempool** const); void tADSRT_free (tADSRT** const); Lfloat tADSRT_tick (tADSRT* const); @@ -401,17 +401,17 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); @brief @{ - @fn void tADSRS_init (tADSRS* const, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, LEAF* const leaf) + @fn void tADSRS_init(tADSRS** const, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, LEAF* const leaf) @brief Initialize a tADSRS to the default mempool of a LEAF instance. @param adsr A pointer to the tADSRS to initialize. @param leaf A pointer to the leaf instance. - @fn void tADSRS_initToPool (tADSRS* const, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, tMempool* const) + @fn void tADSRS_initToPool(tADSRS** const, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, tMempool** const) @brief Initialize a tADSRS to a specified mempool. @param adsr A pointer to the tADSRS to initialize. @param mempool A pointer to the tMempool to use. - @fn void tADSRS_free (tADSRS* const) + @fn void tADSRS_free(tADSRS** const) @brief Free a tADSRS from its mempool. @param adsr A pointer to the tADSRS to free. @@ -460,8 +460,8 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); typedef struct tADSRS { - - tMempool mempool; + + tMempool* mempool; Lfloat sampleRate; Lfloat sampleRateInMs; int state; @@ -490,7 +490,7 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); } tADSRS; void tADSRS_init (tADSRS** const, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, LEAF* const leaf); - void tADSRS_initToPool (tADSRS** const, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, tMempool* const); + void tADSRS_initToPool (tADSRS** const, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, tMempool** const); void tADSRS_free (tADSRS** const); Lfloat tADSRS_tick (tADSRS* const); @@ -511,17 +511,17 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); @brief Value ramp. @{ - @fn void tRamp_init (tRamp* const, Lfloat time, int samplesPerTick, LEAF* const leaf) + @fn void tRamp_init(tRamp** const, Lfloat time, int samplesPerTick, LEAF* const leaf) @brief Initialize a tRamp to the default mempool of a LEAF instance. @param ramp A pointer to the tRamp to initialize. @param leaf A pointer to the leaf instance. - @fn void tRamp_initToPool (tRamp* const, Lfloat time, int samplesPerTick, tMempool* const) + @fn void tRamp_initToPool(tRamp** const, Lfloat time, int samplesPerTick, tMempool** const) @brief Initialize a tRamp to a specified mempool. @param ramp A pointer to the tRamp to initialize. @param mempool A pointer to the tMempool to use. - @fn void tRamp_free (tRamp* const) + @fn void tRamp_free(tRamp** const) @brief Free a tRamp from its mempool. @param ramp A pointer to the tRamp to free. @@ -549,7 +549,7 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); typedef struct tRamp { - tMempool mempool; + tMempool* mempool; Lfloat inc; Lfloat sampleRate; Lfloat inv_sr_ms; @@ -561,7 +561,7 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); } tRamp; void tRamp_init (tRamp** const, Lfloat time, int samplesPerTick, LEAF* const leaf); - void tRamp_initToPool (tRamp** const, Lfloat time, int samplesPerTick, tMempool* const); + void tRamp_initToPool (tRamp** const, Lfloat time, int samplesPerTick, tMempool** const); void tRamp_free (tRamp** const); Lfloat tRamp_tick (tRamp* const); @@ -577,17 +577,17 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); @brief Value ramp with variable rate depending on direction. @{ - @fn void tRampUpDown_init (tRampUpDown* const, Lfloat upTime, Lfloat downTime, int samplesPerTick, LEAF* const leaf) + @fn void tRampUpDown_init(tRampUpDown** const, Lfloat upTime, Lfloat downTime, int samplesPerTick, LEAF* const leaf) @brief Initialize a tRampUpDown to the default mempool of a LEAF instance. @param ramp A pointer to the tRampUpDown to initialize. @param leaf A pointer to the leaf instance. - @fn void tRampUpDown_initToPool (tRampUpDown* const, Lfloat upTime, Lfloat downTime, int samplesPerTick, tMempool* const) + @fn void tRampUpDown_initToPool(tRampUpDown** const, Lfloat upTime, Lfloat downTime, int samplesPerTick, tMempool** const) @brief Initialize a tRampUpDown to a specified mempool. @param ramp A pointer to the tRampUpDown to initialize. @param mempool A pointer to the tMempool to use. - @fn void tRampUpDown_free (tRampUpDown* const) + @fn void tRampUpDown_free(tRampUpDown** const) @brief Free a tRampUpDown from its mempool. @param ramp A pointer to the tRampUpDown to free. @@ -619,7 +619,7 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); typedef struct tRampUpDown { - tMempool mempool; + tMempool* mempool; Lfloat upInc; Lfloat downInc; Lfloat sampleRate; @@ -632,7 +632,7 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); } tRampUpDown; void tRampUpDown_init (tRampUpDown** const, Lfloat upTime, Lfloat downTime, int samplesPerTick, LEAF* const leaf); - void tRampUpDown_initToPool (tRampUpDown** const, Lfloat upTime, Lfloat downTime, int samplesPerTick, tMempool* const); + void tRampUpDown_initToPool (tRampUpDown** const, Lfloat upTime, Lfloat downTime, int samplesPerTick, tMempool** const); void tRampUpDown_free (tRampUpDown** const); Lfloat tRampUpDown_tick (tRampUpDown* const); @@ -649,17 +649,17 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); @brief Based on Max/MSP's slide~ @{ - @fn void tSlide_init (tSlide* const, Lfloat upSlide, Lfloat downSlide, LEAF* const leaf) + @fn void tSlide_init(tSlide** const, Lfloat upSlide, Lfloat downSlide, LEAF* const leaf) @brief Initialize a tSlide to the default mempool of a LEAF instance. @param slide A pointer to the tSlide to initialize. @param leaf A pointer to the leaf instance. - @fn void tSlide_initToPool (tSlide* const, Lfloat upSlide, Lfloat downSlide, tMempool* const) + @fn void tSlide_initToPool(tSlide** const, Lfloat upSlide, Lfloat downSlide, tMempool** const) @brief Initialize a tSlide to a specified mempool. @param slide A pointer to the tSlide to initialize. @param mempool A pointer to the tMempool to use. - @fn void tSlide_free (tSlide* const) + @fn void tSlide_free(tSlide** const) @brief Free a tSlide from its mempool. @param slide A pointer to the tSlide to free. @@ -687,7 +687,7 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); typedef struct tSlide { - tMempool mempool; + tMempool* mempool; Lfloat prevOut; Lfloat currentOut; Lfloat prevIn; @@ -697,7 +697,7 @@ void tExpSmooth_setDest (tExpSmooth const, Lfloat dest); } tSlide; void tSlide_init (tSlide** const, Lfloat upSlide, Lfloat downSlide, LEAF* const leaf); - void tSlide_initToPool (tSlide** const, Lfloat upSlide, Lfloat downSlide, tMempool* const); + void tSlide_initToPool (tSlide** const, Lfloat upSlide, Lfloat downSlide, tMempool** const); void tSlide_free (tSlide** const); Lfloat tSlide_tick (tSlide* const, Lfloat in); diff --git a/leaf/Inc/leaf-filters.h b/leaf/Inc/leaf-filters.h index 9a1b541..19d2f73 100644 --- a/leaf/Inc/leaf-filters.h +++ b/leaf/Inc/leaf-filters.h @@ -36,17 +36,17 @@ extern "C" { @brief Schroeder allpass. Comb-filter with feedforward and feedback. @{ - @fn void tAllpass_init (tAllpass* const, Lfloat initDelay, uint32_t maxDelay, LEAF* const leaf) + @fn void tAllpass_init(tAllpass** const, Lfloat initDelay, uint32_t maxDelay, LEAF* const leaf) @brief Initialize a tAllpass to the default mempool of a LEAF instance. @param filter A pointer to the tAllpass to initialize. @param leaf A pointer to the leaf instance. - @fn void tAllpass_initToPool (tAllpass* const, Lfloat initDelay, uint32_t maxDelay, tMempool* const) + @fn void tAllpass_initToPool(tAllpass** const, Lfloat initDelay, uint32_t maxDelay, tMempool** const) @brief Initialize a tAllpass to a specified mempool. @param filter A pointer to the tAllpass to initialize. @param mempool A pointer to the tMempool to use. - @fn void tAllpass_free (tAllpass* const) + @fn void tAllpass_free(tAllpass** const) @brief Free a tAllpass from its mempool. @param filter A pointer to the tAllpass to free. @@ -66,19 +66,18 @@ extern "C" { typedef struct tAllpass { - - tMempool mempool; + tMempool* mempool; Lfloat gain; - tLinearDelay delay; + tLinearDelay* delay; Lfloat lastOut; } tAllpass; // Memory handlers for `tAllpass` void tAllpass_init (tAllpass** const, Lfloat initDelay, uint32_t maxDelay, LEAF* const leaf); - void tAllpass_initToPool (tAllpass** const, Lfloat initDelay, uint32_t maxDelay, tMempool* const); + void tAllpass_initToPool (tAllpass** const, Lfloat initDelay, uint32_t maxDelay, tMempool** const); void tAllpass_free (tAllpass** const); // Tick function for `tAllpass` @@ -96,17 +95,17 @@ extern "C" { @brief Schroeder allpass. Comb-filter with feedforward and feedback. @{ - @fn void tAllpassSO_init (tAllpassSO* const, Lfloat initDelay, uint32_t maxDelay, LEAF* const leaf) + @fn void tAllpassSO_init(tAllpassSO** const, Lfloat initDelay, uint32_t maxDelay, LEAF* const leaf) @brief Initialize a tAllpassSO to the default mempool of a LEAF instance. @param filter A pointer to the tAllpassSO to initialize. @param leaf A pointer to the leaf instance. - @fn void tAllpassSO_initToPool (tAllpassSO* const, Lfloat initDelay, uint32_t maxDelay, tMempool* const) + @fn void tAllpassSO_initToPool(tAllpassSO** const, Lfloat initDelay, uint32_t maxDelay, tMempool** const) @brief Initialize a tAllpassSO to a specified mempool. @param filter A pointer to the tAllpassSO to initialize. @param mempool A pointer to the tMempool to use. - @fn void tAllpassSO_free (tAllpassSO* const) + @fn void tAllpassSO_free(tAllpassSO** const) @brief Free a tAllpassSO from its mempool. @param filter A pointer to the tAllpassSO to free. @@ -127,7 +126,7 @@ extern "C" { typedef struct tAllpassSO { - tMempool mempool; + tMempool* mempool; Lfloat prevSamp; Lfloat prevPrevSamp; @@ -140,7 +139,7 @@ extern "C" { // Memory handlers for `tAllpassSO` void tAllpassSO_init (tAllpassSO** const, LEAF* const leaf); - void tAllpassSO_initToPool (tAllpassSO** const, tMempool* const); + void tAllpassSO_initToPool (tAllpassSO** const, tMempool** const); void tAllpassSO_free (tAllpassSO** const); // Tick function for `tAllpassSO` @@ -154,10 +153,10 @@ extern "C" { typedef struct tThiranAllpassSOCascade { - tMempool mempool; + tMempool* mempool; int numFilts; - tAllpassSO* filters; + tAllpassSO** filters; Lfloat B; Lfloat iKey; Lfloat a[2]; @@ -175,7 +174,7 @@ extern "C" { // Memory handlers for `tThiranAllpassSOCascade` void tThiranAllpassSOCascade_init (tThiranAllpassSOCascade** const, int order, LEAF* const leaf); - void tThiranAllpassSOCascade_initToPool (tThiranAllpassSOCascade** const, int order, tMempool* const); + void tThiranAllpassSOCascade_initToPool (tThiranAllpassSOCascade** const, int order, tMempool** const); void tThiranAllpassSOCascade_free (tThiranAllpassSOCascade** const); // Tick function for `tThiranAllpassSOCascade` @@ -192,17 +191,17 @@ extern "C" { @brief OnePole filter, reimplemented from STK (Cook and Scavone). @{ - @fn void tOnePole_init (tOnePole* const, Lfloat thePole, LEAF* const leaf) + @fn void tOnePole_init(tOnePole** const, Lfloat thePole, LEAF* const leaf) @brief Initialize a tOnePole to the default mempool of a LEAF instance. @param filter A pointer to the tOnePole to initialize. @param leaf A pointer to the leaf instance. - @fn void tOnePole_initToPool (tOnePole* const, Lfloat thePole, tMempool* const) + @fn void tOnePole_initToPool(tOnePole** const, Lfloat thePole, tMempool** const) @brief Initialize a tOnePole to a specified mempool. @param filter A pointer to the tOnePole to initialize. @param mempool A pointer to the tMempool to use. - @fn void tOnePole_free (tOnePole* const) + @fn void tOnePole_free(tOnePole** const) @brief Free a tOnePole from its mempool. @param filter A pointer to the tOnePole to free. @@ -238,8 +237,8 @@ extern "C" { typedef struct tOnePole { - - tMempool mempool; + + tMempool* mempool; Lfloat freq; Lfloat gain; Lfloat a0,a1; @@ -250,7 +249,7 @@ extern "C" { // Memory handlers for `tOnePole` void tOnePole_init (tOnePole** const, Lfloat freq, LEAF* const leaf); - void tOnePole_initToPool (tOnePole** const, Lfloat freq, tMempool* const); + void tOnePole_initToPool (tOnePole** const, Lfloat freq, tMempool** const); void tOnePole_free (tOnePole** const); // Tick function for `tOnePole` @@ -273,17 +272,17 @@ extern "C" { @brief OnePole filter, reimplemented from STK (Cook and Scavone). @{ - @fn void tOnePole_init (tOnePole* const, Lfloat thePole, LEAF* const leaf) + @fn void tOnePole_init(tOnePole** const, Lfloat thePole, LEAF* const leaf) @brief Initialize a tOnePole to the default mempool of a LEAF instance. @param filter A pointer to the tOnePole to initialize. @param leaf A pointer to the leaf instance. - @fn void tOnePole_initToPool (tOnePole* const, Lfloat thePole, tMempool* const) + @fn void tOnePole_initToPool(tOnePole** const, Lfloat thePole, tMempool** const) @brief Initialize a tOnePole to a specified mempool. @param filter A pointer to the tOnePole to initialize. @param mempool A pointer to the tMempool to use. - @fn void tOnePole_free (tOnePole* const) + @fn void tOnePole_free(tOnePole** const) @brief Free a tOnePole from its mempool. @param filter A pointer to the tOnePole to free. @@ -320,7 +319,7 @@ extern "C" { typedef struct tCookOnePole { - tMempool mempool; + tMempool* mempool; Lfloat poleCoeff, sgain, output; Lfloat twoPiTimesInvSampleRate; Lfloat gain; @@ -328,7 +327,7 @@ extern "C" { // Memory handlers for `tCookOnePole` void tCookOnePole_init (tCookOnePole** const, LEAF* const leaf); - void tCookOnePole_initToPool (tCookOnePole** const, tMempool* const); + void tCookOnePole_initToPool (tCookOnePole** const, tMempool** const); void tCookOnePole_free (tCookOnePole** const); // Tick function for `tCookOnePole` @@ -348,17 +347,17 @@ extern "C" { @brief TwoPole filter, reimplemented from STK (Cook and Scavone). @{ - @fn void tTwoPole_init (tTwoPole* const, LEAF* const leaf) + @fn void tTwoPole_init(tTwoPole** const, LEAF* const leaf) @brief Initialize a tTwoPole to the default mempool of a LEAF instance. @param filter A pointer to the tTwoPole to initialize. @param leaf A pointer to the leaf instance. - @fn void tTwoPole_initToPool (tTwoPole* const, tMempool* const) + @fn void tTwoPole_initToPool(tTwoPole** const, tMempool** const) @brief Initialize a tTwoPole to a specified mempool. @param filter A pointer to the tTwoPole to initialize. @param mempool A pointer to the tMempool to use. - @fn void tTwoPole_free (tTwoPole* const) + @fn void tTwoPole_free(tTwoPole** const) @brief Free a tTwoPole from its mempool. @param filter A pointer to the tTwoPole to free. @@ -394,8 +393,8 @@ extern "C" { typedef struct tTwoPole { - - tMempool mempool; + + tMempool* mempool; Lfloat gain; Lfloat a0, a1, a2; @@ -412,7 +411,7 @@ extern "C" { // Memory handlers for `tTwoPole` void tTwoPole_init (tTwoPole** const, LEAF* const leaf); - void tTwoPole_initToPool (tTwoPole** const, tMempool* const); + void tTwoPole_initToPool (tTwoPole** const, tMempool** const); void tTwoPole_free (tTwoPole** const); // Tick function for `tTwoPole` @@ -435,17 +434,17 @@ extern "C" { @brief OneZero filter, reimplemented from STK (Cook and Scavone). @{ - @fn void tOneZero_init (tOneZero* const, Lfloat theZero, LEAF* const leaf) + @fn void tOneZero_init(tOneZero** const, Lfloat theZero, LEAF* const leaf) @brief Initialize a tOneZero to the default mempool of a LEAF instance. @param filter A pointer to the tSlide to initialize. @param leaf A pointer to the leaf instance. - @fn void tOneZero_initToPool (tOneZero* const, Lfloat theZero, tMempool* const) + @fn void tOneZero_initToPool(tOneZero** const, Lfloat theZero, tMempool** const) @brief Initialize a tOneZero to a specified mempool. @param filter A pointer to the tOneZero to initialize. @param mempool A pointer to the tMempool to use. - @fn void tOneZero_free (tOneZero* const) + @fn void tOneZero_free(tOneZero** const) @brief Free a tOneZero from its mempool. @param filter A pointer to the tOneZero to free. @@ -481,7 +480,7 @@ extern "C" { typedef struct tOneZero { - tMempool mempool; + tMempool* mempool; Lfloat gain; Lfloat b0,b1; Lfloat lastIn, lastOut, frequency; @@ -490,7 +489,7 @@ extern "C" { // Memory handlers for `tOneZero` void tOneZero_init (tOneZero** const, Lfloat theZero, LEAF* const leaf); - void tOneZero_initToPool (tOneZero** const, Lfloat theZero, tMempool* const); + void tOneZero_initToPool (tOneZero** const, Lfloat theZero, tMempool** const); void tOneZero_free (tOneZero** const); // Tick function for `tOneZero` @@ -513,17 +512,17 @@ extern "C" { @brief TwoZero filter, reimplemented from STK (Cook and Scavone). @{ - @fn void tTwoZero_init (tTwoZero* const, LEAF* const leaf) + @fn void tTwoZero_init(tTwoZero** const, LEAF* const leaf) @brief Initialize a tTwoZero to the default mempool of a LEAF instance. @param filter A pointer to the tTwoZero to initialize. @param leaf A pointer to the leaf instance. - @fn void tTwoZero_initToPool (tTwoZero* const, tMempool* const) + @fn void tTwoZero_initToPool(tTwoZero** const, tMempool** const) @brief Initialize a tTwoZero to a specified mempool. @param filter A pointer to the tTwoZero to initialize. @param mempool A pointer to the tMempool to use. - @fn void tTwoZero_free (tTwoZero* const) + @fn void tTwoZero_free(tTwoZero** const) @brief Free a tTwoZero from its mempool. @param filter A pointer to the tTwoZero to free. @@ -560,7 +559,7 @@ extern "C" { typedef struct tTwoZero { - tMempool mempool; + tMempool* mempool; Lfloat gain; Lfloat b0, b1, b2; @@ -571,7 +570,7 @@ extern "C" { // Memory handlers for `tTwoZero` void tTwoZero_init (tTwoZero** const, LEAF* const leaf); - void tTwoZero_initToPool (tTwoZero** const, tMempool* const); + void tTwoZero_initToPool (tTwoZero** const, tMempool** const); void tTwoZero_free (tTwoZero** const); // Tick function for `tTwoZero` @@ -594,17 +593,17 @@ extern "C" { @brief PoleZero filter, reimplemented from STK (Cook and Scavone). @{ - @fn void tPoleZero_init (tPoleZero* const, LEAF* const leaf) + @fn void tPoleZero_init(tPoleZero** const, LEAF* const leaf) @brief Initialize a tPoleZero to the default mempool of a LEAF instance. @param filter A pointer to the tPoleZero to initialize. @param leaf A pointer to the leaf instance. - @fn void tPoleZero_initToPool (tPoleZero* const, tMempool* const) + @fn void tPoleZero_initToPool(tPoleZero** const, tMempool** const) @brief Initialize a tPoleZero to a specified mempool. @param filter A pointer to the tPoleZero to initialize. @param mempool A pointer to the tMempool to use. - @fn void tPoleZero_free (tPoleZero* const) + @fn void tPoleZero_free(tPoleZero** const) @brief Free a tPoleZero from its mempool. @param filter A pointer to the tPoleZero to free. @@ -646,8 +645,8 @@ extern "C" { typedef struct tPoleZero { - - tMempool mempool; + + tMempool* mempool; Lfloat gain; Lfloat a1; @@ -658,7 +657,7 @@ extern "C" { // Memory handlers for `tPoleZero` void tPoleZero_init (tPoleZero** const, LEAF* const leaf); - void tPoleZero_initToPool (tPoleZero** const, tMempool* const); + void tPoleZero_initToPool (tPoleZero** const, tMempool** const); void tPoleZero_free (tPoleZero** const); // Tick function for `tPoleZero` @@ -681,17 +680,17 @@ extern "C" { @brief BiQuad filter, reimplemented from STK (Cook and Scavone). @{ - @fn void tBiQuad_init (tBiQuad* const, LEAF* const leaf) + @fn void tBiQuad_init(tBiQuad** const, LEAF* const leaf) @brief Initialize a tBiQuad to the default mempool of a LEAF instance. @param filter A pointer to the tBiQuad to initialize. @param leaf A pointer to the leaf instance. - @fn void tBiQuad_initToPool (tBiQuad* const, tMempool* const) + @fn void tBiQuad_initToPool(tBiQuad** const, tMempool** const) @brief Initialize a tBiQuad to a specified mempool. @param filter A pointer to the tBiQuad to initialize. @param mempool A pointer to the tMempool to use. - @fn void tBiQuad_free (tBiQuad* const) + @fn void tBiQuad_free(tBiQuad** const) @brief Free a tBiQuad from its mempool. @param filter A pointer to the tBiQuad to free. @@ -741,7 +740,7 @@ extern "C" { typedef struct tBiQuad { - tMempool mempool; + tMempool* mempool; Lfloat gain; Lfloat a0, a1, a2; @@ -759,7 +758,7 @@ extern "C" { // Memory handlers for `tBiQuad` void tBiQuad_init (tBiQuad** const, LEAF* const leaf); - void tBiQuad_initToPool (tBiQuad** const, tMempool* const); + void tBiQuad_initToPool (tBiQuad** const, tMempool** const); void tBiQuad_free (tBiQuad** const); // Tick function for `tBiQuad` @@ -785,17 +784,17 @@ extern "C" { @brief State Variable Filter, algorithm from Andy Simper. @{ - @fn void tSVF_init (tSVF* const, SVFType type, Lfloat freq, Lfloat Q, LEAF* const leaf) + @fn void tSVF_init(tSVF** const, SVFType type, Lfloat freq, Lfloat Q, LEAF* const leaf) @brief Initialize a tSVF to the default mempool of a LEAF instance. @param filter A pointer to the tSVF to initialize. @param leaf A pointer to the leaf instance. - @fn void tSVF_initToPool (tSVF* const, SVFType type, Lfloat freq, Lfloat Q, tMempool* const) + @fn void tSVF_initToPool(tSVF** const, SVFType type, Lfloat freq, Lfloat Q, tMempool** const) @brief Initialize a tSVF to a specified mempool. @param filter A pointer to the tSVF to initialize. @param mempool A pointer to the tMempool to use. - @fn void tSVF_free (tSVF* const) + @fn void tSVF_free(tSVF** const) @brief Free a tSVF from its mempool. @param filter A pointer to the tSVF to free. @@ -834,7 +833,7 @@ extern "C" { typedef struct tSVF { - tMempool mempool; + tMempool* mempool; SVFType type; Lfloat cutoff, Q, cutoffMIDI; Lfloat ic1eq,ic2eq; @@ -848,7 +847,7 @@ extern "C" { // Memory handlers for `tSVF` void tSVF_init (tSVF** const, SVFType type, Lfloat freq, Lfloat Q, LEAF* const leaf); - void tSVF_initToPool (tSVF** const, SVFType type, Lfloat freq, Lfloat Q, tMempool* const); + void tSVF_initToPool (tSVF** const, SVFType type, Lfloat freq, Lfloat Q, tMempool** const); void tSVF_free (tSVF** const); // Tick functions for `tSVF` @@ -871,7 +870,7 @@ extern "C" { typedef struct tSVF_LP { - tMempool mempool; + tMempool* mempool; Lfloat ic1eq,ic2eq; Lfloat g,onePlusg,k,a0,a1,a2,a3,a4,a5; Lfloat sampleRate; @@ -884,7 +883,7 @@ extern "C" { // Memory handlers for `tSVF_LP` void tSVF_LP_init (tSVF_LP** const, Lfloat freq, Lfloat Q, LEAF* const leaf); - void tSVF_LP_initToPool (tSVF_LP** const, Lfloat freq, Lfloat Q, tMempool* const); + void tSVF_LP_initToPool (tSVF_LP** const, Lfloat freq, Lfloat Q, tMempool** const); void tSVF_LP_free (tSVF_LP** const); // Tick function for `tSVF_LP` @@ -906,17 +905,17 @@ extern "C" { @brief Efficient State Variable Filter for 14-bit control input, [0, 4096). @{ - @fn void tEfficientSVF_init (tEfficientSVF* const, SVFType type, uint16_t input, Lfloat Q, LEAF* const leaf) + @fn void tEfficientSVF_init(tEfficientSVF** const, SVFType type, uint16_t input, Lfloat Q, LEAF* const leaf) @brief Initialize a tEfficientSVF to the default mempool of a LEAF instance. @param filter A pointer to the tEfficientSVF to initialize. @param leaf A pointer to the leaf instance. - @fn void tEfficientSVF_initToPool (tEfficientSVF* const, SVFType type, uint16_t input, Lfloat Q, tMempool* const) + @fn void tEfficientSVF_initToPool(tEfficientSVF** const, SVFType type, uint16_t input, Lfloat Q, tMempool** const) @brief Initialize a tEfficientSVF to a specified mempool. @param filter A pointer to the tEfficientSVF to initialize. @param mempool A pointer to the tMempool to use. - @fn void tEfficientSVF_free (tEfficientSVF* const) + @fn void tEfficientSVF_free(tEfficientSVF** const) @brief Free a tEfficientSVF from its mempool. @param filter A pointer to the tEfficientSVF to free. @@ -936,8 +935,8 @@ extern "C" { typedef struct tEfficientSVF { - - tMempool mempool; + + tMempool* mempool; SVFType type; Lfloat cutoff, Q; Lfloat ic1eq,ic2eq; @@ -947,7 +946,7 @@ extern "C" { // Memory handlers for `tEfficientSVF` void tEfficientSVF_init (tEfficientSVF** const, SVFType type, uint16_t input, Lfloat Q, LEAF* const leaf); - void tEfficientSVF_initToPool (tEfficientSVF** const, SVFType type, uint16_t input, Lfloat Q, tMempool* const); + void tEfficientSVF_initToPool (tEfficientSVF** const, SVFType type, uint16_t input, Lfloat Q, tMempool** const); void tEfficientSVF_free (tEfficientSVF** const); // Tick function for `tEfficientSVF` @@ -966,17 +965,17 @@ extern "C" { @brief Simple Highpass filter. @{ - @fn void tHighpass_init (tHighpass* const, Lfloat freq, LEAF* const leaf) + @fn void tHighpass_init(tHighpass** const, Lfloat freq, LEAF* const leaf) @brief Initialize a tHighpass to the default mempool of a LEAF instance. @param filter A pointer to the tHighpass to initialize. @param leaf A pointer to the leaf instance. - @fn void tHighpass_initToPool (tHighpass* const, Lfloat freq, tMempool* const) + @fn void tHighpass_initToPool(tHighpass** const, Lfloat freq, tMempool** const) @brief Initialize a tHighpass to a specified mempool. @param filter A pointer to the tHighpass to initialize. @param mempool A pointer to the tMempool to use. - @fn void tHighpass_free (tHighpass* const) + @fn void tHighpass_free(tHighpass** const) @brief Free a tHighpass from its mempool. @param filter A pointer to the tHighpass to free. @@ -996,7 +995,7 @@ extern "C" { typedef struct tHighpass { - tMempool mempool; + tMempool* mempool; Lfloat xs, ys, R; Lfloat frequency; Lfloat twoPiTimesInvSampleRate; @@ -1004,7 +1003,7 @@ extern "C" { // Memory handlers for `tHighpass` void tHighpass_init (tHighpass** const, Lfloat freq, LEAF* const leaf); - void tHighpass_initToPool (tHighpass** const, Lfloat freq, tMempool* const); + void tHighpass_initToPool (tHighpass** const, Lfloat freq, tMempool** const); void tHighpass_free (tHighpass** const); // Tick function for `tHighpass` @@ -1023,7 +1022,7 @@ extern "C" { @brief Butterworth filter. @{ - @fn void tButterworth_init (tButterworth* const, int N, Lfloat f1, Lfloat f2, LEAF* const leaf, LEAF* const leaf) + @fn void tButterworth_init(tButterworth** const, int N, Lfloat f1, Lfloat f2, LEAF* const leaf, LEAF* const leaf) @brief Initialize a tButterworth to the default mempool of a LEAF instance. @param filter A pointer to the tButterworth to initialize. @param leaf A pointer to the leaf instance. @@ -1031,7 +1030,7 @@ extern "C" { @param lowCutoff Lower cutoff frequency. @param upperCutoff Upper cutoff frequency. - @fn void tButterworth_initToPool (tButterworth* const, int N, Lfloat f1, Lfloat f2, tMempool* const) + @fn void tButterworth_initToPool(tButterworth** const, int N, Lfloat f1, Lfloat f2, tMempool** const) @brief Initialize a tButterworth to a specified mempool. @param filter A pointer to the tButterworth to initialize. @param mempool A pointer to the tMempool to use. @@ -1039,7 +1038,7 @@ extern "C" { @param lowCutoff Lower cutoff frequency. @param upperCutoff Upper cutoff frequency. - @fn void tButterworth_free (tButterworth* const) + @fn void tButterworth_free(tButterworth** const) @brief Free a tButterworth from its mempool. @param filter A pointer to the tButterworth to free. @@ -1064,20 +1063,20 @@ extern "C" { #define NUM_SVF_BW 16 typedef struct tButterworth { - tMempool mempool; + tMempool* mempool; Lfloat gain; int order; int numSVF; - tSVF* svf; + tSVF** svfs; Lfloat f1,f2; } tButterworth; // Memory handlers for `tButterworth` void tButterworth_init (tButterworth** const, int N, Lfloat f1, Lfloat f2, LEAF* const leaf); - void tButterworth_initToPool (tButterworth** const, int N, Lfloat f1, Lfloat f2, tMempool* const); + void tButterworth_initToPool (tButterworth** const, int N, Lfloat f1, Lfloat f2, tMempool** const); void tButterworth_free (tButterworth** const); // Tick function for `tButterworth` @@ -1097,17 +1096,17 @@ extern "C" { @brief Finite impulse response filter. @{ - @fn void tFIR_init (tFIR* const, Lfloat* coeffs, int numTaps, LEAF* const leaf) + @fn void tFIR_init(tFIR** const, Lfloat* coeffs, int numTaps, LEAF* const leaf) @brief Initialize a tFIR to the default mempool of a LEAF instance. @param filter A pointer to the tFIR to initialize. @param leaf A pointer to the leaf instance. - @fn void tFIR_initToPool (tFIR* const, Lfloat* coeffs, int numTaps, tMempool* const) + @fn void tFIR_initToPool(tFIR** const, Lfloat* coeffs, int numTaps, tMempool** const) @brief Initialize a tFIR to a specified mempool. @param filter A pointer to the tFIR to initialize. @param mempool A pointer to the tMempool to use. - @fn void tFIR_free (tFIR* const) + @fn void tFIR_free(tFIR** const) @brief Free a tFIR from its mempool. @param filter A pointer to the tFIR to free. @@ -1119,8 +1118,8 @@ extern "C" { typedef struct tFIR { - - tMempool mempool; + + tMempool* mempool; Lfloat* past; Lfloat* coeff; int numTaps; @@ -1128,7 +1127,7 @@ extern "C" { // Memory handlers for `tFIR` void tFIR_init (tFIR** const, Lfloat* coeffs, int numTaps, LEAF* const leaf); - void tFIR_initToPool (tFIR** const, Lfloat* coeffs, int numTaps, tMempool* const); + void tFIR_initToPool (tFIR** const, Lfloat* coeffs, int numTaps, tMempool** const); void tFIR_free (tFIR** const); // Tick function for `tFIR` @@ -1143,17 +1142,17 @@ extern "C" { @brief Median filter. @{ - @fn void tMedianFilter_init (tMedianFilter* const, int size, LEAF* const leaf) + @fn void tMedianFilter_init(tMedianFilter** const, int size, LEAF* const leaf) @brief Initialize a tMedianFilter to the default mempool of a LEAF instance. @param filter A pointer to the tMedianFilter to initialize. @param leaf A pointer to the leaf instance.f - @fn void tMedianFilter_initToPool (tMedianFilter* const, int size, tMempool* const) + @fn void tMedianFilter_initToPool(tMedianFilter** const, int size, tMempool** const) @brief Initialize a tMedianFilter to a specified mempool. @param filter A pointer to the tMedianFilter to initialize. @param mempool A pointer to the tMempool to use. - @fn void tMedianFilter_free (tMedianFilter* const) + @fn void tMedianFilter_free(tMedianFilter** const) @brief Free a tMedianFilter from its mempool. @param filter A pointer to the tMedianFilter to free. @@ -1165,8 +1164,8 @@ extern "C" { typedef struct tMedianFilter { - - tMempool mempool; + + tMempool* mempool; Lfloat* val; int* age; int m; @@ -1178,7 +1177,7 @@ extern "C" { // Memory handlers for `tMedianFilter` void tMedianFilter_init (tMedianFilter** const, int size, LEAF* const leaf); - void tMedianFilter_initToPool (tMedianFilter** const, int size, tMempool* const); + void tMedianFilter_initToPool (tMedianFilter** const, int size, tMempool** const); void tMedianFilter_free (tMedianFilter** const); // Tick function for `tMedianFilter` @@ -1191,17 +1190,17 @@ extern "C" { @brief Vadim Zavalishin style from VA book (from implementation in RSlib posted to kvr forum) @{ - @fn void tVZFilter_init (tVZFilter* const, VZFilterType type, Lfloat freq, Lfloat Q, LEAF* const leaf) + @fn void tVZFilter_init(tVZFilter** const, VZFilterType type, Lfloat freq, Lfloat Q, LEAF* const leaf) @brief Initialize a tVZFilter to the default mempool of a LEAF instance. @param filter A pointer to the tVZFilter to initialize. @param leaf A pointer to the leaf instance. - @fn void tVZFilter_initToPool (tVZFilter* const, VZFilterType type, Lfloat freq, Lfloat Q, tMempool* const) + @fn void tVZFilter_initToPool(tVZFilter** const, VZFilterType type, Lfloat freq, Lfloat Q, tMempool** const) @brief Initialize a tVZFilter to a specified mempool. @param filter A pointer to the tVZFilter to initialize. @param mempool A pointer to the tMempool to use. - @fn void tVZFilter_free (tVZFilter* const) + @fn void tVZFilter_free(tVZFilter** const) @brief Free a tVZFilter from its mempool. @param filter A pointer to the tVZFilter to free. @@ -1265,7 +1264,7 @@ extern "C" { typedef struct tVZFilter { - tMempool mempool; + tMempool* mempool; VZFilterType type; // state: @@ -1296,7 +1295,7 @@ extern "C" { void tVZFilter_init (tVZFilter** const, VZFilterType type, Lfloat freq, Lfloat Q, LEAF* const leaf); void tVZFilter_initToPool (tVZFilter** const, VZFilterType type, Lfloat freq, Lfloat Q, - tMempool* const); + tMempool** const); void tVZFilter_free (tVZFilter** const); // Tick functions for `tVZFilter` @@ -1328,7 +1327,7 @@ extern "C" { typedef struct tVZFilterLS { - tMempool mempool; + tMempool* mempool; // state: Lfloat s1, s2; @@ -1356,7 +1355,7 @@ extern "C" { void tVZFilterLS_init (tVZFilterLS** const,Lfloat freq, Lfloat Q, Lfloat gain, LEAF* const leaf); void tVZFilterLS_initToPool (tVZFilterLS** const, Lfloat freq, Lfloat Q, Lfloat gain, - tMempool* const); + tMempool** const); void tVZFilterLS_free (tVZFilterLS** const); // Tick function for `tVZFilterLS` @@ -1374,7 +1373,7 @@ extern "C" { typedef struct tVZFilterHS { - tMempool mempool; + tMempool* mempool; // state: Lfloat s1, s2; @@ -1403,7 +1402,7 @@ extern "C" { void tVZFilterHS_init (tVZFilterHS** const,Lfloat freq, Lfloat Q, Lfloat gain, LEAF* const leaf); void tVZFilterHS_initToPool (tVZFilterHS** const, Lfloat freq, Lfloat Q, Lfloat gain, - tMempool* const); + tMempool** const); void tVZFilterHS_free (tVZFilterHS** const); // Tick function for `tVZFilterHS` @@ -1420,7 +1419,7 @@ extern "C" { typedef struct tVZFilterBell { - tMempool mempool; + tMempool* mempool; // state: Lfloat s1, s2; @@ -1447,7 +1446,7 @@ extern "C" { void tVZFilterBell_init (tVZFilterBell** const,Lfloat freq, Lfloat BW, Lfloat gain, LEAF* const leaf); void tVZFilterBell_initToPool (tVZFilterBell** const, Lfloat freq, Lfloat BW, Lfloat gain, - tMempool* const); + tMempool** const); void tVZFilterBell_free (tVZFilterBell** const); // Tick function for `tVZFilterBell` @@ -1466,7 +1465,7 @@ extern "C" { typedef struct tVZFilterBR { - tMempool mempool; + tMempool* mempool; // state: Lfloat s1, s2; @@ -1486,7 +1485,7 @@ extern "C" { // Memory handlers for `tVZFilterBR` void tVZFilterBR_init (tVZFilterBR** const,Lfloat freq, Lfloat Q, LEAF* const leaf); - void tVZFilterBR_initToPool (tVZFilterBR** const, Lfloat freq, Lfloat Q, tMempool* const); + void tVZFilterBR_initToPool (tVZFilterBR** const, Lfloat freq, Lfloat Q, tMempool** const); void tVZFilterBR_free (tVZFilterBR** const); // Tick function for `tVZFilterBR` @@ -1506,17 +1505,17 @@ extern "C" { @brief Diode filter. @{ - @fn void tDiodeFilter_init (tDiodeFilter* const, Lfloat freq, Lfloat Q, LEAF* const leaf) + @fn void tDiodeFilter_init(tDiodeFilter** const, Lfloat freq, Lfloat Q, LEAF* const leaf) @brief Initialize a tDiodeFilter to the default mempool of a LEAF instance. @param filter A pointer to the tDiodeFilter to initialize. @param leaf A pointer to the leaf instance. - @fn void tDiodeFilter_initToPool (tDiodeFilter* const, Lfloat freq, Lfloat Q, tMempool* const) + @fn void tDiodeFilter_initToPool(tDiodeFilter** const, Lfloat freq, Lfloat Q, tMempool** const) @brief Initialize a tDiodeFilter to a specified mempool. @param filter A pointer to the tDiodeFilter to initialize. @param mempool A pointer to the tMempool to use. - @fn void tDiodeFilter_free (tDiodeFilter* const) + @fn void tDiodeFilter_free(tDiodeFilter** const) @brief Free a tDiodeFilter from its mempool. @param filter A pointer to the tDiodeFilter to free. @@ -1537,7 +1536,7 @@ extern "C" { //diode ladder filter by Ivan C, based on mystran's method typedef struct tDiodeFilter { - tMempool mempool; + tMempool* mempool; Lfloat cutoff; Lfloat f; Lfloat r; @@ -1557,7 +1556,7 @@ extern "C" { // Memory handlers for `tDiodeFilter` void tDiodeFilter_init (tDiodeFilter** const, Lfloat freq, Lfloat Q, LEAF* const leaf); - void tDiodeFilter_initToPool (tDiodeFilter** const, Lfloat freq, Lfloat Q, tMempool* const); + void tDiodeFilter_initToPool (tDiodeFilter** const, Lfloat freq, Lfloat Q, tMempool** const); void tDiodeFilter_free (tDiodeFilter** const); // Tick functions for `tDiodeFilter` @@ -1575,7 +1574,7 @@ extern "C" { //transistor ladder filter by aciddose, based on mystran's method, KVR forums typedef struct tLadderFilter { - tMempool mempool; + tMempool* mempool; Lfloat cutoff; Lfloat invSampleRate; Lfloat sampleRatio; @@ -1594,7 +1593,7 @@ extern "C" { // Memory handlers for `tLadderFilter` void tLadderFilter_init (tLadderFilter** const, Lfloat freq, Lfloat Q, LEAF* const leaf); - void tLadderFilter_initToPool (tLadderFilter** const, Lfloat freq, Lfloat Q, tMempool* const); + void tLadderFilter_initToPool (tLadderFilter** const, Lfloat freq, Lfloat Q, tMempool** const); void tLadderFilter_free (tLadderFilter** const); // Tick function for `tLadderFilter` @@ -1611,7 +1610,7 @@ extern "C" { //tilt filter typedef struct tTiltFilter { - tMempool mempool; + tMempool* mempool; Lfloat cutoff; Lfloat sr3; Lfloat gfactor; @@ -1625,7 +1624,7 @@ extern "C" { // Memory handlers for `tTiltFilter` void tTiltFilter_init (tTiltFilter** const, Lfloat freq, LEAF* const leaf); - void tTiltFilter_initToPool (tTiltFilter** const, Lfloat freq, tMempool* const); + void tTiltFilter_initToPool (tTiltFilter** const, Lfloat freq, tMempool** const); void tTiltFilter_free (tTiltFilter** const); // Tick function for `tTiltFilter` diff --git a/leaf/Inc/leaf-global.h b/leaf/Inc/leaf-global.h index 76cf691..b446e81 100644 --- a/leaf/Inc/leaf-global.h +++ b/leaf/Inc/leaf-global.h @@ -37,8 +37,8 @@ extern "C" { Lfloat twoPiTimesInvSampleRate; //!< Two-pi times the inverse of the current sample rate. Lfloat (*random)(void); //!< A pointer to the random() function provided on initialization. int clearOnAllocation; //!< A flag that determines whether memory allocated from the LEAF memory pool will be cleared. - tMempool mempool; //!< The default LEAF mempool object. - _tMempool _internal_mempool; + tMempool* mempool; //!< The default LEAF mempool object. + tMempool _internal_mempool; size_t header_size; //!< The size in bytes of memory region headers within mempools. void (*errorCallback)(LEAF* const, LEAFErrorType); //!< A pointer to the callback function for LEAF errors. Can be set by the user. int errorState[LEAFErrorNil]; //!< An array of flags that indicate which errors have occurred. diff --git a/leaf/Inc/leaf-instruments.h b/leaf/Inc/leaf-instruments.h index 4152907..756ea97 100644 --- a/leaf/Inc/leaf-instruments.h +++ b/leaf/Inc/leaf-instruments.h @@ -37,17 +37,17 @@ extern "C" { @brief 808 drum machine cowbell. @{ - @fn void t808Cowbell_init (t808Cowbell* const, int useStick, LEAF* const leaf) + @fn void t808Cowbell_init(t808Cowbell** const, int useStick, LEAF* const leaf) @brief Initialize a t808Cowbell to the default mempool of a LEAF instance. @param cowbell A pointer to the t808Cowbell to initialize. @param leaf A pointer to the leaf instance. - @fn void t808Cowbell_initToPool (t808Cowbell* const, int useStick, tMempool* const) + @fn void t808Cowbell_initToPool(t808Cowbell** const, int useStick, tMempool** const) @brief Initialize a t808Cowbell to a specified mempool. @param cowbell A pointer to the t808Cowbell to initialize. @param mempool A pointer to the tMempool to use. - @fn void t808Cowbell_free (t808Cowbell* const) + @fn void t808Cowbell_free(t808Cowbell** const) @brief Free a t808Cowbell from its mempool. @param cowbell A pointer to the t808Cowbell to free. @@ -87,22 +87,22 @@ extern "C" { typedef struct t808Cowbell { - tMempool mempool; - tSquare p[2]; - tNoise stick; - tSVF bandpassOsc; - tSVF bandpassStick; - tEnvelope envGain; - tEnvelope envStick; - tEnvelope envFilter; - tHighpass highpass; + tMempool* mempool; + tSquare* p[2]; + tNoise* stick; + tSVF* bandpassOsc; + tSVF* bandpassStick; + tEnvelope* envGain; + tEnvelope* envStick; + tEnvelope* envFilter; + tHighpass* highpass; Lfloat oscMix; Lfloat filterCutoff; uint8_t useStick; } t808Cowbell; void t808Cowbell_init (t808Cowbell** const, int useStick, LEAF* const leaf); - void t808Cowbell_initToPool (t808Cowbell** const, int useStick, tMempool* const); + void t808Cowbell_initToPool (t808Cowbell** const, int useStick, tMempool** const); void t808Cowbell_free (t808Cowbell** const); Lfloat t808Cowbell_tick (t808Cowbell* const); @@ -124,17 +124,17 @@ extern "C" { @brief 808 drum machine hihat. @{ - @fn void t808Hihat_init (t808Hihat* const, LEAF* const leaf) + @fn void t808Hihat_init(t808Hihat** const, LEAF* const leaf) @brief Initialize a t808Hihat to the default mempool of a LEAF instance. @param hihat A pointer to the t808Hihat to initialize. @param leaf A pointer to the leaf instance. - @fn void t808Hihat_initToPool (t808Hihat* const, tMempool* const) + @fn void t808Hihat_initToPool(t808Hihat** const, tMempool** const) @brief Initialize a t808Hihat to a specified mempool. @param hihat A pointer to the t808Hihat to initialize. @param mempool A pointer to the tMempool to use. - @fn void t808Hihat_free (t808Hihat* const) + @fn void t808Hihat_free(t808Hihat** const) @brief Free a t808Hihat from its mempool. @param hihat A pointer to the t808Hihat to free. @@ -190,18 +190,18 @@ extern "C" { typedef struct t808Hihat { - - tMempool mempool; + + tMempool* mempool; // 6 Square waves - tSquare p[6]; - tNoise n; - tSVF bandpassOsc; - tSVF bandpassStick; - tEnvelope envGain; - tEnvelope envStick; - tEnvelope noiseFMGain; - tHighpass highpass; - tNoise stick; + tSquare* p[6]; + tNoise* n; + tSVF* bandpassOsc; + tSVF* bandpassStick; + tEnvelope* envGain; + tEnvelope* envStick; + tEnvelope* noiseFMGain; + tHighpass* highpass; + tNoise* stick; Lfloat freq; Lfloat stretch; @@ -210,7 +210,7 @@ extern "C" { } t808Hihat; void t808Hihat_init (t808Hihat** const, LEAF* const leaf); - void t808Hihat_initToPool (t808Hihat** const, tMempool* const); + void t808Hihat_initToPool (t808Hihat** const, tMempool** const); void t808Hihat_free (t808Hihat** const); Lfloat t808Hihat_tick (t808Hihat* const); @@ -236,17 +236,17 @@ extern "C" { @brief 808 drum machine snare. @{ - @fn void t808Snare_init (t808Snare* const, LEAF* const leaf) + @fn void t808Snare_init(t808Snare** const, LEAF* const leaf) @brief Initialize a t808Snare to the default mempool of a LEAF instance. @param snare A pointer to the t808Snare to initialize. @param leaf A pointer to the leaf instance. - @fn void t808Snare_initToPool (t808Snare* const, tMempool* const) + @fn void t808Snare_initToPool(t808Snare** const, tMempool** const) @brief Initialize a t808Snare to a specified mempool. @param snare A pointer to the t808Snare to initialize. @param mempool A pointer to the tMempool to use. - @fn void t808Snare_free (t808Snare* const) + @fn void t808Snare_free(t808Snare** const) @brief Free a t808Snare from its mempool. @param snare A pointer to the t808Snare to free. @@ -294,18 +294,18 @@ extern "C" { typedef struct t808Snare { - - tMempool mempool; + + tMempool* mempool; // Tone 1, Tone 2, Noise - tTriangle tone[2]; // Tri (not yet antialiased or wavetabled) - tNoise noiseOsc; - tSVF toneLowpass[2]; - tSVF noiseLowpass; // Lowpass from SVF filter - tEnvelope toneEnvOsc[2]; - tEnvelope toneEnvGain[2]; - tEnvelope noiseEnvGain; - tEnvelope toneEnvFilter[2]; - tEnvelope noiseEnvFilter; + tTriangle* tone[2]; // Tri (not yet antialiased or wavetabled) + tNoise* noiseOsc; + tSVF* toneLowpass[2]; + tSVF* noiseLowpass; // Lowpass from SVF filter + tEnvelope* toneEnvOsc[2]; + tEnvelope* toneEnvGain[2]; + tEnvelope* noiseEnvGain; + tEnvelope* toneEnvFilter[2]; + tEnvelope* noiseEnvFilter; Lfloat toneGain[2]; Lfloat noiseGain; @@ -318,7 +318,7 @@ extern "C" { } t808Snare; void t808Snare_init (t808Snare** const, LEAF* const leaf); - void t808Snare_initToPool (t808Snare** const, tMempool* const); + void t808Snare_initToPool (t808Snare** const, tMempool** const); void t808Snare_free (t808Snare** const); Lfloat t808Snare_tick (t808Snare* const); @@ -343,17 +343,17 @@ extern "C" { @brief 808 drum machine snare. @{ - @fn void t808SnareSmall_init (t808SnareSmall* const, LEAF* const leaf) + @fn void t808SnareSmall_init(t808SnareSmall** const, LEAF* const leaf) @brief Initialize a t808SnareSmall to the default mempool of a LEAF instance. @param snare A pointer to the t808SnareSmall to initialize. @param leaf A pointer to the leaf instance. - @fn void t808SnareSmall_initToPool (t808SnareSmall* const, tMempool* const) + @fn void t808SnareSmall_initToPool(t808SnareSmall** const, tMempool** const) @brief Initialize a t808SnareSmall to a specified mempool. @param snare A pointer to the t808SnareSmall to initialize. @param mempool A pointer to the tMempool to use. - @fn void t808SnareSmall_free (t808SnareSmall* const) + @fn void t808SnareSmall_free(t808SnareSmall** const) @brief Free a t808SnareSmall from its mempool. @param snare A pointer to the t808SnareSmall to free. @@ -401,18 +401,18 @@ extern "C" { typedef struct t808SnareSmall { - - tMempool mempool; + + tMempool* mempool; // Tone 1, Tone 2, Noise - tPBTriangle tone[2]; // Tri - tNoise noiseOsc; - tSVF toneLowpass[2]; - tSVF noiseLowpass; // Lowpass from SVF filter - tADSRS toneEnvOsc[2]; - tADSRS toneEnvGain[2]; - tADSRS noiseEnvGain; - tADSRS toneEnvFilter[2]; - tADSRS noiseEnvFilter; + tPBTriangle* tone[2]; // Tri + tNoise* noiseOsc; + tSVF* toneLowpass[2]; + tSVF* noiseLowpass; // Lowpass from SVF filter + tADSRS* toneEnvOsc[2]; + tADSRS* toneEnvGain[2]; + tADSRS* noiseEnvGain; + tADSRS* toneEnvFilter[2]; + tADSRS* noiseEnvFilter; Lfloat toneGain[2]; Lfloat noiseGain; @@ -425,7 +425,7 @@ extern "C" { } t808SnareSmall; void t808SnareSmall_init (t808SnareSmall** const, LEAF* const leaf); - void t808SnareSmall_initToPool (t808SnareSmall** const, tMempool* const); + void t808SnareSmall_initToPool (t808SnareSmall** const, tMempool** const); void t808SnareSmall_free (t808SnareSmall** const); Lfloat t808SnareSmall_tick (t808SnareSmall* const); @@ -448,17 +448,17 @@ extern "C" { @brief 808 drum machine kick. @{ - @fn void t808Kick_init (t808Kick* const, LEAF* const leaf) + @fn void t808Kick_init(t808Kick** const, LEAF* const leaf) @brief Initialize a t808Kick to the default mempool of a LEAF instance. @param kick A pointer to the t808Kick to initialize. @param leaf A pointer to the leaf instance. - @fn void t808Kick_initToPool (t808Kick* const, tMempool* const) + @fn void t808Kick_initToPool(t808Kick** const, tMempool** const) @brief Initialize a t808Kick to a specified mempool. @param kick A pointer to the t808Kick to initialize. @param mempool A pointer to the tMempool to use. - @fn void t808Kick_free (t808Kick* const) + @fn void t808Kick_free(t808Kick** const) @brief Free a t808Kick from its mempool. @param kick A pointer to the t808Kick to free. @@ -506,17 +506,17 @@ extern "C" { typedef struct t808Kick { + + tMempool* mempool; - tMempool mempool; - - tCycle tone; // Tri - tNoise noiseOsc; - tSVF toneLowpass; - tEnvelope toneEnvOscChirp; - tEnvelope toneEnvOscSigh; - tEnvelope toneEnvGain; - tEnvelope noiseEnvGain; - tEnvelope toneEnvFilter; + tCycle* tone; // Tri + tNoise* noiseOsc; + tSVF* toneLowpass; + tEnvelope* toneEnvOscChirp; + tEnvelope* toneEnvOscSigh; + tEnvelope* toneEnvGain; + tEnvelope* noiseEnvGain; + tEnvelope* toneEnvFilter; Lfloat toneGain; Lfloat noiseGain; @@ -528,7 +528,7 @@ extern "C" { } t808Kick; void t808Kick_init (t808Kick** const, LEAF* const leaf); - void t808Kick_initToPool (t808Kick** const, tMempool* const); + void t808Kick_initToPool (t808Kick** const, tMempool** const); void t808Kick_free (t808Kick** const); Lfloat t808Kick_tick (t808Kick* const); @@ -553,17 +553,17 @@ extern "C" { @brief 808 drum machine kick. @{ - @fn void t808KickSmall_init (t808KickSmall* const, LEAF* const leaf) + @fn void t808KickSmall_init(t808KickSmall** const, LEAF* const leaf) @brief Initialize a t808KickSmall to the default mempool of a LEAF instance. @param kick A pointer to the t808KickSmall to initialize. @param leaf A pointer to the leaf instance. - @fn void t808KickSmall_initToPool (t808KickSmall* const, tMempool* const) + @fn void t808KickSmall_initToPool(t808KickSmall** const, tMempool** const) @brief Initialize a t808KickSmall to a specified mempool. @param kick A pointer to the t808KickSmall to initialize. @param mempool A pointer to the tMempool to use. - @fn void t808KickSmall_free (t808KickSmall* const) + @fn void t808KickSmall_free(t808KickSmall** const) @brief Free a t808KickSmall from its mempool. @param kick A pointer to the t808KickSmall to free. @@ -611,17 +611,17 @@ extern "C" { typedef struct t808KickSmall { + + tMempool* mempool; - tMempool mempool; - - tCycle tone; // Tri - tNoise noiseOsc; - tSVF toneLowpass; - tADSRS toneEnvOscChirp; - tADSRS toneEnvOscSigh; - tADSRS toneEnvGain; - tADSRS noiseEnvGain; - tADSRS toneEnvFilter; + tCycle* tone; // Tri + tNoise* noiseOsc; + tSVF* toneLowpass; + tADSRS* toneEnvOscChirp; + tADSRS* toneEnvOscSigh; + tADSRS* toneEnvGain; + tADSRS* noiseEnvGain; + tADSRS* toneEnvFilter; Lfloat toneGain; Lfloat noiseGain; @@ -633,7 +633,7 @@ extern "C" { } t808KickSmall; void t808KickSmall_init (t808KickSmall** const, LEAF* const leaf); - void t808KickSmall_initToPool (t808KickSmall** const, tMempool* const); + void t808KickSmall_initToPool (t808KickSmall** const, tMempool** const); void t808KickSmall_free (t808KickSmall** const); Lfloat t808KickSmall_tick (t808KickSmall* const); diff --git a/leaf/Inc/leaf-mempool.h b/leaf/Inc/leaf-mempool.h index c577bda..62e7ecd 100644 --- a/leaf/Inc/leaf-mempool.h +++ b/leaf/Inc/leaf-mempool.h @@ -77,11 +77,11 @@ extern "C" { size_t size; } mpool_node_t; - typedef struct _tMempool _tMempool; - typedef _tMempool* tMempool; - struct _tMempool + typedef struct tMempool tMempool; + + struct tMempool { - tMempool mempool; + tMempool* mempool; LEAF* leaf; char* mpool; // start of the mpool size_t usize; // used size of the pool @@ -97,14 +97,14 @@ extern "C" { @param size The size of the chunk of memory to be used as a mempool. @param leaf A pointer to the leaf instance. */ - void tMempool_init (tMempool* const pool, char* memory, size_t size, LEAF* const leaf); + void tMempool_init (tMempool** const pool, char* memory, size_t size, LEAF* const leaf); //! Free a tMempool from its mempool. /*! @param pool A pointer to the tMempool to free. */ - void tMempool_free (tMempool* const pool); + void tMempool_free (tMempool** const pool); //! Initialize a tMempool for a given memory location and size to a specified mempool. @@ -114,7 +114,7 @@ extern "C" { @param size The size of the chuck of memory to be used as a mempool. @param poolTo A pointer to the tMempool to which this tMempool should be initialized. */ - void tMempool_initToPool (tMempool* const mp, char* memory, size_t size, tMempool* const mem); + void tMempool_initToPool (tMempool** const mp, char* memory, size_t size, tMempool** const mem); /*! @} */ @@ -129,15 +129,15 @@ extern "C" { // mpool_node_t* head; // first node of memory pool free list // } mpool_t; - void mpool_create (char* memory, size_t size, _tMempool* pool); + void mpool_create (char* memory, size_t size, tMempool* pool); - char* mpool_alloc(size_t size, _tMempool* pool); - char* mpool_calloc(size_t asize, _tMempool* pool); + char* mpool_alloc(size_t size, tMempool* pool); + char* mpool_calloc(size_t asize, tMempool* pool); - void mpool_free(char* ptr, _tMempool* pool); + void mpool_free(char* ptr, tMempool* pool); - size_t mpool_get_size(_tMempool* pool); - size_t mpool_get_used(_tMempool* pool); + size_t mpool_get_size(tMempool* pool); + size_t mpool_get_used(tMempool* pool); void leaf_pool_init(LEAF* const leaf, char* memory, size_t size); diff --git a/leaf/Inc/leaf-midi.h b/leaf/Inc/leaf-midi.h index 4ee4a9f..6777bdc 100644 --- a/leaf/Inc/leaf-midi.h +++ b/leaf/Inc/leaf-midi.h @@ -38,17 +38,17 @@ extern "C" { @brief A basic stack of integers with a fixed capacity of 128, used by tPoly to keep track of MIDI notes. @{ - @fn void tStack_init (tStack* const stack, LEAF* const leaf) + @fn void tStack_init(tStack** const stack, LEAF* const leaf) @brief Initialize a tStack to the default mempool of a LEAF instance. @param stack A pointer to the tStack to initialize. @param leaf A pointer to the leaf instance. - @fn void tStack_initToPool (tStack* const stack, tMempool* const mempool) + @fn void tStack_initToPool(tStack** const stack, tMempool** const mempool) @brief Initialize a tStack to a specified mempool. @param stack A pointer to the tStack to initialize. @param mempool A pointer to the tMempool to use. - @fn void tStack_free (tStack* const stack) + @fn void tStack_free(tStack** const stack) @brief Free a tStack from its mempool. @param stack A pointer to the tStack to free. @@ -108,8 +108,8 @@ extern "C" { #define STACK_SIZE 128 typedef struct tStack { - - tMempool mempool; + + tMempool* mempool; int data[STACK_SIZE]; uint16_t pos; uint16_t size; @@ -118,7 +118,7 @@ extern "C" { } tStack; void tStack_init (tStack** const stack, LEAF* const leaf); - void tStack_initToPool (tStack** const stack, tMempool* const pool); + void tStack_initToPool (tStack** const stack, tMempool** const pool); void tStack_free (tStack** const stack); void tStack_setCapacity (tStack* const stack, uint16_t cap); @@ -138,18 +138,18 @@ extern "C" { @brief Polyphony handler with glide and pitch bend options. @{ - @fn void tPoly_init (tPoly* const poly, int maxNumVoices, LEAF* const leaf) + @fn void tPoly_init(tPoly** const poly, int maxNumVoices, LEAF* const leaf) @brief Initialize a tPoly to the default mempool of a LEAF instance. @param poly A pointer to the tPoly to initialize. @param maxNumVoices The maximum number of voices this tPoly can handle at once. @param leaf A pointer to the leaf instance. - @fn void tPoly_initToPool (tPoly* const poly, int maxNumVoices, tMempool* const pool) + @fn void tPoly_initToPool(tPoly** const poly, int maxNumVoices, tMempool** const pool) @brief Initialize a tPoly to a specified mempool. @param poly A pointer to the tPoly to initialize. @param mempool A pointer to the tMempool to use. - @fn void tPoly_free (tPoly* const poly) + @fn void tPoly_free(tPoly** const poly) @brief Free a tPoly from its mempool. @param poly A pointer to the tPoly to free. @@ -248,13 +248,13 @@ extern "C" { typedef struct tPoly { + + tMempool* mempool; - tMempool mempool; - - tStack stack; - tStack orderStack; + tStack* stack; + tStack* orderStack; - tRamp* ramps; + tRamp** ramps; Lfloat* rampVals; int* firstReceived; Lfloat glideTime; @@ -275,7 +275,7 @@ extern "C" { int lastVoiceToChange; Lfloat pitchBend; - tRamp pitchBendRamp; + tRamp* pitchBendRamp; int currentNote; int currentVoice; @@ -284,7 +284,7 @@ extern "C" { } tPoly; void tPoly_init (tPoly** const poly, int maxNumVoices, LEAF* const leaf); - void tPoly_initToPool (tPoly** const poly, int maxNumVoices, tMempool* const pool); + void tPoly_initToPool (tPoly** const poly, int maxNumVoices, tMempool** const pool); void tPoly_free (tPoly** const poly); void tPoly_tickPitch (tPoly* const poly); @@ -316,18 +316,18 @@ extern "C" { @brief Polyphony handler. @{ - @fn void tSimplePoly_init (tSimplePoly* const poly, int maxNumVoices, LEAF* const leaf) + @fn void tSimplePoly_init(tSimplePoly** const poly, int maxNumVoices, LEAF* const leaf) @brief Initialize a tSimplePoly to the default mempool of a LEAF instance. @param poly A pointer to the tSimplePoly to initialize. @param maxNumVoices The maximum number of voices this tSimplePoly can handle at once. @param leaf A pointer to the leaf instance. - @fn void tSimplePoly_initToPool (tSimplePoly* const poly, int maxNumVoices, tMempool* const pool) + @fn void tSimplePoly_initToPool(tSimplePoly** const poly, int maxNumVoices, tMempool** const pool) @brief Initialize a tSimplePoly to a specified mempool. @param poly A pointer to the tSimplePoly to initialize. @param mempool A pointer to the tMempool to use. - @fn void tSimplePoly_free (tSimplePoly* const poly) + @fn void tSimplePoly_free(tSimplePoly** const poly) @brief Free a tSimplePoly from its mempool. @param poly A pointer to the tSimplePoly to free. @@ -395,9 +395,9 @@ extern "C" { @} */ typedef struct tSimplePoly { - tMempool mempool; + tMempool* mempool; - tStack stack; + tStack* stack; int numVoices; int maxNumVoices; @@ -409,7 +409,7 @@ extern "C" { } tSimplePoly; void tSimplePoly_init (tSimplePoly** const poly, int maxNumVoices, LEAF* const leaf); - void tSimplePoly_initToPool (tSimplePoly** const poly, int maxNumVoices, tMempool* const pool); + void tSimplePoly_initToPool (tSimplePoly** const poly, int maxNumVoices, tMempool** const pool); void tSimplePoly_free (tSimplePoly** const poly); int tSimplePoly_noteOn (tSimplePoly* const poly, int note, uint8_t vel); diff --git a/leaf/Inc/leaf-oscillators.h b/leaf/Inc/leaf-oscillators.h index d97c73e..17066b6 100644 --- a/leaf/Inc/leaf-oscillators.h +++ b/leaf/Inc/leaf-oscillators.h @@ -34,17 +34,17 @@ extern "C" { @brief Wavetable cycle/sine wave oscillator @{ - @fn void tCycle_init (tCycle* const osc, LEAF* const leaf) + @fn void tCycle_init(tCycle** const osc, LEAF* const leaf) @brief Initialize a tCycle to the default mempool of a LEAF instance. @param osc A pointer to the tCycle to initialize. @param leaf A pointer to the leaf instance. - @fn void tCycle_initToPool (tCycle* const osc, tMempool* const mempool) + @fn void tCycle_initToPool(tCycle** const osc, tMempool** const mempool) @brief Initialize a tCycle to a specified mempool. @param osc A pointer to the tCycle to initialize. @param mempool A pointer to the tMempool to use. - @fn void tCycle_free (tCycle* const osc) + @fn void tCycle_free(tCycle** const osc) @brief Free a tCycle from its mempool. @param osc A pointer to the tCycle to free. @@ -63,7 +63,7 @@ extern "C" { typedef struct tCycle { - tMempool mempool; + tMempool* mempool; // Underlying phasor uint32_t phase; int32_t inc; @@ -74,7 +74,7 @@ extern "C" { // Memory handlers for `tCycle` void tCycle_init (tCycle** const osc, LEAF* const leaf); - void tCycle_initToPool (tCycle** const osc, tMempool* const mempool); + void tCycle_initToPool (tCycle** const osc, tMempool** const mempool); void tCycle_free (tCycle** const osc); // Tick function for `tCycle` @@ -93,17 +93,17 @@ extern "C" { @brief Anti-aliased wavetable triangle wave oscillator. @{ - @fn void tTriangle_init (tTriangle* const osc, LEAF* const leaf) + @fn void tTriangle_init(tTriangle** const osc, LEAF* const leaf) @brief Initialize a tTriangle to the default mempool of a LEAF instance. @param osc A pointer to the tTriangle to initialize. @param leaf A pointer to the leaf instance. - @fn void tTriangle_initToPool (tTriangle* const osc, tMempool* const mempool) + @fn void tTriangle_initToPool(tTriangle** const osc, tMempool** const mempool) @brief Initialize a tTriangle to a specified mempool. @param osc A pointer to the tTriangle to initialize. @param mempool A pointer to the tMempool to use. - @fn void tTriangle_free (tTriangle* const osc) + @fn void tTriangle_free(tTriangle** const osc) @brief Free a tTriangle from its mempool. @param osc A pointer to the tTriangle to free. @@ -121,7 +121,7 @@ extern "C" { typedef struct tTriangle { - tMempool mempool; + tMempool* mempool; // Underlying phasor uint32_t phase; int32_t inc; @@ -135,7 +135,7 @@ extern "C" { // Memory handlers for `tTriangle` void tTriangle_init (tTriangle** const osc, LEAF* const leaf); - void tTriangle_initToPool (tTriangle** const osc, tMempool* const mempool); + void tTriangle_initToPool (tTriangle** const osc, tMempool** const mempool); void tTriangle_free (tTriangle** const osc); // Tick function for `tTriangle` @@ -154,17 +154,17 @@ extern "C" { @brief Anti-aliased wavetable square wave oscillator. @{ - @fn void tSquare_init (tSquare* const osc, LEAF* const leaf) + @fn void tSquare_init(tSquare** const osc, LEAF* const leaf) @brief Initialize a tSquare to the default mempool of a LEAF instance. @param osc A pointer to the tSquare to initialize. @param leaf A pointer to the leaf instance. - @fn void tSquare_initToPool (tSquare* const osc, tMempool* const mempool) + @fn void tSquare_initToPool(tSquare** const osc, tMempool** const mempool) @brief Initialize a tSquare to a specified mempool. @param osc A pointer to the tSquare to initialize. @param mempool A pointer to the tMempool to use. - @fn void tSquare_free (tSquare* const osc) + @fn void tSquare_free(tSquare** const osc) @brief Free a tSquare from its mempool. @param osc A pointer to the tSquare to free. @@ -182,7 +182,7 @@ extern "C" { typedef struct tSquare { - tMempool mempool; + tMempool* mempool; // Underlying phasor uint32_t phase; int32_t inc; @@ -196,7 +196,7 @@ extern "C" { // Memory handlers for `tSquare` void tSquare_init (tSquare** const osc, LEAF* const leaf); - void tSquare_initToPool (tSquare** const osc, tMempool* const mempool); + void tSquare_initToPool (tSquare** const osc, tMempool** const mempool); void tSquare_free (tSquare** const osc); // Tick function for `tSquare` @@ -218,17 +218,17 @@ extern "C" { @brief Anti-aliased wavetable saw wave oscillator. @{ - @fn void tSawtooth_init (tSawtooth* const osc, LEAF* const leaf) + @fn void tSawtooth_init(tSawtooth** const osc, LEAF* const leaf) @brief Initialize a tSawtooth to the default mempool of a LEAF instance. @param osc A pointer to the tSawtooth to initialize. @param leaf A pointer to the leaf instance. - @fn void tSawtooth_initToPool (tSawtooth* const osc, tMempool* const mempool) + @fn void tSawtooth_initToPool(tSawtooth** const osc, tMempool** const mempool) @brief Initialize a tSawtooth to a specified mempool. @param osc A pointer to the tSawtooth to initialize. @param mempool A pointer to the tMempool to use. - @fn void tSawtooth_free (tSawtooth* const osc) + @fn void tSawtooth_free(tSawtooth** const osc) @brief Free a tSawtooth from its mempool. @param osc A pointer to the tSawtooth to free. @@ -246,7 +246,7 @@ extern "C" { typedef struct tSawtooth { - tMempool mempool; + tMempool* mempool; // Underlying phasor uint32_t phase; int32_t inc; @@ -260,7 +260,7 @@ extern "C" { // Memory handlers for `tSawtooth` void tSawtooth_init (tSawtooth** const osc, LEAF* const leaf); - void tSawtooth_initToPool (tSawtooth** const osc, tMempool* const mempool); + void tSawtooth_initToPool (tSawtooth** const osc, tMempool** const mempool); void tSawtooth_free (tSawtooth** const osc); // Tick function for `tSawtooth` @@ -279,17 +279,17 @@ extern "C" { @brief Triangle wave oscillator with polyBLEP anti-aliasing. @{ - @fn void tPBTriangle_init (tPBTriangle* const osc, LEAF* const leaf) + @fn void tPBTriangle_init(tPBTriangle** const osc, LEAF* const leaf) @brief Initialize a tPBTriangle to the default mempool of a LEAF instance. @param osc A pointer to the tPBTriangle to initialize. @param leaf A pointer to the leaf instance. - @fn void tPBTriangle_initToPool (tPBTriangle* const osc, tMempool* const mempool) + @fn void tPBTriangle_initToPool(tPBTriangle** const osc, tMempool** const mempool) @brief Initialize a tPBTriangle to a specified mempool. @param osc A pointer to the tPBTriangle to initialize. @param mempool A pointer to the tMempool to use. - @fn void tPBTriangle_free (tPBTriangle* const osc) + @fn void tPBTriangle_free(tPBTriangle** const osc) @brief Free a tTri from its mempool. @param osc A pointer to the tPBTriangle to free. @@ -309,9 +309,9 @@ extern "C" { typedef struct tPBSineTriangle { - tMempool mempool; + tMempool* mempool; uint32_t phase; - tCycle sine; + tCycle* sine; int32_t inc; Lfloat freq; Lfloat shape; @@ -322,7 +322,7 @@ extern "C" { // Memory handlers for `tPBSineTriangle` void tPBSineTriangle_init (tPBSineTriangle** const osc, LEAF* const leaf); - void tPBSineTriangle_initToPool (tPBSineTriangle** const osc, tMempool* const mempool); + void tPBSineTriangle_initToPool (tPBSineTriangle** const osc, tMempool** const mempool); void tPBSineTriangle_free (tPBSineTriangle** const osc); @@ -346,7 +346,7 @@ extern "C" { typedef struct tPBTriangle { - tMempool mempool; + tMempool* mempool; uint32_t phase; int32_t inc; Lfloat freq; @@ -359,7 +359,7 @@ extern "C" { // Memory handlers for `tPBTriangle` void tPBTriangle_init (tPBTriangle** const osc, LEAF* const leaf); - void tPBTriangle_initToPool (tPBTriangle** const osc, tMempool* const mempool); + void tPBTriangle_initToPool (tPBTriangle** const osc, tMempool** const mempool); void tPBTriangle_free (tPBTriangle** const osc); #ifdef ITCMRAM @@ -384,17 +384,17 @@ extern "C" { @brief Pulse wave oscillator with polyBLEP anti-aliasing. @{ - @fn void tPBPulse_init (tPBPulse* const osc, LEAF* const leaf) + @fn void tPBPulse_init(tPBPulse** const osc, LEAF* const leaf) @brief Initialize a tPBPulse to the default mempool of a LEAF instance. @param osc A pointer to the tPBPulse to initialize. @param leaf A pointer to the leaf instance. - @fn void tPBPulse_initToPool (tPBPulse* const osc, tMempool* const) + @fn void tPBPulse_initToPool(tPBPulse** const osc, tMempool** const) @brief Initialize a tPBPulse to a specified mempool. @param osc A pointer to the tPBPulse to initialize. @param mempool A pointer to the tMempool to use. - @fn void tPBPulse_free (tPBPulse* const osc) + @fn void tPBPulse_free(tPBPulse** const osc) @brief Free a tPBPulse from its mempool. @param osc A pointer to the tPBPulse to free. @@ -414,7 +414,7 @@ extern "C" { typedef struct tPBPulse { - tMempool mempool; + tMempool* mempool; uint32_t phase; int32_t inc; Lfloat freq; @@ -426,7 +426,7 @@ extern "C" { // Memory handlers for `tPBPulse` void tPBPulse_init (tPBPulse** const osc, LEAF* const leaf); - void tPBPulse_initToPool (tPBPulse** const osc, tMempool* const); + void tPBPulse_initToPool (tPBPulse** const osc, tMempool** const); void tPBPulse_free (tPBPulse** const osc); #ifdef ITCMRAM @@ -452,17 +452,17 @@ extern "C" { @brief Saw wave oscillator with polyBLEP anti-aliasing. @{ - @fn void tPBSaw_init (tPBSaw* const osc, LEAF* const leaf) + @fn void tPBSaw_init(tPBSaw** const osc, LEAF* const leaf) @brief Initialize a tPBSaw to the default mempool of a LEAF instance. @param osc A pointer to the tPBSaw to initialize. @param leaf A pointer to the leaf instance. - @fn void tPBSaw_initToPool (tPBSaw* const osc, tMempool* const mempool) + @fn void tPBSaw_initToPool(tPBSaw** const osc, tMempool** const mempool) @brief Initialize a tPBSaw to a specified mempool. @param osc A pointer to the tPBSaw to initialize. @param mempool A pointer to the tMempool to use. - @fn void tPBSaw_free (tPBSaw* const osc) + @fn void tPBSaw_free(tPBSaw** const osc) @brief Free a tPBSaw from its mempool. @param osc A pointer to the tPBSaw to free. @@ -478,7 +478,7 @@ extern "C" { typedef struct tPBSaw { - tMempool mempool; + tMempool* mempool; uint32_t phase; int32_t inc; Lfloat freq; @@ -490,7 +490,7 @@ extern "C" { // Memory handlers for `tPBSaw` void tPBSaw_init (tPBSaw** const osc, LEAF* const leaf); - void tPBSaw_initToPool (tPBSaw** const osc, tMempool* const mempool); + void tPBSaw_initToPool (tPBSaw** const osc, tMempool** const mempool); void tPBSaw_free (tPBSaw** const osc); #ifdef ITCMRAM @@ -511,7 +511,7 @@ extern "C" { typedef struct tPBSawSquare { - tMempool mempool; + tMempool* mempool; uint32_t phase; int32_t inc; Lfloat freq; @@ -526,7 +526,7 @@ typedef struct tPBSawSquare // Memory handlers for `tPBSawSquare` void tPBSawSquare_init (tPBSawSquare** const osc, LEAF* const leaf); - void tPBSawSquare_initToPool (tPBSawSquare** const osc, tMempool* const mempool); + void tPBSawSquare_initToPool (tPBSawSquare** const osc, tMempool** const mempool); void tPBSawSquare_free (tPBSawSquare** const osc); #ifdef ITCMRAM @@ -547,7 +547,7 @@ typedef struct tPBSawSquare //============================================================================== typedef struct tSawOS { - tMempool mempool; + tMempool* mempool; uint32_t phase; int32_t inc; Lfloat freq; @@ -556,13 +556,13 @@ typedef struct tPBSawSquare Lfloat invSampleRateOS; uint8_t OSratio; uint32_t invSampleRateTimesTwoTo32OS; - tSVF* aaFilter; + tSVF** aaFilters; uint8_t filterOrder; } tSawOS; // Memory handlers for `tSawOS` void tSawOS_init (tSawOS** const osc, uint8_t OS_ratio, uint8_t filterOrder, LEAF* const leaf); - void tSawOS_initToPool (tSawOS** const osc, uint8_t OS_ratio, uint8_t filterOrder, tMempool* const mp); + void tSawOS_initToPool (tSawOS** const osc, uint8_t OS_ratio, uint8_t filterOrder, tMempool** const mp); void tSawOS_free (tSawOS** const osc); // Tick function for `tSawOS` @@ -581,17 +581,17 @@ typedef struct tPBSawSquare @brief Aliasing phasor. @{ - @fn void tPhasor_init (tPhasor* const osc, LEAF* const leaf) + @fn void tPhasor_init(tPhasor** const osc, LEAF* const leaf) @brief Initialize a tPhasor to the default mempool of a LEAF instance. @param osc A pointer to the tPhasor to initialize. @param leaf A pointer to the leaf instance. - @fn void tPhasor_initToPool (tPhasor* const osc, tMempool* const) + @fn void tPhasor_initToPool(tPhasor** const osc, tMempool** const) @brief Initialize a tPhasor to a specified mempool. @param osc A pointer to the tPhasor to initialize. @param mempool A pointer to the tMempool to use. - @fn void tPhasor_free (tPhasor* const osc) + @fn void tPhasor_free(tPhasor** const osc) @brief Free a tPhasor from its mempool. @param osc A pointer to the tPhasor to free. @@ -607,8 +607,8 @@ typedef struct tPBSawSquare typedef struct tPhasor { - - tMempool mempool; + + tMempool* mempool; uint32_t phase; int32_t inc; Lfloat freq; @@ -618,7 +618,7 @@ typedef struct tPBSawSquare // Memory handlers for `tPhasor` void tPhasor_init (tPhasor** const osc, LEAF* const leaf); - void tPhasor_initToPool (tPhasor** const osc, tMempool* const); + void tPhasor_initToPool (tPhasor** const osc, tMempool** const); void tPhasor_free (tPhasor** const osc); // Tick function for `tPhasor` @@ -636,17 +636,17 @@ typedef struct tPBSawSquare @brief Noise generator, capable of producing white or pink noise. @{ - @fn void tNoise_init (tNoise* const noise, NoiseType type, LEAF* const leaf) + @fn void tNoise_init(tNoise** const noise, NoiseType type, LEAF* const leaf) @brief Initialize a tNoise to the default mempool of a LEAF instance. @param noise A pointer to the tNoise to initialize. @param leaf A pointer to the leaf instance. - @fn void tNoise_initToPool (tNoise* const noise, NoiseType type, tMempool* const) + @fn void tNoise_initToPool(tNoise** const noise, NoiseType type, tMempool** const) @brief Initialize a tNoise to a specified mempool. @param noise A pointer to the tNoise to initialize. @param mempool A pointer to the tMempool to use. - @fn void tNoise_free (tNoise* const noise) + @fn void tNoise_free(tNoise** const noise) @brief Free a tNoise from its mempool. @param noise A pointer to the tNoise to free. @@ -671,7 +671,7 @@ typedef struct tPBSawSquare typedef struct tNoise { - tMempool mempool; + tMempool* mempool; NoiseType type; Lfloat pinkb0, pinkb1, pinkb2; Lfloat(*rand)(void); @@ -679,7 +679,7 @@ typedef struct tPBSawSquare // Memory handlers for `tNoise` void tNoise_init (tNoise** const noise, NoiseType type, LEAF* const leaf); - void tNoise_initToPool (tNoise** const noise, NoiseType type, tMempool* const); + void tNoise_initToPool (tNoise** const noise, NoiseType type, tMempool** const); void tNoise_free (tNoise** const noise); // Tick function for `tNoise` @@ -693,17 +693,17 @@ typedef struct tPBSawSquare @brief Model of a neuron, adapted to act as an oscillator. @{ - @fn void tNeuron_init (tNeuron* const neuron, LEAF* const leaf) + @fn void tNeuron_init(tNeuron** const neuron, LEAF* const leaf) @brief Initialize a tNeuron to the default mempool of a LEAF instance. @param neuron A pointer to the tNeuron to initialize. @param leaf A pointer to the leaf instance. - @fn void tNeuron_initToPool (tNeuron* const neuron, tMempool* const mempool) + @fn void tNeuron_initToPool(tNeuron** const neuron, tMempool** const mempool) @brief Initialize a tNeuron to a specified mempool. @param neuron A pointer to the tNeuron to initialize. @param mempool A pointer to the tMempool to use. - @fn void tNeuron_free (tNeuron* const neuron) + @fn void tNeuron_free(tNeuron** const neuron) @brief Free a tNeuron from its mempool. @param neuron A pointer to the tNeuron to free. @@ -780,9 +780,9 @@ typedef struct tPBSawSquare typedef struct tNeuron { - tMempool mempool; + tMempool* mempool; - tPoleZero f; + tPoleZero* f; NeuronMode mode; @@ -799,7 +799,7 @@ typedef struct tPBSawSquare // Memory handlers for `tNeuron` void tNeuron_init (tNeuron** const neuron, LEAF* const leaf); - void tNeuron_initToPool (tNeuron** const neuron, tMempool* const mempool); + void tNeuron_initToPool (tNeuron** const neuron, tMempool** const mempool); void tNeuron_free (tNeuron** const neuron); // Tick function for `tNeuron` @@ -832,15 +832,15 @@ typedef struct tPBSawSquare @brief Pulse wave oscillator with minBLEP anti-aliasing. @{ - @fn void tMBPulse_init(tMBPulse* const osc, LEAF* const leaf) + @fn void tMBPulse_init(tMBPulse** const osc, LEAF* const leaf) @brief Initialize a tMBPulse to the default mempool of a LEAF instance. @param osc A pointer to the tMBPulse to initialize. - @fn void tMBPulse_initToPool(tMBPulse* const osc, tMempool* const mempool) + @fn void tMBPulse_initToPool(tMBPulse** const osc, tMempool** const mempool) @brief Initialize a tMBPulse to a specified mempool. @param osc A pointer to the tMBPulse to initialize. - @fn void tMBPulse_free(tMBPulse* const osc) + @fn void tMBPulse_free(tMBPulse** const osc) @brief Free a tMBPulse from its mempool. @param osc A pointer to the tMBPulse to free. @@ -868,8 +868,8 @@ typedef struct tPBSawSquare typedef struct tMBPulse { - - tMempool mempool; + + tMempool* mempool; Lfloat out; Lfloat freq; Lfloat waveform; // duty cycle, must be in [-1, 1] @@ -892,12 +892,12 @@ typedef struct tPBSawSquare // Memory handlers for `tMBPulse` void tMBPulse_init (tMBPulse** const osc, LEAF* const leaf); - void tMBPulse_initToPool (tMBPulse** const osc, tMempool* const mempool); + void tMBPulse_initToPool (tMBPulse** const osc, tMempool** const mempool); void tMBPulse_free (tMBPulse** const osc); #ifdef ITCMRAM void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBPulse_place_step_dd_noBuffer(tMBPulse* const osc, int index, Lfloat phase, Lfloat inv_w, Lfloat scale); #else - void tMBPulse_place_step_dd_noBuffer (tMBPulse const osc, int index, Lfloat phase, Lfloat inv_w, Lfloat scale); + void tMBPulse_place_step_dd_noBuffer (tMBPulse* const osc, int index, Lfloat phase, Lfloat inv_w, Lfloat scale); #endif // Tick function for `tMBPulse` Lfloat tMBPulse_tick (tMBPulse* const osc); @@ -917,15 +917,15 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBPul @brief Triangle wave oscillator with minBLEP anti-aliasing. @{ - @fn void tMBTriangle_init(tMBTriangle* const osc, LEAF* const leaf) + @fn void tMBTriangle_init(tMBTriangle** const osc, LEAF* const leaf) @brief Initialize a tMBTriangle to the default mempool of a LEAF instance. @param osc A pointer to the tMBTriangle to initialize. - @fn void tMBTriangle_initToPool(tMBTriangle* const osc, tMempool* const mempool) + @fn void tMBTriangle_initToPool(tMBTriangle** const osc, tMempool** const mempool) @brief Initialize a tMBTriangle to a specified mempool. @param osc A pointer to the tMBTriangle to initialize. - @fn void tMBTriangle_free(tMBTriangle* const osc) + @fn void tMBTriangle_free(tMBTriangle** const osc) @brief Free a tMBTriangle from its mempool. @param osc A pointer to the tMBTriangle to free. @@ -953,8 +953,8 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBPul typedef struct tMBTriangle { - - tMempool mempool; + + tMempool* mempool; Lfloat out; Lfloat freq; Lfloat waveform; // duty cycle, must be in [-1, 1] @@ -978,7 +978,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBPul // Memory handlers for `tMBTriangle` void tMBTriangle_init (tMBTriangle** const osc, LEAF* const leaf); - void tMBTriangle_initToPool (tMBTriangle** const osc, tMempool* const mempool); + void tMBTriangle_initToPool (tMBTriangle** const osc, tMempool** const mempool); void tMBTriangle_free (tMBTriangle** const osc); #ifdef ITCMRAM void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBTriangle_place_dd_noBuffer(tMBTriangle* const osc, int index, Lfloat phase, Lfloat inv_w, Lfloat scale, Lfloat stepOrSlope, Lfloat w); @@ -1005,7 +1005,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBTri typedef struct tMBSineTri { - tMempool mempool; + tMempool* mempool; Lfloat out; Lfloat freq; Lfloat waveform; // duty cycle, must be in [-1, 1] @@ -1031,7 +1031,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBTri // Memory handlers for `tMBSineTri` void tMBSineTri_init (tMBSineTri** const osc, LEAF* const leaf); - void tMBSineTri_initToPool (tMBSineTri** const osc, tMempool* const mempool); + void tMBSineTri_initToPool (tMBSineTri** const osc, tMempool** const mempool); void tMBSineTri_free (tMBSineTri** const osc); #ifdef ITCMRAM void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSineTri_place_dd_noBuffer(tMBSineTri* const osc, int index, Lfloat phase, Lfloat inv_w, Lfloat scale, Lfloat stepOrSlope, Lfloat w); @@ -1059,15 +1059,15 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSin @brief Saw wave oscillator with minBLEP anti-aliasing. @{ - @fn void tMBSaw_init(tMBSaw* const osc, LEAF* const leaf) + @fn void tMBSaw_init(tMBSaw** const osc, LEAF* const leaf) @brief Initialize a tMBSaw to the default mempool of a LEAF instance. @param osc A pointer to the tMBSaw to initialize. - @fn void tMBSaw_initToPool(tMBSaw* const osc, tMempool* const mempool) + @fn void tMBSaw_initToPool(tMBSaw** const osc, tMempool** const mempool) @brief Initialize a tMBSaw to a specified mempool. @param osc A pointer to the tMBSaw to initialize. - @fn void tMBSaw_free(tMBSaw* const osc) + @fn void tMBSaw_free(tMBSaw** const osc) @brief Free a tMBSaw from its mempool. @param osc A pointer to the tMBSaw to free. @@ -1095,7 +1095,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSin typedef struct tMBSaw { - tMempool mempool; + tMempool* mempool; Lfloat out; Lfloat freq; Lfloat lastsyncin; @@ -1116,7 +1116,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSin // Memory handlers for `tMBSaw` void tMBSaw_init (tMBSaw** const osc, LEAF* const leaf); - void tMBSaw_initToPool (tMBSaw** const osc, tMempool* const mempool); + void tMBSaw_initToPool (tMBSaw** const osc, tMempool** const mempool); void tMBSaw_free (tMBSaw** const osc); void tMBSaw_place_step_dd_noBuffer (tMBSaw* const osc, int index, Lfloat phase, Lfloat w, Lfloat scale); @@ -1139,15 +1139,15 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSin @brief Saw wave mixed with Pulse wave oscillator with minBLEP anti-aliasing. @{ - @fn void tMBSaw_init(tMBSaw* const osc, LEAF* const leaf) + @fn void tMBSaw_init(tMBSaw** const osc, LEAF* const leaf) @brief Initialize a tMBSaw to the default mempool of a LEAF instance. @param osc A pointer to the tMBSaw to initialize. - @fn void tMBSaw_initToPool(tMBSaw* const osc, tMempool* const mempool) + @fn void tMBSaw_initToPool(tMBSaw** const osc, tMempool** const mempool) @brief Initialize a tMBSaw to a specified mempool. @param osc A pointer to the tMBSaw to initialize. - @fn void tMBSaw_free(tMBSaw* const osc) + @fn void tMBSaw_free(tMBSaw** const osc) @brief Free a tMBSaw from its mempool. @param osc A pointer to the tMBSaw to free. @@ -1175,7 +1175,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSin typedef struct tMBSawPulse { - tMempool mempool; + tMempool* mempool; Lfloat out; Lfloat freq; Lfloat lastsyncin; @@ -1201,7 +1201,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSin // Memory handlers for `tMBSawPulse` void tMBSawPulse_init (tMBSawPulse** const osc, LEAF* const leaf); - void tMBSawPulse_initToPool (tMBSawPulse** const osc, tMempool* const mempool); + void tMBSawPulse_initToPool (tMBSawPulse** const osc, tMempool** const mempool); void tMBSawPulse_free (tMBSawPulse** const osc); #ifdef ITCMRAM void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSawPulse_place_step_dd_noBuffer(tMBSawPulse* const osc, int index, Lfloat phase, Lfloat inv_w, Lfloat scale); @@ -1228,21 +1228,21 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw @brief Simple aliasing wavetable oscillator. @{ - @fn void tTable_init (tTable* const osc, Lfloat* table, int size, LEAF* const leaf) + @fn void tTable_init(tTable** const osc, Lfloat* table, int size, LEAF* const leaf) @brief Initialize a tTable to the default mempool of a LEAF instance. @param osc A pointer to the tTable to initialize. @param table A pointer to the wavetable data. @param size The number of samples in the wavetable. @param leaf A pointer to the leaf instance. - @fn void tTable_initToPool (tTable* const osc, Lfloat* table, int size, tMempool* const mempool) + @fn void tTable_initToPool(tTable** const osc, Lfloat* table, int size, tMempool** const mempool) @brief Initialize a tTable to a specified mempool. @param osc A pointer to the tTable to initialize. @param table A pointer to the wavetable data. @param size The number of samples in the wave table. @param mempool A pointer to the tMempool to use. - @fn void tTable_free (tTable* const osc) + @fn void tTable_free(tTable** const osc) @brief Free a tTable from its mempool. @param osc A pointer to the tTable to free. @@ -1260,7 +1260,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw typedef struct tTable { - tMempool mempool; + tMempool* mempool; Lfloat* waveTable; int size; @@ -1271,7 +1271,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw // Memory handlers for `tTable` void tTable_init (tTable** const osc, Lfloat* table, int size, LEAF* const leaf); - void tTable_initToPool (tTable** const osc, Lfloat* table, int size, tMempool* const mempool); + void tTable_initToPool (tTable** const osc, Lfloat* table, int size, tMempool** const mempool); void tTable_free (tTable** const osc); // Tick function for `tTable` @@ -1289,7 +1289,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw @brief Anti-aliased wavetable generator. @{ - @fn void tWaveTable_init (tWaveTable* const osc, Lfloat* table, int size, Lfloat maxFreq, LEAF* const leaf) + @fn void tWaveTable_init(tWaveTable** const osc, Lfloat* table, int size, Lfloat maxFreq, LEAF* const leaf) @brief Initialize a tWaveTable to the default mempool of a LEAF instance. @param osc A pointer to the tWaveTable to initialize. @param table A pointer to the wavetable data. @@ -1297,7 +1297,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed. @param leaf A pointer to the leaf instance. - @fn void tWaveTable_initToPool (tWaveTable* const osc, Lfloat* table, int size, Lfloat maxFreq, tMempool* const mempool) + @fn void tWaveTable_initToPool(tWaveTable** const osc, Lfloat* table, int size, Lfloat maxFreq, tMempool** const mempool) @brief Initialize a tWaveTable to a specified mempool. @param osc A pointer to the tWaveTable to initialize. @param table A pointer to the wavetable data. @@ -1305,7 +1305,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed. @param mempool A pointer to the tMempool to use. - @fn void tWaveTable_free (tWaveTable* const osc) + @fn void tWaveTable_free(tWaveTable** const osc) @brief Free a tWaveTable from its mempool. @param osc A pointer to the tWaveTable to free. @@ -1315,7 +1315,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw typedef struct tWaveTable { - tMempool mempool; + tMempool* mempool; Lfloat* baseTable; Lfloat** tables; @@ -1324,14 +1324,14 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw int numTables; Lfloat maxFreq; Lfloat baseFreq, invBaseFreq; - tButterworth bl; + tButterworth* bl; Lfloat sampleRate; } tWaveTable; // Memory handlers for `tWaveTable` void tWaveTable_init (tWaveTable** const osc, Lfloat* table, int size, Lfloat maxFreq, LEAF* const leaf); void tWaveTable_initToPool (tWaveTable** const osc, Lfloat* table, int size, Lfloat maxFreq, - tMempool* const mempool); + tMempool** const mempool); void tWaveTable_free (tWaveTable** const osc); // Setter functions for `tWaveTable` @@ -1345,14 +1345,14 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw @brief Set of anti-aliased wavetable oscillators that can be faded between. @{ - @fn void tWaveOsc_init(tWaveOsc* const osc, const Lfloat** tables, int n, int size, Lfloat maxFreq, LEAF* const leaf) + @fn void tWaveOsc_init(tWaveOsc** const osc, const Lfloat** tables, int n, int size, Lfloat maxFreq, LEAF* const leaf) @brief Initialize a tWaveOsc to the default mempool of a LEAF instance. @param osc A pointer to the tWaveOsc to initialize. @param tables An array of pointers to wavetable data. @param n The number of wavetables. @param leaf A pointer to the leaf instance. - @fn void tWaveOsc_initToPool(tWaveOsc* const osc, const Lfloat** tables, int n, int size, Lfloat maxFreq, tMempool* const mempool) + @fn void tWaveOsc_initToPool(tWaveOsc** const osc, const Lfloat** tables, int n, int size, Lfloat maxFreq, tMempool** const mempool) @brief Initialize a tWaveOsc to a specified mempool. @param osc A pointer to the tWaveTable to initialize. @param tables An array of pointers to wavetable data. @@ -1361,7 +1361,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed. @param mempool A pointer to the tMempool to use. - @fn void tWaveOsc_free (tWaveOsc* const osc) + @fn void tWaveOsc_free(tWaveOsc** const osc) @brief Free a tWaveOsc from its mempool. @param osc A pointer to the tWaveOsc to free. @@ -1383,7 +1383,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw typedef struct tWaveOsc { - tMempool mempool; + tMempool* mempool; tWaveTable** tables; int numTables; Lfloat index; @@ -1409,8 +1409,8 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw } tWaveOsc; // Memory handlers for `tWaveOsc` - void tWaveOsc_init (tWaveOsc** const cy, tWaveTable* tables, int numTables, LEAF* const leaf); - void tWaveOsc_initToPool (tWaveOsc** const cy, tWaveTable* tables, int numTables, tMempool* const mp); + void tWaveOsc_init (tWaveOsc** const cy, tWaveTable** tables, int numTables, LEAF* const leaf); + void tWaveOsc_initToPool (tWaveOsc** const cy, tWaveTable** tables, int numTables, tMempool** const mp); void tWaveOsc_free (tWaveOsc** const osc); // Tick function for `tWaveOsc` @@ -1431,7 +1431,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw @brief A more space-efficient anti-aliased wavetable generator than tWaveTable but with slightly worse fidelity. @{ - @fn void tWaveTableS_init (tWaveTableS* const osc, Lfloat* table, int size, Lfloat maxFreq, LEAF* const leaf) + @fn void tWaveTableS_init(tWaveTableS** const osc, Lfloat* table, int size, Lfloat maxFreq, LEAF* const leaf) @brief Initialize a tWaveTableS to the default mempool of a LEAF instance. @param osc A pointer to the tWaveTableS to initialize. @param table A pointer to the wavetable data. @@ -1439,7 +1439,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed. @param leaf A pointer to the leaf instance. - @fn void tWaveTableS_initToPool (tWaveTableS* const osc, Lfloat* table, int size, Lfloat maxFreq, tMempool* const mempool) + @fn void tWaveTableS_initToPool(tWaveTableS** const osc, Lfloat* table, int size, Lfloat maxFreq, tMempool** const mempool) @brief Initialize a tWaveTableS to a specified mempool. @param osc A pointer to the tWaveTableS to initialize. @param table A pointer to the wavetable data. @@ -1447,7 +1447,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed. @param mempool A pointer to the tMempool to use. - @fn void tWaveTableS_free (tWaveTableS* const osc) + @fn void tWaveTableS_free(tWaveTableS** const osc) @brief Free a tWaveTableS from its mempool. @param osc A pointer to the tWaveTableS to free. @@ -1455,7 +1455,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw typedef struct tWaveTableS { - tMempool mempool; + tMempool* mempool; Lfloat* baseTable; Lfloat** tables; @@ -1464,9 +1464,9 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw int* sizeMasks; Lfloat maxFreq; Lfloat baseFreq, invBaseFreq; - tButterworth bl; + tButterworth* bl; Lfloat dsBuffer[2]; - tOversampler ds; + tOversampler* ds; Lfloat sampleRate; } tWaveTableS; @@ -1474,7 +1474,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw void tWaveTableS_init (tWaveTableS** const osc, Lfloat* table, int size, Lfloat maxFreq, LEAF* const leaf); void tWaveTableS_initToPool (tWaveTableS** const osc, Lfloat* table, int size, Lfloat maxFreq, - tMempool* const mempool); + tMempool** const mempool); void tWaveTableS_free (tWaveTableS** const osc); // Setter functions for `tWaveTableS` @@ -1488,14 +1488,14 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw @brief Set of anti-aliased wavetable oscillators that can be faded between. @{ - @fn void tWaveOscS_init(tWaveOsc* const osc, const Lfloat** tables, int n, int size, Lfloat maxFreq, LEAF* const leaf) + @fn void tWaveOscS_init(tWaveOsc** const osc, const Lfloat** tables, int n, int size, Lfloat maxFreq, LEAF* const leaf) @brief Initialize a tWaveOscS to the default mempool of a LEAF instance. @param osc A pointer to the tWaveOscS to initialize. @param tables An array of pointers to wavetable data. @param n The number of wavetables. @param leaf A pointer to the leaf instance. - @fn void tWaveOscS_initToPool(tWaveOsc* const osc, const Lfloat** tables, int n, int size, Lfloat maxFreq, tMempool* const mempool) + @fn void tWaveOscS_initToPool(tWaveOsc** const osc, const Lfloat** tables, int n, int size, Lfloat maxFreq, tMempool** const mempool) @brief Initialize a tWaveOscS to a specified mempool. @param osc A pointer to the tWaveTableS to initialize. @param tables An array of pointers to wavetable data. @@ -1504,7 +1504,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw @param maxFreq The maximum expected frequency of the oscillator. The higher this is, the more memory will be needed. @param mempool A pointer to the tMempool to use. - @fn void tWaveOscS_free (tWaveOsc* const osc) + @fn void tWaveOscS_free(tWaveOsc** const osc) @brief Free a tWaveOscS from its mempool. @param osc A pointer to the tWaveOscS to free. @@ -1526,11 +1526,11 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw typedef struct tWaveOscS { - tMempool mempool; + tMempool* mempool; //tWaveTableS* tables; - tWaveTableS* tables; + tWaveTableS** tables; int numTables; Lfloat index; @@ -1556,9 +1556,9 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw } tWaveOscS; // Memory handlers for `tWaveOscS` - void tWaveOscS_init (tWaveOscS** const cy, tWaveTableS* tables, int numTables, LEAF* const leaf); - void tWaveOscS_initToPool (tWaveOscS** const osc, tWaveTableS* tables, int numTables, - tMempool* const mempool); + void tWaveOscS_init (tWaveOscS** const cy, tWaveTableS** tables, int numTables, LEAF* const leaf); + void tWaveOscS_initToPool (tWaveOscS** const osc, tWaveTableS** tables, int numTables, + tMempool** const mempool); void tWaveOscS_free (tWaveOscS** const osc); // Tick function for `tWaveOscS` @@ -1581,17 +1581,17 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw @brief Aliasing phasor. @{ - @fn void tIntPhasor_init (tIntPhasor* const osc, LEAF* const leaf) + @fn void tIntPhasor_init(tIntPhasor** const osc, LEAF* const leaf) @brief Initialize a tIntPhasor to the default mempool of a LEAF instance. @param osc A pointer to the tIntPhasor to initialize. @param leaf A pointer to the leaf instance. - @fn void tIntPhasor_initToPool (tIntPhasor* const osc, tMempool* const) + @fn void tIntPhasor_initToPool(tIntPhasor** const osc, tMempool** const) @brief Initialize a tIntPhasor to a specified mempool. @param osc A pointer to the tIntPhasor to initialize. @param mempool A pointer to the tMempool to use. - @fn void tIntPhasor_free (tIntPhasor* const osc) + @fn void tIntPhasor_free(tIntPhasor** const osc) @brief Free a tIntPhasor from its mempool. @param osc A pointer to the tIntPhasor to free. @@ -1607,8 +1607,8 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw typedef struct tIntPhasor { - - tMempool mempool; + + tMempool* mempool; uint32_t phase; uint32_t inc; Lfloat freq; @@ -1619,7 +1619,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw // Memory handlers for `tIntPhasor` void tIntPhasor_init (tIntPhasor** const osc, LEAF* const leaf); - void tIntPhasor_initToPool (tIntPhasor** const osc, tMempool* const); + void tIntPhasor_initToPool (tIntPhasor** const osc, tMempool** const); void tIntPhasor_free (tIntPhasor** const osc); // Tick function for `tIntPhasor` @@ -1638,17 +1638,17 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw @brief Aliasing phasor. @{ - @fn void tSquareLFO_init (tSquareLFO* const osc, LEAF* const leaf) + @fn void tSquareLFO_init(tSquareLFO** const osc, LEAF* const leaf) @brief Initialize a tSquareLFO to the default mempool of a LEAF instance. @param osc A pointer to the tSquareLFO to initialize. @param leaf A pointer to the leaf instance. - @fn void tSquareLFO_initToPool (tSquareLFO* const osc, tMempool* const) + @fn void tSquareLFO_initToPool(tSquareLFO** const osc, tMempool** const) @brief Initialize a tSquareLFO to a specified mempool. @param osc A pointer to the tSquareLFO to initialize. @param mempool A pointer to the tMempool to use. - @fn void tSquareLFO_free (tSquareLFO* const osc) + @fn void tSquareLFO_free(tSquareLFO** const osc) @brief Free a tSquareLFO from its mempool. @param osc A pointer to the tSquareLFO to free. @@ -1664,16 +1664,16 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw typedef struct tSquareLFO { - - tMempool mempool; + + tMempool* mempool; Lfloat pulsewidth; - tIntPhasor phasor; - tIntPhasor invPhasor; + tIntPhasor* phasor; + tIntPhasor* invPhasor; } tSquareLFO; // Memory handlers for `tSquareLFO` void tSquareLFO_init (tSquareLFO** const osc, LEAF* const leaf); - void tSquareLFO_initToPool (tSquareLFO** const osc, tMempool* const); + void tSquareLFO_initToPool (tSquareLFO** const osc, tMempool** const); void tSquareLFO_free (tSquareLFO** const osc); // Tick function for `tSquareLFO` @@ -1687,15 +1687,15 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw typedef struct tSawSquareLFO { - tMempool mempool; + tMempool* mempool; Lfloat shape; - tIntPhasor saw; - tSquareLFO square; + tIntPhasor* saw; + tSquareLFO* square; } tSawSquareLFO; // Memory handlers for `tSawSquareLFO` void tSawSquareLFO_init (tSawSquareLFO** const osc, LEAF* const leaf); - void tSawSquareLFO_initToPool (tSawSquareLFO** const osc, tMempool* const); + void tSawSquareLFO_initToPool (tSawSquareLFO** const osc, tMempool** const); void tSawSquareLFO_free (tSawSquareLFO** const osc); // Tick function for `tSawSquareLFO` @@ -1714,17 +1714,17 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw @brief Aliasing phasor. @{ - @fn void tTriLFO_init (tTriLFO* const osc, LEAF* const leaf) + @fn void tTriLFO_init(tTriLFO** const osc, LEAF* const leaf) @brief Initialize a tTriLFO to the default mempool of a LEAF instance. @param osc A pointer to the tTriLFO to initialize. @param leaf A pointer to the leaf instance. - @fn void tTriLFO_initToPool (tTriLFO* const osc, tMempool* const) + @fn void tTriLFO_initToPool(tTriLFO** const osc, tMempool** const) @brief Initialize a tTriLFO to a specified mempool. @param osc A pointer to the tTriLFO to initialize. @param mempool A pointer to the tMempool to use. - @fn void tTriLFO_free (tTriLFO* const osc) + @fn void tTriLFO_free(tTriLFO** const osc) @brief Free a tTriLFO from its mempool. @param osc A pointer to the tTriLFO to free. @@ -1740,8 +1740,8 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw typedef struct tTriLFO { - - tMempool mempool; + + tMempool* mempool; int32_t phase; int32_t inc; Lfloat freq; @@ -1751,7 +1751,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw // Memory handlers for `tTriLFO` void tTriLFO_init (tTriLFO** const osc, LEAF* const leaf); - void tTriLFO_initToPool (tTriLFO** const osc, tMempool* const); + void tTriLFO_initToPool (tTriLFO** const osc, tMempool** const); void tTriLFO_free (tTriLFO** const osc); // Tick function for `tTriLFO` @@ -1764,15 +1764,15 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw typedef struct tSineTriLFO { - tMempool mempool; + tMempool* mempool; Lfloat shape; - tTriLFO tri; - tCycle sine; + tTriLFO* tri; + tCycle* sine; } tSineTriLFO; // Memory handlers for `tSineTriLFO` void tSineTriLFO_init (tSineTriLFO** const osc, LEAF* const leaf); - void tSineTriLFO_initToPool (tSineTriLFO** const osc, tMempool* const); + void tSineTriLFO_initToPool (tSineTriLFO** const osc, tMempool** const); void tSineTriLFO_free (tSineTriLFO** const osc); // Tick function for `tSineTriLFO` @@ -1788,7 +1788,7 @@ void __attribute__ ((section(".itcmram"))) __attribute__ ((aligned (32))) tMBSaw typedef struct tDampedOscillator { - tMempool mempool; + tMempool* mempool; Lfloat freq_; Lfloat decay_; @@ -1801,7 +1801,7 @@ typedef struct tDampedOscillator // Memory handlers for `tDampedOscillator` void tDampedOscillator_init (tDampedOscillator** const osc, LEAF* const leaf); - void tDampedOscillator_initToPool (tDampedOscillator** const osc, tMempool* const mempool); + void tDampedOscillator_initToPool (tDampedOscillator** const osc, tMempool** const mempool); void tDampedOscillator_free (tDampedOscillator** const osc); // Tick function for `tDampedOscillator` @@ -1816,7 +1816,7 @@ typedef struct tDampedOscillator typedef struct tPlutaQuadOsc { - tMempool mempool; + tMempool* mempool; uint32_t oversamplingRatio; uint32_t phase[4]; Lfloat biPolarOutputs[4]; @@ -1824,14 +1824,14 @@ typedef struct tDampedOscillator Lfloat freq[4]; Lfloat fmMatrix[4][4]; Lfloat outputAmplitudes[4]; - tButterworth lowpass; + tButterworth* lowpass; int32_t mask; Lfloat invSampleRateTimesTwoTo32; } tPlutaQuadOsc; // Memory handlers for `tDampedOscillator` void tPlutaQuadOsc_init (tPlutaQuadOsc** const osc, uint32_t oversamplingRatio, LEAF* const leaf); - void tPlutaQuadOsc_initToPool (tPlutaQuadOsc** const cy, uint32_t oversamplingRatio, tMempool* const mp); + void tPlutaQuadOsc_initToPool (tPlutaQuadOsc** const cy, uint32_t oversamplingRatio, tMempool** const mp); void tPlutaQuadOsc_free (tPlutaQuadOsc** const osc); // Tick function for `tDampedOscillator` diff --git a/leaf/Inc/leaf-physical.h b/leaf/Inc/leaf-physical.h index 4420a34..77c3e02 100644 --- a/leaf/Inc/leaf-physical.h +++ b/leaf/Inc/leaf-physical.h @@ -30,12 +30,12 @@ extern "C" { typedef struct tPickupNonLinearity { - tMempool mempool; + tMempool* mempool; Lfloat prev; } tPickupNonLinearity; void tPickupNonLinearity_init (tPickupNonLinearity** const p, LEAF* const leaf); -void tPickupNonLinearity_initToPool (tPickupNonLinearity** const p, tMempool* const mp); +void tPickupNonLinearity_initToPool (tPickupNonLinearity** const p, tMempool** const mp); void tPickupNonLinearity_free (tPickupNonLinearity** const p); Lfloat tPickupNonLinearity_tick (tPickupNonLinearity* const p, Lfloat in); @@ -48,17 +48,17 @@ Lfloat tPickupNonLinearity_tick (tPickupNonLinearity* const p, Lfloat i @brief Karplus-Strong model @{ - @fn void tPluck_init (tPluck* const, Lfloat lowestFrequency, LEAF* const leaf) + @fn void tPluck_init(tPluck** const, Lfloat lowestFrequency, LEAF* const leaf) @brief Initialize a tPluck to the default mempool of a LEAF instance. @param string A pointer to the tPluck to initialize. @param leaf A pointer to the leaf instance. - @fn void tPluck_initToPool (tPluck* const, Lfloat lowestFrequency, tMempool* const) + @fn void tPluck_initToPool(tPluck** const, Lfloat lowestFrequency, tMempool** const) @brief Initialize a tPluck to a specified mempool. @param string A pointer to the tPluck to initialize. @param mempool A pointer to the tMempool to use. - @fn void tPluck_free (tPluck* const) + @fn void tPluck_free(tPluck** const) @brief Free a tPluck from its mempool. @param string A pointer to the tPluck to free. @@ -94,13 +94,13 @@ Lfloat tPickupNonLinearity_tick (tPickupNonLinearity* const p, Lfloat i typedef struct tPluck { + + tMempool* mempool; - tMempool mempool; - - tAllpassDelay delayLine; // Allpass or Linear?? big difference... - tOneZero loopFilter; - tOnePole pickFilter; - tNoise noise; + tAllpassDelay* delayLine; // Allpass or Linear?? big difference... + tOneZero* loopFilter; + tOnePole* pickFilter; + tNoise* noise; Lfloat lastOut; Lfloat loopGain; @@ -110,7 +110,7 @@ Lfloat tPickupNonLinearity_tick (tPickupNonLinearity* const p, Lfloat i } tPluck; void tPluck_init (tPluck** const, Lfloat lowestFrequency, LEAF* const leaf); //Lfloat delayBuff[DELAY_LENGTH]); - void tPluck_initToPool (tPluck** const, Lfloat lowestFrequency, tMempool* const); + void tPluck_initToPool (tPluck** const, Lfloat lowestFrequency, tMempool** const); void tPluck_free (tPluck** const); Lfloat tPluck_tick (tPluck* const); @@ -131,17 +131,17 @@ Lfloat tPickupNonLinearity_tick (tPickupNonLinearity* const p, Lfloat i @brief Stiff Karplus-Strong model @{ - @fn void tKarplusStrong_init (tKarplusStrong* const, Lfloat lowestFrequency, LEAF* const leaf) + @fn void tKarplusStrong_init(tKarplusStrong** const, Lfloat lowestFrequency, LEAF* const leaf) @brief Initialize a tKarplusStrong to the default mempool of a LEAF instance. @param string A pointer to the tKarplusStrong to initialize. @param leaf A pointer to the leaf instance. - @fn void tKarplusStrong_initToPool (tKarplusStrong* const, Lfloat lowestFrequency, tMempool* const) + @fn void tKarplusStrong_initToPool(tKarplusStrong** const, Lfloat lowestFrequency, tMempool** const) @brief Initialize a tKarplusStrong to a specified mempool. @param string A pointer to the tKarplusStrong to initialize. @param mempool A pointer to the tMempool to use. - @fn void tKarplusStrong_free (tKarplusStrong* const) + @fn void tKarplusStrong_free(tKarplusStrong** const) @brief Free a tKarplusStrong from its mempool. @param string A pointer to the tKarplusStrong to free. @@ -197,14 +197,14 @@ Lfloat tPickupNonLinearity_tick (tPickupNonLinearity* const p, Lfloat i typedef struct tKarplusStrong { + + tMempool* mempool; - tMempool mempool; - - tAllpassDelay delayLine; - tLinearDelay combDelay; - tOneZero filter; - tNoise noise; - tBiQuad biquad[4]; + tAllpassDelay* delayLine; + tLinearDelay* combDelay; + tOneZero* filter; + tNoise* noise; + tBiQuad* biquad[4]; uint32_t length; Lfloat loopGain; @@ -221,7 +221,7 @@ Lfloat tPickupNonLinearity_tick (tPickupNonLinearity* const p, Lfloat i } tKarplusStrong; void tKarplusStrong_init (tKarplusStrong** const, Lfloat lowestFrequency, LEAF* const leaf); // Lfloat delayBuff[2][DELAY_LENGTH]); - void tKarplusStrong_initToPool (tKarplusStrong** const, Lfloat lowestFrequency, tMempool* const); + void tKarplusStrong_initToPool (tKarplusStrong** const, Lfloat lowestFrequency, tMempool** const); void tKarplusStrong_free (tKarplusStrong** const); Lfloat tKarplusStrong_tick (tKarplusStrong* const); @@ -244,17 +244,17 @@ Lfloat tPickupNonLinearity_tick (tPickupNonLinearity* const p, Lfloat i @brief Simplified string model. @{ - @fn void tSimpleLivingString_init (tSimpleLivingString* const, Lfloat freq, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, LEAF* const leaf) + @fn void tSimpleLivingString_init(tSimpleLivingString** const, Lfloat freq, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, LEAF* const leaf) @brief Initialize a tSimpleLivingString to the default mempool of a LEAF instance. @param string A pointer to the tSimpleLivingString to initialize. @param leaf A pointer to the leaf instance. - @fn void tSimpleLivingString_initToPool (tSimpleLivingString* const, Lfloat freq, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, tMempool* const) + @fn void tSimpleLivingString_initToPool(tSimpleLivingString** const, Lfloat freq, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, tMempool** const) @brief Initialize a tSimpleLivingString to a specified mempool. @param string A pointer to the tSimpleLivingString to initialize. @param mempool A pointer to the tMempool to use. - @fn void tSimpleLivingString_free (tSimpleLivingString* const) + @fn void tSimpleLivingString_free(tSimpleLivingString** const) @brief Free a tSimpleLivingString from its mempool. @param string A pointer to the tSimpleLivingString to free. @@ -302,18 +302,18 @@ Lfloat tPickupNonLinearity_tick (tPickupNonLinearity* const p, Lfloat i typedef struct tSimpleLivingString { - - tMempool mempool; + + tMempool* mempool; Lfloat freq, waveLengthInSamples; // the frequency of the string, determining delay length Lfloat dampFreq; // frequency for the bridge LP filter, in Hz Lfloat decay; // amplitude damping factor for the string (only active in mode 0) int levMode; Lfloat curr; - tLinearDelay delayLine; - tOnePole bridgeFilter; - tHighpass DCblocker; - tFeedbackLeveler fbLev; - tExpSmooth wlSmooth; + tLinearDelay* delayLine; + tOnePole* bridgeFilter; + tHighpass* DCblocker; + tFeedbackLeveler* fbLev; + tExpSmooth* wlSmooth; Lfloat sampleRate; } tSimpleLivingString; @@ -322,7 +322,7 @@ Lfloat tPickupNonLinearity_tick (tPickupNonLinearity* const p, Lfloat i Lfloat levStrength, int levMode, LEAF* const leaf); void tSimpleLivingString_initToPool (tSimpleLivingString** const, Lfloat freq, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, - Lfloat levStrength, int levMode, tMempool* const); + Lfloat levStrength, int levMode, tMempool** const); void tSimpleLivingString_free (tSimpleLivingString** const); Lfloat tSimpleLivingString_tick (tSimpleLivingString* const, Lfloat input); @@ -346,17 +346,17 @@ Lfloat tPickupNonLinearity_tick (tPickupNonLinearity* const p, Lfloat i typedef struct tSimpleLivingString2 { - tMempool mempool; + tMempool* mempool; Lfloat freq, waveLengthInSamples; // the frequency of the string, determining delay length Lfloat brightness; // frequency for the bridge LP filter, in Hz Lfloat decay; // amplitude damping factor for the string (only active in mode 0) int levMode; Lfloat curr; - tHermiteDelay delayLine; - tTwoZero bridgeFilter; - tHighpass DCblocker; - tFeedbackLeveler fbLev; - tExpSmooth wlSmooth; + tHermiteDelay* delayLine; + tTwoZero* bridgeFilter; + tHighpass* DCblocker; + tFeedbackLeveler* fbLev; + tExpSmooth* wlSmooth; Lfloat sampleRate; } tSimpleLivingString2; @@ -365,7 +365,7 @@ Lfloat tPickupNonLinearity_tick (tPickupNonLinearity* const p, Lfloat i Lfloat levStrength, int levMode, LEAF* const leaf); void tSimpleLivingString2_initToPool (tSimpleLivingString2** const, Lfloat freq, Lfloat brightness, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, - Lfloat levStrength, int levMode, tMempool* const); + Lfloat levStrength, int levMode, tMempool** const); void tSimpleLivingString2_free (tSimpleLivingString2** const); Lfloat tSimpleLivingString2_tick (tSimpleLivingString2* const, Lfloat input); @@ -386,8 +386,8 @@ Lfloat tPickupNonLinearity_tick (tPickupNonLinearity* const p, Lfloat i typedef struct tSimpleLivingString3 { - - tMempool mempool; + + tMempool* mempool; Lfloat freq, waveLengthInSamples; // the frequency of the string, determining delay length Lfloat dampFreq; // frequency for the bridge LP filter, in Hz Lfloat decay, userDecay; // amplitude damping factor for the string (only active in mode 0) @@ -398,16 +398,16 @@ typedef struct tSimpleLivingString3 Lfloat Uout; Lfloat Lout; int maxLength; - tLinearDelay delayLineU; - tLinearDelay delayLineL; - tOnePole bridgeFilter; - tBiQuad bridgeFilter2; + tLinearDelay* delayLineU; + tLinearDelay* delayLineL; + tOnePole* bridgeFilter; + tBiQuad* bridgeFilter2; Lfloat temp1; Lfloat temp2; Lfloat pickupPoint; - tHighpass DCblocker; - tFeedbackLeveler fbLev; - tExpSmooth wlSmooth; + tHighpass* DCblocker; + tFeedbackLeveler* fbLev; + tExpSmooth* wlSmooth; int oversampling; Lfloat sampleRate; Lfloat rippleGain; @@ -420,7 +420,7 @@ void tSimpleLivingString3_init (tSimpleLivingString3** const, i int levMode, LEAF* const leaf); void tSimpleLivingString3_initToPool (tSimpleLivingString3** const pl, int oversampling, Lfloat freq, Lfloat dam, Lfloat decay, Lfloat targetLev, Lfloat levSmoothF, Lfloat levStrength, - int levMode, tMempool* const mp); + int levMode, tMempool** const mp); void tSimpleLivingString3_free (tSimpleLivingString3** const); Lfloat tSimpleLivingString3_tick (tSimpleLivingString3* const, Lfloat input); @@ -441,8 +441,8 @@ void tSimpleLivingString3_setSampleRate (tSimpleLivingString3* const, Lf // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ typedef struct tSimpleLivingString4 { - - tMempool mempool; + + tMempool* mempool; Lfloat freq, waveLengthInSamples; // the frequency of the string, determining delay length Lfloat dampFreq; // frequency for the bridge LP filter, in Hz Lfloat decay, userDecay; // amplitude damping factor for the string (only active in mode 0) @@ -453,17 +453,17 @@ typedef struct tSimpleLivingString4 Lfloat Uout; Lfloat Lout; int maxLength; - tLinearDelay delayLineU; - tLinearDelay delayLineL; - tOnePole bridgeFilter; - tBiQuad bridgeFilter2; + tLinearDelay* delayLineU; + tLinearDelay* delayLineL; + tOnePole* bridgeFilter; + tBiQuad* bridgeFilter2; Lfloat temp1; Lfloat temp2; Lfloat pickupPoint; Lfloat pluckPosition; - tHighpass DCblocker; - tFeedbackLeveler fbLev; - tExpSmooth wlSmooth; + tHighpass* DCblocker; + tFeedbackLeveler* fbLev; + tExpSmooth* wlSmooth; int oversampling; Lfloat sampleRate; Lfloat rippleGain; @@ -475,7 +475,7 @@ void tSimpleLivingString4_init (tSimpleLivingString4** const, i int levMode, LEAF* const leaf); void tSimpleLivingString4_initToPool (tSimpleLivingString4** const pl, int oversampling, Lfloat freq, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, - int levMode, tMempool* const mp); + int levMode, tMempool** const mp); void tSimpleLivingString4_free (tSimpleLivingString4** const); Lfloat tSimpleLivingString4_tick (tSimpleLivingString4* const, Lfloat input); @@ -499,8 +499,8 @@ void tSimpleLivingString4_setSampleRate (tSimpleLivingString4* const, Lf // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ typedef struct tSimpleLivingString5 { - - tMempool mempool; + + tMempool* mempool; Lfloat freq, waveLengthInSamples; // the frequency of the string, determining delay length Lfloat dampFreq; // frequency for the bridge LP filter, in Hz Lfloat decay, userDecay; // amplitude damping factor for the string (only active in mode 0) @@ -513,18 +513,18 @@ typedef struct tSimpleLivingString5 int maxLength; Lfloat prepIndex; Lfloat prepPos; - tLagrangeDelay delLF,delUF,delUB,delLB; // delay for lower/upper/forward/backward part of the waveguide model - tOnePole bridgeFilter, nutFilter, prepFilterU, prepFilterL; + tLagrangeDelay* delLF,*delUF,*delUB,*delLB; // delay for lower/upper/forward/backward part of the waveguide model + tOnePole* bridgeFilter, *nutFilter, *prepFilterU, *prepFilterL; Lfloat temp1; Lfloat temp2; Lfloat pickupPoint; Lfloat pluckPosition; - tHighpass DCblocker; - tHighpass DCblocker2; - tFeedbackLeveler fbLev; - tFeedbackLeveler fbLev2; + tHighpass* DCblocker; + tHighpass* DCblocker2; + tFeedbackLeveler* fbLev; + tFeedbackLeveler* fbLev2; - tExpSmooth wlSmooth, prepPosSmooth, prepIndexSmooth, pluckPosSmooth, pickupPointSmooth; + tExpSmooth *wlSmooth, *prepPosSmooth, *prepIndexSmooth, *pluckPosSmooth, *pickupPointSmooth; int oversampling; Lfloat sampleRate; Lfloat rippleGain; @@ -538,7 +538,7 @@ void tSimpleLivingString5_init (tSimpleLivingString5** const, i Lfloat levSmoothFactor, Lfloat levStrength, int levMode, LEAF* const leaf); void tSimpleLivingString5_initToPool (tSimpleLivingString5** const pl, int oversampling, Lfloat freq, Lfloat dampFreq, Lfloat decay, Lfloat prepPos, Lfloat prepIndex, Lfloat pluckPos, Lfloat targetLev, - Lfloat levSmoothFactor,Lfloat levStrength, int levMode, tMempool* const mp); + Lfloat levSmoothFactor,Lfloat levStrength, int levMode, tMempool** const mp); void tSimpleLivingString5_free (tSimpleLivingString5** const); Lfloat tSimpleLivingString5_tick (tSimpleLivingString5* const, Lfloat input); @@ -573,17 +573,17 @@ void tSimpleLivingString5_setFFAmount (tSimpleLivingString5* const pl, @brief String model. @{ - @fn void tLivingString_init (tLivingString* const, Lfloat freq, Lfloat pickPos, Lfloat prepIndex, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, LEAF* const leaf) + @fn void tLivingString_init(tLivingString** const, Lfloat freq, Lfloat pickPos, Lfloat prepIndex, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, LEAF* const leaf) @brief Initialize a tLivingString to the default mempool of a LEAF instance. @param string A pointer to the tLivingString to initialize. @param leaf A pointer to the leaf instance. - @fn void tLivingString_initToPool (tLivingString* const, Lfloat freq, Lfloat pickPos, Lfloat prepIndex, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, tMempool* const) + @fn void tLivingString_initToPool(tLivingString** const, Lfloat freq, Lfloat pickPos, Lfloat prepIndex, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, tMempool** const) @brief Initialize a tLivingString to a specified mempool. @param string A pointer to the tLivingString to initialize. @param mempool A pointer to the tMempool to use. - @fn void tLivingString_free (tLivingString* const) + @fn void tLivingString_free(tLivingString** const) @brief Free a tLivingString from its mempool. @param string A pointer to the tLivingString to free. @@ -639,7 +639,7 @@ void tSimpleLivingString5_setFFAmount (tSimpleLivingString5* const pl, typedef struct tLivingString { - tMempool mempool; + tMempool* mempool; Lfloat freq, waveLengthInSamples; // the frequency of the whole string, determining delay length Lfloat pickPos; // the pick position, dividing the string in two, in ratio Lfloat prepIndex; // the amount of pressure on the pickpoint of the string (near 0=soft obj, near 1=hard obj) @@ -647,11 +647,11 @@ void tSimpleLivingString5_setFFAmount (tSimpleLivingString5* const pl, Lfloat decay; // amplitude damping factor for the string (only active in mode 0) int levMode; Lfloat curr; - tLinearDelay delLF,delUF,delUB,delLB; // delay for lower/upper/forward/backward part of the waveguide model - tOnePole bridgeFilter, nutFilter, prepFilterU, prepFilterL; - tHighpass DCblockerL, DCblockerU; - tFeedbackLeveler fbLevU, fbLevL; - tExpSmooth wlSmooth, ppSmooth; + tLinearDelay* delLF,*delUF,*delUB,*delLB; // delay for lower/upper/forward/backward part of the waveguide model + tOnePole* bridgeFilter, *nutFilter,* prepFilterU, *prepFilterL; + tHighpass* DCblockerL, *DCblockerU; + tFeedbackLeveler* fbLevU, *fbLevL; + tExpSmooth* wlSmooth, *ppSmooth; Lfloat sampleRate; } tLivingString; @@ -660,7 +660,7 @@ void tSimpleLivingString5_setFFAmount (tSimpleLivingString5* const pl, Lfloat levStrength, int levMode, LEAF* const leaf); void tLivingString_initToPool (tLivingString** const, Lfloat freq, Lfloat pickPos, Lfloat prepIndex, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, - Lfloat levStrength, int levMode, tMempool* const); + Lfloat levStrength, int levMode, tMempool** const); void tLivingString_free (tLivingString** const); Lfloat tLivingString_tick (tLivingString* const, Lfloat input); @@ -687,17 +687,17 @@ void tSimpleLivingString5_setFFAmount (tSimpleLivingString5* const pl, @brief String model with preparation and pick position separated. @{ - @fn void tLivingString2_init (tLivingString2* const, Lfloat freq, Lfloat pickPos, Lfloat prepIndex, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, LEAF* const leaf) + @fn void tLivingString2_init(tLivingString2** const, Lfloat freq, Lfloat pickPos, Lfloat prepIndex, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, LEAF* const leaf) @brief Initialize a tLivingString to the default mempool of a LEAF instance. @param string A pointer to the tLivingString2 to initialize. @param leaf A pointer to the leaf instance. - @fn void tLivingString2_initToPool (tLivingString2* const, Lfloat freq, Lfloat pickPos, Lfloat prepIndex, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, tMempool* const) + @fn void tLivingString2_initToPool(tLivingString2** const, Lfloat freq, Lfloat pickPos, Lfloat prepIndex, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, tMempool** const) @brief Initialize a tLivingString2 to a specified mempool. @param string A pointer to the tLivingString2 to initialize. @param mempool A pointer to the tMempool to use. - @fn void tLivingString2_free (tLivingString2* const) + @fn void tLivingString2_free(tLivingString2** const) @brief Free a tLivingString2 from its mempool. @param string A pointer to the tLivingString2 to free. @@ -759,7 +759,7 @@ void tSimpleLivingString5_setFFAmount (tSimpleLivingString5* const pl, @} */ typedef struct tLivingString2 { - tMempool mempool; + tMempool* mempool; Lfloat freq, waveLengthInSamples; // the frequency of the whole string, determining delay length Lfloat pickPos; // the pick position, dividing the string in two, in ratio Lfloat prepPos; // the preparation position, dividing the string in two, in ratio @@ -769,11 +769,11 @@ void tSimpleLivingString5_setFFAmount (tSimpleLivingString5* const pl, int levMode; Lfloat brightness; Lfloat curr; - tHermiteDelay delLF,delUF,delUB,delLB; // delay for lower/upper/forward/backward part of the waveguide model - tTwoZero bridgeFilter, nutFilter, prepFilterU, prepFilterL; - tHighpass DCblockerL, DCblockerU; - tFeedbackLeveler fbLevU, fbLevL; - tExpSmooth wlSmooth, ppSmooth, prpSmooth, puSmooth; + tHermiteDelay* delLF,*delUF,*delUB,*delLB; // delay for lower/upper/forward/backward part of the waveguide model + tTwoZero* bridgeFilter, *nutFilter, *prepFilterU, *prepFilterL; + tHighpass* DCblockerL, *DCblockerU; + tFeedbackLeveler* fbLevU, *fbLevL; + tExpSmooth* wlSmooth, *ppSmooth, *prpSmooth, *puSmooth; Lfloat sampleRate; } tLivingString2; @@ -782,7 +782,7 @@ void tSimpleLivingString5_setFFAmount (tSimpleLivingString5* const pl, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, LEAF* const leaf); void tLivingString2_initToPool (tLivingString2** const, Lfloat freq, Lfloat pickPos, Lfloat prepPos, Lfloat pickupPos, Lfloat prepIndex, Lfloat brightness, Lfloat decay, Lfloat targetLev, - Lfloat levSmoothFactor, Lfloat levStrength, int levMode, tMempool* const); + Lfloat levSmoothFactor, Lfloat levStrength, int levMode, tMempool** const); void tLivingString2_free (tLivingString2** const); Lfloat tLivingString2_tick (tLivingString2* const, Lfloat input); @@ -813,17 +813,17 @@ void tSimpleLivingString5_setFFAmount (tSimpleLivingString5* const pl, @brief Complex string model. @{ - @fn void tComplexLivingString_init (tComplexLivingString* const, Lfloat freq, Lfloat pickPos, Lfloat prepPos, Lfloat prepIndex, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, LEAF* const leaf) + @fn void tComplexLivingString_init(tComplexLivingString** const, Lfloat freq, Lfloat pickPos, Lfloat prepPos, Lfloat prepIndex, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, LEAF* const leaf) @brief Initialize a tComplexLivingString to the default mempool of a LEAF instance. @param string A pointer to the tComplexLivingString to initialize. @param leaf A pointer to the leaf instance. - @fn void tComplexLivingString_initToPool (tComplexLivingString* const, Lfloat freq, Lfloat pickPos, Lfloat prepPos, Lfloat prepIndex, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, tMempool* const) + @fn void tComplexLivingString_initToPool(tComplexLivingString** const, Lfloat freq, Lfloat pickPos, Lfloat prepPos, Lfloat prepIndex, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, tMempool** const) @brief Initialize a tComplexLivingString to a specified mempool. @param string A pointer to the tComplexLivingString to initialize. @param mempool A pointer to the tMempool to use. - @fn void tComplexLivingString_free (tComplexLivingString* const) + @fn void tComplexLivingString_free(tComplexLivingString** const) @brief Free a tComplexLivingString from its mempool. @param string A pointer to the tComplexLivingString to free. @@ -883,7 +883,7 @@ void tSimpleLivingString5_setFFAmount (tSimpleLivingString5* const pl, typedef struct tComplexLivingString { - tMempool mempool; + tMempool* mempool; Lfloat freq, waveLengthInSamples; // the frequency of the whole string, determining delay length Lfloat pickPos; // the pick position, dividing the string, in ratio Lfloat prepPos; // preparation position, in ratio @@ -893,11 +893,11 @@ void tSimpleLivingString5_setFFAmount (tSimpleLivingString5* const pl, Lfloat decay; // amplitude damping factor for the string (only active in mode 0) int levMode; Lfloat curr; - tLinearDelay delLF,delUF, delMF, delMB, delUB,delLB; // delay for lower/upper/forward/backward part of the waveguide model - tOnePole bridgeFilter, nutFilter, prepFilterU, prepFilterL; - tHighpass DCblockerL, DCblockerU; - tFeedbackLeveler fbLevU, fbLevL; - tExpSmooth wlSmooth, pickPosSmooth, prepPosSmooth; + tLinearDelay* delLF,*delUF, *delMF, *delMB, *delUB,*delLB; // delay for lower/upper/forward/backward part of the waveguide model + tOnePole* bridgeFilter, *nutFilter, *prepFilterU, *prepFilterL; + tHighpass* DCblockerL, *DCblockerU; + tFeedbackLeveler* fbLevU, *fbLevL; + tExpSmooth* wlSmooth,* pickPosSmooth, *prepPosSmooth; Lfloat sampleRate; } tComplexLivingString; @@ -908,7 +908,7 @@ void tSimpleLivingString5_setFFAmount (tSimpleLivingString5* const pl, void tComplexLivingString_initToPool (tComplexLivingString** const, Lfloat freq, Lfloat pickPos, Lfloat prepPos, Lfloat prepIndex, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, - Lfloat levStrength, int levMode, tMempool* const); + Lfloat levStrength, int levMode, tMempool** const); void tComplexLivingString_free (tComplexLivingString** const); Lfloat tComplexLivingString_tick (tComplexLivingString* const, Lfloat input); @@ -931,21 +931,21 @@ void tSimpleLivingString5_setFFAmount (tSimpleLivingString5* const pl, // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ //Bow Table typedef struct tBowTable { - tMempool mempool; + tMempool* mempool; Lfloat offSet; Lfloat slope; Lfloat lastOutput; } tBowTable; void tBowTable_init (tBowTable** const bt, LEAF* const leaf); -void tBowTable_initToPool (tBowTable** const bt, tMempool* const mp); +void tBowTable_initToPool (tBowTable** const bt, tMempool** const mp); void tBowTable_free (tBowTable** const bt); Lfloat tBowTable_lookup (tBowTable* const bt, Lfloat sample); typedef struct tBowed { - tMempool mempool; + tMempool* mempool; int oversampling; // user controlled vars Lfloat x_bp; // bow pressure @@ -956,24 +956,24 @@ typedef struct tBowed Lfloat fr_save; // delay lines - tLinearDelay neckDelay; - tLinearDelay bridgeDelay; + tLinearDelay* neckDelay; + tLinearDelay* bridgeDelay; // one pole filter - tCookOnePole reflFilt; + tCookOnePole* reflFilt; - tBowTable bowTabl; + tBowTable* bowTabl; // stuff Lfloat maxVelocity, baseDelay, betaRatio; Lfloat sampleRate; Lfloat invSampleRate; - tSVF lowpass; + tSVF* lowpass; Lfloat output; } tBowed; void tBowed_init (tBowed** const, int oversampling, LEAF* const leaf); -void tBowed_initToPool (tBowed** const, int oversampling, tMempool* const); +void tBowed_initToPool (tBowed** const, int oversampling, tMempool** const); void tBowed_free (tBowed** const); Lfloat tBowed_tick (tBowed* const); @@ -988,19 +988,19 @@ void tBowed_setSampleRate (tBowed* const, Lfloat sr); //by Vesa Valimaki typedef struct tTString { - tMempool mempool; + tMempool* mempool; int oversampling; Lfloat invOversampling; Lfloat invOversamplingTimesTwo; Lfloat twoPiTimesInvSampleRate; // delay lines - tLagrangeDelay delay; - tLagrangeDelay delayP; - tHighpass dcBlock; - tHighpass dcBlockP; + tLagrangeDelay* delay; + tLagrangeDelay* delayP; + tHighpass* dcBlock; + tHighpass* dcBlockP; // one pole filter - tCookOnePole reflFilt; - tCookOnePole reflFiltP; + tCookOnePole* reflFilt; + tCookOnePole* reflFiltP; Lfloat baseDelay; Lfloat sampleRate; Lfloat invSampleRate; @@ -1008,16 +1008,16 @@ typedef struct tTString Lfloat output; Lfloat outputP; Lfloat tensionGain; - tSlide slide; - tExpSmooth tensionSmoother; - tExpSmooth pitchSmoother; - tThiranAllpassSOCascade allpass; - tThiranAllpassSOCascade allpassP; + tSlide* slide; + tExpSmooth* tensionSmoother; + tExpSmooth* pitchSmoother; + tThiranAllpassSOCascade* allpass; + tThiranAllpassSOCascade* allpassP; Lfloat allpassDelay; Lfloat allpassDelayP; Lfloat freq; - tSVF lowpassP; - tSVF highpassP; + tSVF* lowpassP; + tSVF* highpassP; Lfloat filterFreq; Lfloat decayCoeff; Lfloat muteCoeff; @@ -1032,24 +1032,24 @@ typedef struct tTString Lfloat pickupPos; Lfloat tensionAmount; - tCycle tensionModOsc; + tCycle* tensionModOsc; Lfloat phantomGain; - tCycle pickupModOsc; + tCycle* pickupModOsc; Lfloat pickupModOscFreq; Lfloat pickupModOscAmp; - tSVF pickupFilter; - tSVF pickupFilter2; + tSVF* pickupFilter; + tSVF* pickupFilter2; Lfloat slideAmount; Lfloat absSlideAmount; Lfloat smoothedSlideAmount; - tNoise noise; + tNoise* noise; Lfloat slideNoise; Lfloat slideGain; uint32_t wound; - tExpSmooth barPulse; + tExpSmooth* barPulse; Lfloat barPulseInc; uint32_t barPulsePhasor; - tSVF barResonator; + tSVF* barResonator; Lfloat barPosition; Lfloat prevBarPosition; Lfloat openStringLength; @@ -1057,12 +1057,12 @@ typedef struct tTString Lfloat lastBump; Lfloat timeSinceLastBump; uint32_t sampleCount; - tSlide barSmooth; - tHighpass barHP; - tSVF barLP; - tSlide barPulseSlide; - tExpSmooth barSmooth2; - tExpSmooth barSmoothVol; + tSlide* barSmooth; + tHighpass* barHP; + tSVF* barLP; + tSlide* barPulseSlide; + tExpSmooth* barSmooth2; + tExpSmooth* barSmoothVol; Lfloat prevBarPosSmoothVol; Lfloat prevBumpSmoothed; Lfloat prevBarPosSmoothed; @@ -1077,8 +1077,8 @@ typedef struct tTString Lfloat inharmonicMult; uint32_t maxDelay; uint32_t tensionJumps; - tFeedbackLeveler feedback; - tFeedbackLeveler feedbackP; + tFeedbackLeveler* feedback; + tFeedbackLeveler* feedbackP; Lfloat feedbackNoise; Lfloat feedbackNoiseLevel; Lfloat quarterSampleRate; @@ -1086,16 +1086,16 @@ typedef struct tTString uint32_t wavelength; Lfloat pluckRatio; Lfloat pickup_Ratio; - tExpSmooth pickNoise; - tNoise pickNoiseSource; + tExpSmooth* pickNoise; + tNoise* pickNoiseSource; Lfloat pluckPoint_forInput; - tSVF peakFilt; + tSVF* peakFilt; Lfloat pickupAmount; - tPickupNonLinearity p; + tPickupNonLinearity* p; } tTString; void tTString_init (tTString** const, int oversampling, Lfloat lowestFreq, LEAF* const leaf); -void tTString_initToPool (tTString** const, int oversampling, Lfloat lowestFreq, tMempool* const); +void tTString_initToPool (tTString** const, int oversampling, Lfloat lowestFreq, tMempool** const); void tTString_free (tTString** const); Lfloat tTString_tick (tTString* const); @@ -1140,17 +1140,17 @@ void tTString_setPickupAmount (tTString* const bw, Lfloat amount); @brief Reed Table - borrowed from STK @{ - @fn void tReedTable_init (tReedTable* const, Lfloat offset, Lfloat slope, LEAF* const leaf) + @fn void tReedTable_init(tReedTable** const, Lfloat offset, Lfloat slope, LEAF* const leaf) @brief Initialize a tReedTable to the default mempool of a LEAF instance. @param reed A pointer to the tReedTable to initialize. @param leaf A pointer to the leaf instance. - @fn void tReedTable_initToPool (tReedTable* const, Lfloat offset, Lfloat slope, tMempool* const) + @fn void tReedTable_initToPool(tReedTable** const, Lfloat offset, Lfloat slope, tMempool** const) @brief Initialize a tReedTable to a specified mempool. @param reed A pointer to the tReedTable to initialize. @param mempool A pointer to the tMempool to use. - @fn void tReedTable_free (tReedTable* const) + @fn void tReedTable_free(tReedTable** const) @brief Free a tReedTable from its mempool. @param reed A pointer to the tReedTable to free. @@ -1174,13 +1174,13 @@ void tTString_setPickupAmount (tTString* const bw, Lfloat amount); typedef struct tReedTable { - - tMempool mempool; + + tMempool* mempool; Lfloat offset, slope; } tReedTable; void tReedTable_init (tReedTable** const, Lfloat offset, Lfloat slope, LEAF* const leaf); - void tReedTable_initToPool (tReedTable** const, Lfloat offset, Lfloat slope, tMempool* const); + void tReedTable_initToPool (tReedTable** const, Lfloat offset, Lfloat slope, tMempool** const); void tReedTable_free (tReedTable** const); Lfloat tReedTable_tick (tReedTable* const, Lfloat input); @@ -1193,9 +1193,9 @@ void tTString_setPickupAmount (tTString* const bw, Lfloat amount); typedef struct tStiffString { - tMempool mempool; + tMempool* mempool; int numModes; - tCycle *osc; // array of oscillators + tCycle **oscs; // array of oscillators Lfloat *amplitudes; Lfloat *outputWeights; Lfloat freqHz; // the frequency of the whole string, determining delay length @@ -1218,7 +1218,7 @@ typedef struct tStiffString } tStiffString; void tStiffString_init (tStiffString** const, int numModes, LEAF* const leaf); - void tStiffString_initToPool (tStiffString** const, int numModes, tMempool* const); + void tStiffString_initToPool (tStiffString** const, int numModes, tMempool** const); void tStiffString_free (tStiffString** const); Lfloat tStiffString_tick (tStiffString* const); @@ -1246,23 +1246,23 @@ typedef struct tStiffString typedef struct tStereoRotation { - tMempool mempool; + tMempool* mempool; Lfloat angle; Lfloat vcaoutx; Lfloat vcaouty; - tHighpass hip1; - tHighpass hip2; + tHighpass* hip1; + tHighpass* hip2; Lfloat rotGain; - tLagrangeDelay rotDelayx; - tLagrangeDelay rotDelayy; - tOnePole filtx; - tOnePole filty; + tLagrangeDelay* rotDelayx; + tLagrangeDelay* rotDelayy; + tOnePole* filtx; + tOnePole* filty; Lfloat feedbackFactorx; Lfloat feedbackFactory; } tStereoRotation; void tStereoRotation_init (tStereoRotation** const, LEAF* const leaf); - void tStereoRotation_initToPool (tStereoRotation** const rr, tMempool* const mp); + void tStereoRotation_initToPool (tStereoRotation** const rr, tMempool** const mp); void tStereoRotation_tick (tStereoRotation* const r, float* samples); void tStereoRotation_tickIn (tStereoRotation* const r, float* samples); diff --git a/leaf/Inc/leaf-reverb.h b/leaf/Inc/leaf-reverb.h index 09b576e..7c2a048 100644 --- a/leaf/Inc/leaf-reverb.h +++ b/leaf/Inc/leaf-reverb.h @@ -38,17 +38,17 @@ extern "C" { @brief Reverb, reimplemented from STK (Cook and Scavone). @{ - @fn void tPRCReverb_init (tPRCReverb* const, Lfloat t60, LEAF* const leaf) + @fn void tPRCReverb_init(tPRCReverb** const, Lfloat t60, LEAF* const leaf) @brief Initialize a tPRCReverb to the default mempool of a LEAF instance. @param reverb A pointer to the tPRCReverb to initialize. @param leaf A pointer to the leaf instance. - @fn void tPRCReverb_initToPool (tPRCReverb* const, Lfloat t60, tMempool* const) + @fn void tPRCReverb_initToPool(tPRCReverb** const, Lfloat t60, tMempool** const) @brief Initialize a tPRCReverb to a specified mempool. @param reverb A pointer to the tPRCReverb to initialize. @param mempool A pointer to the tMempool to use. - @fn void tPRCReverb_free (tPRCReverb* const) + @fn void tPRCReverb_free(tPRCReverb** const) @brief Free a tPRCReverb from its mempool. @param reverb A pointer to the tPRCReverb to free. @@ -72,16 +72,16 @@ extern "C" { typedef struct tPRCReverb { - - tMempool mempool; + + tMempool* mempool; Lfloat mix, t60; Lfloat sampleRate; Lfloat invSampleRate; - tDelay allpassDelays[2]; - tDelay combDelay; + tDelay* allpassDelays[2]; + tDelay* combDelay; Lfloat allpassCoeff; Lfloat combCoeff; @@ -89,7 +89,7 @@ extern "C" { } tPRCReverb; void tPRCReverb_init (tPRCReverb** const, Lfloat t60, LEAF* const leaf); - void tPRCReverb_initToPool (tPRCReverb** const, Lfloat t60, tMempool* const); + void tPRCReverb_initToPool (tPRCReverb** const, Lfloat t60, tMempool** const); void tPRCReverb_free (tPRCReverb** const); Lfloat tPRCReverb_tick (tPRCReverb* const, Lfloat input); @@ -107,17 +107,17 @@ extern "C" { @brief Reverb, reimplemented from STK (Cook and Scavone). @{ - @fn void tNReverb_init (tNReverb* const, Lfloat t60, LEAF* const leaf) + @fn void tNReverb_init(tNReverb** const, Lfloat t60, LEAF* const leaf) @brief Initialize a tNReverb to the default mempool of a LEAF instance. @param reverb A pointer to the tNReverb to initialize. @param leaf A pointer to the leaf instance. - @fn void tNReverb_initToPool (tNReverb* const, Lfloat t60, tMempool* const) + @fn void tNReverb_initToPool(tNReverb** const, Lfloat t60, tMempool** const) @brief Initialize a tNReverb to a specified mempool. @param reverb A pointer to the tNReverb to initialize. @param mempool A pointer to the tMempool to use. - @fn void tNReverb_free (tNReverb* const) + @fn void tNReverb_free(tNReverb** const) @brief Free a tNReverb from its mempool. @param reverb A pointer to the tNReverb to free. @@ -145,16 +145,16 @@ extern "C" { typedef struct tNReverb { - - tMempool mempool; + + tMempool* mempool; Lfloat mix, t60; Lfloat sampleRate; Lfloat invSampleRate; - tLinearDelay allpassDelays[8]; - tLinearDelay combDelays[6]; + tLinearDelay* allpassDelays[8]; + tLinearDelay* combDelays[6]; Lfloat allpassCoeff; Lfloat combCoeffs[6]; Lfloat lowpassState; @@ -163,7 +163,7 @@ extern "C" { } tNReverb; void tNReverb_init (tNReverb** const, Lfloat t60, LEAF* const leaf); - void tNReverb_initToPool (tNReverb** const, Lfloat t60, tMempool* const); + void tNReverb_initToPool (tNReverb** const, Lfloat t60, tMempool** const); void tNReverb_free (tNReverb** const); Lfloat tNReverb_tick (tNReverb* const, Lfloat input); @@ -182,17 +182,17 @@ extern "C" { @brief Dattorro plate reverb. @{ - @fn void tDattorroReverb_init (tDattorroReverb* const, LEAF* const leaf) + @fn void tDattorroReverb_init(tDattorroReverb** const, LEAF* const leaf) @brief Initialize a tDattorroReverb to the default mempool of a LEAF instance. @param reverb A pointer to the tDattorroReverb to initialize. @param leaf A pointer to the leaf instance. - @fn void tDattorroReverb_initToPool (tDattorroReverb* const, tMempool* const) + @fn void tDattorroReverb_initToPool(tDattorroReverb** const, tMempool** const) @brief Initialize a tDattorroReverb to a specified mempool. @param reverb A pointer to the tDattorroReverb to initialize. @param mempool A pointer to the tMempool to use. - @fn void tDattorroReverb_free (tDattorroReverb* const) + @fn void tDattorroReverb_free(tDattorroReverb** const) @brief Free a tDattorroReverb from its mempool. @param reverb A pointer to the tDattorroReverb to free. @@ -244,8 +244,8 @@ extern "C" { typedef struct tDattorroReverb { - - tMempool mempool; + + tMempool* mempool; Lfloat sampleRate; Lfloat predelay; @@ -264,33 +264,32 @@ extern "C" { f2_last; // INPUT - tTapeDelay in_delay; - tOnePole in_filter; - tAllpass in_allpass[4]; - + tTapeDelay* in_delay; + tOnePole* in_filter; + tAllpass* in_allpass[4]; // FEEDBACK 1 - tAllpass f1_allpass; - tTapeDelay f1_delay_1; - tOnePole f1_filter; - tTapeDelay f1_delay_2; - tTapeDelay f1_delay_3; - tHighpass f1_hp; + tAllpass* f1_allpass; + tTapeDelay* f1_delay_1; + tOnePole* f1_filter; + tTapeDelay* f1_delay_2; + tTapeDelay* f1_delay_3; + tHighpass* f1_hp; - tCycle f1_lfo; + tCycle* f1_lfo; // FEEDBACK 2 - tAllpass f2_allpass; - tTapeDelay f2_delay_1; - tOnePole f2_filter; - tTapeDelay f2_delay_2; - tTapeDelay f2_delay_3; - tHighpass f2_hp; + tAllpass* f2_allpass; + tTapeDelay* f2_delay_1; + tOnePole* f2_filter; + tTapeDelay* f2_delay_2; + tTapeDelay* f2_delay_3; + tHighpass* f2_hp; - tCycle f2_lfo; + tCycle* f2_lfo; } tDattorroReverb; void tDattorroReverb_init (tDattorroReverb** const, LEAF* const leaf); - void tDattorroReverb_initToPool (tDattorroReverb** const, tMempool* const); + void tDattorroReverb_initToPool (tDattorroReverb** const, tMempool** const); void tDattorroReverb_free (tDattorroReverb** const); Lfloat tDattorroReverb_tick (tDattorroReverb* const, Lfloat input); diff --git a/leaf/Inc/leaf-sampling.h b/leaf/Inc/leaf-sampling.h index e20bf33..bb21513 100644 --- a/leaf/Inc/leaf-sampling.h +++ b/leaf/Inc/leaf-sampling.h @@ -40,19 +40,19 @@ extern "C" @details Buffer for use in Sampler objects. Can selectively record audio and keeps track of the length of recorded audio. @{ - @fn void tBuffer_init (tBuffer* const, uint32_t length, LEAF* const leaf) + @fn void tBuffer_init(tBuffer** const, uint32_t length, LEAF* const leaf) @brief Initialize a tBuffer to the default mempool of a LEAF instance. @param sampler A pointer to the tBuffer to initialize. @param length The length of the buffer in samples. @param leaf A pointer to the leaf instance. - @fn void tBuffer_initToPool (tBuffer* const, uint32_t length, tMempool* const) + @fn void tBuffer_initToPool(tBuffer** const, uint32_t length, tMempool** const) @brief Initialize a tBuffer to a specified mempool. @param sampler A pointer to the tBuffer to initialize. @param length The length of the buffer in samples. @param mempool A pointer to the tMempool to use. - @fn void tBuffer_free (tBuffer* const) + @fn void tBuffer_free(tBuffer** const) @brief Free a tBuffer from its mempool. @param sampler A pointer to the tBuffer to free. @@ -132,7 +132,7 @@ extern "C" typedef struct tBuffer { - tMempool mempool; + tMempool* mempool; Lfloat *buff; @@ -147,7 +147,7 @@ extern "C" } tBuffer; void tBuffer_init (tBuffer**const, uint32_t length, LEAF *const leaf); - void tBuffer_initToPool (tBuffer**const sb, uint32_t length, tMempool *const mp); + void tBuffer_initToPool (tBuffer**const sb, uint32_t length, tMempool** const mp); void tBuffer_free (tBuffer**const); void tBuffer_tick (tBuffer* const, Lfloat sample); @@ -174,19 +174,19 @@ extern "C" @brief Loopable input sampler with crossfading. @{ - @fn void tSampler_init (tSampler* const, tBuffer* const, LEAF* const leaf) + @fn void tSampler_init(tSampler** const, tBuffer* const, LEAF* const leaf) @brief Initialize a tSampler to the default mempool of a LEAF instance. @param sampler A pointer to the tSampler to initialize. @param buffer A pointer to a tBuffer to playback audio from. Multiple tSamplers can share one tBuffer. @param leaf A pointer to the leaf instance. - @fn void tSampler_initToPool (tSampler* const, tBuffer* const, tMempool* const) + @fn void tSampler_initToPool(tSampler** const, tBuffer* const, tMempool** const) @brief Initialize a tSampler to a specified mempool. @param sampler A pointer to the tSampler to initialize. @param buffer A pointer to a tBuffer to playback audio from. Multiple tSamplers can share one tBuffer. @param mempool A pointer to the tMempool to use. - @fn void tSampler_free (tSampler* const) + @fn void tSampler_free(tSampler** const) @brief Free a tSampler from its mempool. @param sampler A pointer to the tSampler to free. @@ -242,9 +242,9 @@ extern "C" typedef struct tSampler { - tMempool mempool; + tMempool* mempool; - tBuffer samp; + tBuffer* samp; Lfloat invSampleRate; Lfloat sampleRate; @@ -252,7 +252,7 @@ extern "C" Lfloat rateFactor; uint32_t channels; - tRamp gain; + tRamp* gain; Lfloat idx; Lfloat inc; @@ -279,14 +279,14 @@ extern "C" Lfloat flipIdx; } tSampler; - void tSampler_init (tSampler**const, tBuffer *const, LEAF *const leaf); - void tSampler_initToPool (tSampler**const sp, tBuffer *const b, tMempool *const mp, LEAF *const leaf); + void tSampler_init (tSampler**const, tBuffer **const, LEAF *const leaf); + void tSampler_initToPool (tSampler**const sp, tBuffer **const b, tMempool** const mp, LEAF *const leaf); void tSampler_free (tSampler**const); Lfloat tSampler_tick (tSampler* const); Lfloat tSampler_tickStereo (tSampler* const sp, Lfloat *outputArray); - void tSampler_setSample (tSampler* const, tBuffer const); + void tSampler_setSample (tSampler* const, tBuffer* const); void tSampler_setMode (tSampler* const, PlayMode mode); void tSampler_play (tSampler* const); void tSampler_stop (tSampler* const); @@ -306,17 +306,17 @@ extern "C" @brief Automatic sampler based on power of input. @{ - @fn void tAutoSampler_init (tAutoSampler* const, tBuffer* const, LEAF* const leaf) + @fn void tAutoSampler_init(tAutoSampler** const, tBuffer* const, LEAF* const leaf) @brief Initialize a tAutoSampler to the default mempool of a LEAF instance. @param sampler A pointer to the tAutoSampler to initialize. @param leaf A pointer to the leaf instance. - @fn void tAutoSampler_initToPool (tAutoSampler* const, tBuffer* const, tMempool* const) + @fn void tAutoSampler_initToPool(tAutoSampler** const, tBuffer* const, tMempool** const) @brief Initialize a tAutoSampler to a specified mempool. @param sampler A pointer to the tAutoSampler to initialize. @param mempool A pointer to the tMempool to use. - @fn void tAutoSampler_free (tAutoSampler* const) + @fn void tAutoSampler_free(tAutoSampler** const) @brief Free a tAutoSampler from its mempool. @param sampler A pointer to the tAutoSampler to free. @@ -361,9 +361,9 @@ extern "C" typedef struct tAutoSampler { - tMempool mempool; - tSampler sampler; - tEnvelopeFollower ef; + tMempool* mempool; + tSampler* sampler; + tEnvelopeFollower* ef; uint32_t windowSize; Lfloat threshold; Lfloat previousPower; @@ -372,13 +372,13 @@ extern "C" uint8_t sampleTriggered; } tAutoSampler; - void tAutoSampler_init (tAutoSampler**const, tBuffer *const, LEAF *const leaf); - void tAutoSampler_initToPool (tAutoSampler**const as, tBuffer *const b, tMempool *const mp, LEAF *const leaf); + void tAutoSampler_init (tAutoSampler**const, tBuffer* *const, LEAF *const leaf); + void tAutoSampler_initToPool (tAutoSampler**const as, tBuffer **const b, tMempool** const mp, LEAF *const leaf); void tAutoSampler_free (tAutoSampler**const); Lfloat AutoSampler_tick (tAutoSampler* const, Lfloat input); - void tAutoSampler_setBuffer (tAutoSampler* const, tBuffer const); + void tAutoSampler_setBuffer (tAutoSampler* const, tBuffer* const); void tAutoSampler_setMode (tAutoSampler* const, PlayMode mode); void tAutoSampler_play (tAutoSampler* const); void tAutoSampler_stop (tAutoSampler* const); @@ -394,17 +394,17 @@ extern "C" @brief Loopable input sampler using minBLEP to remove discontinuities. @{ - @fn void tMBSampler_init (tMBSampler* const, tBuffer* const, LEAF* const leaf) + @fn void tMBSampler_init(tMBSampler** const, tBuffer* const, LEAF* const leaf) @brief Initialize a tMBSampler to the default mempool of a LEAF instance. @param sampler A pointer to the tMBSampler to initialize. @param leaf A pointer to the leaf instance. - @fn void tMBSampler_initToPool (tMBSampler* const, tBuffer* const, tMempool* const) + @fn void tMBSampler_initToPool(tMBSampler** const, tBuffer* const, tMempool** const) @brief Initialize a tMBSampler to a specified mempool. @param sampler A pointer to the tMBSampler to initialize. @param mempool A pointer to the tMempool to use. - @fn void tMBSampler_free (tMBSampler* const) + @fn void tMBSampler_free(tMBSampler** const) @brief Free a tMBSampler from its mempool. @param sampler A pointer to the tMBSampler to free. @@ -456,13 +456,13 @@ extern "C" typedef struct tMBSampler { - tMempool mempool; + tMempool* mempool; - tBuffer samp; + tBuffer* samp; PlayMode mode; int active; - tExpSmooth gain; + tExpSmooth* gain; Lfloat out; Lfloat last, beforeLast; @@ -478,8 +478,8 @@ extern "C" int currentLoopLength; } tMBSampler; - void tMBSampler_init (tMBSampler**const, tBuffer *const, LEAF *const leaf); - void tMBSampler_initToPool (tMBSampler**const, tBuffer *const, tMempool *const); + void tMBSampler_init (tMBSampler**const, tBuffer **const, LEAF *const leaf); + void tMBSampler_initToPool (tMBSampler**const, tBuffer **const, tMempool** const); void tMBSampler_free (tMBSampler**const); Lfloat tMBSampler_tick (tMBSampler* const); diff --git a/leaf/Inc/leaf-tables.h b/leaf/Inc/leaf-tables.h index 915c575..95a4475 100644 --- a/leaf/Inc/leaf-tables.h +++ b/leaf/Inc/leaf-tables.h @@ -23,12 +23,12 @@ typedef struct tLookupTable { uint32_t tableSize; float* table; - tMempool mempool; + tMempool* mempool; } tLookupTable; void tLookupTable_init(tLookupTable** const tLookupTable, float start, float end, float center, int size, LEAF* const leaf); -void tLookupTable_initToPool(tLookupTable** const tLookupTable, float start, float end, float center, int size, tMempool* const mempool); +void tLookupTable_initToPool(tLookupTable** const tLookupTable, float start, float end, float center, int size, tMempool** const mempool); /*! @ingroup tables diff --git a/leaf/Inc/leaf-vocal.h b/leaf/Inc/leaf-vocal.h index a314a26..b339361 100644 --- a/leaf/Inc/leaf-vocal.h +++ b/leaf/Inc/leaf-vocal.h @@ -21,7 +21,7 @@ typedef struct glottis { - tMempool mempool; + tMempool* mempool; Lfloat freq; Lfloat tenseness; Lfloat Rd; @@ -41,14 +41,14 @@ typedef struct glottis } glottis; void glottis_init (glottis**glo, LEAF* const leaf); -void glottis_initToPool (glottis**glo, tMempool* const mp); +void glottis_initToPool (glottis**glo, tMempool** const mp); Lfloat glottis_compute (glottis* glo); void glottis_setup_waveform (glottis* glo); -typedef struct _transient +typedef struct transient { int position; Lfloat time_alive; @@ -57,25 +57,23 @@ typedef struct _transient Lfloat exponent; char is_free; unsigned int id; - struct _transient *next; -} _transient; + struct transient *next; +} transient; -typedef _transient* transient; -typedef struct _transient_pool + +typedef struct transient_pool { - transient pool[MAX_TRANSIENTS]; - _transient *root; + transient* pool[MAX_TRANSIENTS]; + transient *root; int size; int next_free; -} _transient_pool; - -typedef _transient_pool* transient_pool; +} transient_pool; -typedef struct _tract +typedef struct tract { - tMempool mempool; + tMempool* mempool; int n; Lfloat invN; int nMinusOne; @@ -135,77 +133,75 @@ typedef struct _tract Lfloat block_time; Lfloat diameterScale; - tSVF fricativeNoiseFilt[2]; - tSVF aspirationNoiseFilt; - tNoise whiteNoise; + tSVF* fricativeNoiseFilt[2]; + tSVF* aspirationNoiseFilt; + tNoise* whiteNoise; Lfloat turbuluencePointPosition[2]; Lfloat turbuluencePointDiameter[2]; - transient_pool tpool; + transient_pool* tpool; Lfloat T; -} _tract; - -typedef _tract* tract; - -void tract_init(tract* const t, int numTractSections, int maxNumTractSections, LEAF* const leaf); -void tract_initToPool(tract* const t, int numTractSections, int maxNumTractSections, tMempool* const mp); - -void tract_calculate_reflections (tract t); -void tract_newLength (tract t, int newLength); -void tract_reshape (tract t); -void tract_compute (tract t, Lfloat in, Lfloat lambda); -void tract_calculate_nose_reflections (tract t); -void tract_addTurbulenceNoise (tract const t); -void tract_addTurbulenceNoiseAtPosition (tract const t, Lfloat turbulenceNoise, Lfloat position, Lfloat diameter); -int append_transient (transient_pool pool, int position); -void remove_transient (transient_pool pool, unsigned int id); +} tract; + + + +void tract_init(tract** const t, int numTractSections, int maxNumTractSections, LEAF* const leaf); +void tract_initToPool(tract** const t, int numTractSections, int maxNumTractSections, tMempool** const mp); + +void tract_calculate_reflections (tract* t); +void tract_newLength (tract* t, int newLength); +void tract_reshape (tract* t); +void tract_compute (tract* t, Lfloat in, Lfloat lambda); +void tract_calculate_nose_reflections (tract* t); +void tract_addTurbulenceNoise (tract* const t); +void tract_addTurbulenceNoiseAtPosition (tract* const t, Lfloat turbulenceNoise, Lfloat position, Lfloat diameter); +int append_transient (transient_pool* pool, int position); +void remove_transient (transient_pool* pool, unsigned int id); Lfloat move_towards (Lfloat current, Lfloat target, Lfloat amt_up, Lfloat amt_down); -typedef struct _tVoc +typedef struct tVoc { - tMempool mempool; - glottis glot; /*The Glottis*/ - tract tr; /*The Vocal Tract */ + tMempool* mempool; + glottis* glot; /*The Glottis*/ + tract* tr; /*The Vocal Tract */ int doubleCompute; //Lfloat* buf; int counter; int sampleRate; -} _tVoc; - -typedef _tVoc* tVoc; - -void tVoc_init (tVoc* const voc, int numTractSections, int maxNumTractSections, LEAF* const leaf); -void tVoc_initToPool (tVoc* const voc, int numTractSections,int maxNumTractSections, tMempool* const mempool); -void tVoc_free (tVoc* const voc); - -Lfloat tVoc_tick (tVoc const voc); - -void tVoc_tractCompute (tVoc const voc, Lfloat *in, Lfloat *out); -void tVoc_setSampleRate (tVoc const voc, Lfloat sr); -void tVoc_setFreq (tVoc const voc, Lfloat freq); -Lfloat* tVoc_get_tract_diameters (tVoc const voc); -Lfloat* tVoc_get_current_tract_diameters (tVoc const voc); -Lfloat* tVoc_get_tract_rest_diameters (tVoc const voc); -void tVoc_set_tractLength (tVoc const voc, int newLength); -int tVoc_get_tract_size (tVoc const voc); -Lfloat* tVoc_get_nose_diameters (tVoc const voc); -int tVoc_get_nose_size (tVoc const voc); -void tVoc_set_tongue_shape_and_touch (tVoc const voc, Lfloat tongue_index, Lfloat tongue_diameter, Lfloat touch_index, Lfloat touch_diameter); -void tVoc_set_tongue_and_touch_diameters (tVoc const voc, Lfloat tongue_index, Lfloat tongue_diameter, Lfloat touch_index, Lfloat touch_diameter, Lfloat *theDiameters); -void tVoc_set_tenseness (tVoc const voc, Lfloat breathiness); -Lfloat* tVoc_get_tenseness_ptr (tVoc const voc); -void tVoc_set_velum (tVoc const voc, Lfloat velum); -Lfloat* tVoc_get_velum_ptr (tVoc const voc); -void tVoc_setDoubleComputeFlag (tVoc const voc, int doubleCompute); -int tVoc_get_counter (tVoc const voc); -void tVoc_rescaleDiameter (tVoc const voc, Lfloat scale); -void tVoc_setTurbulenceNoiseGain (tVoc const voc, Lfloat gain); -void tVoc_setAspirationNoiseGain (tVoc const voc, Lfloat gain); -void tVoc_setAspirationNoiseFilterFreq (tVoc const voc, Lfloat Q); -void tVoc_setAspirationNoiseFilterQ (tVoc const voc, Lfloat freq); +} tVoc; + +void tVoc_init(tVoc** const voc, int numTractSections, int maxNumTractSections, LEAF* const leaf); +void tVoc_initToPool(tVoc** const voc, int numTractSections,int maxNumTractSections, tMempool** const mempool); +void tVoc_free(tVoc** const voc); + +Lfloat tVoc_tick (tVoc* const voc); + +void tVoc_tractCompute (tVoc* const voc, Lfloat *in, Lfloat *out); +void tVoc_setSampleRate (tVoc* const voc, Lfloat sr); +void tVoc_setFreq (tVoc* const voc, Lfloat freq); +Lfloat* tVoc_get_tract_diameters (tVoc* const voc); +Lfloat* tVoc_get_current_tract_diameters (tVoc* const voc); +Lfloat* tVoc_get_tract_rest_diameters (tVoc* const voc); +void tVoc_set_tractLength (tVoc* const voc, int newLength); +int tVoc_get_tract_size (tVoc* const voc); +Lfloat* tVoc_get_nose_diameters (tVoc* const voc); +int tVoc_get_nose_size (tVoc* const voc); +void tVoc_set_tongue_shape_and_touch (tVoc* const voc, Lfloat tongue_index, Lfloat tongue_diameter, Lfloat touch_index, Lfloat touch_diameter); +void tVoc_set_tongue_and_touch_diameters (tVoc* const voc, Lfloat tongue_index, Lfloat tongue_diameter, Lfloat touch_index, Lfloat touch_diameter, Lfloat *theDiameters); +void tVoc_set_tenseness (tVoc* const voc, Lfloat breathiness); +Lfloat* tVoc_get_tenseness_ptr (tVoc* const voc); +void tVoc_set_velum (tVoc* const voc, Lfloat velum); +Lfloat* tVoc_get_velum_ptr (tVoc* const voc); +void tVoc_setDoubleComputeFlag (tVoc* const voc, int doubleCompute); +int tVoc_get_counter (tVoc* const voc); +void tVoc_rescaleDiameter (tVoc* const voc, Lfloat scale); +void tVoc_setTurbulenceNoiseGain (tVoc* const voc, Lfloat gain); +void tVoc_setAspirationNoiseGain (tVoc* const voc, Lfloat gain); +void tVoc_setAspirationNoiseFilterFreq (tVoc* const voc, Lfloat Q); +void tVoc_setAspirationNoiseFilterQ (tVoc* const voc, Lfloat freq); #endif /* INC_LEAF_VOCAL_H_ */ diff --git a/leaf/Src/leaf-analysis.c b/leaf/Src/leaf-analysis.c index 2f538e5..b627fe2 100644 --- a/leaf/Src/leaf-analysis.c +++ b/leaf/Src/leaf-analysis.c @@ -26,15 +26,15 @@ /* Envelope Follower */ /******************************************************************************/ -void tEnvelopeFollower_init (tEnvelopeFollower* const ef, Lfloat attackThreshold, Lfloat decayCoeff, LEAF* const leaf) +void tEnvelopeFollower_init(tEnvelopeFollower** const ef, Lfloat attackThreshold, Lfloat decayCoeff, LEAF* const leaf) { tEnvelopeFollower_initToPool(ef, attackThreshold, decayCoeff, &leaf->mempool); } void tEnvelopeFollower_initToPool (tEnvelopeFollower** const ef, Lfloat attackThreshold, Lfloat decayCoeff, - tMempool* const mp) + tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tEnvelopeFollower* e = *ef = (tEnvelopeFollower*) mpool_alloc(sizeof(tEnvelopeFollower), m); e->mempool = m; @@ -84,14 +84,14 @@ void tEnvelopeFollower_setAttackThreshold (tEnvelopeFollower* const e, Lfloat at /******************************************************************************/ -void tZeroCrossingCounter_init (tZeroCrossingCounter* const zc, int maxWindowSize, LEAF* const leaf) +void tZeroCrossingCounter_init(tZeroCrossingCounter** const zc, int maxWindowSize, LEAF* const leaf) { tZeroCrossingCounter_initToPool (zc, maxWindowSize, &leaf->mempool); } -void tZeroCrossingCounter_initToPool (tZeroCrossingCounter** const zc, int maxWindowSize, tMempool* const mp) +void tZeroCrossingCounter_initToPool (tZeroCrossingCounter** const zc, int maxWindowSize, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tZeroCrossingCounter* z = *zc = (tZeroCrossingCounter*) mpool_alloc(sizeof(tZeroCrossingCounter), m); z->mempool = m; @@ -170,14 +170,14 @@ void tZeroCrossingCounter_setWindowSize (tZeroCrossingCounter* const z, Lfloat w /******************************************************************************/ -void tPowerFollower_init (tPowerFollower* const pf, Lfloat factor, LEAF* const leaf) +void tPowerFollower_init(tPowerFollower** const pf, Lfloat factor, LEAF* const leaf) { tPowerFollower_initToPool(pf, factor, &leaf->mempool); } -void tPowerFollower_initToPool (tPowerFollower** const pf, Lfloat factor, tMempool* const mp) +void tPowerFollower_initToPool (tPowerFollower** const pf, Lfloat factor, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tPowerFollower* p = *pf = (tPowerFollower*) mpool_alloc(sizeof(tPowerFollower), m); p->mempool = m; @@ -218,14 +218,14 @@ Lfloat tPowerFollower_getPower (tPowerFollower* const p) /******************************************************************************/ -void tEnvPD_init (tEnvPD* const xpd, int ws, int hs, int bs, LEAF* const leaf) +void tEnvPD_init(tEnvPD** const xpd, int ws, int hs, int bs, LEAF* const leaf) { tEnvPD_initToPool(xpd, ws, hs, bs, &leaf->mempool); } -void tEnvPD_initToPool (tEnvPD** const xpd, int ws, int hs, int bs, tMempool* const mp) +void tEnvPD_initToPool (tEnvPD** const xpd, int ws, int hs, int bs, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tEnvPD* x = *xpd = (tEnvPD*) mpool_calloc(sizeof(tEnvPD), m); x->mempool = m; @@ -318,23 +318,23 @@ void tEnvPD_processBlock(tEnvPD* const x, Lfloat* in) /*********************** Static Function Declarations *************************/ -static void atkdtk_init (tAttackDetection const a, int blocksize, int atk, int rel); -static void atkdtk_envelope (tAttackDetection const a, Lfloat *in); +static void atkdtk_init (tAttackDetection* const a, int blocksize, int atk, int rel); +static void atkdtk_envelope (tAttackDetection* const a, Lfloat *in); /******************************************************************************/ -void tAttackDetection_init (tAttackDetection* const ad, int blocksize, int atk, int rel, LEAF* const leaf) +void tAttackDetection_init(tAttackDetection** const ad, int blocksize, int atk, int rel, LEAF* const leaf) { tAttackDetection_initToPool(ad, blocksize, atk, rel, &leaf->mempool); } -void tAttackDetection_initToPool (tAttackDetection** const ad, int blocksize, int atk, int rel, tMempool* const mp) +void tAttackDetection_initToPool (tAttackDetection** const ad, int blocksize, int atk, int rel, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tAttackDetection* a = *ad = (tAttackDetection*) mpool_alloc(sizeof(tAttackDetection), m); a->mempool = m; - atkdtk_init(*a, blocksize, atk, rel); + atkdtk_init(a, blocksize, atk, rel); } void tAttackDetection_free (tAttackDetection** const ad) @@ -370,7 +370,7 @@ int tAttackDetection_detect (tAttackDetection* const a, Lfloat *in) { int result; - atkdtk_envelope(*a, in); + atkdtk_envelope(a, in); if(a->env >= a->prevAmp*2) //2 times greater = 6dB increase result = 1; @@ -392,7 +392,7 @@ void tAttackDetection_setSampleRate (tAttackDetection* const a, Lfloat sr) /************************ Static Function Definitions *************************/ -static void atkdtk_init (tAttackDetection* const a, int blocksize, int atk, int rel) +static void atkdtk_init(tAttackDetection* const a, int blocksize, int atk, int rel) { LEAF* leaf = a->mempool->leaf; @@ -433,24 +433,24 @@ static void atkdtk_envelope(tAttackDetection* const a, Lfloat *in) /*********************** Static Function Declarations *************************/ -static void snac_analyzeframe (tSNAC const s); -static void snac_autocorrelation (tSNAC const s); -static void snac_normalize (tSNAC const s); -static void snac_pickpeak (tSNAC const s); -static void snac_periodandfidelity (tSNAC const s); -static void snac_biasbuf (tSNAC const s); -static Lfloat snac_spectralpeak (tSNAC const s, Lfloat periodlength); +static void snac_analyzeframe (tSNAC* const s); +static void snac_autocorrelation (tSNAC* const s); +static void snac_normalize (tSNAC* const s); +static void snac_pickpeak (tSNAC* const s); +static void snac_periodandfidelity (tSNAC* const s); +static void snac_biasbuf (tSNAC* const s); +static Lfloat snac_spectralpeak (tSNAC* const s, Lfloat periodlength); /******************************************************************************/ -void tSNAC_init(tSNAC* const snac, int overlaparg, LEAF* const leaf) +void tSNAC_init(tSNAC** const snac, int overlaparg, LEAF* const leaf) { tSNAC_initToPool(snac, overlaparg, &leaf->mempool); } -void tSNAC_initToPool (tSNAC** const snac, int overlaparg, tMempool* const mp) +void tSNAC_initToPool (tSNAC** const snac, int overlaparg, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tSNAC* s = *snac = (tSNAC*) mpool_alloc(sizeof(tSNAC), m); s->mempool = m; @@ -467,7 +467,7 @@ void tSNAC_initToPool (tSNAC** const snac, int overlaparg, tMempool* const s->spectrumbuf = (Lfloat*) mpool_calloc(sizeof(Lfloat) * (SNAC_FRAME_SIZE / 2), m); s->biasbuf = (Lfloat*) mpool_calloc(sizeof(Lfloat) * SNAC_FRAME_SIZE, m); - snac_biasbuf(*s); + snac_biasbuf(s); tSNAC_setOverlap(s, overlaparg); } @@ -492,7 +492,7 @@ void tSNAC_ioSamples (tSNAC* const s, Lfloat *in, int size) // Lfloat *processbuf = s->processbuf; // call analysis function when it is time - if(!(timeindex & (s->framesize / s->overlap - 1))) snac_analyzeframe(*s); + if(!(timeindex & (s->framesize / s->overlap - 1))) snac_analyzeframe(s); while(size--) { @@ -515,7 +515,7 @@ void tSNAC_setBias (tSNAC* const s, Lfloat bias) if(bias > 1.) bias = 1.; if(bias < 0.) bias = 0.; s->biasfactor = bias; - snac_biasbuf(*s); + snac_biasbuf(s); return; } @@ -563,10 +563,10 @@ static void snac_analyzeframe(tSNAC* const s) for(n=framesize; n<(framesize<<1); n++) processbuf[n] = 0.; // call analysis procedures - snac_autocorrelation(*s); - snac_normalize(*s); - snac_pickpeak(*s); - snac_periodandfidelity(*s); + snac_autocorrelation(s); + snac_normalize(s); + snac_pickpeak(s); + snac_periodandfidelity(s); } static void snac_autocorrelation(tSNAC* const s) @@ -645,7 +645,7 @@ static void snac_periodandfidelity (tSNAC* const s) { periodlength = (Lfloat)s->periodindex + interpolate3phase(s->processbuf, s->periodindex); - if(periodlength < 8) periodlength = snac_spectralpeak(*s, periodlength); + if(periodlength < 8) periodlength = snac_spectralpeak(s, periodlength); s->periodlength = periodlength; s->fidelity = interpolate3max(s->processbuf, s->periodindex); } @@ -760,14 +760,14 @@ static void snac_biasbuf (tSNAC* const s) /* Period Detection */ /******************************************************************************/ -void tPeriodDetection_init (tPeriodDetection* const pd, Lfloat* in, int bufSize, int frameSize, LEAF* const leaf) +void tPeriodDetection_init(tPeriodDetection** const pd, Lfloat* in, int bufSize, int frameSize, LEAF* const leaf) { tPeriodDetection_initToPool(pd, in, bufSize, frameSize, &leaf->mempool); } -void tPeriodDetection_initToPool (tPeriodDetection** const pd, Lfloat* in, int bufSize, int frameSize, tMempool* const mp) +void tPeriodDetection_initToPool (tPeriodDetection** const pd, Lfloat* in, int bufSize, int frameSize, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tPeriodDetection* p = *pd = (tPeriodDetection*) mpool_calloc(sizeof(tPeriodDetection), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -824,12 +824,12 @@ Lfloat tPeriodDetection_tick (tPeriodDetection* const p, Lfloat sample) { p->index = 0; - tEnvPD_processBlock(&p->env, &(p->inBuffer[i])); + tEnvPD_processBlock(p->env, &(p->inBuffer[i])); - tSNAC_ioSamples(&p->snac, &(p->inBuffer[i]), p->frameSize); + tSNAC_ioSamples(p->snac, &(p->inBuffer[i]), p->frameSize); // Fidelity threshold recommended by Katja Vetters is 0.95 for most instruments/voices http://www.katjaas.nl/helmholtz/helmholtz.html - p->period = tSNAC_getPeriod(&p->snac); + p->period = tSNAC_getPeriod(p->snac); p->curBlock++; if (p->curBlock >= p->framesPerBuffer) p->curBlock = 0; @@ -846,7 +846,7 @@ Lfloat tPeriodDetection_getPeriod(tPeriodDetection* const p) Lfloat tPeriodDetection_getFidelity(tPeriodDetection* const p) { - return tSNAC_getFidelity(&p->snac); + return tSNAC_getFidelity(p->snac); } void tPeriodDetection_setHopSize(tPeriodDetection* const p, int hs) @@ -885,14 +885,14 @@ void tPeriodDetection_setSampleRate (tPeriodDetection* const p, Lfloat sr) /* Zero Crossing Info */ /******************************************************************************/ -void tZeroCrossingInfo_init (tZeroCrossingInfo* const zc, LEAF* const leaf) +void tZeroCrossingInfo_init(tZeroCrossingInfo** const zc, LEAF* const leaf) { tZeroCrossingInfo_initToPool(zc, &leaf->mempool); } -void tZeroCrossingInfo_initToPool (tZeroCrossingInfo** const zc, tMempool* const mp) +void tZeroCrossingInfo_initToPool (tZeroCrossingInfo** const zc, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tZeroCrossingInfo* z = *zc = (tZeroCrossingInfo*) mpool_calloc(sizeof(tZeroCrossingInfo), m); z->mempool = m; @@ -915,10 +915,8 @@ void tZeroCrossingInfo_updatePeak(tZeroCrossingInfo* const z, Lfloat s, int p z->_width = pos - z->_leading_edge; } -int tZeroCrossingInfo_period(tZeroCrossingInfo* const z, tZeroCrossingInfo* const next) +int tZeroCrossingInfo_period(tZeroCrossingInfo* const z, tZeroCrossingInfo* const n) { - tZeroCrossingInfo* n = &*next; - return n->_leading_edge - z->_leading_edge; } @@ -948,18 +946,18 @@ int tZeroCrossingInfo_getWidth(tZeroCrossingInfo* const z) return z->_width; } -static inline void update_state(tZeroCrossingCollector const zc, Lfloat s); -static inline void shift(tZeroCrossingCollector const zc, int n); -static inline void reset(tZeroCrossingCollector const zc); +static inline void update_state(tZeroCrossingCollector* const zc, Lfloat s); +static inline void shift(tZeroCrossingCollector* const zc, int n); +static inline void reset(tZeroCrossingCollector* const zc); -void tZeroCrossingCollector_init (tZeroCrossingCollector* const zc, int windowSize, Lfloat hysteresis, LEAF* const leaf) +void tZeroCrossingCollector_init(tZeroCrossingCollector** const zc, int windowSize, Lfloat hysteresis, LEAF* const leaf) { tZeroCrossingCollector_initToPool(zc, windowSize, hysteresis, &leaf->mempool); } -void tZeroCrossingCollector_initToPool (tZeroCrossingCollector** const zc, int windowSize, Lfloat hysteresis, tMempool* const mp) +void tZeroCrossingCollector_initToPool (tZeroCrossingCollector** const zc, int windowSize, Lfloat hysteresis, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tZeroCrossingCollector* z = *zc = (tZeroCrossingCollector*) mpool_alloc(sizeof(tZeroCrossingCollector), m); z->mempool = m; @@ -973,7 +971,7 @@ void tZeroCrossingCollector_initToPool (tZeroCrossingCollector** const zc, z->_size = pow(2.0, ceil(log2((double)size))); z->_mask = z->_size - 1; - z->_info = (tZeroCrossingInfo*) mpool_calloc(sizeof(tZeroCrossingInfo) * z->_size, m); + z->_info = (tZeroCrossingInfo**) mpool_calloc(sizeof(tZeroCrossingInfo*) * z->_size, m); for (unsigned i = 0; i < z->_size; i++) { @@ -1012,12 +1010,12 @@ int tZeroCrossingCollector_tick(tZeroCrossingCollector* const z, Lfloat s) s += z->_hysteresis * 0.5f; if (z->_num_edges >= (int)z->_size) - reset(*z); + reset(z); if ((z->_frame == z->_window_size/2) && (z->_num_edges == 0)) - reset(*z); + reset(z); - update_state(*z, s); + update_state(z, s); if ((++z->_frame >= z->_window_size) && !z->_state) { @@ -1028,7 +1026,7 @@ int tZeroCrossingCollector_tick(tZeroCrossingCollector* const z, Lfloat s) if (z->_num_edges > 1) z->_ready = 1; else - reset(*z); + reset(z); } return z->_state; @@ -1039,7 +1037,7 @@ int tZeroCrossingCollector_getState(tZeroCrossingCollector* const z) return z->_state; } -tZeroCrossingInfo const tZeroCrossingCollector_getCrossing(tZeroCrossingCollector* const z, int index) +tZeroCrossingInfo* const tZeroCrossingCollector_getCrossing(tZeroCrossingCollector* const z, int index) { int i = (z->_num_edges - 1) - index; return z->_info[(z->_pos + i) & z->_mask]; @@ -1089,14 +1087,14 @@ static inline void update_state(tZeroCrossingCollector* const z, Lfloat s) { if (z->_ready) { - shift(*z, z->_window_size / 2); + shift(z, z->_window_size / 2); z->_ready = 0; z->_peak = z->_peak_update; z->_peak_update = 0.0f; } if (z->_num_edges >= (int)z->_size) - reset(*z); + reset(z); if (s > 0.0f) { @@ -1104,7 +1102,7 @@ static inline void update_state(tZeroCrossingCollector* const z, Lfloat s) { --z->_pos; z->_pos &= z->_mask; - tZeroCrossingInfo crossing = z->_info[z->_pos & z->_mask]; + tZeroCrossingInfo* crossing = z->_info[z->_pos & z->_mask]; crossing->_before_crossing = z->_prev; crossing->_after_crossing = s; crossing->_peak = s; @@ -1116,7 +1114,7 @@ static inline void update_state(tZeroCrossingCollector* const z, Lfloat s) } else { - tZeroCrossingInfo_updatePeak(&z->_info[z->_pos & z->_mask], s, z->_frame); + tZeroCrossingInfo_updatePeak(z->_info[z->_pos & z->_mask], s, z->_frame); } if (s > z->_peak_update) { @@ -1132,14 +1130,14 @@ static inline void update_state(tZeroCrossingCollector* const z, Lfloat s) } if (z->_frame > z->_window_size * 2) - reset(*z); + reset(z); z->_prev = s; } static inline void shift(tZeroCrossingCollector* const z, int n) { - tZeroCrossingInfo crossing = z->_info[z->_pos & z->_mask]; + tZeroCrossingInfo* crossing = z->_info[z->_pos & z->_mask]; crossing->_leading_edge -= n; if (!z->_state) @@ -1165,14 +1163,14 @@ static inline void reset(tZeroCrossingCollector* const z) -void tBitset_init (tBitset* const bitset, int numBits, LEAF* const leaf) +void tBitset_init(tBitset** const bitset, int numBits, LEAF* const leaf) { tBitset_initToPool(bitset, numBits, &leaf->mempool); } -void tBitset_initToPool (tBitset** const bitset, int numBits, tMempool* const mempool) +void tBitset_initToPool (tBitset** const bitset, int numBits, tMempool** const mempool) { - _tMempool* m = *mempool; + tMempool* m = *mempool; tBitset* b = *bitset = (tBitset*) mpool_alloc(sizeof(tBitset), m); b->mempool = m; @@ -1290,12 +1288,12 @@ void tBitset_setMultiple (tBitset* const b, int index, int n, unsigned int v } } -int tBitset_getSize (tBitset const b) +int tBitset_getSize (tBitset* const b) { return b->_bit_size; } -void tBitset_clear (tBitset const b) +void tBitset_clear (tBitset* const b) { for (int i = 0; i < b->_size; ++i) { @@ -1303,14 +1301,14 @@ void tBitset_clear (tBitset const b) } } -void tBACF_init (tBACF* const bacf, tBitset* const bitset, LEAF* const leaf) +void tBACF_init(tBACF** const bacf, tBitset** const bitset, LEAF* const leaf) { tBACF_initToPool(bacf, bitset, &leaf->mempool); } -void tBACF_initToPool (tBACF** const bacf, tBitset* const bitset, tMempool* const mempool) +void tBACF_initToPool (tBACF** const bacf, tBitset** const bitset, tMempool** const mempool) { - _tMempool* m = *mempool; + tMempool* m = *mempool; tBACF* b = *bacf = (tBACF*) mpool_alloc(sizeof(tBACF), m); b->mempool = m; @@ -1371,14 +1369,14 @@ int tBACF_getCorrelation (tBACF* const b, int pos) return count; } -void tBACF_set (tBACF* const b, tBitset* const bitset) +void tBACF_set (tBACF* const b, tBitset** const bitset) { b->_bitset = *bitset; b->_mid_array = ((b->_bitset->_bit_size / b->_bitset->_value_size) / 2) - 1; } -static inline void set_bitstream(tPeriodDetector const p); -static inline void autocorrelate(tPeriodDetector const detector); +static inline void set_bitstream(tPeriodDetector* const p); +static inline void autocorrelate(tPeriodDetector* const detector); static inline void sub_collector_init(_sub_collector* collector, tZeroCrossingCollector* const crossings, Lfloat pdt, int range); static inline Lfloat sub_collector_period_of(_sub_collector* collector, _auto_correlation_info info); @@ -1388,14 +1386,14 @@ static inline int sub_collector_process_harmonics(_sub_collector* collector, _au static inline void sub_collector_process(_sub_collector* collector, _auto_correlation_info info); static inline void sub_collector_get(_sub_collector* collector, _auto_correlation_info info, _period_info* result); -void tPeriodDetector_init (tPeriodDetector* const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat hysteresis, LEAF* const leaf) +void tPeriodDetector_init(tPeriodDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat hysteresis, LEAF* const leaf) { tPeriodDetector_initToPool(detector, lowestFreq, highestFreq, hysteresis, &leaf->mempool); } -void tPeriodDetector_initToPool (tPeriodDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat hysteresis, tMempool* const mempool) +void tPeriodDetector_initToPool (tPeriodDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat hysteresis, tMempool** const mempool) { - _tMempool* m = *mempool; + tMempool* m = *mempool; tPeriodDetector* p = *detector = (tPeriodDetector*) mpool_alloc(sizeof(tPeriodDetector), m); p->mempool = m; @@ -1409,7 +1407,7 @@ void tPeriodDetector_initToPool (tPeriodDetector** const detector, Lfloat lo p->_min_period = (1.0f / highestFreq) * p->sampleRate; p->_range = highestFreq / lowestFreq; - int windowSize = tZeroCrossingCollector_getWindowSize(&p->_zc); + int windowSize = tZeroCrossingCollector_getWindowSize(p->_zc); tBitset_initToPool(&p->_bits, windowSize, mempool); p->_weight = 2.0f / windowSize; p->_mid_point = windowSize / 2; @@ -1438,8 +1436,8 @@ void tPeriodDetector_free (tPeriodDetector** const detector) int tPeriodDetector_tick (tPeriodDetector* const p, Lfloat s) { // Zero crossing - int prev = tZeroCrossingCollector_getState(&p->_zc); - int zc = tZeroCrossingCollector_tick(&p->_zc, s); + int prev = tZeroCrossingCollector_getState(p->_zc); + int zc = tZeroCrossingCollector_tick(p->_zc, s); if (!zc && prev != zc) { @@ -1447,16 +1445,16 @@ int tPeriodDetector_tick (tPeriodDetector* const p, Lfloat s) p->_predicted_period = -1.0f; } - if (tZeroCrossingCollector_isReset(&p->_zc)) + if (tZeroCrossingCollector_isReset(p->_zc)) { p->_fundamental.period = -1.0f; p->_fundamental.periodicity = 0.0f; } - if (tZeroCrossingCollector_isReady(&p->_zc)) + if (tZeroCrossingCollector_isReady(p->_zc)) { - set_bitstream(*p); - autocorrelate(*p); + set_bitstream(p); + autocorrelate(p); return 1; } return 0; @@ -1482,7 +1480,7 @@ Lfloat tPeriodDetector_harmonic (tPeriodDetector* const p, int harmonicInde Lfloat target_period = p->_fundamental.period / (Lfloat) harmonicIndex; if (target_period >= p->_min_period && target_period < p->_mid_point) { - int count = tBACF_getCorrelation(&p->_bacf, roundf(target_period)); + int count = tBACF_getCorrelation(p->_bacf, roundf(target_period)); Lfloat periodicity = 1.0f - (count * p->_weight); return periodicity; } @@ -1495,21 +1493,21 @@ Lfloat tPeriodDetector_predictPeriod (tPeriodDetector* const p) if (p->_predicted_period == -1.0f && p->_edge_mark != p->_predict_edge) { p->_predict_edge = p->_edge_mark; - int n = tZeroCrossingCollector_getNumEdges(&p->_zc); + int n = tZeroCrossingCollector_getNumEdges(p->_zc); if (n > 1) { - Lfloat threshold = tZeroCrossingCollector_getPeak(&p->_zc) * PULSE_THRESHOLD; + Lfloat threshold = tZeroCrossingCollector_getPeak(p->_zc) * PULSE_THRESHOLD; for (int i = n - 1; i > 0; --i) { - tZeroCrossingInfo edge2 = tZeroCrossingCollector_getCrossing(&p->_zc, i); + tZeroCrossingInfo* edge2 = tZeroCrossingCollector_getCrossing(p->_zc, i); if (edge2->_peak >= threshold) { for (int j = i-1; j >= 0; --j) { - tZeroCrossingInfo edge1 = tZeroCrossingCollector_getCrossing(&p->_zc, j); + tZeroCrossingInfo* edge1 = tZeroCrossingCollector_getCrossing(p->_zc, j); if (edge1->_peak >= threshold) { - Lfloat period = tZeroCrossingInfo_fractionalPeriod(&edge1, &edge2); + Lfloat period = tZeroCrossingInfo_fractionalPeriod(edge1, edge2); if (period > p->_min_period) return (p->_predicted_period = period); } @@ -1524,22 +1522,22 @@ Lfloat tPeriodDetector_predictPeriod (tPeriodDetector* const p) int tPeriodDetector_isReady (tPeriodDetector* const p) { - return tZeroCrossingCollector_isReady(&p->_zc); + return tZeroCrossingCollector_isReady(p->_zc); } int tPeriodDetector_isReset (tPeriodDetector* const p) { - return tZeroCrossingCollector_isReset(&p->_zc); + return tZeroCrossingCollector_isReset(p->_zc); } void tPeriodDetector_setHysteresis (tPeriodDetector* const p, Lfloat hysteresis) { - return tZeroCrossingCollector_setHysteresis(&p->_zc, hysteresis); + return tZeroCrossingCollector_setHysteresis(p->_zc, hysteresis); } void tPeriodDetector_setSampleRate (tPeriodDetector* const p, Lfloat sr) { - _tMempool* m = p->mempool; + tMempool* m = p->mempool; p->sampleRate = sr; Lfloat hysteresis = p->_zc->_hysteresis; @@ -1550,16 +1548,16 @@ void tPeriodDetector_setSampleRate (tPeriodDetector* const p, Lfloat sr) static inline void set_bitstream(tPeriodDetector* const p) { - Lfloat threshold = tZeroCrossingCollector_getPeak(&p->_zc) * PULSE_THRESHOLD; - unsigned int leading_edge = tZeroCrossingCollector_getWindowSize(&p->_zc); + Lfloat threshold = tZeroCrossingCollector_getPeak(p->_zc) * PULSE_THRESHOLD; + unsigned int leading_edge = tZeroCrossingCollector_getWindowSize(p->_zc); unsigned int trailing_edge = 0; p->_num_pulses = 0; tBitset_clear(p->_bits); - for (int i = 0; i != tZeroCrossingCollector_getNumEdges(&p->_zc); ++i) + for (int i = 0; i != tZeroCrossingCollector_getNumEdges(p->_zc); ++i) { - tZeroCrossingInfo info = tZeroCrossingCollector_getCrossing(&p->_zc, i); + tZeroCrossingInfo* info = tZeroCrossingCollector_getCrossing(p->_zc, i); if (info->_peak >= threshold) { ++p->_num_pulses; @@ -1569,7 +1567,7 @@ static inline void set_bitstream(tPeriodDetector* const p) trailing_edge = info->_trailing_edge; int pos = fmax(info->_leading_edge, 0); int n = info->_trailing_edge - pos; - tBitset_setMultiple(&p->_bits, pos, n, 1); + tBitset_setMultiple(p->_bits, pos, n, 1); } } p->_half_empty = (leading_edge > p->_mid_point) || (trailing_edge < p->_mid_point); @@ -1577,10 +1575,10 @@ static inline void set_bitstream(tPeriodDetector* const p) static inline void autocorrelate(tPeriodDetector* const p) { - Lfloat threshold = tZeroCrossingCollector_getPeak(&p->_zc) * PULSE_THRESHOLD; + Lfloat threshold = tZeroCrossingCollector_getPeak(p->_zc) * PULSE_THRESHOLD; _sub_collector collect; - sub_collector_init(&collect, &p->_zc, p->_periodicity_diff_threshold, p->_range); + sub_collector_init(&collect, p->_zc, p->_periodicity_diff_threshold, p->_range); if (p->_half_empty || p->_num_pulses < 2) { @@ -1590,24 +1588,24 @@ static inline void autocorrelate(tPeriodDetector* const p) else { int shouldBreak = 0; - int n = tZeroCrossingCollector_getNumEdges(&p->_zc); + int n = tZeroCrossingCollector_getNumEdges(p->_zc); for (int i = 0; i != n - 1; ++i) { - tZeroCrossingInfo curr = tZeroCrossingCollector_getCrossing(&p->_zc, i); + tZeroCrossingInfo* curr = tZeroCrossingCollector_getCrossing(p->_zc, i); if (curr->_peak >= threshold) { for (int j = i + 1; j != n; ++j) { - tZeroCrossingInfo next = tZeroCrossingCollector_getCrossing(&p->_zc, j); + tZeroCrossingInfo* next = tZeroCrossingCollector_getCrossing(p->_zc, j); if (next->_peak >= threshold) { - int period = tZeroCrossingInfo_period(&curr, &next); + int period = tZeroCrossingInfo_period(curr, next); if (period > p->_mid_point) break; if (period >= p->_min_period) { - int count = tBACF_getCorrelation(&p->_bacf, period); + int count = tBACF_getCorrelation(p->_bacf, period); int mid = p->_bacf->_mid_array * CHAR_BIT * sizeof(unsigned int); @@ -1615,7 +1613,7 @@ static inline void autocorrelate(tPeriodDetector* const p) if ((collect._fundamental._period == -1.0f) && count == 0) { - if (tBACF_getCorrelation(&p->_bacf, period / 2.0f) == 0) + if (tBACF_getCorrelation(p->_bacf, period / 2.0f) == 0) count = -1; } else if (period < 32) // Search minimum if the resolution is low @@ -1623,7 +1621,7 @@ static inline void autocorrelate(tPeriodDetector* const p) // Search upwards for the minimum autocorrelation count for (int d = start + 1; d < mid; ++d) { - int c = tBACF_getCorrelation(&p->_bacf, d); + int c = tBACF_getCorrelation(p->_bacf, d); if (c > count) break; count = c; @@ -1632,7 +1630,7 @@ static inline void autocorrelate(tPeriodDetector* const p) // Search downwards for the minimum autocorrelation count for (int d = start - 1; d > p->_min_period; --d) { - int c = tBACF_getCorrelation(&p->_bacf, d); + int c = tBACF_getCorrelation(p->_bacf, d); if (c > count) break; count = c; @@ -1667,7 +1665,7 @@ static inline void autocorrelate(tPeriodDetector* const p) static inline void sub_collector_init(_sub_collector* collector, tZeroCrossingCollector* const crossings, Lfloat pdt, int range) { - collector->_zc = *crossings; + collector->_zc = crossings; collector->_harmonic_threshold = HARMONIC_PERIODICITY_FACTOR * 2.0f / (Lfloat)collector->_zc->_window_size; collector->_periodicity_diff_threshold = pdt; collector->_range = range; @@ -1681,9 +1679,9 @@ static inline void sub_collector_init(_sub_collector* collector, tZeroCrossingCo static inline Lfloat sub_collector_period_of(_sub_collector* collector, _auto_correlation_info info) { - tZeroCrossingInfo first = tZeroCrossingCollector_getCrossing(&collector->_zc, info._i1); - tZeroCrossingInfo next = tZeroCrossingCollector_getCrossing(&collector->_zc, info._i2); - return tZeroCrossingInfo_fractionalPeriod(&first, &next); + tZeroCrossingInfo* first = tZeroCrossingCollector_getCrossing(collector->_zc, info._i1); + tZeroCrossingInfo* next = tZeroCrossingCollector_getCrossing(collector->_zc, info._i2); + return tZeroCrossingInfo_fractionalPeriod(first, next); } static inline void sub_collector_save(_sub_collector* collector, _auto_correlation_info info) @@ -1763,17 +1761,17 @@ static inline void sub_collector_get(_sub_collector* collector, _auto_correlatio } } -static inline Lfloat calculate_frequency(tPitchDetector const detector); -static inline void bias(tPitchDetector const detector, _pitch_info incoming); +static inline Lfloat calculate_frequency(tPitchDetector* const detector); +static inline void bias(tPitchDetector* const detector, _pitch_info incoming); -void tPitchDetector_init (tPitchDetector* const detector, Lfloat lowestFreq, Lfloat highestFreq, LEAF* const leaf) +void tPitchDetector_init(tPitchDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, LEAF* const leaf) { tPitchDetector_initToPool(detector, lowestFreq, highestFreq, &leaf->mempool); } -void tPitchDetector_initToPool (tPitchDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, tMempool* const mempool) +void tPitchDetector_initToPool (tPitchDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, tMempool** const mempool) { - _tMempool* m = *mempool; + tMempool* m = *mempool; tPitchDetector* p = *detector = (tPitchDetector*) mpool_alloc(sizeof(tPitchDetector), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -1795,15 +1793,15 @@ void tPitchDetector_free (tPitchDetector** const detector) int tPitchDetector_tick (tPitchDetector* const p, Lfloat s) { - tPeriodDetector_tick(&p->_pd, s); + tPeriodDetector_tick(p->_pd, s); - if (tPeriodDetector_isReset(&p->_pd)) + if (tPeriodDetector_isReset(p->_pd)) { p->_current.frequency = 0.0f; p->_current.periodicity = 0.0f; } - int ready = tPeriodDetector_isReady(&p->_pd); + int ready = tPeriodDetector_isReady(p->_pd); if (ready) { Lfloat periodicity = p->_pd->_fundamental.periodicity; @@ -1819,7 +1817,7 @@ int tPitchDetector_tick (tPitchDetector* const p, Lfloat s) { if (periodicity >= ONSET_PERIODICITY) { - Lfloat f = calculate_frequency(*p); + Lfloat f = calculate_frequency(p); if (f > 0.0f) { p->_current.frequency = f; @@ -1832,11 +1830,11 @@ int tPitchDetector_tick (tPitchDetector* const p, Lfloat s) { if (periodicity < MIN_PERIODICITY) p->_frames_after_shift = 0; - Lfloat f = calculate_frequency(*p); + Lfloat f = calculate_frequency(p); if (f > 0.0f) { _pitch_info info = { f, periodicity }; - bias(*p, info); + bias(p, info); } } } @@ -1855,12 +1853,12 @@ Lfloat tPitchDetector_getPeriodicity (tPitchDetector* const p) Lfloat tPitchDetector_harmonic (tPitchDetector* const p, int harmonicIndex) { - return tPeriodDetector_harmonic(&p->_pd, harmonicIndex); + return tPeriodDetector_harmonic(p->_pd, harmonicIndex); } Lfloat tPitchDetector_predictFrequency (tPitchDetector* const p) { - Lfloat period = tPeriodDetector_predictPeriod(&p->_pd); + Lfloat period = tPeriodDetector_predictPeriod(p->_pd); if (period > 0.0f) return p->sampleRate / period; return 0.0f; @@ -1873,13 +1871,13 @@ int tPitchDetector_indeterminate (tPitchDetector* const p) void tPitchDetector_setHysteresis (tPitchDetector* const p, Lfloat hysteresis) { - tPeriodDetector_setHysteresis(&p->_pd, hysteresis); + tPeriodDetector_setHysteresis(p->_pd, hysteresis); } void tPitchDetector_setSampleRate (tPitchDetector* const p, Lfloat sr) { p->sampleRate = sr; - tPeriodDetector_setSampleRate(&p->_pd, p->sampleRate); + tPeriodDetector_setSampleRate(p->_pd, p->sampleRate); } static inline Lfloat calculate_frequency(tPitchDetector* const p) @@ -1983,16 +1981,16 @@ static inline void bias(tPitchDetector* const p, _pitch_info incoming) } } -static inline void compute_predicted_frequency(tDualPitchDetector const detector); +static inline void compute_predicted_frequency(tDualPitchDetector* const detector); -void tDualPitchDetector_init (tDualPitchDetector* const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat* inBuffer, int bufSize, LEAF* const leaf) +void tDualPitchDetector_init(tDualPitchDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat* inBuffer, int bufSize, LEAF* const leaf) { tDualPitchDetector_initToPool(detector, lowestFreq, highestFreq, inBuffer, bufSize, &leaf->mempool); } -void tDualPitchDetector_initToPool (tDualPitchDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat* inBuffer, int bufSize, tMempool* const mempool) +void tDualPitchDetector_initToPool (tDualPitchDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat* inBuffer, int bufSize, tMempool** const mempool) { - _tMempool* m = *mempool; + tMempool* m = *mempool; tDualPitchDetector* p = *detector = (tDualPitchDetector*) mpool_alloc(sizeof(tDualPitchDetector), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -2025,19 +2023,19 @@ void tDualPitchDetector_free (tDualPitchDetector** const detector) int tDualPitchDetector_tick (tDualPitchDetector* const p, Lfloat sample) { - tPeriodDetection_tick(&p->_pd1, sample); - int ready = tPitchDetector_tick(&p->_pd2, sample); + tPeriodDetection_tick(p->_pd1, sample); + int ready = tPitchDetector_tick(p->_pd2, sample); if (ready) { - int pd2_indeterminate = tPitchDetector_indeterminate(&p->_pd2); + int pd2_indeterminate = tPitchDetector_indeterminate(p->_pd2); int disagreement = 0; - Lfloat period = tPeriodDetection_getPeriod(&p->_pd1); + Lfloat period = tPeriodDetection_getPeriod(p->_pd1); if (!pd2_indeterminate && period != 0.0f) { _pitch_info _i1; - _i1.frequency = p->sampleRate / tPeriodDetection_getPeriod(&p->_pd1); - _i1.periodicity = tPeriodDetection_getFidelity(&p->_pd1); + _i1.frequency = p->sampleRate / tPeriodDetection_getPeriod(p->_pd1); + _i1.periodicity = tPeriodDetection_getFidelity(p->_pd1); _pitch_info _i2 = p->_pd2->_current; Lfloat pd1_diff = fabsf(_i1.frequency - p->_mean); @@ -2116,13 +2114,13 @@ Lfloat tDualPitchDetector_getPeriodicity (tDualPitchDetector* const p) Lfloat tDualPitchDetector_predictFrequency (tDualPitchDetector* const p) { if (p->_predicted_frequency == 0.0f) - compute_predicted_frequency(*p); + compute_predicted_frequency(p); return p->_predicted_frequency; } void tDualPitchDetector_setHysteresis (tDualPitchDetector* const p, Lfloat hysteresis) { - tPitchDetector_setHysteresis(&p->_pd2, hysteresis); + tPitchDetector_setHysteresis(p->_pd2, hysteresis); } void tDualPitchDetector_setPeriodicityThreshold (tDualPitchDetector* const p, Lfloat thresh) @@ -2133,14 +2131,14 @@ void tDualPitchDetector_setPeriodicityThreshold (tDualPitchDetector* const p, void tDualPitchDetector_setSampleRate (tDualPitchDetector* const p, Lfloat sr) { p->sampleRate = sr; - tPeriodDetection_setSampleRate(&p->_pd1, p->sampleRate); - tPitchDetector_setSampleRate(&p->_pd2, p->sampleRate); + tPeriodDetection_setSampleRate(p->_pd1, p->sampleRate); + tPitchDetector_setSampleRate(p->_pd2, p->sampleRate); } static inline void compute_predicted_frequency(tDualPitchDetector* const p) { - Lfloat f1 = 1.0f / tPeriodDetection_getPeriod(&p->_pd1); - Lfloat f2 = tPitchDetector_predictFrequency(&p->_pd2); + Lfloat f1 = 1.0f / tPeriodDetection_getPeriod(p->_pd1); + Lfloat f2 = tPitchDetector_predictFrequency(p->_pd2); if (f2 > 0.0f) { Lfloat error = f1 * 0.1f; diff --git a/leaf/Src/leaf-delay.c b/leaf/Src/leaf-delay.c index d3e2ee3..d6aa358 100644 --- a/leaf/Src/leaf-delay.c +++ b/leaf/Src/leaf-delay.c @@ -19,14 +19,14 @@ #endif // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Delay ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ // -void tDelay_init (tDelay* const dl, uint32_t delay, uint32_t maxDelay, LEAF* const leaf) +void tDelay_init(tDelay** const dl, uint32_t delay, uint32_t maxDelay, LEAF* const leaf) { tDelay_initToPool(dl, delay, maxDelay, &leaf->mempool); } -void tDelay_initToPool (tDelay** const dl, uint32_t delay, uint32_t maxDelay, tMempool* const mp) +void tDelay_initToPool (tDelay** const dl, uint32_t delay, uint32_t maxDelay, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tDelay* d = *dl = (tDelay*) mpool_alloc(sizeof(tDelay), m); d->mempool = m; @@ -143,14 +143,14 @@ Lfloat tDelay_getGain (tDelay* const d) } // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ LinearDelay ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ // -void tLinearDelay_init (tLinearDelay* const dl, Lfloat delay, uint32_t maxDelay, LEAF* const leaf) +void tLinearDelay_init(tLinearDelay** const dl, Lfloat delay, uint32_t maxDelay, LEAF* const leaf) { tLinearDelay_initToPool(dl, delay, maxDelay, &leaf->mempool); } -void tLinearDelay_initToPool (tLinearDelay** const dl, Lfloat delay, uint32_t maxDelay, tMempool* const mp) +void tLinearDelay_initToPool (tLinearDelay** const dl, Lfloat delay, uint32_t maxDelay, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tLinearDelay* d = *dl = (tLinearDelay*) mpool_alloc(sizeof(tLinearDelay), m); d->mempool = m; @@ -333,14 +333,14 @@ Lfloat tLinearDelay_getGain (tLinearDelay* const d) /// Hermite Interpolated Delay // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ LinearDelay ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ // -void tHermiteDelay_init (tHermiteDelay* const dl, Lfloat delay, uint32_t maxDelay, LEAF* const leaf) +void tHermiteDelay_init(tHermiteDelay** const dl, Lfloat delay, uint32_t maxDelay, LEAF* const leaf) { tHermiteDelay_initToPool(dl, delay, maxDelay, &leaf->mempool); } -void tHermiteDelay_initToPool (tHermiteDelay** const dl, Lfloat delay, uint32_t maxDelay, tMempool* const mp) +void tHermiteDelay_initToPool (tHermiteDelay** const dl, Lfloat delay, uint32_t maxDelay, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tHermiteDelay* d = *dl = (tHermiteDelay*) mpool_alloc(sizeof(tHermiteDelay), m); d->mempool = m; @@ -524,14 +524,14 @@ Lfloat tHermiteDelay_getGain (tHermiteDelay* const d) /// Lagrange Interpolated Delay // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ LinearDelay ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ // -void tLagrangeDelay_init (tLagrangeDelay* const dl, Lfloat delay, uint32_t maxDelay, LEAF* const leaf) +void tLagrangeDelay_init(tLagrangeDelay** const dl, Lfloat delay, uint32_t maxDelay, LEAF* const leaf) { tLagrangeDelay_initToPool(dl, delay, maxDelay, &leaf->mempool); } -void tLagrangeDelay_initToPool (tLagrangeDelay** const dl, Lfloat delay, uint32_t maxDelay, tMempool* const mp) +void tLagrangeDelay_initToPool (tLagrangeDelay** const dl, Lfloat delay, uint32_t maxDelay, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tLagrangeDelay* d = *dl = (tLagrangeDelay*) mpool_alloc(sizeof(tLagrangeDelay), m); d->mempool = m; @@ -741,14 +741,14 @@ Lfloat tLagrangeDelay_getLastIn (tLagrangeDelay* const d) // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ AllpassDelay ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ // -void tAllpassDelay_init (tAllpassDelay* const dl, Lfloat delay, uint32_t maxDelay, LEAF* const leaf) +void tAllpassDelay_init(tAllpassDelay** const dl, Lfloat delay, uint32_t maxDelay, LEAF* const leaf) { tAllpassDelay_initToPool(dl, delay, maxDelay, &leaf->mempool); } -void tAllpassDelay_initToPool (tAllpassDelay** const dl, Lfloat delay, uint32_t maxDelay, tMempool* const mp) +void tAllpassDelay_initToPool (tAllpassDelay** const dl, Lfloat delay, uint32_t maxDelay, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tAllpassDelay* d = *dl = (tAllpassDelay*) mpool_alloc(sizeof(tAllpassDelay), m); d->mempool = m; @@ -898,14 +898,14 @@ Lfloat tAllpassDelay_getGain (tAllpassDelay* const d) } // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ TapeDelay ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ // -void tTapeDelay_init (tTapeDelay* const dl, Lfloat delay, uint32_t maxDelay, LEAF* const leaf) +void tTapeDelay_init(tTapeDelay** const dl, Lfloat delay, uint32_t maxDelay, LEAF* const leaf) { tTapeDelay_initToPool(dl, delay, maxDelay, &leaf->mempool); } -void tTapeDelay_initToPool (tTapeDelay** const dl, Lfloat delay, uint32_t maxDelay, tMempool* const mp) +void tTapeDelay_initToPool (tTapeDelay** const dl, Lfloat delay, uint32_t maxDelay, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tTapeDelay* d = *dl = (tTapeDelay*) mpool_alloc(sizeof(tTapeDelay), m); d->mempool = m; @@ -1060,14 +1060,14 @@ Lfloat tTapeDelay_getGain (tTapeDelay* const d) -void tRingBuffer_init (tRingBuffer* const ring, int size, LEAF* const leaf) +void tRingBuffer_init(tRingBuffer** const ring, int size, LEAF* const leaf) { tRingBuffer_initToPool(ring, size, &leaf->mempool); } -void tRingBuffer_initToPool (tRingBuffer** const ring, int size, tMempool* const mempool) +void tRingBuffer_initToPool (tRingBuffer** const ring, int size, tMempool** const mempool) { - _tMempool* m = *mempool; + tMempool* m = *mempool; tRingBuffer* r = *ring = (tRingBuffer*) mpool_alloc(sizeof(tRingBuffer), m); r->mempool = m; diff --git a/leaf/Src/leaf-distortion.c b/leaf/Src/leaf-distortion.c index b82657f..777828e 100644 --- a/leaf/Src/leaf-distortion.c +++ b/leaf/Src/leaf-distortion.c @@ -28,14 +28,14 @@ // Sample-Rate reducer //============================================================================================================ -void tSampleReducer_init (tSampleReducer* const sr, LEAF* const leaf) +void tSampleReducer_init (tSampleReducer** const sr, LEAF* const leaf) { tSampleReducer_initToPool(sr, &leaf->mempool); } -void tSampleReducer_initToPool (tSampleReducer** const sr, tMempool** const mp) +void tSampleReducer_initToPool (tSampleReducer** const sr, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tSampleReducer* s = *sr = (tSampleReducer*) mpool_alloc(sizeof(tSampleReducer), m); s->mempool = m; @@ -76,14 +76,14 @@ void tSampleReducer_setRatio(tSampleReducer* const s, Lfloat ratio) // Oversampler //============================================================================================================ // Latency is equal to the phase length (numTaps / ratio) -void tOversampler_init (tOversampler* const osr, int ratio, int extraQuality, LEAF* const leaf) +void tOversampler_init(tOversampler** const osr, int ratio, int extraQuality, LEAF* const leaf) { tOversampler_initToPool(osr, ratio, extraQuality, &leaf->mempool); } -void tOversampler_initToPool (tOversampler** const osr, int maxRatio, int extraQuality, tMempool* const mp) +void tOversampler_initToPool (tOversampler** const osr, int maxRatio, int extraQuality, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; int offset = 0; if (extraQuality) offset = 6; if (maxRatio == 2 || maxRatio == 4 || maxRatio == 8 || @@ -356,14 +356,14 @@ int tOversampler_getLatency(tOversampler* const os) // SIMPLER WAVEFOLDER //============================================================================================================ -void tWavefolder_init (tWavefolder* const wf, Lfloat ffAmount, Lfloat fbAmount, Lfloat foldDepth, LEAF* const leaf) +void tWavefolder_init(tWavefolder** const wf, Lfloat ffAmount, Lfloat fbAmount, Lfloat foldDepth, LEAF* const leaf) { tWavefolder_initToPool (wf, ffAmount, fbAmount, foldDepth, &leaf->mempool); } -void tWavefolder_initToPool (tWavefolder** const wf, Lfloat ffAmount, Lfloat fbAmount, Lfloat foldDepth, tMempool* const mp) +void tWavefolder_initToPool (tWavefolder** const wf, Lfloat ffAmount, Lfloat fbAmount, Lfloat foldDepth, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tWavefolder* w = *wf = (tWavefolder*) mpool_alloc(sizeof(tWavefolder), m); w->mempool = m; tHighpass_initToPool(&w->dcBlock, 1.0f, mp); @@ -450,7 +450,7 @@ Lfloat tWavefolder_tick(tWavefolder* const w, Lfloat in) #endif w->FBsample = (ff + fb) - w->foldDepth * tempVal; sample = w->FBsample * w->invFBAmount; - sample = tHighpass_tick(&w->dcBlock, sample); + sample = tHighpass_tick(w->dcBlock, sample); return sample; } @@ -462,14 +462,14 @@ Lfloat tWavefolder_tick(tWavefolder* const w, Lfloat in) //from the paper: Virtual Analog Model of the Lockhart Wavefolder //by Fabián Esqueda, Henri Pöntynen, Julian D. Parker and Stefan Bilbao -void tLockhartWavefolder_init (tLockhartWavefolder* const wf, LEAF* const leaf) +void tLockhartWavefolder_init(tLockhartWavefolder** const wf, LEAF* const leaf) { tLockhartWavefolder_initToPool (wf, &leaf->mempool); } -void tLockhartWavefolder_initToPool (tLockhartWavefolder** const wf, tMempool* const mp) +void tLockhartWavefolder_initToPool (tLockhartWavefolder** const wf, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tLockhartWavefolder* w = *wf = (tLockhartWavefolder*) mpool_alloc(sizeof(tLockhartWavefolder), m); w->mempool = m; @@ -713,14 +713,14 @@ Lfloat tLockhartWavefolder_tick(tLockhartWavefolder* const w, Lfloat in) #define SCALAR 5000.f #define INV_SCALAR 0.0002f -void tCrusher_init (tCrusher* const cr, LEAF* const leaf) +void tCrusher_init(tCrusher** const cr, LEAF* const leaf) { tCrusher_initToPool(cr, &leaf->mempool); } -void tCrusher_initToPool (tCrusher** const cr, tMempool* const mp) +void tCrusher_initToPool (tCrusher** const cr, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tCrusher* c = *cr = (tCrusher*) mpool_alloc(sizeof(tCrusher), m); c->mempool = m; @@ -756,7 +756,7 @@ Lfloat tCrusher_tick (tCrusher* const c, Lfloat input) sample = LEAF_round(sample, c->rnd); - sample = tSampleReducer_tick(&c->sReducer, sample); + sample = tSampleReducer_tick(c->sReducer, sample); return sample * c->gain; @@ -786,5 +786,5 @@ void tCrusher_setRound (tCrusher* const c, Lfloat rnd) void tCrusher_setSamplingRatio (tCrusher* const c, Lfloat ratio) { c->srr = ratio; - tSampleReducer_setRatio(&c->sReducer, ratio); + tSampleReducer_setRatio(c->sReducer, ratio); } diff --git a/leaf/Src/leaf-dynamics.c b/leaf/Src/leaf-dynamics.c index 8c7465c..dd45f5b 100644 --- a/leaf/Src/leaf-dynamics.c +++ b/leaf/Src/leaf-dynamics.c @@ -46,9 +46,9 @@ void tCompressor_init (tCompressor** const comp, LEAF* const leaf) tCompressor_initToPool(comp, &leaf->mempool); } -void tCompressor_initToPool (tCompressor** const comp, tMempool* const mp) +void tCompressor_initToPool (tCompressor** const comp, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tCompressor* c = *comp = (tCompressor*) mpool_alloc(sizeof(tCompressor), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -76,9 +76,9 @@ void tCompressor_initToPool (tCompressor** const comp, tMempool* const mp) } -void tCompressor_free (tCompressor* const comp) +void tCompressor_free (tCompressor** const comp) { - tCompressor* c = &*comp; + tCompressor* c = *comp; mpool_free((char*)c, c->mempool); } @@ -265,14 +265,14 @@ void tCompressor_setSampleRate(tCompressor* const c, Lfloat sampleRate) } /* Feedback Leveler */ -void tFeedbackLeveler_init (tFeedbackLeveler* const fb, Lfloat targetLevel, Lfloat factor, Lfloat strength, int mode, LEAF* const leaf) +void tFeedbackLeveler_init (tFeedbackLeveler** const fb, Lfloat targetLevel, Lfloat factor, Lfloat strength, int mode, LEAF* const leaf) { tFeedbackLeveler_initToPool(fb, targetLevel, factor, strength, mode, &leaf->mempool); } -void tFeedbackLeveler_initToPool (tFeedbackLeveler** const fb, Lfloat targetLevel, Lfloat factor, Lfloat strength, int mode, tMempool* const mp) +void tFeedbackLeveler_initToPool (tFeedbackLeveler** const fb, Lfloat targetLevel, Lfloat factor, Lfloat strength, int mode, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tFeedbackLeveler* p = *fb = (tFeedbackLeveler*) mpool_alloc(sizeof(tFeedbackLeveler), m); p->mempool = m; @@ -299,7 +299,7 @@ void tFeedbackLeveler_setStrength(tFeedbackLeveler* const p, Lfloat strength void tFeedbackLeveler_setFactor(tFeedbackLeveler* const p, Lfloat factor) { - tPowerFollower_setFactor(&p->pwrFlw,factor); + tPowerFollower_setFactor(p->pwrFlw,factor); } void tFeedbackLeveler_setMode(tFeedbackLeveler* const p, int mode) @@ -309,7 +309,7 @@ void tFeedbackLeveler_setMode(tFeedbackLeveler* const p, int mode) Lfloat tFeedbackLeveler_tick(tFeedbackLeveler* const p, Lfloat input) { - Lfloat levdiff=(tPowerFollower_tick(&p->pwrFlw, input)-p->targetLevel); + Lfloat levdiff=(tPowerFollower_tick(p->pwrFlw, input)-p->targetLevel); if (p->mode==0 && levdiff<0.0f) levdiff=0.0f; p->curr=input*(1.0f-p->strength*levdiff); return p->curr; @@ -327,14 +327,14 @@ void tFeedbackLeveler_setTargetLevel (tFeedbackLeveler* const p, Lfloat Ta } -void tThreshold_init (tThreshold* const th, Lfloat low, Lfloat high, LEAF* const leaf) +void tThreshold_init (tThreshold** const th, Lfloat low, Lfloat high, LEAF* const leaf) { tThreshold_initToPool(th, low, high, &leaf->mempool); } -void tThreshold_initToPool (tThreshold** const th, Lfloat low, Lfloat high, tMempool* const mp) +void tThreshold_initToPool (tThreshold** const th, Lfloat low, Lfloat high, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tThreshold* t = *th = (tThreshold*) mpool_alloc(sizeof(tThreshold), m); t->mempool = m; diff --git a/leaf/Src/leaf-effects.c b/leaf/Src/leaf-effects.c index dafd021..61efbda 100644 --- a/leaf/Src/leaf-effects.c +++ b/leaf/Src/leaf-effects.c @@ -32,14 +32,14 @@ // -JS -void tTalkbox_init (tTalkbox* const voc, int bufsize, LEAF* const leaf) +void tTalkbox_init(tTalkbox** const voc, int bufsize, LEAF* const leaf) { tTalkbox_initToPool(voc, bufsize, &leaf->mempool); } -void tTalkbox_initToPool (tTalkbox** const voc, int bufsize, tMempool* const mp) +void tTalkbox_initToPool (tTalkbox** const voc, int bufsize, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tTalkbox* v = *voc = (tTalkbox*) mpool_alloc(sizeof(tTalkbox), m); v->mempool = m; LEAF* leaf = v->mempool->leaf; @@ -70,9 +70,9 @@ void tTalkbox_initToPool (tTalkbox** const voc, int bufsize, tMempool* const mp) tTalkbox_suspend(v); } -void tTalkbox_free (tTalkbox* const voc) +void tTalkbox_free(tTalkbox** const voc) { - tTalkbox* v = &*voc; + tTalkbox* v = *voc; mpool_free((char*)v->buf1, v->mempool); mpool_free((char*)v->buf0, v->mempool); @@ -137,7 +137,7 @@ void tTalkbox_suspend(tTalkbox* const v) ///clear any buffers... // warped autocorrelation adapted from ten.enegatum@liam's post on music-dsp 2004-04-07 09:37:51 //find the order-P autocorrelation array, R, for the sequence x of length L and warping of lambda -//wAutocorrelate(&pfSrc[stIndex],siglen,R,P,0); +//wAutocorrelate(pfSrc[stIndex],siglen,R,P,0); void tTalkbox_warpedAutocorrelate(Lfloat * x, double* dl, double* Rt, unsigned int L, Lfloat * R, unsigned int P, Lfloat lambda) { double r1,r2,r1t; @@ -355,14 +355,14 @@ void tTalkbox_setSampleRate(tTalkbox* const v, Lfloat sr) // -JS -void tTalkboxLfloat_init (tTalkboxLfloat* const voc, int bufsize, LEAF* const leaf) +void tTalkboxLfloat_init(tTalkboxLfloat** const voc, int bufsize, LEAF* const leaf) { tTalkboxLfloat_initToPool(voc, bufsize, &leaf->mempool); } -void tTalkboxLfloat_initToPool (tTalkboxLfloat** const voc, int bufsize, tMempool* const mp) +void tTalkboxLfloat_initToPool (tTalkboxLfloat** const voc, int bufsize, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tTalkboxLfloat* v = *voc = (tTalkboxLfloat*) mpool_alloc(sizeof(tTalkboxLfloat), m); v->mempool = m; LEAF* leaf = v->mempool->leaf; @@ -389,8 +389,8 @@ void tTalkboxLfloat_initToPool (tTalkboxLfloat** const voc, int bufsize, tMempoo v->sampleRate = leaf->sampleRate; - tTalkboxLfloat_update(&*voc); - tTalkboxLfloat_suspend(&*voc); + tTalkboxLfloat_update(*voc); + tTalkboxLfloat_suspend(*voc); } void tTalkboxLfloat_free (tTalkboxLfloat** const voc) @@ -460,7 +460,7 @@ void tTalkboxLfloat_suspend(tTalkboxLfloat* const v) ///clear any buffers... // warped autocorrelation adapted from ten.enegatum@liam's post on music-dsp 2004-04-07 09:37:51 //find the order-P autocorrelation array, R, for the sequence x of length L and warping of lambda -//wAutocorrelate(&pfSrc[stIndex],siglen,R,P,0); +//wAutocorrelate(pfSrc[stIndex],siglen,R,P,0); void tTalkboxLfloat_warpedAutocorrelate(Lfloat * x, Lfloat* dl, Lfloat* Rt, unsigned int L, Lfloat * R, unsigned int P, Lfloat lambda) { Lfloat r1,r2,r1t; @@ -675,14 +675,14 @@ void tTalkboxLfloat_setSampleRate(tTalkboxLfloat* const v, Lfloat sr) // VOCODER //============================================================================================================ -void tVocoder_init (tVocoder* const voc, LEAF* const leaf) +void tVocoder_init(tVocoder** const voc, LEAF* const leaf) { tVocoder_initToPool(voc, &leaf->mempool); } -void tVocoder_initToPool (tVocoder** const voc, tMempool* const mp) +void tVocoder_initToPool (tVocoder** const voc, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tVocoder* v = *voc = (tVocoder*) mpool_alloc(sizeof(tVocoder), m); v->mempool = m; LEAF* leaf = v->mempool->leaf; @@ -872,14 +872,14 @@ void tVocoder_setSampleRate (tVocoder* const v, Lfloat sr) /// Glottal Pulse (Rosenberg model) -void tRosenbergGlottalPulse_init (tRosenbergGlottalPulse* const gp, LEAF* const leaf) +void tRosenbergGlottalPulse_init(tRosenbergGlottalPulse** const gp, LEAF* const leaf) { tRosenbergGlottalPulse_initToPool(gp, &leaf->mempool); } -void tRosenbergGlottalPulse_initToPool (tRosenbergGlottalPulse** const gp, tMempool* const mp) +void tRosenbergGlottalPulse_initToPool (tRosenbergGlottalPulse** const gp, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tRosenbergGlottalPulse* g = *gp = (tRosenbergGlottalPulse*) mpool_alloc(sizeof(tRosenbergGlottalPulse), m); g->mempool = m; LEAF* leaf = g->mempool->leaf; @@ -1001,14 +1001,14 @@ static void pitchup(tSOLAD *w, Lfloat *out); /******************************************************************************/ // init -void tSOLAD_init (tSOLAD* const wp, int loopSize, LEAF* const leaf) +void tSOLAD_init(tSOLAD** const wp, int loopSize, LEAF* const leaf) { tSOLAD_initToPool(wp, loopSize, &leaf->mempool); } -void tSOLAD_initToPool (tSOLAD** const wp, int loopSize, tMempool* const mp) +void tSOLAD_initToPool (tSOLAD** const wp, int loopSize, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tSOLAD* w = *wp = (tSOLAD*) mpool_calloc(sizeof(tSOLAD), m); w->mempool = m; @@ -1044,17 +1044,17 @@ void tSOLAD_ioSamples(tSOLAD* const w, Lfloat* in, Lfloat* out, int blocksize) if(!i) { - Lfloat sample = tHighpass_tick(&w->hp, in[0]); + Lfloat sample = tHighpass_tick(w->hp, in[0]); w->delaybuf[0] = sample; w->delaybuf[w->loopSize] = sample; // copy one sample for interpolation n--; i++; in++; } - while(n--) w->delaybuf[i++] = tHighpass_tick(&w->hp, *in++); // copy one input block to delay buffer + while(n--) w->delaybuf[i++] = tHighpass_tick(w->hp, *in++); // copy one input block to delay buffer - tAttackDetection_setBlocksize(&w->ad, n); - if (tAttackDetection_detect(&w->ad, in)) + tAttackDetection_setBlocksize(w->ad, n); + if (tAttackDetection_detect(w->ad, in)) { tSOLAD_setReadLag(w, w->blocksize); } @@ -1114,8 +1114,8 @@ void tSOLAD_resetState(tSOLAD* const w) void tSOLAD_setSampleRate(tSOLAD* const w, Lfloat sr) { - tAttackDetection_setSampleRate(&w->ad, sr); - tHighpass_setSampleRate(&w->hp, sr); + tAttackDetection_setSampleRate(w->ad, sr); + tHighpass_setSampleRate(w->hp, sr); } /******************************************************************************/ @@ -1348,14 +1348,14 @@ static inline Lfloat read_sample(tSOLAD* const w, Lfloat Lfloatindex) // PITCHSHIFT //============================================================================================================ -void tPitchShift_init (tPitchShift* const psr, tDualPitchDetector* const dpd, int bufSize, LEAF* const leaf) +void tPitchShift_init(tPitchShift** const psr, tDualPitchDetector** const dpd, int bufSize, LEAF* const leaf) { tPitchShift_initToPool(psr, dpd, bufSize, &leaf->mempool); } -void tPitchShift_initToPool (tPitchShift** const psr, tDualPitchDetector* const dpd, int bufSize, tMempool* const mp) +void tPitchShift_initToPool (tPitchShift** const psr, tDualPitchDetector** const dpd, int bufSize, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tPitchShift* ps = *psr = (tPitchShift*) mpool_alloc(sizeof(tPitchShift), m); ps->mempool = m; LEAF* leaf = ps->mempool->leaf; @@ -1367,7 +1367,7 @@ void tPitchShift_initToPool (tPitchShift** const psr, tDualPitchDetector* const ps->sampleRate = leaf->sampleRate; tSOLAD_initToPool(&ps->sola, pow(2.0, ceil(log2(ps->bufSize * 2.0))), mp); - tSOLAD_setPitchFactor(&ps->sola, DEFPITCHRATIO); + tSOLAD_setPitchFactor(ps->sola, DEFPITCHRATIO); } void tPitchShift_free (tPitchShift** const psr) @@ -1380,31 +1380,31 @@ void tPitchShift_free (tPitchShift** const psr) void tPitchShift_shiftBy (tPitchShift* const ps, Lfloat factor, Lfloat* in, Lfloat* out) { - Lfloat detected = tDualPitchDetector_getFrequency(&ps->pd); - Lfloat periodicity = tDualPitchDetector_getPeriodicity(&ps->pd); + Lfloat detected = tDualPitchDetector_getFrequency(ps->pd); + Lfloat periodicity = tDualPitchDetector_getPeriodicity(ps->pd); if (detected > 0.0f && periodicity > ps->pickiness) { Lfloat period = ps->sampleRate / detected; - tSOLAD_setPeriod(&ps->sola, period); - tSOLAD_setPitchFactor(&ps->sola, factor); + tSOLAD_setPeriod(ps->sola, period); + tSOLAD_setPitchFactor(ps->sola, factor); } - tSOLAD_ioSamples(&ps->sola, in, out, ps->bufSize); + tSOLAD_ioSamples(ps->sola, in, out, ps->bufSize); } void tPitchShift_shiftTo (tPitchShift* const ps, Lfloat freq, Lfloat* in, Lfloat* out) { - Lfloat detected = tDualPitchDetector_getFrequency(&ps->pd); - Lfloat periodicity = tDualPitchDetector_getPeriodicity(&ps->pd); + Lfloat detected = tDualPitchDetector_getFrequency(ps->pd); + Lfloat periodicity = tDualPitchDetector_getPeriodicity(ps->pd); if (detected > 0.0f && periodicity > ps->pickiness) { Lfloat period = 1.0f / detected; Lfloat factor = freq * period; - tSOLAD_setPeriod(&ps->sola, ps->sampleRate * period); - tSOLAD_setPitchFactor(&ps->sola, factor); + tSOLAD_setPeriod(ps->sola, ps->sampleRate * period); + tSOLAD_setPitchFactor(ps->sola, factor); } - tSOLAD_ioSamples(&ps->sola, in, out, ps->bufSize); + tSOLAD_ioSamples(ps->sola, in, out, ps->bufSize); } void tPitchShift_setPickiness (tPitchShift* const ps, Lfloat p) @@ -1414,7 +1414,7 @@ void tPitchShift_setPickiness (tPitchShift* const ps, Lfloat p) void tPitchShift_setSampleRate(tPitchShift* const ps, Lfloat sr) { - tSOLAD_setSampleRate(&ps->sola, sr); + tSOLAD_setSampleRate(ps->sola, sr); } @@ -1422,14 +1422,14 @@ void tPitchShift_setSampleRate(tPitchShift* const ps, Lfloat sr) // SIMPLERETUNE //============================================================================================================ -void tSimpleRetune_init (tSimpleRetune* const rt, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, LEAF* const leaf) +void tSimpleRetune_init(tSimpleRetune** const rt, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, LEAF* const leaf) { tSimpleRetune_initToPool(rt, numVoices, minInputFreq, maxInputFreq, bufSize, &leaf->mempool); } -void tSimpleRetune_initToPool (tSimpleRetune** const rt, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, tMempool* const mp) +void tSimpleRetune_initToPool (tSimpleRetune** const rt, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tSimpleRetune* r = *rt = (tSimpleRetune*) mpool_calloc(sizeof(tSimpleRetune), m); r->mempool = *mp; @@ -1442,7 +1442,7 @@ void tSimpleRetune_initToPool (tSimpleRetune** const rt, int numVoices, Lfloat m r->index = 0; - r->ps = (tPitchShift*) mpool_calloc(sizeof(tPitchShift) * r->numVoices, m); + r->ps = (tPitchShift**) mpool_calloc(sizeof(tPitchShift*) * r->numVoices, m); r->shiftValues = (Lfloat*) mpool_calloc(sizeof(Lfloat) * r->numVoices, m); r->minInputFreq = minInputFreq; @@ -1476,7 +1476,7 @@ void tSimpleRetune_free (tSimpleRetune** const rt) Lfloat tSimpleRetune_tick(tSimpleRetune* const r, Lfloat sample) { - tDualPitchDetector_tick(&r->dp, sample); + tDualPitchDetector_tick(r->dp, sample); r->inBuffer[r->index] = sample; Lfloat out = r->outBuffer[r->index]; @@ -1507,7 +1507,7 @@ void tSimpleRetune_setNumVoices(tSimpleRetune* const r, int numVoices) int bufSize = r->bufSize; Lfloat minInputFreq = r->minInputFreq; Lfloat maxInputFreq = r->maxInputFreq; - tMempool mempool = r->mempool; + tMempool* mempool = r->mempool; /************ FIX HERE *************/ //tSimpleRetune_free(r); @@ -1518,7 +1518,7 @@ void tSimpleRetune_setPickiness (tSimpleRetune* const r, Lfloat p) { for (int i = 0; i < r->numVoices; ++i) { - tPitchShift_setPickiness(&r->ps[i], p); + tPitchShift_setPickiness(r->ps[i], p); } } @@ -1537,15 +1537,15 @@ void tSimpleRetune_tuneVoice(tSimpleRetune* const r, int voice, Lfloat t) Lfloat tSimpleRetune_getInputFrequency (tSimpleRetune* const r) { - return tDualPitchDetector_getFrequency(&r->dp); + return tDualPitchDetector_getFrequency(r->dp); } void tSimpleRetune_setSampleRate (tSimpleRetune* const r, Lfloat sr) { - tDualPitchDetector_setSampleRate(&r->dp, sr); + tDualPitchDetector_setSampleRate(r->dp, sr); for (int i = 0; i < r->numVoices; ++i) { - tPitchShift_setSampleRate(&r->ps[i], sr); + tPitchShift_setSampleRate(r->ps[i], sr); } } @@ -1553,14 +1553,14 @@ void tSimpleRetune_setSampleRate (tSimpleRetune* const r, Lfloat sr) // RETUNE //============================================================================================================ -void tRetune_init(tRetune* const rt, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, LEAF* const leaf) +void tRetune_init(tRetune** const rt, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, LEAF* const leaf) { tRetune_initToPool(rt, numVoices, minInputFreq, maxInputFreq, bufSize, &leaf->mempool); } -void tRetune_initToPool (tRetune** const rt, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, tMempool* const mp) +void tRetune_initToPool (tRetune** const rt, int numVoices, Lfloat minInputFreq, Lfloat maxInputFreq, int bufSize, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tRetune* r = *rt = (tRetune*) mpool_calloc(sizeof(tRetune), m); r->mempool = *mp; @@ -1572,7 +1572,7 @@ void tRetune_initToPool (tRetune** const rt, int numVoices, Lfloat minInputFreq, r->index = 0; - r->ps = (tPitchShift*) mpool_calloc(sizeof(tPitchShift) * r->numVoices, m); + r->ps = (tPitchShift**) mpool_calloc(sizeof(tPitchShift*) * r->numVoices, m); r->shiftValues = (Lfloat*) mpool_calloc(sizeof(Lfloat) * r->numVoices, m); r->outBuffers = (Lfloat**) mpool_calloc(sizeof(Lfloat*) * r->numVoices, m); r->output = (Lfloat*) mpool_calloc(sizeof(Lfloat) * r->numVoices, m); @@ -1611,7 +1611,7 @@ void tRetune_free (tRetune** const rt) Lfloat* tRetune_tick(tRetune* const r, Lfloat sample) { - tDualPitchDetector_tick(&*r->dp, sample); + tDualPitchDetector_tick(*r->dp, sample); r->inBuffer[r->index] = sample; for (int i = 0; i < r->numVoices; ++i) @@ -1641,7 +1641,7 @@ void tRetune_setMode (tRetune* const r, int mode) void tRetune_setPickiness (tRetune* const r, Lfloat p) { - tDualPitchDetector_setPeriodicityThreshold(&*r->dp, p); + tDualPitchDetector_setPeriodicityThreshold(*r->dp, p); } //currently broken void tRetune_setNumVoices(tRetune* const r, int numVoices) @@ -1649,7 +1649,7 @@ void tRetune_setNumVoices(tRetune* const r, int numVoices) int bufSize = r->bufSize; Lfloat minInputFreq = r->minInputFreq; Lfloat maxInputFreq = r->maxInputFreq; - tMempool mempool = r->mempool; + tMempool* mempool = r->mempool; /******* FIX HERE ********/ //tRetune_free(r); @@ -1669,12 +1669,12 @@ void tRetune_tuneVoice(tRetune* const r, int voice, Lfloat t) r->shiftValues[voice] = t; } -Lfloat tRetune_getInputFrequency (tRetune const r) +Lfloat tRetune_getInputFrequency (tRetune* const r) { return tDualPitchDetector_getFrequency(*r->dp); } -void tRetune_setSampleRate(tRetune const r, Lfloat sr) +void tRetune_setSampleRate(tRetune* const r, Lfloat sr) { tDualPitchDetector_setSampleRate(*r->dp, sr); for (int i = 0; i < r->numVoices; ++i) @@ -1688,14 +1688,14 @@ void tRetune_setSampleRate(tRetune const r, Lfloat sr) //============================================================================================================ // algorithm from Tom Baran's autotalent code. -void tFormantShifter_init (tFormantShifter* const fsr, int order, LEAF* const leaf) +void tFormantShifter_init(tFormantShifter** const fsr, int order, LEAF* const leaf) { tFormantShifter_initToPool(fsr, order, &leaf->mempool); } -void tFormantShifter_initToPool (tFormantShifter** const fsr, int order, tMempool* const mp) +void tFormantShifter_initToPool (tFormantShifter** const fsr, int order, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tFormantShifter* fs = *fsr = (tFormantShifter*) mpool_alloc(sizeof(tFormantShifter), m); fs->mempool = m; @@ -1759,8 +1759,8 @@ Lfloat tFormantShifter_tick(tFormantShifter* const fsr, Lfloat in) Lfloat tFormantShifter_remove(tFormantShifter* const fs, Lfloat in) { - in = tFeedbackLeveler_tick(&fs->fbl1, in); - in = tHighpass_tick(&fs->hp, in * fs->intensity); + in = tFeedbackLeveler_tick(fs->fbl1, in); + in = tHighpass_tick(fs->hp, in * fs->intensity); Lfloat fa, fb, fc, foma, falph, ford, flamb, tf, fk; @@ -1884,8 +1884,8 @@ Lfloat tFormantShifter_add(tFormantShifter* const fs, Lfloat in) fs->fmute = (1.0f-tf2) + tf2*fs->fmute; // now tf is signal output // ...and we're done messing with formants - //tf = tFeedbackLeveler_tick(&fs->fbl2, tf); - tf = tHighpass_tick(&fs->hp2, tanhf(tf)); + //tf = tFeedbackLeveler_tick(fs->fbl2, tf); + tf = tHighpass_tick(fs->hp2, tanhf(tf)); return tf * fs->invIntensity; } @@ -1900,8 +1900,8 @@ void tFormantShifter_setIntensity(tFormantShifter* const fs, Lfloat intensity) { fs->intensity = LEAF_clip(1.0f, intensity, 100.0f); - // tFeedbackLeveler_setTargetLevel(&fs->fbl1, fs->intensity); - //tFeedbackLeveler_setTargetLevel(&fs->fbl2, fs->intensity); + // tFeedbackLeveler_setTargetLevel(fs->fbl1, fs->intensity); + //tFeedbackLeveler_setTargetLevel(fs->fbl2, fs->intensity); //make sure you don't divide by zero, doofies if (fs->intensity != 0.0f) { @@ -1921,6 +1921,6 @@ void tFormantShifter_setSampleRate(tFormantShifter* const fs, Lfloat sr) fs->flamb = -(0.8517f*sqrtf(atanf(0.06583f * fs->sampleRate)) - 0.1916f); fs->flpa = powf(0.001f, 10.0f * fs->invSampleRate); fs->fmutealph = powf(0.001f, 1.0f * fs->invSampleRate); - tHighpass_setSampleRate(&fs->hp, fs->sampleRate); - tHighpass_setSampleRate(&fs->hp2, fs->sampleRate); + tHighpass_setSampleRate(fs->hp, fs->sampleRate); + tHighpass_setSampleRate(fs->hp2, fs->sampleRate); } diff --git a/leaf/Src/leaf-electrical.c b/leaf/Src/leaf-electrical.c index f21acd9..3e2f02d 100644 --- a/leaf/Src/leaf-electrical.c +++ b/leaf/Src/leaf-electrical.c @@ -21,35 +21,35 @@ //this got messed up in the switch of the pointer styles. Likely not working at all right now. -JS //============================================================================== -static Lfloat get_port_resistance_for_resistor (tWDF const r); -static Lfloat get_port_resistance_for_capacitor (tWDF const r); -static Lfloat get_port_resistance_for_inductor (tWDF const r); -static Lfloat get_port_resistance_for_resistive (tWDF const r); -static Lfloat get_port_resistance_for_inverter (tWDF const r); -static Lfloat get_port_resistance_for_series (tWDF const r); -static Lfloat get_port_resistance_for_parallel (tWDF const r); -static Lfloat get_port_resistance_for_root (tWDF const r); - -static void set_incident_wave_for_leaf (tWDF const r, Lfloat incident_wave, Lfloat input); -static void set_incident_wave_for_leaf_inverted (tWDF const r, Lfloat incident_wave, Lfloat input); -static void set_incident_wave_for_inverter (tWDF const r, Lfloat incident_wave, Lfloat input); -static void set_incident_wave_for_series (tWDF const r, Lfloat incident_wave, Lfloat input); -static void set_incident_wave_for_parallel (tWDF const r, Lfloat incident_wave, Lfloat input); - -static Lfloat get_reflected_wave_for_resistor (tWDF const r, Lfloat input); -static Lfloat get_reflected_wave_for_capacitor (tWDF const r, Lfloat input); -static Lfloat get_reflected_wave_for_resistive (tWDF const r, Lfloat input); -static Lfloat get_reflected_wave_for_inverter (tWDF const r, Lfloat input); -static Lfloat get_reflected_wave_for_series (tWDF const r, Lfloat input); -static Lfloat get_reflected_wave_for_parallel (tWDF const r, Lfloat input); - -static Lfloat get_reflected_wave_for_ideal (tWDF const n, Lfloat input, Lfloat incident_wave); -static Lfloat get_reflected_wave_for_diode (tWDF const n, Lfloat input, Lfloat incident_wave); -static Lfloat get_reflected_wave_for_diode_pair (tWDF const n, Lfloat input, Lfloat incident_wave); - -static void wdf_init(tWDF* const wdf, WDFComponentType type, Lfloat value, tWDF* const rL, tWDF* const rR) -{ - tWDF* r = &*wdf; +static Lfloat get_port_resistance_for_resistor (tWDF* const r); +static Lfloat get_port_resistance_for_capacitor (tWDF* const r); +static Lfloat get_port_resistance_for_inductor (tWDF* const r); +static Lfloat get_port_resistance_for_resistive (tWDF* const r); +static Lfloat get_port_resistance_for_inverter (tWDF* const r); +static Lfloat get_port_resistance_for_series (tWDF* const r); +static Lfloat get_port_resistance_for_parallel (tWDF* const r); +static Lfloat get_port_resistance_for_root (tWDF* const r); + +static void set_incident_wave_for_leaf (tWDF* const r, Lfloat incident_wave, Lfloat input); +static void set_incident_wave_for_leaf_inverted (tWDF* const r, Lfloat incident_wave, Lfloat input); +static void set_incident_wave_for_inverter (tWDF* const r, Lfloat incident_wave, Lfloat input); +static void set_incident_wave_for_series (tWDF* const r, Lfloat incident_wave, Lfloat input); +static void set_incident_wave_for_parallel (tWDF* const r, Lfloat incident_wave, Lfloat input); + +static Lfloat get_reflected_wave_for_resistor (tWDF* const r, Lfloat input); +static Lfloat get_reflected_wave_for_capacitor (tWDF* const r, Lfloat input); +static Lfloat get_reflected_wave_for_resistive (tWDF* const r, Lfloat input); +static Lfloat get_reflected_wave_for_inverter (tWDF* const r, Lfloat input); +static Lfloat get_reflected_wave_for_series (tWDF* const r, Lfloat input); +static Lfloat get_reflected_wave_for_parallel (tWDF* const r, Lfloat input); + +static Lfloat get_reflected_wave_for_ideal (tWDF* const n, Lfloat input, Lfloat incident_wave); +static Lfloat get_reflected_wave_for_diode (tWDF* const n, Lfloat input, Lfloat incident_wave); +static Lfloat get_reflected_wave_for_diode_pair (tWDF* const n, Lfloat input, Lfloat incident_wave); + +static void wdf_init(tWDF** const wdf, WDFComponentType type, Lfloat value, tWDF** const rL, tWDF** const rR) +{ + tWDF* r = *wdf; LEAF* leaf = r->mempool->leaf; r->type = type; @@ -65,8 +65,8 @@ static void wdf_init(tWDF* const wdf, WDFComponentType type, Lfloat value, tWDF* r->value = value; tWDF* child; - if (&r->child_left != NULL) child = &r->child_left; - else child = &r->child_right; + if (r->child_left != NULL) child = r->child_left; + else child = r->child_right; if (r->type == Resistor) { @@ -143,7 +143,7 @@ static void wdf_init(tWDF* const wdf, WDFComponentType type, Lfloat value, tWDF* } else if (r->type == IdealSource) { - r->port_resistance_up = tWDF_getPortResistance(*child); + r->port_resistance_up = tWDF_getPortResistance(child); r->port_conductance_up = 1.0f / r->port_resistance_up; r->get_reflected_wave_down = &get_reflected_wave_for_ideal; @@ -151,7 +151,7 @@ static void wdf_init(tWDF* const wdf, WDFComponentType type, Lfloat value, tWDF* } else if (r->type == Diode) { - r->port_resistance_up = tWDF_getPortResistance(*child); + r->port_resistance_up = tWDF_getPortResistance(child); r->port_conductance_up = 1.0f / r->port_resistance_up; r->get_reflected_wave_down = &get_reflected_wave_for_diode; @@ -159,7 +159,7 @@ static void wdf_init(tWDF* const wdf, WDFComponentType type, Lfloat value, tWDF* } else if (r->type == DiodePair) { - r->port_resistance_up = tWDF_getPortResistance(*child); + r->port_resistance_up = tWDF_getPortResistance(child); r->port_conductance_up = 1.0f / r->port_resistance_up; r->get_reflected_wave_down = &get_reflected_wave_for_diode_pair; @@ -167,14 +167,14 @@ static void wdf_init(tWDF* const wdf, WDFComponentType type, Lfloat value, tWDF* } } //WDF -void tWDF_init(tWDF* const wdf, WDFComponentType type, Lfloat value, tWDF* const rL, tWDF* const rR, LEAF* const leaf) +void tWDF_init(tWDF** const wdf, WDFComponentType type, Lfloat value, tWDF** const rL, tWDF** const rR, LEAF* const leaf) { tWDF_initToPool(wdf, type, value, rL, rR, &leaf->mempool); } -void tWDF_initToPool(tWDF** const wdf, WDFComponentType type, Lfloat value, tWDF* const rL, tWDF* const rR, tMempool* const mp) +void tWDF_initToPool(tWDF** const wdf, WDFComponentType type, Lfloat value, tWDF** const rL, tWDF** const rR, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; *wdf = (tWDF*) mpool_alloc(sizeof(tWDF), m); wdf_init(wdf, type, value, rL, rR); @@ -190,26 +190,26 @@ void tWDF_free (tWDF** const wdf) Lfloat tWDF_tick(tWDF* const r, Lfloat sample, tWDF* const outputPoint, uint8_t paramsChanged) { tWDF* child; - if (r->child_left != NULL) child = &r->child_left; - else child = &r->child_right; + if (r->child_left != NULL) child = r->child_left; + else child = r->child_right; //step 0 : update port resistances if something changed - if (paramsChanged) tWDF_getPortResistance(*r); + if (paramsChanged) tWDF_getPortResistance(r); //step 1 : set inputs to what they should be Lfloat input = sample; //step 2 : scan the waves up the tree - r->incident_wave_up = tWDF_getReflectedWaveUp(*child, input); + r->incident_wave_up = tWDF_getReflectedWaveUp(child, input); //step 3 : do root scattering computation - r->reflected_wave_up = tWDF_getReflectedWaveDown(*r, input, r->incident_wave_up); + r->reflected_wave_up = tWDF_getReflectedWaveDown(r, input, r->incident_wave_up); //step 4 : propogate waves down the tree - tWDF_setIncidentWave(*child, r->reflected_wave_up, input); + tWDF_setIncidentWave(child, r->reflected_wave_up, input); //step 5 : grab whatever voltages or currents we want as outputs - return tWDF_getVoltage(*outputPoint); + return tWDF_getVoltage(outputPoint); } void tWDF_setValue(tWDF* const r, Lfloat value) @@ -240,22 +240,22 @@ uint8_t tWDF_isLeaf(tWDF* const r) Lfloat tWDF_getPortResistance(tWDF* const r) { - return r->get_port_resistance(*r); + return r->get_port_resistance(r); } void tWDF_setIncidentWave(tWDF* const r, Lfloat incident_wave, Lfloat input) { - r->set_incident_wave(*r, incident_wave, input); + r->set_incident_wave(r, incident_wave, input); } Lfloat tWDF_getReflectedWaveUp(tWDF* const r, Lfloat input) { - return r->get_reflected_wave_up(*r, input); + return r->get_reflected_wave_up(r, input); } Lfloat tWDF_getReflectedWaveDown(tWDF* const r, Lfloat input, Lfloat incident_wave) { - return r->get_reflected_wave_down(*r, input, incident_wave); + return r->get_reflected_wave_down(r, input, incident_wave); } Lfloat tWDF_getVoltage(tWDF* const r) @@ -340,7 +340,7 @@ static Lfloat get_port_resistance_for_parallel(tWDF* const r) static Lfloat get_port_resistance_for_root(tWDF* const r) { - tWDF child; + tWDF* child; if (r->child_left != NULL) child = r->child_left; else child = r->child_right; @@ -442,7 +442,7 @@ static Lfloat get_reflected_wave_for_parallel(tWDF* const r, Lfloat input) return r->reflected_wave_up; } -static Lfloat get_reflected_wave_for_ideal(tWDF const wdf, Lfloat input, Lfloat incident_wave) +static Lfloat get_reflected_wave_for_ideal(tWDF* const wdf, Lfloat input, Lfloat incident_wave) { return (2.0f * input) - incident_wave; } diff --git a/leaf/Src/leaf-envelopes.c b/leaf/Src/leaf-envelopes.c index 50f61da..d20ad93 100644 --- a/leaf/Src/leaf-envelopes.c +++ b/leaf/Src/leaf-envelopes.c @@ -26,14 +26,14 @@ #if LEAF_INCLUDE_ADSR_TABLES // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Envelope ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ // -void tEnvelope_init (tEnvelope *const envlp, Lfloat attack, Lfloat decay, int loop, LEAF *const leaf) +void tEnvelope_init(tEnvelope** const envlp, Lfloat attack, Lfloat decay, int loop, LEAF *const leaf) { tEnvelope_initToPool(envlp, attack, decay, loop, &leaf->mempool); } -void tEnvelope_initToPool (tEnvelope** const envlp, Lfloat attack, Lfloat decay, int loop, tMempool *const mp) +void tEnvelope_initToPool (tEnvelope** const envlp, Lfloat attack, Lfloat decay, int loop, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tEnvelope *env = *envlp = (tEnvelope *) mpool_alloc(sizeof(tEnvelope), m); env->mempool = m; @@ -196,16 +196,16 @@ Lfloat tEnvelope_tick (tEnvelope* const env) #if LEAF_INCLUDE_ADSR_TABLES /* ADSR */ -void tADSR_init (tADSR *const adsrenv, Lfloat attack, Lfloat decay, Lfloat sustain, +void tADSR_init(tADSR** const adsrenv, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, LEAF *const leaf) { tADSR_initToPool(adsrenv, attack, decay, sustain, release, &leaf->mempool); } void tADSR_initToPool (tADSR** const adsrenv, Lfloat attack, Lfloat decay, - Lfloat sustain, Lfloat release, tMempool *const mp) + Lfloat sustain, Lfloat release, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tADSR *adsr = *adsrenv = (tADSR *) mpool_alloc(sizeof(tADSR), m); adsr->mempool = m; @@ -468,7 +468,7 @@ Lfloat calcADSR3Coef (Lfloat rate, Lfloat targetRatio) return (rate <= 0.0f) ? 0.0f : expf(-logf((1.0f + targetRatio) / targetRatio) / rate); } -void tADSRS_init (tADSRS *const adsrenv, Lfloat attack, Lfloat decay, Lfloat sustain, +void tADSRS_init(tADSRS** const adsrenv, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, LEAF *const leaf) { tADSRS_initToPool(adsrenv, attack, decay, sustain, release, &leaf->mempool); @@ -476,9 +476,9 @@ void tADSRS_init (tADSRS *const adsrenv, Lfloat attack, Lfloat decay, Lfloat sus void tADSRS_initToPool (tADSRS** const adsrenv, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, - tMempool *const mp) + tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tADSRS *adsr = *adsrenv = (tADSRS *) mpool_alloc(sizeof(tADSRS), m); adsr->mempool = m; @@ -626,7 +626,7 @@ void tADSRS_setSampleRate (tADSRS* const adsr, Lfloat sr) /* ADSR 4 */ // new version of our original table-based ADSR but with the table passed in by the user // use this if the size of the big ADSR tables is too much. -void tADSRT_init (tADSRT *const adsrenv, Lfloat attack, Lfloat decay, Lfloat sustain, +void tADSRT_init(tADSRT** const adsrenv, Lfloat attack, Lfloat decay, Lfloat sustain, Lfloat release, Lfloat *expBuffer, int bufferSize, LEAF *const leaf) { tADSRT_initToPool(adsrenv, attack, decay, sustain, release, expBuffer, @@ -637,9 +637,9 @@ void tADSRT_init (tADSRT *const adsrenv, Lfloat attack, Lfloat decay, Lfloat sus //times are in ms void tADSRT_initToPool(tADSRT** const adsrenv, Lfloat attack, Lfloat decay, Lfloat sustain, - Lfloat release, Lfloat *expBuffer, int bufferSize, tMempool *const mp) + Lfloat release, Lfloat *expBuffer, int bufferSize, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tADSRT *adsr = *adsrenv = (tADSRT *) mpool_alloc(sizeof(tADSRT), m); adsr->mempool = m; @@ -1007,15 +1007,15 @@ void tADSRT_setSampleRate (tADSRT* const adsr, Lfloat sr) /////----------------- /* Ramp */ -void tRamp_init (tRamp* const r, Lfloat time, int samples_per_tick, LEAF *const leaf) +void tRamp_init(tRamp** const r, Lfloat time, int samples_per_tick, LEAF *const leaf) { tRamp_initToPool(r, time, samples_per_tick, &leaf->mempool); } void tRamp_initToPool (tRamp** const r, Lfloat time, int samples_per_tick, - tMempool *const mp) + tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tRamp *ramp = *r = (tRamp *) mpool_alloc(sizeof(tRamp), m); ramp->mempool = m; @@ -1095,16 +1095,16 @@ void tRamp_setSampleRate (tRamp* const r, Lfloat sr) //=========================================================================================== /* RampUpDown */ -void tRampUpDown_init (tRampUpDown *const r, Lfloat upTime, Lfloat downTime, +void tRampUpDown_init(tRampUpDown** const r, Lfloat upTime, Lfloat downTime, int samples_per_tick, LEAF *const leaf) { tRampUpDown_initToPool(r, upTime, downTime, samples_per_tick, &leaf->mempool); } void tRampUpDown_initToPool (tRampUpDown** const r, Lfloat upTime, Lfloat downTime, - int samples_per_tick, tMempool *const mp) + int samples_per_tick, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tRampUpDown *ramp = *r = (tRampUpDown *) mpool_alloc(sizeof(tRampUpDown), m); ramp->mempool = m; @@ -1205,16 +1205,16 @@ Lfloat tRampUpDown_sample (tRampUpDown* const r) /* Exponential Smoother */ -void tExpSmooth_init (tExpSmooth *const expsmooth, Lfloat val, Lfloat factor, +void tExpSmooth_init(tExpSmooth** const expsmooth, Lfloat val, Lfloat factor, LEAF *const leaf) // factor is usually a value between 0 and 0.1. Lower value is slower. 0.01 for example gives you a smoothing time of about 10ms { tExpSmooth_initToPool(expsmooth, val, factor, &leaf->mempool); } void tExpSmooth_initToPool(tExpSmooth** const expsmooth, Lfloat val, Lfloat factor, - tMempool *const mp) + tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tExpSmooth *smooth = *expsmooth = (tExpSmooth *) mpool_alloc(sizeof(tExpSmooth), m); smooth->mempool = m; @@ -1293,15 +1293,15 @@ void tExpSmooth_setSampleRate (tExpSmooth* const smooth, Lfloat sr) //tSlide is based on the max/msp slide~ object //// -void tSlide_init (tSlide *const sl, Lfloat upSlide, Lfloat downSlide, LEAF *const leaf) +void tSlide_init(tSlide** const sl, Lfloat upSlide, Lfloat downSlide, LEAF *const leaf) { tSlide_initToPool(sl, upSlide, downSlide, &leaf->mempool); } //upslide and downslide are in samples -void tSlide_initToPool (tSlide** const sl, Lfloat upSlide, Lfloat downSlide, tMempool *const mp) +void tSlide_initToPool (tSlide** const sl, Lfloat upSlide, Lfloat downSlide, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tSlide *s = *sl = (tSlide *) mpool_alloc(sizeof(tSlide), m); s->mempool = m; diff --git a/leaf/Src/leaf-filters.c b/leaf/Src/leaf-filters.c index 3580ce8..51d4230 100644 --- a/leaf/Src/leaf-filters.c +++ b/leaf/Src/leaf-filters.c @@ -31,16 +31,16 @@ /******************************************************************************/ -void tAllpass_init (tAllpass *const ft, Lfloat initDelay, uint32_t maxDelay, +void tAllpass_init(tAllpass** const ft, Lfloat initDelay, uint32_t maxDelay, LEAF *const leaf) { tAllpass_initToPool(ft, initDelay, maxDelay, &leaf->mempool); } void tAllpass_initToPool (tAllpass** const ft, Lfloat initDelay, - uint32_t maxDelay, tMempool *const mp) + uint32_t maxDelay, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tAllpass *f = *ft = (tAllpass *) mpool_alloc(sizeof(tAllpass), m); f->mempool = m; @@ -60,7 +60,7 @@ void tAllpass_free (tAllpass** const ft) void tAllpass_setDelay (tAllpass* const f, Lfloat delay) { - tLinearDelay_setDelay(&f->delay, delay); + tLinearDelay_setDelay(f->delay, delay); } void tAllpass_setGain (tAllpass* const f, Lfloat gain) @@ -71,7 +71,7 @@ void tAllpass_setGain (tAllpass* const f, Lfloat gain) Lfloat tAllpass_tick (tAllpass* const f, Lfloat input) { Lfloat s1 = (-f->gain) * f->lastOut + input; - Lfloat s2 = tLinearDelay_tick(&f->delay, s1) + (f->gain) * input; + Lfloat s2 = tLinearDelay_tick(f->delay, s1) + (f->gain) * input; f->lastOut = s2; @@ -83,14 +83,14 @@ Lfloat tAllpass_tick (tAllpass* const f, Lfloat input) /******************************************************************************/ -void tAllpassSO_init (tAllpassSO *const ft, LEAF *const leaf) +void tAllpassSO_init(tAllpassSO** const ft, LEAF *const leaf) { tAllpassSO_initToPool(ft, &leaf->mempool); } -void tAllpassSO_initToPool (tAllpassSO** const ft, tMempool *const mp) +void tAllpassSO_initToPool (tAllpassSO** const ft, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tAllpassSO *f = *ft = (tAllpassSO *) mpool_alloc(sizeof(tAllpassSO), m); f->mempool = m; @@ -167,21 +167,21 @@ Lfloat tAllpassSO_tick (tAllpassSO* const f, Lfloat input) /******************************************************************************/ -void tThiranAllpassSOCascade_init (tThiranAllpassSOCascade *const ft, +void tThiranAllpassSOCascade_init(tThiranAllpassSOCascade** const ft, int numFilts, LEAF *const leaf) { tThiranAllpassSOCascade_initToPool(ft, numFilts, &leaf->mempool); } void tThiranAllpassSOCascade_initToPool (tThiranAllpassSOCascade** const ft, - int numFilts, tMempool *const mp) + int numFilts, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tThiranAllpassSOCascade *f = *ft = (tThiranAllpassSOCascade *) mpool_alloc( sizeof(tThiranAllpassSOCascade), m); f->mempool = m; f->numFilts = numFilts; - f->filters = (tAllpassSO *) mpool_calloc(sizeof(tAllpassSO) * numFilts, m); + f->filters = (tAllpassSO **) mpool_calloc(sizeof(tAllpassSO*) * numFilts, m); f->k1[0] = -0.00050469f; f->k2[0] = -0.0064264f; f->k3[0] = -2.8743f; @@ -274,7 +274,7 @@ float tThiranAllpassSOCascade_setCoeff (tThiranAllpassSOCascade* const f, //f->a[1] = LEAF_clip(-1.999999f, f->a[1], 2.0f); for (int i = 0; i < f->numActiveFilters; i++) { - tAllpassSO_setCoeff(&f->filters[i], f->a[0], f->a[1]); + tAllpassSO_setCoeff(f->filters[i], f->a[0], f->a[1]); //f->filters[i]->prevSamp = 0.0f; //f->filters[i]->prevPrevSamp = 0.0f; //probably should adjust the gain of the internal state variables @@ -290,7 +290,7 @@ Lfloat tThiranAllpassSOCascade_tick (tThiranAllpassSOCascade* const f, Lfloat in { Lfloat sample = input; for (int i = 0; i < f->numActiveFilters; i++) { - sample = tAllpassSO_tick(&f->filters[i], sample); + sample = tAllpassSO_tick(f->filters[i], sample); } return sample; } @@ -298,7 +298,7 @@ Lfloat tThiranAllpassSOCascade_tick (tThiranAllpassSOCascade* const f, Lfloat in void tThiranAllpassSOCascade_clear (tThiranAllpassSOCascade* const f) { for (int i = 0; i < f->numFilts; i++) { - //tAllpassSO_setCoeff(&f->filters[i], f->a[1], f->a[2]); + //tAllpassSO_setCoeff(f->filters[i], f->a[1], f->a[2]); f->filters[i]->prevSamp = 0.0f; f->filters[i]->prevPrevSamp = 0.0f; @@ -311,14 +311,14 @@ void tThiranAllpassSOCascade_clear (tThiranAllpassSOCascade* const f) /******************************************************************************/ -void tOnePole_init (tOnePole *const ft, Lfloat freq, LEAF *const leaf) +void tOnePole_init(tOnePole** const ft, Lfloat freq, LEAF *const leaf) { tOnePole_initToPool(ft, freq, &leaf->mempool); } -void tOnePole_initToPool (tOnePole** const ft, Lfloat freq, tMempool *const mp) +void tOnePole_initToPool (tOnePole** const ft, Lfloat freq, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tOnePole *f = *ft = (tOnePole *) mpool_alloc(sizeof(tOnePole), m); f->mempool = m; LEAF *leaf = f->mempool->leaf; @@ -408,14 +408,14 @@ void tOnePole_setSampleRate (tOnePole* const f, Lfloat sr) /******************************************************************************/ -void tCookOnePole_init (tCookOnePole *const ft, LEAF *const leaf) +void tCookOnePole_init(tCookOnePole** const ft, LEAF *const leaf) { tCookOnePole_initToPool(ft, &leaf->mempool); } -void tCookOnePole_initToPool (tCookOnePole** const ft, tMempool *const mp) +void tCookOnePole_initToPool (tCookOnePole** const ft, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tCookOnePole *f = *ft = (tCookOnePole *) mpool_alloc(sizeof(tCookOnePole), m); f->mempool = m; LEAF *leaf = f->mempool->leaf; @@ -476,14 +476,14 @@ void tCookOnePole_setSampleRate (tCookOnePole* const f, Lfloat sr) /******************************************************************************/ -void tTwoPole_init (tTwoPole *const ft, LEAF *const leaf) +void tTwoPole_init(tTwoPole** const ft, LEAF *const leaf) { tTwoPole_initToPool(ft, &leaf->mempool); } -void tTwoPole_initToPool (tTwoPole** const ft, tMempool *const mp) +void tTwoPole_initToPool (tTwoPole** const ft, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tTwoPole *f = *ft = (tTwoPole *) mpool_alloc(sizeof(tTwoPole), m); f->mempool = m; LEAF *leaf = f->mempool->leaf; @@ -590,14 +590,14 @@ void tTwoPole_setSampleRate (tTwoPole* const f, Lfloat sr) /******************************************************************************/ -void tOneZero_init (tOneZero *const ft, Lfloat theZero, LEAF *const leaf) +void tOneZero_init(tOneZero** const ft, Lfloat theZero, LEAF *const leaf) { tOneZero_initToPool(ft, theZero, &leaf->mempool); } -void tOneZero_initToPool (tOneZero** const ft, Lfloat theZero, tMempool *const mp) +void tOneZero_initToPool (tOneZero** const ft, Lfloat theZero, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tOneZero *f = *ft = (tOneZero *) mpool_alloc(sizeof(tOneZero), m); f->mempool = m; LEAF *leaf = f->mempool->leaf; @@ -695,14 +695,14 @@ void tOneZero_setSampleRate (tOneZero* const f, Lfloat sr) /******************************************************************************/ -void tTwoZero_init (tTwoZero* const ft, LEAF *const leaf) +void tTwoZero_init(tTwoZero** const ft, LEAF *const leaf) { tTwoZero_initToPool(ft, &leaf->mempool); } -void tTwoZero_initToPool (tTwoZero** const ft, tMempool *const mp) +void tTwoZero_initToPool (tTwoZero** const ft, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tTwoZero *f = *ft = (tTwoZero *) mpool_alloc(sizeof(tTwoZero), m); f->mempool = m; LEAF *leaf = f->mempool->leaf; @@ -785,14 +785,14 @@ void tTwoZero_setSampleRate (tTwoZero* const f, Lfloat sr) /******************************************************************************/ -void tPoleZero_init (tPoleZero* const pzf, LEAF *const leaf) +void tPoleZero_init(tPoleZero** const pzf, LEAF *const leaf) { tPoleZero_initToPool(pzf, &leaf->mempool); } -void tPoleZero_initToPool (tPoleZero** const pzf, tMempool *const mp) +void tPoleZero_initToPool (tPoleZero** const pzf, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tPoleZero *f = *pzf = (tPoleZero *) mpool_alloc(sizeof(tPoleZero), m); f->mempool = m; @@ -886,14 +886,14 @@ Lfloat tPoleZero_tick (tPoleZero* const f, Lfloat input) /******************************************************************************/ -void tBiQuad_init (tBiQuad *const ft, LEAF *const leaf) +void tBiQuad_init(tBiQuad** const ft, LEAF *const leaf) { tBiQuad_initToPool(ft, &leaf->mempool); } -void tBiQuad_initToPool (tBiQuad** const ft, tMempool *const mp) +void tBiQuad_initToPool (tBiQuad** const ft, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tBiQuad *f = *ft = (tBiQuad *) mpool_alloc(sizeof(tBiQuad), m); f->mempool = m; LEAF *leaf = f->mempool->leaf; @@ -1038,7 +1038,7 @@ void tBiQuad_setSampleRate (tBiQuad* const f, Lfloat sr) // Less efficient, more accurate version of SVF, in which cutoff frequency is // taken as Lfloating point Hz value and tanf is calculated when frequency changes. -void tSVF_init (tSVF *const svff, SVFType type, Lfloat freq, Lfloat Q, +void tSVF_init(tSVF** const svff, SVFType type, Lfloat freq, Lfloat Q, LEAF *const leaf) { tSVF_initToPool(svff, type, freq, Q, &leaf->mempool); @@ -1049,9 +1049,9 @@ void tSVF_init (tSVF *const svff, SVFType type, Lfloat freq, Lfloat Q, } void tSVF_initToPool (tSVF** const svff, SVFType type, Lfloat freq, Lfloat Q, - tMempool *const mp) + tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tSVF *svf = *svff = (tSVF *) mpool_alloc(sizeof(tSVF), m); svf->mempool = m; @@ -1292,14 +1292,14 @@ Lfloat tSVF_getPhaseAtFrequency (tSVF* const svf, Lfloat freq) // Less efficient, more accurate version of SVF, in which cutoff frequency is taken as Lfloating point Hz value and tanf // is calculated when frequency changes. -void tSVF_LP_init (tSVF_LP* const svff, Lfloat freq, Lfloat Q, LEAF *const leaf) +void tSVF_LP_init(tSVF_LP** const svff, Lfloat freq, Lfloat Q, LEAF *const leaf) { tSVF_LP_initToPool(svff, freq, Q, &leaf->mempool); } -void tSVF_LP_initToPool (tSVF_LP** const svff, Lfloat freq, Lfloat Q, tMempool *const mp) +void tSVF_LP_initToPool (tSVF_LP** const svff, Lfloat freq, Lfloat Q, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tSVF_LP *svf = *svff = (tSVF_LP *) mpool_alloc(sizeof(tSVF_LP), m); svf->mempool = m; @@ -1478,14 +1478,14 @@ Lfloat tSVF_LP_getPhaseAtFrequency (tSVF_LP* const svf, Lfloat freq) // Efficient version of tSVF where frequency is set based on 12-bit integer input for lookup in tanh wavetable. -void tEfficientSVF_init(tEfficientSVF *const svff, SVFType type, uint16_t input, Lfloat Q, LEAF *const leaf) { +void tEfficientSVF_init(tEfficientSVF** const svff, SVFType type, uint16_t input, Lfloat Q, LEAF *const leaf) { tEfficientSVF_initToPool(svff, type, input, Q, &leaf->mempool); } void tEfficientSVF_initToPool (tEfficientSVF** const svff, SVFType type, - uint16_t input, Lfloat Q, tMempool *const mp) + uint16_t input, Lfloat Q, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tEfficientSVF *svf = *svff = (tEfficientSVF *) mpool_alloc(sizeof(tEfficientSVF), m); svf->mempool = m; @@ -1581,14 +1581,14 @@ void tEfficientSVF_setSampleRate (tEfficientSVF* const svf, Lfloat sampleRate) /******************************************************************************/ -void tHighpass_init (tHighpass* const ft, Lfloat freq, LEAF *const leaf) +void tHighpass_init(tHighpass** const ft, Lfloat freq, LEAF *const leaf) { tHighpass_initToPool(ft, freq, &leaf->mempool); } -void tHighpass_initToPool (tHighpass** const ft, Lfloat freq, tMempool *const mp) +void tHighpass_initToPool (tHighpass** const ft, Lfloat freq, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tHighpass *f = *ft = (tHighpass *) mpool_calloc(sizeof(tHighpass), m); f->mempool = m; LEAF *leaf = f->mempool->leaf; @@ -1638,16 +1638,16 @@ void tHighpass_setSampleRate (tHighpass* const f, Lfloat sr) /******************************************************************************/ -void tButterworth_init (tButterworth* const ft, int order, Lfloat f1, Lfloat f2, +void tButterworth_init(tButterworth** const ft, int order, Lfloat f1, Lfloat f2, LEAF *const leaf) { tButterworth_initToPool(ft, order, f1, f2, &leaf->mempool); } void tButterworth_initToPool (tButterworth** const ft, int order, Lfloat f1, - Lfloat f2, tMempool *const mp) + Lfloat f2, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tButterworth *f = *ft = (tButterworth *) mpool_alloc(sizeof(tButterworth), m); f->mempool = m; @@ -1658,15 +1658,15 @@ void tButterworth_initToPool (tButterworth** const ft, int order, Lfloat f1, f->numSVF = f->order = order; if (f1 >= 0.0f && f2 >= 0.0f) f->numSVF *= 2; - f->svf = (tSVF *) mpool_alloc(sizeof(tSVF) * f->numSVF, m); + f->svfs = (tSVF **) mpool_alloc(sizeof(tSVF*) * f->numSVF, m); int o = 0; if (f1 >= 0.0f) o = f->order; for (int i = 0; i < f->order; ++i) { if (f1 >= 0.0f) - tSVF_initToPool(&f->svf[i], SVFTypeHighpass, f1, 0.5f / cosf((1.0f + 2.0f * i) * PI / (4 * f->order)), mp); + tSVF_initToPool(&f->svfs[i], SVFTypeHighpass, f1, 0.5f / cosf((1.0f + 2.0f * i) * PI / (4 * f->order)), mp); if (f2 >= 0.0f) - tSVF_initToPool(&f->svf[i + o], SVFTypeLowpass, f2, 0.5f / cosf((1.0f + 2.0f * i) * PI / (4 * f->order)), + tSVF_initToPool(&f->svfs[i + o], SVFTypeLowpass, f2, 0.5f / cosf((1.0f + 2.0f * i) * PI / (4 * f->order)), mp); } } @@ -1675,16 +1675,16 @@ void tButterworth_free (tButterworth** const ft) { tButterworth *f = *ft; - for (int i = 0; i < f->numSVF; ++i) tSVF_free(&f->svf[i]); + for (int i = 0; i < f->numSVF; ++i) tSVF_free(&f->svfs[i]); - mpool_free((char *) f->svf, f->mempool); + mpool_free((char *) f->svfs, f->mempool); mpool_free((char *) f, f->mempool); } Lfloat tButterworth_tick (tButterworth* const f, Lfloat samp) { for (int i = 0; i < f->numSVF; ++i) - samp = tSVF_tick(&f->svf[i], samp); + samp = tSVF_tick(f->svfs[i], samp); return samp; } @@ -1694,7 +1694,7 @@ void tButterworth_setF1 (tButterworth* const f, Lfloat f1) if (f->f1 < 0.0f || f1 < 0.0f) return; f->f1 = f1; - for (int i = 0; i < f->order; ++i) tSVF_setFreq(&f->svf[i], f1); + for (int i = 0; i < f->order; ++i) tSVF_setFreq(f->svfs[i], f1); } void tButterworth_setF2 (tButterworth* const f, Lfloat f2) @@ -1704,7 +1704,7 @@ void tButterworth_setF2 (tButterworth* const f, Lfloat f2) int o = 0; if (f->f1 >= 0.0f) o = f->order; f->f2 = f2; - for (int i = 0; i < f->order; ++i) tSVF_setFreq(&f->svf[i + o], f2); + for (int i = 0; i < f->order; ++i) tSVF_setFreq(f->svfs[i + o], f2); } void tButterworth_setFreqs (tButterworth* const f, Lfloat f1, Lfloat f2) @@ -1715,7 +1715,7 @@ void tButterworth_setFreqs (tButterworth* const f, Lfloat f1, Lfloat f2) void tButterworth_setSampleRate (tButterworth* const f, Lfloat sr) { - for (int i = 0; i < f->numSVF; ++i) tSVF_setSampleRate(&f->svf[i], sr); + for (int i = 0; i < f->numSVF; ++i) tSVF_setSampleRate(f->svfs[i], sr); } @@ -1724,14 +1724,14 @@ void tButterworth_setSampleRate (tButterworth* const f, Lfloat sr) /******************************************************************************/ -void tFIR_init (tFIR *const firf, Lfloat *coeffs, int numTaps, LEAF *const leaf) +void tFIR_init(tFIR** const firf, Lfloat *coeffs, int numTaps, LEAF *const leaf) { tFIR_initToPool(firf, coeffs, numTaps, &leaf->mempool); } -void tFIR_initToPool (tFIR** const firf, Lfloat *coeffs, int numTaps, tMempool *const mp) +void tFIR_initToPool (tFIR** const firf, Lfloat *coeffs, int numTaps, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tFIR *fir = *firf = (tFIR *) mpool_alloc(sizeof(tFIR), m); fir->mempool = m; @@ -1770,14 +1770,14 @@ Lfloat tFIR_tick (tFIR* const fir, Lfloat input) /// translated from a Gen~ port of the Supercollider code that I believe was made by Rodrigo Costanzo and which I got from PA Tremblay - JS -void tMedianFilter_init (tMedianFilter *const f, int size, LEAF *const leaf) +void tMedianFilter_init(tMedianFilter** const f, int size, LEAF *const leaf) { tMedianFilter_initToPool(f, size, &leaf->mempool); } -void tMedianFilter_initToPool (tMedianFilter** const mf, int size, tMempool *const mp) +void tMedianFilter_initToPool (tMedianFilter** const mf, int size, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tMedianFilter *f = *mf = (tMedianFilter *) mpool_alloc(sizeof(tMedianFilter), m); f->mempool = m; @@ -1845,16 +1845,16 @@ Lfloat tMedianFilter_tick (tMedianFilter* const f, Lfloat input) /******************************************************************************/ -void tVZFilter_init (tVZFilter* const vf, VZFilterType type, Lfloat freq, +void tVZFilter_init(tVZFilter** const vf, VZFilterType type, Lfloat freq, Lfloat bandWidth, LEAF *const leaf) { tVZFilter_initToPool(vf, type, freq, bandWidth, &leaf->mempool); } void tVZFilter_initToPool (tVZFilter** const vf, VZFilterType type, Lfloat freq, - Lfloat bandWidth, tMempool *const mp) + Lfloat bandWidth, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tVZFilter *f = *vf = (tVZFilter *) mpool_alloc(sizeof(tVZFilter), m); f->mempool = m; @@ -2371,16 +2371,16 @@ void tVZFilter_setSampleRate (tVZFilter* const f, Lfloat sr) /******************************************************************************/ -void tVZFilterLS_init (tVZFilterLS* const vf, Lfloat freq, Lfloat Q, Lfloat gain, +void tVZFilterLS_init(tVZFilterLS** const vf, Lfloat freq, Lfloat Q, Lfloat gain, LEAF *const leaf) { tVZFilterLS_initToPool(vf, freq, Q, gain, &leaf->mempool); } void tVZFilterLS_initToPool (tVZFilterLS** const vf, Lfloat freq, Lfloat Q, - Lfloat gain, tMempool *const mp) + Lfloat gain, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tVZFilterLS *f = *vf = (tVZFilterLS *) mpool_alloc(sizeof(tVZFilterLS), m); f->mempool = m; @@ -2530,16 +2530,16 @@ void tVZFilterLS_setFreqFastAndResonanceAndGain (tVZFilterLS* const f, Lfloat cu /******************************************************************************/ -void tVZFilterHS_init (tVZFilterHS *const vf, Lfloat freq, Lfloat Q, Lfloat gain, +void tVZFilterHS_init(tVZFilterHS** const vf, Lfloat freq, Lfloat Q, Lfloat gain, LEAF *const leaf) { tVZFilterHS_initToPool(vf, freq, Q, gain, &leaf->mempool); } void tVZFilterHS_initToPool (tVZFilterHS** const vf, Lfloat freq, Lfloat Q, - Lfloat gain, tMempool *const mp) + Lfloat gain, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tVZFilterHS *f = *vf = (tVZFilterHS *) mpool_alloc(sizeof(tVZFilterHS), m); f->mempool = m; @@ -2693,16 +2693,16 @@ void tVZFilterHS_setFreqFastAndResonanceAndGain (tVZFilterHS* const f, Lfloat cu /******************************************************************************/ -void tVZFilterBell_init (tVZFilterBell* const vf, Lfloat freq, Lfloat BW, +void tVZFilterBell_init(tVZFilterBell** const vf, Lfloat freq, Lfloat BW, Lfloat gain, LEAF *const leaf) { tVZFilterBell_initToPool(vf, freq, BW, gain, &leaf->mempool); } void tVZFilterBell_initToPool (tVZFilterBell** const vf, Lfloat freq, Lfloat BW, - Lfloat gain, tMempool *const mp) + Lfloat gain, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tVZFilterBell *f = *vf = (tVZFilterBell *) mpool_alloc(sizeof(tVZFilterBell), m); f->mempool = m; @@ -2953,14 +2953,14 @@ void tVZFilterBell_setFreqAndBWAndGainFast (tVZFilterBell* const f, Lfloat cutof /******************************************************************************/ -void tVZFilterBR_init (tVZFilterBR* const vf, Lfloat freq, Lfloat Q, LEAF *const leaf) +void tVZFilterBR_init(tVZFilterBR** const vf, Lfloat freq, Lfloat Q, LEAF *const leaf) { tVZFilterBR_initToPool(vf, freq, Q, &leaf->mempool); } -void tVZFilterBR_initToPool (tVZFilterBR** const vf, Lfloat freq, Lfloat Q, tMempool *const mp) +void tVZFilterBR_initToPool (tVZFilterBR** const vf, Lfloat freq, Lfloat Q, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tVZFilterBR *f = *vf = (tVZFilterBR *) mpool_alloc(sizeof(tVZFilterBR), m); f->mempool = m; @@ -3090,16 +3090,16 @@ void tVZFilterBR_setFreqAndResonanceFast (tVZFilterBR* const f, Lfloat cutoff, L //taken from Ivan C's model of the EMS diode ladder, based on mystran's code from KVR forums //https://www.kvraudio.com/forum/viewtopic.php?f=33&t=349859&start=255 -void tDiodeFilter_init (tDiodeFilter* const vf, Lfloat cutoff, Lfloat resonance, +void tDiodeFilter_init(tDiodeFilter** const vf, Lfloat cutoff, Lfloat resonance, LEAF *const leaf) { tDiodeFilter_initToPool(vf, cutoff, resonance, &leaf->mempool); } void tDiodeFilter_initToPool (tDiodeFilter** const vf, Lfloat cutoff, Lfloat resonance, - tMempool *const mp) + tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tDiodeFilter *f = *vf = (tDiodeFilter *) mpool_alloc(sizeof(tDiodeFilter), m); f->mempool = m; @@ -3314,16 +3314,16 @@ void tDiodeFilter_setSampleRate(tDiodeFilter* const f, Lfloat sr) { /******************************************************************************/ -void tLadderFilter_init (tLadderFilter* const vf, Lfloat cutoff, Lfloat resonance, +void tLadderFilter_init(tLadderFilter** const vf, Lfloat cutoff, Lfloat resonance, LEAF *const leaf) { tLadderFilter_initToPool(vf, cutoff, resonance, &leaf->mempool); } void tLadderFilter_initToPool (tLadderFilter** const vf, Lfloat cutoff, - Lfloat resonance, tMempool *const mp) + Lfloat resonance, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tLadderFilter *f = *vf = (tLadderFilter *) mpool_alloc(sizeof(tLadderFilter), m); f->mempool = m; @@ -3517,14 +3517,14 @@ void tLadderFilter_setOversampling (tLadderFilter* const f, int os) /******************************************************************************/ -void tTiltFilter_init (tTiltFilter *const vf, Lfloat cutoff, LEAF *const leaf) +void tTiltFilter_init(tTiltFilter** const vf, Lfloat cutoff, LEAF *const leaf) { tTiltFilter_initToPool(vf, cutoff, &leaf->mempool); } -void tTiltFilter_initToPool (tTiltFilter** const vf, Lfloat cutoff, tMempool *const mp) +void tTiltFilter_initToPool (tTiltFilter** const vf, Lfloat cutoff, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tTiltFilter *f = *vf = (tTiltFilter *) mpool_alloc(sizeof(tTiltFilter), m); f->mempool = m; diff --git a/leaf/Src/leaf-instruments.c b/leaf/Src/leaf-instruments.c index 2f83d0e..2832ab2 100644 --- a/leaf/Src/leaf-instruments.c +++ b/leaf/Src/leaf-instruments.c @@ -18,22 +18,22 @@ // ----------------- COWBELL ----------------------------// -void t808Cowbell_init(t808Cowbell* const cowbellInst, int useStick, LEAF* const leaf) +void t808Cowbell_init(t808Cowbell** const cowbellInst, int useStick, LEAF* const leaf) { t808Cowbell_initToPool(cowbellInst, useStick, &leaf->mempool); } -void t808Cowbell_initToPool (t808Cowbell** const cowbellInst, int useStick, tMempool* const mp) +void t808Cowbell_initToPool (t808Cowbell** const cowbellInst, int useStick, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; t808Cowbell* cowbell = *cowbellInst = (t808Cowbell*) mpool_alloc(sizeof(t808Cowbell), m); cowbell->mempool = m; tSquare_initToPool(&cowbell->p[0], mp); - tSquare_setFreq(&cowbell->p[0], 540.0f); + tSquare_setFreq(cowbell->p[0], 540.0f); tSquare_initToPool(&cowbell->p[1], mp); - tSquare_setFreq(&cowbell->p[1], 1.48148f * 540.0f); + tSquare_setFreq(cowbell->p[1], 1.48148f * 540.0f); cowbell->oscMix = 0.5f; @@ -72,10 +72,10 @@ void t808Cowbell_free (t808Cowbell** const cowbellInst) void t808Cowbell_on(t808Cowbell* const cowbell, Lfloat vel) { - tEnvelope_on(&cowbell->envGain, vel); + tEnvelope_on(cowbell->envGain, vel); if (cowbell->useStick) - tEnvelope_on(&cowbell->envStick,vel); + tEnvelope_on(cowbell->envStick,vel); } Lfloat t808Cowbell_tick(t808Cowbell* const cowbell) @@ -83,31 +83,31 @@ Lfloat t808Cowbell_tick(t808Cowbell* const cowbell) Lfloat sample = 0.0f; // Mix oscillators. - sample = (cowbell->oscMix * tSquare_tick(&cowbell->p[0])) + ((1.0f-cowbell->oscMix) * tSquare_tick(&cowbell->p[1])); + sample = (cowbell->oscMix * tSquare_tick(cowbell->p[0])) + ((1.0f-cowbell->oscMix) * tSquare_tick(cowbell->p[1])); // Filter dive and filter. - tSVF_setFreq(&cowbell->bandpassOsc, cowbell->filterCutoff + 1000.0f * tEnvelope_tick(&cowbell->envFilter)); - sample = tSVF_tick(&cowbell->bandpassOsc,sample); + tSVF_setFreq(cowbell->bandpassOsc, cowbell->filterCutoff + 1000.0f * tEnvelope_tick(cowbell->envFilter)); + sample = tSVF_tick(cowbell->bandpassOsc,sample); - sample *= (0.9f * tEnvelope_tick(&cowbell->envGain)); + sample *= (0.9f * tEnvelope_tick(cowbell->envGain)); if (cowbell->useStick) - sample += (0.1f * tEnvelope_tick(&cowbell->envStick) * tSVF_tick(&cowbell->bandpassStick, tNoise_tick(&cowbell->stick))); + sample += (0.1f * tEnvelope_tick(cowbell->envStick) * tSVF_tick(cowbell->bandpassStick, tNoise_tick(cowbell->stick))); - sample = tHighpass_tick(&cowbell->highpass, sample); + sample = tHighpass_tick(cowbell->highpass, sample); return sample; } void t808Cowbell_setDecay(t808Cowbell* const cowbell, Lfloat decay) { - tEnvelope_setDecay(&cowbell->envGain,decay); + tEnvelope_setDecay(cowbell->envGain,decay); } void t808Cowbell_setHighpassFreq(t808Cowbell* cowbell, Lfloat freq) { - tHighpass_setFreq(&cowbell->highpass,freq); + tHighpass_setFreq(cowbell->highpass,freq); } void t808Cowbell_setBandpassFreq(t808Cowbell* const cowbell, Lfloat freq) @@ -117,8 +117,8 @@ void t808Cowbell_setBandpassFreq(t808Cowbell* const cowbell, Lfloat freq) void t808Cowbell_setFreq(t808Cowbell* const cowbell, Lfloat freq) { - tSquare_setFreq(&cowbell->p[0],freq); - tSquare_setFreq(&cowbell->p[1],1.48148f*freq); + tSquare_setFreq(cowbell->p[0],freq); + tSquare_setFreq(cowbell->p[1],1.48148f*freq); } void t808Cowbell_setOscMix(t808Cowbell* const cowbell, Lfloat oscMix) @@ -133,23 +133,23 @@ void t808Cowbell_setStick(t808Cowbell* const cowbell, int useStick) void t808Cowbell_setSampleRate(t808Cowbell* const cowbell, Lfloat sr) { - tSquare_setSampleRate(&cowbell->p[0], sr); - tSquare_setSampleRate(&cowbell->p[1], sr); - tSVF_setSampleRate(&cowbell->bandpassOsc, sr); - tSVF_setSampleRate(&cowbell->bandpassStick, sr); - tHighpass_setSampleRate(&cowbell->highpass, sr); + tSquare_setSampleRate(cowbell->p[0], sr); + tSquare_setSampleRate(cowbell->p[1], sr); + tSVF_setSampleRate(cowbell->bandpassOsc, sr); + tSVF_setSampleRate(cowbell->bandpassStick, sr); + tHighpass_setSampleRate(cowbell->highpass, sr); } // ----------------- HIHAT ----------------------------// -void t808Hihat_init(t808Hihat* const hihatInst, LEAF* const leaf) +void t808Hihat_init(t808Hihat** const hihatInst, LEAF* const leaf) { t808Hihat_initToPool(hihatInst, &leaf->mempool); } -void t808Hihat_initToPool (t808Hihat** const hihatInst, tMempool* const mp) +void t808Hihat_initToPool (t808Hihat** const hihatInst, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; t808Hihat* hihat = *hihatInst = (t808Hihat*) mpool_alloc(sizeof(t808Hihat), m); hihat->mempool = m; @@ -174,12 +174,12 @@ void t808Hihat_initToPool (t808Hihat** const hihatInst, tMempool* const mp) hihat->freq = 40.0f; hihat->stretch = 0.0f; - tSquare_setFreq(&hihat->p[0], 2.0f * hihat->freq); - tSquare_setFreq(&hihat->p[1], 3.00f * hihat->freq); - tSquare_setFreq(&hihat->p[2], 4.16f * hihat->freq); - tSquare_setFreq(&hihat->p[3], 5.43f * hihat->freq); - tSquare_setFreq(&hihat->p[4], 6.79f * hihat->freq); - tSquare_setFreq(&hihat->p[5], 8.21f * hihat->freq); + tSquare_setFreq(hihat->p[0], 2.0f * hihat->freq); + tSquare_setFreq(hihat->p[1], 3.00f * hihat->freq); + tSquare_setFreq(hihat->p[2], 4.16f * hihat->freq); + tSquare_setFreq(hihat->p[3], 5.43f * hihat->freq); + tSquare_setFreq(hihat->p[4], 6.79f * hihat->freq); + tSquare_setFreq(hihat->p[5], 8.21f * hihat->freq); } void t808Hihat_free (t808Hihat** const hihatInst) @@ -207,8 +207,8 @@ void t808Hihat_free (t808Hihat** const hihatInst) void t808Hihat_on(t808Hihat* const hihat, Lfloat vel) { - tEnvelope_on(&hihat->envGain, vel); - tEnvelope_on(&hihat->envStick, vel); + tEnvelope_on(hihat->envGain, vel); + tEnvelope_on(hihat->envStick, vel); } void t808Hihat_setOscNoiseMix(t808Hihat* const hihat, Lfloat oscNoiseMix) @@ -221,30 +221,30 @@ Lfloat t808Hihat_tick(t808Hihat* const hihat) Lfloat sample = 0.0f; Lfloat gainScale = 0.1666f; - Lfloat myNoise = tNoise_tick(&hihat->n); + Lfloat myNoise = tNoise_tick(hihat->n); - tSquare_setFreq(&hihat->p[0], ((2.0f + hihat->stretch) * hihat->freq)); - tSquare_setFreq(&hihat->p[1], ((3.00f + hihat->stretch) * hihat->freq)); - tSquare_setFreq(&hihat->p[2], ((4.16f + hihat->stretch) * hihat->freq)); - tSquare_setFreq(&hihat->p[3], ((5.43f + hihat->stretch) * hihat->freq)); - tSquare_setFreq(&hihat->p[4], ((6.79f + hihat->stretch) * hihat->freq)); - tSquare_setFreq(&hihat->p[5], ((8.21f + hihat->stretch) * hihat->freq)); + tSquare_setFreq(hihat->p[0], ((2.0f + hihat->stretch) * hihat->freq)); + tSquare_setFreq(hihat->p[1], ((3.00f + hihat->stretch) * hihat->freq)); + tSquare_setFreq(hihat->p[2], ((4.16f + hihat->stretch) * hihat->freq)); + tSquare_setFreq(hihat->p[3], ((5.43f + hihat->stretch) * hihat->freq)); + tSquare_setFreq(hihat->p[4], ((6.79f + hihat->stretch) * hihat->freq)); + tSquare_setFreq(hihat->p[5], ((8.21f + hihat->stretch) * hihat->freq)); for (int i = 0; i < 6; i++) { - sample += tSquare_tick(&hihat->p[i]); + sample += tSquare_tick(hihat->p[i]); } sample *= gainScale; sample = (hihat->oscNoiseMix * sample) + ((1.0f-hihat->oscNoiseMix) * myNoise); - sample = tSVF_tick(&hihat->bandpassOsc, sample); + sample = tSVF_tick(hihat->bandpassOsc, sample); - Lfloat myGain = tEnvelope_tick(&hihat->envGain); + Lfloat myGain = tEnvelope_tick(hihat->envGain); sample *= (myGain*myGain);//square the output gain envelope - sample = tHighpass_tick(&hihat->highpass, sample); - sample += ((0.5f * tEnvelope_tick(&hihat->envStick)) * tSVF_tick(&hihat->bandpassStick, tNoise_tick(&hihat->stick))); + sample = tHighpass_tick(hihat->highpass, sample); + sample += ((0.5f * tEnvelope_tick(hihat->envStick)) * tSVF_tick(hihat->bandpassStick, tNoise_tick(hihat->stick))); sample = tanhf(sample * 2.0f); return sample; @@ -252,12 +252,12 @@ Lfloat t808Hihat_tick(t808Hihat* const hihat) void t808Hihat_setDecay(t808Hihat* const hihat, Lfloat decay) { - tEnvelope_setDecay(&hihat->envGain,decay); + tEnvelope_setDecay(hihat->envGain,decay); } void t808Hihat_setHighpassFreq(t808Hihat* const hihat, Lfloat freq) { - tHighpass_setFreq(&hihat->highpass,freq); + tHighpass_setFreq(hihat->highpass,freq); } void t808Hihat_setStretch(t808Hihat* const hihat, Lfloat stretch) @@ -272,22 +272,22 @@ void t808Hihat_setFM(t808Hihat* const hihat, Lfloat FM_amount) void t808Hihat_setOscBandpassFreq(t808Hihat* const hihat, Lfloat freq) { - tSVF_setFreq(&hihat->bandpassOsc,freq); + tSVF_setFreq(hihat->bandpassOsc,freq); } void t808Hihat_setOscBandpassQ(t808Hihat* const hihat, Lfloat Q) { - tSVF_setQ(&hihat->bandpassOsc,Q); + tSVF_setQ(hihat->bandpassOsc,Q); } void t808Hihat_setStickBandPassFreq(t808Hihat* const hihat, Lfloat freq) { - tSVF_setFreq(&hihat->bandpassStick,freq); + tSVF_setFreq(hihat->bandpassStick,freq); } void t808Hihat_setStickBandPassQ(t808Hihat* const hihat, Lfloat Q) { - tSVF_setQ(&hihat->bandpassStick,Q); + tSVF_setQ(hihat->bandpassStick,Q); } void t808Hihat_setOscFreq(t808Hihat* const hihat, Lfloat freq) @@ -299,26 +299,26 @@ void t808Hihat_setSampleRate(t808Hihat* const hihat, Lfloat sr) { for (int i = 0; i < 6; i++) { - tSquare_setSampleRate(&hihat->p[i], sr); + tSquare_setSampleRate(hihat->p[i], sr); } // need to fix SVF to be generic - tSVF_setSampleRate(&hihat->bandpassStick, sr); - tSVF_setSampleRate(&hihat->bandpassOsc, sr); + tSVF_setSampleRate(hihat->bandpassStick, sr); + tSVF_setSampleRate(hihat->bandpassOsc, sr); - tHighpass_setSampleRate(&hihat->highpass, sr); + tHighpass_setSampleRate(hihat->highpass, sr); } // ----------------- SNARE ----------------------------// -void t808Snare_init (t808Snare* const snareInst, LEAF* const leaf) +void t808Snare_init(t808Snare** const snareInst, LEAF* const leaf) { t808Snare_initToPool(snareInst, &leaf->mempool); } -void t808Snare_initToPool (t808Snare** const snareInst, tMempool* const mp) +void t808Snare_initToPool (t808Snare** const snareInst, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; t808Snare* snare = *snareInst = (t808Snare*) mpool_alloc(sizeof(t808Snare), m); snare->mempool = m; @@ -327,7 +327,7 @@ void t808Snare_initToPool (t808Snare** const snareInst, tMempool* const mp { tTriangle_initToPool(&snare->tone[i], mp); - tTriangle_setFreq(&snare->tone[i], ratio[i] * 400.0f); + tTriangle_setFreq(snare->tone[i], ratio[i] * 400.0f); tSVF_initToPool(&snare->toneLowpass[i], SVFTypeLowpass, 4000, 1.0f, mp); tEnvelope_initToPool(&snare->toneEnvOsc[i], 0.0f, 50.0f, 0, mp); tEnvelope_initToPool(&snare->toneEnvGain[i], 1.0f, 150.0f, 0, mp); @@ -371,40 +371,40 @@ void t808Snare_on(t808Snare* const snare, Lfloat vel) { for (int i = 0; i < 2; i++) { - tEnvelope_on(&snare->toneEnvOsc[i], vel); - tEnvelope_on(&snare->toneEnvGain[i], vel); - tEnvelope_on(&snare->toneEnvFilter[i], vel); + tEnvelope_on(snare->toneEnvOsc[i], vel); + tEnvelope_on(snare->toneEnvGain[i], vel); + tEnvelope_on(snare->toneEnvFilter[i], vel); } - tEnvelope_on(&snare->noiseEnvGain, vel); - tEnvelope_on(&snare->noiseEnvFilter, vel); + tEnvelope_on(snare->noiseEnvGain, vel); + tEnvelope_on(snare->noiseEnvFilter, vel); } void t808Snare_setTone1Freq(t808Snare* const snare, Lfloat freq) { snare->tone1Freq = freq; - tTriangle_setFreq(&snare->tone[0], freq); + tTriangle_setFreq(snare->tone[0], freq); } void t808Snare_setTone2Freq(t808Snare* const snare, Lfloat freq) { snare->tone2Freq = freq; - tTriangle_setFreq(&snare->tone[1],freq); + tTriangle_setFreq(snare->tone[1],freq); } void t808Snare_setTone1Decay(t808Snare* const snare, Lfloat decay) { - tEnvelope_setDecay(&snare->toneEnvGain[0],decay); + tEnvelope_setDecay(snare->toneEnvGain[0],decay); } void t808Snare_setTone2Decay(t808Snare* const snare, Lfloat decay) { - tEnvelope_setDecay(&snare->toneEnvGain[1],decay); + tEnvelope_setDecay(snare->toneEnvGain[1],decay); } void t808Snare_setNoiseDecay(t808Snare* const snare, Lfloat decay) { - tEnvelope_setDecay(&snare->noiseEnvGain,decay); + tEnvelope_setDecay(snare->noiseEnvGain,decay); } void t808Snare_setToneNoiseMix(t808Snare* const snare, Lfloat toneNoiseMix) @@ -419,7 +419,7 @@ void t808Snare_setNoiseFilterFreq(t808Snare* const snare, Lfloat noiseFilterFreq void t808Snare_setNoiseFilterQ(t808Snare* const snare, Lfloat noiseFilterQ) { - tSVF_setQ(&snare->noiseLowpass, noiseFilterQ); + tSVF_setQ(snare->noiseLowpass, noiseFilterQ); } static Lfloat tone[2]; @@ -429,16 +429,16 @@ Lfloat t808Snare_tick(t808Snare* const snare) Lfloat tone[2]; for (int i = 0; i < 2; i++) { - tTriangle_setFreq(&snare->tone[i], snare->tone1Freq + (20.0f * tEnvelope_tick(&snare->toneEnvOsc[i]))); - tone[i] = tTriangle_tick(&snare->tone[i]); + tTriangle_setFreq(snare->tone[i], snare->tone1Freq + (20.0f * tEnvelope_tick(snare->toneEnvOsc[i]))); + tone[i] = tTriangle_tick(snare->tone[i]); - tSVF_setFreq(&snare->toneLowpass[i], 2000.0f + (500.0f * tEnvelope_tick(&snare->toneEnvFilter[i]))); - tone[i] = tSVF_tick(&snare->toneLowpass[i], tone[i]) * tEnvelope_tick(&snare->toneEnvGain[i]); + tSVF_setFreq(snare->toneLowpass[i], 2000.0f + (500.0f * tEnvelope_tick(snare->toneEnvFilter[i]))); + tone[i] = tSVF_tick(snare->toneLowpass[i], tone[i]) * tEnvelope_tick(snare->toneEnvGain[i]); } - Lfloat noise = tNoise_tick(&snare->noiseOsc); - tSVF_setFreq(&snare->noiseLowpass, snare->noiseFilterFreq + (1000.0f * tEnvelope_tick(&snare->noiseEnvFilter))); - noise = tSVF_tick(&snare->noiseLowpass, noise) * tEnvelope_tick(&snare->noiseEnvGain); + Lfloat noise = tNoise_tick(snare->noiseOsc); + tSVF_setFreq(snare->noiseLowpass, snare->noiseFilterFreq + (1000.0f * tEnvelope_tick(snare->noiseEnvFilter))); + noise = tSVF_tick(snare->noiseLowpass, noise) * tEnvelope_tick(snare->noiseEnvGain); Lfloat sample = (snare->toneNoiseMix)*(tone[0] * snare->toneGain[0] + tone[1] * snare->toneGain[1]) + (1.0f-snare->toneNoiseMix) * (noise * snare->noiseGain); sample = tanhf(sample * 2.0f); @@ -449,23 +449,23 @@ void t808Snare_setSampleRate(t808Snare* const snare, Lfloat sr) { for (int i = 0; i < 2; i++) { - tTriangle_setSampleRate(&snare->tone[i], sr); - tSVF_setSampleRate(&snare->toneLowpass[i], sr); + tTriangle_setSampleRate(snare->tone[i], sr); + tSVF_setSampleRate(snare->toneLowpass[i], sr); } - tSVF_setSampleRate(&snare->noiseLowpass, sr); + tSVF_setSampleRate(snare->noiseLowpass, sr); } // ----------------- SNARE WITHOUT ENVELOPE TABLE (SMALLER) ----------------------------// -void t808SnareSmall_init (t808SnareSmall* const snareInst, LEAF* const leaf) +void t808SnareSmall_init(t808SnareSmall** const snareInst, LEAF* const leaf) { t808SnareSmall_initToPool(snareInst, &leaf->mempool); } -void t808SnareSmall_initToPool (t808SnareSmall** const snareInst, tMempool* const mp) +void t808SnareSmall_initToPool (t808SnareSmall** const snareInst, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; t808SnareSmall* snare = *snareInst = (t808SnareSmall*) mpool_alloc(sizeof(t808SnareSmall), m); snare->mempool = m; @@ -473,7 +473,7 @@ void t808SnareSmall_initToPool (t808SnareSmall** const snareInst, tMempool for (int i = 0; i < 2; i++) { tPBTriangle_initToPool(&snare->tone[i], mp); - tPBTriangle_setFreq(&snare->tone[i], ratio[i] * 400.0f); + tPBTriangle_setFreq(snare->tone[i], ratio[i] * 400.0f); tSVF_initToPool(&snare->toneLowpass[i], SVFTypeLowpass, 4000, 1.0f, mp); tADSRS_initToPool(&snare->toneEnvOsc[i], 0.0f, 50.0f, 0.0f, 50.0f, mp); tADSRS_initToPool(&snare->toneEnvGain[i], 1.0f, 150.0f, 0.0f, 50.0f, mp); @@ -517,40 +517,40 @@ void t808SnareSmall_on(t808SnareSmall* const snare, Lfloat vel) { for (int i = 0; i < 2; i++) { - tADSRS_on(&snare->toneEnvOsc[i], vel); - tADSRS_on(&snare->toneEnvGain[i], vel); - tADSRS_on(&snare->toneEnvFilter[i], vel); + tADSRS_on(snare->toneEnvOsc[i], vel); + tADSRS_on(snare->toneEnvGain[i], vel); + tADSRS_on(snare->toneEnvFilter[i], vel); } - tADSRS_on(&snare->noiseEnvGain, vel); - tADSRS_on(&snare->noiseEnvFilter, vel); + tADSRS_on(snare->noiseEnvGain, vel); + tADSRS_on(snare->noiseEnvFilter, vel); } void t808SnareSmall_setTone1Freq(t808SnareSmall* const snare, Lfloat freq) { snare->tone1Freq = freq; - tPBTriangle_setFreq(&snare->tone[0], freq); + tPBTriangle_setFreq(snare->tone[0], freq); } void t808SnareSmall_setTone2Freq(t808SnareSmall* const snare, Lfloat freq) { snare->tone2Freq = freq; - tPBTriangle_setFreq(&snare->tone[1],freq); + tPBTriangle_setFreq(snare->tone[1],freq); } void t808SnareSmall_setTone1Decay(t808SnareSmall* const snare, Lfloat decay) { - tADSRS_setDecay(&snare->toneEnvGain[0],decay); + tADSRS_setDecay(snare->toneEnvGain[0],decay); } void t808SnareSmall_setTone2Decay(t808SnareSmall* const snare, Lfloat decay) { - tADSRS_setDecay(&snare->toneEnvGain[1],decay); + tADSRS_setDecay(snare->toneEnvGain[1],decay); } void t808SnareSmall_setNoiseDecay(t808SnareSmall* const snare, Lfloat decay) { - tADSRS_setDecay(&snare->noiseEnvGain,decay); + tADSRS_setDecay(snare->noiseEnvGain,decay); } void t808SnareSmall_setToneNoiseMix(t808SnareSmall* const snare, Lfloat toneNoiseMix) @@ -565,7 +565,7 @@ void t808SnareSmall_setNoiseFilterFreq(t808SnareSmall* const snare, Lfloat noise void t808SnareSmall_setNoiseFilterQ(t808SnareSmall* const snare, Lfloat noiseFilterQ) { - tSVF_setQ(&snare->noiseLowpass, noiseFilterQ); + tSVF_setQ(snare->noiseLowpass, noiseFilterQ); } @@ -574,16 +574,16 @@ Lfloat t808SnareSmall_tick(t808SnareSmall* const snare) Lfloat tone[2]; for (int i = 0; i < 2; i++) { - tPBTriangle_setFreq(&snare->tone[i], snare->tone1Freq + (20.0f * tADSRS_tick(&snare->toneEnvOsc[i]))); - tone[i] = tPBTriangle_tick(&snare->tone[i]); + tPBTriangle_setFreq(snare->tone[i], snare->tone1Freq + (20.0f * tADSRS_tick(snare->toneEnvOsc[i]))); + tone[i] = tPBTriangle_tick(snare->tone[i]); - tSVF_setFreq(&snare->toneLowpass[i], 2000.0f + (500.0f * tADSRS_tick(&snare->toneEnvFilter[i]))); - tone[i] = tSVF_tick(&snare->toneLowpass[i], tone[i]) * tADSRS_tick(&snare->toneEnvGain[i]); + tSVF_setFreq(snare->toneLowpass[i], 2000.0f + (500.0f * tADSRS_tick(snare->toneEnvFilter[i]))); + tone[i] = tSVF_tick(snare->toneLowpass[i], tone[i]) * tADSRS_tick(snare->toneEnvGain[i]); } - Lfloat noise = tNoise_tick(&snare->noiseOsc); - tSVF_setFreq(&snare->noiseLowpass, snare->noiseFilterFreq + (1000.0f * tADSRS_tick(&snare->noiseEnvFilter))); - noise = tSVF_tick(&snare->noiseLowpass, noise) * tADSRS_tick(&snare->noiseEnvGain); + Lfloat noise = tNoise_tick(snare->noiseOsc); + tSVF_setFreq(snare->noiseLowpass, snare->noiseFilterFreq + (1000.0f * tADSRS_tick(snare->noiseEnvFilter))); + noise = tSVF_tick(snare->noiseLowpass, noise) * tADSRS_tick(snare->noiseEnvGain); Lfloat sample = (snare->toneNoiseMix)*(tone[0] * snare->toneGain[0] + tone[1] * snare->toneGain[1]) + (1.0f-snare->toneNoiseMix) * (noise * snare->noiseGain); //sample = tanhf(sample * 2.0f); @@ -594,22 +594,22 @@ void t808SnareSmall_setSampleRate(t808SnareSmall* const snare, Lfloat sr) { for (int i = 0; i < 2; i++) { - tPBTriangle_setSampleRate(&snare->tone[i], sr); - tSVF_setSampleRate(&snare->toneLowpass[i], sr); + tPBTriangle_setSampleRate(snare->tone[i], sr); + tSVF_setSampleRate(snare->toneLowpass[i], sr); } - tSVF_setSampleRate(&snare->noiseLowpass, sr); + tSVF_setSampleRate(snare->noiseLowpass, sr); } // ----------------- KICK ----------------------------// -void t808Kick_init (t808Kick* const kickInst, LEAF* const leaf) +void t808Kick_init(t808Kick** const kickInst, LEAF* const leaf) { t808Kick_initToPool(kickInst, &leaf->mempool); } -void t808Kick_initToPool (t808Kick** const kickInst, tMempool* const mp) +void t808Kick_initToPool (t808Kick** const kickInst, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; t808Kick* kick = *kickInst = (t808Kick*) mpool_alloc(sizeof(t808Kick), m); kick->mempool = m; @@ -617,7 +617,7 @@ void t808Kick_initToPool (t808Kick** const kickInst, tMempool* const mp) kick->toneInitialFreq = 40.0f; kick->sighAmountInHz = 7.0f; kick->chirpRatioMinusOne = 3.3f; - tCycle_setFreq(&kick->tone, 50.0f); + tCycle_setFreq(kick->tone, 50.0f); tSVF_initToPool(&kick->toneLowpass, SVFTypeLowpass, 2000.0f, 0.5f, mp); tEnvelope_initToPool(&kick->toneEnvOscChirp, 0.0f, 20.0f, 0, mp); tEnvelope_initToPool(&kick->toneEnvOscSigh, 0.0f, 2500.0f, 0, mp); @@ -644,20 +644,20 @@ void t808Kick_free (t808Kick** const kickInst) Lfloat t808Kick_tick (t808Kick* const kick) { - tCycle_setFreq(&kick->tone, (kick->toneInitialFreq * (1.0f + (kick->chirpRatioMinusOne * tEnvelope_tick(&kick->toneEnvOscChirp)))) + (kick->sighAmountInHz * tEnvelope_tick(&kick->toneEnvOscSigh))); - Lfloat sample = tCycle_tick(&kick->tone) * tEnvelope_tick(&kick->toneEnvGain); - sample+= tNoise_tick(&kick->noiseOsc) * tEnvelope_tick(&kick->noiseEnvGain); + tCycle_setFreq(kick->tone, (kick->toneInitialFreq * (1.0f + (kick->chirpRatioMinusOne * tEnvelope_tick(kick->toneEnvOscChirp)))) + (kick->sighAmountInHz * tEnvelope_tick(kick->toneEnvOscSigh))); + Lfloat sample = tCycle_tick(kick->tone) * tEnvelope_tick(kick->toneEnvGain); + sample+= tNoise_tick(kick->noiseOsc) * tEnvelope_tick(kick->noiseEnvGain); //add distortion here - sample = tSVF_tick(&kick->toneLowpass, sample); + sample = tSVF_tick(kick->toneLowpass, sample); return sample; } void t808Kick_on (t808Kick* const kick, Lfloat vel) { - tEnvelope_on(&kick->toneEnvOscChirp, vel); - tEnvelope_on(&kick->toneEnvOscSigh, vel); - tEnvelope_on(&kick->toneEnvGain, vel); - tEnvelope_on(&kick->noiseEnvGain, vel); + tEnvelope_on(kick->toneEnvOscChirp, vel); + tEnvelope_on(kick->toneEnvOscSigh, vel); + tEnvelope_on(kick->toneEnvGain, vel); + tEnvelope_on(kick->noiseEnvGain, vel); } void t808Kick_setToneFreq (t808Kick* const kick, Lfloat freq) @@ -668,8 +668,8 @@ void t808Kick_setToneFreq (t808Kick* const kick, Lfloat freq) void t808Kick_setToneDecay (t808Kick* const kick, Lfloat decay) { - tEnvelope_setDecay(&kick->toneEnvGain,decay); - tEnvelope_setDecay(&kick->toneEnvGain,decay * 3.0f); + tEnvelope_setDecay(kick->toneEnvGain,decay); + tEnvelope_setDecay(kick->toneEnvGain,decay * 3.0f); } @@ -677,21 +677,21 @@ void t808Kick_setSampleRate (t808Kick** const kickInst, Lfloat sr) { t808Kick* kick = *kickInst; - tCycle_setSampleRate(&kick->tone, sr); - tSVF_setSampleRate(&kick->toneLowpass, sr); + tCycle_setSampleRate(kick->tone, sr); + tSVF_setSampleRate(kick->toneLowpass, sr); } // ----------------- KICK ----------------------------// -void t808KickSmall_init (t808KickSmall* const kickInst, LEAF* const leaf) +void t808KickSmall_init(t808KickSmall** const kickInst, LEAF* const leaf) { t808KickSmall_initToPool(kickInst, &leaf->mempool); } -void t808KickSmall_initToPool (t808KickSmall** const kickInst, tMempool* const mp) +void t808KickSmall_initToPool (t808KickSmall** const kickInst, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; t808KickSmall* kick = *kickInst = (t808KickSmall*) mpool_alloc(sizeof(t808KickSmall), m); kick->mempool = m; @@ -699,7 +699,7 @@ void t808KickSmall_initToPool (t808KickSmall** const kickInst, tMempool* const m kick->toneInitialFreq = 40.0f; kick->sighAmountInHz = 7.0f; kick->chirpRatioMinusOne = 3.3f; - tCycle_setFreq(&kick->tone, 50.0f); + tCycle_setFreq(kick->tone, 50.0f); tSVF_initToPool(&kick->toneLowpass, SVFTypeLowpass, 2000.0f, 0.5f, mp); tADSRS_initToPool(&kick->toneEnvOscChirp, 0.0f, 20.0f, 0.0f, 0.0f, mp); tADSRS_initToPool(&kick->toneEnvOscSigh, 0.0f, 2500.0f, 0.0f, 0.0f, mp); @@ -726,20 +726,20 @@ void t808KickSmall_free (t808KickSmall** const kickInst) Lfloat t808KickSmall_tick (t808KickSmall* const kick) { - tCycle_setFreq(&kick->tone, (kick->toneInitialFreq * (1.0f + (kick->chirpRatioMinusOne * tADSRS_tick(&kick->toneEnvOscChirp)))) + (kick->sighAmountInHz * tADSRS_tick(&kick->toneEnvOscSigh))); - Lfloat sample = tCycle_tick(&kick->tone) * tADSRS_tick(&kick->toneEnvGain); - sample+= tNoise_tick(&kick->noiseOsc) * tADSRS_tick(&kick->noiseEnvGain); + tCycle_setFreq(kick->tone, (kick->toneInitialFreq * (1.0f + (kick->chirpRatioMinusOne * tADSRS_tick(kick->toneEnvOscChirp)))) + (kick->sighAmountInHz * tADSRS_tick(kick->toneEnvOscSigh))); + Lfloat sample = tCycle_tick(kick->tone) * tADSRS_tick(kick->toneEnvGain); + sample+= tNoise_tick(kick->noiseOsc) * tADSRS_tick(kick->noiseEnvGain); //add distortion here - sample = tSVF_tick(&kick->toneLowpass, sample); + sample = tSVF_tick(kick->toneLowpass, sample); return sample; } void t808KickSmall_on (t808KickSmall* const kick, Lfloat vel) { - tADSRS_on(&kick->toneEnvOscChirp, vel); - tADSRS_on(&kick->toneEnvOscSigh, vel); - tADSRS_on(&kick->toneEnvGain, vel); - tADSRS_on(&kick->noiseEnvGain, vel); + tADSRS_on(kick->toneEnvOscChirp, vel); + tADSRS_on(kick->toneEnvOscSigh, vel); + tADSRS_on(kick->toneEnvGain, vel); + tADSRS_on(kick->noiseEnvGain, vel); } void t808KickSmall_setToneFreq (t808KickSmall* const kick, Lfloat freq) @@ -750,15 +750,15 @@ void t808KickSmall_setToneFreq (t808KickSmall* const kick, Lfloa void t808KickSmall_setToneDecay (t808KickSmall* const kick, Lfloat decay) { - tADSRS_setDecay(&kick->toneEnvGain,decay); - tADSRS_setDecay(&kick->toneEnvGain,decay * 3.0f); + tADSRS_setDecay(kick->toneEnvGain,decay); + tADSRS_setDecay(kick->toneEnvGain,decay * 3.0f); } void t808KickSmall_setSampleRate (t808KickSmall* const kick, Lfloat sr) { - tCycle_setSampleRate(&kick->tone, sr); - tSVF_setSampleRate(&kick->toneLowpass, sr); + tCycle_setSampleRate(kick->tone, sr); + tSVF_setSampleRate(kick->toneLowpass, sr); } diff --git a/leaf/Src/leaf-mempool.c b/leaf/Src/leaf-mempool.c index 9e9b95e..38f6ac4 100644 --- a/leaf/Src/leaf-mempool.c +++ b/leaf/Src/leaf-mempool.c @@ -64,7 +64,7 @@ static inline void delink_node(mpool_node_t* node); /** * create memory pool */ -void mpool_create (char* memory, size_t size, _tMempool* pool) +void mpool_create (char* memory, size_t size, tMempool* pool) { pool->leaf->header_size = mpool_align(sizeof(mpool_node_t)); @@ -90,7 +90,7 @@ void leaf_pool_init(LEAF* const leaf, char* memory, size_t size) /** * allocate memory from memory pool */ -char* mpool_alloc(size_t asize, _tMempool* pool) +char* mpool_alloc(size_t asize, tMempool* pool) { pool->leaf->allocCount++; #if LEAF_DEBUG @@ -197,7 +197,7 @@ char* mpool_alloc(size_t asize, _tMempool* pool) /** * allocate memory from memory pool and also clear that memory to be blank */ -char* mpool_calloc(size_t asize, _tMempool* pool) +char* mpool_calloc(size_t asize, tMempool* pool) { pool->leaf->allocCount++; #if LEAF_DEBUG @@ -304,7 +304,7 @@ char* leaf_calloc(LEAF* const leaf, size_t size) return mpool_calloc(size, &leaf->_internal_mempool); } -void mpool_free(char* ptr, _tMempool* pool) +void mpool_free(char* ptr, tMempool* pool) { pool->leaf->freeCount++; #if LEAF_DEBUG @@ -385,12 +385,12 @@ void leaf_free(LEAF* const leaf, char* ptr) mpool_free(ptr, &leaf->_internal_mempool); } -size_t mpool_get_size(_tMempool* pool) +size_t mpool_get_size(tMempool* pool) { return pool->msize; } -size_t mpool_get_used(_tMempool* pool) +size_t mpool_get_used(tMempool* pool) { return pool->usize; } @@ -448,22 +448,22 @@ static inline void delink_node(mpool_node_t* node) node->prev = NULL; } -void tMempool_init(tMempool* const mp, char* memory, size_t size, LEAF* const leaf) +void tMempool_init(tMempool** const mp, char* memory, size_t size, LEAF* const leaf) { tMempool_initToPool(mp, memory, size, &leaf->mempool); } -void tMempool_free(tMempool* const mp) +void tMempool_free(tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; mpool_free((char*)m, m->mempool); } -void tMempool_initToPool (tMempool* const mp, char* memory, size_t size, tMempool* const mem) +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); + tMempool* mm = *mem; + tMempool* m = *mp = (tMempool*) mpool_alloc(sizeof(tMempool), mm); m->leaf = mm->leaf; mpool_create (memory, size, m); diff --git a/leaf/Src/leaf-midi.c b/leaf/Src/leaf-midi.c index f5f4921..963cde1 100644 --- a/leaf/Src/leaf-midi.c +++ b/leaf/Src/leaf-midi.c @@ -20,14 +20,14 @@ /* Stack */ //==================================================================================== -void tStack_init(tStack* const stack, LEAF* const leaf) +void tStack_init(tStack** const stack, LEAF* const leaf) { tStack_initToPool(stack, &leaf->mempool); } -void tStack_initToPool (tStack** const stack, tMempool* const mp) +void tStack_initToPool (tStack** const stack, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tStack* ns = *stack = (tStack*) mpool_alloc(sizeof(tStack), m); ns->mempool = m; @@ -239,14 +239,14 @@ int tStack_first(tStack* const ns) // POLY -void tPoly_init(tPoly* const polyh, int maxNumVoices, LEAF* const leaf) +void tPoly_init(tPoly** const polyh, int maxNumVoices, LEAF* const leaf) { tPoly_initToPool(polyh, maxNumVoices, &leaf->mempool); } -void tPoly_initToPool (tPoly** const polyh, int maxNumVoices, tMempool* const mp) +void tPoly_initToPool (tPoly** const polyh, int maxNumVoices, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tPoly* poly = *polyh = (tPoly*) mpool_alloc(sizeof(tPoly), m); poly->mempool = m; @@ -322,29 +322,29 @@ void tPoly_tickPitchGlide(tPoly* poly) { for (int i = 0; i < poly->maxNumVoices; ++i) { - tRamp_tick(&poly->ramps[i]); + tRamp_tick(poly->ramps[i]); } } void tPoly_tickPitchBend(tPoly* poly) { - tRamp_tick(&poly->pitchBendRamp); + tRamp_tick(poly->pitchBendRamp); } void tPoly_setPitchBend(tPoly* const poly, Lfloat pitchBend) { poly->pitchBend = pitchBend; - tRamp_setDest(&poly->pitchBendRamp, poly->pitchBend); + tRamp_setDest(poly->pitchBendRamp, poly->pitchBend); } int tPoly_noteOn(tPoly* const poly, int note, uint8_t vel) { // if not in keymap or already on stack, dont do anything. else, add that note. - if (tStack_contains(&poly->stack, note) >= 0) return -1; + if (tStack_contains(poly->stack, note) >= 0) return -1; else { tPoly_orderedAddToStack(poly, note); - tStack_add(&poly->stack, note); + tStack_add(poly->stack, note); int alteredVoice = -1; int found = 0; @@ -354,7 +354,7 @@ int tPoly_noteOn(tPoly* const poly, int note, uint8_t vel) { if (!poly->firstReceived[i] || !poly->pitchGlideIsActive) { - tRamp_setVal(&poly->ramps[i], note); + tRamp_setVal(poly->ramps[i], note); poly->firstReceived[i] = 1; } @@ -366,7 +366,7 @@ int tPoly_noteOn(tPoly* const poly, int note, uint8_t vel) poly->notes[note][0] = vel; poly->notes[note][1] = i; - tRamp_setDest(&poly->ramps[i], poly->voices[i][0]); + tRamp_setDest(poly->ramps[i], poly->voices[i][0]); alteredVoice = i; break; @@ -376,9 +376,9 @@ int tPoly_noteOn(tPoly* const poly, int note, uint8_t vel) if (!found) //steal { int whichVoice, whichNote; - for (int j = tStack_getSize(&poly->stack) - 1; j >= 0; j--) + for (int j = tStack_getSize(poly->stack) - 1; j >= 0; j--) { - whichNote = tStack_get(&poly->stack, j); + whichNote = tStack_get(poly->stack, j); whichVoice = poly->notes[whichNote][1]; if (whichVoice >= 0) { @@ -392,13 +392,13 @@ int tPoly_noteOn(tPoly* const poly, int note, uint8_t vel) if (poly->pitchGlideIsActive) { - tRamp_setTime(&poly->ramps[whichVoice], poly->glideTime); + tRamp_setTime(poly->ramps[whichVoice], poly->glideTime); } else { - tRamp_setVal(&poly->ramps[whichVoice], note); + tRamp_setVal(poly->ramps[whichVoice], note); } - tRamp_setDest(&poly->ramps[whichVoice], poly->voices[whichVoice][0]); + tRamp_setDest(poly->ramps[whichVoice], poly->voices[whichVoice][0]); alteredVoice = whichVoice; @@ -415,8 +415,8 @@ int16_t noteToTest = -1; int tPoly_noteOff(tPoly* const poly, uint8_t note) { - tStack_remove(&poly->stack, note); - tStack_remove(&poly->orderStack, note); + tStack_remove(poly->stack, note); + tStack_remove(poly->orderStack, note); poly->notes[note][0] = 0; poly->notes[note][1] = -1; @@ -446,22 +446,22 @@ int tPoly_noteOff(tPoly* const poly, uint8_t note) //grab old notes off the stack if there are notes waiting to replace the free voice if (deactivatedVoice >= 0) { - for (int j = 0; j < tStack_getSize(&poly->stack); ++j) + for (int j = 0; j < tStack_getSize(poly->stack); ++j) { - noteToTest = tStack_get(&poly->stack, j); + noteToTest = tStack_get(poly->stack, j); if (poly->notes[noteToTest][1] < 0) //if there is a stolen note waiting (marked inactive but on the stack) { poly->voices[deactivatedVoice][0] = noteToTest; //set the newly free voice to use the old stolen note if (poly->pitchGlideIsActive) { - tRamp_setTime(&poly->ramps[deactivatedVoice], poly->glideTime); + tRamp_setTime(poly->ramps[deactivatedVoice], poly->glideTime); } else { - tRamp_setVal(&poly->ramps[deactivatedVoice], noteToTest); + tRamp_setVal(poly->ramps[deactivatedVoice], noteToTest); } - tRamp_setDest(&poly->ramps[deactivatedVoice], poly->voices[deactivatedVoice][0]); + tRamp_setDest(poly->ramps[deactivatedVoice], poly->voices[deactivatedVoice][0]); poly->voices[deactivatedVoice][1] = poly->notes[noteToTest][0]; // set the velocity of the voice to be the velocity of that note poly->notes[noteToTest][1] = deactivatedVoice; //mark that it is no longer stolen and is now active return -1; @@ -476,7 +476,7 @@ void tPoly_orderedAddToStack(tPoly* const poly, uint8_t noteVal) uint8_t j; int myPitch, thisPitch, nextPitch; - tStack ns = poly->orderStack; + tStack* ns = poly->orderStack; int whereToInsert = 0; @@ -524,13 +524,13 @@ void tPoly_setPitchGlideTime(tPoly* const poly, Lfloat t) poly->glideTime = t; for (int i = 0; i < poly->maxNumVoices; ++i) { - tRamp_setTime(&poly->ramps[i], poly->glideTime); + tRamp_setTime(poly->ramps[i], poly->glideTime); } } void tPoly_setBendGlideTime(tPoly* const poly, Lfloat t) { - tRamp_setTime(&poly->pitchBendRamp, t); + tRamp_setTime(poly->pitchBendRamp, t); } void tPoly_setBendSamplesPerTick(tPoly* const poly, Lfloat t) @@ -545,12 +545,12 @@ int tPoly_getNumVoices(tPoly* const poly) int tPoly_getNumActiveVoices(tPoly* const poly) { - return LEAF_clip(0, tStack_getSize(&poly->stack), poly->numVoices); + return LEAF_clip(0, tStack_getSize(poly->stack), poly->numVoices); } Lfloat tPoly_getPitch(tPoly* const poly, uint8_t voice) { - return tRamp_sample(&poly->ramps[voice]) + tRamp_sample(&poly->pitchBendRamp); + return tRamp_sample(poly->ramps[voice]) + tRamp_sample(poly->pitchBendRamp); } int tPoly_getKey(tPoly* const poly, uint8_t voice) @@ -572,9 +572,9 @@ void tPoly_setSampleRate(tPoly* const poly, Lfloat sr) { for (int i = 0; i < poly->maxNumVoices; i++) { - tRamp_setSampleRate(&poly->ramps[i], sr); + tRamp_setSampleRate(poly->ramps[i], sr); } - tRamp_setSampleRate(&poly->pitchBendRamp, sr); + tRamp_setSampleRate(poly->pitchBendRamp, sr); } @@ -582,14 +582,14 @@ void tPoly_setSampleRate(tPoly* const poly, Lfloat sr) // SIMPLE POLY -void tSimplePoly_init(tSimplePoly* const polyh, int maxNumVoices, LEAF* const leaf) +void tSimplePoly_init(tSimplePoly** const polyh, int maxNumVoices, LEAF* const leaf) { tSimplePoly_initToPool(polyh, maxNumVoices, &leaf->mempool); } -void tSimplePoly_initToPool (tSimplePoly** const polyh, int maxNumVoices, tMempool* const mp) +void tSimplePoly_initToPool (tSimplePoly** const polyh, int maxNumVoices, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tSimplePoly* poly = *polyh = (tSimplePoly*) mpool_alloc(sizeof(tSimplePoly), m); poly->mempool = m; @@ -631,7 +631,7 @@ int tSimplePoly_noteOn(tSimplePoly* const poly, int note, uint8_t vel) { int whichVoice, whichNote, oldNote, alteredVoice; // if not in keymap or already on stack, dont do anything. else, add that note. - if (tStack_contains(&poly->stack, note) >= 0) return -1; + if (tStack_contains(poly->stack, note) >= 0) return -1; else { alteredVoice = -1; @@ -650,7 +650,7 @@ int tSimplePoly_noteOn(tSimplePoly* const poly, int note, uint8_t vel) poly->voices[i][2] = note; // voices[i][2] is the output midi note, (avoiding the -1 when a voice is inactive) alteredVoice = i; - tStack_add(&poly->stack, note); + tStack_add(poly->stack, note); break; } } @@ -671,16 +671,16 @@ int tSimplePoly_noteOn(tSimplePoly* const poly, int note, uint8_t vel) poly->voices[i][2] = note; // voices[i][2] is the output midi note, (avoiding the -1 when a voice is inactive) alteredVoice = i; - tStack_add(&poly->stack, note); + tStack_add(poly->stack, note); break; } } } if ((!found) && (poly->stealing_on)) //steal { - for (int j = tStack_getSize(&poly->stack) - 1; j >= 0; j--) + for (int j = tStack_getSize(poly->stack) - 1; j >= 0; j--) { - whichNote = tStack_get(&poly->stack, j); + whichNote = tStack_get(poly->stack, j); whichVoice = poly->notes[whichNote][0]; if (whichVoice >= 0) { @@ -694,7 +694,7 @@ int tSimplePoly_noteOn(tSimplePoly* const poly, int note, uint8_t vel) poly->voices[whichVoice][2] = note; alteredVoice = whichVoice; - tStack_add(&poly->stack, note); + tStack_add(poly->stack, note); break; } } @@ -708,7 +708,7 @@ int tSimplePoly_noteOff(tSimplePoly* const poly, uint8_t note) { int16_t noteToTest = -1; - tStack_remove(&poly->stack, note); + tStack_remove(poly->stack, note); poly->notes[note][0] = -1; int deactivatedVoice = -1; @@ -728,9 +728,9 @@ int tSimplePoly_noteOff(tSimplePoly* const poly, uint8_t note) //grab old notes off the stack if there are notes waiting to replace the free voice if (deactivatedVoice >= 0) { - for (int j = 0; j < tStack_getSize(&poly->stack); ++j) + for (int j = 0; j < tStack_getSize(poly->stack); ++j) { - noteToTest = tStack_get(&poly->stack, j); + noteToTest = tStack_get(poly->stack, j); if (poly->notes[noteToTest][0] == -3) //if there is a stolen note waiting (marked inactive but on the stack) { @@ -756,9 +756,9 @@ void tSimplePoly_deactivateVoice(tSimplePoly* const poly, uint8_t voice) if (poly->recover_stolen) { //grab old notes off the stack if there are notes waiting to replace the free voice - for (int j = 0; j < tStack_getSize(&poly->stack); ++j) + for (int j = 0; j < tStack_getSize(poly->stack); ++j) { - noteToTest = tStack_get(&poly->stack, j); //note to check if it is waiting to be recovered + noteToTest = tStack_get(poly->stack, j); //note to check if it is waiting to be recovered if (poly->notes[noteToTest][0] == -3) //if there is a stolen note waiting (marked inactive but on the stack) { @@ -793,7 +793,7 @@ int tSimplePoly_markPendingNoteOff(tSimplePoly* const poly, uint8_t note) { int deactivatedVoice = -1; - if (tStack_remove(&poly->stack, note)) + if (tStack_remove(poly->stack, note)) { poly->notes[note][0] = -2; @@ -824,7 +824,7 @@ int tSimplePoly_getNumVoices(tSimplePoly* const poly) int tSimplePoly_getNumActiveVoices(tSimplePoly* const poly) { - return LEAF_clip(0, tStack_getSize(&poly->stack), poly->numVoices); + return LEAF_clip(0, tStack_getSize(poly->stack), poly->numVoices); } diff --git a/leaf/Src/leaf-oscillators.c b/leaf/Src/leaf-oscillators.c index 0863829..422d558 100644 --- a/leaf/Src/leaf-oscillators.c +++ b/leaf/Src/leaf-oscillators.c @@ -47,14 +47,14 @@ static inline float blamp(float t, float dt) { #if LEAF_INCLUDE_SINE_TABLE // Cycle -void tCycle_init(tCycle* const cy, LEAF* const leaf) +void tCycle_init(tCycle** const cy, LEAF* const leaf) { tCycle_initToPool(cy, &leaf->mempool); } -void tCycle_initToPool (tCycle** const cy, tMempool* const mp) +void tCycle_initToPool (tCycle** const cy, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tCycle* c = *cy = (tCycle*) mpool_alloc(sizeof(tCycle), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -121,14 +121,14 @@ void tCycle_setSampleRate (tCycle* const c, Lfloat sr) #if LEAF_INCLUDE_TRIANGLE_TABLE //======================================================================== /* Triangle */ -void tTriangle_init(tTriangle* const cy, LEAF* const leaf) +void tTriangle_init(tTriangle** const cy, LEAF* const leaf) { tTriangle_initToPool(cy, &leaf->mempool); } -void tTriangle_initToPool (tTriangle** const cy, tMempool* const mp) +void tTriangle_initToPool (tTriangle** const cy, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tTriangle* c = *cy = (tTriangle*) mpool_alloc(sizeof(tTriangle), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -208,14 +208,14 @@ void tTriangle_setSampleRate (tTriangle* c, Lfloat sr) #if LEAF_INCLUDE_SQUARE_TABLE //======================================================================== /* Square */ -void tSquare_init(tSquare* const cy, LEAF* const leaf) +void tSquare_init(tSquare** const cy, LEAF* const leaf) { tSquare_initToPool(cy, &leaf->mempool); } -void tSquare_initToPool (tSquare** const cy, tMempool* const mp) +void tSquare_initToPool (tSquare** const cy, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tSquare* c = *cy = (tSquare*) mpool_alloc(sizeof(tSquare), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -298,14 +298,14 @@ void tSquare_setSampleRate (tSquare* c, Lfloat sr) #if LEAF_INCLUDE_SAWTOOTH_TABLE //===================================================================== // Sawtooth -void tSawtooth_init(tSawtooth* const cy, LEAF* const leaf) +void tSawtooth_init(tSawtooth** const cy, LEAF* const leaf) { tSawtooth_initToPool(cy, &leaf->mempool); } -void tSawtooth_initToPool (tSawtooth** const cy, tMempool* const mp) +void tSawtooth_initToPool (tSawtooth** const cy, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tSawtooth* c = *cy = (tSawtooth*) mpool_alloc(sizeof(tSawtooth), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -390,14 +390,14 @@ void tSawtooth_setSampleRate (tSawtooth* c, Lfloat sr) //============================================================================== /* tTri: Anti-aliased Triangle waveform. */ -void tPBTriangle_init (tPBTriangle* const osc, LEAF* const leaf) +void tPBTriangle_init(tPBTriangle** const osc, LEAF* const leaf) { tPBTriangle_initToPool(osc, &leaf->mempool); } -void tPBTriangle_initToPool (tPBTriangle** const osc, tMempool* const mp) +void tPBTriangle_initToPool (tPBTriangle** const osc, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tPBTriangle* c = *osc = (tPBTriangle*) mpool_alloc(sizeof(tPBTriangle), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -485,14 +485,14 @@ void tPBTriangle_setSampleRate (tPBTriangle* c, Lfloat sr) //============================================================================== /* tPBSineTriangle: Anti-aliased Triangle waveform with sine wave, crossfaded between them with shape param. */ -void tPBSineTriangle_init (tPBSineTriangle* const osc, LEAF* const leaf) +void tPBSineTriangle_init(tPBSineTriangle** const osc, LEAF* const leaf) { tPBSineTriangle_initToPool(osc, &leaf->mempool); } -void tPBSineTriangle_initToPool (tPBSineTriangle** const osc, tMempool* const mp) +void tPBSineTriangle_initToPool (tPBSineTriangle** const osc, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tPBSineTriangle* c = *osc = (tPBSineTriangle*) mpool_alloc(sizeof(tPBSineTriangle), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -539,7 +539,7 @@ Lfloat tPBSineTriangle_tick (tPBSineTriangle* const c) y += 4.0f * incFloat * (blamp(t1F, incFloat) - blamp(t2F, incFloat)); y = y * c->shape; // shape handles the inversion so it's in phase with sine (already * -1.0f) - y = y + (tCycle_tick(&c->sine) * c->oneMinusShape); + y = y + (tCycle_tick(c->sine) * c->oneMinusShape); c->phase += c->inc; @@ -554,7 +554,7 @@ void tPBSineTriangle_setFreq (tPBSineTriangle* const c, Lfloat freq) { c->freq = freq; c->inc = freq * c->invSampleRateTimesTwoTo32; - tCycle_setFreq(&c->sine, freq); + tCycle_setFreq(c->sine, freq); } void tPBSineTriangle_setShape (tPBSineTriangle* const c, Lfloat shape) @@ -573,14 +573,14 @@ void tPBSineTriangle_setSampleRate (tPBSineTriangle* const c, Lfloat sr) //============================================================================== /* tPulse: Anti-aliased pulse waveform. */ -void tPBPulse_init (tPBPulse* const osc, LEAF* const leaf) +void tPBPulse_init(tPBPulse** const osc, LEAF* const leaf) { tPBPulse_initToPool(osc, &leaf->mempool); } -void tPBPulse_initToPool (tPBPulse** const osc, tMempool* const mp) +void tPBPulse_initToPool (tPBPulse** const osc, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tPBPulse* c = *osc = (tPBPulse*) mpool_alloc(sizeof(tPBPulse), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -659,14 +659,14 @@ void tPBPulse_setSampleRate (tPBPulse* const c, Lfloat sr) //============================================================================== /* tSawtooth: Anti-aliased Sawtooth waveform. */ -void tPBSaw_init (tPBSaw* const osc, LEAF* const leaf) +void tPBSaw_init(tPBSaw** const osc, LEAF* const leaf) { tPBSaw_initToPool(osc, &leaf->mempool); } -void tPBSaw_initToPool (tPBSaw** const osc, tMempool* const mp) +void tPBSaw_initToPool (tPBSaw** const osc, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tPBSaw* c = *osc = (tPBSaw*) mpool_alloc(sizeof(tPBSaw), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -721,14 +721,14 @@ void tPBSaw_setSampleRate (tPBSaw* const c, Lfloat sr) /* tSawtooth: Anti-aliased Sawtooth waveform. */ -void tPBSawSquare_init (tPBSawSquare* const osc, LEAF* const leaf) +void tPBSawSquare_init(tPBSawSquare** const osc, LEAF* const leaf) { tPBSawSquare_initToPool(osc, &leaf->mempool); } -void tPBSawSquare_initToPool (tPBSawSquare** const osc, tMempool* const mp) +void tPBSawSquare_initToPool (tPBSawSquare** const osc, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tPBSawSquare* c = *osc = (tPBSawSquare*) mpool_alloc(sizeof(tPBSawSquare), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -809,14 +809,14 @@ void tPBSawSquare_setSampleRate (tPBSawSquare* const c, Lfloat sr) //============================================================================== /* tSawtooth: Anti-aliased Sawtooth waveform. */ -void tSawOS_init (tSawOS* const osc, uint8_t OS_ratio, uint8_t filterOrder, LEAF* const leaf) +void tSawOS_init(tSawOS** const osc, uint8_t OS_ratio, uint8_t filterOrder, LEAF* const leaf) { tSawOS_initToPool(osc, OS_ratio, filterOrder, &leaf->mempool); } -void tSawOS_initToPool (tSawOS** const osc, uint8_t OS_ratio, uint8_t filterOrder, tMempool* const mp) +void tSawOS_initToPool (tSawOS** const osc, uint8_t OS_ratio, uint8_t filterOrder, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tSawOS* c = *osc = (tSawOS*) mpool_alloc(sizeof(tSawOS), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -826,13 +826,13 @@ void tSawOS_initToPool (tSawOS** const osc, uint8_t OS_ratio, uint8_t filt c->invSampleRateOS = 1.0f / (leaf->sampleRate * OS_ratio); c->invSampleRateTimesTwoTo32OS = (c->invSampleRateOS * TWO_TO_32); c->filterOrder = filterOrder; - c->aaFilter = (tSVF*) mpool_alloc(sizeof(tSVF) * filterOrder, m); + c->aaFilters = (tSVF**) mpool_alloc(sizeof(tSVF*) * filterOrder, m); for (int i = 0; i < filterOrder; i++) { Lfloat Qval = 0.5f/cosf((1.0f+2.0f*i)*PI/(4*filterOrder)); - tSVF_initToPool(&c->aaFilter[i], SVFTypeLowpass, (19000.0f / OS_ratio), Qval, mp); + tSVF_initToPool(&c->aaFilters[i], SVFTypeLowpass, (19000.0f / OS_ratio), Qval, mp); } tSawOS_setFreq(c, 220.0f); } @@ -840,8 +840,8 @@ void tSawOS_initToPool (tSawOS** const osc, uint8_t OS_ratio, uint8_t filt void tSawOS_free (tSawOS** const osc) { tSawOS* c = *osc; - for (int i = 0; i < c->filterOrder; ++i) tSVF_free(&c->aaFilter[i]); - mpool_free((char*)c->aaFilter, c->mempool); + for (int i = 0; i < c->filterOrder; ++i) tSVF_free(&c->aaFilters[i]); + mpool_free((char*)c->aaFilters, c->mempool); mpool_free((char*)c, c->mempool); } @@ -854,7 +854,7 @@ Lfloat tSawOS_tick (tSawOS* const c) tempFloat = (c->phase * INV_TWO_TO_16)- 1.0f; // inv 2 to 32, then multiplied by 2, same as inv 2 to 16 for (int k = 0; k < c->filterOrder; k++) { - tempFloat = tSVF_tick(&c->aaFilter[k], tempFloat); + tempFloat = tSVF_tick(c->aaFilters[k], tempFloat); } } return tempFloat; @@ -876,14 +876,14 @@ void tSawOS_setSampleRate (tSawOS* const c, Lfloat sr) /* Phasor */ -void tPhasor_init(tPhasor* const ph, LEAF* const leaf) +void tPhasor_init(tPhasor** const ph, LEAF* const leaf) { tPhasor_initToPool(ph, &leaf->mempool); } -void tPhasor_initToPool (tPhasor** const ph, tMempool* const mp) +void tPhasor_initToPool (tPhasor** const ph, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tPhasor* p = *ph = (tPhasor*) mpool_alloc(sizeof(tPhasor), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -922,14 +922,14 @@ void tPhasor_setSampleRate (tPhasor* const p, Lfloat sr) //======================================================================== /* Noise */ -void tNoise_init(tNoise* const ns, NoiseType type, LEAF* const leaf) +void tNoise_init(tNoise** const ns, NoiseType type, LEAF* const leaf) { tNoise_initToPool(ns, type, &leaf->mempool); } -void tNoise_initToPool (tNoise** const ns, NoiseType type, tMempool* const mp) +void tNoise_initToPool (tNoise** const ns, NoiseType type, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tNoise* n = *ns = (tNoise*) mpool_alloc(sizeof(tNoise), m); n->mempool = m; LEAF* leaf = n->mempool->leaf; @@ -967,21 +967,21 @@ Lfloat tNoise_tick(tNoise* const n) //================================================================================= /* Neuron */ -void tNeuron_init(tNeuron* const nr, LEAF* const leaf) +void tNeuron_init(tNeuron** const nr, LEAF* const leaf) { tNeuron_initToPool(nr, &leaf->mempool); } -void tNeuron_initToPool (tNeuron** const nr, tMempool* const mp) +void tNeuron_initToPool (tNeuron** const nr, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tNeuron* n = *nr = (tNeuron*) mpool_alloc(sizeof(tNeuron), m); n->mempool = m; LEAF* leaf = n->mempool->leaf; tPoleZero_initToPool(&n->f, mp); - tPoleZero_setBlockZero(&n->f, 0.99f); + tPoleZero_setBlockZero(n->f, 0.99f); n->invSampleRate = leaf->invSampleRate; n->timeStep = (44100.0f * n->invSampleRate) / 50.0f; @@ -1017,7 +1017,7 @@ void tNeuron_free (tNeuron** const nr) void tNeuron_reset(tNeuron* const n) { - tPoleZero_setBlockZero(&n->f, 0.99f); + tPoleZero_setBlockZero(n->f, 0.99f); n->timeStep = (44100.0f * n->invSampleRate) / 50.0f; @@ -1152,7 +1152,7 @@ Lfloat tNeuron_tick(tNeuron* const n) //set the output voltage to the "step" ugen, which controls the DAC. output = n->voltage * 0.01f; // volts - output = tPoleZero_tick(&n->f, output); + output = tPoleZero_tick(n->f, output); return output; @@ -1176,14 +1176,14 @@ void tNeuron_setSampleRate (tNeuron* const n, Lfloat sr) //---------------------------------------------------------------------------------------------------------- -void tMBPulse_init(tMBPulse* const osc, LEAF* const leaf) +void tMBPulse_init(tMBPulse** const osc, LEAF* const leaf) { tMBPulse_initToPool(osc, &leaf->mempool); } -void tMBPulse_initToPool(tMBPulse** const osc, tMempool* const pool) +void tMBPulse_initToPool(tMBPulse** const osc, tMempool** const pool) { - _tMempool* m = *pool; + tMempool* m = *pool; tMBPulse* c = *osc = (tMBPulse*) mpool_alloc(sizeof(tMBPulse), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -1512,14 +1512,14 @@ void tMBPulse_setSampleRate(tMBPulse* const c, Lfloat sr) //========================================================================================================== //========================================================================================================== -void tMBTriangle_init(tMBTriangle* const osc, LEAF* const leaf) +void tMBTriangle_init(tMBTriangle** const osc, LEAF* const leaf) { tMBTriangle_initToPool(osc, &leaf->mempool); } -void tMBTriangle_initToPool(tMBTriangle** const osc, tMempool* const pool) +void tMBTriangle_initToPool(tMBTriangle** const osc, tMempool** const pool) { - _tMempool* m = *pool; + tMempool* m = *pool; tMBTriangle* c = *osc = (tMBTriangle*) mpool_alloc(sizeof(tMBTriangle), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -1867,14 +1867,14 @@ void tMBTriangle_setSampleRate(tMBTriangle* const c, Lfloat sr) //========================================================================================================== -void tMBSineTri_init(tMBSineTri* const osc, LEAF* const leaf) +void tMBSineTri_init(tMBSineTri** const osc, LEAF* const leaf) { tMBSineTri_initToPool(osc, &leaf->mempool); } -void tMBSineTri_initToPool(tMBSineTri** const osc, tMempool* const pool) +void tMBSineTri_initToPool(tMBSineTri** const osc, tMempool** const pool) { - _tMempool* m = *pool; + tMempool* m = *pool; tMBSineTri* c = *osc = (tMBSineTri*) mpool_alloc(sizeof(tMBSineTri), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -2268,14 +2268,14 @@ void tMBSineTri_setSampleRate(tMBSineTri* const c, Lfloat sr) //================================================================================================== //================================================================================================== -void tMBSaw_init(tMBSaw* const osc, LEAF* const leaf) +void tMBSaw_init(tMBSaw** const osc, LEAF* const leaf) { tMBSaw_initToPool(osc, &leaf->mempool); } -void tMBSaw_initToPool(tMBSaw** const osc, tMempool* const pool) +void tMBSaw_initToPool(tMBSaw** const osc, tMempool** const pool) { - _tMempool* m = *pool; + tMempool* m = *pool; tMBSaw* c = *osc = (tMBSaw*) mpool_alloc(sizeof(tMBSaw), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -2476,14 +2476,14 @@ void tMBSaw_setSampleRate(tMBSaw* const c, Lfloat sr) //================================================================================================== -void tMBSawPulse_init(tMBSawPulse* const osc, LEAF* const leaf) +void tMBSawPulse_init(tMBSawPulse** const osc, LEAF* const leaf) { tMBSawPulse_initToPool(osc, &leaf->mempool); } -void tMBSawPulse_initToPool(tMBSawPulse** const osc, tMempool* const pool) +void tMBSawPulse_initToPool(tMBSawPulse** const osc, tMempool** const pool) { - _tMempool* m = *pool; + tMempool* m = *pool; tMBSawPulse* c = *osc = (tMBSawPulse*) mpool_alloc(sizeof(tMBSawPulse), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -2860,14 +2860,14 @@ void tMBSawPulse_setSampleRate(tMBSawPulse* const c, Lfloat sr) // WaveTable -void tTable_init(tTable* const cy, Lfloat* waveTable, int size, LEAF* const leaf) +void tTable_init(tTable** const cy, Lfloat* waveTable, int size, LEAF* const leaf) { tTable_initToPool(cy, waveTable, size, &leaf->mempool); } -void tTable_initToPool(tTable** const cy, Lfloat* waveTable, int size, tMempool* const mp) +void tTable_initToPool(tTable** const cy, Lfloat* waveTable, int size, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tTable* c = *cy = (tTable*)mpool_alloc(sizeof(tTable), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -2926,14 +2926,14 @@ void tTable_setSampleRate(tTable* const c, Lfloat sr) tTable_setFreq(c, c->freq); } -void tWaveTable_init(tWaveTable* const cy, Lfloat* table, int size, Lfloat maxFreq, LEAF* const leaf) +void tWaveTable_init(tWaveTable** const cy, Lfloat* table, int size, Lfloat maxFreq, LEAF* const leaf) { tWaveTable_initToPool(cy, table, size, maxFreq, &leaf->mempool); } -void tWaveTable_initToPool(tWaveTable** const cy, Lfloat* table, int size, Lfloat maxFreq, tMempool* const mp) +void tWaveTable_initToPool(tWaveTable** const cy, Lfloat* table, int size, Lfloat maxFreq, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tWaveTable* c = *cy = (tWaveTable*) mpool_alloc(sizeof(tWaveTable), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -2979,7 +2979,7 @@ void tWaveTable_initToPool(tWaveTable** const cy, Lfloat* table, int size, Lfloa tButterworth_initToPool(&c->bl, 8, -1.0f, f, mp); for (int t = 1; t < c->numTables; ++t) { - tButterworth_setF2(&c->bl, f); + tButterworth_setF2(c->bl, f); // Do several passes here to prevent errors at the beginning of the waveform // Not sure how many passes to do, seem to need more as the filter cutoff goes down // 12 might be excessive but seems to work for now. @@ -2987,7 +2987,7 @@ void tWaveTable_initToPool(tWaveTable** const cy, Lfloat* table, int size, Lfloa { for (int i = 0; i < c->size; ++i) { - c->tables[t][i] = tButterworth_tick(&c->bl, c->tables[t-1][i]); + c->tables[t][i] = tButterworth_tick(c->bl, c->tables[t-1][i]); } } f *= 0.5f; //halve the cutoff for next pass @@ -3045,10 +3045,10 @@ void tWaveTable_setSampleRate(tWaveTable* const c, Lfloat sr) f = c->sampleRate * 0.25f; //start at half nyquist // Not worth going over order 8 I think, and even 8 is only marginally better than 4. tButterworth_initToPool(&c->bl, 8, -1.0f, f, &c->mempool); - tButterworth_setSampleRate(&c->bl, c->sampleRate); + tButterworth_setSampleRate(c->bl, c->sampleRate); for (int t = 1; t < c->numTables; ++t) { - tButterworth_setF2(&c->bl, f); + tButterworth_setF2(c->bl, f); // Do several passes here to prevent errors at the beginning of the waveform // Not sure how many passes to do, seem to need more as the filter cutoff goes down // 12 might be excessive but seems to work for now. @@ -3056,7 +3056,7 @@ void tWaveTable_setSampleRate(tWaveTable* const c, Lfloat sr) { for (int i = 0; i < c->size; ++i) { - c->tables[t][i] = tButterworth_tick(&c->bl, c->tables[t-1][i]); + c->tables[t][i] = tButterworth_tick(c->bl, c->tables[t-1][i]); } } f *= 0.5f; //halve the cutoff for next pass @@ -3067,14 +3067,14 @@ void tWaveTable_setSampleRate(tWaveTable* const c, Lfloat sr) //================================================================================================ //================================================================================================ -void tWaveOsc_init(tWaveOsc* const cy, tWaveTable* tables, int numTables, LEAF* const leaf) +void tWaveOsc_init(tWaveOsc** const cy, tWaveTable** tables, int numTables, LEAF* const leaf) { tWaveOsc_initToPool(cy, tables, numTables, &leaf->mempool); } -void tWaveOsc_initToPool(tWaveOsc** const cy, tWaveTable* tables, int numTables, tMempool* const mp) +void tWaveOsc_initToPool(tWaveOsc** const cy, tWaveTable** tables, int numTables, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tWaveOsc* c = *cy = (tWaveOsc*) mpool_alloc(sizeof(tWaveOsc), m); c->mempool = m; @@ -3255,14 +3255,14 @@ void tWaveOsc_setSampleRate(tWaveOsc* const c, Lfloat sr) //======================================================================================= //======================================================================================= -void tWaveTableS_init(tWaveTableS* const cy, Lfloat* table, int size, Lfloat maxFreq, LEAF* const leaf) +void tWaveTableS_init(tWaveTableS** const cy, Lfloat* table, int size, Lfloat maxFreq, LEAF* const leaf) { tWaveTableS_initToPool(cy, table, size, maxFreq, &leaf->mempool); } -void tWaveTableS_initToPool(tWaveTableS** const cy, Lfloat* table, int size, Lfloat maxFreq, tMempool* const mp) +void tWaveTableS_initToPool(tWaveTableS** const cy, Lfloat* table, int size, Lfloat maxFreq, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tWaveTableS* c = *cy = (tWaveTableS*) mpool_alloc(sizeof(tWaveTableS), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -3320,20 +3320,20 @@ void tWaveTableS_initToPool(tWaveTableS** const cy, Lfloat* table, int size, Lfl { for (int i = 0; i < c->sizes[t]; ++i) { - c->dsBuffer[0] = tButterworth_tick(&c->bl, c->tables[t-1][i*2]); - c->dsBuffer[1] = tButterworth_tick(&c->bl, c->tables[t-1][(i*2)+1]); - c->tables[t][i] = tOversampler_downsample(&c->ds, c->dsBuffer); + c->dsBuffer[0] = tButterworth_tick(c->bl, c->tables[t-1][i*2]); + c->dsBuffer[1] = tButterworth_tick(c->bl, c->tables[t-1][(i*2)+1]); + c->tables[t][i] = tOversampler_downsample(c->ds, c->dsBuffer); } } } else { - tButterworth_setF2(&c->bl, f); + tButterworth_setF2(c->bl, f); for (int p = 0; p < LEAF_NUM_WAVETABLE_FILTER_PASSES; ++p) { for (int i = 0; i < c->sizes[t]; ++i) { - c->tables[t][i] = tButterworth_tick(&c->bl, c->tables[t-1][i]); + c->tables[t][i] = tButterworth_tick(c->bl, c->tables[t-1][i]); } } f *= 0.5f; //halve the cutoff for next pass @@ -3414,20 +3414,20 @@ void tWaveTableS_setSampleRate(tWaveTableS* const c, Lfloat sr) { for (int i = 0; i < c->sizes[t]; ++i) { - c->dsBuffer[0] = tButterworth_tick(&c->bl, c->tables[t-1][i*2]); - c->dsBuffer[1] = tButterworth_tick(&c->bl, c->tables[t-1][(i*2)+1]); - c->tables[t][i] = tOversampler_downsample(&c->ds, c->dsBuffer); + c->dsBuffer[0] = tButterworth_tick(c->bl, c->tables[t-1][i*2]); + c->dsBuffer[1] = tButterworth_tick(c->bl, c->tables[t-1][(i*2)+1]); + c->tables[t][i] = tOversampler_downsample(c->ds, c->dsBuffer); } } } else { - tButterworth_setF2(&c->bl, f); + tButterworth_setF2(c->bl, f); for (int p = 0; p < LEAF_NUM_WAVETABLE_FILTER_PASSES; ++p) { for (int i = 0; i < c->sizes[t]; ++i) { - c->tables[t][i] = tButterworth_tick(&c->bl, c->tables[t-1][i]); + c->tables[t][i] = tButterworth_tick(c->bl, c->tables[t-1][i]); } } f *= 0.5f; //halve the cutoff for next pass @@ -3440,14 +3440,14 @@ void tWaveTableS_setSampleRate(tWaveTableS* const c, Lfloat sr) //================================================================================================ //================================================================================================ -void tWaveOscS_init(tWaveOscS* const cy, tWaveTableS* tables, int numTables, LEAF* const leaf) +void tWaveOscS_init(tWaveOscS** const cy, tWaveTableS** tables, int numTables, LEAF* const leaf) { tWaveOscS_initToPool(cy, tables, numTables, &leaf->mempool); } -void tWaveOscS_initToPool(tWaveOscS** const cy, tWaveTableS* tables, int numTables, tMempool* const mp) +void tWaveOscS_initToPool(tWaveOscS** const cy, tWaveTableS** tables, int numTables, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tWaveOscS* c = *cy = (tWaveOscS*) mpool_alloc(sizeof(tWaveOscS), m); c->mempool = m; @@ -3628,14 +3628,14 @@ void tWaveOscS_setSampleRate(tWaveOscS* const c, Lfloat sr) //beep boop adding intphasro // Cycle -void tIntPhasor_init(tIntPhasor* const cy, LEAF* const leaf) +void tIntPhasor_init(tIntPhasor** const cy, LEAF* const leaf) { tIntPhasor_initToPool(cy, &leaf->mempool); } -void tIntPhasor_initToPool (tIntPhasor** const cy, tMempool* const mp) +void tIntPhasor_initToPool (tIntPhasor** const cy, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tIntPhasor* c = *cy = (tIntPhasor*) mpool_alloc(sizeof(tIntPhasor), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -3689,14 +3689,14 @@ void tIntPhasor_setSampleRate (tIntPhasor* const c, Lfloat sr) } //////SQUARE(PUSHER)LFO -void tSquareLFO_init(tSquareLFO* const cy, LEAF* const leaf) +void tSquareLFO_init(tSquareLFO** const cy, LEAF* const leaf) { tSquareLFO_initToPool(cy, &leaf->mempool); } -void tSquareLFO_initToPool (tSquareLFO** const cy, tMempool* const mp) +void tSquareLFO_initToPool (tSquareLFO** const cy, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tSquareLFO* c = *cy = (tSquareLFO*) mpool_alloc(sizeof(tSquareLFO), m); c->mempool = m; tIntPhasor_initToPool(&c->phasor,mp); @@ -3716,47 +3716,47 @@ void tSquareLFO_free (tSquareLFO** const cy) Lfloat tSquareLFO_tick(tSquareLFO* const c) { // Phasor increment - Lfloat a = tIntPhasor_tick(&c->phasor); - Lfloat b = tIntPhasor_tick(&c->invPhasor); + Lfloat a = tIntPhasor_tick(c->phasor); + Lfloat b = tIntPhasor_tick(c->invPhasor); Lfloat tmp = ((a - b)) + c->pulsewidth - 0.5f; return 2 * tmp; } void tSquareLFO_setFreq(tSquareLFO* const c, Lfloat freq) { - tIntPhasor_setFreq(&c->phasor,freq); - tIntPhasor_setFreq(&c->invPhasor,freq); + tIntPhasor_setFreq(c->phasor,freq); + tIntPhasor_setFreq(c->invPhasor,freq); } void tSquareLFO_setSampleRate (tSquareLFO* const c, Lfloat sr) { - tIntPhasor_setSampleRate(&c->phasor, sr); - tIntPhasor_setSampleRate(&c->invPhasor, sr); + tIntPhasor_setSampleRate(c->phasor, sr); + tIntPhasor_setSampleRate(c->invPhasor, sr); } void tSquareLFO_setPulseWidth(tSquareLFO* const c, Lfloat pw) { c->pulsewidth = pw; - tIntPhasor_setPhase(&c->invPhasor, c->pulsewidth + (c->phasor->phase * INV_TWO_TO_32)); + tIntPhasor_setPhase(c->invPhasor, c->pulsewidth + (c->phasor->phase * INV_TWO_TO_32)); } void tSquareLFO_setPhase(tSquareLFO* const c, Lfloat phase) { - tIntPhasor_setPhase(&c->phasor, phase); - tIntPhasor_setPhase(&c->invPhasor, c->pulsewidth + (c->phasor->phase * INV_TWO_TO_32)); + tIntPhasor_setPhase(c->phasor, phase); + tIntPhasor_setPhase(c->invPhasor, c->pulsewidth + (c->phasor->phase * INV_TWO_TO_32)); } -void tSawSquareLFO_init (tSawSquareLFO* const cy, LEAF* const leaf) +void tSawSquareLFO_init(tSawSquareLFO** const cy, LEAF* const leaf) { tSawSquareLFO_initToPool(cy, &leaf->mempool); } -void tSawSquareLFO_initToPool (tSawSquareLFO** const cy, tMempool* const mp) +void tSawSquareLFO_initToPool (tSawSquareLFO** const cy, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tSawSquareLFO* c = *cy = (tSawSquareLFO*) mpool_alloc(sizeof(tSawSquareLFO), m); c->mempool = m; tSquareLFO_initToPool(&c->square,mp); @@ -3772,24 +3772,24 @@ void tSawSquareLFO_free (tSawSquareLFO** const cy) Lfloat tSawSquareLFO_tick (tSawSquareLFO* const c) { - Lfloat a = (tIntPhasor_tick(&c->saw) - 0.5f ) * 2.0f; - Lfloat b = tSquareLFO_tick(&c->square); + Lfloat a = (tIntPhasor_tick(c->saw) - 0.5f ) * 2.0f; + Lfloat b = tSquareLFO_tick(c->square); return (1 - c->shape) * a + c->shape * b; } void tSawSquareLFO_setFreq (tSawSquareLFO* const c, Lfloat freq) { - tSquareLFO_setFreq(&c->square, freq); - tIntPhasor_setFreq(&c->saw, freq); + tSquareLFO_setFreq(c->square, freq); + tIntPhasor_setFreq(c->saw, freq); } void tSawSquareLFO_setSampleRate (tSawSquareLFO* const c, Lfloat sr) { - tSquareLFO_setSampleRate(&c->square, sr); - tIntPhasor_setSampleRate(&c->saw, sr); + tSquareLFO_setSampleRate(c->square, sr); + tIntPhasor_setSampleRate(c->saw, sr); } void tSawSquareLFO_setPhase (tSawSquareLFO* const c, Lfloat phase) { - tSquareLFO_setPhase(&c->square, phase); - tIntPhasor_setPhase(&c->saw, phase); + tSquareLFO_setPhase(c->square, phase); + tIntPhasor_setPhase(c->saw, phase); } @@ -3800,14 +3800,14 @@ void tSawSquareLFO_setShape (tSawSquareLFO* const c, Lfloat shape) ///tri -void tTriLFO_init(tTriLFO* const cy, LEAF* const leaf) +void tTriLFO_init(tTriLFO** const cy, LEAF* const leaf) { tTriLFO_initToPool(cy, &leaf->mempool); } -void tTriLFO_initToPool (tTriLFO** const cy, tMempool* const mp) +void tTriLFO_initToPool (tTriLFO** const cy, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tTriLFO* c = *cy = (tTriLFO*) mpool_alloc(sizeof(tTriLFO), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -3819,7 +3819,7 @@ void tTriLFO_initToPool (tTriLFO** const cy, tMempool* const mp) tTriLFO_setFreq(c, 220.0f); } -void tTriLFO_free (tTriLFO* const cy) +void tTriLFO_free(tTriLFO** const cy) { tTriLFO* c = &*cy; @@ -3862,14 +3862,14 @@ void tTriLFO_setSampleRate (tTriLFO* const c, Lfloat sr) } ///sinetri -void tSineTriLFO_init (tSineTriLFO* const cy, LEAF* const leaf) +void tSineTriLFO_init(tSineTriLFO** const cy, LEAF* const leaf) { tSineTriLFO_initToPool(cy, &leaf->mempool); } -void tSineTriLFO_initToPool (tSineTriLFO** const cy, tMempool* const mp) +void tSineTriLFO_initToPool (tSineTriLFO** const cy, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tSineTriLFO* c = *cy = (tSineTriLFO*) mpool_alloc(sizeof(tSineTriLFO), m); c->mempool = m; tTriLFO_initToPool(&c->tri,mp); @@ -3886,24 +3886,24 @@ void tSineTriLFO_free (tSineTriLFO** const cy) Lfloat tSineTriLFO_tick (tSineTriLFO* const c) { - Lfloat a = tCycle_tick(&c->sine); - Lfloat b = tTriLFO_tick(&c->tri); + Lfloat a = tCycle_tick(c->sine); + Lfloat b = tTriLFO_tick(c->tri); return (1.0f - c->shape) * a + c->shape * b; } void tSineTriLFO_setFreq (tSineTriLFO* const c, Lfloat freq) { - tTriLFO_setFreq(&c->tri, freq); - tCycle_setFreq(&c->sine, freq); + tTriLFO_setFreq(c->tri, freq); + tCycle_setFreq(c->sine, freq); } void tSineTriLFO_setSampleRate (tSineTriLFO* const c, Lfloat sr) { - tTriLFO_setSampleRate(&c->tri, sr); - tCycle_setSampleRate(&c->sine, sr); + tTriLFO_setSampleRate(c->tri, sr); + tCycle_setSampleRate(c->sine, sr); } void tSineTriLFO_setPhase (tSineTriLFO* const c, Lfloat phase) { - tTriLFO_setPhase(&c->tri, phase); - tCycle_setPhase(&c->sine, phase); + tTriLFO_setPhase(c->tri, phase); + tCycle_setPhase(c->sine, phase); } void tSineTriLFO_setShape (tSineTriLFO* const c, Lfloat shape) @@ -3915,7 +3915,7 @@ void tSineTriLFO_setPhase (tSineTriLFO* const c, Lfloat phase) - void tDampedOscillator_init (tDampedOscillator* const cy, LEAF* const leaf) + void tDampedOscillator_init(tDampedOscillator** const cy, LEAF* const leaf) { tDampedOscillator_initToPool(cy, &leaf->mempool); } @@ -3923,9 +3923,9 @@ void tSineTriLFO_setPhase (tSineTriLFO* const c, Lfloat phase) - void tDampedOscillator_initToPool (tDampedOscillator** const cy, tMempool* const mp) + void tDampedOscillator_initToPool (tDampedOscillator** const cy, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tDampedOscillator* c = *cy = (tDampedOscillator*) mpool_alloc(sizeof(tDampedOscillator), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -3997,14 +3997,14 @@ void tSineTriLFO_setPhase (tSineTriLFO* const c, Lfloat phase) } -void tPlutaQuadOsc_init(tPlutaQuadOsc* const cy, uint32_t const oversamplingRatio, LEAF* const leaf) +void tPlutaQuadOsc_init(tPlutaQuadOsc** const cy, uint32_t const oversamplingRatio, LEAF* const leaf) { tPlutaQuadOsc_initToPool(cy, oversamplingRatio, &leaf->mempool); } -void tPlutaQuadOsc_initToPool (tPlutaQuadOsc** const cy, uint32_t const oversamplingRatio, tMempool* const mp) +void tPlutaQuadOsc_initToPool (tPlutaQuadOsc** const cy, uint32_t const oversamplingRatio, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tPlutaQuadOsc* c = *cy = (tPlutaQuadOsc*) mpool_alloc(sizeof(tPlutaQuadOsc), m); c->mempool = m; LEAF* leaf = c->mempool->leaf; @@ -4029,9 +4029,9 @@ void tPlutaQuadOsc_initToPool (tPlutaQuadOsc** const cy, uint32_t const ove //butterworth lowpass - would be better to create a butterworth object that is lowpass only and uses tSVFtickLP for efficiency tButterworth_initToPool(&c->lowpass, 8, 0.0f, nyquistFreq, mp); //correct samplerate to take into account oversampling - tButterworth_setSampleRate (&c->lowpass, oversampledSamplingRate); + tButterworth_setSampleRate (c->lowpass, oversampledSamplingRate); //now reset the frequencies with new samplerate - tButterworth_setF2 (&c->lowpass, nyquistFreq); + tButterworth_setF2 (c->lowpass, nyquistFreq); Lfloat invSampleRate = 1.0 / oversampledSamplingRate; c->invSampleRateTimesTwoTo32 = (invSampleRate * TWO_TO_32); @@ -4062,7 +4062,7 @@ Lfloat tPlutaQuadOsc_tick (tPlutaQuadOsc* const c) c->biPolarOutputs[i] = out; currentSample += out * c->outputAmplitudes[i]; } - outputSample = tButterworth_tick(&c->lowpass, currentSample); //lowpass before decimation + outputSample = tButterworth_tick(c->lowpass, currentSample); //lowpass before decimation } //only last sample of the oversampled buffer gets used (decimation step) return outputSample * 0.249f; diff --git a/leaf/Src/leaf-physical.c b/leaf/Src/leaf-physical.c index df4da86..0f6756e 100644 --- a/leaf/Src/leaf-physical.c +++ b/leaf/Src/leaf-physical.c @@ -30,13 +30,13 @@ Lfloat pickupNonLinearity (Lfloat x) } -void tPickupNonLinearity_init (tPickupNonLinearity* const pl, LEAF* const leaf) +void tPickupNonLinearity_init(tPickupNonLinearity** const pl, LEAF* const leaf) { tPickupNonLinearity_initToPool(pl, &leaf->mempool); } -void tPickupNonLinearity_initToPool (tPickupNonLinearity** const pl, tMempool* const mp) +void tPickupNonLinearity_initToPool (tPickupNonLinearity** const pl, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tPickupNonLinearity* p = *pl = (tPickupNonLinearity*) mpool_alloc(sizeof(tPickupNonLinearity), m); p->mempool = m; p->prev = 0.0f; @@ -56,14 +56,14 @@ Lfloat tPickupNonLinearity_tick (tPickupNonLinearity* const p, Lfloat } /* ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ tPluck ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -void tPluck_init (tPluck* const pl, Lfloat lowestFrequency, LEAF* const leaf) +void tPluck_init(tPluck** const pl, Lfloat lowestFrequency, LEAF* const leaf) { tPluck_initToPool(pl, lowestFrequency, &leaf->mempool); } -void tPluck_initToPool (tPluck** const pl, Lfloat lowestFrequency, tMempool* const mp) +void tPluck_initToPool (tPluck** const pl, Lfloat lowestFrequency, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tPluck* p = *pl = (tPluck*) mpool_alloc(sizeof(tPluck), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -79,7 +79,7 @@ void tPluck_initToPool (tPluck** const pl, Lfloat lowestFrequency, tMempoo tOneZero_initToPool(&p->loopFilter, 0.0f, mp); tAllpassDelay_initToPool(&p->delayLine, 0.0f, p->sampleRate * 2, mp); - tAllpassDelay_clear(&p->delayLine); + tAllpassDelay_clear(p->delayLine); tPluck_setFrequency(p, 220.0f); } @@ -103,7 +103,7 @@ Lfloat tPluck_getLastOut (tPluck* const p) Lfloat tPluck_tick (tPluck* const p) { - return (p->lastOut = 3.0f * tAllpassDelay_tick(&p->delayLine, tOneZero_tick(&p->loopFilter, tAllpassDelay_getLastOut(&p->delayLine) * p->loopGain ) )); + return (p->lastOut = 3.0f * tAllpassDelay_tick(p->delayLine, tOneZero_tick(p->loopFilter, tAllpassDelay_getLastOut(p->delayLine) * p->loopGain ) )); } void tPluck_pluck (tPluck* const p, Lfloat amplitude) @@ -111,12 +111,12 @@ void tPluck_pluck (tPluck* const p, Lfloat amplitude) if ( amplitude < 0.0f) amplitude = 0.0f; else if (amplitude > 1.0f) amplitude = 1.0f; - tOnePole_setPole(&p->pickFilter, 0.999f - (amplitude * 0.15f)); - tOnePole_setGain(&p->pickFilter, amplitude * 0.5f ); + tOnePole_setPole(p->pickFilter, 0.999f - (amplitude * 0.15f)); + tOnePole_setGain(p->pickFilter, amplitude * 0.5f ); // Fill delay with noise additively with current contents. - for ( uint32_t i = 0; i < (uint32_t)tAllpassDelay_getDelay(&p->delayLine); i++ ) - tAllpassDelay_tick(&p->delayLine, 0.6f * tAllpassDelay_getLastOut(&p->delayLine) + tOnePole_tick(&p->pickFilter, tNoise_tick(&p->noise) ) ); + for ( uint32_t i = 0; i < (uint32_t)tAllpassDelay_getDelay(p->delayLine); i++ ) + tAllpassDelay_tick(p->delayLine, 0.6f * tAllpassDelay_getLastOut(p->delayLine) + tOnePole_tick(p->pickFilter, tNoise_tick(p->noise) ) ); } // Start a note with the given frequency and amplitude.; @@ -142,9 +142,9 @@ void tPluck_setFrequency (tPluck* const p, Lfloat frequency ) if ( frequency <= 0.0f ) frequency = 0.001f; // Delay = length - filter delay. - Lfloat delay = ( p->sampleRate / frequency ) - tOneZero_getPhaseDelay(&p->loopFilter, frequency ); + Lfloat delay = ( p->sampleRate / frequency ) - tOneZero_getPhaseDelay(p->loopFilter, frequency ); - tAllpassDelay_setDelay(&p->delayLine, delay ); + tAllpassDelay_setDelay(p->delayLine, delay ); p->loopGain = 0.99f + (frequency * 0.000005f); @@ -163,22 +163,22 @@ void tPluck_setSampleRate(tPluck* const p, Lfloat sr) tAllpassDelay_free(&p->delayLine); tAllpassDelay_initToPool(&p->delayLine, 0.0f, p->sampleRate * 2, &p->mempool); - tAllpassDelay_clear(&p->delayLine); + tAllpassDelay_clear(p->delayLine); tPluck_setFrequency(p, p->lastFreq); - tOnePole_setSampleRate(&p->pickFilter, p->sampleRate); - tOneZero_setSampleRate(&p->loopFilter, p->sampleRate); + tOnePole_setSampleRate(p->pickFilter, p->sampleRate); + tOneZero_setSampleRate(p->loopFilter, p->sampleRate); } /* ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ tKarplusStrong ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -void tKarplusStrong_init (tKarplusStrong* const pl, Lfloat lowestFrequency, LEAF* const leaf) +void tKarplusStrong_init(tKarplusStrong** const pl, Lfloat lowestFrequency, LEAF* const leaf) { tKarplusStrong_initToPool(pl, lowestFrequency, &leaf->mempool); } -void tKarplusStrong_initToPool (tKarplusStrong** const pl, Lfloat lowestFrequency, tMempool* const mp) +void tKarplusStrong_initToPool (tKarplusStrong** const pl, Lfloat lowestFrequency, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tKarplusStrong* p = *pl = (tKarplusStrong*) mpool_alloc(sizeof(tKarplusStrong), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -188,10 +188,10 @@ void tKarplusStrong_initToPool (tKarplusStrong** const pl, Lfloat lowestFre if ( lowestFrequency <= 0.0f ) lowestFrequency = 8.0f; tAllpassDelay_initToPool(&p->delayLine, 0.0f, p->sampleRate * 2, mp); - tAllpassDelay_clear(&p->delayLine); + tAllpassDelay_clear(p->delayLine); tLinearDelay_initToPool(&p->combDelay, 0.0f, p->sampleRate * 2, mp); - tLinearDelay_clear(&p->combDelay); + tLinearDelay_clear(p->combDelay); tOneZero_initToPool(&p->filter, 0.0f, mp); @@ -236,16 +236,16 @@ Lfloat tKarplusStrong_getLastOut (tKarplusStrong* const p) Lfloat tKarplusStrong_tick (tKarplusStrong* const p) { - Lfloat temp = tAllpassDelay_getLastOut(&p->delayLine) * p->loopGain; + Lfloat temp = tAllpassDelay_getLastOut(p->delayLine) * p->loopGain; // Calculate allpass stretching. - for (int i=0; i<4; i++) temp = tBiQuad_tick(&p->biquad[i],temp); + for (int i=0; i<4; i++) temp = tBiQuad_tick(p->biquad[i],temp); // Moving average filter. - temp = tOneZero_tick(&p->filter, temp); + temp = tOneZero_tick(p->filter, temp); - Lfloat out = tAllpassDelay_tick(&p->delayLine, temp); - out = out - tLinearDelay_tick(&p->combDelay, out); + Lfloat out = tAllpassDelay_tick(p->delayLine, temp); + out = out - tLinearDelay_tick(p->combDelay, out); p->lastOut = out; return p->lastOut; @@ -258,10 +258,10 @@ void tKarplusStrong_pluck (tKarplusStrong* const p, Lfloat amplitude) p->pluckAmplitude = amplitude; - for ( uint32_t i=0; i < (uint32_t)tAllpassDelay_getDelay(&p->delayLine); i++ ) + for ( uint32_t i=0; i < (uint32_t)tAllpassDelay_getDelay(p->delayLine); i++ ) { // Fill delay with noise additively with current contents. - tAllpassDelay_tick(&p->delayLine, (tAllpassDelay_getLastOut(&p->delayLine) * 0.6f) + 0.4f * tNoise_tick(&p->noise) * p->pluckAmplitude ); + tAllpassDelay_tick(p->delayLine, (tAllpassDelay_getLastOut(p->delayLine) * 0.6f) + 0.4f * tNoise_tick(p->noise) * p->pluckAmplitude ); //delayLine_.tick( combDelay_.tick((delayLine_.lastOut() * 0.6) + 0.4 * noise->tick() * pluckAmplitude_) ); } } @@ -290,7 +290,7 @@ void tKarplusStrong_setFrequency (tKarplusStrong* const p, Lfloat frequency p->lastFrequency = frequency; p->lastLength = p->sampleRate / p->lastFrequency; Lfloat delay = p->lastLength - 0.5f; - tAllpassDelay_setDelay(&p->delayLine, delay); + tAllpassDelay_setDelay(p->delayLine, delay); // MAYBE MODIFY LOOP GAINS p->loopGain = p->baseLoopGain + (frequency * 0.000005f); @@ -298,7 +298,7 @@ void tKarplusStrong_setFrequency (tKarplusStrong* const p, Lfloat frequency tKarplusStrong_setStretch(p, p->stretching); - tLinearDelay_setDelay(&p->combDelay, 0.5f * p->pickupPosition * p->lastLength); + tLinearDelay_setDelay(p->combDelay, 0.5f * p->pickupPosition * p->lastLength); } // Set the stretch "factor" of the string (0.0 - 1.0). @@ -314,13 +314,13 @@ void tKarplusStrong_setStretch (tKarplusStrong* const p, Lfloat stret for ( int i=0; i<4; i++ ) { coefficient = temp * temp; - tBiQuad_setA2(&p->biquad[i], coefficient); - tBiQuad_setB0(&p->biquad[i], coefficient); - tBiQuad_setB2(&p->biquad[i], 1.0f); + tBiQuad_setA2(p->biquad[i], coefficient); + tBiQuad_setB0(p->biquad[i], coefficient); + tBiQuad_setB2(p->biquad[i], 1.0f); coefficient = -2.0f * temp * cosf(TWO_PI * freq / p->sampleRate); - tBiQuad_setA1(&p->biquad[i], coefficient); - tBiQuad_setB1(&p->biquad[i], coefficient); + tBiQuad_setA1(p->biquad[i], coefficient); + tBiQuad_setB1(p->biquad[i], coefficient); freq += dFreq; } @@ -333,7 +333,7 @@ void tKarplusStrong_setPickupPosition (tKarplusStrong* const p, Lfloat posit else if (position <= 1.0f) p->pickupPosition = position; else p->pickupPosition = 1.0f; - tLinearDelay_setDelay(&p->combDelay, 0.5f * p->pickupPosition * p->lastLength); + tLinearDelay_setDelay(p->combDelay, 0.5f * p->pickupPosition * p->lastLength); } // Set the base loop gain. @@ -366,24 +366,24 @@ void tKarplusStrong_setSampleRate (tKarplusStrong* const p, Lfloat sr) tAllpassDelay_free(&p->delayLine); tAllpassDelay_initToPool(&p->delayLine, 0.0f, p->sampleRate * 2, &p->mempool); - tAllpassDelay_clear(&p->delayLine); + tAllpassDelay_clear(p->delayLine); tLinearDelay_free(&p->combDelay); tLinearDelay_initToPool(&p->combDelay, 0.0f, p->sampleRate * 2, &p->mempool); - tLinearDelay_clear(&p->combDelay); + tLinearDelay_clear(p->combDelay); tKarplusStrong_setFrequency(p, p->lastFrequency); - tOneZero_setSampleRate(&p->filter, p->sampleRate); + tOneZero_setSampleRate(p->filter, p->sampleRate); for (int i = 0; i < 4; i++) { - tBiQuad_setSampleRate(&p->biquad[i], p->sampleRate); + tBiQuad_setSampleRate(p->biquad[i], p->sampleRate); } } /* Simple Living String*/ -void tSimpleLivingString_init(tSimpleLivingString* const pl, Lfloat freq, Lfloat dampFreq, +void tSimpleLivingString_init(tSimpleLivingString** const pl, Lfloat freq, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, LEAF* const leaf) { @@ -392,9 +392,9 @@ void tSimpleLivingString_init(tSimpleLivingString* const pl, Lfloat freq, Lfl void tSimpleLivingString_initToPool (tSimpleLivingString** const pl, Lfloat freq, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, - Lfloat levStrength, int levMode, tMempool* const mp) + Lfloat levStrength, int levMode, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tSimpleLivingString* p = *pl = (tSimpleLivingString*) mpool_alloc(sizeof(tSimpleLivingString), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -404,7 +404,7 @@ void tSimpleLivingString_initToPool (tSimpleLivingString** const pl, Lfloat tExpSmooth_initToPool(&p->wlSmooth, p->sampleRate/freq, 0.01f, mp); // smoother for string wavelength (not freq, to avoid expensive divisions) tSimpleLivingString_setFreq(*pl, freq); tLinearDelay_initToPool(&p->delayLine,p->waveLengthInSamples, 2400, mp); - tLinearDelay_clear(&p->delayLine); + tLinearDelay_clear(p->delayLine); tOnePole_initToPool(&p->bridgeFilter, dampFreq, mp); tHighpass_initToPool(&p->DCblocker,13, mp); p->decay=decay; @@ -443,7 +443,7 @@ void tSimpleLivingString_setWaveLength(tSimpleLivingString* const p, Lfloat void tSimpleLivingString_setDampFreq(tSimpleLivingString* const p, Lfloat dampFreq) { - tOnePole_setFreq(&p->bridgeFilter, dampFreq); + tOnePole_setFreq(p->bridgeFilter, dampFreq); } void tSimpleLivingString_setDecay(tSimpleLivingString* const p, Lfloat decay) @@ -453,31 +453,31 @@ void tSimpleLivingString_setDecay(tSimpleLivingString* const p, Lfloat decay void tSimpleLivingString_setTargetLev(tSimpleLivingString* const p, Lfloat targetLev) { - tFeedbackLeveler_setTargetLevel(&p->fbLev, targetLev); + tFeedbackLeveler_setTargetLevel(p->fbLev, targetLev); } void tSimpleLivingString_setLevSmoothFactor(tSimpleLivingString* const p, Lfloat levSmoothFactor) { - tFeedbackLeveler_setFactor(&p->fbLev, levSmoothFactor); + tFeedbackLeveler_setFactor(p->fbLev, levSmoothFactor); } void tSimpleLivingString_setLevStrength(tSimpleLivingString* const p, Lfloat levStrength) { - tFeedbackLeveler_setStrength(&p->fbLev, levStrength); + tFeedbackLeveler_setStrength(p->fbLev, levStrength); } void tSimpleLivingString_setLevMode(tSimpleLivingString* const p, int levMode) { - tFeedbackLeveler_setMode(&p->fbLev, levMode); + tFeedbackLeveler_setMode(p->fbLev, levMode); p->levMode=levMode; } Lfloat tSimpleLivingString_tick(tSimpleLivingString* const p, Lfloat input) { - Lfloat stringOut=tOnePole_tick(&p->bridgeFilter,tLinearDelay_tickOut(&p->delayLine)); - Lfloat stringInput=tHighpass_tick(&p->DCblocker, tFeedbackLeveler_tick(&p->fbLev, (p->levMode==0?p->decay*stringOut:stringOut)+input)); - tLinearDelay_tickIn(&p->delayLine, stringInput); - tLinearDelay_setDelay(&p->delayLine, tExpSmooth_tick(p->wlSmooth)); + Lfloat stringOut=tOnePole_tick(p->bridgeFilter,tLinearDelay_tickOut(p->delayLine)); + Lfloat stringInput=tHighpass_tick(p->DCblocker, tFeedbackLeveler_tick(p->fbLev, (p->levMode==0?p->decay*stringOut:stringOut)+input)); + tLinearDelay_tickIn(p->delayLine, stringInput); + tLinearDelay_setDelay(p->delayLine, tExpSmooth_tick(p->wlSmooth)); p->curr = stringOut; return p->curr; } @@ -493,14 +493,14 @@ void tSimpleLivingString_setSampleRate(tSimpleLivingString* const p, Lfloat sr p->sampleRate = sr; p->waveLengthInSamples = p->sampleRate/freq; tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); - tOnePole_setSampleRate(&p->bridgeFilter, p->sampleRate); - tHighpass_setSampleRate(&p->DCblocker, p->sampleRate); + tOnePole_setSampleRate(p->bridgeFilter, p->sampleRate); + tHighpass_setSampleRate(p->DCblocker, p->sampleRate); } /* Simple Living String 2*/ -void tSimpleLivingString2_init(tSimpleLivingString2* const pl, Lfloat freq, Lfloat brightness, +void tSimpleLivingString2_init(tSimpleLivingString2** const pl, Lfloat freq, Lfloat brightness, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, LEAF* const leaf) { @@ -509,9 +509,9 @@ void tSimpleLivingString2_init(tSimpleLivingString2* const pl, Lfloat freq, L void tSimpleLivingString2_initToPool (tSimpleLivingString2** const pl, Lfloat freq, Lfloat brightness, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, - Lfloat levStrength, int levMode, tMempool* const mp) + Lfloat levStrength, int levMode, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tSimpleLivingString2* p = *pl = (tSimpleLivingString2*) mpool_alloc(sizeof(tSimpleLivingString2), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -521,7 +521,7 @@ void tSimpleLivingString2_initToPool (tSimpleLivingString2** const pl, Lfloa tExpSmooth_initToPool(&p->wlSmooth, p->sampleRate/freq, 0.01f, mp); // smoother for string wavelength (not freq, to avoid expensive divisions) tSimpleLivingString2_setFreq(*pl, freq); tHermiteDelay_initToPool(&p->delayLine,p->waveLengthInSamples, 2400, mp); - tHermiteDelay_clear(&p->delayLine); + tHermiteDelay_clear(p->delayLine); tTwoZero_initToPool(&p->bridgeFilter, mp); tSimpleLivingString2_setBrightness(*pl, brightness); tHighpass_initToPool(&p->DCblocker,13, mp); @@ -563,7 +563,7 @@ void tSimpleLivingString2_setBrightness(tSimpleLivingString2* const p, Lfloa { Lfloat h0 = (1.0f + brightness) * 0.5f; Lfloat h1 = (1.0f - brightness) * 0.25f; - tTwoZero_setCoefficients(&p->bridgeFilter, h1, h0, h1); + tTwoZero_setCoefficients(p->bridgeFilter, h1, h0, h1); } void tSimpleLivingString2_setDecay(tSimpleLivingString2* const p, Lfloat decay) @@ -573,31 +573,31 @@ void tSimpleLivingString2_setDecay(tSimpleLivingString2* const p, Lfloat dec void tSimpleLivingString2_setTargetLev(tSimpleLivingString2* const p, Lfloat targetLev) { - tFeedbackLeveler_setTargetLevel(&p->fbLev, targetLev); + tFeedbackLeveler_setTargetLevel(p->fbLev, targetLev); } void tSimpleLivingString2_setLevSmoothFactor(tSimpleLivingString2* const p, Lfloat levSmoothFactor) { - tFeedbackLeveler_setFactor(&p->fbLev, levSmoothFactor); + tFeedbackLeveler_setFactor(p->fbLev, levSmoothFactor); } void tSimpleLivingString2_setLevStrength(tSimpleLivingString2* const p, Lfloat levStrength) { - tFeedbackLeveler_setStrength(&p->fbLev, levStrength); + tFeedbackLeveler_setStrength(p->fbLev, levStrength); } void tSimpleLivingString2_setLevMode(tSimpleLivingString2* const p, int levMode) { - tFeedbackLeveler_setMode(&p->fbLev, levMode); + tFeedbackLeveler_setMode(p->fbLev, levMode); p->levMode=levMode; } Lfloat tSimpleLivingString2_tick(tSimpleLivingString2* const p, Lfloat input) { - Lfloat stringOut=tTwoZero_tick(&p->bridgeFilter,tHermiteDelay_tickOut(&p->delayLine)); - Lfloat stringInput=tHighpass_tick(&p->DCblocker,(tFeedbackLeveler_tick(&p->fbLev, (p->levMode==0?p->decay*stringOut:stringOut)+input))); - tHermiteDelay_tickIn(&p->delayLine, stringInput); - tHermiteDelay_setDelay(&p->delayLine, tExpSmooth_tick(p->wlSmooth)); + Lfloat stringOut=tTwoZero_tick(p->bridgeFilter,tHermiteDelay_tickOut(p->delayLine)); + Lfloat stringInput=tHighpass_tick(p->DCblocker,(tFeedbackLeveler_tick(p->fbLev, (p->levMode==0?p->decay*stringOut:stringOut)+input))); + tHermiteDelay_tickIn(p->delayLine, stringInput); + tHermiteDelay_setDelay(p->delayLine, tExpSmooth_tick(p->wlSmooth)); p->curr = stringOut; return p->curr; } @@ -614,12 +614,12 @@ void tSimpleLivingString2_setSampleRate(tSimpleLivingString2* const p, Lfloat p->sampleRate = sr; p->waveLengthInSamples = p->sampleRate/freq; tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); - tTwoZero_setSampleRate(&p->bridgeFilter, p->sampleRate); - tHighpass_setSampleRate(&p->DCblocker, p->sampleRate); + tTwoZero_setSampleRate(p->bridgeFilter, p->sampleRate); + tHighpass_setSampleRate(p->DCblocker, p->sampleRate); } /* Living String*/ -void tLivingString_init(tLivingString* const pl, Lfloat freq, Lfloat pickPos, Lfloat prepIndex, +void tLivingString_init(tLivingString** const pl, Lfloat freq, Lfloat pickPos, Lfloat prepIndex, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, LEAF* const leaf) { @@ -628,9 +628,9 @@ void tLivingString_init(tLivingString* const pl, Lfloat freq, Lfloat pickPos, void tLivingString_initToPool (tLivingString** const pl, Lfloat freq, Lfloat pickPos, Lfloat prepIndex, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, - Lfloat levStrength, int levMode, tMempool* const mp) + Lfloat levStrength, int levMode, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tLivingString* p = *pl = (tLivingString*) mpool_alloc(sizeof(tLivingString), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -647,10 +647,10 @@ void tLivingString_initToPool (tLivingString** const pl, Lfloat freq, Lflo tLinearDelay_initToPool(&p->delUF,p->waveLengthInSamples, 2400, mp); tLinearDelay_initToPool(&p->delUB,p->waveLengthInSamples, 2400, mp); tLinearDelay_initToPool(&p->delLB,p->waveLengthInSamples, 2400, mp); - tLinearDelay_clear(&p->delLF); - tLinearDelay_clear(&p->delUF); - tLinearDelay_clear(&p->delUB); - tLinearDelay_clear(&p->delLB); + tLinearDelay_clear(p->delLF); + tLinearDelay_clear(p->delUF); + tLinearDelay_clear(p->delUB); + tLinearDelay_clear(p->delLB); p->dampFreq = dampFreq; tOnePole_initToPool(&p->bridgeFilter, dampFreq, mp); tOnePole_initToPool(&p->nutFilter, dampFreq, mp); @@ -668,7 +668,7 @@ void tLivingString_initToPool (tLivingString** const pl, Lfloat freq, Lflo /* Simple Living String 3*/ -void tSimpleLivingString3_init(tSimpleLivingString3* const pl, int oversampling, Lfloat freq, Lfloat dampFreq, +void tSimpleLivingString3_init(tSimpleLivingString3** const pl, int oversampling, Lfloat freq, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, LEAF* const leaf) { @@ -677,9 +677,9 @@ void tSimpleLivingString3_init(tSimpleLivingString3* const pl, int oversampli void tSimpleLivingString3_initToPool (tSimpleLivingString3** const pl, int oversampling, Lfloat freq, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, - Lfloat levStrength, int levMode, tMempool* const mp) + Lfloat levStrength, int levMode, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tSimpleLivingString3* p = *pl = (tSimpleLivingString3*) mpool_alloc(sizeof(tSimpleLivingString3), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -691,21 +691,21 @@ void tSimpleLivingString3_initToPool (tSimpleLivingString3** const pl, int o tLinearDelay_initToPool(&p->delayLineU,p->waveLengthInSamples, p->maxLength, mp); tLinearDelay_initToPool(&p->delayLineL,p->waveLengthInSamples, p->maxLength, mp); tSimpleLivingString3_setFreq(*pl, freq); - tLinearDelay_setDelay(&p->delayLineU, p->waveLengthInSamples); - tLinearDelay_setDelay(&p->delayLineL, p->waveLengthInSamples); + tLinearDelay_setDelay(p->delayLineU, p->waveLengthInSamples); + tLinearDelay_setDelay(p->delayLineL, p->waveLengthInSamples); //tSimpleLivingString3_setWaveLength(pl, 4800); - tLinearDelay_clear(&p->delayLineU); - tLinearDelay_clear(&p->delayLineL); + tLinearDelay_clear(p->delayLineU); + tLinearDelay_clear(p->delayLineL); p->dampFreq = dampFreq; tOnePole_initToPool(&p->bridgeFilter, dampFreq, mp); - tOnePole_setSampleRate(&p->bridgeFilter, p->sampleRate); - tOnePole_setFreq(&p->bridgeFilter, dampFreq); + tOnePole_setSampleRate(p->bridgeFilter, p->sampleRate); + tOnePole_setFreq(p->bridgeFilter, dampFreq); p->rippleGain = 0.0f; p->rippleDelay = 0.5f; p->invOnePlusr = 1.0f; tHighpass_initToPool(&p->DCblocker,13, mp); - tHighpass_setSampleRate(&p->DCblocker,p->sampleRate); - tHighpass_setFreq(&p->DCblocker,13); + tHighpass_setSampleRate(p->DCblocker,p->sampleRate); + tHighpass_setFreq(p->DCblocker,13); p->userDecay = decay; tFeedbackLeveler_initToPool(&p->fbLev, targetLev, levSmoothFactor, levStrength, levMode, mp); @@ -755,7 +755,7 @@ void tSimpleLivingString3_setFreq(tSimpleLivingString3* const p, Lfloat freq Lfloat temp = ((p->userDecay * 0.01f) + 0.01f) * 6.9078f; p->decay = exp(-6.91 * ((1.0 / p->freq) / temp)); - //tBiQuad_setCoefficients(&p->bridgeFilter2,p->temp1,p->temp2, p->temp1, 0.0f, 0.0f); + //tBiQuad_setCoefficients(p->bridgeFilter2,p->temp1,p->temp2, p->temp1, 0.0f, 0.0f); //p->decay=powf(0.001f,1.0f/(p->freq*p->userDecay)); } @@ -772,9 +772,9 @@ void tSimpleLivingString3_setDampFreq(tSimpleLivingString3* const p, Lfloat { //p->temp1 = (1.0f - brightness) * 0.25f * p->decay; //p->temp2 = (1.0f + brightness) * 0.5f * p->decay; - //tBiQuad_setCoefficients(&p->bridgeFilter2, p->temp1 , p->temp2, p->temp1 , 0.0f, 0.0f); + //tBiQuad_setCoefficients(p->bridgeFilter2, p->temp1 , p->temp2, p->temp1 , 0.0f, 0.0f); - tOnePole_setFreq(&p->bridgeFilter, dampFreq); + tOnePole_setFreq(p->bridgeFilter, dampFreq); } void tSimpleLivingString3_setDecay(tSimpleLivingString3* const p, Lfloat decay) @@ -785,28 +785,28 @@ void tSimpleLivingString3_setDecay(tSimpleLivingString3* const p, Lfloat dec p->decay = exp(-6.9078 * ((1.0 / p->freq) / temp)); - //tBiQuad_setCoefficients(&p->bridgeFilter2,p->temp1,p->temp2, p->temp1, 0.0f, 0.0f); + //tBiQuad_setCoefficients(p->bridgeFilter2,p->temp1,p->temp2, p->temp1, 0.0f, 0.0f); //p->decay=powf(0.001f,1.0f/(p->freq*decay)); } void tSimpleLivingString3_setTargetLev(tSimpleLivingString3* const p, Lfloat targetLev) { - tFeedbackLeveler_setTargetLevel(&p->fbLev, targetLev); + tFeedbackLeveler_setTargetLevel(p->fbLev, targetLev); } void tSimpleLivingString3_setLevSmoothFactor(tSimpleLivingString3* const p, Lfloat levSmoothFactor) { - tFeedbackLeveler_setFactor(&p->fbLev, levSmoothFactor); + tFeedbackLeveler_setFactor(p->fbLev, levSmoothFactor); } void tSimpleLivingString3_setLevStrength(tSimpleLivingString3* const p, Lfloat levStrength) { - tFeedbackLeveler_setStrength(&p->fbLev, levStrength); + tFeedbackLeveler_setStrength(p->fbLev, levStrength); } void tSimpleLivingString3_setLevMode(tSimpleLivingString3* const p, int levMode) { - tFeedbackLeveler_setMode(&p->fbLev, levMode); + tFeedbackLeveler_setMode(p->fbLev, levMode); p->levMode=levMode; } @@ -856,19 +856,19 @@ Lfloat tSimpleLivingString3_tick(tSimpleLivingString3* const p, Lfloat input) { // p->changeGainCompensator = sqrtf(1.0f - changeInDelayTime); } - tLinearDelay_setDelay(&p->delayLineU, wl); - tLinearDelay_setDelay(&p->delayLineL, wl); + tLinearDelay_setDelay(p->delayLineU, wl); + tLinearDelay_setDelay(p->delayLineL, wl); for (int i = 0; i < p->oversampling; i++) { - p->Uout = tHighpass_tick(&p->DCblocker,tOnePole_tick(&p->bridgeFilter,tLinearDelay_tickOut(&p->delayLineU))* (p->decay * p->invOnePlusr)); - p->Uout = LEAF_clip(-1.0f, tFeedbackLeveler_tick(&p->fbLev, p->Uout), 1.0f); - //p->Uout = tLinearDelay_tickOut(&p->delayLineU) * p->decay; - p->Lout = LEAF_clip(-1.0f, tLinearDelay_tickOut(&p->delayLineL), 1.0f); - - tLinearDelay_tickIn(&p->delayLineU, (-1.0f * p->Lout) + input); - tLinearDelay_tickIn(&p->delayLineL, -1.0f * p->Uout); - tLinearDelay_addTo (&p->delayLineU, p->Lout * p->rippleGain, p->rippleDelay*wl); + p->Uout = tHighpass_tick(p->DCblocker,tOnePole_tick(p->bridgeFilter,tLinearDelay_tickOut(p->delayLineU))* (p->decay * p->invOnePlusr)); + p->Uout = LEAF_clip(-1.0f, tFeedbackLeveler_tick(p->fbLev, p->Uout), 1.0f); + //p->Uout = tLinearDelay_tickOut(p->delayLineU) * p->decay; + p->Lout = LEAF_clip(-1.0f, tLinearDelay_tickOut(p->delayLineL), 1.0f); + + tLinearDelay_tickIn(p->delayLineU, (-1.0f * p->Lout) + input); + tLinearDelay_tickIn(p->delayLineL, -1.0f * p->Uout); + tLinearDelay_addTo (p->delayLineU, p->Lout * p->rippleGain, p->rippleDelay*wl); } //calculate pickup point @@ -894,9 +894,9 @@ Lfloat tSimpleLivingString3_tick(tSimpleLivingString3* const p, Lfloat input) //p->curr = p->Uout; p->prevDelayLength = p->waveLengthInSamples; - //Lfloat stringInput=tHighpass_tick(&p->DCblocker, tFeedbackLeveler_tick(&p->fbLev, (p->levMode==0?p->decay*stringOut:stringOut)+input)); - //tLinearDelay_tickIn(&p->delayLine, stringInput); - //tLinearDelay_setDelay(&p->delayLine, tExpSmooth_tick(&p->wlSmooth)); + //Lfloat stringInput=tHighpass_tick(p->DCblocker, tFeedbackLeveler_tick(p->fbLev, (p->levMode==0?p->decay*stringOut:stringOut)+input)); + //tLinearDelay_tickIn(p->delayLine, stringInput); + //tLinearDelay_setDelay(p->delayLine, tExpSmooth_tick(p->wlSmooth)); //p->curr = d1 + d2; return p->curr; } @@ -920,15 +920,15 @@ void tSimpleLivingString3_setSampleRate(tSimpleLivingString3* const p, Lfloat p->waveLengthInSamples = p->sampleRate/freq; tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); - tOnePole_setSampleRate(&p->bridgeFilter, p->sampleRate); - tHighpass_setSampleRate(&p->DCblocker, p->sampleRate); - tBiQuad_setSampleRate(&p->bridgeFilter2, p->sampleRate); + tOnePole_setSampleRate(p->bridgeFilter, p->sampleRate); + tHighpass_setSampleRate(p->DCblocker, p->sampleRate); + tBiQuad_setSampleRate(p->bridgeFilter2, p->sampleRate); } /* Simple Living String 4*/ -void tSimpleLivingString4_init(tSimpleLivingString4* const pl, int oversampling, Lfloat freq, Lfloat dampFreq, +void tSimpleLivingString4_init(tSimpleLivingString4** const pl, int oversampling, Lfloat freq, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, LEAF* const leaf) { @@ -937,9 +937,9 @@ void tSimpleLivingString4_init(tSimpleLivingString4* const pl, int oversampli void tSimpleLivingString4_initToPool (tSimpleLivingString4** const pl, int oversampling, Lfloat freq, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, - Lfloat levStrength, int levMode, tMempool* const mp) + Lfloat levStrength, int levMode, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tSimpleLivingString4* p = *pl = (tSimpleLivingString4*) mpool_alloc(sizeof(tSimpleLivingString4), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -951,24 +951,24 @@ void tSimpleLivingString4_initToPool (tSimpleLivingString4** const pl, int o tLinearDelay_initToPool(&p->delayLineU,p->waveLengthInSamples, p->maxLength, mp); tLinearDelay_initToPool(&p->delayLineL,p->waveLengthInSamples, p->maxLength, mp); tSimpleLivingString4_setFreq(p, freq); - tLinearDelay_setDelay(&p->delayLineU, p->waveLengthInSamples); - tLinearDelay_setDelay(&p->delayLineL, p->waveLengthInSamples); + tLinearDelay_setDelay(p->delayLineU, p->waveLengthInSamples); + tLinearDelay_setDelay(p->delayLineL, p->waveLengthInSamples); //tSimpleLivingString4_setWaveLength(pl, 4800); - tLinearDelay_clear(&p->delayLineU); - tLinearDelay_clear(&p->delayLineL); + tLinearDelay_clear(p->delayLineU); + tLinearDelay_clear(p->delayLineL); p->dampFreq = dampFreq; tOnePole_initToPool(&p->bridgeFilter, dampFreq, mp); - tOnePole_setSampleRate(&p->bridgeFilter, p->sampleRate); - tOnePole_setFreq(&p->bridgeFilter, dampFreq); + tOnePole_setSampleRate(p->bridgeFilter, p->sampleRate); + tOnePole_setFreq(p->bridgeFilter, dampFreq); p->rippleGain = 0.0f; p->rippleDelay = 0.5f; tBiQuad_initToPool(&p->bridgeFilter2, mp); - tBiQuad_setSampleRate(&p->bridgeFilter2, p->sampleRate); + tBiQuad_setSampleRate(p->bridgeFilter2, p->sampleRate); tHighpass_initToPool(&p->DCblocker,0.001f, mp); - tHighpass_setSampleRate(&p->DCblocker,p->sampleRate); - tHighpass_setFreq(&p->DCblocker,0.001f); + tHighpass_setSampleRate(p->DCblocker,p->sampleRate); + tHighpass_setFreq(p->DCblocker,0.001f); p->userDecay = decay; p->pluckPosition = 0.8f; tFeedbackLeveler_initToPool(&p->fbLev, targetLev, levSmoothFactor, levStrength, levMode, mp); @@ -1018,7 +1018,7 @@ void tSimpleLivingString4_setFreq(tSimpleLivingString4* const p, Lfloat freq Lfloat temp = ((p->userDecay * 0.01f) + 0.01f) * 6.9078f; p->decay = exp(-6.91 * ((1.0 / p->freq) / temp)); - //tBiQuad_setCoefficients(&p->bridgeFilter2,p->temp1,p->temp2, p->temp1, 0.0f, 0.0f); + //tBiQuad_setCoefficients(p->bridgeFilter2,p->temp1,p->temp2, p->temp1, 0.0f, 0.0f); //p->decay=powf(0.001f,1.0f/(p->freq*p->userDecay)); } @@ -1035,9 +1035,9 @@ void tSimpleLivingString4_setDampFreq(tSimpleLivingString4* const p, Lfloat { //p->temp1 = (1.0f - brightness) * 0.25f * p->decay; //p->temp2 = (1.0f + brightness) * 0.5f * p->decay; - //tBiQuad_setCoefficients(&p->bridgeFilter2, p->temp1 , p->temp2, p->temp1 , 0.0f, 0.0f); + //tBiQuad_setCoefficients(p->bridgeFilter2, p->temp1 , p->temp2, p->temp1 , 0.0f, 0.0f); - tOnePole_setFreq(&p->bridgeFilter, dampFreq); + tOnePole_setFreq(p->bridgeFilter, dampFreq); } void tSimpleLivingString4_setDecay(tSimpleLivingString4* const p, Lfloat decay) @@ -1046,28 +1046,28 @@ void tSimpleLivingString4_setDecay(tSimpleLivingString4* const p, Lfloat dec Lfloat temp = ((decay * 0.01f) + 0.01f) * 6.9078f; p->decay = exp(-6.91 * ((1.0 / p->freq) / temp)); - //tBiQuad_setCoefficients(&p->bridgeFilter2,p->temp1,p->temp2, p->temp1, 0.0f, 0.0f); + //tBiQuad_setCoefficients(p->bridgeFilter2,p->temp1,p->temp2, p->temp1, 0.0f, 0.0f); //p->decay=powf(0.001f,1.0f/(p->freq*decay)); } void tSimpleLivingString4_setTargetLev(tSimpleLivingString4* const p, Lfloat targetLev) { - tFeedbackLeveler_setTargetLevel(&p->fbLev, targetLev); + tFeedbackLeveler_setTargetLevel(p->fbLev, targetLev); } void tSimpleLivingString4_setLevSmoothFactor(tSimpleLivingString4* const p, Lfloat levSmoothFactor) { - tFeedbackLeveler_setFactor(&p->fbLev, levSmoothFactor); + tFeedbackLeveler_setFactor(p->fbLev, levSmoothFactor); } void tSimpleLivingString4_setLevStrength(tSimpleLivingString4* const p, Lfloat levStrength) { - tFeedbackLeveler_setStrength(&p->fbLev, levStrength); + tFeedbackLeveler_setStrength(p->fbLev, levStrength); } void tSimpleLivingString4_setLevMode(tSimpleLivingString4* const p, int levMode) { - tFeedbackLeveler_setMode(&p->fbLev, levMode); + tFeedbackLeveler_setMode(p->fbLev, levMode); p->levMode=levMode; } @@ -1165,21 +1165,21 @@ Lfloat tSimpleLivingString4_tick(tSimpleLivingString4* const p, Lfloat input) else{ p->changeGainCompensator = 1.0f; } - tLinearDelay_setDelay(&p->delayLineU, wl); - tLinearDelay_setDelay(&p->delayLineL, wl); + tLinearDelay_setDelay(p->delayLineU, wl); + tLinearDelay_setDelay(p->delayLineL, wl); for (int i = 0; i < p->oversampling; i++) { - p->Uout = tHighpass_tick(&p->DCblocker,tOnePole_tick(&p->bridgeFilter,tLinearDelay_tickOut(&p->delayLineU))* (p->decay - fabsf(p->rippleGain))); - p->Uout = LEAF_clip(-1.0f, tFeedbackLeveler_tick(&p->fbLev, p->Uout), 1.0f); - //p->Uout = tLinearDelay_tickOut(&p->delayLineU) * p->decay; - p->Lout = LEAF_clip(-1.0f, tLinearDelay_tickOut(&p->delayLineL), 1.0f); - - tLinearDelay_tickIn(&p->delayLineU, (-1.0f * p->Lout)* p->changeGainCompensator); - tLinearDelay_tickIn(&p->delayLineL, (-1.0f * p->Uout)); - tLinearDelay_addTo (&p->delayLineU, input, p->pluckPosition*wl); - tLinearDelay_addTo (&p->delayLineL, input, (1.0f - p->pluckPosition)*wl); - tLinearDelay_addTo (&p->delayLineU, p->Lout * p->rippleGain, p->rippleDelay*wl); + p->Uout = tHighpass_tick(p->DCblocker,tOnePole_tick(p->bridgeFilter,tLinearDelay_tickOut(p->delayLineU))* (p->decay - fabsf(p->rippleGain))); + p->Uout = LEAF_clip(-1.0f, tFeedbackLeveler_tick(p->fbLev, p->Uout), 1.0f); + //p->Uout = tLinearDelay_tickOut(p->delayLineU) * p->decay; + p->Lout = LEAF_clip(-1.0f, tLinearDelay_tickOut(p->delayLineL), 1.0f); + + tLinearDelay_tickIn(p->delayLineU, (-1.0f * p->Lout)* p->changeGainCompensator); + tLinearDelay_tickIn(p->delayLineL, (-1.0f * p->Uout)); + tLinearDelay_addTo (p->delayLineU, input, p->pluckPosition*wl); + tLinearDelay_addTo (p->delayLineL, input, (1.0f - p->pluckPosition)*wl); + tLinearDelay_addTo (p->delayLineU, p->Lout * p->rippleGain, p->rippleDelay*wl); } //calculate pickup point @@ -1205,9 +1205,9 @@ Lfloat tSimpleLivingString4_tick(tSimpleLivingString4* const p, Lfloat input) //p->curr = p->Uout; p->prevDelayLength = p->waveLengthInSamples; - //Lfloat stringInput=tHighpass_tick(&p->DCblocker, tFeedbackLeveler_tick(&p->fbLev, (p->levMode==0?p->decay*stringOut:stringOut)+input)); - //tLinearDelay_tickIn(&p->delayLine, stringInput); - //tLinearDelay_setDelay(&p->delayLine, tExpSmooth_tick(&p->wlSmooth)); + //Lfloat stringInput=tHighpass_tick(p->DCblocker, tFeedbackLeveler_tick(p->fbLev, (p->levMode==0?p->decay*stringOut:stringOut)+input)); + //tLinearDelay_tickIn(p->delayLine, stringInput); + //tLinearDelay_setDelay(p->delayLine, tExpSmooth_tick(p->wlSmooth)); //p->curr = d1 + d2; return p->curr; } @@ -1231,16 +1231,16 @@ void tSimpleLivingString4_setSampleRate(tSimpleLivingString4* const p, Lfloat p->waveLengthInSamples = p->sampleRate/freq; tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); - tOnePole_setSampleRate(&p->bridgeFilter, p->sampleRate); - tHighpass_setSampleRate(&p->DCblocker, p->sampleRate); - tBiQuad_setSampleRate(&p->bridgeFilter2, p->sampleRate); + tOnePole_setSampleRate(p->bridgeFilter, p->sampleRate); + tHighpass_setSampleRate(p->DCblocker, p->sampleRate); + tBiQuad_setSampleRate(p->bridgeFilter2, p->sampleRate); } /* Simple Living String 5*/ -void tSimpleLivingString5_init(tSimpleLivingString5* const pl, int oversampling, Lfloat freq, Lfloat dampFreq, +void tSimpleLivingString5_init(tSimpleLivingString5** const pl, int oversampling, Lfloat freq, Lfloat dampFreq, Lfloat decay, Lfloat prepPos, Lfloat prepIndex, Lfloat pluckPos, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, LEAF* const leaf) { @@ -1249,9 +1249,9 @@ void tSimpleLivingString5_init(tSimpleLivingString5* const pl, int oversampli void tSimpleLivingString5_initToPool (tSimpleLivingString5** const pl, int oversampling, Lfloat freq, Lfloat dampFreq, Lfloat decay, Lfloat prepPos, Lfloat prepIndex, Lfloat pluckPos, Lfloat targetLev, Lfloat levSmoothFactor, - Lfloat levStrength, int levMode, tMempool* const mp) + Lfloat levStrength, int levMode, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tSimpleLivingString5* p = *pl = (tSimpleLivingString5*) mpool_alloc(sizeof(tSimpleLivingString5), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -1275,23 +1275,23 @@ void tSimpleLivingString5_initToPool (tSimpleLivingString5** const pl, int o tLagrangeDelay_initToPool(&p->delLF,p->waveLengthInSamples, p->maxLength, mp); tLagrangeDelay_initToPool(&p->delLB,p->waveLengthInSamples, p->maxLength, mp); tSimpleLivingString5_setFreq(p, freq); - tLagrangeDelay_setDelay(&p->delUF, p->waveLengthInSamples-(p->prepPos*p->waveLengthInSamples)); - tLagrangeDelay_setDelay(&p->delUB, p->waveLengthInSamples-((1.0f-p->prepPos)*p->waveLengthInSamples)); - tLagrangeDelay_setDelay(&p->delLF, p->waveLengthInSamples-(p->prepPos*p->waveLengthInSamples)); - tLagrangeDelay_setDelay(&p->delLB, p->waveLengthInSamples-((1.0f-p->prepPos)*p->waveLengthInSamples)); + tLagrangeDelay_setDelay(p->delUF, p->waveLengthInSamples-(p->prepPos*p->waveLengthInSamples)); + tLagrangeDelay_setDelay(p->delUB, p->waveLengthInSamples-((1.0f-p->prepPos)*p->waveLengthInSamples)); + tLagrangeDelay_setDelay(p->delLF, p->waveLengthInSamples-(p->prepPos*p->waveLengthInSamples)); + tLagrangeDelay_setDelay(p->delLB, p->waveLengthInSamples-((1.0f-p->prepPos)*p->waveLengthInSamples)); //tSimpleLivingString5_setWaveLength(pl, 4800); - tLagrangeDelay_clear(&p->delUF); - tLagrangeDelay_clear(&p->delUB); - tLagrangeDelay_clear(&p->delLF); - tLagrangeDelay_clear(&p->delLB); + tLagrangeDelay_clear(p->delUF); + tLagrangeDelay_clear(p->delUB); + tLagrangeDelay_clear(p->delLF); + tLagrangeDelay_clear(p->delLB); p->dampFreq = dampFreq; tOnePole_initToPool(&p->bridgeFilter, dampFreq, mp); - tOnePole_setSampleRate(&p->bridgeFilter, p->sampleRate); - tOnePole_setFreq(&p->bridgeFilter, dampFreq); + tOnePole_setSampleRate(p->bridgeFilter, p->sampleRate); + tOnePole_setFreq(p->bridgeFilter, dampFreq); tOnePole_initToPool(&p->nutFilter, dampFreq, mp); - tOnePole_setSampleRate(&p->nutFilter, p->sampleRate); - tOnePole_setFreq(&p->nutFilter, dampFreq); + tOnePole_setSampleRate(p->nutFilter, p->sampleRate); + tOnePole_setFreq(p->nutFilter, dampFreq); @@ -1301,12 +1301,12 @@ void tSimpleLivingString5_initToPool (tSimpleLivingString5** const pl, int o tHighpass_initToPool(&p->DCblocker,0.001f, mp); - tHighpass_setSampleRate(&p->DCblocker,p->sampleRate); - tHighpass_setFreq(&p->DCblocker,0.001f); + tHighpass_setSampleRate(p->DCblocker,p->sampleRate); + tHighpass_setFreq(p->DCblocker,0.001f); tHighpass_initToPool(&p->DCblocker2,0.001f, mp); - tHighpass_setSampleRate(&p->DCblocker2,p->sampleRate); - tHighpass_setFreq(&p->DCblocker2,0.001f); + tHighpass_setSampleRate(p->DCblocker2,p->sampleRate); + tHighpass_setFreq(p->DCblocker2,0.001f); p->userDecay = decay; p->pluckPosition = 0.8f; @@ -1373,7 +1373,7 @@ void tSimpleLivingString5_setFreq(tSimpleLivingString5* const p, Lfloat freq //Lfloat temp = ((p->userDecay * 0.01f) + 0.01f) * 6.9078f; //p->decay = exp(-6.91 * ((1.0 / p->freq) / temp)); - //tBiQuad_setCoefficients(&p->bridgeFilter2,p->temp1,p->temp2, p->temp1, 0.0f, 0.0f); + //tBiQuad_setCoefficients(p->bridgeFilter2,p->temp1,p->temp2, p->temp1, 0.0f, 0.0f); //p->decay=powf(0.001f,1.0f/(p->freq*p->userDecay)); } @@ -1390,10 +1390,10 @@ void tSimpleLivingString5_setDampFreq(tSimpleLivingString5* const p, Lfloat { //p->temp1 = (1.0f - brightness) * 0.25f * p->decay; //p->temp2 = (1.0f + brightness) * 0.5f * p->decay; - //tBiQuad_setCoefficients(&p->bridgeFilter2, p->temp1 , p->temp2, p->temp1 , 0.0f, 0.0f); + //tBiQuad_setCoefficients(p->bridgeFilter2, p->temp1 , p->temp2, p->temp1 , 0.0f, 0.0f); - tOnePole_setFreq(&p->bridgeFilter, dampFreq); - tOnePole_setFreq(&p->nutFilter, dampFreq); + tOnePole_setFreq(p->bridgeFilter, dampFreq); + tOnePole_setFreq(p->nutFilter, dampFreq); } void tSimpleLivingString5_setDecay(tSimpleLivingString5* const p, Lfloat decay) @@ -1404,7 +1404,7 @@ void tSimpleLivingString5_setDecay(tSimpleLivingString5* const p, Lfloat dec //Lfloat temp = ((decay * 0.01f) + 0.01f) * 6.9078f; //p->decay = exp(-6.91 * ((1.0 / p->freq) / temp)); p->decay = decay;//; - //tBiQuad_setCoefficients(&p->bridgeFilter2,p->temp1,p->temp2, p->temp1, 0.0f, 0.0f); + //tBiQuad_setCoefficients(p->bridgeFilter2,p->temp1,p->temp2, p->temp1, 0.0f, 0.0f); //p->decay=powf(0.001f,1.0f/(p->freq*decay)); } void tSimpleLivingString5_setPrepPosition(tSimpleLivingString5* const p, Lfloat prepPosition) @@ -1420,26 +1420,26 @@ void tSimpleLivingString5_setPrepIndex(tSimpleLivingString5* const p, Lfloat p void tSimpleLivingString5_setTargetLev(tSimpleLivingString5* const p, Lfloat targetLev) { - tFeedbackLeveler_setTargetLevel(&p->fbLev, targetLev); - tFeedbackLeveler_setTargetLevel(&p->fbLev2, targetLev); + tFeedbackLeveler_setTargetLevel(p->fbLev, targetLev); + tFeedbackLeveler_setTargetLevel(p->fbLev2, targetLev); } void tSimpleLivingString5_setLevSmoothFactor(tSimpleLivingString5* const p, Lfloat levSmoothFactor) { - tFeedbackLeveler_setFactor(&p->fbLev, levSmoothFactor); - tFeedbackLeveler_setFactor(&p->fbLev2, levSmoothFactor); + tFeedbackLeveler_setFactor(p->fbLev, levSmoothFactor); + tFeedbackLeveler_setFactor(p->fbLev2, levSmoothFactor); } void tSimpleLivingString5_setLevStrength(tSimpleLivingString5* const p, Lfloat levStrength) { - tFeedbackLeveler_setStrength(&p->fbLev, levStrength); - tFeedbackLeveler_setStrength(&p->fbLev2, levStrength); + tFeedbackLeveler_setStrength(p->fbLev, levStrength); + tFeedbackLeveler_setStrength(p->fbLev2, levStrength); } void tSimpleLivingString5_setLevMode(tSimpleLivingString5* const p, int levMode) { - tFeedbackLeveler_setMode(&p->fbLev, levMode); - tFeedbackLeveler_setMode(&p->fbLev2, levMode); + tFeedbackLeveler_setMode(p->fbLev, levMode); + tFeedbackLeveler_setMode(p->fbLev2, levMode); p->levMode=levMode; } @@ -1480,20 +1480,20 @@ void tSimpleLivingString5_pluck(tSimpleLivingString5* const p, Lfloat input, L } if (i < BLenInt) { - tLagrangeDelay_addTo(&p->delUB, val, i); - tLagrangeDelay_addTo(&p->delLB, val, BLenInt-i); + tLagrangeDelay_addTo(p->delUB, val, i); + tLagrangeDelay_addTo(p->delLB, val, BLenInt-i); } else if (i == BLenInt) { - tLagrangeDelay_addTo(&p->delUB, val * (1.0f-BLenAlpha), i); - tLagrangeDelay_addTo(&p->delLB, val * (1.0f-BLenAlpha), BLenInt-i); - tLagrangeDelay_addTo(&p->delUF, val * BLenAlpha, i-BLenInt); - tLagrangeDelay_addTo(&p->delLF, val * BLenAlpha, (FLenInt-1)-(i-BLenInt)); + tLagrangeDelay_addTo(p->delUB, val * (1.0f-BLenAlpha), i); + tLagrangeDelay_addTo(p->delLB, val * (1.0f-BLenAlpha), BLenInt-i); + tLagrangeDelay_addTo(p->delUF, val * BLenAlpha, i-BLenInt); + tLagrangeDelay_addTo(p->delLF, val * BLenAlpha, (FLenInt-1)-(i-BLenInt)); } else { - tLagrangeDelay_addTo(&p->delUF, val, i-BLenInt); - tLagrangeDelay_addTo(&p->delLF, val, (FLenInt-1)-(i-BLenInt)); + tLagrangeDelay_addTo(p->delUF, val, i-BLenInt); + tLagrangeDelay_addTo(p->delLF, val, (FLenInt-1)-(i-BLenInt)); } } } @@ -1521,10 +1521,10 @@ Lfloat tSimpleLivingString5_tick(tSimpleLivingString5* const p, Lfloat input) uint32_t FLenInt = (uint32_t)FLen; Lfloat BLen = wl*prepPosSmoothed; uint32_t BLenInt = (uint32_t)BLen; - tLagrangeDelay_setDelay(&p->delUF, FLen); - tLagrangeDelay_setDelay(&p->delUB, BLen); - tLagrangeDelay_setDelay(&p->delLF, FLen); - tLagrangeDelay_setDelay(&p->delLB, BLen); + tLagrangeDelay_setDelay(p->delUF, FLen); + tLagrangeDelay_setDelay(p->delUB, BLen); + tLagrangeDelay_setDelay(p->delLF, FLen); + tLagrangeDelay_setDelay(p->delLB, BLen); Lfloat pluckPosSmoothed = tExpSmooth_tick(p->pluckPosSmooth); Lfloat pluckPosInSamples = pluckPosSmoothed * wl; uint32_t pluckPosInSamplesInt = (uint32_t) pluckPosInSamples; @@ -1544,38 +1544,38 @@ Lfloat tSimpleLivingString5_tick(tSimpleLivingString5* const p, Lfloat input) { if (sample1 < BLenInt) { - tLagrangeDelay_addTo(&p->delUB, input * (1.0f - alpha), sample1); - tLagrangeDelay_addTo(&p->delLB, input * (1.0f - alpha), BLenInt-sample1); + tLagrangeDelay_addTo(p->delUB, input * (1.0f - alpha), sample1); + tLagrangeDelay_addTo(p->delLB, input * (1.0f - alpha), BLenInt-sample1); } else { - tLagrangeDelay_addTo(&p->delUF, input * (1.0f - alpha), sample1Front); - tLagrangeDelay_addTo(&p->delLF, input * (1.0f - alpha), FLenInt-sample1Front); + tLagrangeDelay_addTo(p->delUF, input * (1.0f - alpha), sample1Front); + tLagrangeDelay_addTo(p->delLF, input * (1.0f - alpha), FLenInt-sample1Front); } if (sample2 < BLenInt) { - tLagrangeDelay_addTo(&p->delUB, input * alpha, sample2); - tLagrangeDelay_addTo(&p->delLB, input * alpha, BLenInt-sample2); + tLagrangeDelay_addTo(p->delUB, input * alpha, sample2); + tLagrangeDelay_addTo(p->delLB, input * alpha, BLenInt-sample2); } else { - tLagrangeDelay_addTo(&p->delUF, input * alpha, sample2Front); - tLagrangeDelay_addTo(&p->delLF, input * alpha, FLenInt-sample2Front); + tLagrangeDelay_addTo(p->delUF, input * alpha, sample2Front); + tLagrangeDelay_addTo(p->delLF, input * alpha, FLenInt-sample2Front); } - Lfloat fromUF=tLagrangeDelay_tickOut(&p->delUF); - Lfloat fromLF=tLagrangeDelay_tickOut(&p->delLF); - Lfloat fromLB=tLagrangeDelay_tickOut(&p->delLB); - Lfloat fromUB=tLagrangeDelay_tickOut(&p->delUB); + Lfloat fromUF=tLagrangeDelay_tickOut(p->delUF); + Lfloat fromLF=tLagrangeDelay_tickOut(p->delLF); + Lfloat fromLB=tLagrangeDelay_tickOut(p->delLB); + Lfloat fromUB=tLagrangeDelay_tickOut(p->delUB); //fromUF = tanhf(p->fbSample1) * p->fb + fromUF*0.1f; //fromLB = tanhf(p->fbSample2) * p->fb + fromLB*0.1f; //p->fbSample1 = fromUF; //p->fbSample2 = fromLB; //fromUF = fromUF * 1.0f / (1.0f+p->fb); //fromLB = fromLB * 1.0f / (1.0f+p->fb); - //fromUF = tWavefolder_tick(&p->wf1, fromUF); - //fromLB = tWavefolder_tick(&p->wf2, fromLB); + //fromUF = tWavefolder_tick(p->wf1, fromUF); + //fromLB = tWavefolder_tick(p->wf2, fromLB); //softclip approx for tanh saturation in original code //float fromUFSat = tanhf(fromUF + input); float fromUFSat = tanhf(fromUF); @@ -1585,43 +1585,43 @@ Lfloat tSimpleLivingString5_tick(tSimpleLivingString5* const p, Lfloat input) fromLB = (p->ff * fromLBSat) + ((1.0f - p->ff) * fromLB); #if 0 - Lfloat fromBridge = -tOnePole_tick(&p->bridgeFilter, fromUF); - tLagrangeDelay_tickIn(&p->delLF, fromBridge + input); - tLagrangeDelay_tickIn(&p->delLB, fromLF); + Lfloat fromBridge = -tOnePole_tick(p->bridgeFilter, fromUF); + tLagrangeDelay_tickIn(p->delLF, fromBridge + input); + tLagrangeDelay_tickIn(p->delLB, fromLF); Lfloat fromNut=-fromLB; - tLagrangeDelay_tickIn(&p->delUB, fromNut); - tLagrangeDelay_tickIn(&p->delUF, fromUB); + tLagrangeDelay_tickIn(p->delUB, fromNut); + tLagrangeDelay_tickIn(p->delUF, fromUB); #endif // into front half of string, from bridge, going backwards (lower section) - //Lfloat fromBridge=-tFeedbackLeveler_tick(&p->fbLev, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(&p->DCblocker, tOnePole_tick(&p->bridgeFilter, fromUF))); - //Lfloat fromBridge=-tFeedbackLeveler_tick(&p->fbLev, (p->levMode==0?p->decay:1.0f)*fromUF); - Lfloat fromBridge=-p->decay*fromUF;//tOnePole_tick(&p->bridgeFilter, fromUF); - //Lfloat fromBridge=-tHighpass_tick(&p->DCblocker, tOnePole_tick(&p->bridgeFilter, fromUF)) * p->decay; //version with feedbackleveler + //Lfloat fromBridge=-tFeedbackLeveler_tick(p->fbLev, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(p->DCblocker, tOnePole_tick(p->bridgeFilter, fromUF))); + //Lfloat fromBridge=-tFeedbackLeveler_tick(p->fbLev, (p->levMode==0?p->decay:1.0f)*fromUF); + Lfloat fromBridge=-p->decay*fromUF;//tOnePole_tick(p->bridgeFilter, fromUF); + //Lfloat fromBridge=-tHighpass_tick(p->DCblocker, tOnePole_tick(p->bridgeFilter, fromUF)) * p->decay; //version with feedbackleveler //fromBridge = LEAF_clip(-1.0f, fromBridge, 1.0f); - tLagrangeDelay_tickIn(&p->delLF, fromBridge); + tLagrangeDelay_tickIn(p->delLF, fromBridge); // into back half of string, from prepPoint, going backwards (lower section) - //Lfloat fromUpperPrep=-tOnePole_tick(&p->prepFilterL, fromUB); + //Lfloat fromUpperPrep=-tOnePole_tick(p->prepFilterL, fromUB); Lfloat fromUpperPrep=-fromUB; //fromUpperPrep = LEAF_clip(-1.0f, fromUpperPrep, 1.0f); Lfloat intoLower=p->prepIndex*fromUpperPrep+(1.0f - p->prepIndex)*fromLF; //used to add input here //intoLower = LEAF_clip(-1.0f, intoLower, 1.0f); - tLagrangeDelay_tickIn(&p->delLB, intoLower); + tLagrangeDelay_tickIn(p->delLB, intoLower); // into back of string, from nut going forward (upper section) - //Lfloat fromNut=-tFeedbackLeveler_tick(&p->fbLev2, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(&p->DCblocker2,fromLB)); - //Lfloat fromNut=-tFeedbackLeveler_tick(&p->fbLev2, (p->levMode==0?p->decay:1.0f)*fromLB); - Lfloat fromNut=-p->decay*fromLB;//tOnePole_tick(&p->nutFilter, fromLB); - //Lfloat fromNut=-p->decay*tHighpass_tick(&p->DCblocker2,fromLB)); //version without feedback leveler + //Lfloat fromNut=-tFeedbackLeveler_tick(p->fbLev2, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(p->DCblocker2,fromLB)); + //Lfloat fromNut=-tFeedbackLeveler_tick(p->fbLev2, (p->levMode==0?p->decay:1.0f)*fromLB); + Lfloat fromNut=-p->decay*fromLB;//tOnePole_tick(p->nutFilter, fromLB); + //Lfloat fromNut=-p->decay*tHighpass_tick(p->DCblocker2,fromLB)); //version without feedback leveler //fromNut = LEAF_clip(-1.0f, fromNut, 1.0f); - tLagrangeDelay_tickIn(&p->delUB, fromNut); + tLagrangeDelay_tickIn(p->delUB, fromNut); // into front half of string, from prepPoint, going forward (upper section) - //Lfloat fromLowerPrep=-tOnePole_tick(&p->prepFilterU, fromLF); + //Lfloat fromLowerPrep=-tOnePole_tick(p->prepFilterU, fromLF); Lfloat fromLowerPrep=-fromLF; //fromLowerPrep = LEAF_clip(-1.0f, fromLowerPrep, 1.0f); Lfloat intoUpperFront=p->prepIndex*fromLowerPrep+(1.0f - p->prepIndex)*fromUB; //intoUpper = tanhf(intoUpper); //intoUpperFront = LEAF_clip(-1.0f, intoUpperFront, 1.0f); - tLagrangeDelay_tickIn(&p->delUF, intoUpperFront); + tLagrangeDelay_tickIn(p->delUF, intoUpperFront); p->curr = fromBridge; } @@ -1649,22 +1649,22 @@ Lfloat tSimpleLivingString5_tick(tSimpleLivingString5* const p, Lfloat input) if (pickupPosInSamples < BLen) { - outputSample1 = tLagrangeDelay_tapOutInterpolated(&p->delUB, a1, a1F); - outputSample1 += tLagrangeDelay_tapOutInterpolated(&p->delLB, a2, a2F); + outputSample1 = tLagrangeDelay_tapOutInterpolated(p->delUB, a1, a1F); + outputSample1 += tLagrangeDelay_tapOutInterpolated(p->delLB, a2, a2F); } else { - outputSample1 = tLagrangeDelay_tapOutInterpolated(&p->delUF, a3, a3F); - outputSample1 += tLagrangeDelay_tapOutInterpolated(&p->delLF, a4, a4F); + outputSample1 = tLagrangeDelay_tapOutInterpolated(p->delUF, a3, a3F); + outputSample1 += tLagrangeDelay_tapOutInterpolated(p->delLF, a4, a4F); } p->curr = 0.5f * outputSample1; //p->curr = p->Uout; p->prevDelayLength = p->waveLengthInSamples; - //Lfloat stringInput=tHighpass_tick(&p->DCblocker, tFeedbackLeveler_tick(&p->fbLev, (p->levMode==0?p->decay*stringOut:stringOut)+input)); - //tLinearDelay_tickIn(&p->delayLine, stringInput); - //tLinearDelay_setDelay(&p->delayLine, tExpSmooth_tick(&p->wlSmooth)); + //Lfloat stringInput=tHighpass_tick(p->DCblocker, tFeedbackLeveler_tick(p->fbLev, (p->levMode==0?p->decay*stringOut:stringOut)+input)); + //tLinearDelay_tickIn(p->delayLine, stringInput); + //tLinearDelay_setDelay(p->delayLine, tExpSmooth_tick(p->wlSmooth)); //p->curr = d1 + d2; return p->curr; } @@ -1689,8 +1689,8 @@ void tSimpleLivingString5_setSampleRate(tSimpleLivingString5* const p, Lfloat p->waveLengthInSamples = p->sampleRate/freq; tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); - tOnePole_setSampleRate(&p->bridgeFilter, p->sampleRate); - tHighpass_setSampleRate(&p->DCblocker, p->sampleRate); + tOnePole_setSampleRate(p->bridgeFilter, p->sampleRate); + tHighpass_setSampleRate(p->DCblocker, p->sampleRate); } @@ -1755,10 +1755,10 @@ void tLivingString_setPrepIndex(tLivingString* const p, Lfloat prepIndex) void tLivingString_setDampFreq(tLivingString* const p, Lfloat dampFreq) { - tOnePole_setFreq(&p->bridgeFilter, dampFreq); - tOnePole_setFreq(&p->nutFilter, dampFreq); - tOnePole_setFreq(&p->prepFilterU, dampFreq); - tOnePole_setFreq(&p->prepFilterL, dampFreq); + tOnePole_setFreq(p->bridgeFilter, dampFreq); + tOnePole_setFreq(p->nutFilter, dampFreq); + tOnePole_setFreq(p->prepFilterU, dampFreq); + tOnePole_setFreq(p->prepFilterL, dampFreq); } void tLivingString_setDecay(tLivingString* const p, Lfloat decay) @@ -1768,59 +1768,59 @@ void tLivingString_setDecay(tLivingString* const p, Lfloat decay) void tLivingString_setTargetLev(tLivingString* const p, Lfloat targetLev) { - tFeedbackLeveler_setTargetLevel(&p->fbLevU, targetLev); - tFeedbackLeveler_setTargetLevel(&p->fbLevL, targetLev); + tFeedbackLeveler_setTargetLevel(p->fbLevU, targetLev); + tFeedbackLeveler_setTargetLevel(p->fbLevL, targetLev); } void tLivingString_setLevSmoothFactor(tLivingString* const p, Lfloat levSmoothFactor) { - tFeedbackLeveler_setFactor(&p->fbLevU, levSmoothFactor); - tFeedbackLeveler_setFactor(&p->fbLevL, levSmoothFactor); + tFeedbackLeveler_setFactor(p->fbLevU, levSmoothFactor); + tFeedbackLeveler_setFactor(p->fbLevL, levSmoothFactor); } void tLivingString_setLevStrength(tLivingString* const p, Lfloat levStrength) { - tFeedbackLeveler_setStrength(&p->fbLevU, levStrength); - tFeedbackLeveler_setStrength(&p->fbLevL, levStrength); + tFeedbackLeveler_setStrength(p->fbLevU, levStrength); + tFeedbackLeveler_setStrength(p->fbLevL, levStrength); } void tLivingString_setLevMode(tLivingString* const p, int levMode) { - tFeedbackLeveler_setMode(&p->fbLevU, levMode); - tFeedbackLeveler_setMode(&p->fbLevL, levMode); + tFeedbackLeveler_setMode(p->fbLevU, levMode); + tFeedbackLeveler_setMode(p->fbLevL, levMode); p->levMode=levMode; } Lfloat tLivingString_tick(tLivingString *const p, Lfloat input) { // from pickPos upwards=forwards - Lfloat fromLF=tLinearDelay_tickOut(&p->delLF); - Lfloat fromUF=tLinearDelay_tickOut(&p->delUF); - Lfloat fromUB=tLinearDelay_tickOut(&p->delUB); - Lfloat fromLB=tLinearDelay_tickOut(&p->delLB); + Lfloat fromLF=tLinearDelay_tickOut(p->delLF); + Lfloat fromUF=tLinearDelay_tickOut(p->delUF); + Lfloat fromUB=tLinearDelay_tickOut(p->delUB); + Lfloat fromLB=tLinearDelay_tickOut(p->delLB); // into upper half of string, from nut, going backwards - Lfloat fromNut=-tFeedbackLeveler_tick(&p->fbLevU, (p->levMode==0?p->decay:1)*tHighpass_tick(&p->DCblockerU, tOnePole_tick(&p->nutFilter, fromUF))); - tLinearDelay_tickIn(&p->delUB, fromNut); + Lfloat fromNut=-tFeedbackLeveler_tick(p->fbLevU, (p->levMode==0?p->decay:1)*tHighpass_tick(p->DCblockerU, tOnePole_tick(p->nutFilter, fromUF))); + tLinearDelay_tickIn(p->delUB, fromNut); // into lower half of string, from pickpoint, going backwards - Lfloat fromLowerPrep=-tOnePole_tick(&p->prepFilterL, fromLF); + Lfloat fromLowerPrep=-tOnePole_tick(p->prepFilterL, fromLF); Lfloat intoLower=p->prepIndex*fromLowerPrep+(1.0f - p->prepIndex)*fromUB+input; - tLinearDelay_tickIn(&p->delLB, intoLower); + tLinearDelay_tickIn(p->delLB, intoLower); // into lower half of string, from bridge - Lfloat fromBridge=-tFeedbackLeveler_tick(&p->fbLevL, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(&p->DCblockerL, tOnePole_tick(&p->bridgeFilter, fromLB))); - tLinearDelay_tickIn(&p->delLF, fromBridge); + Lfloat fromBridge=-tFeedbackLeveler_tick(p->fbLevL, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(p->DCblockerL, tOnePole_tick(p->bridgeFilter, fromLB))); + tLinearDelay_tickIn(p->delLF, fromBridge); // into upper half of string, from pickpoint, going forwards/upwards - Lfloat fromUpperPrep=-tOnePole_tick(&p->prepFilterU, fromUB); + Lfloat fromUpperPrep=-tOnePole_tick(p->prepFilterU, fromUB); Lfloat intoUpper=p->prepIndex*fromUpperPrep+(1.0f - p->prepIndex)*fromLF+input; - tLinearDelay_tickIn(&p->delUF, intoUpper); + tLinearDelay_tickIn(p->delUF, intoUpper); // update all delay lengths Lfloat pickP=tExpSmooth_tick(p->ppSmooth); Lfloat wLen=tExpSmooth_tick(p->wlSmooth); Lfloat lowLen=pickP*wLen; Lfloat upLen=(1.0f-pickP)*wLen; - tLinearDelay_setDelay(&p->delLF, lowLen); - tLinearDelay_setDelay(&p->delLB, lowLen); - tLinearDelay_setDelay(&p->delUF, upLen); - tLinearDelay_setDelay(&p->delUB, upLen); + tLinearDelay_setDelay(p->delLF, lowLen); + tLinearDelay_setDelay(p->delLB, lowLen); + tLinearDelay_setDelay(p->delUF, upLen); + tLinearDelay_setDelay(p->delUB, upLen); p->curr = fromBridge; return p->curr; } @@ -1836,12 +1836,12 @@ void tLivingString_setSampleRate(tLivingString* const p, Lfloat sr) p->sampleRate = sr; p->waveLengthInSamples = p->sampleRate/freq; tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); - tOnePole_setSampleRate(&p->bridgeFilter, p->sampleRate); - tOnePole_setSampleRate(&p->nutFilter, p->sampleRate); - tOnePole_setSampleRate(&p->prepFilterU, p->sampleRate); - tOnePole_setSampleRate(&p->prepFilterL, p->sampleRate); - tHighpass_setSampleRate(&p->DCblockerU, p->sampleRate); - tHighpass_setSampleRate(&p->DCblockerL, p->sampleRate); + tOnePole_setSampleRate(p->bridgeFilter, p->sampleRate); + tOnePole_setSampleRate(p->nutFilter, p->sampleRate); + tOnePole_setSampleRate(p->prepFilterU, p->sampleRate); + tOnePole_setSampleRate(p->prepFilterL, p->sampleRate); + tHighpass_setSampleRate(p->DCblockerU, p->sampleRate); + tHighpass_setSampleRate(p->DCblockerL, p->sampleRate); } @@ -1851,7 +1851,7 @@ void tLivingString_setSampleRate(tLivingString* const p, Lfloat sr) /* Living String*/ -void tLivingString2_init(tLivingString2* const pl, Lfloat freq, Lfloat pickPos, Lfloat prepPos, Lfloat pickupPos, Lfloat prepIndex, +void tLivingString2_init(tLivingString2** const pl, Lfloat freq, Lfloat pickPos, Lfloat prepPos, Lfloat pickupPos, Lfloat prepIndex, Lfloat brightness, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, LEAF* const leaf) { @@ -1860,9 +1860,9 @@ void tLivingString2_init(tLivingString2* const pl, Lfloat freq, Lfloat pickPo void tLivingString2_initToPool (tLivingString2** const pl, Lfloat freq, Lfloat pickPos, Lfloat prepPos, Lfloat pickupPos, Lfloat prepIndex, Lfloat brightness, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, - Lfloat levStrength, int levMode, tMempool* const mp) + Lfloat levStrength, int levMode, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tLivingString2* p = *pl = (tLivingString2*) mpool_alloc(sizeof(tLivingString2), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -1884,10 +1884,10 @@ void tLivingString2_initToPool (tLivingString2** const pl, Lfloat freq, Lf tHermiteDelay_initToPool(&p->delUF,p->waveLengthInSamples, 2400, mp); tHermiteDelay_initToPool(&p->delUB,p->waveLengthInSamples, 2400, mp); tHermiteDelay_initToPool(&p->delLB,p->waveLengthInSamples, 2400, mp); - tHermiteDelay_clear(&p->delLF); - tHermiteDelay_clear(&p->delUF); - tHermiteDelay_clear(&p->delUB); - tHermiteDelay_clear(&p->delLB); + tHermiteDelay_clear(p->delLF); + tHermiteDelay_clear(p->delUF); + tHermiteDelay_clear(p->delUB); + tHermiteDelay_clear(p->delLB); p->brightness = brightness; tTwoZero_initToPool(&p->bridgeFilter, mp); tTwoZero_initToPool(&p->nutFilter, mp); @@ -1983,10 +1983,10 @@ void tLivingString2_setBrightness(tLivingString2* const p, Lfloat brightness Lfloat h0=(1.0 + brightness) * 0.5f; Lfloat h1=(1.0 - brightness) * 0.25f; - tTwoZero_setCoefficients(&p->bridgeFilter, h1, h0, h1); - tTwoZero_setCoefficients(&p->nutFilter, h1, h0, h1); - tTwoZero_setCoefficients(&p->prepFilterU, h1, h0, h1); - tTwoZero_setCoefficients(&p->prepFilterL, h1, h0, h1); + tTwoZero_setCoefficients(p->bridgeFilter, h1, h0, h1); + tTwoZero_setCoefficients(p->nutFilter, h1, h0, h1); + tTwoZero_setCoefficients(p->prepFilterU, h1, h0, h1); + tTwoZero_setCoefficients(p->prepFilterL, h1, h0, h1); } void tLivingString2_setDecay(tLivingString2* const p, Lfloat decay) @@ -1996,26 +1996,26 @@ void tLivingString2_setDecay(tLivingString2* const p, Lfloat decay) void tLivingString2_setTargetLev(tLivingString2* const p, Lfloat targetLev) { - tFeedbackLeveler_setTargetLevel(&p->fbLevU, targetLev); - tFeedbackLeveler_setTargetLevel(&p->fbLevL, targetLev); + tFeedbackLeveler_setTargetLevel(p->fbLevU, targetLev); + tFeedbackLeveler_setTargetLevel(p->fbLevL, targetLev); } void tLivingString2_setLevSmoothFactor(tLivingString2* const p, Lfloat levSmoothFactor) { - tFeedbackLeveler_setFactor(&p->fbLevU, levSmoothFactor); - tFeedbackLeveler_setFactor(&p->fbLevL, levSmoothFactor); + tFeedbackLeveler_setFactor(p->fbLevU, levSmoothFactor); + tFeedbackLeveler_setFactor(p->fbLevL, levSmoothFactor); } void tLivingString2_setLevStrength(tLivingString2* const p, Lfloat levStrength) { - tFeedbackLeveler_setStrength(&p->fbLevU, levStrength); - tFeedbackLeveler_setStrength(&p->fbLevL, levStrength); + tFeedbackLeveler_setStrength(p->fbLevU, levStrength); + tFeedbackLeveler_setStrength(p->fbLevL, levStrength); } void tLivingString2_setLevMode(tLivingString2* const p, int levMode) { - tFeedbackLeveler_setMode(&p->fbLevU, levMode); - tFeedbackLeveler_setMode(&p->fbLevL, levMode); + tFeedbackLeveler_setMode(p->fbLevU, levMode); + tFeedbackLeveler_setMode(p->fbLevL, levMode); p->levMode=levMode; } @@ -2027,7 +2027,7 @@ Lfloat tLivingString2_tick(tLivingString2* const p, Lfloat input) Lfloat pickP=tExpSmooth_tick(p->ppSmooth); - //Lfloat pickupPos=tExpSmooth_tick(&p->puSmooth); + //Lfloat pickupPos=tExpSmooth_tick(p->puSmooth); //need to determine which delay line to put it into (should be half amplitude into forward and backward lines for the correct portion of string) Lfloat prepP=tExpSmooth_tick(p->prpSmooth); @@ -2041,10 +2041,10 @@ Lfloat tLivingString2_tick(tLivingString2* const p, Lfloat input) pickPInt = (uint32_t) fullPickPoint; // where does the input go? that's the pick point Lfloat pickPLfloat = fullPickPoint - pickPInt; - tHermiteDelay_addTo(&p->delUF, input * (1.0f - pickPLfloat), pickPInt); - tHermiteDelay_addTo(&p->delUF, input * pickPLfloat, pickPInt + 1); - tHermiteDelay_addTo(&p->delUB, input * (1.0f - pickPLfloat), (uint32_t) (upLen - pickPInt)); - tHermiteDelay_addTo(&p->delUB, input * pickPLfloat, (uint32_t) (upLen - pickPInt - 1)); + tHermiteDelay_addTo(p->delUF, input * (1.0f - pickPLfloat), pickPInt); + tHermiteDelay_addTo(p->delUF, input * pickPLfloat, pickPInt + 1); + tHermiteDelay_addTo(p->delUB, input * (1.0f - pickPLfloat), (uint32_t) (upLen - pickPInt)); + tHermiteDelay_addTo(p->delUB, input * pickPLfloat, (uint32_t) (upLen - pickPInt - 1)); } else { @@ -2052,10 +2052,10 @@ Lfloat tLivingString2_tick(tLivingString2* const p, Lfloat input) pickPInt = (uint32_t) fullPickPoint; // where does the input go? that's the pick point Lfloat pickPLfloat = fullPickPoint - pickPInt; - tHermiteDelay_addTo(&p->delLF, input * (1.0f - pickPLfloat), pickPInt); - tHermiteDelay_addTo(&p->delLF, input * pickPLfloat, pickPInt + 1); - tHermiteDelay_addTo(&p->delLB, input * (1.0f - pickPLfloat), (uint32_t) (lowLen - pickPInt)); - tHermiteDelay_addTo(&p->delLB, input * pickPLfloat, (uint32_t) (lowLen - pickPInt - 1)); + tHermiteDelay_addTo(p->delLF, input * (1.0f - pickPLfloat), pickPInt); + tHermiteDelay_addTo(p->delLF, input * pickPLfloat, pickPInt + 1); + tHermiteDelay_addTo(p->delLB, input * (1.0f - pickPLfloat), (uint32_t) (lowLen - pickPInt)); + tHermiteDelay_addTo(p->delLB, input * pickPLfloat, (uint32_t) (lowLen - pickPInt - 1)); } /* if (pickP > prepP) @@ -2063,54 +2063,54 @@ Lfloat tLivingString2_tick(tLivingString2* const p, Lfloat input) Lfloat fullPickPoint = ((pickP*wLen) - lowLen); pickPInt = (uint32_t) fullPickPoint; // where does the input go? that's the pick point - tHermiteDelay_addTo(&p->delUF, input, pickPInt); - tHermiteDelay_addTo(&p->delUB, input, (uint32_t) (upLen - pickPInt)); + tHermiteDelay_addTo(p->delUF, input, pickPInt); + tHermiteDelay_addTo(p->delUB, input, (uint32_t) (upLen - pickPInt)); } else { Lfloat fullPickPoint = pickP * wLen; pickPInt = (uint32_t) fullPickPoint; // where does the input go? that's the pick point - tHermiteDelay_addTo(&p->delLF, input, pickPInt); - tHermiteDelay_addTo(&p->delLB, input, (uint32_t) (lowLen - pickPInt)); + tHermiteDelay_addTo(p->delLF, input, pickPInt); + tHermiteDelay_addTo(p->delLB, input, (uint32_t) (lowLen - pickPInt)); } */ - Lfloat fromLF=tHermiteDelay_tickOut(&p->delLF); - Lfloat fromUF=tHermiteDelay_tickOut(&p->delUF); - Lfloat fromUB=tHermiteDelay_tickOut(&p->delUB); - Lfloat fromLB=tHermiteDelay_tickOut(&p->delLB); + Lfloat fromLF=tHermiteDelay_tickOut(p->delLF); + Lfloat fromUF=tHermiteDelay_tickOut(p->delUF); + Lfloat fromUB=tHermiteDelay_tickOut(p->delUB); + Lfloat fromLB=tHermiteDelay_tickOut(p->delLB); fromLB = LEAF_clip(-1.0f, fromLB, 1.0f); fromUB = LEAF_clip(-1.0f, fromUB, 1.0f); fromUF = LEAF_clip(-1.0f, fromUF, 1.0f); fromLF = LEAF_clip(-1.0f, fromLF, 1.0f); // into upper half of string, from bridge, going backwards - Lfloat fromBridge=-tFeedbackLeveler_tick(&p->fbLevU, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(&p->DCblockerU, tTwoZero_tick(&p->bridgeFilter, fromUF))); + Lfloat fromBridge=-tFeedbackLeveler_tick(p->fbLevU, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(p->DCblockerU, tTwoZero_tick(p->bridgeFilter, fromUF))); fromBridge = LEAF_clip(-1.0f, fromBridge, 1.0f); - tHermiteDelay_tickIn(&p->delUB, fromBridge); + tHermiteDelay_tickIn(p->delUB, fromBridge); // into lower half of string, from prepPoint, going backwards - Lfloat fromLowerPrep=-tTwoZero_tick(&p->prepFilterL, fromLF); + Lfloat fromLowerPrep=-tTwoZero_tick(p->prepFilterL, fromLF); fromLowerPrep = LEAF_clip(-1.0f, fromLowerPrep, 1.0f); Lfloat intoLower=p->prepIndex*fromLowerPrep+(1.0f - p->prepIndex)*fromUB; //used to add input here intoLower = LEAF_clip(-1.0f, intoLower, 1.0f); - tHermiteDelay_tickIn(&p->delLB, intoLower); + tHermiteDelay_tickIn(p->delLB, intoLower); // into lower half of string, from nut - Lfloat fromNut=-tFeedbackLeveler_tick(&p->fbLevL, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(&p->DCblockerL, tTwoZero_tick(&p->nutFilter, fromLB))); + Lfloat fromNut=-tFeedbackLeveler_tick(p->fbLevL, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(p->DCblockerL, tTwoZero_tick(p->nutFilter, fromLB))); fromNut = LEAF_clip(-1.0f, fromNut, 1.0f); - tHermiteDelay_tickIn(&p->delLF, fromNut); + tHermiteDelay_tickIn(p->delLF, fromNut); // into upper half of string, from prepPoint, going forwards/upwards - Lfloat fromUpperPrep=-tTwoZero_tick(&p->prepFilterU, fromUB); + Lfloat fromUpperPrep=-tTwoZero_tick(p->prepFilterU, fromUB); fromUpperPrep = LEAF_clip(-1.0f, fromUpperPrep, 1.0f); Lfloat intoUpper=p->prepIndex*fromUpperPrep+(1.0f - p->prepIndex)*fromLF; //intoUpper = tanhf(intoUpper); intoUpper = LEAF_clip(-1.0f, intoUpper, 1.0f); - tHermiteDelay_tickIn(&p->delUF, intoUpper); + tHermiteDelay_tickIn(p->delUF, intoUpper); // update all delay lengths - tHermiteDelay_setDelay(&p->delLF, lowLen); - tHermiteDelay_setDelay(&p->delLB, lowLen); - tHermiteDelay_setDelay(&p->delUF, upLen); - tHermiteDelay_setDelay(&p->delUB, upLen); + tHermiteDelay_setDelay(p->delLF, lowLen); + tHermiteDelay_setDelay(p->delLB, lowLen); + tHermiteDelay_setDelay(p->delUF, upLen); + tHermiteDelay_setDelay(p->delUB, upLen); uint32_t PUPInt; Lfloat pickupOut = 0.0f; @@ -2123,10 +2123,10 @@ Lfloat tLivingString2_tick(tLivingString2* const p, Lfloat input) PUPInt = (uint32_t) fullPUPoint; // where does the input go? that's the pick point Lfloat PUPLfloat = fullPUPoint - PUPInt; - pickupOut = tHermiteDelay_tapOut(&p->delUF, PUPInt) * (1.0f - PUPLfloat); - pickupOut += tHermiteDelay_tapOut(&p->delUF, PUPInt + 1) * PUPLfloat; - pickupOut += tHermiteDelay_tapOut(&p->delUB, (uint32_t) (upLen - PUPInt)) * (1.0f - PUPLfloat); - pickupOut += tHermiteDelay_tapOut(&p->delUB, (uint32_t) (upLen - PUPInt - 1)) * PUPLfloat; + pickupOut = tHermiteDelay_tapOut(p->delUF, PUPInt) * (1.0f - PUPLfloat); + pickupOut += tHermiteDelay_tapOut(p->delUF, PUPInt + 1) * PUPLfloat; + pickupOut += tHermiteDelay_tapOut(p->delUB, (uint32_t) (upLen - PUPInt)) * (1.0f - PUPLfloat); + pickupOut += tHermiteDelay_tapOut(p->delUB, (uint32_t) (upLen - PUPInt - 1)) * PUPLfloat; } else { @@ -2134,10 +2134,10 @@ Lfloat tLivingString2_tick(tLivingString2* const p, Lfloat input) PUPInt = (uint32_t) fullPUPoint; // where does the input go? that's the pick point Lfloat PUPLfloat = fullPUPoint - PUPInt; - pickupOut = tHermiteDelay_tapOut(&p->delLF, PUPInt) * (1.0f - PUPLfloat); - pickupOut += tHermiteDelay_tapOut(&p->delLF, PUPInt + 1) * PUPLfloat; - pickupOut += tHermiteDelay_tapOut(&p->delLB, (uint32_t) (lowLen - PUPInt)) * (1.0f - PUPLfloat); - pickupOut += tHermiteDelay_tapOut(&p->delLB, (uint32_t) (lowLen - PUPInt - 1)) * PUPLfloat; + pickupOut = tHermiteDelay_tapOut(p->delLF, PUPInt) * (1.0f - PUPLfloat); + pickupOut += tHermiteDelay_tapOut(p->delLF, PUPInt + 1) * PUPLfloat; + pickupOut += tHermiteDelay_tapOut(p->delLB, (uint32_t) (lowLen - PUPInt)) * (1.0f - PUPLfloat); + pickupOut += tHermiteDelay_tapOut(p->delLB, (uint32_t) (lowLen - PUPInt - 1)) * PUPLfloat; } p->curr = pickupOut; @@ -2153,8 +2153,8 @@ Lfloat tLivingString2_tick(tLivingString2* const p, Lfloat input) { pickupPosInt = 1; } - pickupOut = tHermiteDelay_tapOutInterpolated(&p->delUF, pickupPosInt, pickupPosLfloat); - pickupOut += tHermiteDelay_tapOutInterpolated(&p->delUB, (uint32_t) (upLen - pickupPosInt), pickupPosLfloat); + pickupOut = tHermiteDelay_tapOutInterpolated(p->delUF, pickupPosInt, pickupPosLfloat); + pickupOut += tHermiteDelay_tapOutInterpolated(p->delUB, (uint32_t) (upLen - pickupPosInt), pickupPosLfloat); p->curr = pickupOut; */ } @@ -2174,7 +2174,7 @@ Lfloat tLivingString2_tickEfficient(tLivingString2* const p, Lfloat input) { input = input * 0.5f; // drop gain by half since we'll be equally adding it at half amplitude to forward and backward waveguides // from prepPos upwards=forwards - //Lfloat pickupPos=tExpSmooth_tick(&p->puSmooth); + //Lfloat pickupPos=tExpSmooth_tick(p->puSmooth); Lfloat wLen = p->wlSmooth->dest; Lfloat pickP = p->ppSmooth->dest; @@ -2189,37 +2189,37 @@ Lfloat tLivingString2_tickEfficient(tLivingString2* const p, Lfloat input) Lfloat fullPickPoint = ((pickP*wLen) - lowLen); pickPInt = (uint32_t) fullPickPoint; // where does the input go? that's the pick point - tHermiteDelay_addTo(&p->delUF, input, pickPInt); - tHermiteDelay_addTo(&p->delUB, input, (uint32_t) (upLen - pickPInt)); + tHermiteDelay_addTo(p->delUF, input, pickPInt); + tHermiteDelay_addTo(p->delUB, input, (uint32_t) (upLen - pickPInt)); } else { Lfloat fullPickPoint = pickP * wLen; pickPInt = (uint32_t) fullPickPoint; // where does the input go? that's the pick point - tHermiteDelay_addTo(&p->delLF, input, pickPInt); - tHermiteDelay_addTo(&p->delLB, input, (uint32_t) (lowLen - pickPInt)); + tHermiteDelay_addTo(p->delLF, input, pickPInt); + tHermiteDelay_addTo(p->delLB, input, (uint32_t) (lowLen - pickPInt)); } - Lfloat fromLF=tHermiteDelay_tickOut(&p->delLF); - Lfloat fromUF=tHermiteDelay_tickOut(&p->delUF); - Lfloat fromUB=tHermiteDelay_tickOut(&p->delUB); - Lfloat fromLB=tHermiteDelay_tickOut(&p->delLB); + Lfloat fromLF=tHermiteDelay_tickOut(p->delLF); + Lfloat fromUF=tHermiteDelay_tickOut(p->delUF); + Lfloat fromUB=tHermiteDelay_tickOut(p->delUB); + Lfloat fromLB=tHermiteDelay_tickOut(p->delLB); // into upper half of string, from bridge, going backwards - //Lfloat fromBridge=-tFeedbackLeveler_tick(&p->fbLevU, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(&p->DCblockerU, tTwoZero_tick(&p->bridgeFilter, fromUF))); - Lfloat fromBridge=-tFeedbackLeveler_tick(&p->fbLevU,tHighpass_tick(&p->DCblockerU, tTwoZero_tick(&p->bridgeFilter, fromUF))); - tHermiteDelay_tickIn(&p->delUB, fromBridge); + //Lfloat fromBridge=-tFeedbackLeveler_tick(p->fbLevU, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(p->DCblockerU, tTwoZero_tick(p->bridgeFilter, fromUF))); + Lfloat fromBridge=-tFeedbackLeveler_tick(p->fbLevU,tHighpass_tick(p->DCblockerU, tTwoZero_tick(p->bridgeFilter, fromUF))); + tHermiteDelay_tickIn(p->delUB, fromBridge); // into lower half of string, from prepPoint, going backwards - Lfloat fromLowerPrep=-tTwoZero_tick(&p->prepFilterL, fromLF); + Lfloat fromLowerPrep=-tTwoZero_tick(p->prepFilterL, fromLF); Lfloat intoLower=(p->prepIndex*fromLowerPrep)+((1.0f - p->prepIndex)*fromUB); //used to add input here - tHermiteDelay_tickIn(&p->delLB, intoLower); + tHermiteDelay_tickIn(p->delLB, intoLower); // into lower half of string, from nut - //Lfloat fromNut=-tFeedbackLeveler_tick(&p->fbLevL, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(&p->DCblockerL, tTwoZero_tick(&p->nutFilter, fromLB))); - Lfloat fromNut=-tFeedbackLeveler_tick(&p->fbLevL,tHighpass_tick(&p->DCblockerL, tTwoZero_tick(&p->nutFilter, fromLB))); - tHermiteDelay_tickIn(&p->delLF, fromNut); + //Lfloat fromNut=-tFeedbackLeveler_tick(p->fbLevL, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(p->DCblockerL, tTwoZero_tick(p->nutFilter, fromLB))); + Lfloat fromNut=-tFeedbackLeveler_tick(p->fbLevL,tHighpass_tick(p->DCblockerL, tTwoZero_tick(p->nutFilter, fromLB))); + tHermiteDelay_tickIn(p->delLF, fromNut); // into upper half of string, from prepPoint, going forwards/upwards - Lfloat fromUpperPrep=-tTwoZero_tick(&p->prepFilterU, fromUB); + Lfloat fromUpperPrep=-tTwoZero_tick(p->prepFilterU, fromUB); Lfloat intoUpper=(p->prepIndex*fromUpperPrep)+((1.0f - p->prepIndex)*fromLF); - tHermiteDelay_tickIn(&p->delUF, intoUpper); + tHermiteDelay_tickIn(p->delUF, intoUpper); // update all delay lengths p->curr = fromBridge; @@ -2238,10 +2238,10 @@ void tLivingString2_updateDelays(tLivingString2* const p) Lfloat lowLen=p->prpSmooth->dest*p->wlSmooth->dest; Lfloat upLen=(1.0f-p->prpSmooth->dest)*p->wlSmooth->dest; - tHermiteDelay_setDelay(&p->delLF, lowLen); - tHermiteDelay_setDelay(&p->delLB, lowLen); - tHermiteDelay_setDelay(&p->delUF, upLen); - tHermiteDelay_setDelay(&p->delUB, upLen); + tHermiteDelay_setDelay(p->delLF, lowLen); + tHermiteDelay_setDelay(p->delLB, lowLen); + tHermiteDelay_setDelay(p->delUF, upLen); + tHermiteDelay_setDelay(p->delUB, upLen); } Lfloat tLivingString2_sample(tLivingString2* const p) @@ -2254,12 +2254,12 @@ void tLivingString2_setSampleRate(tLivingString2* const p, Lfloat sr) p->sampleRate = sr; p->waveLengthInSamples = (p->sampleRate/p->freq) - 1; tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); - tTwoZero_setSampleRate(&p->bridgeFilter, p->sampleRate); - tTwoZero_setSampleRate(&p->nutFilter, p->sampleRate); - tTwoZero_setSampleRate(&p->prepFilterU, p->sampleRate); - tTwoZero_setSampleRate(&p->prepFilterL, p->sampleRate); - tHighpass_setSampleRate(&p->DCblockerU, p->sampleRate); - tHighpass_setSampleRate(&p->DCblockerL, p->sampleRate); + tTwoZero_setSampleRate(p->bridgeFilter, p->sampleRate); + tTwoZero_setSampleRate(p->nutFilter, p->sampleRate); + tTwoZero_setSampleRate(p->prepFilterU, p->sampleRate); + tTwoZero_setSampleRate(p->prepFilterL, p->sampleRate); + tHighpass_setSampleRate(p->DCblockerU, p->sampleRate); + tHighpass_setSampleRate(p->DCblockerL, p->sampleRate); } @@ -2267,7 +2267,7 @@ void tLivingString2_setSampleRate(tLivingString2* const p, Lfloat sr) /* Complex Living String (has pick position and preparation position separated) */ -void tComplexLivingString_init(tComplexLivingString* const pl, Lfloat freq, Lfloat pickPos, Lfloat prepPos, Lfloat prepIndex, +void tComplexLivingString_init(tComplexLivingString** const pl, Lfloat freq, Lfloat pickPos, Lfloat prepPos, Lfloat prepIndex, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, Lfloat levStrength, int levMode, LEAF* const leaf) { @@ -2276,9 +2276,9 @@ void tComplexLivingString_init(tComplexLivingString* const pl, Lfloat freq, L void tComplexLivingString_initToPool (tComplexLivingString** const pl, Lfloat freq, Lfloat pickPos, Lfloat prepPos, Lfloat prepIndex, Lfloat dampFreq, Lfloat decay, Lfloat targetLev, Lfloat levSmoothFactor, - Lfloat levStrength, int levMode, tMempool* const mp) + Lfloat levStrength, int levMode, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tComplexLivingString* p = *pl = (tComplexLivingString*) mpool_alloc(sizeof(tComplexLivingString), m); p->mempool = m; LEAF* leaf = p->mempool->leaf; @@ -2302,12 +2302,12 @@ void tComplexLivingString_initToPool (tComplexLivingString** const pl, Lfl tLinearDelay_initToPool(&p->delUB,p->waveLengthInSamples, 2400, mp); tLinearDelay_initToPool(&p->delMB,p->waveLengthInSamples, 2400, mp); tLinearDelay_initToPool(&p->delLB,p->waveLengthInSamples, 2400, mp); - tLinearDelay_clear(&p->delLF); - tLinearDelay_clear(&p->delMF); - tLinearDelay_clear(&p->delUF); - tLinearDelay_clear(&p->delUB); - tLinearDelay_clear(&p->delMB); - tLinearDelay_clear(&p->delLB); + tLinearDelay_clear(p->delLF); + tLinearDelay_clear(p->delMF); + tLinearDelay_clear(p->delUF); + tLinearDelay_clear(p->delUB); + tLinearDelay_clear(p->delMB); + tLinearDelay_clear(p->delLB); p->dampFreq = dampFreq; tOnePole_initToPool(&p->bridgeFilter, dampFreq, mp); tOnePole_initToPool(&p->nutFilter, dampFreq, mp); @@ -2388,10 +2388,10 @@ void tComplexLivingString_setPrepIndex(tComplexLivingString* const p, Lfloat void tComplexLivingString_setDampFreq(tComplexLivingString* const p, Lfloat dampFreq) { - tOnePole_setFreq(&p->bridgeFilter, dampFreq); - tOnePole_setFreq(&p->nutFilter, dampFreq); - tOnePole_setFreq(&p->prepFilterU, dampFreq); - tOnePole_setFreq(&p->prepFilterL, dampFreq); + tOnePole_setFreq(p->bridgeFilter, dampFreq); + tOnePole_setFreq(p->nutFilter, dampFreq); + tOnePole_setFreq(p->prepFilterU, dampFreq); + tOnePole_setFreq(p->prepFilterL, dampFreq); } void tComplexLivingString_setDecay(tComplexLivingString* const p, Lfloat decay) @@ -2401,64 +2401,64 @@ void tComplexLivingString_setDecay(tComplexLivingString* const p, Lfloat dec void tComplexLivingString_setTargetLev(tComplexLivingString* const p, Lfloat targetLev) { - tFeedbackLeveler_setTargetLevel(&p->fbLevU, targetLev); - tFeedbackLeveler_setTargetLevel(&p->fbLevL, targetLev); + tFeedbackLeveler_setTargetLevel(p->fbLevU, targetLev); + tFeedbackLeveler_setTargetLevel(p->fbLevL, targetLev); } void tComplexLivingString_setLevSmoothFactor(tComplexLivingString* const p, Lfloat levSmoothFactor) { - tFeedbackLeveler_setFactor(&p->fbLevU, levSmoothFactor); - tFeedbackLeveler_setFactor(&p->fbLevL, levSmoothFactor); + tFeedbackLeveler_setFactor(p->fbLevU, levSmoothFactor); + tFeedbackLeveler_setFactor(p->fbLevL, levSmoothFactor); } void tComplexLivingString_setLevStrength(tComplexLivingString* const p, Lfloat levStrength) { - tFeedbackLeveler_setStrength(&p->fbLevU, levStrength); - tFeedbackLeveler_setStrength(&p->fbLevL, levStrength); + tFeedbackLeveler_setStrength(p->fbLevU, levStrength); + tFeedbackLeveler_setStrength(p->fbLevL, levStrength); } void tComplexLivingString_setLevMode(tComplexLivingString* const p, int levMode) { - tFeedbackLeveler_setMode(&p->fbLevU, levMode); - tFeedbackLeveler_setMode(&p->fbLevL, levMode); + tFeedbackLeveler_setMode(p->fbLevU, levMode); + tFeedbackLeveler_setMode(p->fbLevL, levMode); p->levMode=levMode; } Lfloat tComplexLivingString_tick(tComplexLivingString* const p, Lfloat input) { // from pickPos upwards=forwards - Lfloat fromLF=tLinearDelay_tickOut(&p->delLF); - Lfloat fromMF=tLinearDelay_tickOut(&p->delMF); - Lfloat fromUF=tLinearDelay_tickOut(&p->delUF); - Lfloat fromUB=tLinearDelay_tickOut(&p->delUB); - Lfloat fromMB=tLinearDelay_tickOut(&p->delMB); - Lfloat fromLB=tLinearDelay_tickOut(&p->delLB); + Lfloat fromLF=tLinearDelay_tickOut(p->delLF); + Lfloat fromMF=tLinearDelay_tickOut(p->delMF); + Lfloat fromUF=tLinearDelay_tickOut(p->delUF); + Lfloat fromUB=tLinearDelay_tickOut(p->delUB); + Lfloat fromMB=tLinearDelay_tickOut(p->delMB); + Lfloat fromLB=tLinearDelay_tickOut(p->delLB); // into upper part of string, from bridge, going backwards - Lfloat fromBridge=-tFeedbackLeveler_tick(&p->fbLevU, (p->levMode==0?p->decay:1)*tHighpass_tick(&p->DCblockerU, tOnePole_tick(&p->bridgeFilter, fromUF))); - tLinearDelay_tickIn(&p->delUB, fromBridge); + Lfloat fromBridge=-tFeedbackLeveler_tick(p->fbLevU, (p->levMode==0?p->decay:1)*tHighpass_tick(p->DCblockerU, tOnePole_tick(p->bridgeFilter, fromUF))); + tLinearDelay_tickIn(p->delUB, fromBridge); // into pick position, take input and add it into the waveguide, going to come out of middle segment - tLinearDelay_tickIn(&p->delMB, fromUB+input); + tLinearDelay_tickIn(p->delMB, fromUB+input); // into lower part of string, from prepPos, going backwards - Lfloat fromLowerPrep=-tOnePole_tick(&p->prepFilterL, fromLF); + Lfloat fromLowerPrep=-tOnePole_tick(p->prepFilterL, fromLF); Lfloat intoLower=p->prepIndex*fromLowerPrep+(1.0f - p->prepIndex)*fromMB; - tLinearDelay_tickIn(&p->delLB, intoLower); + tLinearDelay_tickIn(p->delLB, intoLower); // into lower part of string, from nut, going forwards toward prep position - Lfloat fromNut=-tFeedbackLeveler_tick(&p->fbLevL, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(&p->DCblockerL, tOnePole_tick(&p->nutFilter, fromLB))); - tLinearDelay_tickIn(&p->delLF, fromNut); + Lfloat fromNut=-tFeedbackLeveler_tick(p->fbLevL, (p->levMode==0?p->decay:1.0f)*tHighpass_tick(p->DCblockerL, tOnePole_tick(p->nutFilter, fromLB))); + tLinearDelay_tickIn(p->delLF, fromNut); // into middle part of string, from prep going toward pick position - Lfloat fromUpperPrep=-tOnePole_tick(&p->prepFilterU, fromMB); + Lfloat fromUpperPrep=-tOnePole_tick(p->prepFilterU, fromMB); Lfloat intoMiddle=p->prepIndex*fromUpperPrep+(1.0f - p->prepIndex)*fromLF; //pick position, going to come out of middle segment - tLinearDelay_tickIn(&p->delMF, intoMiddle); + tLinearDelay_tickIn(p->delMF, intoMiddle); //take output of middle segment and put it into upper segment connecting to the bridge, take input and add it into the waveguide, - tLinearDelay_tickIn(&p->delUF, fromMF + input); + tLinearDelay_tickIn(p->delUF, fromMF + input); // update all delay lengths Lfloat pickP=tExpSmooth_tick(p->pickPosSmooth); @@ -2470,14 +2470,14 @@ Lfloat tComplexLivingString_tick(tComplexLivingString* const p, Lfloat input) Lfloat upLen = (1.0f-pickP)*wLen; // the length from pick to bridge - tLinearDelay_setDelay(&p->delLF, lowLen); - tLinearDelay_setDelay(&p->delLB, lowLen); + tLinearDelay_setDelay(p->delLF, lowLen); + tLinearDelay_setDelay(p->delLB, lowLen); - tLinearDelay_setDelay(&p->delMF, midLen); - tLinearDelay_setDelay(&p->delMB, midLen); + tLinearDelay_setDelay(p->delMF, midLen); + tLinearDelay_setDelay(p->delMB, midLen); - tLinearDelay_setDelay(&p->delUF, upLen); - tLinearDelay_setDelay(&p->delUB, upLen); + tLinearDelay_setDelay(p->delUF, upLen); + tLinearDelay_setDelay(p->delUB, upLen); //update this to allow pickup position variation p->curr = fromBridge; @@ -2495,22 +2495,22 @@ void tComplexLivingString_setSampleRate(tComplexLivingString* const p, Lfloat p->sampleRate = sr; p->waveLengthInSamples = p->sampleRate/freq; tExpSmooth_setDest(p->wlSmooth, p->waveLengthInSamples); - tOnePole_setSampleRate(&p->bridgeFilter, p->sampleRate); - tOnePole_setSampleRate(&p->nutFilter, p->sampleRate); - tOnePole_setSampleRate(&p->prepFilterU, p->sampleRate); - tOnePole_setSampleRate(&p->prepFilterL, p->sampleRate); - tHighpass_setSampleRate(&p->DCblockerU, p->sampleRate); - tHighpass_setSampleRate(&p->DCblockerL, p->sampleRate); + tOnePole_setSampleRate(p->bridgeFilter, p->sampleRate); + tOnePole_setSampleRate(p->nutFilter, p->sampleRate); + tOnePole_setSampleRate(p->prepFilterU, p->sampleRate); + tOnePole_setSampleRate(p->prepFilterL, p->sampleRate); + tHighpass_setSampleRate(p->DCblockerU, p->sampleRate); + tHighpass_setSampleRate(p->DCblockerL, p->sampleRate); } -void tBowed_init (tBowed* const b, int oversampling, LEAF* const leaf) +void tBowed_init(tBowed** const b, int oversampling, LEAF* const leaf) { tBowed_initToPool(b, oversampling, &leaf->mempool); } -void tBowed_initToPool (tBowed** const bw, int oversampling, tMempool* const mp) +void tBowed_initToPool (tBowed** const bw, int oversampling, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tBowed* x = *bw = (tBowed*) mpool_alloc(sizeof(tBowed), m); x->mempool = m; LEAF* leaf = x->mempool->leaf; @@ -2525,20 +2525,20 @@ void tBowed_initToPool (tBowed** const bw, int oversampling, tMemp tLinearDelay_initToPool(&x->neckDelay, 100.0f, 2400.0f, mp); tLinearDelay_initToPool(&x->bridgeDelay, 29.0f, 2400.0f, mp); - tLinearDelay_clear(&x->neckDelay); - tLinearDelay_clear(&x->bridgeDelay); + tLinearDelay_clear(x->neckDelay); + tLinearDelay_clear(x->bridgeDelay); tCookOnePole_initToPool(&x->reflFilt, mp); - tCookOnePole_setSampleRate(&x->reflFilt, x->sampleRate); + tCookOnePole_setSampleRate(x->reflFilt, x->sampleRate); - tCookOnePole_setPole(&x->reflFilt, 0.6f - (0.1f * 22050.f / x->sampleRate)); - tCookOnePole_setGain(&x->reflFilt, .95f); + tCookOnePole_setPole(x->reflFilt, 0.6f - (0.1f * 22050.f / x->sampleRate)); + tCookOnePole_setGain(x->reflFilt, .95f); tBowTable_initToPool(&x->bowTabl, mp); x->bowTabl->slope = 3.0f; tBowed_setFreq(x, x->x_fr); tSVF_initToPool(&x->lowpass, SVFTypeLowpass, 18000.0f, 0.6f, mp); - tSVF_setSampleRate(&x->lowpass, x->sampleRate); - tSVF_setFreq(&x->lowpass,16000.0f); + tSVF_setSampleRate(x->lowpass, x->sampleRate); + tSVF_setFreq(x->lowpass,16000.0f); x->betaRatio = 0.127236; x->fr_save = x->x_fr; @@ -2569,19 +2569,19 @@ Lfloat tBowed_tick (tBowed* const x) if (bpos != x->betaRatio) { x->betaRatio = bpos; - tLinearDelay_setDelay(&x->bridgeDelay, x->baseDelay * x->betaRatio); /* bow to bridge length */ - tLinearDelay_setDelay(&x->neckDelay, x->baseDelay * (1. - x->betaRatio)); /* bow to nut (finger) length */ + tLinearDelay_setDelay(x->bridgeDelay, x->baseDelay * x->betaRatio); /* bow to bridge length */ + tLinearDelay_setDelay(x->neckDelay, x->baseDelay * (1. - x->betaRatio)); /* bow to nut (finger) length */ for (int i = 0; i < x->oversampling; i++) { - bridgeRefl = -tCookOnePole_tick(&x->reflFilt, x->bridgeDelay->lastOut); /* Bridge Reflection */ + bridgeRefl = -tCookOnePole_tick(x->reflFilt, x->bridgeDelay->lastOut); /* Bridge Reflection */ nutRefl = x->neckDelay->lastOut; /* Nut Reflection */ stringVel = bridgeRefl + nutRefl; /* Sum is String Velocity */ velDiff = bv - stringVel; /* Differential Velocity */ - newVel = velDiff * tBowTable_lookup(&x->bowTabl, velDiff); /* Non-Lin Bow Function */ - tLinearDelay_tick(&x->neckDelay, bridgeRefl + newVel); /* Do string */ - tLinearDelay_tick(&x->bridgeDelay, nutRefl + newVel); /* propagations */ - x->output = tSVF_tick(&x->lowpass, x->bridgeDelay->lastOut); + newVel = velDiff * tBowTable_lookup(x->bowTabl, velDiff); /* Non-Lin Bow Function */ + tLinearDelay_tick(x->neckDelay, bridgeRefl + newVel); /* Do string */ + tLinearDelay_tick(x->bridgeDelay, nutRefl + newVel); /* propagations */ + x->output = tSVF_tick(x->lowpass, x->bridgeDelay->lastOut); } return x->output; @@ -2593,19 +2593,19 @@ void tBowed_setFreq (tBowed* const x, Lfloat freq) if (freq < 20.f) freq = 20.f; x->baseDelay = (x->sampleRate / freq) - 4.0; /* delay - approx. filter delay */ - tLinearDelay_setDelay(&x->bridgeDelay, x->baseDelay * x->betaRatio); /* bow to bridge length */ - tLinearDelay_setDelay(&x->neckDelay, x->baseDelay * (1. - x->betaRatio)); /* bow to nut (finger) length */ + tLinearDelay_setDelay(x->bridgeDelay, x->baseDelay * x->betaRatio); /* bow to bridge length */ + tLinearDelay_setDelay(x->neckDelay, x->baseDelay * (1. - x->betaRatio)); /* bow to nut (finger) length */ } -void tTString_init (tTString* const b, int oversampling, Lfloat lowestFreq, LEAF* const leaf) +void tTString_init(tTString** const b, int oversampling, Lfloat lowestFreq, LEAF* const leaf) { tTString_initToPool(b, oversampling, lowestFreq, &leaf->mempool); } -void tTString_initToPool (tTString** const bw, int oversampling, Lfloat lowestFreq, tMempool* const mp) +void tTString_initToPool (tTString** const bw, int oversampling, Lfloat lowestFreq, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tTString* x = *bw = (tTString*) mpool_alloc(sizeof(tTString), m); x->mempool = m; LEAF* leaf = x->mempool->leaf; @@ -2638,21 +2638,21 @@ void tTString_initToPool (tTString** const bw, int oversampling, L x->barPulsePhasor = 0; Lfloat maxDelayTemp = x->sampleRate / lowestFreq; tLagrangeDelay_initToPool(&x->delay, 100.0f, maxDelayTemp, mp); - x->actualLowestFreq = x->sampleRate / tLagrangeDelay_getMaxDelay (&x->delay); //adjusted to create a power-of-two size buffer + x->actualLowestFreq = x->sampleRate / tLagrangeDelay_getMaxDelay (x->delay); //adjusted to create a power-of-two size buffer - tLagrangeDelay_clear(&x->delay); + tLagrangeDelay_clear(x->delay); tLagrangeDelay_initToPool(&x->delayP, 100.0f, maxDelayTemp, mp); - tLagrangeDelay_clear(&x->delayP); + tLagrangeDelay_clear(x->delayP); - x->maxDelay = tLagrangeDelay_getMaxDelay (&x->delay); + x->maxDelay = tLagrangeDelay_getMaxDelay (x->delay); tCookOnePole_initToPool(&x->reflFilt, mp); - tCookOnePole_setSampleRate(&x->reflFilt, x->sampleRate); + tCookOnePole_setSampleRate(x->reflFilt, x->sampleRate); tCookOnePole_initToPool(&x->reflFiltP, mp); - tCookOnePole_setSampleRate(&x->reflFiltP, x->sampleRate); + tCookOnePole_setSampleRate(x->reflFiltP, x->sampleRate); - tCookOnePole_setGainAndPole(&x->reflFilt,0.999f, -0.0014f); - tCookOnePole_setGainAndPole(&x->reflFiltP,0.999f, -0.0014f); + tCookOnePole_setGainAndPole(x->reflFilt,0.999f, -0.0014f); + tCookOnePole_setGainAndPole(x->reflFiltP,0.999f, -0.0014f); tTString_setFreq(x, 440.0f); @@ -2664,43 +2664,43 @@ void tTString_initToPool (tTString** const bw, int oversampling, L tExpSmooth_setDest(x->pickNoise, 0.0f); tThiranAllpassSOCascade_initToPool(&x->allpass, 4, mp); tThiranAllpassSOCascade_initToPool(&x->allpassP, 4, mp); - x->allpassDelay = tThiranAllpassSOCascade_setCoeff(&x->allpass, 0.0001f, 100.0f, x->invOversampling); - x->allpassDelayP = tThiranAllpassSOCascade_setCoeff(&x->allpassP, 0.000025f, 100.0f, x->invOversampling); + x->allpassDelay = tThiranAllpassSOCascade_setCoeff(x->allpass, 0.0001f, 100.0f, x->invOversampling); + x->allpassDelayP = tThiranAllpassSOCascade_setCoeff(x->allpassP, 0.000025f, 100.0f, x->invOversampling); tSVF_initToPool(&x->lowpassP, SVFTypeLowpass, 5000.0f, 0.8f, mp); - tSVF_setSampleRate(&x->lowpassP, x->sampleRate); - tSVF_setFreq(&x->lowpassP, 6000.0f); + tSVF_setSampleRate(x->lowpassP, x->sampleRate); + tSVF_setFreq(x->lowpassP, 6000.0f); tSVF_initToPool(&x->highpassP, SVFTypeHighpass, 1800.0f, 0.8f, mp); - tSVF_setSampleRate(&x->highpassP, x->sampleRate); - tSVF_setFreq(&x->highpassP, 1800.0f); + tSVF_setSampleRate(x->highpassP, x->sampleRate); + tSVF_setFreq(x->highpassP, 1800.0f); x->twoPiTimesInvSampleRate = TWO_PI * x->invSampleRate; tCycle_initToPool(&x->tensionModOsc, mp); - tCycle_setSampleRate(&x->tensionModOsc, x->sampleRate); + tCycle_setSampleRate(x->tensionModOsc, x->sampleRate); tCycle_initToPool(&x->pickupModOsc, mp); - tCycle_setSampleRate(&x->pickupModOsc, x->sampleRate); + tCycle_setSampleRate(x->pickupModOsc, x->sampleRate); x->pickupModOscFreq = 440.0f; x->pickupModOscAmp = 1.0f; tSVF_initToPool(&x->pickupFilter, SVFTypeLowpass, 2900.0f, 1.0f, mp); - tSVF_setSampleRate(&x->pickupFilter, x->sampleRate); + tSVF_setSampleRate(x->pickupFilter, x->sampleRate); - tSVF_setFreq(&x->pickupFilter, 3900.0f); + tSVF_setFreq(x->pickupFilter, 3900.0f); tSVF_initToPool(&x->pickupFilter2, SVFTypeLowpass, 3800.0f, 1.1f, mp); - tSVF_setSampleRate(&x->pickupFilter2, x->sampleRate); + tSVF_setSampleRate(x->pickupFilter2, x->sampleRate); - tSVF_setFreq(&x->pickupFilter2, 4100.0f); + tSVF_setFreq(x->pickupFilter2, 4100.0f); tSVF_initToPool(&x->peakFilt, SVFTypePeak, 1000.0f, .9f, mp); - tSVF_setSampleRate(&x->peakFilt, x->sampleRate); + tSVF_setSampleRate(x->peakFilt, x->sampleRate); - tSVF_setFreq(&x->peakFilt, 1000.0f); + tSVF_setFreq(x->peakFilt, 1000.0f); tNoise_initToPool(&x->noise, PinkNoise, mp); tHighpass_initToPool(&x->dcBlock, 1.0f, mp); - tHighpass_setSampleRate(&x->dcBlock,x->sampleRate); + tHighpass_setSampleRate(x->dcBlock,x->sampleRate); tHighpass_initToPool(&x->dcBlockP, 1.0f, mp); - tHighpass_setSampleRate(&x->dcBlockP,x->sampleRate); + tHighpass_setSampleRate(x->dcBlockP,x->sampleRate); tSlide_initToPool(&x->slide, 0, 3000, mp);//100 1400 if (x->wound) { @@ -2783,7 +2783,7 @@ void tTString_free (tTString** const bw) Lfloat tTString_tick (tTString* const x) { Lfloat theOutput = 0.0f; - x->feedbackNoise = tNoise_tick(&x->noise); + x->feedbackNoise = tNoise_tick(x->noise); Lfloat barPos = x->barPosition; if ((barPos > (x->prevBarPosSmoothed + 3.0f)) || (barPos < (x->prevBarPosSmoothed - 3.0f))) @@ -2820,14 +2820,14 @@ Lfloat tTString_tick (tTString* const x) x->prevBarPosSmoothed = barPosSmoothed; barDifference = LEAF_clip(0.0f, barDifference*2.0f, 1.0f); - x->slideAmount = tSlide_tick(&x->slide, barDifference); + x->slideAmount = tSlide_tick(x->slide, barDifference); if (x->wound) { if (bumpDifference > 1.0f) { tExpSmooth_setVal(x->barPulse, 1.0f); - tSlide_setDest(&x->barPulseSlide, 1.0f); + tSlide_setDest(x->barPulseSlide, 1.0f); x->lastBump = currentBump; x->timeSinceLastBump = x->sampleCount+1 / bumpDifference; @@ -2840,7 +2840,7 @@ Lfloat tTString_tick (tTString* const x) x->bumpOsc = 0; } - tSlide_setDest(&x->barSmooth, (x->sampleRate * x->invOversampling / x->timeSinceLastBump)); + tSlide_setDest(x->barSmooth, (x->sampleRate * x->invOversampling / x->timeSinceLastBump)); x->sampleCount = 0; } else @@ -2853,7 +2853,7 @@ Lfloat tTString_tick (tTString* const x) if (x->bumpCount > x->timeSinceLastBump) { tExpSmooth_setVal(x->barPulse, 1.0f); - tSlide_setDest(&x->barPulseSlide, 1.0f); + tSlide_setDest(x->barPulseSlide, 1.0f); x->bumpCount = 0; } x->bumpCount++; @@ -2866,28 +2866,28 @@ Lfloat tTString_tick (tTString* const x) } else { - tSlide_setDest(&x->barSmooth, 5.0f); + tSlide_setDest(x->barSmooth, 5.0f); } - Lfloat barFreq = tSlide_tickNoInput(&x->barSmooth); - tSVF_setFreq(&x->barResonator, barFreq); + Lfloat barFreq = tSlide_tickNoInput(x->barSmooth); + tSVF_setFreq(x->barResonator, barFreq); Lfloat filterAmount = 0.5f; Lfloat dryAmount = 1.0f; x->slideNoise = x->feedbackNoise; - Lfloat pulseVal = tSlide_tickNoInput(&x->barPulseSlide); + Lfloat pulseVal = tSlide_tickNoInput(x->barPulseSlide); if (pulseVal > .99f) { - tSlide_setDest(&x->barPulseSlide, 0.0f); + tSlide_setDest(x->barPulseSlide, 0.0f); } x->slideNoise *= pulseVal; - //x->slideNoise = tExpSmooth_tick(&x->barPulse); + //x->slideNoise = tExpSmooth_tick(x->barPulse); x->slideNoise *= tExpSmooth_tick(x->barPulse); //x->slideNoise *= x->slideGain; Lfloat tempSlideNoise1 = x->slideNoise; - Lfloat tempSlideNoise2 = fast_tanh5(tSVF_tick(&x->barResonator, tempSlideNoise1)*x->barDrive); + Lfloat tempSlideNoise2 = fast_tanh5(tSVF_tick(x->barResonator, tempSlideNoise1)*x->barDrive); Lfloat filterFade = 1.0f; if (barFreq < 300.0f) @@ -2899,17 +2899,17 @@ Lfloat tTString_tick (tTString* const x) x->slideNoise = ((tempSlideNoise1 * dryAmount) + (tempSlideNoise2 * filterAmount * filterFade));// * x->slideAmount; x->slideNoise *= x->muted; - x->slideNoise = tHighpass_tick(&x->barHP, x->slideNoise); - x->slideNoise = tSVF_tick(&x->barLP, x->slideNoise * x->slideGain * volCut); + x->slideNoise = tHighpass_tick(x->barHP, x->slideNoise); + x->slideNoise = tSVF_tick(x->barLP, x->slideNoise * x->slideGain * volCut); x->slideNoise = x->slideNoise * x->slideGain; } else { - //x->slideNoise = tNoise_tick(&x->pickNoiseSource)*0.3f; + //x->slideNoise = tNoise_tick(x->pickNoiseSource)*0.3f; x->slideNoise = x->feedbackNoise; x->slideNoise *= x->muted; - x->slideNoise = tHighpass_tick(&x->barHP, x->slideNoise); - x->slideNoise = tSVF_tick(&x->barLP, x->slideNoise * x->slideGain * 0.5f * volCut); + x->slideNoise = tHighpass_tick(x->barHP, x->slideNoise); + x->slideNoise = tSVF_tick(x->barLP, x->slideNoise * x->slideGain * 0.5f * volCut); x->slideNoise = x->slideNoise * x->slideGain; } for (int i = 0; i < x->oversampling; i++) @@ -2919,7 +2919,7 @@ Lfloat tTString_tick (tTString* const x) Lfloat tension = tExpSmooth_tick(x->tensionSmoother) * x->tensionGain * x->baseDelay; - //x->tensionAmount = (tension + (tCycle_tick(&x->tensionModOsc) * tension * 0.0f)) * 0.01f; + //x->tensionAmount = (tension + (tCycle_tick(x->tensionModOsc) * tension * 0.0f)) * 0.01f; x->tensionAmount = tension * 0.01f; Lfloat currentDelay = x->baseDelay; @@ -2933,21 +2933,21 @@ Lfloat tTString_tick (tTString* const x) { currentDelay = x->maxDelay; } - //tCycle_setFreq(&x->tensionModOsc, (x->sampleRate / (currentDelay - x->tensionAmount)) * 2.0f); + //tCycle_setFreq(x->tensionModOsc, (x->sampleRate / (currentDelay - x->tensionAmount)) * 2.0f); Lfloat halfCurrentDelay = currentDelay * 0.5f; - //tLagrangeDelay_setDelay(&x->delay, x->wavelength-2);//currentDelay - x->tensionAmount - (x->allpassDelay * x->inharmonicMult));// - ((x->phaseComp * INV_TWO_PI ) * currentDelay)); - //tLagrangeDelay_setDelay(&x->delayP,x->wavelength-2);// currentDelay - x->tensionAmount - (x->allpassDelayP * x->inharmonicMult));// - ((x->phaseComp * INV_TWO_PI ) * currentDelay)); - tLagrangeDelay_setDelay(&x->delay, currentDelay - x->tensionAmount - (x->allpassDelay * x->inharmonicMult) - ((x->phaseComp * INV_TWO_PI ) * currentDelay)); - tLagrangeDelay_setDelay(&x->delayP,currentDelay - x->tensionAmount - (x->allpassDelayP * x->inharmonicMult) - ((x->phaseComp * INV_TWO_PI ) * currentDelay)); + //tLagrangeDelay_setDelay(x->delay, x->wavelength-2);//currentDelay - x->tensionAmount - (x->allpassDelay * x->inharmonicMult));// - ((x->phaseComp * INV_TWO_PI ) * currentDelay)); + //tLagrangeDelay_setDelay(x->delayP,x->wavelength-2);// currentDelay - x->tensionAmount - (x->allpassDelayP * x->inharmonicMult));// - ((x->phaseComp * INV_TWO_PI ) * currentDelay)); + tLagrangeDelay_setDelay(x->delay, currentDelay - x->tensionAmount - (x->allpassDelay * x->inharmonicMult) - ((x->phaseComp * INV_TWO_PI ) * currentDelay)); + tLagrangeDelay_setDelay(x->delayP,currentDelay - x->tensionAmount - (x->allpassDelayP * x->inharmonicMult) - ((x->phaseComp * INV_TWO_PI ) * currentDelay)); - Lfloat pickNoiseSound = tNoise_tick(&x->pickNoiseSource) * tExpSmooth_tick(x->pickNoise); - tLagrangeDelay_addTo(&x->delay,pickNoiseSound * 2.0f, (uint32_t)x->pluckPoint_forInput); - tLagrangeDelay_addTo(&x->delayP,pickNoiseSound * 2.0f, (uint32_t)x->pluckPoint_forInput); + Lfloat pickNoiseSound = tNoise_tick(x->pickNoiseSource) * tExpSmooth_tick(x->pickNoise); + tLagrangeDelay_addTo(x->delay,pickNoiseSound * 2.0f, (uint32_t)x->pluckPoint_forInput); + tLagrangeDelay_addTo(x->delayP,pickNoiseSound * 2.0f, (uint32_t)x->pluckPoint_forInput); - Lfloat filterOut = tCookOnePole_tick(&x->reflFilt, x->output); - Lfloat filterOutP = tCookOnePole_tick(&x->reflFiltP, x->outputP); + Lfloat filterOut = tCookOnePole_tick(x->reflFilt, x->output); + Lfloat filterOutP = tCookOnePole_tick(x->reflFiltP, x->outputP); //Lfloat filterOut = x->output; //Lfloat filterOutP = x->outputP; @@ -2961,32 +2961,32 @@ Lfloat tTString_tick (tTString* const x) //Lfloat rippleLengthAlpha2 = rippleLength2 - rippleLengthInt2; - //Lfloat rippleOut = (tLagrangeDelay_tapOutInterpolated(&x->delay,rippleLengthInt,rippleLengthAlpha) * x->r); - //delayOut -= (tLagrangeDelay_tapOutInterpolated(&x->delay,rippleLengthInt2,rippleLengthAlpha2) * x->r); - Lfloat delayOut = tLagrangeDelay_tickOut(&x->delay); - Lfloat delayOutP = tLagrangeDelay_tickOut(&x->delayP); - Lfloat rippleOut1 = (tLagrangeDelay_tapOutInterpolated(&x->delay,rippleLengthInt,rippleLengthAlpha) * x->r); - Lfloat rippleOut1P = (tLagrangeDelay_tapOutInterpolated(&x->delayP,rippleLengthInt,rippleLengthAlpha) * x->r); + //Lfloat rippleOut = (tLagrangeDelay_tapOutInterpolated(x->delay,rippleLengthInt,rippleLengthAlpha) * x->r); + //delayOut -= (tLagrangeDelay_tapOutInterpolated(x->delay,rippleLengthInt2,rippleLengthAlpha2) * x->r); + Lfloat delayOut = tLagrangeDelay_tickOut(x->delay); + Lfloat delayOutP = tLagrangeDelay_tickOut(x->delayP); + Lfloat rippleOut1 = (tLagrangeDelay_tapOutInterpolated(x->delay,rippleLengthInt,rippleLengthAlpha) * x->r); + Lfloat rippleOut1P = (tLagrangeDelay_tapOutInterpolated(x->delayP,rippleLengthInt,rippleLengthAlpha) * x->r); - //Lfloat rippleSampleP = (tLagrangeDelay_tapOutInterpolated(&x->delayP,rippleLengthInt,rippleLengthAlpha) * x->r); + //Lfloat rippleSampleP = (tLagrangeDelay_tapOutInterpolated(x->delayP,rippleLengthInt,rippleLengthAlpha) * x->r); //delayOutP += rippleSampleP; - //Lfloat outputP = tLagrangeDelay_tickOut(&x->delayP); + //Lfloat outputP = tLagrangeDelay_tickOut(x->delayP); //filterOut = rippleOut1 + rippleOut2; Lfloat rippleOut = delayOut + rippleOut1; Lfloat rippleOutP = delayOutP + rippleOut1P; - // outputP += (tLagrangeDelay_tapOutInterpolated(&x->delayP,rippleLengthInt,rippleLengthAlpha) * x->r); + // outputP += (tLagrangeDelay_tapOutInterpolated(x->delayP,rippleLengthInt,rippleLengthAlpha) * x->r); - //output += (tLagrangeDelay_tapOutInterpolated(&x->delay,rippleLengthInt2,rippleLengthAlpha2) * x->r); - //output += (tLagrangeDelay_tapOutInterpolated(&x->delayP,rippleLengthInt2,rippleLengthAlpha2) * x->r); + //output += (tLagrangeDelay_tapOutInterpolated(x->delay,rippleLengthInt2,rippleLengthAlpha2) * x->r); + //output += (tLagrangeDelay_tapOutInterpolated(x->delayP,rippleLengthInt2,rippleLengthAlpha2) * x->r); Lfloat allpassOut = rippleOut; Lfloat allpassOutP = rippleOutP; if (x->inharmonic) { - allpassOut = tThiranAllpassSOCascade_tick(&x->allpass, rippleOut); - allpassOutP = tThiranAllpassSOCascade_tick(&x->allpassP, rippleOutP); + allpassOut = tThiranAllpassSOCascade_tick(x->allpass, rippleOut); + allpassOutP = tThiranAllpassSOCascade_tick(x->allpassP, rippleOutP); } @@ -2999,7 +2999,7 @@ Lfloat tTString_tick (tTString* const x) Lfloat positionMin = (x->openStringLength * 0.104166666666667f); Lfloat positionMax = (x->openStringLength * 0.021666666666667f); - Lfloat pickupInput = x->pickupPos + (tCycle_tick(&x->pickupModOsc) * x->pickupModOscAmp); + Lfloat pickupInput = x->pickupPos + (tCycle_tick(x->pickupModOsc) * x->pickupModOscAmp); //Lfloat pickupInput = x->pickupPos; Lfloat pickupPos = LEAF_mapFromZeroToOneInput(pickupInput, positionMin, positionMax); @@ -3034,34 +3034,34 @@ Lfloat tTString_tick (tTString* const x) Lfloat inversePickupPosAlpha = inversePickupPos - inversePickupPosInt; Lfloat oneMinusinversePickupPosAlpha = 1.0f - inversePickupPosAlpha; - Lfloat rightgoing = tLagrangeDelay_tapOut(&x->delay, pickupPosInt) * oneMinusPickupPosAlpha; - rightgoing += tLagrangeDelay_tapOut(&x->delay, pickupPosIntPlusOne) * pickupPosAlpha; - Lfloat leftgoing = tLagrangeDelay_tapOut(&x->delay, inversePickupPosInt) * oneMinusinversePickupPosAlpha; - leftgoing += tLagrangeDelay_tapOut(&x->delay, inversePickupPosIntPlusOne) * inversePickupPosAlpha; + Lfloat rightgoing = tLagrangeDelay_tapOut(x->delay, pickupPosInt) * oneMinusPickupPosAlpha; + rightgoing += tLagrangeDelay_tapOut(x->delay, pickupPosIntPlusOne) * pickupPosAlpha; + Lfloat leftgoing = tLagrangeDelay_tapOut(x->delay, inversePickupPosInt) * oneMinusinversePickupPosAlpha; + leftgoing += tLagrangeDelay_tapOut(x->delay, inversePickupPosIntPlusOne) * inversePickupPosAlpha; //x->pickupOut = (((volumes[1] * pickupNonLinearity(rightgoing)) + (volumes[0] * rightgoing)) - ((volumes[1] * pickupNonLinearity(leftgoing)) + (volumes[0] * leftgoing))); x->pickupOut = (pickupNonLinearity(rightgoing) - pickupNonLinearity(leftgoing)); - rightgoing = tLagrangeDelay_tapOut(&x->delayP, pickupPosInt) * oneMinusPickupPosAlpha; - rightgoing += tLagrangeDelay_tapOut(&x->delayP, pickupPosIntPlusOne) * pickupPosAlpha; - leftgoing = tLagrangeDelay_tapOut(&x->delayP, inversePickupPosInt) * oneMinusinversePickupPosAlpha; - leftgoing += tLagrangeDelay_tapOut(&x->delayP, inversePickupPosIntPlusOne) * inversePickupPosAlpha; + rightgoing = tLagrangeDelay_tapOut(x->delayP, pickupPosInt) * oneMinusPickupPosAlpha; + rightgoing += tLagrangeDelay_tapOut(x->delayP, pickupPosIntPlusOne) * pickupPosAlpha; + leftgoing = tLagrangeDelay_tapOut(x->delayP, inversePickupPosInt) * oneMinusinversePickupPosAlpha; + leftgoing += tLagrangeDelay_tapOut(x->delayP, inversePickupPosIntPlusOne) * inversePickupPosAlpha; x->pickupOutP = (pickupNonLinearity(rightgoing) - pickupNonLinearity(leftgoing)); - Lfloat inputSample = tFeedbackLeveler_tick(&x->feedback, tHighpass_tick(&x->dcBlock, filterOut + x->slideNoise + x->feedbackNoise * x->feedbackNoiseLevel)); - Lfloat inputSampleP = tFeedbackLeveler_tick(&x->feedbackP, tHighpass_tick(&x->dcBlockP, filterOutP + x->slideNoise + x->feedbackNoise * x->feedbackNoiseLevel)); - tLagrangeDelay_tickIn(&x->delay, inputSample); - tLagrangeDelay_tickIn(&x->delayP, inputSampleP); - //tLagrangeDelay_tickIn(&x->delayP, delayOutP + x->slideNoise); + Lfloat inputSample = tFeedbackLeveler_tick(x->feedback, tHighpass_tick(x->dcBlock, filterOut + x->slideNoise + x->feedbackNoise * x->feedbackNoiseLevel)); + Lfloat inputSampleP = tFeedbackLeveler_tick(x->feedbackP, tHighpass_tick(x->dcBlockP, filterOutP + x->slideNoise + x->feedbackNoise * x->feedbackNoiseLevel)); + tLagrangeDelay_tickIn(x->delay, inputSample); + tLagrangeDelay_tickIn(x->delayP, inputSampleP); + //tLagrangeDelay_tickIn(x->delayP, delayOutP + x->slideNoise); //Lfloat outputPfilt = 0.0f; - Lfloat outputPfilt = tSVF_tick(&x->lowpassP, x->pickupOutP); - outputPfilt = tSVF_tick(&x->highpassP, outputPfilt); + Lfloat outputPfilt = tSVF_tick(x->lowpassP, x->pickupOutP); + outputPfilt = tSVF_tick(x->highpassP, outputPfilt); Lfloat volumes[2]; LEAF_crossfade(x->pickupAmount * 2.0f - 1.0f,volumes); Lfloat prefilter = (x->pickupOut + (outputPfilt * x->phantomGain)) * 2.0f; - Lfloat prefilter2 = tSVF_tick(&x->pickupFilter2, prefilter);// + x->slideNoise; - Lfloat prefilter3 = tSVF_tick(&x->pickupFilter, prefilter2);// + x->slideNoise; - Lfloat prefilter4 = tSVF_tick(&x->peakFilt, prefilter3);// + x->slideNoise; + Lfloat prefilter2 = tSVF_tick(x->pickupFilter2, prefilter);// + x->slideNoise; + Lfloat prefilter3 = tSVF_tick(x->pickupFilter, prefilter2);// + x->slideNoise; + Lfloat prefilter4 = tSVF_tick(x->peakFilt, prefilter3);// + x->slideNoise; theOutput = (prefilter4 * 1.3f* volumes[1]) + (prefilter * 1.3f * volumes[0]); } @@ -3077,10 +3077,10 @@ void tTString_setFreq (tTString* const x, Lfloat freq) Lfloat Fc = (freq*x->invSampleRateTimesTwoPi); - //tExpSmooth_setDest(&x->pitchSmoother, (x->sampleRate / freq) - 1.0f); + //tExpSmooth_setDest(x->pitchSmoother, (x->sampleRate / freq) - 1.0f); tExpSmooth_setDest(x->pitchSmoother, (x->sampleRate / freq) - 2.0f); //why 2? is it the combo of the lowpass one pole and highpass one pole? - //tCycle_setFreq(&x->tensionModOsc, freq * x->invOversamplingTimesTwo); + //tCycle_setFreq(x->tensionModOsc, freq * x->invOversamplingTimesTwo); #ifdef ARM_MATH_CM7 Lfloat result = 0.0f; arm_atan2_f32(x->poleCoeff * arm_sin_f32(Fc) , 1.0f - (x->poleCoeff * arm_cos_f32(Fc)), &result); @@ -3142,7 +3142,7 @@ void tTString_setPickupModAmp (tTString* const x, Lfloat amp) void tTString_setPickupModFreq (tTString* const x, Lfloat freq) { x->pickupModOscFreq = freq; - tCycle_setFreq(&x->pickupModOsc, freq); + tCycle_setFreq(x->pickupModOsc, freq); } @@ -3177,8 +3177,8 @@ void tTString_setFilter (tTString* const x, Lfloat filter) //volatile Lfloat normalizedFreq = (overtone * x->freq) * x->twoPiTimesInvSampleRate; //filter = 1.0f - normalizedFreq; - tCookOnePole_setPole(&x->reflFilt,filter); - tCookOnePole_setPole(&x->reflFiltP,filter); + tCookOnePole_setPole(x->reflFilt,filter); + tCookOnePole_setPole(x->reflFiltP,filter); x->poleCoeff = filter; } @@ -3194,8 +3194,8 @@ void tTString_setFilterFreqDirectly (tTString* const x, Lfloat f //volatile Lfloat normalizedFreq = (overtone * x->freq) * x->twoPiTimesInvSampleRate; //filter = 1.0f - normalizedFreq; - tCookOnePole_setPole(&x->reflFilt,freq); - tCookOnePole_setPole(&x->reflFiltP,freq); + tCookOnePole_setPole(x->reflFilt,freq); + tCookOnePole_setPole(x->reflFiltP,freq); x->poleCoeff = freq; } @@ -3247,8 +3247,8 @@ void tTString_setRippleDepth (tTString* const x, Lfloat depth x->r = fastExp3(-1.0f / (x->freq * (x->decayInSeconds * 0.005f + 0.0001f))) * depth * 0.5f; x->invOnePlusr = 1.0f / (1.0f + x->r); Lfloat highpassFreq = depth * 30.0f + 1.0f; - tHighpass_setFreq(&x->dcBlock,highpassFreq); - tHighpass_setFreq(&x->dcBlockP,highpassFreq); + tHighpass_setFreq(x->dcBlock,highpassFreq); + tHighpass_setFreq(x->dcBlockP,highpassFreq); } void tTString_setHarmonic (tTString* const x, Lfloat harmonic) @@ -3259,24 +3259,24 @@ void tTString_setHarmonic (tTString* const x, Lfloat harmonic void tTString_setFeedbackStrength (tTString* const x, Lfloat strength) { Lfloat strengthVal = 0.5f * strength; - tFeedbackLeveler_setStrength(&x->feedback, strengthVal); - tFeedbackLeveler_setStrength(&x->feedbackP, strengthVal); + tFeedbackLeveler_setStrength(x->feedback, strengthVal); + tFeedbackLeveler_setStrength(x->feedbackP, strengthVal); x->feedbackNoiseLevel = strength * 0.005f; } void tTString_setFeedbackReactionSpeed (tTString* const x, Lfloat speed) { Lfloat speedVal = speed * 0.1f + 0.00001f; - tFeedbackLeveler_setFactor(&x->feedback, speedVal); - tFeedbackLeveler_setFactor(&x->feedbackP, speedVal); + tFeedbackLeveler_setFactor(x->feedback, speedVal); + tFeedbackLeveler_setFactor(x->feedbackP, speedVal); } void tTString_pluck (tTString* const x, Lfloat position, Lfloat amplitude) { x->muted = 1.0f; tExpSmooth_setVal(x->tensionSmoother, amplitude); - tFeedbackLeveler_setTargetLevel(&x->feedback, amplitude * 0.25f); - tFeedbackLeveler_setTargetLevel(&x->feedbackP, amplitude * 0.25f); + tFeedbackLeveler_setTargetLevel(x->feedback, amplitude * 0.25f); + tFeedbackLeveler_setTargetLevel(x->feedbackP, amplitude * 0.25f); tExpSmooth_setValAndDest(x->pitchSmoother, x->pitchSmoother->dest); x->baseDelay = x->pitchSmoother->dest; Lfloat currentDelay = x->baseDelay;// - x->allpassDelay; @@ -3292,7 +3292,7 @@ void tTString_pluck (tTString* const x, Lfloat position, Lfloat uint32_t pluckPointInt = (uint32_t) pluckPoint; Lfloat invPluckPointInt = (1.0f / ((Lfloat)pluckPointInt+.001f)); volatile Lfloat invRemainder = 1.0f / ((halfCurrentDelay-pluckPoint)+.001f); - tLagrangeDelay_clear(&x->delay); + tLagrangeDelay_clear(x->delay); x->pluckRatio = pluckPoint / halfCurrentDelay; x->pluckPoint_forInput = pluckPoint; for (uint32_t i = 0; i < halfCurrentDelay; i++) @@ -3312,14 +3312,14 @@ void tTString_pluck (tTString* const x, Lfloat position, Lfloat val = (1.0f - (((Lfloat)i-(Lfloat)pluckPointInt)*invRemainder)); } val = LEAF_tanh(val* 1.2f) * amplitude; - tLagrangeDelay_tapIn(&x->delay, val, i); - tLagrangeDelay_tapIn(&x->delay, -val, currentDelayInt-i); - tLagrangeDelay_tapIn(&x->delayP, val, i); - tLagrangeDelay_tapIn(&x->delayP, -val, currentDelayInt-i); + tLagrangeDelay_tapIn(x->delay, val, i); + tLagrangeDelay_tapIn(x->delay, -val, currentDelayInt-i); + tLagrangeDelay_tapIn(x->delayP, val, i); + tLagrangeDelay_tapIn(x->delayP, -val, currentDelayInt-i); } - tThiranAllpassSOCascade_clear(&x->allpass); - tThiranAllpassSOCascade_clear(&x->allpassP); + tThiranAllpassSOCascade_clear(x->allpass); + tThiranAllpassSOCascade_clear(x->allpassP); tExpSmooth_setVal(x->pickNoise, amplitude); } @@ -3328,15 +3328,15 @@ void tTString_pluck (tTString* const x, Lfloat position, Lfloat void tTString_setWavelength (tTString* const x, uint32_t waveLength) { - //tExpSmooth_setDest(&x->pitchSmoother,waveLength);; // in samples + //tExpSmooth_setDest(x->pitchSmoother,waveLength);; // in samples x->wavelength = waveLength; } void tTString_setHarmonicity (tTString* const x, Lfloat B, Lfloat freq) { - x->allpassDelay = tThiranAllpassSOCascade_setCoeff(&x->allpass, B, freq * x->invOversampling, x->oversampling); - x->allpassDelayP = tThiranAllpassSOCascade_setCoeff(&x->allpassP, B * 0.25f, freq * x->invOversampling, x->oversampling); + x->allpassDelay = tThiranAllpassSOCascade_setCoeff(x->allpass, B, freq * x->invOversampling, x->oversampling); + x->allpassDelayP = tThiranAllpassSOCascade_setCoeff(x->allpassP, B * 0.25f, freq * x->invOversampling, x->oversampling); } void tTString_setInharmonic (tTString* const x, uint32_t onOrOff) @@ -3369,36 +3369,36 @@ void tTString_setWindingsPerInch (tTString* const x, uint32_t winding void tTString_setPickupFilterFreq (tTString* const x, Lfloat cutoff) { - tSVF_setFreq(&x->pickupFilter,cutoff); + tSVF_setFreq(x->pickupFilter,cutoff); } void tTString_setPickupFilterQ (tTString* const x, Lfloat Q) { - tSVF_setQ(&x->pickupFilter,Q+0.5f); + tSVF_setQ(x->pickupFilter,Q+0.5f); } void tTString_setPeakFilterFreq (tTString* const x, Lfloat cutoff) { - tSVF_setFreq(&x->peakFilt,cutoff); + tSVF_setFreq(x->peakFilt,cutoff); } void tTString_setPeakFilterQ (tTString* const x, Lfloat Q) { - tSVF_setQ(&x->peakFilt,Q+0.5f); + tSVF_setQ(x->peakFilt,Q+0.5f); } ////BOW TABLE OBJECT -void tBowTable_init (tBowTable* const bt, LEAF* const leaf) +void tBowTable_init(tBowTable** const bt, LEAF* const leaf) { tBowTable_initToPool(bt, &leaf->mempool); } -void tBowTable_initToPool (tBowTable** const bt, tMempool* const mp) +void tBowTable_initToPool (tBowTable** const bt, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tBowTable* x = *bt = (tBowTable*) mpool_alloc(sizeof(tBowTable), m); x->mempool = m; @@ -3426,14 +3426,14 @@ Lfloat tBowTable_lookup (tBowTable* const x, Lfloat sample) ///Reed Table model //default values from STK are 0.6 offset and -0.8 slope -void tReedTable_init (tReedTable* const pm, Lfloat offset, Lfloat slope, LEAF* const leaf) +void tReedTable_init(tReedTable** const pm, Lfloat offset, Lfloat slope, LEAF* const leaf) { tReedTable_initToPool(pm, offset, slope, &leaf->mempool); } -void tReedTable_initToPool (tReedTable** const pm, Lfloat offset, Lfloat slope, tMempool* const mp) +void tReedTable_initToPool (tReedTable** const pm, Lfloat offset, Lfloat slope, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tReedTable* p = *pm = (tReedTable*) mpool_alloc(sizeof(tReedTable), m); p->mempool = m; @@ -3487,14 +3487,14 @@ void tReedTable_setSlope (tReedTable* const p, Lfloat slope) /* ============================ */ -void tStiffString_init (tStiffString* const pm, int numModes, LEAF* const leaf) +void tStiffString_init(tStiffString** const pm, int numModes, LEAF* const leaf) { tStiffString_initToPool(pm, numModes, &leaf->mempool); } -void tStiffString_initToPool (tStiffString** const pm, int numModes, tMempool* const mp) +void tStiffString_initToPool (tStiffString** const pm, int numModes, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tStiffString* p = *pm = (tStiffString*) mpool_alloc(sizeof(tStiffString), m); p->mempool = m; @@ -3522,9 +3522,9 @@ void tStiffString_initToPool (tStiffString** const pm, int numModes, tMempo tDampedOscillator_initToPool(&p->osc[i], &m); } */ - p->osc = (tCycle *) mpool_alloc(numModes * sizeof(tCycle), m); + p->oscs = (tCycle *) mpool_alloc(numModes * sizeof(tCycle), m); for (int i = 0; i < numModes; ++i) { - tCycle_initToPool(&p->osc[i], &m); + tCycle_initToPool(&p->oscs[i], &m); } // p->amplitudes = (Lfloat *) mpool_alloc(numModes * sizeof(Lfloat), m); @@ -3543,7 +3543,7 @@ void tStiffString_free (tStiffString** const pm) for (int i = 0; i < p->numModes; ++i) { //tDampedOscillator_free(&p->osc[i]); - tCycle_free(&p->osc[i]); + tCycle_free(&p->oscs[i]); // } mpool_free((char *) p->nyquistCoeff, p->mempool); @@ -3574,19 +3574,19 @@ void tStiffString_updateOscillators(tStiffString* const p) /* if ((p->freqHz * w) < (p->sampleRate * 0.4f)) { - tDampedOscillator_setFreq(&p->osc[i], p->freqHz * w * compensation); - tDampedOscillator_setDecay(&p->osc[i],p->freqHz * sig); + tDampedOscillator_setFreq(p->osc[i], p->freqHz * w * compensation); + tDampedOscillator_setDecay(p->osc[i],p->freqHz * sig); } else { - tDampedOscillator_setDecay(&p->osc[i],0.5f); + tDampedOscillator_setDecay(p->osc[i],0.5f); } */ Lfloat testFreq = (p->freqHz * w); Lfloat nyquistTest = (testFreq - p->nyquist) * p->nyquistScalingFactor; p->nyquistCoeff[i] = LEAF_clip(0.0f, nyquistTest, 1.0f); - tCycle_setFreq(&p->osc[i], testFreq * compensation); - //tDampedOscillator_setDecay(&p->osc[i],p->freqHz * sig); + tCycle_setFreq(p->oscs[i], testFreq * compensation); + //tDampedOscillator_setDecay(p->osc[i],p->freqHz * sig); Lfloat val = p->freqHz * sig; Lfloat r = fastExp4(-val * p->twoPiTimesInvSampleRate); p->decayScalar[i] = r * r; @@ -3619,8 +3619,8 @@ Lfloat tStiffString_tick (tStiffString* const p) { Lfloat sample = 0.0f; for (int i = 0; i < p->numModes; ++i) { - //sample += tDampedOscillator_tick(&p->osc[i]) * p->amplitudes[i] * p->outputWeights[i]; - sample += tCycle_tick(&p->osc[i]) * p->amplitudes[i] * p->outputWeights[i] * p->decayVal[i] * p->nyquistCoeff[i]; + //sample += tDampedOscillator_tick(p->osc[i]) * p->amplitudes[i] * p->outputWeights[i]; + sample += tCycle_tick(p->oscs[i]) * p->amplitudes[i] * p->outputWeights[i] * p->decayVal[i] * p->nyquistCoeff[i]; p->decayVal[i] *= p->decayScalar[i] * p->muteDecay; } return sample * p->amp * p->gainComp; @@ -3683,7 +3683,7 @@ void tStiffString_pluck(tStiffString* const p, Lfloat amp) #else p->amplitudes[i] = 2.0f * sinf(x0 * n) / denom; #endif - //tDampedOscillator_reset(&p->osc[i]); + //tDampedOscillator_reset(p->osc[i]); p->decayVal[i] = 1.0f; } p->amp = amp; @@ -3692,10 +3692,10 @@ void tStiffString_pluck(tStiffString* const p, Lfloat amp) void tStiffString_setSampleRate(tStiffString* const pm, Lfloat sr) { - tStiffString p = *pm; - p->sampleRate = sr; - p->twoPiTimesInvSampleRate = TWO_PI / sr; + + pm->sampleRate = sr; + pm->twoPiTimesInvSampleRate = TWO_PI / sr; } void tStiffString_setStiffnessNoUpdate(tStiffString* const p, Lfloat newValue) @@ -3747,22 +3747,22 @@ void tStiffString_pluckNoUpdate(tStiffString* const p, Lfloat amp) #else p->amplitudes[i] = 2.0f * sinf(x0 * n) / denom; #endif - //tDampedOscillator_reset(&p->osc[i]); + //tDampedOscillator_reset(p->osc[i]); p->decayVal[i] = 1.0f; } p->amp = amp; } -void tStereoRotation_init (tStereoRotation* const r, LEAF* const leaf) +void tStereoRotation_init(tStereoRotation** const r, LEAF* const leaf) { tStereoRotation_initToPool (r, &leaf->mempool); } -void tStereoRotation_initToPool (tStereoRotation** const rr, tMempool* const mp) +void tStereoRotation_initToPool (tStereoRotation** const rr, tMempool** const mp) { - _tMempool *m = *mp; + tMempool *m = *mp; tStereoRotation *r = *rr = (tStereoRotation *) mpool_alloc(sizeof(tStereoRotation), m); r->mempool = m; LEAF *leaf = r->mempool->leaf; @@ -3791,20 +3791,20 @@ void tStereoRotation_tick (tStereoRotation* const r, float float samplex = (samples[0] + r->vcaoutx); float sampley = (samples[1] + r->vcaouty); - samplex = tHighpass_tick(&r->hip1, samplex * r->rotGain); - sampley = tHighpass_tick(&r->hip2, sampley * r->rotGain); + samplex = tHighpass_tick(r->hip1, samplex * r->rotGain); + sampley = tHighpass_tick(r->hip2, sampley * r->rotGain); // float samplex = (input[0] + vcaoutx); // float sampley = (input[1] + vcaouty); float rotOutx = (samplex * cosf(r->angle)) - (sampley * sinf(r->angle)); float rotOuty = (samplex * sinf(r->angle)) + (sampley * cosf(r->angle)); - float delayoutx = tLagrangeDelay_tick(&r->rotDelayx, tanhf(rotOutx)); - float delayouty = tLagrangeDelay_tick(&r->rotDelayy,tanhf( rotOuty)); + float delayoutx = tLagrangeDelay_tick(r->rotDelayx, tanhf(rotOutx)); + float delayouty = tLagrangeDelay_tick(r->rotDelayy,tanhf( rotOuty)); - float filteroutx = tOnePole_tick(&r->filtx, delayoutx); - float filterouty = tOnePole_tick(&r->filty, delayouty); + float filteroutx = tOnePole_tick(r->filtx, delayoutx); + float filterouty = tOnePole_tick(r->filty, delayouty); r->vcaoutx = filteroutx * r->feedbackFactorx; r->vcaouty = filterouty * r->feedbackFactory; @@ -3820,26 +3820,26 @@ void tStereoRotation_tickIn (tStereoRotation* const r, floa float samplex = (samples[0] + r->vcaoutx); float sampley = (samples[1] + r->vcaouty); - samplex = tHighpass_tick(&r->hip1, samplex * r->rotGain); - sampley = tHighpass_tick(&r->hip2, sampley * r->rotGain); + samplex = tHighpass_tick(r->hip1, samplex * r->rotGain); + sampley = tHighpass_tick(r->hip2, sampley * r->rotGain); // float samplex = (input[0] + vcaoutx); // float sampley = (input[1] + vcaouty); float rotOutx = (samplex * cosf(r->angle)) - (sampley * sinf(r->angle)); float rotOuty = (samplex * sinf(r->angle)) + (sampley * cosf(r->angle)); - tLagrangeDelay_tickIn(&r->rotDelayx, tanhf(rotOutx)); - tLagrangeDelay_tickIn(&r->rotDelayy,tanhf( rotOuty)); + tLagrangeDelay_tickIn(r->rotDelayx, tanhf(rotOutx)); + tLagrangeDelay_tickIn(r->rotDelayy,tanhf( rotOuty)); return; } void tStereoRotation_tickOut (tStereoRotation* const r, float* samples) { - float delayoutx = tLagrangeDelay_tickOut(&r->rotDelayx); - float delayouty = tLagrangeDelay_tickOut(&r->rotDelayy); + float delayoutx = tLagrangeDelay_tickOut(r->rotDelayx); + float delayouty = tLagrangeDelay_tickOut(r->rotDelayy); - float filteroutx = tOnePole_tick(&r->filtx, delayoutx); - float filterouty = tOnePole_tick(&r->filty, delayouty); + float filteroutx = tOnePole_tick(r->filtx, delayoutx); + float filterouty = tOnePole_tick(r->filty, delayouty); r->vcaoutx = filteroutx * r->feedbackFactorx; r->vcaouty = filterouty * r->feedbackFactory; @@ -3856,12 +3856,12 @@ void tStereoRotation_setAngle (tStereoRotation* const r, f void tStereoRotation_setDelayX (tStereoRotation* const r, float time) { - tLagrangeDelay_setDelay(&r->rotDelayx, time); + tLagrangeDelay_setDelay(r->rotDelayx, time); } void tStereoRotation_setDelayY (tStereoRotation* const r, float time) { - tLagrangeDelay_setDelay(&r->rotDelayy, time); + tLagrangeDelay_setDelay(r->rotDelayy, time); } @@ -3876,12 +3876,12 @@ void tStereoRotation_setFeedbackY (tStereoRotation* const void tStereoRotation_setFilterX (tStereoRotation* const r, float freq) { - tOnePole_setFreq(&r->filtx, freq); + tOnePole_setFreq(r->filtx, freq); } void tStereoRotation_setFilterY (tStereoRotation* const r, float freq) { - tOnePole_setFreq(&r->filty, freq); + tOnePole_setFreq(r->filty, freq); } diff --git a/leaf/Src/leaf-reverb.c b/leaf/Src/leaf-reverb.c index 622b4eb..b14c399 100644 --- a/leaf/Src/leaf-reverb.c +++ b/leaf/Src/leaf-reverb.c @@ -19,14 +19,14 @@ #endif // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ PRCReverb ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ // -void tPRCReverb_init(tPRCReverb* const rev, Lfloat t60, LEAF* const leaf) +void tPRCReverb_init(tPRCReverb** const rev, Lfloat t60, LEAF* const leaf) { tPRCReverb_initToPool(rev, t60, &leaf->mempool); } -void tPRCReverb_initToPool (tPRCReverb** const rev, Lfloat t60, tMempool* const mp) +void tPRCReverb_initToPool (tPRCReverb** const rev, Lfloat t60, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tPRCReverb* r = *rev = (tPRCReverb*) mpool_alloc(sizeof(tPRCReverb), m); r->mempool = m; LEAF* leaf = r->mempool->leaf; @@ -76,9 +76,9 @@ void tPRCReverb_free (tPRCReverb** const rev) void tPRCRevert_clear(tPRCReverb* const r) { - tDelay_clear(&r->allpassDelays[0]); - tDelay_clear(&r->allpassDelays[1]); - tDelay_clear(&r->combDelay); + tDelay_clear(r->allpassDelays[0]); + tDelay_clear(r->allpassDelays[1]); + tDelay_clear(r->combDelay); } void tPRCReverb_setT60(tPRCReverb* const r, Lfloat t60) @@ -87,7 +87,7 @@ void tPRCReverb_setT60(tPRCReverb* const r, Lfloat t60) r->t60 = t60; - r->combCoeff = powf(10.0f, (-3.0f * tDelay_getDelay(&r->combDelay) * r->invSampleRate / t60 )); + r->combCoeff = powf(10.0f, (-3.0f * tDelay_getDelay(r->combDelay) * r->invSampleRate / t60 )); } void tPRCReverb_setMix(tPRCReverb* const r, Lfloat mix) @@ -102,21 +102,21 @@ Lfloat tPRCReverb_tick(tPRCReverb* const r, Lfloat input) r->lastIn = input; - temp = tDelay_getLastOut(&r->allpassDelays[0]); + temp = tDelay_getLastOut(r->allpassDelays[0]); temp0 = r->allpassCoeff * temp; temp0 += input; - tDelay_tick(&r->allpassDelays[0], temp0); + tDelay_tick(r->allpassDelays[0], temp0); temp0 = -(r->allpassCoeff * temp0) + temp; - temp = tDelay_getLastOut(&r->allpassDelays[1]); + temp = tDelay_getLastOut(r->allpassDelays[1]); temp1 = r->allpassCoeff * temp; temp1 += temp0; - tDelay_tick(&r->allpassDelays[1], temp1); + tDelay_tick(r->allpassDelays[1], temp1); temp1 = -(r->allpassCoeff * temp1) + temp; - temp2 = temp1 + ( r->combCoeff * tDelay_getLastOut(&r->combDelay)); + temp2 = temp1 + ( r->combCoeff * tDelay_getLastOut(r->combDelay)); - out = r->mix * tDelay_tick(&r->combDelay, temp2); + out = r->mix * tDelay_tick(r->combDelay, temp2); temp = (1.0f - r->mix) * input; @@ -158,18 +158,18 @@ void tPRCReverb_setSampleRate (tPRCReverb* const r, Lfloat sr) tDelay_initToPool(&r->allpassDelays[1], lengths[1], lengths[1] * 2, &r->mempool); tDelay_initToPool(&r->combDelay, lengths[2], lengths[2] * 2, &r->mempool); - r->combCoeff = powf(10.0f, (-3.0f * tDelay_getDelay(&r->combDelay) * r->invSampleRate / r->t60 )); + r->combCoeff = powf(10.0f, (-3.0f * tDelay_getDelay(r->combDelay) * r->invSampleRate / r->t60 )); } /* ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ NReverb ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -void tNReverb_init(tNReverb* const rev, Lfloat t60, LEAF* const leaf) +void tNReverb_init(tNReverb** const rev, Lfloat t60, LEAF* const leaf) { tNReverb_initToPool(rev, t60, &leaf->mempool); } -void tNReverb_initToPool (tNReverb** const rev, Lfloat t60, tMempool* const mp) +void tNReverb_initToPool (tNReverb** const rev, Lfloat t60, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tNReverb* r = *rev = (tNReverb*) mpool_alloc(sizeof(tNReverb), m); r->mempool = m; LEAF* leaf = r->mempool->leaf; @@ -197,14 +197,14 @@ void tNReverb_initToPool (tNReverb** const rev, Lfloat t60, tMempool* con for ( i=0; i<6; i++ ) { tLinearDelay_initToPool(&r->combDelays[i], lengths[i], lengths[i] * 2, mp); - tLinearDelay_clear(&r->combDelays[i]); + tLinearDelay_clear(r->combDelays[i]); r->combCoeffs[i] = powf(10.0f, (-3.0f * (Lfloat)lengths[i] * r->invSampleRate / t60)); } for ( i=0; i<8; i++ ) { tLinearDelay_initToPool(&r->allpassDelays[i], lengths[i+6], lengths[i+6] * 2, mp); - tLinearDelay_clear(&r->allpassDelays[i]); + tLinearDelay_clear(r->allpassDelays[i]); } tNReverb_setT60(r, t60); @@ -235,7 +235,7 @@ void tNReverb_setT60(tNReverb* const r, Lfloat t60) r->t60 = t60; - for (int i=0; i<6; i++) r->combCoeffs[i] = powf(10.0f, (-3.0f * tLinearDelay_getDelay(&r->combDelays[i]) * r->invSampleRate / t60 )); + for (int i=0; i<6; i++) r->combCoeffs[i] = powf(10.0f, (-3.0f * tLinearDelay_getDelay(r->combDelays[i]) * r->invSampleRate / t60 )); } void tNReverb_setMix(tNReverb* const r, Lfloat mix) @@ -247,12 +247,12 @@ void tNReverb_clear (tNReverb* const r) { for (int i = 0; i < 6; i++) { - tLinearDelay_clear(&r->combDelays[i]); + tLinearDelay_clear(r->combDelays[i]); } for (int i = 0; i < 8; i++) { - tLinearDelay_clear(&r->allpassDelays[i]); + tLinearDelay_clear(r->allpassDelays[i]); } } @@ -266,40 +266,40 @@ Lfloat tNReverb_tick(tNReverb* const r, Lfloat input) temp0 = 0.0; for ( i=0; i<6; i++ ) { - temp = input + (r->combCoeffs[i] * tLinearDelay_getLastOut(&r->combDelays[i])); - temp0 += tLinearDelay_tick(&r->combDelays[i],temp); + temp = input + (r->combCoeffs[i] * tLinearDelay_getLastOut(r->combDelays[i])); + temp0 += tLinearDelay_tick(r->combDelays[i],temp); } for ( i=0; i<3; i++ ) { - temp = tLinearDelay_getLastOut(&r->allpassDelays[i]); + temp = tLinearDelay_getLastOut(r->allpassDelays[i]); temp1 = r->allpassCoeff * temp; temp1 += temp0; - tLinearDelay_tick(&r->allpassDelays[i], temp1); + tLinearDelay_tick(r->allpassDelays[i], temp1); temp0 = -(r->allpassCoeff * temp1) + temp; } // One-pole lowpass filter. r->lowpassState = 0.7f * r->lowpassState + 0.3f * temp0; - temp = tLinearDelay_getLastOut(&r->allpassDelays[3]); + temp = tLinearDelay_getLastOut(r->allpassDelays[3]); temp1 = r->allpassCoeff * temp; temp1 += r->lowpassState; - tLinearDelay_tick(&r->allpassDelays[3], temp1 ); + tLinearDelay_tick(r->allpassDelays[3], temp1 ); temp1 = -(r->allpassCoeff * temp1) + temp; - temp = tLinearDelay_getLastOut(&r->allpassDelays[4]); + temp = tLinearDelay_getLastOut(r->allpassDelays[4]); temp2 = r->allpassCoeff * temp; temp2 += temp1; - tLinearDelay_tick(&r->allpassDelays[4], temp2 ); + tLinearDelay_tick(r->allpassDelays[4], temp2 ); out = -( r->allpassCoeff * temp2 ) + temp ; //the other channel in stereo version below /* - temp = tLinearDelay_getLastOut(&r->allpassDelays[5]); + temp = tLinearDelay_getLastOut(r->allpassDelays[5]); temp3 = r->allpassCoeff * temp; temp3 += temp1; - tLinearDelay_tick(&r->allpassDelays[5], temp3 ); + tLinearDelay_tick(r->allpassDelays[5], temp3 ); out = r->mix *( - ( r->allpassCoeff * temp3 ) + temp ); */ @@ -322,41 +322,41 @@ void tNReverb_tickStereo(tNReverb* const r, Lfloat input, Lfloat* output) temp0 = 0.0; for ( i=0; i<6; i++ ) { - temp = input + (r->combCoeffs[i] * tLinearDelay_getLastOut(&r->combDelays[i])); - temp0 += tLinearDelay_tick(&r->combDelays[i],temp); + temp = input + (r->combCoeffs[i] * tLinearDelay_getLastOut(r->combDelays[i])); + temp0 += tLinearDelay_tick(r->combDelays[i],temp); } for ( i=0; i<3; i++ ) { - temp = tLinearDelay_getLastOut(&r->allpassDelays[i]); + temp = tLinearDelay_getLastOut(r->allpassDelays[i]); temp1 = r->allpassCoeff * temp; temp1 += temp0; - tLinearDelay_tick(&r->allpassDelays[i], temp1); + tLinearDelay_tick(r->allpassDelays[i], temp1); temp0 = -(r->allpassCoeff * temp1) + temp; } // One-pole lowpass filter. r->lowpassState = 0.7f * r->lowpassState + 0.3f * temp0; - temp = tLinearDelay_getLastOut(&r->allpassDelays[3]); + temp = tLinearDelay_getLastOut(r->allpassDelays[3]); temp1 = r->allpassCoeff * temp; temp1 += r->lowpassState; - tLinearDelay_tick(&r->allpassDelays[3], temp1 ); + tLinearDelay_tick(r->allpassDelays[3], temp1 ); temp1 = -(r->allpassCoeff * temp1) + temp; Lfloat drymix = ( 1.0f - r->mix ) * input; - temp = tLinearDelay_getLastOut(&r->allpassDelays[4]); + temp = tLinearDelay_getLastOut(r->allpassDelays[4]); temp2 = r->allpassCoeff * temp; temp2 += temp1; - tLinearDelay_tick(&r->allpassDelays[4], temp2 ); + tLinearDelay_tick(r->allpassDelays[4], temp2 ); output[0] = -( r->allpassCoeff * temp2 ) + temp + drymix; out = output[0]; - temp = tLinearDelay_getLastOut(&r->allpassDelays[5]); + temp = tLinearDelay_getLastOut(r->allpassDelays[5]); temp3 = r->allpassCoeff * temp; temp3 += temp1; - tLinearDelay_tick(&r->allpassDelays[5], temp3 ); + tLinearDelay_tick(r->allpassDelays[5], temp3 ); output[1] = r->mix *( - ( r->allpassCoeff * temp3 ) + temp + drymix); r->lastOut = out; @@ -386,7 +386,7 @@ void tNReverb_setSampleRate (tNReverb* const r, Lfloat sr) { tLinearDelay_free(&r->combDelays[i]); tLinearDelay_initToPool(&r->combDelays[i], lengths[i], lengths[i] * 2, &r->mempool); - tLinearDelay_clear(&r->combDelays[i]); + tLinearDelay_clear(r->combDelays[i]); r->combCoeffs[i] = powf(10.0f, (-3.0f * (Lfloat)lengths[i] * r->invSampleRate / r->t60)); } @@ -394,7 +394,7 @@ void tNReverb_setSampleRate (tNReverb* const r, Lfloat sr) { tLinearDelay_free(&r->allpassDelays[i]); tLinearDelay_initToPool(&r->allpassDelays[i], lengths[i+6], lengths[i+6] * 2, &r->mempool); - tLinearDelay_clear(&r->allpassDelays[i]); + tLinearDelay_clear(r->allpassDelays[i]); } tNReverb_setT60(r, r->t60); @@ -407,14 +407,14 @@ void tNReverb_setSampleRate (tNReverb* const r, Lfloat sr) Lfloat in_allpass_delays[4] = { 4.771f, 3.595f, 12.73f, 9.307f }; Lfloat in_allpass_gains[4] = { 0.75f, 0.75f, 0.625f, 0.625f }; -void tDattorroReverb_init (tDattorroReverb* const rev, LEAF* const leaf) +void tDattorroReverb_init(tDattorroReverb** const rev, LEAF* const leaf) { tDattorroReverb_initToPool(rev, &leaf->mempool); } -void tDattorroReverb_initToPool (tDattorroReverb** const rev, tMempool* const mp) +void tDattorroReverb_initToPool (tDattorroReverb** const rev, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tDattorroReverb* r = *rev = (tDattorroReverb*) mpool_alloc(sizeof(tDattorroReverb), m); r->mempool = m; LEAF* leaf = r->mempool->leaf; @@ -432,12 +432,12 @@ void tDattorroReverb_initToPool (tDattorroReverb** const rev, tMempool for (int i = 0; i < 4; i++) { tAllpass_initToPool(&r->in_allpass[i], SAMP(in_allpass_delays[i]), SAMP(20.f), mp); // * r->size_max - tAllpass_setGain(&r->in_allpass[i], in_allpass_gains[i]); + tAllpass_setGain(r->in_allpass[i], in_allpass_gains[i]); } // FEEDBACK 1 tAllpass_initToPool(&r->f1_allpass, SAMP(30.51f), SAMP(100.f), mp); // * r->size_max - tAllpass_setGain(&r->f1_allpass, 0.7f); + tAllpass_setGain(r->f1_allpass, 0.7f); tTapeDelay_initToPool(&r->f1_delay_1, SAMP(141.69f), SAMP(200.0f) * r->size_max + 1, mp); tTapeDelay_initToPool(&r->f1_delay_2, SAMP(89.24f), SAMP(100.0f) * r->size_max + 1, mp); @@ -448,11 +448,11 @@ void tDattorroReverb_initToPool (tDattorroReverb** const rev, tMempool tHighpass_initToPool(&r->f1_hp, 20.f, mp); tCycle_initToPool(&r->f1_lfo, mp); - tCycle_setFreq(&r->f1_lfo, 0.1f); + tCycle_setFreq(r->f1_lfo, 0.1f); // FEEDBACK 2 tAllpass_initToPool(&r->f2_allpass, SAMP(22.58f), SAMP(100.f), mp); // * r->size_max - tAllpass_setGain(&r->f2_allpass, 0.7f); + tAllpass_setGain(r->f2_allpass, 0.7f); tTapeDelay_initToPool(&r->f2_delay_1, SAMP(149.62f), SAMP(200.f) * r->size_max + 1, mp); tTapeDelay_initToPool(&r->f2_delay_2, SAMP(60.48f), SAMP(100.f) * r->size_max + 1, mp); @@ -463,7 +463,7 @@ void tDattorroReverb_initToPool (tDattorroReverb** const rev, tMempool tHighpass_initToPool(&r->f2_hp, 20.f, mp); tCycle_initToPool(&r->f2_lfo, mp); - tCycle_setFreq(&r->f2_lfo, 0.07f); + tCycle_setFreq(r->f2_lfo, 0.07f); // PARAMETERS tDattorroReverb_setMix(*rev, 0.5f); @@ -517,13 +517,13 @@ void tDattorroReverb_free (tDattorroReverb** const rev) void tDattorroReverb_clear (tDattorroReverb* const r) { - tTapeDelay_clear(&r->in_delay); - tTapeDelay_clear(&r->f1_delay_1); - tTapeDelay_clear(&r->f1_delay_2); - tTapeDelay_clear(&r->f1_delay_3); - tTapeDelay_clear(&r->f2_delay_1); - tTapeDelay_clear(&r->f2_delay_2); - tTapeDelay_clear(&r->f2_delay_3); + tTapeDelay_clear(r->in_delay); + tTapeDelay_clear(r->f1_delay_1); + tTapeDelay_clear(r->f1_delay_2); + tTapeDelay_clear(r->f1_delay_3); + tTapeDelay_clear(r->f2_delay_1); + tTapeDelay_clear(r->f2_delay_2); + tTapeDelay_clear(r->f2_delay_3); } Lfloat tDattorroReverb_tick (tDattorroReverb* const r, Lfloat input) @@ -537,94 +537,94 @@ Lfloat tDattorroReverb_tick (tDattorroReverb* const r, Lfloat inp //r->f2_last = 0.0f; } // INPUT - in_sample = tTapeDelay_tick(&r->in_delay, input); + in_sample = tTapeDelay_tick(r->in_delay, input); - in_sample = tOnePole_tick(&r->in_filter, in_sample); + in_sample = tOnePole_tick(r->in_filter, in_sample); for (int i = 0; i < 4; i++) { - in_sample = tAllpass_tick(&r->in_allpass[i], in_sample); + in_sample = tAllpass_tick(r->in_allpass[i], in_sample); } // FEEDBACK 1 f1_sample = in_sample + r->f2_last; // + f2_last_out; - tAllpass_setDelay(&r->f1_allpass, SAMP(30.51f) + tCycle_tick(&r->f1_lfo) * SAMP(4.0f)); + tAllpass_setDelay(r->f1_allpass, SAMP(30.51f) + tCycle_tick(r->f1_lfo) * SAMP(4.0f)); - f1_sample = tAllpass_tick(&r->f1_allpass, f1_sample); + f1_sample = tAllpass_tick(r->f1_allpass, f1_sample); - f1_sample = tTapeDelay_tick(&r->f1_delay_1, f1_sample); + f1_sample = tTapeDelay_tick(r->f1_delay_1, f1_sample); - f1_sample = tOnePole_tick(&r->f1_filter, f1_sample); + f1_sample = tOnePole_tick(r->f1_filter, f1_sample); f1_sample = f1_sample + r->f1_delay_2_last * 0.5f; - f1_delay_2_sample = tTapeDelay_tick(&r->f1_delay_2, f1_sample * 0.5f); + f1_delay_2_sample = tTapeDelay_tick(r->f1_delay_2, f1_sample * 0.5f); r->f1_delay_2_last = f1_delay_2_sample; f1_sample = r->f1_delay_2_last + f1_sample; - f1_sample = tHighpass_tick(&r->f1_hp, f1_sample); + f1_sample = tHighpass_tick(r->f1_hp, f1_sample); f1_sample *= r->feedback_gain; - r->f1_last = tTapeDelay_tick(&r->f1_delay_3, f1_sample); + r->f1_last = tTapeDelay_tick(r->f1_delay_3, f1_sample); // FEEDBACK 2 f2_sample = in_sample + r->f1_last; - tAllpass_setDelay(&r->f2_allpass, SAMP(22.58f) + tCycle_tick(&r->f2_lfo) * SAMP(4.0f)); + tAllpass_setDelay(r->f2_allpass, SAMP(22.58f) + tCycle_tick(r->f2_lfo) * SAMP(4.0f)); - f2_sample = tAllpass_tick(&r->f2_allpass, f2_sample); + f2_sample = tAllpass_tick(r->f2_allpass, f2_sample); - f2_sample = tTapeDelay_tick(&r->f2_delay_1, f2_sample); + f2_sample = tTapeDelay_tick(r->f2_delay_1, f2_sample); - f2_sample = tOnePole_tick(&r->f2_filter, f2_sample); + f2_sample = tOnePole_tick(r->f2_filter, f2_sample); f2_sample = f2_sample + r->f2_delay_2_last * 0.5f; - f2_delay_2_sample = tTapeDelay_tick(&r->f2_delay_2, f2_sample * 0.5f); + f2_delay_2_sample = tTapeDelay_tick(r->f2_delay_2, f2_sample * 0.5f); r->f2_delay_2_last = f2_delay_2_sample; f2_sample = r->f2_delay_2_last + f2_sample; - f2_sample = tHighpass_tick(&r->f2_hp, f2_sample); + f2_sample = tHighpass_tick(r->f2_hp, f2_sample); f2_sample *= r->feedback_gain; - r->f2_last = tTapeDelay_tick(&r->f2_delay_3, f2_sample); + r->f2_last = tTapeDelay_tick(r->f2_delay_3, f2_sample); // TAP OUT 1 - f1_sample = tTapeDelay_tapOut(&r->f1_delay_1, SAMP(8.9f)) + - tTapeDelay_tapOut(&r->f1_delay_1, SAMP(99.8f)); + f1_sample = tTapeDelay_tapOut(r->f1_delay_1, SAMP(8.9f)) + + tTapeDelay_tapOut(r->f1_delay_1, SAMP(99.8f)); - f1_sample -= tTapeDelay_tapOut(&r->f1_delay_2, SAMP(64.2f)); + f1_sample -= tTapeDelay_tapOut(r->f1_delay_2, SAMP(64.2f)); - f1_sample += tTapeDelay_tapOut(&r->f1_delay_3, SAMP(67.f)); + f1_sample += tTapeDelay_tapOut(r->f1_delay_3, SAMP(67.f)); - f1_sample -= tTapeDelay_tapOut(&r->f2_delay_1, SAMP(66.8f)); + f1_sample -= tTapeDelay_tapOut(r->f2_delay_1, SAMP(66.8f)); - f1_sample -= tTapeDelay_tapOut(&r->f2_delay_2, SAMP(6.3f)); + f1_sample -= tTapeDelay_tapOut(r->f2_delay_2, SAMP(6.3f)); - f1_sample -= tTapeDelay_tapOut(&r->f2_delay_3, SAMP(35.8f)); + f1_sample -= tTapeDelay_tapOut(r->f2_delay_3, SAMP(35.8f)); f1_sample *= 0.14f; // TAP OUT 2 - f2_sample = tTapeDelay_tapOut(&r->f2_delay_1, SAMP(11.8f)) + - tTapeDelay_tapOut(&r->f2_delay_1, SAMP(121.7f)); + f2_sample = tTapeDelay_tapOut(r->f2_delay_1, SAMP(11.8f)) + + tTapeDelay_tapOut(r->f2_delay_1, SAMP(121.7f)); - f2_sample -= tTapeDelay_tapOut(&r->f2_delay_2, SAMP(6.3f)); + f2_sample -= tTapeDelay_tapOut(r->f2_delay_2, SAMP(6.3f)); - f2_sample += tTapeDelay_tapOut(&r->f2_delay_3, SAMP(89.7f)); + f2_sample += tTapeDelay_tapOut(r->f2_delay_3, SAMP(89.7f)); - f2_sample -= tTapeDelay_tapOut(&r->f1_delay_1, SAMP(70.8f)); + f2_sample -= tTapeDelay_tapOut(r->f1_delay_1, SAMP(70.8f)); - f2_sample -= tTapeDelay_tapOut(&r->f1_delay_2, SAMP(11.2f)); + f2_sample -= tTapeDelay_tapOut(r->f1_delay_2, SAMP(11.2f)); - f2_sample -= tTapeDelay_tapOut(&r->f1_delay_3, SAMP(4.1f)); + f2_sample -= tTapeDelay_tapOut(r->f1_delay_3, SAMP(4.1f)); f2_sample *= 0.14f; @@ -644,35 +644,35 @@ void tDattorroReverb_tickStereo (tDattorroReverb* const r, Lfloat //r->f2_last = 0.0f; } // INPUT - in_sample = tTapeDelay_tick(&r->in_delay, input); + in_sample = tTapeDelay_tick(r->in_delay, input); - in_sample = tOnePole_tick(&r->in_filter, in_sample); + in_sample = tOnePole_tick(r->in_filter, in_sample); for (int i = 0; i < 4; i++) { - in_sample = tAllpass_tick(&r->in_allpass[i], in_sample); + in_sample = tAllpass_tick(r->in_allpass[i], in_sample); } // FEEDBACK 1 f1_sample = in_sample + r->f2_last; // + f2_last_out; - tAllpass_setDelay(&r->f1_allpass, SAMP(30.51f) + tCycle_tick(&r->f1_lfo) * SAMP(4.0f)); + tAllpass_setDelay(r->f1_allpass, SAMP(30.51f) + tCycle_tick(r->f1_lfo) * SAMP(4.0f)); - f1_sample = tAllpass_tick(&r->f1_allpass, f1_sample); + f1_sample = tAllpass_tick(r->f1_allpass, f1_sample); - f1_sample = tTapeDelay_tick(&r->f1_delay_1, f1_sample); + f1_sample = tTapeDelay_tick(r->f1_delay_1, f1_sample); - f1_sample = tOnePole_tick(&r->f1_filter, f1_sample); + f1_sample = tOnePole_tick(r->f1_filter, f1_sample); f1_sample = f1_sample + r->f1_delay_2_last * 0.5f; - f1_delay_2_sample = tTapeDelay_tick(&r->f1_delay_2, f1_sample * 0.5f); + f1_delay_2_sample = tTapeDelay_tick(r->f1_delay_2, f1_sample * 0.5f); r->f1_delay_2_last = f1_delay_2_sample; f1_sample = r->f1_delay_2_last + f1_sample; - f1_sample = tHighpass_tick(&r->f1_hp, f1_sample); + f1_sample = tHighpass_tick(r->f1_hp, f1_sample); f1_sample *= r->feedback_gain; @@ -681,28 +681,28 @@ void tDattorroReverb_tickStereo (tDattorroReverb* const r, Lfloat f1_sample = 0.0f; } - r->f1_last = tTapeDelay_tick(&r->f1_delay_3, f1_sample); + r->f1_last = tTapeDelay_tick(r->f1_delay_3, f1_sample); // FEEDBACK 2 f2_sample = in_sample + r->f1_last; - tAllpass_setDelay(&r->f2_allpass, SAMP(22.58f) + tCycle_tick(&r->f2_lfo) * SAMP(4.0f)); + tAllpass_setDelay(r->f2_allpass, SAMP(22.58f) + tCycle_tick(r->f2_lfo) * SAMP(4.0f)); - f2_sample = tAllpass_tick(&r->f2_allpass, f2_sample); + f2_sample = tAllpass_tick(r->f2_allpass, f2_sample); - f2_sample = tTapeDelay_tick(&r->f2_delay_1, f2_sample); + f2_sample = tTapeDelay_tick(r->f2_delay_1, f2_sample); - f2_sample = tOnePole_tick(&r->f2_filter, f2_sample); + f2_sample = tOnePole_tick(r->f2_filter, f2_sample); f2_sample = f2_sample + r->f2_delay_2_last * 0.5f; - f2_delay_2_sample = tTapeDelay_tick(&r->f2_delay_2, f2_sample * 0.5f); + f2_delay_2_sample = tTapeDelay_tick(r->f2_delay_2, f2_sample * 0.5f); r->f2_delay_2_last = f2_delay_2_sample; f2_sample = r->f2_delay_2_last + f2_sample; - f2_sample = tHighpass_tick(&r->f2_hp, f2_sample); + f2_sample = tHighpass_tick(r->f2_hp, f2_sample); f2_sample *= r->feedback_gain; @@ -710,39 +710,39 @@ void tDattorroReverb_tickStereo (tDattorroReverb* const r, Lfloat { f2_sample = 0.0f; } - r->f2_last = tTapeDelay_tick(&r->f2_delay_3, f2_sample); + r->f2_last = tTapeDelay_tick(r->f2_delay_3, f2_sample); // TAP OUT 1 - f1_sample = tTapeDelay_tapOut(&r->f1_delay_1, SAMP(8.9f)) + - tTapeDelay_tapOut(&r->f1_delay_1, SAMP(99.8f)); + f1_sample = tTapeDelay_tapOut(r->f1_delay_1, SAMP(8.9f)) + + tTapeDelay_tapOut(r->f1_delay_1, SAMP(99.8f)); - f1_sample -= tTapeDelay_tapOut(&r->f1_delay_2, SAMP(64.2f)); + f1_sample -= tTapeDelay_tapOut(r->f1_delay_2, SAMP(64.2f)); - f1_sample += tTapeDelay_tapOut(&r->f1_delay_3, SAMP(67.f)); + f1_sample += tTapeDelay_tapOut(r->f1_delay_3, SAMP(67.f)); - f1_sample -= tTapeDelay_tapOut(&r->f2_delay_1, SAMP(66.8f)); + f1_sample -= tTapeDelay_tapOut(r->f2_delay_1, SAMP(66.8f)); - f1_sample -= tTapeDelay_tapOut(&r->f2_delay_2, SAMP(6.3f)); + f1_sample -= tTapeDelay_tapOut(r->f2_delay_2, SAMP(6.3f)); - f1_sample -= tTapeDelay_tapOut(&r->f2_delay_3, SAMP(35.8f)); + f1_sample -= tTapeDelay_tapOut(r->f2_delay_3, SAMP(35.8f)); f1_sample *= 0.14f; // TAP OUT 2 - f2_sample = tTapeDelay_tapOut(&r->f2_delay_1, SAMP(11.8f)) + - tTapeDelay_tapOut(&r->f2_delay_1, SAMP(121.7f)); + f2_sample = tTapeDelay_tapOut(r->f2_delay_1, SAMP(11.8f)) + + tTapeDelay_tapOut(r->f2_delay_1, SAMP(121.7f)); - f2_sample -= tTapeDelay_tapOut(&r->f2_delay_2, SAMP(6.3f)); + f2_sample -= tTapeDelay_tapOut(r->f2_delay_2, SAMP(6.3f)); - f2_sample += tTapeDelay_tapOut(&r->f2_delay_3, SAMP(89.7f)); + f2_sample += tTapeDelay_tapOut(r->f2_delay_3, SAMP(89.7f)); - f2_sample -= tTapeDelay_tapOut(&r->f1_delay_1, SAMP(70.8f)); + f2_sample -= tTapeDelay_tapOut(r->f1_delay_1, SAMP(70.8f)); - f2_sample -= tTapeDelay_tapOut(&r->f1_delay_2, SAMP(11.2f)); + f2_sample -= tTapeDelay_tapOut(r->f1_delay_2, SAMP(11.2f)); - f2_sample -= tTapeDelay_tapOut(&r->f1_delay_3, SAMP(4.1f)); + f2_sample -= tTapeDelay_tapOut(r->f1_delay_3, SAMP(4.1f)); f2_sample *= 0.14f; @@ -761,26 +761,26 @@ void tDattorroReverb_setFreeze (tDattorroReverb* const r, int free r->frozen = freeze; if (freeze) { - tAllpass_setGain(&r->f2_allpass, 1.0f); - tAllpass_setGain(&r->f1_allpass, 1.0f); + tAllpass_setGain(r->f2_allpass, 1.0f); + tAllpass_setGain(r->f1_allpass, 1.0f); for (int i = 0; i < 4; i++) { - //tAllpass_setGain(&r->in_allpass[i], 1.0f); + //tAllpass_setGain(r->in_allpass[i], 1.0f); } - tCycle_setFreq(&r->f1_lfo, 0.0f); - tCycle_setFreq(&r->f2_lfo, 0.0f); + tCycle_setFreq(r->f1_lfo, 0.0f); + tCycle_setFreq(r->f2_lfo, 0.0f); } else { - tAllpass_setGain(&r->f2_allpass, 0.7f); - tAllpass_setGain(&r->f1_allpass, 0.7f); + tAllpass_setGain(r->f2_allpass, 0.7f); + tAllpass_setGain(r->f1_allpass, 0.7f); for (int i = 0; i < 4; i++) { - //tAllpass_setGain(&r->in_allpass[i], in_allpass_gains[i]); + //tAllpass_setGain(r->in_allpass[i], in_allpass_gains[i]); } - tCycle_setFreq(&r->f1_lfo, 0.1f); - tCycle_setFreq(&r->f2_lfo, 0.07f); + tCycle_setFreq(r->f1_lfo, 0.1f); + tCycle_setFreq(r->f2_lfo, 0.07f); } } @@ -788,8 +788,8 @@ void tDattorroReverb_setFreeze (tDattorroReverb* const r, int free void tDattorroReverb_setHP (tDattorroReverb* const r, Lfloat freq) { Lfloat newFreq = LEAF_clip(20.0f, freq, 20000.0f); - tHighpass_setFreq(&r->f1_hp, newFreq); - tHighpass_setFreq(&r->f2_hp, newFreq); + tHighpass_setFreq(r->f1_hp, newFreq); + tHighpass_setFreq(r->f2_hp, newFreq); } @@ -801,48 +801,48 @@ void tDattorroReverb_setSize (tDattorroReverb* const r, Lfloat size /* for (int i = 0; i < 4; i++) { - tAllpass_setDelay(&r->in_allpass[i], SAMP(in_allpass_delays[i])); + tAllpass_setDelay(r->in_allpass[i], SAMP(in_allpass_delays[i])); } */ // FEEDBACK 1 - //tAllpass_setDelay(&r->f1_allpass, SAMP(30.51f)); + //tAllpass_setDelay(r->f1_allpass, SAMP(30.51f)); - tTapeDelay_setDelay(&r->f1_delay_1, SAMP(141.69f)); - tTapeDelay_setDelay(&r->f1_delay_2, SAMP(89.24f)); - tTapeDelay_setDelay(&r->f1_delay_3, SAMP(125.f)); + tTapeDelay_setDelay(r->f1_delay_1, SAMP(141.69f)); + tTapeDelay_setDelay(r->f1_delay_2, SAMP(89.24f)); + tTapeDelay_setDelay(r->f1_delay_3, SAMP(125.f)); // maybe change rate of SINE LFO's when size changes? - //tCycle_setFreq(&r->f2_lfo, 0.07f * size * r->size_max); + //tCycle_setFreq(r->f2_lfo, 0.07f * size * r->size_max); // FEEDBACK 2 - //tAllpass_setDelay(&r->f2_allpass, SAMP(22.58f)); + //tAllpass_setDelay(r->f2_allpass, SAMP(22.58f)); - tTapeDelay_setDelay(&r->f2_delay_1, SAMP(149.62f)); - tTapeDelay_setDelay(&r->f2_delay_2, SAMP(60.48f)); - tTapeDelay_setDelay(&r->f2_delay_3, SAMP(106.28f)); + tTapeDelay_setDelay(r->f2_delay_1, SAMP(149.62f)); + tTapeDelay_setDelay(r->f2_delay_2, SAMP(60.48f)); + tTapeDelay_setDelay(r->f2_delay_3, SAMP(106.28f)); } void tDattorroReverb_setInputDelay (tDattorroReverb* const r, Lfloat preDelay) { r->predelay = LEAF_clip(0.0f, preDelay, 200.0f); - tTapeDelay_setDelay(&r->in_delay, SAMP(r->predelay)); + tTapeDelay_setDelay(r->in_delay, SAMP(r->predelay)); } void tDattorroReverb_setInputFilter (tDattorroReverb* const r, Lfloat freq) { r->input_filter = LEAF_clip(0.0f, freq, 20000.0f); - tOnePole_setFreq(&r->in_filter, r->input_filter); + tOnePole_setFreq(r->in_filter, r->input_filter); } void tDattorroReverb_setFeedbackFilter (tDattorroReverb* const r, Lfloat freq) { r->feedback_filter = LEAF_clip(0.0f, freq, 20000.0f); - tOnePole_setFreq(&r->f1_filter, r->feedback_filter); - tOnePole_setFreq(&r->f2_filter, r->feedback_filter); + tOnePole_setFreq(r->f1_filter, r->feedback_filter); + tOnePole_setFreq(r->f2_filter, r->feedback_filter); } void tDattorroReverb_setFeedbackGain (tDattorroReverb* const r, Lfloat gain) @@ -852,7 +852,7 @@ void tDattorroReverb_setFeedbackGain (tDattorroReverb* const r, Lfloat gain void tDattorroReverb_setSampleRate (tDattorroReverb* const r, Lfloat sr) { - tMempool* mp = &r->mempool; + tMempool** mp = &r->mempool; r->sampleRate = sr; r->t = r->size * r->sampleRate * 0.001f; @@ -885,12 +885,12 @@ void tDattorroReverb_setSampleRate (tDattorroReverb* const r, Lfloat sr) for (int i = 0; i < 4; i++) { tAllpass_initToPool(&r->in_allpass[i], SAMP(in_allpass_delays[i]), SAMP(20.f), mp); // * r->size_max - tAllpass_setGain(&r->in_allpass[i], in_allpass_gains[i]); + tAllpass_setGain(r->in_allpass[i], in_allpass_gains[i]); } // FEEDBACK 1 tAllpass_initToPool(&r->f1_allpass, SAMP(30.51f), SAMP(100.f), mp); // * r->size_max - tAllpass_setGain(&r->f1_allpass, 0.7f); + tAllpass_setGain(r->f1_allpass, 0.7f); tTapeDelay_initToPool(&r->f1_delay_1, SAMP(141.69f), SAMP(200.0f) * r->size_max + 1, mp); tTapeDelay_initToPool(&r->f1_delay_2, SAMP(89.24f), SAMP(100.0f) * r->size_max + 1, mp); @@ -898,19 +898,19 @@ void tDattorroReverb_setSampleRate (tDattorroReverb* const r, Lfloat sr) // FEEDBACK 2 tAllpass_initToPool(&r->f2_allpass, SAMP(22.58f), SAMP(100.f), mp); // * r->size_max - tAllpass_setGain(&r->f2_allpass, 0.7f); + tAllpass_setGain(r->f2_allpass, 0.7f); tTapeDelay_initToPool(&r->f2_delay_1, SAMP(149.62f), SAMP(200.f) * r->size_max + 1, mp); tTapeDelay_initToPool(&r->f2_delay_2, SAMP(60.48f), SAMP(100.f) * r->size_max + 1, mp); tTapeDelay_initToPool(&r->f2_delay_3, SAMP(106.28f), SAMP(200.f) * r->size_max + 1, mp); - tOnePole_setSampleRate(&r->in_filter, r->sampleRate); - tOnePole_setSampleRate(&r->f1_filter, r->sampleRate); - tHighpass_setSampleRate(&r->f1_hp, r->sampleRate); - tCycle_setSampleRate(&r->f1_lfo, r->sampleRate); - tOnePole_setSampleRate(&r->f2_filter, r->sampleRate); - tHighpass_setSampleRate(&r->f2_hp, r->sampleRate); - tCycle_setSampleRate(&r->f2_lfo, r->sampleRate); + tOnePole_setSampleRate(r->in_filter, r->sampleRate); + tOnePole_setSampleRate(r->f1_filter, r->sampleRate); + tHighpass_setSampleRate(r->f1_hp, r->sampleRate); + tCycle_setSampleRate(r->f1_lfo, r->sampleRate); + tOnePole_setSampleRate(r->f2_filter, r->sampleRate); + tHighpass_setSampleRate(r->f2_hp, r->sampleRate); + tCycle_setSampleRate(r->f2_lfo, r->sampleRate); // PARAMETERS tDattorroReverb_setSize(r, r->size*0.5f); diff --git a/leaf/Src/leaf-sampling.c b/leaf/Src/leaf-sampling.c index 21009f4..98443cb 100644 --- a/leaf/Src/leaf-sampling.c +++ b/leaf/Src/leaf-sampling.c @@ -24,14 +24,14 @@ //============================================================================== -void tBuffer_init (tBuffer* const sb, uint32_t length, LEAF* const leaf) +void tBuffer_init(tBuffer** const sb, uint32_t length, LEAF* const leaf) { tBuffer_initToPool(sb, length, &leaf->mempool); } -void tBuffer_initToPool (tBuffer** const sb, uint32_t length, tMempool* const mp) +void tBuffer_initToPool (tBuffer** const sb, uint32_t length, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tBuffer* s = *sb = (tBuffer*) mpool_alloc(sizeof(tBuffer), m); s->mempool = m; LEAF* leaf = s->mempool->leaf; @@ -159,17 +159,17 @@ int tBuffer_isActive(tBuffer* const s) //================================tSampler===================================== -static void handleStartEndChange(tSampler const sp); -static void attemptStartEndChange(tSampler const sp); +static void handleStartEndChange(tSampler* const sp); +static void attemptStartEndChange(tSampler* const sp); -void tSampler_init(tSampler* const sp, tBuffer* const b, LEAF* const leaf) +void tSampler_init(tSampler** const sp, tBuffer** const b, LEAF* const leaf) { tSampler_initToPool(sp, b, &leaf->mempool, leaf); } -void tSampler_initToPool(tSampler** const sp, tBuffer** const b, tMempool* const mp, LEAF* const leaf) +void tSampler_initToPool(tSampler** const sp, tBuffer** const b, tMempool** const mp, LEAF* const leaf) { - _tMempool* m = *mp; + tMempool* m = *mp; tSampler* p = *sp = (tSampler*) mpool_alloc(sizeof(tSampler), m); p->mempool = m; @@ -181,7 +181,7 @@ void tSampler_initToPool(tSampler** const sp, tBuffer** const b, tMempool* const p->rateFactor = s->sampleRate * p->invSampleRate; p->channels = s->channels; - p->samp = *s; + p->samp = s; p->active = 0; @@ -214,7 +214,7 @@ void tSampler_initToPool(tSampler** const sp, tBuffer** const b, tMempool* const p->cfxlen = 500; // default 300 sample crossfade tRamp_initToPool(&p->gain, 5.0f, 1, mp); - tRamp_setVal(&p->gain, 0.f); + tRamp_setVal(p->gain, 0.f); p->targetstart = -1; p->targetend = -1; @@ -232,7 +232,7 @@ void tSampler_free (tSampler** const sp) mpool_free((char*)p, p->mempool); } -void tSampler_setSample (tSampler* const p, tBuffer const s) +void tSampler_setSample (tSampler* const p, tBuffer* const s) { p->samp = s; @@ -249,7 +249,7 @@ void tSampler_setSample (tSampler* const p, tBuffer const s) Lfloat tSampler_tick (tSampler* const p) { - attemptStartEndChange(*p); + attemptStartEndChange(p); if (p->active == 0) return 0.f; @@ -416,7 +416,7 @@ Lfloat tSampler_tick (tSampler* const p) } - attemptStartEndChange(*p); + attemptStartEndChange(p); if (p->mode == PlayLoop) @@ -459,24 +459,24 @@ Lfloat tSampler_tick (tSampler* const p) Lfloat ticksToEnd = rev ? ((idx - myStart) * p->iinc) : ((myEnd - idx) * p->iinc); if ((ticksToEnd < p->ticksPerSevenMs) && (p->active == 1)) { - tRamp_setDest(&p->gain, 0.f); + tRamp_setDest(p->gain, 0.f); p->active = -1; } } sample = ((sample * (1.0f - crossfadeMix)) + (cfxsample * crossfadeMix)) * (1.0f - flipMix) + (flipsample * flipMix); - sample = sample * tRamp_tick(&p->gain); + sample = sample * tRamp_tick(p->gain); if (p->active < 0) { - if (tRamp_sample(&p->gain) <= 0.00001f) + if (tRamp_sample(p->gain) <= 0.00001f) { if (p->retrigger == 1) { p->active = 1; p->retrigger = 0; - tRamp_setDest(&p->gain, 1.f); + tRamp_setDest(p->gain, 1.f); if (p->dir > 0) { @@ -505,7 +505,7 @@ Lfloat tSampler_tick (tSampler* const p) Lfloat tSampler_tickStereo (tSampler* const p, Lfloat* outputArray) { - attemptStartEndChange(*p); + attemptStartEndChange(p); if (p->active == 0) return 0.f; @@ -690,7 +690,7 @@ Lfloat tSampler_tickStereo (tSampler* const p, Lfloat* outputArray) } } - attemptStartEndChange(*p); + attemptStartEndChange(p); if (p->mode == PlayLoop) { @@ -732,12 +732,12 @@ Lfloat tSampler_tickStereo (tSampler* const p, Lfloat* outputArray) Lfloat ticksToEnd = rev ? ((idx - myStart) * p->iinc) : ((myEnd - idx) * p->iinc); if ((ticksToEnd < p->ticksPerSevenMs) && (p->active == 1)) { - tRamp_setDest(&p->gain, 0.f); + tRamp_setDest(p->gain, 0.f); p->active = -1; } } - Lfloat sampleGain = tRamp_tick(&p->gain); + Lfloat sampleGain = tRamp_tick(p->gain); for (int i = 0; i < p->channels; i++) { outputArray[i] = ((outputArray[i] * (1.0f - crossfadeMix)) + (cfxsample[i] * crossfadeMix)) * (1.0f - flipMix) + (flipsample[i] * flipMix); @@ -747,13 +747,13 @@ Lfloat tSampler_tickStereo (tSampler* const p, Lfloat* outputArray) if (p->active < 0) { //if was fading out and reached silence - if (tRamp_sample(&p->gain) <= 0.0001f) + if (tRamp_sample(p->gain) <= 0.0001f) { if (p->retrigger == 1) { p->active = 1; p->retrigger = 0; - tRamp_setDest(&p->gain, 1.f); + tRamp_setDest(p->gain, 1.f); if (p->dir > 0) { @@ -765,7 +765,7 @@ Lfloat tSampler_tickStereo (tSampler* const p, Lfloat* outputArray) if (p->flip > 0) p->idx = p->end; else p->idx = p->start; } - handleStartEndChange(*p); + handleStartEndChange(p); } else { @@ -800,7 +800,7 @@ void tSampler_play (tSampler* const p) p->active = -1; p->retrigger = 1; - tRamp_setDest(&p->gain, 0.f); + tRamp_setDest(p->gain, 0.f); } else if (p->active < 0) @@ -808,7 +808,7 @@ void tSampler_play (tSampler* const p) p->active = -1; p->retrigger = 1; - //tRamp_setDest(&p->gain, 0.f); + //tRamp_setDest(p->gain, 0.f); } else @@ -816,7 +816,7 @@ void tSampler_play (tSampler* const p) p->active = 1; p->retrigger = 0; - tRamp_setDest(&p->gain, 1.f); + tRamp_setDest(p->gain, 1.f); if (p->dir > 0) { @@ -828,7 +828,7 @@ void tSampler_play (tSampler* const p) if (p->flip > 0) p->idx = p->end; else p->idx = p->start; } - handleStartEndChange(*p); + handleStartEndChange(p); } } @@ -836,7 +836,7 @@ void tSampler_stop (tSampler* const p) { p->active = -1; - tRamp_setDest(&p->gain, 0.f); + tRamp_setDest(p->gain, 0.f); } static void handleStartEndChange(tSampler* const p) @@ -1098,30 +1098,30 @@ void tSampler_setRate (tSampler* const p, Lfloat rate) void tSampler_setSampleRate(tSampler* const p, Lfloat sr) { - tBuffer* s = &p->samp; + tBuffer* s = p->samp; p->sampleRate = sr; p->invSampleRate = 1.0f/p->sampleRate; p->ticksPerSevenMs = 0.007f * p->sampleRate; p->rateFactor = s->sampleRate * p->invSampleRate; - tRamp_setSampleRate(&p->gain, p->sampleRate); + tRamp_setSampleRate(p->gain, p->sampleRate); } //============================================================================== -void tAutoSampler_init (tAutoSampler* const as, tBuffer* const b, LEAF* const leaf) +void tAutoSampler_init(tAutoSampler** const as, tBuffer** const b, LEAF* const leaf) { tAutoSampler_initToPool(as, b, &leaf->mempool, leaf); } -void tAutoSampler_initToPool (tAutoSampler** const as, tBuffer* const b, tMempool* const mp, LEAF* const leaf) +void tAutoSampler_initToPool (tAutoSampler** const as, tBuffer** const b, tMempool** const mp, LEAF* const leaf) { - _tMempool* m = *mp; + tMempool* m = *mp; tAutoSampler* a = *as = (tAutoSampler*) mpool_alloc(sizeof(tAutoSampler), m); a->mempool = m; - tBuffer_setRecordMode(&*b, RecordOneShot); + tBuffer_setRecordMode(*b, RecordOneShot); tSampler_initToPool(&a->sampler, b, mp, leaf); - tSampler_setMode(&a->sampler, PlayLoop); + tSampler_setMode(a->sampler, PlayLoop); tEnvelopeFollower_initToPool(&a->ef, 0.05f, 0.9999f, mp); } @@ -1137,7 +1137,7 @@ void tAutoSampler_free (tAutoSampler** const as) Lfloat tAutoSampler_tick (tAutoSampler* const a, Lfloat input) { - Lfloat currentPower = tEnvelopeFollower_tick(&a->ef, input); + Lfloat currentPower = tEnvelopeFollower_tick(a->ef, input); if ((currentPower > (a->threshold)) && (currentPower > a->previousPower + 0.001f) && @@ -1157,7 +1157,7 @@ Lfloat tAutoSampler_tick (tAutoSampler* const a, Lfloat input) } - tSampler_setEnd(&a->sampler, a->windowSize); + tSampler_setEnd(a->sampler, a->windowSize); tBuffer_tick(a->sampler->samp, input); //on its way down if (currentPower <= a->previousPower) @@ -1174,29 +1174,29 @@ Lfloat tAutoSampler_tick (tAutoSampler* const a, Lfloat input) a->previousPower = currentPower; - return tSampler_tick(&a->sampler); + return tSampler_tick(a->sampler); } -void tAutoSampler_setBuffer (tAutoSampler* const a, tBuffer const b) +void tAutoSampler_setBuffer (tAutoSampler* const a, tBuffer* const b) { - tBuffer_setRecordMode(&b, RecordOneShot); - if (a->windowSize > tBuffer_getBufferLength(&b)) - a->windowSize = tBuffer_getBufferLength(&b); - tSampler_setSample(&a->sampler, b); + tBuffer_setRecordMode(b, RecordOneShot); + if (a->windowSize > tBuffer_getBufferLength(b)) + a->windowSize = tBuffer_getBufferLength(b); + tSampler_setSample(a->sampler, b); } void tAutoSampler_setMode (tAutoSampler* const a, PlayMode mode) { - tSampler_setMode(&a->sampler, mode); + tSampler_setMode(a->sampler, mode); } void tAutoSampler_play (tAutoSampler* const a) { - tSampler_play(&a->sampler); + tSampler_play(a->sampler); } void tAutoSampler_stop (tAutoSampler* const a) { - tSampler_stop(&a->sampler); + tSampler_stop(a->sampler); } void tAutoSampler_setThreshold (tAutoSampler* const a, Lfloat thresh) @@ -1213,7 +1213,7 @@ void tAutoSampler_setWindowSize (tAutoSampler* const a, uint32_t size) void tAutoSampler_setCrossfadeLength (tAutoSampler* const a, uint32_t length) { - tSampler_setCrossfadeLength(&a->sampler, length); + tSampler_setCrossfadeLength(a->sampler, length); } void tAutoSampler_setRate (tAutoSampler* const a, Lfloat rate) @@ -1223,18 +1223,18 @@ void tAutoSampler_setRate (tAutoSampler* const a, Lfloat rate) void tAutoSampler_setSampleRate (tAutoSampler* const a, Lfloat sr) { - tSampler_setSampleRate(&a->sampler, sr); + tSampler_setSampleRate(a->sampler, sr); } -void tMBSampler_init(tMBSampler* const sp, tBuffer* const b, LEAF* const leaf) +void tMBSampler_init(tMBSampler** const sp, tBuffer** const b, LEAF* const leaf) { tMBSampler_initToPool(sp, b, &leaf->mempool); } -void tMBSampler_initToPool(tMBSampler** const sp, tBuffer* const b, tMempool* const mp) +void tMBSampler_initToPool(tMBSampler** const sp, tBuffer** const b, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; tMBSampler* c = *sp = (tMBSampler*) mpool_alloc(sizeof(tMBSampler), m); c->mempool = m; @@ -1271,7 +1271,7 @@ void tMBSampler_free (tMBSampler** const sp) void tMBSampler_setSample (tMBSampler* const p, tBuffer* const b) { - p->samp = *b;; + p->samp = b; p->start = 0; tMBSampler_setEnd(p, p->samp->bufferLength); diff --git a/leaf/Src/leaf-tables.c b/leaf/Src/leaf-tables.c index 5185113..0bd1063 100644 --- a/leaf/Src/leaf-tables.c +++ b/leaf/Src/leaf-tables.c @@ -14,15 +14,15 @@ #include "stdlib.h" -void tLookupTable_init(tLookupTable* const tLookupTable, float start, float end, float center, int size, LEAF* const leaf) +void tLookupTable_init(tLookupTable** const tLookupTable, float start, float end, float center, int size, LEAF* const leaf) { tLookupTable_initToPool(tLookupTable, start, end, center, size, &leaf->mempool); } -void tLookupTable_initToPool(tLookupTable* const tLookupTable, float start, float end, float center, int size, tMempool* const mempool) +void tLookupTable_initToPool(tLookupTable** const table, float start, float end, float center, int size, tMempool** const mempool) { - _tMempool* m = *mempool; - _tLookupTable* t = *tLookupTable = (_tLookupTable*) mpool_alloc(sizeof(_tLookupTable), m); + tMempool* m = *mempool; + tLookupTable* t = *table = (tLookupTable*) mpool_alloc(sizeof(tLookupTable), m); t->table = (float*) mpool_alloc(sizeof(float) * size, m); t->tableSize = size; t->mempool = m; diff --git a/leaf/Src/leaf-vocal.c b/leaf/Src/leaf-vocal.c index 0ec9d46..f9420ac 100644 --- a/leaf/Src/leaf-vocal.c +++ b/leaf/Src/leaf-vocal.c @@ -126,15 +126,15 @@ void glottis_setup_waveform(glottis* const glot) glot->Te = Te; glot->omega = omega; } -void glottis_init(glottis* const glo, LEAF* const leaf) +void glottis_init(glottis** const glo, LEAF* const leaf) { glottis_initToPool(glo, &leaf->mempool); } -void glottis_initToPool(glottis** const glo, tMempool* const mp) +void glottis_initToPool(glottis** const glo, tMempool** const mp) { - _tMempool* m = *mp; + tMempool* m = *mp; glottis* glot = *glo = (glottis*) mpool_calloc(sizeof(glottis), m); glot->mempool = m; LEAF* leaf = glot->mempool->leaf; @@ -202,15 +202,15 @@ Lfloat glottis_compute(glottis* const glot) return out; } -void tract_init(tract* const t, int numTractSections, int maxNumTractSections, LEAF* const leaf) +void tract_init(tract** const t, int numTractSections, int maxNumTractSections, LEAF* const leaf) { tract_initToPool(t, numTractSections, maxNumTractSections, &leaf->mempool); } -void tract_initToPool(tract* const t, int numTractSections, int maxNumTractSections, tMempool* const mp) +void tract_initToPool(tract** const t, int numTractSections, int maxNumTractSections, tMempool** const mp) { - _tMempool* m = *mp; - _tract* tr = *t = (_tract*) mpool_calloc(sizeof(_tract), m); + tMempool* m = *mp; + tract* tr = *t = (tract*) mpool_calloc(sizeof(tract), m); tr->mempool = m; LEAF* leaf = m->leaf; @@ -312,11 +312,11 @@ void tract_initToPool(tract* const t, int numTractSections, int maxNumTractSect tr->block_time = 64.0f / leaf->sampleRate; tr->T = 1.0f / leaf->sampleRate; - tr->tpool = (_transient_pool*) mpool_alloc(sizeof(_transient_pool), m); + tr->tpool = (transient_pool*) mpool_alloc(sizeof(transient_pool), m); tr->tpool->size = 0; tr->tpool->next_free = 0; for(i = 0; i < MAX_TRANSIENTS; i++) { - tr->tpool->pool[i] = (_transient*) mpool_alloc(sizeof(_transient), m); + tr->tpool->pool[i] = (transient*) mpool_alloc(sizeof(transient), m); tr->tpool->pool[i]->is_free = 1; tr->tpool->pool[i]->id = i; tr->tpool->pool[i]->position = 0; @@ -326,14 +326,14 @@ void tract_initToPool(tract* const t, int numTractSections, int maxNumTractSect } } -void tract_free(tract* const t) +void tract_free(tract** const t) { - _tract* tr = *t; + tract* tr = *t; mpool_free((char*)tr, tr->mempool); } -void tract_calculate_reflections(tract const tr) +void tract_calculate_reflections(tract* const tr) { int i; Lfloat sum; @@ -379,7 +379,7 @@ void tract_calculate_reflections(tract const tr) tr->new_reflection_nose = (Lfloat)(2.0f * tr->noseA[0] - sum) * invSum; } -void tract_newLength(tract const tr, int numTractSections) +void tract_newLength(tract* const tr, int numTractSections) { int i; Lfloat diameter, d; @@ -482,7 +482,7 @@ void tract_newLength(tract const tr, int numTractSections) } -void tract_reshape(tract const tr) +void tract_reshape(tract* const tr) { Lfloat amount; Lfloat slow_return; @@ -520,7 +520,7 @@ void tract_reshape(tract const tr) /* if(tr->last_obstruction > -1 && current_obstruction == -1 && tr->noseA[0] < 0.05f) { - append_transient(&tr->tpool, tr->last_obstruction); + append_transient(tr->tpool, tr->last_obstruction); } tr->last_obstruction = current_obstruction; @@ -530,16 +530,16 @@ void tract_reshape(tract const tr) tr->noseA[0] = tr->nose_diameter[0] * tr->nose_diameter[0]; } -void tract_addTurbulenceNoise(tract const tr) +void tract_addTurbulenceNoise(tract* const tr) { for (int i = 0; i < 2; i++) { - Lfloat turbulenceNoise = tr->TnoiseGain * tSVF_tick(&tr->fricativeNoiseFilt[i], tNoise_tick(&tr->whiteNoise) * 0.20f); + Lfloat turbulenceNoise = tr->TnoiseGain * tSVF_tick(tr->fricativeNoiseFilt[i], tNoise_tick(tr->whiteNoise) * 0.20f); tract_addTurbulenceNoiseAtPosition(tr, turbulenceNoise, tr->turbuluencePointPosition[i], tr->turbuluencePointDiameter[i]); } } -void tract_addTurbulenceNoiseAtPosition(tract const tr, Lfloat turbulenceNoise, Lfloat position, Lfloat diameter) +void tract_addTurbulenceNoiseAtPosition(tract* const tr, Lfloat turbulenceNoise, Lfloat position, Lfloat diameter) { int i = (int)floorf(position); Lfloat delta = position - i; @@ -560,7 +560,7 @@ void tract_addTurbulenceNoiseAtPosition(tract const tr, Lfloat turbulenceNoise, } -void tract_compute(tract const tr, Lfloat in, Lfloat lambda) +void tract_compute(tract* const tr, Lfloat in, Lfloat lambda) { Lfloat r, w; int i; @@ -581,14 +581,14 @@ void tract_compute(tract const tr, Lfloat in, Lfloat lambda) tr->R[n->position] += amp * 0.5f; n->time_alive += tr->T * 0.5f; if(n->time_alive > n->lifetime) { - remove_transient(&thepool, n->id); + remove_transient(thepool, n->id); } n = n->next; } */ - Lfloat UVnoise = tNoise_tick(&tr->whiteNoise); - UVnoise = tSVF_tick(&tr->aspirationNoiseFilt,UVnoise); + Lfloat UVnoise = tNoise_tick(tr->whiteNoise); + UVnoise = tSVF_tick(tr->aspirationNoiseFilt,UVnoise); in = fast_tanh5((UVnoise * tr->AnoiseGain) + (in * (1.0f - tr->AnoiseGain))); @@ -644,7 +644,7 @@ void tract_compute(tract const tr, Lfloat in, Lfloat lambda) } -void tract_calculate_nose_reflections(tract const tr) +void tract_calculate_nose_reflections(tract* const tr) { int i; @@ -664,9 +664,9 @@ void tract_calculate_nose_reflections(tract const tr) -int append_transient(transient_pool const pool, int position) +int append_transient(transient_pool* const pool, int position) { - _transient* t; + transient* t; int i; int free_id; @@ -699,10 +699,10 @@ int append_transient(transient_pool const pool, int position) } -void remove_transient(transient_pool const pool, unsigned int id) +void remove_transient(transient_pool* const pool, unsigned int id) { int i; - _transient *n; + transient *n; pool->next_free = id; n = pool->root; @@ -741,30 +741,30 @@ Lfloat move_towards(Lfloat current, Lfloat target, -void tVoc_init (tVoc* const voc, int numTractSections, int maxNumTractSections, LEAF* const leaf) +void tVoc_init(tVoc** const voc, int numTractSections, int maxNumTractSections, LEAF* const leaf) { tVoc_initToPool (voc, numTractSections, maxNumTractSections, &leaf->mempool); } -void tVoc_initToPool (tVoc* const voc, int numTractSections, int maxNumTractSections, tMempool* const mp) +void tVoc_initToPool(tVoc** const voc, int numTractSections, int maxNumTractSections, tMempool** const mp) { - _tMempool* m = *mp; - _tVoc* v = *voc = (_tVoc*) mpool_alloc(sizeof(_tVoc), m); + tMempool* m = *mp; + tVoc* v = *voc = (tVoc*) mpool_alloc(sizeof(tVoc), m); v->mempool = m; glottis_initToPool(&v->glot, &m); /* initialize glottis */ tract_initToPool(&v->tr, numTractSections, maxNumTractSections, &m); /* initialize vocal tract */ v->counter = 0; } -void tVoc_free (tVoc* const voc) +void tVoc_free(tVoc** const voc) { - _tVoc* v = *voc; + tVoc* v = *voc; glottis_free(&v->glot); tract_free(&v->tr); //mpool_free((char*)v->buf, v->mempool); mpool_free((char*)v, v->mempool); } -Lfloat tVoc_tick (tVoc const v) +Lfloat tVoc_tick (tVoc* const v) { Lfloat vocal_output, glot; Lfloat lambda1,lambda2; @@ -778,7 +778,7 @@ Lfloat tVoc_tick (tVoc const v) vocal_output = 0.0f; lambda1 = ((Lfloat) v->counter) * 0.015625f;// /64 lambda2 = (Lfloat) (v->counter + 0.5f) * 0.015625f; // /64 - glot = glottis_compute(&v->glot); + glot = glottis_compute(v->glot); tract_compute(v->tr, glot, lambda1); vocal_output += v->tr->lip_output + v->tr->nose_output; @@ -798,7 +798,7 @@ Lfloat tVoc_tick (tVoc const v) return vocal_output; } -void tVoc_tractCompute (tVoc const v, Lfloat *in, Lfloat *out) +void tVoc_tractCompute (tVoc* const v, Lfloat *in, Lfloat *out) { Lfloat vocal_output; Lfloat lambda1, lambda2; @@ -821,57 +821,57 @@ void tVoc_tractCompute (tVoc const v, Lfloat *in, Lfloat *out) *out = vocal_output * 0.125; v->counter = (v->counter + 1) & 64; } -void tVoc_setDoubleComputeFlag(tVoc const v, int doubleCompute) +void tVoc_setDoubleComputeFlag(tVoc* const v, int doubleCompute) { v->doubleCompute = doubleCompute; } -void tVoc_setSampleRate(tVoc const v, Lfloat sr) +void tVoc_setSampleRate(tVoc* const v, Lfloat sr) { v->sampleRate = sr; } -void tVoc_setFreq (tVoc const v, Lfloat freq) +void tVoc_setFreq (tVoc* const v, Lfloat freq) { v->glot->freq = freq; } -Lfloat * tVoc_get_frequency_ptr(tVoc const v) +Lfloat * tVoc_get_frequency_ptr(tVoc* const v) { return &v->glot->freq; } -Lfloat* tVoc_get_tract_diameters(tVoc const v) +Lfloat* tVoc_get_tract_diameters(tVoc* const v) { return v->tr->target_diameter; } -Lfloat* tVoc_get_tract_rest_diameters(tVoc const v) +Lfloat* tVoc_get_tract_rest_diameters(tVoc* const v) { return v->tr->rest_diameter; } -Lfloat* tVoc_get_current_tract_diameters(tVoc const v) +Lfloat* tVoc_get_current_tract_diameters(tVoc* const v) { return v->tr->diameter; } -int tVoc_get_tract_size(tVoc const v) +int tVoc_get_tract_size(tVoc* const v) { return v->tr->n; } -Lfloat* tVoc_get_nose_diameters(tVoc const v) +Lfloat* tVoc_get_nose_diameters(tVoc* const v) { return v->tr->nose_diameter; } -int tVoc_get_nose_size(tVoc const v) +int tVoc_get_nose_size(tVoc* const v) { return v->tr->nose_length; } //diameter and index are 0-1.0f -void tVoc_set_tongue_shape_and_touch(tVoc const v, Lfloat tongue_index, Lfloat tongue_diameter, Lfloat touch_index, Lfloat touch_diameter) +void tVoc_set_tongue_shape_and_touch(tVoc* const v, Lfloat tongue_index, Lfloat tongue_diameter, Lfloat touch_index, Lfloat touch_diameter) { Lfloat *diameters; diameters = tVoc_get_tract_diameters(v); @@ -889,53 +889,53 @@ void tVoc_set_tongue_shape_and_touch(tVoc const v, Lfloat tongue_index, Lfloat t v->tr->turbuluencePointPosition[1] = touch_index; v->tr->turbuluencePointDiameter[1] = touch_diameter; } -void tVoc_set_tractLength(tVoc const v, int newLength) +void tVoc_set_tractLength(tVoc* const v, int newLength) { tract_newLength(v->tr, newLength); } -void tVoc_set_tenseness(tVoc const v, Lfloat tenseness) +void tVoc_set_tenseness(tVoc* const v, Lfloat tenseness) { v->glot->tenseness = tenseness; } -Lfloat * tVoc_get_tenseness_ptr(tVoc const v) +Lfloat * tVoc_get_tenseness_ptr(tVoc* const v) { return &v->glot->tenseness; } -void tVoc_set_velum(tVoc const v, Lfloat velum) +void tVoc_set_velum(tVoc* const v, Lfloat velum) { v->tr->velum_target = velum; } -void tVoc_setTurbulenceNoiseGain(tVoc const v, Lfloat gain) +void tVoc_setTurbulenceNoiseGain(tVoc* const v, Lfloat gain) { v->tr->TnoiseGain = gain; } -void tVoc_setAspirationNoiseGain(tVoc const v, Lfloat gain) +void tVoc_setAspirationNoiseGain(tVoc* const v, Lfloat gain) { v->tr->AnoiseGain = gain; } -Lfloat * tVoc_get_velum_ptr(tVoc const v) +Lfloat * tVoc_get_velum_ptr(tVoc* const v) { return &v->tr->velum_target; } //0-1 -void tVoc_setAspirationNoiseFilterFreq(tVoc const v, Lfloat freq) +void tVoc_setAspirationNoiseFilterFreq(tVoc* const v, Lfloat freq) { - tSVF_setFreqFast(&v->tr->aspirationNoiseFilt,freq*30.0f + 60.0f); + tSVF_setFreqFast(v->tr->aspirationNoiseFilt,freq*30.0f + 60.0f); } -void tVoc_setAspirationNoiseFilterQ(tVoc const v, Lfloat Q) +void tVoc_setAspirationNoiseFilterQ(tVoc* const v, Lfloat Q) { - tSVF_setQ(&v->tr->aspirationNoiseFilt,Q*0.49f + 0.5f); + tSVF_setQ(v->tr->aspirationNoiseFilt,Q*0.49f + 0.5f); } //diameter and index are 0-1.0f -void tVoc_set_tongue_and_touch_diameters(tVoc const v, Lfloat tongue_index, Lfloat tongue_diameter, Lfloat touch_index, Lfloat touch_diameter, Lfloat *theDiameters) +void tVoc_set_tongue_and_touch_diameters(tVoc* const v, Lfloat tongue_index, Lfloat tongue_diameter, Lfloat touch_index, Lfloat touch_diameter, Lfloat *theDiameters) { int i; Lfloat t; @@ -1021,12 +1021,12 @@ void tVoc_set_tongue_and_touch_diameters(tVoc const v, Lfloat tongue_index, Lflo } -int tVoc_get_counter(tVoc const v) +int tVoc_get_counter(tVoc* const v) { return v->counter; } -void tVoc_rescaleDiameter(tVoc const v, Lfloat scale) +void tVoc_rescaleDiameter(tVoc* const v, Lfloat scale) { v->tr->diameterScale = scale; } diff --git a/leaf/leaf.h b/leaf/leaf.h index 363f763..4e4edf4 100644 --- a/leaf/leaf.h +++ b/leaf/leaf.h @@ -149,7 +149,7 @@ extern "C" { @param memorySize The size of the memory that will make up the default mempool of a LEAF instance. @param random A pointer to a random number function. Should return a Lfloat >= 0 and < 1. */ - void LEAF_init (LEAF* const leaf, Lfloat sampleRate, char* memory, size_t memorySize, Lfloat(*random)(void)); + void LEAF_init(LEAF* const leaf, Lfloat sampleRate, char* memory, size_t memorySize, Lfloat(*random)(void)); //! Set the sample rate of LEAF. /*! diff --git a/test/filters_test.cpp b/test/filters_test.cpp index 8064c5b..5b75e53 100644 --- a/test/filters_test.cpp +++ b/test/filters_test.cpp @@ -11,7 +11,7 @@ TEST_CASE("Tests for `tAllpass` filer", "[tAllpass]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tAllpass filter; + tAllpass* filter; tAllpass_init(&filter, 50, 100, &leaf); REQUIRE(filter != nullptr); @@ -24,7 +24,7 @@ TEST_CASE("Tests for `tAllpassSO` filer", "[tAllpassSO]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tAllpassSO filter; +tAllpassSO* filter; tAllpassSO_init(&filter, &leaf); REQUIRE(filter != nullptr); @@ -37,7 +37,7 @@ TEST_CASE("Tests for `tThiranAllpassSOCascade` filer", "[tThiranAllpassSOCascade char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tThiranAllpassSOCascade filter; +tThiranAllpassSOCascade* filter; tThiranAllpassSOCascade_init(&filter, 3, &leaf); REQUIRE(filter != nullptr); @@ -50,7 +50,7 @@ TEST_CASE("Tests for `tOnePole` filer", "[tOnePole]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tOnePole filter; +tOnePole* filter; tOnePole_init(&filter, 22050, &leaf); REQUIRE(filter != nullptr); @@ -63,7 +63,7 @@ TEST_CASE("Tests for `tCookOnePole` filer", "[tCookOnePole]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tCookOnePole filter; +tCookOnePole* filter; tCookOnePole_init(&filter, &leaf); REQUIRE(filter != nullptr); @@ -76,7 +76,7 @@ TEST_CASE("Tests for `tTwoPole` filer", "[tTwoPole]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tTwoPole filter; +tTwoPole* filter; tTwoPole_init(&filter, &leaf); REQUIRE(filter != nullptr); @@ -89,7 +89,7 @@ TEST_CASE("Tests for `tOneZero` filer", "[tOneZero]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tOneZero filter; +tOneZero* filter; tOneZero_init(&filter, 1, &leaf); REQUIRE(filter != nullptr); @@ -102,7 +102,7 @@ TEST_CASE("Tests for `tTwoZero` filer", "[tTwoZero]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tTwoZero filter; +tTwoZero* filter; tTwoZero_init(&filter, &leaf); REQUIRE(filter != nullptr); @@ -115,7 +115,7 @@ TEST_CASE("Tests for `tPoleZero` filer", "[tPoleZero]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tPoleZero filter; +tPoleZero* filter; tPoleZero_init(&filter, &leaf); REQUIRE(filter != nullptr); @@ -128,7 +128,7 @@ TEST_CASE("Tests for `tBiQuad` filer", "[tBiQuad]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tBiQuad filter; +tBiQuad* filter; tBiQuad_init(&filter, &leaf); REQUIRE(filter != nullptr); @@ -141,43 +141,43 @@ TEST_CASE("Tests for `tSVF` filer", "[tSVF]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tSVF filter1; +tSVF* filter1; tSVF_init(&filter1, SVFTypeHighpass, 22050, 4, &leaf); REQUIRE(filter1 != nullptr); REQUIRE_NOTHROW(tSVF_free(&filter1)); - tSVF filter2; +tSVF* filter2; tSVF_init(&filter2, SVFTypeLowpass, 22050, 4, &leaf); REQUIRE(filter2 != nullptr); REQUIRE_NOTHROW(tSVF_free(&filter2)); - tSVF filter3; +tSVF* filter3; tSVF_init(&filter3, SVFTypeBandpass, 22050, 4, &leaf); REQUIRE(filter3 != nullptr); REQUIRE_NOTHROW(tSVF_free(&filter3)); - tSVF filter4; +tSVF* filter4; tSVF_init(&filter4, SVFTypeNotch, 22050, 4, &leaf); REQUIRE(filter4 != nullptr); REQUIRE_NOTHROW(tSVF_free(&filter4)); - tSVF filter5; +tSVF* filter5; tSVF_init(&filter5, SVFTypePeak, 22050, 4, &leaf); REQUIRE(filter5 != nullptr); REQUIRE_NOTHROW(tSVF_free(&filter5)); - tSVF filter6; +tSVF* filter6; tSVF_init(&filter6, SVFTypeLowShelf, 22050, 4, &leaf); REQUIRE(filter6 != nullptr); REQUIRE_NOTHROW(tSVF_free(&filter6)); - tSVF filter7; +tSVF* filter7; tSVF_init(&filter7, SVFTypeHighShelf, 22050, 4, &leaf); REQUIRE(filter7 != nullptr); @@ -190,43 +190,43 @@ TEST_CASE("Tests for `tEfficientSVF` filer", "[tEfficientSVF]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tEfficientSVF filter1; +tEfficientSVF* filter1; tEfficientSVF_init(&filter1, SVFTypeHighpass, 22050, 4, &leaf); REQUIRE(filter1 != nullptr); REQUIRE_NOTHROW(tEfficientSVF_free(&filter1)); - tEfficientSVF filter2; +tEfficientSVF* filter2; tEfficientSVF_init(&filter2, SVFTypeLowpass, 22050, 4, &leaf); REQUIRE(filter2 != nullptr); REQUIRE_NOTHROW(tEfficientSVF_free(&filter2)); - tEfficientSVF filter3; +tEfficientSVF* filter3; tEfficientSVF_init(&filter3, SVFTypeBandpass, 22050, 4, &leaf); REQUIRE(filter3 != nullptr); REQUIRE_NOTHROW(tEfficientSVF_free(&filter3)); - tEfficientSVF filter4; +tEfficientSVF* filter4; tEfficientSVF_init(&filter4, SVFTypeNotch, 22050, 4, &leaf); REQUIRE(filter4 != nullptr); REQUIRE_NOTHROW(tEfficientSVF_free(&filter4)); - tEfficientSVF filter5; +tEfficientSVF* filter5; tEfficientSVF_init(&filter5, SVFTypePeak, 22050, 4, &leaf); REQUIRE(filter5 != nullptr); REQUIRE_NOTHROW(tEfficientSVF_free(&filter5)); - tEfficientSVF filter6; +tEfficientSVF* filter6; tEfficientSVF_init(&filter6, SVFTypeLowShelf, 22050, 4, &leaf); REQUIRE(filter6 != nullptr); REQUIRE_NOTHROW(tEfficientSVF_free(&filter6)); - tEfficientSVF filter7; +tEfficientSVF* filter7; tEfficientSVF_init(&filter7, SVFTypeHighShelf, 22050, 4, &leaf); REQUIRE(filter7 != nullptr); @@ -239,7 +239,7 @@ TEST_CASE("Tests for `tHighpass` filer", "[tHighpass]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tHighpass filter; +tHighpass* filter; tHighpass_init(&filter, 22050, &leaf); REQUIRE(filter != nullptr); @@ -252,7 +252,7 @@ TEST_CASE("Tests for `tButterworth` filer", "[tButterworth]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tButterworth filter; +tButterworth* filter; tButterworth_init(&filter, 3, 1, 1, &leaf); REQUIRE(filter != nullptr); @@ -269,7 +269,7 @@ TEST_CASE("Tests for `tFIR` filer", "[tFIR]") { Lfloat coeffs[512]; LEAF_generate_sine(coeffs, 512); - tFIR filter; +tFIR* filter; tFIR_init(&filter, coeffs, 1, &leaf); REQUIRE(filter != nullptr); @@ -297,67 +297,67 @@ TEST_CASE("Tests for `tVZFilter` filer", "[tVZFilter]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tVZFilter filter1; +tVZFilter* filter1; tVZFilter_init(&filter1, Highpass, 22050, 4, &leaf); REQUIRE(filter1 != nullptr); REQUIRE_NOTHROW(tVZFilter_free(&filter1)); - tVZFilter filter2; +tVZFilter* filter2; tVZFilter_init(&filter2, Lowpass, 22050, 4, &leaf); REQUIRE(filter2 != nullptr); REQUIRE_NOTHROW(tVZFilter_free(&filter2)); - tVZFilter filter3; +tVZFilter* filter3; tVZFilter_init(&filter3, BandpassSkirt, 22050, 4, &leaf); REQUIRE(filter3 != nullptr); REQUIRE_NOTHROW(tVZFilter_free(&filter3)); - tVZFilter filter4; +tVZFilter* filter4; tVZFilter_init(&filter4, BandpassPeak, 22050, 4, &leaf); REQUIRE(filter4 != nullptr); REQUIRE_NOTHROW(tVZFilter_free(&filter4)); - tVZFilter filter5; +tVZFilter* filter5; tVZFilter_init(&filter5, BandReject, 22050, 4, &leaf); REQUIRE(filter5 != nullptr); REQUIRE_NOTHROW(tVZFilter_free(&filter5)); - tVZFilter filter6; +tVZFilter* filter6; tVZFilter_init(&filter6, Bell, 22050, 4, &leaf); REQUIRE(filter6 != nullptr); REQUIRE_NOTHROW(tVZFilter_free(&filter6)); - tVZFilter filter7; +tVZFilter* filter7; tVZFilter_init(&filter7, Lowshelf, 22050, 4, &leaf); REQUIRE(filter7 != nullptr); REQUIRE_NOTHROW(tVZFilter_free(&filter7)); - tVZFilter filter8; +tVZFilter* filter8; tVZFilter_init(&filter8, Highshelf, 22050, 4, &leaf); REQUIRE(filter8 != nullptr); REQUIRE_NOTHROW(tVZFilter_free(&filter8)); - tVZFilter filter9; +tVZFilter* filter9; tVZFilter_init(&filter9, Morph, 22050, 4, &leaf); REQUIRE(filter9 != nullptr); REQUIRE_NOTHROW(tVZFilter_free(&filter9)); - tVZFilter filter10; +tVZFilter* filter10; tVZFilter_init(&filter10, Bypass, 22050, 4, &leaf); REQUIRE(filter10 != nullptr); REQUIRE_NOTHROW(tVZFilter_free(&filter10)); - tVZFilter filter11; +tVZFilter* filter11; tVZFilter_init(&filter11, Allpass, 22050, 4, &leaf); REQUIRE(filter11 != nullptr); @@ -370,7 +370,7 @@ TEST_CASE("Tests for `tVZFilterLS` filer", "[tVZFilterLS]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tVZFilterLS filter; +tVZFilterLS* filter; tVZFilterLS_init(&filter, 22050, 1, 1, &leaf); REQUIRE(filter != nullptr); @@ -383,7 +383,7 @@ TEST_CASE("Tests for `tVZFilterHS` filer", "[tVZFilterHS]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tVZFilterHS filter; +tVZFilterHS* filter; tVZFilterHS_init(&filter, 22050, 1, 1, &leaf); REQUIRE(filter != nullptr); @@ -396,7 +396,7 @@ TEST_CASE("Tests for `tVZFilterBell` filer", "[tVZFilterBell]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tVZFilterBell filter; +tVZFilterBell* filter; tVZFilterBell_init(&filter, 22050, 1, 1, &leaf); REQUIRE(filter != nullptr); @@ -409,7 +409,7 @@ TEST_CASE("Tests for `tVZFilterBR` filer", "[tVZFilterBR]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tVZFilterBR filter; +tVZFilterBR* filter; tVZFilterBR_init(&filter, 22050, 1, &leaf); REQUIRE(filter != nullptr); @@ -422,7 +422,7 @@ TEST_CASE("Tests for `tDiodeFilter` filer", "[tDiodeFilter]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tDiodeFilter filter; +tDiodeFilter* filter; tDiodeFilter_init(&filter, 22050, 1, &leaf); REQUIRE(filter != nullptr); @@ -435,7 +435,7 @@ TEST_CASE("Tests for `tLadderFilter` filer", "[tLadderFilter]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tLadderFilter filter; +tLadderFilter* filter; tLadderFilter_init(&filter, 22050, 1, &leaf); REQUIRE(filter != nullptr); @@ -448,7 +448,7 @@ TEST_CASE("Tests for `tTiltFilter` filer", "[tTiltFilter]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tTiltFilter filter; +tTiltFilter* filter; tTiltFilter_init(&filter, 22050, &leaf); REQUIRE(filter != nullptr); diff --git a/test/oscillators_test.cpp b/test/oscillators_test.cpp index 39bd28a..d53a1a1 100644 --- a/test/oscillators_test.cpp +++ b/test/oscillators_test.cpp @@ -11,7 +11,7 @@ TEST_CASE("Tests for `tCycle` object", "[tCycle]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tCycle osc; +tCycle* osc; tCycle_init(&osc, &leaf); REQUIRE(osc != nullptr); @@ -24,7 +24,7 @@ TEST_CASE("Tests for `tTriangle` object", "[tTriangle]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tTriangle osc; +tTriangle* osc; tTriangle_init(&osc, &leaf); REQUIRE(osc != nullptr); @@ -37,7 +37,7 @@ TEST_CASE("Tests for `tSquare` object", "[tSquare]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tSquare osc; +tSquare* osc; tSquare_init(&osc, &leaf); REQUIRE(osc != nullptr); @@ -50,7 +50,7 @@ TEST_CASE("Tests for `tSawtooth` object", "[tSawtooth]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tSawtooth osc; +tSawtooth* osc; tSawtooth_init(&osc, &leaf); REQUIRE(osc != nullptr); @@ -63,7 +63,7 @@ TEST_CASE("Tests for `tPBSineTriangle` object", "[tPBSineTriangle]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tPBSineTriangle osc; +tPBSineTriangle* osc; tPBSineTriangle_init(&osc, &leaf); REQUIRE(osc != nullptr); @@ -76,7 +76,7 @@ TEST_CASE("Tests for `tPBTriangle` object", "[tPBTriangle]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tPBTriangle osc; +tPBTriangle* osc; tPBTriangle_init(&osc, &leaf); REQUIRE(osc != nullptr); @@ -89,7 +89,7 @@ TEST_CASE("Tests for `tPBPulse` object", "[tPBPulse]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tPBPulse osc; +tPBPulse* osc; tPBPulse_init(&osc, &leaf); REQUIRE(osc != nullptr); @@ -102,7 +102,7 @@ TEST_CASE("Tests for `tPBSaw` object", "[tPBSaw]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tPBSaw osc; +tPBSaw* osc; tPBSaw_init(&osc, &leaf); REQUIRE(osc != nullptr); @@ -115,7 +115,7 @@ TEST_CASE("Tests for `tPBSawSquare` object", "[tPBSawSquare]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tPBSawSquare osc; +tPBSawSquare* osc; tPBSawSquare_init(&osc, &leaf); REQUIRE(osc != nullptr); @@ -128,7 +128,7 @@ TEST_CASE("Tests for `tSawOS` object", "[tSawOS]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tSawOS osc; +tSawOS* osc; tSawOS_init(&osc, 2, 2, &leaf); REQUIRE(osc != nullptr); @@ -141,7 +141,7 @@ TEST_CASE("Tests for `tPhasor` object", "[tPhasor]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tPhasor osc; +tPhasor* osc; tPhasor_init(&osc, &leaf); REQUIRE(osc != nullptr); @@ -154,13 +154,13 @@ TEST_CASE("Tests for `tNoise` object", "[tNoise]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tNoise osc; +tNoise* osc; tNoise_init(&osc, WhiteNoise, &leaf); REQUIRE(osc != nullptr); REQUIRE_NOTHROW(tNoise_free(&osc)); - tNoise osc2; +tNoise* osc2; tNoise_init(&osc2, PinkNoise, &leaf); REQUIRE(osc2 != nullptr); @@ -173,7 +173,7 @@ TEST_CASE("Tests for `tNeuron` object", "[tNeuron]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tNeuron osc; +tNeuron* osc; tNeuron_init(&osc, &leaf); REQUIRE(osc != nullptr); @@ -186,7 +186,7 @@ TEST_CASE("Tests for `tMBPulse` object", "[tMBPulse]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tMBPulse osc; +tMBPulse* osc; tMBPulse_init(&osc, &leaf); REQUIRE(osc != nullptr); @@ -199,7 +199,7 @@ TEST_CASE("Tests for `tMBTriangle` object", "[tMBTriangle]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tMBTriangle osc; +tMBTriangle* osc; tMBTriangle_init(&osc, &leaf); REQUIRE(osc != nullptr); @@ -212,7 +212,7 @@ TEST_CASE("Tests for `tMBSineTri` object", "[tMBSineTri]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tMBSineTri osc; +tMBSineTri* osc; tMBSineTri_init(&osc, &leaf); REQUIRE(osc != nullptr); @@ -225,7 +225,7 @@ TEST_CASE("Tests for `tMBSaw` object", "[tMBSaw]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tMBSaw osc; +tMBSaw* osc; tMBSaw_init(&osc, &leaf); REQUIRE(osc != nullptr); @@ -238,7 +238,7 @@ TEST_CASE("Tests for `tMBSawPulse` object", "[tMBSawPulse]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tMBSawPulse osc; +tMBSawPulse* osc; tMBSawPulse_init(&osc, &leaf); REQUIRE(osc != nullptr); @@ -251,7 +251,7 @@ TEST_CASE("Tests for `tTable` object", "[tTable]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tTable osc; +tTable* osc; Lfloat num[512]; LEAF_generate_sine(num, 512); @@ -270,7 +270,7 @@ TEST_CASE("Tests for `tWaveTable` object", "[tWaveTable]") { Lfloat num[512]; LEAF_generate_sine(num, 512); - tWaveTable osc; +tWaveTable* osc; tWaveTable_init(&osc, num, 512, 22050, &leaf); REQUIRE(osc != nullptr); @@ -283,13 +283,13 @@ TEST_CASE("Tests for `tWaveOsc` object", "[tWaveOsc]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tWaveTable waveTable; +tWaveTable* waveTable; Lfloat num[512]; LEAF_generate_sine(num, 512); tWaveTable_init(&waveTable, num, 512, 22050, &leaf); - tWaveOsc osc; +tWaveOsc* osc; tWaveOsc_init(&osc, &waveTable, waveTable->numTables, &leaf); REQUIRE(osc != nullptr); @@ -305,7 +305,7 @@ TEST_CASE("Tests for `tWaveTableS` object", "[tWaveTableS]") { Lfloat num[512]; LEAF_generate_sine(num, 512); - tWaveTableS osc; +tWaveTableS* osc; tWaveTableS_init(&osc, num, 512, 22050, &leaf); REQUIRE(osc != nullptr); @@ -318,13 +318,13 @@ TEST_CASE("Tests for `tWaveOscS` object", "[tWaveOscS]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tWaveTableS waveTable; +tWaveTableS* waveTable; Lfloat num[512]; LEAF_generate_sine(num, 512); tWaveTableS_init(&waveTable, num, 512, 22050, &leaf); - tWaveOscS osc; +tWaveOscS* osc; tWaveOscS_init(&osc, &waveTable, waveTable->numTables, &leaf); REQUIRE(osc != nullptr); @@ -337,7 +337,7 @@ TEST_CASE("Tests for `tIntPhasor` object", "[tIntPhasor]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tIntPhasor osc; +tIntPhasor* osc; tIntPhasor_init(&osc, &leaf); REQUIRE(osc != nullptr); @@ -350,7 +350,7 @@ TEST_CASE("Tests for `tSquareLFO` object", "[tSquareLFO]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tSquareLFO osc; +tSquareLFO* osc; tSquareLFO_init(&osc, &leaf); REQUIRE(osc != nullptr); @@ -363,7 +363,7 @@ TEST_CASE("Tests for `tSawSquareLFO` object", "[tSawSquareLFO]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tSawSquareLFO osc; +tSawSquareLFO* osc; tSawSquareLFO_init(&osc, &leaf); REQUIRE(osc != nullptr); @@ -376,7 +376,7 @@ TEST_CASE("Tests for `tTriLFO` object", "[tTriLFO]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tTriLFO osc; +tTriLFO* osc; tTriLFO_init(&osc, &leaf); REQUIRE(osc != nullptr); @@ -389,7 +389,7 @@ TEST_CASE("Tests for `tSineTriLFO` object", "[tSineTriLFO]") { char leafMemory[65535]; LEAF_init(&leaf, 44100.f, leafMemory, 65535, &myrand); - tSineTriLFO osc; +tSineTriLFO* osc; tSineTriLFO_init(&osc, &leaf); REQUIRE(osc != nullptr); From 5536133c19d032958a7c2e01d094fb5a03ee6323 Mon Sep 17 00:00:00 2001 From: Davis Polito Date: Thu, 10 Jul 2025 16:07:10 -0400 Subject: [PATCH 04/14] psuhign --- leaf/Src/leaf-instruments.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/leaf/Src/leaf-instruments.c b/leaf/Src/leaf-instruments.c index 2832ab2..5462c46 100644 --- a/leaf/Src/leaf-instruments.c +++ b/leaf/Src/leaf-instruments.c @@ -67,7 +67,7 @@ void t808Cowbell_free (t808Cowbell** const cowbellInst) tHighpass_free(&cowbell->highpass); tNoise_free(&cowbell->stick); tEnvelope_free(&cowbell->envStick); - mpool_free((char*)cowbell, cowbell->mempool); + mpool_free((char*)cowbell, cowbell->mempool)t ; } void t808Cowbell_on(t808Cowbell* const cowbell, Lfloat vel) From 9706116c5c4850e708bbdbf6c2be2a0b0661860c Mon Sep 17 00:00:00 2001 From: seanxue Date: Tue, 15 Jul 2025 15:50:43 -0400 Subject: [PATCH 05/14] examples and notation for leaf-analysis.h --- leaf/Inc/leaf-analysis.h | 246 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 238 insertions(+), 8 deletions(-) diff --git a/leaf/Inc/leaf-analysis.h b/leaf/Inc/leaf-analysis.h index bfa41d6..10315e4 100644 --- a/leaf/Inc/leaf-analysis.h +++ b/leaf/Inc/leaf-analysis.h @@ -37,7 +37,25 @@ extern "C" { @defgroup tenvelopefollower tEnvelopeFollower @ingroup analysis @brief Detects and returns the basic envelope of incoming audio data. - @{ + + The envelope follower watches incoming samples and re-opens envelope to threshold limit whenever sample exceeds limit. + Between sample attacks, the envelope value decays each tick by the delay coefficient. + + Example + @code{.c} + //initialize + tEnvelopeFollower* env = NULL; + tEnvelopeFollower_init(&env, + 0.1f, //attack threshold + 1.0f, //decay coefficient + leaf;) + + //audio loop + float envVal = tEnvelopeFollower_tick(env, inputSample); + + //when done + tEnvelopeFollower_free(&env); + @endcode @fn void tEnvelopeFollower_init(tEnvelopeFollower** const follower, Lfloat attackThreshold, Lfloat decayCoeff, LEAF* const leaf) @brief Initialize a tEnvelopeFollower to the default mempool of a LEAF instance. @@ -98,7 +116,33 @@ extern "C" { @defgroup tzerocrossingcounter tZeroCrossingCounter @ingroup analysis @brief Count the amount of zero crossings within a window of the input audio data - @{ + + The zero crossing counter keeps a circular buffer of the most recent samples, up to 'maxWindowSize. + On each tick it: + 1. Inserts the new sample into the buffer, overwriting the current oldest sample + 2. Checks if the new sample and what it replaced have zero crossing + 3. Updates internal counter + 4. Returns the count normalized by window size, from [0.0 to 1.0] + Higher counts indicate rapid sign changes + Lower counts indicate steady signals + + Example + @code{.c} + //initialize + tZeroCrossingCounter* zc = NULL; + tZeroCrossingCounter_init(&zc, + 1024, //max window size + leaf); + + //audio loop + float r = tZeroCrossingCounter_tick(zc, inputSample); //r is the fraction of zero crossings in the last window + + //changing window size + tZeroCrossingCounter_setWindowSize(zc, 512); + + /when done + tZeroCrossingCounter_free(&zc); + @endcode @fn void tZeroCrossingCounter_init(tZeroCrossingCounter** const counter, int maxWindowSize, LEAF* const leaf) @brief Initialize a tZeroCrossingCounter to the default mempool of a LEAF instance. @@ -158,7 +202,34 @@ extern "C" { @defgroup tpowerfollower tPowerFollower @ingroup analysis @brief Measure and follow the power of an input signal using an exponential moving average for smoothing. - @{ + + The power follower calculates a estimate of signal power by: + 1. Squaring or taking the absolute value of each incoming sample to get its instantaneous power + 2. Updating its internal state + 3. Returning the updated power value + A higher value gives faster response and less smoothing + A lower value gives slower response and more smoothing + + Example + @code{.c} + //initialize + tPowerFollower+ pf = NULL; + tPowerFollower_init(&pf, + 0.4, //smoothing factor + leaf); + + //audio loop + float power = tPowerFollower_tick(pf, inputSample); + + //getting last power directly + float lPower = tPowerFollower_getPower(pf); + + //adjust smoothing factor + tPowerFollower_setFactor(pf, 0.2f); + + /when done + tPowerFollower_free(&pdf); + @endcode @fn void tPowerFollower_init(tPowerFollower** const, Lfloat factor, LEAF* const leaf) @brief Initialize a tPowerFollower to the default mempool of a LEAF instance. @@ -219,7 +290,35 @@ extern "C" { @defgroup tenvpd tEnvPD @ingroup analysis @brief ENV~ from PD, modified for LEAF - @{ + + The ENV algorithm measures the envelope by: + 1. Summing the squared or absolute values of samples in a sliding window of size + 2. Calculating average over last 'windowSize' samples every 'hopSize' samples + 3. Outputting one envelope value per hop + 4. Using 'blockSize' to allocate extra buffer space for overlapping and vectorized DSP operations + + Example + @code{.c} + //initialize + tEnvPD* env = NULL; + tEnvPD_init(&env, + 1024, //number of samples per analysis frame + 256, // output interval in samples + 512, // internal block allocation + leaf); + + //audio loop, either: + //process one block at a time + float envelopeValue; + for (int i = 0; i < hopSize; ++i){ + envelopeValue = tEnvPD_tick(env); + } + //or process entire block buffer simultaneously + TEnvPD_processBlock(env, inputBuffer); + + //when done + tEnvPD_free(&env); + @endcode @fn void tEnvPD_init(tEnvPD** const, int windowSize, int hopSize, int blockSize, LEAF* const leaf) @brief Initialize a tEnvPD to the default mempool of a LEAF instance. @@ -288,7 +387,41 @@ extern "C" { @defgroup tattackdetection tAttackDetection @ingroup analysis @brief Detect attacks in an input signal - @{ + + The attack detector works on a fixed size block of samples it: + 1. Computes the RMS amplitude of each incoming block of specified length + 2. Calculates the difference between the current and previous block's RMS + 3. If that difference exceeds set threshold, an attack is flagged + 4. Returns the sample index within the block where the largest transient occured + A shorter attack (ms) makes the detected respond quicker to fast transients + A longer release (ms) time smooths out successive detections + + Example + @code{.c} + //initialize + tAttackDetection* ad = NULL; + tAttackDetection_init(&ad, + 1024, //block size in samples + 10, //attack time in ms + 50, //release time in ms + leaf); + + //audio block + float block[1024]; + //detect largest attack in the block + int id = tAttackDetection_detect(ad, block); + if (id >= 0){ + ... + } + + //tweak parameters + tAttackDetection_setThreshold(ad, 5.0f); //change detection threshold + tAttackDetection_setAttack(ad, 3); //change attack response (ms) + tAttackDetection_setRelease(ad, 100); //change release (ms) + + //when done + tAttackDetection_free(&ad); + @endcode @fn void tAttackDetection_init(tAttackDetection** const, int blocksize, int atk, int rel, LEAF* const leaf) @brief Initialize a tAttackDetection to the default mempool of a LEAF instance. @@ -389,7 +522,42 @@ extern "C" { @defgroup tsnac tSNAC @ingroup analysis @brief Component of period detection algorithm from Katja Vetters http://www.katjaas.nl/helmholtz/helmholtz.html - @{ + + The SNAC algorithm estimates signal periodicity by: + 1. Splitting each analysis frame of set samples into two overlapping segments separated by 'overlap' samples + 2. Computing the dot product between these segments + 3. Applying bias factor and thresholding to ignore low level noise + 4. Scanning for lag with maximum correlation above the noise floor + 5. Storing the detected period length in samples and fidelity (confidence) score (0.0-1.0) + + Example + @code{.c} + //initialize + tSNAC* snac = NULL; + tSNAC_init(&snac, + 4, //overlap in samples + leaf); + + //audio loop + Lfloat buffer[SNAC_FRAME_SIZE]; + //fill buffer with audio + tSNAC_ioSamples(snac, buffer, SNAC_FRAME_SIZE); + //retrieve the detected period and fidelity + Lfloat periodSamples = tSNAC_getPeriod(snac); + Lfloat fidelity = tSNAC_getFidelity(snac); + if (fidelity > 0.8f){ + float freq = sampleRate / periodSamples; + ... + } + + //tweak parameters + tSNAC_setOverlap(snac, 2); //change overlap + tSNAC_setBias(snac, 0.1f); //change bias factor + tSNAC_setMinRMS(snac, 0.01f); //change minimum RMS + + //when done + tSNAC_free(&snac); + @endcode @fn void tSNAC_init(tSNAC** const, int overlaparg, LEAF* const leaf) @brief Initialize a tSNAC to the default mempool of a LEAF instance. @@ -484,7 +652,35 @@ extern "C" { @defgroup tperioddetection tPeriodDetection @ingroup analysis @brief Period detection algorithm from Katja Vetters http://www.katjaas.nl/helmholtz/helmholtz.html - @{ + + Example + @code{.c} + //initalize + tPeriodDetection* pd = NULL; + tPeriodDetection_init(&pd, + inputBuffer, //pointer to float array of 'bufSize' + 1024, //buffer size in samples + 512, //analysis frame size + leaf); + + //audio loop + for (int i = 0; i < numSamples; ++i){ + float period = tPeriodDetection_tick(pd, inputSamples[i]); + if (period > 0.0f){ + float freq = sampleRate / period; + } + } + + //tweak parameters + tPeriodDetection_setHopSize(pd, 128); + tPeriodDetection_setWindowSize(pd, 512); + tPeriodDetection_setFidelityThreshold(pd, 0.8f); + tPeriodDetection_setAlpha(pd, 0.7f); + tPeriodDetection_setTolerance(pd, 0.1f); + + //when done + tPeriodDetection_free(&pd); + @endcode @fn void tPeriodDetection_init(tPeriodDetection** const, Lfloat* in, Lfloat* out, int bufSize, int frameSize, LEAF* const leaf) @brief Initialize a tPeriodDetection to the default mempool of a LEAF instance. @@ -952,7 +1148,41 @@ extern "C" { @defgroup tdualpitchdetector tDualPitchDetector @ingroup analysis @brief Combined pitch detection algorithm using both Joel de Guzman's Q Audio DSP Library and Katya Vetters algorithms - @{ + + The dual pitch detector feeds each sample into: + 1. A tPeriodDetection stage for coarse, low frequency estimates + 2. A tPitchDetector stage for refined, high frequency and harmonic tracking + It then adjusts both estimates by averaging and applies hysteresis and periodicity thresholding to produce a stable pitch + + Example + @code{.c} + //initialize + tDualPitchDetector* dpd = NULL; + tDualPitchDetector_init(&dpd, + 50.0f, //lowest frequency + 2000.0f, //highest frequency + inputBuf, + bufSize, + leaf); + + //audio loop + for (int i = 0; i < numSamples; ++i){ + int ready = tDualPitchDetector_tick(dpd, inputSample[i]); + if (ready){ + float freq = tDualPitchDetector_getFrequency(dpd); + float conf = tDualPitchDetector_getPeriodicity(dpd); + ... + } + } + + //tweak parameters + tDualPitchDetector_setHysteresis(dpd, -40.0f); // hysteresis in dB + tDualPitchDetector_setPeriodicityThreshold(dpd, 0.9f);// minimum periodicity + tDualPitchDetector_setSampleRate(dpd, sampleRate); // update sample rate + + //when done + tDualPitchDetector_free(&dpd); + @endcode @fn void tDualPitchDetector_init(tDualPitchDetector** const detector, Lfloat lowestFreq, Lfloat highestFreq, Lfloat* inBuffer, int bufSize, LEAF* const leaf) @brief Initialize a tDualPitchDetector to the default mempool of a LEAF instance. From 5f5e88c1d4f482355bef842ddb435ad56064fec7 Mon Sep 17 00:00:00 2001 From: seanxue Date: Tue, 15 Jul 2025 15:56:52 -0400 Subject: [PATCH 06/14] examples and notation for leaf-delay.h --- leaf/Inc/leaf-delay.h | 431 +++++++++++++++++++++++++++++------------- 1 file changed, 299 insertions(+), 132 deletions(-) diff --git a/leaf/Inc/leaf-delay.h b/leaf/Inc/leaf-delay.h index 17c0420..5b102f3 100644 --- a/leaf/Inc/leaf-delay.h +++ b/leaf/Inc/leaf-delay.h @@ -32,90 +32,120 @@ extern "C" { @defgroup tdelay tDelay @ingroup delay @brief Non-interpolating delay, reimplemented from STK (Cook and Scavone). - @{ - + + The tDelay object implements a simple, fixed-length delay line: + 1. Allocates a buffer of length `maxDelay` samples. + 2. Maintains separate read/write pointers (`inPoint`/`outPoint`). + 3. On each tick, writes the new sample into the buffer at `inPoint`, advances both pointers modulo the buffer length, and returns the delayed output from `outPoint`. + + Example + @code{.c} + //initialize + tDelay* delay = NULL; + tDelay_init(&delay, + 480, // initial delay length in samples + 1024, // maximum delay length + leaf); + + //audio loop: + float input = getNextSample(); + float out = tDelay_tick(delay, input); // write+read one sample + //tweak delay parameter + tDelay_setDelay(delay, 240); //!< now 240-sample delay + // read a tap without advancing pointers: + float tapVal = tDelay_tapOut(delay, 120); // value 120 samples ago + // add feedback into a tap: + float fb = 0.5f * tDelay_tapOut(delay, 480); + tDelay_addTo(delay, fb, 480); + // reset the buffer to silence: + tDelay_clear(delay); + + // when done: + tDelay_free(&delay); + @endcode + @fn void tDelay_init(tDelay** const, uint32_t delay, uint32_t maxDelay, LEAF* const leaf) @brief Initialize a tDelay to the default mempool of a LEAF instance. @param delay A pointer to the tDelay to initialize. @param initalLength @param maxLength @param leaf A pointer to the leaf instance. - + @fn void tDelay_initToPool(tDelay** const, uint32_t delay, uint32_t maxDelay, tMempool** const) @brief Initialize a tDelay to a specified mempool. @param delay A pointer to the tDelay to initialize. @param initalLength @param maxLength @param mempool A pointer to the tMempool to use. - + @fn void tDelay_free(tDelay** const) @brief Free a tDelay from its mempool. @param delay A pointer to the tDelay to free. - + @fn void tDelay_clear (tDelay* const) @brief @param delay A pointer to the relevant tDelay. - + @fn void tDelay_setDelay (tDelay* const, uint32_t delay) @brief @param delay A pointer to the relevant tDelay. @param delayLength The new delay length in samples. Cannot be greater than the max delay length given on initialization. - + @fn uint32_t tDelay_getDelay (tDelay* const) @brief @param delay A pointer to the relevant tDelay. @return The current delay length. - + @fn void tDelay_tapIn (tDelay* const, Lfloat in, uint32_t tapDelay) @brief @param delay A pointer to the relevant tDelay. @param input @param position - + @fn Lfloat tDelay_tapOut (tDelay* const, uint32_t tapDelay) @brief @param delay A pointer to the relevant tDelay. @param position @return - + @fn Lfloat tDelay_addTo (tDelay* const, Lfloat value, uint32_t tapDelay) @brief @param delay A pointer to the relevant tDelay. @param input @param position @return - + @fn Lfloat tDelay_tick (tDelay* const, Lfloat sample) @brief @param delay A pointer to the relevant tDelay. @param input @return - + @fn Lfloat tDelay_getLastOut (tDelay* const) @brief @param delay A pointer to the relevant tDelay. @return - + @fn Lfloat tDelay_getLastIn (tDelay* const) @brief @param delay A pointer to the relevant tDelay. @return  @} */ - + typedef struct tDelay { tMempool* mempool; - + Lfloat gain; Lfloat* buff; - + Lfloat lastOut, lastIn; - + uint32_t inPoint, outPoint; - + uint32_t delay, maxDelay; - + } tDelay; void tDelay_init (tDelay** const, uint32_t delay, uint32_t maxDelay, LEAF* const leaf); @@ -132,111 +162,135 @@ extern "C" { Lfloat tDelay_addTo (tDelay* const, Lfloat value, uint32_t tapDelay); Lfloat tDelay_getLastOut (tDelay* const); Lfloat tDelay_getLastIn (tDelay* const); - + //============================================================================== - + /*! @defgroup tlineardelay tLinearDelay @ingroup delay @brief Linearly-interpolating delay, reimplemented from STK (Cook and Scavone). - @{ - + + The tLinearDelay object maintains a buffer of length 'maxDelay' and uses linear interpolation between samples when reading the delayed output + + Example + @code{.c} + //initialize + tLinearDelay* ld = NULL; + tLinearDelay_init(&ld, + 480.5f, // initial delay length in samples (fractional) + 1024, // maximum delay length in samples + leaf); + + //audio loop + float in = getNextSample(); + float out = tLinearDelay_tick(ld, in); + //tweak delay length + tLinearDelay_setDelay(ld, 240.25f); + // read a tap without advancing pointers: + float tap = tLinearDelay_tapOut(ld, 120.75f); + // reset the buffer to silence: + tLinearDelay_clear(ld); + + // when done: + tLinearDelay_free(&ld); + @endcode + @fn void tLinearDelay_init(tLinearDelay** const, Lfloat delay, uint32_t maxDelay, LEAF* const leaf) @brief Initialize a tLinearDelay to the default mempool of a LEAF instance. @param delay A pointer to the tLinearDelay to initialize. @param initialLength @param maxLength @param leaf A pointer to the leaf instance. - + @fn void tLinearDelay_initToPool(tLinearDelay** const, Lfloat delay, uint32_t maxDelay, tMempool** const) @brief Initialize a tLinearDelay to a specified mempool. @param delay A pointer to the tLinearDelay to initialize. @param initialLength @param maxLength @param mempool A pointer to the tMempool to use. - + @fn void tLinearDelay_free(tLinearDelay** const) @brief Free a tLinearDelay from its mempool. @param delay A pointer to the tLinearDelay to free. - + @fn void tLinearDelay_clear (tLinearDelay* const dl) @brief @param delay A pointer to the relevant tLinearDelay. - + @fn void tLinearDelay_setDelay (tLinearDelay* const, Lfloat delay) @brief @param delay A pointer to the relevant tLinearDelay. @param delayLength The new delay length in samples. Cannot be greater than the max delay length given on initialization. - + @fn Lfloat tLinearDelay_getDelay (tLinearDelay* const) @brief @param delay A pointer to the relevant tLinearDelay. @return - + @fn void tLinearDelay_tapIn (tLinearDelay* const, Lfloat in, uint32_t tapDelay) @brief @param delay A pointer to the relevant tLinearDelay. @param input @param position - + @fn Lfloat tLinearDelay_tapOut (tLinearDelay* const, uint32_t tapDelay) @brief @param delay A pointer to the relevant tLinearDelay. @param position @return - + @fn Lfloat tLinearDelay_addTo (tLinearDelay* const, Lfloat value, uint32_t tapDelay) @brief @param delay A pointer to the relevant tLinearDelay. @param input @param position @return - + @fn Lfloat tLinearDelay_tick (tLinearDelay* const, Lfloat sample) @brief @param delay A pointer to the relevant tLinearDelay. @param input @return - + @fn void tLinearDelay_tickIn (tLinearDelay* const, Lfloat input) @brief @param delay A pointer to the relevant tLinearDelay. @param input - + @fn Lfloat tLinearDelay_tickOut (tLinearDelay* const) @brief @param delay A pointer to the relevant tLinearDelay. @return - + @fn Lfloat tLinearDelay_getLastOut (tLinearDelay* const) @brief @param delay A pointer to the relevant tLinearDelay. @return - + @fn Lfloat tLinearDelay_getLastIn (tLinearDelay* const) @brief @param delay A pointer to the relevant tLinearDelay. @return  @} */ - + typedef struct tLinearDelay { tMempool* mempool; - + Lfloat gain; Lfloat* buff; - + Lfloat lastOut, lastIn; - + uint32_t inPoint, outPoint; - + uint32_t maxDelay; - + Lfloat delay; - + Lfloat alpha, omAlpha; - + } tLinearDelay; void tLinearDelay_init (tLinearDelay** const, Lfloat delay, uint32_t maxDelay, LEAF* const leaf); @@ -256,127 +310,156 @@ extern "C" { Lfloat tLinearDelay_addTo (tLinearDelay* const, Lfloat value, uint32_t tapDelay); Lfloat tLinearDelay_getLastOut (tLinearDelay* const); Lfloat tLinearDelay_getLastIn (tLinearDelay* const); - - - + + + //============================================================================== - + /*! @defgroup thermitedelay tHermiteDelay @ingroup delay @brief Hermite-interpolating delay, created by adapting STK linear delay with Hermite interpolation. - @{ - + + The HermiteDelay maintains a circular buffer of up to `maxDelay` samples and + uses cubic interpolation to produce smooth fractional delays + 1. Four neighboring samples around the desired fractional read index are fetched + 2. A Hermite polynomial is evaluated to interpolate between them + 3. The write pointer advances each sample and the read pointer follows the current fractional delay + + Example + @code{.c} + //initialize + tHermiteDelay* hd = NULL; + tHermiteDelay_init(&hd, + 480.5f, // initial delay length in samples (fractional) + 1024, // maximum delay length in samples + leaf); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float out = tHermiteDelay_tick(hd, inputSamples[i]); + ... + } + + //tweak delay length + tHermiteDelay_setDelay(hd, 240.25f); + // reset the delay buffer to silence + tHermiteDelay_clear(hd); + + //when done + tHermiteDelay_free(&hd); + @endcode + @fn void tHermiteDelay_init(tHermiteDelay** const dl, Lfloat delay, uint32_t maxDelay, LEAF* const leaf) @brief Initialize a tHermiteDelay to the default mempool of a LEAF instance. @param delay A pointer to the tHermiteDelay to initialize. @param initialLength @param maxLength @param leaf A pointer to the leaf instance. - + @fn void tHermiteDelay_initToPool(tHermiteDelay** const dl, Lfloat delay, uint32_t maxDelay, tMempool** const mp) @brief Initialize a tHermiteDelay to a specified mempool. @param delay A pointer to the tHermiteDelay to initialize. @param initialLength @param maxLength @param mempool A pointer to the tMempool to use. - + @fn void tHermiteDelay_free(tHermiteDelay** const dl) @brief Free a tHermiteDelay from its mempool. @param delay A pointer to the tHermiteDelay to free. - + @fn void tHermiteDelay_clear (tHermiteDelay* const dl) @brief @param delay A pointer to the relevant tHermiteDelay. - + @fn Lfloat tHermiteDelay_tick (tHermiteDelay* const dl, Lfloat input) @brief @param delay A pointer to the relevant tHermiteDelay. @param input @return - + @fn void tHermiteDelay_tickIn (tHermiteDelay* const dl, Lfloat input) @brief @param delay A pointer to the relevant tHermiteDelay. @param input - + @fn Lfloat tHermiteDelay_tickOut (tHermiteDelay* const dl) @brief @param delay A pointer to the relevant tHermiteDelay. @return - + @fn void tHermiteDelay_setDelay (tHermiteDelay* const dl, Lfloat delay) @brief @param delay A pointer to the relevant tHermiteDelay. @param delayLength The new delay length in samples. Cannot be greater than the max delay length given on initialization. - + @fn Lfloat tHermiteDelay_tapOut (tHermiteDelay* const dl, uint32_t tapDelay) @brief @param delay A pointer to the relevant tHermiteDelay. @param position @return - + @fn Lfloat tHermiteDelay_tapOutInterpolated (tHermiteDelay* const dl, uint32_t tapDelay, Lfloat alpha); @brief @param delay A pointer to the relevant tHermiteDelay. @param integer position @param fractional portion of the position @return - + @fn void tHermiteDelay_tapIn (tHermiteDelay* const dl, Lfloat value, uint32_t tapDelay) @brief @param delay A pointer to the relevant tHermiteDelay. @param input @param position - + @fn Lfloat tHermiteDelay_addTo (tHermiteDelay* const dl, Lfloat value, uint32_t tapDelay) @brief @param delay A pointer to the relevant tHermiteDelay. @param input @param position @return - + @fn Lfloat tHermiteDelay_getDelay (tHermiteDelay* const dl) @brief @param delay A pointer to the relevant tHermiteDelay. @return - + @fn Lfloat tHermiteDelay_getLastOut (tHermiteDelay* const dl) @brief @param delay A pointer to the relevant tHermiteDelay. @return - + @fn Lfloat tHermiteDelay_getLastIn (tHermiteDelay* const dl) @brief @param delay A pointer to the relevant tHermiteDelay. @return - + @fn void tHermiteDelay_setGain (tHermiteDelay* const dl, Lfloat gain) @brief @param delay A pointer to the relevant tHermiteDelay. @param gain - + @fn Lfloat tHermiteDelay_getGain (tHermiteDelay* const dl) @brief @param delay A pointer to the relevant tHermiteDelay. @return  @} */ - + typedef struct tHermiteDelay { tMempool* mempool; - + Lfloat* buff; uint32_t bufferMask; Lfloat lastOut, lastIn; - + uint32_t inPoint, outPoint; - + uint32_t maxDelay; Lfloat gain; Lfloat delay; - + Lfloat alpha, omAlpha; } tHermiteDelay; @@ -399,10 +482,10 @@ extern "C" { Lfloat tHermiteDelay_getLastIn (tHermiteDelay* const dl); void tHermiteDelay_setGain (tHermiteDelay* const dl, Lfloat gain); Lfloat tHermiteDelay_getGain (tHermiteDelay* const dl); - - + + //============================================================================== - + //============================================================================== /*! @@ -543,96 +626,123 @@ extern "C" { @defgroup tallpassdelay tAllpassDelay @ingroup delay @brief Allpass-interpolating delay, reimplemented from STK (Cook and Scavone). - @{ - + + The AllpassDelay uses a first‐order allpass filter in a circular buffer: + 1. Writes each input sample into the buffer at the write pointer + 2. Advances the write pointer modulo 'maxDelay' + 3. Computes the fractional read index based on the desired delay + 4. Reads two adjacent samples and applies an allpass interpolation coefficient to produce a smooth output + 5. Stores the last input/output for feedback and tap operations + + Example + @code{.c} + //initialize + tAllpassDelay* ap = NULL; + tAllpassDelay_init(&ap, + 480.5f, // initial delay length (fractional samples) + 1024, // maximum allowed delay length + leaf); + + //audio loop + float in = getNextSample(); + float out = tAllpassDelay_tick(ap, in); + //tweak delay length + tAllpassDelay_setDelay(ap, 240.25f); + // clear the delay buffer: + tAllpassDelay_clear(ap); + + //when done + tAllpassDelay_free(&ap); + @endcode + @fn void tAllpassDelay_init(tAllpassDelay** const, Lfloat delay, uint32_t maxDelay, LEAF* const leaf) @brief Initialize a tAllpassDelay to the default mempool of a LEAF instance. @param delay A pointer to the tAllpassDelay to initialize. @param initialLength @param maxLength @param leaf A pointer to the leaf instance. - + @fn void tAllpassDelay_initToPool(tAllpassDelay** const, Lfloat delay, uint32_t maxDelay, tMempool** const) @brief Initialize a tAllpassDelay to a specified mempool. @param delay A pointer to the tAllpassDelay to initialize. @param initialLength @param maxLength @param mempool A pointer to the tMempool to use. - + @fn void tAllpassDelay_free(tAllpassDelay** const) @brief Free a tAllpassDelay from its mempool. @param delay A pointer to the tAllpassDelay to free. - + @fn void tAllpassDelay_clear (tAllpassDelay* const) @brief @param delay A pointer to the relevant tAllpassDelay. - + @fn void tAllpassDelay_setDelay (tAllpassDelay* const, Lfloat delay) @brief @param delay A pointer to the relevant tAllpassDelay. @param delayLength The new delay length in samples. Cannot be greater than the max delay length given on initialization. - + @fn Lfloat tAllpassDelay_getDelay (tAllpassDelay* const) @brief @param delay A pointer to the relevant tAllpassDelay. @return The current delay length in samples. - + @fn void tAllpassDelay_tapIn (tAllpassDelay* const, Lfloat in, uint32_t tapDelay) @brief @param delay A pointer to the relevant tAllpassDelay. @param inptu @param position - + @fn Lfloat tAllpassDelay_tapOut (tAllpassDelay* const, uint32_t tapDelay) @brief @param delay A pointer to the relevant tAllpassDelay. @param position @return - + @fn Lfloat tAllpassDelay_addTo (tAllpassDelay* const, Lfloat value, uint32_t tapDelay) @brief @param delay A pointer to the relevant tAllpassDelay. @param input @param position @return - + @fn Lfloat tAllpassDelay_tick (tAllpassDelay* const, Lfloat sample) @brief @param delay A pointer to the relevant tAllpassDelay. @param input @return - + @fn Lfloat tAllpassDelay_getLastOut (tAllpassDelay* const) @brief @param delay A pointer to the relevant tAllpassDelay. @return - + @fn Lfloat tAllpassDelay_getLastIn (tAllpassDelay* const) @brief @param delay A pointer to the relevant tAllpassDelay. @return  @} */ - + typedef struct tAllpassDelay { tMempool* mempool; - + Lfloat gain; Lfloat* buff; - + Lfloat lastOut, lastIn; - + uint32_t inPoint, outPoint; - + uint32_t maxDelay; - + Lfloat delay; - + Lfloat alpha, omAlpha, coeff; - + Lfloat apInput; - + } tAllpassDelay; void tAllpassDelay_init (tAllpassDelay** const, Lfloat delay, uint32_t maxDelay, LEAF* const leaf); @@ -649,105 +759,141 @@ extern "C" { Lfloat tAllpassDelay_addTo (tAllpassDelay* const, Lfloat value, uint32_t tapDelay); Lfloat tAllpassDelay_getLastOut (tAllpassDelay* const); Lfloat tAllpassDelay_getLastIn (tAllpassDelay* const); - + //============================================================================== - + /*! @defgroup ttapedelay tTapeDelay @ingroup delay @brief Linear interpolating delay with fixed read and write pointers, variable rate. - @{ - + + The Tape Delay implements a simple delay line where: + 1. New samples are written at a fixed write pointer (`inPoint`) + 2. A separate read index (`idx`) advances by `inc` each tick, allowing for variable-speed “tape” playback + 3. The output is linearly interpolated between the two nearest buffer samples + + Example + @code{.c} + //initialize + tTapeDelay* td = NULL; + tTapeDelay_init(&td, + 480.0f, // delay length in samples (fractional) + 2048, // maximum buffer size + leaf); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float in = inputSamples[i]; + float out = tTapeDelay_tick(td, in); + outputSamples[i] = out; + } + + //tweak delay length + tTapeDelay_setDelay(td, 240.5f); + + // manually advance the write pointer + tTapeDelay_incrementInPoint(td); + + // read a past sample without advancing pointers + float tap = tTapeDelay_tapOut(td, 120.25f); + + // reset the delay to silence + tTapeDelay_clear(td); + + //when done + tTapeDelay_free(&td); + @endcode + @fn void tTapeDelay_init(tTapeDelay** const, Lfloat delay, uint32_t maxDelay, LEAF* const leaf) @brief Initialize a tTapeDelay to the default mempool of a LEAF instance. @param delay A pointer to the tTapeDelay to initialize. @param initialLength @param maxLength @param leaf A pointer to the leaf instance. - + @fn void tTapeDelay_initToPool(tTapeDelay** const, Lfloat delay, uint32_t maxDelay, tMempool** const) @brief Initialize a tTapeDelay to a specified mempool. @param delay A pointer to the tTapeDelay to initialize. @param initialLength @param maxLength @param mempool A pointer to the tMempool to use. - + @fn void tTapeDelay_free(tTapeDelay** const) @brief Free a tTapeDelay from its mempool. @param delay A pointer to the tTapeDelay to free. - + @fn void tTapeDelay_clear (tTapeDelay* const) - @brief + @brief @param delay A pointer to the relevant tTapeDelay. - + @fn void tTapeDelay_setDelay (tTapeDelay* const, Lfloat delay) @brief @param delay A pointer to the relevant tTapeDelay. @param delayLength The new delay length in samples. Cannot be greater than the max delay length given on initialization. - + @fn Lfloat tTapeDelay_getDelay (tTapeDelay* const) @brief @param delay A pointer to the relevant tTapeDelay. @return - + @fn void tTapeDelay_tapIn (tTapeDelay* const, Lfloat in, uint32_t tapDelay) @brief @param delay A pointer to the relevant tTapeDelay. @param input @param position - + @fn Lfloat tTapeDelay_tapOut (tTapeDelay* const d, Lfloat tapDelay) @brief @param delay A pointer to the relevant tTapeDelay. @param position @return - + @fn Lfloat tTapeDelay_addTo (tTapeDelay* const, Lfloat value, uint32_t tapDelay) @brief @param delay A pointer to the relevant tTapeDelay. @param input @param position @return - + @fn Lfloat tTapeDelay_tick (tTapeDelay* const, Lfloat sample) @brief @param delay A pointer to the relevant tTapeDelay. @param input @return - + @fn void tTapeDelay_incrementInPoint(tTapeDelay* const dl) @brief @param delay A pointer to the relevant tTapeDelay. - + @fn Lfloat tTapeDelay_getLastOut (tTapeDelay* const) @brief @param delay A pointer to the relevant tTapeDelay. @return - + @fn Lfloat tTapeDelay_getLastIn (tTapeDelay* const) @brief @param delay A pointer to the relevant tTapeDelay. @return  @} */ - + typedef struct tTapeDelay { tMempool* mempool; - + Lfloat gain; Lfloat* buff; - + Lfloat lastOut, lastIn; - + uint32_t inPoint; - + uint32_t maxDelay; - + Lfloat delay, inc, idx; - + Lfloat apInput; - + } tTapeDelay; void tTapeDelay_init (tTapeDelay** const, Lfloat delay, uint32_t maxDelay, LEAF* const leaf); @@ -765,46 +911,67 @@ extern "C" { void tTapeDelay_incrementInPoint (tTapeDelay* const dl); Lfloat tTapeDelay_getLastOut (tTapeDelay* const); Lfloat tTapeDelay_getLastIn (tTapeDelay* const); - + //============================================================================== - + /*! @defgroup tringbuffer tRingBuffer @ingroup delay @brief Ring buffer. - @{ - + + The RingBuffer automatically rounds the requested size up to the next power of two, + then provides a simple FIFO interface + + Example + @code{.c} + //initialize + tRingBuffer* rb = NULL; + tRingBuffer_init(&rb, 5, leaf); + + // push twelve values (0–11); oldest values get overwritten + for (int i = 0; i < 12; ++i) + tRingBuffer_push(rb, (float)i); + + float newest = tRingBuffer_getNewest(rb); + float oldest = tRingBuffer_getOldest(rb); + float val = tRingBuffer_get(rb, 3); + int cap = tRingBuffer_getSize(rb); + + //when done + tRingBuffer_free(&rb); + @endcode + @fn void tRingBuffer_init(tRingBuffer** const ring, int size, LEAF* const leaf) @brief Initialize a tRingBuffer to the default mempool of a LEAF instance. @param buffer A pointer to the tRingbuffer to initialize. @param size Size of the buffer. Should be a power of 2. Will otherwise be adjusted to the nearest greater power of 2. @param leaf A pointer to the leaf instance. - + @fn void tRingBuffer_initToPool(tRingBuffer** const ring, int size, tMempool** const mempool) @brief Initialize a tRingBuffer to a specified mempool. @param buffer A pointer to the tRingbuffer to initialize. @param size Size of the buffer. Should be a power of 2. Will otherwise be adjusted to the nearest greater power of 2. @param mempool A pointer to the tMempool to use. - + @fn void tRingBuffer_free(tRingBuffer** const ring) @brief Free a tRingBuffer from its mempool. @param buffer A pointer to the tRingBuffer to free. - + @fn void tRingBuffer_push (tRingBuffer* const ring, Lfloat val) @brief Push a value to the ring buffer, overwriting the oldest value if the buffer is full. @param buffer A pointer to the relevant tRingBuffer. @param input The value to push to the buffer. - + @fn Lfloat tRingBuffer_getNewest (tRingBuffer* const ring) @brief Get the newest value in the ring buffer. @param buffer A pointer to the relevant tRingBuffer. @return The newest value in the ring buffer. - + @fn Lfloat tRingBuffer_getOldest (tRingBuffer* const ring) @brief Get the oldest value in the ring buffer. @param buffer A pointer to the relevant tRingBuffer. @return The oldest value in the ring buffer. - + @fn Lfloat tRingBuffer_get (tRingBuffer* const ring, int index) @brief Get the value at an index of the buffer. @param buffer A pointer to the relevant tRingBuffer. @@ -821,7 +988,7 @@ extern "C" { { tMempool* mempool; - + Lfloat* buffer; unsigned int size; unsigned int pos; From 114b37489ccbad00eb35fc764f3d560d66ba9aa0 Mon Sep 17 00:00:00 2001 From: seanxue Date: Tue, 15 Jul 2025 16:03:03 -0400 Subject: [PATCH 07/14] examples and notation for leaf-distortion.h --- leaf/Inc/leaf-distortion.h | 122 +++++++++++++++++++++++++++++++++++-- 1 file changed, 117 insertions(+), 5 deletions(-) diff --git a/leaf/Inc/leaf-distortion.h b/leaf/Inc/leaf-distortion.h index bd0bc91..5ff0036 100644 --- a/leaf/Inc/leaf-distortion.h +++ b/leaf/Inc/leaf-distortion.h @@ -34,7 +34,31 @@ extern "C" { @defgroup tsamplereducer tSampleReducer @ingroup distortion @brief Sample rate reducer. - @{ + + The SampleReducer outputs each incoming sample and then “holds” it for a number of subsequent calls + determined by the reduction ratio (0.0–1.0): + A ratio of 1.0 means no reduction (pass-through) + A ratio of 0.5 outputs the new input only every two calls, holding the previous value in between + Lower ratios produce more aggressive sample-rate reduction and the bitcrush effect + + Example + @code{.c} + // initialize + tSampleReducer* sr = NULL; + tSampleReducer_init(&sr, leaf); + + // set when to output new sample by calls + tSampleReducer_setRatio(sr, 0.25f); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float out = tSampleReducer_tick(sr, inputSamples[i]); + outputSamples[i] = out; + } + + //when done + tSampleReducer_free(&sr); + @endcode @fn void tSampleReducer_init(tSampleReducer** const, LEAF* const leaf) @brief Initialize a tSampleReducer to the default mempool of a LEAF instance. @@ -81,7 +105,36 @@ extern "C" { @defgroup toversampler tOversampler @ingroup distortion @brief Oversampler. - @{ + + The Oversampler upsamples each input sample by integer `ratio`, + applies a user‐supplied effect at the higher rate, then downsamples back to the + original rate. This reduces aliasing and improves quality for nonlinear processing + + Example + @code{.c} + //initialize + tOversampler* os = NULL; + tOversampler_init(&os, + 8, // filter order (taps per phase) + 1, // extraQuality flag + leaf); + + //set oversampling + tOversampler_setRatio(os, 4); + + //audio loop + float oversampleBuf[4]; + for (int i = 0; i < numSamples; ++i) { + float out = tOversampler_tick(os, + inputSamples[i], + oversampleBuf, + myDistortion); + outputSamples[i] = out; + } + + //when done + tOversampler_free(&os); + @endcode @fn void tOversampler_init(tOversampler** const, int order, int extraQuality, LEAF* const leaf) @brief Initialize a tOversampler to the default mempool of a LEAF instance. @@ -151,7 +204,30 @@ extern "C" { @defgroup tWavefolder tWavefolder @ingroup distortion @brief more efficient and simpler wavefolder. - @{ + + Example +@code{.c} +//initialize +tWavefolder* wf = NULL; +tWavefolder_init(&wf, + 1.0f, // feed-forward gain + 0.5f, // feedback gain + 0.8f, // fold depth limit + leaf); + +//audio loop +for (int i = 0; i < numSamples; ++i) { + float out = tWavefolder_tick(wf, inputSamples[i]); + outputSamples[i] = out; +} + +//tweak parameters +tWavefolder_setGain(wf, 2.0f); +tWavefolder_setOffset(wf, 0.1f); + +//when done +tWavefolder_free(&wf); +@endcode @fn void tWavefolder_init(tWavefolder** const, LEAF* const leaf) @brief Initialize a tWavefolder to the default mempool of a LEAF instance. @@ -207,7 +283,22 @@ void tWavefolder_setGain (tWavefolder* const wf, Lfloat gain); @defgroup tlockhartwavefolder tLockhartWavefolder @ingroup distortion @brief Analog model wavefolder. - @{ + + Example + @code{.c} + // initialize + tLockhartWavefolder* lfw = NULL; + tLockhartWavefolder_init(&lfw, leaf); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float out = tLockhartWavefolder_tick(lfw, inputSamples[i]); + outputSamples[i] = out; + } + + //when done + tLockhartWavefolder_free(&lfw); + @endcode @fn void tLockhartWavefolder_init(tLockhartWavefolder** const, LEAF* const leaf) @brief Initialize a tLockhartWavefolder to the default mempool of a LEAF instance. @@ -273,7 +364,28 @@ void tWavefolder_setGain (tWavefolder* const wf, Lfloat gain); @defgroup tcrusher tCrusher @ingroup distortion @brief Bit depth and sampler rate degrader. - @{ + + Example + @code{.c} + // initialize + tCrusher* cb = NULL; + tCrusher_init(&cb, leaf); + + // configure bitcrush + tCrusher_setOperation(cb, 4.0f); + tCrusher_setQuality(cb, 0.5f); + tCrusher_setRound(cb, 0.1f); + tCrusher_setSamplingRatio(cb, 0.25f); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float out = tCrusher_tick(cb, inputSamples[i]); + outputSamples[i] = out; + } + + //when done + tCrusher_free(&cb); + @endcode @fn void tCrusher_init(tCrusher** const, LEAF* const leaf) @brief Initialize a tCrusher to the default mempool of a LEAF instance. From fd429ef8e1118afbb70e82f3e133ca9a7e7631c1 Mon Sep 17 00:00:00 2001 From: seanxue Date: Tue, 15 Jul 2025 16:11:29 -0400 Subject: [PATCH 08/14] examples and notation for leaf-dynamics.h --- leaf/Inc/leaf-dynamics.h | 111 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 106 insertions(+), 5 deletions(-) diff --git a/leaf/Inc/leaf-dynamics.h b/leaf/Inc/leaf-dynamics.h index f1049ab..c2f5d50 100644 --- a/leaf/Inc/leaf-dynamics.h +++ b/leaf/Inc/leaf-dynamics.h @@ -35,8 +35,43 @@ extern "C" { @defgroup tcompressor tCompressor @ingroup dynamics @brief Standard compressor. - @{ - + + Example + @code{.c} + //initialize + tCompressor* comp = NULL; + tCompressor_init(&comp, leaf); + + //configure parameters + tCompressor_setParams(comp, + -12.0f, //threshold (dB) + 4.0f, //compression ratio + 6.0f, //knee width (dB) + 3.0f, //makeup gain (dB) + 0.010f, //attack time (s) + 0.100f); //release time (s) + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float in = inputSamples[i]; + // tick processes the sample and applies compression + float out = tCompressor_tick(comp, in); + outputSamples[i] = out; + } + + //tweak parameters + tCompressor_setParams(comp, + -6.0f, //new threshold + 4.0f, + 6.0f, + 3.0f, + 0.010f, + 0.100f); + + //when done + tCompressor_free(&comp); + @endcode + @fn void tCompressor_init(tCompressor** const, LEAF* const leaf) @brief Initialize a tCompressor to the default mempool of a LEAF instance. @param compressor A pointer to the tCompressor to initialize. @@ -99,8 +134,44 @@ extern "C" { @ingroup dynamics @brief An auto VCA that you put into a feedback circuit to make it stay at the same level. @details An auto VCA that you put into a feedback circuit to make it stay at the same level. It can enforce level bidirectionally (amplifying and attenuating as needed) or just attenutating. The former option allows for infinite sustain strings, for example, while the latter option allows for decaying strings, which can never exceed a specific level. - @{ - + + Example + @code{.c} + //initialize + tFeedbackLeveler* fl = NULL; + tFeedbackLeveler_init(&fl, + 0.1f, //targetLevel (linear scale) + 1.0f, //factor for smoothing + 0.5f, //strength of correction + 1, //mode: 0 = attenuate only, 1 = bidirectional + leaf); + + //audio loop + float fbBuffer[1024] = {0}; + int idx = 0; + + for (int n = 0; n < totalSamples; ++n) { + float input = inputSamples[n]; + // apply leveler before feeding back + float leveled = tFeedbackLeveler_tick(fl, fbBuffer[idx]); + //mix leveled feedback with new input + float out = input + leveled; + outputSamples[n] = out; + //write back into circular feedback buffer + fbBuffer[idx] = out; + idx = (idx + 1) & 1023; + } + + //monitor current gain applied + float currentGain = tFeedbackLeveler_sample(fl); + + //tweak target level + tFeedbackLeveler_setTargetLevel(fl, 0.2f); + + //when done + tFeedbackLeveler_free(&fl); + @endcode + @fn void tFeedbackLeveler_init(tFeedbackLeveler** const, Lfloat targetLevel, Lfloat factor, Lfloat strength, int mode, LEAF* const leaf) @brief Initialize a tFeedbackLeveler to the default mempool of a LEAF instance. @param leveler A pointer to the tFeedbackLeveler to initialize. @@ -173,7 +244,37 @@ extern "C" { @defgroup tthreshold tThreshold @ingroup dynamics @brief Threshold with hysteresis (like Max/MSP thresh~ object) - @{ + + Example + @code{.c} + //initialize + tThreshold* th = NULL; + tThreshold_init(&th, + 0.2f, //low threshold + 0.8f, //high threshold + leaf); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float in = inputSamples[i]; + int state = tThreshold_tick(th, in); + if (state) { + //above hysteresis upper bound + outputSamples[i] = 1.0f; + } else { + //below hysteresis lower bound + outputSamples[i] = 0.0f; + } + } + + //tweak parameters + tThreshold_setLow(th, 0.3f); + tThreshold_setHigh(th, 0.7f); + + //when done + tThreshold_free(&th); + @endcode + @fn void tThreshold_init(tThreshold** const, Lfloat low, Lfloat high, LEAF* const leaf) @brief Initialize a tThreshold to the default mempool of a LEAF instance. From 6e6d3d3c040f019e9f1883d8bba1889e720478f4 Mon Sep 17 00:00:00 2001 From: seanxue Date: Tue, 15 Jul 2025 18:08:42 -0400 Subject: [PATCH 09/14] examples and notation for leaf-effects.h --- leaf/Inc/leaf-effects.h | 290 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 281 insertions(+), 9 deletions(-) diff --git a/leaf/Inc/leaf-effects.h b/leaf/Inc/leaf-effects.h index b13d19f..a02d7bd 100644 --- a/leaf/Inc/leaf-effects.h +++ b/leaf/Inc/leaf-effects.h @@ -28,7 +28,38 @@ extern "C" { @defgroup ttalkbox tTalkbox @ingroup effects @brief High resolution vocoder from mda using Levinson-Durbin LPC algorithm. - @{ + + The talkbox splits the input into carrier and modulator signals, computes LPC coefficients via the Levinson-Durbin algorithm on hte modulator, + and filters the carrier through that spectral envvelope to produce the "talking instrument" effect + + Example + @code{.c} + //initialize + tTalkbox* tb = NULL; + tTalkbox_init(&tb, + 1024, //analysis buffer size (samples) + leaf); + + //aydio loop + for (int i = 0; i < numSamples; ++i) { + float vocoded = tTalkbox_tick(tb, + synthSamples[i], // carrier input + voiceSamples[i]); //modulator input + outputSamples[i] = vocoded; + } + + // freeze the LPC envelope to hold a vowel tone + tTalkbox_setFreeze(tb, 1.0f); + + // change LPC warp factor for formant shifting + tTalkbox_setWarpFactor(tb, 0.8f); + + // resume live tracking + tTalkbox_setFreeze(tb, 0.0f); + + //when done + tTalkbox_free(&tb); + @endcode @fn void tTalkbox_init(tTalkbox** const, int bufsize, LEAF* const leaf) @brief Initialize a tTalkbox to the default mempool of a LEAF instance. @@ -148,7 +179,32 @@ extern "C" { @defgroup ttalkboxLfloat tTalkboxLfloat @ingroup effects @brief High resolution vocoder from mda using Levinson-Durbin LPC algorithm. - @{ + + Example + @code{.c} + tTalkboxLfloat* tb = NULL; + tTalkboxLfloat_init(&tb, + 1024, //analysis buffer size + leaf); + + //audio loop + for (int i = 0; i < numSamples; ++i){ + float out = tTalkboxLfloat_tick(tb, + synthSamples[i], + voiceSamples[i]); + outputSamples[i] = out; + } + + //freezing/resuming the envelope + tTalkboxLfloat_setFreeze(tb, 1); + tTalkboxLfloat_setFreeze(tb, 0); + + //shifting formats + tTalkboxLfloat_setWarpFactor(tb, 0.8f); + + //when done + tTalkboxLfloat_free(&tb); + @endcode @fn void tTalkboxLfloat_init(tTalkboxLfloat** const, int bufsize, LEAF* const leaf) @brief Initialize a tTalkboxLfloat to the default mempool of a LEAF instance. @@ -265,7 +321,33 @@ extern "C" { @defgroup tvocoder tVocoder @ingroup effects @brief Channel vocoder from mda. - @{ + + Example + @code{.c} + //initialize + tVocoder* voc = NULL; + tVocoder_init(&voc, leaf); + + // in your audio loop: + for (int i = 0; i < numSamples; ++i) { + float vocoded = tVocoder_tick(voc, + carrierSamples[i], //carrier input + voiceSamples[i]); //modulator input + outputSamples[i] = vocoded; + } + + // suspend envelope tracking (holds current filters) + tVocoder_suspend(voc); + + // resume live envelope updates: + tVocoder_update(voc); + + //adjust sample rate for correct band timing + tVocoder_setSampleRate(voc, sampleRate); + + //when done: + tVocoder_free(&voc); + @endcode @fn void tVocoder_init(tVocoder** const, LEAF* const leaf) @brief Initialize a tVocoder to the default mempool of a LEAF instance. @@ -333,7 +415,35 @@ extern "C" { @defgroup trosenbergglottalpulse tRosenbergGlottalPulse @ingroup effects @brief Rosenberg glottal pulse approximator. - @{ + + The Rosenberg glottal pulse produced a simplified glottal excitation model by: + 1. Advancing a phase accumulator at a user set frequency + 2. Generating an opening slope over the first 'openLength' part of the cycle + 3. Genearting a closing slope over the next 'pulseLength' portion + 4. Holding zero for the remainder of the cycle + + Example + @code{.c} + //initialize + tRosebBergGlottalPulse* gp = NULL; + tRosenbergPulse_init(&gp, leaf); + + //set frequency of glottal pulse + tRosenbergGlottalPulse_setFreq(gp, 120.0f); + //set opening and close of cycle + tRosenbergGlottalPulse_setOpenLengthAndPulseLength(gp, 0.5, 0.6f); + //set sample rate for correct timing + tRosenbergGlottalPulse_setSampleRate(gp, sampleRate); + + //audio loop + for (int i = 0; i < sampleRate; ++i){ + float pulse = tRosenbergGlottalPulse_tick(gp); + output[i] = pulse + } + + //when done + tRosenbergGlottalPulse_free(&gp); + @endcode @fn void tRosenbergGlottalPulse_init(tRosenbergGlottalPulse** const, LEAF* const leaf) @brief Initialize a tRosenbergGlottalPulse to the default mempool of a LEAF instance. @@ -407,7 +517,44 @@ extern "C" { @defgroup tsolad tSOLAD @ingroup effects @brief pitch shifting algorithm that underlies tRetune etc from Katja Vetters http://www.katjaas.nl/pitchshiftlowlatency/pitchshiftlowlatency.html - @{ + + The SOLAD algorithm performs real-time pitch shifting by + 1. Writing incoming blocks into a circular delay buffer (`loopSize` samples) + 2. Reading from the buffer with a lag adjusted by `pitchFactor` to change pitch + 3. Crossfading between successive read pointers over `xfadeLength` samples to avoid clicks + 4. Optionally using a periodicity estimate (`period`) and forced `readLag` to stabilize the shift + + Example + @code{.c} + //initialize + tSOLAD* solad = NULL; + tSOLAD_init(&solad, + 4096, //loopSize (power of two) + leaf); + + //2× speed-up (one octave up) + tSOLAD_setPitchFactor(solad, 2.0f); + //lock read lag for smoother output + tSOLAD_setReadLag(solad, 512.0f); + // provide an estimated period for transients (in samples) + tSOLAD_setPeriod(solad, 64.0f); + + const int blockSize = 128; + float inBlock[blockSize], outBlock[blockSize]; + while (hasAudio()) { + fillInput(inBlock, blockSize); + tSOLAD_ioSamples(solad, inBlock, outBlock, blockSize); + playOutput(outBlock, blockSize); + } + + // reset internal state if needed + tSOLAD_resetState(solad); + // update sample rate for internal filters + tSOLAD_setSampleRate(solad, sampleRate); + + //when done + tSOLAD_free(&solad); + @endcode @fn void tSOLAD_init(tSOLAD** const, LEAF* const leaf) @brief Initialize a tSOLAD to the default mempool of a LEAF instance. @@ -493,7 +640,39 @@ extern "C" { @defgroup tpitchshift tPitchShift @ingroup effects @brief SOLAD-based pitch shifter. - @{ + + The pitch shift combines a dual pitch detector to track the desired pitch shift factor, + and the SOLAD buffer to perform the time-domain shift + On each block or sample, you feed in audio and either specify a shift factory directly or + let the dual detector drive the factory automatically + + Example + @code{.c} + //initialize + tDualPitchDetector* dpd = NULL; + tDualPitchDetector_init(&dpd, 50.0f, 2000.0f, leaf); + + //create a PitchShift instance + tPitchShift* ps = NULL; + int bufSize = 1024; + tPitchShift_init(&ps, dpd, bufSize, leaf); + + //audio loop + float inBuf[bufSize], outBuf[bufSize]; + // fill inBuf... + tPitchShift_shiftBy(ps, 1.5f, inBuf, outBuf); // +50% pitch + + + //adjust pickiness (how strongly it follows the detector) + tPitchShift_setPickiness(ps, 0.8f); + + //set sample rate + tPitchShift_setSampleRate(ps, sampleRate); + + //when done: + tPitchShift_free(&ps); + tDualPitchDetector_free(&dpd); + @endcode @fn void tPitchShift_init(tPitchShift** const, tPeriodDetection* const, Lfloat* out, int bufSize, LEAF* const leaf) @brief Initialize a tPitchShift to the default mempool of a LEAF instance. @@ -557,7 +736,33 @@ extern "C" { @defgroup tsimpleretune tSimpleRetune @ingroup effects @brief Wrapper for multiple pitch shifters with single-channel output. - @{ + + The simple retune spawns `numVoices` independent SOLAD‐based pitch shifters, all driven by tDualPitchDetector + It mixes their outputs into one channel, allowing detune, chorusing, or harmonization with minimal setup + + Example + @code{.c} + // initialize + tSimpleRetune* tr = NULL; + tSimpleRetune_init(&tr, + 3, //number of voices + 100.0f, //minimum input frequency + 1000.0f, //maximum input frequency + 512, //buffer size + leaf); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float out = tSimpleRetune_tick(tr, inputSamples[i]); + outputSamples[i] = out; + } + + //adjust responsiveness + tSimpleRetune_setPickiness(tr, 0.7f); + + //when done + tSimpleRetune_free(&tr); + @endcode @fn void tSimpleRetune_init(tSimpleRetune** const, int numVoices, int bufSize, int frameSize, LEAF* const leaf) @brief Initialize a tSimpleRetune to the default mempool of a LEAF instance. @@ -630,7 +835,39 @@ extern "C" { @defgroup tretune tRetune @ingroup effects @brief Wrapper for multiple pitch shifters with multi-channel output. - @{ + + tRetune builds on SOLAD and dual‐detector pitch tracking to drive `numVoices` independent + pitch shifters, each producing its own channel. You can use it for chorus, harmonies, + or multi‐voice layering with minimal setup + + Example + @code{.c} + //initialize + tRetune* rt = NULL; + tRetune_init(&rt, + 4, //number of voices + 80.0f, //minimum input frequency + 1200.0f, //maximum input frequency + 512, //buffer size + leaf); + + //audio loop, + for (int i = 0; i < numSamples; ++i) { + Lfloat* outs = tRetune_tick(rt, inputSamples[i]); + for (int v = 0; v < 4; ++v) + outputBuffers[v][i] = outs[v]; + } + + //adjust number of voices + tRetune_setNumVoices(rt, 3); + + //set individual pitch factors + tRetune_setPitchFactor(rt, 1.5f, 0); //voice 0 up a fifth + tRetune_setPitchFactor(rt, 0.8f, 1); //voice 1 down a minor third + + //when done + tRetune_free(&rt); + @endcode @fn void tRetune_init(tRetune** const, int numVoices, int bufSize, int frameSize, LEAF* const leaf) @brief Initialize a tRetune to the default mempool of a LEAF instance. @@ -707,7 +944,42 @@ extern "C" { @defgroup tformantshifter tFormantShifter @ingroup effects @brief Formant remover and adder, allowing for formant shifting. - @{ + + The formant shifter analyzes the spectral envelope of incoming audio via LPC-like filters + and then either subtracts that envelope (removal) or reapplies it shifted by `shiftFactor` + (addition). An `intensity` control blends between dry and processed signals. + + Example + @code{.c} + //initialize + tFormantShifter* fs = NULL; + tFormantShifter_init(&fs, + 12, // filter order + leaf); + + // in your audio loop: + for (int i = 0; i < numSamples; ++i) { + float in = inputSamples[i]; + //remove formants for a robotic sound + float removed = tFormantShifter_remove(fs, in); + //add shifted formants (e.g. 1.2×): + tFormantShifter_setShiftFactor(fs, 1.2f); + float added = tFormantShifter_add(fs, in); + //mix dry and shifted + float out = fs->intensity * added + (1.0f - fs->intensity) * in; + outputSamples[i] = out; + } + + //for block processing with warp factor fwarp + float inBuf[256], outBuf[256]; + tFormantShifter_ioSamples(fs, inBuf, outBuf, 256, 0.8f); + + //adjust intensity of effect + tFormantShifter_setIntensity(fs, 0.75f); + + //when done + tFormantShifter_free(&fs); + @endcode @fn void tFormantShifter_init(tFormantShifter** const, int order, LEAF* const leaf) @brief Initialize a tFormantShifter to the default mempool of a LEAF instance. From eaebba9d8994a9e42c8fadf7a8b9fbbcdec5a23d Mon Sep 17 00:00:00 2001 From: seanxue Date: Tue, 15 Jul 2025 18:10:17 -0400 Subject: [PATCH 10/14] examples and notation for leaf-electrical.h --- leaf/Inc/leaf-electrical.h | 49 +++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/leaf/Inc/leaf-electrical.h b/leaf/Inc/leaf-electrical.h index cb5416a..28e2082 100644 --- a/leaf/Inc/leaf-electrical.h +++ b/leaf/Inc/leaf-electrical.h @@ -32,7 +32,54 @@ extern "C" { @defgroup twdf tWDF @ingroup electrical @brief Wave digital filter component. - @{ + + The tWDF represents any WDF element: resistors, capacitors, inductors, adaptors, sources, nonlinear diodes + + Example + @code{.c} + //initialize + tWDF* resistor = NULL; + tWDF_init(&resistor, + Resistor, //component type + 1000.0f, //resistance in ohms + NULL, NULL, //children (none) + leaf); + + tWDF* capacitor = NULL; + tWDF_init(&capacitor, + Capacitor, //component type + 1e-6f, //capacitance in farads + NULL, NULL, //children (none) + leaf); + + //Series adaptor combining R and C + tWDF* series = NULL; + tWDF_init(&series, + SeriesAdaptor, //adaptor type + 0.0f, //value unused + resistor, //left child (R) + capacitor, //right child (C) + leaf); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float vin = inputSamples[i]; + float wave = tWDF_tick(series, + vin, + series, //outputPoint is the root + 0); //paramsChanged = false + float vout = tWDF_getVoltage(series); + outputSamples[i] = vout; + } + + //tweak resistor value + tWDF_setValue(resistor, 2000.0f); + + //when done + tWDF_free(&series); + tWDF_free(&resistor); + tWDF_free(&capacitor); + @endcode @fn void tWDF_init(tWDF** const, WDFComponentType type, Lfloat value, tWDF* const rL, tWDF* const rR, LEAF* const leaf) @brief Initialize a tWDF to the default mempool of a LEAF instance. From 839f36518a23cfd1ab5a56bab073e32af45af36a Mon Sep 17 00:00:00 2001 From: seanxue Date: Tue, 15 Jul 2025 18:33:22 -0400 Subject: [PATCH 11/14] examples for leaf-filters.h --- leaf/Inc/leaf-filters.h | 420 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 405 insertions(+), 15 deletions(-) diff --git a/leaf/Inc/leaf-filters.h b/leaf/Inc/leaf-filters.h index 19d2f73..afdc226 100644 --- a/leaf/Inc/leaf-filters.h +++ b/leaf/Inc/leaf-filters.h @@ -93,7 +93,28 @@ extern "C" { @defgroup tallpass tAllpassSO @ingroup filters @brief Schroeder allpass. Comb-filter with feedforward and feedback. - @{ + + Example + @code{.c} + //initialize + tAllpassSO* ap2 = NULL; + tAllpassSO_init(&ap2, leaf); + + // set coefficients (50-sample equivalent delay) + float theta = 2.0f * M_PI * 50.0f / sampleRate; + float a1 = -2.0f * cosf(theta); + float a2 = 1.0f; + tAllpassSO_setCoeff(ap2, a1, a2); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float out = tAllpassSO_tick(ap2, inputSamples[i]); + outputSamples[i] = out; + } + + //when done + tAllpassSO_free(&ap2); + @endcode @fn void tAllpassSO_init(tAllpassSO** const, Lfloat initDelay, uint32_t maxDelay, LEAF* const leaf) @brief Initialize a tAllpassSO to the default mempool of a LEAF instance. @@ -149,6 +170,41 @@ extern "C" { void tAllpassSO_setCoeff (tAllpassSO* const ft, Lfloat a1, Lfloat a2); //============================================================================== + /*! + @defgroup tThiranAllpassSOCascade ThiranAllpassSOCascade + @ingroup filters + @brief Cascade of second order Thiran allpass filters for fractional delay dispersion correction + + Example + @code{.c} + // initialize + tThiranAllpassSOCascade* th = NULL; + tThiranAllpassSOCascade_init(&th, + 4, //order (number of 2nd‐order sections) + leaf); + + //set coefficients (0.7‐sample dispersion at 1 kHz with 2× oversampling) + float delayFrac = 0.7f; + float centerFreq = 1000.0f; + float invOS = 0.5f; // 1/oversampling ratio + tThiranAllpassSOCascade_setCoeff(th, + delayFrac, + centerFreq, + invOS); + + //audio loop: + for (int i = 0; i < numSamples; ++i) { + float out = tThiranAllpassSOCascade_tick(th, inputSamples[i]); + outputSamples[i] = out; + } + + //clear filter memory when needed + tThiranAllpassSOCascade_clear(th); + + //when done + tThiranAllpassSOCascade_free(&th); + @endcode + */ typedef struct tThiranAllpassSOCascade { @@ -189,7 +245,32 @@ extern "C" { @defgroup tonepole tOnePole @ingroup filters @brief OnePole filter, reimplemented from STK (Cook and Scavone). - @{ + + Example + @code{.c} + // initialize + tOnePole* op = NULL; + tOnePole_init(&op, + 1000.0f, // cutoff frequency (Hz) + leaf); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float in = inputSamples[i]; + float out = tOnePole_tick(op, in); + outputSamples[i] = out; + } + + //tweak parameters + tOnePole_setFreq(op, 500.0f); + tOnePole_setGain(op, 0.7f); + + // set raw coefficients + tOnePole_setCoefficients(op, 0.3f, -0.7f); + + //when done + tOnePole_free(&op); + @endcode @fn void tOnePole_init(tOnePole** const, Lfloat thePole, LEAF* const leaf) @brief Initialize a tOnePole to the default mempool of a LEAF instance. @@ -345,7 +426,31 @@ extern "C" { @defgroup ttwopole tTwoPole @ingroup filters @brief TwoPole filter, reimplemented from STK (Cook and Scavone). - @{ + + Example + @code{.c} + // initialize + tTwoPole* tp = NULL; + tTwoPole_init(&tp, leaf); + + tTwoPole_setResonance(tp, + 1000.0f, //center frequency (Hz) + 0.9f, //pole radius (0 < r < 1) + 1); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float in = inputSamples[i]; + float out = tTwoPole_tick(tp, in); + outputSamples[i] = out; + } + + //tweak parameters + tTwoPole_setResonance(tp, 500.0f, 0.7f, 1); + + //when done + tTwoPole_free(&tp); + @endcode @fn void tTwoPole_init(tTwoPole** const, LEAF* const leaf) @brief Initialize a tTwoPole to the default mempool of a LEAF instance. @@ -432,7 +537,31 @@ extern "C" { @defgroup tonezero tOneZero @ingroup filters @brief OneZero filter, reimplemented from STK (Cook and Scavone). - @{ + + Example + @code{.c} + // initialize + tOneZero* oz = NULL; + tOneZero_init(&oz, + -1.0f, // zero coefficient + leaf); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float in = inputSamples[i]; + float out = tOneZero_tick(oz, in); + outputSamples[i] = out; + } + + //tweak parameters + tOneZero_setZero(oz, 0.5f); + + // set raw coefficients + tOneZero_setCoefficients(oz, 0.8f, -0.2f); + + //when done + tOneZero_free(&oz); + @endcode @fn void tOneZero_init(tOneZero** const, Lfloat theZero, LEAF* const leaf) @brief Initialize a tOneZero to the default mempool of a LEAF instance. @@ -510,7 +639,30 @@ extern "C" { @defgroup ttwozero tTwoZero @ingroup filters @brief TwoZero filter, reimplemented from STK (Cook and Scavone). - @{ + + Example + @code{.c} + // initialize + tTwoZero* tz = NULL; + tTwoZero_init(&tz, leaf); + + tTwoZero_setNotch(tz, + 1000.0f, //notch center frequency (Hz) + 0.95f); //pole radius + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float in = inputSamples[i]; + float out = tTwoZero_tick(tz, in); + outputSamples[i] = out; + } + + //tweak parameters + tTwoZero_setNotch(tz, 500.0f, 0.8f); + + //when done + tTwoZero_free(&tz); + @endcode @fn void tTwoZero_init(tTwoZero** const, LEAF* const leaf) @brief Initialize a tTwoZero to the default mempool of a LEAF instance. @@ -591,7 +743,32 @@ extern "C" { @defgroup tpolezero tPoleZero @ingroup filters @brief PoleZero filter, reimplemented from STK (Cook and Scavone). - @{ + + Example + @code{.c} + //initialize + tPoleZero* pz = NULL; + tPoleZero_init(&pz, leaf); + + tPoleZero_setAllpass(pz, 0.5f); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float in = inputSamples[i]; + float out = tPoleZero_tick(pz, in); + outputSamples[i] = out; + } + + //tweak parameters and types + tPoleZero_setBlockZero(pz, -1.0f); + tPoleZero_setA1(pz, 0.8f); + tPoleZero_setB0(pz, 0.1f); + tPoleZero_setB1(pz, 0.1f); + tPoleZero_setGain(pz, 1.2f); + + //when done + tPoleZero_free(&pz); + @endcode @fn void tPoleZero_init(tPoleZero** const, LEAF* const leaf) @brief Initialize a tPoleZero to the default mempool of a LEAF instance. @@ -678,7 +855,34 @@ extern "C" { @defgroup tbiquad tBiQuad @ingroup filters @brief BiQuad filter, reimplemented from STK (Cook and Scavone). - @{ + + Example + @code{.c} + // initialize + tBiQuad* bq = NULL; + tBiQuad_init(&bq, leaf); + + tBiQuad_setResonance(bq, + 1000.0f, //center frequency (Hz) + 0.707f, //pole radius (controls Q) + 1); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float in = inputSamples[i]; + float out = tBiQuad_tick(bq, in); + outputSamples[i] = out; + } + + //tweak parameters and type + tBiQuad_setNotch(bq, + 2000.0f, //!< notch center frequency in Hz + 0.9f); //!< radius (0 < r < 1) + tBiQuad_setGain(bq, 1.2f); + + //when done + tBiQuad_free(&bq); + @endcode @fn void tBiQuad_init(tBiQuad** const, LEAF* const leaf) @brief Initialize a tBiQuad to the default mempool of a LEAF instance. @@ -782,7 +986,34 @@ extern "C" { @defgroup tsvf tSVF @ingroup filters @brief State Variable Filter, algorithm from Andy Simper. - @{ + + Example + @code{.c} + //initialize + tSVF* svf = NULL; + tSVF_init(&svf, + SVFTypeBandpass, //filter type (bandpass) + 500.0f, //cutoff frequency (Hz) + 1.0f, //resonance Q + leaf); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float in = inputSamples[i]; + float bp = tSVF_tickBP(svf, in); //bandpass output + float lp = tSVF_tickLP(svf, in); //lowpass output + float hp = tSVF_tickHP(svf, in); //highpass output + //mix using bandpass + outputSamples[i] = bp; + } + + //tweaking filter type and parameter + tSVF_setFilterType(svf, SVFTypeNotch); + tSVF_setFreq(svf, 1000.0f); + + //when done + tSVF_free(&svf); + @endcode @fn void tSVF_init(tSVF** const, SVFType type, Lfloat freq, Lfloat Q, LEAF* const leaf) @brief Initialize a tSVF to the default mempool of a LEAF instance. @@ -903,7 +1134,31 @@ extern "C" { @defgroup tefficientsvf tEfficientSVF @ingroup filters @brief Efficient State Variable Filter for 14-bit control input, [0, 4096). - @{ + + Example + @code{.c} + //initialize + tEfficientSVF* esvf = NULL; + tEfficientSVF_init(&esvf, + SVFTypeLowpass, //filter type (lowpass) + 2048, //14-bit control value (0–4095) + 0.707f, //resonance Q + leaf); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float in = inputSamples[i]; + float out = tEfficientSVF_tick(esvf, in); + outputSamples[i] = out; + } + + //tweak parameters + tEfficientSVF_setFreq(esvf, 3072); + tEfficientSVF_setQ(esvf, 1.2f); + + //when done + tEfficientSVF_free(&esvf); + @endcode @fn void tEfficientSVF_init(tEfficientSVF** const, SVFType type, uint16_t input, Lfloat Q, LEAF* const leaf) @brief Initialize a tEfficientSVF to the default mempool of a LEAF instance. @@ -963,7 +1218,31 @@ extern "C" { @defgroup thighpass tHighpass @ingroup filters @brief Simple Highpass filter. - @{ + + Example + @code{.c} + //initialize + tHighpass* hp = NULL; + tHighpass_init(&hp, + 200.0f, //cutoff frequency (Hz) + leaf); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float in = inputSamples[i]; + float out = tHighpass_tick(hp, in); + outputSamples[i] = out; + } + + //tweak parameters + tHighpass_setFreq(hp, 800.0f); + + //find current cutoff + float currentCutoff = tHighpass_getFreq(hp); + + //when done + tHighpass_free(&hp); + @endcode @fn void tHighpass_init(tHighpass** const, Lfloat freq, LEAF* const leaf) @brief Initialize a tHighpass to the default mempool of a LEAF instance. @@ -1020,7 +1299,31 @@ extern "C" { @defgroup tbutterworth tButterworth @ingroup filters @brief Butterworth filter. - @{ + + Example + @code{.c} + //initialize + tButterworth* bw = NULL; + tButterworth_init(&bw, + 4, //filter order + 300.0f, //low cutoff (Hz) + 3000.0f, //high cutoff (Hz) + leaf); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float in = inputSamples[i]; + float out = tButterworth_tick(bw, in); + outputSamples[i] = out; + } + + //tweak parameters + tButterworth_setFreqs(bw, 500.0f, 2500.0f); + tButterworth_setF2(bw, 2000.0f); //only tweaking high cutoff + + //when done + tButterworth_free(&bw); + @endcode @fn void tButterworth_init(tButterworth** const, int N, Lfloat f1, Lfloat f2, LEAF* const leaf, LEAF* const leaf) @brief Initialize a tButterworth to the default mempool of a LEAF instance. @@ -1094,7 +1397,29 @@ extern "C" { @defgroup tfir tFIR @ingroup filters @brief Finite impulse response filter. - @{ + + Example + @code{.c} + //initialize + float coeffs[5] = { + 0.2f, 0.2f, 0.2f, 0.2f, 0.2f + }; + tFIR* fir = NULL; + tFIR_init(&fir, + coeffs, //pointer to coefficient array + 5, //number of taps + leaf); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float input = inputSamples[i]; + float output = tFIR_tick(fir, input); + outputSamples[i] = output; + } + + //when done + tFIR_free(&fir); + @endcode @fn void tFIR_init(tFIR** const, Lfloat* coeffs, int numTaps, LEAF* const leaf) @brief Initialize a tFIR to the default mempool of a LEAF instance. @@ -1140,7 +1465,25 @@ extern "C" { @defgroup tmedianfilter tMedianFilter @ingroup filters @brief Median filter. - @{ + + Example + @code{.c} + //initialize + tMedianFilter* mf = NULL; + tMedianFilter_init(&mf, + 5, //window size (must be odd) + leaf); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float input = inputSamples[i]; + float output = tMedianFilter_tick(mf, input); + outputSamples[i] = output; + } + + //when done + tMedianFilter_free(&mf); + @endcode @fn void tMedianFilter_init(tMedianFilter** const, int size, LEAF* const leaf) @brief Initialize a tMedianFilter to the default mempool of a LEAF instance. @@ -1188,7 +1531,31 @@ extern "C" { @defgroup tvzfilter tVZFilter @ingroup filters @brief Vadim Zavalishin style from VA book (from implementation in RSlib posted to kvr forum) - @{ + + Example + @code{.c} + //initialize + tVZFilter* vz = NULL; + tVZFilter_init(&vz, + Highpass, //filter type + 1000.0f, //cutoff frequency (Hz) + 0.707f, //Q factor + leaf); + + //tweak parameters or filter type + tVZFilter_setBandwidth(vz, 1.0f); + tVZFilter_setType(vz, Bell); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float in = inputSamples[i]; + float out = tVZFilter_tick(vz, in); + outputSamples[i] = out; + } + + //when done + tVZFilter_free(&vz); + @endcode @fn void tVZFilter_init(tVZFilter** const, VZFilterType type, Lfloat freq, Lfloat Q, LEAF* const leaf) @brief Initialize a tVZFilter to the default mempool of a LEAF instance. @@ -1503,7 +1870,30 @@ extern "C" { @defgroup tdiodefilter tDiodeFilter @ingroup filters @brief Diode filter. - @{ + + Example + @code{.c} + //initialize + tDiodeFilter* df = NULL; + tDiodeFilter_init(&df, + 1000.0f, //cutoff frequency (Hz) + 0.5f, //resonance Q + leaf); + + //tweak parameters + tDiodeFilter_setFreqFast(df, 1200.0f); + tDiodeFilter_setQ(df, 0.7f); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float in = inputSamples[i]; + float out = tDiodeFilter_tick(df, in); + outputSamples[i] = out; + } + + //when done + tDiodeFilter_free(&df); + @endcode @fn void tDiodeFilter_init(tDiodeFilter** const, Lfloat freq, Lfloat Q, LEAF* const leaf) @brief Initialize a tDiodeFilter to the default mempool of a LEAF instance. From e9da1ab6d409f93e20288be20bd5577fb81caeaf Mon Sep 17 00:00:00 2001 From: seanxue Date: Tue, 22 Jul 2025 12:30:40 -0400 Subject: [PATCH 12/14] examples for leaf-instruments.h --- leaf/Inc/leaf-instruments.h | 186 ++++++++++++++++++++++++++++++++++-- 1 file changed, 180 insertions(+), 6 deletions(-) diff --git a/leaf/Inc/leaf-instruments.h b/leaf/Inc/leaf-instruments.h index 756ea97..7caadfc 100644 --- a/leaf/Inc/leaf-instruments.h +++ b/leaf/Inc/leaf-instruments.h @@ -35,7 +35,34 @@ extern "C" { @defgroup t808cowbell t808Cowbell @ingroup instruments @brief 808 drum machine cowbell. - @{ + + Example + @code{.c} + //initialize + t808Cowbell* cb = NULL; + t808Cowbell_init(&cb, + 1, //toggle stick noise + leaf); + + //set trigger velocity threshold + t808Cowbell_on(cb, 0.8f); + + //tweak parameters + t808Cowbell_setFreq(cb, 1200.0f); //bell pitch + t808Cowbell_setDecay(cb, 0.5f); //decay time (0–1) + t808Cowbell_setHighpassFreq(cb, 800.0f); //remove lows + t808Cowbell_setBandpassFreq(cb, 2400.0f); + t808Cowbell_setOscMix(cb, 0.7f); //balance square osc vs. stick + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float out = t808Cowbell_tick(cb); + outputSamples[i] = out; + } + + //when done + t808Cowbell_free(&cb); + @endcode @fn void t808Cowbell_init(t808Cowbell** const, int useStick, LEAF* const leaf) @brief Initialize a t808Cowbell to the default mempool of a LEAF instance. @@ -122,7 +149,37 @@ extern "C" { @defgroup t808hihat t808Hihat @ingroup instruments @brief 808 drum machine hihat. - @{ + + Example + @code{.c} + //initialize + t808Hihat* hh = NULL; + t808Hihat_init(&hh, + leaf); + + //set trigger velocity threshold + t808Hihat_on(hh, 0.9f); + + //tweak parameters + t808Hihat_setOscFreq(hh, 8000.0f); //oscillator pitch + t808Hihat_setStretch(hh, 0.5f); //spread of the six squares + t808Hihat_setFM(hh, 0.3f); //noise‑modulated frequency + t808Hihat_setOscNoiseMix(hh, 0.7f); //balance osc vs. noise + t808Hihat_setHighpassFreq(hh, 1000.0f); //remove lows + t808Hihat_setOscBandpassFreq(hh, 6000.0f); + t808Hihat_setOscBandpassQ(hh, 1.2f); + t808Hihat_setStickBandPassFreq(hh, 3000.0f); + t808Hihat_setStickBandPassQ(hh, 0.8f); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float out = t808Hihat_tick(hh); + outputSamples[i] = out; + } + + //when done + t808Hihat_free(&hh); + @endcode @fn void t808Hihat_init(t808Hihat** const, LEAF* const leaf) @brief Initialize a t808Hihat to the default mempool of a LEAF instance. @@ -234,7 +291,36 @@ extern "C" { @defgroup t808snare t808Snare @ingroup instruments @brief 808 drum machine snare. - @{ + + Example + @code{.c} + //initialize + t808Snare* sn = NULL; + t808Snare_init(&sn, + leaf); + + //set trigger velocity threshold + t808Snare_on(sn, 0.8f); + + //tweak parameters + t808Snare_setTone1Freq(sn, 180.0f); //pitch of lower tone + t808Snare_setTone1Decay(sn, 0.15f); //decay time of lower tone + t808Snare_setTone2Freq(sn, 330.0f); //pitch of upper tone + t808Snare_setTone2Decay(sn, 0.10f); //decay time of upper tone + t808Snare_setNoiseDecay(sn, 0.12f); //decay time of noise component + t808Snare_setToneNoiseMix(sn, 0.6f); //balance between tone and noise + t808Snare_setNoiseFilterFreq(sn, 8000.0f); //noise filter cutoff + t808Snare_setNoiseFilterQ(sn, 1.0f); //noise filter resonance + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float out = t808Snare_tick(sn); + outputSamples[i] = out; + } + + //when done + t808Snare_free(&sn); + @endcode @fn void t808Snare_init(t808Snare** const, LEAF* const leaf) @brief Initialize a t808Snare to the default mempool of a LEAF instance. @@ -341,7 +427,36 @@ extern "C" { @defgroup t808SnareSmall t808SnareSmall @ingroup instruments @brief 808 drum machine snare. - @{ + + Example + @code{.c} + //initilize + t808SnareSmall* sn = NULL; + t808SnareSmall_init(&sn, + leaf); + + //set trigger velocity + t808SnareSmall_on(sn, 0.9f); + + //tweak parameters + t808SnareSmall_setTone1Freq(sn, 200.0f); //lower tone pitch (Hz) + t808SnareSmall_setTone1Decay(sn, 0.12f); //lower tone decay (s) + t808SnareSmall_setTone2Freq(sn, 330.0f); //upper tone pitch (Hz) + t808SnareSmall_setTone2Decay(sn, 0.09f); //upper tone decay (s) + t808SnareSmall_setNoiseDecay(sn, 0.10f); //noise decay time (s) + t808SnareSmall_setToneNoiseMix(sn, 0.7f); //tone/noise balance: 0.0 (all tone)–1.0 (all noise) + t808SnareSmall_setNoiseFilterFreq(sn, 8000.0f); //noise filter cutoff (Hz) + t808SnareSmall_setNoiseFilterQ(sn, 0.8f); //noise filter resonance (Q) + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float sample = t808SnareSmall_tick(sn); + output[i] = sample; + } + + //when done + t808SnareSmall_free(&sn); + @endcode @fn void t808SnareSmall_init(t808SnareSmall** const, LEAF* const leaf) @brief Initialize a t808SnareSmall to the default mempool of a LEAF instance. @@ -446,7 +561,36 @@ extern "C" { @defgroup t808kick t808Kick @ingroup instruments @brief 808 drum machine kick. - @{ + + Example + @code{.c} + //initialize + t808Kick* kick = NULL; + t808Kick_init(&kick, + leaf); + + //set trigger velocity + t808Kick_on(kick, 0.8f); + + //tweak parameters + t808Kick_setToneFreq(kick, 60.0f); //fundamental pitch + t808Kick_setToneDecay(kick, 0.35f); //tone decay time + t808Kick_setNoiseDecay(kick, 0.08f); //noise decay time + t808Kick_setToneNoiseMix(kick, 0.6f); //tone/noise balance: 0.0 (all tone)–1.0 (all noise) + t808Kick_setNoiseFilterFreq(kick, 8000.0f); //noise filter cutoff + t808Kick_setNoiseFilterQ(kick, 0.7f); //noise filter resonance (Q) + t808Kick_setSighAmount(kick, 40.0f); //sigh sweep depth + t808Kick_setChirpAmount(kick, 0.25f); //chirp rate + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float out = t808Kick_tick(kick); + output[i] = out; + } + + //when done + t808Kick_free(&kick); + @endcode @fn void t808Kick_init(t808Kick** const, LEAF* const leaf) @brief Initialize a t808Kick to the default mempool of a LEAF instance. @@ -551,7 +695,37 @@ extern "C" { @defgroup t808KickSmall t808KickSmall @ingroup instruments @brief 808 drum machine kick. - @{ + + Example + @code{.c} + //initialize + t808KickSmall* kick = NULL; + t808KickSmall_init(&kick, leaf); + + //tweak trigger + t808KickSmall_on(kick, 0.9f); + + //tweak parameters + t808KickSmall_setToneFreq //(hz) + t808KickSmall_setToneDecay //(s) + t808KickSmall_setNoiseDecay //(s) + t808KickSmall_setToneNoiseMix(kick, 0.5f); //0.0=tone only, 1.0=noise only + t808KickSmall_setNoiseFilterFreq(kick, 7000.0f); //(Hz) + t808KickSmall_setNoiseFilterQ (kick, 0.8f); + + //pitch sweeps + t808KickSmall_setSighAmount (kick, 30.0f); //Hz drop over decay + t808KickSmall_setChirpAmount(kick, 0.2f); //ratio offset + + //audio loop + for (int n = 0; n < numSamples; ++n) { + float y = t808KickSmall_tick(kick); + out[n] = y; + } + + //when done + t808KickSmall_free(&kick); + @endcode @fn void t808KickSmall_init(t808KickSmall** const, LEAF* const leaf) @brief Initialize a t808KickSmall to the default mempool of a LEAF instance. From 41a85cd88dd088520d2de8ccfa6073ff70f49358 Mon Sep 17 00:00:00 2001 From: seanxue Date: Fri, 25 Jul 2025 18:32:34 -0400 Subject: [PATCH 13/14] examples for leaf-midi.h --- leaf/Inc/leaf-envelopes.h | 34 ++++++++++++++- leaf/Inc/leaf-midi.h | 88 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 119 insertions(+), 3 deletions(-) diff --git a/leaf/Inc/leaf-envelopes.h b/leaf/Inc/leaf-envelopes.h index 8a2b4ae..be29967 100644 --- a/leaf/Inc/leaf-envelopes.h +++ b/leaf/Inc/leaf-envelopes.h @@ -38,7 +38,39 @@ extern "C" { @defgroup tenvelope tEnvelope @ingroup envelopes @brief Basic attack-decay envelope. - @{ + + The envelope produces a one shot or looping ramp. + When triggered, it centers the attack phase, rising exponentially toward 'velocity' at the configured attack time + When it reaches its peak, it transitions to hte decay phase, falling toward zero at the decay time + If 'loop' is non zero, it repeats attack & decay indefinitely, otherwise it stops after decay + + Example + @code{.c} + // initialize + tEnvelope* env = NULL; + tEnvelope_init(&env, + 0.05f, //attack time in seconds + 0.2f, //decay time in seconds + 0, //set loop boolean (false) + leaf); + + // trigger the envelope with full velocity (1.0) + tEnvelope_on(env, 1.0f); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + float envVal = tEnvelope_tick(env); + outputSamples[i] = envVal * inputSamples[i]; + } + + //tweak parameters + tEnvelope_setAttack(env, 0.1f); + tEnvelope_setDecay(env, 0.5f); + tEnvelope_loop(env, 1); //enable continuous looping + + //when done + tEnvelope_free(&env); + @endcode @fn void tEnvelope_init(tEnvelope** const, Lfloat attack, Lfloat decay, int loop, LEAF* const leaf) @brief Initialize a tEnvelope to the default mempool of a LEAF instance. diff --git a/leaf/Inc/leaf-midi.h b/leaf/Inc/leaf-midi.h index 6777bdc..5fcab39 100644 --- a/leaf/Inc/leaf-midi.h +++ b/leaf/Inc/leaf-midi.h @@ -36,7 +36,50 @@ extern "C" { @defgroup tstack tStack @ingroup midi @brief A basic stack of integers with a fixed capacity of 128, used by tPoly to keep track of MIDI notes. - @{ + + Example + @code{.c} + //initialize + tStack* noteStack = NULL; + tStack_init(¬eStack, leaf); + + //limit capacity if needed (128 by default) + tStack_setCapacity(noteStack, 32); + + //note on handler + void noteOn(uint8_t note) + { + tStack_addIfNotAlreadyThere(noteStack, note); + } + + //note off handler + void noteOff(uint8_t note) + { + tStack_remove(noteStack, note); + } + + //retrieve newest note for mono priority logic + int current = tStack_first(noteStack); //eturns -1 if empty + + //iterate through stack in order of arrival + int n; + while ((n = tStack_next(noteStack)) != -1) { + ... + } + + //direct indexed access + int size = tStack_getSize(noteStack); + for (int i = 0; i < size; ++i) { + int val = tStack_get(noteStack, i); + ... + } + + //clear all held notes + tStack_clear(noteStack); + + //when done + tStack_free(¬eStack); + @endcode @fn void tStack_init(tStack** const stack, LEAF* const leaf) @brief Initialize a tStack to the default mempool of a LEAF instance. @@ -314,7 +357,48 @@ extern "C" { @defgroup tsimplepoly tSimplePoly @ingroup midi @brief Polyphony handler. - @{ + + Example + @code{.c} + //initialize + tPoly* poly = NULL; + tPoly_init(&poly, + 8, //maximum number of voices + leaf); + + // Enable voices at runtime + tPoly_setNumVoices(poly, + 4); // amout of voices + + //tweak parameters + tPoly_setPitchGlideActive(poly, + 1); //portimento 1 = on, 0 = off + tPoly_setPitchGlideTime(poly, + 200.0f); //glide glide (ms) + tPoly_setPitchBend(poly, + 2.0f); //pitch send (semitones) + tPoly_setBendGlideTime(poly, + 50.0f); //pitch bend time (ms) + + //audio loop + int voice = tPoly_noteOn(poly, + midiNote, // MIDI note number (0–127) + velocity); // MIDI velocity (0–127) + int freedVoice = tPoly_noteOff(poly, + midiNote); + tPoly_tickPitch(poly); // advances glide and bend each sample + for (int v = 0; v < tPoly_getNumVoices(poly); ++v) { + if (tPoly_isOn(poly, v)) { + Lfloat pitch = tPoly_getPitch(poly, v); + int key = tPoly_getKey(poly, v); + int vel = tPoly_getVelocity(poly, v); + // key, vel: as above + } + } + + //when done + tPoly_free(&poly); + @endcode @fn void tSimplePoly_init(tSimplePoly** const poly, int maxNumVoices, LEAF* const leaf) @brief Initialize a tSimplePoly to the default mempool of a LEAF instance. From f726a36eab484172abfdb09e7b7947ab58e233ab Mon Sep 17 00:00:00 2001 From: seanxue Date: Tue, 29 Jul 2025 12:51:47 -0400 Subject: [PATCH 14/14] examples for leaf-oscillators.h --- leaf/Inc/leaf-oscillators.h | 237 ++++++++++++++++++++++++++++++++++-- 1 file changed, 228 insertions(+), 9 deletions(-) diff --git a/leaf/Inc/leaf-oscillators.h b/leaf/Inc/leaf-oscillators.h index 17066b6..31bddf4 100644 --- a/leaf/Inc/leaf-oscillators.h +++ b/leaf/Inc/leaf-oscillators.h @@ -32,7 +32,33 @@ extern "C" { @defgroup tcycle tCycle @ingroup oscillators @brief Wavetable cycle/sine wave oscillator - @{ + + Example + @code{.c} + //intialize + tCycle* osc = NULL; + // Initialize to default mempool + tCycle_init(&osc, + leaf); + + //tweak parameters + tCycle_setSampleRate(osc, + 48000.0f); //(Hz) + tCycle_setFreq(osc, + 440.0f); //(Hz) + tCycle_setPhase(osc, + 0.25f); //set initial cycle phase (fraction of cycle [0–1]) + + //audio loop + for (int i = 0; i < numSamples; ++i) { + // Get next sample in range –1.0 … +1.0 + Lfloat sample = tCycle_tick(osc); + output[i] = sample * 0.8f; // apply output gain + } + + //when done + tCycle_free(&osc); + @endcode @fn void tCycle_init(tCycle** const osc, LEAF* const leaf) @brief Initialize a tCycle to the default mempool of a LEAF instance. @@ -216,7 +242,32 @@ extern "C" { @defgroup tsawtooth tSawtooth @ingroup oscillators @brief Anti-aliased wavetable saw wave oscillator. - @{ + + Example + @code{.c} + //initialize + tSawtooth* osc = NULL; + tSawtooth_init(&osc, + leaf); + + //tweak parameters + tSawtooth_setSampleRate(osc, + 48000.0f); //(Hz) + tSawtooth_setFreq(osc, + 261.63f); //(Hz) + tSawtooth_setPhase(osc, + 0.5f); //initial phase offset (fraction of cycle [0–1]) + + //audio loop + for (int i = 0; i < numSamples; ++i) { + // Get next saw sample in range –1.0 … +1.0 + Lfloat sample = tSawtooth_tick(osc); + output[i] = sample * 0.7f; // apply output gain + } + + //when done + tSawtooth_free(&osc); + @endcode @fn void tSawtooth_init(tSawtooth** const osc, LEAF* const leaf) @brief Initialize a tSawtooth to the default mempool of a LEAF instance. @@ -277,7 +328,34 @@ extern "C" { @defgroup tpbtriangle tPBTriangle @ingroup oscillators @brief Triangle wave oscillator with polyBLEP anti-aliasing. - @{ + + Example + @code{.c} + //initialize + tPBSineTriangle* osc = NULL; + // Initialize to default mempool + tPBSineTriangle_init(&osc, + leaf); + + //tweak parameters + tPBSineTriangle_setSampleRate(osc, + 48000.0f); //(Hz) + tPBSineTriangle_setFreq(osc, + 440.0f); //(Hz) + //adjust waveform skew (0.0 = rising saw, 0.5 = classic triangle, 1.0 = falling saw) + tPBSineTriangle_setShape(osc, + 0.5f); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + //get next triangle sample in range –1.0 … +1.0 + Lfloat sample = tPBSineTriangle_tick(osc); + output[i] = sample * 0.8f; // apply output gain + } + + //when done + tPBSineTriangle_free(&osc); + @endcode @fn void tPBTriangle_init(tPBTriangle** const osc, LEAF* const leaf) @brief Initialize a tPBTriangle to the default mempool of a LEAF instance. @@ -382,7 +460,35 @@ extern "C" { @defgroup tpbpulse tPBPulse @ingroup oscillators @brief Pulse wave oscillator with polyBLEP anti-aliasing. - @{ + + Example + @code{.c} + //initialize + tPBPulse* osc = NULL; + // Initialize to default mempool + tPBPulse_init(&osc, + leaf); + + //tweak parameters + tPBPulse_setSampleRate(osc, + 48000.0f); //(Hz) + tPBPulse_setFreq(osc, + 261.63f); //(Hz) + + //set pulse width + tPBPulse_setWidth(osc, + 0.25f); //width parameter is a fraction of period (0.0-1.0) + + //audio loop + for (int i = 0; i < numSamples; ++i) { + //get next pulse sample in range –1.0 … +1.0 + Lfloat sample = tPBPulse_tick(osc); + output[i] = sample * 0.7f; //apply output gain + } + + //when done + tPBPulse_free(&osc); + @endcode @fn void tPBPulse_init(tPBPulse** const osc, LEAF* const leaf) @brief Initialize a tPBPulse to the default mempool of a LEAF instance. @@ -450,7 +556,30 @@ extern "C" { @defgroup tpbsaw tPBSaw @ingroup oscillators @brief Saw wave oscillator with polyBLEP anti-aliasing. - @{ + + Example + @code{.c} + //initialize + tPBSaw* osc = NULL; + tPBSaw_init(&osc, + leaf); + + //tweak parameters + tPBSaw_setSampleRate(osc, + 44100.0f); //(Hz) + tPBSaw_setFreq(osc, + 440.0f); //(Hz) + + //audio loop + for (int i = 0; i < numSamples; ++i) { + //tick the saw wave oscillator (-1.0 … +1.0) + Lfloat sample = tPBSaw_tick(osc); + output[i] = sample * 0.5f; //apply output gain + } + + //when done + tPBSaw_free(&osc); + @endcode @fn void tPBSaw_init(tPBSaw** const osc, LEAF* const leaf) @brief Initialize a tPBSaw to the default mempool of a LEAF instance. @@ -579,7 +708,31 @@ typedef struct tPBSawSquare @defgroup tphasor tPhasor @ingroup oscillators @brief Aliasing phasor. - @{ + + Example + @code{.c} + //initialize + tPhasor* ph = NULL; + tPhasor_init(&ph, + leaf); + + //tweak parameters + tPhasor_setSampleRate(ph, + 48000.0f); //(Hz) + tPhasor_setFreq(ph, + 1000.0f); //(Hz) + + //audio loop + for (int i = 0; i < numSamples; ++i) { + //tick the phasor (0.0 … 1.0) + Lfloat phase = tPhasor_tick(ph); + //use phase + output[i] = phase * 2.0f - 1.0f; + } + + //when done + tPhasor_free(&ph); + @endcode @fn void tPhasor_init(tPhasor** const osc, LEAF* const leaf) @brief Initialize a tPhasor to the default mempool of a LEAF instance. @@ -634,7 +787,35 @@ typedef struct tPBSawSquare @defgroup tnoise tNoise @ingroup oscillators @brief Noise generator, capable of producing white or pink noise. - @{ + + Example + @code{.c} + //initialize white noise + tNoise* white = NULL; + tNoise_init(&white, + WhiteNoise, //noise type + leaf); + + //pink noise + tNoise* pink = NULL; + tNoise_init(&pink, + PinkNoise, //noise type + leaf); + + //audio loop + for (int i = 0; i < numSamples; ++i) { + //generate one sample of white noise + Lfloat w = tNoise_tick(white); + outputWhite[i] = w; + + // Generate one sample of pink noise + Lfloat p = tNoise_tick(pink); + outputPink[i] = p; + } + + //when done + tNoise_free(&white); + tNoise_free(&pink); @fn void tNoise_init(tNoise** const noise, NoiseType type, LEAF* const leaf) @brief Initialize a tNoise to the default mempool of a LEAF instance. @@ -691,7 +872,44 @@ typedef struct tPBSawSquare @defgroup tneuron tNeuron @ingroup oscillators @brief Model of a neuron, adapted to act as an oscillator. - @{ + + Example + @code{.c} + //initialize + tNeuron* neuron = NULL; + tNeuron_init(&neuron, + leaf); + + //tweak parameters + tNeuron_setCurrent(neuron, + 5.0f); //set applied current (I) in microamperes (µA) + + // Set maximal conductances (gₖ, gₙ, gₗ) in millisiemens (mS) + tNeuron_setK(neuron, + 36.0f); + tNeuron_setN(neuron, + 120.0f); + tNeuron_setL(neuron, + 0.3f); + + tNeuron_setC(neuron, + 1.0f); //set membrane capacitance (C) in microfarads (µF) + tNeuron_setMode(neuron, + NeuronTanh); //set shaping mode + tNeuron_setTimeStep(neuron, + 0.025f); //set time step (Δt) in milliseconds (ms) + tNeuron_setSampleRate(neuron, + 44100.0f); //(Hz) + + //audio loop + for (int i = 0; i < numSamples; ++i) { + //advance the neuron model and get one sample + Lfloat out = tNeuron_tick(neuron); + output[i] = out; + } + + //when done + tNeuron_free(&neuron); @fn void tNeuron_init(tNeuron** const neuron, LEAF* const leaf) @brief Initialize a tNeuron to the default mempool of a LEAF instance. @@ -830,7 +1048,8 @@ typedef struct tPBSawSquare @defgroup tmbpulse tMBPulse @ingroup oscillators @brief Pulse wave oscillator with minBLEP anti-aliasing. - @{ + + @fn void tMBPulse_init(tMBPulse** const osc, LEAF* const leaf) @brief Initialize a tMBPulse to the default mempool of a LEAF instance.