class MTK::IO::UniMIDIOutput

Provides realtime MIDI output for “standard” Ruby (MRI) via the unimidi and gamelan gems. @note This class is optional and only available if you require ‘mtk/midi/unimidi_output’.

It depends on the 'unimidi' and 'gamelan' gems.

Public Class Methods

devices() click to toggle source
# 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() click to toggle source
# 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
new(output_device, options={}) click to toggle source
# File lib/mtk/io/midi_output.rb, line 62
def initialize(output_device, options={})
  @device = output_device
  @device.open
  @options = options
end

Protected Instance Methods

bend(midi_value, channel) click to toggle source

(see MIDIOutput#bend)

# 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) click to toggle source

(see MIDIOutput#channel_pressure)

# 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) click to toggle source

(see MIDIOutput#control)

# 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) click to toggle source

(see MIDIOutput#note_off)

# 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) click to toggle source

(see MIDIOutput#note_on)

# 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) click to toggle source

(see MIDIOutput#poly_pressure)

# 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) click to toggle source

(see MIDIOutput#program)

# File lib/mtk/io/unimidi_output.rb, line 56
def program(number, channel)
  @device.puts(0xC0|channel, number, 0)
end