Commit 41dece4c authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Convert old xml LADSPA effects to the new ones

svn path=/trunk/kdenlive/; revision=5593
parent 36e64bf3
......@@ -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
......
......@@ -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";
......
......@@ -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);
};
......
......@@ -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)
{
......
......@@ -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. */
......
......@@ -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),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment