From b29ab56e233e387113c438ae0f61e4d48b34cad0 Mon Sep 17 00:00:00 2001 From: Charles Julian Knight Date: Sat, 13 Mar 2021 14:27:30 -0500 Subject: [PATCH] bound notes to supported frequencies --- Source/Synth.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/Synth.cpp b/Source/Synth.cpp index be9530c..bbef242 100644 --- a/Source/Synth.cpp +++ b/Source/Synth.cpp @@ -143,6 +143,10 @@ void SquareOscilator::setDuty(DutyCycle duty) void SquareOscilator::setEvent(MidiEvent event) { + if (event.note < 36 || event.note > 108) { + setConstantVolume(0); // ignore it + return; + } setConstantVolume(event.velocity); set11BitPeriod(event.note); } @@ -184,6 +188,10 @@ void WaveOscillator::setWaveTable(uint8_t* samples) void WaveOscillator::setEvent(MidiEvent event) { + if (event.note < 36 || event.note > 120) { + setVelocity(0); // ignore it + return; + } setVelocity(event.velocity); set11BitPeriod(event.note); } @@ -308,8 +316,6 @@ void Synth::handleMIDIEvent(juce::MidiMessage msg) for (OSCID i = 0; i < NUM_OSC; i++) { if (!configs_[i].enabled) continue; MidiEvent e = manager_.get(configs_[i].voice); - // NOTE: transposes can cause notes to wrap. I'm choosing to call this - // expected behavior. e.note += configs_[i].transpose; oscs_[i]->setEvent(e); }