From e1a5cc2145796fc6b5ba8beac0d36d37246807d7 Mon Sep 17 00:00:00 2001 From: Johannes Lorenz Date: Sat, 5 Sep 2020 15:29:50 +0200 Subject: [PATCH] CAPS: DataFile: Map some ports, incomplete --- src/core/DataFile.cpp | 172 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 152 insertions(+), 20 deletions(-) diff --git a/src/core/DataFile.cpp b/src/core/DataFile.cpp index 193045c7a9c..7ed891b9399 100644 --- a/src/core/DataFile.cpp +++ b/src/core/DataFile.cpp @@ -964,7 +964,9 @@ void iterate_ladspa_ports(QDomElement& effect, Ftor& ftor) { continue; } - int num = parts[1].toInt(); + + int proc = parts[1].left(1).toInt(); // = left or right + int num = parts[1].mid(1).toInt(); // From Qt's docs of QDomNode: // * copying a QDomNode is OK, they still have the same @@ -976,7 +978,7 @@ void iterate_ladspa_ports(QDomElement& effect, Ftor& ftor) // QDomElements by value, not references // => The loops below for adding and removing don't // invalidate any other QDomElements - ftor(port, num, addList, removeList); + ftor(port, proc, num, addList, removeList); } // Add ports marked for adding @@ -1030,6 +1032,9 @@ void DataFile::upgrade_1_3_0() } } + /* + * fix CALF and CAPS effects + */ list = elementsByTagName( "effect" ); for( int i = 0; !list.item( i ).isNull(); ++i ) { @@ -1043,8 +1048,9 @@ void DataFile::upgrade_1_3_0() QDomNodeList attributes = key.elementsByTagName( "attribute" ); for( int k = 0; !attributes.item( k ).isNull(); ++k ) { - // Effect name changes - + /* + * CALF effect name changes + */ QDomElement attribute = attributes.item( k ).toElement(); if( attribute.attribute( "name" ) == "file" && ( attribute.attribute( "value" ) == "calf" || @@ -1078,14 +1084,15 @@ void DataFile::upgrade_1_3_0() attribute.setAttribute( "value", "MultibandLimiter" ); } - // Handle port changes - + /* + * CALF port changes + */ if( attribute.attribute( "name" ) == "plugin" && ( attribute.attribute( "value" ) == "MultibandLimiter" || attribute.attribute( "value" ) == "MultibandCompressor" || attribute.attribute( "value" ) == "MultibandGate" ) ) { - auto fn = [&](QDomElement& port, int num, QList&, QList& removeList) + auto fn = [&](QDomElement& port, int, int num, QList&, QList& removeList) { // Mark ports for removal if ( num >= 18 && num <= 23 ) @@ -1107,7 +1114,7 @@ void DataFile::upgrade_1_3_0() if( attribute.attribute( "name" ) == "plugin" && ( attribute.attribute( "value" ) == "Pulsator" ) ) { - auto fn = [&](QDomElement& port, int num, QList& addList, QList& removeList) + auto fn = [&](QDomElement& port, int, int num, QList& addList, QList& removeList) { switch(num) { @@ -1152,7 +1159,7 @@ void DataFile::upgrade_1_3_0() if( attribute.attribute( "name" ) == "plugin" && ( attribute.attribute( "value" ) == "VintageDelay" ) ) { - auto fn = [&](QDomElement& port, int num, QList& addList, QList& ) + auto fn = [&](QDomElement& port, int, int num, QList& addList, QList& ) { switch(num) { @@ -1195,7 +1202,7 @@ void DataFile::upgrade_1_3_0() // NBand equalizers got 4 q nobs inserted. We need to shift everything else... // HOWEVER: 5 band eq has only 2 q nobs inserted (no LS/HS filters) bool band5 = ( attribute.attribute( "value" ) == "Equalizer5Band" ); - auto fn = [&](QDomElement& port, int num, QList& addList, QList& ) + auto fn = [&](QDomElement& port, int, int num, QList& addList, QList& ) { if(num == 4) { @@ -1287,7 +1294,7 @@ void DataFile::upgrade_1_3_0() if( attribute.attribute( "name" ) == "plugin" && attribute.attribute( "value" ) == "Saturator" ) { - auto fn = [&](QDomElement& port, int num, QList&, QList& ) + auto fn = [&](QDomElement& port, int, int num, QList&, QList& ) { // These ports have been shifted a bit weird... if( num == 7 ) @@ -1315,7 +1322,7 @@ void DataFile::upgrade_1_3_0() if( attribute.attribute( "name" ) == "plugin" && attribute.attribute( "value" ) == "StereoTools" ) { - auto fn = [&](QDomElement& port, int num, QList&, QList& ) + auto fn = [&](QDomElement& port, int, int num, QList&, QList& ) { // This effect can not be back-ported due to bugs in the old version, // or due to different behaviour. We thus port all parameters we can, @@ -1329,9 +1336,87 @@ void DataFile::upgrade_1_3_0() }; iterate_ladspa_ports(effect, fn); } - // Upgrade C* Eq to C* Eq10 + + /* + * CAPS port changes + */ + + /* + how to write this + 1 - open both LMMS versions, and check visually where ports moved + 2 - compare savefiles to find out how the indexes of the movements are + 3 - write down the port movements here (port.setTagName...) + 4 - all port numbers that are not source or dest of a move and exist in both old and new must be bashed to the new defaults + 5 - fine tuning on individual parameters (e.g. if their scale changed) + */ + auto new_port_name = [](int proc, int new_num) -> QString { + return "port" + QString::number(proc) + QString::number(new_num); + }; + + if( attribute.attribute( "name" ) == "plugin" && + attribute.attribute( "value" ) == "AmpVTS" ) + { + auto fn = [&](QDomElement& port, int proc, int num, QList&, QList&) + { + if(num == 2) + { + port.setTagName(new_port_name(proc, 1)); + } + else if(num == 3 || num == 4 || num == 5) + { + port.setTagName(new_port_name(proc, 2 + num)); + } + }; + iterate_ladspa_ports(effect, fn); + } + + if( attribute.attribute( "name" ) == "plugin" && + attribute.attribute( "value" ) == "AutoWah" ) + { + attribute.setAttribute( "value", "AutoFilter" ); + auto fn = [&](QDomElement& port, int proc, int num, QList&, QList&) + { + if(num == 1 || num == 2 || num == 3) + { + port.setTagName(new_port_name(proc, 1 + num)); + } + }; + iterate_ladspa_ports(effect, fn); + } + + if( attribute.attribute( "name" ) == "plugin" && + attribute.attribute( "value" ) == "ChorusI" ) + { + auto fn = [&](QDomElement& port, int proc, int num, QList&, QList&) + { + port.setTagName(new_port_name(proc, num - 1)); + }; + iterate_ladspa_ports(effect, fn); + } + + if( attribute.attribute( "name" ) == "plugin" && + attribute.attribute( "value" ) == "Clip" ) + { + attribute.setAttribute( "value", "Saturate" ); + // FIXME: Ports conveniently map, but the volume is too quiet + } + + if( attribute.attribute( "name" ) == "plugin" && + attribute.attribute( "value" ) == "Compress" ) + { + // TODO + + // 1->6 + // 2->3??? (or bash) + // 3 -> 4 + // 4 -> 5 + // 5-> 2 + // 6 -> bash + + } + if( attribute.attribute( "name" ) == "plugin" && - attribute.attribute( "value" ) == "Eq" ) + attribute.attribute( "value" ) == "Eq" ) { attribute.setAttribute( "value", "Eq10" ); // Head back up the DOM to upgrade ports @@ -1385,11 +1470,53 @@ void DataFile::upgrade_1_3_0() } } } - // Upgrade C* Plate2x2 to PlateX2 + if( attribute.attribute( "name" ) == "plugin" && - attribute.attribute( "value" ) == "Plate2x2" ) + attribute.attribute( "value" ) == "Eq2x2" ) + { + attribute.setAttribute( "value", "Eq10X2" ); + auto fn = [&](QDomElement& port, int proc, int num, QList&, QList&) + { + port.setTagName(new_port_name(proc, num - 2)); + }; + iterate_ladspa_ports(effect, fn); + } + + if( attribute.attribute( "name" ) == "Narrower" && + attribute.attribute( "value" ) == "Narrower" ) + { + attribute.setAttribute( "value", "Eq10X2" ); + auto fn = [&](QDomElement& port, int proc, int num, QList&, QList&) + { + if(num == 2) { + port.setTagName(new_port_name(proc, 1)); + } + }; + iterate_ladspa_ports(effect, fn); + } + + if( attribute.attribute( "name" ) == "PhaserII" && + attribute.attribute( "value" ) == "PhaserII" ) + { + auto fn = [&](QDomElement& port, int proc, int num, QList&, QList&) + { + if(num == 1) { + port.setTagName(new_port_name(proc, 0)); + } + else if(num == 4) { + assert(port.hasAttribute("data")); + // feedback is now multiplied by 0.9f => change scale + port.setAttribute("data", port.attribute("data").toFloat() / 0.9f); + } + }; + iterate_ladspa_ports(effect, fn); + } + + if( attribute.attribute( "name" ) == "plugin" && + attribute.attribute( "value" ) == "Plate2x2" ) { attribute.setAttribute( "value", "PlateX2" ); + // Head back up the DOM to upgrade ports QDomNodeList ladspacontrols = effect.elementsByTagName( "ladspacontrols" ); for( int m = 0; !ladspacontrols.item( m ).isNull(); ++m ) @@ -1414,12 +1541,17 @@ void DataFile::upgrade_1_3_0() } } } - // Upgrade C* Clip to C* Saturate + if( attribute.attribute( "name" ) == "plugin" && - attribute.attribute( "value" ) == "Clip" ) + attribute.attribute( "value" ) == "ToneStack" ) { - attribute.setAttribute( "value", "Saturate" ); - // FIXME: Ports conveniently map, but the volume is too quiet + auto fn = [&](QDomElement& port, int proc, int num, QList&, QList& ) + { + // all ports move down by one + QString new_number = QString::number(proc) + QString::number(num - 1); + port.setTagName( "port" + new_number ); + }; + iterate_ladspa_ports(effect, fn); } } }