mirror of
https://github.com/yokemura/Magical8bitPlug2.git
synced 2025-05-24 23:00:21 -04:00
arpeggio
This commit is contained in:
parent
5bc7fa85d0
commit
97aadde9ab
@ -59,14 +59,15 @@ void CustomSynth::noteOn(int midiChannel, int midiNoteNumber, float velocity) {
|
|||||||
} else {
|
} else {
|
||||||
switch (processor.settingRefs.monophonicBehavior()) {
|
switch (processor.settingRefs.monophonicBehavior()) {
|
||||||
case kLegato:
|
case kLegato:
|
||||||
// just start
|
// start note and set legato mode
|
||||||
Synthesiser::noteOn(midiChannel, midiNoteNumber, velocity);
|
Synthesiser::noteOn(midiChannel, midiNoteNumber, velocity);
|
||||||
voice->setLegatoMode(*(processor.settingRefs.portamentoTime));
|
voice->setLegatoMode(*(processor.settingRefs.portamentoTime));
|
||||||
break;
|
break;
|
||||||
case kArpeggioUp:
|
case kArpeggioUp:
|
||||||
case kArpeggioDown:
|
case kArpeggioDown:
|
||||||
// calc arpeggio interval
|
// start note and calc arpeggio interval
|
||||||
// set arpeggio mode with this note number and arp interval
|
Synthesiser::noteOn(midiChannel, midiNoteNumber, velocity);
|
||||||
|
voice->setArpeggioMode(calcArpeggioInterval());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// no-op
|
// no-op
|
||||||
@ -75,6 +76,30 @@ void CustomSynth::noteOn(int midiChannel, int midiNoteNumber, float velocity) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double CustomSynth::calcArpeggioInterval() {
|
||||||
|
switch (processor.settingRefs.apreggioIntervalType()) {
|
||||||
|
case k1frame:
|
||||||
|
return 1.0 / 60.0;
|
||||||
|
case k2frames:
|
||||||
|
return 1.0 / 30.0;
|
||||||
|
case k3frames:
|
||||||
|
return 1.0 / 20.0;
|
||||||
|
case k64th:
|
||||||
|
return 240.0 / (processor.getCurrentBPM() * 64);
|
||||||
|
case k48th:
|
||||||
|
return 240.0 / (processor.getCurrentBPM() * 48);
|
||||||
|
case k32nd:
|
||||||
|
return 240.0 / (processor.getCurrentBPM() * 32);
|
||||||
|
case k24th:
|
||||||
|
return 240.0 / (processor.getCurrentBPM() * 24);
|
||||||
|
case kSlider:
|
||||||
|
return *(processor.settingRefs.arpeggioIntervalSliderValue);
|
||||||
|
default:
|
||||||
|
return 1.0 / 60.0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CustomSynth::noteOff(int midiChannel, int midiNoteNumber, float velocity, bool allowTailOff) {
|
void CustomSynth::noteOff(int midiChannel, int midiNoteNumber, float velocity, bool allowTailOff) {
|
||||||
TonalVoice *voice = getVoiceIfShouldProcessInMonoMode();
|
TonalVoice *voice = getVoiceIfShouldProcessInMonoMode();
|
||||||
|
|
||||||
@ -104,9 +129,12 @@ void CustomSynth::noteOff(int midiChannel, int midiNoteNumber, float velocity, b
|
|||||||
break;
|
break;
|
||||||
case kArpeggioUp:
|
case kArpeggioUp:
|
||||||
case kArpeggioDown:
|
case kArpeggioDown:
|
||||||
// remove arpeggio note and get # of remaining arpeggio notes
|
{
|
||||||
// if zero
|
int numBuffer = voice->removeArpeggioNote(midiNoteNumber);
|
||||||
// all notes off
|
if (numBuffer < 1) {
|
||||||
|
Synthesiser::noteOff(midiChannel, voice->getCurrentlyPlayingNote(), velocity, allowTailOff);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -24,5 +24,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
TonalVoice* getVoiceIfShouldProcessInMonoMode();
|
TonalVoice* getVoiceIfShouldProcessInMonoMode();
|
||||||
|
double calcArpeggioInterval();
|
||||||
Magical8bitPlug2AudioProcessor& processor;
|
Magical8bitPlug2AudioProcessor& processor;
|
||||||
};
|
};
|
||||||
|
@ -176,6 +176,17 @@ void Magical8bitPlug2AudioProcessor::setupVoice()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double Magical8bitPlug2AudioProcessor::getCurrentBPM()
|
||||||
|
{
|
||||||
|
auto ph = getPlayHead();
|
||||||
|
if (ph == NULL) {
|
||||||
|
return 120.0;
|
||||||
|
}
|
||||||
|
juce::AudioPlayHead::CurrentPositionInfo result;
|
||||||
|
ph->getCurrentPosition(result);
|
||||||
|
|
||||||
|
return result.bpm > 0 ? result.bpm : 120.0;
|
||||||
|
}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
const String Magical8bitPlug2AudioProcessor::getName() const
|
const String Magical8bitPlug2AudioProcessor::getName() const
|
||||||
|
@ -72,6 +72,7 @@ public:
|
|||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
void setupVoice();
|
void setupVoice();
|
||||||
|
double getCurrentBPM();
|
||||||
|
|
||||||
AudioProcessorValueTreeState parameters;
|
AudioProcessorValueTreeState parameters;
|
||||||
SettingRefs settingRefs;
|
SettingRefs settingRefs;
|
||||||
|
@ -38,6 +38,7 @@ void TonalVoice::startNote (int midiNoteNumber, float velocity, SynthesiserSound
|
|||||||
arpeggioFrameTimer = 0;
|
arpeggioFrameTimer = 0;
|
||||||
arpeggioFrameLength = 0;
|
arpeggioFrameLength = 0;
|
||||||
currentNumNoteBuffer = 0;
|
currentNumNoteBuffer = 0;
|
||||||
|
for (int i=0; i<10; i++) { noteBuffer[i] = 0; }
|
||||||
}
|
}
|
||||||
|
|
||||||
void TonalVoice::advanceControlFrame()
|
void TonalVoice::advanceControlFrame()
|
||||||
@ -262,4 +263,23 @@ void TonalVoice::onFrameAdvanced()
|
|||||||
autoBendDelta = 0;
|
autoBendDelta = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (arpeggioFrameLength > 0) {
|
||||||
|
arpeggioFrameTimer += 1.0 / getSampleRate();
|
||||||
|
|
||||||
|
if (arpeggioFrameTimer >= arpeggioFrameLength)
|
||||||
|
{
|
||||||
|
currentArpeggioFrame++;
|
||||||
|
|
||||||
|
if (currentArpeggioFrame >= currentNumNoteBuffer) {
|
||||||
|
currentArpeggioFrame = 0;
|
||||||
|
}
|
||||||
|
noteNumber = noteBuffer[currentArpeggioFrame];
|
||||||
|
|
||||||
|
while (arpeggioFrameTimer >= arpeggioFrameLength)
|
||||||
|
{
|
||||||
|
arpeggioFrameTimer -= arpeggioFrameLength;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user