Back

Loop

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:

 loop = music.Loop(callback, time)


Example


function OnStart()
{
  app._122()
  music = app._381()
  synth = music.CreateSynth()

  // Call a function every 2 seconds
  music.Loop(OnLoop, "+2").Start()
  music.StartTransport()
}

function OnLoop(time)
{
  console.log(time)
  synth.PlayStopTone("C4", "8n")
}

  Copy   Copy All    Run   


Methods:

 loop.Start(number)

Start the source at the specified time. If no time is given, start the source now.


 loop.Stop(number)

Stop the loop at the given time.


 loop.Cancel(number)

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


Seconds
function(time)
Time can be described in a number of ways. Read more Time.