Class: Lydown::Rendering::Lyrics

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

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

Instance Method Details

#lilypond_lyrics(lyrics) ⇒ Object



12
13
14
15
16
# File 'lib/lydown/rendering/lyrics.rb', line 12

def lilypond_lyrics(lyrics)
  lyrics.
    gsub(/_+/)  {|m| " __ #{'_ ' * (m.size - 1)}"}.
    gsub(/(\\\-)?(\-+)/) {|m| "#{$1 && "-"} -- #{'_ ' * ($2.size - 1)}"}
end

#translateObject



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

def translate
  value = lilypond_lyrics(@event[:content])
  
  lyrics_idx = @event[:stream_index] || 1
  voice = @context['process/voice_selector'] || 'voice1'
  
  @context.emit("lyrics/#{voice}/#{lyrics_idx}", value, ' ')
end