Mercurial > hg > svcore
changeset 318:7a4bd2c8585c
* Some export fixes, and avoid clipping on resampling on import
author | Chris Cannam |
---|---|
date | Mon, 22 Oct 2007 09:45:35 +0000 |
parents | c324d410b096 |
children | 3ff8f571da09 |
files | base/XmlExportable.cpp data/fileio/CodedAudioFileReader.cpp data/model/EditableDenseThreeDimensionalModel.cpp data/model/EditableDenseThreeDimensionalModel.h data/model/ImageModel.h data/model/NoteModel.h data/model/SparseModel.h data/model/SparseOneDimensionalModel.h data/model/SparseTimeValueModel.h data/model/SparseValueModel.h data/model/TextModel.h |
diffstat | 11 files changed, 55 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/base/XmlExportable.cpp Thu Oct 18 16:20:26 2007 +0000 +++ b/base/XmlExportable.cpp Mon Oct 22 09:45:35 2007 +0000 @@ -19,10 +19,14 @@ #include <QMutexLocker> #include <QTextStream> +#include <iostream> + QString XmlExportable::toXmlString(QString indent, QString extraAttributes) const { + std::cerr << "XmlExportable::toXmlString" << std::endl; + QString s; {
--- a/data/fileio/CodedAudioFileReader.cpp Thu Oct 18 16:20:26 2007 +0000 +++ b/data/fileio/CodedAudioFileReader.cpp Mon Oct 22 09:45:35 2007 +0000 @@ -291,6 +291,13 @@ void CodedAudioFileReader::pushBuffer(float *buffer, size_t sz, bool final) { + for (size_t i = 0; i < sz; ++i) { + if (buffer[i] > 1.f) buffer[i] = 1.f; + } + for (size_t i = 0; i < sz; ++i) { + if (buffer[i] < -1.f) buffer[i] = -1.f; + } + if (m_resampler) { float ratio = float(m_sampleRate) / float(m_fileRate); @@ -303,14 +310,16 @@ ratio, final); - for (size_t i = 0; i < out; ++i) { - if (m_resampleBuffer[i] > 1.f) m_resampleBuffer[i] = 1.f; - if (m_resampleBuffer[i] < -1.f) m_resampleBuffer[i] = -1.f; - } - buffer = m_resampleBuffer; sz = out; } + + for (size_t i = 0; i < sz; ++i) { + if (buffer[i] > 1.f) buffer[i] = 1.f; + } + for (size_t i = 0; i < sz; ++i) { + if (buffer[i] < -1.f) buffer[i] = -1.f; + } } m_frameCount += sz;
--- a/data/model/EditableDenseThreeDimensionalModel.cpp Thu Oct 18 16:20:26 2007 +0000 +++ b/data/model/EditableDenseThreeDimensionalModel.cpp Mon Oct 22 09:45:35 2007 +0000 @@ -270,6 +270,20 @@ } } +QString +EditableDenseThreeDimensionalModel::toDelimitedDataString(QString delimiter) const +{ + QString s; + for (size_t i = 0; i < m_data.size(); ++i) { + QStringList list; + for (size_t j = 0; j < m_data[i].size(); ++j) { + list << QString("%1").arg(m_data[i][j]); + } + s += list.join(delimiter) + "\n"; + } + return s; +} + void EditableDenseThreeDimensionalModel::toXml(QTextStream &out, QString indent, @@ -277,6 +291,8 @@ { // For historical reasons we read and write "resolution" as "windowSize" + std::cerr << "EditableDenseThreeDimensionalModel::toXml" << std::endl; + Model::toXml (out, indent, QString("type=\"dense\" dimensions=\"3\" windowSize=\"%1\" yBinCount=\"%2\" minimum=\"%3\" maximum=\"%4\" dataset=\"%5\" %6") @@ -307,6 +323,7 @@ out << m_data[i][j]; } out << QString("</row>\n"); + out.flush(); } out << indent + "</dataset>\n";
--- a/data/model/EditableDenseThreeDimensionalModel.h Thu Oct 18 16:20:26 2007 +0000 +++ b/data/model/EditableDenseThreeDimensionalModel.h Mon Oct 22 09:45:35 2007 +0000 @@ -109,6 +109,8 @@ virtual void setCompletion(int completion); virtual int getCompletion() const { return m_completion; } + virtual QString toDelimitedDataString(QString delimiter) const; + virtual void toXml(QTextStream &out, QString indent = "", QString extraAttributes = "") const;
--- a/data/model/ImageModel.h Thu Oct 18 16:20:26 2007 +0000 +++ b/data/model/ImageModel.h Mon Oct 22 09:45:35 2007 +0000 @@ -56,7 +56,7 @@ QStringList list; list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); list << image; - list << label; + if (label != "") list << label; return list.join(delimiter); }
--- a/data/model/NoteModel.h Thu Oct 18 16:20:26 2007 +0000 +++ b/data/model/NoteModel.h Mon Oct 22 09:45:35 2007 +0000 @@ -58,7 +58,7 @@ list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); list << QString("%1").arg(value); list << QString("%1").arg(duration); - list << label; + if (label != "") list << label; return list.join(delimiter); } @@ -126,6 +126,9 @@ QString indent = "", QString extraAttributes = "") const { + std::cerr << "NoteModel::toXml: extraAttributes = \"" + << extraAttributes.toStdString() << std::endl; + SparseValueModel<Note>::toXml (out, indent,
--- a/data/model/SparseModel.h Thu Oct 18 16:20:26 2007 +0000 +++ b/data/model/SparseModel.h Mon Oct 22 09:45:35 2007 +0000 @@ -548,6 +548,9 @@ QString indent, QString extraAttributes) const { + std::cerr << "SparseModel::toXml: extraAttributes = \"" + << extraAttributes.toStdString() << std::endl; + Model::toXml (out, indent,
--- a/data/model/SparseOneDimensionalModel.h Thu Oct 18 16:20:26 2007 +0000 +++ b/data/model/SparseOneDimensionalModel.h Mon Oct 22 09:45:35 2007 +0000 @@ -43,7 +43,7 @@ { QStringList list; list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); - list << label; + if (label != "") list << label; return list.join(delimiter); }
--- a/data/model/SparseTimeValueModel.h Thu Oct 18 16:20:26 2007 +0000 +++ b/data/model/SparseTimeValueModel.h Mon Oct 22 09:45:35 2007 +0000 @@ -51,7 +51,7 @@ QStringList list; list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); list << QString("%1").arg(value); - list << label; + if (label != "") list << label; return list.join(delimiter); }
--- a/data/model/SparseValueModel.h Thu Oct 18 16:20:26 2007 +0000 +++ b/data/model/SparseValueModel.h Mon Oct 22 09:45:35 2007 +0000 @@ -110,11 +110,16 @@ } } - virtual void toXml(QTextStream &stream, QString indent = "", + virtual void toXml(QTextStream &stream, + QString indent = "", QString extraAttributes = "") const { + std::cerr << "SparseValueModel::toXml: extraAttributes = \"" + << extraAttributes.toStdString() << std::endl; + SparseModel<PointType>::toXml - (stream, indent, + (stream, + indent, QString("%1 minimum=\"%2\" maximum=\"%3\" units=\"%4\"") .arg(extraAttributes).arg(m_valueMinimum).arg(m_valueMaximum) .arg(this->encodeEntities(m_units)));
--- a/data/model/TextModel.h Thu Oct 18 16:20:26 2007 +0000 +++ b/data/model/TextModel.h Mon Oct 22 09:45:35 2007 +0000 @@ -52,7 +52,7 @@ QStringList list; list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); list << QString("%1").arg(height); - list << label; + if (label != "") list << label; return list.join(delimiter); }