svcore  1.9
DenseTimeValueModel.cpp
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2006 Chris Cannam.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #include "DenseTimeValueModel.h"
18 
19 #include <QStringList>
20 
22 {
24 }
25 
27 {
29 }
30 
31 QString
32 DenseTimeValueModel::toDelimitedDataStringSubset(QString delimiter, int f0, int f1) const
33 {
34  int ch = getChannelCount();
35 
36  cerr << "f0 = " << f0 << ", f1 = " << f1 << endl;
37 
38  if (f1 <= f0) return "";
39 
40  float **all = new float *[ch];
41  for (int c = 0; c < ch; ++c) {
42  all[c] = new float[f1 - f0];
43  }
44 
45  int n = getData(0, ch - 1, f0, f1 - f0, all);
46 
47  QStringList list;
48  for (int i = 0; i < n; ++i) {
49  QStringList parts;
50  parts << QString("%1").arg(f0 + i);
51  for (int c = 0; c < ch; ++c) {
52  parts << QString("%1").arg(all[c][i]);
53  }
54  list << parts.join(delimiter);
55  }
56 
57  for (int c = 0; c < ch; ++c) {
58  delete[] all[c];
59  }
60  delete[] all;
61 
62  return list.join("\n");
63 }
virtual int getChannelCount() const =0
Return the number of distinct channels for this model.
static PlayParameterRepository * getInstance()
void removePlayable(const Playable *playable)
virtual int getData(int channel, int start, int count, float *buffer) const =0
Get the specified set of samples from the given channel of the model in single-precision floating-poi...
virtual QString toDelimitedDataStringSubset(QString delimiter, int f0, int f1) const
void addPlayable(const Playable *playable)