Formatted code (#1007)

* Updated style

* Updated files

* fixed new line

* Updated spacing

* File fix WIP

* Updated to clang 13

* updated comment style

* Removed old comment code
This commit is contained in:
jLynx 2023-05-19 08:16:05 +12:00 committed by GitHub
parent 7aca7ce74d
commit 033c4e9a5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
599 changed files with 70746 additions and 66896 deletions

View file

@ -1,7 +1,7 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
*
*
* This file is part of PortaPack.
*
* This program is free software; you can redistribute it and/or modify
@ -28,84 +28,86 @@
#include <cstdint>
void RDSProcessor::execute(const buffer_c8_t& buffer) {
for (size_t i = 0; i < buffer.count; i++) {
// Sample generation at 2.28M / 10 = 228kHz
if (s >= 9) {
s = 0;
if (sample_count >= SAMPLES_PER_BIT) {
if (bit_pos >= message_length) {
bit_pos = 0;
cur_output = 0;
}
cur_bit = (rdsdata[(bit_pos / 26) & 127] >> (25 - (bit_pos % 26))) & 1;
prev_output = cur_output;
cur_output = prev_output ^ cur_bit;
for (size_t i = 0; i < buffer.count; i++) {
// Sample generation at 2.28M / 10 = 228kHz
if (s >= 9) {
s = 0;
if (sample_count >= SAMPLES_PER_BIT) {
if (bit_pos >= message_length) {
bit_pos = 0;
cur_output = 0;
}
const int32_t * src = waveform_biphase;
int idx = in_sample_index;
cur_bit = (rdsdata[(bit_pos / 26) & 127] >> (25 - (bit_pos % 26))) & 1;
prev_output = cur_output;
cur_output = prev_output ^ cur_bit;
for (int j = 0; j < FILTER_SIZE; j++) {
val = (*src++);
if (cur_output) val = -val;
sample_buffer[idx++] += val;
if (idx >= SAMPLE_BUFFER_SIZE) idx = 0;
}
const int32_t* src = waveform_biphase;
int idx = in_sample_index;
in_sample_index += SAMPLES_PER_BIT;
if (in_sample_index >= SAMPLE_BUFFER_SIZE) in_sample_index -= SAMPLE_BUFFER_SIZE;
bit_pos++;
sample_count = 0;
}
sample = sample_buffer[out_sample_index];
sample_buffer[out_sample_index] = 0;
out_sample_index++;
if (out_sample_index >= SAMPLE_BUFFER_SIZE) out_sample_index = 0;
// AM @ 228k/4 = 57kHz
// 0, sample, 0, -sample...
switch (mphase & 3) {
case 0:
case 2: sample = 0; break;
case 1: break;
case 3: sample = -sample; // break;
}
mphase++;
sample_count++;
} else {
s++;
}
// FM
delta = (sample >> 16) * 386760; // ?
phase += delta;
sphase = phase + (64 << 18);
re = (sine_table_i8[(sphase & 0x03FF0000) >> 18]);
im = (sine_table_i8[(phase & 0x03FF0000) >> 18]);
buffer.p[i] = {re, im};
}
for (int j = 0; j < FILTER_SIZE; j++) {
val = (*src++);
if (cur_output) val = -val;
sample_buffer[idx++] += val;
if (idx >= SAMPLE_BUFFER_SIZE) idx = 0;
}
in_sample_index += SAMPLES_PER_BIT;
if (in_sample_index >= SAMPLE_BUFFER_SIZE) in_sample_index -= SAMPLE_BUFFER_SIZE;
bit_pos++;
sample_count = 0;
}
sample = sample_buffer[out_sample_index];
sample_buffer[out_sample_index] = 0;
out_sample_index++;
if (out_sample_index >= SAMPLE_BUFFER_SIZE) out_sample_index = 0;
// AM @ 228k/4 = 57kHz
// 0, sample, 0, -sample...
switch (mphase & 3) {
case 0:
case 2:
sample = 0;
break;
case 1:
break;
case 3:
sample = -sample; // break;
}
mphase++;
sample_count++;
} else {
s++;
}
// FM
delta = (sample >> 16) * 386760; // ?
phase += delta;
sphase = phase + (64 << 18);
re = (sine_table_i8[(sphase & 0x03FF0000) >> 18]);
im = (sine_table_i8[(phase & 0x03FF0000) >> 18]);
buffer.p[i] = {re, im};
}
}
void RDSProcessor::on_message(const Message* const msg) {
if (msg->id == Message::ID::RDSConfigure) {
const auto message = *reinterpret_cast<const RDSConfigureMessage*>(msg);
rdsdata = (uint32_t*)shared_memory.bb_data.data;
message_length = message.length;
configured = true;
}
if (msg->id == Message::ID::RDSConfigure) {
const auto message = *reinterpret_cast<const RDSConfigureMessage*>(msg);
rdsdata = (uint32_t*)shared_memory.bb_data.data;
message_length = message.length;
configured = true;
}
}
int main() {
EventDispatcher event_dispatcher { std::make_unique<RDSProcessor>() };
event_dispatcher.run();
return 0;
EventDispatcher event_dispatcher{std::make_unique<RDSProcessor>()};
event_dispatcher.run();
return 0;
}