comparison plugin/DSSIPluginInstance.cpp @ 385:9b35a1731c3d

* Tolerable fixes to #1903062 and #1903046
author Chris Cannam
date Wed, 27 Feb 2008 18:04:10 +0000
parents ca3b91119482
children 65311fb86166
comparison
equal deleted inserted replaced
382:9867f99e0bb7 385:9b35a1731c3d
970 970
971 return false; 971 return false;
972 } 972 }
973 973
974 void 974 void
975 DSSIPluginInstance::run(const Vamp::RealTime &blockTime) 975 DSSIPluginInstance::run(const Vamp::RealTime &blockTime, size_t count)
976 { 976 {
977 static snd_seq_event_t localEventBuffer[EVENT_BUFFER_SIZE]; 977 static snd_seq_event_t localEventBuffer[EVENT_BUFFER_SIZE];
978 int evCount = 0; 978 int evCount = 0;
979
980 if (count == 0) count = m_blockSize;
979 981
980 bool needLock = false; 982 bool needLock = false;
981 if (m_descriptor->select_program) needLock = true; 983 if (m_descriptor->select_program) needLock = true;
982 984
983 if (needLock) { 985 if (needLock) {
996 998
997 if (!m_descriptor || !m_descriptor->run_synth) { 999 if (!m_descriptor || !m_descriptor->run_synth) {
998 m_eventBuffer.skip(m_eventBuffer.getReadSpace()); 1000 m_eventBuffer.skip(m_eventBuffer.getReadSpace());
999 m_haveLastEventSendTime = false; 1001 m_haveLastEventSendTime = false;
1000 if (m_descriptor->LADSPA_Plugin->run) { 1002 if (m_descriptor->LADSPA_Plugin->run) {
1001 m_descriptor->LADSPA_Plugin->run(m_instanceHandle, m_blockSize); 1003 m_descriptor->LADSPA_Plugin->run(m_instanceHandle, count);
1002 } else { 1004 } else {
1003 for (size_t ch = 0; ch < m_audioPortsOut.size(); ++ch) { 1005 for (size_t ch = 0; ch < m_audioPortsOut.size(); ++ch) {
1004 memset(m_outputBuffers[ch], 0, m_blockSize * sizeof(sample_t)); 1006 memset(m_outputBuffers[ch], 0, m_blockSize * sizeof(sample_t));
1005 } 1007 }
1006 } 1008 }
1037 std::cerr << "DSSIPluginInstance::run: evTime " << evTime << ", blockTime " << blockTime << ", frameOffset " << frameOffset 1039 std::cerr << "DSSIPluginInstance::run: evTime " << evTime << ", blockTime " << blockTime << ", frameOffset " << frameOffset
1038 << ", blockSize " << m_blockSize << std::endl; 1040 << ", blockSize " << m_blockSize << std::endl;
1039 std::cerr << "Type: " << int(ev->type) << ", pitch: " << int(ev->data.note.note) << ", velocity: " << int(ev->data.note.velocity) << std::endl; 1041 std::cerr << "Type: " << int(ev->type) << ", pitch: " << int(ev->data.note.note) << ", velocity: " << int(ev->data.note.velocity) << std::endl;
1040 #endif 1042 #endif
1041 1043
1042 if (frameOffset >= int(m_blockSize)) break; 1044 if (frameOffset >= int(count)) break;
1043 if (frameOffset < 0) { 1045 if (frameOffset < 0) {
1044 frameOffset = 0; 1046 frameOffset = 0;
1045 if (ev->type == SND_SEQ_EVENT_NOTEON) { 1047 if (ev->type == SND_SEQ_EVENT_NOTEON) {
1046 m_eventBuffer.skip(1); 1048 m_eventBuffer.skip(1);
1047 continue; 1049 continue;
1083 #ifdef DEBUG_DSSI_PROCESS 1085 #ifdef DEBUG_DSSI_PROCESS
1084 std::cerr << "DSSIPluginInstance::run: running with " << evCount << " events" 1086 std::cerr << "DSSIPluginInstance::run: running with " << evCount << " events"
1085 << std::endl; 1087 << std::endl;
1086 #endif 1088 #endif
1087 1089
1088 m_descriptor->run_synth(m_instanceHandle, m_blockSize, 1090 m_descriptor->run_synth(m_instanceHandle, count,
1089 localEventBuffer, evCount); 1091 localEventBuffer, evCount);
1090 1092
1091 #ifdef DEBUG_DSSI_PROCESS 1093 #ifdef DEBUG_DSSI_PROCESS
1092 // for (int i = 0; i < m_blockSize; ++i) { 1094 // for (int i = 0; i < count; ++i) {
1093 // std::cout << m_outputBuffers[0][i] << " "; 1095 // std::cout << m_outputBuffers[0][i] << " ";
1094 // if (i % 8 == 0) std::cout << std::endl; 1096 // if (i % 8 == 0) std::cout << std::endl;
1095 // } 1097 // }
1096 #endif 1098 #endif
1097 1099