-
Notifications
You must be signed in to change notification settings - Fork 267
Using custom Settings
Francois Best edited this page Nov 7, 2018
·
4 revisions
The library is shipped with the following default Settings (found in src/midi_Settings.h
):
struct DefaultSettings
{
/*! Running status enables short messages when sending multiple values
of the same type and channel.\n
Warning: does not work with some hardware, enable with caution.
*/
static const bool UseRunningStatus = false;
/*! NoteOn with 0 velocity should be handled as NoteOff.\n
Set to true to get NoteOff events when receiving null-velocity NoteOn messages.\n
Set to false to get NoteOn events when receiving null-velocity NoteOn messages.
*/
static const bool HandleNullVelocityNoteOnAsNoteOff = true;
/*! Setting this to true will make MIDI.read parse only one byte of data for each
call when data is available. This can speed up your application if receiving
a lot of traffic, but might induce MIDI Thru and treatment latency.
*/
static const bool Use1ByteParsing = true;
/*! Override the default MIDI baudrate to transmit over USB serial, to
a decoding program such as Hairless MIDI (set baudrate to 115200)\n
http://projectgus.github.io/hairless-midiserial/
*/
static const long BaudRate = 31250;
/*! Maximum size of SysEx receivable. Decrease to save RAM if you don't expect
to receive SysEx, or adjust accordingly.
*/
static const unsigned SysExMaxSize = 128;
};
Rather than changing the defaults in the library source files, you can override them locally in your sketch with your own Settings, like this:
struct MySettings : public midi::DefaultSettings
{
static const unsigned SysExMaxSize = 1024; // Accept SysEx messages up to 1024 bytes long.
static const bool UseRunningStatus = true; // My devices seem to be ok with it.
};
// Create a 'MIDI' object using MySettings bound to Serial2.
MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial2, MIDI, MySettings);
void setup()
{
MIDI.begin();
}
void loop()
{
MIDI.read();
}