c@5: 
c@5: #include "VampJson.h"
c@5: 
c@5: using std::cerr;
c@5: using std::endl;
c@5: 
c@5: int main(int, char **)
c@5: {
c@5:     Vamp::PluginBase::ParameterDescriptor d;
c@5:     d.identifier = "threshold";
c@5:     d.name = "Energy rise threshold";
c@5:     d.description = "Energy rise within a frequency bin necessary to count toward broadband total";
c@5:     d.unit = "dB";
c@5:     d.minValue = 0;
c@5:     d.maxValue = 20.5;
c@5:     d.defaultValue = 3;
c@5:     d.isQuantized = false;
c@5:     cerr << VampJson::fromParameterDescriptor(d).dump() << endl;
c@5: 
c@5:     Vamp::Plugin::OutputDescriptor od;
c@5:     od.identifier = "powerspectrum";
c@5:     od.name = "Power Spectrum";
c@5:     od.description = "Power values of the frequency spectrum bins calculated from the input signal";
c@5:     od.unit = "";
c@5:     od.hasFixedBinCount = true;
c@5:     od.binCount = 513;
c@5:     od.hasKnownExtents = false;
c@5:     od.isQuantized = false;
c@5:     od.sampleType = Vamp::Plugin::OutputDescriptor::OneSamplePerStep;
c@5:     cerr << VampJson::fromOutputDescriptor(od).dump() << endl;
c@5: 
c@5:     cerr << VampJson::fromFeature(Vamp::Plugin::Feature()).dump() << endl;
c@5:     
c@5:     Vamp::Plugin::Feature f;
c@5:     f.hasTimestamp = true;
c@5:     f.timestamp = Vamp::RealTime::fromSeconds(3.14159);
c@5:     f.hasDuration = false;
c@5:     f.values = { 1, 2, 3.000001, 4, 5, 6, 6.5, 7 };
c@5:     f.label = "A feature";
c@5:     cerr << VampJson::fromFeature(f).dump() << endl;
c@5: 
c@5:     Vamp::Plugin::FeatureSet fs;
c@5:     fs[0].push_back(f);
c@5:     std::string fs_str = VampJson::fromFeatureSet(fs).dump();
c@5:     cerr << fs_str << endl;
c@5: 
c@5:     std::string err;
c@5:     
c@5:     try {
c@5: 	Vamp::Plugin::ParameterDescriptor d1 =
c@5: 	    VampJson::toParameterDescriptor
c@5: 	    (json11::Json::parse
c@5: 	     (VampJson::fromParameterDescriptor(d).dump(), err));
c@5: 	if (err != "") {
c@5: 	    cerr << "error returned from parser: " << err << endl;
c@5: 	}
c@5: 	cerr << "\nsuccessfully converted parameter descriptor back from json: serialising it again, we get:" << endl;
c@5: 	cerr << VampJson::fromParameterDescriptor(d1).dump() << endl;
c@5:     } catch (std::runtime_error &e) {
c@5: 	cerr << "caught exception: " << e.what() << endl;
c@5:     }
c@5:     
c@5:     try {
c@5: 	Vamp::Plugin::OutputDescriptor od1 =
c@5: 	    VampJson::toOutputDescriptor
c@5: 	    (json11::Json::parse
c@5: 	     (VampJson::fromOutputDescriptor(od).dump(), err));
c@5: 	if (err != "") {
c@5: 	    cerr << "error returned from parser: " << err << endl;
c@5: 	}
c@5: 	cerr << "\nsuccessfully converted output descriptor back from json: serialising it again, we get:" << endl;
c@5: 	cerr << VampJson::fromOutputDescriptor(od1).dump() << endl;
c@5:     } catch (std::runtime_error &e) {
c@5: 	cerr << "caught exception: " << e.what() << endl;
c@5:     }
c@5:     
c@5:     try {
c@5: 	Vamp::Plugin::FeatureSet fs1 =
c@5: 	    VampJson::toFeatureSet
c@5: 	    (json11::Json::parse(fs_str, err));
c@5: 	if (err != "") {
c@5: 	    cerr << "error returned from parser: " << err << endl;
c@5: 	}
c@5: 	cerr << "\nsuccessfully converted feature set back from json: serialising it again, we get:" << endl;
c@5: 	cerr << VampJson::fromFeatureSet(fs1).dump() << endl;
c@5:     } catch (std::runtime_error &e) {
c@5: 	cerr << "caught exception: " << e.what() << endl;
c@5:     }
c@5: 
c@5:     return 0;
c@5: }
c@5: 
c@5:     
c@5: