The lowpass cutoff frequency is now configurable via CLI
with -cutoff [compliant/quality/{cutoff freq}] you can now select the cutoff frequency
This commit is contained in:
parent
d81db0e798
commit
43d9431d30
|
|
@ -84,7 +84,7 @@ float *alloc_empty_buffer(size_t length) {
|
|||
}
|
||||
|
||||
|
||||
int fm_mpx_open(char *filename, size_t len, float preemphasis_corner_freq) {
|
||||
int fm_mpx_open(char *filename, size_t len, float cutoff_freq, float preemphasis_corner_freq) {
|
||||
length = len;
|
||||
|
||||
if(filename != NULL) {
|
||||
|
|
@ -130,11 +130,9 @@ int fm_mpx_open(char *filename, size_t len, float preemphasis_corner_freq) {
|
|||
|
||||
|
||||
// Create the low-pass FIR filter
|
||||
float cutoff_freq = 22050;
|
||||
if(in_samplerate/2 < cutoff_freq) cutoff_freq = in_samplerate/2;
|
||||
|
||||
|
||||
|
||||
low_pass_fir[FIR_HALF_SIZE-1] = 2 * cutoff_freq / 228000 /2;
|
||||
// Here we divide this coefficient by two because it will be counted twice
|
||||
// when applying the filter
|
||||
|
|
|
|||
|
|
@ -21,6 +21,6 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
extern int fm_mpx_open(char *filename, size_t len, float preemphasis_corner_freq);
|
||||
extern int fm_mpx_open(char *filename, size_t len, float cutoff_freq, float preemphasis_corner_freq);
|
||||
extern int fm_mpx_get_samples(float *mpx_buffer);
|
||||
extern int fm_mpx_close();
|
||||
|
|
@ -310,7 +310,7 @@ map_peripheral(uint32_t base, uint32_t len)
|
|||
#define DATA_SIZE 5000
|
||||
|
||||
|
||||
int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt, float ppm, char *control_pipe, float preemphasis_cutoff) {
|
||||
int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt, float ppm, char *control_pipe, float cutoff, float preemphasis_cutoff) {
|
||||
// Catch all signals possible - it is vital we kill the DMA engine
|
||||
// on process exit!
|
||||
for (int i = 0; i < 64; i++) {
|
||||
|
|
@ -445,7 +445,7 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt,
|
|||
int data_index = 0;
|
||||
|
||||
// Initialize the baseband generator
|
||||
if(fm_mpx_open(audio_file, DATA_SIZE, preemphasis_cutoff) < 0) return 1;
|
||||
if(fm_mpx_open(audio_file, DATA_SIZE, cutoff, preemphasis_cutoff) < 0) return 1;
|
||||
|
||||
// Initialize the RDS modulator
|
||||
char myps[9] = {0};
|
||||
|
|
@ -539,6 +539,9 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt,
|
|||
#define PREEMPHASIS_EU 3185
|
||||
#define PREEMPHASIS_US 2120
|
||||
|
||||
#define CUTOFF_COMPLIANT 15000
|
||||
#define CUTOFF_QUALITY 22050
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
char *audio_file = NULL;
|
||||
char *control_pipe = NULL;
|
||||
|
|
@ -547,6 +550,7 @@ int main(int argc, char **argv) {
|
|||
char *rt = "PiFmRds: live FM-RDS transmission from the RaspberryPi";
|
||||
uint16_t pi = 0x1234;
|
||||
float ppm = 0;
|
||||
float cutoff = CUTOFF_COMPLIANT;
|
||||
float preemphasis_cutoff = PREEMPHASIS_US;
|
||||
|
||||
|
||||
|
|
@ -590,6 +594,16 @@ int main(int argc, char **argv) {
|
|||
else {
|
||||
preemphasis_cutoff = atof(param);
|
||||
}
|
||||
} else if(strcmp("-cutoff", arg)==0 && param != NULL) {
|
||||
i++;
|
||||
if(strcmp("compliant", param)==0) {
|
||||
cutoff = CUTOFF_COMPLIANT;
|
||||
} else if(strcmp("quality", param)==0) {
|
||||
cutoff = CUTOFF_QUALITY;
|
||||
}
|
||||
else {
|
||||
cutoff = atof(param);
|
||||
}
|
||||
} else {
|
||||
fatal("Unrecognised argument: %s.\n"
|
||||
"Syntax: pi_fm_rds [-freq freq] [-audio file] [-ppm ppm_error] [-pi pi_code]\n"
|
||||
|
|
@ -597,7 +611,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
}
|
||||
|
||||
int errcode = tx(carrier_freq, audio_file, pi, ps, rt, ppm, control_pipe, preemphasis_cutoff);
|
||||
int errcode = tx(carrier_freq, audio_file, pi, ps, rt, ppm, control_pipe, cutoff, preemphasis_cutoff);
|
||||
|
||||
terminate(errcode);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue