From: Simon A. Eugster Date: Tue, 14 Feb 2012 15:30:15 +0000 (+0100) Subject: Audio alignment libraries moved to src/lib/audio/ X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=5aa35dcbf590cefca46d82ff0c2a2c29bb374853;p=kdenlive Audio alignment libraries moved to src/lib/audio/ I suggest to put other libraries to src/lib/ as well in future. Some comments added. --- diff --git a/testingArea/audioCorrelation.cpp b/src/lib/audio/audioCorrelation.cpp similarity index 78% rename from testingArea/audioCorrelation.cpp rename to src/lib/audio/audioCorrelation.cpp index 96adab6c..9a807c80 100644 --- a/testingArea/audioCorrelation.cpp +++ b/src/lib/audio/audioCorrelation.cpp @@ -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 diff --git a/src/lib/audio/audioCorrelation.h b/src/lib/audio/audioCorrelation.h new file mode 100644 index 00000000..1f943687 --- /dev/null +++ b/src/lib/audio/audioCorrelation.h @@ -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 + +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 m_children; + QList m_correlations; +}; + +#endif // AUDIOCORRELATION_H diff --git a/testingArea/audioCorrelationInfo.cpp b/src/lib/audio/audioCorrelationInfo.cpp similarity index 71% rename from testingArea/audioCorrelationInfo.cpp rename to src/lib/audio/audioCorrelationInfo.cpp index 1d33aee1..b4380909 100644 --- a/testingArea/audioCorrelationInfo.cpp +++ b/src/lib/audio/audioCorrelationInfo.cpp @@ -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 diff --git a/src/lib/audio/audioCorrelationInfo.h b/src/lib/audio/audioCorrelationInfo.h new file mode 100644 index 00000000..6bb5b8b7 --- /dev/null +++ b/src/lib/audio/audioCorrelationInfo.h @@ -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 + +/** + 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 diff --git a/testingArea/audioEnvelope.cpp b/src/lib/audio/audioEnvelope.cpp similarity index 100% rename from testingArea/audioEnvelope.cpp rename to src/lib/audio/audioEnvelope.cpp diff --git a/testingArea/audioEnvelope.h b/src/lib/audio/audioEnvelope.h similarity index 84% rename from testingArea/audioEnvelope.h rename to src/lib/audio/audioEnvelope.h index bdf4a0b8..c0390334 100644 --- a/testingArea/audioEnvelope.h +++ b/src/lib/audio/audioEnvelope.h @@ -15,6 +15,14 @@ #include 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: diff --git a/testingArea/audioInfo.cpp b/src/lib/audio/audioInfo.cpp similarity index 100% rename from testingArea/audioInfo.cpp rename to src/lib/audio/audioInfo.cpp diff --git a/testingArea/audioInfo.h b/src/lib/audio/audioInfo.h similarity index 100% rename from testingArea/audioInfo.h rename to src/lib/audio/audioInfo.h diff --git a/testingArea/audioStreamInfo.cpp b/src/lib/audio/audioStreamInfo.cpp similarity index 100% rename from testingArea/audioStreamInfo.cpp rename to src/lib/audio/audioStreamInfo.cpp diff --git a/testingArea/audioStreamInfo.h b/src/lib/audio/audioStreamInfo.h similarity index 95% rename from testingArea/audioStreamInfo.h rename to src/lib/audio/audioStreamInfo.h index 92d9e434..868bb6cf 100644 --- a/testingArea/audioStreamInfo.h +++ b/src/lib/audio/audioStreamInfo.h @@ -14,6 +14,9 @@ #include #include +/** + Provides easy access to properties of an audio stream. + */ class AudioStreamInfo { public: diff --git a/testingArea/CMakeLists.txt b/testingArea/CMakeLists.txt index 340acf32..3e561dc8 100644 --- a/testingArea/CMakeLists.txt +++ b/testingArea/CMakeLists.txt @@ -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 index 89c53de3..00000000 --- a/testingArea/audioCorrelation.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef AUDIOCORRELATION_H -#define AUDIOCORRELATION_H - -#include "audioCorrelationInfo.h" -#include "audioEnvelope.h" -#include - -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 m_children; - QList m_correlations; -}; - -#endif // AUDIOCORRELATION_H diff --git a/testingArea/audioCorrelationInfo.h b/testingArea/audioCorrelationInfo.h deleted file mode 100644 index ee2ea82d..00000000 --- a/testingArea/audioCorrelationInfo.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef AUDIOCORRELATIONINFO_H -#define AUDIOCORRELATIONINFO_H - -#include - -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 diff --git a/testingArea/audioOffset.cpp b/testingArea/audioOffset.cpp index 842096aa..8629cb8a 100644 --- a/testingArea/audioOffset.cpp +++ b/testingArea/audioOffset.cpp @@ -23,17 +23,19 @@ #include #include -#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 << "
" << std::endl - << "\t-h, --help\tDisplay this help" << std::endl - << "\t--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 << "
" << std::endl + << "\t-h, --help\n\t\tDisplay this help" << std::endl + << "\t--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 ; }