linuxsampler 2.3.1
|
#include <MidiInputPort.h>
Classes | |
class | ParameterName |
MIDI Port Parameter 'NAME'. More... | |
Public Member Functions | |
void | Connect (EngineChannel *pEngineChannel, midi_chan_t MidiChannel) |
Connect given sampler engine channel with this MIDI input device. | |
void | Disconnect (EngineChannel *pEngineChannel) |
Disconnect given sampler engine channel from this MIDI input device. | |
MidiInputDevice * | GetDevice () |
Return MIDI device where this MIDI port belongs to. | |
uint | GetPortNumber () |
Return port number with which this MIDI port is registered to the MIDI device. | |
std::map< String, DeviceRuntimeParameter * > | PortParameters () |
Return all parameter settings of this MIDI port. | |
void | Connect (VirtualMidiDevice *pDevice) |
Connects the given virtual MIDI device to this MIDI input device. | |
void | Disconnect (VirtualMidiDevice *pDevice) |
Disconnect the previously connected virtual MIDI device. | |
void | SetNoteOnVelocityFilter (const std::vector< uint8_t > &filter) |
Registers the given filter to be applied against all note on events, adjusting their MIDI velocity data. | |
void | DispatchNoteOn (uint8_t Key, uint8_t Velocity, uint MidiChannel) |
Should be called by the implementing MIDI input device whenever a note on event arrived, this will cause the note on event to be forwarded to all connected engines on the corresponding MIDI channel. | |
void | DispatchNoteOn (uint8_t Key, uint8_t Velocity, uint MidiChannel, int32_t FragmentPos) |
Should be called by the implementing MIDI input device whenever a note on event arrived, this will cause the note on event to be forwarded to all connected engines on the corresponding MIDI channel. | |
void | DispatchNoteOff (uint8_t Key, uint8_t Velocity, uint MidiChannel) |
Should be called by the implementing MIDI input device whenever a note off event arrived, this will cause the note off event to be forwarded to all connected engines on the corresponding MIDI channel. | |
void | DispatchNoteOff (uint8_t Key, uint8_t Velocity, uint MidiChannel, int32_t FragmentPos) |
Should be called by the implementing MIDI input device whenever a note off event arrived, this will cause the note off event to be forwarded to all connected engines on the corresponding MIDI channel. | |
void | DispatchPitchbend (int Pitch, uint MidiChannel) |
Should be called by the implementing MIDI input device whenever a pitchbend event arrived, this will cause the pitchbend event to be forwarded to all connected engines. | |
void | DispatchPitchbend (int Pitch, uint MidiChannel, int32_t FragmentPos) |
Should be called by the implementing MIDI input device whenever a pitchbend event arrived, this will cause the pitchbend event to be forwarded to all connected engines. | |
void | DispatchControlChange (uint8_t Controller, uint8_t Value, uint MidiChannel) |
Should be called by the implementing MIDI input device whenever a control change event arrived, this will cause the control change event to be forwarded to all engines on the corresponding MIDI channel. | |
void | DispatchControlChange (uint8_t Controller, uint8_t Value, uint MidiChannel, int32_t FragmentPos) |
Should be called by the implementing MIDI input device whenever a control change event arrived, this will cause the control change event to be forwarded to all engines on the corresponding MIDI channel. | |
void | DispatchChannelPressure (uint8_t Value, uint MidiChannel) |
Should be called by the implementing MIDI input device whenever a channel pressure event arrived (a.k.a. | |
void | DispatchChannelPressure (uint8_t Value, uint MidiChannel, int32_t FragmentPos) |
Should be called by the implementing MIDI input device whenever a channel pressure event arrived (a.k.a. | |
void | DispatchPolyphonicKeyPressure (uint8_t Key, uint8_t Value, uint MidiChannel) |
Should be called by the implementing MIDI input device whenever a polyphonic key pressure event arrived (a.k.a. | |
void | DispatchPolyphonicKeyPressure (uint8_t Key, uint8_t Value, uint MidiChannel, int32_t FragmentPos) |
Should be called by the implementing MIDI input device whenever a polyphonic key pressure event arrived (a.k.a. | |
void | DispatchProgramChange (uint8_t Program, uint MidiChannel) |
Should be called by the implementing MIDI input device whenever a program change event arrived. | |
void | DispatchBankSelectMsb (uint8_t BankMsb, uint MidiChannel) |
Should be called by the implementing MIDI input device whenever a MIDI bank select MSB (Most Significant Byte) event arrived. | |
void | DispatchBankSelectLsb (uint8_t BankLsb, uint MidiChannel) |
Should be called by the implementing MIDI input device whenever a MIDI bank select LSB (Least Significant Byte) event arrived. | |
void | DispatchSysex (void *pData, uint Size) |
Should be called by the implementing MIDI input device whenever a system exclusive message arrived, this will cause the message to be forwarded to all connected engines. | |
void | DispatchRaw (uint8_t *pData) |
Helper function for MIDI input devices that have the MIDI data as raw bytes. | |
void | DispatchRaw (uint8_t *pData, int32_t FragmentPos) |
Helper function for MIDI input devices that have the MIDI data as raw bytes. | |
Static Public Member Functions | |
static void | AddSysexListener (Engine *engine) |
Registers that an engine wants to have sysex messages. | |
static bool | RemoveSysexListener (Engine *engine) |
Removes engine from list of engines getting sysex messages. | |
Protected Types | |
typedef std::set< EngineChannel * > | MidiChannelMap_t[17] |
Protected Member Functions | |
MidiInputPort (MidiInputDevice *pDevice, int portNumber) | |
Constructor. | |
virtual | ~MidiInputPort () |
Destructor. | |
int | expectedEventSize (unsigned char byte) |
Takes a MIDI status byte (the first byte of each MIDI event) as argument and returns the expected size of the associated MIDI event according to the MIDI protocol. | |
Protected Attributes | |
MidiInputDevice * | pDevice |
int | portNumber |
std::map< String, DeviceRuntimeParameter * > | Parameters |
All port parameters. | |
SynchronizedConfig< MidiChannelMap_t > | MidiChannelMap |
Contains the list of connected engines for each MIDI channel, where index 0 points to the list of engines which are connected to all MIDI channels. Usually it's not necessary for the descendant to use this map, instead it should just use the Dispatch* methods. | |
SynchronizedConfig< MidiChannelMap_t >::Reader | MidiChannelMapReader |
MIDI thread access to MidiChannelMap. | |
Mutex | MidiChannelMapMutex |
Used to protect the MidiChannelMap from being used at the same time by different threads. | |
SynchronizedConfig< std::set< Engine * > >::Reader | SysexListenersReader |
MIDI thread access to SysexListeners. | |
SynchronizedConfig< std::vector< VirtualMidiDevice * > > | virtualMidiDevices |
SynchronizedConfig< std::vector< VirtualMidiDevice * > >::Reader | virtualMidiDevicesReader |
Mutex | virtualMidiDevicesMutex |
SynchronizedConfig< std::vector< uint8_t > > | noteOnVelocityFilter |
SynchronizedConfig< std::vector< uint8_t > >::Reader | noteOnVelocityFilterReader |
Mutex | noteOnVelocityFilterMutex |
uint8_t | runningStatusBuf [3] |
Friends | |
class | MidiInputDevice |
Definition at line 43 of file MidiInputPort.h.
|
protected |
Definition at line 471 of file MidiInputPort.h.
|
protected |
Constructor.
|
protectedvirtual |
Destructor.
Registers that an engine wants to have sysex messages.
void LinuxSampler::MidiInputPort::Connect | ( | EngineChannel * | pEngineChannel, |
midi_chan_t | MidiChannel | ||
) |
Connect given sampler engine channel with this MIDI input device.
The engine channel can either be connected to one specific MIDI channel or all MIDI channels. If an engine channel gets connected twice to this MIDI input device, then the engine's old connection will be detached (no matter on which MIDI channel).
pEngineChannel | - sampler engine |
MidiChannel | - MIDI channel to connect to |
MidiInputException | if MidiChannel argument invalid |
void LinuxSampler::MidiInputPort::Connect | ( | VirtualMidiDevice * | pDevice | ) |
Connects the given virtual MIDI device to this MIDI input device.
This can be used to listen to MIDI data arriving on the MIDI input device's MIDI ports, e.g. to show an MIDI activity indicator somewhere.
void LinuxSampler::MidiInputPort::Disconnect | ( | EngineChannel * | pEngineChannel | ) |
Disconnect given sampler engine channel from this MIDI input device.
If the given engine channel was not connected with this device, nothing happens.
pEngineChannel | - sampler engine |
void LinuxSampler::MidiInputPort::Disconnect | ( | VirtualMidiDevice * | pDevice | ) |
Disconnect the previously connected virtual MIDI device.
Should be called by the implementing MIDI input device whenever a MIDI bank select LSB (Least Significant Byte) event arrived.
In case the respective sampler channel(s) are enabled for "MIDI instrument mapping", a subsequent MIDI program change event can be used to let the respective sampler engine load another instrument according to the respective entry in the MIDI instrument map.
MIDI sources can either a) just send bank select MSB events, or b) just send bank select LSB events or c) they can send both bank select MSB and LSB events. The sampler will automatically detect which style the MIDI source is using and appropriately interpret it for selecting the appropriate bank.
BankMsb | - Most Significant Byte of the bank number |
MidiChannel | - MIDI channel on which this bank select occurred |
Should be called by the implementing MIDI input device whenever a MIDI bank select MSB (Most Significant Byte) event arrived.
In case the respective sampler channel(s) are enabled for "MIDI instrument mapping", a subsequent MIDI program change event can be used to let the respective sampler engine load another instrument according to the respective entry in the MIDI instrument map.
MIDI sources can either a) just send bank select MSB events, or b) just send bank select LSB events or c) they can send both bank select MSB and LSB events. The sampler will automatically detect which style the MIDI source is using and appropriately interpret it for selecting the appropriate bank.
BankMsb | - Most Significant Byte of the bank number |
MidiChannel | - MIDI channel on which this bank select occurred |
Should be called by the implementing MIDI input device whenever a channel pressure event arrived (a.k.a.
aftertouch), this will cause the channel pressure event to be forwarded to all engines on the corresponding MIDI channel.
This method is meant for realtime rendering, this way an event is immediately created with the current system time as time stamp.
Value | - MIDI channel pressure value (0..127) |
MidiChannel | - MIDI channel on which event occured on (low level indexing, means 0..15) |
void LinuxSampler::MidiInputPort::DispatchChannelPressure | ( | uint8_t | Value, |
uint | MidiChannel, | ||
int32_t | FragmentPos | ||
) |
Should be called by the implementing MIDI input device whenever a channel pressure event arrived (a.k.a.
aftertouch), this will cause the channel pressure event to be forwarded to all engines on the corresponding MIDI channel.
This method is meant for offline rendering and / or in case the exact fragment position of the event is already known.
Value | - MIDI channel pressure value (0..127) |
MidiChannel | - MIDI channel on which event occured on (low level indexing, means 0..15) |
FragmentPos | - event's sample point position in the current audio fragment |
void LinuxSampler::MidiInputPort::DispatchControlChange | ( | uint8_t | Controller, |
uint8_t | Value, | ||
uint | MidiChannel | ||
) |
Should be called by the implementing MIDI input device whenever a control change event arrived, this will cause the control change event to be forwarded to all engines on the corresponding MIDI channel.
This method is meant for realtime rendering, this way an event is immediately created with the current system time as time stamp.
Controller | - MIDI controller number |
Value | - MIDI control change value |
MidiChannel | - MIDI channel on which event occured on (low level indexing, means 0..15) |
void LinuxSampler::MidiInputPort::DispatchControlChange | ( | uint8_t | Controller, |
uint8_t | Value, | ||
uint | MidiChannel, | ||
int32_t | FragmentPos | ||
) |
Should be called by the implementing MIDI input device whenever a control change event arrived, this will cause the control change event to be forwarded to all engines on the corresponding MIDI channel.
This method is meant for offline rendering and / or in case the exact fragment position of the event is already known.
Controller | - MIDI controller number |
Value | - MIDI control change value |
MidiChannel | - MIDI channel on which event occured on (low level indexing, means 0..15) |
FragmentPos | - event's sample point position in the current audio fragment |
void LinuxSampler::MidiInputPort::DispatchNoteOff | ( | uint8_t | Key, |
uint8_t | Velocity, | ||
uint | MidiChannel | ||
) |
Should be called by the implementing MIDI input device whenever a note off event arrived, this will cause the note off event to be forwarded to all connected engines on the corresponding MIDI channel.
This method is meant for realtime rendering, this way an event is immediately created with the current system time as time stamp.
Key | - MIDI key number of the released key |
Velocity | - MIDI velocity of the released key |
MidiChannel | - MIDI channel on which event occured on (low level indexing, means 0..15) |
void LinuxSampler::MidiInputPort::DispatchNoteOff | ( | uint8_t | Key, |
uint8_t | Velocity, | ||
uint | MidiChannel, | ||
int32_t | FragmentPos | ||
) |
Should be called by the implementing MIDI input device whenever a note off event arrived, this will cause the note off event to be forwarded to all connected engines on the corresponding MIDI channel.
This method is meant for offline rendering and / or in case the exact fragment position of the event is already known.
Key | - MIDI key number of the released key |
Velocity | - MIDI velocity of the released key |
MidiChannel | - MIDI channel on which event occured on (low level indexing, means 0..15) |
FragmentPos | - event's sample point position in the current audio fragment |
void LinuxSampler::MidiInputPort::DispatchNoteOn | ( | uint8_t | Key, |
uint8_t | Velocity, | ||
uint | MidiChannel | ||
) |
Should be called by the implementing MIDI input device whenever a note on event arrived, this will cause the note on event to be forwarded to all connected engines on the corresponding MIDI channel.
This method is meant for realtime rendering, this way an event is immediately created with the current system time as time stamp.
Key | - MIDI key number of the triggered key |
Velocity | - MIDI velocity of the triggered key |
MidiChannel | - MIDI channel on which event occured on (low level indexing, means 0..15) |
void LinuxSampler::MidiInputPort::DispatchNoteOn | ( | uint8_t | Key, |
uint8_t | Velocity, | ||
uint | MidiChannel, | ||
int32_t | FragmentPos | ||
) |
Should be called by the implementing MIDI input device whenever a note on event arrived, this will cause the note on event to be forwarded to all connected engines on the corresponding MIDI channel.
This method is meant for offline rendering and / or in case the exact fragment position of the event is already known.
Key | - MIDI key number of the triggered key |
Velocity | - MIDI velocity of the triggered key |
MidiChannel | - MIDI channel on which event occured on (low level indexing, means 0..15) |
FragmentPos | - event's sample point position in the current audio fragment |
Should be called by the implementing MIDI input device whenever a pitchbend event arrived, this will cause the pitchbend event to be forwarded to all connected engines.
This method is meant for realtime rendering, this way an event is immediately created with the current system time as time stamp.
Pitch | - MIDI pitch value |
MidiChannel | - MIDI channel on which event occured on (low level indexing, means 0..15) |
void LinuxSampler::MidiInputPort::DispatchPitchbend | ( | int | Pitch, |
uint | MidiChannel, | ||
int32_t | FragmentPos | ||
) |
Should be called by the implementing MIDI input device whenever a pitchbend event arrived, this will cause the pitchbend event to be forwarded to all connected engines.
This method is meant for offline rendering and / or in case the exact fragment position of the event is already known.
Pitch | - MIDI pitch value |
MidiChannel | - MIDI channel on which event occured on (low level indexing, means 0..15) |
FragmentPos | - event's sample point position in the current audio fragment |
void LinuxSampler::MidiInputPort::DispatchPolyphonicKeyPressure | ( | uint8_t | Key, |
uint8_t | Value, | ||
uint | MidiChannel | ||
) |
Should be called by the implementing MIDI input device whenever a polyphonic key pressure event arrived (a.k.a.
polyphonic aftertouch), this will cause the polyphonic key pressure event to be forwarded to all engines on the corresponding MIDI channel.
This method is meant for realtime rendering, this way an event is immediately created with the current system time as time stamp.
Key | - MIDI key number of the key where pressure changed |
Value | - MIDI key pressure value (0..127) |
MidiChannel | - MIDI channel on which event occured on (low level indexing, means 0..15) |
void LinuxSampler::MidiInputPort::DispatchPolyphonicKeyPressure | ( | uint8_t | Key, |
uint8_t | Value, | ||
uint | MidiChannel, | ||
int32_t | FragmentPos | ||
) |
Should be called by the implementing MIDI input device whenever a polyphonic key pressure event arrived (a.k.a.
polyphonic aftertouch), this will cause the polyphonic key pressure event to be forwarded to all engines on the corresponding MIDI channel.
This method is meant for offline rendering and / or in case the exact fragment position of the event is already known.
Key | - MIDI key number of the key where pressure changed |
Value | - MIDI key pressure value (0..127) |
MidiChannel | - MIDI channel on which event occured on (low level indexing, means 0..15) |
FragmentPos | - event's sample point position in the current audio fragment |
Should be called by the implementing MIDI input device whenever a program change event arrived.
In case the respective sampler channel(s) are enabled for MIDI instrument mapping, the respective sampler engine and instrument will be loaded on the connected sampler channel(s) as defined by the respective entry in the MIDI instrument map.
Note: the MIDI instrument map is empty by default on sampler startup. It has to be explicitly filled with entries and the sampler channel(s) have to be enabled for a certain MIDI instrument table, otherwise program change messages are ignored!
Program | - MIDI program change number |
MidiChannel | - MIDI channel on which this program change occured |
Helper function for MIDI input devices that have the MIDI data as raw bytes.
pData | - pointer to the raw MIDI data |
Helper function for MIDI input devices that have the MIDI data as raw bytes.
pData | - pointer to the raw MIDI data |
FragmentPos | - event's sample point position in the current audio fragment |
Should be called by the implementing MIDI input device whenever a system exclusive message arrived, this will cause the message to be forwarded to all connected engines.
pData | - pointer to the sysex data |
Size | - length of the sysex data (in bytes) |
Takes a MIDI status byte (the first byte of each MIDI event) as argument and returns the expected size of the associated MIDI event according to the MIDI protocol.
Returns -1 on invalid status bytes AND on variable size events (SysEx events).
This method can be used for drivers which have to deal with raw MIDI data, like the CoreMIDI driver, which can receive MIDI packets with more than one event per packet.
This method handles "MIDI running status" as well. That is, in case the supplied byte is not a status byte but a data byte, it expects the event to be in "running status" and accordingly uses the status byte of the previous event (processed by the Dispatch*() methods).
MidiInputDevice * LinuxSampler::MidiInputPort::GetDevice | ( | ) |
Return MIDI device where this MIDI port belongs to.
uint LinuxSampler::MidiInputPort::GetPortNumber | ( | ) |
Return port number with which this MIDI port is registered to the MIDI device.
std::map< String, DeviceRuntimeParameter * > LinuxSampler::MidiInputPort::PortParameters | ( | ) |
Return all parameter settings of this MIDI port.
Removes engine from list of engines getting sysex messages.
Registers the given filter to be applied against all note on events, adjusting their MIDI velocity data.
The vector supplied here must exactly be either of size 128 or 0. In case the given vector is of size 128, it will be used as lookup table by this MIDI inpurt port to remap any incoming MIDI note on velocity data to the respective value in that vector, or exactly:
Accordingly the values in the vector have to be in the range 0..127, however note that a value 0 should actually never be used, since by MIDI specification, a note on with velocity 0 is interpreted as note off event instead!
If a vector of size 0 is supplied, this note on velocity filter mechanism will be disabled.
filter | - lookup table in the format described above |
MidiInputException | - if filter is in invalid format |
|
friend |
Definition at line 512 of file MidiInputPort.h.
|
protected |
Contains the list of connected engines for each MIDI channel, where index 0 points to the list of engines which are connected to all MIDI channels. Usually it's not necessary for the descendant to use this map, instead it should just use the Dispatch* methods.
Definition at line 472 of file MidiInputPort.h.
|
protected |
Used to protect the MidiChannelMap from being used at the same time by different threads.
Definition at line 474 of file MidiInputPort.h.
|
protected |
MIDI thread access to MidiChannelMap.
Definition at line 473 of file MidiInputPort.h.
|
protected |
Definition at line 479 of file MidiInputPort.h.
|
protected |
Definition at line 481 of file MidiInputPort.h.
|
protected |
Definition at line 480 of file MidiInputPort.h.
|
protected |
All port parameters.
Definition at line 470 of file MidiInputPort.h.
|
protected |
Definition at line 468 of file MidiInputPort.h.
|
protected |
Definition at line 469 of file MidiInputPort.h.
|
protected |
Definition at line 482 of file MidiInputPort.h.
|
protected |
MIDI thread access to SysexListeners.
Definition at line 475 of file MidiInputPort.h.
|
protected |
Definition at line 476 of file MidiInputPort.h.
|
protected |
Definition at line 478 of file MidiInputPort.h.
|
protected |
Definition at line 477 of file MidiInputPort.h.