Class: Lydown::Rendering::TupletDuration

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

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

.emit_tuplet_end(context) ⇒ Object



61
62
63
# File 'lib/lydown/rendering/music.rb', line 61

def self.emit_tuplet_end(context)
  context.emit(:music, '} ')
end

Instance Method Details

#translateObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/lydown/rendering/music.rb', line 65

def translate
  Notes.cleanup_duration_macro(@context)

  # close tuplet braces
  if @context['process/tuplet_mode']
    TupletDuration.emit_tuplet_end(@context)
    @context['process/tuplet_mode'] = nil
  end

  if next_event && next_event[:type] == :stand_alone_figures
    @context['process/figures_duration_value'] = "#{@event[:value]}*#{@event[:fraction]}"
  else
    value = LILYPOND_DURATIONS[@event[:value]] || @event[:value]

    @context['process/duration_values'] = [value]
    @context['process/last_value'] = nil
    @context['process/tuplet_mode'] = true
    
    group_value = value.to_i / @event[:group_length].to_i
    @context.emit(:music, "\\tuplet #{@event[:fraction]} #{group_value} { ")
  end
end