Mercurial > hg > svcore
comparison transform/RealTimeEffectModelTransformer.cpp @ 1039:b14064bd1f97 cxx11
This code now compiles. Main problem: sample rate types
author | Chris Cannam |
---|---|
date | Tue, 03 Mar 2015 17:09:19 +0000 |
parents | d5404b8421b4 |
children | a1cd5abcb38b |
comparison
equal
deleted
inserted
replaced
1038:cc27f35aa75c | 1039:b14064bd1f97 |
---|---|
80 return; | 80 return; |
81 } | 81 } |
82 | 82 |
83 if (m_outputNo == -1) { | 83 if (m_outputNo == -1) { |
84 | 84 |
85 int outputChannels = m_plugin->getAudioOutputCount(); | 85 int outputChannels = (int)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 |
139 | 139 |
140 int sampleRate = input->getSampleRate(); | 140 int sampleRate = input->getSampleRate(); |
141 int 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 sv_frame_t blockSize = m_plugin->getBufferSize(); |
145 | 145 |
146 float **inbufs = m_plugin->getAudioInputBuffers(); | 146 float **inbufs = m_plugin->getAudioInputBuffers(); |
147 | 147 |
148 long startFrame = m_input.getModel()->getStartFrame(); | 148 sv_frame_t startFrame = m_input.getModel()->getStartFrame(); |
149 long endFrame = m_input.getModel()->getEndFrame(); | 149 sv_frame_t endFrame = m_input.getModel()->getEndFrame(); |
150 | 150 |
151 Transform transform = m_transforms[0]; | 151 Transform transform = m_transforms[0]; |
152 | 152 |
153 RealTime contextStartRT = transform.getStartTime(); | 153 RealTime contextStartRT = transform.getStartTime(); |
154 RealTime contextDurationRT = transform.getDuration(); | 154 RealTime contextDurationRT = transform.getDuration(); |
155 | 155 |
156 long contextStart = | 156 sv_frame_t contextStart = |
157 RealTime::realTime2Frame(contextStartRT, sampleRate); | 157 RealTime::realTime2Frame(contextStartRT, sampleRate); |
158 | 158 |
159 long contextDuration = | 159 sv_frame_t contextDuration = |
160 RealTime::realTime2Frame(contextDurationRT, sampleRate); | 160 RealTime::realTime2Frame(contextDurationRT, sampleRate); |
161 | 161 |
162 if (contextStart == 0 || contextStart < startFrame) { | 162 if (contextStart == 0 || contextStart < startFrame) { |
163 contextStart = startFrame; | 163 contextStart = startFrame; |
164 } | 164 } |
172 | 172 |
173 if (wwfm) { | 173 if (wwfm) { |
174 wwfm->setStartFrame(contextStart); | 174 wwfm->setStartFrame(contextStart); |
175 } | 175 } |
176 | 176 |
177 long blockFrame = contextStart; | 177 sv_frame_t blockFrame = contextStart; |
178 | 178 |
179 long prevCompletion = 0; | 179 int prevCompletion = 0; |
180 | 180 |
181 long latency = m_plugin->getLatency(); | 181 sv_frame_t latency = m_plugin->getLatency(); |
182 | 182 |
183 while (blockFrame < contextStart + contextDuration + latency && | 183 while (blockFrame < contextStart + contextDuration + latency && |
184 !m_abandoned) { | 184 !m_abandoned) { |
185 | 185 |
186 long completion = | 186 int completion = int |
187 (((blockFrame - contextStart) / blockSize) * 99) / | 187 ((((blockFrame - contextStart) / blockSize) * 99) / |
188 (1 + ((contextDuration) / blockSize)); | 188 (1 + ((contextDuration) / blockSize))); |
189 | 189 |
190 long got = 0; | 190 sv_frame_t got = 0; |
191 | 191 |
192 if (channelCount == 1) { | 192 if (channelCount == 1) { |
193 if (inbufs && inbufs[0]) { | 193 if (inbufs && inbufs[0]) { |
194 got = input->getData | 194 got = input->getData |
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 for (int ch = 1; ch < (int)m_plugin->getAudioInputCount(); ++ch) { | 199 for (int ch = 1; ch < (int)m_plugin->getAudioInputCount(); ++ch) { |
200 for (long i = 0; i < blockSize; ++i) { | 200 for (sv_frame_t i = 0; i < blockSize; ++i) { |
201 inbufs[ch][i] = inbufs[0][i]; | 201 inbufs[ch][i] = inbufs[0][i]; |
202 } | 202 } |
203 } | 203 } |
204 } | 204 } |
205 } else { | 205 } else { |
212 inbufs[ch][got] = 0.0; | 212 inbufs[ch][got] = 0.0; |
213 } | 213 } |
214 ++got; | 214 ++got; |
215 } | 215 } |
216 for (int ch = channelCount; ch < (int)m_plugin->getAudioInputCount(); ++ch) { | 216 for (int ch = channelCount; ch < (int)m_plugin->getAudioInputCount(); ++ch) { |
217 for (long i = 0; i < blockSize; ++i) { | 217 for (sv_frame_t i = 0; i < blockSize; ++i) { |
218 inbufs[ch][i] = inbufs[ch % channelCount][i]; | 218 inbufs[ch][i] = inbufs[ch % channelCount][i]; |
219 } | 219 } |
220 } | 220 } |
221 } | 221 } |
222 } | 222 } |
239 | 239 |
240 if (stvm) { | 240 if (stvm) { |
241 | 241 |
242 float value = m_plugin->getControlOutputValue(m_outputNo); | 242 float value = m_plugin->getControlOutputValue(m_outputNo); |
243 | 243 |
244 long pointFrame = blockFrame; | 244 sv_frame_t pointFrame = blockFrame; |
245 if (pointFrame > latency) pointFrame -= latency; | 245 if (pointFrame > latency) pointFrame -= latency; |
246 else pointFrame = 0; | 246 else pointFrame = 0; |
247 | 247 |
248 stvm->addPoint(SparseTimeValueModel::Point | 248 stvm->addPoint(SparseTimeValueModel::Point |
249 (pointFrame, value, "")); | 249 (pointFrame, value, "")); |
253 float **outbufs = m_plugin->getAudioOutputBuffers(); | 253 float **outbufs = m_plugin->getAudioOutputBuffers(); |
254 | 254 |
255 if (outbufs) { | 255 if (outbufs) { |
256 | 256 |
257 if (blockFrame >= latency) { | 257 if (blockFrame >= latency) { |
258 long writeSize = std::min | 258 sv_frame_t writeSize = std::min |
259 (blockSize, | 259 (blockSize, |
260 contextStart + contextDuration + latency - blockFrame); | 260 contextStart + contextDuration + latency - blockFrame); |
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 sv_frame_t offset = latency - blockFrame; |
264 long count = blockSize - offset; | 264 sv_frame_t count = blockSize - offset; |
265 float **tmp = new float *[channelCount]; | 265 float **tmp = new float *[channelCount]; |
266 for (int 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); |