ToneWithContext < Options >

The Base class for all nodes that have an AudioContext.

Constructor

Pass in a constructor as the first argument

new ToneWithContext (
context?:BaseContext
) => ToneWithContext

Pass in a constructor as the first argument

new ToneWithContext (
options?:Partial<ToneWithContextOptions >
) => ToneWithContext

Properties

blockTime #

readonly Seconds

The number of seconds of 1 processing block (128 samples)


console.log(Tone.Destination.blockTime);

context #

BaseContext

The context belonging to the node.

debug #

boolean

Set this debug flag to log all events that happen in this class.

disposed #

readonly boolean

Indicates if the instance was disposed. 'Disposing' an instance means that all of the Web Audio nodes that were created for the instance are disconnected and freed for garbage collection.

sampleTime #

readonly Seconds

The duration in seconds of one sample.


console.log(Tone.Transport.sampleTime);

static version #

string

The version number semver

Methods

dispose #

disconnect and dispose.

dispose ( ) => this

get #

Get the object's attributes.


const osc = new Tone.Oscillator();
console.log(osc.get());
get ( ) => Options

static getDefaults #

Returns all of the default options belonging to the class.

getDefaults ( ) => ToneWithContextOptions

immediate #

Return the current time of the Context clock without any lookAhead.


setInterval(() => {
	console.log(Tone.immediate());
}, 100);
immediate ( ) => Seconds

now #

Return the current time of the Context clock plus the lookAhead.


setInterval(() => {
	console.log(Tone.now());
}, 100);
now ( ) => Seconds

set #

Set multiple properties at once with an object.


const filter = new Tone.Filter();
// set values using an object
filter.set({
	frequency: 300,
	type: "highpass"
});
set (
props:RecursivePartial<Options >
) => this

toFrequency #

Convert the input to a frequency number


const gain = new Tone.Gain();
console.log(gain.toFrequency("4n"));
toFrequency (
freq:Frequency
) => Hertz

toSeconds #

Convert the incoming time to seconds


const gain = new Tone.Gain();
console.log(gain.toSeconds("4n"));
toSeconds (
time?:Time
) => Seconds

toString #

Convert the class to a string


const osc = new Tone.Oscillator();
console.log(osc.toString());
toString ( ) => string

toTicks #

Convert the input time into ticks


const gain = new Tone.Gain();
console.log(gain.toTicks("4n"));
toTicks (
time?:Time | TimeClass
) => Ticks