diff audioio/AudioGenerator.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 2edc0757ca75
children b6dc944128da
line wrap: on
line diff
--- a/audioio/AudioGenerator.cpp	Mon Jan 30 17:51:56 2006 +0000
+++ b/audioio/AudioGenerator.cpp	Thu Feb 02 16:10:19 2006 +0000
@@ -79,6 +79,7 @@
 	(pluginId, 0, 0, m_sourceSampleRate, m_pluginBlockSize, m_targetChannelCount);
 
     if (instance) {
+	QMutexLocker locker(&m_mutex);
 	m_synthMap[sodm] = instance;
 	for (unsigned int i = 0; i < instance->getParameterCount(); ++i) {
 	    instance->setParameterValue(i, instance->getParameterDefault(i));
@@ -102,6 +103,8 @@
 	dynamic_cast<SparseOneDimensionalModel *>(model);
     if (!sodm) return; // nothing to do
 
+    QMutexLocker locker(&m_mutex);
+
     if (m_synthMap.find(sodm) == m_synthMap.end()) return;
 
     RealTimePluginInstance *instance = m_synthMap[sodm];
@@ -112,6 +115,7 @@
 void
 AudioGenerator::clearModels()
 {
+    QMutexLocker locker(&m_mutex);
     while (!m_synthMap.empty()) {
 	RealTimePluginInstance *instance = m_synthMap.begin()->second;
 	m_synthMap.erase(m_synthMap.begin());
@@ -122,6 +126,7 @@
 void
 AudioGenerator::reset()
 {
+    QMutexLocker locker(&m_mutex);
     for (PluginMap::iterator i = m_synthMap.begin(); i != m_synthMap.end(); ++i) {
 	if (i->second) {
 	    i->second->silence();
@@ -135,6 +140,7 @@
 void
 AudioGenerator::setTargetChannelCount(size_t targetChannelCount)
 {
+    QMutexLocker locker(&m_mutex);
     m_targetChannelCount = targetChannelCount;
 
     for (PluginMap::iterator i = m_synthMap.begin(); i != m_synthMap.end(); ++i) {
@@ -157,6 +163,8 @@
 	return frameCount;
     }
 
+    QMutexLocker locker(&m_mutex);
+
     PlayParameters *parameters = m_viewManager->getPlayParameters(model);
     if (!parameters) return frameCount;