Module: Rtmidi::Api

Defined in:
lib/rtmidi/api.rb

Constant Summary collapse

VALUES =
{
  unspecified: 0,
  macosx_core: 1,
  linux_alsa: 2,
  unix_jack: 3,
  windows_mm: 4,
  rtmidi_dummy: 5,
  web_midi_api: 6,
  windows_uwp: 7,
  android_amidi: 8,
  num_apis: 9
}.freeze
NUMBERS =
VALUES.invert.freeze

Class Method Summary collapse

Class Method Details

.normalize(api) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/rtmidi/api.rb', line 21

def normalize(api)
  case api
  when Symbol
    symbol_for(api)
  when Integer
    symbol_for(api)
  else
    nil
  end || raise(ArgumentError, "unknown API: #{api.inspect}")
end

.symbol_for(api) ⇒ Object



32
33
34
35
36
37
# File 'lib/rtmidi/api.rb', line 32

def symbol_for(api)
  return api if api.is_a?(Symbol) && VALUES.key?(api)
  return NUMBERS[api] if api.is_a?(Integer)

  nil
end