Class midi_out¶
Defined in File libremidi.hpp
Class Documentation¶
-
class
libremidi::midi_out¶ 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-2017.
Public Functions
-
inline
midi_out(libremidi::API api, std::string_view clientName)¶ 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).
-
inline
midi_out()¶
-
inline
~midi_out()¶ The destructor closes any open MIDI connections.
-
inline libremidi::API
get_current_api() noexcept¶ Returns the MIDI API specifier for the current instance of RtMidiOut.
-
inline void
open_port(unsigned int portNumber, std::string_view portName)¶ 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.
-
inline void
open_port()¶
-
inline void
open_port(unsigned int port)¶
-
inline void
close_port()¶ Close an open MIDI connection (if one exists).
-
inline bool
is_port_open() const noexcept¶ Returns true if a port is open and false if not.
Note that this only applies to connections made with the openPort() function, not to virtual ports.
-
inline void
open_virtual_port(std::string_view portName)¶ 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.
-
inline void
open_virtual_port()¶
-
inline unsigned int
get_port_count()¶ Return the number of available MIDI output ports.
-
inline std::string
get_port_name(unsigned int portNumber = 0)¶ Return a string identifier for the specified MIDI port type and number.
- Return
The name of the port with the given Id is returned. An empty string is returned if an invalid port specifier is provided. User code should assume a UTF-8 encoding.
-
inline void
send_message(const std::vector<unsigned char> &message)¶ 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.
-
inline void
send_message(const unsigned char *message, size_t size)¶ 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.
- Parameters
message: A pointer to the MIDI message as raw bytessize: Length of the MIDI message in bytes
-
inline void
set_error_callback(midi_error_callback errorCallback) noexcept¶ 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.
-
inline void
set_client_name(std::string_view clientName)¶
-
inline void
set_port_name(std::string_view portName)¶
-
inline void
set_chunking_parameters(std::optional<chunking_parameters> parameters)¶ For large messages, chunk their content and wait. Setting a null optional will disable chunking.
-
inline