Skip to content
forked from naudio/NLayer

MPEG 1 & 2 Decoder for Layers 1, 2, & 3

License

Notifications You must be signed in to change notification settings

OpenMLTD/NLayer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nlayer

NLayer is a fully managed MP3 to WAV decoder. The code was originally based on JavaLayer (v1.0.1), which has been ported to C#.

Was previously hosted at nlayer.codeplex.com. Please see the history there for full details of contributors.

Usage

To use NLayer for decoding MP3, first reference NLayer.

using NLayer;

Then create an MpegFile, pass a file name or a stream to the constructor, and use ReadSamples for decoding the content:

var fileName = "myMp3File.mp3";
var mpegFile = new MpegFile(filename);
float[] samples = new float[44100];
mpegFile.ReadSamples(samples, 0, 44100);

More information could be found in code documents.

Use with NAudio

NLayer is capable of using in conjunction with NAudio for file conversion and real-time playback.

You need to reference NAudio, NLayer and NLayer.NAudioSupport first.

using NAudio.Wave;
using NLayer.NAudioSupport;

Then create an Mp3FileReader, passing in a FrameDecompressorBuilder that uses the Mp3FrameDecompressor from NLayer.NAudioSupport:

var fileName = "myMp3File.mp3";
var builder = new Mp3FileReader.FrameDecompressorBuilder(wf => new Mp3FrameDecompressor(wf));
var reader = new Mp3FileReader(fileName, builder);
// play or process the file, e.g.:
waveOut.Init(reader);
waveOut.Play();

About

MPEG 1 & 2 Decoder for Layers 1, 2, & 3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%