diff --git a/LameXP.vcproj b/LameXP.vcproj
index 13242db9..d77459c7 100644
--- a/LameXP.vcproj
+++ b/LameXP.vcproj
@@ -302,6 +302,10 @@
RelativePath=".\src\Dialog_MetaInfo.cpp"
>
+
+
@@ -478,6 +482,40 @@
/>
+
+
+
+
+
+
+
+
+
+
+
@@ -559,7 +597,7 @@
@@ -569,7 +607,7 @@
@@ -579,7 +617,7 @@
@@ -834,6 +872,10 @@
RelativePath=".\tmp\MOC_Dialog_MetaInfo.cpp"
>
+
+
@@ -1072,6 +1114,40 @@
/>
+
+
+
+
+
+
+
+
+
+
+
diff --git a/gui/ProcessingDialog.ui b/gui/ProcessingDialog.ui
new file mode 100644
index 00000000..abdaf584
--- /dev/null
+++ b/gui/ProcessingDialog.ui
@@ -0,0 +1,443 @@
+
+
+ ProcessingDialog
+
+
+
+ 0
+ 0
+ 663
+ 458
+
+
+
+ LameXP - Processing
+
+
+
+ 0
+
+
+ 0
+
+ -
+
+
+ 0
+
+
-
+
+
+
+ 0
+ 72
+
+
+
+
+ 16777215
+ 72
+
+
+
+
+
+
+
+
+ 255
+ 255
+ 255
+
+
+
+
+
+
+ 255
+ 255
+ 255
+
+
+
+
+
+
+
+
+ 255
+ 255
+ 255
+
+
+
+
+
+
+ 255
+ 255
+ 255
+
+
+
+
+
+
+
+
+ 255
+ 255
+ 255
+
+
+
+
+
+
+ 255
+ 255
+ 255
+
+
+
+
+
+
+
+ true
+
+
+ QFrame::NoFrame
+
+
+ QFrame::Raised
+
+
+
+ 3
+
+
-
+
+
-
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 4
+ 20
+
+
+
+
+ -
+
+
+
+ 60
+ 56
+
+
+
+
+ 60
+ 56
+
+
+
+
+
+
+ :/MainIcon.png
+
+
+ true
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Fixed
+
+
+
+ 12
+ 20
+
+
+
+
+ -
+
+
+ <b>Encoding Files</b><br>Your files are being encoded, please be pateint...
+
+
+
+ -
+
+
+
+ 48
+ 16777215
+
+
+
+
+
+
+ :/images/Working.gif
+
+
+ Qt::AlignCenter
+
+
+
+
+
+
+
+
+ -
+
+
+
+ 0
+ 2
+
+
+
+
+ 16777215
+ 2
+
+
+
+ QFrame::HLine
+
+
+ QFrame::Sunken
+
+
+
+ -
+
+
+ 8
+
+
+ 21
+
+
-
+
+
+
+ 75
+ true
+
+
+
+ Initializing, please wait...
+
+
+
+ -
+
+
+ 24
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+ QSizePolicy::Fixed
+
+
+
+ 20
+ 1
+
+
+
+
+ -
+
+
+
+ 50
+ false
+
+
+
+
+ -
+
+
-
+
+
+ true
+
+
+
+
+
+
+
+ 85
+ 85
+ 127
+
+
+
+
+
+
+
+
+ 85
+ 85
+ 127
+
+
+
+
+
+
+
+
+ 120
+ 120
+ 120
+
+
+
+
+
+
+
+
+ 75
+ true
+
+
+
+ (VERSION_TAG)
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+
+ 120
+ 0
+
+
+
+ Abort
+
+
+
+ :/icons/cancel.png:/icons/cancel.png
+
+
+
+ -
+
+
+
+ 120
+ 0
+
+
+
+ Close
+
+
+
+ :/icons/accept.png:/icons/accept.png
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ button_closeDialog
+ clicked()
+ ProcessingDialog
+ accept()
+
+
+ 579
+ 422
+
+
+ 331
+ 228
+
+
+
+
+ button_AbortProcess
+ clicked()
+ ProcessingDialog
+ reject()
+
+
+ 453
+ 422
+
+
+ 331
+ 228
+
+
+
+
+
diff --git a/res/Images.qrc b/res/Images.qrc
index 1a75d719..9fe1e8cc 100644
--- a/res/Images.qrc
+++ b/res/Images.qrc
@@ -11,5 +11,6 @@
images/Construction.gif
images/Cogwheels.png
images/Qt.svg
+ images/Working.gif
diff --git a/src/Config.h b/src/Config.h
index 79fd217d..ee5ea289 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 30
+#define VER_LAMEXP_BUILD 33
#define VER_LAMEXP_SUFFIX TechPreview
/*
diff --git a/src/Dialog_Processing.cpp b/src/Dialog_Processing.cpp
new file mode 100644
index 00000000..71df808e
--- /dev/null
+++ b/src/Dialog_Processing.cpp
@@ -0,0 +1,54 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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 "Dialog_Processing.h"
+
+#include "Global.h"
+
+#include
+#include
+#include
+#include
+
+ProcessingDialog::ProcessingDialog(void)
+{
+ //Init the dialog, from the .ui file
+ setupUi(this);
+ setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
+ label_versionInfo->setText(QString().sprintf("v%d.%02d %s (Build %d)", lamexp_version_major(), lamexp_version_minor(), lamexp_version_release(), lamexp_version_build()));
+
+ //Center window in screen
+ QRect desktopRect = QApplication::desktop()->screenGeometry();
+ QRect thisRect = this->geometry();
+ move((desktopRect.width() - thisRect.width()) / 2, (desktopRect.height() - thisRect.height()) / 2);
+ setMinimumSize(thisRect.width(), thisRect.height());
+
+ //Init progress indicator
+ m_progressIndicator = new QMovie(":/images/Working.gif");
+ label_headerWorking->setMovie(m_progressIndicator);
+ m_progressIndicator->start();
+}
+
+ProcessingDialog::~ProcessingDialog(void)
+{
+ if(m_progressIndicator) m_progressIndicator->stop();
+ LAMEXP_DELETE(m_progressIndicator);
+}
diff --git a/src/Dialog_Processing.h b/src/Dialog_Processing.h
new file mode 100644
index 00000000..59efbc8c
--- /dev/null
+++ b/src/Dialog_Processing.h
@@ -0,0 +1,38 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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 "../tmp/UIC_ProcessingDialog.h"
+
+class QMovie;
+
+class ProcessingDialog : public QDialog, private Ui::ProcessingDialog
+{
+ Q_OBJECT
+
+public:
+ ProcessingDialog(void);
+ ~ProcessingDialog(void);
+
+private:
+ QMovie *m_progressIndicator;
+};
diff --git a/src/Encoder_Abstract.cpp b/src/Encoder_Abstract.cpp
new file mode 100644
index 00000000..43cc52ab
--- /dev/null
+++ b/src/Encoder_Abstract.cpp
@@ -0,0 +1,39 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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_Abstract.h"
+
+#define max(a,b) (((a) > (b)) ? (a) : (b))
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+
+AbstractEncoder::AbstractEncoder(void)
+{
+ m_configBitrate = 0;
+ m_configRCMode = 0;
+}
+
+AbstractEncoder::~AbstractEncoder(void)
+{
+}
+
+//Setters
+void AbstractEncoder::setBitrate(int bitrate) { m_configBitrate = max(0, bitrate); }
+void AbstractEncoder::setRCMode(int mode) { m_configRCMode = max(0, mode); }
diff --git a/src/Encoder_Abstract.h b/src/Encoder_Abstract.h
new file mode 100644
index 00000000..7775886b
--- /dev/null
+++ b/src/Encoder_Abstract.h
@@ -0,0 +1,43 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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 "Model_AudioFile.h"
+
+#include
+
+class AbstractEncoder
+{
+public:
+ AbstractEncoder(void);
+ ~AbstractEncoder(void);
+
+ virtual bool encode(const AudioFileModel &sourceFile, const QString &outputFile) = 0;
+
+ void setBitrate(int bitrate);
+ void setRCMode(int mode);
+
+protected:
+ int m_configBitrate;
+ int m_configRCMode;
+
+};
diff --git a/src/Encoder_MP3.cpp b/src/Encoder_MP3.cpp
new file mode 100644
index 00000000..dfd19fa8
--- /dev/null
+++ b/src/Encoder_MP3.cpp
@@ -0,0 +1,121 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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_MP3.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()))
+
+MP3Encoder::MP3Encoder(void) : m_binary(lamexp_lookup_tool("lame.exe"))
+{
+ if(m_binary.isEmpty())
+ {
+ throw "Error initializing MP3 encoder. Tool 'lame.exe' is not registred!";
+ }
+}
+
+MP3Encoder::~MP3Encoder(void)
+{
+}
+
+bool MP3Encoder::encode(const AudioFileModel &sourceFile, const QString &outputFile)
+{
+ const QString baseName = QFileInfo(outputFile).fileName();
+ emit statusUpdated(baseName);
+
+ QProcess process;
+ process.setProcessChannelMode(QProcess::MergedChannels);
+ process.setReadChannel(QProcess::StandardOutput);
+
+ QStringList args;
+ args << "--nohist";
+ args << "-h";
+
+ switch(m_configRCMode)
+ {
+ case SettingsModel::VBRMode:
+ args << "-V" << QString::number(9 - min(9, m_configBitrate));
+ break;
+ case SettingsModel::ABRMode:
+ args << "--abr" << QString::number(SettingsModel::mp3Bitrates[min(13, m_configBitrate)]);
+ break;
+ case SettingsModel::CBRMode:
+ args << "--cbr";
+ args << "-b" << QString::number(SettingsModel::mp3Bitrates[min(13, m_configBitrate)]);
+ break;
+ default:
+ throw "Bad rate-control mode!";
+ break;
+ }
+
+ if(!sourceFile.fileName().isEmpty()) args << (IS_UNICODE(sourceFile.fileName()) ? "--uTitle" : "--lTitle") << sourceFile.fileName();
+ if(!sourceFile.fileArtist().isEmpty()) args << (IS_UNICODE(sourceFile.fileArtist()) ? "--uArtist" : "--lArtist") << sourceFile.fileArtist();
+ if(!sourceFile.fileGenre().isEmpty()) args << (IS_UNICODE(sourceFile.fileGenre()) ? "--uGenre" : "--lGenre") << sourceFile.fileGenre();
+ if(!sourceFile.fileComment().isEmpty()) args << (IS_UNICODE(sourceFile.fileComment()) ? "--uComment" : "--lComment") << sourceFile.fileComment();
+
+ args << QDir::toNativeSeparators(sourceFile.filePath());
+ args << QDir::toNativeSeparators(outputFile);
+
+ process.start(lamexp_lookup_tool("lame.exe"), args);
+ if(!process.waitForStarted())
+ {
+ return false;
+ }
+
+ QRegExp regExp("\\(.*(\\d+)%\\)\\|");
+
+ while(process.state() != QProcess::NotRunning)
+ {
+ process.waitForReadyRead();
+ while(process.bytesAvailable() > 0)
+ {
+ QByteArray line = process.readLine();
+ qDebug("%s", line.constData());
+ QString text = QString::fromLocal8Bit(line.constData()).simplified();
+ if(regExp.lastIndexIn(line) >= 0)
+ {
+ emit statusUpdated(QString("%1 [%2%]").arg(baseName, regExp.cap(1)));
+ }
+ }
+ }
+
+ process.waitForFinished();
+
+ if(process.state() != QProcess::NotRunning)
+ {
+ process.kill();
+ process.waitForFinished(-1);
+ }
+
+ if(process.exitStatus() != QProcess::NormalExit)
+ {
+ return false;
+ }
+
+ return true;
+}
\ No newline at end of file
diff --git a/src/Encoder_MP3.h b/src/Encoder_MP3.h
new file mode 100644
index 00000000..0822cf0f
--- /dev/null
+++ b/src/Encoder_MP3.h
@@ -0,0 +1,43 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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 MP3Encoder : public QObject, public AbstractEncoder
+{
+ Q_OBJECT
+
+public:
+ MP3Encoder(void);
+ ~MP3Encoder(void);
+
+ virtual bool encode(const AudioFileModel &sourceFile, const QString &outputFile);
+
+signals:
+ void statusUpdated(const QString &text);
+
+private:
+ const QString m_binary;
+};
diff --git a/src/Main.cpp b/src/Main.cpp
index d79ce17b..5280b35d 100644
--- a/src/Main.cpp
+++ b/src/Main.cpp
@@ -23,6 +23,7 @@
#include "Global.h"
#include "Dialog_SplashScreen.h"
#include "Dialog_MainWindow.h"
+#include "Dialog_Processing.h"
#include "Thread_Initialization.h"
#include "Thread_MessageProducer.h"
#include "Model_Settings.h"
@@ -121,6 +122,11 @@ int lamexp_main(int argc, char* argv[])
iResult = QApplication::instance()->exec();
LAMEXP_DELETE(poMainWindow);
+ //Show processing dialog
+ ProcessingDialog *processingDialog = new ProcessingDialog();
+ processingDialog->exec();
+ LAMEXP_DELETE(processingDialog);
+
//Final clean-up
qDebug("Shutting down, please wait...\n");