I suggest to put other libraries to src/lib/ as well in future.
Some comments added.
+/***************************************************************************
+ * 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>
--- /dev/null
+/***************************************************************************
+ * 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
+/***************************************************************************
+ * 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>
--- /dev/null
+/***************************************************************************
+ * 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
#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:
#include <mlt++/Mlt.h>
#include <QString>
+/**
+ Provides easy access to properties of an audio stream.
+ */
class AudioStreamInfo
{
public:
)
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}
+++ /dev/null
-#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
+++ /dev/null
-#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
#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
;
}