Skip to content

fix(audio): prewarm process taps, apply AutoEQ during crossfade, cut startup CPU, and improve streaming detection - #409

Open
FelikZ wants to merge 1 commit into
ronitsingh10:mainfrom
FelikZ:fix/stable-crossfade-and-startup
Open

fix(audio): prewarm process taps, apply AutoEQ during crossfade, cut startup CPU, and improve streaming detection#409
FelikZ wants to merge 1 commit into
ronitsingh10:mainfrom
FelikZ:fix/stable-crossfade-and-startup

Conversation

@FelikZ

@FelikZ FelikZ commented Aug 8, 2026

Copy link
Copy Markdown

Hand written summary:
When using heavy preamp profiles (-23db in my case) there are annoying bugs:

  • First time chrome (for example) starts playing music there is a brief moment where EQ is not applied and my ears are bleeding
  • When switching between audio sources, there is ~2sec delay before FineTune actually applies preamp + eq.
  • There is CPU spike on a startup and resolves only when UI shown, seem related to apply eq to every source even if its flat~

All of the above seem fixed here.

From AI details:

Fixes #170.
Fixes #245.

Summary

Prewarm process taps before playback

Keeps Core Audio process objects visible to the engine even before they are actively streaming, so FineTune can create process taps before the first audible buffer. Avoids raw/unprocessed audio leak when playback starts.

Apply destination AutoEQ profile during device crossfade

When switching output devices (e.g. MacBook speakers → USB DAC with EQ preset), the secondary tap now receives the destination's AutoEQ profile before the crossfade begins. Previously, the profile was applied only after the crossfade completed, leaving a 1–2s window where audio hit the device without preamp reduction — dangerous when the preset applies heavy negative gain (e.g. −23 dB).

Cut startup CPU from silent taps and flat EQ (#245)

  • EQ processing is skipped entirely when all bands are at 0 dB (isFlat → setEnabled(false)), avoiding wasted CPU on identity transforms.
  • AudioEngine.apps now filters out non-streaming apps so silent taps aren't created unnecessarily.

Improve streaming change detection

  • AppFingerprint now includes hasRunningProcess so play/pause transitions trigger onAppsChanged.
  • Previous fingerprint set is snapshotted for reliable diffing against fresh state.

Files changed

AudioEngine.swift, ProcessTapController.swift, ProcessTapControlling.swift, AudioProcessMonitor.swift, EQProcessor.swift, EQSettings.swift, AudioEngineTapInitialStateTests.swift, ProcessingPipelineTests.swift

Testing

  • Manual verification: Chrome first playback no longer leaks unprocessed audio.
  • Manual verification: device switch with −23 dB AutoEQ preset applies correction immediately, no volume spike.
  • Manual verification: flat EQ skips biquad processing.
  • ./test.sh passes.
  • xcrun swiftc -parse passes on all changed files.
  • git diff --check clean.

… cut startup CPU from silent taps, and improve streaming change detection

- apply destination AutoEQ profile during device crossfade and destructive switch — eliminates the 1-2s window where unprocessed audio (no preamp) hits the output device at full volume
- skip biquad processing for flat EQ bands to cut startup CPU from silent taps (ronitsingh10#245)
- filter non-streaming apps from AudioEngine.apps to avoid creating unnecessary taps
- include hasRunningProcess in AppFingerprint so play/pause transitions trigger onAppsChanged
- snapshot previous fingerprints for reliable streaming change detection
- add autoEQProfile parameter to ProcessTapControlling protocol with convenience overloads
- update test RecordingProcessTapController to match new protocol signatures
- adjust ProcessingPipelineTests expectation: flat EQ now bit-exact passthrough
@FelikZ

FelikZ commented Aug 8, 2026

Copy link
Copy Markdown
Author

@ronitsingh10 hi, please consider this PR - it likely closes 5 issues:
#170 #245 #273 #306 #346

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.

[bug] Unnecessary CPU usage on app startup Initial audio playback bypasses EQ/Volume settings for a brief moment (Tap Initialization Delay)

1 participant