Archived

This topic is now archived and is closed to further replies.

water908

Please, Help me with music!

Recommended Posts

water908    122
I''m trying to find out how to play music. From the NeHe Zelda I was able to get the following lines of code, mciSendString("open Data/Overworld.mid type sequencer", NULL, 0, NULL); mciSendString("play Data/Overworld.mid", NULL, 0, NULL); the problem with this code is that the song will play, then stop at the end of the song, I want to make it so it will repeat. How do i do that?

Share this post


Link to post
Share on other sites
K-1    122
In your play string try:
mciSendString("play Data/Overworld.mid repeat", NULL, 0, NULL);

There''s more info on MSDN.

---
K-1 Productions: Come visit us here.

Share this post


Link to post
Share on other sites
DarkKiller    122
Try to use OpenAL to play sounds.

I know it is much more complicated than MCI but it is a new world of sound-programming!

Many things are very equal to OpenGL

http://www.openal.org

Dark

McNugget next time...

[edited by - DarkKiller on April 30, 2003 12:00:46 PM]

Share this post


Link to post
Share on other sites
Krohm    5031
I also raccomand FMOD.

AL would actually be my best choice but looks like it's going to hell. Anyway, it is very easy and I actually think it's approach is very good.


EDIT: note about AL easiness.

[edited by - Krohm on April 30, 2003 6:29:56 PM]

Share this post


Link to post
Share on other sites
cippyboy    223
Here`s the code I use for playing midi-s:
UINT wDeviceID;
DWORD dwReturn;
MCI_OPEN_PARMS mciOpenParms;
MCI_PLAY_PARMS mciPlayParms;
void stop();
DWORD play(LPSTR lpszMIDIFileName){
stop();
mciOpenParms.lpstrDeviceType = "sequencer";
mciOpenParms.lpstrElementName = lpszMIDIFileName;
unsigned int U;
if (dwReturn = mciSendCommand(U,MCI_OPEN,MCI_OPEN_TYPE | MCI_OPEN_ELEMENT,(DWORD)&mciOpenParms))
{
return (dwReturn);
}
wDeviceID = mciOpenParms.wDeviceID;
if (dwReturn = mciSendCommand(wDeviceID, MCI_PLAY, MCI_NOTIFY,
(DWORD)(LPVOID) &mciPlayParms))
{
mciSendCommand(wDeviceID, MCI_CLOSE,0,0);
return (dwReturn);
}
return dwReturn;
}
void stop(){
mciSendCommand(wDeviceID, MCI_STOP, MCI_NOTIFY,
(DWORD)(LPVOID) &mciPlayParms);
mciSendCommand(wDeviceID, MCI_CLOSE, 0, 0);
}
//and then in the use code :
{
................
play("Mymidi.mid");
................
}
//I sorted the stop() function that way so you can play another midi just by calling another play() function...

Share this post


Link to post
Share on other sites
water908    122
It works now. I took out the line

mciSendString("open Data/Overworld.mid type sequencer", NULL, 0, NULL);

and moved this line into the main loop of the program, instead of having it in the initializing part of the program

mciSendString("play Data/Overworld.mid", NULL, 0, NULL);

it won''t play another song until the current one is finished, i didn''t think it would do that.

I previously got FMOD but i had problems using the function in my program, so i took it out.

Thanks for the advice.

Share this post


Link to post
Share on other sites