Forums > MaxMSP

mp3 hassle – automatically setting buffer size from import!

May 16 2009 | 4:15 pm

Hi all,

Ive been making a pretty good mp3 player by using buffer~, info~ and play~.

Ive noticed an issue with import and read. Firstly the read function must be used before an import otherwise the buffer will not load the audio. Once read had been used with a .wav file I can then import a mp3 into the buffer. The buffer will then automatically adjust to the correct length for the mp3. If I then use a read function with wav after the buffer will remain at the length of the mp3 previously loaded. This only happens when switching from wav to mp3 and back again.

Does any one know how to get round this, without having to manually enter the info, thanks in advance.

Ahhhhhhhhhhhh! MP3 sucks.

May 16 2009 | 5:08 pm

ahhh sod it!

some one please make it betterr. LOL

— Pasted Max Patch, click to expand. —


May 16 2009 | 5:45 pm

Use "replace" instead of "read" to automatically resize the buffer to the length of the audio file. If you look at the [buffer~] reference page it will explain all the different messages you can send to the object.


May 16 2009 | 5:48 pm

Please take a look at the buffer~ entry in the manual, check the message description for read and import.

While the help patches are a good start, you should always refer to the manual for detailed behaviour if things does not work out as you expected.

May 16 2009 | 5:51 pm

Simultaneous post Wink.

May 16 2009 | 5:53 pm

High five!


May 16 2009 | 5:58 pm

I only noticed that command after posting. And yes it does work perfectly thanks very much. Will look closer next time.

Whilst u are all here on the subject. I intend to try and make a audio list slash library. How would I approach trying to detect a format of file, so I could somehow automatically use replace or import depending on format.

Also can I get the length of file without adding to a buffer then using info~?

Am I using the best method for mp3 functionality also. Is grove better? Or maybe spigot~ via the quicktime stuff? Any opinions are welcome.

Just wanna consider the best options really.

Thanks peps.

May 16 2009 | 6:08 pm

RabidRaja, thanks very much. Just what I needed. I have been using some over complicated ways to achieve what u did with a few objects!

Thanks very much.

May 16 2009 | 6:10 pm

Here’s a method that uses [regexp] to check to see if the filename ends in ".mp3" if it does then it is formatted for the "import" message and if not for the "replace" message.


— Pasted Max Patch, click to expand. —
May 16 2009 | 6:22 pm

Keep em coming, some great techniques. Thanks!

May 17 2009 | 3:23 am


Is there a way to filter only .mp3 files?


Luis Marques

May 17 2009 | 4:42 am

The example I posted above will show only .mp3 files from the middle outlet.


May 17 2009 | 4:45 am


yes, that does do that. but in objects like "folder" or "umenu"?


Luis Marques

May 17 2009 | 4:50 am

Look at the help file and you will notice you need the filetype message. These can be found in cycling ’74 > init > max-fileformats.txt or for individual files by looking at the right outlet of [dropfile].


May 17 2009 | 4:54 am

i’ve already done that… and nothing appears in the right outlet from dropfile object when i drop an mp3 file, and there is no mp3 code in max-fileformats.txt. I hope there’s a new way to do that…


Luis Marques

May 17 2009 | 4:57 am

I just tried a few.p3 files and got "MP3 " and "MPG3" as the results, perhaps give those a try.


May 17 2009 | 4:58 am


i will.


Luis Marques

May 17 2009 | 5:07 am


i tried those mp3 codes, but only work whit some of them, not all.
I dropped my iTunes Library to object folder, and have luck on a few albums…

Thanks for your time,

Luis Marques

May 17 2009 | 12:16 pm

Did you try the sfinfo~ object? Not sure if it works for compressed files.

May 17 2009 | 6:20 pm

Dam! That is rubbish. Same problem here too.

May 17 2009 | 6:36 pm

This is particularly disappointing!

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

Forums > MaxMSP