comparison plugin/DSSIPluginInstance.cpp @ 847:2d53205f70cd tonioni

Merge from default branch
author Chris Cannam
date Tue, 26 Nov 2013 14:37:01 +0000
parents 373923435472 a299c4cec0f8
children 7aa9088e9bcd
comparison
equal deleted inserted replaced
841:226733f3cf3f 847:2d53205f70cd
39 #define EVENT_BUFFER_SIZE 1023 39 #define EVENT_BUFFER_SIZE 1023
40 40
41 #ifdef DEBUG_DSSI 41 #ifdef DEBUG_DSSI
42 static std::ostream &operator<<(std::ostream& o, const QString &s) 42 static std::ostream &operator<<(std::ostream& o, const QString &s)
43 { 43 {
44 o << s.toLocal8Bit().data(); 44 o << s;
45 return o; 45 return o;
46 } 46 }
47 #endif 47 #endif
48 48
49 DSSIPluginInstance::GroupMap DSSIPluginInstance::m_groupMap; 49 DSSIPluginInstance::GroupMap DSSIPluginInstance::m_groupMap;
180 SVDEBUG << "DSSIPluginInstance::getParameter(" << id << ")" << endl; 180 SVDEBUG << "DSSIPluginInstance::getParameter(" << id << ")" << endl;
181 #endif 181 #endif
182 for (unsigned int i = 0; i < m_controlPortsIn.size(); ++i) { 182 for (unsigned int i = 0; i < m_controlPortsIn.size(); ++i) {
183 if (id == m_descriptor->LADSPA_Plugin->PortNames[m_controlPortsIn[i].first]) { 183 if (id == m_descriptor->LADSPA_Plugin->PortNames[m_controlPortsIn[i].first]) {
184 #ifdef DEBUG_DSSI 184 #ifdef DEBUG_DSSI
185 std::cerr << "Matches port " << i << std::endl; 185 cerr << "Matches port " << i << endl;
186 #endif 186 #endif
187 float v = getParameterValue(i); 187 float v = getParameterValue(i);
188 #ifdef DEBUG_DSSI 188 #ifdef DEBUG_DSSI
189 SVDEBUG << "Returning " << v << endl; 189 SVDEBUG << "Returning " << v << endl;
190 #endif 190 #endif
248 m_controlPortsOut.push_back( 248 m_controlPortsOut.push_back(
249 std::pair<unsigned long, LADSPA_Data*>(i, data)); 249 std::pair<unsigned long, LADSPA_Data*>(i, data));
250 if (!strcmp(descriptor->PortNames[i], "latency") || 250 if (!strcmp(descriptor->PortNames[i], "latency") ||
251 !strcmp(descriptor->PortNames[i], "_latency")) { 251 !strcmp(descriptor->PortNames[i], "_latency")) {
252 #ifdef DEBUG_DSSI 252 #ifdef DEBUG_DSSI
253 std::cerr << "Wooo! We have a latency port!" << std::endl; 253 cerr << "Wooo! We have a latency port!" << endl;
254 #endif 254 #endif
255 m_latencyPort = data; 255 m_latencyPort = data;
256 } 256 }
257 } 257 }
258 } 258 }
456 DSSIPluginInstance::instantiate(unsigned long sampleRate) 456 DSSIPluginInstance::instantiate(unsigned long sampleRate)
457 { 457 {
458 if (!m_descriptor) return; 458 if (!m_descriptor) return;
459 459
460 #ifdef DEBUG_DSSI 460 #ifdef DEBUG_DSSI
461 std::cout << "DSSIPluginInstance::instantiate - plugin \"unique\" id = " 461 cout << "DSSIPluginInstance::instantiate - plugin \"unique\" id = "
462 << m_descriptor->LADSPA_Plugin->UniqueID << std::endl; 462 << m_descriptor->LADSPA_Plugin->UniqueID << endl;
463 #endif 463 #endif
464 const LADSPA_Descriptor *descriptor = m_descriptor->LADSPA_Plugin; 464 const LADSPA_Descriptor *descriptor = m_descriptor->LADSPA_Plugin;
465 465
466 if (!descriptor->instantiate) { 466 if (!descriptor->instantiate) {
467 std::cerr << "Bad plugin: plugin id " << descriptor->UniqueID 467 cerr << "Bad plugin: plugin id " << descriptor->UniqueID
468 << ":" << descriptor->Label 468 << ":" << descriptor->Label
469 << " has no instantiate method!" << std::endl; 469 << " has no instantiate method!" << endl;
470 return; 470 return;
471 } 471 }
472 472
473 m_instanceHandle = descriptor->instantiate(descriptor, sampleRate); 473 m_instanceHandle = descriptor->instantiate(descriptor, sampleRate);
474 474
895 qm = std::string(m_descriptor->LADSPA_Plugin->Label) + ": "; 895 qm = std::string(m_descriptor->LADSPA_Plugin->Label) + ": ";
896 } 896 }
897 qm = qm + message; 897 qm = qm + message;
898 free(message); 898 free(message);
899 899
900 std::cerr << "DSSIPluginInstance::configure: warning: configure returned message: \"" << qm << "\"" << std::endl; 900 cerr << "DSSIPluginInstance::configure: warning: configure returned message: \"" << qm << "\"" << endl;
901 } 901 }
902 902
903 return qm; 903 return qm;
904 } 904 }
905 905
916 // we will happily drop events here if we find the timeline going 916 // we will happily drop events here if we find the timeline going
917 // backwards. 917 // backwards.
918 if (m_haveLastEventSendTime && 918 if (m_haveLastEventSendTime &&
919 m_lastEventSendTime > eventTime) { 919 m_lastEventSendTime > eventTime) {
920 #ifdef DEBUG_DSSI_PROCESS 920 #ifdef DEBUG_DSSI_PROCESS
921 std::cerr << "... clearing down" << std::endl; 921 cerr << "... clearing down" << endl;
922 #endif 922 #endif
923 m_haveLastEventSendTime = false; 923 m_haveLastEventSendTime = false;
924 clearEvents(); 924 clearEvents();
925 } 925 }
926 926
1044 } 1044 }
1045 1045
1046 #ifdef DEBUG_DSSI_PROCESS 1046 #ifdef DEBUG_DSSI_PROCESS
1047 SVDEBUG << "DSSIPluginInstance::run: evTime " << evTime << ", blockTime " << blockTime << ", frameOffset " << frameOffset 1047 SVDEBUG << "DSSIPluginInstance::run: evTime " << evTime << ", blockTime " << blockTime << ", frameOffset " << frameOffset
1048 << ", blockSize " << m_blockSize << endl; 1048 << ", blockSize " << m_blockSize << endl;
1049 std::cerr << "Type: " << int(ev->type) << ", pitch: " << int(ev->data.note.note) << ", velocity: " << int(ev->data.note.velocity) << std::endl; 1049 cerr << "Type: " << int(ev->type) << ", pitch: " << int(ev->data.note.note) << ", velocity: " << int(ev->data.note.velocity) << endl;
1050 #endif 1050 #endif
1051 1051
1052 if (frameOffset >= int(count)) break; 1052 if (frameOffset >= int(count)) break;
1053 if (frameOffset < 0) { 1053 if (frameOffset < 0) {
1054 frameOffset = 0; 1054 frameOffset = 0;
1098 m_descriptor->run_synth(m_instanceHandle, count, 1098 m_descriptor->run_synth(m_instanceHandle, count,
1099 localEventBuffer, evCount); 1099 localEventBuffer, evCount);
1100 1100
1101 #ifdef DEBUG_DSSI_PROCESS 1101 #ifdef DEBUG_DSSI_PROCESS
1102 // for (int i = 0; i < count; ++i) { 1102 // for (int i = 0; i < count; ++i) {
1103 // std::cout << m_outputBuffers[0][i] << " "; 1103 // cout << m_outputBuffers[0][i] << " ";
1104 // if (i % 8 == 0) std::cout << std::endl; 1104 // if (i % 8 == 0) cout << endl;
1105 // } 1105 // }
1106 #endif 1106 #endif
1107 1107
1108 done: 1108 done:
1109 if (needLock) m_processLock.unlock(); 1109 if (needLock) m_processLock.unlock();
1319 SVDEBUG << "DSSIPluginInstance::cleanup " << m_identifier << endl; 1319 SVDEBUG << "DSSIPluginInstance::cleanup " << m_identifier << endl;
1320 #endif 1320 #endif
1321 if (!m_descriptor) return; 1321 if (!m_descriptor) return;
1322 1322
1323 if (!m_descriptor->LADSPA_Plugin->cleanup) { 1323 if (!m_descriptor->LADSPA_Plugin->cleanup) {
1324 std::cerr << "Bad plugin: plugin id " 1324 cerr << "Bad plugin: plugin id "
1325 << m_descriptor->LADSPA_Plugin->UniqueID 1325 << m_descriptor->LADSPA_Plugin->UniqueID
1326 << ":" << m_descriptor->LADSPA_Plugin->Label 1326 << ":" << m_descriptor->LADSPA_Plugin->Label
1327 << " has no cleanup method!" << std::endl; 1327 << " has no cleanup method!" << endl;
1328 return; 1328 return;
1329 } 1329 }
1330 1330
1331 m_descriptor->LADSPA_Plugin->cleanup(m_instanceHandle); 1331 m_descriptor->LADSPA_Plugin->cleanup(m_instanceHandle);
1332 m_instanceHandle = 0; 1332 m_instanceHandle = 0;