Upload song to piano - hugbug/conpianist GitHub Wiki
Upload song via WiFi
When app is connected to piano via WiFi all piano control is made via RTP-MIDI protocol. This protocol provides a transport for MIDI-messages. The upload of the song to piano however isn't performed via MIDI-messages and RTP-MIDI isn't used for that. Instead the song content is sent to piano via TCP to a separate port (port number 10504).
Example song 1
0000 01 00 00 06 00 00 00 01 00 00 01 bc 00 00 00 01 ................
0010 00 00 00 00 00 00 00 16 45 58 54 45 52 4e 41 4c ........EXTERNAL
0020 3a 2f 41 70 70 53 6f 6e 67 2e 6d 69 64 00 00 00 :/AppSong.mid...
0030 01 96 4d 54 68 64 00 00 00 06 00 01 00 04 01 e0 ..MThd..........
<MIDI-FILE CONTENT CONTINUES>
Example song 2
0000 01 00 00 06 00 00 00 01 00 00 04 80 00 00 00 01 ................
0010 00 00 00 00 00 00 00 16 45 58 54 45 52 4e 41 4c ........EXTERNAL
0020 3a 2f 41 70 70 53 6f 6e 67 2e 6d 69 64 00 00 00 :/AppSong.mid...
0030 04 5a 4d 54 68 64 00 00 00 06 00 00 00 01 07 80 .ZMThd..........
<MIDI-FILE CONTENT CONTINUES>
TCP data format for song upload
0000 01 00 00 06 00 00 00 01 MM MM MM MM 00 00 00 01 ................
0010 00 00 00 00 00 00 00 16 45 58 54 45 52 4e 41 4c ........EXTERNAL
0020 3a 2f 41 70 70 53 6f 6e 67 2e 6d 69 64 00 NN NN :/AppSong.mid...
0030 NN NN ..
<MIDI-FILE CONTENT>
- NN NN NN NN - midi-file size, little endian
- MM MM MM MM - payload size (midi-file size + 38), little endian
Smart Pianist app always use "EXTERNAL:/AppSong.mid" as song name but any other name can be used. The first byte of the name encodes the length of string (+ terminating NULL-character). Then the song name content goes and then the terminating NULL-character. When using custom song names make an adjustment to the field "payload size".
Upload song via USB
Currently we don't know how the song is uploaded when an iOS device is connected via lightning cable. It's also not clear if the similar possibility can be used when a PC is connected to USB-to-host port of the piano.
Any info on this matter is much appreciated.
Anyway our app can upload songs via WiFi even if MIDI-ports are connected via USB cable. That may be a little inconvenient but not a deal breaker.