Mercurial > hg > svapp
comparison audioio/AudioGenerator.cpp @ 26:cc48a7189152
* Modify to use Vamp SDK for proper feature extraction plugins.
Requires that the vamp-plugin-sdk directory tree be present below
plugin/ (it's separate in Subversion).
author | Chris Cannam |
---|---|
date | Fri, 31 Mar 2006 15:56:35 +0000 |
parents | cb23944ce9e2 |
children | dd2084d32652 |
comparison
equal
deleted
inserted
replaced
25:4593a7ebad93 | 26:cc48a7189152 |
---|---|
24 #include "model/SparseOneDimensionalModel.h" | 24 #include "model/SparseOneDimensionalModel.h" |
25 | 25 |
26 #include "plugin/RealTimePluginFactory.h" | 26 #include "plugin/RealTimePluginFactory.h" |
27 #include "plugin/RealTimePluginInstance.h" | 27 #include "plugin/RealTimePluginInstance.h" |
28 #include "plugin/PluginIdentifier.h" | 28 #include "plugin/PluginIdentifier.h" |
29 #include "plugin/PluginXml.h" | |
29 #include "plugin/api/alsa/seq_event.h" | 30 #include "plugin/api/alsa/seq_event.h" |
30 | 31 |
31 #include <iostream> | 32 #include <iostream> |
32 #include <math.h> | 33 #include <math.h> |
33 | 34 |
115 { | 116 { |
116 if (m_synthMap.find(model) == m_synthMap.end()) return; | 117 if (m_synthMap.find(model) == m_synthMap.end()) return; |
117 | 118 |
118 RealTimePluginInstance *plugin = m_synthMap[model]; | 119 RealTimePluginInstance *plugin = m_synthMap[model]; |
119 if (plugin) { | 120 if (plugin) { |
120 plugin->setParametersFromXml(configurationXml); | 121 PluginXml(plugin).setParametersFromXml(configurationXml); |
121 } | 122 } |
122 } | 123 } |
123 | 124 |
124 QString | 125 QString |
125 AudioGenerator::getDefaultPlayPluginId(const Model *model) | 126 AudioGenerator::getDefaultPlayPluginId(const Model *model) |
176 | 177 |
177 if (pluginId == "") return 0; | 178 if (pluginId == "") return 0; |
178 | 179 |
179 RealTimePluginInstance *plugin = loadPlugin(pluginId, ""); | 180 RealTimePluginInstance *plugin = loadPlugin(pluginId, ""); |
180 if (configurationXml != "") { | 181 if (configurationXml != "") { |
181 plugin->setParametersFromXml(configurationXml); | 182 PluginXml(plugin).setParametersFromXml(configurationXml); |
182 } | 183 } |
183 | 184 |
184 if (parameters) { | 185 if (parameters) { |
185 parameters->setPlayPluginId(pluginId); | 186 parameters->setPlayPluginId(pluginId); |
186 parameters->setPlayPluginConfiguration(configurationXml); | 187 parameters->setPlayPluginConfiguration(configurationXml); |
451 | 452 |
452 SparseOneDimensionalModel::PointList points = | 453 SparseOneDimensionalModel::PointList points = |
453 sodm->getPoints(reqStart + latency, | 454 sodm->getPoints(reqStart + latency, |
454 reqStart + latency + m_pluginBlockSize); | 455 reqStart + latency + m_pluginBlockSize); |
455 | 456 |
456 RealTime blockTime = RealTime::frame2RealTime | 457 Vamp::RealTime blockTime = Vamp::RealTime::frame2RealTime |
457 (startFrame + i * m_pluginBlockSize, m_sourceSampleRate); | 458 (startFrame + i * m_pluginBlockSize, m_sourceSampleRate); |
458 | 459 |
459 for (SparseOneDimensionalModel::PointList::iterator pli = | 460 for (SparseOneDimensionalModel::PointList::iterator pli = |
460 points.begin(); pli != points.end(); ++pli) { | 461 points.begin(); pli != points.end(); ++pli) { |
461 | 462 |
467 pliFrame >= reqStart + m_pluginBlockSize) continue; | 468 pliFrame >= reqStart + m_pluginBlockSize) continue; |
468 | 469 |
469 while (noteOffs.begin() != noteOffs.end() && | 470 while (noteOffs.begin() != noteOffs.end() && |
470 noteOffs.begin()->frame <= pliFrame) { | 471 noteOffs.begin()->frame <= pliFrame) { |
471 | 472 |
472 RealTime eventTime = RealTime::frame2RealTime | 473 Vamp::RealTime eventTime = Vamp::RealTime::frame2RealTime |
473 (noteOffs.begin()->frame, m_sourceSampleRate); | 474 (noteOffs.begin()->frame, m_sourceSampleRate); |
474 | 475 |
475 offEv.data.note.note = noteOffs.begin()->pitch; | 476 offEv.data.note.note = noteOffs.begin()->pitch; |
476 | 477 |
477 #ifdef DEBUG_AUDIO_GENERATOR | 478 #ifdef DEBUG_AUDIO_GENERATOR |
480 | 481 |
481 plugin->sendEvent(eventTime, &offEv); | 482 plugin->sendEvent(eventTime, &offEv); |
482 noteOffs.erase(noteOffs.begin()); | 483 noteOffs.erase(noteOffs.begin()); |
483 } | 484 } |
484 | 485 |
485 RealTime eventTime = RealTime::frame2RealTime | 486 Vamp::RealTime eventTime = Vamp::RealTime::frame2RealTime |
486 (pliFrame, m_sourceSampleRate); | 487 (pliFrame, m_sourceSampleRate); |
487 | 488 |
488 plugin->sendEvent(eventTime, &onEv); | 489 plugin->sendEvent(eventTime, &onEv); |
489 | 490 |
490 #ifdef DEBUG_AUDIO_GENERATOR | 491 #ifdef DEBUG_AUDIO_GENERATOR |
500 | 501 |
501 while (noteOffs.begin() != noteOffs.end() && | 502 while (noteOffs.begin() != noteOffs.end() && |
502 noteOffs.begin()->frame <= | 503 noteOffs.begin()->frame <= |
503 startFrame + i * m_pluginBlockSize + m_pluginBlockSize) { | 504 startFrame + i * m_pluginBlockSize + m_pluginBlockSize) { |
504 | 505 |
505 RealTime eventTime = RealTime::frame2RealTime | 506 Vamp::RealTime eventTime = Vamp::RealTime::frame2RealTime |
506 (noteOffs.begin()->frame, m_sourceSampleRate); | 507 (noteOffs.begin()->frame, m_sourceSampleRate); |
507 | 508 |
508 offEv.data.note.note = noteOffs.begin()->pitch; | 509 offEv.data.note.note = noteOffs.begin()->pitch; |
509 | 510 |
510 #ifdef DEBUG_AUDIO_GENERATOR | 511 #ifdef DEBUG_AUDIO_GENERATOR |
595 | 596 |
596 NoteModel::PointList points = | 597 NoteModel::PointList points = |
597 nm->getPoints(reqStart + latency, | 598 nm->getPoints(reqStart + latency, |
598 reqStart + latency + m_pluginBlockSize); | 599 reqStart + latency + m_pluginBlockSize); |
599 | 600 |
600 RealTime blockTime = RealTime::frame2RealTime | 601 Vamp::RealTime blockTime = Vamp::RealTime::frame2RealTime |
601 (startFrame + i * m_pluginBlockSize, m_sourceSampleRate); | 602 (startFrame + i * m_pluginBlockSize, m_sourceSampleRate); |
602 | 603 |
603 for (NoteModel::PointList::iterator pli = | 604 for (NoteModel::PointList::iterator pli = |
604 points.begin(); pli != points.end(); ++pli) { | 605 points.begin(); pli != points.end(); ++pli) { |
605 | 606 |
611 pliFrame >= reqStart + m_pluginBlockSize) continue; | 612 pliFrame >= reqStart + m_pluginBlockSize) continue; |
612 | 613 |
613 while (noteOffs.begin() != noteOffs.end() && | 614 while (noteOffs.begin() != noteOffs.end() && |
614 noteOffs.begin()->frame <= pliFrame) { | 615 noteOffs.begin()->frame <= pliFrame) { |
615 | 616 |
616 RealTime eventTime = RealTime::frame2RealTime | 617 Vamp::RealTime eventTime = Vamp::RealTime::frame2RealTime |
617 (noteOffs.begin()->frame, m_sourceSampleRate); | 618 (noteOffs.begin()->frame, m_sourceSampleRate); |
618 | 619 |
619 offEv.data.note.note = noteOffs.begin()->pitch; | 620 offEv.data.note.note = noteOffs.begin()->pitch; |
620 | 621 |
621 #ifdef DEBUG_AUDIO_GENERATOR | 622 #ifdef DEBUG_AUDIO_GENERATOR |
624 | 625 |
625 plugin->sendEvent(eventTime, &offEv); | 626 plugin->sendEvent(eventTime, &offEv); |
626 noteOffs.erase(noteOffs.begin()); | 627 noteOffs.erase(noteOffs.begin()); |
627 } | 628 } |
628 | 629 |
629 RealTime eventTime = RealTime::frame2RealTime | 630 Vamp::RealTime eventTime = Vamp::RealTime::frame2RealTime |
630 (pliFrame, m_sourceSampleRate); | 631 (pliFrame, m_sourceSampleRate); |
631 | 632 |
632 onEv.data.note.note = lrintf(pli->value); | 633 onEv.data.note.note = lrintf(pli->value); |
633 | 634 |
634 plugin->sendEvent(eventTime, &onEv); | 635 plugin->sendEvent(eventTime, &onEv); |
646 | 647 |
647 while (noteOffs.begin() != noteOffs.end() && | 648 while (noteOffs.begin() != noteOffs.end() && |
648 noteOffs.begin()->frame <= | 649 noteOffs.begin()->frame <= |
649 startFrame + i * m_pluginBlockSize + m_pluginBlockSize) { | 650 startFrame + i * m_pluginBlockSize + m_pluginBlockSize) { |
650 | 651 |
651 RealTime eventTime = RealTime::frame2RealTime | 652 Vamp::RealTime eventTime = Vamp::RealTime::frame2RealTime |
652 (noteOffs.begin()->frame, m_sourceSampleRate); | 653 (noteOffs.begin()->frame, m_sourceSampleRate); |
653 | 654 |
654 offEv.data.note.note = noteOffs.begin()->pitch; | 655 offEv.data.note.note = noteOffs.begin()->pitch; |
655 | 656 |
656 #ifdef DEBUG_AUDIO_GENERATOR | 657 #ifdef DEBUG_AUDIO_GENERATOR |