audio and sound effects

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
prexsoccer
Posts: 29
Joined: Fri Jun 08, 2012 9:54 am

audio and sound effects

Post by prexsoccer » Fri Jun 08, 2012 9:57 am

sorry im totally new in this livecode.
im going to develop a game and i want to add sound effects on it like when the player punch an enemy.

anyone has an Idea about this? please share.
thank you.

best regard,
prex :)

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: audio and sound effects

Post by Klaus » Fri Jun 08, 2012 1:58 pm

Hi prex,

1. welcome to the forum! :)

2. check these stacks:
http://www.runrev.com/developers/lesson ... nferences/

3. regarding your question:
basically you just play a sound (file) at the right time, but you might need to be a TAD more specific about your question. 8)


Best

Klaus

prexsoccer
Posts: 29
Joined: Fri Jun 08, 2012 9:54 am

Re: audio and sound effects

Post by prexsoccer » Sat Jun 09, 2012 3:29 am

hi klaus,

thank you for the link that you provide,
If so happen that you have a sample script that would trigger a certain music

like:

on mouseUp
if player is jump then
play jump audio
else if player is running then
play running audio
end if
end mouseUp

hopefully I get your point and you get my point :)

thank you much :)

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: audio and sound effects

Post by Klaus » Sat Jun 09, 2012 4:17 pm

Hi prex,

OK, given that "tPlayer" (player is a reserved word in LiveCode!) is the name of a variable
and you want to check its content and act accordingly:

Code: Select all

...
if tPlayer = "jump" then
  play audioclip "jump.aif"
     else if tPlayer = "running" then

  ## audioclip can be abbreviated to ac
  play ac "running.aif"
end if
...
8)

Best

Klaus

prexsoccer
Posts: 29
Joined: Fri Jun 08, 2012 9:54 am

Re: audio and sound effects

Post by prexsoccer » Mon Jun 11, 2012 4:32 am

thank you klaus.

but one more thing. does it support mp3,mp4,mov files?

thank you for this sample code it solves my problem :)

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: audio and sound effects

Post by Klaus » Mon Jun 11, 2012 11:46 am

Hi prex,

the "play" command will only play uncompressed AIF and WAV and compressed AU sounds on hte desktop.
For MP3 etc. you need to use a "player" object.

Check the "Images and Multimedia" stack here:
http://www.runrev.com/developers/lesson ... nferences/


Best

Klaus

Post Reply