Helstorm
April 14th, 2009, 11:35 AM
hi,
I'm trying to use MCI to play a MIDI sequence, but the problem is that I can't hear anything after the device is successfully opened. Here's my code:
#include<windows.h>
#include<stdio.h>
#include<mmsystem.h>
#pragma comment(lib,"winmm.lib")
int main()
{
int i = 0;
MCI_OPEN_PARMS mciOpen;
mciOpen.lpstrDeviceType = L"mpegvideo";
mciOpen.lpstrElementName = L"F:\\Program Files\\RPG Maker XP\\RGSS\\Standard\\Audio\\BGM\\011-LastBoss03.mid";
mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)&mciOpen);
MCI_STATUS_PARMS mciStatusParms;
mciStatusParms.dwItem = MCI_STATUS_LENGTH;
mciSendCommand(mciOpen.wDeviceID, MCI_STATUS, MCI_STATUS_ITEM, (DWORD)&mciStatusParms);
int curLength = mciStatusParms.dwReturn;
printf("total length:%d\n", curLength);
MCI_PLAY_PARMS mciPlay;
mciSendCommand(mciOpen.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mciPlay);
while(1)
{
printf("now playing\t%d\tseconds\r", i);
i++;
Sleep(1000);
}
return 0;
}
The program opened the device and obtained the media length (correctly), then the MCI_PLAY command is also sent and mciSendCommand returns. Then the program enters the while loop and starts to count in second, but I can't hear anything O.O...
I've tried to change the device type to "sequencer", it still doesn't work..
Then I tried to used mciSendString to play it, still..
I've also tried to play media that are in WAV and MP3 format, and they both worked, so I don't know why MIDI doesn't, since it works fine using Microsoft media player.
Any help is appreciated!
I'm trying to use MCI to play a MIDI sequence, but the problem is that I can't hear anything after the device is successfully opened. Here's my code:
#include<windows.h>
#include<stdio.h>
#include<mmsystem.h>
#pragma comment(lib,"winmm.lib")
int main()
{
int i = 0;
MCI_OPEN_PARMS mciOpen;
mciOpen.lpstrDeviceType = L"mpegvideo";
mciOpen.lpstrElementName = L"F:\\Program Files\\RPG Maker XP\\RGSS\\Standard\\Audio\\BGM\\011-LastBoss03.mid";
mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, (DWORD)&mciOpen);
MCI_STATUS_PARMS mciStatusParms;
mciStatusParms.dwItem = MCI_STATUS_LENGTH;
mciSendCommand(mciOpen.wDeviceID, MCI_STATUS, MCI_STATUS_ITEM, (DWORD)&mciStatusParms);
int curLength = mciStatusParms.dwReturn;
printf("total length:%d\n", curLength);
MCI_PLAY_PARMS mciPlay;
mciSendCommand(mciOpen.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&mciPlay);
while(1)
{
printf("now playing\t%d\tseconds\r", i);
i++;
Sleep(1000);
}
return 0;
}
The program opened the device and obtained the media length (correctly), then the MCI_PLAY command is also sent and mciSendCommand returns. Then the program enters the while loop and starts to count in second, but I can't hear anything O.O...
I've tried to change the device type to "sequencer", it still doesn't work..
Then I tried to used mciSendString to play it, still..
I've also tried to play media that are in WAV and MP3 format, and they both worked, so I don't know why MIDI doesn't, since it works fine using Microsoft media player.
Any help is appreciated!