Class: Musa::Transcription::FeatureTranscriptor
- Defined in:
- lib/musa-dsl/transcription/transcription.rb
Overview
Base class for feature transcriptors.
Provides common functionality for processing specific musical features
in GDV events. Subclasses implement transcript method to handle
their specific feature (ornament, articulation, etc.).
Contract
Transcriptor implementations should:
- Extract their specific feature from GDV hash
- Process/transform the event based on that feature
- Return modified event(s) or call
superif feature not present - Use
deleteto remove processed feature attributes
Helper Methods
check(value, &block): Safely iterate over value or array
Direct Known Subclasses
Musa::Transcriptors::FromGDV::Base, Musa::Transcriptors::FromGDV::ToMIDI::Appogiatura, Musa::Transcriptors::FromGDV::ToMIDI::Mordent, Musa::Transcriptors::FromGDV::ToMIDI::Staccato, Musa::Transcriptors::FromGDV::ToMIDI::Trill, Musa::Transcriptors::FromGDV::ToMIDI::Turn, Musa::Transcriptors::FromGDV::ToMusicXML::Appogiatura
Instance Method Summary collapse
-
#check(value_or_array) {|value| ... } ⇒ Object
Helper to safely process value or array.
-
#transcript(element, base_duration:, tick_duration:) ⇒ Hash+
Transcribes GDV event for this feature.
Instance Method Details
#check(value_or_array) {|value| ... } ⇒ Object
Helper to safely process value or array.
Yields each element if array, or yields single value. Useful for processing feature values that may be single or multiple.
298 299 300 301 302 303 304 305 306 |
# File 'lib/musa-dsl/transcription/transcription.rb', line 298 def check(value_or_array, &block) if block_given? if value_or_array.is_a?(Array) value_or_array.each(&block) else yield value_or_array end end end |
#transcript(element, base_duration:, tick_duration:) ⇒ Hash+
Transcribes GDV event for this feature.
Base implementation cleans up empty :modifiers attribute. Subclasses
should override to process their specific feature, then call super.
270 271 272 273 274 275 276 277 278 279 |
# File 'lib/musa-dsl/transcription/transcription.rb', line 270 def transcript(element, base_duration:, tick_duration:) case element when Hash element.delete :modifiers if element[:modifiers]&.empty? when Array element.each { |_| _.delete :modifiers if _[:modifiers]&.empty? } end element end |