Class: Musa::Transcription::Transcriptor

Inherits:
Object
  • Object
show all
Defined in:
lib/musa-dsl/transcription/transcription.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transcriptors = nil, base_duration: nil, tick_duration: nil) ⇒ Transcriptor

Returns a new instance of Transcriptor.



6
7
8
9
10
11
# File 'lib/musa-dsl/transcription/transcription.rb', line 6

def initialize(transcriptors = nil, base_duration: nil, tick_duration: nil)
  @transcriptors = transcriptors || []

  @base_duration = base_duration || 1/4r
  @tick_duration = tick_duration || 1/96r
end

Instance Attribute Details

#transcriptorsObject (readonly)

Returns the value of attribute transcriptors.



4
5
6
# File 'lib/musa-dsl/transcription/transcription.rb', line 4

def transcriptors
  @transcriptors
end

Instance Method Details

#transcript(element) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/musa-dsl/transcription/transcription.rb', line 13

def transcript(element)
  @transcriptors.each do |transcriptor|
    if element
      if element.is_a?(Array)
        element = element.collect { |element_i| transcriptor.transcript(element_i, base_duration: @base_duration, tick_duration: @tick_duration) }.flatten(1)
      else
        element = transcriptor.transcript(element, base_duration: @base_duration, tick_duration: @tick_duration)
      end
    end
  end

  element
end