Mercurial > hg > sonic-visualiser
comparison audioio/AudioCallbackPlaySource.cpp @ 139:ee977f93f66c
* Fix #1709968 replacement for file with derived models plays at wrong rate
author | Chris Cannam |
---|---|
date | Mon, 30 Apr 2007 14:28:47 +0000 |
parents | 006c90387f40 |
children | 0c22273a1d8c |
comparison
equal
deleted
inserted
replaced
138:834ff910e3d2 | 139:ee977f93f66c |
---|---|
20 #include "data/model/Model.h" | 20 #include "data/model/Model.h" |
21 #include "view/ViewManager.h" | 21 #include "view/ViewManager.h" |
22 #include "base/PlayParameterRepository.h" | 22 #include "base/PlayParameterRepository.h" |
23 #include "base/Preferences.h" | 23 #include "base/Preferences.h" |
24 #include "data/model/DenseTimeValueModel.h" | 24 #include "data/model/DenseTimeValueModel.h" |
25 #include "data/model/WaveFileModel.h" | |
25 #include "data/model/SparseOneDimensionalModel.h" | 26 #include "data/model/SparseOneDimensionalModel.h" |
26 #include "plugin/RealTimePluginInstance.h" | 27 #include "plugin/RealTimePluginInstance.h" |
27 #include "PhaseVocoderTimeStretcher.h" | 28 #include "PhaseVocoderTimeStretcher.h" |
28 | 29 |
29 #include <iostream> | 30 #include <iostream> |
144 | 145 |
145 bool conflicting = false; | 146 bool conflicting = false; |
146 | 147 |
147 for (std::set<Model *>::const_iterator i = m_models.begin(); | 148 for (std::set<Model *>::const_iterator i = m_models.begin(); |
148 i != m_models.end(); ++i) { | 149 i != m_models.end(); ++i) { |
149 DenseTimeValueModel *dtvm2 = | 150 // Only wave file models can be considered conflicting -- |
150 dynamic_cast<DenseTimeValueModel *>(*i); | 151 // writable wave file models are derived and we shouldn't |
151 if (dtvm2 && dtvm2 != dtvm && | 152 // take their rates into account. Also, don't give any |
152 dtvm2->getSampleRate() != model->getSampleRate()) { | 153 // particular weight to a file that's already playing at |
153 std::cerr << "AudioCallbackPlaySource::addModel: Conflicting dense time-value model " << *i << " found" << std::endl; | 154 // the wrong rate anyway |
155 WaveFileModel *wfm = dynamic_cast<WaveFileModel *>(*i); | |
156 if (wfm && wfm != dtvm && | |
157 wfm->getSampleRate() != model->getSampleRate() && | |
158 wfm->getSampleRate() == m_sourceSampleRate) { | |
159 std::cerr << "AudioCallbackPlaySource::addModel: Conflicting wave file model " << *i << " found" << std::endl; | |
154 conflicting = true; | 160 conflicting = true; |
155 break; | 161 break; |
156 } | 162 } |
157 } | 163 } |
158 | 164 |
163 << "existing model(s) (new " << model->getSampleRate() | 169 << "existing model(s) (new " << model->getSampleRate() |
164 << " vs " << m_sourceSampleRate | 170 << " vs " << m_sourceSampleRate |
165 << "), playback will be wrong" | 171 << "), playback will be wrong" |
166 << std::endl; | 172 << std::endl; |
167 | 173 |
168 emit sampleRateMismatch(model->getSampleRate(), m_sourceSampleRate, | 174 emit sampleRateMismatch(model->getSampleRate(), |
175 m_sourceSampleRate, | |
169 false); | 176 false); |
170 } else { | 177 } else { |
171 m_sourceSampleRate = model->getSampleRate(); | 178 m_sourceSampleRate = model->getSampleRate(); |
172 srChanged = true; | 179 srChanged = true; |
173 } | 180 } |