new Tone()
Tone is the baseclass of all ToneNodes
From Tone, children inherit timing and math which is used throughout Tone.js
Classes
- Add
- AutoPanner
- BitCrusher
- DryWet
- Effect
- Envelope
- FeedbackDelay
- FeedbackEffect
- LFO
- Merge
- Meter
- Microphone
- Multiply
- Noise
- Oscillator
- Panner
- PingPongDelay
- Player
- Recorder
- Scale
- Signal
- Source
- Split
- Transport
Members
-
<static> context :AudioContext
-
A static pointer to the audio context
Type:
- AudioContext
-
input :GainNode
-
default input of the ToneNode
Type:
- GainNode
-
output :GainNode
-
default output of the ToneNode
Type:
- GainNode
Methods
-
<static> extend(child, parent)
-
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
Parameters:
Name Type Argument Description child
function parent
function <optional>
(optional) parent to inherit from if no parent is supplied, the child will inherit from Tone
-
chain()
-
connect together all of the arguments in series
Parameters:
Type Argument Description AudioParam | Tone <repeatable>
-
connect(unit)
-
connect the output of a ToneNode to an AudioParam, AudioNode, or ToneNode
Parameters:
Name Type Description unit
Tone | AudioParam | AudioNode -
dbToGain(db) → {number}
-
convert db scale to gain scale (0-1)
Parameters:
Name Type Description db
number Returns:
- Type
- number
-
defaultArg(given, fallback) → {*}
-
if a the given is undefined, use the fallback
Parameters:
Name Type Description given
* fallback
* Returns:
- Type
- *
-
disconnect()
-
disconnect the output
-
<virtual> dispose()
-
a dispose method
-
equalPowerScale(percent) → {number}
-
equal power gain scale good for cross-fading
Parameters:
Name Type Description percent
number (0-1)
Returns:
output gain (0-1)
- Type
- number
-
expScale(gain) → {number}
-
Parameters:
Name Type Description gain
number (0-1)
Returns:
gain (decibel scale but betwee 0-1)
- Type
- number
-
frequencyToSeconds(freq) → {number}
-
convert a frequency into seconds accepts both numbers and strings i.e. 10hz or 10 both equal .1
Parameters:
Name Type Description freq
number | string Returns:
- Type
- number
-
gainToDb(gain) → {number}
-
convert gain scale to decibels
Parameters:
Name Type Description gain
number (0-1)
Returns:
- Type
- number
-
interpolate(input, outputMin, outputMax) → {number}
-
interpolate the input value (0-1) to be between outputMin and outputMax
Parameters:
Name Type Description input
number outputMin
number outputMax
number Returns:
- Type
- number
-
logScale(gain) → {number}
-
Parameters:
Name Type Description gain
number (0-1)
Returns:
gain (decibel scale but betwee 0-1)
- Type
- number
-
noGC()
-
makes a connection to ensure that the node will not be garbage collected until 'dispose' is explicitly called
use carefully. circumvents JS and WebAudio's normal Garbage Collection behavior
-
normalize(input, inputMin, inputMax) → {number}
-
normalize the input to 0-1 from between inputMin to inputMax
Parameters:
Name Type Description input
number inputMin
number inputMax
number Returns:
- Type
- number
-
notationToSeconds(notation, bpm, timeSignature) → {number}
-
convert notation format strings to seconds
Parameters:
Name Type Argument Description notation
string bpm
number <optional>
timeSignature
number <optional>
Returns:
- Type
- number
-
now() → {number}
-
Returns:
the currentTime from the AudioContext
- Type
- number
-
receive(channelName)
-
recieve the input from the desired channelName to the input gain of 'this' node.
Parameters:
Name Type Description channelName
string -
samplesToSeconds(samples) → {number}
-
convert a sample count to seconds
Parameters:
Name Type Description samples
number Returns:
- Type
- number
-
secondsToFrequency(seconds) → {number}
-
convert a number in seconds to a frequency
Parameters:
Name Type Description seconds
number Returns:
- Type
- number
-
send(channelName, amount) → {GainNode}
-
send signal to a channel name
Parameters:
Name Type Description channelName
string amount
number Returns:
- Type
- GainNode
-
toFrequency(time) → {number}
-
convert a time to a frequency
Parameters:
Name Type Description time
Tone.Time Returns:
the time in hertz
- Type
- number
-
toMaster()
-
connect 'this' to the master output
-
toSamples(time) → {number}
-
convert a time into samples
Parameters:
Name Type Description time
Tone.time Returns:
- Type
- number
-
toSeconds(time, now) → {number}
-
convert Tone.Time to seconds
this is a simplified version which only handles numbers and 'now' relative numbers. If the Transport is included this method is overridden to include many other features including notationTime, Frequency, and transportTime
Parameters:
Name Type Argument Description time
Tone.Time now
number <optional>
if passed in, this number will be used for all 'now' relative timings
Returns:
seconds in the same timescale as the AudioContext
- Type
- number
-
toSeconds(time, now) → {number}
-
convert Tone.Time into seconds.
unlike the method which it overrides, this takes into account transporttime and musical notation
Parameters:
Name Type Argument Description time
Tone.Time now
number <optional>
if passed in, this number will be used for all 'now' relative timings
Returns:
- Type
- number