- added jay_add and jay_peak_detect

git-svn-id: http://moon:8086/svn/software/trunk/projects/GnuRadio@431 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2019-05-20 22:45:17 +00:00
parent 78e708783e
commit f928afec25
19 changed files with 627 additions and 59 deletions
+3 -1
View File
@@ -31,7 +31,9 @@ list(APPEND jay_sources
bit_slicer_impl.cc
PocsagDecoder.cpp
pocsag_decoder_impl.cc
bit_packer_impl.cc )
bit_packer_impl.cc
add_impl.cc
peak_detect_impl.cc )
set(jay_sources "${jay_sources}" PARENT_SCOPE)
if(NOT jay_sources)
+70
View File
@@ -0,0 +1,70 @@
/* -*- c++ -*- */
/*
* Copyright 2019 Jay Arrowfield.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gnuradio/io_signature.h>
#include "add_impl.h"
namespace gr {
namespace jay {
add::sptr
add::make()
{
return gnuradio::get_initial_sptr
(new add_impl());
}
/*
* The private constructor
*/
add_impl::add_impl()
: gr::sync_block("add",
gr::io_signature::make(1, 1, sizeof(float)),
gr::io_signature::make(1, 1, sizeof(float)))
{}
/*
* Our virtual destructor.
*/
add_impl::~add_impl()
{
}
int
add_impl::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const float *in = (const float *) input_items[0];
float *out = (float *) output_items[0];
// Do <+signal processing+>
// Tell runtime system how many output items we produced.
return noutput_items;
}
} /* namespace jay */
} /* namespace gr */
+48
View File
@@ -0,0 +1,48 @@
/* -*- c++ -*- */
/*
* Copyright 2019 Jay Arrowfield.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef INCLUDED_JAY_ADD_IMPL_H
#define INCLUDED_JAY_ADD_IMPL_H
#include <jay/add.h>
namespace gr {
namespace jay {
class add_impl : public add
{
private:
// Nothing to declare in this block.
public:
add_impl();
~add_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);
};
} // namespace jay
} // namespace gr
#endif /* INCLUDED_JAY_ADD_IMPL_H */
+100
View File
@@ -0,0 +1,100 @@
/* -*- c++ -*- */
/*
* Copyright 2019 Jay Arrowfield.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gnuradio/io_signature.h>
#include "peak_detect_impl.h"
namespace gr {
namespace jay {
peak_detect::sptr
peak_detect::make(float alpha_s, float alpha_m, int vlen)
{
return gnuradio::get_initial_sptr
(new peak_detect_impl(alpha_s, alpha_m, vlen));
}
/*
* The private constructor
*/
peak_detect_impl::peak_detect_impl(float alpha_s, float alpha_m, int vlen)
: gr::sync_block("peak_detect"
, gr::io_signature::make(1, 1, vlen*sizeof(float))
, gr::io_signature::make(1, 1, vlen*sizeof(float)))
, m_alpha_s (alpha_s)
, m_alpha_m(alpha_m)
, m_vlen(vlen)
{
m_pPeakCount = new int[vlen];
m_pXs = new float[vlen];
m_pXm = new float[vlen];
memset(m_pPeakCount, 0, vlen*sizeof(int));
memset(m_pXs, 0, vlen*sizeof(float));
memset(m_pXm, 0, vlen*sizeof(float));
}
/*
* Our virtual destructor.
*/
peak_detect_impl::~peak_detect_impl()
{
delete [] m_pXm;
delete [] m_pXs;
delete [] m_pPeakCount;
}
int
peak_detect_impl::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
int k=0;
fprintf(stderr, "Peak at");
for(int i = 0; i < (noutput_items * m_vlen); i++)
{
float x = ((float*)input_items[k])[i];
m_pXs[i] = (1.f-m_alpha_s)*m_pXs[i] + m_alpha_s*x;
int gate = (int)(m_pXs[i] > (10+m_pXm[i]));
m_pPeakCount[i] = gate*m_pPeakCount[i] + gate;
float peak = (float)(m_pPeakCount[i] > 1);
m_pXm[i] = (1.f-peak)*((1.f-m_alpha_m)*m_pXm[i] + m_alpha_m*x) + peak*m_pXm[i];
((float*)output_items[k])[i] = m_pXm[i];
if (peak > 0.5)
{
fprintf(stderr, " %d", i);
}
}
fprintf(stderr, "\n");
// Tell runtime system how many output items we produced.
return noutput_items;
}
} /* namespace jay */
} /* namespace gr */
+54
View File
@@ -0,0 +1,54 @@
/* -*- c++ -*- */
/*
* Copyright 2019 Jay Arrowfield.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef INCLUDED_JAY_PEAK_DETECT_IMPL_H
#define INCLUDED_JAY_PEAK_DETECT_IMPL_H
#include <jay/peak_detect.h>
namespace gr {
namespace jay {
class peak_detect_impl : public peak_detect
{
private:
// Nothing to declare in this block.
float m_alpha_s;
float m_alpha_m;
int m_vlen;
int *m_pPeakCount;
float *m_pXs;
float *m_pXm;
public:
peak_detect_impl(float alpha_s, float alpha_m, int vlen);
~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);
};
} // namespace jay
} // namespace gr
#endif /* INCLUDED_JAY_PEAK_DETECT_IMPL_H */