]> git.sesse.net Git - kdenlive/commitdiff
Audio alignment libraries moved to src/lib/audio/
authorSimon A. Eugster <simon.eu@gmail.com>
Tue, 14 Feb 2012 15:30:15 +0000 (16:30 +0100)
committerSimon A. Eugster <simon.eu@gmail.com>
Tue, 14 Feb 2012 15:31:33 +0000 (16:31 +0100)
I suggest to put other libraries to src/lib/ as well in future.

Some comments added.

14 files changed:
src/lib/audio/audioCorrelation.cpp [moved from testingArea/audioCorrelation.cpp with 78% similarity]
src/lib/audio/audioCorrelation.h [new file with mode: 0644]
src/lib/audio/audioCorrelationInfo.cpp [moved from testingArea/audioCorrelationInfo.cpp with 71% similarity]
src/lib/audio/audioCorrelationInfo.h [new file with mode: 0644]
src/lib/audio/audioEnvelope.cpp [moved from testingArea/audioEnvelope.cpp with 100% similarity]
src/lib/audio/audioEnvelope.h [moved from testingArea/audioEnvelope.h with 84% similarity]
src/lib/audio/audioInfo.cpp [moved from testingArea/audioInfo.cpp with 100% similarity]
src/lib/audio/audioInfo.h [moved from testingArea/audioInfo.h with 100% similarity]
src/lib/audio/audioStreamInfo.cpp [moved from testingArea/audioStreamInfo.cpp with 100% similarity]
src/lib/audio/audioStreamInfo.h [moved from testingArea/audioStreamInfo.h with 95% similarity]
testingArea/CMakeLists.txt
testingArea/audioCorrelation.h [deleted file]
testingArea/audioCorrelationInfo.h [deleted file]
testingArea/audioOffset.cpp

similarity index 78%
rename from testingArea/audioCorrelation.cpp
rename to src/lib/audio/audioCorrelation.cpp
index 96adab6cff98bc4439a5f2b586c74e33580ae280..9a807c80c28e7593964a975058ae7703968d798d 100644 (file)
@@ -1,3 +1,13 @@
+/***************************************************************************
+ *   Copyright (C) 2012 by Simon Andreas Eugster (simon.eu@gmail.com)      *
+ *   This file is part of kdenlive. See www.kdenlive.org.                  *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ ***************************************************************************/
+
 #include "audioCorrelation.h"
 
 #include <QTime>
diff --git a/src/lib/audio/audioCorrelation.h b/src/lib/audio/audioCorrelation.h
new file mode 100644 (file)
index 0000000..1f94368
--- /dev/null
@@ -0,0 +1,47 @@
+/***************************************************************************
+ *   Copyright (C) 2012 by Simon Andreas Eugster (simon.eu@gmail.com)      *
+ *   This file is part of kdenlive. See www.kdenlive.org.                  *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ ***************************************************************************/
+
+#ifndef AUDIOCORRELATION_H
+#define AUDIOCORRELATION_H
+
+#include "audioCorrelationInfo.h"
+#include "audioEnvelope.h"
+#include <QList>
+
+class AudioCorrelationInfo;
+
+/**
+  This class does the correlation between two tracks
+  in order to synchronize (align) them.
+
+  It uses one main track (used in the initializer); further tracks will be
+  aligned relative to this main track.
+  */
+class AudioCorrelation
+{
+public:
+    AudioCorrelation(AudioEnvelope *mainTrackEnvelope);
+    ~AudioCorrelation();
+
+    /// \return The child's index
+    int addChild(AudioEnvelope *envelope);
+
+    const AudioCorrelationInfo *info(int childIndex) const;
+    int getShift(int childIndex) const;
+
+
+private:
+    AudioEnvelope *m_mainTrackEnvelope;
+
+    QList<AudioEnvelope*> m_children;
+    QList<AudioCorrelationInfo*> m_correlations;
+};
+
+#endif // AUDIOCORRELATION_H
similarity index 71%
rename from testingArea/audioCorrelationInfo.cpp
rename to src/lib/audio/audioCorrelationInfo.cpp
index 1d33aee10fff4513d50a70312ad019325f069245..b43809095bbf8a8476f38ce12225c1b8e8561ccd 100644 (file)
@@ -1,3 +1,13 @@
+/***************************************************************************
+ *   Copyright (C) 2012 by Simon Andreas Eugster (simon.eu@gmail.com)      *
+ *   This file is part of kdenlive. See www.kdenlive.org.                  *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ ***************************************************************************/
+
 #include "audioCorrelationInfo.h"
 #include <iostream>
 
diff --git a/src/lib/audio/audioCorrelationInfo.h b/src/lib/audio/audioCorrelationInfo.h
new file mode 100644 (file)
index 0000000..6bb5b8b
--- /dev/null
@@ -0,0 +1,47 @@
+/***************************************************************************
+ *   Copyright (C) 2012 by Simon Andreas Eugster (simon.eu@gmail.com)      *
+ *   This file is part of kdenlive. See www.kdenlive.org.                  *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ ***************************************************************************/
+
+#ifndef AUDIOCORRELATIONINFO_H
+#define AUDIOCORRELATIONINFO_H
+
+#include <QImage>
+
+/**
+  This class holds the correlation of two audio samples.
+  It is mainly a container for data, the correlation itself is calculated
+  in the class AudioCorrelation.
+  */
+class AudioCorrelationInfo
+{
+public:
+    AudioCorrelationInfo(int mainSize, int subSize);
+    ~AudioCorrelationInfo();
+
+    int size() const;
+    int64_t* correlationVector();
+    int64_t const* correlationVector() const;
+
+    int64_t max() const;
+    void setMax(int64_t max); ///< Can be set to avoid calculating the max again in this function
+
+    int maxIndex() const;
+
+    QImage toImage(int height = 400) const;
+
+private:
+    int m_mainSize;
+    int m_subSize;
+
+    int64_t *m_correlationVector;
+    int64_t m_max;
+
+};
+
+#endif // AUDIOCORRELATIONINFO_H
similarity index 84%
rename from testingArea/audioEnvelope.h
rename to src/lib/audio/audioEnvelope.h
index bdf4a0b8215ff9c117f9c866df95fd9c0637852a..c039033480d3ba0c656e25df98b56b188350172e 100644 (file)
 #include <mlt++/Mlt.h>
 
 class QImage;
+
+/**
+  The audio envelope is a simplified version of an audio track
+  with frame resolution. One entry is calculated by the sum
+  of the absolute values of all samples in the current frame.
+
+  See also: http://bemasc.net/wordpress/2011/07/26/an-auto-aligner-for-pitivi/
+  */
 class AudioEnvelope
 {
 public:
similarity index 95%
rename from testingArea/audioStreamInfo.h
rename to src/lib/audio/audioStreamInfo.h
index 92d9e434c305159c541ee925ad40e621bac0695d..868bb6cf0ac9361f246ae1747572755158d316dc 100644 (file)
@@ -14,6 +14,9 @@
 #include <mlt++/Mlt.h>
 #include <QString>
 
+/**
+  Provides easy access to properties of an audio stream.
+  */
 class AudioStreamInfo
 {
 public:
index 340acf321bbdf2efe75c410fd8c07931da3f99f9..3e561dc871dca46686957b73d1e65f46f82135b3 100644 (file)
@@ -7,7 +7,14 @@ include_directories(
 )
 include(${QT_USE_FILE})
 
-add_executable(audioOffset  audioOffset.cpp audioInfo.cpp audioStreamInfo.cpp audioEnvelope.cpp audioCorrelation.cpp audioCorrelationInfo.cpp)
+add_executable(audioOffset
+    audioOffset.cpp
+    ../src/lib/audio/audioInfo.cpp
+    ../src/lib/audio/audioStreamInfo.cpp
+    ../src/lib/audio/audioEnvelope.cpp
+    ../src/lib/audio/audioCorrelation.cpp
+    ../src/lib/audio/audioCorrelationInfo.cpp
+)
 target_link_libraries(audioOffset 
   ${QT_LIBRARIES}
   ${LIBMLT_LIBRARY}
diff --git a/testingArea/audioCorrelation.h b/testingArea/audioCorrelation.h
deleted file mode 100644 (file)
index 89c53de..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef AUDIOCORRELATION_H
-#define AUDIOCORRELATION_H
-
-#include "audioCorrelationInfo.h"
-#include "audioEnvelope.h"
-#include <QList>
-
-class AudioCorrelationInfo;
-class AudioCorrelation
-{
-public:
-    AudioCorrelation(AudioEnvelope *mainTrackEnvelope);
-    ~AudioCorrelation();
-
-    int addChild(AudioEnvelope *envelope);
-//    int childIndex(AudioEnvelope *envelope) const;
-
-    const AudioCorrelationInfo *info(int childIndex) const;
-    int getShift(int childIndex) const;
-
-
-private:
-    AudioEnvelope *m_mainTrackEnvelope;
-
-    QList<AudioEnvelope*> m_children;
-    QList<AudioCorrelationInfo*> m_correlations;
-};
-
-#endif // AUDIOCORRELATION_H
diff --git a/testingArea/audioCorrelationInfo.h b/testingArea/audioCorrelationInfo.h
deleted file mode 100644 (file)
index ee2ea82..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef AUDIOCORRELATIONINFO_H
-#define AUDIOCORRELATIONINFO_H
-
-#include <QImage>
-
-class AudioCorrelationInfo
-{
-public:
-    AudioCorrelationInfo(int mainSize, int subSize);
-    ~AudioCorrelationInfo();
-
-    int size() const;
-    int64_t* correlationVector();
-    int64_t const* correlationVector() const;
-
-    int64_t max() const;
-    void setMax(int64_t max); ///< Can be set to avoid calculating the max again in this function
-
-    int maxIndex() const;
-
-    QImage toImage(int height = 400) const;
-
-private:
-    int m_mainSize;
-    int m_subSize;
-
-    int64_t *m_correlationVector;
-    int64_t m_max;
-
-};
-
-#endif // AUDIOCORRELATIONINFO_H
index 842096aa61c4113c0748925197730f352760f474..8629cb8a745332996b277c7ff7f4e6e5e5386573 100644 (file)
 #include <cstdlib>
 #include <cmath>
 
-#include "audioInfo.h"
-#include "audioStreamInfo.h"
-#include "audioEnvelope.h"
-#include "audioCorrelation.h"
+#include "../src/lib/audio/audioInfo.h"
+#include "../src/lib/audio/audioStreamInfo.h"
+#include "../src/lib/audio/audioEnvelope.h"
+#include "../src/lib/audio/audioCorrelation.h"
 
 void printUsage(const char *path)
 {
-    std::cout << "Usage: " << path << " <main audio file> <second audio file>" << std::endl
-              << "\t-h, --help\tDisplay this help" << std::endl
-              << "\t--profile=<profile>\tUse the given profile for calculation (run: melt -query profiles)" << std::endl
-              << "\t--no-images\tDo not save envelope and correlation images" << std::endl
+    std::cout << "This executable takes two audio/video files A and B and determines " << std::endl
+              << "how much B needs to be shifted in order to be synchronized with A." << std::endl << std::endl
+              << path << " <main audio file> <second audio file>" << std::endl
+              << "\t-h, --help\n\t\tDisplay this help" << std::endl
+              << "\t--profile=<profile>\n\t\tUse the given profile for calculation (run: melt -query profiles)" << std::endl
+              << "\t--no-images\n\t\tDo not save envelope and correlation images" << std::endl
                  ;
 }