class Negasonic::LoopedEvent::Part

Public Class Methods

new(synth) click to toggle source
# File lib/negasonic/looped_event/part.rb, line 4
def initialize(synth)
  @synth = synth
  @definitions = []
end

Public Instance Methods

play(note, time, duration) click to toggle source
# File lib/negasonic/looped_event/part.rb, line 15
def play(note, time, duration)
  @definitions << { note: note, time: time, duration: duration }
end
start() click to toggle source
# File lib/negasonic/looped_event/part.rb, line 9
def start
  do_start do |time, event|
    @synth.trigger_attack_release(event.JS['note'], event.JS['duration'], time)
  end
end

Private Instance Methods

do_start(&block) click to toggle source
# File lib/negasonic/looped_event/part.rb, line 21
def do_start(&block)
  LoopedEvent.start(Tone::Event::Part.new @definitions, &block)
end