Class: Lydown::Rendering::VoiceSelect

Inherits:
Base
  • Object
show all
Defined in:
lib/lydown/rendering/voices.rb

Constant Summary collapse

VOICE_COMMANDS =
{
  'voice1' => '\voiceOne',
  'voice2' => '\voiceTwo',
  'voice3' => '\voiceThree',
  'voice4' => '\voiceFour',
}

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#find_prev_event, #initialize, #next_event, #prev_event

Constructor Details

This class inherits a constructor from Lydown::Rendering::Base

Class Method Details

.render_voices(context) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/lydown/rendering/voices.rb', line 11

def self.render_voices(context)
  context['process/voice_selector'] = nil
  
  music = Inverso::Template.render(:multi_voice, context: context, part: context[:part])
  
  context.emit(:music, music)
  
  context['process/voices'].each_value do |stream|
    if stream['lyrics']
      stream['lyrics'].each do |voice, lyrics_stream|
        lyrics_stream.each do |idx, content|
          context.emit("lyrics/#{voice}/#{idx}", content)
        end
      end
    end
  end
  
  context['process/voices'] = nil
end

.voice_command(voice) ⇒ Object



38
39
40
# File 'lib/lydown/rendering/voices.rb', line 38

def self.voice_command(voice)
  VOICE_COMMANDS[voice]
end

Instance Method Details

#translateObject



3
4
5
6
7
8
9
# File 'lib/lydown/rendering/voices.rb', line 3

def translate
  if @event[:voice]
    @context['process/voice_selector'] = "voice#{@event[:voice]}"
  else
    self.class.render_voices(@context)
  end
end