×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

sound on keypress??

sound on keypress??

sound on keypress??

(OP)
hi i am trying to create something that acts as a kind of midi keyboard but using a conventional ascii keyboard.  I have so far worked out how to call up sounds on keypress using this:

on keydown me
  if "1" = the key then
    sound(2).play(member("edgyrockguitar"))
  else if "2" = the key then
    sound(3).play(member("ambientguitar 3"))

and so on

i want to know if it is possible to keep a sound playing for the length of the keypress (i.e. like on an organ)

any ideas?????

much appreciated

RE: sound on keypress??

Hey I'm no expert but

I think if you can figure out how to get the sound to loop on keyDown then stop looping on keyUp that may be the best way to do it?

perhaps:

on keydown me
  if "1" = the key then
    sound(2).play(member("edgyrockguitar"))
    repeat/loop??
   end if
end

on keyUp me
   if "1" = the key then
    sound(2).stop(member("edgyrockguitar"))
   end if
end

Sorry i couldnt be anymore specific, someone else will no doubt reply, but im only a beginner but theoretically i think thats the right sort of idea...

Peter Butler
Tandokuno Design

RE: sound on keypress??

If you set the sound channel's "loopCount" to 0, the sound will loop forever. Once you set that you can just use keyUp/keyDown to start/stop the sound as Peter said.

Kenneth Kawamoto
www.materiaprima.co.uk

RE: sound on keypress??

Yay ^_^

Thanks for the input, im sure that will help!!

Useful thing to learn too i didnt know you could do that >_>

Peter Butler
Tandokuno Design

RE: sound on keypress??

(OP)
do i need to check the loop box for the sound member??? i dont have the sounds on the score either they are all in the ast and im calling them with that code.  I tried this:

on keydown me
  if "1" = the key then
    sound(2).play(member("edgyrockguitar"))
   
end if
end

on keyUp me
if "2"= the key then
sound(2).stop(member("edgyrockguitar"))
end if
end

but it doesnt work it replays the sound from the start on every press and the loop/repeat idea that goes below the .play section doesnt work either (script error)????>?

RE: sound on keypress??

Try:

--
on startMovie
  sound(2).queue([#member: member("edgyrockguitar"), #loopCount: 0])
end startMovie

on keyDown
  if the key = "1" then
    sound(2).play()   
  end if
end

on keyUp
  if the key = "1" then
    sound(2).pause()
  end if
end
--

Kenneth Kawamoto
www.materiaprima.co.uk

RE: sound on keypress??

(OP)
--sound(2).queue([#member: member("edgyrockguitar"), #loopCount: 0])

variable used beor assigned a value

sad

RE: sound on keypress??

(OP)
i use mx

RE: sound on keypress??

The following is the better way of doing this. I've verified it works fine on MX.

-- Movie script
on startMovie
  sound(2).queue([#member: member("edgyrockguitar"), #loopCount: 0])
  the keyDownScript = "handleMousedown"
  the keyUpScript = "handleKeyUp"
end startMovie

on handleMousedown
  if the key = "1" then
    sound(2).play()   
  end if
end handleMousedown

on handleKeyUp
  if the key = "1" then
    sound(2).pause()
  end if
end handleKeyUp
--

Kenneth Kawamoto
www.materiaprima.co.uk

RE: sound on keypress??

(OP)
Your saying this works on its own in mx - ive imported the script into a new file and it is still saying that in the first section (starting sound(2).queue...) there is a variable used before assigned value so how did you get it working?????????

RE: sound on keypress??

That's very interesting. I've just done copy & paste the script and it's fine - it's standard Lingo anyway.

Funny thing is that there are no variables in that line. Do you see the words "sound", "queue", "member" and "loopCount" all in green? Then they are not variables.

May be your Director itself is the problem. If you type in "put version" in the message window do you get "8.5.1"? If not, update.

Kenneth Kawamoto
www.materiaprima.co.uk

RE: sound on keypress??

(OP)
mine comes up 10.1 man! they are all in green

RE: sound on keypress??

10.1? That's Director 10 (a.k.a. "MX 2004").

Anyway I tested on D10 and the script works fine (however, "the key" should be "_key.key" in D10).

If you copy & paste sound(2).queue([#member: member("edgyrockguitar"), #loopCount: 0]) into Message window and press return, do you get the same error?

Kenneth Kawamoto
www.materiaprima.co.uk

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close