Mercurial > hg > svcore
comparison data/model/BoxModel.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 | 343ef2a866a4 |
children | 21c792334c2e |
comparison
equal
deleted
inserted
replaced
1814:1318e069906b | 1815:c546429d4c2f |
---|---|
346 options.levelAttributeName = "extent"; | 346 options.levelAttributeName = "extent"; |
347 | 347 |
348 m_events.toXml(out, indent, QString("dimensions=\"2\""), options); | 348 m_events.toXml(out, indent, QString("dimensions=\"2\""), options); |
349 } | 349 } |
350 | 350 |
351 QString getDelimitedDataHeaderLine(QString delimiter, | |
352 DataExportOptions opts) const override { | |
353 QStringList list; | |
354 | |
355 // These are considered API rather than human-readable text - | |
356 // they shouldn't be translated | |
357 | |
358 if (opts & DataExportWriteTimeInFrames) { | |
359 list << "startframe" << "endframe"; | |
360 } else { | |
361 list << "start" << "end"; | |
362 } | |
363 | |
364 list << "extent start" << "extent end" << "label"; | |
365 | |
366 return list.join(delimiter).toUpper(); | |
367 } | |
368 | |
351 QString toDelimitedDataString(QString delimiter, | 369 QString toDelimitedDataString(QString delimiter, |
352 DataExportOptions, | 370 DataExportOptions opts, |
353 sv_frame_t startFrame, | 371 sv_frame_t startFrame, |
354 sv_frame_t duration) const override { | 372 sv_frame_t duration) const override { |
355 | 373 |
356 // We need a custom format here | 374 // We need a custom format here |
357 | 375 |
361 | 379 |
362 for (auto e: ee) { | 380 for (auto e: ee) { |
363 | 381 |
364 QStringList list; | 382 QStringList list; |
365 | 383 |
366 list << RealTime::frame2RealTime | 384 if (opts & DataExportWriteTimeInFrames) { |
367 (e.getFrame(), getSampleRate()) | 385 |
368 .toString().c_str() | 386 list << QString("%1").arg(e.getFrame()); |
369 << RealTime::frame2RealTime | 387 list << QString("%1").arg(e.getFrame() + e.getDuration()); |
370 (e.getFrame() + e.getDuration(), getSampleRate()) | 388 |
371 .toString().c_str() | 389 } else { |
372 << QString("%1").arg(e.getValue()) | 390 |
373 << QString("%1").arg(e.getValue() + fabsf(e.getLevel())); | 391 list << RealTime::frame2RealTime |
392 (e.getFrame(), getSampleRate()) | |
393 .toString().c_str(); | |
394 | |
395 list << RealTime::frame2RealTime | |
396 (e.getFrame() + e.getDuration(), getSampleRate()) | |
397 .toString().c_str(); | |
398 } | |
399 | |
400 list << QString("%1").arg(e.getValue()); | |
401 | |
402 list << QString("%1").arg(e.getValue() + fabsf(e.getLevel())); | |
374 | 403 |
375 if (e.getLabel() != "") { | 404 if (e.getLabel() != "") { |
376 list << e.getLabel(); | 405 list << e.getLabel(); |
377 } | 406 } |
378 | 407 |