import React from 'react'; import './TuningMeter.css'; interface TuningMeterProps { cents: number; // Deviation in cents from nearest note (-50 to +50 usually) noteName: string; // The detected note name (e.g. "A4") } export const TuningMeter: React.FC = ({ cents, noteName }) => { // Clamp cents for display (-50 to 50) const clampedCents = Math.max(-50, Math.min(50, cents)); // Map -50..50 to 0..100% for position // -50 cents -> 0% // 0 cents -> 50% // 50 cents -> 100% const positionPercent = ((clampedCents + 50) / 100) * 100; // Color determination let statusClass = 'neutral'; if (Math.abs(cents) < 5) { statusClass = 'perfect'; // Green } else if (Math.abs(cents) < 15) { statusClass = 'good'; // Green-ish } else if (Math.abs(cents) < 30) { statusClass = 'okay'; // Yellow } else { statusClass = 'poor'; // Red } return (
-50
0
+50
{/* Center Marker Line */}
{/* The Needle/Indicator */}
{noteName} {cents > 0 ? '+' : ''}{Math.round(cents)} ct
); };