mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-07 20:17:04 +03:00
fixed point resampling option
This commit is contained in:
@@ -9,6 +9,7 @@ COMPONENT_ADD_LDFLAGS=-l$(COMPONENT_NAME) \
|
||||
$(COMPONENT_PATH)/lib/libvorbisidec.a \
|
||||
$(COMPONENT_PATH)/lib/libogg.a \
|
||||
$(COMPONENT_PATH)/lib/libalac.a \
|
||||
$(COMPONENT_PATH)/lib/libresample16.a \
|
||||
$(COMPONENT_PATH)/lib/libsoxr.a
|
||||
|
||||
|
||||
|
||||
85
components/codecs/inc/resample16/resample16.h
Normal file
85
components/codecs/inc/resample16/resample16.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* FILE: resample16.h
|
||||
*
|
||||
* The configuration constants below govern
|
||||
* the number of bits in the input sample and filter coefficients, the
|
||||
* number of bits to the right of the binary-point for fixed-point math, etc.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Conversion constants */
|
||||
#define Nhc 8
|
||||
#define Na 7
|
||||
#define Np (Nhc+Na)
|
||||
#define Npc (1<<Nhc)
|
||||
#define Amask ((1<<Na)-1)
|
||||
#define Pmask ((1<<Np)-1)
|
||||
#define Nh 16
|
||||
#define Nb 16
|
||||
#define Nhxn 14
|
||||
#define Nhg (Nh-Nhxn)
|
||||
#define NLpScl 13
|
||||
|
||||
/* Description of constants:
|
||||
*
|
||||
* Npc - is the number of look-up values available for the lowpass filter
|
||||
* between the beginning of its impulse response and the "cutoff time"
|
||||
* of the filter. The cutoff time is defined as the reciprocal of the
|
||||
* lowpass-filter cut off frequence in Hz. For example, if the
|
||||
* lowpass filter were a sinc function, Npc would be the index of the
|
||||
* impulse-response lookup-table corresponding to the first zero-
|
||||
* crossing of the sinc function. (The inverse first zero-crossing
|
||||
* time of a sinc function equals its nominal cutoff frequency in Hz.)
|
||||
* Npc must be a power of 2 due to the details of the current
|
||||
* implementation. The default value of 512 is sufficiently high that
|
||||
* using linear interpolation to fill in between the table entries
|
||||
* gives approximately 16-bit accuracy in filter coefficients.
|
||||
*
|
||||
* Nhc - is log base 2 of Npc.
|
||||
*
|
||||
* Na - is the number of bits devoted to linear interpolation of the
|
||||
* filter coefficients.
|
||||
*
|
||||
* Np - is Na + Nhc, the number of bits to the right of the binary point
|
||||
* in the integer "time" variable. To the left of the point, it indexes
|
||||
* the input array (X), and to the right, it is interpreted as a number
|
||||
* between 0 and 1 sample of the input X. Np must be less than 16 in
|
||||
* this implementation.
|
||||
*
|
||||
* Nh - is the number of bits in the filter coefficients. The sum of Nh and
|
||||
* the number of bits in the input data (typically 16) cannot exceed 32.
|
||||
* Thus Nh should be 16. The largest filter coefficient should nearly
|
||||
* fill 16 bits (32767).
|
||||
*
|
||||
* Nb - is the number of bits in the input data. The sum of Nb and Nh cannot
|
||||
* exceed 32.
|
||||
*
|
||||
* Nhxn - is the number of bits to right shift after multiplying each input
|
||||
* sample times a filter coefficient. It can be as great as Nh and as
|
||||
* small as 0. Nhxn = Nh-2 gives 2 guard bits in the multiply-add
|
||||
* accumulation. If Nhxn=0, the accumulation will soon overflow 32 bits.
|
||||
*
|
||||
* Nhg - is the number of guard bits in mpy-add accumulation (equal to Nh-Nhxn)
|
||||
*
|
||||
* NLpScl - is the number of bits allocated to the unity-gain normalization
|
||||
* factor. The output of the lowpass filter is multiplied by LpScl and
|
||||
* then right-shifted NLpScl bits. To avoid overflow, we must have
|
||||
* Nb+Nhg+NLpScl < 32.
|
||||
*/
|
||||
|
||||
typedef char BOOL;
|
||||
typedef short HWORD;
|
||||
typedef unsigned short UHWORD;
|
||||
typedef int WORD;
|
||||
typedef unsigned int UWORD;
|
||||
|
||||
struct resample16_s;
|
||||
|
||||
typedef enum { RESAMPLE16_FAST, RESAMPLE16_SMALL, RESAMPLE16_LARGE, RESAMPLE_CUSTOM } resample16_filter_e;
|
||||
|
||||
WORD resample16(struct resample16_s *r, HWORD X[], int inCount, HWORD Y[]);
|
||||
struct resample16_s* resample16_create(double factor, resample16_filter_e filter, BOOL interp);
|
||||
void resample16_delete(struct resample16_s *r);
|
||||
void resample16_flush(struct resample16_s *r);
|
||||
|
||||
|
||||
BIN
components/codecs/lib/libresample16.a
Normal file
BIN
components/codecs/lib/libresample16.a
Normal file
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user