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 / ive forgot (Playing sounds on key presses)

Author
Message
z i l c h vortex
17
Years of Service
User Offline
Joined: 20th Feb 2007
Location: united kingdom
Posted: 11th Jun 2007 01:03
GUYS ive forgot most of the things i can do in db now so i need help could someone help me.
i was wondering if anyone knows how to make it so when you press a button it plays a sound and dosnt repeat it because i have decided to start a drum game so any help will help me

life is short but so am i
Cloggy
20
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 11th Jun 2007 01:22
I've written a small code snippet to handle keypresses, it allows keys that have to be release before you can press them again, keys that toggle on and off and keys that repeat after a set time.

See here

Hopefully you'll find it useful.

D3DFunc - Superfast Antialiased text & much much more
Gil Galvanti
19
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Texas, United States
Posted: 11th Jun 2007 01:31



z i l c h vortex
17
Years of Service
User Offline
Joined: 20th Feb 2007
Location: united kingdom
Posted: 12th Jun 2007 00:40
what formats of music does dbpro support eg .ogg .mp3 etc

life is short but so am i
z i l c h vortex
17
Years of Service
User Offline
Joined: 20th Feb 2007
Location: united kingdom
Posted: 12th Jun 2007 01:42
when i press a key it play a sound but it plays it loads of times at once is there any way of making it play once every key hit

life is short but so am i
Tom J
19
Years of Service
User Offline
Joined: 4th Aug 2005
Location: Essex, England
Posted: 12th Jun 2007 18:46
Quote: "what formats of music does dbpro support eg .ogg .mp3 etc"


Music: .mp3, .midi
Sound: .wav, .aiff, .au, .snd

Text adventure competition 2007 - Click here to find out more
z i l c h vortex
17
Years of Service
User Offline
Joined: 20th Feb 2007
Location: united kingdom
Posted: 12th Jun 2007 19:00 Edited at: 12th Jun 2007 19:08
thank you do you know how i could change this so that is only playes once every key press


is not much but its a start

p.s. does anyone know were i can find the scancodes for the keyboard for dbp

life is short but so am i
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 12th Jun 2007 23:39
hallo z i l c h vortex .. try this code...i think you could udjust it.. good luck




oh my god
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 13th Jun 2007 00:55
Zilch, read the replies that have been posted! They have shown you how to do it.

If you use the search function for Scancode you will find lots of relevant posts.

Cloggy
20
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 13th Jun 2007 16:52
Here is some code that will play a sound when you press a key. It will only play it again if you release the key and press it again.

It uses my key monitor code which hopefully simplifies the process.

I have included to wav files for testing. Unfortunately I cannot test this fully at the moment as my work PC does not have speakers, but I will try this later when I get home.

Here is the actual code, but this is included in the zip as you also require my scancodes.dba file.



D3DFunc - Superfast Antialiased text & much much more

Attachments

Login to view attachments
z i l c h vortex
17
Years of Service
User Offline
Joined: 20th Feb 2007
Location: united kingdom
Posted: 13th Jun 2007 18:47 Edited at: 13th Jun 2007 18:49
thank you for this guys its been a great help do you no anyways to do it so when you press the key it plays once per key press but without using any other dlls and includes do you know how to do it jst with darkbasicpro any help will do

life is short but so am i
Cloggy
20
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 13th Jun 2007 20:20
What I gave you was pure DB. just had the functions included in the include file

Here is some basic code. I'm sure you can optimise it. but I wrote the functions to make this really simple so I dont' see why you would want to do it this way.



D3DFunc - Superfast Antialiased text & much much more
z i l c h vortex
17
Years of Service
User Offline
Joined: 20th Feb 2007
Location: united kingdom
Posted: 13th Jun 2007 21:46
Thank you cloggy

life is short but so am i
z i l c h vortex
17
Years of Service
User Offline
Joined: 20th Feb 2007
Location: united kingdom
Posted: 13th Jun 2007 22:39
when i add another letter say a q everything does the if u press a key it plays loads of times if any of you have msn and you rekon you can help me add IDH_Josh@hotmail.com


if you cant it doesnt matter thank you guys

life is short but so am i
Cloggy
20
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 13th Jun 2007 23:01
post the code so we can have a look and tell you what the problem is. That way if someone has a similar question in the future then can find a solution here.

D3DFunc - Superfast Antialiased text & much much more
z i l c h vortex
17
Years of Service
User Offline
Joined: 20th Feb 2007
Location: united kingdom
Posted: 14th Jun 2007 15:13
heres the code you asked for cloggy


life is short but so am i
Cloggy
20
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 14th Jun 2007 15:37
This is what you should use



the cpressed variable is used to track the state of the 'C' key. Therefore you need another valiable to track the 'V' key. That's why I created the functions to simplify things.

D3DFunc - Superfast Antialiased text & much much more
z i l c h vortex
17
Years of Service
User Offline
Joined: 20th Feb 2007
Location: united kingdom
Posted: 14th Jun 2007 16:43
thank you o mighty cloggy thank you

life is short but so am i

Login to post a reply

Server time is: 2024-11-25 17:24:46
Your offset time is: 2024-11-25 17:24:46