Class: Topaz::MIDIClockOutput

Inherits:
Object
  • Object
show all
Defined in:
lib/topaz/midi_clock_output.rb

Overview

Send clock messages via MIDI

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ MIDIClockOutput

Returns a new instance of MIDIClockOutput.

Parameters:

  • options (Hash)

Options Hash (options):

  • :device (Array<UniMIDI::Output>, UniMIDI::Output)


10
11
12
13
# File 'lib/topaz/midi_clock_output.rb', line 10

def initialize(options)
  device = options[:device] || options[:devices]
  @devices = [device].flatten.compact
end

Instance Attribute Details

#devicesObject (readonly)

Returns the value of attribute devices.



6
7
8
# File 'lib/topaz/midi_clock_output.rb', line 6

def devices
  @devices
end

Instance Method Details

#do_clock(*a) ⇒ Boolean

Send a clock tick message

Returns:

  • (Boolean)

    Whether a message was emitted



33
34
35
36
37
# File 'lib/topaz/midi_clock_output.rb', line 33

def do_clock(*a)
  clock = MIDIMessage::SystemRealtime["Clock"].new
  emit(clock)
  !@devices.empty?
end

#do_start(*a) ⇒ Boolean

Send a start message

Returns:

  • (Boolean)

    Whether a message was emitted



17
18
19
20
21
# File 'lib/topaz/midi_clock_output.rb', line 17

def do_start(*a)
  start = MIDIMessage::SystemRealtime["Start"].new
  emit(start)
  !@devices.empty?
end

#do_stop(*a) ⇒ Boolean

Send a stop message

Returns:

  • (Boolean)

    Whether a message was emitted



25
26
27
28
29
# File 'lib/topaz/midi_clock_output.rb', line 25

def do_stop(*a)
  stop = MIDIMessage::SystemRealtime["Stop"].new
  emit(stop)
  !@devices.empty?
end