Class: MusaLCEServer::Live::Track

Inherits:
Object
  • Object
show all
Defined in:
lib/live/tracks.rb

Overview

Represents a track in Ableton Live.

Tracks in Live are identified by their internal ID and can have MIDI input routing configured. The output is dynamically proxied to allow routing changes without recreating the track object.

Since:

  • 0.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, midi_devices, logger:) ⇒ Track

Creates a new track.

Parameters:

  • id (Integer)

    the Live track ID

  • midi_devices (MIDIDevices)

    the MIDI devices manager

  • logger (Logger)

    the logger

Since:

  • 0.1.0



16
17
18
19
20
21
22
# File 'lib/live/tracks.rb', line 16

def initialize(id, midi_devices, logger:)
  @id = id
  @midi_devices = midi_devices
  @logger = logger

  @output = Musa::Extension::DynamicProxy::DynamicProxy.new
end

Instance Attribute Details

#idInteger (readonly)

Returns the Live track ID.

Returns:

  • (Integer)

    the Live track ID



28
29
30
# File 'lib/live/tracks.rb', line 28

def id
  @id
end

#nameObject (readonly)

Since:

  • 0.1.0



28
# File 'lib/live/tracks.rb', line 28

attr_reader :id, :name

Instance Method Details

#_update_current_input_routing(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



61
62
63
64
# File 'lib/live/tracks.rb', line 61

def _update_current_input_routing(value)
  @current_input_routing = value
  _update_current_input_sub_routing(@current_input_sub_routing)
end

#_update_current_input_sub_routing(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/live/tracks.rb', line 67

def _update_current_input_sub_routing(value)
  @current_input_sub_routing = value

  effective_midi_voice = nil

  if @has_midi_input
    device = @midi_devices.find(@current_input_routing)

    if device
      channel = /Ch\. (?<channel>\d+)/.match(@current_input_sub_routing)&.[](:channel)
      effective_midi_voice = device.channels[channel.to_i - 1] if channel

      @logger.info "track #{@id} assigned new input: device '#{device.name}' #{effective_midi_voice}"
    end
  end

  @output.receiver = effective_midi_voice
end

#_update_current_output_routing(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



87
88
89
# File 'lib/live/tracks.rb', line 87

def _update_current_output_routing(value);
@current_output_routing = value
end

#_update_current_output_sub_routing(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



92
93
94
# File 'lib/live/tracks.rb', line 92

def _update_current_output_sub_routing(value);
@current_output_sub_routing = value
end

#_update_has_audio_input(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



52
53
54
# File 'lib/live/tracks.rb', line 52

def _update_has_audio_input(value);
@has_audio_input = value == 1;
end

#_update_has_audio_output(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



56
57
58
# File 'lib/live/tracks.rb', line 56

def _update_has_audio_output(value);
@has_audio_output = value == 1;
end

#_update_has_midi_input(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



44
45
46
# File 'lib/live/tracks.rb', line 44

def _update_has_midi_input(value);
@has_midi_input = value == 1;
end

#_update_has_midi_output(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



48
49
50
# File 'lib/live/tracks.rb', line 48

def _update_has_midi_output(value);
@has_midi_output = value == 1;
end

#_update_name(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0



38
39
40
41
# File 'lib/live/tracks.rb', line 38

def _update_name(value)
  @name = value
  @logger.info "track #{@id} assigned name #{@name}"
end

#outMusa::Extension::DynamicProxy::DynamicProxy

Returns the MIDI output for this track.

Returns:

  • (Musa::Extension::DynamicProxy::DynamicProxy)

    proxy to the MIDI voice

Since:

  • 0.1.0



33
34
35
# File 'lib/live/tracks.rb', line 33

def out
  @output
end