History

mostly working minblep sampler

Matthew Wang committed 6 years ago

Commit 382ddd11 parent d634fb36 files · +480 −101Browse files

Showing the changes to TestPlugin/Source/MyTest.cpp (1 of 6 files). Show all

Unified · Split

TestPlugin/Source/MyTest.cpp+44−55
@@ -14,21 +14,6 @@ static void leaf_pool_report(void); · 13 unmodified lines
1414 static void leaf_pool_dump(void);
1515 static void run_pool_test(void);
1616
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−
3217 tMBSaw bsaw;
3318 tMBTriangle btri;
3419 tMBPulse bpulse;
@@ -42,6 +27,9 @@ tEnvelopeFollower ef; · 7 unmodified lines
4227
4328 tCycle sine;
4429
30+tBuffer samp;
31+tMBSampler sampler;
32+
4533 float gain;
4634 float dtime;
4735 bool buttonState;
@@ -53,7 +41,7 @@ float a, b, c, d; · 5 unmodified lines
5341 float* bufIn;
5442 float* bufOut;
5543
56−#define MSIZE 500000
44+#define MSIZE 2048000
5745 char memory[MSIZE];
5846
5947 void LEAFTest_init (float sampleRate, int blockSize)
@@ -76,6 +64,12 @@ void LEAFTest_init (float sampleRate, int blockSize) · 16 unmodified lines
7664
7765 tCycle_init(&sine);
7866 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);
7973 }
8074
8175 inline double getSawFall(double angle) {
@@ -90,6 +84,11 @@ inline double getSawFall(double angle) { · 8 unmodified lines
9084 float lastFreq;
9185 float LEAFTest_tick (float input)
9286 {
87+ tBuffer_tick(&samp, input);
88+
89+ return tMBSampler_tick(&sampler);
90+
91+
9392 // tMBSaw_setFreq(&bsaw, x);
9493 // tMBTriangle_setFreq(&btri, x);
9594 // tMBPulse_setFreq(&bpulse, x);
@@ -102,21 +101,21 @@ float LEAFTest_tick (float input) · 6 unmodified lines
102101 // return tMBPulse_tick(&bpulse);
103102
104103
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;
120119 }
121120
122121 int firstFrame = 1;
@@ -129,37 +128,27 @@ void LEAFTest_block (void) · 6 unmodified lines
129128 DBG(tPitchDetector_getFrequency(&detector));
130129 DBG(tPitchDetector_getPeriodicity(&detector));
131130 }
132− // if (firstFrame == 1)
133− // {
134− // tBuffer_record(&buff); // starts recording
135− // tSampler_play(&samp); // start spitting samples out
136− // firstFrame = 0;
137− // }
138131
139− float val = getSliderValue("mod freq");
132+ float val = getSliderValue("on/off");
140133
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+ }
144143
145− // a = val * tBuffer_getBufferLength(&buff);
144+ val = getSliderValue("mod freq");
146145
147−// DBG("start: " + String(a));
146+ tMBSampler_setStart(&sampler, val * 5.0f * leaf.sampleRate);
147+
148148
149149 val = getSliderValue("mod depth");
150150
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);
163152
164153 }
165154

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t