Calculate note freq when root freq changes

main
Charlotte Som 2023-03-06 02:19:08 +00:00
parent f39fb3214e
commit cb25caee08
1 changed files with 4 additions and 1 deletions

View File

@ -67,16 +67,19 @@ export default function Main() {
const setRootValue: ChangeEventHandler<HTMLInputElement> = (e) => {
const newRoot = parseInt(e.target.value);
if (!isNaN(newRoot)) setRoot(newRoot);
const frequency = calculateFrequency(newRoot, note);
if (frequency != null) setFrequency(frequency.toFixed(3));
};
const setNoteValue: ChangeEventHandler<HTMLInputElement> = (e) => {
setNote(e.target.value);
const frequency = calculateFrequency(root, e.target.value);
const frequency = calculateFrequency(root, note);
if (frequency != null) setFrequency(frequency.toFixed(3));
};
const setFrequencyValue: ChangeEventHandler<HTMLInputElement> = (e) => {
setFrequency(e.target.value);
const newFrequency = parseFloat(e.target.value);
if (!isNaN(newFrequency)) {
const noteDescriptor = calculateNote(root, newFrequency);