Class: Musa::Transcriptors::FromGDV::ToMIDI::Turn

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

Overview

Process: .turn

Instance Method Summary collapse

Methods inherited from Musa::Transcription::FeatureTranscriptor

#check

Instance Method Details

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



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/musa-dsl/transcription/from-gdv-to-midi.rb', line 79

def transcript(gdv, base_duration:, tick_duration:)
  turn = gdv.delete :turn

  if turn
    start = :up

    check(turn) do |turn|
      case turn
      when :true, :up
        start = :up
      when :down, :low
        start = :down
      end
    end

    duration = gdv[:duration] / 4r

    gdvs = []

    case start
    when :up
      gdvs << gdv.clone.tap { |gdv| gdv[:grade] += 1; gdv[:duration] = duration }
      gdvs << gdv.clone.tap { |gdv| gdv[:grade] += 0; gdv[:duration] = duration }
      gdvs << gdv.clone.tap { |gdv| gdv[:grade] += -1; gdv[:duration] = duration }
      gdvs << gdv.clone.tap { |gdv| gdv[:grade] += 0; gdv[:duration] = duration }
    when :down
      gdvs << gdv.clone.tap { |gdv| gdv[:grade] += -1; gdv[:duration] = duration }
      gdvs << gdv.clone.tap { |gdv| gdv[:grade] += 0; gdv[:duration] = duration }
      gdvs << gdv.clone.tap { |gdv| gdv[:grade] += 1; gdv[:duration] = duration }
      gdvs << gdv.clone.tap { |gdv| gdv[:grade] += 0; gdv[:duration] = duration }
    end

    super gdvs, base_duration: base_duration, tick_duration: tick_duration
  else
    super
  end
end