Support for Wave (PCM) output.

This commit is contained in:
LoRd_MuldeR 2010-12-17 01:12:12 +01:00
parent a8554a2d5c
commit e189eb08c2
6 changed files with 199 additions and 4 deletions

View File

@ -366,6 +366,10 @@
RelativePath=".\src\Encoder_Vorbis.cpp" RelativePath=".\src\Encoder_Vorbis.cpp"
> >
</File> </File>
<File
RelativePath=".\src\Encoder_Wave.cpp"
>
</File>
<File <File
RelativePath=".\src\Genres.cpp" RelativePath=".\src\Genres.cpp"
> >
@ -944,6 +948,40 @@
/> />
</FileConfiguration> </FileConfiguration>
</File> </File>
<File
RelativePath=".\src\Encoder_Wave.h"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="MOC &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; -o &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot; &quot;$(InputPath)&quot;"
Outputs="&quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="MOC &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; -o &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot; &quot;$(InputPath)&quot;"
Outputs="&quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
/>
</FileConfiguration>
<FileConfiguration
Name="Release_Static|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="MOC &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; -o &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot; &quot;$(InputPath)&quot;"
Outputs="&quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
/>
</FileConfiguration>
</File>
<File <File
RelativePath=".\src\Genres.h" RelativePath=".\src\Genres.h"
> >
@ -1352,6 +1390,10 @@
RelativePath=".\tmp\MOC_Encoder_Vorbis.cpp" RelativePath=".\tmp\MOC_Encoder_Vorbis.cpp"
> >
</File> </File>
<File
RelativePath=".\tmp\MOC_Encoder_Wave.cpp"
>
</File>
<File <File
RelativePath=".\tmp\MOC_Model_FileList.cpp" RelativePath=".\tmp\MOC_Model_FileList.cpp"
> >

View File

@ -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 157 #define VER_LAMEXP_BUILD 161
#define VER_LAMEXP_SUFFIX TechPreview #define VER_LAMEXP_SUFFIX TechPreview
/* /*

View File

@ -599,9 +599,10 @@ void MainWindow::encodeButtonClicked(void)
case SettingsModel::VorbisEncoder: case SettingsModel::VorbisEncoder:
case SettingsModel::AACEncoder: case SettingsModel::AACEncoder:
case SettingsModel::FLACEncoder: case SettingsModel::FLACEncoder:
case SettingsModel::PCMEncoder:
break; break;
default: 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!"); QMessageBox::warning(this, "LameXP", "Sorry, an unsupported encoder has been chosen!");
tabWidget->setCurrentIndex(3); tabWidget->setCurrentIndex(3);
return; return;
} }
@ -815,6 +816,10 @@ void MainWindow::styleActionActivated(QAction *action)
*/ */
void MainWindow::outputFolderViewClicked(const QModelIndex &index) void MainWindow::outputFolderViewClicked(const QModelIndex &index)
{ {
if(outputFolderView->currentIndex() != index)
{
outputFolderView->setCurrentIndex(index);
}
QString selectedDir = m_fileSystemModel->filePath(index); QString selectedDir = m_fileSystemModel->filePath(index);
if(selectedDir.length() < 3) selectedDir.append(QDir::separator()); if(selectedDir.length() < 3) selectedDir.append(QDir::separator());
outputFolderLabel->setText(selectedDir); outputFolderLabel->setText(selectedDir);
@ -1287,9 +1292,12 @@ void MainWindow::restoreCursor(void)
* Show context menu for source files * Show context menu for source files
*/ */
void MainWindow::sourceFilesContextMenu(const QPoint &pos) void MainWindow::sourceFilesContextMenu(const QPoint &pos)
{
if(pos.x() <= sourceFileView->width() && pos.y() <= sourceFileView->height() && pos.x() >= 0 && pos.y() >= 0)
{ {
m_sourceFilesContextMenu->popup(sourceFileView->mapToGlobal(pos)); m_sourceFilesContextMenu->popup(sourceFileView->mapToGlobal(pos));
} }
}
/* /*
* Open selected file in external player * Open selected file in external player
@ -1365,9 +1373,13 @@ void MainWindow::findFileContextActionTriggered(void)
* Show context menu for output folder * Show context menu for output folder
*/ */
void MainWindow::outputFolderContextMenu(const QPoint &pos) void MainWindow::outputFolderContextMenu(const QPoint &pos)
{
if(pos.x() <= outputFolderView->width() && pos.y() <= outputFolderView->height() && pos.x() >= 0 && pos.y() >= 0)
{ {
m_outputFolderContextMenu->popup(outputFolderView->mapToGlobal(pos)); m_outputFolderContextMenu->popup(outputFolderView->mapToGlobal(pos));
} }
}
/* /*
* Show selected folder in explorer * Show selected folder in explorer

View File

@ -32,6 +32,7 @@
#include "Encoder_Vorbis.h" #include "Encoder_Vorbis.h"
#include "Encoder_AAC.h" #include "Encoder_AAC.h"
#include "Encoder_FLAC.h" #include "Encoder_FLAC.h"
#include "Encoder_Wave.h"
#include "WinSevenTaskbar.h" #include "WinSevenTaskbar.h"
#include <QApplication> #include <QApplication>
@ -455,6 +456,14 @@ void ProcessingDialog::startNextJob(void)
encoder = flacEncoder; encoder = flacEncoder;
} }
break; break;
case SettingsModel::PCMEncoder:
{
WaveEncoder *waveEncoder = new WaveEncoder();
waveEncoder->setBitrate(m_settings->compressionBitrate());
waveEncoder->setRCMode(m_settings->compressionRCMode());
encoder = waveEncoder;
}
break;
default: default:
throw "Unsupported encoder!"; throw "Unsupported encoder!";
} }

93
src/Encoder_Wave.cpp Normal file
View File

@ -0,0 +1,93 @@
///////////////////////////////////////////////////////////////////////////////
// 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_Wave.h"
#include "Global.h"
#include "Model_Settings.h"
#include <QDir>
#include <Shellapi.h>
#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()))
#define FIX_SEPARATORS(STR) for(int i = 0; STR[i]; i++) { if(STR[i] == L'/') STR[i] = L'\\'; }
WaveEncoder::WaveEncoder(void)
{
}
WaveEncoder::~WaveEncoder(void)
{
}
bool WaveEncoder::encode(const QString &sourceFile, const AudioFileModel &metaInfo, const QString &outputFile, volatile bool *abortFlag)
{
emit messageLogged(QString("Moving file \"%1\" to \"%2\"").arg(sourceFile, outputFile));
SHFILEOPSTRUCTW fileOperation;
memset(&fileOperation, 0, sizeof(SHFILEOPSTRUCTW));
fileOperation.wFunc = FO_MOVE;
fileOperation.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR | FOF_NOERRORUI | FOF_FILESONLY;
size_t srcLen = wcslen(reinterpret_cast<const wchar_t*>(sourceFile.utf16())) + 3;
wchar_t *srcBuffer = new wchar_t[srcLen];
memset(srcBuffer, 0, srcLen * sizeof(wchar_t));
wcscpy_s(srcBuffer, srcLen, reinterpret_cast<const wchar_t*>(sourceFile.utf16()));
FIX_SEPARATORS (srcBuffer);
fileOperation.pFrom = srcBuffer;
size_t outLen = wcslen(reinterpret_cast<const wchar_t*>(outputFile.utf16())) + 3;
wchar_t *outBuffer = new wchar_t[outLen];
memset(outBuffer, 0, outLen * sizeof(wchar_t));
wcscpy_s(outBuffer, outLen, reinterpret_cast<const wchar_t*>(outputFile.utf16()));
FIX_SEPARATORS (outBuffer);
fileOperation.pTo = outBuffer;
emit statusUpdated(0);
int result = SHFileOperation(&fileOperation);
emit statusUpdated(100);
emit messageLogged(QString().sprintf("\nExited with code: 0x%04X", result));
delete [] srcBuffer;
delete [] outBuffer;
return (result == 0 && fileOperation.fAnyOperationsAborted == false);
}
QString WaveEncoder::extension(void)
{
return "wav";
}
bool WaveEncoder::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;
}

39
src/Encoder_Wave.h Normal file
View File

@ -0,0 +1,39 @@
///////////////////////////////////////////////////////////////////////////////
// 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 WaveEncoder : public AbstractEncoder
{
Q_OBJECT
public:
WaveEncoder(void);
~WaveEncoder(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);
};