History

mostly working bacf pitch detection

Matthew Wang committed 6 years ago

Commit 7c1652a1 parent 3e210947 files · +691 −45Browse files

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

Unified · Split

TestPlugin/Source/MyTest.cpp+26−14
@@ -33,6 +33,8 @@ tMBSaw bsaw; · 32 unmodified lines
3333 tMBTriangle btri;
3434 tMBPulse bpulse;
3535
36+tPitchDetector detector;
37+
3638 float gain;
3739 float freq;
3840 float dtime;
@@ -42,7 +44,7 @@ float x = 0.0f; · 3 unmodified lines
4244 float y = 0.0f;
4345 float a, b, c, d;
4446
45−#define MSIZE 50000
47+#define MSIZE 500000
4648 char memory[MSIZE];
4749
4850 void LEAFTest_init (float sampleRate, int blockSize)
@@ -52,6 +54,8 @@ void LEAFTest_init (float sampleRate, int blockSize) · 3 unmodified lines
5254 tMBSaw_init(&bsaw);
5355 tMBTriangle_init(&btri);
5456 tMBPulse_init(&bpulse);
57+
58+ tPitchDetector_init(&detector, 1000.0f, 5000.0f, 0.0f);
5559 }
5660
5761 inline double getSawFall(double angle) {
@@ -65,22 +69,30 @@ inline double getSawFall(double angle) { · 7 unmodified lines
6569
6670 float LEAFTest_tick (float input)
6771 {
68− tMBSaw_setFreq(&bsaw, x);
69− tMBTriangle_setFreq(&btri, x);
70− tMBPulse_setFreq(&bpulse, x);
71−
72− tMBTriangle_setWidth(&btri, y);
73− tMBPulse_setWidth(&bpulse, y);
74−
75−// return tMBSaw_tick(&bsaw);
76−// return tMBTriangle_tick(&btri);
77− return tMBPulse_tick(&bpulse);
72+// tMBSaw_setFreq(&bsaw, x);
73+// tMBTriangle_setFreq(&btri, x);
74+// tMBPulse_setFreq(&bpulse, x);
75+//
76+// tMBTriangle_setWidth(&btri, y);
77+// tMBPulse_setWidth(&bpulse, y);
78+//
79+//// return tMBSaw_tick(&bsaw);
80+//// return tMBTriangle_tick(&btri);
81+// return tMBPulse_tick(&bpulse);
82+
83+ tPitchDetector_tick(&detector, input);
84+
85+ tMBTriangle_setFreq(&btri, tPitchDetector_getFrequency(&detector));
86+
87+ return input + tMBTriangle_tick(&btri) * 0.25;
7888 }
7989
8090 int firstFrame = 1;
8191 bool lastState = false, lastPlayState = false;
8292 void LEAFTest_block (void)
8393 {
94+ DBG(tPitchDetector_getFrequency(&detector));
95+ DBG(tPitchDetector_getPeriodicity(&detector));
8496 // if (firstFrame == 1)
8597 // {
8698 // tBuffer_record(&buff); // starts recording
@@ -94,15 +106,15 @@ void LEAFTest_block (void) · 7 unmodified lines
94106
95107 // a = val * tBuffer_getBufferLength(&buff);
96108
97− DBG("start: " + String(a));
109+// DBG("start: " + String(a));
98110
99111 val = getSliderValue("mod depth");
100112
101113 y = val * 2.0f - 1.0f;
102− DBG(String(y));
114+// DBG(String(y));
103115 // b = val * tBuffer_getBufferLength(&buff);
104116
105− DBG("rate: " + String(b));
117+// DBG("rate: " + String(b));
106118 //
107119 // tSampler_setStart(&samp, a);
108120 // tSampler_setEnd(&samp, b);

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