tomi.lee.jones
tomi.lee.jones

Reputation: 1553

Web Audio - AudioParam scheduling functions not working

I think i am completely missing something. None of the setValueAtTime(), linearRampToValueAtTime(), exponentialRampToValueAtTime(), setTargetAtTime() methods of the AudioParam interface are working for me. The simplest possible example below:

var context = new window.AudioContext();
gain = context.createGain();
gain.connect(context.destination);

// none of this is working, gain stays at 1
gain.gain.setValueAtTime(0.5, 0);
gain.gain.setValueAtTime(0.2, 1);

setInterval(function () {
    console.log(gain.gain.value);
}, 100);

The expected is that the gain will be 0.5 and after 1 second it will be 0.2. However, it stays at 1. Same happens for every other scheduling method. Nothing works. What is the problem?

Here's the fiddle: http://jsfiddle.net/twxyz/qbo4tLfr/

EDIT: Obviously those methods are fine. I did the test with the audio source and the gain is changing audibly. Then my question is why console keeps logging initial value?

Upvotes: 0

Views: 483

Answers (2)

tomi.lee.jones
tomi.lee.jones

Reputation: 1553

This seem to be an issue with the Firefox and had been reported as bug already: https://bugzilla.mozilla.org/show_bug.cgi?id=893020

Upvotes: 1

Raymond Toy
Raymond Toy

Reputation: 6048

The automation values are not exposed in the .value attribute. See computation of value, bullet item 1.

Upvotes: 1

Related Questions