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@1815
|
19
|
Chris@1815
|
20 QString
|
Chris@1815
|
21 DenseTimeValueModel::getDelimitedDataHeaderLine(QString delimiter,
|
Chris@1815
|
22 DataExportOptions) const
|
Chris@1815
|
23 {
|
Chris@1815
|
24 int ch = getChannelCount();
|
Chris@1815
|
25 QStringList list;
|
Chris@1815
|
26 for (int i = 0; i < ch; ++i) {
|
Chris@1815
|
27 list << QString("Channel%1").arg(i+1);
|
Chris@1815
|
28 }
|
Chris@1815
|
29 return list.join(delimiter);
|
Chris@1815
|
30 }
|
Chris@1815
|
31
|
Chris@838
|
32 QString
|
Chris@1679
|
33 DenseTimeValueModel::toDelimitedDataString(QString delimiter,
|
Chris@1679
|
34 DataExportOptions,
|
Chris@1679
|
35 sv_frame_t startFrame,
|
Chris@1679
|
36 sv_frame_t duration) const
|
Chris@838
|
37 {
|
Chris@929
|
38 int ch = getChannelCount();
|
Chris@838
|
39
|
Chris@1679
|
40 if (duration <= 0) return "";
|
Chris@838
|
41
|
Chris@1679
|
42 auto data = getMultiChannelData(0, ch - 1, startFrame, duration);
|
Chris@838
|
43
|
Chris@1096
|
44 if (data.empty() || data[0].empty()) return "";
|
Chris@1096
|
45
|
Chris@838
|
46 QStringList list;
|
Chris@1096
|
47 for (sv_frame_t i = 0; in_range_for(data[0], i); ++i) {
|
Chris@838
|
48 QStringList parts;
|
Chris@1679
|
49 parts << QString("%1").arg(startFrame + i);
|
Chris@1096
|
50 for (int c = 0; in_range_for(data, c); ++c) {
|
Chris@1096
|
51 parts << QString("%1").arg(data[c][i]);
|
Chris@838
|
52 }
|
Chris@838
|
53 list << parts.join(delimiter);
|
Chris@838
|
54 }
|
Chris@838
|
55
|
Chris@838
|
56 return list.join("\n");
|
Chris@838
|
57 }
|