Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"tailwindcss-animate": "^1.0.7",
"tslib": "^2.8.1",
"typescript": "^5.6.3",
"wxt": "^0.19.13"
"wxt": "^0.19.29"
},
"private": true,
"scripts": {
Expand Down
22 changes: 15 additions & 7 deletions src/lib/audio-effects/audio-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,10 @@ export default class AudioManager {

getGainPairing(effect: string) {
const pairings = {
kick_ir: { dry: 0.95, wet: 0.05 },
muffler_ir: { dry: 0.9, wet: 0.1 },
diffusor_ir: { dry: 0.9, wet: 0.1 },
telephone_ir: { dry: 0.65, wet: 0.35 }
kick_ir: { dry: 0.5, wet: 0.5 },
muffler_ir: { dry: 0.4, wet: 0.6 },
diffusor_ir: { dry: 0.4, wet: 0.6 },
telephone_ir: { dry: 0.3, wet: 0.7 }
}
return pairings[effect as keyof typeof pairings]
}
Expand Down Expand Up @@ -410,11 +410,19 @@ export default class AudioManager {
disconnect() {
if (!this.isConnectable) return

// Clear all active effects
// CRITICAL: First cleanup the effect chain while we still have references to the effect nodes
// This ensures all effect nodes are properly disconnected before we clear the references
this.cleanupEffectChain()

// Now clear all active effects
this._activeEffects = {}

// Rebuild with no effects (just gain → soundTouch → destination)
this.rebuildEffectChain()
// Reconnect the basic chain: source → gain → soundTouch → destination
if (this.source && this._gainNode && this._soundTouchNode && this.destination) {
this.source.connect(this._gainNode)
this._gainNode.connect(this._soundTouchNode)
this._soundTouchNode.connect(this.destination)
}
}

removeEffect(effectType: 'equalizer' | 'msProcessor' | 'reverb') {
Expand Down
7 changes: 0 additions & 7 deletions src/lib/audio-effects/ms-processor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@ export default class MSProcessor {
}

async setMSEffect(effect: string) {
console.log('MSProcessor.setMSEffect called with:', effect)
if (!this._audioManager.audioContext) {
console.warn('MSProcessor: AudioContext not initialized yet, skipping')
return
}

this._audioContext = this._audioManager.audioContext

if (effect === 'none') {
console.log('MSProcessor: disconnecting')
this.cleanup()
if (this._audioManager.audioContext) {
this._audioManager.removeEffect('msProcessor')
Expand All @@ -34,7 +31,6 @@ export default class MSProcessor {
await this.createMSProcessor()
this.connectMSProcessor()
this.applyMSEffect(effect)
console.log('MSProcessor: effect applied successfully')
} catch (error) {
console.error('Error setting MS effect:', error)
this.cleanup()
Expand All @@ -46,9 +42,7 @@ export default class MSProcessor {
}

async applyManualParams(params: MSParams) {
console.log('MSProcessor.applyManualParams called with:', params)
if (!this._audioManager.audioContext) {
console.warn('MSProcessor: AudioContext not initialized yet, skipping')
return
}

Expand All @@ -62,7 +56,6 @@ export default class MSProcessor {
}

this.applyParams(params)
console.log('MSProcessor: manual params applied successfully')
} catch (error) {
console.error('Error applying manual MS params:', error)
throw error
Expand Down
5 changes: 0 additions & 5 deletions src/lib/audio-effects/reverb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,12 @@ export default class Reverb {
}

async setReverbEffect(effect: string) {
console.log('Reverb.setReverbEffect called with:', effect)
if (!this._audioManager.audioContext) {
console.warn('Reverb: AudioContext not initialized yet, skipping')
return
}

this._audioContext = this._audioManager.audioContext
if (effect === 'none') {
console.log('Reverb: disconnecting')
this.cleanup()
if (this._audioManager.audioContext) {
this._audioManager.removeEffect('reverb')
Expand All @@ -43,12 +40,10 @@ export default class Reverb {
const isImpulse = this.isImpulse(effect)
if (isImpulse) {
await this.createImpulseReverb(effect)
console.log('Reverb: impulse reverb applied')
} else {
await this.createDigitalReverb()
this.connectDigitalReverb()
this.applyReverbEffect(effect)
console.log('Reverb: digital reverb applied')
}
} catch (error) {
console.error('Error setting reverb effect:', error)
Expand Down
3 changes: 0 additions & 3 deletions src/lib/media/media-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ export default class MediaElement {

this.loadMediaOverride()
document.dispatchEvent(new CustomEvent('FROM_MEDIA_PLAY_INIT'))

// Trigger re-application of stored effects after media is ready
window.postMessage({ type: 'REQUEST_EFFECT_REAPPLY' }, '*')
})

// Set up window message listener (instance-based, v2.7.1 pattern)
Expand Down
4 changes: 1 addition & 3 deletions src/lib/observers/track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ export class TrackObserver {
private async processMediaPlayInit() {
await this.trackStateManager.updateTrackType()
await this.trackStateManager.setPlayback(this.audioPreset)
// Note: setEffect() will be called via REQUEST_EFFECT_REAPPLY message
// dispatched from media-element.ts, so we don't need to call it here
// to avoid redundant effect applications
this.setEffect()
}

// Simplified getters for commonly accessed stores
Expand Down
9 changes: 0 additions & 9 deletions src/lib/stores/effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,6 @@ function createAudioEffectsStore() {
set(syncedValue)
})

// Listen for requests to reapply effects (e.g., after media element recreation)
// Only set up listener if window is available (not in service worker context)
if (typeof window !== 'undefined') {
window.addEventListener('message', (event) => {
if (event.source !== window) return
if (event.data?.type === 'REQUEST_EFFECT_REAPPLY') dispatchEffect()
})
}

return {
set,
reset,
Expand Down
14 changes: 0 additions & 14 deletions src/lib/stores/ms-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,6 @@ function createMSParamsStore() {
set(syncedValue)
})

// Listen for requests to reapply params (e.g., after media element recreation)
// Only set up listener if window is available (not in service worker context)
if (typeof window !== 'undefined') {
window.addEventListener('message', (event) => {
if (event.source !== window) return
if (
event.data?.type === 'REQUEST_MS_PARAMS_REAPPLY' ||
event.data?.type === 'REQUEST_EFFECT_REAPPLY'
) {
dispatchParams()
}
})
}

return {
set,
reset,
Expand Down
11 changes: 0 additions & 11 deletions src/lib/stores/playback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,6 @@ function createPlaybackStore() {
set(syncedValues)
})

// Listen for requests to reapply playback settings (e.g., after media element recreation)
// Only set up listener if window is available (not in service worker context)
if (typeof window !== 'undefined') {
window.addEventListener('message', (event) => {
if (event.source !== window) return
if (event.data?.type === 'REQUEST_EFFECT_REAPPLY') {
dispatchPlaybackSettings()
}
})
}

return {
reset,
togglePin,
Expand Down
11 changes: 0 additions & 11 deletions src/lib/stores/volume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,6 @@ function createVolumeStore() {
set(syncedVolume)
})

// Listen for requests to reapply volume (e.g., after media element recreation)
// Only set up listener if window is available (not in service worker context)
if (typeof window !== 'undefined') {
window.addEventListener('message', (event) => {
if (event.source !== window) return
if (event.data?.type === 'REQUEST_EFFECT_REAPPLY') {
dispatchVolumeEvent()
}
})
}

return {
mute,
unMute,
Expand Down