Module: MicroMIDI::Device

Extended by:
Device
Included in:
Device
Defined in:
lib/micromidi/device.rb

Overview

Deal with MIDI devices

Instance Method Summary collapse

Instance Method Details

#get_inputs(*args) ⇒ Array<UniMIDI::Input>

Select the MIDI inputs from the given objects

Returns:

  • (Array<UniMIDI::Input>)

25
26
27
# File 'lib/micromidi/device.rb', line 25

def get_inputs(*args)
  [args].flatten.select { |device| input?(device) }
end

#get_outputs(*args) ⇒ Array<UniMIDI::Output, IO>

Select the MIDI outputs from the given objects

Returns:

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

32
33
34
# File 'lib/micromidi/device.rb', line 32

def get_outputs(*args)
  [args].flatten.select { |device| output?(device) }
end

#input?(device) ⇒ Boolean

Is the given device a MIDI input?

Parameters:

  • device (Object)

Returns:

  • (Boolean)

11
12
13
# File 'lib/micromidi/device.rb', line 11

def input?(device)
  device.respond_to?(:type) && device.type == :input && device.respond_to?(:gets)
end

#output?(device) ⇒ Boolean

Is the given device a MIDI output?

Parameters:

  • device (Object)

Returns:

  • (Boolean)

18
19
20
# File 'lib/micromidi/device.rb', line 18

def output?(device)
  device.respond_to?(:puts)
end