Class: SynthBlocks::Fx::FixedDelay

Inherits:
Object
  • Object
show all
Defined in:
lib/synth_blocks/fx/g_verb.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(size) ⇒ FixedDelay

Returns a new instance of FixedDelay.



29
30
31
32
33
34
# File 'lib/synth_blocks/fx/g_verb.rb', line 29

def initialize(size)
  @size = size
  @buf = Array.new(size)
  @idx = 0
  @buf = @buf.map { |e| 0.0 }
end

Instance Method Details

#read(n) ⇒ Object



36
37
38
39
# File 'lib/synth_blocks/fx/g_verb.rb', line 36

def read(n)
  i = (@idx - n + @size) % @size;
  @buf[i]
end

#write(x) ⇒ Object



41
42
43
44
# File 'lib/synth_blocks/fx/g_verb.rb', line 41

def write(x)
  @buf[@idx] = x
  @idx = (@idx + 1) % @size
end