Mercurial > hg > svcore
comparison plugin/DSSIPluginInstance.cpp @ 690:1424aa29ae95
Seems to be a bad idea to use plain DEBUG symbol on OS/X (system wants it)
author | Chris Cannam |
---|---|
date | Tue, 14 Jun 2011 15:26:52 +0100 |
parents | 06f13a3b9e9e |
children | 7eb389da7976 |
comparison
equal
deleted
inserted
replaced
689:573d45e9487b | 690:1424aa29ae95 |
---|---|
75 m_bypassed(false), | 75 m_bypassed(false), |
76 m_grouped(false), | 76 m_grouped(false), |
77 m_haveLastEventSendTime(false) | 77 m_haveLastEventSendTime(false) |
78 { | 78 { |
79 #ifdef DEBUG_DSSI | 79 #ifdef DEBUG_DSSI |
80 DEBUG << "DSSIPluginInstance::DSSIPluginInstance(" << identifier << ")" | 80 SVDEBUG << "DSSIPluginInstance::DSSIPluginInstance(" << identifier << ")" |
81 << endl; | 81 << endl; |
82 #endif | 82 #endif |
83 | 83 |
84 init(); | 84 init(); |
85 | 85 |
175 | 175 |
176 float | 176 float |
177 DSSIPluginInstance::getParameter(std::string id) const | 177 DSSIPluginInstance::getParameter(std::string id) const |
178 { | 178 { |
179 #ifdef DEBUG_DSSI | 179 #ifdef DEBUG_DSSI |
180 DEBUG << "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 std::cerr << "Matches port " << i << std::endl; |
186 #endif | 186 #endif |
187 float v = getParameterValue(i); | 187 float v = getParameterValue(i); |
188 #ifdef DEBUG_DSSI | 188 #ifdef DEBUG_DSSI |
189 DEBUG << "Returning " << v << endl; | 189 SVDEBUG << "Returning " << v << endl; |
190 #endif | 190 #endif |
191 return v; | 191 return v; |
192 } | 192 } |
193 } | 193 } |
194 | 194 |
197 | 197 |
198 void | 198 void |
199 DSSIPluginInstance::setParameter(std::string id, float value) | 199 DSSIPluginInstance::setParameter(std::string id, float value) |
200 { | 200 { |
201 #ifdef DEBUG_DSSI | 201 #ifdef DEBUG_DSSI |
202 DEBUG << "DSSIPluginInstance::setParameter(" << id << ", " << value << ")" << endl; | 202 SVDEBUG << "DSSIPluginInstance::setParameter(" << id << ", " << value << ")" << endl; |
203 #endif | 203 #endif |
204 | 204 |
205 for (unsigned int i = 0; i < m_controlPortsIn.size(); ++i) { | 205 for (unsigned int i = 0; i < m_controlPortsIn.size(); ++i) { |
206 if (id == m_descriptor->LADSPA_Plugin->PortNames[m_controlPortsIn[i].first]) { | 206 if (id == m_descriptor->LADSPA_Plugin->PortNames[m_controlPortsIn[i].first]) { |
207 setParameterValue(i, value); | 207 setParameterValue(i, value); |
212 | 212 |
213 void | 213 void |
214 DSSIPluginInstance::init() | 214 DSSIPluginInstance::init() |
215 { | 215 { |
216 #ifdef DEBUG_DSSI | 216 #ifdef DEBUG_DSSI |
217 DEBUG << "DSSIPluginInstance::init" << endl; | 217 SVDEBUG << "DSSIPluginInstance::init" << endl; |
218 #endif | 218 #endif |
219 | 219 |
220 // Discover ports numbers and identities | 220 // Discover ports numbers and identities |
221 // | 221 // |
222 const LADSPA_Descriptor *descriptor = m_descriptor->LADSPA_Plugin; | 222 const LADSPA_Descriptor *descriptor = m_descriptor->LADSPA_Plugin; |
256 } | 256 } |
257 } | 257 } |
258 } | 258 } |
259 #ifdef DEBUG_DSSI | 259 #ifdef DEBUG_DSSI |
260 else | 260 else |
261 DEBUG << "DSSIPluginInstance::DSSIPluginInstance - " | 261 SVDEBUG << "DSSIPluginInstance::DSSIPluginInstance - " |
262 << "unrecognised port type" << endl; | 262 << "unrecognised port type" << endl; |
263 #endif | 263 #endif |
264 } | 264 } |
265 | 265 |
266 m_outputBufferCount = std::max(m_idealChannelCount, m_audioPortsOut.size()); | 266 m_outputBufferCount = std::max(m_idealChannelCount, m_audioPortsOut.size()); |
270 DSSIPluginInstance::getLatency() | 270 DSSIPluginInstance::getLatency() |
271 { | 271 { |
272 size_t latency = 0; | 272 size_t latency = 0; |
273 | 273 |
274 #ifdef DEBUG_DSSI_PROCESS | 274 #ifdef DEBUG_DSSI_PROCESS |
275 DEBUG << "DSSIPluginInstance::getLatency(): m_latencyPort " << m_latencyPort << ", m_run " << m_run << endl; | 275 SVDEBUG << "DSSIPluginInstance::getLatency(): m_latencyPort " << m_latencyPort << ", m_run " << m_run << endl; |
276 #endif | 276 #endif |
277 | 277 |
278 if (m_latencyPort) { | 278 if (m_latencyPort) { |
279 if (!m_run) { | 279 if (!m_run) { |
280 for (size_t i = 0; i < getAudioInputCount(); ++i) { | 280 for (size_t i = 0; i < getAudioInputCount(); ++i) { |
286 } | 286 } |
287 latency = (size_t)(*m_latencyPort + 0.1); | 287 latency = (size_t)(*m_latencyPort + 0.1); |
288 } | 288 } |
289 | 289 |
290 #ifdef DEBUG_DSSI_PROCESS | 290 #ifdef DEBUG_DSSI_PROCESS |
291 DEBUG << "DSSIPluginInstance::getLatency(): latency is " << latency << endl; | 291 SVDEBUG << "DSSIPluginInstance::getLatency(): latency is " << latency << endl; |
292 #endif | 292 #endif |
293 | 293 |
294 return latency; | 294 return latency; |
295 } | 295 } |
296 | 296 |
311 | 311 |
312 void | 312 void |
313 DSSIPluginInstance::setIdealChannelCount(size_t channels) | 313 DSSIPluginInstance::setIdealChannelCount(size_t channels) |
314 { | 314 { |
315 #ifdef DEBUG_DSSI | 315 #ifdef DEBUG_DSSI |
316 DEBUG << "DSSIPluginInstance::setIdealChannelCount: channel count " | 316 SVDEBUG << "DSSIPluginInstance::setIdealChannelCount: channel count " |
317 << channels << " (was " << m_idealChannelCount << ")" << endl; | 317 << channels << " (was " << m_idealChannelCount << ")" << endl; |
318 #endif | 318 #endif |
319 | 319 |
320 if (channels == m_idealChannelCount) { | 320 if (channels == m_idealChannelCount) { |
321 silence(); | 321 silence(); |
399 } | 399 } |
400 | 400 |
401 DSSIPluginInstance::~DSSIPluginInstance() | 401 DSSIPluginInstance::~DSSIPluginInstance() |
402 { | 402 { |
403 #ifdef DEBUG_DSSI | 403 #ifdef DEBUG_DSSI |
404 DEBUG << "DSSIPluginInstance::~DSSIPluginInstance" << endl; | 404 SVDEBUG << "DSSIPluginInstance::~DSSIPluginInstance" << endl; |
405 #endif | 405 #endif |
406 | 406 |
407 if (m_threads.find(m_instanceHandle) != m_threads.end()) { | 407 if (m_threads.find(m_instanceHandle) != m_threads.end()) { |
408 | 408 |
409 for (std::set<NonRTPluginThread *>::iterator i = | 409 for (std::set<NonRTPluginThread *>::iterator i = |
500 { | 500 { |
501 if (m_programCacheValid) return; | 501 if (m_programCacheValid) return; |
502 m_cachedPrograms.clear(); | 502 m_cachedPrograms.clear(); |
503 | 503 |
504 #ifdef DEBUG_DSSI | 504 #ifdef DEBUG_DSSI |
505 DEBUG << "DSSIPluginInstance::checkProgramCache" << endl; | 505 SVDEBUG << "DSSIPluginInstance::checkProgramCache" << endl; |
506 #endif | 506 #endif |
507 | 507 |
508 if (!m_descriptor || !m_descriptor->get_program) { | 508 if (!m_descriptor || !m_descriptor->get_program) { |
509 m_programCacheValid = true; | 509 m_programCacheValid = true; |
510 return; | 510 return; |
520 d.name = programDescriptor->Name; | 520 d.name = programDescriptor->Name; |
521 m_cachedPrograms.push_back(d); | 521 m_cachedPrograms.push_back(d); |
522 } | 522 } |
523 | 523 |
524 #ifdef DEBUG_DSSI | 524 #ifdef DEBUG_DSSI |
525 DEBUG << "DSSIPluginInstance::checkProgramCache: have " << m_cachedPrograms.size() << " programs" << endl; | 525 SVDEBUG << "DSSIPluginInstance::checkProgramCache: have " << m_cachedPrograms.size() << " programs" << endl; |
526 #endif | 526 #endif |
527 | 527 |
528 m_programCacheValid = true; | 528 m_programCacheValid = true; |
529 } | 529 } |
530 | 530 |
531 DSSIPluginInstance::ProgramList | 531 DSSIPluginInstance::ProgramList |
532 DSSIPluginInstance::getPrograms() const | 532 DSSIPluginInstance::getPrograms() const |
533 { | 533 { |
534 #ifdef DEBUG_DSSI | 534 #ifdef DEBUG_DSSI |
535 DEBUG << "DSSIPluginInstance::getPrograms" << endl; | 535 SVDEBUG << "DSSIPluginInstance::getPrograms" << endl; |
536 #endif | 536 #endif |
537 | 537 |
538 if (!m_descriptor) return ProgramList(); | 538 if (!m_descriptor) return ProgramList(); |
539 | 539 |
540 checkProgramCache(); | 540 checkProgramCache(); |
551 | 551 |
552 std::string | 552 std::string |
553 DSSIPluginInstance::getProgram(int bank, int program) const | 553 DSSIPluginInstance::getProgram(int bank, int program) const |
554 { | 554 { |
555 #ifdef DEBUG_DSSI | 555 #ifdef DEBUG_DSSI |
556 DEBUG << "DSSIPluginInstance::getProgram(" << bank << "," << program << ")" << endl; | 556 SVDEBUG << "DSSIPluginInstance::getProgram(" << bank << "," << program << ")" << endl; |
557 #endif | 557 #endif |
558 | 558 |
559 if (!m_descriptor) return std::string(); | 559 if (!m_descriptor) return std::string(); |
560 | 560 |
561 checkProgramCache(); | 561 checkProgramCache(); |
570 | 570 |
571 unsigned long | 571 unsigned long |
572 DSSIPluginInstance::getProgram(std::string name) const | 572 DSSIPluginInstance::getProgram(std::string name) const |
573 { | 573 { |
574 #ifdef DEBUG_DSSI | 574 #ifdef DEBUG_DSSI |
575 DEBUG << "DSSIPluginInstance::getProgram(" << name << ")" << endl; | 575 SVDEBUG << "DSSIPluginInstance::getProgram(" << name << ")" << endl; |
576 #endif | 576 #endif |
577 | 577 |
578 if (!m_descriptor) return 0; | 578 if (!m_descriptor) return 0; |
579 | 579 |
580 checkProgramCache(); | 580 checkProgramCache(); |
607 | 607 |
608 void | 608 void |
609 DSSIPluginInstance::selectProgramAux(std::string program, bool backupPortValues) | 609 DSSIPluginInstance::selectProgramAux(std::string program, bool backupPortValues) |
610 { | 610 { |
611 #ifdef DEBUG_DSSI | 611 #ifdef DEBUG_DSSI |
612 DEBUG << "DSSIPluginInstance::selectProgram(" << program << ")" << endl; | 612 SVDEBUG << "DSSIPluginInstance::selectProgram(" << program << ")" << endl; |
613 #endif | 613 #endif |
614 | 614 |
615 if (!m_descriptor) return; | 615 if (!m_descriptor) return; |
616 | 616 |
617 checkProgramCache(); | 617 checkProgramCache(); |
629 bankNo = i->bank; | 629 bankNo = i->bank; |
630 programNo = i->program; | 630 programNo = i->program; |
631 found = true; | 631 found = true; |
632 | 632 |
633 #ifdef DEBUG_DSSI | 633 #ifdef DEBUG_DSSI |
634 DEBUG << "DSSIPluginInstance::selectProgram(" << program << "): found at bank " << bankNo << ", program " << programNo << endl; | 634 SVDEBUG << "DSSIPluginInstance::selectProgram(" << program << "): found at bank " << bankNo << ", program " << programNo << endl; |
635 #endif | 635 #endif |
636 | 636 |
637 break; | 637 break; |
638 } | 638 } |
639 } | 639 } |
645 m_processLock.lock(); | 645 m_processLock.lock(); |
646 m_descriptor->select_program(m_instanceHandle, bankNo, programNo); | 646 m_descriptor->select_program(m_instanceHandle, bankNo, programNo); |
647 m_processLock.unlock(); | 647 m_processLock.unlock(); |
648 | 648 |
649 #ifdef DEBUG_DSSI | 649 #ifdef DEBUG_DSSI |
650 DEBUG << "DSSIPluginInstance::selectProgram(" << program << "): made select_program(" << bankNo << "," << programNo << ") call" << endl; | 650 SVDEBUG << "DSSIPluginInstance::selectProgram(" << program << "): made select_program(" << bankNo << "," << programNo << ") call" << endl; |
651 #endif | 651 #endif |
652 | 652 |
653 if (backupPortValues) { | 653 if (backupPortValues) { |
654 for (size_t i = 0; i < m_backupControlPortsIn.size(); ++i) { | 654 for (size_t i = 0; i < m_backupControlPortsIn.size(); ++i) { |
655 m_backupControlPortsIn[i] = *m_controlPortsIn[i].second; | 655 m_backupControlPortsIn[i] = *m_controlPortsIn[i].second; |
659 | 659 |
660 void | 660 void |
661 DSSIPluginInstance::activate() | 661 DSSIPluginInstance::activate() |
662 { | 662 { |
663 #ifdef DEBUG_DSSI | 663 #ifdef DEBUG_DSSI |
664 DEBUG << "DSSIPluginInstance::activate" << endl; | 664 SVDEBUG << "DSSIPluginInstance::activate" << endl; |
665 #endif | 665 #endif |
666 | 666 |
667 if (!m_descriptor || !m_descriptor->LADSPA_Plugin->activate) return; | 667 if (!m_descriptor || !m_descriptor->LADSPA_Plugin->activate) return; |
668 m_descriptor->LADSPA_Plugin->activate(m_instanceHandle); | 668 m_descriptor->LADSPA_Plugin->activate(m_instanceHandle); |
669 | 669 |
670 if (m_program != "") { | 670 if (m_program != "") { |
671 #ifdef DEBUG_DSSI | 671 #ifdef DEBUG_DSSI |
672 DEBUG << "DSSIPluginInstance::activate: restoring program " << m_program << endl; | 672 SVDEBUG << "DSSIPluginInstance::activate: restoring program " << m_program << endl; |
673 #endif | 673 #endif |
674 selectProgramAux(m_program, false); | 674 selectProgramAux(m_program, false); |
675 } | 675 } |
676 | 676 |
677 for (size_t i = 0; i < m_backupControlPortsIn.size(); ++i) { | 677 for (size_t i = 0; i < m_backupControlPortsIn.size(); ++i) { |
678 #ifdef DEBUG_DSSI | 678 #ifdef DEBUG_DSSI |
679 DEBUG << "DSSIPluginInstance::activate: setting port " << m_controlPortsIn[i].first << " to " << m_backupControlPortsIn[i] << endl; | 679 SVDEBUG << "DSSIPluginInstance::activate: setting port " << m_controlPortsIn[i].first << " to " << m_backupControlPortsIn[i] << endl; |
680 #endif | 680 #endif |
681 *m_controlPortsIn[i].second = m_backupControlPortsIn[i]; | 681 *m_controlPortsIn[i].second = m_backupControlPortsIn[i]; |
682 } | 682 } |
683 } | 683 } |
684 | 684 |
685 void | 685 void |
686 DSSIPluginInstance::connectPorts() | 686 DSSIPluginInstance::connectPorts() |
687 { | 687 { |
688 if (!m_descriptor || !m_descriptor->LADSPA_Plugin->connect_port) return; | 688 if (!m_descriptor || !m_descriptor->LADSPA_Plugin->connect_port) return; |
689 #ifdef DEBUG_DSSI | 689 #ifdef DEBUG_DSSI |
690 DEBUG << "DSSIPluginInstance::connectPorts: " << m_audioPortsIn.size() | 690 SVDEBUG << "DSSIPluginInstance::connectPorts: " << m_audioPortsIn.size() |
691 << " audio ports in, " << m_audioPortsOut.size() << " out, " | 691 << " audio ports in, " << m_audioPortsOut.size() << " out, " |
692 << m_outputBufferCount << " output buffers" << endl; | 692 << m_outputBufferCount << " output buffers" << endl; |
693 #endif | 693 #endif |
694 | 694 |
695 assert(sizeof(LADSPA_Data) == sizeof(float)); | 695 assert(sizeof(LADSPA_Data) == sizeof(float)); |
724 float defaultValue = f->getPortDefault | 724 float defaultValue = f->getPortDefault |
725 (m_descriptor->LADSPA_Plugin, m_controlPortsIn[i].first); | 725 (m_descriptor->LADSPA_Plugin, m_controlPortsIn[i].first); |
726 *m_controlPortsIn[i].second = defaultValue; | 726 *m_controlPortsIn[i].second = defaultValue; |
727 m_backupControlPortsIn[i] = defaultValue; | 727 m_backupControlPortsIn[i] = defaultValue; |
728 #ifdef DEBUG_DSSI | 728 #ifdef DEBUG_DSSI |
729 DEBUG << "DSSIPluginInstance::connectPorts: set control port " << i << " to default value " << defaultValue << endl; | 729 SVDEBUG << "DSSIPluginInstance::connectPorts: set control port " << i << " to default value " << defaultValue << endl; |
730 #endif | 730 #endif |
731 } | 731 } |
732 } | 732 } |
733 | 733 |
734 for (unsigned int i = 0; i < m_controlPortsOut.size(); ++i) { | 734 for (unsigned int i = 0; i < m_controlPortsOut.size(); ++i) { |
747 | 747 |
748 void | 748 void |
749 DSSIPluginInstance::setParameterValue(unsigned int parameter, float value) | 749 DSSIPluginInstance::setParameterValue(unsigned int parameter, float value) |
750 { | 750 { |
751 #ifdef DEBUG_DSSI | 751 #ifdef DEBUG_DSSI |
752 DEBUG << "DSSIPluginInstance::setParameterValue(" << parameter << ") to " << value << endl; | 752 SVDEBUG << "DSSIPluginInstance::setParameterValue(" << parameter << ") to " << value << endl; |
753 #endif | 753 #endif |
754 if (parameter >= m_controlPortsIn.size()) return; | 754 if (parameter >= m_controlPortsIn.size()) return; |
755 | 755 |
756 unsigned int portNumber = m_controlPortsIn[parameter].first; | 756 unsigned int portNumber = m_controlPortsIn[parameter].first; |
757 | 757 |
771 | 771 |
772 void | 772 void |
773 DSSIPluginInstance::setPortValueFromController(unsigned int port, int cv) | 773 DSSIPluginInstance::setPortValueFromController(unsigned int port, int cv) |
774 { | 774 { |
775 #ifdef DEBUG_DSSI | 775 #ifdef DEBUG_DSSI |
776 DEBUG << "DSSIPluginInstance::setPortValueFromController(" << port << ") to " << cv << endl; | 776 SVDEBUG << "DSSIPluginInstance::setPortValueFromController(" << port << ") to " << cv << endl; |
777 #endif | 777 #endif |
778 | 778 |
779 const LADSPA_Descriptor *p = m_descriptor->LADSPA_Plugin; | 779 const LADSPA_Descriptor *p = m_descriptor->LADSPA_Plugin; |
780 LADSPA_PortRangeHintDescriptor d = p->PortRangeHints[port].HintDescriptor; | 780 LADSPA_PortRangeHintDescriptor d = p->PortRangeHints[port].HintDescriptor; |
781 LADSPA_Data lb = p->PortRangeHints[port].LowerBound; | 781 LADSPA_Data lb = p->PortRangeHints[port].LowerBound; |
817 | 817 |
818 float | 818 float |
819 DSSIPluginInstance::getParameterValue(unsigned int parameter) const | 819 DSSIPluginInstance::getParameterValue(unsigned int parameter) const |
820 { | 820 { |
821 #ifdef DEBUG_DSSI | 821 #ifdef DEBUG_DSSI |
822 DEBUG << "DSSIPluginInstance::getParameterValue(" << parameter << ")" << endl; | 822 SVDEBUG << "DSSIPluginInstance::getParameterValue(" << parameter << ")" << endl; |
823 #endif | 823 #endif |
824 if (parameter >= m_controlPortsIn.size()) return 0.0; | 824 if (parameter >= m_controlPortsIn.size()) return 0.0; |
825 return (*m_controlPortsIn[parameter].second); | 825 return (*m_controlPortsIn[parameter].second); |
826 } | 826 } |
827 | 827 |
867 #endif | 867 #endif |
868 } | 868 } |
869 | 869 |
870 | 870 |
871 #ifdef DEBUG_DSSI | 871 #ifdef DEBUG_DSSI |
872 DEBUG << "DSSIPluginInstance::configure(" << key << "," << value << ")" << endl; | 872 SVDEBUG << "DSSIPluginInstance::configure(" << key << "," << value << ")" << endl; |
873 #endif | 873 #endif |
874 | 874 |
875 char *message = m_descriptor->configure(m_instanceHandle, | 875 char *message = m_descriptor->configure(m_instanceHandle, |
876 key.c_str(), | 876 key.c_str(), |
877 value.c_str()); | 877 value.c_str()); |
906 void | 906 void |
907 DSSIPluginInstance::sendEvent(const Vamp::RealTime &eventTime, | 907 DSSIPluginInstance::sendEvent(const Vamp::RealTime &eventTime, |
908 const void *e) | 908 const void *e) |
909 { | 909 { |
910 #ifdef DEBUG_DSSI_PROCESS | 910 #ifdef DEBUG_DSSI_PROCESS |
911 DEBUG << "DSSIPluginInstance::sendEvent: last was " << m_lastEventSendTime << " (valid " << m_haveLastEventSendTime << "), this is " << eventTime << endl; | 911 SVDEBUG << "DSSIPluginInstance::sendEvent: last was " << m_lastEventSendTime << " (valid " << m_haveLastEventSendTime << "), this is " << eventTime << endl; |
912 #endif | 912 #endif |
913 | 913 |
914 // The process mechanism only works correctly if the events are | 914 // The process mechanism only works correctly if the events are |
915 // sorted. It's the responsibility of the caller to ensure that: | 915 // sorted. It's the responsibility of the caller to ensure that: |
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 |
924 clearEvents(); | 924 clearEvents(); |
925 } | 925 } |
926 | 926 |
927 snd_seq_event_t *event = (snd_seq_event_t *)e; | 927 snd_seq_event_t *event = (snd_seq_event_t *)e; |
928 #ifdef DEBUG_DSSI_PROCESS | 928 #ifdef DEBUG_DSSI_PROCESS |
929 DEBUG << "DSSIPluginInstance::sendEvent at " << eventTime << endl; | 929 SVDEBUG << "DSSIPluginInstance::sendEvent at " << eventTime << endl; |
930 #endif | 930 #endif |
931 snd_seq_event_t ev(*event); | 931 snd_seq_event_t ev(*event); |
932 | 932 |
933 ev.time.time.tv_sec = eventTime.sec; | 933 ev.time.time.tv_sec = eventTime.sec; |
934 ev.time.time.tv_nsec = eventTime.nsec; | 934 ev.time.time.tv_nsec = eventTime.nsec; |
953 DSSIPluginInstance::handleController(snd_seq_event_t *ev) | 953 DSSIPluginInstance::handleController(snd_seq_event_t *ev) |
954 { | 954 { |
955 int controller = ev->data.control.param; | 955 int controller = ev->data.control.param; |
956 | 956 |
957 #ifdef DEBUG_DSSI_PROCESS | 957 #ifdef DEBUG_DSSI_PROCESS |
958 DEBUG << "DSSIPluginInstance::handleController " << controller << endl; | 958 SVDEBUG << "DSSIPluginInstance::handleController " << controller << endl; |
959 #endif | 959 #endif |
960 | 960 |
961 if (controller == 0) { // bank select MSB | 961 if (controller == 0) { // bank select MSB |
962 | 962 |
963 m_pending.msb = ev->data.control.value; | 963 m_pending.msb = ev->data.control.value; |
1018 if (needLock) m_processLock.unlock(); | 1018 if (needLock) m_processLock.unlock(); |
1019 return; | 1019 return; |
1020 } | 1020 } |
1021 | 1021 |
1022 #ifdef DEBUG_DSSI_PROCESS | 1022 #ifdef DEBUG_DSSI_PROCESS |
1023 DEBUG << "DSSIPluginInstance::run(" << blockTime << ")" << endl; | 1023 SVDEBUG << "DSSIPluginInstance::run(" << blockTime << ")" << endl; |
1024 #endif | 1024 #endif |
1025 | 1025 |
1026 #ifdef DEBUG_DSSI_PROCESS | 1026 #ifdef DEBUG_DSSI_PROCESS |
1027 if (m_eventBuffer.getReadSpace() > 0) { | 1027 if (m_eventBuffer.getReadSpace() > 0) { |
1028 DEBUG << "DSSIPluginInstance::run: event buffer has " | 1028 SVDEBUG << "DSSIPluginInstance::run: event buffer has " |
1029 << m_eventBuffer.getReadSpace() << " event(s) in it" << endl; | 1029 << m_eventBuffer.getReadSpace() << " event(s) in it" << endl; |
1030 } | 1030 } |
1031 #endif | 1031 #endif |
1032 | 1032 |
1033 while (m_eventBuffer.getReadSpace() > 0) { | 1033 while (m_eventBuffer.getReadSpace() > 0) { |
1042 if (evTime > blockTime) { | 1042 if (evTime > blockTime) { |
1043 frameOffset = Vamp::RealTime::realTime2Frame(evTime - blockTime, m_sampleRate); | 1043 frameOffset = Vamp::RealTime::realTime2Frame(evTime - blockTime, m_sampleRate); |
1044 } | 1044 } |
1045 | 1045 |
1046 #ifdef DEBUG_DSSI_PROCESS | 1046 #ifdef DEBUG_DSSI_PROCESS |
1047 DEBUG << "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 std::cerr << "Type: " << int(ev->type) << ", pitch: " << int(ev->data.note.note) << ", velocity: " << int(ev->data.note.velocity) << std::endl; |
1050 #endif | 1050 #endif |
1051 | 1051 |
1052 if (frameOffset >= int(count)) break; | 1052 if (frameOffset >= int(count)) break; |
1077 | 1077 |
1078 int program = m_pending.program; | 1078 int program = m_pending.program; |
1079 int bank = m_pending.lsb + 128 * m_pending.msb; | 1079 int bank = m_pending.lsb + 128 * m_pending.msb; |
1080 | 1080 |
1081 #ifdef DEBUG_DSSI | 1081 #ifdef DEBUG_DSSI |
1082 DEBUG << "DSSIPluginInstance::run: making select_program(" << bank << "," << program << ") call" << endl; | 1082 SVDEBUG << "DSSIPluginInstance::run: making select_program(" << bank << "," << program << ") call" << endl; |
1083 #endif | 1083 #endif |
1084 | 1084 |
1085 m_pending.lsb = m_pending.msb = m_pending.program = -1; | 1085 m_pending.lsb = m_pending.msb = m_pending.program = -1; |
1086 m_descriptor->select_program(m_instanceHandle, bank, program); | 1086 m_descriptor->select_program(m_instanceHandle, bank, program); |
1087 | 1087 |
1088 #ifdef DEBUG_DSSI | 1088 #ifdef DEBUG_DSSI |
1089 DEBUG << "DSSIPluginInstance::run: made select_program(" << bank << "," << program << ") call" << endl; | 1089 SVDEBUG << "DSSIPluginInstance::run: made select_program(" << bank << "," << program << ") call" << endl; |
1090 #endif | 1090 #endif |
1091 } | 1091 } |
1092 | 1092 |
1093 #ifdef DEBUG_DSSI_PROCESS | 1093 #ifdef DEBUG_DSSI_PROCESS |
1094 DEBUG << "DSSIPluginInstance::run: running with " << evCount << " events" | 1094 SVDEBUG << "DSSIPluginInstance::run: running with " << evCount << " events" |
1095 << endl; | 1095 << endl; |
1096 #endif | 1096 #endif |
1097 | 1097 |
1098 m_descriptor->run_synth(m_instanceHandle, count, | 1098 m_descriptor->run_synth(m_instanceHandle, count, |
1099 localEventBuffer, evCount); | 1099 localEventBuffer, evCount); |
1151 bool needRun = true; | 1151 bool needRun = true; |
1152 | 1152 |
1153 PluginSet &s = m_groupMap[m_identifier]; | 1153 PluginSet &s = m_groupMap[m_identifier]; |
1154 | 1154 |
1155 #ifdef DEBUG_DSSI_PROCESS | 1155 #ifdef DEBUG_DSSI_PROCESS |
1156 DEBUG << "DSSIPluginInstance::runGrouped(" << blockTime << "): this is " << this << "; " << s.size() << " elements in m_groupMap[" << m_identifier << "]" << endl; | 1156 SVDEBUG << "DSSIPluginInstance::runGrouped(" << blockTime << "): this is " << this << "; " << s.size() << " elements in m_groupMap[" << m_identifier << "]" << endl; |
1157 #endif | 1157 #endif |
1158 | 1158 |
1159 if (m_lastRunTime != blockTime) { | 1159 if (m_lastRunTime != blockTime) { |
1160 for (PluginSet::iterator i = s.begin(); i != s.end(); ++i) { | 1160 for (PluginSet::iterator i = s.begin(); i != s.end(); ++i) { |
1161 DSSIPluginInstance *instance = *i; | 1161 DSSIPluginInstance *instance = *i; |
1162 if (instance != this && instance->m_lastRunTime == blockTime) { | 1162 if (instance != this && instance->m_lastRunTime == blockTime) { |
1163 #ifdef DEBUG_DSSI_PROCESS | 1163 #ifdef DEBUG_DSSI_PROCESS |
1164 DEBUG << "DSSIPluginInstance::runGrouped(" << blockTime << "): plugin " << instance << " has already been run" << endl; | 1164 SVDEBUG << "DSSIPluginInstance::runGrouped(" << blockTime << "): plugin " << instance << " has already been run" << endl; |
1165 #endif | 1165 #endif |
1166 needRun = false; | 1166 needRun = false; |
1167 } | 1167 } |
1168 } | 1168 } |
1169 } | 1169 } |
1170 | 1170 |
1171 if (!needRun) { | 1171 if (!needRun) { |
1172 #ifdef DEBUG_DSSI_PROCESS | 1172 #ifdef DEBUG_DSSI_PROCESS |
1173 DEBUG << "DSSIPluginInstance::runGrouped(" << blockTime << "): already run, returning" << endl; | 1173 SVDEBUG << "DSSIPluginInstance::runGrouped(" << blockTime << "): already run, returning" << endl; |
1174 #endif | 1174 #endif |
1175 return; | 1175 return; |
1176 } | 1176 } |
1177 | 1177 |
1178 #ifdef DEBUG_DSSI_PROCESS | 1178 #ifdef DEBUG_DSSI_PROCESS |
1179 DEBUG << "DSSIPluginInstance::runGrouped(" << blockTime << "): I'm the first, running" << endl; | 1179 SVDEBUG << "DSSIPluginInstance::runGrouped(" << blockTime << "): I'm the first, running" << endl; |
1180 #endif | 1180 #endif |
1181 | 1181 |
1182 size_t index = 0; | 1182 size_t index = 0; |
1183 unsigned long *counts = (unsigned long *) | 1183 unsigned long *counts = (unsigned long *) |
1184 alloca(m_groupLocalEventBufferCount * sizeof(unsigned long)); | 1184 alloca(m_groupLocalEventBufferCount * sizeof(unsigned long)); |
1192 DSSIPluginInstance *instance = *i; | 1192 DSSIPluginInstance *instance = *i; |
1193 counts[index] = 0; | 1193 counts[index] = 0; |
1194 instances[index] = instance->m_instanceHandle; | 1194 instances[index] = instance->m_instanceHandle; |
1195 | 1195 |
1196 #ifdef DEBUG_DSSI_PROCESS | 1196 #ifdef DEBUG_DSSI_PROCESS |
1197 DEBUG << "DSSIPluginInstance::runGrouped(" << blockTime << "): running " << instance << endl; | 1197 SVDEBUG << "DSSIPluginInstance::runGrouped(" << blockTime << "): running " << instance << endl; |
1198 #endif | 1198 #endif |
1199 | 1199 |
1200 if (instance->m_pending.program >= 0 && | 1200 if (instance->m_pending.program >= 0 && |
1201 instance->m_descriptor->select_program) { | 1201 instance->m_descriptor->select_program) { |
1202 int program = instance->m_pending.program; | 1202 int program = instance->m_pending.program; |
1218 if (evTime > blockTime) { | 1218 if (evTime > blockTime) { |
1219 frameOffset = Vamp::RealTime::realTime2Frame(evTime - blockTime, m_sampleRate); | 1219 frameOffset = Vamp::RealTime::realTime2Frame(evTime - blockTime, m_sampleRate); |
1220 } | 1220 } |
1221 | 1221 |
1222 #ifdef DEBUG_DSSI_PROCESS | 1222 #ifdef DEBUG_DSSI_PROCESS |
1223 DEBUG << "DSSIPluginInstance::runGrouped: evTime " << evTime << ", frameOffset " << frameOffset | 1223 SVDEBUG << "DSSIPluginInstance::runGrouped: evTime " << evTime << ", frameOffset " << frameOffset |
1224 << ", block size " << m_blockSize << endl; | 1224 << ", block size " << m_blockSize << endl; |
1225 #endif | 1225 #endif |
1226 | 1226 |
1227 if (frameOffset >= int(m_blockSize)) break; | 1227 if (frameOffset >= int(m_blockSize)) break; |
1228 if (frameOffset < 0) frameOffset = 0; | 1228 if (frameOffset < 0) frameOffset = 0; |
1257 unsigned char /* ports */, | 1257 unsigned char /* ports */, |
1258 unsigned char /* channels */) | 1258 unsigned char /* channels */) |
1259 { | 1259 { |
1260 // This is called from a non-RT context (during instantiate) | 1260 // This is called from a non-RT context (during instantiate) |
1261 | 1261 |
1262 DEBUG << "DSSIPluginInstance::requestMidiSend" << endl; | 1262 SVDEBUG << "DSSIPluginInstance::requestMidiSend" << endl; |
1263 return 1; | 1263 return 1; |
1264 } | 1264 } |
1265 | 1265 |
1266 void | 1266 void |
1267 DSSIPluginInstance::midiSend(LADSPA_Handle /* instance */, | 1267 DSSIPluginInstance::midiSend(LADSPA_Handle /* instance */, |
1268 snd_seq_event_t * /* events */, | 1268 snd_seq_event_t * /* events */, |
1269 unsigned long /* eventCount */) | 1269 unsigned long /* eventCount */) |
1270 { | 1270 { |
1271 // This is likely to be called from an RT context | 1271 // This is likely to be called from an RT context |
1272 | 1272 |
1273 DEBUG << "DSSIPluginInstance::midiSend" << endl; | 1273 SVDEBUG << "DSSIPluginInstance::midiSend" << endl; |
1274 } | 1274 } |
1275 | 1275 |
1276 void | 1276 void |
1277 DSSIPluginInstance::NonRTPluginThread::run() | 1277 DSSIPluginInstance::NonRTPluginThread::run() |
1278 { | 1278 { |
1294 | 1294 |
1295 void | 1295 void |
1296 DSSIPluginInstance::deactivate() | 1296 DSSIPluginInstance::deactivate() |
1297 { | 1297 { |
1298 #ifdef DEBUG_DSSI | 1298 #ifdef DEBUG_DSSI |
1299 DEBUG << "DSSIPluginInstance::deactivate " << m_identifier << endl; | 1299 SVDEBUG << "DSSIPluginInstance::deactivate " << m_identifier << endl; |
1300 #endif | 1300 #endif |
1301 if (!m_descriptor || !m_descriptor->LADSPA_Plugin->deactivate) return; | 1301 if (!m_descriptor || !m_descriptor->LADSPA_Plugin->deactivate) return; |
1302 | 1302 |
1303 for (size_t i = 0; i < m_backupControlPortsIn.size(); ++i) { | 1303 for (size_t i = 0; i < m_backupControlPortsIn.size(); ++i) { |
1304 m_backupControlPortsIn[i] = *m_controlPortsIn[i].second; | 1304 m_backupControlPortsIn[i] = *m_controlPortsIn[i].second; |
1305 } | 1305 } |
1306 | 1306 |
1307 m_descriptor->LADSPA_Plugin->deactivate(m_instanceHandle); | 1307 m_descriptor->LADSPA_Plugin->deactivate(m_instanceHandle); |
1308 #ifdef DEBUG_DSSI | 1308 #ifdef DEBUG_DSSI |
1309 DEBUG << "DSSIPluginInstance::deactivate " << m_identifier << " done" << endl; | 1309 SVDEBUG << "DSSIPluginInstance::deactivate " << m_identifier << " done" << endl; |
1310 #endif | 1310 #endif |
1311 | 1311 |
1312 m_bufferScavenger.scavenge(); | 1312 m_bufferScavenger.scavenge(); |
1313 } | 1313 } |
1314 | 1314 |
1315 void | 1315 void |
1316 DSSIPluginInstance::cleanup() | 1316 DSSIPluginInstance::cleanup() |
1317 { | 1317 { |
1318 #ifdef DEBUG_DSSI | 1318 #ifdef DEBUG_DSSI |
1319 DEBUG << "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 std::cerr << "Bad plugin: plugin id " |
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; |
1333 #ifdef DEBUG_DSSI | 1333 #ifdef DEBUG_DSSI |
1334 DEBUG << "DSSIPluginInstance::cleanup " << m_identifier << " done" << endl; | 1334 SVDEBUG << "DSSIPluginInstance::cleanup " << m_identifier << " done" << endl; |
1335 #endif | 1335 #endif |
1336 } | 1336 } |
1337 | 1337 |