import React, { useState } from 'react'; import { X, Volume2, VolumeX, ChevronDown, ChevronUp, Mic, MicOff, Sun, Moon, Monitor, Clock } from 'lucide-react'; import type { AppSettings } from '../types/SettingsTypes'; import { MIC_SENSITIVITY_DB_RANGE, MIC_DEFAULT_SENSITIVITY } from '../AppConfig'; import type { MicrophoneDebugInfo } from '../hooks/usePitchDetector'; interface SettingsModalProps { isOpen: boolean; onClose: () => void; settings: AppSettings; onUpdateSettings: (s: AppSettings) => void; audioLevel?: number; debugInfo?: MicrophoneDebugInfo | null; isListening?: boolean; onMicToggle?: () => void; } // Level meter component const LevelMeter: React.FC<{ level: number; isActive: boolean }> = ({ level, isActive }) => { // Convert RMS to dB for display, then normalize to 0-100% // RMS of 0.001 = -60dB, RMS of 1.0 = 0dB // `level` is already EMA-smoothed in the detection loop — no CSS transition // here (a transition on a value that changes every frame gets interrupted // 60x/sec, which Safari/WebKit handles by leaving the bar stuck). const db = level > 0 ? 20 * Math.log10(level) : -120; // Map full range from -100dB to 0dB => 0% to 100% // This ensures even very quiet inputs (-80 or -90dB) show on the meter const minDb = MIC_SENSITIVITY_DB_RANGE.max; // e.g. -100 const maxDb = 0; // 0dB is full scale const percentage = Math.max(0, Math.min(100, ((db - minDb) / (maxDb - minDb)) * 100)); return (
Removes the "Good!" overlay to allow faster playing.
{settings.gameMode === 'ear_training' ? "Automatically plays the note audio (Required for Ear Training)." : "Automatically plays the note audio when a new note appears."}
{/* Reference note duration */}Holds the next reference note until your instrument has gone quiet, so a still-ringing string can't mask it. (Requires the microphone.)
{isListening ? 'Microphone is active and listening for notes.' : 'Enable microphone to detect your playing.'}
Adjust if notes are not detected (increase/right) or if background noise triggers notes (decrease/left).
Enable microphone to see audio levels
)}