1 #ifndef _Signal_h_
2 #define _Signal_h_
3 /* -------------------------------------------------------------------------- *
4  *                             OpenSim:  Signal.h                             *
5  * -------------------------------------------------------------------------- *
6  * The OpenSim API is a toolkit for musculoskeletal modeling and simulation.  *
7  * See http://opensim.stanford.edu and the NOTICE file for more information.  *
8  * OpenSim is developed at Stanford University and supported by the US        *
9  * National Institutes of Health (U54 GM072970, R24 HD065690) and by DARPA    *
10  * through the Warrior Web program.                                           *
11  *                                                                            *
12  * Copyright (c) 2005-2017 Stanford University and the Authors                *
13  * Author(s): Frank C. Anderson                                               *
14  *                                                                            *
15  * Licensed under the Apache License, Version 2.0 (the "License"); you may    *
16  * not use this file except in compliance with the License. You may obtain a  *
17  * copy of the License at http://www.apache.org/licenses/LICENSE-2.0.         *
18  *                                                                            *
19  * Unless required by applicable law or agreed to in writing, software        *
20  * distributed under the License is distributed on an "AS IS" BASIS,          *
21  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   *
22  * See the License for the specific language governing permissions and        *
23  * limitations under the License.                                             *
24  * -------------------------------------------------------------------------- */
25 
26 /* Note: This code was originally developed by Realistic Dynamics Inc.
27  * Author: Frank C. Anderson
28  */
29 
30 
31 #include "osimCommonDLL.h"
32 
33 
34 namespace OpenSim {
35 
36 template <class T> class Array;
37 
38 //=============================================================================
39 //=============================================================================
40 /**
41  * A class for signal processing.
42  */
43 class OSIMCOMMON_API Signal
44 {
45 //=============================================================================
46 // DATA
47 //=============================================================================
48 
49 //=============================================================================
50 // METHODS
51 //=============================================================================
52 public:
53     //--------------------------------------------------------------------------
54     // CONSTRUCTION
55     //--------------------------------------------------------------------------
56     //Signal();
57     //virtual ~Signal();
58 
59     //--------------------------------------------------------------------------
60     // FILTERS
61     //--------------------------------------------------------------------------
62     static int
63         SmoothSpline(int aDegree,double aDeltaT,double aCutOffFrequency,
64         int aN,double *aTimes,double *aSignal,double *rFilteredSignal);
65     static int
66         LowpassIIR(double aDeltaT,double aCutOffFrequency,
67         int aN,double *aSignal,double *rFilteredSignal);
68     static int
69         LowpassFIR(int aOrder,double aDeltaT,double aCutoffFrequency,
70         int aN,double *aSignal,double *rFilteredSignal);
71     static int
72         BandpassFIR(int aOrder,double aDeltaT,
73         double aLowFrequency,double aHighFrequency,
74         int aN,double *aSignal,double *aFilteredSignal);
75 
76     //--------------------------------------------------------------------------
77     // PADDING
78     //--------------------------------------------------------------------------
79     static double*
80         Pad(int aPad,int aN,const double aSignal[]);
81     static void
82         Pad(int aPad,OpenSim::Array<double> &aSignal);
83 
84     //--------------------------------------------------------------------------
85     // POINT REDUCTION
86     //--------------------------------------------------------------------------
87     static int
88         ReduceNumberOfPoints(double aDistance,
89         Array<double> &rTime,Array<double> &rSignal);
90 
91 
92     //--------------------------------------------------------------------------
93     // CORE MATH
94     //--------------------------------------------------------------------------
95     static double sinc(double x);
96     static double hamming(int k,int M);
97 
98 //=============================================================================
99 };  // END class Signal
100 
101 }; //namespace
102 //=============================================================================
103 //=============================================================================
104 
105 #endif  // __Signal_h__
106