Class: Diamond::Clock
- Inherits:
-
Object
- Object
- Diamond::Clock
- Extended by:
- Forwardable
- Defined in:
- lib/diamond/clock.rb
Overview
A wrapper for Sequencer::Clock (and thus Topaz::Tempo) that’s geared towards the arpeggiator
Instance Method Summary collapse
-
#add(arpeggiator) ⇒ Boolean
(also: #<<)
Add an arpeggiator to this clock’s control.
-
#initialize(*args) ⇒ Clock
constructor
A new instance of Clock.
-
#remove(arpeggiator) ⇒ Boolean
Remove an arpeggiator from this clock’s control.
-
#start(options = {}) ⇒ Boolean
Start the clock.
-
#stop ⇒ Boolean
Stop the clock (and fire the arpeggiator sequencer stop event).
Constructor Details
#initialize(*args) ⇒ Clock
Returns a new instance of Clock.
13 14 15 16 |
# File 'lib/diamond/clock.rb', line 13 def initialize(*args) @arpeggiators = [] @clock = Sequencer::Clock.new(*args) end |
Instance Method Details
#add(arpeggiator) ⇒ Boolean Also known as: <<
Add an arpeggiator to this clock’s control
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/diamond/clock.rb', line 42 def add(arpeggiator) arpeggiators = [arpeggiator].flatten result = arpeggiators.map do |arpeggiator| unless @arpeggiators.include?(arpeggiator) @arpeggiators << arpeggiator reset_tick true else false end end result.any? end |
#remove(arpeggiator) ⇒ Boolean
Remove an arpeggiator from this clock’s control
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/diamond/clock.rb', line 60 def remove(arpeggiator) arpeggiators = [arpeggiator].flatten result = arpeggiators.map do |arpeggiator| if @arpeggiators.include?(arpeggiator) @arpeggiators.delete(arpeggiator) reset_tick true else false end end result.any? end |
#start(options = {}) ⇒ Boolean
Start the clock
23 24 25 26 27 28 29 |
# File 'lib/diamond/clock.rb', line 23 def start( = {}) begin @clock.start() rescue SystemExit, Interrupt => exception stop end end |
#stop ⇒ Boolean
Stop the clock (and fire the arpeggiator sequencer stop event)
33 34 35 36 37 |
# File 'lib/diamond/clock.rb', line 33 def stop @arpeggiators.each { |arpeggiator| arpeggiator.sequencer.event.do_stop } @clock.stop true end |