Mercurial > hg > svcore
comparison plugin/DSSIPluginInstance.cpp @ 57:7439f1696314
* Add editing for auralisation plugin parameters and programs
* Rename and reorganise the sample plugin sample set
author | Chris Cannam |
---|---|
date | Thu, 23 Mar 2006 15:49:41 +0000 |
parents | d397ea0a79f5 |
children | 3086ff194ea0 |
comparison
equal
deleted
inserted
replaced
56:2157fa46c1e7 | 57:7439f1696314 |
---|---|
23 | 23 |
24 #include "DSSIPluginInstance.h" | 24 #include "DSSIPluginInstance.h" |
25 #include "PluginIdentifier.h" | 25 #include "PluginIdentifier.h" |
26 #include "LADSPAPluginFactory.h" | 26 #include "LADSPAPluginFactory.h" |
27 | 27 |
28 //#define DEBUG_DSSI 1 | 28 #define DEBUG_DSSI 1 |
29 //#define DEBUG_DSSI_PROCESS 1 | 29 //#define DEBUG_DSSI_PROCESS 1 |
30 | 30 |
31 #define EVENT_BUFFER_SIZE 1023 | 31 #define EVENT_BUFFER_SIZE 1023 |
32 | 32 |
33 #ifdef DEBUG_DSSI | 33 #ifdef DEBUG_DSSI |
141 pd.name = m_descriptor->LADSPA_Plugin->PortNames[pn]; | 141 pd.name = m_descriptor->LADSPA_Plugin->PortNames[pn]; |
142 pd.description = pd.name; | 142 pd.description = pd.name; |
143 pd.minValue = f->getPortMinimum(m_descriptor->LADSPA_Plugin, pn); | 143 pd.minValue = f->getPortMinimum(m_descriptor->LADSPA_Plugin, pn); |
144 pd.maxValue = f->getPortMaximum(m_descriptor->LADSPA_Plugin, pn); | 144 pd.maxValue = f->getPortMaximum(m_descriptor->LADSPA_Plugin, pn); |
145 pd.defaultValue = f->getPortDefault(m_descriptor->LADSPA_Plugin, pn); | 145 pd.defaultValue = f->getPortDefault(m_descriptor->LADSPA_Plugin, pn); |
146 pd.isQuantized = false; | 146 |
147 float q = f->getPortQuantization(m_descriptor->LADSPA_Plugin, pn); | |
148 if (q == 0.0) { | |
149 pd.isQuantized = false; | |
150 } else { | |
151 pd.isQuantized = true; | |
152 pd.quantizeStep = q; | |
153 } | |
147 | 154 |
148 list.push_back(pd); | 155 list.push_back(pd); |
149 } | 156 } |
150 | 157 |
151 return list; | 158 return list; |
152 } | 159 } |
153 | 160 |
154 float | 161 float |
155 DSSIPluginInstance::getParameter(std::string name) const | 162 DSSIPluginInstance::getParameter(std::string name) const |
156 { | 163 { |
164 std::cerr << "DSSIPluginInstance::getParameter(" << name << ")" << std::endl; | |
157 for (unsigned int i = 0; i < m_controlPortsIn.size(); ++i) { | 165 for (unsigned int i = 0; i < m_controlPortsIn.size(); ++i) { |
158 if (name == m_descriptor->LADSPA_Plugin->PortNames[m_controlPortsIn[i].first]) { | 166 if (name == m_descriptor->LADSPA_Plugin->PortNames[m_controlPortsIn[i].first]) { |
159 return getParameterValue(i); | 167 std::cerr << "Matches port " << i << std::endl; |
168 float v = getParameterValue(i); | |
169 std::cerr << "Returning " << v << std::endl; | |
170 return v; | |
160 } | 171 } |
161 } | 172 } |
162 | 173 |
163 return 0.0; | 174 return 0.0; |
164 } | 175 } |
165 | 176 |
166 void | 177 void |
167 DSSIPluginInstance::setParameter(std::string name, float value) | 178 DSSIPluginInstance::setParameter(std::string name, float value) |
168 { | 179 { |
180 std::cerr << "DSSIPluginInstance::setParameter(" << name << ", " << value << ")" << std::endl; | |
181 | |
169 for (unsigned int i = 0; i < m_controlPortsIn.size(); ++i) { | 182 for (unsigned int i = 0; i < m_controlPortsIn.size(); ++i) { |
170 if (name == m_descriptor->LADSPA_Plugin->PortNames[m_controlPortsIn[i].first]) { | 183 if (name == m_descriptor->LADSPA_Plugin->PortNames[m_controlPortsIn[i].first]) { |
171 setParameterValue(i, value); | 184 setParameterValue(i, value); |
172 break; | 185 break; |
173 } | 186 } |
645 << " audio ports in, " << m_audioPortsOut.size() << " out, " | 658 << " audio ports in, " << m_audioPortsOut.size() << " out, " |
646 << m_outputBufferCount << " output buffers" << std::endl; | 659 << m_outputBufferCount << " output buffers" << std::endl; |
647 | 660 |
648 assert(sizeof(LADSPA_Data) == sizeof(float)); | 661 assert(sizeof(LADSPA_Data) == sizeof(float)); |
649 assert(sizeof(sample_t) == sizeof(float)); | 662 assert(sizeof(sample_t) == sizeof(float)); |
650 | 663 |
664 LADSPAPluginFactory *f = dynamic_cast<LADSPAPluginFactory *>(m_factory); | |
651 int inbuf = 0, outbuf = 0; | 665 int inbuf = 0, outbuf = 0; |
652 | 666 |
653 for (unsigned int i = 0; i < m_audioPortsIn.size(); ++i) { | 667 for (unsigned int i = 0; i < m_audioPortsIn.size(); ++i) { |
654 m_descriptor->LADSPA_Plugin->connect_port | 668 m_descriptor->LADSPA_Plugin->connect_port |
655 (m_instanceHandle, | 669 (m_instanceHandle, |
669 for (unsigned int i = 0; i < m_controlPortsIn.size(); ++i) { | 683 for (unsigned int i = 0; i < m_controlPortsIn.size(); ++i) { |
670 m_descriptor->LADSPA_Plugin->connect_port | 684 m_descriptor->LADSPA_Plugin->connect_port |
671 (m_instanceHandle, | 685 (m_instanceHandle, |
672 m_controlPortsIn[i].first, | 686 m_controlPortsIn[i].first, |
673 m_controlPortsIn[i].second); | 687 m_controlPortsIn[i].second); |
688 | |
689 if (f) { | |
690 float defaultValue = f->getPortDefault | |
691 (m_descriptor->LADSPA_Plugin, m_controlPortsIn[i].first); | |
692 *m_controlPortsIn[i].second = defaultValue; | |
693 m_backupControlPortsIn[i] = defaultValue; | |
694 std::cerr << "DSSIPluginInstance::connectPorts: set control port " << i << " to default value " << defaultValue << std::endl; | |
695 } | |
674 } | 696 } |
675 | 697 |
676 for (unsigned int i = 0; i < m_controlPortsOut.size(); ++i) { | 698 for (unsigned int i = 0; i < m_controlPortsOut.size(); ++i) { |
677 m_descriptor->LADSPA_Plugin->connect_port | 699 m_descriptor->LADSPA_Plugin->connect_port |
678 (m_instanceHandle, | 700 (m_instanceHandle, |