Fading out an audio clip

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
timbrian
Posts: 6
Joined: Sat Jan 17, 2015 12:51 am

Fading out an audio clip

Post by timbrian »

Developing a program with LiveCode 7 that has soundboard component where I can queue commercial spots. I can get the audio clips to play and stop, but
I want to also use a fade out control. I have looked high and low but can not find a sample script or any how to's.
I am developing the app for OS X . Just need to be pointed in the right direction. I am using the play audio clip ID xxxx command and play stop command.
Tim
Louisville, Ky
Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Fading out an audio clip

Post by Simon »

Hi timbrian,
How about this

Code: Select all

   repeat with x = 100 down to 0
        set the playLoudness to x
   end repeat
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Fading out an audio clip

Post by Klaus »

Hi Tim,

1. welcome to the forum! :D

2. To actually hear the fade-out you should add a little wait statement.
Without, well, it will sound like the sound got switched off immediately :D

Code: Select all

   repeat with x = 100 down to 0
        set the playLoudness to x
        wait 2 millisecs with messages
       ## play with the millisecs value
   end repeat
Or use something like this:

Code: Select all

## fade out in 1 second:
   repeat with x = 100 down to 0 STEP 10
        set the playLoudness to x
        wait 100 millisecs with messages
   end repeat
Best

Klaus
timbrian
Posts: 6
Joined: Sat Jan 17, 2015 12:51 am

Re: Fading out an audio clip

Post by timbrian »

Thanks Simon and Klaus for the help. That did the job!
Tim
Louisville, Ky
Post Reply