Class: Stretto::Tokens::ChordToken
- Includes:
- WithAttackDecayToken, WithDurationToken, WithNoteStringToken
- Defined in:
- lib/stretto/grammar/tokens/chord_token.rb
Overview
Parses a named chord
@example: “C5#maj”
Instance Method Summary collapse
-
#base_note ⇒ Object
Returns a base note hash, which can be seen as a token returned by the parsed note.
-
#inversions ⇒ Object
If inversions are present, return a hash containing the pivot note (e.g. “^C”) or the number of inversions (e.g. 5).
-
#named_chord ⇒ Object
A string containing the named chord.
- #note_string ⇒ NoteStringToken
-
#notes ⇒ Object
Don’t precalculate values.
-
#to_stretto(pattern = nil) ⇒ MusicElements::Chord
The constructed Chord element.
Methods included from WithAttackDecayToken
Methods included from WithNoteStringToken
#accidental, #key, #octave, #pitch
Methods included from WithDurationToken
Methods inherited from HashToken
Instance Method Details
#base_note ⇒ Object
Returns a base note hash, which can be seen as a token returned by the parsed note
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/stretto/grammar/tokens/chord_token.rb', line 25 def base_note { :text_value => note_string.text_value, :key => key, :pitch => pitch, :accidental => accidental, :octave => octave, :attack => attack, :decay => decay, :duration => duration } end |
#inversions ⇒ Object
If inversions are present, return a hash containing the pivot note
(e.g. "^C") or the number of inversions (e.g. 5)
51 52 53 54 55 56 |
# File 'lib/stretto/grammar/tokens/chord_token.rb', line 51 def inversions if __chord_inversions and __chord_inversions.text_value.present? { :inversions => __chord_inversions.inversions, :pivot_note => __chord_inversions.pivot_note } end end |
#named_chord ⇒ Object
Returns A string containing the named chord.
45 46 47 |
# File 'lib/stretto/grammar/tokens/chord_token.rb', line 45 def named_chord __named_chord.text_value end |
#note_string ⇒ NoteStringToken
39 40 41 |
# File 'lib/stretto/grammar/tokens/chord_token.rb', line 39 def note_string __note_string end |
#notes ⇒ Object
Don’t precalculate values. Added for harmonic chords to be able to be constructed from a chord token.
61 62 63 |
# File 'lib/stretto/grammar/tokens/chord_token.rb', line 61 def notes nil end |
#to_stretto(pattern = nil) ⇒ MusicElements::Chord
Returns The constructed Chord element.
19 20 21 |
# File 'lib/stretto/grammar/tokens/chord_token.rb', line 19 def to_stretto(pattern = nil) Stretto::MusicElements::Chord.new(self, pattern) end |