History

pitch detector testing

Matthew Wang committed 6 years ago

Commit 327ba3d1 parent 7acbeda3 files · +28 −18Browse files

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

Unified · Split

TestPlugin/Source/MyTest.cpp+14−13
@@ -82,6 +82,7 @@ inline double getSawFall(double angle) { · 81 unmodified lines
82 82
83}83}
84 84
85float lastFreq;
85float LEAFTest_tick (float input)86float LEAFTest_tick (float input)
86{87{
87// tMBSaw_setFreq(&bsaw, x);88// tMBSaw_setFreq(&bsaw, x);
@@ -96,25 +97,25 @@ float LEAFTest_tick (float input) · 8 unmodified lines
96// return tMBPulse_tick(&bpulse);97// return tMBPulse_tick(&bpulse);
97 98
98 99
99 if (x > 0.5)100 float freq = 1.0f/tPeriodDetection_tick(&pd, input) * leaf.sampleRate;
100 {101 tPitchDetector_tick(&detector, input);
101 tPitchDetector_tick(&detector, input);
102 if (tPitchDetector_getPeriodicity(&detector) > 0.99 && (tZeroCrossing_tick(&zc, input) < 0.05))
103 {
104 float freq = tPitchDetector_getFrequency(&detector);
105 if (freq != 0.0f)
106 tMBTriangle_setFreq(&btri, freq);
107 }
108 102
103 if (tPitchDetector_getPeriodicity(&detector) > 0.0)
104 {
105 float altFreq = tPitchDetector_getFrequency(&detector);
106 if (fabsf(lastFreq - freq) > fabsf(lastFreq - altFreq))
107 freq = altFreq;
109 }108 }
110 else109
110 if (tZeroCrossing_tick(&zc, input) < 0.05 && freq > 0.0f)
111 {111 {
112 float freq = 1.0f/tPeriodDetection_tick(&pd, input) * leaf.sampleRate;112 tMBTriangle_setFreq(&btri, freq);
113 if (tZeroCrossing_tick(&zc, input) < 0.05)
114 tMBTriangle_setFreq(&btri, freq);
115 }113 }
116 114
117 float g = tEnvelopeFollower_tick(&ef, input);115 float g = tEnvelopeFollower_tick(&ef, input);
116
117 lastFreq = freq;
118
118 return input + tMBTriangle_tick(&btri) * g * 10.0f;119 return input + tMBTriangle_tick(&btri) * g * 10.0f;
119}120}
120 121

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