new Signal(value)
constant audio-rate signal
Tone.Signal is a core component which allows for synchronization of many components. A single signal can drive multiple parameters by applying Scaling.
For example: to synchronize two Tone.Oscillators in octaves of each other, Signal --> OscillatorA.frequency ^--> Tone.Multiply(2) --> OscillatorB.frequency
Tone.Signal can be scheduled with all of the functions available to AudioParams
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
value |
number |
<optional> |
(optional) initial value |
- Source:
Extends
Members
-
<private> _syncRatio :number
-
the ratio of the this value to the control signal value
Type:
- number
- Source:
-
bufferSize :number
-
the default buffer size
Type:
- number
- Inherited From:
- Source:
-
context :AudioContext
-
A static pointer to the audio context
Type:
- AudioContext
- Inherited From:
- Source:
-
input :GainNode
-
default input of the ToneNode
Type:
- GainNode
- Inherited From:
- Source:
-
isFrequency
-
true if the input is in the format number+hz i.e.: 10hz
- Inherited From:
- Source:
-
isNotation
-
tests if a string is musical notation i.e.: 4n = quarter note 2m = two measures 8t = eighth-note triplet
- Inherited From:
- Source:
-
isTransportTime
-
tests if a string is transportTime i.e. : 1:2:0 = 1 measure + two quarter notes + 0 sixteenth notes
- Inherited From:
- Source:
-
output :GainNode
-
default output of the ToneNode
Type:
- GainNode
- Inherited From:
- Source:
-
scalar :GainNode
-
scales the constant output to the desired output
Type:
- GainNode
- Source:
Methods
-
cancelScheduledValues(startTime)
-
Cancels all scheduled parameter changes with times greater than or equal to startTime.
Parameters:
Name Type Description startTime
Tone.Time - Source:
-
chain()
-
connect together all of the arguments in series
Parameters:
Type Argument Description AudioParam | Tone <repeatable>
- Inherited From:
- Source:
-
connect(node)
-
Signals can connect to other Signals
Parameters:
Name Type Description node
AudioParam | AudioNode | Tone.Signal | Tone - Source:
-
dbToGain(db) → {number}
-
convert db scale to gain scale (0-1)
Parameters:
Name Type Description db
number - Inherited From:
- Source:
Returns:
- Type
- number
-
defaultArg(given, fallback) → {*}
-
if a the given is undefined, use the fallback
Parameters:
Name Type Description given
* fallback
* - Inherited From:
- Source:
Returns:
- Type
- *
-
disconnect()
-
disconnect the output
- Inherited From:
- Source:
-
dispose()
-
internal dispose method to tear down the node
- Source:
-
equalPowerScale(percent) → {number}
-
equal power gain scale good for cross-fading
Parameters:
Name Type Description percent
number (0-1)
- Inherited From:
- Source:
Returns:
output gain (0-1)
- Type
- number
-
exponentialRampToValueAtTime(value, endTime)
-
Schedules an exponential continuous change in parameter value from the previous scheduled parameter value to the given value.
NOTE: Chrome will throw an error if you try to exponentially ramp to a value 0 or less.
Parameters:
Name Type Description value
number endTime
Tone.Time - Source:
-
exponentialRampToValueNow(value, endTime)
-
Schedules an exponential continuous change in parameter value from the current time and current value to the given value.
Parameters:
Name Type Description value
number endTime
Tone.Time - Source:
-
expScale(gain) → {number}
-
Parameters:
Name Type Description gain
number (0-1)
- Inherited From:
- Source:
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 - Inherited From:
- Source:
Returns:
- Type
- number
-
gainToDb(gain) → {number}
-
convert gain scale to decibels
Parameters:
Name Type Description gain
number (0-1)
- Inherited From:
- Source:
Returns:
- Type
- number
-
getValue() → {number}
-
- Source:
Returns:
the current value of the signal
- 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 - Inherited From:
- Source:
Returns:
- Type
- number
-
linearRampToValueAtTime(value, endTime)
-
Schedules a linear continuous change in parameter value from the previous scheduled parameter value to the given value.
Parameters:
Name Type Description value
number endTime
Tone.Time - Source:
-
linearRampToValueNow(value, endTime)
-
Schedules an linear continuous change in parameter value from the current time and current value to the given value at the given time.
Parameters:
Name Type Description value
number endTime
Tone.Time - Source:
-
logScale(gain) → {number}
-
Parameters:
Name Type Description gain
number (0-1)
- Inherited From:
- Source:
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
- Inherited From:
- Source:
-
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 - Inherited From:
- Source:
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>
- Inherited From:
- Source:
Returns:
- Type
- number
-
now() → {number}
-
- Inherited From:
- Source:
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 - Inherited From:
- Source:
-
samplesToSeconds(samples) → {number}
-
convert a sample count to seconds
Parameters:
Name Type Description samples
number - Inherited From:
- Source:
Returns:
- Type
- number
-
secondsToFrequency(seconds) → {number}
-
convert a number in seconds to a frequency
Parameters:
Name Type Description seconds
number - Inherited From:
- Source:
Returns:
- Type
- number
-
send(channelName, amount) → {GainNode}
-
send signal to a channel name
Parameters:
Name Type Description channelName
string amount
number - Inherited From:
- Source:
Returns:
- Type
- GainNode
-
setCurrentValueNow(now) → {number}
-
creates a schedule point with the current value at the current time
Parameters:
Name Type Argument Description now
number <optional>
(optionally) pass the now value in
- Source:
Returns:
the current value
- Type
- number
-
setTargetAtTime(value, startTime, timeConstant)
-
Start exponentially approaching the target value at the given time with a rate having the given time constant.
Parameters:
Name Type Description value
number startTime
Tone.Time timeConstant
number - Source:
-
setValue(value)
-
set the value of the signal right away will be overwritten if there are previously scheduled automation curves
Parameters:
Name Type Description value
number - Source:
-
setValueAtTime(value, time)
-
Schedules a parameter value change at the given time.
Parameters:
Name Type Description value
number time
Tone.Time - Source:
-
setValueCurveAtTime(values, startTime, duration)
-
Sets an array of arbitrary parameter values starting at the given time for the given duration.
Parameters:
Name Type Description values
Array.<number> startTime
Tone.Time duration
Tone.Time - Source:
-
sync(signal, ratio)
-
Sync this to another signal and it will always maintain the ratio between the two signals until it is unsynced
Signals can only be synced to one other signal. while syncing, if a signal's value is changed, the new ratio between the signals is maintained as the syncing signal is changed.
Parameters:
Name Type Argument Description signal
Tone.Signal to sync to
ratio
number <optional>
optionally pass in the ratio between the two signals, otherwise it will be computed
- Source:
-
toFrequency(time) → {number}
-
convert a time to a frequency
Parameters:
Name Type Description time
Tone.Time - Inherited From:
- Source:
Returns:
the time in hertz
- Type
- number
-
toMaster()
-
connect 'this' to the master output
- Inherited From:
- Source:
-
toSamples(time) → {number}
-
convert a time into samples
Parameters:
Name Type Description time
Tone.time - Inherited From:
- Source:
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
- Inherited From:
- Source:
Returns:
- 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
- Inherited From:
- Source:
Returns:
- Type
- number
-
toTransportTime(seconds, bpm, timeSignature) → {string}
-
Convert seconds to the closest transportTime in the form measures:quarters:sixteenths
Parameters:
Name Type Argument Description seconds
Tone.Time bpm
number <optional>
timeSignature
number <optional>
- Inherited From:
- Source:
Returns:
- Type
- string
-
transportTimeToSeconds(transportTime, bpm, timeSignature) → {number}
-
convert transportTime into seconds i.e.: 4:2:3 == 4 measures + 2 quarters + 3 sixteenths
Parameters:
Name Type Argument Description transportTime
string bpm
number <optional>
timeSignature
number <optional>
- Inherited From:
- Source:
Returns:
seconds
- Type
- number
-
unsync()
-
unbind the signal control
will leave the signal value as it was without the influence of the control signal
- Source: