comparison data/model/AggregateWaveModel.cpp @ 1038:cc27f35aa75c cxx11

Introducing the signed 64-bit frame index type, and fixing build failures from inclusion of -Wconversion with -Werror. Not finished yet.
author Chris Cannam
date Tue, 03 Mar 2015 15:18:24 +0000
parents d9e0e59a1581
children a1cd5abcb38b
comparison
equal deleted inserted replaced
1037:bf0e5944289b 1038:cc27f35aa75c
63 } 63 }
64 } 64 }
65 return ready; 65 return ready;
66 } 66 }
67 67
68 int 68 sv_frame_t
69 AggregateWaveModel::getFrameCount() const 69 AggregateWaveModel::getFrameCount() const
70 { 70 {
71 int count = 0; 71 sv_frame_t count = 0;
72 72
73 for (ChannelSpecList::const_iterator i = m_components.begin(); 73 for (ChannelSpecList::const_iterator i = m_components.begin();
74 i != m_components.end(); ++i) { 74 i != m_components.end(); ++i) {
75 int thisCount = i->model->getEndFrame() - i->model->getStartFrame(); 75 sv_frame_t thisCount = i->model->getEndFrame() - i->model->getStartFrame();
76 if (thisCount > count) count = thisCount; 76 if (thisCount > count) count = thisCount;
77 } 77 }
78 78
79 return count; 79 return count;
80 } 80 }
81 81
82 int 82 int
83 AggregateWaveModel::getChannelCount() const 83 AggregateWaveModel::getChannelCount() const
84 { 84 {
85 return m_components.size(); 85 return int(m_components.size());
86 } 86 }
87 87
88 int 88 int
89 AggregateWaveModel::getSampleRate() const 89 AggregateWaveModel::getSampleRate() const
90 { 90 {
96 AggregateWaveModel::clone() const 96 AggregateWaveModel::clone() const
97 { 97 {
98 return new AggregateWaveModel(m_components); 98 return new AggregateWaveModel(m_components);
99 } 99 }
100 100
101 int 101 sv_frame_t
102 AggregateWaveModel::getData(int channel, int start, int count, 102 AggregateWaveModel::getData(int channel, sv_frame_t start, sv_frame_t count,
103 float *buffer) const 103 float *buffer) const
104 { 104 {
105 int ch0 = channel, ch1 = channel; 105 int ch0 = channel, ch1 = channel;
106 bool mixing = false; 106 bool mixing = false;
107 if (channel == -1) { 107 if (channel == -1) {
111 } 111 }
112 112
113 float *readbuf = buffer; 113 float *readbuf = buffer;
114 if (mixing) { 114 if (mixing) {
115 readbuf = new float[count]; 115 readbuf = new float[count];
116 for (int i = 0; i < count; ++i) { 116 for (sv_frame_t i = 0; i < count; ++i) {
117 buffer[i] = 0.f; 117 buffer[i] = 0.f;
118 } 118 }
119 } 119 }
120 120
121 int longest = 0; 121 sv_frame_t longest = 0;
122 122
123 for (int c = ch0; c <= ch1; ++c) { 123 for (int c = ch0; c <= ch1; ++c) {
124 int here = 124 sv_frame_t here =
125 m_components[c].model->getData(m_components[c].channel, 125 m_components[c].model->getData(m_components[c].channel,
126 start, count, 126 start, count,
127 readbuf); 127 readbuf);
128 if (here > longest) { 128 if (here > longest) {
129 longest = here; 129 longest = here;
130 } 130 }
131 if (here < count) { 131 if (here < count) {
132 for (int i = here; i < count; ++i) { 132 for (sv_frame_t i = here; i < count; ++i) {
133 readbuf[i] = 0.f; 133 readbuf[i] = 0.f;
134 } 134 }
135 } 135 }
136 if (mixing) { 136 if (mixing) {
137 for (int i = 0; i < count; ++i) { 137 for (sv_frame_t i = 0; i < count; ++i) {
138 buffer[i] += readbuf[i]; 138 buffer[i] += readbuf[i];
139 } 139 }
140 } 140 }
141 } 141 }
142 142
143 if (mixing) delete[] readbuf; 143 if (mixing) delete[] readbuf;
144 return longest; 144 return longest;
145 } 145 }
146 146
147 int 147 sv_frame_t
148 AggregateWaveModel::getData(int channel, int start, int count, 148 AggregateWaveModel::getData(int channel, sv_frame_t start, sv_frame_t count,
149 double *buffer) const 149 double *buffer) const
150 { 150 {
151 int ch0 = channel, ch1 = channel; 151 int ch0 = channel, ch1 = channel;
152 bool mixing = false; 152 bool mixing = false;
153 if (channel == -1) { 153 if (channel == -1) {
157 } 157 }
158 158
159 double *readbuf = buffer; 159 double *readbuf = buffer;
160 if (mixing) { 160 if (mixing) {
161 readbuf = new double[count]; 161 readbuf = new double[count];
162 for (int i = 0; i < count; ++i) { 162 for (sv_frame_t i = 0; i < count; ++i) {
163 buffer[i] = 0.0; 163 buffer[i] = 0.0;
164 } 164 }
165 } 165 }
166 166
167 int longest = 0; 167 sv_frame_t longest = 0;
168 168
169 for (int c = ch0; c <= ch1; ++c) { 169 for (int c = ch0; c <= ch1; ++c) {
170 int here = 170 sv_frame_t here =
171 m_components[c].model->getData(m_components[c].channel, 171 m_components[c].model->getData(m_components[c].channel,
172 start, count, 172 start, count,
173 readbuf); 173 readbuf);
174 if (here > longest) { 174 if (here > longest) {
175 longest = here; 175 longest = here;
176 } 176 }
177 if (here < count) { 177 if (here < count) {
178 for (int i = here; i < count; ++i) { 178 for (sv_frame_t i = here; i < count; ++i) {
179 readbuf[i] = 0.; 179 readbuf[i] = 0.;
180 } 180 }
181 } 181 }
182 if (mixing) { 182 if (mixing) {
183 for (int i = 0; i < count; ++i) { 183 for (sv_frame_t i = 0; i < count; ++i) {
184 buffer[i] += readbuf[i]; 184 buffer[i] += readbuf[i];
185 } 185 }
186 } 186 }
187 } 187 }
188 188
189 if (mixing) delete[] readbuf; 189 if (mixing) delete[] readbuf;
190 return longest; 190 return longest;
191 } 191 }
192 192
193 int 193 sv_frame_t
194 AggregateWaveModel::getData(int fromchannel, int tochannel, 194 AggregateWaveModel::getData(int fromchannel, int tochannel,
195 int start, int count, 195 sv_frame_t start, sv_frame_t count,
196 float **buffer) const 196 float **buffer) const
197 { 197 {
198 int min = count; 198 sv_frame_t min = count;
199 199
200 for (int c = fromchannel; c <= tochannel; ++c) { 200 for (int c = fromchannel; c <= tochannel; ++c) {
201 int here = getData(c, start, count, buffer[c - fromchannel]); 201 sv_frame_t here = getData(c, start, count, buffer[c - fromchannel]);
202 if (here < min) min = here; 202 if (here < min) min = here;
203 } 203 }
204 204
205 return min; 205 return min;
206 } 206 }
211 //!!! complete 211 //!!! complete
212 return desired; 212 return desired;
213 } 213 }
214 214
215 void 215 void
216 AggregateWaveModel::getSummaries(int, int, int, 216 AggregateWaveModel::getSummaries(int, sv_frame_t, sv_frame_t,
217 RangeBlock &, int &) const 217 RangeBlock &, int &) const
218 { 218 {
219 //!!! complete 219 //!!! complete
220 } 220 }
221 221
222 AggregateWaveModel::Range 222 AggregateWaveModel::Range
223 AggregateWaveModel::getSummary(int, int, int) const 223 AggregateWaveModel::getSummary(int, sv_frame_t, sv_frame_t) const
224 { 224 {
225 //!!! complete 225 //!!! complete
226 return Range(); 226 return Range();
227 } 227 }
228 228
229 int 229 int
230 AggregateWaveModel::getComponentCount() const 230 AggregateWaveModel::getComponentCount() const
231 { 231 {
232 return m_components.size(); 232 return int(m_components.size());
233 } 233 }
234 234
235 AggregateWaveModel::ModelChannelSpec 235 AggregateWaveModel::ModelChannelSpec
236 AggregateWaveModel::getComponent(int c) const 236 AggregateWaveModel::getComponent(int c) const
237 { 237 {
243 { 243 {
244 emit modelChanged(); 244 emit modelChanged();
245 } 245 }
246 246
247 void 247 void
248 AggregateWaveModel::componentModelChangedWithin(int start, int end) 248 AggregateWaveModel::componentModelChangedWithin(sv_frame_t start, sv_frame_t end)
249 { 249 {
250 emit modelChangedWithin(start, end); 250 emit modelChangedWithin(start, end);
251 } 251 }
252 252
253 void 253 void