The RtMidi Tutorial

Tutorial Class/Enum List File List Compound Members C interface

rtmidi_c.h
Go to the documentation of this file.
1/************************************************************************/
13/************************************************************************/
14
18
19#include <stdbool.h>
20#include <stddef.h>
21#ifndef RTMIDI_C_H
22#define RTMIDI_C_H
23
24#if defined(RTMIDI_EXPORT)
25#if defined _WIN32 || defined __CYGWIN__
26#define RTMIDIAPI __declspec(dllexport)
27#else
28#define RTMIDIAPI __attribute__((visibility("default")))
29#endif
30#else
31#define RTMIDIAPI //__declspec(dllimport)
32#endif
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
39 struct RtMidiWrapper {
41 void* ptr;
42 void* data;
43
45 bool ok;
46
48 const char* msg;
49};
50
52typedef struct RtMidiWrapper* RtMidiPtr;
53
55typedef struct RtMidiWrapper* RtMidiInPtr;
56
58typedef struct RtMidiWrapper* RtMidiOutPtr;
59
61 enum RtMidiApi {
62 RTMIDI_API_UNSPECIFIED,
63 RTMIDI_API_MACOSX_CORE,
64 RTMIDI_API_LINUX_ALSA,
65 RTMIDI_API_UNIX_JACK,
66 RTMIDI_API_WINDOWS_MM,
67 RTMIDI_API_RTMIDI_DUMMY,
68 RTMIDI_API_WEB_MIDI_API,
69 RTMIDI_API_WINDOWS_UWP,
70 RTMIDI_API_ANDROID,
71 RTMIDI_API_NUM
72};
73
75 enum RtMidiErrorType {
76 RTMIDI_ERROR_WARNING,
77 RTMIDI_ERROR_DEBUG_WARNING,
78 RTMIDI_ERROR_UNSPECIFIED,
79 RTMIDI_ERROR_NO_DEVICES_FOUND,
80 RTMIDI_ERROR_INVALID_DEVICE,
81 RTMIDI_ERROR_MEMORY_ERROR,
82 RTMIDI_ERROR_INVALID_PARAMETER,
83 RTMIDI_ERROR_INVALID_USE,
84 RTMIDI_ERROR_DRIVER_ERROR,
85 RTMIDI_ERROR_SYSTEM_ERROR,
86 RTMIDI_ERROR_THREAD_ERROR
87};
88
97 typedef void(* RtMidiCCallback) (double timeStamp, const unsigned char* message,
98 size_t messageSize, void *userData);
99
100
101/* RtMidi API */
102
106RTMIDIAPI const char* rtmidi_get_version();
107
121RTMIDIAPI int rtmidi_get_compiled_api (enum RtMidiApi *apis, unsigned int apis_size);
122
125RTMIDIAPI const char *rtmidi_api_name(enum RtMidiApi api);
126
129RTMIDIAPI const char *rtmidi_api_display_name(enum RtMidiApi api);
130
133RTMIDIAPI enum RtMidiApi rtmidi_compiled_api_by_name(const char *name);
134
136RTMIDIAPI void rtmidi_error (enum RtMidiErrorType type, const char* errorString);
137
145RTMIDIAPI void rtmidi_open_port (RtMidiPtr device, unsigned int portNumber, const char *portName);
146
154RTMIDIAPI void rtmidi_open_virtual_port (RtMidiPtr device, const char *portName);
155
159RTMIDIAPI void rtmidi_close_port (RtMidiPtr device);
160
164RTMIDIAPI unsigned int rtmidi_get_port_count (RtMidiPtr device);
165
173RTMIDIAPI int rtmidi_get_port_name (RtMidiPtr device, unsigned int portNumber, char * bufOut, int * bufLen);
174
175/* RtMidiIn API */
176
178RTMIDIAPI RtMidiInPtr rtmidi_in_create_default (void);
179
191RTMIDIAPI RtMidiInPtr rtmidi_in_create (enum RtMidiApi api, const char *clientName, unsigned int queueSizeLimit);
192
194RTMIDIAPI void rtmidi_in_free (RtMidiInPtr device);
195
198RTMIDIAPI enum RtMidiApi rtmidi_in_get_current_api (RtMidiPtr device);
199
202RTMIDIAPI void rtmidi_in_set_callback (RtMidiInPtr device, RtMidiCCallback callback, void *userData);
203
206RTMIDIAPI void rtmidi_in_cancel_callback (RtMidiInPtr device);
207
210RTMIDIAPI void rtmidi_in_ignore_types (RtMidiInPtr device, bool midiSysex, bool midiTime, bool midiSense);
211
224RTMIDIAPI double rtmidi_in_get_message (RtMidiInPtr device, unsigned char *message, size_t *size);
225
226/* RtMidiOut API */
227
229RTMIDIAPI RtMidiOutPtr rtmidi_out_create_default (void);
230
240RTMIDIAPI RtMidiOutPtr rtmidi_out_create (enum RtMidiApi api, const char *clientName);
241
243RTMIDIAPI void rtmidi_out_free (RtMidiOutPtr device);
244
247RTMIDIAPI enum RtMidiApi rtmidi_out_get_current_api (RtMidiPtr device);
248
251RTMIDIAPI int rtmidi_out_send_message (RtMidiOutPtr device, const unsigned char *message, int length);
252
253
254#ifdef __cplusplus
255}
256#endif
257#endif
258
rtmidi_in_set_callback
RTMIDIAPI void rtmidi_in_set_callback(RtMidiInPtr device, RtMidiCCallback callback, void *userData)
Set a callback function to be invoked for incoming MIDI messages. See RtMidiIn::setCallback().
rtmidi_in_get_current_api
RTMIDIAPI enum RtMidiApi rtmidi_in_get_current_api(RtMidiPtr device)
Returns the MIDI API specifier for the given instance of RtMidiIn. See RtMidiIn::getCurrentApi().
RtMidiApi
RtMidiApi
MIDI API specifier arguments. See RtMidi::Api.
Definition rtmidi_c.h:61
RtMidiWrapper::ptr
void * ptr
The wrapped RtMidi object.
Definition rtmidi_c.h:41
RtMidiErrorType
RtMidiErrorType
Defined RtMidiError types. See RtMidiError::Type.
Definition rtmidi_c.h:75
rtmidi_open_virtual_port
RTMIDIAPI void rtmidi_open_virtual_port(RtMidiPtr device, const char *portName)
Creates a virtual MIDI port to which other software applications can connect.
rtmidi_in_get_message
RTMIDIAPI double rtmidi_in_get_message(RtMidiInPtr device, unsigned char *message, size_t *size)
rtmidi_in_create_default
RTMIDIAPI RtMidiInPtr rtmidi_in_create_default(void)
Create a default RtMidiInPtr value, with no initialization.
rtmidi_close_port
RTMIDIAPI void rtmidi_close_port(RtMidiPtr device)
Close a MIDI connection. See RtMidi::closePort().
RtMidiWrapper::msg
const char * msg
If an error occurred (ok != true), set to an error message.
Definition rtmidi_c.h:48
rtmidi_in_ignore_types
RTMIDIAPI void rtmidi_in_ignore_types(RtMidiInPtr device, bool midiSysex, bool midiTime, bool midiSense)
Specify whether certain MIDI message types should be queued or ignored during input....
rtmidi_get_compiled_api
RTMIDIAPI int rtmidi_get_compiled_api(enum RtMidiApi *apis, unsigned int apis_size)
Determine the available compiled MIDI APIs.
rtmidi_out_create
RTMIDIAPI RtMidiOutPtr rtmidi_out_create(enum RtMidiApi api, const char *clientName)
Create a RtMidiOutPtr value, with given and clientName.
RtMidiWrapper::ok
bool ok
True when the last function call was OK.
Definition rtmidi_c.h:45
rtmidi_in_cancel_callback
RTMIDIAPI void rtmidi_in_cancel_callback(RtMidiInPtr device)
Cancel use of the current callback function (if one exists). See RtMidiIn::cancelCallback().
rtmidi_open_port
RTMIDIAPI void rtmidi_open_port(RtMidiPtr device, unsigned int portNumber, const char *portName)
Open a MIDI port.
rtmidi_out_send_message
RTMIDIAPI int rtmidi_out_send_message(RtMidiOutPtr device, const unsigned char *message, int length)
Immediately send a single message out an open MIDI output port. See RtMidiOut::sendMessage().
rtmidi_out_free
RTMIDIAPI void rtmidi_out_free(RtMidiOutPtr device)
Free the given RtMidiOutPtr.
rtmidi_get_version
RTMIDIAPI const char * rtmidi_get_version()
Return the current RtMidi version. ! See RtMidi::getVersion().
rtmidi_in_create
RTMIDIAPI RtMidiInPtr rtmidi_in_create(enum RtMidiApi api, const char *clientName, unsigned int queueSizeLimit)
Create a RtMidiInPtr value, with given api, clientName and queueSizeLimit.
rtmidi_in_free
RTMIDIAPI void rtmidi_in_free(RtMidiInPtr device)
Free the given RtMidiInPtr.
RtMidiCCallback
void(* RtMidiCCallback)(double timeStamp, const unsigned char *message, size_t messageSize, void *userData)
The type of a RtMidi callback function.
Definition rtmidi_c.h:97
rtmidi_get_port_count
RTMIDIAPI unsigned int rtmidi_get_port_count(RtMidiPtr device)
Return the number of available MIDI ports. See RtMidi::getPortCount().
rtmidi_out_get_current_api
RTMIDIAPI enum RtMidiApi rtmidi_out_get_current_api(RtMidiPtr device)
Returns the MIDI API specifier for the given instance of RtMidiOut. See RtMidiOut::getCurrentApi().
rtmidi_get_port_name
RTMIDIAPI int rtmidi_get_port_name(RtMidiPtr device, unsigned int portNumber, char *bufOut, int *bufLen)
Access a string identifier for the specified MIDI input port number.
rtmidi_api_name
RTMIDIAPI const char * rtmidi_api_name(enum RtMidiApi api)
Return the name of a specified compiled MIDI API. See RtMidi::getApiName().
rtmidi_compiled_api_by_name
RTMIDIAPI enum RtMidiApi rtmidi_compiled_api_by_name(const char *name)
Return the compiled MIDI API having the given name. See RtMidi::getCompiledApiByName().
rtmidi_api_display_name
RTMIDIAPI const char * rtmidi_api_display_name(enum RtMidiApi api)
Return the display name of a specified compiled MIDI API. See RtMidi::getApiDisplayName().
rtmidi_out_create_default
RTMIDIAPI RtMidiOutPtr rtmidi_out_create_default(void)
Create a default RtMidiInPtr value, with no initialization.
RTMIDI_API_NUM
@ RTMIDI_API_NUM
Definition rtmidi_c.h:71
RTMIDI_API_LINUX_ALSA
@ RTMIDI_API_LINUX_ALSA
Definition rtmidi_c.h:64
RTMIDI_API_WINDOWS_MM
@ RTMIDI_API_WINDOWS_MM
Definition rtmidi_c.h:66
RTMIDI_API_MACOSX_CORE
@ RTMIDI_API_MACOSX_CORE
Definition rtmidi_c.h:63
RTMIDI_API_RTMIDI_DUMMY
@ RTMIDI_API_RTMIDI_DUMMY
Definition rtmidi_c.h:67
RTMIDI_API_WINDOWS_UWP
@ RTMIDI_API_WINDOWS_UWP
Definition rtmidi_c.h:69
RTMIDI_API_WEB_MIDI_API
@ RTMIDI_API_WEB_MIDI_API
Definition rtmidi_c.h:68
RTMIDI_API_UNSPECIFIED
@ RTMIDI_API_UNSPECIFIED
Definition rtmidi_c.h:62
RTMIDI_API_UNIX_JACK
@ RTMIDI_API_UNIX_JACK
Definition rtmidi_c.h:65
RTMIDI_API_ANDROID
@ RTMIDI_API_ANDROID
Definition rtmidi_c.h:70
RTMIDI_ERROR_INVALID_PARAMETER
@ RTMIDI_ERROR_INVALID_PARAMETER
Definition rtmidi_c.h:82
RTMIDI_ERROR_MEMORY_ERROR
@ RTMIDI_ERROR_MEMORY_ERROR
Definition rtmidi_c.h:81
RTMIDI_ERROR_UNSPECIFIED
@ RTMIDI_ERROR_UNSPECIFIED
Definition rtmidi_c.h:78
RTMIDI_ERROR_INVALID_USE
@ RTMIDI_ERROR_INVALID_USE
Definition rtmidi_c.h:83
RTMIDI_ERROR_DRIVER_ERROR
@ RTMIDI_ERROR_DRIVER_ERROR
Definition rtmidi_c.h:84
RTMIDI_ERROR_DEBUG_WARNING
@ RTMIDI_ERROR_DEBUG_WARNING
Definition rtmidi_c.h:77
RTMIDI_ERROR_WARNING
@ RTMIDI_ERROR_WARNING
Definition rtmidi_c.h:76
RTMIDI_ERROR_SYSTEM_ERROR
@ RTMIDI_ERROR_SYSTEM_ERROR
Definition rtmidi_c.h:85
RTMIDI_ERROR_NO_DEVICES_FOUND
@ RTMIDI_ERROR_NO_DEVICES_FOUND
Definition rtmidi_c.h:79
RTMIDI_ERROR_INVALID_DEVICE
@ RTMIDI_ERROR_INVALID_DEVICE
Definition rtmidi_c.h:80
RTMIDI_ERROR_THREAD_ERROR
@ RTMIDI_ERROR_THREAD_ERROR
Definition rtmidi_c.h:86
RtMidiWrapper
Wraps an RtMidi object for C function return statuses.
Definition rtmidi_c.h:39

| ©2003-2023 Gary P. Scavone, McGill University. All Rights Reserved. Maintained by Gary P. Scavone, gary at music.mcgill.ca