This project has moved. For the latest updates, please go here.

Totaltime of Wav file is twice as much as the real totaltime

Mar 5, 2014 at 3:48 PM
Hi ..
I have 2 different wav files:
D1.wav:

Download D1 HERE

Encoding:IeeeFloat
Channels:1
SampleRate:44100
AverageBytesPerSecond:176400
BlockAlign:4
BitsPerSample:32
ExtraSize:0

D2.wav:

Download D2 HERE

Encoding:IeeeFloat
Channels:2
SampleRate:48000
AverageBytesPerSecond:384000
BlockAlign:8
BitsPerSample:32
ExtraSize:0

and iam using the following code to play them:
....
private DirectSoundOut waveOut;
AudioFileReader AudioFile;

this.AudioFile = new AudioFileReader(audioFilePath);
this.waveOut = new DirectSoundOut(this.deviceGuid);
this.postVolumeMeter = new MeteringSampleProvider(this.AudioFile);
this.postVolumeMeter.StreamVolume += OnPostVolumeMeter;
waveOut.PlaybackStopped += WaveOutPlaybackStopped;
this.waveOut.Init(new SampleToWaveProvider(this.postVolumeMeter));
Now iam reading the AudioFile.Totaltime.TotalMilliseconds D1 is 20742 (but it is in fact only 10seconds long)
where the second file D2 is reporting 6307.0 which is correct...

Do you know where the problem is ? and how would I correct it so I can display the real totaltime of both files ..

Any ideas ?

thanks in advance
Coordinator
Apr 29, 2014 at 7:24 PM
This was a bug with AudioFileReader and mono files that was fixed a while back.
May 26, 2014 at 2:19 PM
Hi Mark,

iam using the newest naudio (version 1.7)...
so what do you think iam doing wrong ?
Coordinator
May 29, 2014 at 10:07 AM
Edited May 29, 2014 at 10:07 AM
the fix is in 1.7.1, available on nuget
Jun 2, 2014 at 8:02 AM
Wow ..thanks a lot