Class: MIDICommunicationsWindows::Output
- Inherits:
-
Object
- Object
- MIDICommunicationsWindows::Output
- Extended by:
- Device::ClassMethods
- Includes:
- Device::InstanceMethods
- Defined in:
- lib/midi-communications-windows/output.rb
Overview
A MIDI output port: somewhere to send messages.
Instance Attribute Summary collapse
- #enabled ⇒ Object (also: #enabled?) included from Device::InstanceMethods readonly
-
#id ⇒ Integer
included
from Device::InstanceMethods
readonly
The port's WinMM index within its direction; see the note on identity in Device.
-
#name ⇒ String
included
from Device::InstanceMethods
readonly
The port's name, as WinMM reports it, truncated to 31 characters.
Class Method Summary collapse
-
.all ⇒ Array<Input>, Array<Output>
extended
from Device::ClassMethods
Every port of this direction.
-
.direction ⇒ Symbol
:output. -
.first ⇒ Input, ...
extended
from Device::ClassMethods
The first port of this direction, or nil if there are none.
-
.last ⇒ Input, ...
extended
from Device::ClassMethods
The last port of this direction, or nil if there are none.
Instance Method Summary collapse
-
#close ⇒ Boolean
included
from Device::InstanceMethods
Closes the port.
-
#display_name ⇒ String
included
from Device::InstanceMethods
The name to show a person choosing a port.
- #initialize(id, name) ⇒ Object included from Device::InstanceMethods private
-
#manufacturer ⇒ nil
included
from Device::InstanceMethods
Who made the device.
-
#model ⇒ nil
included
from Device::InstanceMethods
The device model.
-
#open {|self| ... } ⇒ self
(also: #enable, #start)
included
from Device::InstanceMethods
Opens the port.
-
#puts(*args) ⇒ Boolean
(also: #write)
Sends a MIDI message, in whichever form it is given.
-
#puts_bytes(*data) ⇒ Boolean
Sends a MIDI message given as numeric bytes.
-
#puts_s(data) ⇒ Boolean
(also: #puts_bytestr, #puts_hex)
Sends a MIDI message given as a hex string.
- #to_s ⇒ String included from Device::InstanceMethods
-
#type ⇒ Symbol
included
from Device::InstanceMethods
The port's direction.
Instance Attribute Details
#enabled ⇒ Object (readonly) Also known as: enabled? Originally defined in module Device::InstanceMethods
#id ⇒ Integer (readonly) Originally defined in module Device::InstanceMethods
Returns the port's WinMM index within its direction; see the note on identity in MIDICommunicationsWindows::Device.
#name ⇒ String (readonly) Originally defined in module Device::InstanceMethods
Returns the port's name, as WinMM reports it, truncated to 31 characters. Not unique: see the note on names in MIDICommunicationsWindows::Device.
Class Method Details
.all ⇒ Array<Input>, Array<Output> Originally defined in module Device::ClassMethods
Every port of this direction.
WinMM is asked afresh on every call, so a port that appeared or went away since the last one is reflected. A port that is still there comes back as the same object as before; see MIDICommunicationsWindows::Device.enumerate.
.direction ⇒ Symbol
Returns :output.
22 23 24 |
# File 'lib/midi-communications-windows/output.rb', line 22 def self.direction :output end |
.first ⇒ Input, ... Originally defined in module Device::ClassMethods
The first port of this direction, or nil if there are none.
.last ⇒ Input, ... Originally defined in module Device::ClassMethods
The last port of this direction, or nil if there are none.
Instance Method Details
#close ⇒ Boolean Originally defined in module Device::InstanceMethods
Closes the port.
#display_name ⇒ String Originally defined in module Device::InstanceMethods
The name to show a person choosing a port.
This is the port name unchanged. On macOS the display name is built as "manufacturer model (name)", which here would render as a name wrapped in the punctuation of two absent fields.
#initialize(id, name) ⇒ 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.
#manufacturer ⇒ nil Originally defined in module Device::InstanceMethods
Who made the device.
Always nil on Windows. See the note in MIDICommunicationsWindows::Device for why this is not
derived from wMid.
#model ⇒ nil Originally defined in module Device::InstanceMethods
The device model.
Always nil on Windows, for the same reason as #manufacturer.
#open {|self| ... } ⇒ self Also known as: enable, start Originally defined in module Device::InstanceMethods
Opens the port.
Opening twice is not an error and does nothing the second time, which
is what midi-communications relies on when it opens a port a caller
may already hold.
#puts(*args) ⇒ Boolean Also known as: write
Sends a MIDI message, in whichever form it is given.
37 38 39 40 41 42 43 44 45 |
# File 'lib/midi-communications-windows/output.rb', line 37 def puts(*args) case args.first when Array then args.each { |argument| puts(*argument) } when Integer then puts_bytes(*args) when String then puts_s(*args) end true end |
#puts_bytes(*data) ⇒ Boolean
Sends a MIDI message given as numeric bytes.
System Exclusive takes a different route through WinMM than everything else, and this is where the two part company.
67 68 69 70 71 |
# File 'lib/midi-communications-windows/output.rb', line 67 def puts_bytes(*data) Message.sysex?(data) ? send_sysex(data) : send_short(data) true end |
#puts_s(data) ⇒ Boolean Also known as: puts_bytestr, puts_hex
Sends a MIDI message given as a hex string.
53 54 55 |
# File 'lib/midi-communications-windows/output.rb', line 53 def puts_s(data) puts_bytes(*data.scan(/../).map(&:hex)) end |
#to_s ⇒ String Originally defined in module Device::InstanceMethods
#type ⇒ Symbol Originally defined in module Device::InstanceMethods
The port's direction.