Class: Musa::MusicXML::Builder::Internal::Note Abstract

Inherits:
Object
  • Object
show all
Extended by:
Extension::AttributeBuilder
Includes:
Extension::With, Helper, ToXML
Defined in:
lib/musa-dsl/musicxml/builder/note.rb

Overview

This class is abstract.

Subclass and override #specific_to_xml to implement.

Abstract base class for all note types.

Note is the foundation for pitched notes, rests, and unpitched percussion notes. It provides comprehensive support for musical notation including:

Core Note Properties

  • Duration and Type: Timing (duration in divisions, type: whole/half/quarter/etc.)
  • Voice and Staff: Multi-voice and multi-staff support
  • Dots: Dotted and double-dotted notes
  • Grace Notes: Ornamental notes without duration
  • Cue Notes: Smaller notes for reference
  • Chords: Notes that sound simultaneously

Notations

The <notations> element groups musical symbols attached to notes:

Basic Notations

  • Ties/Tied: Visual ties connecting notes (tie) vs sustained sound (tied)
  • Slurs: Phrase markings
  • Tuplets: Irregular rhythmic groupings (triplets, quintuplets, etc.)
  • Dynamics: Volume markings (pp, p, mp, mf, f, ff, etc.)
  • Fermata: Pause/hold symbols
  • Accidental Marks: Sharp, flat, natural annotations
  • Arpeggiate: Rolled chord indication
  • Glissando/Slide: Pitch glide

Articulations

Attack and release characteristics:

  • accent: Emphasis (>)
  • staccato: Short, detached (•)
  • tenuto: Full value (−)
  • staccatissimo: Very short (▼)
  • spiccato: Bouncing bow
  • strong_accent: Forceful (^)
  • detached_legato: Portato
  • breath_mark: Breath pause
  • caesura: Railroad tracks (caesura)
  • Plus: doit, falloff, plop, scoop, stress, unstress

Ornaments

Melodic decorations:

  • trill_mark: Rapid alternation with upper neighbor
  • mordent: Single alternation with lower neighbor
  • inverted_mordent: Single alternation with upper neighbor
  • turn: Four-note figure around main note
  • inverted_turn: Inverted turn figure
  • delayed_turn: Turn after main note
  • shake: Extended trill
  • tremolo: Rapid repetition (single) or alternation (start/stop)
  • schleifer: Slide ornament
  • wavy_line: Trill extension

Technical Markings

Performance technique indicators:

String Instruments:

  • fingering: Finger numbers
  • up_bow/down_bow: Bowing direction (↑/↓)
  • harmonic: Natural or artificial harmonics
  • open_string: Open string indication (○)
  • stopped: Stopped note (+)
  • snap_pizzicato: Bartók pizzicato
  • thumb_position: Cello thumb position
  • string: String number
  • hammer_on/pull_off: Legato technique

Wind Instruments:

  • double_tongue/triple_tongue: Tonguing technique
  • fingernails: Use fingernails
  • hole: Woodwind fingering holes

Guitar/Fretted:

  • fret: Fret number
  • bend: String bend
  • tap: Tapping technique
  • pluck: Plucking style

Other:

  • arrow: Directional arrow
  • handbell: Handbell technique (damp, echo, gyro, etc.)
  • heel/toe: Organ pedal technique

Hierarchy

Note is an abstract base class with three concrete subclasses:

  • PitchedNote: Notes with specific pitch (step, octave, alteration)
  • Rest: Silences with duration
  • UnpitchedNote: Percussion notes without specific pitch

Usage

Note is not used directly—use PitchedNote, Rest, or UnpitchedNote. Notes are typically added via Measure convenience methods:

Direct Known Subclasses

PitchedNote, Rest, UnpitchedNote

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.attr_complex_adder_to_array(name, klass, plural: nil, variable: nil) ⇒ Object Originally defined in module Extension::AttributeBuilder

Creates methods for adding complex objects (with multiple parameters) to an array.

Supports both positional and keyword arguments when creating instances.

Parameters:

  • name (Symbol)

    singular name.

  • klass (Class)

    class to instantiate.

  • plural (Symbol, nil) (defaults to: nil)

    plural name.

  • variable (Symbol, nil) (defaults to: nil)

    instance variable name.

.attr_complex_adder_to_custom(name, plural: nil, variable: nil) { ... } ⇒ Object Originally defined in module Extension::AttributeBuilder

Creates methods for adding complex objects with custom construction logic.

The block receives parameters and should construct and add the object.

Parameters:

  • name (Symbol)

    singular name.

  • plural (Symbol, nil) (defaults to: nil)

    plural name.

  • variable (Symbol, nil) (defaults to: nil)

    instance variable name.

Yields:

  • Constructor block executed in instance context.

.attr_complex_builder(name, klass, variable: nil, first_parameter: nil) ⇒ Object Originally defined in module Extension::AttributeBuilder

Creates a getter/setter DSL method for complex objects with multiple parameters.

Supports optional first_parameter that's automatically prepended when constructing.

Parameters:

  • name (Symbol)

    attribute name.

  • klass (Class)

    class to instantiate.

  • variable (Symbol, nil) (defaults to: nil)

    instance variable name.

  • first_parameter (Object, nil) (defaults to: nil)

    parameter automatically prepended to constructor.

.attr_simple_builder(name, klass = nil, variable: nil) ⇒ Object Originally defined in module Extension::AttributeBuilder

Creates a simple getter/setter DSL method for a single value.

Parameters:

  • name (Symbol)

    attribute name.

  • klass (Class, nil) (defaults to: nil)

    class to instantiate (nil = use value as-is).

  • variable (Symbol, nil) (defaults to: nil)

    instance variable name.

.attr_tuple_adder_to_array(name, klass, plural: nil, variable: nil) ⇒ Object Originally defined in module Extension::AttributeBuilder

Creates methods for adding id/value tuples to an array collection.

Similar to attr_tuple_adder_to_hash but stores items in an array instead of hash. Useful when order matters or duplicates are allowed.

Parameters:

  • name (Symbol)

    singular name for the item.

  • klass (Class)

    class to instantiate.

  • plural (Symbol, nil) (defaults to: nil)

    plural name.

  • variable (Symbol, nil) (defaults to: nil)

    instance variable name.

.attr_tuple_adder_to_hash(name, klass, plural: nil, variable: nil) ⇒ Object Originally defined in module Extension::AttributeBuilder

Creates methods for adding id/value tuples to a hash collection.

Generates:

  • add_#{name}(id, parameter) → creates instance and adds to hash
  • #{plural}(**parameters) → batch add or retrieve hash

Parameters:

  • name (Symbol)

    singular name for the item.

  • klass (Class)

    class to instantiate (receives id, parameter).

  • plural (Symbol, nil) (defaults to: nil)

    plural name (defaults to name + 's').

  • variable (Symbol, nil) (defaults to: nil)

    instance variable name (defaults to '@' + plural).

.attr_tuple_builder(name, klass, variable: nil) ⇒ Object Originally defined in module Extension::AttributeBuilder

Creates a getter/setter DSL method for a single id/value tuple.

Parameters:

  • name (Symbol)

    attribute name.

  • klass (Class)

    class to instantiate.

  • variable (Symbol, nil) (defaults to: nil)

    instance variable name.

Instance Method Details

#with(*value_parameters, keep_block_context: nil, **key_parameters, &block) ⇒ Object Originally defined in module Extension::With

Note:

The _ parameter is special: when present, it signals "keep caller's context" and receives self (the object) as its value.

Note:

Uses SmartProcBinder internally to handle parameter matching.

Executes a block with flexible context and parameter handling.

Parameters:

  • value_parameters (Array)

    positional parameters to pass to block.

  • keep_block_context (Boolean, nil) (defaults to: nil)

    explicit control of context switching:

    • true: always keep caller's context
    • false: always use object's context
    • nil: auto-detect based on _ parameter
  • key_parameters (Hash)

    keyword parameters to pass to block.

  • block (Proc)

    block to execute.

Returns:

  • (Object)

    result of block execution.