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