comparison VampTestPlugin.cpp @ 17:ac7f544c7b20

Give the plugin a parameter
author Chris Cannam
date Tue, 25 Nov 2014 12:00:52 +0000
parents 33a799b77949
children 014cce47e998
comparison
equal deleted inserted replaced
16:a7bd1daac7f3 17:ac7f544c7b20
8 8
9 using Vamp::RealTime; 9 using Vamp::RealTime;
10 10
11 VampTestPlugin::VampTestPlugin(float inputSampleRate) : 11 VampTestPlugin::VampTestPlugin(float inputSampleRate) :
12 Plugin(inputSampleRate), 12 Plugin(inputSampleRate),
13 m_produceOutput(true),
13 m_n(0), 14 m_n(0),
14 m_stepSize(0), 15 m_stepSize(0),
15 m_blockSize(0) 16 m_blockSize(0)
16 { 17 {
17 for (int i = 0; i < 10; ++i) { 18 for (int i = 0; i < 10; ++i) {
48 } 49 }
49 50
50 int 51 int
51 VampTestPlugin::getPluginVersion() const 52 VampTestPlugin::getPluginVersion() const
52 { 53 {
53 return 1; 54 return 2;
54 } 55 }
55 56
56 string 57 string
57 VampTestPlugin::getCopyright() const 58 VampTestPlugin::getCopyright() const
58 { 59 {
91 92
92 VampTestPlugin::ParameterList 93 VampTestPlugin::ParameterList
93 VampTestPlugin::getParameterDescriptors() const 94 VampTestPlugin::getParameterDescriptors() const
94 { 95 {
95 ParameterList list; 96 ParameterList list;
97
98 // Provide one parameter, and make it so that we can easily tell
99 // whether it has been changed
100 ParameterDescriptor d;
101 d.identifier = "produce_output";
102 d.name = "Produce some output";
103 d.description = "Whether to produce any output. If this parameter is switched off, the plugin will produce no output. This is intended for basic testing of whether a host's parameter setting logic is functioning.";
104 d.unit = "";
105 d.minValue = 0;
106 d.maxValue = 1;
107 d.defaultValue = 1;
108 d.isQuantized = true;
109 d.quantizeStep = 1;
110 list.push_back(d);
111
96 return list; 112 return list;
97 } 113 }
98 114
99 float 115 float
100 VampTestPlugin::getParameter(string identifier) const 116 VampTestPlugin::getParameter(string identifier) const
101 { 117 {
118 if (identifier == "produce_output") {
119 return m_produceOutput ? 1.f : 0.f;
120 }
102 return 0; 121 return 0;
103 } 122 }
104 123
105 void 124 void
106 VampTestPlugin::setParameter(string identifier, float value) 125 VampTestPlugin::setParameter(string identifier, float value)
107 { 126 {
127 if (identifier == "produce_output") {
128 m_produceOutput = (value > 0.5);
129 }
108 } 130 }
109 131
110 VampTestPlugin::ProgramList 132 VampTestPlugin::ProgramList
111 VampTestPlugin::getPrograms() const 133 VampTestPlugin::getPrograms() const
112 { 134 {
445 } 467 }
446 468
447 VampTestPlugin::FeatureSet 469 VampTestPlugin::FeatureSet
448 VampTestPlugin::process(const float *const *inputBuffers, RealTime timestamp) 470 VampTestPlugin::process(const float *const *inputBuffers, RealTime timestamp)
449 { 471 {
472 if (!m_produceOutput) return FeatureSet();
450 FeatureSet fs = featuresFrom(timestamp, false); 473 FeatureSet fs = featuresFrom(timestamp, false);
451 return fs; 474 return fs;
452 } 475 }
453 476
454 VampTestPlugin::FeatureSet 477 VampTestPlugin::FeatureSet
455 VampTestPlugin::getRemainingFeatures() 478 VampTestPlugin::getRemainingFeatures()
456 { 479 {
480 if (!m_produceOutput) return FeatureSet();
457 FeatureSet fs = featuresFrom(m_lastTime, true); 481 FeatureSet fs = featuresFrom(m_lastTime, true);
458 return fs; 482 return fs;
459 } 483 }
460 484