Skip to content

Commit 1ff874c

Browse files
author
Francois Best
committed
Merge branch 'settings' into dev
2 parents db00213 + 9facc3e commit 1ff874c

File tree

5 files changed

+257
-299
lines changed

5 files changed

+257
-299
lines changed

src/MIDI.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,6 @@
2525

2626
// -----------------------------------------------------------------------------
2727

28-
#if !(MIDI_BUILD_INPUT) && !(MIDI_BUILD_OUTPUT)
29-
# error To use MIDI, you need to enable at least input or output.
30-
#endif
31-
32-
#if MIDI_BUILD_THRU && !(MIDI_BUILD_OUTPUT)
33-
# error For thru to work, you need to enable output.
34-
#endif
35-
#if MIDI_BUILD_THRU && !(MIDI_BUILD_INPUT)
36-
# error For thru to work, you need to enable input.
37-
#endif
38-
39-
// -----------------------------------------------------------------------------
40-
41-
#if MIDI_AUTO_INSTANCIATE && defined(ARDUINO)
42-
MIDI_CREATE_INSTANCE(MIDI_DEFAULT_SERIAL_CLASS,
43-
MIDI_DEFAULT_SERIAL_PORT,
44-
MIDI);
45-
#endif
46-
47-
// -----------------------------------------------------------------------------
48-
4928
BEGIN_MIDI_NAMESPACE
5029

5130
/*! \brief Encode System Exclusive messages.

src/MIDI.h

Lines changed: 21 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@
2626
#include "midi_Settings.h"
2727
#include "midi_Defs.h"
2828

29-
#ifdef FSE_AVR
30-
#include <ak47.h>
31-
#endif
32-
3329
// -----------------------------------------------------------------------------
3430

3531
BEGIN_MIDI_NAMESPACE
@@ -40,21 +36,19 @@ the hardware interface, meaning you can use HardwareSerial, SoftwareSerial
4036
or ak47's Uart classes. The only requirement is that the class implements
4137
the begin, read, write and available methods.
4238
*/
43-
template<class SerialPort>
39+
template<class SerialPort, class Settings = DefaultSettings>
4440
class MidiInterface
4541
{
4642
public:
47-
MidiInterface(SerialPort& inSerial);
48-
~MidiInterface();
43+
inline MidiInterface(SerialPort& inSerial);
44+
inline ~MidiInterface();
4945

5046
public:
5147
void begin(Channel inChannel = 1);
5248

5349
// -------------------------------------------------------------------------
5450
// MIDI Output
5551

56-
#if MIDI_BUILD_OUTPUT
57-
5852
public:
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-
114100
public:
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-
155126
public:
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-
207173
public:
208174
inline MidiFilterMode getFilterMode() const;
209175
inline bool getThruState() const;
@@ -216,11 +182,28 @@ class MidiInterface
216182
private:
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+
219191
private:
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

Comments
 (0)