Mercurial > hg > piper-vamp-js
comparison src/PiperAdapter.h @ 152:c43d2e93153f
Provide category and output static info
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Tue, 13 Jun 2017 17:25:47 +0100 |
parents | c0256c2debf5 |
children |
comparison
equal
deleted
inserted
replaced
151:9a0947545d37 | 152:c43d2e93153f |
---|---|
36 #define PIPER_ADAPTER_H | 36 #define PIPER_ADAPTER_H |
37 | 37 |
38 #include "vamp-support/PluginStaticData.h" | 38 #include "vamp-support/PluginStaticData.h" |
39 #include "vamp-support/PluginConfiguration.h" | 39 #include "vamp-support/PluginConfiguration.h" |
40 #include "vamp-support/RequestResponse.h" | 40 #include "vamp-support/RequestResponse.h" |
41 #include "vamp-support/StaticOutputDescriptor.h" | |
41 | 42 |
42 #include <vamp-hostsdk/PluginInputDomainAdapter.h> | 43 #include <vamp-hostsdk/PluginInputDomainAdapter.h> |
43 #include <vamp-hostsdk/PluginBufferingAdapter.h> | 44 #include <vamp-hostsdk/PluginBufferingAdapter.h> |
44 #include <vamp-hostsdk/PluginChannelAdapter.h> | 45 #include <vamp-hostsdk/PluginChannelAdapter.h> |
45 | 46 |
60 const int adaptInputDomain = 0x01; | 61 const int adaptInputDomain = 0x01; |
61 const int adaptChannelCount = 0x02; | 62 const int adaptChannelCount = 0x02; |
62 const int adaptBufferSize = 0x04; | 63 const int adaptBufferSize = 0x04; |
63 | 64 |
64 protected: | 65 protected: |
65 PiperAdapterBase(std::string libname) : m_soname(libname) { } | 66 PiperAdapterBase(std::string libname, |
67 std::vector<std::string> category = {}, | |
68 piper_vamp::StaticOutputInfo staticOutputInfo = {}) : | |
69 m_soname(libname), | |
70 m_category(category), | |
71 m_staticOutputInfo(staticOutputInfo) { } | |
66 | 72 |
67 public: | 73 public: |
68 virtual std::string getLibraryName() const override { | 74 virtual std::string getLibraryName() const override { |
69 return m_soname; | 75 return m_soname; |
70 } | 76 } |
71 | 77 |
72 virtual piper_vamp::PluginStaticData getStaticData() const override { | 78 virtual piper_vamp::PluginStaticData getStaticData() const override { |
73 Vamp::Plugin *p = createPlugin(44100.f); | 79 Vamp::Plugin *p = createPlugin(44100.f); |
74 auto data = piper_vamp::PluginStaticData::fromPlugin | 80 auto data = piper_vamp::PluginStaticData::fromPlugin |
75 (m_soname + ":" + p->getIdentifier(), | 81 (m_soname + ":" + p->getIdentifier(), |
76 {}, //!!! todo: category - tricky one that | 82 m_category, |
77 p); | 83 p); |
84 data.staticOutputInfo = m_staticOutputInfo; | |
78 delete p; | 85 delete p; |
79 return data; | 86 return data; |
80 } | 87 } |
81 | 88 |
82 virtual piper_vamp::LoadResponse loadPlugin(piper_vamp::LoadRequest r) | 89 virtual piper_vamp::LoadResponse loadPlugin(piper_vamp::LoadRequest r) |
105 piper_vamp::LoadResponse response; | 112 piper_vamp::LoadResponse response; |
106 response.plugin = p; | 113 response.plugin = p; |
107 | 114 |
108 response.staticData = piper_vamp::PluginStaticData::fromPlugin | 115 response.staticData = piper_vamp::PluginStaticData::fromPlugin |
109 (m_soname + ":" + p->getIdentifier(), | 116 (m_soname + ":" + p->getIdentifier(), |
110 {}, //!!! todo: category - tricky one that | 117 m_category, |
111 p); | 118 p); |
119 response.staticData.staticOutputInfo = m_staticOutputInfo; | |
112 | 120 |
113 int defaultChannels = 0; | 121 int defaultChannels = 0; |
114 if (p->getMinChannelCount() == p->getMaxChannelCount()) { | 122 if (p->getMinChannelCount() == p->getMaxChannelCount()) { |
115 defaultChannels = p->getMinChannelCount(); | 123 defaultChannels = p->getMinChannelCount(); |
116 } | 124 } |
139 return response; | 147 return response; |
140 } | 148 } |
141 | 149 |
142 private: | 150 private: |
143 std::string m_soname; | 151 std::string m_soname; |
152 std::vector<std::string> m_category; | |
153 piper_vamp::StaticOutputInfo m_staticOutputInfo; | |
144 }; | 154 }; |
145 | 155 |
146 template <typename P> | 156 template <typename P> |
147 class PiperAdapter : public PiperAdapterBase<P> | 157 class PiperAdapter : public PiperAdapterBase<P> |
148 { | 158 { |
149 public: | 159 public: |
150 PiperAdapter(std::string libname) : PiperAdapterBase<P>(libname) { } | 160 PiperAdapter(std::string libname, |
161 std::vector<std::string> category = {}, | |
162 piper_vamp::StaticOutputInfo staticOutputInfo = {}) : | |
163 PiperAdapterBase<P>(libname, category, staticOutputInfo) { } | |
151 | 164 |
152 virtual Vamp::Plugin *createPlugin(float inputSampleRate) const override { | 165 virtual Vamp::Plugin *createPlugin(float inputSampleRate) const override { |
153 return new P(inputSampleRate); | 166 return new P(inputSampleRate); |
154 } | 167 } |
155 }; | 168 }; |