Mercurial > hg > svapp
comparison audioio/AudioGenerator.cpp @ 351:36efd75d7b7b tonioni
Merge from default branch
author | Chris Cannam |
---|---|
date | Wed, 14 May 2014 09:58:27 +0100 |
parents | 8d7f39df44ed |
children | 0876ea394902 |
comparison
equal
deleted
inserted
replaced
344:63dec7dc11cc | 351:36efd75d7b7b |
---|---|
46 //#define DEBUG_AUDIO_GENERATOR 1 | 46 //#define DEBUG_AUDIO_GENERATOR 1 |
47 | 47 |
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 { | 53 { |
54 initialiseSampleDir(); | 54 initialiseSampleDir(); |
55 | 55 |
56 connect(PlayParameterRepository::getInstance(), | 56 connect(PlayParameterRepository::getInstance(), |
171 qobject_cast<const FlexiNoteModel *>(model)); | 171 qobject_cast<const FlexiNoteModel *>(model)); |
172 return clip; | 172 return clip; |
173 } | 173 } |
174 | 174 |
175 bool | 175 bool |
176 AudioGenerator::wantsQuieterClips(const Model *model) | |
177 { | |
178 // basically, anything that usually has sustain (like notes) or | |
179 // often has multiple sounds at once (like notes) wants to use a | |
180 // quieter level than simple click tracks | |
181 bool does = | |
182 (qobject_cast<const NoteModel *>(model) || | |
183 qobject_cast<const FlexiNoteModel *>(model)); | |
184 return does; | |
185 } | |
186 | |
187 bool | |
176 AudioGenerator::usesContinuousSynth(const Model *model) | 188 AudioGenerator::usesContinuousSynth(const Model *model) |
177 { | 189 { |
178 bool cont = | 190 bool cont = |
179 (qobject_cast<const SparseTimeValueModel *>(model)); | 191 (qobject_cast<const SparseTimeValueModel *>(model)); |
180 return cont; | 192 return cont; |
207 | 219 |
208 float clipF0 = Pitch::getFrequencyForPitch(60, 0, 440.0f); // required | 220 float clipF0 = Pitch::getFrequencyForPitch(60, 0, 440.0f); // required |
209 | 221 |
210 QString clipPath = QString("%1/%2.wav").arg(m_sampleDir).arg(clipId); | 222 QString clipPath = QString("%1/%2.wav").arg(m_sampleDir).arg(clipId); |
211 | 223 |
212 if (!mixer->loadClipData(clipPath, clipF0)) { | 224 float level = wantsQuieterClips(model) ? 0.5 : 1.0; |
225 if (!mixer->loadClipData(clipPath, clipF0, level)) { | |
213 delete mixer; | 226 delete mixer; |
214 return 0; | 227 return 0; |
215 } | 228 } |
216 | 229 |
217 std::cerr << "AudioGenerator::makeClipMixerFor(" << model << "): loaded clip " << clipId << std::endl; | 230 std::cerr << "AudioGenerator::makeClipMixerFor(" << model << "): loaded clip " << clipId << std::endl; |
549 on.frequency = ni->getFrequency(); | 562 on.frequency = ni->getFrequency(); |
550 on.level = float(ni->velocity) / 127.0; | 563 on.level = float(ni->velocity) / 127.0; |
551 on.pan = pan; | 564 on.pan = pan; |
552 | 565 |
553 #ifdef DEBUG_AUDIO_GENERATOR | 566 #ifdef DEBUG_AUDIO_GENERATOR |
554 cout << "mixModel [clip]: adding note at frame " << noteFrame << ", frame offset " << on.frameOffset << " frequency " << on.frequency << endl; | 567 cout << "mixModel [clip]: adding note at frame " << noteFrame << ", frame offset " << on.frameOffset << " frequency " << on.frequency << ", level " << on.level << endl; |
555 #endif | 568 #endif |
556 | 569 |
557 starts.push_back(on); | 570 starts.push_back(on); |
558 noteOffs.insert | 571 noteOffs.insert |
559 (NoteOff(on.frequency, noteFrame + ni->duration)); | 572 (NoteOff(on.frequency, noteFrame + ni->duration)); |