Archived

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

Started with DMusic, but latency is killing me.

This topic is 5332 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

I''m pretty new with sound, so forgive me for asking stupid questions. Last week I went through the tutorial in the SDK and set up a DMusic wrapper class that seems to work fine. . . well, it did until I put it to the test. I threw together a short demo with an airplane shooting bullets, and I found that the sound would play around half of a second too late. I''ve read that DMusic had some latency problems, but Microsoft also claimed to have addressed this problem for DX9. So basically my question is: Is there any way to overcome this latency problem in DMusic? If not, what is the purpose of DMusic, at least, in any situation where you''d need sounds to be timed to an event, which is most of the time, I''m guessing. DSound seems like it''s the only way to go, but then again, DMusic has some functionality not available to DSound. Any direction would be great on this subject. Thanks all, --Vic-- The future of 2D game development: Flat Red Ball

Share this post


Link to post
Share on other sites
Couple things:
1) Make sure that you are SETTING the latency to it''s lowest value. This is documented in the SDK and isn''t hard. By default, it is higher than you''d want it for sound effects.
2) You can always use DirectSound and DirectMusic together... for example simply use DirectMusic to play the music and DirectSound to play the effects. This system works remarkably well, although it''s more difficult to set up (check out IDirectMusicPerformance::InitAudio).

Share this post


Link to post
Share on other sites
I will look into the setting for latency. I am also wondering if it would even be worth it to use DMusic. I am planning on making a game where things will happen to the music. And the events will need to be very accurate. For this reason, wouldn''t it be worth it to do everything with DSound?


--Vic--

The future of 2D game development:
Flat Red Ball

Share this post


Link to post
Share on other sites
i suggest using FMOD, if you''re looking for a powerful and easy-to-use library. Or, if you have a bunch of time, make your own library :-D. Thats all the advice I can give you, sorry.

Share this post


Link to post
Share on other sites
Well I dunno... when you are using dynamic music, changes normally have to be aligned at least to the "beat" level, which means that latency is no longer an issue.

What kinds of things were you thinking of?

Share this post


Link to post
Share on other sites
Well, I want to make one of my next games (Planes 2) a very new type of game. It is going to be more of an interactive music video. Things will happen to the beat as you have suggested. But the issue is how do I know when the music really starts? I mean, I could tell it to start, but it might start 400 milliseconds later. How would I know for sure? And also, what do I do when the song is nearing the end.

Tell me about FMOD. I''m interested in hearing about it.


--Vic--

The future of 2D game development:
Flat Red Ball

Share this post


Link to post
Share on other sites
Don''t try to time it yourself! Use DirectMusic notify messages... they can be set up to call a predefined call-back on beats/measures/starts/ends, practically whatever you want! This is definitely the way to go and it solves all of your problems nicely.

Share this post


Link to post
Share on other sites
But wav files don''t have any kind of internal timing methods. On the other hand, there are programs that I can use to find the BPM (I''m using techno/trance songs). So I could time things that way, I''m guessing.

--Vic--

Share this post


Link to post
Share on other sites
Well if you''re ONLY using WAV files, I''d suggest using DirectSound exclusively anyways (which will give you almost no latency), and forget about DirectMusic (and performances, loaders, etc).

Share this post


Link to post
Share on other sites
quote:
Original post by Roof Top Pew Wee
Well, that''s the answer I was looking for. Thanks.

--Vic--


Awww.. And I was thinking that someone had found a cool use for DirectMusic (and there are many)...and was actually going to use it.

When DirectMusic first arrived I had hoped that there would be many more PC games with dynamic-music. Of course, writing the music to be dynamic to begin with is complicated, but the end result can be very rewarding.

But if WAV is used for the music instead of MIDI (or similar format), then DirectMusic is not the best solution.

--TheMuuj

Share this post


Link to post
Share on other sites
So here's the age old question. Where are the DSound tutorials. I have looked all over. The Articles here only have one on 3D sound, but not the basics of DSound. The only ones on the Internet are for older versions of DX. Or rather, all tutorials start with the initialization of DMusic. Is it necessary to initialize DMusic as well?


--Vic--

The future of 2D game development:
Flat Red Ball

[edited by - Roof Top Pew Wee on May 8, 2003 11:14:04 AM]

Share this post


Link to post
Share on other sites
My (our... it includes others) game uses dynamic DirectMusic stuff, and I agree, it''s much harder to write non-linear music... the final effect is pretty cool though.

Anyways the tutorials in the SDK for DirectSound are quite good... I suggest that you start there.

Share this post


Link to post
Share on other sites