Class: Ruck::UGen::Generators::Delay

Inherits:
Object
  • Object
show all
Includes:
Source, Target, 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 Target

#add_source, #remove_source

Methods included from UGenBase

#to_s

Constructor Details

#initialize(attrs = {}) ⇒ Delay

Returns a new instance of Delay.



63
64
65
66
67
68
69
70
# File 'lib/ruck/ugen/basic.rb', line 63

def initialize(attrs = {})
  require_attrs attrs, [:time]
  samples = attrs.delete(:time)
  parse_attrs attrs
  @ins = []
  @last = 0.0
  @queue = [0.0] * samples
end

Instance Method Details

#attr_namesObject



80
81
82
# File 'lib/ruck/ugen/basic.rb', line 80

def attr_names
  [:time]
end

#next(now) ⇒ Object



72
73
74
75
76
77
78
# File 'lib/ruck/ugen/basic.rb', line 72

def next(now)
  return @last if @now == now
  @now = now

  @queue << @ins.inject(0) { |samp, ugen| samp += ugen.next(now) } * gain
  @last = @queue.shift
end