[Solved] Fade out audio

Get help using Construct 2

Post » Wed Apr 17, 2013 3:16 am

I know the new WebAudio support is capable of this, but I can't seem to figure out how to implement it. I want to be able to specify a ramp-down on the gain over a period of time. I actually have the low level calls, from the MIDI.js code, but I can't figure out how to get the C2 implementation to do the same thing.

From MIDI.js
    source.gain.linearRampToValueAtTime(1, delay);
    source.gain.linearRampToValueAtTime(0, delay + 0.2);
                        blackhornet2013-04-21 17:20:14
ImageImageImage
B
67
S
19
G
123
Posts: 3,214
Reputation: 73,915

Post » Wed Apr 17, 2013 3:18 am

don't you use lerp expression from current dB to zero db?
B
96
S
25
G
20
Posts: 3,055
Reputation: 22,644

Post » Wed Apr 17, 2013 3:32 am

That's old school. WebAudio can do this itself.
ImageImageImage
B
67
S
19
G
123
Posts: 3,214
Reputation: 73,915

Post » Thu Apr 18, 2013 1:44 am

@Ashley, you are probably the only one who can answer this. Thanks.
ImageImageImage
B
67
S
19
G
123
Posts: 3,214
Reputation: 73,915

Post » Sun Apr 21, 2013 5:19 pm

Figured it out. You apply a Gain effect with a gain of zero, so there is no immediate effect, and then call Set effect parameter when you want to fade, set to Filter/delay/gain gain with your final dB (negative to fade down), and the time period to fade over.

Sample here: GainTester.CAPX
ImageImageImage
B
67
S
19
G
123
Posts: 3,214
Reputation: 73,915


Return to How do I....?

Who is online

Users browsing this forum: YoHoho and 14 guests