Class: Diamond::Clock
- Inherits:
-
Object
- Object
- Diamond::Clock
- Extended by:
- Forwardable
- Defined in:
- lib/diamond/clock.rb
Overview
A wrapper for Topaz::Tempo that’s geared towards the arpeggiator
Instance Method Summary collapse
-
#add(arpeggiator) ⇒ Array<Arpeggiator>
(also: #<<)
Add arpeggiator(s) to this clock’s control.
-
#initialize(tempo_or_input, options = {}) ⇒ Clock
constructor
A new instance of Clock.
-
#midi_outputs ⇒ Array<UniMIDI::Output>
Shortcut to the clock’s MIDI output devices.
-
#remove(arpeggiator) ⇒ Array<Arpeggiator>
Remove arpeggiator(s) 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(tempo_or_input, options = {}) ⇒ Clock
Returns a new instance of Clock.
13 14 15 16 17 18 |
# File 'lib/diamond/clock.rb', line 13 def initialize(tempo_or_input, = {}) @arpeggiators = [] output = [:output] || [:outputs] || [:midi] initialize_clock(tempo_or_input, :output => output) initialize_events end |
Instance Method Details
#add(arpeggiator) ⇒ Array<Arpeggiator> Also known as: <<
Add arpeggiator(s) to this clock’s control
50 51 52 53 54 |
# File 'lib/diamond/clock.rb', line 50 def add(arpeggiator) arpeggiators = [arpeggiator].flatten @arpeggiators += arpeggiators @arpeggiators end |
#midi_outputs ⇒ Array<UniMIDI::Output>
Shortcut to the clock’s MIDI output devices
22 23 24 |
# File 'lib/diamond/clock.rb', line 22 def midi_outputs @clock.midi_output.devices end |
#remove(arpeggiator) ⇒ Array<Arpeggiator>
Remove arpeggiator(s) from this clock’s control
60 61 62 63 64 |
# File 'lib/diamond/clock.rb', line 60 def remove(arpeggiator) arpeggiators = [arpeggiator].flatten @arpeggiators.delete_if { |arpeggiator| arpeggiators.include?(arpeggiator) } @arpeggiators end |
#start(options = {}) ⇒ Boolean
Start the clock
31 32 33 34 35 36 37 |
# File 'lib/diamond/clock.rb', line 31 def start( = {}) begin @clock.start() rescue SystemExit, Interrupt => exception stop end end |
#stop ⇒ Boolean
Stop the clock (and fire the arpeggiator sequencer stop event)
41 42 43 44 45 |
# File 'lib/diamond/clock.rb', line 41 def stop @arpeggiators.each { |arpeggiator| arpeggiator.sequencer.event.do_stop } @clock.stop true end |