Afinador Visual
Afinador Visual
Afinador Visual
import './App.css';
const standardTuning = {
E2: 82.41,
A2: 110.00,
D3: 146.83,
G3: 196.00,
B3: 246.94,
E4: 329.63,
};
useEffect(() => {
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
const analyser = audioContext.createAnalyser();
analyser.fftSize = 2048;
const bufferLength = analyser.fftSize;
const dataArray = new Float32Array(bufferLength);
let d = 0;
while (c[d] > c[d + 1]) d++;
let maxval = -1, maxpos = -1;
let T0 = maxpos;
if (a) T0 = T0 - b / (2 * a);
}, []);
return (
<div className="tuner">
<h1>Visor de Afinação de Violão</h1>
<div className="dial">
<div className="needle" ref={needleRef}></div>
</div>
<p>Nota: {note} ({frequency.toFixed(2)} Hz)</p>
</div>
);
};
/* styles.css */
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f5f5f5;
margin: 0;
}
.tuner {
text-align: center;
}
.dial {
width: 200px;
height: 200px;
border: 2px solid #000;
border-radius: 50%;
position: relative;
margin: 0 auto 20px;
}
.needle {
width: 2px;
height: 100px;
background-color: red;
position: absolute;
top: 50%;
left: 50%;
transform-origin: bottom;
transform: rotate(0deg);
}