Chris@147: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
Chris@147: 
Chris@147: /*
Chris@147:     Sonic Visualiser
Chris@147:     An audio file viewer and annotation editor.
Chris@147:     Centre for Digital Music, Queen Mary, University of London.
Chris@147:     This file copyright 2006 Chris Cannam.
Chris@147:     
Chris@147:     This program is free software; you can redistribute it and/or
Chris@147:     modify it under the terms of the GNU General Public License as
Chris@147:     published by the Free Software Foundation; either version 2 of the
Chris@147:     License, or (at your option) any later version.  See the file
Chris@147:     COPYING included with this distribution for more information.
Chris@147: */
Chris@147: 
Chris@147: #include "DenseTimeValueModel.h"
Chris@150: #include "base/PlayParameterRepository.h"
Chris@147: 
Chris@838: #include <QStringList>
Chris@838: 
Chris@147: DenseTimeValueModel::DenseTimeValueModel()
Chris@147: {
Chris@391:     PlayParameterRepository::getInstance()->addPlayable(this);
Chris@391: }
Chris@391: 
Chris@391: DenseTimeValueModel::~DenseTimeValueModel()
Chris@391: {
Chris@391:     PlayParameterRepository::getInstance()->removePlayable(this);
Chris@147: }
Chris@147: 	
Chris@838: QString
Chris@1038: DenseTimeValueModel::toDelimitedDataStringSubset(QString delimiter, sv_frame_t f0, sv_frame_t f1) const
Chris@838: {
Chris@929:     int ch = getChannelCount();
Chris@838: 
Chris@843:     cerr << "f0 = " << f0 << ", f1 = " << f1 << endl;
Chris@838: 
Chris@838:     if (f1 <= f0) return "";
Chris@838: 
Chris@1096:     auto data = getMultiChannelData(0, ch - 1, f0, f1 - f0);
Chris@838: 
Chris@1096:     if (data.empty() || data[0].empty()) return "";
Chris@1096:     
Chris@838:     QStringList list;
Chris@1096:     for (sv_frame_t i = 0; in_range_for(data[0], i); ++i) {
Chris@838:         QStringList parts;
Chris@838:         parts << QString("%1").arg(f0 + i);
Chris@1096:         for (int c = 0; in_range_for(data, c); ++c) {
Chris@1096:             parts << QString("%1").arg(data[c][i]);
Chris@838:         }
Chris@838:         list << parts.join(delimiter);
Chris@838:     }
Chris@838: 
Chris@838:     return list.join("\n");
Chris@838: }