comparison vamp-json/VampJson.h @ 139:1c58149b64a2

Fix various compiler warnings
author Chris Cannam <c.cannam@qmul.ac.uk>
date Thu, 12 Jan 2017 08:49:36 +0000
parents 615fc5a47509
children 807a0a43096e
comparison
equal deleted inserted replaced
138:b01dac674beb 139:1c58149b64a2
37 37
38 #include <vector> 38 #include <vector>
39 #include <string> 39 #include <string>
40 #include <sstream> 40 #include <sstream>
41 #include <iterator> 41 #include <iterator>
42 #include <cmath>
42 43
43 #include <json11/json11.hpp> 44 #include <json11/json11.hpp>
44 #include <base-n/include/basen.hpp> 45 #include <base-n/include/basen.hpp>
45 46
46 #include <vamp-hostsdk/Plugin.h> 47 #include <vamp-hostsdk/Plugin.h>
261 262
262 if (!j["sampleRate"].is_number()) { 263 if (!j["sampleRate"].is_number()) {
263 err = "number expected for sample rate"; 264 err = "number expected for sample rate";
264 return {}; 265 return {};
265 } 266 }
266 od.sampleRate = j["sampleRate"].number_value(); 267 od.sampleRate = float(j["sampleRate"].number_value());
267 od.hasDuration = j["hasDuration"].bool_value(); 268 od.hasDuration = j["hasDuration"].bool_value();
268 269
269 if (j["binCount"].is_number() && j["binCount"].int_value() > 0) { 270 if (j["binCount"].is_number() && j["binCount"].int_value() > 0) {
270 od.hasFixedBinCount = true; 271 od.hasFixedBinCount = true;
271 od.binCount = j["binCount"].int_value(); 272 od.binCount = j["binCount"].int_value();
285 286
286 od.hasKnownExtents = extentsPresent; 287 od.hasKnownExtents = extentsPresent;
287 288
288 if (j["quantizeStep"].is_number()) { 289 if (j["quantizeStep"].is_number()) {
289 od.isQuantized = true; 290 od.isQuantized = true;
290 od.quantizeStep = j["quantizeStep"].number_value(); 291 od.quantizeStep = float(j["quantizeStep"].number_value());
291 } else { 292 } else {
292 od.isQuantized = false; 293 od.isQuantized = false;
293 } 294 }
294 295
295 return od; 296 return od;
354 if (!j["defaultValue"].is_number()) { 355 if (!j["defaultValue"].is_number()) {
355 err = "number expected for default value"; 356 err = "number expected for default value";
356 return {}; 357 return {};
357 } 358 }
358 359
359 pd.defaultValue = j["defaultValue"].number_value(); 360 pd.defaultValue = float(j["defaultValue"].number_value());
360 361
361 pd.valueNames.clear(); 362 pd.valueNames.clear();
362 for (auto &n: j["valueNames"].array_items()) { 363 for (auto &n: j["valueNames"].array_items()) {
363 if (!n.is_string()) { 364 if (!n.is_string()) {
364 err = "string expected for value name"; 365 err = "string expected for value name";
367 pd.valueNames.push_back(n.string_value()); 368 pd.valueNames.push_back(n.string_value());
368 } 369 }
369 370
370 if (j["quantizeStep"].is_number()) { 371 if (j["quantizeStep"].is_number()) {
371 pd.isQuantized = true; 372 pd.isQuantized = true;
372 pd.quantizeStep = j["quantizeStep"].number_value(); 373 pd.quantizeStep = float(j["quantizeStep"].number_value());
373 } else { 374 } else {
374 pd.isQuantized = false; 375 pd.isQuantized = false;
375 } 376 }
376 377
377 return pd; 378 return pd;
445 f.values = toFloatBuffer(j["featureValues"].string_value(), err); 446 f.values = toFloatBuffer(j["featureValues"].string_value(), err);
446 if (failed(err)) return {}; 447 if (failed(err)) return {};
447 serialisation = BufferSerialisation::Base64; 448 serialisation = BufferSerialisation::Base64;
448 } else if (j["featureValues"].is_array()) { 449 } else if (j["featureValues"].is_array()) {
449 for (auto v : j["featureValues"].array_items()) { 450 for (auto v : j["featureValues"].array_items()) {
450 f.values.push_back(v.number_value()); 451 f.values.push_back(float(v.number_value()));
451 } 452 }
452 serialisation = BufferSerialisation::Array; 453 serialisation = BufferSerialisation::Array;
453 } 454 }
454 f.label = j["label"].string_value(); 455 f.label = j["label"].string_value();
455 return f; 456 return f;
729 return {}; 730 return {};
730 } 731 }
731 732
732 PluginConfiguration config; 733 PluginConfiguration config;
733 734
734 config.channelCount = j["channelCount"].number_value(); 735 config.channelCount = int(round(j["channelCount"].number_value()));
735 config.stepSize = j["stepSize"].number_value(); 736 config.stepSize = int(round(j["stepSize"].number_value()));
736 config.blockSize = j["blockSize"].number_value(); 737 config.blockSize = int(round(j["blockSize"].number_value()));
737 738
738 for (auto &pv : j["parameterValues"].object_items()) { 739 for (auto &pv : j["parameterValues"].object_items()) {
739 config.parameterValues[pv.first] = pv.second.number_value(); 740 config.parameterValues[pv.first] = float(pv.second.number_value());
740 } 741 }
741 742
742 if (j["currentProgram"].is_string()) { 743 if (j["currentProgram"].is_string()) {
743 config.currentProgram = j["currentProgram"].string_value(); 744 config.currentProgram = j["currentProgram"].string_value();
744 } 745 }
875 return {}; 876 return {};
876 } 877 }
877 878
878 LoadRequest req; 879 LoadRequest req;
879 req.pluginKey = j["key"].string_value(); 880 req.pluginKey = j["key"].string_value();
880 req.inputSampleRate = j["inputSampleRate"].number_value(); 881 req.inputSampleRate = float(j["inputSampleRate"].number_value());
881 if (!j["adapterFlags"].is_null()) { 882 if (!j["adapterFlags"].is_null()) {
882 req.adapterFlags = toAdapterFlags(j["adapterFlags"], err); 883 req.adapterFlags = toAdapterFlags(j["adapterFlags"], err);
883 if (failed(err)) return {}; 884 if (failed(err)) return {};
884 } 885 }
885 return req; 886 return req;
1051 serialisation = BufferSerialisation::Base64; 1052 serialisation = BufferSerialisation::Base64;
1052 1053
1053 } else if (a.is_array()) { 1054 } else if (a.is_array()) {
1054 std::vector<float> buf; 1055 std::vector<float> buf;
1055 for (auto v : a.array_items()) { 1056 for (auto v : a.array_items()) {
1056 buf.push_back(v.number_value()); 1057 buf.push_back(float(v.number_value()));
1057 } 1058 }
1058 r.inputBuffers.push_back(buf); 1059 r.inputBuffers.push_back(buf);
1059 serialisation = BufferSerialisation::Array; 1060 serialisation = BufferSerialisation::Array;
1060 1061
1061 } else { 1062 } else {