Mercurial > hg > svapp
comparison align/Align.h @ 778:83a7b10b7415
Merge from branch pitch-align
author | Chris Cannam |
---|---|
date | Fri, 26 Jun 2020 13:48:52 +0100 |
parents | 32e66fcc4cb7 |
children | b651dc5ff555 |
comparison
equal
deleted
inserted
replaced
774:7bded7599874 | 778:83a7b10b7415 |
---|---|
21 #include <QMutex> | 21 #include <QMutex> |
22 #include <set> | 22 #include <set> |
23 | 23 |
24 #include "Aligner.h" | 24 #include "Aligner.h" |
25 | 25 |
26 #include "transform/Transform.h" | |
27 | |
26 class AlignmentModel; | 28 class AlignmentModel; |
27 class Document; | 29 class Document; |
28 | 30 |
29 class Align : public QObject | 31 class Align : public QObject |
30 { | 32 { |
31 Q_OBJECT | 33 Q_OBJECT |
32 | 34 |
33 public: | 35 public: |
34 Align() { } | 36 Align() { } |
35 | 37 |
38 enum AlignmentType { | |
39 NoAlignment, | |
40 LinearAlignment, | |
41 TrimmedLinearAlignment, | |
42 MATCHAlignment, | |
43 MATCHAlignmentWithPitchCompare, | |
44 SungNoteContourAlignment, | |
45 TransformDrivenDTWAlignment, | |
46 ExternalProgramAlignment, | |
47 | |
48 LastAlignmentType = ExternalProgramAlignment | |
49 }; | |
50 | |
51 /** | |
52 * Convert an alignment type to a stable machine-readable string. | |
53 */ | |
54 static QString getAlignmentTypeTag(AlignmentType type); | |
55 | |
56 /** | |
57 * Convert an alignment type back from a stable machine-readable | |
58 * string. | |
59 */ | |
60 static AlignmentType getAlignmentTypeForTag(QString tag); | |
61 | |
62 /** | |
63 * Get the currently set alignment preference from the global | |
64 * application settings. If the returned preference is | |
65 * TransformDrivenDTWAlignment or ExternalProgramAlignment, then | |
66 * it will also be necessary to query | |
67 * getPreferredAlignmentTransform() or | |
68 * getPreferredAlignmentProgram() respectively in order to get the | |
69 * information needed to perform an alignment. | |
70 */ | |
71 static AlignmentType getAlignmentPreference(); | |
72 | |
73 /** | |
74 * Set the alignment preference to the global application | |
75 * settings. If the preference is TransformDrivenDTWAlignment or | |
76 * ExternalProgramAlignment, you may also wish to call | |
77 * setPreferredAlignmentTransform() or | |
78 * setPreferredAlignmentProgram() respectively. | |
79 */ | |
80 static void setAlignmentPreference(AlignmentType type); | |
81 | |
82 /** | |
83 * Get the external program associated with the | |
84 * ExternalProgramAlignment type, if any is set (an empty string | |
85 * otherwise). Note that this will return a value if any has ever | |
86 * been set, regardless of whether ExternalProgramAlignment is the | |
87 * currently chosen alignment type or not. | |
88 */ | |
89 static QString getPreferredAlignmentProgram(); | |
90 | |
91 /** | |
92 * Set the external program associated with the | |
93 * ExternalProgramAlignment type. It is not necessary for the | |
94 * current preferred alignment type actually to be | |
95 * ExternalProgramAlignment in order to change this setting. No | |
96 * validation is carried out on the argument - we don't verify | |
97 * that it actually is the path of a program, or anything else. | |
98 */ | |
99 static void setPreferredAlignmentProgram(QString program); | |
100 | |
101 /** | |
102 * Get the transform associated with the | |
103 * TransformDrivenDTWAlignment type, if any is set (a default | |
104 * constructed Transform otherwise). Note that this will return a | |
105 * value if any has ever been set, regardless of whether | |
106 * TransformDrivenDTWAlignment is the currently chosen alignment | |
107 * type or not. | |
108 */ | |
109 static Transform getPreferredAlignmentTransform(); | |
110 | |
111 /** | |
112 * Set the transform associated with the | |
113 * TransformDrivenDTWAlignment type. It is not necessary for the | |
114 * current preferred alignment type actually to be | |
115 * TransformDrivenDTWAlignment in order to change this setting. | |
116 */ | |
117 static void setPreferredAlignmentTransform(Transform transform); | |
118 | |
36 /** | 119 /** |
37 * Align the "other" model to the reference, attaching an | 120 * Align the "other" model to the reference, attaching an |
38 * AlignmentModel to it. Alignment is carried out by the method | 121 * AlignmentModel to it. Alignment is carried out by the method |
39 * configured in the user preferences (either a plugin transform | 122 * configured in the user preferences (see |
40 * or an external process) and is done asynchronously. | 123 * getAlignmentPreference() etc) and is done asynchronously. |
41 * | 124 * |
42 * Any errors are reported by firing the alignmentFailed | 125 * Any errors are reported by firing the alignmentFailed |
43 * signal. Note that the signal may be fired during the call to | 126 * signal. Note that the signal may be fired during the call to |
44 * this function, if the aligner fails to start at all. | 127 * this function, if the aligner fails to start at all. |
45 * | 128 * |
77 void scheduleAlignment(Document *doc, | 160 void scheduleAlignment(Document *doc, |
78 ModelId reference, | 161 ModelId reference, |
79 ModelId toAlign); | 162 ModelId toAlign); |
80 | 163 |
81 /** | 164 /** |
82 * Return true if the alignment facility is available (relevant | 165 * Return true if the preferred alignment facility is available |
83 * plugin installed, etc). | 166 * (relevant plugin installed, etc). |
84 */ | 167 */ |
85 static bool canAlign(); | 168 static bool canAlign(); |
86 | 169 |
87 signals: | 170 signals: |
88 /** | 171 /** |
109 // although we can calculate alignments with different references, | 192 // although we can calculate alignments with different references, |
110 // we can only have one alignment on any given toAlign model, so | 193 // we can only have one alignment on any given toAlign model, so |
111 // we don't key this on the whole (reference, toAlign) pair | 194 // we don't key this on the whole (reference, toAlign) pair |
112 std::map<ModelId, std::shared_ptr<Aligner>> m_aligners; | 195 std::map<ModelId, std::shared_ptr<Aligner>> m_aligners; |
113 | 196 |
114 void addAligner(Document *doc, ModelId reference, ModelId toAlign); | 197 bool addAligner(Document *doc, ModelId reference, ModelId toAlign); |
115 void removeAligner(QObject *); | 198 void removeAligner(QObject *); |
116 | |
117 static void getAlignerPreference(bool &useProgram, QString &program); | |
118 }; | 199 }; |
119 | 200 |
120 #endif | 201 #endif |
121 | 202 |