Resizing a buffer according to the file it will load
I’m really desperate with this one:
I’m importing Mp3 files into a buffer, for the very first Mp3 file the buffer will automatically set itself to the correct size for it.
But if I import another file into the same buffer~ again it will stay at the length of the first file.
I don’t know how I can find out inside Max how long the file that shall get loaded next would be so I cannot just set the length with the "size" message…
Is there ANY way to get the buffer~ to resize before it loads?
I cannot use "replace" because it seems that "replace" can ONLY be used with wav or aiff files :( …
(@#Error: buffer~ | cannot open parser for this file)
I would be really glad for some help, thanks.
But theimport message seems to still work "fine" with Max 6.1.4. But as replace it won’t change the number of channels (see this topic)
Thanks for the response, but I don’t really understand how this relates:
I am using the "import" message and it does size the buffer correct for only the first time, afterwards it will not resize the buffer when using the "import"-message on the same buffer with another file again.
I am also using the newest version of Max.
When I try to use "replace" with any mp3 file it always gives me the error message: cannot open parser for this file
This does also happen when I do it in the manner of: replace 0 -11 //As the guy in the linked post said it would work… Still that error… :/
[quote] import filename [list]
The filename may be followed by a float indicating a starting time in the file, in milliseconds, to begin reading. (The beginning of the file is 0.)
The buffer~ object uses QuickTime (…)
The starting time may be followed by a second argument – a floating point value that specifies the duration of sound, in milliseconds, to be read into buffer~. This duration overrides the current size of the object’s sample memory. If the duration is specified by a negative value, buffer~ reads in the entire file and resizes its sample memory and adjusts the number of channels in the file accordingly.
//This might be interesting for you Patrick… tho I’m not sure…
The duration may be followed by a third argument that specifies the number of channels to be read in. If the number of channels is not specified (i.e., if the message includes only offset and duration information), buffer~ reads in the number of channels indicated in the header of the audio file.
If only two arguments are specified, buffer~ imports the number of channels indicated in the header of the audio file. If three arguments are specified, buffer~ imports the number of channels specified by the third argument. If the third argument is 0, buffer~ imports the number of channels indicated in the header of the audio file.
So now I’m using the import message as following:
import 0 -1 0
linked in to a buffer~ object and it works!
Sorry for the silly question then… I should have read the docs more careful!
Strange, import 0 -1 does update the buffer’s size everytime here.
But trying with buffer~‘s helpfile, I see that waveform~ doesn’t update its size: you need to send the 0 -1 0 -1 message to its rightmost inlet to select all the buffer.
BTW, beware: the "guy" you speak about works for c74 ;-)
^^ I said nothing bad about him did I? ^^