Skip to content

Commit

Permalink
Optimizing event detection code
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Siegle committed Oct 10, 2012
1 parent 6a04e27 commit 7335162
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
Binary file not shown.
1 change: 0 additions & 1 deletion Source/Processors/DataThreads/FPGAThread.h
Expand Up @@ -57,7 +57,6 @@ class FPGAThread : public DataThread

int getNumEventChannels();


void setOutputHigh();
void setOutputLow();

Expand Down
8 changes: 4 additions & 4 deletions Source/Processors/EventDetector.cpp
Expand Up @@ -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));

}

Expand Down Expand Up @@ -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
Expand All @@ -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;
}
Expand Down

0 comments on commit 7335162

Please sign in to comment.