Multiple Sounds - Playing 1 sound in 2 separate instances

Started by
2 comments, last by benryves 20 years, 7 months ago
I''m sure you''re aware that if you have a sound (let''s call it "Fred"), then want to play it you go: Fred.Play xxxx (with xxxx for looping or not). However, what do I do if I want to play 2 of these sounds? I cannot seem to "mix" multiple instances of sounds together. A simple example would be the sound of a rocket exploding: this is quite a long wave file (2 secs) and so if 2 rockets hit within 1 sec of eachother or so the second one won''t make a sound. How do I get around this? I''m programming in DirectX8, Visual Basic 6, if you need to know. Thanks!

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

Advertisement
I jsut duplicate the same sound 2 or 3 times.. a bit wasteful, but thats the only easy way I know around this.

you can also play it throug direct music and assign SECONDARY_BUFFER flags to the audio path; this will eliminate the need for duplication, and you can play it as many times as your card supports (I.e. 1024 voices...).

www.cppnow.com
Exactly how do you dupe it? If I just "copy" it (with a set command, say) to another variable, it retains all the features of the original...

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

2 ways:

1) reload the same sound using your existing facilities into a new instance of your sound object (I am assuming you have a "MYWAVESOUND" class, or something equivalent, allowing loading, playing, pausing, volume, etc..., in easy to use syntax)

2) Within your class, implement a "duplicate()" method that uses the DirectSound facility: SoundBuffer8::DuplicateSoundBuffer(...) taking advantage of your existing interface objects...

Hope this helps.

www.cppnow.com

[edit] Spelling mistakes...

[edited by - superdeveloper on September 4, 2003 1:41:27 PM]

This topic is closed to new replies.

Advertisement