]> git.sesse.net Git - kdenlive/commitdiff
Convert old xml LADSPA effects to the new ones
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 17 May 2011 15:53:41 +0000 (15:53 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 17 May 2011 15:53:41 +0000 (15:53 +0000)
svn path=/trunk/kdenlive/; revision=5593

effects/CMakeLists.txt
src/documentvalidator.cpp
src/documentvalidator.h
src/effectslist.cpp
src/effectslist.h
src/kdenlivedoc.cpp

index 9a595c456d7adc9882f1fc2fb1781412a5ccddd0..36a1474c30723327ecdc2aa55541d8716814710d 100644 (file)
@@ -15,17 +15,6 @@ gamma.xml
 grain.xml
 greyscale.xml
 invert.xml
-ladspa_declipper.xml
-ladspa_equalizer.xml
-ladspa_equalizer_15.xml
-ladspa_limiter.xml
-ladspa_phaser.xml
-ladspa_pitch_scale.xml
-ladspa_pitch.xml
-ladspa_rate_scale.xml
-ladspa_reverb.xml
-ladspa_room_reverb.xml
-ladspa_vinyl.xml
 mirror.xml
 mute.xml
 normalise.xml
index e6e0be7edaab395330d09b06003bc9b6c87986d9..1f66b5e42584667d1c808513604e8fe2164586ad 100644 (file)
@@ -811,6 +811,30 @@ bool DocumentValidator::upgrade(double version, const double currentVersion)
             }
         }
     }
+    if (version <= 0.85) {
+        // update the LADSPA effects to use the new ladspa.id format instead of external xml file
+        QDomNodeList effectNodes = m_doc.elementsByTagName("filter");
+        for (int i = 0; i < effectNodes.count(); ++i) {
+            QDomElement effect = effectNodes.at(i).toElement();
+            if (EffectsList::property(effect, "mlt_service") == "ladspa") {
+                // Needs to be converted
+                QStringList info = getInfoFromEffectName(EffectsList::property(effect, "kdenlive_id"));
+                if (info.isEmpty()) continue;
+                // info contains the correct ladspa.id from kdenlive effect name, and a list of parameter's old and new names
+                EffectsList::setProperty(effect, "kdenlive_id", info.at(0));
+                EffectsList::setProperty(effect, "tag", info.at(0));
+                EffectsList::setProperty(effect, "mlt_service", info.at(0));
+                EffectsList::removeProperty(effect, "src");
+                for (int j = 1; j < info.size(); j++) {
+                    QString value = EffectsList::property(effect, info.at(j).section('=', 0, 0));
+                    if (!value.isEmpty()) {
+                        // update parameter name
+                        EffectsList::renameProperty(effect, info.at(j).section('=', 0, 0), info.at(j).section('=', 1, 1));
+                    }
+                }
+            }
+        }
+    }
 
 
     // The document has been converted: mark it as modified
@@ -819,6 +843,84 @@ bool DocumentValidator::upgrade(double version, const double currentVersion)
     return true;
 }
 
+QStringList DocumentValidator::getInfoFromEffectName(const QString oldName)
+{
+    QStringList info;
+    // Returns a list to convert old Kdenlive ladspa effects
+    if (oldName == "pitch_shift") {
+        info << "ladspa.1433";
+        info << "pitch=0";
+    }
+    else if (oldName == "vinyl") {
+        info << "ladspa.1905";
+        info << "year=0";
+        info << "rpm=1";
+        info << "warping=2";
+        info << "crackle=3";
+        info << "wear=4";
+    }
+    else if (oldName == "room_reverb") {
+        info << "ladspa.1216";
+        info << "room=0";
+        info << "delay=1";
+        info << "damp=2";
+    }
+    else if (oldName == "reverb") {
+        info << "ladspa.1423";
+        info << "room=0";
+        info << "damp=1";
+    }
+    else if (oldName == "rate_scale") {
+        info << "ladspa.1417";
+        info << "rate=0";
+    }
+    else if (oldName == "pitch_scale") {
+        info << "ladspa.1193";
+        info << "coef=0";
+    }
+    else if (oldName == "phaser") {
+        info << "ladspa.1217";
+        info << "rate=0";
+        info << "depth=1";
+        info << "feedback=2";
+        info << "spread=3";
+    }
+    else if (oldName == "limiter") {
+        info << "ladspa.1913";
+        info << "gain=0";
+        info << "limit=1";
+        info << "release=2";
+    }
+    else if (oldName == "equalizer_15") {
+        info << "ladspa.1197";
+        info << "1=0";
+        info << "2=1";
+        info << "3=2";
+        info << "4=3";
+        info << "5=4";
+        info << "6=5";
+        info << "7=6";
+        info << "8=7";
+        info << "9=8";
+        info << "10=9";
+        info << "11=10";
+        info << "12=11";
+        info << "13=12";
+        info << "14=13";
+        info << "15=14";
+    }
+    else if (oldName == "equalizer") {
+        info << "ladspa.1901";
+        info << "logain=0";
+        info << "midgain=1";
+        info << "higain=2";
+    }
+    else if (oldName == "declipper") {
+        info << "ladspa.1195";
+    }
+    return info;
+}
+
 QString DocumentValidator::colorToString(const QColor& c)
 {
     QString ret = "%1,%2,%3,%4";
index 2ee0a59f7ad92170977cbe11943aee77f9659311..a4427b7f9040d418a91ba5b15e39bb2048976a68 100644 (file)
@@ -37,6 +37,7 @@ private:
     QDomDocument m_doc;
     bool m_modified;
     bool upgrade(double version, const double currentVersion);
+    QStringList getInfoFromEffectName(const QString oldName);
     QString colorToString(const QColor& c);
 };
 
index 91b7693647aed91b7e7c9942200f8d87c543bf3b..f3ac8877b8876cf0721374c42df330774d7063d3 100644 (file)
@@ -219,6 +219,7 @@ QString EffectsList::parameter(QDomElement effect, const QString &name)
 void EffectsList::setProperty(QDomElement effect, const QString &name, const QString &value)
 {
     QDomNodeList params = effect.elementsByTagName("property");
+    // Update property if it already exists
     for (int i = 0; i < params.count(); i++) {
         QDomElement e = params.item(i).toElement();
         if (e.attribute("name") == name) {
@@ -228,6 +229,20 @@ void EffectsList::setProperty(QDomElement effect, const QString &name, const QSt
     }
 }
 
+// static
+void EffectsList::renameProperty(QDomElement effect, const QString &oldName, const QString &newName)
+{
+    QDomNodeList params = effect.elementsByTagName("property");
+    // Update property if it already exists
+    for (int i = 0; i < params.count(); i++) {
+        QDomElement e = params.item(i).toElement();
+        if (e.attribute("name") == oldName) {
+            e.setAttribute("name", newName);
+            break;
+        }
+    }
+}
+
 // static
 QString EffectsList::property(QDomElement effect, const QString &name)
 {
index b30c2ee2a9b04b09d55fe5da76b607218e05bf88..a12a36f4d9943f2beaeec76d5d123ed2f4585b12 100644 (file)
@@ -74,6 +74,8 @@ public:
     static QString parameter(QDomElement effect, const QString &name);
     /** @brief Change the value of a 'property' element from the effect node. */
     static void setProperty(QDomElement effect, const QString &name, const QString &value);
+    /** @brief Rename a 'property' element from the effect node. */
+    static void renameProperty(QDomElement effect, const QString &oldName, const QString &newName);
     /** @brief Get the value of a 'property' element from the effect node. */
     static QString property(QDomElement effect, const QString &name);
     /** @brief Delete a 'property' element from the effect node. */
index a69fe31fc186eb2c144c3d8719dc9d6d07f64de4..e44135b992d9b8c35b7b1f3f1a18c90e6d5b9c78 100644 (file)
@@ -52,7 +52,7 @@
 
 #include <mlt++/Mlt.h>
 
-const double DOCUMENTVERSION = 0.85;
+const double DOCUMENTVERSION = 0.86;
 
 KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, QString profileName, QMap <QString, QString> properties, const QPoint tracks, Render *render, KTextEdit *notes, MainWindow *parent, KProgressDialog *progressDialog) :
     QObject(parent),