class SMF::Shuffle

Public Class Methods

new(div, beat=1.0/8) click to toggle source
# File lib/smf/toy/shuffle.rb, line 10
def initialize(div, beat=1.0/8)
  @unit = beat * div * 4
  self.amount = 0.5
end

Public Instance Methods

amount=(v) click to toggle source
# File lib/smf/toy/shuffle.rb, line 15
def amount=(v)
  qunit = @unit / 4
  shift = @unit / 2 * v
  x = GSL::Vector.alloc(0, qunit, qunit*2, qunit*3, @unit)
  y = GSL::Vector.alloc(0, qunit + shift*0.25, qunit*2 + shift, qunit*3 + shift*0.5, @unit)
  @spline = GSL::Spline.alloc('linear', x, y)
end
shuffle(ev) click to toggle source
# File lib/smf/toy/shuffle.rb, line 23
def shuffle(ev)
  q, r = ev.offset.divmod(@unit)
  r2 = @spline.eval(r)
  ev.offset = (q * @unit + r2).round
end