Unified · Split
Binary file not shown.
| @@ -15,9 +15,7 @@ extern "C" { · 14 unmodified lines | ||
| 15 | 15 | |
| 16 | 16 | //============================================================================== |
| 17 | 17 | |
| 18 | −#include "leaf-globals.h" | |
| 19 | 18 | #include "leaf-math.h" |
| 20 | − | |
| 21 | 19 | #include "leaf-oscillator.h" |
| 22 | 20 | #include "leaf-utilities.h" |
| 23 | 21 | #include "leaf-filter.h" |
| @@ -37,10 +35,11 @@ typedef struct _t808Cowbell { · 13 unmodified lines | ||
| 37 | 35 | tHighpass highpass; |
| 38 | 36 | float oscMix; |
| 39 | 37 | float filterCutoff; |
| 38 | + oBool useStick; | |
| 40 | 39 | |
| 41 | 40 | } t808Cowbell; |
| 42 | 41 | |
| 43 | −void t808Cowbell_init (t808Cowbell* const); | |
| 42 | +void t808Cowbell_init (t808Cowbell* const, int useStick); | |
| 44 | 43 | void t808Cowbell_free (t808Cowbell* const); |
| 45 | 44 | float t808Cowbell_tick (t808Cowbell* const); |
| 46 | 45 | void t808Cowbell_on (t808Cowbell* const, float vel); |
| @@ -49,6 +48,7 @@ void t808Cowbell_setHighpassFreq (t808Cowbell* const, float freq); · 2 unmodified lines | ||
| 49 | 48 | void t808Cowbell_setBandpassFreq (t808Cowbell* const, float freq); |
| 50 | 49 | void t808Cowbell_setFreq (t808Cowbell* const, float freq); |
| 51 | 50 | void t808Cowbell_setOscMix (t808Cowbell* const, float oscMix); |
| 51 | +void t808Cowbell_setStick (t808Cowbell* const, int useStick); | |
| 52 | 52 | |
| 53 | 53 | //============================================================================== |
| 54 | 54 | |
| @@ -14,7 +14,7 @@ extern "C" { · 13 unmodified lines | ||
| 14 | 14 | |
| 15 | 15 | //============================================================================== |
| 16 | 16 | |
| 17 | −#include "leaf-globals.h" | |
| 17 | +#include "leaf-global.h" | |
| 18 | 18 | #include "leaf-math.h" |
| 19 | 19 | |
| 20 | 20 | //============================================================================== |
| @@ -18,7 +18,7 @@ extern "C" { · 17 unmodified lines | ||
| 18 | 18 | |
| 19 | 19 | //============================================================================== |
| 20 | 20 | |
| 21 | −#include "leaf-globals.h" | |
| 21 | +#include "leaf-global.h" | |
| 22 | 22 | #include "leaf-math.h" |
| 23 | 23 | |
| 24 | 24 | //============================================================================== |
| @@ -7,18 +7,17 @@ · 6 unmodified lines | ||
| 7 | 7 | ==============================================================================*/ |
| 8 | 8 | |
| 9 | 9 | #ifndef LEAF_DELAY_H_INCLUDED |
| 10 | −#define LEAF_DELAY_H_INCLUDED | |
| 11 | − | |
| 12 | −#ifdef __cplusplus | |
| 13 | −extern "C" { | |
| 10 | +#define LEAF_DELAY_H_INCLUDED | |
| 11 | + | |
| 12 | +#ifdef __cplusplus | |
| 13 | +extern "C" { | |
| 14 | 14 | #endif |
| 15 | 15 | |
| 16 | −//============================================================================== | |
| 16 | +//============================================================================== | |
| 17 | 17 | |
| 18 | −#include "leaf-globals.h" | |
| 19 | 18 | #include "leaf-math.h" |
| 20 | 19 | |
| 21 | −//============================================================================== | |
| 20 | +//============================================================================== | |
| 22 | 21 | |
| 23 | 22 | /* Non-interpolating delay, reimplemented from STK (Cook and Scavone). */ |
| 24 | 23 | typedef struct _tDelay |
| @@ -46,7 +45,7 @@ float tDelay_tick (tDelay* const, float sample); · 21 unmodified lines | ||
| 46 | 45 | float tDelay_getLastOut (tDelay* const); |
| 47 | 46 | float tDelay_getLastIn (tDelay* const); |
| 48 | 47 | |
| 49 | −//============================================================================== | |
| 48 | +//============================================================================== | |
| 50 | 49 | |
| 51 | 50 | /* Linearly-interpolating delay, reimplemented from STK (Cook and Scavone). */ |
| 52 | 51 | typedef struct _tDelayL |
| @@ -80,7 +79,7 @@ float tDelayL_tickOut (tDelayL* const d); · 27 unmodified lines | ||
| 80 | 79 | float tDelayL_getLastOut (tDelayL* const); |
| 81 | 80 | float tDelayL_getLastIn (tDelayL* const); |
| 82 | 81 | |
| 83 | −//============================================================================== | |
| 82 | +//============================================================================== | |
| 84 | 83 | |
| 85 | 84 | /* Allpass-interpolating delay, reimplemented from STK (Cook and Scavone). */ |
| 86 | 85 | typedef struct _tDelayA |
| @@ -103,7 +102,7 @@ typedef struct _tDelayA · 16 unmodified lines | ||
| 103 | 102 | } tDelayA; |
| 104 | 103 | |
| 105 | 104 | void tDelayA_init (tDelayA* const, float delay, uint32_t maxDelay); |
| 106 | −void tDelayA_free (tDelayA* const); | |
| 105 | +void tDelayA_free (tDelayA* const); | |
| 107 | 106 | |
| 108 | 107 | int tDelayA_setDelay (tDelayA* const, float delay); |
| 109 | 108 | float tDelayA_getDelay (tDelayA* const); |
| @@ -114,44 +113,44 @@ float tDelayA_tick (tDelayA* const, float sample); · 4 unmodified lines | ||
| 114 | 113 | float tDelayA_getLastOut (tDelayA* const); |
| 115 | 114 | float tDelayA_getLastIn (tDelayA* const); |
| 116 | 115 | |
| 117 | −//============================================================================== | |
| 118 | − | |
| 119 | −/* Linear interpolating delay with fixed read and write pointers, variable rate. */ | |
| 120 | −typedef struct _tTapeDelay | |
| 121 | −{ | |
| 122 | − float gain; | |
| 123 | − float* buff; | |
| 124 | − | |
| 125 | − float lastOut, lastIn; | |
| 126 | − | |
| 127 | − uint32_t inPoint; | |
| 128 | − | |
| 129 | − uint32_t maxDelay; | |
| 130 | − | |
| 131 | − float delay, inc, idx; | |
| 132 | − | |
| 133 | − float apInput; | |
| 134 | − | |
| 135 | −} tTapeDelay; | |
| 136 | − | |
| 137 | −void tTapeDelay_init (tTapeDelay* const, float delay, uint32_t maxDelay); | |
| 138 | −void tTapeDelay_free (tTapeDelay* const); | |
| 139 | − | |
| 140 | −int tTapeDelay_setDelay (tTapeDelay* const, float delay); | |
| 141 | −float tTapeDelay_getDelay (tTapeDelay* const); | |
| 142 | −void tTapeDelay_tapIn (tTapeDelay* const, float in, uint32_t tapDelay); | |
| 143 | −float tTapeDelay_tapOut (tTapeDelay* const d, float tapDelay); | |
| 144 | −float tTapeDelay_addTo (tTapeDelay* const, float value, uint32_t tapDelay); | |
| 145 | −float tTapeDelay_tick (tTapeDelay* const, float sample); | |
| 146 | −float tTapeDelay_getLastOut (tTapeDelay* const); | |
| 147 | −float tTapeDelay_getLastIn (tTapeDelay* const); | |
| 148 | − | |
| 149 | −//============================================================================== | |
| 150 | − | |
| 151 | −#ifdef __cplusplus | |
| 152 | −} | |
| 116 | +//============================================================================== | |
| 117 | + | |
| 118 | +/* Linear interpolating delay with fixed read and write pointers, variable rate. */ | |
| 119 | +typedef struct _tTapeDelay | |
| 120 | +{ | |
| 121 | + float gain; | |
| 122 | + float* buff; | |
| 123 | + | |
| 124 | + float lastOut, lastIn; | |
| 125 | + | |
| 126 | + uint32_t inPoint; | |
| 127 | + | |
| 128 | + uint32_t maxDelay; | |
| 129 | + | |
| 130 | + float delay, inc, idx; | |
| 131 | + | |
| 132 | + float apInput; | |
| 133 | + | |
| 134 | +} tTapeDelay; | |
| 135 | + | |
| 136 | +void tTapeDelay_init (tTapeDelay* const, float delay, uint32_t maxDelay); | |
| 137 | +void tTapeDelay_free (tTapeDelay* const); | |
| 138 | + | |
| 139 | +int tTapeDelay_setDelay (tTapeDelay* const, float delay); | |
| 140 | +float tTapeDelay_getDelay (tTapeDelay* const); | |
| 141 | +void tTapeDelay_tapIn (tTapeDelay* const, float in, uint32_t tapDelay); | |
| 142 | +float tTapeDelay_tapOut (tTapeDelay* const d, float tapDelay); | |
| 143 | +float tTapeDelay_addTo (tTapeDelay* const, float value, uint32_t tapDelay); | |
| 144 | +float tTapeDelay_tick (tTapeDelay* const, float sample); | |
| 145 | +float tTapeDelay_getLastOut (tTapeDelay* const); | |
| 146 | +float tTapeDelay_getLastIn (tTapeDelay* const); | |
| 147 | + | |
| 148 | +//============================================================================== | |
| 149 | + | |
| 150 | +#ifdef __cplusplus | |
| 151 | +} | |
| 153 | 152 | #endif |
| 154 | 153 | |
| 155 | −#endif // LEAF_DELAY_H_INCLUDED | |
| 156 | − | |
| 154 | +#endif // LEAF_DELAY_H_INCLUDED | |
| 155 | + | |
| 157 | 156 | //============================================================================== |
| @@ -15,11 +15,8 @@ extern "C" { · 14 unmodified lines | ||
| 15 | 15 | |
| 16 | 16 | //============================================================================== |
| 17 | 17 | |
| 18 | −#include "leaf-globals.h" | |
| 19 | 18 | #include "leaf-math.h" |
| 20 | − | |
| 21 | 19 | #include "leaf-delay.h" |
| 22 | − | |
| 23 | 20 | #include "leaf-tables.h" |
| 24 | 21 | |
| 25 | 22 | //============================================================================== |
| @@ -15,7 +15,8 @@ extern "C" { · 14 unmodified lines | ||
| 15 | 15 | |
| 16 | 16 | //============================================================================== |
| 17 | 17 | |
| 18 | −#include "leaf-globals.h" | |
| 18 | +#include "leaf-global.h" | |
| 19 | +#include "leaf-mempool.h" | |
| 19 | 20 | #include "leaf-math.h" |
| 20 | 21 | |
| 21 | 22 | //============================================================================== |
| @@ -0,0 +1,37 @@ | ||
| 1 | +/* | |
| 2 | + ============================================================================== | |
| 3 | + | |
| 4 | + leaf-global.h | |
| 5 | + Created: 24 Oct 2019 2:24:38pm | |
| 6 | + Author: Matthew Wang | |
| 7 | + | |
| 8 | + ============================================================================== | |
| 9 | +*/ | |
| 10 | + | |
| 11 | +#ifndef LEAF_GLOBAL_H_INCLUDED | |
| 12 | +#define LEAF_GLOBAL_H_INCLUDED | |
| 13 | + | |
| 14 | +#ifdef __cplusplus | |
| 15 | +extern "C" { | |
| 16 | +#endif | |
| 17 | + | |
| 18 | +typedef struct _LEAF | |
| 19 | +{ | |
| 20 | + float sampleRate; | |
| 21 | + float invSampleRate; | |
| 22 | + int blockSize; | |
| 23 | + | |
| 24 | + float (*random)(void); | |
| 25 | +} LEAF; | |
| 26 | + | |
| 27 | +extern LEAF leaf; // The global instance of LEAF. | |
| 28 | + | |
| 29 | + //============================================================================== | |
| 30 | + | |
| 31 | +#ifdef __cplusplus | |
| 32 | +} | |
| 33 | +#endif | |
| 34 | + | |
| 35 | +#endif // LEAF_GLOBAL_H_INCLUDED | |
| 36 | + | |
| 37 | +//============================================================================== | |
| @@ -1,61 +0,0 @@ | ||
| 1 | −/*============================================================================== | |
| 2 | − | |
| 3 | − leaf-globals.h | |
| 4 | − Created: 23 Jan 2017 10:34:10pm | |
| 5 | − Author: Michael R Mulshine | |
| 6 | − | |
| 7 | −==============================================================================*/ | |
| 8 | − | |
| 9 | −#ifndef LEAF_GLOBALS_H_INCLUDED | |
| 10 | −#define LEAF_GLOBALS_H_INCLUDED | |
| 11 | − | |
| 12 | −#ifdef __cplusplus | |
| 13 | −extern "C" { | |
| 14 | −#endif | |
| 15 | − | |
| 16 | −//============================================================================== | |
| 17 | − | |
| 18 | −#include "leaf-mempool.h" | |
| 19 | − | |
| 20 | −//============================================================================== | |
| 21 | − | |
| 22 | −typedef struct _LEAF | |
| 23 | −{ | |
| 24 | − float sampleRate; | |
| 25 | − float invSampleRate; | |
| 26 | − int blockSize; | |
| 27 | − | |
| 28 | − | |
| 29 | − float* sinewave; | |
| 30 | − float* sawtooth[11]; | |
| 31 | − float* square[11]; | |
| 32 | − float* triangle[11]; | |
| 33 | − | |
| 34 | − | |
| 35 | − float (*random)(void); | |
| 36 | −} LEAF; | |
| 37 | − | |
| 38 | −//============================================================================== | |
| 39 | − | |
| 40 | −extern LEAF leaf; // The global instance of LEAF. | |
| 41 | − | |
| 42 | −//============================================================================== | |
| 43 | − | |
| 44 | −#define PS_FRAME_SIZE 1024 // SNAC_FRAME_SIZE in leaf-pitch.h should match (or be smaller than?) this | |
| 45 | −#define ENV_WINDOW_SIZE 1024 | |
| 46 | −#define ENV_HOP_SIZE 256 | |
| 47 | − | |
| 48 | −union unholy_t { /* a union between a float and an integer */ | |
| 49 | − float f; | |
| 50 | − int i; | |
| 51 | −}; | |
| 52 | − | |
| 53 | −//============================================================================== | |
| 54 | − | |
| 55 | −#ifdef __cplusplus | |
| 56 | −} | |
| 57 | −#endif | |
| 58 | − | |
| 59 | −#endif // LEAF_GLOBALS_H_INCLUDED | |
| 60 | − | |
| 61 | −//============================================================================== | |
| @@ -13,6 +13,7 @@ · 12 unmodified lines | ||
| 13 | 13 | extern "C" { |
| 14 | 14 | #endif |
| 15 | 15 | |
| 16 | +#include "leaf-global.h" | |
| 16 | 17 | #include "math.h" |
| 17 | 18 | #include "stdint.h" |
| 18 | 19 | #include "stdlib.h" |
| @@ -26,6 +27,12 @@ typedef enum oBool · 7 unmodified lines | ||
| 26 | 27 | OTRUE = 1, |
| 27 | 28 | OFALSE = 0 |
| 28 | 29 | }oBool; |
| 30 | + | |
| 31 | +// Allows for bitwise operations on floats | |
| 32 | +union unholy_t { /* a union between a float and an integer */ | |
| 33 | + float f; | |
| 34 | + int i; | |
| 35 | +}; | |
| 29 | 36 | |
| 30 | 37 | #define SQRT8 2.82842712475f |
| 31 | 38 | #define WSCALE 1.30612244898f |
| @@ -50,9 +50,6 @@ extern "C" { · 49 unmodified lines | ||
| 50 | 50 | |
| 51 | 51 | //============================================================================== |
| 52 | 52 | |
| 53 | − | |
| 54 | −#define MPOOL_POOL_SIZE 50 000 | |
| 55 | − | |
| 56 | 53 | #define MPOOL_ALIGN_SIZE (8) |
| 57 | 54 | |
| 58 | 55 | //#define size_t unsigned long |
| @@ -15,9 +15,9 @@ extern "C" { · 14 unmodified lines | ||
| 15 | 15 | |
| 16 | 16 | //============================================================================== |
| 17 | 17 | |
| 18 | −#include "leaf-globals.h" | |
| 18 | +#include "leaf-global.h" | |
| 19 | +#include "leaf-mempool.h" | |
| 19 | 20 | #include "leaf-math.h" |
| 20 | − | |
| 21 | 21 | #include "leaf-utilities.h" |
| 22 | 22 | |
| 23 | 23 | //============================================================================== |
| @@ -28,7 +28,7 @@ typedef struct _tPoly · 4 unmodified lines | ||
| 28 | 28 | tStack stack; |
| 29 | 29 | tStack orderStack; |
| 30 | 30 | |
| 31 | − tRamp* ramp; | |
| 31 | + tRamp* ramps; | |
| 32 | 32 | float* rampVals; |
| 33 | 33 | oBool* firstReceived; |
| 34 | 34 | float glideTime; |
| @@ -7,15 +7,14 @@ · 6 unmodified lines | ||
| 7 | 7 | ==============================================================================*/ |
| 8 | 8 | |
| 9 | 9 | #ifndef LEAF_OSCILLATOR_H_INCLUDED |
| 10 | −#define LEAF_OSCILLATOR_H_INCLUDED | |
| 11 | − | |
| 12 | −#ifdef __cplusplus | |
| 13 | −extern "C" { | |
| 10 | +#define LEAF_OSCILLATOR_H_INCLUDED | |
| 11 | + | |
| 12 | +#ifdef __cplusplus | |
| 13 | +extern "C" { | |
| 14 | 14 | #endif |
| 15 | 15 | |
| 16 | 16 | //============================================================================== |
| 17 | 17 | |
| 18 | −#include "leaf-globals.h" | |
| 19 | 18 | #include "leaf-math.h" |
| 20 | 19 | |
| 21 | 20 | #include "leaf-filter.h" |
| @@ -171,12 +170,12 @@ void tNoise_free (tNoise* const); · 149 unmodified lines | ||
| 171 | 170 | |
| 172 | 171 | float tNoise_tick (tNoise* const); |
| 173 | 172 | |
| 174 | −//============================================================================== | |
| 173 | +//============================================================================== | |
| 175 | 174 | |
| 176 | −#ifdef __cplusplus | |
| 177 | −} | |
| 178 | −#endif | |
| 175 | +#ifdef __cplusplus | |
| 176 | +} | |
| 177 | +#endif | |
| 179 | 178 | |
| 180 | −#endif // LEAF_OSCILLATOR_H_INCLUDED | |
| 181 | − | |
| 179 | +#endif // LEAF_OSCILLATOR_H_INCLUDED | |
| 180 | + | |
| 182 | 181 | //============================================================================== |
| @@ -16,7 +16,8 @@ extern "C" { · 15 unmodified lines | ||
| 16 | 16 | |
| 17 | 17 | //============================================================================== |
| 18 | 18 | |
| 19 | −#include "leaf-globals.h" | |
| 19 | +#include "leaf-global.h" | |
| 20 | +#include "leaf-mempool.h" | |
| 20 | 21 | #include "leaf-math.h" |
| 21 | 22 | #include "leaf-filter.h" |
| 22 | 23 | |
| @@ -17,12 +17,12 @@ extern "C" { · 16 unmodified lines | ||
| 17 | 17 | |
| 18 | 18 | //============================================================================== |
| 19 | 19 | |
| 20 | −#include "leaf-globals.h" | |
| 20 | +#include "leaf-global.h" | |
| 21 | 21 | #include "leaf-math.h" |
| 22 | 22 | |
| 23 | 23 | #include "leaf-filter.h" |
| 24 | 24 | #include "leaf-utilities.h" |
| 25 | −#include "../leaf.h" | |
| 25 | + | |
| 26 | 26 | //============================================================================== |
| 27 | 27 | |
| 28 | 28 | #define DEFPITCHRATIO 2.0f |
| @@ -15,7 +15,7 @@ extern "C" { · 14 unmodified lines | ||
| 15 | 15 | |
| 16 | 16 | //============================================================================== |
| 17 | 17 | |
| 18 | −#include "leaf-globals.h" | |
| 18 | +#include "leaf-global.h" | |
| 19 | 19 | #include "leaf-math.h" |
| 20 | 20 | |
| 21 | 21 | #include "leaf-delay.h" |
| @@ -16,7 +16,7 @@ extern "C" { · 15 unmodified lines | ||
| 16 | 16 | |
| 17 | 17 | //============================================================================== |
| 18 | 18 | |
| 19 | −#include "leaf-globals.h" | |
| 19 | +#include "leaf-global.h" | |
| 20 | 20 | #include "leaf-math.h" |
| 21 | 21 | |
| 22 | 22 | #include "leaf-utilities.h" |
| @@ -17,7 +17,7 @@ extern "C" { · 16 unmodified lines | ||
| 17 | 17 | |
| 18 | 18 | //============================================================================== |
| 19 | 19 | |
| 20 | −#include "leaf-globals.h" | |
| 20 | +#include "leaf-global.h" | |
| 21 | 21 | #include "leaf-math.h" |
| 22 | 22 | |
| 23 | 23 | #include "leaf-delay.h" |
| @@ -15,7 +15,6 @@ extern "C" { · 14 unmodified lines | ||
| 15 | 15 | |
| 16 | 16 | //============================================================================== |
| 17 | 17 | |
| 18 | −#include "leaf-globals.h" | |
| 19 | 18 | #include "leaf-math.h" |
| 20 | 19 | |
| 21 | 20 | //============================================================================== |
| @@ -17,7 +17,6 @@ extern "C" { · 16 unmodified lines | ||
| 17 | 17 | |
| 18 | 18 | // ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ |
| 19 | 19 | |
| 20 | −#include "leaf-globals.h" | |
| 21 | 20 | #include "leaf-math.h" |
| 22 | 21 | #include "leaf-filter.h" |
| 23 | 22 | #include "leaf-delay.h" |
| @@ -369,6 +368,8 @@ int tAtkDtk_detect (tAtkDtk* const, float *in); · 345 unmodified lines | ||
| 369 | 368 | // ENV~ from PD, modified for LEAF |
| 370 | 369 | #define MAXOVERLAP 32 |
| 371 | 370 | #define INITVSTAKEN 64 |
| 371 | +#define ENV_WINDOW_SIZE 1024 | |
| 372 | +#define ENV_HOP_SIZE 256 | |
| 372 | 373 | |
| 373 | 374 | typedef struct _tEnv |
| 374 | 375 | { |
| @@ -15,7 +15,7 @@ extern "C" { · 14 unmodified lines | ||
| 15 | 15 | |
| 16 | 16 | //============================================================================== |
| 17 | 17 | |
| 18 | −#include "leaf-globals.h" | |
| 18 | +#include "leaf-global.h" | |
| 19 | 19 | #include "leaf-math.h" |
| 20 | 20 | |
| 21 | 21 | //============================================================================== |
| @@ -16,7 +16,7 @@ extern "C" { · 15 unmodified lines | ||
| 16 | 16 | |
| 17 | 17 | //============================================================================== |
| 18 | 18 | |
| 19 | −#include "leaf-globals.h" | |
| 19 | +#include "leaf-global.h" | |
| 20 | 20 | #include "leaf-math.h" |
| 21 | 21 | |
| 22 | 22 | //============================================================================== |
| @@ -16,16 +16,54 @@ · 15 unmodified lines | ||
| 16 | 16 | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | −#define USE_STICK 0 | |
| 19 | +// ----------------- COWBELL ----------------------------// | |
| 20 | + | |
| 21 | +void t808Cowbell_init(t808Cowbell* const cowbell, int useStick) { | |
| 22 | + | |
| 23 | + tSquare_init(&cowbell->p[0]); | |
| 24 | + tSquare_setFreq(&cowbell->p[0], 540.0f); | |
| 25 | + | |
| 26 | + tSquare_init(&cowbell->p[1]); | |
| 27 | + tSquare_setFreq(&cowbell->p[1], 1.48148f * 540.0f); | |
| 28 | + | |
| 29 | + cowbell->oscMix = 0.5f; | |
| 30 | + | |
| 31 | + tSVF_init(&cowbell->bandpassOsc, SVFTypeBandpass, 2500, 1.0f); | |
| 32 | + | |
| 33 | + tSVF_init(&cowbell->bandpassStick, SVFTypeBandpass, 1800, 1.0f); | |
| 34 | + | |
| 35 | + tEnvelope_init(&cowbell->envGain, 5.0f, 100.0f, OFALSE); | |
| 36 | + | |
| 37 | + tEnvelope_init(&cowbell->envFilter, 5.0, 100.0f, OFALSE); | |
| 38 | + | |
| 39 | + tHighpass_init(&cowbell->highpass, 1000.0f); | |
| 40 | + | |
| 41 | + tNoise_init(&cowbell->stick, WhiteNoise); | |
| 42 | + | |
| 43 | + tEnvelope_init(&cowbell->envStick, 5.0f, 5.0f, 0); | |
| 44 | + | |
| 45 | + cowbell->useStick = useStick; | |
| 46 | +} | |
| 47 | + | |
| 48 | +void t808Cowebell_free(t808Cowbell* const cowbell) | |
| 49 | +{ | |
| 50 | + tSquare_free(&cowbell->p[0]); | |
| 51 | + tSquare_free(&cowbell->p[1]); | |
| 52 | + tSVF_free(&cowbell->bandpassOsc); | |
| 53 | + tSVF_free(&cowbell->bandpassStick); | |
| 54 | + tEnvelope_free(&cowbell->envGain); | |
| 55 | + tEnvelope_free(&cowbell->envFilter); | |
| 56 | + tHighpass_free(&cowbell->highpass); | |
| 57 | + tNoise_free(&cowbell->stick); | |
| 58 | + tEnvelope_free(&cowbell->envStick); | |
| 59 | +} | |
| 60 | + | |
| 20 | 61 | void t808Cowbell_on(t808Cowbell* const cowbell, float vel) |
| 21 | 62 | { |
| 22 | − | |
| 23 | 63 | tEnvelope_on(&cowbell->envGain, vel); |
| 24 | 64 | |
| 25 | −#if USE_STICK | |
| 26 | − tEnvelope_on(&cowbell->envStick,vel); | |
| 27 | −#endif | |
| 28 | − | |
| 65 | + if (cowbell->useStick) | |
| 66 | + tEnvelope_on(&cowbell->envStick,vel); | |
| 29 | 67 | } |
| 30 | 68 | |
| 31 | 69 | float t808Cowbell_tick(t808Cowbell* const cowbell) { |
| @@ -41,9 +79,9 @@ float t808Cowbell_tick(t808Cowbell* const cowbell) { · 9 unmodified lines | ||
| 41 | 79 | |
| 42 | 80 | sample *= (0.9f * tEnvelope_tick(&cowbell->envGain)); |
| 43 | 81 | |
| 44 | −#if USE_STICK | |
| 45 | − sample += (0.1f * tEnvelope_tick(&cowbell->envStick) * tSVF_tick(&cowbell->bandpassStick, tNoise_tick(&cowbell->stick))); | |
| 46 | −#endif | |
| 82 | + if (cowbell->useStick) | |
| 83 | + sample += (0.1f * tEnvelope_tick(&cowbell->envStick) * tSVF_tick(&cowbell->bandpassStick, tNoise_tick(&cowbell->stick))); | |
| 84 | + | |
| 47 | 85 | |
| 48 | 86 | sample = tHighpass_tick(&cowbell->highpass, sample); |
| 49 | 87 | |
| @@ -77,30 +115,61 @@ void t808Cowbell_setOscMix(t808Cowbell* const cowbell, float oscMix) · 27 unmodified lines | ||
| 77 | 115 | cowbell->oscMix = oscMix; |
| 78 | 116 | } |
| 79 | 117 | |
| 80 | −void t808Cowbell_init(t808Cowbell* const cowbell) { | |
| 118 | +void t808Cowbell_setStick(t808Cowbell* const cowbell, int useStick) | |
| 119 | +{ | |
| 120 | + cowbell->useStick = useStick; | |
| 121 | +} | |
| 122 | + | |
| 123 | +// ----------------- HIHAT ----------------------------// | |
| 124 | + | |
| 125 | +void t808Hihat_init(t808Hihat* const hihat) | |
| 126 | +{ | |
| 127 | + for (int i = 0; i < 6; i++) | |
| 128 | + { | |
| 129 | + tSquare_init(&hihat->p[i]); | |
| 130 | + } | |
| 81 | 131 | |
| 82 | − tSquare_init(&cowbell->p[0]); | |
| 83 | − tSquare_setFreq(&cowbell->p[0], 540.0f); | |
| 132 | + tNoise_init(&hihat->stick, PinkNoise); | |
| 133 | + tNoise_init(&hihat->n, WhiteNoise); | |
| 84 | 134 | |
| 85 | − tSquare_init(&cowbell->p[1]); | |
| 86 | − tSquare_setFreq(&cowbell->p[1], 1.48148f * 540.0f); | |
| 135 | + // need to fix SVF to be generic | |
| 136 | + tSVF_init(&hihat->bandpassStick, SVFTypeBandpass,2500.0f,1.2f); | |
| 137 | + tSVF_init(&hihat->bandpassOsc, SVFTypeBandpass,3500.0f,0.3f); | |
| 87 | 138 | |
| 88 | − cowbell->oscMix = 0.5f; | |
| 139 | + tEnvelope_init(&hihat->envGain, 0.0f, 50.0f, OFALSE); | |
| 140 | + tEnvelope_init(&hihat->envStick, 0.0f, 7.0f, OFALSE); | |
| 89 | 141 | |
| 90 | − tSVF_init(&cowbell->bandpassOsc, SVFTypeBandpass, 2500, 1.0f); | |
| 91 | 142 | |
| 92 | − tSVF_init(&cowbell->bandpassStick, SVFTypeBandpass, 1800, 1.0f); | |
| 143 | + tHighpass_init(&hihat->highpass, 7000.0f); | |
| 93 | 144 | |
| 94 | − tEnvelope_init(&cowbell->envGain, 5.0f, 100.0f, OFALSE); | |
| 145 | + hihat->freq = 40.0f; | |
| 146 | + hihat->stretch = 0.0f; | |
| 95 | 147 | |
| 96 | − tEnvelope_init(&cowbell->envFilter, 5.0, 100.0f, OFALSE); | |
| 148 | + tSquare_setFreq(&hihat->p[0], 2.0f * hihat->freq); | |
| 149 | + tSquare_setFreq(&hihat->p[1], 3.00f * hihat->freq); | |
| 150 | + tSquare_setFreq(&hihat->p[2], 4.16f * hihat->freq); | |
| 151 | + tSquare_setFreq(&hihat->p[3], 5.43f * hihat->freq); | |
| 152 | + tSquare_setFreq(&hihat->p[4], 6.79f * hihat->freq); | |
| 153 | + tSquare_setFreq(&hihat->p[5], 8.21f * hihat->freq); | |
| 154 | +} | |
| 155 | + | |
| 156 | +void t808Hihat_free(t808Hihat* const hihat) | |
| 157 | +{ | |
| 158 | + for (int i = 0; i < 6; i++) | |
| 159 | + { | |
| 160 | + tSquare_free(&hihat->p[i]); | |
| 161 | + } | |
| 97 | 162 | |
| 98 | − tHighpass_init(&cowbell->highpass, 1000.0f); | |
| 163 | + tNoise_free(&hihat->stick); | |
| 164 | + tNoise_free(&hihat->n); | |
| 99 | 165 | |
| 100 | −#if USE_STICK | |
| 101 | − tNoise_init(&cowbell->stick, NoiseTypeWhite); | |
| 102 | − tEnvelope_init(&cowbell->envStick, 5.0f, 5.0f, 0); | |
| 103 | −#endif | |
| 166 | + // need to fix SVF to be generic | |
| 167 | + tSVF_free(&hihat->bandpassStick); | |
| 168 | + tSVF_free(&hihat->bandpassOsc); | |
| 169 | + tEnvelope_free(&hihat->envGain); | |
| 170 | + tEnvelope_free(&hihat->envStick); | |
| 171 | + | |
| 172 | + tHighpass_free(&hihat->highpass); | |
| 104 | 173 | } |
| 105 | 174 | |
| 106 | 175 | void t808Hihat_on(t808Hihat* const hihat, float vel) { |
| @@ -198,35 +267,50 @@ void t808Hihat_setOscFreq(t808Hihat* const hihat, float freq) · 91 unmodified lines | ||
| 198 | 267 | hihat->freq = freq; |
| 199 | 268 | } |
| 200 | 269 | |
| 201 | −void t808Hihat_init(t808Hihat* const hihat) | |
| 270 | +// ----------------- SNARE ----------------------------// | |
| 271 | + | |
| 272 | +void t808Snare_init(t808Snare* const snare) | |
| 202 | 273 | { |
| 203 | − for (int i = 0; i < 6; i++) | |
| 274 | + float ratio[2] = {1.0, 1.5}; | |
| 275 | + for (int i = 0; i < 2; i++) | |
| 204 | 276 | { |
| 205 | − tSquare_init(&hihat->p[i]); | |
| 277 | + tTriangle_init(&snare->tone[i]); | |
| 278 | + | |
| 279 | + tTriangle_setFreq(&snare->tone[i], ratio[i] * 400.0f); | |
| 280 | + tSVF_init(&snare->toneLowpass[i], SVFTypeLowpass, 4000, 1.0f); | |
| 281 | + tEnvelope_init(&snare->toneEnvOsc[i], 0.0f, 50.0f, OFALSE); | |
| 282 | + tEnvelope_init(&snare->toneEnvGain[i], 1.0f, 150.0f, OFALSE); | |
| 283 | + tEnvelope_init(&snare->toneEnvFilter[i], 1.0f, 2000.0f, OFALSE); | |
| 284 | + | |
| 285 | + snare->toneGain[i] = 0.5f; | |
| 206 | 286 | } |
| 207 | 287 | |
| 208 | − tNoise_init(&hihat->stick, PinkNoise); | |
| 209 | − tNoise_init(&hihat->n, WhiteNoise); | |
| 210 | − | |
| 211 | − // need to fix SVF to be generic | |
| 212 | − tSVF_init(&hihat->bandpassStick, SVFTypeBandpass,2500.0f,1.2f); | |
| 213 | − tSVF_init(&hihat->bandpassOsc, SVFTypeBandpass,3500.0f,0.3f); | |
| 214 | − | |
| 215 | − tEnvelope_init(&hihat->envGain, 0.0f, 50.0f, OFALSE); | |
| 216 | − tEnvelope_init(&hihat->envStick, 0.0f, 7.0f, OFALSE); | |
| 217 | − | |
| 288 | + snare->tone1Freq = ratio[0] * 100.0f; | |
| 289 | + snare->tone2Freq = ratio[1] * 100.0f; | |
| 290 | + snare->noiseFilterFreq = 3000.0f; | |
| 291 | + tNoise_init(&snare->noiseOsc, WhiteNoise); | |
| 292 | + tSVF_init(&snare->noiseLowpass, SVFTypeLowpass, 12000.0f, 0.8f); | |
| 293 | + tEnvelope_init(&snare->noiseEnvGain, 0.0f, 100.0f, OFALSE); | |
| 294 | + tEnvelope_init(&snare->noiseEnvFilter, 0.0f, 1000.0f, OFALSE); | |
| 295 | + snare->noiseGain = 1.0f; | |
| 296 | +} | |
| 218 | 297 | |
| 219 | − tHighpass_init(&hihat->highpass, 7000.0f); | |
| 298 | +void t808Snare_free (t808Snare* const snare) | |
| 299 | +{ | |
| 300 | + for (int i = 0; i < 2; i++) | |
| 301 | + { | |
| 302 | + tTriangle_free(&snare->tone[i]); | |
| 303 | + tSVF_free(&snare->toneLowpass[i]); | |
| 304 | + tEnvelope_free(&snare->toneEnvOsc[i]); | |
| 305 | + tEnvelope_free(&snare->toneEnvGain[i]); | |
| 306 | + tEnvelope_free(&snare->toneEnvFilter[i]); | |
| 307 | + } | |
| 220 | 308 | |
| 221 | − hihat->freq = 40.0f; | |
| 222 | − hihat->stretch = 0.0f; | |
| 223 | − | |
| 224 | − tSquare_setFreq(&hihat->p[0], 2.0f * hihat->freq); | |
| 225 | − tSquare_setFreq(&hihat->p[1], 3.00f * hihat->freq); | |
| 226 | − tSquare_setFreq(&hihat->p[2], 4.16f * hihat->freq); | |
| 227 | − tSquare_setFreq(&hihat->p[3], 5.43f * hihat->freq); | |
| 228 | − tSquare_setFreq(&hihat->p[4], 6.79f * hihat->freq); | |
| 229 | − tSquare_setFreq(&hihat->p[5], 8.21f * hihat->freq); | |
| 309 | + | |
| 310 | + tNoise_free(&snare->noiseOsc); | |
| 311 | + tSVF_free(&snare->noiseLowpass); | |
| 312 | + tEnvelope_free(&snare->noiseEnvGain); | |
| 313 | + tEnvelope_free(&snare->noiseEnvFilter); | |
| 230 | 314 | } |
| 231 | 315 | |
| 232 | 316 | void t808Snare_on(t808Snare* const snare, float vel) |
| @@ -285,7 +369,6 @@ void t808Snare_setNoiseFilterQ(t808Snare* const snare, float noiseFilterQ) · 52 unmodified lines | ||
| 285 | 369 | tSVF_setQ(&snare->noiseLowpass, noiseFilterQ); |
| 286 | 370 | } |
| 287 | 371 | |
| 288 | − | |
| 289 | 372 | static float tone[2]; |
| 290 | 373 | |
| 291 | 374 | float t808Snare_tick(t808Snare* const snare) |
| @@ -308,50 +391,7 @@ float t808Snare_tick(t808Snare* const snare) · 16 unmodified lines | ||
| 308 | 391 | return sample; |
| 309 | 392 | } |
| 310 | 393 | |
| 311 | −void t808Snare_init(t808Snare* const snare) | |
| 312 | −{ | |
| 313 | − float ratio[2] = {1.0, 1.5}; | |
| 314 | − for (int i = 0; i < 2; i++) | |
| 315 | − { | |
| 316 | − tTriangle_init(&snare->tone[i]); | |
| 317 | − | |
| 318 | − tTriangle_setFreq(&snare->tone[i], ratio[i] * 400.0f); | |
| 319 | − tSVF_init(&snare->toneLowpass[i], SVFTypeLowpass, 4000, 1.0f); | |
| 320 | − tEnvelope_init(&snare->toneEnvOsc[i], 0.0f, 50.0f, OFALSE); | |
| 321 | − tEnvelope_init(&snare->toneEnvGain[i], 1.0f, 150.0f, OFALSE); | |
| 322 | − tEnvelope_init(&snare->toneEnvFilter[i], 1.0f, 2000.0f, OFALSE); | |
| 323 | − | |
| 324 | − snare->toneGain[i] = 0.5f; | |
| 325 | − } | |
| 326 | − | |
| 327 | − snare->tone1Freq = ratio[0] * 100.0f; | |
| 328 | − snare->tone2Freq = ratio[1] * 100.0f; | |
| 329 | − snare->noiseFilterFreq = 3000.0f; | |
| 330 | − tNoise_init(&snare->noiseOsc, WhiteNoise); | |
| 331 | − tSVF_init(&snare->noiseLowpass, SVFTypeLowpass, 12000.0f, 0.8f); | |
| 332 | − tEnvelope_init(&snare->noiseEnvGain, 0.0f, 100.0f, OFALSE); | |
| 333 | − tEnvelope_init(&snare->noiseEnvFilter, 0.0f, 1000.0f, OFALSE); | |
| 334 | − snare->noiseGain = 1.0f; | |
| 335 | −} | |
| 336 | − | |
| 337 | −void t808Snare_free (t808Snare* const snare) | |
| 338 | −{ | |
| 339 | − for (int i = 0; i < 2; i++) | |
| 340 | − { | |
| 341 | − tTriangle_free(&snare->tone[i]); | |
| 342 | − tSVF_free(&snare->toneLowpass[i]); | |
| 343 | − tEnvelope_free(&snare->toneEnvOsc[i]); | |
| 344 | − tEnvelope_free(&snare->toneEnvGain[i]); | |
| 345 | − tEnvelope_free(&snare->toneEnvFilter[i]); | |
| 346 | − } | |
| 347 | − | |
| 348 | − | |
| 349 | − tNoise_free(&snare->noiseOsc); | |
| 350 | − tSVF_free(&snare->noiseLowpass); | |
| 351 | − tEnvelope_free(&snare->noiseEnvGain); | |
| 352 | − tEnvelope_free(&snare->noiseEnvFilter); | |
| 353 | −} | |
| 354 | − | |
| 394 | +// ----------------- KICK ----------------------------// | |
| 355 | 395 | |
| 356 | 396 | void t808Kick_init (t808Kick* const kick) |
| 357 | 397 | { |
| @@ -369,7 +409,6 @@ void t808Kick_init (t808Kick* const kick) · 11 unmodified lines | ||
| 369 | 409 | kick->noiseGain = 0.3f; |
| 370 | 410 | } |
| 371 | 411 | |
| 372 | − | |
| 373 | 412 | void t808Kick_free (t808Kick* const kick) |
| 374 | 413 | { |
| 375 | 414 | tCycle_free(&kick->tone); |
| @@ -410,6 +449,7 @@ void t808Kick_setToneDecay (t808Kick* const kick, float decay) · 34 unmodified lines | ||
| 410 | 449 | tEnvelope_setDecay(&kick->toneEnvGain,decay); |
| 411 | 450 | tEnvelope_setDecay(&kick->toneEnvGain,decay * 3.0f); |
| 412 | 451 | } |
| 452 | + | |
| 413 | 453 | void t808Kick_setNoiseDecay (t808Kick* const kick, float decay); |
| 414 | 454 | void t808Kick_setSighAmount (t808Kick* const kick, float sigh); |
| 415 | 455 | void t808Kick_setChirpAmount (t808Kick* const kick, float chirp); |
| @@ -154,7 +154,7 @@ void tWDF_init(tWDF* const r, WDFComponentType type, float value, tWDF* const rL · 153 unmodified lines | ||
| 154 | 154 | |
| 155 | 155 | void tWDF_free(tWDF* const r) |
| 156 | 156 | { |
| 157 | − leaf_free(r); | |
| 157 | + | |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | float tWDF_tick(tWDF* const r, float sample, tWDF* const outputPoint, uint8_t paramsChanged) |
| @@ -32,7 +32,7 @@ void tCrusher_init (tCrusher* const c) · 31 unmodified lines | ||
| 32 | 32 | |
| 33 | 33 | void tCrusher_free (tCrusher* const c) |
| 34 | 34 | { |
| 35 | − leaf_free(c); | |
| 35 | + | |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | float tCrusher_tick (tCrusher* const c, float input) |
| @@ -41,7 +41,6 @@ void tDelay_init (tDelay* const d, uint32_t delay, uint32_t maxDelay) · 40 unmodified lines | ||
| 41 | 41 | void tDelay_free(tDelay* const d) |
| 42 | 42 | { |
| 43 | 43 | leaf_free(d->buff); |
| 44 | − leaf_free(d); | |
| 45 | 44 | } |
| 46 | 45 | |
| 47 | 46 | float tDelay_tick (tDelay* const d, float input) |
| @@ -153,7 +152,6 @@ void tDelayL_init (tDelayL* const d, float delay, uint32_t maxDelay) · 105 unmodified lines | ||
| 153 | 152 | void tDelayL_free(tDelayL* const d) |
| 154 | 153 | { |
| 155 | 154 | leaf_free(d->buff); |
| 156 | − leaf_free(d); | |
| 157 | 155 | } |
| 158 | 156 | |
| 159 | 157 | float tDelayL_tick (tDelayL* const d, float input) |
| @@ -319,7 +317,6 @@ void tDelayA_init (tDelayA* const d, float delay, uint32_t maxDelay) · 159 unmodified lines | ||
| 319 | 317 | void tDelayA_free(tDelayA* const d) |
| 320 | 318 | { |
| 321 | 319 | leaf_free(d->buff); |
| 322 | − leaf_free(d); | |
| 323 | 320 | } |
| 324 | 321 | |
| 325 | 322 | float tDelayA_tick (tDelayA* const d, float input) |
| @@ -455,7 +452,6 @@ void tTapeDelay_init (tTapeDelay* const d, float delay, uint32_t maxDelay) · 129 unmodified lines | ||
| 455 | 452 | void tTapeDelay_free(tTapeDelay* const d) |
| 456 | 453 | { |
| 457 | 454 | leaf_free(d->buff); |
| 458 | − leaf_free(d); | |
| 459 | 455 | } |
| 460 | 456 | |
| 461 | 457 | //#define SMOOTH_FACTOR 10.f |
| @@ -30,15 +30,14 @@ void tAllpass_init(tAllpass* const f, float initDelay, uint32_t maxDelay) · 29 unmodified lines | ||
| 30 | 30 | tDelayL_init(&f->delay, initDelay, maxDelay); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | −void tAllpass_setDelay(tAllpass* const f, float delay) | |
| 33 | +void tAllpass_free(tAllpass* const f) | |
| 34 | 34 | { |
| 35 | − tDelayL_setDelay(&f->delay, delay); | |
| 35 | + tDelayL_free(&f->delay); | |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | −void tAllpass_free(tAllpass* const f) | |
| 38 | +void tAllpass_setDelay(tAllpass* const f, float delay) | |
| 39 | 39 | { |
| 40 | − leaf_free(&f->delay); | |
| 41 | − leaf_free(f); | |
| 40 | + tDelayL_setDelay(&f->delay, delay); | |
| 42 | 41 | } |
| 43 | 42 | |
| 44 | 43 | void tAllpass_setGain(tAllpass* const f, float gain) |
| @@ -81,8 +80,6 @@ void tButterworth_free(tButterworth* const f) · 36 unmodified lines | ||
| 81 | 80 | tSVF_free(&f->low[i]); |
| 82 | 81 | tSVF_free(&f->high[i]); |
| 83 | 82 | } |
| 84 | − | |
| 85 | − leaf_free(f); | |
| 86 | 83 | } |
| 87 | 84 | |
| 88 | 85 | float tButterworth_tick(tButterworth* const f, float samp) |
| @@ -129,7 +126,7 @@ void tOneZero_init(tOneZero* const f, float theZero) · 40 unmodified lines | ||
| 129 | 126 | |
| 130 | 127 | void tOneZero_free(tOneZero* const f) |
| 131 | 128 | { |
| 132 | − leaf_free(f); | |
| 129 | + | |
| 133 | 130 | } |
| 134 | 131 | |
| 135 | 132 | float tOneZero_tick(tOneZero* const f, float input) |
| @@ -210,7 +207,7 @@ void tTwoZero_init(tTwoZero* const f) · 74 unmodified lines | ||
| 210 | 207 | |
| 211 | 208 | void tTwoZero_free(tTwoZero* const f) |
| 212 | 209 | { |
| 213 | − leaf_free(f); | |
| 210 | + | |
| 214 | 211 | } |
| 215 | 212 | |
| 216 | 213 | float tTwoZero_tick(tTwoZero* const f, float input) |
| @@ -287,7 +284,7 @@ void tOnePole_init(tOnePole* const f, float freq) · 70 unmodified lines | ||
| 287 | 284 | |
| 288 | 285 | void tOnePole_free(tOnePole* const f) |
| 289 | 286 | { |
| 290 | − leaf_free(f); | |
| 287 | + | |
| 291 | 288 | } |
| 292 | 289 | |
| 293 | 290 | void tOnePole_setB0(tOnePole* const f, float b0) |
| @@ -359,7 +356,7 @@ void tTwoPole_init(tTwoPole* const f) · 65 unmodified lines | ||
| 359 | 356 | |
| 360 | 357 | void tTwoPole_free(tTwoPole* const f) |
| 361 | 358 | { |
| 362 | − leaf_free(f); | |
| 359 | + | |
| 363 | 360 | } |
| 364 | 361 | |
| 365 | 362 | float tTwoPole_tick(tTwoPole* const f, float input) |
| @@ -450,7 +447,7 @@ void tPoleZero_init(tPoleZero* const f) · 84 unmodified lines | ||
| 450 | 447 | |
| 451 | 448 | void tPoleZero_free(tPoleZero* const f) |
| 452 | 449 | { |
| 453 | − leaf_free(f); | |
| 450 | + | |
| 454 | 451 | } |
| 455 | 452 | |
| 456 | 453 | void tPoleZero_setB0(tPoleZero* const pzf, float b0) |
| @@ -543,7 +540,7 @@ void tBiQuad_init(tBiQuad* const f) · 86 unmodified lines | ||
| 543 | 540 | |
| 544 | 541 | void tBiQuad_free(tBiQuad* const f) |
| 545 | 542 | { |
| 546 | − leaf_free(f); | |
| 543 | + | |
| 547 | 544 | } |
| 548 | 545 | |
| 549 | 546 | float tBiQuad_tick(tBiQuad* const f, float input) |
| @@ -655,6 +652,20 @@ void tBiQuadSampleRateChanged(tBiQuad* const f) · 105 unmodified lines | ||
| 655 | 652 | } |
| 656 | 653 | |
| 657 | 654 | /* Highpass */ |
| 655 | +void tHighpass_init(tHighpass* const f, float freq) | |
| 656 | +{ | |
| 657 | + f->R = (1.0f-((freq * 2.0f * 3.14f)* leaf.invSampleRate)); | |
| 658 | + f->ys = 0.0f; | |
| 659 | + f->xs = 0.0f; | |
| 660 | + | |
| 661 | + f->frequency = freq; | |
| 662 | +} | |
| 663 | + | |
| 664 | +void tHighpass_free(tHighpass* const f) | |
| 665 | +{ | |
| 666 | + | |
| 667 | +} | |
| 668 | + | |
| 658 | 669 | void tHighpass_setFreq(tHighpass* const f, float freq) |
| 659 | 670 | { |
| 660 | 671 | f->frequency = freq; |
| @@ -675,20 +686,6 @@ float tHighpass_tick(tHighpass* const f, float x) · 14 unmodified lines | ||
| 675 | 686 | return f->ys; |
| 676 | 687 | } |
| 677 | 688 | |
| 678 | −void tHighpass_init(tHighpass* const f, float freq) | |
| 679 | −{ | |
| 680 | − f->R = (1.0f-((freq * 2.0f * 3.14f)* leaf.invSampleRate)); | |
| 681 | − f->ys = 0.0f; | |
| 682 | − f->xs = 0.0f; | |
| 683 | − | |
| 684 | − f->frequency = freq; | |
| 685 | −} | |
| 686 | − | |
| 687 | −void tHighpass_free(tHighpass* const f) | |
| 688 | −{ | |
| 689 | − leaf_free(f); | |
| 690 | −} | |
| 691 | − | |
| 692 | 689 | void tHighpassSampleRateChanged(tHighpass* const f) |
| 693 | 690 | { |
| 694 | 691 | f->R = (1.0f-((f->frequency * 2.0f * 3.14f) * leaf.invSampleRate)); |
| @@ -737,7 +734,7 @@ void tSVF_init(tSVF* const svf, SVFType type, float freq, float Q) · 42 unmodified lines | ||
| 737 | 734 | |
| 738 | 735 | void tSVF_free(tSVF* const svf) |
| 739 | 736 | { |
| 740 | − leaf_free(svf); | |
| 737 | + | |
| 741 | 738 | } |
| 742 | 739 | |
| 743 | 740 | int tSVF_setFreq(tSVF* const svf, float freq) |
| @@ -782,6 +779,11 @@ void tSVFE_init(tSVFE* const svf, SVFType type, uint16_t input, float Q) · 38 unmodified lines | ||
| 782 | 779 | svf->a3 = a3; |
| 783 | 780 | } |
| 784 | 781 | |
| 782 | +void tSVFE_free(tSVFE* const svf) | |
| 783 | +{ | |
| 784 | + | |
| 785 | +} | |
| 786 | + | |
| 785 | 787 | float tSVFE_tick(tSVFE* const svf, float v0) |
| 786 | 788 | { |
| 787 | 789 | float v1,v2,v3; |
| @@ -838,5 +840,4 @@ float tFIR_tick(tFIR* const fir, float input){ · 50 unmodified lines | ||
| 838 | 840 | void tFIR_free(tFIR* const fir) |
| 839 | 841 | { |
| 840 | 842 | leaf_free(fir->past); |
| 841 | − leaf_free(fir); | |
| 842 | 843 | } |
| @@ -61,8 +61,6 @@ void tFormantShifter_free(tFormantShifter* const fs) · 60 unmodified lines | ||
| 61 | 61 | leaf_free(fs->fbuff[i]); |
| 62 | 62 | } |
| 63 | 63 | leaf_free(fs->fbuff); |
| 64 | − | |
| 65 | − leaf_free(fs); | |
| 66 | 64 | } |
| 67 | 65 | |
| 68 | 66 | |
| @@ -48,6 +48,7 @@ · 47 unmodified lines | ||
| 48 | 48 | |
| 49 | 49 | #endif |
| 50 | 50 | |
| 51 | +// This might be too low. | |
| 51 | 52 | #define NUM_BLOCKS 50 |
| 52 | 53 | |
| 53 | 54 | mpool_pool_t blocks[NUM_BLOCKS]; |
| @@ -37,7 +37,7 @@ void tPoly_init(tPoly* const poly, int maxNumVoices) · 36 unmodified lines | ||
| 37 | 37 | |
| 38 | 38 | poly->glideTime = 5.0f; |
| 39 | 39 | |
| 40 | − poly->ramp = (tRamp*) leaf_alloc(sizeof(tRamp) * poly->maxNumVoices); | |
| 40 | + poly->ramps = (tRamp*) leaf_alloc(sizeof(tRamp) * poly->maxNumVoices); | |
| 41 | 41 | poly->rampVals = (float*) leaf_alloc(sizeof(float) * poly->maxNumVoices); |
| 42 | 42 | poly->firstReceived = (oBool*) leaf_alloc(sizeof(oBool) * poly->maxNumVoices); |
| 43 | 43 | poly->voices = (int**) leaf_alloc(sizeof(int*) * poly->maxNumVoices); |
| @@ -48,7 +48,7 @@ void tPoly_init(tPoly* const poly, int maxNumVoices) · 4 unmodified lines | ||
| 48 | 48 | poly->voices[i][0] = -1; |
| 49 | 49 | poly->firstReceived[i] = OFALSE; |
| 50 | 50 | |
| 51 | − tRamp_init(&poly->ramp[i], poly->glideTime, 1); | |
| 51 | + tRamp_init(&poly->ramps[i], poly->glideTime, 1); | |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | poly->pitchBend = 0.0f; |
| @@ -64,7 +64,7 @@ void tPoly_free(tPoly* const poly) · 9 unmodified lines | ||
| 64 | 64 | { |
| 65 | 65 | for (int i = 0; i < poly->maxNumVoices; i++) |
| 66 | 66 | { |
| 67 | − tRamp_free(&poly->ramp[i]); | |
| 67 | + tRamp_free(&poly->ramps[i]); | |
| 68 | 68 | leaf_free(poly->voices[i]); |
| 69 | 69 | } |
| 70 | 70 | tRamp_free(&poly->pitchBendRamp); |
| @@ -72,11 +72,9 @@ void tPoly_free(tPoly* const poly) · 1 unmodified line | ||
| 72 | 72 | tStack_free(&poly->orderStack); |
| 73 | 73 | |
| 74 | 74 | leaf_free(poly->voices); |
| 75 | − leaf_free(poly->ramp); | |
| 75 | + leaf_free(poly->ramps); | |
| 76 | 76 | leaf_free(poly->rampVals); |
| 77 | 77 | leaf_free(poly->firstReceived); |
| 78 | − | |
| 79 | − | |
| 80 | 78 | } |
| 81 | 79 | |
| 82 | 80 | void tPoly_tickPitch(tPoly* poly) |
| @@ -89,7 +87,7 @@ void tPoly_tickPitchGlide(tPoly* poly) · 6 unmodified lines | ||
| 89 | 87 | { |
| 90 | 88 | for (int i = 0; i < poly->maxNumVoices; ++i) |
| 91 | 89 | { |
| 92 | − tRamp_tick(&poly->ramp[i]); | |
| 90 | + tRamp_tick(&poly->ramps[i]); | |
| 93 | 91 | } |
| 94 | 92 | } |
| 95 | 93 | |
| @@ -122,7 +120,7 @@ int tPoly_noteOn(tPoly* const poly, int note, uint8_t vel) · 26 unmodified lines | ||
| 122 | 120 | { |
| 123 | 121 | if (!poly->firstReceived[i] || !poly->pitchGlideIsActive) |
| 124 | 122 | { |
| 125 | − tRamp_setVal(&poly->ramp[i], note); | |
| 123 | + tRamp_setVal(&poly->ramps[i], note); | |
| 126 | 124 | poly->firstReceived[i] = OTRUE; |
| 127 | 125 | } |
| 128 | 126 | |
| @@ -134,7 +132,7 @@ int tPoly_noteOn(tPoly* const poly, int note, uint8_t vel) · 5 unmodified lines | ||
| 134 | 132 | poly->notes[note][0] = vel; |
| 135 | 133 | poly->notes[note][1] = i; |
| 136 | 134 | |
| 137 | − tRamp_setDest(&poly->ramp[i], poly->voices[i][0]); | |
| 135 | + tRamp_setDest(&poly->ramps[i], poly->voices[i][0]); | |
| 138 | 136 | |
| 139 | 137 | alteredVoice = i; |
| 140 | 138 | break; |
| @@ -158,8 +156,8 @@ int tPoly_noteOn(tPoly* const poly, int note, uint8_t vel) · 17 unmodified lines | ||
| 158 | 156 | poly->notes[note][0] = vel; |
| 159 | 157 | poly->notes[note][1] = whichVoice; |
| 160 | 158 | |
| 161 | − tRamp_setTime(&poly->ramp[whichVoice], poly->glideTime); | |
| 162 | − tRamp_setDest(&poly->ramp[whichVoice], poly->voices[whichVoice][0]); | |
| 159 | + tRamp_setTime(&poly->ramps[whichVoice], poly->glideTime); | |
| 160 | + tRamp_setDest(&poly->ramps[whichVoice], poly->voices[whichVoice][0]); | |
| 163 | 161 | |
| 164 | 162 | alteredVoice = whichVoice; |
| 165 | 163 | |
| @@ -214,7 +212,7 @@ int tPoly_noteOff(tPoly* const poly, uint8_t note) · 48 unmodified lines | ||
| 214 | 212 | if (poly->notes[noteToTest][1] < 0) //if there is a stolen note waiting (marked inactive but on the stack) |
| 215 | 213 | { |
| 216 | 214 | poly->voices[deactivatedVoice][0] = noteToTest; //set the newly free voice to use the old stolen note |
| 217 | − tRamp_setDest(&poly->ramp[deactivatedVoice], poly->voices[deactivatedVoice][0]); | |
| 215 | + tRamp_setDest(&poly->ramps[deactivatedVoice], poly->voices[deactivatedVoice][0]); | |
| 218 | 216 | poly->voices[deactivatedVoice][1] = poly->notes[noteToTest][0]; // set the velocity of the voice to be the velocity of that note |
| 219 | 217 | poly->notes[noteToTest][1] = deactivatedVoice; //mark that it is no longer stolen and is now active |
| 220 | 218 | return -1; |
| @@ -278,7 +276,7 @@ void tPoly_setPitchGlideTime(tPoly* const poly, float t) · 57 unmodified lines | ||
| 278 | 276 | poly->glideTime = t; |
| 279 | 277 | for (int i = 0; i < poly->maxNumVoices; ++i) |
| 280 | 278 | { |
| 281 | − tRamp_setTime(&poly->ramp[i], poly->glideTime); | |
| 279 | + tRamp_setTime(&poly->ramps[i], poly->glideTime); | |
| 282 | 280 | } |
| 283 | 281 | } |
| 284 | 282 | |
| @@ -289,7 +287,7 @@ int tPoly_getNumVoices(tPoly* const poly) · 4 unmodified lines | ||
| 289 | 287 | |
| 290 | 288 | float tPoly_getPitch(tPoly* const poly, uint8_t voice) |
| 291 | 289 | { |
| 292 | − return tRamp_sample(&poly->ramp[voice]) + tRamp_sample(&poly->pitchBendRamp); | |
| 290 | + return tRamp_sample(&poly->ramps[voice]) + tRamp_sample(&poly->pitchBendRamp); | |
| 293 | 291 | } |
| 294 | 292 | |
| 295 | 293 | int tPoly_getKey(tPoly* const poly, uint8_t voice) |
| @@ -57,8 +57,6 @@ void tNeuron_init(tNeuron* const n) · 56 unmodified lines | ||
| 57 | 57 | void tNeuron_free(tNeuron* const n) |
| 58 | 58 | { |
| 59 | 59 | tPoleZero_free(&n->f); |
| 60 | − | |
| 61 | − leaf_free(n); | |
| 62 | 60 | } |
| 63 | 61 | |
| 64 | 62 | void tNeuron_reset(tNeuron* const n) |
| @@ -226,7 +224,7 @@ void tCycle_init(tCycle* const c) · 161 unmodified lines | ||
| 226 | 224 | |
| 227 | 225 | void tCycle_free(tCycle* const c) |
| 228 | 226 | { |
| 229 | − leaf_free(c); | |
| 227 | + | |
| 230 | 228 | } |
| 231 | 229 | |
| 232 | 230 | int tCycle_setFreq(tCycle* const c, float freq) |
| @@ -266,6 +264,17 @@ void tPhasorSampleRateChanged (tPhasor* const p) · 33 unmodified lines | ||
| 266 | 264 | p->inc = p->freq * leaf.invSampleRate; |
| 267 | 265 | }; |
| 268 | 266 | |
| 267 | +void tPhasor_init(tPhasor* const p) | |
| 268 | +{ | |
| 269 | + p->phase = 0.0f; | |
| 270 | + p->inc = 0.0f; | |
| 271 | +} | |
| 272 | + | |
| 273 | +void tPhasor_free(tPhasor* const p) | |
| 274 | +{ | |
| 275 | + | |
| 276 | +} | |
| 277 | + | |
| 269 | 278 | int tPhasor_setFreq(tPhasor* const p, float freq) |
| 270 | 279 | { |
| 271 | 280 | if (freq < 0.0f) freq = 0.0f; |
| @@ -285,16 +294,7 @@ float tPhasor_tick(tPhasor* const p) · 13 unmodified lines | ||
| 285 | 294 | return p->phase; |
| 286 | 295 | } |
| 287 | 296 | |
| 288 | −void tPhasor_init(tPhasor* const p) | |
| 289 | −{ | |
| 290 | − p->phase = 0.0f; | |
| 291 | − p->inc = 0.0f; | |
| 292 | −} | |
| 293 | 297 | |
| 294 | −void tPhasor_free(tPhasor* const p) | |
| 295 | −{ | |
| 296 | − leaf_free(p); | |
| 297 | −} | |
| 298 | 298 | |
| 299 | 299 | void tSawtooth_init(tSawtooth* const c) |
| 300 | 300 | { |
| @@ -304,7 +304,7 @@ void tSawtooth_init(tSawtooth* const c) · 3 unmodified lines | ||
| 304 | 304 | |
| 305 | 305 | void tSawtooth_free(tSawtooth* const c) |
| 306 | 306 | { |
| 307 | − leaf_free(c); | |
| 307 | + | |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | int tSawtooth_setFreq(tSawtooth* const c, float freq) |
| @@ -411,7 +411,8 @@ void tTriangle_init(tTriangle* const c) · 100 unmodified lines | ||
| 411 | 411 | |
| 412 | 412 | void tTriangle_free(tTriangle* const c) |
| 413 | 413 | { |
| 414 | − leaf_free(c);} | |
| 414 | + | |
| 415 | +} | |
| 415 | 416 | |
| 416 | 417 | int tTriangle_setFreq(tTriangle* const c, float freq) |
| 417 | 418 | { |
| @@ -513,7 +514,7 @@ void tSquare_init(tSquare* const c) · 95 unmodified lines | ||
| 513 | 514 | |
| 514 | 515 | void tSquare_free(tSquare* const c) |
| 515 | 516 | { |
| 516 | − leaf_free(c); | |
| 517 | + | |
| 517 | 518 | } |
| 518 | 519 | |
| 519 | 520 | int tSquare_setFreq(tSquare* const c, float freq) |
| @@ -614,7 +615,7 @@ void tNoise_init(tNoise* const n, NoiseType type) · 94 unmodified lines | ||
| 614 | 615 | |
| 615 | 616 | void tNoise_free(tNoise* const n) |
| 616 | 617 | { |
| 617 | − leaf_free(n); | |
| 618 | + | |
| 618 | 619 | } |
| 619 | 620 | |
| 620 | 621 | float tNoise_tick(tNoise* const n) |
| @@ -41,7 +41,6 @@ void tOversampler_free(tOversampler* const os) · 40 unmodified lines | ||
| 41 | 41 | { |
| 42 | 42 | leaf_free(os->upState); |
| 43 | 43 | leaf_free(os->downState); |
| 44 | − leaf_free(os); | |
| 45 | 44 | } |
| 46 | 45 | |
| 47 | 46 | float tOversampler_tick(tOversampler* const os, float input, float (*effectTick)(float)) |
| @@ -51,8 +51,6 @@ void tPitchShifter_free(tPitchShifter* const ps) · 50 unmodified lines | ||
| 51 | 51 | tSNAC_free(&ps->snac); |
| 52 | 52 | tSOLAD_free(&ps->sola); |
| 53 | 53 | tHighpass_free(&ps->hp); |
| 54 | − | |
| 55 | − leaf_free(ps); | |
| 56 | 54 | } |
| 57 | 55 | |
| 58 | 56 | float tPitchShifter_tick(tPitchShifter* ps, float sample) |
| @@ -94,7 +92,6 @@ float tPitchShifter_tick(tPitchShifter* ps, float sample) · 35 unmodified lines | ||
| 94 | 92 | tSOLAD_setPitchFactor(&ps->sola, ps->pitchFactor); |
| 95 | 93 | tSOLAD_ioSamples(&ps->sola, &(ps->inBuffer[i]), &(ps->outBuffer[i]), ps->frameSize); |
| 96 | 94 | |
| 97 | − | |
| 98 | 95 | } |
| 99 | 96 | |
| 100 | 97 | return out; |
| @@ -368,8 +365,6 @@ void tPeriod_free (tPeriod* const p) · 267 unmodified lines | ||
| 368 | 365 | { |
| 369 | 366 | tEnv_free(&p->env); |
| 370 | 367 | tSNAC_free(&p->snac); |
| 371 | − | |
| 372 | − leaf_free(p); | |
| 373 | 368 | } |
| 374 | 369 | |
| 375 | 370 | float tPeriod_findPeriod (tPeriod* p, float sample) |
| @@ -470,8 +465,6 @@ void tPitchShift_free(tPitchShift* const ps) · 94 unmodified lines | ||
| 470 | 465 | { |
| 471 | 466 | tSOLAD_free(&ps->sola); |
| 472 | 467 | tHighpass_free(&ps->hp); |
| 473 | − | |
| 474 | − leaf_free(ps); | |
| 475 | 468 | } |
| 476 | 469 | |
| 477 | 470 | float tPitchShift_shift (tPitchShift* ps) |
| @@ -58,7 +58,6 @@ void tPRCRev_free(tPRCRev* const r) · 57 unmodified lines | ||
| 58 | 58 | tDelay_free(&r->allpassDelays[0]); |
| 59 | 59 | tDelay_free(&r->allpassDelays[1]); |
| 60 | 60 | tDelay_free(&r->combDelay); |
| 61 | − leaf_free(r); | |
| 62 | 61 | } |
| 63 | 62 | |
| 64 | 63 | void tPRCRev_setT60(tPRCRev* const r, float t60) |
| @@ -167,8 +166,6 @@ void tNRev_free(tNRev* const r) · 102 unmodified lines | ||
| 167 | 166 | { |
| 168 | 167 | tDelay_free(&r->allpassDelays[i]); |
| 169 | 168 | } |
| 170 | − | |
| 171 | − leaf_free(r); | |
| 172 | 169 | } |
| 173 | 170 | |
| 174 | 171 | void tNRev_setT60(tNRev* const r, float t60) |
| @@ -334,6 +331,8 @@ void tDattorro_free (tDattorro* const r) · 159 unmodified lines | ||
| 334 | 331 | |
| 335 | 332 | tOnePole_free(&r->f1_filter); |
| 336 | 333 | |
| 334 | + tHighpass_free(&r->f2_hp); | |
| 335 | + | |
| 337 | 336 | tCycle_free(&r->f1_lfo); |
| 338 | 337 | |
| 339 | 338 | // FEEDBACK 2 |
| @@ -345,9 +344,9 @@ void tDattorro_free (tDattorro* const r) · 5 unmodified lines | ||
| 345 | 344 | |
| 346 | 345 | tOnePole_free(&r->f2_filter); |
| 347 | 346 | |
| 348 | − tCycle_free(&r->f2_lfo); | |
| 347 | + tHighpass_free(&r->f2_hp); | |
| 349 | 348 | |
| 350 | − leaf_free(r); | |
| 349 | + tCycle_free(&r->f2_lfo); | |
| 351 | 350 | } |
| 352 | 351 | |
| 353 | 352 | float tDattorro_tick (tDattorro* const r, float input) |
| @@ -39,7 +39,6 @@ void tBuffer_init (tBuffer* const s, uint32_t length) · 38 unmodified lines | ||
| 39 | 39 | void tBuffer_free (tBuffer* const s) |
| 40 | 40 | { |
| 41 | 41 | leaf_free(s->buff); |
| 42 | − leaf_free(s); | |
| 43 | 42 | } |
| 44 | 43 | |
| 45 | 44 | void tBuffer_tick (tBuffer* const s, float sample) |
| @@ -136,7 +135,6 @@ void tSampler_init(tSampler* const p, tBuffer* const s) · 90 unmodified lines | ||
| 136 | 135 | void tSampler_free (tSampler* const p) |
| 137 | 136 | { |
| 138 | 137 | tRamp_free(&p->gain); |
| 139 | − leaf_free(p); | |
| 140 | 138 | } |
| 141 | 139 | |
| 142 | 140 | float tSampler_tick (tSampler* const p) |
| @@ -38,8 +38,6 @@ void tPluck_free (tPluck* const p) · 37 unmodified lines | ||
| 38 | 38 | tOnePole_free(&p->pickFilter); |
| 39 | 39 | tOneZero_free(&p->loopFilter); |
| 40 | 40 | tDelayA_free(&p->delayLine); |
| 41 | − | |
| 42 | − leaf_free(p); | |
| 43 | 41 | } |
| 44 | 42 | |
| 45 | 43 | float tPluck_getLastOut (tPluck *p) |
| @@ -149,8 +147,6 @@ void tStifKarp_free (tStifKarp* const p) · 103 unmodified lines | ||
| 149 | 147 | { |
| 150 | 148 | tBiQuad_free(&p->biquad[i]); |
| 151 | 149 | } |
| 152 | − | |
| 153 | − leaf_free(p); | |
| 154 | 150 | } |
| 155 | 151 | |
| 156 | 152 | float tStifKarp_getLastOut (tStifKarp* const p) |
| @@ -3,11 +3,11 @@ · 2 unmodified lines | ||
| 3 | 3 | #if _WIN32 || _WIN64 |
| 4 | 4 | |
| 5 | 5 | #include "..\Inc\leaf-tables.h" |
| 6 | −#include "..\Inc\leaf-globals.h" | |
| 6 | +#include "..\Inc\leaf-global.h" | |
| 7 | 7 | #else |
| 8 | 8 | |
| 9 | 9 | #include "../Inc/leaf-tables.h" |
| 10 | −#include "../Inc/leaf-globals.h" | |
| 10 | +#include "../Inc/leaf-global.h" | |
| 11 | 11 | |
| 12 | 12 | #endif |
| 13 | 13 | |
| @@ -126,7 +126,7 @@ void tEnv_init(tEnv* const x, int ws, int hs, int bs) · 125 unmodified lines | ||
| 126 | 126 | |
| 127 | 127 | void tEnv_free (tEnv* const x) |
| 128 | 128 | { |
| 129 | − leaf_free(x); | |
| 129 | + | |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | float tEnv_tick (tEnv* const x) |
| @@ -204,6 +204,11 @@ void tCompressor_init(tCompressor* const c) · 71 unmodified lines | ||
| 204 | 204 | c->W = 1.0f; // decibel Make-up gain |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | +void tCompressor_free(tCompressor* const c) | |
| 208 | +{ | |
| 209 | + | |
| 210 | +} | |
| 211 | + | |
| 207 | 212 | int ccount = 0; |
| 208 | 213 | float tCompressor_tick(tCompressor* const c, float in) |
| 209 | 214 | { |
| @@ -306,7 +311,7 @@ void tEnvelope_init(tEnvelope* const env, float attack, float decay, oBool lo · 96 unmodified lines | ||
| 306 | 311 | |
| 307 | 312 | void tEnvelope_free(tEnvelope* const env) |
| 308 | 313 | { |
| 309 | − leaf_free(env); | |
| 314 | + | |
| 310 | 315 | } |
| 311 | 316 | |
| 312 | 317 | int tEnvelope_setAttack(tEnvelope* const env, float attack) |
| @@ -498,6 +503,11 @@ void tADSR_init(tADSR* const adsr, float attack, float decay, float sustain, · 185 unmodified lines | ||
| 498 | 503 | adsr->rampInc = adsr->inc_buff[rampIndex]; |
| 499 | 504 | } |
| 500 | 505 | |
| 506 | +void tADSR_free(tADSR* const adsr) | |
| 507 | +{ | |
| 508 | + | |
| 509 | +} | |
| 510 | + | |
| 501 | 511 | int tADSR_setAttack(tADSR* const adsr, float attack) |
| 502 | 512 | { |
| 503 | 513 | int32_t attackIndex; |
| @@ -683,6 +693,11 @@ void tEnvelopeFollower_init(tEnvelopeFollower* const e, float attackThreshold · 179 unmodified lines | ||
| 683 | 693 | e->d_coeff = decayCoeff; |
| 684 | 694 | } |
| 685 | 695 | |
| 696 | +void tEnvelopeFollower_free(tEnvelopeFollower* const e) | |
| 697 | +{ | |
| 698 | + | |
| 699 | +} | |
| 700 | + | |
| 686 | 701 | float tEnvelopeFollower_tick(tEnvelopeFollower* const ef, float x) |
| 687 | 702 | { |
| 688 | 703 | if (x < 0.0f ) x = -x; /* Absolute value. */ |
| @@ -729,6 +744,11 @@ void tRamp_init(tRamp* const ramp, float time, int samples_per_tick) · 40 unmodified lines | ||
| 729 | 744 | ramp->inc = ((ramp->dest - ramp->curr) / ramp->time * ramp->inv_sr_ms) * (float)ramp->samples_per_tick; |
| 730 | 745 | } |
| 731 | 746 | |
| 747 | +void tRamp_free(tRamp* const ramp) | |
| 748 | +{ | |
| 749 | + | |
| 750 | +} | |
| 751 | + | |
| 732 | 752 | int tRamp_setTime(tRamp* const r, float time) |
| 733 | 753 | { |
| 734 | 754 | if (time < r->minimum_time) |
| @@ -791,6 +811,11 @@ void tExpSmooth_init(tExpSmooth* const smooth, float val, float factor) · 56 unmodified lines | ||
| 791 | 811 | smooth->oneminusfactor=1.0f-factor; |
| 792 | 812 | } |
| 793 | 813 | |
| 814 | +void tExpSmooth_free(tExpSmooth* const smooth) | |
| 815 | +{ | |
| 816 | + | |
| 817 | +} | |
| 818 | + | |
| 794 | 819 | int tExpSmooth_setFactor(tExpSmooth* const smooth, float factor) |
| 795 | 820 | { // 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 |
| 796 | 821 | if (factor<0) |
| @@ -835,6 +860,11 @@ void tPwrFollow_init(tPwrFollow* const p, float factor) · 38 unmodified lines | ||
| 835 | 860 | p->oneminusfactor=1.0f-factor; |
| 836 | 861 | } |
| 837 | 862 | |
| 863 | +void tPwrFollow_free(tPwrFollow* const p) | |
| 864 | +{ | |
| 865 | + | |
| 866 | +} | |
| 867 | + | |
| 838 | 868 | int tPwrFollow_setFactor(tPwrFollow* const p, float factor) |
| 839 | 869 | { |
| 840 | 870 | if (factor<0) factor=0; |
| @@ -866,6 +896,11 @@ void tFBleveller_init(tFBleveller* const p, float targetLevel, float factor, · 25 unmodified lines | ||
| 866 | 896 | p->strength=strength; |
| 867 | 897 | } |
| 868 | 898 | |
| 899 | +void tFBleveller_free(tFBleveller* const p) | |
| 900 | +{ | |
| 901 | + tPwrFollow_free(&p->pwrFlw); | |
| 902 | +} | |
| 903 | + | |
| 869 | 904 | int tFBleveller_setStrength(tFBleveller* const p, float strength) |
| 870 | 905 | { // strength is how strongly level diff is affecting the amp ratio |
| 871 | 906 | // try 0.125 for a start |
| @@ -972,6 +1007,15 @@ void tSimpleLivingString_init(tSimpleLivingString* const p, float freq, float · 100 unmodified lines | ||
| 972 | 1007 | p->levMode=levMode; |
| 973 | 1008 | } |
| 974 | 1009 | |
| 1010 | +void tSimpleLivingString_free(tSimpleLivingString* const p) | |
| 1011 | +{ | |
| 1012 | + tExpSmooth_free(&p->wlSmooth); | |
| 1013 | + tDelayL_free(&p->delayLine); | |
| 1014 | + tOnePole_free(&p->bridgeFilter); | |
| 1015 | + tHighpass_free(&p->DCblocker); | |
| 1016 | + tFBleveller_free(&p->fbLev); | |
| 1017 | +} | |
| 1018 | + | |
| 975 | 1019 | int tSimpleLivingString_setFreq(tSimpleLivingString* const p, float freq) |
| 976 | 1020 | { |
| 977 | 1021 | if (freq<20) freq=20; |
| @@ -1068,6 +1112,24 @@ void tLivingString_init(tLivingString* const p, float freq, float pickPos, fl · 90 unmodified lines | ||
| 1068 | 1112 | p->levMode=levMode; |
| 1069 | 1113 | } |
| 1070 | 1114 | |
| 1115 | +void tLivingString_free(tLivingString* const p) | |
| 1116 | +{ | |
| 1117 | + tExpSmooth_free(&p->wlSmooth); | |
| 1118 | + tExpSmooth_free(&p->ppSmooth); | |
| 1119 | + tDelayL_free(&p->delLF); | |
| 1120 | + tDelayL_free(&p->delUF); | |
| 1121 | + tDelayL_free(&p->delUB); | |
| 1122 | + tDelayL_free(&p->delLB); | |
| 1123 | + tOnePole_free(&p->bridgeFilter); | |
| 1124 | + tOnePole_free(&p->nutFilter); | |
| 1125 | + tOnePole_free(&p->prepFilterU); | |
| 1126 | + tOnePole_free(&p->prepFilterL); | |
| 1127 | + tHighpass_free(&p->DCblockerU); | |
| 1128 | + tHighpass_free(&p->DCblockerL); | |
| 1129 | + tFBleveller_free(&p->fbLevU); | |
| 1130 | + tFBleveller_free(&p->fbLevL); | |
| 1131 | +} | |
| 1132 | + | |
| 1071 | 1133 | int tLivingString_setFreq(tLivingString* const p, float freq) |
| 1072 | 1134 | { // NOTE: It is faster to set wavelength in samples directly |
| 1073 | 1135 | if (freq<20) freq=20; |
| @@ -1189,6 +1251,21 @@ float tLivingString_sample(tLivingString* const p) · 115 unmodified lines | ||
| 1189 | 1251 | |
| 1190 | 1252 | /* Stack */ |
| 1191 | 1253 | |
| 1254 | +void tStack_init(tStack* const ns) | |
| 1255 | +{ | |
| 1256 | + ns->ordered = OFALSE; | |
| 1257 | + ns->size = 0; | |
| 1258 | + ns->pos = 0; | |
| 1259 | + ns->capacity = STACK_SIZE; | |
| 1260 | + | |
| 1261 | + for (int i = 0; i < STACK_SIZE; i++) ns->data[i] = -1; | |
| 1262 | +} | |
| 1263 | + | |
| 1264 | +void tStack_free(tStack* const ns) | |
| 1265 | +{ | |
| 1266 | + | |
| 1267 | +} | |
| 1268 | + | |
| 1192 | 1269 | // If stack contains note, returns index. Else returns -1; |
| 1193 | 1270 | int tStack_contains(tStack* const ns, uint16_t noteVal) |
| 1194 | 1271 | { |
| @@ -1382,17 +1459,6 @@ int tStack_first(tStack* const ns) · 187 unmodified lines | ||
| 1382 | 1459 | { |
| 1383 | 1460 | return ns->data[0]; |
| 1384 | 1461 | } |
| 1385 | − | |
| 1386 | −void tStack_init(tStack* const ns) | |
| 1387 | −{ | |
| 1388 | − ns->ordered = OFALSE; | |
| 1389 | − ns->size = 0; | |
| 1390 | − ns->pos = 0; | |
| 1391 | − ns->capacity = STACK_SIZE; | |
| 1392 | − | |
| 1393 | − for (int i = 0; i < STACK_SIZE; i++) ns->data[i] = -1; | |
| 1394 | −} | |
| 1395 | − | |
| 1396 | 1462 | /******************************************************************************/ |
| 1397 | 1463 | /***************** static function declarations *******************************/ |
| 1398 | 1464 | /******************************************************************************/ |
| @@ -1416,7 +1482,6 @@ void tSOLAD_init(tSOLAD* const w) · 17 unmodified lines | ||
| 1416 | 1482 | |
| 1417 | 1483 | void tSOLAD_free(tSOLAD* const w) |
| 1418 | 1484 | { |
| 1419 | − leaf_free(w); | |
| 1420 | 1485 | } |
| 1421 | 1486 | |
| 1422 | 1487 | // send one block of input samples, receive one block of output samples |
| @@ -1750,7 +1815,10 @@ void tSNAC_init(tSNAC* const s, int overlaparg) · 327 unmodified lines | ||
| 1750 | 1815 | |
| 1751 | 1816 | void tSNAC_free(tSNAC* const s) |
| 1752 | 1817 | { |
| 1753 | − leaf_free(s); | |
| 1818 | + leaf_free(s->inputbuf); | |
| 1819 | + leaf_free(s->processbuf); | |
| 1820 | + leaf_free(s->spectrumbuf); | |
| 1821 | + leaf_free(s->biasbuf); | |
| 1754 | 1822 | } |
| 1755 | 1823 | /******************************************************************************/ |
| 1756 | 1824 | /************************** public access functions****************************/ |
| @@ -2058,7 +2126,7 @@ void tAtkDtk_init_expanded(tAtkDtk* const a, int blocksize, int atk, int rel) · 301 unmodified lines | ||
| 2058 | 2126 | |
| 2059 | 2127 | void tAtkDtk_free(tAtkDtk *a) |
| 2060 | 2128 | { |
| 2061 | − leaf_free(a); | |
| 2129 | + | |
| 2062 | 2130 | } |
| 2063 | 2131 | |
| 2064 | 2132 | /*******Public Functions***********/ |
| @@ -51,8 +51,6 @@ void tTalkbox_free(tTalkbox* const v) · 50 unmodified lines | ||
| 51 | 51 | leaf_free(v->window); |
| 52 | 52 | leaf_free(v->buf0); |
| 53 | 53 | leaf_free(v->buf1); |
| 54 | − | |
| 55 | − leaf_free(v); | |
| 56 | 54 | } |
| 57 | 55 | |
| 58 | 56 | void tTalkbox_update(tTalkbox* const v) ///update internal parameters... |
| @@ -227,7 +225,6 @@ void tTalkbox_setQuality(tTalkbox* const v, float quality) · 168 unmodified lines | ||
| 227 | 225 | v->O = (int32_t)((0.0001f + 0.0004f * v->param[3]) * leaf.sampleRate); |
| 228 | 226 | } |
| 229 | 227 | |
| 230 | − | |
| 231 | 228 | void tVocoder_init (tVocoder* const v) |
| 232 | 229 | { |
| 233 | 230 | v->param[0] = 0.33f; //input select |
| @@ -242,6 +239,11 @@ void tVocoder_init (tVocoder* const v) · 8 unmodified lines | ||
| 242 | 239 | tVocoder_update(v); |
| 243 | 240 | } |
| 244 | 241 | |
| 242 | +void tVocoder_free (tVocoder* const v) | |
| 243 | +{ | |
| 244 | + | |
| 245 | +} | |
| 246 | + | |
| 245 | 247 | void tVocoder_update (tVocoder* const v) |
| 246 | 248 | { |
| 247 | 249 | float tpofs = 6.2831853f * leaf.invSampleRate; |
| @@ -23,6 +23,11 @@ void tLockhartWavefolder_init(tLockhartWavefolder* const w) · 22 unmodified lines | ||
| 23 | 23 | w->xn1 = 0.0f; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | +void tLockhardWavefolder_free(tLockhartWavefolder* const w) | |
| 27 | +{ | |
| 28 | + | |
| 29 | +} | |
| 30 | + | |
| 26 | 31 | double tLockhartWavefolderLambert(double x, double ln) |
| 27 | 32 | { |
| 28 | 33 | double thresh, w, expw, p, r, s, err; |
| @@ -19,8 +19,9 @@ · 18 unmodified lines | ||
| 19 | 19 | |
| 20 | 20 | #if _WIN32 || _WIN64 |
| 21 | 21 | |
| 22 | −#include ".\Inc\leaf-globals.h" | |
| 22 | +#include ".\Inc\leaf-global.h" | |
| 23 | 23 | #include ".\Inc\leaf-math.h" |
| 24 | +#include ".\Inc\leaf-mempool.h" | |
| 24 | 25 | #include ".\Inc\leaf-utilities.h" |
| 25 | 26 | #include ".\Inc\leaf-delay.h" |
| 26 | 27 | #include ".\Inc\leaf-filter.h" |
| @@ -40,8 +41,9 @@ · 13 unmodified lines | ||
| 40 | 41 | |
| 41 | 42 | #else |
| 42 | 43 | |
| 43 | −#include "./Inc/leaf-globals.h" | |
| 44 | +#include "./Inc/leaf-global.h" | |
| 44 | 45 | #include "./Inc/leaf-math.h" |
| 46 | +#include "./Inc/leaf-mempool.h" | |
| 45 | 47 | #include "./Inc/leaf-utilities.h" |
| 46 | 48 | #include "./Inc/leaf-delay.h" |
| 47 | 49 | #include "./Inc/leaf-filter.h" |
| @@ -23,7 +23,7 @@ · 22 unmodified lines | ||
| 23 | 23 | <FILE id="Hu4b98" name="trigtbl.h" compile="0" resource="0" file="../LEAF/Externals/trigtbl.h"/> |
| 24 | 24 | </GROUP> |
| 25 | 25 | <GROUP id="{0E2E673D-2AE5-AECB-4E28-A1EE29180BD2}" name="Inc"> |
| 26 | − <FILE id="xaaxl7" name="leaf-globals.h" compile="0" resource="0" file="../LEAF/Inc/leaf-globals.h"/> | |
| 26 | + <FILE id="IwBoc4" name="leaf-global.h" compile="0" resource="0" file="../LEAF/Inc/leaf-global.h"/> | |
| 27 | 27 | <FILE id="cmehFw" name="leaf-math.h" compile="0" resource="0" file="../LEAF/Inc/leaf-math.h"/> |
| 28 | 28 | <FILE id="XQTGHV" name="leaf-mempool.h" compile="0" resource="0" file="../LEAF/Inc/leaf-mempool.h"/> |
| 29 | 29 | <FILE id="k0yQ8k" name="leaf-808.h" compile="0" resource="0" file="../LEAF/Inc/leaf-808.h"/> |