Skip to content

Treat separately-profiled app instances as separate entries - #471

Draft
monet-vibrations-proto wants to merge 2 commits into
ronitsingh10:mainfrom
monet-vibrations-proto:feature/per-instance-apps
Draft

monet-vibrations-proto wants to merge 2 commits into
ronitsingh10:mainfrom
monet-vibrations-proto:feature/per-instance-apps

Conversation

@monet-vibrations-proto

Copy link
Copy Markdown

Builds on #470 (per-app stereo pan). This branch includes that commit, so until #470 merges the diff here also shows the pan changes. The change specific to this PR is commit 084f26f.

Why

All of a Chromium browser's tabs and windows play audio through one shared audio-service process, so FineTune can't tell browser windows apart. A second copy launched with its own profile, though, gets its own process tree and audio service:

open -na "Brave Browser" --args --user-data-dir="$HOME/Library/Application Support/BraveSecond"

Before this change, that second copy was merged into the same row and settings as the default instance because both share a bundle ID.

What

  • AppInstance reads the app's main-process argv via KERN_PROCARGS2 and recognises Chromium's --user-data-dir and Firefox's -profile / -P.
  • AudioApp.persistenceIdentifier becomes bundleID@<profile path> for such instances, so volume, pan, mute, EQ and routing persist per instance. Normal launches keep the plain bundle ID, so existing settings are untouched and need no migration.
  • UI: rows are labelled "App (profile)", e.g. Brave Browser (BraveSecond). Activating an instance row uses its PID only, since AppleScript tell application id can't target a specific instance.
  • AudioProcessMonitor caches instances per PID and prunes them when the app quits.

Limitation: media-key shortcuts still resolve by bundle ID and pick the first matching instance.

Testing

  • xcodebuild test -only-testing:FineTuneTests: 982 tests pass, including the new AppInstanceTests (argument parsing, KERN_PROCARGS2 buffer layout, a live read of the test process's own arguments, and persistence identifiers).
  • Manual: a default Brave and a --user-data-dir Brave playing at the same time show as two rows and pan independently.

🤖 Generated with Claude Code

FineTune contributor and others added 2 commits October 15, 2026 08:52
Each app gets a pan control (-1 full left … 0 center … 1 full right) in its
expanded panel, so two apps can share one pair of headphones, one per ear
(e.g. music left, meeting right). Closes the per-app half of ronitsingh10#416.

- PanMath: RT-safe pan. Moving off center progressively folds a stereo
  source to mono before attenuating the far side, so a hard-panned stereo
  app keeps both channels in one ear instead of losing half the program.
- ProcessTapController: pan is ramped per frame with the existing volume
  ramp coefficient (no zipper noise), carried across crossfade/device
  switches, and skipped entirely at center so the default path is
  bit-exact with today's output.
- Persisted per app in settings (appPans), cleared by ignore/prune/reset.
- URL scheme: finetune://set-pan?app=ID&pan=-100…100|left|center|right
- Tests for pan math, pipeline mapping (stereo, mono, multichannel),
  ramp/snap behaviour and URL parsing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KQG7XZ7tYR1MrJGZ7P8ri5
A second copy of a browser launched with its own profile (e.g.
`open -na "Brave Browser" --args --user-data-dir=...`) has its own
process tree and audio service, but was merged into the same row and
settings as the default instance because both share a bundle ID.

- AppInstance reads the main process's argv (KERN_PROCARGS2) and
  recognises Chromium's --user-data-dir and Firefox's -profile / -P.
- AudioApp.persistenceIdentifier becomes `bundleID@<profile path>` for
  such instances, so volume, pan, mute, EQ and routing persist per
  instance. Normal launches keep the plain bundle ID, so existing
  settings are untouched.
- Rows are labelled "App (profile)"; activating an instance row uses
  its PID only, since AppleScript can't target a specific instance.
- Instances are cached per PID and pruned when the app quits.

Media-key shortcuts still resolve by bundle ID and pick the first
matching instance.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants