-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from lathoub/v.3.0.0rc
V.3.0.0rc
- Loading branch information
Showing
30 changed files
with
1,080 additions
and
563 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
#include <Ethernet.h> | ||
|
||
#define USE_EXT_CALLBACKS | ||
#define SerialMon Serial | ||
#define APPLEMIDI_DEBUG SerialMon | ||
#include <AppleMIDI.h> | ||
|
||
// Enter a MAC address for your controller below. | ||
// Newer Ethernet shields have a MAC address printed on a sticker on the shield | ||
byte mac[] = { | ||
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED | ||
}; | ||
|
||
unsigned long t1 = millis(); | ||
int8_t isConnected = 0; | ||
|
||
APPLEMIDI_CREATE_DEFAULTSESSION_INSTANCE(); | ||
|
||
void OnAppleMidiException(const APPLEMIDI_NAMESPACE::ssrc_t&, const APPLEMIDI_NAMESPACE::Exception&, const int32_t); | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
void setup() | ||
{ | ||
DBG_SETUP(115200); | ||
DBG("Das Booting"); | ||
|
||
if (Ethernet.begin(mac) == 0) { | ||
DBG(F("Failed DHCP, check network cable & reboot")); | ||
for (;;); | ||
} | ||
|
||
DBG(F("OK, now make sure you an rtpMIDI session that is Enabled")); | ||
DBG(F("Add device named Arduino with Host"), Ethernet.localIP(), "Port", AppleMIDI.getPort(), "(Name", AppleMIDI.getName(), ")"); | ||
DBG(F("Select and then press the Connect button")); | ||
DBG(F("Then open a MIDI listener and monitor incoming notes")); | ||
|
||
MIDI.begin(); | ||
|
||
// Normal callbacks - always available | ||
// Stay informed on connection status | ||
AppleMIDI.setHandleConnected([](const APPLEMIDI_NAMESPACE::ssrc_t & ssrc, const char* name) { | ||
isConnected++; | ||
DBG(F("Connected to session"), ssrc, name); | ||
}); | ||
AppleMIDI.setHandleDisconnected([](const APPLEMIDI_NAMESPACE::ssrc_t & ssrc) { | ||
isConnected--; | ||
DBG(F("Disconnected"), ssrc); | ||
}); | ||
|
||
// Extended callback, only available when defining USE_EXT_CALLBACKS | ||
AppleMIDI.setHandleSentRtp([](const APPLEMIDI_NAMESPACE::Rtp_t & rtp) { | ||
DBG(F("an rtpMessage has been sent with sequenceNr"), rtp.sequenceNr); | ||
}); | ||
AppleMIDI.setHandleSentRtpMidi([](const APPLEMIDI_NAMESPACE::RtpMIDI_t& rtpMidi) { | ||
DBG(F("an rtpMidiMessage has been sent"), rtpMidi.flags); | ||
}); | ||
AppleMIDI.setHandleReceivedRtp([](const APPLEMIDI_NAMESPACE::ssrc_t & ssrc, const APPLEMIDI_NAMESPACE::Rtp_t & rtp, const int32_t& latency) { | ||
DBG(F("setHandleReceivedRtp"), ssrc, rtp.sequenceNr , "with", latency, "ms latency"); | ||
}); | ||
AppleMIDI.setHandleStartReceivedMidi([](const APPLEMIDI_NAMESPACE::ssrc_t& ssrc) { | ||
DBG(F("setHandleStartReceivedMidi from SSRC"), ssrc); | ||
}); | ||
AppleMIDI.setHandleReceivedMidi([](const APPLEMIDI_NAMESPACE::ssrc_t& ssrc, byte value) { | ||
DBG(F("setHandleReceivedMidi from SSRC"), ssrc, ", value:", value); | ||
}); | ||
AppleMIDI.setHandleEndReceivedMidi([](const APPLEMIDI_NAMESPACE::ssrc_t& ssrc) { | ||
DBG(F("setHandleEndReceivedMidi from SSRC"), ssrc); | ||
}); | ||
AppleMIDI.setHandleException(OnAppleMidiException); | ||
|
||
MIDI.setHandleNoteOn([](byte channel, byte note, byte velocity) { | ||
DBG(F("NoteOn"), note); | ||
}); | ||
MIDI.setHandleNoteOff([](byte channel, byte note, byte velocity) { | ||
DBG(F("NoteOff"), note); | ||
}); | ||
|
||
DBG(F("Sending MIDI messages every second")); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
void loop() | ||
{ | ||
// Listen to incoming notes | ||
MIDI.read(); | ||
|
||
// send a note every second | ||
// (dont cáll delay(1000) as it will stall the pipeline) | ||
if ((isConnected > 0) && (millis() - t1) > 1000) | ||
{ | ||
t1 = millis(); | ||
|
||
byte note = random(1, 127); | ||
byte velocity = 55; | ||
byte channel = 1; | ||
|
||
DBG(F("\nsendNoteOn"), note, velocity, channel); | ||
MIDI.sendNoteOn(note, velocity, channel); | ||
//MIDI.sendNoteOff(note, velocity, channel); | ||
|
||
} | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
void OnAppleMidiException(const APPLEMIDI_NAMESPACE::ssrc_t& ssrc, const APPLEMIDI_NAMESPACE::Exception& e, const int32_t value ) { | ||
switch (e) | ||
{ | ||
case APPLEMIDI_NAMESPACE::Exception::BufferFullException: | ||
DBG(F("*** BufferFullException")); | ||
break; | ||
case APPLEMIDI_NAMESPACE::Exception::ParseException: | ||
DBG(F("*** ParseException")); | ||
break; | ||
case APPLEMIDI_NAMESPACE::Exception::TooManyParticipantsException: | ||
DBG(F("*** TooManyParticipantsException")); | ||
break; | ||
case APPLEMIDI_NAMESPACE::Exception::UnexpectedInviteException: | ||
DBG(F("*** UnexpectedInviteException")); | ||
break; | ||
case APPLEMIDI_NAMESPACE::Exception::ParticipantNotFoundException: | ||
DBG(F("*** ParticipantNotFoundException"), value); | ||
break; | ||
case APPLEMIDI_NAMESPACE::Exception::ComputerNotInDirectory: | ||
DBG(F("*** ComputerNotInDirectory"), value); | ||
break; | ||
case APPLEMIDI_NAMESPACE::Exception::NotAcceptingAnyone: | ||
DBG(F("*** NotAcceptingAnyone"), value); | ||
break; | ||
case APPLEMIDI_NAMESPACE::Exception::ListenerTimeOutException: | ||
DBG(F("*** ListenerTimeOutException")); | ||
break; | ||
case APPLEMIDI_NAMESPACE::Exception::MaxAttemptsException: | ||
DBG(F("*** MaxAttemptsException")); | ||
break; | ||
case APPLEMIDI_NAMESPACE::Exception::NoResponseFromConnectionRequestException: | ||
DBG(F("***:yyy did't respond to the connection request. Check the address and port, and any firewall or router settings. (time)")); | ||
break; | ||
case APPLEMIDI_NAMESPACE::Exception::SendPacketsDropped: | ||
DBG(F("*** SendPacketsDropped"), value); | ||
break; | ||
case APPLEMIDI_NAMESPACE::Exception::ReceivedPacketsDropped: | ||
DBG(F("*** ReceivedPacketsDropped"), value); | ||
break; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#include <Ethernet.h> | ||
|
||
#define USE_DIRECTORY | ||
#define SerialMon Serial | ||
#define APPLEMIDI_DEBUG SerialMon | ||
#include <AppleMIDI.h> | ||
|
||
// Enter a MAC address for your controller below. | ||
// Newer Ethernet shields have a MAC address printed on a sticker on the shield | ||
byte mac[] = { | ||
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED | ||
}; | ||
|
||
unsigned long t1 = millis(); | ||
int8_t isConnected = 0; | ||
|
||
APPLEMIDI_CREATE_DEFAULTSESSION_INSTANCE(); | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
void setup() | ||
{ | ||
DBG_SETUP(115200); | ||
DBG("Booting"); | ||
|
||
if (Ethernet.begin(mac) == 0) { | ||
DBG(F("Failed DHCP, check network cable & reboot")); | ||
for (;;); | ||
} | ||
|
||
AppleMIDI.directory.push_back(IPAddress(192, 168, 1, 63)); | ||
AppleMIDI.directory.push_back(IPAddress(192, 168, 1, 66)); | ||
// AppleMIDI.whoCanConnectToMe = APPLEMIDI_NAMESPACE::None; | ||
AppleMIDI.whoCanConnectToMe = APPLEMIDI_NAMESPACE::OnlyComputersInMyDirectory; | ||
// AppleMIDI.whoCanConnectToMe = APPLEMIDI_NAMESPACE::Anyone; | ||
|
||
DBG(F("OK, now make sure you an rtpMIDI session that is Enabled")); | ||
DBG(F("Add device named Arduino with Host"), Ethernet.localIP(), "Port", AppleMIDI.getPort(), "(Name", AppleMIDI.getName(), ")"); | ||
DBG(F("Select and then press the Connect button")); | ||
DBG(F("Then open a MIDI listener and monitor incoming notes")); | ||
|
||
MIDI.begin(); | ||
|
||
// Stay informed on connection status | ||
AppleMIDI.setHandleConnected([](const APPLEMIDI_NAMESPACE::ssrc_t & ssrc, const char* name) { | ||
isConnected++; | ||
DBG(F("Connected to session"), ssrc, name); | ||
}); | ||
AppleMIDI.setHandleDisconnected([](const APPLEMIDI_NAMESPACE::ssrc_t & ssrc) { | ||
isConnected--; | ||
DBG(F("Disconnected"), ssrc); | ||
}); | ||
|
||
MIDI.setHandleNoteOn([](byte channel, byte note, byte velocity) { | ||
DBG(F("NoteOn"), note); | ||
}); | ||
MIDI.setHandleNoteOff([](byte channel, byte note, byte velocity) { | ||
DBG(F("NoteOff"), note); | ||
}); | ||
|
||
DBG(F("Sending MIDI messages every second")); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
void loop() | ||
{ | ||
// Listen to incoming notes | ||
MIDI.read(); | ||
|
||
// send a note every second | ||
// (dont cáll delay(1000) as it will stall the pipeline) | ||
if ((isConnected > 0) && (millis() - t1) > 1000) | ||
{ | ||
t1 = millis(); | ||
|
||
byte note = random(1, 127); | ||
byte velocity = 55; | ||
byte channel = 1; | ||
|
||
MIDI.sendNoteOn(note, velocity, channel); | ||
// MIDI.sendNoteOff(note, velocity, channel); | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
examples/AVR_E3_NoteOnOffEverySec/AVR_E3_NoteOnOffEverySec.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#include <Ethernet3.h> // from https://github.com/sstaub/Ethernet3 | ||
|
||
#define SerialMon Serial | ||
#define APPLEMIDI_DEBUG SerialMon | ||
#include <AppleMIDI.h> | ||
|
||
// Enter a MAC address for your controller below. | ||
// Newer Ethernet shields have a MAC address printed on a sticker on the shield | ||
byte mac[] = { | ||
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED | ||
}; | ||
|
||
unsigned long t1 = millis(); | ||
int8_t isConnected = 0; | ||
|
||
APPLEMIDI_CREATE_DEFAULTSESSION_INSTANCE(); | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
void setup() | ||
{ | ||
DBG_SETUP(115200); | ||
DBG("Booting"); | ||
|
||
if (Ethernet.begin(mac) == 0) { | ||
DBG(F("Failed DHCP, check network cable & reboot")); | ||
for (;;); | ||
} | ||
|
||
DBG(F("OK, now make sure you an rtpMIDI session that is Enabled")); | ||
DBG(F("Add device named Arduino with Host"), Ethernet.localIP(), "Port", AppleMIDI.getPort(), "(Name", AppleMIDI.getName(), ")"); | ||
DBG(F("Select and then press the Connect button")); | ||
DBG(F("Then open a MIDI listener and monitor incoming notes")); | ||
|
||
MIDI.begin(); | ||
|
||
// Stay informed on connection status | ||
AppleMIDI.setHandleConnected([](const APPLEMIDI_NAMESPACE::ssrc_t & ssrc, const char* name) { | ||
isConnected++; | ||
DBG(F("Connected to session"), ssrc, name); | ||
}); | ||
AppleMIDI.setHandleDisconnected([](const APPLEMIDI_NAMESPACE::ssrc_t & ssrc) { | ||
isConnected--; | ||
DBG(F("Disconnected"), ssrc); | ||
}); | ||
|
||
MIDI.setHandleNoteOn([](byte channel, byte note, byte velocity) { | ||
DBG(F("NoteOn"), note); | ||
}); | ||
MIDI.setHandleNoteOff([](byte channel, byte note, byte velocity) { | ||
DBG(F("NoteOff"), note); | ||
}); | ||
|
||
DBG(F("Sending MIDI messages every second")); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
void loop() | ||
{ | ||
// Listen to incoming notes | ||
MIDI.read(); | ||
|
||
// send a note every second | ||
// (dont cáll delay(1000) as it will stall the pipeline) | ||
if ((isConnected > 0) && (millis() - t1) > 1000) | ||
{ | ||
t1 = millis(); | ||
|
||
byte note = random(1, 127); | ||
byte velocity = 55; | ||
byte channel = 1; | ||
|
||
MIDI.sendNoteOn(note, velocity, channel); | ||
// MIDI.sendNoteOff(note, velocity, channel); | ||
} | ||
} |
Oops, something went wrong.