+ int64_t max = 0;
+
+ if (useFFT) {
+ FFTCorrelation::correlate(envMain, sizeMain,
+ envSub, sizeSub,
+ correlation);
+ } else {
+ correlate(envMain, sizeMain,
+ envSub, sizeSub,
+ correlation,
+ &max);
+ info->setMax(max);
+ }
+
+
+ m_children.append(envelope);
+ m_correlations.append(info);
+
+ Q_ASSERT(m_correlations.size() == m_children.size());
+
+ return m_children.indexOf(envelope);
+}
+
+int AudioCorrelation::getShift(int childIndex) const
+{
+ Q_ASSERT(childIndex >= 0);
+ Q_ASSERT(childIndex < m_correlations.size());
+
+ int indexOffset = m_correlations.at(childIndex)->maxIndex();
+ indexOffset -= m_children.at(childIndex)->envelopeSize();
+
+ return indexOffset;
+}
+
+AudioCorrelationInfo const* AudioCorrelation::info(int childIndex) const
+{
+ Q_ASSERT(childIndex >= 0);
+ Q_ASSERT(childIndex < m_correlations.size());
+
+ return m_correlations.at(childIndex);
+}
+
+
+void AudioCorrelation::correlate(const int64_t *envMain, int sizeMain,
+ const int64_t *envSub, int sizeSub,
+ int64_t *correlation,
+ int64_t *out_max)
+{
+ Q_ASSERT(correlation != NULL);
+