Module: HeadMusic::Time::EventMapSupport

Included in:
MeterMap, TempoMap
Defined in:
lib/head_music/time/event_map_support.rb

Overview

Shared support for MeterMap and TempoMap event management

Instance Method Summary collapse

Instance Method Details

#compare_positions(first_position, second_position) ⇒ Object (private)



20
21
22
# File 'lib/head_music/time/event_map_support.rb', line 20

def compare_positions(first_position, second_position)
  position_tuple(first_position) <=> position_tuple(second_position)
end

#position_tuple(position) ⇒ Object (private)



24
25
26
# File 'lib/head_music/time/event_map_support.rb', line 24

def position_tuple(position)
  [position.bar, position.beat, position.tick, position.subtick]
end

#positions_equal?(first_position, second_position) ⇒ Boolean (private)

Returns:

  • (Boolean)


16
17
18
# File 'lib/head_music/time/event_map_support.rb', line 16

def positions_equal?(first_position, second_position)
  position_tuple(first_position) == position_tuple(second_position)
end

#sort_events!Object (private)



9
10
11
12
13
14
# File 'lib/head_music/time/event_map_support.rb', line 9

def sort_events!
  @events.sort_by! do |event|
    position = event.position
    [position.bar, position.beat, position.tick, position.subtick]
  end
end