I'm following this tutorial to play MP3 audio files with NAudio. To create the WaveStream I use this method:
private WaveStream CreateInputStream(string fileName)
        {
            WaveChannel32 inputStream;
            if (fileName.EndsWith(".mp3"))
            {
                WaveStream mp3Reader = new Mp3FileReader(fileName);
                inputStream = new WaveChannel32(mp3Reader);
            }
            else
            {
                throw new InvalidOperationException("Unsupported extension");
            }
            volumeStream 开发者_如何转开发= inputStream;
            return volumeStream;
        }
Unfortunately I always get an exception in the
line inputStream = new WaveChanne32(mp3Reader):
Blockquote
System.ApplicationException was unhandled
  Message=Only PCM supported
  Source=NAudio
  StackTrace:
You can use
var pStream = NAudio.Wave.WaveFormatConversionStream.CreatePcmStream(mp3Reader);
var inputStream = new NAudio.Wave.BlockAlignReductionStream(pStream);
PCM is an encoding type (Pulse-code modulation). Seems like NAudio can only handle PCM encoded files.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论