History

working bacf pitch detection

Matthew Wang committed 6 years ago

Commit fdb31241 parent 7c1652a2 files · +24 −10Browse files

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

Unified · Split

TestPlugin/Source/MyTest.cpp+15−3
@@ -35,6 +35,8 @@ tMBPulse bpulse; · 34 unmodified lines
3535
3636 tPitchDetector detector;
3737
38+tPeriodDetection pd;
39+
3840 float gain;
3941 float freq;
4042 float dtime;
@@ -44,6 +46,9 @@ float x = 0.0f; · 3 unmodified lines
4446 float y = 0.0f;
4547 float a, b, c, d;
4648
49+float bufIn[4096];
50+float bufOut[4096];
51+
4752 #define MSIZE 500000
4853 char memory[MSIZE];
4954
@@ -55,7 +60,11 @@ void LEAFTest_init (float sampleRate, int blockSize) · 5 unmodified lines
5560 tMBTriangle_init(&btri);
5661 tMBPulse_init(&bpulse);
5762
58− tPitchDetector_init(&detector, 1000.0f, 5000.0f, 0.0f);
63+
64+ // lowestFreq, highestFreq, hysteresis (width of hysteresis region around 0.0 for zero crossing detection)
65+ tPitchDetector_init(&detector, mtof(48), mtof(84), 0.01f);
66+
67+ tPeriodDetection_init(&pd, bufIn, bufOut, 4096, 1024);
5968 }
6069
6170 inline double getSawFall(double angle) {
@@ -81,10 +90,13 @@ float LEAFTest_tick (float input) · 19 unmodified lines
8190 // return tMBPulse_tick(&bpulse);
8291
8392 tPitchDetector_tick(&detector, input);
84−
93+
8594 tMBTriangle_setFreq(&btri, tPitchDetector_getFrequency(&detector));
8695
87− return input + tMBTriangle_tick(&btri) * 0.25;
96+// float freq = 1.0f/tPeriodDetection_tick(&pd, input) * leaf.sampleRate;
97+// tMBTriangle_setFreq(&btri, freq);
98+
99+ return tMBTriangle_tick(&btri);// * 0.25;
88100 }
89101
90102 int firstFrame = 1;

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