[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:
2019-05-25 05:41:50 +00:00
parent 045de0c155
commit f0b29e0e6e
4 changed files with 55 additions and 23 deletions
+39 -12
View File
@@ -4,27 +4,54 @@
<key>jay_peak_detect</key>
<category>[jay]</category>
<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.
Sub-nodes:
* name
* key (makes the value accessible as $keyname, e.g. in the make node)
* type -->
<param>
<name>Alpha short</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>
<name>Vector Length</name>
<key>vlen</key>
<value>1024</value>
<type>int</type>
</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:
* name (an identifier for the GUI)
+1 -1
View File
@@ -46,7 +46,7 @@ namespace gr {
* class. jay::peak_detect::make is the public interface for
* 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
+10 -6
View File
@@ -29,19 +29,23 @@ namespace gr {
namespace jay {
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
(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
*/
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::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_m(alpha_m)
, m_frameCount(0)
@@ -200,7 +204,7 @@ namespace gr {
// Create peak list
// -----------------------------------------------------------------
// 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);
// -----------------------------------------------------------------
@@ -318,9 +322,9 @@ namespace gr {
pbh = std::max(pbh_left, pbh_right);
// 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;
break;
+5 -4
View File
@@ -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_m;
float *m_pPeakData;
@@ -57,11 +61,8 @@ namespace jay {
uint64_t m_frameCount;
pmt::pmt_t m_tag_id;
const int PB_MIN = 5;
const int PB_MAX = 37;
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();
// Where all the action really happens