diff --git a/src/global.h b/src/global.h index 0cc65d54..ca751b33 100755 --- a/src/global.h +++ b/src/global.h @@ -56,7 +56,7 @@ #define LLCON_DEFAULT_PORT_NUMBER 22123 // system sample rate -#define SYSTEM_SAMPLE_RATE 32000 +#define SYSTEM_SAMPLE_RATE 33000 // sound card sample rate. Should be always 48 kHz to avoid sound card driver // internal sample rate conversion which might be buggy diff --git a/src/resample.cpp b/src/resample.cpp index 4bc71463..8f9fccec 100755 --- a/src/resample.cpp +++ b/src/resample.cpp @@ -157,16 +157,10 @@ void CStereoAudioResample::Init ( const int iNewMonoInputBlockSize, iI = DECIM_D_2; break; - case ( SND_CRD_SAMPLE_RATE * 7 / 12 ): // 48 kHz to 28 kHz - pFiltTaps = fResTaps12_7; - iNumTaps = INTERP_I_12_7 * NUM_TAPS_PER_PHASE12_7; - iI = DECIM_D_12_7; - break; - - case ( SND_CRD_SAMPLE_RATE * 2 / 3 ): // 48 kHz to 32 kHz - pFiltTaps = fResTaps3_2; - iNumTaps = INTERP_I_3_2 * NUM_TAPS_PER_PHASE3_2; - iI = DECIM_D_3_2; + case ( SND_CRD_SAMPLE_RATE * 11 / 16 ): // 48 kHz to 33 kHz + pFiltTaps = fResTaps16_11; + iNumTaps = INTERP_I_16_11 * NUM_TAPS_PER_PHASE16_11; + iI = DECIM_D_16_11; break; case SND_CRD_SAMPLE_RATE: // 48 kHz to 48 kHz @@ -192,16 +186,10 @@ void CStereoAudioResample::Init ( const int iNewMonoInputBlockSize, iI = INTERP_I_2; break; - case ( SND_CRD_SAMPLE_RATE * 7 / 12 ): // 28 kHz to 48 kHz - pFiltTaps = fResTaps12_7; - iNumTaps = DECIM_D_12_7 * NUM_TAPS_PER_PHASE12_7; - iI = INTERP_I_12_7; - break; - - case ( SND_CRD_SAMPLE_RATE * 2 / 3 ): // 32 kHz to 48 kHz - pFiltTaps = fResTaps3_2; - iNumTaps = DECIM_D_3_2 * NUM_TAPS_PER_PHASE3_2; - iI = INTERP_I_3_2; + case ( SND_CRD_SAMPLE_RATE * 11 / 16 ): // 33 kHz to 48 kHz + pFiltTaps = fResTaps16_11; + iNumTaps = DECIM_D_16_11 * NUM_TAPS_PER_PHASE16_11; + iI = INTERP_I_16_11; break; default: diff --git a/src/resamplefilter.h b/src/resamplefilter.h index 550680de..39c9a23a 100644 --- a/src/resamplefilter.h +++ b/src/resamplefilter.h @@ -6,15 +6,12 @@ #define _RESAMPLEFILTER_H_ #define NUM_TAPS_PER_PHASE2 4 -#define NUM_TAPS_PER_PHASE3_2 4 -#define NUM_TAPS_PER_PHASE12_7 4 +#define NUM_TAPS_PER_PHASE16_11 4 #define NUM_TAPS_PER_PHASE1 4 #define INTERP_I_2 2 #define DECIM_D_2 1 -#define INTERP_I_3_2 3 -#define DECIM_D_3_2 2 -#define INTERP_I_12_7 12 -#define DECIM_D_12_7 7 +#define INTERP_I_16_11 16 +#define DECIM_D_16_11 11 #define INTERP_DECIM_I_D1 10 @@ -32,73 +29,72 @@ static float fResTaps2[INTERP_I_2 * DECIM_D_2 * NUM_TAPS_PER_PHASE2] = { }; -// Filter for ratio 3 / 2 -static float fResTaps3_2[INTERP_I_3_2 * DECIM_D_3_2 * NUM_TAPS_PER_PHASE3_2] = { - -0.00236050848304511720f, - -0.01964925537472771800f, - -0.02322665824624670800f, - 0.07695645894852715100f, - 0.31008603640539528000f, - 0.52643626441129154000f, - 0.52643626441129154000f, - 0.31008603640539528000f, - 0.07695645894852715100f, - -0.02322665824624670800f, - -0.01964925537472771800f, - -0.00236050848304511720f -}; - - -// Filter for ratio 12 / 7 -static float fResTaps12_7[INTERP_I_12_7 * DECIM_D_12_7 * NUM_TAPS_PER_PHASE12_7] = { - -0.00053443628842632721f, - -0.00154456511654914500f, - -0.00318877973492145670f, - -0.00548415611879476010f, - -0.00831996900560136310f, - -0.01142644215457233100f, - -0.01435914512086756300f, - -0.01650486134503697700f, - -0.01711253513002239700f, - -0.01534980745584262400f, - -0.01038204348602874600f, - -0.00146712812293579720f, - 0.01194379798880749800f, - 0.03011155812550227500f, - 0.05293264234056074100f, - 0.07989289520785943000f, - 0.11006001475908662000f, - 0.14211961311732932000f, - 0.17445458077244999000f, - 0.20526218373129310000f, - 0.23269841067097030000f, - 0.25503525684230932000f, - 0.27081444032816293000f, - 0.27898084356141867000f, - 0.27898084356141867000f, - 0.27081444032816293000f, - 0.25503525684230932000f, - 0.23269841067097030000f, - 0.20526218373129310000f, - 0.17445458077244999000f, - 0.14211961311732932000f, - 0.11006001475908662000f, - 0.07989289520785943000f, - 0.05293264234056074100f, - 0.03011155812550227500f, - 0.01194379798880749800f, - -0.00146712812293579720f, - -0.01038204348602874600f, - -0.01534980745584262400f, - -0.01711253513002239700f, - -0.01650486134503697700f, - -0.01435914512086756300f, - -0.01142644215457233100f, - -0.00831996900560136310f, - -0.00548415611879476010f, - -0.00318877973492145670f, - -0.00154456511654914500f, - -0.00053443628842632721f +// Filter for ratio 16 / 11 +static float fResTaps16_11[INTERP_I_16_11 * DECIM_D_16_11 * NUM_TAPS_PER_PHASE16_11] = { + -0.00041538398445601011f, + -0.00100091112500674300f, + -0.00188545235900149580f, + -0.00309245271152946720f, + -0.00461648637097546860f, + -0.00641536079120213090f, + -0.00840374276694629340f, + -0.01044911278449296500f, + -0.01237076454632044700f, + -0.01394240453358767100f, + -0.01489867899787415000f, + -0.01494567649453993500f, + -0.01377514228383602500f, + -0.01108182026370746600f, + -0.00658303471198398540f, + -0.00003936453391759546f, + 0.00872492845809500280f, + 0.01980315802304051200f, + 0.03319059870725740000f, + 0.04877332727115071100f, + 0.06632263168859610400f, + 0.08549578434166034400f, + 0.10584358400577590000f, + 0.12682462834108582000f, + 0.14782581648829729000f, + 0.16818813437991034000f, + 0.18723637790984679000f, + 0.20431115275701389000f, + 0.21880128059464088000f, + 0.23017465811007956000f, + 0.23800566683418956000f, + 0.24199741710446424000f, + 0.24199741710446424000f, + 0.23800566683418956000f, + 0.23017465811007956000f, + 0.21880128059464088000f, + 0.20431115275701389000f, + 0.18723637790984679000f, + 0.16818813437991034000f, + 0.14782581648829729000f, + 0.12682462834108582000f, + 0.10584358400577590000f, + 0.08549578434166034400f, + 0.06632263168859610400f, + 0.04877332727115071100f, + 0.03319059870725740000f, + 0.01980315802304051200f, + 0.00872492845809500280f, + -0.00003936453391759546f, + -0.00658303471198398540f, + -0.01108182026370746600f, + -0.01377514228383602500f, + -0.01494567649453993500f, + -0.01489867899787415000f, + -0.01394240453358767100f, + -0.01237076454632044700f, + -0.01044911278449296500f, + -0.00840374276694629340f, + -0.00641536079120213090f, + -0.00461648637097546860f, + -0.00309245271152946720f, + -0.00188545235900149580f, + -0.00100091112500674300f, + -0.00041538398445601011f }; // Filter for ratios close to 1 diff --git a/src/resamplefilter.m b/src/resamplefilter.m index 5da6bfe1..5b3d13da 100755 --- a/src/resamplefilter.m +++ b/src/resamplefilter.m @@ -11,10 +11,9 @@ function resamplefilter() % Number of taps per poly phase for different resampling types GlobalNoTaps = 4; % use global value for all types -NoTapsP2 = GlobalNoTaps; % 24 kHz -NoTapsP3_2 = GlobalNoTaps; % 32 kHz -NoTapsP12_7 = GlobalNoTaps; % 28 kHz -NoTapsP1 = GlobalNoTaps; % 48 kHz +NoTapsP2 = GlobalNoTaps; % 24 kHz +NoTapsP16_11 = GlobalNoTaps; % 33 kHz +NoTapsP1 = GlobalNoTaps; % 48 kHz % Filter for ratio 2 ----------------------------------------------------------- @@ -26,22 +25,13 @@ D2 = 1; h2 = DesignFilter(NoTapsP2, I2); -% Filter for ratio 3 / 2 ------------------------------------------------------- +% Filter for ratio 16 / 11 ----------------------------------------------------- % I and D -I3_2 = 3; -D3_2 = 2; +I16_11 = 16; +D16_11 = 11; % filter design -h3_2 = DesignFilter(NoTapsP3_2, I3_2); - - -% Filter for ratio 12 / 7 ------------------------------------------------------ -% I and D -I12_7 = 12; -D12_7 = 7; - -% filter design -h12_7 = DesignFilter(NoTapsP12_7, I12_7); +h16_11 = DesignFilter(NoTapsP16_11, I16_11); % Filter for ratios close to 1 ------------------------------------------------- @@ -65,11 +55,8 @@ 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_PHASE3_2 '); -fprintf(fid, int2str(NoTapsP3_2)); -fprintf(fid, '\n'); -fprintf(fid, '#define NUM_TAPS_PER_PHASE12_7 '); -fprintf(fid, int2str(NoTapsP12_7)); +fprintf(fid, '#define NUM_TAPS_PER_PHASE16_11 '); +fprintf(fid, int2str(NoTapsP16_11)); fprintf(fid, '\n'); fprintf(fid, '#define NUM_TAPS_PER_PHASE1 '); fprintf(fid, int2str(NoTapsP1)); @@ -80,17 +67,11 @@ fprintf(fid, '\n'); fprintf(fid, '#define DECIM_D_2 '); fprintf(fid, int2str(D2)); fprintf(fid, '\n'); -fprintf(fid, '#define INTERP_I_3_2 '); -fprintf(fid, int2str(I3_2)); +fprintf(fid, '#define INTERP_I_16_11 '); +fprintf(fid, int2str(I16_11)); fprintf(fid, '\n'); -fprintf(fid, '#define DECIM_D_3_2 '); -fprintf(fid, int2str(D3_2)); -fprintf(fid, '\n'); -fprintf(fid, '#define INTERP_I_12_7 '); -fprintf(fid, int2str(I12_7)); -fprintf(fid, '\n'); -fprintf(fid, '#define DECIM_D_12_7 '); -fprintf(fid, int2str(D12_7)); +fprintf(fid, '#define DECIM_D_16_11 '); +fprintf(fid, int2str(D16_11)); fprintf(fid, '\n'); fprintf(fid, '#define INTERP_DECIM_I_D1 '); fprintf(fid, int2str(I1)); @@ -101,11 +82,8 @@ 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 3 / 2\n'); -ExportFilterTaps(fid, 'fResTaps3_2[INTERP_I_3_2 * DECIM_D_3_2 * NUM_TAPS_PER_PHASE3_2]', h3_2); - -fprintf(fid, '\n// Filter for ratio 12 / 7\n'); -ExportFilterTaps(fid, 'fResTaps12_7[INTERP_I_12_7 * DECIM_D_12_7 * NUM_TAPS_PER_PHASE12_7]', h12_7); +fprintf(fid, '\n// Filter for ratio 16 / 11\n'); +ExportFilterTaps(fid, 'fResTaps16_11[INTERP_I_16_11 * DECIM_D_16_11 * NUM_TAPS_PER_PHASE16_11]', h16_11); fprintf(fid, '// Filter for ratios close to 1\n'); ExportFilterTaps(fid, 'fResTaps1[INTERP_DECIM_I_D1 * NUM_TAPS_PER_PHASE1]', h1);