我正在尝试制作win32应用程序,我模拟我按下钢琴上的C
键,键盘No 60,然后拨打以下电话:midiOutShortMsg (hMidiOut, DWORD (0x090 | 0 | (60 << 8) | (64 << 16)));
当释放密钥no 60时,请执行以下呼叫:midiOutShortMsg (hMidiOut, DWORD (0x080 | 0 | (60 << 8) | (0 << 16)));
问题是当我按下按钮时,我只听到一次声音。当我运行程序时,只有一个案例有效。
只要按下,我该怎么做才能重复声音。如何制作长长的旋律。
case WM_KEYDOWN:
{
switch (wParam) {
case VK_LEFT:
midiOutOpen(&hMidiOut, -1, 0, 0, 0);
// Set instrument to 0 = Acoustic Grand Piano
midiOutShortMsg(hMidiOut, DWORD(0x0C0 | 0 | (0 << 8) | (0 << 16)));
midiOutShortMsg (hMidiOut, DWORD(0x090 | 0 | (65<<8 ) | (64 << 16)));
break;
case 'S':
midiOutShortMsg (hMidiOut, DWORD(0x090 | 0 | (62<<8 ) | (64 << 16)));
break;
case 'D':
midiOutShortMsg (hMidiOut, DWORD(0x090 | 0 | (64<<8 ) | (64 << 16)));
break;
case 'F':
midiOutShortMsg (hMidiOut, DWORD(0x090 | 0 | (65<<8 ) | (64 << 16)));
break;
case 'G':
midiOutShortMsg (hMidiOut, DWORD(0x090 | 0 | (67<<8 ) | (64 << 16)));
break;
case 'H':
midiOutShortMsg (hMidiOut, DWORD(0x090 | 0 | (69<<8 ) | (64 << 16)));
break;
case 'J':
midiOutShortMsg (hMidiOut, DWORD(0x090 | 0 | (71<<8 ) | (64 << 16)));
break;
case 'K':
midiOutShortMsg (hMidiOut, DWORD(0x090 | 0 | (72<<8 ) | (64 << 16)));
break;
答案 0 :(得分:0)
我猜你可以存储键状态(可能使用bool数组)并在消息处理循环中进行播放。