aboutsummaryrefslogtreecommitdiffstats
path: root/lib/types.h
blob: c023a9a0d5e1aa5f3e80efd73a4bfb50e89e2158 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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);