Please, Help me with music!

Started by
5 comments, last by water908 20 years, 11 months ago
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?
Advertisement
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.
---K-1 Productions: Come visit us here.
you could look at using FMOD which has good MIDI support (aswell as all other formats).. Is free and is very easy to use..

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]
DarkMcNugget next time... ;)
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]

Previously "Krohm"

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...

Relative Games - My apps

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.

This topic is closed to new replies.

Advertisement