Class: Ruck::UGen::Generators::TriOsc
- Includes:
- Oscillator, Source
- Defined in:
- lib/ruck/ugen/oscillators.rb
Constant Summary
Constants included from Oscillator
Instance Attribute Summary
Attributes included from UGenBase
Instance Method Summary collapse
- #attr_names ⇒ Object
-
#initialize(attrs = {}) ⇒ TriOsc
constructor
A new instance of TriOsc.
- #next(now) ⇒ Object
Methods included from Oscillator
Methods included from UGenBase
Methods included from Source
#<<, #>>, #last, #out, #out_channels
Constructor Details
#initialize(attrs = {}) ⇒ TriOsc
Returns a new instance of TriOsc.
86 87 88 89 90 91 |
# File 'lib/ruck/ugen/oscillators.rb', line 86 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
105 106 107 |
# File 'lib/ruck/ugen/oscillators.rb', line 105 def attr_names [:freq, :gain, :phase] end |
#next(now) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/ruck/ugen/oscillators.rb', line 93 def next(now) return @last if @now == now @now = now @last = if phase < 0.5 phase * 4.0 - 1.0 else 1.0 - ((phase - 0.5) * 4.0) end * gain phase_forward @last end |