[med-svn] [aghermann] 10/31: rk1968: op_get_signal_envelope opcode

andrei zavada hmmr-guest at alioth.debian.org
Sun Nov 10 00:34:16 UTC 2013


This is an automated email from the git hooks/post-receive script.

hmmr-guest pushed a commit to branch WIP
in repository aghermann.

commit a43cd60175205fecb609e2a33af3208e4c2db787
Author: Andrei Zavada <hmmr at ra>
Date:   Sat Nov 9 13:41:14 2013 +0200

    rk1968: op_get_signal_envelope opcode
---
 upstream/src/aghermann/rk1968/rk1968.cc |   39 +++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/upstream/src/aghermann/rk1968/rk1968.cc b/upstream/src/aghermann/rk1968/rk1968.cc
index 1972dcb..238973c 100644
--- a/upstream/src/aghermann/rk1968/rk1968.cc
+++ b/upstream/src/aghermann/rk1968/rk1968.cc
@@ -175,6 +175,8 @@ enum TOpcode {
         op_get_psd = 100,
         op_get_mc,
         op_get_swu,
+
+        op_get_signal_envelope,
 };
 
 
@@ -302,6 +304,43 @@ host_get_data( lua_State *L)
                 }
         }
 
+        case op_get_signal_envelope: {
+                NEED_ARITY_EXACT(4);
+
+                const char* channel = lua_tostring( L, 3);
+                auto Hi = E.recordings.find( sigfile::SChannel (channel));
+                if ( Hi == E.recordings.end() ) {
+                        make_error_return( "No such channel (%s)", channel);
+                } else {
+                        auto& R = Hi->second;
+                        int p = lua_tointeger( L, 4);
+                        if ( p < 0 || (size_t)p >= R.full_pages() )
+                                make_error_return( "Page %d out of valid range (%zu is last full)", p, R.full_pages());
+
+                        double dh = lua_tonumber( L, 5);
+                        if ( dh <= 0. || dh > 1e2 )
+                                make_error_return( "Bad scope parameter (%g; expecting it to be in range 0..1e2)", dh);
+                        double dt = lua_tonumber( L, 6);
+                        if ( dt <= 0. || dt > R.pagesize() )
+                                make_error_return( "Bad dt parameter (%g; expecting it to be in range 0..%zu)", dt, R.pagesize());
+
+                        auto sr = R.F().samplerate(R.h());
+                        auto raw_profile = sigproc::raw_signal_profile<TFloat>(
+                                {R.F().get_region_filtered_smpl(
+                                                R.h(),
+                                                p * R.pagesize() * sr, (p+1) * R.pagesize() * sr),
+                                 sr},
+                                dh, dt);
+
+                        auto b = 0u;
+                        if ( !lua_checkstack( L, raw_profile.size()) )
+                                make_error_return( "Failed to grow stack for %zu numbers", raw_profile.size());
+                        while ( b < raw_profile.size() )
+                                lua_pushnumber( L, raw_profile[b]);
+                        return raw_profile.size();
+                }
+        }
+
         default:
                 make_error_return( "Invalid host opcode %d", opcode);
         }

-- 
Alioth's /git/debian-med/git-commit-notice on /srv/git.debian.org/git/debian-med/aghermann.git



More information about the debian-med-commit mailing list