Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions include/InstrumentTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ class LMMS_EXPORT InstrumentTrack : public Track, public MidiEventProcessor

void setPreviewMode( const bool );

bool isPreviewMode() const
{
return m_previewMode;
}

signals:
void instrumentChanged();
Expand All @@ -230,6 +234,8 @@ class LMMS_EXPORT InstrumentTrack : public Track, public MidiEventProcessor
return "instrumenttrack";
}

QString getInstrumentName(const QDomElement & thisElement) const;


protected slots:
void updateBaseNote();
Expand Down
28 changes: 21 additions & 7 deletions plugins/vestige/vestige.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,15 @@ void vestigeInstrument::loadSettings( const QDomElement & _this )
{
m_plugin->loadSettings( _this );

if ( _this.attribute( "guivisible" ).toInt() ) {
if (instrumentTrack() != NULL && instrumentTrack()->isPreviewMode())
{
m_plugin->hideUI();
}
else if (_this.attribute( "guivisible" ).toInt())
{
m_plugin->showUI();
} else {
} else
{
m_plugin->hideUI();
}

Expand Down Expand Up @@ -322,12 +328,17 @@ void vestigeInstrument::loadFile( const QString & _file )
{
m_pluginMutex.lock();
const bool set_ch_name = ( m_plugin != NULL &&
instrumentTrack()->name() == m_plugin->name() ) ||
instrumentTrack()->name() == InstrumentTrack::tr( "Default preset" ) ||
instrumentTrack()->name() == displayName();
instrumentTrack()->name() == m_plugin->name() ) ||
instrumentTrack()->name() == InstrumentTrack::tr( "Default preset" ) ||
instrumentTrack()->name() == displayName();

m_pluginMutex.unlock();

// if the same is loaded don't load again (for preview)
if (instrumentTrack() != NULL && instrumentTrack()->isPreviewMode() &&
m_pluginDLL == SampleBuffer::tryToMakeRelative( _file ))
return;

if ( m_plugin != NULL )
{
closePlugin();
Expand All @@ -354,8 +365,11 @@ void vestigeInstrument::loadFile( const QString & _file )
return;
}

m_plugin->createUI(nullptr);
m_plugin->showUI();
if ( !(instrumentTrack() != NULL && instrumentTrack()->isPreviewMode()))
{
m_plugin->createUI(nullptr);
m_plugin->showUI();
}

if( set_ch_name )
{
Expand Down
16 changes: 3 additions & 13 deletions src/core/PresetPreviewPlayHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,9 @@ PresetPreviewPlayHandle::PresetPreviewPlayHandle( const QString & _preset_file,
dataFileCreated = true;
}

// vestige previews are bug prone; fallback on 3xosc with volume of 0
// without an instrument in preview track, it will segfault
if(dataFile->content().elementsByTagName( "vestige" ).length() == 0 )
{
s_previewTC->previewInstrumentTrack()->
loadTrackSpecificSettings(
dataFile->content().firstChild().toElement() );
}
else
{
s_previewTC->previewInstrumentTrack()->loadInstrument("tripleoscillator");
s_previewTC->previewInstrumentTrack()->setVolume( 0 );
}
s_previewTC->previewInstrumentTrack()->loadTrackSpecificSettings(
dataFile->content().firstChild().toElement());

if( dataFileCreated )
{
delete dataFile;
Expand Down
57 changes: 43 additions & 14 deletions src/tracks/InstrumentTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,8 @@ void InstrumentTrack::saveTrackSpecificSettings( QDomDocument& doc, QDomElement

void InstrumentTrack::loadTrackSpecificSettings( const QDomElement & thisElement )
{
silenceAllNotes( true );
silenceAllNotes(!(m_previewMode && m_instrument && m_instrument->nodeName() == "vestige"
&& getInstrumentName(thisElement) == "vestige"));

lock();

Expand Down Expand Up @@ -815,33 +816,44 @@ void InstrumentTrack::loadTrackSpecificSettings( const QDomElement & thisElement
{
m_audioPort.effects()->restoreState( node.toElement() );
}
else if( node.nodeName() == "instrument" )
else if(node.nodeName() == "instrument")
{
typedef Plugin::Descriptor::SubPluginFeatures::Key PluginKey;
PluginKey key( node.toElement().elementsByTagName( "key" ).item( 0 ).toElement() );

delete m_instrument;
m_instrument = NULL;
m_instrument = Instrument::instantiate(
node.toElement().attribute( "name" ), this, &key);
m_instrument->restoreState( node.firstChildElement() );
PluginKey key(node.toElement().elementsByTagName("key").item(0).toElement());

emit instrumentChanged();
// don't delete vestige instrument in preview mode because loading vst
// can take long time, so better try change settings without recreating
// everything (this speeds up the loading of subsequent presets from one plugin)
if (m_previewMode && m_instrument && m_instrument->nodeName() == "vestige" &&
node.toElement().attribute("name") == "vestige")
{
m_instrument->restoreState(node.firstChildElement());
emit instrumentChanged();
}
else
{
delete m_instrument;
m_instrument = NULL;
m_instrument = Instrument::instantiate(
node.toElement().attribute("name"), this, &key);
m_instrument->restoreState(node.firstChildElement());
emit instrumentChanged();
}
}
// compat code - if node-name doesn't match any known
// one, we assume that it is an instrument-plugin
// which we'll try to load
else if( AutomationPattern::classNodeName() != node.nodeName() &&
else if(AutomationPattern::classNodeName() != node.nodeName() &&
ControllerConnection::classNodeName() != node.nodeName() &&
!node.toElement().hasAttribute( "id" ) )
!node.toElement().hasAttribute( "id" ))
{
delete m_instrument;
m_instrument = NULL;
m_instrument = Instrument::instantiate(
node.nodeName(), this, nullptr, true);
if( m_instrument->nodeName() == node.nodeName() )
if (m_instrument->nodeName() == node.nodeName())
{
m_instrument->restoreState( node.toElement() );
m_instrument->restoreState(node.toElement());
}
emit instrumentChanged();
}
Expand All @@ -863,6 +875,23 @@ void InstrumentTrack::setPreviewMode( const bool value )



QString InstrumentTrack::getInstrumentName(const QDomElement &thisElement) const
{
QDomNode node = thisElement.firstChild();
while (!node.isNull())
{
if (node.isElement() && node.nodeName() == "instrument")
{
return node.toElement().attribute("name");
}
node = node.nextSibling();
}
return "";
}




Instrument * InstrumentTrack::loadInstrument(const QString & _plugin_name,
const Plugin::Descriptor::SubPluginFeatures::Key *key, bool keyFromDnd)
{
Expand Down