Mixxx

/home/maxime/Projets/Mixxx/1.10/mixxx/src/ladspa/ladspapreset.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002 *                                                                         *
00003 *   This program is free software; you can redistribute it and/or modify  *
00004 *   it under the terms of the GNU General Public License as published by  *
00005 *   the Free Software Foundation; either version 2 of the License, or     *
00006 *   (at your option) any later version.                                   *
00007 *                                                                         *
00008 ***************************************************************************/
00009 
00010 #include "ladspapreset.h"
00011 #include "ladspapresetinstance.h"
00012 #include "engine/engineladspa.h"
00013 #include "ladspaloader.h"
00014 
00015 #include <QtCore>
00016 #include <QtXml>
00017 
00018 LADSPAPreset::LADSPAPreset()
00019 {
00020 }
00021 
00022 LADSPAPreset::LADSPAPreset(QDomElement element, LADSPALoader * loader)
00023 {
00024     m_qName = element.tagName();
00025 
00026     QDomNodeList pluginNodeList = element.elementsByTagName(QString("Plugin"));
00027     m_Plugins.resize(pluginNodeList.count());
00028     int j = 0;
00029     for (int i = 0; i < pluginNodeList.count(); i++)
00030     {
00031         QDomElement pluginElement = pluginNodeList.item(i).toElement();
00032         if (pluginElement.parentNode() != element)
00033         {
00034             continue;
00035         }
00036         LADSPAPlugin * plugin = loader->getByLabel(pluginElement.text());
00037         if (plugin == NULL)
00038         {
00039             m_bValid = false;
00040             qDebug() << "LADSPA: Plugin " << pluginElement.text() << " not found (required by preset " << m_qName << ")";
00041             return; // ?
00042         }
00043         m_Plugins[j] = plugin;
00044         j++;
00045     }
00046     m_Plugins.resize(j);
00047 
00048     QDomNodeList knobNodeList = element.elementsByTagName(QString("Knob"));
00049     m_Knobs.resize(knobNodeList.count());
00050     for (int i = 0; i < knobNodeList.count(); i++)
00051     {
00052         QDomElement knobElement = knobNodeList.item(i).toElement();
00053         LADSPAPresetKnob * knob = new LADSPAPresetKnob(knobElement);
00054         m_Knobs[i] = knob;
00055     }
00056 
00057     m_bValid = true;
00058 }
00059 
00060 LADSPAPreset::~LADSPAPreset()
00061 {
00062 }
00063 
00064 LADSPAPresetInstance * LADSPAPreset::instantiate(int slot)
00065 {
00066     LADSPAPresetInstance * instance = new LADSPAPresetInstance(m_Plugins.count(), m_Knobs.count(), slot);
00067 
00068     EngineLADSPA * engine = EngineLADSPA::getEngine();
00069 
00070     for (int i = 0; i < m_Plugins.count(); i++)
00071     {
00072         instance->addPlugin(i, m_Plugins[i], engine);
00073     }
00074 
00075     for (int i = 0; i < m_Knobs.count(); i++)
00076     {
00077         instance->addControl(i, m_Knobs[i], engine);
00078     }
00079 
00080     return instance;
00081 }
00082 
00083 QString LADSPAPreset::getName()
00084 {
00085     return m_qName;
00086 }
00087 
00088 bool LADSPAPreset::isValid()
00089 {
00090     return m_bValid;
00091 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines