Peak detect

- optional outputs
- make general block

git-svn-id: http://moon:8086/svn/software/trunk/projects/GnuRadio@509 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2019-05-29 16:16:42 +00:00
parent e78ef5b772
commit 0faa5a81db
4 changed files with 38 additions and 16 deletions
+2
View File
@@ -90,11 +90,13 @@
<name>out</name>
<type>float</type>
<vlen>$vlen</vlen>
<optional>1</optional>
</source>
<source>
<name>pbox</name>
<type>float</type>
<vlen>$vlen</vlen>
<optional>1</optional>
</source>
<source>
<name>status</name>
+1 -1
View File
@@ -33,7 +33,7 @@ namespace gr {
* \ingroup jay
*
*/
class JAY_API peak_detect : virtual public gr::sync_block
class JAY_API peak_detect : virtual public gr::block
{
public:
typedef boost::shared_ptr<peak_detect> sptr;
+32 -14
View File
@@ -39,9 +39,9 @@ namespace gr {
* The private constructor
*/
peak_detect_impl::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)
: gr::sync_block("peak_detect"
: gr::block("peak_detect"
, gr::io_signature::make(1, 1, vlen*sizeof(float))
, gr::io_signature::make(2, 2, vlen*sizeof(float)))
, gr::io_signature::make(0, 2, vlen*sizeof(float)))
, m_vlen(vlen)
, m_framerate (framerate)
, m_bandwidth (bandwidth)
@@ -126,23 +126,31 @@ namespace gr {
}
}
return result;
}
}
int
peak_detect_impl::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
void peak_detect_impl::forecast(int noutput_items, gr_vector_int& ninput_items_required)
{
ninput_items_required[0] = noutput_items;
}
int peak_detect_impl::general_work (int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
{
const int DATA = 0;
const int PBOX = 1;
int nitems_per_block = this->output_signature()->sizeof_stream_item(0)/sizeof(float);
float *iptr = (float *)input_items[DATA];
float *optr_data = (float *)output_items[DATA];
float *optr_pbox = (float *)output_items[PBOX];
float *optr_data = nullptr;
float *optr_pbox = nullptr;
if (output_items.size() > 0)
{
optr_data = (float *)output_items[DATA];
optr_pbox = (float *)output_items[PBOX];
}
for (int k = 0; k < noutput_items; k++)
for (int k = 0; k < ninput_items[DATA]; k++)
{
// Initialization on first frame
if (m_frameCount == 0)
@@ -369,13 +377,23 @@ namespace gr {
// -----------------------------------------------------------------
// Output peak box data
// -----------------------------------------------------------------
for (int i = 0; i < nitems_per_block; i++)
if (optr_data)
{
*(optr_data++) = m_pXs[i];
*(optr_pbox++) = m_pPeakBox_abs[i];
for (int i = 0; i < nitems_per_block; i++)
{
*(optr_data++) = m_pXs[i];
}
}
if (optr_pbox)
{
for (int i = 0; i < nitems_per_block; i++)
{
*(optr_pbox++) = m_pPeakBox_abs[i];
}
}
m_frameCount++;
consume(0, ninput_items[DATA]);
}
// Tell runtime system how many output items we produced.
+3 -1
View File
@@ -326,7 +326,9 @@ namespace jay {
~peak_detect_impl();
// Where all the action really happens
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
int general_work (int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
void forecast (int noutput_items, gr_vector_int &ninput_items_required);
private:
void fill(float *pDst, int length, float value);
float mean(float *pSrc, int length);