Content¶
Documentation¶
Midi¶
-
template<Api
api
= Unspecified>
classMidijo
::
Midi
¶ Public Functions
-
const DeviceInfo &
Device
(int id) const¶ Returns device with the given id.
- Return
device with id
- Parameters
id
: device id
-
int
DeviceCount
() const¶ Get the device count.
- Return
device count
-
const MidiInformation &
Information
() const¶ Get midi information. This call only returns useful information after a device has been opened.
- Return
midi information
-
Error
Open
(const MidiParameters &settings = MidiParameters{})¶ Open the midi device.
- Return
AlreadyOpen - If the stream is already opened
InUse - If the midi device is already in use
InvalidDevice - If the provided device id is invalid
Fail - If the device failed to open
NoError - If stream opened successfully
- Parameters
settings
:MidiParameters
-
const DeviceInfo &
-
template<Api
api
= Unspecified>
classMidijo
::
MidiIn
: public Midijo::Midi<Unspecified>¶ Public Functions
-
MidiIn
()¶ Constructor
- Parameters
a
: api
-
template<Api
a
>
MidiIn<a> &Get
()¶ Get this MidiIn object as a specific api, to expose api specific functions.
- Return
this as a midi object for a specific api
-
template<ValidCallback
T
>
CallbackScopedCallback
(T &&callback)¶ Add a midi event callback. The returned Callback object will remove the callback from when its destructor is called. This behaviour is useful when registering a callback inside an object, because this will automatically remove the callback when the object is destroyed.
- Return
callback object
- Parameters
callback
: callback
-
template<ValidCallback
T
>
voidCallback
(T &&callback)¶ Add a midi event callback.
- Parameters
callback
: callback
-
void
HandleEvents
()¶ Only use this when async is set to false. Handles all the events in the queue.
-
bool
HandleEvent
()¶ Only use this when async is set to false. Handles a single event, returns true when an event was handled.
- Return
true if there was an event to handle.
-
Events¶
-
struct
Midijo
::
Event
¶ Subclassed by Midijo::Aftertouch, Midijo::CC, Midijo::ChannelAftertouch, Midijo::NoteOff, Midijo::NoteOn, Midijo::PitchBend, Midijo::ProgramChange
-
struct
Midijo
::
NoteOn
: public Midijo::Event¶ Event that fires when you press a midi key.
Public Functions
-
NoteOn
(Midijo::Note note, uint8_t velocity)¶ Create note on event.
- Parameters
note
: notevelocity
: velocity
-
NoteOn
(uint8_t raw, uint8_t velocity)¶ Create note on event.
- Parameters
raw
: raw note numbervelocity
: velocity
-
Midijo::Note
Note
() const¶ Get the midi note that was pressed.
- Return
midi note
-
uint8_t
RawNote
() const¶ Get the raw note number.
- Return
raw note number
-
uint8_t
Velocity
() const¶ Get the velocity.
- Return
velocity
-
-
struct
Midijo
::
NoteOff
: public Midijo::Event¶ Event that fires when you release a midi key.
Public Functions
-
NoteOff
(Midijo::Note note, uint8_t velocity)¶ Create note off event.
- Parameters
note
: notevelocity
: velocity
-
NoteOff
(uint8_t raw, uint8_t velocity)¶ Create note off event.
- Parameters
raw
: raw note numbervelocity
: velocity
-
Midijo::Note
Note
() const¶ Get the midi note that was pressed.
- Return
midi note
-
uint8_t
RawNote
() const¶ Get the raw note number.
- Return
raw note number
-
uint8_t
Velocity
() const¶ Get the velocity.
- Return
velocity
-
-
struct
Midijo
::
Aftertouch
: public Midijo::Event¶ Event that fires when there is a pressure change press on one of the currently pressed midi keys.
Public Functions
-
Aftertouch
(Midijo::Note note, uint8_t amount)¶ Create aftertouch event.
- Parameters
note
: noteamount
: amount
-
Aftertouch
(uint8_t raw, uint8_t amount)¶ Create aftertouch event.
- Parameters
raw
: raw note numberamount
: amount
-
Midijo::Note
Note
() const¶ Get the midi note that was pressed.
- Return
midi note
-
uint8_t
RawNote
() const¶ Get the raw note number.
- Return
raw note number
-
uint8_t
Amount
() const¶ Get the aftertouch amount.
- Return
amount
-
-
struct
Midijo
::
CC
: public Midijo::Event¶ Event that fires when there is a change in state of one of the controllers.
-
struct
Midijo
::
ProgramChange
: public Midijo::Event¶ Event that fires when a program change is requested.
Examples¶
Midi input¶
#include "Midijo/Midijo.hpp"
using namespace Midijo;
int main()
{
MidiIn midi;
// Register a callback for any event type.
midi.Callback([](const Event& e)
{
std::cout <<
(int)e.byte1 << ", " << (int)e.byte2 << ", " <<
(int)e.byte3 << ", " << (int)e.byte4 << '\n';
});
// Register a callback for a specific event type.
midi.Callback([](const NoteOn& e)
{
std::cout << e.Note() << ", " << e.Velocity() << '\n';
});
// Open device with id 0 and start.
midi.Open({.device = 0 });
midi.Start();
// Receive events for 10 seconds.
std::this_thread::sleep_for(std::chrono::seconds(10));
// Close the device.
midi.Close();
}