Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 playing sound when any button is pressed
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
junkpro11




PostPosted: Sun May 09, 2004 10:34 am   Post subject: playing sound when any button is pressed

how do u play a sound whenever anything on the keyboard is pressed?
Sponsor
Sponsor
Sponsor
sponsor
Paul




PostPosted: Sun May 09, 2004 11:18 am   Post subject: (No subject)

This works Razz
code:

setscreen ("nocursor")
var key : string (1)
loop
getch (key)
Music.Play ("a")
end loop
Mazer




PostPosted: Sun May 09, 2004 11:43 am   Post subject: (No subject)

Shocked
How about this instead?
code:

setscreen ("nocursor")
var key : string (1)
loop
    if hasch then
        getch (key)
        Music.Play ("a")
    end if
end loop
junkpro11




PostPosted: Sun May 09, 2004 2:58 pm   Post subject: (No subject)

can u explain how the code works?

it would help alot
Dan




PostPosted: Sun May 09, 2004 3:40 pm   Post subject: (No subject)

code:

setscreen ("nocursor")

var key : string (1) %a char to store the keyinput

%main loop that keeps the progame runing
loop
   
    if hasch then %if a key has been hit on the key borad

        getch (key) %input the key in to the char var

        Music.Play ("a") %plays the note A like on a paino

    end if

end loop
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
s_climax




PostPosted: Sun May 09, 2004 4:37 pm   Post subject: (No subject)

It works better to do this.

code:

var key : string (1)
loop
getch (key)
Music.Play ("16a")
end loop
Mazer




PostPosted: Sun May 09, 2004 5:38 pm   Post subject: (No subject)

But that halts the program waiting for the user to give input, that's why I had the if statement with hasch.
recneps




PostPosted: Sun May 09, 2004 6:42 pm   Post subject: (No subject)

whgen i run that and hit the key before it stop, my comp bluscreens, wtf? :/
Sponsor
Sponsor
Sponsor
sponsor
Dan




PostPosted: Sun May 09, 2004 11:13 pm   Post subject: (No subject)

both verson work fine for me, dose your comp have a sound card?
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: