Showing the changes to TestPlugin/Source (1 of 6 files). Show all
Unified · Split
| @@ -14,21 +14,6 @@ static void leaf_pool_report(void); · 13 unmodified lines | |||
| 14 | static void leaf_pool_dump(void); | 14 | static void leaf_pool_dump(void); |
| 15 | static void run_pool_test(void); | 15 | static void run_pool_test(void); |
| 16 | 16 | ||
| 17 | tNoise noise; | ||
| 18 | tSVF bp1; | ||
| 19 | tSVF bp2; | ||
| 20 | tFormantShifter fs; | ||
| 21 | |||
| 22 | tSampler samp; | ||
| 23 | tBuffer buff; | ||
| 24 | tEnvelope env; | ||
| 25 | |||
| 26 | tAutotune at; | ||
| 27 | |||
| 28 | tPhasor phasor; | ||
| 29 | |||
| 30 | tHighpass hipass; | ||
| 31 | |||
| 32 | tMBSaw bsaw; | 17 | tMBSaw bsaw; |
| 33 | tMBTriangle btri; | 18 | tMBTriangle btri; |
| 34 | tMBPulse bpulse; | 19 | tMBPulse bpulse; |
| @@ -42,6 +27,9 @@ tEnvelopeFollower ef; · 7 unmodified lines | |||
| 42 | 27 | ||
| 43 | tCycle sine; | 28 | tCycle sine; |
| 44 | 29 | ||
| 30 | tBuffer samp; | ||
| 31 | tMBSampler sampler; | ||
| 32 | |||
| 45 | float gain; | 33 | float gain; |
| 46 | float dtime; | 34 | float dtime; |
| 47 | bool buttonState; | 35 | bool buttonState; |
| @@ -53,7 +41,7 @@ float a, b, c, d; · 5 unmodified lines | |||
| 53 | float* bufIn; | 41 | float* bufIn; |
| 54 | float* bufOut; | 42 | float* bufOut; |
| 55 | 43 | ||
| 56 | #define MSIZE 500000 | 44 | #define MSIZE 2048000 |
| 57 | char memory[MSIZE]; | 45 | char memory[MSIZE]; |
| 58 | 46 | ||
| 59 | void LEAFTest_init (float sampleRate, int blockSize) | 47 | void LEAFTest_init (float sampleRate, int blockSize) |
| @@ -76,6 +64,12 @@ void LEAFTest_init (float sampleRate, int blockSize) · 16 unmodified lines | |||
| 76 | 64 | ||
| 77 | tCycle_init(&sine); | 65 | tCycle_init(&sine); |
| 78 | tCycle_setFreq(&sine, 100); | 66 | tCycle_setFreq(&sine, 100); |
| 67 | |||
| 68 | tBuffer_init(&samp, 5.0f * leaf.sampleRate); | ||
| 69 | tMBSampler_init(&sampler, &samp); | ||
| 70 | |||
| 71 | tMBSampler_setMode(&sampler, PlayLoop); | ||
| 72 | tMBSampler_setEnd(&sampler, samp->bufferLength); | ||
| 79 | } | 73 | } |
| 80 | 74 | ||
| 81 | inline double getSawFall(double angle) { | 75 | inline double getSawFall(double angle) { |
| @@ -90,6 +84,11 @@ inline double getSawFall(double angle) { · 8 unmodified lines | |||
| 90 | float lastFreq; | 84 | float lastFreq; |
| 91 | float LEAFTest_tick (float input) | 85 | float LEAFTest_tick (float input) |
| 92 | { | 86 | { |
| 87 | tBuffer_tick(&samp, input); | ||
| 88 | |||
| 89 | return tMBSampler_tick(&sampler); | ||
| 90 | |||
| 91 | |||
| 93 | // tMBSaw_setFreq(&bsaw, x); | 92 | // tMBSaw_setFreq(&bsaw, x); |
| 94 | // tMBTriangle_setFreq(&btri, x); | 93 | // tMBTriangle_setFreq(&btri, x); |
| 95 | // tMBPulse_setFreq(&bpulse, x); | 94 | // tMBPulse_setFreq(&bpulse, x); |
| @@ -102,21 +101,21 @@ float LEAFTest_tick (float input) · 6 unmodified lines | |||
| 102 | // return tMBPulse_tick(&bpulse); | 101 | // return tMBPulse_tick(&bpulse); |
| 103 | 102 | ||
| 104 | 103 | ||
| 105 | float freq = 1.0f/tPeriodDetection_tick(&pd, input) * leaf.sampleRate; | 104 | // float freq = 1.0f/tPeriodDetection_tick(&pd, input) * leaf.sampleRate; |
| 106 | tPitchDetector_tick(&detector, input); | 105 | // tPitchDetector_tick(&detector, input); |
| 107 | float altFreq = tPitchDetector_getFrequency(&detector); | 106 | // float altFreq = tPitchDetector_getFrequency(&detector); |
| 108 | 107 | // | |
| 109 | if (fabsf(1.0f - (freq / altFreq)) < 0.05f) | 108 | // if (fabsf(1.0f - (freq / altFreq)) < 0.05f) |
| 110 | // if (tZeroCrossingCounter_tick(&zc, input) < 0.05 && freq > 0.0f) | 109 | //// if (tZeroCrossingCounter_tick(&zc, input) < 0.05 && freq > 0.0f) |
| 111 | { | 110 | // { |
| 112 | tCycle_setFreq(&sine, altFreq); | 111 | // tCycle_setFreq(&sine, altFreq); |
| 113 | } | 112 | // } |
| 114 | 113 | // | |
| 115 | float g = tEnvelopeFollower_tick(&ef, input); | 114 | // float g = tEnvelopeFollower_tick(&ef, input); |
| 116 | 115 | // | |
| 117 | lastFreq = freq; | 116 | // lastFreq = freq; |
| 118 | 117 | // | |
| 119 | return tCycle_tick(&sine) * g * 2.0f + input; | 118 | // return tCycle_tick(&sine) * g * 2.0f + input; |
| 120 | } | 119 | } |
| 121 | 120 | ||
| 122 | int firstFrame = 1; | 121 | int firstFrame = 1; |
| @@ -129,37 +128,27 @@ void LEAFTest_block (void) · 6 unmodified lines | |||
| 129 | DBG(tPitchDetector_getFrequency(&detector)); | 128 | DBG(tPitchDetector_getFrequency(&detector)); |
| 130 | DBG(tPitchDetector_getPeriodicity(&detector)); | 129 | DBG(tPitchDetector_getPeriodicity(&detector)); |
| 131 | } | 130 | } |
| 132 | // if (firstFrame == 1) | ||
| 133 | // { | ||
| 134 | // tBuffer_record(&buff); // starts recording | ||
| 135 | // tSampler_play(&samp); // start spitting samples out | ||
| 136 | // firstFrame = 0; | ||
| 137 | // } | ||
| 138 | 131 | ||
| 139 | float val = getSliderValue("mod freq"); | 132 | float val = getSliderValue("on/off"); |
| 140 | 133 | ||
| 141 | x = val; | 134 | if (val > 0.5f && !sampler->active) |
| 142 | 135 | { | |
| 143 | 136 | tBuffer_record(&samp); | |
| 137 | tMBSampler_play(&sampler); | ||
| 138 | } | ||
| 139 | else if (val < 0.5f && sampler->active) | ||
| 140 | { | ||
| 141 | tMBSampler_stop(&sampler); | ||
| 142 | } | ||
| 144 | 143 | ||
| 145 | // a = val * tBuffer_getBufferLength(&buff); | 144 | val = getSliderValue("mod freq"); |
| 146 | 145 | ||
| 147 | // DBG("start: " + String(a)); | 146 | tMBSampler_setStart(&sampler, val * 5.0f * leaf.sampleRate); |
| 147 | |||
| 148 | 148 | ||
| 149 | val = getSliderValue("mod depth"); | 149 | val = getSliderValue("mod depth"); |
| 150 | 150 | ||
| 151 | y = val * 2.0f - 1.0f; | 151 | tMBSampler_setRate(&sampler, val * 8.0f - 4.0f); |
| 152 | // DBG(String(y)); | ||
| 153 | // b = val * tBuffer_getBufferLength(&buff); | ||
| 154 | |||
| 155 | // DBG("rate: " + String(b)); | ||
| 156 | // | ||
| 157 | // tSampler_setStart(&samp, a); | ||
| 158 | // tSampler_setEnd(&samp, b); | ||
| 159 | // tSampler_setRate(&samp, b); | ||
| 160 | |||
| 161 | // tFormantShifter_setShiftFactor(&fs, x); | ||
| 162 | // tFormantShifter_setIntensity(&fs, y); | ||
| 163 | 152 | ||
| 164 | } | 153 | } |
| 165 | 154 | ||