class Music::Performance::NoteLinker
Public Class Methods
figure_links(note, next_note)
click to toggle source
# File lib/music-performance/util/note_linker.rb, line 16 def self.figure_links note, next_note unlinked = find_unlinked_pitches(note) untargeted = find_untargeted_pitches(note, next_note) Optimization.linking(unlinked, untargeted) end
find_unlinked_pitches(note)
click to toggle source
# File lib/music-performance/util/note_linker.rb, line 5 def self.find_unlinked_pitches note linked = Set.new(note.pitches) & note.links.keys (Set.new(note.pitches) - linked).to_a end
find_untargeted_pitches(note, next_note)
click to toggle source
# File lib/music-performance/util/note_linker.rb, line 10 def self.find_untargeted_pitches note, next_note linked = Set.new(note.pitches) & note.links.keys targeted = Set.new(linked.map {|p| note.links[p].target_pitch }) (Set.new(next_note.pitches) - targeted).to_a end
fully_link(note, next_note, link_class)
click to toggle source
# File lib/music-performance/util/note_linker.rb, line 22 def self.fully_link note, next_note, link_class figure_links(note,next_note).each do |pitch,tgt_pitch| note.links[pitch] = link_class.new(tgt_pitch) end end