Class: MIDIInstrument::Input
- Inherits:
-
Object
- Object
- MIDIInstrument::Input
- Extended by:
- Forwardable
- Defined in:
- lib/midi-instrument/input.rb
Overview
Enable a node to listen for MIDI messages on a MIDI input
Defined Under Namespace
Classes: InputContainer
Instance Attribute Summary collapse
-
#channel ⇒ Object
Returns the value of attribute channel.
-
#devices ⇒ Object
Returns the value of attribute devices.
Instance Method Summary collapse
-
#add(*messages) ⇒ Array<MIDIMessage>
(also: #<<)
Manually add messages to the input.
-
#initialize(options = {}) ⇒ Input
constructor
A new instance of Input.
-
#omni ⇒ Boolean
(also: #omni_on)
Set the listener to acknowledge notes on all channels.
-
#receive(match = {}, &block) ⇒ Listen
Add a MIDI input callback.
Constructor Details
#initialize(options = {}) ⇒ Input
Returns a new instance of Input.
14 15 16 17 18 |
# File 'lib/midi-instrument/input.rb', line 14 def initialize( = {}) @listener = Listener.new([:sources]) @devices = InputContainer.new(@listener) @channel = nil end |
Instance Attribute Details
#channel ⇒ Object
Returns the value of attribute channel.
8 9 10 |
# File 'lib/midi-instrument/input.rb', line 8 def channel @channel end |
#devices ⇒ Object
Returns the value of attribute devices.
8 9 10 |
# File 'lib/midi-instrument/input.rb', line 8 def devices @devices end |
Instance Method Details
#add(*messages) ⇒ Array<MIDIMessage> Also known as: <<
Manually add messages to the input
34 35 36 37 38 |
# File 'lib/midi-instrument/input.rb', line 34 def add(*) = Message.([].flatten).compact @listener.add(*) unless .empty? end |
#omni ⇒ Boolean Also known as: omni_on
Set the listener to acknowledge notes on all channels
43 44 45 46 |
# File 'lib/midi-instrument/input.rb', line 43 def omni @channel = nil true end |
#receive(match = {}, &block) ⇒ Listen
Add a MIDI input callback
24 25 26 27 28 29 |
# File 'lib/midi-instrument/input.rb', line 24 def receive(match = {}, &block) if block_given? @listener.receive(match) { |event| yield(event) } end self end |