Skip to content
Snippets Groups Projects
Commit 73351621 authored by Josh Siegle's avatar Josh Siegle
Browse files

Optimizing event detection code

parent 6a04e270
No related branches found
No related tags found
No related merge requests found
......@@ -57,7 +57,6 @@ public:
int getNumEventChannels();
void setOutputHigh();
void setOutputLow();
......
......@@ -28,11 +28,11 @@
EventDetector::EventDetector()
: GenericProcessor("Event Detector"), state(false), threshold(50.0), bufferZone(5.0f)
: GenericProcessor("Event Detector"), state(false), threshold(200.0), bufferZone(5.0f)
{
parameters.add(Parameter("thresh", 0.0, 200.0, 50.0, 0));
parameters.add(Parameter("thresh", 0.0, 500.0, 200.0, 0));
}
......@@ -76,7 +76,7 @@ void EventDetector::process(AudioSampleBuffer &buffer,
for (int i = 0; i < nSamples; i++)
{
if ((*buffer.getSampleData(0, i) > threshold) && !state)
if ((*buffer.getSampleData(0, i) < -threshold) && !state)
{
// generate midi event
......@@ -85,7 +85,7 @@ void EventDetector::process(AudioSampleBuffer &buffer,
state = true;
} else if ((*buffer.getSampleData(0, i) < threshold - bufferZone) && state)
} else if ((*buffer.getSampleData(0, i) > -threshold + bufferZone) && state)
{
state = false;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment