Skip to main content
GameDev.net gamedev.net
🔒 Locked

Why doesnt MIDI sound right in DX MUSIC 8.0

Started by Dark Star Jun 29, 2003 at 8:40 AM 10 replies 900+ views
Original Post
Dark Star
Dark Star
Hi people, Im using Direct Music 8.0 and I am using it to play MIDI songs. When I play MIDI files using Windows Media player it sounds right of course. But when I play them in my application, they sound a little different. Such differences are: 1. Midi songs play with a little more tempo. 2. Some of the back beat has been removed, so it sound basic So my MIDI does not sound like how it did in Media player and in other apps. I am using Direct Music with no additional settings. Only setting Im using is DMUS_SEGF_SECONDARY to play multiple sounds at once. Can any body tell me how to sort this out. I thought DirectMusic was meant to make music sound the same no matter what? Please Help DarkStar UK
---------------------------------------------You Only Live Once - Don't be afriad to take chances.
Mastaba
Mastaba
The difference in the sound you are hearing is likely because the media player is using a different midi device. I know on mine I have 3 different internal midi devices, the DirectX Synth, Creative Synth, and hardware synth. And they each sound different. Just make it use the DirectX synth and you are ensured it will sound the same on all computers. So then the problem is reduced to simply making the midi sound good when played on the DirectX synth.

P.S. Just checked DXDiag, and what I referred to as the DirectX synth, is actually enumerated as the Microsoft Synth.

[edited by - Mastaba on June 29, 2003 12:13:15 PM]
Dark Star
Dark Star
I''ll have a look at it. Thanks for your help.

DarkStar
Uk
---------------------------------------------You Only Live Once - Don't be afriad to take chances.
Night Elf
Night Elf
I had the lost sounds problem before. I found that, to make it work the right way you must make sure you call the SetParam() function BEFORE you call Download() for the segment. Like this:


pDMSegment->SetParam(GUID_StandardMIDIFile, 0xFFFFFFFF, 0, 0, NULL);
pDMSegment->Download(pDMPerformance);


Hope it helps.

[edited by - Night Elf on June 29, 2003 2:12:44 PM]
Mastaba
Mastaba
You could also install the DirectMusic Producer, and save the midi as a DirectMusic segment file, and use that instead of the midi file. Either way will solve the missing sounds. Plus with the DirectMusic Producer, you could tweak the segment anyway you wanted.

Edit: Converting the midi to the generic segment format, while preserving tracks, does involve more work than simply loading the midi and saving the segment. Didn't mean to give that impression.


[edited by - Mastaba on June 29, 2003 3:02:09 PM]
Dark Star
Dark Star
Hey NightElf, thanks for the help but it still does not solve the problem. Could it be that the MIDI file is just an awkward one that Windows somehow knows how to play? Sounds like a silly excuse but I havenot got a clue!

My general understanding is if Windows Media player can play it right, DirectMusic should be able to play it the same way somehow.

Confused

DarkStar
UK

---------------------------------------------You Only Live Once - Don't be afriad to take chances.
Night Elf
Night Elf
I don''t think there''s such thing as awkward MIDI file (The MIDI format is quite simple.) It most probably is a problem in your code.

Have you tried playing your MIDI file with the DirectMusic PalyAudio sample that comes with the SDK? If that works OK, you may want to look at the sample''s source code and try to fix your own.
Dark Star
Dark Star
Thanks for all your help...I have now figured out why my sounds play strangely. It was because I used the constant DMUS_SEGF_SECONDARY in PlaySegmentEx() as dwFlags in order to play multiple sounds. when I reset this back to 0 the sounds played well. This means now I cannot play multiple sounds using the IDirectMusicPerformance8 interface. because when I want to start another one, the current one will stop to allow the new one to start.

My intention was to use DirectMusic for playing WAVS and MIDI and totally ignore DirectSound. It was working when I used DMUS_SEGF_SECONDARY and waves were playing perfectly and SOME midis played well others didnt.

Now my only options are:

1. Insert as a field in my music struct a IDirectMusicPerformance8 ptr, so that for each sound to play there is a different DirectMusicPerformance to play it. This was my first approach and worked well, but I feared its a big memory drainer.So I changed to one Performance and used DMUS_SEGF_DEFAULT in PlaySegmentEx

2. Use DirectMusic to play one song at a time and then use DirectSound to play multiple waves at same time.


Unless anyone can come up with anything better.I''m glad Ive got somewhere but annoyed its messing me around.


Thanks for the help

DarkStar
UK
---------------------------------------------You Only Live Once - Don't be afriad to take chances.
Night Elf
Night Elf
You don't need several performances and you don't need DirectSound:

You have to differenciate between segments. You can only play one MIDI segment at a time, but you can play several wave segments simmultaneously.

What you must do is use the IDirectMusicPerformance8:: PlaySegment[Ex]() function, changin the dwFlags parameter according to the segment to be played: 0 for MIDI segments, DMUS_SEGF_SECONDARY for wave sounds.

Maybe you can structure your sounds using a class Segment wich defines the Play() method. Segment would have two subclasses: WaveSegment and MIDISegment, each one redefining the Play() method for that particular kind of segment.

[Edit: I hate automatic smileys]

[edited by - Night Elf on June 30, 2003 12:45:27 PM]
superdeveloper
superdeveloper
option 3) Create multiple Music Performances, each playing its own midi file.

why would you omit this option?

I wrote an app that created 10 separate performances and all play flawlessly. People seem to think that you should have only 1 per application. not true.

People also think that you must have only 1 directsound object, which is also false.


www.cppnow.com
Dark Star
Dark Star
Thanks for all ur help guys. Night Elf, I tried what u said and it works... I got two play functions for my wrapper:

DXDPlaySound (id);
DXDPlayMusic (id);


the DXDPlaySound function will play waves and DXDPlayMusic will play MIDI....the only difference is that one uses PlaySegmentEx with dwFlags set as 0 (for MIDIS) and PlaySegmentex with dxFlags set as DMUS_SEGF_SECONDARY (for multiple wave sounds).

I guess I didnt need 2 seperate functions which are pretty much Identical but one which has a flag u pass to play which ever one. But my implementation is not important here.


It works and thats good enough.

Thanks Guys for everything.I wouldnt have made it with out u or would have taken bloody long time.

Cheers

DarkStar
UK
---------------------------------------------You Only Live Once - Don't be afriad to take chances.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.