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