Created
July 11, 2020 14:35
-
-
Save x42/467acc2b3033705f28a778f86daec972 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gcc -o bpms bpms.c -Wall && ./bpms | |
#include<stdio.h> | |
int main (int argc, char** argv) | |
{ | |
// 176400: 2 2 2 2 3 3 5 5 7 7 == 2^4 * 3^2 * 5^2 * 7^2 | |
// 384000: 2 2 2 2 2 2 2 2 2 2 3 5 5 5 == 2^10 * 3^1 * 5^3 | |
int sr = 56448000; // 2^10 * 3^2 * 5^3 * 7^2 | |
int i = 0; | |
double pbpm = 0; | |
double dmax = 0; | |
double bmax = 0; | |
while (1) { | |
// assume shortest note is a 128th | |
double bpm = 60.0/128.0 * sr / ++i; | |
if (bpm > 400) { | |
pbpm = bpm; | |
continue; | |
} | |
double diff = pbpm - bpm; | |
if (diff > dmax) { | |
dmax = diff; | |
bmax = bpm; | |
} | |
pbpm = bpm; | |
if (bpm < 20) { | |
printf ("Min delta at %6.2f: %f\n", bpm, diff); | |
break; | |
} | |
} | |
printf ("Max delta at %6.2f: %f\n", bmax, dmax); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment