Unified · Split
| @@ -1,19 +1,20 @@ | ||
| 1 | −/* | |
| 2 | − ============================================================================== | |
| 1 | +/*============================================================================== | |
| 3 | 2 | |
| 4 | 3 | leaf_808.h |
| 5 | 4 | Created: 30 Nov 2018 10:24:44am |
| 6 | 5 | Author: airship |
| 7 | 6 | |
| 8 | − ============================================================================== | |
| 9 | −*/ | |
| 10 | − | |
| 11 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 7 | +==============================================================================*/ | |
| 8 | + | |
| 9 | +#ifndef LEAF_808_H_INCLUDED | |
| 10 | +#define LEAF_808_H_INCLUDED | |
| 12 | 11 | |
| 13 | 12 | #ifdef __cplusplus |
| 14 | 13 | extern "C" { |
| 15 | −#endif | |
| 16 | − | |
| 14 | +#endif | |
| 15 | + | |
| 16 | +//============================================================================== | |
| 17 | + | |
| 17 | 18 | #include "leaf-globals.h" |
| 18 | 19 | #include "leaf-math.h" |
| 19 | 20 | |
| @@ -21,10 +22,8 @@ extern "C" { · 1 unmodified line | ||
| 21 | 22 | #include "leaf-utilities.h" |
| 22 | 23 | #include "leaf-filter.h" |
| 23 | 24 | |
| 24 | − | |
| 25 | − | |
| 26 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 27 | − | |
| 25 | +//============================================================================== | |
| 26 | + | |
| 28 | 27 | // 808 Cowbell |
| 29 | 28 | typedef struct _t808Cowbell { |
| 30 | 29 | |
| @@ -51,9 +50,8 @@ void t808Cowbell_setBandpassFreq (t808Cowbell* const, float freq); · 20 unmodified lines | ||
| 51 | 50 | void t808Cowbell_setFreq (t808Cowbell* const, float freq); |
| 52 | 51 | void t808Cowbell_setOscMix (t808Cowbell* const, float oscMix); |
| 53 | 52 | |
| 54 | − | |
| 55 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 56 | − | |
| 53 | +//============================================================================== | |
| 54 | + | |
| 57 | 55 | // 808 Hihat |
| 58 | 56 | typedef struct _t808Hihat { |
| 59 | 57 | |
| @@ -90,9 +88,9 @@ void t808Hihat_setStickBandPassQ (t808Hihat* const hihat, float Q); · 30 unmodified lines | ||
| 90 | 88 | void t808Hihat_setOscFreq (t808Hihat* const, float freq); |
| 91 | 89 | void t808Hihat_setStretch (t808Hihat* const hihat, float stretch); |
| 92 | 90 | void t808Hihat_setFM (t808Hihat* const hihat, float FM_amount); |
| 93 | − | |
| 94 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 95 | − | |
| 91 | + | |
| 92 | +//============================================================================== | |
| 93 | + | |
| 96 | 94 | // 808 Snare |
| 97 | 95 | typedef struct _t808Snare { |
| 98 | 96 | |
| @@ -133,8 +131,8 @@ void t808Snare_setToneNoiseMix (t808Snare* const, float toneNoiseMi · 34 unmodified lines | ||
| 133 | 131 | void t808Snare_setNoiseFilterFreq (t808Snare* const, float noiseFilterFreq); |
| 134 | 132 | void t808Snare_setNoiseFilterQ (t808Snare* const, float noiseFilterQ); |
| 135 | 133 | |
| 136 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 137 | − | |
| 134 | +//============================================================================== | |
| 135 | + | |
| 138 | 136 | // 808 Kick |
| 139 | 137 | typedef struct _t808Kick { |
| 140 | 138 | |
| @@ -173,9 +171,14 @@ void t808Kick_setToneNoiseMix (t808Kick* const, float toneNoiseMix) · 32 unmodified lines | ||
| 173 | 171 | void t808Kick_setNoiseFilterFreq (t808Kick* const, float noiseFilterFreq); |
| 174 | 172 | void t808Kick_setNoiseFilterQ (t808Kick* const, float noiseFilterQ); |
| 175 | 173 | |
| 174 | +//============================================================================== | |
| 175 | + | |
| 176 | 176 | #ifdef __cplusplus |
| 177 | 177 | } |
| 178 | −#endif | |
| 178 | +#endif | |
| 179 | + | |
| 180 | +#endif // LEAF_808_H_INCLUDED | |
| 181 | + | |
| 182 | +//============================================================================== | |
| 179 | 183 | |
| 180 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 181 | 184 | |
| @@ -1,27 +1,25 @@ | ||
| 1 | −/* | |
| 2 | − ============================================================================== | |
| 1 | +/*============================================================================== | |
| 3 | 2 | |
| 4 | 3 | LEAFDelay.h |
| 5 | 4 | Created: 20 Jan 2017 12:01:24pm |
| 6 | 5 | Author: Michael R Mulshine |
| 7 | 6 | |
| 8 | − ============================================================================== | |
| 9 | −*/ | |
| 7 | +==============================================================================*/ | |
| 10 | 8 | |
| 11 | −#ifndef LEAFDELAY_H_INCLUDED | |
| 12 | −#define LEAFDELAY_H_INCLUDED | |
| 9 | +#ifndef LEAF_DELAY_H_INCLUDED | |
| 10 | +#define LEAF_DELAY_H_INCLUDED | |
| 13 | 11 | |
| 14 | 12 | #ifdef __cplusplus |
| 15 | 13 | extern "C" { |
| 16 | 14 | #endif |
| 17 | 15 | |
| 18 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 19 | − | |
| 16 | +//============================================================================== | |
| 17 | + | |
| 20 | 18 | #include "leaf-globals.h" |
| 21 | 19 | #include "leaf-math.h" |
| 22 | 20 | |
| 23 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 24 | − | |
| 21 | +//============================================================================== | |
| 22 | + | |
| 25 | 23 | /* Non-interpolating delay, reimplemented from STK (Cook and Scavone). */ |
| 26 | 24 | typedef struct _tDelay |
| 27 | 25 | { |
| @@ -48,9 +46,8 @@ float tDelay_tick (tDelay* const, float sample); · 20 unmodified lines | ||
| 48 | 46 | float tDelay_getLastOut (tDelay* const); |
| 49 | 47 | float tDelay_getLastIn (tDelay* const); |
| 50 | 48 | |
| 51 | − | |
| 52 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 53 | − | |
| 49 | +//============================================================================== | |
| 50 | + | |
| 54 | 51 | /* Linearly-interpolating delay, reimplemented from STK (Cook and Scavone). */ |
| 55 | 52 | typedef struct _tDelayL |
| 56 | 53 | { |
| @@ -81,8 +78,8 @@ float tDelayL_tick (tDelayL* const, float sample); · 24 unmodified lines | ||
| 81 | 78 | float tDelayL_getLastOut (tDelayL* const); |
| 82 | 79 | float tDelayL_getLastIn (tDelayL* const); |
| 83 | 80 | |
| 84 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 85 | − | |
| 81 | +//============================================================================== | |
| 82 | + | |
| 86 | 83 | /* Allpass-interpolating delay, reimplemented from STK (Cook and Scavone). */ |
| 87 | 84 | typedef struct _tDelayA |
| 88 | 85 | { |
| @@ -115,8 +112,8 @@ float tDelayA_tick (tDelayA* const, float sample); · 26 unmodified lines | ||
| 115 | 112 | float tDelayA_getLastOut (tDelayA* const); |
| 116 | 113 | float tDelayA_getLastIn (tDelayA* const); |
| 117 | 114 | |
| 118 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 119 | − | |
| 115 | +//============================================================================== | |
| 116 | + | |
| 120 | 117 | /* Linear interpolating delay with fixed read and write pointers, variable rate. */ |
| 121 | 118 | typedef struct _tTapeDelay |
| 122 | 119 | { |
| @@ -147,8 +144,12 @@ float tTapeDelay_tick (tTapeDelay* const, float sample); · 24 unmodified lines | ||
| 147 | 144 | float tTapeDelay_getLastOut (tTapeDelay* const); |
| 148 | 145 | float tTapeDelay_getLastIn (tTapeDelay* const); |
| 149 | 146 | |
| 147 | +//============================================================================== | |
| 148 | + | |
| 150 | 149 | #ifdef __cplusplus |
| 151 | 150 | } |
| 152 | 151 | #endif |
| 153 | 152 | |
| 154 | −#endif // LEAFDELAY_H_INCLUDED | |
| 153 | +#endif // LEAF_DELAY_H_INCLUDED | |
| 154 | + | |
| 155 | +//============================================================================== | |
| @@ -1,22 +1,20 @@ | ||
| 1 | −/* | |
| 2 | − ============================================================================== | |
| 1 | +/*============================================================================== | |
| 3 | 2 | |
| 4 | 3 | LEAFFilter.h |
| 5 | 4 | Created: 20 Jan 2017 12:01:10pm |
| 6 | 5 | Author: Michael R Mulshine |
| 7 | 6 | |
| 8 | − ============================================================================== | |
| 9 | −*/ | |
| 7 | +==============================================================================*/ | |
| 10 | 8 | |
| 11 | −#ifndef LEAFFILTER_H_INCLUDED | |
| 12 | −#define LEAFFILTER_H_INCLUDED | |
| 9 | +#ifndef LEAF_FILTER_H_INCLUDED | |
| 10 | +#define LEAF_FILTER_H_INCLUDED | |
| 13 | 11 | |
| 14 | 12 | #ifdef __cplusplus |
| 15 | 13 | extern "C" { |
| 16 | 14 | #endif |
| 17 | 15 | |
| 18 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 19 | − | |
| 16 | +//============================================================================== | |
| 17 | + | |
| 20 | 18 | #include "leaf-globals.h" |
| 21 | 19 | #include "leaf-math.h" |
| 22 | 20 | |
| @@ -24,8 +22,8 @@ extern "C" { · 1 unmodified line | ||
| 24 | 22 | |
| 25 | 23 | #include "leaf-wavetables.h" |
| 26 | 24 | |
| 27 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 28 | − | |
| 25 | +//============================================================================== | |
| 26 | + | |
| 29 | 27 | /* tAllpass: Schroeder allpass. Comb-filter with feedforward and feedback. */ |
| 30 | 28 | typedef struct _tAllpass |
| 31 | 29 | { |
| @@ -45,8 +43,8 @@ void tAllpass_setGain (tAllpass* const, float gain); · 13 unmodified lines | ||
| 45 | 43 | void tAllpass_setDelay (tAllpass* const f, float delay); |
| 46 | 44 | |
| 47 | 45 | |
| 48 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 49 | − | |
| 46 | +//============================================================================== | |
| 47 | + | |
| 50 | 48 | /* tOnePole: OnePole filter, reimplemented from STK (Cook and Scavone). */ |
| 51 | 49 | typedef struct _tOnePole |
| 52 | 50 | { |
| @@ -73,9 +71,8 @@ void tOnePole_setFreq (tOnePole* const, float freq); · 20 unmodified lines | ||
| 73 | 71 | void tOnePole_setCoefficients(tOnePole* const, float b0, float a1); |
| 74 | 72 | void tOnePole_setGain (tOnePole* const, float gain); |
| 75 | 73 | |
| 76 | − | |
| 77 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 78 | − | |
| 74 | +//============================================================================== | |
| 75 | + | |
| 79 | 76 | /* TwoPole filter, reimplemented from STK (Cook and Scavone). */ |
| 80 | 77 | typedef struct _tTwoPole |
| 81 | 78 | { |
| @@ -100,10 +97,9 @@ void tTwoPole_setA2 (tTwoPole* const, float a2); · 18 unmodified lines | ||
| 100 | 97 | void tTwoPole_setResonance (tTwoPole* const, float freq, float radius, oBool normalize); |
| 101 | 98 | void tTwoPole_setCoefficients(tTwoPole* const, float b0, float a1, float a2); |
| 102 | 99 | void tTwoPole_setGain (tTwoPole* const, float gain); |
| 103 | − | |
| 104 | − | |
| 105 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 106 | 100 | |
| 101 | +//============================================================================== | |
| 102 | + | |
| 107 | 103 | /* OneZero filter, reimplemented from STK (Cook and Scavone). */ |
| 108 | 104 | typedef struct _tOneZero |
| 109 | 105 | { |
| @@ -123,9 +119,8 @@ void tOneZero_setCoefficients(tOneZero* const, float b0, float b1); · 13 unmodified lines | ||
| 123 | 119 | void tOneZero_setGain (tOneZero* const, float gain); |
| 124 | 120 | float tOneZero_getPhaseDelay(tOneZero *f, float frequency ); |
| 125 | 121 | |
| 126 | − | |
| 127 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 128 | − | |
| 122 | +//============================================================================== | |
| 123 | + | |
| 129 | 124 | /* TwoZero filter, reimplemented from STK (Cook and Scavone). */ |
| 130 | 125 | typedef struct _tTwoZero |
| 131 | 126 | { |
| @@ -149,9 +144,8 @@ void tTwoZero_setNotch (tTwoZero* const, float frequency, float ra · 17 unmodified lines | ||
| 149 | 144 | void tTwoZero_setCoefficients(tTwoZero* const, float b0, float b1, float b2); |
| 150 | 145 | void tTwoZero_setGain (tTwoZero* const, float gain); |
| 151 | 146 | |
| 152 | − | |
| 153 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 154 | − | |
| 147 | +//============================================================================== | |
| 148 | + | |
| 155 | 149 | /* PoleZero filter, reimplemented from STK (Cook and Scavone). */ |
| 156 | 150 | typedef struct _tPoleZero |
| 157 | 151 | { |
| @@ -175,9 +169,8 @@ void tPoleZero_setAllpass (tPoleZero* const, float coeff); · 17 unmodified lines | ||
| 175 | 169 | void tPoleZero_setBlockZero (tPoleZero* const, float thePole); |
| 176 | 170 | void tPoleZero_setGain (tPoleZero* const, float gain); |
| 177 | 171 | |
| 178 | − | |
| 179 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 180 | − | |
| 172 | +//============================================================================== | |
| 173 | + | |
| 181 | 174 | /* BiQuad filter, reimplemented from STK (Cook and Scavone). */ |
| 182 | 175 | typedef struct _tBiQuad |
| 183 | 176 | { |
| @@ -206,9 +199,8 @@ void tBiQuad_setResonance (tBiQuad* const, float freq, float radius, o · 22 unmodified lines | ||
| 206 | 199 | void tBiQuad_setCoefficients(tBiQuad* const, float b0, float b1, float b2, float a1, float a2); |
| 207 | 200 | void tBiQuad_setGain (tBiQuad* const, float gain); |
| 208 | 201 | |
| 209 | − | |
| 210 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 211 | − | |
| 202 | +//============================================================================== | |
| 203 | + | |
| 212 | 204 | /* State Variable Filter, algorithm from Andy Simper. */ |
| 213 | 205 | typedef enum SVFType |
| 214 | 206 | { |
| @@ -235,9 +227,8 @@ float tSVF_tick (tSVF* const, float v0); · 20 unmodified lines | ||
| 235 | 227 | int tSVF_setFreq (tSVF* const, float freq); |
| 236 | 228 | int tSVF_setQ (tSVF* const, float Q); |
| 237 | 229 | |
| 238 | − | |
| 239 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 240 | − | |
| 230 | +//============================================================================== | |
| 231 | + | |
| 241 | 232 | /* Efficient State Variable Filter for 14-bit control input, [0, 4096). */ |
| 242 | 233 | typedef struct _tSVFE |
| 243 | 234 | { |
| @@ -255,9 +246,8 @@ float tSVFE_tick (tSVFE* const, float v0); · 11 unmodified lines | ||
| 255 | 246 | int tSVFE_setFreq (tSVFE* const, uint16_t controlFreq); |
| 256 | 247 | int tSVFE_setQ (tSVFE* const, float Q); |
| 257 | 248 | |
| 258 | − | |
| 259 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 260 | − | |
| 249 | +//============================================================================== | |
| 250 | + | |
| 261 | 251 | /* Simple Highpass filter. */ |
| 262 | 252 | typedef struct _tHighpass |
| 263 | 253 | { |
| @@ -273,9 +263,8 @@ float tHighpass_tick (tHighpass* const, float x); · 9 unmodified lines | ||
| 273 | 263 | void tHighpass_setFreq (tHighpass* const, float freq); |
| 274 | 264 | float tHighpass_getFreq (tHighpass* const); |
| 275 | 265 | |
| 276 | − | |
| 277 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 278 | − | |
| 266 | +//============================================================================== | |
| 267 | + | |
| 279 | 268 | // Butterworth Filter |
| 280 | 269 | #define NUM_SVF_BW 16 |
| 281 | 270 | typedef struct _tButterworth |
| @@ -299,10 +288,12 @@ void tButterworth_setF1 (tButterworth* const, float in); · 17 unmodified lines | ||
| 299 | 288 | void tButterworth_setF2 (tButterworth* const, float in); |
| 300 | 289 | void tButterworth_setFreqs (tButterworth* const, float f1, float f2); |
| 301 | 290 | |
| 302 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 291 | +//============================================================================== | |
| 303 | 292 | |
| 304 | 293 | #ifdef __cplusplus |
| 305 | 294 | } |
| 306 | 295 | #endif |
| 307 | 296 | |
| 308 | −#endif // LEAFFILTER_H_INCLUDED | |
| 297 | +#endif // LEAF_FILTER_H_INCLUDED | |
| 298 | + | |
| 299 | +//============================================================================== | |
| @@ -1,24 +1,25 @@ | ||
| 1 | −/* | |
| 2 | − ============================================================================== | |
| 1 | +/*============================================================================== | |
| 3 | 2 | |
| 4 | 3 | leaf-formant.h |
| 5 | 4 | Created: 30 Nov 2018 11:03:37am |
| 6 | 5 | Author: airship |
| 7 | 6 | |
| 8 | − ============================================================================== | |
| 9 | −*/ | |
| 7 | +==============================================================================*/ | |
| 8 | + | |
| 9 | +#ifndef LEAF_FORMANT_H_INCLUDED | |
| 10 | +#define LEAF_FORMANT_H_INCLUDED | |
| 10 | 11 | |
| 11 | 12 | #ifdef __cplusplus |
| 12 | 13 | extern "C" { |
| 13 | 14 | #endif |
| 14 | 15 | |
| 15 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 16 | − | |
| 16 | +//============================================================================== | |
| 17 | + | |
| 17 | 18 | #include "leaf-globals.h" |
| 18 | 19 | #include "leaf-math.h" |
| 19 | 20 | |
| 20 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 21 | − | |
| 21 | +//============================================================================== | |
| 22 | + | |
| 22 | 23 | #define FORD 7 |
| 23 | 24 | #define FORMANT_BUFFER_SIZE 2048 |
| 24 | 25 | |
| @@ -51,11 +52,15 @@ void tFormantShifter_free (tFormantShifter* const); · 26 unmodified lines | ||
| 51 | 52 | float tFormantShifter_tick (tFormantShifter* const, float input, float fwarp); |
| 52 | 53 | float tFormantShifter_remove (tFormantShifter* const, float input); |
| 53 | 54 | float tFormantShifter_add (tFormantShifter* const, float input, float fwarp); |
| 54 | −void tFormantShifter_ioSamples (tFormantShifter* const, float* in, float* out, int size, float fwarp); | |
| 55 | − | |
| 56 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 55 | +void tFormantShifter_ioSamples (tFormantShifter* const, float* in, float* out, int size, float fwarp); | |
| 56 | + | |
| 57 | +//============================================================================== | |
| 57 | 58 | |
| 58 | 59 | #ifdef __cplusplus |
| 59 | 60 | } |
| 60 | −#endif | |
| 61 | +#endif | |
| 62 | + | |
| 63 | +#endif // LEAF_FORMANT_H_INCLUDED | |
| 64 | + | |
| 65 | +//============================================================================== | |
| 61 | 66 | |
| @@ -1,40 +1,45 @@ | ||
| 1 | −/* | |
| 2 | − ============================================================================== | |
| 1 | +/*============================================================================== | |
| 3 | 2 | |
| 4 | 3 | leaf-globals.h |
| 5 | 4 | Created: 23 Jan 2017 10:34:10pm |
| 6 | 5 | Author: Michael R Mulshine |
| 7 | 6 | |
| 8 | − ============================================================================== | |
| 9 | −*/ | |
| 7 | +==============================================================================*/ | |
| 10 | 8 | |
| 11 | −#ifndef OPPSGLOBALS_H_INCLUDED | |
| 12 | −#define OPPSGLOBALS_H_INCLUDED | |
| 13 | − | |
| 14 | −/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | |
| 15 | − * * | |
| 16 | − * If your application requires use of many instances of one component or is facing memory limitations, * | |
| 17 | − * use this set of defines to increase or limit the number of instances of each component. The library * | |
| 18 | − * will pre-allocate only the number of instances defined here. * | |
| 19 | − * * | |
| 20 | − * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | |
| 21 | − | |
| 22 | −#include "leaf-mempool.h" | |
| 9 | +#ifndef LEAF_GLOBALS_H_INCLUDED | |
| 10 | +#define LEAF_GLOBALS_H_INCLUDED | |
| 23 | 11 | |
| 24 | 12 | #ifdef __cplusplus |
| 25 | 13 | extern "C" { |
| 26 | 14 | #endif |
| 15 | + | |
| 16 | +//============================================================================== | |
| 17 | + | |
| 18 | +#include "leaf-mempool.h" | |
| 19 | + | |
| 20 | +//============================================================================== | |
| 27 | 21 | |
| 28 | 22 | typedef struct _LEAF |
| 29 | 23 | { |
| 30 | 24 | float sampleRate; |
| 31 | 25 | float invSampleRate; |
| 32 | 26 | int blockSize; |
| 33 | − | |
| 27 | + | |
| 28 | + /* | |
| 29 | + float* sinewave; | |
| 30 | + float* sawtooth[11]; | |
| 31 | + float* square[11]; | |
| 32 | + float* triangle[11]; | |
| 33 | + */ | |
| 34 | + | |
| 34 | 35 | float (*random)(void); |
| 35 | −} LEAF; | |
| 36 | +} LEAF; | |
| 37 | + | |
| 38 | +//============================================================================== | |
| 36 | 39 | |
| 37 | −extern LEAF leaf; | |
| 40 | +extern LEAF leaf; // The global instance of LEAF. | |
| 41 | + | |
| 42 | +//============================================================================== | |
| 38 | 43 | |
| 39 | 44 | #define SHAPER1_TABLE_SIZE 65536 |
| 40 | 45 | extern const float shaper1[SHAPER1_TABLE_SIZE]; |
| @@ -54,8 +59,13 @@ extern const float shaper1[SHAPER1_TABLE_SIZE]; · 13 unmodified lines | ||
| 54 | 59 | |
| 55 | 60 | #define TALKBOX_BUFFER_LENGTH 1600 // Every talkbox instance introduces 5 buffers of this size |
| 56 | 61 | |
| 62 | + | |
| 63 | +//============================================================================== | |
| 64 | + | |
| 57 | 65 | #ifdef __cplusplus |
| 58 | 66 | } |
| 59 | 67 | #endif |
| 60 | 68 | |
| 61 | −#endif // OPPSGLOBALS_H_INCLUDED | |
| 69 | +#endif // LEAF_GLOBALS_H_INCLUDED | |
| 70 | + | |
| 71 | +//============================================================================== | |
| @@ -1,23 +1,23 @@ | ||
| 1 | −/* | |
| 2 | − ============================================================================== | |
| 1 | +/*============================================================================== | |
| 3 | 2 | |
| 4 | 3 | LEAFMath.h |
| 5 | 4 | Created: 22 Jan 2017 7:02:56pm |
| 6 | 5 | Author: Michael R Mulshine |
| 7 | 6 | |
| 8 | − ============================================================================== | |
| 9 | −*/ | |
| 7 | +==============================================================================*/ | |
| 10 | 8 | |
| 11 | −#ifndef LEAFMATH_H_INCLUDED | |
| 12 | −#define LEAFMATH_H_INCLUDED | |
| 9 | +#ifndef LEAF_MATH_H_INCLUDED | |
| 10 | +#define LEAF_MATH_H_INCLUDED | |
| 11 | + | |
| 12 | +#ifdef __cplusplus | |
| 13 | +extern "C" { | |
| 14 | +#endif | |
| 13 | 15 | |
| 14 | 16 | #include "math.h" |
| 15 | 17 | #include "stdint.h" |
| 16 | 18 | #include "stdlib.h" |
| 17 | 19 | |
| 18 | −#ifdef __cplusplus | |
| 19 | −extern "C" { | |
| 20 | −#endif | |
| 20 | +//============================================================================== | |
| 21 | 21 | |
| 22 | 22 | typedef enum oBool |
| 23 | 23 | { |
| @@ -78,8 +78,9 @@ typedef enum oBool · 54 unmodified lines | ||
| 78 | 78 | float LEAF_shaper (float input, float m_drive); |
| 79 | 79 | float LEAF_reedTable (float input, float offset, float slope); |
| 80 | 80 | |
| 81 | −float LEAF_clip (float min, float val, float max); | |
| 82 | −float LEAF_softClip (float val, float thresh); | |
| 81 | +float LEAF_clip (float min, float val, float max); | |
| 82 | +int LEAF_clipInt (int min, int val, int max); | |
| 83 | +float LEAF_softClip (float val, float thresh); | |
| 83 | 84 | oBool LEAF_isPrime (uint64_t number ); |
| 84 | 85 | |
| 85 | 86 | float LEAF_midiToFrequency (float f); |
| @@ -110,9 +111,12 @@ int fastabs_int(int in); · 24 unmodified lines | ||
| 110 | 111 | // REQUIRES: 32 bit floats |
| 111 | 112 | float fastabs(float f); |
| 112 | 113 | |
| 114 | +//============================================================================== | |
| 113 | 115 | |
| 114 | 116 | #ifdef __cplusplus |
| 115 | 117 | } |
| 116 | 118 | #endif |
| 117 | 119 | |
| 118 | −#endif // LEAFMATH_H_INCLUDED | |
| 120 | +#endif // LEAF_MATH_H_INCLUDED | |
| 121 | + | |
| 122 | +//============================================================================== | |
| @@ -1,4 +1,5 @@ | ||
| 1 | −/** | |
| 1 | +/*============================================================================== | |
| 2 | + | |
| 2 | 3 | In short, mpool is distributed under so called "BSD license", |
| 3 | 4 | |
| 4 | 5 | Copyright (c) 2009-2010 Tatsuhiko Kubo <cubicdaiya@gmail.com> |
| @@ -28,25 +29,29 @@ · 23 unmodified lines | ||
| 28 | 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 29 | 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 30 | 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 31 | − SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 32 | −*/ | |
| 33 | − | |
| 34 | −/* written by C99 style */ | |
| 32 | + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 33 | + | |
| 34 | + written by C99 style | |
| 35 | +==============================================================================*/ | |
| 35 | 36 | |
| 36 | −#ifndef MPOOL_H | |
| 37 | −#define MPOOL_H | |
| 37 | +#ifndef LEAF_MPOOL_H_INCLUDED | |
| 38 | +#define LEAF_MPOOL_H_INCLUDED | |
| 39 | + | |
| 40 | +#ifdef __cplusplus | |
| 41 | +extern "C" { | |
| 42 | +#endif | |
| 43 | + | |
| 44 | +//============================================================================== | |
| 38 | 45 | |
| 39 | 46 | #include <stdio.h> |
| 40 | 47 | #include <stdlib.h> |
| 41 | 48 | #include <string.h> |
| 42 | −#include <stdbool.h> | |
| 49 | +#include <stdbool.h> | |
| 50 | + | |
| 51 | +//============================================================================== | |
| 43 | 52 | |
| 44 | −#define MPOOL_POOL_SIZE 500000 | |
| 53 | +#define MPOOL_POOL_SIZE 1000000 | |
| 45 | 54 | #define MPOOL_ALIGN_SIZE (8) |
| 46 | − | |
| 47 | −#ifdef __cplusplus | |
| 48 | −extern "C" { | |
| 49 | −#endif | |
| 50 | 55 | |
| 51 | 56 | //#define size_t unsigned long |
| 52 | 57 | |
| @@ -68,7 +73,6 @@ typedef struct mpool_t { · 15 unmodified lines | ||
| 68 | 73 | int next; |
| 69 | 74 | } mpool_t; |
| 70 | 75 | |
| 71 | − | |
| 72 | 76 | void mpool_create (size_t size, mpool_t* pool); |
| 73 | 77 | |
| 74 | 78 | void *mpool_alloc(size_t size, mpool_t* pool); |
| @@ -86,12 +90,16 @@ void leaf_free(void* ptr); · 11 unmodified lines | ||
| 86 | 90 | size_t leaf_pool_get_size(void); |
| 87 | 91 | size_t leaf_pool_get_used(void); |
| 88 | 92 | |
| 89 | −void* leaf_pool_get_pool(void); | |
| 93 | +void* leaf_pool_get_pool(void); | |
| 94 | + | |
| 95 | +//============================================================================== | |
| 90 | 96 | |
| 91 | 97 | #ifdef __cplusplus |
| 92 | 98 | } |
| 93 | 99 | #endif |
| 94 | 100 | |
| 95 | −#endif | |
| 101 | +#endif // LEAF_MPOOL_H | |
| 102 | + | |
| 103 | +//============================================================================== | |
| 96 | 104 | |
| 97 | 105 | |
| @@ -1,26 +1,27 @@ | ||
| 1 | −/* | |
| 2 | − ============================================================================== | |
| 1 | +/*============================================================================== | |
| 3 | 2 | |
| 4 | 3 | leaf-midi.h |
| 5 | 4 | Created: 30 Nov 2018 11:29:26am |
| 6 | 5 | Author: airship |
| 7 | 6 | |
| 8 | − ============================================================================== | |
| 9 | −*/ | |
| 7 | +==============================================================================*/ | |
| 8 | + | |
| 9 | +#ifndef LEAF_MIDI_H_INCLUDED | |
| 10 | +#define LEAF_MIDI_H_INCLUDED | |
| 10 | 11 | |
| 11 | 12 | #ifdef __cplusplus |
| 12 | 13 | extern "C" { |
| 13 | 14 | #endif |
| 14 | 15 | |
| 15 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 16 | − | |
| 16 | +//============================================================================== | |
| 17 | + | |
| 17 | 18 | #include "leaf-globals.h" |
| 18 | 19 | #include "leaf-math.h" |
| 19 | 20 | |
| 20 | 21 | #include "leaf-utilities.h" |
| 21 | 22 | |
| 22 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 23 | − | |
| 23 | +//============================================================================== | |
| 24 | + | |
| 24 | 25 | typedef struct _tMidiNote |
| 25 | 26 | { |
| 26 | 27 | uint8_t pitch; |
| @@ -38,8 +39,8 @@ typedef struct _tMidiNode · 11 unmodified lines | ||
| 38 | 39 | |
| 39 | 40 | } tMidiNode; |
| 40 | 41 | |
| 41 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 42 | − | |
| 42 | +//============================================================================== | |
| 43 | + | |
| 43 | 44 | /* Polyphonic Handler */ |
| 44 | 45 | typedef struct _tPoly |
| 45 | 46 | { |
| @@ -56,8 +57,8 @@ tMidiNote* tPoly_getMidiNote(tPoly* const, int8_t voiceIndex); · 10 unmodified lines | ||
| 56 | 57 | void tPoly_noteOn(tPoly* poly, int midiNoteNumber, float velocity); |
| 57 | 58 | void tPoly_noteOff(tPoly* poly, int midiNoteNumber); |
| 58 | 59 | |
| 59 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 60 | − | |
| 60 | +//============================================================================== | |
| 61 | + | |
| 61 | 62 | /* tMPoly */ |
| 62 | 63 | typedef struct _tMPoly |
| 63 | 64 | { |
| @@ -110,9 +111,13 @@ float tMPoly_getPitch(tMPoly* const, uint8_t voice); · 46 unmodified lines | ||
| 110 | 111 | int tMPoly_getVelocity(tMPoly* const, uint8_t voice); |
| 111 | 112 | int tMPoly_isOn(tMPoly* const, uint8_t voice); |
| 112 | 113 | |
| 113 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 114 | +//============================================================================== | |
| 114 | 115 | |
| 115 | 116 | #ifdef __cplusplus |
| 116 | 117 | } |
| 117 | −#endif | |
| 118 | +#endif | |
| 119 | + | |
| 120 | +#endif // LEAF_MIDI_H_INCLUDED | |
| 121 | + | |
| 122 | +//============================================================================== | |
| 118 | 123 | |
| @@ -1,28 +1,26 @@ | ||
| 1 | −/* | |
| 2 | − ============================================================================== | |
| 1 | +/*============================================================================== | |
| 3 | 2 | |
| 4 | 3 | LEAFOscillator.h |
| 5 | 4 | Created: 20 Jan 2017 12:00:58pm |
| 6 | 5 | Author: Michael R Mulshine |
| 7 | 6 | |
| 8 | − ============================================================================== | |
| 9 | −*/ | |
| 7 | +==============================================================================*/ | |
| 10 | 8 | |
| 11 | −#ifndef LEAFOSCILLATOR_H_INCLUDED | |
| 12 | −#define LEAFOSCILLATOR_H_INCLUDED | |
| 9 | +#ifndef LEAF_OSCILLATOR_H_INCLUDED | |
| 10 | +#define LEAF_OSCILLATOR_H_INCLUDED | |
| 13 | 11 | |
| 14 | 12 | #ifdef __cplusplus |
| 15 | 13 | extern "C" { |
| 16 | 14 | #endif |
| 17 | 15 | |
| 18 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 16 | +//============================================================================== | |
| 19 | 17 | |
| 20 | 18 | #include "leaf-globals.h" |
| 21 | 19 | #include "leaf-math.h" |
| 22 | 20 | |
| 23 | 21 | #include "leaf-filter.h" |
| 24 | 22 | |
| 25 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 23 | +//============================================================================== | |
| 26 | 24 | |
| 27 | 25 | /* tNeuron */ |
| 28 | 26 | typedef enum NeuronMode |
| @@ -66,7 +64,7 @@ void tNeuron_setV2 (tNeuron* const, float V2); · 37 unmodified lines | ||
| 66 | 64 | void tNeuron_setV3 (tNeuron* const, float V3); |
| 67 | 65 | void tNeuron_setTimeStep (tNeuron* const, float timestep); |
| 68 | 66 | |
| 69 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 67 | +//============================================================================== | |
| 70 | 68 | |
| 71 | 69 | /* tPhasor: Aliasing phasor [0.0, 1.0) */ |
| 72 | 70 | typedef struct _tPhasor |
| @@ -82,7 +80,7 @@ void tPhasor_free (tPhasor* const); · 9 unmodified lines | ||
| 82 | 80 | float tPhasor_tick (tPhasor* const); |
| 83 | 81 | int tPhasor_setFreq (tPhasor* const, float freq); |
| 84 | 82 | |
| 85 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 83 | +//============================================================================== | |
| 86 | 84 | |
| 87 | 85 | /* tCycle: Cycle/Sine waveform. Wavetable synthesis.*/ |
| 88 | 86 | typedef struct _tCycle |
| @@ -99,7 +97,7 @@ void tCycle_free (tCycle* const); · 10 unmodified lines | ||
| 99 | 97 | float tCycle_tick (tCycle* const); |
| 100 | 98 | int tCycle_setFreq (tCycle* const, float freq); |
| 101 | 99 | |
| 102 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 100 | +//============================================================================== | |
| 103 | 101 | |
| 104 | 102 | /* tSawtooth: Anti-aliased Sawtooth waveform using wavetable interpolation. Wavetables constructed from sine components. */ |
| 105 | 103 | typedef struct _tSawtooth |
| @@ -116,7 +114,7 @@ void tSawtooth_free (tSawtooth* const); · 10 unmodified lines | ||
| 116 | 114 | float tSawtooth_tick (tSawtooth* const); |
| 117 | 115 | int tSawtooth_setFreq (tSawtooth* const, float freq); |
| 118 | 116 | |
| 119 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 117 | +//============================================================================== | |
| 120 | 118 | |
| 121 | 119 | /* tTriangle: Anti-aliased Triangle waveform using wavetable interpolation. Wavetables constructed from sine components. */ |
| 122 | 120 | typedef struct _tTriangle |
| @@ -133,7 +131,7 @@ void tTriangle_free (tTriangle* const); · 10 unmodified lines | ||
| 133 | 131 | float tTriangle_tick (tTriangle* const); |
| 134 | 132 | int tTriangle_setFreq (tTriangle* const, float freq); |
| 135 | 133 | |
| 136 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 134 | +//============================================================================== | |
| 137 | 135 | |
| 138 | 136 | /* tSquare: Anti-aliased Square waveform using wavetable interpolation. Wavetables constructed from sine components. */ |
| 139 | 137 | typedef struct _tSquare |
| @@ -150,7 +148,7 @@ void tSquare_free (tSquare* const); · 10 unmodified lines | ||
| 150 | 148 | float tSquare_tick (tSquare* const); |
| 151 | 149 | int tSquare_setFreq (tSquare* const, float freq); |
| 152 | 150 | |
| 153 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 151 | +//============================================================================== | |
| 154 | 152 | |
| 155 | 153 | /* tNoise. WhiteNoise, PinkNoise. */ |
| 156 | 154 | typedef enum NoiseType |
| @@ -173,10 +171,12 @@ void tNoise_free (tNoise* const); · 16 unmodified lines | ||
| 173 | 171 | |
| 174 | 172 | float tNoise_tick (tNoise* const); |
| 175 | 173 | |
| 176 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 174 | +//============================================================================== | |
| 177 | 175 | |
| 178 | 176 | #ifdef __cplusplus |
| 179 | 177 | } |
| 180 | 178 | #endif |
| 181 | 179 | |
| 182 | −#endif // LEAFOSCILLATOR_H_INCLUDED | |
| 180 | +#endif // LEAF_OSCILLATOR_H_INCLUDED | |
| 181 | + | |
| 182 | +//============================================================================== | |
| @@ -8,11 +8,14 @@ · 7 unmodified lines | ||
| 8 | 8 | ============================================================================== |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | +#ifndef LEAF_PITCH_H_INCLUDED | |
| 12 | +#define LEAF_PITCH_H_INCLUDED | |
| 13 | + | |
| 11 | 14 | #ifdef __cplusplus |
| 12 | 15 | extern "C" { |
| 13 | 16 | #endif |
| 14 | 17 | |
| 15 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 18 | +//============================================================================== | |
| 16 | 19 | |
| 17 | 20 | #include "leaf-globals.h" |
| 18 | 21 | #include "leaf-math.h" |
| @@ -20,8 +23,8 @@ extern "C" { · 1 unmodified line | ||
| 20 | 23 | #include "leaf-filter.h" |
| 21 | 24 | #include "leaf-utilities.h" |
| 22 | 25 | |
| 23 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 24 | − | |
| 26 | +//============================================================================== | |
| 27 | + | |
| 25 | 28 | #define DEFPITCHRATIO 2.0f |
| 26 | 29 | #define DEFTIMECONSTANT 100.0f |
| 27 | 30 | #define DEFHOPSIZE 64 |
| @@ -29,8 +32,8 @@ extern "C" { · 1 unmodified line | ||
| 29 | 32 | #define FBA 20 |
| 30 | 33 | #define HPFREQ 40.0f |
| 31 | 34 | |
| 32 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 33 | − | |
| 35 | +//============================================================================== | |
| 36 | + | |
| 34 | 37 | /* tSOLAD : pitch shifting algorithm that underlies tPitchShifter etc */ |
| 35 | 38 | #define LOOPSIZE (2048*2) // (4096*2) // loop size must be power of two |
| 36 | 39 | #define LOOPMASK (LOOPSIZE - 1) |
| @@ -72,8 +75,8 @@ void tSOLAD_setReadLag (tSOLAD *w, float readlag); · 35 unmodified lines | ||
| 72 | 75 | // reset state variables |
| 73 | 76 | void tSOLAD_resetState (tSOLAD *w); |
| 74 | 77 | |
| 75 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 76 | − | |
| 78 | +//============================================================================== | |
| 79 | + | |
| 77 | 80 | // tSNAC: period detector |
| 78 | 81 | #define SNAC_FRAME_SIZE 1024 // default analysis framesize // should be the same as (or smaller than?) PS_FRAME_SIZE |
| 79 | 82 | #define DEFOVERLAP 1 // default overlap |
| @@ -112,8 +115,8 @@ void tSNAC_setMinRMS (tSNAC *s, float rms); · 32 unmodified lines | ||
| 112 | 115 | float tSNAC_getPeriod (tSNAC *s); |
| 113 | 116 | float tSNAC_getfidelity (tSNAC *s); |
| 114 | 117 | |
| 115 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 116 | − | |
| 118 | +//============================================================================== | |
| 119 | + | |
| 117 | 120 | // Pitch shifter |
| 118 | 121 | typedef struct _tPitchShifter |
| 119 | 122 | { |
| @@ -159,8 +162,8 @@ void tPitchShifter_setHopSize (tPitchShifter* const, int hs); · 39 unmodified lines | ||
| 159 | 162 | void tPitchShifter_setWindowSize (tPitchShifter* const, int ws); |
| 160 | 163 | float tPitchShifter_getPeriod (tPitchShifter* const); |
| 161 | 164 | |
| 162 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 163 | − | |
| 165 | +//============================================================================== | |
| 166 | + | |
| 164 | 167 | // Period detection |
| 165 | 168 | typedef struct _tPeriod |
| 166 | 169 | { |
| @@ -198,8 +201,8 @@ float tPeriod_findPeriod (tPeriod* const, float sample); · 31 unmodified lines | ||
| 198 | 201 | void tPeriod_setHopSize (tPeriod* p, int hs); |
| 199 | 202 | void tPeriod_setWindowSize (tPeriod* p, int ws); |
| 200 | 203 | |
| 201 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 202 | − | |
| 204 | +//============================================================================== | |
| 205 | + | |
| 203 | 206 | // Pitch shift |
| 204 | 207 | typedef struct _tPitchShift |
| 205 | 208 | { |
| @@ -229,8 +232,12 @@ float tPitchShift_shiftToFunc (tPitchShift* const, float (*fun)(fl · 23 unmodified lines | ||
| 229 | 232 | float tPitchShift_shiftToFreq (tPitchShift* const, float freq); |
| 230 | 233 | void tPitchShift_setPitchFactor (tPitchShift* const, float pf); |
| 231 | 234 | |
| 232 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 235 | +//============================================================================== | |
| 233 | 236 | |
| 234 | 237 | #ifdef __cplusplus |
| 235 | 238 | } |
| 236 | −#endif | |
| 239 | +#endif | |
| 240 | + | |
| 241 | +#endif // LEAF_PITCH_H_INCLUDED | |
| 242 | + | |
| 243 | +//============================================================================== | |
| @@ -1,22 +1,20 @@ | ||
| 1 | −/* | |
| 2 | − ============================================================================== | |
| 1 | +/*============================================================================== | |
| 3 | 2 | |
| 4 | 3 | LEAFReverb.h |
| 5 | 4 | Created: 20 Jan 2017 12:02:04pm |
| 6 | 5 | Author: Michael R Mulshine |
| 7 | 6 | |
| 8 | − ============================================================================== | |
| 9 | −*/ | |
| 7 | +==============================================================================*/ | |
| 10 | 8 | |
| 11 | −#ifndef LEAFREVERB_H_INCLUDED | |
| 12 | −#define LEAFREVERB_H_INCLUDED | |
| 9 | +#ifndef LEAF_REVERB_H_INCLUDED | |
| 10 | +#define LEAF_REVERB_H_INCLUDED | |
| 13 | 11 | |
| 14 | 12 | #ifdef __cplusplus |
| 15 | 13 | extern "C" { |
| 16 | 14 | #endif |
| 17 | 15 | |
| 18 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 19 | − | |
| 16 | +//============================================================================== | |
| 17 | + | |
| 20 | 18 | #include "leaf-globals.h" |
| 21 | 19 | #include "leaf-math.h" |
| 22 | 20 | |
| @@ -24,7 +22,7 @@ extern "C" { · 1 unmodified line | ||
| 24 | 22 | #include "leaf-filter.h" |
| 25 | 23 | #include "leaf-oscillator.h" |
| 26 | 24 | |
| 27 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 25 | +//============================================================================== | |
| 28 | 26 | |
| 29 | 27 | /* PRCRev: Reverb, reimplemented from STK (Cook and Scavone). */ |
| 30 | 28 | typedef struct _tPRCRev |
| @@ -53,7 +51,7 @@ void tPRCRev_setT60 (tPRCRev* const, float t60); · 22 unmodified lines | ||
| 53 | 51 | // Set mix between dry input and wet output signal. |
| 54 | 52 | void tPRCRev_setMix (tPRCRev* const, float mix); |
| 55 | 53 | |
| 56 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 54 | +//============================================================================== | |
| 57 | 55 | |
| 58 | 56 | /* NRev: Reverb, reimplemented from STK (Cook and Scavone). */ |
| 59 | 57 | typedef struct _tNRev |
| @@ -83,7 +81,7 @@ void tNRev_setT60 (tNRev* const, float t60); · 23 unmodified lines | ||
| 83 | 81 | // Set mix between dry input and wet output signal. |
| 84 | 82 | void tNRev_setMix (tNRev* const, float mix); |
| 85 | 83 | |
| 86 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 84 | +//============================================================================== | |
| 87 | 85 | |
| 88 | 86 | typedef struct _tDattorro |
| 89 | 87 | { |
| @@ -145,4 +143,6 @@ void tDattorro_setFeedbackGain (tDattorro* const, float gain); · 55 unmodified lines | ||
| 145 | 143 | } |
| 146 | 144 | #endif |
| 147 | 145 | |
| 148 | −#endif // LEAFREVERB_H_INCLUDED | |
| 146 | +#endif // LEAF_REVERB_H_INCLUDED | |
| 147 | + | |
| 148 | +//============================================================================== | |
| @@ -0,0 +1,114 @@ | ||
| 1 | +/*============================================================================== | |
| 2 | + | |
| 3 | + leaf-sample.h | |
| 4 | + Created: 23 Jan 2019 11:22:09am | |
| 5 | + Author: Mike Mulshine | |
| 6 | + | |
| 7 | +==============================================================================*/ | |
| 8 | + | |
| 9 | + | |
| 10 | +#ifndef LEAF_SAMPLE_H_INCLUDED | |
| 11 | +#define LEAF_SAMPLE_H_INCLUDED | |
| 12 | + | |
| 13 | +#ifdef __cplusplus | |
| 14 | +extern "C" { | |
| 15 | +#endif | |
| 16 | + | |
| 17 | +//============================================================================== | |
| 18 | + | |
| 19 | +#include "leaf-globals.h" | |
| 20 | +#include "leaf-math.h" | |
| 21 | + | |
| 22 | +//============================================================================== | |
| 23 | + | |
| 24 | + typedef enum RecordMode | |
| 25 | + { | |
| 26 | + RecordOneShot = 0, | |
| 27 | + RecordLoop, | |
| 28 | + RecordModeNil | |
| 29 | + } RecordMode; | |
| 30 | + | |
| 31 | + typedef struct _tSample | |
| 32 | + { | |
| 33 | + float* buff; | |
| 34 | + | |
| 35 | + uint32_t idx; | |
| 36 | + uint32_t length; | |
| 37 | + | |
| 38 | + RecordMode mode; | |
| 39 | + | |
| 40 | + int active; | |
| 41 | + | |
| 42 | + } tSample; | |
| 43 | + | |
| 44 | + void tSample_init (tSample* const, uint32_t length); | |
| 45 | + void tSample_free (tSample* const); | |
| 46 | + | |
| 47 | + void tSample_tick (tSample* const, float sample); | |
| 48 | + | |
| 49 | + void tSample_read(tSample* const, float* buff, uint32_t len); | |
| 50 | + | |
| 51 | + float tSample_get (tSample* const, int idx); | |
| 52 | + | |
| 53 | + void tSample_start (tSample* const); | |
| 54 | + void tSample_stop (tSample* const); | |
| 55 | + | |
| 56 | + void tSample_setRecordMode (tSample* const, RecordMode mode); | |
| 57 | + | |
| 58 | + void tSample_clear (tSample* const); | |
| 59 | + | |
| 60 | +//============================================================================== | |
| 61 | + | |
| 62 | + typedef enum Mode | |
| 63 | + { | |
| 64 | + Normal, | |
| 65 | + Loop, | |
| 66 | + BackAndForth, | |
| 67 | + ModeNil | |
| 68 | + } Mode; | |
| 69 | + | |
| 70 | + typedef struct _tSamplePlayer | |
| 71 | + { | |
| 72 | + tSample* samp; | |
| 73 | + | |
| 74 | + float idx; | |
| 75 | + float inc; | |
| 76 | + int dir; | |
| 77 | + | |
| 78 | + int32_t start; | |
| 79 | + int32_t end; | |
| 80 | + uint32_t len; | |
| 81 | + | |
| 82 | + Mode mode; | |
| 83 | + | |
| 84 | + int active; | |
| 85 | + | |
| 86 | + float gain; | |
| 87 | + } tSamplePlayer; | |
| 88 | + | |
| 89 | + void tSamplePlayer_init (tSamplePlayer* const, tSample* s); | |
| 90 | + void tSamplePlayer_free (tSamplePlayer* const); | |
| 91 | + | |
| 92 | + float tSamplePlayer_tick (tSamplePlayer* const); | |
| 93 | + | |
| 94 | + void tSamplePlayer_setSample (tSamplePlayer* const, tSample* s); | |
| 95 | + | |
| 96 | + void tSamplePlayer_setMode (tSamplePlayer* const, Mode mode); | |
| 97 | + | |
| 98 | + void tSamplePlayer_play (tSamplePlayer* const); | |
| 99 | + void tSamplePlayer_stop (tSamplePlayer* const); | |
| 100 | + | |
| 101 | + void tSamplePlayer_setStart (tSamplePlayer* const, int32_t start); | |
| 102 | + void tSamplePlayer_setEnd (tSamplePlayer* const, int32_t end); | |
| 103 | + | |
| 104 | + void tSamplePlayer_setRate (tSamplePlayer* const, float rate); | |
| 105 | + | |
| 106 | +//============================================================================== | |
| 107 | + | |
| 108 | +#ifdef __cplusplus | |
| 109 | +} | |
| 110 | +#endif | |
| 111 | + | |
| 112 | +#endif // LEAF_SAMPLE_H_INCLUDED | |
| 113 | + | |
| 114 | +//============================================================================== | |
| @@ -8,11 +8,14 @@ · 7 unmodified lines | ||
| 8 | 8 | ============================================================================== |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | +#ifndef LEAF_STRING_H_INCLUDED | |
| 12 | +#define LEAF_STRING_H_INCLUDED | |
| 13 | + | |
| 11 | 14 | #ifdef __cplusplus |
| 12 | 15 | extern "C" { |
| 13 | 16 | #endif |
| 14 | 17 | |
| 15 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 18 | +//============================================================================== | |
| 16 | 19 | |
| 17 | 20 | #include "leaf-globals.h" |
| 18 | 21 | #include "leaf-math.h" |
| @@ -21,7 +24,7 @@ extern "C" { · 2 unmodified lines | ||
| 21 | 24 | #include "leaf-filter.h" |
| 22 | 25 | #include "leaf-oscillator.h" |
| 23 | 26 | |
| 24 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 27 | +//============================================================================== | |
| 25 | 28 | |
| 26 | 29 | /* Karplus Strong model */ |
| 27 | 30 | typedef struct _tPluck |
| @@ -62,9 +65,8 @@ void tPluck_controlChange (tPluck* const, int number, float value); · 34 unmodified lines | ||
| 62 | 65 | // tPluck Utilities. |
| 63 | 66 | float tPluck_getLastOut (tPluck* const); |
| 64 | 67 | |
| 65 | − | |
| 66 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 67 | − | |
| 68 | +//============================================================================== | |
| 69 | + | |
| 68 | 70 | /* Stif Karplus Strong model */ |
| 69 | 71 | typedef struct _tStifKarp |
| 70 | 72 | { |
| @@ -130,8 +132,12 @@ void tStifKarp_setBaseLoopGain (tStifKarp* const, float aGain ); · 59 unmodified lines | ||
| 130 | 132 | // tStifKarp utilities. |
| 131 | 133 | float tStifKarp_getLastOut (tStifKarp* const); |
| 132 | 134 | |
| 133 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 135 | +//============================================================================== | |
| 134 | 136 | |
| 135 | 137 | #ifdef __cplusplus |
| 136 | 138 | } |
| 137 | −#endif | |
| 139 | +#endif | |
| 140 | + | |
| 141 | +#endif // LEAF_STRING_H_INCLUDED | |
| 142 | + | |
| 143 | +//============================================================================== | |
| @@ -1,26 +1,24 @@ | ||
| 1 | −/* | |
| 2 | − ============================================================================== | |
| 1 | +/*============================================================================== | |
| 3 | 2 | |
| 4 | 3 | LEAFUtilities.h |
| 5 | 4 | Created: 20 Jan 2017 12:02:17pm |
| 6 | 5 | Author: Michael R Mulshine |
| 7 | 6 | |
| 8 | − ============================================================================== | |
| 9 | −*/ | |
| 7 | +==============================================================================*/ | |
| 10 | 8 | |
| 11 | −#ifndef LEAFUTILITIES_H_INCLUDED | |
| 12 | −#define LEAFUTILITIES_H_INCLUDED | |
| 9 | +#ifndef LEAF_UTILITIES_H_INCLUDED | |
| 10 | +#define LEAF_UTILITIES_H_INCLUDED | |
| 13 | 11 | |
| 14 | 12 | #ifdef __cplusplus |
| 15 | 13 | extern "C" { |
| 16 | 14 | #endif |
| 17 | 15 | |
| 18 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 16 | +//============================================================================== | |
| 19 | 17 | |
| 20 | 18 | #include "leaf-globals.h" |
| 21 | 19 | #include "leaf-math.h" |
| 22 | 20 | |
| 23 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 21 | +//============================================================================== | |
| 24 | 22 | |
| 25 | 23 | // STACK implementation (fixed size) |
| 26 | 24 | #define STACK_SIZE 128 |
| @@ -48,7 +46,7 @@ int tStack_contains (tStack* const, uint16_t item); · 21 unmodified lines | ||
| 48 | 46 | int tStack_next (tStack* const); |
| 49 | 47 | int tStack_get (tStack* const, int which); |
| 50 | 48 | |
| 51 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 49 | +//============================================================================== | |
| 52 | 50 | |
| 53 | 51 | /* Ramp */ |
| 54 | 52 | typedef struct _tRamp { |
| @@ -70,7 +68,7 @@ int tRamp_setTime (tRamp* const, float time); · 15 unmodified lines | ||
| 70 | 68 | int tRamp_setDest (tRamp* const, float dest); |
| 71 | 69 | int tRamp_setVal (tRamp* const, float val); |
| 72 | 70 | |
| 73 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 71 | +//============================================================================== | |
| 74 | 72 | |
| 75 | 73 | /* Compressor */ |
| 76 | 74 | typedef struct _tCompressor |
| @@ -88,7 +86,7 @@ void tCompressor_init (tCompressor* const); · 11 unmodified lines | ||
| 88 | 86 | void tCompressor_free (tCompressor* const); |
| 89 | 87 | float tCompressor_tick (tCompressor* const, float input); |
| 90 | 88 | |
| 91 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 89 | +//============================================================================== | |
| 92 | 90 | |
| 93 | 91 | /* Attack-Decay envelope */ |
| 94 | 92 | typedef struct _tEnvelope { |
| @@ -120,7 +118,7 @@ int tEnvelope_setDecay (tEnvelope* const, float decay); · 25 unmodified lines | ||
| 120 | 118 | int tEnvelope_loop (tEnvelope* const, oBool loop); |
| 121 | 119 | int tEnvelope_on (tEnvelope* const, float velocity); |
| 122 | 120 | |
| 123 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 121 | +//============================================================================== | |
| 124 | 122 | |
| 125 | 123 | /* ADSR */ |
| 126 | 124 | typedef struct _tADSR |
| @@ -152,7 +150,7 @@ int tADSR_setRelease(tADSR* const, float release); · 25 unmodified lines | ||
| 152 | 150 | int tADSR_on (tADSR* const, float velocity); |
| 153 | 151 | int tADSR_off (tADSR* const); |
| 154 | 152 | |
| 155 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 153 | +//============================================================================== | |
| 156 | 154 | |
| 157 | 155 | /* Envelope Follower */ |
| 158 | 156 | typedef struct _tEnvelopeFollower |
| @@ -170,7 +168,7 @@ float tEnvelopeFollower_tick (tEnvelopeFollower* const, float x); · 11 unmodified lines | ||
| 170 | 168 | int tEnvelopeFollower_decayCoeff (tEnvelopeFollower* const, float decayCoeff); |
| 171 | 169 | int tEnvelopeFollower_attackThresh (tEnvelopeFollower* const, float attackThresh); |
| 172 | 170 | |
| 173 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 171 | +//============================================================================== | |
| 174 | 172 | |
| 175 | 173 | /* tAtkDtk */ |
| 176 | 174 | #define DEFBLOCKSIZE 1024 |
| @@ -221,7 +219,7 @@ void tAtkDtk_setThreshold (tAtkDtk* const, float thres); · 44 unmodified lines | ||
| 221 | 219 | // find largest transient in input block, return index of attack |
| 222 | 220 | int tAtkDtk_detect (tAtkDtk* const, float *in); |
| 223 | 221 | |
| 224 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 222 | +//============================================================================== | |
| 225 | 223 | |
| 226 | 224 | // ENV~ from PD, modified for LEAF |
| 227 | 225 | #define MAXOVERLAP 32 |
| @@ -246,12 +244,14 @@ void tEnv_free (tEnv* const); · 18 unmodified lines | ||
| 246 | 244 | float tEnv_tick (tEnv* const); |
| 247 | 245 | void tEnv_processBlock (tEnv* const, float* in); |
| 248 | 246 | |
| 249 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 247 | +//============================================================================== | |
| 250 | 248 | |
| 251 | 249 | #ifdef __cplusplus |
| 252 | 250 | } |
| 253 | 251 | #endif |
| 254 | 252 | |
| 255 | −#endif // LEAFUTILITIES_H_INCLUDED | |
| 253 | +#endif // LEAF_UTILITIES_H_INCLUDED | |
| 254 | + | |
| 255 | +//============================================================================== | |
| 256 | 256 | |
| 257 | 257 | |
| @@ -1,26 +1,24 @@ | ||
| 1 | −/* | |
| 2 | − ============================================================================== | |
| 1 | +/*============================================================================== | |
| 3 | 2 | |
| 4 | 3 | LEAFInstrument.h |
| 5 | 4 | Created: 20 Jan 2017 12:01:54pm |
| 6 | 5 | Author: Michael R Mulshine |
| 7 | 6 | |
| 8 | − ============================================================================== | |
| 9 | −*/ | |
| 7 | +==============================================================================*/ | |
| 10 | 8 | |
| 11 | −#ifndef LEAFINSTRUMENT_H_INCLUDED | |
| 12 | −#define LEAFINSTRUMENT_H_INCLUDED | |
| 9 | +#ifndef LEAF_VOCODER_H_INCLUDED | |
| 10 | +#define LEAF_VOCODER_H_INCLUDED | |
| 13 | 11 | |
| 14 | 12 | #ifdef __cplusplus |
| 15 | 13 | extern "C" { |
| 16 | 14 | #endif |
| 17 | 15 | |
| 18 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 16 | +//============================================================================== | |
| 19 | 17 | |
| 20 | 18 | #include "leaf-globals.h" |
| 21 | 19 | #include "leaf-math.h" |
| 22 | 20 | |
| 23 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 21 | +//============================================================================== | |
| 24 | 22 | |
| 25 | 23 | /* tTalkbox */ |
| 26 | 24 | #define NUM_TALKBOX_PARAM 4 |
| @@ -52,7 +50,7 @@ void tTalkbox_lpcDurbin (float *r, int p, float *k, float *g); · 25 unmodified lines | ||
| 52 | 50 | void tTalkbox_lpc (float *buf, float *car, int32_t n, int32_t o); |
| 53 | 51 | void tTalkbox_setQuality (tTalkbox* const, float quality); |
| 54 | 52 | |
| 55 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 53 | +//============================================================================== | |
| 56 | 54 | |
| 57 | 55 | /* tVocoder */ |
| 58 | 56 | #define NUM_VOCODER_PARAM 8 |
| @@ -79,10 +77,12 @@ float tVocoder_tick (tVocoder* const, float synth, float voice); · 20 unmodified lines | ||
| 79 | 77 | void tVocoder_update (tVocoder* const); |
| 80 | 78 | void tVocoder_suspend (tVocoder* const); |
| 81 | 79 | |
| 82 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 80 | +//============================================================================== | |
| 83 | 81 | |
| 84 | 82 | #ifdef __cplusplus |
| 85 | 83 | } |
| 86 | 84 | #endif |
| 87 | 85 | |
| 88 | −#endif // LEAFINSTRUMENT_H_INCLUDED | |
| 86 | +#endif // LEAF_VOCODER_H_INCLUDED | |
| 87 | + | |
| 88 | +//============================================================================== | |
| @@ -1,23 +1,25 @@ | ||
| 1 | −/* | |
| 2 | − ============================================================================== | |
| 1 | +/*============================================================================== | |
| 3 | 2 | |
| 4 | 3 | leaf-wavefolder.h |
| 5 | 4 | Created: 30 Nov 2018 11:57:05am |
| 6 | 5 | Author: airship |
| 7 | 6 | |
| 8 | − ============================================================================== | |
| 9 | −*/ | |
| 7 | +==============================================================================*/ | |
| 8 | + | |
| 9 | +#ifndef LEAF_WAVEFOLDER_H_INCLUDED | |
| 10 | +#define LEAF_WAVEFOLDER_H_INCLUDED | |
| 11 | + | |
| 10 | 12 | |
| 11 | 13 | #ifdef __cplusplus |
| 12 | 14 | extern "C" { |
| 13 | 15 | #endif |
| 14 | 16 | |
| 15 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 17 | +//============================================================================== | |
| 16 | 18 | |
| 17 | 19 | #include "leaf-globals.h" |
| 18 | 20 | #include "leaf-math.h" |
| 19 | 21 | |
| 20 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 22 | +//============================================================================== | |
| 21 | 23 | |
| 22 | 24 | /* tLockhartWavefolder */ |
| 23 | 25 | #define THRESH 10e-10 |
| @@ -45,7 +47,12 @@ void tLockhartWavefolder_free (tLockhartWavefolder* const); · 21 unmodified lines | ||
| 45 | 47 | float tLockhartWavefolder_tick (tLockhartWavefolder* const, float samp); |
| 46 | 48 | |
| 47 | 49 | |
| 50 | +//============================================================================== | |
| 51 | + | |
| 48 | 52 | #ifdef __cplusplus |
| 49 | 53 | } |
| 50 | −#endif | |
| 51 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 54 | +#endif | |
| 55 | + | |
| 56 | +#endif // LEAF_WAVEFOLDER_H_INCLUDED | |
| 57 | + | |
| 58 | +//============================================================================== | |
| @@ -1,26 +1,24 @@ | ||
| 1 | −/* | |
| 2 | − ============================================================================== | |
| 1 | +/*============================================================================== | |
| 3 | 2 | |
| 4 | 3 | LEAFWavetables.h |
| 5 | 4 | Created: 4 Dec 2016 9:42:41pm |
| 6 | 5 | Author: Michael R Mulshine |
| 7 | 6 | |
| 8 | − ============================================================================== | |
| 9 | −*/ | |
| 7 | +==============================================================================*/ | |
| 10 | 8 | |
| 11 | −#ifndef WAVETABLES_H_INCLUDED | |
| 12 | −#define WAVETABLES_H_INCLUDED | |
| 9 | +#ifndef LEAF_WAVETABLES_H_INCLUDED | |
| 10 | +#define LEAF_WAVETABLES_H_INCLUDED | |
| 13 | 11 | |
| 14 | 12 | #ifdef __cplusplus |
| 15 | 13 | extern "C" { |
| 16 | −#endif | |
| 17 | − | |
| 18 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 14 | +#endif | |
| 15 | + | |
| 16 | +//============================================================================== | |
| 19 | 17 | |
| 20 | 18 | #include "leaf-globals.h" |
| 21 | 19 | #include "leaf-math.h" |
| 22 | 20 | |
| 23 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 21 | +//============================================================================== | |
| 24 | 22 | |
| 25 | 23 | |
| 26 | 24 | #define SINE_TABLE_SIZE 2048 |
| @@ -62,7 +60,7 @@ extern const float decayCoeffTable[DECAY_COEFF_TABLE_SIZE]; · 35 unmodified lines | ||
| 62 | 60 | |
| 63 | 61 | extern const float tanh1[TANH1_TABLE_SIZE]; |
| 64 | 62 | |
| 65 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 63 | +//============================================================================== | |
| 66 | 64 | |
| 67 | 65 | /* Sine wave table ripped from http://aquaticus.info/pwm-sine-wave. */ |
| 68 | 66 | extern const float sinewave[SINE_TABLE_SIZE]; |
| @@ -73,10 +71,12 @@ extern const float triangle[11][TRI_TABLE_SIZE]; · 4 unmodified lines | ||
| 73 | 71 | |
| 74 | 72 | extern const float squarewave[11][SQR_TABLE_SIZE]; |
| 75 | 73 | |
| 76 | −// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | |
| 74 | +//============================================================================== | |
| 77 | 75 | |
| 78 | 76 | #ifdef __cplusplus |
| 79 | 77 | } |
| 80 | 78 | #endif |
| 81 | 79 | |
| 82 | −#endif // WAVETABLES_H_INCLUDED | |
| 80 | +#endif // LEAF_WAVETABLES_H_INCLUDED | |
| 81 | + | |
| 82 | +//============================================================================== | |
| @@ -159,7 +159,19 @@ float LEAF_clip(float min, float val, float max) · 158 unmodified lines | ||
| 159 | 159 | } else { |
| 160 | 160 | return val; |
| 161 | 161 | } |
| 162 | −} | |
| 162 | +} | |
| 163 | + | |
| 164 | +int LEAF_clipInt(int min, int val, int max) | |
| 165 | +{ | |
| 166 | + if (val < min) { | |
| 167 | + return min; | |
| 168 | + } else if (val > max) { | |
| 169 | + return max; | |
| 170 | + } else { | |
| 171 | + return val; | |
| 172 | + } | |
| 173 | +} | |
| 174 | + | |
| 163 | 175 | |
| 164 | 176 | oBool LEAF_isPrime(uint64_t number ) |
| 165 | 177 | { |
| @@ -0,0 +1,244 @@ | ||
| 1 | +/* | |
| 2 | + ============================================================================== | |
| 3 | + | |
| 4 | + LEAFUtilities.c | |
| 5 | + Created: 20 Jan 2017 12:02:17pm | |
| 6 | + Author: Michael R Mulshine | |
| 7 | + | |
| 8 | + ============================================================================== | |
| 9 | +*/ | |
| 10 | + | |
| 11 | + | |
| 12 | +#if _WIN32 || _WIN64 | |
| 13 | + | |
| 14 | +#include "..\Inc\leaf-sample.h" | |
| 15 | +#include "..\leaf.h" | |
| 16 | + | |
| 17 | +#else | |
| 18 | + | |
| 19 | +#include "../Inc/leaf-sample.h" | |
| 20 | +#include "../leaf.h" | |
| 21 | + | |
| 22 | +#endif | |
| 23 | + | |
| 24 | +//============================================================================== | |
| 25 | + | |
| 26 | +void tSample_init (tSample* const s, uint32_t length) | |
| 27 | +{ | |
| 28 | + s->buff = (float*) leaf_alloc( sizeof(float) * length); | |
| 29 | + | |
| 30 | + | |
| 31 | + s->length = length; | |
| 32 | + s->active = 0; | |
| 33 | + s->idx = 0; | |
| 34 | + s->mode = RecordOneShot; | |
| 35 | + | |
| 36 | + tSample_clear(s); | |
| 37 | +} | |
| 38 | + | |
| 39 | +void tSample_free (tSample* const s) | |
| 40 | +{ | |
| 41 | + leaf_free(s->buff); | |
| 42 | + leaf_free(s); | |
| 43 | +} | |
| 44 | + | |
| 45 | +void tSample_tick (tSample* const s, float sample) | |
| 46 | +{ | |
| 47 | + if (s->active == 1) | |
| 48 | + { | |
| 49 | + s->buff[s->idx] = sample; | |
| 50 | + | |
| 51 | + s->idx += 1; | |
| 52 | + | |
| 53 | + if (s->idx >= s->length) | |
| 54 | + { | |
| 55 | + if (s->mode == RecordOneShot) | |
| 56 | + { | |
| 57 | + tSample_stop(s); | |
| 58 | + } | |
| 59 | + else if (s->mode == RecordLoop) | |
| 60 | + { | |
| 61 | + s->idx = 0; | |
| 62 | + } | |
| 63 | + } | |
| 64 | + } | |
| 65 | +} | |
| 66 | + | |
| 67 | +void tSample_read(tSample* const s, float* buff, uint32_t len) | |
| 68 | +{ | |
| 69 | + for (int i = 0; i < s->length; i++) | |
| 70 | + { | |
| 71 | + if (i < len) s->buff[i] = buff[i]; | |
| 72 | + else s->buff[i] = 0.f; | |
| 73 | + } | |
| 74 | +} | |
| 75 | + | |
| 76 | +float tSample_get (tSample* const s, int idx) | |
| 77 | +{ | |
| 78 | + if ((idx < 0) || (idx >= s->length)) return 0.f; | |
| 79 | + | |
| 80 | + return s->buff[idx]; | |
| 81 | +} | |
| 82 | + | |
| 83 | +void tSample_start(tSample* const s) | |
| 84 | +{ | |
| 85 | + s->active = 1; | |
| 86 | + s->idx = 0; | |
| 87 | +} | |
| 88 | + | |
| 89 | +void tSample_stop(tSample* const s) | |
| 90 | +{ | |
| 91 | + s->active = 0; | |
| 92 | +} | |
| 93 | + | |
| 94 | +void tSample_setRecordMode (tSample* const s, RecordMode mode) | |
| 95 | +{ | |
| 96 | + s->mode = mode; | |
| 97 | +} | |
| 98 | + | |
| 99 | +void tSample_clear (tSample* const s) | |
| 100 | +{ | |
| 101 | + for (int i = 0; i < s->length; i++) | |
| 102 | + { | |
| 103 | + s->buff[i] = 0.f; | |
| 104 | + } | |
| 105 | +} | |
| 106 | + | |
| 107 | +//============================================================================== | |
| 108 | + | |
| 109 | +void tSamplePlayer_init (tSamplePlayer* const p, tSample* s) | |
| 110 | +{ | |
| 111 | + p->samp = s; | |
| 112 | + | |
| 113 | + p->active = 0; | |
| 114 | + | |
| 115 | + p->start = 0; | |
| 116 | + p->end = p->samp->length - 1; | |
| 117 | + | |
| 118 | + p->len = p->end - p->start; | |
| 119 | + | |
| 120 | + p->idx = 0.f; | |
| 121 | + p->inc = 1.f; | |
| 122 | + | |
| 123 | + p->mode = Normal; | |
| 124 | + | |
| 125 | + p->gain = 1.; | |
| 126 | +} | |
| 127 | + | |
| 128 | +void tSamplePlayer_free (tSamplePlayer* const p) | |
| 129 | +{ | |
| 130 | + leaf_free(p->samp); | |
| 131 | + leaf_free(p); | |
| 132 | +} | |
| 133 | + | |
| 134 | +float tSamplePlayer_tick (tSamplePlayer* const p) | |
| 135 | +{ | |
| 136 | + if (p->active == 0 || (p->len < 4)) return 0.f; | |
| 137 | + | |
| 138 | + float sample = 0.f; | |
| 139 | + | |
| 140 | + float* buff = p->samp->buff; | |
| 141 | + | |
| 142 | + int idx = (int) p->idx; | |
| 143 | + float alpha = p->idx - idx; | |
| 144 | + | |
| 145 | + int i1 = idx-1; | |
| 146 | + int i3 = idx+1; | |
| 147 | + int i4 = idx+2; | |
| 148 | + | |
| 149 | + if (i1 < p->start) i1 += p->len; | |
| 150 | + if (i3 > p->end) i3 -= p->len; | |
| 151 | + if (i4 > p->end) i4 -= p->len; | |
| 152 | + | |
| 153 | + sample = LEAF_interpolate_hermite (buff[i1], | |
| 154 | + buff[idx], | |
| 155 | + buff[i3], | |
| 156 | + buff[i4], | |
| 157 | + alpha); | |
| 158 | + | |
| 159 | + p->idx += (p->dir * p->inc); | |
| 160 | + | |
| 161 | + if (p->mode == Normal) | |
| 162 | + { | |
| 163 | + // FIX THIS: NORMAL MODE NOT IMPLEMENTED YET | |
| 164 | + if ((p->dir == 1) && (idx > p->end)) | |
| 165 | + { | |
| 166 | + p->active = 0; | |
| 167 | + } | |
| 168 | + } | |
| 169 | + else if (p->mode == Loop) | |
| 170 | + { | |
| 171 | + if (idx < p->start) p->idx += (float)(p->len); | |
| 172 | + | |
| 173 | + if (idx > p->end) p->idx -= (float)(p->len); | |
| 174 | + } | |
| 175 | + else if (p->mode == BackAndForth) | |
| 176 | + { | |
| 177 | + if ((idx < p->start) || (idx > p->end)) | |
| 178 | + { | |
| 179 | + p->dir = -p->dir; | |
| 180 | + p->idx += (2*p->inc); | |
| 181 | + } | |
| 182 | + } | |
| 183 | + | |
| 184 | + | |
| 185 | + return sample * p->gain; | |
| 186 | +} | |
| 187 | + | |
| 188 | +void tSamplePlayer_setSample (tSamplePlayer* const p, tSample* s) | |
| 189 | +{ | |
| 190 | + p->samp = s; | |
| 191 | +} | |
| 192 | + | |
| 193 | +void tSamplePlayer_setMode (tSamplePlayer* const p, Mode mode) | |
| 194 | +{ | |
| 195 | + p->mode = mode; | |
| 196 | +} | |
| 197 | + | |
| 198 | +void tSamplePlayer_play (tSamplePlayer* const p) | |
| 199 | +{ | |
| 200 | + p->active = 1; | |
| 201 | +} | |
| 202 | + | |
| 203 | +void tSamplePlayer_stop (tSamplePlayer* const p) | |
| 204 | +{ | |
| 205 | + p->active = 0; | |
| 206 | +} | |
| 207 | + | |
| 208 | +void tSamplePlayer_setStart (tSamplePlayer* const p, int32_t start) | |
| 209 | +{ | |
| 210 | + p->start = LEAF_clipInt(0, start, (p->samp->length - 1)); | |
| 211 | + | |
| 212 | + p->len = abs(p->end - p->start); | |
| 213 | + | |
| 214 | + if (p->start > p->end) p->dir = -1; | |
| 215 | + else p->dir = 1; | |
| 216 | +} | |
| 217 | + | |
| 218 | +void tSamplePlayer_setEnd (tSamplePlayer* const p, int32_t end) | |
| 219 | +{ | |
| 220 | + p->end = LEAF_clipInt(0, end, (p->samp->length - 1)); | |
| 221 | + | |
| 222 | + p->len = abs(p->end - p->start); | |
| 223 | + | |
| 224 | + if (p->start > p->end) p->dir = -1; | |
| 225 | + else p->dir = 1; | |
| 226 | +} | |
| 227 | + | |
| 228 | +void tSamplePlayer_setRate (tSamplePlayer* const p, float rate) | |
| 229 | +{ | |
| 230 | + if (rate < 0.f) | |
| 231 | + { | |
| 232 | + rate = -rate; | |
| 233 | + p->dir = -1; | |
| 234 | + } | |
| 235 | + else | |
| 236 | + { | |
| 237 | + p->dir = 1; | |
| 238 | + } | |
| 239 | + | |
| 240 | + p->inc = LEAF_clip(0.f, rate, 8.0f); | |
| 241 | +} | |
| 242 | + | |
| 243 | + | |
| 244 | +//============================================================================== | |
| @@ -31,7 +31,8 @@ · 30 unmodified lines | ||
| 31 | 31 | #include ".\Inc\leaf-string.h" |
| 32 | 32 | #include ".\Inc\leaf-pitch.h" |
| 33 | 33 | #include ".\Inc\leaf-formant.h" |
| 34 | −#include ".\Inc\leaf-midi.h" | |
| 34 | +#include ".\Inc\leaf-midi.h" | |
| 35 | +#include ".\Inc\leaf-sample.h" | |
| 35 | 36 | #include ".\Inc\leaf-wavefolder.h" |
| 36 | 37 | #include ".\Inc\leaf-wavetables.h" |
| 37 | 38 | |
| @@ -49,7 +50,8 @@ · 11 unmodified lines | ||
| 49 | 50 | #include "./Inc/leaf-string.h" |
| 50 | 51 | #include "./Inc/leaf-pitch.h" |
| 51 | 52 | #include "./Inc/leaf-formant.h" |
| 52 | −#include "./Inc/leaf-midi.h" | |
| 53 | +#include "./Inc/leaf-midi.h" | |
| 54 | +#include "./Inc/leaf-sample.h" | |
| 53 | 55 | #include "./Inc/leaf-wavefolder.h" |
| 54 | 56 | #include "./Inc/leaf-wavetables.h" |
| 55 | 57 | |
| @@ -39,6 +39,7 @@ · 38 unmodified lines | ||
| 39 | 39 | <FILE id="OS2D83" name="leaf-utilities.h" compile="0" resource="0" |
| 40 | 40 | file="../LEAF/Inc/leaf-utilities.h"/> |
| 41 | 41 | <FILE id="Szb5LP" name="leaf-vocoder.h" compile="0" resource="0" file="../LEAF/Inc/leaf-vocoder.h"/> |
| 42 | + <FILE id="T6KXi7" name="leaf-sample.h" compile="0" resource="0" file="../LEAF/Inc/leaf-sample.h"/> | |
| 42 | 43 | <FILE id="PRkOp2" name="leaf-wavefolder.h" compile="0" resource="0" |
| 43 | 44 | file="../LEAF/Inc/leaf-wavefolder.h"/> |
| 44 | 45 | <FILE id="KpGzKv" name="leaf-wavetables.h" compile="0" resource="0" |
| @@ -60,6 +61,7 @@ · 15 unmodified lines | ||
| 60 | 61 | <FILE id="uKHzgz" name="leaf-utilities.c" compile="1" resource="0" |
| 61 | 62 | file="../LEAF/Src/leaf-utilities.c"/> |
| 62 | 63 | <FILE id="u1aLLR" name="leaf-vocoder.c" compile="1" resource="0" file="../LEAF/Src/leaf-vocoder.c"/> |
| 64 | + <FILE id="nmtoFJ" name="leaf-sample.c" compile="1" resource="0" file="../LEAF/Src/leaf-sample.c"/> | |
| 63 | 65 | <FILE id="LVoaGm" name="leaf-wavefolder.c" compile="1" resource="0" |
| 64 | 66 | file="../LEAF/Src/leaf-wavefolder.c"/> |
| 65 | 67 | <FILE id="HRk07h" name="leaf-wavetables.c" compile="1" resource="0" |
| @@ -15,17 +15,14 @@ · 14 unmodified lines | ||
| 15 | 15 | |
| 16 | 16 | std::vector<juce::String> cButtonNames = std::vector<juce::String> |
| 17 | 17 | { |
| 18 | − | |
| 18 | + "sample" | |
| 19 | 19 | }; |
| 20 | 20 | |
| 21 | 21 | std::vector<juce::String> cSliderNames = std::vector<juce::String> |
| 22 | 22 | { |
| 23 | − "mix", | |
| 24 | − "predelay", | |
| 25 | − "input filter", | |
| 26 | − "feedback filter", | |
| 27 | − "feedback gain", | |
| 28 | − "size" | |
| 23 | + "rate", | |
| 24 | + "start", | |
| 25 | + "end" | |
| 29 | 26 | }; |
| 30 | 27 | |
| 31 | 28 | std::vector<juce::String> cComboBoxNames = std::vector<juce::String> |
| @@ -16,91 +16,67 @@ static void leaf_pool_report(void); · 15 unmodified lines | ||
| 16 | 16 | static void leaf_pool_dump(void); |
| 17 | 17 | static void run_pool_test(void); |
| 18 | 18 | |
| 19 | −tDattorro reverb; | |
| 20 | − | |
| 21 | − | |
| 22 | −tTapeDelay delay; | |
| 23 | − | |
| 24 | −float size; | |
| 25 | −tRamp dtime; | |
| 19 | +tSample sample; | |
| 26 | 20 | |
| 21 | +tSamplePlayer player; | |
| 27 | 22 | |
| 28 | 23 | void LEAFTest_init (float sampleRate, int blockSize) |
| 29 | 24 | { |
| 30 | 25 | LEAF_init(sampleRate, blockSize, &randomNumberGenerator); |
| 31 | 26 | |
| 32 | − tDattorro_init(&reverb); | |
| 33 | − | |
| 34 | − //tTapeDelay_init(&delay, 0.5f * leaf.sampleRate, leaf.sampleRate); | |
| 35 | − | |
| 36 | − tRamp_init(&dtime, 500.0f, 1); | |
| 27 | + tSample_init(&sample, leaf.sampleRate * 4); | |
| 37 | 28 | |
| 38 | − | |
| 39 | − setSliderValue("mix", reverb.mix); | |
| 40 | − setSliderValue("predelay", reverb.predelay / 200.0f); | |
| 41 | − setSliderValue("input filter", reverb.input_filter / 20000.0f); | |
| 42 | − setSliderValue("feedback filter", reverb.feedback_filter / 20000.0f); | |
| 43 | − setSliderValue("feedback gain", reverb.feedback_gain); | |
| 44 | − setSliderValue("size", reverb.size / 4.0f); | |
| 29 | + tSamplePlayer_init(&player, &sample); | |
| 30 | + tSamplePlayer_setMode(&player, Loop); | |
| 45 | 31 | |
| 32 | + leaf_pool_report(); | |
| 46 | 33 | |
| 47 | − leaf_pool_report(); | |
| 34 | + tSample_start(&sample); | |
| 48 | 35 | } |
| 49 | 36 | |
| 50 | 37 | int timer = 0; |
| 51 | − | |
| 52 | − | |
| 53 | −#define CLICK 0 | |
| 54 | 38 | |
| 55 | 39 | float LEAFTest_tick (float input) |
| 56 | 40 | { |
| 57 | −#if CLICK | |
| 58 | − input = 0.0f; | |
| 41 | + tSample_tick(&sample, input); | |
| 59 | 42 | |
| 60 | 43 | timer++; |
| 61 | − if (timer == (1 * leaf.sampleRate)) | |
| 44 | + | |
| 45 | + if (timer >= leaf.sampleRate * 4) | |
| 62 | 46 | { |
| 63 | − timer = 0; | |
| 64 | − | |
| 65 | − input = 1.0f; | |
| 47 | + tSamplePlayer_play(&player); | |
| 66 | 48 | } |
| 67 | −#endif | |
| 68 | − //tTapeDelay_setDelay(&delay, tRamp_tick(&dtime)); | |
| 69 | − | |
| 70 | − //return tTapeDelay_tick(&delay, input); | |
| 71 | − | |
| 72 | − | |
| 73 | − tDattorro_setSize(&reverb, tRamp_tick(&dtime)); | |
| 74 | − | |
| 75 | − return tDattorro_tick(&reverb, input); | |
| 76 | 49 | |
| 50 | + return tSamplePlayer_tick(&player); | |
| 77 | 51 | } |
| 78 | − | |
| 52 | + | |
| 53 | +bool lastState = false; | |
| 79 | 54 | void LEAFTest_block (void) |
| 80 | 55 | { |
| 81 | − | |
| 82 | − float val = getSliderValue("mix"); | |
| 83 | − tDattorro_setMix(&reverb, val); | |
| 56 | + float val = getSliderValue("rate"); | |
| 84 | 57 | |
| 85 | − val = getSliderValue("predelay"); | |
| 86 | − tDattorro_setInputDelay(&reverb, val * 200.0f); | |
| 58 | + tSamplePlayer_setRate(&player, val * 16.0f - 8.0f); | |
| 87 | 59 | |
| 88 | − val = getSliderValue("input filter"); | |
| 89 | − tDattorro_setInputFilter(&reverb, val * 20000.0f); | |
| 60 | + val = getSliderValue("start"); | |
| 61 | + float start = val * sample.length; | |
| 62 | + tSamplePlayer_setStart(&player, start); | |
| 63 | + DBG("start: " + String(start)); | |
| 90 | 64 | |
| 91 | − val = getSliderValue("feedback filter"); | |
| 92 | − tDattorro_setFeedbackFilter(&reverb, val * 20000.0f); | |
| 65 | + val = getSliderValue("end"); | |
| 66 | + float end = val * sample.length; | |
| 67 | + tSamplePlayer_setEnd(&player, end); | |
| 68 | + DBG("end: " + String(end)); | |
| 93 | 69 | |
| 94 | − val = getSliderValue("feedback gain"); | |
| 95 | − tDattorro_setFeedbackGain(&reverb, val); | |
| 96 | − | |
| 97 | − val = getSliderValue("size"); | |
| 98 | − tRamp_setDest(&dtime, val * reverb.size_max); | |
| 70 | + bool state = getButtonState("sample"); | |
| 99 | 71 | |
| 72 | + if (state && !lastState) | |
| 73 | + { | |
| 74 | + timer = 0; | |
| 75 | + tSamplePlayer_stop(&player); | |
| 76 | + tSample_start(&sample); | |
| 77 | + } | |
| 100 | 78 | |
| 101 | − //float val = getSliderValue("size"); | |
| 102 | − //tRamp_setDest(&dtime, val * leaf.sampleRate + 1); | |
| 103 | − | |
| 79 | + lastState = state; | |
| 104 | 80 | } |
| 105 | 81 | |
| 106 | 82 | void LEAFTest_controllerInput (int cnum, float cval) |
| @@ -144,9 +144,9 @@ void UIComponent::sliderValueChanged(Slider* s) · 143 unmodified lines | ||
| 144 | 144 | setSliderValue(s->getName(), s->getValue()); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | −void UIComponent::buttonClicked (Button* b) | |
| 147 | +void UIComponent::buttonStateChanged (Button* b) | |
| 148 | 148 | { |
| 149 | − setButtonState(b->getName(), true); | |
| 149 | + setButtonState(b->getName(), b->getState()); | |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | void UIComponent::comboBoxChanged (ComboBox* cb) |
| @@ -35,7 +35,8 @@ public: · 34 unmodified lines | ||
| 35 | 35 | |
| 36 | 36 | void sliderValueChanged(Slider* s) override; |
| 37 | 37 | |
| 38 | − void buttonClicked (Button* b) override; | |
| 38 | + void buttonClicked(Button*b) override {}; | |
| 39 | + void buttonStateChanged(Button* b) override; | |
| 39 | 40 | |
| 40 | 41 | void textEditorTextChanged (TextEditor&) override; |
| 41 | 42 | |