Module: Musa::Transcriptors::FromGDV::ToMIDI

Defined in:
lib/musa-dsl/transcription/from-gdv-to-midi.rb

Overview

MIDI-specific GDV transcriptors for playback output.

Transcribes GDV events to MIDI playback format by expanding ornaments and articulations into explicit note sequences. Unlike MusicXML transcription, MIDI transcription generates the actual notes to be played.

MIDI vs MusicXML Approach

MIDI transcription expands ornaments for playback:

  • MIDI: Ornaments become explicit note sequences with calculated durations
  • MusicXML: Ornaments preserved as notation symbols

Supported Ornaments & Articulations

  • Appogiatura (:appogiatura): Grace note before main note
  • Mordent (.mor): Quick alternation with adjacent note
  • Turn (.turn): Four-note figure circling main note
  • Trill (.tr): Rapid alternation with upper note
  • Staccato (.st): Shortened note duration

Duration Factor

Many ornaments use a configurable duration_factor (default 1/4) to determine ornament note durations relative to base_duration:

ornament_duration = base_duration * duration_factor

Usage

transcriptor = Musa::Transcription::Transcriptor.new(
  Musa::Transcriptors::FromGDV::ToMIDI.transcription_set(duration_factor: 1/8r),
  base_duration: 1/4r,
  tick_duration: 1/96r
)
result = transcriptor.transcript(gdv_event)

Transcription Set

The transcription_set returns transcriptors applied in order:

  1. Appogiatura - Expand appogiatura grace notes
  2. Mordent - Expand mordent ornaments
  3. Turn - Expand turn ornaments
  4. Trill - Expand trill ornaments
  5. Staccato - Apply staccato articulation
  6. Base - Process base/rest markers

Examples:

MIDI trill expansion

gdv = { grade: 0, duration: 1r, tr: true }
transcriptor = Musa::Transcriptors::FromGDV::ToMIDI::Trill.new
result = transcriptor.transcript(gdv, base_duration: 1/4r, tick_duration: 1/96r)
# => [
#   { grade: 1, duration: 1/16r },  # Upper neighbor
#   { grade: 0, duration: 1/16r },  # Main note
#   { grade: 1, duration: 1/16r },  # Upper neighbor
#   ...
# ]

See Also:

Defined Under Namespace

Classes: Appogiatura, Mordent, Staccato, Trill, Turn

Class Method Summary collapse

Class Method Details

.transcription_set(duration_factor: nil) ⇒ Array<FeatureTranscriptor>

Returns standard transcription set for MIDI output.

Creates array of transcriptors for processing GDV to MIDI playback format, expanding all ornaments to explicit note sequences.

Examples:

Create MIDI transcription chain with default factor

transcriptors = Musa::Transcriptors::FromGDV::ToMIDI.transcription_set
transcriptor = Musa::Transcription::Transcriptor.new(
  transcriptors,
  base_duration: 1/4r
)

Custom duration factor for faster ornaments

transcriptors = Musa::Transcriptors::FromGDV::ToMIDI.transcription_set(
  duration_factor: 1/8r
)

Parameters:

  • duration_factor (Rational) (defaults to: nil)

    factor for ornament note durations relative to base_duration (default: 1/4)

Returns:

  • (Array<FeatureTranscriptor>)

    transcriptor chain



95
96
97
98
99
100
101
102
# File 'lib/musa-dsl/transcription/from-gdv-to-midi.rb', line 95

def self.transcription_set(duration_factor: nil)
  [ Appogiatura.new,
    Mordent.new(duration_factor: duration_factor),
    Turn.new,
    Trill.new(duration_factor: duration_factor),
    Staccato.new,
    Base.new ]
end