Mercurial > hg > svcore
diff base/Event.h @ 1815:c546429d4c2f
Add optional ability to write a header on delimited data output, & to write times in frames
author | Chris Cannam |
---|---|
date | Fri, 10 Jan 2020 14:29:54 +0000 |
parents | 6eb3a76c74f7 |
children | fd5a87f3c5b4 |
line wrap: on
line diff
--- a/base/Event.h Wed Jan 08 15:26:49 2020 +0000 +++ b/base/Event.h Fri Jan 10 14:29:54 2020 +0000 @@ -366,21 +366,67 @@ return n; } + QString getDelimitedDataHeaderLine(QString delimiter, + DataExportOptions opts, + ExportNameOptions nameOpts) const { + + QStringList list; + + // These are considered API rather than human-readable text - + // they shouldn't be translated + + if (opts & DataExportWriteTimeInFrames) { + list << "frame"; + } else { + list << "time"; + } + + if (m_haveValue) { + list << nameOpts.valueAttributeName; + } + + if (m_haveDuration) { + list << "duration"; + } + + if (m_haveLevel) { + if (!(opts & DataExportOmitLevels)) { + list << nameOpts.levelAttributeName; + } + } + + if (m_uri != "") { + list << nameOpts.uriAttributeName; + } + + list << "label"; + + return list.join(delimiter).toUpper(); + } + QString toDelimitedDataString(QString delimiter, DataExportOptions opts, sv_samplerate_t sampleRate) const { QStringList list; - list << RealTime::frame2RealTime(m_frame, sampleRate) - .toString().c_str(); + if (opts & DataExportWriteTimeInFrames) { + list << QString("%1").arg(m_frame); + } else { + list << RealTime::frame2RealTime(m_frame, sampleRate) + .toString().c_str(); + } if (m_haveValue) { list << QString("%1").arg(m_value); } if (m_haveDuration) { - list << RealTime::frame2RealTime(m_duration, sampleRate) - .toString().c_str(); + if (opts & DataExportWriteTimeInFrames) { + list << QString("%1").arg(m_duration); + } else { + list << RealTime::frame2RealTime(m_duration, sampleRate) + .toString().c_str(); + } } if (m_haveLevel) {