Mercurial > hg > svapp
changeset 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 |
files | audioio/AudioCallbackPlaySource.cpp audioio/AudioGenerator.cpp audioio/AudioGenerator.h |
diffstat | 3 files changed, 18 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/audioio/AudioCallbackPlaySource.cpp Mon Jan 30 17:51:56 2006 +0000 +++ b/audioio/AudioCallbackPlaySource.cpp Thu Feb 02 16:10:19 2006 +0000 @@ -80,6 +80,8 @@ void AudioCallbackPlaySource::addModel(Model *model) { + m_audioGenerator->addModel(model); + m_mutex.lock(); m_models.insert(model); @@ -116,8 +118,6 @@ m_audioGenerator->setTargetChannelCount(modelChannels); } - m_audioGenerator->addModel(model); - if (!m_writeBuffers || (m_writeBuffers->size() < modelChannels)) { clearRingBuffers(true, modelChannels); buffersChanged = true; @@ -172,10 +172,10 @@ } m_lastModelEndFrame = lastEnd; + m_mutex.unlock(); + m_audioGenerator->removeModel(model); - m_mutex.unlock(); - clearRingBuffers(); } @@ -193,11 +193,11 @@ m_lastModelEndFrame = 0; - m_audioGenerator->clearModels(); - m_sourceSampleRate = 0; m_mutex.unlock(); + + m_audioGenerator->clearModels(); } void @@ -224,7 +224,7 @@ if (!haveLock) { m_mutex.unlock(); - m_condition.wakeAll(); +//!!! m_condition.wakeAll(); } }
--- 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;
--- a/audioio/AudioGenerator.h Mon Jan 30 17:51:56 2006 +0000 +++ b/audioio/AudioGenerator.h Thu Feb 02 16:10:19 2006 +0000 @@ -16,6 +16,8 @@ class SparseOneDimensionalModel; class RealTimePluginInstance; +#include <QMutex> + #include <set> #include <map> @@ -88,6 +90,7 @@ typedef std::set<NoteOff, NoteOff::Comparator> NoteOffSet; typedef std::map<SparseOneDimensionalModel *, NoteOffSet> NoteOffMap; + QMutex m_mutex; PluginMap m_synthMap; NoteOffMap m_noteOffs;