Class: Musa::Transcriptors::FromGDV::ToMIDI::Staccato
- Inherits:
-
Musa::Transcription::FeatureTranscriptor
- Object
- Musa::Transcription::FeatureTranscriptor
- Musa::Transcriptors::FromGDV::ToMIDI::Staccato
- Defined in:
- lib/musa-dsl/transcription/from-gdv-to-midi.rb
Overview
Staccato transcriptor for MIDI playback.
Applies staccato articulation by shortening note duration. Instead of
creating multiple notes, staccato modifies the :note_duration attribute
to create a gap between note-off and the next note-on.
Staccato Levels
.stor.st(true)- Half duration (1/2).st(1)- Half duration (1/2).st(2)- Quarter duration (1/4).st(3)- Eighth duration (1/8).st(n)- Duration divided by 2^n
Processing
Staccato sets :note_duration attribute (actual sounding duration)
while preserving :duration (rhythmic position duration). The gap
between these creates the staccato articulation.
Given .st on a note:
{ grade: 0, duration: 1r, st: true }
Results in:
{ grade: 0, duration: 1r, note_duration: 1/2r }
duration: 1r- Next note starts after 1 beatnote_duration: 1/2r- Note sounds for 1/2 beat (staccato gap)
Minimum Duration
A minimum duration (base_duration * min_duration_factor, default 1/8)
prevents extremely short notes that might sound like clicks.
Process: .st .st(1) .st(2) .st(3): staccato level 1 2 3
Instance Method Summary collapse
-
#initialize(min_duration_factor: nil) ⇒ Staccato
constructor
Creates staccato transcriptor.
-
#transcript(gdv, base_duration:, tick_duration:) ⇒ Hash
Transcribes staccato by setting note_duration.
Constructor Details
#initialize(min_duration_factor: nil) ⇒ Staccato
Creates staccato transcriptor.
591 592 593 |
# File 'lib/musa-dsl/transcription/from-gdv-to-midi.rb', line 591 def initialize(min_duration_factor: nil) @min_duration_factor = min_duration_factor || 1/8r end |
Instance Method Details
#transcript(gdv, base_duration:, tick_duration:) ⇒ Hash
Transcribes staccato by setting note_duration.
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 |
# File 'lib/musa-dsl/transcription/from-gdv-to-midi.rb', line 604 def transcript(gdv, base_duration:, tick_duration:) st = gdv.delete :st if st calculated = 0 check(st) do |st| case st when true calculated = gdv[:duration] / 2r when Numeric calculated = gdv[:duration] / 2**st if st >= 1 end end gdv[:note_duration] = [calculated, base_duration * @min_duration_factor].max end super end |