- Peak detector delivers frequency instead of bin

git-svn-id: http://moon:8086/svn/software/trunk/projects/GnuRadio@492 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2019-05-28 17:19:19 +00:00
parent 315932ea4e
commit dc6485e73f
6 changed files with 73 additions and 18 deletions
+12 -5
View File
@@ -31,19 +31,20 @@ namespace jay {
struct Peak
{
Peak()
: Peak(0, 0, 0, 0.0, 0.0)
: Peak(0, 0, 0, 0.0, 0.0, 0.0)
{
}
Peak(uint64_t _id, int _pos)
: Peak(_id, _pos, 0, 0.0, 0.0)
Peak(uint64_t _id, int _pos, float frequency)
: Peak(_id, _pos, 0, frequency, 0.0, 0.0)
{
}
Peak(uint64_t _id, int _pos, int _pbh, float _height_rel, float _height_abs)
Peak(uint64_t _id, int _pos, int _pbh, float _frequency, float _height_rel, float _height_abs)
: id(_id)
, pos(_pos)
, pbh(_pbh)
, frequency(_frequency)
, height_rel(_height_rel)
, height_abs(_height_abs)
{
@@ -54,6 +55,7 @@ namespace jay {
int pbh;
float height_rel;
float height_abs;
float frequency;
bool isInRange(const Peak &other) const
{
@@ -153,6 +155,7 @@ namespace jay {
float alpha = (1.f-beta);
float pos_f = alpha*(float)pos + beta*(float)other.pos;
float pbh_f = alpha*(float)pbh + beta*(float)other.pbh;
float frequency = alpha*(float)frequency + beta*(float)other.frequency;
pos = (int)(pos_f + 0.5f);
pbh = (int)(pbh_f + 0.5f);
height_rel = other.height_rel;
@@ -175,6 +178,7 @@ namespace jay {
pmt::pmt_t dict = pmt::make_dict();
dict = pmt::dict_add(dict, pmt::string_to_symbol(std::string("id")), pmt::from_long(id));
dict = pmt::dict_add(dict, pmt::string_to_symbol(std::string("pos")), pmt::from_long(pos));
dict = pmt::dict_add(dict, pmt::string_to_symbol(std::string("freq_Hz")), pmt::from_float(frequency));
dict = pmt::dict_add(dict, pmt::string_to_symbol(std::string("height")), pmt::from_float(height_rel));
dict = pmt::dict_add(dict, pmt::string_to_symbol(std::string("state")), pmt::from_long(state));
@@ -222,7 +226,10 @@ namespace jay {
return !found;
}
int m_vlen;
float m_framerate;
float m_bandwidth;
float m_fcenter;
float m_peak_height_min;
int m_peak_width_min;
int m_peak_width_max;
@@ -245,7 +252,7 @@ namespace jay {
pmt::pmt_t m_msg_port_out;
public:
peak_detect_impl(int vlen, float framerate, float peak_height_min, int peak_width_min, int peak_width_max, float alpha_s, float alpha_m);
peak_detect_impl(int vlen, float framerate, float bandwidth, float fcenter, float peak_height_min, int peak_width_min, int peak_width_max, float alpha_s, float alpha_m);
~peak_detect_impl();
// Where all the action really happens