1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Allow simulating poly-aftertouch messages in MPEInstrument

This commit is contained in:
ed 2019-03-11 16:22:13 +00:00
parent 5666d5b1b0
commit 1a22a3fafb
2 changed files with 27 additions and 12 deletions

View file

@ -258,18 +258,8 @@ void MPEInstrument::processMidiAfterTouchMessage (const MidiMessage& message)
if (! isMasterChannel (message.getChannel())) if (! isMasterChannel (message.getChannel()))
return; return;
const ScopedLock sl (lock); polyAftertouch (message.getChannel(), message.getNoteNumber(),
MPEValue::from7BitInt (message.getAfterTouchValue()));
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); });
}
}
} }
//============================================================================== //==============================================================================
@ -385,6 +375,24 @@ void MPEInstrument::timbre (int midiChannel, MPEValue value)
updateDimension (midiChannel, timbreDimension, 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 MPEValue MPEInstrument::getInitialValueForNewNote (int midiChannel, MPEDimension& dimension) const
{ {
if (getLastNotePlayedPtr (midiChannel) != nullptr) if (getLastNotePlayedPtr (midiChannel) != nullptr)

View file

@ -185,6 +185,13 @@ public:
*/ */
virtual void timbre (int midiChannel, MPEValue value); 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. /** Request a sustain pedal press or release.
If midiChannel is a zone's master channel, this will act on all notes in If midiChannel is a zone's master channel, this will act on all notes in