- QString outImg = QString("envelope-%1.png")
- .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd-hh:mm:ss"));
- envelopeMain.drawEnvelope().save(outImg);
- std::cout << "Saved volume envelope as "
- << QFileInfo(outImg).absoluteFilePath().toStdString()
- << std::endl;
+
+
+ // Calculate the correlation and hereby the audio shift
+ AudioCorrelation corr(envelopeMain);
+ int index = corr.addChild(envelopeSub);
+
+ int shift = corr.getShift(index);
+ std::cout << fileSub << " should be shifted by " << shift << " frames" << std::endl
+ << "\trelative to " << fileMain << std::endl
+ << "\tin a " << prodMain.get_fps() << " fps profile (" << profile << ")." << std::endl
+ ;
+
+
+ if (saveImages) {
+ QString outImg;
+ outImg = QString("envelope-main-%1.png")
+ .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd-hh:mm:ss"));
+ envelopeMain->drawEnvelope().save(outImg);
+ std::cout << "Saved volume envelope as "
+ << QFileInfo(outImg).absoluteFilePath().toStdString()
+ << std::endl;
+ outImg = QString("envelope-sub-%1.png")
+ .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd-hh:mm:ss"));
+ envelopeSub->drawEnvelope().save(outImg);
+ std::cout << "Saved volume envelope as "
+ << QFileInfo(outImg).absoluteFilePath().toStdString()
+ << std::endl;
+ outImg = QString("correlation-%1.png")
+ .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd-hh:mm:ss"));
+ corr.info(index)->toImage().save(outImg);
+ std::cout << "Saved correlation image as "
+ << QFileInfo(outImg).absoluteFilePath().toStdString()
+ << std::endl;
+ }