mirror of
https://github.com/radio95-rnt/fm95.git
synced 2026-02-26 19:23:51 +01:00
try to make rds2 use the pilot osc
This commit is contained in:
2
.vscode/.server-controller-port.log
vendored
2
.vscode/.server-controller-port.log
vendored
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"port": 13452,
|
"port": 13452,
|
||||||
"time": 1742673002809,
|
"time": 1742717063787,
|
||||||
"version": "0.0.3"
|
"version": "0.0.3"
|
||||||
}
|
}
|
||||||
@@ -8,8 +8,7 @@ FM95 is a audio processor for FM, it does:
|
|||||||
Supports these inputs:
|
Supports these inputs:
|
||||||
- Audio (via Pulse)
|
- Audio (via Pulse)
|
||||||
- MPX (via Pulse)
|
- MPX (via Pulse)
|
||||||
- RDS (via Pulse, expects unmodulated RDS)
|
- RDS (via Pulse, expects unmodulated RDS, stereo, left channel on 57 KHz, right on 66.5)
|
||||||
- RDS2 (via Pulse, expects unmodulated RDS, one stream on 66.5)
|
|
||||||
- SCA (via Pulse)
|
- SCA (via Pulse)
|
||||||
|
|
||||||
and one output:
|
and one output:
|
||||||
|
|||||||
@@ -23,12 +23,15 @@ float get_oscillator_cos_sample(Oscillator *osc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float get_oscillator_sin_multiplier_ni(Oscillator *osc, float multiplier) { // ni = No Increment
|
float get_oscillator_sin_multiplier_ni(Oscillator *osc, float multiplier) { // ni = No Increment
|
||||||
return sinf(osc->phase*multiplier);
|
return sinf(fmodf(osc->phase * multiplier, M_2PI));
|
||||||
}
|
}
|
||||||
float get_oscillator_cos_multiplier_ni(Oscillator *osc, float multiplier) {
|
float get_oscillator_cos_multiplier_ni(Oscillator *osc, float multiplier) {
|
||||||
return cosf(osc->phase*multiplier);
|
return cosf(fmodf(osc->phase * multiplier, M_2PI));
|
||||||
}
|
}
|
||||||
|
|
||||||
void advance_oscillator(Oscillator *osc) {
|
void advance_oscillator(Oscillator *osc) {
|
||||||
osc->phase = fmodf(osc->phase + osc->phase_increment, M_2PI);
|
osc->phase += osc->phase_increment;
|
||||||
|
if (osc->phase >= M_2PI) {
|
||||||
|
osc->phase -= M_2PI;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
10
src/fm95.c
10
src/fm95.c
@@ -11,7 +11,7 @@
|
|||||||
#define DEFAULT_CLIPPER_THRESHOLD 1.0f
|
#define DEFAULT_CLIPPER_THRESHOLD 1.0f
|
||||||
#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
|
||||||
#define DEFAULT_PREEMPHASIS_TAU 50e-6 // Europe, the freedomers use 75µs
|
#define DEFAULT_PREEMPHASIS_TAU 50e-6 // Europe, the freedomers use 75µs
|
||||||
|
|
||||||
#include "../lib/constants.h"
|
#include "../lib/constants.h"
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
#define PILOT_VOLUME 0.09f // 19 KHz Pilot
|
#define PILOT_VOLUME 0.09f // 19 KHz Pilot
|
||||||
#define STEREO_VOLUME 0.45f // L-R signal, should be same as MONO
|
#define STEREO_VOLUME 0.45f // L-R signal, should be same as MONO
|
||||||
#define RDS_VOLUME 0.075f // RDS Volume, after dsb-sc
|
#define RDS_VOLUME 0.075f // RDS Volume, after dsb-sc
|
||||||
#define RDS2_VOLUME 0.05f // RDS2 Volume
|
#define RDS2_VOLUME 0.075f // RDS2 Volume
|
||||||
#define SCA_VOLUME 0.1f // FM SCA signal, 10%
|
#define SCA_VOLUME 0.1f // FM SCA signal, 10%
|
||||||
#define MPX_VOLUME 1.0f // Passtrough
|
#define MPX_VOLUME 1.0f // Passtrough
|
||||||
#define MPX_CLIPPER_THRESHOLD 1.0f
|
#define MPX_CLIPPER_THRESHOLD 1.0f
|
||||||
@@ -414,9 +414,6 @@ int main(int argc, char **argv) {
|
|||||||
ResistorCapacitor preemp_l, preemp_r;
|
ResistorCapacitor preemp_l, preemp_r;
|
||||||
init_preemphasis(&preemp_l, preemphasis_tau, sample_rate);
|
init_preemphasis(&preemp_l, preemphasis_tau, sample_rate);
|
||||||
init_preemphasis(&preemp_r, preemphasis_tau, sample_rate);
|
init_preemphasis(&preemp_r, preemphasis_tau, sample_rate);
|
||||||
|
|
||||||
Oscillator rds2_osc;
|
|
||||||
init_oscillator(&rds2_osc, 66500, sample_rate);
|
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
signal(SIGINT, stop);
|
signal(SIGINT, stop);
|
||||||
@@ -425,6 +422,7 @@ int main(int argc, char **argv) {
|
|||||||
int pulse_error;
|
int pulse_error;
|
||||||
|
|
||||||
float audio_stereo_input[BUFFER_SIZE*2];
|
float audio_stereo_input[BUFFER_SIZE*2];
|
||||||
|
|
||||||
float rds1_rds2_in[BUFFER_SIZE*2] = {0};
|
float rds1_rds2_in[BUFFER_SIZE*2] = {0};
|
||||||
float rds1_in[BUFFER_SIZE] = {0};
|
float rds1_in[BUFFER_SIZE] = {0};
|
||||||
float rds2_in[BUFFER_SIZE] = {0};
|
float rds2_in[BUFFER_SIZE] = {0};
|
||||||
@@ -494,7 +492,7 @@ int main(int argc, char **argv) {
|
|||||||
float rds_carrier = get_oscillator_sin_multiplier_ni(&osc, 3);
|
float rds_carrier = get_oscillator_sin_multiplier_ni(&osc, 3);
|
||||||
output[i] += (current_rds_in*rds_carrier)*RDS_VOLUME;
|
output[i] += (current_rds_in*rds_carrier)*RDS_VOLUME;
|
||||||
if(!sca_on) {
|
if(!sca_on) {
|
||||||
float rds2_carrier_66 = get_oscillator_sin_sample(&rds2_osc);
|
float rds2_carrier_66 = get_oscillator_cos_multiplier_ni(&osc, 3.5f);
|
||||||
output[i] += (current_rds2_in*rds2_carrier_66)*RDS2_VOLUME;
|
output[i] += (current_rds2_in*rds2_carrier_66)*RDS2_VOLUME;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user