# HG changeset patch # User Chris Cannam # Date 1403095876 -3600 # Node ID 0c1d6de8f44bc158bcb55866874602bcb912e2cf # Parent 49618f39ff091e72eb94dd0d8424da44cf10e272# Parent a8f3195b0761c446ed4726e942be8228870f965e Merge from branch warnfix_no_size_t diff -r 49618f39ff09 -r 0c1d6de8f44b base/AudioPlaySource.h --- a/base/AudioPlaySource.h Tue Jun 03 11:05:49 2014 +0100 +++ b/base/AudioPlaySource.h Wed Jun 18 13:51:16 2014 +0100 @@ -37,7 +37,7 @@ * Start playing from the given frame. If playback is already * under way, reseek to the given frame and continue. */ - virtual void play(size_t startFrame) = 0; + virtual void play(int startFrame) = 0; /** * Stop playback. @@ -53,7 +53,7 @@ * Return the frame number that is currently expected to be coming * out of the speakers. (i.e. compensating for playback latency.) */ - virtual size_t getCurrentPlayingFrame() = 0; + virtual int getCurrentPlayingFrame() = 0; /** * Return the current (or thereabouts) output levels in the range @@ -65,14 +65,14 @@ * Return the sample rate of the source material -- any material * that wants to play at a different rate will sound wrong. */ - virtual size_t getSourceSampleRate() const = 0; + virtual int getSourceSampleRate() const = 0; /** * Return the sample rate set by the target audio device (or the * source sample rate if the target hasn't set one). If the * source and target sample rates differ, resampling will occur. */ - virtual size_t getTargetSampleRate() const = 0; + virtual int getTargetSampleRate() const = 0; /** * Get the block size of the target audio device. This may be an @@ -80,7 +80,7 @@ * size; the source should behave itself even if this value turns * out to be inaccurate. */ - virtual size_t getTargetBlockSize() const = 0; + virtual int getTargetBlockSize() const = 0; /** * Get the number of channels of audio that will be provided @@ -88,7 +88,7 @@ * count: for example, a mono source will provide 2 channels * after pan. */ - virtual size_t getTargetChannelCount() const = 0; + virtual int getTargetChannelCount() const = 0; /** * Set a plugin or other subclass of Auditionable as an diff -r 49618f39ff09 -r 0c1d6de8f44b base/Clipboard.cpp --- a/base/Clipboard.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/base/Clipboard.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -44,7 +44,7 @@ { } -Clipboard::Point::Point(long frame, float value, size_t duration, QString label) : +Clipboard::Point::Point(long frame, float value, int duration, QString label) : m_haveFrame(true), m_frame(frame), m_haveValue(true), @@ -60,7 +60,7 @@ { } -Clipboard::Point::Point(long frame, float value, size_t duration, float level, QString label) : +Clipboard::Point::Point(long frame, float value, int duration, float level, QString label) : m_haveFrame(true), m_frame(frame), m_haveValue(true), @@ -159,14 +159,14 @@ return m_haveDuration; } -size_t +int Clipboard::Point::getDuration() const { return m_duration; } Clipboard::Point -Clipboard::Point::withDuration(size_t duration) const +Clipboard::Point::withDuration(int duration) const { Point p(*this); p.m_haveDuration = true; diff -r 49618f39ff09 -r 0c1d6de8f44b base/Clipboard.h --- a/base/Clipboard.h Tue Jun 03 11:05:49 2014 +0100 +++ b/base/Clipboard.h Wed Jun 18 13:51:16 2014 +0100 @@ -27,8 +27,8 @@ public: Point(long frame, QString label); Point(long frame, float value, QString label); - Point(long frame, float value, size_t duration, QString label); - Point(long frame, float value, size_t duration, float level, QString label); + Point(long frame, float value, int duration, QString label); + Point(long frame, float value, int duration, float level, QString label); Point(const Point &point); Point &operator=(const Point &point); @@ -41,8 +41,8 @@ Point withValue(float value) const; bool haveDuration() const; - size_t getDuration() const; - Point withDuration(size_t duration) const; + int getDuration() const; + Point withDuration(int duration) const; bool haveLabel() const; QString getLabel() const; @@ -64,7 +64,7 @@ bool m_haveValue; float m_value; bool m_haveDuration; - size_t m_duration; + int m_duration; bool m_haveLabel; QString m_label; bool m_haveLevel; diff -r 49618f39ff09 -r 0c1d6de8f44b base/Exceptions.cpp --- a/base/Exceptions.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/base/Exceptions.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -91,8 +91,8 @@ } InsufficientDiscSpace::InsufficientDiscSpace(QString directory, - size_t required, - size_t available) throw() : + int required, + int available) throw() : m_directory(directory), m_required(required), m_available(available) diff -r 49618f39ff09 -r 0c1d6de8f44b base/Exceptions.h --- a/base/Exceptions.h Tue Jun 03 11:05:49 2014 +0100 +++ b/base/Exceptions.h Wed Jun 18 13:51:16 2014 +0100 @@ -82,19 +82,19 @@ { public: InsufficientDiscSpace(QString directory, - size_t required, size_t available) throw(); + int required, int available) throw(); InsufficientDiscSpace(QString directory) throw(); virtual ~InsufficientDiscSpace() throw() { } virtual const char *what() const throw(); QString getDirectory() const { return m_directory; } - size_t getRequired() const { return m_required; } - size_t getAvailable() const { return m_available; } + int getRequired() const { return m_required; } + int getAvailable() const { return m_available; } protected: QString m_directory; - size_t m_required; - size_t m_available; + int m_required; + int m_available; }; class AllocationFailed : virtual public std::exception diff -r 49618f39ff09 -r 0c1d6de8f44b base/FrameTimer.h --- a/base/FrameTimer.h Tue Jun 03 11:05:49 2014 +0100 +++ b/base/FrameTimer.h Wed Jun 18 13:51:16 2014 +0100 @@ -25,7 +25,7 @@ class FrameTimer { public: - virtual unsigned long getFrame() const = 0; + virtual int getFrame() const = 0; }; #endif diff -r 49618f39ff09 -r 0c1d6de8f44b base/Preferences.cpp --- a/base/Preferences.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/base/Preferences.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -43,7 +43,9 @@ m_resampleQuality(1), m_omitRecentTemps(true), m_tempDirRoot(""), + m_fixedSampleRate(0), m_resampleOnLoad(false), + m_normaliseAudio(false), m_viewFontSize(10), m_backgroundMode(BackgroundFromTheme), m_timeToTextMode(TimeToTextMs), @@ -62,7 +64,9 @@ 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_resampleOnLoad = settings.value("resample-on-load", false).toBool(); + m_normaliseAudio = settings.value("normalise-audio", false).toBool(); m_backgroundMode = BackgroundMode (settings.value("background-mode", int(BackgroundFromTheme)).toInt()); m_timeToTextMode = TimeToTextMode @@ -93,6 +97,8 @@ props.push_back("Resample Quality"); props.push_back("Omit Temporaries from Recent Files"); props.push_back("Resample On Load"); + props.push_back("Normalise Audio"); + props.push_back("Fixed Sample Rate"); props.push_back("Temporary Directory Root"); props.push_back("Background Mode"); props.push_back("Time To Text Mode"); @@ -123,12 +129,18 @@ if (name == "Resample Quality") { return tr("Playback resampler type"); } + if (name == "Normalise Audio") { + return tr("Normalise audio signal when reading from audio file"); + } if (name == "Omit Temporaries from Recent Files") { return tr("Omit temporaries from Recent Files menu"); } if (name == "Resample On Load") { return tr("Resample mismatching files on import"); } + if (name == "Fixed Sample Rate") { + return tr("Single fixed sample rate to resample all files to"); + } if (name == "Temporary Directory Root") { return tr("Location for cache file directory"); } @@ -171,12 +183,18 @@ if (name == "Resample Quality") { return ValueProperty; } + if (name == "Normalise Audio") { + return ToggleProperty; + } if (name == "Omit Temporaries from Recent Files") { return ToggleProperty; } if (name == "Resample On Load") { return ToggleProperty; } + if (name == "Fixed Sample Rate") { + return ValueProperty; + } if (name == "Temporary Directory Root") { // It's an arbitrary string, we don't have a set of values for this return InvalidProperty; @@ -525,6 +543,32 @@ } void +Preferences::setFixedSampleRate(int rate) +{ + if (m_fixedSampleRate != rate) { + m_fixedSampleRate = rate; + QSettings settings; + settings.beginGroup("Preferences"); + settings.setValue("fixed-sample-rate", rate); + settings.endGroup(); + emit propertyChanged("Fixed Sample Rate"); + } +} + +void +Preferences::setNormaliseAudio(bool norm) +{ + if (m_normaliseAudio != norm) { + m_normaliseAudio = norm; + QSettings settings; + settings.beginGroup("Preferences"); + settings.setValue("normalise-audio", norm); + settings.endGroup(); + emit propertyChanged("Normalise Audio"); + } +} + +void Preferences::setBackgroundMode(BackgroundMode mode) { if (m_backgroundMode != mode) { diff -r 49618f39ff09 -r 0c1d6de8f44b base/Preferences.h --- a/base/Preferences.h Tue Jun 03 11:05:49 2014 +0100 +++ b/base/Preferences.h Wed Jun 18 13:51:16 2014 +0100 @@ -66,8 +66,15 @@ 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; } + + /// True if we should resample second or subsequent audio file to match first audio file's rate bool getResampleOnLoad() const { return m_resampleOnLoad; } + /// True if audio files should be loaded with normalisation (max == 1) + bool getNormaliseAudio() const { return m_normaliseAudio; } + enum BackgroundMode { BackgroundFromTheme, DarkBackground, @@ -107,7 +114,9 @@ void setResampleQuality(int quality); void setOmitTempsFromRecentFiles(bool omit); void setTemporaryDirectoryRoot(QString tempDirRoot); + void setFixedSampleRate(int); void setResampleOnLoad(bool); + void setNormaliseAudio(bool); void setBackgroundMode(BackgroundMode mode); void setTimeToTextMode(TimeToTextMode mode); void setOctaveOfMiddleC(int oct); @@ -141,7 +150,9 @@ int m_resampleQuality; bool m_omitRecentTemps; QString m_tempDirRoot; + int m_fixedSampleRate; bool m_resampleOnLoad; + bool m_normaliseAudio; int m_viewFontSize; BackgroundMode m_backgroundMode; TimeToTextMode m_timeToTextMode; diff -r 49618f39ff09 -r 0c1d6de8f44b base/PropertyContainer.cpp --- a/base/PropertyContainer.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/base/PropertyContainer.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -54,7 +54,7 @@ } QString -PropertyContainer::getPropertyValueLabel(const PropertyName &name, int value) const +PropertyContainer::getPropertyValueLabel(const PropertyName &, int) const { return QString(); } diff -r 49618f39ff09 -r 0c1d6de8f44b base/RealTime.cpp --- a/base/RealTime.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/base/RealTime.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -89,8 +89,6 @@ bool negative = false, afterT = false; - int valstart = 0; - while (i < len) { if (s[i] == '-') { @@ -103,7 +101,6 @@ char *eptr = 0; if (isdigit(s[i]) || s[i] == '.') { - valstart = i; value = strtod(&s[i], &eptr); i = eptr - s; } @@ -151,7 +148,11 @@ t = t + fromSeconds(second); - return t; + if (negative) { + return -t; + } else { + return t; + } } double diff -r 49618f39ff09 -r 0c1d6de8f44b base/RecentFiles.cpp --- a/base/RecentFiles.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/base/RecentFiles.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -21,7 +21,7 @@ #include #include -RecentFiles::RecentFiles(QString settingsGroup, size_t maxCount) : +RecentFiles::RecentFiles(QString settingsGroup, int maxCount) : m_settingsGroup(settingsGroup), m_maxCount(maxCount) { @@ -40,7 +40,7 @@ QSettings settings; settings.beginGroup(m_settingsGroup); - for (size_t i = 0; i < 100; ++i) { + for (int i = 0; i < 100; ++i) { QString key = QString("recent-%1").arg(i); QString name = settings.value(key, "").toString(); if (name == "") break; @@ -57,10 +57,10 @@ QSettings settings; settings.beginGroup(m_settingsGroup); - for (size_t i = 0; i < m_maxCount; ++i) { + for (int i = 0; i < m_maxCount; ++i) { QString key = QString("recent-%1").arg(i); QString name = ""; - if (i < m_names.size()) name = m_names[i]; + if (i < (int)m_names.size()) name = m_names[i]; settings.setValue(key, name); } @@ -70,7 +70,7 @@ void RecentFiles::truncateAndWrite() { - while (m_names.size() > m_maxCount) { + while (int(m_names.size()) > m_maxCount) { m_names.pop_back(); } write(); @@ -80,8 +80,8 @@ RecentFiles::getRecent() const { std::vector names; - for (size_t i = 0; i < m_maxCount; ++i) { - if (i < m_names.size()) { + for (int i = 0; i < m_maxCount; ++i) { + if (i < (int)m_names.size()) { names.push_back(m_names[i]); } } @@ -92,7 +92,7 @@ RecentFiles::add(QString name) { bool have = false; - for (size_t i = 0; i < m_names.size(); ++i) { + for (int i = 0; i < int(m_names.size()); ++i) { if (m_names[i] == name) { have = true; break; @@ -104,7 +104,7 @@ } else { std::deque newnames; newnames.push_back(name); - for (size_t i = 0; i < m_names.size(); ++i) { + for (int i = 0; i < int(m_names.size()); ++i) { if (m_names[i] == name) continue; newnames.push_back(m_names[i]); } diff -r 49618f39ff09 -r 0c1d6de8f44b base/RecentFiles.h --- a/base/RecentFiles.h Tue Jun 03 11:05:49 2014 +0100 +++ b/base/RecentFiles.h Wed Jun 18 13:51:16 2014 +0100 @@ -37,7 +37,7 @@ * given QSettings group and truncates when the given count of * strings is reached. */ - RecentFiles(QString settingsGroup = "RecentFiles", size_t maxCount = 10); + RecentFiles(QString settingsGroup = "RecentFiles", int maxCount = 10); virtual ~RecentFiles(); @@ -68,7 +68,7 @@ protected: QString m_settingsGroup; - size_t m_maxCount; + int m_maxCount; std::deque m_names; diff -r 49618f39ff09 -r 0c1d6de8f44b base/Resampler.cpp --- a/base/Resampler.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/base/Resampler.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -31,15 +31,15 @@ class Resampler::D { public: - D(Quality quality, size_t channels, size_t chunkSize); + D(Quality quality, int channels, int chunkSize); ~D(); - size_t resample(float **in, float **out, - size_t incount, float ratio, + int resample(float **in, float **out, + int incount, float ratio, bool final); - size_t resampleInterleaved(float *in, float *out, - size_t incount, float ratio, + int resampleInterleaved(float *in, float *out, + int incount, float ratio, bool final); void reset(); @@ -48,12 +48,12 @@ SRC_STATE *m_src; float *m_iin; float *m_iout; - size_t m_channels; - size_t m_iinsize; - size_t m_ioutsize; + int m_channels; + int m_iinsize; + int m_ioutsize; }; -Resampler::D::D(Quality quality, size_t channels, size_t chunkSize) : +Resampler::D::D(Quality quality, int channels, int chunkSize) : m_src(0), m_iin(0), m_iout(0), @@ -89,16 +89,16 @@ } } -size_t +int Resampler::D::resample(float **in, float **out, - size_t incount, float ratio, + int incount, float ratio, bool final) { if (m_channels == 1) { return resampleInterleaved(*in, *out, incount, ratio, final); } - size_t outcount = lrintf(ceilf(incount * ratio)); + int outcount = lrintf(ceilf(incount * ratio)); if (incount * m_channels > m_iinsize) { m_iinsize = incount * m_channels; @@ -108,16 +108,16 @@ m_ioutsize = outcount * m_channels; m_iout = (float *)realloc(m_iout, m_ioutsize * sizeof(float)); } - for (size_t i = 0; i < incount; ++i) { - for (size_t c = 0; c < m_channels; ++c) { + for (int i = 0; i < incount; ++i) { + for (int c = 0; c < m_channels; ++c) { m_iin[i * m_channels + c] = in[c][i]; } } - size_t gen = resampleInterleaved(m_iin, m_iout, incount, ratio, final); + int gen = resampleInterleaved(m_iin, m_iout, incount, ratio, final); - for (size_t i = 0; i < gen; ++i) { - for (size_t c = 0; c < m_channels; ++c) { + for (int i = 0; i < gen; ++i) { + for (int c = 0; c < m_channels; ++c) { out[c][i] = m_iout[i * m_channels + c]; } } @@ -125,14 +125,14 @@ return gen; } -size_t +int Resampler::D::resampleInterleaved(float *in, float *out, - size_t incount, float ratio, + int incount, float ratio, bool final) { SRC_DATA data; - size_t outcount = lrintf(ceilf(incount * ratio)); + int outcount = lrintf(ceilf(incount * ratio)); data.data_in = in; data.data_out = out; @@ -143,9 +143,13 @@ int err = src_process(m_src, &data); - //!!! check err, respond appropriately + if (err) { + cerr << "Resampler: ERROR: src_process returned error: " << + src_strerror(err) << endl; + return 0; + } - if (data.input_frames_used != incount) { + if (data.input_frames_used != (int)incount) { cerr << "Resampler: NOTE: input_frames_used == " << data.input_frames_used << " (while incount = " << incount << ")" << endl; } @@ -158,7 +162,7 @@ src_reset(m_src); } -Resampler::Resampler(Quality quality, size_t channels, size_t chunkSize) +Resampler::Resampler(Quality quality, int channels, int chunkSize) { m_d = new D(quality, channels, chunkSize); } @@ -168,17 +172,17 @@ delete m_d; } -size_t +int Resampler::resample(float **in, float **out, - size_t incount, float ratio, + int incount, float ratio, bool final) { return m_d->resample(in, out, incount, ratio, final); } -size_t +int Resampler::resampleInterleaved(float *in, float *out, - size_t incount, float ratio, + int incount, float ratio, bool final) { return m_d->resampleInterleaved(in, out, incount, ratio, final); diff -r 49618f39ff09 -r 0c1d6de8f44b base/Resampler.h --- a/base/Resampler.h Tue Jun 03 11:05:49 2014 +0100 +++ b/base/Resampler.h Wed Jun 18 13:51:16 2014 +0100 @@ -28,15 +28,15 @@ public: enum Quality { Best, FastestTolerable, Fastest }; - Resampler(Quality quality, size_t channels, size_t chunkSize = 0); + Resampler(Quality quality, int channels, int chunkSize = 0); ~Resampler(); - size_t resample(float **in, float **out, - size_t incount, float ratio, + int resample(float **in, float **out, + int incount, float ratio, bool final = false); - size_t resampleInterleaved(float *in, float *out, - size_t incount, float ratio, + int resampleInterleaved(float *in, float *out, + int incount, float ratio, bool final = false); void reset(); diff -r 49618f39ff09 -r 0c1d6de8f44b base/RingBuffer.h --- a/base/RingBuffer.h Tue Jun 03 11:05:49 2014 +0100 +++ b/base/RingBuffer.h Wed Jun 18 13:51:16 2014 +0100 @@ -55,7 +55,7 @@ * power of two, this means n should ideally be some power of two * minus one. */ - RingBuffer(size_t n); + RingBuffer(int n); virtual ~RingBuffer(); @@ -63,7 +63,7 @@ * Return the total capacity of the ring buffer in samples. * (This is the argument n passed to the constructor.) */ - size_t getSize() const; + int getSize() const; /** * Return a new ring buffer (allocated with "new" -- caller must @@ -74,7 +74,7 @@ * inconsistent. If this buffer's data will not fit in the new * size, the contents are undefined. */ - RingBuffer *resized(size_t newSize) const; + RingBuffer *resized(int newSize) const; /** * Lock the ring buffer into physical memory. Returns true @@ -92,19 +92,19 @@ * Return the amount of data available for reading by reader R, in * samples. */ - size_t getReadSpace(int R = 0) const; + int getReadSpace(int R = 0) const; /** * Return the amount of space available for writing, in samples. */ - size_t getWriteSpace() const; + int getWriteSpace() const; /** * Read n samples from the buffer, for reader R. If fewer than n * are available, the remainder will be zeroed out. Returns the * number of samples actually read. */ - size_t read(T *destination, size_t n, int R = 0); + int read(T *destination, int n, int R = 0); /** * Read n samples from the buffer, for reader R, adding them to @@ -112,7 +112,7 @@ * will be left alone. Returns the number of samples actually * read. */ - size_t readAdding(T *destination, size_t n, int R = 0); + int readAdding(T *destination, int n, int R = 0); /** * Read one sample from the buffer, for reader R. If no sample is @@ -130,7 +130,7 @@ * n are available, the remainder will be zeroed out. Returns the * number of samples actually read. */ - size_t peek(T *destination, size_t n, int R = 0) const; + int peek(T *destination, int n, int R = 0) const; /** * Read one sample from the buffer, if available, without @@ -146,29 +146,29 @@ * samples). Returns the number of samples actually available for * discarding. */ - size_t skip(size_t n, int R = 0); + int skip(int n, int R = 0); /** * Write n samples to the buffer. If insufficient space is * available, not all samples may actually be written. Returns * the number of samples actually written. */ - size_t write(const T *source, size_t n); + int write(const T *source, int n); /** * Write n zero-value samples to the buffer. If insufficient * space is available, not all zeros may actually be written. * Returns the number of zeroes actually written. */ - size_t zero(size_t n); + int zero(int n); protected: - T *m_buffer; - bool m_mlocked; - size_t m_writer; - size_t *m_readers; - size_t m_size; - size_t m_spare; + T *m_buffer; + bool m_mlocked; + int m_writer; + int *m_readers; + int m_size; + int m_spare; private: RingBuffer(const RingBuffer &); // not provided @@ -176,11 +176,11 @@ }; template -RingBuffer::RingBuffer(size_t n) : +RingBuffer::RingBuffer(int n) : m_buffer(new T[n + 1]), m_mlocked(false), m_writer(0), - m_readers(new size_t[N]), + m_readers(new int[N]), m_size(n + 1) { #ifdef DEBUG_RINGBUFFER @@ -216,7 +216,7 @@ } template -size_t +int RingBuffer::getSize() const { #ifdef DEBUG_RINGBUFFER @@ -228,7 +228,7 @@ template RingBuffer * -RingBuffer::resized(size_t newSize) const +RingBuffer::resized(int newSize) const { #ifdef DEBUG_RINGBUFFER std::cerr << "RingBuffer[" << this << "]::resized(" << newSize << ")" << std::endl; @@ -270,12 +270,12 @@ } template -size_t +int RingBuffer::getReadSpace(int R) const { - size_t writer = m_writer; - size_t reader = m_readers[R]; - size_t space = 0; + int writer = m_writer; + int reader = m_readers[R]; + int space = 0; if (writer > reader) space = writer - reader; else space = ((writer + m_size) - reader) % m_size; @@ -288,17 +288,17 @@ } template -size_t +int RingBuffer::getWriteSpace() const { - size_t space = 0; + int space = 0; for (int i = 0; i < N; ++i) { - size_t here = (m_readers[i] + m_size - m_writer - 1) % m_size; + int here = (m_readers[i] + m_size - m_writer - 1) % m_size; if (i == 0 || here < space) space = here; } #ifdef DEBUG_RINGBUFFER - size_t rs(getReadSpace()), rp(m_readers[0]); + int rs(getReadSpace()), rp(m_readers[0]); std::cerr << "RingBuffer: write space " << space << ", read space " << rs << ", total " << (space + rs) << ", m_size " << m_size << std::endl; @@ -313,14 +313,14 @@ } template -size_t -RingBuffer::read(T *destination, size_t n, int R) +int +RingBuffer::read(T *destination, int n, int R) { #ifdef DEBUG_RINGBUFFER std::cerr << "RingBuffer[" << this << "]::read(dest, " << n << ", " << R << ")" << std::endl; #endif - size_t available = getReadSpace(R); + int available = getReadSpace(R); if (n > available) { #ifdef DEBUG_RINGBUFFER std::cerr << "WARNING: Only " << available << " samples available" @@ -331,7 +331,7 @@ } if (n == 0) return n; - size_t here = m_size - m_readers[R]; + int here = m_size - m_readers[R]; if (here >= n) { memcpy(destination, m_buffer + m_readers[R], n * sizeof(T)); } else { @@ -350,14 +350,14 @@ } template -size_t -RingBuffer::readAdding(T *destination, size_t n, int R) +int +RingBuffer::readAdding(T *destination, int n, int R) { #ifdef DEBUG_RINGBUFFER std::cerr << "RingBuffer[" << this << "]::readAdding(dest, " << n << ", " << R << ")" << std::endl; #endif - size_t available = getReadSpace(R); + int available = getReadSpace(R); if (n > available) { #ifdef DEBUG_RINGBUFFER std::cerr << "WARNING: Only " << available << " samples available" @@ -367,17 +367,17 @@ } if (n == 0) return n; - size_t here = m_size - m_readers[R]; + int here = m_size - m_readers[R]; if (here >= n) { - for (size_t i = 0; i < n; ++i) { + for (int i = 0; i < n; ++i) { destination[i] += (m_buffer + m_readers[R])[i]; } } else { - for (size_t i = 0; i < here; ++i) { + for (int i = 0; i < here; ++i) { destination[i] += (m_buffer + m_readers[R])[i]; } - for (size_t i = 0; i < (n - here); ++i) { + for (int i = 0; i < (n - here); ++i) { destination[i + here] += m_buffer[i]; } } @@ -411,14 +411,14 @@ } template -size_t -RingBuffer::peek(T *destination, size_t n, int R) const +int +RingBuffer::peek(T *destination, int n, int R) const { #ifdef DEBUG_RINGBUFFER std::cerr << "RingBuffer[" << this << "]::peek(dest, " << n << ", " << R << ")" << std::endl; #endif - size_t available = getReadSpace(R); + int available = getReadSpace(R); if (n > available) { #ifdef DEBUG_RINGBUFFER std::cerr << "WARNING: Only " << available << " samples available" @@ -429,7 +429,7 @@ } if (n == 0) return n; - size_t here = m_size - m_readers[R]; + int here = m_size - m_readers[R]; if (here >= n) { memcpy(destination, m_buffer + m_readers[R], n * sizeof(T)); } else { @@ -466,14 +466,14 @@ } template -size_t -RingBuffer::skip(size_t n, int R) +int +RingBuffer::skip(int n, int R) { #ifdef DEBUG_RINGBUFFER std::cerr << "RingBuffer[" << this << "]::skip(" << n << ", " << R << ")" << std::endl; #endif - size_t available = getReadSpace(R); + int available = getReadSpace(R); if (n > available) { #ifdef DEBUG_RINGBUFFER std::cerr << "WARNING: Only " << available << " samples available" @@ -487,14 +487,14 @@ } template -size_t -RingBuffer::write(const T *source, size_t n) +int +RingBuffer::write(const T *source, int n) { #ifdef DEBUG_RINGBUFFER std::cerr << "RingBuffer[" << this << "]::write(" << n << ")" << std::endl; #endif - size_t available = getWriteSpace(); + int available = getWriteSpace(); if (n > available) { #ifdef DEBUG_RINGBUFFER std::cerr << "WARNING: Only room for " << available << " samples" @@ -504,7 +504,7 @@ } if (n == 0) return n; - size_t here = m_size - m_writer; + int here = m_size - m_writer; if (here >= n) { memcpy(m_buffer + m_writer, source, n * sizeof(T)); } else { @@ -523,14 +523,14 @@ } template -size_t -RingBuffer::zero(size_t n) +int +RingBuffer::zero(int n) { #ifdef DEBUG_RINGBUFFER std::cerr << "RingBuffer[" << this << "]::zero(" << n << ")" << std::endl; #endif - size_t available = getWriteSpace(); + int available = getWriteSpace(); if (n > available) { #ifdef DEBUG_RINGBUFFER std::cerr << "WARNING: Only room for " << available << " samples" @@ -540,7 +540,7 @@ } if (n == 0) return n; - size_t here = m_size - m_writer; + int here = m_size - m_writer; if (here >= n) { memset(m_buffer + m_writer, 0, n * sizeof(T)); } else { diff -r 49618f39ff09 -r 0c1d6de8f44b base/Selection.cpp --- a/base/Selection.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/base/Selection.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -22,12 +22,12 @@ { } -Selection::Selection(size_t startFrame, size_t endFrame) : +Selection::Selection(int startFrame, int endFrame) : m_startFrame(startFrame), m_endFrame(endFrame) { if (m_startFrame > m_endFrame) { - size_t tmp = m_endFrame; + int tmp = m_endFrame; m_endFrame = m_startFrame; m_startFrame = tmp; } @@ -59,20 +59,20 @@ return m_startFrame == m_endFrame; } -size_t +int Selection::getStartFrame() const { return m_startFrame; } -size_t +int Selection::getEndFrame() const { return m_endFrame; } bool -Selection::contains(size_t frame) const +Selection::contains(int frame) const { return (frame >= m_startFrame) && (frame < m_endFrame); } @@ -174,7 +174,7 @@ } void -MultiSelection::getExtents(size_t &startFrame, size_t &endFrame) const +MultiSelection::getExtents(int &startFrame, int &endFrame) const { startFrame = 0; endFrame = 0; @@ -193,7 +193,7 @@ } Selection -MultiSelection::getContainingSelection(size_t frame, bool defaultToFollowing) const +MultiSelection::getContainingSelection(int frame, bool defaultToFollowing) const { // This scales very badly with the number of selections, but it's // more efficient for very small numbers of selections than a more diff -r 49618f39ff09 -r 0c1d6de8f44b base/Selection.h --- a/base/Selection.h Tue Jun 03 11:05:49 2014 +0100 +++ b/base/Selection.h Wed Jun 18 13:51:16 2014 +0100 @@ -21,26 +21,41 @@ #include "XmlExportable.h" +/** + * A selection object simply represents a range in time, via start and + * end frame. + * + * The end frame is the index of the frame just *after* the end of the + * selection. For example a selection of length 10 frames starting at + * time 0 will have start frame 0 and end frame 10. This will be + * contiguous with (rather than overlapping with) a selection that + * starts at frame 10. + * + * Any selection with equal start and end frames is empty, + * representing "no selection". All empty selections are equal under + * the comparison operators. The default constructor makes an empty + * selection with start and end frames equal to zero. + */ class Selection { public: Selection(); - Selection(size_t startFrame, size_t endFrame); + Selection(int startFrame, int endFrame); Selection(const Selection &); Selection &operator=(const Selection &); virtual ~Selection(); bool isEmpty() const; - size_t getStartFrame() const; - size_t getEndFrame() const; - bool contains(size_t frame) const; + int getStartFrame() const; + int getEndFrame() const; + bool contains(int frame) const; bool operator<(const Selection &) const; bool operator==(const Selection &) const; protected: - size_t m_startFrame; - size_t m_endFrame; + int m_startFrame; + int m_endFrame; }; class MultiSelection : public XmlExportable @@ -57,7 +72,7 @@ void removeSelection(const Selection &selection); void clearSelections(); - void getExtents(size_t &startFrame, size_t &endFrame) const; + void getExtents(int &startFrame, int &endFrame) const; /** * Return the selection that contains a given frame. @@ -65,7 +80,7 @@ * selected area, return the next selection after the given frame. * Return the empty selection if no appropriate selection is found. */ - Selection getContainingSelection(size_t frame, bool defaultToFollowing) const; + Selection getContainingSelection(int frame, bool defaultToFollowing) const; virtual void toXml(QTextStream &stream, QString indent = "", QString extraAttributes = "") const; diff -r 49618f39ff09 -r 0c1d6de8f44b base/StringBits.cpp --- a/base/StringBits.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/base/StringBits.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -105,14 +105,14 @@ c = s[i]; switch (mode) { case sep: mode = unq; tok += c; break; - default: tok += c; break; + case unq: case q1: case q2: tok += c; break; } } } else { switch (mode) { case sep: mode = unq; tok += c; break; - default: tok += c; break; + case unq: case q1: case q2: tok += c; break; } } } diff -r 49618f39ff09 -r 0c1d6de8f44b base/ViewManagerBase.h --- a/base/ViewManagerBase.h Tue Jun 03 11:05:49 2014 +0100 +++ b/base/ViewManagerBase.h Wed Jun 18 13:51:16 2014 +0100 @@ -37,15 +37,15 @@ virtual void setAudioPlaySource(AudioPlaySource *source) = 0; - virtual size_t alignPlaybackFrameToReference(size_t) const = 0; - virtual size_t alignReferenceToPlaybackFrame(size_t) const = 0; + virtual int alignPlaybackFrameToReference(int) const = 0; + virtual int alignReferenceToPlaybackFrame(int) const = 0; virtual const MultiSelection &getSelection() const = 0; virtual const MultiSelection::SelectionList &getSelections() const = 0; - virtual size_t constrainFrameToSelection(size_t frame) const = 0; + virtual int constrainFrameToSelection(int frame) const = 0; virtual Selection getContainingSelection - (size_t frame, bool defaultToFollowing) const = 0; + (int frame, bool defaultToFollowing) const = 0; virtual bool getPlayLoopMode() const = 0; virtual bool getPlaySelectionMode() const = 0; diff -r 49618f39ff09 -r 0c1d6de8f44b base/Window.h --- a/base/Window.h Tue Jun 03 11:05:49 2014 +0100 +++ b/base/Window.h Wed Jun 18 13:51:16 2014 +0100 @@ -47,7 +47,7 @@ * than symmetrical. (A window of size N is equivalent to a * symmetrical window of size N+1 with the final element missing.) */ - Window(WindowType type, size_t size) : m_type(type), m_size(size) { encache(); } + Window(WindowType type, int size) : m_type(type), m_size(size) { encache(); } Window(const Window &w) : m_type(w.m_type), m_size(w.m_size) { encache(); } Window &operator=(const Window &w) { if (&w == this) return *this; @@ -60,14 +60,14 @@ void cut(T *src) const { cut(src, src); } void cut(T *src, T *dst) const { - for (size_t i = 0; i < m_size; ++i) dst[i] = src[i] * m_cache[i]; + for (int i = 0; i < m_size; ++i) dst[i] = src[i] * m_cache[i]; } T getArea() { return m_area; } - T getValue(size_t i) { return m_cache[i]; } + T getValue(int i) { return m_cache[i]; } WindowType getType() const { return m_type; } - size_t getSize() const { return m_size; } + int getSize() const { return m_size; } // The names used by these functions are un-translated, for use in // e.g. XML I/O. Use Preferences::getPropertyValueLabel if you @@ -77,7 +77,7 @@ protected: WindowType m_type; - size_t m_size; + int m_size; T *m_cache; T m_area; @@ -88,7 +88,7 @@ template void Window::encache() { - int n = int(m_size); + const int n = m_size; T *mult = new T[n]; int i; for (i = 0; i < n; ++i) mult[i] = 1.0; @@ -164,7 +164,7 @@ template void Window::cosinewin(T *mult, T a0, T a1, T a2, T a3) { - int n = int(m_size); + const int n = m_size; for (int i = 0; i < n; ++i) { mult[i] *= (a0 - a1 * cos((2 * M_PI * i) / n) diff -r 49618f39ff09 -r 0c1d6de8f44b base/ZoomConstraint.h --- a/base/ZoomConstraint.h Tue Jun 03 11:05:49 2014 +0100 +++ b/base/ZoomConstraint.h Wed Jun 18 13:51:16 2014 +0100 @@ -48,7 +48,7 @@ * summaries at powers-of-two block sizes, return 1024 or 2048 * depending on the rounding direction supplied. */ - virtual size_t getNearestBlockSize(size_t requestedBlockSize, + virtual int getNearestBlockSize(int requestedBlockSize, RoundingDirection = RoundNearest) const { @@ -59,7 +59,7 @@ /** * Return the maximum zoom level within range for this constraint. */ - virtual size_t getMaxZoomLevel() const { return 262144; } + virtual int getMaxZoomLevel() const { return 262144; } }; #endif diff -r 49618f39ff09 -r 0c1d6de8f44b configure --- a/configure Tue Jun 03 11:05:49 2014 +0100 +++ b/configure Wed Jun 18 13:51:16 2014 +0100 @@ -4202,7 +4202,7 @@ CXXFLAGS_MINIMAL="$AUTOCONF_CXXFLAGS" if test "x$GCC" = "xyes"; then - CXXFLAGS_DEBUG="-Wall -Woverloaded-virtual -Wextra -Wformat-nonliteral -Wformat-security -Winit-self -Wswitch-enum -g -pipe" + CXXFLAGS_DEBUG="-Wall -Wextra -Werror -Woverloaded-virtual -Wformat-nonliteral -Wformat-security -Winit-self -Wswitch-enum -g -pipe" CXXFLAGS_RELEASE="-g0 -O2 -Wall -pipe" CXXFLAGS_MINIMAL="-g0 -O0" fi diff -r 49618f39ff09 -r 0c1d6de8f44b configure.ac --- a/configure.ac Tue Jun 03 11:05:49 2014 +0100 +++ b/configure.ac Wed Jun 18 13:51:16 2014 +0100 @@ -50,7 +50,7 @@ CXXFLAGS_MINIMAL="$AUTOCONF_CXXFLAGS" if test "x$GCC" = "xyes"; then - CXXFLAGS_DEBUG="-Wall -Woverloaded-virtual -Wextra -Wformat-nonliteral -Wformat-security -Winit-self -Wswitch-enum -g -pipe" + CXXFLAGS_DEBUG="-Wall -Wextra -Werror -Woverloaded-virtual -Wformat-nonliteral -Wformat-security -Winit-self -Wswitch-enum -g -pipe" CXXFLAGS_RELEASE="-g0 -O2 -Wall -pipe" CXXFLAGS_MINIMAL="-g0 -O0" fi diff -r 49618f39ff09 -r 0c1d6de8f44b data/fft/FFTCacheReader.h --- a/data/fft/FFTCacheReader.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fft/FFTCacheReader.h Wed Jun 18 13:51:16 2014 +0100 @@ -24,18 +24,18 @@ public: virtual ~FFTCacheReader() { } - virtual size_t getWidth() const = 0; - virtual size_t getHeight() const = 0; + virtual int getWidth() const = 0; + virtual int getHeight() const = 0; - virtual float getMagnitudeAt(size_t x, size_t y) const = 0; - virtual float getNormalizedMagnitudeAt(size_t x, size_t y) const = 0; - virtual float getMaximumMagnitudeAt(size_t x) const = 0; - virtual float getPhaseAt(size_t x, size_t y) const = 0; + virtual float getMagnitudeAt(int x, int y) const = 0; + virtual float getNormalizedMagnitudeAt(int x, int y) const = 0; + virtual float getMaximumMagnitudeAt(int x) const = 0; + virtual float getPhaseAt(int x, int y) const = 0; - virtual void getValuesAt(size_t x, size_t y, float &real, float &imag) const = 0; - virtual void getMagnitudesAt(size_t x, float *values, size_t minbin, size_t count, size_t step) const = 0; + virtual void getValuesAt(int x, int y, float &real, float &imag) const = 0; + virtual void getMagnitudesAt(int x, float *values, int minbin, int count, int step) const = 0; - virtual bool haveSetColumnAt(size_t x) const = 0; + virtual bool haveSetColumnAt(int x) const = 0; virtual FFTCache::StorageType getStorageType() const = 0; }; diff -r 49618f39ff09 -r 0c1d6de8f44b data/fft/FFTCacheWriter.h --- a/data/fft/FFTCacheWriter.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fft/FFTCacheWriter.h Wed Jun 18 13:51:16 2014 +0100 @@ -23,13 +23,13 @@ public: virtual ~FFTCacheWriter() { } - virtual size_t getWidth() const = 0; - virtual size_t getHeight() const = 0; + virtual int getWidth() const = 0; + virtual int getHeight() const = 0; - virtual void setColumnAt(size_t x, float *mags, float *phases, float factor) = 0; - virtual void setColumnAt(size_t x, float *reals, float *imags) = 0; + virtual void setColumnAt(int x, float *mags, float *phases, float factor) = 0; + virtual void setColumnAt(int x, float *reals, float *imags) = 0; - virtual bool haveSetColumnAt(size_t x) const = 0; + virtual bool haveSetColumnAt(int x) const = 0; virtual void allColumnsWritten() = 0; // notify cache to close diff -r 49618f39ff09 -r 0c1d6de8f44b data/fft/FFTDataServer.cpp --- a/data/fft/FFTDataServer.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fft/FFTDataServer.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -48,12 +48,12 @@ FFTDataServer::getInstance(const DenseTimeValueModel *model, int channel, WindowType windowType, - size_t windowSize, - size_t windowIncrement, - size_t fftSize, + int windowSize, + int windowIncrement, + int fftSize, bool polar, StorageAdviser::Criteria criteria, - size_t fillFromColumn) + int fillFromColumn) { QString n = generateFileBasename(model, channel, @@ -110,12 +110,12 @@ FFTDataServer::getFuzzyInstance(const DenseTimeValueModel *model, int channel, WindowType windowType, - size_t windowSize, - size_t windowIncrement, - size_t fftSize, + int windowSize, + int windowIncrement, + int fftSize, bool polar, StorageAdviser::Criteria criteria, - size_t fillFromColumn) + int fillFromColumn) { // Fuzzy matching: // @@ -483,12 +483,12 @@ const DenseTimeValueModel *model, int channel, WindowType windowType, - size_t windowSize, - size_t windowIncrement, - size_t fftSize, + int windowSize, + int windowIncrement, + int fftSize, bool polar, StorageAdviser::Criteria criteria, - size_t fillFromColumn) : + int fillFromColumn) : m_fileBaseName(fileBaseName), m_model(model), m_channel(channel), @@ -514,8 +514,8 @@ //!!! end is not correct until model finished reading -- what to do??? - size_t start = m_model->getStartFrame(); - size_t end = m_model->getEndFrame(); + int start = m_model->getStartFrame(); + int end = m_model->getEndFrame(); m_width = (end - start) / m_windowIncrement + 1; m_height = m_fftSize / 2 + 1; // DC == 0, Nyquist == fftsize/2 @@ -525,8 +525,8 @@ << m_width << "x" << m_height << endl; #endif - size_t maxCacheSize = 20 * 1024 * 1024; - size_t columnSize = m_height * sizeof(fftsample) * 2 + sizeof(fftsample); + int maxCacheSize = 20 * 1024 * 1024; + int columnSize = m_height * sizeof(fftsample) * 2 + sizeof(fftsample); if (m_width * columnSize < maxCacheSize * 2) m_cacheWidth = m_width; else m_cacheWidth = maxCacheSize / columnSize; @@ -562,7 +562,7 @@ } } - for (size_t i = 0; i <= m_width / m_cacheWidth; ++i) { + for (int i = 0; i <= m_width / m_cacheWidth; ++i) { m_caches.push_back(0); } @@ -678,7 +678,7 @@ } void -FFTDataServer::getStorageAdvice(size_t w, size_t h, +FFTDataServer::getStorageAdvice(int w, int h, bool &memoryCache, bool &compactCache) { int cells = w * h; @@ -763,7 +763,7 @@ QString name = QString("%1-%2").arg(m_fileBaseName).arg(c); - size_t width = m_cacheWidth; + int width = m_cacheWidth; if (c * m_cacheWidth + width > m_width) { width = m_width - c * m_cacheWidth; } @@ -885,7 +885,7 @@ } float -FFTDataServer::getMagnitudeAt(size_t x, size_t y) +FFTDataServer::getMagnitudeAt(int x, int y) { Profiler profiler("FFTDataServer::getMagnitudeAt", false); @@ -894,7 +894,7 @@ float val = 0; try { - size_t col; + int col; FFTCacheReader *cache = getCacheReader(x, col); if (!cache) return 0; @@ -917,7 +917,7 @@ } bool -FFTDataServer::getMagnitudesAt(size_t x, float *values, size_t minbin, size_t count, size_t step) +FFTDataServer::getMagnitudesAt(int x, float *values, int minbin, int count, int step) { Profiler profiler("FFTDataServer::getMagnitudesAt", false); @@ -930,7 +930,7 @@ } try { - size_t col; + int col; FFTCacheReader *cache = getCacheReader(x, col); if (!cache) return false; @@ -950,7 +950,7 @@ } float -FFTDataServer::getNormalizedMagnitudeAt(size_t x, size_t y) +FFTDataServer::getNormalizedMagnitudeAt(int x, int y) { Profiler profiler("FFTDataServer::getNormalizedMagnitudeAt", false); @@ -960,7 +960,7 @@ try { - size_t col; + int col; FFTCacheReader *cache = getCacheReader(x, col); if (!cache) return 0; @@ -978,7 +978,7 @@ } bool -FFTDataServer::getNormalizedMagnitudesAt(size_t x, float *values, size_t minbin, size_t count, size_t step) +FFTDataServer::getNormalizedMagnitudesAt(int x, float *values, int minbin, int count, int step) { Profiler profiler("FFTDataServer::getNormalizedMagnitudesAt", false); @@ -992,7 +992,7 @@ try { - size_t col; + int col; FFTCacheReader *cache = getCacheReader(x, col); if (!cache) return false; @@ -1001,7 +1001,7 @@ fillColumn(x); } - for (size_t i = 0; i < count; ++i) { + for (int i = 0; i < count; ++i) { values[i] = cache->getNormalizedMagnitudeAt(col, i * step + minbin); } @@ -1014,7 +1014,7 @@ } float -FFTDataServer::getMaximumMagnitudeAt(size_t x) +FFTDataServer::getMaximumMagnitudeAt(int x) { Profiler profiler("FFTDataServer::getMaximumMagnitudeAt", false); @@ -1024,7 +1024,7 @@ try { - size_t col; + int col; FFTCacheReader *cache = getCacheReader(x, col); if (!cache) return 0; @@ -1042,7 +1042,7 @@ } float -FFTDataServer::getPhaseAt(size_t x, size_t y) +FFTDataServer::getPhaseAt(int x, int y) { Profiler profiler("FFTDataServer::getPhaseAt", false); @@ -1052,7 +1052,7 @@ try { - size_t col; + int col; FFTCacheReader *cache = getCacheReader(x, col); if (!cache) return 0; @@ -1070,7 +1070,7 @@ } bool -FFTDataServer::getPhasesAt(size_t x, float *values, size_t minbin, size_t count, size_t step) +FFTDataServer::getPhasesAt(int x, float *values, int minbin, int count, int step) { Profiler profiler("FFTDataServer::getPhasesAt", false); @@ -1084,7 +1084,7 @@ try { - size_t col; + int col; FFTCacheReader *cache = getCacheReader(x, col); if (!cache) return false; @@ -1093,7 +1093,7 @@ fillColumn(x); } - for (size_t i = 0; i < count; ++i) { + for (int i = 0; i < count; ++i) { values[i] = cache->getPhaseAt(col, i * step + minbin); } @@ -1106,7 +1106,7 @@ } void -FFTDataServer::getValuesAt(size_t x, size_t y, float &real, float &imaginary) +FFTDataServer::getValuesAt(int x, int y, float &real, float &imaginary) { Profiler profiler("FFTDataServer::getValuesAt", false); @@ -1118,7 +1118,7 @@ try { - size_t col; + int col; FFTCacheReader *cache = getCacheReader(x, col); if (!cache) { @@ -1143,7 +1143,7 @@ } bool -FFTDataServer::getValuesAt(size_t x, float *reals, float *imaginaries, size_t minbin, size_t count, size_t step) +FFTDataServer::getValuesAt(int x, float *reals, float *imaginaries, int minbin, int count, int step) { Profiler profiler("FFTDataServer::getValuesAt", false); @@ -1157,7 +1157,7 @@ try { - size_t col; + int col; FFTCacheReader *cache = getCacheReader(x, col); if (!cache) return false; @@ -1166,7 +1166,7 @@ fillColumn(x); } - for (size_t i = 0; i < count; ++i) { + for (int i = 0; i < count; ++i) { cache->getValuesAt(col, i * step + minbin, reals[i], imaginaries[i]); } @@ -1179,7 +1179,7 @@ } bool -FFTDataServer::isColumnReady(size_t x) +FFTDataServer::isColumnReady(int x) { Profiler profiler("FFTDataServer::isColumnReady", false); @@ -1200,7 +1200,7 @@ try { - size_t col; + int col; FFTCacheReader *cache = getCacheReader(x, col); if (!cache) return true; @@ -1213,7 +1213,7 @@ } void -FFTDataServer::fillColumn(size_t x) +FFTDataServer::fillColumn(int x) { Profiler profiler("FFTDataServer::fillColumn", false); @@ -1237,7 +1237,7 @@ return; } - size_t col; + int col; #ifdef DEBUG_FFT_SERVER_FILL cout << "FFTDataServer::fillColumn(" << x << ")" << endl; #endif @@ -1397,14 +1397,14 @@ else return ""; } -size_t +int FFTDataServer::getFillCompletion() const { if (m_fillThread) return m_fillThread->getCompletion(); else return 100; } -size_t +int FFTDataServer::getFillExtent() const { if (m_fillThread) return m_fillThread->getExtent(); @@ -1423,9 +1423,9 @@ FFTDataServer::generateFileBasename(const DenseTimeValueModel *model, int channel, WindowType windowType, - size_t windowSize, - size_t windowIncrement, - size_t fftSize, + int windowSize, + int windowIncrement, + int fftSize, bool polar) { char buffer[200]; @@ -1460,9 +1460,9 @@ } if (m_server.m_exiting) return; - size_t start = m_server.m_model->getStartFrame(); - size_t end = m_server.m_model->getEndFrame(); - size_t remainingEnd = end; + int start = m_server.m_model->getStartFrame(); + int end = m_server.m_model->getEndFrame(); + int remainingEnd = end; int counter = 0; int updateAt = 1; @@ -1471,7 +1471,7 @@ if (m_fillFrom > start) { - for (size_t f = m_fillFrom; f < end; f += m_server.m_windowIncrement) { + for (int f = m_fillFrom; f < end; f += m_server.m_windowIncrement) { try { m_server.fillColumn(int((f - start) / m_server.m_windowIncrement)); @@ -1503,7 +1503,7 @@ if (++counter == updateAt) { m_extent = f; - m_completion = size_t(100 * fabsf(float(f - m_fillFrom) / + m_completion = int(100 * fabsf(float(f - m_fillFrom) / float(end - start))); counter = 0; if (updateAt < maxUpdateAt) { @@ -1518,9 +1518,9 @@ else remainingEnd = start; } - size_t baseCompletion = m_completion; + int baseCompletion = m_completion; - for (size_t f = start; f < remainingEnd; f += m_server.m_windowIncrement) { + for (int f = start; f < remainingEnd; f += m_server.m_windowIncrement) { try { m_server.fillColumn(int((f - start) / m_server.m_windowIncrement)); @@ -1552,7 +1552,7 @@ if (++counter == updateAt) { m_extent = f; m_completion = baseCompletion + - size_t(100 * fabsf(float(f - start) / + int(100 * fabsf(float(f - start) / float(end - start))); counter = 0; if (updateAt < maxUpdateAt) { diff -r 49618f39ff09 -r 0c1d6de8f44b data/fft/FFTDataServer.h --- a/data/fft/FFTDataServer.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fft/FFTDataServer.h Wed Jun 18 13:51:16 2014 +0100 @@ -43,24 +43,24 @@ static FFTDataServer *getInstance(const DenseTimeValueModel *model, int channel, WindowType windowType, - size_t windowSize, - size_t windowIncrement, - size_t fftSize, + int windowSize, + int windowIncrement, + int fftSize, bool polar, StorageAdviser::Criteria criteria = StorageAdviser::NoCriteria, - size_t fillFromColumn = 0); + int fillFromColumn = 0); static FFTDataServer *getFuzzyInstance(const DenseTimeValueModel *model, int channel, WindowType windowType, - size_t windowSize, - size_t windowIncrement, - size_t fftSize, + int windowSize, + int windowIncrement, + int fftSize, bool polar, StorageAdviser::Criteria criteria = StorageAdviser::NoCriteria, - size_t fillFromColumn = 0); + int fillFromColumn = 0); static void claimInstance(FFTDataServer *); static void releaseInstance(FFTDataServer *); @@ -70,25 +70,25 @@ const DenseTimeValueModel *getModel() const { return m_model; } int getChannel() const { return m_channel; } WindowType getWindowType() const { return m_windower.getType(); } - size_t getWindowSize() const { return m_windowSize; } - size_t getWindowIncrement() const { return m_windowIncrement; } - size_t getFFTSize() const { return m_fftSize; } + int getWindowSize() const { return m_windowSize; } + int getWindowIncrement() const { return m_windowIncrement; } + int getFFTSize() const { return m_fftSize; } bool getPolar() const { return m_polar; } - size_t getWidth() const { return m_width; } - size_t getHeight() const { return m_height; } + int getWidth() const { return m_width; } + int getHeight() const { return m_height; } - float getMagnitudeAt(size_t x, size_t y); - float getNormalizedMagnitudeAt(size_t x, size_t y); - float getMaximumMagnitudeAt(size_t x); - float getPhaseAt(size_t x, size_t y); - void getValuesAt(size_t x, size_t y, float &real, float &imaginary); - bool isColumnReady(size_t x); + float getMagnitudeAt(int x, int y); + float getNormalizedMagnitudeAt(int x, int y); + float getMaximumMagnitudeAt(int x); + float getPhaseAt(int x, int y); + void getValuesAt(int x, int y, float &real, float &imaginary); + bool isColumnReady(int x); - bool getMagnitudesAt(size_t x, float *values, size_t minbin = 0, size_t count = 0, size_t step = 1); - bool getNormalizedMagnitudesAt(size_t x, float *values, size_t minbin = 0, size_t count = 0, size_t step = 1); - bool getPhasesAt(size_t x, float *values, size_t minbin = 0, size_t count = 0, size_t step = 1); - bool getValuesAt(size_t x, float *reals, float *imaginaries, size_t minbin = 0, size_t count = 0, size_t step = 1); + bool getMagnitudesAt(int x, float *values, int minbin = 0, int count = 0, int step = 1); + bool getNormalizedMagnitudesAt(int x, float *values, int minbin = 0, int count = 0, int step = 1); + bool getPhasesAt(int x, float *values, int minbin = 0, int count = 0, int step = 1); + bool getValuesAt(int x, float *reals, float *imaginaries, int minbin = 0, int count = 0, int step = 1); void suspend(); void suspendWrites(); @@ -96,31 +96,31 @@ // Convenience functions: - bool isLocalPeak(size_t x, size_t y) { + bool isLocalPeak(int x, int y) { float mag = getMagnitudeAt(x, y); if (y > 0 && mag < getMagnitudeAt(x, y - 1)) return false; if (y < getHeight()-1 && mag < getMagnitudeAt(x, y + 1)) return false; return true; } - bool isOverThreshold(size_t x, size_t y, float threshold) { + bool isOverThreshold(int x, int y, float threshold) { return getMagnitudeAt(x, y) > threshold; } QString getError() const; - size_t getFillCompletion() const; - size_t getFillExtent() const; + int getFillCompletion() const; + int getFillExtent() const; private: FFTDataServer(QString fileBaseName, const DenseTimeValueModel *model, int channel, WindowType windowType, - size_t windowSize, - size_t windowIncrement, - size_t fftSize, + int windowSize, + int windowIncrement, + int fftSize, bool polar, StorageAdviser::Criteria criteria, - size_t fillFromColumn = 0); + int fillFromColumn = 0); virtual ~FFTDataServer(); @@ -135,16 +135,16 @@ Window m_windower; - size_t m_windowSize; - size_t m_windowIncrement; - size_t m_fftSize; + int m_windowSize; + int m_windowIncrement; + int m_fftSize; bool m_polar; - size_t m_width; - size_t m_height; - size_t m_cacheWidth; - size_t m_cacheWidthPower; - size_t m_cacheWidthMask; + int m_width; + int m_height; + int m_cacheWidth; + int m_cacheWidthPower; + int m_cacheWidthMask; struct CacheBlock { FFTMemoryCache *memoryCache; @@ -167,7 +167,7 @@ QReadWriteLock m_cacheVectorLock; // locks cache lookup, not use QMutex m_cacheCreationMutex; // solely to serialise makeCache() calls - FFTCacheReader *getCacheReader(size_t x, size_t &col) { + FFTCacheReader *getCacheReader(int x, int &col) { Profiler profiler("FFTDataServer::getCacheReader"); col = x & m_cacheWidthMask; int c = x >> m_cacheWidthPower; @@ -200,7 +200,7 @@ return getCacheReader(x, col); } - FFTCacheWriter *getCacheWriter(size_t x, size_t &col) { + FFTCacheWriter *getCacheWriter(int x, int &col) { Profiler profiler("FFTDataServer::getCacheWriter"); col = x & m_cacheWidthMask; int c = x >> m_cacheWidthPower; @@ -218,7 +218,7 @@ return getCacheWriter(x, col); } - bool haveCache(size_t x) { + bool haveCache(int x) { int c = x >> m_cacheWidthPower; return (m_caches.at(c) != 0); } @@ -228,7 +228,7 @@ StorageAdviser::Criteria m_criteria; - void getStorageAdvice(size_t w, size_t h, bool &memory, bool &compact); + void getStorageAdvice(int w, int h, bool &memory, bool &compact); QMutex m_fftBuffersLock; QWaitCondition m_condition; @@ -241,20 +241,20 @@ class FillThread : public Thread { public: - FillThread(FFTDataServer &server, size_t fillFromColumn) : + FillThread(FFTDataServer &server, int fillFromColumn) : m_server(server), m_extent(0), m_completion(0), m_fillFrom(fillFromColumn) { } - size_t getExtent() const { return m_extent; } - size_t getCompletion() const { return m_completion ? m_completion : 1; } + int getExtent() const { return m_extent; } + int getCompletion() const { return m_completion ? m_completion : 1; } QString getError() const { return m_error; } virtual void run(); protected: FFTDataServer &m_server; - size_t m_extent; - size_t m_completion; - size_t m_fillFrom; + int m_extent; + int m_completion; + int m_fillFrom; QString m_error; }; @@ -264,16 +264,16 @@ QString m_error; void deleteProcessingData(); - void fillColumn(size_t x); + void fillColumn(int x); void fillComplete(); QString generateFileBasename() const; static QString generateFileBasename(const DenseTimeValueModel *model, int channel, WindowType windowType, - size_t windowSize, - size_t windowIncrement, - size_t fftSize, + int windowSize, + int windowIncrement, + int fftSize, bool polar); typedef std::pair ServerCountPair; diff -r 49618f39ff09 -r 0c1d6de8f44b data/fft/FFTFileCacheReader.cpp --- a/data/fft/FFTFileCacheReader.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fft/FFTFileCacheReader.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -53,22 +53,22 @@ delete m_mfc; } -size_t +int FFTFileCacheReader::getWidth() const { return m_mfc->getWidth(); } -size_t +int FFTFileCacheReader::getHeight() const { - size_t mh = m_mfc->getHeight(); + int mh = m_mfc->getHeight(); if (mh > m_factorSize) return (mh - m_factorSize) / 2; else return 0; } float -FFTFileCacheReader::getMagnitudeAt(size_t x, size_t y) const +FFTFileCacheReader::getMagnitudeAt(int x, int y) const { Profiler profiler("FFTFileCacheReader::getMagnitudeAt", false); @@ -98,7 +98,7 @@ } float -FFTFileCacheReader::getNormalizedMagnitudeAt(size_t x, size_t y) const +FFTFileCacheReader::getNormalizedMagnitudeAt(int x, int y) const { float value = 0.f; @@ -108,7 +108,8 @@ value = getFromReadBufCompactUnsigned(x, y * 2) / 65535.0; break; - default: + case FFTCache::Rectangular: + case FFTCache::Polar: { float mag = getMagnitudeAt(x, y); float factor = getNormalizationFactor(x); @@ -122,13 +123,13 @@ } float -FFTFileCacheReader::getMaximumMagnitudeAt(size_t x) const +FFTFileCacheReader::getMaximumMagnitudeAt(int x) const { return getNormalizationFactor(x); } float -FFTFileCacheReader::getPhaseAt(size_t x, size_t y) const +FFTFileCacheReader::getPhaseAt(int x, int y) const { float value = 0.f; @@ -155,7 +156,7 @@ } void -FFTFileCacheReader::getValuesAt(size_t x, size_t y, float &real, float &imag) const +FFTFileCacheReader::getValuesAt(int x, int y, float &real, float &imag) const { // SVDEBUG << "FFTFileCacheReader::getValuesAt(" << x << "," << y << ")" << endl; @@ -166,7 +167,8 @@ imag = getFromReadBufStandard(x, y * 2 + 1); return; - default: + case FFTCache::Compact: + case FFTCache::Polar: float mag = getMagnitudeAt(x, y); float phase = getPhaseAt(x, y); real = mag * cosf(phase); @@ -176,15 +178,15 @@ } void -FFTFileCacheReader::getMagnitudesAt(size_t x, float *values, size_t minbin, size_t count, size_t step) const +FFTFileCacheReader::getMagnitudesAt(int x, float *values, int minbin, int count, int step) const { Profiler profiler("FFTFileCacheReader::getMagnitudesAt"); switch (m_storageType) { case FFTCache::Compact: - for (size_t i = 0; i < count; ++i) { - size_t y = minbin + i * step; + for (int i = 0; i < count; ++i) { + int y = minbin + i * step; values[i] = (getFromReadBufCompactUnsigned(x, y * 2) / 65535.0) * getNormalizationFactor(x); } @@ -193,8 +195,8 @@ case FFTCache::Rectangular: { float real, imag; - for (size_t i = 0; i < count; ++i) { - size_t y = minbin + i * step; + for (int i = 0; i < count; ++i) { + int y = minbin + i * step; real = getFromReadBufStandard(x, y * 2); imag = getFromReadBufStandard(x, y * 2 + 1); values[i] = sqrtf(real * real + imag * imag); @@ -203,8 +205,8 @@ } case FFTCache::Polar: - for (size_t i = 0; i < count; ++i) { - size_t y = minbin + i * step; + for (int i = 0; i < count; ++i) { + int y = minbin + i * step; values[i] = getFromReadBufStandard(x, y * 2); } break; @@ -212,7 +214,7 @@ } bool -FFTFileCacheReader::haveSetColumnAt(size_t x) const +FFTFileCacheReader::haveSetColumnAt(int x) const { if (m_readbuf && m_readbufGood && (m_readbufCol == x || (m_readbufWidth > 1 && m_readbufCol+1 == x))) { @@ -222,17 +224,17 @@ return m_mfc->haveSetColumnAt(x); } -size_t -FFTFileCacheReader::getCacheSize(size_t width, size_t height, +int +FFTFileCacheReader::getCacheSize(int width, int height, FFTCache::StorageType type) { return (height * 2 + (type == FFTCache::Compact ? 2 : 1)) * width * (type == FFTCache::Compact ? sizeof(uint16_t) : sizeof(float)) + - 2 * sizeof(size_t); // matrix file header size + 2 * sizeof(int); // matrix file header size } void -FFTFileCacheReader::populateReadBuf(size_t x) const +FFTFileCacheReader::populateReadBuf(int x) const { Profiler profiler("FFTFileCacheReader::populateReadBuf", false); diff -r 49618f39ff09 -r 0c1d6de8f44b data/fft/FFTFileCacheReader.h --- a/data/fft/FFTFileCacheReader.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fft/FFTFileCacheReader.h Wed Jun 18 13:51:16 2014 +0100 @@ -28,31 +28,31 @@ FFTFileCacheReader(FFTFileCacheWriter *); ~FFTFileCacheReader(); - size_t getWidth() const; - size_t getHeight() const; + int getWidth() const; + int getHeight() const; - float getMagnitudeAt(size_t x, size_t y) const; - float getNormalizedMagnitudeAt(size_t x, size_t y) const; - float getMaximumMagnitudeAt(size_t x) const; - float getPhaseAt(size_t x, size_t y) const; + float getMagnitudeAt(int x, int y) const; + float getNormalizedMagnitudeAt(int x, int y) const; + float getMaximumMagnitudeAt(int x) const; + float getPhaseAt(int x, int y) const; - void getValuesAt(size_t x, size_t y, float &real, float &imag) const; - void getMagnitudesAt(size_t x, float *values, size_t minbin, size_t count, size_t step) const; + void getValuesAt(int x, int y, float &real, float &imag) const; + void getMagnitudesAt(int x, float *values, int minbin, int count, int step) const; - bool haveSetColumnAt(size_t x) const; + bool haveSetColumnAt(int x) const; - static size_t getCacheSize(size_t width, size_t height, + static int getCacheSize(int width, int height, FFTCache::StorageType type); FFTCache::StorageType getStorageType() const { return m_storageType; } protected: mutable char *m_readbuf; - mutable size_t m_readbufCol; - mutable size_t m_readbufWidth; + mutable int m_readbufCol; + mutable int m_readbufWidth; mutable bool m_readbufGood; - float getFromReadBufStandard(size_t x, size_t y) const { + float getFromReadBufStandard(int x, int y) const { float v; if (m_readbuf && (m_readbufCol == x || (m_readbufWidth > 1 && m_readbufCol+1 == x))) { @@ -65,7 +65,7 @@ } } - float getFromReadBufCompactUnsigned(size_t x, size_t y) const { + float getFromReadBufCompactUnsigned(int x, int y) const { float v; if (m_readbuf && (m_readbufCol == x || (m_readbufWidth > 1 && m_readbufCol+1 == x))) { @@ -78,7 +78,7 @@ } } - float getFromReadBufCompactSigned(size_t x, size_t y) const { + float getFromReadBufCompactSigned(int x, int y) const { float v; if (m_readbuf && (m_readbufCol == x || (m_readbufWidth > 1 && m_readbufCol+1 == x))) { @@ -91,10 +91,10 @@ } } - void populateReadBuf(size_t x) const; + void populateReadBuf(int x) const; - float getNormalizationFactor(size_t col) const { - size_t h = m_mfc->getHeight(); + float getNormalizationFactor(int col) const { + int h = m_mfc->getHeight(); if (h < m_factorSize) return 0; if (m_storageType != FFTCache::Compact) { return getFromReadBufStandard(col, h - 1); @@ -108,7 +108,7 @@ (m_readbufWidth > 1 && m_readbufCol+1 == col))) { populateReadBuf(col); } - size_t ix = (col - m_readbufCol) * m_mfc->getHeight() + h; + int ix = (col - m_readbufCol) * m_mfc->getHeight() + h; factor.u[0] = ((uint16_t *)m_readbuf)[ix - 2]; factor.u[1] = ((uint16_t *)m_readbuf)[ix - 1]; return factor.f; @@ -116,7 +116,7 @@ } FFTCache::StorageType m_storageType; - size_t m_factorSize; + int m_factorSize; MatrixFile *m_mfc; }; diff -r 49618f39ff09 -r 0c1d6de8f44b data/fft/FFTFileCacheWriter.cpp --- a/data/fft/FFTFileCacheWriter.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fft/FFTFileCacheWriter.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -33,7 +33,7 @@ FFTFileCacheWriter::FFTFileCacheWriter(QString fileBase, FFTCache::StorageType storageType, - size_t width, size_t height) : + int width, int height) : m_writebuf(0), m_fileBase(fileBase), m_storageType(storageType), @@ -62,49 +62,49 @@ return m_fileBase; } -size_t +int FFTFileCacheWriter::getWidth() const { return m_mfc->getWidth(); } -size_t +int FFTFileCacheWriter::getHeight() const { - size_t mh = m_mfc->getHeight(); + int mh = m_mfc->getHeight(); if (mh > m_factorSize) return (mh - m_factorSize) / 2; else return 0; } bool -FFTFileCacheWriter::haveSetColumnAt(size_t x) const +FFTFileCacheWriter::haveSetColumnAt(int x) const { return m_mfc->haveSetColumnAt(x); } void -FFTFileCacheWriter::setColumnAt(size_t x, float *mags, float *phases, float factor) +FFTFileCacheWriter::setColumnAt(int x, float *mags, float *phases, float factor) { - size_t h = getHeight(); + int h = getHeight(); switch (m_storageType) { case FFTCache::Compact: - for (size_t y = 0; y < h; ++y) { + for (int y = 0; y < h; ++y) { ((uint16_t *)m_writebuf)[y * 2] = uint16_t((mags[y] / factor) * 65535.0); ((uint16_t *)m_writebuf)[y * 2 + 1] = uint16_t(int16_t((phases[y] * 32767) / M_PI)); } break; case FFTCache::Rectangular: - for (size_t y = 0; y < h; ++y) { + for (int y = 0; y < h; ++y) { ((float *)m_writebuf)[y * 2] = mags[y] * cosf(phases[y]); ((float *)m_writebuf)[y * 2 + 1] = mags[y] * sinf(phases[y]); } break; case FFTCache::Polar: - for (size_t y = 0; y < h; ++y) { + for (int y = 0; y < h; ++y) { ((float *)m_writebuf)[y * 2] = mags[y]; ((float *)m_writebuf)[y * 2 + 1] = phases[y]; } @@ -123,20 +123,20 @@ } void -FFTFileCacheWriter::setColumnAt(size_t x, float *real, float *imag) +FFTFileCacheWriter::setColumnAt(int x, float *real, float *imag) { - size_t h = getHeight(); + int h = getHeight(); float factor = 0.0f; switch (m_storageType) { case FFTCache::Compact: - for (size_t y = 0; y < h; ++y) { + for (int y = 0; y < h; ++y) { float mag = sqrtf(real[y] * real[y] + imag[y] * imag[y]); if (mag > factor) factor = mag; } - for (size_t y = 0; y < h; ++y) { + for (int y = 0; y < h; ++y) { float mag = sqrtf(real[y] * real[y] + imag[y] * imag[y]); float phase = atan2f(imag[y], real[y]); ((uint16_t *)m_writebuf)[y * 2] = uint16_t((mag / factor) * 65535.0); @@ -145,7 +145,7 @@ break; case FFTCache::Rectangular: - for (size_t y = 0; y < h; ++y) { + for (int y = 0; y < h; ++y) { ((float *)m_writebuf)[y * 2] = real[y]; ((float *)m_writebuf)[y * 2 + 1] = imag[y]; float mag = sqrtf(real[y] * real[y] + imag[y] * imag[y]); @@ -154,7 +154,7 @@ break; case FFTCache::Polar: - for (size_t y = 0; y < h; ++y) { + for (int y = 0; y < h; ++y) { float mag = sqrtf(real[y] * real[y] + imag[y] * imag[y]); if (mag > factor) factor = mag; ((float *)m_writebuf)[y * 2] = mag; @@ -175,13 +175,13 @@ m_mfc->setColumnAt(x, m_writebuf); } -size_t -FFTFileCacheWriter::getCacheSize(size_t width, size_t height, +int +FFTFileCacheWriter::getCacheSize(int width, int height, FFTCache::StorageType type) { return (height * 2 + (type == FFTCache::Compact ? 2 : 1)) * width * (type == FFTCache::Compact ? sizeof(uint16_t) : sizeof(float)) + - 2 * sizeof(size_t); // matrix file header size + 2 * sizeof(int); // matrix file header size } void diff -r 49618f39ff09 -r 0c1d6de8f44b data/fft/FFTFileCacheWriter.h --- a/data/fft/FFTFileCacheWriter.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fft/FFTFileCacheWriter.h Wed Jun 18 13:51:16 2014 +0100 @@ -25,19 +25,19 @@ public: FFTFileCacheWriter(QString fileBase, FFTCache::StorageType storageType, - size_t width, size_t height); + int width, int height); ~FFTFileCacheWriter(); - size_t getWidth() const; - size_t getHeight() const; + int getWidth() const; + int getHeight() const; - void setColumnAt(size_t x, float *mags, float *phases, float factor); - void setColumnAt(size_t x, float *reals, float *imags); + void setColumnAt(int x, float *mags, float *phases, float factor); + void setColumnAt(int x, float *reals, float *imags); - static size_t getCacheSize(size_t width, size_t height, + static int getCacheSize(int width, int height, FFTCache::StorageType type); - bool haveSetColumnAt(size_t x) const; + bool haveSetColumnAt(int x) const; void allColumnsWritten(); @@ -48,7 +48,7 @@ char *m_writebuf; void setNormalizationFactorToWritebuf(float newfactor) { - size_t h = m_mfc->getHeight(); + int h = m_mfc->getHeight(); if (h < m_factorSize) return; if (m_storageType != FFTCache::Compact) { ((float *)m_writebuf)[h - 1] = newfactor; @@ -65,7 +65,7 @@ QString m_fileBase; FFTCache::StorageType m_storageType; - size_t m_factorSize; + int m_factorSize; MatrixFile *m_mfc; }; diff -r 49618f39ff09 -r 0c1d6de8f44b data/fft/FFTMemoryCache.cpp --- a/data/fft/FFTMemoryCache.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fft/FFTMemoryCache.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -22,7 +22,7 @@ //#define DEBUG_FFT_MEMORY_CACHE 1 FFTMemoryCache::FFTMemoryCache(FFTCache::StorageType storageType, - size_t width, size_t height) : + int width, int height) : m_width(width), m_height(height), m_magnitude(0), @@ -48,7 +48,7 @@ cerr << "FFTMemoryCache[" << this << "]::~FFTMemoryCache" << endl; #endif - for (size_t i = 0; i < m_width; ++i) { + for (int i = 0; i < m_width; ++i) { if (m_magnitude && m_magnitude[i]) free(m_magnitude[i]); if (m_phase && m_phase[i]) free(m_phase[i]); if (m_fmagnitude && m_fmagnitude[i]) free(m_fmagnitude[i]); @@ -71,7 +71,7 @@ { Profiler profiler("FFTMemoryCache::initialise"); - size_t width = m_width, height = m_height; + int width = m_width, height = m_height; #ifdef DEBUG_FFT_MEMORY_CACHE cerr << "FFTMemoryCache[" << this << "]::initialise(" << width << "x" << height << " = " << width*height << ")" << endl; @@ -107,7 +107,7 @@ if (!array) throw std::bad_alloc(); MUNLOCK(array, m_width * sizeof(uint16_t *)); - for (size_t i = 0; i < m_width; ++i) { + for (int i = 0; i < m_width; ++i) { array[i] = (uint16_t *)malloc(m_height * sizeof(uint16_t)); if (!array[i]) throw std::bad_alloc(); MUNLOCK(array[i], m_height * sizeof(uint16_t)); @@ -121,7 +121,7 @@ if (!array) throw std::bad_alloc(); MUNLOCK(array, m_width * sizeof(float *)); - for (size_t i = 0; i < m_width; ++i) { + for (int i = 0; i < m_width; ++i) { array[i] = (float *)malloc(m_height * sizeof(float)); if (!array[i]) throw std::bad_alloc(); MUNLOCK(array[i], m_height * sizeof(float)); @@ -129,7 +129,7 @@ } void -FFTMemoryCache::setColumnAt(size_t x, float *mags, float *phases, float factor) +FFTMemoryCache::setColumnAt(int x, float *mags, float *phases, float factor) { Profiler profiler("FFTMemoryCache::setColumnAt: from polar"); @@ -137,12 +137,12 @@ if (m_storageType == FFTCache::Rectangular) { Profiler subprof("FFTMemoryCache::setColumnAt: polar to cart"); - for (size_t y = 0; y < m_height; ++y) { + for (int y = 0; y < m_height; ++y) { m_freal[x][y] = mags[y] * cosf(phases[y]); m_fimag[x][y] = mags[y] * sinf(phases[y]); } } else { - for (size_t y = 0; y < m_height; ++y) { + for (int y = 0; y < m_height; ++y) { setMagnitudeAt(x, y, mags[y]); setPhaseAt(x, y, phases[y]); } @@ -154,7 +154,7 @@ } void -FFTMemoryCache::setColumnAt(size_t x, float *reals, float *imags) +FFTMemoryCache::setColumnAt(int x, float *reals, float *imags) { Profiler profiler("FFTMemoryCache::setColumnAt: from cart"); @@ -163,7 +163,7 @@ switch (m_storageType) { case FFTCache::Rectangular: - for (size_t y = 0; y < m_height; ++y) { + for (int y = 0; y < m_height; ++y) { m_freal[x][y] = reals[y]; m_fimag[x][y] = imags[y]; float mag = sqrtf(reals[y] * reals[y] + imags[y] * imags[y]); @@ -175,7 +175,7 @@ case FFTCache::Polar: { Profiler subprof("FFTMemoryCache::setColumnAt: cart to polar"); - for (size_t y = 0; y < m_height; ++y) { + for (int y = 0; y < m_height; ++y) { float mag = sqrtf(reals[y] * reals[y] + imags[y] * imags[y]); float phase = atan2f(imags[y], reals[y]); reals[y] = mag; @@ -196,10 +196,10 @@ } } -size_t -FFTMemoryCache::getCacheSize(size_t width, size_t height, FFTCache::StorageType type) +int +FFTMemoryCache::getCacheSize(int width, int height, FFTCache::StorageType type) { - size_t sz = 0; + int sz = 0; switch (type) { diff -r 49618f39ff09 -r 0c1d6de8f44b data/fft/FFTMemoryCache.h --- a/data/fft/FFTMemoryCache.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fft/FFTMemoryCache.h Wed Jun 18 13:51:16 2014 +0100 @@ -47,13 +47,13 @@ { public: FFTMemoryCache(FFTCache::StorageType storageType, - size_t width, size_t height); + int width, int height); ~FFTMemoryCache(); - size_t getWidth() const { return m_width; } - size_t getHeight() const { return m_height; } + int getWidth() const { return m_width; } + int getHeight() const { return m_height; } - float getMagnitudeAt(size_t x, size_t y) const { + float getMagnitudeAt(int x, int y) const { if (m_storageType == FFTCache::Rectangular) { Profiler profiler("FFTMemoryCache::getMagnitudeAt: cart to polar"); return sqrtf(m_freal[x][y] * m_freal[x][y] + @@ -63,17 +63,17 @@ } } - float getNormalizedMagnitudeAt(size_t x, size_t y) const { + float getNormalizedMagnitudeAt(int x, int y) const { if (m_storageType == FFTCache::Rectangular) return getMagnitudeAt(x, y) / m_factor[x]; else if (m_storageType == FFTCache::Polar) return m_fmagnitude[x][y]; else return float(m_magnitude[x][y]) / 65535.0; } - float getMaximumMagnitudeAt(size_t x) const { + float getMaximumMagnitudeAt(int x) const { return m_factor[x]; } - float getPhaseAt(size_t x, size_t y) const { + float getPhaseAt(int x, int y) const { if (m_storageType == FFTCache::Rectangular) { Profiler profiler("FFTMemoryCache::getValuesAt: cart to polar"); return atan2f(m_fimag[x][y], m_freal[x][y]); @@ -85,7 +85,7 @@ } } - void getValuesAt(size_t x, size_t y, float &real, float &imag) const { + void getValuesAt(int x, int y, float &real, float &imag) const { if (m_storageType == FFTCache::Rectangular) { real = m_freal[x][y]; imag = m_fimag[x][y]; @@ -98,48 +98,48 @@ } } - void getMagnitudesAt(size_t x, float *values, size_t minbin, size_t count, size_t step) const + void getMagnitudesAt(int x, float *values, int minbin, int count, int step) const { if (m_storageType == FFTCache::Rectangular) { - for (size_t i = 0; i < count; ++i) { - size_t y = i * step + minbin; + for (int i = 0; i < count; ++i) { + int y = i * step + minbin; values[i] = sqrtf(m_freal[x][y] * m_freal[x][y] + m_fimag[x][y] * m_fimag[x][y]); } } else if (m_storageType == FFTCache::Polar) { - for (size_t i = 0; i < count; ++i) { - size_t y = i * step + minbin; + for (int i = 0; i < count; ++i) { + int y = i * step + minbin; values[i] = m_fmagnitude[x][y] * m_factor[x]; } } else { - for (size_t i = 0; i < count; ++i) { - size_t y = i * step + minbin; + for (int i = 0; i < count; ++i) { + int y = i * step + minbin; values[i] = (float(m_magnitude[x][y]) * m_factor[x]) / 65535.0; } } } - bool haveSetColumnAt(size_t x) const { + bool haveSetColumnAt(int x) const { m_colsetLock.lockForRead(); bool have = m_colset.get(x); m_colsetLock.unlock(); return have; } - void setColumnAt(size_t x, float *mags, float *phases, float factor); + void setColumnAt(int x, float *mags, float *phases, float factor); - void setColumnAt(size_t x, float *reals, float *imags); + void setColumnAt(int x, float *reals, float *imags); void allColumnsWritten() { } - static size_t getCacheSize(size_t width, size_t height, + static int getCacheSize(int width, int height, FFTCache::StorageType type); FFTCache::StorageType getStorageType() const { return m_storageType; } private: - size_t m_width; - size_t m_height; + int m_width; + int m_height; uint16_t **m_magnitude; uint16_t **m_phase; float **m_fmagnitude; @@ -153,23 +153,23 @@ void initialise(); - void setNormalizationFactor(size_t x, float factor) { + void setNormalizationFactor(int x, float factor) { if (x < m_width) m_factor[x] = factor; } - void setMagnitudeAt(size_t x, size_t y, float mag) { + void setMagnitudeAt(int x, int y, float mag) { // norm factor must already be set setNormalizedMagnitudeAt(x, y, mag / m_factor[x]); } - void setNormalizedMagnitudeAt(size_t x, size_t y, float norm) { + void setNormalizedMagnitudeAt(int x, int y, float norm) { if (x < m_width && y < m_height) { if (m_storageType == FFTCache::Polar) m_fmagnitude[x][y] = norm; else m_magnitude[x][y] = uint16_t(norm * 65535.0); } } - void setPhaseAt(size_t x, size_t y, float phase) { + void setPhaseAt(int x, int y, float phase) { // phase in range -pi -> pi if (x < m_width && y < m_height) { if (m_storageType == FFTCache::Polar) m_fphase[x][y] = phase; diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/AudioFileReader.cpp --- a/data/fileio/AudioFileReader.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/AudioFileReader.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -16,23 +16,23 @@ #include "AudioFileReader.h" void -AudioFileReader::getDeInterleavedFrames(size_t start, size_t count, +AudioFileReader::getDeInterleavedFrames(int start, int count, std::vector &frames) const { SampleBlock interleaved; getInterleavedFrames(start, count, interleaved); - size_t channels = getChannelCount(); - size_t rc = interleaved.size() / channels; + int channels = getChannelCount(); + int rc = interleaved.size() / channels; frames.clear(); - for (size_t c = 0; c < channels; ++c) { + for (int c = 0; c < channels; ++c) { frames.push_back(SampleBlock()); } - for (size_t i = 0; i < rc; ++i) { - for (size_t c = 0; c < channels; ++c) { + for (int i = 0; i < rc; ++i) { + for (int c = 0; c < channels; ++c) { frames[c].push_back(interleaved[i * channels + c]); } } diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/AudioFileReader.h --- a/data/fileio/AudioFileReader.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/AudioFileReader.h Wed Jun 18 13:51:16 2014 +0100 @@ -36,11 +36,11 @@ virtual QString getError() const { return ""; } - size_t getFrameCount() const { return m_frameCount; } - size_t getChannelCount() const { return m_channelCount; } - size_t getSampleRate() const { return m_sampleRate; } + int getFrameCount() const { return m_frameCount; } + int getChannelCount() const { return m_channelCount; } + int getSampleRate() const { return m_sampleRate; } - virtual size_t getNativeRate() const { return m_sampleRate; } // if resampled + virtual int getNativeRate() const { return m_sampleRate; } // if resampled /** * Return the location of the audio data in the reader (as passed @@ -81,7 +81,7 @@ * thread-safe -- that is, safe to call from multiple threads with * different arguments on the same object at the same time. */ - virtual void getInterleavedFrames(size_t start, size_t count, + virtual void getInterleavedFrames(int start, int count, SampleBlock &frames) const = 0; /** @@ -91,7 +91,7 @@ * will contain getChannelCount() sample blocks of count samples * each (or fewer if end of file is reached). */ - virtual void getDeInterleavedFrames(size_t start, size_t count, + virtual void getDeInterleavedFrames(int start, int count, std::vector &frames) const; // only subclasses that do not know exactly how long the audio @@ -104,9 +104,9 @@ void frameCountChanged(); protected: - size_t m_frameCount; - size_t m_channelCount; - size_t m_sampleRate; + int m_frameCount; + int m_channelCount; + int m_sampleRate; }; #endif diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/AudioFileReaderFactory.cpp --- a/data/fileio/AudioFileReaderFactory.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/AudioFileReaderFactory.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -58,21 +58,28 @@ } AudioFileReader * -AudioFileReaderFactory::createReader(FileSource source, size_t targetRate, +AudioFileReaderFactory::createReader(FileSource source, + int targetRate, + bool normalised, ProgressReporter *reporter) { - return create(source, targetRate, false, reporter); + return create(source, targetRate, normalised, false, reporter); } AudioFileReader * -AudioFileReaderFactory::createThreadingReader(FileSource source, size_t targetRate, +AudioFileReaderFactory::createThreadingReader(FileSource source, + int targetRate, + bool normalised, ProgressReporter *reporter) { - return create(source, targetRate, true, reporter); + return create(source, targetRate, normalised, true, reporter); } AudioFileReader * -AudioFileReaderFactory::create(FileSource source, size_t targetRate, bool threading, +AudioFileReaderFactory::create(FileSource source, + int targetRate, + bool normalised, + bool threading, ProgressReporter *reporter) { QString err; @@ -102,9 +109,10 @@ if (reader->isOK() && (!reader->isQuicklySeekable() || + normalised || (targetRate != 0 && fileRate != targetRate))) { - SVDEBUG << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", seekable " << reader->isQuicklySeekable() << ", creating decoding reader" << endl; + SVDEBUG << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", normalised " << normalised << ", seekable " << reader->isQuicklySeekable() << ", creating decoding reader" << endl; delete reader; reader = new DecodingWavFileReader @@ -114,6 +122,7 @@ DecodingWavFileReader::ResampleAtOnce, DecodingWavFileReader::CacheInTemporaryFile, targetRate ? targetRate : fileRate, + normalised, reporter); if (!reader->isOK()) { delete reader; @@ -133,6 +142,7 @@ OggVorbisFileReader::DecodeAtOnce, OggVorbisFileReader::CacheInTemporaryFile, targetRate, + normalised, reporter); if (!reader->isOK()) { delete reader; @@ -153,6 +163,7 @@ MP3FileReader::DecodeAtOnce, MP3FileReader::CacheInTemporaryFile, targetRate, + normalised, reporter); if (!reader->isOK()) { delete reader; @@ -172,6 +183,7 @@ QuickTimeFileReader::DecodeAtOnce, QuickTimeFileReader::CacheInTemporaryFile, targetRate, + normalised, reporter); if (!reader->isOK()) { delete reader; @@ -191,6 +203,7 @@ CoreAudioFileReader::DecodeAtOnce, CoreAudioFileReader::CacheInTemporaryFile, targetRate, + normalised, reporter); if (!reader->isOK()) { delete reader; @@ -215,9 +228,10 @@ if (reader->isOK() && (!reader->isQuicklySeekable() || + normalised || (targetRate != 0 && fileRate != targetRate))) { - SVDEBUG << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", seekable " << reader->isQuicklySeekable() << ", creating decoding reader" << endl; + SVDEBUG << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", normalised " << normalised << ", seekable " << reader->isQuicklySeekable() << ", creating decoding reader" << endl; delete reader; reader = new DecodingWavFileReader @@ -227,6 +241,7 @@ DecodingWavFileReader::ResampleAtOnce, DecodingWavFileReader::CacheInTemporaryFile, targetRate ? targetRate : fileRate, + normalised, reporter); } diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/AudioFileReaderFactory.h --- a/data/fileio/AudioFileReaderFactory.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/AudioFileReaderFactory.h Wed Jun 18 13:51:16 2014 +0100 @@ -43,6 +43,9 @@ * if you want to find out whether the file is being resampled * or not. * + * If normalised is true, the file data will be normalised to + * abs(max) == 1.0. Otherwise the file will not be normalised. + * * If a ProgressReporter is provided, it will be updated with * progress status. Caller retains ownership of the reporter * object. @@ -50,7 +53,8 @@ * Caller owns the returned object and must delete it after use. */ static AudioFileReader *createReader(FileSource source, - size_t targetRate = 0, + int targetRate = 0, + bool normalised = false, ProgressReporter *reporter = 0); /** @@ -65,6 +69,9 @@ * if you want to find out whether the file is being resampled * or not. * + * If normalised is true, the file data will be normalised to + * abs(max) == 1.0. Otherwise the file will not be normalised. + * * If a ProgressReporter is provided, it will be updated with * progress status. This will only be meaningful if threading * mode is not used because the file reader in use does not @@ -75,12 +82,14 @@ * Caller owns the returned object and must delete it after use. */ static AudioFileReader *createThreadingReader(FileSource source, - size_t targetRate = 0, + int targetRate = 0, + bool normalised = false, ProgressReporter *reporter = 0); protected: static AudioFileReader *create(FileSource source, - size_t targetRate, + int targetRate, + bool normalised, bool threading, ProgressReporter *reporter); }; diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/CSVFileReader.cpp --- a/data/fileio/CSVFileReader.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/CSVFileReader.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -35,7 +35,7 @@ #include CSVFileReader::CSVFileReader(QString path, CSVFormat format, - size_t mainModelSampleRate) : + int mainModelSampleRate) : m_format(format), m_file(0), m_warnings(0), @@ -81,16 +81,16 @@ return m_error; } -size_t -CSVFileReader::convertTimeValue(QString s, int lineno, size_t sampleRate, - size_t windowSize) const +int +CSVFileReader::convertTimeValue(QString s, int lineno, int sampleRate, + int windowSize) const { QRegExp nonNumericRx("[^0-9eE.,+-]"); int warnLimit = 10; CSVFormat::TimeUnits timeUnits = m_format.getTimeUnits(); - size_t calculatedFrame = 0; + int calculatedFrame = 0; bool ok = false; QString numeric = s; @@ -135,8 +135,8 @@ CSVFormat::ModelType modelType = m_format.getModelType(); CSVFormat::TimingType timingType = m_format.getTimingType(); CSVFormat::TimeUnits timeUnits = m_format.getTimeUnits(); - size_t sampleRate = m_format.getSampleRate(); - size_t windowSize = m_format.getWindowSize(); + int sampleRate = m_format.getSampleRate(); + int windowSize = m_format.getWindowSize(); QChar separator = m_format.getSeparator(); bool allowQuoting = m_format.getAllowQuoting(); @@ -169,15 +169,15 @@ float min = 0.0, max = 0.0; - size_t frameNo = 0; - size_t duration = 0; - size_t endFrame = 0; + int frameNo = 0; + int duration = 0; + int endFrame = 0; bool haveAnyValue = false; bool haveEndTime = false; bool pitchLooksLikeMIDI = true; - size_t startFrame = 0; // for calculation of dense model resolution + int startFrame = 0; // for calculation of dense model resolution bool firstEverValue = true; std::map labelCountMap; diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/CSVFileReader.h --- a/data/fileio/CSVFileReader.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/CSVFileReader.h Wed Jun 18 13:51:16 2014 +0100 @@ -28,7 +28,7 @@ class CSVFileReader : public DataFileReader { public: - CSVFileReader(QString path, CSVFormat format, size_t mainModelSampleRate); + CSVFileReader(QString path, CSVFormat format, int mainModelSampleRate); virtual ~CSVFileReader(); virtual bool isOK() const; @@ -40,10 +40,10 @@ QFile *m_file; QString m_error; mutable int m_warnings; - size_t m_mainModelSampleRate; + int m_mainModelSampleRate; - size_t convertTimeValue(QString, int lineno, size_t sampleRate, - size_t windowSize) const; + int convertTimeValue(QString, int lineno, int sampleRate, + int windowSize) const; }; diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/CSVFileWriter.cpp --- a/data/fileio/CSVFileWriter.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/CSVFileWriter.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -95,8 +95,8 @@ selection->getSelections().begin(); i != selection->getSelections().end(); ++i) { - size_t f0(i->getStartFrame()), f1(i->getEndFrame()); - out << m_model->toDelimitedDataString(m_delimiter, f0, f1); + int f0(i->getStartFrame()), f1(i->getEndFrame()); + out << m_model->toDelimitedDataStringSubset(m_delimiter, f0, f1); } file.close(); diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/CSVFormat.h --- a/data/fileio/CSVFormat.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/CSVFormat.h Wed Jun 18 13:51:16 2014 +0100 @@ -86,8 +86,8 @@ ModelType getModelType() const { return m_modelType; } TimingType getTimingType() const { return m_timingType; } TimeUnits getTimeUnits() const { return m_timeUnits; } - size_t getSampleRate() const { return m_sampleRate; } - size_t getWindowSize() const { return m_windowSize; } + int getSampleRate() const { return m_sampleRate; } + int getWindowSize() const { return m_windowSize; } int getColumnCount() const { return m_columnCount; } bool getAllowQuoting() const { return m_allowQuoting; } QChar getSeparator() const { @@ -99,8 +99,8 @@ void setTimingType(TimingType t) { m_timingType = t; } void setTimeUnits(TimeUnits t) { m_timeUnits = t; } void setSeparator(QChar s) { m_separator = s; } - void setSampleRate(size_t r) { m_sampleRate = r; } - void setWindowSize(size_t s) { m_windowSize = s; } + void setSampleRate(int 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; } @@ -123,8 +123,8 @@ TimingType m_timingType; TimeUnits m_timeUnits; QString m_separator; - size_t m_sampleRate; - size_t m_windowSize; + int m_sampleRate; + int m_windowSize; int m_columnCount; bool m_variableColumnCount; diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/CodedAudioFileReader.cpp --- a/data/fileio/CodedAudioFileReader.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/CodedAudioFileReader.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -28,7 +28,8 @@ #include CodedAudioFileReader::CodedAudioFileReader(CacheMode cacheMode, - size_t targetRate) : + int targetRate, + bool normalised) : m_cacheMode(cacheMode), m_initialised(false), m_serialiser(0), @@ -40,9 +41,12 @@ m_cacheWriteBufferSize(16384), m_resampler(0), m_resampleBuffer(0), - m_fileFrameCount(0) + m_fileFrameCount(0), + m_normalised(normalised), + m_max(0.f), + m_gain(1.f) { - SVDEBUG << "CodedAudioFileReader::CodedAudioFileReader: rate " << targetRate << endl; + SVDEBUG << "CodedAudioFileReader::CodedAudioFileReader: rate " << targetRate << ", normalised = " << normalised << endl; m_frameCount = 0; m_sampleRate = targetRate; @@ -172,15 +176,15 @@ } void -CodedAudioFileReader::addSamplesToDecodeCache(float **samples, size_t nframes) +CodedAudioFileReader::addSamplesToDecodeCache(float **samples, int nframes) { QMutexLocker locker(&m_cacheMutex); if (!m_initialised) return; - for (size_t i = 0; i < nframes; ++i) { + for (int i = 0; i < nframes; ++i) { - for (size_t c = 0; c < m_channelCount; ++c) { + for (int c = 0; c < m_channelCount; ++c) { float sample = samples[c][i]; @@ -202,15 +206,15 @@ } void -CodedAudioFileReader::addSamplesToDecodeCache(float *samples, size_t nframes) +CodedAudioFileReader::addSamplesToDecodeCache(float *samples, int nframes) { QMutexLocker locker(&m_cacheMutex); if (!m_initialised) return; - for (size_t i = 0; i < nframes; ++i) { + for (int i = 0; i < nframes; ++i) { - for (size_t c = 0; c < m_channelCount; ++c) { + for (int c = 0; c < m_channelCount; ++c) { float sample = samples[i * m_channelCount + c]; @@ -238,7 +242,7 @@ if (!m_initialised) return; - for (size_t i = 0; i < samples.size(); ++i) { + for (int i = 0; i < (int)samples.size(); ++i) { float sample = samples[i]; @@ -270,11 +274,9 @@ return; } -// if (m_cacheWriteBufferIndex > 0) { - pushBuffer(m_cacheWriteBuffer, - m_cacheWriteBufferIndex / m_channelCount, - true); -// } + pushBuffer(m_cacheWriteBuffer, + m_cacheWriteBufferIndex / m_channelCount, + true); delete[] m_cacheWriteBuffer; m_cacheWriteBuffer = 0; @@ -293,7 +295,7 @@ } void -CodedAudioFileReader::pushBuffer(float *buffer, size_t sz, bool final) +CodedAudioFileReader::pushBuffer(float *buffer, int sz, bool final) { m_fileFrameCount += sz; @@ -310,16 +312,26 @@ } void -CodedAudioFileReader::pushBufferNonResampling(float *buffer, size_t sz) +CodedAudioFileReader::pushBufferNonResampling(float *buffer, int sz) { - float max = 1.0; - size_t count = sz * m_channelCount; + float clip = 1.0; + int count = sz * m_channelCount; - for (size_t i = 0; i < count; ++i) { - if (buffer[i] > max) buffer[i] = max; - } - for (size_t i = 0; i < count; ++i) { - if (buffer[i] < -max) buffer[i] = -max; + if (m_normalised) { + for (int i = 0; i < count; ++i) { + float v = fabsf(buffer[i]); + if (v > m_max) { + m_max = v; + m_gain = 1.f / m_max; + } + } + } else { + for (int i = 0; i < count; ++i) { + if (buffer[i] > clip) buffer[i] = clip; + } + for (int i = 0; i < count; ++i) { + if (buffer[i] < -clip) buffer[i] = -clip; + } } m_frameCount += sz; @@ -327,7 +339,7 @@ switch (m_cacheMode) { case CacheInTemporaryFile: - if (sf_writef_float(m_cacheFileWritePtr, buffer, sz) < sz) { + if (sf_writef_float(m_cacheFileWritePtr, buffer, sz) < (int)sz) { sf_close(m_cacheFileWritePtr); m_cacheFileWritePtr = 0; throw InsufficientDiscSpace(TempDirectory::getInstance()->getPath()); @@ -336,7 +348,7 @@ case CacheInMemory: m_dataLock.lockForWrite(); - for (size_t s = 0; s < count; ++s) { + for (int s = 0; s < count; ++s) { m_data.push_back(buffer[s]); } MUNLOCK_SAMPLEBLOCK(m_data); @@ -346,14 +358,14 @@ } void -CodedAudioFileReader::pushBufferResampling(float *buffer, size_t sz, +CodedAudioFileReader::pushBufferResampling(float *buffer, int sz, float ratio, bool final) { SVDEBUG << "pushBufferResampling: ratio = " << ratio << ", sz = " << sz << ", final = " << final << endl; if (sz > 0) { - size_t out = m_resampler->resampleInterleaved + int out = m_resampler->resampleInterleaved (buffer, m_resampleBuffer, sz, @@ -365,27 +377,27 @@ if (final) { - size_t padFrames = 1; + int padFrames = 1; if (m_frameCount / ratio < m_fileFrameCount) { padFrames = m_fileFrameCount - (m_frameCount / ratio) + 1; } - size_t padSamples = padFrames * m_channelCount; + int padSamples = padFrames * m_channelCount; SVDEBUG << "frameCount = " << m_frameCount << ", equivFileFrames = " << m_frameCount / ratio << ", m_fileFrameCount = " << m_fileFrameCount << ", padFrames= " << padFrames << ", padSamples = " << padSamples << endl; float *padding = new float[padSamples]; for (int i = 0; i < padSamples; ++i) padding[i] = 0.f; - size_t out = m_resampler->resampleInterleaved + int out = m_resampler->resampleInterleaved (padding, m_resampleBuffer, padFrames, ratio, true); - if (m_frameCount + out > int(m_fileFrameCount * ratio)) { - out = int(m_fileFrameCount * ratio) - m_frameCount; + if (int(m_frameCount + out) > int(m_fileFrameCount * ratio)) { + out = int(m_fileFrameCount * ratio) - int(m_frameCount); } pushBufferNonResampling(m_resampleBuffer, out); @@ -394,7 +406,7 @@ } void -CodedAudioFileReader::getInterleavedFrames(size_t start, size_t count, +CodedAudioFileReader::getInterleavedFrames(int start, int count, SampleBlock &frames) const { // Lock is only required in CacheInMemory mode (the cache file @@ -421,16 +433,22 @@ if (count == 0) return; frames.reserve(count * m_channelCount); - size_t idx = start * m_channelCount; - size_t i = 0; + int idx = start * m_channelCount; + int i = 0; m_dataLock.lockForRead(); - while (i < count * m_channelCount && idx < m_data.size()) { + while (i < count * m_channelCount && idx < (int)m_data.size()) { frames.push_back(m_data[idx]); ++idx; } m_dataLock.unlock(); } } + + if (m_normalised) { + for (int i = 0; i < (int)(count * m_channelCount); ++i) { + frames[i] *= m_gain; + } + } } diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/CodedAudioFileReader.h --- a/data/fileio/CodedAudioFileReader.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/CodedAudioFileReader.h Wed Jun 18 13:51:16 2014 +0100 @@ -38,10 +38,10 @@ CacheInMemory }; - virtual void getInterleavedFrames(size_t start, size_t count, + virtual void getInterleavedFrames(int start, int count, SampleBlock &frames) const; - virtual size_t getNativeRate() const { return m_fileRate; } + virtual int getNativeRate() const { return m_fileRate; } /// Intermediate cache means all CodedAudioFileReaders are quickly seekable virtual bool isQuicklySeekable() const { return true; } @@ -50,13 +50,15 @@ void progress(int); protected: - CodedAudioFileReader(CacheMode cacheMode, size_t targetRate); + CodedAudioFileReader(CacheMode cacheMode, + int targetRate, + bool normalised); void initialiseDecodeCache(); // samplerate, channels must have been set // may throw InsufficientDiscSpace: - void addSamplesToDecodeCache(float **samples, size_t nframes); - void addSamplesToDecodeCache(float *samplesInterleaved, size_t nframes); + void addSamplesToDecodeCache(float **samples, int nframes); + void addSamplesToDecodeCache(float *samplesInterleaved, int nframes); void addSamplesToDecodeCache(const SampleBlock &interleaved); // may throw InsufficientDiscSpace: @@ -68,9 +70,9 @@ void endSerialised(); private: - void pushBuffer(float *interleaved, size_t sz, bool final); - void pushBufferResampling(float *interleaved, size_t sz, float ratio, bool final); - void pushBufferNonResampling(float *interleaved, size_t sz); + void pushBuffer(float *interleaved, int sz, bool final); + void pushBufferResampling(float *interleaved, int sz, float ratio, bool final); + void pushBufferNonResampling(float *interleaved, int sz); protected: QMutex m_cacheMutex; @@ -79,18 +81,22 @@ mutable QReadWriteLock m_dataLock; bool m_initialised; Serialiser *m_serialiser; - size_t m_fileRate; + int m_fileRate; QString m_cacheFileName; SNDFILE *m_cacheFileWritePtr; WavFileReader *m_cacheFileReader; float *m_cacheWriteBuffer; - size_t m_cacheWriteBufferIndex; - size_t m_cacheWriteBufferSize; // frames + int m_cacheWriteBufferIndex; + int m_cacheWriteBufferSize; // frames Resampler *m_resampler; float *m_resampleBuffer; - size_t m_fileFrameCount; + int m_fileFrameCount; + + bool m_normalised; + float m_max; + float m_gain; }; #endif diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/CoreAudioFileReader.cpp --- a/data/fileio/CoreAudioFileReader.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/CoreAudioFileReader.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -59,9 +59,10 @@ CoreAudioFileReader::CoreAudioFileReader(FileSource source, DecodeMode decodeMode, CacheMode mode, - size_t targetRate, + int targetRate, + bool normalised, ProgressReporter *reporter) : - CodedAudioFileReader(mode, targetRate), + CodedAudioFileReader(mode, targetRate, normalised), m_source(source), m_path(source.getLocalFilename()), m_d(new D), diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/CoreAudioFileReader.h --- a/data/fileio/CoreAudioFileReader.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/CoreAudioFileReader.h Wed Jun 18 13:51:16 2014 +0100 @@ -39,7 +39,8 @@ CoreAudioFileReader(FileSource source, DecodeMode decodeMode, CacheMode cacheMode, - size_t targetRate = 0, + int targetRate = 0, + bool normalised = false, ProgressReporter *reporter = 0); virtual ~CoreAudioFileReader(); diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/DataFileReaderFactory.cpp --- a/data/fileio/DataFileReaderFactory.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/DataFileReaderFactory.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -32,7 +32,7 @@ bool csv, MIDIFileImportPreferenceAcquirer *acquirer, CSVFormat format, - size_t mainModelSampleRate) + int mainModelSampleRate) { QString err; @@ -58,7 +58,7 @@ DataFileReader * DataFileReaderFactory::createReader(QString path, MIDIFileImportPreferenceAcquirer *acquirer, - size_t mainModelSampleRate) + int mainModelSampleRate) { DataFileReader *reader = createReader (path, false, acquirer, CSVFormat(), mainModelSampleRate); @@ -74,7 +74,7 @@ Model * DataFileReaderFactory::load(QString path, MIDIFileImportPreferenceAcquirer *acquirer, - size_t mainModelSampleRate) + int mainModelSampleRate) { DataFileReader *reader = createReader(path, acquirer, @@ -94,7 +94,7 @@ Model * DataFileReaderFactory::loadNonCSV(QString path, MIDIFileImportPreferenceAcquirer *acquirer, - size_t mainModelSampleRate) + int mainModelSampleRate) { DataFileReader *reader = createReader(path, false, acquirer, @@ -114,7 +114,7 @@ Model * DataFileReaderFactory::loadCSV(QString path, CSVFormat format, - size_t mainModelSampleRate) + int mainModelSampleRate) { DataFileReader *reader = createReader(path, true, 0, format, mainModelSampleRate); diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/DataFileReaderFactory.h --- a/data/fileio/DataFileReaderFactory.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/DataFileReaderFactory.h Wed Jun 18 13:51:16 2014 +0100 @@ -48,7 +48,7 @@ */ static DataFileReader *createReader(QString path, MIDIFileImportPreferenceAcquirer *, - size_t mainModelSampleRate); + int mainModelSampleRate); /** * Read the given path, if a suitable reader is available. @@ -60,7 +60,7 @@ */ static Model *load(QString path, MIDIFileImportPreferenceAcquirer *acquirer, - size_t mainModelSampleRate); + int mainModelSampleRate); /** * Read the given path, if a suitable reader is available. @@ -69,7 +69,7 @@ */ static Model *loadNonCSV(QString path, MIDIFileImportPreferenceAcquirer *acquirer, - size_t mainModelSampleRate); + int mainModelSampleRate); /** * Read the given path using the CSV reader with the given format. @@ -77,13 +77,13 @@ */ static Model *loadCSV(QString path, CSVFormat format, - size_t mainModelSampleRate); + int mainModelSampleRate); protected: static DataFileReader *createReader(QString path, bool csv, MIDIFileImportPreferenceAcquirer *, CSVFormat format, - size_t mainModelSampleRate); + int mainModelSampleRate); }; #endif diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/DecodingWavFileReader.cpp --- a/data/fileio/DecodingWavFileReader.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/DecodingWavFileReader.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -22,11 +22,12 @@ #include DecodingWavFileReader::DecodingWavFileReader(FileSource source, - ResampleMode resampleMode, - CacheMode mode, - size_t targetRate, - ProgressReporter *reporter) : - CodedAudioFileReader(mode, targetRate), + ResampleMode resampleMode, + CacheMode mode, + int targetRate, + bool normalised, + ProgressReporter *reporter) : + CodedAudioFileReader(mode, targetRate, normalised), m_source(source), m_path(source.getLocalFilename()), m_cancelled(false), @@ -63,14 +64,14 @@ (tr("Decoding %1...").arg(QFileInfo(m_path).fileName())); } - size_t blockSize = 16384; - size_t total = m_original->getFrameCount(); + int blockSize = 16384; + int total = m_original->getFrameCount(); SampleBlock block; - for (size_t i = 0; i < total; i += blockSize) { + for (int i = 0; i < total; i += blockSize) { - size_t count = blockSize; + int count = blockSize; if (i + count > total) count = total - i; m_original->getInterleavedFrames(i, count, block); @@ -120,14 +121,14 @@ m_reader->startSerialised("DecodingWavFileReader::Decode"); } - size_t blockSize = 16384; - size_t total = m_reader->m_original->getFrameCount(); + int blockSize = 16384; + int total = m_reader->m_original->getFrameCount(); SampleBlock block; - for (size_t i = 0; i < total; i += blockSize) { + for (int i = 0; i < total; i += blockSize) { - size_t count = blockSize; + int count = blockSize; if (i + count > total) count = total - i; m_reader->m_original->getInterleavedFrames(i, count, block); diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/DecodingWavFileReader.h --- a/data/fileio/DecodingWavFileReader.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/DecodingWavFileReader.h Wed Jun 18 13:51:16 2014 +0100 @@ -35,10 +35,11 @@ }; DecodingWavFileReader(FileSource source, - ResampleMode resampleMode, - CacheMode cacheMode, - size_t targetRate = 0, - ProgressReporter *reporter = 0); + ResampleMode resampleMode, + CacheMode cacheMode, + int targetRate = 0, + bool normalised = false, + ProgressReporter *reporter = 0); virtual ~DecodingWavFileReader(); virtual QString getError() const { return m_error; } @@ -62,7 +63,7 @@ QString m_path; QString m_error; bool m_cancelled; - size_t m_processed; + int m_processed; int m_completion; WavFileReader *m_original; diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/FFTFuzzyAdapter.cpp --- a/data/fileio/FFTFuzzyAdapter.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/FFTFuzzyAdapter.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -20,11 +20,11 @@ FFTFuzzyAdapter::FFTFuzzyAdapter(const DenseTimeValueModel *model, int channel, WindowType windowType, - size_t windowSize, - size_t windowIncrement, - size_t fftSize, + int windowSize, + int windowIncrement, + int fftSize, bool polar, - size_t fillFromColumn) : + int fillFromColumn) : m_server(0), m_xshift(0), m_yshift(0) @@ -38,8 +38,8 @@ polar, fillFromColumn); - size_t xratio = windowIncrement / m_server->getWindowIncrement(); - size_t yratio = m_server->getFFTSize() / fftSize; + int xratio = windowIncrement / m_server->getWindowIncrement(); + int yratio = m_server->getFFTSize() / fftSize; while (xratio > 1) { if (xratio & 0x1) { diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/FFTFuzzyAdapter.h --- a/data/fileio/FFTFuzzyAdapter.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/FFTFuzzyAdapter.h Wed Jun 18 13:51:16 2014 +0100 @@ -24,49 +24,49 @@ FFTFuzzyAdapter(const DenseTimeValueModel *model, int channel, WindowType windowType, - size_t windowSize, - size_t windowIncrement, - size_t fftSize, + int windowSize, + int windowIncrement, + int fftSize, bool polar, - size_t fillFromColumn = 0); + int fillFromColumn = 0); ~FFTFuzzyAdapter(); - size_t getWidth() const { + int getWidth() const { return m_server->getWidth() >> m_xshift; } - size_t getHeight() const { + int getHeight() const { return m_server->getHeight() >> m_yshift; } - float getMagnitudeAt(size_t x, size_t y) { + float getMagnitudeAt(int x, int y) { return m_server->getMagnitudeAt(x << m_xshift, y << m_yshift); } - float getNormalizedMagnitudeAt(size_t x, size_t y) { + float getNormalizedMagnitudeAt(int x, int y) { return m_server->getNormalizedMagnitudeAt(x << m_xshift, y << m_yshift); } - float getMaximumMagnitudeAt(size_t x) { + float getMaximumMagnitudeAt(int x) { return m_server->getMaximumMagnitudeAt(x << m_xshift); } - float getPhaseAt(size_t x, size_t y) { + float getPhaseAt(int x, int y) { return m_server->getPhaseAt(x << m_xshift, y << m_yshift); } - void getValuesAt(size_t x, size_t y, float &real, float &imaginary) { + void getValuesAt(int x, int y, float &real, float &imaginary) { m_server->getValuesAt(x << m_xshift, y << m_yshift, real, imaginary); } - bool isColumnReady(size_t x) { + bool isColumnReady(int x) { return m_server->isColumnReady(x << m_xshift); } - bool isLocalPeak(size_t x, size_t y) { + bool isLocalPeak(int x, int y) { float mag = getMagnitudeAt(x, y); if (y > 0 && mag < getMagnitudeAt(x, y - 1)) return false; if (y < getHeight() - 1 && mag < getMagnitudeAt(x, y + 1)) return false; return true; } - bool isOverThreshold(size_t x, size_t y, float threshold) { + bool isOverThreshold(int x, int y, float threshold) { return getMagnitudeAt(x, y) > threshold; } - size_t getFillCompletion() const { return m_server->getFillCompletion(); } - size_t getFillExtent() const { return m_server->getFillExtent(); } + int getFillCompletion() const { return m_server->getFillCompletion(); } + int getFillExtent() const { return m_server->getFillExtent(); } private: FFTFuzzyAdapter(const FFTFuzzyAdapter &); // not implemented diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/MIDIFileReader.cpp --- a/data/fileio/MIDIFileReader.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/MIDIFileReader.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -57,7 +57,7 @@ MIDIFileReader::MIDIFileReader(QString path, MIDIFileImportPreferenceAcquirer *acquirer, - size_t mainModelSampleRate) : + int mainModelSampleRate) : m_smpte(false), m_timingDivision(0), m_fps(0), @@ -896,7 +896,7 @@ if (tracksToLoad.empty()) return 0; - size_t n = tracksToLoad.size(), count = 0; + int n = tracksToLoad.size(), count = 0; Model *model = 0; for (std::set::iterator i = tracksToLoad.begin(); @@ -943,10 +943,9 @@ const MIDITrack &track = m_midiComposition.find(trackToLoad)->second; - size_t totalEvents = track.size(); - size_t count = 0; + int totalEvents = track.size(); + int count = 0; - bool minorKey = false; bool sharpKey = true; for (MIDITrack::const_iterator i = track.begin(); i != track.end(); ++i) { @@ -968,7 +967,7 @@ switch((*i)->getMetaEventCode()) { case MIDI_KEY_SIGNATURE: - minorKey = (int((*i)->getMetaMessage()[1]) != 0); + // minorKey = (int((*i)->getMetaMessage()[1]) != 0); sharpKey = (int((*i)->getMetaMessage()[0]) >= 0); break; diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/MIDIFileReader.h --- a/data/fileio/MIDIFileReader.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/MIDIFileReader.h Wed Jun 18 13:51:16 2014 +0100 @@ -62,7 +62,7 @@ public: MIDIFileReader(QString path, MIDIFileImportPreferenceAcquirer *pref, - size_t mainModelSampleRate); + int mainModelSampleRate); virtual ~MIDIFileReader(); virtual bool isOK() const; @@ -126,9 +126,9 @@ QString m_path; std::ifstream *m_midiFile; - size_t m_fileSize; + int m_fileSize; QString m_error; - size_t m_mainModelSampleRate; + int m_mainModelSampleRate; MIDIFileImportPreferenceAcquirer *m_acquirer; }; diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/MIDIFileWriter.cpp --- a/data/fileio/MIDIFileWriter.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/MIDIFileWriter.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -344,8 +344,8 @@ for (NoteList::const_iterator i = notes.begin(); i != notes.end(); ++i) { - size_t frame = i->start; - size_t duration = i->duration; + int frame = i->start; + int duration = i->duration; int pitch = i->midiPitch; int velocity = i->velocity; diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/MP3FileReader.cpp --- a/data/fileio/MP3FileReader.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/MP3FileReader.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -37,9 +37,10 @@ #include MP3FileReader::MP3FileReader(FileSource source, DecodeMode decodeMode, - CacheMode mode, size_t targetRate, + CacheMode mode, int targetRate, + bool normalised, ProgressReporter *reporter) : - CodedAudioFileReader(mode, targetRate), + CodedAudioFileReader(mode, targetRate, normalised), m_source(source), m_path(source.getLocalFilename()), m_decodeThread(0) @@ -85,7 +86,7 @@ } ssize_t sz = 0; - size_t offset = 0; + int offset = 0; while (offset < m_fileSize) { sz = ::read(fd, m_filebuffer + offset, m_fileSize - offset); if (sz < 0) { @@ -274,7 +275,7 @@ m_reader->m_filebuffer = 0; if (m_reader->m_samplebuffer) { - for (size_t c = 0; c < m_reader->m_channelCount; ++c) { + for (int c = 0; c < m_reader->m_channelCount; ++c) { delete[] m_reader->m_samplebuffer[c]; } delete[] m_reader->m_samplebuffer; @@ -290,7 +291,7 @@ } bool -MP3FileReader::decode(void *mm, size_t sz) +MP3FileReader::decode(void *mm, int sz) { DecoderData data; struct mad_decoder decoder; @@ -391,7 +392,7 @@ initialiseDecodeCache(); } - if (m_samplebuffersize < frames) { + if (int(m_samplebuffersize) < frames) { if (!m_samplebuffer) { m_samplebuffer = new float *[channels]; for (int c = 0; c < channels; ++c) { @@ -427,11 +428,11 @@ } enum mad_flow -MP3FileReader::error(void *dp, - struct mad_stream *stream, +MP3FileReader::error(void * /* dp */, + struct mad_stream * /* stream */, struct mad_frame *) { - DecoderData *data = (DecoderData *)dp; +// DecoderData *data = (DecoderData *)dp; // fprintf(stderr, "decoding error 0x%04x (%s) at byte offset %lu\n", // stream->error, mad_stream_errorstr(stream), diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/MP3FileReader.h --- a/data/fileio/MP3FileReader.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/MP3FileReader.h Wed Jun 18 13:51:16 2014 +0100 @@ -40,7 +40,8 @@ MP3FileReader(FileSource source, DecodeMode decodeMode, CacheMode cacheMode, - size_t targetRate = 0, + int targetRate = 0, + bool normalised = false, ProgressReporter *reporter = 0); virtual ~MP3FileReader(); @@ -72,15 +73,15 @@ QString m_title; QString m_maker; TagMap m_tags; - size_t m_fileSize; + int m_fileSize; double m_bitrateNum; - size_t m_bitrateDenom; + int m_bitrateDenom; int m_completion; bool m_done; unsigned char *m_filebuffer; float **m_samplebuffer; - size_t m_samplebuffersize; + int m_samplebuffersize; ProgressReporter *m_reporter; bool m_cancelled; @@ -92,7 +93,7 @@ MP3FileReader *reader; }; - bool decode(void *mm, size_t sz); + bool decode(void *mm, int sz); enum mad_flow accept(struct mad_header const *, struct mad_pcm *); static enum mad_flow input(void *, struct mad_stream *); diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/MatchFileReader.cpp --- a/data/fileio/MatchFileReader.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/MatchFileReader.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -163,8 +163,11 @@ break; } - if (state < 3) ++state; - else if (state == 3 && alignment.thisIndex.size() == count) ++state; + if (state < 3) { + ++state; + } else if (state == 3 && int(alignment.thisIndex.size()) == count) { + ++state; + } } if (alignment.thisHopTime == 0.0) { diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/MatrixFile.cpp --- a/data/fileio/MatrixFile.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/MatrixFile.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -52,7 +52,7 @@ static size_t openCount = 0; MatrixFile::MatrixFile(QString fileBase, Mode mode, - size_t cellSize, size_t width, size_t height) : + int cellSize, int width, int height) : m_fd(-1), m_mode(mode), m_flags(0), @@ -60,7 +60,7 @@ m_cellSize(cellSize), m_width(width), m_height(height), - m_headerSize(2 * sizeof(size_t)), + m_headerSize(2 * sizeof(int)), m_setColumns(0), m_autoClose(false), m_readyToReadColumn(-1) @@ -125,8 +125,8 @@ if (newFile) { initialise(); // write header and "unwritten" column tags } else { - size_t header[2]; - if (::read(m_fd, header, 2 * sizeof(size_t)) < 0) { + int header[2]; + if (::read(m_fd, header, 2 * sizeof(int)) < 0) { ::perror("MatrixFile::MatrixFile: read failed"); cerr << "ERROR: MatrixFile::MatrixFile: " << "Failed to read header (fd " << m_fd << ", file \"" @@ -222,10 +222,10 @@ throw FileOperationFailed(m_fileName, "lseek"); } - size_t header[2]; + int header[2]; header[0] = m_width; header[1] = m_height; - if (::write(m_fd, header, 2 * sizeof(size_t)) != 2 * sizeof(size_t)) { + if (::write(m_fd, header, 2 * sizeof(int)) != 2 * sizeof(int)) { ::perror("ERROR: MatrixFile::initialise: Failed to write header"); throw FileOperationFailed(m_fileName, "write"); } @@ -263,7 +263,7 @@ } void -MatrixFile::getColumnAt(size_t x, void *data) +MatrixFile::getColumnAt(int x, void *data) { assert(m_mode == ReadOnly); @@ -276,7 +276,7 @@ ssize_t r = -1; if (m_readyToReadColumn < 0 || - size_t(m_readyToReadColumn) != x) { + m_readyToReadColumn != x) { unsigned char set = 0; if (!seekTo(x)) { @@ -303,14 +303,14 @@ } bool -MatrixFile::haveSetColumnAt(size_t x) const +MatrixFile::haveSetColumnAt(int x) const { if (m_mode == WriteOnly) { return m_setColumns->get(x); } if (m_readyToReadColumn >= 0 && - size_t(m_readyToReadColumn) == x) return true; + int(m_readyToReadColumn) == x) return true; Profiler profiler("MatrixFile::haveSetColumnAt"); @@ -338,7 +338,7 @@ } void -MatrixFile::setColumnAt(size_t x, const void *data) +MatrixFile::setColumnAt(int x, const void *data) { assert(m_mode == WriteOnly); if (m_fd < 0) return; // closed @@ -408,7 +408,7 @@ } bool -MatrixFile::seekTo(size_t x) const +MatrixFile::seekTo(int x) const { if (m_fd < 0) { cerr << "ERROR: MatrixFile::seekTo: File not open" << endl; diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/MatrixFile.h --- a/data/fileio/MatrixFile.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/MatrixFile.h Wed Jun 18 13:51:16 2014 +0100 @@ -58,15 +58,15 @@ * MatrixFile has no built-in cache and is not thread-safe. Use a * separate MatrixFile in each thread. */ - MatrixFile(QString fileBase, Mode mode, size_t cellSize, - size_t width, size_t height); + MatrixFile(QString fileBase, Mode mode, int cellSize, + int width, int height); virtual ~MatrixFile(); Mode getMode() const { return m_mode; } - size_t getWidth() const { return m_width; } - size_t getHeight() const { return m_height; } - size_t getCellSize() const { return m_cellSize; } + int getWidth() const { return m_width; } + int getHeight() const { return m_height; } + int getCellSize() const { return m_cellSize; } /** * If this is set true on a write-mode MatrixFile, then the file @@ -76,19 +76,19 @@ void close(); // does not decrement ref count; that happens in dtor - bool haveSetColumnAt(size_t x) const; - void getColumnAt(size_t x, void *data); // may throw FileReadFailed - void setColumnAt(size_t x, const void *data); + bool haveSetColumnAt(int x) const; + void getColumnAt(int x, void *data); // may throw FileReadFailed + void setColumnAt(int x, const void *data); protected: int m_fd; Mode m_mode; int m_flags; mode_t m_fmode; - size_t m_cellSize; - size_t m_width; - size_t m_height; - size_t m_headerSize; + int m_cellSize; + int m_width; + int m_height; + int m_headerSize; QString m_fileName; ResizeableBitset *m_setColumns; // only in writer @@ -102,7 +102,7 @@ static QMutex m_createMutex; void initialise(); - bool seekTo(size_t x) const; + bool seekTo(int col) const; }; #endif diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/OggVorbisFileReader.cpp --- a/data/fileio/OggVorbisFileReader.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/OggVorbisFileReader.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -34,9 +34,10 @@ OggVorbisFileReader::OggVorbisFileReader(FileSource source, DecodeMode decodeMode, CacheMode mode, - size_t targetRate, + int targetRate, + bool normalised, ProgressReporter *reporter) : - CodedAudioFileReader(mode, targetRate), + CodedAudioFileReader(mode, targetRate, normalised), m_source(source), m_path(source.getLocalFilename()), m_reporter(reporter), diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/OggVorbisFileReader.h --- a/data/fileio/OggVorbisFileReader.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/OggVorbisFileReader.h Wed Jun 18 13:51:16 2014 +0100 @@ -42,7 +42,8 @@ OggVorbisFileReader(FileSource source, DecodeMode decodeMode, CacheMode cacheMode, - size_t targetRate = 0, + int targetRate = 0, + bool normalised = false, ProgressReporter *reporter = 0); virtual ~OggVorbisFileReader(); @@ -78,8 +79,8 @@ OGGZ *m_oggz; FishSound *m_fishSound; ProgressReporter *m_reporter; - size_t m_fileSize; - size_t m_bytesRead; + int m_fileSize; + int m_bytesRead; bool m_commentsRead; bool m_cancelled; int m_completion; diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/QuickTimeFileReader.cpp --- a/data/fileio/QuickTimeFileReader.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/QuickTimeFileReader.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -43,16 +43,17 @@ OSErr err; AudioStreamBasicDescription asbd; Movie movie; - size_t blockSize; + int blockSize; }; QuickTimeFileReader::QuickTimeFileReader(FileSource source, DecodeMode decodeMode, CacheMode mode, - size_t targetRate, + int targetRate, + bool normalised, ProgressReporter *reporter) : - CodedAudioFileReader(mode, targetRate), + CodedAudioFileReader(mode, targetRate, normalised), m_source(source), m_path(source.getLocalFilename()), m_d(new D), diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/QuickTimeFileReader.h --- a/data/fileio/QuickTimeFileReader.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/QuickTimeFileReader.h Wed Jun 18 13:51:16 2014 +0100 @@ -42,7 +42,8 @@ QuickTimeFileReader(FileSource source, DecodeMode decodeMode, CacheMode cacheMode, - size_t targetRate = 0, + int targetRate = 0, + bool normalised = false, ProgressReporter *reporter = 0); virtual ~QuickTimeFileReader(); diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/WavFileReader.cpp --- a/data/fileio/WavFileReader.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/WavFileReader.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -89,7 +89,7 @@ { QMutexLocker locker(&m_mutex); - size_t prevCount = m_fileInfo.frames; + int prevCount = m_fileInfo.frames; if (m_file) { sf_close(m_file); @@ -123,7 +123,7 @@ } void -WavFileReader::getInterleavedFrames(size_t start, size_t count, +WavFileReader::getInterleavedFrames(int start, int count, SampleBlock &results) const { if (count == 0) return; @@ -173,7 +173,7 @@ m_lastCount = readCount; } - for (size_t i = 0; i < count * m_fileInfo.channels; ++i) { + for (int i = 0; i < count * m_fileInfo.channels; ++i) { if (i >= m_bufsiz) { cerr << "INTERNAL ERROR: WavFileReader::getInterleavedFrames: " << i << " >= " << m_bufsiz << endl; } diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/WavFileReader.h --- a/data/fileio/WavFileReader.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/WavFileReader.h Wed Jun 18 13:51:16 2014 +0100 @@ -48,7 +48,7 @@ * Must be safe to call from multiple threads with different * arguments on the same object at the same time. */ - virtual void getInterleavedFrames(size_t start, size_t count, + virtual void getInterleavedFrames(int start, int count, SampleBlock &frames) const; static void getSupportedExtensions(std::set &extensions); @@ -75,9 +75,9 @@ mutable QMutex m_mutex; mutable float *m_buffer; - mutable size_t m_bufsiz; - mutable size_t m_lastStart; - mutable size_t m_lastCount; + mutable int m_bufsiz; + mutable int m_lastStart; + mutable int m_lastCount; bool m_updating; }; diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/WavFileWriter.cpp --- a/data/fileio/WavFileWriter.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/WavFileWriter.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -25,8 +25,8 @@ #include WavFileWriter::WavFileWriter(QString path, - size_t sampleRate, - size_t channels, + int sampleRate, + int channels, FileWriteMode mode) : m_path(path), m_sampleRate(sampleRate), @@ -120,7 +120,7 @@ ownSelection = true; } - size_t bs = 2048; + int bs = 2048; float *ub = new float[bs]; // uninterleaved buffer (one channel) float *ib = new float[bs * m_channels]; // interleaved buffer @@ -128,15 +128,15 @@ selection->getSelections().begin(); i != selection->getSelections().end(); ++i) { - size_t f0(i->getStartFrame()), f1(i->getEndFrame()); + int f0(i->getStartFrame()), f1(i->getEndFrame()); - for (size_t f = f0; f < f1; f += bs) { + for (int f = f0; f < f1; f += bs) { - size_t n = std::min(bs, f1 - f); + int n = std::min(bs, f1 - f); for (int c = 0; c < int(m_channels); ++c) { source->getData(c, f, n, ub); - for (size_t i = 0; i < n; ++i) { + for (int i = 0; i < n; ++i) { ib[i * m_channels + c] = ub[i]; } } @@ -159,7 +159,7 @@ } bool -WavFileWriter::writeSamples(float **samples, size_t count) +WavFileWriter::writeSamples(float **samples, int count) { if (!m_file) { m_error = QString("Failed to write model to audio file '%1': File not open") @@ -168,8 +168,8 @@ } float *b = new float[count * m_channels]; - for (size_t i = 0; i < count; ++i) { - for (size_t c = 0; c < m_channels; ++c) { + for (int i = 0; i < int(count); ++i) { + for (int c = 0; c < int(m_channels); ++c) { b[i * m_channels + c] = samples[c][i]; } } @@ -178,7 +178,7 @@ delete[] b; - if (written < count) { + if (written < int(count)) { m_error = QString("Only wrote %1 of %2 frames") .arg(written).arg(count); } diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/WavFileWriter.h --- a/data/fileio/WavFileWriter.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/WavFileWriter.h Wed Jun 18 13:51:16 2014 +0100 @@ -44,7 +44,7 @@ WriteToTarget }; - WavFileWriter(QString path, size_t sampleRate, size_t channels, + WavFileWriter(QString path, int sampleRate, int channels, FileWriteMode mode); virtual ~WavFileWriter(); @@ -57,14 +57,14 @@ bool writeModel(DenseTimeValueModel *source, MultiSelection *selection = 0); - bool writeSamples(float **samples, size_t count); // count per channel + bool writeSamples(float **samples, int count); // count per channel bool close(); protected: QString m_path; - size_t m_sampleRate; - size_t m_channels; + int m_sampleRate; + int m_channels; TempWriteFile *m_temp; SNDFILE *m_file; QString m_error; diff -r 49618f39ff09 -r 0c1d6de8f44b data/fileio/test/AudioFileReaderTest.h --- a/data/fileio/test/AudioFileReaderTest.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/fileio/test/AudioFileReaderTest.h Wed Jun 18 13:51:16 2014 +0100 @@ -94,7 +94,6 @@ float *reference = tdata.getInterleavedData(); int refFrames = tdata.getFrameCount(); - int refsize = refFrames * channels; vector test; diff -r 49618f39ff09 -r 0c1d6de8f44b data/midi/MIDIInput.h --- a/data/midi/MIDIInput.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/midi/MIDIInput.h Wed Jun 18 13:51:16 2014 +0100 @@ -36,7 +36,7 @@ bool isOK() const { return m_rtmidi != 0; } bool isEmpty() const { return getEventsAvailable() == 0; } - size_t getEventsAvailable() const { return m_buffer.getReadSpace(); } + int getEventsAvailable() const { return m_buffer.getReadSpace(); } MIDIEvent readEvent(); signals: diff -r 49618f39ff09 -r 0c1d6de8f44b data/midi/rtmidi/RtMidi.cpp --- a/data/midi/rtmidi/RtMidi.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/midi/rtmidi/RtMidi.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -2263,5 +2263,5 @@ { } -#endif __RTMIDI_DUMMY_ONLY__ +#endif /* __RTMIDI_DUMMY_ONLY__ */ diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/AggregateWaveModel.cpp --- a/data/model/AggregateWaveModel.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/AggregateWaveModel.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -65,27 +65,27 @@ return ready; } -size_t +int AggregateWaveModel::getFrameCount() const { - size_t count = 0; + int count = 0; for (ChannelSpecList::const_iterator i = m_components.begin(); i != m_components.end(); ++i) { - size_t thisCount = i->model->getEndFrame() - i->model->getStartFrame(); + int thisCount = i->model->getEndFrame() - i->model->getStartFrame(); if (thisCount > count) count = thisCount; } return count; } -size_t +int AggregateWaveModel::getChannelCount() const { return m_components.size(); } -size_t +int AggregateWaveModel::getSampleRate() const { if (m_components.empty()) return 0; @@ -98,8 +98,8 @@ return new AggregateWaveModel(m_components); } -size_t -AggregateWaveModel::getData(int channel, size_t start, size_t count, +int +AggregateWaveModel::getData(int channel, int start, int count, float *buffer) const { int ch0 = channel, ch1 = channel; @@ -113,21 +113,21 @@ float *readbuf = buffer; if (mixing) { readbuf = new float[count]; - for (size_t i = 0; i < count; ++i) { + for (int i = 0; i < count; ++i) { buffer[i] = 0.f; } } - size_t sz = count; + int sz = count; for (int c = ch0; c <= ch1; ++c) { - size_t szHere = + int szHere = m_components[c].model->getData(m_components[c].channel, start, count, readbuf); if (szHere < sz) sz = szHere; if (mixing) { - for (size_t i = 0; i < count; ++i) { + for (int i = 0; i < count; ++i) { buffer[i] += readbuf[i]; } } @@ -137,8 +137,8 @@ return sz; } -size_t -AggregateWaveModel::getData(int channel, size_t start, size_t count, +int +AggregateWaveModel::getData(int channel, int start, int count, double *buffer) const { int ch0 = channel, ch1 = channel; @@ -152,21 +152,21 @@ double *readbuf = buffer; if (mixing) { readbuf = new double[count]; - for (size_t i = 0; i < count; ++i) { + for (int i = 0; i < count; ++i) { buffer[i] = 0.0; } } - size_t sz = count; + int sz = count; for (int c = ch0; c <= ch1; ++c) { - size_t szHere = + int szHere = m_components[c].model->getData(m_components[c].channel, start, count, readbuf); if (szHere < sz) sz = szHere; if (mixing) { - for (size_t i = 0; i < count; ++i) { + for (int i = 0; i < count; ++i) { buffer[i] += readbuf[i]; } } @@ -176,50 +176,50 @@ return sz; } -size_t -AggregateWaveModel::getData(size_t fromchannel, size_t tochannel, - size_t start, size_t count, +int +AggregateWaveModel::getData(int fromchannel, int tochannel, + int start, int count, float **buffer) const { - size_t min = count; + int min = count; - for (size_t c = fromchannel; c <= tochannel; ++c) { - size_t here = getData(c, start, count, buffer[c - fromchannel]); + for (int c = fromchannel; c <= tochannel; ++c) { + int here = getData(c, start, count, buffer[c - fromchannel]); if (here < min) min = here; } return min; } -size_t -AggregateWaveModel::getSummaryBlockSize(size_t desired) const +int +AggregateWaveModel::getSummaryBlockSize(int desired) const { //!!! complete return desired; } void -AggregateWaveModel::getSummaries(size_t channel, size_t start, size_t count, - RangeBlock &ranges, size_t &blockSize) const +AggregateWaveModel::getSummaries(int, int, int, + RangeBlock &, int &) const { //!!! complete } AggregateWaveModel::Range -AggregateWaveModel::getSummary(size_t channel, size_t start, size_t count) const +AggregateWaveModel::getSummary(int, int, int) const { //!!! complete return Range(); } -size_t +int AggregateWaveModel::getComponentCount() const { return m_components.size(); } AggregateWaveModel::ModelChannelSpec -AggregateWaveModel::getComponent(size_t c) const +AggregateWaveModel::getComponent(int c) const { return m_components[c]; } @@ -231,7 +231,7 @@ } void -AggregateWaveModel::componentModelChanged(size_t start, size_t end) +AggregateWaveModel::componentModelChanged(int start, int end) { emit modelChanged(start, end); } @@ -243,9 +243,9 @@ } void -AggregateWaveModel::toXml(QTextStream &out, - QString indent, - QString extraAttributes) const +AggregateWaveModel::toXml(QTextStream &, + QString , + QString ) const { //!!! complete } diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/AggregateWaveModel.h --- a/data/model/AggregateWaveModel.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/AggregateWaveModel.h Wed Jun 18 13:51:16 2014 +0100 @@ -44,40 +44,40 @@ QString getTypeName() const { return tr("Aggregate Wave"); } - size_t getComponentCount() const; - ModelChannelSpec getComponent(size_t c) const; + int getComponentCount() const; + ModelChannelSpec getComponent(int c) const; const ZoomConstraint *getZoomConstraint() const { return &m_zoomConstraint; } - size_t getFrameCount() const; - size_t getChannelCount() const; - size_t getSampleRate() const; + int getFrameCount() const; + int getChannelCount() const; + int getSampleRate() const; virtual Model *clone() const; float getValueMinimum() const { return -1.0f; } float getValueMaximum() const { return 1.0f; } - virtual size_t getStartFrame() const { return 0; } - virtual size_t getEndFrame() const { return getFrameCount(); } + virtual int getStartFrame() const { return 0; } + virtual int getEndFrame() const { return getFrameCount(); } - virtual size_t getData(int channel, size_t start, size_t count, + virtual int getData(int channel, int start, int count, float *buffer) const; - virtual size_t getData(int channel, size_t start, size_t count, + virtual int getData(int channel, int start, int count, double *buffer) const; - virtual size_t getData(size_t fromchannel, size_t tochannel, - size_t start, size_t count, + virtual int getData(int fromchannel, int tochannel, + int start, int count, float **buffer) const; - virtual size_t getSummaryBlockSize(size_t desired) const; + virtual int getSummaryBlockSize(int desired) const; - virtual void getSummaries(size_t channel, size_t start, size_t count, + virtual void getSummaries(int channel, int start, int count, RangeBlock &ranges, - size_t &blockSize) const; + int &blockSize) const; - virtual Range getSummary(size_t channel, size_t start, size_t count) const; + virtual Range getSummary(int channel, int start, int count) const; virtual void toXml(QTextStream &out, QString indent = "", @@ -85,12 +85,12 @@ signals: void modelChanged(); - void modelChanged(size_t, size_t); + void modelChanged(int, int); void completionChanged(); protected slots: void componentModelChanged(); - void componentModelChanged(size_t, size_t); + void componentModelChanged(int, int); void componentModelCompletionChanged(); protected: diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/AlignmentModel.cpp --- a/data/model/AlignmentModel.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/AlignmentModel.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -37,8 +37,8 @@ connect(m_rawPath, SIGNAL(modelChanged()), this, SLOT(pathChanged())); - connect(m_rawPath, SIGNAL(modelChanged(size_t, size_t)), - this, SLOT(pathChanged(size_t, size_t))); + connect(m_rawPath, SIGNAL(modelChanged(int, int)), + this, SLOT(pathChanged(int, int))); connect(m_rawPath, SIGNAL(completionChanged()), this, SLOT(pathCompletionChanged())); @@ -74,23 +74,23 @@ else return true; } -size_t +int AlignmentModel::getStartFrame() const { - size_t a = m_reference->getStartFrame(); - size_t b = m_aligned->getStartFrame(); + int a = m_reference->getStartFrame(); + int b = m_aligned->getStartFrame(); return std::min(a, b); } -size_t +int AlignmentModel::getEndFrame() const { - size_t a = m_reference->getEndFrame(); - size_t b = m_aligned->getEndFrame(); + int a = m_reference->getEndFrame(); + int b = m_aligned->getEndFrame(); return std::max(a, b); } -size_t +int AlignmentModel::getSampleRate() const { return m_reference->getSampleRate(); @@ -137,8 +137,8 @@ return m_aligned; } -size_t -AlignmentModel::toReference(size_t frame) const +int +AlignmentModel::toReference(int frame) const { #ifdef DEBUG_ALIGNMENT_MODEL SVDEBUG << "AlignmentModel::toReference(" << frame << ")" << endl; @@ -150,8 +150,8 @@ return align(m_path, frame); } -size_t -AlignmentModel::fromReference(size_t frame) const +int +AlignmentModel::fromReference(int frame) const { #ifdef DEBUG_ALIGNMENT_MODEL SVDEBUG << "AlignmentModel::fromReference(" << frame << ")" << endl; @@ -175,7 +175,7 @@ } void -AlignmentModel::pathChanged(size_t, size_t) +AlignmentModel::pathChanged(int, int) { if (!m_pathComplete) return; constructPath(); @@ -277,8 +277,8 @@ #endif } -size_t -AlignmentModel::align(PathModel *path, size_t frame) const +int +AlignmentModel::align(PathModel *path, int frame) const { if (!path) return frame; @@ -330,7 +330,7 @@ if (foundMapFrame < 0) return 0; - size_t resultFrame = foundMapFrame; + int resultFrame = foundMapFrame; if (followingFrame != foundFrame && long(frame) > foundFrame) { float interp = diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/AlignmentModel.h --- a/data/model/AlignmentModel.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/AlignmentModel.h Wed Jun 18 13:51:16 2014 +0100 @@ -37,9 +37,9 @@ ~AlignmentModel(); virtual bool isOK() const; - virtual size_t getStartFrame() const; - virtual size_t getEndFrame() const; - virtual size_t getSampleRate() const; + virtual int getStartFrame() const; + virtual int getEndFrame() const; + virtual int getSampleRate() const; virtual Model *clone() const; virtual bool isReady(int *completion = 0) const; virtual const ZoomConstraint *getZoomConstraint() const; @@ -49,8 +49,8 @@ const Model *getReferenceModel() const; const Model *getAlignedModel() const; - size_t toReference(size_t frame) const; - size_t fromReference(size_t frame) const; + int toReference(int frame) const; + int fromReference(int frame) const; void setPath(PathModel *path); @@ -60,12 +60,12 @@ signals: void modelChanged(); - void modelChanged(size_t startFrame, size_t endFrame); + void modelChanged(int startFrame, int endFrame); void completionChanged(); protected slots: void pathChanged(); - void pathChanged(size_t startFrame, size_t endFrame); + void pathChanged(int startFrame, int endFrame); void pathCompletionChanged(); protected: @@ -83,7 +83,7 @@ void constructPath() const; void constructReversePath() const; - size_t align(PathModel *path, size_t frame) const; + int align(PathModel *path, int frame) const; }; #endif diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/Dense3DModelPeakCache.cpp --- a/data/model/Dense3DModelPeakCache.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/Dense3DModelPeakCache.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -18,7 +18,7 @@ #include "base/Profiler.h" Dense3DModelPeakCache::Dense3DModelPeakCache(DenseThreeDimensionalModel *source, - size_t columnsPerPeak) : + int columnsPerPeak) : m_source(source), m_resolution(columnsPerPeak) { @@ -44,7 +44,7 @@ } bool -Dense3DModelPeakCache::isColumnAvailable(size_t column) const +Dense3DModelPeakCache::isColumnAvailable(int column) const { if (!m_source) return false; if (haveColumn(column)) return true; @@ -58,7 +58,7 @@ } Dense3DModelPeakCache::Column -Dense3DModelPeakCache::getColumn(size_t column) const +Dense3DModelPeakCache::getColumn(int column) const { Profiler profiler("Dense3DModelPeakCache::getColumn"); if (!m_source) return Column(); @@ -67,7 +67,7 @@ } float -Dense3DModelPeakCache::getValueAt(size_t column, size_t n) const +Dense3DModelPeakCache::getValueAt(int column, int n) const { if (!m_source) return 0.f; if (!haveColumn(column)) fillColumn(column); @@ -93,29 +93,29 @@ } bool -Dense3DModelPeakCache::haveColumn(size_t column) const +Dense3DModelPeakCache::haveColumn(int column) const { - return column < m_coverage.size() && m_coverage.get(column); + return column < (int)m_coverage.size() && m_coverage.get(column); } void -Dense3DModelPeakCache::fillColumn(size_t column) const +Dense3DModelPeakCache::fillColumn(int column) const { Profiler profiler("Dense3DModelPeakCache::fillColumn"); - if (column >= m_coverage.size()) { + if (column >= (int)m_coverage.size()) { // see note in sourceModelChanged if (m_coverage.size() > 0) m_coverage.reset(m_coverage.size()-1); m_coverage.resize(column + 1); } Column peak; - for (int i = 0; i < m_resolution; ++i) { + for (int i = 0; i < int(m_resolution); ++i) { Column here = m_source->getColumn(column * m_resolution + i); if (i == 0) { peak = here; } else { - for (int j = 0; j < peak.size() && j < here.size(); ++j) { + for (int j = 0; j < (int)peak.size() && j < (int)here.size(); ++j) { if (here[j] > peak[j]) peak[j] = here[j]; } } diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/Dense3DModelPeakCache.h --- a/data/model/Dense3DModelPeakCache.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/Dense3DModelPeakCache.h Wed Jun 18 13:51:16 2014 +0100 @@ -26,22 +26,22 @@ public: Dense3DModelPeakCache(DenseThreeDimensionalModel *source, - size_t columnsPerPeak); + int columnsPerPeak); ~Dense3DModelPeakCache(); virtual bool isOK() const { return m_source && m_source->isOK(); } - virtual size_t getSampleRate() const { + virtual int getSampleRate() const { return m_source->getSampleRate(); } - virtual size_t getStartFrame() const { + virtual int getStartFrame() const { return m_source->getStartFrame(); } - virtual size_t getEndFrame() const { + virtual int getEndFrame() const { return m_source->getEndFrame(); } @@ -49,15 +49,15 @@ return new Dense3DModelPeakCache(m_source, m_resolution); } - virtual size_t getResolution() const { + virtual int getResolution() const { return m_source->getResolution() * m_resolution; } - virtual size_t getWidth() const { + virtual int getWidth() const { return m_source->getWidth() / m_resolution + 1; } - virtual size_t getHeight() const { + virtual int getHeight() const { return m_source->getHeight(); } @@ -69,13 +69,13 @@ return m_source->getMaximumLevel(); } - virtual bool isColumnAvailable(size_t column) const; + virtual bool isColumnAvailable(int column) const; - virtual Column getColumn(size_t column) const; + virtual Column getColumn(int column) const; - virtual float getValueAt(size_t column, size_t n) const; + virtual float getValueAt(int column, int n) const; - virtual QString getBinName(size_t n) const { + virtual QString getBinName(int n) const { return m_source->getBinName(n); } @@ -97,10 +97,10 @@ DenseThreeDimensionalModel *m_source; mutable EditableDenseThreeDimensionalModel *m_cache; mutable ResizeableBitset m_coverage; - size_t m_resolution; + int m_resolution; - bool haveColumn(size_t column) const; - void fillColumn(size_t column) const; + bool haveColumn(int column) const; + void fillColumn(int column) const; }; diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/DenseThreeDimensionalModel.h --- a/data/model/DenseThreeDimensionalModel.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/DenseThreeDimensionalModel.h Wed Jun 18 13:51:16 2014 +0100 @@ -33,17 +33,17 @@ /** * Return the number of sample frames covered by each column of bins. */ - virtual size_t getResolution() const = 0; + virtual int getResolution() const = 0; /** * Return the number of columns of bins in the model. */ - virtual size_t getWidth() const = 0; + virtual int getWidth() const = 0; /** * Return the number of bins in each column. */ - virtual size_t getHeight() const = 0; + virtual int getHeight() const = 0; /** * Return the minimum permissible value in each bin. @@ -62,25 +62,25 @@ * If this function returns false, it may still be possible to * retrieve the column, but its values may have to be calculated. */ - virtual bool isColumnAvailable(size_t column) const = 0; + virtual bool isColumnAvailable(int column) const = 0; typedef QVector Column; /** * Get data from the given column of bin values. */ - virtual Column getColumn(size_t column) const = 0; + virtual Column getColumn(int column) const = 0; /** * Get the single data point from the n'th bin of the given column. */ - virtual float getValueAt(size_t column, size_t n) const = 0; + virtual float getValueAt(int column, int n) const = 0; /** * Get the name of a given bin (i.e. a label to associate with * that bin across all columns). */ - virtual QString getBinName(size_t n) const = 0; + virtual QString getBinName(int n) const = 0; /** * Return true if the bins have values as well as names. If this @@ -93,7 +93,7 @@ * value which does not vary from one column to the next. This is * only meaningful if hasBinValues() returns true. */ - virtual float getBinValue(size_t n) const { return n; } + virtual float getBinValue(int n) const { return n; } /** * Obtain the name of the unit of the values returned from @@ -111,7 +111,7 @@ * Utility function to query whether a given bin is greater than * its (vertical) neighbours. */ - bool isLocalPeak(size_t x, size_t y) { + bool isLocalPeak(int x, int y) { float value = getValueAt(x, y); if (y > 0 && value < getValueAt(x, y - 1)) return false; if (y < getHeight() - 1 && value < getValueAt(x, y + 1)) return false; @@ -122,7 +122,7 @@ * Utility function to query whether a given bin is greater than a * certain threshold. */ - bool isOverThreshold(size_t x, size_t y, float threshold) { + bool isOverThreshold(int x, int y, float threshold) { return getValueAt(x, y) > threshold; } diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/DenseTimeValueModel.cpp --- a/data/model/DenseTimeValueModel.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/DenseTimeValueModel.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -29,32 +29,32 @@ } QString -DenseTimeValueModel::toDelimitedDataString(QString delimiter, size_t f0, size_t f1) const +DenseTimeValueModel::toDelimitedDataStringSubset(QString delimiter, int f0, int f1) const { - size_t ch = getChannelCount(); + int ch = getChannelCount(); cerr << "f0 = " << f0 << ", f1 = " << f1 << endl; if (f1 <= f0) return ""; float **all = new float *[ch]; - for (size_t c = 0; c < ch; ++c) { + for (int c = 0; c < ch; ++c) { all[c] = new float[f1 - f0]; } - size_t n = getData(0, ch - 1, f0, f1 - f0, all); + int n = getData(0, ch - 1, f0, f1 - f0, all); QStringList list; - for (size_t i = 0; i < n; ++i) { + for (int i = 0; i < n; ++i) { QStringList parts; parts << QString("%1").arg(f0 + i); - for (size_t c = 0; c < ch; ++c) { + for (int c = 0; c < ch; ++c) { parts << QString("%1").arg(all[c][i]); } list << parts.join(delimiter); } - for (size_t c = 0; c < ch; ++c) { + for (int c = 0; c < ch; ++c) { delete[] all[c]; } delete[] all; diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/DenseTimeValueModel.h --- a/data/model/DenseTimeValueModel.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/DenseTimeValueModel.h Wed Jun 18 13:51:16 2014 +0100 @@ -53,7 +53,7 @@ /** * Return the number of distinct channels for this model. */ - virtual size_t getChannelCount() const = 0; + virtual int getChannelCount() const = 0; /** * Get the specified set of samples from the given channel of the @@ -62,7 +62,7 @@ * If the channel is given as -1, mix all available channels and * return the result. */ - virtual size_t getData(int channel, size_t start, size_t count, + virtual int getData(int channel, int start, int count, float *buffer) const = 0; /** @@ -72,7 +72,7 @@ * If the channel is given as -1, mix all available channels and * return the result. */ - virtual size_t getData(int channel, size_t start, size_t count, + virtual int getData(int channel, int start, int count, double *buffer) const = 0; /** @@ -80,14 +80,14 @@ * of channels of the model in single-precision floating-point * format. Return the number of sample frames actually retrieved. */ - virtual size_t getData(size_t fromchannel, size_t tochannel, - size_t start, size_t count, + virtual int getData(int fromchannel, int tochannel, + int start, int count, float **buffers) const = 0; virtual bool canPlay() const { return true; } virtual QString getDefaultPlayClipId() const { return ""; } - virtual QString toDelimitedDataString(QString delimiter, size_t f0, size_t f1) const; + virtual QString toDelimitedDataStringSubset(QString delimiter, int f0, int f1) const; QString getTypeName() const { return tr("Dense Time-Value"); } }; diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/EditableDenseThreeDimensionalModel.cpp --- a/data/model/EditableDenseThreeDimensionalModel.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/EditableDenseThreeDimensionalModel.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -29,9 +29,9 @@ #include "system/System.h" -EditableDenseThreeDimensionalModel::EditableDenseThreeDimensionalModel(size_t sampleRate, - size_t resolution, - size_t yBinCount, +EditableDenseThreeDimensionalModel::EditableDenseThreeDimensionalModel(int sampleRate, + int resolution, + int yBinCount, CompressionType compression, bool notifyOnAdd) : m_startFrame(0), @@ -55,25 +55,25 @@ return true; } -size_t +int EditableDenseThreeDimensionalModel::getSampleRate() const { return m_sampleRate; } -size_t +int EditableDenseThreeDimensionalModel::getStartFrame() const { return m_startFrame; } void -EditableDenseThreeDimensionalModel::setStartFrame(size_t f) +EditableDenseThreeDimensionalModel::setStartFrame(int f) { m_startFrame = f; } -size_t +int EditableDenseThreeDimensionalModel::getEndFrame() const { return m_resolution * m_data.size() + (m_resolution - 1); @@ -92,39 +92,39 @@ model->m_maximum = m_maximum; model->m_haveExtents = m_haveExtents; - for (size_t i = 0; i < m_data.size(); ++i) { + for (int i = 0; i < m_data.size(); ++i) { model->setColumn(i, m_data.at(i)); } return model; } -size_t +int EditableDenseThreeDimensionalModel::getResolution() const { return m_resolution; } void -EditableDenseThreeDimensionalModel::setResolution(size_t sz) +EditableDenseThreeDimensionalModel::setResolution(int sz) { m_resolution = sz; } -size_t +int EditableDenseThreeDimensionalModel::getWidth() const { return m_data.size(); } -size_t +int EditableDenseThreeDimensionalModel::getHeight() const { return m_yBinCount; } void -EditableDenseThreeDimensionalModel::setHeight(size_t sz) +EditableDenseThreeDimensionalModel::setHeight(int sz) { m_yBinCount = sz; } @@ -154,28 +154,28 @@ } EditableDenseThreeDimensionalModel::Column -EditableDenseThreeDimensionalModel::getColumn(size_t index) const +EditableDenseThreeDimensionalModel::getColumn(int index) const { QReadLocker locker(&m_lock); - if (index >= m_data.size()) return Column(); + if (int(index) >= m_data.size()) return Column(); return expandAndRetrieve(index); } float -EditableDenseThreeDimensionalModel::getValueAt(size_t index, size_t n) const +EditableDenseThreeDimensionalModel::getValueAt(int index, int n) const { Column c = getColumn(index); - if (n < c.size()) return c.at(n); + if (int(n) < c.size()) return c.at(n); return m_minimum; } //static int given = 0, stored = 0; void -EditableDenseThreeDimensionalModel::truncateAndStore(size_t index, +EditableDenseThreeDimensionalModel::truncateAndStore(int index, const Column &values) { - assert(index < m_data.size()); + assert(int(index) < m_data.size()); //cout << "truncateAndStore(" << index << ", " << values.size() << ")" << endl; @@ -187,7 +187,7 @@ m_trunc[index] = 0; if (index == 0 || m_compression == NoCompression || - values.size() != m_yBinCount) { + values.size() != int(m_yBinCount)) { // given += values.size(); // stored += values.size(); m_data[index] = values; @@ -283,11 +283,11 @@ } EditableDenseThreeDimensionalModel::Column -EditableDenseThreeDimensionalModel::expandAndRetrieve(size_t index) const +EditableDenseThreeDimensionalModel::expandAndRetrieve(int index) const { // See comment above m_trunc declaration in header - assert(index < m_data.size()); + assert(int(index) < m_data.size()); Column c = m_data.at(index); if (index == 0) { return c; @@ -301,7 +301,7 @@ if (trunc < 0) { top = false; tdist = -trunc; } Column p = expandAndRetrieve(index - tdist); int psize = p.size(), csize = c.size(); - if (psize != m_yBinCount) { + if (psize != int(m_yBinCount)) { cerr << "WARNING: EditableDenseThreeDimensionalModel::expandAndRetrieve: Trying to expand from incorrectly sized column" << endl; } if (top) { @@ -326,12 +326,12 @@ } void -EditableDenseThreeDimensionalModel::setColumn(size_t index, +EditableDenseThreeDimensionalModel::setColumn(int index, const Column &values) { QWriteLocker locker(&m_lock); - while (index >= m_data.size()) { + while (int(index) >= m_data.size()) { m_data.push_back(Column()); m_trunc.push_back(0); } @@ -340,7 +340,7 @@ // if (values.size() > m_yBinCount) m_yBinCount = values.size(); - for (size_t i = 0; i < values.size(); ++i) { + for (int i = 0; i < values.size(); ++i) { float value = values[i]; if (ISNAN(value) || ISINF(value)) { continue; @@ -367,7 +367,7 @@ if (allChange) { emit modelChanged(); } else { - emit modelChanged(windowStart, windowStart + m_resolution); + emit modelChangedWithin(windowStart, windowStart + m_resolution); } } else { if (allChange) { @@ -388,16 +388,16 @@ } QString -EditableDenseThreeDimensionalModel::getBinName(size_t n) const +EditableDenseThreeDimensionalModel::getBinName(int n) const { - if (m_binNames.size() > n) return m_binNames[n]; + if ((int)m_binNames.size() > n) return m_binNames[n]; else return ""; } void -EditableDenseThreeDimensionalModel::setBinName(size_t n, QString name) +EditableDenseThreeDimensionalModel::setBinName(int n, QString name) { - while (m_binNames.size() <= n) m_binNames.push_back(""); + while ((int)m_binNames.size() <= n) m_binNames.push_back(""); m_binNames[n] = name; emit modelChanged(); } @@ -416,9 +416,9 @@ } float -EditableDenseThreeDimensionalModel::getBinValue(size_t n) const +EditableDenseThreeDimensionalModel::getBinValue(int n) const { - if (n < m_binValues.size()) return m_binValues[n]; + if (n < (int)m_binValues.size()) return m_binValues[n]; else return 0.f; } @@ -449,7 +449,7 @@ QVector n; for (int i = 0; i < 10; ++i) { - size_t index = i * 10; + int index = i * 10; if (index < m_data.size()) { const Column &c = m_data.at(index); while (c.size() > sample.size()) { @@ -487,8 +487,8 @@ if (update && m_sinceLastNotifyMin >= 0 && m_sinceLastNotifyMax >= 0) { - emit modelChanged(m_sinceLastNotifyMin, - m_sinceLastNotifyMax + m_resolution); + emit modelChangedWithin(m_sinceLastNotifyMin, + m_sinceLastNotifyMax + m_resolution); m_sinceLastNotifyMin = m_sinceLastNotifyMax = -1; } else { emit completionChanged(); @@ -504,9 +504,9 @@ { QReadLocker locker(&m_lock); QString s; - for (size_t i = 0; i < m_data.size(); ++i) { + for (int i = 0; i < m_data.size(); ++i) { QStringList list; - for (size_t j = 0; j < m_data.at(i).size(); ++j) { + for (int j = 0; j < m_data.at(i).size(); ++j) { list << QString("%1").arg(m_data.at(i).at(j)); } s += list.join(delimiter) + "\n"; @@ -515,15 +515,15 @@ } QString -EditableDenseThreeDimensionalModel::toDelimitedDataString(QString delimiter, size_t f0, size_t f1) const +EditableDenseThreeDimensionalModel::toDelimitedDataStringSubset(QString delimiter, int f0, int f1) const { QReadLocker locker(&m_lock); QString s; - for (size_t i = 0; i < m_data.size(); ++i) { - size_t fr = m_startFrame + i * m_resolution; - if (fr >= f0 && fr < f1) { + for (int i = 0; i < m_data.size(); ++i) { + int fr = m_startFrame + i * m_resolution; + if (fr >= int(f0) && fr < int(f1)) { QStringList list; - for (size_t j = 0; j < m_data.at(i).size(); ++j) { + for (int j = 0; j < m_data.at(i).size(); ++j) { list << QString("%1").arg(m_data.at(i).at(j)); } s += list.join(delimiter) + "\n"; @@ -558,7 +558,7 @@ out << QString("\n") .arg(getObjectExportId(&m_data)); - for (size_t i = 0; i < m_binNames.size(); ++i) { + for (int i = 0; i < (int)m_binNames.size(); ++i) { if (m_binNames[i] != "") { out << indent + " "; out << QString("\n") @@ -566,10 +566,10 @@ } } - for (size_t i = 0; i < m_data.size(); ++i) { + for (int i = 0; i < (int)m_data.size(); ++i) { out << indent + " "; out << QString("").arg(i); - for (size_t j = 0; j < m_data.at(i).size(); ++j) { + for (int j = 0; j < (int)m_data.at(i).size(); ++j) { if (j > 0) out << " "; out << m_data.at(i).at(j); } diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/EditableDenseThreeDimensionalModel.h --- a/data/model/EditableDenseThreeDimensionalModel.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/EditableDenseThreeDimensionalModel.h Wed Jun 18 13:51:16 2014 +0100 @@ -42,17 +42,17 @@ BasicMultirateCompression }; - EditableDenseThreeDimensionalModel(size_t sampleRate, - size_t resolution, - size_t yBinCount, + EditableDenseThreeDimensionalModel(int sampleRate, + int resolution, + int yBinCount, CompressionType compression, bool notifyOnAdd = true); virtual bool isOK() const; - virtual size_t getSampleRate() const; - virtual size_t getStartFrame() const; - virtual size_t getEndFrame() const; + virtual int getSampleRate() const; + virtual int getStartFrame() const; + virtual int getEndFrame() const; virtual Model *clone() const; @@ -60,32 +60,32 @@ /** * Set the frame offset of the first column. */ - virtual void setStartFrame(size_t); + virtual void setStartFrame(int); /** * Return the number of sample frames covered by each set of bins. */ - virtual size_t getResolution() const; + virtual int getResolution() const; /** * Set the number of sample frames covered by each set of bins. */ - virtual void setResolution(size_t sz); + virtual void setResolution(int sz); /** * Return the number of columns. */ - virtual size_t getWidth() const; + virtual int getWidth() const; /** * Return the number of bins in each set of bins. */ - virtual size_t getHeight() const; + virtual int getHeight() const; /** * Set the number of bins in each set of bins. */ - virtual void setHeight(size_t sz); + virtual void setHeight(int sz); /** * Return the minimum value of the value in each bin. @@ -110,33 +110,33 @@ /** * Return true if there are data available for the given column. */ - virtual bool isColumnAvailable(size_t x) const { return x < getWidth(); } + virtual bool isColumnAvailable(int x) const { return x < getWidth(); } /** * Get the set of bin values at the given column. */ - virtual Column getColumn(size_t x) const; + virtual Column getColumn(int x) const; /** * Get a single value, from the n'th bin of the given column. */ - virtual float getValueAt(size_t x, size_t n) const; + virtual float getValueAt(int x, int n) const; /** * Set the entire set of bin values at the given column. */ - virtual void setColumn(size_t x, const Column &values); + virtual void setColumn(int x, const Column &values); /** * Return the name of bin n. This is a single label per bin that * does not vary from one column to the next. */ - virtual QString getBinName(size_t n) const; + virtual QString getBinName(int n) const; /** * Set the name of bin n. */ - virtual void setBinName(size_t n, QString); + virtual void setBinName(int n, QString); /** * Set the names of all bins. @@ -156,7 +156,7 @@ * value which does not vary from one column to the next. This is * only meaningful if hasBinValues() returns true. */ - virtual float getBinValue(size_t n) const; + virtual float getBinValue(int n) const; /** * Set the values of all bins (separate from their labels). These @@ -190,7 +190,7 @@ QString getTypeName() const { return tr("Editable Dense 3-D"); } virtual QString toDelimitedDataString(QString delimiter) const; - virtual QString toDelimitedDataString(QString delimiter, size_t f0, size_t f1) const; + virtual QString toDelimitedDataStringSubset(QString delimiter, int f0, int f1) const; virtual void toXml(QTextStream &out, QString indent = "", @@ -209,17 +209,17 @@ // value). If m_trunc[x] is 0 then the whole of column x is // stored. std::vector m_trunc; - void truncateAndStore(size_t index, const Column & values); - Column expandAndRetrieve(size_t index) const; + void truncateAndStore(int index, const Column & values); + Column expandAndRetrieve(int index) const; std::vector m_binNames; std::vector m_binValues; QString m_binValueUnit; - size_t m_startFrame; - size_t m_sampleRate; - size_t m_resolution; - size_t m_yBinCount; + int m_startFrame; + int m_sampleRate; + int m_resolution; + int m_yBinCount; CompressionType m_compression; float m_minimum; float m_maximum; diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/FFTModel.cpp --- a/data/model/FFTModel.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/FFTModel.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -31,12 +31,12 @@ FFTModel::FFTModel(const DenseTimeValueModel *model, int channel, WindowType windowType, - size_t windowSize, - size_t windowIncrement, - size_t fftSize, + int windowSize, + int windowIncrement, + int fftSize, bool polar, StorageAdviser::Criteria criteria, - size_t fillFromColumn) : + int fillFromColumn) : //!!! ZoomConstraint! m_server(0), m_xshift(0), @@ -56,8 +56,8 @@ if (!m_server) return; // caller should check isOK() - size_t xratio = windowIncrement / m_server->getWindowIncrement(); - size_t yratio = m_server->getFFTSize() / fftSize; + int xratio = windowIncrement / m_server->getWindowIncrement(); + int yratio = m_server->getFFTSize() / fftSize; while (xratio > 1) { if (xratio & 0x1) { @@ -105,12 +105,12 @@ FFTModel::getServer(const DenseTimeValueModel *model, int channel, WindowType windowType, - size_t windowSize, - size_t windowIncrement, - size_t fftSize, + int windowSize, + int windowIncrement, + int fftSize, bool polar, StorageAdviser::Criteria criteria, - size_t fillFromColumn) + int fillFromColumn) { // Obviously, an FFT model of channel C (where C != -1) of an // aggregate model is the same as the FFT model of the appropriate @@ -159,21 +159,21 @@ fillFromColumn); } -size_t +int FFTModel::getSampleRate() const { return isOK() ? m_server->getModel()->getSampleRate() : 0; } FFTModel::Column -FFTModel::getColumn(size_t x) const +FFTModel::getColumn(int x) const { Profiler profiler("FFTModel::getColumn", false); Column result; result.clear(); - size_t h = getHeight(); + int h = getHeight(); result.reserve(h); #ifdef __GNUC__ @@ -184,34 +184,34 @@ if (m_server->getMagnitudesAt(x << m_xshift, magnitudes)) { - for (size_t y = 0; y < h; ++y) { + for (int y = 0; y < h; ++y) { result.push_back(magnitudes[y]); } } else { - for (size_t i = 0; i < h; ++i) result.push_back(0.f); + for (int i = 0; i < h; ++i) result.push_back(0.f); } return result; } QString -FFTModel::getBinName(size_t n) const +FFTModel::getBinName(int n) const { - size_t sr = getSampleRate(); + int sr = getSampleRate(); if (!sr) return ""; QString name = tr("%1 Hz").arg((n * sr) / ((getHeight()-1) * 2)); return name; } bool -FFTModel::estimateStableFrequency(size_t x, size_t y, float &frequency) +FFTModel::estimateStableFrequency(int x, int y, float &frequency) { if (!isOK()) return false; - size_t sampleRate = m_server->getModel()->getSampleRate(); + int sampleRate = m_server->getModel()->getSampleRate(); - size_t fftSize = m_server->getFFTSize() >> m_yshift; + int fftSize = m_server->getFFTSize() >> m_yshift; frequency = (float(y) * sampleRate) / fftSize; if (x+1 >= getWidth()) return false; @@ -228,7 +228,7 @@ float oldPhase = getPhaseAt(x, y); float newPhase = getPhaseAt(x+1, y); - size_t incr = getResolution(); + int incr = getResolution(); float expectedPhase = oldPhase + (2.0 * M_PI * y * incr) / fftSize; @@ -247,7 +247,7 @@ } FFTModel::PeakLocationSet -FFTModel::getPeaks(PeakPickType type, size_t x, size_t ymin, size_t ymax) +FFTModel::getPeaks(PeakPickType type, int x, int ymin, int ymax) { Profiler profiler("FFTModel::getPeaks"); @@ -270,7 +270,7 @@ float *values = (float *)alloca(n * sizeof(float)); #endif getMagnitudesAt(x, values, minbin, maxbin - minbin + 1); - for (size_t bin = ymin; bin <= ymax; ++bin) { + for (int bin = ymin; bin <= ymax; ++bin) { if (bin == minbin || bin == maxbin) continue; if (values[bin - minbin] > values[bin - minbin - 1] && values[bin - minbin] > values[bin - minbin + 1]) { @@ -291,26 +291,26 @@ // exceed the median. For pitch adaptivity, we adjust the window // size to a roughly constant pitch range (about four tones). - size_t sampleRate = getSampleRate(); + int sampleRate = getSampleRate(); std::deque window; - std::vector inrange; + std::vector inrange; float dist = 0.5; - size_t medianWinSize = getPeakPickWindowSize(type, sampleRate, ymin, dist); - size_t halfWin = medianWinSize/2; + int medianWinSize = getPeakPickWindowSize(type, sampleRate, ymin, dist); + int halfWin = medianWinSize/2; - size_t binmin; + int binmin; if (ymin > halfWin) binmin = ymin - halfWin; else binmin = 0; - size_t binmax; + int binmax; if (ymax + halfWin < values.size()) binmax = ymax + halfWin; else binmax = values.size()-1; - size_t prevcentre = 0; + int prevcentre = 0; - for (size_t bin = binmin; bin <= binmax; ++bin) { + for (int bin = binmin; bin <= binmax; ++bin) { float value = values[bin]; @@ -320,11 +320,11 @@ medianWinSize = getPeakPickWindowSize(type, sampleRate, bin, dist); halfWin = medianWinSize/2; - while (window.size() > medianWinSize) { + while ((int)window.size() > medianWinSize) { window.pop_front(); } - size_t actualSize = window.size(); + int actualSize = window.size(); if (type == MajorPitchAdaptivePeaks) { if (ymax + halfWin < values.size()) binmax = ymax + halfWin; @@ -335,7 +335,7 @@ std::sort(sorted.begin(), sorted.end()); float median = sorted[int(sorted.size() * dist)]; - size_t centrebin = 0; + int centrebin = 0; if (bin > actualSize/2) centrebin = bin - actualSize/2; while (centrebin > prevcentre || bin == binmin) { @@ -350,9 +350,9 @@ if (centre <= median || centrebin+1 == values.size()) { if (!inrange.empty()) { - size_t peakbin = 0; + int peakbin = 0; float peakval = 0.f; - for (size_t i = 0; i < inrange.size(); ++i) { + for (int i = 0; i < (int)inrange.size(); ++i) { if (i == 0 || values[inrange[i]] > peakval) { peakval = values[inrange[i]]; peakbin = inrange[i]; @@ -372,15 +372,15 @@ return peaks; } -size_t -FFTModel::getPeakPickWindowSize(PeakPickType type, size_t sampleRate, - size_t bin, float &percentile) const +int +FFTModel::getPeakPickWindowSize(PeakPickType type, int sampleRate, + int bin, float &percentile) const { percentile = 0.5; if (type == MajorPeaks) return 10; if (bin == 0) return 3; - size_t fftSize = m_server->getFFTSize() >> m_yshift; + int fftSize = m_server->getFFTSize() >> m_yshift; float binfreq = (sampleRate * bin) / fftSize; float hifreq = Pitch::getFrequencyForPitch(73, 0, binfreq); @@ -394,8 +394,8 @@ } FFTModel::PeakSet -FFTModel::getPeakFrequencies(PeakPickType type, size_t x, - size_t ymin, size_t ymax) +FFTModel::getPeakFrequencies(PeakPickType type, int x, + int ymin, int ymax) { Profiler profiler("FFTModel::getPeakFrequencies"); @@ -403,9 +403,9 @@ if (!isOK()) return peaks; PeakLocationSet locations = getPeaks(type, x, ymin, ymax); - size_t sampleRate = getSampleRate(); - size_t fftSize = m_server->getFFTSize() >> m_yshift; - size_t incr = getResolution(); + int sampleRate = getSampleRate(); + int fftSize = m_server->getFFTSize() >> m_yshift; + int incr = getResolution(); // This duplicates some of the work of estimateStableFrequency to // allow us to retrieve the phases in two separate vertical @@ -418,7 +418,7 @@ phases.push_back(getPhaseAt(x, *i)); } - size_t phaseIndex = 0; + int phaseIndex = 0; for (PeakLocationSet::iterator i = locations.begin(); i != locations.end(); ++i) { float oldPhase = phases[phaseIndex]; diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/FFTModel.h --- a/data/model/FFTModel.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/FFTModel.h Wed Jun 18 13:51:16 2014 +0100 @@ -58,54 +58,54 @@ FFTModel(const DenseTimeValueModel *model, int channel, WindowType windowType, - size_t windowSize, - size_t windowIncrement, - size_t fftSize, + int windowSize, + int windowIncrement, + int fftSize, bool polar, StorageAdviser::Criteria criteria = StorageAdviser::NoCriteria, - size_t fillFromColumn = 0); + int fillFromColumn = 0); ~FFTModel(); - inline float getMagnitudeAt(size_t x, size_t y) { + inline float getMagnitudeAt(int x, int y) { return m_server->getMagnitudeAt(x << m_xshift, y << m_yshift); } - inline float getNormalizedMagnitudeAt(size_t x, size_t y) { + inline float getNormalizedMagnitudeAt(int x, int y) { return m_server->getNormalizedMagnitudeAt(x << m_xshift, y << m_yshift); } - inline float getMaximumMagnitudeAt(size_t x) { + inline float getMaximumMagnitudeAt(int x) { return m_server->getMaximumMagnitudeAt(x << m_xshift); } - inline float getPhaseAt(size_t x, size_t y) { + inline float getPhaseAt(int x, int y) { return m_server->getPhaseAt(x << m_xshift, y << m_yshift); } - inline void getValuesAt(size_t x, size_t y, float &real, float &imaginary) { + inline void getValuesAt(int x, int y, float &real, float &imaginary) { m_server->getValuesAt(x << m_xshift, y << m_yshift, real, imaginary); } - inline bool isColumnAvailable(size_t x) const { + inline bool isColumnAvailable(int x) const { return m_server->isColumnReady(x << m_xshift); } - inline bool getMagnitudesAt(size_t x, float *values, size_t minbin = 0, size_t count = 0) { + inline bool getMagnitudesAt(int x, float *values, int minbin = 0, int count = 0) { return m_server->getMagnitudesAt(x << m_xshift, values, minbin << m_yshift, count, getYRatio()); } - inline bool getNormalizedMagnitudesAt(size_t x, float *values, size_t minbin = 0, size_t count = 0) { + inline bool getNormalizedMagnitudesAt(int x, float *values, int minbin = 0, int count = 0) { return m_server->getNormalizedMagnitudesAt(x << m_xshift, values, minbin << m_yshift, count, getYRatio()); } - inline bool getPhasesAt(size_t x, float *values, size_t minbin = 0, size_t count = 0) { + inline bool getPhasesAt(int x, float *values, int minbin = 0, int count = 0) { return m_server->getPhasesAt(x << m_xshift, values, minbin << m_yshift, count, getYRatio()); } - inline bool getValuesAt(size_t x, float *reals, float *imaginaries, size_t minbin = 0, size_t count = 0) { + inline bool getValuesAt(int x, float *reals, float *imaginaries, int minbin = 0, int count = 0) { return m_server->getValuesAt(x << m_xshift, reals, imaginaries, minbin << m_yshift, count, getYRatio()); } - inline size_t getFillExtent() const { return m_server->getFillExtent(); } + inline int getFillExtent() const { return m_server->getFillExtent(); } // DenseThreeDimensionalModel and Model methods: // - inline virtual size_t getWidth() const { + inline virtual int getWidth() const { return m_server->getWidth() >> m_xshift; } - inline virtual size_t getHeight() const { + inline virtual int getHeight() const { // If there is no y-shift, the server's height (based on its // fftsize/2 + 1) is correct. If there is a shift, then the // server is using a larger fft size than we want, so we shift @@ -114,23 +114,23 @@ // fftsize/2 + 1). return (m_server->getHeight() >> m_yshift) + (m_yshift > 0 ? 1 : 0); } - virtual float getValueAt(size_t x, size_t y) const { + virtual float getValueAt(int x, int y) const { return const_cast(this)->getMagnitudeAt(x, y); } virtual bool isOK() const { return m_server && m_server->getModel(); } - virtual size_t getStartFrame() const { + virtual int getStartFrame() const { return 0; } - virtual size_t getEndFrame() const { + virtual int getEndFrame() const { return getWidth() * getResolution() + getResolution(); } - virtual size_t getSampleRate() const; - virtual size_t getResolution() const { + virtual int getSampleRate() const; + virtual int getResolution() const { return m_server->getWindowIncrement() << m_xshift; } - virtual size_t getYBinCount() const { + virtual int getYBinCount() const { return getHeight(); } virtual float getMinimumLevel() const { @@ -139,8 +139,8 @@ virtual float getMaximumLevel() const { return 1.f; // Can't provide } - virtual Column getColumn(size_t x) const; - virtual QString getBinName(size_t n) const; + virtual Column getColumn(int x) const; + virtual QString getBinName(int n) const; virtual bool shouldUseLogValueScale() const { return true; // Although obviously it's up to the user... @@ -151,7 +151,7 @@ * bin, using phase unwrapping. This will be completely wrong if * the signal is not stable here. */ - virtual bool estimateStableFrequency(size_t x, size_t y, float &frequency); + virtual bool estimateStableFrequency(int x, int y, float &frequency); enum PeakPickType { @@ -160,21 +160,21 @@ MajorPitchAdaptivePeaks /// Bigger window for higher frequencies }; - typedef std::set PeakLocationSet; // bin - typedef std::map PeakSet; // bin -> freq + typedef std::set PeakLocationSet; // bin + typedef std::map PeakSet; // bin -> freq /** * Return locations of peak bins in the range [ymin,ymax]. If * ymax is zero, getHeight()-1 will be used. */ - virtual PeakLocationSet getPeaks(PeakPickType type, size_t x, - size_t ymin = 0, size_t ymax = 0); + virtual PeakLocationSet getPeaks(PeakPickType type, int x, + int ymin = 0, int ymax = 0); /** * Return locations and estimated stable frequencies of peak bins. */ - virtual PeakSet getPeakFrequencies(PeakPickType type, size_t x, - size_t ymin = 0, size_t ymax = 0); + virtual PeakSet getPeakFrequencies(PeakPickType type, int x, + int ymin = 0, int ymax = 0); virtual int getCompletion() const { return m_server->getFillCompletion(); } virtual QString getError() const { return m_server->getError(); } @@ -199,15 +199,15 @@ int m_yshift; FFTDataServer *getServer(const DenseTimeValueModel *, - int, WindowType, size_t, size_t, size_t, - bool, StorageAdviser::Criteria, size_t); + int, WindowType, int, int, int, + bool, StorageAdviser::Criteria, int); - size_t getPeakPickWindowSize(PeakPickType type, size_t sampleRate, - size_t bin, float &percentile) const; + int getPeakPickWindowSize(PeakPickType type, int sampleRate, + int bin, float &percentile) const; - size_t getYRatio() { - size_t ys = m_yshift; - size_t r = 1; + int getYRatio() { + int ys = m_yshift; + int r = 1; while (ys) { --ys; r <<= 1; } return r; } diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/FlexiNoteModel.h --- a/data/model/FlexiNoteModel.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/FlexiNoteModel.h Wed Jun 18 13:51:16 2014 +0100 @@ -43,14 +43,14 @@ { public: FlexiNote(long _frame) : frame(_frame), value(0.0f), duration(0), level(1.f) { } - FlexiNote(long _frame, float _value, size_t _duration, float _level, QString _label) : + FlexiNote(long _frame, float _value, int _duration, float _level, QString _label) : frame(_frame), value(_value), duration(_duration), level(_level), label(_label) { } int getDimensions() const { return 3; } long frame; float value; - size_t duration; + int duration; float level; QString label; @@ -66,7 +66,7 @@ .arg(XmlExportable::encodeEntities(label)).arg(extraAttributes); } - QString toDelimitedDataString(QString delimiter, size_t sampleRate) const + QString toDelimitedDataString(QString delimiter, int sampleRate) const { QStringList list; list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); @@ -102,7 +102,7 @@ Q_OBJECT public: - FlexiNoteModel(size_t sampleRate, size_t resolution, + FlexiNoteModel(int sampleRate, int resolution, bool notifyOnAdd = true) : IntervalModel(sampleRate, resolution, notifyOnAdd), m_valueQuantization(0) @@ -110,7 +110,7 @@ PlayParameterRepository::getInstance()->addPlayable(this); } - FlexiNoteModel(size_t sampleRate, size_t resolution, + FlexiNoteModel(int sampleRate, int resolution, float valueMinimum, float valueMaximum, bool notifyOnAdd = true) : IntervalModel(sampleRate, resolution, @@ -228,15 +228,15 @@ NoteList getNotes() const { - return getNotes(getStartFrame(), getEndFrame()); + return getNotesWithin(getStartFrame(), getEndFrame()); } - NoteList getNotes(size_t startFrame, size_t endFrame) const + NoteList getNotesWithin(int startFrame, int endFrame) const { PointList points = getPoints(startFrame, endFrame); NoteList notes; for (PointList::iterator pli = points.begin(); pli != points.end(); ++pli) { - size_t duration = pli->duration; + int duration = pli->duration; if (duration == 0 || duration == 1) { duration = getSampleRate() / 20; } diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/ImageModel.h --- a/data/model/ImageModel.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/ImageModel.h Wed Jun 18 13:51:16 2014 +0100 @@ -55,7 +55,7 @@ .arg(extraAttributes); } - QString toDelimitedDataString(QString delimiter, size_t sampleRate) const + QString toDelimitedDataString(QString delimiter, int sampleRate) const { QStringList list; list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); @@ -89,7 +89,7 @@ Q_OBJECT public: - ImageModel(size_t sampleRate, size_t resolution, bool notifyOnAdd = true) : + ImageModel(int sampleRate, int resolution, bool notifyOnAdd = true) : SparseModel(sampleRate, resolution, notifyOnAdd) { } diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/IntervalModel.h --- a/data/model/IntervalModel.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/IntervalModel.h Wed Jun 18 13:51:16 2014 +0100 @@ -29,12 +29,12 @@ class IntervalModel : public SparseValueModel { public: - IntervalModel(size_t sampleRate, size_t resolution, + IntervalModel(int sampleRate, int resolution, bool notifyOnAdd = true) : SparseValueModel(sampleRate, resolution, notifyOnAdd) { } - IntervalModel(size_t sampleRate, size_t resolution, + IntervalModel(int sampleRate, int resolution, float valueMinimum, float valueMaximum, bool notifyOnAdd = true) : SparseValueModel(sampleRate, resolution, diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/Labeller.h --- a/data/model/Labeller.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/Labeller.h Wed Jun 18 13:51:16 2014 +0100 @@ -292,7 +292,7 @@ } else if (!prevPoint) { std::cerr << "ERROR: Labeller::getValueFor: Time difference required, but only one point provided" << std::endl; } else { - size_t f0 = prevPoint->frame, f1 = newPoint.frame; + int f0 = prevPoint->frame, f1 = newPoint.frame; if (m_type == ValueFromDurationToNext || m_type == ValueFromDurationFromPrevious) { value = float(f1 - f0) / m_rate; diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/Model.cpp --- a/data/model/Model.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/Model.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -106,27 +106,27 @@ return m_alignment->getReferenceModel(); } -size_t -Model::alignToReference(size_t frame) const +int +Model::alignToReference(int frame) const { if (!m_alignment) { if (m_sourceModel) return m_sourceModel->alignToReference(frame); else return frame; } - size_t refFrame = m_alignment->toReference(frame); + int refFrame = m_alignment->toReference(frame); const Model *m = m_alignment->getReferenceModel(); if (m && refFrame > m->getEndFrame()) refFrame = m->getEndFrame(); return refFrame; } -size_t -Model::alignFromReference(size_t refFrame) const +int +Model::alignFromReference(int refFrame) const { if (!m_alignment) { if (m_sourceModel) return m_sourceModel->alignFromReference(refFrame); else return refFrame; } - size_t frame = m_alignment->fromReference(refFrame); + int frame = m_alignment->fromReference(refFrame); if (frame > getEndFrame()) frame = getEndFrame(); return frame; } diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/Model.h --- a/data/model/Model.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/Model.h Wed Jun 18 13:51:16 2014 +0100 @@ -50,23 +50,23 @@ /** * Return the first audio frame spanned by the model. */ - virtual size_t getStartFrame() const = 0; + virtual int getStartFrame() const = 0; /** * Return the last audio frame spanned by the model. */ - virtual size_t getEndFrame() const = 0; + virtual int getEndFrame() const = 0; /** * Return the frame rate in frames per second. */ - virtual size_t getSampleRate() const = 0; + virtual int getSampleRate() const = 0; /** * Return the frame rate of the underlying material, if the model * itself has already been resampled. */ - virtual size_t getNativeRate() const { return getSampleRate(); } + virtual int getNativeRate() const { return getSampleRate(); } /** * Return the "work title" of the model, if known. @@ -105,7 +105,27 @@ * Caller owns the returned value. */ virtual Model *clone() const = 0; - + + /** + * Mark the model as abandoning. This means that the application + * no longer needs it, so it can stop doing any background + * calculations it may be involved in. Note that as far as the + * model API is concerned, this does nothing more than tell the + * model to return true from isAbandoning(). The actual response + * to this will depend on the model's context -- it's possible + * nothing at all will change. + */ + virtual void abandon() { + m_abandoning = true; + } + + /** + * Query whether the model has been marked as abandoning. + */ + virtual bool isAbandoning() const { + return m_abandoning; + } + /** * Return true if the model has finished loading or calculating * all its data, for a model that is capable of calculating in a @@ -180,13 +200,13 @@ * Return the frame number of the reference model that corresponds * to the given frame number in this model. */ - virtual size_t alignToReference(size_t frame) const; + virtual int alignToReference(int frame) const; /** * Return the frame number in this model that corresponds to the * given frame number of the reference model. */ - virtual size_t alignFromReference(size_t referenceFrame) const; + virtual int alignFromReference(int referenceFrame) const; /** * Return the completion percentage for the alignment model: 100 @@ -214,9 +234,9 @@ QString extraAttributes = "") const; virtual QString toDelimitedDataString(QString delimiter) const { - return toDelimitedDataString(delimiter, getStartFrame(), getEndFrame()); + return toDelimitedDataStringSubset(delimiter, getStartFrame(), getEndFrame()); } - virtual QString toDelimitedDataString(QString, size_t /* f0 */, size_t /* f1 */) const { + virtual QString toDelimitedDataStringSubset(QString, int /* f0 */, int /* f1 */) const { return ""; } @@ -235,7 +255,7 @@ * Emitted when a model has been edited (or more data retrieved * from cache, in the case of a cached model that generates slowly) */ - void modelChanged(size_t startFrame, size_t endFrame); + void modelChangedWithin(int startFrame, int endFrame); /** * Emitted when some internal processing has advanced a stage, but @@ -268,7 +288,11 @@ void aboutToBeDeleted(); protected: - Model() : m_sourceModel(0), m_alignment(0), m_aboutToDelete(false) { } + Model() : + m_sourceModel(0), + m_alignment(0), + m_abandoning(false), + m_aboutToDelete(false) { } // Not provided. Model(const Model &); @@ -277,6 +301,7 @@ Model *m_sourceModel; AlignmentModel *m_alignment; QString m_typeUri; + bool m_abandoning; bool m_aboutToDelete; }; diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/ModelDataTableModel.cpp --- a/data/model/ModelDataTableModel.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/ModelDataTableModel.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -31,8 +31,8 @@ Model *baseModel = dynamic_cast(m); connect(baseModel, SIGNAL(modelChanged()), this, SLOT(modelChanged())); - connect(baseModel, SIGNAL(modelChanged(size_t, size_t)), - this, SLOT(modelChanged(size_t, size_t))); + connect(baseModel, SIGNAL(modelChanged(int, int)), + this, SLOT(modelChanged(int, int))); connect(baseModel, SIGNAL(aboutToBeDeleted()), this, SLOT(modelAboutToBeDeleted())); } @@ -105,7 +105,7 @@ } Qt::ItemFlags -ModelDataTableModel::flags(const QModelIndex &index) const +ModelDataTableModel::flags(const QModelIndex &) const { Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsSelectable; @@ -127,13 +127,13 @@ } QModelIndex -ModelDataTableModel::index(int row, int column, const QModelIndex &parent) const +ModelDataTableModel::index(int row, int column, const QModelIndex &) const { return createIndex(row, column, (void *)0); } QModelIndex -ModelDataTableModel::parent(const QModelIndex &index) const +ModelDataTableModel::parent(const QModelIndex &) const { return QModelIndex(); } @@ -155,14 +155,14 @@ } QModelIndex -ModelDataTableModel::getModelIndexForFrame(size_t frame) const +ModelDataTableModel::getModelIndexForFrame(int frame) const { if (!m_model) return createIndex(0, 0); int row = m_model->getRowForFrame(frame); return createIndex(getSorted(row), 0, (void *)0); } -size_t +int ModelDataTableModel::getFrameForModelIndex(const QModelIndex &index) const { if (!m_model) return 0; @@ -219,7 +219,7 @@ } void -ModelDataTableModel::modelChanged(size_t f0, size_t f1) +ModelDataTableModel::modelChanged(int, int) { //!!! inefficient clearSort(); @@ -250,7 +250,7 @@ resort(); } int result = 0; - if (row >= 0 && row < m_sort.size()) { + if (row >= 0 && row < (int)m_sort.size()) { result = m_sort[row]; } if (m_sortOrdering == Qt::DescendingOrder) { @@ -278,7 +278,7 @@ } int result = 0; - if (row >= 0 && row < m_sort.size()) { + if (row >= 0 && row < (int)m_sort.size()) { if (m_sortOrdering == Qt::AscendingOrder) { result = m_rsort[row]; } else { @@ -309,7 +309,7 @@ // rsort maps from sorted row number to original row number - for (int i = 0; i < m_rsort.size(); ++i) { + for (int i = 0; i < (int)m_rsort.size(); ++i) { tmp[m_rsort[i]] = i; } diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/ModelDataTableModel.h --- a/data/model/ModelDataTableModel.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/ModelDataTableModel.h Wed Jun 18 13:51:16 2014 +0100 @@ -51,8 +51,8 @@ int rowCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const; - QModelIndex getModelIndexForFrame(size_t frame) const; - size_t getFrameForModelIndex(const QModelIndex &) const; + QModelIndex getModelIndexForFrame(int frame) const; + int getFrameForModelIndex(const QModelIndex &) const; void sort(int column, Qt::SortOrder order = Qt::AscendingOrder); @@ -62,14 +62,14 @@ int getCurrentRow() const; signals: - void frameSelected(size_t); + void frameSelected(int); void addCommand(Command *); void currentChanged(const QModelIndex &); void modelRemoved(); protected slots: void modelChanged(); - void modelChanged(size_t, size_t); + void modelChanged(int, int); void modelAboutToBeDeleted(); protected: diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/NoteData.h --- a/data/model/NoteData.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/NoteData.h Wed Jun 18 13:51:16 2014 +0100 @@ -21,12 +21,12 @@ struct NoteData { - NoteData(size_t _start, size_t _dur, int _mp, int _vel) : + NoteData(int _start, int _dur, int _mp, int _vel) : start(_start), duration(_dur), midiPitch(_mp), frequency(0), isMidiPitchQuantized(true), velocity(_vel) { }; - size_t start; // audio sample frame - size_t duration; // in audio sample frames + int start; // audio sample frame + int duration; // in audio sample frames int midiPitch; // 0-127 float frequency; // Hz, to be used if isMidiPitchQuantized false bool isMidiPitchQuantized; @@ -47,7 +47,7 @@ { public: virtual NoteList getNotes() const = 0; - virtual NoteList getNotes(size_t startFrame, size_t endFrame) const = 0; + virtual NoteList getNotesWithin(int startFrame, int endFrame) const = 0; }; #endif diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/NoteModel.h --- a/data/model/NoteModel.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/NoteModel.h Wed Jun 18 13:51:16 2014 +0100 @@ -39,14 +39,14 @@ { public: Note(long _frame) : frame(_frame), value(0.0f), duration(0), level(1.f) { } - Note(long _frame, float _value, size_t _duration, float _level, QString _label) : + Note(long _frame, float _value, int _duration, float _level, QString _label) : frame(_frame), value(_value), duration(_duration), level(_level), label(_label) { } int getDimensions() const { return 3; } long frame; float value; - size_t duration; + int duration; float level; QString label; @@ -62,7 +62,7 @@ .arg(XmlExportable::encodeEntities(label)).arg(extraAttributes); } - QString toDelimitedDataString(QString delimiter, size_t sampleRate) const + QString toDelimitedDataString(QString delimiter, int sampleRate) const { QStringList list; list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); @@ -98,7 +98,7 @@ Q_OBJECT public: - NoteModel(size_t sampleRate, size_t resolution, + NoteModel(int sampleRate, int resolution, bool notifyOnAdd = true) : IntervalModel(sampleRate, resolution, notifyOnAdd), m_valueQuantization(0) @@ -106,7 +106,7 @@ PlayParameterRepository::getInstance()->addPlayable(this); } - NoteModel(size_t sampleRate, size_t resolution, + NoteModel(int sampleRate, int resolution, float valueMinimum, float valueMaximum, bool notifyOnAdd = true) : IntervalModel(sampleRate, resolution, @@ -221,10 +221,10 @@ */ NoteList getNotes() const { - return getNotes(getStartFrame(), getEndFrame()); + return getNotesWithin(getStartFrame(), getEndFrame()); } - NoteList getNotes(size_t startFrame, size_t endFrame) const { + NoteList getNotesWithin(int startFrame, int endFrame) const { PointList points = getPoints(startFrame, endFrame); NoteList notes; @@ -232,7 +232,7 @@ for (PointList::iterator pli = points.begin(); pli != points.end(); ++pli) { - size_t duration = pli->duration; + int duration = pli->duration; if (duration == 0 || duration == 1) { duration = getSampleRate() / 20; } diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/PathModel.h --- a/data/model/PathModel.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/PathModel.h Wed Jun 18 13:51:16 2014 +0100 @@ -43,7 +43,7 @@ } QString toDelimitedDataString(QString delimiter, - size_t sampleRate) const { + int sampleRate) const { QStringList list; list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); list << QString("%1").arg(mapframe); @@ -67,7 +67,7 @@ class PathModel : public SparseModel { public: - PathModel(size_t sampleRate, size_t resolution, bool notify = true) : + PathModel(int sampleRate, int resolution, bool notify = true) : SparseModel(sampleRate, resolution, notify) { } virtual void toXml(QTextStream &out, diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/PowerOfSqrtTwoZoomConstraint.cpp --- a/data/model/PowerOfSqrtTwoZoomConstraint.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/PowerOfSqrtTwoZoomConstraint.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -19,26 +19,26 @@ #include -size_t -PowerOfSqrtTwoZoomConstraint::getNearestBlockSize(size_t blockSize, +int +PowerOfSqrtTwoZoomConstraint::getNearestBlockSize(int blockSize, RoundingDirection dir) const { int type, power; - size_t rv = getNearestBlockSize(blockSize, type, power, dir); + int rv = getNearestBlockSize(blockSize, type, power, dir); return rv; } -size_t -PowerOfSqrtTwoZoomConstraint::getNearestBlockSize(size_t blockSize, +int +PowerOfSqrtTwoZoomConstraint::getNearestBlockSize(int blockSize, int &type, int &power, RoundingDirection dir) const { // cerr << "given " << blockSize << endl; - size_t minCachePower = getMinCachePower(); + int minCachePower = getMinCachePower(); - if (blockSize < (1U << minCachePower)) { + if (blockSize < (1 << minCachePower)) { type = -1; power = 0; float val = 1.0, prevVal = 1.0; @@ -46,27 +46,27 @@ prevVal = val; val *= sqrt(2.f); } - size_t rval; - if (dir == RoundUp) rval = size_t(val + 0.01); - else if (dir == RoundDown) rval = size_t(prevVal + 0.01); - else if (val - blockSize < blockSize - prevVal) rval = size_t(val + 0.01); - else rval = size_t(prevVal + 0.01); + int rval; + if (dir == RoundUp) rval = int(val + 0.01); + else if (dir == RoundDown) rval = int(prevVal + 0.01); + else if (val - blockSize < blockSize - prevVal) rval = int(val + 0.01); + else rval = int(prevVal + 0.01); // SVDEBUG << "returning " << rval << endl; return rval; } - unsigned int prevBase = (1 << minCachePower); - unsigned int prevPower = minCachePower; - unsigned int prevType = 0; + int prevBase = (1 << minCachePower); + int prevPower = minCachePower; + int prevType = 0; - size_t result = 0; + int result = 0; for (unsigned int i = 0; ; ++i) { power = minCachePower + i/2; type = i % 2; - unsigned int base; + int base; if (type == 0) { base = (1 << power); } else { diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/PowerOfSqrtTwoZoomConstraint.h --- a/data/model/PowerOfSqrtTwoZoomConstraint.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/PowerOfSqrtTwoZoomConstraint.h Wed Jun 18 13:51:16 2014 +0100 @@ -21,17 +21,17 @@ class PowerOfSqrtTwoZoomConstraint : virtual public ZoomConstraint { public: - virtual size_t getNearestBlockSize(size_t requestedBlockSize, + virtual int getNearestBlockSize(int requestedBlockSize, RoundingDirection dir = RoundNearest) const; - virtual size_t getNearestBlockSize(size_t requestedBlockSize, + virtual int getNearestBlockSize(int requestedBlockSize, int &type, int &power, RoundingDirection dir = RoundNearest) const; - virtual size_t getMinCachePower() const { return 6; } + virtual int getMinCachePower() const { return 6; } }; #endif diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/PowerOfTwoZoomConstraint.cpp --- a/data/model/PowerOfTwoZoomConstraint.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/PowerOfTwoZoomConstraint.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -15,13 +15,13 @@ #include "PowerOfTwoZoomConstraint.h" -size_t -PowerOfTwoZoomConstraint::getNearestBlockSize(size_t req, +int +PowerOfTwoZoomConstraint::getNearestBlockSize(int req, RoundingDirection dir) const { - size_t result = 0; + int result = 0; - for (size_t bs = 1; ; bs *= 2) { + for (int bs = 1; ; bs *= 2) { if (bs >= req) { if (dir == RoundNearest) { if (bs - req < req - bs/2) { diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/PowerOfTwoZoomConstraint.h --- a/data/model/PowerOfTwoZoomConstraint.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/PowerOfTwoZoomConstraint.h Wed Jun 18 13:51:16 2014 +0100 @@ -21,7 +21,7 @@ class PowerOfTwoZoomConstraint : virtual public ZoomConstraint { public: - virtual size_t getNearestBlockSize(size_t requestedBlockSize, + virtual int getNearestBlockSize(int requestedBlockSize, RoundingDirection dir = RoundNearest) const; }; diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/RangeSummarisableTimeValueModel.h --- a/data/model/RangeSummarisableTimeValueModel.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/RangeSummarisableTimeValueModel.h Wed Jun 18 13:51:16 2014 +0100 @@ -74,18 +74,18 @@ * parameter so as to return the block size that was actually * obtained. */ - virtual void getSummaries(size_t channel, size_t start, size_t count, + virtual void getSummaries(int channel, int start, int count, RangeBlock &ranges, - size_t &blockSize) const = 0; + int &blockSize) const = 0; /** * Return the range from the given start frame, corresponding to * the given number of underlying sample frames, summarised at a * block size equal to the distance between start and end frames. */ - virtual Range getSummary(size_t channel, size_t start, size_t count) const = 0; + virtual Range getSummary(int channel, int start, int count) const = 0; - virtual size_t getSummaryBlockSize(size_t desired) const = 0; + virtual int getSummaryBlockSize(int desired) const = 0; QString getTypeName() const { return tr("Range-Summarisable Time-Value"); } }; diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/RegionModel.h --- a/data/model/RegionModel.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/RegionModel.h Wed Jun 18 13:51:16 2014 +0100 @@ -38,14 +38,14 @@ public: RegionRec() : frame(0), value(0.f), duration(0) { } RegionRec(long _frame) : frame(_frame), value(0.0f), duration(0) { } - RegionRec(long _frame, float _value, size_t _duration, QString _label) : + RegionRec(long _frame, float _value, int _duration, QString _label) : frame(_frame), value(_value), duration(_duration), label(_label) { } int getDimensions() const { return 3; } long frame; float value; - size_t duration; + int duration; QString label; QString getLabel() const { return label; } @@ -60,7 +60,7 @@ .arg(XmlExportable::encodeEntities(label)).arg(extraAttributes); } - QString toDelimitedDataString(QString delimiter, size_t sampleRate) const + QString toDelimitedDataString(QString delimiter, int sampleRate) const { QStringList list; list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); @@ -94,7 +94,7 @@ Q_OBJECT public: - RegionModel(size_t sampleRate, size_t resolution, + RegionModel(int sampleRate, int resolution, bool notifyOnAdd = true) : IntervalModel(sampleRate, resolution, notifyOnAdd), m_valueQuantization(0), @@ -102,7 +102,7 @@ { } - RegionModel(size_t sampleRate, size_t resolution, + RegionModel(int sampleRate, int resolution, float valueMinimum, float valueMaximum, bool notifyOnAdd = true) : IntervalModel(sampleRate, resolution, diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/SparseModel.h --- a/data/model/SparseModel.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/SparseModel.h Wed Jun 18 13:51:16 2014 +0100 @@ -43,14 +43,14 @@ public TabularModel { public: - SparseModel(size_t sampleRate, size_t resolution, + SparseModel(int sampleRate, int resolution, bool notifyOnAdd = true); virtual ~SparseModel() { } virtual bool isOK() const { return true; } - virtual size_t getStartFrame() const; - virtual size_t getEndFrame() const; - virtual size_t getSampleRate() const { return m_sampleRate; } + virtual int getStartFrame() const; + virtual int getEndFrame() const; + virtual int getSampleRate() const { return m_sampleRate; } virtual Model *clone() const; @@ -59,10 +59,10 @@ // then every point in this model will be at a multiple of 10 // sample frames and should be considered to cover a window ending // 10 sample frames later. - virtual size_t getResolution() const { + virtual int getResolution() const { return m_resolution ? m_resolution : 1; } - virtual void setResolution(size_t resolution); + virtual void setResolution(int resolution); typedef PointType Point; typedef std::multiset int(m_rows.size())) return m_points.end(); - size_t frame = m_rows[row]; + int frame = m_rows[row]; int indexAtFrame = 0; int ri = row; while (ri > 0 && m_rows[ri-1] == m_rows[row]) { --ri; ++indexAtFrame; } @@ -434,7 +434,7 @@ if (m_rows.empty()) rebuildRowVector(); if (row < 0 || row + 1 > int(m_rows.size())) return m_points.end(); - size_t frame = m_rows[row]; + int frame = m_rows[row]; int indexAtFrame = 0; int ri = row; while (ri > 0 && m_rows[ri-1] == m_rows[row]) { --ri; ++indexAtFrame; } @@ -465,8 +465,8 @@ template -SparseModel::SparseModel(size_t sampleRate, - size_t resolution, +SparseModel::SparseModel(int sampleRate, + int resolution, bool notifyOnAdd) : m_sampleRate(sampleRate), m_resolution(resolution), @@ -480,11 +480,11 @@ } template -size_t +int SparseModel::getStartFrame() const { QMutexLocker locker(&m_mutex); - size_t f = 0; + int f = 0; if (!m_points.empty()) { f = m_points.begin()->frame; } @@ -492,11 +492,11 @@ } template -size_t +int SparseModel::getEndFrame() const { QMutexLocker locker(&m_mutex); - size_t f = 0; + int f = 0; if (!m_points.empty()) { PointListConstIterator i(m_points.end()); f = (--i)->frame; @@ -526,7 +526,7 @@ } template -size_t +int SparseModel::getPointCount() const { return m_pointCount; @@ -676,7 +676,7 @@ template void -SparseModel::setResolution(size_t resolution) +SparseModel::setResolution(int resolution) { { QMutexLocker locker(&m_mutex); @@ -718,7 +718,7 @@ if (m_notifyOnAdd) { m_rows.clear(); //!!! inefficient - emit modelChanged(point.frame, point.frame + m_resolution); + emit modelChangedWithin(point.frame, point.frame + m_resolution); } else { if (m_sinceLastNotifyMin == -1 || point.frame < m_sinceLastNotifyMin) { @@ -753,7 +753,7 @@ // std::cout << "SparseOneDimensionalModel: emit modelChanged(" // << point.frame << ")" << std::endl; m_rows.clear(); //!!! inefficient - emit modelChanged(point.frame, point.frame + m_resolution); + emit modelChangedWithin(point.frame, point.frame + m_resolution); } template @@ -781,7 +781,7 @@ m_sinceLastNotifyMin >= 0 && m_sinceLastNotifyMax >= 0) { m_rows.clear(); //!!! inefficient - emit modelChanged(m_sinceLastNotifyMin, m_sinceLastNotifyMax); + emit modelChangedWithin(m_sinceLastNotifyMin, m_sinceLastNotifyMax); m_sinceLastNotifyMin = m_sinceLastNotifyMax = -1; } else { emit completionChanged(); diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/SparseOneDimensionalModel.h --- a/data/model/SparseOneDimensionalModel.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/SparseOneDimensionalModel.h Wed Jun 18 13:51:16 2014 +0100 @@ -26,12 +26,12 @@ struct OneDimensionalPoint { public: - OneDimensionalPoint(long _frame) : frame(_frame) { } - OneDimensionalPoint(long _frame, QString _label) : frame(_frame), label(_label) { } + OneDimensionalPoint(int _frame) : frame(_frame) { } + OneDimensionalPoint(int _frame, QString _label) : frame(_frame), label(_label) { } int getDimensions() const { return 1; } - long frame; + int frame; QString label; QString getLabel() const { return label; } @@ -45,7 +45,7 @@ .arg(extraAttributes); } - QString toDelimitedDataString(QString delimiter, size_t sampleRate) const + QString toDelimitedDataString(QString delimiter, int sampleRate) const { QStringList list; list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); @@ -76,7 +76,7 @@ Q_OBJECT public: - SparseOneDimensionalModel(size_t sampleRate, size_t resolution, + SparseOneDimensionalModel(int sampleRate, int resolution, bool notifyOnAdd = true) : SparseModel(sampleRate, resolution, notifyOnAdd) { @@ -184,10 +184,10 @@ */ NoteList getNotes() const { - return getNotes(getStartFrame(), getEndFrame()); + return getNotesWithin(getStartFrame(), getEndFrame()); } - NoteList getNotes(size_t startFrame, size_t endFrame) const { + NoteList getNotesWithin(int startFrame, int endFrame) const { PointList points = getPoints(startFrame, endFrame); NoteList notes; diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/SparseTimeValueModel.h --- a/data/model/SparseTimeValueModel.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/SparseTimeValueModel.h Wed Jun 18 13:51:16 2014 +0100 @@ -49,7 +49,7 @@ .arg(extraAttributes); } - QString toDelimitedDataString(QString delimiter, size_t sampleRate) const + QString toDelimitedDataString(QString delimiter, int sampleRate) const { QStringList list; list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); @@ -81,7 +81,7 @@ Q_OBJECT public: - SparseTimeValueModel(size_t sampleRate, size_t resolution, + SparseTimeValueModel(int sampleRate, int resolution, bool notifyOnAdd = true) : SparseValueModel(sampleRate, resolution, notifyOnAdd) @@ -91,7 +91,7 @@ PlayParameterRepository::getInstance()->addPlayable(this); } - SparseTimeValueModel(size_t sampleRate, size_t resolution, + SparseTimeValueModel(int sampleRate, int resolution, float valueMinimum, float valueMaximum, bool notifyOnAdd = true) : SparseValueModel(sampleRate, resolution, diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/SparseValueModel.h --- a/data/model/SparseValueModel.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/SparseValueModel.h Wed Jun 18 13:51:16 2014 +0100 @@ -31,7 +31,7 @@ class SparseValueModel : public SparseModel { public: - SparseValueModel(size_t sampleRate, size_t resolution, + SparseValueModel(int sampleRate, int resolution, bool notifyOnAdd = true) : SparseModel(sampleRate, resolution, notifyOnAdd), m_valueMinimum(0.f), @@ -39,7 +39,7 @@ m_haveExtents(false) { } - SparseValueModel(size_t sampleRate, size_t resolution, + SparseValueModel(int sampleRate, int resolution, float valueMinimum, float valueMaximum, bool notifyOnAdd = true) : SparseModel(sampleRate, resolution, notifyOnAdd), diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/TextModel.h --- a/data/model/TextModel.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/TextModel.h Wed Jun 18 13:51:16 2014 +0100 @@ -51,7 +51,7 @@ .arg(encodeEntities(label)).arg(extraAttributes); } - QString toDelimitedDataString(QString delimiter, size_t sampleRate) const + QString toDelimitedDataString(QString delimiter, int sampleRate) const { QStringList list; list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); @@ -85,7 +85,7 @@ Q_OBJECT public: - TextModel(size_t sampleRate, size_t resolution, bool notifyOnAdd = true) : + TextModel(int sampleRate, int resolution, bool notifyOnAdd = true) : SparseModel(sampleRate, resolution, notifyOnAdd) { } diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/WaveFileModel.cpp --- a/data/model/WaveFileModel.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/WaveFileModel.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -20,6 +20,8 @@ #include "system/System.h" +#include "base/Preferences.h" + #include #include @@ -35,7 +37,7 @@ PowerOfSqrtTwoZoomConstraint WaveFileModel::m_zoomConstraint; -WaveFileModel::WaveFileModel(FileSource source, size_t targetRate) : +WaveFileModel::WaveFileModel(FileSource source, int targetRate) : m_source(source), m_path(source.getLocation()), m_myReader(true), @@ -49,8 +51,9 @@ { m_source.waitForData(); if (m_source.isOK()) { + bool normalise = Preferences::getInstance()->getNormaliseAudio(); m_reader = AudioFileReaderFactory::createThreadingReader - (m_source, targetRate); + (m_source, targetRate, normalise); if (m_reader) { SVDEBUG << "WaveFileModel::WaveFileModel: reader rate: " << m_reader->getSampleRate() << endl; @@ -126,32 +129,32 @@ return model; } -size_t +int WaveFileModel::getFrameCount() const { if (!m_reader) return 0; return m_reader->getFrameCount(); } -size_t +int WaveFileModel::getChannelCount() const { if (!m_reader) return 0; return m_reader->getChannelCount(); } -size_t +int WaveFileModel::getSampleRate() const { if (!m_reader) return 0; return m_reader->getSampleRate(); } -size_t +int WaveFileModel::getNativeRate() const { if (!m_reader) return 0; - size_t rate = m_reader->getNativeRate(); + int rate = m_reader->getNativeRate(); if (rate == 0) rate = getSampleRate(); return rate; } @@ -179,8 +182,8 @@ return ""; } -size_t -WaveFileModel::getData(int channel, size_t start, size_t count, +int +WaveFileModel::getData(int channel, int start, int count, float *buffer) const { // Always read these directly from the file. @@ -194,7 +197,7 @@ if (start >= m_startFrame) { start -= m_startFrame; } else { - for (size_t i = 0; i < count; ++i) buffer[i] = 0.f; + for (int i = 0; i < count; ++i) buffer[i] = 0.f; if (count <= m_startFrame - start) { return 0; } else { @@ -204,7 +207,7 @@ } if (!m_reader || !m_reader->isOK() || count == 0) { - for (size_t i = 0; i < count; ++i) buffer[i] = 0.f; + for (int i = 0; i < count; ++i) buffer[i] = 0.f; return 0; } @@ -218,7 +221,7 @@ SampleBlock frames(count * channels); m_reader->getInterleavedFrames(start, count, frames); - size_t i = 0; + int i = 0; int ch0 = channel, ch1 = channel; if (channel == -1) { @@ -232,8 +235,8 @@ for (int ch = ch0; ch <= ch1; ++ch) { - size_t index = i * channels + ch; - if (index >= frames.size()) break; + int index = i * channels + ch; + if (index >= (int)frames.size()) break; float sample = frames[index]; buffer[i] += sample; @@ -245,8 +248,8 @@ return i; } -size_t -WaveFileModel::getData(int channel, size_t start, size_t count, +int +WaveFileModel::getData(int channel, int start, int count, double *buffer) const { #ifdef DEBUG_WAVE_FILE_MODEL @@ -256,7 +259,7 @@ if (start > m_startFrame) { start -= m_startFrame; } else { - for (size_t i = 0; i < count; ++i) buffer[i] = 0.0; + for (int i = 0; i < count; ++i) buffer[i] = 0.0; if (count <= m_startFrame - start) { return 0; } else { @@ -266,7 +269,7 @@ } if (!m_reader || !m_reader->isOK() || count == 0) { - for (size_t i = 0; i < count; ++i) buffer[i] = 0.0; + for (int i = 0; i < count; ++i) buffer[i] = 0.0; return 0; } @@ -275,7 +278,7 @@ SampleBlock frames(count * channels); m_reader->getInterleavedFrames(start, count, frames); - size_t i = 0; + int i = 0; int ch0 = channel, ch1 = channel; if (channel == -1) { @@ -289,8 +292,8 @@ for (int ch = ch0; ch <= ch1; ++ch) { - size_t index = i * channels + ch; - if (index >= frames.size()) break; + int index = i * channels + ch; + if (index >= (int)frames.size()) break; float sample = frames[index]; buffer[i] += sample; @@ -302,16 +305,16 @@ return i; } -size_t -WaveFileModel::getData(size_t fromchannel, size_t tochannel, - size_t start, size_t count, +int +WaveFileModel::getData(int fromchannel, int tochannel, + int start, int count, float **buffer) const { #ifdef DEBUG_WAVE_FILE_MODEL cout << "WaveFileModel::getData[" << this << "]: " << fromchannel << "," << tochannel << ", " << start << ", " << count << ", " << buffer << endl; #endif - size_t channels = getChannelCount(); + int channels = getChannelCount(); if (fromchannel > tochannel) { cerr << "ERROR: WaveFileModel::getData: fromchannel (" @@ -331,7 +334,7 @@ return getData(fromchannel, start, count, buffer[0]); } - size_t reqchannels = (tochannel - fromchannel) + 1; + int reqchannels = (tochannel - fromchannel) + 1; // Always read these directly from the file. // This is used for e.g. audio playback. @@ -340,8 +343,8 @@ if (start >= m_startFrame) { start -= m_startFrame; } else { - for (size_t c = 0; c < reqchannels; ++c) { - for (size_t i = 0; i < count; ++i) buffer[c][i] = 0.f; + for (int c = 0; c < reqchannels; ++c) { + for (int i = 0; i < count; ++i) buffer[c][i] = 0.f; } if (count <= m_startFrame - start) { return 0; @@ -352,8 +355,8 @@ } if (!m_reader || !m_reader->isOK() || count == 0) { - for (size_t c = 0; c < reqchannels; ++c) { - for (size_t i = 0; i < count; ++i) buffer[c][i] = 0.f; + for (int c = 0; c < reqchannels; ++c) { + for (int i = 0; i < count; ++i) buffer[c][i] = 0.f; } return 0; } @@ -361,19 +364,17 @@ SampleBlock frames(count * channels); m_reader->getInterleavedFrames(start, count, frames); - size_t i = 0; + int i = 0; - int ch0 = fromchannel, ch1 = tochannel; - - size_t index = 0, available = frames.size(); + int index = 0, available = frames.size(); while (i < count) { if (index >= available) break; - size_t destc = 0; + int destc = 0; - for (size_t c = 0; c < channels; ++c) { + for (int c = 0; c < channels; ++c) { if (c >= fromchannel && c <= tochannel) { buffer[destc][i] = frames[index]; @@ -389,12 +390,12 @@ return i; } -size_t -WaveFileModel::getSummaryBlockSize(size_t desired) const +int +WaveFileModel::getSummaryBlockSize(int desired) const { int cacheType = 0; int power = m_zoomConstraint.getMinCachePower(); - size_t roundedBlockSize = m_zoomConstraint.getNearestBlockSize + int roundedBlockSize = m_zoomConstraint.getNearestBlockSize (desired, cacheType, power, ZoomConstraint::RoundDown); if (cacheType != 0 && cacheType != 1) { // We will be reading directly from file, so can satisfy any @@ -406,8 +407,8 @@ } void -WaveFileModel::getSummaries(size_t channel, size_t start, size_t count, - RangeBlock &ranges, size_t &blockSize) const +WaveFileModel::getSummaries(int channel, int start, int count, + RangeBlock &ranges, int &blockSize) const { ranges.clear(); if (!isOK()) return; @@ -422,10 +423,10 @@ int cacheType = 0; int power = m_zoomConstraint.getMinCachePower(); - size_t roundedBlockSize = m_zoomConstraint.getNearestBlockSize + int roundedBlockSize = m_zoomConstraint.getNearestBlockSize (blockSize, cacheType, power, ZoomConstraint::RoundDown); - size_t channels = getChannelCount(); + int channels = getChannelCount(); if (cacheType != 0 && cacheType != 1) { @@ -449,12 +450,12 @@ } float max = 0.0, min = 0.0, total = 0.0; - size_t i = 0, got = 0; + int i = 0, got = 0; while (i < count) { - size_t index = i * channels + channel; - if (index >= m_directRead.size()) break; + int index = i * channels + channel; + if (index >= (int)m_directRead.size()) break; float sample = m_directRead[index]; if (sample > max || got == 0) max = sample; @@ -487,7 +488,7 @@ blockSize = roundedBlockSize; - size_t cacheBlock, div; + int cacheBlock, div; if (cacheType == 0) { cacheBlock = (1 << m_zoomConstraint.getMinCachePower()); @@ -497,11 +498,11 @@ div = ((unsigned int)((1 << power) * sqrt(2.) + 0.01)) / cacheBlock; } - size_t startIndex = start / cacheBlock; - size_t endIndex = (start + count) / cacheBlock; + int startIndex = start / cacheBlock; + int endIndex = (start + count) / cacheBlock; float max = 0.0, min = 0.0, total = 0.0; - size_t i = 0, got = 0; + int i = 0, got = 0; #ifdef DEBUG_WAVE_FILE_MODEL cerr << "blockSize is " << blockSize << ", cacheBlock " << cacheBlock << ", start " << start << ", count " << count << " (frame count " << getFrameCount() << "), power is " << power << ", div is " << div << ", startIndex " << startIndex << ", endIndex " << endIndex << endl; @@ -509,8 +510,8 @@ for (i = 0; i <= endIndex - startIndex; ) { - size_t index = (i + startIndex) * channels + channel; - if (index >= cache.size()) break; + int index = (i + startIndex) * channels + channel; + if (index >= (int)cache.size()) break; const Range &range = cache[index]; if (range.max() > max || got == 0) max = range.max(); @@ -539,7 +540,7 @@ } WaveFileModel::Range -WaveFileModel::getSummary(size_t channel, size_t start, size_t count) const +WaveFileModel::getSummary(int channel, int start, int count) const { Range range; if (!isOK()) return range; @@ -551,21 +552,21 @@ start = 0; } - size_t blockSize; + int blockSize; for (blockSize = 1; blockSize <= count; blockSize *= 2); if (blockSize > 1) blockSize /= 2; bool first = false; - size_t blockStart = (start / blockSize) * blockSize; - size_t blockEnd = ((start + count) / blockSize) * blockSize; + int blockStart = (start / blockSize) * blockSize; + int blockEnd = ((start + count) / blockSize) * blockSize; if (blockStart < start) blockStart += blockSize; if (blockEnd > blockStart) { RangeBlock ranges; getSummaries(channel, blockStart, blockEnd - blockStart, ranges, blockSize); - for (size_t i = 0; i < ranges.size(); ++i) { + for (int i = 0; i < (int)ranges.size(); ++i) { if (first || ranges[i].min() < range.min()) range.setMin(ranges[i].min()); if (first || ranges[i].max() > range.max()) range.setMax(ranges[i].max()); if (first || ranges[i].absmean() < range.absmean()) range.setAbsmean(ranges[i].absmean()); @@ -614,12 +615,12 @@ WaveFileModel::fillTimerTimedOut() { if (m_fillThread) { - size_t fillExtent = m_fillThread->getFillExtent(); + int fillExtent = m_fillThread->getFillExtent(); #ifdef DEBUG_WAVE_FILE_MODEL SVDEBUG << "WaveFileModel::fillTimerTimedOut: extent = " << fillExtent << endl; #endif if (fillExtent > m_lastFillExtent) { - emit modelChanged(m_lastFillExtent, fillExtent); + emit modelChangedWithin(m_lastFillExtent, fillExtent); m_lastFillExtent = fillExtent; } } else { @@ -640,7 +641,7 @@ m_updateTimer = 0; m_mutex.unlock(); if (getEndFrame() > m_lastFillExtent) { - emit modelChanged(m_lastFillExtent, getEndFrame()); + emit modelChangedWithin(m_lastFillExtent, getEndFrame()); } emit modelChanged(); emit ready(); @@ -652,18 +653,18 @@ void WaveFileModel::RangeCacheFillThread::run() { - size_t cacheBlockSize[2]; + int cacheBlockSize[2]; cacheBlockSize[0] = (1 << m_model.m_zoomConstraint.getMinCachePower()); cacheBlockSize[1] = ((unsigned int)((1 << m_model.m_zoomConstraint.getMinCachePower()) * sqrt(2.) + 0.01)); - size_t frame = 0; + int frame = 0; int readBlockSize = 16384; SampleBlock block; if (!m_model.isOK()) return; - size_t channels = m_model.getChannelCount(); + int channels = m_model.getChannelCount(); bool updating = m_model.m_reader->isUpdating(); if (updating) { @@ -676,7 +677,7 @@ Range *range = new Range[2 * channels]; float *means = new float[2 * channels]; - size_t count[2]; + int count[2]; count[0] = count[1] = 0; for (int i = 0; i < 2 * channels; ++i) { means[i] = 0.f; @@ -703,7 +704,7 @@ for (int i = 0; i < readBlockSize; ++i) { - if (channels * i + channels > block.size()) break; + if (channels * i + channels > (int)block.size()) break; for (int ch = 0; ch < channels; ++ch) { @@ -727,12 +728,12 @@ QMutexLocker locker(&m_model.m_mutex); - for (size_t ct = 0; ct < 2; ++ct) { + for (int ct = 0; ct < 2; ++ct) { if (++count[ct] == cacheBlockSize[ct]) { - for (size_t ch = 0; ch < size_t(channels); ++ch) { - size_t rangeIndex = ch * 2 + ct; + for (int ch = 0; ch < int(channels); ++ch) { + int rangeIndex = ch * 2 + ct; means[rangeIndex] /= count[ct]; range[rangeIndex].setAbsmean(means[rangeIndex]); m_model.m_cache[ct].push_back(range[rangeIndex]); @@ -766,12 +767,12 @@ QMutexLocker locker(&m_model.m_mutex); - for (size_t ct = 0; ct < 2; ++ct) { + for (int ct = 0; ct < 2; ++ct) { if (count[ct] > 0) { - for (size_t ch = 0; ch < size_t(channels); ++ch) { - size_t rangeIndex = ch * 2 + ct; + for (int ch = 0; ch < int(channels); ++ch) { + int rangeIndex = ch * 2 + ct; means[rangeIndex] /= count[ct]; range[rangeIndex].setAbsmean(means[rangeIndex]); m_model.m_cache[ct].push_back(range[rangeIndex]); @@ -793,7 +794,7 @@ m_fillExtent = m_frameCount; #ifdef DEBUG_WAVE_FILE_MODEL - for (size_t ct = 0; ct < 2; ++ct) { + for (int ct = 0; ct < 2; ++ct) { cerr << "Cache type " << ct << " now contains " << m_model.m_cache[ct].size() << " ranges" << endl; } #endif diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/WaveFileModel.h --- a/data/model/WaveFileModel.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/WaveFileModel.h Wed Jun 18 13:51:16 2014 +0100 @@ -34,7 +34,7 @@ Q_OBJECT public: - WaveFileModel(FileSource source, size_t targetRate = 0); + WaveFileModel(FileSource source, int targetRate = 0); WaveFileModel(FileSource source, AudioFileReader *reader); ~WaveFileModel(); @@ -43,10 +43,10 @@ const ZoomConstraint *getZoomConstraint() const { return &m_zoomConstraint; } - size_t getFrameCount() const; - size_t getChannelCount() const; - size_t getSampleRate() const; - size_t getNativeRate() const; + int getFrameCount() const; + int getChannelCount() const; + int getSampleRate() const; + int getNativeRate() const; QString getTitle() const; QString getMaker() const; @@ -57,28 +57,28 @@ float getValueMinimum() const { return -1.0f; } float getValueMaximum() const { return 1.0f; } - virtual size_t getStartFrame() const { return m_startFrame; } - virtual size_t getEndFrame() const { return m_startFrame + getFrameCount(); } + virtual int getStartFrame() const { return m_startFrame; } + virtual int getEndFrame() const { return m_startFrame + getFrameCount(); } - void setStartFrame(size_t startFrame) { m_startFrame = startFrame; } + void setStartFrame(int startFrame) { m_startFrame = startFrame; } - virtual size_t getData(int channel, size_t start, size_t count, + virtual int getData(int channel, int start, int count, float *buffer) const; - virtual size_t getData(int channel, size_t start, size_t count, + virtual int getData(int channel, int start, int count, double *buffer) const; - virtual size_t getData(size_t fromchannel, size_t tochannel, - size_t start, size_t count, + virtual int getData(int fromchannel, int tochannel, + int start, int count, float **buffers) const; - virtual size_t getSummaryBlockSize(size_t desired) const; + virtual int getSummaryBlockSize(int desired) const; - virtual void getSummaries(size_t channel, size_t start, size_t count, + virtual void getSummaries(int channel, int start, int count, RangeBlock &ranges, - size_t &blockSize) const; + int &blockSize) const; - virtual Range getSummary(size_t channel, size_t start, size_t count) const; + virtual Range getSummary(int channel, int start, int count) const; QString getTypeName() const { return tr("Wave File"); } @@ -100,13 +100,13 @@ m_model(model), m_fillExtent(0), m_frameCount(model.getFrameCount()) { } - size_t getFillExtent() const { return m_fillExtent; } + int getFillExtent() const { return m_fillExtent; } virtual void run(); protected: WaveFileModel &m_model; - size_t m_fillExtent; - size_t m_frameCount; + int m_fillExtent; + int m_frameCount; }; void fillCache(); @@ -116,19 +116,19 @@ AudioFileReader *m_reader; bool m_myReader; - size_t m_startFrame; + int m_startFrame; RangeBlock m_cache[2]; // interleaved at two base resolutions mutable QMutex m_mutex; RangeCacheFillThread *m_fillThread; QTimer *m_updateTimer; - size_t m_lastFillExtent; + int m_lastFillExtent; bool m_exiting; static PowerOfSqrtTwoZoomConstraint m_zoomConstraint; mutable SampleBlock m_directRead; - mutable size_t m_lastDirectReadStart; - mutable size_t m_lastDirectReadCount; + mutable int m_lastDirectReadStart; + mutable int m_lastDirectReadCount; mutable QMutex m_directReadMutex; }; diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/WritableWaveFileModel.cpp --- a/data/model/WritableWaveFileModel.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/WritableWaveFileModel.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -30,8 +30,8 @@ //#define DEBUG_WRITABLE_WAVE_FILE_MODEL 1 -WritableWaveFileModel::WritableWaveFileModel(size_t sampleRate, - size_t channels, +WritableWaveFileModel::WritableWaveFileModel(int sampleRate, + int channels, QString path) : m_model(0), m_writer(0), @@ -86,8 +86,8 @@ m_model->setStartFrame(m_startFrame); connect(m_model, SIGNAL(modelChanged()), this, SIGNAL(modelChanged())); - connect(m_model, SIGNAL(modelChanged(size_t, size_t)), - this, SIGNAL(modelChanged(size_t, size_t))); + connect(m_model, SIGNAL(modelChanged(int, int)), + this, SIGNAL(modelChanged(int, int))); } WritableWaveFileModel::~WritableWaveFileModel() @@ -98,14 +98,14 @@ } void -WritableWaveFileModel::setStartFrame(size_t startFrame) +WritableWaveFileModel::setStartFrame(int startFrame) { m_startFrame = startFrame; if (m_model) m_model->setStartFrame(startFrame); } bool -WritableWaveFileModel::addSamples(float **samples, size_t count) +WritableWaveFileModel::addSamples(float **samples, int count) { if (!m_writer) return false; @@ -162,7 +162,7 @@ } } -size_t +int WritableWaveFileModel::getFrameCount() const { // SVDEBUG << "WritableWaveFileModel::getFrameCount: count = " << m_frameCount << endl; @@ -176,42 +176,42 @@ return 0; } -size_t -WritableWaveFileModel::getData(int channel, size_t start, size_t count, +int +WritableWaveFileModel::getData(int channel, int start, int count, float *buffer) const { if (!m_model || m_model->getChannelCount() == 0) return 0; return m_model->getData(channel, start, count, buffer); } -size_t -WritableWaveFileModel::getData(int channel, size_t start, size_t count, +int +WritableWaveFileModel::getData(int channel, int start, int count, double *buffer) const { if (!m_model || m_model->getChannelCount() == 0) return 0; return m_model->getData(channel, start, count, buffer); } -size_t -WritableWaveFileModel::getData(size_t fromchannel, size_t tochannel, - size_t start, size_t count, +int +WritableWaveFileModel::getData(int fromchannel, int tochannel, + int start, int count, float **buffers) const { if (!m_model || m_model->getChannelCount() == 0) return 0; return m_model->getData(fromchannel, tochannel, start, count, buffers); } -size_t -WritableWaveFileModel::getSummaryBlockSize(size_t desired) const +int +WritableWaveFileModel::getSummaryBlockSize(int desired) const { if (!m_model) return desired; return m_model->getSummaryBlockSize(desired); } void -WritableWaveFileModel::getSummaries(size_t channel, size_t start, size_t count, +WritableWaveFileModel::getSummaries(int channel, int start, int count, RangeBlock &ranges, - size_t &blockSize) const + int &blockSize) const { ranges.clear(); if (!m_model || m_model->getChannelCount() == 0) return; @@ -219,7 +219,7 @@ } WritableWaveFileModel::Range -WritableWaveFileModel::getSummary(size_t channel, size_t start, size_t count) const +WritableWaveFileModel::getSummary(int channel, int start, int count) const { if (!m_model || m_model->getChannelCount() == 0) return Range(); return m_model->getSummary(channel, start, count); diff -r 49618f39ff09 -r 0c1d6de8f44b data/model/WritableWaveFileModel.h --- a/data/model/WritableWaveFileModel.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/model/WritableWaveFileModel.h Wed Jun 18 13:51:16 2014 +0100 @@ -26,7 +26,7 @@ Q_OBJECT public: - WritableWaveFileModel(size_t sampleRate, size_t channels, QString path = ""); + WritableWaveFileModel(int sampleRate, int channels, QString path = ""); ~WritableWaveFileModel(); /** @@ -35,7 +35,7 @@ * progress of this file, if it has a known end point, and should * call setCompletion(100) when the file has been written. */ - virtual bool addSamples(float **samples, size_t count); + virtual bool addSamples(float **samples, int count); bool isOK() const; bool isReady(int *) const; @@ -48,36 +48,36 @@ return &zc; } - size_t getFrameCount() const; - size_t getChannelCount() const { return m_channels; } - size_t getSampleRate() const { return m_sampleRate; } + int getFrameCount() const; + int getChannelCount() const { return m_channels; } + int getSampleRate() const { return m_sampleRate; } virtual Model *clone() const; float getValueMinimum() const { return -1.0f; } float getValueMaximum() const { return 1.0f; } - virtual size_t getStartFrame() const { return m_startFrame; } - virtual size_t getEndFrame() const { return m_startFrame + getFrameCount(); } + virtual int getStartFrame() const { return m_startFrame; } + virtual int getEndFrame() const { return m_startFrame + getFrameCount(); } - void setStartFrame(size_t startFrame); + void setStartFrame(int startFrame); - virtual size_t getData(int channel, size_t start, size_t count, + virtual int getData(int channel, int start, int count, float *buffer) const; - virtual size_t getData(int channel, size_t start, size_t count, + virtual int getData(int channel, int start, int count, double *buffer) const; - virtual size_t getData(size_t fromchannel, size_t tochannel, - size_t start, size_t count, + virtual int getData(int fromchannel, int tochannel, + int start, int count, float **buffer) const; - virtual size_t getSummaryBlockSize(size_t desired) const; + virtual int getSummaryBlockSize(int desired) const; - virtual void getSummaries(size_t channel, size_t start, size_t count, - RangeBlock &ranges, size_t &blockSize) const; + virtual void getSummaries(int channel, int start, int count, + RangeBlock &ranges, int &blockSize) const; - virtual Range getSummary(size_t channel, size_t start, size_t count) const; + virtual Range getSummary(int channel, int start, int count) const; QString getTypeName() const { return tr("Writable Wave File"); } @@ -89,10 +89,10 @@ WaveFileModel *m_model; WavFileWriter *m_writer; WavFileReader *m_reader; - size_t m_sampleRate; - size_t m_channels; - size_t m_frameCount; - size_t m_startFrame; + int m_sampleRate; + int m_channels; + int m_frameCount; + int m_startFrame; int m_completion; }; diff -r 49618f39ff09 -r 0c1d6de8f44b data/osc/OSCMessage.cpp --- a/data/osc/OSCMessage.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/osc/OSCMessage.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -38,14 +38,14 @@ m_args.push_back(arg); } -size_t +int OSCMessage::getArgCount() const { return m_args.size(); } const QVariant & -OSCMessage::getArg(size_t i) const +OSCMessage::getArg(int i) const { return m_args[i]; } diff -r 49618f39ff09 -r 0c1d6de8f44b data/osc/OSCMessage.h --- a/data/osc/OSCMessage.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/osc/OSCMessage.h Wed Jun 18 13:51:16 2014 +0100 @@ -47,8 +47,8 @@ void clearArgs(); void addArg(QVariant arg); - size_t getArgCount() const; - const QVariant &getArg(size_t i) const; + int getArgCount() const; + const QVariant &getArg(int i) const; private: int m_target; diff -r 49618f39ff09 -r 0c1d6de8f44b data/osc/OSCQueue.cpp --- a/data/osc/OSCQueue.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/data/osc/OSCQueue.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -142,7 +142,7 @@ return url; } -size_t +int OSCQueue::getMessagesAvailable() const { return m_buffer.getReadSpace(); diff -r 49618f39ff09 -r 0c1d6de8f44b data/osc/OSCQueue.h --- a/data/osc/OSCQueue.h Tue Jun 03 11:05:49 2014 +0100 +++ b/data/osc/OSCQueue.h Wed Jun 18 13:51:16 2014 +0100 @@ -42,7 +42,7 @@ bool isOK() const; bool isEmpty() const { return getMessagesAvailable() == 0; } - size_t getMessagesAvailable() const; + int getMessagesAvailable() const; OSCMessage readMessage(); QString getOSCURL() const; diff -r 49618f39ff09 -r 0c1d6de8f44b plugin/DSSIPluginFactory.cpp --- a/plugin/DSSIPluginFactory.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/plugin/DSSIPluginFactory.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -281,7 +281,7 @@ void -DSSIPluginFactory::discoverPlugins(QString soname) +DSSIPluginFactory::discoverPluginsFrom(QString soname) { Profiler profiler("DSSIPluginFactory::discoverPlugins"); diff -r 49618f39ff09 -r 0c1d6de8f44b plugin/DSSIPluginFactory.h --- a/plugin/DSSIPluginFactory.h Tue Jun 03 11:05:49 2014 +0100 +++ b/plugin/DSSIPluginFactory.h Wed Jun 18 13:51:16 2014 +0100 @@ -52,7 +52,7 @@ virtual std::vector getLRDFPath(QString &baseUri); - virtual void discoverPlugins(QString soName); + virtual void discoverPluginsFrom(QString soName); virtual const LADSPA_Descriptor *getLADSPADescriptor(QString identifier); virtual const DSSI_Descriptor *getDSSIDescriptor(QString identifier); diff -r 49618f39ff09 -r 0c1d6de8f44b plugin/LADSPAPluginFactory.cpp --- a/plugin/LADSPAPluginFactory.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/plugin/LADSPAPluginFactory.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -672,13 +672,13 @@ QDir pluginDir(*i, PLUGIN_GLOB); for (unsigned int j = 0; j < pluginDir.count(); ++j) { - discoverPlugins(QString("%1/%2").arg(*i).arg(pluginDir[j])); + discoverPluginsFrom(QString("%1/%2").arg(*i).arg(pluginDir[j])); } } } void -LADSPAPluginFactory::discoverPlugins(QString soname) +LADSPAPluginFactory::discoverPluginsFrom(QString soname) { void *libraryHandle = DLOPEN(soname, RTLD_LAZY); diff -r 49618f39ff09 -r 0c1d6de8f44b plugin/LADSPAPluginFactory.h --- a/plugin/LADSPAPluginFactory.h Tue Jun 03 11:05:49 2014 +0100 +++ b/plugin/LADSPAPluginFactory.h Wed Jun 18 13:51:16 2014 +0100 @@ -67,7 +67,7 @@ virtual std::vector getLRDFPath(QString &baseUri); - virtual void discoverPlugins(QString soName); + virtual void discoverPluginsFrom(QString soName); virtual void generateTaxonomy(QString uri, QString base); virtual void generateFallbackCategories(); diff -r 49618f39ff09 -r 0c1d6de8f44b plugin/PluginXml.cpp --- a/plugin/PluginXml.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/plugin/PluginXml.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -214,7 +214,7 @@ QDomNamedNodeMap attrNodes = pluginElt.attributes(); QXmlAttributes attrs; - for (unsigned int i = 0; i < attrNodes.length(); ++i) { + for (int i = 0; i < attrNodes.length(); ++i) { QDomAttr attr = attrNodes.item(i).toAttr(); if (attr.isNull()) continue; // SVDEBUG << "PluginXml::setParametersFromXml: Adding attribute \"" << attr.name()// << "\" with value \"" << attr.value() << "\"" << endl; diff -r 49618f39ff09 -r 0c1d6de8f44b rdf/RDFFeatureWriter.cpp --- a/rdf/RDFFeatureWriter.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/rdf/RDFFeatureWriter.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -534,7 +534,7 @@ // iterate through FeatureLists - for (int i = 0; i < featureList.size(); ++i) { + for (int i = 0; i < (int)featureList.size(); ++i) { const Plugin::Feature &feature = featureList[i]; unsigned long featureNumber = m_count++; @@ -597,7 +597,7 @@ stream << ";\n"; //!!! named bins? stream << " af:feature \"" << feature.values[0]; - for (int j = 1; j < feature.values.size(); ++j) { + for (int j = 1; j < (int)feature.values.size(); ++j) { stream << " " << feature.values[j]; } stream << "\" "; @@ -609,7 +609,7 @@ void RDFFeatureWriter::writeTrackLevelRDF(QTextStream *sptr, - const Transform &transform, + const Transform &, const Plugin::OutputDescriptor& od, const Plugin::FeatureList& featureList, PluginRDFDescription &desc, @@ -618,7 +618,7 @@ if (featureList.empty()) return; QTextStream &stream = *sptr; - bool plain = (m_plain || !desc.haveDescription()); +// bool plain = (m_plain || !desc.haveDescription()); QString outputId = od.identifier.c_str(); QString featureUri = desc.getOutputFeatureAttributeURI(outputId); @@ -628,7 +628,7 @@ return; } - for (int i = 0; i < featureList.size(); ++i) { + for (int i = 0; i < (int)featureList.size(); ++i) { const Plugin::Feature &feature = featureList[i]; @@ -679,13 +679,13 @@ stream << "\n:feature_timeline_" << featureNumber << " a tl:DiscreteTimeLine .\n\n"; - size_t stepSize = transform.getStepSize(); + int stepSize = transform.getStepSize(); if (stepSize == 0) { cerr << "RDFFeatureWriter: INTERNAL ERROR: writing dense features without having set the step size properly!" << endl; return; } - size_t blockSize = transform.getBlockSize(); + int blockSize = transform.getBlockSize(); if (blockSize == 0) { cerr << "RDFFeatureWriter: INTERNAL ERROR: writing dense features without having set the block size properly!" << endl; return; @@ -756,11 +756,11 @@ QString &str = m_openDenseFeatures[sp].second; QTextStream stream(&str); - for (int i = 0; i < featureList.size(); ++i) { + for (int i = 0; i < (int)featureList.size(); ++i) { const Plugin::Feature &feature = featureList[i]; - for (int j = 0; j < feature.values.size(); ++j) { + for (int j = 0; j < (int)feature.values.size(); ++j) { stream << feature.values[j] << " "; } } diff -r 49618f39ff09 -r 0c1d6de8f44b rdf/RDFFeatureWriter.h --- a/rdf/RDFFeatureWriter.h Tue Jun 03 11:05:49 2014 +0100 +++ b/rdf/RDFFeatureWriter.h Wed Jun 18 13:51:16 2014 +0100 @@ -126,7 +126,7 @@ bool m_network; bool m_networkRetrieved; - unsigned long m_count; + long m_count; }; #endif diff -r 49618f39ff09 -r 0c1d6de8f44b rdf/RDFImporter.cpp --- a/rdf/RDFImporter.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/rdf/RDFImporter.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -576,14 +576,14 @@ RealTime time; RealTime duration; - bool haveTime = false; +// bool haveTime = false; bool haveDuration = false; Node at = m_store->complete(Triple(tn, expand("tl:at"), Node())); if (at != Node()) { time = RealTime::fromXsdDuration(at.value.toStdString()); - haveTime = true; +// haveTime = true; } else { //!!! NB we're using rather old terminology for these things, apparently: // beginsAt -> start @@ -596,7 +596,7 @@ (start.value.toStdString()); duration = RealTime::fromXsdDuration (dur.value.toStdString()); - haveTime = haveDuration = true; +// haveTime = haveDuration = true; } } diff -r 49618f39ff09 -r 0c1d6de8f44b rdf/RDFTransformFactory.cpp --- a/rdf/RDFTransformFactory.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/rdf/RDFTransformFactory.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -156,7 +156,7 @@ } std::vector -RDFTransformFactoryImpl::getTransforms(ProgressReporter *reporter) +RDFTransformFactoryImpl::getTransforms(ProgressReporter *) { std::vector transforms; @@ -215,7 +215,7 @@ "duration" }; - for (int j = 0; j < sizeof(optionals)/sizeof(optionals[0]); ++j) { + for (int j = 0; j < int(sizeof(optionals)/sizeof(optionals[0])); ++j) { QString optional = optionals[j]; diff -r 49618f39ff09 -r 0c1d6de8f44b transform/CSVFeatureWriter.cpp --- a/transform/CSVFeatureWriter.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/transform/CSVFeatureWriter.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -79,7 +79,7 @@ void CSVFeatureWriter::write(QString trackId, const Transform &transform, - const Plugin::OutputDescriptor& output, + const Plugin::OutputDescriptor& , const Plugin::FeatureList& features, std::string summaryType) { diff -r 49618f39ff09 -r 0c1d6de8f44b transform/FeatureExtractionModelTransformer.cpp --- a/transform/FeatureExtractionModelTransformer.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/transform/FeatureExtractionModelTransformer.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -112,11 +112,11 @@ TransformFactory::getInstance()->setPluginParameters (primaryTransform, m_plugin); - size_t channelCount = input->getChannelCount(); - if (m_plugin->getMaxChannelCount() < channelCount) { + int channelCount = input->getChannelCount(); + if ((int)m_plugin->getMaxChannelCount() < channelCount) { channelCount = 1; } - if (m_plugin->getMinChannelCount() > channelCount) { + if ((int)m_plugin->getMinChannelCount() > channelCount) { m_message = tr("Cannot provide enough channels to feature extraction plugin \"%1\" (plugin min is %2, max %3; input model has %4)") .arg(pluginId) .arg(m_plugin->getMinChannelCount()) @@ -133,8 +133,8 @@ primaryTransform.getStepSize(), primaryTransform.getBlockSize())) { - size_t pstep = primaryTransform.getStepSize(); - size_t pblock = primaryTransform.getBlockSize(); + int pstep = primaryTransform.getStepSize(); + int pblock = primaryTransform.getBlockSize(); ///!!! hang on, this isn't right -- we're modifying a copy primaryTransform.setStepSize(0); @@ -204,7 +204,7 @@ } } - if (m_descriptors.size() <= j) { + if ((int)m_descriptors.size() <= j) { m_message = tr("Plugin \"%1\" has no output named \"%2\"") .arg(pluginId) .arg(m_transforms[j].getOutput()); @@ -249,8 +249,8 @@ haveExtents = true; } - size_t modelRate = input->getSampleRate(); - size_t modelResolution = 1; + int modelRate = input->getSampleRate(); + int modelResolution = 1; if (m_descriptors[n]->sampleType != Vamp::Plugin::OutputDescriptor::OneSamplePerStep) { @@ -264,7 +264,7 @@ case Vamp::Plugin::OutputDescriptor::VariableSampleRate: if (m_descriptors[n]->sampleRate != 0.0) { - modelResolution = size_t(modelRate / m_descriptors[n]->sampleRate + 0.001); + modelResolution = int(modelRate / m_descriptors[n]->sampleRate + 0.001); } break; @@ -281,7 +281,7 @@ if (m_descriptors[n]->sampleRate > input->getSampleRate()) { modelResolution = 1; } else { - modelResolution = size_t(round(input->getSampleRate() / + modelResolution = int(round(input->getSampleRate() / m_descriptors[n]->sampleRate)); } break; @@ -455,7 +455,7 @@ if (!m_descriptors[n]->binNames.empty()) { std::vector names; - for (size_t i = 0; i < m_descriptors[n]->binNames.size(); ++i) { + for (int i = 0; i < (int)m_descriptors[n]->binNames.size(); ++i) { names.push_back(m_descriptors[n]->binNames[i].c_str()); } model->setBinNames(names); @@ -477,7 +477,7 @@ { // SVDEBUG << "FeatureExtractionModelTransformer::~FeatureExtractionModelTransformer()" << endl; delete m_plugin; - for (int j = 0; j < m_descriptors.size(); ++j) { + for (int j = 0; j < (int)m_descriptors.size(); ++j) { delete m_descriptors[j]; } } @@ -573,27 +573,27 @@ } if (m_abandoned) return; - size_t sampleRate = input->getSampleRate(); + int sampleRate = input->getSampleRate(); - size_t channelCount = input->getChannelCount(); - if (m_plugin->getMaxChannelCount() < channelCount) { + int channelCount = input->getChannelCount(); + if ((int)m_plugin->getMaxChannelCount() < channelCount) { channelCount = 1; } float **buffers = new float*[channelCount]; - for (size_t ch = 0; ch < channelCount; ++ch) { + for (int ch = 0; ch < channelCount; ++ch) { buffers[ch] = new float[primaryTransform.getBlockSize() + 2]; } - size_t stepSize = primaryTransform.getStepSize(); - size_t blockSize = primaryTransform.getBlockSize(); + int stepSize = primaryTransform.getStepSize(); + int blockSize = primaryTransform.getBlockSize(); bool frequencyDomain = (m_plugin->getInputDomain() == Vamp::Plugin::FrequencyDomain); std::vector fftModels; if (frequencyDomain) { - for (size_t ch = 0; ch < channelCount; ++ch) { + for (int ch = 0; ch < channelCount; ++ch) { FFTModel *model = new FFTModel (getConformingInput(), channelCount == 1 ? m_input.getChannel() : ch, @@ -677,10 +677,10 @@ // channelCount is either m_input.getModel()->channelCount or 1 if (frequencyDomain) { - for (size_t ch = 0; ch < channelCount; ++ch) { + for (int ch = 0; ch < channelCount; ++ch) { int column = (blockFrame - startFrame) / stepSize; fftModels[ch]->getValuesAt(column, reals, imaginaries); - for (size_t i = 0; i <= blockSize/2; ++i) { + for (int i = 0; i <= blockSize/2; ++i) { buffers[ch][i*2] = reals[i]; buffers[ch][i*2+1] = imaginaries[i]; } @@ -703,7 +703,7 @@ if (m_abandoned) break; for (int j = 0; j < (int)m_outputNos.size(); ++j) { - for (size_t fi = 0; fi < features[m_outputNos[j]].size(); ++fi) { + for (int fi = 0; fi < (int)features[m_outputNos[j]].size(); ++fi) { Vamp::Plugin::Feature feature = features[m_outputNos[j]][fi]; addFeature(j, blockFrame, feature); } @@ -723,7 +723,7 @@ Vamp::Plugin::FeatureSet features = m_plugin->getRemainingFeatures(); for (int j = 0; j < (int)m_outputNos.size(); ++j) { - for (size_t fi = 0; fi < features[m_outputNos[j]].size(); ++fi) { + for (int fi = 0; fi < (int)features[m_outputNos[j]].size(); ++fi) { Vamp::Plugin::Feature feature = features[m_outputNos[j]][fi]; addFeature(j, blockFrame, feature); } @@ -735,7 +735,7 @@ } if (frequencyDomain) { - for (size_t ch = 0; ch < channelCount; ++ch) { + for (int ch = 0; ch < channelCount; ++ch) { delete fftModels[ch]; } delete[] reals; @@ -805,10 +805,10 @@ void FeatureExtractionModelTransformer::addFeature(int n, - size_t blockFrame, + int blockFrame, const Vamp::Plugin::Feature &feature) { - size_t inputRate = m_input.getModel()->getSampleRate(); + int inputRate = m_input.getModel()->getSampleRate(); // cerr << "FeatureExtractionModelTransformer::addFeature: blockFrame = " // << blockFrame << ", hasTimestamp = " << feature.hasTimestamp @@ -816,11 +816,6 @@ // << feature.hasDuration << ", duration = " << feature.duration // << endl; - int binCount = 1; - if (m_descriptors[n]->hasFixedBinCount) { - binCount = m_descriptors[n]->binCount; - } - int frame = blockFrame; if (m_descriptors[n]->sampleType == @@ -885,7 +880,7 @@ getConformingOutput(n); if (!model) return; - for (int i = 0; i < feature.values.size(); ++i) { + for (int i = 0; i < (int)feature.values.size(); ++i) { float value = feature.values[i]; @@ -912,7 +907,7 @@ int index = 0; float value = 0.0; - if (feature.values.size() > index) { + if ((int)feature.values.size() > index) { value = feature.values[index++]; } @@ -920,7 +915,7 @@ if (feature.hasDuration) { duration = Vamp::RealTime::realTime2Frame(feature.duration, inputRate); } else { - if (feature.values.size() > index) { + if ((int)feature.values.size() > index) { duration = feature.values[index++]; } } @@ -928,7 +923,7 @@ if (isOutput(n)) { // GF: added for flexi note model float velocity = 100; - if (feature.values.size() > index) { + if ((int)feature.values.size() > index) { velocity = feature.values[index++]; } if (velocity < 0) velocity = 127; @@ -944,7 +939,7 @@ } else if (isOutput(n)) { float velocity = 100; - if (feature.values.size() > index) { + if ((int)feature.values.size() > index) { velocity = feature.values[index++]; } if (velocity < 0) velocity = 127; @@ -963,7 +958,7 @@ if (feature.hasDuration && !feature.values.empty()) { - for (int i = 0; i < feature.values.size(); ++i) { + for (int i = 0; i < (int)feature.values.size(); ++i) { float value = feature.values[i]; @@ -1018,6 +1013,7 @@ SparseOneDimensionalModel *model = getConformingOutput(n); if (!model) return; + if (model->isAbandoning()) abandon(); model->setCompletion(completion, true); } else if (isOutput(n)) { @@ -1025,24 +1021,28 @@ SparseTimeValueModel *model = getConformingOutput(n); if (!model) return; + if (model->isAbandoning()) abandon(); model->setCompletion(completion, true); } else if (isOutput(n)) { NoteModel *model = getConformingOutput(n); if (!model) return; + if (model->isAbandoning()) abandon(); model->setCompletion(completion, true); - } else if (isOutput(n)) { + } else if (isOutput(n)) { FlexiNoteModel *model = getConformingOutput(n); if (!model) return; + if (model->isAbandoning()) abandon(); model->setCompletion(completion, true); } else if (isOutput(n)) { RegionModel *model = getConformingOutput(n); if (!model) return; + if (model->isAbandoning()) abandon(); model->setCompletion(completion, true); } else if (isOutput(n)) { @@ -1050,6 +1050,7 @@ EditableDenseThreeDimensionalModel *model = getConformingOutput(n); if (!model) return; + if (model->isAbandoning()) abandon(); model->setCompletion(completion, true); //!!!m_context.updates); } } diff -r 49618f39ff09 -r 0c1d6de8f44b transform/FeatureExtractionModelTransformer.h --- a/transform/FeatureExtractionModelTransformer.h Tue Jun 03 11:05:49 2014 +0100 +++ b/transform/FeatureExtractionModelTransformer.h Wed Jun 18 13:51:16 2014 +0100 @@ -66,7 +66,7 @@ SparseTimeValueModel *getAdditionalModel(int transformNo, int binNo); void addFeature(int n, - size_t blockFrame, + int blockFrame, const Vamp::Plugin::Feature &feature); void setCompletion(int, int); diff -r 49618f39ff09 -r 0c1d6de8f44b transform/FeatureWriter.h --- a/transform/FeatureWriter.h Tue Jun 03 11:05:49 2014 +0100 +++ b/transform/FeatureWriter.h Wed Jun 18 13:51:16 2014 +0100 @@ -49,7 +49,7 @@ return ParameterList(); } - virtual void setParameters(map ¶ms) { + virtual void setParameters(map &) { return; } @@ -57,7 +57,7 @@ QString title; QString maker; }; - virtual void setTrackMetadata(QString trackid, TrackMetadata metadata) { } + virtual void setTrackMetadata(QString /* trackid */, TrackMetadata) { } class FailedToOpenOutputStream : virtual public std::exception { @@ -93,7 +93,7 @@ * really an optimisation to ensure that easy-to-recognise failure * cases fail early. */ - virtual void testOutputFile(QString trackId, TransformId transformId) { } + virtual void testOutputFile(QString /* trackId */, TransformId) { } virtual void flush() { } // whatever the last stream was diff -r 49618f39ff09 -r 0c1d6de8f44b transform/FileFeatureWriter.h --- a/transform/FileFeatureWriter.h Tue Jun 03 11:05:49 2014 +0100 +++ b/transform/FileFeatureWriter.h Wed Jun 18 13:51:16 2014 +0100 @@ -67,7 +67,7 @@ QFile *getOutputFile(QString, TransformId); // subclass can implement this to be called before file is opened for append - virtual void reviewFileForAppending(QString filename) { } + virtual void reviewFileForAppending(QString) { } int m_support; QString m_extension; diff -r 49618f39ff09 -r 0c1d6de8f44b transform/ModelTransformerFactory.cpp --- a/transform/ModelTransformerFactory.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/transform/ModelTransformerFactory.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -55,8 +55,8 @@ const std::vector &candidateInputModels, Model *defaultInputModel, AudioPlaySource *source, - size_t startFrame, - size_t duration, + int startFrame, + int duration, UserConfigurator *configurator) { ModelTransformer::Input input(0); @@ -70,7 +70,7 @@ QStringList candidateModelNames; QString defaultModelName; QMap modelMap; - for (size_t i = 0; i < candidateInputModels.size(); ++i) { + for (int i = 0; i < (int)candidateInputModels.size(); ++i) { QString modelName = candidateInputModels[i]->objectName(); QString origModelName = modelName; int dupcount = 1; @@ -106,11 +106,10 @@ } else if (RealTimePluginFactory::instanceFor(id)) { RealTimePluginFactory *factory = RealTimePluginFactory::instanceFor(id); - const RealTimePluginDescriptor *desc = factory->getPluginDescriptor(id); - size_t sampleRate = inputModel->getSampleRate(); - size_t blockSize = 1024; - size_t channels = 1; + int sampleRate = inputModel->getSampleRate(); + int blockSize = 1024; + int channels = 1; if (source) { sampleRate = source->getTargetSampleRate(); blockSize = source->getTargetBlockSize(); @@ -234,7 +233,7 @@ QString trn = TransformFactory::getInstance()->getTransformFriendlyName (transforms[0].getIdentifier()); - for (int i = 0; i < models.size(); ++i) { + for (int i = 0; i < (int)models.size(); ++i) { if (imn != "") { if (trn != "") { models[i]->setObjectName(tr("%1: %2").arg(imn).arg(trn)); diff -r 49618f39ff09 -r 0c1d6de8f44b transform/ModelTransformerFactory.h --- a/transform/ModelTransformerFactory.h Tue Jun 03 11:05:49 2014 +0100 +++ b/transform/ModelTransformerFactory.h Wed Jun 18 13:51:16 2014 +0100 @@ -47,8 +47,8 @@ Vamp::PluginBase *plugin, Model *&inputModel, AudioPlaySource *source, - size_t startFrame, - size_t duration, + int startFrame, + int duration, const QMap &modelMap, QStringList candidateModelNames, QString defaultModelName) = 0; @@ -67,8 +67,8 @@ const std::vector &candidateInputModels, Model *defaultInputModel, AudioPlaySource *source = 0, - size_t startFrame = 0, - size_t duration = 0, + int startFrame = 0, + int duration = 0, UserConfigurator *configurator = 0); class AdditionalModelHandler { @@ -84,7 +84,8 @@ * Return the output model resulting from applying the named * transform to the given input model. The transform may still be * working in the background when the model is returned; check the - * output model's isReady completion status for more details. + * output model's isReady completion status for more details. To + * cancel a background transform, call abandon() on its model. * * If the transform is unknown or the input model is not an * appropriate type for the given transform, or if some other @@ -116,7 +117,8 @@ * (as appropriate). Models will be returned in the same order as * the transforms were given. The plugin may still be working in * the background when the model is returned; check the output - * models' isReady completion statuses for more details. + * models' isReady completion statuses for more details. To cancel + * a background transform, call abandon() on its model. * * If a transform is unknown or the transforms are insufficiently * closely related or the input model is not an appropriate type @@ -130,7 +132,10 @@ * is provided here, its moreModelsAvailable method will be called * when those models become available, and ownership of those * models will be transferred to the handler. Otherwise (if the - * handler is null) any such models will be discarded. + * handler is null) any such models will be discarded. Note that + * calling abandon() on any one of the models returned by + * transformMultiple is sufficient to cancel all background + * transform activity associated with these output models. * * The returned models are owned by the caller and must be deleted * when no longer needed. diff -r 49618f39ff09 -r 0c1d6de8f44b transform/RealTimeEffectModelTransformer.cpp --- a/transform/RealTimeEffectModelTransformer.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/transform/RealTimeEffectModelTransformer.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -82,7 +82,7 @@ if (m_outputNo == -1) { - size_t outputChannels = m_plugin->getAudioOutputCount(); + int outputChannels = m_plugin->getAudioOutputCount(); if (outputChannels > input->getChannelCount()) { outputChannels = input->getChannelCount(); } @@ -137,8 +137,8 @@ if (stvm && (m_outputNo >= int(m_plugin->getControlOutputCount()))) return; - size_t sampleRate = input->getSampleRate(); - size_t channelCount = input->getChannelCount(); + int sampleRate = input->getSampleRate(); + int channelCount = input->getChannelCount(); if (!wwfm && m_input.getChannel() != -1) channelCount = 1; long blockSize = m_plugin->getBufferSize(); @@ -197,7 +197,7 @@ inbufs[0][got++] = 0.0; } } - for (size_t ch = 1; ch < m_plugin->getAudioInputCount(); ++ch) { + for (int ch = 1; ch < (int)m_plugin->getAudioInputCount(); ++ch) { for (long i = 0; i < blockSize; ++i) { inbufs[ch][i] = inbufs[0][i]; } @@ -208,13 +208,13 @@ blockFrame, blockSize, inbufs); while (got < blockSize) { - for (size_t ch = 0; ch < channelCount; ++ch) { + for (int ch = 0; ch < channelCount; ++ch) { inbufs[ch][got] = 0.0; } ++got; } } - for (size_t ch = channelCount; ch < m_plugin->getAudioInputCount(); ++ch) { + for (int ch = channelCount; ch < (int)m_plugin->getAudioInputCount(); ++ch) { for (long i = 0; i < blockSize; ++i) { inbufs[ch][i] = inbufs[ch % channelCount][i]; } @@ -224,9 +224,9 @@ /* cerr << "Input for plugin: " << m_plugin->getAudioInputCount() << " channels "<< endl; - for (size_t ch = 0; ch < m_plugin->getAudioInputCount(); ++ch) { + for (int ch = 0; ch < m_plugin->getAudioInputCount(); ++ch) { cerr << "Input channel " << ch << endl; - for (size_t i = 0; i < 100; ++i) { + for (int i = 0; i < 100; ++i) { cerr << inbufs[ch][i] << " "; if (isnan(inbufs[ch][i])) { cerr << "\n\nWARNING: NaN in audio input" << endl; @@ -263,7 +263,7 @@ long offset = latency - blockFrame; long count = blockSize - offset; float **tmp = new float *[channelCount]; - for (size_t c = 0; c < channelCount; ++c) { + for (int c = 0; c < channelCount; ++c) { tmp[c] = outbufs[c] + offset; } wwfm->addSamples(tmp, count); diff -r 49618f39ff09 -r 0c1d6de8f44b transform/Transform.cpp --- a/transform/Transform.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/transform/Transform.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -66,7 +66,7 @@ QDomNamedNodeMap attrNodes = transformElt.attributes(); QXmlAttributes attrs; - for (unsigned int i = 0; i < attrNodes.length(); ++i) { + for (int i = 0; i < attrNodes.length(); ++i) { QDomAttr attr = attrNodes.item(i).toAttr(); if (!attr.isNull()) attrs.append(attr.name(), "", "", attr.value()); } @@ -319,26 +319,26 @@ m_summaryType = type; } -size_t +int Transform::getStepSize() const { return m_stepSize; } void -Transform::setStepSize(size_t s) +Transform::setStepSize(int s) { m_stepSize = s; } -size_t +int Transform::getBlockSize() const { return m_blockSize; } void -Transform::setBlockSize(size_t s) +Transform::setBlockSize(int s) { m_blockSize = s; } diff -r 49618f39ff09 -r 0c1d6de8f44b transform/Transform.h --- a/transform/Transform.h Tue Jun 03 11:05:49 2014 +0100 +++ b/transform/Transform.h Wed Jun 18 13:51:16 2014 +0100 @@ -120,11 +120,11 @@ QString getProgram() const; void setProgram(QString program); - size_t getStepSize() const; - void setStepSize(size_t s); + int getStepSize() const; + void setStepSize(int s); - size_t getBlockSize() const; - void setBlockSize(size_t s); + int getBlockSize() const; + void setBlockSize(int s); WindowType getWindowType() const; void setWindowType(WindowType type); @@ -189,8 +189,8 @@ SummaryType m_summaryType; QString m_pluginVersion; QString m_program; - size_t m_stepSize; - size_t m_blockSize; + int m_stepSize; + int m_blockSize; WindowType m_windowType; RealTime m_startTime; RealTime m_duration; diff -r 49618f39ff09 -r 0c1d6de8f44b transform/TransformFactory.cpp --- a/transform/TransformFactory.cpp Tue Jun 03 11:05:49 2014 +0100 +++ b/transform/TransformFactory.cpp Wed Jun 18 13:51:16 2014 +0100 @@ -405,7 +405,7 @@ FeatureExtractionPluginFactory::getAllPluginIdentifiers(); if (m_exiting) return; - for (size_t i = 0; i < plugs.size(); ++i) { + for (int i = 0; i < (int)plugs.size(); ++i) { QString pluginId = plugs[i]; @@ -431,7 +431,7 @@ Vamp::Plugin::OutputList outputs = plugin->getOutputDescriptors(); - for (size_t j = 0; j < outputs.size(); ++j) { + for (int j = 0; j < (int)outputs.size(); ++j) { QString transformId = QString("%1:%2") .arg(pluginId).arg(outputs[j].identifier.c_str()); @@ -506,7 +506,7 @@ static QRegExp unitRE("[\\[\\(]([A-Za-z0-9/]+)[\\)\\]]$"); - for (size_t i = 0; i < plugs.size(); ++i) { + for (int i = 0; i < (int)plugs.size(); ++i) { QString pluginId = plugs[i]; @@ -539,14 +539,14 @@ if (descriptor->audioInputPortCount > 0) { - for (size_t j = 0; j < descriptor->controlOutputPortCount; ++j) { + for (int j = 0; j < (int)descriptor->controlOutputPortCount; ++j) { QString transformId = QString("%1:%2").arg(pluginId).arg(j); QString userName; QString units; QString portName; - if (j < descriptor->controlOutputPortNames.size() && + if (j < (int)descriptor->controlOutputPortNames.size() && descriptor->controlOutputPortNames[j] != "") { portName = descriptor->controlOutputPortNames[j].c_str(); @@ -749,7 +749,7 @@ } Transform -TransformFactory::getDefaultTransformFor(TransformId id, size_t rate) +TransformFactory::getDefaultTransformFor(TransformId id, int rate) { Transform t; t.setIdentifier(id); @@ -781,7 +781,7 @@ } Vamp::PluginBase * -TransformFactory::instantiateDefaultPluginFor(TransformId identifier, size_t rate) +TransformFactory::instantiateDefaultPluginFor(TransformId identifier, int rate) { Transform t; t.setIdentifier(identifier); diff -r 49618f39ff09 -r 0c1d6de8f44b transform/TransformFactory.h --- a/transform/TransformFactory.h Tue Jun 03 11:05:49 2014 +0100 +++ b/transform/TransformFactory.h Wed Jun 18 13:51:16 2014 +0100 @@ -88,7 +88,7 @@ * with different parameters and execution context settings. * Return the default one for the given transform. */ - Transform getDefaultTransformFor(TransformId identifier, size_t rate = 0); + Transform getDefaultTransformFor(TransformId identifier, int 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, size_t rate); + Vamp::PluginBase *instantiateDefaultPluginFor(TransformId id, int rate); QMutex m_transformsMutex; QMutex m_uninstalledTransformsMutex;