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
37 37
38tPeriodDetection pd;38tPeriodDetection pd;
39 39
40tZeroCrossing zc;
41tEnvelopeFollower ef;
42
40float gain;43float gain;
41float freq;
42float dtime;44float dtime;
43bool buttonState;45bool buttonState;
44int ratio = 2;46int ratio = 2;
@@ -46,8 +48,8 @@ float x = 0.0f; · 1 unmodified line
46float y = 0.0f;48float y = 0.0f;
47float a, b, c, d;49float a, b, c, d;
48 50
49float bufIn[4096];51float* bufIn;
50float bufOut[4096];52float* bufOut;
51 53
52#define MSIZE 50000054#define MSIZE 500000
53char memory[MSIZE];55char memory[MSIZE];
@@ -60,11 +62,15 @@ void LEAFTest_init (float sampleRate, int blockSize) · 6 unmodified lines
60 tMBTriangle_init(&btri);62 tMBTriangle_init(&btri);
61 tMBPulse_init(&bpulse);63 tMBPulse_init(&bpulse);
62 64
63 65 bufIn = (float*) leaf_alloc(sizeof(float) * 4096);
66 bufOut = (float*) leaf_alloc(sizeof(float) * 4096);
64 // lowestFreq, highestFreq, hysteresis (width of hysteresis region around 0.0 for zero crossing detection)67 // lowestFreq, highestFreq, hysteresis (width of hysteresis region around 0.0 for zero crossing detection)
65 tPitchDetector_init(&detector, mtof(48), mtof(84), 0.01f);68 tPitchDetector_init(&detector, mtof(48), mtof(84), 0.01f);
66 69
67 tPeriodDetection_init(&pd, bufIn, bufOut, 4096, 1024);70 tPeriodDetection_init(&pd, bufIn, bufOut, 4096, 1024);
71
72 tZeroCrossing_init(&zc, 128);
73 tEnvelopeFollower_init(&ef, 0.02f, 0.9999f);
68}74}
69 75
70inline double getSawFall(double angle) {76inline double getSawFall(double angle) {
@@ -88,15 +94,28 @@ float LEAFTest_tick (float input) · 17 unmodified lines
88//// return tMBSaw_tick(&bsaw);94//// return tMBSaw_tick(&bsaw);
89//// return tMBTriangle_tick(&btri);95//// return tMBTriangle_tick(&btri);
90// return tMBPulse_tick(&bpulse);96// return tMBPulse_tick(&bpulse);
97
91 98
92 tPitchDetector_tick(&detector, input);99 if (x > 0.5)
93 100 {
94 tMBTriangle_setFreq(&btri, tPitchDetector_getFrequency(&detector));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 }
95 108
96// float freq = 1.0f/tPeriodDetection_tick(&pd, input) * leaf.sampleRate;109 }
97// tMBTriangle_setFreq(&btri, freq);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 }
98 116
99 return tMBTriangle_tick(&btri);// * 0.25;117 float g = tEnvelopeFollower_tick(&ef, input);
118 return input + tMBTriangle_tick(&btri) * g * 10.0f;
100}119}
101 120
102int firstFrame = 1;121int firstFrame = 1;
@@ -114,7 +133,9 @@ void LEAFTest_block (void) · 11 unmodified lines
114 133
115 float val = getSliderValue("mod freq");134 float val = getSliderValue("mod freq");
116 135
117 x = val * 20000.0f + 220.0f;136 x = val;
137
138
118 139
119 // a = val * tBuffer_getBufferLength(&buff);140 // a = val * tBuffer_getBufferLength(&buff);
120 141

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