mirror of
https://github.com/yokemura/Magical8bitPlug2.git
synced 2025-05-24 23:00:21 -04:00
Basic monophonic
This commit is contained in:
parent
be1f0b4e3b
commit
0a5110c8d3
@ -218,6 +218,13 @@ void BaseVoice::renderNextBlock (AudioSampleBuffer& outputBuffer, int startSampl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseVoice::changeNote (int midiNoteNumber, float velocity) {
|
||||||
|
noteNumber = midiNoteNumber;
|
||||||
|
|
||||||
|
ampByVelocityAndGain = * (settingRefs->gain) * velocity; // velocity value range is 0.0f-1.0f
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void BaseVoice::calculateAngleDelta()
|
void BaseVoice::calculateAngleDelta()
|
||||||
{
|
{
|
||||||
auto cyclesPerSecond = MidiMessage::getMidiNoteInHertz (noteNumber);
|
auto cyclesPerSecond = MidiMessage::getMidiNoteInHertz (noteNumber);
|
||||||
|
@ -24,6 +24,8 @@ struct BaseVoice : public SynthesiserVoice
|
|||||||
void pitchWheelMoved (int) override {}
|
void pitchWheelMoved (int) override {}
|
||||||
void controllerMoved (int, int) override {}
|
void controllerMoved (int, int) override {}
|
||||||
void renderNextBlock (AudioSampleBuffer& outputBuffer, int startSample, int numSamples) override;
|
void renderNextBlock (AudioSampleBuffer& outputBuffer, int startSample, int numSamples) override;
|
||||||
|
|
||||||
|
void changeNote (int midiNoteNumber, float velocity);
|
||||||
|
|
||||||
virtual float voltageForAngle (double angle) = 0;
|
virtual float voltageForAngle (double angle) = 0;
|
||||||
virtual void onFrameAdvanced() {};
|
virtual void onFrameAdvanced() {};
|
||||||
|
@ -9,13 +9,36 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "CustomSynth.h"
|
#include "CustomSynth.h"
|
||||||
|
#include "BaseVoice.h"
|
||||||
|
#include "PluginProcessor.h"
|
||||||
|
|
||||||
CustomSynth::CustomSynth(Magical8bitPlug2AudioProcessor& p) : processor(p) {}
|
CustomSynth::CustomSynth(Magical8bitPlug2AudioProcessor& p) : processor(p) {}
|
||||||
|
|
||||||
void CustomSynth::noteOn(int midiChannel, int midiNoteNumber, float velocity) {
|
void CustomSynth::noteOn(int midiChannel, int midiNoteNumber, float velocity) {
|
||||||
Synthesiser::noteOn(midiChannel, midiNoteNumber, velocity);
|
// Poly
|
||||||
|
if (!processor.settingRefs.isMonophonic()) {
|
||||||
|
Synthesiser::noteOn(midiChannel, midiNoteNumber, velocity);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mono
|
||||||
|
auto voice = voices.getFirst();
|
||||||
|
|
||||||
|
if (voice == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (voice->isKeyDown()) {
|
||||||
|
((BaseVoice*)voice)->changeNote(midiNoteNumber, velocity);
|
||||||
|
} else {
|
||||||
|
Synthesiser::noteOn(midiChannel, midiNoteNumber, velocity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomSynth::noteOff(int midiChannel, int midiNoteNumber, float velocity, bool allowTailOff) {
|
void CustomSynth::noteOff(int midiChannel, int midiNoteNumber, float velocity, bool allowTailOff) {
|
||||||
Synthesiser::noteOff(midiChannel, midiNoteNumber, velocity, allowTailOff);
|
Synthesiser::noteOff(midiChannel, midiNoteNumber, velocity, allowTailOff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CustomSynth::allNotesOff (const int midiChannel, const bool allowTailOff) {
|
||||||
|
Synthesiser::allNotesOff(midiChannel, allowTailOff);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ public:
|
|||||||
|
|
||||||
void noteOn(int midiChannel, int midiNoteNumber, float velocity) override;
|
void noteOn(int midiChannel, int midiNoteNumber, float velocity) override;
|
||||||
void noteOff(int midiChannel, int midiNoteNumber, float velocity, bool allowTailOff) override;
|
void noteOff(int midiChannel, int midiNoteNumber, float velocity, bool allowTailOff) override;
|
||||||
|
void allNotesOff (const int midiChannel, const bool allowTailOff) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Magical8bitPlug2AudioProcessor& processor;
|
Magical8bitPlug2AudioProcessor& processor;
|
||||||
|
Loading…
Reference in New Issue
Block a user