# HG changeset patch # User Chris Cannam # Date 1413376225 -3600 # Node ID d0be35a305cc3848745e5fa13c18fb2d48d125c0 # Parent ddc47a055434c5fce3ff6870d1636b1a2ecb9d4c Add transform metadata to output diff -r ddc47a055434 -r d0be35a305cc .hgsubstate --- a/.hgsubstate Wed Oct 15 13:06:38 2014 +0100 +++ b/.hgsubstate Wed Oct 15 13:30:25 2014 +0100 @@ -1,3 +1,3 @@ d16f0fd6db6104d87882bc43788a3bb1b0f8c528 dataquay 879bdc878826bebec67130326f99397c430419b1 sv-dependency-builds -274c4362bda661a7ef7706cf6b160777b88b3abe svcore +7d003fe48225c0fc4f811de075b4d7f0b9bc599b svcore diff -r ddc47a055434 -r d0be35a305cc runner/JAMSFeatureWriter.cpp --- a/runner/JAMSFeatureWriter.cpp Wed Oct 15 13:06:38 2014 +0100 +++ b/runner/JAMSFeatureWriter.cpp Wed Oct 15 13:30:25 2014 +0100 @@ -125,13 +125,15 @@ " \"annotation_metadata\": {\n" " \"annotation_tools\": \"Sonic Annotator v%2\",\n" " \"data_source\": \"Automatic feature extraction\",\n" - " \"annotator\": { \"transform_id\": \"%3\" }\n" + " \"annotator\": {\n" + "%3" + " },\n" " },\n" " \"data\": ["); m_data[tt] = json .arg(getTaskKey(m_tasks[transformId])) .arg(RUNNER_VERSION) - .arg(transformId); + .arg(writeTransformToObjectContents(transform)); justBegun = true; } @@ -337,3 +339,70 @@ } return "unknown"; } + +QString +JAMSFeatureWriter::writeTransformToObjectContents(const Transform &t) +{ + QString json; + QString stpl(" \"%1\": \"%2\",\n"); + QString ntpl(" \"%1\": %2,\n"); + + json += stpl.arg("plugin_id").arg(t.getPluginIdentifier()); + json += stpl.arg("output_id").arg(t.getOutput()); + + if (t.getSummaryType() != Transform::NoSummary) { + json += stpl.arg("summary_type") + .arg(Transform::summaryTypeToString(t.getSummaryType())); + } + + if (t.getPluginVersion() != QString()) { + json += stpl.arg("plugin_version").arg(t.getPluginVersion()); + } + + if (t.getProgram() != QString()) { + json += stpl.arg("program").arg(t.getProgram()); + } + + if (t.getStepSize() != 0) { + json += ntpl.arg("step_size").arg(t.getStepSize()); + } + + if (t.getBlockSize() != 0) { + json += ntpl.arg("block_size").arg(t.getBlockSize()); + } + + if (t.getWindowType() != HanningWindow) { + json += stpl.arg("window_type") + .arg(Window::getNameForType(t.getWindowType()).c_str()); + } + + if (t.getStartTime() != RealTime::zeroTime) { + json += ntpl.arg("start").arg(t.getStartTime().toDouble()); + } + + if (t.getDuration() != RealTime::zeroTime) { + json += ntpl.arg("duration").arg(t.getDuration().toDouble()); + } + + if (t.getSampleRate() != 0) { + json += ntpl.arg("sample_rate").arg(t.getSampleRate()); + } + + if (!t.getParameters().empty()) { + json += QString(" \"parameters\": {\n"); + Transform::ParameterMap parameters = t.getParameters(); + for (Transform::ParameterMap::const_iterator i = parameters.begin(); + i != parameters.end(); ++i) { + QString name = i->first; + float value = i->second; + json += QString(" \"%1\": %2\n").arg(name).arg(value); + } + json += QString(" },\n"); + } + + // no trailing comma on final property: + json += QString(" \"transform_id\": \"%1\"\n").arg(t.getIdentifier()); + + return json; +} + diff -r ddc47a055434 -r d0be35a305cc runner/JAMSFeatureWriter.h --- a/runner/JAMSFeatureWriter.h Wed Oct 15 13:06:38 2014 +0100 +++ b/runner/JAMSFeatureWriter.h Wed Oct 15 13:30:25 2014 +0100 @@ -79,6 +79,8 @@ QString getTaskKey(Task); + QString writeTransformToObjectContents(const Transform &); + bool m_network; bool m_networkRetrieved; };