# HG changeset patch # User Chris Cannam # Date 1427794794 -3600 # Node ID 1ec57a28e92438306def4772a847e84c6ceb56e1 # Parent c1e43c8d2527af44971a1f30c5231e94ab01b2a2# Parent 57633d605547924f16c02162f6e7f211fdcea783 Merge diff -r c1e43c8d2527 -r 1ec57a28e924 base/DataExportOptions.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/base/DataExportOptions.h Tue Mar 31 10:39:54 2015 +0100 @@ -0,0 +1,27 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Sonic Visualiser + An audio file viewer and annotation editor. + Centre for Digital Music, Queen Mary, University of London. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + +#ifndef DATA_EXPORT_OPTIONS_H +#define DATA_EXPORT_OPTIONS_H + +enum DataExportOption +{ + DataExportDefaults = 0x0, + DataExportFillGaps = 0x1, + DataExportOmitLevels = 0x2, +}; + +typedef int DataExportOptions; + +#endif diff -r c1e43c8d2527 -r 1ec57a28e924 base/Window.h --- a/base/Window.h Tue Mar 31 10:36:52 2015 +0100 +++ b/base/Window.h Tue Mar 31 10:39:54 2015 +0100 @@ -22,7 +22,7 @@ #include #include -#include +#include "system/System.h" enum WindowType { RectangularWindow, diff -r c1e43c8d2527 -r 1ec57a28e924 data/model/FlexiNoteModel.h --- a/data/model/FlexiNoteModel.h Tue Mar 31 10:36:52 2015 +0100 +++ b/data/model/FlexiNoteModel.h Tue Mar 31 10:39:54 2015 +0100 @@ -66,13 +66,15 @@ .arg(XmlExportable::encodeEntities(label)).arg(extraAttributes); } - QString toDelimitedDataString(QString delimiter, sv_samplerate_t sampleRate) const + QString toDelimitedDataString(QString delimiter, DataExportOptions opts, sv_samplerate_t sampleRate) const { QStringList list; list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); list << QString("%1").arg(value); list << RealTime::frame2RealTime(duration, sampleRate).toString().c_str(); - list << QString("%1").arg(level); + if (!(opts & DataExportOmitLevels)) { + list << QString("%1").arg(level); + } if (label != "") list << label; return list.join(delimiter); } diff -r c1e43c8d2527 -r 1ec57a28e924 data/model/ImageModel.h --- a/data/model/ImageModel.h Tue Mar 31 10:36:52 2015 +0100 +++ b/data/model/ImageModel.h Tue Mar 31 10:39:54 2015 +0100 @@ -55,7 +55,7 @@ .arg(extraAttributes); } - QString toDelimitedDataString(QString delimiter, sv_samplerate_t sampleRate) const + QString toDelimitedDataString(QString delimiter, DataExportOptions, sv_samplerate_t sampleRate) const { QStringList list; list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); diff -r c1e43c8d2527 -r 1ec57a28e924 data/model/Model.h --- a/data/model/Model.h Tue Mar 31 10:36:52 2015 +0100 +++ b/data/model/Model.h Tue Mar 31 10:39:54 2015 +0100 @@ -22,6 +22,7 @@ #include "base/XmlExportable.h" #include "base/Playable.h" #include "base/BaseTypes.h" +#include "base/DataExportOptions.h" typedef std::vector SampleBlock; @@ -237,9 +238,16 @@ virtual QString toDelimitedDataString(QString delimiter) const { return toDelimitedDataStringSubset(delimiter, getStartFrame(), getEndFrame()); } + virtual QString toDelimitedDataStringWithOptions(QString delimiter, DataExportOptions opts) const { + return toDelimitedDataStringSubsetWithOptions(delimiter, opts, getStartFrame(), getEndFrame()); + } virtual QString toDelimitedDataStringSubset(QString, sv_frame_t /* f0 */, sv_frame_t /* f1 */) const { return ""; } + virtual QString toDelimitedDataStringSubsetWithOptions(QString delimiter, DataExportOptions, sv_frame_t f0, sv_frame_t f1) const { + // Default implementation supports no options + return toDelimitedDataStringSubset(delimiter, f0, f1); + } public slots: void aboutToDelete(); diff -r c1e43c8d2527 -r 1ec57a28e924 data/model/NoteModel.h --- a/data/model/NoteModel.h Tue Mar 31 10:36:52 2015 +0100 +++ b/data/model/NoteModel.h Tue Mar 31 10:39:54 2015 +0100 @@ -62,13 +62,14 @@ .arg(XmlExportable::encodeEntities(label)).arg(extraAttributes); } - QString toDelimitedDataString(QString delimiter, sv_samplerate_t sampleRate) const - { + QString toDelimitedDataString(QString delimiter, DataExportOptions opts, sv_samplerate_t sampleRate) const { QStringList list; list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); list << QString("%1").arg(value); list << RealTime::frame2RealTime(duration, sampleRate).toString().c_str(); - list << QString("%1").arg(level); + if (!(opts & DataExportOmitLevels)) { + list << QString("%1").arg(level); + } if (label != "") list << label; return list.join(delimiter); } diff -r c1e43c8d2527 -r 1ec57a28e924 data/model/PathModel.h --- a/data/model/PathModel.h Tue Mar 31 10:36:52 2015 +0100 +++ b/data/model/PathModel.h Tue Mar 31 10:39:54 2015 +0100 @@ -43,7 +43,7 @@ .arg(indent).arg(frame).arg(mapframe).arg(extraAttributes); } - QString toDelimitedDataString(QString delimiter, + QString toDelimitedDataString(QString delimiter, DataExportOptions, sv_samplerate_t sampleRate) const { QStringList list; list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); diff -r c1e43c8d2527 -r 1ec57a28e924 data/model/RegionModel.h --- a/data/model/RegionModel.h Tue Mar 31 10:36:52 2015 +0100 +++ b/data/model/RegionModel.h Tue Mar 31 10:39:54 2015 +0100 @@ -60,7 +60,7 @@ .arg(XmlExportable::encodeEntities(label)).arg(extraAttributes); } - QString toDelimitedDataString(QString delimiter, sv_samplerate_t sampleRate) const + QString toDelimitedDataString(QString delimiter, DataExportOptions, sv_samplerate_t sampleRate) const { QStringList list; list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); diff -r c1e43c8d2527 -r 1ec57a28e924 data/model/SparseModel.h --- a/data/model/SparseModel.h Tue Mar 31 10:36:52 2015 +0100 +++ b/data/model/SparseModel.h Tue Mar 31 10:39:54 2015 +0100 @@ -148,21 +148,28 @@ QString indent = "", QString extraAttributes = "") const; - virtual QString toDelimitedDataString(QString delimiter) const - { + virtual QString toDelimitedDataString(QString delimiter) const { + return toDelimitedDataStringWithOptions(delimiter, DataExportDefaults); + } + + virtual QString toDelimitedDataStringWithOptions(QString delimiter, + DataExportOptions opts) const { QString s; for (PointListConstIterator i = m_points.begin(); i != m_points.end(); ++i) { - s += i->toDelimitedDataString(delimiter, m_sampleRate) + "\n"; + s += i->toDelimitedDataString(delimiter, opts, m_sampleRate) + "\n"; } return s; } - virtual QString toDelimitedDataStringSubset(QString delimiter, sv_frame_t f0, sv_frame_t f1) const - { + virtual QString toDelimitedDataStringSubset(QString delimiter, sv_frame_t f0, sv_frame_t f1) const { + return toDelimitedDataStringSubsetWithOptions(delimiter, DataExportDefaults, f0, f1); + } + + virtual QString toDelimitedDataStringSubsetWithOptions(QString delimiter, DataExportOptions opts, sv_frame_t f0, sv_frame_t f1) const { QString s; for (PointListConstIterator i = m_points.begin(); i != m_points.end(); ++i) { if (i->frame >= f0 && i->frame < f1) { - s += i->toDelimitedDataString(delimiter, m_sampleRate) + "\n"; + s += i->toDelimitedDataString(delimiter, opts, m_sampleRate) + "\n"; } } return s; diff -r c1e43c8d2527 -r 1ec57a28e924 data/model/SparseOneDimensionalModel.h --- a/data/model/SparseOneDimensionalModel.h Tue Mar 31 10:36:52 2015 +0100 +++ b/data/model/SparseOneDimensionalModel.h Tue Mar 31 10:39:54 2015 +0100 @@ -45,7 +45,7 @@ .arg(extraAttributes); } - QString toDelimitedDataString(QString delimiter, sv_samplerate_t sampleRate) const + QString toDelimitedDataString(QString delimiter, DataExportOptions, sv_samplerate_t sampleRate) const { QStringList list; list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); diff -r c1e43c8d2527 -r 1ec57a28e924 data/model/SparseTimeValueModel.h --- a/data/model/SparseTimeValueModel.h Tue Mar 31 10:36:52 2015 +0100 +++ b/data/model/SparseTimeValueModel.h Tue Mar 31 10:39:54 2015 +0100 @@ -49,7 +49,7 @@ .arg(extraAttributes); } - QString toDelimitedDataString(QString delimiter, sv_samplerate_t sampleRate) const + QString toDelimitedDataString(QString delimiter, DataExportOptions, sv_samplerate_t sampleRate) const { QStringList list; list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); diff -r c1e43c8d2527 -r 1ec57a28e924 data/model/TextModel.h --- a/data/model/TextModel.h Tue Mar 31 10:36:52 2015 +0100 +++ b/data/model/TextModel.h Tue Mar 31 10:39:54 2015 +0100 @@ -51,7 +51,7 @@ .arg(encodeEntities(label)).arg(extraAttributes); } - QString toDelimitedDataString(QString delimiter, sv_samplerate_t sampleRate) const + QString toDelimitedDataString(QString delimiter, DataExportOptions, sv_samplerate_t sampleRate) const { QStringList list; list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); diff -r c1e43c8d2527 -r 1ec57a28e924 system/System.h --- a/system/System.h Tue Mar 31 10:36:52 2015 +0100 +++ b/system/System.h Tue Mar 31 10:39:54 2015 +0100 @@ -156,6 +156,10 @@ #include +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + extern double mod(double x, double y); extern float modf(float x, float y);