Class: CoreMIDI::Output
- Inherits:
-
Object
- Object
- CoreMIDI::Output
- Includes:
- Endpoint
- Defined in:
- lib/coremidi/output.rb
Overview
Output endpoint class
Constant Summary
- SysexCompletionCallback =
FFI::Function.new(:void, [:pointer]) do |sysex_request_ptr| p 'hi' # this isn't working for some reason # as of now, we don't need it though end
Instance Attribute Summary
Attributes included from Endpoint
#enabled, #entity, #id, #resource_id, #type
Class Method Summary (collapse)
-
+ (Object) all
all output endpoints.
-
+ (Object) first
shortcut to the first output endpoint available.
-
+ (Object) last
shortcut to the last output endpoint available.
Instance Method Summary (collapse)
-
- (Object) close
close this output.
-
- (Object) enable(options = {}, &block)
(also: #open, #start)
enable this device; also takes a block.
-
- (Object) puts(*a)
(also: #write)
send a MIDI message of an indeterminant type.
-
- (Object) puts_bytes(*data)
sends a MIDI messages comprised of Numeric bytes.
-
- (Object) puts_s(data)
(also: #puts_bytestr, #puts_hex)
sends a MIDI message comprised of a String of hex digits.
Methods included from Endpoint
all_by_type, #initialize, #online?
Class Method Details
+ (Object) all
all output endpoints
88 89 90 |
# File 'lib/coremidi/output.rb', line 88 def self.all Endpoint.all_by_type[:output] end |
+ (Object) first
shortcut to the first output endpoint available
78 79 80 |
# File 'lib/coremidi/output.rb', line 78 def self.first Endpoint.first(:output) end |
+ (Object) last
shortcut to the last output endpoint available
83 84 85 |
# File 'lib/coremidi/output.rb', line 83 def self.last Endpoint.last(:output) end |
Instance Method Details
- (Object) close
close this output
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/coremidi/output.rb', line 13 def close error = Map.MIDIClientDispose(@handle) raise "MIDIClientDispose returned error code #{error}" unless error.zero? error = Map.MIDIPortDispose(@handle) raise "MIDIPortDispose returned error code #{error}" unless error.zero? error = Map.MIDIEndpointDispose(@resource) raise "MIDIEndpointDispose returned error code #{error}" unless error.zero? @enabled = false end |
- (Object) enable(options = {}, &block) Also known as: open, start
enable this device; also takes a block
61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/coremidi/output.rb', line 61 def enable( = {}, &block) #connect @enabled = true unless block.nil? begin yield(self) ensure close end else self end end |
- (Object) puts(*a) Also known as: write
send a MIDI message of an indeterminant type
51 52 53 54 55 56 57 |
# File 'lib/coremidi/output.rb', line 51 def puts(*a) case a.first when Array then puts_bytes(*a.first) when Numeric then puts_bytes(*a) when String then puts_bytestr(*a) end end |
- (Object) puts_bytes(*data)
sends a MIDI messages comprised of Numeric bytes
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/coremidi/output.rb', line 37 def puts_bytes(*data) format = "C" * data.size bytes = (FFI::MemoryPointer.new FFI.type_size(:char) * data.size) bytes.write_string(data.pack(format)) if data.first.eql?(0xF0) && data.last.eql?(0xF7) puts_sysex(bytes, data.size) else puts_small(bytes, data.size) end end |
- (Object) puts_s(data) Also known as: puts_bytestr, puts_hex
sends a MIDI message comprised of a String of hex digits
25 26 27 28 29 30 31 32 |
# File 'lib/coremidi/output.rb', line 25 def puts_s(data) data = data.dup output = [] until (str = data.slice!(0,2)).eql?("") output << str.hex end puts_bytes(*output) end |