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
40tZeroCrossingCounter zc;40tZeroCrossingCounter zc;
41tEnvelopeFollower ef;41tEnvelopeFollower ef;
42 42
43tCycle sine;
44
43float gain;45float gain;
44float dtime;46float dtime;
45bool buttonState;47bool buttonState;
@@ -71,6 +73,9 @@ void LEAFTest_init (float sampleRate, int blockSize) · 25 unmodified lines
71 73
72 tZeroCrossingCounter_init(&zc, 128);74 tZeroCrossingCounter_init(&zc, 128);
73 tEnvelopeFollower_init(&ef, 0.02f, 0.9999f);75 tEnvelopeFollower_init(&ef, 0.02f, 0.9999f);
76
77 tCycle_init(&sine);
78 tCycle_setFreq(&sine, 100);
74}79}
75 80
76inline double getSawFall(double angle) {81inline double getSawFall(double angle) {
@@ -99,32 +104,31 @@ float LEAFTest_tick (float input) · 22 unmodified lines
99 104
100 float freq = 1.0f/tPeriodDetection_tick(&pd, input) * leaf.sampleRate;105 float freq = 1.0f/tPeriodDetection_tick(&pd, input) * leaf.sampleRate;
101 tPitchDetector_tick(&detector, input);106 tPitchDetector_tick(&detector, input);
107 float altFreq = tPitchDetector_getFrequency(&detector);
102 108
103 if (tPitchDetector_getPeriodicity(&detector) > 0.0)109 if (fabsf(1.0f - (freq / altFreq)) < 0.05f)
104 {
105 float altFreq = tPitchDetector_getFrequency(&detector);
106// if (fabsf(lastFreq - freq) > fabsf(lastFreq - altFreq))
107 freq = altFreq;
108 }
109
110// if (tZeroCrossingCounter_tick(&zc, input) < 0.05 && freq > 0.0f)110// if (tZeroCrossingCounter_tick(&zc, input) < 0.05 && freq > 0.0f)
111 {111 {
112 tMBTriangle_setFreq(&btri, freq);112 tCycle_setFreq(&sine, altFreq);
113 }113 }
114 114
115 float g = tEnvelopeFollower_tick(&ef, input);115 float g = tEnvelopeFollower_tick(&ef, input);
116 116
117 lastFreq = freq;117 lastFreq = freq;
118 118
119 return input + tMBTriangle_tick(&btri) * g * 10.0f;119 return tCycle_tick(&sine) * g * 2.0f + input;
120}120}
121 121
122int firstFrame = 1;122int firstFrame = 1;
123bool lastState = false, lastPlayState = false;123bool lastState = false, lastPlayState = false;
124void LEAFTest_block (void)124void LEAFTest_block (void)
125{125{
126 DBG(tPitchDetector_getFrequency(&detector));126 float periodicity = tPitchDetector_getPeriodicity(&detector);
127 DBG(tPitchDetector_getPeriodicity(&detector));127 if (periodicity > 0.99f)
128 {
129 DBG(tPitchDetector_getFrequency(&detector));
130 DBG(tPitchDetector_getPeriodicity(&detector));
131 }
128 // if (firstFrame == 1)132 // if (firstFrame == 1)
129 // {133 // {
130 // tBuffer_record(&buff); // starts recording134 // 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