Class: MusaLCEServer::MIDIDevice

Inherits:
Object
  • Object
show all
Defined in:
lib/midi-devices.rb

Overview

Wrapper for a MIDI output device with voice management.

Provides access to individual MIDI channels as voices and panic functionality.

Since:

  • 0.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sequencer, low_level_device) ⇒ MIDIDevice

Creates a new MIDI device wrapper.

Parameters:

  • sequencer (Musa::Sequencer::Sequencer)

    the sequencer for voice management

  • low_level_device (MIDICommunications::Output)

    the underlying MIDI device

Since:

  • 0.1.0



105
106
107
108
# File 'lib/midi-devices.rb', line 105

def initialize(sequencer, low_level_device)
  @low_level_device = low_level_device
  @voices = Musa::MIDIVoices::MIDIVoices.new(sequencer: sequencer, output: low_level_device, channels: 0..15, do_log: true)
end

Instance Attribute Details

#low_level_deviceObject (readonly)

Since:

  • 0.1.0



112
113
114
# File 'lib/midi-devices.rb', line 112

def low_level_device
  @low_level_device
end

Instance Method Details

#channelsArray<Musa::MIDIVoices::MIDIVoice>

Returns the MIDI channels/voices for this device.

Returns:

  • (Array<Musa::MIDIVoices::MIDIVoice>)

    the 16 MIDI channels

Since:

  • 0.1.0



131
132
133
# File 'lib/midi-devices.rb', line 131

def channels
  @voices.voices
end

#nameString

Returns the device name.

Returns:

  • (String)

    the device name

Since:

  • 0.1.0



117
118
119
# File 'lib/midi-devices.rb', line 117

def name
  @low_level_device.name
end

#panic!void

This method returns an undefined value.

Sends All Notes Off and reset to all channels.

Since:

  • 0.1.0



124
125
126
# File 'lib/midi-devices.rb', line 124

def panic!
  @voices.panic reset: true
end

#to_sString

Returns the display name of the device.

Returns:

  • (String)

    the display name

Since:

  • 0.1.0



138
139
140
# File 'lib/midi-devices.rb', line 138

def to_s
  @low_level_device.display_name
end