svcore
1.9
|
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 00002 00003 /* 00004 Sonic Visualiser 00005 An audio file viewer and annotation editor. 00006 Centre for Digital Music, Queen Mary, University of London. 00007 This file copyright 2006 Chris Cannam. 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License as 00011 published by the Free Software Foundation; either version 2 of the 00012 License, or (at your option) any later version. See the file 00013 COPYING included with this distribution for more information. 00014 */ 00015 00016 #include "DenseTimeValueModel.h" 00017 #include "base/PlayParameterRepository.h" 00018 00019 #include <QStringList> 00020 00021 DenseTimeValueModel::DenseTimeValueModel() 00022 { 00023 PlayParameterRepository::getInstance()->addPlayable(this); 00024 } 00025 00026 DenseTimeValueModel::~DenseTimeValueModel() 00027 { 00028 PlayParameterRepository::getInstance()->removePlayable(this); 00029 } 00030 00031 QString 00032 DenseTimeValueModel::toDelimitedDataStringSubset(QString delimiter, int f0, int f1) const 00033 { 00034 int ch = getChannelCount(); 00035 00036 cerr << "f0 = " << f0 << ", f1 = " << f1 << endl; 00037 00038 if (f1 <= f0) return ""; 00039 00040 float **all = new float *[ch]; 00041 for (int c = 0; c < ch; ++c) { 00042 all[c] = new float[f1 - f0]; 00043 } 00044 00045 int n = getData(0, ch - 1, f0, f1 - f0, all); 00046 00047 QStringList list; 00048 for (int i = 0; i < n; ++i) { 00049 QStringList parts; 00050 parts << QString("%1").arg(f0 + i); 00051 for (int c = 0; c < ch; ++c) { 00052 parts << QString("%1").arg(all[c][i]); 00053 } 00054 list << parts.join(delimiter); 00055 } 00056 00057 for (int c = 0; c < ch; ++c) { 00058 delete[] all[c]; 00059 } 00060 delete[] all; 00061 00062 return list.join("\n"); 00063 }