I'm sure this has been asked tons of times, but I googled it and searched gamedev with little success. I'm using DirectX 8.1 and DirectMusic. Currently I can only play wavs and mids. I'm using the following code to load the file:
DMUS_OBJECTDESC dmod;
Free();
if(m_Sound == NULL)
return FALSE;
if(m_Sound->GetPerformanceCOM() == NULL)
return FALSE;
if(m_Sound->GetLoaderCOM() == NULL)
return FALSE;
// Get the object
ZeroMemory(&dmod, sizeof(DMUS_OBJECTDESC));
dmod.dwSize = sizeof(DMUS_OBJECTDESC);
dmod.guidClass = CLSID_DirectMusicSegment;
dmod.dwValidData = DMUS_OBJ_CLASS | DMUS_OBJ_FILENAME | DMUS_OBJ_FULLPATH;
mbstowcs(dmod.wszFileName, Filename, MAX_PATH);
if(FAILED(m_Sound->GetLoaderCOM()->GetObject(&dmod, IID_IDirectMusicSegment8, (LPVOID*)&m_pDMSegment)))
return FALSE;
// Setup MIDI playing
if(strstr(Filename, ".mid") != NULL) {
if(FAILED(m_pDMSegment->SetParam(GUID_StandardMIDIFile, 0xFFFFFFFF, 0, 0, NULL)))
return FALSE;
}
// Download the band
if(FAILED(m_pDMSegment->Download(m_Sound->GetPerformanceCOM())))
return FALSE;
return TRUE;
and this to play it:
Stop();
// Return if not setup correctly
if(m_Sound == NULL)
return FALSE;
if(m_Sound->GetPerformanceCOM() == NULL)
return FALSE;
if(m_pDMSegment == NULL)
return FALSE;
// Set the number of loops
if(!Loop)
m_pDMSegment->SetRepeats(DMUS_SEG_REPEAT_INFINITE);
else
m_pDMSegment->SetRepeats(Loop-1);
// Set the playback volume
SetVolume(VolumePercent);
// Play on default audio path
if(FAILED(m_Sound->GetPerformanceCOM()->PlaySegmentEx(
m_pDMSegment, NULL, NULL,
0, 0, NULL, NULL, NULL)))
return FALSE;
return TRUE;
Does anyone know how I can modify the code so it will load and play mp3 files?
Also, if anyone knows of a good program that can modify mids I would appreciate it.
Thanks.