comparison audioio/AudioGenerator.cpp @ 179:0db3fc28a2a1

* debug only
author Chris Cannam
date Tue, 18 Aug 2009 11:08:29 +0000
parents 7dae51741cc9
children 67cea66bd588
comparison
equal deleted inserted replaced
178:e81c1ea227ee 179:0db3fc28a2a1
209 RealTimePluginInstance *plugin = loadPlugin(pluginId, ""); 209 RealTimePluginInstance *plugin = loadPlugin(pluginId, "");
210 if (!plugin) return 0; 210 if (!plugin) return 0;
211 211
212 if (configurationXml != "") { 212 if (configurationXml != "") {
213 PluginXml(plugin).setParametersFromXml(configurationXml); 213 PluginXml(plugin).setParametersFromXml(configurationXml);
214 setSampleDir(plugin);
214 } 215 }
215 216
216 configurationXml = PluginXml(plugin).toXmlString(); 217 configurationXml = PluginXml(plugin).toXmlString();
217 218
218 if (parameters) { 219 if (parameters) {
568 (noteOffs.begin()->frame, m_sourceSampleRate); 569 (noteOffs.begin()->frame, m_sourceSampleRate);
569 570
570 offEv.data.note.note = noteOffs.begin()->pitch; 571 offEv.data.note.note = noteOffs.begin()->pitch;
571 572
572 #ifdef DEBUG_AUDIO_GENERATOR 573 #ifdef DEBUG_AUDIO_GENERATOR
573 std::cerr << "mixModel [sparse]: sending note-off event at time " << eventTime << " frame " << noteOffs.begin()->frame << std::endl; 574 std::cerr << "mixModel [sparse]: sending note-off event at time " << eventTime << " frame " << noteOffs.begin()->frame << " pitch " << noteOffs.begin()->pitch << std::endl;
574 #endif 575 #endif
575 576
576 plugin->sendEvent(eventTime, &offEv); 577 plugin->sendEvent(eventTime, &offEv);
577 noteOffs.erase(noteOffs.begin()); 578 noteOffs.erase(noteOffs.begin());
578 } 579 }
601 (noteOffs.begin()->frame, m_sourceSampleRate); 602 (noteOffs.begin()->frame, m_sourceSampleRate);
602 603
603 offEv.data.note.note = noteOffs.begin()->pitch; 604 offEv.data.note.note = noteOffs.begin()->pitch;
604 605
605 #ifdef DEBUG_AUDIO_GENERATOR 606 #ifdef DEBUG_AUDIO_GENERATOR
606 std::cerr << "mixModel [sparse]: sending leftover note-off event at time " << eventTime << " frame " << noteOffs.begin()->frame << std::endl; 607 std::cerr << "mixModel [sparse]: sending leftover note-off event at time " << eventTime << " frame " << noteOffs.begin()->frame << " pitch " << noteOffs.begin()->pitch << std::endl;
607 #endif 608 #endif
608 609
609 plugin->sendEvent(eventTime, &offEv); 610 plugin->sendEvent(eventTime, &offEv);
610 noteOffs.erase(noteOffs.begin()); 611 noteOffs.erase(noteOffs.begin());
611 } 612 }
665 //calls to mixModel 666 //calls to mixModel
666 667
667 size_t got = blocks * m_pluginBlockSize; 668 size_t got = blocks * m_pluginBlockSize;
668 669
669 #ifdef DEBUG_AUDIO_GENERATOR 670 #ifdef DEBUG_AUDIO_GENERATOR
670 std::cout << "mixModel [note]: frames " << frames 671 Vamp::RealTime startTime = Vamp::RealTime::frame2RealTime
671 << ", blocks " << blocks << std::endl; 672 (startFrame, m_sourceSampleRate);
673
674 std::cout << "mixModel [note]: frames " << frames << " from " << startFrame
675 << " (time " << startTime << "), blocks " << blocks << std::endl;
672 #endif 676 #endif
673 677
674 snd_seq_event_t onEv; 678 snd_seq_event_t onEv;
675 onEv.type = SND_SEQ_EVENT_NOTEON; 679 onEv.type = SND_SEQ_EVENT_NOTEON;
676 onEv.data.note.channel = 0; 680 onEv.data.note.channel = 0;
712 (noteOffs.begin()->frame, m_sourceSampleRate); 716 (noteOffs.begin()->frame, m_sourceSampleRate);
713 717
714 offEv.data.note.note = noteOffs.begin()->pitch; 718 offEv.data.note.note = noteOffs.begin()->pitch;
715 719
716 #ifdef DEBUG_AUDIO_GENERATOR 720 #ifdef DEBUG_AUDIO_GENERATOR
717 std::cerr << "mixModel [note]: sending note-off event at time " << eventTime << " frame " << noteOffs.begin()->frame << std::endl; 721 std::cerr << "mixModel [note]: sending note-off event at time " << eventTime << " frame " << noteOffs.begin()->frame << " pitch " << noteOffs.begin()->pitch << std::endl;
718 #endif 722 #endif
719 723
720 plugin->sendEvent(eventTime, &offEv); 724 plugin->sendEvent(eventTime, &offEv);
721 noteOffs.erase(noteOffs.begin()); 725 noteOffs.erase(noteOffs.begin());
722 } 726 }
737 } 741 }
738 742
739 plugin->sendEvent(eventTime, &onEv); 743 plugin->sendEvent(eventTime, &onEv);
740 744
741 #ifdef DEBUG_AUDIO_GENERATOR 745 #ifdef DEBUG_AUDIO_GENERATOR
742 std::cout << "mixModel [note]: point at frame " << pliFrame << ", block start " << (startFrame + i * m_pluginBlockSize) << ", resulting time " << eventTime << std::endl; 746 std::cout << "mixModel [note]: point at frame " << pliFrame << ", pitch " << (int)onEv.data.note.note << ", block start " << (startFrame + i * m_pluginBlockSize) << ", resulting time " << eventTime << std::endl;
743 #endif 747 #endif
744 748
745 size_t duration = pli->duration; 749 size_t duration = pli->duration;
746 if (duration == 0 || duration == 1) { 750 if (duration == 0 || duration == 1) {
747 duration = m_sourceSampleRate / 20; 751 duration = m_sourceSampleRate / 20;
748 } 752 }
749 NoteOff noff; 753 NoteOff noff;
750 noff.pitch = onEv.data.note.note; 754 noff.pitch = onEv.data.note.note;
751 noff.frame = pliFrame + duration; 755 noff.frame = pliFrame + duration;
752 noteOffs.insert(noff); 756 noteOffs.insert(noff);
757
758 #ifdef DEBUG_AUDIO_GENERATOR
759 std::cout << "mixModel [note]: recording note off at " << noff.frame << std::endl;
760 #endif
753 } 761 }
754 762
755 while (noteOffs.begin() != noteOffs.end() && 763 while (noteOffs.begin() != noteOffs.end() &&
756 noteOffs.begin()->frame <= 764 noteOffs.begin()->frame <=
757 startFrame + i * m_pluginBlockSize + m_pluginBlockSize) { 765 startFrame + i * m_pluginBlockSize + m_pluginBlockSize) {
760 (noteOffs.begin()->frame, m_sourceSampleRate); 768 (noteOffs.begin()->frame, m_sourceSampleRate);
761 769
762 offEv.data.note.note = noteOffs.begin()->pitch; 770 offEv.data.note.note = noteOffs.begin()->pitch;
763 771
764 #ifdef DEBUG_AUDIO_GENERATOR 772 #ifdef DEBUG_AUDIO_GENERATOR
765 std::cerr << "mixModel [note]: sending leftover note-off event at time " << eventTime << " frame " << noteOffs.begin()->frame << std::endl; 773 std::cerr << "mixModel [note]: sending leftover note-off event at time " << eventTime << " frame " << noteOffs.begin()->frame << " pitch " << noteOffs.begin()->pitch << std::endl;
766 #endif 774 #endif
767 775
768 plugin->sendEvent(eventTime, &offEv); 776 plugin->sendEvent(eventTime, &offEv);
769 noteOffs.erase(noteOffs.begin()); 777 noteOffs.erase(noteOffs.begin());
770 } 778 }