Hi,
I have some problem by using the midi file. I wish to control the left and the right channels volumes, and i got some information from msdn library, but it didn't tell me the exact way to do it. Could anyone tell me what is the meaning of
"The low-order word contains the left-channel volume setting, and the high-order word contains the right-channel setting. A value of 0xFFFF represents full volume, and a value of 0x0000 is silence."
The sentence above i copy from the the msdn library of MidiOutGetVolume and midiOutSetVolume. Does it mean the low order is 0x000 to 0x7777(left channel) and 0x8000 to 0xFFFF is high order (right channel)?
The code below is modified from an example from internet. Although I set the midiOutSetVolume(hdev, 0xF000); But it didn't work at all.
Anyone have similar example could control the left and right volumes? I already stuck on this step quite a while.
I wish someone could give some suggestion for me. Thanks a lot.
#include <windows.h>
#include <stdio.h>
#pragma comment(lib, "Winmm.lib")
#define NOTE_ON 0x90
#define NOTE_OFF 0x80
//command, note, velocity
#define MAKE_MSG(X, Y, Z) (X + (Y<<8) + (Z<<16))
int playChord(HMIDIOUT hdev)
{
[B]midiOutSetVolume(hdev, 0x0000);[/B]
midiOutShortMsg(hdev, MAKE_MSG(NOTE_ON, 62, 65));
Sleep(1000);
[B]midiOutSetVolume(hdev, 0xF000);
[/B] midiOutShortMsg(hdev, MAKE_MSG(NOTE_ON, 62, 65));
Sleep(1000);
[B]midiOutSetVolume(hdev, 0x5555);
[/B] midiOutShortMsg(hdev, MAKE_MSG(NOTE_ON, 62, 65));
Sleep(1000);
[B]midiOutSetVolume(hdev, 0xFFF0);
[/B] midiOutShortMsg(hdev, MAKE_MSG(NOTE_ON, 62, 65));
Sleep(1000);
midiOutShortMsg(hdev, MAKE_MSG(NOTE_OFF, 62, 65));
midiOutShortMsg(hdev, MAKE_MSG(NOTE_OFF, 62, 65));
midiOutShortMsg(hdev, MAKE_MSG(NOTE_OFF, 62, 65));
midiOutShortMsg(hdev, MAKE_MSG(NOTE_OFF, 62, 65));
return 0;
}
int main()
{
HMIDIOUT hdev;
static MIDIOUTCAPS devCaps;
static LPMIDIOUTCAPS lpCaps = &devCaps;
DWORD abc;
[B] devCaps.dwSupport = MIDICAPS_VOLUME|MIDICAPS_LRVOLUME;[/B]
abc = devCaps.dwSupport;
if (devCaps.dwSupport == MIDICAPS_VOLUME|MIDICAPS_LRVOLUME)
{
wprintf(L"abc");
}
midiOutGetDevCaps(0, lpCaps, sizeof(MIDIOUTCAPS)); // Get device capabilities for first device (curDevice == 0)
midiOutOpen(&hdev, -1, NULL, NULL, CALLBACK_NULL);
midiOutSetVolume(hdev, 0x0000);
wchar_t menu_sel = 0;
while(menu_sel != 'q')
{
wprintf(L"Midi test app\nc: play chord\nd: change device\nv: set volume\nq: quit\n");
wscanf(L" %c", &menu_sel);
switch(menu_sel)
{
case 'q':
break;
case 'c':
playChord(hdev);
break;
default:
wprintf(L"try again\n");
break;
}
}
midiOutClose(hdev);
return 0;
}