![]() |
wxMidi - A MIDI interface based on PortMidi
|
Represents a MIDI stream on which MIDI data traffic can be sent. More...
#include <wxMidi.h>
Public Member Functions | |
wxMidiOutDevice (wxMidiDeviceID nDevice) | |
Constructor. More... | |
~wxMidiOutDevice () | |
Destructor. | |
wxMidiError | Open (long latency, void *pDriverInfo=NULL) |
This methods opens a wxMidiOutDevice stream so that it can be used. More... | |
wxMidiError | Write (wxMidiShortMessage *pMsg) |
Sends a MIDI message to the MIDI device represented by this wxMidiOutDevice object. More... | |
wxMidiError | Write (wxMidiSysExMessage *pMsg) |
Sends a MIDI message to the MIDI device represented by this wxMidiOutDevice object. More... | |
wxMidiError | Write (wxByte *msg, wxMidiTimestamp when=0) |
Sends a MIDI message to the MIDI device represented by this wxMidiOutDevice object. More... | |
wxMidiError | Write (PmEvent *buffer, long length) |
This method is just a wrapper for the portmidi native Write function. More... | |
wxMidiError | NoteOn (int channel, int note, int velocity) |
Prepares and sends a NoteOn MIDI message. More... | |
wxMidiError | NoteOff (int channel, int note, int velocity) |
Prepares and sends a NoteOff MIDI message. More... | |
wxMidiError | ProgramChange (int channel, int instrument) |
Prepares and sends a ProgramChange MIDI message. More... | |
wxMidiError | AllSoundsOff () |
From time to time, specially during user application debugging, you may encounter a situation in which a MIDI synthesizer sounds as if its keys are "stuck," and it plays continuously as though someone's still pressing them. More... | |
wxMidiError | Abort () |
Terminates any outgoing message immediately; this call may result in a partial transmission of a MIDI message. More... | |
![]() | |
wxMidiDevice (wxMidiDeviceID nDevice) | |
Constructor. More... | |
virtual | ~wxMidiDevice () |
Destructor. | |
wxMidiError | Close () |
Closes a MIDI stream, flushing any pending messages. More... | |
const wxString | DeviceName () |
Returns a string containing the name of the MIDI device. More... | |
const wxString | InterfaceUsed () |
Returns a string containing the name of the API used internally by portmidi to implement MIDI communication. More... | |
bool | IsInputPort () |
Returns true if the device has input capabilities and then can be used as wxMidiInDevice. More... | |
bool | IsOutputPort () |
Returns true if the device has output capabilities and then can be used as wxMidiOutDevice. More... | |
int | HasHostError () |
Check if the wxMidiDevice has a pending host error to be reported. More... | |
Additional Inherited Members | |
![]() | |
wxMidiDeviceID | m_nDevice |
const PmDeviceInfo * | m_pInfo |
PortMidiStream * | m_stream |
Represents a MIDI stream on which MIDI data traffic can be sent.
|
inline |
Constructor.
nDevice | The number of the device. Device numbers (also referred as device IDs) range from 0 to wxMidiSystem::CountDevices() - 1 |
|
inline |
Terminates any outgoing message immediately; this call may result in a partial transmission of a MIDI message.
The caller should immediately close the output port.
wxMidiError wxMidiOutDevice::AllSoundsOff | ( | ) |
From time to time, specially during user application debugging, you may encounter a situation in which a MIDI synthesizer sounds as if its keys are "stuck," and it plays continuously as though someone's still pressing them.
Method AllSoundsOff() sends the MIDI device a signal that tells it to stop immediately all sounds.
wxMidiError wxMidiOutDevice::NoteOff | ( | int | channel, |
int | note, | ||
int | velocity | ||
) |
Prepares and sends a NoteOff MIDI message.
It is normally used to stop a sound started by a previous call to NoteOn().
channel | The number (0 to 15) of the logical channel that will be used for sending the message. |
note | A number in the range 0 to 127 that specifies the note's pitch to stop. |
velocity | A number in the range 0 to 127 that specifies the velocity with which the key was released. This information is usually ignored by MIDI synthesizers. |
wxMidiError wxMidiOutDevice::NoteOn | ( | int | channel, |
int | note, | ||
int | velocity | ||
) |
Prepares and sends a NoteOn MIDI message.
channel | The number (0 to 15) of the logical channel that will be used for sending the message. See macro_midi_channel |
note | A number in the range 0 to 127 that specifies the note's pitch. Middle C note corresponds to MIDI note 60, middle C # is 61, middle D is 62, and so on. |
velocity | Velocity refers to how hard the key, on a MIDI keyboard, was pressed. This parameter controls the volume of the sound to be produced. So you can consider velocity as synonymous to volume. Parameter velocity is a value from 0 to 127. A logarithmic scale is recommended, for example: |
Dynamics | velocity |
---|---|
OFF | 0 |
ppp | 1 |
pp | 2 |
p | 4 |
mp | 8 |
mf | 16 |
f | 32 |
ff | 64 |
fff | 127 |
Remarks: You must be aware that in MIDI systems, the activation of a particular note and the release of the same note are considered as two separate events. So, after calling method NoteOn() it is necessary to call later to method NoteOff() to stop the sound generator, even if the sound produced by the NoteOn() command is no longer audible due to natural sound extinction because of the chosen instrument (i.e.piano or percussion instruments).
wxMidiError wxMidiOutDevice::Open | ( | long | latency, |
void * | pDriverInfo = NULL |
||
) |
This methods opens a wxMidiOutDevice stream so that it can be used.
latency | It is the delay in milliseconds applied to timestamps to determine when the output should actually occur (If latency is less than zero, 0 is assumed). If latency is zero, timestamps are ignored and all output is delivered immediately. If latency is greater than zero, output is delayed until the message timestamp plus the latency. Timestamps are absolute, not relative delays or offsets. In some cases, by using the latency parameter you can obtain better timing than your application by passing timestamps along to the device driver or hardware. Latency may also help you to synchronize midi data to audio data by matching midi latency to the audio buffer latency. |
pDriverInfo | It is a pointer to an optional driver specific data structure containing additional information for device setup or handle processing. pDriverInfo is never required for correct operation. If not used pDriverInfo should be NULL. |
wxMidiError wxMidiOutDevice::ProgramChange | ( | int | channel, |
int | instrument | ||
) |
Prepares and sends a ProgramChange MIDI message.
This message is used to change the sound (instrument) assigned to a channel.
channel | The number (0 to 15) of the logical channel whose sound is to be re-programmed |
instrument | A number in the range 0 to 127 that specifies the new instrument sound to assign to the channel. |
wxMidiError wxMidiOutDevice::Write | ( | wxMidiShortMessage * | pMsg | ) |
Sends a MIDI message to the MIDI device represented by this wxMidiOutDevice object.
wxMidiError wxMidiOutDevice::Write | ( | wxMidiSysExMessage * | pMsg | ) |
Sends a MIDI message to the MIDI device represented by this wxMidiOutDevice object.
wxMidiError wxMidiOutDevice::Write | ( | wxByte * | msg, |
wxMidiTimestamp | when = 0 |
||
) |
Sends a MIDI message to the MIDI device represented by this wxMidiOutDevice object.
msg | String of bytes with the message to send. |
when | Timestamp with the absolute time at which message must be sent. This parameter is only meaningful if the device was opened with latency parameter different from zero. Otherwise messages are sent immediately and parameter Timestamp will be ignored. |
|
inline |
This method is just a wrapper for the portmidi native Write function.
This method is provided in case it is needed but, probably, it is not needed.