History

mostly working bacf pitch detection

Matthew Wang committed 6 years ago

Commit 7c1652a1 parent 3e210947 files · +691 −45Browse files

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

Unified · Split

TestPlugin/Source/MyTest.cpp+26−14
@@ -33,6 +33,8 @@ tMBSaw bsaw; · 32 unmodified lines
33tMBTriangle btri;33tMBTriangle btri;
34tMBPulse bpulse;34tMBPulse bpulse;
35 35
36tPitchDetector detector;
37
36float gain;38float gain;
37float freq;39float freq;
38float dtime;40float dtime;
@@ -42,7 +44,7 @@ float x = 0.0f; · 3 unmodified lines
42float y = 0.0f;44float y = 0.0f;
43float a, b, c, d;45float a, b, c, d;
44 46
45#define MSIZE 5000047#define MSIZE 500000
46char memory[MSIZE];48char memory[MSIZE];
47 49
48void LEAFTest_init (float sampleRate, int blockSize)50void LEAFTest_init (float sampleRate, int blockSize)
@@ -52,6 +54,8 @@ void LEAFTest_init (float sampleRate, int blockSize) · 3 unmodified lines
52 tMBSaw_init(&bsaw);54 tMBSaw_init(&bsaw);
53 tMBTriangle_init(&btri);55 tMBTriangle_init(&btri);
54 tMBPulse_init(&bpulse);56 tMBPulse_init(&bpulse);
57
58 tPitchDetector_init(&detector, 1000.0f, 5000.0f, 0.0f);
55}59}
56 60
57inline double getSawFall(double angle) {61inline double getSawFall(double angle) {
@@ -65,22 +69,30 @@ inline double getSawFall(double angle) { · 7 unmodified lines
65 69
66float LEAFTest_tick (float input)70float LEAFTest_tick (float input)
67{71{
68 tMBSaw_setFreq(&bsaw, x);72// tMBSaw_setFreq(&bsaw, x);
69 tMBTriangle_setFreq(&btri, x);73// tMBTriangle_setFreq(&btri, x);
70 tMBPulse_setFreq(&bpulse, x);74// tMBPulse_setFreq(&bpulse, x);
71 75//
72 tMBTriangle_setWidth(&btri, y);76// tMBTriangle_setWidth(&btri, y);
73 tMBPulse_setWidth(&bpulse, y);77// tMBPulse_setWidth(&bpulse, y);
74 78//
75// return tMBSaw_tick(&bsaw);79//// return tMBSaw_tick(&bsaw);
76// return tMBTriangle_tick(&btri);80//// return tMBTriangle_tick(&btri);
77 return tMBPulse_tick(&bpulse);81// return tMBPulse_tick(&bpulse);
82
83 tPitchDetector_tick(&detector, input);
84
85 tMBTriangle_setFreq(&btri, tPitchDetector_getFrequency(&detector));
86
87 return input + tMBTriangle_tick(&btri) * 0.25;
78}88}
79 89
80int firstFrame = 1;90int firstFrame = 1;
81bool lastState = false, lastPlayState = false;91bool lastState = false, lastPlayState = false;
82void LEAFTest_block (void)92void LEAFTest_block (void)
83{93{
94 DBG(tPitchDetector_getFrequency(&detector));
95 DBG(tPitchDetector_getPeriodicity(&detector));
84 // if (firstFrame == 1)96 // if (firstFrame == 1)
85 // {97 // {
86 // tBuffer_record(&buff); // starts recording98 // tBuffer_record(&buff); // starts recording
@@ -94,15 +106,15 @@ void LEAFTest_block (void) · 7 unmodified lines
94 106
95 // a = val * tBuffer_getBufferLength(&buff);107 // a = val * tBuffer_getBufferLength(&buff);
96 108
97 DBG("start: " + String(a));109// DBG("start: " + String(a));
98 110
99 val = getSliderValue("mod depth");111 val = getSliderValue("mod depth");
100 112
101 y = val * 2.0f - 1.0f;113 y = val * 2.0f - 1.0f;
102 DBG(String(y));114// DBG(String(y));
103 // b = val * tBuffer_getBufferLength(&buff);115 // b = val * tBuffer_getBufferLength(&buff);
104 116
105 DBG("rate: " + String(b));117// DBG("rate: " + String(b));
106 //118 //
107 // tSampler_setStart(&samp, a);119 // tSampler_setStart(&samp, a);
108 // tSampler_setEnd(&samp, b);120 // tSampler_setEnd(&samp, b);

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