Module: Musa::Neumalang::Neumalang::Parser::NeumaAsAttributes Private

Defined in:
lib/musa-dsl/neumalang/neumalang.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Semantic action for neuma notation (core musical event).

Transforms neuma notation like "+2_2.tr" into GDVD structure. Combines grade, octave, duration, velocity, and modifiers.

This is the most important module - it builds the musical events that form the core of Neumalang notation.

Instance Method Summary collapse

Instance Method Details

#valueHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Builds GDVD structure from neuma attributes.

Merges:

  • Grade attributes (delta_grade, abs_grade, etc.)
  • Octave attributes (delta_octave, abs_octave)
  • Duration attributes (delta_duration, abs_duration, factor_duration)
  • Velocity attributes (delta_velocity, abs_velocity)
  • Modifiers (ornaments, articulations)

Examples:

Parse result

# "+2_2.tr" becomes:
{
  kind: :gdvd,
  gdvd: {
    delta_grade: 2,
    factor_duration: 2,
    modifiers: { tr: true }
  }.extend(Musa::Datasets::GDVd)
}

Returns:

  • (Hash)

    GDVD neuma with kind :gdvd



478
479
480
481
482
483
484
485
486
487
488
489
490
# File 'lib/musa-dsl/neumalang/neumalang.rb', line 478

def value
  h = {}.extend Musa::Datasets::GDVd

  capture(:grade)&.value&.tap { |_| h.merge! _ if _ }
  capture(:octave)&.value&.tap { |_| h.merge! _ if _ }
  capture(:duration)&.value&.tap { |_| h.merge! _ if _ }
  capture(:velocity)&.value&.tap { |_| h.merge! _ if _ }

  h[:modifiers] = {} unless captures(:modifiers).empty?
  captures(:modifiers).collect(&:value).each { |_| h[:modifiers].merge! _ if _ }

  { kind: :gdvd, gdvd: h }.extend Musa::Neumas::Neuma
end