Step 4: Code the Script Calculation

This script will first rectify the input data, then apply a low-pass filter with the specified cutoff to the rectified data.  In EMGscript this can be performed in a single line of code.  Modify the default template as seen below.

/**
* Determine the EMG Envelope through rectification and low-pass filtering.
* @name EMG Envelope
* @version 0.0.0.0
* @author Your Name
* @signed 0
* @namespace EMGENV
*/


EMGENV = {
Calculate : function()
   {
    EMGENV.Output.ENV = EMGENV.Input.abs().filter("LP", EMGENV.Parameter.LPCutoff);
   },

Input : 5,

OutputTemplate:
           {
              ENV: {seq: 1, name: "Signal Envelope"}
           },

Validate : function()
           {
              if (false /* replace with a test for invalid parameters */)
     return "Error message text.";
           },

ParameterTemplate:
           {
     LPCutoff: {seq: 1, name: "LP Cutoff Frequency (Hz)", type:"number", initial: 5, min: 1}
   },
}