0
1
mirror of https://github.com/radio95-rnt/fm95.git synced 2026-02-26 19:23:51 +01:00

remove lpf

This commit is contained in:
2025-01-25 23:37:20 +01:00
parent b6c7607807
commit c63e94744e
5 changed files with 5 additions and 64 deletions

View File

@@ -16,17 +16,6 @@ float apply_pre_emphasis(ResistorCapacitor *rc, float sample) {
return audio;
}
void init_low_pass_filter(ResistorCapacitor *rc, float cutoff_frequency, float sample_rate) {
float RC = 1.0f / (M_2PI * cutoff_frequency);
init_rc(&rc, 1.0f / (1.0f + sample_rate * RC));
}
float apply_low_pass_filter(ResistorCapacitor *rc, float sample) {
float output = rc->alpha*sample+(1.0f-rc->alpha)*rc->prev_sample;
rc->prev_sample = output;
return output;
}
void init_delay_line(DelayLine *delay_line, int max_delay) {
delay_line->buffer = (float *)calloc(max_delay, sizeof(float));
delay_line->size = max_delay;

View File

@@ -14,9 +14,6 @@ void init_rc(ResistorCapacitor *pe, float alpha);
void init_rc_tau(ResistorCapacitor *pe, float tau, float sample_rate);
float apply_pre_emphasis(ResistorCapacitor *pe, float sample);
void init_low_pass_filter(ResistorCapacitor *lp, float cutoff_frequency, float sample_rate);
float apply_low_pass_filter(ResistorCapacitor *lp, float sample);
typedef struct {
float *buffer;
int write_idx; // Write position

View File

@@ -1,5 +1,4 @@
#define PREEMPHASIS
#define LPF
#define buffer_maxlength 12288
#define buffer_tlength_fragsize 8192

View File

@@ -35,10 +35,6 @@
#define PREEMPHASIS_TAU 0.00005 // 50 microseconds, use 0.000075 if in america
#endif
#ifdef LPF
#define LPF_CUTOFF 7500
#endif
volatile sig_atomic_t to_run = 1;
float hard_clip(float sample) {
@@ -149,10 +145,6 @@ int main() {
ResistorCapacitor preemp;
init_rc_tau(&preemp, PREEMPHASIS_TAU, SAMPLE_RATE);
#endif
#ifdef LPF
ResistorCapacitor lpf;
init_low_pass_filter(&lpf, LPF_CUTOFF, SAMPLE_RATE);
#endif
signal(SIGINT, stop);
signal(SIGTERM, stop);
@@ -171,21 +163,10 @@ int main() {
float in = input[i];
#ifdef PREEMPHASIS
#ifdef LPF
float lowpassed = apply_low_pass_filter(&lpf, in);
float preemphasized = apply_pre_emphasis(&preemp, lowpassed)*2;
float current_input = hard_clip(preemphasized);
#else
float preemphasized = apply_pre_emphasis(&preemp, in)*2;
float current_input = hard_clip(preemphasized);
#endif
#else
#ifdef LPF
float lowpassed = apply_low_pass_filter(&lpf, in);
float current_input = hard_clip(lowpassed);
#else
float current_input = hard_clip(in);
#endif
#endif
signal[i] = modulate_fm(&mod, current_input)*VOLUME;

View File

@@ -42,10 +42,6 @@
#define PREEMPHASIS_TAU 0.00005 // 50 microseconds, use 0.000075 if in america
#endif
#ifdef LPF
#define LPF_CUTOFF 15000
#endif
volatile sig_atomic_t to_run = 1;
float hard_clip(float sample, float threshold) {
@@ -78,7 +74,7 @@ void show_version() {
void show_help(char *name) {
printf(
"FM95 (an FM Processor by radio95)\n"
"fm95 (an FM Processor by radio95)\n"
"Usage: %s\n\n"
" -m,--mono Force Mono\n"
" -s,--stereo Force Stereo\n"
@@ -97,10 +93,7 @@ void show_help(char *name) {
int main(int argc, char **argv) {
show_version();
int stereo = DEFAULT_STEREO;
int polar_stereo = DEFAULT_STEREO_POLAR;
int ssb = DEFAULT_STEREO_SSB;
float clipper_threshold = DEFAULT_CLIPPER_THRESHOLD;
#ifndef MPX_DEVICE
#ifndef MPX_DEVICE
char audio_mpx_device[64] = "\0";
#else
char audio_mpx_device[64] = MPX_DEVICE;
@@ -109,6 +102,9 @@ int main(int argc, char **argv) {
pa_simple *output_device;
snd_pcm_hw_params_t *output_params;
snd_pcm_t *output_handle;
float clipper_threshold = DEFAULT_CLIPPER_THRESHOLD;
int polar_stereo = DEFAULT_STEREO_POLAR;
int ssb = DEFAULT_STEREO_SSB;
char audio_input_device[64] = INPUT_DEVICE;
char audio_output_device[64] = OUTPUT_DEVICE;
int alsa_output = DEFAULT_ALSA_OUTPUT;
@@ -314,11 +310,6 @@ int main(int argc, char **argv) {
init_rc_tau(&preemp_l, PREEMPHASIS_TAU, SAMPLE_RATE);
init_rc_tau(&preemp_r, PREEMPHASIS_TAU, SAMPLE_RATE);
#endif
#ifdef LPF
ResistorCapacitor lpf_l, lpf_r;
init_low_pass_filter(&lpf_l, LPF_CUTOFF, SAMPLE_RATE);
init_low_pass_filter(&lpf_r, LPF_CUTOFF, SAMPLE_RATE);
#endif
signal(SIGINT, stop);
signal(SIGTERM, stop);
@@ -349,29 +340,13 @@ int main(int argc, char **argv) {
float multiplex_in = mpx_in[i];
#ifdef PREEMPHASIS
#ifdef LPF
float lowpassed_left = apply_low_pass_filter(&lpf_l, l_in);
float lowpassed_right = apply_low_pass_filter(&lpf_r, r_in);
float preemphasized_left = apply_pre_emphasis(&preemp_l, lowpassed_left)*2;
float preemphasized_right = apply_pre_emphasis(&preemp_r, lowpassed_right)*2;
float current_left_input = hard_clip(preemphasized_left, clipper_threshold);
float current_right_input = hard_clip(preemphasized_right, clipper_threshold);
#else
float preemphasized_left = apply_pre_emphasis(&preemp_l, l_in)*2;
float preemphasized_right = apply_pre_emphasis(&preemp_r, r_in)*2;
float current_left_input = hard_clip(preemphasized_left, clipper_threshold);
float current_right_input = hard_clip(preemphasized_right, clipper_threshold);
#endif
#else
#ifdef LPF
float lowpassed_left = apply_low_pass_filter(&lpf_l, l_in);
float lowpassed_right = apply_low_pass_filter(&lpf_r, r_in);
float current_left_input = hard_clip(lowpassed_left, clipper_threshold);
float current_right_input = hard_clip(lowpassed_right, clipper_threshold);
#else
float current_left_input = hard_clip(l_in, clipper_threshold);
float current_right_input = hard_clip(r_in, clipper_threshold);
#endif
#endif
float mono = (current_left_input + current_right_input) / 2.0f; // Stereo to Mono