XLayer 1.0.2

dotnet add package XLayer --version 1.0.2
                    
NuGet\Install-Package XLayer -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XLayer" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XLayer" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="XLayer" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add XLayer --version 1.0.2
                    
#r "nuget: XLayer, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package XLayer@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=XLayer&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=XLayer&version=1.0.2
                    
Install as a Cake Tool

XLayer

XLayer is a fully managed MP3 to WAV decoder.

This repository is my port of NLayer to modern .NET

Install with dotnet add package XLayer

Optimized for performance:

Method Mean Error StdDev Ratio Gen0 Gen1 Allocated Alloc Ratio
NLayer 514.5 ms 3.51 ms 3.28 ms 1.00 26000.0000 1000.0000 484.66 MB 1.000
XLayer 476.5 ms 2.11 ms 1.98 ms 0.93 - - 3.47 MB 0.007

The NLayer 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 XLayer for decoding MP3, first reference XLayer.

using XLayer;

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

// samples per second times channel count
const int samplesCount = 44100;
var fileName = "myMp3File.mp3";
var mpegFile = new MpegFile(fileName);
float[] samples = new float[samplesCount];
int readCount = mpegFile.ReadSamples(samples, 0, samplesCount);

More information could be found in code documents.

Use with NAudio

I have not tested this port with NAudio

Testing

XLayer.Tests project:

  • dotnet run Will compare NLayer samples = XLayer samples
  • dotnet run -m Helper that will run just XLayer for memory profiling
  • dotnet run -b Run benchmarks against NLayer
  • dotnet run -p Loop through ffmpeg pipe back to mp3 to validate audio quality

Music

Sample music is from my god-father's classic rock band The Toons.

Cover Band

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 189 4/6/2025
1.0.1 171 4/6/2025
1.0.0 170 4/6/2025