0

Here, my task is to fetch aiff audio details including bit rate. But with this code I am able to fetch sample rate, bits per sample and channel only. Is there any way to get bit rate too?

public void GetAudioDetails()
{
   FileStream fs = new FileStream("..\\guitar.aiff",FileMode.OpenOrCreate,FileAccess.ReadWrite);
   MemoryStream ms = new MemoryStream();
   fs.CopyTo(ms);
   ms.Seek(0, SeekOrigin.Begin);
   var ddf = new AiffFileReader(ms);

}
Roman R.
  • 68,205
  • 6
  • 94
  • 158
sainath sagar
  • 499
  • 2
  • 10
  • 28

1 Answers1

2

bitrate is average bytes per second * 8. So use the following code:

var bitRate = ddf.WaveFormat.AverageBytesPerSecond * 8;
Mark Heath
  • 48,273
  • 29
  • 137
  • 194
  • Hi @Mark, here for my file average bytes per second is 192000. As per your answer it would come around, 1536000 (192000*8). Is it right ?? – sainath sagar Nov 28 '13 at 13:59
  • but when I used 128 bit rate mp3 file in Mp3FileReader() function, the average bytes per second was given as 176400. Now as per your calculation its bit rate become, 1411200. which is completely different from the source bit rate. I have checked the file bit rate using AudioInspection demo, which is 128 bit only. – sainath sagar Nov 28 '13 at 14:09
  • because Mp3FileReader converts to uncompressed PCM for you. Look at Mp3WaveFormat instead – Mark Heath Nov 28 '13 at 14:10
  • Will this technique applies for MFTReader too?? – sainath sagar Nov 28 '13 at 14:15
  • It seems with MFTReader it is difficult to find the source bit rate of a mp3 fie. – sainath sagar Nov 28 '13 at 14:22