diff --git a/dist/src/playback/processing/streamProcessor.js b/dist/src/playback/processing/streamProcessor.js index 46866439..942cff8f 100644 --- a/dist/src/playback/processing/streamProcessor.js +++ b/dist/src/playback/processing/streamProcessor.js @@ -2416,8 +2416,8 @@ class StreamAudioResource extends BaseAudioResource { type: 's16le', volume, enableAGC, - lookaheadMs: this.nodelink?.options?.audio?.lookaheadMs, - gateThresholdLUFS: this.nodelink?.options?.audio?.gateThresholdLUFS + lookaheadMs: this.nodelink?.options?.playback?.audio?.lookaheadMs, + gateThresholdLUFS: this.nodelink?.options?.playback?.audio?.gateThresholdLUFS }); pipeline(pcmStream, volumeTransformer, (err) => { if (err && !this._destroyed) { @@ -2520,7 +2520,7 @@ export const createSeekeableAudioResource = async (guildId, url, seekTime, endTi return _createErrorResponse(err.message, cause); } }; -export const createPCMStream = (_guildId, stream, type, nodelink, volume = 1.0, filters = {}) => { +export const createPCMStream = (_guildId, stream, type, nodelink, volume = 1.0, filters = {}, enableAGC = false) => { const resamplingQuality = nodelink.options.playback.audio?.resamplingQuality || 'fastest'; const normalizedType = normalizeFormat(type); const streams = [stream]; @@ -2584,7 +2584,13 @@ export const createPCMStream = (_guildId, stream, type, nodelink, volume = 1.0, default: throw new Error(`Unsupported audio format: '${type}'`); } - streams.push(new VolumeTransformer({ type: 's16le', volume })); + streams.push(new VolumeTransformer({ + type: 's16le', + volume, + enableAGC, + lookaheadMs: nodelink.options.playback.audio?.lookaheadMs, + gateThresholdLUFS: nodelink.options.playback.audio?.gateThresholdLUFS + })); streams.push(new FiltersManager(nodelink, filters)); for (const s of streams) { if (s !== stream) { diff --git a/dist/src/workers/main.js b/dist/src/workers/main.js index d550bd3a..85f4dce5 100644 --- a/dist/src/workers/main.js +++ b/dist/src/workers/main.js @@ -1404,7 +1404,7 @@ async function startLoadStream(streamId, payload) { throw new Error(fetched.exception.message || 'Failed to load stream'); } const createPCMStream = await getCreatePCMStream(); - const pcmStream = createPCMStream(payload?.guildId ?? 'worker-stream', fetched.stream, fetched.type || urlResult.format || 'unknown', nodelink, (payload?.volume ?? 100) / 100, payload?.filters || {}); + const pcmStream = createPCMStream(payload?.guildId ?? 'worker-stream', fetched.stream, fetched.type || urlResult.format || 'unknown', nodelink, (payload?.volume ?? 100) / 100, payload?.filters || {}, nodelink.options.playback?.audio?.loudnessNormalizer ?? false); const entry = { pcmStream, fetched, diff --git a/dist/src/workers/source.js b/dist/src/workers/source.js index d7ecddf9..72c738a8 100644 --- a/dist/src/workers/source.js +++ b/dist/src/workers/source.js @@ -997,7 +997,7 @@ else { if (urlResult.url && !isHls && !isLocal && !isSabr) { const resource = await createSeekeableAudioResource(id, urlResult.url, payload?.position || 0, undefined, nodelink, {}, { streamInfo: urlResult, - loudnessNormalizer: nodelink.options.audio?.loudnessNormalizer + loudnessNormalizer: nodelink.options.playback?.audio?.loudnessNormalizer ?? false }, (payload?.volume ?? 100) / 100, null, true); if ('exception' in resource) { throw new Error(resource.exception.message); @@ -1015,7 +1015,7 @@ else { if (!fetched || fetched.exception) { throw new Error(fetched?.exception?.message || 'Failed to load stream'); } - pcmStream = createPCMStream(id, fetched.stream, fetched.type || urlResult.format || 'unknown', nodelink, (payload?.volume ?? 100) / 100, payload?.filters || {}); + pcmStream = createPCMStream(id, fetched.stream, fetched.type || urlResult.format || 'unknown', nodelink, (payload?.volume ?? 100) / 100, payload?.filters || {}, nodelink.options.playback?.audio?.loudnessNormalizer ?? false); } pcmStream.on('data', (chunk) => { if (!finished) diff --git a/src/playback/processing/streamProcessor.ts b/src/playback/processing/streamProcessor.ts index ddea283b..352aedff 100644 --- a/src/playback/processing/streamProcessor.ts +++ b/src/playback/processing/streamProcessor.ts @@ -3210,8 +3210,9 @@ class StreamAudioResource extends BaseAudioResource { type: 's16le', volume, enableAGC, - lookaheadMs: this.nodelink?.options?.audio?.lookaheadMs, - gateThresholdLUFS: this.nodelink?.options?.audio?.gateThresholdLUFS + lookaheadMs: this.nodelink?.options?.playback?.audio?.lookaheadMs, + gateThresholdLUFS: + this.nodelink?.options?.playback?.audio?.gateThresholdLUFS }) pipeline(pcmStream, volumeTransformer, (err: Error | null): void => { @@ -3429,7 +3430,8 @@ export const createPCMStream = ( type: string, nodelink: NodeLink, volume: number = 1.0, - filters: FiltersState = {} + filters: FiltersState = {}, + enableAGC: boolean = false ): Transform => { const resamplingQuality = nodelink.options.playback.audio?.resamplingQuality || 'fastest' @@ -3514,7 +3516,15 @@ export const createPCMStream = ( throw new Error(`Unsupported audio format: '${type}'`) } - streams.push(new VolumeTransformer({ type: 's16le', volume })) + streams.push( + new VolumeTransformer({ + type: 's16le', + volume, + enableAGC, + lookaheadMs: nodelink.options.playback.audio?.lookaheadMs, + gateThresholdLUFS: nodelink.options.playback.audio?.gateThresholdLUFS + }) + ) streams.push(new FiltersManager(nodelink, filters)) for (const s of streams) { diff --git a/src/workers/main.ts b/src/workers/main.ts index 099ac85e..85f99889 100644 --- a/src/workers/main.ts +++ b/src/workers/main.ts @@ -1949,7 +1949,8 @@ async function startLoadStream( fetched.type || (urlResult.format as string) || 'unknown', nodelink as unknown as NodeLink, (payload?.volume ?? 100) / 100, - payload?.filters || {} + payload?.filters || {}, + nodelink.options.playback?.audio?.loudnessNormalizer ?? false ) as unknown as PCMStream const entry: ActiveStreamEntry = { diff --git a/src/workers/source.ts b/src/workers/source.ts index 14bbf401..24e387cf 100644 --- a/src/workers/source.ts +++ b/src/workers/source.ts @@ -1380,11 +1380,8 @@ if (isMainThread) { {}, { streamInfo: urlResult, - loudnessNormalizer: ( - nodelink.options as unknown as { - audio?: { loudnessNormalizer?: boolean } - } - ).audio?.loudnessNormalizer + loudnessNormalizer: + nodelink.options.playback?.audio?.loudnessNormalizer ?? false }, (payload?.volume ?? 100) / 100, null, @@ -1423,7 +1420,8 @@ if (isMainThread) { fetched.type || (urlResult.format as string) || 'unknown', nodelink as unknown as NodeLink, (payload?.volume ?? 100) / 100, - payload?.filters || {} + payload?.filters || {}, + nodelink.options.playback?.audio?.loudnessNormalizer ?? false ) as unknown as PCMStream }