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 16
16
17
17
#include " MIDIUSB.h"
18
18
19
- #define MIDI_BUFFER_SIZE 16
19
+ #define MIDI_BUFFER_SIZE 64
20
20
21
21
#if defined(ARDUINO_ARCH_AVR)
22
22
@@ -125,24 +125,23 @@ midiEventPacket_t MIDI_::read(void)
125
125
{
126
126
ring_bufferMIDI *buffer = &midi_rx_buffer;
127
127
midiEventPacket_t c = buffer->midiEvent [buffer->tail ];
128
- c.header = 0 ;
129
- c.byte1 = 0 ;
130
- c.byte2 = 0 ;
131
- c.byte3 = 0 ;
132
128
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 ;
137
137
}
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 )
139
141
{
140
- midiEventPacket_t c = buffer->midiEvent [buffer->tail ];
141
142
buffer->tail = (uint32_t )(buffer->tail + 1 ) % MIDI_BUFFER_SIZE;
142
- if (USB_Available (MIDI_RX))
143
- accept ();
144
- return c;
145
143
}
144
+ return c;
146
145
}
147
146
148
147
void MIDI_::flush (void )
Original file line number Diff line number Diff line change @@ -47,13 +47,14 @@ class MIDI_
47
47
{
48
48
// private:
49
49
// RingBuffer *_midi_rx_buffer;
50
+ private:
51
+ void accept (void );
50
52
public:
51
53
MIDI_ (void );
52
54
53
55
int8_t begin ();
54
56
55
57
uint32_t available (void );
56
- void accept (void );
57
58
midiEventPacket_t read (void );
58
59
void flush (void );
59
60
void sendMIDI (midiEventPacket_t event);
You can’t perform that action at this time.
0 commit comments