This commit is contained in:
furrtek
2016-05-09 21:05:11 +02:00
parent 8523bd860e
commit 569f299f42
57 changed files with 1155 additions and 772 deletions

View File

@@ -96,8 +96,8 @@ void AudioOutput::fill_audio_buffer(const buffer_f32_t& audio, const bool send_t
audio_buffer.p[i].left = audio_buffer.p[i].right = sample_saturated;
audio_int[i] = sample_saturated;
}
if( send_to_fifo ) {
stream.write(audio_int.data(), audio_buffer.count * sizeof(audio_int[0]));
if( stream && send_to_fifo ) {
stream->write(audio_int.data(), audio_buffer.count * sizeof(audio_int[0]));
}
feed_audio_stats(audio);

View File

@@ -32,6 +32,7 @@
#include "audio_stats_collector.hpp"
#include <cstdint>
#include <memory>
class AudioOutput {
public:
@@ -44,6 +45,10 @@ public:
void write(const buffer_s16_t& audio);
void write(const buffer_f32_t& audio);
void set_stream(std::unique_ptr<StreamInput> new_stream) {
stream = std::move(new_stream);
}
private:
static constexpr float k = 32768.0f;
static constexpr float ki = 1.0f / k;
@@ -54,7 +59,7 @@ private:
IIRBiquadFilter deemph;
FMSquelch squelch;
StreamInput stream { 14 };
std::unique_ptr<StreamInput> stream;
AudioStatsCollector audio_stats;

View File

@@ -63,6 +63,10 @@ void NarrowbandAMAudio::on_message(const Message* const message) {
configure(*reinterpret_cast<const AMConfigureMessage*>(message));
break;
case Message::ID::CaptureConfig:
capture_config(*reinterpret_cast<const CaptureConfigMessage*>(message));
break;
default:
break;
}
@@ -93,3 +97,11 @@ void NarrowbandAMAudio::configure(const AMConfigureMessage& message) {
configured = true;
}
void NarrowbandAMAudio::capture_config(const CaptureConfigMessage& message) {
if( message.config ) {
audio_output.set_stream(std::make_unique<StreamInput>(message.config));
} else {
audio_output.set_stream(nullptr);
}
}

View File

@@ -72,6 +72,7 @@ private:
bool configured { false };
void configure(const AMConfigureMessage& message);
void capture_config(const CaptureConfigMessage& message);
buffer_f32_t demodulate(const buffer_c16_t& channel);
};

View File

@@ -34,23 +34,16 @@ CaptureProcessor::CaptureProcessor() {
constexpr size_t decim_1_input_fs = decim_0_output_fs;
constexpr size_t decim_1_output_fs = decim_1_input_fs / decim_1.decimation_factor;
const auto& channel_filter = decim_1_filter;
constexpr size_t channel_filter_input_fs = decim_1_output_fs;
constexpr size_t channel_decimation = 1;
const size_t channel_filter_output_fs = channel_filter_input_fs / channel_decimation;
decim_0.configure(decim_0_filter.taps, 33554432);
decim_1.configure(decim_1_filter.taps, 131072);
channel_filter_pass_f = channel_filter.pass_frequency_normalized * channel_filter_input_fs;
channel_filter_stop_f = channel_filter.stop_frequency_normalized * channel_filter_input_fs;
channel_filter_pass_f = decim_1_filter.pass_frequency_normalized * decim_1_input_fs;
channel_filter_stop_f = decim_1_filter.stop_frequency_normalized * decim_1_input_fs;
spectrum_interval_samples = channel_filter_output_fs / spectrum_rate_hz;
spectrum_interval_samples = decim_1_output_fs / spectrum_rate_hz;
spectrum_samples = 0;
channel_spectrum.set_decimation_factor(1);
stream = std::make_unique<StreamInput>(15);
}
void CaptureProcessor::execute(const buffer_c8_t& buffer) {
@@ -81,7 +74,19 @@ void CaptureProcessor::on_message(const Message* const message) {
channel_spectrum.on_message(message);
break;
case Message::ID::CaptureConfig:
capture_config(*reinterpret_cast<const CaptureConfigMessage*>(message));
break;
default:
break;
}
}
void CaptureProcessor::capture_config(const CaptureConfigMessage& message) {
if( message.config ) {
stream = std::make_unique<StreamInput>(message.config);
} else {
stream.reset();
}
}

View File

@@ -41,7 +41,8 @@ public:
void on_message(const Message* const message) override;
private:
static constexpr size_t baseband_fs = 2457600;
// TODO: Repeated value needs to be transmitted from application side.
static constexpr size_t baseband_fs = 4000000;
static constexpr auto spectrum_rate_hz = 50.0f;
std::array<complex16_t, 512> dst;
@@ -60,6 +61,8 @@ private:
SpectrumCollector channel_spectrum;
size_t spectrum_interval_samples = 0;
size_t spectrum_samples = 0;
void capture_config(const CaptureConfigMessage& message);
};
#endif/*__PROC_CAPTURE_HPP__*/

View File

@@ -53,6 +53,10 @@ void NarrowbandFMAudio::on_message(const Message* const message) {
configure(*reinterpret_cast<const NBFMConfigureMessage*>(message));
break;
case Message::ID::CaptureConfig:
capture_config(*reinterpret_cast<const CaptureConfigMessage*>(message));
break;
default:
break;
}
@@ -81,3 +85,11 @@ void NarrowbandFMAudio::configure(const NBFMConfigureMessage& message) {
configured = true;
}
void NarrowbandFMAudio::capture_config(const CaptureConfigMessage& message) {
if( message.config ) {
audio_output.set_stream(std::make_unique<StreamInput>(message.config));
} else {
audio_output.set_stream(nullptr);
}
}

View File

@@ -66,6 +66,7 @@ private:
bool configured { false };
void configure(const NBFMConfigureMessage& message);
void capture_config(const CaptureConfigMessage& message);
};
#endif/*__PROC_NFM_AUDIO_H__*/

View File

@@ -81,6 +81,10 @@ void WidebandFMAudio::on_message(const Message* const message) {
configure(*reinterpret_cast<const WFMConfigureMessage*>(message));
break;
case Message::ID::CaptureConfig:
capture_config(*reinterpret_cast<const CaptureConfigMessage*>(message));
break;
default:
break;
}
@@ -110,3 +114,11 @@ void WidebandFMAudio::configure(const WFMConfigureMessage& message) {
configured = true;
}
void WidebandFMAudio::capture_config(const CaptureConfigMessage& message) {
if( message.config ) {
audio_output.set_stream(std::make_unique<StreamInput>(message.config));
} else {
audio_output.set_stream(nullptr);
}
}

View File

@@ -68,6 +68,7 @@ private:
bool configured { false };
void configure(const WFMConfigureMessage& message);
void capture_config(const CaptureConfigMessage& message);
};
#endif/*__PROC_WFM_AUDIO_H__*/

View File

@@ -32,18 +32,12 @@
class StreamInput {
public:
StreamInput(const size_t K) :
StreamInput(const size_t K, CaptureConfig& config) :
K { K },
data { std::make_unique<uint8_t[]>(1UL << K) },
fifo { data.get(), K }
{
// TODO: Send stream creation message.
shared_memory.FIFO_HACK = &fifo;
}
~StreamInput() {
// TODO: Send stream distruction message.
shared_memory.FIFO_HACK = nullptr;
config.fifo = &fifo;
}
size_t write(const void* const data, const size_t length) {