thebigmunch / audio-metadata

A library for reading and, in the future, writing audio metadata. https://audio-metadata.readthedocs.io/
https://forum.thebigmunch.me
MIT License
53 stars 11 forks source link

Invalid duration for wav files #37

Closed jhentsch2 closed 4 years ago

jhentsch2 commented 4 years ago

The latest update v0.8.0 breaks the duration for wav files.

In /src/audio_metadata_formats/wav.py L195:

self.streaminfo.duration = self.streaminfo._size / self.streaminfo.bitrate / 8

should read

self.streaminfo.duration = self.streaminfo._size / (self.streaminfo.bitrate / 8)

This bug was introduced in 2bbda71b2cb9aa7dde8fc8148c60b89b510482b1. It was tested on a 130 second wav file. In v0.6.0, the duration is correctly returned. In v0.8.0, the duration returned is 2.03 seconds.

It might be a good idea to include a test for the streaminfo to ensure data is correct.

thebigmunch commented 4 years ago

Thanks for the report. Wish this had come just a few minutes earlier, could've put this in 0.9.0 that I just released : P

It might be a good idea to include a test for the streaminfo to ensure data is correct.

Yeah, I haven't gotten around to adding all the tests I want to. Many of which would be to validate values as in this case rather than just testing code paths. Only so much time and energy : )