Working RRC filter design
This commit is contained in:
parent
d1af45a588
commit
bfc6f5dea0
2 changed files with 17 additions and 12 deletions
17
csdr.c
17
csdr.c
|
@ -3039,22 +3039,26 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if(argc<=2) return badsyntax("required parameter <matched_filter_type> is missing.");
|
if(argc<=2) return badsyntax("required parameter <matched_filter_type> is missing.");
|
||||||
matched_filter_type_t type = matched_filter_get_type_from_string(argv[2]);
|
matched_filter_type_t type = matched_filter_get_type_from_string(argv[2]);
|
||||||
int samples_per_symbol = 0;
|
|
||||||
|
|
||||||
|
int samples_per_symbol = 0;
|
||||||
if(argc<=3) return badsyntax("required parameter <samples_per_symbol> is missing.");
|
if(argc<=3) return badsyntax("required parameter <samples_per_symbol> is missing.");
|
||||||
sscanf(argv[3],"%d",&samples_per_symbol);
|
sscanf(argv[3],"%d",&samples_per_symbol);
|
||||||
|
|
||||||
int num_taps = 0;
|
int num_taps = 0;
|
||||||
if(argc<=4 && type!=MATCHED_FILTER_COSINE)
|
if(type!=MATCHED_FILTER_COSINE)
|
||||||
return badsyntax("required parameter <num_taps> is missing.");
|
{
|
||||||
|
if(argc<=4) return badsyntax("required parameter <num_taps> is missing.");
|
||||||
sscanf(argv[4],"%d",&num_taps);
|
sscanf(argv[4],"%d",&num_taps);
|
||||||
|
}
|
||||||
|
else num_taps = (2*samples_per_symbol)+1;
|
||||||
|
|
||||||
float beta = 0;
|
float beta = 0;
|
||||||
if(argc<=5 && type==MATCHED_FILTER_RRC)
|
if(type==MATCHED_FILTER_RRC)
|
||||||
return badsyntax("required parameter <beta> is missing.");
|
{
|
||||||
|
if(argc<=5) return badsyntax("required parameter <beta> is missing.");
|
||||||
sscanf(argv[5],"%f",&beta);
|
sscanf(argv[5],"%f",&beta);
|
||||||
|
}
|
||||||
|
|
||||||
if(type==MATCHED_FILTER_COSINE) num_taps = (2*samples_per_symbol)+1;
|
|
||||||
float* taps = (float*)malloc(sizeof(float)*num_taps);
|
float* taps = (float*)malloc(sizeof(float)*num_taps);
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
|
@ -3065,6 +3069,7 @@ int main(int argc, char *argv[])
|
||||||
firdes_cosine_f(taps, num_taps, samples_per_symbol);
|
firdes_cosine_f(taps, num_taps, samples_per_symbol);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
//fprintf(stderr, "beta = %f, num_taps = %d, samples_per_symbol = %d\n", beta, num_taps, samples_per_symbol);
|
||||||
|
|
||||||
if(!sendbufsize(initialize_buffers())) return -2;
|
if(!sendbufsize(initialize_buffers())) return -2;
|
||||||
|
|
||||||
|
|
|
@ -2371,13 +2371,13 @@ int firdes_rrc_f(float* taps, int taps_length, int samples_per_symbol, float bet
|
||||||
{
|
{
|
||||||
//needs an odd taps_length
|
//needs an odd taps_length
|
||||||
int middle_i=taps_length/2;
|
int middle_i=taps_length/2;
|
||||||
taps[middle_i]=(1/samples_per_symbol)*(1+beta*(4/PI-1));
|
taps[middle_i]=(1/(float)samples_per_symbol)*(1+beta*(4/PI-1));
|
||||||
for(int i=1;i<taps_length/2;i++)
|
for(int i=1;i<1+taps_length/2;i++)
|
||||||
{
|
{
|
||||||
if(i==samples_per_symbol/(4*beta))
|
if(i==samples_per_symbol/(4*beta))
|
||||||
taps[middle_i+i]=taps[middle_i-i]=(beta/(samples_per_symbol*sqrt(2)))*((1+(2/PI))*sin(PI/(4*beta))+(1-(2/PI)*cos(PI/(4*beta))));
|
taps[middle_i+i]=taps[middle_i-i]=(beta/(samples_per_symbol*sqrt(2)))*((1+(2/PI))*sin(PI/(4*beta))+(1-(2/PI))*cos(PI/(4*beta)));
|
||||||
else
|
else
|
||||||
taps[middle_i+i]=taps[middle_i-i]=(1/samples_per_symbol)*
|
taps[middle_i+i]=taps[middle_i-i]=(1/(float)samples_per_symbol)*
|
||||||
(sin(PI*(i/(float)samples_per_symbol)*(1-beta)) + 4*beta*(i/(float)samples_per_symbol)*cos(PI*(i/(float)samples_per_symbol)*(1+beta)))/
|
(sin(PI*(i/(float)samples_per_symbol)*(1-beta)) + 4*beta*(i/(float)samples_per_symbol)*cos(PI*(i/(float)samples_per_symbol)*(1+beta)))/
|
||||||
(PI*(i/(float)samples_per_symbol)*(1-powf(4*beta*(i/(float)samples_per_symbol),2)));
|
(PI*(i/(float)samples_per_symbol)*(1-powf(4*beta*(i/(float)samples_per_symbol),2)));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue