svcore  1.9
AlignmentModel.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2007 QMUL.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef _ALIGNMENT_MODEL_H_
17 #define _ALIGNMENT_MODEL_H_
18 
19 #include "Model.h"
20 #include "PathModel.h"
21 #include "base/RealTime.h"
22 
23 #include <QString>
24 #include <QStringList>
25 
27 
28 class AlignmentModel : public Model
29 {
30  Q_OBJECT
31 
32 public:
33  AlignmentModel(Model *reference,
34  Model *aligned,
35  Model *inputModel, // probably an AggregateWaveModel; I take ownership
36  SparseTimeValueModel *path); // I take ownership
38 
39  virtual bool isOK() const;
40  virtual int getStartFrame() const;
41  virtual int getEndFrame() const;
42  virtual int getSampleRate() const;
43  virtual Model *clone() const;
44  virtual bool isReady(int *completion = 0) const;
45  virtual const ZoomConstraint *getZoomConstraint() const;
46 
47  QString getTypeName() const { return tr("Alignment"); }
48 
49  const Model *getReferenceModel() const;
50  const Model *getAlignedModel() const;
51 
52  int toReference(int frame) const;
53  int fromReference(int frame) const;
54 
55  void setPath(PathModel *path);
56 
57  virtual void toXml(QTextStream &stream,
58  QString indent = "",
59  QString extraAttributes = "") const;
60 
61 signals:
62  void modelChanged();
63  void modelChangedWithin(int startFrame, int endFrame);
64  void completionChanged();
65 
66 protected slots:
67  void pathChanged();
68  void pathChangedWithin(int startFrame, int endFrame);
69  void pathCompletionChanged();
70 
71 protected:
72  Model *m_reference; // I don't own this
73  Model *m_aligned; // I don't own this
74 
75  Model *m_inputModel; // I own this
76 
78  mutable PathModel *m_path; // I own this
79  mutable PathModel *m_reversePath; // I own this
82 
83  void constructPath() const;
84  void constructReversePath() const;
85 
86  int align(PathModel *path, int frame) const;
87 };
88 
89 #endif
void pathCompletionChanged()
virtual int getStartFrame() const
Return the first audio frame spanned by the model.
const Model * getAlignedModel() const
void completionChanged()
int fromReference(int frame) const
void setPath(PathModel *path)
virtual void toXml(QTextStream &stream, QString indent="", QString extraAttributes="") const
Stream this exportable object out to XML on a text stream.
virtual bool isOK() const
Return true if the model was constructed successfully.
int toReference(int frame) const
void modelChangedWithin(int startFrame, int endFrame)
void constructReversePath() const
void constructPath() const
QString getTypeName() const
Return the type of the model.
AlignmentModel(Model *reference, Model *aligned, Model *inputModel, SparseTimeValueModel *path)
void modelChanged()
PathModel * m_reversePath
Model is the base class for all data models that represent any sort of data on a time scale based on ...
Definition: Model.h:35
PathModel * m_path
Model * m_inputModel
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
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)
const Model * getReferenceModel() const
Model * m_reference
virtual int getSampleRate() const
Return the frame rate in frames per second.