Class: MIDIDevices
Instance Method Summary collapse
- #[](name) ⇒ Object
- #each(&block) ⇒ Object
- #find(name) ⇒ Object
-
#initialize(sequencer) ⇒ MIDIDevices
constructor
A new instance of MIDIDevices.
- #sync ⇒ Object
Constructor Details
#initialize(sequencer) ⇒ MIDIDevices
Returns a new instance of MIDIDevices.
8 9 10 11 12 13 |
# File 'lib/midi-devices.rb', line 8 def initialize(sequencer) @sequencer = sequencer @low_level_devices = {} sync end |
Instance Method Details
#[](name) ⇒ Object
32 33 34 |
# File 'lib/midi-devices.rb', line 32 def [](name) @low_level_devices[name] end |
#each(&block) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/midi-devices.rb', line 41 def each(&block) if block_given? @low_level_devices.values.each(&block) else @low_level_devices.values.each end end |
#find(name) ⇒ Object
36 37 38 39 |
# File 'lib/midi-devices.rb', line 36 def find(name) full_name = @low_level_devices.keys.find { |_| _.end_with?(name) } @low_level_devices[full_name] end |
#sync ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/midi-devices.rb', line 15 def sync names = @low_level_devices.keys MIDICommunications::Output.all.each do |low_level_device| next if @low_level_devices.key?(low_level_device.name) @low_level_devices[low_level_device.name] = MIDIDevice.new(@sequencer, low_level_device) names.delete low_level_device.name end # remove disconnected devices # names.each do |name| @low_level_devices.delete name end end |