[Peak Detect]
- added more parameter git-svn-id: http://moon:8086/svn/software/trunk/projects/GnuRadio@460 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -4,27 +4,54 @@
|
|||||||
<key>jay_peak_detect</key>
|
<key>jay_peak_detect</key>
|
||||||
<category>[jay]</category>
|
<category>[jay]</category>
|
||||||
<import>import jay</import>
|
<import>import jay</import>
|
||||||
<make>jay.peak_detect($alpha_s, $alpha_m, $vlen)</make>
|
<make>jay.peak_detect($vlen, $framerate, $peak_height_min, $peak_width_min, $peak_width_max, $alpha_s, $alpha_m)</make>
|
||||||
<!-- Make one 'param' node for every Parameter you want settable from the GUI.
|
<!-- Make one 'param' node for every Parameter you want settable from the GUI.
|
||||||
Sub-nodes:
|
Sub-nodes:
|
||||||
* name
|
* name
|
||||||
* key (makes the value accessible as $keyname, e.g. in the make node)
|
* key (makes the value accessible as $keyname, e.g. in the make node)
|
||||||
* type -->
|
* type -->
|
||||||
<param>
|
<param>
|
||||||
<name>Alpha short</name>
|
<name>Vector Length</name>
|
||||||
<key>alpha_s</key>
|
|
||||||
<type>float</type>
|
|
||||||
</param>
|
|
||||||
<param>
|
|
||||||
<name>Alpha medium</name>
|
|
||||||
<key>alpha_m</key>
|
|
||||||
<type>float</type>
|
|
||||||
</param>
|
|
||||||
<param>
|
|
||||||
<name>Vector length</name>
|
|
||||||
<key>vlen</key>
|
<key>vlen</key>
|
||||||
|
<value>1024</value>
|
||||||
<type>int</type>
|
<type>int</type>
|
||||||
</param>
|
</param>
|
||||||
|
<param>
|
||||||
|
<name>Frame Rate</name>
|
||||||
|
<key>framerate</key>
|
||||||
|
<value>30</value>
|
||||||
|
<type>float</type>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<name>Peak Height Minimum [dB]</name>
|
||||||
|
<key>peak_height_min</key>
|
||||||
|
<value>20</value>
|
||||||
|
<type>float</type>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<name>Peak Width Minimum [samples]</name>
|
||||||
|
<key>peak_width_min</key>
|
||||||
|
<value>5</value>
|
||||||
|
<type>int</type>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<name>Peak Width Maximum [samples]</name>
|
||||||
|
<key>peak_width_max</key>
|
||||||
|
<value>37</value>
|
||||||
|
<type>int</type>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<name>Alpha Short</name>
|
||||||
|
<key>alpha_s</key>
|
||||||
|
<value>0.4</value>
|
||||||
|
<type>float</type>
|
||||||
|
</param>
|
||||||
|
<param>
|
||||||
|
<name>Alpha Medium</name>
|
||||||
|
<key>alpha_m</key>
|
||||||
|
<value>0.04</value>
|
||||||
|
<type>float</type>
|
||||||
|
</param>
|
||||||
|
|
||||||
<!-- Make one 'sink' node per input. Sub-nodes:
|
<!-- Make one 'sink' node per input. Sub-nodes:
|
||||||
* name (an identifier for the GUI)
|
* name (an identifier for the GUI)
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace gr {
|
|||||||
* class. jay::peak_detect::make is the public interface for
|
* class. jay::peak_detect::make is the public interface for
|
||||||
* creating new instances.
|
* creating new instances.
|
||||||
*/
|
*/
|
||||||
static sptr make(float alpha_s, float alpha_l, int vlen);
|
static sptr make(int vlen, float framerate, float peak_height_min, int peak_width_min, int peak_width_max, float alpha_s, float alpha_m);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace jay
|
} // namespace jay
|
||||||
|
|||||||
@@ -29,19 +29,23 @@ namespace gr {
|
|||||||
namespace jay {
|
namespace jay {
|
||||||
|
|
||||||
peak_detect::sptr
|
peak_detect::sptr
|
||||||
peak_detect::make(float alpha_s, float alpha_m, int vlen)
|
peak_detect::make(int vlen, float framerate, float peak_height_min, int peak_width_min, int peak_width_max, float alpha_s, float alpha_m)
|
||||||
{
|
{
|
||||||
return gnuradio::get_initial_sptr
|
return gnuradio::get_initial_sptr
|
||||||
(new peak_detect_impl(alpha_s, alpha_m, vlen));
|
(new peak_detect_impl(vlen, framerate, peak_height_min, peak_width_min, peak_width_max, alpha_s, alpha_m));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The private constructor
|
* The private constructor
|
||||||
*/
|
*/
|
||||||
peak_detect_impl::peak_detect_impl(float alpha_s, float alpha_m, int vlen)
|
peak_detect_impl::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)
|
||||||
: gr::sync_block("peak_detect"
|
: gr::sync_block("peak_detect"
|
||||||
, gr::io_signature::make(1, 1, vlen*sizeof(float))
|
, gr::io_signature::make(1, 1, vlen*sizeof(float))
|
||||||
, gr::io_signature::make(1, 1, vlen*sizeof(float)))
|
, gr::io_signature::make(1, 1, vlen*sizeof(float)))
|
||||||
|
, m_framerate (framerate)
|
||||||
|
, m_peak_height_min (peak_height_min)
|
||||||
|
, m_peak_width_min (peak_width_min)
|
||||||
|
, m_peak_width_max (peak_width_max)
|
||||||
, m_alpha_s (alpha_s)
|
, m_alpha_s (alpha_s)
|
||||||
, m_alpha_m(alpha_m)
|
, m_alpha_m(alpha_m)
|
||||||
, m_frameCount(0)
|
, m_frameCount(0)
|
||||||
@@ -200,7 +204,7 @@ namespace gr {
|
|||||||
// Create peak list
|
// Create peak list
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
// Find peak candidates by thresholding
|
// Find peak candidates by thresholding
|
||||||
threshold(m_pPeakData, m_pXd, nitems_per_block, 20.f);
|
threshold(m_pPeakData, m_pXd, nitems_per_block, m_peak_height_min);
|
||||||
int numPeaks = findPeakPos(m_pPeakPos, m_pPeakData, nitems_per_block);
|
int numPeaks = findPeakPos(m_pPeakPos, m_pPeakData, nitems_per_block);
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
@@ -318,9 +322,9 @@ namespace gr {
|
|||||||
pbh = std::max(pbh_left, pbh_right);
|
pbh = std::max(pbh_left, pbh_right);
|
||||||
|
|
||||||
// Ensure peak box is at least pb_min
|
// Ensure peak box is at least pb_min
|
||||||
pbh = std::max(pbh, PB_MIN);
|
pbh = std::max(pbh, m_peak_width_min);
|
||||||
|
|
||||||
if (pbh > PB_MAX)
|
if (pbh > m_peak_width_max)
|
||||||
{
|
{
|
||||||
pbh = 0;
|
pbh = 0;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -44,6 +44,10 @@ namespace jay {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
float m_framerate;
|
||||||
|
float m_peak_height_min;
|
||||||
|
int m_peak_width_min;
|
||||||
|
int m_peak_width_max;
|
||||||
float m_alpha_s;
|
float m_alpha_s;
|
||||||
float m_alpha_m;
|
float m_alpha_m;
|
||||||
float *m_pPeakData;
|
float *m_pPeakData;
|
||||||
@@ -57,11 +61,8 @@ namespace jay {
|
|||||||
uint64_t m_frameCount;
|
uint64_t m_frameCount;
|
||||||
pmt::pmt_t m_tag_id;
|
pmt::pmt_t m_tag_id;
|
||||||
|
|
||||||
const int PB_MIN = 5;
|
|
||||||
const int PB_MAX = 37;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
peak_detect_impl(float alpha_s, float alpha_m, int vlen);
|
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();
|
~peak_detect_impl();
|
||||||
|
|
||||||
// Where all the action really happens
|
// Where all the action really happens
|
||||||
|
|||||||
Reference in New Issue
Block a user