Calculate note freq when root freq changes
This commit is contained in:
parent
f39fb3214e
commit
cb25caee08
1 changed files with 4 additions and 1 deletions
|
@ -67,16 +67,19 @@ export default function Main() {
|
||||||
const setRootValue: ChangeEventHandler<HTMLInputElement> = (e) => {
|
const setRootValue: ChangeEventHandler<HTMLInputElement> = (e) => {
|
||||||
const newRoot = parseInt(e.target.value);
|
const newRoot = parseInt(e.target.value);
|
||||||
if (!isNaN(newRoot)) setRoot(newRoot);
|
if (!isNaN(newRoot)) setRoot(newRoot);
|
||||||
|
const frequency = calculateFrequency(newRoot, note);
|
||||||
|
if (frequency != null) setFrequency(frequency.toFixed(3));
|
||||||
};
|
};
|
||||||
|
|
||||||
const setNoteValue: ChangeEventHandler<HTMLInputElement> = (e) => {
|
const setNoteValue: ChangeEventHandler<HTMLInputElement> = (e) => {
|
||||||
setNote(e.target.value);
|
setNote(e.target.value);
|
||||||
const frequency = calculateFrequency(root, e.target.value);
|
const frequency = calculateFrequency(root, note);
|
||||||
if (frequency != null) setFrequency(frequency.toFixed(3));
|
if (frequency != null) setFrequency(frequency.toFixed(3));
|
||||||
};
|
};
|
||||||
|
|
||||||
const setFrequencyValue: ChangeEventHandler<HTMLInputElement> = (e) => {
|
const setFrequencyValue: ChangeEventHandler<HTMLInputElement> = (e) => {
|
||||||
setFrequency(e.target.value);
|
setFrequency(e.target.value);
|
||||||
|
|
||||||
const newFrequency = parseFloat(e.target.value);
|
const newFrequency = parseFloat(e.target.value);
|
||||||
if (!isNaN(newFrequency)) {
|
if (!isNaN(newFrequency)) {
|
||||||
const noteDescriptor = calculateNote(root, newFrequency);
|
const noteDescriptor = calculateNote(root, newFrequency);
|
||||||
|
|
Loading…
Reference in a new issue