This is a basic user guide to NVorbis. Please feel free to ask questions on the Discussions page.


Copy "NVorbis.dll" to your libraries folder, then add a reference to it from your project. If NAudio support is needed, repeat for "NVorbis.NAudioSupport.dll".


NVorbis provides an easy-to-use API for reading metadata and raw audio data from an Ogg Vorbis file. The basic usage of NVorbis is as follows:

using (var vorbis = new NVorbis.VorbisReader(@"C:\PATH\TO\OGG\FILE.ogg"))
    int channels = vorbis.Channels;
    int sampleRate = vorbis.SampleRate;
    var duration = vorbis.TotalTime;

    var buffer = new float[16384];
    int count;
    while ((count = vorbis.ReadSamples(buffer, 0, buffer.Length)) > 0)
        // Do stuff with the samples returned...
        // Sample value range is -0.99999994f to 0.99999994f
        // Samples are interleaved (chan0, chan1, chan0, chan1, etc.)

Using NVorbis with NAudio is also easy:

// Console application version
using (var vorbis = new NVorbis.NAudioSupport.VorbisWaveReader(@"C:\PATH\TO\OGG\FILE.ogg"))
using (var waveOut = new NAudio.Wave.WaveOut())

    while (waveOut.PlaybackState != NAudio.Wave.PlaybackState.Stopped)

// WinForms / WPF version with WaveOut (NAudio supports a lot more outputs)
NVorbis.NAudioSupport.VorbisWaveReader _reader;
NAudio.Wave.WaveOut _waveOut;

// Wire this up to a button on your UI
void OnClickHandler(object sender, EventArgs e)
    _reader = new NVorbis.NAudioSupport.VorbisWaveReader(@"C:\PATH\TO\OGG\FILE.ogg");

    _waveOut = new NAudio.Wave.WaveOut();
    _waveOut.PlaybackStopped += OnStoppedHandler;

void OnStoppedHandler(object sender, EventArgs e)
    _waveOut.PlaybackStopped -= OnStoppedHandler;
    _waveOut = null;

    _reader = null;

Building from Source

NVorbis is a Visual Studio 2010 project (currently). Normal VS usage applies.

Last edited Jun 27, 2013 at 8:44 PM by ioctlLR, version 3