Loop creates a looped callback at the specified interval. The callback can be started, stopped and scheduled along the Transport's timeline.
You can an instance of the music object when you need it like this:
Example
function OnStart()
{
app._122()
music = app._381()
synth = music.CreateSynth()
music.Loop(OnLoop, "+2").Start()
music.StartTransport()
}
function OnLoop(time)
{
console.log(time)
synth.PlayStopTone("C4", "8n")
}
Methods:
Start the source at the specified time. If no time is given, start the source now.
Stop the loop at the given time.
Cancel all scheduled events greater than or equal to the given time.
loop.GetName()
Return loop name.
loop._loop
Return Tone.Loop class from Tonejs
Time can be described in a number of ways. Read more
Time.
- Numbers, which will be taken literally as the time (in seconds).
- Notation, ("4n", "8t") describes time in BPM and time signature relative values.
- TransportTime, ("4:3:2") will also provide tempo and time signature relative times in the form BARS:QUARTERS:SIXTEENTHS.
- Frequency, ("8hz") is converted to the length of the cycle in seconds.
- Now-Relative, ("+1") prefix any of the above with "+" and it will be interpreted as "the current time plus whatever expression follows".
- Object, ({"4n" : 3, "8t" : -1}). The resulting time is equal to the sum of all of the keys multiplied by the values in the object.
- No Argument, for methods which accept time, no argument will be interpreted as "now" (i.e. the currentTime).