Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   FAQ   Tutorial


Public Member Functions | List of all members
RtMidiOut Class Reference

A realtime MIDI output class. More...

#include <RtMidi.h>

Inheritance diagram for RtMidiOut:
RtMidi

Public Member Functions

 RtMidiOut (RtMidi::Api api=UNSPECIFIED, const std::string clientName=std::string("RtMidi Output Client"))
 Default constructor that allows an optional client name. More...
 
 ~RtMidiOut (void) throw ()
 The destructor closes any open MIDI connections.
 
RtMidi::Api getCurrentApi (void) throw ()
 Returns the MIDI API specifier for the current instance of RtMidiOut.
 
void openPort (unsigned int portNumber=0, const std::string portName=std::string("RtMidi Output"))
 Open a MIDI output connection. More...
 
void closePort (void)
 Close an open MIDI connection (if one exists).
 
virtual bool isPortOpen () const
 Returns true if a port is open and false if not.
 
void openVirtualPort (const std::string portName=std::string("RtMidi Output"))
 Create a virtual output port, with optional name, to allow software connections (OS X, JACK and ALSA only). More...
 
unsigned int getPortCount (void)
 Return the number of available MIDI output ports.
 
std::string getPortName (unsigned int portNumber=0)
 Return a string identifier for the specified MIDI port type and number. More...
 
void sendMessage (std::vector< unsigned char > *message)
 Immediately send a single message out an open MIDI output port. More...
 
virtual void setErrorCallback (RtMidiErrorCallback errorCallback=NULL)
 Set an error callback function to be invoked when an error has occured. More...
 

Additional Inherited Members

- Public Types inherited from RtMidi
enum  Api {
  UNSPECIFIED, MACOSX_CORE, LINUX_ALSA, UNIX_JACK,
  WINDOWS_MM, RTMIDI_DUMMY
}
 MIDI API specifier arguments. More...
 
- Static Public Member Functions inherited from RtMidi
static std::string getVersion (void) throw ()
 A static function to determine the current RtMidi version.
 
static void getCompiledApi (std::vector< RtMidi::Api > &apis) throw ()
 A static function to determine the available compiled MIDI APIs. More...
 

Detailed Description

A realtime MIDI output class.

This class provides a common, platform-independent API for MIDI output. It allows one to probe available MIDI output ports, to connect to one such port, and to send MIDI bytes immediately over the connection. Create multiple instances of this class to connect to more than one MIDI device at the same time. With the OS-X, Linux ALSA and JACK MIDI APIs, it is also possible to open a virtual port to which other MIDI software clients can connect.

by Gary P. Scavone, 2003-2014.

Constructor & Destructor Documentation

RtMidiOut::RtMidiOut ( RtMidi::Api  api = UNSPECIFIED,
const std::string  clientName = std::string("RtMidi Output Client") 
)

Default constructor that allows an optional client name.

An exception will be thrown if a MIDI system initialization error occurs.

If no API argument is specified and multiple API support has been compiled, the default order of use is ALSA, JACK (Linux) and CORE, JACK (OS-X).

Member Function Documentation

void RtMidiOut::openPort ( unsigned int  portNumber = 0,
const std::string  portName = std::string( "RtMidi Output" ) 
)
inlinevirtual

Open a MIDI output connection.

An optional port number greater than 0 can be specified. Otherwise, the default or first port found is opened. An exception is thrown if an error occurs while attempting to make the port connection.

Implements RtMidi.

553 { rtapi_->openPort( portNumber, portName ); }
void RtMidiOut::openVirtualPort ( const std::string  portName = std::string( "RtMidi Output" ))
inlinevirtual

Create a virtual output port, with optional name, to allow software connections (OS X, JACK and ALSA only).

This function creates a virtual MIDI output port to which other software applications can connect. This type of functionality is currently only supported by the Macintosh OS-X, Linux ALSA and JACK APIs (the function does nothing with the other APIs). An exception is thrown if an error occurs while attempting to create the virtual port.

Implements RtMidi.

554 { rtapi_->openVirtualPort( portName ); }
std::string RtMidiOut::getPortName ( unsigned int  portNumber = 0)
inlinevirtual

Return a string identifier for the specified MIDI port type and number.

An empty string is returned if an invalid port specifier is provided.

Implements RtMidi.

558 { return rtapi_->getPortName( portNumber ); }
void RtMidiOut::sendMessage ( std::vector< unsigned char > *  message)
inline

Immediately send a single message out an open MIDI output port.

An exception is thrown if an error occurs during output or an output connection was not previously established.

559 { ((MidiOutApi *)rtapi_)->sendMessage( message ); }
void RtMidiOut::setErrorCallback ( RtMidiErrorCallback  errorCallback = NULL)
inlinevirtual

Set an error callback function to be invoked when an error has occured.

The callback function will be called whenever an error has occured. It is best to set the error callback function before opening a port.

Implements RtMidi.

560 { rtapi_->setErrorCallback(errorCallback); }

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

The Synthesis ToolKit in C++ (STK)
©1995--2014 Perry R. Cook and Gary P. Scavone. All Rights Reserved.