With NAudio, the bitrate is calculated via the AverageBytesPerSecond
member of the WaveFormat
structure:
using (var reader = new WaveFileReader(filename))
{
bitrate = reader.WaveFormat.AverageBytesPerSecond * 8;
}
This will work for all uncompressed audio formats and most compressed. The WAV file format is a container format and can actually contain audio in any codec, even though it's most common use is PCM. But not all codecs are CBR (constant bit rate). Some have a variable bit rate, so the AverageBytesPerSecond
property may be an estimate.