annotate data/model/DenseTimeValueModel.cpp @ 963:12e62865fd61

As coverity points out, MIDI_END_OF_EXCLUSIVE (0xF7) cannot result from masking with MIDI_MESSAGE_TYPE_MASK(0xF0). Not that it really matters here.
author Chris Cannam
date Wed, 03 Sep 2014 10:40:37 +0100
parents 59e7fe1b1003
children cc27f35aa75c
rev   line source
Chris@147 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@147 2
Chris@147 3 /*
Chris@147 4 Sonic Visualiser
Chris@147 5 An audio file viewer and annotation editor.
Chris@147 6 Centre for Digital Music, Queen Mary, University of London.
Chris@147 7 This file copyright 2006 Chris Cannam.
Chris@147 8
Chris@147 9 This program is free software; you can redistribute it and/or
Chris@147 10 modify it under the terms of the GNU General Public License as
Chris@147 11 published by the Free Software Foundation; either version 2 of the
Chris@147 12 License, or (at your option) any later version. See the file
Chris@147 13 COPYING included with this distribution for more information.
Chris@147 14 */
Chris@147 15
Chris@147 16 #include "DenseTimeValueModel.h"
Chris@150 17 #include "base/PlayParameterRepository.h"
Chris@147 18
Chris@838 19 #include <QStringList>
Chris@838 20
Chris@147 21 DenseTimeValueModel::DenseTimeValueModel()
Chris@147 22 {
Chris@391 23 PlayParameterRepository::getInstance()->addPlayable(this);
Chris@391 24 }
Chris@391 25
Chris@391 26 DenseTimeValueModel::~DenseTimeValueModel()
Chris@391 27 {
Chris@391 28 PlayParameterRepository::getInstance()->removePlayable(this);
Chris@147 29 }
Chris@147 30
Chris@838 31 QString
Chris@929 32 DenseTimeValueModel::toDelimitedDataStringSubset(QString delimiter, int f0, int f1) const
Chris@838 33 {
Chris@929 34 int ch = getChannelCount();
Chris@838 35
Chris@843 36 cerr << "f0 = " << f0 << ", f1 = " << f1 << endl;
Chris@838 37
Chris@838 38 if (f1 <= f0) return "";
Chris@838 39
Chris@838 40 float **all = new float *[ch];
Chris@929 41 for (int c = 0; c < ch; ++c) {
Chris@838 42 all[c] = new float[f1 - f0];
Chris@838 43 }
Chris@838 44
Chris@929 45 int n = getData(0, ch - 1, f0, f1 - f0, all);
Chris@838 46
Chris@838 47 QStringList list;
Chris@929 48 for (int i = 0; i < n; ++i) {
Chris@838 49 QStringList parts;
Chris@838 50 parts << QString("%1").arg(f0 + i);
Chris@929 51 for (int c = 0; c < ch; ++c) {
Chris@838 52 parts << QString("%1").arg(all[c][i]);
Chris@838 53 }
Chris@838 54 list << parts.join(delimiter);
Chris@838 55 }
Chris@838 56
Chris@929 57 for (int c = 0; c < ch; ++c) {
Chris@838 58 delete[] all[c];
Chris@838 59 }
Chris@838 60 delete[] all;
Chris@838 61
Chris@838 62 return list.join("\n");
Chris@838 63 }