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 / music selector

Author
Message
octave
21
Years of Service
User Offline
Joined: 6th Apr 2003
Location: U.K
Posted: 9th Feb 2005 04:05
hi there everybody

i was wondering if anybody could help me in doing a routine so that you are able to select 5 different music tracks using ~~~~ 1 - 5(or any key) as when i've done it it still plays the last track from the last key pressed as was wondering if anybody could help me

attached is the source code done in dbpro

any help would be greatly appreciated
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 9th Feb 2005 04:46
Untested but you may want to try stopping the music that is already playing.



wmf
19
Years of Service
User Offline
Joined: 6th Nov 2004
Location:
Posted: 9th Feb 2005 07:09
you are in a loop so it plays last key over and over. use entry$() and then clear it.
Clueless
20
Years of Service
User Offline
Joined: 16th Feb 2004
Location: Corbin, KY, USA
Posted: 9th Feb 2005 08:16
Also be aware of the fact that the computer reads the keystrokes far more rapidly than you can press and release a key. When the human thinks they're simply pressing and releasing "1", the computer can read the keystroke and do the processing that you direct hundreds or thousands of times.

You should "debounce" your input. There are lots of ways to do this and the best way depends on what you're trying to accomplish. One way is to use a variable that holds the last keystroke input. Before taking an action, compare the keystroke you just read to the last keystroke. If they're the same, don't do anything -- it's just the "slow human" with their finger still on the key.

With music and sounds in DB, you've got another option -- check the value of MUSIC PLAYING() or SOUND PLAYING(). If the sound/music associated with the keystroke is already playing, do nothing. If the keystroke is associated with a DIFFERENT sound or song, stop the currently playing then start the new. IMHO, it's good to check whether a sound or song is already playing anyway; I've seen "already playing" errors before if the check isn't made.

Trivia (not exactly an answer to your question but maybe of interest) -- the debouncing is a little different if you're doing something like a pistol that shoots one shot at a time. If you just hold down the "fire" key, your pistol goes off like a very unreal machine gun. For something like this, I use a flag that gets cleared by a timer, and only process the keypress and fire then gun when the flag says I can.

Login to post a reply

Server time is: 2024-09-23 11:27:37
Your offset time is: 2024-09-23 11:27:37