History

getting new pitch detection working in retune and autotune

Matthew Wang committed 6 years ago

Commit 11c878e1 parent 17430886 files · +157 −531Browse files

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

Unified · Split

TestPlugin/Source/MyTest.cpp+14−86
@@ -18,7 +18,8 @@ tMBSaw bsaw; · 17 unmodified lines
1818 tMBTriangle btri;
1919 tMBPulse bpulse;
2020
21−tDualPitchDetector detector;
21+tRetune retune;
22+tAutotune autotune;
2223
2324 tCompressor compressor;
2425
@@ -54,33 +55,8 @@ void LEAFTest_init (float sampleRate, int blockSize) · 29 unmodified lines
5455 {
5556 LEAF_init(&leaf, sampleRate, blockSize, memory, MSIZE, &getRandomFloat);
5657
57− tMBSaw_init(&bsaw, &leaf);
58− tMBTriangle_init(&btri, &leaf);
59− tMBPulse_init(&bpulse, &leaf);
60−
61− bufIn = (float*) leaf_alloc(&leaf, sizeof(float) * 4096);
62− bufOut = (float*) leaf_alloc(&leaf, sizeof(float) * 4096);
63−
64− tDualPitchDetector_init(&detector, mtof(48), mtof(84), &leaf);
65−
66− tCompressor_init(&compressor, &leaf);
67−
68− tSVF_init(&lp, SVFTypeLowpass, mtof(84) * 2.0f, 1.0f, &leaf);
69− tSVF_init(&hp, SVFTypeHighpass, mtof(48) * 0.5f, 1.0f, &leaf);
70−
71− tPeriodDetection_init(&pd, bufIn, bufOut, 4096, 1024, &leaf);
72−
73− tZeroCrossingCounter_init(&zc, 128, &leaf);
74− tEnvelopeFollower_init(&ef, 0.02f, 0.9999f, &leaf);
75−
76− tTriangle_init(&tri, &leaf);
77− tTriangle_setFreq(&tri, 100);
78−
79− tBuffer_init(&samp, 5.0f * leaf.sampleRate, &leaf);
80− tMBSampler_init(&sampler, &samp, &leaf);
81−
82− tMBSampler_setMode(&sampler, PlayLoop);
83− tMBSampler_setEnd(&sampler, samp->bufferLength);
58+ tRetune_init(&retune, 1, 1024, &leaf);
59+ tAutotune_init(&autotune, 1, 1024, &leaf);
8460 }
8561
8662 inline double getSawFall(double angle) {
@@ -94,72 +70,24 @@ inline double getSawFall(double angle) { · 7 unmodified lines
9470
9571 float LEAFTest_tick (float input)
9672 {
97− tBuffer_tick(&samp, input);
98−
99− return tMBSampler_tick(&sampler);
100−
101−
102−// tMBSaw_setFreq(&bsaw, x);
103−// tMBTriangle_setFreq(&btri, x);
104−// tMBPulse_setFreq(&bpulse, x);
105−//
106−// tMBTriangle_setWidth(&btri, y);
107−// tMBPulse_setWidth(&bpulse, y);
108−//
109−//// return tMBSaw_tick(&bsaw);
110−//// return tMBTriangle_tick(&btri);
111−// return tMBPulse_tick(&bpulse);
112−
113−// input = tSVF_tick(&hp, tSVF_tick(&lp, tCompressor_tick(&compressor, input)));
114−//
115−//// float freq = 1.0f/tPeriodDetection_tick(&pd, input) * leaf.sampleRate;
116−// tDualPitchDetector_tick(&detector, input);
117−// float altFreq = tDualPitchDetector_getFrequency(&detector);
118−//
119−//// if (fabsf(1.0f - (freq / altFreq)) < 0.05f)
120−//// if (tZeroCrossingCounter_tick(&zc, input) < 0.05 && freq > 0.0f)
121−// if (altFreq > 0.0f)
122−// {
123−// tTriangle_setFreq(&tri, altFreq);
124−// }
125−//
126−// float g = tEnvelopeFollower_tick(&ef, input);
127−//
128−// return tTriangle_tick(&tri) * g;
73+// return tRetune_tick(&retune, input);
74+ return tAutotune_tick(&autotune, input);
12975 }
13076
13177 int firstFrame = 1;
13278 bool lastState = false, lastPlayState = false;
13379 void LEAFTest_block (void)
13480 {
135− float periodicity = tDualPitchDetector_getPeriodicity(&detector);
136− if (periodicity > 0.99f)
137− {
138− DBG(tDualPitchDetector_getFrequency(&detector));
139− DBG(tDualPitchDetector_getPeriodicity(&detector));
140− }
141−
142− float val = getSliderValue("on/off");
143−
144− if (val > 0.5f && !sampler->active)
145− {
146− tBuffer_record(&samp);
147− tMBSampler_play(&sampler);
148− }
149− else if (val < 0.5f && sampler->active)
150− {
151− tMBSampler_stop(&sampler);
152− }
153−
154− val = getSliderValue("mod freq");
155−
156− tMBSampler_setStart(&sampler, val * 5.0f * leaf.sampleRate);
81+ float val = getSliderValue("slider1");
82+// tRetune_setPitchFactor(&retune, val * 3.0f + 0.5f, 0);
83+ tAutotune_setFreq(&autotune, 300, 0);
15784
85+ val = getSliderValue("slider2");
86+// tRetune_setPitchFactor(&retune, val * 3.0f + 0.5f, 1);
15887
159− val = getSliderValue("mod depth");
160−
161− tMBSampler_setRate(&sampler, val * 8.0f - 4.0f);
162−
88+ val = getSliderValue("slider3");
89+// tRetune_setPitchFactor(&retune, val * 3.0f + 0.5f, 2);
90+
16391 }
16492
16593 void LEAFTest_controllerInput (int cnum, float cval)

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