Class: Stretto::MusicElements::Tempo
Overview
Tempo represents the bpm of the song.
It is indicated by a T followed by the value of the tempo. There are some predefined variables that define the most common tempos (see Variables::TEMPO_VARIABLES), and the default is allegro, that is, a tempo of T120 bpm
Instance Attribute Summary
Attributes inherited from MusicElement
#original_string, #pattern
Attributes included from Node
#next, #prev
Instance Method Summary
collapse
#build_music_string, #duration, #end_of_tie?, #start_of_tie?, #to_s
Constructor Details
#initialize(string_or_options, pattern = nil) ⇒ Tempo
14
15
16
17
18
19
20
21
|
# File 'lib/stretto/music_elements/tempo.rb', line 14
def initialize(string_or_options, pattern = nil)
token = case string_or_options
when String then Stretto::Parser.parse_tempo!(string_or_options)
else string_or_options
end
super(token[:text_value], pattern)
@original_value = token[:value]
end
|
Instance Method Details
27
28
29
|
# File 'lib/stretto/music_elements/tempo.rb', line 27
def bpm
value
end
|
#substitute_variables! ⇒ Object
35
36
37
|
# File 'lib/stretto/music_elements/tempo.rb', line 35
def substitute_variables!
self.value = value
end
|
31
32
33
|
# File 'lib/stretto/music_elements/tempo.rb', line 31
def value
@value || @original_value.to_i(@pattern)
end
|
#value=(value) ⇒ Object
23
24
25
|
# File 'lib/stretto/music_elements/tempo.rb', line 23
def value=(value)
@value = value
end
|