normalizing whitespace in comments

This commit is contained in:
Yotam Mann 2019-09-14 16:39:18 -04:00
parent 829a7ebd2c
commit 261a5f4c3b
92 changed files with 840 additions and 839 deletions

View file

@ -23,17 +23,17 @@ export class Analyser extends ToneAudioNode<AnalyserOptions> {
readonly output: AnalyserNode;
/**
* The analyser node.
* The analyser node.
*/
private _analyser = this.context.createAnalyser();
/**
* The analysis type
* The analysis type
*/
private _type!: AnalyserType;
/**
* The buffer that the FFT data is written to
* The buffer that the FFT data is written to
*/
private _buffer!: Float32Array;
@ -61,7 +61,7 @@ export class Analyser extends ToneAudioNode<AnalyserOptions> {
}
/**
* Run the analysis given the current settings and return the
* Run the analysis given the current settings and return the
*/
getValue(): Float32Array {
if (this._type === "fft") {
@ -73,7 +73,7 @@ export class Analyser extends ToneAudioNode<AnalyserOptions> {
}
/**
* The size of analysis. This must be a power of two in the range 16 to 16384.
* The size of analysis. This must be a power of two in the range 16 to 16384.
*/
get size(): PowerOfTwo {
return this._analyser.frequencyBinCount;
@ -84,7 +84,7 @@ export class Analyser extends ToneAudioNode<AnalyserOptions> {
}
/**
* The analysis function returned by analyser.getValue(), either "fft" or "waveform".
* The analysis function returned by analyser.getValue(), either "fft" or "waveform".
*/
get type(): AnalyserType {
return this._type;
@ -95,7 +95,7 @@ export class Analyser extends ToneAudioNode<AnalyserOptions> {
}
/**
* 0 represents no time averaging with the last analysis frame.
* 0 represents no time averaging with the last analysis frame.
*/
get smoothing(): NormalRange {
return this._analyser.smoothingTimeConstant;
@ -106,7 +106,7 @@ export class Analyser extends ToneAudioNode<AnalyserOptions> {
}
/**
* Clean up.
* Clean up.
*/
dispose(): this {
super.dispose();

View file

@ -28,7 +28,7 @@ export class DCMeter extends MeterBase<DCMeterOptions> {
}
/**
* Get the signal value of the incoming signal
* Get the signal value of the incoming signal
*/
getValue(): number {
const value = this._analyser.getValue();

View file

@ -48,17 +48,17 @@ export class FFT extends MeterBase<FFTOptions> {
}
/**
* Gets the current frequency data from the connected audio source.
* Returns the frequency data of length [[size]] as a Float32Array of decibel values.
* Gets the current frequency data from the connected audio source.
* Returns the frequency data of length [[size]] as a Float32Array of decibel values.
*/
getValue(): Float32Array {
return this._analyser.getValue().map(v => this.normalRange ? dbToGain(v) : v);
}
/**
* The size of analysis. This must be a power of two in the range 16 to 16384.
* Determines the size of the array returned by [[getValue]] (i.e. the number of
* frequency bins). Large FFT sizes may be costly to compute.
* The size of analysis. This must be a power of two in the range 16 to 16384.
* Determines the size of the array returned by [[getValue]] (i.e. the number of
* frequency bins). Large FFT sizes may be costly to compute.
*/
get size(): PowerOfTwo {
return this._analyser.size;
@ -68,7 +68,7 @@ export class FFT extends MeterBase<FFTOptions> {
}
/**
* 0 represents no time averaging with the last analysis frame.
* 0 represents no time averaging with the last analysis frame.
*/
get smoothing(): NormalRange {
return this._analyser.smoothing;

View file

@ -10,7 +10,7 @@ export interface WaveformOptions extends MeterBaseOptions {
}
/**
* Get the current waveform data of the connected audio source.
* Get the current waveform data of the connected audio source.
*/
export class Waveform extends MeterBase<WaveformOptions> {
@ -45,8 +45,8 @@ export class Waveform extends MeterBase<WaveformOptions> {
}
/**
* The size of analysis. This must be a power of two in the range 16 to 16384.
* Determines the size of the array returned by [[getValue]].
* The size of analysis. This must be a power of two in the range 16 to 16384.
* Determines the size of the array returned by [[getValue]].
*/
get size(): PowerOfTwo {
return this._analyser.size;

View file

@ -89,9 +89,9 @@ export class CrossFade extends ToneAudioNode<CrossFadeOptions> {
readonly input: undefined;
/**
* The mix between the two inputs. A fade value of 0
* will output 100% crossFade.a and
* a value of 1 will output 100% crossFade.b.
* The mix between the two inputs. A fade value of 0
* will output 100% crossFade.a and
* a value of 1 will output 100% crossFade.b.
*/
readonly fade: Signal<NormalRange>;

View file

@ -24,7 +24,7 @@ export class Merge extends ToneAudioNode<MergeOptions> {
readonly name: string = "Merge";
/**
* The merger node for the two channels.
* The merger node for the two channels.
*/
private _merger: ChannelMergerNode;

View file

@ -15,7 +15,7 @@ export class Mono extends ToneAudioNode<MonoOptions> {
readonly name: string = "Mono";
/**
* merge the signal
* merge the signal
*/
private _merge: Merge;

View file

@ -13,8 +13,8 @@ interface MultibandSplitOptions extends ToneAudioNodeOptions {
}
/**
* Split the incoming signal into three bands (low, mid, high)
* with two crossover frequency controls.
* Split the incoming signal into three bands (low, mid, high)
* with two crossover frequency controls.
* ```
* +----------------------+
* +-> input < lowFrequency +------------------> low
@ -34,7 +34,7 @@ export class MultibandSplit extends ToneAudioNode<MultibandSplitOptions> {
readonly name: string = "MultibandSplit";
/**
* the input
* the input
*/
readonly input = new Gain({ context: this.context });
@ -44,7 +44,7 @@ export class MultibandSplit extends ToneAudioNode<MultibandSplitOptions> {
readonly output = undefined;
/**
* The low band.
* The low band.
*/
readonly low = new Filter({
context: this.context,
@ -53,7 +53,7 @@ export class MultibandSplit extends ToneAudioNode<MultibandSplitOptions> {
});
/**
* the lower filter of the mid band
* the lower filter of the mid band
*/
private _lowMidFilter = new Filter({
context: this.context,
@ -62,7 +62,7 @@ export class MultibandSplit extends ToneAudioNode<MultibandSplitOptions> {
});
/**
* The mid band output.
* The mid band output.
*/
readonly mid = new Filter({
context: this.context,
@ -71,7 +71,7 @@ export class MultibandSplit extends ToneAudioNode<MultibandSplitOptions> {
});
/**
* The high band output.
* The high band output.
*/
readonly high = new Filter({
context: this.context,
@ -80,19 +80,19 @@ export class MultibandSplit extends ToneAudioNode<MultibandSplitOptions> {
});
/**
* The low/mid crossover frequency.
* The low/mid crossover frequency.
*/
readonly lowFrequency: Signal<Frequency>;
/**
* The mid/high crossover frequency.
* The mid/high crossover frequency.
*/
readonly highFrequency: Signal<Frequency>;
protected _internalChannels = [this.low, this.mid, this.high];
/**
* The Q or Quality of the filter
* The Q or Quality of the filter
*/
readonly Q: Signal<Positive>;
@ -147,7 +147,7 @@ export class MultibandSplit extends ToneAudioNode<MultibandSplitOptions> {
}
/**
* Clean up.
* Clean up.
*/
dispose(): this {
super.dispose();

View file

@ -31,17 +31,17 @@ export class PanVol extends ToneAudioNode<PanVolOptions> {
private _panner: Panner;
/**
* The L/R panning control.
* The L/R panning control.
*/
readonly pan: Param<AudioRange>;
/**
* The volume node
* The volume node
*/
private _volume: Volume;
/**
* The volume control in decibels.
* The volume control in decibels.
*/
readonly volume: Param<Decibels>;

View file

@ -19,14 +19,14 @@ export class Panner extends ToneAudioNode<TonePannerOptions> {
readonly name: string = "Panner";
/**
* the panner node
* the panner node
*/
private _panner: StereoPannerNode = this.context.createStereoPanner();
readonly input: StereoPannerNode = this._panner;
readonly output: StereoPannerNode = this._panner;
/**
* The pan control. -1 = hard left, 1 = hard right.
* The pan control. -1 = hard left, 1 = hard right.
*/
readonly pan: Param<AudioRange>;

View file

@ -21,7 +21,7 @@ export interface Panner3DOptions extends ToneAudioNodeOptions {
}
/**
* A spatialized panner node which supports equalpower or HRTF panning.
* A spatialized panner node which supports equalpower or HRTF panning.
*/
export class Panner3D extends ToneAudioNode<Panner3DOptions> {
@ -117,7 +117,7 @@ export class Panner3D extends ToneAudioNode<Panner3DOptions> {
}
/**
* Sets the position of the source in 3d space.
* Sets the position of the source in 3d space.
*/
setPosition(x: number, y: number, z: number): this {
this.positionX.value = x;
@ -127,7 +127,7 @@ export class Panner3D extends ToneAudioNode<Panner3DOptions> {
}
/**
* Sets the orientation of the source in 3d space.
* Sets the orientation of the source in 3d space.
*/
setOrientation(x: number, y: number, z: number): this {
this.orientationX.value = x;
@ -137,7 +137,7 @@ export class Panner3D extends ToneAudioNode<Panner3DOptions> {
}
/**
* The panning model. Either "equalpower" or "HRTF".
* The panning model. Either "equalpower" or "HRTF".
*/
get panningModel(): PanningModelType {
return this._panner.panningModel;
@ -147,7 +147,7 @@ export class Panner3D extends ToneAudioNode<Panner3DOptions> {
}
/**
* A reference distance for reducing volume as source move further from the listener
* A reference distance for reducing volume as source move further from the listener
*/
get refDistance(): number {
return this._panner.refDistance;
@ -157,7 +157,7 @@ export class Panner3D extends ToneAudioNode<Panner3DOptions> {
}
/**
* Describes how quickly the volume is reduced as source moves away from listener.
* Describes how quickly the volume is reduced as source moves away from listener.
*/
get rolloffFactor(): number {
return this._panner.rolloffFactor;
@ -167,7 +167,7 @@ export class Panner3D extends ToneAudioNode<Panner3DOptions> {
}
/**
* The distance model used by, "linear", "inverse", or "exponential".
* The distance model used by, "linear", "inverse", or "exponential".
*/
get distanceModel(): DistanceModelType {
return this._panner.distanceModel;
@ -177,7 +177,7 @@ export class Panner3D extends ToneAudioNode<Panner3DOptions> {
}
/**
* The angle, in degrees, inside of which there will be no volume reduction
* The angle, in degrees, inside of which there will be no volume reduction
*/
get coneInnerAngle(): Degrees {
return this._panner.coneInnerAngle;
@ -187,8 +187,8 @@ export class Panner3D extends ToneAudioNode<Panner3DOptions> {
}
/**
* The angle, in degrees, outside of which the volume will be reduced
* to a constant value of coneOuterGain
* The angle, in degrees, outside of which the volume will be reduced
* to a constant value of coneOuterGain
*/
get coneOuterAngle(): Degrees {
return this._panner.coneOuterAngle;
@ -198,7 +198,7 @@ export class Panner3D extends ToneAudioNode<Panner3DOptions> {
}
/**
* The gain outside of the coneOuterAngle
* The gain outside of the coneOuterAngle
*/
get coneOuterGain(): GainFactor {
return this._panner.coneOuterGain;
@ -208,8 +208,8 @@ export class Panner3D extends ToneAudioNode<Panner3DOptions> {
}
/**
* The maximum distance between source and listener,
* after which the volume will not be reduced any further.
* The maximum distance between source and listener,
* after which the volume will not be reduced any further.
*/
get maxDistance(): number {
return this._panner.maxDistance;

View file

@ -64,9 +64,9 @@ export class Solo extends ToneAudioNode<SoloOptions> {
private static _soloed: Map<Context, Set<Solo>> = new Map();
/**
* Isolates this instance and mutes all other instances of Solo.
* Only one instance can be soloed at a time. A soloed
* instance will report `solo=false` when another instance is soloed.
* Isolates this instance and mutes all other instances of Solo.
* Only one instance can be soloed at a time. A soloed
* instance will report `solo=false` when another instance is soloed.
*/
get solo(): boolean {
return this._isSoloed();
@ -81,7 +81,7 @@ export class Solo extends ToneAudioNode<SoloOptions> {
}
/**
* If the current instance is muted, i.e. another instance is soloed
* If the current instance is muted, i.e. another instance is soloed
*/
get muted(): boolean {
return this.input.gain.value === 0;
@ -124,7 +124,7 @@ export class Solo extends ToneAudioNode<SoloOptions> {
}
/**
* Solo the current instance and unsolo all other instances.
* Solo the current instance and unsolo all other instances.
*/
private _updateSolo(): void {
if (this._isSoloed()) {

View file

@ -37,7 +37,7 @@ export class Volume extends ToneAudioNode<VolumeOptions> {
private _unmutedVolume: Decibels;
/**
* The volume control in decibels.
* The volume control in decibels.
*/
volume: Param<Decibels>;
@ -92,7 +92,7 @@ export class Volume extends ToneAudioNode<VolumeOptions> {
}
/**
* clean up
* clean up
*/
dispose(): this {
super.dispose();

View file

@ -26,19 +26,19 @@ export class Compressor extends ToneAudioNode<CompressorOptions> {
readonly name: string = "Compressor";
/**
* the compressor node
* the compressor node
*/
private _compressor: DynamicsCompressorNode = this.context.createDynamicsCompressor();
readonly input = this._compressor;
readonly output = this._compressor;
/**
* The decibel value above which the compression will start taking effect.
* The decibel value above which the compression will start taking effect.
*/
readonly threshold: Param<Decibels>;
/**
* The amount of time (in seconds) to reduce the gain by 10dB.
* The amount of time (in seconds) to reduce the gain by 10dB.
*/
readonly attack: Param<Time>;

View file

@ -36,11 +36,11 @@ export class AmplitudeEnvelope extends Envelope {
/**
* @param attack The amount of time it takes for the envelope to go from 0 to it's maximum value.
* @param decay The period of time after the attack that it takes for the envelope
* to fall to the sustain value. Value must be greater than 0.
* to fall to the sustain value. Value must be greater than 0.
* @param sustain The percent of the maximum value that the envelope rests at until
* the release is triggered.
* the release is triggered.
* @param release The amount of time after the release is triggered it takes to reach 0.
* Value must be greater than 0.
* Value must be greater than 0.
*/
constructor(attack?: Time, decay?: Time, sustain?: NormalRange, release?: Time);
constructor(options?: Partial<EnvelopeOptions>)

View file

@ -20,9 +20,9 @@ export interface EnvelopeOptions extends ToneAudioNodeOptions {
}
/**
* Envelope is an [ADSR](https://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope)
* envelope generator. Envelope outputs a signal which
* can be connected to an AudioParam or Tone.Signal.
* Envelope is an [ADSR](https://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope)
* envelope generator. Envelope outputs a signal which
* can be connected to an AudioParam or Tone.Signal.
* ```
* /\
* / \
@ -85,9 +85,9 @@ export class Envelope extends ToneAudioNode<EnvelopeOptions> {
decay: Time;
/**
* The sustain value is the value
* which the envelope rests at after triggerAttack is
* called, but before triggerRelease is invoked.
* The sustain value is the value
* which the envelope rests at after triggerAttack is
* called, but before triggerRelease is invoked.
* ```
* /\
* / \
@ -103,9 +103,9 @@ export class Envelope extends ToneAudioNode<EnvelopeOptions> {
sustain: NormalRange;
/**
* After triggerRelease is called, the envelope's
* value will fall to it's miminum value over the
* duration of the release time.
* After triggerRelease is called, the envelope's
* value will fall to it's miminum value over the
* duration of the release time.
* ```
* /\
* / \
@ -121,22 +121,22 @@ export class Envelope extends ToneAudioNode<EnvelopeOptions> {
release: Time;
/**
* The automation curve type for the attack
* The automation curve type for the attack
*/
private _attackCurve!: InternalEnvelopeCurve;
/**
* The automation curve type for the decay
* The automation curve type for the decay
*/
private _decayCurve!: BasicEnvelopeCurve;
/**
* The automation curve type for the release
* The automation curve type for the release
*/
private _releaseCurve!: InternalEnvelopeCurve;
/**
* the signal which is output.
* the signal which is output.
*/
protected _sig: Signal<NormalRange> = new Signal({
context: this.context,
@ -155,13 +155,13 @@ export class Envelope extends ToneAudioNode<EnvelopeOptions> {
/**
* @param attack The amount of time it takes for the envelope to go from
* 0 to it's maximum value.
* 0 to it's maximum value.
* @param decay The period of time after the attack that it takes for the envelope
* to fall to the sustain value. Value must be greater than 0.
* to fall to the sustain value. Value must be greater than 0.
* @param sustain The percent of the maximum value that the envelope rests at until
* the release is triggered.
* the release is triggered.
* @param release The amount of time after the release is triggered it takes to reach 0.
* Value must be greater than 0.
* Value must be greater than 0.
*/
constructor(attack?: Time, decay?: Time, sustain?: NormalRange, release?: Time);
constructor(options?: Partial<EnvelopeOptions>)
@ -200,7 +200,7 @@ export class Envelope extends ToneAudioNode<EnvelopeOptions> {
}
/**
* Get the curve
* Get the curve
* @param curve
* @param direction In/Out
* @return The curve name
@ -222,7 +222,7 @@ export class Envelope extends ToneAudioNode<EnvelopeOptions> {
}
/**
* Assign a the curve to the given name using the direction
* Assign a the curve to the given name using the direction
* @param name
* @param direction In/Out
* @param curve
@ -305,7 +305,7 @@ export class Envelope extends ToneAudioNode<EnvelopeOptions> {
* Trigger the attack/decay portion of the ADSR envelope.
* @param time When the attack should start.
* @param velocity The velocity of the envelope scales the vales.
* number between 0-1
* number between 0-1
* @example
* //trigger the attack 0.5 seconds from now with a velocity of 0.2
* env.triggerAttack("+0.5", 0.2);
@ -365,11 +365,11 @@ export class Envelope extends ToneAudioNode<EnvelopeOptions> {
}
/**
* Triggers the release of the envelope.
* Triggers the release of the envelope.
* @param time When the release portion of the envelope should start.
* @example
* //trigger release immediately
* env.triggerRelease();
* //trigger release immediately
* env.triggerRelease();
*/
triggerRelease(time?: Time): this {
this.log("triggerRelease", time);
@ -391,16 +391,16 @@ export class Envelope extends ToneAudioNode<EnvelopeOptions> {
}
/**
* Get the scheduled value at the given time. This will
* return the unconverted (raw) value.
* Get the scheduled value at the given time. This will
* return the unconverted (raw) value.
*/
getValueAtTime(time: Time): NormalRange {
return this._sig.getValueAtTime(time);
}
/**
* triggerAttackRelease is shorthand for triggerAttack, then waiting
* some duration, then triggerRelease.
* triggerAttackRelease is shorthand for triggerAttack, then waiting
* some duration, then triggerRelease.
* @param duration The duration of the sustain.
* @param time When the attack should be triggered.
* @param velocity The velocity of the envelope.
@ -416,7 +416,7 @@ export class Envelope extends ToneAudioNode<EnvelopeOptions> {
}
/**
* Cancels all scheduled envelope changes after the given time.
* Cancels all scheduled envelope changes after the given time.
*/
cancel(after?: Time): this {
this._sig.cancelScheduledValues(this.toSeconds(after));
@ -458,7 +458,7 @@ interface EnvelopeCurveMap {
type EnvelopeCurveName = keyof EnvelopeCurveMap;
/**
* Generate some complex envelope curves.
* Generate some complex envelope curves.
*/
// tslint:disable-next-line: variable-name
const EnvelopeCurves: EnvelopeCurveMap = (() => {
@ -508,7 +508,7 @@ const EnvelopeCurves: EnvelopeCurveMap = (() => {
}
/**
* Invert a value curve to make it work for the release
* Invert a value curve to make it work for the release
*/
function invertCurve(curve: number[]): number[] {
const out = new Array(curve.length);
@ -519,14 +519,14 @@ const EnvelopeCurves: EnvelopeCurveMap = (() => {
}
/**
* reverse the curve
* reverse the curve
*/
function reverseCurve(curve: number[]): number[] {
return curve.slice(0).reverse();
}
/**
* attack and release curve arrays
* attack and release curve arrays
*/
return {
bounce : {

View file

@ -20,29 +20,29 @@ export class EQ3 extends ToneAudioNode<EQ3Options> {
readonly name: string = "EQ3";
/**
* the input
* the input
*/
readonly input: MultibandSplit;
/**
* the output
* the output
*/
readonly output = new Gain({ context: this.context });
private _multibandSplit: MultibandSplit;
/**
* The gain for the lower signals
* The gain for the lower signals
*/
private _lowGain: Gain<Decibels>;
/**
* The gain for the mid signals
* The gain for the mid signals
*/
private _midGain: Gain<Decibels>;
/**
* The gain for the high signals
* The gain for the high signals
*/
private _highGain: Gain<Decibels>;
@ -62,17 +62,17 @@ export class EQ3 extends ToneAudioNode<EQ3Options> {
readonly high: Param<Decibels>;
/**
* The Q value for all of the filters.
* The Q value for all of the filters.
*/
readonly Q: Signal<Positive>;
/**
* The low/mid crossover frequency.
* The low/mid crossover frequency.
*/
readonly lowFrequency: Signal<Frequency>;
/**
* The mid/high crossover frequency.
* The mid/high crossover frequency.
*/
readonly highFrequency: Signal<Frequency>;
@ -135,7 +135,7 @@ export class EQ3 extends ToneAudioNode<EQ3Options> {
}
/**
* Clean up.
* Clean up.
*/
dispose(): this {
super.dispose();

View file

@ -32,28 +32,28 @@ export class Filter extends ToneAudioNode<FilterOptions> {
private _filters: BiquadFilterNode[] = [];
/**
* the rolloff value of the filter
* the rolloff value of the filter
*/
private _rolloff!: number;
private _type: BiquadFilterType;
/**
* The Q or Quality of the filter
* The Q or Quality of the filter
*/
readonly Q: Signal<Positive>;
/**
* The cutoff frequency of the filter.
* The cutoff frequency of the filter.
*/
readonly frequency: Signal<Frequency>;
/**
* The detune parameter
* The detune parameter
*/
readonly detune: Signal<Cents>;
/**
* The gain of the filter, only used in certain filter types
* The gain of the filter, only used in certain filter types
*/
readonly gain: Signal<Decibels>;
@ -187,7 +187,7 @@ export class Filter extends ToneAudioNode<FilterOptions> {
}
/**
* Clean up.
* Clean up.
*/
dispose(): this {
super.dispose();

View file

@ -16,17 +16,17 @@ export class PhaseShiftAllpass extends ToneAudioNode<ToneAudioNodeOptions> {
readonly input = new Gain({ context : this.context });
/**
* The Allpass filter in the first bank
* The Allpass filter in the first bank
*/
private _bank0: IIRFilterNode[];
/**
* The Allpass filter in the seconds bank
* The Allpass filter in the seconds bank
*/
private _bank1: IIRFilterNode[];
/**
* A IIR filter implementing a delay by one sample used by the first bank
* A IIR filter implementing a delay by one sample used by the first bank
*/
private _oneSampleDelay: IIRFilterNode;

View file

@ -1,5 +1,5 @@
/**
* Tone.js
* Tone.js
* @author Yotam Mann
* @license http://opensource.org/licenses/MIT MIT License
* @copyright 2014-2019 Yotam Mann
@ -66,7 +66,7 @@ export abstract class Tone {
}
/**
* Assert that the statement is true, otherwise invoke the error.
* Assert that the statement is true, otherwise invoke the error.
* @param statement
* @param error The message which is passed into an Error
*/
@ -84,7 +84,7 @@ export abstract class Tone {
private _wasDisposed: boolean = false;
/**
* disconnect and dispose.
* disconnect and dispose.
*/
dispose(): this {
this._wasDisposed = true;
@ -105,14 +105,14 @@ export abstract class Tone {
///////////////////////////////////////////////////////////////////////////
/**
* If the `given` parameter is undefined, use the `fallback`.
* If both `given` and `fallback` are object literals, it will
* return a deep copy which includes all of the parameters from both
* objects. If a parameter is undefined in given, it will return
* the fallback property.
* <br><br>
* WARNING: if object is self referential, it will go into an an
* infinite recursive loop.
* If the `given` parameter is undefined, use the `fallback`.
* If both `given` and `fallback` are object literals, it will
* return a deep copy which includes all of the parameters from both
* objects. If a parameter is undefined in given, it will return
* the fallback property.
* <br><br>
* WARNING: if object is self referential, it will go into an an
* infinite recursive loop.
* @memberOf Tone
* @param {*} given
* @param {*} fallback

View file

@ -27,7 +27,7 @@ type ClockEvent = "start" | "stop" | "pause";
* //the callback will be invoked approximately once a second
* //and will print the time exactly once a second apart.
* const clock = new Clock(time => {
* console.log(time);
* console.log(time);
* }, 1);
* @category Core
*/
@ -37,22 +37,22 @@ extends ToneWithContext<ClockOptions> implements Emitter<ClockEvent> {
readonly name: string = "Clock";
/**
* The callback function to invoke at the scheduled tick.
* The callback function to invoke at the scheduled tick.
*/
callback: ClockCallback = noOp;
/**
* The tick counter
* The tick counter
*/
private _tickSource: TickSource<Type>;
/**
* The last time the loop callback was invoked
* The last time the loop callback was invoked
*/
private _lastUpdate: number = 0;
/**
* Keep track of the playback state
* Keep track of the playback state
*/
private _state: StateTimeline = new StateTimeline("stopped");
@ -63,7 +63,7 @@ extends ToneWithContext<ClockOptions> implements Emitter<ClockEvent> {
private _boundLoop: () => void = this._loop.bind(this);
/**
* The rate the callback function should be invoked.
* The rate the callback function should be invoked.
*/
frequency: TickSignal<Type>;
@ -104,15 +104,15 @@ extends ToneWithContext<ClockOptions> implements Emitter<ClockEvent> {
}
/**
* Returns the playback state of the source, either "started", "stopped" or "paused".
* Returns the playback state of the source, either "started", "stopped" or "paused".
*/
get state(): PlaybackState {
return this._state.getValueAtTime(this.now());
}
/**
* Start the clock at the given time. Optionally pass in an offset
* of where to start the tick counter from.
* Start the clock at the given time. Optionally pass in an offset
* of where to start the tick counter from.
* @param time The time the clock should start
* @param offset Where the tick counter starts counting from.
*/
@ -132,7 +132,7 @@ extends ToneWithContext<ClockOptions> implements Emitter<ClockEvent> {
}
/**
* Stop the clock. Stopping the clock resets the tick counter to 0.
* Stop the clock. Stopping the clock resets the tick counter to 0.
* @param time The time when the clock should stop.
* @example
* clock.stop();
@ -149,7 +149,7 @@ extends ToneWithContext<ClockOptions> implements Emitter<ClockEvent> {
}
/**
* Pause the clock. Pausing does not reset the tick counter.
* Pause the clock. Pausing does not reset the tick counter.
* @param time The time when the clock should stop.
*/
pause(time?: Time): this {
@ -165,8 +165,8 @@ extends ToneWithContext<ClockOptions> implements Emitter<ClockEvent> {
}
/**
* The number of times the callback was invoked. Starts counting at 0
* and increments after the callback was invoked.
* The number of times the callback was invoked. Starts counting at 0
* and increments after the callback was invoked.
*/
get ticks(): Ticks {
return Math.ceil(this.getTicksAtTime(this.now()));
@ -176,7 +176,7 @@ extends ToneWithContext<ClockOptions> implements Emitter<ClockEvent> {
}
/**
* The time since ticks=0 that the Clock has been running. Accounts for tempo curves
* The time since ticks=0 that the Clock has been running. Accounts for tempo curves
*/
get seconds(): Seconds {
return this._tickSource.seconds;
@ -186,7 +186,7 @@ extends ToneWithContext<ClockOptions> implements Emitter<ClockEvent> {
}
/**
* Return the elapsed seconds at the given time.
* Return the elapsed seconds at the given time.
* @param time When to get the elapsed seconds
* @return The number of elapsed seconds
*/
@ -224,7 +224,7 @@ extends ToneWithContext<ClockOptions> implements Emitter<ClockEvent> {
}
/**
* The scheduling loop.
* The scheduling loop.
*/
private _loop(): void {
@ -271,7 +271,7 @@ extends ToneWithContext<ClockOptions> implements Emitter<ClockEvent> {
}
/**
* Clean up
* Clean up
*/
dispose(): this {
super.dispose();

View file

@ -27,12 +27,12 @@ export class TickSource<Type extends BPM | Hertz> extends ToneWithContext<TickSo
readonly name: string = "TickSource";
/**
* The frequency the callback function should be invoked.
* The frequency the callback function should be invoked.
*/
readonly frequency: TickSignal<Type>;
/**
* The state timeline
* The state timeline
*/
private _state: StateTimeline = new StateTimeline();
@ -72,15 +72,15 @@ export class TickSource<Type extends BPM | Hertz> extends ToneWithContext<TickSo
}
/**
* Returns the playback state of the source, either "started", "stopped" or "paused".
* Returns the playback state of the source, either "started", "stopped" or "paused".
*/
get state(): PlaybackState {
return this._state.getValueAtTime(this.now());
}
/**
* Start the clock at the given time. Optionally pass in an offset
* of where to start the tick counter from.
* Start the clock at the given time. Optionally pass in an offset
* of where to start the tick counter from.
* @param time The time the clock should start
* @param offset The number of ticks to start the source at
*/
@ -116,7 +116,7 @@ export class TickSource<Type extends BPM | Hertz> extends ToneWithContext<TickSo
}
/**
* Pause the clock. Pausing does not reset the tick counter.
* Pause the clock. Pausing does not reset the tick counter.
* @param time The time when the clock should stop.
*/
pause(time: Time): this {
@ -128,7 +128,7 @@ export class TickSource<Type extends BPM | Hertz> extends ToneWithContext<TickSo
}
/**
* Cancel start/stop/pause and setTickAtTime events scheduled after the given time.
* Cancel start/stop/pause and setTickAtTime events scheduled after the given time.
* @param time When to clear the events after
*/
cancel(time: Time): this {
@ -180,8 +180,8 @@ export class TickSource<Type extends BPM | Hertz> extends ToneWithContext<TickSo
}
/**
* The number of times the callback was invoked. Starts counting at 0
* and increments after the callback was invoked. Returns -1 when stopped.
* The number of times the callback was invoked. Starts counting at 0
* and increments after the callback was invoked. Returns -1 when stopped.
*/
get ticks(): Ticks {
return this.getTicksAtTime(this.now());
@ -192,8 +192,8 @@ export class TickSource<Type extends BPM | Hertz> extends ToneWithContext<TickSo
}
/**
* The time since ticks=0 that the TickSource has been running. Accounts
* for tempo curves
* The time since ticks=0 that the TickSource has been running. Accounts
* for tempo curves
*/
get seconds(): Seconds {
return this.getSecondsAtTime(this.now());
@ -206,7 +206,7 @@ export class TickSource<Type extends BPM | Hertz> extends ToneWithContext<TickSo
}
/**
* Return the elapsed seconds at the given time.
* Return the elapsed seconds at the given time.
* @param time When to get the elapsed seconds
* @return The number of elapsed seconds
*/
@ -263,7 +263,7 @@ export class TickSource<Type extends BPM | Hertz> extends ToneWithContext<TickSo
}
/**
* Returns the scheduled state at the given time.
* Returns the scheduled state at the given time.
* @param time The time to query.
* @example
* source.start("+0.1");
@ -291,8 +291,8 @@ export class TickSource<Type extends BPM | Hertz> extends ToneWithContext<TickSo
}
/**
* Invoke the callback event at all scheduled ticks between the
* start time and the end time
* Invoke the callback event at all scheduled ticks between the
* start time and the end time
* @param startTime The beginning of the search range
* @param endTime The end of the search range
* @param callback The callback to invoke with each tick
@ -343,7 +343,7 @@ export class TickSource<Type extends BPM | Hertz> extends ToneWithContext<TickSo
}
/**
* Clean up
* Clean up
*/
dispose(): this {
super.dispose();

View file

@ -45,7 +45,7 @@ export class Ticker {
}
/**
* Generate a web worker
* Generate a web worker
*/
private _createWorker(): void {

View file

@ -54,12 +54,12 @@ type TransportCallback = (time: Seconds) => void;
* @example
* //repeated event every 8th note
* Transport.scheduleRepeat(function(time){
* //do something with the time
* //do something with the time
* }, "8n");
* @example
* //schedule an event on the 16th measure
* Transport.schedule(function(time){
* //do something with the time
* //do something with the time
* }, "16:0:0");
* @category Core
*/
@ -72,17 +72,17 @@ export class Transport extends ToneWithContext<TransportOptions> implements Emit
//////////////////////////////////////////////////////////////////////
/**
* If the transport loops or not.
* If the transport loops or not.
*/
loop: boolean = false;
/**
* The loop start position in ticks
* The loop start position in ticks
*/
private _loopStart: Ticks = 0;
/**
* The loop end position in ticks
* The loop end position in ticks
*/
private _loopEnd: Ticks = 0;
@ -91,13 +91,13 @@ export class Transport extends ToneWithContext<TransportOptions> implements Emit
//////////////////////////////////////////////////////////////////////
/**
* Pulses per quarter is the number of ticks per quarter note.
* Pulses per quarter is the number of ticks per quarter note.
*/
private _ppq: number;
/**
* watches the main oscillator for timing ticks
* initially starts at 120bpm
* watches the main oscillator for timing ticks
* initially starts at 120bpm
*/
private _clock: Clock<BPM>;
@ -111,8 +111,8 @@ export class Transport extends ToneWithContext<TransportOptions> implements Emit
bpm: TickParam<BPM>;
/**
* The time signature, or more accurately the numerator
* of the time signature over a denominator of 4.
* The time signature, or more accurately the numerator
* of the time signature over a denominator of 4.
*/
private _timeSignature: number;
@ -121,22 +121,22 @@ export class Transport extends ToneWithContext<TransportOptions> implements Emit
//////////////////////////////////////////////////////////////////////
/**
* All the events in an object to keep track by ID
* All the events in an object to keep track by ID
*/
private _scheduledEvents = {};
/**
* The scheduled events.
* The scheduled events.
*/
private _timeline: Timeline<TransportEvent> = new Timeline();
/**
* Repeated events
* Repeated events
*/
private _repeatedEvents: IntervalTimeline = new IntervalTimeline();
/**
* All of the synced Signals
* All of the synced Signals
*/
private _syncedSignals: SyncedSignalEvent[] = [];
@ -145,12 +145,12 @@ export class Transport extends ToneWithContext<TransportOptions> implements Emit
//////////////////////////////////////////////////////////////////////
/**
* The subdivision of the swing
* The subdivision of the swing
*/
private _swingTicks: Ticks;
/**
* The swing amount
* The swing amount
*/
private _swingAmount: NormalRange = 0;
@ -196,7 +196,7 @@ export class Transport extends ToneWithContext<TransportOptions> implements Emit
///////////////////////////////////////////////////////////////////////////////
/**
* called on every tick
* called on every tick
* @param tickTime clock relative tick time
*/
private _processTick(tickTime: Seconds, ticks: Ticks): void {
@ -235,7 +235,7 @@ export class Transport extends ToneWithContext<TransportOptions> implements Emit
* @example
* //trigger the callback when the Transport reaches the desired time
* Transport.schedule(function(time){
* envelope.triggerAttack(time);
* envelope.triggerAttack(time);
* }, "128i");
*/
schedule(callback: TransportCallback, time: TransportTime | TransportTimeClass): number {
@ -277,7 +277,7 @@ export class Transport extends ToneWithContext<TransportOptions> implements Emit
}
/**
* Schedule an event that will be removed after it is invoked.
* Schedule an event that will be removed after it is invoked.
* @param callback The callback to invoke once.
* @param time The time the callback should be invoked.
* @returns The ID of the scheduled event.
@ -337,7 +337,7 @@ export class Transport extends ToneWithContext<TransportOptions> implements Emit
///////////////////////////////////////////////////////////////////////////////
/**
* Bind start/stop/pause events from the clock and emit them.
* Bind start/stop/pause events from the clock and emit them.
*/
private _bindClockEvents(): void {
this._clock.on("start", (time, offset) => {
@ -355,7 +355,7 @@ export class Transport extends ToneWithContext<TransportOptions> implements Emit
}
/**
* Returns the playback state of the source, either "started", "stopped", or "paused"
* Returns the playback state of the source, either "started", "stopped", or "paused"
*/
get state(): PlaybackState {
return this._clock.getStateAtTime(this.now());
@ -495,8 +495,8 @@ export class Transport extends ToneWithContext<TransportOptions> implements Emit
}
/**
* The Transport's position in Bars:Beats:Sixteenths.
* Setting the value will jump to that position right away.
* The Transport's position in Bars:Beats:Sixteenths.
* Setting the value will jump to that position right away.
*/
get position(): BarsBeatsSixteenths | Time {
const now = this.now();
@ -509,8 +509,8 @@ export class Transport extends ToneWithContext<TransportOptions> implements Emit
}
/**
* The Transport's position in seconds
* Setting the value will jump to that position right away.
* The Transport's position in seconds
* Setting the value will jump to that position right away.
*/
get seconds(): Seconds {
return this._clock.seconds;
@ -523,8 +523,8 @@ export class Transport extends ToneWithContext<TransportOptions> implements Emit
}
/**
* The Transport's loop position as a normalized value. Always
* returns 0 if the transport if loop is not true.
* The Transport's loop position as a normalized value. Always
* returns 0 if the transport if loop is not true.
*/
get progress(): NormalRange {
if (this.loop) {
@ -537,7 +537,7 @@ export class Transport extends ToneWithContext<TransportOptions> implements Emit
}
/**
* The transports current tick position.
* The transports current tick position.
*/
get ticks(): Ticks {
return this._clock.ticks;
@ -567,7 +567,7 @@ export class Transport extends ToneWithContext<TransportOptions> implements Emit
}
/**
* Return the elapsed seconds at the given time.
* Return the elapsed seconds at the given time.
* @param time When to get the elapsed seconds
* @return The number of elapsed seconds
*/
@ -576,10 +576,10 @@ export class Transport extends ToneWithContext<TransportOptions> implements Emit
}
/**
* Pulses Per Quarter note. This is the smallest resolution
* the Transport timing supports. This should be set once
* on initialization and not set again. Changing this value
* after other objects have been created can cause problems.
* Pulses Per Quarter note. This is the smallest resolution
* the Transport timing supports. This should be set once
* on initialization and not set again. Changing this value
* after other objects have been created can cause problems.
*/
get PPQ(): number {
return this._clock.frequency.multiplier;
@ -618,13 +618,13 @@ export class Transport extends ToneWithContext<TransportOptions> implements Emit
}
/**
* Attaches the signal to the tempo control signal so that
* any changes in the tempo will change the signal in the same
* ratio.
* Attaches the signal to the tempo control signal so that
* any changes in the tempo will change the signal in the same
* ratio.
*
* @param signal
* @param ratio Optionally pass in the ratio between the two signals.
* Otherwise it will be computed based on their current values.
* Otherwise it will be computed based on their current values.
*/
syncSignal(signal: Signal<any>, ratio?: number): this {
if (!ratio) {
@ -653,8 +653,8 @@ export class Transport extends ToneWithContext<TransportOptions> implements Emit
}
/**
* Unsyncs a previously synced signal from the transport's control.
* See Transport.syncSignal.
* Unsyncs a previously synced signal from the transport's control.
* See Transport.syncSignal.
*/
unsyncSignal(signal: Signal<any>): this {
for (let i = this._syncedSignals.length - 1; i >= 0; i--) {
@ -669,7 +669,7 @@ export class Transport extends ToneWithContext<TransportOptions> implements Emit
}
/**
* Clean up.
* Clean up.
*/
dispose(): this {
super.dispose();

View file

@ -18,8 +18,8 @@ export abstract class AbstractParam<Type extends Unit> {
abstract setValueAtTime(value: Type, time: Time): this;
/**
* Get the signals value at the given time. Subsequent scheduling
* may invalidate the returned value.
* Get the signals value at the given time. Subsequent scheduling
* may invalidate the returned value.
* @param time When to get the value
*/
abstract getValueAtTime(time: Time): Type;
@ -41,8 +41,8 @@ export abstract class AbstractParam<Type extends Unit> {
abstract linearRampToValueAtTime(value: Type, time: Time): this;
/**
* Schedules an exponential continuous change in parameter value from
* the previous scheduled parameter value to the given value.
* Schedules an exponential continuous change in parameter value from
* the previous scheduled parameter value to the given value.
*/
abstract exponentialRampToValueAtTime(value: Type, time: Time): this;
@ -52,7 +52,7 @@ export abstract class AbstractParam<Type extends Unit> {
* duration of the rampTime.
* @param value The value to ramp to.
* @param rampTime the time that it takes the
* value to ramp from it's current value
* value to ramp from it's current value
* @param startTime When the ramp should start.
* @example
* //exponentially ramp to the value 2 over 4 seconds.
@ -61,13 +61,13 @@ export abstract class AbstractParam<Type extends Unit> {
abstract exponentialRampTo(value: Type, rampTime: Time, startTime?: Time): this;
/**
* Schedules an linear continuous change in parameter value from
* the current time and current value to the given value over the
* duration of the rampTime.
* Schedules an linear continuous change in parameter value from
* the current time and current value to the given value over the
* duration of the rampTime.
*
* @param value The value to ramp to.
* @param rampTime the time that it takes the
* value to ramp from it's current value
* value to ramp from it's current value
* @param startTime When the ramp should start.
* @returns {Param} this
* @example
@ -77,12 +77,12 @@ export abstract class AbstractParam<Type extends Unit> {
abstract linearRampTo(value: Type, rampTime: Time, startTime?: Time): this;
/**
* Start exponentially approaching the target value at the given time. Since it
* is an exponential approach it will continue approaching after the ramp duration. The
* rampTime is the time that it takes to reach over 99% of the way towards the value.
* Start exponentially approaching the target value at the given time. Since it
* is an exponential approach it will continue approaching after the ramp duration. The
* rampTime is the time that it takes to reach over 99% of the way towards the value.
* @param value The value to ramp to.
* @param rampTime the time that it takes the
* value to ramp from it's current value
* value to ramp from it's current value
* @param startTime When the ramp should start.
* @example
* //exponentially ramp to the value 2 over 4 seconds.

View file

@ -63,22 +63,22 @@ export class Context extends Emitter<"statechange" | "tick"> implements BaseAudi
private readonly _ticker: Ticker;
/**
* The default latency hint
* The default latency hint
*/
private _latencyHint: ContextLatencyHint | Seconds;
/**
* An object containing all of the constants AudioBufferSourceNodes
* An object containing all of the constants AudioBufferSourceNodes
*/
private _constants = new Map<number, AudioBufferSourceNode>();
/**
* All of the setTimeout events.
* All of the setTimeout events.
*/
private _timeouts: Timeline<ContextTimeoutEvent> = new Timeline();
/**
* The timeout id counter
* The timeout id counter
*/
private _timeoutIds = 0;
@ -204,32 +204,32 @@ export class Context extends Emitter<"statechange" | "tick"> implements BaseAudi
}
/**
* The current time in seconds of the AudioContext.
* The current time in seconds of the AudioContext.
*/
get currentTime(): Seconds {
return this._context.currentTime;
}
/**
* The current time in seconds of the AudioContext.
* The current time in seconds of the AudioContext.
*/
get state(): AudioContextState {
return this._context.state;
}
/**
* The current time in seconds of the AudioContext.
* The current time in seconds of the AudioContext.
*/
get sampleRate(): number {
return this._context.sampleRate;
}
/**
* The listener
* The listener
*/
get listener(): AudioListener {
return this._context.listener;
}
/**
* There is only one Transport per Context. It is created on initialization.
* There is only one Transport per Context. It is created on initialization.
*/
get transport(): Transport {
this.assert(this._initialized, "The context must be initialized before being used by invoking context.initialize()");
@ -241,7 +241,7 @@ export class Context extends Emitter<"statechange" | "tick"> implements BaseAudi
}
/**
* A reference to the Context's destination node.
* A reference to the Context's destination node.
*/
get destination(): Destination {
this.assert(this._initialized, "The context must be initialized before being used by invoking context.initialize()");
@ -257,10 +257,10 @@ export class Context extends Emitter<"statechange" | "tick"> implements BaseAudi
///////////////////////////////////////////////////////////////////////
/**
* How often the interval callback is invoked.
* This number corresponds to how responsive the scheduling
* can be. context.updateInterval + context.lookAhead gives you the
* total latency between scheduling an event and hearing it.
* How often the interval callback is invoked.
* This number corresponds to how responsive the scheduling
* can be. context.updateInterval + context.lookAhead gives you the
* total latency between scheduling an event and hearing it.
*/
get updateInterval(): Seconds {
return this._ticker.updateInterval;
@ -270,8 +270,8 @@ export class Context extends Emitter<"statechange" | "tick"> implements BaseAudi
}
/**
* What the source of the clock is, either "worker" (default),
* "timeout", or "offline" (none).
* What the source of the clock is, either "worker" (default),
* "timeout", or "offline" (none).
*/
get clockSource(): TickerClockSource {
return this._ticker.type;
@ -318,7 +318,7 @@ export class Context extends Emitter<"statechange" | "tick"> implements BaseAudi
}
/**
* The unwrapped AudioContext.
* The unwrapped AudioContext.
*/
get rawContext(): AnyAudioContext {
return this._context;
@ -332,8 +332,8 @@ export class Context extends Emitter<"statechange" | "tick"> implements BaseAudi
}
/**
* Starts the audio context from a suspended state. This is required
* to initially start the AudioContext.
* Starts the audio context from a suspended state. This is required
* to initially start the AudioContext.
*/
resume(): Promise<void> {
if (this._context.state === "suspended" && isAudioContext(this._context)) {
@ -344,8 +344,8 @@ export class Context extends Emitter<"statechange" | "tick"> implements BaseAudi
}
/**
* Promise which is invoked when the context is running.
* Tries to resume the context if it's not started.
* Promise which is invoked when the context is running.
* Tries to resume the context if it's not started.
*/
async close(): Promise<void> {
if (isAudioContext(this._context)) {
@ -357,7 +357,7 @@ export class Context extends Emitter<"statechange" | "tick"> implements BaseAudi
}
/**
* Generate a looped buffer at some constant value.
* Generate a looped buffer at some constant value.
*/
getConstant(val: number): AudioBufferSourceNode {
if (this._constants.has(val)) {
@ -380,7 +380,7 @@ export class Context extends Emitter<"statechange" | "tick"> implements BaseAudi
}
/**
* Clean up. Also closes the audio context.
* Clean up. Also closes the audio context.
*/
dispose(): this {
super.dispose();
@ -395,8 +395,8 @@ export class Context extends Emitter<"statechange" | "tick"> implements BaseAudi
///////////////////////////////////////////////////////////////////////
/**
* The private loop which keeps track of the context scheduled timeouts
* Is invoked from the clock source
* The private loop which keeps track of the context scheduled timeouts
* Is invoked from the clock source
*/
private _timeoutLoop(): void {
const now = this.now();
@ -412,8 +412,8 @@ export class Context extends Emitter<"statechange" | "tick"> implements BaseAudi
}
/**
* A setTimeout which is guaranteed by the clock source.
* Also runs in the offline context.
* A setTimeout which is guaranteed by the clock source.
* Also runs in the offline context.
* @param fn The callback to invoke
* @param timeout The timeout in seconds
* @returns ID to use when invoking Context.clearTimeout
@ -430,7 +430,7 @@ export class Context extends Emitter<"statechange" | "tick"> implements BaseAudi
}
/**
* Clears a previously scheduled timeout with Tone.context.setTimeout
* Clears a previously scheduled timeout with Tone.context.setTimeout
* @param id The ID returned from setTimeout
*/
clearTimeout(id: number): this {

View file

@ -24,7 +24,7 @@ export class Delay extends ToneAudioNode<DelayOptions> {
readonly maxDelay: Time;
/**
* The amount of time the incoming signal is delayed.
* The amount of time the incoming signal is delayed.
*/
readonly delayTime: Param<Time>;
@ -69,7 +69,7 @@ export class Delay extends ToneAudioNode<DelayOptions> {
}
/**
* Clean up.
* Clean up.
*/
dispose(): this {
super.dispose();

View file

@ -72,8 +72,8 @@ export class Destination extends ToneAudioNode<DestinationOptions> {
}
/**
* Add a master effects chain. NOTE: this will disconnect any nodes which were previously
* chained in the master effects chain.
* Add a master effects chain. NOTE: this will disconnect any nodes which were previously
* chained in the master effects chain.
* @param nodes All arguments will be connected in a row and the Master will be routed through it.
* @return {Destination} this
* @example
@ -99,7 +99,7 @@ export class Destination extends ToneAudioNode<DestinationOptions> {
}
/**
* Clean up
* Clean up
*/
dispose(): this {
super.dispose();

View file

@ -21,7 +21,7 @@ export class Gain<Type extends Unit = GainFactor> extends ToneAudioNode<GainOpti
readonly name: string = "Gain";
/**
* The gain parameter of the gain node.
* The gain parameter of the gain node.
*/
readonly gain: Param<Type>;
@ -63,7 +63,7 @@ export class Gain<Type extends Unit = GainFactor> extends ToneAudioNode<GainOpti
}
/**
* Clean up.
* Clean up.
*/
dispose(): this {
super.dispose();

View file

@ -12,12 +12,12 @@ export class OfflineContext extends Context {
readonly name: string = "OfflineContext";
/**
* A private reference to the duration
* A private reference to the duration
*/
private readonly _duration: Seconds;
/**
* An artificial clock source
* An artificial clock source
*/
private _currentTime: Seconds = 0;
@ -52,7 +52,7 @@ export class OfflineContext extends Context {
}
/**
* Override the now method to point to the internal clock time
* Override the now method to point to the internal clock time
*/
now(): Seconds {
return this._currentTime;
@ -66,7 +66,7 @@ export class OfflineContext extends Context {
}
/**
* Render the output of the OfflineContext
* Render the output of the OfflineContext
*/
render(): Promise<AudioBuffer> {
while (this._duration - this._currentTime >= 0) {
@ -80,7 +80,7 @@ export class OfflineContext extends Context {
}
/**
* Close the context
* Close the context
*/
close(): Promise<void> {
return Promise.resolve();

View file

@ -71,17 +71,17 @@ implements AbstractParam<Type> {
protected _events: Timeline<AutomationEvent>;
/**
* The native parameter to control
* The native parameter to control
*/
protected _param: AudioParam;
/**
* The default value before anything is assigned
* The default value before anything is assigned
*/
protected _initialValue: number;
/**
* The minimum output value
* The minimum output value
*/
private _minOutput = 1e-7;
@ -158,8 +158,8 @@ implements AbstractParam<Type> {
}
/**
* Convert the given value from the type specified by Param.units
* into the destination value (such as Gain or Frequency).
* Convert the given value from the type specified by Param.units
* into the destination value (such as Gain or Frequency).
*/
protected _fromType(val: Type): number {
if (this.convert && !this.overridden) {

View file

@ -23,8 +23,8 @@ interface ToneAudioBufferOptions {
* of _all_ of the buffers. These are ToneAudioBuffer.on("load" / "progress" / "error")
* @example
* var buffer = new ToneAudioBuffer("path/to/sound.mp3", function(){
* //the buffer is now available.
* var buff = buffer.get();
* //the buffer is now available.
* var buff = buffer.get();
* });
* @example
* //can load provide fallback extension types if the first type is not supported.
@ -36,12 +36,12 @@ export class ToneAudioBuffer extends Tone {
readonly name: string = "ToneAudioBuffer";
/**
* stores the loaded AudioBuffer
* stores the loaded AudioBuffer
*/
private _buffer?: AudioBuffer;
/**
* indicates if the buffer should be reversed or not
* indicates if the buffer should be reversed or not
*/
private _reversed!: boolean;
@ -54,8 +54,8 @@ export class ToneAudioBuffer extends Tone {
*
* @param url The url to load, or the audio buffer to set.
* @param onload A callback which is invoked after the buffer is loaded.
* It's recommended to use `ToneAudioBuffer.on('load', callback)` instead
* since it will give you a callback when _all_ buffers are loaded.
* It's recommended to use `ToneAudioBuffer.on('load', callback)` instead
* since it will give you a callback when _all_ buffers are loaded.
* @param onerror The callback to invoke if there is an error
*/
constructor(
@ -101,7 +101,7 @@ export class ToneAudioBuffer extends Tone {
}
/**
* Pass in an AudioBuffer or ToneAudioBuffer to set the value of this buffer.
* Pass in an AudioBuffer or ToneAudioBuffer to set the value of this buffer.
*/
set(buffer: AudioBuffer | ToneAudioBuffer): this {
if (buffer instanceof ToneAudioBuffer) {
@ -126,15 +126,15 @@ export class ToneAudioBuffer extends Tone {
}
/**
* The audio buffer stored in the object.
* The audio buffer stored in the object.
*/
get(): AudioBuffer | undefined {
return this._buffer;
}
/**
* Makes an fetch request for the selected url then decodes the file as an audio buffer.
* Invokes the callback once the audio buffer loads.
* Makes an fetch request for the selected url then decodes the file as an audio buffer.
* Invokes the callback once the audio buffer loads.
* @param url The url of the buffer to load. filetype support depends on the browser.
* @returns A Promise which resolves with this ToneAudioBuffer
*/
@ -156,7 +156,7 @@ export class ToneAudioBuffer extends Tone {
}
/**
* clean up
* clean up
*/
dispose(): this {
super.dispose();
@ -186,7 +186,7 @@ export class ToneAudioBuffer extends Tone {
}
/**
* Sums multiple channels into 1 channel
* Sums multiple channels into 1 channel
* @param channel Optionally only copy a single channel from the array.
*/
toMono(chanNum?: number): this {
@ -209,8 +209,8 @@ export class ToneAudioBuffer extends Tone {
}
/**
* Get the buffer as an array. Single channel buffers will return a 1-dimensional
* Float32Array, and multichannel buffers will return multidimensional arrays.
* Get the buffer as an array. Single channel buffers will return a 1-dimensional
* Float32Array, and multichannel buffers will return multidimensional arrays.
* @param channel Optionally only copy a single channel from the array.
*/
toArray(channel?: number): Float32Array | Float32Array[] {
@ -228,7 +228,7 @@ export class ToneAudioBuffer extends Tone {
}
/**
* Returns the Float32Array representing the PCM audio data for the specific channel.
* Returns the Float32Array representing the PCM audio data for the specific channel.
* @param channel The channel number to return
* @return The audio as a TypedArray
*/
@ -241,8 +241,8 @@ export class ToneAudioBuffer extends Tone {
}
/**
* Cut a subsection of the array and return a buffer of the
* subsection. Does not modify the original buffer
* Cut a subsection of the array and return a buffer of the
* subsection. Does not modify the original buffer
* @param start The time to start the slice
* @param end The end time to slice. If none is given will default to the end of the buffer
*/
@ -259,7 +259,7 @@ export class ToneAudioBuffer extends Tone {
}
/**
* Reverse the buffer.
* Reverse the buffer.
*/
private _reverse(): this {
if (this.loaded) {
@ -328,13 +328,13 @@ export class ToneAudioBuffer extends Tone {
///////////////////////////////////////////////////////////////////////////
/**
* A path which is prefixed before every url.
* A path which is prefixed before every url.
*/
static baseUrl = "";
/**
* Create a ToneAudioBuffer from the array. To create a multichannel AudioBuffer,
* pass in a multidimensional array.
* Create a ToneAudioBuffer from the array. To create a multichannel AudioBuffer,
* pass in a multidimensional array.
* @param array The array to fill the audio buffer
* @return A ToneAudioBuffer created from the array
*/
@ -358,7 +358,7 @@ export class ToneAudioBuffer extends Tone {
static downloads: Array<Promise<AudioBuffer>> = [];
/**
* Loads a url using fetch and returns the AudioBuffer.
* Loads a url using fetch and returns the AudioBuffer.
*/
static async load(url: string): Promise<AudioBuffer> {
@ -388,7 +388,7 @@ export class ToneAudioBuffer extends Tone {
}
/**
* Checks a url's extension to see if the current browser can play that file type.
* Checks a url's extension to see if the current browser can play that file type.
* @param url The url/extension to test
* @return If the file extension can be played
* @static
@ -404,7 +404,7 @@ export class ToneAudioBuffer extends Tone {
}
/**
* Returns a Promise which resolves when all of the buffers have loaded
* Returns a Promise which resolves when all of the buffers have loaded
*/
static async loaded(): Promise<void> {
for (const promise of ToneAudioBuffer.downloads) {

View file

@ -22,20 +22,20 @@ interface ToneAudioBuffersOptions {
* @example
* //load a whole bank of piano samples
* var pianoSamples = new ToneAudioBuffers({
* "C4" : "path/to/C4.mp3"
* "C#4" : "path/to/C#4.mp3"
* "D4" : "path/to/D4.mp3"
* "D#4" : "path/to/D#4.mp3"
* "C4" : "path/to/C4.mp3"
* "C#4" : "path/to/C#4.mp3"
* "D4" : "path/to/D4.mp3"
* "D#4" : "path/to/D#4.mp3"
* }, function(){
* //play one of the samples when they all load
* player.buffer = pianoSamples.get("C4");
* player.start();
* //play one of the samples when they all load
* player.buffer = pianoSamples.get("C4");
* player.start();
* });
* @example
* //To pass in additional parameters in the second parameter
* var buffers = new ToneAudioBuffers(urls, {
* "onload" : callback,
* "baseUrl" : "../path/to/audio/"
* "onload" : callback,
* "baseUrl" : "../path/to/audio/"
* })
* @category Core
*/
@ -44,12 +44,12 @@ export class ToneAudioBuffers extends Tone {
readonly name: string = "ToneAudioBuffers";
/**
* All of the buffers
* All of the buffers
*/
private _buffers: Map<string, ToneAudioBuffer> = new Map();
/**
* A path which is prefixed before every url.
* A path which is prefixed before every url.
*/
baseUrl: string;
@ -96,7 +96,7 @@ export class ToneAudioBuffers extends Tone {
}
/**
* True if the buffers object has a buffer by that name.
* True if the buffers object has a buffer by that name.
* @param name The key or index of the buffer.
*/
has(name: string | number): boolean {
@ -104,8 +104,8 @@ export class ToneAudioBuffers extends Tone {
}
/**
* Get a buffer by name. If an array was loaded,
* then use the array index.
* Get a buffer by name. If an array was loaded,
* then use the array index.
* @param name The key or index of the buffer.
*/
get(name: string | number): ToneAudioBuffer {
@ -114,7 +114,7 @@ export class ToneAudioBuffers extends Tone {
}
/**
* A buffer was loaded. decrement the counter.
* A buffer was loaded. decrement the counter.
*/
private _bufferLoaded(callback: () => void): void {
this._loadingCount--;
@ -131,7 +131,7 @@ export class ToneAudioBuffers extends Tone {
}
/**
* Add a buffer by name and url to the Buffers
* Add a buffer by name and url to the Buffers
* @param name A unique name to give the buffer
* @param url Either the url of the bufer, or a buffer which will be added with the given name.
* @param callback The callback to invoke when the url is loaded.

View file

@ -26,7 +26,10 @@ export type ToneAudioNodeOptions = ToneWithContextOptions;
export abstract class ToneAudioNode<Options extends ToneAudioNodeOptions = ToneAudioNodeOptions>
extends ToneWithContext<Options> {
abstract name = "AudioNode";
/**
* The name of the class
*/
abstract readonly name: string = "AudioNode";
/**
* The input node or nodes. If the object is a source,
@ -41,8 +44,8 @@ extends ToneWithContext<Options> {
abstract output: OutputNode | undefined;
/**
* The number of inputs feeding into the AudioNode.
* For source nodes, this will be 0.
* The number of inputs feeding into the AudioNode.
* For source nodes, this will be 0.
*/
get numberOfInputs(): number {
if (isDefined(this.input)) {
@ -57,7 +60,7 @@ extends ToneWithContext<Options> {
}
/**
* The number of outputs of the AudioNode.
* The number of outputs of the AudioNode.
*/
get numberOfOutputs(): number {
if (isDefined(this.output)) {
@ -132,9 +135,9 @@ extends ToneWithContext<Options> {
}
/**
* channelCount is the number of channels used when up-mixing and down-mixing
* connections to any inputs to the node. The default value is 2 except for
* specific nodes where its value is specially determined.
* channelCount is the number of channels used when up-mixing and down-mixing
* connections to any inputs to the node. The default value is 2 except for
* specific nodes where its value is specially determined.
*/
get channelCount(): number {
return this._getChannelProperties().channelCount;
@ -147,9 +150,9 @@ extends ToneWithContext<Options> {
// tslint:disable: max-line-length
/**
* channelCountMode determines how channels will be counted when up-mixing and
* down-mixing connections to any inputs to the node.
* The default value is "max". This attribute has no effect for nodes with no inputs.
* channelCountMode determines how channels will be counted when up-mixing and
* down-mixing connections to any inputs to the node.
* The default value is "max". This attribute has no effect for nodes with no inputs.
* * "max" - computedNumberOfChannels is the maximum of the number of channels of all connections to an input. In this mode channelCount is ignored.
* * "clamped-max" - computedNumberOfChannels is determined as for "max" and then clamped to a maximum value of the given channelCount.
* * "explicit" - computedNumberOfChannels is the exact value as specified by the channelCount.
@ -165,9 +168,9 @@ extends ToneWithContext<Options> {
}
/**
* channelInterpretation determines how individual channels will be treated
* when up-mixing and down-mixing connections to any inputs to the node.
* The default value is "speakers".
* channelInterpretation determines how individual channels will be treated
* when up-mixing and down-mixing connections to any inputs to the node.
* The default value is "speakers".
*/
get channelInterpretation(): ChannelInterpretation {
return this._getChannelProperties().channelInterpretation;
@ -220,10 +223,10 @@ extends ToneWithContext<Options> {
}
/**
* Connect the output of this node to the rest of the nodes in series.
* Connect the output of this node to the rest of the nodes in series.
* @example
* //connect a node to an effect, panVol and then to the master output
* node.chain(effect, panVol, Tone.Destination);
* //connect a node to an effect, panVol and then to the master output
* node.chain(effect, panVol, Tone.Destination);
*/
chain(...nodes: InputNode[]): this {
connectSeries(this, ...nodes);
@ -231,7 +234,7 @@ extends ToneWithContext<Options> {
}
/**
* connect the output of this node to the rest of the nodes in parallel.
* connect the output of this node to the rest of the nodes in parallel.
*/
fan(...nodes: InputNode[]): this {
nodes.forEach(node => this.connect(node));
@ -267,7 +270,7 @@ extends ToneWithContext<Options> {
///////////////////////////////////////////////////////////////////////////////
/**
* connect together all of the arguments in series
* connect together all of the arguments in series
* @param nodes
*/
export function connectSeries(...nodes: InputNode[]): void {

View file

@ -148,8 +148,8 @@ export abstract class ToneWithContext<Options extends ToneWithContextOptions> ex
* @example
* //set values using an object
* filter.set({
* "frequency" : 300,
* "type" : "highpass"
* "frequency" : 300,
* "type" : "highpass"
* });
*/
set(props: RecursivePartial<Options>): this {

View file

@ -1,7 +1,7 @@
import { Decibels, GainFactor, Hertz, Interval, MidiNote, NormalRange } from "./Units";
/**
* Equal power gain scale. Good for cross-fading.
* Equal power gain scale. Good for cross-fading.
* @param percent (0-1)
*/
export function equalPowerScale(percent: NormalRange): number {
@ -10,14 +10,14 @@ export function equalPowerScale(percent: NormalRange): number {
}
/**
* Convert decibels into gain.
* Convert decibels into gain.
*/
export function dbToGain(db: Decibels): GainFactor {
return Math.pow(10, db / 20);
}
/**
* Convert gain to decibels.
* Convert gain to decibels.
*/
export function gainToDb(gain: GainFactor): Decibels {
return 20 * (Math.log(gain) / Math.LN10);

View file

@ -138,14 +138,14 @@ export class FrequencyClass<Type extends number = Hertz> extends TimeClass<Type,
}
/**
* Return the duration of one cycle in seconds.
* Return the duration of one cycle in seconds.
*/
toSeconds(): Seconds {
return 1 / super.toSeconds();
}
/**
* Return the duration of one cycle in ticks
* Return the duration of one cycle in ticks
*/
toTicks(): Ticks {
const quarterTime = this._beatsToUnits(1);
@ -158,35 +158,35 @@ export class FrequencyClass<Type extends number = Hertz> extends TimeClass<Type,
///////////////////////////////////////////////////////////////////////////
/**
* With no arguments, return 0
* With no arguments, return 0
*/
protected _noArg(): Type {
return 0 as Type;
}
/**
* Returns the value of a frequency in the current units
* Returns the value of a frequency in the current units
*/
protected _frequencyToUnits(freq: Hertz): Type {
return freq as Type;
}
/**
* Returns the value of a tick in the current time units
* Returns the value of a tick in the current time units
*/
protected _ticksToUnits(ticks: Ticks): Type {
return 1 / ((ticks * 60) / (this._getBpm() * this._getPPQ())) as Type;
}
/**
* Return the value of the beats in the current units
* Return the value of the beats in the current units
*/
protected _beatsToUnits(beats: number): Type {
return 1 / super._beatsToUnits(beats) as Type;
}
/**
* Returns the value of a second in the current units
* Returns the value of a second in the current units
*/
protected _secondsToUnits(seconds: Seconds): Type {
return 1 / seconds as Type;

View file

@ -19,35 +19,35 @@ export class MidiClass extends FrequencyClass<MidiNote> {
readonly defaultUnits = "midi";
/**
* Returns the value of a frequency in the current units
* Returns the value of a frequency in the current units
*/
protected _frequencyToUnits(freq: Hertz): MidiNote {
return ftom(super._frequencyToUnits(freq));
}
/**
* Returns the value of a tick in the current time units
* Returns the value of a tick in the current time units
*/
protected _ticksToUnits(ticks: Ticks): MidiNote {
return ftom(super._ticksToUnits(ticks));
}
/**
* Return the value of the beats in the current units
* Return the value of the beats in the current units
*/
protected _beatsToUnits(beats: number): MidiNote {
return ftom(super._beatsToUnits(beats));
}
/**
* Returns the value of a second in the current units
* Returns the value of a second in the current units
*/
protected _secondsToUnits(seconds: Seconds): MidiNote {
return ftom(super._secondsToUnits(seconds));
}
/**
* Return the value of the frequency as a MIDI note
* Return the value of the frequency as a MIDI note
* @return {MIDI}
* @example
* Midi(60).toMidi(); //60
@ -57,7 +57,7 @@ export class MidiClass extends FrequencyClass<MidiNote> {
}
/**
* Return the value of the frequency as a MIDI note
* Return the value of the frequency as a MIDI note
* @return {MIDI}
* @example
* Midi(60).toFrequency(); //261.6255653005986
@ -67,7 +67,7 @@ export class MidiClass extends FrequencyClass<MidiNote> {
}
/**
* Transposes the frequency by the given number of semitones.
* Transposes the frequency by the given number of semitones.
* @return A new transposed MidiClass
* @example
* Midi("A4").transpose(3); //"C5"

View file

@ -25,35 +25,35 @@ export class TicksClass extends TransportTimeClass<Ticks> {
}
/**
* Return the value of the beats in the current units
* Return the value of the beats in the current units
*/
protected _beatsToUnits(beats: number): Ticks {
return this._getPPQ() * beats;
}
/**
* Returns the value of a second in the current units
* Returns the value of a second in the current units
*/
protected _secondsToUnits(seconds: Seconds): Ticks {
return Math.floor(seconds / (60 / this._getBpm()) * this._getPPQ());
}
/**
* Returns the value of a tick in the current time units
* Returns the value of a tick in the current time units
*/
protected _ticksToUnits(ticks: Ticks): Ticks {
return ticks;
}
/**
* Return the time in ticks
* Return the time in ticks
*/
toTicks(): Ticks {
return this.valueOf() as Ticks;
}
/**
* Return the time in seconds
* Return the time in seconds
*/
toSeconds(): Seconds {
return (this.valueOf() / this._getPPQ()) * (60 / this._getBpm());

View file

@ -58,8 +58,8 @@ extends TimeBaseClass<Type, Unit> {
// CONVERSIONS
///////////////////////////////////////////////////////////////////////////
/**
* Convert a Time to Notation. The notation values are will be the
* closest representation between 1m to 128th note.
* Convert a Time to Notation. The notation values are will be the
* closest representation between 1m to 128th note.
* @return {Notation}
* @example
* //if the Transport is at 120bpm:
@ -89,7 +89,7 @@ extends TimeBaseClass<Type, Unit> {
}
/**
* Return the time encoded as Bars:Beats:Sixteenths.
* Return the time encoded as Bars:Beats:Sixteenths.
*/
toBarsBeatsSixteenths(): BarsBeatsSixteenths {
const quarterTime = this._beatsToUnits(1);
@ -108,7 +108,7 @@ extends TimeBaseClass<Type, Unit> {
}
/**
* Return the time in ticks.
* Return the time in ticks.
*/
toTicks(): Ticks {
const quarterTime = this._beatsToUnits(1);
@ -117,14 +117,14 @@ extends TimeBaseClass<Type, Unit> {
}
/**
* Return the time in seconds.
* Return the time in seconds.
*/
toSeconds(): Seconds {
return this.valueOf();
}
/**
* Return the value as a midi note.
* Return the value as a midi note.
*/
toMidi(): MidiNote {
return ftom(this.toFrequency());

View file

@ -155,7 +155,7 @@ export abstract class TimeBaseClass<Type extends number, Unit extends string> ex
///////////////////////////////////////////////////////////////////////////
/**
* Evaluate the time value. Returns the time in seconds.
* Evaluate the time value. Returns the time in seconds.
*/
valueOf(): Type {
if (this._val instanceof TimeBaseClass) {
@ -202,35 +202,35 @@ export abstract class TimeBaseClass<Type extends number, Unit extends string> ex
///////////////////////////////////////////////////////////////////////////
/**
* Returns the value of a frequency in the current units
* Returns the value of a frequency in the current units
*/
protected _frequencyToUnits(freq: Hertz): Type {
return 1 / freq as Type;
}
/**
* Return the value of the beats in the current units
* Return the value of the beats in the current units
*/
protected _beatsToUnits(beats: number): Type {
return (60 / this._getBpm()) * beats as Type;
}
/**
* Returns the value of a second in the current units
* Returns the value of a second in the current units
*/
protected _secondsToUnits(seconds: Seconds): Type {
return seconds as Type;
}
/**
* Returns the value of a tick in the current time units
* Returns the value of a tick in the current time units
*/
protected _ticksToUnits(ticks: Ticks): Type {
return (ticks * (this._beatsToUnits(1)) / this._getPPQ()) as Type;
}
/**
* With no arguments, return 'now'
* With no arguments, return 'now'
*/
protected _noArg(): Type {
return this._now();
@ -294,12 +294,12 @@ export abstract class TimeBaseClass<Type extends number, Unit extends string> ex
}
/**
* Return the value in seconds
* Return the value in seconds
*/
abstract toSeconds(): Seconds;
/**
* Return the value as a Midi note
* Return the value as a Midi note
*/
abstract toMidi(): MidiNote;
@ -309,21 +309,21 @@ export abstract class TimeBaseClass<Type extends number, Unit extends string> ex
abstract toTicks(): Ticks;
/**
* Return the value in hertz
* Return the value in hertz
*/
toFrequency(): Hertz {
return 1 / this.toSeconds();
}
/**
* Return the time in samples
* Return the time in samples
*/
toSamples(): Samples {
return this.toSeconds() * this.context.sampleRate;
}
/**
* Return the time in milliseconds.
* Return the time in milliseconds.
*/
toMilliseconds(): Milliseconds {
return this.toSeconds() * 1000;

View file

@ -27,7 +27,7 @@ export type NormalRange = number;
export type AudioRange = number;
/**
* Half-step note increments, i.e. 12 is an octave above the root. and 1 is a half-step up.
* Half-step note increments, i.e. 12 is an octave above the root. and 1 is a half-step up.
* @category Unit
*/
export type Interval = number;
@ -73,27 +73,26 @@ export type TimeObject = {
// tslint:disable: max-line-length
/**
* Time can be described in a number of ways. Read more [Time](https://github.com/Tonejs/Tone.js/wiki/Time).
*
* * Numbers, which will be taken literally as the time (in seconds).
* * Notation, ("4n", "8t") describes time in BPM and time signature relative values.
* * TransportTime, ("4:3:2") will also provide tempo and time signature relative times in the form BARS:QUARTERS:SIXTEENTHS.
* * Frequency, ("8hz") is converted to the length of the cycle in seconds.
* * Now-Relative, ("+1") prefix any of the above with "+" and it will be interpreted as "the current time plus whatever expression follows".
* * Object, ({"4n" : 3, "8t" : -1}). The resulting time is equal to the sum of all of the keys multiplied by the values in the object.
* * No Argument, for methods which accept time, no argument will be interpreted as "now" (i.e. the currentTime).
* Time can be described in a number of ways. Read more [Time](https://github.com/Tonejs/Tone.js/wiki/Time).
* * Numbers, which will be taken literally as the time (in seconds).
* * Notation, ("4n", "8t") describes time in BPM and time signature relative values.
* * TransportTime, ("4:3:2") will also provide tempo and time signature relative times in the form BARS:QUARTERS:SIXTEENTHS.
* * Frequency, ("8hz") is converted to the length of the cycle in seconds.
* * Now-Relative, ("+1") prefix any of the above with "+" and it will be interpreted as "the current time plus whatever expression follows".
* * Object, ({"4n" : 3, "8t" : -1}). The resulting time is equal to the sum of all of the keys multiplied by the values in the object.
* * No Argument, for methods which accept time, no argument will be interpreted as "now" (i.e. the currentTime).
* @category Unit
*/
// tslint:enable: max-line-length
export type Time = string | Seconds | TimeObject | Subdivision;
/**
* Frequency can be described similar to time, except ultimately the
* values are converted to frequency instead of seconds. A number
* is taken literally as the value in hertz. Additionally any of the
* Time encodings can be used. Note names in the form
* of NOTE OCTAVE (i.e. C4) are also accepted and converted to their
* frequency value.
* Frequency can be described similar to time, except ultimately the
* values are converted to frequency instead of seconds. A number
* is taken literally as the value in hertz. Additionally any of the
* Time encodings can be used. Note names in the form
* of NOTE OCTAVE (i.e. C4) are also accepted and converted to their
* frequency value.
* @category Unit
*/
export type Frequency = Subdivision | Note | string | Hertz;
@ -105,54 +104,54 @@ export type Frequency = Subdivision | Note | string | Hertz;
export type TimeSignature = number | number[];
/**
* TransportTime describes a position along the Transport's timeline. It is
* similar to Time in that it uses all the same encodings, but TransportTime specifically
* pertains to the Transport's timeline, which is startable, stoppable, loopable, and seekable.
* [Read more](https://github.com/Tonejs/Tone.js/wiki/TransportTime)
* TransportTime describes a position along the Transport's timeline. It is
* similar to Time in that it uses all the same encodings, but TransportTime specifically
* pertains to the Transport's timeline, which is startable, stoppable, loopable, and seekable.
* [Read more](https://github.com/Tonejs/Tone.js/wiki/TransportTime)
* @category Unit
*/
export type TransportTime = Time;
/**
* Ticks are the basic subunit of the Transport. They are
* the smallest unit of time that the Transport supports.
* Ticks are the basic subunit of the Transport. They are
* the smallest unit of time that the Transport supports.
* @category Unit
*/
export type Ticks = number;
/**
* Beats per minute
* Beats per minute
* @category Unit
*/
export type BPM = number;
/**
* Angle between 0 and 360.
* Angle between 0 and 360.
* @category Unit
*/
export type Degrees = number;
/**
* Angle between 0 and 2 * PI.
* Angle between 0 and 2 * PI.
* @category Unit
*/
export type Radians = number;
/**
* A colon-separated representation of time in the form of
* Bars:Beats:Sixteenths.
* A colon-separated representation of time in the form of
* Bars:Beats:Sixteenths.
* @category Unit
*/
export type BarsBeatsSixteenths = string;
/**
* Sampling is the reduction of a continuous signal to a discrete signal.
* Audio is typically sampled 44100 times per second.
* Sampling is the reduction of a continuous signal to a discrete signal.
* Audio is typically sampled 44100 times per second.
* @category Unit
*/
export type Samples = number | "samples";
/**
* Hertz are a frequency representation defined as one cycle per second.
* Hertz are a frequency representation defined as one cycle per second.
* @category Unit
*/
export type Hertz = number;
@ -165,13 +164,13 @@ export type Hertz = number;
export type Cents = number;
/**
* One millisecond is a thousandth of a second.
* One millisecond is a thousandth of a second.
* @category Unit
*/
export type Milliseconds = number;
/**
* A value which is a power of 2
* A value which is a power of 2
* @category Unit
*/
export type PowerOfTwo = number;

View file

@ -1,5 +1,5 @@
/**
* Assert that the statement is true, otherwise invoke an error with the given message.
* Assert that the statement is true, otherwise invoke an error with the given message.
*/
export function assert(statement: boolean, error: string): void {
if (!statement) {

View file

@ -27,24 +27,24 @@ export class Draw extends ToneWithContext<ToneWithContextOptions> {
readonly name: string = "Draw";
/**
* The duration after which events are not invoked.
* The duration after which events are not invoked.
*/
expiration: Seconds = 0.25;
/**
* The amount of time before the scheduled time
* that the callback can be invoked. Default is
* half the time of an animation frame (0.008 seconds).
* The amount of time before the scheduled time
* that the callback can be invoked. Default is
* half the time of an animation frame (0.008 seconds).
*/
anticipation: Seconds = 0.008;
/**
* All of the events.
* All of the events.
*/
private _events: Timeline<DrawEvent> = new Timeline();
/**
* The draw loop
* The draw loop
*/
private _boundDrawLoop = this._drawLoop.bind(this);
@ -54,8 +54,8 @@ export class Draw extends ToneWithContext<ToneWithContextOptions> {
private _animationFrame: number = -1;
/**
* Schedule a function at the given time to be invoked
* on the nearest animation frame.
* Schedule a function at the given time to be invoked
* on the nearest animation frame.
* @param callback Callback is invoked at the given time.
* @param time The time relative to the AudioContext time to invoke the callback.
*/
@ -72,7 +72,7 @@ export class Draw extends ToneWithContext<ToneWithContextOptions> {
}
/**
* Cancel events scheduled after the given time
* Cancel events scheduled after the given time
* @param after Time after which scheduled events will be removed from the scheduling timeline.
*/
cancel(after?: Time): this {
@ -81,7 +81,7 @@ export class Draw extends ToneWithContext<ToneWithContextOptions> {
}
/**
* The draw loop
* The draw loop
*/
private _drawLoop(): void {
const now = this.context.currentTime;

View file

@ -22,7 +22,7 @@ export class Emitter<EventType extends string = string> extends Tone {
private _events?: EmitterEventObject;
/**
* Bind a callback to a specific event.
* Bind a callback to a specific event.
* @param event The name of the event to listen for.
* @param callback The callback to invoke when the event is emitted
*/
@ -42,7 +42,7 @@ export class Emitter<EventType extends string = string> extends Tone {
}
/**
* Bind a callback which is only invoked once
* Bind a callback which is only invoked once
* @param event The name of the event to listen for.
* @param callback The callback to invoke when the event is emitted
*/
@ -58,10 +58,10 @@ export class Emitter<EventType extends string = string> extends Tone {
}
/**
* Remove the event listener.
* Remove the event listener.
* @param event The event to stop listening to.
* @param callback The callback which was bound to the event with Emitter.on.
* If no callback is given, all callbacks events are removed.
* If no callback is given, all callbacks events are removed.
*/
off(event: EventType, callback?: (...args: any[]) => void): this {
const events = event.split(/\W+/);
@ -86,8 +86,8 @@ export class Emitter<EventType extends string = string> extends Tone {
}
/**
* Invoke all of the callbacks bound to the event
* with any arguments passed in.
* Invoke all of the callbacks bound to the event
* with any arguments passed in.
* @param event The name of the event.
* @param args The arguments to pass to the functions listening.
*/
@ -104,7 +104,7 @@ export class Emitter<EventType extends string = string> extends Tone {
}
/**
* Add Emitter functions (on/off/emit) to the object
* Add Emitter functions (on/off/emit) to the object
*/
static mixin(constr: any): void {
// instance._events = {};
@ -115,7 +115,7 @@ export class Emitter<EventType extends string = string> extends Tone {
}
/**
* Clean up
* Clean up
*/
dispose(): this {
super.dispose();

View file

@ -4,7 +4,7 @@ import { isArray } from "./TypeCheck";
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
/**
* Make the property not writable using `defineProperty`. Internal use only.
* Make the property not writable using `defineProperty`. Internal use only.
*/
export function readOnly(target: object, property: string | string[]): void {
if (isArray(property)) {
@ -18,7 +18,7 @@ export function readOnly(target: object, property: string | string[]): void {
}
/**
* Make an attribute writeable. Internal use only.
* Make an attribute writeable. Internal use only.
*/
export function writable(target: object, property: string | string[]): void {
if (isArray(property)) {

View file

@ -26,18 +26,18 @@ export class IntervalTimeline extends Tone {
readonly name: string = "IntervalTimeline";
/**
* The root node of the inteval tree
* The root node of the inteval tree
*/
private _root: IntervalNode | null = null;
/**
* Keep track of the length of the timeline.
* Keep track of the length of the timeline.
*/
private _length: number = 0;
/**
* The event to add to the timeline. All events must
* have a time and duration value
* The event to add to the timeline. All events must
* have a time and duration value
* @param event The event to add to the timeline
*/
add(event: IntervalTimelineEvent): this {
@ -63,7 +63,7 @@ export class IntervalTimeline extends Tone {
}
/**
* Remove an event from the timeline.
* Remove an event from the timeline.
* @param event The event to remove from the timeline
*/
remove(event: IntervalTimelineEvent): this {
@ -82,7 +82,7 @@ export class IntervalTimeline extends Tone {
}
/**
* The number of items in the timeline.
* The number of items in the timeline.
* @readOnly
*/
get length(): number {
@ -90,7 +90,7 @@ export class IntervalTimeline extends Tone {
}
/**
* Remove events whose time time is after the given time
* Remove events whose time time is after the given time
* @param time The time to query.
*/
cancel(after: number): this {
@ -99,7 +99,7 @@ export class IntervalTimeline extends Tone {
}
/**
* Set the root node as the given node
* Set the root node as the given node
*/
private _setRoot(node: IntervalNode | null): void {
this._root = node;
@ -109,8 +109,8 @@ export class IntervalTimeline extends Tone {
}
/**
* Replace the references to the node in the node's parent
* with the replacement node.
* Replace the references to the node in the node's parent
* with the replacement node.
*/
private _replaceNodeInParent(node: IntervalNode, replacement: IntervalNode | null): void {
if (node.parent !== null) {
@ -126,8 +126,8 @@ export class IntervalTimeline extends Tone {
}
/**
* Remove the node from the tree and replace it with
* a successor which follows the schema.
* Remove the node from the tree and replace it with
* a successor which follows the schema.
*/
private _removeNode(node: IntervalNode): void {
if (node.left === null && node.right === null) {
@ -190,7 +190,7 @@ export class IntervalTimeline extends Tone {
}
/**
* Rotate the tree to the left
* Rotate the tree to the left
*/
private _rotateLeft(node: IntervalNode): void {
const parent = node.parent;
@ -215,7 +215,7 @@ export class IntervalTimeline extends Tone {
}
/**
* Rotate the tree to the right
* Rotate the tree to the right
*/
private _rotateRight(node: IntervalNode): void {
const parent = node.parent;
@ -240,7 +240,7 @@ export class IntervalTimeline extends Tone {
}
/**
* Balance the BST
* Balance the BST
*/
private _rebalance(node: IntervalNode): void {
const balance = node.getBalance();
@ -260,8 +260,8 @@ export class IntervalTimeline extends Tone {
}
/**
* Get an event whose time and duration span the give time. Will
* return the match whose "time" value is closest to the given time.
* Get an event whose time and duration span the give time. Will
* return the match whose "time" value is closest to the given time.
* @return The event which spans the desired time
*/
get(time: number): IntervalTimelineEvent | null {
@ -282,7 +282,7 @@ export class IntervalTimeline extends Tone {
}
/**
* Iterate over everything in the timeline.
* Iterate over everything in the timeline.
* @param callback The callback to invoke with every item
*/
forEach(callback: IteratorCallback): this {
@ -299,8 +299,8 @@ export class IntervalTimeline extends Tone {
}
/**
* Iterate over everything in the array in which the given time
* overlaps with the time and duration time of the event.
* Iterate over everything in the array in which the given time
* overlaps with the time and duration time of the event.
* @param time The time to check if items are overlapping
* @param callback The callback to invoke with every item
*/
@ -318,8 +318,8 @@ export class IntervalTimeline extends Tone {
}
/**
* Iterate over everything in the array in which the time is greater
* than or equal to the given time.
* Iterate over everything in the array in which the time is greater
* than or equal to the given time.
* @param time The time to check if items are before
* @param callback The callback to invoke with every item
*/
@ -337,7 +337,7 @@ export class IntervalTimeline extends Tone {
}
/**
* Clean up
* Clean up
*/
dispose(): this {
super.dispose();
@ -354,12 +354,12 @@ export class IntervalTimeline extends Tone {
///////////////////////////////////////////////////////////////////////////
/**
* Represents a node in the binary search tree, with the addition
* of a "high" value which keeps track of the highest value of
* its children.
* References:
* https://brooknovak.wordpress.com/2013/12/07/augmented-interval-tree-in-c/
* http://www.mif.vu.lt/~valdas/ALGORITMAI/LITERATURA/Cormen/Cormen.pdf
* Represents a node in the binary search tree, with the addition
* of a "high" value which keeps track of the highest value of
* its children.
* References:
* https://brooknovak.wordpress.com/2013/12/07/augmented-interval-tree-in-c/
* http://www.mif.vu.lt/~valdas/ALGORITMAI/LITERATURA/Cormen/Cormen.pdf
* @param low
* @param high
*/
@ -394,7 +394,7 @@ class IntervalNode {
}
/**
* Insert a node into the correct spot in the tree
* Insert a node into the correct spot in the tree
*/
insert(node: IntervalNode): void {
if (node.low <= this.low) {
@ -411,8 +411,8 @@ class IntervalNode {
}
/**
* Search the tree for nodes which overlap
* with the given point
* Search the tree for nodes which overlap
* with the given point
* @param point The point to query
* @param results The array to put the results
*/
@ -442,8 +442,8 @@ class IntervalNode {
}
/**
* Search the tree for nodes which are less
* than the given point
* Search the tree for nodes which are less
* than the given point
* @param point The point to query
* @param results The array to put the results
*/
@ -462,7 +462,7 @@ class IntervalNode {
}
/**
* Invoke the callback on this element and both it's branches
* Invoke the callback on this element and both it's branches
* @param {Function} callback
*/
traverse(callback: (self: IntervalNode) => void): void {
@ -476,7 +476,7 @@ class IntervalNode {
}
/**
* Update the height of the node
* Update the height of the node
*/
updateHeight(): void {
if (this.left !== null && this.right !== null) {
@ -491,7 +491,7 @@ class IntervalNode {
}
/**
* Update the height of the node
* Update the height of the node
*/
updateMax(): void {
this.max = this.high;
@ -504,7 +504,7 @@ class IntervalNode {
}
/**
* The balance is how the leafs are distributed on the node
* The balance is how the leafs are distributed on the node
* @return Negative numbers are balanced to the right
*/
getBalance(): number {
@ -527,7 +527,7 @@ class IntervalNode {
}
/**
* get/set the left node
* get/set the left node
*/
get left(): IntervalNode | null {
return this._left;
@ -543,7 +543,7 @@ class IntervalNode {
}
/**
* get/set the right node
* get/set the right node
*/
get right(): IntervalNode | null {
return this._right;
@ -559,7 +559,7 @@ class IntervalNode {
}
/**
* null out references.
* null out references.
*/
dispose(): void {
this.parent = null;

View file

@ -9,7 +9,7 @@ export interface StateTimelineEvent extends TimelineEvent {
}
/**
* A Timeline State. Provides the methods: `setStateAtTime("state", time)` and `getValueAtTime(time)`
* A Timeline State. Provides the methods: `setStateAtTime("state", time)` and `getValueAtTime(time)`
* @param initial The initial state of the StateTimeline. Defaults to `undefined`
* @category Core
*/
@ -18,7 +18,7 @@ export class StateTimeline<AdditionalOptions extends {} = {}> extends Timeline<S
readonly name: string = "StateTimeline";
/**
* The initial state
* The initial state
*/
private _initial: PlaybackState;
@ -28,8 +28,8 @@ export class StateTimeline<AdditionalOptions extends {} = {}> extends Timeline<S
}
/**
* Returns the scheduled state scheduled before or at
* the given time.
* Returns the scheduled state scheduled before or at
* the given time.
* @param time The time to query.
* @return The name of the state input in setStateAtTime.
*/
@ -43,7 +43,7 @@ export class StateTimeline<AdditionalOptions extends {} = {}> extends Timeline<S
}
/**
* Add a state to the timeline.
* Add a state to the timeline.
* @param state The name of the state to set.
* @param time The time to query.
* @param options Any additional options that are needed in the timeline.
@ -59,7 +59,7 @@ export class StateTimeline<AdditionalOptions extends {} = {}> extends Timeline<S
}
/**
* Return the event before the time with the given state
* Return the event before the time with the given state
* @param state The state to look for
* @param time When to check before
* @return The event with the given state before the time
@ -76,7 +76,7 @@ export class StateTimeline<AdditionalOptions extends {} = {}> extends Timeline<S
}
/**
* Return the event after the time with the given state
* Return the event after the time with the given state
* @param state The state to look for
* @param time When to check from
* @return The event with the given state after the time

View file

@ -30,8 +30,8 @@ export class Timeline<GenericEvent extends TimelineEvent> extends Tone {
readonly name: string = "Timeline";
/**
* The memory of the timeline, i.e.
* how many events in the past it will retain
* The memory of the timeline, i.e.
* how many events in the past it will retain
*/
memory: number;
@ -60,14 +60,14 @@ export class Timeline<GenericEvent extends TimelineEvent> extends Tone {
}
/**
* The number of items in the timeline.
* The number of items in the timeline.
*/
get length(): number {
return this._timeline.length;
}
/**
* Insert an event object onto the timeline. Events must have a "time" attribute.
* Insert an event object onto the timeline. Events must have a "time" attribute.
* @param event The event object to insert into the timeline.
*/
add(event: GenericEvent): this {
@ -85,7 +85,7 @@ export class Timeline<GenericEvent extends TimelineEvent> extends Tone {
}
/**
* Remove an event from the timeline.
* Remove an event from the timeline.
* @param {Object} event The event object to remove from the list.
* @returns {Timeline} this
*/
@ -98,7 +98,7 @@ export class Timeline<GenericEvent extends TimelineEvent> extends Tone {
}
/**
* Get the nearest event whose time is less than or equal to the given time.
* Get the nearest event whose time is less than or equal to the given time.
* @param time The time to query.
*/
get(time: number, param: TimelineSearchParam = "time"): GenericEvent | null {
@ -111,7 +111,7 @@ export class Timeline<GenericEvent extends TimelineEvent> extends Tone {
}
/**
* Return the first event in the timeline without removing it
* Return the first event in the timeline without removing it
* @returns {Object} The first event object
*/
peek(): GenericEvent | undefined {
@ -119,14 +119,14 @@ export class Timeline<GenericEvent extends TimelineEvent> extends Tone {
}
/**
* Return the first event in the timeline and remove it
* Return the first event in the timeline and remove it
*/
shift(): GenericEvent | undefined {
return this._timeline.shift();
}
/**
* Get the event which is scheduled after the given time.
* Get the event which is scheduled after the given time.
* @param time The time to query.
*/
getAfter(time: number, param: TimelineSearchParam = "time"): GenericEvent | null {
@ -139,7 +139,7 @@ export class Timeline<GenericEvent extends TimelineEvent> extends Tone {
}
/**
* Get the event before the event at the given time.
* Get the event before the event at the given time.
* @param time The time to query.
*/
getBefore(time: number): GenericEvent | null {
@ -157,7 +157,7 @@ export class Timeline<GenericEvent extends TimelineEvent> extends Tone {
}
/**
* Cancel events at and after the given time
* Cancel events at and after the given time
* @param time The time to query.
*/
cancel(after: number): this {
@ -190,7 +190,7 @@ export class Timeline<GenericEvent extends TimelineEvent> extends Tone {
}
/**
* Cancel events before or equal to the given time.
* Cancel events before or equal to the given time.
* @param time The time to cancel before.
*/
cancelBefore(time: number): this {
@ -216,10 +216,10 @@ export class Timeline<GenericEvent extends TimelineEvent> extends Tone {
}
/**
* Does a binary search on the timeline array and returns the
* nearest event index whose time is after or equal to the given time.
* If a time is searched before the first index in the timeline, -1 is returned.
* If the time is after the end, the index of the last item is returned.
* Does a binary search on the timeline array and returns the
* nearest event index whose time is after or equal to the given time.
* If a time is searched before the first index in the timeline, -1 is returned.
* If the time is after the end, the index of the last item is returned.
* @param time
*/
protected _search(time: number, param: TimelineSearchParam = "time"): number {
@ -260,8 +260,8 @@ export class Timeline<GenericEvent extends TimelineEvent> extends Tone {
}
/**
* Internal iterator. Applies extra safety checks for
* removing items from the array.
* Internal iterator. Applies extra safety checks for
* removing items from the array.
*/
private _iterate(
callback: (event: GenericEvent) => void,
@ -271,7 +271,7 @@ export class Timeline<GenericEvent extends TimelineEvent> extends Tone {
}
/**
* Iterate over everything in the array
* Iterate over everything in the array
* @param callback The callback to invoke with every item
*/
forEach(callback: (event: GenericEvent) => void): this {
@ -280,7 +280,7 @@ export class Timeline<GenericEvent extends TimelineEvent> extends Tone {
}
/**
* Iterate over everything in the array at or before the given time.
* Iterate over everything in the array at or before the given time.
* @param time The time to check if items are before
* @param callback The callback to invoke with every item
*/
@ -294,7 +294,7 @@ export class Timeline<GenericEvent extends TimelineEvent> extends Tone {
}
/**
* Iterate over everything in the array after the given time.
* Iterate over everything in the array after the given time.
* @param time The time to check if items are before
* @param callback The callback to invoke with every item
*/
@ -306,9 +306,9 @@ export class Timeline<GenericEvent extends TimelineEvent> extends Tone {
}
/**
* Iterate over everything in the array between the startTime and endTime.
* The timerange is inclusive of the startTime, but exclusive of the endTime.
* range = [startTime, endTime).
* Iterate over everything in the array between the startTime and endTime.
* The timerange is inclusive of the startTime, but exclusive of the endTime.
* range = [startTime, endTime).
* @param startTime The time to check if items are before
* @param endTime The end of the test interval.
* @param callback The callback to invoke with every item
@ -332,8 +332,8 @@ export class Timeline<GenericEvent extends TimelineEvent> extends Tone {
}
/**
* Iterate over everything in the array at or after the given time. Similar to
* forEachAfter, but includes the item(s) at the given time.
* Iterate over everything in the array at or after the given time. Similar to
* forEachAfter, but includes the item(s) at the given time.
* @param time The time to check if items are before
* @param callback The callback to invoke with every item
*/
@ -349,7 +349,7 @@ export class Timeline<GenericEvent extends TimelineEvent> extends Tone {
}
/**
* Iterate over everything in the array at the given time
* Iterate over everything in the array at the given time
* @param time The time to check if items are before
* @param callback The callback to invoke with every item
*/
@ -367,7 +367,7 @@ export class Timeline<GenericEvent extends TimelineEvent> extends Tone {
}
/**
* Clean up.
* Clean up.
*/
dispose(): this {
super.dispose();

View file

@ -1,64 +1,64 @@
import { Note } from "../type/Units";
/**
* Test if the arg is undefined
* Test if the arg is undefined
*/
export function isUndef(arg: any): arg is undefined {
return typeof arg === "undefined";
}
/**
* Test if the arg is not undefined
* Test if the arg is not undefined
*/
export function isDefined<T>(arg: T | undefined): arg is T {
return !isUndef(arg);
}
/**
* Test if the arg is a function
* Test if the arg is a function
*/
export function isFunction(arg: any): arg is (a: any) => any {
return typeof arg === "function";
}
/**
* Test if the argument is a number.
* Test if the argument is a number.
*/
export function isNumber(arg: any): arg is number {
return (typeof arg === "number");
}
/**
* Test if the given argument is an object literal (i.e. `{}`);
* Test if the given argument is an object literal (i.e. `{}`);
*/
export function isObject(arg: any): arg is object {
return (Object.prototype.toString.call(arg) === "[object Object]" && arg.constructor === Object);
}
/**
* Test if the argument is a boolean.
* Test if the argument is a boolean.
*/
export function isBoolean(arg: any): arg is boolean {
return (typeof arg === "boolean");
}
/**
* Test if the argument is an Array
* Test if the argument is an Array
*/
export function isArray(arg: any): arg is any[] {
return (Array.isArray(arg));
}
/**
* Test if the argument is a string.
* Test if the argument is a string.
*/
export function isString(arg: any): arg is string {
return (typeof arg === "string");
}
/**
* Test if the argument is in the form of a note in scientific pitch notation.
* e.g. "C4"
* Test if the argument is in the form of a note in scientific pitch notation.
* e.g. "C4"
*/
export function isNote(arg: any): arg is Note {
return isString(arg) && /^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(arg);

View file

@ -24,12 +24,12 @@ export class Convolver extends Effect<ToneConvolverOptions> {
readonly name: string = "Convolver";
/**
* The native ConvolverNode
* The native ConvolverNode
*/
private _convolver: ConvolverNode = this.context.createConvolver();
/**
* The Buffer belonging to the convolver
* The Buffer belonging to the convolver
*/
private _buffer: ToneAudioBuffer;
@ -79,7 +79,7 @@ export class Convolver extends Effect<ToneConvolverOptions> {
}
/**
* The convolver's buffer
* The convolver's buffer
*/
get buffer(): ToneAudioBuffer | null {
if (this._buffer.length) {

View file

@ -19,24 +19,24 @@ extends ToneAudioNode<Options> {
readonly name: string = "Effect";
/**
* the drywet knob to control the amount of effect
* the drywet knob to control the amount of effect
*/
private _dryWet: CrossFade = new CrossFade({ context : this.context });
/**
* The wet control is how much of the effected
* will pass through to the output. 1 = 100% effected
* signal, 0 = 100% dry signal.
* The wet control is how much of the effected
* will pass through to the output. 1 = 100% effected
* signal, 0 = 100% dry signal.
*/
wet: Signal<NormalRange> = this._dryWet.fade;
/**
* connect the effectSend to the input of hte effect
* connect the effectSend to the input of hte effect
*/
protected effectSend: Gain = new Gain({ context : this.context });
/**
* connect the output of the effect to the effectReturn
* connect the output of the effect to the effectReturn
*/
protected effectReturn: Gain = new Gain({ context : this.context });
@ -68,7 +68,7 @@ extends ToneAudioNode<Options> {
}
/**
* chains the effect in between the effectSend and effectReturn
* chains the effect in between the effectSend and effectReturn
*/
protected connectEffect(effect: ToneAudioNode | AudioNode): this {
// add it to the internal channels

View file

@ -18,8 +18,8 @@ interface FeedbackDelayOptions extends FeedbackEffectOptions {
* @example
* var feedbackDelay = new FeedbackDelay("8n", 0.5).toDestination();
* var tom = new Tone.MembraneSynth({
* "octaves" : 4,
* "pitchDecay" : 0.1
* "octaves" : 4,
* "pitchDecay" : 0.1
* }).connect(feedbackDelay);
* tom.triggerAttackRelease("A2","32n");
*/
@ -28,12 +28,12 @@ export class FeedbackDelay extends FeedbackEffect<FeedbackDelayOptions> {
readonly name: string = "FeedbackDelay";
/**
* the delay node
* the delay node
*/
private _delayNode: Delay;
/**
* The delayTime of the FeedbackDelay.
* The delayTime of the FeedbackDelay.
*/
readonly delayTime: Param<Time>;

View file

@ -27,12 +27,12 @@ export abstract class FeedbackEffect<Options extends FeedbackEffectOptions> exte
readonly name: string = "FeedbackEffect";
/**
* the gain which controls the feedback
* the gain which controls the feedback
*/
private _feedbackGain: Gain<NormalRange>;
/**
* The amount of signal which is fed back into the effect input.
* The amount of signal which is fed back into the effect input.
*/
feedback: Param<NormalRange>;

View file

@ -35,13 +35,13 @@ export class FrequencyShifter extends Effect<FrequencyShifterOptions> {
readonly name: string = "FrequencyShifter";
/**
* The ring modulators carrier frequency. This frequency determines
* by how many Hertz the input signal will be shifted up or down. Default is 0.
* The ring modulators carrier frequency. This frequency determines
* by how many Hertz the input signal will be shifted up or down. Default is 0.
*/
readonly frequency: Signal<Frequency>;
/**
* The ring modulators sine carrier
* The ring modulators sine carrier
*/
private _sine: ToneOscillatorNode;
@ -51,27 +51,27 @@ export class FrequencyShifter extends Effect<FrequencyShifterOptions> {
private _cosine: Oscillator;
/**
* The sine multiply operator
* The sine multiply operator
*/
private _sineMultiply: Multiply;
/**
* The cosine multiply operator
* The cosine multiply operator
*/
private _cosineMultiply: Multiply;
/**
* The negate operator
* The negate operator
*/
private _negate: Negate;
/**
* The final add operator
* The final add operator
*/
private _add: Add;
/**
* The phase shifter to create the initial 90° phase offset
* The phase shifter to create the initial 90° phase offset
*/
private _phaseShifter: PhaseShiftAllpass;

View file

@ -12,14 +12,14 @@ interface ReverbOptions extends EffectOptions {
}
/**
* Simple convolution created with decaying noise.
* Generates an Impulse Response Buffer
* with Tone.Offline then feeds the IR into ConvolverNode.
* Note: the Reverb will not make any sound until [generate](#generate)
* has been invoked and resolved.
* Simple convolution created with decaying noise.
* Generates an Impulse Response Buffer
* with Tone.Offline then feeds the IR into ConvolverNode.
* Note: the Reverb will not make any sound until [generate](#generate)
* has been invoked and resolved.
*
* Inspiration from [ReverbGen](https://github.com/adelespinasse/reverbGen).
* Copyright (c) 2014 Alan deLespinasse Apache 2.0 License.
* Inspiration from [ReverbGen](https://github.com/adelespinasse/reverbGen).
* Copyright (c) 2014 Alan deLespinasse Apache 2.0 License.
*
*/
export class Reverb extends Effect<ReverbOptions> {
@ -27,7 +27,7 @@ export class Reverb extends Effect<ReverbOptions> {
readonly name: string = "Reverb";
/**
* Convolver node
* Convolver node
*/
private _convolver: ConvolverNode = this.context.createConvolver();

View file

@ -33,7 +33,7 @@ interface PartOptions<T> extends Omit<ToneEventOptions<CallbackType<T>>, "value"
* //the value is an object which contains both the note and the velocity
* synth.triggerAttackRelease(value.note, "8n", time, value.velocity);
* }, [{"time" : 0, "note" : "C3", "velocity": 0.9},
* {"time" : "0:2", "note" : "C4", "velocity": 0.5}
* {"time" : "0:2", "note" : "C4", "velocity": 0.5}
* ]).start(0);
*/
export class Part<ValueType = any> extends ToneEvent<ValueType> {
@ -41,7 +41,7 @@ export class Part<ValueType = any> extends ToneEvent<ValueType> {
readonly name: string = "Part";
/**
* Tracks the scheduled events
* Tracks the scheduled events
*/
protected _state: StateTimeline<{
id: number,
@ -81,7 +81,7 @@ export class Part<ValueType = any> extends ToneEvent<ValueType> {
}
/**
* Start the part at the given time.
* Start the part at the given time.
* @param time When to start the part.
* @param offset The offset from the start of the part to begin playing at.
*/
@ -109,8 +109,8 @@ export class Part<ValueType = any> extends ToneEvent<ValueType> {
}
/**
* Start the event in the given event at the correct time given
* the ticks and offset and looping.
* Start the event in the given event at the correct time given
* the ticks and offset and looping.
* @param event
* @param ticks
* @param offset
@ -144,7 +144,7 @@ export class Part<ValueType = any> extends ToneEvent<ValueType> {
}
/**
* Stop the part at the given time.
* Stop the part at the given time.
* @param time When to stop the part.
*/
stop(time?: TransportTime): this {
@ -197,9 +197,9 @@ export class Part<ValueType = any> extends ToneEvent<ValueType> {
}
/**
* Add a an event to the part.
* Add a an event to the part.
* @param time The time the note should start. If an object is passed in, it should
* have a 'time' attribute and the rest of the object will be used as the 'value'.
* have a 'time' attribute and the rest of the object will be used as the 'value'.
* @param value
* @example
* part.add("1m", "C#+11");
@ -253,7 +253,7 @@ export class Part<ValueType = any> extends ToneEvent<ValueType> {
}
/**
* Restart the given event
* Restart the given event
*/
private _restartEvent(event: ToneEvent): void {
this._state.forEach((stateEvent) => {
@ -267,8 +267,8 @@ export class Part<ValueType = any> extends ToneEvent<ValueType> {
}
/**
* Remove an event from the part. If the event at that time is a Part,
* it will remove the entire part.
* Remove an event from the part. If the event at that time is a Part,
* it will remove the entire part.
* @param time The time of the event
* @param value Optionally select only a specific event value
*/
@ -296,7 +296,7 @@ export class Part<ValueType = any> extends ToneEvent<ValueType> {
}
/**
* Remove all of the notes from the group.
* Remove all of the notes from the group.
*/
clear(): this {
this._forEach(event => event.dispose());
@ -305,7 +305,7 @@ export class Part<ValueType = any> extends ToneEvent<ValueType> {
}
/**
* Cancel scheduled state change events: i.e. "start" and "stop".
* Cancel scheduled state change events: i.e. "start" and "stop".
* @param after The time after which to cancel the scheduled events.
*/
cancel(after?: TransportTime | TransportTimeClass): this {
@ -315,7 +315,7 @@ export class Part<ValueType = any> extends ToneEvent<ValueType> {
}
/**
* Iterate over all of the events
* Iterate over all of the events
*/
private _forEach(callback: (event: ToneEvent) => void): this {
if (this._events) {
@ -331,7 +331,7 @@ export class Part<ValueType = any> extends ToneEvent<ValueType> {
}
/**
* Set the attribute of all of the events
* Set the attribute of all of the events
* @param attr the attribute to set
* @param value The value to set it to
*/
@ -342,7 +342,7 @@ export class Part<ValueType = any> extends ToneEvent<ValueType> {
}
/**
* Internal tick method
* Internal tick method
* @param time The time of the event in seconds
*/
protected _tick(time: Seconds, value?: any): void {
@ -352,8 +352,8 @@ export class Part<ValueType = any> extends ToneEvent<ValueType> {
}
/**
* Determine if the event should be currently looping
* given the loop boundries of this Part.
* Determine if the event should be currently looping
* given the loop boundries of this Part.
* @param event The event to test
*/
private _testLoopBoundries(event: ToneEvent): void {
@ -366,7 +366,7 @@ export class Part<ValueType = any> extends ToneEvent<ValueType> {
}
/**
* The probability of the notes being triggered.
* The probability of the notes being triggered.
*/
get probability(): NormalRange {
return this._probability;
@ -418,8 +418,8 @@ export class Part<ValueType = any> extends ToneEvent<ValueType> {
}
/**
* The loopEnd point determines when it will
* loop if Part.loop is true.
* The loopEnd point determines when it will
* loop if Part.loop is true.
* @memberOf Part#
* @type {Time}
* @name loopEnd
@ -438,8 +438,8 @@ export class Part<ValueType = any> extends ToneEvent<ValueType> {
}
/**
* The loopStart point determines when it will
* loop if Part.loop is true.
* The loopStart point determines when it will
* loop if Part.loop is true.
*/
get loopStart(): Time {
return new TicksClass(this.context, this._loopStart).toSeconds();
@ -455,7 +455,7 @@ export class Part<ValueType = any> extends ToneEvent<ValueType> {
}
/**
* The playback rate of the part
* The playback rate of the part
*/
get playbackRate(): Positive {
return this._playbackRate;
@ -466,7 +466,7 @@ export class Part<ValueType = any> extends ToneEvent<ValueType> {
}
/**
* The number of scheduled notes in the part.
* The number of scheduled notes in the part.
*/
get length(): number {
return this._events.size;

View file

@ -37,7 +37,7 @@ export class Sequence<ValueType = any> extends ToneEvent<ValueType> {
readonly name: string = "Sequence";
/**
* The subdivison of each note
* The subdivison of each note
*/
private _subdivision: Ticks;
@ -123,7 +123,7 @@ export class Sequence<ValueType = any> extends ToneEvent<ValueType> {
}
/**
* Start the part at the given time.
* Start the part at the given time.
* @param time When to start the part.
* @param offset The offset index to start at
*/
@ -133,7 +133,7 @@ export class Sequence<ValueType = any> extends ToneEvent<ValueType> {
}
/**
* Stop the part at the given time.
* Stop the part at the given time.
* @param time When to stop the part.
*/
stop(time?: TransportTime): this {
@ -142,9 +142,9 @@ export class Sequence<ValueType = any> extends ToneEvent<ValueType> {
}
/**
* The subdivision of the sequence. This can only be
* set in the constructor. The subdivision is the
* interval between successive steps.
* The subdivision of the sequence. This can only be
* set in the constructor. The subdivision is the
* interval between successive steps.
*/
get subdivision(): Seconds {
return new TicksClass(this.context, this._subdivision).toSeconds();
@ -203,7 +203,7 @@ export class Sequence<ValueType = any> extends ToneEvent<ValueType> {
}
/**
* Get the time of the index given the Sequence's subdivision
* Get the time of the index given the Sequence's subdivision
* @param index
* @return The time of that index
*/

View file

@ -42,61 +42,61 @@ export class ToneEvent<ValueType = any> extends ToneWithContext<ToneEventOptions
readonly name: string = "ToneEvent";
/**
* Loop value
* Loop value
*/
protected _loop: boolean | number;
/**
* The callback to invoke.
* The callback to invoke.
*/
callback: ToneEventCallback<ValueType>;
/**
* The value which is passed to the
* callback function.
* The value which is passed to the
* callback function.
*/
value: ValueType;
/**
* When the note is scheduled to start.
* When the note is scheduled to start.
*/
protected _loopStart: Ticks;
/**
* When the note is scheduled to start.
* When the note is scheduled to start.
*/
protected _loopEnd: Ticks;
/**
* Tracks the scheduled events
* Tracks the scheduled events
*/
protected _state: StateTimeline<{
id: number,
}> = new StateTimeline("stopped");
/**
* The playback speed of the note. A speed of 1
* is no change.
* The playback speed of the note. A speed of 1
* is no change.
*/
protected _playbackRate: Positive;
/**
* A delay time from when the event is scheduled to start
* A delay time from when the event is scheduled to start
*/
protected _startOffset: Ticks = 0;
/**
* private holder of probability value
* private holder of probability value
*/
protected _probability: NormalRange;
/**
* the amount of variation from the given time.
* the amount of variation from the given time.
*/
protected _humanize: boolean | Time;
/**
* If mute is true, the callback won't be invoked.
* If mute is true, the callback won't be invoked.
*/
mute: boolean;
@ -138,8 +138,8 @@ export class ToneEvent<ValueType = any> extends ToneWithContext<ToneEventOptions
}
/**
* Reschedule all of the events along the timeline
* with the updated values.
* Reschedule all of the events along the timeline
* with the updated values.
* @param after Only reschedules events after the given time.
*/
private _rescheduleEvents(after: Ticks = -1): void {
@ -176,7 +176,7 @@ export class ToneEvent<ValueType = any> extends ToneWithContext<ToneEventOptions
}
/**
* Returns the playback state of the note, either "started" or "stopped".
* Returns the playback state of the note, either "started" or "stopped".
*/
get state(): BasicPlaybackState {
return this._state.getValueAtTime(this.context.transport.ticks) as BasicPlaybackState;
@ -193,7 +193,7 @@ export class ToneEvent<ValueType = any> extends ToneWithContext<ToneEventOptions
}
/**
* The probability of the notes being triggered.
* The probability of the notes being triggered.
*/
get probability(): NormalRange {
return this._probability;
@ -203,9 +203,9 @@ export class ToneEvent<ValueType = any> extends ToneWithContext<ToneEventOptions
}
/**
* If set to true, will apply small random variation
* to the callback time. If the value is given as a time, it will randomize
* by that amount.
* If set to true, will apply small random variation
* to the callback time. If the value is given as a time, it will randomize
* by that amount.
* @example
* event.humanize = true;
*/
@ -218,7 +218,7 @@ export class ToneEvent<ValueType = any> extends ToneWithContext<ToneEventOptions
}
/**
* Start the note at the given time.
* Start the note at the given time.
* @param time When the event should start.
*/
start(time?: TransportTime | TransportTimeClass): this {
@ -235,7 +235,7 @@ export class ToneEvent<ValueType = any> extends ToneWithContext<ToneEventOptions
}
/**
* Stop the Event at the given time.
* Stop the Event at the given time.
* @param time When the event should stop.
*/
stop(time?: TransportTime | TransportTimeClass): this {
@ -254,7 +254,7 @@ export class ToneEvent<ValueType = any> extends ToneWithContext<ToneEventOptions
}
/**
* Cancel all scheduled events greater than or equal to the given time
* Cancel all scheduled events greater than or equal to the given time
* @param time The time after which events will be cancel.
*/
cancel(time?: TransportTime | TransportTimeClass): this {
@ -268,8 +268,8 @@ export class ToneEvent<ValueType = any> extends ToneWithContext<ToneEventOptions
}
/**
* The callback function invoker. Also
* checks if the Event is done playing
* The callback function invoker. Also
* checks if the Event is done playing
* @param time The time of the event in seconds
*/
protected _tick(time: Seconds): void {
@ -290,21 +290,21 @@ export class ToneEvent<ValueType = any> extends ToneWithContext<ToneEventOptions
}
/**
* Get the duration of the loop.
* Get the duration of the loop.
*/
protected _getLoopDuration(): Ticks {
return Math.round((this._loopEnd - this._loopStart) / this._playbackRate);
}
/**
* If the note should loop or not
* between ToneEvent.loopStart and
* ToneEvent.loopEnd. If set to true,
* the event will loop indefinitely,
* if set to a number greater than 1
* it will play a specific number of
* times, if set to false, 0 or 1, the
* part will only play once.
* If the note should loop or not
* between ToneEvent.loopStart and
* ToneEvent.loopEnd. If set to true,
* the event will loop indefinitely,
* if set to a number greater than 1
* it will play a specific number of
* times, if set to false, 0 or 1, the
* part will only play once.
*/
get loop(): boolean | number {
return this._loop;
@ -315,7 +315,7 @@ export class ToneEvent<ValueType = any> extends ToneWithContext<ToneEventOptions
}
/**
* The playback rate of the note. Defaults to 1.
* The playback rate of the note. Defaults to 1.
* @example
* note.loop = true;
* //repeat the note twice as fast
@ -330,8 +330,8 @@ export class ToneEvent<ValueType = any> extends ToneWithContext<ToneEventOptions
}
/**
* The loopEnd point is the time the event will loop
* if ToneEvent.loop is true.
* The loopEnd point is the time the event will loop
* if ToneEvent.loop is true.
*/
get loopEnd(): Time {
return new TicksClass(this.context, this._loopEnd).toSeconds();
@ -344,7 +344,7 @@ export class ToneEvent<ValueType = any> extends ToneWithContext<ToneEventOptions
}
/**
* The time when the loop should start.
* The time when the loop should start.
*/
get loopStart(): Time {
return new TicksClass(this.context, this._loopStart).toSeconds();
@ -357,9 +357,9 @@ export class ToneEvent<ValueType = any> extends ToneWithContext<ToneEventOptions
}
/**
* The current progress of the loop interval.
* Returns 0 if the event is not started yet or
* it is not set to loop.
* The current progress of the loop interval.
* Returns 0 if the event is not started yet or
* it is not set to loop.
*/
get progress(): NormalRange {
if (this._loop) {

View file

@ -4,7 +4,7 @@ import { getContext } from "./core/Global";
export { start } from "./core/Global";
/**
* The current audio context time
* The current audio context time
*/
export function now(): import("./core/type/Units").Seconds {
return getContext().now();

View file

@ -10,12 +10,12 @@ export interface InstrumentOptions extends ToneAudioNodeOptions {
}
/**
* Base-class for all instruments
* Base-class for all instruments
*/
export abstract class Instrument<Options extends InstrumentOptions> extends ToneAudioNode<Options> {
/**
* The output and volume triming node
* The output and volume triming node
*/
private _volume: Volume;
output: OutputNode;
@ -118,10 +118,10 @@ export abstract class Instrument<Options extends InstrumentOptions> extends Tone
}
/**
* Trigger the attack and then the release after the duration.
* Trigger the attack and then the release after the duration.
* @param note The note to trigger.
* @param duration How long the note should be held for before
* triggering the release. This value must be greater than 0.
* triggering the release. This value must be greater than 0.
* @param time When the note should be triggered.
* @param velocity The velocity the note should be triggered at.
* @example
@ -155,7 +155,7 @@ export abstract class Instrument<Options extends InstrumentOptions> extends Tone
private _original_triggerRelease = this.triggerRelease;
/**
* clean up
* clean up
* @returns {Instrument} this
*/
dispose(): this {

View file

@ -27,12 +27,12 @@ export class MembraneSynth extends Synth<MembraneSynthOptions> {
readonly name: string = "MembraneSynth";
/**
* The number of octaves the pitch envelope ramps.
* The number of octaves the pitch envelope ramps.
*/
octaves: Positive;
/**
* The amount of time the frequency envelope takes.
* The amount of time the frequency envelope takes.
*/
pitchDecay: Time;

View file

@ -20,8 +20,8 @@ export interface MetalSynthOptions extends MonophonicOptions {
}
/**
* Inharmonic ratio of frequencies based on the Roland TR-808
* Taken from https://ccrma.stanford.edu/papers/tr-808-cymbal-physically-informed-circuit-bendable-digital-model
* Inharmonic ratio of frequencies based on the Roland TR-808
* Taken from https://ccrma.stanford.edu/papers/tr-808-cymbal-physically-informed-circuit-bendable-digital-model
*/
const inharmRatios: number[] = [1.0, 1.483, 1.932, 2.546, 2.630, 3.897];
@ -171,9 +171,9 @@ export class MetalSynth extends Monophonic<MetalSynthOptions> {
}
/**
* Trigger the attack.
* @param time When the attack should be triggered.
* @param velocity The velocity that the envelope should be triggered at.
* Trigger the attack.
* @param time When the attack should be triggered.
* @param velocity The velocity that the envelope should be triggered at.
*/
protected _triggerEnvelopeAttack(time: Time, velocity: NormalRange = 1): this {
this.envelope.triggerAttack(time, velocity);
@ -187,8 +187,8 @@ export class MetalSynth extends Monophonic<MetalSynthOptions> {
}
/**
* Trigger the release of the envelope.
* @param time When the release should be triggered.
* Trigger the release of the envelope.
* @param time When the release should be triggered.
*/
protected _triggerEnvelopeRelease(time: Time): this {
this.envelope.triggerRelease(time);
@ -197,8 +197,8 @@ export class MetalSynth extends Monophonic<MetalSynthOptions> {
}
/**
* The modulationIndex of the oscillators which make up the source.
* see [[FMOscillator.modulationIndex]]
* The modulationIndex of the oscillators which make up the source.
* see [[FMOscillator.modulationIndex]]
*/
get modulationIndex(): number {
return this._oscillators[0].modulationIndex.value;
@ -208,8 +208,8 @@ export class MetalSynth extends Monophonic<MetalSynthOptions> {
}
/**
* The harmonicity of the oscillators which make up the source.
* see Tone.FMOscillator.harmonicity
* The harmonicity of the oscillators which make up the source.
* see Tone.FMOscillator.harmonicity
*/
get harmonicity(): number {
return this._oscillators[0].harmonicity.value;
@ -233,8 +233,8 @@ export class MetalSynth extends Monophonic<MetalSynthOptions> {
}
/**
* The number of octaves above the "resonance" frequency
* that the filter ramps during the attack/decay envelope
* The number of octaves above the "resonance" frequency
* that the filter ramps during the attack/decay envelope
*/
get octaves(): number {
return this._octaves;

View file

@ -20,7 +20,7 @@ export interface MonophonicOptions extends InstrumentOptions {
export abstract class Monophonic<Options extends MonophonicOptions> extends Instrument<Options> {
/**
* The glide time between notes.
* The glide time between notes.
*/
portamento: Seconds;

View file

@ -372,7 +372,7 @@ export class PolySynth<Voice extends Monophonic<any> = Synth> extends Instrument
}
/**
* Get the synth's attributes.
* Get the synth's attributes.
*/
get(): VoiceOptions<Voice> {
// return a clone of the options

View file

@ -68,21 +68,21 @@ export class Sampler extends Instrument<SamplerOptions> {
release: Time;
/**
* The shape of the attack/release curve.
* Either "linear" or "exponential"
* The shape of the attack/release curve.
* Either "linear" or "exponential"
*/
curve: ToneBufferSourceCurve;
/**
* @param samples An object of samples mapping either Midi Note Numbers or
* Scientific Pitch Notation to the url of that sample.
* Scientific Pitch Notation to the url of that sample.
* @param onload The callback to invoke when all of the samples are loaded.
* @param baseUrl The root URL of all of the samples, which is prepended to all the URLs.
*/
constructor(samples?: SamplesMap, onload?: () => void, baseUrl?: string);
/**
* @param samples An object of samples mapping either Midi Note Numbers or
* Scientific Pitch Notation to the url of that sample.
* Scientific Pitch Notation to the url of that sample.
* @param options The remaining options associated with the sampler
*/
constructor(samples?: SamplesMap, options?: Partial<Omit<SamplerOptions, "urls">>);

View file

@ -32,7 +32,7 @@ export class Synth<Options extends SynthOptions = SynthOptions> extends Monophon
readonly name: string = "Synth";
/**
* The oscillator.
* The oscillator.
*/
readonly oscillator: OmniOscillator<any>;
@ -98,7 +98,7 @@ export class Synth<Options extends SynthOptions = SynthOptions> extends Monophon
}
/**
* start the attack portion of the envelope
* start the attack portion of the envelope
* @param time the time the attack should start
* @param velocity the velocity of the note (0-1)
*/
@ -115,7 +115,7 @@ export class Synth<Options extends SynthOptions = SynthOptions> extends Monophon
}
/**
* start the release portion of the envelope
* start the release portion of the envelope
* @param time the time the release should start
*/
protected _triggerEnvelopeRelease(time: Seconds): void {
@ -124,7 +124,7 @@ export class Synth<Options extends SynthOptions = SynthOptions> extends Monophon
}
/**
* clean up
* clean up
*/
dispose(): this {
super.dispose();

View file

@ -40,7 +40,7 @@ export class Abs extends SignalOperator<ToneAudioNodeOptions> {
output = this._abs;
/**
* clean up
* clean up
*/
dispose(): this {
super.dispose();

View file

@ -29,7 +29,7 @@ export class Add extends Signal {
readonly name: string = "Add";
/**
* the summing node
* the summing node
*/
private _sum: Gain = new Gain({ context: this.context });
readonly input = this._sum;

View file

@ -32,7 +32,7 @@ export class AudioToGain extends SignalOperator<ToneAudioNodeOptions> {
output = this._norm;
/**
* clean up
* clean up
*/
dispose(): this {
super.dispose();

View file

@ -32,7 +32,7 @@ export class GainToAudio extends SignalOperator<ToneAudioNodeOptions> {
output = this._norm;
/**
* clean up
* clean up
*/
dispose(): this {
super.dispose();

View file

@ -16,7 +16,7 @@ export class Negate extends SignalOperator<ToneAudioNodeOptions> {
readonly name: string = "Negate";
/**
* negation is done by multiplying by -1
* negation is done by multiplying by -1
*/
private _multiply: Multiply = new Multiply({
context: this.context,
@ -30,7 +30,7 @@ export class Negate extends SignalOperator<ToneAudioNodeOptions> {
output = this._multiply;
/**
* clean up
* clean up
* @returns {Negate} this
*/
dispose(): this {

View file

@ -84,7 +84,7 @@ export class Scale extends SignalOperator<ScaleOptions> {
}
/**
* set the values
* set the values
*/
private _setRange(): void {
this.output.value = this._outputMin;

View file

@ -28,14 +28,14 @@ export class Subtract extends Signal {
readonly name: string = "Subtract";
/**
* the summing node
* the summing node
*/
private _sum: Gain = new Gain({ context: this.context });
readonly input: Gain = this._sum;
readonly output: Gain = this._sum;
/**
* Negate the input of the second input before connecting it to the summing node.
* Negate the input of the second input before connecting it to the summing node.
*/
private _neg: Negate = new Negate({ context : this.context });
@ -46,7 +46,7 @@ export class Subtract extends Signal {
/**
* @param value The value to subtract from the incoming signal. If the value
* is omitted, it will subtract the second signal from the first.
* is omitted, it will subtract the second signal from the first.
*/
constructor(value?: number);
// tslint:disable-next-line: unified-signatures

View file

@ -13,19 +13,18 @@ export interface ToneConstantSourceOptions<Type> extends OneShotSourceOptions {
/**
* Wrapper around the native fire-and-forget ConstantSource.
* Adds the ability to reschedule the stop method.
* ***[[Oscillator]] is better for most use-cases***
*/
export class ToneConstantSource<Type extends Unit = number> extends OneShotSource<ToneConstantSourceOptions<Type>> {
readonly name: string = "ToneConstantSource";
/**
* The signal generator
* The signal generator
*/
private _source = this.context.createConstantSource();
/**
* The offset of the signal generator
* The offset of the signal generator
*/
readonly offset: Param<Type>;

View file

@ -31,7 +31,7 @@ export class WaveShaper extends SignalOperator<WaveShaperOptions> {
readonly name: string = "WaveShaper";
/**
* the waveshaper node
* the waveshaper node
*/
private _shaper: WaveShaperNode = this.context.createWaveShaper();
@ -47,13 +47,13 @@ export class WaveShaper extends SignalOperator<WaveShaperOptions> {
/**
* @param mapping The function used to define the values.
* The mapping function should take two arguments:
* the first is the value at the current position
* and the second is the array position.
* If the argument is an array, that array will be
* set as the wave shaping function. The input
* signal is an AudioRange [-1, 1] value and the output
* signal can take on any numerical values.
* The mapping function should take two arguments:
* the first is the value at the current position
* and the second is the array position.
* If the argument is an array, that array will be
* set as the wave shaping function. The input
* signal is an AudioRange [-1, 1] value and the output
* signal can take on any numerical values.
*
* @param bufferLen The length of the WaveShaperNode buffer.
*/
@ -77,12 +77,12 @@ export class WaveShaper extends SignalOperator<WaveShaperOptions> {
}
/**
* Uses a mapping function to set the value of the curve.
* Uses a mapping function to set the value of the curve.
* @param mapping The function used to define the values.
* The mapping function take two arguments:
* the first is the value at the current position
* which goes from -1 to 1 over the number of elements
* in the curve array. The second argument is the array position.
* The mapping function take two arguments:
* the first is the value at the current position
* which goes from -1 to 1 over the number of elements
* in the curve array. The second argument is the array position.
* @example
* //map the input signal from [-1, 1] to [0, 10]
* shaper.setMap(function(val, index){
@ -127,7 +127,7 @@ export class WaveShaper extends SignalOperator<WaveShaperOptions> {
}
/**
* Clean up.
* Clean up.
*/
dispose(): this {
super.dispose();

View file

@ -4,9 +4,9 @@ import { optionsFromArguments } from "../core/util/Defaults";
import { SignalOperator } from "./SignalOperator";
/**
* Tone.Zero outputs 0's at audio-rate. The reason this has to be
* it's own class is that many browsers optimize out Tone.Signal
* with a value of 0 and will not process nodes further down the graph.
* Tone.Zero outputs 0's at audio-rate. The reason this has to be
* it's own class is that many browsers optimize out Tone.Signal
* with a value of 0 and will not process nodes further down the graph.
*/
export class Zero extends SignalOperator<ToneAudioNodeOptions> {

View file

@ -49,18 +49,18 @@ export class Noise extends Source<NoiseOptions> {
private _type!: NoiseType;
/**
* The playback rate of the noise. Affects
* the "frequency" of the noise.
* The playback rate of the noise. Affects
* the "frequency" of the noise.
*/
private _playbackRate: Positive;
/**
* The fadeIn time of the amplitude envelope.
* The fadeIn time of the amplitude envelope.
*/
protected _fadeIn: Time;
/**
* The fadeOut time of the amplitude envelope.
* The fadeOut time of the amplitude envelope.
*/
protected _fadeOut: Time;
@ -111,8 +111,8 @@ export class Noise extends Source<NoiseOptions> {
}
/**
* The playback rate of the noise. Affects
* the "frequency" of the noise.
* The playback rate of the noise. Affects
* the "frequency" of the noise.
*/
get playbackRate(): Positive {
return this._playbackRate;
@ -125,7 +125,7 @@ export class Noise extends Source<NoiseOptions> {
}
/**
* internal start method
* internal start method
*/
protected _start(time?: Time): void {
const buffer = _noiseBuffers[this._type];
@ -152,7 +152,7 @@ export class Noise extends Source<NoiseOptions> {
}
/**
* The fadeIn time of the amplitude envelope.
* The fadeIn time of the amplitude envelope.
*/
get fadeIn(): Time {
return this._fadeIn;
@ -165,7 +165,7 @@ export class Noise extends Source<NoiseOptions> {
}
/**
* The fadeOut time of the amplitude envelope.
* The fadeOut time of the amplitude envelope.
*/
get fadeOut(): Time {
return this._fadeOut;
@ -190,7 +190,7 @@ export class Noise extends Source<NoiseOptions> {
}
/**
* Clean up.
* Clean up.
*/
dispose(): this {
super.dispose();

View file

@ -21,8 +21,8 @@ export interface OneShotSourceOptions extends ToneAudioNodeOptions {
export abstract class OneShotSource<Options extends ToneAudioNodeOptions> extends ToneAudioNode<Options> {
/**
* The callback to invoke after the
* source is done playing.
* The callback to invoke after the
* source is done playing.
*/
onended: onEndedCallback = noOp;
@ -32,12 +32,12 @@ export abstract class OneShotSource<Options extends ToneAudioNodeOptions> extend
input: undefined;
/**
* The start time
* The start time
*/
protected _startTime: number = -1;
/**
* The stop time
* The stop time
*/
protected _stopTime: number = -1;
@ -55,17 +55,17 @@ export abstract class OneShotSource<Options extends ToneAudioNodeOptions> extend
});
/**
* The output gain node.
* The output gain node.
*/
protected _gainNode = this.output;
/**
* The fadeIn time of the amplitude envelope.
* The fadeIn time of the amplitude envelope.
*/
protected _fadeIn: Time;
/**
* The fadeOut time of the amplitude envelope.
* The fadeOut time of the amplitude envelope.
*/
protected _fadeOut: Time;
@ -190,7 +190,7 @@ export abstract class OneShotSource<Options extends ToneAudioNodeOptions> extend
}
/**
* Get the playback state at the given time
* Get the playback state at the given time
*/
getStateAtTime = function(time: Time): BasicPlaybackState {
const computedTime = this.toSeconds(time);
@ -210,7 +210,7 @@ export abstract class OneShotSource<Options extends ToneAudioNodeOptions> extend
}
/**
* Cancel a scheduled stop event
* Cancel a scheduled stop event
*/
cancelStop(): this {
this.log("cancelStop");

View file

@ -39,7 +39,7 @@ export interface SourceOptions extends ToneAudioNodeOptions {
export abstract class Source<Options extends SourceOptions> extends ToneAudioNode<Options> {
/**
* The output volume node
* The output volume node
*/
private _volume: Volume;
@ -66,7 +66,7 @@ export abstract class Source<Options extends SourceOptions> extends ToneAudioNod
onstop: onStopCallback;
/**
* Keep track of the scheduled state.
* Keep track of the scheduled state.
*/
protected _state: StateTimeline<{
duration?: Seconds;
@ -84,7 +84,7 @@ export abstract class Source<Options extends SourceOptions> extends ToneAudioNod
protected _synced: boolean = false;
/**
* Keep track of all of the scheduled event ids
* Keep track of all of the scheduled event ids
*/
private _scheduled: number[] = [];
@ -117,7 +117,7 @@ export abstract class Source<Options extends SourceOptions> extends ToneAudioNod
}
/**
* Returns the playback state of the source, either "started" or "stopped".
* Returns the playback state of the source, either "started" or "stopped".
*/
get state(): BasicPlaybackState {
if (this._synced) {
@ -162,8 +162,8 @@ export abstract class Source<Options extends SourceOptions> extends ToneAudioNod
}
/**
* Start the source at the specified time. If no time is given,
* start the source now.
* Start the source at the specified time. If no time is given,
* start the source now.
* @param time When the source should be started.
* @example
* source.start("+0.5"); //starts the source 0.5 seconds from now
@ -203,8 +203,8 @@ export abstract class Source<Options extends SourceOptions> extends ToneAudioNod
}
/**
* Stop the source at the specified time. If no time is given,
* stop the source now.
* Stop the source at the specified time. If no time is given,
* stop the source now.
* @param time When the source should be stopped.
* @example
* source.stop(); // stops the source immediately
@ -225,9 +225,9 @@ export abstract class Source<Options extends SourceOptions> extends ToneAudioNod
}
/**
* Sync the source to the Transport so that all subsequent
* calls to `start` and `stop` are synced to the TransportTime
* instead of the AudioContext time.
* Sync the source to the Transport so that all subsequent
* calls to `start` and `stop` are synced to the TransportTime
* instead of the AudioContext time.
*
* @example
* //sync the source so that it plays between 0 and 0.3 on the Transport's timeline
@ -277,7 +277,7 @@ export abstract class Source<Options extends SourceOptions> extends ToneAudioNod
}
/**
* Unsync the source to the Transport. See Source.sync
* Unsync the source to the Transport. See Source.sync
*/
unsync(): this {
if (this._synced) {

View file

@ -43,42 +43,42 @@ export class Player extends Source<PlayerOptions> {
autostart: boolean;
/**
* The buffer
* The buffer
*/
private _buffer: ToneAudioBuffer;
/**
* if the buffer should loop once it's over
* if the buffer should loop once it's over
*/
private _loop: boolean;
/**
* if 'loop' is true, the loop will start at this position
* if 'loop' is true, the loop will start at this position
*/
private _loopStart: Time;
/**
* if 'loop' is true, the loop will end at this position
* if 'loop' is true, the loop will end at this position
*/
private _loopEnd: Time;
/**
* the playback rate
* the playback rate
*/
private _playbackRate: Positive;
/**
* All of the active buffer source nodes
* All of the active buffer source nodes
*/
private _activeSources: Set<ToneBufferSource> = new Set();
/**
* The fadeIn time of the amplitude envelope.
* The fadeIn time of the amplitude envelope.
*/
fadeIn: Time;
/**
* The fadeOut time of the amplitude envelope.
* The fadeOut time of the amplitude envelope.
*/
fadeOut: Time;
@ -161,15 +161,15 @@ export class Player extends Source<PlayerOptions> {
}
/**
* Play the buffer at the given startTime. Optionally add an offset
* and/or duration which will play the buffer from a position
* within the buffer for the given duration.
* Play the buffer at the given startTime. Optionally add an offset
* and/or duration which will play the buffer from a position
* within the buffer for the given duration.
*
* @param time When the player should start.
* @param offset The offset from the beginning of the sample
* to start at.
* to start at.
* @param duration How long the sample should play. If no duration is given, it will default to the full length
* of the sample (minus any offset)
* of the sample (minus any offset)
*/
start(time?: Time, offset?: Time, duration?: Time): this {
super.start(time, offset, duration);
@ -177,7 +177,7 @@ export class Player extends Source<PlayerOptions> {
}
/**
* Internal start method
* Internal start method
*/
protected _start(startTime?: Time, offset?: Time, duration?: Time): void {
// if it's a loop the default offset is the loopstart point
@ -241,7 +241,7 @@ export class Player extends Source<PlayerOptions> {
}
/**
* Stop playback.
* Stop playback.
*/
protected _stop(time?: Time): void {
const computedTime = this.toSeconds(time);
@ -253,7 +253,7 @@ export class Player extends Source<PlayerOptions> {
* @param time When the player should start.
* @param offset The offset from the beginning of the sample to start at.
* @param duration How long the sample should play. If no duration is given,
* it will default to the full length of the sample (minus any offset)
* it will default to the full length of the sample (minus any offset)
*/
restart(time?: Time, offset?: Time, duration?: Time): this {
this._stop(time);
@ -262,9 +262,9 @@ export class Player extends Source<PlayerOptions> {
}
/**
* Seek to a specific time in the player's buffer. If the
* source is no longer playing at that time, it will stop.
* If you seek to a time that
* Seek to a specific time in the player's buffer. If the
* source is no longer playing at that time, it will stop.
* If you seek to a time that
* @param {Time} offset The time to seek to.
* @param {Time=} time The time for the seek event to occur.
* @return {Player} this

View file

@ -28,7 +28,7 @@ export class Players extends ToneAudioNode<PlayersOptions> {
readonly name: string = "Players";
/**
* The output volume node
* The output volume node
*/
private _volume: Volume;
@ -86,7 +86,7 @@ export class Players extends ToneAudioNode<PlayersOptions> {
const options = optionsFromArguments(Players.getDefaults(), arguments, ["urls", "onload"], "urls");
/**
* The output volume node
* The output volume node
*/
this._volume = this.output = new Volume({
context: this.context,
@ -162,16 +162,16 @@ export class Players extends ToneAudioNode<PlayersOptions> {
}
/**
* True if the buffers object has a buffer by that name.
* @param name The key or index of the buffer.
* True if the buffers object has a buffer by that name.
* @param name The key or index of the buffer.
*/
has(name: string): boolean {
return this._buffers.has(name);
}
/**
* Get a player by name.
* @param name The players name as defined in the constructor object or `add` method.
* Get a player by name.
* @param name The players name as defined in the constructor object or `add` method.
*/
player(name: string): Player {
this.assert(this.has(name), `No Player with the name ${name} exists on this object`);
@ -195,10 +195,10 @@ export class Players extends ToneAudioNode<PlayersOptions> {
}
/**
* Add a player by name and url to the Players
* @param name A unique name to give the player
* @param url Either the url of the bufer or a buffer which will be added with the given name.
* @param callback The callback to invoke when the url is loaded.
* Add a player by name and url to the Players
* @param name A unique name to give the player
* @param url Either the url of the bufer or a buffer which will be added with the given name.
* @param callback The callback to invoke when the url is loaded.
*/
add(name: string, url: string | ToneAudioBuffer | AudioBuffer, callback?: () => void): this {
this.assert(!this._buffers.has(name), "A buffer with that name already exists on this object");

View file

@ -22,20 +22,20 @@ export interface ToneBufferSourceOptions extends OneShotSourceOptions {
}
/**
* Wrapper around the native BufferSourceNode.
* Wrapper around the native BufferSourceNode.
*/
export class ToneBufferSource extends OneShotSource<ToneBufferSourceOptions> {
readonly name: string = "ToneBufferSource";
/**
* The oscillator
* The oscillator
*/
private _source = this.context.createBufferSource();
protected _internalChannels = [this._source];
/**
* The frequency of the oscillator
* The frequency of the oscillator
*/
readonly playbackRate: Param<Positive>;
@ -65,7 +65,7 @@ export class ToneBufferSource extends OneShotSource<ToneBufferSourceOptions> {
this._source.onended = () => this._stopSource();
/**
* The playbackRate of the buffer
* The playbackRate of the buffer
*/
this.playbackRate = new Param({
context: this.context,
@ -95,7 +95,7 @@ export class ToneBufferSource extends OneShotSource<ToneBufferSourceOptions> {
}
/**
* The fadeIn time of the amplitude envelope.
* The fadeIn time of the amplitude envelope.
*/
get fadeIn(): Time {
return this._fadeIn;
@ -105,7 +105,7 @@ export class ToneBufferSource extends OneShotSource<ToneBufferSourceOptions> {
}
/**
* The fadeOut time of the amplitude envelope.
* The fadeOut time of the amplitude envelope.
*/
get fadeOut(): Time {
return this._fadeOut;
@ -125,12 +125,12 @@ export class ToneBufferSource extends OneShotSource<ToneBufferSourceOptions> {
}
/**
* Start the buffer
* Start the buffer
* @param time When the player should start.
* @param offset The offset from the beginning of the sample to start at.
* @param duration How long the sample should play. If no duration
* is given, it will default to the full length
* of the sample (minus any offset)
* is given, it will default to the full length
* of the sample (minus any offset)
* @param gain The gain to play the buffer back at.
*/
start(time?: Time, offset?: Time, duration?: Time, gain: GainFactor = 1): this {
@ -233,7 +233,7 @@ export class ToneBufferSource extends OneShotSource<ToneBufferSourceOptions> {
}
/**
* Clean up.
* Clean up.
*/
dispose(): this {
super.dispose();

View file

@ -36,34 +36,34 @@ export class AMOscillator extends Source<AMOscillatorOptions> implements ToneOsc
readonly name: string = "AMOscillator";
/**
* The carrier oscillator
* The carrier oscillator
*/
private _carrier: Oscillator;
/**
* The oscillator's frequency
* The oscillator's frequency
*/
readonly frequency: Signal<Frequency>;
/**
* The detune control signal.
* The detune control signal.
*/
readonly detune: Signal<Cents>;
/**
* The modulating oscillator
* The modulating oscillator
*/
private _modulator: Oscillator;
/**
* convert the -1,1 output to 0,1
* convert the -1,1 output to 0,1
*/
private _modulationScale = new AudioToGain({ context: this.context });
/**
* Harmonicity is the frequency ratio between the carrier and the modulator oscillators.
* A harmonicity of 1 gives both oscillators the same frequency.
* Harmonicity = 2 means a change of an octave.
* Harmonicity is the frequency ratio between the carrier and the modulator oscillators.
* A harmonicity of 1 gives both oscillators the same frequency.
* Harmonicity = 2 means a change of an octave.
* @example
* //pitch the modulator an octave below carrier
* synth.harmonicity.value = 0.5;
@ -71,7 +71,7 @@ export class AMOscillator extends Source<AMOscillatorOptions> implements ToneOsc
readonly harmonicity: Signal<Positive>;
/**
* the node where the modulation happens
* the node where the modulation happens
*/
private _modulationNode = new Gain({
context: this.context,
@ -128,7 +128,7 @@ export class AMOscillator extends Source<AMOscillatorOptions> implements ToneOsc
}
/**
* start the oscillator
* start the oscillator
*/
protected _start(time: Seconds): void {
this._modulator.start(time);
@ -136,7 +136,7 @@ export class AMOscillator extends Source<AMOscillatorOptions> implements ToneOsc
}
/**
* stop the oscillator
* stop the oscillator
*/
protected _stop(time: Seconds): void {
this._modulator.stop(time);
@ -144,7 +144,7 @@ export class AMOscillator extends Source<AMOscillatorOptions> implements ToneOsc
}
/**
* restart the oscillator
* restart the oscillator
*/
restart(time?: Time): this {
this._modulator.restart(time);
@ -230,7 +230,7 @@ export class AMOscillator extends Source<AMOscillatorOptions> implements ToneOsc
}
/**
* Clean up.
* Clean up.
*/
dispose(): this {
super.dispose();

View file

@ -33,29 +33,29 @@ export class FMOscillator extends Source<FMOscillatorOptions> implements ToneOsc
readonly name: string = "FMOscillator";
/**
* The carrier oscillator
* The carrier oscillator
*/
private _carrier: Oscillator;
/**
* The oscillator's frequency
* The oscillator's frequency
*/
readonly frequency: Signal<Frequency>;
/**
* The detune control signal.
* The detune control signal.
*/
readonly detune: Signal<Cents>;
/**
* The modulating oscillator
* The modulating oscillator
*/
private _modulator: Oscillator;
/**
* Harmonicity is the frequency ratio between the carrier and the modulator oscillators.
* A harmonicity of 1 gives both oscillators the same frequency.
* Harmonicity = 2 means a change of an octave.
* Harmonicity is the frequency ratio between the carrier and the modulator oscillators.
* A harmonicity of 1 gives both oscillators the same frequency.
* Harmonicity = 2 means a change of an octave.
* @example
* //pitch the modulator an octave below carrier
* synth.harmonicity.value = 0.5;
@ -63,14 +63,14 @@ export class FMOscillator extends Source<FMOscillatorOptions> implements ToneOsc
readonly harmonicity: Signal<Positive>;
/**
* The modulation index which is in essence the depth or amount of the modulation. In other terms it is the
* ratio of the frequency of the modulating signal (mf) to the amplitude of the
* modulating signal (ma) -- as in ma/mf.
* The modulation index which is in essence the depth or amount of the modulation. In other terms it is the
* ratio of the frequency of the modulating signal (mf) to the amplitude of the
* modulating signal (ma) -- as in ma/mf.
*/
readonly modulationIndex: Signal<Positive>;
/**
* the node where the modulation happens
* the node where the modulation happens
*/
private _modulationNode: Gain = new Gain({
context: this.context,
@ -145,7 +145,7 @@ export class FMOscillator extends Source<FMOscillatorOptions> implements ToneOsc
}
/**
* start the oscillator
* start the oscillator
*/
protected _start(time: Time): void {
this._modulator.start(time);
@ -153,7 +153,7 @@ export class FMOscillator extends Source<FMOscillatorOptions> implements ToneOsc
}
/**
* stop the oscillator
* stop the oscillator
*/
protected _stop(time: Time): void {
this._modulator.stop(time);
@ -161,7 +161,7 @@ export class FMOscillator extends Source<FMOscillatorOptions> implements ToneOsc
}
/**
* stop and restart the oscillator
* stop and restart the oscillator
*/
restart(time?: Time): this {
this._modulator.restart(time);
@ -245,7 +245,7 @@ export class FMOscillator extends Source<FMOscillatorOptions> implements ToneOsc
}
/**
* Clean up.
* Clean up.
*/
dispose(): this {
super.dispose();

View file

@ -12,7 +12,7 @@ import { FatConstructorOptions, FatOscillatorOptions,
export { FatOscillatorOptions } from "./OscillatorInterface";
/**
* FatOscillator is an array of oscillators with detune spread between the oscillators
* FatOscillator is an array of oscillators with detune spread between the oscillators
* @param frequency The oscillator's frequency.
* @param type The type of the oscillator.
* @param spread The detune spread between the oscillators.
@ -24,42 +24,42 @@ export class FatOscillator extends Source<FatOscillatorOptions> implements ToneO
readonly name: string = "FatOscillator";
/**
* The oscillator's frequency
* The oscillator's frequency
*/
readonly frequency: Signal<Frequency>;
/**
* The detune control signal.
* The detune control signal.
*/
readonly detune: Signal<Cents>;
/**
* The array of oscillators
* The array of oscillators
*/
private _oscillators: Oscillator[] = [];
/**
* The total spread of the oscillators
* The total spread of the oscillators
*/
private _spread: Cents;
/**
* The type of the oscillator
* The type of the oscillator
*/
private _type: ToneOscillatorType;
/**
* The phase of the oscillators
* The phase of the oscillators
*/
private _phase: Degrees;
/**
* The partials array
* The partials array
*/
private _partials: number[];
/**
* The number of partials to use
* The number of partials to use
*/
private _partialCount: number;
@ -102,7 +102,7 @@ export class FatOscillator extends Source<FatOscillatorOptions> implements ToneO
}
/**
* start the oscillator
* start the oscillator
*/
protected _start(time: Time): void {
time = this.toSeconds(time);
@ -110,7 +110,7 @@ export class FatOscillator extends Source<FatOscillatorOptions> implements ToneO
}
/**
* stop the oscillator
* stop the oscillator
*/
protected _stop(time: Time): void {
time = this.toSeconds(time);
@ -118,7 +118,7 @@ export class FatOscillator extends Source<FatOscillatorOptions> implements ToneO
}
/**
* restart the oscillator
* restart the oscillator
*/
restart(time): this {
time = this.toSeconds(time);
@ -127,7 +127,7 @@ export class FatOscillator extends Source<FatOscillatorOptions> implements ToneO
}
/**
* Iterate over all of the oscillators
* Iterate over all of the oscillators
*/
private _forEach(iterator: (osc: Oscillator, index: number) => void): void {
for (let i = 0; i < this._oscillators.length; i++) {
@ -273,7 +273,7 @@ export class FatOscillator extends Source<FatOscillatorOptions> implements ToneO
}
/**
* Clean up.
* Clean up.
*/
dispose(): this {
super.dispose();

View file

@ -37,7 +37,7 @@ export class LFO extends ToneAudioNode<LFOOptions> {
readonly name: string = "LFO";
/**
* The oscillator.
* The oscillator.
*/
private _oscillator: Oscillator;
@ -55,7 +55,7 @@ export class LFO extends ToneAudioNode<LFOOptions> {
readonly amplitude: Param<NormalRange>;
/**
* The signal which is output when the LFO is stopped
* The signal which is output when the LFO is stopped
*/
private _stoppedSignal: Signal<AudioRange>;
@ -66,7 +66,7 @@ export class LFO extends ToneAudioNode<LFOOptions> {
private _zeros: Zero;
/**
* The value that the LFO outputs when it's stopped
* The value that the LFO outputs when it's stopped
*/
private _stoppedValue: number = 0;
@ -170,8 +170,8 @@ export class LFO extends ToneAudioNode<LFOOptions> {
}
/**
* Start the LFO.
* @param time The time the LFO will start
* Start the LFO.
* @param time The time the LFO will start
*/
start(time?: Time): this {
time = this.toSeconds(time);
@ -181,8 +181,8 @@ export class LFO extends ToneAudioNode<LFOOptions> {
}
/**
* Stop the LFO.
* @param time The time the LFO will stop
* Stop the LFO.
* @param time The time the LFO will stop
*/
stop(time?: Time): this {
time = this.toSeconds(time);
@ -277,7 +277,7 @@ export class LFO extends ToneAudioNode<LFOOptions> {
}
/**
* Returns the playback state of the source, either "started" or "stopped".
* Returns the playback state of the source, either "started" or "stopped".
*/
get state(): BasicPlaybackState {
return this._oscillator.state;

View file

@ -78,12 +78,12 @@ implements Omit<ToneOscillatorInterface, "type"> {
readonly name: string = "OmniOscillator";
/**
* The frequency control.
* The frequency control.
*/
readonly frequency: Signal<Frequency>;
/**
* The detune control.
* The detune control.
*/
readonly detune: Signal<Cents>;
@ -93,7 +93,7 @@ implements Omit<ToneOscillatorInterface, "type"> {
private _oscillator!: AnyOscillator;
/**
* the type of the oscillator source
* the type of the oscillator source
*/
private _sourceType!: OmniOscSourceType;
@ -136,14 +136,14 @@ implements Omit<ToneOscillatorInterface, "type"> {
}
/**
* start the oscillator
* start the oscillator
*/
protected _start(time: Time): void {
this._oscillator.start(time);
}
/**
* start the oscillator
* start the oscillator
*/
protected _stop(time: Time): void {
this._oscillator.stop(time);
@ -271,7 +271,7 @@ implements Omit<ToneOscillatorInterface, "type"> {
}
/**
* connect the oscillator to the frequency and detune signals
* connect the oscillator to the frequency and detune signals
*/
private _createNewOscillator(oscType: OmniOscSourceType): void {
if (oscType !== this._sourceType) {
@ -451,10 +451,10 @@ implements Omit<ToneOscillatorInterface, "type"> {
}
/**
* Harmonicity is the frequency ratio between the carrier and the modulator oscillators.
* A harmonicity of 1 gives both oscillators the same frequency.
* Harmonicity = 2 means a change of an octave. See Tone.AMOscillator or Tone.FMOscillator
* for more info.
* Harmonicity is the frequency ratio between the carrier and the modulator oscillators.
* A harmonicity of 1 gives both oscillators the same frequency.
* Harmonicity = 2 means a change of an octave. See Tone.AMOscillator or Tone.FMOscillator
* for more info.
*/
get harmonicity(): IsAmOrFmOscillator<OscType, Signal<Positive>> {
if (this._getOscType(this._oscillator, "fm") || this._getOscType(this._oscillator, "am")) {

View file

@ -10,9 +10,9 @@ import { ToneOscillatorNode } from "./ToneOscillatorNode";
export { ToneOscillatorOptions, ToneOscillatorType } from "./OscillatorInterface";
/**
* Oscillator supports a number of features including
* phase rotation, multiple oscillator types (see Oscillator.type),
* and Transport syncing (see Oscillator.syncFrequency).
* Oscillator supports a number of features including
* phase rotation, multiple oscillator types (see Oscillator.type),
* and Transport syncing (see Oscillator.syncFrequency).
*
* @example
* //make and start a 440hz sine tone
@ -23,42 +23,42 @@ export class Oscillator extends Source<ToneOscillatorOptions> implements ToneOsc
readonly name: string = "Oscillator";
/**
* the main oscillator
* the main oscillator
*/
private _oscillator: ToneOscillatorNode | null = null;
/**
* The frequency control.
* The frequency control.
*/
frequency: Signal<Frequency>;
/**
* The detune control signal.
* The detune control signal.
*/
detune: Signal<Cents>;
/**
* the periodic wave
* the periodic wave
*/
private _wave?: PeriodicWave;
/**
* The partials of the oscillator
* The partials of the oscillator
*/
private _partials: number[];
/**
* The number of partials to limit or extend the periodic wave by
* The number of partials to limit or extend the periodic wave by
*/
private _partialCount: number;
/**
* the phase of the oscillator between 0 - 360
* the phase of the oscillator between 0 - 360
*/
private _phase!: Radians;
/**
* the type of the oscillator
* the type of the oscillator
*/
private _type: ToneOscillatorType;
@ -109,7 +109,7 @@ export class Oscillator extends Source<ToneOscillatorOptions> implements ToneOsc
}
/**
* start the oscillator
* start the oscillator
*/
protected _start(time?: Time): void {
const computedTime = this.toSeconds(time);
@ -134,7 +134,7 @@ export class Oscillator extends Source<ToneOscillatorOptions> implements ToneOsc
}
/**
* stop the oscillator
* stop the oscillator
*/
protected _stop(time?: Time): void {
const computedTime = this.toSeconds(time);
@ -158,8 +158,8 @@ export class Oscillator extends Source<ToneOscillatorOptions> implements ToneOsc
}
/**
* Sync the signal to the Transport's bpm. Any changes to the transports bpm,
* will also affect the oscillators frequency.
* Sync the signal to the Transport's bpm. Any changes to the transports bpm,
* will also affect the oscillators frequency.
* @example
* Tone.Transport.bpm.value = 120;
* osc.frequency.value = 440;
@ -174,8 +174,8 @@ export class Oscillator extends Source<ToneOscillatorOptions> implements ToneOsc
}
/**
* Unsync the oscillator's frequency from the Transport.
* See Oscillator.syncFrequency
* Unsync the oscillator's frequency from the Transport.
* See Oscillator.syncFrequency
*/
unsyncFrequency(): this {
this.context.transport.unsyncSignal(this.frequency);
@ -332,9 +332,9 @@ export class Oscillator extends Source<ToneOscillatorOptions> implements ToneOsc
}
/**
* Get the object's attributes. Given no arguments get
* will return all available object properties and their corresponding
* values.
* Get the object's attributes. Given no arguments get
* will return all available object properties and their corresponding
* values.
*/
get(): ToneOscillatorOptions {
const values = super.get();
@ -422,7 +422,7 @@ export class Oscillator extends Source<ToneOscillatorOptions> implements ToneOsc
}
/**
* Compute the inverse FFT for a given phase.
* Compute the inverse FFT for a given phase.
*/
private _inverseFFT(real: Float32Array, imag: Float32Array, phase: Radians): number {
let sum = 0;

View file

@ -16,7 +16,7 @@ export { PWMOscillatorOptions } from "./OscillatorInterface";
* changing the timbre of the oscillator by altering the harmonics
* generated.
* @example
* var pwm = new PWMOscillator("Ab3", 0.3).toDestination().start();
* var pwm = new PWMOscillator("Ab3", 0.3).toDestination().start();
*/
export class PWMOscillator extends Source<PWMOscillatorOptions> implements ToneOscillatorInterface {
@ -25,17 +25,17 @@ export class PWMOscillator extends Source<PWMOscillatorOptions> implements ToneO
readonly sourceType = "pwm";
/**
* the pulse oscillator
* the pulse oscillator
*/
private _pulse: PulseOscillator;
/**
* the modulator
* the modulator
*/
private _modulator: Oscillator;
/**
* Scale the oscillator so it doesn't go silent
* at the extreme values.
* Scale the oscillator so it doesn't go silent
* at the extreme values.
*/
private _scale: Multiply = new Multiply({
context: this.context,
@ -43,17 +43,17 @@ export class PWMOscillator extends Source<PWMOscillatorOptions> implements ToneO
});
/**
* The frequency control.
* The frequency control.
*/
readonly frequency: Signal<Frequency>;
/**
* The detune of the oscillator.
* The detune of the oscillator.
*/
readonly detune: Signal<Cents>;
/**
* The modulation rate of the oscillator.
* The modulation rate of the oscillator.
*/
readonly modulationFrequency: Signal<Frequency>;
@ -104,7 +104,7 @@ export class PWMOscillator extends Source<PWMOscillatorOptions> implements ToneO
});
}
/**
* start the oscillator
* start the oscillator
*/
protected _start(time: Time): void {
time = this.toSeconds(time);
@ -113,7 +113,7 @@ export class PWMOscillator extends Source<PWMOscillatorOptions> implements ToneO
}
/**
* stop the oscillator
* stop the oscillator
*/
protected _stop(time: Time): void {
time = this.toSeconds(time);
@ -122,7 +122,7 @@ export class PWMOscillator extends Source<PWMOscillatorOptions> implements ToneO
}
/**
* restart the oscillator
* restart the oscillator
*/
restart(time?: Time): this {
this._modulator.restart(time);
@ -169,7 +169,7 @@ export class PWMOscillator extends Source<PWMOscillatorOptions> implements ToneO
}
/**
* Clean up.
* Clean up.
*/
dispose(): this {
super.dispose();

View file

@ -47,12 +47,12 @@ export class PulseOscillator extends Source<PulseOscillatorOptions> implements T
readonly name: string = "PulseOscillator";
/**
* The width of the pulse.
* The width of the pulse.
*/
width: Signal<AudioRange>;
/**
* gate the width amount
* gate the width amount
*/
private _widthGate: Gain = new Gain({
context: this.context,
@ -60,22 +60,22 @@ export class PulseOscillator extends Source<PulseOscillatorOptions> implements T
});
/**
* the sawtooth oscillator
* the sawtooth oscillator
*/
private _sawtooth: Oscillator;
/**
* The frequency control.
* The frequency control.
*/
frequency: Signal<Frequency>;
/**
* The detune in cents.
* The detune in cents.
*/
detune: Signal<Cents>;
/**
* Threshold the signal to turn it into a square
* Threshold the signal to turn it into a square
*/
private _thresh = new WaveShaper({
context: this.context,
@ -127,7 +127,7 @@ export class PulseOscillator extends Source<PulseOscillatorOptions> implements T
}
/**
* start the oscillator
* start the oscillator
*/
protected _start(time: Time): void {
time = this.toSeconds(time);
@ -136,7 +136,7 @@ export class PulseOscillator extends Source<PulseOscillatorOptions> implements T
}
/**
* stop the oscillator
* stop the oscillator
*/
protected _stop(time: Time): void {
time = this.toSeconds(time);
@ -148,7 +148,7 @@ export class PulseOscillator extends Source<PulseOscillatorOptions> implements T
}
/**
* Restart the oscillator
* Restart the oscillator
*/
restart(time?: Time): this {
const computedTime = this.toSeconds(time);
@ -197,7 +197,7 @@ export class PulseOscillator extends Source<PulseOscillatorOptions> implements T
}
/**
* Clean up method.
* Clean up method.
*/
dispose(): this {
super.dispose();

View file

@ -20,18 +20,18 @@ export class ToneOscillatorNode extends OneShotSource<ToneOscillatorNodeOptions>
readonly name: string = "ToneOscillatorNode";
/**
* The oscillator
* The oscillator
*/
private _oscillator = this.context.createOscillator();
protected _internalChannels = [this._oscillator];
/**
* The frequency of the oscillator
* The frequency of the oscillator
*/
readonly frequency: Param<Frequency>;
/**
* The detune of the oscillator
* The detune of the oscillator
*/
readonly detune: Param<Cents>;
@ -112,7 +112,7 @@ export class ToneOscillatorNode extends OneShotSource<ToneOscillatorNodeOptions>
}
/**
* Clean up.
* Clean up.
*/
dispose(): this {
super.dispose();