2626#include " midi_Settings.h"
2727#include " midi_Defs.h"
2828
29- #ifdef FSE_AVR
30- #include < ak47.h>
31- #endif
32-
3329// -----------------------------------------------------------------------------
3430
3531BEGIN_MIDI_NAMESPACE
@@ -40,21 +36,19 @@ the hardware interface, meaning you can use HardwareSerial, SoftwareSerial
4036or ak47's Uart classes. The only requirement is that the class implements
4137the begin, read, write and available methods.
4238 */
43- template <class SerialPort >
39+ template <class SerialPort , class Settings = DefaultSettings >
4440class MidiInterface
4541{
4642public:
47- MidiInterface (SerialPort& inSerial);
48- ~MidiInterface ();
43+ inline MidiInterface (SerialPort& inSerial);
44+ inline ~MidiInterface ();
4945
5046public:
5147 void begin (Channel inChannel = 1 );
5248
5349 // -------------------------------------------------------------------------
5450 // MIDI Output
5551
56- #if MIDI_BUILD_OUTPUT
57-
5852public:
5953 inline void sendNoteOn (DataByte inNoteNumber,
6054 DataByte inVelocity,
@@ -100,17 +94,9 @@ class MidiInterface
10094 DataByte inData2,
10195 Channel inChannel);
10296
103- private:
104- inline StatusByte getStatus (MidiType inType,
105- Channel inChannel) const ;
106-
107- #endif // MIDI_BUILD_OUTPUT
108-
10997 // -------------------------------------------------------------------------
11098 // MIDI Input
11199
112- #if MIDI_BUILD_INPUT
113-
114100public:
115101 inline bool read ();
116102 inline bool read (Channel inChannel);
@@ -133,25 +119,10 @@ class MidiInterface
133119 static inline Channel getChannelFromStatusByte (byte inStatus);
134120 static inline bool isChannelMessage (MidiType inType);
135121
136- private:
137- bool parse ();
138- inline void handleNullVelocityNoteOnAsNoteOff ();
139- inline bool inputFilter (Channel inChannel);
140- inline void resetInput ();
141-
142- private:
143- StatusByte mRunningStatus_RX ;
144- Channel mInputChannel ;
145- byte mPendingMessage [3 ];
146- unsigned mPendingMessageExpectedLenght ;
147- unsigned mPendingMessageIndex ;
148- Message mMessage ;
149122
150123 // -------------------------------------------------------------------------
151124 // Input Callbacks
152125
153- #if MIDI_USE_CALLBACKS
154-
155126public:
156127 inline void setHandleNoteOff (void (*fptr)(byte channel, byte note, byte velocity));
157128 inline void setHandleNoteOn (void (*fptr)(byte channel, byte note, byte velocity));
@@ -196,14 +167,9 @@ class MidiInterface
196167 void (*mActiveSensingCallback )(void );
197168 void (*mSystemResetCallback )(void );
198169
199- #endif // MIDI_USE_CALLBACKS
200- #endif // MIDI_BUILD_INPUT
201-
202170 // -------------------------------------------------------------------------
203171 // MIDI Soft Thru
204172
205- #if MIDI_BUILD_THRU
206-
207173public:
208174 inline MidiFilterMode getFilterMode () const ;
209175 inline bool getThruState () const ;
@@ -216,11 +182,28 @@ class MidiInterface
216182private:
217183 void thruFilter (byte inChannel);
218184
185+ private:
186+ bool parse ();
187+ inline void handleNullVelocityNoteOnAsNoteOff ();
188+ inline bool inputFilter (Channel inChannel);
189+ inline void resetInput ();
190+
219191private:
220192 bool mThruActivated : 1 ;
221193 MidiFilterMode mThruFilterMode : 7 ;
222194
223- #endif // MIDI_BUILD_THRU
195+ private:
196+ StatusByte mRunningStatus_RX ;
197+ Channel mInputChannel ;
198+ byte mPendingMessage [3 ];
199+ unsigned mPendingMessageExpectedLenght ;
200+ unsigned mPendingMessageIndex ;
201+ Message mMessage ;
202+
203+ private:
204+ inline StatusByte getStatus (MidiType inType,
205+ Channel inChannel) const ;
206+
224207
225208
226209#if MIDI_USE_RUNNING_STATUS
@@ -241,10 +224,4 @@ END_MIDI_NAMESPACE
241224
242225// -----------------------------------------------------------------------------
243226
244- #if MIDI_AUTO_INSTANCIATE && defined(ARDUINO)
245- extern MIDI_NAMESPACE::MidiInterface<MIDI_DEFAULT_SERIAL_CLASS> MIDI;
246- #endif
247-
248- // -----------------------------------------------------------------------------
249-
250227#include " MIDI.hpp"
0 commit comments