This is an automated email from the git hooks/post-receive script. hmmr-guest pushed a commit to branch WIP in repository aghermann.
commit c3be63f49fe799a33e21486ff7f5d3936075ff00 Author: Andrei Zavada <[email protected]> Date: Tue Oct 8 02:22:35 2013 +0300 rk1968::emg_steady_tone --- upstream/src/aghermann/rk1968/rk1968.hh | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/upstream/src/aghermann/rk1968/rk1968.hh b/upstream/src/aghermann/rk1968/rk1968.hh index 9de6fc8..6d9e892 100644 --- a/upstream/src/aghermann/rk1968/rk1968.hh +++ b/upstream/src/aghermann/rk1968/rk1968.hh @@ -12,8 +12,10 @@ #ifndef AGH_AGHERMANN_RK1968_H_ #define AGH_AGHERMANN_RK1968_H_ +#include <float.h> #include <string> #include "aghermann/expdesign/dirlevel.hh" +#include "libsigproc/sigproc.hh" using namespace std; @@ -90,6 +92,42 @@ class CScoreAssistant }; + + +template <typename T> +pair<T, size_t> +emg_steady_tone( const sigproc::SSignalRef<T>& V, size_t steady_secs, double max_dev_factor) +{ + // static const double env_scope = 1.; + // static const double dt = 1.; + // static const double range_min = 0.; + // static const size_t bins = 20; + // const double binsize = + // sigproc::envelope_breadth_histogram( + // sigref, env_scope, dt, + /// take it easy + + // examine 1-sec intervals until a length of, say, 10 sec is seen steady enough + valarray<T> bench (steady_secs); + size_t s = 1 * V.samplerate; + for ( int sec = 0; sec < V.signal.size() / V.samplerate - steady_secs - 1; ++sec ) { + auto range = slice (sec * s, s, 1); + bench[sec % steady_secs] = V.signal[range].sum() / s; + printf( "r[%zu] = %g\n", sec, bench[sec % steady_secs]); + if ( sec < steady_secs ) + continue; + T avg = bench.sum() / steady_secs; + for ( size_t t = 0; t < steady_secs; ++t ) + if ( 1 + fabs(bench[t] - avg) / avg > max_dev_factor ) + goto outer_continue; + return {avg, sec}; + outer_continue: + ; + } + return {NAN, (size_t)-1}; +} + + } // namespace rk1968 } // namespace agh -- Alioth's /git/debian-med/git-commit-notice on /srv/git.debian.org/git/debian-med/aghermann.git _______________________________________________ debian-med-commit mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/debian-med-commit
