Added psk_modulator_u8_ci, duplicate_samples_ntimes_u8_u8i, psk31_interpolate_sine_cci, pack_bits_8to1_u8_u8i, psk31_varicode_encoder_u8_u8i
This commit is contained in:
parent
fabca11450
commit
c23693e885
3 changed files with 126 additions and 7 deletions
116
csdr.c
116
csdr.c
|
@ -973,7 +973,7 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!strcmp(argv[1],"floatdump_f"))
|
if(!strcmp(argv[1],"floatdump_f") || !strcmp(argv[1],"dump_f"))
|
||||||
{
|
{
|
||||||
if(!sendbufsize(initialize_buffers())) return -2;
|
if(!sendbufsize(initialize_buffers())) return -2;
|
||||||
for(;;)
|
for(;;)
|
||||||
|
@ -2428,6 +2428,120 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!strcmp(argv[1],"psk_modulator_u8_c")) //<n_psk>
|
||||||
|
{
|
||||||
|
int n_psk;
|
||||||
|
if(argc<=2) return badsyntax("need required parameter (n_psk)");
|
||||||
|
sscanf(argv[2],"%d",&n_psk);
|
||||||
|
if(n_psk<=0 || n_psk>256) badsyntax("n_psk should be between 1 and 256");
|
||||||
|
|
||||||
|
if(!initialize_buffers()) return -2;
|
||||||
|
sendbufsize(the_bufsize);
|
||||||
|
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
FEOF_CHECK;
|
||||||
|
fread((unsigned char*)input_buffer, sizeof(unsigned char), the_bufsize, stdin);
|
||||||
|
psk_modulator_u8_c((unsigned char*)input_buffer, (complexf*)output_buffer, the_bufsize, n_psk);
|
||||||
|
FWRITE_C;
|
||||||
|
TRY_YIELD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!strcmp(argv[1],"duplicate_samples_ntimes_u8_u8")) //<sample_size_bytes> <ntimes>
|
||||||
|
{
|
||||||
|
int sample_size_bytes, ntimes;
|
||||||
|
if(argc<=2) return badsyntax("need required parameter (sample_size_bytes)");
|
||||||
|
sscanf(argv[2],"%d",&sample_size_bytes);
|
||||||
|
if(argc<=3) return badsyntax("need required parameter (ntimes)");
|
||||||
|
sscanf(argv[3],"%d",&ntimes);
|
||||||
|
if(!initialize_buffers()) return -2;
|
||||||
|
sendbufsize(the_bufsize*ntimes);
|
||||||
|
unsigned char* local_input_buffer = (unsigned char*)malloc(sizeof(unsigned char)*the_bufsize*sample_size_bytes);
|
||||||
|
unsigned char* local_output_buffer = (unsigned char*)malloc(sizeof(unsigned char)*the_bufsize*sample_size_bytes*ntimes);
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
FEOF_CHECK;
|
||||||
|
fread((void*)local_input_buffer, sizeof(unsigned char), the_bufsize*sample_size_bytes, stdin);
|
||||||
|
duplicate_samples_ntimes_u8_u8(local_input_buffer, local_input_buffer, the_bufsize*sample_size_bytes, sample_size_bytes, ntimes);
|
||||||
|
fwrite((void*)local_output_buffer, sizeof(unsigned char), the_bufsize*sample_size_bytes*ntimes, stdout);
|
||||||
|
TRY_YIELD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!strcmp(argv[1],"psk31_interpolate_sine_cc")) //<interpolation>
|
||||||
|
{
|
||||||
|
int interpolation;
|
||||||
|
if(argc<=2) return badsyntax("need required parameter (interpolation)");
|
||||||
|
sscanf(argv[2],"%d",&interpolation);
|
||||||
|
if(interpolation<=0) badsyntax("interpolation should be >0");
|
||||||
|
if(!initialize_buffers()) return -2;
|
||||||
|
sendbufsize(the_bufsize*interpolation);
|
||||||
|
complexf* local_output_buffer = (complexf*)malloc(sizeof(complexf)*the_bufsize*interpolation);
|
||||||
|
complexf last_input;
|
||||||
|
iof(&last_input,0) = 0;
|
||||||
|
qof(&last_input,0) = 0;
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
FEOF_CHECK;
|
||||||
|
FREAD_C;
|
||||||
|
last_input = psk31_interpolate_sine_cc((complexf*)input_buffer, local_output_buffer, the_bufsize, interpolation, last_input);
|
||||||
|
fwrite((void*)local_output_buffer, sizeof(complexf), the_bufsize*interpolation, stdout);
|
||||||
|
TRY_YIELD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!strcmp(argv[1],"pack_bits_8to1_u8_u8"))
|
||||||
|
{
|
||||||
|
if(!initialize_buffers()) return -2;
|
||||||
|
sendbufsize(the_bufsize*8);
|
||||||
|
unsigned char* local_input_buffer = (unsigned char*)malloc(sizeof(unsigned char)*the_bufsize);
|
||||||
|
unsigned char* local_output_buffer = (unsigned char*)malloc(sizeof(unsigned char)*the_bufsize*8);
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
FEOF_CHECK;
|
||||||
|
fread((void*)local_input_buffer, sizeof(unsigned char), the_bufsize, stdin);
|
||||||
|
pack_bits_8to1_u8_u8(local_input_buffer, local_output_buffer, the_bufsize);
|
||||||
|
fwrite((void*)local_output_buffer, sizeof(unsigned char), the_bufsize*8, stdout);
|
||||||
|
TRY_YIELD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!strcmp(argv[1],"psk31_varicode_encoder_u8_u8"))
|
||||||
|
{
|
||||||
|
if(!initialize_buffers()) return -2;
|
||||||
|
sendbufsize(the_bufsize*8);
|
||||||
|
int output_max_size=the_bufsize*30;
|
||||||
|
int output_size;
|
||||||
|
int input_processed;
|
||||||
|
unsigned char* local_input_buffer = (unsigned char*)malloc(sizeof(unsigned char)*the_bufsize);
|
||||||
|
unsigned char* local_output_buffer = (unsigned char*)malloc(sizeof(unsigned char)*output_max_size);
|
||||||
|
fread((void*)local_input_buffer, sizeof(unsigned char), the_bufsize, stdin);
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
psk31_varicode_encoder_u8_u8(local_input_buffer, local_output_buffer, the_bufsize, output_max_size, &input_processed, &output_size);
|
||||||
|
fwrite((void*)local_output_buffer, sizeof(unsigned char), output_size, stdout);
|
||||||
|
FEOF_CHECK;
|
||||||
|
memmove(local_input_buffer, local_input_buffer+input_processed, the_bufsize-input_processed);
|
||||||
|
fread(input_buffer+the_bufsize-input_processed, sizeof(unsigned char), input_processed, stdin);
|
||||||
|
TRY_YIELD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!strcmp(argv[1],"dump_u8"))
|
||||||
|
{
|
||||||
|
if(!initialize_buffers()) return -2;
|
||||||
|
sendbufsize(the_bufsize*3);
|
||||||
|
unsigned char* local_input_buffer = (unsigned char*)malloc(sizeof(unsigned char)*the_bufsize);
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
FEOF_CHECK;
|
||||||
|
fread((void*)local_input_buffer, sizeof(unsigned char), the_bufsize, stdin);
|
||||||
|
for(int i=0;i<the_bufsize;i++) printf("%02x ", local_input_buffer[i]);
|
||||||
|
TRY_YIELD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!strcmp(argv[1],"none"))
|
if(!strcmp(argv[1],"none"))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
|
12
libcsdr.c
12
libcsdr.c
|
@ -1420,13 +1420,13 @@ void psk31_varicode_encoder_u8_u8(unsigned char* input, unsigned char* output, i
|
||||||
{
|
{
|
||||||
for(int ci=0; ci<n_psk31_varicode_items; ci++) //ci: character index
|
for(int ci=0; ci<n_psk31_varicode_items; ci++) //ci: character index
|
||||||
{
|
{
|
||||||
psk31_varicode_item_t current_varicode = psk31_varicode_items[ci].ascii;
|
psk31_varicode_item_t current_varicode = psk31_varicode_items[ci];
|
||||||
if(input[*input_processed]==current_varicode.ascii)
|
if(input[*input_processed]==current_varicode.ascii)
|
||||||
{
|
{
|
||||||
if(output_max_size<current_varicode.bitcount) return;
|
if(output_max_size<current_varicode.bitcount) return;
|
||||||
for(int bi=0; bi<current_varicode.bitcount; bi++) //bi: bit index
|
for(int bi=0; bi<current_varicode.bitcount; bi++) //bi: bit index
|
||||||
{
|
{
|
||||||
output[*output_size]=(psk31_varicode_items[ci]>>(current_varicode.bitcount-bi-1))&1;
|
output[*output_size]=(psk31_varicode_items[ci].code>>(current_varicode.bitcount-bi-1))&1;
|
||||||
*output_size++;
|
*output_size++;
|
||||||
output_max_size--;
|
output_max_size--;
|
||||||
}
|
}
|
||||||
|
@ -1595,12 +1595,12 @@ void binary_slicer_f_u8(float* input, unsigned char* output, int input_size)
|
||||||
for(int i=0;i<input_size;i++) output[i] = input[i] > 0;
|
for(int i=0;i<input_size;i++) output[i] = input[i] > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void psk_modulator_u8_c(unsigned char* input, complexf* output, int input_size, int npsk)
|
void psk_modulator_u8_c(unsigned char* input, complexf* output, int input_size, int n_psk)
|
||||||
{
|
{
|
||||||
//outputs one complex sample per input symbol
|
//outputs one complex sample per input symbol
|
||||||
for(int i=0;i<input_size;i++)
|
for(int i=0;i<input_size;i++)
|
||||||
{
|
{
|
||||||
float out_phase=((2*M_PI)/npsk)*input[i];
|
float out_phase=((2*M_PI)/n_psk)*input[i];
|
||||||
iof(output,i)=cos(out_phase);
|
iof(output,i)=cos(out_phase);
|
||||||
qof(output,i)=sin(out_phase);
|
qof(output,i)=sin(out_phase);
|
||||||
}
|
}
|
||||||
|
@ -1621,8 +1621,8 @@ complexf psk31_interpolate_sine_cc(complexf* input, complexf* output, int input_
|
||||||
for(int j=0; j<interpolation; j++)
|
for(int j=0; j<interpolation; j++)
|
||||||
{
|
{
|
||||||
float rate = (1+sin(-(M_PI/2)+M_PI*((j+1)/(float)interpolation)))/2;
|
float rate = (1+sin(-(M_PI/2)+M_PI*((j+1)/(float)interpolation)))/2;
|
||||||
iof(output,i)=iof(input,i) * rate + last_input * (1-rate);
|
iof(output,i)=iof(input,i) * rate + iof(&last_input,0) * (1-rate);
|
||||||
qof(output,i)=qof(input,i) * rate + last_input * (1-rate);
|
qof(output,i)=qof(input,i) * rate + qof(&last_input,0) * (1-rate);
|
||||||
last_input = output[i];
|
last_input = output[i];
|
||||||
}
|
}
|
||||||
return last_input;
|
return last_input;
|
||||||
|
|
|
@ -317,3 +317,8 @@ timing_recovery_algorithm_t timing_recovery_get_algorithm_from_string(char* inpu
|
||||||
char* timing_recovery_get_string_from_algorithm(timing_recovery_algorithm_t algorithm);
|
char* timing_recovery_get_string_from_algorithm(timing_recovery_algorithm_t algorithm);
|
||||||
void timing_recovery_trigger_debug(timing_recovery_state_t* state, int debug_phase);
|
void timing_recovery_trigger_debug(timing_recovery_state_t* state, int debug_phase);
|
||||||
void octave_plot_point_on_cplxsig(complexf* signal, int signal_size, float error, int index, int correction_offset, int writefiles, int points_size, ...);
|
void octave_plot_point_on_cplxsig(complexf* signal, int signal_size, float error, int index, int correction_offset, int writefiles, int points_size, ...);
|
||||||
|
void psk_modulator_u8_c(unsigned char* input, complexf* output, int input_size, int n_psk);
|
||||||
|
void duplicate_samples_ntimes_u8_u8(unsigned char* input, unsigned char* output, int input_size_bytes, int sample_size_bytes, int ntimes);
|
||||||
|
complexf psk31_interpolate_sine_cc(complexf* input, complexf* output, int input_size, int interpolation, complexf last_input);
|
||||||
|
void pack_bits_8to1_u8_u8(unsigned char* input, unsigned char* output, int input_size);
|
||||||
|
void psk31_varicode_encoder_u8_u8(unsigned char* input, unsigned char* output, int input_size, int output_max_size, int* input_processed, int* output_size);
|
||||||
|
|
Loading…
Reference in a new issue