Closed righthalfplane closed 2 years ago
`
int cReceive::setFrequency3(double frequency) {
if(frequency == rx->f)return 0; //fprintf(stderr,"\n setFrequency3 f %g MHZ\n",frequency/1e6); rx->f=frequency; double pi; pi=4.0*atan(1.0); rx->dt=1.0/(double)rx->samplerate; rx->sino=0; rx->coso=1; rx->w=2.0*pi*(rx->fc - rx->f); rx->sindt=sin(rx->w*rx->dt); rx->cosdt=cos(rx->w*rx->dt); //fprintf(stderr,"fc %f f %f dt %g samplerate %d\n",rx->fc,rx->f,rx->dt,rx->samplerate); return 0;
}
double sint,cost; if(rx->r->iplay){ for (int k = 0 ; k < rx->size ; k++){ float r = buf[k * rx->channels]; float i = buf[k * rx->channels + 1]; //r = 0.001*(rand() % 100); //i = 0.001*(rand() % 100); if(rx->dt > 0){ buf2[k * rx->channels] = (float)(r*rx->coso - i*rx->sino); buf2[k * rx->channels + 1] = (float)(i*rx->coso + r*rx->sino); sint=rx->sino*rx->cosdt+rx->coso*rx->sindt; cost=rx->coso*rx->cosdt-rx->sino*rx->sindt; rx->coso=cost; rx->sino=sint; }else{ buf2[k * rx->channels] = r; buf2[k * rx->channels + 1] = i; } } }else{ for (int k = 0 ; k < rx->size ; k++){ buf2[k * rx->channels] = 0; buf2[k * rx->channels + 1] = 0; } } double r=sqrt(rx->coso*rx->coso+rx->sino*rx->sino); rx->coso /= r; rx->sino /= r; unsigned int num; unsigned int num2; num=0; num2=0; msresamp_crcf_execute(f->iqSampler, (liquid_float_complex *)buf2, rx->size, (liquid_float_complex *)buf, &num); // decimate if(rx->decodemode < MODE_AM){ freqdem_demodulate_block(f->demod, (liquid_float_complex *)buf, (int)num, (float *)buf2); }else if(rx->decodemode < MODE_USB){ #define DC_ALPHA 0.99 //ALPHA for DC removal filter ~20Hz Fcut with 15625Hz Sample Rate for(unsigned int n=0;n<num;++n){ double mag=sqrt(buf[2*n]*buf[2*n]+buf[2*n+1]*buf[2*n+1]); double z0=mag + (f->amHistory * DC_ALPHA); buf2[n]=(float)(z0-f->amHistory); f->amHistory=z0; } }else{ ampmodem_demodulate_block(f->demodAM, (liquid_float_complex *)buf, (int)num, (float *)buf2);
msresamp_rrrf_execute(f->iqSampler2, (float )buf2, num, (float )buf, &num2); // interpolate
int setFilters(struct playData rx,struct Filters f) {
if(!rx)return 0; float As = 60.0f; float ratio=(float)(rx->faudio / rx->samplerate); liquid_ampmodem_type mode=LIQUID_AMPMODEM_DSB; int iflag=0; if(rx->decodemode == MODE_AM){ rx->bw=10000.0; mode=LIQUID_AMPMODEM_DSB; iflag=0; } else if(rx->decodemode == MODE_NAM){ rx->bw=5000.0; mode=LIQUID_AMPMODEM_DSB; iflag=0; } else if(rx->decodemode == MODE_NBFM){ rx->bw=12500.0; }else if(rx->decodemode == MODE_FM){ rx->bw=200000.0; }else if(rx->decodemode == MODE_USB){ // Above 10 MHZ rx->bw=6000.0; mode=LIQUID_AMPMODEM_USB; iflag=1; }else if(rx->decodemode == MODE_LSB){ // Below 10 MHZ rx->bw=6000.0; mode=LIQUID_AMPMODEM_LSB; iflag=1; }else if(rx->decodemode == MODE_CW){ // Below 10 MHZ rx->bw=3000.0; mode=LIQUID_AMPMODEM_LSB; iflag=1; } rx->Ratio = (float)(rx->bw/ rx->samplerate); ratio= (float)(rx->faudio/rx->bw); if(rx->Debug)fprintf(stderr,"rx->Ratio %g ratio %g\n",rx->Ratio,ratio); f->demod=freqdem_create(0.5);
f->demodAM = ampmodem_create(0.5, 0.0, mode, iflag);
f->demodAM = ampmodem_create(0.5, mode, iflag);
f->iqSampler = msresamp_crcf_create(rx->Ratio, As); f->iqSampler2 = msresamp_rrrf_create(ratio, As); //msresamp_crcf_print(f->iqSampler); f->fShift = nco_crcf_create(LIQUID_NCO); f->amHistory=0; return 0;
`
int cReceive::setFrequency3(double frequency) {
}
}
msresamp_rrrf_execute(f->iqSampler2, (float )buf2, num, (float )buf, &num2); // interpolate
int setFilters(struct playData rx,struct Filters f) {
ifdef LIQUID_VERSION_4
else
endif
}
`