Tone

Tone is the base class of all other classes.

CONSTRUCTOR

new Tone ( )

Members

.context

Tone.Context READONLY #

The AudioContext

</>

Methods

.toTicks ( )

#
time
type: Time
↪ returns Ticks

the time in ticks

Convert a time representation into ticks.

</>

.receive ( )

#
channelName

A named channel to send the signal to.

type: String
channelNumber

The channel to connect to

type: Number
optional
↪ returns Tone

this

Recieve the input from the desired channelName to the input

EXAMPLE

reverbEffect.receive("reverb");
</>

.send ( )

#
channelName

A named channel to send the signal to.

type: String
amount

The amount of the source to send to the bus.

↪ returns GainNode

The gain node which connects this node to the desired channel. Can be used to adjust the levels of the send.

Send this signal to the channel name.

EXAMPLE

source.send("reverb", -12);
</>

.toFrequency ( )

#
freq
↪ returns Hertz

the frequency in hertz

Convert a frequency representation into a number.

</>

.toSeconds ( )

#
time
type: Time
↪ returns Seconds

Convert Time into seconds. Unlike the method which it overrides, this takes into account transporttime and musical notation. Time : 1.40 Notation: 4n or 1m or 2t Now Relative: +3n Math: 3n+16n or even complicated expressions ((3n*2)/6 + 1)

</>

Static Methods

.connectSeries ( )

#
nodes
↪ returns Tone

connect together all of the arguments in series

</>

.dbToGain ( )

#
db
↪ returns Number

Convert decibels into gain.

</>

.defaultArg ( )

#
given
type: *
fallback
type: *
↪ returns *

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.

WARNING: if object is self referential, it will go into an an infinite recursive loop.

</>

.defaults ( )

#
values

The arguments array

type: Array
keys

The names of the arguments

type: Array
constr

The class constructor

↪ returns Object

An object composed of the defaults between the class’ defaults and the passed in arguments.

</>

.equalPowerScale ( )

#
percent

(0-1)

↪ returns Number

output gain (0-1)

Equal power gain scale. Good for cross-fading.

</>

.extend ( )

#
child
parent

(optional) parent to inherit from if no parent is supplied, the child will inherit from Tone

optional

have a child inherit all of Tone’s (or a parent’s) prototype to inherit the parent’s properties, make sure to call Parent.call(this) in the child’s constructor based on closure library’s inherit function

</>

.gainToDb ( )

#
gain

(0-1)

type: Number
↪ returns Decibels

Convert gain to decibels.

</>

.intervalToFrequencyRatio ( )

#
interval

the number of semitones above the base note

↪ returns Number

the frequency ratio

Convert an interval (in semitones) to a frequency ratio.

EXAMPLE

tone.intervalToFrequencyRatio(0); // 1
tone.intervalToFrequencyRatio(12); // 2
tone.intervalToFrequencyRatio(-12); // 0.5
</>

.isArray ( )

#
arg

the argument to test

type: *
↪ returns Boolean

true if the arg is an array

Test if the argument is an Array

</>

.isBoolean ( )

#
arg

the argument to test

type: *
↪ returns Boolean

true if the arg is a boolean

Test if the argument is a boolean.

</>

.isDefined ( )

#
arg

the argument to test

type: *
↪ returns Boolean

true if the arg is undefined

Test if the arg is not undefined

</>

.isFunction ( )

#
arg

the argument to test

type: *
↪ returns Boolean

true if the arg is a function

Test if the arg is a function

</>

.isNote ( )

#
arg

the argument to test

type: *
↪ returns Boolean

true if the arg is a string

Test if the argument is in the form of a note in scientific pitch notation. e.g. “C4”

</>

.isNumber ( )

#
arg

the argument to test

type: *
↪ returns Boolean

true if the arg is a number

Test if the argument is a number.

</>

.isObject ( )

#
arg

the argument to test

type: *
↪ returns Boolean

true if the arg is an object literal.

Test if the given argument is an object literal (i.e. {});

</>

.isString ( )

#
arg

the argument to test

type: *
↪ returns Boolean

true if the arg is a string

Test if the argument is a string.

</>

.isUndef ( )

#
arg

the argument to test

type: *
↪ returns Boolean

true if the arg is undefined

Test if the arg is undefined

</>

.loaded ( )

#
↪ returns Promise

Returns a Promise which resolves when all of the buffers have loaded

</>

.now ( )

#
↪ returns Number

the currentTime from the AudioContext

Return the current time of the AudioContext clock.

</>

.Offline ( )

#
callback

All Tone.js nodes which are created and scheduled within this callback are recorded into the output Buffer.

duration

the amount of time to record for.

type: Time
↪ returns Promise

The promise which is invoked with the Tone.Buffer of the recorded output.

Generate a buffer by rendering all of the Tone.js code within the callback using the OfflineAudioContext. The OfflineAudioContext is capable of rendering much faster than real time in many cases. The callback function also passes in an offline instance of Tone.Transport which can be used to schedule events along the Transport. NOTE OfflineAudioContext has the same restrictions as the AudioContext in that on certain platforms (like iOS) it must be invoked by an explicit user action like a click or tap.

EXAMPLE

//render 2 seconds of the oscillator
Tone.Offline(function(){
	//only nodes created in this callback will be recorded
	var oscillator = new Tone.Oscillator().toMaster().start(0)
	//schedule their events
}, 2).then(function(buffer){
	//do something with the output buffer
})

EXAMPLE

//can also schedule events along the Transport
//using the passed in Offline Transport
Tone.Offline(function(Transport){
	var osc = new Tone.Oscillator().toMaster()
	Transport.schedule(function(time){
		osc.start(time).stop(time + 0.1)
	}, 1)
	Transport.start(0.2)
}, 4).then(function(buffer){
	//do something with the output buffer
})
</>
docs generated Sep 15 2019