From 03d3548ba1807ca8356133f0322be949c035ee9f Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sun, 29 Nov 2009 15:29:46 +0100 Subject: [PATCH] ProjectRenderer: renamed OutputSettings to EncoderSettings + Doxygen comments Renamed the ProjectRenderer::OutputSettings structure to ProjectRenderer::EncoderSettings to better reflect its meaning. Additionally added some basic Doxygen comments. --- include/ProjectRenderer.h | 59 +++++++++++++++++++++------------ src/core/ProjectRenderer.cpp | 24 ++++++++------ src/core/main.cpp | 11 +++--- src/gui/ExportProjectDialog.cpp | 4 +-- 4 files changed, 57 insertions(+), 41 deletions(-) diff --git a/include/ProjectRenderer.h b/include/ProjectRenderer.h index 68bcf1b7c..4c01d809a 100644 --- a/include/ProjectRenderer.h +++ b/include/ProjectRenderer.h @@ -31,38 +31,41 @@ class QTimer; +/*! \brief The ProjectRenderer class provides functionality to render current Song into a file. */ class ProjectRenderer : public QThread { Q_OBJECT public: + /*! Lists all supported output file formats. */ enum ExportFileFormats { - WaveFile, - OggFile, - Mp3File, - FlacFile, + WaveFile, /*!< Uncompressed WAV file */ + OggFile, /*!< Vorbis-encoded OGG file */ + Mp3File, /*!< MP3 file encoded via LAME */ + FlacFile, /*!< Free Lossless Audio Codec */ NumFileFormats } ; static const char * EFF_ext[]; + /*! Lists all supported sample type depths. */ enum Depths { - Depth_16Bit, - Depth_24Bit, - Depth_32Bit, + Depth_16Bit, /*!< 16 bit signed integer */ + Depth_24Bit, /*!< 24 bit floating point */ + Depth_32Bit, /*!< 32 bit floating point */ NumDepths } ; - struct OutputSettings + /*! Settings for the output file encoder. */ + struct EncoderSettings { - sample_rate_t samplerate; - bool vbr; - int bitrate; - Depths depth; + sample_rate_t samplerate; /*!< Desired output sample rate */ + bool vbr; /*!< Use variable bitrate encoding */ + int bitrate; /*!< Desired bitrate (kbps) */ + Depths depth; /*!< Depth of samples */ - OutputSettings( sample_rate_t _sr, bool _vbr, int _bitrate, - Depths _d ) : + EncoderSettings( sample_rate_t _sr, bool _vbr, int _bitrate, Depths _d ) : samplerate( _sr ), vbr( _vbr ), bitrate( _bitrate ), @@ -71,30 +74,40 @@ public: } } ; - - ProjectRenderer( const AudioOutputContext::QualitySettings & _qs, - const OutputSettings & _os, - ExportFileFormats _file_format, - const QString & _out_file ); + /*! \brief Constructs a ProjectRenderer object with given settings. + * + * \param qualitySettings The desired quality settings for the AudioOutputContext + * \param encoderSettings The desired settings for the output file encoder + * \param fileFormat One of the file formats listed in the ExportFileFormats enumeration + * \param outFile The output file name + */ + ProjectRenderer( const AudioOutputContext::QualitySettings & qualitySettings, + const EncoderSettings & encoderSettings, + ExportFileFormats fileFormat, + const QString & outFile ); virtual ~ProjectRenderer(); + /*! \brief Returns whether the ProjectRenderer was initialized properly. */ bool isReady() const { return m_fileDev != NULL; } - static ExportFileFormats getFileFormatFromExtension( - const QString & _ext ); + static ExportFileFormats getFileFormatFromExtension( const QString & _ext ); - void setConsoleUpdateTimer(QTimer * t) + void setConsoleUpdateTimer( QTimer * t ) { m_consoleUpdateTimer = t; } + public slots: + /*! \brief Sets according AudioOutputContext for Mixer and starts render thread. */ void startProcessing(); + /*! \brief Aborts the processing and cleans up resources. */ void abortProcessing(); + /*! \brief Prints current render progress to the console. */ void updateConsoleProgress(); @@ -103,6 +116,7 @@ signals: private slots: + /*! \brief Finalizes the render process and restores Mixer's AudioOutputContext. */ void finishProcessing(); @@ -120,6 +134,7 @@ private: } ; +/*! \brief Holds information about a certain file encoder. */ struct FileEncodeDevice { ProjectRenderer::ExportFileFormats m_fileFormat; diff --git a/src/core/ProjectRenderer.cpp b/src/core/ProjectRenderer.cpp index 887f45f6e..d5bcc926f 100644 --- a/src/core/ProjectRenderer.cpp +++ b/src/core/ProjectRenderer.cpp @@ -79,9 +79,9 @@ const char * ProjectRenderer::EFF_ext[] = {"wav", "ogg", "mp3", "flac"}; ProjectRenderer::ProjectRenderer( const AudioOutputContext::QualitySettings & _qs, - const OutputSettings & _os, - ExportFileFormats _file_format, - const QString & _out_file ) : + const EncoderSettings & es, + ExportFileFormats fileFormat, + const QString & outFile ) : QThread( engine::getMixer() ), m_fileDev( NULL ), m_progress( 0 ), @@ -90,18 +90,18 @@ ProjectRenderer::ProjectRenderer( m_context = new AudioOutputContext( engine::getMixer(), NULL, _qs ); - if( __fileEncodeDevices[_file_format].m_getDevInst == NULL ) + if( __fileEncodeDevices[fileFormat].m_getDevInst == NULL ) { return; } bool success_ful = false; - m_fileDev = __fileEncodeDevices[_file_format].m_getDevInst( - _os.samplerate, DEFAULT_CHANNELS, success_ful, - _out_file, _os.vbr, - _os.bitrate, _os.bitrate - 64, _os.bitrate + 64, - _os.depth == Depth_32Bit ? 32 : - ( _os.depth == Depth_24Bit ? 24 : 16 ), + m_fileDev = __fileEncodeDevices[fileFormat].m_getDevInst( + es.samplerate, DEFAULT_CHANNELS, success_ful, + outFile, es.vbr, + es.bitrate, es.bitrate - 64, es.bitrate + 64, + es.depth == Depth_32Bit ? 32 : + ( es.depth == Depth_24Bit ? 24 : 16 ), m_context ); if( success_ful == false ) { @@ -119,6 +119,7 @@ ProjectRenderer::ProjectRenderer( ProjectRenderer::~ProjectRenderer() { delete m_fileDev; + delete m_context; } @@ -182,7 +183,8 @@ void ProjectRenderer::updateConsoleProgress() char buf[80]; char prog[cols+1]; - if( m_fileDev == NULL ){ + if( m_fileDev == NULL ) + { qWarning("Error occured. Aborting render."); m_consoleUpdateTimer->stop(); delete m_consoleUpdateTimer; diff --git a/src/core/main.cpp b/src/core/main.cpp index ec5b46b63..f9aade288 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -22,7 +22,6 @@ * */ - #include #include #include @@ -128,8 +127,8 @@ int main( int argc, char * * argv ) AudioOutputContext::QualitySettings qs( AudioOutputContext::QualitySettings::Preset_HighQuality ); - ProjectRenderer::OutputSettings os( 44100, false, 160, - ProjectRenderer::Depth_16Bit ); + ProjectRenderer::EncoderSettings es( 44100, false, 160, + ProjectRenderer::Depth_16Bit ); ProjectRenderer::ExportFileFormats eff = ProjectRenderer::WaveFile; @@ -251,7 +250,7 @@ int main( int argc, char * * argv ) sample_rate_t sr = QString( argv[i + 1] ).toUInt(); if( sr >= 44100 && sr <= 192000 ) { - os.samplerate = sr; + es.samplerate = sr; } else { @@ -268,7 +267,7 @@ int main( int argc, char * * argv ) int br = QString( argv[i + 1] ).toUInt(); if( br >= 64 && br <= 384 ) { - os.bitrate = br; + es.bitrate = br; } else { @@ -515,7 +514,7 @@ int main( int argc, char * * argv ) if( !render_out.isEmpty() ) { // create renderer - ProjectRenderer * r = new ProjectRenderer( qs, os, eff, + ProjectRenderer * r = new ProjectRenderer( qs, es, eff, render_out + QString( ProjectRenderer::EFF_ext[eff] ) ); QCoreApplication::instance()->connect( r, SIGNAL( finished() ), SLOT( quit() ) ); diff --git a/src/gui/ExportProjectDialog.cpp b/src/gui/ExportProjectDialog.cpp index b8c8ccf8b..3d898e93e 100644 --- a/src/gui/ExportProjectDialog.cpp +++ b/src/gui/ExportProjectDialog.cpp @@ -155,13 +155,13 @@ void ExportProjectDialog::startBtnClicked() ui->sampleExactControllersCB->isChecked(), ui->aliasFreeOscillatorsCB->isChecked() ); - ProjectRenderer::OutputSettings os = ProjectRenderer::OutputSettings( + ProjectRenderer::EncoderSettings es = ProjectRenderer::EncoderSettings( ui->samplerateCB->currentText().section( " ", 0, 0 ).toUInt(), false, ui->bitrateCB->currentText().section( " ", 0, 0 ).toUInt(), static_cast( ui->depthCB->currentIndex() ) ); - m_renderer = new ProjectRenderer( qs, os, ft, m_fileName ); + m_renderer = new ProjectRenderer( qs, es, ft, m_fileName ); if( m_renderer->isReady() ) { updateTitleBar( 0 );