comparison transform/RealTimeEffectModelTransformer.cpp @ 936:0c1d6de8f44b

Merge from branch warnfix_no_size_t
author Chris Cannam
date Wed, 18 Jun 2014 13:51:16 +0100
parents 06579b8ffb7b
children d5404b8421b4
comparison
equal deleted inserted replaced
917:49618f39ff09 936:0c1d6de8f44b
80 return; 80 return;
81 } 81 }
82 82
83 if (m_outputNo == -1) { 83 if (m_outputNo == -1) {
84 84
85 size_t outputChannels = m_plugin->getAudioOutputCount(); 85 int outputChannels = m_plugin->getAudioOutputCount();
86 if (outputChannels > input->getChannelCount()) { 86 if (outputChannels > input->getChannelCount()) {
87 outputChannels = input->getChannelCount(); 87 outputChannels = input->getChannelCount();
88 } 88 }
89 89
90 WritableWaveFileModel *model = new WritableWaveFileModel 90 WritableWaveFileModel *model = new WritableWaveFileModel
135 WritableWaveFileModel *wwfm = dynamic_cast<WritableWaveFileModel *>(m_outputs[0]); 135 WritableWaveFileModel *wwfm = dynamic_cast<WritableWaveFileModel *>(m_outputs[0]);
136 if (!stvm && !wwfm) return; 136 if (!stvm && !wwfm) return;
137 137
138 if (stvm && (m_outputNo >= int(m_plugin->getControlOutputCount()))) return; 138 if (stvm && (m_outputNo >= int(m_plugin->getControlOutputCount()))) return;
139 139
140 size_t sampleRate = input->getSampleRate(); 140 int sampleRate = input->getSampleRate();
141 size_t channelCount = input->getChannelCount(); 141 int channelCount = input->getChannelCount();
142 if (!wwfm && m_input.getChannel() != -1) channelCount = 1; 142 if (!wwfm && m_input.getChannel() != -1) channelCount = 1;
143 143
144 long blockSize = m_plugin->getBufferSize(); 144 long blockSize = m_plugin->getBufferSize();
145 145
146 float **inbufs = m_plugin->getAudioInputBuffers(); 146 float **inbufs = m_plugin->getAudioInputBuffers();
195 (m_input.getChannel(), blockFrame, blockSize, inbufs[0]); 195 (m_input.getChannel(), blockFrame, blockSize, inbufs[0]);
196 while (got < blockSize) { 196 while (got < blockSize) {
197 inbufs[0][got++] = 0.0; 197 inbufs[0][got++] = 0.0;
198 } 198 }
199 } 199 }
200 for (size_t ch = 1; ch < m_plugin->getAudioInputCount(); ++ch) { 200 for (int ch = 1; ch < (int)m_plugin->getAudioInputCount(); ++ch) {
201 for (long i = 0; i < blockSize; ++i) { 201 for (long i = 0; i < blockSize; ++i) {
202 inbufs[ch][i] = inbufs[0][i]; 202 inbufs[ch][i] = inbufs[0][i];
203 } 203 }
204 } 204 }
205 } else { 205 } else {
206 if (inbufs && inbufs[0]) { 206 if (inbufs && inbufs[0]) {
207 got = input->getData(0, channelCount - 1, 207 got = input->getData(0, channelCount - 1,
208 blockFrame, blockSize, 208 blockFrame, blockSize,
209 inbufs); 209 inbufs);
210 while (got < blockSize) { 210 while (got < blockSize) {
211 for (size_t ch = 0; ch < channelCount; ++ch) { 211 for (int ch = 0; ch < channelCount; ++ch) {
212 inbufs[ch][got] = 0.0; 212 inbufs[ch][got] = 0.0;
213 } 213 }
214 ++got; 214 ++got;
215 } 215 }
216 } 216 }
217 for (size_t ch = channelCount; ch < m_plugin->getAudioInputCount(); ++ch) { 217 for (int ch = channelCount; ch < (int)m_plugin->getAudioInputCount(); ++ch) {
218 for (long i = 0; i < blockSize; ++i) { 218 for (long i = 0; i < blockSize; ++i) {
219 inbufs[ch][i] = inbufs[ch % channelCount][i]; 219 inbufs[ch][i] = inbufs[ch % channelCount][i];
220 } 220 }
221 } 221 }
222 } 222 }
223 223
224 /* 224 /*
225 cerr << "Input for plugin: " << m_plugin->getAudioInputCount() << " channels "<< endl; 225 cerr << "Input for plugin: " << m_plugin->getAudioInputCount() << " channels "<< endl;
226 226
227 for (size_t ch = 0; ch < m_plugin->getAudioInputCount(); ++ch) { 227 for (int ch = 0; ch < m_plugin->getAudioInputCount(); ++ch) {
228 cerr << "Input channel " << ch << endl; 228 cerr << "Input channel " << ch << endl;
229 for (size_t i = 0; i < 100; ++i) { 229 for (int i = 0; i < 100; ++i) {
230 cerr << inbufs[ch][i] << " "; 230 cerr << inbufs[ch][i] << " ";
231 if (isnan(inbufs[ch][i])) { 231 if (isnan(inbufs[ch][i])) {
232 cerr << "\n\nWARNING: NaN in audio input" << endl; 232 cerr << "\n\nWARNING: NaN in audio input" << endl;
233 } 233 }
234 } 234 }
261 wwfm->addSamples(outbufs, writeSize); 261 wwfm->addSamples(outbufs, writeSize);
262 } else if (blockFrame + blockSize >= latency) { 262 } else if (blockFrame + blockSize >= latency) {
263 long offset = latency - blockFrame; 263 long offset = latency - blockFrame;
264 long count = blockSize - offset; 264 long count = blockSize - offset;
265 float **tmp = new float *[channelCount]; 265 float **tmp = new float *[channelCount];
266 for (size_t c = 0; c < channelCount; ++c) { 266 for (int c = 0; c < channelCount; ++c) {
267 tmp[c] = outbufs[c] + offset; 267 tmp[c] = outbufs[c] + offset;
268 } 268 }
269 wwfm->addSamples(tmp, count); 269 wwfm->addSamples(tmp, count);
270 delete[] tmp; 270 delete[] tmp;
271 } 271 }