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 / I am trying to build a drum program but..

Author
Message
Slaughter
20
Years of Service
User Offline
Joined: 9th Mar 2004
Location:
Posted: 9th Mar 2004 16:55
the code:
do

Rem Load sounds
load sound "snare.wav",1
load sound "kick.wav",2
load sound "hi.wav",3

Rem press key
if keystate(2)=1 then play sound 1
if keystate(2)=0 then stop sound

if keystate(3)=1 then play sound 2
if keystate(3)=0 then stop sound

if keystate(4)=1 then play sound 3
if keystate(4)=0 then stop sound

if keystate(5)=1 then end

loop

the apologize: there could be littie mistakes in code becouse ı can't exactly remember it...

the matter: when ı run program and hit a key of 1, 2, or 3 the sound starts but not stops it continue till ı stop pressing.

the question: how could ı play that sound one time per one key hit?

the note: ı want that when ı hit all keys at the same time ı must take all sound.(it's drum you know.)

thanx for help.

You didn't choose where to born...
But you could choose HOW TO DIE!
Slaughter
Night Giant
21
Years of Service
User Offline
Joined: 26th Jul 2003
Location:
Posted: 9th Mar 2004 18:27
well, it should do what you said in the note if you are using keystates. but to get it to only play once you need to set up flags for each key, i.e. oldone=one : keystate(2)=one, then when you check for keypresses, check that one=1 and oldone=0, that way it will only play if that is so, which only last for one loop of your program while the key is held. hope that helps. btw: keep this flag principle in mind, it helps in many situations.

oh, wow. insignificantpunks.cjb.net. we like orange treble clef notes, just for future reference.

no: website for progs yet.
ReD_eYe
21
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 9th Mar 2004 20:45
its because you telling it to stop playing when the key is released...
do something like:

if keystate(3)=1 and sound playing(2)=0
play sound 2
endif

that way, your sound will only play if it isn't already playing and the right key is pressed

In the beginning, the universe was created...
This made alot of people very angry and it has been widely regarded as a bad idea...
Visit http://redeye.dbspot.com
Slaughter
20
Years of Service
User Offline
Joined: 9th Mar 2004
Location:
Posted: 10th Mar 2004 12:27
before everything: everybody! thanx for help
But nightgiant ı can't exactly understand what you mean. because I'm new on programming (3 weeks) and ı don't know the code you wrote. if you write it in my code or tell me where ı can use it ı could have a chance to use it. if it works there is no doubt ı will put your name in full credit at internet publish copy. so red_eye thanx to you too. ı don't try it yet but ı'm sure it will work. ı will make you know if it is ok at this page.

You didn't choose where to born...
But you could choose HOW TO DIE!
Slaughter
Slaughter
20
Years of Service
User Offline
Joined: 9th Mar 2004
Location:
Posted: 14th Mar 2004 00:51
red eye your code didn't work. or else ı put it to wrong place.

You didn't choose where to born...
But you could choose HOW TO DIE!
Slaughter
Saikoro
21
Years of Service
User Offline
Joined: 6th Oct 2003
Location: California
Posted: 14th Mar 2004 05:43
I believe night giant meant something like this:



Hope this helps.

-Vash the Stampede

"This world is LOVE and PEACE!" -Vash the Stampede

Login to post a reply

Server time is: 2024-11-26 07:45:03
Your offset time is: 2024-11-26 07:45:03