Skip to content

Formats

Axwabo edited this page Mar 14, 2026 · 6 revisions

File Formats

The AudioReaderFactoryManager class holds the factories used to create WaveStreams based on file extensions. You can register your own factories.

SecretLabNAudio.Core itself supports wav and aiff files. To add support for mp3 and ogg containers, install the required modules or choose the full SecretLabNAudio installation.

Tip

See the README for installation steps.

Format Pros Cons
wav Very fast decoding Large file size
mp3 Widely used Very slow to decode
ogg (Ogg Vorbis) Smallest file size A bit slow to decode
aiff Fast decoding Large file size, macOS standard

Tip

Check out FFmpeg which supports essentially every format.

Custom Factories

Implement the IAudioReaderFactory interface and pass an instance to AudioReaderFactoryManager.RegisterFactory with the file type.

The IAudioReaderFactory defines methods to create WaveStreams and/or ISampleProviders, given a path or a Stream

Both methods return an AudioReaderFactoryResult which has an implicit conversion from a WaveStream that sets the provider using ToSampleProvider

using NAudio.Wave;
using SecretLabNAudio.Core.FileReading;

public AudioReaderFactoryResult FromPath(string path) => new WaveFileReader(path);
// is the same as
public AudioReaderFactoryResult FromPath(string path) 
{
    var reader =  new WaveFileReader(path);
    return new AudioReaderFactoryResult(reader, reader.ToSampleProvider());
}

Getting Started

Playing Audio

Advanced

Audio Processors

FFmpeg

v1 Guides

Caution

v1 will be out of support soon.

Clone this wiki locally