Log in

View Full Version : DirectMusic


TJM
06-28-2003, 04:02 AM
I'm using DirectMusic to play midi files and it is giving me erratic frame rate. I'm new to using DirectX in that I'm pulling my older Window games up to DirectX. In the past, I used the multimedia funtion of Windows to play midi files and never had any trouble.

Is it common for DirectMusic to take so much processor time or am I doing something wrong? Any advice or links to good information about DirectMusic would be appreciated.

gilzu
06-28-2003, 04:43 AM
Framerate problem?
none that i know of.
I'm doing a 3d platformer game with music running
in the background, plus sound effects and I'm having
80+ fps, and thats only because i'm limiting the screen
refresh rate...

check out your code.
see if youre not doing some things you shouldnt.
load and initialize all your objects outside the game loop.
or check in one of the technical forums around the net,
i saw numerus similiar problems.

TJM
06-28-2003, 06:00 AM
Originally posted by gilzu
i saw numerus similiar problems.

Can you post some links to the similiar problems that you found. I can't find any. Thx.

brassfish
06-28-2003, 06:14 AM
run it through a profiler and see whats causing it.

TJM
06-28-2003, 07:05 AM
Originally posted by brassfish
run it through a profiler and see whats causing it.

Recommend one please...

LordKronos
06-28-2003, 08:19 AM
You can always download a trial copy of Intel VTune and give it a try. I've never found another profiler as good as it.

gilzu
06-28-2003, 01:33 PM
Originally posted by TJM
Can you post some links to the similiar problems that you found. I can't find any. Thx.

look here (http://www.gamedev.net/community/forums/topic.asp?topic_id=137911)

go to technical forums like Gamedev's, or CodeGuru's
or even check out google. youll be surprised of how many
results youll get.

TJM
06-28-2003, 03:54 PM
I've looked around on the Internet, but most places tell you the basics of how to set it up. I think I'm doing it exactly the way everyone says, but when I play the music the frame rate drops. I read on MSDN that there is a myth that "DirectMusic chews up CPU cycles and RAM". Is this true?

I also read that DirectMusic in DirectX 9 has great improvements. I'm developing under DirectX 7. Did DirectMusic have problems with that version? Do you think it would be better to develop using DirectX 7's DirectMusic or should I just use my old routines using Windows multimedia API?

Does "everyone" use DirectMusic for their games or are some people still using the old Windows mutimedia?

svero
06-28-2003, 04:21 PM
Sorry, this is very very fuzzy but maybe with some luck it will send you looking in the right direction... I think I may have had this problem a long time ago when I firsted started using these objects. I believe I was creating too many of a particular kind of object or not reusing something but creating many of them when I really only wanted 1. I was creating one object per song, but it was incorrect, and I needed just 1 object for all songs or something *like* that. Sorry I can't be more specific but it was a long long time ago. I do remember that it manifested itself in the same way you're describing though.

Jake Stine
06-28-2003, 04:40 PM
Originally posted by TJM
I read on MSDN that there is a myth that "DirectMusic chews up CPU cycles and RAM". Is this true?Yes. This is entirely true. Without a Soundblaster Live or better soundcard, DirectMusic will cheerfully consume quite a lot of ram and cpu time to mix the music. Unlike the old Windows media-based Midi player like you mentioned in your original post, DirectMusic uses a software mixer and digital samples. The older midi player used either the soundcard FM synthesizer (usually sounded pretty lousy) or built-in wavetable features supported on Soundblaster AWE32 cards and similar models. Both methods don't sound as good as directmusic, but use almost no CPU time.

I also read that DirectMusic in DirectX 9 has great improvements. I'm developing under DirectX 7. Did DirectMusic have problems with that version?In a sense, yes. If you are actually running DirectX 7 runtimes still (ie, you haven't installed a game that requires and installs DX9/DirectMusic 9), then you're using the old original DirectMusic software mixers, which are even slower than the ones in DX9. Switching to the DirectMusic 9 API should not be necessary; only upgrading to the DirectX 9 runtimes is (use WindowsUpdate). The DirectMusic 7 API should be able to utilize the new mixers-- but I don't know that for certain.

Does "everyone" use DirectMusic for their games or are some people still using the old Windows mutimedia?Very few people use DirectMusic for their games still. I only know of two or three indies who do off-hand, and possibly even fewer commercial developers do. Most of them use either Miles (http://www.radgametools.com/miles.htm) or FMOD (http://www.fmod.org), both of which are generally more stable, better supported by a wider range of systems, and a heckuva lot faster. But they can also cost you some money too, depending on what you are using them for.

- Air

TJM
06-28-2003, 05:40 PM
Thank you very much. The information you provided was very useful. It's just the things I wanted to know.

svero
06-28-2003, 07:08 PM
Incidentally once I fixed the problem cpu usage for sound went down to basically 0, so I'm not sure it's accurate to say that directmusic spends a lot of time mixing compared to fmod etc... Course I've never used the other libraries so perhaps they are comparitively fast. CPU usage for me with DM has always been negligeable.

Jake Stine
06-28-2003, 07:46 PM
Yeah, on any modern PC mixing sound is negligable (P3/athlon, etc), and having a good soundcard makes a huge difference obviously when dmusic is concerned. However, TJM's posts give me the impression that he's doing development on an older box so I suspect it's simply dmusic's slowness that's in the way more than anything.

When I was working on Winamp plugins back in 2000, we were experimenting with a dmusic version of a midi player. It ran fine on the developer's box (a P3/700) but drew over 40% of the CPU time on my P2/300 (often spiking much higher). By contrast, Mikamp and FMOD drew about 4-8% for comparative mixing demands, and regisered 0% on that P3. So yea, on faster machines even dmusic registers nearly 0%. Fast computers are wonderful at nullifiying the effects of slow code. It's all about percentages.

That was DirectMusic 7. DirectMusic 8/9 are both using much better software mixers and, according to microsoft, DX9 is almost 8x faster than 7. I don't find that too hard to believe considering how slow it used to be, but I don't always trust benchmark press releases either. ;)

- Air

bstone
06-28-2003, 08:53 PM
Posted by Jake Stine
Switching to the DirectMusic 9 API should not be necessary; only upgrading to the DirectX 9 runtimes is.This doesn’t make much sense IMHO. Even if it fixes the problem on TJM’s box, customers with older DirectX versions will experience slowdowns.

Also, there’s a big difference between the concepts under MIDI and FMOD. So it may be hard to switch from MIDI to "mod" music.

TJM
06-29-2003, 04:23 AM
I don't seem to notice any problems when I use DirectSound for my sound effects (wav files). Does DirectSound take a lot of processor time too or just DirectMusic?

Jake Stine
06-29-2003, 07:21 AM
Just DirectMusic. The two systems (dsound & dmusic) use entirely independent internal hardware abstraction and software emulation layers.

The rumor I heard as to why DirectMusic was so slow back in version 7 was because the mixer actually checks the bitdepth of the sample data every time it mixes a sample-- which is pretty dumb to say the least. There was some bizarre sense of logic behind the decision, mostly on the basis that directmusic was to have the most 'robust' flexable audio mixer ever, capable of mixing samples that actually contained both 8 and 16 bit data and were, therefore, more memory efficient or something.

More likely the programmers at the time just thought it would be nifty to create a single unified sample mixer instead of making several optimized mixers for the various supported audio formats, and since they were busy working away on their cutting edge P3 dev boxes, they neglected to realize the subtantial impact on performance all those conditions would have on slightly older CPU models that are far less capable of caching over jump boundries and doing accurate jump prediction. Oops.

TJM
06-29-2003, 09:26 AM
That's good to know. We're trying to use a version of DirectX that we hope some of our customers that have older computers may use. Many of our customers are somewhat computer illiterate and don't do well downloading the latest version of DirectX.

It's always difficult for us to decide how far backwards compatible we should make our games. We're trying to develop as far back as we can and still get a decent game. I think I make a post on that.

Thanks for all your help.