Add Master and Return Track Support#189
Open
jwhector wants to merge 4 commits intoideoforms:masterfrom
Open
Conversation
|
masterful work. would love to see this merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Master and Return Track Support
This PR adds support for accessing master and return tracks throughout the AbletonOSC API, independent of the number of tracks in the set. Previously, only regular Audio/MIDI tracks could be accessed via the Track, Device, and Song APIs. Now, master and return tracks can be accessed using string identifiers or are automatically included when enumerating "all" tracks.
This PR closes #47 and reimplements #84. Referencing that discussion, a goal with this PR was to keep a similar namespace to what's already implemented by the API for maximum legibility and backward compatibility, as well as to enable querying master and send/return tracks independent of the number of tracks in the set. More details about the specific implementation below.
Motivation
Changes
1. Added Shared Track Resolution Helper
File:
abletonosc/handler.pyCreated a reusable
_resolve_track()method onAbletonOSCHandlerthat resolves track parameters to track objects:0,1,2) → regular tracks viaself.song.tracks[index]self.song.master_track"A","B") → matches againstself.song.return_tracksnames (format: "A-Reverb", "B-Delay")2. Track API: Master and Return Track Support
File:
abletonosc/track.pyChanges:
track_callbackto use the shared_resolve_track()helper"*"to include master and return tracksNew Usage:
3. Device API: Master and Return Track Support
File:
abletonosc/device.pyChanges:
device_callbackto use the shared_resolve_track()helperNew Usage:
4. Song API: Extended Enumeration Functions
File:
abletonosc/song.py4a.
song_get_track_namesExtended to include master and return tracks when enumerating "all":
4b.
song_get_track_dataExtended to process master and return tracks when
track_index_max == -1:Note: Handles tracks without
clip_slots(master/returns don't have clips) gracefully.4c.
song_export_structureAlways includes master and return tracks in the exported JSON:
New JSON structure:
{ "tracks": [ // Regular tracks (existing) ], "master_track": { "name": "Master", "devices": [...] }, "return_tracks": [ { "index": 0, "name": "A-Reverb", "devices": [...] }, { "index": 1, "name": "B-Delay", "devices": [...] } ] }Technical Details
Response Format
When using string identifiers, OSC responses include the string identifier:
/live/track/get/volume master→("master", 0.75)/live/track/get/volume A→("A", 0.8)/live/device/get/name master 0→("master", 0, "Compressor")This maintains consistency with the existing API where numeric indices are returned.
Backward Compatibility
All changes are fully backward compatible:
Tests
tests/test_track.pyNew tests verify that track properties (name, volume, panning, mute, num_devices) can be read and written using the string identifiers
"master"/"main"for the master track and a return track prefix (e.g."A") for return tracks. A listener test confirmsstart_listen/stop_listenwork correctly with the"master"identifier. Additional tests assert that an unrecognised string identifier returnsNonewithout crashing, and that pre-existing numeric integer indexing continues to work as before.tests/test_song.pyNew tests cover the two modified endpoints:
/live/song/get/track_names— verifies that a no-argument call (or a range ending in-1) includes the master and return tracks in the response, while an explicit numeric range excludes them./live/song/get/track_data— verifies that a range ending in-1includes master/return track data, that an explicit range does not, and that queryingclip,clip_slot, ordeviceproperties over a range that includes master/return tracks (which have noclip_slots) does not raise an error.Checklist