Class: MIDICommunicationsMacOS::Destination
- Inherits:
-
Object
- Object
- MIDICommunicationsMacOS::Destination
- Includes:
- Endpoint
- Defined in:
- lib/midi-communications-macos/destination.rb
Overview
Type of endpoint used for output
Instance Attribute Summary collapse
-
#entity ⇒ Object
readonly
Returns the value of attribute entity.
Attributes included from Endpoint
#enabled, #id, #resource_id, #type
Class Method Summary collapse
-
.all ⇒ Array<Destination>
All output endpoints.
-
.first ⇒ Destination
Shortcut to the first output endpoint available.
-
.last ⇒ Destination
Shortcut to the last output endpoint available.
Instance Method Summary collapse
-
#close ⇒ Boolean
Close this output.
-
#enable ⇒ Destination
(also: #open, #start)
Enable this device.
-
#puts(*args) ⇒ Boolean
(also: #write)
Send a MIDI message of indeterminate type.
-
#puts_bytes(*data) ⇒ Boolean
Send a MIDI message comprised of numeric bytes.
-
#puts_s(data) ⇒ Boolean
(also: #puts_bytestr, #puts_hex)
Send a MIDI message comprised of a String of hex digits.
Methods included from Endpoint
all_by_type, destinations, get_class, #initialize, #online?, sources
Instance Attribute Details
#entity ⇒ Object (readonly)
Returns the value of attribute entity.
6 7 8 |
# File 'lib/midi-communications-macos/destination.rb', line 6 def entity @entity end |
Class Method Details
.all ⇒ Array<Destination>
All output endpoints
86 87 88 |
# File 'lib/midi-communications-macos/destination.rb', line 86 def self.all Endpoint.all_by_type[:destination] end |
.first ⇒ Destination
Shortcut to the first output endpoint available
74 75 76 |
# File 'lib/midi-communications-macos/destination.rb', line 74 def self.first Endpoint.first(:destination) end |
.last ⇒ Destination
Shortcut to the last output endpoint available
80 81 82 |
# File 'lib/midi-communications-macos/destination.rb', line 80 def self.last Endpoint.last(:destination) end |
Instance Method Details
#close ⇒ Boolean
Close this output
10 11 12 13 14 15 16 17 |
# File 'lib/midi-communications-macos/destination.rb', line 10 def close if @enabled @enabled = false true else false end end |
#enable ⇒ Destination Also known as: open, start
Enable this device
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/midi-communications-macos/destination.rb', line 58 def enable @enabled ||= true if block_given? begin yield(self) ensure close end end self end |
#puts(*args) ⇒ Boolean Also known as: write
Send a MIDI message of indeterminate type
47 48 49 50 51 52 53 |
# File 'lib/midi-communications-macos/destination.rb', line 47 def puts(*args) case args.first when Array then args.each { |arg| puts(*arg) } when Integer then puts_bytes(*args) when String then puts_bytestr(*args) end end |
#puts_bytes(*data) ⇒ Boolean
Send a MIDI message comprised of numeric bytes
37 38 39 40 41 42 |
# File 'lib/midi-communications-macos/destination.rb', line 37 def puts_bytes(*data) type = sysex?(data) ? :sysex : :small bytes = API.get_midi_packet(data) send("puts_#{type.to_s}", bytes, data.size) true end |
#puts_s(data) ⇒ Boolean Also known as: puts_bytestr, puts_hex
Send a MIDI message comprised of a String of hex digits
22 23 24 25 26 27 28 29 30 |
# File 'lib/midi-communications-macos/destination.rb', line 22 def puts_s(data) data = data.dup bytes = [] until (str = data.slice!(0, 2)).eql?('') bytes << str.hex end puts_bytes(*bytes) true end |