LibSampleRate 1.1.0

dotnet add package LibSampleRate --version 1.1.0
                    
NuGet\Install-Package LibSampleRate -Version 1.1.0
                    
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="LibSampleRate" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LibSampleRate" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="LibSampleRate" />
                    
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 LibSampleRate --version 1.1.0
                    
#r "nuget: LibSampleRate, 1.1.0"
                    
#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 LibSampleRate@1.1.0
                    
#: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=LibSampleRate&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=LibSampleRate&version=1.1.0
                    
Install as a Cake Tool

LibSampleRate.NET

A managed wrapper for the popular libsamplerate (aka Secret Rabbit Code) resampling library, written in C#.

Platform Support

The library currently supports Windows x86 and x64. Other platforms can be easily added, but are currently not included because the upstream repository only provides Windows builds.

Usage

The easiest way to use this library is by installing the package through NuGet.

The entire public API surface lives in and is documented in SampleRateConverter.cs. A minimal example:

using System;
using LibSampleRate;

var channels = 1;
var ratio = 2.0;
var inputBuffer = new float[1000];
var outputBuffer = new float[2000];

var src = new SampleRateConverter(ConverterType.SRC_SINC_BEST_QUALITY, channels);
src.SetRatio(ratio);

src.Process(
    inputBuffer,
    0,
    inputBuffer.Length,
    outputBuffer,
    0,
    outputBuffer.Length,
    endOfInput: true,
    out var inputSampleCount,
    out var outputSampleCount
);

Console.WriteLine($"{inputSampleCount} input samples resampled to {outputSampleCount} output samples.");

See the LibSampleRate.Demo project for a more complete streaming scenario that shows how to push blocks of audio through the converter.

Development

The solution contains two projects: the managed wrapper library, and a small console app demonstrating streaming resampling and serving as an integration test.

Run the helper script before building with Visual Studio or dotnet build so the native DLLs and their notices are available:

pwsh scripts/fetch-libsamplerate.ps1

License & Credits

Copyright (C) 2011-2025 Mario Guggenberger mg@protyposis.net. Released under the BSD 2-Clause license.

This project builds upon libsamplerate, Copyright (c) 2012-2016, Erik de Castro Lopo erikd@mega-nerd.com. Released under the BSD 2-Clause license.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on LibSampleRate:

Package Downloads
Aurio.LibSampleRate

Extension library for Aurio, which provides audio resampling through the external libsamplerate/SecretRabbitCode library (see https://github.com/libsndfile/libsamplerate).

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 264 11/16/2025