diff options
| author | Markus Mittendrein <maxmitti@maxmitti.tk> | 2022-11-28 20:16:46 +0100 |
|---|---|---|
| committer | Markus Mittendrein <maxmitti@maxmitti.tk> | 2022-11-28 20:16:46 +0100 |
| commit | 4cb83acddbe154312b74d2d63985ac1100bad7c5 (patch) | |
| tree | d49dc904acc9af57acca8864fb6a40e340accacc /lib/types.h | |
| download | fresample-4cb83acddbe154312b74d2d63985ac1100bad7c5.tar.gz fresample-4cb83acddbe154312b74d2d63985ac1100bad7c5.zip | |
Diffstat (limited to 'lib/types.h')
| -rw-r--r-- | lib/types.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/types.h b/lib/types.h new file mode 100644 index 0000000..c023a9a --- /dev/null +++ b/lib/types.h @@ -0,0 +1,44 @@ +#pragma once +#include <cstdint> + +/* + A 32.32 fixed point number. Th*is is used for expressing fractional + positions in a buffer. + + When used for converting from sample rate f_s to f_d, the timing + error at time t is bounded by t * 2^-33 * r_d / r_s. For a + pessimistic conversion ratio, 8 kHz -> 192 kHz, this means that it + will take at least five days to accumulate one millisecond of error. + */ +using lfr_fixed_t = std::int64_t; + + +/* ======================================== + Sample formats + ======================================== */ + +/* + Audio sample formats. + */ +enum lfr_fmt_t { + LFR_FMT_U8, + LFR_FMT_S16BE, + LFR_FMT_S16LE, + LFR_FMT_S24BE, + LFR_FMT_S24LE, + LFR_FMT_F32BE, + LFR_FMT_F32LE, + LFR_FMT_COUNT +}; + + +/* + Specialized resampling function, designed to work with a specific + sample format and filter type. Do not attempt to reuse a function + for a different filter. + + Note that lengths are still measured in frames, but since the + function is specialized for a given format and number of channels, + there is no need to specify the format or number of channels. +*/ +using lfr_resample_func_t = void (*)( lfr_fixed_t *pos, lfr_fixed_t inv_ratio, unsigned *dither, void *out, int outlen, const void *in, int inlen, const struct lfr_filter *filter);
\ No newline at end of file |
