test code to let sing eVocaloid eVY1 shield
Fork of eVY1_shield_test by
Revision 0:bc5433b55c5c, committed 2013-10-30
- Comitter:
- ytsuboi
- Date:
- Wed Oct 30 08:38:33 2013 +0000
- Child:
- 1:ffd1fb78a02f
- Commit message:
- first commit
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.lib | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Oct 30 08:38:33 2013 +0000 @@ -0,0 +1,94 @@ +#include "mbed.h" + +Serial evy1(P0_4, P0_0); // tx, rx configured for LPC800-MAX + +// DO NOT EDIT!! +const char* phoneticSymbols[] = { + "a", "i", "M", "e", "o", // あいうえお0-4 + "k a", "k' i", "k M", "k e", "k o", // かきくけこ5-9 + "s a", "S i", "s M", "s e", "s o", // さしすえそ10-14 + "t a", "tS i", "ts M", "t e", "t o", // たちつてと15-19 + "n a", "J i", "n M", "n e", "n o", //なにぬねの20-24 + "h a", "C i", "p\\ M", "h e", "h o", // はひふへほ25-29 + "m a", "m' i", "m M", "m e", "m o", // まみむめも30-34 + "j a","i", "j M","e","j o",//やいゆえよ35-39 + "4 a", "4' i", "4 M", "4 e", "4 o", // らりるれろ40-44 + "w a","w o","N\\","","",// わをん 45-49 + "g a", "g' i", "g M", "g e", "g o",//がぎぐげご 50-54 + "dz a", "dZ i", "dz M", "dz e", "dz o",//ざじずぜぞ55-59 + "d a", "dZ i", "dz M", "d e", "d o",//だじづでど60-64 + "b a", "b' i", "b M", "b e", "b o",//ばびぶべぼ 65-69 + "p a", "p' i", "p M", "p e", "p o"//ぱぴぷぺぽ70-74 +}; + +//lylics +//かえるのうたがきこえてくるよ +int lylics[]={5,3,42,24,2,15,50,6,9,3,18,7,42,39}; +char mml[] ="CDEFEDC EFGAGFE"; + +void Short_Message(int cmd, int d1, int d2) { + evy1.putc(cmd); + evy1.putc(d1); + evy1.putc(d2); +} + +// send lylics +void lylic_send(int num){ + //hedaer + evy1.putc(0xF0); + evy1.putc(0x43); + evy1.putc(0x79); + evy1.putc(0x09); + evy1.putc(0x00); + evy1.putc(0x50); + evy1.putc(0x10); + + for(int i=0;i<num;i++){ + if(i != 0) evy1.putc(0x2c); + evy1.printf(phoneticSymbols[lylics[i]]); + } + //footer + evy1.putc(0x00); + evy1.putc(0xF7); +} + + +int main() { + int key = 0x3c; //C +// float wait =0.5; +// int oct = 0; + + evy1.baud(31250); // MIDI speed + wait(5); // waiting for eVY1 module boot up + + //send lylics + int lylic_len = sizeof(lylics) / sizeof(lylics[0]); + lylic_send(lylic_len); + + int mml_len = sizeof(mml) / sizeof(mml[0]); + for(int i = 0;i< mml_len ;i++){ + char c = mml[i]; + if(c >= 'a' && c <='z') c-= 0x20; + if((c>='A' && c<='Z')||c=='<'||c=='>'){ + //key send + if(i!=0){ + Short_Message(0x90,key,0x7f); + wait(0.5); + } + key= 0x3c; + + switch(c) { + case 'C': break; + case 'D': key+=2; break; + case 'E': key+=4; break; + case 'F': key+=5; break; + case 'G': key+=7; break; + case 'A': key+=9; break; + case 'B': key+=11; break; + default: break; + } + } + } + Short_Message(0x90,key,0x7f); + wait(0.5); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.lib Wed Oct 30 08:38:33 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/#f37f3b9c9f0b