Getting length of audio file?

I’m using aud to handle audio in my game and I have had a good session learning the api and feel quite comfortable with it.

One thing I can’t figure out is how to get the length of an audio file. I have the factory.position variable, but I am looking for the length of the file so I can determine how long is left to play.

Any pointers?

cheers

interesting question…
i know that the size of a common .wav file is about 1MB per minute, at a bitrate of 16 Bit at 44.1 KHz…

have a look here:

I guess, if you can extract the information for the size, bitrate and frequency of the file, you could probably calculate the lenght of it…

I’m pretty shure, that the information must be somewhere in the file …

Yea I’m using .ogg files and I think the length of the file is in the meta data in the file. I just dont know how to parse the file and get this information out. I have had a look at a couple of python libraries that let you extract data about vorbis ogg files. But I was hoping there was an easier way to get this information. Still learning python, so linking in libraries and things kind of haunts me.

I was really hoping for something like audioFactory.length to get the length of the file, but I dont think its implemented.

I have made a temporary solution by creating a class to hold information about the tracks, then just hardcoding in the length of the audio file in seconds. It works but I was hoping for a more elegant solution that would maybe let me loop through a directory of audio files and use them.