Class: RtMidi::In
- Inherits:
-
Object
- Object
- RtMidi::In
- Defined in:
- lib/rtmidi/in.rb
Overview
Ruby representation of a RtMidiIn C++ object
Instance Method Summary collapse
-
#cancel_callback ⇒ Object
Cancel previously registered callbacks.
-
#close_ports ⇒ Object
Close all opened ports.
-
#initialize ⇒ In
constructor
Create a new RtMidiIn wrapper object.
-
#open_port(index) ⇒ Object
Open the MIDI input port at the given index.
-
#port_count ⇒ Object
The number of MIDI input ports available.
-
#port_name(index) ⇒ Object
The name of the MIDI input port at the given index.
-
#port_names ⇒ Object
The list of all MIDI input port names.
-
#set_callback(&callback) ⇒ Object
Setup a callback block to handle incoming MIDI channel messages from opened ports.
Constructor Details
#initialize ⇒ In
Create a new RtMidiIn wrapper object.
8 9 10 11 |
# File 'lib/rtmidi/in.rb', line 8 def initialize @midiin = Interface::midiin_new() at_exit{ Interface::midiin_delete @midiin } end |
Instance Method Details
#cancel_callback ⇒ Object
Cancel previously registered callbacks.
70 71 72 |
# File 'lib/rtmidi/in.rb', line 70 def cancel_callback Interface::midiin_cancel_callback(@midiin) end |
#close_ports ⇒ Object
Close all opened ports.
45 46 47 |
# File 'lib/rtmidi/in.rb', line 45 def close_ports() Interface::midiin_close_port(@midiin) end |
#open_port(index) ⇒ Object
Open the MIDI input port at the given index.
40 41 42 |
# File 'lib/rtmidi/in.rb', line 40 def open_port(index) Interface::midiin_open_port(@midiin, index) end |
#port_count ⇒ Object
The number of MIDI input ports available.
14 15 16 |
# File 'lib/rtmidi/in.rb', line 14 def port_count @port_count ||= Interface::midiin_port_count(@midiin) end |
#port_name(index) ⇒ Object
The name of the MIDI input port at the given index.
20 21 22 |
# File 'lib/rtmidi/in.rb', line 20 def port_name(index) port_names[index] end |
#port_names ⇒ Object
The list of all MIDI input port names.
The index of a port in this list is the index to be passed to #port_name and #open_port.
30 31 32 33 34 35 36 |
# File 'lib/rtmidi/in.rb', line 30 def port_names @port_namess ||= ( names = [] port_count.times{|i| names << Interface::midiin_port_name(@midiin, i) } names ) end |
#set_callback(&callback) ⇒ Object
Setup a callback block to handle incoming MIDI channel messages from opened ports.
The block should receive 3 bytes (Ruby integers)
All messages are assumed to have 3 bytes. Some channel messages only have 2 bytes in which case the 3rd byte is 0.
64 65 66 |
# File 'lib/rtmidi/in.rb', line 64 def set_callback &callback Interface::midiin_set_callback(@midiin, callback) end |