Skip to content

Commit 596a1b0

Browse files
committed
added CustomBaudRate example
- added customer baudrate example - fixed old refs to examples in Doxygen
1 parent 8f8c7cf commit 596a1b0

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

.github/workflows/platformio.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
- Input
2424
- RPN_NRPN
2525
- SimpleSynth
26+
- CustomBaudRate
2627
board:
2728
- uno
2829
- due

doc/midi_DoxygenMainPage.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// Examples
1313

1414
/*!
15-
\example MIDI_Basic_IO.ino
15+
\example Basic_IO.ino
1616
This example shows how to perform simple input and output MIDI. \n
1717
\n
1818
When any message arrives to the Arduino, the LED is turned on,
@@ -29,15 +29,15 @@
2929
*/
3030

3131
/*!
32-
\example MIDI_Callbacks.ino
32+
\example Callbacks.ino
3333
This example shows how to use callbacks for easier MIDI input handling. \n
3434
*/
3535

3636
/*!
37-
\example MIDI_Bench.ino
38-
\example MIDI_DualMerger.ino
39-
\example MIDI_Input.ino
40-
\example MIDI_SimpleSynth.ino
37+
\example Bench.ino
38+
\example DualMerger.ino
39+
\example Input.ino
40+
\example SimpleSynth.ino
4141
*/
4242

4343
// -----------------------------------------------------------------------------
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <MIDI.h>
2+
3+
// Override the default MIDI baudrate to
4+
// a decoding program such as Hairless MIDI (set baudrate to 115200)
5+
6+
struct CustomBaudRate : public MIDI_NAMESPACE::DefaultSettings {
7+
static const long BaudRate = 115200;
8+
};
9+
10+
MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial, MIDI, CustomBaudRate);
11+
12+
void setup() {
13+
pinMode(LED_BUILTIN, OUTPUT);
14+
MIDI.begin(MIDI_CHANNEL_OMNI);
15+
}
16+
17+
void loop() {
18+
if (MIDI.read()) // If we have received a message
19+
{
20+
digitalWrite(LED_BUILTIN, HIGH);
21+
MIDI.sendNoteOn(42, 127, 1); // Send a Note (pitch 42, velo 127 on channel 1)
22+
delay(1000); // Wait for a second
23+
MIDI.sendNoteOff(42, 0, 1); // Stop the note
24+
digitalWrite(LED_BUILTIN, LOW);
25+
}
26+
}

0 commit comments

Comments
 (0)