BlipBuf.Net
1.0.1
dotnet add package BlipBuf.Net --version 1.0.1
NuGet\Install-Package BlipBuf.Net -Version 1.0.1
<PackageReference Include="BlipBuf.Net" Version="1.0.1" />
<PackageVersion Include="BlipBuf.Net" Version="1.0.1" />
<PackageReference Include="BlipBuf.Net" />
paket add BlipBuf.Net --version 1.0.1
#r "nuget: BlipBuf.Net, 1.0.1"
#:package BlipBuf.Net@1.0.1
#addin nuget:?package=BlipBuf.Net&version=1.0.1
#tool nuget:?package=BlipBuf.Net&version=1.0.1
BlipBuf.Net
A .NET port of blip_buf by Shay Green (aka blargg). BlipBuf.Net enables easy high-quality resampling of PSG-like audio (the kind that was present in 1980s-era sound chips, featuring square and sawtooth waves). Simply set the input clock rate and output sample rate, add waveforms by specifying the clock times where their amplitude changes, then reads the resulting output samples. BlipBuf.Net uses band-limited synthesis to avoid the aliasing that would typically be present when resampling this kind of audio. For more information on the algorithm, see Shay Green's articles: Band-Limited Sound Synthesis.
Usage
Install NuGet Package
dotnet add package BlipBuf.Net
Install-Package BlipBuf.Net
Use BlipBuf.Net
using BlipBufDotNet;
double clockRate = 1000000.0; // Input clock rate
double sampleRate = 48000.0; // Output sample rate
int bufLength = 4800; // Number of samples the buffer can hold
var blipBuf = new BlipBuf(bufLength, clockRate, sampleRate); // Create a BlipBuf
blipBuf.SetRates(clockRate / 2, sampleRate); // Adjust clock/sample rates if needed.
blipBuf.AddDelta(30, -5000); // Add a delta of -5000 at clock offset 30. Deltas should be in the range of signed 16-bit samples.
blipBuf.AddDeltaFast(30, -5000); // Same as above, but using a faster and lower-quality synthesis.
int clocksNeeded = blipBuf.GetClocksNeeded(100); // Number of clocks needed to make 100 additional samples available.
blipBuf.EndFrame(200); // Makes input clocks before 200 available for reading as output samples, and restarts the frame at 0 clocks.
short[] outputBuffer = new short[200];
blipBuf.ReadSamples(outputBuffer, 200, stereo: false); // Read and remove 200 16-bit signed samples and write them to outputBuffer.
float[] floatBuffer = new float[200]
blipBuf.ReadFloatSamples(floatBuffer, 200, stereo: false); // Same as above, but produces 32-bit floating point samples.
blipBuf.Clear(); // Clear the buffer
Product | Versions 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. |
-
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.