Skip to content

Commit

Permalink
Update documentation for core of single-sample branch. Also fix broke…
Browse files Browse the repository at this point in the history
…n merge or branch 'master' into SingleSample

Conflicts:
	src/audiolet/Audiolet.js
  • Loading branch information
oampo committed Apr 27, 2012
2 parents 06af428 + 6a622cd commit 67de132
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 47 deletions.
43 changes: 20 additions & 23 deletions src/audiolet/Audiolet.js
Expand Up @@ -540,8 +540,7 @@ AudioletNode.prototype.linkNumberOfOutputChannels = function(output, input) {
}; };


/** /**
* Process a buffer of samples, first pulling any necessary data from * Process samples a from each channel. This function should not be called
* higher up the processing graph. This function should not be called
* manually by users, who should instead rely on automatic ticking from * manually by users, who should instead rely on automatic ticking from
* connections to the AudioletDevice. * connections to the AudioletDevice.
*/ */
Expand All @@ -552,6 +551,12 @@ AudioletNode.prototype.tick = function() {
this.generate(); this.generate();
}; };


/**
* Traverse the audio graph, adding this and any parent nodes to the nodes
* array.
*
* @param {AudioletNode[]} nodes Array to add nodes to.
*/
AudioletNode.prototype.traverse = function(nodes) { AudioletNode.prototype.traverse = function(nodes) {
if (nodes.indexOf(this) == -1) { if (nodes.indexOf(this) == -1) {
nodes.push(this); nodes.push(this);
Expand All @@ -561,8 +566,7 @@ AudioletNode.prototype.traverse = function(nodes) {
}; };


/** /**
* Call the tick function on nodes which are connected to the inputs. This * Call the traverse function on nodes which are connected to the inputs.
* function should not be called manually by users.
*/ */
AudioletNode.prototype.traverseParents = function(nodes) { AudioletNode.prototype.traverseParents = function(nodes) {
var numberOfInputs = this.inputs.length; var numberOfInputs = this.inputs.length;
Expand All @@ -577,16 +581,16 @@ AudioletNode.prototype.traverseParents = function(nodes) {
}; };


/** /**
* Process a block of samples, reading from the input buffers and putting * Process a sample for each channel, reading from the inputs and putting new
* new values into the output buffers. Override me! * values into the outputs. Override me!
*/ */
AudioletNode.prototype.generate = function() { AudioletNode.prototype.generate = function() {
}; };


/** /**
* Create the input buffers by grabbing data from the outputs of connected * Create the input samples by grabbing data from the outputs of connected
* nodes and summing it. If no nodes are connected to an input, then * nodes and summing it. If no nodes are connected to an input, then
* give a one channel empty buffer. * give an empty array
*/ */
AudioletNode.prototype.createInputSamples = function() { AudioletNode.prototype.createInputSamples = function() {
var numberOfInputs = this.inputs.length; var numberOfInputs = this.inputs.length;
Expand Down Expand Up @@ -617,7 +621,7 @@ AudioletNode.prototype.createInputSamples = function() {




/** /**
* Create output buffers of the correct length. * Create output samples for each channel.
*/ */
AudioletNode.prototype.createOutputSamples = function() { AudioletNode.prototype.createOutputSamples = function() {
var numberOfOutputs = this.outputs.length; var numberOfOutputs = this.outputs.length;
Expand Down Expand Up @@ -1042,7 +1046,7 @@ var ParameterNode = function(audiolet, value) {
extend(ParameterNode, AudioletNode); extend(ParameterNode, AudioletNode);


/** /**
* Process a block of samples * Process samples
*/ */
ParameterNode.prototype.generate = function() { ParameterNode.prototype.generate = function() {
this.outputs[0].samples[0] = this.parameter.getValue(); this.outputs[0].samples[0] = this.parameter.getValue();
Expand Down Expand Up @@ -1080,12 +1084,10 @@ var PassThroughNode = function(audiolet, numberOfInputs, numberOfOutputs) {
extend(PassThroughNode, AudioletNode); extend(PassThroughNode, AudioletNode);


/** /**
* Create output buffers of the correct length, copying any input buffers to * Create output samples for each channel, copying any input samples to
* the corresponding outputs. * the corresponding outputs.
*
* @param {Number} length The number of samples for the resulting buffers.
*/ */
PassThroughNode.prototype.createOutputSamples = function(length) { PassThroughNode.prototype.createOutputSamples = function() {
var numberOfOutputs = this.outputs.length; var numberOfOutputs = this.outputs.length;
// Copy the inputs buffers straight to the output buffers // Copy the inputs buffers straight to the output buffers
for (var i = 0; i < numberOfOutputs; i++) { for (var i = 0; i < numberOfOutputs; i++) {
Expand Down Expand Up @@ -1257,10 +1259,8 @@ PriorityQueue.prototype.compare = function(a, b) {


/** /**
* A sample-accurate scheduler built as an AudioletNode. The scheduler works * A sample-accurate scheduler built as an AudioletNode. The scheduler works
* by storing a queue of events, and subdividing the tick call from the * by storing a queue of events, and running callback functions when the
* AudioletDevice if an event is scheduled to happen during the tick. Any * correct sample is being processed. All timing and events are handled in
* buffers obtained in subdivided ticks are finally merged to produce the
* single buffer expected at the output. All timing and events are handled in
* beats, which are converted to sample positions using a master tempo. * beats, which are converted to sample positions using a master tempo.
* *
* **Inputs** * **Inputs**
Expand Down Expand Up @@ -1418,11 +1418,8 @@ Scheduler.prototype.stop = function(event) {
}; };


/** /**
* Overridden tick method. This is where the scheduler magic of splitting down * Overridden tick method. Process any events which are due to take place
* blocks allows sample-accurate changes to happen, and also where we process * either now or previously.
* the events themselves.
*
* @param {Number} timestamp A timestamp for the block of samples.
*/ */
Scheduler.prototype.tick = function() { Scheduler.prototype.tick = function() {
PassThroughNode.prototype.tick.call(this); PassThroughNode.prototype.tick.call(this);
Expand Down
2 changes: 1 addition & 1 deletion src/audiolet/Audiolet.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 13 additions & 9 deletions src/core/AudioletNode.js
Expand Up @@ -96,8 +96,7 @@ AudioletNode.prototype.linkNumberOfOutputChannels = function(output, input) {
}; };


/** /**
* Process a buffer of samples, first pulling any necessary data from * Process samples a from each channel. This function should not be called
* higher up the processing graph. This function should not be called
* manually by users, who should instead rely on automatic ticking from * manually by users, who should instead rely on automatic ticking from
* connections to the AudioletDevice. * connections to the AudioletDevice.
*/ */
Expand All @@ -108,6 +107,12 @@ AudioletNode.prototype.tick = function() {
this.generate(); this.generate();
}; };


/**
* Traverse the audio graph, adding this and any parent nodes to the nodes
* array.
*
* @param {AudioletNode[]} nodes Array to add nodes to.
*/
AudioletNode.prototype.traverse = function(nodes) { AudioletNode.prototype.traverse = function(nodes) {
if (nodes.indexOf(this) == -1) { if (nodes.indexOf(this) == -1) {
nodes.push(this); nodes.push(this);
Expand All @@ -117,8 +122,7 @@ AudioletNode.prototype.traverse = function(nodes) {
}; };


/** /**
* Call the tick function on nodes which are connected to the inputs. This * Call the traverse function on nodes which are connected to the inputs.
* function should not be called manually by users.
*/ */
AudioletNode.prototype.traverseParents = function(nodes) { AudioletNode.prototype.traverseParents = function(nodes) {
var numberOfInputs = this.inputs.length; var numberOfInputs = this.inputs.length;
Expand All @@ -133,16 +137,16 @@ AudioletNode.prototype.traverseParents = function(nodes) {
}; };


/** /**
* Process a block of samples, reading from the input buffers and putting * Process a sample for each channel, reading from the inputs and putting new
* new values into the output buffers. Override me! * values into the outputs. Override me!
*/ */
AudioletNode.prototype.generate = function() { AudioletNode.prototype.generate = function() {
}; };


/** /**
* Create the input buffers by grabbing data from the outputs of connected * Create the input samples by grabbing data from the outputs of connected
* nodes and summing it. If no nodes are connected to an input, then * nodes and summing it. If no nodes are connected to an input, then
* give a one channel empty buffer. * give an empty array
*/ */
AudioletNode.prototype.createInputSamples = function() { AudioletNode.prototype.createInputSamples = function() {
var numberOfInputs = this.inputs.length; var numberOfInputs = this.inputs.length;
Expand Down Expand Up @@ -173,7 +177,7 @@ AudioletNode.prototype.createInputSamples = function() {




/** /**
* Create output buffers of the correct length. * Create output samples for each channel.
*/ */
AudioletNode.prototype.createOutputSamples = function() { AudioletNode.prototype.createOutputSamples = function() {
var numberOfOutputs = this.outputs.length; var numberOfOutputs = this.outputs.length;
Expand Down
2 changes: 1 addition & 1 deletion src/core/ParameterNode.js
Expand Up @@ -33,7 +33,7 @@ var ParameterNode = function(audiolet, value) {
extend(ParameterNode, AudioletNode); extend(ParameterNode, AudioletNode);


/** /**
* Process a block of samples * Process samples
*/ */
ParameterNode.prototype.generate = function() { ParameterNode.prototype.generate = function() {
this.outputs[0].samples[0] = this.parameter.getValue(); this.outputs[0].samples[0] = this.parameter.getValue();
Expand Down
6 changes: 2 additions & 4 deletions src/core/PassThroughNode.js
Expand Up @@ -21,12 +21,10 @@ var PassThroughNode = function(audiolet, numberOfInputs, numberOfOutputs) {
extend(PassThroughNode, AudioletNode); extend(PassThroughNode, AudioletNode);


/** /**
* Create output buffers of the correct length, copying any input buffers to * Create output samples for each channel, copying any input samples to
* the corresponding outputs. * the corresponding outputs.
*
* @param {Number} length The number of samples for the resulting buffers.
*/ */
PassThroughNode.prototype.createOutputSamples = function(length) { PassThroughNode.prototype.createOutputSamples = function() {
var numberOfOutputs = this.outputs.length; var numberOfOutputs = this.outputs.length;
// Copy the inputs buffers straight to the output buffers // Copy the inputs buffers straight to the output buffers
for (var i = 0; i < numberOfOutputs; i++) { for (var i = 0; i < numberOfOutputs; i++) {
Expand Down
13 changes: 4 additions & 9 deletions src/core/Scheduler.js
Expand Up @@ -4,10 +4,8 @@


/** /**
* A sample-accurate scheduler built as an AudioletNode. The scheduler works * A sample-accurate scheduler built as an AudioletNode. The scheduler works
* by storing a queue of events, and subdividing the tick call from the * by storing a queue of events, and running callback functions when the
* AudioletDevice if an event is scheduled to happen during the tick. Any * correct sample is being processed. All timing and events are handled in
* buffers obtained in subdivided ticks are finally merged to produce the
* single buffer expected at the output. All timing and events are handled in
* beats, which are converted to sample positions using a master tempo. * beats, which are converted to sample positions using a master tempo.
* *
* **Inputs** * **Inputs**
Expand Down Expand Up @@ -165,11 +163,8 @@ Scheduler.prototype.stop = function(event) {
}; };


/** /**
* Overridden tick method. This is where the scheduler magic of splitting down * Overridden tick method. Process any events which are due to take place
* blocks allows sample-accurate changes to happen, and also where we process * either now or previously.
* the events themselves.
*
* @param {Number} timestamp A timestamp for the block of samples.
*/ */
Scheduler.prototype.tick = function() { Scheduler.prototype.tick = function() {
PassThroughNode.prototype.tick.call(this); PassThroughNode.prototype.tick.call(this);
Expand Down

0 comments on commit 67de132

Please sign in to comment.