Mercurial > hg > vamp-plugin-sdk
comparison vamp-sdk/PluginAdapter.cpp @ 167:31eda4b11f2b
* First bit of Vamp v2 work -- add an optional duration to features in
a backward compatible way.
Warning: this code is unstable and experimental and may change
significantly in the coming weeks.
author | cannam |
---|---|
date | Thu, 17 Jul 2008 08:52:26 +0000 |
parents | 44e6b94c2696 |
children | 006a775133b1 |
comparison
equal
deleted
inserted
replaced
166:120f88880347 | 167:31eda4b11f2b |
---|---|
53 | 53 |
54 protected: | 54 protected: |
55 PluginAdapterBase *m_base; | 55 PluginAdapterBase *m_base; |
56 | 56 |
57 static VampPluginHandle vampInstantiate(const VampPluginDescriptor *desc, | 57 static VampPluginHandle vampInstantiate(const VampPluginDescriptor *desc, |
58 float inputSampleRate); | 58 float inputSampleRate); |
59 | 59 |
60 static void vampCleanup(VampPluginHandle handle); | 60 static void vampCleanup(VampPluginHandle handle); |
61 | 61 |
62 static int vampInitialise(VampPluginHandle handle, unsigned int channels, | 62 static int vampInitialise(VampPluginHandle handle, unsigned int channels, |
63 unsigned int stepSize, unsigned int blockSize); | 63 unsigned int stepSize, unsigned int blockSize); |
590 if (list[i].features[j].values) { | 590 if (list[i].features[j].values) { |
591 free(list[i].features[j].values); | 591 free(list[i].features[j].values); |
592 } | 592 } |
593 } | 593 } |
594 if (list[i].features) free(list[i].features); | 594 if (list[i].features) free(list[i].features); |
595 if (list[i].featuresV2) free(list[i].featuresV2); | |
595 } | 596 } |
596 m_fs.erase(plugin); | 597 m_fs.erase(plugin); |
597 m_fsizes.erase(plugin); | 598 m_fsizes.erase(plugin); |
598 m_fvsizes.erase(plugin); | 599 m_fvsizes.erase(plugin); |
599 } | 600 } |
705 return convertFeatures(plugin, plugin->getRemainingFeatures()); | 706 return convertFeatures(plugin, plugin->getRemainingFeatures()); |
706 } | 707 } |
707 | 708 |
708 VampFeatureList * | 709 VampFeatureList * |
709 PluginAdapterBase::Impl::convertFeatures(Plugin *plugin, | 710 PluginAdapterBase::Impl::convertFeatures(Plugin *plugin, |
710 const Plugin::FeatureSet &features) | 711 const Plugin::FeatureSet &features) |
711 { | 712 { |
712 int lastN = -1; | 713 int lastN = -1; |
713 | 714 |
714 int outputCount = 0; | 715 int outputCount = 0; |
715 if (m_pluginOutputs[plugin]) outputCount = m_pluginOutputs[plugin]->size(); | 716 if (m_pluginOutputs[plugin]) outputCount = m_pluginOutputs[plugin]->size(); |
750 feature->hasTimestamp = fl[j].hasTimestamp; | 751 feature->hasTimestamp = fl[j].hasTimestamp; |
751 feature->sec = fl[j].timestamp.sec; | 752 feature->sec = fl[j].timestamp.sec; |
752 feature->nsec = fl[j].timestamp.nsec; | 753 feature->nsec = fl[j].timestamp.nsec; |
753 feature->valueCount = fl[j].values.size(); | 754 feature->valueCount = fl[j].values.size(); |
754 | 755 |
756 VampFeatureV2 *v2 = &fs[n].featuresV2[j]; | |
757 | |
758 v2->hasDuration = fl[j].hasDuration; | |
759 v2->durationSec = fl[j].duration.sec; | |
760 v2->durationNsec = fl[j].duration.nsec; | |
761 | |
755 if (feature->label) free(feature->label); | 762 if (feature->label) free(feature->label); |
756 | 763 |
757 if (fl[j].label.empty()) { | 764 if (fl[j].label.empty()) { |
758 feature->label = 0; | 765 feature->label = 0; |
759 } else { | 766 } else { |
798 (m_fs[plugin], n * sizeof(VampFeatureList)); | 805 (m_fs[plugin], n * sizeof(VampFeatureList)); |
799 | 806 |
800 while (i < n) { | 807 while (i < n) { |
801 m_fs[plugin][i].featureCount = 0; | 808 m_fs[plugin][i].featureCount = 0; |
802 m_fs[plugin][i].features = 0; | 809 m_fs[plugin][i].features = 0; |
810 m_fs[plugin][i].featuresV2 = 0; | |
803 m_fsizes[plugin].push_back(0); | 811 m_fsizes[plugin].push_back(0); |
804 m_fvsizes[plugin].push_back(std::vector<size_t>()); | 812 m_fvsizes[plugin].push_back(std::vector<size_t>()); |
805 i++; | 813 i++; |
806 } | 814 } |
807 } | 815 } |
818 // std::cerr << "resizing from " << i << std::endl; | 826 // std::cerr << "resizing from " << i << std::endl; |
819 | 827 |
820 m_fs[plugin][n].features = (VampFeature *)realloc | 828 m_fs[plugin][n].features = (VampFeature *)realloc |
821 (m_fs[plugin][n].features, sz * sizeof(VampFeature)); | 829 (m_fs[plugin][n].features, sz * sizeof(VampFeature)); |
822 | 830 |
831 m_fs[plugin][n].featuresV2 = (VampFeatureV2 *)realloc | |
832 (m_fs[plugin][n].featuresV2, sz * sizeof(VampFeatureV2)); | |
833 | |
823 while (m_fsizes[plugin][n] < sz) { | 834 while (m_fsizes[plugin][n] < sz) { |
835 m_fs[plugin][n].features[m_fsizes[plugin][n]].hasTimestamp = 0; | |
824 m_fs[plugin][n].features[m_fsizes[plugin][n]].valueCount = 0; | 836 m_fs[plugin][n].features[m_fsizes[plugin][n]].valueCount = 0; |
825 m_fs[plugin][n].features[m_fsizes[plugin][n]].values = 0; | 837 m_fs[plugin][n].features[m_fsizes[plugin][n]].values = 0; |
826 m_fs[plugin][n].features[m_fsizes[plugin][n]].label = 0; | 838 m_fs[plugin][n].features[m_fsizes[plugin][n]].label = 0; |
839 m_fs[plugin][n].featuresV2[m_fsizes[plugin][n]].hasDuration = 0; | |
827 m_fvsizes[plugin][n].push_back(0); | 840 m_fvsizes[plugin][n].push_back(0); |
828 m_fsizes[plugin][n]++; | 841 m_fsizes[plugin][n]++; |
829 } | 842 } |
830 } | 843 } |
831 | 844 |