From: Jean-Baptiste Mardelle Date: Tue, 17 May 2011 15:53:41 +0000 (+0000) Subject: Convert old xml LADSPA effects to the new ones X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=41dece4cea069263ee17ab9d491964c1705fec6b;p=kdenlive Convert old xml LADSPA effects to the new ones svn path=/trunk/kdenlive/; revision=5593 --- diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt index 9a595c45..36a1474c 100644 --- a/effects/CMakeLists.txt +++ b/effects/CMakeLists.txt @@ -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 diff --git a/src/documentvalidator.cpp b/src/documentvalidator.cpp index e6e0be7e..1f66b5e4 100644 --- a/src/documentvalidator.cpp +++ b/src/documentvalidator.cpp @@ -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"; diff --git a/src/documentvalidator.h b/src/documentvalidator.h index 2ee0a59f..a4427b7f 100644 --- a/src/documentvalidator.h +++ b/src/documentvalidator.h @@ -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); }; diff --git a/src/effectslist.cpp b/src/effectslist.cpp index 91b76936..f3ac8877 100644 --- a/src/effectslist.cpp +++ b/src/effectslist.cpp @@ -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) { diff --git a/src/effectslist.h b/src/effectslist.h index b30c2ee2..a12a36f4 100644 --- a/src/effectslist.h +++ b/src/effectslist.h @@ -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. */ diff --git a/src/kdenlivedoc.cpp b/src/kdenlivedoc.cpp index a69fe31f..e44135b9 100644 --- a/src/kdenlivedoc.cpp +++ b/src/kdenlivedoc.cpp @@ -52,7 +52,7 @@ #include -const double DOCUMENTVERSION = 0.85; +const double DOCUMENTVERSION = 0.86; KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, QString profileName, QMap properties, const QPoint tracks, Render *render, KTextEdit *notes, MainWindow *parent, KProgressDialog *progressDialog) : QObject(parent),