comparison data/model/test/MockWaveModel.cpp @ 1429:48e9f538e6e9

Untabify
author Chris Cannam
date Thu, 01 Mar 2018 18:02:22 +0000
parents 54af1e21705c
children a12fd0456f0c
comparison
equal deleted inserted replaced
1428:87ae75da6527 1429:48e9f538e6e9
20 using namespace std; 20 using namespace std;
21 21
22 MockWaveModel::MockWaveModel(vector<Sort> sorts, int length, int pad) 22 MockWaveModel::MockWaveModel(vector<Sort> sorts, int length, int pad)
23 { 23 {
24 for (auto sort: sorts) { 24 for (auto sort: sorts) {
25 m_data.push_back(generate(sort, length, pad)); 25 m_data.push_back(generate(sort, length, pad));
26 } 26 }
27 } 27 }
28 28
29 floatvec_t 29 floatvec_t
30 MockWaveModel::getData(int channel, sv_frame_t start, sv_frame_t count) const 30 MockWaveModel::getData(int channel, sv_frame_t start, sv_frame_t count) const
34 // cerr << "MockWaveModel::getData(" << channel << "," << start << "," << count << "): "; 34 // cerr << "MockWaveModel::getData(" << channel << "," << start << "," << count << "): ";
35 35
36 floatvec_t data; 36 floatvec_t data;
37 37
38 while (i < count) { 38 while (i < count) {
39 sv_frame_t idx = start + i; 39 sv_frame_t idx = start + i;
40 if (!in_range_for(m_data[channel], idx)) break; 40 if (!in_range_for(m_data[channel], idx)) break;
41 data.push_back(m_data[channel][idx]); 41 data.push_back(m_data[channel][idx]);
42 // cerr << data[i] << " "; 42 // cerr << data[i] << " ";
43 ++i; 43 ++i;
44 } 44 }
45 45
46 // cerr << endl; 46 // cerr << endl;
47 47
48 return data; 48 return data;
49 } 49 }
50 50
51 vector<floatvec_t> 51 vector<floatvec_t>
52 MockWaveModel::getMultiChannelData(int fromchannel, int tochannel, 52 MockWaveModel::getMultiChannelData(int fromchannel, int tochannel,
53 sv_frame_t start, sv_frame_t count) const 53 sv_frame_t start, sv_frame_t count) const
54 { 54 {
55 vector<floatvec_t> data(tochannel - fromchannel + 1); 55 vector<floatvec_t> data(tochannel - fromchannel + 1);
56 56
57 for (int c = fromchannel; c <= tochannel; ++c) { 57 for (int c = fromchannel; c <= tochannel; ++c) {
58 data.push_back(getData(c, start, count)); 58 data.push_back(getData(c, start, count));
70 data.push_back(0.f); 70 data.push_back(0.f);
71 } 71 }
72 72
73 for (int i = 0; i < length; ++i) { 73 for (int i = 0; i < length; ++i) {
74 74
75 double v = 0.0; 75 double v = 0.0;
76 76
77 switch (sort) { 77 switch (sort) {
78 case DC: v = 1.0; break; 78 case DC: v = 1.0; break;
79 case Sine: v = sin((2.0 * M_PI / 8.0) * i); break; 79 case Sine: v = sin((2.0 * M_PI / 8.0) * i); break;
80 case Cosine: v = cos((2.0 * M_PI / 8.0) * i); break; 80 case Cosine: v = cos((2.0 * M_PI / 8.0) * i); break;
81 case Nyquist: v = (i % 2) * 2 - 1; break; 81 case Nyquist: v = (i % 2) * 2 - 1; break;
82 case Dirac: v = (i == 0) ? 1.0 : 0.0; break; 82 case Dirac: v = (i == 0) ? 1.0 : 0.0; break;
83 } 83 }
84 84
85 data.push_back(float(v)); 85 data.push_back(float(v));
86 } 86 }
87 87
88 for (int i = 0; i < pad; ++i) { 88 for (int i = 0; i < pad; ++i) {
89 data.push_back(0.f); 89 data.push_back(0.f);
90 } 90 }