Mercurial > hg > svcore
changeset 1038:cc27f35aa75c cxx11
Introducing the signed 64-bit frame index type, and fixing build failures from inclusion of -Wconversion with -Werror. Not finished yet.
line wrap: on
line diff
--- a/base/AudioLevel.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/base/AudioLevel.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -26,52 +26,52 @@ #include <cassert> #include "system/System.h" -const float AudioLevel::DB_FLOOR = -1000.f; +const double AudioLevel::DB_FLOOR = -1000.; struct FaderDescription { - FaderDescription(float _minDb, float _maxDb, float _zeroPoint) : + FaderDescription(double _minDb, double _maxDb, double _zeroPoint) : minDb(_minDb), maxDb(_maxDb), zeroPoint(_zeroPoint) { } - float minDb; - float maxDb; - float zeroPoint; // as fraction of total throw + double minDb; + double maxDb; + double zeroPoint; // as fraction of total throw }; static const FaderDescription faderTypes[] = { - FaderDescription(-40.f, +6.f, 0.75f), // short - FaderDescription(-70.f, +10.f, 0.80f), // long - FaderDescription(-70.f, 0.f, 1.00f), // IEC268 - FaderDescription(-70.f, +10.f, 0.80f), // IEC268 long - FaderDescription(-40.f, 0.f, 1.00f), // preview + FaderDescription(-40., +6., 0.75), // short + FaderDescription(-70., +10., 0.80), // long + FaderDescription(-70., 0., 1.00), // IEC268 + FaderDescription(-70., +10., 0.80), // IEC268 long + FaderDescription(-40., 0., 1.00), // preview }; -//typedef std::vector<float> LevelList; +//typedef std::vector<double> LevelList; //static std::map<int, LevelList> previewLevelCache; //static const LevelList &getPreviewLevelCache(int levels); -float -AudioLevel::multiplier_to_dB(float multiplier) +double +AudioLevel::multiplier_to_dB(double multiplier) { - if (multiplier == 0.f) return DB_FLOOR; - else if (multiplier < 0.f) return multiplier_to_dB(-multiplier); - float dB = 10 * log10f(multiplier); + if (multiplier == 0.) return DB_FLOOR; + else if (multiplier < 0.) return multiplier_to_dB(-multiplier); + double dB = 10 * log10(multiplier); return dB; } -float -AudioLevel::dB_to_multiplier(float dB) +double +AudioLevel::dB_to_multiplier(double dB) { - if (dB == DB_FLOOR) return 0.f; - float m = powf(10.f, dB / 10.f); + if (dB == DB_FLOOR) return 0.; + double m = pow(10., dB / 10.); return m; } /* IEC 60-268-18 fader levels. Thanks to Steve Harris. */ -static float iec_dB_to_fader(float db) +static double iec_dB_to_fader(double db) { - float def = 0.0f; // Meter deflection %age + double def = 0.0f; // Meter deflection %age if (db < -70.0f) { def = 0.0f; @@ -92,9 +92,9 @@ return def; } -static float iec_fader_to_dB(float def) // Meter deflection %age +static double iec_fader_to_dB(double def) // Meter deflection %age { - float db = 0.0f; + double db = 0.0f; if (def >= 50.0f) { db = (def - 50.0f) / 2.5f - 20.0f; @@ -113,16 +113,16 @@ return db; } -float +double AudioLevel::fader_to_dB(int level, int maxLevel, FaderType type) { if (level == 0) return DB_FLOOR; if (type == IEC268Meter || type == IEC268LongMeter) { - float maxPercent = iec_dB_to_fader(faderTypes[type].maxDb); - float percent = float(level) * maxPercent / float(maxLevel); - float dB = iec_fader_to_dB(percent); + double maxPercent = iec_dB_to_fader(faderTypes[type].maxDb); + double percent = double(level) * maxPercent / double(maxLevel); + double dB = iec_fader_to_dB(percent); return dB; } else { // scale proportional to sqrt(fabs(dB)) @@ -131,27 +131,27 @@ if (level >= zeroLevel) { - float value = level - zeroLevel; - float scale = float(maxLevel - zeroLevel) / - sqrtf(faderTypes[type].maxDb); + double value = level - zeroLevel; + double scale = (maxLevel - zeroLevel) / + sqrt(faderTypes[type].maxDb); value /= scale; - float dB = powf(value, 2.f); + double dB = pow(value, 2.); return dB; } else { - float value = zeroLevel - level; - float scale = zeroLevel / sqrtf(0.f - faderTypes[type].minDb); + double value = zeroLevel - level; + double scale = zeroLevel / sqrt(0. - faderTypes[type].minDb); value /= scale; - float dB = powf(value, 2.f); - return 0.f - dB; + double dB = pow(value, 2.); + return 0. - dB; } } } int -AudioLevel::dB_to_fader(float dB, int maxLevel, FaderType type) +AudioLevel::dB_to_fader(double dB, int maxLevel, FaderType type) { if (dB == DB_FLOOR) return 0; @@ -162,8 +162,8 @@ // result not as a percentage, but as a scale between 0 and // whatever the "percentage" for our (possibly >0dB) max dB is. - float maxPercent = iec_dB_to_fader(faderTypes[type].maxDb); - float percent = iec_dB_to_fader(dB); + double maxPercent = iec_dB_to_fader(faderTypes[type].maxDb); + double percent = iec_dB_to_fader(dB); int faderLevel = int((maxLevel * percent) / maxPercent + 0.01f); if (faderLevel < 0) faderLevel = 0; @@ -174,16 +174,16 @@ int zeroLevel = int(maxLevel * faderTypes[type].zeroPoint); - if (dB >= 0.f) { + if (dB >= 0.) { - if (faderTypes[type].maxDb <= 0.f) { + if (faderTypes[type].maxDb <= 0.) { return maxLevel; } else { - float value = sqrtf(dB); - float scale = (maxLevel - zeroLevel) / sqrtf(faderTypes[type].maxDb); + double value = sqrt(dB); + double scale = (maxLevel - zeroLevel) / sqrt(faderTypes[type].maxDb); value *= scale; int level = int(value + 0.01f) + zeroLevel; if (level > maxLevel) level = maxLevel; @@ -192,9 +192,9 @@ } else { - dB = 0.f - dB; - float value = sqrtf(dB); - float scale = zeroLevel / sqrtf(0.f - faderTypes[type].minDb); + dB = 0. - dB; + double value = sqrt(dB); + double scale = zeroLevel / sqrt(0. - faderTypes[type].minDb); value *= scale; int level = zeroLevel - int(value + 0.01f); if (level < 0) level = 0; @@ -204,18 +204,18 @@ } -float +double AudioLevel::fader_to_multiplier(int level, int maxLevel, FaderType type) { - if (level == 0) return 0.f; + if (level == 0) return 0.; return dB_to_multiplier(fader_to_dB(level, maxLevel, type)); } int -AudioLevel::multiplier_to_fader(float multiplier, int maxLevel, FaderType type) +AudioLevel::multiplier_to_fader(double multiplier, int maxLevel, FaderType type) { - if (multiplier == 0.f) return 0; - float dB = multiplier_to_dB(multiplier); + if (multiplier == 0.) return 0; + double dB = multiplier_to_dB(multiplier); int fader = dB_to_fader(dB, maxLevel, type); return fader; } @@ -227,7 +227,7 @@ LevelList &ll = previewLevelCache[levels]; if (ll.empty()) { for (int i = 0; i <= levels; ++i) { - float m = AudioLevel::fader_to_multiplier + double m = AudioLevel::fader_to_multiplier (i + levels/4, levels + levels/4, AudioLevel::PreviewLevel); if (levels == 1) m /= 100; // noise ll.push_back(m); @@ -238,14 +238,14 @@ */ int -AudioLevel::multiplier_to_preview(float m, int levels) +AudioLevel::multiplier_to_preview(double m, int levels) { assert(levels > 0); return multiplier_to_fader(m, levels, PreviewLevel); /* The original multiplier_to_preview which follows is not thread-safe. - if (m < 0.f) return -multiplier_to_preview(-m, levels); + if (m < 0.) return -multiplier_to_preview(-m, levels); const LevelList &ll = getPreviewLevelCache(levels); int result = -1; @@ -277,7 +277,7 @@ */ } -float +double AudioLevel::preview_to_multiplier(int level, int levels) { assert(levels > 0);
--- a/base/AudioLevel.h Tue Mar 03 09:33:59 2015 +0000 +++ b/base/AudioLevel.h Tue Mar 03 15:18:24 2015 +0000 @@ -35,7 +35,7 @@ { public: - static const float DB_FLOOR; + static const double DB_FLOOR; enum FaderType { ShortFader = 0, // -40 -> +6 dB @@ -45,19 +45,19 @@ PreviewLevel = 4 }; - static float multiplier_to_dB(float multiplier); - static float dB_to_multiplier(float dB); + static double multiplier_to_dB(double multiplier); + static double dB_to_multiplier(double dB); - static float fader_to_dB(int level, int maxLevel, FaderType type); - static int dB_to_fader(float dB, int maxFaderLevel, FaderType type); + static double fader_to_dB(int level, int maxLevel, FaderType type); + static int dB_to_fader(double dB, int maxFaderLevel, FaderType type); - static float fader_to_multiplier(int level, int maxLevel, FaderType type); - static int multiplier_to_fader(float multiplier, int maxFaderLevel, + static double fader_to_multiplier(int level, int maxLevel, FaderType type); + static int multiplier_to_fader(double multiplier, int maxFaderLevel, FaderType type); // fast if "levels" doesn't change often -- for audio segment previews - static int multiplier_to_preview(float multiplier, int levels); - static float preview_to_multiplier(int level, int levels); + static int multiplier_to_preview(double multiplier, int levels); + static double preview_to_multiplier(int level, int levels); };
--- a/base/Command.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/base/Command.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -95,6 +95,6 @@ BundleCommand::getName() const { if (m_commands.size() == 1) return m_name; - return tr("%1 (%n change(s))", "", m_commands.size()).arg(m_name); + return tr("%1 (%n change(s))", "", int(m_commands.size())).arg(m_name); }
--- a/base/Exceptions.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/base/Exceptions.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -91,8 +91,8 @@ } InsufficientDiscSpace::InsufficientDiscSpace(QString directory, - int required, - int available) throw() : + size_t required, + size_t available) throw() : m_directory(directory), m_required(required), m_available(available)
--- a/base/Exceptions.h Tue Mar 03 09:33:59 2015 +0000 +++ b/base/Exceptions.h Tue Mar 03 15:18:24 2015 +0000 @@ -82,19 +82,19 @@ { public: InsufficientDiscSpace(QString directory, - int required, int available) throw(); + size_t required, size_t available) throw(); InsufficientDiscSpace(QString directory) throw(); virtual ~InsufficientDiscSpace() throw() { } virtual const char *what() const throw(); QString getDirectory() const { return m_directory; } - int getRequired() const { return m_required; } - int getAvailable() const { return m_available; } + size_t getRequired() const { return m_required; } + size_t getAvailable() const { return m_available; } protected: QString m_directory; - int m_required; - int m_available; + size_t m_required; + size_t m_available; }; class AllocationFailed : virtual public std::exception
--- a/base/LogRange.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/base/LogRange.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -74,20 +74,20 @@ return powf(10.0, value); } -static float -sd(const std::vector<float> &values, size_t start, size_t n) +static double +sd(const std::vector<float> &values, int start, int n) { - float sum = 0.f, mean = 0.f, variance = 0.f; - for (size_t i = 0; i < n; ++i) { + double sum = 0.f, mean = 0.f, variance = 0.f; + for (int i = 0; i < n; ++i) { sum += values[start + i]; } mean = sum / n; - for (size_t i = 0; i < n; ++i) { - float diff = values[start + i] - mean; + for (int i = 0; i < n; ++i) { + double diff = values[start + i] - mean; variance += diff * diff; } variance = variance / n; - return sqrtf(variance); + return sqrt(variance); } bool @@ -97,12 +97,13 @@ // calculate the standard deviation of each set; if the two SDs // are very different, it's likely that a log scale would be good. - if (values.size() < 4) return false; + int n = int(values.size()); + if (n < 4) return false; std::sort(values.begin(), values.end()); - size_t mi = values.size() / 2; + int mi = n / 2; - float sd0 = sd(values, 0, mi); - float sd1 = sd(values, mi, values.size() - mi); + double sd0 = sd(values, 0, mi); + double sd1 = sd(values, mi, n - mi); SVDEBUG << "LogRange::useLogScale: sd0 = " << sd0 << ", sd1 = " << sd1 << endl; @@ -111,7 +112,7 @@ // I wonder what method of determining "one sd much bigger than // the other" would be appropriate here... - if (std::max(sd0, sd1) / std::min(sd0, sd1) > 10.f) return true; + if (std::max(sd0, sd1) / std::min(sd0, sd1) > 10.) return true; else return false; }
--- a/base/Pitch.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/base/Pitch.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -141,7 +141,7 @@ QString plain = (useFlats ? flatNotes : notes)[note].arg(octave); - int ic = lrint(centsOffset); + long ic = lrint(centsOffset); if (ic == 0) return plain; else if (ic > 0) return QString("%1+%2c").arg(plain).arg(ic); else return QString("%1%2c").arg(plain).arg(ic); @@ -176,7 +176,7 @@ } } - int ic = lrint(cents); + long ic = lrint(cents); if (ic == 0) { if (semis >= 12) {
--- a/base/Preferences.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/base/Preferences.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -59,7 +59,7 @@ (settings.value("spectrogram-y-smoothing", int(m_spectrogramSmoothing)).toInt()); m_spectrogramXSmoothing = SpectrogramXSmoothing (settings.value("spectrogram-x-smoothing", int(m_spectrogramXSmoothing)).toInt()); - m_tuningFrequency = settings.value("tuning-frequency", 440.f).toDouble(); + m_tuningFrequency = settings.value("tuning-frequency", 440.).toDouble(); m_propertyBoxLayout = PropertyBoxLayout (settings.value("property-box-layout", int(VerticallyStacked)).toInt()); m_windowType = WindowType @@ -467,7 +467,7 @@ } void -Preferences::setTuningFrequency(float freq) +Preferences::setTuningFrequency(double freq) { if (m_tuningFrequency != freq) { m_tuningFrequency = freq;
--- a/base/Preferences.h Tue Mar 03 09:33:59 2015 +0000 +++ b/base/Preferences.h Tue Mar 03 15:18:24 2015 +0000 @@ -49,7 +49,7 @@ SpectrogramSmoothing getSpectrogramSmoothing() const { return m_spectrogramSmoothing; } SpectrogramXSmoothing getSpectrogramXSmoothing() const { return m_spectrogramXSmoothing; } - float getTuningFrequency() const { return m_tuningFrequency; } + double getTuningFrequency() const { return m_tuningFrequency; } WindowType getWindowType() const { return m_windowType; } int getResampleQuality() const { return m_resampleQuality; } @@ -110,7 +110,7 @@ void setSpectrogramSmoothing(SpectrogramSmoothing smoothing); void setSpectrogramXSmoothing(SpectrogramXSmoothing smoothing); - void setTuningFrequency(float freq); + void setTuningFrequency(double freq); void setPropertyBoxLayout(PropertyBoxLayout layout); void setWindowType(WindowType type); void setResampleQuality(int quality); @@ -147,7 +147,7 @@ SpectrogramSmoothing m_spectrogramSmoothing; SpectrogramXSmoothing m_spectrogramXSmoothing; - float m_tuningFrequency; + double m_tuningFrequency; PropertyBoxLayout m_propertyBoxLayout; WindowType m_windowType; int m_resampleQuality;
--- a/base/RangeMapper.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/base/RangeMapper.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -22,7 +22,7 @@ #include <iostream> LinearRangeMapper::LinearRangeMapper(int minpos, int maxpos, - float minval, float maxval, + double minval, double maxval, QString unit, bool inverted) : m_minpos(minpos), m_maxpos(maxpos), @@ -36,7 +36,7 @@ } int -LinearRangeMapper::getPositionForValue(float value) const +LinearRangeMapper::getPositionForValue(double value) const { int position = getPositionForValueUnclamped(value); if (position < m_minpos) position = m_minpos; @@ -45,36 +45,36 @@ } int -LinearRangeMapper::getPositionForValueUnclamped(float value) const +LinearRangeMapper::getPositionForValueUnclamped(double value) const { int position = m_minpos + - lrintf(((value - m_minval) / (m_maxval - m_minval)) - * (m_maxpos - m_minpos)); + int(lrint(((value - m_minval) / (m_maxval - m_minval)) + * (m_maxpos - m_minpos))); if (m_inverted) return m_maxpos - (position - m_minpos); else return position; } -float +double LinearRangeMapper::getValueForPosition(int position) const { if (position < m_minpos) position = m_minpos; if (position > m_maxpos) position = m_maxpos; - float value = getValueForPositionUnclamped(position); + double value = getValueForPositionUnclamped(position); return value; } -float +double LinearRangeMapper::getValueForPositionUnclamped(int position) const { if (m_inverted) position = m_maxpos - (position - m_minpos); - float value = m_minval + - ((float(position - m_minpos) / float(m_maxpos - m_minpos)) + double value = m_minval + + ((double(position - m_minpos) / double(m_maxpos - m_minpos)) * (m_maxval - m_minval)); return value; } LogRangeMapper::LogRangeMapper(int minpos, int maxpos, - float minval, float maxval, + double minval, double maxval, QString unit, bool inverted) : m_minpos(minpos), m_maxpos(maxpos), @@ -97,26 +97,26 @@ void LogRangeMapper::convertMinMax(int minpos, int maxpos, - float minval, float maxval, - float &minlog, float &ratio) + double minval, double maxval, + double &minlog, double &ratio) { - static float thresh = powf(10, -10); + static double thresh = powf(10, -10); if (minval < thresh) minval = thresh; - minlog = log10f(minval); - ratio = (maxpos - minpos) / (log10f(maxval) - minlog); + minlog = log10(minval); + ratio = (maxpos - minpos) / (log10(maxval) - minlog); } void -LogRangeMapper::convertRatioMinLog(float ratio, float minlog, +LogRangeMapper::convertRatioMinLog(double ratio, double minlog, int minpos, int maxpos, - float &minval, float &maxval) + double &minval, double &maxval) { - minval = powf(10, minlog); - maxval = powf(10, (maxpos - minpos) / ratio + minlog); + minval = pow(10, minlog); + maxval = pow(10, (maxpos - minpos) / ratio + minlog); } int -LogRangeMapper::getPositionForValue(float value) const +LogRangeMapper::getPositionForValue(double value) const { int position = getPositionForValueUnclamped(value); if (position < m_minpos) position = m_minpos; @@ -125,29 +125,29 @@ } int -LogRangeMapper::getPositionForValueUnclamped(float value) const +LogRangeMapper::getPositionForValueUnclamped(double value) const { - static float thresh = powf(10, -10); + static double thresh = pow(10, -10); if (value < thresh) value = thresh; - int position = lrintf((log10(value) - m_minlog) * m_ratio) + m_minpos; + int position = int(lrint((log10(value) - m_minlog) * m_ratio)) + m_minpos; if (m_inverted) return m_maxpos - (position - m_minpos); else return position; } -float +double LogRangeMapper::getValueForPosition(int position) const { if (position < m_minpos) position = m_minpos; if (position > m_maxpos) position = m_maxpos; - float value = getValueForPositionUnclamped(position); + double value = getValueForPositionUnclamped(position); return value; } -float +double LogRangeMapper::getValueForPositionUnclamped(int position) const { if (m_inverted) position = m_maxpos - (position - m_minpos); - float value = powf(10, (position - m_minpos) / m_ratio + m_minlog); + double value = pow(10, (position - m_minpos) / m_ratio + m_minlog); return value; } @@ -163,7 +163,7 @@ } int -InterpolatingRangeMapper::getPositionForValue(float value) const +InterpolatingRangeMapper::getPositionForValue(double value) const { int pos = getPositionForValueUnclamped(value); CoordMap::const_iterator i = m_mappings.begin(); @@ -174,16 +174,16 @@ } int -InterpolatingRangeMapper::getPositionForValueUnclamped(float value) const +InterpolatingRangeMapper::getPositionForValueUnclamped(double value) const { - float p = interpolate(&m_mappings, value); - return lrintf(p); + double p = interpolate(&m_mappings, value); + return int(lrint(p)); } -float +double InterpolatingRangeMapper::getValueForPosition(int position) const { - float val = getValueForPositionUnclamped(position); + double val = getValueForPositionUnclamped(position); CoordMap::const_iterator i = m_mappings.begin(); if (val < i->first) val = i->first; i = m_mappings.end(); --i; @@ -191,18 +191,19 @@ return val; } -float +double InterpolatingRangeMapper::getValueForPositionUnclamped(int position) const { return interpolate(&m_reverse, position); } template <typename T> -float -InterpolatingRangeMapper::interpolate(T *mapping, float value) const +double +InterpolatingRangeMapper::interpolate(T *mapping, double value) const { // lower_bound: first element which does not compare less than value - typename T::const_iterator i = mapping->lower_bound(value); + typename T::const_iterator i = + mapping->lower_bound(typename T::key_type(value)); if (i == mapping->begin()) { // value is less than or equal to first element, so use the @@ -219,7 +220,7 @@ typename T::const_iterator j = i; --j; - float gradient = float(i->second - j->second) / float(i->first - j->first); + double gradient = double(i->second - j->second) / double(i->first - j->first); return j->second + (value - j->first) * gradient; } @@ -316,24 +317,24 @@ } int -AutoRangeMapper::getPositionForValue(float value) const +AutoRangeMapper::getPositionForValue(double value) const { return m_mapper->getPositionForValue(value); } -float +double AutoRangeMapper::getValueForPosition(int position) const { return m_mapper->getValueForPosition(position); } int -AutoRangeMapper::getPositionForValueUnclamped(float value) const +AutoRangeMapper::getPositionForValueUnclamped(double value) const { return m_mapper->getPositionForValueUnclamped(value); } -float +double AutoRangeMapper::getValueForPositionUnclamped(int position) const { return m_mapper->getValueForPositionUnclamped(position);
--- a/base/RangeMapper.h Tue Mar 03 09:33:59 2015 +0000 +++ b/base/RangeMapper.h Tue Mar 03 15:18:24 2015 +0000 @@ -31,7 +31,7 @@ * the nearest position and clamping to the minimum and maximum * extents of the mapper's positional range. */ - virtual int getPositionForValue(float value) const = 0; + virtual int getPositionForValue(double value) const = 0; /** * Return the position that maps to the given value, rounding to @@ -41,13 +41,13 @@ * range. (The mapping outside that range is not guaranteed to be * exact, except if the mapper is a linear one.) */ - virtual int getPositionForValueUnclamped(float value) const = 0; + virtual int getPositionForValueUnclamped(double value) const = 0; /** * Return the value mapped from the given position, clamping to * the minimum and maximum extents of the mapper's value range. */ - virtual float getValueForPosition(int position) const = 0; + virtual double getValueForPosition(int position) const = 0; /** * Return the value mapped from the given positionq, without @@ -56,7 +56,7 @@ * mapper's value range. (The mapping outside that range is not * guaranteed to be exact, except if the mapper is a linear one.) */ - virtual float getValueForPositionUnclamped(int position) const = 0; + virtual double getValueForPositionUnclamped(int position) const = 0; /** * Get the unit of the mapper's value range. @@ -75,22 +75,22 @@ * mapped "backwards" (minval to maxpos and maxval to minpos). */ LinearRangeMapper(int minpos, int maxpos, - float minval, float maxval, + double minval, double maxval, QString unit = "", bool inverted = false); - virtual int getPositionForValue(float value) const; - virtual int getPositionForValueUnclamped(float value) const; + virtual int getPositionForValue(double value) const; + virtual int getPositionForValueUnclamped(double value) const; - virtual float getValueForPosition(int position) const; - virtual float getValueForPositionUnclamped(int position) const; + virtual double getValueForPosition(int position) const; + virtual double getValueForPositionUnclamped(int position) const; virtual QString getUnit() const { return m_unit; } protected: int m_minpos; int m_maxpos; - float m_minval; - float m_maxval; + double m_minval; + double m_maxval; QString m_unit; bool m_inverted; }; @@ -107,31 +107,31 @@ * to maxpos and maxval to minpos). */ LogRangeMapper(int minpos, int maxpos, - float minval, float maxval, + double minval, double maxval, QString m_unit = "", bool inverted = false); - static void convertRatioMinLog(float ratio, float minlog, + static void convertRatioMinLog(double ratio, double minlog, int minpos, int maxpos, - float &minval, float &maxval); + double &minval, double &maxval); static void convertMinMax(int minpos, int maxpos, - float minval, float maxval, - float &ratio, float &minlog); + double minval, double maxval, + double &ratio, double &minlog); - virtual int getPositionForValue(float value) const; - virtual int getPositionForValueUnclamped(float value) const; + virtual int getPositionForValue(double value) const; + virtual int getPositionForValueUnclamped(double value) const; - virtual float getValueForPosition(int position) const; - virtual float getValueForPositionUnclamped(int position) const; + virtual double getValueForPosition(int position) const; + virtual double getValueForPositionUnclamped(int position) const; virtual QString getUnit() const { return m_unit; } protected: int m_minpos; int m_maxpos; - float m_ratio; - float m_minlog; - float m_maxlog; + double m_ratio; + double m_minlog; + double m_maxlog; QString m_unit; bool m_inverted; }; @@ -139,7 +139,7 @@ class InterpolatingRangeMapper : public RangeMapper { public: - typedef std::map<float, int> CoordMap; + typedef std::map<double, int> CoordMap; /** * Given a series of (value, position) coordinate mappings, @@ -162,21 +162,21 @@ InterpolatingRangeMapper(CoordMap pointMappings, QString unit); - virtual int getPositionForValue(float value) const; - virtual int getPositionForValueUnclamped(float value) const; + virtual int getPositionForValue(double value) const; + virtual int getPositionForValueUnclamped(double value) const; - virtual float getValueForPosition(int position) const; - virtual float getValueForPositionUnclamped(int position) const; + virtual double getValueForPosition(int position) const; + virtual double getValueForPositionUnclamped(int position) const; virtual QString getUnit() const { return m_unit; } protected: CoordMap m_mappings; - std::map<int, float> m_reverse; + std::map<int, double> m_reverse; QString m_unit; template <typename T> - float interpolate(T *mapping, float v) const; + double interpolate(T *mapping, double v) const; }; class AutoRangeMapper : public RangeMapper @@ -188,7 +188,7 @@ Logarithmic, }; - typedef std::map<float, int> CoordMap; + typedef std::map<double, int> CoordMap; /** * Given a series of (value, position) coordinate mappings, @@ -235,11 +235,11 @@ */ MappingType getType() const { return m_type; } - virtual int getPositionForValue(float value) const; - virtual int getPositionForValueUnclamped(float value) const; + virtual int getPositionForValue(double value) const; + virtual int getPositionForValueUnclamped(double value) const; - virtual float getValueForPosition(int position) const; - virtual float getValueForPositionUnclamped(int position) const; + virtual double getValueForPosition(int position) const; + virtual double getValueForPositionUnclamped(int position) const; virtual QString getUnit() const { return m_unit; }
--- a/base/RealTime.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/base/RealTime.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -75,7 +75,7 @@ RealTime RealTime::fromTimeval(const struct timeval &tv) { - return RealTime(tv.tv_sec, tv.tv_usec * 1000); + return RealTime(int(tv.tv_sec), int(tv.tv_usec * 1000)); } RealTime @@ -89,7 +89,7 @@ int i = 0; const char *s = xsdd.c_str(); - int len = xsdd.length(); + int len = int(xsdd.length()); bool negative = false, afterT = false; @@ -106,7 +106,7 @@ if (isdigit(s[i]) || s[i] == '.') { value = strtod(&s[i], &eptr); - i = eptr - s; + i = int(eptr - s); } if (i == len) break; @@ -456,22 +456,22 @@ else return lTotal/rTotal; } -long -RealTime::realTime2Frame(const RealTime &time, unsigned int sampleRate) +sv_frame_t +RealTime::realTime2Frame(const RealTime &time, int sampleRate) { if (time < zeroTime) return -realTime2Frame(-time, sampleRate); double s = time.sec + double(time.nsec + 1) / 1000000000.0; - return long(s * double(sampleRate)); + return sv_frame_t(s * double(sampleRate)); } RealTime -RealTime::frame2RealTime(long frame, unsigned int sampleRate) +RealTime::frame2RealTime(sv_frame_t frame, int sampleRate) { if (frame < 0) return -frame2RealTime(-frame, sampleRate); RealTime rt; - rt.sec = frame / long(sampleRate); - frame -= rt.sec * long(sampleRate); + rt.sec = int(frame / sv_frame_t(sampleRate)); + frame -= rt.sec * sv_frame_t(sampleRate); rt.nsec = (int)(((double(frame) * 1000000.0) / long(sampleRate)) * 1000.0); return rt; }
--- a/base/RealTime.h Tue Mar 03 09:33:59 2015 +0000 +++ b/base/RealTime.h Tue Mar 03 15:18:24 2015 +0000 @@ -21,12 +21,13 @@ #ifndef _REAL_TIME_H_ #define _REAL_TIME_H_ +#include "BaseTypes.h" + #include <iostream> #include <string> struct timeval; - /** * RealTime represents time values to nanosecond precision * with accurate arithmetic and frame-rate conversion functions. @@ -149,12 +150,12 @@ /** * Convert a RealTime into a sample frame at the given sample rate. */ - static long realTime2Frame(const RealTime &r, unsigned int sampleRate); + static sv_frame_t realTime2Frame(const RealTime &r, int sampleRate); /** * Convert a sample frame at the given sample rate into a RealTime. */ - static RealTime frame2RealTime(long frame, unsigned int sampleRate); + static RealTime frame2RealTime(sv_frame_t frame, int sampleRate); static const RealTime zeroTime; };
--- a/base/Resampler.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/base/Resampler.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -31,16 +31,16 @@ class Resampler::D { public: - D(Quality quality, int channels, int chunkSize); + D(Quality quality, int channels, sv_frame_t chunkSize); ~D(); - int resample(float **in, float **out, - int incount, float ratio, - bool final); + sv_frame_t resample(float **in, float **out, + sv_frame_t incount, double ratio, + bool final); - int resampleInterleaved(float *in, float *out, - int incount, float ratio, - bool final); + sv_frame_t resampleInterleaved(float *in, float *out, + sv_frame_t incount, double ratio, + bool final); void reset(); @@ -49,11 +49,11 @@ float *m_iin; float *m_iout; int m_channels; - int m_iinsize; - int m_ioutsize; + sv_frame_t m_iinsize; + sv_frame_t m_ioutsize; }; -Resampler::D::D(Quality quality, int channels, int chunkSize) : +Resampler::D::D(Quality quality, int channels, sv_frame_t chunkSize) : m_src(0), m_iin(0), m_iout(0), @@ -89,16 +89,16 @@ } } -int +sv_frame_t Resampler::D::resample(float **in, float **out, - int incount, float ratio, + sv_frame_t incount, double ratio, bool final) { if (m_channels == 1) { return resampleInterleaved(*in, *out, incount, ratio, final); } - int outcount = lrintf(ceilf(incount * ratio)); + sv_frame_t outcount = lrint(ceil(double(incount) * ratio)); if (incount * m_channels > m_iinsize) { m_iinsize = incount * m_channels; @@ -108,15 +108,15 @@ m_ioutsize = outcount * m_channels; m_iout = (float *)realloc(m_iout, m_ioutsize * sizeof(float)); } - for (int i = 0; i < incount; ++i) { + for (sv_frame_t i = 0; i < incount; ++i) { for (int c = 0; c < m_channels; ++c) { m_iin[i * m_channels + c] = in[c][i]; } } - int gen = resampleInterleaved(m_iin, m_iout, incount, ratio, final); + sv_frame_t gen = resampleInterleaved(m_iin, m_iout, incount, ratio, final); - for (int i = 0; i < gen; ++i) { + for (sv_frame_t 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; } -int +sv_frame_t Resampler::D::resampleInterleaved(float *in, float *out, - int incount, float ratio, + sv_frame_t incount, double ratio, bool final) { SRC_DATA data; - int outcount = lrintf(ceilf(incount * ratio)); + sv_frame_t outcount = lrint(ceil(double(incount) * ratio)); data.data_in = in; data.data_out = out; @@ -149,7 +149,7 @@ return 0; } - if (data.input_frames_used != (int)incount) { + if (data.input_frames_used != incount) { cerr << "Resampler: NOTE: input_frames_used == " << data.input_frames_used << " (while incount = " << incount << ")" << endl; } @@ -162,7 +162,7 @@ src_reset(m_src); } -Resampler::Resampler(Quality quality, int channels, int chunkSize) +Resampler::Resampler(Quality quality, int channels, sv_frame_t chunkSize) { m_d = new D(quality, channels, chunkSize); } @@ -172,18 +172,18 @@ delete m_d; } -int +sv_frame_t Resampler::resample(float **in, float **out, - int incount, float ratio, + sv_frame_t incount, double ratio, bool final) { return m_d->resample(in, out, incount, ratio, final); } -int +sv_frame_t Resampler::resampleInterleaved(float *in, float *out, - int incount, float ratio, - bool final) + sv_frame_t incount, double ratio, + bool final) { return m_d->resampleInterleaved(in, out, incount, ratio, final); }
--- a/base/Resampler.h Tue Mar 03 09:33:59 2015 +0000 +++ b/base/Resampler.h Tue Mar 03 15:18:24 2015 +0000 @@ -21,6 +21,8 @@ #ifndef _RESAMPLER_H_ #define _RESAMPLER_H_ +#include "BaseTypes.h" + #include <sys/types.h> class Resampler @@ -28,16 +30,16 @@ public: enum Quality { Best, FastestTolerable, Fastest }; - Resampler(Quality quality, int channels, int chunkSize = 0); + Resampler(Quality quality, int channels, sv_frame_t chunkSize = 0); ~Resampler(); - int resample(float **in, float **out, - int incount, float ratio, - bool final = false); + sv_frame_t resample(float **in, float **out, + sv_frame_t incount, double ratio, + bool final = false); - int resampleInterleaved(float *in, float *out, - int incount, float ratio, - bool final = false); + sv_frame_t resampleInterleaved(float *in, float *out, + sv_frame_t incount, double ratio, + bool final = false); void reset();
--- a/base/ResizeableBitset.h Tue Mar 03 09:33:59 2015 +0000 +++ b/base/ResizeableBitset.h Tue Mar 03 15:18:24 2015 +0000 @@ -62,11 +62,11 @@ } void set(size_t column) { - ((*m_bits)[column >> 3]) |= (uint8_t(1) << (column & 0x07)); + ((*m_bits)[column >> 3]) |= uint8_t((1u << (column & 0x07)) & 0xff); } void reset(size_t column) { - ((*m_bits)[column >> 3]) &= ~(uint8_t(1) << (column & 0x07)); + ((*m_bits)[column >> 3]) &= uint8_t((~(1u << (column & 0x07))) & 0xff); } void copy(size_t source, size_t dest) {
--- a/base/Selection.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/base/Selection.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -22,12 +22,12 @@ { } -Selection::Selection(int startFrame, int endFrame) : +Selection::Selection(sv_frame_t startFrame, sv_frame_t endFrame) : m_startFrame(startFrame), m_endFrame(endFrame) { if (m_startFrame > m_endFrame) { - int tmp = m_endFrame; + sv_frame_t tmp = m_endFrame; m_endFrame = m_startFrame; m_startFrame = tmp; } @@ -59,20 +59,20 @@ return m_startFrame == m_endFrame; } -int +sv_frame_t Selection::getStartFrame() const { return m_startFrame; } -int +sv_frame_t Selection::getEndFrame() const { return m_endFrame; } bool -Selection::contains(int frame) const +Selection::contains(sv_frame_t frame) const { return (frame >= m_startFrame) && (frame < m_endFrame); } @@ -174,7 +174,7 @@ } void -MultiSelection::getExtents(int &startFrame, int &endFrame) const +MultiSelection::getExtents(sv_frame_t &startFrame, sv_frame_t &endFrame) const { startFrame = 0; endFrame = 0; @@ -193,7 +193,7 @@ } Selection -MultiSelection::getContainingSelection(int frame, bool defaultToFollowing) const +MultiSelection::getContainingSelection(sv_frame_t 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
--- a/base/Selection.h Tue Mar 03 09:33:59 2015 +0000 +++ b/base/Selection.h Tue Mar 03 15:18:24 2015 +0000 @@ -20,6 +20,7 @@ #include <set> #include "XmlExportable.h" +#include "BaseTypes.h" /** * A selection object simply represents a range in time, via start and @@ -40,22 +41,22 @@ { public: Selection(); - Selection(int startFrame, int endFrame); + Selection(sv_frame_t startFrame, sv_frame_t endFrame); Selection(const Selection &); Selection &operator=(const Selection &); virtual ~Selection(); bool isEmpty() const; - int getStartFrame() const; - int getEndFrame() const; - bool contains(int frame) const; + sv_frame_t getStartFrame() const; + sv_frame_t getEndFrame() const; + bool contains(sv_frame_t frame) const; bool operator<(const Selection &) const; bool operator==(const Selection &) const; protected: - int m_startFrame; - int m_endFrame; + sv_frame_t m_startFrame; + sv_frame_t m_endFrame; }; class MultiSelection : public XmlExportable @@ -72,7 +73,7 @@ void removeSelection(const Selection &selection); void clearSelections(); - void getExtents(int &startFrame, int &endFrame) const; + void getExtents(sv_frame_t &startFrame, sv_frame_t &endFrame) const; /** * Return the selection that contains a given frame. @@ -80,7 +81,7 @@ * selected area, return the next selection after the given frame. * Return the empty selection if no appropriate selection is found. */ - Selection getContainingSelection(int frame, bool defaultToFollowing) const; + Selection getContainingSelection(sv_frame_t frame, bool defaultToFollowing) const; virtual void toXml(QTextStream &stream, QString indent = "", QString extraAttributes = "") const;
--- a/base/StorageAdviser.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/base/StorageAdviser.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -24,16 +24,16 @@ //#define DEBUG_STORAGE_ADVISER 1 -long StorageAdviser::m_discPlanned = 0; -long StorageAdviser::m_memoryPlanned = 0; +size_t StorageAdviser::m_discPlanned = 0; +size_t StorageAdviser::m_memoryPlanned = 0; StorageAdviser::Recommendation StorageAdviser::m_baseRecommendation = StorageAdviser::NoRecommendation; StorageAdviser::Recommendation StorageAdviser::recommend(Criteria criteria, - int minimumSize, - int maximumSize) + size_t minimumSize, + size_t maximumSize) { #ifdef DEBUG_STORAGE_ADVISER SVDEBUG << "StorageAdviser::recommend: Criteria " << criteria @@ -52,17 +52,17 @@ cerr << "StorageAdviser::recommend: ERROR: Failed to get temporary directory path: " << e.what() << endl; return Recommendation(UseMemory | ConserveSpace); } - int discFree = GetDiscSpaceMBAvailable(path.toLocal8Bit()); - int memoryFree, memoryTotal; + ssize_t discFree = GetDiscSpaceMBAvailable(path.toLocal8Bit()); + ssize_t memoryFree, memoryTotal; GetRealMemoryMBAvailable(memoryFree, memoryTotal); - if (discFree > m_discPlanned / 1024 + 1) { + if (discFree > ssize_t(m_discPlanned / 1024 + 1)) { discFree -= m_discPlanned / 1024 + 1; } else if (discFree > 0) { // can also be -1 for unknown discFree = 0; } - if (memoryFree > m_memoryPlanned / 1024 + 1) { + if (memoryFree > ssize_t(m_memoryPlanned / 1024 + 1)) { memoryFree -= m_memoryPlanned / 1024 + 1; } else if (memoryFree > 0) { // can also be -1 for unknown memoryFree = 0; @@ -87,8 +87,8 @@ StorageStatus memoryStatus = Unknown; StorageStatus discStatus = Unknown; - int minmb = minimumSize / 1024 + 1; - int maxmb = maximumSize / 1024 + 1; + ssize_t minmb = ssize_t(minimumSize / 1024 + 1); + ssize_t maxmb = ssize_t(maximumSize / 1024 + 1); if (memoryFree == -1) memoryStatus = Unknown; else if (memoryFree < memoryTotal / 3) memoryStatus = Insufficient; @@ -185,7 +185,7 @@ } void -StorageAdviser::notifyPlannedAllocation(AllocationArea area, int size) +StorageAdviser::notifyPlannedAllocation(AllocationArea area, size_t size) { if (area == MemoryAllocation) m_memoryPlanned += size; else if (area == DiscAllocation) m_discPlanned += size; @@ -194,7 +194,7 @@ } void -StorageAdviser::notifyDoneAllocation(AllocationArea area, int size) +StorageAdviser::notifyDoneAllocation(AllocationArea area, size_t size) { if (area == MemoryAllocation) { if (m_memoryPlanned > size) m_memoryPlanned -= size;
--- a/base/StorageAdviser.h Tue Mar 03 09:33:59 2015 +0000 +++ b/base/StorageAdviser.h Tue Mar 03 15:18:24 2015 +0000 @@ -17,6 +17,8 @@ #ifndef _STORAGE_ADVISER_H_ #define _STORAGE_ADVISER_H_ +#include <cstdlib> + /** * A utility class designed to help decide whether to store cache data * (for example FFT outputs) in memory or on disk in the TempDirectory. @@ -57,8 +59,8 @@ * be nowhere the minimum amount of data can be stored. */ static Recommendation recommend(Criteria criteria, - int minimumSize, - int maximumSize); + size_t minimumSize, + size_t maximumSize); enum AllocationArea { MemoryAllocation, @@ -69,14 +71,14 @@ * Specify that we are planning to use a given amount of storage * (in kilobytes), but haven't allocated it yet. */ - static void notifyPlannedAllocation(AllocationArea area, int size); + static void notifyPlannedAllocation(AllocationArea area, size_t size); /** * Specify that we have now allocated, or abandoned the allocation * of, the given amount (in kilobytes) of a storage area that was * previously notified using notifyPlannedAllocation. */ - static void notifyDoneAllocation(AllocationArea area, int size); + static void notifyDoneAllocation(AllocationArea area, size_t size); /** * Force all subsequent recommendations to use the (perhaps @@ -86,8 +88,8 @@ static void setFixedRecommendation(Recommendation recommendation); private: - static long m_discPlanned; - static long m_memoryPlanned; + static size_t m_discPlanned; + static size_t m_memoryPlanned; static Recommendation m_baseRecommendation; };
--- a/base/TempDirectory.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/base/TempDirectory.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -110,7 +110,7 @@ QString suffix; int padlen = 6, attempts = 100; - unsigned int r = time(0) ^ getpid(); + unsigned int r = (unsigned int)(time(0) ^ getpid()); for (int i = 0; i < padlen; ++i) { suffix += "X";
--- a/base/Window.h Tue Mar 03 09:33:59 2015 +0000 +++ b/base/Window.h Tue Mar 03 15:18:24 2015 +0000 @@ -82,7 +82,7 @@ T m_area; void encache(); - void cosinewin(T *, T, T, T, T); + void cosinewin(T *, double, double, double, double); }; template <typename T> @@ -97,14 +97,14 @@ case RectangularWindow: for (i = 0; i < n; ++i) { - mult[i] *= 0.5; + mult[i] *= T(0.5); } break; case BartlettWindow: for (i = 0; i < n/2; ++i) { - mult[i] *= (i / T(n/2)); - mult[i + n/2] *= (1.0 - (i / T(n/2))); + mult[i] *= T(i) / T(n/2); + mult[i + n/2] *= T(1.0) - T(i) / T(n/2); } break; @@ -122,7 +122,7 @@ case GaussianWindow: for (i = 0; i < n; ++i) { - mult[i] *= pow(2, - pow((i - (n-1)/2.0) / ((n-1)/2.0 / 3), 2)); + mult[i] *= T(pow(2, - pow((i - (n-1)/2.0) / ((n-1)/2.0 / 3), 2))); } break; @@ -130,13 +130,13 @@ { int N = n-1; for (i = 0; i < N/4; ++i) { - T m = 2 * pow(1.0 - (T(N)/2 - i) / (T(N)/2), 3); + T m = T(2 * pow(1.0 - (T(N)/2 - T(i)) / (T(N)/2), 3)); mult[i] *= m; mult[N-i] *= m; } for (i = N/4; i <= N/2; ++i) { int wn = i - N/2; - T m = 1.0 - 6 * pow(wn / (T(N)/2), 2) * (1.0 - abs(wn) / (T(N)/2)); + T m = T(1.0 - 6 * pow(T(wn) / (T(N)/2), 2) * (1.0 - T(abs(wn)) / (T(N)/2))); mult[i] *= m; mult[N-i] *= m; } @@ -158,18 +158,18 @@ for (int i = 0; i < n; ++i) { m_area += m_cache[i]; } - m_area /= n; + m_area /= T(n); } template <typename T> -void Window<T>::cosinewin(T *mult, T a0, T a1, T a2, T a3) +void Window<T>::cosinewin(T *mult, double a0, double a1, double a2, double a3) { const int n = m_size; for (int i = 0; i < n; ++i) { - mult[i] *= (a0 - - a1 * cos((2 * M_PI * i) / n) - + a2 * cos((4 * M_PI * i) / n) - - a3 * cos((6 * M_PI * i) / n)); + mult[i] *= T(a0 + - a1 * cos((2 * M_PI * i) / n) + + a2 * cos((4 * M_PI * i) / n) + - a3 * cos((6 * M_PI * i) / n)); } }
--- a/configure Tue Mar 03 09:33:59 2015 +0000 +++ b/configure Tue Mar 03 15:18:24 2015 +0000 @@ -4343,9 +4343,10 @@ CXXFLAGS_MINIMAL="$AUTOCONF_CXXFLAGS" if test "x$GCC" = "xyes"; then - CXXFLAGS_DEBUG="-std=c++11 -Wall -Wextra -Werror -Woverloaded-virtual -Wformat-nonliteral -Wformat-security -Winit-self -Wswitch-enum -g -pipe" - CXXFLAGS_RELEASE="-std=c++11 -g0 -O2 -Wall -pipe" - CXXFLAGS_MINIMAL="-std=c++11 -g0 -O0" + CXXFLAGS_ANY="-std=c++11 -Wall -Wextra -Werror -Woverloaded-virtual -Wformat-nonliteral -Wformat-security -Winit-self -Wswitch-enum -Wconversion -pipe" + CXXFLAGS_DEBUG="$CXXFLAGS_ANY -g" + CXXFLAGS_RELEASE="$CXXFLAGS_ANY -g0 -O2" + CXXFLAGS_MINIMAL="$CXXFLAGS_ANY -g0 -O0" fi CXXFLAGS_BUILD="$CXXFLAGS_RELEASE"
--- a/configure.ac Tue Mar 03 09:33:59 2015 +0000 +++ b/configure.ac Tue Mar 03 15:18:24 2015 +0000 @@ -53,9 +53,10 @@ CXXFLAGS_MINIMAL="$AUTOCONF_CXXFLAGS" if test "x$GCC" = "xyes"; then - CXXFLAGS_DEBUG="-std=c++11 -Wall -Wextra -Werror -Woverloaded-virtual -Wformat-nonliteral -Wformat-security -Winit-self -Wswitch-enum -g -pipe" - CXXFLAGS_RELEASE="-std=c++11 -g0 -O2 -Wall -pipe" - CXXFLAGS_MINIMAL="-std=c++11 -g0 -O0" + CXXFLAGS_ANY="-std=c++11 -Wall -Wextra -Werror -Woverloaded-virtual -Wformat-nonliteral -Wformat-security -Winit-self -Wswitch-enum -Wconversion -pipe" + CXXFLAGS_DEBUG="$CXXFLAGS_ANY -g" + CXXFLAGS_RELEASE="$CXXFLAGS_ANY -g0 -O2" + CXXFLAGS_MINIMAL="$CXXFLAGS_ANY -g0 -O0" fi CXXFLAGS_BUILD="$CXXFLAGS_RELEASE"
--- a/data/fft/FFTDataServer.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fft/FFTDataServer.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -30,6 +30,8 @@ #include <QWriteLocker> +#include <stdexcept> + //#define DEBUG_FFT_SERVER 1 //#define DEBUG_FFT_SERVER_FILL 1 @@ -514,10 +516,10 @@ //!!! end is not correct until model finished reading -- what to do??? - int start = m_model->getStartFrame(); - int end = m_model->getEndFrame(); + sv_frame_t start = m_model->getStartFrame(); + sv_frame_t end = m_model->getEndFrame(); - m_width = (end - start) / m_windowIncrement + 1; + m_width = int((end - start) / m_windowIncrement) + 1; m_height = m_fftSize / 2 + 1; // DC == 0, Nyquist == fftsize/2 #ifdef DEBUG_FFT_SERVER @@ -526,7 +528,7 @@ #endif int maxCacheSize = 20 * 1024 * 1024; - int columnSize = m_height * sizeof(fftsample) * 2 + sizeof(fftsample); + int columnSize = int(m_height * sizeof(fftsample) * 2 + sizeof(fftsample)); if (m_width * columnSize < maxCacheSize * 2) m_cacheWidth = m_width; else m_cacheWidth = maxCacheSize / columnSize; @@ -681,9 +683,10 @@ FFTDataServer::getStorageAdvice(int w, int h, bool &memoryCache, bool &compactCache) { - int cells = w * h; - int minimumSize = (cells / 1024) * sizeof(uint16_t); // kb - int maximumSize = (cells / 1024) * sizeof(float); // kb + if (w < 0 || h < 0) throw std::domain_error("width & height must be non-negative"); + size_t cells = size_t(w) * h; + size_t minimumSize = (cells / 1024) * sizeof(uint16_t); // kb + size_t maximumSize = (cells / 1024) * sizeof(float); // kb // We don't have a compact rectangular representation, and compact // of course is never precision-critical @@ -1248,11 +1251,11 @@ int fftsize = m_fftSize; int hs = fftsize/2; - int pfx = 0; + sv_frame_t pfx = 0; int off = (fftsize - winsize) / 2; - int startFrame = m_windowIncrement * x; - int endFrame = startFrame + m_windowSize; + sv_frame_t startFrame = m_windowIncrement * sv_frame_t(x); + sv_frame_t endFrame = startFrame + m_windowSize; startFrame -= winsize / 2; endFrame -= winsize / 2; @@ -1300,11 +1303,11 @@ } } - int count = 0; + sv_frame_t count = 0; if (endFrame > startFrame + pfx) count = endFrame - (startFrame + pfx); - int got = m_model->getData(m_channel, startFrame + pfx, - count, m_fftInput + off + pfx); + sv_frame_t got = m_model->getData(m_channel, startFrame + pfx, + count, m_fftInput + off + pfx); while (got + pfx < winsize) { m_fftInput[off + got + pfx] = 0.0; @@ -1315,7 +1318,7 @@ int channels = m_model->getChannelCount(); if (channels > 1) { for (int i = 0; i < winsize; ++i) { - m_fftInput[off + i] /= channels; + m_fftInput[off + i] /= float(channels); } } } @@ -1404,7 +1407,7 @@ else return 100; } -int +sv_frame_t FFTDataServer::getFillExtent() const { if (m_fillThread) return m_fillThread->getExtent(); @@ -1456,18 +1459,18 @@ } if (m_server.m_exiting) return; - int start = m_server.m_model->getStartFrame(); - int end = m_server.m_model->getEndFrame(); - int remainingEnd = end; + sv_frame_t start = m_server.m_model->getStartFrame(); + sv_frame_t end = m_server.m_model->getEndFrame(); + sv_frame_t remainingEnd = end; int counter = 0; int updateAt = 1; - int maxUpdateAt = (end / m_server.m_windowIncrement) / 20; + int maxUpdateAt = int(end / m_server.m_windowIncrement) / 20; if (maxUpdateAt < 100) maxUpdateAt = 100; if (m_fillFrom > start) { - for (int f = m_fillFrom; f < end; f += m_server.m_windowIncrement) { + for (sv_frame_t f = m_fillFrom; f < end; f += m_server.m_windowIncrement) { try { m_server.fillColumn(int((f - start) / m_server.m_windowIncrement)); @@ -1516,7 +1519,7 @@ int baseCompletion = m_completion; - for (int f = start; f < remainingEnd; f += m_server.m_windowIncrement) { + for (sv_frame_t f = start; f < remainingEnd; f += m_server.m_windowIncrement) { try { m_server.fillColumn(int((f - start) / m_server.m_windowIncrement));
--- a/data/fft/FFTDataServer.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fft/FFTDataServer.h Tue Mar 03 15:18:24 2015 +0000 @@ -108,7 +108,7 @@ QString getError() const; int getFillCompletion() const; - int getFillExtent() const; + sv_frame_t getFillExtent() const; private: FFTDataServer(QString fileBaseName, @@ -245,16 +245,16 @@ m_server(server), m_extent(0), m_completion(0), m_fillFrom(fillFromColumn) { } - int getExtent() const { return m_extent; } + sv_frame_t 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; - int m_extent; + sv_frame_t m_extent; int m_completion; - int m_fillFrom; + sv_frame_t m_fillFrom; QString m_error; };
--- a/data/fft/FFTFileCacheReader.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fft/FFTFileCacheReader.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -40,7 +40,7 @@ m_mfc(new MatrixFile (writer->getFileBase(), MatrixFile::ReadOnly, - m_storageType == FFTCache::Compact ? sizeof(uint16_t) : sizeof(float), + int((m_storageType == FFTCache::Compact) ? sizeof(uint16_t) : sizeof(float)), writer->getWidth(), writer->getHeight() * 2 + m_factorSize)) { @@ -77,7 +77,7 @@ switch (m_storageType) { case FFTCache::Compact: - value = (getFromReadBufCompactUnsigned(x, y * 2) / 65535.0) + value = (getFromReadBufCompactUnsigned(x, y * 2) / 65535.f) * getNormalizationFactor(x); break; @@ -105,7 +105,7 @@ switch (m_storageType) { case FFTCache::Compact: - value = getFromReadBufCompactUnsigned(x, y * 2) / 65535.0; + value = getFromReadBufCompactUnsigned(x, y * 2) / 65535.f; break; case FFTCache::Rectangular: @@ -136,7 +136,7 @@ switch (m_storageType) { case FFTCache::Compact: - value = (getFromReadBufCompactSigned(x, y * 2 + 1) / 32767.0) * M_PI; + value = (getFromReadBufCompactSigned(x, y * 2 + 1) / 32767.f) * float(M_PI); break; case FFTCache::Rectangular: @@ -187,7 +187,7 @@ case FFTCache::Compact: for (int i = 0; i < count; ++i) { int y = minbin + i * step; - values[i] = (getFromReadBufCompactUnsigned(x, y * 2) / 65535.0) + values[i] = (getFromReadBufCompactUnsigned(x, y * 2) / 65535.f) * getNormalizationFactor(x); } break; @@ -224,7 +224,7 @@ return m_mfc->haveSetColumnAt(x); } -int +size_t FFTFileCacheReader::getCacheSize(int width, int height, FFTCache::StorageType type) {
--- a/data/fft/FFTFileCacheReader.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fft/FFTFileCacheReader.h Tue Mar 03 15:18:24 2015 +0000 @@ -41,7 +41,7 @@ bool haveSetColumnAt(int x) const; - static int getCacheSize(int width, int height, + static size_t getCacheSize(int width, int height, FFTCache::StorageType type); FFTCache::StorageType getStorageType() const { return m_storageType; }
--- a/data/fft/FFTFileCacheWriter.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fft/FFTFileCacheWriter.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -40,7 +40,7 @@ m_factorSize(storageType == FFTCache::Compact ? 2 : 1), m_mfc(new MatrixFile (fileBase, MatrixFile::WriteOnly, - storageType == FFTCache::Compact ? sizeof(uint16_t) : sizeof(float), + int((storageType == FFTCache::Compact) ? sizeof(uint16_t) : sizeof(float)), width, height * 2 + m_factorSize)) { #ifdef DEBUG_FFT_FILE_CACHE_WRITER @@ -175,7 +175,7 @@ m_mfc->setColumnAt(x, m_writebuf); } -int +size_t FFTFileCacheWriter::getCacheSize(int width, int height, FFTCache::StorageType type) {
--- a/data/fft/FFTFileCacheWriter.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fft/FFTFileCacheWriter.h Tue Mar 03 15:18:24 2015 +0000 @@ -34,7 +34,7 @@ void setColumnAt(int x, float *mags, float *phases, float factor); void setColumnAt(int x, float *reals, float *imags); - static int getCacheSize(int width, int height, + static size_t getCacheSize(int width, int height, FFTCache::StorageType type); bool haveSetColumnAt(int x) const;
--- a/data/fft/FFTMemoryCache.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fft/FFTMemoryCache.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -196,10 +196,10 @@ } } -int +size_t FFTMemoryCache::getCacheSize(int width, int height, FFTCache::StorageType type) { - int sz = 0; + size_t sz = 0; switch (type) {
--- a/data/fft/FFTMemoryCache.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fft/FFTMemoryCache.h Tue Mar 03 15:18:24 2015 +0000 @@ -66,7 +66,7 @@ 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; + else return float(m_magnitude[x][y]) / 65535.f; } float getMaximumMagnitudeAt(int x) const { @@ -81,7 +81,7 @@ return m_fphase[x][y]; } else { int16_t i = (int16_t)m_phase[x][y]; - return (float(i) / 32767.0) * M_PI; + return float(i / 32767.0 * M_PI); } } @@ -114,7 +114,7 @@ } else { for (int i = 0; i < count; ++i) { int y = i * step + minbin; - values[i] = (float(m_magnitude[x][y]) * m_factor[x]) / 65535.0; + values[i] = float(double(m_magnitude[x][y]) * m_factor[x] / 65535.0); } } } @@ -132,7 +132,7 @@ void allColumnsWritten() { } - static int getCacheSize(int width, int height, + static size_t getCacheSize(int width, int height, FFTCache::StorageType type); FFTCache::StorageType getStorageType() const { return m_storageType; }
--- a/data/fileio/AudioFileReader.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fileio/AudioFileReader.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -16,14 +16,14 @@ #include "AudioFileReader.h" void -AudioFileReader::getDeInterleavedFrames(int start, int count, +AudioFileReader::getDeInterleavedFrames(sv_frame_t start, sv_frame_t count, std::vector<SampleBlock> &frames) const { SampleBlock interleaved; getInterleavedFrames(start, count, interleaved); int channels = getChannelCount(); - int rc = interleaved.size() / channels; + sv_frame_t rc = interleaved.size() / channels; frames.clear(); @@ -31,7 +31,7 @@ frames.push_back(SampleBlock()); } - for (int i = 0; i < rc; ++i) { + for (sv_frame_t i = 0; i < rc; ++i) { for (int c = 0; c < channels; ++c) { frames[c].push_back(interleaved[i * channels + c]); }
--- a/data/fileio/AudioFileReader.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fileio/AudioFileReader.h Tue Mar 03 15:18:24 2015 +0000 @@ -18,6 +18,7 @@ #include <QString> +#include "base/BaseTypes.h" #include "FileSource.h" #include <vector> @@ -36,7 +37,7 @@ virtual QString getError() const { return ""; } - int getFrameCount() const { return m_frameCount; } + sv_frame_t getFrameCount() const { return m_frameCount; } int getChannelCount() const { return m_channelCount; } int getSampleRate() const { return m_sampleRate; } @@ -93,7 +94,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(int start, int count, + virtual void getInterleavedFrames(sv_frame_t start, sv_frame_t count, SampleBlock &frames) const = 0; /** @@ -103,7 +104,7 @@ * will contain getChannelCount() sample blocks of count samples * each (or fewer if end of file is reached). */ - virtual void getDeInterleavedFrames(int start, int count, + virtual void getDeInterleavedFrames(sv_frame_t start, sv_frame_t count, std::vector<SampleBlock> &frames) const; // only subclasses that do not know exactly how long the audio @@ -116,7 +117,7 @@ void frameCountChanged(); protected: - int m_frameCount; + sv_frame_t m_frameCount; int m_channelCount; int m_sampleRate; };
--- a/data/fileio/BZipFileDevice.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fileio/BZipFileDevice.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -178,7 +178,7 @@ if (m_atEnd) return 0; int bzError = BZ_OK; - int read = BZ2_bzRead(&bzError, m_bzFile, data, maxSize); + int read = BZ2_bzRead(&bzError, m_bzFile, data, int(maxSize)); // SVDEBUG << "BZipFileDevice::readData: requested " << maxSize << ", read " << read << endl; @@ -201,7 +201,7 @@ BZipFileDevice::writeData(const char *data, qint64 maxSize) { int bzError = BZ_OK; - BZ2_bzWrite(&bzError, m_bzFile, (void *)data, maxSize); + BZ2_bzWrite(&bzError, m_bzFile, (void *)data, int(maxSize)); // SVDEBUG << "BZipFileDevice::writeData: " << maxSize << " to write" << endl;
--- a/data/fileio/CSVFileReader.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fileio/CSVFileReader.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -95,7 +95,7 @@ return m_error; } -int +sv_frame_t CSVFileReader::convertTimeValue(QString s, int lineno, int sampleRate, int windowSize) const { @@ -104,7 +104,7 @@ CSVFormat::TimeUnits timeUnits = m_format.getTimeUnits(); - int calculatedFrame = 0; + sv_frame_t calculatedFrame = 0; bool ok = false; QString numeric = s; @@ -114,13 +114,13 @@ double time = numeric.toDouble(&ok); if (!ok) time = StringBits::stringToDoubleLocaleFree(numeric, &ok); - calculatedFrame = int(time * sampleRate + 0.5); + calculatedFrame = sv_frame_t(time * sampleRate + 0.5); } else if (timeUnits == CSVFormat::TimeMilliseconds) { double time = numeric.toDouble(&ok); if (!ok) time = StringBits::stringToDoubleLocaleFree(numeric, &ok); - calculatedFrame = int((time / 1000.0) * sampleRate + 0.5); + calculatedFrame = sv_frame_t((time / 1000.0) * sampleRate + 0.5); } else { @@ -189,15 +189,15 @@ float min = 0.0, max = 0.0; - int frameNo = 0; - int duration = 0; - int endFrame = 0; + sv_frame_t frameNo = 0; + sv_frame_t duration = 0; + sv_frame_t endFrame = 0; bool haveAnyValue = false; bool haveEndTime = false; bool pitchLooksLikeMIDI = true; - int startFrame = 0; // for calculation of dense model resolution + sv_frame_t startFrame = 0; // for calculation of dense model resolution bool firstEverValue = true; std::map<QString, int> labelCountMap; @@ -373,7 +373,7 @@ model3->setStartFrame(startFrame); } else if (lineno == 1 && timingType == CSVFormat::ExplicitTiming) { - model3->setResolution(frameNo - startFrame); + model3->setResolution(int(frameNo - startFrame)); } firstEverValue = false;
--- a/data/fileio/CSVFileReader.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fileio/CSVFileReader.h Tue Mar 03 15:18:24 2015 +0000 @@ -20,6 +20,8 @@ #include "CSVFormat.h" +#include "base/BaseTypes.h" + #include <QList> #include <QStringList> @@ -58,8 +60,8 @@ mutable int m_warnings; int m_mainModelSampleRate; - int convertTimeValue(QString, int lineno, int sampleRate, - int windowSize) const; + sv_frame_t convertTimeValue(QString, int lineno, int sampleRate, + int windowSize) const; };
--- a/data/fileio/CSVFileWriter.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fileio/CSVFileWriter.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -95,7 +95,7 @@ selection->getSelections().begin(); i != selection->getSelections().end(); ++i) { - int f0(i->getStartFrame()), f1(i->getEndFrame()); + sv_frame_t f0(i->getStartFrame()), f1(i->getEndFrame()); out << m_model->toDelimitedDataStringSubset(m_delimiter, f0, f1); }
--- a/data/fileio/CodedAudioFileReader.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fileio/CodedAudioFileReader.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -113,9 +113,9 @@ m_resampler = new Resampler(Resampler::FastestTolerable, m_channelCount, m_cacheWriteBufferSize); - float ratio = float(m_sampleRate) / float(m_fileRate); + double ratio = double(m_sampleRate) / double(m_fileRate); m_resampleBuffer = new float - [lrintf(ceilf(m_cacheWriteBufferSize * m_channelCount * ratio + 1))]; + [lrint(ceil(double(m_cacheWriteBufferSize) * m_channelCount * ratio + 1))]; } m_cacheWriteBuffer = new float[m_cacheWriteBufferSize * m_channelCount]; @@ -176,13 +176,13 @@ } void -CodedAudioFileReader::addSamplesToDecodeCache(float **samples, int nframes) +CodedAudioFileReader::addSamplesToDecodeCache(float **samples, sv_frame_t nframes) { QMutexLocker locker(&m_cacheMutex); if (!m_initialised) return; - for (int i = 0; i < nframes; ++i) { + for (sv_frame_t i = 0; i < nframes; ++i) { for (int c = 0; c < m_channelCount; ++c) { @@ -206,13 +206,13 @@ } void -CodedAudioFileReader::addSamplesToDecodeCache(float *samples, int nframes) +CodedAudioFileReader::addSamplesToDecodeCache(float *samples, sv_frame_t nframes) { QMutexLocker locker(&m_cacheMutex); if (!m_initialised) return; - for (int i = 0; i < nframes; ++i) { + for (sv_frame_t i = 0; i < nframes; ++i) { for (int c = 0; c < m_channelCount; ++c) { @@ -242,9 +242,7 @@ if (!m_initialised) return; - for (int i = 0; i < (int)samples.size(); ++i) { - - float sample = samples[i]; + for (float sample: samples) { m_cacheWriteBuffer[m_cacheWriteBufferIndex++] = sample; @@ -295,7 +293,7 @@ } void -CodedAudioFileReader::pushBuffer(float *buffer, int sz, bool final) +CodedAudioFileReader::pushBuffer(float *buffer, sv_frame_t sz, bool final) { m_fileFrameCount += sz; @@ -312,13 +310,13 @@ } void -CodedAudioFileReader::pushBufferNonResampling(float *buffer, int sz) +CodedAudioFileReader::pushBufferNonResampling(float *buffer, sv_frame_t sz) { float clip = 1.0; - int count = sz * m_channelCount; + sv_frame_t count = sz * m_channelCount; if (m_normalised) { - for (int i = 0; i < count; ++i) { + for (sv_frame_t i = 0; i < count; ++i) { float v = fabsf(buffer[i]); if (v > m_max) { m_max = v; @@ -326,10 +324,10 @@ } } } else { - for (int i = 0; i < count; ++i) { + for (sv_frame_t i = 0; i < count; ++i) { if (buffer[i] > clip) buffer[i] = clip; } - for (int i = 0; i < count; ++i) { + for (sv_frame_t i = 0; i < count; ++i) { if (buffer[i] < -clip) buffer[i] = -clip; } } @@ -339,7 +337,7 @@ switch (m_cacheMode) { case CacheInTemporaryFile: - if (sf_writef_float(m_cacheFileWritePtr, buffer, sz) < (int)sz) { + if (sf_writef_float(m_cacheFileWritePtr, buffer, sz) < sz) { sf_close(m_cacheFileWritePtr); m_cacheFileWritePtr = 0; throw InsufficientDiscSpace(TempDirectory::getInstance()->getPath()); @@ -348,7 +346,7 @@ case CacheInMemory: m_dataLock.lockForWrite(); - for (int s = 0; s < count; ++s) { + for (sv_frame_t s = 0; s < count; ++s) { m_data.push_back(buffer[s]); } MUNLOCK_SAMPLEBLOCK(m_data); @@ -358,14 +356,14 @@ } void -CodedAudioFileReader::pushBufferResampling(float *buffer, int sz, - float ratio, bool final) +CodedAudioFileReader::pushBufferResampling(float *buffer, sv_frame_t sz, + double ratio, bool final) { SVDEBUG << "pushBufferResampling: ratio = " << ratio << ", sz = " << sz << ", final = " << final << endl; if (sz > 0) { - int out = m_resampler->resampleInterleaved + sv_frame_t out = m_resampler->resampleInterleaved (buffer, m_resampleBuffer, sz, @@ -377,27 +375,27 @@ if (final) { - int padFrames = 1; - if (m_frameCount / ratio < m_fileFrameCount) { - padFrames = m_fileFrameCount - (m_frameCount / ratio) + 1; + sv_frame_t padFrames = 1; + if (double(m_frameCount) / ratio < double(m_fileFrameCount)) { + padFrames = m_fileFrameCount - sv_frame_t(double(m_frameCount) / ratio) + 1; } - int padSamples = padFrames * m_channelCount; + sv_frame_t padSamples = padFrames * m_channelCount; - SVDEBUG << "frameCount = " << m_frameCount << ", equivFileFrames = " << m_frameCount / ratio << ", m_fileFrameCount = " << m_fileFrameCount << ", padFrames= " << padFrames << ", padSamples = " << padSamples << endl; + SVDEBUG << "frameCount = " << m_frameCount << ", equivFileFrames = " << double(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; + for (sv_frame_t i = 0; i < padSamples; ++i) padding[i] = 0.f; - int out = m_resampler->resampleInterleaved + sv_frame_t out = m_resampler->resampleInterleaved (padding, m_resampleBuffer, padFrames, ratio, true); - if (int(m_frameCount + out) > int(m_fileFrameCount * ratio)) { - out = int(m_fileFrameCount * ratio) - int(m_frameCount); + if (m_frameCount + out > sv_frame_t(double(m_fileFrameCount) * ratio)) { + out = sv_frame_t(double(m_fileFrameCount) * ratio) - m_frameCount; } pushBufferNonResampling(m_resampleBuffer, out); @@ -406,7 +404,7 @@ } void -CodedAudioFileReader::getInterleavedFrames(int start, int count, +CodedAudioFileReader::getInterleavedFrames(sv_frame_t start, sv_frame_t count, SampleBlock &frames) const { // Lock is only required in CacheInMemory mode (the cache file @@ -433,11 +431,11 @@ if (count == 0) return; frames.reserve(count * m_channelCount); - int idx = start * m_channelCount; - int i = 0; + sv_frame_t idx = start * m_channelCount; + sv_frame_t i = 0; m_dataLock.lockForRead(); - while (i < count * m_channelCount && idx < (int)m_data.size()) { + while (i < count * m_channelCount && idx < (sv_frame_t)m_data.size()) { frames.push_back(m_data[idx]); ++idx; } @@ -446,7 +444,7 @@ } if (m_normalised) { - for (int i = 0; i < (int)(count * m_channelCount); ++i) { + for (sv_frame_t i = 0; i < (sv_frame_t)(count * m_channelCount); ++i) { frames[i] *= m_gain; } }
--- a/data/fileio/CodedAudioFileReader.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fileio/CodedAudioFileReader.h Tue Mar 03 15:18:24 2015 +0000 @@ -38,7 +38,7 @@ CacheInMemory }; - virtual void getInterleavedFrames(int start, int count, + virtual void getInterleavedFrames(sv_frame_t start, sv_frame_t count, SampleBlock &frames) const; virtual int getNativeRate() const { return m_fileRate; } @@ -59,8 +59,8 @@ void initialiseDecodeCache(); // samplerate, channels must have been set // may throw InsufficientDiscSpace: - void addSamplesToDecodeCache(float **samples, int nframes); - void addSamplesToDecodeCache(float *samplesInterleaved, int nframes); + void addSamplesToDecodeCache(float **samples, sv_frame_t nframes); + void addSamplesToDecodeCache(float *samplesInterleaved, sv_frame_t nframes); void addSamplesToDecodeCache(const SampleBlock &interleaved); // may throw InsufficientDiscSpace: @@ -72,9 +72,9 @@ void endSerialised(); private: - void pushBuffer(float *interleaved, int sz, bool final); - void pushBufferResampling(float *interleaved, int sz, float ratio, bool final); - void pushBufferNonResampling(float *interleaved, int sz); + void pushBuffer(float *interleaved, sv_frame_t sz, bool final); + void pushBufferResampling(float *interleaved, sv_frame_t sz, double ratio, bool final); + void pushBufferNonResampling(float *interleaved, sv_frame_t sz); protected: QMutex m_cacheMutex; @@ -89,12 +89,12 @@ SNDFILE *m_cacheFileWritePtr; WavFileReader *m_cacheFileReader; float *m_cacheWriteBuffer; - int m_cacheWriteBufferIndex; - int m_cacheWriteBufferSize; // frames + sv_frame_t m_cacheWriteBufferIndex; + sv_frame_t m_cacheWriteBufferSize; // frames Resampler *m_resampler; float *m_resampleBuffer; - int m_fileFrameCount; + sv_frame_t m_fileFrameCount; bool m_normalised; float m_max;
--- a/data/fileio/DecodingWavFileReader.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fileio/DecodingWavFileReader.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -64,14 +64,14 @@ (tr("Decoding %1...").arg(QFileInfo(m_path).fileName())); } - int blockSize = 16384; - int total = m_original->getFrameCount(); + sv_frame_t blockSize = 16384; + sv_frame_t total = m_original->getFrameCount(); SampleBlock block; - for (int i = 0; i < total; i += blockSize) { + for (sv_frame_t i = 0; i < total; i += blockSize) { - int count = blockSize; + sv_frame_t count = blockSize; if (i + count > total) count = total - i; m_original->getInterleavedFrames(i, count, block); @@ -121,14 +121,14 @@ m_reader->startSerialised("DecodingWavFileReader::Decode"); } - int blockSize = 16384; - int total = m_reader->m_original->getFrameCount(); + sv_frame_t blockSize = 16384; + sv_frame_t total = m_reader->m_original->getFrameCount(); SampleBlock block; - for (int i = 0; i < total; i += blockSize) { + for (sv_frame_t i = 0; i < total; i += blockSize) { - int count = blockSize; + sv_frame_t count = blockSize; if (i + count > total) count = total - i; m_reader->m_original->getInterleavedFrames(i, count, block); @@ -153,10 +153,10 @@ m_processed += frames.size(); - float ratio = float(m_sampleRate) / float(m_fileRate); + double ratio = double(m_sampleRate) / double(m_fileRate); - int progress = lrint((float(m_processed) * ratio * 100) / - float(m_original->getFrameCount())); + int progress = int(lrint((double(m_processed) * ratio * 100) / + double(m_original->getFrameCount()))); if (progress > 99) progress = 99; m_completion = progress;
--- a/data/fileio/DecodingWavFileReader.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fileio/DecodingWavFileReader.h Tue Mar 03 15:18:24 2015 +0000 @@ -63,7 +63,7 @@ QString m_path; QString m_error; bool m_cancelled; - int m_processed; + sv_frame_t m_processed; int m_completion; WavFileReader *m_original;
--- a/data/fileio/MIDIFileReader.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fileio/MIDIFileReader.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -301,7 +301,9 @@ // Set file size so we can count it off // m_midiFile->seekg(0, ios::end); - m_fileSize = m_midiFile->tellg(); + std::streamoff off = m_midiFile->tellg(); + m_fileSize = 0; + if (off > 0) m_fileSize = off; m_midiFile->seekg(0, ios::beg); // Parse the MIDI header first. The first 14 bytes of the file. @@ -440,9 +442,9 @@ MIDIByte midiByte, metaEventCode, data1, data2; MIDIByte eventCode = 0x80; string metaMessage; - unsigned int messageLength; - unsigned long deltaTime; - unsigned long accumulatedTime = 0; + long messageLength; + long deltaTime; + long accumulatedTime = 0; // The trackNum passed in to this method is the default track for // all events provided they're all on the same channel. If we find @@ -890,7 +892,7 @@ if (tracksToLoad.empty()) return 0; - int n = tracksToLoad.size(), count = 0; + int n = int(tracksToLoad.size()), count = 0; Model *model = 0; for (std::set<unsigned int>::iterator i = tracksToLoad.begin(); @@ -938,7 +940,7 @@ const MIDITrack &track = m_midiComposition.find(trackToLoad)->second; - int totalEvents = track.size(); + int totalEvents = int(track.size()); int count = 0; bool sharpKey = true;
--- a/data/fileio/MIDIFileReader.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fileio/MIDIFileReader.h Tue Mar 03 15:18:24 2015 +0000 @@ -126,7 +126,7 @@ QString m_path; std::ifstream *m_midiFile; - int m_fileSize; + size_t m_fileSize; QString m_error; int m_mainModelSampleRate;
--- a/data/fileio/MIDIFileWriter.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fileio/MIDIFileWriter.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -89,8 +89,8 @@ MIDIByte upper; MIDIByte lower; - upper = (number & 0xFF00) >> 8; - lower = (number & 0x00FF); + upper = MIDIByte((number & 0xFF00) >> 8); + lower = MIDIByte( number & 0x00FF); string rv; rv += upper; @@ -106,10 +106,10 @@ MIDIByte upper2; MIDIByte lower2; - upper1 = (number & 0xff000000) >> 24; - lower1 = (number & 0x00ff0000) >> 16; - upper2 = (number & 0x0000ff00) >> 8; - lower2 = (number & 0x000000ff); + upper1 = MIDIByte((number & 0xff000000) >> 24); + lower1 = MIDIByte((number & 0x00ff0000) >> 16); + upper2 = MIDIByte((number & 0x0000ff00) >> 8); + lower2 = MIDIByte((number & 0x000000ff)); string rv; rv += upper1; @@ -344,8 +344,8 @@ for (NoteList::const_iterator i = notes.begin(); i != notes.end(); ++i) { - int frame = i->start; - int duration = i->duration; + sv_frame_t frame = i->start; + sv_frame_t duration = i->duration; int pitch = i->midiPitch; int velocity = i->velocity; int channel = i->channel;
--- a/data/fileio/MP3FileReader.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fileio/MP3FileReader.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -86,7 +86,7 @@ } ssize_t sz = 0; - int offset = 0; + ssize_t offset = 0; while (offset < m_fileSize) { sz = ::read(fd, m_filebuffer + offset, m_fileSize - offset); if (sz < 0) { @@ -291,7 +291,7 @@ } bool -MP3FileReader::decode(void *mm, int sz) +MP3FileReader::decode(void *mm, sv_frame_t sz) { DecoderData data; struct mad_decoder decoder; @@ -320,7 +320,7 @@ #ifdef HAVE_ID3TAG if (length > ID3_TAG_QUERYSIZE) { - int taglen = id3_tag_query(start, ID3_TAG_QUERYSIZE); + ssize_t taglen = id3_tag_query(start, ID3_TAG_QUERYSIZE); if (taglen > 0) { // cerr << "ID3 tag length to skip: " << taglen << endl; start += taglen; @@ -352,7 +352,7 @@ int frames = pcm->length; if (header) { - m_bitrateNum += header->bitrate; + m_bitrateNum = m_bitrateNum + double(header->bitrate); m_bitrateDenom ++; }
--- a/data/fileio/MP3FileReader.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fileio/MP3FileReader.h Tue Mar 03 15:18:24 2015 +0000 @@ -73,7 +73,7 @@ QString m_title; QString m_maker; TagMap m_tags; - int m_fileSize; + sv_frame_t m_fileSize; double m_bitrateNum; int m_bitrateDenom; int m_completion; @@ -93,7 +93,7 @@ MP3FileReader *reader; }; - bool decode(void *mm, int sz); + bool decode(void *mm, sv_frame_t sz); enum mad_flow accept(struct mad_header const *, struct mad_pcm *); static enum mad_flow input(void *, struct mad_stream *);
--- a/data/fileio/MatchFileReader.cpp Tue Mar 03 09:33:59 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,187 +0,0 @@ -/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ - -/* - Sonic Visualiser - An audio file viewer and annotation editor. - Centre for Digital Music, Queen Mary, University of London. - This file copyright 2007 QMUL. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. See the file - COPYING included with this distribution for more information. -*/ - -#include "MatchFileReader.h" - -#include <QFile> -#include <QTextStream> - -#include <cmath> -#include <iostream> - -Alignment::Alignment() : - thisHopTime(0.0), - refHopTime(0.0), - m_mainModel(0) -{ -} - -double -Alignment::fromReference(double t) const -{ - int ri = lrint(t / refHopTime); - int index = search(refIndex, ri); - return thisIndex[index] * thisHopTime; -} - -double -Alignment::toReference(double t) const -{ - int ti = lrint(t / thisHopTime); - int index = search(thisIndex, ti); - return refIndex[index] * refHopTime; -} - -int -Alignment::search(const FrameArray &arr, int val) const -{ - int len = arr.size(); - int max = len - 1; - int min = 0; - while (max > min) { - int mid = (max + min) / 2; - if (val > arr[mid]) { - min = mid + 1; - } else { - max = mid; - } - } // max = MIN_j (arr[j] >= val) i.e. the first equal or next highest - while ((max + 1 < len) && (arr[max + 1] == val)) { - max++; - } - return (min + max) / 2; -} - -MatchFileReader::MatchFileReader(QString path) : - m_file(0) -{ - m_file = new QFile(path); - bool good = false; - - if (!m_file->exists()) { - m_error = QFile::tr("File \"%1\" does not exist").arg(path); - } else if (!m_file->open(QIODevice::ReadOnly | QIODevice::Text)) { - m_error = QFile::tr("Failed to open file \"%1\"").arg(path); - } else { - good = true; - } - - if (!good) { - delete m_file; - m_file = 0; - } -} - -MatchFileReader::~MatchFileReader() -{ - if (m_file) { - SVDEBUG << "MatchFileReader::MatchFileReader: Closing file" << endl; - m_file->close(); - } - delete m_file; -} - -bool -MatchFileReader::isOK() const -{ - return (m_file != 0); -} - -QString -MatchFileReader::getError() const -{ - return m_error; -} - -Alignment -MatchFileReader::load() const -{ - Alignment alignment; - - if (!m_file) return alignment; - - QTextStream in(m_file); - -/* -File: /home/studio/match-test/mahler-3-boulez-5.wav -Marks: -1 -FixedPoints: true 0 -0 -0 -0 -0 -File: /home/studio/match-test/mahler-3-haitink-5.wav -Marks: 0 -FixedPoints: true 0 -0.02 -0.02 -12836 -*/ - - int fileCount = 0; - int state = 0; - int count = 0; - - while (!in.atEnd()) { - - QString line = in.readLine().trimmed(); - if (line.startsWith("File: ")) { - ++fileCount; - continue; - } - if (fileCount != 2) continue; - if (line.startsWith("Marks:") || line.startsWith("FixedPoints:")) { - continue; - } - - switch (state) { - case 0: - alignment.thisHopTime = line.toDouble(); - break; - case 1: - alignment.refHopTime = line.toDouble(); - break; - case 2: - count = line.toInt(); - break; - case 3: - alignment.thisIndex.push_back(line.toInt()); - break; - case 4: - alignment.refIndex.push_back(line.toInt()); - break; - } - - if (state < 3) { - ++state; - } else if (state == 3 && int(alignment.thisIndex.size()) == count) { - ++state; - } - } - - if (alignment.thisHopTime == 0.0) { - cerr << "ERROR in Match file: this hop time == 0, using 0.01 instead" << endl; - alignment.thisHopTime = 0.01; - } - - if (alignment.refHopTime == 0.0) { - cerr << "ERROR in Match file: ref hop time == 0, using 0.01 instead" << endl; - alignment.refHopTime = 0.01; - } - - cerr << "MatchFileReader: this hop = " << alignment.thisHopTime << ", ref hop = " << alignment.refHopTime << ", this index count = " << alignment.thisIndex.size() << ", ref index count = " << alignment.refIndex.size() << endl; - - return alignment; -}
--- a/data/fileio/MatchFileReader.h Tue Mar 03 09:33:59 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ - -/* - Sonic Visualiser - An audio file viewer and annotation editor. - Centre for Digital Music, Queen Mary, University of London. - This file copyright 2007 QMUL. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. See the file - COPYING included with this distribution for more information. -*/ - -#ifndef _MATCH_FILE_READER_H_ -#define _MATCH_FILE_READER_H_ - -#include <vector> -#include <QString> -#include "base/Debug.h" - -class QFile; -class Model; - -class Alignment -{ -public: - Alignment(); - - typedef std::vector<int> FrameArray; - - double thisHopTime; - double refHopTime; - - FrameArray thisIndex; - FrameArray refIndex; - - double fromReference(double) const; - double toReference(double) const; - - //!!! blah - void setMainModel(Model *m) { m_mainModel = m; } - bool isMainModel(Model *m) const { return m == m_mainModel; } - - int search(const FrameArray &arr, int val) const; - -protected: - Model *m_mainModel; -}; - -class MatchFileReader -{ -public: - MatchFileReader(QString path); - virtual ~MatchFileReader(); - - virtual bool isOK() const; - virtual QString getError() const; - virtual Alignment load() const; - -protected: - QFile *m_file; - QString m_error; -}; - -#endif -
--- a/data/fileio/WavFileReader.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fileio/WavFileReader.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -89,7 +89,7 @@ { QMutexLocker locker(&m_mutex); - int prevCount = m_fileInfo.frames; + sv_frame_t prevCount = m_fileInfo.frames; if (m_file) { sf_close(m_file); @@ -123,7 +123,7 @@ } void -WavFileReader::getInterleavedFrames(int start, int count, +WavFileReader::getInterleavedFrames(sv_frame_t start, sv_frame_t count, SampleBlock &results) const { if (count == 0) return; @@ -173,7 +173,7 @@ m_lastCount = readCount; } - for (int i = 0; i < count * m_fileInfo.channels; ++i) { + for (sv_frame_t i = 0; i < count * m_fileInfo.channels; ++i) { if (i >= m_bufsiz) { cerr << "INTERNAL ERROR: WavFileReader::getInterleavedFrames: " << i << " >= " << m_bufsiz << endl; }
--- a/data/fileio/WavFileReader.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fileio/WavFileReader.h Tue Mar 03 15:18:24 2015 +0000 @@ -50,7 +50,7 @@ * Must be safe to call from multiple threads with different * arguments on the same object at the same time. */ - virtual void getInterleavedFrames(int start, int count, + virtual void getInterleavedFrames(sv_frame_t start, sv_frame_t count, SampleBlock &frames) const; static void getSupportedExtensions(std::set<QString> &extensions); @@ -77,9 +77,9 @@ mutable QMutex m_mutex; mutable float *m_buffer; - mutable int m_bufsiz; - mutable int m_lastStart; - mutable int m_lastCount; + mutable sv_frame_t m_bufsiz; + mutable sv_frame_t m_lastStart; + mutable sv_frame_t m_lastCount; bool m_updating; };
--- a/data/fileio/WavFileWriter.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fileio/WavFileWriter.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -120,7 +120,7 @@ ownSelection = true; } - int bs = 2048; + sv_frame_t bs = 2048; float *ub = new float[bs]; // uninterleaved buffer (one channel) float *ib = new float[bs * m_channels]; // interleaved buffer @@ -128,11 +128,11 @@ selection->getSelections().begin(); i != selection->getSelections().end(); ++i) { - int f0(i->getStartFrame()), f1(i->getEndFrame()); + sv_frame_t f0(i->getStartFrame()), f1(i->getEndFrame()); - for (int f = f0; f < f1; f += bs) { + for (sv_frame_t f = f0; f < f1; f += bs) { - int n = std::min(bs, f1 - f); + sv_frame_t n = std::min(bs, f1 - f); for (int c = 0; c < int(m_channels); ++c) { source->getData(c, f, n, ub); @@ -159,7 +159,7 @@ } bool -WavFileWriter::writeSamples(float **samples, int count) +WavFileWriter::writeSamples(float **samples, sv_frame_t count) { if (!m_file) { m_error = QString("Failed to write model to audio file '%1': File not open") @@ -168,17 +168,17 @@ } float *b = new float[count * m_channels]; - for (int i = 0; i < int(count); ++i) { + for (sv_frame_t i = 0; i < count; ++i) { for (int c = 0; c < int(m_channels); ++c) { b[i * m_channels + c] = samples[c][i]; } } - sf_count_t written = sf_writef_float(m_file, b, count); + sv_frame_t written = sf_writef_float(m_file, b, count); delete[] b; - if (written < int(count)) { + if (written < count) { m_error = QString("Only wrote %1 of %2 frames") .arg(written).arg(count); }
--- a/data/fileio/WavFileWriter.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/fileio/WavFileWriter.h Tue Mar 03 15:18:24 2015 +0000 @@ -20,6 +20,8 @@ #include <sndfile.h> +#include "base/BaseTypes.h" + class DenseTimeValueModel; class MultiSelection; class TempWriteFile; @@ -57,7 +59,7 @@ bool writeModel(DenseTimeValueModel *source, MultiSelection *selection = 0); - bool writeSamples(float **samples, int count); // count per channel + bool writeSamples(float **samples, sv_frame_t count); // count per channel bool close();
--- a/data/midi/MIDIEvent.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/midi/MIDIEvent.h Tue Mar 03 15:18:24 2015 +0000 @@ -25,6 +25,8 @@ #include <QString> #include <string> #include <iostream> +#include <stdexcept> + #include "base/Debug.h" typedef unsigned char MIDIByte; @@ -118,16 +120,22 @@ { public: MIDIEvent(unsigned long deltaTime, - MIDIByte eventCode, - MIDIByte data1 = 0, - MIDIByte data2 = 0) : + int eventCode, + int data1 = 0, + int data2 = 0) : m_deltaTime(deltaTime), m_duration(0), - m_eventCode(eventCode), - m_data1(data1), - m_data2(data2), m_metaEventCode(0) - { } + { + if (eventCode < 0 || eventCode > 0xff || + data1 < 0 || data1 > 0xff || + data2 < 0 || data2 > 0xff) { + throw std::domain_error("not all args within byte range"); + } + m_eventCode = MIDIByte(eventCode); + m_data1 = MIDIByte(data1); + m_data2 = MIDIByte(data2); + } MIDIEvent(unsigned long deltaTime, MIDIByte eventCode,
--- a/data/midi/rtmidi/RtMidi.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/midi/rtmidi/RtMidi.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -835,7 +835,7 @@ if ( data->firstMessage == true ) data->firstMessage = false; else - message.timeStamp = time * 0.000001; + message.timeStamp = double(time) * 0.000001; } snd_seq_free_event(ev); @@ -947,9 +947,9 @@ snd_seq_addr_t sender, receiver; - sender.client = snd_seq_port_info_get_client( pinfo ); - sender.port = snd_seq_port_info_get_port( pinfo ); - receiver.client = snd_seq_client_id( data->seq ); + sender.client = (unsigned char)snd_seq_port_info_get_client( pinfo ); + sender.port = (unsigned char)snd_seq_port_info_get_port( pinfo ); + receiver.client = (unsigned char)snd_seq_client_id( data->seq ); if ( data->vport < 0 ) { snd_seq_port_info_set_client( pinfo, 0 ); snd_seq_port_info_set_port( pinfo, 0 ); @@ -972,7 +972,7 @@ } } - receiver.port = data->vport; + receiver.port = (unsigned char)data->vport; // Make subscription snd_seq_port_subscribe_malloc( &data->subscription ); @@ -1222,9 +1222,9 @@ } snd_seq_addr_t sender, receiver; - receiver.client = snd_seq_port_info_get_client( pinfo ); - receiver.port = snd_seq_port_info_get_port( pinfo ); - sender.client = snd_seq_client_id( data->seq ); + receiver.client = (unsigned char)snd_seq_port_info_get_client( pinfo ); + receiver.port = (unsigned char)snd_seq_port_info_get_port( pinfo ); + sender.client = (unsigned char)snd_seq_client_id( data->seq ); if ( data->vport < 0 ) { data->vport = snd_seq_create_simple_port( data->seq, portName.c_str(), @@ -1236,7 +1236,7 @@ } } - sender.port = data->vport; + sender.port = (unsigned char)data->vport; // Make subscription snd_seq_port_subscribe_malloc( &data->subscription ); @@ -1295,7 +1295,7 @@ { int result; AlsaMidiData *data = static_cast<AlsaMidiData *> (apiData_); - unsigned int nBytes = message->size(); + unsigned int nBytes = (unsigned int) message->size(); if ( nBytes > data->bufferSize ) { data->bufferSize = nBytes; result = snd_midi_event_resize_buffer ( data->coder, nBytes); @@ -1313,11 +1313,11 @@ snd_seq_event_t ev; snd_seq_ev_clear(&ev); - snd_seq_ev_set_source(&ev, data->vport); + snd_seq_ev_set_source(&ev, (unsigned char) data->vport); snd_seq_ev_set_subs(&ev); snd_seq_ev_set_direct(&ev); for ( unsigned int i=0; i<nBytes; i++ ) data->buffer[i] = message->at(i); - result = snd_midi_event_encode( data->coder, data->buffer, (long)nBytes, &ev ); + result = (int) snd_midi_event_encode( data->coder, data->buffer, (long)nBytes, &ev ); if ( result < (int)nBytes ) { errorString_ = "RtMidiOut::sendMessage: event parsing error!"; error( RtError::WARNING );
--- a/data/model/AggregateWaveModel.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/AggregateWaveModel.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -65,14 +65,14 @@ return ready; } -int +sv_frame_t AggregateWaveModel::getFrameCount() const { - int count = 0; + sv_frame_t count = 0; for (ChannelSpecList::const_iterator i = m_components.begin(); i != m_components.end(); ++i) { - int thisCount = i->model->getEndFrame() - i->model->getStartFrame(); + sv_frame_t thisCount = i->model->getEndFrame() - i->model->getStartFrame(); if (thisCount > count) count = thisCount; } @@ -82,7 +82,7 @@ int AggregateWaveModel::getChannelCount() const { - return m_components.size(); + return int(m_components.size()); } int @@ -98,8 +98,8 @@ return new AggregateWaveModel(m_components); } -int -AggregateWaveModel::getData(int channel, int start, int count, +sv_frame_t +AggregateWaveModel::getData(int channel, sv_frame_t start, sv_frame_t count, float *buffer) const { int ch0 = channel, ch1 = channel; @@ -113,15 +113,15 @@ float *readbuf = buffer; if (mixing) { readbuf = new float[count]; - for (int i = 0; i < count; ++i) { + for (sv_frame_t i = 0; i < count; ++i) { buffer[i] = 0.f; } } - int longest = 0; + sv_frame_t longest = 0; for (int c = ch0; c <= ch1; ++c) { - int here = + sv_frame_t here = m_components[c].model->getData(m_components[c].channel, start, count, readbuf); @@ -129,12 +129,12 @@ longest = here; } if (here < count) { - for (int i = here; i < count; ++i) { + for (sv_frame_t i = here; i < count; ++i) { readbuf[i] = 0.f; } } if (mixing) { - for (int i = 0; i < count; ++i) { + for (sv_frame_t i = 0; i < count; ++i) { buffer[i] += readbuf[i]; } } @@ -144,8 +144,8 @@ return longest; } -int -AggregateWaveModel::getData(int channel, int start, int count, +sv_frame_t +AggregateWaveModel::getData(int channel, sv_frame_t start, sv_frame_t count, double *buffer) const { int ch0 = channel, ch1 = channel; @@ -159,15 +159,15 @@ double *readbuf = buffer; if (mixing) { readbuf = new double[count]; - for (int i = 0; i < count; ++i) { + for (sv_frame_t i = 0; i < count; ++i) { buffer[i] = 0.0; } } - int longest = 0; + sv_frame_t longest = 0; for (int c = ch0; c <= ch1; ++c) { - int here = + sv_frame_t here = m_components[c].model->getData(m_components[c].channel, start, count, readbuf); @@ -175,12 +175,12 @@ longest = here; } if (here < count) { - for (int i = here; i < count; ++i) { + for (sv_frame_t i = here; i < count; ++i) { readbuf[i] = 0.; } } if (mixing) { - for (int i = 0; i < count; ++i) { + for (sv_frame_t i = 0; i < count; ++i) { buffer[i] += readbuf[i]; } } @@ -190,15 +190,15 @@ return longest; } -int +sv_frame_t AggregateWaveModel::getData(int fromchannel, int tochannel, - int start, int count, + sv_frame_t start, sv_frame_t count, float **buffer) const { - int min = count; + sv_frame_t min = count; for (int c = fromchannel; c <= tochannel; ++c) { - int here = getData(c, start, count, buffer[c - fromchannel]); + sv_frame_t here = getData(c, start, count, buffer[c - fromchannel]); if (here < min) min = here; } @@ -213,14 +213,14 @@ } void -AggregateWaveModel::getSummaries(int, int, int, +AggregateWaveModel::getSummaries(int, sv_frame_t, sv_frame_t, RangeBlock &, int &) const { //!!! complete } AggregateWaveModel::Range -AggregateWaveModel::getSummary(int, int, int) const +AggregateWaveModel::getSummary(int, sv_frame_t, sv_frame_t) const { //!!! complete return Range(); @@ -229,7 +229,7 @@ int AggregateWaveModel::getComponentCount() const { - return m_components.size(); + return int(m_components.size()); } AggregateWaveModel::ModelChannelSpec @@ -245,7 +245,7 @@ } void -AggregateWaveModel::componentModelChangedWithin(int start, int end) +AggregateWaveModel::componentModelChangedWithin(sv_frame_t start, sv_frame_t end) { emit modelChangedWithin(start, end); }
--- a/data/model/AggregateWaveModel.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/AggregateWaveModel.h Tue Mar 03 15:18:24 2015 +0000 @@ -49,7 +49,7 @@ const ZoomConstraint *getZoomConstraint() const { return &m_zoomConstraint; } - int getFrameCount() const; + sv_frame_t getFrameCount() const; int getChannelCount() const; int getSampleRate() const; @@ -58,26 +58,26 @@ float getValueMinimum() const { return -1.0f; } float getValueMaximum() const { return 1.0f; } - virtual int getStartFrame() const { return 0; } - virtual int getEndFrame() const { return getFrameCount(); } + virtual sv_frame_t getStartFrame() const { return 0; } + virtual sv_frame_t getEndFrame() const { return getFrameCount(); } - virtual int getData(int channel, int start, int count, + virtual sv_frame_t getData(int channel, sv_frame_t start, sv_frame_t count, float *buffer) const; - virtual int getData(int channel, int start, int count, + virtual sv_frame_t getData(int channel, sv_frame_t start, sv_frame_t count, double *buffer) const; - virtual int getData(int fromchannel, int tochannel, - int start, int count, + virtual sv_frame_t getData(int fromchannel, int tochannel, + sv_frame_t start, sv_frame_t count, float **buffer) const; virtual int getSummaryBlockSize(int desired) const; - virtual void getSummaries(int channel, int start, int count, + virtual void getSummaries(int channel, sv_frame_t start, sv_frame_t count, RangeBlock &ranges, int &blockSize) const; - virtual Range getSummary(int channel, int start, int count) const; + virtual Range getSummary(int channel, sv_frame_t start, sv_frame_t count) const; virtual void toXml(QTextStream &out, QString indent = "", @@ -85,12 +85,12 @@ signals: void modelChanged(); - void modelChangedWithin(int, int); + void modelChangedWithin(sv_frame_t, sv_frame_t); void completionChanged(); protected slots: void componentModelChanged(); - void componentModelChangedWithin(int, int); + void componentModelChangedWithin(sv_frame_t, sv_frame_t); void componentModelCompletionChanged(); protected:
--- a/data/model/AlignmentModel.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/AlignmentModel.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -37,8 +37,8 @@ connect(m_rawPath, SIGNAL(modelChanged()), this, SLOT(pathChanged())); - connect(m_rawPath, SIGNAL(modelChangedWithin(int, int)), - this, SLOT(pathChangedWithin(int, int))); + connect(m_rawPath, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), + this, SLOT(pathChangedWithin(sv_frame_t, sv_frame_t))); connect(m_rawPath, SIGNAL(completionChanged()), this, SLOT(pathCompletionChanged())); @@ -74,19 +74,19 @@ else return true; } -int +sv_frame_t AlignmentModel::getStartFrame() const { - int a = m_reference->getStartFrame(); - int b = m_aligned->getStartFrame(); + sv_frame_t a = m_reference->getStartFrame(); + sv_frame_t b = m_aligned->getStartFrame(); return std::min(a, b); } -int +sv_frame_t AlignmentModel::getEndFrame() const { - int a = m_reference->getEndFrame(); - int b = m_aligned->getEndFrame(); + sv_frame_t a = m_reference->getEndFrame(); + sv_frame_t b = m_aligned->getEndFrame(); return std::max(a, b); } @@ -144,8 +144,8 @@ return m_aligned; } -int -AlignmentModel::toReference(int frame) const +sv_frame_t +AlignmentModel::toReference(sv_frame_t frame) const { #ifdef DEBUG_ALIGNMENT_MODEL SVDEBUG << "AlignmentModel::toReference(" << frame << ")" << endl; @@ -157,8 +157,8 @@ return align(m_path, frame); } -int -AlignmentModel::fromReference(int frame) const +sv_frame_t +AlignmentModel::fromReference(sv_frame_t frame) const { #ifdef DEBUG_ALIGNMENT_MODEL SVDEBUG << "AlignmentModel::fromReference(" << frame << ")" << endl; @@ -182,7 +182,7 @@ } void -AlignmentModel::pathChangedWithin(int, int) +AlignmentModel::pathChangedWithin(sv_frame_t, sv_frame_t) { if (!m_pathComplete) return; constructPath(); @@ -242,9 +242,9 @@ for (SparseTimeValueModel::PointList::const_iterator i = points.begin(); i != points.end(); ++i) { - long frame = i->frame; - float value = i->value; - long rframe = lrintf(value * m_aligned->getSampleRate()); + sv_frame_t frame = i->frame; + double value = i->value; + sv_frame_t rframe = lrint(value * m_aligned->getSampleRate()); m_path->addPoint(PathPoint(frame, rframe)); } @@ -274,8 +274,8 @@ for (PathModel::PointList::const_iterator i = points.begin(); i != points.end(); ++i) { - long frame = i->frame; - long rframe = i->mapframe; + sv_frame_t frame = i->frame; + sv_frame_t rframe = i->mapframe; m_reversePath->addPoint(PathPoint(rframe, frame)); } @@ -284,8 +284,8 @@ #endif } -int -AlignmentModel::align(PathModel *path, int frame) const +sv_frame_t +AlignmentModel::align(PathModel *path, sv_frame_t frame) const { if (!path) return frame; @@ -315,13 +315,13 @@ #endif --i; } - while (i != points.begin() && i->frame > long(frame)) --i; + while (i != points.begin() && i->frame > frame) --i; - long foundFrame = i->frame; - long foundMapFrame = i->mapframe; + sv_frame_t foundFrame = i->frame; + sv_frame_t foundMapFrame = i->mapframe; - long followingFrame = foundFrame; - long followingMapFrame = foundMapFrame; + sv_frame_t followingFrame = foundFrame; + sv_frame_t followingMapFrame = foundMapFrame; if (++i != points.end()) { #ifdef DEBUG_ALIGNMENT_MODEL @@ -337,13 +337,13 @@ if (foundMapFrame < 0) return 0; - int resultFrame = foundMapFrame; + sv_frame_t resultFrame = foundMapFrame; - if (followingFrame != foundFrame && long(frame) > foundFrame) { - float interp = - float(frame - foundFrame) / - float(followingFrame - foundFrame); - resultFrame += lrintf((followingMapFrame - foundMapFrame) * interp); + if (followingFrame != foundFrame && frame > foundFrame) { + double interp = + double(frame - foundFrame) / + double(followingFrame - foundFrame); + resultFrame += lrint(double(followingMapFrame - foundMapFrame) * interp); } #ifdef DEBUG_ALIGNMENT_MODEL
--- a/data/model/AlignmentModel.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/AlignmentModel.h Tue Mar 03 15:18:24 2015 +0000 @@ -37,8 +37,8 @@ ~AlignmentModel(); virtual bool isOK() const; - virtual int getStartFrame() const; - virtual int getEndFrame() const; + virtual sv_frame_t getStartFrame() const; + virtual sv_frame_t getEndFrame() const; virtual int getSampleRate() const; virtual Model *clone() const; virtual bool isReady(int *completion = 0) const; @@ -49,8 +49,8 @@ const Model *getReferenceModel() const; const Model *getAlignedModel() const; - int toReference(int frame) const; - int fromReference(int frame) const; + sv_frame_t toReference(sv_frame_t frame) const; + sv_frame_t fromReference(sv_frame_t frame) const; void setPathFrom(SparseTimeValueModel *rawpath); void setPath(PathModel *path); @@ -61,12 +61,12 @@ signals: void modelChanged(); - void modelChangedWithin(int startFrame, int endFrame); + void modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame); void completionChanged(); protected slots: void pathChanged(); - void pathChangedWithin(int startFrame, int endFrame); + void pathChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame); void pathCompletionChanged(); protected: @@ -84,7 +84,7 @@ void constructPath() const; void constructReversePath() const; - int align(PathModel *path, int frame) const; + sv_frame_t align(PathModel *path, sv_frame_t frame) const; }; #endif
--- a/data/model/Dense3DModelPeakCache.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/Dense3DModelPeakCache.h Tue Mar 03 15:18:24 2015 +0000 @@ -37,11 +37,11 @@ return m_source->getSampleRate(); } - virtual int getStartFrame() const { + virtual sv_frame_t getStartFrame() const { return m_source->getStartFrame(); } - virtual int getEndFrame() const { + virtual sv_frame_t getEndFrame() const { return m_source->getEndFrame(); }
--- a/data/model/DenseThreeDimensionalModel.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/DenseThreeDimensionalModel.h Tue Mar 03 15:18:24 2015 +0000 @@ -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(int n) const { return n; } + virtual float getBinValue(int n) const { return float(n); } /** * Obtain the name of the unit of the values returned from @@ -171,11 +171,11 @@ return SortNumeric; } - virtual long getFrameForRow(int row) const { - return row * getResolution(); + virtual sv_frame_t getFrameForRow(int row) const { + return sv_frame_t(row) * getResolution(); } - virtual int getRowForFrame(long frame) const { - return frame / getResolution(); + virtual int getRowForFrame(sv_frame_t frame) const { + return int(frame / getResolution()); } protected:
--- a/data/model/DenseTimeValueModel.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/DenseTimeValueModel.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -29,7 +29,7 @@ } QString -DenseTimeValueModel::toDelimitedDataStringSubset(QString delimiter, int f0, int f1) const +DenseTimeValueModel::toDelimitedDataStringSubset(QString delimiter, sv_frame_t f0, sv_frame_t f1) const { int ch = getChannelCount(); @@ -42,10 +42,10 @@ all[c] = new float[f1 - f0]; } - int n = getData(0, ch - 1, f0, f1 - f0, all); + sv_frame_t n = getData(0, ch - 1, f0, f1 - f0, all); QStringList list; - for (int i = 0; i < n; ++i) { + for (sv_frame_t i = 0; i < n; ++i) { QStringList parts; parts << QString("%1").arg(f0 + i); for (int c = 0; c < ch; ++c) {
--- a/data/model/DenseTimeValueModel.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/DenseTimeValueModel.h Tue Mar 03 15:18:24 2015 +0000 @@ -62,8 +62,8 @@ * If the channel is given as -1, mix all available channels and * return the result. */ - virtual int getData(int channel, int start, int count, - float *buffer) const = 0; + virtual sv_frame_t getData(int channel, sv_frame_t start, sv_frame_t count, + float *buffer) const = 0; /** * Get the specified set of samples from the given channel of the @@ -72,22 +72,22 @@ * If the channel is given as -1, mix all available channels and * return the result. */ - virtual int getData(int channel, int start, int count, - double *buffer) const = 0; - + virtual sv_frame_t getData(int channel, sv_frame_t start, sv_frame_t count, + double *buffer) const = 0; + /** * Get the specified set of samples from given contiguous range * of channels of the model in single-precision floating-point * format. Return the number of sample frames actually retrieved. */ - virtual int getData(int fromchannel, int tochannel, - int start, int count, - float **buffers) const = 0; + virtual sv_frame_t getData(int fromchannel, int tochannel, + sv_frame_t start, sv_frame_t count, + float **buffers) const = 0; virtual bool canPlay() const { return true; } virtual QString getDefaultPlayClipId() const { return ""; } - virtual QString toDelimitedDataStringSubset(QString delimiter, int f0, int f1) const; + virtual QString toDelimitedDataStringSubset(QString delimiter, sv_frame_t f0, sv_frame_t f1) const; QString getTypeName() const { return tr("Dense Time-Value"); } };
--- a/data/model/EditableDenseThreeDimensionalModel.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/EditableDenseThreeDimensionalModel.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -61,19 +61,19 @@ return m_sampleRate; } -int +sv_frame_t EditableDenseThreeDimensionalModel::getStartFrame() const { return m_startFrame; } void -EditableDenseThreeDimensionalModel::setStartFrame(int f) +EditableDenseThreeDimensionalModel::setStartFrame(sv_frame_t f) { m_startFrame = f; } -int +sv_frame_t EditableDenseThreeDimensionalModel::getEndFrame() const { return m_resolution * m_data.size() + (m_resolution - 1); @@ -255,7 +255,7 @@ tcol[i - bcount] = values.at(i); } m_data[index] = tcol; - m_trunc[index] = -tdist; + m_trunc[index] = (signed char)(-tdist); return; } else { // create a new column with h - tcount values from 0 up @@ -266,7 +266,7 @@ tcol[i] = values.at(i); } m_data[index] = tcol; - m_trunc[index] = tdist; + m_trunc[index] = (signed char)(tdist); return; } } @@ -465,7 +465,7 @@ if (sample.empty()) return false; for (int j = 0; j < sample.size(); ++j) { - if (n[j]) sample[j] /= n[j]; + if (n[j]) sample[j] /= float(n[j]); } return LogRange::useLogScale(sample.toStdVector()); @@ -515,13 +515,13 @@ } QString -EditableDenseThreeDimensionalModel::toDelimitedDataStringSubset(QString delimiter, int f0, int f1) const +EditableDenseThreeDimensionalModel::toDelimitedDataStringSubset(QString delimiter, sv_frame_t f0, sv_frame_t f1) const { QReadLocker locker(&m_lock); QString s; for (int i = 0; i < m_data.size(); ++i) { - int fr = m_startFrame + i * m_resolution; - if (fr >= int(f0) && fr < int(f1)) { + sv_frame_t fr = m_startFrame + i * m_resolution; + if (fr >= f0 && fr < f1) { QStringList list; for (int j = 0; j < m_data.at(i).size(); ++j) { list << QString("%1").arg(m_data.at(i).at(j));
--- a/data/model/EditableDenseThreeDimensionalModel.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/EditableDenseThreeDimensionalModel.h Tue Mar 03 15:18:24 2015 +0000 @@ -51,8 +51,8 @@ virtual bool isOK() const; virtual int getSampleRate() const; - virtual int getStartFrame() const; - virtual int getEndFrame() const; + virtual sv_frame_t getStartFrame() const; + virtual sv_frame_t getEndFrame() const; virtual Model *clone() const; @@ -60,7 +60,7 @@ /** * Set the frame offset of the first column. */ - virtual void setStartFrame(int); + virtual void setStartFrame(sv_frame_t); /** * Return the number of sample frames covered by each set of bins. @@ -190,7 +190,7 @@ QString getTypeName() const { return tr("Editable Dense 3-D"); } virtual QString toDelimitedDataString(QString delimiter) const; - virtual QString toDelimitedDataStringSubset(QString delimiter, int f0, int f1) const; + virtual QString toDelimitedDataStringSubset(QString delimiter, sv_frame_t f0, sv_frame_t f1) const; virtual void toXml(QTextStream &out, QString indent = "", @@ -216,7 +216,7 @@ std::vector<float> m_binValues; QString m_binValueUnit; - int m_startFrame; + sv_frame_t m_startFrame; int m_sampleRate; int m_resolution; int m_yBinCount;
--- a/data/model/FFTModel.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/FFTModel.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -212,7 +212,7 @@ int sampleRate = m_server->getModel()->getSampleRate(); int fftSize = m_server->getFFTSize() >> m_yshift; - frequency = (float(y) * sampleRate) / fftSize; + frequency = float((double(y) * sampleRate) / fftSize); if (x+1 >= getWidth()) return false; @@ -225,14 +225,14 @@ // = 2pi * ((h * b * sr) / (w * sr)) // = 2pi * (h * b) / w. - float oldPhase = getPhaseAt(x, y); - float newPhase = getPhaseAt(x+1, y); + double oldPhase = getPhaseAt(x, y); + double newPhase = getPhaseAt(x+1, y); int incr = getResolution(); - float expectedPhase = oldPhase + (2.0 * M_PI * y * incr) / fftSize; + double expectedPhase = oldPhase + (2.0 * M_PI * y * incr) / fftSize; - float phaseError = princargf(newPhase - expectedPhase); + double phaseError = princarg(newPhase - expectedPhase); // bool stable = (fabsf(phaseError) < (1.1f * (m_windowIncrement * M_PI) / m_fftSize)); @@ -240,8 +240,8 @@ // from assuming the "native" frequency of this bin frequency = - (sampleRate * (expectedPhase + phaseError - oldPhase)) / - (2 * M_PI * incr); + float((sampleRate * (expectedPhase + phaseError - oldPhase)) / + (2 * M_PI * incr)); return true; } @@ -284,8 +284,8 @@ float mean = 0.f; for (int i = 0; i < values.size(); ++i) mean += values[i]; - if (values.size() >0) mean /= values.size(); - + if (values.size() > 0) mean = mean / float(values.size()); + // For peak picking we use a moving median window, picking the // highest value within each continuous region of values that // exceed the median. For pitch adaptivity, we adjust the window @@ -324,7 +324,7 @@ window.pop_front(); } - int actualSize = window.size(); + int actualSize = int(window.size()); if (type == MajorPitchAdaptivePeaks) { if (ymax + halfWin < values.size()) binmax = ymax + halfWin; @@ -333,7 +333,7 @@ std::deque<float> sorted(window); std::sort(sorted.begin(), sorted.end()); - float median = sorted[int(sorted.size() * dist)]; + float median = sorted[int(float(sorted.size()) * dist)]; int centrebin = 0; if (bin > actualSize/2) centrebin = bin - actualSize/2; @@ -381,14 +381,14 @@ if (bin == 0) return 3; int fftSize = m_server->getFFTSize() >> m_yshift; - float binfreq = (float(sampleRate) * bin) / fftSize; - float hifreq = Pitch::getFrequencyForPitch(73, 0, binfreq); + double binfreq = (double(sampleRate) * bin) / fftSize; + double hifreq = Pitch::getFrequencyForPitch(73, 0, binfreq); - int hibin = lrintf((hifreq * fftSize) / sampleRate); + int hibin = int(lrint((hifreq * fftSize) / sampleRate)); int medianWinSize = hibin - bin; if (medianWinSize < 3) medianWinSize = 3; - percentile = 0.5 + (binfreq / sampleRate); + percentile = 0.5f + float(binfreq / sampleRate); return medianWinSize; } @@ -421,16 +421,16 @@ int phaseIndex = 0; for (PeakLocationSet::iterator i = locations.begin(); i != locations.end(); ++i) { - float oldPhase = phases[phaseIndex]; - float newPhase = getPhaseAt(x+1, *i); - float expectedPhase = oldPhase + (2.0 * M_PI * *i * incr) / fftSize; - float phaseError = princargf(newPhase - expectedPhase); - float frequency = + double oldPhase = phases[phaseIndex]; + double newPhase = getPhaseAt(x+1, *i); + double expectedPhase = oldPhase + (2.0 * M_PI * *i * incr) / fftSize; + double phaseError = princarg(newPhase - expectedPhase); + double frequency = (sampleRate * (expectedPhase + phaseError - oldPhase)) / (2 * M_PI * incr); // bool stable = (fabsf(phaseError) < (1.1f * (incr * M_PI) / fftSize)); // if (stable) - peaks[*i] = frequency; + peaks[*i] = float(frequency); ++phaseIndex; }
--- a/data/model/FFTModel.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/FFTModel.h Tue Mar 03 15:18:24 2015 +0000 @@ -98,7 +98,7 @@ return m_server->getValuesAt(x << m_xshift, reals, imaginaries, minbin << m_yshift, count, getYRatio()); } - inline int getFillExtent() const { return m_server->getFillExtent(); } + inline sv_frame_t getFillExtent() const { return m_server->getFillExtent(); } // DenseThreeDimensionalModel and Model methods: // @@ -120,11 +120,11 @@ virtual bool isOK() const { return m_server && m_server->getModel(); } - virtual int getStartFrame() const { + virtual sv_frame_t getStartFrame() const { return 0; } - virtual int getEndFrame() const { - return getWidth() * getResolution() + getResolution(); + virtual sv_frame_t getEndFrame() const { + return sv_frame_t(getWidth()) * getResolution() + getResolution(); } virtual int getSampleRate() const; virtual int getResolution() const {
--- a/data/model/IntervalModel.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/IntervalModel.h Tue Mar 03 15:18:24 2015 +0000 @@ -55,7 +55,7 @@ * given frame. Consequently this can be very slow (optimised * data structures still to be done!). */ - virtual typename SparseValueModel<PointType>::PointList getPoints(long frame) const; + virtual typename SparseValueModel<PointType>::PointList getPoints(sv_frame_t frame) const; virtual const typename SparseModel<PointType>::PointList &getPoints() const { return SparseModel<PointType>::getPoints(); @@ -107,7 +107,7 @@ switch (column) { // column cannot be 0 or 1, those cases were handled above - case 2: point.value = value.toDouble(); break; + case 2: point.value = float(value.toDouble()); break; case 3: point.duration = value.toInt(); break; } @@ -125,7 +125,7 @@ template <typename PointType> typename SparseValueModel<PointType>::PointList -IntervalModel<PointType>::getPoints(long start, long end) const +IntervalModel<PointType>::getPoints(sv_frame_t start, sv_frame_t end) const { typedef IntervalModel<PointType> I; @@ -146,7 +146,7 @@ for (typename I::PointListConstIterator i = endItr; i != I::m_points.begin(); ) { --i; if (i->frame < start) { - if (i->frame + long(i->duration) >= start) { + if (i->frame + i->duration >= start) { rv.insert(*i); } } else if (i->frame <= end) { @@ -159,7 +159,7 @@ template <typename PointType> typename SparseValueModel<PointType>::PointList -IntervalModel<PointType>::getPoints(long frame) const +IntervalModel<PointType>::getPoints(sv_frame_t frame) const { typedef IntervalModel<PointType> I; @@ -168,8 +168,8 @@ if (I::m_resolution == 0) return typename I::PointList(); - long start = (frame / I::m_resolution) * I::m_resolution; - long end = start + I::m_resolution; + sv_frame_t start = (frame / I::m_resolution) * I::m_resolution; + sv_frame_t end = start + I::m_resolution; PointType endPoint(end); @@ -180,7 +180,7 @@ for (typename I::PointListConstIterator i = endItr; i != I::m_points.begin(); ) { --i; if (i->frame < start) { - if (i->frame + long(i->duration) >= start) { + if (i->frame + i->duration >= start) { rv.insert(*i); } } else if (i->frame <= end) {
--- a/data/model/Model.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/Model.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -110,30 +110,30 @@ return m_alignment->getReferenceModel(); } -int -Model::alignToReference(int frame) const +sv_frame_t +Model::alignToReference(sv_frame_t frame) const { // cerr << "Model(" << this << ")::alignToReference(" << frame << ")" << endl; if (!m_alignment) { if (m_sourceModel) return m_sourceModel->alignToReference(frame); else return frame; } - int refFrame = m_alignment->toReference(frame); + sv_frame_t refFrame = m_alignment->toReference(frame); const Model *m = m_alignment->getReferenceModel(); if (m && refFrame > m->getEndFrame()) refFrame = m->getEndFrame(); // cerr << "have alignment, aligned is " << refFrame << endl; return refFrame; } -int -Model::alignFromReference(int refFrame) const +sv_frame_t +Model::alignFromReference(sv_frame_t refFrame) const { // cerr << "Model(" << this << ")::alignFromReference(" << refFrame << ")" << endl; if (!m_alignment) { if (m_sourceModel) return m_sourceModel->alignFromReference(refFrame); else return refFrame; } - int frame = m_alignment->fromReference(refFrame); + sv_frame_t frame = m_alignment->fromReference(refFrame); if (frame > getEndFrame()) frame = getEndFrame(); // cerr << "have alignment, aligned is " << frame << endl; return frame;
--- a/data/model/Model.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/Model.h Tue Mar 03 15:18:24 2015 +0000 @@ -21,6 +21,7 @@ #include "base/XmlExportable.h" #include "base/Playable.h" +#include "base/BaseTypes.h" typedef std::vector<float> SampleBlock; @@ -50,12 +51,12 @@ /** * Return the first audio frame spanned by the model. */ - virtual int getStartFrame() const = 0; + virtual sv_frame_t getStartFrame() const = 0; /** * Return the last audio frame spanned by the model. */ - virtual int getEndFrame() const = 0; + virtual sv_frame_t getEndFrame() const = 0; /** * Return the frame rate in frames per second. @@ -200,13 +201,13 @@ * Return the frame number of the reference model that corresponds * to the given frame number in this model. */ - virtual int alignToReference(int frame) const; + virtual sv_frame_t alignToReference(sv_frame_t frame) const; /** * Return the frame number in this model that corresponds to the * given frame number of the reference model. */ - virtual int alignFromReference(int referenceFrame) const; + virtual sv_frame_t alignFromReference(sv_frame_t referenceFrame) const; /** * Return the completion percentage for the alignment model: 100 @@ -236,7 +237,7 @@ virtual QString toDelimitedDataString(QString delimiter) const { return toDelimitedDataStringSubset(delimiter, getStartFrame(), getEndFrame()); } - virtual QString toDelimitedDataStringSubset(QString, int /* f0 */, int /* f1 */) const { + virtual QString toDelimitedDataStringSubset(QString, sv_frame_t /* f0 */, sv_frame_t /* f1 */) const { return ""; } @@ -255,7 +256,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 modelChangedWithin(int startFrame, int endFrame); + void modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame); /** * Emitted when some internal processing has advanced a stage, but
--- a/data/model/ModelDataTableModel.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/ModelDataTableModel.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -155,14 +155,14 @@ } QModelIndex -ModelDataTableModel::getModelIndexForFrame(int frame) const +ModelDataTableModel::getModelIndexForFrame(sv_frame_t frame) const { if (!m_model) return createIndex(0, 0); int row = m_model->getRowForFrame(frame); return createIndex(getSorted(row), 0, (void *)0); } -int +sv_frame_t ModelDataTableModel::getFrameForModelIndex(const QModelIndex &index) const { if (!m_model) return 0;
--- a/data/model/ModelDataTableModel.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/ModelDataTableModel.h Tue Mar 03 15:18:24 2015 +0000 @@ -20,6 +20,8 @@ #include <vector> +#include "base/BaseTypes.h" + class TabularModel; class Command; @@ -51,8 +53,8 @@ int rowCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const; - QModelIndex getModelIndexForFrame(int frame) const; - int getFrameForModelIndex(const QModelIndex &) const; + QModelIndex getModelIndexForFrame(sv_frame_t frame) const; + sv_frame_t getFrameForModelIndex(const QModelIndex &) const; void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
--- a/data/model/NoteData.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/NoteData.h Tue Mar 03 15:18:24 2015 +0000 @@ -21,12 +21,12 @@ struct NoteData { - NoteData(int _start, int _dur, int _mp, int _vel) : + NoteData(sv_frame_t _start, sv_frame_t _dur, int _mp, int _vel) : start(_start), duration(_dur), midiPitch(_mp), frequency(0), isMidiPitchQuantized(true), velocity(_vel), channel(0) { }; - int start; // audio sample frame - int duration; // in audio sample frames + sv_frame_t start; // audio sample frame + sv_frame_t duration; // in audio sample frames int midiPitch; // 0-127 float frequency; // Hz, to be used if isMidiPitchQuantized false bool isMidiPitchQuantized; @@ -35,7 +35,7 @@ float getFrequency() const { if (isMidiPitchQuantized) { - return Pitch::getFrequencyForPitch(midiPitch); + return float(Pitch::getFrequencyForPitch(midiPitch)); } else { return frequency; } @@ -48,7 +48,7 @@ { public: virtual NoteList getNotes() const = 0; - virtual NoteList getNotesWithin(int startFrame, int endFrame) const = 0; + virtual NoteList getNotesWithin(sv_frame_t startFrame, sv_frame_t endFrame) const = 0; }; #endif
--- a/data/model/NoteModel.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/NoteModel.h Tue Mar 03 15:18:24 2015 +0000 @@ -38,15 +38,15 @@ struct Note { public: - Note(long _frame) : frame(_frame), value(0.0f), duration(0), level(1.f) { } - Note(long _frame, float _value, int _duration, float _level, QString _label) : + Note(sv_frame_t _frame) : frame(_frame), value(0.0f), duration(0), level(1.f) { } + Note(sv_frame_t _frame, float _value, sv_frame_t _duration, float _level, QString _label) : frame(_frame), value(_value), duration(_duration), level(_level), label(_label) { } int getDimensions() const { return 3; } - long frame; + sv_frame_t frame; float value; - int duration; + sv_frame_t duration; float level; QString label; @@ -202,7 +202,7 @@ command->deletePoint(point); switch (column) { - case 4: point.level = value.toDouble(); break; + case 4: point.level = float(value.toDouble()); break; case 5: point.label = value.toString(); break; } @@ -224,7 +224,7 @@ return getNotesWithin(getStartFrame(), getEndFrame()); } - NoteList getNotesWithin(int startFrame, int endFrame) const { + NoteList getNotesWithin(sv_frame_t startFrame, sv_frame_t endFrame) const { PointList points = getPoints(startFrame, endFrame); NoteList notes; @@ -232,16 +232,16 @@ for (PointList::iterator pli = points.begin(); pli != points.end(); ++pli) { - int duration = pli->duration; + sv_frame_t duration = pli->duration; if (duration == 0 || duration == 1) { duration = getSampleRate() / 20; } - int pitch = lrintf(pli->value); + int pitch = int(lrintf(pli->value)); int velocity = 100; if (pli->level > 0.f && pli->level <= 1.f) { - velocity = lrintf(pli->level * 127); + velocity = int(lrintf(pli->level * 127)); } NoteData note(pli->frame, duration, pitch, velocity);
--- a/data/model/PowerOfSqrtTwoZoomConstraint.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/PowerOfSqrtTwoZoomConstraint.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -44,12 +44,13 @@ float val = 1.0, prevVal = 1.0; while (val + 0.01 < blockSize) { prevVal = val; - val *= sqrt(2.f); + val *= sqrtf(2.f); } 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); + if (dir == RoundUp) rval = int(val + 0.01f); + else if (dir == RoundDown) rval = int(prevVal + 0.01f); + else if (val - float(blockSize) < + float(blockSize) - prevVal) rval = int(val + 0.01f); else rval = int(prevVal + 0.01); // SVDEBUG << "returning " << rval << endl; return rval;
--- a/data/model/RangeSummarisableTimeValueModel.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/RangeSummarisableTimeValueModel.h Tue Mar 03 15:18:24 2015 +0000 @@ -74,7 +74,7 @@ * parameter so as to return the block size that was actually * obtained. */ - virtual void getSummaries(int channel, int start, int count, + virtual void getSummaries(int channel, sv_frame_t start, sv_frame_t count, RangeBlock &ranges, int &blockSize) const = 0; @@ -83,7 +83,7 @@ * the given number of underlying sample frames, summarised at a * block size equal to the distance between start and end frames. */ - virtual Range getSummary(int channel, int start, int count) const = 0; + virtual Range getSummary(int channel, sv_frame_t start, sv_frame_t count) const = 0; virtual int getSummaryBlockSize(int desired) const = 0;
--- a/data/model/RegionModel.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/RegionModel.h Tue Mar 03 15:18:24 2015 +0000 @@ -37,15 +37,15 @@ { public: RegionRec() : frame(0), value(0.f), duration(0) { } - RegionRec(long _frame) : frame(_frame), value(0.0f), duration(0) { } - RegionRec(long _frame, float _value, int _duration, QString _label) : + RegionRec(sv_frame_t _frame) : frame(_frame), value(0.0f), duration(0) { } + RegionRec(sv_frame_t _frame, float _value, sv_frame_t _duration, QString _label) : frame(_frame), value(_value), duration(_duration), label(_label) { } int getDimensions() const { return 3; } - long frame; + sv_frame_t frame; float value; - int duration; + sv_frame_t duration; QString label; QString getLabel() const { return label; }
--- a/data/model/SparseModel.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/SparseModel.h Tue Mar 03 15:18:24 2015 +0000 @@ -48,8 +48,8 @@ virtual ~SparseModel() { } virtual bool isOK() const { return true; } - virtual int getStartFrame() const; - virtual int getEndFrame() const; + virtual sv_frame_t getStartFrame() const; + virtual sv_frame_t getEndFrame() const; virtual int getSampleRate() const { return m_sampleRate; } virtual Model *clone() const; @@ -91,25 +91,25 @@ * after the boundaries. If you need exact boundaries, check the * point coordinates in the returned list. */ - virtual PointList getPoints(long start, long end) const; + virtual PointList getPoints(sv_frame_t start, sv_frame_t end) const; /** * Get all points that cover the given frame number, taking the * resolution of the model into account. */ - virtual PointList getPoints(long frame) const; + virtual PointList getPoints(sv_frame_t frame) const; /** * Return all points that share the nearest frame number prior to * the given one at which there are any points. */ - virtual PointList getPreviousPoints(long frame) const; + virtual PointList getPreviousPoints(sv_frame_t frame) const; /** * Return all points that share the nearest frame number * subsequent to the given one at which there are any points. */ - virtual PointList getNextPoints(long frame) const; + virtual PointList getNextPoints(sv_frame_t frame) const; /** * Remove all points. @@ -157,11 +157,11 @@ return s; } - virtual QString toDelimitedDataStringSubset(QString delimiter, int f0, int f1) const + virtual QString toDelimitedDataStringSubset(QString delimiter, sv_frame_t f0, sv_frame_t f1) const { QString s; for (PointListConstIterator i = m_points.begin(); i != m_points.end(); ++i) { - if (i->frame >= (long)f0 && i->frame < (long)f1) { + if (i->frame >= f0 && i->frame < f1) { s += i->toDelimitedDataString(delimiter, m_sampleRate) + "\n"; } } @@ -284,31 +284,26 @@ virtual int getRowCount() const { - return m_points.size(); + return int(m_points.size()); } - virtual long getFrameForRow(int row) const + virtual sv_frame_t getFrameForRow(int row) const { PointListConstIterator i = getPointListIteratorForRow(row); if (i == m_points.end()) return 0; return i->frame; } - virtual int getRowForFrame(long frame) const + virtual int getRowForFrame(sv_frame_t frame) const { if (m_rows.empty()) rebuildRowVector(); - std::vector<long>::iterator i = + std::vector<sv_frame_t>::iterator i = std::lower_bound(m_rows.begin(), m_rows.end(), frame); -#if defined(__SUNPRO_CC) && defined(__STD_RW_ITERATOR__) - int row = 0; - std::distance(m_rows.begin(), i, row); -#else - int row = std::distance(m_rows.begin(), i); -#endif + ssize_t row = std::distance(m_rows.begin(), i); if (i != m_rows.begin() && (i == m_rows.end() || *i != frame)) { --row; } - return row; + return int(row); } virtual int getColumnCount() const { return 1; } @@ -374,8 +369,8 @@ int m_sampleRate; int m_resolution; bool m_notifyOnAdd; - long m_sinceLastNotifyMin; - long m_sinceLastNotifyMax; + sv_frame_t m_sinceLastNotifyMin; + sv_frame_t m_sinceLastNotifyMax; bool m_hasTextLabels; PointList m_points; @@ -383,16 +378,16 @@ mutable QMutex m_mutex; int m_completion; - void getPointIterators(long frame, + void getPointIterators(sv_frame_t frame, PointListIterator &startItr, PointListIterator &endItr); - void getPointIterators(long frame, + void getPointIterators(sv_frame_t frame, PointListConstIterator &startItr, PointListConstIterator &endItr) const; // This is only used if the model is called on to act in // TabularModel mode - mutable std::vector<long> m_rows; // map from row number to frame + mutable std::vector<sv_frame_t> m_rows; // map from row number to frame void rebuildRowVector() const { m_rows.clear(); @@ -407,7 +402,7 @@ if (m_rows.empty()) rebuildRowVector(); if (row < 0 || row + 1 > int(m_rows.size())) return m_points.end(); - int frame = m_rows[row]; + sv_frame_t frame = m_rows[row]; int indexAtFrame = 0; int ri = row; while (ri > 0 && m_rows[ri-1] == m_rows[row]) { --ri; ++indexAtFrame; } @@ -434,7 +429,7 @@ if (m_rows.empty()) rebuildRowVector(); if (row < 0 || row + 1 > int(m_rows.size())) return m_points.end(); - int frame = m_rows[row]; + sv_frame_t frame = m_rows[row]; int indexAtFrame = 0; int ri = row; while (ri > 0 && m_rows[ri-1] == m_rows[row]) { --ri; ++indexAtFrame; } @@ -480,11 +475,11 @@ } template <typename PointType> -int +sv_frame_t SparseModel<PointType>::getStartFrame() const { QMutexLocker locker(&m_mutex); - int f = 0; + sv_frame_t f = 0; if (!m_points.empty()) { f = m_points.begin()->frame; } @@ -492,11 +487,11 @@ } template <typename PointType> -int +sv_frame_t SparseModel<PointType>::getEndFrame() const { QMutexLocker locker(&m_mutex); - int f = 0; + sv_frame_t f = 0; if (!m_points.empty()) { PointListConstIterator i(m_points.end()); f = (--i)->frame; @@ -541,7 +536,7 @@ template <typename PointType> typename SparseModel<PointType>::PointList -SparseModel<PointType>::getPoints(long start, long end) const +SparseModel<PointType>::getPoints(sv_frame_t start, sv_frame_t end) const { if (start > end) return PointList(); QMutexLocker locker(&m_mutex); @@ -567,7 +562,7 @@ template <typename PointType> typename SparseModel<PointType>::PointList -SparseModel<PointType>::getPoints(long frame) const +SparseModel<PointType>::getPoints(sv_frame_t frame) const { PointListConstIterator startItr, endItr; getPointIterators(frame, startItr, endItr); @@ -583,7 +578,7 @@ template <typename PointType> void -SparseModel<PointType>::getPointIterators(long frame, +SparseModel<PointType>::getPointIterators(sv_frame_t frame, PointListIterator &startItr, PointListIterator &endItr) { @@ -595,8 +590,8 @@ return; } - long start = (frame / m_resolution) * m_resolution; - long end = start + m_resolution; + sv_frame_t start = (frame / m_resolution) * m_resolution; + sv_frame_t end = start + m_resolution; PointType startPoint(start), endPoint(end); @@ -606,7 +601,7 @@ template <typename PointType> void -SparseModel<PointType>::getPointIterators(long frame, +SparseModel<PointType>::getPointIterators(sv_frame_t frame, PointListConstIterator &startItr, PointListConstIterator &endItr) const { @@ -619,8 +614,8 @@ return; } - long start = (frame / m_resolution) * m_resolution; - long end = start + m_resolution; + sv_frame_t start = (frame / m_resolution) * m_resolution; + sv_frame_t end = start + m_resolution; PointType startPoint(start), endPoint(end); @@ -632,7 +627,7 @@ template <typename PointType> typename SparseModel<PointType>::PointList -SparseModel<PointType>::getPreviousPoints(long originFrame) const +SparseModel<PointType>::getPreviousPoints(sv_frame_t originFrame) const { QMutexLocker locker(&m_mutex); @@ -643,7 +638,7 @@ if (i == m_points.begin()) return rv; --i; - long frame = i->frame; + sv_frame_t frame = i->frame; while (i->frame == frame) { rv.insert(*i); if (i == m_points.begin()) break; @@ -655,7 +650,7 @@ template <typename PointType> typename SparseModel<PointType>::PointList -SparseModel<PointType>::getNextPoints(long originFrame) const +SparseModel<PointType>::getNextPoints(sv_frame_t originFrame) const { QMutexLocker locker(&m_mutex); @@ -665,7 +660,7 @@ PointListConstIterator i = m_points.upper_bound(lookupPoint); if (i == m_points.end()) return rv; - long frame = i->frame; + sv_frame_t frame = i->frame; while (i != m_points.end() && i->frame == frame) { rv.insert(*i); ++i;
--- a/data/model/SparseOneDimensionalModel.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/SparseOneDimensionalModel.h Tue Mar 03 15:18:24 2015 +0000 @@ -26,12 +26,12 @@ struct OneDimensionalPoint { public: - OneDimensionalPoint(int _frame) : frame(_frame) { } - OneDimensionalPoint(int _frame, QString _label) : frame(_frame), label(_label) { } + OneDimensionalPoint(sv_frame_t _frame) : frame(_frame) { } + OneDimensionalPoint(sv_frame_t _frame, QString _label) : frame(_frame), label(_label) { } int getDimensions() const { return 1; } - int frame; + sv_frame_t frame; QString label; QString getLabel() const { return label; } @@ -187,7 +187,7 @@ return getNotesWithin(getStartFrame(), getEndFrame()); } - NoteList getNotesWithin(int startFrame, int endFrame) const { + NoteList getNotesWithin(sv_frame_t startFrame, sv_frame_t endFrame) const { PointList points = getPoints(startFrame, endFrame); NoteList notes;
--- a/data/model/SparseTimeValueModel.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/SparseTimeValueModel.h Tue Mar 03 15:18:24 2015 +0000 @@ -168,7 +168,7 @@ command->deletePoint(point); switch (column) { - case 2: point.value = value.toDouble(); break; + case 2: point.value = float(value.toDouble()); break; case 3: point.label = value.toString(); break; }
--- a/data/model/TextModel.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/TextModel.h Tue Mar 03 15:18:24 2015 +0000 @@ -31,13 +31,13 @@ struct TextPoint : public XmlExportable { public: - TextPoint(long _frame) : frame(_frame), height(0.0f) { } - TextPoint(long _frame, float _height, QString _label) : + TextPoint(sv_frame_t _frame) : frame(_frame), height(0.0f) { } + TextPoint(sv_frame_t _frame, float _height, QString _label) : frame(_frame), height(_height), label(_label) { } int getDimensions() const { return 2; } - long frame; + sv_frame_t frame; float height; QString label; @@ -155,7 +155,7 @@ command->deletePoint(point); switch (column) { - case 2: point.height = value.toDouble(); break; + case 2: point.height = float(value.toDouble()); break; case 3: point.label = value.toString(); break; }
--- a/data/model/WaveFileModel.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/WaveFileModel.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -131,7 +131,7 @@ return model; } -int +sv_frame_t WaveFileModel::getFrameCount() const { if (!m_reader) return 0; @@ -191,8 +191,8 @@ return ""; } -int -WaveFileModel::getData(int channel, int start, int count, +sv_frame_t +WaveFileModel::getData(int channel, sv_frame_t start, sv_frame_t count, float *buffer) const { // Always read these directly from the file. @@ -206,7 +206,7 @@ if (start >= m_startFrame) { start -= m_startFrame; } else { - for (int i = 0; i < count; ++i) { + for (sv_frame_t i = 0; i < count; ++i) { buffer[i] = 0.f; } if (count <= m_startFrame - start) { @@ -218,7 +218,7 @@ } if (!m_reader || !m_reader->isOK() || count == 0) { - for (int i = 0; i < count; ++i) buffer[i] = 0.f; + for (sv_frame_t i = 0; i < count; ++i) buffer[i] = 0.f; return 0; } @@ -232,7 +232,7 @@ SampleBlock frames(count * channels); m_reader->getInterleavedFrames(start, count, frames); - int i = 0; + sv_frame_t i = 0; int ch0 = channel, ch1 = channel; if (channel == -1) { @@ -246,8 +246,8 @@ for (int ch = ch0; ch <= ch1; ++ch) { - int index = i * channels + ch; - if (index >= (int)frames.size()) break; + sv_frame_t index = i * channels + ch; + if (index >= (sv_frame_t)frames.size()) break; float sample = frames[index]; buffer[i] += sample; @@ -259,8 +259,8 @@ return i; } -int -WaveFileModel::getData(int channel, int start, int count, +sv_frame_t +WaveFileModel::getData(int channel, sv_frame_t start, sv_frame_t count, double *buffer) const { #ifdef DEBUG_WAVE_FILE_MODEL @@ -270,7 +270,7 @@ if (start > m_startFrame) { start -= m_startFrame; } else { - for (int i = 0; i < count; ++i) buffer[i] = 0.0; + for (sv_frame_t i = 0; i < count; ++i) buffer[i] = 0.0; if (count <= m_startFrame - start) { return 0; } else { @@ -280,7 +280,7 @@ } if (!m_reader || !m_reader->isOK() || count == 0) { - for (int i = 0; i < count; ++i) buffer[i] = 0.0; + for (sv_frame_t i = 0; i < count; ++i) buffer[i] = 0.0; return 0; } @@ -289,7 +289,7 @@ SampleBlock frames(count * channels); m_reader->getInterleavedFrames(start, count, frames); - int i = 0; + sv_frame_t i = 0; int ch0 = channel, ch1 = channel; if (channel == -1) { @@ -303,8 +303,8 @@ for (int ch = ch0; ch <= ch1; ++ch) { - int index = i * channels + ch; - if (index >= (int)frames.size()) break; + sv_frame_t index = i * channels + ch; + if (index >= (sv_frame_t)frames.size()) break; float sample = frames[index]; buffer[i] += sample; @@ -316,9 +316,9 @@ return i; } -int +sv_frame_t WaveFileModel::getData(int fromchannel, int tochannel, - int start, int count, + sv_frame_t start, sv_frame_t count, float **buffer) const { #ifdef DEBUG_WAVE_FILE_MODEL @@ -355,7 +355,7 @@ start -= m_startFrame; } else { for (int c = 0; c < reqchannels; ++c) { - for (int i = 0; i < count; ++i) buffer[c][i] = 0.f; + for (sv_frame_t i = 0; i < count; ++i) buffer[c][i] = 0.f; } if (count <= m_startFrame - start) { return 0; @@ -367,7 +367,7 @@ if (!m_reader || !m_reader->isOK() || count == 0) { for (int c = 0; c < reqchannels; ++c) { - for (int i = 0; i < count; ++i) buffer[c][i] = 0.f; + for (sv_frame_t i = 0; i < count; ++i) buffer[c][i] = 0.f; } return 0; } @@ -375,9 +375,9 @@ SampleBlock frames(count * channels); m_reader->getInterleavedFrames(start, count, frames); - int i = 0; + sv_frame_t i = 0; - int index = 0, available = frames.size(); + sv_frame_t index = 0, available = frames.size(); while (i < count) { @@ -418,7 +418,7 @@ } void -WaveFileModel::getSummaries(int channel, int start, int count, +WaveFileModel::getSummaries(int channel, sv_frame_t start, sv_frame_t count, RangeBlock &ranges, int &blockSize) const { ranges.clear(); @@ -461,12 +461,12 @@ } float max = 0.0, min = 0.0, total = 0.0; - int i = 0, got = 0; + sv_frame_t i = 0, got = 0; while (i < count) { - int index = i * channels + channel; - if (index >= (int)m_directRead.size()) break; + sv_frame_t index = i * channels + channel; + if (index >= (sv_frame_t)m_directRead.size()) break; float sample = m_directRead[index]; if (sample > max || got == 0) max = sample; @@ -477,7 +477,7 @@ ++got; if (got == blockSize) { - ranges.push_back(Range(min, max, total / got)); + ranges.push_back(Range(min, max, total / float(got))); min = max = total = 0.0f; got = 0; } @@ -486,7 +486,7 @@ m_directReadMutex.unlock(); if (got > 0) { - ranges.push_back(Range(min, max, total / got)); + ranges.push_back(Range(min, max, total / float(got))); } return; @@ -499,21 +499,21 @@ blockSize = roundedBlockSize; - int cacheBlock, div; + sv_frame_t cacheBlock, div; if (cacheType == 0) { cacheBlock = (1 << m_zoomConstraint.getMinCachePower()); div = (1 << power) / cacheBlock; } else { - cacheBlock = ((unsigned int)((1 << m_zoomConstraint.getMinCachePower()) * sqrt(2.) + 0.01)); - div = ((unsigned int)((1 << power) * sqrt(2.) + 0.01)) / cacheBlock; + cacheBlock = sv_frame_t((1 << m_zoomConstraint.getMinCachePower()) * sqrt(2.) + 0.01); + div = sv_frame_t(((1 << power) * sqrt(2.) + 0.01) / double(cacheBlock)); } - int startIndex = start / cacheBlock; - int endIndex = (start + count) / cacheBlock; + sv_frame_t startIndex = start / cacheBlock; + sv_frame_t endIndex = (start + count) / cacheBlock; float max = 0.0, min = 0.0, total = 0.0; - int i = 0, got = 0; + sv_frame_t 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; @@ -521,8 +521,8 @@ for (i = 0; i <= endIndex - startIndex; ) { - int index = (i + startIndex) * channels + channel; - if (index >= (int)cache.size()) break; + sv_frame_t index = (i + startIndex) * channels + channel; + if (index >= (sv_frame_t)cache.size()) break; const Range &range = cache[index]; if (range.max() > max || got == 0) max = range.max(); @@ -533,14 +533,14 @@ ++got; if (got == div) { - ranges.push_back(Range(min, max, total / got)); + ranges.push_back(Range(min, max, total / float(got))); min = max = total = 0.0f; got = 0; } } if (got > 0) { - ranges.push_back(Range(min, max, total / got)); + ranges.push_back(Range(min, max, total / float(got))); } } @@ -551,7 +551,7 @@ } WaveFileModel::Range -WaveFileModel::getSummary(int channel, int start, int count) const +WaveFileModel::getSummary(int channel, sv_frame_t start, sv_frame_t count) const { Range range; if (!isOK()) return range; @@ -569,8 +569,8 @@ bool first = false; - int blockStart = (start / blockSize) * blockSize; - int blockEnd = ((start + count) / blockSize) * blockSize; + sv_frame_t blockStart = (start / blockSize) * blockSize; + sv_frame_t blockEnd = ((start + count) / blockSize) * blockSize; if (blockStart < start) blockStart += blockSize; @@ -626,7 +626,7 @@ WaveFileModel::fillTimerTimedOut() { if (m_fillThread) { - int fillExtent = m_fillThread->getFillExtent(); + sv_frame_t fillExtent = m_fillThread->getFillExtent(); #ifdef DEBUG_WAVE_FILE_MODEL SVDEBUG << "WaveFileModel::fillTimerTimedOut: extent = " << fillExtent << endl; #endif @@ -666,11 +666,11 @@ { int cacheBlockSize[2]; cacheBlockSize[0] = (1 << m_model.m_zoomConstraint.getMinCachePower()); - cacheBlockSize[1] = ((unsigned int)((1 << m_model.m_zoomConstraint.getMinCachePower()) * + cacheBlockSize[1] = (int((1 << m_model.m_zoomConstraint.getMinCachePower()) * sqrt(2.) + 0.01)); - int frame = 0; - int readBlockSize = 16384; + sv_frame_t frame = 0; + sv_frame_t readBlockSize = 16384; SampleBlock block; if (!m_model.isOK()) return; @@ -713,18 +713,18 @@ // cerr << "block is " << block.size() << endl; - for (int i = 0; i < readBlockSize; ++i) { + for (sv_frame_t i = 0; i < readBlockSize; ++i) { if (channels * i + channels > (int)block.size()) break; for (int ch = 0; ch < channels; ++ch) { - int index = channels * i + ch; + sv_frame_t index = channels * i + ch; float sample = block[index]; for (int ct = 0; ct < 2; ++ct) { // cache type - int rangeIndex = ch * 2 + ct; + sv_frame_t rangeIndex = ch * 2 + ct; if (sample > range[rangeIndex].max() || count[ct] == 0) { range[rangeIndex].setMax(sample); @@ -745,7 +745,7 @@ for (int ch = 0; ch < int(channels); ++ch) { int rangeIndex = ch * 2 + ct; - means[rangeIndex] /= count[ct]; + means[rangeIndex] = means[rangeIndex] / float(count[ct]); range[rangeIndex].setAbsmean(means[rangeIndex]); m_model.m_cache[ct].push_back(range[rangeIndex]); range[rangeIndex] = Range(); @@ -784,7 +784,7 @@ for (int ch = 0; ch < int(channels); ++ch) { int rangeIndex = ch * 2 + ct; - means[rangeIndex] /= count[ct]; + means[rangeIndex] = means[rangeIndex] / float(count[ct]); range[rangeIndex].setAbsmean(means[rangeIndex]); m_model.m_cache[ct].push_back(range[rangeIndex]); range[rangeIndex] = Range();
--- a/data/model/WaveFileModel.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/WaveFileModel.h Tue Mar 03 15:18:24 2015 +0000 @@ -43,7 +43,7 @@ const ZoomConstraint *getZoomConstraint() const { return &m_zoomConstraint; } - int getFrameCount() const; + sv_frame_t getFrameCount() const; int getChannelCount() const; int getSampleRate() const; int getNativeRate() const; @@ -59,28 +59,28 @@ float getValueMinimum() const { return -1.0f; } float getValueMaximum() const { return 1.0f; } - virtual int getStartFrame() const { return m_startFrame; } - virtual int getEndFrame() const { return m_startFrame + getFrameCount(); } + virtual sv_frame_t getStartFrame() const { return m_startFrame; } + virtual sv_frame_t getEndFrame() const { return m_startFrame + getFrameCount(); } - void setStartFrame(int startFrame) { m_startFrame = startFrame; } + void setStartFrame(sv_frame_t startFrame) { m_startFrame = startFrame; } - virtual int getData(int channel, int start, int count, + virtual sv_frame_t getData(int channel, sv_frame_t start, sv_frame_t count, float *buffer) const; - virtual int getData(int channel, int start, int count, + virtual sv_frame_t getData(int channel, sv_frame_t start, sv_frame_t count, double *buffer) const; - virtual int getData(int fromchannel, int tochannel, - int start, int count, + virtual sv_frame_t getData(int fromchannel, int tochannel, + sv_frame_t start, sv_frame_t count, float **buffers) const; virtual int getSummaryBlockSize(int desired) const; - virtual void getSummaries(int channel, int start, int count, + virtual void getSummaries(int channel, sv_frame_t start, sv_frame_t count, RangeBlock &ranges, int &blockSize) const; - virtual Range getSummary(int channel, int start, int count) const; + virtual Range getSummary(int channel, sv_frame_t start, sv_frame_t count) const; QString getTypeName() const { return tr("Wave File"); } @@ -102,13 +102,13 @@ m_model(model), m_fillExtent(0), m_frameCount(model.getFrameCount()) { } - int getFillExtent() const { return m_fillExtent; } + sv_frame_t getFillExtent() const { return m_fillExtent; } virtual void run(); protected: WaveFileModel &m_model; - int m_fillExtent; - int m_frameCount; + sv_frame_t m_fillExtent; + sv_frame_t m_frameCount; }; void fillCache(); @@ -118,19 +118,19 @@ AudioFileReader *m_reader; bool m_myReader; - int m_startFrame; + sv_frame_t m_startFrame; RangeBlock m_cache[2]; // interleaved at two base resolutions mutable QMutex m_mutex; RangeCacheFillThread *m_fillThread; QTimer *m_updateTimer; - int m_lastFillExtent; + sv_frame_t m_lastFillExtent; bool m_exiting; static PowerOfSqrtTwoZoomConstraint m_zoomConstraint; mutable SampleBlock m_directRead; - mutable int m_lastDirectReadStart; - mutable int m_lastDirectReadCount; + mutable sv_frame_t m_lastDirectReadStart; + mutable sv_frame_t m_lastDirectReadCount; mutable QMutex m_directReadMutex; };
--- a/data/model/WritableWaveFileModel.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/WritableWaveFileModel.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -86,8 +86,8 @@ m_model->setStartFrame(m_startFrame); connect(m_model, SIGNAL(modelChanged()), this, SIGNAL(modelChanged())); - connect(m_model, SIGNAL(modelChangedWithin(int, int)), - this, SIGNAL(modelChangedWithin(int, int))); + connect(m_model, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), + this, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t))); } WritableWaveFileModel::~WritableWaveFileModel() @@ -98,14 +98,14 @@ } void -WritableWaveFileModel::setStartFrame(int startFrame) +WritableWaveFileModel::setStartFrame(sv_frame_t startFrame) { m_startFrame = startFrame; if (m_model) m_model->setStartFrame(startFrame); } bool -WritableWaveFileModel::addSamples(float **samples, int count) +WritableWaveFileModel::addSamples(float **samples, sv_frame_t count) { if (!m_writer) return false; @@ -162,7 +162,7 @@ } } -int +sv_frame_t WritableWaveFileModel::getFrameCount() const { // SVDEBUG << "WritableWaveFileModel::getFrameCount: count = " << m_frameCount << endl; @@ -176,25 +176,25 @@ return 0; } -int -WritableWaveFileModel::getData(int channel, int start, int count, +sv_frame_t +WritableWaveFileModel::getData(int channel, sv_frame_t start, sv_frame_t count, float *buffer) const { if (!m_model || m_model->getChannelCount() == 0) return 0; return m_model->getData(channel, start, count, buffer); } -int -WritableWaveFileModel::getData(int channel, int start, int count, +sv_frame_t +WritableWaveFileModel::getData(int channel, sv_frame_t start, sv_frame_t count, double *buffer) const { if (!m_model || m_model->getChannelCount() == 0) return 0; return m_model->getData(channel, start, count, buffer); } -int +sv_frame_t WritableWaveFileModel::getData(int fromchannel, int tochannel, - int start, int count, + sv_frame_t start, sv_frame_t count, float **buffers) const { if (!m_model || m_model->getChannelCount() == 0) return 0; @@ -209,7 +209,7 @@ } void -WritableWaveFileModel::getSummaries(int channel, int start, int count, +WritableWaveFileModel::getSummaries(int channel, sv_frame_t start, sv_frame_t count, RangeBlock &ranges, int &blockSize) const { @@ -219,7 +219,7 @@ } WritableWaveFileModel::Range -WritableWaveFileModel::getSummary(int channel, int start, int count) const +WritableWaveFileModel::getSummary(int channel, sv_frame_t start, sv_frame_t count) const { if (!m_model || m_model->getChannelCount() == 0) return Range(); return m_model->getSummary(channel, start, count);
--- a/data/model/WritableWaveFileModel.h Tue Mar 03 09:33:59 2015 +0000 +++ b/data/model/WritableWaveFileModel.h Tue Mar 03 15:18:24 2015 +0000 @@ -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, int count); + virtual bool addSamples(float **samples, sv_frame_t count); bool isOK() const; bool isReady(int *) const; @@ -48,7 +48,7 @@ return &zc; } - int getFrameCount() const; + sv_frame_t getFrameCount() const; int getChannelCount() const { return m_channels; } int getSampleRate() const { return m_sampleRate; } @@ -57,27 +57,27 @@ float getValueMinimum() const { return -1.0f; } float getValueMaximum() const { return 1.0f; } - virtual int getStartFrame() const { return m_startFrame; } - virtual int getEndFrame() const { return m_startFrame + getFrameCount(); } + virtual sv_frame_t getStartFrame() const { return m_startFrame; } + virtual sv_frame_t getEndFrame() const { return m_startFrame + getFrameCount(); } - void setStartFrame(int startFrame); + void setStartFrame(sv_frame_t startFrame); - virtual int getData(int channel, int start, int count, + virtual sv_frame_t getData(int channel, sv_frame_t start, sv_frame_t count, float *buffer) const; - virtual int getData(int channel, int start, int count, + virtual sv_frame_t getData(int channel, sv_frame_t start, sv_frame_t count, double *buffer) const; - virtual int getData(int fromchannel, int tochannel, - int start, int count, + virtual sv_frame_t getData(int fromchannel, int tochannel, + sv_frame_t start, sv_frame_t count, float **buffer) const; virtual int getSummaryBlockSize(int desired) const; - virtual void getSummaries(int channel, int start, int count, + virtual void getSummaries(int channel, sv_frame_t start, sv_frame_t count, RangeBlock &ranges, int &blockSize) const; - virtual Range getSummary(int channel, int start, int count) const; + virtual Range getSummary(int channel, sv_frame_t start, sv_frame_t count) const; QString getTypeName() const { return tr("Writable Wave File"); } @@ -91,8 +91,8 @@ WavFileReader *m_reader; int m_sampleRate; int m_channels; - int m_frameCount; - int m_startFrame; + sv_frame_t m_frameCount; + sv_frame_t m_startFrame; int m_completion; };
--- a/data/osc/OSCMessage.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/data/osc/OSCMessage.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -41,7 +41,7 @@ int OSCMessage::getArgCount() const { - return m_args.size(); + return int(m_args.size()); } const QVariant &
--- a/plugin/DSSIPluginFactory.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/plugin/DSSIPluginFactory.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -82,7 +82,7 @@ list.push_back(m_taxonomy[*i]); list.push_back(QString("%1").arg(descriptor->PortCount)); - for (unsigned long p = 0; p < descriptor->PortCount; ++p) { + for (int p = 0; p < (int)descriptor->PortCount; ++p) { int type = 0; if (LADSPA_IS_PORT_CONTROL(descriptor->PortDescriptors[p])) { @@ -375,13 +375,13 @@ unsigned int controlPortNumber = 1; - for (unsigned long i = 0; i < ladspaDescriptor->PortCount; i++) { + for (int i = 0; i < (int)ladspaDescriptor->PortCount; i++) { if (LADSPA_IS_PORT_CONTROL(ladspaDescriptor->PortDescriptors[i])) { if (def_uri && defs) { - for (unsigned int j = 0; j < defs->count; j++) { + for (int j = 0; j < (int)defs->count; j++) { if (defs->items[j].pid == controlPortNumber) { // cerr << "Default for this port (" << defs->items[j].pid << ", " << defs->items[j].label << ") is " << defs->items[j].value << "; applying this to port number " << i << " with name " << ladspaDescriptor->PortNames[i] << endl; m_portDefaults[ladspaDescriptor->UniqueID][i] =
--- a/plugin/DSSIPluginInstance.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/plugin/DSSIPluginInstance.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -57,7 +57,7 @@ int clientId, QString identifier, int position, - unsigned long sampleRate, + int sampleRate, size_t blockSize, int idealChannelCount, const DSSI_Descriptor* descriptor) : @@ -149,10 +149,10 @@ LADSPAPluginFactory *f = dynamic_cast<LADSPAPluginFactory *>(m_factory); if (!f) return list; - for (unsigned int i = 0; i < m_controlPortsIn.size(); ++i) { + for (int i = 0; in_range_for(m_controlPortsIn, i); ++i) { ParameterDescriptor pd; - unsigned int pn = m_controlPortsIn[i].first; + int pn = (int)m_controlPortsIn[i].first; pd.identifier = m_descriptor->LADSPA_Plugin->PortNames[pn]; pd.name = pd.identifier; @@ -181,7 +181,7 @@ #ifdef DEBUG_DSSI SVDEBUG << "DSSIPluginInstance::getParameter(" << id << ")" << endl; #endif - for (unsigned int i = 0; i < m_controlPortsIn.size(); ++i) { + for (int i = 0; in_range_for(m_controlPortsIn, i); ++i) { if (id == m_descriptor->LADSPA_Plugin->PortNames[m_controlPortsIn[i].first]) { #ifdef DEBUG_DSSI cerr << "Matches port " << i << endl; @@ -204,7 +204,7 @@ SVDEBUG << "DSSIPluginInstance::setParameter(" << id << ", " << value << ")" << endl; #endif - for (unsigned int i = 0; i < m_controlPortsIn.size(); ++i) { + for (int i = 0; in_range_for(m_controlPortsIn, i); ++i) { if (id == m_descriptor->LADSPA_Plugin->PortNames[m_controlPortsIn[i].first]) { setParameterValue(i, value); break; @@ -223,7 +223,7 @@ // const LADSPA_Descriptor *descriptor = m_descriptor->LADSPA_Plugin; - for (unsigned long i = 0; i < descriptor->PortCount; ++i) + for (int i = 0; i < (int)descriptor->PortCount; ++i) { if (LADSPA_IS_PORT_AUDIO(descriptor->PortDescriptors[i])) { @@ -240,7 +240,7 @@ LADSPA_Data *data = new LADSPA_Data(0.0); - m_controlPortsIn.push_back(std::pair<unsigned long, LADSPA_Data*> + m_controlPortsIn.push_back(std::pair<long, LADSPA_Data*> (i, data)); m_backupControlPortsIn.push_back(0.0); @@ -248,7 +248,7 @@ } else { LADSPA_Data *data = new LADSPA_Data(0.0); m_controlPortsOut.push_back( - std::pair<unsigned long, LADSPA_Data*>(i, data)); + std::pair<long, LADSPA_Data*>(i, data)); if (!strcmp(descriptor->PortNames[i], "latency") || !strcmp(descriptor->PortNames[i], "_latency")) { #ifdef DEBUG_DSSI @@ -428,10 +428,10 @@ cleanup(); - for (unsigned int i = 0; i < m_controlPortsIn.size(); ++i) + for (int i = 0; in_range_for(m_controlPortsIn, i); ++i) delete m_controlPortsIn[i].second; - for (unsigned int i = 0; i < m_controlPortsOut.size(); ++i) + for (int i = 0; in_range_for(m_controlPortsOut, i); ++i) delete m_controlPortsOut[i].second; m_controlPortsIn.clear(); @@ -455,7 +455,7 @@ void -DSSIPluginInstance::instantiate(unsigned long sampleRate) +DSSIPluginInstance::instantiate(int sampleRate) { if (!m_descriptor) return; @@ -478,7 +478,7 @@ if (m_descriptor->get_midi_controller_for_port) { - for (unsigned long i = 0; i < descriptor->PortCount; ++i) { + for (int i = 0; i < (int)descriptor->PortCount; ++i) { if (LADSPA_IS_PORT_CONTROL(descriptor->PortDescriptors[i]) && LADSPA_IS_PORT_INPUT(descriptor->PortDescriptors[i])) { @@ -512,13 +512,13 @@ return; } - unsigned long index = 0; + int index = 0; const DSSI_Program_Descriptor *programDescriptor; while ((programDescriptor = m_descriptor->get_program(m_instanceHandle, index))) { ++index; ProgramDescriptor d; - d.bank = programDescriptor->Bank; - d.program = programDescriptor->Program; + d.bank = (int)programDescriptor->Bank; + d.program = (int)programDescriptor->Program; d.name = programDescriptor->Name; m_cachedPrograms.push_back(d); } @@ -570,7 +570,7 @@ return std::string(); } -unsigned long +int DSSIPluginInstance::getProgram(std::string name) const { #ifdef DEBUG_DSSI @@ -581,7 +581,7 @@ checkProgramCache(); - unsigned long rv; + int rv; for (std::vector<ProgramDescriptor>::iterator i = m_cachedPrograms.begin(); i != m_cachedPrograms.end(); ++i) { @@ -621,7 +621,7 @@ if (!m_descriptor->select_program) return; bool found = false; - unsigned long bankNo = 0, programNo = 0; + int bankNo = 0, programNo = 0; for (std::vector<ProgramDescriptor>::iterator i = m_cachedPrograms.begin(); i != m_cachedPrograms.end(); ++i) { @@ -700,7 +700,7 @@ LADSPAPluginFactory *f = dynamic_cast<LADSPAPluginFactory *>(m_factory); int inbuf = 0, outbuf = 0; - for (unsigned int i = 0; i < m_audioPortsIn.size(); ++i) { + for (size_t i = 0; i < m_audioPortsIn.size(); ++i) { m_descriptor->LADSPA_Plugin->connect_port (m_instanceHandle, m_audioPortsIn[i], @@ -708,7 +708,7 @@ ++inbuf; } - for (unsigned int i = 0; i < m_audioPortsOut.size(); ++i) { + for (size_t i = 0; i < m_audioPortsOut.size(); ++i) { m_descriptor->LADSPA_Plugin->connect_port (m_instanceHandle, m_audioPortsOut[i], @@ -716,7 +716,7 @@ ++outbuf; } - for (unsigned int i = 0; i < m_controlPortsIn.size(); ++i) { + for (size_t i = 0; i < m_controlPortsIn.size(); ++i) { m_descriptor->LADSPA_Plugin->connect_port (m_instanceHandle, m_controlPortsIn[i].first, @@ -724,7 +724,7 @@ if (f) { float defaultValue = f->getPortDefault - (m_descriptor->LADSPA_Plugin, m_controlPortsIn[i].first); + (m_descriptor->LADSPA_Plugin, (int)m_controlPortsIn[i].first); *m_controlPortsIn[i].second = defaultValue; m_backupControlPortsIn[i] = defaultValue; #ifdef DEBUG_DSSI @@ -733,7 +733,7 @@ } } - for (unsigned int i = 0; i < m_controlPortsOut.size(); ++i) { + for (size_t i = 0; i < m_controlPortsOut.size(); ++i) { m_descriptor->LADSPA_Plugin->connect_port (m_instanceHandle, m_controlPortsOut[i].first, @@ -741,21 +741,21 @@ } } -unsigned int +int DSSIPluginInstance::getParameterCount() const { - return m_controlPortsIn.size(); + return (int)m_controlPortsIn.size(); } void -DSSIPluginInstance::setParameterValue(unsigned int parameter, float value) +DSSIPluginInstance::setParameterValue(int parameter, float value) { #ifdef DEBUG_DSSI SVDEBUG << "DSSIPluginInstance::setParameterValue(" << parameter << ") to " << value << endl; #endif - if (parameter >= m_controlPortsIn.size()) return; + if (!in_range_for(m_controlPortsIn, parameter)) return; - unsigned int portNumber = m_controlPortsIn[parameter].first; + int portNumber = m_controlPortsIn[parameter].first; LADSPAPluginFactory *f = dynamic_cast<LADSPAPluginFactory *>(m_factory); if (f) { @@ -772,7 +772,7 @@ } void -DSSIPluginInstance::setPortValueFromController(unsigned int port, int cv) +DSSIPluginInstance::setPortValueFromController(int port, int cv) { #ifdef DEBUG_DSSI SVDEBUG << "DSSIPluginInstance::setPortValueFromController(" << port << ") to " << cv << endl; @@ -803,7 +803,7 @@ } } - for (unsigned int i = 0; i < m_controlPortsIn.size(); ++i) { + for (int i = 0; in_range_for(m_controlPortsIn, i); ++i) { if (m_controlPortsIn[i].first == port) { setParameterValue(i, value); } @@ -813,24 +813,24 @@ float DSSIPluginInstance::getControlOutputValue(size_t output) const { - if (output > m_controlPortsOut.size()) return 0.0; + if (!in_range_for(m_controlPortsOut, output)) return 0.0; return (*m_controlPortsOut[output].second); } float -DSSIPluginInstance::getParameterValue(unsigned int parameter) const +DSSIPluginInstance::getParameterValue(int parameter) const { #ifdef DEBUG_DSSI SVDEBUG << "DSSIPluginInstance::getParameterValue(" << parameter << ")" << endl; #endif - if (parameter >= m_controlPortsIn.size()) return 0.0; + if (!in_range_for(m_controlPortsIn, parameter)) return 0.0; return (*m_controlPortsIn[parameter].second); } float -DSSIPluginInstance::getParameterDefault(unsigned int parameter) const +DSSIPluginInstance::getParameterDefault(int parameter) const { - if (parameter >= m_controlPortsIn.size()) return 0.0; + if (!in_range_for(m_controlPortsIn, parameter)) return 0.0; LADSPAPluginFactory *f = dynamic_cast<LADSPAPluginFactory *>(m_factory); if (f) { @@ -842,9 +842,9 @@ } int -DSSIPluginInstance::getParameterDisplayHint(unsigned int parameter) const +DSSIPluginInstance::getParameterDisplayHint(int parameter) const { - if (parameter >= m_controlPortsIn.size()) return 0.0; + if (!in_range_for(m_controlPortsIn, parameter)) return 0.0; LADSPAPluginFactory *f = dynamic_cast<LADSPAPluginFactory *>(m_factory); if (f) { @@ -1040,9 +1040,11 @@ Vamp::RealTime evTime(ev->time.time.tv_sec, ev->time.time.tv_nsec); - int frameOffset = 0; + long frameOffset = 0; if (evTime > blockTime) { - frameOffset = Vamp::RealTime::realTime2Frame(evTime - blockTime, m_sampleRate); + frameOffset = Vamp::RealTime::realTime2Frame + (evTime - blockTime, + (unsigned int)m_sampleRate); } #ifdef DEBUG_DSSI_PROCESS @@ -1051,7 +1053,7 @@ cerr << "Type: " << int(ev->type) << ", pitch: " << int(ev->data.note.note) << ", velocity: " << int(ev->data.note.velocity) << endl; #endif - if (frameOffset >= int(count)) break; + if (frameOffset >= (long)count) break; if (frameOffset < 0) { frameOffset = 0; if (ev->type == SND_SEQ_EVENT_NOTEON) { @@ -1182,8 +1184,8 @@ #endif size_t index = 0; - unsigned long *counts = (unsigned long *) - alloca(m_groupLocalEventBufferCount * sizeof(unsigned long)); + int *counts = (int *) + alloca(m_groupLocalEventBufferCount * sizeof(int)); LADSPA_Handle *instances = (LADSPA_Handle *) alloca(m_groupLocalEventBufferCount * sizeof(LADSPA_Handle)); @@ -1268,7 +1270,7 @@ void DSSIPluginInstance::midiSend(LADSPA_Handle /* instance */, snd_seq_event_t * /* events */, - unsigned long /* eventCount */) + unsignd long /* eventCount */) { // This is likely to be called from an RT context
--- a/plugin/DSSIPluginInstance.h Tue Mar 03 09:33:59 2015 +0000 +++ b/plugin/DSSIPluginInstance.h Tue Mar 03 15:18:24 2015 +0000 @@ -56,11 +56,11 @@ virtual void run(const Vamp::RealTime &, size_t count = 0); - virtual unsigned int getParameterCount() const; - virtual void setParameterValue(unsigned int parameter, float value); - virtual float getParameterValue(unsigned int parameter) const; - virtual float getParameterDefault(unsigned int parameter) const; - virtual int getParameterDisplayHint(unsigned int parameter) const; + virtual int getParameterCount() const; + virtual void setParameterValue(int parameter, float value); + virtual float getParameterValue(int parameter) const; + virtual float getParameterDefault(int parameter) const; + virtual int getParameterDisplayHint(int parameter) const; virtual ParameterList getParameterDescriptors() const; virtual float getParameter(std::string) const; @@ -83,7 +83,7 @@ virtual ProgramList getPrograms() const; virtual std::string getCurrentProgram() const; virtual std::string getProgram(int bank, int program) const; - virtual unsigned long getProgram(std::string name) const; + virtual int getProgram(std::string name) const; virtual void selectProgram(std::string program); virtual bool isBypassed() const { return m_bypassed; } @@ -110,20 +110,20 @@ int client, QString identifier, int position, - unsigned long sampleRate, + int sampleRate, size_t blockSize, int idealChannelCount, const DSSI_Descriptor* descriptor); void init(); - void instantiate(unsigned long sampleRate); + void instantiate(int sampleRate); void cleanup(); void activate(); void deactivate(); void connectPorts(); bool handleController(snd_seq_event_t *ev); - void setPortValueFromController(unsigned int portNumber, int controlValue); + void setPortValueFromController(int portNumber, int controlValue); void selectProgramAux(std::string program, bool backupPortValues); void checkProgramCache() const; @@ -145,8 +145,8 @@ LADSPA_Handle m_instanceHandle; const DSSI_Descriptor *m_descriptor; - std::vector<std::pair<unsigned long, LADSPA_Data*> > m_controlPortsIn; - std::vector<std::pair<unsigned long, LADSPA_Data*> > m_controlPortsOut; + std::vector<std::pair<int, LADSPA_Data*> > m_controlPortsIn; + std::vector<std::pair<int, LADSPA_Data*> > m_controlPortsOut; std::vector<LADSPA_Data> m_backupControlPortsIn;
--- a/plugin/RealTimePluginInstance.h Tue Mar 03 09:33:59 2015 +0000 +++ b/plugin/RealTimePluginInstance.h Tue Mar 03 15:18:24 2015 +0000 @@ -109,14 +109,14 @@ // virtual QStringList getPrograms() const { return QStringList(); } // virtual QString getCurrentProgram() const { return QString(); } virtual std::string getProgram(int /* bank */, int /* program */) const { return std::string(); } -// virtual unsigned long getProgram(QString /* name */) const { return 0; } // bank << 16 + program +// virtual int getProgram(QString /* name */) const { return 0; } // bank << 16 + program // virtual void selectProgram(QString) { } - virtual unsigned int getParameterCount() const = 0; - virtual void setParameterValue(unsigned int parameter, float value) = 0; - virtual float getParameterValue(unsigned int parameter) const = 0; - virtual float getParameterDefault(unsigned int parameter) const = 0; - virtual int getParameterDisplayHint(unsigned int parameter) const = 0; + virtual int getParameterCount() const = 0; + virtual void setParameterValue(int parameter, float value) = 0; + virtual float getParameterValue(int parameter) const = 0; + virtual float getParameterDefault(int parameter) const = 0; + virtual int getParameterDisplayHint(int parameter) const = 0; virtual std::string configure(std::string /* key */, std::string /* value */) { return std::string(); }
--- a/svcore.pro Tue Mar 03 09:33:59 2015 +0000 +++ b/svcore.pro Tue Mar 03 15:18:24 2015 +0000 @@ -51,6 +51,7 @@ HEADERS += base/AudioLevel.h \ base/AudioPlaySource.h \ + base/BaseTypes.h \ base/Clipboard.h \ base/Command.h \ base/Debug.h \ @@ -138,7 +139,6 @@ data/fileio/FileFinder.h \ data/fileio/FileReadThread.h \ data/fileio/FileSource.h \ - data/fileio/MatchFileReader.h \ data/fileio/MatrixFile.h \ data/fileio/MIDIFileReader.h \ data/fileio/MIDIFileWriter.h \ @@ -199,7 +199,6 @@ data/fileio/DataFileReaderFactory.cpp \ data/fileio/FileReadThread.cpp \ data/fileio/FileSource.cpp \ - data/fileio/MatchFileReader.cpp \ data/fileio/MatrixFile.cpp \ data/fileio/MIDIFileReader.cpp \ data/fileio/MIDIFileWriter.cpp \
--- a/system/System.cpp Tue Mar 03 09:33:59 2015 +0000 +++ b/system/System.cpp Tue Mar 03 15:18:24 2015 +0000 @@ -123,7 +123,7 @@ #endif void -GetRealMemoryMBAvailable(int &available, int &total) +GetRealMemoryMBAvailable(ssize_t &available, ssize_t &total) { available = -1; total = -1; @@ -175,11 +175,11 @@ DWORDLONG size = wavail / 1048576; if (size > INT_MAX) size = INT_MAX; - available = int(size); + available = ssize_t(size); size = wtotal / 1048576; if (size > INT_MAX) size = INT_MAX; - total = int(size); + total = ssize_t(size); return; @@ -243,7 +243,7 @@ #endif } -int +ssize_t GetDiscSpaceMBAvailable(const char *path) { #ifdef _WIN32 @@ -252,7 +252,7 @@ __int64 a = available.QuadPart; a /= 1048576; if (a > INT_MAX) a = INT_MAX; - return int(a); + return ssize_t(a); } else { cerr << "WARNING: GetDiskFreeSpaceEx failed: error code " << GetLastError() << endl; @@ -266,7 +266,7 @@ // cerr << "statvfs(" << path << ") says available: " << buf.f_bavail << ", block size: " << buf.f_bsize << endl; uint64_t available = ((buf.f_bavail / 1024) * buf.f_bsize) / 1024; if (available > INT_MAX) available = INT_MAX; - return int(available); + return ssize_t(available); } else { perror("statvfs failed"); return -1;
--- a/system/System.h Tue Mar 03 09:33:59 2015 +0000 +++ b/system/System.h Tue Mar 03 15:18:24 2015 +0000 @@ -143,12 +143,13 @@ extern ProcessStatus GetProcessStatus(int pid); // Return a vague approximation to the number of free megabytes of real memory. -// Return -1 if unknown. -extern void GetRealMemoryMBAvailable(int &available, int &total); +// Return -1 if unknown. (Hence signed args) +extern void GetRealMemoryMBAvailable(ssize_t &available, ssize_t &total); -// Return a vague approximation to the number of free megabytes of disc space -// on the partition containing the given path. Return -1 if unknown. -extern int GetDiscSpaceMBAvailable(const char *path); +// Return a vague approximation to the number of free megabytes of +// disc space on the partition containing the given path. Return -1 +// if unknown. (Hence signed return type) +extern ssize_t GetDiscSpaceMBAvailable(const char *path); extern void StoreStartupLocale(); extern void RestoreStartupLocale();