Class: Ruck::Generators::SawOsc
- Includes:
- Oscillator, Source
- Defined in:
- lib/ruck/ugen/oscillators.rb
Constant Summary
Constants included from Oscillator
Instance Attribute Summary
Attributes included from UGen
Instance Method Summary collapse
- #attr_names ⇒ Object
-
#initialize(attrs = {}) ⇒ SawOsc
constructor
A new instance of SawOsc.
- #next(now) ⇒ Object
Methods included from Oscillator
Methods included from UGen
Methods included from Source
#<<, #>>, #last, #out, #out_channels
Constructor Details
#initialize(attrs = {}) ⇒ SawOsc
Returns a new instance of SawOsc.
55 56 57 58 59 60 |
# File 'lib/ruck/ugen/oscillators.rb', line 55 def initialize(attrs = {}) parse_attrs({ :freq => 440.0, :gain => 1.0 }.merge(attrs)) @phase = 0.0 @last = 0.0 end |
Instance Method Details
#attr_names ⇒ Object
70 71 72 |
# File 'lib/ruck/ugen/oscillators.rb', line 70 def attr_names [:freq, :gain, :phase] end |
#next(now) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/ruck/ugen/oscillators.rb', line 62 def next(now) return @last if @now == now @now = now @last = ((phase * 2.0) - 1.0) * gain phase_forward @last end |