# HG changeset patch # User Chris Cannam # Date 1426006972 0 # Node ID 26cf6d5251ec93b965a5d4b20bb76f6da9ef85ae # Parent 2f49be7d4264ddcb12f8ae9335ceb9ba6389a002 Further dedicated-types fixes diff -r 2f49be7d4264 -r 26cf6d5251ec base/Preferences.cpp --- a/base/Preferences.cpp Tue Mar 10 13:22:10 2015 +0000 +++ b/base/Preferences.cpp Tue Mar 10 17:02:52 2015 +0000 @@ -65,7 +65,7 @@ m_windowType = WindowType (settings.value("window-type", int(HanningWindow)).toInt()); m_resampleQuality = settings.value("resample-quality", 1).toInt(); - m_fixedSampleRate = settings.value("fixed-sample-rate", 0).toInt(); + m_fixedSampleRate = settings.value("fixed-sample-rate", 0).toDouble(); m_resampleOnLoad = settings.value("resample-on-load", false).toBool(); m_normaliseAudio = settings.value("normalise-audio", false).toBool(); m_backgroundMode = BackgroundMode @@ -561,7 +561,7 @@ } void -Preferences::setFixedSampleRate(int rate) +Preferences::setFixedSampleRate(sv_samplerate_t rate) { if (m_fixedSampleRate != rate) { m_fixedSampleRate = rate; diff -r 2f49be7d4264 -r 26cf6d5251ec base/Preferences.h --- a/base/Preferences.h Tue Mar 10 13:22:10 2015 +0000 +++ b/base/Preferences.h Tue Mar 10 17:02:52 2015 +0000 @@ -67,7 +67,7 @@ QString getTemporaryDirectoryRoot() const { return m_tempDirRoot; } /// If we should always resample audio to the same rate, return it; otherwise (the normal case) return 0 - int getFixedSampleRate() const { return m_fixedSampleRate; } + sv_samplerate_t getFixedSampleRate() const { return m_fixedSampleRate; } /// True if we should resample second or subsequent audio file to match first audio file's rate bool getResampleOnLoad() const { return m_resampleOnLoad; } @@ -116,7 +116,7 @@ void setResampleQuality(int quality); void setOmitTempsFromRecentFiles(bool omit); void setTemporaryDirectoryRoot(QString tempDirRoot); - void setFixedSampleRate(int); + void setFixedSampleRate(sv_samplerate_t); void setResampleOnLoad(bool); void setNormaliseAudio(bool); void setBackgroundMode(BackgroundMode mode); @@ -153,7 +153,7 @@ int m_resampleQuality; bool m_omitRecentTemps; QString m_tempDirRoot; - int m_fixedSampleRate; + sv_samplerate_t m_fixedSampleRate; bool m_resampleOnLoad; bool m_normaliseAudio; int m_viewFontSize; diff -r 2f49be7d4264 -r 26cf6d5251ec data/fileio/CSVFileReader.cpp --- a/data/fileio/CSVFileReader.cpp Tue Mar 10 13:22:10 2015 +0000 +++ b/data/fileio/CSVFileReader.cpp Tue Mar 10 17:02:52 2015 +0000 @@ -36,7 +36,7 @@ #include CSVFileReader::CSVFileReader(QString path, CSVFormat format, - int mainModelSampleRate) : + sv_samplerate_t mainModelSampleRate) : m_format(format), m_device(0), m_ownDevice(true), @@ -63,7 +63,7 @@ } CSVFileReader::CSVFileReader(QIODevice *device, CSVFormat format, - int mainModelSampleRate) : + sv_samplerate_t mainModelSampleRate) : m_format(format), m_device(device), m_ownDevice(false), @@ -96,7 +96,8 @@ } sv_frame_t -CSVFileReader::convertTimeValue(QString s, int lineno, int sampleRate, +CSVFileReader::convertTimeValue(QString s, int lineno, + sv_samplerate_t sampleRate, int windowSize) const { QRegExp nonNumericRx("[^0-9eE.,+-]"); @@ -155,7 +156,7 @@ CSVFormat::ModelType modelType = m_format.getModelType(); CSVFormat::TimingType timingType = m_format.getTimingType(); CSVFormat::TimeUnits timeUnits = m_format.getTimeUnits(); - int sampleRate = m_format.getSampleRate(); + sv_samplerate_t sampleRate = m_format.getSampleRate(); int windowSize = m_format.getWindowSize(); QChar separator = m_format.getSeparator(); bool allowQuoting = m_format.getAllowQuoting(); diff -r 2f49be7d4264 -r 26cf6d5251ec data/fileio/CSVFileReader.h --- a/data/fileio/CSVFileReader.h Tue Mar 10 13:22:10 2015 +0000 +++ b/data/fileio/CSVFileReader.h Tue Mar 10 17:02:52 2015 +0000 @@ -34,7 +34,7 @@ * Construct a CSVFileReader to read the CSV file at the given * path, with the given format. */ - CSVFileReader(QString path, CSVFormat format, int mainModelSampleRate); + CSVFileReader(QString path, CSVFormat format, sv_samplerate_t mainModelSampleRate); /** * Construct a CSVFileReader to read from the given @@ -42,7 +42,7 @@ * CSVFileReader will not close or delete it and it must outlive * the CSVFileReader. */ - CSVFileReader(QIODevice *device, CSVFormat format, int mainModelSampleRate); + CSVFileReader(QIODevice *device, CSVFormat format, sv_samplerate_t mainModelSampleRate); virtual ~CSVFileReader(); @@ -58,9 +58,9 @@ QString m_filename; QString m_error; mutable int m_warnings; - int m_mainModelSampleRate; + sv_samplerate_t m_mainModelSampleRate; - sv_frame_t convertTimeValue(QString, int lineno, int sampleRate, + sv_frame_t convertTimeValue(QString, int lineno, sv_samplerate_t sampleRate, int windowSize) const; }; diff -r 2f49be7d4264 -r 26cf6d5251ec data/fileio/CSVFormat.h --- a/data/fileio/CSVFormat.h Tue Mar 10 13:22:10 2015 +0000 +++ b/data/fileio/CSVFormat.h Tue Mar 10 17:02:52 2015 +0000 @@ -19,6 +19,8 @@ #include #include +#include "base/BaseTypes.h" + class CSVFormat { public: @@ -88,7 +90,7 @@ ModelType getModelType() const { return m_modelType; } TimingType getTimingType() const { return m_timingType; } TimeUnits getTimeUnits() const { return m_timeUnits; } - int getSampleRate() const { return m_sampleRate; } + sv_samplerate_t getSampleRate() const { return m_sampleRate; } int getWindowSize() const { return m_windowSize; } int getColumnCount() const { return m_columnCount; } bool getAllowQuoting() const { return m_allowQuoting; } @@ -101,7 +103,7 @@ void setTimingType(TimingType t) { m_timingType = t; } void setTimeUnits(TimeUnits t) { m_timeUnits = t; } void setSeparator(QChar s) { m_separator = s; } - void setSampleRate(int r) { m_sampleRate = r; } + void setSampleRate(sv_samplerate_t r) { m_sampleRate = r; } void setWindowSize(int s) { m_windowSize = s; } void setColumnCount(int c) { m_columnCount = c; } void setAllowQuoting(bool q) { m_allowQuoting = q; } @@ -125,7 +127,7 @@ TimingType m_timingType; TimeUnits m_timeUnits; QString m_separator; - int m_sampleRate; + sv_samplerate_t m_sampleRate; int m_windowSize; int m_columnCount; diff -r 2f49be7d4264 -r 26cf6d5251ec data/fileio/DataFileReaderFactory.cpp --- a/data/fileio/DataFileReaderFactory.cpp Tue Mar 10 13:22:10 2015 +0000 +++ b/data/fileio/DataFileReaderFactory.cpp Tue Mar 10 17:02:52 2015 +0000 @@ -32,7 +32,7 @@ bool csv, MIDIFileImportPreferenceAcquirer *acquirer, CSVFormat format, - int mainModelSampleRate) + sv_samplerate_t mainModelSampleRate) { QString err; @@ -58,7 +58,7 @@ DataFileReader * DataFileReaderFactory::createReader(QString path, MIDIFileImportPreferenceAcquirer *acquirer, - int mainModelSampleRate) + sv_samplerate_t mainModelSampleRate) { DataFileReader *reader = createReader (path, false, acquirer, CSVFormat(), mainModelSampleRate); @@ -74,7 +74,7 @@ Model * DataFileReaderFactory::load(QString path, MIDIFileImportPreferenceAcquirer *acquirer, - int mainModelSampleRate) + sv_samplerate_t mainModelSampleRate) { DataFileReader *reader = createReader(path, acquirer, @@ -94,7 +94,7 @@ Model * DataFileReaderFactory::loadNonCSV(QString path, MIDIFileImportPreferenceAcquirer *acquirer, - int mainModelSampleRate) + sv_samplerate_t mainModelSampleRate) { DataFileReader *reader = createReader(path, false, acquirer, @@ -114,7 +114,7 @@ Model * DataFileReaderFactory::loadCSV(QString path, CSVFormat format, - int mainModelSampleRate) + sv_samplerate_t mainModelSampleRate) { DataFileReader *reader = createReader(path, true, 0, format, mainModelSampleRate); diff -r 2f49be7d4264 -r 26cf6d5251ec data/fileio/DataFileReaderFactory.h --- a/data/fileio/DataFileReaderFactory.h Tue Mar 10 13:22:10 2015 +0000 +++ b/data/fileio/DataFileReaderFactory.h Tue Mar 10 17:02:52 2015 +0000 @@ -48,7 +48,7 @@ */ static DataFileReader *createReader(QString path, MIDIFileImportPreferenceAcquirer *, - int mainModelSampleRate); + sv_samplerate_t mainModelSampleRate); /** * Read the given path, if a suitable reader is available. @@ -60,7 +60,7 @@ */ static Model *load(QString path, MIDIFileImportPreferenceAcquirer *acquirer, - int mainModelSampleRate); + sv_samplerate_t mainModelSampleRate); /** * Read the given path, if a suitable reader is available. @@ -69,7 +69,7 @@ */ static Model *loadNonCSV(QString path, MIDIFileImportPreferenceAcquirer *acquirer, - int mainModelSampleRate); + sv_samplerate_t mainModelSampleRate); /** * Read the given path using the CSV reader with the given format. @@ -77,13 +77,13 @@ */ static Model *loadCSV(QString path, CSVFormat format, - int mainModelSampleRate); + sv_samplerate_t mainModelSampleRate); protected: static DataFileReader *createReader(QString path, bool csv, MIDIFileImportPreferenceAcquirer *, CSVFormat format, - int mainModelSampleRate); + sv_samplerate_t mainModelSampleRate); }; #endif diff -r 2f49be7d4264 -r 26cf6d5251ec data/fileio/MIDIFileReader.cpp --- a/data/fileio/MIDIFileReader.cpp Tue Mar 10 13:22:10 2015 +0000 +++ b/data/fileio/MIDIFileReader.cpp Tue Mar 10 17:02:52 2015 +0000 @@ -58,7 +58,7 @@ MIDIFileReader::MIDIFileReader(QString path, MIDIFileImportPreferenceAcquirer *acquirer, - int mainModelSampleRate) : + sv_samplerate_t mainModelSampleRate) : m_smpte(false), m_timingDivision(0), m_fps(0), diff -r 2f49be7d4264 -r 26cf6d5251ec data/fileio/MIDIFileReader.h --- a/data/fileio/MIDIFileReader.h Tue Mar 10 13:22:10 2015 +0000 +++ b/data/fileio/MIDIFileReader.h Tue Mar 10 17:02:52 2015 +0000 @@ -62,7 +62,7 @@ public: MIDIFileReader(QString path, MIDIFileImportPreferenceAcquirer *pref, - int mainModelSampleRate); + sv_samplerate_t mainModelSampleRate); virtual ~MIDIFileReader(); virtual bool isOK() const; @@ -128,7 +128,7 @@ std::ifstream *m_midiFile; size_t m_fileSize; QString m_error; - int m_mainModelSampleRate; + sv_samplerate_t m_mainModelSampleRate; MIDIFileImportPreferenceAcquirer *m_acquirer; }; diff -r 2f49be7d4264 -r 26cf6d5251ec rdf/RDFFeatureWriter.cpp --- a/rdf/RDFFeatureWriter.cpp Tue Mar 10 13:22:10 2015 +0000 +++ b/rdf/RDFFeatureWriter.cpp Tue Mar 10 17:02:52 2015 +0000 @@ -685,7 +685,7 @@ stream << "\n:feature_timeline_" << featureNumber << " a tl:DiscreteTimeLine .\n\n"; - float sampleRate; + sv_samplerate_t sampleRate; int stepSize, blockSize; // If the output is FixedSampleRate, we need to draw the @@ -752,9 +752,9 @@ RealTime durationrt = transform.getDuration(); sv_frame_t start = RealTime::realTime2Frame - (startrt, int(lrintf(sampleRate))) / stepSize; + (startrt, sampleRate) / stepSize; sv_frame_t duration = RealTime::realTime2Frame - (durationrt, int(lrintf(sampleRate))) / stepSize; + (durationrt, sampleRate) / stepSize; if (start != 0) { stream << "\n tl:start \"" << start << "\"^^xsd:int ;"; diff -r 2f49be7d4264 -r 26cf6d5251ec transform/CSVFeatureWriter.cpp --- a/transform/CSVFeatureWriter.cpp Tue Mar 10 13:22:10 2015 +0000 +++ b/transform/CSVFeatureWriter.cpp Tue Mar 10 17:02:52 2015 +0000 @@ -210,7 +210,7 @@ } } - Vamp::RealTime duration; + ::RealTime duration; bool haveDuration = true; if (f.hasDuration) { @@ -223,17 +223,17 @@ if (m_sampleTiming) { - int rate = int(lrintf(transform.getSampleRate())); + sv_samplerate_t rate = transform.getSampleRate(); - stream << Vamp::RealTime::realTime2Frame(f.timestamp, rate); + stream << ::RealTime::realTime2Frame(f.timestamp, rate); if (haveDuration) { stream << m_separator; if (m_endTimes) { - stream << Vamp::RealTime::realTime2Frame - (f.timestamp + duration, rate); + stream << ::RealTime::realTime2Frame + (::RealTime(f.timestamp) + duration, rate); } else { - stream << Vamp::RealTime::realTime2Frame(duration, rate); + stream << ::RealTime::realTime2Frame(duration, rate); } } @@ -246,11 +246,11 @@ if (haveDuration) { if (m_endTimes) { QString endtime = - (f.timestamp + duration).toString().c_str(); + (::RealTime(f.timestamp) + duration).toString().c_str(); endtime.replace(QRegExp("^ +"), ""); stream << m_separator << endtime; } else { - QString d = duration.toString().c_str(); + QString d = ::RealTime(duration).toString().c_str(); d.replace(QRegExp("^ +"), ""); stream << m_separator << d; } diff -r 2f49be7d4264 -r 26cf6d5251ec transform/Transform.cpp --- a/transform/Transform.cpp Tue Mar 10 13:22:10 2015 +0000 +++ b/transform/Transform.cpp Tue Mar 10 17:02:52 2015 +0000 @@ -379,14 +379,14 @@ m_duration = d; } -float +sv_samplerate_t Transform::getSampleRate() const { return m_sampleRate; } void -Transform::setSampleRate(float rate) +Transform::setSampleRate(sv_samplerate_t rate) { m_sampleRate = rate; } diff -r 2f49be7d4264 -r 26cf6d5251ec transform/Transform.h --- a/transform/Transform.h Tue Mar 10 13:22:10 2015 +0000 +++ b/transform/Transform.h Tue Mar 10 17:02:52 2015 +0000 @@ -135,8 +135,8 @@ RealTime getDuration() const; // 0 -> all void setDuration(RealTime d); - float getSampleRate() const; // 0 -> as input - void setSampleRate(float rate); + sv_samplerate_t getSampleRate() const; // 0 -> as input + void setSampleRate(sv_samplerate_t rate); void toXml(QTextStream &stream, QString indent = "", QString extraAttributes = "") const; @@ -194,7 +194,7 @@ WindowType m_windowType; RealTime m_startTime; RealTime m_duration; - float m_sampleRate; + sv_samplerate_t m_sampleRate; }; typedef std::vector Transforms; diff -r 2f49be7d4264 -r 26cf6d5251ec transform/TransformFactory.cpp --- a/transform/TransformFactory.cpp Tue Mar 10 13:22:10 2015 +0000 +++ b/transform/TransformFactory.cpp Tue Mar 10 17:02:52 2015 +0000 @@ -750,11 +750,11 @@ } Transform -TransformFactory::getDefaultTransformFor(TransformId id, int rate) +TransformFactory::getDefaultTransformFor(TransformId id, sv_samplerate_t rate) { Transform t; t.setIdentifier(id); - if (rate != 0) t.setSampleRate(float(rate)); + if (rate != 0) t.setSampleRate(rate); Vamp::PluginBase *plugin = instantiateDefaultPluginFor(id, rate); @@ -772,7 +772,7 @@ TransformFactory::instantiatePluginFor(const Transform &transform) { Vamp::PluginBase *plugin = instantiateDefaultPluginFor - (transform.getIdentifier(), int(lrintf(transform.getSampleRate()))); + (transform.getIdentifier(), transform.getSampleRate()); if (plugin) { setPluginParameters(transform, plugin); @@ -782,11 +782,12 @@ } Vamp::PluginBase * -TransformFactory::instantiateDefaultPluginFor(TransformId identifier, int rate) +TransformFactory::instantiateDefaultPluginFor(TransformId identifier, + sv_samplerate_t rate) { Transform t; t.setIdentifier(identifier); - if (rate == 0) rate = 44100; + if (rate == 0) rate = 44100.0; QString pluginId = t.getPluginIdentifier(); Vamp::PluginBase *plugin = 0; @@ -797,7 +798,7 @@ FeatureExtractionPluginFactory::instanceFor(pluginId); if (factory) { - plugin = factory->instantiatePlugin(pluginId, float(rate)); + plugin = factory->instantiatePlugin(pluginId, rate); } } else { diff -r 2f49be7d4264 -r 26cf6d5251ec transform/TransformFactory.h --- a/transform/TransformFactory.h Tue Mar 10 13:22:10 2015 +0000 +++ b/transform/TransformFactory.h Tue Mar 10 17:02:52 2015 +0000 @@ -88,7 +88,7 @@ * with different parameters and execution context settings. * Return the default one for the given transform. */ - Transform getDefaultTransformFor(TransformId identifier, int rate = 0); + Transform getDefaultTransformFor(TransformId identifier, sv_samplerate_t rate = 0); /** * Full name of a transform, suitable for putting on a menu. @@ -210,7 +210,7 @@ void populateFeatureExtractionPlugins(TransformDescriptionMap &); void populateRealTimePlugins(TransformDescriptionMap &); - Vamp::PluginBase *instantiateDefaultPluginFor(TransformId id, int rate); + Vamp::PluginBase *instantiateDefaultPluginFor(TransformId id, sv_samplerate_t rate); QMutex m_transformsMutex; QMutex m_uninstalledTransformsMutex;