Class: Musa::Transcriptors::FromGDV::ToMIDI::Mordent
- Inherits:
-
Musa::Transcription::FeatureTranscriptor
- Object
- Musa::Transcription::FeatureTranscriptor
- Musa::Transcriptors::FromGDV::ToMIDI::Mordent
- Defined in:
- lib/musa-dsl/transcription/from-gdv-to-midi.rb
Overview
Mordent transcriptor for MIDI playback.
Expands mordent ornaments into a three-note sequence: main note, adjacent note (upper or lower), then main note. The mordent is a quick ornament typically used to emphasize a note.
Mordent Types
.moror.mor(:up)- Upper mordent (main, upper neighbor, main).mor(:down)or.mor(:low)- Lower mordent (main, lower neighbor, main)
Processing
Given .mor on a note:
{ grade: 0, duration: 1r, mor: true }
Expands to three notes:
[
{ grade: 0, duration: 1/16r }, # Main note (short)
{ grade: 1, duration: 1/16r }, # Upper neighbor (short)
{ grade: 0, duration: 7/8r } # Main note (remaining duration)
]
Duration Calculation
Short notes duration: base_duration * duration_factor (default 1/4)
Final note gets remaining duration: original - 2 * short_duration
Process: .mor
Instance Method Summary collapse
-
#initialize(duration_factor: nil) ⇒ Mordent
constructor
Creates mordent transcriptor.
-
#transcript(gdv, base_duration:, tick_duration:) ⇒ Array<Hash>, Hash
Transcribes mordent to three-note sequence.
Constructor Details
#initialize(duration_factor: nil) ⇒ Mordent
Creates mordent transcriptor.
230 231 232 |
# File 'lib/musa-dsl/transcription/from-gdv-to-midi.rb', line 230 def initialize(duration_factor: nil) @duration_factor = duration_factor || 1/4r end |
Instance Method Details
#transcript(gdv, base_duration:, tick_duration:) ⇒ Array<Hash>, Hash
Transcribes mordent to three-note sequence.
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
# File 'lib/musa-dsl/transcription/from-gdv-to-midi.rb', line 243 def transcript(gdv, base_duration:, tick_duration:) mor = gdv.delete :mor if mor direction = :up check(mor) do |mor| case mor when true, :up direction = :up when :down, :low direction = :down end end short_duration = [base_duration * @duration_factor, tick_duration].max gdvs = [] gdvs << gdv.clone.tap { |gdv| gdv[:duration] = short_duration } case direction when :up gdvs << gdv.clone.tap { |gdv| gdv[:grade] += 1; gdv[:duration] = short_duration } when :down gdvs << gdv.clone.tap { |gdv| gdv[:grade] -= 1; gdv[:duration] = short_duration } end gdvs << gdv.clone.tap { |gdv| gdv[:duration] -= 2 * short_duration } super gdvs, base_duration: base_duration, tick_duration: tick_duration else super end end |