>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)
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!
> 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.