]> git.sesse.net Git - kdenlive/blob - src/lib/audio/audioEnvelope.h
Audio alignment libraries moved to src/lib/audio/
[kdenlive] / src / lib / audio / audioEnvelope.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 AUDIOENVELOPE_H
12 #define AUDIOENVELOPE_H
13
14 #include "audioInfo.h"
15 #include <mlt++/Mlt.h>
16
17 class QImage;
18
19 /**
20   The audio envelope is a simplified version of an audio track
21   with frame resolution. One entry is calculated by the sum
22   of the absolute values of all samples in the current frame.
23
24   See also: http://bemasc.net/wordpress/2011/07/26/an-auto-aligner-for-pitivi/
25   */
26 class AudioEnvelope
27 {
28 public:
29     AudioEnvelope(Mlt::Producer *producer);
30     ~AudioEnvelope();
31
32     /// Returns the envelope, calculates it if necessary.
33     int64_t const* envelope();
34     int envelopeSize() const;
35
36     void loadEnvelope();
37     int64_t loadStdDev();
38     void normalizeEnvelope(bool clampTo0 = false);
39
40     QImage drawEnvelope();
41
42     void dumpInfo() const;
43
44 private:
45     int64_t *m_envelope;
46     Mlt::Producer *m_producer;
47     AudioInfo *m_info;
48
49     int m_envelopeSize;
50     int64_t m_envelopeMax;
51     int64_t m_envelopeMean;
52     int64_t m_envelopeStdDev;
53
54     bool m_envelopeStdDevCalculated;
55     bool m_envelopeIsNormalized;
56 };
57
58 #endif // AUDIOENVELOPE_H