Don't manage to modulate the playbackRate of a BufferSourceNode with an AudioNode

Hi all,

I have some code which I believe should work, but it doesn't ...

      var context = new AudioContext()
        , phasorNode = context.createBufferSource()
        , frequencyNode = context.createBufferSource()
        , bufferFrequency = context.createBuffer(1, context.sampleRate,
context.sampleRate)
        , arrayFrequency = bufferFrequency.getChannelData(0)
        , bufferRamp = context.createBuffer(1, context.sampleRate,
context.sampleRate)
        , arrayRamp = bufferRamp.getChannelData(0)
        , acc = 0, step = 1 / context.sampleRate, i

      for (i = 0; i < arrayRamp.length; i++) {
        arrayRamp[i] = (acc % 1)
        acc += step
      }

      for (i = 0; i < arrayFrequency.length; i++) {
        arrayFrequency[i] = 200
      }

      phasorNode.buffer = bufferRamp
      phasorNode.connect(context.destination)
      phasorNode.loop = true
      phasorNode.start(0)

      frequencyNode.buffer = bufferFrequency
      frequencyNode.connect(phasorNode.playbackRate)
      frequencyNode.loop = true
      frequencyNode.start(0)


Basically, the idea is I am trying to build a perfect sawtooth. The
"phasorNode" is just a ramp that is looped, and I would control the
sawtooth frequency by changing the value of playbackRate. However I want to
control this frequency by using another AudioNode (frequencyNode). It works
if I set the playbackRate by using setValueAtTime, but the frequencyNode
seems to have no effect ...

I really don't see why this doesn't work, but it doesn't ... so if somebody
has an explanation, I'd love to hear it :)

-- 

*Sébastien Piquemal*

 -----* @sebpiq*
 ----- http://github.com/sebpiq
 ----- http://funktion.fm

Received on Sunday, 29 March 2015 10:12:02 UTC