add decoder id (untested)

This commit is contained in:
kuba 2024-08-31 17:40:21 +02:00
parent a0b05b3669
commit 7d4bfae365
5 changed files with 29 additions and 5 deletions

View File

@ -119,7 +119,19 @@ ResultAndArg poll_control_pipe(int log) {
}
resarg.arg_int = ct;
resarg.res = CONTROL_PIPE_CT_SET;
}
} else if(fifo[0] == 'D' && fifo[1] == 'I') {
int di = atoi(arg);
if (di >= 0 && di <= 0xF) {
set_rds_di(di);
if(log==1) {
printf("Set DI to %d\n", di)
}
}
else {
printf("Wrong DI range, range is 0-15\n");
}
resarg.res = CONTROL_PIPE_GENERIC_SET;
}
} else if(strlen(fifo) > 4 && fifo[3] == ' ') {
char *arg = fifo+4;
resarg.arg = fifo+4;

View File

@ -28,6 +28,7 @@
#define CONTROL_PIPE_COMPRESSOR_SET 21
#define CONTROL_PIPE_COMPRESSORMAXGAINRECIP_SET 23
#define CONTROL_PIPE_LIMITERTHRESHOLD_SET 24
#define CONTROL_PIPE_GENERIC_SET 25
typedef struct {
int res;

View File

@ -78,6 +78,11 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt,
set_rds_ms(1);
set_rds_tp(tp);
set_rds_ta(ta);
if(dstereo == 1) {
set_rds_di(0);
} else {
set_rds_di(1);
}
uint16_t count = 0;
uint16_t count2 = 0;
if(log) {
@ -170,7 +175,7 @@ int main(int argc, char **argv) {
uint32_t carrier_freq = 100000000; //100 mhz
char *ps = "Pi-FmSa";
char *rt = "Broadcasting on a Raspberry Pi: Simply Advanced";
uint16_t pi = 0x1234;
uint16_t pi = 0x00ff;
int pty = 0;
float compressor_decay = 0.999995;
float compressor_attack = 1.0;
@ -198,7 +203,7 @@ int main(int argc, char **argv) {
int alternative_freq[100] = {};
int bypassfreqrange = 0;
int ct = 1;
float cutofffreq = 15000; // up to standart
float cutofffreq = 15000; // up to standard
// Parse command-line arguments
for(int i=1; i<argc; i++) {
char *arg = argv[i];

View File

@ -39,6 +39,7 @@ struct {
char ps[PS_LENGTH];
char rt[RT_LENGTH];
int af[100];
int di;
} rds_params = { 0 };
/* Here, the first member of the struct must be a scalar to avoid a
warning on -Wmissing-braces with GCC < 4.8.3
@ -125,7 +126,7 @@ int get_rds_ct_group(uint16_t *blocks, int enabled) {
pattern. 'ps_state' and 'rt_state' keep track of where we are in the PS (0A) sequence
or RT (2A) sequence, respectively.
*/
void get_rds_group(int *buffer, int stereo, int ct_clock_enabled) { //no idea how to do ptyn and decoder id
void get_rds_group(int *buffer, int stereo, int ct_clock_enabled) { //ptyn?
static int state = 0;
static int ps_state = 0;
static int rt_state = 0;
@ -136,7 +137,7 @@ void get_rds_group(int *buffer, int stereo, int ct_clock_enabled) { //no idea ho
if(!get_rds_ct_group(blocks, ct_clock_enabled)) { // CT (clock time) has priority on other group types (when its on)
if(state < 4) {
blocks[1] = 0x0000 | rds_params.tp << 10 | rds_params.pty << 5 | rds_params.ta << 4 | rds_params.ms << 3 | ps_state;
if((ps_state == 3) && stereo) blocks[1] |= 0x0004; // DI Stereo, someone explain from where the 0004 comes from and what does "bit d0" mean?
blocks[1] |= ((rds_params.di >> (3 - ps_state)) & 0x01) << 2; // from micrords
if(rds_params.af[0]) { // AF
if(af_state == 0) {
blocks[2] = (rds_params.af[0] + 224) << 8 | rds_params.af[1]; // Send number of AFs and the first AF
@ -282,6 +283,10 @@ void set_rds_pty(int pty) {
rds_params.pty = pty;
}
void set_rds_di(int di) {
rds_params.di = di;
}
void set_rds_ta(int ta) {
rds_params.ta = ta;
}

View File

@ -30,6 +30,7 @@ extern void set_rds_rt(char *rt);
extern void set_rds_ps(char *ps);
extern void set_rds_ta(int ta);
extern void set_rds_pty(int pty);
extern void set_rds_di(int di);
extern void set_rds_af(int *af_array);
extern void set_rds_tp(int tp);
extern void set_rds_ms(int ms);