Module: Musa::Neumas::Neuma

Included in:
Parallel, Serie
Defined in:
lib/musa-dsl/neumas/neumas.rb

Overview

Base neuma module for serie and parallel structures.

Mixed into neuma hashes to provide structure-specific methods. Neumas are extended with either Neuma::Serie or Neuma::Parallel.

Defined Under Namespace

Modules: Parallel, Serie

Instance Method Summary collapse

Instance Method Details

#|(other) ⇒ Parallel

Creates parallel structure with another neuma.

Combines this neuma with another into parallel (polyphonic) structure. If already parallel, adds to existing parallel array.

Examples:

Create parallel from neumas

using Musa::Extension::Neumas  # refinements are per file

# The voices are parallelised as notation. The right operand has to be
# something convertible to neumas -- a String -- so an already parsed
# serie works on the left but not on the right.
harmony = "(0) (+2) (+4)" | "(-7) (-5) (-3)"

harmony[:kind]           # => :parallel
harmony[:parallel].size  # => 2

Chain multiple parallels

using Musa::Extension::Neumas

satb = "(+7) (+9)" | "(+4) (+5)" | "(0) (+2)" | "(-7) (-5)"

# Chaining adds to the existing parallel instead of nesting it.
satb[:parallel].size  # => 4

Parameters:

Returns:

  • (Parallel)

    parallel neuma structure

Raises:

  • (ArgumentError)

    if other cannot be converted



82
83
84
85
86
87
88
89
90
# File 'lib/musa-dsl/neumas/neumas.rb', line 82

def |(other)
  if is_a?(Parallel)
    clone.tap { |_| _[:parallel] << convert_to_parallel_element(other) }.extend(Parallel)
  else
    { kind: :parallel,
      parallel: [clone, convert_to_parallel_element(other)]
    }.extend(Parallel)
  end
end