dev@190
|
1 #include "catch/catch.hpp"
|
dev@191
|
2 #include "vamp-client/Loader.h"
|
dev@191
|
3 #include "vamp-client/PluginClient.h"
|
dev@191
|
4 #include "vamp-client/PluginStub.h"
|
dev@191
|
5 #include "vamp-support/RequestResponse.h"
|
dev@191
|
6 #include <vector>
|
dev@190
|
7
|
dev@191
|
8 using namespace piper_vamp;
|
dev@191
|
9 using namespace piper_vamp::client;
|
dev@191
|
10 using AudioBuffer = std::vector<std::vector<float>>;
|
dev@190
|
11
|
dev@191
|
12 // This stub mimicks the interaction with a Piper server
|
dev@191
|
13 // Here we only need to implement the configure method
|
dev@191
|
14 // due to testing only the initialise implemention of PluginStub
|
dev@191
|
15 class StubClient : public PluginClient
|
dev@191
|
16 {
|
dev@191
|
17 public:
|
dev@191
|
18 StubClient(PluginStaticData staticData) : m_staticData(staticData) {}
|
dev@191
|
19
|
dev@191
|
20 ConfigurationResponse
|
dev@191
|
21 configure(PluginStub* plugin,
|
dev@191
|
22 PluginConfiguration config) override
|
dev@191
|
23 {
|
dev@191
|
24 const float scale = plugin->getParameter("framing-scale");
|
dev@191
|
25 ConfigurationResponse cr;
|
dev@191
|
26 cr.plugin = plugin;
|
dev@191
|
27
|
dev@191
|
28 // we want to return different framing sizes
|
dev@191
|
29 // than config provides
|
dev@191
|
30 // there isn't really any need to be doing this with a plugin param
|
dev@191
|
31 cr.framing.blockSize = config.framing.stepSize * scale;
|
dev@191
|
32 cr.framing.stepSize = config.framing.blockSize * scale;
|
dev@191
|
33
|
dev@191
|
34
|
dev@191
|
35 // just return some outputs anyway
|
dev@191
|
36 // to avoid a failure case we are not testing here.
|
dev@191
|
37 Vamp::Plugin::OutputDescriptor output;
|
dev@191
|
38 const auto basic = m_staticData.basicOutputInfo[0];
|
dev@191
|
39 output.identifier = basic.identifier;
|
dev@191
|
40 output.name = basic.name;
|
dev@191
|
41 output.description = basic.description;
|
dev@191
|
42 cr.outputs = {output};
|
dev@191
|
43 return cr;
|
dev@191
|
44 }
|
dev@191
|
45
|
dev@191
|
46 Vamp::Plugin::FeatureSet
|
dev@191
|
47 process(PluginStub* /*plugin*/,
|
dev@191
|
48 AudioBuffer /*channels*/,
|
dev@191
|
49 Vamp::RealTime /*timestamp*/) override
|
dev@191
|
50 {
|
dev@191
|
51 return {};
|
dev@191
|
52 }
|
dev@191
|
53
|
dev@191
|
54 Vamp::Plugin::FeatureSet
|
dev@191
|
55 finish(PluginStub* /*plugin*/) override
|
dev@191
|
56 {
|
dev@191
|
57 return {};
|
dev@191
|
58 }
|
dev@191
|
59
|
dev@191
|
60 void
|
dev@191
|
61 reset(PluginStub* /*plugin*/, PluginConfiguration /*config*/) override
|
dev@191
|
62 {}
|
dev@191
|
63 private:
|
dev@191
|
64 PluginStaticData m_staticData;
|
dev@191
|
65 };
|
dev@191
|
66
|
dev@191
|
67
|
dev@191
|
68 TEST_CASE("Init plugin with parameter dependent preferred framing sizes") {
|
dev@191
|
69
|
dev@191
|
70 PluginConfiguration defaultConfig;
|
dev@191
|
71 defaultConfig.channelCount = 1;
|
dev@191
|
72 defaultConfig.parameterValues = {};
|
dev@191
|
73 defaultConfig.framing.blockSize = 1024;
|
dev@191
|
74 defaultConfig.framing.stepSize = 512;
|
dev@191
|
75 defaultConfig.parameterValues = {{"framing-scale", 1.0}};
|
dev@191
|
76
|
dev@191
|
77 Vamp::PluginBase::ParameterDescriptor stubParam;
|
dev@191
|
78 stubParam.identifier = "framing-scale";
|
dev@191
|
79 stubParam.name = "Framing Scale Factor";
|
dev@191
|
80 stubParam.description = "Scales the preferred framing sizes";
|
dev@191
|
81 stubParam.maxValue = 2.0;
|
dev@191
|
82
|
dev@191
|
83 PluginStaticData staticData;
|
dev@191
|
84 staticData.pluginKey = "stub";
|
dev@191
|
85 staticData.basic = {"stub:param-init", "Stub", "Testing init"};
|
dev@191
|
86 staticData.maker = "Lucas Thompson";
|
dev@191
|
87 staticData.copyright = "GPL";
|
dev@191
|
88 staticData.pluginVersion = 1;
|
dev@191
|
89 staticData.category = {"Test"};
|
dev@191
|
90 staticData.minChannelCount = 1;
|
dev@191
|
91 staticData.maxChannelCount = 1;
|
dev@191
|
92 staticData.parameters = {stubParam};
|
dev@191
|
93 staticData.inputDomain = Vamp::Plugin::InputDomain::TimeDomain;
|
dev@191
|
94 staticData.basicOutputInfo = {{"output", "NA", "Not real"}};
|
dev@191
|
95
|
dev@191
|
96 StubClient stub {staticData};
|
dev@191
|
97
|
dev@191
|
98 PluginStub vampPiperAdapter {
|
dev@191
|
99 &stub,
|
dev@191
|
100 "stub", // plugin key
|
dev@191
|
101 44100.0, // sample rate
|
dev@191
|
102 0, // adapter flags, don't care here
|
dev@191
|
103 staticData,
|
dev@191
|
104 defaultConfig
|
dev@191
|
105 };
|
dev@191
|
106
|
dev@191
|
107 vampPiperAdapter.setParameter("framing-scale", 2.0);
|
dev@191
|
108 // setup
|
dev@191
|
109 REQUIRE(
|
dev@191
|
110 vampPiperAdapter.initialise(
|
dev@191
|
111 1,
|
dev@191
|
112 vampPiperAdapter.getPreferredStepSize(),
|
dev@191
|
113 vampPiperAdapter.getPreferredBlockSize()
|
dev@191
|
114 ) == false
|
dev@191
|
115 );
|
dev@191
|
116 REQUIRE(
|
dev@191
|
117 vampPiperAdapter.initialise(
|
dev@191
|
118 1,
|
dev@191
|
119 vampPiperAdapter.getPreferredStepSize(),
|
dev@191
|
120 vampPiperAdapter.getPreferredBlockSize()
|
dev@191
|
121 )
|
dev@191
|
122 );
|
dev@190
|
123 }
|