Chris@420
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@420
|
2
|
Chris@420
|
3 /*
|
Chris@420
|
4 Sonic Visualiser
|
Chris@420
|
5 An audio file viewer and annotation editor.
|
Chris@420
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@420
|
7 This file copyright 2006 Chris Cannam and QMUL.
|
Chris@420
|
8
|
Chris@420
|
9 This program is free software; you can redistribute it and/or
|
Chris@420
|
10 modify it under the terms of the GNU General Public License as
|
Chris@420
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@420
|
12 License, or (at your option) any later version. See the file
|
Chris@420
|
13 COPYING included with this distribution for more information.
|
Chris@420
|
14 */
|
Chris@420
|
15
|
Chris@420
|
16 #ifndef ALIGN_H
|
Chris@420
|
17 #define ALIGN_H
|
Chris@420
|
18
|
Chris@420
|
19 #include <QString>
|
Chris@423
|
20 #include <QObject>
|
Chris@423
|
21 #include <QProcess>
|
Chris@423
|
22 #include <set>
|
Chris@420
|
23
|
Chris@420
|
24 class Model;
|
Chris@423
|
25 class AlignmentModel;
|
Chris@664
|
26 class Document;
|
Chris@420
|
27
|
Chris@423
|
28 class Align : public QObject
|
Chris@420
|
29 {
|
Chris@423
|
30 Q_OBJECT
|
Chris@423
|
31
|
Chris@420
|
32 public:
|
Chris@420
|
33 Align() : m_error("") { }
|
Chris@420
|
34
|
Chris@423
|
35 /**
|
Chris@423
|
36 * Align the "other" model to the reference, attaching an
|
Chris@423
|
37 * AlignmentModel to it. Alignment is carried out by the method
|
Chris@423
|
38 * configured in the user preferences (either a plugin transform
|
Chris@423
|
39 * or an external process) and is done asynchronously.
|
Chris@423
|
40 *
|
Chris@423
|
41 * A single Align object may carry out many simultanous alignment
|
Chris@423
|
42 * calls -- you do not need to create a new Align object each
|
Chris@423
|
43 * time, nor to wait for an alignment to be complete before
|
Chris@423
|
44 * starting a new one.
|
Chris@423
|
45 *
|
Chris@423
|
46 * The Align object must survive after this call, for at least as
|
Chris@428
|
47 * long as the alignment takes. The usual expectation is that the
|
Chris@428
|
48 * Align object will simply share the process or document
|
Chris@428
|
49 * lifespan.
|
Chris@423
|
50 */
|
Chris@664
|
51 bool alignModel(Document *doc,
|
Chris@664
|
52 Model *reference,
|
Chris@664
|
53 Model *other); // via user preference
|
Chris@422
|
54
|
Chris@664
|
55 bool alignModelViaTransform(Document *doc,
|
Chris@664
|
56 Model *reference,
|
Chris@664
|
57 Model *other);
|
Chris@664
|
58
|
Chris@664
|
59 bool alignModelViaProgram(Document *doc,
|
Chris@664
|
60 Model *reference,
|
Chris@664
|
61 Model *other,
|
Chris@664
|
62 QString program);
|
Chris@420
|
63
|
Chris@428
|
64 /**
|
Chris@428
|
65 * Return true if the alignment facility is available (relevant
|
Chris@428
|
66 * plugin installed, etc).
|
Chris@428
|
67 */
|
Chris@428
|
68 static bool canAlign();
|
Chris@428
|
69
|
Chris@420
|
70 QString getError() const { return m_error; }
|
Chris@428
|
71
|
Chris@428
|
72 signals:
|
Chris@428
|
73 /**
|
Chris@428
|
74 * Emitted when an alignment is successfully completed. The
|
Chris@428
|
75 * reference and other models can be queried from the alignment
|
Chris@428
|
76 * model.
|
Chris@428
|
77 */
|
Chris@428
|
78 void alignmentComplete(AlignmentModel *alignment);
|
Chris@428
|
79
|
Chris@423
|
80 private slots:
|
Chris@428
|
81 void alignmentCompletionChanged();
|
Chris@423
|
82 void alignmentProgramFinished(int, QProcess::ExitStatus);
|
Chris@423
|
83
|
Chris@420
|
84 private:
|
Chris@428
|
85 static QString getAlignmentTransformName();
|
Chris@428
|
86
|
Chris@420
|
87 QString m_error;
|
Chris@423
|
88 std::map<QProcess *, AlignmentModel *> m_processModels;
|
Chris@420
|
89 };
|
Chris@420
|
90
|
Chris@420
|
91 #endif
|
Chris@420
|
92
|