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
35 35
36tPitchDetector detector;36tPitchDetector detector;
37 37
38tPeriodDetection pd;
39
38float gain;40float gain;
39float freq;41float freq;
40float dtime;42float dtime;
@@ -44,6 +46,9 @@ float x = 0.0f; · 3 unmodified lines
44float y = 0.0f;46float y = 0.0f;
45float a, b, c, d;47float a, b, c, d;
46 48
49float bufIn[4096];
50float bufOut[4096];
51
47#define MSIZE 50000052#define MSIZE 500000
48char memory[MSIZE];53char memory[MSIZE];
49 54
@@ -55,7 +60,11 @@ void LEAFTest_init (float sampleRate, int blockSize) · 5 unmodified lines
55 tMBTriangle_init(&btri);60 tMBTriangle_init(&btri);
56 tMBPulse_init(&bpulse);61 tMBPulse_init(&bpulse);
57 62
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);
59}68}
60 69
61inline double getSawFall(double angle) {70inline double getSawFall(double angle) {
@@ -81,10 +90,13 @@ float LEAFTest_tick (float input) · 19 unmodified lines
81// return tMBPulse_tick(&bpulse);90// return tMBPulse_tick(&bpulse);
82 91
83 tPitchDetector_tick(&detector, input);92 tPitchDetector_tick(&detector, input);
84 93
85 tMBTriangle_setFreq(&btri, tPitchDetector_getFrequency(&detector));94 tMBTriangle_setFreq(&btri, tPitchDetector_getFrequency(&detector));
86 95
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;
88}100}
89 101
90int firstFrame = 1;102int 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