Mercurial > hg > piper-vamp-js
comparison PiperAdapter.h @ 46:b780e56eebb4
Update to match current namespaces etc in piper-cpp
author | Chris Cannam |
---|---|
date | Thu, 13 Oct 2016 18:13:55 +0100 |
parents | 90bf9d9f9c95 |
children | cedcaa258e22 |
comparison
equal
deleted
inserted
replaced
45:124f6d2fbaa2 | 46:b780e56eebb4 |
---|---|
33 */ | 33 */ |
34 | 34 |
35 #ifndef PIPER_ADAPTER_H | 35 #ifndef PIPER_ADAPTER_H |
36 #define PIPER_ADAPTER_H | 36 #define PIPER_ADAPTER_H |
37 | 37 |
38 #include <vamp-hostsdk/PluginStaticData.h> | 38 #include "vamp-support/PluginStaticData.h" |
39 #include <vamp-hostsdk/PluginConfiguration.h> | 39 #include "vamp-support/PluginConfiguration.h" |
40 #include <vamp-hostsdk/RequestResponse.h> | 40 #include "vamp-support/RequestResponse.h" |
41 | 41 |
42 #include <vamp-hostsdk/PluginInputDomainAdapter.h> | 42 #include <vamp-hostsdk/PluginInputDomainAdapter.h> |
43 #include <vamp-hostsdk/PluginBufferingAdapter.h> | 43 #include <vamp-hostsdk/PluginBufferingAdapter.h> |
44 #include <vamp-hostsdk/PluginChannelAdapter.h> | 44 #include <vamp-hostsdk/PluginChannelAdapter.h> |
45 | 45 |
46 namespace piper { | 46 namespace piper_vamp_js { //!!! not a good name for this namespace |
47 | 47 |
48 class PiperAdapterInterface | 48 class PiperAdapterInterface |
49 { | 49 { |
50 public: | 50 public: |
51 virtual Vamp::HostExt::PluginStaticData getStaticData() const = 0; | 51 virtual piper_vamp::PluginStaticData getStaticData() const = 0; |
52 virtual Vamp::HostExt::LoadResponse loadPlugin(Vamp::HostExt::LoadRequest r) const = 0; | 52 virtual piper_vamp::LoadResponse loadPlugin(piper_vamp::LoadRequest r) const = 0; |
53 virtual Vamp::Plugin *createPlugin(float inputSampleRate) const = 0; | 53 virtual Vamp::Plugin *createPlugin(float inputSampleRate) const = 0; |
54 }; | 54 }; |
55 | 55 |
56 template <typename P> | 56 template <typename P> |
57 class PiperAdapterBase : public PiperAdapterInterface | 57 class PiperAdapterBase : public PiperAdapterInterface |
64 PiperAdapterBase(std::string libname) : m_soname(libname) { } | 64 PiperAdapterBase(std::string libname) : m_soname(libname) { } |
65 | 65 |
66 public: | 66 public: |
67 virtual Vamp::Plugin *createPlugin(float inputSampleRate) const = 0; | 67 virtual Vamp::Plugin *createPlugin(float inputSampleRate) const = 0; |
68 | 68 |
69 virtual Vamp::HostExt::PluginStaticData getStaticData() const { | 69 virtual piper_vamp::PluginStaticData getStaticData() const { |
70 Vamp::Plugin *p = createPlugin(44100.f); | 70 Vamp::Plugin *p = createPlugin(44100.f); |
71 auto data = Vamp::HostExt::PluginStaticData::fromPlugin | 71 auto data = piper_vamp::PluginStaticData::fromPlugin |
72 (m_soname + ":" + p->getIdentifier(), | 72 (m_soname + ":" + p->getIdentifier(), |
73 {}, //!!! todo: category - tricky one that | 73 {}, //!!! todo: category - tricky one that |
74 p); | 74 p); |
75 delete p; | 75 delete p; |
76 return data; | 76 return data; |
77 } | 77 } |
78 | 78 |
79 virtual Vamp::HostExt::LoadResponse loadPlugin(Vamp::HostExt:: | 79 virtual piper_vamp::LoadResponse loadPlugin(piper_vamp::LoadRequest r) const { |
80 LoadRequest r) const { | |
81 | 80 |
82 // We assume the caller has guaranteed that the request is for | 81 // We assume the caller has guaranteed that the request is for |
83 // the correct plugin (so we don't have to check the plugin | 82 // the correct plugin (so we don't have to check the plugin |
84 // key field here) | 83 // key field here) |
85 | 84 |
97 | 96 |
98 if (r.adapterFlags & adaptChannelCount) { | 97 if (r.adapterFlags & adaptChannelCount) { |
99 p = new Vamp::HostExt::PluginChannelAdapter(p); | 98 p = new Vamp::HostExt::PluginChannelAdapter(p); |
100 } | 99 } |
101 | 100 |
102 Vamp::HostExt::LoadResponse response; | 101 piper_vamp::LoadResponse response; |
103 response.plugin = p; | 102 response.plugin = p; |
104 | 103 |
105 response.staticData = Vamp::HostExt::PluginStaticData::fromPlugin | 104 response.staticData = piper_vamp::PluginStaticData::fromPlugin |
106 (m_soname + ":" + p->getIdentifier(), | 105 (m_soname + ":" + p->getIdentifier(), |
107 {}, //!!! todo: category - tricky one that | 106 {}, //!!! todo: category - tricky one that |
108 p); | 107 p); |
109 | 108 |
110 int defaultChannels = 0; | 109 int defaultChannels = 0; |
111 if (p->getMinChannelCount() == p->getMaxChannelCount()) { | 110 if (p->getMinChannelCount() == p->getMaxChannelCount()) { |
112 defaultChannels = p->getMinChannelCount(); | 111 defaultChannels = p->getMinChannelCount(); |
113 } | 112 } |
114 | 113 |
115 response.defaultConfiguration = Vamp::HostExt::PluginConfiguration::fromPlugin | 114 response.defaultConfiguration = piper_vamp::PluginConfiguration::fromPlugin |
116 (p, | 115 (p, |
117 defaultChannels, | 116 defaultChannels, |
118 p->getPreferredStepSize(), | 117 p->getPreferredStepSize(), |
119 p->getPreferredBlockSize()); | 118 p->getPreferredBlockSize()); |
120 | 119 |