* 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

@@ -1,5 +1,41 @@
2008-09-07 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
* plugins/patman/patman.cpp:
* plugins/patman/patman.h:
- apply release of 128 frames
- enable loop mode per default
* plugins/patman/patman.cpp:
* plugins/patman/patman.h:
* plugins/triple_oscillator/triple_oscillator.h:
* plugins/triple_oscillator/triple_oscillator.cpp:
* plugins/audio_file_processor/audio_file_processor.cpp:
* plugins/audio_file_processor/audio_file_processor.h:
* plugins/sf2_player/sf2_player.cpp:
* plugins/sf2_player/sf2_player.h:
* plugins/vestige/vestige.cpp:
* plugins/vestige/vestige.h:
* plugins/flp_import/flp_import.cpp:
* plugins/midi_import/midi_import.cpp:
* include/engine.h:
* include/file_browser.h:
* include/preset_preview_play_handle.h:
* include/plugin.h:
* include/remote_plugin.h:
* include/sample_play_handle.h:
* src/core/engine.cpp:
* src/core/plugin.cpp:
* src/core/preset_preview_play_handle.cpp:
* src/gui/file_browser.cpp:
* src/gui/main_window.cpp:
* src/gui/track_container_view.cpp:
- rewrote the way plugins can handle certain filetypes
- rewrote various parts of file-browser to be less redundant and
more stable (closes #2071891)
* data/themes/default/sample_file.png:
renamed from sound_file.png
* include/midi.h:
* src/core/midi/midi_client.cpp:
* src/core/midi/midi_port.cpp:

View File

@@ -143,9 +143,9 @@ public:
}
static void updateFramesPerTick( void );
static const QMap<QString, QString> & sampleExtensions( void )
static const QMap<QString, QString> & pluginFileHandling( void )
{
return( s_sampleExtensions );
return( s_pluginFileHandling );
}
@@ -172,9 +172,9 @@ private:
static projectNotes * s_projectNotes;
static ladspa2LMMS * s_ladspaManager;
static QMap<QString, QString> s_sampleExtensions;
static QMap<QString, QString> s_pluginFileHandling;
static void loadExtensions( void );
static void initPluginFileHandling( void );
} ;

View File

@@ -1,7 +1,7 @@
/*
* file_browser.h - include file for fileBrowser
*
* Copyright (c) 2004-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -38,6 +38,7 @@ class QColorGroup;
class QPixmap;
class fileItem;
class instrumentTrack;
class listView;
class playHandle;
class trackContainer;
@@ -90,6 +91,10 @@ protected:
private:
void handleFile( fileItem * _fi, instrumentTrack * _it );
void openInNewInstrumentTrack( trackContainer * _tc );
bool m_mousePressed;
QPoint m_pressPos;
@@ -98,8 +103,6 @@ private:
fileItem * m_contextMenuItem;
void openInNewInstrumentTrack( trackContainer * _tc );
private slots:
void activateListItem( QTreeWidgetItem * _item, int _column );
@@ -159,6 +162,28 @@ private:
class fileItem : public QTreeWidgetItem
{
public:
enum FileTypes
{
ProjectFile,
PresetFile,
SampleFile,
SoundFontFile,
PatchFile,
MidiFile,
FlpFile,
UnknownFile,
NumFileTypes
} ;
enum FileHandling
{
NotSupported,
LoadAsProject,
LoadAsPreset,
LoadByPlugin
} ;
fileItem( QTreeWidget * _parent, const QString & _name,
const QString & _path );
fileItem( QTreeWidgetItem * _parent, const QString & _name,
@@ -170,23 +195,16 @@ public:
text( 0 ) );
}
enum FileTypes
{
ProjectFile,
PresetFile,
SpecialPresetFile,
SampleFile,
MidiFile,
FlpFile,
UnknownFile,
NumFileTypes
} ;
inline FileTypes type( void )
inline FileTypes type( void ) const
{
return( m_type );
}
inline FileHandling handling( void ) const
{
return( m_handling );
}
QString extension( void );
static QString extension( const QString & _file );
@@ -201,11 +219,12 @@ private:
static QPixmap * s_midiFilePixmap;
static QPixmap * s_flpFilePixmap;
static QPixmap * s_unknownFilePixmap;
QString m_path;
FileTypes m_type;
FileHandling m_handling;
} ;
#endif

View File

@@ -167,10 +167,9 @@ public:
return( m_descriptor );
}
// plugins can overload this for making other classes able to change
// settings of the plugin without knowing the actual class
virtual void setParameter( const QString & _param,
const QString & _value );
// can be called if a file matching supportedFileTypes should be
// loaded/processed with the help of this plugin
virtual void loadFile( const QString & _file );
// plugins can overload this for making other classes able to query
// settings of the plugin without knowing the actual class

View File

@@ -1,6 +1,6 @@
/*
* preset_preview_play_handle.h - play-handle for playing a short preview-sound
* of a preset
* of a preset or a file processed by a plugin
*
* Copyright (c) 2005-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
@@ -38,7 +38,7 @@ class presetPreviewPlayHandle : public playHandle
{
public:
presetPreviewPlayHandle( const QString & _preset_file,
bool _special_preset = false );
bool _load_by_plugin = false );
virtual ~presetPreviewPlayHandle();
virtual void play( bool _try_parallelizing,

View File

@@ -850,7 +850,7 @@ remotePluginBase::message remotePluginBase::waitForMessage(
if( _busy_waiting && !messagesLeft() )
{
QCoreApplication::processEvents(
QEventLoop::AllEvents, 50 );
QEventLoop::ExcludeUserInputEvents, 50 );
continue;
}
#endif

View File

@@ -26,8 +26,6 @@
#ifndef _SAMPLE_PLAY_HANDLE_H
#define _SAMPLE_PLAY_HANDLE_H
#include <qobject.h>
#include "mixer.h"
#include "sample_buffer.h"
#include "automatable_model.h"

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
{

View File

@@ -62,7 +62,7 @@ projectJournal * engine::s_projectJournal = NULL;
ladspa2LMMS * engine::s_ladspaManager = NULL;
dummyTrackContainer * engine::s_dummyTC = NULL;
controllerRackView * engine::s_controllerRackView = NULL;
QMap<QString, QString> engine::s_sampleExtensions;
QMap<QString, QString> engine::s_pluginFileHandling;
@@ -71,7 +71,7 @@ void engine::init( const bool _has_gui )
{
s_hasGUI = _has_gui;
loadExtensions();
initPluginFileHandling();
s_projectJournal = new projectJournal;
s_mixer = new mixer;
@@ -165,7 +165,7 @@ void engine::updateFramesPerTick( void )
void engine::loadExtensions( void )
void engine::initPluginFileHandling( void )
{
QVector<plugin::descriptor> pluginDescriptors;
plugin::getDescriptorsOfAvailPlugins( pluginDescriptors );
@@ -180,7 +180,7 @@ void engine::loadExtensions( void )
for( QStringList::const_iterator itExt = ext.begin();
itExt != ext.end(); ++itExt )
{
s_sampleExtensions[*itExt] = it->name;
s_pluginFileHandling[*itExt] = it->name;
}
}
}

View File

@@ -76,7 +76,7 @@ plugin::~plugin()
void plugin::setParameter( const QString &, const QString & )
void plugin::loadFile( const QString & )
{
}

View File

@@ -105,7 +105,7 @@ previewTrackContainer * presetPreviewPlayHandle::s_previewTC;
presetPreviewPlayHandle::presetPreviewPlayHandle( const QString & _preset_file,
bool _special_preset ) :
bool _load_by_plugin ) :
playHandle( PresetPreviewHandle ),
m_previewNote( NULL )
{
@@ -120,7 +120,7 @@ presetPreviewPlayHandle::presetPreviewPlayHandle( const QString & _preset_file,
const bool j = engine::getProjectJournal()->isJournalling();
engine::getProjectJournal()->setJournalling( FALSE );
if( _special_preset )
if( _load_by_plugin )
{
instrument * i = s_previewTC->previewInstrumentTrack()->
getInstrument();
@@ -130,11 +130,11 @@ presetPreviewPlayHandle::presetPreviewPlayHandle( const QString & _preset_file,
{
i = s_previewTC->previewInstrumentTrack()->
loadInstrument(
engine::sampleExtensions()[ext] );
engine::pluginFileHandling()[ext] );
}
if( i != NULL )
{
i->setParameter( "samplefile", _preset_file );
i->loadFile( _preset_file );
}
}
else

View File

@@ -176,7 +176,7 @@ listView::listView( QWidget * _parent ) :
m_mousePressed( FALSE ),
m_pressPos(),
m_previewPlayHandle( NULL ),
m_pphMutex(),
m_pphMutex( QMutex::Recursive ),
m_contextMenuItem( NULL )
{
setColumnCount( 1 );
@@ -203,194 +203,11 @@ listView::~listView()
void listView::activateListItem( QTreeWidgetItem * _item, int _column )
{
fileItem * f = dynamic_cast<fileItem *>( _item );
if( f == NULL )
{
return;
}
if( f->type() == fileItem::SampleFile ||
f->type() == fileItem::SpecialPresetFile )
{
// samples are per default opened in bb-editor because they're
// likely drum-samples etc.
engine::getMixer()->lock();
instrumentTrack * it = dynamic_cast<instrumentTrack *>(
track::create( track::InstrumentTrack,
engine::getBBTrackContainer() ) );
#ifdef LMMS_DEBUG
assert( it != NULL );
#endif
instrument * inst = it->loadInstrument(
engine::sampleExtensions()[f->extension()] );
if( inst != NULL )
{
inst->setParameter( "samplefile", f->fullName() );
}
engine::getMixer()->unlock();
}
else if( f->type() == fileItem::PresetFile )
{
// presets are per default opened in bb-editor
multimediaProject mmp( f->fullName() );
instrumentTrack::removeMidiPortNode( mmp );
engine::getMixer()->lock();
instrumentTrack * it = dynamic_cast<instrumentTrack *>(
track::create( track::InstrumentTrack,
engine::getBBTrackContainer() ) );
if( it != NULL )
{
it->setSimpleSerializing();
it->loadSettings( mmp.content().toElement() );
}
engine::getMixer()->unlock();
}
else if( f->type() == fileItem::ProjectFile )
{
if( engine::getMainWindow()->mayChangeProject() )
{
engine::getSong()->loadProject( f->fullName() );
}
}
}
void listView::sendToActiveInstrumentTrack( void )
{
if( engine::getMainWindow()->workspace() == NULL )
{
return;
}
// get all windows opened in the workspace
QList<QMdiSubWindow*> pl = engine::getMainWindow()->workspace()->
subWindowList( QMdiArea::StackingOrder );
QListIterator<QMdiSubWindow *> w( pl );
w.toBack();
// now we travel through the window-list until we find an
// instrument-track
while( w.hasPrevious() )
{
instrumentTrackWindow * itw =
dynamic_cast<instrumentTrackWindow *>( w.previous()->
widget() );
if( itw != NULL && itw->isHidden() == FALSE )
{
// ok, it's an instrument-track, so we can apply the
// sample or the preset
engine::getMixer()->lock();
if( m_contextMenuItem->type() == fileItem::SampleFile ||
m_contextMenuItem->type() ==
fileItem::SpecialPresetFile )
{
QString e = m_contextMenuItem->extension();
instrument * i = itw->model()->getInstrument();
if( !i->getDescriptor()->supportsFileType( e ) )
{
i = itw->model()->loadInstrument(
engine::sampleExtensions()[e] );
}
i->setParameter( "samplefile",
m_contextMenuItem->fullName() );
}
else if( m_contextMenuItem->type() ==
fileItem::PresetFile )
{
multimediaProject mmp(
m_contextMenuItem->fullName() );
instrumentTrack::removeMidiPortNode( mmp );
itw->model()->setSimpleSerializing();
itw->model()->loadSettings(
mmp.content().toElement() );
}
engine::getMixer()->unlock();
break;
}
}
}
void listView::openInNewInstrumentTrack( trackContainer * _tc )
{
engine::getMixer()->lock();
if( m_contextMenuItem->type() == fileItem::SampleFile ||
m_contextMenuItem->type() == fileItem::SpecialPresetFile )
{
instrumentTrack * ct = dynamic_cast<instrumentTrack *>(
track::create( track::InstrumentTrack, _tc ) );
#ifdef LMMS_DEBUG
assert( ct != NULL );
#endif
instrument * i = ct->loadInstrument(
engine::sampleExtensions()
[m_contextMenuItem
->extension()] );
if( i != NULL )
{
i->setParameter( "samplefile",
m_contextMenuItem->fullName() );
}
//ct->toggledInstrumentTrackButton( TRUE );
}
else if( m_contextMenuItem->type() == fileItem::PresetFile )
{
multimediaProject mmp( m_contextMenuItem->fullName() );
instrumentTrack::removeMidiPortNode( mmp );
track * t = track::create( track::InstrumentTrack, _tc );
instrumentTrack * it = dynamic_cast<instrumentTrack *>( t );
if( it != NULL )
{
it->setSimpleSerializing();
it->loadSettings( mmp.content().toElement() );
}
}
engine::getMixer()->unlock();
}
void listView::openInNewInstrumentTrackBBE( void )
{
openInNewInstrumentTrack( engine::getBBTrackContainer() );
}
void listView::openInNewInstrumentTrackSE( void )
{
openInNewInstrumentTrack( engine::getSong() );
}
void listView::updateDirectory( QTreeWidgetItem * _item )
{
directory * dir = dynamic_cast<directory *>( _item );
if( dir != NULL )
{
dir->update();
}
}
void listView::contextMenuEvent( QContextMenuEvent * _e )
{
fileItem * f = dynamic_cast<fileItem *>( itemAt( _e->pos() ) );
if( f != NULL && ( f->type() == fileItem::SampleFile ||
f->type() == fileItem::SpecialPresetFile ||
f->type() == fileItem::PresetFile ) )
if( f != NULL && ( f->handling() == fileItem::LoadAsPreset ||
f->handling() == fileItem::LoadByPlugin ) )
{
m_contextMenuItem = f;
QMenu contextMenu( this );
@@ -439,38 +256,39 @@ void listView::mousePressEvent( QMouseEvent * _me )
fileItem * f = dynamic_cast<fileItem *>( i );
if( f != NULL )
{
if( !m_pphMutex.tryLock() )
{
return;
}
m_pphMutex.lock();
if( m_previewPlayHandle != NULL )
{
engine::getMixer()->removePlayHandle(
m_previewPlayHandle );
m_previewPlayHandle = NULL;
}
// in special case of sample-files we do not care about
// handling() rather than directly creating a samplePlayHandle
if( f->type() == fileItem::SampleFile )
{
textFloat * tf = textFloat::displayMessage(
tr( "Loading sample" ),
tr( "Please wait, loading sample for "
"preview..." ),
embed::getIconPixmap( "sound_file",
embed::getIconPixmap( "sample_file",
24, 24 ), 0 );
qApp->processEvents( QEventLoop::AllEvents );
qApp->processEvents(
QEventLoop::ExcludeUserInputEvents );
samplePlayHandle * s = new samplePlayHandle(
f->fullName() );
s->setDoneMayReturnTrue( FALSE );
m_previewPlayHandle = s;
delete tf;
}
else if( f->type() == fileItem::PresetFile ||
f->type() == fileItem::SpecialPresetFile )
else if( f->handling() == fileItem::LoadAsPreset ||
f->handling() == fileItem::LoadByPlugin )
{
m_previewPlayHandle =
new presetPreviewPlayHandle( f->fullName(),
f->type() ==
fileItem::SpecialPresetFile );
f->handling() ==
fileItem::LoadByPlugin );
}
if( m_previewPlayHandle != NULL )
{
@@ -490,7 +308,9 @@ void listView::mouseMoveEvent( QMouseEvent * _me )
( m_pressPos - _me->pos() ).manhattanLength() >
QApplication::startDragDistance() )
{
// make sure any playback is stopped
mouseReleaseEvent( NULL );
fileItem * f = dynamic_cast<fileItem *>( itemAt( m_pressPos ) );
if( f != NULL )
{
@@ -508,7 +328,7 @@ void listView::mouseMoveEvent( QMouseEvent * _me )
new stringPairDrag( "samplefile",
f->fullName(),
embed::getIconPixmap(
"sound_file" ),
"sample_file" ),
this );
break;
@@ -532,12 +352,9 @@ void listView::mouseMoveEvent( QMouseEvent * _me )
void listView::mouseReleaseEvent( QMouseEvent * _me )
{
if( !m_pphMutex.tryLock() )
{
return;
}
m_mousePressed = FALSE;
m_pphMutex.lock();
if( m_previewPlayHandle != NULL )
{
// if there're samples shorter than 3 seconds, we don't
@@ -567,6 +384,146 @@ void listView::mouseReleaseEvent( QMouseEvent * _me )
void listView::handleFile( fileItem * f, instrumentTrack * _it )
{
engine::getMixer()->lock();
switch( f->handling() )
{
case fileItem::LoadAsProject:
if( engine::getMainWindow()->mayChangeProject() )
{
engine::getSong()->loadProject( f->fullName() );
}
break;
case fileItem::LoadByPlugin:
{
const QString e = f->extension();
instrument * i = _it->getInstrument();
if( i == NULL ||
!i->getDescriptor()->supportsFileType( e ) )
{
i = _it->loadInstrument(
engine::pluginFileHandling()[e] );
}
i->loadFile( f->fullName() );
break;
}
case fileItem::LoadAsPreset:
{
multimediaProject mmp( f->fullName() );
instrumentTrack::removeMidiPortNode( mmp );
_it->setSimpleSerializing();
_it->loadSettings( mmp.content().toElement() );
}
case fileItem::NotSupported:
default:
break;
}
engine::getMixer()->unlock();
}
void listView::activateListItem( QTreeWidgetItem * _item, int _column )
{
fileItem * f = dynamic_cast<fileItem *>( _item );
if( f == NULL )
{
return;
}
if( f->handling() == fileItem::LoadAsProject )
{
handleFile( f, NULL );
}
else
{
engine::getMixer()->lock();
instrumentTrack * it = dynamic_cast<instrumentTrack *>(
track::create( track::InstrumentTrack,
engine::getBBTrackContainer() ) );
handleFile( f, it );
engine::getMixer()->unlock();
}
}
void listView::openInNewInstrumentTrack( trackContainer * _tc )
{
if( m_contextMenuItem->handling() == fileItem::LoadAsPreset ||
m_contextMenuItem->handling() == fileItem::LoadByPlugin )
{
engine::getMixer()->lock();
instrumentTrack * it = dynamic_cast<instrumentTrack *>(
track::create( track::InstrumentTrack, _tc ) );
handleFile( m_contextMenuItem, it );
engine::getMixer()->unlock();
}
}
void listView::openInNewInstrumentTrackBBE( void )
{
openInNewInstrumentTrack( engine::getBBTrackContainer() );
}
void listView::openInNewInstrumentTrackSE( void )
{
openInNewInstrumentTrack( engine::getSong() );
}
void listView::sendToActiveInstrumentTrack( void )
{
// get all windows opened in the workspace
QList<QMdiSubWindow*> pl =
engine::getMainWindow()->workspace()->
subWindowList( QMdiArea::StackingOrder );
QListIterator<QMdiSubWindow *> w( pl );
w.toBack();
// now we travel through the window-list until we find an
// instrument-track
while( w.hasPrevious() )
{
instrumentTrackWindow * itw =
dynamic_cast<instrumentTrackWindow *>(
w.previous()->widget() );
if( itw != NULL && itw->isHidden() == FALSE )
{
handleFile( m_contextMenuItem, itw->model() );
break;
}
}
}
void listView::updateDirectory( QTreeWidgetItem * _item )
{
directory * dir = dynamic_cast<directory *>( _item );
if( dir != NULL )
{
dir->update();
}
}
QPixmap * directory::s_folderPixmap = NULL;
@@ -775,7 +732,7 @@ void fileItem::initPixmapStuff( void )
if( s_sampleFilePixmap == NULL )
{
s_sampleFilePixmap = new QPixmap( embed::getIconPixmap(
"sound_file", 16, 16 ) );
"sample_file", 16, 16 ) );
}
if( s_midiFilePixmap == NULL )
@@ -802,10 +759,11 @@ void fileItem::initPixmapStuff( void )
setIcon( 0, *s_projectFilePixmap );
break;
case PresetFile:
case SpecialPresetFile:
setIcon( 0, *s_presetFilePixmap );
break;
case SampleFile:
case SoundFontFile: // TODO
case PatchFile: // TODO
setIcon( 0, *s_sampleFilePixmap );
break;
case MidiFile:
@@ -826,39 +784,26 @@ void fileItem::initPixmapStuff( void )
void fileItem::determineFileType( void )
{
QString ext = extension();
m_handling = NotSupported;
const QString ext = extension();
if( ext == "mmp" || ext == "mpt" || ext == "mmpz" )
{
m_type = ProjectFile;
m_handling = LoadAsProject;
}
else if( ext == "xml" )
{
/* multimediaProject::ProjectTypes t =
multimediaProject::typeOfFile( fullName() );
if( t == multimediaProject::SongProject )
{
m_type = ProjectFile;
}
else if( t == multimediaProject::InstrumentTrackSettings )
{*/
m_type = PresetFile;
/* }
else
{
m_type = UnknownFile;
}*/
}
else if( ext == "csf" )
else if( ext == "xml" || ext == "xiz" )
{
m_type = PresetFile;
m_handling = LoadAsPreset;
}
else if( ext == "xiz" )
else if( ext == "sf2" )
{
m_type = SpecialPresetFile;
m_type = SoundFontFile;
}
else if( engine::sampleExtensions().contains( ext ) )
else if( ext == "pat" )
{
m_type = SampleFile;
m_type = PatchFile;
}
else if( ext == "mid" )
{
@@ -872,6 +817,17 @@ void fileItem::determineFileType( void )
{
m_type = UnknownFile;
}
if( !ext.isEmpty() && engine::pluginFileHandling().contains( ext ) )
{
m_handling = LoadByPlugin;
// classify as sample if not classified by anything yet but can
// be handled by a certain plugin
if( m_type == UnknownFile )
{
m_type = SampleFile;
}
}
}

View File

@@ -91,14 +91,6 @@ mainWindow::mainWindow( void ) :
QSplitter * splitter = new QSplitter( Qt::Horizontal, w );
splitter->setChildrenCollapsible( FALSE );
QString sample_filter;
QList<QString> ext_keys = engine::sampleExtensions().keys();
for( QList<QString>::iterator it = ext_keys.begin();
it != ext_keys.end(); ++it )
{
sample_filter += " *." + *it;
}
int id = 0;
QString wdir = configManager::inst()->workingDir();
side_bar->appendTab( new pluginBrowser( splitter ), ++id );
@@ -112,8 +104,8 @@ mainWindow::mainWindow( void ) :
side_bar->appendTab( new fileBrowser(
configManager::inst()->userSamplesDir() + "*" +
configManager::inst()->factorySamplesDir(),
sample_filter, tr( "My samples" ),
embed::getIconPixmap( "sound_file" ),
"*", tr( "My samples" ),
embed::getIconPixmap( "sample_file" ),
splitter ), ++id );
side_bar->appendTab( new fileBrowser(
configManager::inst()->userPresetsDir() + "*" +

View File

@@ -380,16 +380,17 @@ void trackContainerView::dropEvent( QDropEvent * _de )
//it->toggledInstrumentTrackButton( TRUE );
_de->accept();
}
else if( type == "sampledata" || type == "samplefile" )
else if( /*type == "sampledata" || */type == "samplefile" )
{
instrumentTrack * it = dynamic_cast<instrumentTrack *>(
track::create( track::InstrumentTrack,
m_tc ) );
QString iname = type == "sampledata" ? "audiofileprocessor" :
engine::sampleExtensions()[fileItem::extension(
const QString iname = /*( type == "sampledata" ) ?
"audiofileprocessor" :*/
engine::pluginFileHandling()[fileItem::extension(
value )];
instrument * i = it->loadInstrument( iname );
i->setParameter( type, value );
i->loadFile( value );
//it->toggledInstrumentTrackButton( TRUE );
_de->accept();
}