W3C home > Mailing lists > Public > public-audio@w3.org > October to December 2012

Feature request and a Chrome 22 bug?

From: Ray Bellis <ray@bellis.me.uk>
Date: Tue, 06 Nov 2012 11:42:46 -0500
Message-ID: <50993E06.3010909@bellis.me.uk>
To: public-audio@w3.org
On a little project I have going on just now (more of that in a week or
two) I was trying to create a filter whose frequency AudioParam was
controlled by an envelope generator, where the EG itself was a GainNode:

  vcfenv.connect(vcfgain);
  vcfgain.connect(filter1.frequency);

I wasn't getting anywhere getting this working, and finally realised
that it was because my GainNode had no input, and hence was producing no
output.

So first, the feature request - I think we need a SourceNode whose sole
job is to produce a _constant_ output.

It seems inefficient to use an a-rate BufferSourceNode or an Oscillator
just to be able to use a GainNode as a modulating source for another node.

In the absence of such a node, I used this code:

  function unitySourceNode(ctx) {
    var array = new Float32Array(1024);
    for (var i = 0, n = array.length; i < n; ++i) {
      array[i] = 1;
    }

    var buffer = ctx.createBuffer(1, array.length, ctx.sampleRate);
    buffer.getChannelData(0).set(array);

    var node = ctx.createBufferSource();
    node.buffer = buffer;
    node.loop = true;

    return node;
  };

This works on Chrome 25.0.1317.0 canary but doesn't work on Chrome 22 -
the node's "playBackState" appears stuck in "scheduled" even though I
called "node.noteOn(0)".

Does anyone have an equivalent that works on Chrome 22?

cheers,

Ray
Received on Tuesday, 6 November 2012 16:43:16 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:03:14 UTC