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.

Newcomers DBPro Corner / Sound/Music Problem!

Author
Message
TheSherminator
13
Years of Service
User Offline
Joined: 20th Feb 2011
Location:
Posted: 24th May 2011 20:24
I am new to darkBASIC pro and I have came across a problem: when I write a line of code like this:

do
if spacekey()=1 then play sound 1
loop

The above code makes the sound play again and again then the spacekey is pressed, restarting again and again rather than finishing! Can someone help me please?
Takis76
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location: Greece
Posted: 25th May 2011 00:36 Edited at: 25th May 2011 00:43
The play sound command just plays the sound , nothing else.

There is a stop sound command if you want to stop your sound.If you want to play your sound when you press the space key , you need to create one variable as flag , which calls your sound once and when your key is released then play the sound again. Also there is the command Sound Playing , which returns 1 if sound is playing or 0 if stopped. If your sound is playing now , so , you can trap the already playing sound and do not make your sound plays again until the already playing sound finishes.

Also you can make and some trick , if your sound is 10 seconds long , then create a timer when the sound starts , you start the timer, and when the timer pass 10 seconds stop your sound , with this trick you can play sound with timer variables.

I use this kind of tricks to control my sounds in my game , also I have made and 3D sounds.

If you press sound and space , all sound commands will appear.

Or press F1 and go to sound commands , there are a lots of good sound commands.
Quel
15
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 25th May 2011 01:02
You need to clone the sound into separate ID numbers to be able to play more than one at the same time.

Calling play sound on the one already playing results in stopping that sound, and start again.

-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%
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 25th May 2011 10:41 Edited at: 25th May 2011 10:43
Yeah use the SOUND PLAYING() command as Takis76 mentioned. If you put it with the spacebar check you can limit the playing of the sound to only when the sound is not playing already.



Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-22 22:20:03
Your offset time is: 2024-11-22 22:20:03