Last active
November 1, 2023 17:41
-
-
Save bingos/609cc13bdffe2e3aacce7fe520b29577 to your computer and use it in GitHub Desktop.
BPM to MS Calculator
This file contains 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
#!/usr/bin/env perl | |
use 5.012; | |
no crap; | |
use Math::BigFloat; | |
sub round { | |
return Math::BigFloat->new(shift)->bfround(1); | |
} | |
my $bpm = shift @ARGV; | |
$bpm = 120 unless $bpm && $bpm =~ m!^\d+$!; | |
my $ms = 60000 / $bpm; | |
say sprintf "Quarter note (one beat):\t%d ms", round( $ms ); | |
say sprintf "Dotted eighth note (3/4):\t%d ms", round( $ms / 4 * 3 ); | |
say sprintf "Eighth note (half beat):\t%d ms", round( $ms / 2 ); | |
say sprintf "Sixteenth note (quarter):\t%d ms", round( $ms / 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment