Mercurial > hg > svapp
comparison 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 |
comparison
equal
deleted
inserted
replaced
7:3a41ba527b4a | 8:24b500216029 |
---|---|
77 RealTimePluginInstance *instance = | 77 RealTimePluginInstance *instance = |
78 factory->instantiatePlugin | 78 factory->instantiatePlugin |
79 (pluginId, 0, 0, m_sourceSampleRate, m_pluginBlockSize, m_targetChannelCount); | 79 (pluginId, 0, 0, m_sourceSampleRate, m_pluginBlockSize, m_targetChannelCount); |
80 | 80 |
81 if (instance) { | 81 if (instance) { |
82 QMutexLocker locker(&m_mutex); | |
82 m_synthMap[sodm] = instance; | 83 m_synthMap[sodm] = instance; |
83 for (unsigned int i = 0; i < instance->getParameterCount(); ++i) { | 84 for (unsigned int i = 0; i < instance->getParameterCount(); ++i) { |
84 instance->setParameterValue(i, instance->getParameterDefault(i)); | 85 instance->setParameterValue(i, instance->getParameterDefault(i)); |
85 } | 86 } |
86 QString program = instance->getProgram(0, 0); | 87 QString program = instance->getProgram(0, 0); |
100 { | 101 { |
101 SparseOneDimensionalModel *sodm = | 102 SparseOneDimensionalModel *sodm = |
102 dynamic_cast<SparseOneDimensionalModel *>(model); | 103 dynamic_cast<SparseOneDimensionalModel *>(model); |
103 if (!sodm) return; // nothing to do | 104 if (!sodm) return; // nothing to do |
104 | 105 |
106 QMutexLocker locker(&m_mutex); | |
107 | |
105 if (m_synthMap.find(sodm) == m_synthMap.end()) return; | 108 if (m_synthMap.find(sodm) == m_synthMap.end()) return; |
106 | 109 |
107 RealTimePluginInstance *instance = m_synthMap[sodm]; | 110 RealTimePluginInstance *instance = m_synthMap[sodm]; |
108 m_synthMap.erase(sodm); | 111 m_synthMap.erase(sodm); |
109 delete instance; | 112 delete instance; |
110 } | 113 } |
111 | 114 |
112 void | 115 void |
113 AudioGenerator::clearModels() | 116 AudioGenerator::clearModels() |
114 { | 117 { |
118 QMutexLocker locker(&m_mutex); | |
115 while (!m_synthMap.empty()) { | 119 while (!m_synthMap.empty()) { |
116 RealTimePluginInstance *instance = m_synthMap.begin()->second; | 120 RealTimePluginInstance *instance = m_synthMap.begin()->second; |
117 m_synthMap.erase(m_synthMap.begin()); | 121 m_synthMap.erase(m_synthMap.begin()); |
118 delete instance; | 122 delete instance; |
119 } | 123 } |
120 } | 124 } |
121 | 125 |
122 void | 126 void |
123 AudioGenerator::reset() | 127 AudioGenerator::reset() |
124 { | 128 { |
129 QMutexLocker locker(&m_mutex); | |
125 for (PluginMap::iterator i = m_synthMap.begin(); i != m_synthMap.end(); ++i) { | 130 for (PluginMap::iterator i = m_synthMap.begin(); i != m_synthMap.end(); ++i) { |
126 if (i->second) { | 131 if (i->second) { |
127 i->second->silence(); | 132 i->second->silence(); |
128 i->second->discardEvents(); | 133 i->second->discardEvents(); |
129 } | 134 } |
133 } | 138 } |
134 | 139 |
135 void | 140 void |
136 AudioGenerator::setTargetChannelCount(size_t targetChannelCount) | 141 AudioGenerator::setTargetChannelCount(size_t targetChannelCount) |
137 { | 142 { |
143 QMutexLocker locker(&m_mutex); | |
138 m_targetChannelCount = targetChannelCount; | 144 m_targetChannelCount = targetChannelCount; |
139 | 145 |
140 for (PluginMap::iterator i = m_synthMap.begin(); i != m_synthMap.end(); ++i) { | 146 for (PluginMap::iterator i = m_synthMap.begin(); i != m_synthMap.end(); ++i) { |
141 if (i->second) i->second->setIdealChannelCount(targetChannelCount); | 147 if (i->second) i->second->setIdealChannelCount(targetChannelCount); |
142 } | 148 } |
154 { | 160 { |
155 if (m_sourceSampleRate == 0) { | 161 if (m_sourceSampleRate == 0) { |
156 std::cerr << "WARNING: AudioGenerator::mixModel: No base source sample rate available" << std::endl; | 162 std::cerr << "WARNING: AudioGenerator::mixModel: No base source sample rate available" << std::endl; |
157 return frameCount; | 163 return frameCount; |
158 } | 164 } |
165 | |
166 QMutexLocker locker(&m_mutex); | |
159 | 167 |
160 PlayParameters *parameters = m_viewManager->getPlayParameters(model); | 168 PlayParameters *parameters = m_viewManager->getPlayParameters(model); |
161 if (!parameters) return frameCount; | 169 if (!parameters) return frameCount; |
162 | 170 |
163 bool playing = !parameters->isPlayMuted(); | 171 bool playing = !parameters->isPlayMuted(); |