Entropy Piano Tuner
1.1.3 (documentation not yet complete)
An open-source experimental software for piano tuning by entropy minimization
|
Interface for reading an externally connected MIDI keyboard. More...
#include <RtMidiimplementation.h>
Public Member Functions | |
RtMidiImplementation () | |
Constructor without functionality. More... | |
~RtMidiImplementation () | |
Destructor without functionality. More... | |
void | init () overridefinal |
Initialize RtMidi implementation. More... | |
void | exit () overridefinal |
Shut down RtMidi implementation. More... | |
int | GetNumberOfPorts () overridefinal |
Get the number of available MIDI input ports. More... | |
std::string | GetPortName (int i) overridefinal |
Get the name of device number i (starting with zero) More... | |
std::string | GetPortNames () overridefinal |
Get a list of all available input devices. More... | |
bool | OpenPort (int i, std::string AppName="") overridefinal |
Open MIDI input device number i. More... | |
bool | OpenPort (std::string AppName="") overridefinal |
Open MIDI device with the highest port number. More... | |
int | getCurrentPort () const overridefinal |
Get the current port number. More... | |
Public Member Functions inherited from MidiAdapter | |
MidiAdapter () | |
Constructor without function. More... | |
~MidiAdapter () | |
Destructor without function. More... | |
void | send (Data &data) |
Send new MIDI data to the messaging system. More... | |
Private Member Functions | |
void | ClearQueue () |
Clear the MIDI input queue. More... | |
Static Private Member Functions | |
static void | StaticCallback (double deltatime, std::vector< unsigned char > *message, void *) |
Static callback function (private) More... | |
Private Attributes | |
std::unique_ptr< RtMidiIn > | mRtMidi |
Instance of the third-party MIDI interface. More... | |
int | mCurrentPort |
The current port that is used or -1 of none. More... | |
Additional Inherited Members | |
Public Types inherited from MidiAdapter | |
enum | MidiEvent { MIDI_UNDEFINED = 0, MIDI_KEY_PRESS, MIDI_KEY_RELEASE, MIDI_CONTROL_CHANGE } |
Enumeration of the possible MIDI events. More... | |
Static Public Member Functions inherited from MidiAdapter | |
static MidiEvent | byteToEvent (int byte) |
Convert MIDI code to MidiEvent. More... | |
Interface for reading an externally connected MIDI keyboard.
This class provides a simplified interface for reading external MIDI keyboards. It uses the third-party software RtMidi 2.1.0 which is published under the same license.
Requirements for Linux: alsa_devel, library asound, #define LINUX_ALSA
Definition at line 52 of file RtMidiimplementation.h.
RtMidiImplementation::RtMidiImplementation | ( | ) |
Constructor without functionality.
Definition at line 37 of file RtMidiimplementation.cpp.
|
inline |
Destructor without functionality.
Definition at line 56 of file RtMidiimplementation.h.
|
private |
Clear the MIDI input queue.
This functions polls data from the queue until it is empty. Here the timing is crucial.
Details: Clearing the queue in RtMidi requires some effort. The queue is read via getMessage in intervals of 2 us. Unfortunately this function does not really tell us wether the queue is empty, rather it may respond after some time. To circumvent this problem we decalare the queue as empty if 1024 request do not render an event.
Definition at line 219 of file RtMidiimplementation.cpp.
|
finaloverridevirtual |
Shut down RtMidi implementation.
Destroys the RtMidi instance, resetting the pointer mRtMidi.
Implements MidiAdapter.
Definition at line 68 of file RtMidiimplementation.cpp.
|
inlinefinaloverridevirtual |
Get the current port number.
Implements MidiAdapter.
Definition at line 66 of file RtMidiimplementation.h.
|
finaloverridevirtual |
Get the number of available MIDI input ports.
Implements MidiAdapter.
Definition at line 82 of file RtMidiimplementation.cpp.
|
finaloverridevirtual |
Get the name of device number i (starting with zero)
i | : Number of the port starting with 0 |
Implements MidiAdapter.
Definition at line 107 of file RtMidiimplementation.cpp.
|
finaloverridevirtual |
Get a list of all available input devices.
Reimplemented from MidiAdapter.
Definition at line 129 of file RtMidiimplementation.cpp.
|
finaloverridevirtual |
Initialize RtMidi implementation.
Initializes the RtMidi implementation by trying to create a new instance. Exception errors are caught and converted into conventional error messages.
Implements MidiAdapter.
Definition at line 53 of file RtMidiimplementation.cpp.
|
finaloverridevirtual |
Open MIDI input device number i.
i | : Number of the MIDI port to be opened. |
AppName | : Name of the application (e.g. Entropy Piano Tuner Midi in). Shows up in the list MIDI input devices. |
Implements MidiAdapter.
Definition at line 160 of file RtMidiimplementation.cpp.
|
finaloverridevirtual |
Open MIDI device with the highest port number.
If MIDI devices are connected, this function opens the port with the highest number (usually this is the last one that has been connected to the computer).
AppName | : Name of the application (e.g. Entropy Piano Tuner Midi in). Shows up in the list MIDI input devices. |
Implements MidiAdapter.
Definition at line 196 of file RtMidiimplementation.cpp.
|
staticprivate |
Static callback function (private)
The RtMidi package does not admit member functions for callback. To circumvent this restriction, we define a static callback function to which all MIDI events are passed. The third user-specific parameter void pointer passes the address of the object. The purpose of the callback function is to send off the received data to the messaging system.
deltatime | : passes the elapsed time since the last callback |
message | : Pointer to a vector containing the MIDI event data. |
obj | : Pointer to the instance of this class. See also: RtMidiImplementation::OpenPort |
Definition at line 262 of file RtMidiimplementation.cpp.
|
private |
The current port that is used or -1 of none.
Static callback function, required by RtMidi.
Definition at line 71 of file RtMidiimplementation.h.
|
private |
Instance of the third-party MIDI interface.
Definition at line 70 of file RtMidiimplementation.h.