]> git.sesse.net Git - kdenlive/blob - src/lib/audio/audioCorrelation.h
Use QLatin1String
[kdenlive] / src / lib / audio / audioCorrelation.h
1 /***************************************************************************
2  *   Copyright (C) 2012 by Simon Andreas Eugster (simon.eu@gmail.com)      *
3  *   This file is part of kdenlive. See www.kdenlive.org.                  *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  ***************************************************************************/
10
11 #ifndef AUDIOCORRELATION_H
12 #define AUDIOCORRELATION_H
13
14 #include "audioCorrelationInfo.h"
15 #include "audioEnvelope.h"
16 #include <QList>
17
18
19 /**
20   This class does the correlation between two tracks
21   in order to synchronize (align) them.
22
23   It uses one main track (used in the initializer); further tracks will be
24   aligned relative to this main track.
25   */
26 class AudioCorrelation
27 {
28 public:
29     /// AudioCorrelation will take ownership of mainTrackEnvelope
30     AudioCorrelation(AudioEnvelope *mainTrackEnvelope);
31     ~AudioCorrelation();
32
33     /**
34       This object will take ownership of the passed envelope.
35       \return The child's index
36       */
37     int addChild(AudioEnvelope *envelope, bool useFFT = false);
38
39     const AudioCorrelationInfo *info(int childIndex) const;
40     int getShift(int childIndex) const;
41
42     /**
43       Correlates the two vectors envMain and envSub.
44       \c correlation must be a pre-allocated vector of size sizeMain+sizeSub+1.
45       */
46     static void correlate(const int64_t *envMain, int sizeMain,
47                           const int64_t *envSub, int sizeSub,
48                           int64_t *correlation,
49                           int64_t *out_max = NULL);
50 private:
51     AudioEnvelope *m_mainTrackEnvelope;
52
53     QList<AudioEnvelope*> m_children;
54     QList<AudioCorrelationInfo*> m_correlations;
55 };
56
57 #endif // AUDIOCORRELATION_H