///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
-// Copyright (C) 2004-2013 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2023 LoRd_MuldeR <MuldeR2@GMX.de>
//
// 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
+// 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.
+// (at your option) any later version; always including the non-optional
+// LAMEXP GNU GENERAL PUBLIC LICENSE ADDENDUM. See "License.txt" file!
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include "Model_AudioFile.h"
+//Internal
#include "Global.h"
+//MUtils
+#include <MUtils/Global.h>
+
+//Qt
#include <QTime>
#include <QObject>
#include <QMutexLocker>
#include <QFile>
+//CRT
#include <limits.h>
const unsigned int AudioFileModel::BITDEPTH_IEEE_FLOAT32 = UINT_MAX-1;
#define PRINT_S(VAR) do \
{ \
- if((VAR).isEmpty()) qDebug(#VAR " = N/A"); else qDebug(#VAR " = \"%s\"", (VAR).toUtf8().constData()); \
+ if((VAR).isEmpty()) qDebug(#VAR " = N/A"); else qDebug(#VAR " = \"%s\"", MUTILS_UTF8((VAR))); \
} \
while(0)
} \
while(0)
+//if((!(OTHER.NAME.isEmpty())) && ((FORCE) || (this.NAME.isEmpty()))) /*this.NAME = OTHER.NAME;*/ \
+
+#define UPDATE_STR(OTHER, FORCE, NAME) do \
+{ \
+ if(!(((OTHER).NAME).isEmpty())) \
+ { \
+ if((FORCE) || ((this->NAME).isEmpty())) (this->NAME) = ((OTHER).NAME); \
+ } \
+} \
+while(0)
+
+#define UPDATE_INT(OTHER, FORCE, NAME) do \
+{ \
+ if(((OTHER).NAME) > 0) \
+ { \
+ if((FORCE) || ((this->NAME) == 0)) (this->NAME) = ((OTHER).NAME); \
+ } \
+} \
+while(0)
+
+#define ASSIGN_VAL(OTHER, NAME) do \
+{ \
+ (this->NAME) = ((OTHER).NAME); \
+} \
+while(0)
+
///////////////////////////////////////////////////////////////////////////////
// Audio File - Meta Info
///////////////////////////////////////////////////////////////////////////////
AudioFileModel_MetaInfo::AudioFileModel_MetaInfo(const AudioFileModel_MetaInfo &model)
{
- m_titel = model.m_titel;
- m_artist = model.m_artist;
- m_album = model.m_album;
- m_genre = model.m_genre;
- m_comment = model.m_comment;
- m_cover = model.m_cover;
- m_year = model.m_year;
- m_position = model.m_position;
+ ASSIGN_VAL(model, m_titel);
+ ASSIGN_VAL(model, m_artist);
+ ASSIGN_VAL(model, m_album);
+ ASSIGN_VAL(model, m_genre);
+ ASSIGN_VAL(model, m_comment);
+ ASSIGN_VAL(model, m_cover);
+ ASSIGN_VAL(model, m_year);
+ ASSIGN_VAL(model, m_position);
}
AudioFileModel_MetaInfo &AudioFileModel_MetaInfo::operator=(const AudioFileModel_MetaInfo &model)
{
- m_titel = model.m_titel;
- m_artist = model.m_artist;
- m_album = model.m_album;
- m_genre = model.m_genre;
- m_comment = model.m_comment;
- m_cover = model.m_cover;
- m_year = model.m_year;
- m_position = model.m_position;
+ ASSIGN_VAL(model, m_titel);
+ ASSIGN_VAL(model, m_artist);
+ ASSIGN_VAL(model, m_album);
+ ASSIGN_VAL(model, m_genre);
+ ASSIGN_VAL(model, m_comment);
+ ASSIGN_VAL(model, m_cover);
+ ASSIGN_VAL(model, m_year);
+ ASSIGN_VAL(model, m_position);
return (*this);
}
+#define IS_EMPTY(X) ((X).isEmpty() ? "YES" : "NO")
+
void AudioFileModel_MetaInfo::update(const AudioFileModel_MetaInfo &model, const bool replace)
{
- qDebug("\n-------[AudioFileModel_MetaInfo::update]-------");
- qDebug("Updating (%p):", this);
- print();
- qDebug("\nUpdating with (%p):", &model);
- model.print();
-
- if((!model.m_titel.isEmpty()) && (replace || m_titel.isEmpty())) m_titel = model.m_titel;
- if((!model.m_artist.isEmpty()) && (replace || m_artist.isEmpty())) m_artist = model.m_artist;
- if((!model.m_album.isEmpty()) && (replace || m_album.isEmpty())) m_album = model.m_album;
- if((!model.m_genre.isEmpty()) && (replace || m_genre.isEmpty())) m_genre = model.m_genre;
- if((!model.m_comment.isEmpty()) && (replace || m_comment.isEmpty())) m_comment = model.m_comment;
- if((!model.m_cover.isEmpty()) && (replace || m_cover.isEmpty())) m_cover = model.m_cover;
- if((model.m_year > 0) && (replace || (m_year == 0))) m_year = model.m_year;
- if((model.m_position > 0) && (replace || (m_position == 0))) m_position = model.m_position;
-
- qDebug("\nResult:");
- print();
- qDebug("-----------------------------------------------\n\n");
+ UPDATE_STR(model, replace, m_titel);
+ UPDATE_STR(model, replace, m_artist);
+ UPDATE_STR(model, replace, m_album);
+ UPDATE_STR(model, replace, m_genre);
+ UPDATE_STR(model, replace, m_comment);
+ UPDATE_STR(model, replace, m_cover);
+ UPDATE_INT(model, replace, m_year);
+ UPDATE_INT(model, replace, m_position);
}
AudioFileModel_MetaInfo::~AudioFileModel_MetaInfo(void)
PRINT_U(m_position);
}
+bool AudioFileModel_MetaInfo::empty(const bool &ignoreArtwork) const
+{
+ bool isEmpty = true;
+
+ if(!m_titel.isEmpty()) isEmpty = false;
+ if(!m_artist.isEmpty()) isEmpty = false;
+ if(!m_album.isEmpty()) isEmpty = false;
+ if(!m_genre.isEmpty()) isEmpty = false;
+ if(!m_comment.isEmpty()) isEmpty = false;
+ if(m_year) isEmpty = false;
+ if(m_position) isEmpty = false;
+
+ if(!ignoreArtwork)
+ {
+ if(!m_cover.isEmpty())
+ {
+ isEmpty = false;
+ }
+ }
+
+ return isEmpty;
+}
+
///////////////////////////////////////////////////////////////////////////////
// Audio File - Technical Info
///////////////////////////////////////////////////////////////////////////////
AudioFileModel_TechInfo::AudioFileModel_TechInfo(const AudioFileModel_TechInfo &model)
{
- m_containerType = model.m_containerType;
- m_containerProfile = model.m_containerProfile;
- m_audioType = model.m_audioType;
- m_audioProfile = model.m_audioProfile;
- m_audioVersion = model.m_audioVersion;
- m_audioEncodeLib = model.m_audioEncodeLib;
- m_audioSamplerate = model.m_audioSamplerate;
- m_audioChannels = model.m_audioChannels;
- m_audioBitdepth = model.m_audioBitdepth;
- m_audioBitrate = model.m_audioBitrate;
- m_audioBitrateMode = model.m_audioBitrateMode;
- m_duration = model.m_duration;
+ ASSIGN_VAL(model, m_containerType);
+ ASSIGN_VAL(model, m_containerProfile);
+ ASSIGN_VAL(model, m_audioType);
+ ASSIGN_VAL(model, m_audioProfile);
+ ASSIGN_VAL(model, m_audioVersion);
+ ASSIGN_VAL(model, m_audioEncodeLib);
+ ASSIGN_VAL(model, m_audioSamplerate);
+ ASSIGN_VAL(model, m_audioChannels);
+ ASSIGN_VAL(model, m_audioBitdepth);
+ ASSIGN_VAL(model, m_audioBitrate);
+ ASSIGN_VAL(model, m_audioBitrateMode);
+ ASSIGN_VAL(model, m_duration);
}
AudioFileModel_TechInfo &AudioFileModel_TechInfo::operator=(const AudioFileModel_TechInfo &model)
{
- m_containerType = model.m_containerType;
- m_containerProfile = model.m_containerProfile;
- m_audioType = model.m_audioType;
- m_audioProfile = model.m_audioProfile;
- m_audioVersion = model.m_audioVersion;
- m_audioEncodeLib = model.m_audioEncodeLib;
- m_audioSamplerate = model.m_audioSamplerate;
- m_audioChannels = model.m_audioChannels;
- m_audioBitdepth = model.m_audioBitdepth;
- m_audioBitrate = model.m_audioBitrate;
- m_audioBitrateMode = model.m_audioBitrateMode;
- m_duration = model.m_duration;
+ ASSIGN_VAL(model, m_containerType);
+ ASSIGN_VAL(model, m_containerProfile);
+ ASSIGN_VAL(model, m_audioType);
+ ASSIGN_VAL(model, m_audioProfile);
+ ASSIGN_VAL(model, m_audioVersion);
+ ASSIGN_VAL(model, m_audioEncodeLib);
+ ASSIGN_VAL(model, m_audioSamplerate);
+ ASSIGN_VAL(model, m_audioChannels);
+ ASSIGN_VAL(model, m_audioBitdepth);
+ ASSIGN_VAL(model, m_audioBitrate);
+ ASSIGN_VAL(model, m_audioBitrateMode);
+ ASSIGN_VAL(model, m_duration);
return (*this);
}
AudioFileModel::AudioFileModel(const AudioFileModel &model)
{
- m_filePath = model.m_filePath;
- m_metaInfo = model.m_metaInfo;
- m_techInfo = model.m_techInfo;
+ ASSIGN_VAL(model, m_filePath);
+ ASSIGN_VAL(model, m_metaInfo);
+ ASSIGN_VAL(model, m_techInfo);
}
AudioFileModel &AudioFileModel::operator=(const AudioFileModel &model)
{
- m_filePath = model.m_filePath;
- m_metaInfo = model.m_metaInfo;
- m_techInfo = model.m_techInfo;
+ ASSIGN_VAL(model, m_filePath);
+ ASSIGN_VAL(model, m_metaInfo);
+ ASSIGN_VAL(model, m_techInfo);
return (*this);
}
info.append(QString(", %1: %2 kbps (%3)").arg(tr("Bitrate"), QString::number(m_techInfo.audioBitrate()), tr("Constant")));
break;
case BitrateModeVariable:
- info.append(WCHAR2QSTR(L", %1: \u2248%2 kbps (%3)").arg(tr("Bitrate"), QString::number(m_techInfo.audioBitrate()), tr("Variable")));
+ info.append(MUTILS_QSTR(L", %1: \u2248%2 kbps (%3)").arg(tr("Bitrate"), QString::number(m_techInfo.audioBitrate()), tr("Variable")));
break;
default:
info.append(QString(", %1: %2 kbps").arg(tr("Bitrate"), QString::number(m_techInfo.audioBitrate())));