Forums > MaxMSP

BPM counter

December 11, 2006 | 12:42 am

Hi Guys,

Just wondering if there’s anyway of displaying the BPM of an audio sample from the groove~ object?

Thanks in advance!

Dave


December 11, 2006 | 12:50 am

>Just wondering if there’s anyway of displaying the BPM of an audio sample from the groove~ object?

Check out [info~], which reports information about a file loaded into a particular buffer, including the total time in ms. If you supply buffer~ with a -1 argument for length, then it will resize itself based on the sample that you load.

As long as you know how many beats are in the sample you’ve loaded, you can use this simple formula:

bpm = 60,000 / (length of the sample in ms/ # of beats in the sample)


December 11, 2006 | 10:53 am

Hi Thanks for that, the problem is that i don’t have any control over what sample is being loaded. It’s to go onto a mixer that the user can drag and drop audio files to play! Ideally i need it to somehow be calulated from the groove~ object and not the buffer, then it shouldn’t matter what sample is being played!

Thanks again,

Dave


December 11, 2006 | 5:15 pm

Quote: comedydave wrote on Mon, 11 December 2006 03:53
—————————————————-
> Hi Thanks for that, the problem is that i don’t have any control over what sample is being loaded. It’s to go onto a mixer that the user can drag and drop audio files to play! Ideally i need it to somehow be calulated from the groove~ object and not the buffer, then it shouldn’t matter what sample is being played!
—————————————————-

What you’re asking for is, as far as I know, not possible. In order to calculate BPM you need to know both how long the file is, and how many beats it contains. This is why a program like Recycle will insist that you tell it how many beats are in your sample before they will let you save/export.

Another thing to keep in mind is that the [groove~] object is really just a reference to a [buffer~]. It doesn’t contain any sample information itself… it’s more of a glorified way to read audio samples out of the buffer. Likewise, the [info~] object that I mentioned in my previous post is another way of getting information from a buffer, such as the length of the sample.

One way to accomplish what you’re after would be to make a dialog box pop up when a new sample is loaded asking how many beats it is. You could store this info, along with the filename, in a coll object so that it is only asked when a brand-new sample is loaded. Or, you could require that the user put the number of beats in the filename (i.e. DrumLoop1_16.wav) and then extract that information when the file is loaded. Either way, you will somehow need to tell Max how many beats are in the file before you can get a BPM reading.


December 11, 2006 | 7:34 pm

There are a few ways to actually analyze the audio file to extract
beat/timing info, but it’s going to come from analyzing the file
directly, not from info that the groove~ object might make available.

By doing some FFT work, detecting transients (if mainly a percussive
track), or other large-scale transitions in the file and calculating
timing, it is possible. Not easy, but possible.

On Dec 11, 2006, at 10:15 AM, Dan wrote:

>
> Quote: comedydave wrote on Mon, 11 December 2006 03:53
> —————————————————-
>> Hi Thanks for that, the problem is that i don’t have any control
>> over what sample is being loaded. It’s to go onto a mixer that the
>> user can drag and drop audio files to play! Ideally i need it to
>> somehow be calulated from the groove~ object and not the buffer,
>> then it shouldn’t matter what sample is being played!
> —————————————————-
>
> What you’re asking for is, as far as I know, not possible. In
> order to calculate BPM you need to know both how long the file is,
> and how many beats it contains. This is why a program like Recycle
> will insist that you tell it how many beats are in your sample
> before they will let you save/export.
>

—-
Steven M. Miller

Associate Professor of Contemporary Music
College of Santa Fe
Contemporary Music Program
1600 St. Michaels Drive
Santa Fe NM 87505
http://pubweb.csf.edu/~smill
(505) 473-6197

SFIFEM
Atrium Sound Space
OVOS


December 12, 2006 | 1:43 pm

Dave Hardy wrote:
> Hi Thanks for that, the problem is that i don’t have any control over
> what sample is being loaded. It’s to go onto a mixer that the user
> can drag and drop audio files to play! Ideally i need it to somehow
> be calulated from the groove~ object and not the buffer, then it
> shouldn’t matter what sample is being played!

The sample has to be analysed, nothing groove~ can do. You need somthing
like bbcut/recycle, but that’s not for Max yet as far as I know…
And if I sing into it it won’t work either… ;-)

One thing considering is to let the user tell how many beats it has.
Some mp3 tags do contain BPM information…

Stefan


Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
– _|_)—-|—–()————–
———-()——–www.ccmix.com


Viewing 6 posts - 1 through 6 (of 6 total)