diff --git a/DeepDrftPublic/Interop/audio/AudioContextManager.ts b/DeepDrftPublic/Interop/audio/AudioContextManager.ts index e083a3d..203dc4c 100644 --- a/DeepDrftPublic/Interop/audio/AudioContextManager.ts +++ b/DeepDrftPublic/Interop/audio/AudioContextManager.ts @@ -31,8 +31,6 @@ export class AudioContextManager { const analyserNode = this.spectrumAnalyzer.initialize(this.audioContext); this.gainNode.connect(analyserNode); analyserNode.connect(this.audioContext.destination); - - console.log(`AudioContext initialized: sampleRate=${this.audioContext.sampleRate}Hz, state=${this.audioContext.state}`); } async ensureReady(): Promise { @@ -40,9 +38,7 @@ export class AudioContextManager { throw new Error('AudioContext not initialized'); } if (this.audioContext.state === 'suspended') { - console.log('🔊 Resuming AudioContext'); await this.audioContext.resume(); - console.log(`✅ AudioContext resumed: state=${this.audioContext.state}`); } } @@ -55,7 +51,6 @@ export class AudioContextManager { return; // Already correct sample rate } - console.log(`🔄 Recreating AudioContext: ${this.audioContext.sampleRate}Hz -> ${sampleRate}Hz`); await this.audioContext.close(); await this.initialize(sampleRate); } diff --git a/DeepDrftPublic/Interop/audio/AudioPlayer.ts b/DeepDrftPublic/Interop/audio/AudioPlayer.ts index e1b00c7..8e2dbf8 100644 --- a/DeepDrftPublic/Interop/audio/AudioPlayer.ts +++ b/DeepDrftPublic/Interop/audio/AudioPlayer.ts @@ -100,7 +100,6 @@ export class AudioPlayer { // Initialize new stream this.isStreamingMode = true; this.streamDecoder.initialize(totalStreamLength); - console.log(`Streaming initialized: ${totalStreamLength} bytes expected`); return { success: true }; } catch (error) { return { success: false, error: (error as Error).message }; @@ -126,7 +125,6 @@ export class AudioPlayer { } } this.streamingCompleted = true; - console.log('Stream marked complete by C# signal'); return { success: true, bufferCount: this.scheduler.getBufferCount() }; } catch (error) { return { success: false, error: (error as Error).message }; @@ -157,7 +155,6 @@ export class AudioPlayer { // Check if streaming is complete if (this.streamDecoder.isComplete) { this.streamingCompleted = true; - console.log('Stream complete'); } const canStart = this.streamDecoder.headerParsed && @@ -181,8 +178,6 @@ export class AudioPlayer { } try { - console.log('\n=== Starting streaming playback ==='); - // A backgrounded tab leaves AudioContext suspended. createBufferSource/start // against a suspended context produces no audio without throwing — the same // failure mode that was fixed for play() (resume path). Awaiting ensureReady() @@ -198,7 +193,6 @@ export class AudioPlayer { this.scheduler.playFromPosition(0); this.startProgressTracking(); - console.log('✅ Streaming playback started'); return { success: true }; } catch (error) { return { success: false, error: (error as Error).message }; @@ -218,7 +212,6 @@ export class AudioPlayer { // Don't restart if already playing if (this.isPlaying) { - console.log('Already playing, ignoring play()'); return { success: true }; } @@ -236,7 +229,6 @@ export class AudioPlayer { this.scheduler.playFromPosition(this.pausePosition); this.startProgressTracking(); - console.log(`â–ļī¸ Resumed from ${this.pausePosition.toFixed(3)}s`); return { success: true }; } catch (error) { return { success: false, error: (error as Error).message }; @@ -254,7 +246,6 @@ export class AudioPlayer { this.isPaused = true; this.stopProgressTracking(); - console.log(`â¸ī¸ Paused at ${this.pausePosition.toFixed(3)}s`); return { success: true }; } catch (error) { return { success: false, error: (error as Error).message }; @@ -268,7 +259,6 @@ export class AudioPlayer { this.resetState(); this.stopProgressTracking(); - console.log('âšī¸ Stopped'); return { success: true }; } catch (error) { return { success: false, error: (error as Error).message }; @@ -312,7 +302,6 @@ export class AudioPlayer { this.scheduler.playFromPosition(Math.max(0, bufferRelativePosition)); } - console.log(`🔍 Seeked within buffer to ${position.toFixed(3)}s (buffer-relative: ${bufferRelativePosition.toFixed(3)}s)`); return { success: true }; } catch (error) { return { success: false, error: (error as Error).message }; @@ -331,8 +320,6 @@ export class AudioPlayer { return { success: false, error: 'Cannot calculate byte offset' }; } - console.log(`🔍 Seek beyond buffer to ${position.toFixed(3)}s requires byte offset ${byteOffset}`); - // Signal that C# needs to request new stream from offset return { success: true, @@ -364,9 +351,6 @@ export class AudioPlayer { */ reinitializeFromOffset(totalStreamLength: number, seekPosition: number): AudioResult { try { - console.log(`\n=== Reinitializing for offset stream ===`); - console.log(`Seek position: ${seekPosition.toFixed(3)}s, Stream length: ${totalStreamLength}`); - // Stop current playback this.stopProgressTracking(); const wasPlaying = this.isPlaying; @@ -384,7 +368,6 @@ export class AudioPlayer { this.streamingStarted = false; // Will restart when new buffers arrive this.streamingCompleted = false; - console.log(`✅ Reinitialized for offset, was playing: ${wasPlaying}`); return { success: true }; } catch (error) { return { success: false, error: (error as Error).message }; diff --git a/DeepDrftPublic/Interop/audio/PlaybackScheduler.ts b/DeepDrftPublic/Interop/audio/PlaybackScheduler.ts index 577b83d..d4bfef3 100644 --- a/DeepDrftPublic/Interop/audio/PlaybackScheduler.ts +++ b/DeepDrftPublic/Interop/audio/PlaybackScheduler.ts @@ -43,7 +43,6 @@ export class PlaybackScheduler { */ addBuffer(buffer: AudioBuffer): void { this.buffers.push(buffer); - console.log(`đŸ“Ļ Buffer[${this.buffers.length - 1}] added: ${buffer.duration.toFixed(3)}s (total: ${this.getTotalDuration().toFixed(3)}s)`); } /** @@ -80,7 +79,6 @@ export class PlaybackScheduler { */ setPlaybackOffset(offset: number): void { this.playbackOffset = offset; - console.log(`📍 Playback offset set to ${offset.toFixed(3)}s`); } /** @@ -117,7 +115,6 @@ export class PlaybackScheduler { // returned silently, leaving the player stuck "playing" with no source // scheduled — a pause near the end followed by play never recovered. // Treat this as end-of-track so listeners (UI / end callback) fire. - console.log('Position at/beyond available buffers — ending playback'); this.isActive_ = false; this.playbackAnchorTime = 0; this.playbackAnchorPosition = 0; @@ -125,8 +122,6 @@ export class PlaybackScheduler { return; } - console.log(`â–ļī¸ Playing from ${position.toFixed(3)}s: buffer[${startBufferIndex}] offset=${offsetInBuffer.toFixed(3)}s`); - // Set timing anchors this.playbackAnchorPosition = position; this.playbackAnchorTime = this.contextManager.currentTime; @@ -192,8 +187,6 @@ export class PlaybackScheduler { // Schedule the source source.start(scheduleTime, offset); - console.log(`đŸŽĩ Scheduled buffer[${i}]: ${scheduleTime.toFixed(3)}s -> ${endTime.toFixed(3)}s`); - // Update for next buffer this.nextScheduleTime = endTime; this.nextBufferIndex = i + 1; @@ -201,7 +194,6 @@ export class PlaybackScheduler { // Check if we have enough lookahead const lookahead = this.nextScheduleTime - this.contextManager.currentTime; if (lookahead > lookaheadTarget) { - console.log(`📋 Lookahead: ${(lookahead * 1000).toFixed(0)}ms buffered`); break; } } @@ -229,7 +221,6 @@ export class PlaybackScheduler { // Check if all playback has finished if (this.scheduledSources.length === 0 && this.nextBufferIndex >= this.buffers.length) { - console.log('✓ Playback complete'); this.isActive_ = false; this.playbackAnchorTime = 0; this.playbackAnchorPosition = 0; @@ -247,7 +238,6 @@ export class PlaybackScheduler { this.playbackAnchorPosition = position; this.playbackAnchorTime = 0; this.nextScheduleTime = 0; - console.log(`â¸ī¸ Paused at ${position.toFixed(3)}s`); return position; } @@ -275,7 +265,6 @@ export class PlaybackScheduler { this.playbackAnchorTime = 0; this.nextBufferIndex = 0; this.nextScheduleTime = 0; - console.log('âŽī¸ Reset to start'); } /** @@ -290,7 +279,6 @@ export class PlaybackScheduler { this.nextBufferIndex = 0; this.nextScheduleTime = 0; this.playbackOffset = 0; - console.log('đŸ—‘ī¸ Scheduler cleared'); } /** @@ -305,7 +293,6 @@ export class PlaybackScheduler { this.nextBufferIndex = 0; this.nextScheduleTime = 0; // Note: playbackOffset is NOT reset - it will be set by the caller - console.log('đŸ—‘ī¸ Scheduler cleared for seek (offset preserved)'); } /** diff --git a/DeepDrftPublic/Interop/audio/SpectrumAnalyzer.ts b/DeepDrftPublic/Interop/audio/SpectrumAnalyzer.ts index 3314502..9dfe9a6 100644 --- a/DeepDrftPublic/Interop/audio/SpectrumAnalyzer.ts +++ b/DeepDrftPublic/Interop/audio/SpectrumAnalyzer.ts @@ -36,7 +36,6 @@ export class SpectrumAnalyzer { this.analyser.smoothingTimeConstant = 0.8; this.dataArray = new Float32Array(this.analyser.frequencyBinCount); - console.log(`SpectrumAnalyzer initialized: fftSize=${this.fftSize}, bins=${this.analyser.frequencyBinCount}`); return this.analyser; } diff --git a/DeepDrftPublic/Interop/audio/StreamDecoder.ts b/DeepDrftPublic/Interop/audio/StreamDecoder.ts index f8d4783..52ba777 100644 --- a/DeepDrftPublic/Interop/audio/StreamDecoder.ts +++ b/DeepDrftPublic/Interop/audio/StreamDecoder.ts @@ -84,7 +84,6 @@ export class StreamDecoder { this.headerBytesReceived = 0; this.headerSearchChunks = []; this.headerError = null; - console.log(`StreamDecoder initialized: expecting ${totalStreamLength} bytes`); } /** @@ -149,13 +148,10 @@ export class StreamDecoder { // without ever producing a valid header, the final processChunk will // mark streamComplete and the player will report no audio decoded; // that is the correct failure mode, since there is no audio to play. - console.log(`Header not yet parsable: ${this.headerBytesReceived} bytes accumulated`); return; } this.wavHeader = header; - console.log(`WAV format: ${header.bitsPerSample}-bit, ${header.channels}ch, ${header.sampleRate}Hz`); - console.log(`Header size: ${header.headerSize}, byteRate: ${header.byteRate}`); // Recreate AudioContext with correct sample rate if needed if (this.contextManager.sampleRate !== header.sampleRate) { @@ -174,7 +170,6 @@ export class StreamDecoder { if (audioData.length > 0) { this.addRawData(audioData); } - console.log(`Extracted ${audioData.length} bytes of audio data from header buffer`); // Header-search buffer no longer needed. this.headerSearchChunks = []; @@ -233,8 +228,6 @@ export class StreamDecoder { if (alignedSize <= 0) return null; const segmentOffset = this.processedBytes; - console.log(`\n--- Decoding segment ---`); - console.log(`Available: ${availableBytes} bytes, aligned size: ${alignedSize} bytes`); const rawSegment = this.extractAlignedData(alignedSize); const wavFile = this.createWavFile(rawSegment); @@ -244,7 +237,6 @@ export class StreamDecoder { // Advance only after a successful decode so a thrown timeout/decode // failure does not silently drop the segment. this.processedBytes += alignedSize; - console.log(`✓ Decoded: ${buffer.duration.toFixed(3)}s, ${buffer.numberOfChannels}ch`); return { buffer, duration: buffer.duration }; } catch (error) { // Re-throw typed errors so the outer drain loop in processChunk / @@ -471,6 +463,5 @@ export class StreamDecoder { this.headerError = null; // wavHeader will be reparsed from the new stream (server sends fresh header) this.wavHeader = null; - console.log(`StreamDecoder reinitialized for offset: expecting ${totalStreamLength} bytes`); } } diff --git a/DeepDrftPublic/Interop/wavutils.ts b/DeepDrftPublic/Interop/wavutils.ts index b60fd13..e169a29 100644 --- a/DeepDrftPublic/Interop/wavutils.ts +++ b/DeepDrftPublic/Interop/wavutils.ts @@ -75,13 +75,11 @@ class WavUtils { if (blockAlign !== channels * (bitsPerSample / 8)) return null; foundFmt = true; - console.log(`Found fmt chunk: ${bitsPerSample}-bit, ${channels}ch, ${sampleRate}Hz, format=${audioFormat}`); } else if (chunkId === 'data') { dataSize = chunkSize; headerSize = chunkOffset + 8; // Audio data starts after 'data' + size (8 bytes) foundData = true; - console.log(`Found data chunk at offset ${chunkOffset}, headerSize=${headerSize}, dataSize=${dataSize}`); } // Move to next chunk with proper alignment (chunks are word-aligned)