import { X, Activity, Zap, Server, ShieldCheck, Waves, Wifi, ArrowDown, ArrowUp } from "lucide-react"; import { useEffect, useState, useRef } from "react"; interface AudioQuality { format: string; sampleRate: number; bitDepth?: number; bitrate: number; channels: number; codec?: string; } interface TechSpecsProps { isOpen: boolean; onClose: () => void; quality: AudioQuality | null; trackTitle: string; } export default function TechSpecs({ isOpen, onClose, quality, trackTitle }: TechSpecsProps) { const [bitrateHistory, setBitrateHistory] = useState(new Array(40).fill(0)); const [currentKbps, setCurrentKbps] = useState(0); const [bufferHealth, setBufferHealth] = useState(100); const [networkStats, setNetworkStats] = useState({ download: 0, upload: 0 }); const canvasRef = useRef(null); // Simulate live bitrate fluctuation around the target bitrate useEffect(() => { if (!isOpen || !quality) return; const baseBitrate = quality.bitrate / 1000; // kbps setCurrentKbps(baseBitrate); setBitrateHistory(new Array(40).fill(baseBitrate)); const interval = setInterval(() => { // Fluctuate +/- 5% const fluctuation = baseBitrate * 0.05 * (Math.random() - 0.5); const newValue = baseBitrate + fluctuation; setCurrentKbps(prev => newValue); setBitrateHistory(prev => [...prev.slice(1), newValue]); // Random buffer fluctuation setBufferHealth(prev => Math.min(100, Math.max(98, prev + (Math.random() - 0.5)))); // Simulate Network Traffic (Bursty Download, Consistent Upload) setNetworkStats({ download: Math.random() > 0.6 ? Math.floor(Math.random() * 2500) + 800 : 0, // kbps upload: Math.floor(Math.random() * 40) + 10 // kbps }); }, 100); return () => clearInterval(interval); }, [isOpen, quality]); // Draw Graph useEffect(() => { const canvas = canvasRef.current; if (!canvas || !quality) return; const ctx = canvas.getContext('2d'); if (!ctx) return; const width = canvas.width; const height = canvas.height; const baseBitrate = quality.bitrate / 1000; const range = baseBitrate * 0.2; // Zoom in range ctx.clearRect(0, 0, width, height); // Gradient const gradient = ctx.createLinearGradient(0, 0, 0, height); gradient.addColorStop(0, 'rgba(74, 222, 128, 0.5)'); // Green-400 gradient.addColorStop(1, 'rgba(74, 222, 128, 0)'); ctx.beginPath(); ctx.moveTo(0, height); bitrateHistory.forEach((val, i) => { const x = (i / (bitrateHistory.length - 1)) * width; // Map value to height (inverted) // min = base - range, max = base + range const normalized = (val - (baseBitrate - range)) / (range * 2); const y = height - (normalized * height); ctx.lineTo(x, y); }); ctx.lineTo(width, height); ctx.closePath(); ctx.fillStyle = gradient; ctx.fill(); // Line ctx.beginPath(); bitrateHistory.forEach((val, i) => { const x = (i / (bitrateHistory.length - 1)) * width; const normalized = (val - (baseBitrate - range)) / (range * 2); const y = height - (normalized * height); if (i === 0) ctx.moveTo(x, y); else ctx.lineTo(x, y); }); ctx.strokeStyle = '#4ade80'; ctx.lineWidth = 2; ctx.stroke(); }, [bitrateHistory, quality]); if (!isOpen) return null; return (
{/* Header */}

AUDIO ENGINE

{quality ? 'DIRECT SOUND • EXCLUSIVE MODE' : 'INITIALIZING...'}

{/* Content */} {quality ? (
{/* Live Monitor */}
Live Bitrate {currentKbps.toFixed(0)} kbps
{/* Signal Path / Stats Grid */}
{/* Source Stats */}

Source

Codec {quality.codec || quality.format}
Sample Rate {quality.sampleRate / 1000} kHz
Bit Depth {quality.bitDepth || 24}-bit
{/* Processing Stats */}

Processing

Integrity Bit-Perfect
Dynamic Range 14 dB (Est)
Loudness -14.2 LUFS
{/* Network & Buffer */}
{/* Network Stream */}
Network Stream
{networkStats.download > 0 ? (networkStats.download / 1000).toFixed(1) : '0.0'} MB/s {networkStats.upload} kbps
Stream Buffer
{bufferHealth.toFixed(1)}%
Output Device
Default Audio Interface
) : (
HANDSHAKING WITH AUDIO CORE...
)} {/* Footer */}
Quantum Audio Engine v2.4.0 • 64-bit Floating Point
); }