# HG changeset patch # User Chris Cannam # Date 1413304237 -3600 # Node ID ec6e69373997482c65b68a10dac1b8a0b5d13dac # Parent 694301cc71ccb10c8cc5a729c9ffb861891589c2 Implement end-times option for CSV writer (not yet tested) diff -r 694301cc71cc -r ec6e69373997 transform/CSVFeatureWriter.cpp --- a/transform/CSVFeatureWriter.cpp Tue Oct 14 10:07:02 2014 +0100 +++ b/transform/CSVFeatureWriter.cpp Tue Oct 14 17:30:37 2014 +0100 @@ -33,7 +33,8 @@ SupportStdOut, "csv"), m_separator(","), - m_sampleTiming(false) + m_sampleTiming(false), + m_endTimes(false) { } @@ -62,6 +63,11 @@ p.description = "Show timings as sample frame counts instead of in seconds."; p.hasArg = false; pl.push_back(p); + + p.name = "end-times"; + p.description = "Show start and end time instead of start and duration, for features with duration."; + p.hasArg = false; + pl.push_back(p); return pl; } @@ -79,6 +85,8 @@ m_separator = i->second.c_str(); } else if (i->first == "sample-timing") { m_sampleTiming = true; + } else if (i->first == "end-times") { + m_endTimes = true; } } } @@ -118,8 +126,14 @@ if (features[i].hasDuration) { stream << m_separator; - stream << Vamp::RealTime::realTime2Frame - (features[i].duration, transform.getSampleRate()); + if (m_endTimes) { + stream << Vamp::RealTime::realTime2Frame + (features[i].timestamp + features[i].duration, + transform.getSampleRate()); + } else { + stream << Vamp::RealTime::realTime2Frame + (features[i].duration, transform.getSampleRate()); + } } } else { @@ -129,9 +143,17 @@ stream << timestamp; if (features[i].hasDuration) { - QString duration = features[i].duration.toString().c_str(); - duration.replace(QRegExp("^ +"), ""); - stream << m_separator << duration; + if (m_endTimes) { + QString endtime = + (features[i].timestamp + features[i].duration) + .toString().c_str(); + endtime.replace(QRegExp("^ +"), ""); + stream << m_separator << endtime; + } else { + QString duration = features[i].duration.toString().c_str(); + duration.replace(QRegExp("^ +"), ""); + stream << m_separator << duration; + } } } diff -r 694301cc71cc -r ec6e69373997 transform/CSVFeatureWriter.h --- a/transform/CSVFeatureWriter.h Tue Oct 14 10:07:02 2014 +0100 +++ b/transform/CSVFeatureWriter.h Tue Oct 14 17:30:37 2014 +0100 @@ -56,6 +56,7 @@ private: QString m_separator; bool m_sampleTiming; + bool m_endTimes; QString m_prevPrintedTrackId; };