Creates a signal that oscillates between -1.0 and 1.0. By default, the oscillation takes the form of a sinusoidal shape ('sine'). Additional types include 'triangle', 'sawtooth' and 'square'. The frequency defaults to 440 oscillations per second (440Hz, equal to the pitch of an 'A' note).
Set the type of oscillation with setType(), or by instantiating a specific oscillator: p5.SinOsc, p5.TriOsc, p5.SqrOsc, or p5.SawOsc.
実例
シンタックス
p5.Oscillator([freq], [type])
パラメーター
frequency defaults to 440Hz
type of oscillator. Options: 'sine' (default), 'triangle', 'sawtooth', 'square'
メソッド
Start an oscillator.
Starting an oscillator on a user gesture will enable audio in browsers that have a strict autoplay policy, including Chrome and most mobile devices. See also: userStartAudio()
.
Stop an oscillator. Accepts an optional parameter to determine how long (in seconds from now) until the oscillator stops.
Set the amplitude between 0 and 1.0. Or, pass in an object such as an oscillator to modulate amplitude with an audio signal.
Returns the value of output gain
Set frequency of an oscillator to a value. Or, pass in an object such as an oscillator to modulate the frequency with an audio signal.
Returns the value of frequency of oscillator
Set type to 'sine', 'triangle', 'sawtooth' or 'square'.
Returns current type of oscillator eg. 'sine', 'triangle', 'sawtooth' or 'square'.
Connect to a p5.sound / Web Audio object.
Disconnect all outputs
Pan between Left (-1) and Right (1)
Returns the current value of panPosition , between Left (-1) and Right (1)
Set the phase of an oscillator between 0.0 and 1.0. In this implementation, phase is a delay time based on the oscillator's current frequency.
Add a value to the p5.Oscillator's output amplitude, and return the oscillator. Calling this method again will override the initial add() with a new value.
Multiply the p5.Oscillator's output amplitude by a fixed value (i.e. turn it up!). Calling this method again will override the initial mult() with a new value.
Scale this oscillator's amplitude values to a given range, and return the oscillator. Calling this method again will override the initial scale() with new values.