-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNetwork.ino
83 lines (67 loc) · 2.69 KB
/
Network.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
void networkInit() {
Serial.print(F("Getting IP address..."));
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(F("."));
}
Serial.println(F(""));
Serial.println(F("WiFi connected"));
Serial.println();
Serial.print(F("IP address is "));
Serial.println(WiFi.localIP());
Serial.println(F("OK, now make sure you an rtpMIDI session that is Enabled"));
Serial.print(F("Add device named Arduino with Host/Port "));
Serial.print(WiFi.localIP());
Serial.println(F(":5004"));
Serial.println(F("Then press the Connect button"));
Serial.println(F("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);
}
// ====================================================================================
// Event handlers for incoming MIDI messages
// ====================================================================================
// -----------------------------------------------------------------------------
// rtpMIDI session. Device connected
// -----------------------------------------------------------------------------
void OnAppleMidiConnected(uint32_t ssrc, char* name) {
isConnected = true;
Serial.print(F("Connected to session "));
Serial.println(name);
}
// -----------------------------------------------------------------------------
// rtpMIDI session. Device disconnected
// -----------------------------------------------------------------------------
void OnAppleMidiDisconnected(uint32_t ssrc) {
isConnected = false;
Serial.println(F("Disconnected"));
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void OnAppleMidiNoteOn(byte channel, byte note, byte velocity) {
Serial.print(F("Incoming NoteOn from channel:"));
Serial.print(channel);
Serial.print(F(" note:"));
Serial.print(note);
Serial.print(F(" velocity:"));
Serial.print(velocity);
Serial.println();
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void OnAppleMidiNoteOff(byte channel, byte note, byte velocity) {
Serial.print(F("Incoming NoteOff from channel:"));
Serial.print(channel);
Serial.print(F(" note:"));
Serial.print(note);
Serial.print(F(" velocity:"));
Serial.print(velocity);
Serial.println();
}