linuxsampler 2.3.1
|
Light-weight MIDI interface (for MIDI in & out) intended to be used by pure software MIDI "devices", that is e.g. More...
#include <VirtualMidiDevice.h>
Classes | |
struct | event_t |
Public Types | |
enum | event_type_t { EVENT_TYPE_NOTEON = 1 , EVENT_TYPE_NOTEOFF = 2 , EVENT_TYPE_CC = 3 , EVENT_TYPE_PITCHBEND , EVENT_TYPE_PROGRAM , EVENT_TYPE_CHPRESSURE } |
Public Member Functions | |
bool | SendNoteOnToSampler (uint8_t Key, uint8_t Velocity) |
Sends a MIDI note on event to the sampler. | |
bool | SendNoteOffToSampler (uint8_t Key, uint8_t Velocity) |
Sends a MIDI note off event to the sampler. | |
bool | SendCCToSampler (uint8_t Controller, uint8_t Value) |
Sends a MIDI Control Change event to the sampler. | |
bool | SendChannelPressureToSampler (uint8_t Pressure) |
Sends a MIDI Channel Pressure (aftertouch) event to the sampler. | |
bool | SendPitchBendToSampler (int Pitch) |
Sends a MIDI Pitch Bend event to the sampler. | |
bool | SendProgramChangeToSampler (uint8_t Program) |
Sends a MIDI Program Change event to the sampler. | |
bool | NotesChanged () |
Can be called by the virtual MIDI device to check whether a new note on or note off MIDI event arrived to the sampler during the last call to this method. | |
bool | NoteChanged (uint8_t Key) |
Can be called by the virtual MIDI device to check whether a new note on or note off MIDI event arrived to the sampler for Key during the last call to this method. | |
bool | NoteIsActive (uint8_t Key) |
Can be called by the virtual MIDI device to check which key / note is currently active by the sampler, e.g. | |
uint8_t | NoteOnVelocity (uint8_t Key) |
Returns the velocity of the last note on event. | |
uint8_t | NoteOffVelocity (uint8_t Key) |
Returns the velocity of the last note off event. | |
bool | ControllersChanged () |
Can be called by the virtual MIDI device to check whether a Control Change MIDI event arrived to the sampler during the last call to this method. | |
bool | ControllerChanged (uint8_t Controller) |
Can be called by the virtual MIDI device to check whether a Control Change MIDI event arrived to the sampler for Controller during the last call to this method. | |
uint8_t | ControllerValue (uint8_t Controller) |
Returns the value of the last Control Change event. | |
void | SendNoteOnToDevice (uint8_t Key, uint8_t Velocity) |
Informs the virtual MIDI device that a note on event occured (e.g. | |
void | SendNoteOffToDevice (uint8_t Key, uint8_t Velocity) |
Informs the virtual MIDI device that a note off event occured (e.g. | |
void | SendCCToDevice (uint8_t Controller, uint8_t Value) |
Informs the virtual MIDI device that a Control Change event occured (e.g. | |
bool | GetMidiEventFromDevice (event_t &Event) |
Gets the next pending MIDI event from the virtual MIDI device by using a lockfree FIFO. | |
void | SetMaxEvents (int n) |
Adjusts the internal event buffer to cover at least the given amount of MIDI events. | |
void | Reset () |
Intended to be called on "panic" / all notes off situations. | |
VirtualMidiDevice () | |
Constructor. | |
virtual | ~VirtualMidiDevice () |
Destructor. | |
Light-weight MIDI interface (for MIDI in & out) intended to be used by pure software MIDI "devices", that is e.g.
a graphical virtual MIDI keyboard in an instrument editor or in a sampler frontend. This class should not be used for regular MIDI input device drivers for the sampler. This primitive interface by design doesn't care about jitter, fast event delivery or masses and masses of events in a short time!
Definition at line 20 of file VirtualMidiDevice.h.
Enumerator | |
---|---|
EVENT_TYPE_NOTEON | |
EVENT_TYPE_NOTEOFF | |
EVENT_TYPE_CC | |
EVENT_TYPE_PITCHBEND | |
EVENT_TYPE_PROGRAM | |
EVENT_TYPE_CHPRESSURE |
Definition at line 22 of file VirtualMidiDevice.h.
LinuxSampler::VirtualMidiDevice::VirtualMidiDevice | ( | ) |
Constructor.
|
virtual |
Destructor.
Can be called by the virtual MIDI device to check whether a Control Change MIDI event arrived to the sampler for Controller during the last call to this method.
So this is a asynchronously, "polling" based communication mechanism, which works in conjunction with the ControllerValue() method call.
bool LinuxSampler::VirtualMidiDevice::ControllersChanged | ( | ) |
Can be called by the virtual MIDI device to check whether a Control Change MIDI event arrived to the sampler during the last call to this method.
So this is a asynchronously, "polling" based communication mechanism, which works in conjunction with the ControllerValue() method call.
Returns the value of the last Control Change event.
No FIFO is used!
Gets the next pending MIDI event from the virtual MIDI device by using a lockfree FIFO.
Note: this method is usually only called by the sampler.
Event | - destination for writing the next event to |
Can be called by the virtual MIDI device to check whether a new note on or note off MIDI event arrived to the sampler for Key during the last call to this method.
So this is a asynchronously, "polling" based communication mechanism, which works in conjunction with the NoteIsActive() method call.
Can be called by the virtual MIDI device to check which key / note is currently active by the sampler, e.g.
to highlight the respective keys on a graphical virtual keyboard.
Returns the velocity of the last note off event.
No FIFO is used!
Returns the velocity of the last note on event.
No FIFO is used!
bool LinuxSampler::VirtualMidiDevice::NotesChanged | ( | ) |
Can be called by the virtual MIDI device to check whether a new note on or note off MIDI event arrived to the sampler during the last call to this method.
So this is a asynchronously, "polling" based communication mechanism, which works in conjunction with the NoteIsActive() method call.
void LinuxSampler::VirtualMidiDevice::Reset | ( | ) |
Intended to be called on "panic" / all notes off situations.
Calling this method will reset all internal atomic flags, such that the state reflects that no note is currently active (its key pressed down).
Only exception: this method currently does not reset the internal ring buffer which is used to transmit MIDI events to the sampler.
Also note that this method is not fully concurrency safe. That means since only flags are reset, calling this method means no harm, but it might conflict with MIDI events etc and thus still cause hanging notes durcing such a specific concurrency conflict. Or in other words: the user might need to trigger the "panic" button multiple times.
Informs the virtual MIDI device that a Control Change event occured (e.g.
caused by a MIDI keyboard connected to the sampler). Communication acts asynchronously, that is this method call doesn't lock in any way and returns immediately. It is thus realtime safe.
Note: this method is usually only called by the sampler.
Sends a MIDI Control Change event to the sampler.
Sends a MIDI Channel Pressure (aftertouch) event to the sampler.
Informs the virtual MIDI device that a note off event occured (e.g.
caused by a MIDI keyboard connected to the sampler). Communication acts asynchronously, that is this method call doesn't lock in any way and returns immediately. It is thus realtime safe.
Note: this method is usually only called by the sampler.
Sends a MIDI note off event to the sampler.
Informs the virtual MIDI device that a note on event occured (e.g.
caused by a MIDI keyboard connected to the sampler). Communication acts asynchronously, that is this method call doesn't lock in any way and returns immediately. It is thus realtime safe.
Note: this method is usually only called by the sampler.
Sends a MIDI note on event to the sampler.
Sends a MIDI Pitch Bend event to the sampler.
Pitch | - MIDI pitch value (-8192 ... +8191) |
Sends a MIDI Program Change event to the sampler.
If you want to change the sound bank, call SendCCToSampler() (with controller = 0 for bank select MSB and/or controller = 32 for bank select LSB) before calling this method.
Program | - MIDI program number |
Adjusts the internal event buffer to cover at least the given amount of MIDI events.
This might be useful, since the internal event buffer is by default quite small (i.e. just 12 events).
This method is not thread safe! Any operations upon this device have to be stopped before calling this method!