I've created a bash bpm to ms calculator

What other apps and distros do you use to round out your studio?

Moderators: MattKingUSA, khz

Post Reply
User avatar
sysrqer
Established Member
Posts: 2523
Joined: Thu Nov 14, 2013 11:47 pm
Has thanked: 320 times
Been thanked: 152 times
Contact:

I've created a bash bpm to ms calculator

Post by sysrqer »

I know there are numerous websites to do this but I wanted a quick way to calculate ms values from a bpm so I wrote my first proper bash script. When you run it you will be asked for a bpm and it will give you ms at various fractions.

For example:
./bpm
Enter bpm: 120
EVEN
1/1: 500 ms
1/2: 250 ms
1/4: 125 ms
1/6: 83 ms
1/8: 62 ms
1/10: 50 ms
1/12: 41 ms
1/14: 35 ms
1/16: 31 ms
ODD
1/3: 166 ms
1/5: 100 ms
1/7: 71 ms
1/9: 55 ms
1/11: 45 ms
1/13: 38 ms
1/15: 33 ms
This was really just a lesson bash for me than anything else. If you feel like it would be useful then you can download it here.
User avatar
sunrat
Established Member
Posts: 919
Joined: Wed Jul 22, 2020 2:08 pm
Has thanked: 151 times
Been thanked: 244 times

Re: I've created a bash bpm to ms calculator

Post by sunrat »

Neat little script. :wink: I usually just work out 60000/bpm in my head or with pen and paper (or KCalc :mrgreen: ). I saved your script anyway, never know when it may be handy.
glowrak guy
Established Member
Posts: 2325
Joined: Sat Jun 21, 2014 8:37 pm
Been thanked: 256 times

Re: I've created a bash bpm to ms calculator

Post by glowrak guy »

Hi, I'd like to know the bpm of Audacity's default playback speed, and what percentile of change from that,
would equal 1 bpm, which would be helpful using Hydrogen to add beats to a song in the creation progress,
as well as retrofitting beats to music made without them. Google searches of audacity speed topics cover
everything BUT that secret formula.

Audacity manual helps for some things, but also does not directly mention bpm

https://manual.audacityteam.org/man/cha ... e%20others.

(I'll be surprised if I'm not missing something obvious to the real world :oops: )
Cheers
j_e_f_f_g
Established Member
Posts: 2032
Joined: Fri Aug 10, 2012 10:48 pm
Been thanked: 358 times

Re: I've created a bash bpm to ms calculator

Post by j_e_f_f_g »

If you're going to be adding instruments triggered via MIDI, always remember to create an audible click track (preferably using a MIDI track) before you record any wave tracks. That will make it possible to later add MIDI in sync, without needing to resort to all these bpm to sample freq calculations/adjustments.

It will save you lots of time and trouble later.

Author of BackupBand at https://sourceforge.net/projects/backupband/files/
My fans show their support by mentioning my name in their signature.

tavasti
Established Member
Posts: 2057
Joined: Tue Feb 16, 2016 6:56 am
Location: Kangasala, Finland
Has thanked: 372 times
Been thanked: 209 times
Contact:

Re: I've created a bash bpm to ms calculator

Post by tavasti »

glowrak guy wrote: Fri Feb 04, 2022 9:58 am Hi, I'd like to know the bpm of Audacity's default playback speed, and what percentile of change from that,
would equal 1 bpm, which would be helpful using Hydrogen to add beats to a song in the creation progress,
as well as retrofitting beats to music made without them. Google searches of audacity speed topics cover
everything BUT that secret formula.

Audacity manual helps for some things, but also does not directly mention bpm
Yeah, and that same problem is also in instruments! None of my guitars have bpm adjustment, not even fancy Line6 Variax. That is most likely reason they are mostly out of tempo.

Linux veteran & Novice musician

Latest track: https://www.youtube.com/watch?v=ycVrgGtrBmM

merlyn
Established Member
Posts: 1392
Joined: Thu Oct 11, 2018 4:13 pm
Has thanked: 168 times
Been thanked: 247 times

Re: I've created a bash bpm to ms calculator

Post by merlyn »

glowrak guy wrote: Fri Feb 04, 2022 9:58 am Hi, I'd like to know the bpm of Audacity's default playback speed, and what percentile of change from that,
would equal 1 bpm, which would be helpful using Hydrogen to add beats to a song in the creation progress,
as well as retrofitting beats to music made without them. Google searches of audacity speed topics cover
everything BUT that secret formula.
It depends on the bpm that is started with. Playback speed is changing the time in seconds, not in bars and beats.

As an example if 60bpm is started with and played back at 50% the resulting bpm is 30bpm. If 120bpm is started with and played back at 50% the resulting tempo is 60bpm. If 100bpm is started with the resulting tempo is equal to the playback percentage e.g. 75% results in 75bpm.

To calculate the percentage : ((new tempo)/(old tempo)) * 100

To check that with an old tempo of 120bpm and a new tempo of 60bpm : 60/120 * 100 = 50
glowrak guy
Established Member
Posts: 2325
Joined: Sat Jun 21, 2014 8:37 pm
Been thanked: 256 times

Re: I've created a bash bpm to ms calculator

Post by glowrak guy »

Thanks for the useful tips! I shall try to upgrade my logic, math, common-sense, and rtfm skills for 2022 :)
User avatar
GMaq
Established Member
Posts: 2806
Joined: Fri Sep 25, 2009 1:42 pm
Has thanked: 525 times
Been thanked: 563 times

Re: I've created a bash bpm to ms calculator

Post by GMaq »

@sysrqer

Would it be OK with you if I incorporated this into the AV Linux Assistant Utilities?
User avatar
sysrqer
Established Member
Posts: 2523
Joined: Thu Nov 14, 2013 11:47 pm
Has thanked: 320 times
Been thanked: 152 times
Contact:

Re: I've created a bash bpm to ms calculator

Post by sysrqer »

GMaq wrote: Mon Feb 07, 2022 3:19 pm @sysrqer

Would it be OK with you if I incorporated this into the AV Linux Assistant Utilities?
Absolutely, if you think it's good enough!
User avatar
GMaq
Established Member
Posts: 2806
Joined: Fri Sep 25, 2009 1:42 pm
Has thanked: 525 times
Been thanked: 563 times

Re: I've created a bash bpm to ms calculator

Post by GMaq »

It's 'simply perfect'! Thanks!
Post Reply