-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get duration of wav file? #35
Comments
Try this
|
I wasn't able to get the above working for me. But I was able to use @wxfred 's suggestion to get it working using the following: // Where wav is a correctly created WaveFile:
const duration: number = wav.chunkSize / wav.fmt.numChannels / wav.fmt.sampleRate / (wav.fmt.bitsPerSample / 8)
// Some debug to validate values are coming back as expected.
console.log(
'wav.chunkSize', wav.chunkSize,
'wav.fmt.numChannels', wav.fmt.numChannels,
'wav.fmt.sampleRate', wav.fmt.sampleRate,
'wav.fmt.bitsPerSample', wav.fmt.bitsPerSample
); If you save the wave file, on MacOS you can validate the calculated duration of a final output using the built in utility:
I found they were very close, but not exactly the same. |
I calculate it in ms like this:
|
No description provided.
The text was updated successfully, but these errors were encountered: