Skip to content

Commit 415591a

Browse files
authored
Merge pull request #148 from lathoub/small-buffer
Small buffer
2 parents 8044e7a + 2c0fd84 commit 415591a

File tree

22 files changed

+451
-419
lines changed

22 files changed

+451
-419
lines changed
Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#include <Ethernet.h>
22

33
#define SerialMon Serial
4-
#include <AppleMIDI_Debug.h>
5-
64
#define ONE_PARTICIPANT
75
#define USE_EXT_CALLBACKS
86
#include <AppleMIDI.h>
@@ -25,70 +23,70 @@ void OnAppleMidiException(const APPLEMIDI_NAMESPACE::ssrc_t&, const APPLEMIDI_NA
2523
// -----------------------------------------------------------------------------
2624
void setup()
2725
{
28-
DBG_SETUP(115200);
29-
DBG("Das Booting");
26+
AM_DBG_SETUP(115200);
27+
AM_DBG(F("Das Booting"));
3028

3129
if (Ethernet.begin(mac) == 0) {
32-
DBG(F("Failed DHCP, check network cable & reboot"));
30+
AM_DBG(F("Failed DHCP, check network cable & reboot"));
3331
for (;;);
3432
}
3533

36-
DBG(F("OK, now make sure you an rtpMIDI session that is Enabled"));
37-
DBG(F("Add device named Arduino with Host"), Ethernet.localIP(), "Port", AppleMIDI.getPort(), "(Name", AppleMIDI.getName(), ")");
38-
DBG(F("Select and then press the Connect button"));
39-
DBG(F("Then open a MIDI listener and monitor incoming notes"));
34+
AM_DBG(F("OK, now make sure you an rtpMIDI session that is Enabled"));
35+
AM_DBG(F("Add device named Arduino with Host"), Ethernet.localIP(), "Port", AppleMIDI.getPort(), "(Name", AppleMIDI.getName(), ")");
36+
AM_DBG(F("Select and then press the Connect button"));
37+
AM_DBG(F("Then open a MIDI listener and monitor incoming notes"));
4038

4139
MIDI.begin(MIDI_CHANNEL_OMNI);
4240

4341
// Normal callbacks - always available
4442
// Stay informed on connection status
4543
AppleMIDI.setHandleConnected([](const APPLEMIDI_NAMESPACE::ssrc_t & ssrc, const char* name) {
4644
isConnected++;
47-
DBG(F("Connected to session"), ssrc, name);
45+
AM_DBG(F("Connected to session"), ssrc, name);
4846
});
4947
AppleMIDI.setHandleDisconnected([](const APPLEMIDI_NAMESPACE::ssrc_t & ssrc) {
5048
isConnected--;
51-
DBG(F("Disconnected"), ssrc);
49+
AM_DBG(F("Disconnected"), ssrc);
5250
});
5351
/*
5452
// Extended callback, only available when defining USE_EXT_CALLBACKS
5553
AppleMIDI.setHandleSentRtp([](const APPLEMIDI_NAMESPACE::Rtp_t & rtp) {
56-
// DBG(F("an rtpMessage has been sent with sequenceNr"), rtp.sequenceNr);
54+
// AM_DBG(F("an rtpMessage has been sent with sequenceNr"), rtp.sequenceNr);
5755
});
5856
AppleMIDI.setHandleSentRtpMidi([](const APPLEMIDI_NAMESPACE::RtpMIDI_t& rtpMidi) {
59-
// DBG(F("an rtpMidiMessage has been sent"), rtpMidi.flags);
57+
// AM_DBG(F("an rtpMidiMessage has been sent"), rtpMidi.flags);
6058
});
6159
AppleMIDI.setHandleReceivedRtp([](const APPLEMIDI_NAMESPACE::ssrc_t & ssrc, const APPLEMIDI_NAMESPACE::Rtp_t & rtp, const int32_t& latency) {
62-
// DBG(F("setHandleReceivedRtp"), ssrc, rtp.sequenceNr , "with", latency, "ms latency");
60+
// AM_DBG(F("setHandleReceivedRtp"), ssrc, rtp.sequenceNr , "with", latency, "ms latency");
6361
});
6462
AppleMIDI.setHandleStartReceivedMidi([](const APPLEMIDI_NAMESPACE::ssrc_t& ssrc) {
65-
// DBG(F("setHandleStartReceivedMidi from SSRC"), ssrc);
63+
// AM_DBG(F("setHandleStartReceivedMidi from SSRC"), ssrc);
6664
});
6765
AppleMIDI.setHandleReceivedMidi([](const APPLEMIDI_NAMESPACE::ssrc_t& ssrc, byte value) {
68-
// DBG(F("setHandleReceivedMidi from SSRC"), ssrc, ", value:", value);
66+
// AM_DBG(F("setHandleReceivedMidi from SSRC"), ssrc, ", value:", value);
6967
});
7068
AppleMIDI.setHandleEndReceivedMidi([](const APPLEMIDI_NAMESPACE::ssrc_t& ssrc) {
71-
// DBG(F("setHandleEndReceivedMidi from SSRC"), ssrc);
69+
// AM_DBG(F("setHandleEndReceivedMidi from SSRC"), ssrc);
7270
});
7371
AppleMIDI.setHandleException(OnAppleMidiException);
7472
7573
MIDI.setHandleControlChange([](Channel channel, byte v1, byte v2) {
76-
DBG(F("ControlChange"), channel, v1, v2);
74+
AM_DBG(F("ControlChange"), channel, v1, v2);
7775
});
7876
MIDI.setHandleProgramChange([](Channel channel, byte v1) {
79-
DBG(F("ProgramChange"), channel, v1);
77+
AM_DBG(F("ProgramChange"), channel, v1);
8078
});
8179
MIDI.setHandlePitchBend([](Channel channel, int v1) {
82-
DBG(F("PitchBend"), channel, v1);
80+
AM_DBG(F("PitchBend"), channel, v1);
8381
});
8482
MIDI.setHandleNoteOn([](byte channel, byte note, byte velocity) {
85-
DBG(F("NoteOn"), channel, note, velocity);
83+
AM_DBG(F("NoteOn"), channel, note, velocity);
8684
});
8785
MIDI.setHandleNoteOff([](byte channel, byte note, byte velocity) {
88-
DBG(F("NoteOff"), channel, note, velocity);
86+
AM_DBG(F("NoteOff"), channel, note, velocity);
8987
});
9088
*/
91-
DBG(F("Sending MIDI messages every second"));
89+
AM_DBG(F("Sending MIDI messages every second"));
9290
}
9391

9492
// -----------------------------------------------------------------------------
@@ -109,7 +107,7 @@ void loop()
109107
byte velocity = random(55, 100);
110108
byte channel = 1;
111109

112-
// DBG(F("\nsendNoteOn"), note, velocity, channel);
110+
// AM_DBG(F("\nsendNoteOn"), note, velocity, channel);
113111
MIDI.sendNoteOn(note, velocity, channel);
114112
//MIDI.sendNoteOff(note, velocity, channel);
115113
}
@@ -122,43 +120,43 @@ void OnAppleMidiException(const APPLEMIDI_NAMESPACE::ssrc_t& ssrc, const APPLEMI
122120
switch (e)
123121
{
124122
case APPLEMIDI_NAMESPACE::Exception::BufferFullException:
125-
DBG(F("*** BufferFullException"));
123+
AM_DBG(F("*** BufferFullException"));
126124
break;
127125
case APPLEMIDI_NAMESPACE::Exception::ParseException:
128-
DBG(F("*** ParseException"));
126+
AM_DBG(F("*** ParseException"));
129127
break;
130128
case APPLEMIDI_NAMESPACE::Exception::TooManyParticipantsException:
131-
DBG(F("*** TooManyParticipantsException"));
129+
AM_DBG(F("*** TooManyParticipantsException"));
132130
break;
133131
case APPLEMIDI_NAMESPACE::Exception::UnexpectedInviteException:
134-
DBG(F("*** UnexpectedInviteException"));
132+
AM_DBG(F("*** UnexpectedInviteException"));
135133
break;
136134
case APPLEMIDI_NAMESPACE::Exception::ParticipantNotFoundException:
137-
DBG(F("*** ParticipantNotFoundException"), value);
135+
AM_DBG(F("*** ParticipantNotFoundException"), value);
138136
break;
139137
case APPLEMIDI_NAMESPACE::Exception::ComputerNotInDirectory:
140-
DBG(F("*** ComputerNotInDirectory"), value);
138+
AM_DBG(F("*** ComputerNotInDirectory"), value);
141139
break;
142140
case APPLEMIDI_NAMESPACE::Exception::NotAcceptingAnyone:
143-
DBG(F("*** NotAcceptingAnyone"), value);
141+
AM_DBG(F("*** NotAcceptingAnyone"), value);
144142
break;
145143
case APPLEMIDI_NAMESPACE::Exception::ListenerTimeOutException:
146-
DBG(F("*** ListenerTimeOutException"));
144+
AM_DBG(F("*** ListenerTimeOutException"));
147145
break;
148146
case APPLEMIDI_NAMESPACE::Exception::MaxAttemptsException:
149-
DBG(F("*** MaxAttemptsException"));
147+
AM_DBG(F("*** MaxAttemptsException"));
150148
break;
151149
case APPLEMIDI_NAMESPACE::Exception::NoResponseFromConnectionRequestException:
152-
DBG(F("***:yyy did't respond to the connection request. Check the address and port, and any firewall or router settings. (time)"));
150+
AM_DBG(F("***:yyy did't respond to the connection request. Check the address and port, and any firewall or router settings. (time)"));
153151
break;
154152
case APPLEMIDI_NAMESPACE::Exception::SendPacketsDropped:
155-
DBG(F("*** SendPacketsDropped"), value);
153+
AM_DBG(F("*** SendPacketsDropped"), value);
156154
break;
157155
case APPLEMIDI_NAMESPACE::Exception::ReceivedPacketsDropped:
158-
DBG(F("*** ReceivedPacketsDropped"), value);
156+
AM_DBG(F("*** ReceivedPacketsDropped"), value);
159157
break;
160158
case APPLEMIDI_NAMESPACE::Exception::UdpBeginPacketFailed:
161-
DBG(F("*** UdpBeginPacketFailed"), value);
159+
AM_DBG(F("*** UdpBeginPacketFailed"), value);
162160
break;
163161
}
164162
}

examples/AVR_Directory/AVR_Directory.ino

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#include <Ethernet.h>
22

33
#define SerialMon Serial
4-
#include <AppleMIDI_Debug.h>
5-
64
#define USE_DIRECTORY
75
#include <AppleMIDI.h>
86

@@ -22,11 +20,11 @@ APPLEMIDI_CREATE_DEFAULTSESSION_INSTANCE();
2220
// -----------------------------------------------------------------------------
2321
void setup()
2422
{
25-
DBG_SETUP(115200);
26-
DBG("Booting");
23+
AM_DBG_SETUP(115200);
24+
AM_DBG(F("Booting"));
2725

2826
if (Ethernet.begin(mac) == 0) {
29-
DBG(F("Failed DHCP, check network cable & reboot"));
27+
AM_DBG(F("Failed DHCP, check network cable & reboot"));
3028
for (;;);
3129
}
3230

@@ -36,31 +34,31 @@ void setup()
3634
AppleMIDI.whoCanConnectToMe = APPLEMIDI_NAMESPACE::OnlyComputersInMyDirectory;
3735
// AppleMIDI.whoCanConnectToMe = APPLEMIDI_NAMESPACE::Anyone;
3836

39-
DBG(F("OK, now make sure you an rtpMIDI session that is Enabled"));
40-
DBG(F("Add device named Arduino with Host"), Ethernet.localIP(), "Port", AppleMIDI.getPort(), "(Name", AppleMIDI.getName(), ")");
41-
DBG(F("Select and then press the Connect button"));
42-
DBG(F("Then open a MIDI listener and monitor incoming notes"));
37+
AM_DBG(F("OK, now make sure you an rtpMIDI session that is Enabled"));
38+
AM_DBG(F("Add device named Arduino with Host"), Ethernet.localIP(), "Port", AppleMIDI.getPort(), "(Name", AppleMIDI.getName(), ")");
39+
AM_DBG(F("Select and then press the Connect button"));
40+
AM_DBG(F("Then open a MIDI listener and monitor incoming notes"));
4341

4442
MIDI.begin();
4543

4644
// Stay informed on connection status
4745
AppleMIDI.setHandleConnected([](const APPLEMIDI_NAMESPACE::ssrc_t & ssrc, const char* name) {
4846
isConnected++;
49-
DBG(F("Connected to session"), ssrc, name);
47+
AM_DBG(F("Connected to session"), ssrc, name);
5048
});
5149
AppleMIDI.setHandleDisconnected([](const APPLEMIDI_NAMESPACE::ssrc_t & ssrc) {
5250
isConnected--;
53-
DBG(F("Disconnected"), ssrc);
51+
AM_DBG(F("Disconnected"), ssrc);
5452
});
5553

5654
MIDI.setHandleNoteOn([](byte channel, byte note, byte velocity) {
57-
DBG(F("NoteOn"), note);
55+
AM_DBG(F("NoteOn"), note);
5856
});
5957
MIDI.setHandleNoteOff([](byte channel, byte note, byte velocity) {
60-
DBG(F("NoteOff"), note);
58+
AM_DBG(F("NoteOff"), note);
6159
});
6260

63-
DBG(F("Sending MIDI messages every second"));
61+
AM_DBG(F("Sending MIDI messages every second"));
6462
}
6563

6664
// -----------------------------------------------------------------------------

examples/AVR_E3_NoteOnOffEverySec/AVR_E3_NoteOnOffEverySec.ino

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#include <Ethernet3.h> // from https://github.com/sstaub/Ethernet3
22

33
#define SerialMon Serial
4-
#include <AppleMIDI_Debug.h>
5-
64
#include <AppleMIDI.h>
75

86
// Enter a MAC address for your controller below.
@@ -21,39 +19,39 @@ APPLEMIDI_CREATE_DEFAULTSESSION_INSTANCE();
2119
// -----------------------------------------------------------------------------
2220
void setup()
2321
{
24-
DBG_SETUP(115200);
25-
DBG("Booting");
22+
AM_DBG_SETUP(115200);
23+
AM_DBG(F("Booting"));
2624

2725
if (Ethernet.begin(mac) == 0) {
28-
DBG(F("Failed DHCP, check network cable & reboot"));
26+
AM_DBG(F("Failed DHCP, check network cable & reboot"));
2927
for (;;);
3028
}
3129

32-
DBG(F("OK, now make sure you an rtpMIDI session that is Enabled"));
33-
DBG(F("Add device named Arduino with Host"), Ethernet.localIP(), "Port", AppleMIDI.getPort(), "(Name", AppleMIDI.getName(), ")");
34-
DBG(F("Select and then press the Connect button"));
35-
DBG(F("Then open a MIDI listener and monitor incoming notes"));
30+
AM_DBG(F("OK, now make sure you an rtpMIDI session that is Enabled"));
31+
AM_DBG(F("Add device named Arduino with Host"), Ethernet.localIP(), "Port", AppleMIDI.getPort(), "(Name", AppleMIDI.getName(), ")");
32+
AM_DBG(F("Select and then press the Connect button"));
33+
AM_DBG(F("Then open a MIDI listener and monitor incoming notes"));
3634

3735
MIDI.begin();
3836

3937
// Stay informed on connection status
4038
AppleMIDI.setHandleConnected([](const APPLEMIDI_NAMESPACE::ssrc_t & ssrc, const char* name) {
4139
isConnected++;
42-
DBG(F("Connected to session"), ssrc, name);
40+
AM_DBG(F("Connected to session"), ssrc, name);
4341
});
4442
AppleMIDI.setHandleDisconnected([](const APPLEMIDI_NAMESPACE::ssrc_t & ssrc) {
4543
isConnected--;
46-
DBG(F("Disconnected"), ssrc);
44+
AM_DBG(F("Disconnected"), ssrc);
4745
});
4846

4947
MIDI.setHandleNoteOn([](byte channel, byte note, byte velocity) {
50-
DBG(F("NoteOn"), note);
48+
AM_DBG(F("NoteOn"), note);
5149
});
5250
MIDI.setHandleNoteOff([](byte channel, byte note, byte velocity) {
53-
DBG(F("NoteOff"), note);
51+
AM_DBG(F("NoteOff"), note);
5452
});
5553

56-
DBG(F("Sending MIDI messages every second"));
54+
AM_DBG(F("Sending MIDI messages every second"));
5755
}
5856

5957
// -----------------------------------------------------------------------------

examples/AVR_Initiator/AVR_Initiator.ino

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#include <Ethernet.h>
22

33
#define SerialMon Serial
4-
#include <AppleMIDI_Debug.h>
5-
64
#define APPLEMIDI_INITIATOR
75
#include <AppleMIDI.h>
86

@@ -22,43 +20,43 @@ APPLEMIDI_CREATE_DEFAULTSESSION_INSTANCE();
2220
// -----------------------------------------------------------------------------
2321
void setup()
2422
{
25-
DBG_SETUP(115200);
26-
DBG("Booting");
23+
AM_DBG_SETUP(115200);
24+
AM_DBG(F("Booting"));
2725

2826
if (Ethernet.begin(mac) == 0) {
29-
DBG(F("Failed DHCP, check network cable & reboot"));
27+
AM_DBG(F("Failed DHCP, check network cable & reboot"));
3028
for (;;);
3129
}
3230

33-
DBG(F("OK, now make sure you an rtpMIDI session that is Enabled"));
31+
AM_DBG(F("OK, now make sure you an rtpMIDI session that is Enabled"));
3432

3533
MIDI.begin();
3634

3735
AppleMIDI.setHandleConnected([](const APPLEMIDI_NAMESPACE::ssrc_t & ssrc, const char* name) {
3836
isConnected++;
39-
DBG(F("Connected to session"), ssrc, name);
37+
AM_DBG(F("Connected to session"), ssrc, name);
4038
});
4139
AppleMIDI.setHandleDisconnected([](const APPLEMIDI_NAMESPACE::ssrc_t & ssrc) {
4240
isConnected--;
43-
DBG(F("Disconnected"), ssrc);
41+
AM_DBG(F("Disconnected"), ssrc);
4442
});
4543

4644
MIDI.setHandleNoteOn([](byte channel, byte note, byte velocity) {
47-
DBG(F("NoteOn"), note);
45+
AM_DBG(F("NoteOn"), note);
4846
});
4947
MIDI.setHandleNoteOff([](byte channel, byte note, byte velocity) {
50-
DBG(F("NoteOff"), note);
48+
AM_DBG(F("NoteOff"), note);
5149
});
5250

5351
// Initiate the session
5452
IPAddress remote(192, 168, 1, 65);
5553
AppleMIDI.sendInvite(remote, DEFAULT_CONTROL_PORT); // port is 5004 by default
5654

57-
DBG(F("Connecting to "), remote, "Port", DEFAULT_CONTROL_PORT, "(Name", AppleMIDI.getName(), ")");
58-
DBG(F("Watch as this session is added to the Participants list"));
59-
DBG(F("Then open a MIDI listener and monitor incoming notes"));
55+
AM_DBG(F("Connecting to "), remote, "Port", DEFAULT_CONTROL_PORT, "(Name", AppleMIDI.getName(), ")");
56+
AM_DBG(F("Watch as this session is added to the Participants list"));
57+
AM_DBG(F("Then open a MIDI listener and monitor incoming notes"));
6058

61-
DBG(F("Sending a random NoteOn/Off every second"));
59+
AM_DBG(F("Sending a random NoteOn/Off every second"));
6260
}
6361

6462
// -----------------------------------------------------------------------------

0 commit comments

Comments
 (0)