mirror of
https://github.com/radio95-rnt/fm95.git
synced 2026-02-26 19:23:51 +01:00
remove some
This commit is contained in:
@@ -78,14 +78,6 @@ float hard_clip(float sample, float threshold) {
|
|||||||
return sample; // No clipping
|
return sample; // No clipping
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
float soft_clip(float sample, float threshold) {
|
|
||||||
if (fabs(sample) <= threshold) {
|
|
||||||
return sample; // Linear region
|
|
||||||
} else {
|
|
||||||
float sign = (sample > 0) ? 1.0f : -1.0f;
|
|
||||||
return sign * (threshold + (1.0f - threshold) * pow(fabs(sample) - threshold, 0.5f));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void init_delay_line(DelayLine *delay_line, int max_delay) {
|
void init_delay_line(DelayLine *delay_line, int max_delay) {
|
||||||
delay_line->buffer = (float *)calloc(max_delay, sizeof(float));
|
delay_line->buffer = (float *)calloc(max_delay, sizeof(float));
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ void init_hpf(BiquadFilter* filter, float cutoffFreq, float qFactor, float sampl
|
|||||||
float apply_frequency_filter(BiquadFilter* filter, float input);
|
float apply_frequency_filter(BiquadFilter* filter, float input);
|
||||||
|
|
||||||
float hard_clip(float sample, float threshold);
|
float hard_clip(float sample, float threshold);
|
||||||
float soft_clip(float sample, float threshold);
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float *buffer;
|
float *buffer;
|
||||||
|
|||||||
22
src/fm95.c
22
src/fm95.c
@@ -10,7 +10,6 @@
|
|||||||
#define DEFAULT_STEREO_POLAR 0
|
#define DEFAULT_STEREO_POLAR 0
|
||||||
#define DEFAULT_STEREO_SSB 0
|
#define DEFAULT_STEREO_SSB 0
|
||||||
#define DEFAULT_CLIPPER_THRESHOLD 1.0f
|
#define DEFAULT_CLIPPER_THRESHOLD 1.0f
|
||||||
#define DEFAULT_SOFT_CLIPPER_THRESHOLD 0.95f
|
|
||||||
#define DEFAULT_SCA_FREQUENCY 67000.0f
|
#define DEFAULT_SCA_FREQUENCY 67000.0f
|
||||||
#define DEFAULT_SCA_DEVIATION 7000.0f
|
#define DEFAULT_SCA_DEVIATION 7000.0f
|
||||||
#define DEFAULT_SCA_CLIPPER_THRESHOLD 1.0f // Full deviation, if you set this to 0.5 then you may as well set the deviation to 3.5k
|
#define DEFAULT_SCA_CLIPPER_THRESHOLD 1.0f // Full deviation, if you set this to 0.5 then you may as well set the deviation to 3.5k
|
||||||
@@ -44,8 +43,6 @@
|
|||||||
#define MPX_VOLUME 1.0f
|
#define MPX_VOLUME 1.0f
|
||||||
|
|
||||||
#define LPF_CUTOFF 15000 // Should't need to be changed
|
#define LPF_CUTOFF 15000 // Should't need to be changed
|
||||||
#define HPF_CUTOFF 30 // Unless you wanna have SOME bass then leave this alone
|
|
||||||
#define CENTER_BASS 50 // Bass upto this will be mono
|
|
||||||
|
|
||||||
volatile sig_atomic_t to_run = 1;
|
volatile sig_atomic_t to_run = 1;
|
||||||
|
|
||||||
@@ -79,7 +76,6 @@ void show_help(char *name) {
|
|||||||
" -F,--sca_dev Override the SCA deviation [default: %.2f]\n"
|
" -F,--sca_dev Override the SCA deviation [default: %.2f]\n"
|
||||||
" -L,--sca_clip Override the SCA clipper threshold [default: %.2f]\n"
|
" -L,--sca_clip Override the SCA clipper threshold [default: %.2f]\n"
|
||||||
" -c,--clipper Override the clipper threshold [default: %.2f]\n"
|
" -c,--clipper Override the clipper threshold [default: %.2f]\n"
|
||||||
" -l,--soft_clip Override the soft clipper threshold [default: %.2f]\n"
|
|
||||||
" -P,--polar Force Polar Stereo (does not take effect with -m%s)\n"
|
" -P,--polar Force Polar Stereo (does not take effect with -m%s)\n"
|
||||||
" -g,--ge Force Zenith/GE stereo (does not take effect with -m%s)\n"
|
" -g,--ge Force Zenith/GE stereo (does not take effect with -m%s)\n"
|
||||||
" -S,--ssb Force SSB [default: %d]\n"
|
" -S,--ssb Force SSB [default: %d]\n"
|
||||||
@@ -106,7 +102,6 @@ void show_help(char *name) {
|
|||||||
,DEFAULT_SCA_DEVIATION
|
,DEFAULT_SCA_DEVIATION
|
||||||
,DEFAULT_SCA_CLIPPER_THRESHOLD
|
,DEFAULT_SCA_CLIPPER_THRESHOLD
|
||||||
,DEFAULT_CLIPPER_THRESHOLD
|
,DEFAULT_CLIPPER_THRESHOLD
|
||||||
,DEFAULT_SOFT_CLIPPER_THRESHOLD
|
|
||||||
,(DEFAULT_STEREO_POLAR == 1) ? ", default" : ""
|
,(DEFAULT_STEREO_POLAR == 1) ? ", default" : ""
|
||||||
,(DEFAULT_STEREO_POLAR == 1) ? "" : ", default"
|
,(DEFAULT_STEREO_POLAR == 1) ? "" : ", default"
|
||||||
,DEFAULT_STEREO_SSB
|
,DEFAULT_STEREO_SSB
|
||||||
@@ -124,7 +119,6 @@ int main(int argc, char **argv) {
|
|||||||
pa_simple *output_device;
|
pa_simple *output_device;
|
||||||
|
|
||||||
float clipper_threshold = DEFAULT_CLIPPER_THRESHOLD;
|
float clipper_threshold = DEFAULT_CLIPPER_THRESHOLD;
|
||||||
float soft_clipper_threshold = DEFAULT_SOFT_CLIPPER_THRESHOLD;
|
|
||||||
int stereo = DEFAULT_STEREO;
|
int stereo = DEFAULT_STEREO;
|
||||||
int polar_stereo = DEFAULT_STEREO_POLAR;
|
int polar_stereo = DEFAULT_STEREO_POLAR;
|
||||||
int ssb = DEFAULT_STEREO_SSB;
|
int ssb = DEFAULT_STEREO_SSB;
|
||||||
@@ -165,7 +159,6 @@ int main(int argc, char **argv) {
|
|||||||
{"sca_dev", required_argument, NULL, 'F'},
|
{"sca_dev", required_argument, NULL, 'F'},
|
||||||
{"sca_clip", required_argument, NULL, 'L'},
|
{"sca_clip", required_argument, NULL, 'L'},
|
||||||
{"clipper", required_argument, NULL, 'c'},
|
{"clipper", required_argument, NULL, 'c'},
|
||||||
{"soft_clip", required_argument, NULL, 'l'},
|
|
||||||
{"polar", no_argument, NULL, 'P'},
|
{"polar", no_argument, NULL, 'P'},
|
||||||
{"ge", no_argument, NULL, 'g'},
|
{"ge", no_argument, NULL, 'g'},
|
||||||
{"ssb", no_argument, NULL, 'S'},
|
{"ssb", no_argument, NULL, 'S'},
|
||||||
@@ -211,9 +204,6 @@ int main(int argc, char **argv) {
|
|||||||
case 'c': //Clipper
|
case 'c': //Clipper
|
||||||
clipper_threshold = strtof(optarg, NULL);
|
clipper_threshold = strtof(optarg, NULL);
|
||||||
break;
|
break;
|
||||||
case 'l': //Soft Clipper
|
|
||||||
soft_clipper_threshold = strtof(optarg, NULL);
|
|
||||||
break;
|
|
||||||
case 'P': //Polar
|
case 'P': //Polar
|
||||||
polar_stereo = 1;
|
polar_stereo = 1;
|
||||||
break;
|
break;
|
||||||
@@ -403,13 +393,6 @@ int main(int argc, char **argv) {
|
|||||||
BiquadFilter lpf_l, lpf_r;
|
BiquadFilter lpf_l, lpf_r;
|
||||||
init_lpf(&lpf_l, LPF_CUTOFF, 1.0f, SAMPLE_RATE);
|
init_lpf(&lpf_l, LPF_CUTOFF, 1.0f, SAMPLE_RATE);
|
||||||
init_lpf(&lpf_r, LPF_CUTOFF, 1.0f, SAMPLE_RATE);
|
init_lpf(&lpf_r, LPF_CUTOFF, 1.0f, SAMPLE_RATE);
|
||||||
|
|
||||||
BiquadFilter hpf_l, hpf_r;
|
|
||||||
init_hpf(&hpf_l, HPF_CUTOFF, 1.0f, SAMPLE_RATE);
|
|
||||||
init_hpf(&hpf_r, HPF_CUTOFF, 1.0f, SAMPLE_RATE);
|
|
||||||
|
|
||||||
BiquadFilter bass_hpf;
|
|
||||||
init_hpf(&bass_hpf, CENTER_BASS, 1.0f, SAMPLE_RATE);
|
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
signal(SIGINT, stop);
|
signal(SIGINT, stop);
|
||||||
@@ -452,19 +435,14 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
float ready_l = apply_frequency_filter(&lpf_l, l_in);
|
float ready_l = apply_frequency_filter(&lpf_l, l_in);
|
||||||
float ready_r = apply_frequency_filter(&lpf_r, r_in);
|
float ready_r = apply_frequency_filter(&lpf_r, r_in);
|
||||||
ready_l = apply_frequency_filter(&hpf_l, ready_l);
|
|
||||||
ready_r = apply_frequency_filter(&hpf_r, ready_r);
|
|
||||||
ready_l = apply_preemphasis(&preemp_l, ready_l);
|
ready_l = apply_preemphasis(&preemp_l, ready_l);
|
||||||
ready_r = apply_preemphasis(&preemp_r, ready_r);
|
ready_r = apply_preemphasis(&preemp_r, ready_r);
|
||||||
ready_l = soft_clip(ready_l, soft_clipper_threshold);
|
|
||||||
ready_r = soft_clip(ready_r, soft_clipper_threshold);
|
|
||||||
ready_l = hard_clip(ready_l, clipper_threshold);
|
ready_l = hard_clip(ready_l, clipper_threshold);
|
||||||
ready_r = hard_clip(ready_r, clipper_threshold);
|
ready_r = hard_clip(ready_r, clipper_threshold);
|
||||||
|
|
||||||
float mono = (ready_l + ready_r) / 2.0f; // Stereo to Mono
|
float mono = (ready_l + ready_r) / 2.0f; // Stereo to Mono
|
||||||
if(stereo == 1) {
|
if(stereo == 1) {
|
||||||
float stereo = (ready_l - ready_r) / 2.0f; // Also Stereo to Mono but a bit diffrent
|
float stereo = (ready_l - ready_r) / 2.0f; // Also Stereo to Mono but a bit diffrent
|
||||||
if(CENTER_BASS != 0) stereo = apply_frequency_filter(&bass_hpf, stereo);
|
|
||||||
|
|
||||||
float stereo_i, stereo_q;
|
float stereo_i, stereo_q;
|
||||||
if(ssb) {
|
if(ssb) {
|
||||||
|
|||||||
Reference in New Issue
Block a user