Class: Stretto::MusicElements::Timing

Inherits:
MusicElement show all
Defined in:
lib/stretto/music_elements/timing.rb

Overview

Timing information places the elements at the specified position in time,

This information is mostly used when reading a MIDI file or using it live, to synchronize with playback. The quantity is expressed in miliseconds.

Instance Attribute Summary

Attributes inherited from MusicElement

#original_string, #pattern

Attributes included from Node

#next, #prev

Instance Method Summary collapse

Methods inherited from MusicElement

#build_music_string, #duration, #end_of_tie?, #start_of_tie?, #to_s

Constructor Details

#initialize(string_or_options, pattern = nil) ⇒ Timing

Returns a new instance of Timing



12
13
14
15
16
17
18
19
# File 'lib/stretto/music_elements/timing.rb', line 12

def initialize(string_or_options, pattern = nil)
  token = case string_or_options
    when String then Stretto::Parser.parse_timing!(string_or_options)
    else string_or_options
  end
  super(token[:text_value], pattern)
  @original_value = token[:value]
end

Instance Method Details

#substitute_variables!Object

private



26
27
28
# File 'lib/stretto/music_elements/timing.rb', line 26

def substitute_variables!
  @value = self.value
end

#valueObject



21
22
23
# File 'lib/stretto/music_elements/timing.rb', line 21

def value
  @value || @original_value.to_i(@pattern)
end