Class: Topaz::InternalTempo

Inherits:
Gamelan::Timer
  • Object
show all
Includes:
TempoSource
Defined in:
lib/topaz/internal_tempo.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from TempoSource

#do_midi_clock, #do_tick, #stop?

Constructor Details

#initialize(actions, tempo, options = {}) ⇒ InternalTempo

Returns a new instance of InternalTempo.



10
11
12
13
14
15
16
# File 'lib/topaz/internal_tempo.rb', line 10

def initialize(actions, tempo, options = {})
  @actions = actions
  self.interval = options[:interval] || 4 
  @last = 0
  @last_sync = 0
  super({:tempo => tempo})
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



8
9
10
# File 'lib/topaz/internal_tempo.rb', line 8

def action
  @action
end

Instance Method Details

#intervalObject



31
32
33
# File 'lib/topaz/internal_tempo.rb', line 31

def interval
  @interval * 4
end

#interval=(val) ⇒ Object

change the timer’s click interval



27
28
29
# File 'lib/topaz/internal_tempo.rb', line 27

def interval=(val)
  @interval = val / 4
end

#joinObject



41
42
43
44
# File 'lib/topaz/internal_tempo.rb', line 41

def join
  super()
  self
end

#start(options = {}) ⇒ Object

start the internal timer pass :background => true to keep the timer in a background thread



20
21
22
23
24
# File 'lib/topaz/internal_tempo.rb', line 20

def start(options = {})
  run
  join unless options[:background]
  self
end

#stop(*a) ⇒ Object

stop the timer



36
37
38
39
# File 'lib/topaz/internal_tempo.rb', line 36

def stop(*a)
  super()
  self
end