summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2021-04-02 15:47:40 +0700
committerGitHub <[email protected]>2021-04-02 15:47:40 +0700
commiteb92986b88602de046655a1fdb2f8538dce1c098 (patch)
tree0c1a52230f9af7b774f12539c8637df62ec59ebc /examples
parente4f5a5d7b345ce056f033d382151ee834f2458f2 (diff)
parent7582528067fcfc0a4fe6039cfcb00d2f4c702b53 (diff)
Merge pull request #766 from hathach/enhance-midi
Enhance midi
Diffstat (limited to 'examples')
-rw-r--r--examples/device/dynamic_configuration/src/main.c8
-rw-r--r--examples/device/midi_test/src/main.c8
2 files changed, 10 insertions, 6 deletions
diff --git a/examples/device/dynamic_configuration/src/main.c b/examples/device/dynamic_configuration/src/main.c
index acee295f6..4c10f55b0 100644
--- a/examples/device/dynamic_configuration/src/main.c
+++ b/examples/device/dynamic_configuration/src/main.c
@@ -172,7 +172,7 @@ void midi_task(void)
// regardless of these being used or not. Therefore incoming traffic should be read
// (possibly just discarded) to avoid the sender blocking in IO
uint8_t packet[4];
- while(tud_midi_available()) tud_midi_receive(packet);
+ while( tud_midi_available() ) tud_midi_packet_read(packet);
// send note every 1000 ms
if (board_millis() - start_ms < 286) return; // not enough time
@@ -186,10 +186,12 @@ void midi_task(void)
if (previous < 0) previous = sizeof(note_sequence) - 1;
// Send Note On for current position at full velocity (127) on channel 1.
- tud_midi_write24(cable_num, 0x90 | channel, note_sequence[note_pos], 127);
+ uint8_t note_on[3] = { 0x90 | channel, note_sequence[note_pos], 127 };
+ tud_midi_stream_write(cable_num, note_on, 3);
// Send Note Off for previous note.
- tud_midi_write24(cable_num, 0x80 | channel, note_sequence[previous], 0);
+ uint8_t note_off[3] = { 0x80 | channel, note_sequence[previous], 0};
+ tud_midi_stream_write(cable_num, note_off, 3);
// Increment position
note_pos++;
diff --git a/examples/device/midi_test/src/main.c b/examples/device/midi_test/src/main.c
index 858a096b6..9e0e82a10 100644
--- a/examples/device/midi_test/src/main.c
+++ b/examples/device/midi_test/src/main.c
@@ -132,7 +132,7 @@ void midi_task(void)
// regardless of these being used or not. Therefore incoming traffic should be read
// (possibly just discarded) to avoid the sender blocking in IO
uint8_t packet[4];
- while(tud_midi_available()) tud_midi_receive(packet);
+ while ( tud_midi_available() ) tud_midi_packet_read(packet);
// send note every 1000 ms
if (board_millis() - start_ms < 286) return; // not enough time
@@ -146,10 +146,12 @@ void midi_task(void)
if (previous < 0) previous = sizeof(note_sequence) - 1;
// Send Note On for current position at full velocity (127) on channel 1.
- tud_midi_write24(cable_num, 0x90 | channel, note_sequence[note_pos], 127);
+ uint8_t note_on[3] = { 0x90 | channel, note_sequence[note_pos], 127 };
+ tud_midi_stream_write(cable_num, note_on, 3);
// Send Note Off for previous note.
- tud_midi_write24(cable_num, 0x80 | channel, note_sequence[previous], 0);
+ uint8_t note_off[3] = { 0x80 | channel, note_sequence[previous], 0};
+ tud_midi_stream_write(cable_num, note_off, 3);
// Increment position
note_pos++;