Quick hack to make NSX-39 (Poke-Miku) USB MIDI device to speak "mbed" from mbed which acts as an USB host.

Dependencies:   FatFileSystem mbed

Fork of MIDI_BlueUSB by Radio Junk Box

Description of the project

This is quick hack to control Poke-miku (NSX-39) from mbed. The mbed acts as an USB host and controls USB MIDI device NSX-39. It speaks "mbed" if you send "s¥n" from virtual USB serial (connected to PC or Mac) or push SW connected to p21. It plays MIDI file "test.mid" on local file-system if you push SW connected to p22. You can find files that I have tested at the bottom. The standard MIDI file support is still preliminary. See TestShell.cpp for the hack. This program is derived from MIDI_BlueUSB (http://mbed.org/users/radiojunkbox/code/MIDI_BlueUSB/) by Radio Junk Box.

ポケミク(NSX-39)を無改造のままmbedから鳴らせるようにしてみました。mbedがUSB hostになって、USB MIDIデバイスのポケミクを鳴らします。mbedのバーチャルシリアル(USBシリアル)にPCからs\nを送るか、p21につないだスイッチを押すとmbedとしゃべります。p22につないだスイッチを押すと、ローカルファイルシステム(.binと同じ場所)に保存した test.mid を再生します。試したファイルは下にある test1.mid と test2.mid です。MIDIファイルのサポートはまだまだ完全とはいえません。

tested MIDI files

Video: Poke-miku speaks `mbed'

Committer:
non
Date:
Tue Apr 29 06:01:52 2014 +0000
Revision:
4:cd0d8ce967d8
Parent:
0:79620c558b0c
Fix issues when it plays a MIDI file which has multi tracks.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
radiojunkbox 0:79620c558b0c 1
radiojunkbox 0:79620c558b0c 2 typedef unsigned char u8;
radiojunkbox 0:79620c558b0c 3 typedef unsigned short u16;
radiojunkbox 0:79620c558b0c 4 typedef unsigned long u32;
radiojunkbox 0:79620c558b0c 5
radiojunkbox 0:79620c558b0c 6 void DelayMS(int ms);
radiojunkbox 0:79620c558b0c 7
radiojunkbox 0:79620c558b0c 8 void printfBytes(const char* label,const u8* data, int len);
radiojunkbox 0:79620c558b0c 9 void printHex(const u8* d, int len);
radiojunkbox 0:79620c558b0c 10
radiojunkbox 0:79620c558b0c 11 #ifndef min
radiojunkbox 0:79620c558b0c 12 #define min(_a,_b) ((_a) < (_b) ? (_a) : (_b))
radiojunkbox 0:79620c558b0c 13 #endif
radiojunkbox 0:79620c558b0c 14
radiojunkbox 0:79620c558b0c 15 inline int LE16(const u8* d)
radiojunkbox 0:79620c558b0c 16 {
radiojunkbox 0:79620c558b0c 17 return d[0] | (d[1] << 8);
radiojunkbox 0:79620c558b0c 18 }
radiojunkbox 0:79620c558b0c 19
radiojunkbox 0:79620c558b0c 20 inline u32 BE32(const u8* d)
radiojunkbox 0:79620c558b0c 21 {
radiojunkbox 0:79620c558b0c 22 return (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | d[3];
radiojunkbox 0:79620c558b0c 23 }
radiojunkbox 0:79620c558b0c 24
radiojunkbox 0:79620c558b0c 25 inline void BE32(u32 n, u8* d)
radiojunkbox 0:79620c558b0c 26 {
radiojunkbox 0:79620c558b0c 27 d[0] = (u8)(n >> 24);
radiojunkbox 0:79620c558b0c 28 d[1] = (u8)(n >> 16);
radiojunkbox 0:79620c558b0c 29 d[2] = (u8)(n >> 8);
radiojunkbox 0:79620c558b0c 30 d[3] = (u8)n;
radiojunkbox 0:79620c558b0c 31 }
radiojunkbox 0:79620c558b0c 32
radiojunkbox 0:79620c558b0c 33 inline void BE16(u32 n, u8* d)
radiojunkbox 0:79620c558b0c 34 {
radiojunkbox 0:79620c558b0c 35 d[0] = (u8)(n >> 8);
radiojunkbox 0:79620c558b0c 36 d[1] = (u8)n;
radiojunkbox 0:79620c558b0c 37 }