Const/pass-by-reference a bunch more baseband stuff.

This commit is contained in:
Jared Boone 2015-12-10 12:36:12 -08:00
parent 3ed77af0c1
commit ef315f0d92
22 changed files with 28 additions and 28 deletions

View File

@ -32,7 +32,7 @@
class AudioStatsCollector { class AudioStatsCollector {
public: public:
template<typename Callback> template<typename Callback>
void feed(buffer_s16_t src, Callback callback) { void feed(const buffer_s16_t& src, Callback callback) {
consume_audio_buffer(src); consume_audio_buffer(src);
if( update_stats(src.count, src.sampling_rate) ) { if( update_stats(src.count, src.sampling_rate) ) {
@ -55,7 +55,7 @@ private:
AudioStatistics statistics; AudioStatistics statistics;
void consume_audio_buffer(buffer_s16_t src) { void consume_audio_buffer(const buffer_s16_t& src) {
auto src_p = src.p; auto src_p = src.p;
const auto src_end = &src.p[src.count]; const auto src_end = &src.p[src.count];
while(src_p < src_end) { while(src_p < src_end) {

View File

@ -37,7 +37,7 @@ class BasebandProcessor {
public: public:
virtual ~BasebandProcessor() = default; virtual ~BasebandProcessor() = default;
virtual void execute(buffer_c8_t& buffer) = 0; virtual void execute(const buffer_c8_t& buffer) = 0;
void update_spectrum(); void update_spectrum();

View File

@ -46,7 +46,7 @@ public:
} }
template<typename Callback> template<typename Callback>
void process(buffer_c8_t buffer, Callback callback) { void process(const buffer_c8_t& buffer, Callback callback) {
samples += buffer.count; samples += buffer.count;
const size_t report_samples = buffer.sampling_rate * report_interval; const size_t report_samples = buffer.sampling_rate * report_interval;

View File

@ -65,7 +65,7 @@ public:
} }
template<typename BlockCallback> template<typename BlockCallback>
void feed(const buffer_c16_t src, BlockCallback callback) { void feed(const buffer_c16_t& src, BlockCallback callback) {
/* NOTE: Input block size must be >= factor */ /* NOTE: Input block size must be >= factor */
set_input_sampling_rate(src.sampling_rate); set_input_sampling_rate(src.sampling_rate);

View File

@ -21,7 +21,7 @@
#include "channel_decimator.hpp" #include "channel_decimator.hpp"
buffer_c16_t ChannelDecimator::execute_decimation(buffer_c8_t buffer) { buffer_c16_t ChannelDecimator::execute_decimation(const buffer_c8_t& buffer) {
const buffer_c16_t work_baseband_buffer { const buffer_c16_t work_baseband_buffer {
work_baseband.data(), work_baseband.data(),
work_baseband.size() work_baseband.size()
@ -80,8 +80,8 @@ buffer_c16_t ChannelDecimator::execute_decimation(buffer_c8_t buffer) {
} }
buffer_c16_t ChannelDecimator::execute_stage_0( buffer_c16_t ChannelDecimator::execute_stage_0(
buffer_c8_t buffer, const buffer_c8_t& buffer,
buffer_c16_t work_baseband_buffer const buffer_c16_t& work_baseband_buffer
) { ) {
if( fs_over_4_downconvert ) { if( fs_over_4_downconvert ) {
return translate.execute(buffer, work_baseband_buffer); return translate.execute(buffer, work_baseband_buffer);

View File

@ -57,7 +57,7 @@ public:
decimation_factor = f; decimation_factor = f;
} }
buffer_c16_t execute(buffer_c8_t buffer) { buffer_c16_t execute(const buffer_c8_t& buffer) {
auto decimated = execute_decimation(buffer); auto decimated = execute_decimation(buffer);
return decimated; return decimated;
@ -76,11 +76,11 @@ private:
DecimationFactor decimation_factor; DecimationFactor decimation_factor;
const bool fs_over_4_downconvert; const bool fs_over_4_downconvert;
buffer_c16_t execute_decimation(buffer_c8_t buffer); buffer_c16_t execute_decimation(const buffer_c8_t& buffer);
buffer_c16_t execute_stage_0( buffer_c16_t execute_stage_0(
buffer_c8_t buffer, const buffer_c8_t& buffer,
buffer_c16_t work_baseband_buffer const buffer_c16_t& work_baseband_buffer
); );
}; };

View File

@ -34,7 +34,7 @@
class ChannelStatsCollector { class ChannelStatsCollector {
public: public:
template<typename Callback> template<typename Callback>
void feed(buffer_c16_t src, Callback callback) { void feed(const buffer_c16_t& src, Callback callback) {
auto src_p = src.p; auto src_p = src.p;
while(src_p < &src.p[src.count]) { while(src_p < &src.p[src.count]) {
const uint32_t sample = *__SIMD32(src_p)++; const uint32_t sample = *__SIMD32(src_p)++;

View File

@ -26,7 +26,7 @@
#include "i2s.hpp" #include "i2s.hpp"
using namespace lpc43xx; using namespace lpc43xx;
void AISProcessor::execute(buffer_c8_t& buffer) { void AISProcessor::execute(const buffer_c8_t& buffer) {
/* 2.4576MHz, 2048 samples */ /* 2.4576MHz, 2048 samples */
auto decimator_out = decimator.execute(buffer); auto decimator_out = decimator.execute(buffer);

View File

@ -42,7 +42,7 @@
class AISProcessor : public BasebandProcessor { class AISProcessor : public BasebandProcessor {
public: public:
void execute(buffer_c8_t& buffer) override; void execute(const buffer_c8_t& buffer) override;
private: private:
ChannelDecimator decimator { ChannelDecimator::DecimationFactor::By32 }; ChannelDecimator decimator { ChannelDecimator::DecimationFactor::By32 };

View File

@ -23,7 +23,7 @@
#include <cstdint> #include <cstdint>
void NarrowbandAMAudio::execute(buffer_c8_t& buffer) { void NarrowbandAMAudio::execute(const buffer_c8_t& buffer) {
auto decimator_out = decimator.execute(buffer); auto decimator_out = decimator.execute(buffer);
const buffer_c16_t work_baseband_buffer { const buffer_c16_t work_baseband_buffer {

View File

@ -38,7 +38,7 @@ public:
channel_filter.configure(channel_filter_taps.taps, 2); channel_filter.configure(channel_filter_taps.taps, 2);
} }
void execute(buffer_c8_t& buffer) override; void execute(const buffer_c8_t& buffer) override;
private: private:
ChannelDecimator decimator; ChannelDecimator decimator;

View File

@ -41,7 +41,7 @@ float ERTProcessor::abs(const complex8_t& v) {
return std::sqrt(r2_i2); return std::sqrt(r2_i2);
} }
void ERTProcessor::execute(buffer_c8_t& buffer) { void ERTProcessor::execute(const buffer_c8_t& buffer) {
/* 4.194304MHz, 2048 samples */ /* 4.194304MHz, 2048 samples */
// auto decimator_out = decimator.execute(buffer); // auto decimator_out = decimator.execute(buffer);

View File

@ -50,7 +50,7 @@ constexpr size_t idm_payload_length_max { 1408 };
class ERTProcessor : public BasebandProcessor { class ERTProcessor : public BasebandProcessor {
public: public:
void execute(buffer_c8_t& buffer) override; void execute(const buffer_c8_t& buffer) override;
private: private:
const uint32_t baseband_sampling_rate = 4194304; const uint32_t baseband_sampling_rate = 4194304;

View File

@ -24,7 +24,7 @@
#include <cstdint> #include <cstdint>
#include <cstddef> #include <cstddef>
void NarrowbandFMAudio::execute(buffer_c8_t& buffer) { void NarrowbandFMAudio::execute(const buffer_c8_t& buffer) {
/* Called every 2048/3072000 second -- 1500Hz. */ /* Called every 2048/3072000 second -- 1500Hz. */
auto decimator_out = decimator.execute(buffer); auto decimator_out = decimator.execute(buffer);

View File

@ -39,7 +39,7 @@ public:
channel_filter.configure(channel_filter_taps.taps, 2); channel_filter.configure(channel_filter_taps.taps, 2);
} }
void execute(buffer_c8_t& buffer) override; void execute(const buffer_c8_t& buffer) override;
private: private:
ChannelDecimator decimator; ChannelDecimator decimator;

View File

@ -26,7 +26,7 @@
#include "i2s.hpp" #include "i2s.hpp"
using namespace lpc43xx; using namespace lpc43xx;
void TPMSProcessor::execute(buffer_c8_t& buffer) { void TPMSProcessor::execute(const buffer_c8_t& buffer) {
/* 2.4576MHz, 2048 samples */ /* 2.4576MHz, 2048 samples */
auto decimator_out = decimator.execute(buffer); auto decimator_out = decimator.execute(buffer);

View File

@ -50,7 +50,7 @@ constexpr std::array<std::complex<float>, 8> rect_taps_153k6_1t_p { {
class TPMSProcessor : public BasebandProcessor { class TPMSProcessor : public BasebandProcessor {
public: public:
void execute(buffer_c8_t& buffer) override; void execute(const buffer_c8_t& buffer) override;
private: private:
ChannelDecimator decimator { ChannelDecimator::DecimationFactor::By16 }; ChannelDecimator decimator { ChannelDecimator::DecimationFactor::By16 };

View File

@ -23,7 +23,7 @@
#include <cstdint> #include <cstdint>
void WidebandFMAudio::execute(buffer_c8_t& buffer) { void WidebandFMAudio::execute(const buffer_c8_t& buffer) {
auto decimator_out = decimator.execute(buffer); auto decimator_out = decimator.execute(buffer);
const buffer_s16_t work_audio_buffer { const buffer_s16_t work_audio_buffer {

View File

@ -37,7 +37,7 @@ public:
decimator.set_decimation_factor(ChannelDecimator::DecimationFactor::By4); decimator.set_decimation_factor(ChannelDecimator::DecimationFactor::By4);
} }
void execute(buffer_c8_t& buffer) override; void execute(const buffer_c8_t& buffer) override;
private: private:
ChannelDecimator decimator; ChannelDecimator decimator;

View File

@ -33,7 +33,7 @@ using namespace lpc43xx;
#include <array> #include <array>
void WidebandSpectrum::execute(buffer_c8_t& buffer) { void WidebandSpectrum::execute(const buffer_c8_t& buffer) {
// 2048 complex8_t samples per buffer. // 2048 complex8_t samples per buffer.
// 102.4us per buffer. 20480 instruction cycles per buffer. // 102.4us per buffer. 20480 instruction cycles per buffer.

View File

@ -30,7 +30,7 @@
class WidebandSpectrum : public BasebandProcessor { class WidebandSpectrum : public BasebandProcessor {
public: public:
void execute(buffer_c8_t& buffer) override; void execute(const buffer_c8_t& buffer) override;
private: private:
size_t sample_count = 0; size_t sample_count = 0;

View File

@ -31,7 +31,7 @@
class RSSIStatisticsCollector { class RSSIStatisticsCollector {
public: public:
template<typename Callback> template<typename Callback>
void process(rf::rssi::buffer_t buffer, Callback callback) { void process(const rf::rssi::buffer_t& buffer, Callback callback) {
auto p = buffer.p; auto p = buffer.p;
if( p == nullptr ) { if( p == nullptr ) {
return; return;