# HG changeset patch # User Chris Cannam # Date 1426017788 0 # Node ID 5ad98be7f635c3abe7b8f577fe1a5ee237052988 # Parent 10055a284716ca793c9ccba2e92ae1cce3316a4e# Parent c7e9afcbf07063c99e25f696c9f6d61b3d76ff45 Merge diff -r 10055a284716 -r 5ad98be7f635 base/Clipboard.cpp --- a/base/Clipboard.cpp Tue Mar 10 20:02:02 2015 +0000 +++ b/base/Clipboard.cpp Tue Mar 10 20:03:08 2015 +0000 @@ -15,7 +15,7 @@ #include "Clipboard.h" -Clipboard::Point::Point(long frame, QString label) : +Clipboard::Point::Point(sv_frame_t frame, QString label) : m_haveFrame(true), m_frame(frame), m_haveValue(false), @@ -31,7 +31,7 @@ { } -Clipboard::Point::Point(long frame, float value, QString label) : +Clipboard::Point::Point(sv_frame_t frame, float value, QString label) : m_haveFrame(true), m_frame(frame), m_haveValue(true), @@ -47,7 +47,7 @@ { } -Clipboard::Point::Point(long frame, float value, int duration, QString label) : +Clipboard::Point::Point(sv_frame_t frame, float value, sv_frame_t duration, QString label) : m_haveFrame(true), m_frame(frame), m_haveValue(true), @@ -63,7 +63,7 @@ { } -Clipboard::Point::Point(long frame, float value, int duration, float level, QString label) : +Clipboard::Point::Point(sv_frame_t frame, float value, sv_frame_t duration, float level, QString label) : m_haveFrame(true), m_frame(frame), m_haveValue(true), @@ -120,14 +120,14 @@ return m_haveFrame; } -long +sv_frame_t Clipboard::Point::getFrame() const { return m_frame; } Clipboard::Point -Clipboard::Point::withFrame(long frame) const +Clipboard::Point::withFrame(sv_frame_t frame) const { Point p(*this); p.m_haveFrame = true; @@ -162,14 +162,14 @@ return m_haveDuration; } -int +sv_frame_t Clipboard::Point::getDuration() const { return m_duration; } Clipboard::Point -Clipboard::Point::withDuration(int duration) const +Clipboard::Point::withDuration(sv_frame_t duration) const { Point p(*this); p.m_haveDuration = true; @@ -231,14 +231,14 @@ return m_haveReferenceFrame && (m_referenceFrame != m_frame); } -long +sv_frame_t Clipboard::Point::getReferenceFrame() const { return m_referenceFrame; } void -Clipboard::Point::setReferenceFrame(long f) +Clipboard::Point::setReferenceFrame(sv_frame_t f) { m_haveReferenceFrame = true; m_referenceFrame = f; diff -r 10055a284716 -r 5ad98be7f635 base/Clipboard.h --- a/base/Clipboard.h Tue Mar 10 20:02:02 2015 +0000 +++ b/base/Clipboard.h Tue Mar 10 20:03:08 2015 +0000 @@ -19,30 +19,32 @@ #include #include +#include "BaseTypes.h" + class Clipboard { public: class Point { public: - Point(long frame, QString label); - Point(long frame, float value, QString label); - Point(long frame, float value, int duration, QString label); - Point(long frame, float value, int duration, float level, QString label); + Point(sv_frame_t frame, QString label); + Point(sv_frame_t frame, float value, QString label); + Point(sv_frame_t frame, float value, sv_frame_t duration, QString label); + Point(sv_frame_t frame, float value, sv_frame_t duration, float level, QString label); Point(const Point &point); Point &operator=(const Point &point); bool haveFrame() const; - long getFrame() const; - Point withFrame(long frame) const; + sv_frame_t getFrame() const; + Point withFrame(sv_frame_t frame) const; bool haveValue() const; float getValue() const; Point withValue(float value) const; bool haveDuration() const; - int getDuration() const; - Point withDuration(int duration) const; + sv_frame_t getDuration() const; + Point withDuration(sv_frame_t duration) const; bool haveLabel() const; QString getLabel() const; @@ -55,22 +57,22 @@ bool haveReferenceFrame() const; bool referenceFrameDiffers() const; // from point frame - long getReferenceFrame() const; - void setReferenceFrame(long); + sv_frame_t getReferenceFrame() const; + void setReferenceFrame(sv_frame_t); private: bool m_haveFrame; - long m_frame; + sv_frame_t m_frame; bool m_haveValue; float m_value; bool m_haveDuration; - int m_duration; + sv_frame_t m_duration; bool m_haveLabel; QString m_label; bool m_haveLevel; float m_level; bool m_haveReferenceFrame; - long m_referenceFrame; + sv_frame_t m_referenceFrame; }; Clipboard(); diff -r 10055a284716 -r 5ad98be7f635 base/FrameTimer.h --- a/base/FrameTimer.h Tue Mar 10 20:02:02 2015 +0000 +++ b/base/FrameTimer.h Tue Mar 10 20:03:08 2015 +0000 @@ -16,6 +16,8 @@ #ifndef _FRAME_TIMER_H_ #define _FRAME_TIMER_H_ +#include "BaseTypes.h" + /** * A trivial interface for things that permit retrieving "the current * frame". Implementations of this interface are used, for example, @@ -25,7 +27,7 @@ class FrameTimer { public: - virtual int getFrame() const = 0; + virtual sv_frame_t getFrame() const = 0; }; #endif diff -r 10055a284716 -r 5ad98be7f635 base/LogRange.cpp --- a/base/LogRange.cpp Tue Mar 10 20:02:02 2015 +0000 +++ b/base/LogRange.cpp Tue Mar 10 20:03:08 2015 +0000 @@ -21,7 +21,7 @@ #include void -LogRange::mapRange(float &min, float &max, float logthresh) +LogRange::mapRange(double &min, double &max, double logthresh) { if (min > max) std::swap(min, max); if (max == min) max = min + 1; @@ -30,19 +30,19 @@ if (min >= 0.f) { - max = log10f(max); // we know max != 0 + max = log10(max); // we know max != 0 if (min == 0.f) min = std::min(logthresh, max); - else min = log10f(min); + else min = log10(min); // SVDEBUG << "LogRange::mapRange: positive: min = " << min << ", max = " << max << endl; } else if (max <= 0.f) { - min = log10f(-min); // we know min != 0 + min = log10(-min); // we know min != 0 if (max == 0.f) max = std::min(logthresh, min); - else max = log10f(-max); + else max = log10(-max); std::swap(min, max); @@ -52,7 +52,7 @@ // min < 0 and max > 0 - max = log10f(std::max(max, -min)); + max = log10(std::max(max, -min)); min = std::min(logthresh, max); // SVDEBUG << "LogRange::mapRange: spanning: min = " << min << ", max = " << max << endl; @@ -61,21 +61,21 @@ if (min == max) min = max - 1; } -float -LogRange::map(float value, float thresh) +double +LogRange::map(double value, double thresh) { if (value == 0.f) return thresh; - return log10f(fabsf(value)); + return log10(fabs(value)); } -float -LogRange::unmap(float value) +double +LogRange::unmap(double value) { - return powf(10.0, value); + return pow(10.0, value); } static double -sd(const std::vector &values, int start, int n) +sd(const std::vector &values, int start, int n) { double sum = 0.f, mean = 0.f, variance = 0.f; for (int i = 0; i < n; ++i) { @@ -91,7 +91,7 @@ } bool -LogRange::useLogScale(std::vector values) +LogRange::useLogScale(std::vector values) { // Principle: Partition the data into two sets around the median; // calculate the standard deviation of each set; if the two SDs diff -r 10055a284716 -r 5ad98be7f635 base/LogRange.h --- a/base/LogRange.h Tue Mar 10 20:02:02 2015 +0000 +++ b/base/LogRange.h Tue Mar 10 20:03:08 2015 +0000 @@ -28,27 +28,27 @@ * extents of the logarithmic range. thresh is the minimum value * for the log range, to be used if the linear range spans zero. */ - static void mapRange(float &min, float &max, float thresh = -10); + static void mapRange(double &min, double &max, double thresh = -10); /** * Map a value onto a logarithmic range. This just means taking * the base-10 log of the absolute value, or using the threshold * value if the absolute value is zero. */ - static float map(float value, float thresh = -10); + static double map(double value, double thresh = -10); /** * Map a value from the logarithmic range back again. This just * means taking the value'th power of ten. */ - static float unmap(float value); + static double unmap(double value); /** * Estimate whether a set of values would be more properly shown * using a logarithmic than a linear scale. This is only ever * going to be a rough guess. */ - static bool useLogScale(std::vector values); + static bool useLogScale(std::vector values); }; diff -r 10055a284716 -r 5ad98be7f635 base/Preferences.cpp --- a/base/Preferences.cpp Tue Mar 10 20:02:02 2015 +0000 +++ b/base/Preferences.cpp Tue Mar 10 20:03:08 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 10055a284716 -r 5ad98be7f635 base/Preferences.h --- a/base/Preferences.h Tue Mar 10 20:02:02 2015 +0000 +++ b/base/Preferences.h Tue Mar 10 20:03:08 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 10055a284716 -r 5ad98be7f635 data/fft/FFTDataServer.cpp --- a/data/fft/FFTDataServer.cpp Tue Mar 10 20:02:02 2015 +0000 +++ b/data/fft/FFTDataServer.cpp Tue Mar 10 20:03:08 2015 +0000 @@ -55,7 +55,7 @@ int fftSize, bool polar, StorageAdviser::Criteria criteria, - int fillFromColumn) + sv_frame_t fillFromFrame) { QString n = generateFileBasename(model, channel, @@ -95,7 +95,7 @@ fftSize, polar, criteria, - fillFromColumn); + fillFromFrame); } catch (InsufficientDiscSpace) { delete server; server = 0; @@ -117,7 +117,7 @@ int fftSize, bool polar, StorageAdviser::Criteria criteria, - int fillFromColumn) + sv_frame_t fillFromFrame) { // Fuzzy matching: // @@ -223,7 +223,7 @@ fftSize, polar, criteria, - fillFromColumn); + fillFromFrame); } FFTDataServer * @@ -490,7 +490,7 @@ int fftSize, bool polar, StorageAdviser::Criteria criteria, - int fillFromColumn) : + sv_frame_t fillFromFrame) : m_fileBaseName(fileBaseName), m_model(model), m_channel(channel), @@ -587,7 +587,7 @@ throw(0); } - m_fillThread = new FillThread(*this, fillFromColumn); + m_fillThread = new FillThread(*this, fillFromFrame); } FFTDataServer::~FFTDataServer() diff -r 10055a284716 -r 5ad98be7f635 data/fft/FFTDataServer.h --- a/data/fft/FFTDataServer.h Tue Mar 10 20:02:02 2015 +0000 +++ b/data/fft/FFTDataServer.h Tue Mar 10 20:03:08 2015 +0000 @@ -49,7 +49,7 @@ bool polar, StorageAdviser::Criteria criteria = StorageAdviser::NoCriteria, - int fillFromColumn = 0); + sv_frame_t fillFromFrame = 0); static FFTDataServer *getFuzzyInstance(const DenseTimeValueModel *model, int channel, @@ -60,7 +60,7 @@ bool polar, StorageAdviser::Criteria criteria = StorageAdviser::NoCriteria, - int fillFromColumn = 0); + sv_frame_t fillFromFrame = 0); static void claimInstance(FFTDataServer *); static void releaseInstance(FFTDataServer *); @@ -120,7 +120,7 @@ int fftSize, bool polar, StorageAdviser::Criteria criteria, - int fillFromColumn = 0); + sv_frame_t fillFromFrame = 0); virtual ~FFTDataServer(); @@ -241,9 +241,9 @@ class FillThread : public Thread { public: - FillThread(FFTDataServer &server, int fillFromColumn) : + FillThread(FFTDataServer &server, sv_frame_t fillFromFrame) : m_server(server), m_extent(0), m_completion(0), - m_fillFrom(fillFromColumn) { } + m_fillFrom(fillFromFrame) { } sv_frame_t getExtent() const { return m_extent; } int getCompletion() const { return m_completion ? m_completion : 1; } diff -r 10055a284716 -r 5ad98be7f635 data/fileio/CSVFileReader.cpp --- a/data/fileio/CSVFileReader.cpp Tue Mar 10 20:02:02 2015 +0000 +++ b/data/fileio/CSVFileReader.cpp Tue Mar 10 20:03:08 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 10055a284716 -r 5ad98be7f635 data/fileio/CSVFileReader.h --- a/data/fileio/CSVFileReader.h Tue Mar 10 20:02:02 2015 +0000 +++ b/data/fileio/CSVFileReader.h Tue Mar 10 20:03:08 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 10055a284716 -r 5ad98be7f635 data/fileio/CSVFormat.h --- a/data/fileio/CSVFormat.h Tue Mar 10 20:02:02 2015 +0000 +++ b/data/fileio/CSVFormat.h Tue Mar 10 20:03:08 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 10055a284716 -r 5ad98be7f635 data/fileio/DataFileReaderFactory.cpp --- a/data/fileio/DataFileReaderFactory.cpp Tue Mar 10 20:02:02 2015 +0000 +++ b/data/fileio/DataFileReaderFactory.cpp Tue Mar 10 20:03:08 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 10055a284716 -r 5ad98be7f635 data/fileio/DataFileReaderFactory.h --- a/data/fileio/DataFileReaderFactory.h Tue Mar 10 20:02:02 2015 +0000 +++ b/data/fileio/DataFileReaderFactory.h Tue Mar 10 20:03:08 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 10055a284716 -r 5ad98be7f635 data/fileio/MIDIFileReader.cpp --- a/data/fileio/MIDIFileReader.cpp Tue Mar 10 20:02:02 2015 +0000 +++ b/data/fileio/MIDIFileReader.cpp Tue Mar 10 20:03:08 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 10055a284716 -r 5ad98be7f635 data/fileio/MIDIFileReader.h --- a/data/fileio/MIDIFileReader.h Tue Mar 10 20:02:02 2015 +0000 +++ b/data/fileio/MIDIFileReader.h Tue Mar 10 20:03:08 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 10055a284716 -r 5ad98be7f635 data/fileio/MIDIFileWriter.cpp --- a/data/fileio/MIDIFileWriter.cpp Tue Mar 10 20:02:02 2015 +0000 +++ b/data/fileio/MIDIFileWriter.cpp Tue Mar 10 20:03:08 2015 +0000 @@ -37,7 +37,7 @@ using namespace MIDIConstants; MIDIFileWriter::MIDIFileWriter(QString path, const NoteExportable *exportable, - int sampleRate, float tempo) : + sv_samplerate_t sampleRate, float tempo) : m_path(path), m_exportable(exportable), m_sampleRate(sampleRate), @@ -358,12 +358,12 @@ // Convert frame to MIDI time - double seconds = double(frame) / double(m_sampleRate); + double seconds = double(frame) / m_sampleRate; double quarters = (seconds * m_tempo) / 60.0; unsigned long midiTime = int(quarters * m_timingDivision + 0.5); // Get the sounding time for the matching NOTE_OFF - seconds = double(frame + duration) / double(m_sampleRate); + seconds = double(frame + duration) / m_sampleRate; quarters = (seconds * m_tempo) / 60.0; unsigned long endTime = int(quarters * m_timingDivision + 0.5); diff -r 10055a284716 -r 5ad98be7f635 data/fileio/MIDIFileWriter.h --- a/data/fileio/MIDIFileWriter.h Tue Mar 10 20:02:02 2015 +0000 +++ b/data/fileio/MIDIFileWriter.h Tue Mar 10 20:03:08 2015 +0000 @@ -24,6 +24,7 @@ #define _MIDI_FILE_WRITER_H_ #include "base/RealTime.h" +#include "base/BaseTypes.h" #include @@ -45,7 +46,7 @@ public: MIDIFileWriter(QString path, const NoteExportable *exportable, - int sampleRate, // used to convert exportable sample timings + sv_samplerate_t sampleRate, // used to convert exportable sample timings float tempo = 120.f); virtual ~MIDIFileWriter(); @@ -79,7 +80,7 @@ QString m_path; const NoteExportable *m_exportable; - int m_sampleRate; + sv_samplerate_t m_sampleRate; float m_tempo; int m_timingDivision; // pulses per quarter note MIDIFileFormatType m_format; diff -r 10055a284716 -r 5ad98be7f635 data/model/AlignmentModel.cpp --- a/data/model/AlignmentModel.cpp Tue Mar 10 20:02:02 2015 +0000 +++ b/data/model/AlignmentModel.cpp Tue Mar 10 20:03:08 2015 +0000 @@ -364,8 +364,8 @@ connect(m_rawPath, SIGNAL(modelChanged()), this, SLOT(pathChanged())); - connect(m_rawPath, SIGNAL(modelChangedWithin(int, int)), - this, SLOT(pathChangedWithin(int, int))); + connect(m_rawPath, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), + this, SLOT(pathChangedWithin(sv_frame_t, sv_frame_t))); connect(m_rawPath, SIGNAL(completionChanged()), this, SLOT(pathCompletionChanged())); diff -r 10055a284716 -r 5ad98be7f635 data/model/EditableDenseThreeDimensionalModel.cpp --- a/data/model/EditableDenseThreeDimensionalModel.cpp Tue Mar 10 20:02:02 2015 +0000 +++ b/data/model/EditableDenseThreeDimensionalModel.cpp Tue Mar 10 20:03:08 2015 +0000 @@ -27,6 +27,8 @@ #include #include +using std::vector; + #include "system/System.h" EditableDenseThreeDimensionalModel::EditableDenseThreeDimensionalModel(sv_samplerate_t sampleRate, @@ -445,15 +447,15 @@ { QReadLocker locker(&m_lock); - QVector sample; - QVector n; + vector sample; + vector n; for (int i = 0; i < 10; ++i) { int index = i * 10; if (index < m_data.size()) { const Column &c = m_data.at(index); - while (c.size() > sample.size()) { - sample.push_back(0.f); + while (c.size() > int(sample.size())) { + sample.push_back(0.0); n.push_back(0); } for (int j = 0; j < c.size(); ++j) { @@ -464,11 +466,11 @@ } if (sample.empty()) return false; - for (int j = 0; j < sample.size(); ++j) { - if (n[j]) sample[j] /= float(n[j]); + for (decltype(sample)::size_type j = 0; j < sample.size(); ++j) { + if (n[j]) sample[j] /= n[j]; } - return LogRange::useLogScale(sample.toStdVector()); + return LogRange::useLogScale(sample); } void diff -r 10055a284716 -r 5ad98be7f635 data/model/FFTModel.cpp --- a/data/model/FFTModel.cpp Tue Mar 10 20:02:02 2015 +0000 +++ b/data/model/FFTModel.cpp Tue Mar 10 20:03:08 2015 +0000 @@ -36,7 +36,7 @@ int fftSize, bool polar, StorageAdviser::Criteria criteria, - int fillFromColumn) : + sv_frame_t fillFromFrame) : //!!! ZoomConstraint! m_server(0), m_xshift(0), @@ -52,7 +52,7 @@ fftSize, polar, criteria, - fillFromColumn); + fillFromFrame); if (!m_server) return; // caller should check isOK() @@ -110,7 +110,7 @@ int fftSize, bool polar, StorageAdviser::Criteria criteria, - int fillFromColumn) + sv_frame_t fillFromFrame) { // Obviously, an FFT model of channel C (where C != -1) of an // aggregate model is the same as the FFT model of the appropriate @@ -142,7 +142,7 @@ fftSize, polar, criteria, - fillFromColumn); + fillFromFrame); } } @@ -156,7 +156,7 @@ fftSize, polar, criteria, - fillFromColumn); + fillFromFrame); } sv_samplerate_t @@ -205,14 +205,14 @@ } bool -FFTModel::estimateStableFrequency(int x, int y, float &frequency) +FFTModel::estimateStableFrequency(int x, int y, double &frequency) { if (!isOK()) return false; sv_samplerate_t sampleRate = m_server->getModel()->getSampleRate(); int fftSize = m_server->getFFTSize() >> m_yshift; - frequency = float((y * sampleRate) / fftSize); + frequency = double(y * sampleRate) / fftSize; if (x+1 >= getWidth()) return false; @@ -240,8 +240,8 @@ // from assuming the "native" frequency of this bin frequency = - float((sampleRate * (expectedPhase + phaseError - oldPhase)) / - (2 * M_PI * incr)); + (sampleRate * (expectedPhase + phaseError - oldPhase)) / + (2.0 * M_PI * incr); return true; } @@ -430,7 +430,7 @@ / (2 * M_PI * incr); // bool stable = (fabsf(phaseError) < (1.1f * (incr * M_PI) / fftSize)); // if (stable) - peaks[*i] = float(frequency); + peaks[*i] = frequency; ++phaseIndex; } diff -r 10055a284716 -r 5ad98be7f635 data/model/FFTModel.h --- a/data/model/FFTModel.h Tue Mar 10 20:02:02 2015 +0000 +++ b/data/model/FFTModel.h Tue Mar 10 20:03:08 2015 +0000 @@ -63,7 +63,7 @@ int fftSize, bool polar, StorageAdviser::Criteria criteria = StorageAdviser::NoCriteria, - int fillFromColumn = 0); + sv_frame_t fillFromFrame = 0); ~FFTModel(); inline float getMagnitudeAt(int x, int y) { @@ -151,7 +151,7 @@ * bin, using phase unwrapping. This will be completely wrong if * the signal is not stable here. */ - virtual bool estimateStableFrequency(int x, int y, float &frequency); + virtual bool estimateStableFrequency(int x, int y, double &frequency); enum PeakPickType { @@ -161,7 +161,7 @@ }; typedef std::set PeakLocationSet; // bin - typedef std::map PeakSet; // bin -> freq + typedef std::map PeakSet; // bin -> freq /** * Return locations of peak bins in the range [ymin,ymax]. If @@ -200,7 +200,7 @@ FFTDataServer *getServer(const DenseTimeValueModel *, int, WindowType, int, int, int, - bool, StorageAdviser::Criteria, int); + bool, StorageAdviser::Criteria, sv_frame_t); int getPeakPickWindowSize(PeakPickType type, sv_samplerate_t sampleRate, int bin, float &percentile) const; diff -r 10055a284716 -r 5ad98be7f635 data/model/Labeller.h --- a/data/model/Labeller.h Tue Mar 10 20:02:02 2015 +0000 +++ b/data/model/Labeller.h Tue Mar 10 20:03:08 2015 +0000 @@ -132,7 +132,7 @@ if (m_counter > m_cycle) m_counter = 1; } - void setSampleRate(float rate) { m_rate = rate; } + void setSampleRate(sv_samplerate_t rate) { m_rate = rate; } void resetCounters() { m_counter = 1; @@ -262,24 +262,24 @@ case ValueFromSimpleCounter: case ValueFromCyclicalCounter: - value = m_counter; + value = float(m_counter); incrementCounter(); break; case ValueFromTwoLevelCounter: - value = m_counter2 + double(m_counter) / double(m_dp); + value = float(m_counter2 + double(m_counter) / double(m_dp)); incrementCounter(); break; case ValueFromFrameNumber: - value = newPoint.frame; + value = float(newPoint.frame); break; case ValueFromRealTime: - if (m_rate == 0.f) { + if (m_rate == 0.0) { std::cerr << "ERROR: Labeller::getValueFor: Real-time conversion required, but no sample rate set" << std::endl; } else { - value = float(newPoint.frame) / float(m_rate); + value = float(double(newPoint.frame) / m_rate); } break; @@ -287,18 +287,18 @@ case ValueFromTempoToNext: case ValueFromDurationFromPrevious: case ValueFromTempoFromPrevious: - if (m_rate == 0.f) { + if (m_rate == 0.0) { std::cerr << "ERROR: Labeller::getValueFor: Real-time conversion required, but no sample rate set" << std::endl; } else if (!prevPoint) { std::cerr << "ERROR: Labeller::getValueFor: Time difference required, but only one point provided" << std::endl; } else { - int f0 = prevPoint->frame, f1 = newPoint.frame; + sv_frame_t f0 = prevPoint->frame, f1 = newPoint.frame; if (m_type == ValueFromDurationToNext || m_type == ValueFromDurationFromPrevious) { - value = float(f1 - f0) / m_rate; + value = float(double(f1 - f0) / m_rate); } else { if (f1 > f0) { - value = (60.f * m_rate) / (f1 - f0); + value = float((60.0 * m_rate) / double(f1 - f0)); } } } @@ -313,7 +313,7 @@ case ValueFromLabel: if (newPoint.label != "") { // more forgiving than QString::toFloat() - value = atof(newPoint.label.toLocal8Bit()); + value = float(atof(newPoint.label.toLocal8Bit())); } else { value = 0.f; } @@ -328,7 +328,7 @@ int m_counter2; int m_cycle; int m_dp; - float m_rate; + sv_samplerate_t m_rate; }; #endif diff -r 10055a284716 -r 5ad98be7f635 data/model/ModelDataTableModel.cpp --- a/data/model/ModelDataTableModel.cpp Tue Mar 10 20:02:02 2015 +0000 +++ b/data/model/ModelDataTableModel.cpp Tue Mar 10 20:03:08 2015 +0000 @@ -31,8 +31,8 @@ Model *baseModel = dynamic_cast(m); connect(baseModel, SIGNAL(modelChanged()), this, SLOT(modelChanged())); - connect(baseModel, SIGNAL(modelChangedWithin(int, int)), - this, SLOT(modelChangedWithin(int, int))); + connect(baseModel, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), + this, SLOT(modelChangedWithin(sv_frame_t, sv_frame_t))); connect(baseModel, SIGNAL(aboutToBeDeleted()), this, SLOT(modelAboutToBeDeleted())); } @@ -219,7 +219,7 @@ } void -ModelDataTableModel::modelChangedWithin(int, int) +ModelDataTableModel::modelChangedWithin(sv_frame_t, sv_frame_t) { //!!! inefficient clearSort(); diff -r 10055a284716 -r 5ad98be7f635 data/model/ModelDataTableModel.h --- a/data/model/ModelDataTableModel.h Tue Mar 10 20:02:02 2015 +0000 +++ b/data/model/ModelDataTableModel.h Tue Mar 10 20:03:08 2015 +0000 @@ -71,7 +71,7 @@ protected slots: void modelChanged(); - void modelChangedWithin(int, int); + void modelChangedWithin(sv_frame_t, sv_frame_t); void modelAboutToBeDeleted(); protected: diff -r 10055a284716 -r 5ad98be7f635 rdf/RDFFeatureWriter.cpp --- a/rdf/RDFFeatureWriter.cpp Tue Mar 10 20:02:02 2015 +0000 +++ b/rdf/RDFFeatureWriter.cpp Tue Mar 10 20:03:08 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 10055a284716 -r 5ad98be7f635 transform/CSVFeatureWriter.cpp --- a/transform/CSVFeatureWriter.cpp Tue Mar 10 20:02:02 2015 +0000 +++ b/transform/CSVFeatureWriter.cpp Tue Mar 10 20:03:08 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 10055a284716 -r 5ad98be7f635 transform/ModelTransformerFactory.cpp --- a/transform/ModelTransformerFactory.cpp Tue Mar 10 20:02:02 2015 +0000 +++ b/transform/ModelTransformerFactory.cpp Tue Mar 10 20:03:08 2015 +0000 @@ -55,8 +55,8 @@ const std::vector &candidateInputModels, Model *defaultInputModel, AudioPlaySource *source, - int startFrame, - int duration, + sv_frame_t startFrame, + sv_frame_t duration, UserConfigurator *configurator) { ModelTransformer::Input input(0); diff -r 10055a284716 -r 5ad98be7f635 transform/ModelTransformerFactory.h --- a/transform/ModelTransformerFactory.h Tue Mar 10 20:02:02 2015 +0000 +++ b/transform/ModelTransformerFactory.h Tue Mar 10 20:03:08 2015 +0000 @@ -47,8 +47,8 @@ Vamp::PluginBase *plugin, Model *&inputModel, AudioPlaySource *source, - int startFrame, - int duration, + sv_frame_t startFrame, + sv_frame_t duration, const QMap &modelMap, QStringList candidateModelNames, QString defaultModelName) = 0; @@ -67,8 +67,8 @@ const std::vector &candidateInputModels, Model *defaultInputModel, AudioPlaySource *source = 0, - int startFrame = 0, - int duration = 0, + sv_frame_t startFrame = 0, + sv_frame_t duration = 0, UserConfigurator *configurator = 0); class AdditionalModelHandler { diff -r 10055a284716 -r 5ad98be7f635 transform/Transform.cpp --- a/transform/Transform.cpp Tue Mar 10 20:02:02 2015 +0000 +++ b/transform/Transform.cpp Tue Mar 10 20:03:08 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 10055a284716 -r 5ad98be7f635 transform/Transform.h --- a/transform/Transform.h Tue Mar 10 20:02:02 2015 +0000 +++ b/transform/Transform.h Tue Mar 10 20:03:08 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 10055a284716 -r 5ad98be7f635 transform/TransformFactory.cpp --- a/transform/TransformFactory.cpp Tue Mar 10 20:02:02 2015 +0000 +++ b/transform/TransformFactory.cpp Tue Mar 10 20:03:08 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 10055a284716 -r 5ad98be7f635 transform/TransformFactory.h --- a/transform/TransformFactory.h Tue Mar 10 20:02:02 2015 +0000 +++ b/transform/TransformFactory.h Tue Mar 10 20:03:08 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;