From 1459271f3dab16fd88eb05387653a423ce866da9 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sat, 4 Jul 2009 13:58:21 +0000 Subject: [PATCH] added resample filter taps for ratio 3/4 --- src/resample.cpp | 2 +- src/resamplefilter.h | 24 ++++++++++++++++++++++++ src/resamplefilter.m | 36 +++++++++++++++++++++++++++++------- 3 files changed, 54 insertions(+), 8 deletions(-) diff --git a/src/resample.cpp b/src/resample.cpp index c841c235..01015699 100755 --- a/src/resample.cpp +++ b/src/resample.cpp @@ -154,7 +154,7 @@ void CStereoAudioResample::Init ( const int iNewMonoInputBlockSize, iMonoOutputBlockSize = (int) ( iNewMonoInputBlockSize * dRation ); // set correct parameters - if ( iFrom == SND_CRD_SAMPLE_RATE ) // downsampling case + if ( iFrom >= iTo ) // downsampling case { switch ( iTo ) { diff --git a/src/resamplefilter.h b/src/resamplefilter.h index 550680de..80996d3c 100644 --- a/src/resamplefilter.h +++ b/src/resamplefilter.h @@ -6,11 +6,14 @@ #define _RESAMPLEFILTER_H_ #define NUM_TAPS_PER_PHASE2 4 +#define NUM_TAPS_PER_PHASE4_3 4 #define NUM_TAPS_PER_PHASE3_2 4 #define NUM_TAPS_PER_PHASE12_7 4 #define NUM_TAPS_PER_PHASE1 4 #define INTERP_I_2 2 #define DECIM_D_2 1 +#define INTERP_I_4_3 4 +#define DECIM_D_4_3 3 #define INTERP_I_3_2 3 #define DECIM_D_3_2 2 #define INTERP_I_12_7 12 @@ -32,6 +35,27 @@ static float fResTaps2[INTERP_I_2 * DECIM_D_2 * NUM_TAPS_PER_PHASE2] = { }; +// Filter for ratio 4 / 3 +static float fResTaps4_3[INTERP_I_4_3 * DECIM_D_4_3 * NUM_TAPS_PER_PHASE4_3] = { + -0.00168001826454421440f, + -0.01144215502840437900f, + -0.02497303843128512500f, + -0.01659712409419326200f, + 0.04986971950193624900f, + 0.18653698120980966000f, + 0.35284376758014113000f, + 0.46867597265041389000f, + 0.46867597265041389000f, + 0.35284376758014113000f, + 0.18653698120980966000f, + 0.04986971950193624900f, + -0.01659712409419326200f, + -0.02497303843128512500f, + -0.01144215502840437900f, + -0.00168001826454421440f +}; + + // Filter for ratio 3 / 2 static float fResTaps3_2[INTERP_I_3_2 * DECIM_D_3_2 * NUM_TAPS_PER_PHASE3_2] = { -0.00236050848304511720f, diff --git a/src/resamplefilter.m b/src/resamplefilter.m index 33c48ebc..29482f5c 100755 --- a/src/resamplefilter.m +++ b/src/resamplefilter.m @@ -1,10 +1,10 @@ -%/******************************************************************************\ -% * Copyright (c) 2004-2009 -% * -% * Author(s): -% * Volker Fischer -% * -%\******************************************************************************/ +% /****************************************************************************\ +% * Copyright (c) 2004-2009 +% * +% * Author(s): +% * Volker Fischer +% * +% \****************************************************************************/ function resamplefilter() @@ -12,6 +12,7 @@ function resamplefilter() GlobalNoTaps = 4; % use global value for all types NoTapsP2 = GlobalNoTaps; % 24 kHz +NoTapsP4_3 = GlobalNoTaps; % 32 kHz <-> 24 kHz NoTapsP3_2 = GlobalNoTaps; % 32 kHz NoTapsP12_7 = GlobalNoTaps; % 28 kHz NoTapsP1 = GlobalNoTaps; % 48 kHz @@ -26,6 +27,15 @@ D2 = 1; h2 = DesignFilter(NoTapsP2, I2); +% Filter for ratio 4 / 3 ------------------------------------------------------- +% I and D +I4_3 = 4; +D4_3 = 3; + +% filter design +h4_3 = DesignFilter(NoTapsP4_3, I4_3); + + % Filter for ratio 3 / 2 ------------------------------------------------------- % I and D I3_2 = 3; @@ -65,6 +75,9 @@ fprintf(fid, '#define _RESAMPLEFILTER_H_\n\n'); fprintf(fid, '#define NUM_TAPS_PER_PHASE2 '); fprintf(fid, int2str(NoTapsP2)); fprintf(fid, '\n'); +fprintf(fid, '#define NUM_TAPS_PER_PHASE4_3 '); +fprintf(fid, int2str(NoTapsP4_3)); +fprintf(fid, '\n'); fprintf(fid, '#define NUM_TAPS_PER_PHASE3_2 '); fprintf(fid, int2str(NoTapsP3_2)); fprintf(fid, '\n'); @@ -80,6 +93,12 @@ fprintf(fid, '\n'); fprintf(fid, '#define DECIM_D_2 '); fprintf(fid, int2str(D2)); fprintf(fid, '\n'); +fprintf(fid, '#define INTERP_I_4_3 '); +fprintf(fid, int2str(I4_3)); +fprintf(fid, '\n'); +fprintf(fid, '#define DECIM_D_4_3 '); +fprintf(fid, int2str(D4_3)); +fprintf(fid, '\n'); fprintf(fid, '#define INTERP_I_3_2 '); fprintf(fid, int2str(I3_2)); fprintf(fid, '\n'); @@ -101,6 +120,9 @@ fprintf(fid, '\n\n'); fprintf(fid, '\n// Filter for ratio 2\n'); ExportFilterTaps(fid, 'fResTaps2[INTERP_I_2 * DECIM_D_2 * NUM_TAPS_PER_PHASE2]', h2); +fprintf(fid, '\n// Filter for ratio 4 / 3\n'); +ExportFilterTaps(fid, 'fResTaps4_3[INTERP_I_4_3 * DECIM_D_4_3 * NUM_TAPS_PER_PHASE4_3]', h4_3); + fprintf(fid, '\n// Filter for ratio 3 / 2\n'); ExportFilterTaps(fid, 'fResTaps3_2[INTERP_I_3_2 * DECIM_D_3_2 * NUM_TAPS_PER_PHASE3_2]', h3_2);