Class: JSound::Midi::Devices::OutputDevice

Inherits:
JDevice show all
Defined in:
lib/jsound/midi/devices/output_device.rb

Overview

A device that sends all it’s received messages to a system MIDI output port.

Available outputs are contained in the OUTPUTS list in the JSound::Midi module.

Instance Attribute Summary

Attributes inherited from JDevice

#description, #info, #type

Instance Method Summary collapse

Methods inherited from JDevice

#[], #close, from_java, #inspect, #method_missing, #open, open_devices, #respond_to?, #to_s

Methods inherited from JSound::Midi::Device

#<=, #>>, #close, #open, #open?, #output, #to_s, #type

Methods included from TypeFromClassName

included

Constructor Details

#initialize(java_device) ⇒ OutputDevice

Note:

Typically you won’t instantiate these directly. Instead, find an output via the OUTPUTS list in the JSound::Midi module.

Wrap a javax.sound.midi.MidiDevice transmitter to provide MIDI output.



15
16
17
# File 'lib/jsound/midi/devices/output_device.rb', line 15

def initialize(java_device)
  super(java_device, :output)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class JSound::Midi::Devices::JDevice

Instance Method Details

#message(message) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/jsound/midi/devices/output_device.rb', line 23

def message(message)
  # unwrap the ruby message wrapper, if needed:
  message = message.to_java if message.respond_to? :to_java

  # Use java_send to call Receiver.send() since it conflicts with Ruby's built-in send method
  # -1 means no timestamp, so we're not supporting timestamps
  @java_device.receiver.java_send(:send, [javax.sound.midi.MidiMessage, Java::long], message, -1)
end

#output=(device) ⇒ Object



19
20
21
# File 'lib/jsound/midi/devices/output_device.rb', line 19

def output= device
  raise "#{self.class} cannot be assigned an output"
end