wxMidi - A MIDI interface based on PortMidi
wxMidiOutDevice Class Reference

Represents a MIDI stream on which MIDI data traffic can be sent. More...

#include <wxMidi.h>

Inheritance diagram for wxMidiOutDevice:
wxMidiDevice

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...
 
- Public Member Functions inherited from wxMidiDevice
 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

- Protected Attributes inherited from wxMidiDevice
wxMidiDeviceID m_nDevice
 
const PmDeviceInfo * m_pInfo
 
PortMidiStream * m_stream
 

Detailed Description

Represents a MIDI stream on which MIDI data traffic can be sent.

Constructor & Destructor Documentation

◆ wxMidiOutDevice()

wxMidiOutDevice::wxMidiOutDevice ( wxMidiDeviceID  nDevice)
inline

Constructor.

Parameters
nDeviceThe number of the device. Device numbers (also referred as device IDs) range from 0 to wxMidiSystem::CountDevices() - 1
See also
wxMidiSystem::CountDevices()

Member Function Documentation

◆ Abort()

wxMidiError wxMidiOutDevice::Abort ( )
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.

See also
error_codes

◆ AllSoundsOff()

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.

See also
error_codes

◆ NoteOff()

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().

Parameters
channelThe number (0 to 15) of the logical channel that will be used for sending the message.
noteA number in the range 0 to 127 that specifies the note's pitch to stop.
velocityA 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.
See also
error_codes, macro_midi_channel

◆ NoteOn()

wxMidiError wxMidiOutDevice::NoteOn ( int  channel,
int  note,
int  velocity 
)

Prepares and sends a NoteOn MIDI message.

Parameters
channelThe number (0 to 15) of the logical channel that will be used for sending the message. See macro_midi_channel
noteA 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.
velocityVelocity 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:
Dynamicsvelocity
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).

See also
error_codes, macro_midi_channel

◆ Open()

wxMidiError wxMidiOutDevice::Open ( long  latency,
void *  pDriverInfo = NULL 
)

This methods opens a wxMidiOutDevice stream so that it can be used.

Parameters
latencyIt 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.
pDriverInfoIt 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.
Returns
Upon success Open() returns zero (wxMIDI_NO_ERROR). If a call to Open() fails a nonzero error code is returned.
See also
error_codes

◆ ProgramChange()

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.

Parameters
channelThe number (0 to 15) of the logical channel whose sound is to be re-programmed
instrumentA number in the range 0 to 127 that specifies the new instrument sound to assign to the channel.
See also
wxMidiDatabaseGM, macro_midi_channel

◆ Write() [1/4]

wxMidiError wxMidiOutDevice::Write ( wxMidiShortMessage pMsg)

Sends a MIDI message to the MIDI device represented by this wxMidiOutDevice object.

See also
error_codes

◆ Write() [2/4]

wxMidiError wxMidiOutDevice::Write ( wxMidiSysExMessage pMsg)

Sends a MIDI message to the MIDI device represented by this wxMidiOutDevice object.

See also
error_codes

◆ Write() [3/4]

wxMidiError wxMidiOutDevice::Write ( wxByte *  msg,
wxMidiTimestamp  when = 0 
)

Sends a MIDI message to the MIDI device represented by this wxMidiOutDevice object.

Parameters
msgString of bytes with the message to send.
whenTimestamp 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.
See also
error_codes

◆ Write() [4/4]

wxMidiError wxMidiOutDevice::Write ( PmEvent *  buffer,
long  length 
)
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.

See also
error_codes

The documentation for this class was generated from the following files: