Class: MIDIJRuby::Output
- Inherits:
-
Object
- Object
- MIDIJRuby::Output
- Includes:
- Device
- Defined in:
- lib/midi-jruby/output.rb
Overview
Output device class
Instance Attribute Summary
Attributes included from Device
#description, #enabled, #id, #name, #type, #vendor
Class Method Summary collapse
-
.all ⇒ Array<Output>
All outputs.
-
.first ⇒ Output
Select the first output.
-
.last ⇒ Output
Select the last output.
Instance Method Summary collapse
-
#close ⇒ Boolean
Close this output.
-
#enable(_options = {}) ⇒ Output
(also: #open, #start)
Enable this device; also takes a block.
-
#puts(*args) ⇒ Boolean
(also: #write)
Output the given MIDI message.
-
#puts_bytes(*data) ⇒ Boolean
Output the given MIDI message.
-
#puts_s(data) ⇒ Boolean
(also: #puts_bytestr, #puts_hex)
Output the given MIDI message.
Methods included from Device
Class Method Details
.all ⇒ Array<Output>
All outputs
80 81 82 |
# File 'lib/midi-jruby/output.rb', line 80 def self.all Device.all_by_type[:output] end |
Instance Method Details
#close ⇒ Boolean
Close this output
10 11 12 13 |
# File 'lib/midi-jruby/output.rb', line 10 def close API.close_output(@device) @enabled = false end |
#enable(_options = {}) ⇒ Output Also known as: open, start
Enable this device; also takes a block
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/midi-jruby/output.rb', line 48 def enable( = {}) unless @enabled API.enable_output(@device) @enabled = true end if block_given? begin yield(self) ensure close end else self end end |
#puts(*args) ⇒ Boolean Also known as: write
Output the given MIDI message
35 36 37 38 39 40 41 |
# File 'lib/midi-jruby/output.rb', line 35 def puts(*args) case args.first when Array then args.each { |arg| puts(*arg) } when Numeric then puts_bytes(*args) when String then puts_bytestr(*args) end end |
#puts_bytes(*data) ⇒ Boolean
Output the given MIDI message
28 29 30 |
# File 'lib/midi-jruby/output.rb', line 28 def puts_bytes(*data) API.write_output(@device, data) end |
#puts_s(data) ⇒ Boolean Also known as: puts_bytestr, puts_hex
Output the given MIDI message
18 19 20 21 |
# File 'lib/midi-jruby/output.rb', line 18 def puts_s(data) bytes = hex_string_to_numeric_bytes(data) puts_bytes(*bytes) end |