diff --git a/components/codecs/component.mk b/components/codecs/component.mk index 9707fc8d..c68cbd97 100644 --- a/components/codecs/component.mk +++ b/components/codecs/component.mk @@ -12,7 +12,6 @@ COMPONENT_ADD_LDFLAGS=-l$(COMPONENT_NAME) \ $(COMPONENT_PATH)/lib/libresample16.a \ $(COMPONENT_PATH)/lib/libsoxr.a - #$(COMPONENT_PATH)/lib/libfaad.a #$(COMPONENT_PATH)/lib/libvorbisidec.a #$(COMPONENT_PATH)/lib/libogg.a diff --git a/components/codecs/inc/resample16/resample16.h b/components/codecs/inc/resample16/resample16.h index ddf3aced..e38c020f 100644 --- a/components/codecs/inc/resample16/resample16.h +++ b/components/codecs/inc/resample16/resample16.h @@ -74,11 +74,18 @@ typedef int WORD; typedef unsigned int UWORD; struct resample16_s; +typedef struct { + UHWORD LpScl; /* Unity-gain scale factor */ + UHWORD Nwing; /* Filter table size */ + UHWORD Nmult; /* Filter length for up-conversions */ + const HWORD *Imp; /* Filter coefficients */ + const HWORD *ImpD; /* ImpD[n] = Imp[n+1]-Imp[n] */ +} resample16_filter_t; -typedef enum { RESAMPLE16_FAST, RESAMPLE16_SMALL, RESAMPLE16_LARGE, RESAMPLE_CUSTOM } resample16_filter_e; +typedef enum { RESAMPLE16_BASIC, RESAMPLE16_LOW, RESAMPLE16_MED } 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); +struct resample16_s* resample16_create(float factor, resample16_filter_e filter, resample16_filter_t *custom, BOOL interp); void resample16_delete(struct resample16_s *r); void resample16_flush(struct resample16_s *r); diff --git a/components/codecs/lib/libresample16.a b/components/codecs/lib/libresample16.a index 8772f252..80ae2fdf 100644 Binary files a/components/codecs/lib/libresample16.a and b/components/codecs/lib/libresample16.a differ diff --git a/main/main.c b/main/main.c index ac354ea5..e1e4cf5e 100644 --- a/main/main.c +++ b/main/main.c @@ -112,8 +112,8 @@ static void usage(const char *argv0) { " \t\t\t phase_response = 0-100 (0 = minimum / 50 = linear / 100 = maximum)\n" #endif #if RESAMPLE16 - " -R -u [params]\tResample, params = (i|m)[:i],\n" - " \t\t\t i = linear interpolation, m = 13 taps filter, i = interpolate filter coefficients\n" + " -R -u [params]\tResample, params = (b|l|m)[:i],\n" + " \t\t\t b = basic linear interpolation, l = 13 taps, m = 21 taps, i = interpolate filter coefficients\n" #endif #if DSD #if ALSA diff --git a/main/resample16.c b/main/resample16.c index f86ac798..80bb74f3 100644 --- a/main/resample16.c +++ b/main/resample16.c @@ -116,7 +116,7 @@ bool resample_newstream(struct processstate *process, unsigned raw_sample_rate, if (raw_sample_rate != outrate) { LOG_INFO("resampling from %u -> %u", raw_sample_rate, outrate); - r.resampler = resample16_create((float) outrate / raw_sample_rate, RESAMPLE16_SMALL, false); + r.resampler = resample16_create((float) outrate / raw_sample_rate, r.filter, NULL, false); return true; @@ -147,8 +147,9 @@ bool resample_init(char *opt) { } if (filter) { - if (*filter == 'm') r.filter = RESAMPLE16_SMALL; - else r.filter = RESAMPLE16_FAST; + if (*filter == 'm') r.filter = RESAMPLE16_MED; + else if (*filter == 'l') r.filter = RESAMPLE16_LOW; + else r.filter = RESAMPLE16_BASIC; } if (interp && *interp == 'i') {