Mercurial > hg > svcore
comparison data/model/DenseTimeValueModel.cpp @ 838:33fca917c800
Add toDelimitedDataString alternative with frame extents
author | Chris Cannam |
---|---|
date | Wed, 09 Oct 2013 14:47:19 +0100 |
parents | 5858cc462d0a |
children | e802e550a1f2 |
comparison
equal
deleted
inserted
replaced
837:1de00ee53be1 | 838:33fca917c800 |
---|---|
14 */ | 14 */ |
15 | 15 |
16 #include "DenseTimeValueModel.h" | 16 #include "DenseTimeValueModel.h" |
17 #include "base/PlayParameterRepository.h" | 17 #include "base/PlayParameterRepository.h" |
18 | 18 |
19 #include <QStringList> | |
20 | |
19 DenseTimeValueModel::DenseTimeValueModel() | 21 DenseTimeValueModel::DenseTimeValueModel() |
20 { | 22 { |
21 PlayParameterRepository::getInstance()->addPlayable(this); | 23 PlayParameterRepository::getInstance()->addPlayable(this); |
22 } | 24 } |
23 | 25 |
24 DenseTimeValueModel::~DenseTimeValueModel() | 26 DenseTimeValueModel::~DenseTimeValueModel() |
25 { | 27 { |
26 PlayParameterRepository::getInstance()->removePlayable(this); | 28 PlayParameterRepository::getInstance()->removePlayable(this); |
27 } | 29 } |
28 | 30 |
31 QString | |
32 DenseTimeValueModel::toDelimitedDataString(QString delimiter, size_t f0, size_t f1) const | |
33 { | |
34 size_t ch = getChannelCount(); | |
35 | |
36 std::cerr << "f0 = " << f0 << ", f1 = " << f1 << std::endl; | |
37 | |
38 if (f1 <= f0) return ""; | |
39 | |
40 float **all = new float *[ch]; | |
41 for (size_t c = 0; c < ch; ++c) { | |
42 all[c] = new float[f1 - f0]; | |
43 } | |
44 | |
45 size_t n = getData(0, ch - 1, f0, f1 - f0, all); | |
46 | |
47 QStringList list; | |
48 for (size_t i = 0; i < n; ++i) { | |
49 QStringList parts; | |
50 parts << QString("%1").arg(f0 + i); | |
51 for (size_t c = 0; c < ch; ++c) { | |
52 parts << QString("%1").arg(all[c][i]); | |
53 } | |
54 list << parts.join(delimiter); | |
55 } | |
56 | |
57 for (size_t c = 0; c < ch; ++c) { | |
58 delete[] all[c]; | |
59 } | |
60 delete[] all; | |
61 | |
62 return list.join("\n"); | |
63 } |