Class: Topaz::InternalTempo

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of InternalTempo.



5
6
7
8
9
10
11
12
# File 'lib/topaz/internal_tempo.rb', line 5

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

Instance Method Details

#intervalObject



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

def interval
  @interval * 4
end

#interval=(val) ⇒ Object

change the timer’s click interval



23
24
25
# File 'lib/topaz/internal_tempo.rb', line 23

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

#joinObject



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

def join
  super()
  self
end

#start(options = {}) ⇒ Object

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



16
17
18
19
20
# File 'lib/topaz/internal_tempo.rb', line 16

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

#stop(*a) ⇒ Object

stop the timer



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

def stop(*a)
  super()
  self
end