0
1
mirror of https://github.com/radio95-rnt/rds95.git synced 2026-02-26 20:33:53 +01:00
This commit is contained in:
2025-03-11 17:48:47 +01:00
parent ce9ec1eab9
commit d05135efcd
2 changed files with 21 additions and 22 deletions

View File

@@ -1,5 +1,5 @@
{ {
"port": 13452, "port": 13452,
"time": 1741642644925, "time": 1741711510603,
"version": "0.0.3" "version": "0.0.3"
} }

View File

@@ -45,39 +45,38 @@ float get_rds_sample() {
float sample; float sample;
if (rds->sample_count == SAMPLES_PER_BIT) { if (rds->sample_count == SAMPLES_PER_BIT) {
// New Sample // New Sample
if (rds->bit_pos == BITS_PER_GROUP) { if (rds->bit_pos == BITS_PER_GROUP) {
// New bit stream // New bit stream
get_rds_bits(rds->bit_buffer); get_rds_bits(rds->bit_buffer);
rds->bit_pos = 0; rds->bit_pos = 0;
} }
// Differentially encode, so 1111 becomes 1000 and 0001 becomes 0001 // Differentially encode, so 1111 becomes 1000 and 0001 becomes 0001
rds->cur_bit = rds->bit_buffer[rds->bit_pos++]; rds->cur_bit = rds->bit_buffer[rds->bit_pos++];
rds->prev_output = rds->cur_output; rds->prev_output = rds->cur_output;
rds->cur_output = rds->prev_output ^ rds->cur_bit; rds->cur_output = rds->prev_output ^ rds->cur_bit;
idx = rds->in_sample_index; idx = rds->in_sample_index;
cur_waveform = waveform[rds->cur_output]; // get the waveform, this is the biphase in a 0/180 degree phase shift cur_waveform = waveform[rds->cur_output]; // get the waveform, this is the biphase in a 0/180 degree phase shift
// Copy over the biphase to the sample buffer, every SAMPLES_PER_BIT for (uint16_t i = 0; i < FILTER_SIZE; i++) {
for (uint16_t i = 0; i < FILTER_SIZE; i++) {
rds->sample_buffer[idx++] += *cur_waveform++; rds->sample_buffer[idx++] += *cur_waveform++;
if (idx == SAMPLE_BUFFER_SIZE) idx = 0; if (idx == SAMPLE_BUFFER_SIZE) idx = 0;
} }
rds->in_sample_index += SAMPLES_PER_BIT; rds->in_sample_index += SAMPLES_PER_BIT;
if (rds->in_sample_index == SAMPLE_BUFFER_SIZE) if (rds->in_sample_index == SAMPLE_BUFFER_SIZE)
rds->in_sample_index = 0; rds->in_sample_index = 0;
rds->sample_count = 0; rds->sample_count = 0;
} }
rds->sample_count++; rds->sample_count++;
sample = rds->sample_buffer[rds->out_sample_index]; sample = rds->sample_buffer[rds->out_sample_index];
rds->sample_buffer[rds->out_sample_index++] = 0; rds->sample_buffer[rds->out_sample_index++] = 0;
if (rds->out_sample_index == SAMPLE_BUFFER_SIZE) if (rds->out_sample_index == SAMPLE_BUFFER_SIZE)
rds->out_sample_index = 0; rds->out_sample_index = 0;
return sample; return sample;
} }