Class: Metronome::Practice
- Inherits:
-
Array
- Object
- Array
- Metronome::Practice
- Includes:
- Stop
- Defined in:
- lib/metronome-odd.rb
Instance Method Summary collapse
- #force_tempo(tempo) ⇒ Object
-
#initialize ⇒ Practice
constructor
A new instance of Practice.
- #loop_stop? ⇒ Boolean
- #play ⇒ Object
- #print_practice ⇒ Object
- #push(b) ⇒ Object
- #sound(type) ⇒ Object
Constructor Details
#initialize ⇒ Practice
Returns a new instance of Practice.
192 193 194 |
# File 'lib/metronome-odd.rb', line 192 def initialize @next_bar_hash = Hash.new(nil) end |
Instance Method Details
#force_tempo(tempo) ⇒ Object
233 234 235 236 237 238 239 |
# File 'lib/metronome-odd.rb', line 233 def force_tempo(tempo) self.each do || unless .class == Silence .set_tempo(tempo) end end end |
#loop_stop? ⇒ Boolean
228 229 230 231 |
# File 'lib/metronome-odd.rb', line 228 def loop_stop? sound(:loop) @@stop end |
#play ⇒ Object
224 225 226 |
# File 'lib/metronome-odd.rb', line 224 def play sound(:play) end |
#print_practice ⇒ Object
249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/metronome-odd.rb', line 249 def print_practice = 0 # 0 accounts for the intial silence self.each do |b| unless b.class == Silence print "\n#{}:\t" b.print_sign end += 1 end puts end |
#push(b) ⇒ Object
241 242 243 244 245 246 247 |
# 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) ⇒ Object
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/metronome-odd.rb', line 196 def sound(type) @@stop = false = 0 # 0 accounts for the intial silence self.each do |b| unless b.class == Silence print "\n#{}:\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 += 1 if @@stop then break end end puts end |