VST preset preview (#5441)

* Enable vestige presets preview.

* Don't destroy vestige instrument on every preset change.

* Don't reload VST dll plugin when it's not necessary. Always hide plugin UI in preview mode.

* Don't remove other instruments in preview mode, don't send instrument change signal.

* Minor changes

* Add a change I missed

Co-authored-by: Hyunjin Song <tteu.ingog@gmail.com>
This commit is contained in:
akimaze
2020-05-09 06:23:40 +02:00
committed by GitHub
parent 1a6f4c1104
commit ab107f01f9
4 changed files with 68 additions and 34 deletions

View File

@@ -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;

View File

@@ -771,7 +771,11 @@ void InstrumentTrack::saveTrackSpecificSettings( QDomDocument& doc, QDomElement
void InstrumentTrack::loadTrackSpecificSettings( const QDomElement & thisElement )
{
silenceAllNotes( true );
// don't delete instrument in preview mode if it's the same
// we can't do this for other situations due to some issues with linked models
bool reuseInstrument = m_previewMode && m_instrument && m_instrument->nodeName() == getSavedInstrumentName(thisElement);
// remove the InstrumentPlayHandle if and only if we need to delete the instrument
silenceAllNotes(!reuseInstrument);
lock();
@@ -815,33 +819,39 @@ 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() );
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() );
emit instrumentChanged();
if (reuseInstrument)
{
m_instrument->restoreState(node.firstChildElement());
}
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();
}
@@ -863,6 +873,19 @@ void InstrumentTrack::setPreviewMode( const bool value )
QString InstrumentTrack::getSavedInstrumentName(const QDomElement &thisElement) const
{
QDomElement elem = thisElement.firstChildElement("instrument");
if (!elem.isNull())
{
return elem.attribute("name");
}
return "";
}
Instrument * InstrumentTrack::loadInstrument(const QString & _plugin_name,
const Plugin::Descriptor::SubPluginFeatures::Key *key, bool keyFromDnd)
{