Mercurial > hg > svcore
comparison data/model/DenseTimeValueModel.cpp @ 1096:4d9816ba0ebe simple-fft-model
Rework audio file reader API to prefer using std containers
author | Chris Cannam |
---|---|
date | Mon, 15 Jun 2015 12:19:47 +0100 |
parents | 9f4505ac9072 |
children | 48e9f538e6e9 |
comparison
equal
deleted
inserted
replaced
1095:b66734b5f806 | 1096:4d9816ba0ebe |
---|---|
35 | 35 |
36 cerr << "f0 = " << f0 << ", f1 = " << f1 << endl; | 36 cerr << "f0 = " << f0 << ", f1 = " << f1 << endl; |
37 | 37 |
38 if (f1 <= f0) return ""; | 38 if (f1 <= f0) return ""; |
39 | 39 |
40 float **all = new float *[ch]; | 40 auto data = getMultiChannelData(0, ch - 1, f0, f1 - f0); |
41 for (int c = 0; c < ch; ++c) { | |
42 all[c] = new float[f1 - f0]; | |
43 } | |
44 | 41 |
45 sv_frame_t n = getMultiChannelData(0, ch - 1, f0, f1 - f0, all); | 42 if (data.empty() || data[0].empty()) return ""; |
46 | 43 |
47 QStringList list; | 44 QStringList list; |
48 for (sv_frame_t i = 0; i < n; ++i) { | 45 for (sv_frame_t i = 0; in_range_for(data[0], i); ++i) { |
49 QStringList parts; | 46 QStringList parts; |
50 parts << QString("%1").arg(f0 + i); | 47 parts << QString("%1").arg(f0 + i); |
51 for (int c = 0; c < ch; ++c) { | 48 for (int c = 0; in_range_for(data, c); ++c) { |
52 parts << QString("%1").arg(all[c][i]); | 49 parts << QString("%1").arg(data[c][i]); |
53 } | 50 } |
54 list << parts.join(delimiter); | 51 list << parts.join(delimiter); |
55 } | 52 } |
56 | 53 |
57 for (int c = 0; c < ch; ++c) { | |
58 delete[] all[c]; | |
59 } | |
60 delete[] all; | |
61 | |
62 return list.join("\n"); | 54 return list.join("\n"); |
63 } | 55 } |