class PicoTune::Sample

Attributes

left[R]
right[R]

Public Class Methods

new(left = 0.0, right = 0.0) click to toggle source
# File lib/picotune.rb, line 44
def initialize left = 0.0, right = 0.0
  @left, @right = left.to_f, right.to_f
end

Public Instance Methods

add(sample) click to toggle source
# File lib/picotune.rb, line 48
def add sample
  @left += sample.left
  @right += sample.right

  # hard clip

  if @left > 1.0
    @left = 1.0
  elsif @left < -1.0
    @left = -1.0
  end

  if @right > 1.0
    @right = 1.0
  elsif @right < -1.0
    @right = -1.0
  end

  self # return self to chain ops EX: sample.add(sample).add(sample) etc
end
modify_left(operator, modifier) click to toggle source
# File lib/picotune.rb, line 69
def modify_left operator, modifier
  @left = @left.send operator, modifier
end
modify_right(operator, modifier) click to toggle source
# File lib/picotune.rb, line 73
def modify_right operator, modifier
  @right = @right.send operator, modifier
end
to_a() click to toggle source
# File lib/picotune.rb, line 40
def to_a
  [@left, @right]
end