diff --git a/src/Makefile b/src/Makefile index 51ad9bc..70b0068 100644 --- a/src/Makefile +++ b/src/Makefile @@ -62,7 +62,7 @@ LDFLAGS_Pissb = $(LDFLAGS) -lsndfile -lliquid $(CC) $(CFLAGS) -c -o pifmrds/waveforms.o pifmrds/waveforms.c # $(CC) $(CFLAGS) -c -o pifmrds/rds_wav.o pifmrds/rds_wav.c $(CC) $(CFLAGS) -c -o pifmrds/fm_mpx.o pifmrds/fm_mpx.c - $(CC) -o pifmrds/rds_wav pifmrds/rds_wav.o pifmrds/rds.o pifmrds/waveforms.o pifmrds/fm_mpx.o -lm -lsndfile + #$(CC) -o pifmrds/rds_wav pifmrds/rds_wav.o pifmrds/rds.o pifmrds/waveforms.o pifmrds/fm_mpx.o -lm -lsndfile $(CXX) $(CXXFLAGS) -Wno-write-strings -o ../pifmrds pifmrds/rds.o pifmrds/waveforms.o pifmrds/pi_fm_rds.cpp pifmrds/fm_mpx.o pifmrds/control_pipe.o -lm -lsndfile -lrt -lpthread -L/opt/vc/lib -lrpitx ../rpitx: rpitxv1/rpitx.cpp diff --git a/src/pifmrds/fm_mpx.c b/src/pifmrds/fm_mpx.c index 2f41caf..598b628 100644 --- a/src/pifmrds/fm_mpx.c +++ b/src/pifmrds/fm_mpx.c @@ -81,7 +81,7 @@ float *alloc_empty_buffer(size_t length) { } -int fm_mpx_open(char *filename, size_t len, int raw, double preemphasis, int rawSampleRate, int rawChannels, float cutoff_freq) { +int fm_mpx_open(char *filename, size_t len, int raw, double preemphasis, int rawSampleRate, int rawChannels, float cutoff_freq, float gain) { length = len; raw_ = raw; @@ -131,7 +131,6 @@ int fm_mpx_open(char *filename, size_t len, int raw, double preemphasis, int raw // Create the low-pass FIR filter, with pre-emphasis double window, firlowpass, firpreemph , sincpos; - double gain=FIR_PHASES/25.0; // Why??? Maybe gain adjustment for preemphais // IIR pre-emphasis filter // Reference material: http://jontio.zapto.org/hda1/preempiir.pdf @@ -166,7 +165,7 @@ int fm_mpx_open(char *filename, size_t len, int raw, double preemphasis, int raw } } - printf("Created low-pass FIR filter for audio channels, with cutoff at %.1f Hz\n", cutoff_freq); + printf("Created low-pass FIR filter for audio channels, with cutoff at %.1f Hz (gain: %.f\n", cutoff_freq, gain); if( 0 ) { diff --git a/src/pifmrds/fm_mpx.h b/src/pifmrds/fm_mpx.h index 7825375..211b069 100644 --- a/src/pifmrds/fm_mpx.h +++ b/src/pifmrds/fm_mpx.h @@ -21,6 +21,6 @@ along with this program. If not, see . */ -extern int fm_mpx_open(char *filename, size_t len, int raw, double preemphasis, int rawSampleRate, int rawChannels, float cutoff_freq); +extern int fm_mpx_open(char *filename, size_t len, int raw, double preemphasis, int rawSampleRate, int rawChannels, float cutoff_freq, float gain); extern int fm_mpx_get_samples(float *mpx_buffer, int drds); extern int fm_mpx_close(); diff --git a/src/pifmrds/pi_fm_rds.cpp b/src/pifmrds/pi_fm_rds.cpp index 96e87cf..e0bda2a 100644 --- a/src/pifmrds/pi_fm_rds.cpp +++ b/src/pifmrds/pi_fm_rds.cpp @@ -87,7 +87,7 @@ static volatile void *map_peripheral(uint32_t base, uint32_t len) return vaddr; } -int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt, float ppm, char *control_pipe, int pty, int *af_array, int raw, int drds, double preemp, int power, int rawSampleRate, int rawChannels, int deviation, int ta, int tp, float cutoff_freq) { +int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt, float ppm, char *control_pipe, int pty, int *af_array, int raw, int drds, double preemp, int power, int rawSampleRate, int rawChannels, int deviation, int ta, int tp, float cutoff_freq, float gaim) { // Catch all signals possible - it is vital we kill the DMA engine // on process exit! for (int i = 0; i < 64; i++) { @@ -110,7 +110,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, raw, preemp, rawSampleRate, rawChannels, cutoff_freq) < 0) return 1; + if(fm_mpx_open(audio_file, DATA_SIZE, raw, preemp, rawSampleRate, rawChannels, cutoff_freq, gaim) < 0) return 1; // Initialize the RDS modulator char myps[9] = {0}; @@ -222,6 +222,7 @@ int main(int argc, char **argv) { int raw = 0; int drds = 0; int power = 7; + float gain = 1; int rawSampleRate = 44100; int rawChannels = 2; double preemp = 50e-6; //eu @@ -298,9 +299,12 @@ int main(int argc, char **argv) { } else if(strcmp("-rawsamplerate", arg)==0 && param != NULL) { i++; rawSampleRate = atoi(param); - } else if(strcmp("-cutofffreq", arg)==0 && param != NULL) { + } else if(strcmp("-cutofffreq", arg)==0 && param != NULL) { + i++; + cutofffreq = atoi(param); + } else if(strcmp("-audiogain", arg)==0 && param != NULL) { i++; - cutofffreq = atoi(param); + gain = atoi(param); } else if(strcmp("-power", arg)==0 && param != NULL) { i++; int tpower = atoi(param); @@ -343,6 +347,6 @@ int main(int argc, char **argv) { alternative_freq[0] = af_size; int FifoSize=DATA_SIZE*2; fmmod=new ngfmdmasync(carrier_freq,228000,14,FifoSize, false, gpiopin); - int errcode = tx(carrier_freq, audio_file, pi, ps, rt, ppm, control_pipe, pty, alternative_freq, raw, drds, preemp, power, rawSampleRate, rawChannels, deviation, ta, tp, cutofffreq); + int errcode = tx(carrier_freq, audio_file, pi, ps, rt, ppm, control_pipe, pty, alternative_freq, raw, drds, preemp, power, rawSampleRate, rawChannels, deviation, ta, tp, cutofffreq, gain); terminate(errcode); } diff --git a/src/pifmrds/rds_wav b/src/pifmrds/rds_wav deleted file mode 100755 index 920b01d..0000000 Binary files a/src/pifmrds/rds_wav and /dev/null differ diff --git a/src/pift8/pift8 b/src/pift8/pift8 new file mode 100755 index 0000000..1407025 Binary files /dev/null and b/src/pift8/pift8 differ