Back

Oscillator

Oscillator supports a number of features including phase rotation, multiple oscillator types.

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

 synth = music.CreateOscillator(note, type, noDestination)


Example


function OnStart()
{
  music = app.CreateMusic()
  osc = music.CreateOscillator(440, "sine")

  osc.Play()
}

  Copy   Copy All    Run   


Methods:

 osc.Play(time, offset, duration)

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


 osc.Stop(time)

Stop the source at the specified time. If no time is given, stop the source now.


 osc.Restart(note, type)

Restart the source.


 osc.SetVolume(decibels)

The volume of the output in decibels.


 osc.SetFrequency(value)

The volume of the output in decibels.


 osc.SetFrequencyRampTo(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.


 osc.Connect(...nodes)

Connect the output of this node to the rest of the nodes in series.


 osc.GetName()

Return oscillator name.


 osc.Dispose()

Clean up.


 osc._oscillator

Return Tone.Oscillator class from Tonejs


Synth, AM, FM, Membrane, Metal, Duo, Pluck, Mono, Noise
{volume: DECIBELS,
portamento: SECONDS}
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.
Time can be described in a number of ways. Read more Time.
true or false
music.Gain, music.Phaser or other Tonejs effects.
Range: 0..1
Range: 0..2
Range: 0..5
Sine, Square, Triangle, Sawtooth
Decibels are a logarithmic unit of measurement which is useful for volume because of the logarithmic way that we perceive loudness. 0 decibels means no change in volume. -10db is approximately half as loud and 10db is twice is loud.