History

bacf testing

Matthew Wang committed 6 years ago

Commit 65a3aed1 parent 9862cbb2 files · +33 −13Browse files

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

Unified · Split

TestPlugin/Source/MyTest.cpp+32−11
@@ -37,8 +37,10 @@ tPitchDetector detector; · 36 unmodified lines
3737
3838 tPeriodDetection pd;
3939
40+tZeroCrossing zc;
41+tEnvelopeFollower ef;
42+
4043 float gain;
41−float freq;
4244 float dtime;
4345 bool buttonState;
4446 int ratio = 2;
@@ -46,8 +48,8 @@ float x = 0.0f; · 1 unmodified line
4648 float y = 0.0f;
4749 float a, b, c, d;
4850
49−float bufIn[4096];
50−float bufOut[4096];
51+float* bufIn;
52+float* bufOut;
5153
5254 #define MSIZE 500000
5355 char memory[MSIZE];
@@ -60,11 +62,15 @@ void LEAFTest_init (float sampleRate, int blockSize) · 6 unmodified lines
6062 tMBTriangle_init(&btri);
6163 tMBPulse_init(&bpulse);
6264
63−
65+ bufIn = (float*) leaf_alloc(sizeof(float) * 4096);
66+ bufOut = (float*) leaf_alloc(sizeof(float) * 4096);
6467 // lowestFreq, highestFreq, hysteresis (width of hysteresis region around 0.0 for zero crossing detection)
6568 tPitchDetector_init(&detector, mtof(48), mtof(84), 0.01f);
6669
6770 tPeriodDetection_init(&pd, bufIn, bufOut, 4096, 1024);
71+
72+ tZeroCrossing_init(&zc, 128);
73+ tEnvelopeFollower_init(&ef, 0.02f, 0.9999f);
6874 }
6975
7076 inline double getSawFall(double angle) {
@@ -88,15 +94,28 @@ float LEAFTest_tick (float input) · 17 unmodified lines
8894 //// return tMBSaw_tick(&bsaw);
8995 //// return tMBTriangle_tick(&btri);
9096 // return tMBPulse_tick(&bpulse);
97+
9198
92− tPitchDetector_tick(&detector, input);
93−
94− tMBTriangle_setFreq(&btri, tPitchDetector_getFrequency(&detector));
99+ if (x > 0.5)
100+ {
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+ }
95108
96−// float freq = 1.0f/tPeriodDetection_tick(&pd, input) * leaf.sampleRate;
97−// tMBTriangle_setFreq(&btri, freq);
109+ }
110+ else
111+ {
112+ float freq = 1.0f/tPeriodDetection_tick(&pd, input) * leaf.sampleRate;
113+ if (tZeroCrossing_tick(&zc, input) < 0.05)
114+ tMBTriangle_setFreq(&btri, freq);
115+ }
98116
99− return tMBTriangle_tick(&btri);// * 0.25;
117+ float g = tEnvelopeFollower_tick(&ef, input);
118+ return input + tMBTriangle_tick(&btri) * g * 10.0f;
100119 }
101120
102121 int firstFrame = 1;
@@ -114,7 +133,9 @@ void LEAFTest_block (void) · 11 unmodified lines
114133
115134 float val = getSliderValue("mod freq");
116135
117− x = val * 20000.0f + 220.0f;
136+ x = val;
137+
138+
118139
119140 // a = val * tBuffer_getBufferLength(&buff);
120141

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