Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Play sound - Repeated calls makes the previous ones stop instantly?

Author
Message
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 15th May 2011 17:51
I call numerous sounds in my game, and they all get along with each other pretty well, but i noticed that one special sound, mr. number 6 to be exact, which one is being called quite frequently, and is about 4 seconds long... just stops when it is played one more time.

So it never can be heard at two or more channels at once.

It is the 'rocket take off' take off in my game, and sounds quite stupid as many rockets fly up, but all the time, only the last one of them has sound.

Is this because of my sound card, or should i load in a type of sound like this into more than one slot to get it played numerous times in parallel?

-In.Dev.X: A unique heavy story based shoot'em ~25%
-CoreFleet: An underground commander unit based RTS ~15%
-TailsVSEggman: An Sonic themed RTS under development for idea presentation to Sega ~15%
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 15th May 2011 19:01
That is the way it should be (or at least the way it is ).
Every time you call "play sound x", sound x will reset to the beginning if it is already being played.
In order to achieve what you are after you will need to have one source sound and then clone it to various new ID's which will be played once and then deleted (deleting the clone will not remove the source sound and cloning is near instant) so that you may re-use that ID again at a later point.


"Why do programmers get Halloween and Christmas mixed up?"
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 15th May 2011 19:20
Aha-a, nice thank you!

-In.Dev.X: A unique heavy story based shoot'em ~25%
-CoreFleet: An underground commander unit based RTS ~15%
-TailsVSEggman: An Sonic themed RTS under development for idea presentation to Sega ~15%
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 15th May 2011 21:28
As far as someone said to me, cloning just instances the sound. Not put it to the test though, but I'll stick to that for now.

Warning! May contain Nuts!
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 15th May 2011 22:43
You mean it doesn't get its own number?

Which would mean it plays once and then gone for ever?

(..or stays in the memory and causes a memory overload error after a half hour play?..)

-In.Dev.X: A unique heavy story based shoot'em ~25%
-CoreFleet: An underground commander unit based RTS ~15%
-TailsVSEggman: An Sonic themed RTS under development for idea presentation to Sega ~15%
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 15th May 2011 23:08
I saw in another thread somewhere that the whole sound isn't copied, but the new sound number just points to the original sound. It sends that sound to the audio system with the new number as it's reference, so each instance plays the same sound data from the same location and tracks it's own progress and state in the sound data.

When you delete the clone, you're just deleting the reference information, but not the sound data.

That seems to make sense because in my tests hundreds of cloned sounds take up very little memory, and it's lightning fast.

WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 16th May 2011 01:51
Yep, exactly what KISTech said. Basically load you sound effects in and when you need to play them, clone and play. When the cloned sounds have finished, delete them. When you're done with the originals, delete them. Maybe my first explanation didn't fill in all the blanks... Sowwy...

Warning! May contain Nuts!
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 16th May 2011 09:41
When you clone a sound, it get's its own sound number, but the actual wave data is just referenced from the original sound rather than duplicating it and taking up more memory.

You may want to check out this sound function I wrote a few weeks ago. You can specify how many times a sound can be played over itself before it stops and replays from the beginning.

http://forum.thegamecreators.com/?m=forum_view&t=183703&b=6

Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 16th May 2011 11:19
I've just wrote a function like that myself, but thank you all for this rather unnatural activity

...Everybody is hungry for a little more life here, like me huh?

-In.Dev.X: A unique heavy story based shoot'em ~25%
-CoreFleet: An underground commander unit based RTS ~15%
-TailsVSEggman: An Sonic themed RTS under development for idea presentation to Sega ~15%
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 16th May 2011 18:49
I'd vote for a little more life in DBPro's sound commands! - like adding echo and stuff like that - I guess I should check for plugins that allow more freedom.

I always tend to make sound functions, it's good to be able to say, play this sound at this general position, then affect the volume and pan. It doesn't take a lot of time to get some nice effects going. I usually clone a sound effect 4 times, so there's 5 instances each - but also I use a controlling array, so each unique sound keeps track of how many sounds are still playing. I have found that when a lot of the same sound are playing, they can wash eachother out, so I tend to reduce the volume depending on sound activity.

Health, Ammo, and bacon and eggs!
AutoBot
16
Years of Service
User Offline
Joined: 25th Sep 2009
Location: Everywhere
Posted: 16th May 2011 20:03 Edited at: 16th May 2011 20:03
Quote: "I'd vote for a little more life in DBPro's sound commands!"

Yeah, one thing that I would suggest being added is asynchronous sound support, which is basically what Quel was talking about. Doesn't DirectX have a sound API that can do this?


Click for the voting thread!
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 16th May 2011 23:46
Quote: "I'd vote for a little more life in DBPro's sound commands! - like adding echo and stuff like that"


Didn't DB used to support EAX?

I thought we also had a BASS/FMOD plugin out there somewhere.

Login to post a reply

Server time is: 2026-07-11 09:30:26
Your offset time is: 2026-07-11 09:30:26