Archived

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

directmusic playing twice as fast

This topic is 5242 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi! I''m using directmusic to play my sounds, but it plays twice as fast as it sould. I have read other posts that say the same thing. They say the solution is:
if(FAILED(m_dmsegment->SetParam(GUID_StandardMIDIFile,
0xFFFFFFFF,0,0,NULL)))
{
m_dmsegment->Release();
return false;
}

But it doesn''t work, it makes no difference... Anyone knows what to do? Thanks in advance!

Share on other sites
Well, you could do something such as reducing the tempo of the Playback try this code to set the tempo

you could get the Tempo value from this

pPerf->GetGlobalParam( GUID_PerfMasterTempo,
(void*)&fTempo, sizeof(float) );

then, divide the tempo by half i.e. 2 :-)

then set the new tempo with this

pPerf->SetGlobalParam( GUID_PerfMasterTempo,
(void*)&fTempo, sizeof(float) );

where, fTempo is the current tempo of playback.

Actually i dont know the cause of this problem myself.It happens on some machines. I have seen such things happening before.

Share on other sites
If I do that then maybe the sound will play slow on some machines and normal on others...

This should work!... but doesn't... =(

if(FAILED(m_dmsegment->SetParam(GUID_StandardMIDIFile,0xFFFFFFFF,0,0,NULL)))	{		m_dmsegment->Release();		return false;	}

[edited by - kobingo on January 14, 2004 3:27:16 AM]

[edited by - kobingo on January 14, 2004 3:28:11 AM]

Share on other sites
I dont know exactly but the function SetParam(...) ensures that a standard MIDI file (one not authored specifically for DirectMusic) plays correctly which means that as long as the sound is playing( sound coming from speakers..) this function will return a success.

Why don''t you try to test on different machines and see if it works....or try posting the executable with the MIDI file and let others test for you? You might get some better answers than mine...I too am new in DX

Share on other sites
I've tried at 3 differnt computers now, they all play the sound twice as fast.

*sigh*

Anyone?

Here I set up directmusic
// init com	CoInitialize(NULL);	if(FAILED(CoCreateInstance(CLSID_DirectMusicLoader,NULL,		CLSCTX_INPROC, IID_IDirectMusicLoader8,(void**)&m_dmloader)))	{		return false;	}	if(FAILED(CoCreateInstance(CLSID_DirectMusicPerformance,NULL,		CLSCTX_INPROC,IID_IDirectMusicPerformance8,		(void**)&m_dmperfomance)))	{		m_dmloader->Release();		return false;	}	if(FAILED(m_dmperfomance->InitAudio(NULL,NULL,NULL,		DMUS_APATH_SHARED_STEREOPLUSREVERB,64,DMUS_AUDIOF_ALL,NULL)))	{		m_dmperfomance->Release();		m_dmloader->Release();		return false;	}

if(FAILED(m_audio->get_dmloader()->LoadObjectFromFile(		CLSID_DirectMusicSegment,IID_IDirectMusicSegment8,wfilename,		(LPVOID*)&m_dmsegment)))	{		return false;	}	if(FAILED(m_dmsegment->SetParam(GUID_StandardMIDIFile,		0xFFFFFFFF,0,0,NULL)))	{		m_dmsegment->Release();		return false;	}	if(FAILED(m_dmsegment->Download(m_audio->get_dmperformance())))	{		m_dmsegment->Release();		return false;	}

Here I play the file

m_dmperfomance->PlaySegmentEx(sound->get_dmsegment(),NULL,NULL,		DMUS_SEGF_SECONDARY,0,NULL,NULL,NULL);

[edited by - kobingo on January 15, 2004 9:36:21 AM]

Share on other sites
Hmm...

if I skip DMUS_SEGF_SECONDARY and put in DEFAULT value there instead it plays normal, but then I can't play two sounds at the same time...

[edited by - kobingo on January 15, 2004 9:39:12 AM]

Share on other sites
Have you tried combining DMUS_SEGF_DEFAULT and DMUS_SEGF_SECONDARY?

Share on other sites
Yes, and I get the same problem...

Share on other sites
Yes, and I get the same problem...

Share on other sites
Does your midi file contain a tempo setting? If not, I think directmusic uses the default midi tempo of 120. Try experimenting with different tempo settings until you get it to play the way you want it. By explicitly setting the tempo, it *should* play the same on any computer.

• 39
• 15
• 9
• 23
• 10