Class: MusaLCEServer::Live::Tracks Private
- Inherits:
-
Object
- Object
- MusaLCEServer::Live::Tracks
- Includes:
- Enumerable
- Defined in:
- lib/live/tracks.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Collection of tracks for Ableton Live.
Manages track registration and lookup, automatically creating and updating tracks based on OSC messages from the MIDI Remote Script.
Instance Method Summary collapse
-
#[](id) ⇒ Track?
private
Retrieves a track by ID.
-
#each {|Track| ... } ⇒ Enumerator
private
Iterates over all tracks.
-
#find_by_name(name) ⇒ Array<Track>
private
Finds all tracks with the given name.
-
#grant_registry(id, name = nil, has_midi_input = nil, has_midi_output = nil, has_audio_input = nil, has_audio_output = nil, current_input_routing = nil, current_input_sub_routing = nil, current_output_routing = nil, current_output_sub_routing = nil) ⇒ void
private
Registers or updates a track with the provided data.
-
#grant_registry_collection(tracks_data) ⇒ void
private
Processes a batch of track data, creating, updating, and deleting tracks.
-
#initialize(midi_devices, logger:) ⇒ Tracks
constructor
private
Creates a new tracks collection.
Constructor Details
#initialize(midi_devices, logger:) ⇒ Tracks
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.
Creates a new tracks collection.
110 111 112 113 114 |
# File 'lib/live/tracks.rb', line 110 def initialize(midi_devices, logger:) @midi_devices = midi_devices @logger = logger @tracks = {} end |
Instance Method Details
#[](id) ⇒ Track?
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.
Retrieves a track by ID.
187 188 189 |
# File 'lib/live/tracks.rb', line 187 def [](id) @tracks[id] end |
#each {|Track| ... } ⇒ Enumerator
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.
Iterates over all tracks.
175 176 177 178 179 180 181 |
# File 'lib/live/tracks.rb', line 175 def each(&block) if block_given? @tracks.values.each(&block) else @tracks.values.each end end |
#find_by_name(name) ⇒ Array<Track>
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.
Adapt to Bitwig semantics where track names are unique
Finds all tracks with the given name.
197 198 199 |
# File 'lib/live/tracks.rb', line 197 def find_by_name(name) @tracks.values.select { |_| _.name == name } end |
#grant_registry(id, name = nil, has_midi_input = nil, has_midi_output = nil, has_audio_input = nil, has_audio_output = nil, current_input_routing = nil, current_input_sub_routing = nil, current_output_routing = nil, current_output_sub_routing = nil) ⇒ void
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.
This method returns an undefined value.
Registers or updates a track with the provided data.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/live/tracks.rb', line 147 def grant_registry(id, name = nil, has_midi_input = nil, has_midi_output = nil, has_audio_input = nil, has_audio_output = nil, current_input_routing = nil, current_input_sub_routing = nil, current_output_routing = nil, current_output_sub_routing = nil) track = @tracks[id] unless track track = Track.new(id, @midi_devices, logger: @logger) @tracks[id] = track end track._update_name(name) if name track._update_has_midi_input(has_midi_input) if has_midi_input track._update_has_midi_output(has_midi_output) if has_midi_output track._update_has_audio_input(has_audio_input) if has_audio_input track._update_has_audio_output(has_audio_output) if has_audio_output track._update_current_input_routing(parse_device_name(current_input_routing)) if current_input_routing track._update_current_input_sub_routing(current_input_sub_routing) if current_input_sub_routing track._update_current_output_routing(parse_device_name(current_output_routing)) if current_output_routing track._update_current_output_sub_routing(current_output_sub_routing) if current_output_sub_routing end |
#grant_registry_collection(tracks_data) ⇒ void
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.
This method returns an undefined value.
Processes a batch of track data, creating, updating, and deleting tracks.
120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/live/tracks.rb', line 120 def grant_registry_collection(tracks_data) tracks_to_delete = Set[*@tracks.keys] tracks_data.each do |track_data| grant_registry(*track_data) tracks_to_delete.delete track_data[0] end tracks_to_delete.each do |id| @tracks.delete(id) @logger.info "deleted track #{id}" end end |