Class: RtMidi::Out

Inherits:
Object
  • Object
show all
Defined in:
lib/rtmidi/out.rb

Overview

Ruby representation of a RtMidiOut C++ object

See Also:

Instance Method Summary collapse

Constructor Details

#initializeOut

Create a new RtMidiOut wrapper object.



8
9
10
11
# File 'lib/rtmidi/out.rb', line 8

def initialize
  @midiout = Interface::midiout_new()
  at_exit{ Interface::midiout_delete @midiout }
end

Instance Method Details

#close_portsObject

Close all opened ports.



45
46
47
# File 'lib/rtmidi/out.rb', line 45

def close_ports()
  Interface::midiout_close_port(@midiout)
end

#open_port(index) ⇒ Object

Open the MIDI output port at the given index.

See Also:



40
41
42
# File 'lib/rtmidi/out.rb', line 40

def open_port(index)
  Interface::midiout_open_port(@midiout, index)
end

#port_countObject

The number of MIDI output ports available.



14
15
16
# File 'lib/rtmidi/out.rb', line 14

def port_count      
  @port_count ||= Interface::midiout_port_count(@midiout)
end

#port_name(index) ⇒ Object

The name of the MIDI output port at the given index.

See Also:



20
21
22
# File 'lib/rtmidi/out.rb', line 20

def port_name(index)
  port_names[index]
end

#port_namesObject

The list of all MIDI output 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/out.rb', line 30

def port_names
  @port_namess ||= (
    names = []
    port_count.times{|i| names << Interface::midiout_port_name(@midiout, i) }
    names
  )       
end

#send_message(byte1, byte2, byte3 = 0) ⇒ Object

Send a 3-byte MIDI channel message to the opened port.

Some channel messages only have 2 bytes in which case the 3rd byte is ignored.

See Also:



53
54
55
# File 'lib/rtmidi/out.rb', line 53

def send_message(byte1, byte2, byte3=0)
  Interface::midiout_send_message(@midiout, byte1, byte2, byte3)
end