26 m_reference(reference),
28 m_inputModel(inputModel),
82 return std::min(a, b);
90 return std::max(a, b);
112 if (completion) *completion = 0;
116 if (completion) *completion = 100;
143 #ifdef DEBUG_ALIGNMENT_MODEL 144 SVDEBUG <<
"AlignmentModel::toReference(" << frame <<
")" << endl;
156 #ifdef DEBUG_ALIGNMENT_MODEL 157 SVDEBUG <<
"AlignmentModel::fromReference(" << frame <<
")" << endl;
170 cerr <<
"AlignmentModel: deleting raw path model" << endl;
196 #ifdef DEBUG_ALIGNMENT_MODEL 197 SVDEBUG <<
"AlignmentModel::pathCompletionChanged: completion = " 198 << completion << endl;
222 cerr <<
"ERROR: AlignmentModel::constructPath: " 223 <<
"No raw path available" << endl;
236 for (SparseTimeValueModel::PointList::const_iterator i = points.begin();
237 i != points.end(); ++i) {
238 long frame = i->frame;
239 float value = i->value;
244 #ifdef DEBUG_ALIGNMENT_MODEL 254 cerr <<
"ERROR: AlignmentModel::constructReversePath: " 255 <<
"No forward path available" << endl;
268 for (PathModel::PointList::const_iterator i = points.begin();
269 i != points.end(); ++i) {
270 long frame = i->frame;
271 long rframe = i->mapframe;
275 #ifdef DEBUG_ALIGNMENT_MODEL 283 if (!path)
return frame;
292 if (points.empty()) {
293 #ifdef DEBUG_ALIGNMENT_MODEL 294 SVDEBUG <<
"AlignmentModel::align: No points" << endl;
299 #ifdef DEBUG_ALIGNMENT_MODEL 300 SVDEBUG <<
"AlignmentModel::align: frame " << frame <<
" requested" << endl;
304 PathModel::PointList::const_iterator i = points.lower_bound(point);
305 if (i == points.end()) {
306 #ifdef DEBUG_ALIGNMENT_MODEL 307 cerr <<
"Note: i == points.end()" << endl;
311 while (i != points.begin() && i->frame > long(frame)) --i;
313 long foundFrame = i->frame;
314 long foundMapFrame = i->mapframe;
316 long followingFrame = foundFrame;
317 long followingMapFrame = foundMapFrame;
319 if (++i != points.end()) {
320 #ifdef DEBUG_ALIGNMENT_MODEL 321 cerr <<
"another point available" << endl;
323 followingFrame = i->frame;
324 followingMapFrame = i->mapframe;
326 #ifdef DEBUG_ALIGNMENT_MODEL 327 cerr <<
"no other point available" << endl;
331 if (foundMapFrame < 0)
return 0;
333 int resultFrame = foundMapFrame;
335 if (followingFrame != foundFrame &&
long(frame) > foundFrame) {
337 float(frame - foundFrame) /
338 float(followingFrame - foundFrame);
339 resultFrame += lrintf((followingMapFrame - foundMapFrame) * interp);
342 #ifdef DEBUG_ALIGNMENT_MODEL 343 SVDEBUG <<
"AlignmentModel::align: resultFrame = " << resultFrame << endl;
355 #ifdef DEBUG_ALIGNMENT_MODEL 356 SVDEBUG <<
"AlignmentModel::setPath: path = " <<
m_path << endl;
359 #ifdef DEBUG_ALIGNMENT_MODEL 360 SVDEBUG <<
"AlignmentModel::setPath: after construction path = " 368 QString extraAttributes)
const 371 SVDEBUG <<
"AlignmentModel::toXml: no path" << endl;
378 QString(
"type=\"alignment\" reference=\"%1\" aligned=\"%2\" path=\"%3\" %4")
382 .arg(extraAttributes));
virtual void toXml(QTextStream &out, QString indent="", QString extraAttributes="") const
Stream this exportable object out to XML on a text stream.
void pathCompletionChanged()
std::multiset< TimeValuePoint, typename TimeValuePoint ::OrderComparator > PointList
virtual int getStartFrame() const
Return the first audio frame spanned by the model.
const Model * getAlignedModel() const
int fromReference(int frame) const
virtual int getSampleRate() const
Return the frame rate in frames per second.
void setPath(PathModel *path)
virtual int getStartFrame() const =0
Return the first audio frame spanned by the model.
virtual void toXml(QTextStream &stream, QString indent="", QString extraAttributes="") const
Stream this exportable object out to XML on a text stream.
static int getObjectExportId(const void *)
virtual bool isOK() const
Return true if the model was constructed successfully.
int toReference(int frame) const
virtual void addPoint(const PointType &point)
Add a point.
virtual int getPointCount() const
Get the total number of points in the model.
void modelChangedWithin(int startFrame, int endFrame)
void constructReversePath() const
virtual void toXml(QTextStream &stream, QString indent="", QString extraAttributes="") const
Stream this exportable object out to XML on a text stream.
void constructPath() const
virtual Model * clone() const =0
Return a copy of this model.
virtual const PointList & getPoints() const
Get all points.
AlignmentModel(Model *reference, Model *aligned, Model *inputModel, SparseTimeValueModel *path)
PathModel * m_reversePath
virtual int getSampleRate() const =0
Return the frame rate in frames per second.
Model is the base class for all data models that represent any sort of data on a time scale based on ...
virtual bool isOK() const
Return true if the model was constructed successfully.
virtual void clear()
Remove all points.
virtual int getResolution() const
virtual bool isReady(int *completion=0) const
Return true if the model has finished loading or calculating all its data, for a model that is capabl...
virtual Model * clone() const
Return a copy of this model.
virtual int getEndFrame() const =0
Return the last audio frame spanned by the model.
virtual Model * clone() const
Return a copy of this model.
virtual int getEndFrame() const
Return the last audio frame spanned by the model.
virtual const ZoomConstraint * getZoomConstraint() const
If this model imposes a zoom constraint, i.e.
SparseTimeValueModel * m_rawPath
ZoomConstraint is a simple interface that describes a limitation on the available zoom sizes for a vi...
int align(PathModel *path, int frame) const
void pathChangedWithin(int startFrame, int endFrame)
virtual bool isReady(int *completion=0) const
Return true if the model has finished loading or calculating all its data, for a model that is capabl...
const Model * getReferenceModel() const
virtual int getSampleRate() const
Return the frame rate in frames per second.