pull/218/head
James Ball 2024-01-21 19:14:49 +00:00
commit 379109be0d
3 zmienionych plików z 21 dodań i 9 usunięć

Wyświetl plik

@ -12,6 +12,7 @@ bool ShapeVoice::canPlaySound(juce::SynthesiserSound* sound) {
void ShapeVoice::startNote(int midiNoteNumber, float velocity, juce::SynthesiserSound* sound, int currentPitchWheelPosition) { void ShapeVoice::startNote(int midiNoteNumber, float velocity, juce::SynthesiserSound* sound, int currentPitchWheelPosition) {
this->velocity = velocity; this->velocity = velocity;
pitchWheelMoved(currentPitchWheelPosition);
auto* shapeSound = dynamic_cast<ShapeSound*>(sound); auto* shapeSound = dynamic_cast<ShapeSound*>(sound);
currentlyPlaying = true; currentlyPlaying = true;
@ -75,8 +76,10 @@ void ShapeVoice::renderNextBlock(juce::AudioSampleBuffer& outputBuffer, int star
int numChannels = outputBuffer.getNumChannels(); int numChannels = outputBuffer.getNumChannels();
float actualFrequency = frequency * pitchWheelAdjustment;
if (!audioProcessor.midiEnabled->getBoolValue()) { if (!audioProcessor.midiEnabled->getBoolValue()) {
frequency = audioProcessor.frequency; actualFrequency = audioProcessor.frequency;
} }
for (auto sample = startSample; sample < startSample + numSamples; ++sample) { 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 traceMax = traceMaxEnabled ? actualTraceMax : 1.0;
double traceMin = traceMinEnabled ? actualTraceMin : 0.0; double traceMin = traceMinEnabled ? actualTraceMin : 0.0;
double proportionalLength = (traceMax - traceMin) * frameLength; 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; Point channels;
double x = 0.0; double x = 0.0;
@ -101,7 +104,7 @@ void ShapeVoice::renderNextBlock(juce::AudioSampleBuffer& outputBuffer, int star
renderingSample = parser != nullptr && parser->isSample(); renderingSample = parser != nullptr && parser->isSample();
if (renderingSample) { 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()) { } else if (currentShape < frame.size()) {
auto& shape = frame[currentShape]; auto& shape = frame[currentShape];
double length = shape->length(); double length = shape->length();
@ -119,8 +122,7 @@ void ShapeVoice::renderNextBlock(juce::AudioSampleBuffer& outputBuffer, int star
if (waitingForRelease) { if (waitingForRelease) {
time = juce::jmin(time, releaseTime); time = juce::jmin(time, releaseTime);
} else if (time >= endTime) { } else if (time >= endTime) {
clearCurrentNote(); noteStopped();
sound = nullptr;
break; break;
} }
@ -177,11 +179,17 @@ void ShapeVoice::stopNote(float velocity, bool allowTailOff) {
currentlyPlaying = false; currentlyPlaying = false;
waitingForRelease = false; waitingForRelease = false;
if (!allowTailOff) { if (!allowTailOff) {
clearCurrentNote(); noteStopped();
sound = nullptr;
} }
} }
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) {} void ShapeVoice::controllerMoved(int controllerNumber, int newControllerValue) {}

Wyświetl plik

@ -16,6 +16,7 @@ public:
void pitchWheelMoved(int newPitchWheelValue) override; void pitchWheelMoved(int newPitchWheelValue) override;
void controllerMoved(int controllerNumber, int newControllerValue) override; void controllerMoved(int controllerNumber, int newControllerValue) override;
void incrementShapeDrawing(); void incrementShapeDrawing();
private: private:
@ -37,6 +38,7 @@ private:
bool currentlyPlaying = false; bool currentlyPlaying = false;
double frequency = 1.0; double frequency = 1.0;
double velocity = 1.0; double velocity = 1.0;
double pitchWheelAdjustment = 1.0;
lua_State* L = nullptr; lua_State* L = nullptr;
long step = 1; long step = 1;
@ -47,4 +49,6 @@ private:
double releaseTime = 0.0; double releaseTime = 0.0;
double endTime = 99999999; double endTime = 99999999;
bool waitingForRelease = false; bool waitingForRelease = false;
void noteStopped();
}; };

Wyświetl plik

@ -5,7 +5,7 @@
pluginCharacteristicsValue="pluginProducesMidiOut,pluginWantsMidiIn" pluginCharacteristicsValue="pluginProducesMidiOut,pluginWantsMidiIn"
pluginManufacturer="jameshball" aaxIdentifier="sh.ball.oscirender" pluginManufacturer="jameshball" aaxIdentifier="sh.ball.oscirender"
cppLanguageStandard="20" projectLineFeed="&#10;" headerPath="./include" cppLanguageStandard="20" projectLineFeed="&#10;" 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"> companyEmail="james@ball.sh">
<MAINGROUP id="j5Ge2T" name="osci-render"> <MAINGROUP id="j5Ge2T" name="osci-render">
<GROUP id="{5ABCED88-0059-A7AF-9596-DBF91DDB0292}" name="Resources"> <GROUP id="{5ABCED88-0059-A7AF-9596-DBF91DDB0292}" name="Resources">