marsyas/marsyas — pull request #23 by evojimmy (2013-12-14 03:16:56+00:00)
Title: AudioSink support for probe and resample & ResampleLinear potential error

`AudioSink` now probe sample rates that the backend supports in initialization. `onSamples` and `osrate` are adjusted to the supported sample rate. A linear interpolation takes place in `myProcess()`.

Tested with sample rates of 11025Hz, 22050Hz, 36000Hz, 44100Hz, 46000Hz, 48000Hz with ALSA and JACK backend, as well as `inSamples` of 256, 258, 512, 1024, 2048, 8192. Built-in apps like `MarPlayer` and `MarGrid2` now work fine.

I have not tested it under extreme circumstances (e.g. when reinitialization is needed). And I have not tested it with other backends.

For the resample algorithm, I simply copied the code in `ResampleLinear.cpp`. The output is not really good if sample rate differece is large, but at least it works. Perhaps a better resample algorithm is needed.