Jump to content
  • Advertisement

Archived

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

kobingo

directmusic playing twice as fast

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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;
}


Here I load the file


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 this post


Link to post
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!