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

Mpeg layer 2 audio.

Aug 24, 2015 at 12:18 AM

Layer 2 is not implement in Naudio, isn't? (I get the comException error when trying to decode it) So i wonder if there is a simple way to decode the Layer 2 stream and passing it to Naudio in PCM... or do you have a better idea? Layer 2 is still a very popular format in broadcasting, and thus, there's a lot of files compressed in that layer.

Thank you!
Aug 26, 2015 at 6:08 AM
Hi Knob
can u help me out

i am implementing some part of Naudio project
but i am unable to approach to the code

I need only graph in my project
i am getting every thing but graph is not running
what method to implement and how can u guide me

Aug 26, 2015 at 4:12 PM

That is a very general question. What you do you want to do? what's the final idea? winforms or WPF? what code are you using?

See you.
Aug 27, 2015 at 2:39 AM

I want wave graph for .wav file when it play .
in winform

i have done every thing but i am not getting final out put
Audio wave graph.
Aug 27, 2015 at 9:14 AM

Have you tried the demo? It's in the zip. You have to run Naudiodemo, and select AudioPlaybackDemo. Inside that form you will find the control that displays the waveform.
The code for represent the wave graph there is:

private ISampleProvider CreateInputStream(string fileName)
        this.audioFileReader = new AudioFileReader(fileName);

        var sampleChannel = new SampleChannel(audioFileReader, true); --> true to force it stereo.
        sampleChannel.PreVolumeMeter+= OnPreVolumeMeter; //--> This creates the event for draw the graph before any change made later to the amplitude of the original sound (volume i.e.). Follow the method below...
        this.setVolumeDelegate = (vol) => sampleChannel.Volume = vol;
        var postVolumeMeter = new MeteringSampleProvider(sampleChannel);
        postVolumeMeter.StreamVolume += OnPostVolumeMeter;

        return postVolumeMeter;

    void OnPreVolumeMeter(object sender, StreamVolumeEventArgs e)
        // we know it is stereo
        waveformPainter1.AddMax(e.MaxSampleValues[0]); //--> Waveform graph for L channel
        waveformPainter2.AddMax(e.MaxSampleValues[1]);  //--> Waveform graph for R channel
As soon as you initialize WaveOut.Init(sampleChannel); and fire WaveOut.Play; it will begin to draw.
Sep 1, 2015 at 1:06 PM
i had create a form.

        public Form1([ImportMany]IEnumerable<IOutputDevicePlugin> outputDevicePlugins)
How to call this constructor on page loading.
Sep 4, 2015 at 11:36 AM
Mpeg Audio Layer 2 is actually not supported
Sep 7, 2015 at 8:33 PM
NAudio does not include any MP3 decoding, it simply provides access to the codecs available on your machine (e.g. ACM or Media Foundation Transforms).