diff --git a/Source/audio/ShapeVoice.cpp b/Source/audio/ShapeVoice.cpp index 497f1ea..846cfeb 100644 --- a/Source/audio/ShapeVoice.cpp +++ b/Source/audio/ShapeVoice.cpp @@ -12,6 +12,7 @@ bool ShapeVoice::canPlaySound(juce::SynthesiserSound* sound) { void ShapeVoice::startNote(int midiNoteNumber, float velocity, juce::SynthesiserSound* sound, int currentPitchWheelPosition) { this->velocity = velocity; + pitchWheelMoved(currentPitchWheelPosition); auto* shapeSound = dynamic_cast(sound); currentlyPlaying = true; @@ -75,8 +76,10 @@ void ShapeVoice::renderNextBlock(juce::AudioSampleBuffer& outputBuffer, int star int numChannels = outputBuffer.getNumChannels(); + float actualFrequency = frequency * pitchWheelAdjustment; + if (!audioProcessor.midiEnabled->getBoolValue()) { - frequency = audioProcessor.frequency; + actualFrequency = audioProcessor.frequency; } for (auto sample = startSample; sample < startSample + numSamples; ++sample) { @@ -87,7 +90,7 @@ void ShapeVoice::renderNextBlock(juce::AudioSampleBuffer& outputBuffer, int star double traceMax = traceMaxEnabled ? actualTraceMax : 1.0; double traceMin = traceMinEnabled ? actualTraceMin : 0.0; double proportionalLength = (traceMax - traceMin) * frameLength; - lengthIncrement = juce::jmax(proportionalLength / (audioProcessor.currentSampleRate / frequency), MIN_LENGTH_INCREMENT); + lengthIncrement = juce::jmax(proportionalLength / (audioProcessor.currentSampleRate / actualFrequency), MIN_LENGTH_INCREMENT); Point channels; double x = 0.0; @@ -101,7 +104,7 @@ void ShapeVoice::renderNextBlock(juce::AudioSampleBuffer& outputBuffer, int star renderingSample = parser != nullptr && parser->isSample(); if (renderingSample) { - channels = parser->nextSample(L, LuaVariables{ audioProcessor.currentSampleRate, frequency }, step, phase); + channels = parser->nextSample(L, LuaVariables{ audioProcessor.currentSampleRate, actualFrequency }, step, phase); } else if (currentShape < frame.size()) { auto& shape = frame[currentShape]; double length = shape->length(); @@ -119,8 +122,7 @@ void ShapeVoice::renderNextBlock(juce::AudioSampleBuffer& outputBuffer, int star if (waitingForRelease) { time = juce::jmin(time, releaseTime); } else if (time >= endTime) { - clearCurrentNote(); - sound = nullptr; + noteStopped(); break; } @@ -177,11 +179,17 @@ void ShapeVoice::stopNote(float velocity, bool allowTailOff) { currentlyPlaying = false; waitingForRelease = false; if (!allowTailOff) { - clearCurrentNote(); - sound = nullptr; + noteStopped(); } } -void ShapeVoice::pitchWheelMoved(int newPitchWheelValue) {} +void ShapeVoice::noteStopped() { + clearCurrentNote(); + sound = nullptr; +} + +void ShapeVoice::pitchWheelMoved(int newPitchWheelValue) { + pitchWheelAdjustment = 1.0 + (newPitchWheelValue - 8192.0) / 65536.0; +} void ShapeVoice::controllerMoved(int controllerNumber, int newControllerValue) {} diff --git a/Source/audio/ShapeVoice.h b/Source/audio/ShapeVoice.h index 5809042..6412673 100644 --- a/Source/audio/ShapeVoice.h +++ b/Source/audio/ShapeVoice.h @@ -16,6 +16,7 @@ public: void pitchWheelMoved(int newPitchWheelValue) override; void controllerMoved(int controllerNumber, int newControllerValue) override; + void incrementShapeDrawing(); private: @@ -37,6 +38,7 @@ private: bool currentlyPlaying = false; double frequency = 1.0; double velocity = 1.0; + double pitchWheelAdjustment = 1.0; lua_State* L = nullptr; long step = 1; @@ -47,4 +49,6 @@ private: double releaseTime = 0.0; double endTime = 99999999; bool waitingForRelease = false; + + void noteStopped(); }; diff --git a/osci-render.jucer b/osci-render.jucer index 2553709..972419d 100644 --- a/osci-render.jucer +++ b/osci-render.jucer @@ -5,7 +5,7 @@ pluginCharacteristicsValue="pluginProducesMidiOut,pluginWantsMidiIn" pluginManufacturer="jameshball" aaxIdentifier="sh.ball.oscirender" cppLanguageStandard="20" projectLineFeed=" " headerPath="./include" - version="2.0.5" companyName="James H Ball" companyWebsite="https://osci-render.com" + version="2.0.6" companyName="James H Ball" companyWebsite="https://osci-render.com" companyEmail="james@ball.sh">