Back

Music Object

You can create an instance of the Music object when you need it like this:

 music = app.CreateMusic()

Methods:

 music.CreateSynth(type, options, noDestination)

Create synth.


 music.Gain(value, options)

A thin wrapper around the Native Web Audio GainNode. The GainNode is a basic building block of the Web Audio API and is useful for routing audio and adjusting gains.

Synth Example With Gain


function OnStart()
{
  music = app.CreateMusic()
  synth = music.CreateSynth("Synth", null, true)
  synth.Connect(music.Gain(0.5))
  synth.PlayStopTone("C4", "8n")
}

  Copy   Copy All    Run   

 music.Phaser(frequency, octaves, baseFrequency)

Phaser is a phaser effect. Phasers work by changing the phase of different frequency components of an incoming signal.

Synth Example With Phaser


function OnStart()
{
  music = app.CreateMusic()
  synth = music.CreateSynth("Synth", null, true)
  synth.Connect(music.Phaser())
  synth.PlayStopTone("C4", "8n")
}

  Copy   Copy All    Run   

 music.Distortion(value)

A simple distortion effect.

Synth Example With Distortion


function OnStart()
{
  music = app.CreateMusic()
  synth = music.CreateSynth("Synth", null, true)
  synth.Connect(music.Distortion(0.5))
  synth.PlayStopTone("C4", "8n")
}

  Copy   Copy All    Run   

 music.FeedbackDelay(delay, feedback)

FeedbackDelay is a DelayNode in which part of output signal is fed back into the delay.

Synth Example With FeedbackDelay


function OnStart()
{
  music = app.CreateMusic()
  synth = music.CreateSynth("Synth", null, true)
  synth.Connect(music.FeedbackDelay(0.125, 0.5))
  synth.PlayStopTone("C4", "8n")
}

  Copy   Copy All    Run   

 music.Filter(frequency, type, rolloff)

Filter is a filter which allows for all of the same native methods as the BiquadFilterNode. Tone.Filter has the added ability to set the filter rolloff at -12 (default), -24 and -48.

Synth Example With Filter


function OnStart()
{
  music = app.CreateMusic()
  synth = music.CreateSynth("Synth", null, true)
  synth.Connect(music.Filter(500, "lowpass"))
  synth.PlayStopTone("C4", "8n")
}

  Copy   Copy All    Run   

 music.Now()

The current audio context time of the global context.


 music.SetOnLoaded(callback)

Callback which resolves when all of the loading promises are resolved.


 music.StartTransport(time, offset)

Start the transport and all sources synced to the transport.


 music.StopTransport(time)

Stop the transport and all sources synced to the transport.


 music.RampToTransport(value, rampTime, startTime)

Ramps to the given value over the duration of the rampTime. Automatically selects the best ramp type (exponential or linear) depending on the units of the signal


 music.RepeatTransport(callback, interval)

Schedule a repeated event along the timeline. The event will fire at the interval starting at the startTime and for the specified duration.


 music._tone

Return Tone class from Tonejs


Synth, AM, FM, Membrane, Metal, Duo, Pluck, Noise
{}
{
  convert: BOOLEAN,
  minValue: NUMBER,
  maxValue: NUMBER,
  units: TYPE
}
true or false
A number greater than or equal to 0.
Frequency can be described similar to time, except ultimately the values are converted to frequency instead of seconds. A number is taken literally as the value in hertz. Additionally any of the Time encodings can be used. Note names in the form of NOTE OCTAVE (i.e. C4) are also accepted and converted to their frequency value.
function
Time can be described in a number of ways. Read more TransportTime describes a position along the Transport's timeline. It is similar to Time in that it uses all the same encodings, but TransportTime specifically pertains to the Transport's timeline, which is startable, stoppable, loopable, and seekable. Range: 0,1
Range: 0,2
If make true you can use synth.Connect inside music.Gain and music.Filter
Sine, Square, Triangle, Sawtooth
-12, -24, -48, -96
lowpass, highpass, bandpass, lowshelf, highself, notch, allpass, peaking