annotate data/model/DenseTimeValueModel.cpp @ 1778:59d9dcfd67c2
Replace the model used for the cache part of the peak-cache model with a simple vector of vectors. Avoids unnecessary locking in a class that is not thread-safe in any case. Also record whether the final column is actually truncated, rather than risk possible backward seeks to re-read it in the case where it simply might be
author |
Chris Cannam |
date |
Wed, 11 Sep 2019 11:19:27 +0100 |
parents |
77543124651b |
children |
c546429d4c2f |
rev |
line source |
Chris@147
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@147
|
2
|
Chris@147
|
3 /*
|
Chris@147
|
4 Sonic Visualiser
|
Chris@147
|
5 An audio file viewer and annotation editor.
|
Chris@147
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@147
|
7 This file copyright 2006 Chris Cannam.
|
Chris@147
|
8
|
Chris@147
|
9 This program is free software; you can redistribute it and/or
|
Chris@147
|
10 modify it under the terms of the GNU General Public License as
|
Chris@147
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@147
|
12 License, or (at your option) any later version. See the file
|
Chris@147
|
13 COPYING included with this distribution for more information.
|
Chris@147
|
14 */
|
Chris@147
|
15
|
Chris@147
|
16 #include "DenseTimeValueModel.h"
|
Chris@147
|
17
|
Chris@838
|
18 #include <QStringList>
|
Chris@1429
|
19
|
Chris@838
|
20 QString
|
Chris@1679
|
21 DenseTimeValueModel::toDelimitedDataString(QString delimiter,
|
Chris@1679
|
22 DataExportOptions,
|
Chris@1679
|
23 sv_frame_t startFrame,
|
Chris@1679
|
24 sv_frame_t duration) const
|
Chris@838
|
25 {
|
Chris@929
|
26 int ch = getChannelCount();
|
Chris@838
|
27
|
Chris@1679
|
28 if (duration <= 0) return "";
|
Chris@838
|
29
|
Chris@1679
|
30 auto data = getMultiChannelData(0, ch - 1, startFrame, duration);
|
Chris@838
|
31
|
Chris@1096
|
32 if (data.empty() || data[0].empty()) return "";
|
Chris@1096
|
33
|
Chris@838
|
34 QStringList list;
|
Chris@1096
|
35 for (sv_frame_t i = 0; in_range_for(data[0], i); ++i) {
|
Chris@838
|
36 QStringList parts;
|
Chris@1679
|
37 parts << QString("%1").arg(startFrame + i);
|
Chris@1096
|
38 for (int c = 0; in_range_for(data, c); ++c) {
|
Chris@1096
|
39 parts << QString("%1").arg(data[c][i]);
|
Chris@838
|
40 }
|
Chris@838
|
41 list << parts.join(delimiter);
|
Chris@838
|
42 }
|
Chris@838
|
43
|
Chris@838
|
44 return list.join("\n");
|
Chris@838
|
45 }
|