support for 28 kHz sample rate -> sample rate conversion is not working correctly right now, TODO find the bug

This commit is contained in:
Volker Fischer 2008-08-06 06:51:46 +00:00
parent 5fe78dda7d
commit f425bf3d8b
3 changed files with 405 additions and 216 deletions

View file

@ -204,6 +204,12 @@ void CAudioResample::Init ( const int iNewInputBlockSize,
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;
@ -212,6 +218,9 @@ void CAudioResample::Init ( const int iNewInputBlockSize,
case SND_CRD_SAMPLE_RATE: // 48 kHz to 48 kHz
// no resampling needed
pFiltTaps = NULL;
iNumTaps = 0;
iI = 1;
break;
default:
@ -230,6 +239,12 @@ void CAudioResample::Init ( const int iNewInputBlockSize,
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;

View file

@ -7,11 +7,14 @@
#define NUM_TAPS_PER_PHASE2 12
#define NUM_TAPS_PER_PHASE3_2 12
#define NUM_TAPS_PER_PHASE12_7 12
#define NUM_TAPS_PER_PHASE1 12
#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_DECIM_I_D1 10
@ -85,6 +88,155 @@ static float fResTaps3_2[INTERP_I_3_2 * DECIM_D_3_2 * NUM_TAPS_PER_PHASE3_2] = {
-0.00176046250093099540f
};
// Filter for ratio 12 / 7
static float fResTaps12_7[INTERP_I_12_7 * DECIM_D_12_7 * NUM_TAPS_PER_PHASE12_7] = {
-0.00125208827289417920f,
-0.00190626448556412160f,
-0.00258725330105407910f,
-0.00321911699468315850f,
-0.00371304124871946240f,
-0.00397449433584967650f,
-0.00391226244728601170f,
-0.00344872729447937270f,
-0.00253053775303447700f,
-0.00113866891904707700f,
0.00070321859502462086f,
0.00292319218332290870f,
0.00539918825312160800f,
0.00796161187294208010f,
0.01040080648737300700f,
0.01247940789020031800f,
0.01394914970162503700f,
0.01457122611642731000f,
0.01413888175955135800f,
0.01250052994177179200f,
0.00958143947199255330f,
0.00540191094345563410f,
0.00008991148771200068f,
-0.00611363430350713410f,
-0.01285829127084545300f,
-0.01969712096259990500f,
-0.02610936928229550000f,
-0.03153216669657662300f,
-0.03539975740910365800f,
-0.03718799481084937600f,
-0.03646116541074920900f,
-0.03291769690105803700f,
-0.02643102432092192500f,
-0.01708187424006729600f,
-0.00517850526744063640f,
0.00873798258468762820f,
0.02390530685294215600f,
0.03936958373129542700f,
0.05403253332659402300f,
0.06671467306160311400f,
0.07623153406248735200f,
0.08147871600785833200f,
0.08152058589868019200f,
0.07567671586657001600f,
0.06359981811742342100f,
0.04533902176348663500f,
0.02138286854317816500f,
-0.00732262749824698880f,
-0.03938414980169741000f,
-0.07300109067071840200f,
-0.10603511604421303000f,
-0.13610699820077277000f,
-0.16071647179549162000f,
-0.17737908657056814000f,
-0.18377255785167662000f,
-0.17788407020636693000f,
-0.15814946187689599000f,
-0.12357526654261679000f,
-0.07383523520087217900f,
-0.00933418413014485730f,
0.06876624614792664600f,
0.15856318013703752000f,
0.25747026200729783000f,
0.36231581851199790000f,
0.46947713391879947000f,
0.57504420553142555000f,
0.67500437604388086000f,
0.76543776689193965000f,
0.84271257101448604000f,
0.90366907084389148000f,
0.94578175032061074000f,
0.96729004417063957000f,
0.96729004417063957000f,
0.94578175032061074000f,
0.90366907084389148000f,
0.84271257101448604000f,
0.76543776689193965000f,
0.67500437604388086000f,
0.57504420553142555000f,
0.46947713391879947000f,
0.36231581851199790000f,
0.25747026200729783000f,
0.15856318013703752000f,
0.06876624614792664600f,
-0.00933418413014485730f,
-0.07383523520087217900f,
-0.12357526654261679000f,
-0.15814946187689599000f,
-0.17788407020636693000f,
-0.18377255785167662000f,
-0.17737908657056814000f,
-0.16071647179549162000f,
-0.13610699820077277000f,
-0.10603511604421303000f,
-0.07300109067071840200f,
-0.03938414980169741000f,
-0.00732262749824698880f,
0.02138286854317816500f,
0.04533902176348663500f,
0.06359981811742342100f,
0.07567671586657001600f,
0.08152058589868019200f,
0.08147871600785833200f,
0.07623153406248735200f,
0.06671467306160311400f,
0.05403253332659402300f,
0.03936958373129542700f,
0.02390530685294215600f,
0.00873798258468762820f,
-0.00517850526744063640f,
-0.01708187424006729600f,
-0.02643102432092192500f,
-0.03291769690105803700f,
-0.03646116541074920900f,
-0.03718799481084937600f,
-0.03539975740910365800f,
-0.03153216669657662300f,
-0.02610936928229550000f,
-0.01969712096259990500f,
-0.01285829127084545300f,
-0.00611363430350713410f,
0.00008991148771200068f,
0.00540191094345563410f,
0.00958143947199255330f,
0.01250052994177179200f,
0.01413888175955135800f,
0.01457122611642731000f,
0.01394914970162503700f,
0.01247940789020031800f,
0.01040080648737300700f,
0.00796161187294208010f,
0.00539918825312160800f,
0.00292319218332290870f,
0.00070321859502462086f,
-0.00113866891904707700f,
-0.00253053775303447700f,
-0.00344872729447937270f,
-0.00391226244728601170f,
-0.00397449433584967650f,
-0.00371304124871946240f,
-0.00321911699468315850f,
-0.00258725330105407910f,
-0.00190626448556412160f,
-0.00125208827289417920f
};
// Filter for ratios close to 1
static float fResTaps1[INTERP_DECIM_I_D1 * NUM_TAPS_PER_PHASE1] = {
-0.00129181992672801360f,

View file

@ -9,9 +9,10 @@
function resamplefilter()
% Number of taps per poly phase for different resampling types
NoTapsP2 = 12;
NoTapsP3_2 = 12;
NoTapsP1 = 12;
NoTapsP2 = 12; % 24 kHz
NoTapsP3_2 = 12; % 32 kHz
NoTapsP12_7 = 12; % 28 kHz
NoTapsP1 = 12; % 48 kHz
% Filter for ratio 2 -----------------------------------------------------------
@ -32,6 +33,15 @@ D3_2 = 2;
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);
% Filter for ratios close to 1 -------------------------------------------------
% Fixed for sample-rate conversiones of R ~ 1
I1 = 10; % D = I in this mode
@ -56,6 +66,9 @@ 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, '\n');
fprintf(fid, '#define NUM_TAPS_PER_PHASE1 ');
fprintf(fid, int2str(NoTapsP1));
fprintf(fid, '\n');
@ -71,6 +84,12 @@ 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, '\n');
fprintf(fid, '#define INTERP_DECIM_I_D1 ');
fprintf(fid, int2str(I1));
fprintf(fid, '\n');
@ -83,6 +102,9 @@ ExportFilterTaps(fid, 'fResTaps2[INTERP_I_2 * DECIM_D_2 * NUM_TAPS_PER_PHASE2]',
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, '// Filter for ratios close to 1\n');
ExportFilterTaps(fid, 'fResTaps1[INTERP_DECIM_I_D1 * NUM_TAPS_PER_PHASE1]', h1);