Use new blocking method

master
F5OEO 2018-03-21 10:06:22 +00:00
rodzic 3fb4d66e6b
commit 2707ecc8ab
2 zmienionych plików z 16 dodań i 26 usunięć

Wyświetl plik

@ -118,6 +118,7 @@ int fm_mpx_open(char *filename, size_t len) {
// Choose a cutoff frequency for the low-pass FIR filter
float cutoff_freq = 15700;
//float cutoff_freq = 3000; //For NBFM
if(in_samplerate/2 < cutoff_freq) cutoff_freq = in_samplerate/2 * .8;
@ -236,6 +237,7 @@ int fm_mpx_get_samples(float *mpx_buffer) {
// Sanity checks
if ( iphase < 0 ) {iphase=0; printf("low\n"); }// Seems to run faster with these checks in place
if ( iphase >= FIR_PHASES ) {iphase=FIR_PHASES-2; printf("high\n"); }
if( channels > 1 )
{
for(int fi=0; fi<FIR_TAPS; fi++) // fi = Filter Index
@ -251,7 +253,7 @@ int fm_mpx_get_samples(float *mpx_buffer) {
out_left+=low_pass_fir[iphase][fi] * fir_buffer_left[(fir_index-fi)&(FIR_TAPS-1)];
}
}
// Simple broadcast compressor
//
// The goal is to get the loudest sounding audio while
@ -310,7 +312,7 @@ int fm_mpx_get_samples(float *mpx_buffer) {
else
{
mpx_buffer[i] =
mpx_buffer[i] + // RDS data samples are currently in mpx_buffer
mpx_buffer[i] + // RDS data samples are currently in mpx_buffer :to be Remove in NBFM
9.0*out_left; // Unmodulated monophonic signal
}

Wyświetl plik

@ -119,7 +119,8 @@ ngfmdmasync *fmmod;
// Use 75kHz for WBFM (broadcast radio)
// and about 2.5kHz for NBFM (walkie-talkie style radio)
#define DEVIATION 75000
//FOR NBFM
//#define DEVIATION 2500
static void
terminate(int num)
@ -165,6 +166,7 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt,
// Data structures for baseband data
float data[DATA_SIZE];
float devfreq[DATA_SIZE];
int data_len = 0;
int data_index = 0;
@ -230,32 +232,18 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt,
varying_ps = 0;
}
usleep(500);
int free_slots=fmmod->GetBufferAvailable();
if (free_slots >= DATA_SIZE)
{
int Index=fmmod->GetUserMemIndex();
// get more baseband samples if necessary
if( fm_mpx_get_samples(data) < 0 ) {
if( fm_mpx_get_samples(data) < 0 ) {
terminate(0);
}
data_len = DATA_SIZE;
for(int i=0;i< data_len;i++)
for(int i=0;i< data_len;i++)
{
float dval = data[i]*deviation_scale_factor;
//printf("%f\n",dval);
fmmod->SetFrequencySample(Index+i,dval);
devfreq[i] = data[i]*deviation_scale_factor;
}
}
fmmod->SetFrequencySamples(devfreq,data_len);
}
return 0;
@ -286,8 +274,8 @@ int main(int argc, char **argv) {
} else if(strcmp("-freq", arg)==0 && param != NULL) {
i++;
carrier_freq = 1e6 * atof(param);
if(carrier_freq < 76e6 || carrier_freq > 108e6)
fatal("Incorrect frequency specification. Must be in megahertz, of the form 107.9, between 76 and 108.\n");
//if(carrier_freq < 76e6 || carrier_freq > 108e6)
// fatal("Incorrect frequency specification. Must be in megahertz, of the form 107.9, between 76 and 108.\n");
} else if(strcmp("-pi", arg)==0 && param != NULL) {
i++;
pi = (uint16_t) strtol(param, NULL, 16);