annotate Test.h @ 80:f84e12a1553c tip

Update server certificate fingerprints
author Chris Cannam
date Wed, 14 Aug 2019 14:58:48 +0100
parents c7fd03f5ae02
children
rev   line source
cannam@0 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
cannam@0 2
cannam@0 3 /*
cannam@0 4 Vamp Plugin Tester
cannam@0 5 Chris Cannam, cannam@all-day-breakfast.com
cannam@0 6 Centre for Digital Music, Queen Mary, University of London.
Chris@42 7 Copyright 2009-2014 QMUL.
cannam@0 8
cannam@0 9 This program loads a Vamp plugin and tests its susceptibility to a
cannam@0 10 number of common pitfalls, including handling of extremes of input
cannam@0 11 data. If you can think of any additional useful tests that are
cannam@0 12 easily added, please send them to me.
cannam@0 13
cannam@0 14 Permission is hereby granted, free of charge, to any person
cannam@0 15 obtaining a copy of this software and associated documentation
cannam@0 16 files (the "Software"), to deal in the Software without
cannam@0 17 restriction, including without limitation the rights to use, copy,
cannam@0 18 modify, merge, publish, distribute, sublicense, and/or sell copies
cannam@0 19 of the Software, and to permit persons to whom the Software is
cannam@0 20 furnished to do so, subject to the following conditions:
cannam@0 21
cannam@0 22 The above copyright notice and this permission notice shall be
cannam@0 23 included in all copies or substantial portions of the Software.
cannam@0 24
cannam@0 25 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
cannam@0 26 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
cannam@0 27 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
cannam@0 28 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
cannam@0 29 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
cannam@0 30 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
cannam@0 31 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
cannam@0 32
cannam@0 33 Except as contained in this notice, the names of the Centre for
cannam@0 34 Digital Music; Queen Mary, University of London; and Chris Cannam
cannam@0 35 shall not be used in advertising or otherwise to promote the sale,
cannam@0 36 use or other dealings in this Software without prior written
cannam@0 37 authorization.
cannam@0 38 */
cannam@0 39
cannam@0 40 #ifndef _TEST_H_
cannam@0 41 #define _TEST_H_
cannam@0 42
cannam@0 43 #include <string>
cannam@0 44
cannam@0 45 #include <vamp-hostsdk/Plugin.h>
cannam@0 46
cannam@0 47 class Test
cannam@0 48 {
cannam@0 49 public:
cannam@0 50 virtual ~Test();
cannam@8 51
cannam@8 52 enum Option {
Chris@39 53 NoOption = 0x0,
Chris@39 54 NonDeterministic = 0x1,
Chris@39 55 Verbose = 0x2,
Chris@39 56 SingleTest = 0x4
cannam@8 57 };
cannam@8 58 typedef int Options;
cannam@0 59
cannam@0 60 class Result {
cannam@0 61
cannam@0 62 public:
cannam@3 63 enum Code { Success, Note, Warning, Error };
cannam@0 64
cannam@8 65 Result() : m_code(Success) { }
cannam@0 66 Result(Code c, std::string m) : m_code(c), m_message(m) { }
cannam@0 67
cannam@3 68 Code code() const { return m_code; }
cannam@3 69 std::string message() const { return m_message; }
cannam@8 70
cannam@0 71 protected:
cannam@0 72 Code m_code;
cannam@0 73 std::string m_message;
cannam@0 74 };
cannam@0 75
cannam@0 76 static Result success() { return Result(Result::Success, ""); }
cannam@3 77 static Result note(std::string m) { return Result(Result::Note, m); }
cannam@0 78 static Result warning(std::string m) { return Result(Result::Warning, m); }
cannam@0 79 static Result error(std::string m) { return Result(Result::Error, m); }
cannam@0 80
cannam@0 81 typedef std::vector<Result> Results;
cannam@0 82
cannam@0 83 class FailedToLoadPlugin { };
cannam@0 84
cannam@0 85 // may throw FailedToLoadPlugin
cannam@8 86 virtual Results test(std::string key, Options) = 0;
cannam@0 87
cannam@0 88 protected:
cannam@0 89 Test();
cannam@0 90
cannam@0 91 // may throw FailedToLoadPlugin
cannam@0 92 Vamp::Plugin *load(std::string key, float rate = 44100);
cannam@0 93
cannam@1 94 float **createBlock(size_t channels, size_t blocksize);
cannam@1 95 void destroyBlock(float **blocks, size_t channels);
cannam@1 96
cannam@3 97 float **createTestAudio(size_t channels, size_t blocksize, size_t blocks);
cannam@3 98 void destroyTestAudio(float **audio, size_t channels);
cannam@3 99
cannam@4 100 // use plugin's preferred step/block size, return them:
cannam@1 101 bool initDefaults(Vamp::Plugin *, size_t &channels,
cannam@1 102 size_t &step, size_t &block, Results &r);
cannam@1 103
cannam@4 104 // use the given step/block size and an adapter:
cannam@3 105 bool initAdapted(Vamp::Plugin *, size_t &channels,
cannam@3 106 size_t step, size_t block, Results &r);
cannam@3 107
cannam@0 108 void appendFeatures(Vamp::Plugin::FeatureSet &a,
cannam@0 109 const Vamp::Plugin::FeatureSet &b);
cannam@1 110
cannam@1 111 bool allFeaturesValid(const Vamp::Plugin::FeatureSet &); // i.e. no NaN/inf
cannam@3 112
Chris@53 113 bool containsTimestamps(const Vamp::Plugin::FeatureSet &);
Chris@53 114
Chris@61 115 void dumpFeature(const Vamp::Plugin::Feature &, bool showValues,
Chris@61 116 const Vamp::Plugin::Feature *other = 0);
Chris@52 117 void dump(const Vamp::Plugin::FeatureSet &, bool showValues = true);
Chris@52 118 void dumpTwo(const Result &r,
Chris@52 119 const Vamp::Plugin::FeatureSet &,
Chris@52 120 const Vamp::Plugin::FeatureSet &);
Chris@52 121 void dumpDiff(const Result &r,
Chris@52 122 const Vamp::Plugin::FeatureSet &,
Chris@52 123 const Vamp::Plugin::FeatureSet &);
cannam@0 124 };
cannam@0 125
cannam@0 126 extern bool operator==(const Vamp::Plugin::FeatureSet &a,
cannam@0 127 const Vamp::Plugin::FeatureSet &b);
cannam@0 128 extern bool operator==(const Vamp::Plugin::FeatureList &a,
cannam@0 129 const Vamp::Plugin::FeatureList &b);
cannam@0 130 extern bool operator==(const Vamp::Plugin::Feature &a,
cannam@0 131 const Vamp::Plugin::Feature &b);
cannam@0 132
cannam@0 133 #endif
cannam@0 134