Class: Musa::Neumas::Decoders::NeumaDecoder
- Inherits:
-
Decoder
- Object
- ProtoDecoder
- DifferentialDecoder
- Decoder
- Musa::Neumas::Decoders::NeumaDecoder
- Defined in:
- lib/musa-dsl/neumas/neuma-gdv-decoder.rb
Overview
to get a GDV
Instance Attribute Summary collapse
-
#base_duration ⇒ Object
Returns the value of attribute base_duration.
-
#scale ⇒ Object
Returns the value of attribute scale.
Attributes inherited from Decoder
Instance Method Summary collapse
- #apply(gdvd, on:) ⇒ Object
-
#initialize(scale, base_duration: nil, transcriptor: nil, base: nil) ⇒ NeumaDecoder
constructor
A new instance of NeumaDecoder.
- #inspect ⇒ Object (also: #to_s)
- #process(gdvd) ⇒ Object
- #subcontext ⇒ Object
Methods inherited from Decoder
Methods inherited from DifferentialDecoder
Methods inherited from ProtoDecoder
Constructor Details
#initialize(scale, base_duration: nil, transcriptor: nil, base: nil) ⇒ NeumaDecoder
Returns a new instance of NeumaDecoder.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/musa-dsl/neumas/neuma-gdv-decoder.rb', line 6 def initialize(scale, base_duration: nil, transcriptor: nil, base: nil) @base_duration = base_duration @base_duration ||= base[:duration] if base @base_duration ||= Rational(1,4) base ||= { grade: 0, octave: 0, duration: @base_duration, velocity: 1 } @scale = scale super base, transcriptor: transcriptor end |
Instance Attribute Details
#base_duration ⇒ Object
Returns the value of attribute base_duration.
18 19 20 |
# File 'lib/musa-dsl/neumas/neuma-gdv-decoder.rb', line 18 def base_duration @base_duration end |
#scale ⇒ Object
Returns the value of attribute scale.
18 19 20 |
# File 'lib/musa-dsl/neumas/neuma-gdv-decoder.rb', line 18 def scale @scale end |
Instance Method Details
#apply(gdvd, on:) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/musa-dsl/neumas/neuma-gdv-decoder.rb', line 41 def apply(gdvd, on:) gdv = gdvd.to_gdv @scale, previous: on appogiatura_action = gdvd.dig(:modifiers, :appogiatura) gdv[:appogiatura] = appogiatura_action.to_gdv @scale, previous: on if appogiatura_action gdv end |
#inspect ⇒ Object Also known as: to_s
50 51 52 |
# File 'lib/musa-dsl/neumas/neuma-gdv-decoder.rb', line 50 def inspect "GDV NeumaDecoder: @last = #{@last}" end |
#process(gdvd) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/musa-dsl/neumas/neuma-gdv-decoder.rb', line 20 def process(gdvd) gdvd = gdvd.clone gdvd.base_duration = @base_duration appogiatura_gdvd = gdvd[:modifiers]&.delete :appogiatura if appogiatura_gdvd appogiatura_gdvd = appogiatura_gdvd.clone appogiatura_gdvd.base_duration = @base_duration gdvd[:modifiers][:appogiatura] = appogiatura_gdvd end gdvd end |
#subcontext ⇒ Object
37 38 39 |
# File 'lib/musa-dsl/neumas/neuma-gdv-decoder.rb', line 37 def subcontext NeumaDecoder.new @scale, base_duration: @base_duration, transcriptor: @transcriptor, base: @last end |