Method: Musicality::NoteSequence#simplify!
- Defined in:
- lib/musicality/performance/model/note_sequence.rb
#simplify! ⇒ Object
any consecutive elements with the same pitch and no attack will be combined
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/musicality/performance/model/note_sequence.rb', line 31 def simplify! return if @elements.none? prev_element = @elements[0] idx = 1 while idx < @elements.size element = @elements[idx] if (element.pitch == prev_element.pitch) && (element.attack == Attack::NONE) prev_element.duration += element.duration @elements.delete_at(idx) else prev_element = element idx += 1 end end end |