Mercurial > hg > svcore
comparison 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 |
comparison
equal
deleted
inserted
replaced
1814:1318e069906b | 1815:c546429d4c2f |
---|---|
364 } | 364 } |
365 | 365 |
366 return n; | 366 return n; |
367 } | 367 } |
368 | 368 |
369 QString getDelimitedDataHeaderLine(QString delimiter, | |
370 DataExportOptions opts, | |
371 ExportNameOptions nameOpts) const { | |
372 | |
373 QStringList list; | |
374 | |
375 // These are considered API rather than human-readable text - | |
376 // they shouldn't be translated | |
377 | |
378 if (opts & DataExportWriteTimeInFrames) { | |
379 list << "frame"; | |
380 } else { | |
381 list << "time"; | |
382 } | |
383 | |
384 if (m_haveValue) { | |
385 list << nameOpts.valueAttributeName; | |
386 } | |
387 | |
388 if (m_haveDuration) { | |
389 list << "duration"; | |
390 } | |
391 | |
392 if (m_haveLevel) { | |
393 if (!(opts & DataExportOmitLevels)) { | |
394 list << nameOpts.levelAttributeName; | |
395 } | |
396 } | |
397 | |
398 if (m_uri != "") { | |
399 list << nameOpts.uriAttributeName; | |
400 } | |
401 | |
402 list << "label"; | |
403 | |
404 return list.join(delimiter).toUpper(); | |
405 } | |
406 | |
369 QString toDelimitedDataString(QString delimiter, | 407 QString toDelimitedDataString(QString delimiter, |
370 DataExportOptions opts, | 408 DataExportOptions opts, |
371 sv_samplerate_t sampleRate) const { | 409 sv_samplerate_t sampleRate) const { |
372 QStringList list; | 410 QStringList list; |
373 | 411 |
374 list << RealTime::frame2RealTime(m_frame, sampleRate) | 412 if (opts & DataExportWriteTimeInFrames) { |
375 .toString().c_str(); | 413 list << QString("%1").arg(m_frame); |
414 } else { | |
415 list << RealTime::frame2RealTime(m_frame, sampleRate) | |
416 .toString().c_str(); | |
417 } | |
376 | 418 |
377 if (m_haveValue) { | 419 if (m_haveValue) { |
378 list << QString("%1").arg(m_value); | 420 list << QString("%1").arg(m_value); |
379 } | 421 } |
380 | 422 |
381 if (m_haveDuration) { | 423 if (m_haveDuration) { |
382 list << RealTime::frame2RealTime(m_duration, sampleRate) | 424 if (opts & DataExportWriteTimeInFrames) { |
383 .toString().c_str(); | 425 list << QString("%1").arg(m_duration); |
426 } else { | |
427 list << RealTime::frame2RealTime(m_duration, sampleRate) | |
428 .toString().c_str(); | |
429 } | |
384 } | 430 } |
385 | 431 |
386 if (m_haveLevel) { | 432 if (m_haveLevel) { |
387 if (!(opts & DataExportOmitLevels)) { | 433 if (!(opts & DataExportOmitLevels)) { |
388 list << QString("%1").arg(m_level); | 434 list << QString("%1").arg(m_level); |