comparison audioio/AudioGenerator.cpp @ 309:71050ffd0141 tonioni

sampleId -> clipId
author Chris Cannam
date Tue, 07 Jan 2014 15:52:47 +0000
parents 289d65722123
children 58582119c92a
comparison
equal deleted inserted replaced
308:289d65722123 309:71050ffd0141
49 m_soloing(false) 49 m_soloing(false)
50 { 50 {
51 initialiseSampleDir(); 51 initialiseSampleDir();
52 52
53 connect(PlayParameterRepository::getInstance(), 53 connect(PlayParameterRepository::getInstance(),
54 SIGNAL(playSampleIdChanged(const Playable *, QString)), 54 SIGNAL(playClipIdChanged(const Playable *, QString)),
55 this, 55 this,
56 SLOT(playSampleIdChanged(const Playable *, QString))); 56 SLOT(playClipIdChanged(const Playable *, QString)));
57 } 57 }
58 58
59 AudioGenerator::~AudioGenerator() 59 AudioGenerator::~AudioGenerator()
60 { 60 {
61 #ifdef DEBUG_AUDIO_GENERATOR 61 #ifdef DEBUG_AUDIO_GENERATOR
127 127
128 return false; 128 return false;
129 } 129 }
130 130
131 void 131 void
132 AudioGenerator::playSampleIdChanged(const Playable *playable, QString) 132 AudioGenerator::playClipIdChanged(const Playable *playable, QString)
133 { 133 {
134 const Model *model = dynamic_cast<const Model *>(playable); 134 const Model *model = dynamic_cast<const Model *>(playable);
135 if (!model) { 135 if (!model) {
136 cerr << "WARNING: AudioGenerator::playSampleIdChanged: playable " 136 cerr << "WARNING: AudioGenerator::playClipIdChanged: playable "
137 << playable << " is not a supported model type" 137 << playable << " is not a supported model type"
138 << endl; 138 << endl;
139 return; 139 return;
140 } 140 }
141 141
155 { 155 {
156 // SVDEBUG << "AudioGenerator::playPluginConfigurationChanged" << endl; 156 // SVDEBUG << "AudioGenerator::playPluginConfigurationChanged" << endl;
157 157
158 const Model *model = dynamic_cast<const Model *>(playable); 158 const Model *model = dynamic_cast<const Model *>(playable);
159 if (!model) { 159 if (!model) {
160 cerr << "WARNING: AudioGenerator::playSampleIdChanged: playable " 160 cerr << "WARNING: AudioGenerator::playClipIdChanged: playable "
161 << playable << " is not a supported model type" 161 << playable << " is not a supported model type"
162 << endl; 162 << endl;
163 return; 163 return;
164 } 164 }
165 165
183 } 183 }
184 */ 184 */
185 ClipMixer * 185 ClipMixer *
186 AudioGenerator::makeClipMixerFor(const Model *model) 186 AudioGenerator::makeClipMixerFor(const Model *model)
187 { 187 {
188 QString sampleId; 188 QString clipId;
189 189
190 const Playable *playable = model; 190 const Playable *playable = model;
191 if (!playable || !playable->canPlay()) return 0; 191 if (!playable || !playable->canPlay()) return 0;
192 192
193 PlayParameters *parameters = 193 PlayParameters *parameters =
194 PlayParameterRepository::getInstance()->getPlayParameters(playable); 194 PlayParameterRepository::getInstance()->getPlayParameters(playable);
195 if (parameters) { 195 if (parameters) {
196 sampleId = parameters->getPlaySampleId(); 196 clipId = parameters->getPlayClipId();
197 } 197 }
198 198
199 std::cerr << "AudioGenerator::makeClipMixerFor(" << model << "): sample id = " << sampleId << std::endl; 199 std::cerr << "AudioGenerator::makeClipMixerFor(" << model << "): sample id = " << clipId << std::endl;
200 200
201 if (sampleId == "") { 201 if (clipId == "") {
202 SVDEBUG << "AudioGenerator::makeClipMixerFor(" << model << "): no sample, skipping" << endl; 202 SVDEBUG << "AudioGenerator::makeClipMixerFor(" << model << "): no sample, skipping" << endl;
203 return 0; 203 return 0;
204 } 204 }
205 205
206 ClipMixer *mixer = new ClipMixer(m_targetChannelCount, 206 ClipMixer *mixer = new ClipMixer(m_targetChannelCount,
207 m_sourceSampleRate, 207 m_sourceSampleRate,
208 m_processingBlockSize); 208 m_processingBlockSize);
209 209
210 float clipF0 = Pitch::getFrequencyForPitch(60, 0, 440.0f); // required 210 float clipF0 = Pitch::getFrequencyForPitch(60, 0, 440.0f); // required
211 211
212 QString clipPath = QString("%1/%2.wav").arg(m_sampleDir).arg(sampleId); 212 QString clipPath = QString("%1/%2.wav").arg(m_sampleDir).arg(clipId);
213 213
214 if (!mixer->loadClipData(clipPath, clipF0)) { 214 if (!mixer->loadClipData(clipPath, clipF0)) {
215 delete mixer; 215 delete mixer;
216 return 0; 216 return 0;
217 } 217 }
218 218
219 std::cerr << "AudioGenerator::makeClipMixerFor(" << model << "): loaded clip " << sampleId << std::endl; 219 std::cerr << "AudioGenerator::makeClipMixerFor(" << model << "): loaded clip " << clipId << std::endl;
220 220
221 return mixer; 221 return mixer;
222 } 222 }
223 223
224 void 224 void