Skip to content
Snippets Groups Projects
Commit b9101b45 authored by jsiegle's avatar jsiegle
Browse files

Added functionality to EventDetector

parent 8d24a675
No related branches found
No related tags found
No related merge requests found
......@@ -61,7 +61,7 @@ ParameterEditor::ParameterEditor(GenericProcessor* proc, Parameter& p, Font labe
(float) p.getDefaultValue(),
labelFont);
ps->setBounds(0,0, 40, 40);
ps->setBounds(0,0, 80, 80);
ps->setName(String(p.getID()));
addAndMakeVisible(ps);
sliderArray.add(ps);
......@@ -73,11 +73,11 @@ ParameterEditor::ParameterEditor(GenericProcessor* proc, Parameter& p, Font labe
int width = labelFont.getStringWidth(p.getName());
label->setColour(Label::textColourId, Colours::darkgrey);
label->setFont(labelFont);
label->setBounds((40-width)/2-5, 40, 100, 10);
label->setBounds((80-width)/2-5, 70, 100, 10);
addAndMakeVisible(label);
desiredWidth = 50;
desiredHeight = 50;
desiredWidth = 80;
desiredHeight = 80;
} else if (p.isDiscrete())
{
......@@ -402,11 +402,11 @@ Path ParameterSlider::makeRotaryPath(double min, double max, double val)
{
Path p;
double start = 5*double_Pi/4;
double start = 5*double_Pi/4 - 0.11;
double range = (val-min)/(max - min)*1.5*double_Pi + start;
double range = (val-min)/(max - min)*1.5*double_Pi + start + 0.22;
p.addPieSegment(6,6, getWidth()-12, getHeight()-12, start, range, 0.8);
p.addPieSegment(6,6, getWidth()-12, getHeight()-12, start, range, 0.65);
// p.startNewSubPath(5, getHeight()-5);
// p.addArc(5, 5, getWidth()-10, getWidth()-10, 5/4*double_Pi, range);
......
......@@ -28,11 +28,12 @@
EventDetector::EventDetector()
: GenericProcessor("Event Detector")
: GenericProcessor("Event Detector"), state(0), threshold(250)
{
parameters.add(Parameter("thresh", 0.0, 5000.0, 250.0, 0));
}
EventDetector::~EventDetector()
......@@ -55,15 +56,37 @@ EventDetector::~EventDetector()
void EventDetector::setParameter (int parameterIndex, float newValue)
{
Parameter& p = parameters.getReference(parameterIndex);
p.setValue(newValue, 0);
//std::cout << float(p[0]) << std::endl;
}
void EventDetector::process(AudioSampleBuffer &buffer,
MidiBuffer &midiMessages,
MidiBuffer &events,
int& nSamples)
{
for (int i = 0; i < nSamples; i++)
{
if (*buffer.getSampleData(0, i) > threshold && !state)
{
// generate midi event
addEvent(events, TTL, i);
state = true;
} else if (*buffer.getSampleData(0, i) < threshold && state)
{
state = false;
}
}
}
......@@ -53,7 +53,8 @@ public:
private:
float threshold;
bool state;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (EventDetector);
......
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