annotate align/TransformDTWAligner.h @ 768:1b1960009be6 pitch-align

Provide callback for output preprocessing before DTW, use it for freq-pitch conversion; use direct setting of completion on alignment models instead of creating fake outputs for completion only
author Chris Cannam
date Fri, 22 May 2020 17:17:44 +0100
parents dd742e566e60
children 1d6cca5a5621
rev   line source
Chris@767 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@767 2
Chris@767 3 /*
Chris@767 4 Sonic Visualiser
Chris@767 5 An audio file viewer and annotation editor.
Chris@767 6 Centre for Digital Music, Queen Mary, University of London.
Chris@767 7
Chris@767 8 This program is free software; you can redistribute it and/or
Chris@767 9 modify it under the terms of the GNU General Public License as
Chris@767 10 published by the Free Software Foundation; either version 2 of the
Chris@767 11 License, or (at your option) any later version. See the file
Chris@767 12 COPYING included with this distribution for more information.
Chris@767 13 */
Chris@767 14
Chris@767 15 #ifndef SV_TRANSFORM_DTW_ALIGNER_H
Chris@767 16 #define SV_TRANSFORM_DTW_ALIGNER_H
Chris@767 17
Chris@767 18 #include "Aligner.h"
Chris@767 19
Chris@767 20 #include "transform/Transform.h"
Chris@767 21
Chris@768 22 #include <functional>
Chris@768 23
Chris@767 24 class AlignmentModel;
Chris@767 25 class Document;
Chris@767 26
Chris@767 27 class TransformDTWAligner : public Aligner
Chris@767 28 {
Chris@767 29 Q_OBJECT
Chris@767 30
Chris@767 31 public:
Chris@767 32 enum DTWType {
Chris@767 33 Magnitude,
Chris@767 34 RiseFall
Chris@767 35 };
Chris@767 36
Chris@767 37 TransformDTWAligner(Document *doc,
Chris@767 38 ModelId reference,
Chris@767 39 ModelId toAlign,
Chris@767 40 Transform transform,
Chris@767 41 DTWType dtwType);
Chris@768 42
Chris@768 43 TransformDTWAligner(Document *doc,
Chris@768 44 ModelId reference,
Chris@768 45 ModelId toAlign,
Chris@768 46 Transform transform,
Chris@768 47 DTWType dtwType,
Chris@768 48 std::function<double(double)> outputPreprocessor);
Chris@767 49
Chris@767 50 // Destroy the aligner, cleanly cancelling any ongoing alignment
Chris@767 51 ~TransformDTWAligner();
Chris@767 52
Chris@767 53 void begin() override;
Chris@767 54
Chris@767 55 static bool isAvailable();
Chris@767 56
Chris@767 57 private slots:
Chris@767 58 void completionChanged(ModelId);
Chris@767 59
Chris@767 60 private:
Chris@767 61 bool performAlignment();
Chris@767 62 bool performAlignmentMagnitude();
Chris@767 63 bool performAlignmentRiseFall();
Chris@767 64
Chris@767 65 Document *m_document;
Chris@767 66 ModelId m_reference;
Chris@767 67 ModelId m_toAlign;
Chris@767 68 ModelId m_referenceOutputModel;
Chris@767 69 ModelId m_toAlignOutputModel;
Chris@767 70 ModelId m_alignmentModel;
Chris@767 71 Transform m_transform;
Chris@767 72 DTWType m_dtwType;
Chris@767 73 bool m_incomplete;
Chris@768 74 std::function<double(double)> m_outputPreprocessor;
Chris@767 75 };
Chris@767 76
Chris@767 77 #endif