Skip to content

Conversation

@cdrani
Copy link
Collaborator

@cdrani cdrani commented Jan 2, 2026

Summary

  • Fix race condition causing EQ and reverb effects to be applied twice during audio chain initialization
  • Fix blocked track state not syncing between SkipButton and TrackListSkipButton components
  • Fix loop count and infinite loop functionality

Changes

Audio Effects Race Condition Fix

  • Add _effectUpdateInProgress lock in media-override.ts to prevent concurrent effect updates
  • Properly disconnect equalizer input/output nodes in audio-manager.ts during cleanup to prevent duplicate connections
  • Remove redundant setEffect() call in track.ts since it's already triggered via REQUEST_EFFECT_REAPPLY message

Blocked Track State Sync Fix

  • TrackListSkipButton now listens for both chorus:track-blocked and chorus:track-unblocked events
  • Query dataStore.blocked as source of truth when handling events instead of relying on static prop values
  • SkipButton now dispatches chorus:track-blocked event for proper sync with tracklist icons

Loop Count Fix

  • Fix loop count logic: iteration now decrements to 0 before stopping (count=1 means loop once)
  • Enable looping for full tracks, not just snipped tracks
  • Handle track advancement after loop count is exhausted
  • Properly separate infinite vs count-based loop handling

Test plan

  • Toggle EQ presets rapidly and verify effects are applied once (no volume changes from double-application)
  • Enable reverb and verify it's applied correctly without distortion
  • Block a track from SkipButton and verify the Ban icon in tracklist updates to green
  • Unblock from BlockedTracksDialog and verify the Ban icon in tracklist updates back to default color
  • Block/unblock from TrackListSkipButton and verify BlockedTracksDialog stays in sync
  • Set loop count to 1, verify track loops once then advances to next track
  • Set loop count to 2, verify track loops twice then advances
  • Enable infinite loop, verify track loops continuously until disabled
  • Test looping on full track (no snip) and snipped track

Charles Drani and others added 3 commits January 2, 2026 13:15
This commit fixes a bug where EQ and reverb effects could be applied
twice, causing excessive audio processing. The issue was most likely
to occur on Windows due to slower AudioContext operations, but could
happen on any platform during rapid track transitions or effect changes.

Root causes fixed:
1. Race condition in effect reapplication - Multiple async paths could
   trigger updateAudioEffect() simultaneously without synchronization
2. Incomplete equalizer cleanup - The filter chain's input/output nodes
   weren't being disconnected from the external audio chain, allowing
   duplicate connections to accumulate
3. Redundant effect dispatch - processMediaPlayInit() was calling
   setEffect() when REQUEST_EFFECT_REAPPLY already handles this

Changes:
- media-override.ts: Added synchronization lock (_effectUpdateInProgress)
  to ensure only one effect update runs at a time
- audio-manager.ts: Fixed cleanupEffectChain() to properly disconnect
  equalizer input/output nodes from external chain while preserving
  internal filter connections
- track.ts: Removed redundant setEffect() call from processMediaPlayInit()
  since REQUEST_EFFECT_REAPPLY message handles effect reapplication
- SkipButton.svelte: Added chorus:track-blocked event dispatcher to sync
  with blocked tracks dialog

The fix ensures thread-safe effect application and prevents duplicate
audio processing without changing the public API.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
…utton

Listen for both chorus:track-blocked and chorus:track-unblocked events
in TrackListSkipButton to properly reflect block state changes made from
SkipButton or BlockedTracksDialog. Query dataStore.blocked as source of
truth when handling events instead of relying on static prop values.
- Fix loop count logic: iteration now decrements to 0 before stopping
- Enable looping for full tracks (not just snipped tracks)
- Handle track advancement after loop count exhausted
- Properly separate infinite vs count-based loop handling
@cdrani cdrani merged commit d365571 into develop Jan 3, 2026
2 checks passed
@cdrani cdrani deleted the fix/eq-reverb-double-application branch January 3, 2026 19:39
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