/*********************************/ /* MIDI音源 */ /* うさぎ */ /* リンク時に winmm.lib を追加 */ /*********************************/ #include #include //--音階データ(-1 は最後の印)-- int onkai [128]={ 65,65,69,71,69,71, // ファ,ファ,ラ,シ,ラ,シ, 65,65,65,69,71,69,71, // ファ,ファ,ファ,ラ,シ,ラ,シ, 69,71,72,72,71,69,69,65,64, // ラ,シ,ド,ド,シ,ラ,ラ,ファ,ミ, 69,65,64,65,64,62,64,-1 // ラ,ファ,ミ,ファ,ミ,レ,ミ }; //--音の長さデータ(ミリ秒)-- int nagasa[128]={ 1000,500,500,500,500,1000, 500,500,500,500,500,500,1000, 500,500,500,500,500,250,250,500,500, 500,500,1000,500,500,1000,1000 }; void main( ) { HMIDIOUT hmo; // MIDI出力デバイスのハンドル int neiro= 4; // 音色(1〜128) int i; printf("\nうさぎ\n"); midiOutOpen(&hmo,MIDI_MAPPER,0,0,CALLBACK_NULL); // MIDI出力デバイスを開く midiOutShortMsg(hmo,0x000000C0|(neiro<<8)); // 音色を設定する for( i=0; onkai[i]!=-1; i++ ) // データの最後まで { //--音を出す-- midiOutShortMsg(hmo,0x7F0090|(onkai[i]<<8)); // MID出力デバイスにメッセージ送信 Sleep(nagasa[i]); // ミリ秒単位で待機 //--音を消す-- midiOutShortMsg(hmo,0x80|(onkai[i]<<8)); // MID出力デバイスにメッセージ送信 } midiOutClose(hmo); // MIDI出力デバイスを閉じる }