-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathRectangle.cpp
More file actions
executable file
·61 lines (53 loc) · 1.19 KB
/
Rectangle.cpp
File metadata and controls
executable file
·61 lines (53 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Rectangle.cpp: implementation of the CRectangle class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "SpectrumAnalysis.h"
#include "Rectangle.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CRectangle::CRectangle()
{
m_iType = SPA_FIL_RECTANGLE;
}
CRectangle::~CRectangle()
{
}
//////////////////////////////////////////////////////////////////////////
// main function
DOUBLE CRectangle::getRectangleValue(LONG in_n, LONG in_N)
{
if(in_n < 0 || in_n > 2*in_N)
{
return 0;
}
else
{
return 1;
}
}
INT CRectangle::DoFilter(CSignal &inout_pSignal)
{
try
{
LONG nSignalSize = inout_pSignal.GetSignalSize();
LONG nN = nSignalSize/2;
for(LONG i=0;i< nSignalSize; i++ )
{
DOUBLE dTemp =
inout_pSignal[i] * this->getRectangleValue(i,nN);
inout_pSignal[i] = (SAMPLE)dTemp;
}
}
catch(...)
{
return SPA_ERR_FILTERFAIL;
}
return SPA_NORMAL;
}