Refactor supportedFileExts from AudioFileProcessor

Refactor supported file extensions from AudioFileProcessor to
sampleBuffer, where the magic really happens. Change the hard-
coded MessageBox explaining supported formats to the real deal.
Also added modelines and switched spaces to tabs in the files
affected.
This commit is contained in:
Andrew Kelley
2009-07-16 04:34:11 -07:00
parent c7205351c2
commit 2aae228af4
8 changed files with 57 additions and 21 deletions

1
TODO
View File

@@ -55,7 +55,6 @@ Andrew Kelley's todo:
* when you press down or up while browsing the resource browser, it should
play the sample
* select the output file format based on what you selected in file->save as
* ability to read mp3 samples
* load asdlol.mmpz. if you render it without playing it, or if you play it
the first time, you hear unwanted artifacts.

View File

@@ -215,3 +215,5 @@ private:
#endif
/* vim: set tw=0 noexpandtab: */

View File

@@ -46,6 +46,11 @@ class EXPORT sampleBuffer : public QObject, public sharedObject
{
Q_OBJECT
public:
static const char * supportedExts[];
QString niceListOfExts() const;
class EXPORT handleState
{
public:
@@ -254,4 +259,4 @@ signals:
#endif
/* vim: set tw=0 expandtab: */
/* vim: set tw=0 noexpandtab: */

View File

@@ -46,9 +46,6 @@
#undef SINGLE_SOURCE_COMPILE
#include "embed.cpp"
static const char * __supportedExts[] =
{ "wav", "ogg", "ds", "spx", "au", "voc", "aif", "aiff", "flac", "raw", "mp3",
NULL };
extern "C"
{
@@ -65,7 +62,7 @@ plugin::descriptor PLUGIN_EXPORT audiofileprocessor_plugin_descriptor =
0x0100,
plugin::Instrument,
new pluginPixmapLoader( "logo" ),
__supportedExts,
sampleBuffer::supportedExts,
NULL
} ;
@@ -222,8 +219,8 @@ void audioFileProcessor::setAudioFile( const QString & _audio_file,
{
// is current channel-name equal to previous-filename??
if( _rename && ( getInstrumentTrack()->name() ==
QFileInfo( m_sampleBuffer.audioFile() ).fileName() ||
m_sampleBuffer.audioFile() == "" ) )
QFileInfo( m_sampleBuffer.audioFile() ).fileName() ||
m_sampleBuffer.audioFile() == "" ) )
{
// then set it to new one
getInstrumentTrack()->setName( QFileInfo( _audio_file).fileName() );
@@ -503,3 +500,4 @@ plugin * PLUGIN_EXPORT lmms_plugin_main( model *, void * _data )
#include "moc_audio_file_processor.cxx"
/* vim: set tw=0 expandtab: */

View File

@@ -1,6 +1,6 @@
/*
* audio_file_processor.h - declaration of class audioFileProcessor
* (instrument-plugin for using audio-files)
* (instrument-plugin for using audio-files)
*
* Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
@@ -128,3 +128,5 @@ private:
#endif
/* vim: set tw=0 noexpandtab: */

View File

@@ -180,4 +180,4 @@ bool LameLibrary::isLoaded()
return m_lameLib != NULL;
}
/* vim: set tw=0 expandtab: */
/* vim: set tw=0 noexpandtab: */

View File

@@ -155,10 +155,10 @@ int main( int argc, char * * argv )
printf( "\nLinux MultiMedia Studio %s\n"
"Copyright (c) 2004-2008 LMMS developers.\n\n"
"usage: lmms [ -r <project file> ] [ options ]\n"
" [ -u <in> <out> ]\n"
" [ -d <in> ]\n"
" [ -h ]\n"
" [ <file to load> ]\n\n"
" [ -u <in> <out> ]\n"
" [ -d <in> ]\n"
" [ -h ]\n"
" [ <file to load> ]\n\n"
"-r, --render <project file> render given project file\n"
"-o, --output <file> render into <file>\n"
"-f, --output-format <format> specify format of render-output where\n"
@@ -227,10 +227,10 @@ int main( int argc, char * * argv )
eff = projectRenderer::OggFile;
}
#endif
else if( ext == "mp3" )
{
eff = projectRenderer::Mp3File;
}
else if( ext == "mp3" )
{
eff = projectRenderer::Mp3File;
}
else
{
printf( "\nInvalid output format %s.\n\n"
@@ -522,3 +522,5 @@ int main( int argc, char * * argv )
#endif
/* vim: set tw=0 noexpandtab: */

View File

@@ -66,6 +66,21 @@
#include "lame_library.h"
const char * sampleBuffer::supportedExts[] = {
"wav",
"ogg",
"ds",
"spx",
"au",
"voc",
"aif",
"aiff",
"flac",
"raw",
"mp3",
NULL
};
sampleBuffer::sampleBuffer( const QString & _audio_file,
bool _is_base64_data ) :
m_audioFile( ( _is_base64_data == true ) ? "" : _audio_file ),
@@ -260,7 +275,8 @@ void sampleBuffer::update( bool _keep_settings )
m_loopStartFrame = m_startFrame = 0;
m_loopEndFrame = m_endFrame = 1;
QString decoders = tr( "wav, ogg, mp3" );
// TODO: this list probably shouldn't be hardcoded
QString decoders = niceListOfExts();
QMessageBox::information( NULL,
QObject::tr( "Unrecognized audio format" ),
QObject::tr( "None of the available audio decoders "
@@ -292,10 +308,22 @@ void sampleBuffer::update( bool _keep_settings )
}
QString sampleBuffer::niceListOfExts() const
{
QString ret = "";
for( const char * * i = supportedExts; *i; ++i )
{
ret.append(*i);
if( *(i+1) )
ret.append(", ");
}
return ret;
}
void sampleBuffer::normalizeSampleRate( const sample_rate_t _src_sr,
bool _keep_settings )
bool _keep_settings )
{
// do samplerate-conversion to our default-samplerate
if( _src_sr != engine::getMixer()->baseSampleRate() )
@@ -1328,4 +1356,4 @@ sampleBuffer::handleState::~handleState()
#endif
/* vim: set tw=0 expandtab: */
/* vim: set tw=0 noexpandtab: */