kopia lustrzana https://github.com/jameshball/osci-render
Add pitch bend support
rodzic
18776c7324
commit
240fafe65c
|
@ -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;
|
||||||
|
@ -74,9 +75,11 @@ void ShapeVoice::renderNextBlock(juce::AudioSampleBuffer& outputBuffer, int star
|
||||||
juce::ScopedNoDenormals noDenormals;
|
juce::ScopedNoDenormals noDenormals;
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
Vector2 channels;
|
Vector2 channels;
|
||||||
double x = 0.0;
|
double x = 0.0;
|
||||||
|
@ -100,7 +103,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();
|
||||||
|
@ -117,8 +120,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,11 +167,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) {}
|
||||||
|
|
|
@ -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();
|
||||||
};
|
};
|
||||||
|
|
Ładowanie…
Reference in New Issue