![]() |
Mixxx
|
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 "ladspainstancemono.h" 00012 00013 LADSPAInstanceMono::LADSPAInstanceMono(const LADSPA_Descriptor * descriptor, int slot) : LADSPAInstance(descriptor, slot) 00014 { 00015 int sampleRate = getSampleRate(); 00016 qDebug() << "LADSPA: Sample rate: " << sampleRate; 00017 00018 m_HandleLeft = descriptor->instantiate(descriptor, sampleRate); 00019 m_HandleRight = descriptor->instantiate(descriptor, sampleRate); 00020 00021 if (descriptor->activate) 00022 { 00023 descriptor->activate(m_HandleLeft); 00024 descriptor->activate(m_HandleRight); 00025 } 00026 00027 m_InputPort = descriptor->PortCount; 00028 m_OutputPort = descriptor->PortCount; 00029 for (unsigned long port = 0; port < descriptor->PortCount; port++) 00030 { 00031 qDebug() << "LADSPA: Port " << port << "u: " << descriptor->PortNames[port]; 00032 if (LADSPA_IS_PORT_AUDIO(descriptor->PortDescriptors [port])) 00033 { 00034 if (LADSPA_IS_PORT_INPUT(descriptor->PortDescriptors [port])) 00035 { 00036 m_InputPort = port; 00037 } 00038 else 00039 { 00040 m_OutputPort = port; 00041 } 00042 } 00043 } 00044 qDebug() << "LADSPA: Input: " << m_InputPort << "u"; 00045 qDebug() << "LADSPA: Output: " << m_OutputPort << "u"; 00046 } 00047 00048 LADSPAInstanceMono::~LADSPAInstanceMono() 00049 { 00050 if (getDescriptor()->deactivate) 00051 { 00052 getDescriptor()->deactivate(m_HandleLeft); 00053 getDescriptor()->deactivate(m_HandleRight); 00054 } 00055 00056 getDescriptor()->cleanup(m_HandleLeft); 00057 getDescriptor()->cleanup(m_HandleRight); 00058 } 00059 00060 void LADSPAInstanceMono::process(const CSAMPLE * pInLeft, const CSAMPLE * pInRight, const CSAMPLE * pOutLeft, const CSAMPLE * pOutRight, const int iBufferSize) 00061 { 00062 getDescriptor()->connect_port(m_HandleLeft, m_InputPort, (LADSPA_Data *) pInLeft); 00063 getDescriptor()->connect_port(m_HandleLeft, m_OutputPort, (LADSPA_Data *) pOutLeft); 00064 getDescriptor()->connect_port(m_HandleRight, m_InputPort, (LADSPA_Data *) pInRight); 00065 getDescriptor()->connect_port(m_HandleRight, m_OutputPort, (LADSPA_Data *) pOutRight); 00066 getDescriptor()->run(m_HandleLeft, iBufferSize); 00067 getDescriptor()->run(m_HandleRight, iBufferSize); 00068 } 00069 00070 void LADSPAInstanceMono::connect(unsigned long port, LADSPA_Data * buffer) 00071 { 00072 getDescriptor()->connect_port(m_HandleLeft, port, buffer); 00073 getDescriptor()->connect_port(m_HandleRight, port, buffer); 00074 }