0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

特定のBPMのn分音符の長さを求める方法

Posted at

前提

  • BPM とは Beats Per Minute の略で、1 分間にどれだけの単位音符が鳴るかでテンポを示す指標

    • 4分音符を基準とすることが多い。また、この記事では4分音符を基準とする
  • 音符の分割数 $n$ について、この記事では次のとおり定義する

    • $n$ は整数で、範囲は $1 \leq n \leq 192$
    • 全音符は 「1分音符」と読み替え、$n$ 分音符はこれを $n$ 分割したものとする
    • $n$ 連符も同様に 「$n$分音符」と読み替える。 e.g. $16$ 分音符の3連符→ $24$ 分音符

計算方法

まず、変数を以下の通り定義する。

  • $T$ ... Tempo より。BPMの値を指す
  • $n$ ... n 分音符より。 音符の分割数を指す
  • $L_n$ ... Length より。音符の長さを指す。下付き文字が定数 $a$ の場合、$a$ 分音符を指す

$4$ 分音符の長さは、BPM の定義より次のように表される。ここで、$4$ 分音符の長さ(秒)を $L_4$ と表すこととする。

$$L_4[s] = \frac{60}{T} $$

$2$ 分音符の場合は $L_2[s] = \frac{120}{T} $、全音符($1$ 分音符)の場合は $L_1[s] = \frac{240}{T} $ と表される。$64$ などといった大きな分割数でも扱いやすいように単位を $ms$ にし、以下のように一般化ができる。

$$L_n[ms] = \frac{240000 \div n}{T}$$

C++ における実装例

#include <iostream>
usnig namespace std;

int main() {
    int t = 0, n = 0;
    
    cout << "Please input BPM -> ";
    do {
        cin >> t;
        if(t > 0) break;
        cout << "Please input BPM correctly! ->"
    } while(t <= 0);

    cout << "Please input the note division -> ";
    do {
        cin >> n;
        if(n > 0) break;
        cout << "Please input the note division correctly! ->"
    } while(n <= 0);

    cout << "Note length: " << (240000 / n) / t << endl;

    return 0;
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?