Class: Zgomot::Drivers::CoreMidi
- Defined in:
- lib/zgomot/drivers/core_midi.rb
Defined Under Namespace
Modules: Interface
Constant Summary
Constants inherited from Driver
Driver::CA, Driver::CC, Driver::OFF, Driver::ON, Driver::PA, Driver::PB, Driver::PC
Instance Attribute Summary collapse
-
#destinations ⇒ Object
readonly
Returns the value of attribute destinations.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#sources ⇒ Object
readonly
Returns the value of attribute sources.
Instance Method Summary collapse
- #add_input(name) ⇒ Object
- #close ⇒ Object
-
#initialize ⇒ CoreMidi
constructor
Driver.
- #remove_input(name) ⇒ Object
- #write(*data) ⇒ Object
Methods inherited from Driver
#aftertouch, #channel_aftertouch, #control_change, #note_off, #note_on, #pitch_bend, #program_change
Constructor Details
#initialize ⇒ CoreMidi
Driver
67 68 69 70 71 72 73 74 75 |
# File 'lib/zgomot/drivers/core_midi.rb', line 67 def initialize load_destinations load_sources find_iac_destination @input_client = create_client('Input-Client') @output_client = create_client('Output-Client') create_output_port create_input_port end |
Instance Attribute Details
#destinations ⇒ Object (readonly)
Returns the value of attribute destinations.
5 6 7 |
# File 'lib/zgomot/drivers/core_midi.rb', line 5 def destinations @destinations end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
5 6 7 |
# File 'lib/zgomot/drivers/core_midi.rb', line 5 def input @input end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
5 6 7 |
# File 'lib/zgomot/drivers/core_midi.rb', line 5 def output @output end |
#sources ⇒ Object (readonly)
Returns the value of attribute sources.
5 6 7 |
# File 'lib/zgomot/drivers/core_midi.rb', line 5 def sources @sources end |
Instance Method Details
#add_input(name) ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/zgomot/drivers/core_midi.rb', line 92 def add_input(name) remove_input(name) if @input src_index = find_source_index_for_name(name) src = Interface.MIDIGetSource(src_index) Interface::MIDIPortConnectSource(@input_port, src, nil) @input = name end |
#close ⇒ Object
77 78 79 |
# File 'lib/zgomot/drivers/core_midi.rb', line 77 def close Map.MIDIClientDispose(@client) end |
#remove_input(name) ⇒ Object
100 101 102 103 104 105 |
# File 'lib/zgomot/drivers/core_midi.rb', line 100 def remove_input(name) src_index = find_source_index_for_name(name) src = Interface.MIDIGetSource(src_index) Interface::MIDIPortDisconnectSource(@input_endpoint, src) @input = nil end |
#write(*data) ⇒ Object
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/zgomot/drivers/core_midi.rb', line 81 def write(*data) size = data.size format = "C" * size bytes = FFI::MemoryPointer.new(FFI.type_size(:char) * size) bytes.write_string(data.pack(format)) packet_list = FFI::MemoryPointer.new(256) packet_ptr = Interface.MIDIPacketListInit(packet_list) packet_ptr = Interface.MIDIPacketListAdd(packet_list, 256, packet_ptr, 0, size, bytes) Interface.MIDISend(@output_port, @destination, packet_list) end |