Showing the changes to TestPlugin/Source/MyTest.cpp (1 of 6 files). Show all
Unified · Split
| @@ -14,21 +14,6 @@ static void leaf_pool_report(void); · 13 unmodified lines | ||
| 14 | 14 | static void leaf_pool_dump(void); |
| 15 | 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 | 17 | tMBSaw bsaw; |
| 33 | 18 | tMBTriangle btri; |
| 34 | 19 | tMBPulse bpulse; |
| @@ -42,6 +27,9 @@ tEnvelopeFollower ef; · 7 unmodified lines | ||
| 42 | 27 | |
| 43 | 28 | tCycle sine; |
| 44 | 29 | |
| 30 | +tBuffer samp; | |
| 31 | +tMBSampler sampler; | |
| 32 | + | |
| 45 | 33 | float gain; |
| 46 | 34 | float dtime; |
| 47 | 35 | bool buttonState; |
| @@ -53,7 +41,7 @@ float a, b, c, d; · 5 unmodified lines | ||
| 53 | 41 | float* bufIn; |
| 54 | 42 | float* bufOut; |
| 55 | 43 | |
| 56 | −#define MSIZE 500000 | |
| 44 | +#define MSIZE 2048000 | |
| 57 | 45 | char memory[MSIZE]; |
| 58 | 46 | |
| 59 | 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 | 65 | tCycle_init(&sine); |
| 78 | 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 | 75 | inline double getSawFall(double angle) { |
| @@ -90,6 +84,11 @@ inline double getSawFall(double angle) { · 8 unmodified lines | ||
| 90 | 84 | float lastFreq; |
| 91 | 85 | float LEAFTest_tick (float input) |
| 92 | 86 | { |
| 87 | + tBuffer_tick(&samp, input); | |
| 88 | + | |
| 89 | + return tMBSampler_tick(&sampler); | |
| 90 | + | |
| 91 | + | |
| 93 | 92 | // tMBSaw_setFreq(&bsaw, x); |
| 94 | 93 | // tMBTriangle_setFreq(&btri, x); |
| 95 | 94 | // tMBPulse_setFreq(&bpulse, x); |
| @@ -102,21 +101,21 @@ float LEAFTest_tick (float input) · 6 unmodified lines | ||
| 102 | 101 | // return tMBPulse_tick(&bpulse); |
| 103 | 102 | |
| 104 | 103 | |
| 105 | − float freq = 1.0f/tPeriodDetection_tick(&pd, input) * leaf.sampleRate; | |
| 106 | − tPitchDetector_tick(&detector, input); | |
| 107 | − float altFreq = tPitchDetector_getFrequency(&detector); | |
| 108 | − | |
| 109 | − if (fabsf(1.0f - (freq / altFreq)) < 0.05f) | |
| 110 | −// if (tZeroCrossingCounter_tick(&zc, input) < 0.05 && freq > 0.0f) | |
| 111 | − { | |
| 112 | − tCycle_setFreq(&sine, altFreq); | |
| 113 | − } | |
| 114 | − | |
| 115 | − float g = tEnvelopeFollower_tick(&ef, input); | |
| 116 | − | |
| 117 | − lastFreq = freq; | |
| 118 | − | |
| 119 | − return tCycle_tick(&sine) * g * 2.0f + input; | |
| 104 | +// float freq = 1.0f/tPeriodDetection_tick(&pd, input) * leaf.sampleRate; | |
| 105 | +// tPitchDetector_tick(&detector, input); | |
| 106 | +// float altFreq = tPitchDetector_getFrequency(&detector); | |
| 107 | +// | |
| 108 | +// if (fabsf(1.0f - (freq / altFreq)) < 0.05f) | |
| 109 | +//// if (tZeroCrossingCounter_tick(&zc, input) < 0.05 && freq > 0.0f) | |
| 110 | +// { | |
| 111 | +// tCycle_setFreq(&sine, altFreq); | |
| 112 | +// } | |
| 113 | +// | |
| 114 | +// float g = tEnvelopeFollower_tick(&ef, input); | |
| 115 | +// | |
| 116 | +// lastFreq = freq; | |
| 117 | +// | |
| 118 | +// return tCycle_tick(&sine) * g * 2.0f + input; | |
| 120 | 119 | } |
| 121 | 120 | |
| 122 | 121 | int firstFrame = 1; |
| @@ -129,37 +128,27 @@ void LEAFTest_block (void) · 6 unmodified lines | ||
| 129 | 128 | DBG(tPitchDetector_getFrequency(&detector)); |
| 130 | 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; | |
| 142 | − | |
| 143 | − | |
| 134 | + if (val > 0.5f && !sampler->active) | |
| 135 | + { | |
| 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 | 149 | val = getSliderValue("mod depth"); |
| 150 | 150 | |
| 151 | − y = val * 2.0f - 1.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); | |
| 151 | + tMBSampler_setRate(&sampler, val * 8.0f - 4.0f); | |
| 163 | 152 | |
| 164 | 153 | } |
| 165 | 154 | |