BasebandProcessor interface change to pass references, not copies.

This commit is contained in:
Jared Boone 2015-12-10 11:56:16 -08:00
parent 4d52f73f6a
commit 3bed016128
17 changed files with 30 additions and 30 deletions

View File

@ -59,7 +59,7 @@ void BasebandProcessor::update_spectrum() {
}
}
void BasebandProcessor::feed_channel_stats(const buffer_c16_t channel) {
void BasebandProcessor::feed_channel_stats(const buffer_c16_t& channel) {
channel_stats.feed(
channel,
[this](const ChannelStatistics statistics) {
@ -69,7 +69,7 @@ void BasebandProcessor::feed_channel_stats(const buffer_c16_t channel) {
}
void BasebandProcessor::feed_channel_spectrum(
const buffer_c16_t channel,
const buffer_c16_t& channel,
const uint32_t filter_pass_frequency,
const uint32_t filter_stop_frequency
) {
@ -83,7 +83,7 @@ void BasebandProcessor::feed_channel_spectrum(
);
}
void BasebandProcessor::fill_audio_buffer(const buffer_s16_t audio) {
void BasebandProcessor::fill_audio_buffer(const buffer_s16_t& audio) {
auto audio_buffer = audio::dma::tx_empty_buffer();;
for(size_t i=0; i<audio_buffer.count; i++) {
audio_buffer.p[i].left = audio_buffer.p[i].right = audio.p[i];
@ -93,12 +93,12 @@ void BasebandProcessor::fill_audio_buffer(const buffer_s16_t audio) {
feed_audio_stats(audio);
}
void BasebandProcessor::post_channel_stats_message(const ChannelStatistics statistics) {
void BasebandProcessor::post_channel_stats_message(const ChannelStatistics& statistics) {
channel_stats_message.statistics = statistics;
shared_memory.application_queue.push(channel_stats_message);
}
void BasebandProcessor::post_channel_spectrum_message(const buffer_c16_t data) {
void BasebandProcessor::post_channel_spectrum_message(const buffer_c16_t& data) {
if( !channel_spectrum_request_update ) {
fft_swap(data, channel_spectrum);
channel_spectrum_sampling_rate = data.sampling_rate;
@ -107,7 +107,7 @@ void BasebandProcessor::post_channel_spectrum_message(const buffer_c16_t data) {
}
}
void BasebandProcessor::feed_audio_stats(const buffer_s16_t audio) {
void BasebandProcessor::feed_audio_stats(const buffer_s16_t& audio) {
audio_stats.feed(
audio,
[this](const AudioStatistics statistics) {
@ -116,7 +116,7 @@ void BasebandProcessor::feed_audio_stats(const buffer_s16_t audio) {
);
}
void BasebandProcessor::post_audio_stats_message(const AudioStatistics statistics) {
void BasebandProcessor::post_audio_stats_message(const AudioStatistics& statistics) {
audio_stats_message.statistics = statistics;
shared_memory.application_queue.push(audio_stats_message);
}

View File

@ -37,20 +37,20 @@ class BasebandProcessor {
public:
virtual ~BasebandProcessor() = default;
virtual void execute(buffer_c8_t buffer) = 0;
virtual void execute(buffer_c8_t& buffer) = 0;
void update_spectrum();
protected:
void feed_channel_stats(const buffer_c16_t channel);
void feed_channel_stats(const buffer_c16_t& channel);
void feed_channel_spectrum(
const buffer_c16_t channel,
const buffer_c16_t& channel,
const uint32_t filter_pass_frequency,
const uint32_t filter_stop_frequency
);
void fill_audio_buffer(const buffer_s16_t audio);
void fill_audio_buffer(const buffer_s16_t& audio);
volatile bool channel_spectrum_request_update { false };
std::array<std::complex<float>, 256> channel_spectrum;
@ -67,10 +67,10 @@ private:
AudioStatsCollector audio_stats;
AudioStatisticsMessage audio_stats_message;
void post_channel_stats_message(const ChannelStatistics statistics);
void post_channel_spectrum_message(const buffer_c16_t data);
void feed_audio_stats(const buffer_s16_t audio);
void post_audio_stats_message(const AudioStatistics statistics);
void post_channel_stats_message(const ChannelStatistics& statistics);
void post_channel_spectrum_message(const buffer_c16_t& data);
void feed_audio_stats(const buffer_s16_t& audio);
void post_audio_stats_message(const AudioStatistics& statistics);
};
#endif/*__BASEBAND_PROCESSOR_H__*/

View File

@ -135,7 +135,7 @@ private:
while(true) {
// TODO: Place correct sampling rate into buffer returned here:
const auto buffer_tmp = baseband::dma::wait_for_rx_buffer();
const buffer_c8_t buffer {
buffer_c8_t buffer {
buffer_tmp.p, buffer_tmp.count, baseband_configuration.sampling_rate
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -26,7 +26,7 @@
#include "i2s.hpp"
using namespace lpc43xx;
void TPMSProcessor::execute(buffer_c8_t buffer) {
void TPMSProcessor::execute(buffer_c8_t& buffer) {
/* 2.4576MHz, 2048 samples */
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 {
public:
void execute(buffer_c8_t buffer) override;
void execute(buffer_c8_t& buffer) override;
private:
ChannelDecimator decimator { ChannelDecimator::DecimationFactor::By16 };

View File

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

View File

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

View File

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

View File

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