kazuma goto
/
eVY1test
YAMAHA eVY1 test program. using MIDI class.
main.cpp@0:50741b26449e, 2014-01-21 (annotated)
- Committer:
- gkmaro634
- Date:
- Tue Jan 21 15:01:24 2014 +0000
- Revision:
- 0:50741b26449e
YAMAHA eVY1 test program
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gkmaro634 | 0:50741b26449e | 1 | #include "mbed.h" |
gkmaro634 | 0:50741b26449e | 2 | #include "MIDI.h" |
gkmaro634 | 0:50741b26449e | 3 | #include "main.h" |
gkmaro634 | 0:50741b26449e | 4 | #include <stdlib.h> |
gkmaro634 | 0:50741b26449e | 5 | #include <string.h> |
gkmaro634 | 0:50741b26449e | 6 | |
gkmaro634 | 0:50741b26449e | 7 | #define CH_VOICE 1; |
gkmaro634 | 0:50741b26449e | 8 | |
gkmaro634 | 0:50741b26449e | 9 | void setup_eVY1(void); |
gkmaro634 | 0:50741b26449e | 10 | |
gkmaro634 | 0:50741b26449e | 11 | DigitalOut myled(LED1); |
gkmaro634 | 0:50741b26449e | 12 | MIDI evy1(p9, p10); |
gkmaro634 | 0:50741b26449e | 13 | int ch_use = CH_VOICE; |
gkmaro634 | 0:50741b26449e | 14 | |
gkmaro634 | 0:50741b26449e | 15 | // DO NOT EDIT!! |
gkmaro634 | 0:50741b26449e | 16 | const char* phoneticSymbols[] = { |
gkmaro634 | 0:50741b26449e | 17 | "a", "i", "M", "e", "o", // あいうえお0-4 |
gkmaro634 | 0:50741b26449e | 18 | "k a", "k' i", "k M", "k e", "k o", // かきくけこ5-9 |
gkmaro634 | 0:50741b26449e | 19 | "s a", "S i", "s M", "s e", "s o", // さしすえそ10-14 |
gkmaro634 | 0:50741b26449e | 20 | "t a", "tS i", "ts M", "t e", "t o", // たちつてと15-19 |
gkmaro634 | 0:50741b26449e | 21 | "n a", "J i", "n M", "n e", "n o", //なにぬねの20-24 |
gkmaro634 | 0:50741b26449e | 22 | "h a", "C i", "p\\ M", "h e", "h o", // はひふへほ25-29 |
gkmaro634 | 0:50741b26449e | 23 | "m a", "m' i", "m M", "m e", "m o", // まみむめも30-34 |
gkmaro634 | 0:50741b26449e | 24 | "j a","i", "j M","e","j o",//やいゆえよ35-39 |
gkmaro634 | 0:50741b26449e | 25 | "4 a", "4' i", "4 M", "4 e", "4 o", // らりるれろ40-44 |
gkmaro634 | 0:50741b26449e | 26 | "w a","w o","N\\","","",// わをん 45-49 |
gkmaro634 | 0:50741b26449e | 27 | "g a", "g' i", "g M", "g e", "g o",//がぎぐげご 50-54 |
gkmaro634 | 0:50741b26449e | 28 | "dz a", "dZ i", "dz M", "dz e", "dz o",//ざじずぜぞ55-59 |
gkmaro634 | 0:50741b26449e | 29 | "d a", "dZ i", "dz M", "d e", "d o",//だじづでど60-64 |
gkmaro634 | 0:50741b26449e | 30 | "b a", "b' i", "b M", "b e", "b o",//ばびぶべぼ 65-69 |
gkmaro634 | 0:50741b26449e | 31 | "p a", "p' i", "p M", "p e", "p o"//ぱぴぷぺぽ70-74 |
gkmaro634 | 0:50741b26449e | 32 | }; |
gkmaro634 | 0:50741b26449e | 33 | |
gkmaro634 | 0:50741b26449e | 34 | void setup_eVY1(void){ |
gkmaro634 | 0:50741b26449e | 35 | evy1.begin(ch_use); |
gkmaro634 | 0:50741b26449e | 36 | } |
gkmaro634 | 0:50741b26449e | 37 | |
gkmaro634 | 0:50741b26449e | 38 | /* |
gkmaro634 | 0:50741b26449e | 39 | int make_lylic(){ |
gkmaro634 | 0:50741b26449e | 40 | int i; |
gkmaro634 | 0:50741b26449e | 41 | int* lylic; |
gkmaro634 | 0:50741b26449e | 42 | int lylics[]={5,3,42,24,2,15,50,6,9,3,18,7,42,39}; |
gkmaro634 | 0:50741b26449e | 43 | |
gkmaro634 | 0:50741b26449e | 44 | lylic = (int*)malloc(sizeof(lylics)); |
gkmaro634 | 0:50741b26449e | 45 | if(lylic == NULL)return (-1) |
gkmaro634 | 0:50741b26449e | 46 | |
gkmaro634 | 0:50741b26449e | 47 | for(i=0; i<sizeof(lylics)/sizeof(lylics[0]); i++){ |
gkmaro634 | 0:50741b26449e | 48 | lylic[i] = phoneticSymbols[lylics[i]]; |
gkmaro634 | 0:50741b26449e | 49 | } |
gkmaro634 | 0:50741b26449e | 50 | free(lylic); |
gkmaro634 | 0:50741b26449e | 51 | } |
gkmaro634 | 0:50741b26449e | 52 | */ |
gkmaro634 | 0:50741b26449e | 53 | void send_lylic(uint8_t mode){ |
gkmaro634 | 0:50741b26449e | 54 | int i, j; |
gkmaro634 | 0:50741b26449e | 55 | int len; |
gkmaro634 | 0:50741b26449e | 56 | int lylics[]={5,3,42,24,2,15,50,6,9,3,18,7,42,39}; |
gkmaro634 | 0:50741b26449e | 57 | int len_lylics = sizeof(lylics)/sizeof(lylics[0]); |
gkmaro634 | 0:50741b26449e | 58 | |
gkmaro634 | 0:50741b26449e | 59 | byte header[] = {0xF0,0x43,0x79,0x09,0x00,0x50,0x10|mode}; |
gkmaro634 | 0:50741b26449e | 60 | byte lylic[] = {'a'}; |
gkmaro634 | 0:50741b26449e | 61 | byte sepalate[] = {','}; |
gkmaro634 | 0:50741b26449e | 62 | byte footer[] = {0x00,0xF7}; |
gkmaro634 | 0:50741b26449e | 63 | |
gkmaro634 | 0:50741b26449e | 64 | int len_header = sizeof(header)/sizeof(header[0]); |
gkmaro634 | 0:50741b26449e | 65 | int len_lylic = sizeof(lylic)/sizeof(lylic[0]); |
gkmaro634 | 0:50741b26449e | 66 | int len_sepalate = sizeof(sepalate)/sizeof(sepalate[0]); |
gkmaro634 | 0:50741b26449e | 67 | int len_footer = sizeof(footer)/sizeof(footer[0]); |
gkmaro634 | 0:50741b26449e | 68 | |
gkmaro634 | 0:50741b26449e | 69 | evy1.sendSysEx(len_header, header, true); |
gkmaro634 | 0:50741b26449e | 70 | for(i=0; i<len_lylics; i++){ |
gkmaro634 | 0:50741b26449e | 71 | len = strlen(phoneticSymbols[lylics[i]]); |
gkmaro634 | 0:50741b26449e | 72 | for(j=0; j<len;j++){ |
gkmaro634 | 0:50741b26449e | 73 | lylic[0] = phoneticSymbols[lylics[i]][j]; |
gkmaro634 | 0:50741b26449e | 74 | evy1.sendSysEx(len_lylic, lylic, true); |
gkmaro634 | 0:50741b26449e | 75 | } |
gkmaro634 | 0:50741b26449e | 76 | if(i<len_lylics-1) evy1.sendSysEx(len_sepalate, sepalate, true); |
gkmaro634 | 0:50741b26449e | 77 | } |
gkmaro634 | 0:50741b26449e | 78 | evy1.sendSysEx(len_footer, footer, true); |
gkmaro634 | 0:50741b26449e | 79 | } |
gkmaro634 | 0:50741b26449e | 80 | |
gkmaro634 | 0:50741b26449e | 81 | int main() { |
gkmaro634 | 0:50741b26449e | 82 | int i; |
gkmaro634 | 0:50741b26449e | 83 | int key = 0x3c; //C |
gkmaro634 | 0:50741b26449e | 84 | int ch1 = CH_VOICE; |
gkmaro634 | 0:50741b26449e | 85 | |
gkmaro634 | 0:50741b26449e | 86 | //setup |
gkmaro634 | 0:50741b26449e | 87 | setup_eVY1(); |
gkmaro634 | 0:50741b26449e | 88 | |
gkmaro634 | 0:50741b26449e | 89 | //make lylic |
gkmaro634 | 0:50741b26449e | 90 | |
gkmaro634 | 0:50741b26449e | 91 | //send lylic |
gkmaro634 | 0:50741b26449e | 92 | send_lylic(0x00);//mode replace:0x00, append:0x01 |
gkmaro634 | 0:50741b26449e | 93 | |
gkmaro634 | 0:50741b26449e | 94 | //send MIDI message |
gkmaro634 | 0:50741b26449e | 95 | char mml[] ="CDEFEDC EFGAGFE"; |
gkmaro634 | 0:50741b26449e | 96 | int mml_len = sizeof(mml) / sizeof(mml[0]); |
gkmaro634 | 0:50741b26449e | 97 | |
gkmaro634 | 0:50741b26449e | 98 | for(i = 0;i< mml_len ;i++){ |
gkmaro634 | 0:50741b26449e | 99 | char c = mml[i]; |
gkmaro634 | 0:50741b26449e | 100 | if(c >= 'a' && c <='z') c-= 0x20; |
gkmaro634 | 0:50741b26449e | 101 | if((c>='A' && c<='Z')||c=='<'||c=='>'){ |
gkmaro634 | 0:50741b26449e | 102 | //key send |
gkmaro634 | 0:50741b26449e | 103 | if(i!=0){ |
gkmaro634 | 0:50741b26449e | 104 | evy1.sendNoteOn(key,0x7f,ch1); |
gkmaro634 | 0:50741b26449e | 105 | wait(0.5); |
gkmaro634 | 0:50741b26449e | 106 | } |
gkmaro634 | 0:50741b26449e | 107 | key= 0x3c; |
gkmaro634 | 0:50741b26449e | 108 | |
gkmaro634 | 0:50741b26449e | 109 | switch(c) { |
gkmaro634 | 0:50741b26449e | 110 | case 'C': break; |
gkmaro634 | 0:50741b26449e | 111 | case 'D': key+=2; break; |
gkmaro634 | 0:50741b26449e | 112 | case 'E': key+=4; break; |
gkmaro634 | 0:50741b26449e | 113 | case 'F': key+=5; break; |
gkmaro634 | 0:50741b26449e | 114 | case 'G': key+=7; break; |
gkmaro634 | 0:50741b26449e | 115 | case 'A': key+=9; break; |
gkmaro634 | 0:50741b26449e | 116 | case 'B': key+=11; break; |
gkmaro634 | 0:50741b26449e | 117 | default: break; |
gkmaro634 | 0:50741b26449e | 118 | } |
gkmaro634 | 0:50741b26449e | 119 | } |
gkmaro634 | 0:50741b26449e | 120 | } |
gkmaro634 | 0:50741b26449e | 121 | evy1.sendNoteOn(key, 0x7f, ch1); // note on message. 0x90=1ch, 0x7f=Velocity |
gkmaro634 | 0:50741b26449e | 122 | wait(0.5); |
gkmaro634 | 0:50741b26449e | 123 | evy1.sendNoteOff(key, 0x7f, ch1); // note on message. 0x90=1ch, 0x7f=Velocity |
gkmaro634 | 0:50741b26449e | 124 | } |