File tree Expand file tree Collapse file tree 2 files changed +15
-15
lines changed Expand file tree Collapse file tree 2 files changed +15
-15
lines changed Original file line number Diff line number Diff line change 1616
1717#include " MIDIUSB.h"
1818
19- #define MIDI_BUFFER_SIZE 16
19+ #define MIDI_BUFFER_SIZE 64
2020
2121#if defined(ARDUINO_ARCH_AVR)
2222
@@ -125,24 +125,23 @@ midiEventPacket_t MIDI_::read(void)
125125{
126126 ring_bufferMIDI *buffer = &midi_rx_buffer;
127127 midiEventPacket_t c = buffer->midiEvent [buffer->tail ];
128- c.header = 0 ;
129- c.byte1 = 0 ;
130- c.byte2 = 0 ;
131- c.byte3 = 0 ;
132128
133- // if the head isn't ahead of the tail, we don't have any characters
134- if (buffer->head == buffer->tail )
135- {
136- return c;
129+ if (USB_Available (MIDI_RX)) {
130+ accept ();
131+ c = buffer->midiEvent [buffer->tail ];
132+ } else {
133+ c.header = 0 ;
134+ c.byte1 = 0 ;
135+ c.byte2 = 0 ;
136+ c.byte3 = 0 ;
137137 }
138- else
138+
139+ // if the head isn't ahead of the tail, we don't have any characters
140+ if (buffer->head != buffer->tail )
139141 {
140- midiEventPacket_t c = buffer->midiEvent [buffer->tail ];
141142 buffer->tail = (uint32_t )(buffer->tail + 1 ) % MIDI_BUFFER_SIZE;
142- if (USB_Available (MIDI_RX))
143- accept ();
144- return c;
145143 }
144+ return c;
146145}
147146
148147void MIDI_::flush (void )
Original file line number Diff line number Diff line change @@ -47,13 +47,14 @@ class MIDI_
4747{
4848// private:
4949// RingBuffer *_midi_rx_buffer;
50+ private:
51+ void accept (void );
5052public:
5153 MIDI_ (void );
5254
5355 int8_t begin ();
5456
5557 uint32_t available (void );
56- void accept (void );
5758 midiEventPacket_t read (void );
5859 void flush (void );
5960 void sendMIDI (midiEventPacket_t event);
You can’t perform that action at this time.
0 commit comments