comparison plugin/DSSIPluginInstance.cpp @ 10:ec6886f0e673

* Fix update and play limits for play-selection mode when not looping * Fix playback in loop mode when no selection -- but the GUI update for this is still wrong on the flyback * Various fixes and improvements to making selections, particularly during playback * Draw selection under non-opaque non-scrollable layers, so as to improve cacheing * Show selection limits as text when drawing selection * Allow user to find missing audio files when loading session * Cross-fade selections when in play-selection mode -- mostly. We don't cross-fade on a processing block boundary, and unfortunately with short selections the selection boundary is quite likely to coincide with a block boundary.
author Chris Cannam
date Wed, 25 Jan 2006 17:46:28 +0000
parents d86891498eef
children cb05ba39664a
comparison
equal deleted inserted replaced
9:73d85d19919f 10:ec6886f0e673
58 m_idealChannelCount(idealChannelCount), 58 m_idealChannelCount(idealChannelCount),
59 m_sampleRate(sampleRate), 59 m_sampleRate(sampleRate),
60 m_latencyPort(0), 60 m_latencyPort(0),
61 m_run(false), 61 m_run(false),
62 m_bypassed(false), 62 m_bypassed(false),
63 m_grouped(false) 63 m_grouped(false),
64 m_haveLastEventSendTime(false)
64 { 65 {
65 #ifdef DEBUG_DSSI 66 #ifdef DEBUG_DSSI
66 std::cerr << "DSSIPluginInstance::DSSIPluginInstance(" << identifier << ")" 67 std::cerr << "DSSIPluginInstance::DSSIPluginInstance(" << identifier << ")"
67 << std::endl; 68 << std::endl;
68 #endif 69 #endif
786 787
787 void 788 void
788 DSSIPluginInstance::sendEvent(const RealTime &eventTime, 789 DSSIPluginInstance::sendEvent(const RealTime &eventTime,
789 const void *e) 790 const void *e)
790 { 791 {
792 if (m_haveLastEventSendTime &&
793 m_lastEventSendTime > eventTime) {
794 clearEvents();
795 }
796
791 snd_seq_event_t *event = (snd_seq_event_t *)e; 797 snd_seq_event_t *event = (snd_seq_event_t *)e;
792 #ifdef DEBUG_DSSI_PROCESS 798 #ifdef DEBUG_DSSI_PROCESS
793 std::cerr << "DSSIPluginInstance::sendEvent at " << eventTime << std::endl; 799 std::cerr << "DSSIPluginInstance::sendEvent at " << eventTime << std::endl;
794 #endif 800 #endif
795 snd_seq_event_t ev(*event); 801 snd_seq_event_t ev(*event);
799 805
800 // DSSI doesn't use MIDI channels, it uses run_multiple_synths instead. 806 // DSSI doesn't use MIDI channels, it uses run_multiple_synths instead.
801 ev.data.note.channel = 0; 807 ev.data.note.channel = 0;
802 808
803 m_eventBuffer.write(&ev, 1); 809 m_eventBuffer.write(&ev, 1);
810 }
811
812 void
813 DSSIPluginInstance::clearEvents()
814 {
815 m_haveLastEventSendTime = false;
816 m_eventBuffer.reset();
804 } 817 }
805 818
806 bool 819 bool
807 DSSIPluginInstance::handleController(snd_seq_event_t *ev) 820 DSSIPluginInstance::handleController(snd_seq_event_t *ev)
808 { 821 {
856 goto done; 869 goto done;
857 } 870 }
858 871
859 if (!m_descriptor || !m_descriptor->run_synth) { 872 if (!m_descriptor || !m_descriptor->run_synth) {
860 m_eventBuffer.skip(m_eventBuffer.getReadSpace()); 873 m_eventBuffer.skip(m_eventBuffer.getReadSpace());
874 m_haveLastEventSendTime = false;
861 if (m_descriptor->LADSPA_Plugin->run) { 875 if (m_descriptor->LADSPA_Plugin->run) {
862 m_descriptor->LADSPA_Plugin->run(m_instanceHandle, m_blockSize); 876 m_descriptor->LADSPA_Plugin->run(m_instanceHandle, m_blockSize);
863 } else { 877 } else {
864 for (size_t ch = 0; ch < m_audioPortsOut.size(); ++ch) { 878 for (size_t ch = 0; ch < m_audioPortsOut.size(); ++ch) {
865 memset(m_outputBuffers[ch], 0, m_blockSize * sizeof(sample_t)); 879 memset(m_outputBuffers[ch], 0, m_blockSize * sizeof(sample_t));
899 << ", blockSize " << m_blockSize << std::endl; 913 << ", blockSize " << m_blockSize << std::endl;
900 std::cerr << "Type: " << int(ev->type) << ", pitch: " << int(ev->data.note.note) << ", velocity: " << int(ev->data.note.velocity) << std::endl; 914 std::cerr << "Type: " << int(ev->type) << ", pitch: " << int(ev->data.note.note) << ", velocity: " << int(ev->data.note.velocity) << std::endl;
901 #endif 915 #endif
902 916
903 if (frameOffset >= int(m_blockSize)) break; 917 if (frameOffset >= int(m_blockSize)) break;
904 if (frameOffset < 0) frameOffset = 0; 918 if (frameOffset < 0) {
919 frameOffset = 0;
920 if (ev->type == SND_SEQ_EVENT_NOTEON) {
921 m_eventBuffer.skip(1);
922 continue;
923 }
924 }
905 925
906 ev->time.tick = frameOffset; 926 ev->time.tick = frameOffset;
907 m_eventBuffer.skip(1); 927 m_eventBuffer.skip(1);
908 928
909 if (ev->type == SND_SEQ_EVENT_CONTROLLER) { 929 if (ev->type == SND_SEQ_EVENT_CONTROLLER) {