Class: Ruck::UGen::Generators::Ramp

Inherits:
Object
  • Object
show all
Includes:
Source, UGenBase
Defined in:
lib/ruck/ugen/basic.rb

Instance Attribute Summary

Attributes included from UGenBase

#name

Instance Method Summary collapse

Methods included from Source

#<<, #>>, #last, #out, #out_channels

Methods included from UGenBase

#to_s

Constructor Details

#initialize(attrs = {}) ⇒ Ramp

Returns a new instance of Ramp.



117
118
119
120
121
122
123
124
# File 'lib/ruck/ugen/basic.rb', line 117

def initialize(attrs = {})
  parse_attrs({ :from => 0.0,
                :to => 1.0,
                :duration => 1.second }.merge(attrs))
  @progress = 0.0
  @paused = false
  @last = 0.0
end

Instance Method Details

#attr_namesObject



146
147
148
# File 'lib/ruck/ugen/basic.rb', line 146

def attr_names
  [:from, :to, :duration, :progress, :paused]
end

#finished?Boolean

Returns:

  • (Boolean)


142
143
144
# File 'lib/ruck/ugen/basic.rb', line 142

def finished?
  progress == 1.0
end

#next(now) ⇒ Object



126
127
128
129
130
131
132
# File 'lib/ruck/ugen/basic.rb', line 126

def next(now)
  return @last if @now == now
  @now = now
  @last = progress * (to - from) + from
  inc_progress
  @last
end

#resetObject



138
139
140
# File 'lib/ruck/ugen/basic.rb', line 138

def reset
  @progress = 0.0
end

#reverseObject



134
135
136
# File 'lib/ruck/ugen/basic.rb', line 134

def reverse
  @from, @to = @to, @from
end