static private void add(Object info) { lock (locker) { Smooth.sliding_rms(info); if (Validator.invalid != 0) { Validator.invalid--; return; } AccumNoise[0] += Smooth.output[0]; AccumNoise[1] += Smooth.output[1]; } }
//temporary calibration which tracks maximum amplitude public static void AmpCal(Object info) { lock (locker) { Smooth.sliding_rms(info); // should be called by add EMG_Socket.add instead if (invalid != 0) { --invalid; return; } if (max[0] < Smooth.output[0]) { max[0] = Smooth.output[0]; } if (max[1] < Smooth.output[1]) { max[1] = Smooth.output[1]; } } }
//function use to calculate percentage of muscle activity. public static void evaluate(Object info) { lock (locker) { Smooth.sliding_rms(info); //process EMG Data flex_norm = Math.Abs((Smooth.output[0] - rest_Avg[0]) / (flex_Max[0] - rest_Avg[0])); ext_norm = Math.Abs((Smooth.output[1] - rest_Avg[1]) / (ext_Max[1] - rest_Avg[1])); data[0] = flex_norm; data[1] = ext_norm; if (0.5 * flex_Max[0] <= Smooth.output[0]) { } //valid.Set(); else if (0.5 * ext_Max[1] <= Smooth.output[1]) { } //valid.Set(); } m_LSLOutlet.push_sample(data); }