comparison audio/AudioGenerator.cpp @ 644:6fd0ebfd2bbe

Merge from branch fix-static-analysis
author Chris Cannam
date Wed, 09 Jan 2019 15:25:09 +0000
parents e2715204feaa
children 6240788893e7
comparison
equal deleted inserted replaced
643:713b9a6b284a 644:6fd0ebfd2bbe
48 AudioGenerator::AudioGenerator() : 48 AudioGenerator::AudioGenerator() :
49 m_sourceSampleRate(0), 49 m_sourceSampleRate(0),
50 m_targetChannelCount(1), 50 m_targetChannelCount(1),
51 m_waveType(0), 51 m_waveType(0),
52 m_soloing(false), 52 m_soloing(false),
53 m_channelBuffer(0), 53 m_channelBuffer(nullptr),
54 m_channelBufSiz(0), 54 m_channelBufSiz(0),
55 m_channelBufCount(0) 55 m_channelBufCount(0)
56 { 56 {
57 initialiseSampleDir(); 57 initialiseSampleDir();
58 58
214 AudioGenerator::makeClipMixerFor(const Model *model) 214 AudioGenerator::makeClipMixerFor(const Model *model)
215 { 215 {
216 QString clipId; 216 QString clipId;
217 217
218 const Playable *playable = model; 218 const Playable *playable = model;
219 if (!playable || !playable->canPlay()) return 0; 219 if (!playable || !playable->canPlay()) return nullptr;
220 220
221 PlayParameters *parameters = 221 PlayParameters *parameters =
222 PlayParameterRepository::getInstance()->getPlayParameters(playable); 222 PlayParameterRepository::getInstance()->getPlayParameters(playable);
223 if (parameters) { 223 if (parameters) {
224 clipId = parameters->getPlayClipId(); 224 clipId = parameters->getPlayClipId();
228 std::cerr << "AudioGenerator::makeClipMixerFor(" << model << "): sample id = " << clipId << std::endl; 228 std::cerr << "AudioGenerator::makeClipMixerFor(" << model << "): sample id = " << clipId << std::endl;
229 #endif 229 #endif
230 230
231 if (clipId == "") { 231 if (clipId == "") {
232 SVDEBUG << "AudioGenerator::makeClipMixerFor(" << model << "): no sample, skipping" << endl; 232 SVDEBUG << "AudioGenerator::makeClipMixerFor(" << model << "): no sample, skipping" << endl;
233 return 0; 233 return nullptr;
234 } 234 }
235 235
236 ClipMixer *mixer = new ClipMixer(m_targetChannelCount, 236 ClipMixer *mixer = new ClipMixer(m_targetChannelCount,
237 m_sourceSampleRate, 237 m_sourceSampleRate,
238 m_processingBlockSize); 238 m_processingBlockSize);
242 QString clipPath = QString("%1/%2.wav").arg(m_sampleDir).arg(clipId); 242 QString clipPath = QString("%1/%2.wav").arg(m_sampleDir).arg(clipId);
243 243
244 double level = wantsQuieterClips(model) ? 0.5 : 1.0; 244 double level = wantsQuieterClips(model) ? 0.5 : 1.0;
245 if (!mixer->loadClipData(clipPath, clipF0, level)) { 245 if (!mixer->loadClipData(clipPath, clipF0, level)) {
246 delete mixer; 246 delete mixer;
247 return 0; 247 return nullptr;
248 } 248 }
249 249
250 #ifdef DEBUG_AUDIO_GENERATOR 250 #ifdef DEBUG_AUDIO_GENERATOR
251 std::cerr << "AudioGenerator::makeClipMixerFor(" << model << "): loaded clip " << clipId << std::endl; 251 std::cerr << "AudioGenerator::makeClipMixerFor(" << model << "): loaded clip " << clipId << std::endl;
252 #endif 252 #endif
256 256
257 ContinuousSynth * 257 ContinuousSynth *
258 AudioGenerator::makeSynthFor(const Model *model) 258 AudioGenerator::makeSynthFor(const Model *model)
259 { 259 {
260 const Playable *playable = model; 260 const Playable *playable = model;
261 if (!playable || !playable->canPlay()) return 0; 261 if (!playable || !playable->canPlay()) return nullptr;
262 262
263 ContinuousSynth *synth = new ContinuousSynth(m_targetChannelCount, 263 ContinuousSynth *synth = new ContinuousSynth(m_targetChannelCount,
264 m_sourceSampleRate, 264 m_sourceSampleRate,
265 m_processingBlockSize, 265 m_processingBlockSize,
266 m_waveType); 266 m_waveType);