How to get exact length of a buffer in samples?
atm I am trying to make some non-realtime-calculation of audiofiles, and for it I need to know exactly the length in samples of a loaded buffer. The objects [info~] and [sfinfo~] just give me the lenght in ms (and both give slightly different answers). So my question is: Is there a possibility to get this information directly in samples?
you can send the getSize message to [mxj buf.Op your_buffer_name] – a very nice thing almost hidden in the Max distribution.
thank you, i didn’t know this before. But it is still not accurate enough.
I’ll give you an example with 1 testing file (44.1kHz):
gives me a length of 7470 ms
-> 329427 samples
gives me a length of 7470.476074 ms
-> 329447.96875 samples
gives me a length of
gives me a length of
i tested now a lot and I found out, that I need as number the 329448 samples as length. this number seems to be the correct one. so, there is still no method in max, to give me the correct number…? Atm the only way I see is to round the number of the [sfinfo~],but i can’t believe this is the only way to get the correct information in max…?
i found out, that even with the other numbers calculated my program works well now (there were a few other bugs). but still wondering about my last concern.
Well, the fact that the actual size is smaller in buffer~ objects than in sfinfo~ and audacity makes me think of a bug… I might be wrong of course.
If you found out that the Audacity value is reliable (are you sure of this?), I would suggest you to try what happens with much larger files… if you see that rounding the sfinfo~ output still gives you the correct value, I don’t think there’s anything wrong with using it. If not, well, we’re in some trouble!
the sfinfo~ output also behaves with larger files in the same way as audacity.
but it is really strange, that all methods in maxMSP give me different results (at least with bigger files (180mb)).. here the patch to test it. (maybe I myself did some mistake there)
-- Pasted Max Patch, click to expand. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 999.3oc0ZsrbaBCEcs8WgFurSpK5Jd1ccW20EcYmLcvXQhRAjGPdxqI4auBI vwwQXSh4UVXvHvny4nqN2q.+37YKVwuiVr.8czePyl837YyTMU1vrpimsHM7 tnjvB0ksHhmlRyDKtPeNA8Ngp8ejjfDzBAcMJlkPKP2RyoHr6WWwDWfrsWh+ 2Oe3Bj7Bxo75ecBKiFw2lotEPUir0paHe0Me0u9Bi4YhrvTptqxYgI0mIaaJ KKgJTnC+Ri7sh5Vs16lTvdPcSvvx5l2DJhtlkc0eyoQBsTX6GHOMhfK2h8U6 H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.1 khz require 442 samples.
Forums > MaxMSP