-
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.
removed reference to Ethernet.h and templated AppleMidi
removed reference to Ethernet.h and templated AppleMidi, so that other ethernet libraries can be used. Wireless (wifishield and Esp8266) is not tested. Add 2 UNTESTED examples
- Loading branch information
Showing
21 changed files
with
1,229 additions
and
917 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
131 changes: 131 additions & 0 deletions
131
examples/NoteOnOffEverySecEsp8266/NoteOnOffEverySecEso8266.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,131 @@ | ||
// Hardware: Mega 2560 R2 + Ethernet Shield | ||
|
||
// These need to be included when using standard Ethernet | ||
#include <ESP8266WiFi.h> | ||
#include <WiFiClient.h> | ||
#include <WiFiUdp.h> | ||
|
||
#include "AppleMidi.h" | ||
|
||
char ssid[] = "yourNetwork"; // your network SSID (name) | ||
char pass[] = "secretPassword"; // your network password (use for WPA, or use as key for WEP) | ||
|
||
unsigned long t0 = millis(); | ||
|
||
APPLEMIDI_CREATE_INSTANCE(WiFiUDP, AppleMIDI); // see definition in AppleMidi_Defs.h | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
void setup() | ||
{ | ||
// Serial communications and wait for port to open: | ||
Serial.begin(115200); | ||
while (!Serial) { | ||
; // wait for serial port to connect. Needed for Leonardo only | ||
} | ||
|
||
Serial.print("Getting IP address..."); | ||
|
||
|
||
WiFi.begin(ssid, password); | ||
|
||
while (WiFi.status() != WL_CONNECTED) { | ||
delay(500); | ||
Serial.print("."); | ||
} | ||
Serial.println(""); | ||
Serial.println("WiFi connected"); | ||
|
||
|
||
Serial.println(); | ||
Serial.print("IP address is "); | ||
Serial.println(WiFi.localIP()); | ||
|
||
Serial.println("OK, now make sure you an rtpMIDI session that is Enabled"); | ||
Serial.print("Add device named Arduino with Host/Port "); | ||
Serial.print(WiFi.localIP()); | ||
Serial.println(":5004"); | ||
Serial.println("Then press the Connect button"); | ||
Serial.println("Then open a MIDI listener (eg MIDI-OX) and monitor incoming notes"); | ||
|
||
// Create a session and wait for a remote host to connect to us | ||
AppleMIDI.begin("test"); | ||
|
||
AppleMIDI.OnConnected(OnAppleMidiConnected); | ||
AppleMIDI.OnDisconnected(OnAppleMidiDisconnected); | ||
|
||
AppleMIDI.OnReceiveNoteOn(OnAppleMidiNoteOn); | ||
AppleMIDI.OnReceiveNoteOff(OnAppleMidiNoteOff); | ||
|
||
Serial.println("Sending NoteOn/Off of note 45, every second"); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
void loop() | ||
{ | ||
// Listen to incoming notes | ||
AppleMIDI.run(); | ||
|
||
// send a note every second | ||
// (dont cáll delay(1000) as it will stall the pipeline) | ||
if ((millis() - t0) > 1000) | ||
{ | ||
t0 = millis(); | ||
// Serial.print("."); | ||
|
||
int note = 45; | ||
int velocity = 55; | ||
int channel = 1; | ||
|
||
AppleMIDI.noteOn(note, velocity, channel); | ||
AppleMIDI.noteOff(note, velocity, channel); | ||
} | ||
} | ||
|
||
// ==================================================================================== | ||
// Event handlers for incoming MIDI messages | ||
// ==================================================================================== | ||
|
||
// ----------------------------------------------------------------------------- | ||
// rtpMIDI session. Device connected | ||
// ----------------------------------------------------------------------------- | ||
void OnAppleMidiConnected(char* name) { | ||
// Serial.print("Connected to session "); | ||
// Serial.println(name); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
// rtpMIDI session. Device disconnected | ||
// ----------------------------------------------------------------------------- | ||
void OnAppleMidiDisconnected() { | ||
// Serial.println("Disconnected"); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
void OnAppleMidiNoteOn(byte channel, byte note, byte velocity) { | ||
Serial.print("Incoming NoteOn from channel:"); | ||
Serial.print(channel); | ||
Serial.print(" note:"); | ||
Serial.print(note); | ||
Serial.print(" velocity:"); | ||
Serial.print(velocity); | ||
Serial.println(); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
void OnAppleMidiNoteOff(byte channel, byte note, byte velocity) { | ||
Serial.print("Incoming NoteOff from channel:"); | ||
Serial.print(channel); | ||
Serial.print(" note:"); | ||
Serial.print(note); | ||
Serial.print(" velocity:"); | ||
Serial.print(velocity); | ||
Serial.println(); | ||
} |
146 changes: 146 additions & 0 deletions
146
examples/NoteOnOffEverySecWifi/NoteOnOffEverySecWifi.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,146 @@ | ||
// Hardware: Mega 2560 R2 + Ethernet Shield | ||
|
||
// These need to be included when using standard Ethernet | ||
#include <SPI.h> | ||
#include <WiFi.h> | ||
#include <WiFiUdp.h> | ||
|
||
#include "AppleMidi.h" | ||
|
||
int status = WL_IDLE_STATUS; | ||
char ssid[] = "yourNetwork"; // your network SSID (name) | ||
char pass[] = "secretPassword"; // your network password (use for WPA, or use as key for WEP) | ||
int keyIndex = 0; // your network key Index number (needed only for WEP) | ||
|
||
|
||
unsigned long t0 = millis(); | ||
|
||
APPLEMIDI_CREATE_INSTANCE(WiFiUDP, AppleMIDI); // see definition in AppleMidi_Defs.h | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
void setup() | ||
{ | ||
// Serial communications and wait for port to open: | ||
Serial.begin(115200); | ||
while (!Serial) { | ||
; // wait for serial port to connect. Needed for Leonardo only | ||
} | ||
|
||
Serial.print("Getting IP address..."); | ||
|
||
|
||
// check for the presence of the shield: | ||
if (WiFi.status() == WL_NO_SHIELD) { | ||
Serial.println("WiFi shield not present"); | ||
// don't continue: | ||
while (true); | ||
} | ||
|
||
String fv = WiFi.firmwareVersion(); | ||
if ( fv != "1.1.0" ) | ||
Serial.println("Please upgrade the firmware"); | ||
|
||
// attempt to connect to Wifi network: | ||
while ( status != WL_CONNECTED) { | ||
Serial.print("Attempting to connect to SSID: "); | ||
Serial.println(ssid); | ||
// Connect to WPA/WPA2 network. Change this line if using open or WEP network: | ||
status = WiFi.begin(ssid); | ||
|
||
// wait 10 seconds for connection: | ||
delay(10000); | ||
} | ||
|
||
Serial.println(); | ||
Serial.print("IP address is "); | ||
Serial.println(WiFi.localIP()); | ||
|
||
Serial.println("OK, now make sure you an rtpMIDI session that is Enabled"); | ||
Serial.print("Add device named Arduino with Host/Port "); | ||
Serial.print(WiFi.localIP()); | ||
Serial.println(":5004"); | ||
Serial.println("Then press the Connect button"); | ||
Serial.println("Then open a MIDI listener (eg MIDI-OX) and monitor incoming notes"); | ||
|
||
// Create a session and wait for a remote host to connect to us | ||
AppleMIDI.begin("test"); | ||
|
||
AppleMIDI.OnConnected(OnAppleMidiConnected); | ||
AppleMIDI.OnDisconnected(OnAppleMidiDisconnected); | ||
|
||
AppleMIDI.OnReceiveNoteOn(OnAppleMidiNoteOn); | ||
AppleMIDI.OnReceiveNoteOff(OnAppleMidiNoteOff); | ||
|
||
Serial.println("Sending NoteOn/Off of note 45, every second"); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
void loop() | ||
{ | ||
// Listen to incoming notes | ||
AppleMIDI.run(); | ||
|
||
// send a note every second | ||
// (dont cáll delay(1000) as it will stall the pipeline) | ||
if ((millis() - t0) > 1000) | ||
{ | ||
t0 = millis(); | ||
// Serial.print("."); | ||
|
||
int note = 45; | ||
int velocity = 55; | ||
int channel = 1; | ||
|
||
AppleMIDI.noteOn(note, velocity, channel); | ||
AppleMIDI.noteOff(note, velocity, channel); | ||
} | ||
} | ||
|
||
// ==================================================================================== | ||
// Event handlers for incoming MIDI messages | ||
// ==================================================================================== | ||
|
||
// ----------------------------------------------------------------------------- | ||
// rtpMIDI session. Device connected | ||
// ----------------------------------------------------------------------------- | ||
void OnAppleMidiConnected(char* name) { | ||
// Serial.print("Connected to session "); | ||
// Serial.println(name); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
// rtpMIDI session. Device disconnected | ||
// ----------------------------------------------------------------------------- | ||
void OnAppleMidiDisconnected() { | ||
// Serial.println("Disconnected"); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
void OnAppleMidiNoteOn(byte channel, byte note, byte velocity) { | ||
Serial.print("Incoming NoteOn from channel:"); | ||
Serial.print(channel); | ||
Serial.print(" note:"); | ||
Serial.print(note); | ||
Serial.print(" velocity:"); | ||
Serial.print(velocity); | ||
Serial.println(); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
// | ||
// ----------------------------------------------------------------------------- | ||
void OnAppleMidiNoteOff(byte channel, byte note, byte velocity) { | ||
Serial.print("Incoming NoteOff from channel:"); | ||
Serial.print(channel); | ||
Serial.print(" note:"); | ||
Serial.print(note); | ||
Serial.print(" velocity:"); | ||
Serial.print(velocity); | ||
Serial.println(); | ||
} |
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
Oops, something went wrong.