comparison audioio/AudioCallbackPlaySource.cpp @ 8:24b500216029

* Refactor sparse models. Previously the 1D and time-value models duplicated a lot of code; now there is a base class (SparseModel) templated on the stored point type, and the subclasses define point types with the necessary characteristics. * Add NoteModel, a new SparseModel subclass. * Reorganise local feature description display. Instead of asking the layer to draw its own, just query it for a textual description and draw that in Pane. Greatly simplifies this part of the layer code. * Add local feature descriptions to colour 3D plot and waveform layers. * Add pitch in MIDI-pitch-and-cents to spectrogram layer. * Give AudioGenerator its own mutex to shorten lock times in CallbackPlaySource. * Minor adjustments to layers menu &c
author Chris Cannam
date Thu, 02 Feb 2006 16:10:19 +0000
parents 3a41ba527b4a
children e71385792d9d
comparison
equal deleted inserted replaced
7:3a41ba527b4a 8:24b500216029
78 } 78 }
79 79
80 void 80 void
81 AudioCallbackPlaySource::addModel(Model *model) 81 AudioCallbackPlaySource::addModel(Model *model)
82 { 82 {
83 m_audioGenerator->addModel(model);
84
83 m_mutex.lock(); 85 m_mutex.lock();
84 86
85 m_models.insert(model); 87 m_models.insert(model);
86 if (model->getEndFrame() > m_lastModelEndFrame) { 88 if (model->getEndFrame() > m_lastModelEndFrame) {
87 m_lastModelEndFrame = model->getEndFrame(); 89 m_lastModelEndFrame = model->getEndFrame();
114 116
115 if (!m_writeBuffers || m_writeBuffers->size() < modelChannels) { 117 if (!m_writeBuffers || m_writeBuffers->size() < modelChannels) {
116 m_audioGenerator->setTargetChannelCount(modelChannels); 118 m_audioGenerator->setTargetChannelCount(modelChannels);
117 } 119 }
118 120
119 m_audioGenerator->addModel(model);
120
121 if (!m_writeBuffers || (m_writeBuffers->size() < modelChannels)) { 121 if (!m_writeBuffers || (m_writeBuffers->size() < modelChannels)) {
122 clearRingBuffers(true, modelChannels); 122 clearRingBuffers(true, modelChannels);
123 buffersChanged = true; 123 buffersChanged = true;
124 } else { 124 } else {
125 clearRingBuffers(true); 125 clearRingBuffers(true);
170 i != m_models.end(); ++i) { 170 i != m_models.end(); ++i) {
171 if ((*i)->getEndFrame() > lastEnd) lastEnd = (*i)->getEndFrame(); 171 if ((*i)->getEndFrame() > lastEnd) lastEnd = (*i)->getEndFrame();
172 } 172 }
173 m_lastModelEndFrame = lastEnd; 173 m_lastModelEndFrame = lastEnd;
174 174
175 m_mutex.unlock();
176
175 m_audioGenerator->removeModel(model); 177 m_audioGenerator->removeModel(model);
176
177 m_mutex.unlock();
178 178
179 clearRingBuffers(); 179 clearRingBuffers();
180 } 180 }
181 181
182 void 182 void
191 m_converter = 0; 191 m_converter = 0;
192 } 192 }
193 193
194 m_lastModelEndFrame = 0; 194 m_lastModelEndFrame = 0;
195 195
196 m_sourceSampleRate = 0;
197
198 m_mutex.unlock();
199
196 m_audioGenerator->clearModels(); 200 m_audioGenerator->clearModels();
197
198 m_sourceSampleRate = 0;
199
200 m_mutex.unlock();
201 } 201 }
202 202
203 void 203 void
204 AudioCallbackPlaySource::clearRingBuffers(bool haveLock, size_t count) 204 AudioCallbackPlaySource::clearRingBuffers(bool haveLock, size_t count)
205 { 205 {
222 std::cerr << "AudioCallbackPlaySource::clearRingBuffers: Created " 222 std::cerr << "AudioCallbackPlaySource::clearRingBuffers: Created "
223 << count << " write buffers" << std::endl; 223 << count << " write buffers" << std::endl;
224 224
225 if (!haveLock) { 225 if (!haveLock) {
226 m_mutex.unlock(); 226 m_mutex.unlock();
227 m_condition.wakeAll(); 227 //!!! m_condition.wakeAll();
228 } 228 }
229 } 229 }
230 230
231 void 231 void
232 AudioCallbackPlaySource::play(size_t startFrame) 232 AudioCallbackPlaySource::play(size_t startFrame)