Mixxx

/home/maxime/Projets/Mixxx/1.10/mixxx/src/ladspa/ladspapresetinstance.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 <QtCore>
00011 #include "engine/engineladspa.h"
00012 #include "ladspapresetinstance.h"
00013 #include "ladspapresetknob.h"
00014 #include "controlpotmeter.h"
00015 #include "ladspacontrol.h"
00016 #include "configobject.h"
00017 
00018 int LADSPAPresetInstance::m_iNextInstanceID = 0;
00019 
00020 LADSPAPresetInstance::LADSPAPresetInstance(int pluginCount, int controlCount, int slot)
00021 {
00022     m_iInstanceID = m_iNextInstanceID;
00023     m_iNextInstanceID++;
00024 
00025     m_Instances.resize(pluginCount);
00026     m_Connections.resize(controlCount);
00027     m_Keys.resize(controlCount);
00028 
00029     m_iSlotNumber = slot;
00030 }
00031 
00032 LADSPAPresetInstance::~LADSPAPresetInstance()
00033 {
00034     for (int i = 0; i < m_Instances.count(); i++)
00035     {
00036         m_Instances[i]->remove = 1;
00037     }
00038     for (int i = 0; i < m_Connections.count(); i++)
00039     {
00040         m_Connections[i]->remove = 1;
00041     }
00042 }
00043 
00044 void LADSPAPresetInstance::addPlugin(int i, LADSPAPlugin * plugin, EngineLADSPA * engine)
00045 {
00046     LADSPAInstance * instance = plugin->instantiate(m_iSlotNumber);
00047     m_Instances [i] = instance;
00048     engine->addInstance(instance);
00049 }
00050 
00051 void LADSPAPresetInstance::addControl(int i, LADSPAPresetKnob * knob, EngineLADSPA * engine)
00052 {
00053     ConfigKey * key = new ConfigKey("[LADSPA]", knob->getLabel());
00054     ControlObject * potmeter = new ControlPotmeter(*key, knob->getMin(), knob->getMax());
00055     ControlObjectThreadMain * potmeterThreadMain = new ControlObjectThreadMain(potmeter);
00056     LADSPAControl * control = new LADSPAControl;
00057     control->setValue(knob->getDefault());
00058     potmeterThreadMain->slotSet(knob->getDefault());
00059     m_Keys[i] = key;
00060     LADSPAPortConnectionVector * portConnections = knob->getConnections();
00061     for (LADSPAPortConnectionVector::iterator connection = portConnections->begin(); connection != portConnections->end(); connection++)
00062     {
00063         m_Instances[(*connection).plugin]->connect((*connection).port, control->getBuffer());
00064     }
00065     m_Connections[i] = engine->addControl(potmeter, control);
00066 }
00067 
00068 int LADSPAPresetInstance::getKnobCount()
00069 {
00070     return m_Connections.count();
00071 }
00072 
00073 ConfigKey LADSPAPresetInstance::getKey(int i)
00074 {
00075     return *(m_Keys[i]);
00076 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines