Partial refactor of channel filter frequency code.

Move channel filter frequency determination to baseband side, where the filtering is determined and performed.
Add useful accessor methods to BlockDecimator.
This commit is contained in:
Jared Boone 2015-07-17 23:16:09 -07:00
parent ffc50785b7
commit 6f2cbd1ac5
4 changed files with 34 additions and 19 deletions

View File

@ -226,17 +226,9 @@ private:
void on_channel_spectrum(const ChannelSpectrum& spectrum) {
waterfall_view.on_channel_spectrum(spectrum);
frequency_scale.set_spectrum_sampling_rate(spectrum.sampling_rate, spectrum.db_count);
// TODO: Set with actual information.
//taps_64_lp_042_078_tfilter
// TODO: Pass these details, don't hard-code them.
// Channel spectrum is channel filter input, decimated by 2 by the
// channel filter, then by 4 by the channel spectrum decimator.
constexpr size_t channel_spectrum_decimation = 2 * 4;
// TODO: Rename spectrum.bandwidth to spectrum.sampling_rate so this makes sense. */
frequency_scale.set_channel_filter(
spectrum.sampling_rate * channel_spectrum_decimation * 42 / 1000,
spectrum.sampling_rate * channel_spectrum_decimation * 78 / 1000
spectrum.channel_filter_pass_frequency,
spectrum.channel_filter_stop_frequency
);
}
};

View File

@ -32,26 +32,34 @@ class BlockDecimator {
public:
constexpr BlockDecimator(
const size_t factor
) : factor { factor }
) : factor_ { factor }
{
}
void set_input_sampling_rate(const uint32_t new_sampling_rate) {
if( new_sampling_rate != input_sampling_rate ) {
input_sampling_rate = new_sampling_rate;
if( new_sampling_rate != input_sampling_rate() ) {
input_sampling_rate_ = new_sampling_rate;
reset_state();
}
}
uint32_t input_sampling_rate() const {
return input_sampling_rate_;
}
void set_factor(const size_t new_factor) {
if( new_factor != factor ) {
factor = new_factor;
if( new_factor != factor() ) {
factor_ = new_factor;
reset_state();
}
}
size_t factor() const {
return factor_;
}
uint32_t output_sampling_rate() const {
return input_sampling_rate / factor;
return input_sampling_rate() / factor();
}
template<typename BlockCallback>
@ -68,7 +76,7 @@ public:
dst_i = 0;
}
src_i += factor;
src_i += factor();
}
src_i -= src.count;
@ -76,8 +84,8 @@ public:
private:
std::array<complex16_t, N> buffer;
uint32_t input_sampling_rate { 0 };
size_t factor { 1 };
uint32_t input_sampling_rate_ { 0 };
size_t factor_ { 1 };
size_t src_i { 0 };
size_t dst_i { 0 };

View File

@ -338,6 +338,8 @@ private:
static volatile bool channel_spectrum_request_update { false };
static std::array<complex16_t, 256> channel_spectrum;
static uint32_t channel_spectrum_sampling_rate { 0 };
static uint32_t channel_filter_pass_frequency { 0 };
static uint32_t channel_filter_stop_frequency { 0 };
class BasebandProcessor {
public:
@ -434,6 +436,9 @@ public:
* -> FIR filter, <?kHz (0.???fs) pass, gain 1.0
* -> 48kHz int16_t[32] */
auto channel = channel_filter.execute(decimator_out, work_baseband_buffer);
// TODO: Set with information determined from filter taps.
channel_filter_pass_frequency = decimator_out.sampling_rate * 31 / 1000;
channel_filter_stop_frequency = decimator_out.sampling_rate * 70 / 1000;
// TODO: Feed channel_stats post-decimation data?
feed_channel_stats(channel);
@ -480,6 +485,9 @@ public:
* -> FIR filter, <6kHz (0.063fs) pass, gain 1.0
* -> 48kHz int16_t[32] */
auto channel = channel_filter.execute(decimator_out, work_baseband_buffer);
// TODO: Set with information determined from filter taps.
channel_filter_pass_frequency = decimator_out.sampling_rate * 42 / 1000;
channel_filter_stop_frequency = decimator_out.sampling_rate * 78 / 1000;
// TODO: Feed channel_stats post-decimation data?
feed_channel_stats(channel);
@ -620,6 +628,9 @@ public:
* -> FIR filter, <?kHz (?fs) pass, gain 1.0
* -> 76.8kHz int16_t[64] */
auto channel = channel_filter.execute(decimator_out, work_baseband_buffer);
// TODO: Set with information determined from filter taps.
channel_filter_pass_frequency = decimator_out.sampling_rate * 31 / 1000;
channel_filter_stop_frequency = decimator_out.sampling_rate * 70 / 1000;
/* 76.8kHz, 64 samples */
feed_channel_stats(channel);
@ -862,6 +873,8 @@ private:
spectrum_message.spectrum.db = &spectrum_db;
spectrum_message.spectrum.db_count = spectrum_db.size();
spectrum_message.spectrum.sampling_rate = channel_spectrum_sampling_rate;
spectrum_message.spectrum.channel_filter_pass_frequency = channel_filter_pass_frequency;
spectrum_message.spectrum.channel_filter_stop_frequency = channel_filter_stop_frequency;
shared_memory.application_queue.push(&spectrum_message);
}
}

View File

@ -186,6 +186,8 @@ struct ChannelSpectrum {
std::array<uint8_t, 256>* db { nullptr };
size_t db_count { 256 };
uint32_t sampling_rate { 0 };
uint32_t channel_filter_pass_frequency { 0 };
uint32_t channel_filter_stop_frequency { 0 };
};
class ChannelSpectrumMessage : public Message {