import { Card, CardContent, CardHeader } from "@/components/ui/card"; import { Spinner } from "@/components/ui/spinner"; import { Button } from "@/components/ui/button"; import { Activity, Waves, Radio, TrendingUp, FileAudio, Clock, Gauge, HardDrive } from "lucide-react"; import type { AnalysisResult } from "@/types/api"; interface AudioAnalysisProps { result: AnalysisResult | null; analyzing: boolean; onAnalyze?: () => void; showAnalyzeButton?: boolean; filePath?: string; } export function AudioAnalysis({ result, analyzing, onAnalyze, showAnalyzeButton = true, filePath }: AudioAnalysisProps) { if (analyzing) { return (
Analyzing audio quality...
); } if (!result && showAnalyzeButton) { return (

Audio Quality Analysis

Verify the true lossless quality of downloaded files

{onAnalyze && ()}
); } if (!result) { return null; } const formatDuration = (seconds: number) => { const mins = Math.floor(seconds / 60); const secs = Math.floor(seconds % 60); return `${mins}:${secs.toString().padStart(2, '0')}`; }; const formatNumber = (num: number) => { return num.toFixed(2); }; const formatFileSize = (bytes: number): string => { if (bytes === 0) return "0 B"; const k = 1024; const sizes = ["B", "KB", "MB", "GB"]; const i = Math.floor(Math.log(bytes) / Math.log(k)); return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + " " + sizes[i]; }; const nyquistFreq = result.sample_rate / 2; return ( {filePath && (

{filePath}

)}
Sample Rate: {(result.sample_rate / 1000).toFixed(1)} kHz
Bit Depth: {result.bit_depth}
Channels: {result.channels === 2 ? "Stereo" : result.channels === 1 ? "Mono" : `${result.channels}`}
Duration: {formatDuration(result.duration)}
Nyquist: {(nyquistFreq / 1000).toFixed(1)} kHz
{result.file_size > 0 && (
Size: {formatFileSize(result.file_size)}
)}
Dynamic Range: {formatNumber(result.dynamic_range)} dB
Peak: {formatNumber(result.peak_amplitude)} dB
RMS: {formatNumber(result.rms_level)} dB
Samples: {result.total_samples.toLocaleString()}
); }