From 92d3c7a238bf1e2d4a5454eea7c767747ab8d018 Mon Sep 17 00:00:00 2001 From: Yotam Mann Date: Tue, 17 Jun 2014 12:15:10 -0400 Subject: [PATCH] doc'ing --- Tone/signal/Signal.js | 13 +++++++++---- Tone/source/Oscillator.js | 23 ++++++++++++++--------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Tone/signal/Signal.js b/Tone/signal/Signal.js index 8ebc85eb..349f783c 100644 --- a/Tone/signal/Signal.js +++ b/Tone/signal/Signal.js @@ -30,14 +30,19 @@ define(["Tone/core/Tone"], function(Tone){ generator.start(0); /** - * Signal + * constant audio-rate signal * - * audio rate value with ramping syncing - * useful for controlling AudioParams - * can sync to another Tone.Signal + * Tone.Signal is a core component which allows for synchronization of many components. + * A single signal can drive multiple parameters by applying Scaling. + * + * For example: to synchronize two Tone.Oscillators in octaves of each other, + * Signal --> OscillatorA.frequency + * ^--> Tone.Multiply(2) --> OscillatorB.frequency + * * * Tone.Signal can be scheduled with all of the functions available to AudioParams * + * * @constructor * @param {number=} value (optional) initial value */ diff --git a/Tone/source/Oscillator.js b/Tone/source/Oscillator.js index 8ea22719..021fdcfd 100644 --- a/Tone/source/Oscillator.js +++ b/Tone/source/Oscillator.js @@ -14,16 +14,21 @@ function(Tone){ Tone.Oscillator = function(freq, type){ Tone.Source.call(this); - //components + /** + * the main oscillator + * @type {OscillatorNode} + */ this.oscillator = this.context.createOscillator(); - this.control = new Tone.Signal(this.defaultArg(this.toFrequency(freq), 440)); + /** + * the frequency control signal + * @type {Tone.Signal} + */ + this.frequency = new Tone.Signal(this.defaultArg(this.toFrequency(freq), 440)); //connections this.oscillator.connect(this.output); - - //parameters + //setup this.oscillator.type = this.defaultArg(type, "sine"); - this.isSynced = false; }; Tone.extend(Tone.Oscillator, Tone.Source); @@ -43,7 +48,7 @@ function(Tone){ this.oscillator.detune.value = detune; //connect the control signal to the oscillator frequency this.oscillator.connect(this.output); - this.control.connect(this.oscillator.frequency); + this.frequency.connect(this.oscillator.frequency); this.oscillator.frequency.value = 0; //start the oscillator this.oscillator.start(this.toSeconds(time)); @@ -59,7 +64,7 @@ function(Tone){ * Transport start/pause/stop will also start/pause/stop the oscillator */ Tone.Oscillator.prototype.sync = function(){ - Tone.Transport.sync(this, this.control); + Tone.Transport.sync(this, this.frequency); }; /** @@ -67,7 +72,7 @@ function(Tone){ */ Tone.Oscillator.prototype.unsync = function(){ Tone.Transport.unsync(this); - this.control.unsync(); + this.frequency.unsync(); }; /** @@ -85,7 +90,7 @@ function(Tone){ * @param {Tone.Time=} rampTime when the oscillator will arrive at the frequency */ Tone.Oscillator.prototype.setFrequency = function(val, rampTime){ - this.control.exponentialRampToValueAtTime(this.toFrequency(val), this.toSeconds(rampTime)); + this.frequency.exponentialRampToValueAtTime(this.toFrequency(val), this.toSeconds(rampTime)); }; /**