Page 1 of 1

I've created a bash bpm to ms calculator

Posted: Fri Jan 28, 2022 7:40 pm
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.

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

Posted: Sat Jan 29, 2022 4:16 am
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.

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

Posted: Fri Feb 04, 2022 9:58 am
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

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

Posted: Fri Feb 04, 2022 12:18 pm
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.

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

Posted: Fri Feb 04, 2022 12:25 pm
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.

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

Posted: Fri Feb 04, 2022 2:49 pm
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

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

Posted: Sun Feb 06, 2022 12:11 am
by glowrak guy
Thanks for the useful tips! I shall try to upgrade my logic, math, common-sense, and rtfm skills for 2022 :)

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

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

Would it be OK with you if I incorporated this into the AV Linux Assistant Utilities?

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

Posted: Mon Feb 07, 2022 6:24 pm
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!

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

Posted: Mon Feb 07, 2022 6:59 pm
by GMaq
It's 'simply perfect'! Thanks!