The audioFile class in nup-headless is currently using Ebitengine's ResampleReader class to upsample and downsample audio data that isn't 44.1 kHz.
I don't think it makes sense to pull in as big a dependency as Ebitengine now that it's not being used for audio playback (see #139). Ebitengine development looks like it went all-in on Claude Code about two weeks ago, and I'd noticed weird behavior even before then (e.g. ResampleReader doesn't seem to report EOF correctly).
I'd prefer to find some other small resampling library that I can use instead. A brief survey:
- libsamplerate gets mentioned as the best resampling library in various places. It's written in C, but there are some minimal Go bindings at https://github.com/dh1tw/gosamplerate. It looks like it only operates on float32 and float64, but I think that
ResampleReader is already converting to float64 behind-the-scenes so that's probably not a big deal. At first glance, the Go bindings look like they make a bunch of probably-unnecessary copies, so I'd probably want to write my own.
- resample is a small CGo wrapper around libsoxr. It looks like it implements
io.Writer. It has the downside that it requires the C library to be installed on the system.
- gomplerate is a simple, public domain pure Go library. I have no idea about the quality of the resampling or its performance.
- oov/audio has a resampler package with a pure Go port of opus-tools' audio resampler. The code hasn't been touched since 2014.
- beep looks like it has a small pure Go Resampler class. It's MIT-licensed, but it pulls a ton of other dependencies (including Ebitengine).
- go-audio-resampler is a recent vibecoded port of libsoxr, complete with a 13.5k LOC initial commit. :-/
- Ron's Digital Signal Processing Page provides some small snippets in Basic, in case I want to try to port them to Go.
- Julius Orion Smith III's Digital Audio Resampling Home Page goes into the theory behind resampling, but it's way over my head given my lack of DSP experience.
The `audioFile` class in `nup-headless` is currently using Ebitengine's `ResampleReader` class to upsample and downsample audio data that isn't 44.1 kHz.
I don't think it makes sense to pull in as big a dependency as Ebitengine now that it's not being used for audio playback (see #139). Ebitengine development looks like it went all-in on Claude Code about two weeks ago, and I'd noticed weird behavior even before then (e.g. `ResampleReader` doesn't seem to report EOF correctly).
I'd prefer to find some other small resampling library that I can use instead. A brief survey:
* [libsamplerate](http://www.mega-nerd.com/SRC/) gets mentioned as the best resampling library in various places. It's written in C, but there are some minimal Go bindings at https://github.com/dh1tw/gosamplerate. It looks like it only operates on float32 and float64, but I think that `ResampleReader` is already converting to float64 behind-the-scenes so that's probably not a big deal. At first glance, the Go bindings look like they make a bunch of probably-unnecessary copies, so I'd probably want to write my own.
* [resample](https://github.com/zaf/resample) is a small CGo wrapper around libsoxr. It looks like it implements `io.Writer`. It has the downside that it requires the C library to be installed on the system.
* [gomplerate](https://github.com/zeozeozeo/gomplerate) is a simple, public domain pure Go library. I have no idea about the quality of the resampling or its performance.
* [oov/audio](https://github.com/oov/audio) has a [resampler](https://pkg.go.dev/github.com/oov/audio/resampler) package with a pure Go port of opus-tools' audio resampler. The code hasn't been touched since 2014.
* [beep](https://github.com/gopxl/beep) looks like it has a small pure Go [Resampler](https://pkg.go.dev/github.com/gopxl/beep#Resampler) class. It's MIT-licensed, but it pulls a ton of other dependencies (including Ebitengine).
* [go-audio-resampler](https://github.com/tphakala/go-audio-resampler) is a recent vibecoded port of libsoxr, complete with a [13.5k LOC initial commit](https://github.com/tphakala/go-audio-resampler/commit/d02270343ace12a95f6b0c51404886f038e80c7c). :-/
* [Ron's Digital Signal Processing Page](https://www.nicholson.com/rhn/dsp.html) provides some small snippets in Basic, in case I want to try to port them to Go.
* [Julius Orion Smith III's Digital Audio Resampling Home Page](https://ccrma.stanford.edu/~jos/resample/resample.html) goes into the theory behind resampling, but it's way over my head given my lack of DSP experience.