new sample rate, default port number, removed 4/3 sample rate filter
This commit is contained in:
parent
c7168206d0
commit
fa7617be21
4 changed files with 50 additions and 136 deletions
|
@ -43,7 +43,7 @@
|
|||
|
||||
// version and application name (always use this version)
|
||||
#undef VERSION
|
||||
#define VERSION "2.2.3cvs"
|
||||
#define VERSION "2.3.0cvs"
|
||||
#define APP_NAME "llcon"
|
||||
|
||||
// file name for logging file
|
||||
|
@ -53,10 +53,10 @@
|
|||
#define DEFAULT_SERVER_ADDRESS "llcon.dyndns.org"
|
||||
|
||||
// defined port number for client and server
|
||||
#define LLCON_DEFAULT_PORT_NUMBER 22122
|
||||
#define LLCON_DEFAULT_PORT_NUMBER 22123
|
||||
|
||||
// system sample rate
|
||||
#define SYSTEM_SAMPLE_RATE 24000
|
||||
#define SYSTEM_SAMPLE_RATE 32000
|
||||
|
||||
// sound card sample rate. Should be always 48 kHz to avoid sound card driver
|
||||
// internal sample rate conversion which might be buggy
|
||||
|
|
134
src/resample.cpp
134
src/resample.cpp
|
@ -149,105 +149,65 @@ void CStereoAudioResample::Init ( const int iNewMonoInputBlockSize,
|
|||
// set correct parameters
|
||||
if ( iFrom >= iTo ) // downsampling case
|
||||
{
|
||||
if ( iFrom == SND_CRD_SAMPLE_RATE )
|
||||
switch ( iTo )
|
||||
{
|
||||
// sound card resampling
|
||||
switch ( iTo )
|
||||
{
|
||||
case ( SND_CRD_SAMPLE_RATE / 2 ): // 48 kHz to 24 kHz
|
||||
pFiltTaps = fResTaps2;
|
||||
iNumTaps = INTERP_I_2 * NUM_TAPS_PER_PHASE2;
|
||||
iI = DECIM_D_2;
|
||||
break;
|
||||
case ( SND_CRD_SAMPLE_RATE / 2 ): // 48 kHz to 24 kHz
|
||||
pFiltTaps = fResTaps2;
|
||||
iNumTaps = INTERP_I_2 * NUM_TAPS_PER_PHASE2;
|
||||
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 * 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;
|
||||
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;
|
||||
break;
|
||||
|
||||
case SND_CRD_SAMPLE_RATE: // 48 kHz to 48 kHz
|
||||
// no resampling needed
|
||||
pFiltTaps = NULL;
|
||||
iNumTaps = 0;
|
||||
iI = 1;
|
||||
break;
|
||||
case SND_CRD_SAMPLE_RATE: // 48 kHz to 48 kHz
|
||||
// no resampling needed
|
||||
pFiltTaps = NULL;
|
||||
iNumTaps = 0;
|
||||
iI = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
// resample ratio not defined, throw error
|
||||
throw 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// general sampling rate conversion
|
||||
if ( ( iFrom == 32000 ) && ( iTo == 24000 ) )
|
||||
{
|
||||
// 32 kHz to 24 kHz
|
||||
pFiltTaps = fResTaps4_3;
|
||||
iNumTaps = INTERP_I_4_3 * NUM_TAPS_PER_PHASE4_3;
|
||||
iI = DECIM_D_4_3;
|
||||
}
|
||||
else
|
||||
{
|
||||
// resample ratio not defined, throw error
|
||||
throw 0;
|
||||
}
|
||||
default:
|
||||
// resample ratio not defined, throw error
|
||||
throw 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else // upsampling case
|
||||
else // upsampling case (assumption: iTo == SND_CRD_SAMPLE_RATE)
|
||||
{
|
||||
if ( iTo == SND_CRD_SAMPLE_RATE )
|
||||
switch ( iFrom )
|
||||
{
|
||||
// sound card resampling
|
||||
switch ( iFrom )
|
||||
{
|
||||
case ( SND_CRD_SAMPLE_RATE / 2 ): // 24 kHz to 48 kHz
|
||||
pFiltTaps = fResTaps2;
|
||||
iNumTaps = DECIM_D_2 * NUM_TAPS_PER_PHASE2;
|
||||
iI = INTERP_I_2;
|
||||
break;
|
||||
case ( SND_CRD_SAMPLE_RATE / 2 ): // 24 kHz to 48 kHz
|
||||
pFiltTaps = fResTaps2;
|
||||
iNumTaps = DECIM_D_2 * NUM_TAPS_PER_PHASE2;
|
||||
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 * 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;
|
||||
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;
|
||||
break;
|
||||
|
||||
default:
|
||||
// resample ratio not defined, throw error
|
||||
throw 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// general sampling rate conversion
|
||||
if ( ( iFrom == 24000 ) && ( iTo == 32000 ) )
|
||||
{
|
||||
// 24 kHz to 32 kHz
|
||||
pFiltTaps = fResTaps4_3;
|
||||
iNumTaps = DECIM_D_4_3 * NUM_TAPS_PER_PHASE4_3;
|
||||
iI = INTERP_I_4_3;
|
||||
}
|
||||
else
|
||||
{
|
||||
// resample ratio not defined, throw error
|
||||
throw 0;
|
||||
}
|
||||
default:
|
||||
// resample ratio not defined, throw error
|
||||
throw 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,14 +6,11 @@
|
|||
#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
|
||||
|
@ -35,27 +32,6 @@ 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,
|
||||
|
|
|
@ -12,7 +12,6 @@ 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
|
||||
|
@ -27,15 +26,6 @@ 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;
|
||||
|
@ -75,9 +65,6 @@ 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');
|
||||
|
@ -93,12 +80,6 @@ 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');
|
||||
|
@ -120,9 +101,6 @@ 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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue