Class: MusaLCEServer::Live::Track
- Inherits:
-
Object
- Object
- MusaLCEServer::Live::Track
- 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.
Instance Attribute Summary collapse
-
#id ⇒ Integer
readonly
The Live track ID.
- #name ⇒ Object readonly
Instance Method Summary collapse
- #_update_current_input_routing(value) ⇒ Object private
- #_update_current_input_sub_routing(value) ⇒ Object private
- #_update_current_output_routing(value) ⇒ Object private
- #_update_current_output_sub_routing(value) ⇒ Object private
- #_update_has_audio_input(value) ⇒ Object private
- #_update_has_audio_output(value) ⇒ Object private
- #_update_has_midi_input(value) ⇒ Object private
- #_update_has_midi_output(value) ⇒ Object private
- #_update_name(value) ⇒ Object private
-
#initialize(id, midi_devices, logger:) ⇒ Track
constructor
Creates a new track.
-
#out ⇒ Musa::Extension::DynamicProxy::DynamicProxy
Returns the MIDI output for this track.
Constructor Details
#initialize(id, midi_devices, logger:) ⇒ Track
Creates a new track.
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
#id ⇒ Integer (readonly)
Returns the Live track ID.
28 29 30 |
# File 'lib/live/tracks.rb', line 28 def id @id end |
#name ⇒ Object (readonly)
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.
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.
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.
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.
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.
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.
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.
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.
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.
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 |
#out ⇒ Musa::Extension::DynamicProxy::DynamicProxy
Returns the MIDI output for this track.
33 34 35 |
# File 'lib/live/tracks.rb', line 33 def out @output end |