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



95
96
97
98
# File 'lib/midi-devices.rb', line 95

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



102
103
104
# File 'lib/midi-devices.rb', line 102

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



121
122
123
# File 'lib/midi-devices.rb', line 121

def channels
  @voices.voices
end

#nameString

Returns the device name.

Returns:

  • (String)

    the device name

Since:

  • 0.1.0



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

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



114
115
116
# File 'lib/midi-devices.rb', line 114

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



128
129
130
# File 'lib/midi-devices.rb', line 128

def to_s
  @low_level_device.display_name
end