Added FM modulator.
This commit is contained in:
parent
0800e4f431
commit
fb5899f087
4 changed files with 1105 additions and 0 deletions
14
csdr.c
14
csdr.c
|
@ -1562,6 +1562,20 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
if(!strcmp(argv[1],"fmmod_fc"))
|
||||
{
|
||||
if(!sendbufsize(initialize_buffers())) return -2;
|
||||
float last_phase = 0;
|
||||
for(;;)
|
||||
{
|
||||
FEOF_CHECK;
|
||||
FREAD_R;
|
||||
last_phase = fmmod_fc(input_buffer, (complexf*)output_buffer, the_bufsize, last_phase);
|
||||
FWRITE_C;
|
||||
TRY_YIELD;
|
||||
}
|
||||
}
|
||||
|
||||
if(!strcmp(argv[1],"none"))
|
||||
{
|
||||
return 0;
|
||||
|
|
1076
grc_tests/test_fmmod.grc
Normal file
1076
grc_tests/test_fmmod.grc
Normal file
File diff suppressed because it is too large
Load diff
14
libcsdr.c
14
libcsdr.c
|
@ -834,6 +834,20 @@ void add_dcoffset_cc(complexf* input, complexf* output, int input_size)
|
|||
for(int i=0;i<input_size;i++) qof(output,i)=qof(input,i)/2;
|
||||
}
|
||||
|
||||
float fmmod_fc(float* input, complexf* output, int input_size, float last_phase)
|
||||
{
|
||||
float phase=last_phase;
|
||||
for(int i=0;i<input_size;i++)
|
||||
{
|
||||
phase+=input[i]*PI;
|
||||
while(phase>PI) phase-=2*PI;
|
||||
while(phase<=-PI) phase+=2*PI;
|
||||
iof(output,i)=cos(phase);
|
||||
qof(output,i)=sin(phase);
|
||||
}
|
||||
return phase;
|
||||
}
|
||||
|
||||
/*
|
||||
______ _ ______ _ _______ __
|
||||
| ____| | | | ____| (_) |__ __| / _|
|
||||
|
|
|
@ -163,6 +163,7 @@ void apply_fir_fft_cc(FFT_PLAN_T* plan, FFT_PLAN_T* plan_inverse, complexf* taps
|
|||
void gain_ff(float* input, float* output, int input_size, float gain);
|
||||
|
||||
void add_dcoffset_cc(complexf* input, complexf* output, int input_size);
|
||||
float fmmod_fc(float* input, complexf* output, int input_size, float last_phase);
|
||||
|
||||
void convert_u8_f(unsigned char* input, float* output, int input_size);
|
||||
void convert_f_u8(float* input, unsigned char* output, int input_size);
|
||||
|
|
Loading…
Reference in a new issue