Class: MTK::IO::UniMIDIOutput
- Inherits:
-
MIDIOutput
- Object
- MIDIOutput
- MTK::IO::UniMIDIOutput
- Defined in:
- lib/mtk/io/unimidi_output.rb
Overview
This class is optional and only available if you require ‘mtk/midi/unimidi_output’. It depends on the ‘unimidi’ and ‘gamelan’ gems.
Provides realtime MIDI output for “standard” Ruby (MRI) via the unimidi and gamelan gems.
Instance Attribute Summary
Attributes inherited from MIDIOutput
Class Method Summary collapse
Instance Method Summary collapse
-
#bend(midi_value, channel) ⇒ Object
protected
Send a pitch bend event to the MIDI output.
-
#channel_pressure(midi_value, channel) ⇒ Object
protected
Send a channel pressure event to the MIDI output.
-
#control(number, midi_value, channel) ⇒ Object
protected
Send a control change event to the MIDI output.
-
#note_off(pitch, velocity, channel) ⇒ Object
protected
Send a note off event to the MIDI output.
-
#note_on(pitch, velocity, channel) ⇒ Object
protected
Send a note on event to the MIDI output.
-
#poly_pressure(pitch, midi_value, channel) ⇒ Object
protected
Send a poly pressure event to the MIDI output.
-
#program(number, channel) ⇒ Object
protected
Send a program change event to the MIDI output.
Methods inherited from MIDIOutput
available_output_types, find_by_name, #initialize, #name, open, output_types_by_device, #play
Constructor Details
This class inherits a constructor from MTK::IO::MIDIOutput
Class Method Details
.devices ⇒ Object
13 14 15 |
# File 'lib/mtk/io/unimidi_output.rb', line 13 def self.devices @devices ||= ::UniMIDI::Output.all.reject{|d| d.name.strip.empty? } end |
.devices_by_name ⇒ Object
17 18 19 |
# File 'lib/mtk/io/unimidi_output.rb', line 17 def self.devices_by_name @devices_by_name ||= devices.each_with_object( Hash.new ){|device,hash| hash[device.name] = device } end |
Instance Method Details
#bend(midi_value, channel) ⇒ Object (protected)
Send a pitch bend event to the MIDI output.
51 52 53 |
# File 'lib/mtk/io/unimidi_output.rb', line 51 def bend(midi_value, channel) @device.puts(0xE0|channel, midi_value & 127, (midi_value >> 7) & 127) end |
#channel_pressure(midi_value, channel) ⇒ Object (protected)
Send a channel pressure event to the MIDI output.
41 42 43 |
# File 'lib/mtk/io/unimidi_output.rb', line 41 def channel_pressure(midi_value, channel) @device.puts(0xD0|channel, midi_value, 0) end |
#control(number, midi_value, channel) ⇒ Object (protected)
Send a control change event to the MIDI output
36 37 38 |
# File 'lib/mtk/io/unimidi_output.rb', line 36 def control(number, midi_value, channel) @device.puts(0xB0|channel, number, midi_value) end |
#note_off(pitch, velocity, channel) ⇒ Object (protected)
Send a note off event to the MIDI output
31 32 33 |
# File 'lib/mtk/io/unimidi_output.rb', line 31 def note_off(pitch, velocity, channel) @device.puts(0x80|channel, pitch, velocity) end |
#note_on(pitch, velocity, channel) ⇒ Object (protected)
Send a note on event to the MIDI output
26 27 28 |
# File 'lib/mtk/io/unimidi_output.rb', line 26 def note_on(pitch, velocity, channel) @device.puts(0x90|channel, pitch, velocity) end |
#poly_pressure(pitch, midi_value, channel) ⇒ Object (protected)
Send a poly pressure event to the MIDI output.
46 47 48 |
# File 'lib/mtk/io/unimidi_output.rb', line 46 def poly_pressure(pitch, midi_value, channel) @device.puts(0xA0|channel, pitch, midi_value) end |
#program(number, channel) ⇒ Object (protected)
Send a program change event to the MIDI output.
56 57 58 |
# File 'lib/mtk/io/unimidi_output.rb', line 56 def program(number, channel) @device.puts(0xC0|channel, number, 0) end |