Browse Source

Allow simulating poly-aftertouch messages in MPEInstrument

tags/2021-05-28
ed 6 years ago
parent
commit
1a22a3fafb
2 changed files with 27 additions and 12 deletions
  1. +20
    -12
      modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp
  2. +7
    -0
      modules/juce_audio_basics/mpe/juce_MPEInstrument.h

+ 20
- 12
modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp View File

@@ -258,18 +258,8 @@ void MPEInstrument::processMidiAfterTouchMessage (const MidiMessage& message)
if (! isMasterChannel (message.getChannel()))
return;
const ScopedLock sl (lock);
for (auto i = notes.size(); --i >= 0;)
{
auto& note = notes.getReference (i);
if (note.midiChannel == message.getChannel() && note.initialNote == message.getNoteNumber())
{
pressureDimension.getValue (note) = MPEValue::from7BitInt (message.getAfterTouchValue());
listeners.call ([&] (Listener& l) { l.notePressureChanged (note); });
}
}
polyAftertouch (message.getChannel(), message.getNoteNumber(),
MPEValue::from7BitInt (message.getAfterTouchValue()));
}
//==============================================================================
@@ -385,6 +375,24 @@ void MPEInstrument::timbre (int midiChannel, MPEValue value)
updateDimension (midiChannel, timbreDimension, value);
}
void MPEInstrument::polyAftertouch (int midiChannel, int midiNoteNumber, MPEValue value)
{
const ScopedLock sl (lock);
for (auto i = notes.size(); --i >= 0;)
{
auto& note = notes.getReference (i);
if (note.midiChannel == midiChannel
&& note.initialNote == midiNoteNumber
&& pressureDimension.getValue (note) != value)
{
pressureDimension.getValue (note) = value;
callListenersDimensionChanged (note, pressureDimension);
}
}
}
MPEValue MPEInstrument::getInitialValueForNewNote (int midiChannel, MPEDimension& dimension) const
{
if (getLastNotePlayedPtr (midiChannel) != nullptr)


+ 7
- 0
modules/juce_audio_basics/mpe/juce_MPEInstrument.h View File

@@ -185,6 +185,13 @@ public:
*/
virtual void timbre (int midiChannel, MPEValue value);
/** Request a poly-aftertouch change for a given note number.
The change will be broadcast to all notes sharing the channel and note
number of the change message.
*/
virtual void polyAftertouch (int midiChannel, int midiNoteNumber, MPEValue value);
/** Request a sustain pedal press or release.
If midiChannel is a zone's master channel, this will act on all notes in


Loading…
Cancel
Save