History

more pitch detection testing; using both algs and only setting pitch when they match within some error works decently but at the cost of running both; at least suggests that they tend to make different errors

Matthew Wang committed 6 years ago

Commit d634fb31 parent 45af5ea3 files · +21 −13Browse files

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

Unified · Split

TestPlugin/Source/MyTest.cpp+15−11
@@ -40,6 +40,8 @@ tPeriodDetection pd; · 39 unmodified lines
4040 tZeroCrossingCounter zc;
4141 tEnvelopeFollower ef;
4242
43+tCycle sine;
44+
4345 float gain;
4446 float dtime;
4547 bool buttonState;
@@ -71,6 +73,9 @@ void LEAFTest_init (float sampleRate, int blockSize) · 25 unmodified lines
7173
7274 tZeroCrossingCounter_init(&zc, 128);
7375 tEnvelopeFollower_init(&ef, 0.02f, 0.9999f);
76+
77+ tCycle_init(&sine);
78+ tCycle_setFreq(&sine, 100);
7479 }
7580
7681 inline double getSawFall(double angle) {
@@ -99,32 +104,31 @@ float LEAFTest_tick (float input) · 22 unmodified lines
99104
100105 float freq = 1.0f/tPeriodDetection_tick(&pd, input) * leaf.sampleRate;
101106 tPitchDetector_tick(&detector, input);
107+ float altFreq = tPitchDetector_getFrequency(&detector);
102108
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;
108− }
109−
109+ if (fabsf(1.0f - (freq / altFreq)) < 0.05f)
110110 // if (tZeroCrossingCounter_tick(&zc, input) < 0.05 && freq > 0.0f)
111111 {
112− tMBTriangle_setFreq(&btri, freq);
112+ tCycle_setFreq(&sine, altFreq);
113113 }
114114
115115 float g = tEnvelopeFollower_tick(&ef, input);
116116
117117 lastFreq = freq;
118118
119− return input + tMBTriangle_tick(&btri) * g * 10.0f;
119+ return tCycle_tick(&sine) * g * 2.0f + input;
120120 }
121121
122122 int firstFrame = 1;
123123 bool lastState = false, lastPlayState = false;
124124 void LEAFTest_block (void)
125125 {
126− DBG(tPitchDetector_getFrequency(&detector));
127− DBG(tPitchDetector_getPeriodicity(&detector));
126+ float periodicity = tPitchDetector_getPeriodicity(&detector);
127+ if (periodicity > 0.99f)
128+ {
129+ DBG(tPitchDetector_getFrequency(&detector));
130+ DBG(tPitchDetector_getPeriodicity(&detector));
131+ }
128132 // if (firstFrame == 1)
129133 // {
130134 // tBuffer_record(&buff); // starts recording

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