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
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
35 extern "C" {
36 #endif
37
39 struct RtMidiWrapper {
41 void* ptr;
42 void* data;
43
45 bool ok;
46
48 const char* msg;
49 };
50
52 typedef struct RtMidiWrapper* RtMidiPtr;
53
55 typedef struct RtMidiWrapper* RtMidiInPtr;
56
58 typedef 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_NUM
69 };
70
72 enum RtMidiErrorType {
73 RTMIDI_ERROR_WARNING,
74 RTMIDI_ERROR_DEBUG_WARNING,
75 RTMIDI_ERROR_UNSPECIFIED,
76 RTMIDI_ERROR_NO_DEVICES_FOUND,
77 RTMIDI_ERROR_INVALID_DEVICE,
78 RTMIDI_ERROR_MEMORY_ERROR,
79 RTMIDI_ERROR_INVALID_PARAMETER,
80 RTMIDI_ERROR_INVALID_USE,
81 RTMIDI_ERROR_DRIVER_ERROR,
82 RTMIDI_ERROR_SYSTEM_ERROR,
83 RTMIDI_ERROR_THREAD_ERROR
84 };
85
94 typedef void(* RtMidiCCallback) (double timeStamp, const unsigned char* message,
95 size_t messageSize, void *userData);
96
97
98 /* RtMidi API */
99
113 RTMIDIAPI int rtmidi_get_compiled_api (enum RtMidiApi *apis, unsigned int apis_size);
114
117 RTMIDIAPI const char *rtmidi_api_name(enum RtMidiApi api);
118
121 RTMIDIAPI const char *rtmidi_api_display_name(enum RtMidiApi api);
122
125 RTMIDIAPI enum RtMidiApi rtmidi_compiled_api_by_name(const char *name);
126
128 RTMIDIAPI void rtmidi_error (enum RtMidiErrorType type, const char* errorString);
129
137 RTMIDIAPI void rtmidi_open_port (RtMidiPtr device, unsigned int portNumber, const char *portName);
138
146 RTMIDIAPI void rtmidi_open_virtual_port (RtMidiPtr device, const char *portName);
147
151 RTMIDIAPI void rtmidi_close_port (RtMidiPtr device);
152
156 RTMIDIAPI unsigned int rtmidi_get_port_count (RtMidiPtr device);
157
161 RTMIDIAPI const char* rtmidi_get_port_name (RtMidiPtr device, unsigned int portNumber);
162
163 /* RtMidiIn API */
164
166 RTMIDIAPI RtMidiInPtr rtmidi_in_create_default (void);
167
179 RTMIDIAPI RtMidiInPtr rtmidi_in_create (enum RtMidiApi api, const char *clientName, unsigned int queueSizeLimit);
180
182 RTMIDIAPI void rtmidi_in_free (RtMidiInPtr device);
183
186 RTMIDIAPI enum RtMidiApi rtmidi_in_get_current_api (RtMidiPtr device);
187
190 RTMIDIAPI void rtmidi_in_set_callback (RtMidiInPtr device, RtMidiCCallback callback, void *userData);
191
194 RTMIDIAPI void rtmidi_in_cancel_callback (RtMidiInPtr device);
195
198 RTMIDIAPI void rtmidi_in_ignore_types (RtMidiInPtr device, bool midiSysex, bool midiTime, bool midiSense);
199
211 RTMIDIAPI double rtmidi_in_get_message (RtMidiInPtr device, unsigned char *message, size_t *size);
212
213 /* RtMidiOut API */
214
216 RTMIDIAPI RtMidiOutPtr rtmidi_out_create_default (void);
217
227 RTMIDIAPI RtMidiOutPtr rtmidi_out_create (enum RtMidiApi api, const char *clientName);
228
230 RTMIDIAPI void rtmidi_out_free (RtMidiOutPtr device);
231
234 RTMIDIAPI enum RtMidiApi rtmidi_out_get_current_api (RtMidiPtr device);
235
238 RTMIDIAPI int rtmidi_out_send_message (RtMidiOutPtr device, const unsigned char *message, int length);
239
240
241 #ifdef __cplusplus
242 }
243 #endif
244 #endif
245
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_ERROR_MEMORY_ERROR
Definition: rtmidi_c.h:78
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_ERROR_INVALID_USE
Definition: rtmidi_c.h:80
RTMIDI_API_NUM
Definition: rtmidi_c.h:68
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_close_port
RTMIDIAPI void rtmidi_close_port(RtMidiPtr device)
Close a MIDI connection. See RtMidi::closePort().
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:94
RtMidiApi
RtMidiApi
MIDI API specifier arguments. See RtMidi::Api.
Definition: rtmidi_c.h:61
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_API_WINDOWS_MM
Definition: rtmidi_c.h:66
RTMIDI_ERROR_NO_DEVICES_FOUND
Definition: rtmidi_c.h:76
rtmidi_out_create_default
RTMIDIAPI RtMidiOutPtr rtmidi_out_create_default(void)
Create a default RtMidiInPtr value, with no initialization.
rtmidi_out_free
RTMIDIAPI void rtmidi_out_free(RtMidiOutPtr device)
Free the given RtMidiOutPtr.
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_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_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_ERROR_THREAD_ERROR
Definition: rtmidi_c.h:83
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().
rtmidi_in_create_default
RTMIDIAPI RtMidiInPtr rtmidi_in_create_default(void)
Create a default RtMidiInPtr value, with no initialization.
RTMIDI_ERROR_SYSTEM_ERROR
Definition: rtmidi_c.h:82
RTMIDI_ERROR_DRIVER_ERROR
Definition: rtmidi_c.h:81
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_API_MACOSX_CORE
Definition: rtmidi_c.h:63
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_ERROR_INVALID_PARAMETER
Definition: rtmidi_c.h:79
RtMidiWrapper::msg
const char * msg
If an error occured (ok != true), set to an error message.
Definition: rtmidi_c.h:48
RTMIDI_ERROR_INVALID_DEVICE
Definition: rtmidi_c.h:77
rtmidi_open_port
RTMIDIAPI void rtmidi_open_port(RtMidiPtr device, unsigned int portNumber, const char *portName)
Open a MIDI port.
rtmidi_get_compiled_api
RTMIDIAPI int rtmidi_get_compiled_api(enum RtMidiApi *apis, unsigned int apis_size)
Determine the available compiled MIDI APIs.
rtmidi_in_get_message
RTMIDIAPI double rtmidi_in_get_message(RtMidiInPtr device, unsigned char *message, size_t *size)
RtMidiWrapper::ptr
void * ptr
The wrapped RtMidi object.
Definition: rtmidi_c.h:41
RTMIDI_API_RTMIDI_DUMMY
Definition: rtmidi_c.h:67
RtMidiErrorType
RtMidiErrorType
Defined RtMidiError types. See RtMidiError::Type.
Definition: rtmidi_c.h:72
rtmidi_out_create
RTMIDIAPI RtMidiOutPtr rtmidi_out_create(enum RtMidiApi api, const char *clientName)
Create a RtMidiOutPtr value, with given and clientName.
rtmidi_get_port_name
RTMIDIAPI const char * rtmidi_get_port_name(RtMidiPtr device, unsigned int portNumber)
Return a string identifier for the specified MIDI input port number. See RtMidi::getPortName().
rtmidi_in_free
RTMIDIAPI void rtmidi_in_free(RtMidiInPtr device)
Free the given RtMidiInPtr.
RtMidiWrapper::ok
bool ok
True when the last function call was OK.
Definition: rtmidi_c.h:45
RTMIDI_API_UNSPECIFIED
Definition: rtmidi_c.h:62
RTMIDI_ERROR_UNSPECIFIED
Definition: rtmidi_c.h:75
RTMIDI_ERROR_WARNING
Definition: rtmidi_c.h:73
RtMidiWrapper
Wraps an RtMidi object for C function return statuses.
Definition: rtmidi_c.h:39
RTMIDI_API_LINUX_ALSA
Definition: rtmidi_c.h:64
RTMIDI_ERROR_DEBUG_WARNING
Definition: rtmidi_c.h:74
RTMIDI_API_UNIX_JACK
Definition: rtmidi_c.h:65
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_api_name
RTMIDIAPI const char * rtmidi_api_name(enum RtMidiApi api)
Return the name of a specified compiled MIDI API. See RtMidi::getApiName().

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