W3C home > Mailing lists > Public > public-audio@w3.org > July to September 2012

getChannelData() in onAudioProcess

From: Peter van der Noord <peterdunord@gmail.com>
Date: Sun, 22 Jul 2012 13:33:42 +0200
Message-ID: <CAL9tNz_J+A4Fzf9v_56SSX1RZAbhaq0vqW4D+-HPFvk8Tmhcbw@mail.gmail.com>
To: public-audio@w3.org
Yay, I just made my first jsnode! When writing the event-callback....

onAudioProcess: function(event)
	{
                var inputArray = event.inputBuffer.getChannelData(0);
		var outputArray = event.outputBuffer.getChannelData(0);
		for(var i = 0; i < outputArray.length; i++)
		{
			outputArray[i] = // write stuff
		}
	}


... i wondered: what exactly do the getChannelData() methods do, or to
be more precise: what does the implementation do? Looking at the
behavior of nodes when they don't have outgoing connections (they
don't run in that case), i assume that one method requests a buffer
from whatever output is connected to its input, possibly
creating/copying/passing large buffers around.

Aren't those two methods rather heavy? I know they're not in the main
bufferwriting loop, but they still get hit quite a few times, and my
thought would be to remove as many functioncalls as possible from
onAudioProcess (and especially from the for-loop, obviously).


Peter
Received on Sunday, 22 July 2012 11:34:09 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 22 July 2012 11:34:10 GMT