• Advertisement

Archived

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

playing 2 sound files at once

This topic is 5156 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 have a problem here...I''m using directshow to play media files but when I tried to play 2 media files (I tried using audio files) it didn''y play those two files and only play the one that been loaded first.... Is there any way to solve my problem and I want to use directshow.....

Share this post


Link to post
Share on other sites
Advertisement
Well zacharya,
As far as I know( Even i am new to the world of DX ), only one media file can be played over a primary segment and many ( I dont know how much exactly ) media files over a secondary segment. This is the case when two or more media files are to be played.

Share this post


Link to post
Share on other sites
I want to use for background music and sound effect which need at least playing two audio files at once.

Share this post


Link to post
Share on other sites
Like he said, you have to play it as a secondary segment.

Use DMUS_SEGF_SECONDARY.. also, try to search the forums first. I''m learning directinput and stuff right now as well, and this is probably the single most frequently asked question on the topic and has been answered countless times.

Share this post


Link to post
Share on other sites
the answer is: you have to sample your media files into one file/object to get played at run time, say I have music constantly on, but when I click my mouse button to shoot, it samples my gun shot into the music thereby giving the appearence of two files at once.

Or there may be a way around that, I would look into all the DirectX audio functions to see if there is one that will suit your needs.

EDIT: beat me to it iron-monkey

[edited by - tri-thanatos on January 13, 2004 12:15:47 PM]

Share this post


Link to post
Share on other sites
If your making a game and you want sound effects and background music... why use DirectShow? DirectSound doesn''t have any problems with blending sounds the way you want to. I''m just wondering if you''ve found something that DirectShow can do that I wasn''t aware. *shrugs*

Share this post


Link to post
Share on other sites
I want to use mp3 files.....
so if I want to play two audio files at once I have to use directsound??

Share this post


Link to post
Share on other sites
Well Zacharya, I don't know whether anyone can play mp3 files using DirectSound or DirectMusic coz, you would need a MP3 codec to decode the mp3 file and then sample it through your sound hardware. Well, good luck trying as i dont know much about it myself. As for playing two audio files at once, it is always easier to use the already available functions instead of say, RE-INVENTING THE WHEEL! ofcourse i dont have any problems on you rewrting it yourself but you would get the same results plus extra development time and no extra gain whatsoever.This is the same thing i have seen with many programmers.

As for Tri-Thantos: Its the same basic question i put it above....why re-invent the wheel? do you know that when you are playing a primary segment and play a secondary segment over it, it is already sampling both these sound files and providing the final waveform( electrical signals) to the speaker? I mean, even you can understand for yourself, there's only one wire going to the speaker and unless your speaker again has a onboard processor( LOL ) it wont do any further processing on the signals and will directly output sound. Again, to produce a final waveform, you need two seperate waveforms right? so, we have a primary segment and one or more secondary segments which is blended to produce a final output. If you have both files on the primary segment.....then should we call it a primary segment? There's much that can be said but it would be better if you picked a book on basic electronics and see how a speaker and soundcard works.As for the DirectX functions, they are already there...its the same thing that all of us have been using for quite a long time!!!!

EDIT: uhh...Zacharya, I think You should try using DirectMusic over DirectSound.Both have the very similar functions but DirectMusic has a bit more.

[edited by - iron_monkey on January 14, 2004 11:17:00 AM]

Share this post


Link to post
Share on other sites
It''s is rather difficult to get mp3''s running over directsound, but as far as I can tell it is rather difficult to get mp3''s running with anything. DirectSound can easily play multiple sound buffers at once, infact, I do this routinely. I wrote a game where I clapped once (you know, clapping your hands) and I recorded a single wav of this one clap, and I replay this sound with multiple sound buffers repeating the sound for a set duration and with random frequencies and it sounds very much like there are 20 people in the room clapping (with speaker panning it''s almost spooky)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
directshow plays mp3 files in 4 lines of code. well 6 if u want to clean up.

two lines to init dshow
one line to load the mp3
one line to play the mp3
and two lines to release dshow

i think you could use dshow for background music
and then use directsound for game sound fx
unless u cant use both dshow and dsound at the same time
but i think u can

Share this post


Link to post
Share on other sites
How would you play two sounds at once using direct music

Thanks

[edited by - dr_slash_uh on January 14, 2004 7:02:00 PM]

Share this post


Link to post
Share on other sites

  • Advertisement