| @@ -21,6 +21,10 @@ tSVF bp1; · 20 unmodified lines |
| 21 | tSVF bp2; | 21 | tSVF bp2; |
| 22 | tFormantShifter fs; | 22 | tFormantShifter fs; |
| 23 | | 23 | |
| | 24 | tSampler samp; |
| | 25 | tBuffer buff; |
| | 26 | tEnvelope env; |
| | 27 | |
| 24 | float gain; | 28 | float gain; |
| 25 | float freq; | 29 | float freq; |
| 26 | float dtime; | 30 | float dtime; |
| @@ -28,6 +32,7 @@ bool buttonState; · 1 unmodified line |
| 28 | int ratio = 2; | 32 | int ratio = 2; |
| 29 | float x = 0.0f; | 33 | float x = 0.0f; |
| 30 | float y = 0.0f; | 34 | float y = 0.0f; |
| | 35 | float a, b, c, d; |
| 31 | | 36 | |
| 32 | #define MSIZE 500000 | 37 | #define MSIZE 500000 |
| 33 | char memory[MSIZE]; | 38 | char memory[MSIZE]; |
| @@ -42,36 +47,62 @@ void LEAFTest_init (float sampleRate, int blockSize) · 8 unmodified lines |
| 42 | tSVF_init(&bp2, SVFTypeBandpass, 1000, 4.0f); | 47 | tSVF_init(&bp2, SVFTypeBandpass, 1000, 4.0f); |
| 43 | | 48 | |
| 44 | tFormantShifter_init(&fs, 2048, 20); | 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 | float LEAFTest_tick (float input) | 61 | float LEAFTest_tick (float input) |
| 48 | { | 62 | { |
| 49 | float sample = tNoise_tick(&noise); | 63 | // float sample = tNoise_tick(&noise); |
| 50 | sample *= 0.5f; | 64 | // sample *= 0.5f; |
| 51 | float b = tSVF_tick(&bp1, sample); | 65 | // float b = tSVF_tick(&bp1, sample); |
| 52 | b += tSVF_tick(&bp2, 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 | bool lastState = false, lastPlayState = false; | 76 | bool lastState = false, lastPlayState = false; |
| 59 | void LEAFTest_block (void) | 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 | float val = getSliderValue("mod freq"); | 86 | float val = getSliderValue("mod freq"); |
| 62 | | 87 | |
| 63 | x = val * 3.5f + 0.5f; | 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 | val = getSliderValue("mod depth"); | 94 | val = getSliderValue("mod depth"); |
| 68 | | 95 | |
| 69 | y = val * 49.0f + 1.0f; | 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); | 104 | // tFormantShifter_setShiftFactor(&fs, x); |
| 74 | tFormantShifter_setIntensity(&fs, y); | 105 | // tFormantShifter_setIntensity(&fs, y); |
| 75 | | 106 | |
| 76 | } | 107 | } |
| 77 | | 108 | |