Perform frequency-domain windowing of spectrum.

Reduces sidelobes a bit, improves apparent resolution. Avoids windowing (more RAM and CPU) in baseband.
This commit is contained in:
Jared Boone 2015-12-20 13:31:00 -08:00
parent b38338efc0
commit bddd26d557

View File

@ -69,7 +69,10 @@ void SpectrumCollector::update() {
ChannelSpectrumMessage spectrum_message; ChannelSpectrumMessage spectrum_message;
for(size_t i=0; i<spectrum_message.spectrum.db.size(); i++) { for(size_t i=0; i<spectrum_message.spectrum.db.size(); i++) {
const auto mag2 = magnitude_squared(channel_spectrum[i]); // Three point Hamming window.
const auto corrected_sample = channel_spectrum[i] * 0.54f
+ (channel_spectrum[(i-1) & 0xff] + channel_spectrum[(i+1) & 0xff]) * -0.23f;
const auto mag2 = magnitude_squared(corrected_sample);
const float db = complex16_mag_squared_to_dbv_norm(mag2); const float db = complex16_mag_squared_to_dbv_norm(mag2);
constexpr float mag_scale = 5.0f; constexpr float mag_scale = 5.0f;
const unsigned int v = (db * mag_scale) + 255.0f; const unsigned int v = (db * mag_scale) + 255.0f;