[ubuntu-studio-users] BPM to ms calculation by command line

Ralf Mardorf ralf.mardorf at alice-dsl.net
Fri Feb 3 05:01:21 UTC 2017


Hi,

if you also should dislike to use a calculator each time you want to
sync beats per minute to milliseconds, the following script might be
useful for you, too.

Run

  bpm2ms <beats_per_minute>

just running

  bpm2ms

without a value defaults to 120 beats per minute.

I wrote it some minutes ago, I'm not only tired of using the
calculator, but was really sleepy, too. Maybe I made one or the other
typo.

With root privileges store the script as /usr/local/bin/bpm2ms and then
run

sudo chmod a+x /usr/local/bin/bpm2ms
sudo apt update
sudo apt install apcalc

[weremouse at moonstudio ~]$ bpm2ms --help
Usage:
  bpm2ms <BPM>
Version 2017-Feb-03 Rocketmouse
[weremouse at moonstudio ~]$ bpm2ms 60 | head -1
(60000ms/60BPM)*4*(1/1)= 4000ms
[weremouse at moonstudio ~]$ bpm2ms | head -9
(60000ms/120BPM)*4*(1/1)= 2000ms
(60000ms/120BPM)*4*(3/4)= 1500ms
(60000ms/120BPM)*4*(1/2)= 1000ms
(60000ms/120BPM)*4*(1/4)= 500ms
(60000ms/120BPM)*4*(1/8)= 250ms
(60000ms/120BPM)*4*(1/12)= ~166.66666666666666666667ms
(60000ms/120BPM)*4*(1/16)= 125ms
(60000ms/120BPM)*4*(1/24)= ~83.33333333333333333333ms
(60000ms/120BPM)*4*(1/32)= 62.5ms
[weremouse at moonstudio ~]$ ls -l /usr/local/bin/bpm2ms 
-rwxr-xr-x 1 root root 508 Feb  3 05:15 /usr/local/bin/bpm2ms

Regards,
Ralf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bpm2ms
Type: application/octet-stream
Size: 508 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/ubuntu-studio-users/attachments/20170203/9484a761/attachment.obj>


More information about the ubuntu-studio-users mailing list