diff --git a/data/projects/templates/AcousticDrumset.mpt b/data/projects/templates/AcousticDrumset.mpt index b134cd9e6..8faca3d4b 100644 --- a/data/projects/templates/AcousticDrumset.mpt +++ b/data/projects/templates/AcousticDrumset.mpt @@ -96,24 +96,6 @@ - - - - - - - - - - - - - - - - - - diff --git a/data/projects/templates/CR8000.mpt b/data/projects/templates/CR8000.mpt index 7d7314b65..9f2b4bfc3 100644 --- a/data/projects/templates/CR8000.mpt +++ b/data/projects/templates/CR8000.mpt @@ -214,24 +214,6 @@ - - - - - - - - - - - - - - - - - - diff --git a/data/projects/templates/ClubMix.mpt b/data/projects/templates/ClubMix.mpt index 41779d493..0b973548c 100644 --- a/data/projects/templates/ClubMix.mpt +++ b/data/projects/templates/ClubMix.mpt @@ -113,24 +113,6 @@ - - - - - - - - - - - - - - - - - - diff --git a/data/projects/templates/Empty.mpt b/data/projects/templates/Empty.mpt index e558347dd..048bd4ee6 100644 --- a/data/projects/templates/Empty.mpt +++ b/data/projects/templates/Empty.mpt @@ -4,19 +4,6 @@ - - - - - - - - - - - - - diff --git a/data/projects/templates/TR808.mpt b/data/projects/templates/TR808.mpt index 08ad876ca..f0c1a23fd 100644 --- a/data/projects/templates/TR808.mpt +++ b/data/projects/templates/TR808.mpt @@ -282,24 +282,6 @@ - - - - - - - - - - - - - - - - - - diff --git a/data/projects/templates/default.mpt b/data/projects/templates/default.mpt index 299aaff2d..e15b6210a 100644 --- a/data/projects/templates/default.mpt +++ b/data/projects/templates/default.mpt @@ -52,24 +52,6 @@ - - - - - - - - - - - - - - - - - - diff --git a/data/projects/tutorials/editing_note_volumes.mmp b/data/projects/tutorials/editing_note_volumes.mmp index b54580618..6f7de11d3 100644 --- a/data/projects/tutorials/editing_note_volumes.mmp +++ b/data/projects/tutorials/editing_note_volumes.mmp @@ -50,23 +50,6 @@ - - - - - - - - - - - - - - diff --git a/include/DataFile.h b/include/DataFile.h index 7f5f5b888..38e67f102 100644 --- a/include/DataFile.h +++ b/include/DataFile.h @@ -134,6 +134,7 @@ private: void upgrade_fixCMTDelays(); void upgrade_fixBassLoopsTypo(); void findProblematicLadspaPlugins(); + void upgrade_noHiddenAutomationTracks(); // List of all upgrade methods static const std::vector UPGRADE_METHODS; diff --git a/src/core/DataFile.cpp b/src/core/DataFile.cpp index 503a0b6a9..a724f25c0 100644 --- a/src/core/DataFile.cpp +++ b/src/core/DataFile.cpp @@ -85,7 +85,8 @@ const std::vector DataFile::UPGRADE_METHODS = { &DataFile::upgrade_sampleAndHold , &DataFile::upgrade_midiCCIndexing, &DataFile::upgrade_loopsRename , &DataFile::upgrade_noteTypes, &DataFile::upgrade_fixCMTDelays , &DataFile::upgrade_fixBassLoopsTypo, - &DataFile::findProblematicLadspaPlugins + &DataFile::findProblematicLadspaPlugins, + &DataFile::upgrade_noHiddenAutomationTracks }; // Vector of all versions that have upgrade routines. @@ -1638,6 +1639,51 @@ void DataFile::upgrade_1_3_0() } } +void DataFile::upgrade_noHiddenAutomationTracks() +{ + // convert global automation tracks to non-hidden + QDomElement song = firstChildElement("lmms-project") + .firstChildElement("song"); + QDomElement trackContainer = song.firstChildElement("trackcontainer"); + QDomElement globalAutomationTrack = song.firstChildElement("track"); + if (!globalAutomationTrack.isNull() + && globalAutomationTrack.attribute("type").toInt() == static_cast(Track::Type::HiddenAutomation)) + { + // global automation clips + QDomNodeList automationClips = globalAutomationTrack.elementsByTagName("automationclip"); + QList tracksToInsert; + for (int i = 0; i < automationClips.length(); ++i) + { + QDomElement automationClip = automationClips.item(i).toElement(); + // If automationClip has time nodes, move it to trackcontainer + // There are times when an node is present without an + // object with the same ID in the file, so we ignore that node + if (automationClip.elementsByTagName("time").length() > 1) + { + QDomElement automationTrackForClip = createElement("track"); + automationTrackForClip.setAttribute("muted", QString::number(false)); + automationTrackForClip.setAttribute("solo", QString::number(false)); + automationTrackForClip.setAttribute("type", + QString::number(static_cast(Track::Type::Automation))); + automationTrackForClip.setAttribute("name", + automationClip.attribute("name", "Automation Track")); + QDomElement at = createElement("automationtrack"); + automationTrackForClip.appendChild(at); + automationTrackForClip.appendChild(automationClips.item(i).cloneNode()); + tracksToInsert.prepend(automationTrackForClip); // To preserve orders + } + } + + // Insert the tracks at the beginning of trackContainer, preserving their order + for (const auto& track : tracksToInsert) { + trackContainer.insertBefore(track, trackContainer.firstChild()); + } + + // Remove the track object just in case + globalAutomationTrack.parentNode().removeChild(globalAutomationTrack); + } +} + void DataFile::upgrade_noHiddenClipNames() { QDomNodeList tracks = elementsByTagName("track"); diff --git a/src/core/Song.cpp b/src/core/Song.cpp index 4e6bf6f58..ea60e349b 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -1079,12 +1079,6 @@ void Song::loadProject( const QString & fileName ) getTimeline(PlayMode::Song).setLoopEnabled(false); - if( !dataFile.content().firstChildElement( "track" ).isNull() ) - { - m_globalAutomationTrack->restoreState( dataFile.content(). - firstChildElement( "track" ) ); - } - //Backward compatibility for LMMS <= 0.4.15 PeakController::initGetControllerBySetting(); @@ -1239,7 +1233,6 @@ bool Song::saveProjectFile(const QString & filename, bool withResources) saveState( dataFile, dataFile.content() ); - m_globalAutomationTrack->saveState( dataFile, dataFile.content() ); Engine::mixer()->saveState( dataFile, dataFile.content() ); if( getGUI() != nullptr ) {