Tone.Transport
↳ EXTENDS Tone.EmitterTransport for timing musical events. Supports tempo curves and time changes. Unlike browser-based timing (setInterval, requestAnimationFrame) Tone.Transport timing events pass in the exact time of the scheduled event in the argument of the callback function. Pass that time value to the object you’re scheduling.
A single transport is created for you when the library is initialized.
The transport emits the events: “start”, “stop”, “pause”, and “loop” which are called with the time of that event as the argument.
CONSTRUCTOR
new Tone.Transport ( )DEFAULTS
EXAMPLE
EXAMPLE
Members
.timeSignature
↝ Number or Array #The time signature as just the numerator over 4. For example 4/4 would be just 4 and 6/8 would be 3.
EXAMPLE
.position
↝ BarsBeatsSixteenths #The Transport’s position in Bars:Beats:Sixteenths. Setting the value will jump to that position right away.
.progress
↝ NormalRange #The Transport’s loop position as a normalized value. Always returns 0 if the transport if loop is not true.
.seconds
↝ Seconds #The Transport’s position in seconds Setting the value will jump to that position right away.
.state
↝ Tone.State READONLY #Returns the playback state of the source, either “started”, “stopped”, or “paused”
.swing
↝ NormalRange #The swing value. Between 0-1 where 1 equal to the note + half the subdivision.
.swingSubdivision
↝ Time #Set the subdivision which the swing will be applied to. The default value is an 8th note. Value must be less than a quarter note.
.PPQ
↝ Number #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.
Methods
.unsyncSignal ( )
#this
Unsyncs a previously synced signal from the transport’s control. See Tone.Transport.syncSignal.
.clear ( )
#The id of the event.
this
Clear the passed in event id from the timeline
.stop ( )
#The time when the transport should stop.
this
Stop the transport and all sources synced to the transport.
EXAMPLE
.syncSignal ( )
#Optionally pass in the ratio between the two signals. Otherwise it will be computed based on their current values.
this
Attaches the signal to the tempo control signal so that any changes in the tempo will change the signal in the same ratio.
.toggle ( )
#The time of the event
this
Toggle the current state of the transport. If it is started, it will stop it, otherwise it will start the Transport.
.cancel ( )
#Clear all events after this time.
this
Remove scheduled events from the timeline after the given time. Repeated events will be removed if their startTime is after the given time
.getSecondsAtTime ( )
#Return the elapsed seconds at the given time.
.getTicksAtTime ( )
#Get the clock’s ticks at the given time.
.nextSubdivision ( )
#The subdivision to quantize to
The context time of the next subdivision.
Returns the time aligned to the next subdivision of the Transport. If the Transport is not started, it will return 0. Note: this will not work precisely during tempo ramps.
EXAMPLE
.pause ( )
#this
Pause the transport and all sources synced to the transport.
.schedule ( )
#The callback to be invoked at the time.
The time to invoke the callback at.
The id of the event which can be used for canceling the event.
Schedule an event along the timeline.
EXAMPLE
.scheduleOnce ( )
#The callback to invoke once.
The time the callback should be invoked.
The ID of the scheduled event.
Schedule an event that will be removed after it is invoked.
.scheduleRepeat ( )
#The callback to invoke.
The duration between successive callbacks. Must be a positive number.
When along the timeline the events should start being invoked.
How long the event should repeat.
The ID of the scheduled event. Use this to cancel the event.
Schedule a repeated event along the timeline. The event will fire at the interval
starting at the startTime
and for the specified duration
.
EXAMPLE
.start ( )
#The time when the transport should start.
The timeline offset to start the transport.
this
Start the transport and all sources synced to the transport.
EXAMPLE
.emit ( )
#The name of the event.
The arguments to pass to the functions listening.
this
Invoke all of the callbacks bound to the event with any arguments passed in.
.off ( )
#The event to stop listening to.
The callback which was bound to the event with Tone.Emitter.on. If no callback is given, all callbacks events are removed.
this
Remove the event listener.
.on ( )
#The name of the event to listen for.
The callback to invoke when the event is emitted
this
Bind a callback to a specific event.
.once ( )
#The name of the event to listen for.
The callback to invoke when the event is emitted
this
Bind a callback which is only invoked once