class Musicality::Sequencer
Attributes
part_names[R]
part_sequenceables[R]
Public Class Methods
new(part_sequenceables)
click to toggle source
# File lib/musicality/composition/sequencing/sequencer.rb, line 6 def initialize part_sequenceables @part_sequenceables = part_sequenceables.freeze @part_note_fifos = Hash[ part_sequenceables.keys.map {|partname| [ partname, NoteFIFO.new ] } ] @part_names = @part_sequenceables.keys end
Public Instance Methods
next_part_notes(target_duration)
click to toggle source
# File lib/musicality/composition/sequencing/sequencer.rb, line 12 def next_part_notes target_duration if target_duration <= 0 raise ArgumentError, "Target duration #{target_duration} is non-positive}" end part_notes = {} @part_sequenceables.each do |partname, sequenceable| note_fifo = @part_note_fifos[partname] while note_fifo.duration < target_duration note_fifo.add_note(sequenceable.next_note) end part_notes[partname] = note_fifo.remove_notes(target_duration) end return part_notes end
reset()
click to toggle source
# File lib/musicality/composition/sequencing/sequencer.rb, line 30 def reset @part_sequenceables.values.each { |s| s.reset } end