FLAC encoding support.
This commit is contained in:
parent
33974146e6
commit
e6460b9779
@ -350,6 +350,10 @@
|
|||||||
RelativePath=".\src\Encoder_Abstract.cpp"
|
RelativePath=".\src\Encoder_Abstract.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Encoder_FLAC.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\Encoder_MP3.cpp"
|
RelativePath=".\src\Encoder_MP3.cpp"
|
||||||
>
|
>
|
||||||
@ -830,6 +834,40 @@
|
|||||||
/>
|
/>
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Encoder_FLAC.h"
|
||||||
|
>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
Description="MOC "$(SolutionDir)tmp\MOC_$(SafeInputName).cpp""
|
||||||
|
CommandLine=""$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_$(SafeInputName).cpp" "$(InputPath)""
|
||||||
|
Outputs=""$(SolutionDir)tmp\MOC_$(SafeInputName).cpp""
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
Description="MOC "$(SolutionDir)tmp\MOC_$(SafeInputName).cpp""
|
||||||
|
CommandLine=""$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_$(SafeInputName).cpp" "$(InputPath)""
|
||||||
|
Outputs=""$(SolutionDir)tmp\MOC_$(SafeInputName).cpp""
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release_Static|Win32"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
Description="MOC "$(SolutionDir)tmp\MOC_$(SafeInputName).cpp""
|
||||||
|
CommandLine=""$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_$(SafeInputName).cpp" "$(InputPath)""
|
||||||
|
Outputs=""$(SolutionDir)tmp\MOC_$(SafeInputName).cpp""
|
||||||
|
/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\Encoder_MP3.h"
|
RelativePath=".\src\Encoder_MP3.h"
|
||||||
>
|
>
|
||||||
@ -1294,6 +1332,10 @@
|
|||||||
RelativePath=".\tmp\MOC_Encoder_Abstract.cpp"
|
RelativePath=".\tmp\MOC_Encoder_Abstract.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\tmp\MOC_Encoder_FLAC.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\tmp\MOC_Encoder_MP3.cpp"
|
RelativePath=".\tmp\MOC_Encoder_MP3.cpp"
|
||||||
>
|
>
|
||||||
|
Binary file not shown.
@ -25,7 +25,7 @@
|
|||||||
#define VER_LAMEXP_MAJOR 4
|
#define VER_LAMEXP_MAJOR 4
|
||||||
#define VER_LAMEXP_MINOR_HI 0
|
#define VER_LAMEXP_MINOR_HI 0
|
||||||
#define VER_LAMEXP_MINOR_LO 0
|
#define VER_LAMEXP_MINOR_LO 0
|
||||||
#define VER_LAMEXP_BUILD 151
|
#define VER_LAMEXP_BUILD 153
|
||||||
#define VER_LAMEXP_SUFFIX TechPreview
|
#define VER_LAMEXP_SUFFIX TechPreview
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -593,9 +593,15 @@ void MainWindow::encodeButtonClicked(void)
|
|||||||
return;
|
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.<br>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.<br>Support for more encoders to be added in later versions!");
|
||||||
tabWidget->setCurrentIndex(3);
|
tabWidget->setCurrentIndex(3);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "Encoder_MP3.h"
|
#include "Encoder_MP3.h"
|
||||||
#include "Encoder_Vorbis.h"
|
#include "Encoder_Vorbis.h"
|
||||||
#include "Encoder_AAC.h"
|
#include "Encoder_AAC.h"
|
||||||
|
#include "Encoder_FLAC.h"
|
||||||
#include "WinSevenTaskbar.h"
|
#include "WinSevenTaskbar.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@ -446,6 +447,14 @@ void ProcessingDialog::startNextJob(void)
|
|||||||
encoder = aacEncoder;
|
encoder = aacEncoder;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case SettingsModel::FLACEncoder:
|
||||||
|
{
|
||||||
|
FLACEncoder *flacEncoder = new FLACEncoder();
|
||||||
|
flacEncoder->setBitrate(m_settings->compressionBitrate());
|
||||||
|
flacEncoder->setRCMode(m_settings->compressionRCMode());
|
||||||
|
encoder = flacEncoder;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw "Unsupported encoder!";
|
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->fileAlbum().isEmpty()) result.setFileAlbum(m_metaInfo->fileAlbum());
|
||||||
if(!m_metaInfo->fileGenre().isEmpty()) result.setFileGenre(m_metaInfo->fileGenre());
|
if(!m_metaInfo->fileGenre().isEmpty()) result.setFileGenre(m_metaInfo->fileGenre());
|
||||||
if(m_metaInfo->fileYear()) result.setFileYear(m_metaInfo->fileYear());
|
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());
|
if(!m_metaInfo->fileComment().isEmpty()) result.setFileComment(m_metaInfo->fileComment());
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
147
src/Encoder_FLAC.cpp
Normal file
147
src/Encoder_FLAC.cpp
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// LameXP - Audio Encoder Front-End
|
||||||
|
// Copyright (C) 2004-2010 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
|
||||||
|
// 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 <QProcess>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
42
src/Encoder_FLAC.h
Normal file
42
src/Encoder_FLAC.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// LameXP - Audio Encoder Front-End
|
||||||
|
// Copyright (C) 2004-2010 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
|
||||||
|
// 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 <QObject>
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
@ -317,8 +317,7 @@ void MetaInfoModel::editItem(const QModelIndex &index, QWidget *parent)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
QStringList options;
|
QStringList options;
|
||||||
options << "Unspecified (copy from source file)";
|
options << "Unspecified (copy from source file)" << "Generate from list position";
|
||||||
options << "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);
|
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)
|
if(ok)
|
||||||
{
|
{
|
||||||
|
@ -48,7 +48,7 @@ static const struct lamexp_tool_t g_lamexp_tools[] =
|
|||||||
{"153f4274702f3629093b561a31dbf50e2c146305", "alac.exe"},
|
{"153f4274702f3629093b561a31dbf50e2c146305", "alac.exe"},
|
||||||
{"4ecc017a66fe43092110f11494f384e57d99280d", "elevator.exe"},
|
{"4ecc017a66fe43092110f11494f384e57d99280d", "elevator.exe"},
|
||||||
{"097dd004f44dbda57dbaeb5f15b34a220724ad60", "faad.exe"},
|
{"097dd004f44dbda57dbaeb5f15b34a220724ad60", "faad.exe"},
|
||||||
{"070bf98f78e572a97e4703ef5720c682567a6a56", "flac.exe"},
|
{"133171ac21f083d565ee9c33ef9cd92fc966811e", "flac.exe"},
|
||||||
{"cf379081035ae6bfb6f7bc22f13bfb7ac6302ac5", "gpgv.exe"},
|
{"cf379081035ae6bfb6f7bc22f13bfb7ac6302ac5", "gpgv.exe"},
|
||||||
{"d837bf6ee4dab557d8b02d46c75a24e58980fffa", "gpgv.gpg"},
|
{"d837bf6ee4dab557d8b02d46c75a24e58980fffa", "gpgv.gpg"},
|
||||||
{"143fc001a2f6c56fe1b9e6f8a2eb2b53b9e1e504", "lame.exe"},
|
{"143fc001a2f6c56fe1b9e6f8a2eb2b53b9e1e504", "lame.exe"},
|
||||||
|
Loading…
Reference in New Issue
Block a user