Development Topics > Plugin Development
Get the length of audio file
(1/1)
grh:
Hallo!
Is it possible to get the length of the audio file which I want to analyze ?
In one algorithm I want to analyze the whole audio file at once and now I am thinking about a good way to do it:
a) I could set the blocksize to the length of the whole audio file (therefore I would need the length of the file)
b) or process the file in small blocks, save them and call getRemainingFeatures at the end
But also in b) I need the file length, because it would be nice to allocate the big buffer arrays before (and not always resize them each block).
Thanks for any hints how this could be achieved in a nice way,
LG
Georg
PS: I am using python/vampy, but I guess the same problem is valid for C++ plugins ...
cannam:
Hello there.
You can't get the length of the audio file ahead of processing it -- apart from anything else, the host does not necessarily know it (it could be reading from a stream, though most existing hosts use files).
You therefore need to take option (b), and work out the length of the file yourself by counting the frames that are passed to process() calls.
Chris
grh:
Ok, that's sad .. then I have to reallocate the big buffer array all the time, because I don't know how big the file will be ...
However, thanks for the information and have a good weekend,
LG
Georg
Navigation
[0] Message Index
Go to full version