Skip to content

Commit

Permalink
Preserve FX channel when replacing track (#5957)
Browse files Browse the repository at this point in the history
* Preserve FX channel when replacing track

* Add comment
  • Loading branch information
Spekular authored Jun 21, 2021
1 parent 37ed247 commit c71e408
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
2 changes: 2 additions & 0 deletions include/InstrumentTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ class LMMS_EXPORT InstrumentTrack : public Track, public MidiEventProcessor
{
return m_previewMode;
}

void replaceInstrument(DataFile dataFile);

void autoAssignMidiDevice( bool );

Expand Down
10 changes: 3 additions & 7 deletions src/gui/FileBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,15 +776,11 @@ void FileBrowserTreeWidget::handleFile(FileItem * f, InstrumentTrack * it)
break;
}

case FileItem::LoadAsPreset:
{
DataFile dataFile( f->fullName() );
InstrumentTrack::removeMidiPortNode( dataFile );
it->setSimpleSerializing();
it->loadSettings( dataFile.content().toElement() );
case FileItem::LoadAsPreset: {
DataFile dataFile(f->fullName());
it->replaceInstrument(dataFile);
break;
}

case FileItem::ImportAsProject:
ImportFilter::import( f->fullName(),
Engine::getSong() );
Expand Down
25 changes: 18 additions & 7 deletions src/tracks/InstrumentTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,22 @@ void InstrumentTrack::setPreviewMode( const bool value )



void InstrumentTrack::replaceInstrument(DataFile dataFile)
{
// loadSettings clears the FX channel, so we save it here and set it back later
int effectChannel = effectChannelModel()->value();

InstrumentTrack::removeMidiPortNode(dataFile);
setSimpleSerializing();
loadSettings(dataFile.content().toElement());

m_effectChannelModel.setValue(effectChannel);
Engine::getSong()->setModified();
}




QString InstrumentTrack::getSavedInstrumentName(const QDomElement &thisElement) const
{
QDomElement elem = thisElement.firstChildElement("instrument");
Expand Down Expand Up @@ -1835,13 +1851,8 @@ void InstrumentTrackWindow::dropEvent( QDropEvent* event )
}
else if( type == "presetfile" )
{
DataFile dataFile( value );
InstrumentTrack::removeMidiPortNode( dataFile );
m_track->setSimpleSerializing();
m_track->loadSettings( dataFile.content().toElement() );

Engine::getSong()->setModified();

DataFile dataFile(value);
m_track->replaceInstrument(dataFile);
event->accept();
setFocus();
}
Expand Down

0 comments on commit c71e408

Please sign in to comment.