libinterp is a tiny library for real-time data interpolation, especially focused on sound resampling.
It is written in plain C and, as of now, it just offers three algorithms (zero order hold, linear and cubic splines calculated on 4 points), only on mono channels and only using regular float values for input and output.
However, you can already process multiple mono channels and switch algorithms and buffer sizes (thus also the output rate) on the fly.
For the (near or far) future I hope to add some sinc-based algorithms, (optional?) low-pass filtering when downsampling, optional limiting (maybe normalization?), support for other data encodings, maybe even support for interleaved data for multiple channels and some toy/simple analysis/example programs.
However this is a "part part time" thing, so I'm not working regularly on it. Contributions are very welcome. ;-)
2007-12-05: First public release: libinterp 0.1.0.
This software is licensed under a MIT-style license. Here's a copy:
Copyright (c) 2007, Stefano D'Angelo <zanga.mail@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
You can get it here.
As usual:
$ ./configure $ make # make install(
./configure --help
for configuration options).
An example (you can always do more complex things, obviously):
#include <libinterp/libinterp.h> [...] float in_buf[], out_buf[]; unsigned int in_samples, out_samples; float last_in_samples[4] = {0.0, 0.0, 0.0, 0.0}; [...] while (have_some_data_to_process) interp_spline(in_buf, in_samples, out_buf, out_samples, last_in_samples); [...]
You can issue a make doxygen-doc
to generate Doxygen
documentation from the public headers (you have to install those files
manually, though). The generated API reference should, then, be found in
the doc/reference
directory.
As of now it works on Linux and BeOS (probably Haiku and Zeta too).
However, since the code is very platform neutral, you can easily port it
to other operating systems as well. If you're interested, take a look at
the configure.ac
and include/libinterp/config.h
files (those should be quite self-explaining).
For anything: zanga _dot_ mail _at_ gmail _dot_ com
.
Copyright © 2007, Stefano D'Angelo