* rewrote the way plugins can handle certain filetypes

* rewrote various parts of file-browser to be less redundant and more stable (closes #2071891)



git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1582 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-09-07 22:38:23 +00:00
parent 9667fecd8b
commit fa1a9f4967
23 changed files with 354 additions and 400 deletions

View File

@@ -173,17 +173,9 @@ void audioFileProcessor::loadSettings( const QDomElement & _this )
void audioFileProcessor::setParameter( const QString & _param,
const QString & _value )
void audioFileProcessor::loadFile( const QString & _file )
{
if( _param == "samplefile" )
{
setAudioFile( _value );
}
else if( _param == "sampledata" )
{
m_sampleBuffer.loadFromBase64( _value );
}
setAudioFile( _file );
}

View File

@@ -52,8 +52,7 @@ public:
QDomElement & _parent );
virtual void loadSettings( const QDomElement & _this );
virtual void setParameter( const QString & _param,
const QString & _value );
virtual void loadFile( const QString & _file );
virtual QString nodeName( void ) const;

View File

@@ -519,26 +519,26 @@ bool flpImport::tryImport( trackContainer * _tc )
"created so far\n" );
break;
}
QString dir = text;
/* if( dir.mid( 1, 11 ) == "Instruments" )
QString f = text;
/* if( f.mid( 1, 11 ) == "Instruments" )
{
dir = "\\Patches\\Packs" +
dir.mid( 12 );
f = "\\Patches\\Packs" +
f.mid( 12 );
}*/
dir.replace( '\\', QDir::separator() );
f.replace( '\\', QDir::separator() );
if( QFileInfo( configManager::inst()->flDir() +
"/Data/" ).exists() )
{
dir = configManager::inst()->flDir() +
"/Data/" + dir;
f = configManager::inst()->flDir() +
"/Data/" + f;
}
else
{
// FL 3 compat
dir = configManager::inst()->flDir() +
"/Samples/" + dir;
f = configManager::inst()->flDir() +
"/Samples/" + f;
}
it_inst->setParameter( "samplefile", dir );
it_inst->loadFile( f );
break;
}

View File

@@ -337,10 +337,9 @@ invalid_format:
const QStringList files = QDir( dir ).
entryList( QStringList(
filter ) );
if( !files.empty() && !sample_loaded )
if( it_inst && !files.empty() && !sample_loaded )
{
it_inst->setParameter( "samplefile",
dir+files.front() );
it_inst->loadFile( dir+files.front() );
sample_loaded = TRUE;
}
break;

View File

@@ -238,13 +238,14 @@ void sf2Instrument::loadSettings( const QDomElement & _this )
void sf2Instrument::setParameter( const QString & _param,
const QString & _value )
void sf2Instrument::loadFile( const QString & _file )
{
if( _param == "samplefile" )
{
openFile( _value );
}
openFile( _file );
updatePatch();
// for some reason we've to call that, otherwise preview of a
// soundfont for the first time fails
updateSampleRate();
}

View File

@@ -62,8 +62,7 @@ public:
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
virtual void loadSettings( const QDomElement & _this );
virtual void setParameter( const QString & _param,
const QString & _value );
virtual void loadFile( const QString & _file );
virtual QString nodeName( void ) const;

View File

@@ -289,21 +289,6 @@ void tripleOscillator::loadSettings( const QDomElement & _this )
void tripleOscillator::setParameter( const QString & _param,
const QString & _value )
{
if( _param == "samplefile" )
{
for( int i = 0; i < NUM_OF_OSCILLATORS; ++i )
{
m_osc[i]->m_sampleBuffer->setAudioFile( _value );
}
}
}
QString tripleOscillator::nodeName( void ) const
{
return( tripleoscillator_plugin_descriptor.name );

View File

@@ -105,9 +105,6 @@ public:
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
virtual void loadSettings( const QDomElement & _this );
virtual void setParameter( const QString & _param,
const QString & _value );
virtual QString nodeName( void ) const;
virtual f_cnt_t desiredReleaseFrames( void ) const

View File

@@ -92,7 +92,7 @@ vestigeInstrument::~vestigeInstrument()
void vestigeInstrument::loadSettings( const QDomElement & _this )
{
setParameter( "plugin", _this.attribute( "plugin" ) );
loadFile( _this.attribute( "plugin" ) );
m_pluginMutex.lock();
if( m_plugin != NULL )
{
@@ -126,76 +126,58 @@ QString vestigeInstrument::nodeName( void ) const
void vestigeInstrument::setParameter( const QString & _param,
const QString & _value )
void vestigeInstrument::loadFile( const QString & _file )
{
if( _param == "plugin" && _value != "" )
m_pluginMutex.lock();
const bool set_ch_name = ( m_plugin != NULL &&
getInstrumentTrack()->name() == m_plugin->name() ) ||
getInstrumentTrack()->name() ==
instrumentTrack::tr( "Default preset" );
m_pluginMutex.unlock();
closePlugin();
m_pluginDLL = _file;
textFloat * tf = textFloat::displayMessage(
tr( "Loading plugin" ),
tr( "Please wait while loading VST-plugin..." ),
PLUGIN_NAME::getIconPixmap( "logo", 24, 24 ), 0 );
m_pluginMutex.lock();
m_plugin = new vstPlugin( m_pluginDLL );
if( m_plugin->failed() )
{
m_pluginMutex.lock();
const bool set_ch_name = ( m_plugin != NULL &&
getInstrumentTrack()->name() == m_plugin->name() ) ||
getInstrumentTrack()->name() ==
instrumentTrack::tr( "Default" );
m_pluginMutex.unlock();
closePlugin();
m_pluginDLL = _value;
textFloat * tf = textFloat::displayMessage(
tr( "Loading plugin" ),
tr( "Please wait while loading VST-plugin..." ),
PLUGIN_NAME::getIconPixmap( "logo", 24, 24 ),
0 );
m_pluginMutex.lock();
m_plugin = new vstPlugin( m_pluginDLL );
if( m_plugin->failed() )
{
m_pluginMutex.unlock();
closePlugin();
delete tf;
QMessageBox::information( 0,
tr( "Failed loading VST-plugin" ),
tr( "The VST-plugin %1 could not "
"be loaded for some reason.\n"
"If it runs with other VST-"
"software under Linux, please "
"contact an LMMS-developer!"
).arg( m_pluginDLL ),
QMessageBox::Ok );
return;
}
/* if( m_plugin->vstVersion() < 2000 )
{
QMessageBox::information( this,
tr( "VST-plugin too old" ),
tr( "The version of VST-plugin %1 "
"is smaller than 2, which "
"isn't supported." ).arg(
m_pluginDLL ),
QMessageBox::Ok );
closePlugin();
return;
}*/
m_plugin->showEditor();
connect( engine::getSong(), SIGNAL( tempoChanged( bpm_t ) ),
m_plugin, SLOT( setTempo( bpm_t ) ) );
m_plugin->setTempo( engine::getSong()->getTempo() );
connect( engine::getMixer(), SIGNAL( sampleRateChanged() ),
m_plugin, SLOT( updateSampleRate() ) );
if( set_ch_name == TRUE )
{
getInstrumentTrack()->setName( m_plugin->name() );
}
if( m_plugin->pluginWidget() != NULL )
{
/* m_plugin->pluginWidget()->setWindowIcon(
getInstrumentTrack()->windowIcon() );*/
}
m_pluginMutex.unlock();
// update();
emit dataChanged();
delete tf;
QMessageBox::information( 0,
tr( "Failed loading VST-plugin" ),
tr( "The VST-plugin %1 could not "
"be loaded for some reason.\n"
"If it runs with other VST-"
"software under Linux, please "
"contact an LMMS-developer!"
).arg( m_pluginDLL ),
QMessageBox::Ok );
return;
}
m_plugin->showEditor();
connect( engine::getSong(), SIGNAL( tempoChanged( bpm_t ) ),
m_plugin, SLOT( setTempo( bpm_t ) ) );
m_plugin->setTempo( engine::getSong()->getTempo() );
connect( engine::getMixer(), SIGNAL( sampleRateChanged() ),
m_plugin, SLOT( updateSampleRate() ) );
if( set_ch_name )
{
getInstrumentTrack()->setName( m_plugin->name() );
}
m_pluginMutex.unlock();
emit dataChanged();
delete tf;
}
@@ -385,7 +367,7 @@ void vestigeInstrumentView::openPlugin( void )
return;
}
engine::getMixer()->lock();
m_vi->setParameter( "plugin", ofd.selectedFiles()[0] );
m_vi->loadFile( ofd.selectedFiles()[0] );
engine::getMixer()->unlock();
}
}

View File

@@ -58,8 +58,7 @@ public:
virtual QString nodeName( void ) const;
virtual void setParameter( const QString & _param,
const QString & _value );
virtual void loadFile( const QString & _file );
virtual bool supportsParallelizing( void ) const
{