RTXI  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
gen_biphase.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011 Georgia Institute of Technology
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the Free
6  * Software Foundation, either version 3 of the License, or (at your option)
7  * any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include "gen_biphase.h"
19 
20 // default constructor
21 
23  : width(1)
24  , amplitude(1)
25  , delay(1)
26 {
27  dt = 1e-3;
28  numsamples = floor(delay / dt) + 2 * floor(width / dt) + 1;
29  wave.clear();
30  for (int i = 0; i < floor(delay / dt); i++) {
31  wave.push_back(0); // initial delay
32  }
33  for (int i = 0; i < floor(width / dt); i++) {
34  wave.push_back(amplitude); // positive part
35  }
36  for (int i = 0; i < floor(width / dt); i++) {
37  wave.push_back(-amplitude); // negative part
38  }
39  numsamples = wave.size();
40  index = 0;
41 }
42 
43 GeneratorBiphase::GeneratorBiphase(double delay, double width, double amplitude,
44  double dt)
45  : Generator()
46 {
47  numsamples = floor(delay / dt) + 2 * floor(width / dt) + 1;
48  wave.clear();
49  for (int i = 0; i < floor(delay / dt); i++) {
50  wave.push_back(0); // initial delay
51  }
52  for (int i = 0; i < floor(width / dt); i++) {
53  wave.push_back(amplitude); // positive part
54  }
55  for (int i = 0; i < floor(width / dt); i++) {
56  wave.push_back(-amplitude); // negative part
57  }
58  numsamples = wave.size();
59  index = 0;
60 }
61 
63 {
64 }
65 
66 void
67 GeneratorBiphase::init(double delay, double width, double amplitude, double dt)
68 {
69  numsamples = floor(delay / dt) + 2 * floor(width / dt) + 1;
70  wave.clear();
71 
72  for (int i = 0; i < floor(delay / dt); i++) {
73  wave.push_back(0); // initial delay
74  }
75  for (int i = 0; i < floor(width / dt); i++) {
76  wave.push_back(amplitude); // positive part
77  }
78  for (int i = 0; i < floor(width / dt); i++) {
79  wave.push_back(-amplitude); // negative part
80  }
81  numsamples = wave.size();
82  index = 0;
83 }
double dt
Definition: generator.h:57
int numsamples
Definition: generator.h:56
int index
Definition: generator.h:55
std::vector< double > wave
Definition: generator.h:54
void init()
Definition: generator.cpp:43