Awesome Go

go-resample

CategoryAudio and Music
SubcategoryAudio and Music
Stars0

Pure-Go (no cgo) audio sample-rate converter with sinc, linear, and zero-order-hold converters

About go-resample

go-resample

CI Go Reference

A pure-Go (no cgo) audio sample-rate converter.

  • No cgo — cross-compiles and links cleanly into static Go binaries.
  • Arbitrary & time-varying ratios in [1/256, 256] (ratio = output_rate / input_rate).
  • Interleaved float32 frames, any channel count.

Converters

ConverterQualityCostNotes
SincBestQualityhighesthighwidest passband, deepest stopband
SincMediumQualitytransparent for most usesmediumgood default
SincFastestgoodlowband-limited sinc, low CPU
ZeroOrderHoldlowtrivialnearest-sample hold
Linearlowtriviallinear interpolation

The sinc converters build a Kaiser-windowed sinc prototype filter and evaluate it via a polyphase table with linear interpolation between phases; downsampling widens the filter for anti-aliasing and rescales for unity gain.

Usage

One-shot conversion of a whole buffer:

out, err := resample.Simple(in, 48000.0/44100.0, 2, resample.SincMediumQuality)

Streaming:

r, _ := resample.New(resample.SincMediumQuality, 2)
d := &resample.Data{
    In: in, InputFrames: len(in) / 2,
    Out: out, OutputFrames: len(out) / 2,
    Ratio: 2.0,
    EndOfInput: false, // set true on the final call
}
_ = r.Process(d)
// d.OutputFramesGen frames written; call again to feed more / drain.

License

BSD-2-Clause — see LICENSE. Credit for the reference implementation this work is based on is in NOTICE.

Frequently Asked Questions

What is go-resample?

go-resample is a Audio and Music library for the Go programming language. Pure-Go (no cgo) audio sample-rate converter with sinc, linear, and zero-order-hold converters

How do I install go-resample?

Install go-resample with the Go module system using `go get gojargo/go-resample`. Check the repository for the current installation instructions.

What category does go-resample belong to?

go-resample is listed under Audio and Music, specifically Audio and Music.

← Back to Audio and Music