diff --git a/LameXP.vcproj b/LameXP.vcproj
index ee432ab4..bd367952 100644
--- a/LameXP.vcproj
+++ b/LameXP.vcproj
@@ -350,6 +350,10 @@
RelativePath=".\src\Encoder_Abstract.cpp"
>
+
+
@@ -830,6 +834,40 @@
/>
+
+
+
+
+
+
+
+
+
+
+
@@ -1294,6 +1332,10 @@
RelativePath=".\tmp\MOC_Encoder_Abstract.cpp"
>
+
+
diff --git a/res/tools/flac.exe b/res/tools/flac.exe
index def7f8a2..5f4f7bf9 100644
Binary files a/res/tools/flac.exe and b/res/tools/flac.exe differ
diff --git a/src/Config.h b/src/Config.h
index 1d7b9988..4ed9e3c0 100644
--- a/src/Config.h
+++ b/src/Config.h
@@ -25,7 +25,7 @@
#define VER_LAMEXP_MAJOR 4
#define VER_LAMEXP_MINOR_HI 0
#define VER_LAMEXP_MINOR_LO 0
-#define VER_LAMEXP_BUILD 151
+#define VER_LAMEXP_BUILD 153
#define VER_LAMEXP_SUFFIX TechPreview
/*
diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp
index 706ac889..df27a484 100644
--- a/src/Dialog_MainWindow.cpp
+++ b/src/Dialog_MainWindow.cpp
@@ -593,9 +593,15 @@ void MainWindow::encodeButtonClicked(void)
return;
}
- if(m_settings->compressionEncoder() != SettingsModel::MP3Encoder && m_settings->compressionEncoder() != SettingsModel::VorbisEncoder && m_settings->compressionEncoder() != SettingsModel::AACEncoder)
+ switch(m_settings->compressionEncoder())
{
- QMessageBox::warning(this, "LameXP", "Sorry, only MP3, Vorbis and AAC encoding is supported at the moment.
Support for more encoders to be added in later versions!");
+ case SettingsModel::MP3Encoder:
+ case SettingsModel::VorbisEncoder:
+ case SettingsModel::AACEncoder:
+ case SettingsModel::FLACEncoder:
+ break;
+ default:
+ QMessageBox::warning(this, "LameXP", "Sorry, only MP3, Vorbis, AAC and FLAC encoding is supported at the moment.
Support for more encoders to be added in later versions!");
tabWidget->setCurrentIndex(3);
return;
}
diff --git a/src/Dialog_Processing.cpp b/src/Dialog_Processing.cpp
index af1697c7..e9ce828b 100644
--- a/src/Dialog_Processing.cpp
+++ b/src/Dialog_Processing.cpp
@@ -31,6 +31,7 @@
#include "Encoder_MP3.h"
#include "Encoder_Vorbis.h"
#include "Encoder_AAC.h"
+#include "Encoder_FLAC.h"
#include "WinSevenTaskbar.h"
#include
@@ -419,7 +420,7 @@ void ProcessingDialog::startNextJob(void)
m_currentFile++;
AudioFileModel currentFile = updateMetaInfo(m_pendingJobs.takeFirst());
AbstractEncoder *encoder = NULL;
-
+
switch(m_settings->compressionEncoder())
{
case SettingsModel::MP3Encoder:
@@ -446,6 +447,14 @@ void ProcessingDialog::startNextJob(void)
encoder = aacEncoder;
}
break;
+ case SettingsModel::FLACEncoder:
+ {
+ FLACEncoder *flacEncoder = new FLACEncoder();
+ flacEncoder->setBitrate(m_settings->compressionBitrate());
+ flacEncoder->setRCMode(m_settings->compressionRCMode());
+ encoder = flacEncoder;
+ }
+ break;
default:
throw "Unsupported encoder!";
}
@@ -528,7 +537,7 @@ AudioFileModel ProcessingDialog::updateMetaInfo(const AudioFileModel &audioFile)
if(!m_metaInfo->fileAlbum().isEmpty()) result.setFileAlbum(m_metaInfo->fileAlbum());
if(!m_metaInfo->fileGenre().isEmpty()) result.setFileGenre(m_metaInfo->fileGenre());
if(m_metaInfo->fileYear()) result.setFileYear(m_metaInfo->fileYear());
- if(m_metaInfo->filePosition()) result.setFileYear(m_metaInfo->filePosition() != UINT_MAX ? m_metaInfo->filePosition() : m_currentFile);
+ if(m_metaInfo->filePosition() == UINT_MAX) result.setFilePosition(m_currentFile);
if(!m_metaInfo->fileComment().isEmpty()) result.setFileComment(m_metaInfo->fileComment());
return result;
diff --git a/src/Encoder_FLAC.cpp b/src/Encoder_FLAC.cpp
new file mode 100644
index 00000000..fce851c4
--- /dev/null
+++ b/src/Encoder_FLAC.cpp
@@ -0,0 +1,147 @@
+///////////////////////////////////////////////////////////////////////////////
+// LameXP - Audio Encoder Front-End
+// Copyright (C) 2004-2010 LoRd_MuldeR
+//
+// 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.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// http://www.gnu.org/licenses/gpl-2.0.txt
+///////////////////////////////////////////////////////////////////////////////
+
+#include "Encoder_FLAC.h"
+
+#include "Global.h"
+#include "Model_Settings.h"
+
+#include
+#include
+
+#define max(a,b) (((a) > (b)) ? (a) : (b))
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+#define IS_UNICODE(STR) (qstricmp(STR.toUtf8().constData(), QString::fromLocal8Bit(STR.toLocal8Bit()).toUtf8().constData()))
+
+FLACEncoder::FLACEncoder(void)
+:
+ m_binary(lamexp_lookup_tool("flac.exe"))
+{
+ if(m_binary.isEmpty())
+ {
+ throw "Error initializing FLAC encoder. Tool 'flac.exe' is not registred!";
+ }
+}
+
+FLACEncoder::~FLACEncoder(void)
+{
+}
+
+bool FLACEncoder::encode(const QString &sourceFile, const AudioFileModel &metaInfo, const QString &outputFile, volatile bool *abortFlag)
+{
+ QProcess process;
+ QStringList args;
+
+ args << QString("-%1").arg(QString::number(max(0, min(8, m_configBitrate))));
+ qWarning("Year: %u", metaInfo.fileYear());
+
+ if(!metaInfo.fileName().isEmpty()) args << "-T" << QString("title=%1").arg(metaInfo.fileName());
+ if(!metaInfo.fileArtist().isEmpty()) args << "-T" << QString("artist=%1").arg(metaInfo.fileArtist());
+ if(!metaInfo.fileAlbum().isEmpty()) args << "-T" << QString("album=%1").arg(metaInfo.fileAlbum());
+ if(!metaInfo.fileGenre().isEmpty()) args << "-T" << QString("genre=%1").arg(metaInfo.fileGenre());
+ if(!metaInfo.fileComment().isEmpty()) args << "-T" << QString("comment=%1").arg(metaInfo.fileComment());
+ if(metaInfo.fileYear()) args << "-T" << QString("date=%1").arg(QString::number(metaInfo.fileYear()));
+ if(metaInfo.filePosition()) args << "-T" << QString("track=%1").arg(QString::number(metaInfo.filePosition()));
+
+ //args << "--tv" << QString().sprintf("Encoder=LameXP v%d.%02d.%04d [%s]", lamexp_version_major(), lamexp_version_minor(), lamexp_version_build(), lamexp_version_release());
+
+ args << "-f" << "-o" << QDir::toNativeSeparators(outputFile);
+ args << QDir::toNativeSeparators(sourceFile);
+
+ if(!startProcess(process, m_binary, args))
+ {
+ return false;
+ }
+
+ bool bTimeout = false;
+ bool bAborted = false;
+
+ QRegExp regExp("\\s(\\d+)% complete");
+
+ while(process.state() != QProcess::NotRunning)
+ {
+ if(*abortFlag)
+ {
+ process.kill();
+ bAborted = true;
+ emit messageLogged("\nABORTED BY USER !!!");
+ break;
+ }
+ process.waitForReadyRead();
+ if(!process.bytesAvailable() && process.state() == QProcess::Running)
+ {
+ process.kill();
+ qWarning("FLAC process timed out <-- killing!");
+ bTimeout = true;
+ break;
+ }
+ while(process.bytesAvailable() > 0)
+ {
+ QByteArray line = process.readLine();
+ QString text = QString::fromUtf8(line.constData()).simplified();
+ if(regExp.lastIndexIn(text) >= 0)
+ {
+ bool ok = false;
+ int progress = regExp.cap(1).toInt(&ok);
+ if(ok) emit statusUpdated(progress);
+ }
+ else if(!text.isEmpty())
+ {
+ emit messageLogged(text);
+ }
+ }
+ }
+
+ process.waitForFinished();
+ if(process.state() != QProcess::NotRunning)
+ {
+ process.kill();
+ process.waitForFinished(-1);
+ }
+
+ emit statusUpdated(100);
+ emit messageLogged(QString().sprintf("\nExited with code: 0x%04X", process.exitCode()));
+
+ if(bTimeout || bAborted || process.exitStatus() != QProcess::NormalExit)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+QString FLACEncoder::extension(void)
+{
+ return "flac";
+}
+
+bool FLACEncoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
+{
+ if(containerType.compare("Wave", Qt::CaseInsensitive) == 0)
+ {
+ if(formatType.compare("PCM", Qt::CaseInsensitive) == 0)
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
diff --git a/src/Encoder_FLAC.h b/src/Encoder_FLAC.h
new file mode 100644
index 00000000..f9dcb7bf
--- /dev/null
+++ b/src/Encoder_FLAC.h
@@ -0,0 +1,42 @@
+///////////////////////////////////////////////////////////////////////////////
+// LameXP - Audio Encoder Front-End
+// Copyright (C) 2004-2010 LoRd_MuldeR
+//
+// 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.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// http://www.gnu.org/licenses/gpl-2.0.txt
+///////////////////////////////////////////////////////////////////////////////
+
+#pragma once
+
+#include "Encoder_Abstract.h"
+
+#include
+
+class FLACEncoder : public AbstractEncoder
+{
+ Q_OBJECT
+
+public:
+ FLACEncoder(void);
+ ~FLACEncoder(void);
+
+ virtual bool encode(const QString &sourceFile, const AudioFileModel &metaInfo, const QString &outputFile, volatile bool *abortFlag);
+ virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
+ virtual QString extension(void);
+
+private:
+ const QString m_binary;
+};
diff --git a/src/Model_MetaInfo.cpp b/src/Model_MetaInfo.cpp
index 1370d6b9..35b0dc85 100644
--- a/src/Model_MetaInfo.cpp
+++ b/src/Model_MetaInfo.cpp
@@ -317,8 +317,7 @@ void MetaInfoModel::editItem(const QModelIndex &index, QWidget *parent)
else
{
QStringList options;
- options << "Unspecified (copy from source file)";
- options << "Generate from list position";
+ options << "Unspecified (copy from source file)" << "Generate from list position";
temp = QInputDialog::getItem(parent, "Edit Position", EXPAND("Please enter the position (track no.) for this file:"), options, ((m_audioFile->filePosition() == UINT_MAX) ? 1 : 0), false, &ok);
if(ok)
{
diff --git a/src/Thread_Initialization.cpp b/src/Thread_Initialization.cpp
index b98c2595..0e237c72 100644
--- a/src/Thread_Initialization.cpp
+++ b/src/Thread_Initialization.cpp
@@ -48,7 +48,7 @@ static const struct lamexp_tool_t g_lamexp_tools[] =
{"153f4274702f3629093b561a31dbf50e2c146305", "alac.exe"},
{"4ecc017a66fe43092110f11494f384e57d99280d", "elevator.exe"},
{"097dd004f44dbda57dbaeb5f15b34a220724ad60", "faad.exe"},
- {"070bf98f78e572a97e4703ef5720c682567a6a56", "flac.exe"},
+ {"133171ac21f083d565ee9c33ef9cd92fc966811e", "flac.exe"},
{"cf379081035ae6bfb6f7bc22f13bfb7ac6302ac5", "gpgv.exe"},
{"d837bf6ee4dab557d8b02d46c75a24e58980fffa", "gpgv.gpg"},
{"143fc001a2f6c56fe1b9e6f8a2eb2b53b9e1e504", "lame.exe"},