| @@ -21,6 +21,10 @@ tSVF bp1; · 20 unmodified lines |
| 21 | 21 | tSVF bp2; |
| 22 | 22 | tFormantShifter fs; |
| 23 | 23 | |
| 24 | +tSampler samp; |
| 25 | +tBuffer buff; |
| 26 | +tEnvelope env; |
| 27 | + |
| 24 | 28 | float gain; |
| 25 | 29 | float freq; |
| 26 | 30 | float dtime; |
| @@ -28,6 +32,7 @@ bool buttonState; · 1 unmodified line |
| 28 | 32 | int ratio = 2; |
| 29 | 33 | float x = 0.0f; |
| 30 | 34 | float y = 0.0f; |
| 35 | +float a, b, c, d; |
| 31 | 36 | |
| 32 | 37 | #define MSIZE 500000 |
| 33 | 38 | char memory[MSIZE]; |
| @@ -42,36 +47,62 @@ void LEAFTest_init (float sampleRate, int blockSize) · 8 unmodified lines |
| 42 | 47 | tSVF_init(&bp2, SVFTypeBandpass, 1000, 4.0f); |
| 43 | 48 | |
| 44 | 49 | tFormantShifter_init(&fs, 2048, 20); |
| 50 | + |
| 51 | + // Init and set record |
| 52 | + tBuffer_init (&buff, leaf.sampleRate); // init, 1 second buffer |
| 53 | + tBuffer_setRecordMode (&buff, RecordOneShot); // RecordOneShot records once through |
| 54 | + |
| 55 | + // Init and set play |
| 56 | + tSampler_init (&samp, &buff); // init, give address of record buffer |
| 57 | + tSampler_setMode (&samp, PlayLoop); //set in Loop Mode |
| 58 | + tSampler_setRate(&samp, 1.f); // Rate of 1.0 |
| 45 | 59 | } |
| 46 | 60 | |
| 47 | 61 | float LEAFTest_tick (float input) |
| 48 | 62 | { |
| 49 | | − float sample = tNoise_tick(&noise); |
| 50 | | − sample *= 0.5f; |
| 51 | | − float b = tSVF_tick(&bp1, sample); |
| 52 | | − b += tSVF_tick(&bp2, sample); |
| 63 | +// float sample = tNoise_tick(&noise); |
| 64 | +// sample *= 0.5f; |
| 65 | +// float b = tSVF_tick(&bp1, sample); |
| 66 | +// b += tSVF_tick(&bp2, sample); |
| 67 | +// |
| 68 | +// return (tFormantShifter_tick(&fs, input)); |
| 53 | 69 | |
| 54 | | − return (tFormantShifter_tick(&fs, input)); |
| 70 | + tBuffer_tick(&buff, input); |
| 71 | + |
| 72 | + return tSampler_tick(&samp); |
| 55 | 73 | } |
| 56 | 74 | |
| 57 | | − |
| 75 | +int firstFrame = 1; |
| 58 | 76 | bool lastState = false, lastPlayState = false; |
| 59 | 77 | void LEAFTest_block (void) |
| 60 | 78 | { |
| 79 | + if (firstFrame == 1) |
| 80 | + { |
| 81 | + tBuffer_record(&buff); // starts recording |
| 82 | + tSampler_play(&samp); // start spitting samples out |
| 83 | + firstFrame = 0; |
| 84 | + } |
| 85 | + |
| 61 | 86 | float val = getSliderValue("mod freq"); |
| 62 | 87 | |
| 63 | 88 | x = val * 3.5f + 0.5f; |
| 64 | 89 | |
| 65 | | − DBG("fwarp: " + String(x)); |
| 90 | + a = val * tBuffer_getLength(&buff); |
| 91 | + |
| 92 | + DBG("start: " + String(a)); |
| 66 | 93 | |
| 67 | 94 | val = getSliderValue("mod depth"); |
| 68 | 95 | |
| 69 | 96 | y = val * 49.0f + 1.0f; |
| 97 | + b = val * 20.0f - 5.0f; |
| 98 | + |
| 99 | + DBG("rate: " + String(b)); |
| 70 | 100 | |
| 71 | | − DBG("intensity: " + String(y)); |
| 101 | + tSampler_setStart(&samp, a); |
| 102 | + tSampler_setRate(&samp, b); |
| 72 | 103 | |
| 73 | | − tFormantShifter_setShiftFactor(&fs, x); |
| 74 | | − tFormantShifter_setIntensity(&fs, y); |
| 104 | +// tFormantShifter_setShiftFactor(&fs, x); |
| 105 | +// tFormantShifter_setIntensity(&fs, y); |
| 75 | 106 | |
| 76 | 107 | } |
| 77 | 108 | |