mp3 hassle - automatically setting buffer size from import!

MadBeat's icon

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.

MadBeat's icon

ahhh sod it!

some one please make it betterr. LOL

Max Patch
Copy patch and select New From Clipboard in Max.

thanks!

Luke Hall's icon

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.

lh

Hans Höglund's icon

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.

Hans Höglund's icon

Simultaneous post .

Luke Hall's icon

High five!

lh

MadBeat's icon

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.

MadBeat's icon

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.

Luke Hall's icon

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.

lh

Max Patch
Copy patch and select New From Clipboard in Max.

MadBeat's icon

Keep em coming, some great techniques. Thanks!

Luis Marques's icon

hi,

Is there a way to filter only .mp3 files?

Thanks

Luis Marques

Luke Hall's icon

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

lh

Luis Marques's icon

hi,

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

Thanks

Luis Marques

Luke Hall's icon

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].

lh

Luis Marques's icon

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

thanks

Luis Marques

Luke Hall's icon

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

lh

Luis Marques's icon

OK.

i will.

Thanks

Luis Marques

Luis Marques's icon

hi,

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

Hans Höglund's icon

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

MadBeat's icon

Dam! That is rubbish. Same problem here too.

MadBeat's icon

This is particularly disappointing!