MUCOM88のテンポ計算するやつ

2022-01-31追記 ♩=… を指定するだけの簡易版作った。普通はこれで十分な気が。

https://est.ceres.ne.jp/tmp/mucom-tempo-easy.html


毎回計算式探すの面倒なので作った。1万年ぶりにJavaScript書いたので合ってるかわからんけど、計算はできてる気がする。

https://est.ceres.ne.jp/tmp/mucom-tempo.html

上記ページで使うもよし、適当にコピーして改造するもよし。

ソース

<!DOCTYPE html>
<html lang="ja">
<head>
<title>MUCOM88のテンポ計算するやつ</title>
<!-- by Est Suzumenomiya, BSDL -->
<style>
#error { color: red; }
form { font-size: 150%; margin-bottom: 1.5em; }
input { font-size: 100%; }
th,td { border: solid 1px; padding: 0.5em 1.0em; }
table { border-collapse: collapse; }
</style>
<script>
function mucomTempo(c, t) {
    if (t > 0 && c > 0 && c < 256) {
        return Math.round(256 - (832000 / (c * t)));
    }
    return -1;
}
function update_sub(c, mt, suffix) {
    mucom = document.getElementById("mucom_" + suffix);
    ref = document.getElementById("ref_" + suffix);
    document.getElementById("c").textContent = "C" + c;
    if (mt > 0 && mt <= 252) {
        mucom.textContent = "t" + mt
        ref.textContent = Math.round((832000 / (c * (256 - mt))) * 1000) / 1000;
    } else {
        mucom.textContent = "指定不可 (" + mt + ")";
        ref.textContent = "";
    }
}
function update() {
    c = parseInt(document.form.C.value);
    document.form.C.value = c;
    t = parseFloat(document.form.T.value);
    err = document.getElementById("error");
    mt = mucomTempo(c, t);
    if (mt > 0) {
        err.textContent = ""
        update_sub(c, mt - 1, "m1");
        update_sub(c, mt, "0");
        update_sub(c, mt + 1, "p1");
    } else {
        err.textContent = "値が不正です"
    }
}
</script>
</head>
<body onload="update();">
<h1>MUCOM88のテンポ計算するやつ</h1>
<form name="form">
&#9833;= <input type="number" name="T" min="1" max="300" value="130" onChange="update();"/>,
C<input type="number" name="C" min="1" max="255" value="128" onChange="update();"/> <span id="error"></span>
</form>
<table>
<tr><th></th><th>tコマンド</th><th>実際のテンポ</th></tr>
<tr><td></td><td id="mucom_m1"></td><td id="ref_m1"></td></tr>
<tr><td><span id="c"></span> &rArr;</td><td id="mucom_0"></td><td id="ref_0"></td></tr>
<tr><td></td><td id="mucom_p1"></td><td id="ref_p1"></td></tr>
</table>
</body>
</html>

おまけ