Class: MIDICommunications::Input
- Inherits:
-
Object
- Object
- MIDICommunications::Input
- Extended by:
- Device::ClassMethods
- Includes:
- Device::InstanceMethods, StreamReader
- Defined in:
- lib/midi-communications/input.rb,
lib/midi-communications/input/stream_reader.rb
Overview
A MIDI input device for receiving MIDI messages.
Input devices receive MIDI data from external controllers, instruments, or other MIDI sources. Use the class methods to discover and select available input devices.
Defined Under Namespace
Modules: StreamReader
Instance Attribute Summary collapse
-
#direction ⇒ Symbol
included
from Device::InstanceMethods
readonly
The device direction (:input or :output).
-
#display_name ⇒ String
included
from Device::InstanceMethods
readonly
The device display name.
-
#enabled ⇒ Boolean
included
from Device::InstanceMethods
readonly
Whether the device is currently open.
-
#id ⇒ Integer
included
from Device::InstanceMethods
readonly
The device ID.
-
#manufacturer ⇒ String
included
from Device::InstanceMethods
readonly
The device manufacturer name.
-
#model ⇒ String
included
from Device::InstanceMethods
readonly
The device model name.
-
#name ⇒ String
included
from Device::InstanceMethods
readonly
The device name.
Class Method Summary collapse
-
.all ⇒ Array<Input>
Returns all available MIDI input devices.
-
.at(index) ⇒ Input, Output
(also: #[])
extended
from Device::ClassMethods
Returns the device at the given index without opening it.
-
.each {|device| ... } ⇒ Enumerator
extended
from Device::ClassMethods
Iterates over all devices of this type.
-
.find_by_name(name) ⇒ Input, ...
extended
from Device::ClassMethods
Finds a device by its name.
-
.first {|device| ... } ⇒ Input, Output
extended
from Device::ClassMethods
Selects and opens the first available device.
-
.gets {|device| ... } ⇒ Input, Output
extended
from Device::ClassMethods
Interactive console prompt for device selection.
-
.last {|device| ... } ⇒ Input, Output
extended
from Device::ClassMethods
Selects and opens the last available device.
-
.list ⇒ Array<String>
extended
from Device::ClassMethods
Prints the ID and name of each device to the console.
-
.use(index) {|device| ... } ⇒ Input, Output
(also: #open)
extended
from Device::ClassMethods
Selects and opens the device at the given index.
Instance Method Summary collapse
-
#close(*args) ⇒ Boolean
included
from Device::InstanceMethods
Closes the device.
-
#closed? ⇒ Boolean
included
from Device::InstanceMethods
Returns true if the device is closed (not enabled).
-
#enabled? ⇒ Boolean
included
from Device::InstanceMethods
Alias for Device::InstanceMethods#enabled.
-
#gets(*args) ⇒ Array<Hash>
included
from StreamReader
Reads MIDI messages from the input buffer.
-
#gets_data(*args) ⇒ Array<Integer>
included
from StreamReader
Reads MIDI data as a flat array of bytes.
-
#gets_data_s(*args) ⇒ String
(also: #gets_data_bytestr, #gets_data_hex)
included
from StreamReader
Reads MIDI data as a concatenated hex string.
-
#gets_s(*args) ⇒ Array<Hash>
(also: #gets_bytestr, #gets_hex)
included
from StreamReader
Reads MIDI messages as hex strings.
-
#initialize(device) ⇒ Object
included
from Device::InstanceMethods
private
Creates a new device wrapper.
-
#open(*args) {|device| ... } ⇒ Input, Output
included
from Device::InstanceMethods
Opens the device for use.
-
#type ⇒ Symbol
included
from Device::InstanceMethods
Alias for Device::InstanceMethods#direction.
Instance Attribute Details
#direction ⇒ Symbol (readonly) Originally defined in module Device::InstanceMethods
Returns the device direction (:input or :output).
#display_name ⇒ String (readonly) Originally defined in module Device::InstanceMethods
Returns the device display name.
#enabled ⇒ Boolean (readonly) Originally defined in module Device::InstanceMethods
Returns whether the device is currently open.
#id ⇒ Integer (readonly) Originally defined in module Device::InstanceMethods
Returns the device ID.
#manufacturer ⇒ String (readonly) Originally defined in module Device::InstanceMethods
Returns the device manufacturer name.
#model ⇒ String (readonly) Originally defined in module Device::InstanceMethods
Returns the device model name.
#name ⇒ String (readonly) Originally defined in module Device::InstanceMethods
Returns the device name.
Class Method Details
.all ⇒ Array<Input>
Returns all available MIDI input devices.
41 42 43 |
# File 'lib/midi-communications/input.rb', line 41 def self.all Loader.devices(direction: :input) end |
.at(index) ⇒ Input, Output Also known as: [] Originally defined in module Device::ClassMethods
Returns the device at the given index without opening it.
.each {|device| ... } ⇒ Enumerator Originally defined in module Device::ClassMethods
Iterates over all devices of this type.
.find_by_name(name) ⇒ Input, ... Originally defined in module Device::ClassMethods
Finds a device by its name.
.first {|device| ... } ⇒ Input, Output Originally defined in module Device::ClassMethods
Selects and opens the first available device.
.gets {|device| ... } ⇒ Input, Output Originally defined in module Device::ClassMethods
Interactive console prompt for device selection.
Displays available devices and waits for user input. When a valid selection is received, the device is opened and returned.
.last {|device| ... } ⇒ Input, Output Originally defined in module Device::ClassMethods
Selects and opens the last available device.
.list ⇒ Array<String> Originally defined in module Device::ClassMethods
Prints the ID and name of each device to the console.
.use(index) {|device| ... } ⇒ Input, Output Also known as: open Originally defined in module Device::ClassMethods
Selects and opens the device at the given index.
Instance Method Details
#close(*args) ⇒ Boolean Originally defined in module Device::InstanceMethods
Closes the device.
#closed? ⇒ Boolean Originally defined in module Device::InstanceMethods
Returns true if the device is closed (not enabled).
#enabled? ⇒ Boolean Originally defined in module Device::InstanceMethods
Returns alias for #enabled.
#gets(*args) ⇒ Array<Hash> Originally defined in module StreamReader
Reads MIDI messages from the input buffer.
Returns all messages received since the last read. Each message includes the MIDI data and a timestamp.
#gets_data(*args) ⇒ Array<Integer> Originally defined in module StreamReader
Reads MIDI data as a flat array of bytes.
Returns all message data concatenated into a single array, without timestamps.
#gets_data_s(*args) ⇒ String Also known as: gets_data_bytestr, gets_data_hex Originally defined in module StreamReader
Reads MIDI data as a concatenated hex string.
Returns all message data concatenated into a single hex string, without timestamps.
#gets_s(*args) ⇒ Array<Hash> Also known as: gets_bytestr, gets_hex Originally defined in module StreamReader
Reads MIDI messages as hex strings.
Similar to #gets but returns data as hex strings instead of byte arrays.
#initialize(device) ⇒ Object Originally defined in module Device::InstanceMethods
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a new device wrapper.
#open(*args) {|device| ... } ⇒ Input, Output Originally defined in module Device::InstanceMethods
Opens the device for use.
When a block is given, the device is automatically closed when the block exits. Otherwise, the device is closed at program exit.
#type ⇒ Symbol Originally defined in module Device::InstanceMethods
Returns alias for #direction.