Class: Musa::Transcriptors::FromGDV::ToMIDI::Staccato

Inherits:
Musa::Transcription::FeatureTranscriptor show all
Defined in:
lib/musa-dsl/transcription/from-gdv-to-midi.rb

Overview

Process: .st .st(1) .st(2) .st(3): staccato level 1 2 3

Instance Method Summary collapse

Methods inherited from Musa::Transcription::FeatureTranscriptor

#check

Constructor Details

#initialize(min_duration_factor: nil) ⇒ Staccato

Returns a new instance of Staccato.



197
198
199
# File 'lib/musa-dsl/transcription/from-gdv-to-midi.rb', line 197

def initialize(min_duration_factor: nil)
  @min_duration_factor = min_duration_factor || 1/8r
end

Instance Method Details

#transcript(gdv, base_duration:, tick_duration:) ⇒ Object



201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/musa-dsl/transcription/from-gdv-to-midi.rb', line 201

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