class Metronome::Practice

Public Class Methods

new() click to toggle source
# File lib/metronome-odd.rb, line 192
def initialize
  @next_bar_hash = Hash.new(nil)
end

Public Instance Methods

force_tempo(tempo) click to toggle source
# File lib/metronome-odd.rb, line 233
def force_tempo(tempo)
  self.each do |bar|
    unless bar.class == Silence
      bar.set_tempo(tempo)
    end
  end
end
loop_stop?() click to toggle source
# File lib/metronome-odd.rb, line 228
def loop_stop?
  sound(:loop)
  @@stop
end
play() click to toggle source
# File lib/metronome-odd.rb, line 224
def play
  sound(:play)
end
print_practice() click to toggle source
push(b) click to toggle source
Calls superclass method
# File lib/metronome-odd.rb, line 241
def push(b)
  super(b)
  if @prev_bar
    @next_bar_hash[@prev_bar] = b
  end
  @prev_bar = b
end
sound(type) click to toggle source
# File lib/metronome-odd.rb, line 196
def sound(type)
  @@stop = false
  bar_counter = 0 # 0 accounts for the intial silence

  self.each do |b| 
    unless b.class == Silence
      print "\n#{bar_counter}:\t"
      b.print_sign
      if @next_bar_hash[b]
        print " -> "
        @next_bar_hash[b].print_sign
        print "\t"
      else
        case type
        when :play
          print " - last bar! "
        when :loop
          print " - repeat! "
        end
      end
    end
    b.play
    bar_counter += 1
    if @@stop then break end
  end
  puts
end