disables STL support with QT_NO_STL.
Also, changed delete to delete[].
AudioCorrelation::~AudioCorrelation()
{
+ delete m_mainTrackEnvelope;
+ foreach (AudioEnvelope *envelope, m_children) {
+ delete envelope;
+ }
}
int AudioCorrelation::addChild(AudioEnvelope *envelope)
class AudioCorrelation
{
public:
+ /// AudioCorrelation will take ownership of mainTrackEnvelope
AudioCorrelation(AudioEnvelope *mainTrackEnvelope);
~AudioCorrelation();
- /// \return The child's index
+ /**
+ This object will take ownership of the passed envelope.
+ \return The child's index
+ */
int addChild(AudioEnvelope *envelope);
const AudioCorrelationInfo *info(int childIndex) const;
AudioCorrelationInfo::~AudioCorrelationInfo()
{
- delete m_correlationVector;
+ delete[] m_correlationVector;
}
int AudioCorrelationInfo::size() const
AudioEnvelope::~AudioEnvelope()
{
if (m_envelope != NULL) {
- delete m_envelope;
+ delete[] m_envelope;
}
delete m_info;
}
#include "audioInfo.h"
#include "audioStreamInfo.h"
+#include <QString>
#include <iostream>
#include <cstdlib>
// Get the number of streams and add the information of each of them if it is an audio stream.
int streams = atoi(producer->get("meta.media.nb_streams"));
for (int i = 0; i < streams; i++) {
- std::string propertyName = QString("meta.media.%1.stream.type").arg(i).toStdString();
+ QByteArray propertyName = QString("meta.media.%1.stream.type").arg(i).toLocal8Bit();
- if (strcmp("audio", producer->get(propertyName.c_str())) == 0) {
+ if (strcmp("audio", producer->get(propertyName.data())) == 0) {
m_list << new AudioStreamInfo(producer, i);
}
#include "audioStreamInfo.h"
+#include <QString>
#include <iostream>
#include <cstdlib>
m_audioStreamIndex(audioStreamIndex)
{
- std::string key;
+ QByteArray key;
- key = QString("meta.media.%1.codec.sample_fmt").arg(audioStreamIndex).toStdString();
- m_samplingFormat = QString(producer->get(key.c_str()));
+ key = QString("meta.media.%1.codec.sample_fmt").arg(audioStreamIndex).toLocal8Bit();
+ m_samplingFormat = QString(producer->get(key.data()));
- key = QString("meta.media.%1.codec.sample_rate").arg(audioStreamIndex).toStdString();
- m_samplingRate = atoi(producer->get(key.c_str()));
+ key = QString("meta.media.%1.codec.sample_rate").arg(audioStreamIndex).toLocal8Bit();
+ m_samplingRate = atoi(producer->get(key.data()));
- key = QString("meta.media.%1.codec.bit_rate").arg(audioStreamIndex).toStdString();
- m_bitRate = atoi(producer->get(key.c_str()));
+ key = QString("meta.media.%1.codec.bit_rate").arg(audioStreamIndex).toLocal8Bit();
+ m_bitRate = atoi(producer->get(key.data()));
- key = QString("meta.media.%1.codec.channels").arg(audioStreamIndex).toStdString();
- m_channels = atoi(producer->get(key.c_str()));
+ key = QString("meta.media.%1.codec.channels").arg(audioStreamIndex).toLocal8Bit();
+ m_channels = atoi(producer->get(key.data()));
- key = QString("meta.media.%1.codec.name").arg(audioStreamIndex).toStdString();
- m_codecName = QString(producer->get(key.c_str()));
+ key = QString("meta.media.%1.codec.name").arg(audioStreamIndex).toLocal8Bit();
+ m_codecName = QString(producer->get(key.data()));
- key = QString("meta.media.%1.codec.long_name").arg(audioStreamIndex).toStdString();
- m_codecLongName = QString(producer->get(key.c_str()));
+ key = QString("meta.media.%1.codec.long_name").arg(audioStreamIndex).toLocal8Bit();
+ m_codecLongName = QString(producer->get(key.data()));
}
AudioStreamInfo::~AudioStreamInfo()
{
void AudioStreamInfo::dumpInfo() const
{
std::cout << "Info for audio stream " << m_audioStreamIndex << std::endl
- << "\tCodec: " << m_codecLongName.toStdString() << " (" << m_codecName.toStdString() << ")" << std::endl
+ << "\tCodec: " << m_codecLongName.toLocal8Bit().data() << " (" << m_codecName.toLocal8Bit().data() << ")" << std::endl
<< "\tChannels: " << m_channels << std::endl
<< "\tSampling rate: " << m_samplingRate << std::endl
<< "\tBit rate: " << m_bitRate << std::endl
// Build the audio envelopes for the correlation
- AudioEnvelope envelopeMain(&prodMain);
- envelopeMain.loadEnvelope();
- envelopeMain.loadStdDev();
- envelopeMain.dumpInfo();
+ AudioEnvelope *envelopeMain = new AudioEnvelope(&prodMain);
+ envelopeMain->loadEnvelope();
+ envelopeMain->loadStdDev();
+ envelopeMain->dumpInfo();
- AudioEnvelope envelopeSub(&prodSub);
- envelopeSub.loadEnvelope();
- envelopeSub.loadStdDev();
- envelopeSub.dumpInfo();
+ AudioEnvelope *envelopeSub = new AudioEnvelope(&prodSub);
+ envelopeSub->loadEnvelope();
+ envelopeSub->loadStdDev();
+ envelopeSub->dumpInfo();
// Calculate the correlation and hereby the audio shift
- AudioCorrelation corr(&envelopeMain);
- int index = corr.addChild(&envelopeSub);
+ AudioCorrelation corr(envelopeMain);
+ int index = corr.addChild(envelopeSub);
int shift = corr.getShift(index);
std::cout << fileSub << " should be shifted by " << shift << " frames" << std::endl
QString outImg;
outImg = QString("envelope-main-%1.png")
.arg(QDateTime::currentDateTime().toString("yyyy-MM-dd-hh:mm:ss"));
- envelopeMain.drawEnvelope().save(outImg);
+ 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);
+ envelopeSub->drawEnvelope().save(outImg);
std::cout << "Saved volume envelope as "
<< QFileInfo(outImg).absoluteFilePath().toStdString()
<< std::endl;