#include "myWin.h" #pragma comment(lib,"winmm.lib") #define SMSG(st, ch,d1,d2)((DWORD)(st<<4)|ch|(d1<<8)|(d2<<16)) #define MAXLEN 100 #define NUMCHAN 2 typedef struct{ int Len; //音の長さ。0で終わり。 BYTE note; //音の高さ。休符のとき無視。 BYTE vel; //音の強さ。休符のときは0を入れる。 }MY_SCALE_DATA; //音の高さのコード // ド ド# レ レ# ミ ファ ファ# ソ ソ# ラ ラ# シ ド // 3C 3D 3E 3F 40 41 42 43 44 45 46 47 48 // 30 31 32 33 34 35 36 37 38 39 39 3B 3C static MY_SCALE_DATA scale[NUMCHAN][MAXLEN]={ {{4,0x45,0x45},{4,0x45,0x40},{8,0x47,0x45}, //さくら {4,0x45,0x45}, {4,0x45,0x40},{7,0x47,0x45},{1,0,0}, //さくら {4,0x45,0x45},{4,0x47,0x40},{4,0x48,0x45},{4,0x47,0x40}, //やよいの {4,0x45,0x45},{2,0x47,0x40},{2,0x45,0x45},{7,0x41,0x40}, {1,0,0}, //そらは {4,0x40,0x45},{4,0x3C,0x40},{4,0x40,0x45},{4,0x41,0x40}, //みわたす {4,0x40,0x45},{2,0x40,0x40},{2,0x3C,0x45},{7,0x3B,0x40}, {1,0,0},//かぎり {4,0x45,0x45},{4,0x47,0x40},{4,0x48,0x45},{4,0x47,0x40}, //かすみか {4,0x45,0x45},{2,0x47,0x40},{2,0x45,0x45},{7,0x41,0x40}, {1,0,0},//くもか {4,0x40,0x45},{4,0x3C,0x40},{4,0x40,0x45},{4,0x41,0x40}, //においぞ {4,0x40,0x45},{2,0x40,0x40},{2,0x3C,0x45},{7,0x3B,0x40}, {1,0,0},//いずる {4,0x45,0x45},{4,0x45,0x40},{8,0x47,0x45}, //いざや {4,0x45,0x45},{4,0x45,0x40},{7,0x47,0x45},{1,0,0}, //いざや {4,0x40,0x45}, {4,0x41,0x40},{2,0x47,0x40},{3,0x45,0x35},{6,0x41,0x32},//みにゆかん {8,0x40,0x30} }, {{6,0x39,0x45},{2,0x39,0},{6,0x34,0x40},{2,0x39,0}, {6,0x39,0x45},{2,0x39,0},{6,0x34,0x40},{2,0x39,0}, {6,0x39,0x45},{2,0x39,0},{6,0x39,0x40},{2,0x39,0}, {6,0x39,0x45},{2,0x39,0},{6,0x32,0x40},{2,0x32,0}, {6,0x39,0x40},{2,0x39,0},{6,0x34,0x40},{2,0x34,0}, {6,0x39,0x40},{2,0x39,0},{6,0x34,0x40},{2,0x34,0}, {6,0x39,0x45},{2,0x39,0},{6,0x39,0x40},{2,0x39,0}, {6,0x39,0x45},{2,0x39,0},{6,0x32,0x40},{2,0x32,0}, {6,0x39,0x40},{2,0x39,0},{6,0x34,0x40},{2,0x34,0}, {6,0x39,0x40},{2,0x39,0},{6,0x34,0x40},{2,0x34,0}, {6,0x39,0x45},{2,0x39,0},{6,0x34,0x40},{2,0x39,0}, {6,0x39,0x45},{2,0x39,0},{6,0x34,0x40},{2,0x39,0}, {6,0x39,0x45},{2,0x39,0},{3,0x34,0x45},{2,0x34,0},{5,0x32,0x32},{1,0x39,0}, {6,0x39,0x30} }}; static MY_SCALE_DATA Temp[NUMCHAN][MAXLEN]; static int ID[NUMCHAN];static int prog[NUMCHAN]={0x49,0x6B}; static HMIDIOUT hM; void procRButtonUp(HWND hw, WPARAM wp,LPARAM lp){ KillTimer(hw,1); midiOutReset(hM); } void procLButtonUp(HWND hw, WPARAM wp,LPARAM lp){ for(int j=0;j0){ Temp[j][ID[j]].Len--; if(Temp[j][ID[j]].Len==0){ midiOutShortMsg(hM,SMSG(0x9,j,Temp[j][ID[j]].note,0)); midiOutShortMsg(hM,SMSG(0xC,j,prog[j],0)); ID[j]++; if(Temp[j][ID[j]].note>0) midiOutShortMsg(hM,SMSG(0x9,j,Temp[j][ID[j]].note,Temp[j][ID[j]].vel)); } } } BOOL endCH=TRUE; for(int j=0;j0)endCH=FALSE; if(endCH){ KillTimer(hw,1); midiOutReset(hM); //midiOutClose(hM); } } void procCreate(HWND hw, WPARAM wp,LPARAM lp){ midiOutOpen(&hM,MIDIMAPPER,NULL,0,CALLBACK_NULL); } LRESULT CALLBACK WndProc(HWND hw, UINT msg, WPARAM wp,LPARAM lp){ switch(msg){ case WM_DESTROY : midiOutReset(hM); midiOutClose(hM); PostQuitMessage(0) ;return 0; case WM_CREATE : procCreate (hw,wp,lp);return 0; case WM_LBUTTONUP : procLButtonUp(hw,wp,lp);return 0; case WM_RBUTTONUP : procRButtonUp (hw,wp,lp);return 0; case WM_TIMER : procTimer (hw,wp,lp);return 0; } return DefWindowProc(hw,msg,wp,lp); }