# HG changeset patch # User Chris Cannam # Date 1427109988 0 # Node ID 26da827e8fb52d5fa599b05c01e9360481fdccb9 # Parent 4968bbaf1ed87860df7d8a4bc68e0c89f122dbab# Parent 50be12cf280271763a61c8630e442fd5f6e4dcc6 Merge from cxx11 branch diff -r 4968bbaf1ed8 -r 26da827e8fb5 acinclude.m4 --- a/acinclude.m4 Mon Mar 23 10:04:51 2015 +0000 +++ b/acinclude.m4 Mon Mar 23 11:26:28 2015 +0000 @@ -112,3 +112,146 @@ ]) +# From autoconf archive: + +# ============================================================================ +# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html +# ============================================================================ +# +# SYNOPSIS +# +# AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional]) +# +# DESCRIPTION +# +# Check for baseline language coverage in the compiler for the C++11 +# standard; if necessary, add switches to CXXFLAGS to enable support. +# +# The first argument, if specified, indicates whether you insist on an +# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. +# -std=c++11). If neither is specified, you get whatever works, with +# preference for an extended mode. +# +# The second argument, if specified 'mandatory' or if left unspecified, +# indicates that baseline C++11 support is required and that the macro +# should error out if no mode with that support is found. If specified +# 'optional', then configuration proceeds regardless, after defining +# HAVE_CXX11 if and only if a supporting mode is found. +# +# LICENSE +# +# Copyright (c) 2008 Benjamin Kosnik +# Copyright (c) 2012 Zack Weinberg +# Copyright (c) 2013 Roy Stogner +# Copyright (c) 2014 Alexey Sokolov +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [[ + template + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + struct Base { + virtual void f() {} + }; + struct Child : public Base { + virtual void f() override {} + }; + + typedef check> right_angle_brackets; + + int a; + decltype(a) b; + + typedef check check_type; + check_type c; + check_type&& cr = static_cast(c); + + auto d = a; + auto l = [](){}; +]]) + +AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl + m4_if([$1], [], [], + [$1], [ext], [], + [$1], [noext], [], + [m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl + m4_if([$2], [], [ax_cxx_compile_cxx11_required=true], + [$2], [mandatory], [ax_cxx_compile_cxx11_required=true], + [$2], [optional], [ax_cxx_compile_cxx11_required=false], + [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])]) + AC_LANG_PUSH([C++])dnl + ac_success=no + AC_CACHE_CHECK(whether $CXX supports C++11 features by default, + ax_cv_cxx_compile_cxx11, + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], + [ax_cv_cxx_compile_cxx11=yes], + [ax_cv_cxx_compile_cxx11=no])]) + if test x$ax_cv_cxx_compile_cxx11 = xyes; then + ac_success=yes + fi + + m4_if([$1], [noext], [], [dnl + if test x$ac_success = xno; then + for switch in -std=gnu++11 -std=gnu++0x; do + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch]) + AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch, + $cachevar, + [ac_save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS $switch" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], + [eval $cachevar=yes], + [eval $cachevar=no]) + CXXFLAGS="$ac_save_CXXFLAGS"]) + if eval test x\$$cachevar = xyes; then + CXXFLAGS="$CXXFLAGS $switch" + ac_success=yes + break + fi + done + fi]) + + m4_if([$1], [ext], [], [dnl + if test x$ac_success = xno; then + for switch in -std=c++11 -std=c++0x; do + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch]) + AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch, + $cachevar, + [ac_save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS $switch" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], + [eval $cachevar=yes], + [eval $cachevar=no]) + CXXFLAGS="$ac_save_CXXFLAGS"]) + if eval test x\$$cachevar = xyes; then + CXXFLAGS="$CXXFLAGS $switch" + ac_success=yes + break + fi + done + fi]) + AC_LANG_POP([C++]) + if test x$ax_cxx_compile_cxx11_required = xtrue; then + if test x$ac_success = xno; then + AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.]) + fi + else + if test x$ac_success = xno; then + HAVE_CXX11=0 + AC_MSG_NOTICE([No compiler with C++11 support was found]) + else + HAVE_CXX11=1 + AC_DEFINE(HAVE_CXX11,1, + [define if the compiler supports basic C++11 syntax]) + fi + + AC_SUBST(HAVE_CXX11) + fi +]) + diff -r 4968bbaf1ed8 -r 26da827e8fb5 configure --- a/configure Mon Mar 23 10:04:51 2015 +0000 +++ b/configure Mon Mar 23 11:26:28 2015 +0000 @@ -673,6 +673,7 @@ EGREP GREP CXXCPP +HAVE_CXX11 MKDIR_P INSTALL_DATA INSTALL_SCRIPT @@ -3449,6 +3450,146 @@ $as_echo "$MKDIR_P" >&6; } +# We are daringly making use of C++11 now + + ax_cxx_compile_cxx11_required=true + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + ac_success=no + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features by default" >&5 +$as_echo_n "checking whether $CXX supports C++11 features by default... " >&6; } +if ${ax_cv_cxx_compile_cxx11+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + template + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + struct Base { + virtual void f() {} + }; + struct Child : public Base { + virtual void f() override {} + }; + + typedef check> right_angle_brackets; + + int a; + decltype(a) b; + + typedef check check_type; + check_type c; + check_type&& cr = static_cast(c); + + auto d = a; + auto l = [](){}; + +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv_cxx_compile_cxx11=yes +else + ax_cv_cxx_compile_cxx11=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11" >&5 +$as_echo "$ax_cv_cxx_compile_cxx11" >&6; } + if test x$ax_cv_cxx_compile_cxx11 = xyes; then + ac_success=yes + fi + + + + if test x$ac_success = xno; then + for switch in -std=c++11 -std=c++0x; do + cachevar=`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports C++11 features with $switch" >&5 +$as_echo_n "checking whether $CXX supports C++11 features with $switch... " >&6; } +if eval \${$cachevar+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS $switch" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + template + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + struct Base { + virtual void f() {} + }; + struct Child : public Base { + virtual void f() override {} + }; + + typedef check> right_angle_brackets; + + int a; + decltype(a) b; + + typedef check check_type; + check_type c; + check_type&& cr = static_cast(c); + + auto d = a; + auto l = [](){}; + +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + eval $cachevar=yes +else + eval $cachevar=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CXXFLAGS="$ac_save_CXXFLAGS" +fi +eval ac_res=\$$cachevar + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + if eval test x\$$cachevar = xyes; then + CXXFLAGS="$CXXFLAGS $switch" + ac_success=yes + break + fi + done + fi + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + if test x$ax_cxx_compile_cxx11_required = xtrue; then + if test x$ac_success = xno; then + as_fn_error $? "*** A compiler with support for C++11 language features is required." "$LINENO" 5 + fi + else + if test x$ac_success = xno; then + HAVE_CXX11=0 + { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++11 support was found" >&5 +$as_echo "$as_me: No compiler with C++11 support was found" >&6;} + else + HAVE_CXX11=1 + +$as_echo "#define HAVE_CXX11 1" >>confdefs.h + + fi + + + fi + ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' @@ -4202,9 +4343,10 @@ CXXFLAGS_MINIMAL="$AUTOCONF_CXXFLAGS" if test "x$GCC" = "xyes"; then - CXXFLAGS_DEBUG="-Wall -Wextra -Werror -Woverloaded-virtual -Wformat-nonliteral -Wformat-security -Winit-self -Wswitch-enum -g -pipe" - CXXFLAGS_RELEASE="-g0 -O2 -Wall -pipe" - CXXFLAGS_MINIMAL="-g0 -O0" + CXXFLAGS_ANY="-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" diff -r 4968bbaf1ed8 -r 26da827e8fb5 configure.ac --- a/configure.ac Mon Mar 23 10:04:51 2015 +0000 +++ b/configure.ac Mon Mar 23 11:26:28 2015 +0000 @@ -25,6 +25,9 @@ AC_PROG_INSTALL AC_PROG_MKDIR_P +# We are daringly making use of C++11 now +AX_CXX_COMPILE_STDCXX_11(noext) + AC_HEADER_STDC # These are the flags Autoconf guesses for us; we use them later if @@ -50,9 +53,10 @@ CXXFLAGS_MINIMAL="$AUTOCONF_CXXFLAGS" if test "x$GCC" = "xyes"; then - CXXFLAGS_DEBUG="-Wall -Wextra -Werror -Woverloaded-virtual -Wformat-nonliteral -Wformat-security -Winit-self -Wswitch-enum -g -pipe" - CXXFLAGS_RELEASE="-g0 -O2 -Wall -pipe" - CXXFLAGS_MINIMAL="-g0 -O0" + CXXFLAGS_ANY="-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" diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/Colour3DPlotLayer.cpp --- a/layer/Colour3DPlotLayer.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/Colour3DPlotLayer.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -34,6 +34,8 @@ #include #endif +using std::vector; + //#define DEBUG_COLOUR_3D_PLOT_LAYER_PAINT 1 @@ -78,8 +80,8 @@ connectSignals(m_model); connect(m_model, SIGNAL(modelChanged()), this, SLOT(modelChanged())); - connect(m_model, SIGNAL(modelChangedWithin(int, int)), - this, SLOT(modelChangedWithin(int, int))); + connect(m_model, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), + this, SLOT(modelChangedWithin(sv_frame_t, sv_frame_t))); m_peakResolution = 256; if (model->getResolution() > 512) { @@ -107,13 +109,13 @@ } void -Colour3DPlotLayer::cacheInvalid(int startFrame, int endFrame) +Colour3DPlotLayer::cacheInvalid(sv_frame_t startFrame, sv_frame_t endFrame) { if (!m_cache || !m_model) return; int modelResolution = m_model->getResolution(); - int start = startFrame / modelResolution; - int end = endFrame / modelResolution + 1; + int start = int(startFrame / modelResolution); + int end = int(endFrame / modelResolution + 1); if (m_cacheValidStart < end) m_cacheValidStart = end; if (m_cacheValidEnd > start) m_cacheValidEnd = start; if (m_cacheValidStart > m_cacheValidEnd) m_cacheValidEnd = m_cacheValidStart; @@ -135,7 +137,7 @@ } void -Colour3DPlotLayer::modelChangedWithin(int startFrame, int endFrame) +Colour3DPlotLayer::modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame) { if (!m_colourScaleSet && m_colourScale == LinearScale) { if (m_model && m_model->getWidth() > 50) { @@ -234,11 +236,11 @@ *min = -50; *max = 50; - *deflt = lrintf(log10(1.f) * 20.0);; + *deflt = int(lrint(log10(1.0) * 20.0)); if (*deflt < *min) *deflt = *min; if (*deflt > *max) *deflt = *max; - val = lrintf(log10(m_gain) * 20.0); + val = int(lrint(log10(m_gain) * 20.0)); if (val < *min) val = *min; if (val > *max) val = *max; @@ -336,7 +338,7 @@ Colour3DPlotLayer::setProperty(const PropertyName &name, int value) { if (name == "Gain") { - setGain(pow(10, float(value)/20.0)); + setGain(float(pow(10, value/20.0))); } else if (name == "Colour Scale") { switch (value) { default: @@ -541,13 +543,13 @@ } bool -Colour3DPlotLayer::getValueExtents(float &min, float &max, +Colour3DPlotLayer::getValueExtents(double &min, double &max, bool &logarithmic, QString &unit) const { if (!m_model) return false; min = 0; - max = m_model->getHeight(); + max = double(m_model->getHeight()); logarithmic = false; unit = ""; @@ -556,29 +558,31 @@ } bool -Colour3DPlotLayer::getDisplayExtents(float &min, float &max) const +Colour3DPlotLayer::getDisplayExtents(double &min, double &max) const { if (!m_model) return false; + double hmax = double(m_model->getHeight()); + min = m_miny; max = m_maxy; if (max <= min) { min = 0; - max = m_model->getHeight(); + max = hmax; } if (min < 0) min = 0; - if (max > m_model->getHeight()) max = m_model->getHeight(); + if (max > hmax) max = hmax; return true; } bool -Colour3DPlotLayer::setDisplayExtents(float min, float max) +Colour3DPlotLayer::setDisplayExtents(double min, double max) { if (!m_model) return false; - m_miny = lrintf(min); - m_maxy = lrintf(max); + m_miny = int(lrint(min)); + m_maxy = int(lrint(max)); emit layerParametersChanged(); return true; @@ -586,7 +590,7 @@ bool Colour3DPlotLayer::getYScaleValue(const View *, int, - float &, QString &) const + double &, QString &) const { return false;//!!! } @@ -606,9 +610,9 @@ { if (!m_model) return 0; - float min, max; + double min, max; getDisplayExtents(min, max); - return m_model->getHeight() - lrintf(max - min); + return m_model->getHeight() - int(lrint(max - min)); } void @@ -620,8 +624,8 @@ int dist = m_model->getHeight() - step; if (dist < 1) dist = 1; - float centre = m_miny + (float(m_maxy) - float(m_miny)) / 2.f; - m_miny = lrintf(centre - float(dist)/2); + double centre = m_miny + (m_maxy - m_miny) / 2.0; + m_miny = int(lrint(centre - dist/2.0)); if (m_miny < 0) m_miny = 0; m_maxy = m_miny + dist; if (m_maxy > m_model->getHeight()) m_maxy = m_model->getHeight(); @@ -640,42 +644,54 @@ 0, m_model->getHeight(), ""); } -float -Colour3DPlotLayer::getYForBin(View *v, float bin) const +double +Colour3DPlotLayer::getYForBin(View *v, double bin) const { - float y = bin; + double y = bin; if (!m_model) return y; - float mn = 0, mx = m_model->getHeight(); + double mn = 0, mx = m_model->getHeight(); getDisplayExtents(mn, mx); - float h = v->height(); + double h = v->height(); if (m_binScale == LinearBinScale) { y = h - (((bin - mn) * h) / (mx - mn)); } else { - float logmin = mn + 1, logmax = mx + 1; + double logmin = mn + 1, logmax = mx + 1; LogRange::mapRange(logmin, logmax); y = h - (((LogRange::map(bin + 1) - logmin) * h) / (logmax - logmin)); } return y; } -float -Colour3DPlotLayer::getBinForY(View *v, float y) const +int +Colour3DPlotLayer::getIYForBin(View *v, int bin) const { - float bin = y; + return int(round(getYForBin(v, bin))); +} + +double +Colour3DPlotLayer::getBinForY(View *v, double y) const +{ + double bin = y; if (!m_model) return bin; - float mn = 0, mx = m_model->getHeight(); + double mn = 0, mx = m_model->getHeight(); getDisplayExtents(mn, mx); - float h = v->height(); + double h = v->height(); if (m_binScale == LinearBinScale) { bin = mn + ((h - y) * (mx - mn)) / h; } else { - float logmin = mn + 1, logmax = mx + 1; + double logmin = mn + 1, logmax = mx + 1; LogRange::mapRange(logmin, logmax); bin = LogRange::unmap(logmin + ((h - y) * (logmax - logmin)) / h) - 1; } return bin; } +int +Colour3DPlotLayer::getIBinForY(View *v, int y) const +{ + return int(floor(getBinForY(v, y))); +} + QString Colour3DPlotLayer::getFeatureDescription(View *v, QPoint &pos) const { @@ -684,14 +700,14 @@ int x = pos.x(); int y = pos.y(); - int modelStart = m_model->getStartFrame(); + sv_frame_t modelStart = m_model->getStartFrame(); int modelResolution = m_model->getResolution(); - float srRatio = - float(v->getViewManager()->getMainModelSampleRate()) / - float(m_model->getSampleRate()); + double srRatio = + v->getViewManager()->getMainModelSampleRate() / + m_model->getSampleRate(); - int sx0 = int((v->getFrameForX(x) / srRatio - modelStart) / + int sx0 = int((double(v->getFrameForX(x)) / srRatio - double(modelStart)) / modelResolution); int f0 = sx0 * modelResolution; @@ -708,10 +724,10 @@ if (symin < 0) symin = 0; if (symax > sh) symax = sh; - // float binHeight = float(v->height()) / (symax - symin); + // double binHeight = double(v->height()) / (symax - symin); // int sy = int((v->height() - y) / binHeight) + symin; - int sy = getBinForY(v, y); + int sy = getIBinForY(v, y); if (sy < 0 || sy >= m_model->getHeight()) { return ""; @@ -779,11 +795,11 @@ int ch = h - 20; if (ch > 20 && m_cache) { - float min = m_model->getMinimumLevel(); - float max = m_model->getMaximumLevel(); + double min = m_model->getMinimumLevel(); + double max = m_model->getMaximumLevel(); - float mmin = min; - float mmax = max; + double mmin = min; + double mmax = max; if (m_colourScale == LogScale) { LogRange::mapRange(mmin, mmax); @@ -792,23 +808,23 @@ mmax = 1.f; } else if (m_colourScale == AbsoluteScale) { if (mmin < 0) { - if (fabsf(mmin) > fabsf(mmax)) mmax = fabsf(mmin); - else mmax = fabsf(mmax); + if (fabs(mmin) > fabs(mmax)) mmax = fabs(mmin); + else mmax = fabs(mmax); mmin = 0; } else { - mmin = fabsf(mmin); - mmax = fabsf(mmax); + mmin = fabs(mmin); + mmax = fabs(mmax); } } - if (max == min) max = min + 1.0; - if (mmax == mmin) mmax = mmin + 1.0; + if (max == min) max = min + 1.f; + if (mmax == mmin) mmax = mmin + 1.f; paint.setPen(v->getForeground()); paint.drawRect(4, 10, cw - 8, ch+1); for (int y = 0; y < ch; ++y) { - float value = ((max - min) * (ch - y - 1)) / ch + min; + double value = ((max - min) * (double(ch-y) - 1.0)) / double(ch) + min; if (m_colourScale == LogScale) { value = LogRange::map(value); } @@ -870,7 +886,7 @@ int y0; - y0 = lrintf(getYForBin(v, i)); + y0 = getIYForBin(v, i); int h = py - y0; if (i > symin) { @@ -918,8 +934,8 @@ while (values.size() < m_model->getHeight()) values.push_back(0.f); if (!m_normalizeColumns && !m_normalizeHybrid) return values; - float colMax = 0.f, colMin = 0.f; - float min = 0.f, max = 0.f; + double colMax = 0.f, colMin = 0.f; + double min = 0.f, max = 0.f; min = m_model->getMinimumLevel(); max = m_model->getMaximumLevel(); @@ -932,17 +948,17 @@ for (int y = 0; y < values.size(); ++y) { - float value = values.at(y); - float norm = (value - colMin) / (colMax - colMin); - float newvalue = min + (max - min) * norm; + double value = values.at(y); + double norm = (value - colMin) / (colMax - colMin); + double newvalue = min + (max - min) * norm; - if (value != newvalue) values[y] = newvalue; + if (value != newvalue) values[y] = float(newvalue); } if (m_normalizeHybrid && (colMax > 0.0)) { - float logmax = log10(colMax); + double logmax = log10(colMax); for (int y = 0; y < values.size(); ++y) { - values[y] *= logmax; + values[y] = float(values[y] * logmax); } } @@ -954,12 +970,12 @@ { Profiler profiler("Colour3DPlotLayer::fillCache", true); - int modelStart = m_model->getStartFrame(); - int modelEnd = m_model->getEndFrame(); + sv_frame_t modelStart = m_model->getStartFrame(); + sv_frame_t modelEnd = m_model->getEndFrame(); int modelResolution = m_model->getResolution(); - int modelStartBin = modelStart / modelResolution; - int modelEndBin = modelEnd / modelResolution; + int modelStartBin = int(modelStart / modelResolution); + int modelEndBin = int(modelEnd / modelResolution); #ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT cerr << "Colour3DPlotLayer::fillCache: range " << firstBin << " -> " << lastBin << " of model range " << modelStartBin << " -> " << modelEndBin << " (model resolution " << modelResolution << ")" << endl; @@ -1069,8 +1085,8 @@ DenseThreeDimensionalModel::Column values; - float min = m_model->getMinimumLevel(); - float max = m_model->getMaximumLevel(); + double min = m_model->getMinimumLevel(); + double max = m_model->getMaximumLevel(); if (m_colourScale == LogScale) { LogRange::mapRange(min, max); @@ -1079,16 +1095,16 @@ max = 1.f; } else if (m_colourScale == AbsoluteScale) { if (min < 0) { - if (fabsf(min) > fabsf(max)) max = fabsf(min); - else max = fabsf(max); + if (fabs(min) > fabs(max)) max = fabs(min); + else max = fabs(max); min = 0; } else { - min = fabsf(min); - max = fabsf(max); + min = fabs(min); + max = fabs(max); } } - if (max == min) max = min + 1.0; + if (max == min) max = min + 1.f; ColourMapper mapper(m_colourMap, 0.f, 255.f); @@ -1102,7 +1118,7 @@ } } - float visibleMax = 0.f, visibleMin = 0.f; + double visibleMax = 0.f, visibleMin = 0.f; if (normalizeVisible) { @@ -1110,7 +1126,7 @@ values = getColumn(c); - float colMax = 0.f, colMin = 0.f; + double colMax = 0.f, colMin = 0.f; for (int y = 0; y < cacheHeight; ++y) { if (y >= values.size()) break; @@ -1128,12 +1144,12 @@ if (visibleMin > visibleMax) std::swap(visibleMin, visibleMax); } else if (m_colourScale == AbsoluteScale) { if (visibleMin < 0) { - if (fabsf(visibleMin) > fabsf(visibleMax)) visibleMax = fabsf(visibleMin); - else visibleMax = fabsf(visibleMax); + if (fabs(visibleMin) > fabs(visibleMax)) visibleMax = fabs(visibleMin); + else visibleMax = fabs(visibleMax); visibleMin = 0; } else { - visibleMin = fabsf(visibleMin); - visibleMax = fabsf(visibleMax); + visibleMin = fabs(visibleMin); + visibleMax = fabs(visibleMax); } } } @@ -1162,7 +1178,7 @@ for (int y = 0; y < cacheHeight; ++y) { - float value = min; + double value = min; if (y < values.size()) { value = values.at(y); } @@ -1172,11 +1188,11 @@ if (m_colourScale == LogScale) { value = LogRange::map(value); } else if (m_colourScale == AbsoluteScale) { - value = fabsf(value); + value = fabs(value); } if (normalizeVisible) { - float norm = (value - visibleMin) / (visibleMax - visibleMin); + double norm = (value - visibleMin) / (visibleMax - visibleMin); value = min + (max - min) * norm; } @@ -1235,9 +1251,8 @@ if (!m_model || !v || !(v->getViewManager())) { return false; } - float srRatio = - float(v->getViewManager()->getMainModelSampleRate()) / - float(m_model->getSampleRate()); + double srRatio = + v->getViewManager()->getMainModelSampleRate() / m_model->getSampleRate(); if (m_opaque || m_smooth || m_model->getHeight() >= v->height() || @@ -1271,8 +1286,8 @@ if (m_normalizeVisibleArea && !m_normalizeColumns) rect = v->rect(); - int modelStart = m_model->getStartFrame(); - int modelEnd = m_model->getEndFrame(); + sv_frame_t modelStart = m_model->getStartFrame(); + sv_frame_t modelEnd = m_model->getEndFrame(); int modelResolution = m_model->getResolution(); // The cache is from the model's start frame to the model's end @@ -1289,13 +1304,12 @@ int h = v->height(); - float srRatio = - float(v->getViewManager()->getMainModelSampleRate()) / - float(m_model->getSampleRate()); + double srRatio = + v->getViewManager()->getMainModelSampleRate() / m_model->getSampleRate(); - int sx0 = int((v->getFrameForX(x0) / srRatio - modelStart) + int sx0 = int((double(v->getFrameForX(x0)) / srRatio - double(modelStart)) / modelResolution); - int sx1 = int((v->getFrameForX(x1) / srRatio - modelStart) + int sx1 = int((double(v->getFrameForX(x1)) / srRatio - double(modelStart)) / modelResolution); int sh = m_model->getHeight(); @@ -1337,12 +1351,12 @@ for (int sx = sx0; sx <= sx1; ++sx) { - int fx = sx * modelResolution; + sv_frame_t fx = sx * modelResolution; if (fx + modelResolution <= modelStart || fx > modelEnd) continue; - int rx0 = v->getXForFrame(int((fx + modelStart) * srRatio)); - int rx1 = v->getXForFrame(int((fx + modelStart + modelResolution + 1) * srRatio)); + int rx0 = v->getXForFrame(int(double(fx + modelStart) * srRatio)); + int rx1 = v->getXForFrame(int(double(fx + modelStart + modelResolution + 1) * srRatio)); int rw = rx1 - rx0; if (rw < 1) rw = 1; @@ -1353,8 +1367,8 @@ for (int sy = symin; sy < symax; ++sy) { - int ry0 = getYForBin(v, sy); - int ry1 = getYForBin(v, sy + 1); + int ry0 = getIYForBin(v, sy); + int ry1 = getIYForBin(v, sy + 1); QRect r(rx0, ry1, rw, ry0 - ry1); QRgb pixel = qRgb(255, 255, 255); @@ -1396,7 +1410,7 @@ if (showLabel) { if (sx >= 0 && sx < m_cache->width() && sy >= 0 && sy < m_cache->height()) { - float value = m_model->getValueAt(sx, sy); + double value = m_model->getValueAt(sx, sy); snprintf(labelbuf, buflen, "%06f", value); QString text(labelbuf); paint.setPen(v->getBackground()); @@ -1415,12 +1429,12 @@ Profiler profiler("Colour3DPlotLayer::paintDense", true); if (!m_cache) return; - float modelStart = m_model->getStartFrame(); - float modelResolution = m_model->getResolution(); + double modelStart = double(m_model->getStartFrame()); + double modelResolution = double(m_model->getResolution()); - int mmsr = v->getViewManager()->getMainModelSampleRate(); - int msr = m_model->getSampleRate(); - float srRatio = float(mmsr) / float(msr); + sv_samplerate_t mmsr = v->getViewManager()->getMainModelSampleRate(); + sv_samplerate_t msr = m_model->getSampleRate(); + double srRatio = mmsr / msr; int x0 = rect.left(); int x1 = rect.right() + 1; @@ -1476,29 +1490,26 @@ int sw = source->width(); - int xf = -1; - int nxf = v->getFrameForX(x0); + sv_frame_t xf = -1; + sv_frame_t nxf = v->getFrameForX(x0); - float epsilon = 0.000001; + double epsilon = 0.000001; -#ifdef __GNUC__ - float sxa[w * 2]; -#else - float *sxa = (float *)alloca(w * 2 * sizeof(float)); -#endif + vector sxa(w*2); + for (int x = 0; x < w; ++x) { xf = nxf; nxf = xf + zoomLevel; - float sx0 = (float(xf) / srRatio - modelStart) / modelResolution; - float sx1 = (float(nxf) / srRatio - modelStart) / modelResolution; + double sx0 = (double(xf) / srRatio - modelStart) / modelResolution; + double sx1 = (double(nxf) / srRatio - modelStart) / modelResolution; sxa[x*2] = sx0; sxa[x*2 + 1] = sx1; } - float logmin = symin+1, logmax = symax+1; + double logmin = symin+1, logmax = symax+1; LogRange::mapRange(logmin, logmax); #ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT @@ -1509,7 +1520,7 @@ for (int y = 0; y < h; ++y) { - float sy = getBinForY(v, y) - 0.5; + double sy = getBinForY(v, y) - 0.5; int syi = int(sy + epsilon); if (syi < 0 || syi >= source->height()) continue; @@ -1526,52 +1537,52 @@ targetLine[x] = 0; - float sx0 = sxa[x*2]; + double sx0 = sxa[x*2]; if (sx0 < 0) continue; int sx0i = int(sx0 + epsilon); if (sx0i >= sw) break; - float a = float(sourceLine[sx0i]); - float b = a; - float value; + double a = sourceLine[sx0i]; + double b = a; + double value; - float sx1 = sxa[x*2+1]; + double sx1 = sxa[x*2+1]; if (sx1 > sx0 + 1.f) { int sx1i = int(sx1); bool have = false; for (int sx = sx0i; sx <= sx1i; ++sx) { if (sx < 0 || sx >= sw) continue; if (!have) { - a = float(sourceLine[sx]); - b = float(nextSource[sx]); + a = sourceLine[sx]; + b = nextSource[sx]; have = true; } else { - a = std::max(a, float(sourceLine[sx])); - b = std::max(b, float(nextSource[sx])); + a = std::max(a, double(sourceLine[sx])); + b = std::max(b, double(nextSource[sx])); } } - float yprop = sy - syi; + double yprop = sy - syi; value = (a * (1.f - yprop) + b * yprop); } else { - a = float(sourceLine[sx0i]); - b = float(nextSource[sx0i]); - float yprop = sy - syi; + a = sourceLine[sx0i]; + b = nextSource[sx0i]; + double yprop = sy - syi; value = (a * (1.f - yprop) + b * yprop); int oi = sx0i + 1; - float xprop = sx0 - sx0i; + double xprop = sx0 - sx0i; xprop -= 0.5; if (xprop < 0) { oi = sx0i - 1; xprop = -xprop; } if (oi < 0 || oi >= sw) oi = sx0i; - a = float(sourceLine[oi]); - b = float(nextSource[oi]); + a = sourceLine[oi]; + b = nextSource[oi]; value = (value * (1.f - xprop) + (a * (1.f - yprop) + b * yprop) * xprop); } - int vi = lrintf(value); + int vi = int(lrint(value)); if (vi > 255) vi = 255; if (vi < 0) vi = 0; targetLine[x] = uchar(vi); @@ -1579,14 +1590,14 @@ } } else { - float sy0 = getBinForY(v, 0); + double sy0 = getBinForY(v, 0); int psy0i = -1, psy1i = -1; for (int y = 0; y < h; ++y) { - float sy1 = sy0; - sy0 = getBinForY(v, y + 1); + double sy1 = sy0; + sy0 = getBinForY(v, double(y + 1)); int sy0i = int(sy0 + epsilon); int sy1i = int(sy1); @@ -1613,11 +1624,11 @@ for (int x = 0; x < w; ++x) { - float sx1 = sxa[x*2 + 1]; + double sx1 = sxa[x*2 + 1]; if (sx1 < 0) continue; int sx1i = int(sx1); - float sx0 = sxa[x*2]; + double sx0 = sxa[x*2]; if (sx0 < 0) continue; int sx0i = int(sx0 + epsilon); if (sx0i >= sw) break; @@ -1644,7 +1655,7 @@ } bool -Colour3DPlotLayer::snapToFeatureFrame(View *v, int &frame, +Colour3DPlotLayer::snapToFeatureFrame(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const { @@ -1653,8 +1664,8 @@ } resolution = m_model->getResolution(); - int left = (frame / resolution) * resolution; - int right = left + resolution; + sv_frame_t left = (frame / resolution) * resolution; + sv_frame_t right = left + resolution; switch (snap) { case SnapLeft: frame = left; break; diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/Colour3DPlotLayer.h --- a/layer/Colour3DPlotLayer.h Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/Colour3DPlotLayer.h Mon Mar 23 11:26:28 2015 +0000 @@ -56,7 +56,7 @@ virtual QString getFeatureDescription(View *v, QPoint &) const; - virtual bool snapToFeatureFrame(View *v, int &frame, + virtual bool snapToFeatureFrame(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const; @@ -145,14 +145,14 @@ void setSmooth(bool i); bool getSmooth() const; - virtual bool getValueExtents(float &min, float &max, + virtual bool getValueExtents(double &min, double &max, bool &logarithmic, QString &unit) const; - virtual bool getDisplayExtents(float &min, float &max) const; - virtual bool setDisplayExtents(float min, float max); + virtual bool getDisplayExtents(double &min, double &max) const; + virtual bool setDisplayExtents(double min, double max); virtual bool getYScaleValue(const View *, int /* y */, - float &/* value */, QString &/* unit */) const; + double &/* value */, QString &/* unit */) const; virtual int getVerticalZoomSteps(int &defaultStep) const; virtual int getCurrentVerticalZoomStep() const; @@ -166,9 +166,9 @@ protected slots: void cacheInvalid(); - void cacheInvalid(int startFrame, int endFrame); + void cacheInvalid(sv_frame_t startFrame, sv_frame_t endFrame); void modelChanged(); - void modelChangedWithin(int, int); + void modelChangedWithin(sv_frame_t, sv_frame_t); protected: const DenseThreeDimensionalModel *m_model; // I do not own this @@ -202,15 +202,25 @@ * and the vertical scale is the usual way up). Bin number may be * fractional, to obtain a position part-way through a bin. */ - float getYForBin(View *, float bin) const; + double getYForBin(View *, double bin) const; /** + * As getYForBin, but rounding to integer values. + */ + int getIYForBin(View *, int bin) const; + + /** * Return the bin number, possibly fractional, at the given y * coordinate. Note that the whole numbers occur at the positions * at which the bins "start" (i.e. the bottom of the visible bin, * if the vertical scale is the usual way up). */ - float getBinForY(View *, float y) const; + double getBinForY(View *, double y) const; + + /** + * As getBinForY, but rounding to integer values. + */ + int getIBinForY(View *, int y) const; DenseThreeDimensionalModel::Column getColumn(int col) const; diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/ColourDatabase.cpp --- a/layer/ColourDatabase.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/ColourDatabase.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -34,29 +34,28 @@ int ColourDatabase::getColourCount() const { - return m_colours.size(); + return int(m_colours.size()); } QString ColourDatabase::getColourName(int c) const { - if (c < 0 || size_t(c) >= m_colours.size()) return ""; + if (!in_range_for(m_colours, c)) return ""; return m_colours[c].name; } QColor ColourDatabase::getColour(int c) const { - if (c < 0 || size_t(c) >= m_colours.size()) return Qt::black; + if (!in_range_for(m_colours, c)) return Qt::black; return m_colours[c].colour; } QColor ColourDatabase::getColour(QString name) const { - for (ColourList::const_iterator i = m_colours.begin(); - i != m_colours.end(); ++i) { - if (i->name == name) return i->colour; + for (auto &c: m_colours) { + if (c.name == name) return c.colour; } return Qt::black; @@ -66,9 +65,8 @@ ColourDatabase::getColourIndex(QString name) const { int index = 0; - for (ColourList::const_iterator i = m_colours.begin(); - i != m_colours.end(); ++i) { - if (i->name == name) return index; + for (auto &c: m_colours) { + if (c.name == name) return index; ++index; } @@ -76,12 +74,11 @@ } int -ColourDatabase::getColourIndex(QColor c) const +ColourDatabase::getColourIndex(QColor col) const { int index = 0; - for (ColourList::const_iterator i = m_colours.begin(); - i != m_colours.end(); ++i) { - if (i->colour == c) return index; + for (auto &c: m_colours) { + if (c.colour == col) return index; ++index; } @@ -91,14 +88,14 @@ bool ColourDatabase::useDarkBackground(int c) const { - if (c < 0 || size_t(c) >= m_colours.size()) return false; + if (!in_range_for(m_colours, c)) return false; return m_colours[c].darkbg; } void ColourDatabase::setUseDarkBackground(int c, bool dark) { - if (c < 0 || size_t(c) >= m_colours.size()) return; + if (!in_range_for(m_colours, c)) return; if (m_colours[c].darkbg != dark) { m_colours[c].darkbg = dark; emit colourDatabaseChanged(); @@ -109,6 +106,7 @@ ColourDatabase::addColour(QColor c, QString name) { int index = 0; + for (ColourList::iterator i = m_colours.begin(); i != m_colours.end(); ++i) { if (i->name == name) { @@ -147,7 +145,7 @@ { colourName = ""; colourSpec = ""; - if (index < 0 || size_t(index) >= m_colours.size()) return; + if (!in_range_for(m_colours, index)) return; colourName = getColourName(index); QColor c = getColour(index); diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/ColourMapper.cpp --- a/layer/ColourMapper.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/ColourMapper.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -21,7 +21,7 @@ #include "base/Debug.h" -ColourMapper::ColourMapper(int map, float min, float max) : +ColourMapper::ColourMapper(int map, double min, double max) : QObject(), m_map(map), m_min(min), @@ -69,17 +69,16 @@ } QColor -ColourMapper::map(float value) const +ColourMapper::map(double value) const { - float norm = (value - m_min) / (m_max - m_min); - if (norm < 0.f) norm = 0.f; - if (norm > 1.f) norm = 1.f; + double norm = (value - m_min) / (m_max - m_min); + if (norm < 0.0) norm = 0.0; + if (norm > 1.0) norm = 1.0; - float h = 0.f, s = 0.f, v = 0.f, r = 0.f, g = 0.f, b = 0.f; + double h = 0.0, s = 0.0, v = 0.0, r = 0.0, g = 0.0, b = 0.0; bool hsv = true; -// float red = 0.f, green = 0.3333f; - float blue = 0.6666f, pieslice = 0.3333f; + double blue = 0.6666, pieslice = 0.3333; if (m_map >= getColourMapCount()) return Qt::black; StandardMap map = (StandardMap)m_map; @@ -87,8 +86,8 @@ switch (map) { case DefaultColours: - h = blue - norm * 2.f * pieslice; - s = 0.5f + norm/2.f; + h = blue - norm * 2.0 * pieslice; + s = 0.5f + norm/2.0; v = norm; break; @@ -98,53 +97,53 @@ break; case BlackOnWhite: - r = g = b = 1.f - norm; + r = g = b = 1.0 - norm; hsv = false; break; case RedOnBlue: - h = blue - pieslice/4.f + norm * (pieslice + pieslice/4.f); - s = 1.f; + h = blue - pieslice/4.0 + norm * (pieslice + pieslice/4.0); + s = 1.0; v = norm; break; case YellowOnBlack: - h = 0.15f; - s = 1.f; + h = 0.15; + s = 1.0; v = norm; break; case BlueOnBlack: h = blue; - s = 1.f; - v = norm * 2.f; - if (v > 1.f) { - v = 1.f; - s = 1.f - (sqrtf(norm) - 0.707f) * 3.413f; - if (s < 0.f) s = 0.f; - if (s > 1.f) s = 1.f; + s = 1.0; + v = norm * 2.0; + if (v > 1.0) { + v = 1.0; + s = 1.0 - (sqrt(norm) - 0.707) * 3.413; + if (s < 0.0) s = 0.0; + if (s > 1.0) s = 1.0; } break; case Sunset: - r = (norm - 0.24f) * 2.38f; - if (r > 1.f) r = 1.f; - if (r < 0.f) r = 0.f; - g = (norm - 0.64f) * 2.777f; - if (g > 1.f) g = 1.f; - if (g < 0.f) g = 0.f; + r = (norm - 0.24) * 2.38; + if (r > 1.0) r = 1.0; + if (r < 0.0) r = 0.0; + g = (norm - 0.64) * 2.777; + if (g > 1.0) g = 1.0; + if (g < 0.0) g = 0.0; b = (3.6f * norm); - if (norm > 0.277f) b = 2.f - b; - if (b > 1.f) b = 1.f; - if (b < 0.f) b = 0.f; + if (norm > 0.277) b = 2.0 - b; + if (b > 1.0) b = 1.0; + if (b < 0.0) b = 0.0; hsv = false; break; case FruitSalad: - h = blue + (pieslice/6.f) - norm; - if (h < 0.f) h += 1.f; - s = 1.f; - v = 1.f; + h = blue + (pieslice/6.0) - norm; + if (h < 0.0) h += 1.0; + s = 1.0; + v = 1.0; break; case Banded: @@ -164,47 +163,47 @@ case Printer: if (norm > 0.8) { - r = 1.f; + r = 1.0; } else if (norm > 0.7) { - r = 0.9f; + r = 0.9; } else if (norm > 0.6) { - r = 0.8f; + r = 0.8; } else if (norm > 0.5) { - r = 0.7f; + r = 0.7; } else if (norm > 0.4) { - r = 0.6f; + r = 0.6; } else if (norm > 0.3) { - r = 0.5f; + r = 0.5; } else if (norm > 0.2) { - r = 0.4f; + r = 0.4; } else { - r = 0.f; + r = 0.0; } - r = g = b = 1.f - r; + r = g = b = 1.0 - r; hsv = false; break; case HighGain: - if (norm <= 1.f / 256.f) { - norm = 0.f; + if (norm <= 1.0 / 256.0) { + norm = 0.0; } else { - norm = 0.1f + (powf(((norm - 0.5f) * 2.f), 3.f) + 1.f) / 2.081f; + norm = 0.1f + (pow(((norm - 0.5) * 2.0), 3.0) + 1.0) / 2.081; } // now as for Sunset - r = (norm - 0.24f) * 2.38f; - if (r > 1.f) r = 1.f; - if (r < 0.f) r = 0.f; - g = (norm - 0.64f) * 2.777f; - if (g > 1.f) g = 1.f; - if (g < 0.f) g = 0.f; + r = (norm - 0.24) * 2.38; + if (r > 1.0) r = 1.0; + if (r < 0.0) r = 0.0; + g = (norm - 0.64) * 2.777; + if (g > 1.0) g = 1.0; + if (g < 0.0) g = 0.0; b = (3.6f * norm); - if (norm > 0.277f) b = 2.f - b; - if (b > 1.f) b = 1.f; - if (b < 0.f) b = 0.f; + if (norm > 0.277) b = 2.0 - b; + if (b > 1.0) b = 1.0; + if (b < 0.0) b = 0.0; hsv = false; /* - if (r > 1.f) r = 1.f; - r = g = b = 1.f - r; + if (r > 1.0) r = 1.0; + r = g = b = 1.0 - r; hsv = false; */ break; diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/ColourMapper.h --- a/layer/ColourMapper.h Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/ColourMapper.h Mon Mar 23 11:26:28 2015 +0000 @@ -29,7 +29,7 @@ Q_OBJECT public: - ColourMapper(int map, float minValue, float maxValue); + ColourMapper(int map, double minValue, double maxValue); virtual ~ColourMapper(); enum StandardMap { @@ -48,21 +48,21 @@ }; int getMap() const { return m_map; } - float getMinValue() const { return m_min; } - float getMaxValue() const { return m_max; } + double getMinValue() const { return m_min; } + double getMaxValue() const { return m_max; } static int getColourMapCount(); static QString getColourMapName(int n); - QColor map(float value) const; + QColor map(double value) const; QColor getContrastingColour() const; // for cursors etc bool hasLightBackground() const; protected: int m_map; - float m_min; - float m_max; + double m_min; + double m_max; }; #endif diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/ColourScaleLayer.h --- a/layer/ColourScaleLayer.h Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/ColourScaleLayer.h Mon Mar 23 11:26:28 2015 +0000 @@ -23,7 +23,7 @@ { public: virtual QString getScaleUnits() const = 0; - virtual QColor getColourForValue(View *v, float value) const = 0; + virtual QColor getColourForValue(View *v, double value) const = 0; }; #endif diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/FlexiNoteLayer.cpp --- a/layer/FlexiNoteLayer.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/FlexiNoteLayer.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -222,7 +222,7 @@ } bool -FlexiNoteLayer::getValueExtents(float &min, float &max, +FlexiNoteLayer::getValueExtents(double &min, double &max, bool &logarithmic, QString &unit) const { if (!m_model) return false; @@ -231,8 +231,8 @@ if (shouldConvertMIDIToHz()) { unit = "Hz"; - min = Pitch::getFrequencyForPitch(lrintf(min)); - max = Pitch::getFrequencyForPitch(lrintf(max + 1)); + min = Pitch::getFrequencyForPitch(int(lrint(min))); + max = Pitch::getFrequencyForPitch(int(lrint(max + 1))); } else unit = getScaleUnits(); if (m_verticalScale == MIDIRangeScale || @@ -242,7 +242,7 @@ } bool -FlexiNoteLayer::getDisplayExtents(float &min, float &max) const +FlexiNoteLayer::getDisplayExtents(double &min, double &max) const { if (!m_model || shouldAutoAlign()) { // std::cerr << "No model or shouldAutoAlign()" << std::endl; @@ -264,8 +264,8 @@ } if (shouldConvertMIDIToHz()) { - min = Pitch::getFrequencyForPitch(lrintf(min)); - max = Pitch::getFrequencyForPitch(lrintf(max + 1)); + min = Pitch::getFrequencyForPitch(int(lrint(min))); + max = Pitch::getFrequencyForPitch(int(lrint(max + 1))); } #ifdef DEBUG_NOTE_LAYER @@ -276,7 +276,7 @@ } bool -FlexiNoteLayer::setDisplayExtents(float min, float max) +FlexiNoteLayer::setDisplayExtents(double min, double max) { if (!m_model) return false; @@ -284,7 +284,7 @@ if (min == 0.f) { max = 1.f; } else { - max = min * 1.0001; + max = min * 1.0001f; } } @@ -318,7 +318,7 @@ RangeMapper *mapper = getNewVerticalZoomRangeMapper(); if (!mapper) return 0; - float dmin, dmax; + double dmin, dmax; getDisplayExtents(dmin, dmax); int nr = mapper->getPositionForValue(dmax - dmin); @@ -339,29 +339,29 @@ RangeMapper *mapper = getNewVerticalZoomRangeMapper(); if (!mapper) return; - float min, max; + double min, max; bool logarithmic; QString unit; getValueExtents(min, max, logarithmic, unit); - float dmin, dmax; + double dmin, dmax; getDisplayExtents(dmin, dmax); - float newdist = mapper->getValueForPosition(100 - step); + double newdist = mapper->getValueForPosition(100 - step); - float newmin, newmax; + double newmin, newmax; if (logarithmic) { // see SpectrogramLayer::setVerticalZoomStep - newmax = (newdist + sqrtf(newdist*newdist + 4*dmin*dmax)) / 2; + newmax = (newdist + sqrt(newdist*newdist + 4*dmin*dmax)) / 2; newmin = newmax - newdist; // cerr << "newmin = " << newmin << ", newmax = " << newmax << endl; } else { - float dmid = (dmax + dmin) / 2; + double dmid = (dmax + dmin) / 2; newmin = dmid - newdist / 2; newmax = dmid + newdist / 2; } @@ -388,7 +388,7 @@ RangeMapper *mapper; - float min, max; + double min, max; bool logarithmic; QString unit; getValueExtents(min, max, logarithmic, unit); @@ -409,7 +409,7 @@ { if (!m_model) return FlexiNoteModel::PointList(); - int frame = v->getFrameForX(x); + sv_frame_t frame = v->getFrameForX(x); FlexiNoteModel::PointList onPoints = m_model->getPoints(frame); @@ -452,7 +452,7 @@ { if (!m_model) return false; - int frame = v->getFrameForX(x); + sv_frame_t frame = v->getFrameForX(x); FlexiNoteModel::PointList onPoints = m_model->getPoints(frame); if (onPoints.empty()) return false; @@ -481,7 +481,7 @@ // GF: find the note that is closest to the cursor if (!m_model) return false; - int frame = v->getFrameForX(x); + sv_frame_t frame = v->getFrameForX(x); FlexiNoteModel::PointList onPoints = m_model->getPoints(frame); if (onPoints.empty()) return false; @@ -552,9 +552,9 @@ if (shouldConvertMIDIToHz()) { - int mnote = lrintf(note.value); - int cents = lrintf((note.value - mnote) * 100); - float freq = Pitch::getFrequencyForPitch(mnote, cents); + int mnote = int(lrint(note.value)); + int cents = int(lrint((note.value - double(mnote)) * 100)); + double freq = Pitch::getFrequencyForPitch(mnote, cents); pitchText = tr("%1 (%2, %3 Hz)") .arg(Pitch::getPitchLabel(mnote, cents)) .arg(mnote) @@ -593,7 +593,7 @@ } bool -FlexiNoteLayer::snapToFeatureFrame(View *v, int &frame, +FlexiNoteLayer::snapToFeatureFrame(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const { @@ -613,7 +613,7 @@ } points = m_model->getPoints(frame, frame); - int snapped = frame; + sv_frame_t snapped = frame; bool found = false; for (FlexiNoteModel::PointList::const_iterator i = points.begin(); @@ -673,7 +673,7 @@ } void -FlexiNoteLayer::getScaleExtents(View *v, float &min, float &max, bool &log) const +FlexiNoteLayer::getScaleExtents(View *v, double &min, double &max, bool &log) const { min = 0.0; max = 0.0; @@ -691,8 +691,8 @@ max = m_model->getValueMaximum(); if (shouldConvertMIDIToHz()) { - min = Pitch::getFrequencyForPitch(lrintf(min)); - max = Pitch::getFrequencyForPitch(lrintf(max + 1)); + min = Pitch::getFrequencyForPitch(int(lrint(min))); + max = Pitch::getFrequencyForPitch(int(lrint(max + 1))); } #ifdef DEBUG_NOTE_LAYER @@ -716,8 +716,8 @@ min = Pitch::getFrequencyForPitch(0); max = Pitch::getFrequencyForPitch(70); } else if (shouldConvertMIDIToHz()) { - min = Pitch::getFrequencyForPitch(lrintf(min)); - max = Pitch::getFrequencyForPitch(lrintf(max + 1)); + min = Pitch::getFrequencyForPitch(int(lrint(min))); + max = Pitch::getFrequencyForPitch(int(lrint(max + 1))); } if (m_verticalScale == LogScale || m_verticalScale == MIDIRangeScale) { @@ -730,9 +730,9 @@ } int -FlexiNoteLayer::getYForValue(View *v, float val) const +FlexiNoteLayer::getYForValue(View *v, double val) const { - float min = 0.0, max = 0.0; + double min = 0.0, max = 0.0; bool logarithmic = false; int h = v->height(); @@ -743,8 +743,8 @@ #endif if (shouldConvertMIDIToHz()) { - val = Pitch::getFrequencyForPitch(lrintf(val), - lrintf((val - lrintf(val)) * 100)); + val = Pitch::getFrequencyForPitch(int(lrint(val)), + int(lrint((val - floor(val)) * 100.0))); #ifdef DEBUG_NOTE_LAYER cerr << "shouldConvertMIDIToHz true, val now = " << val << endl; #endif @@ -764,19 +764,19 @@ return y; } -float +double FlexiNoteLayer::getValueForY(View *v, int y) const { - float min = 0.0, max = 0.0; + double min = 0.0, max = 0.0; bool logarithmic = false; int h = v->height(); getScaleExtents(v, min, max, logarithmic); - float val = min + (float(h - y) * float(max - min)) / h; + double val = min + (double(h - y) * double(max - min)) / h; if (logarithmic) { - val = powf(10.f, val); + val = pow(10.f, val); } if (shouldConvertMIDIToHz()) { @@ -798,13 +798,13 @@ { if (!m_model || !m_model->isOK()) return; - int sampleRate = m_model->getSampleRate(); + sv_samplerate_t sampleRate = m_model->getSampleRate(); if (!sampleRate) return; // Profiler profiler("FlexiNoteLayer::paint", true); int x1 = rect.right(); - int frame1 = v->getFrameForX(x1); + sv_frame_t frame1 = v->getFrameForX(x1); FlexiNoteModel::PointList points(m_model->getPoints(0, frame1)); if (points.empty()) return; @@ -817,8 +817,8 @@ // SVDEBUG << "FlexiNoteLayer::paint: resolution is " // << m_model->getResolution() << " frames" << endl; - float min = m_model->getValueMinimum(); - float max = m_model->getValueMaximum(); + double min = m_model->getValueMinimum(); + double max = m_model->getValueMaximum(); if (max == min) max = min + 1.0; QPoint localPos; @@ -923,7 +923,7 @@ if (!m_model || m_model->getPoints().empty()) return; QString unit; - float min, max; + double min, max; bool logarithmic; int w = getVerticalScaleWidth(v, false, paint); @@ -962,13 +962,13 @@ if (!m_model) return; - int frame = v->getFrameForX(e->x()); + sv_frame_t frame = v->getFrameForX(e->x()); if (frame < 0) frame = 0; frame = frame / m_model->getResolution() * m_model->getResolution(); - float value = getValueForY(v, e->y()); + double value = getValueForY(v, e->y()); - m_editingPoint = FlexiNoteModel::Point(frame, value, 0, 0.8, tr("New Point")); + m_editingPoint = FlexiNoteModel::Point(frame, float(value), 0, 0.8f, tr("New Point")); m_originalPoint = m_editingPoint; if (m_editingCommand) finish(m_editingCommand); @@ -986,14 +986,14 @@ if (!m_model || !m_editing) return; - int frame = v->getFrameForX(e->x()); + sv_frame_t frame = v->getFrameForX(e->x()); if (frame < 0) frame = 0; frame = frame / m_model->getResolution() * m_model->getResolution(); - float newValue = getValueForY(v, e->y()); + double newValue = getValueForY(v, e->y()); - int newFrame = m_editingPoint.frame; - int newDuration = frame - newFrame; + sv_frame_t newFrame = m_editingPoint.frame; + sv_frame_t newDuration = frame - newFrame; if (newDuration < 0) { newFrame = frame; newDuration = -newDuration; @@ -1003,7 +1003,7 @@ m_editingCommand->deletePoint(m_editingPoint); m_editingPoint.frame = newFrame; - m_editingPoint.value = newValue; + m_editingPoint.value = float(newValue); m_editingPoint.duration = newDuration; m_editingCommand->addPoint(m_editingPoint); } @@ -1085,8 +1085,8 @@ m_dragStartX = e->x(); m_dragStartY = e->y(); - int onset = m_originalPoint.frame; - int offset = m_originalPoint.frame + m_originalPoint.duration - 1; + sv_frame_t onset = m_originalPoint.frame; + sv_frame_t offset = m_originalPoint.frame + m_originalPoint.duration - 1; m_greatestLeftNeighbourFrame = -1; m_smallestRightNeighbourFrame = std::numeric_limits::max(); @@ -1122,11 +1122,11 @@ int newx = m_dragPointX + xdist; int newy = m_dragPointY + ydist; - int dragFrame = v->getFrameForX(newx); + sv_frame_t dragFrame = v->getFrameForX(newx); if (dragFrame < 0) dragFrame = 0; dragFrame = dragFrame / m_model->getResolution() * m_model->getResolution(); - float value = getValueForY(v, newy); + double value = getValueForY(v, newy); if (!m_editingCommand) { m_editingCommand = new FlexiNoteModel::EditCommand(m_model, @@ -1165,17 +1165,18 @@ dragFrame = m_smallestRightNeighbourFrame - m_originalPoint.duration; } m_editingPoint.frame = dragFrame; - m_editingPoint.value = value; + + m_editingPoint.value = float(value); // Re-analyse region within +/- 1 semitone of the dragged value float cents = 0; int midiPitch = Pitch::getPitchForFrequency(m_editingPoint.value, ¢s); - float lower = Pitch::getFrequencyForPitch(midiPitch - 1, cents); - float higher = Pitch::getFrequencyForPitch(midiPitch + 1, cents); + double lower = Pitch::getFrequencyForPitch(midiPitch - 1, cents); + double higher = Pitch::getFrequencyForPitch(midiPitch + 1, cents); emit reAnalyseRegion(m_editingPoint.frame, m_editingPoint.frame + m_editingPoint.duration, - lower, higher); + float(lower), float(higher)); break; } case SplitNote: // nothing @@ -1264,19 +1265,19 @@ return; } - int frame = v->getFrameForX(e->x()); + sv_frame_t frame = v->getFrameForX(e->x()); splitNotesAt(v, frame, e); } void -FlexiNoteLayer::splitNotesAt(View *v, int frame) +FlexiNoteLayer::splitNotesAt(View *v, sv_frame_t frame) { splitNotesAt(v, frame, 0); } void -FlexiNoteLayer::splitNotesAt(View *v, int frame, QMouseEvent *e) +FlexiNoteLayer::splitNotesAt(View *v, sv_frame_t frame, QMouseEvent *e) { FlexiNoteModel::PointList onPoints = m_model->getPoints(frame); if (onPoints.empty()) return; @@ -1321,15 +1322,15 @@ std::cerr << "addNote" << std::endl; if (!m_model) return; - int duration = 10000; + sv_frame_t duration = 10000; - int frame = v->getFrameForX(e->x()); - float value = getValueForY(v, e->y()); + sv_frame_t frame = v->getFrameForX(e->x()); + double value = getValueForY(v, e->y()); FlexiNoteModel::PointList noteList = m_model->getPoints(); if (m_intelligentActions) { - int smallestRightNeighbourFrame = 0; + sv_frame_t smallestRightNeighbourFrame = 0; for (FlexiNoteModel::PointList::const_iterator i = noteList.begin(); i != noteList.end(); ++i) { FlexiNote currentNote = *i; @@ -1346,7 +1347,7 @@ if (!m_intelligentActions || (m_model->getPoints(frame).empty() && duration > 0)) { - FlexiNote newNote(frame, value, duration, 100, "new note"); + FlexiNote newNote(frame, float(value), duration, 100.f, "new note"); FlexiNoteModel::EditCommand *command = new FlexiNoteModel::EditCommand (m_model, tr("Add Point")); command->addPoint(newNote); @@ -1476,7 +1477,7 @@ if (dataPoints.empty()) return false; - std::vector pitchValues; + std::vector pitchValues; for (SparseModel::PointList::const_iterator i = dataPoints.begin(); i != dataPoints.end(); ++i) { @@ -1489,7 +1490,7 @@ if (pitchValues.empty()) return false; sort(pitchValues.begin(), pitchValues.end()); - int size = pitchValues.size(); + int size = int(pitchValues.size()); double median; if (size % 2 == 0) { @@ -1500,7 +1501,7 @@ std::cerr << "updateNoteValueFromPitchCurve: corrected from " << note.value << " to median " << median << std::endl; - note.value = median; + note.value = float(median); return true; } @@ -1616,7 +1617,7 @@ } void -FlexiNoteLayer::moveSelection(Selection s, int newStartFrame) +FlexiNoteLayer::moveSelection(Selection s, sv_frame_t newStartFrame) { if (!m_model) return; @@ -1660,13 +1661,13 @@ if (s.contains(i->frame)) { - double targetStart = i->frame; - targetStart = newSize.getStartFrame() + - double(targetStart - s.getStartFrame()) * ratio; + double targetStart = double(i->frame); + targetStart = double(newSize.getStartFrame()) + + targetStart - double(s.getStartFrame()) * ratio; - double targetEnd = i->frame + i->duration; - targetEnd = newSize.getStartFrame() + - double(targetEnd - s.getStartFrame()) * ratio; + double targetEnd = double(i->frame + i->duration); + targetEnd = double(newSize.getStartFrame()) + + targetEnd - double(s.getStartFrame()) * ratio; FlexiNoteModel::Point newPoint(*i); newPoint.frame = lrint(targetStart); @@ -1745,7 +1746,7 @@ } bool -FlexiNoteLayer::paste(View *v, const Clipboard &from, int /*frameOffset */, bool /* interactive */) +FlexiNoteLayer::paste(View *v, const Clipboard &from, sv_frame_t /*frameOffset */, bool /* interactive */) { if (!m_model) return false; @@ -1777,7 +1778,7 @@ i != points.end(); ++i) { if (!i->haveFrame()) continue; - int frame = 0; + sv_frame_t frame = 0; if (!realign) { @@ -1802,7 +1803,7 @@ if (i->haveLevel()) newPoint.level = i->getLevel(); if (i->haveDuration()) newPoint.duration = i->getDuration(); else { - int nextFrame = frame; + sv_frame_t nextFrame = frame; Clipboard::PointList::const_iterator j = i; for (; j != points.end(); ++j) { if (!j->haveFrame()) continue; @@ -1826,17 +1827,17 @@ } void -FlexiNoteLayer::addNoteOn(int frame, int pitch, int velocity) +FlexiNoteLayer::addNoteOn(sv_frame_t frame, int pitch, int velocity) { - m_pendingNoteOns.insert(FlexiNote(frame, pitch, 0, float(velocity) / 127.0, "")); + m_pendingNoteOns.insert(FlexiNote(frame, float(pitch), 0, float(velocity / 127.0), "")); } void -FlexiNoteLayer::addNoteOff(int frame, int pitch) +FlexiNoteLayer::addNoteOff(sv_frame_t frame, int pitch) { for (FlexiNoteSet::iterator i = m_pendingNoteOns.begin(); i != m_pendingNoteOns.end(); ++i) { - if (lrintf((*i).value) == pitch) { + if (lrint((*i).value) == pitch) { FlexiNote note(*i); m_pendingNoteOns.erase(i); note.duration = frame - note.frame; @@ -1887,16 +1888,16 @@ if (ok) setVerticalScale(scale); // bool alsoOk; -// float min = attributes.value("scaleMinimum").toFloat(&ok); -// float max = attributes.value("scaleMaximum").toFloat(&alsoOk); +// double min = attributes.value("scaleMinimum").toDouble(&ok); +// double max = attributes.value("scaleMaximum").toDouble(&alsoOk); // if (ok && alsoOk && min != max) setDisplayExtents(min, max); } void FlexiNoteLayer::setVerticalRangeToNoteRange(View *v) { - float minf = std::numeric_limits::max(); - float maxf = 0; + double minf = std::numeric_limits::max(); + double maxf = 0; bool hasNotes = 0; for (FlexiNoteModel::PointList::const_iterator i = m_model->getPoints().begin(); i != m_model->getPoints().end(); ++i) { diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/FlexiNoteLayer.h --- a/layer/FlexiNoteLayer.h Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/FlexiNoteLayer.h Mon Mar 23 11:26:28 2015 +0000 @@ -45,7 +45,7 @@ virtual QString getFeatureDescription(View *v, QPoint &) const; - virtual bool snapToFeatureFrame(View *v, int &frame, + virtual bool snapToFeatureFrame(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const; @@ -70,16 +70,16 @@ virtual bool editOpen(View *v, QMouseEvent *); - virtual void moveSelection(Selection s, int newStartFrame); + virtual void moveSelection(Selection s, sv_frame_t newStartFrame); virtual void resizeSelection(Selection s, Selection newSize); virtual void deleteSelection(Selection s); virtual void deleteSelectionInclusive(Selection s); virtual void copy(View *v, Selection s, Clipboard &to); - virtual bool paste(View *v, const Clipboard &from, int frameOffset, + virtual bool paste(View *v, const Clipboard &from, sv_frame_t frameOffset, bool interactive); - void splitNotesAt(View *v, int frame); + void splitNotesAt(View *v, sv_frame_t frame); void snapSelectedNotesToPitchTrack(View *v, Selection s); void mergeNotes(View *v, Selection s, bool inclusive); @@ -122,11 +122,11 @@ virtual int getCompletion(View *) const { return m_model->getCompletion(); } - virtual bool getValueExtents(float &min, float &max, + virtual bool getValueExtents(double &min, double &max, bool &log, QString &unit) const; - virtual bool getDisplayExtents(float &min, float &max) const; - virtual bool setDisplayExtents(float min, float max); + virtual bool getDisplayExtents(double &min, double &max) const; + virtual bool setDisplayExtents(double min, double max); virtual int getVerticalZoomSteps(int &defaultStep) const; virtual int getCurrentVerticalZoomStep() const; @@ -138,13 +138,13 @@ * not be finally added to the layer until the corresponding * note-off. */ - void addNoteOn(int frame, int pitch, int velocity); + void addNoteOn(sv_frame_t frame, int pitch, int velocity); /** * Add a note-off. This will cause a note to appear, if and only * if there is a matching pending note-on. */ - void addNoteOff(int frame, int pitch); + void addNoteOff(sv_frame_t frame, int pitch); /** * Abandon all pending note-on events. @@ -159,16 +159,16 @@ void setVerticalRangeToNoteRange(View *v); /// VerticalScaleLayer methods - virtual int getYForValue(View *v, float value) const; - virtual float getValueForY(View *v, int y) const; + virtual int getYForValue(View *v, double value) const; + virtual double getValueForY(View *v, int y) const; virtual QString getScaleUnits() const; signals: - void reAnalyseRegion(int, int, float, float); + void reAnalyseRegion(sv_frame_t, sv_frame_t, float, float); void materialiseReAnalysis(); protected: - void getScaleExtents(View *, float &min, float &max, bool &log) const; + void getScaleExtents(View *, double &min, double &max, bool &log) const; bool shouldConvertMIDIToHz() const; virtual int getDefaultColourHint(bool dark, bool &impose); @@ -184,7 +184,7 @@ SparseTimeValueModel *getAssociatedPitchModel(View *v) const; bool updateNoteValueFromPitchCurve(View *v, FlexiNoteModel::Point ¬e) const; - void splitNotesAt(View *v, int frame, QMouseEvent *e); + void splitNotesAt(View *v, sv_frame_t frame, QMouseEvent *e); FlexiNoteModel *m_model; bool m_editing; @@ -195,8 +195,8 @@ int m_dragStartY; FlexiNoteModel::Point m_originalPoint; FlexiNoteModel::Point m_editingPoint; - int m_greatestLeftNeighbourFrame; - int m_smallestRightNeighbourFrame; + sv_frame_t m_greatestLeftNeighbourFrame; + sv_frame_t m_smallestRightNeighbourFrame; FlexiNoteModel::EditCommand *m_editingCommand; VerticalScale m_verticalScale; EditMode m_editMode; @@ -204,8 +204,8 @@ typedef std::set FlexiNoteSet; FlexiNoteSet m_pendingNoteOns; - mutable float m_scaleMinimum; - mutable float m_scaleMaximum; + mutable double m_scaleMinimum; + mutable double m_scaleMaximum; bool shouldAutoAlign() const; diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/ImageLayer.cpp --- a/layer/ImageLayer.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/ImageLayer.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -110,7 +110,7 @@ } bool -ImageLayer::getValueExtents(float &, float &, bool &, QString &) const +ImageLayer::getValueExtents(double &, double &, bool &, QString &) const { return false; } @@ -208,7 +208,7 @@ //!!! too much overlap with TimeValueLayer/TimeInstantLayer/TextLayer bool -ImageLayer::snapToFeatureFrame(View *v, int &frame, +ImageLayer::snapToFeatureFrame(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const { @@ -228,7 +228,7 @@ } points = m_model->getPoints(frame, frame); - int snapped = frame; + sv_frame_t snapped = frame; bool found = false; for (ImageModel::PointList::const_iterator i = points.begin(); @@ -284,7 +284,7 @@ { if (!m_model || !m_model->isOK()) return; - int sampleRate = m_model->getSampleRate(); + sv_samplerate_t sampleRate = m_model->getSampleRate(); if (!sampleRate) return; // Profiler profiler("ImageLayer::paint", true); @@ -292,8 +292,8 @@ // int x0 = rect.left(), x1 = rect.right(); int x0 = 0, x1 = v->width(); - int frame0 = v->getFrameForX(x0); - int frame1 = v->getFrameForX(x1); + sv_frame_t frame0 = v->getFrameForX(x0); + sv_frame_t frame1 = v->getFrameForX(x1); ImageModel::PointList points(m_model->getPoints(frame0, frame1)); if (points.empty()) return; @@ -563,7 +563,7 @@ return; } - int frame = v->getFrameForX(e->x()); + sv_frame_t frame = v->getFrameForX(e->x()); if (frame < 0) frame = 0; frame = frame / m_model->getResolution() * m_model->getResolution(); @@ -584,7 +584,7 @@ if (!m_model || !m_editing) return; - int frame = v->getFrameForX(e->x()); + sv_frame_t frame = v->getFrameForX(e->x()); if (frame < 0) frame = 0; frame = frame / m_model->getResolution() * m_model->getResolution(); @@ -619,7 +619,7 @@ } bool -ImageLayer::addImage(int frame, QString url) +ImageLayer::addImage(sv_frame_t frame, QString url) { QImage image(getLocalFilename(url)); if (image.isNull()) { @@ -664,8 +664,8 @@ { if (!m_model || !m_editing) return; - int frameDiff = v->getFrameForX(e->x()) - v->getFrameForX(m_editOrigin.x()); - int frame = m_originalPoint.frame + frameDiff; + sv_frame_t frameDiff = v->getFrameForX(e->x()) - v->getFrameForX(m_editOrigin.x()); + sv_frame_t frame = m_originalPoint.frame + frameDiff; if (frame < 0) frame = 0; frame = (frame / m_model->getResolution()) * m_model->getResolution(); @@ -723,7 +723,7 @@ } void -ImageLayer::moveSelection(Selection s, int newStartFrame) +ImageLayer::moveSelection(Selection s, sv_frame_t newStartFrame) { if (!m_model) return; @@ -767,9 +767,9 @@ if (s.contains(i->frame)) { - double target = i->frame; - target = newSize.getStartFrame() + - double(target - s.getStartFrame()) * ratio; + double target = double(i->frame); + target = double(newSize.getStartFrame()) + + target - double(s.getStartFrame()) * ratio; ImageModel::Point newPoint(*i); newPoint.frame = lrint(target); @@ -819,7 +819,7 @@ } bool -ImageLayer::paste(View *v, const Clipboard &from, int /* frameOffset */, bool /* interactive */) +ImageLayer::paste(View *v, const Clipboard &from, sv_frame_t /* frameOffset */, bool /* interactive */) { if (!m_model) return false; @@ -852,7 +852,7 @@ if (!i->haveFrame()) continue; - int frame = 0; + sv_frame_t frame = 0; if (!realign) { diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/ImageLayer.h --- a/layer/ImageLayer.h Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/ImageLayer.h Mon Mar 23 11:26:28 2015 +0000 @@ -42,7 +42,7 @@ virtual QString getFeatureDescription(View *v, QPoint &) const; - virtual bool snapToFeatureFrame(View *v, int &frame, + virtual bool snapToFeatureFrame(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const; @@ -54,12 +54,12 @@ virtual void editDrag(View *v, QMouseEvent *); virtual void editEnd(View *v, QMouseEvent *); - virtual void moveSelection(Selection s, int newStartFrame); + virtual void moveSelection(Selection s, sv_frame_t newStartFrame); virtual void resizeSelection(Selection s, Selection newSize); virtual void deleteSelection(Selection s); virtual void copy(View *v, Selection s, Clipboard &to); - virtual bool paste(View *v, const Clipboard &from, int frameOffset, + virtual bool paste(View *v, const Clipboard &from, sv_frame_t frameOffset, bool interactive); virtual bool editOpen(View *, QMouseEvent *); // on double-click @@ -86,7 +86,7 @@ virtual int getCompletion(View *) const { return m_model->getCompletion(); } - virtual bool getValueExtents(float &min, float &max, + virtual bool getValueExtents(double &min, double &max, bool &logarithmic, QString &unit) const; virtual void toXml(QTextStream &stream, QString indent = "", @@ -98,7 +98,7 @@ void setProperties(const QXmlAttributes &attributes); - virtual bool addImage(int frame, QString url); // using a command + virtual bool addImage(sv_frame_t frame, QString url); // using a command protected slots: void checkAddSources(); diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/ImageRegionFinder.cpp --- a/layer/ImageRegionFinder.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/ImageRegionFinder.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -107,9 +107,9 @@ return false; } - float ar = float(qRed(a) / 255.f); - float ag = float(qGreen(a) / 255.f); - float ab = float(qBlue(a) / 255.f); + float ar = float(qRed(a)) / 255.f; + float ag = float(qGreen(a)) / 255.f; + float ab = float(qBlue(a)) / 255.f; float amag = sqrtf(ar * ar + ag * ag + ab * ab); float thresh = amag / 2; diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/Layer.cpp --- a/layer/Layer.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/Layer.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -51,8 +51,8 @@ connect(model, SIGNAL(modelChanged()), this, SIGNAL(modelChanged())); - connect(model, SIGNAL(modelChangedWithin(int, int)), - this, SIGNAL(modelChangedWithin(int, int))); + connect(model, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), + this, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t))); connect(model, SIGNAL(completionChanged()), this, SIGNAL(modelCompletionChanged())); @@ -139,34 +139,34 @@ } bool -Layer::getXScaleValue(const View *v, int x, float &value, QString &unit) const +Layer::getXScaleValue(const View *v, int x, double &value, QString &unit) const { if (!hasTimeXAxis()) return false; const Model *m = getModel(); if (!m) return false; - value = float(v->getFrameForX(x)) / m->getSampleRate(); + value = double(v->getFrameForX(x)) / m->getSampleRate(); unit = "s"; return true; } bool Layer::getYScaleDifference(const View *v, int y0, int y1, - float &diff, QString &unit) const + double &diff, QString &unit) const { - float v0, v1; + double v0, v1; if (!getYScaleValue(v, y0, v0, unit) || !getYScaleValue(v, y1, v1, unit)) { diff = 0.f; return false; } - diff = fabsf(v1 - v0); + diff = fabs(v1 - v0); return true; } -int -Layer::alignToReference(View *v, int frame) const +sv_frame_t +Layer::alignToReference(View *v, sv_frame_t frame) const { const Model *m = getModel(); SVDEBUG << "Layer::alignToReference(" << frame << "): model = " << m << ", alignment reference = " << (m ? m->getAlignmentReference() : 0) << endl; @@ -177,8 +177,8 @@ } } -int -Layer::alignFromReference(View *v, int frame) const +sv_frame_t +Layer::alignFromReference(View *v, sv_frame_t frame) const { const Model *m = getModel(); SVDEBUG << "Layer::alignFromReference(" << frame << "): model = " << m << ", alignment reference = " << (m ? m->getAlignmentReference() : 0) << endl; @@ -250,12 +250,12 @@ // reference (i.e. having been copied from the reference // model). - int sourceFrame = i->getFrame(); - int referenceFrame = sourceFrame; + sv_frame_t sourceFrame = i->getFrame(); + sv_frame_t referenceFrame = sourceFrame; if (i->haveReferenceFrame()) { referenceFrame = i->getReferenceFrame(); } - int myMappedFrame = alignToReference(v, sourceFrame); + sv_frame_t myMappedFrame = alignToReference(v, sourceFrame); // cerr << "sourceFrame = " << sourceFrame << ", referenceFrame = " << referenceFrame << " (have = " << i->haveReferenceFrame() << "), myMappedFrame = " << myMappedFrame << endl; @@ -470,8 +470,8 @@ void Layer::updateMeasurePixrects(View *v) const { - int sf = v->getStartFrame(); - int ef = v->getEndFrame(); + sv_frame_t sf = v->getStartFrame(); + sv_frame_t ef = v->getEndFrame(); for (MeasureRectSet::const_iterator i = m_measureRects.begin(); i != m_measureRects.end(); ++i) { @@ -509,8 +509,8 @@ void Layer::updateMeasureRectYCoords(View *v, const MeasureRect &r) const { - int y0 = lrint(r.startY * v->height()); - int y1 = lrint(r.endY * v->height()); + int y0 = int(lrint(r.startY * v->height())); + int y1 = int(lrint(r.endY * v->height())); r.pixrect = QRect(r.pixrect.x(), y0, r.pixrect.width(), y1 - y0); } @@ -541,7 +541,7 @@ Layer::MeasureRectSet::const_iterator Layer::findFocusedMeasureRect(QPoint focusPoint) const { - float frDist = 0; + double frDist = 0; MeasureRectSet::const_iterator focusRectItr = m_measureRects.end(); for (MeasureRectSet::const_iterator i = m_measureRects.begin(); @@ -554,7 +554,7 @@ int xd = focusPoint.x() - cx; int yd = focusPoint.y() - cy; - float d = sqrt(float(xd * xd + yd * yd)); + double d = sqrt(double(xd * xd + yd * yd)); if (focusRectItr == m_measureRects.end() || d < frDist) { focusRectItr = i; diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/Layer.h --- a/layer/Layer.h Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/Layer.h Mon Mar 23 11:26:28 2015 +0000 @@ -150,7 +150,7 @@ return ""; } - virtual QString getLabelPreceding(int /* frame */) const { + virtual QString getLabelPreceding(sv_frame_t /* frame */) const { return ""; } @@ -180,8 +180,8 @@ * (and leave frame unmodified). If returning true, also return * the resolution of the model in this layer in sample frames. */ - virtual bool snapToFeatureFrame(View * /* v */, - int & /* frame */, + virtual bool snapToFeatureFrame(View * /* v */, + sv_frame_t & /* frame */, int &resolution, SnapType /* snap */) const { resolution = 1; @@ -204,8 +204,8 @@ * (and leave frame unmodified). If returning true, also return * the resolution of the model in this layer in sample frames. */ - virtual bool snapToSimilarFeature(View * /* v */, - int & /* source frame */, + virtual bool snapToSimilarFeature(View * /* v */, + sv_frame_t & /* source frame */, int &resolution, SnapType /* snap */) const { resolution = 1; @@ -254,7 +254,7 @@ */ virtual bool editOpen(View *, QMouseEvent *) { return false; } - virtual void moveSelection(Selection, int /* newStartFrame */) { } + virtual void moveSelection(Selection, sv_frame_t /* newStartFrame */) { } virtual void resizeSelection(Selection, Selection /* newSize */) { } virtual void deleteSelection(Selection) { } @@ -269,7 +269,7 @@ */ virtual bool paste(View *, const Clipboard & /* from */, - int /* frameOffset */, + sv_frame_t /* frameOffset */, bool /* interactive */) { return false; } // Text mode: @@ -423,7 +423,7 @@ * This function returns the "normal" extents for the layer, not * necessarily the extents actually in use in the display. */ - virtual bool getValueExtents(float &min, float &max, + virtual bool getValueExtents(double &min, double &max, bool &logarithmic, QString &unit) const = 0; /** @@ -434,8 +434,8 @@ * extent (using the normal layer extents or deferring to whatever * is in use for the same units elsewhere in the view). */ - virtual bool getDisplayExtents(float & /* min */, - float & /* max */) const { + virtual bool getDisplayExtents(double & /* min */, + double & /* max */) const { return false; } @@ -446,8 +446,8 @@ * return false for getDisplayExtents should also return false for * this function. */ - virtual bool setDisplayExtents(float /* min */, - float /* max */) { + virtual bool setDisplayExtents(double /* min */, + double /* max */) { return false; } @@ -458,14 +458,14 @@ * if the layer hasTimeXAxis(). */ virtual bool getXScaleValue(const View *v, int x, - float &value, QString &unit) const; + double &value, QString &unit) const; /** * Return the value and unit at the given y coordinate in the * given view. */ virtual bool getYScaleValue(const View *, int /* y */, - float &/* value */, QString &/* unit */) const { + double &/* value */, QString &/* unit */) const { return false; } @@ -476,7 +476,7 @@ * returns the difference, with the same unit. */ virtual bool getYScaleDifference(const View *v, int y0, int y1, - float &diff, QString &unit) const; + double &diff, QString &unit) const; /** * Get the number of vertical zoom steps available for this layer. @@ -525,7 +525,7 @@ void modelChanged(); void modelCompletionChanged(); void modelAlignmentCompletionChanged(); - void modelChangedWithin(int startFrame, int endFrame); + void modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame); void modelReplaced(); void layerParametersChanged(); @@ -538,16 +538,16 @@ protected: void connectSignals(const Model *); - virtual int alignToReference(View *v, int frame) const; - virtual int alignFromReference(View *v, int frame) const; + virtual sv_frame_t alignToReference(View *v, sv_frame_t frame) const; + virtual sv_frame_t alignFromReference(View *v, sv_frame_t frame) const; bool clipboardHasDifferentAlignment(View *v, const Clipboard &clip) const; struct MeasureRect { mutable QRect pixrect; bool haveFrames; - int startFrame; // only valid if haveFrames - int endFrame; // ditto + sv_frame_t startFrame; // only valid if haveFrames + sv_frame_t endFrame; // ditto double startY; double endY; diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/LinearColourScale.cpp --- a/layer/LinearColourScale.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/LinearColourScale.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -34,15 +34,15 @@ const ColourScaleLayer *layer, QPainter &paint, int /* x0 */, - float min, - float max) + double min, + double max) { int h = v->height(); int n = 10; - float val = min; - float inc = (max - val) / n; + double val = min; + double inc = (max - val) / n; const int buflen = 40; char buffer[buflen]; @@ -58,16 +58,16 @@ paint.save(); for (int y = 0; y < boxh; ++y) { - float val = ((boxh - y) * (max - min)) / boxh + min; + double val = ((boxh - y) * (max - min)) / boxh + min; paint.setPen(layer->getColourForValue(v, val)); paint.drawLine(boxx + 1, y + boxy + 1, boxx + boxw, y + boxy + 1); } paint.restore(); -// float round = 1.f; +// double round = 1.f; int dp = 0; if (inc > 0) { - int prec = trunc(log10f(inc)); + int prec = int(trunc(log10(inc))); prec -= 1; if (prec < 0) dp = -prec; // round = powf(10.f, prec); diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/LinearColourScale.h --- a/layer/LinearColourScale.h Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/LinearColourScale.h Mon Mar 23 11:26:28 2015 +0000 @@ -29,7 +29,7 @@ void paintVertical (View *v, const ColourScaleLayer *layer, QPainter &paint, int x0, - float minf, float maxf); + double minf, double maxf); }; #endif diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/LinearNumericalScale.cpp --- a/layer/LinearNumericalScale.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/LinearNumericalScale.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -34,26 +34,26 @@ const VerticalScaleLayer *layer, QPainter &paint, int x0, - float minf, - float maxf) + double minf, + double maxf) { int n = 10; - float val = minf; - float inc = (maxf - val) / n; + double val = minf; + double inc = (maxf - val) / n; const int buflen = 40; char buffer[buflen]; int w = getWidth(v, paint) + x0; - float round = 1.f; + double round = 1.0; int dp = 0; if (inc > 0) { - int prec = trunc(log10f(inc)); + int prec = int(trunc(log10(inc))); prec -= 1; if (prec < 0) dp = -prec; - round = powf(10.f, prec); + round = pow(10.0, prec); #ifdef DEBUG_TIME_VALUE_LAYER cerr << "inc = " << inc << ", round = " << round << ", dp = " << dp << endl; #endif @@ -66,13 +66,13 @@ int y, ty; bool drawText = true; - float dispval = val; + double dispval = val; if (i == n-1 && v->height() < paint.fontMetrics().height() * (n*2)) { if (layer->getScaleUnits() != "") drawText = false; } - dispval = lrintf(val / round) * round; + dispval = int(rint(val / round) * round); #ifdef DEBUG_TIME_VALUE_LAYER cerr << "val = " << val << ", dispval = " << dispval << endl; diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/LinearNumericalScale.h --- a/layer/LinearNumericalScale.h Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/LinearNumericalScale.h Mon Mar 23 11:26:28 2015 +0000 @@ -29,7 +29,7 @@ void paintVertical (View *v, const VerticalScaleLayer *layer, QPainter &paint, int x0, - float minf, float maxf); + double minf, double maxf); }; #endif diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/LogColourScale.cpp --- a/layer/LogColourScale.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/LogColourScale.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -36,15 +36,15 @@ const ColourScaleLayer *layer, QPainter &paint, int /* x0 */, - float minlog, - float maxlog) + double minlog, + double maxlog) { int h = v->height(); int n = 10; - float val = minlog; - float inc = (maxlog - val) / n; + double val = minlog; + double inc = (maxlog - val) / n; const int buflen = 40; char buffer[buflen]; @@ -60,7 +60,7 @@ paint.save(); for (int y = 0; y < boxh; ++y) { - float val = ((boxh - y) * (maxlog - minlog)) / boxh + minlog; + double val = ((boxh - y) * (maxlog - minlog)) / boxh + minlog; paint.setPen(layer->getColourForValue(v, LogRange::unmap(val))); paint.drawLine(boxx + 1, y + boxy + 1, boxx + boxw, y + boxy + 1); } @@ -68,7 +68,7 @@ int dp = 0; if (inc > 0) { - int prec = trunc(log10f(inc)); + int prec = int(trunc(log10(inc))); prec -= 1; if (prec < 0) dp = -prec; } @@ -83,7 +83,7 @@ paint.fontMetrics().ascent() + 2; double dv = LogRange::unmap(val); - int digits = trunc(log10f(dv)); + int digits = int(trunc(log10(dv))); int sf = dp + (digits > 0 ? digits : 0); if (sf < 2) sf = 2; snprintf(buffer, buflen, "%.*g", sf, dv); diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/LogColourScale.h --- a/layer/LogColourScale.h Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/LogColourScale.h Mon Mar 23 11:26:28 2015 +0000 @@ -29,7 +29,7 @@ void paintVertical (View *v, const ColourScaleLayer *layer, QPainter &paint, int x0, - float minf, float maxf); + double minf, double maxf); }; #endif diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/LogNumericalScale.cpp --- a/layer/LogNumericalScale.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/LogNumericalScale.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -38,18 +38,18 @@ const VerticalScaleLayer *layer, QPainter &paint, int x0, - float minlog, - float maxlog) + double minlog, + double maxlog) { int w = getWidth(v, paint) + x0; int n = 10; - float val = minlog; - float inc = (maxlog - val) / n; // even increments of log scale + double val = minlog; + double inc = (maxlog - val) / n; // even increments of log scale // smallest increment as displayed - float minDispInc = LogRange::unmap(minlog + inc) - LogRange::unmap(minlog); + double minDispInc = LogRange::unmap(minlog + inc) - LogRange::unmap(minlog); #ifdef DEBUG_TIME_VALUE_LAYER cerr << "min = " << minlog << ", max = " << maxlog << ", inc = " << inc << ", minDispInc = " << minDispInc << endl; @@ -58,13 +58,13 @@ const int buflen = 40; char buffer[buflen]; - float round = 1.f; + double round = 1.f; int dp = 0; if (minDispInc > 0) { - int prec = trunc(log10f(minDispInc)); + int prec = int(trunc(log10(minDispInc))); if (prec < 0) dp = -prec; - round = powf(10.f, prec); + round = pow(10.0, prec); if (dp > 4) dp = 4; #ifdef DEBUG_TIME_VALUE_LAYER cerr << "round = " << round << ", prec = " << prec << ", dp = " << dp << endl; @@ -83,7 +83,7 @@ if (layer->getScaleUnits() != "") drawText = false; } - float dispval = LogRange::unmap(val); + double dispval = LogRange::unmap(val); dispval = floor(dispval / round) * round; #ifdef DEBUG_TIME_VALUE_LAYER @@ -99,7 +99,7 @@ continue; } - int digits = trunc(log10f(dispval)); + int digits = int(trunc(log10(dispval))); int sf = dp + (digits > 0 ? digits : 0); if (sf < 4) sf = 4; #ifdef DEBUG_TIME_VALUE_LAYER diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/LogNumericalScale.h --- a/layer/LogNumericalScale.h Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/LogNumericalScale.h Mon Mar 23 11:26:28 2015 +0000 @@ -29,7 +29,7 @@ void paintVertical (View *v, const VerticalScaleLayer *layer, QPainter &paint, int x0, - float minlog, float maxlog); + double minlog, double maxlog); }; #endif diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/NoteLayer.cpp --- a/layer/NoteLayer.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/NoteLayer.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -209,7 +209,7 @@ } bool -NoteLayer::getValueExtents(float &min, float &max, +NoteLayer::getValueExtents(double &min, double &max, bool &logarithmic, QString &unit) const { if (!m_model) return false; @@ -218,8 +218,8 @@ if (shouldConvertMIDIToHz()) { unit = "Hz"; - min = Pitch::getFrequencyForPitch(lrintf(min)); - max = Pitch::getFrequencyForPitch(lrintf(max + 1)); + min = Pitch::getFrequencyForPitch(int(lrint(min))); + max = Pitch::getFrequencyForPitch(int(lrint(max + 1))); } else unit = getScaleUnits(); if (m_verticalScale == MIDIRangeScale || @@ -229,7 +229,7 @@ } bool -NoteLayer::getDisplayExtents(float &min, float &max) const +NoteLayer::getDisplayExtents(double &min, double &max) const { if (!m_model || shouldAutoAlign()) return false; @@ -248,8 +248,8 @@ } if (shouldConvertMIDIToHz()) { - min = Pitch::getFrequencyForPitch(lrintf(min)); - max = Pitch::getFrequencyForPitch(lrintf(max + 1)); + min = Pitch::getFrequencyForPitch(int(lrint(min))); + max = Pitch::getFrequencyForPitch(int(lrint(max + 1))); } #ifdef DEBUG_NOTE_LAYER @@ -260,7 +260,7 @@ } bool -NoteLayer::setDisplayExtents(float min, float max) +NoteLayer::setDisplayExtents(double min, double max) { if (!m_model) return false; @@ -302,7 +302,7 @@ RangeMapper *mapper = getNewVerticalZoomRangeMapper(); if (!mapper) return 0; - float dmin, dmax; + double dmin, dmax; getDisplayExtents(dmin, dmax); int nr = mapper->getPositionForValue(dmax - dmin); @@ -323,29 +323,29 @@ RangeMapper *mapper = getNewVerticalZoomRangeMapper(); if (!mapper) return; - float min, max; + double min, max; bool logarithmic; QString unit; getValueExtents(min, max, logarithmic, unit); - float dmin, dmax; + double dmin, dmax; getDisplayExtents(dmin, dmax); - float newdist = mapper->getValueForPosition(100 - step); + double newdist = mapper->getValueForPosition(100 - step); - float newmin, newmax; + double newmin, newmax; if (logarithmic) { // see SpectrogramLayer::setVerticalZoomStep - newmax = (newdist + sqrtf(newdist*newdist + 4*dmin*dmax)) / 2; + newmax = (newdist + sqrt(newdist*newdist + 4*dmin*dmax)) / 2; newmin = newmax - newdist; // cerr << "newmin = " << newmin << ", newmax = " << newmax << endl; } else { - float dmid = (dmax + dmin) / 2; + double dmid = (dmax + dmin) / 2; newmin = dmid - newdist / 2; newmax = dmid + newdist / 2; } @@ -372,7 +372,7 @@ RangeMapper *mapper; - float min, max; + double min, max; bool logarithmic; QString unit; getValueExtents(min, max, logarithmic, unit); @@ -393,7 +393,7 @@ { if (!m_model) return NoteModel::PointList(); - int frame = v->getFrameForX(x); + sv_frame_t frame = v->getFrameForX(x); NoteModel::PointList onPoints = m_model->getPoints(frame); @@ -436,7 +436,7 @@ { if (!m_model) return false; - int frame = v->getFrameForX(x); + sv_frame_t frame = v->getFrameForX(x); NoteModel::PointList onPoints = m_model->getPoints(frame); if (onPoints.empty()) return false; @@ -506,9 +506,9 @@ if (shouldConvertMIDIToHz()) { - int mnote = lrintf(note.value); - int cents = lrintf((note.value - mnote) * 100); - float freq = Pitch::getFrequencyForPitch(mnote, cents); + int mnote = int(lrint(note.value)); + int cents = int(lrint((note.value - float(mnote)) * 100)); + double freq = Pitch::getFrequencyForPitch(mnote, cents); pitchText = tr("%1 (%2, %3 Hz)") .arg(Pitch::getPitchLabel(mnote, cents)) .arg(mnote) @@ -547,7 +547,7 @@ } bool -NoteLayer::snapToFeatureFrame(View *v, int &frame, +NoteLayer::snapToFeatureFrame(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const { @@ -567,7 +567,7 @@ } points = m_model->getPoints(frame, frame); - int snapped = frame; + sv_frame_t snapped = frame; bool found = false; for (NoteModel::PointList::const_iterator i = points.begin(); @@ -619,7 +619,7 @@ } void -NoteLayer::getScaleExtents(View *v, float &min, float &max, bool &log) const +NoteLayer::getScaleExtents(View *v, double &min, double &max, bool &log) const { min = 0.0; max = 0.0; @@ -637,8 +637,8 @@ max = m_model->getValueMaximum(); if (shouldConvertMIDIToHz()) { - min = Pitch::getFrequencyForPitch(lrintf(min)); - max = Pitch::getFrequencyForPitch(lrintf(max + 1)); + min = Pitch::getFrequencyForPitch(int(lrint(min))); + max = Pitch::getFrequencyForPitch(int(lrint(max + 1))); } #ifdef DEBUG_NOTE_LAYER @@ -663,8 +663,8 @@ min = Pitch::getFrequencyForPitch(0); max = Pitch::getFrequencyForPitch(127); } else if (shouldConvertMIDIToHz()) { - min = Pitch::getFrequencyForPitch(lrintf(min)); - max = Pitch::getFrequencyForPitch(lrintf(max + 1)); + min = Pitch::getFrequencyForPitch(int(lrint(min))); + max = Pitch::getFrequencyForPitch(int(lrint(max + 1))); } if (m_verticalScale == LogScale || m_verticalScale == MIDIRangeScale) { @@ -677,9 +677,9 @@ } int -NoteLayer::getYForValue(View *v, float val) const +NoteLayer::getYForValue(View *v, double val) const { - float min = 0.0, max = 0.0; + double min = 0.0, max = 0.0; bool logarithmic = false; int h = v->height(); @@ -690,8 +690,8 @@ #endif if (shouldConvertMIDIToHz()) { - val = Pitch::getFrequencyForPitch(lrintf(val), - lrintf((val - lrintf(val)) * 100)); + val = Pitch::getFrequencyForPitch(int(lrint(val)), + int(lrint((val - rint(val)) * 100))); #ifdef DEBUG_NOTE_LAYER cerr << "shouldConvertMIDIToHz true, val now = " << val << endl; #endif @@ -711,19 +711,19 @@ return y; } -float +double NoteLayer::getValueForY(View *v, int y) const { - float min = 0.0, max = 0.0; + double min = 0.0, max = 0.0; bool logarithmic = false; int h = v->height(); getScaleExtents(v, min, max, logarithmic); - float val = min + (float(h - y) * float(max - min)) / h; + double val = min + (double(h - y) * double(max - min)) / h; if (logarithmic) { - val = powf(10.f, val); + val = pow(10.0, val); } if (shouldConvertMIDIToHz()) { @@ -745,14 +745,14 @@ { if (!m_model || !m_model->isOK()) return; - int sampleRate = m_model->getSampleRate(); + sv_samplerate_t sampleRate = m_model->getSampleRate(); if (!sampleRate) return; // Profiler profiler("NoteLayer::paint", true); int x0 = rect.left(), x1 = rect.right(); - int frame0 = v->getFrameForX(x0); - int frame1 = v->getFrameForX(x1); + sv_frame_t frame0 = v->getFrameForX(x0); + sv_frame_t frame1 = v->getFrameForX(x1); NoteModel::PointList points(m_model->getPoints(frame0, frame1)); if (points.empty()) return; @@ -765,8 +765,8 @@ // SVDEBUG << "NoteLayer::paint: resolution is " // << m_model->getResolution() << " frames" << endl; - float min = m_model->getValueMinimum(); - float max = m_model->getValueMaximum(); + double min = m_model->getValueMinimum(); + double max = m_model->getValueMaximum(); if (max == min) max = min + 1.0; QPoint localPos; @@ -849,7 +849,7 @@ if (!m_model || m_model->getPoints().empty()) return; QString unit; - float min, max; + double min, max; bool logarithmic; int w = getVerticalScaleWidth(v, false, paint); @@ -888,13 +888,13 @@ if (!m_model) return; - int frame = v->getFrameForX(e->x()); + sv_frame_t frame = v->getFrameForX(e->x()); if (frame < 0) frame = 0; frame = frame / m_model->getResolution() * m_model->getResolution(); - float value = getValueForY(v, e->y()); + double value = getValueForY(v, e->y()); - m_editingPoint = NoteModel::Point(frame, value, 0, 0.8, tr("New Point")); + m_editingPoint = NoteModel::Point(frame, float(value), 0, 0.8f, tr("New Point")); m_originalPoint = m_editingPoint; if (m_editingCommand) finish(m_editingCommand); @@ -912,14 +912,14 @@ if (!m_model || !m_editing) return; - int frame = v->getFrameForX(e->x()); + sv_frame_t frame = v->getFrameForX(e->x()); if (frame < 0) frame = 0; frame = frame / m_model->getResolution() * m_model->getResolution(); - float newValue = getValueForY(v, e->y()); + double newValue = getValueForY(v, e->y()); - int newFrame = m_editingPoint.frame; - int newDuration = frame - newFrame; + sv_frame_t newFrame = m_editingPoint.frame; + sv_frame_t newDuration = frame - newFrame; if (newDuration < 0) { newFrame = frame; newDuration = -newDuration; @@ -929,7 +929,7 @@ m_editingCommand->deletePoint(m_editingPoint); m_editingPoint.frame = newFrame; - m_editingPoint.value = newValue; + m_editingPoint.value = float(newValue); m_editingPoint.duration = newDuration; m_editingCommand->addPoint(m_editingPoint); } @@ -1019,11 +1019,11 @@ int newx = m_dragPointX + xdist; int newy = m_dragPointY + ydist; - int frame = v->getFrameForX(newx); + sv_frame_t frame = v->getFrameForX(newx); if (frame < 0) frame = 0; frame = frame / m_model->getResolution() * m_model->getResolution(); - float value = getValueForY(v, newy); + double value = getValueForY(v, newy); if (!m_editingCommand) { m_editingCommand = new NoteModel::EditCommand(m_model, @@ -1032,7 +1032,7 @@ m_editingCommand->deletePoint(m_editingPoint); m_editingPoint.frame = frame; - m_editingPoint.value = value; + m_editingPoint.value = float(value); m_editingCommand->addPoint(m_editingPoint); } @@ -1107,7 +1107,7 @@ } void -NoteLayer::moveSelection(Selection s, int newStartFrame) +NoteLayer::moveSelection(Selection s, sv_frame_t newStartFrame) { if (!m_model) return; @@ -1151,13 +1151,13 @@ if (s.contains(i->frame)) { - double targetStart = i->frame; - targetStart = newSize.getStartFrame() + - double(targetStart - s.getStartFrame()) * ratio; + double targetStart = double(i->frame); + targetStart = double(newSize.getStartFrame()) + + targetStart - double(s.getStartFrame()) * ratio; - double targetEnd = i->frame + i->duration; - targetEnd = newSize.getStartFrame() + - double(targetEnd - s.getStartFrame()) * ratio; + double targetEnd = double(i->frame + i->duration); + targetEnd = double(newSize.getStartFrame()) + + targetEnd - double(s.getStartFrame()) * ratio; NoteModel::Point newPoint(*i); newPoint.frame = lrint(targetStart); @@ -1211,7 +1211,7 @@ } bool -NoteLayer::paste(View *v, const Clipboard &from, int /* frameOffset */, bool /* interactive */) +NoteLayer::paste(View *v, const Clipboard &from, sv_frame_t /* frameOffset */, bool /* interactive */) { if (!m_model) return false; @@ -1243,7 +1243,7 @@ i != points.end(); ++i) { if (!i->haveFrame()) continue; - int frame = 0; + sv_frame_t frame = 0; if (!realign) { @@ -1268,7 +1268,7 @@ if (i->haveLevel()) newPoint.level = i->getLevel(); if (i->haveDuration()) newPoint.duration = i->getDuration(); else { - int nextFrame = frame; + sv_frame_t nextFrame = frame; Clipboard::PointList::const_iterator j = i; for (; j != points.end(); ++j) { if (!j->haveFrame()) continue; @@ -1292,13 +1292,13 @@ } void -NoteLayer::addNoteOn(int frame, int pitch, int velocity) +NoteLayer::addNoteOn(sv_frame_t frame, int pitch, int velocity) { - m_pendingNoteOns.insert(Note(frame, pitch, 0, float(velocity) / 127.0, "")); + m_pendingNoteOns.insert(Note(frame, float(pitch), 0, float(velocity) / 127.f, "")); } void -NoteLayer::addNoteOff(int frame, int pitch) +NoteLayer::addNoteOff(sv_frame_t frame, int pitch) { for (NoteSet::iterator i = m_pendingNoteOns.begin(); i != m_pendingNoteOns.end(); ++i) { diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/NoteLayer.h --- a/layer/NoteLayer.h Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/NoteLayer.h Mon Mar 23 11:26:28 2015 +0000 @@ -42,7 +42,7 @@ virtual QString getFeatureDescription(View *v, QPoint &) const; - virtual bool snapToFeatureFrame(View *v, int &frame, + virtual bool snapToFeatureFrame(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const; @@ -60,12 +60,12 @@ virtual bool editOpen(View *v, QMouseEvent *); - virtual void moveSelection(Selection s, int newStartFrame); + virtual void moveSelection(Selection s, sv_frame_t newStartFrame); virtual void resizeSelection(Selection s, Selection newSize); virtual void deleteSelection(Selection s); virtual void copy(View *v, Selection s, Clipboard &to); - virtual bool paste(View *v, const Clipboard &from, int frameOffset, + virtual bool paste(View *v, const Clipboard &from, sv_frame_t frameOffset, bool interactive); virtual const Model *getModel() const { return m_model; } @@ -97,11 +97,11 @@ virtual int getCompletion(View *) const { return m_model->getCompletion(); } - virtual bool getValueExtents(float &min, float &max, + virtual bool getValueExtents(double &min, double &max, bool &log, QString &unit) const; - virtual bool getDisplayExtents(float &min, float &max) const; - virtual bool setDisplayExtents(float min, float max); + virtual bool getDisplayExtents(double &min, double &max) const; + virtual bool setDisplayExtents(double min, double max); virtual int getVerticalZoomSteps(int &defaultStep) const; virtual int getCurrentVerticalZoomStep() const; @@ -113,13 +113,13 @@ * not be finally added to the layer until the corresponding * note-off. */ - void addNoteOn(int frame, int pitch, int velocity); + void addNoteOn(sv_frame_t frame, int pitch, int velocity); /** * Add a note-off. This will cause a note to appear, if and only * if there is a matching pending note-on. */ - void addNoteOff(int frame, int pitch); + void addNoteOff(sv_frame_t frame, int pitch); /** * Abandon all pending note-on events. @@ -132,12 +132,12 @@ void setProperties(const QXmlAttributes &attributes); /// VerticalScaleLayer methods - virtual int getYForValue(View *v, float value) const; - virtual float getValueForY(View *v, int y) const; + virtual int getYForValue(View *v, double value) const; + virtual double getValueForY(View *v, int y) const; virtual QString getScaleUnits() const; protected: - void getScaleExtents(View *, float &min, float &max, bool &log) const; + void getScaleExtents(View *, double &min, double &max, bool &log) const; bool shouldConvertMIDIToHz() const; virtual int getDefaultColourHint(bool dark, bool &impose); @@ -160,8 +160,8 @@ typedef std::set NoteSet; NoteSet m_pendingNoteOns; - mutable float m_scaleMinimum; - mutable float m_scaleMaximum; + mutable double m_scaleMinimum; + mutable double m_scaleMaximum; bool shouldAutoAlign() const; diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/PaintAssistant.cpp --- a/layer/PaintAssistant.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/PaintAssistant.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -25,11 +25,11 @@ void PaintAssistant::paintVerticalLevelScale(QPainter &paint, QRect rect, - float minVal, float maxVal, + double minVal, double maxVal, Scale scale, int &mult, std::vector *vy) { - static float meterdbs[] = { -40, -30, -20, -15, -10, + static double meterdbs[] = { -40, -30, -20, -15, -10, -5, -3, -2, -1, -0.5, 0 }; int h = rect.height(), w = rect.width(); @@ -41,7 +41,7 @@ int n = 10; if (vy) vy->clear(); - float step = 0; + double step = 0; mult = 1; if (scale == LinearScale) { step = (maxVal - minVal) / n; @@ -53,8 +53,8 @@ if (round) { mult /= 10; // cerr << "\n\nstep goes from " << step; - step = float(round) / mult; - n = lrintf((maxVal - minVal) / step); + step = double(round) / mult; + n = int(lrint((maxVal - minVal) / step)); if (mult > 1) { mult /= 10; } @@ -64,7 +64,7 @@ for (int i = 0; i <= n; ++i) { - float val = 0.0, nval = 0.0; + double val = 0.0, nval = 0.0; QString text = ""; switch (scale) { @@ -166,20 +166,20 @@ } static int -dBscale(float sample, int m, float maxVal, float minVal) +dBscale(double sample, int m, double maxVal, double minVal) { if (sample < 0.0) return dBscale(-sample, m, maxVal, minVal); - float dB = AudioLevel::multiplier_to_dB(sample); - float mindB = AudioLevel::multiplier_to_dB(minVal); - float maxdB = AudioLevel::multiplier_to_dB(maxVal); + double dB = AudioLevel::multiplier_to_dB(sample); + double mindB = AudioLevel::multiplier_to_dB(minVal); + double maxdB = AudioLevel::multiplier_to_dB(maxVal); if (dB < mindB) return 0; if (dB > 0.0) return m; return int(((dB - mindB) * m) / (maxdB - mindB) + 0.1); } int -PaintAssistant::getYForValue(Scale scale, float value, - float minVal, float maxVal, +PaintAssistant::getYForValue(Scale scale, double value, + double minVal, double maxVal, int minY, int height) { int vy = 0; diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/PaintAssistant.h --- a/layer/PaintAssistant.h Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/PaintAssistant.h Mon Mar 23 11:26:28 2015 +0000 @@ -27,12 +27,12 @@ enum Scale { LinearScale, MeterScale, dBScale }; static void paintVerticalLevelScale(QPainter &p, QRect rect, - float minVal, float maxVal, + double minVal, double maxVal, Scale scale, int &multRtn, std::vector *markCoordRtns = 0); - static int getYForValue(Scale scale, float value, - float minVal, float maxVal, + static int getYForValue(Scale scale, double value, + double minVal, double maxVal, int minY, int height); }; diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/PianoScale.cpp --- a/layer/PianoScale.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/PianoScale.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -27,8 +27,8 @@ PianoScale::paintPianoVertical(View *v, QPainter &paint, QRect r, - float minf, - float maxf) + double minf, + double maxf) { int x0 = r.x(), y0 = r.y(), x1 = r.x() + r.width(), y1 = r.y() + r.height(); @@ -39,8 +39,8 @@ for (int i = 0; i < 128; ++i) { - float f = Pitch::getFrequencyForPitch(i); - int y = lrintf(v->getYForFrequency(f, minf, maxf, true)); + double f = Pitch::getFrequencyForPitch(i); + int y = int(lrint(v->getYForFrequency(f, minf, maxf, true))); if (y < y0 - 2) break; if (y > y1 + 2) { diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/PianoScale.h --- a/layer/PianoScale.h Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/PianoScale.h Mon Mar 23 11:26:28 2015 +0000 @@ -25,7 +25,7 @@ { public: void paintPianoVertical - (View *v, QPainter &paint, QRect rect, float minf, float maxf); + (View *v, QPainter &paint, QRect rect, double minf, double maxf); }; #endif diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/RegionLayer.cpp --- a/layer/RegionLayer.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/RegionLayer.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -275,7 +275,7 @@ } bool -RegionLayer::getValueExtents(float &min, float &max, +RegionLayer::getValueExtents(double &min, double &max, bool &logarithmic, QString &unit) const { if (!m_model) return false; @@ -289,7 +289,7 @@ } bool -RegionLayer::getDisplayExtents(float &min, float &max) const +RegionLayer::getDisplayExtents(double &min, double &max) const { if (!m_model || m_verticalScale == AutoAlignScale || @@ -371,7 +371,7 @@ } QString -RegionLayer::getLabelPreceding(int frame) const +RegionLayer::getLabelPreceding(sv_frame_t frame) const { if (!m_model) return ""; RegionModel::PointList points = m_model->getPreviousPoints(frame); @@ -453,7 +453,7 @@ } bool -RegionLayer::snapToFeatureFrame(View *v, int &frame, +RegionLayer::snapToFeatureFrame(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const { @@ -473,7 +473,7 @@ } points = m_model->getPoints(frame, frame); - int snapped = frame; + sv_frame_t snapped = frame; bool found = false; for (RegionModel::PointList::const_iterator i = points.begin(); @@ -536,7 +536,7 @@ } bool -RegionLayer::snapToSimilarFeature(View *v, int &frame, +RegionLayer::snapToSimilarFeature(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const { @@ -551,8 +551,8 @@ RegionModel::PointList::const_iterator i; - int matchframe = frame; - float matchvalue = 0.f; + sv_frame_t matchframe = frame; + double matchvalue = 0.f; for (i = close.begin(); i != close.end(); ++i) { if (i->frame > frame) break; @@ -560,10 +560,10 @@ matchframe = i->frame; } - int snapped = frame; + sv_frame_t snapped = frame; bool found = false; bool distant = false; - float epsilon = 0.0001; + double epsilon = 0.0001; i = close.begin(); @@ -588,7 +588,7 @@ if (snap == SnapRight) { if (i->frame > matchframe && - fabsf(i->value - matchvalue) < epsilon) { + fabs(i->value - matchvalue) < epsilon) { snapped = i->frame; found = true; break; @@ -597,7 +597,7 @@ } else if (snap == SnapLeft) { if (i->frame < matchframe) { - if (fabsf(i->value - matchvalue) < epsilon) { + if (fabs(i->value - matchvalue) < epsilon) { snapped = i->frame; found = true; // don't break, as the next may be better } @@ -624,7 +624,7 @@ } void -RegionLayer::getScaleExtents(View *v, float &min, float &max, bool &log) const +RegionLayer::getScaleExtents(View *v, double &min, double &max, bool &log) const { min = 0.0; max = 0.0; @@ -679,28 +679,28 @@ RegionLayer::spacingIndexToY(View *v, int i) const { int h = v->height(); - int n = m_spacingMap.size(); + int n = int(m_spacingMap.size()); // this maps from i (spacing of the value from the spacing // map) and n (number of region types) to y int y = h - (((h * i) / n) + (h / (2 * n))); return y; } -float +double RegionLayer::yToSpacingIndex(View *v, int y) const { - // we return an inexact result here (float rather than int) + // we return an inexact result here (double rather than int) int h = v->height(); - int n = m_spacingMap.size(); + int n = int(m_spacingMap.size()); // from y = h - ((h * i) / n) + (h / (2 * n)) as above (vh taking place of i) - float vh = float(2*h*n - h - 2*n*y) / float(2*h); + double vh = double(2*h*n - h - 2*n*y) / double(2*h); return vh; } int -RegionLayer::getYForValue(View *v, float val) const +RegionLayer::getYForValue(View *v, double val) const { - float min = 0.0, max = 0.0; + double min = 0.0, max = 0.0; bool logarithmic = false; int h = v->height(); @@ -732,16 +732,16 @@ } } -float +double RegionLayer::getValueForY(View *v, int y) const { return getValueForY(v, y, -1); } -float +double RegionLayer::getValueForY(View *v, int y, int avoid) const { - float min = 0.0, max = 0.0; + double min = 0.0, max = 0.0; bool logarithmic = false; int h = v->height(); @@ -757,14 +757,14 @@ // one of the m/n divisions in the y scale, we should snap to // the value of the mth region. - float vh = yToSpacingIndex(v, y); + double vh = yToSpacingIndex(v, y); // spacings in the map are integral, so find the closest one, // map it back to its y coordinate, and see how far we are // from it - int n = m_spacingMap.size(); - int ivh = lrintf(vh); + int n = int(m_spacingMap.size()); + int ivh = int(lrint(vh)); if (ivh < 0) ivh = 0; if (ivh > n-1) ivh = n-1; int iy = spacingIndexToY(v, ivh); @@ -783,7 +783,7 @@ // cerr << "nearest existing value = " << i->first << " at " << iy << endl; - float val = 0; + double val = 0; // cerr << "note: avoid = " << avoid << ", i->second = " << i->second << endl; @@ -825,10 +825,10 @@ getScaleExtents(v, min, max, logarithmic); - float val = min + (float(h - y) * float(max - min)) / h; + double val = min + (double(h - y) * double(max - min)) / h; if (logarithmic) { - val = powf(10.f, val); + val = pow(10.0, val); } return val; @@ -836,9 +836,9 @@ } QColor -RegionLayer::getColourForValue(View *v, float val) const +RegionLayer::getColourForValue(View *v, double val) const { - float min, max; + double min, max; bool log; getScaleExtents(v, min, max, log); @@ -870,14 +870,14 @@ { if (!m_model || !m_model->isOK()) return; - int sampleRate = m_model->getSampleRate(); + sv_samplerate_t sampleRate = m_model->getSampleRate(); if (!sampleRate) return; // Profiler profiler("RegionLayer::paint", true); int x0 = rect.left() - 40, x1 = rect.right(); - long frame0 = v->getFrameForX(x0); - long frame1 = v->getFrameForX(x1); + sv_frame_t frame0 = v->getFrameForX(x0); + sv_frame_t frame1 = v->getFrameForX(x1); RegionModel::PointList points(m_model->getPoints(frame0, frame1)); if (points.empty()) return; @@ -890,8 +890,8 @@ // SVDEBUG << "RegionLayer::paint: resolution is " // << m_model->getResolution() << " frames" << endl; - float min = m_model->getValueMinimum(); - float max = m_model->getValueMaximum(); + double min = m_model->getValueMinimum(); + double max = m_model->getValueMaximum(); if (max == min) max = min + 1.0; QPoint localPos; @@ -1083,7 +1083,7 @@ if (!m_model || m_model->getPoints().empty()) return; QString unit; - float min, max; + double min, max; bool logarithmic; int w = getVerticalScaleWidth(v, false, paint); @@ -1129,9 +1129,9 @@ if (frame < 0) frame = 0; frame = frame / m_model->getResolution() * m_model->getResolution(); - float value = getValueForY(v, e->y()); + double value = getValueForY(v, e->y()); - m_editingPoint = RegionModel::Point(frame, value, 0, ""); + m_editingPoint = RegionModel::Point(frame, float(value), 0, ""); m_originalPoint = m_editingPoint; if (m_editingCommand) finish(m_editingCommand); @@ -1149,15 +1149,15 @@ { if (!m_model || !m_editing) return; - long frame = v->getFrameForX(e->x()); + sv_frame_t frame = v->getFrameForX(e->x()); if (frame < 0) frame = 0; frame = frame / m_model->getResolution() * m_model->getResolution(); - float newValue = m_editingPoint.value; + double newValue = m_editingPoint.value; if (m_verticalScale != EqualSpaced) newValue = getValueForY(v, e->y()); - long newFrame = m_editingPoint.frame; - long newDuration = frame - newFrame; + sv_frame_t newFrame = m_editingPoint.frame; + sv_frame_t newDuration = frame - newFrame; if (newDuration < 0) { newFrame = frame; newDuration = -newDuration; @@ -1167,7 +1167,7 @@ m_editingCommand->deletePoint(m_editingPoint); m_editingPoint.frame = newFrame; - m_editingPoint.value = newValue; + m_editingPoint.value = float(newValue); m_editingPoint.duration = newDuration; m_editingCommand->addPoint(m_editingPoint); @@ -1274,7 +1274,7 @@ // ... unless there are other points with the same value if (m_distributionMap[m_editingPoint.value] > 1) avoid = -1; - float value = getValueForY(v, newy, avoid); + double value = getValueForY(v, newy, avoid); if (!m_editingCommand) { m_editingCommand = new RegionModel::EditCommand(m_model, @@ -1283,7 +1283,7 @@ m_editingCommand->deletePoint(m_editingPoint); m_editingPoint.frame = frame; - m_editingPoint.value = value; + m_editingPoint.value = float(value); m_editingCommand->addPoint(m_editingPoint); recalcSpacing(); } @@ -1358,7 +1358,7 @@ } void -RegionLayer::moveSelection(Selection s, int newStartFrame) +RegionLayer::moveSelection(Selection s, sv_frame_t newStartFrame) { if (!m_model) return; @@ -1403,13 +1403,13 @@ if (s.contains(i->frame)) { - double targetStart = i->frame; - targetStart = newSize.getStartFrame() + - double(targetStart - s.getStartFrame()) * ratio; + double targetStart = double(i->frame); + targetStart = double(newSize.getStartFrame()) + + targetStart - double(s.getStartFrame()) * ratio; - double targetEnd = i->frame + i->duration; - targetEnd = newSize.getStartFrame() + - double(targetEnd - s.getStartFrame()) * ratio; + double targetEnd = double(i->frame + i->duration); + targetEnd = double(newSize.getStartFrame()) + + targetEnd - double(s.getStartFrame()) * ratio; RegionModel::Point newPoint(*i); newPoint.frame = lrint(targetStart); @@ -1465,7 +1465,7 @@ } bool -RegionLayer::paste(View *v, const Clipboard &from, int /* frameOffset */, bool /* interactive */) +RegionLayer::paste(View *v, const Clipboard &from, sv_frame_t /* frameOffset */, bool /* interactive */) { if (!m_model) return false; @@ -1497,7 +1497,7 @@ i != points.end(); ++i) { if (!i->haveFrame()) continue; - int frame = 0; + sv_frame_t frame = 0; if (!realign) { @@ -1521,7 +1521,7 @@ m_model->getValueMaximum()) / 2; if (i->haveDuration()) newPoint.duration = i->getDuration(); else { - int nextFrame = frame; + sv_frame_t nextFrame = frame; Clipboard::PointList::const_iterator j = i; for (; j != points.end(); ++j) { if (!j->haveFrame()) continue; diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/RegionLayer.h --- a/layer/RegionLayer.h Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/RegionLayer.h Mon Mar 23 11:26:28 2015 +0000 @@ -45,12 +45,12 @@ virtual void paintVerticalScale(View *v, bool, QPainter &paint, QRect rect) const; virtual QString getFeatureDescription(View *v, QPoint &) const; - virtual QString getLabelPreceding(int) const; + virtual QString getLabelPreceding(sv_frame_t) const; - virtual bool snapToFeatureFrame(View *v, int &frame, + virtual bool snapToFeatureFrame(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const; - virtual bool snapToSimilarFeature(View *v, int &frame, + virtual bool snapToSimilarFeature(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const; @@ -68,12 +68,12 @@ virtual bool editOpen(View *v, QMouseEvent *); - virtual void moveSelection(Selection s, int newStartFrame); + virtual void moveSelection(Selection s, sv_frame_t newStartFrame); virtual void resizeSelection(Selection s, Selection newSize); virtual void deleteSelection(Selection s); virtual void copy(View *v, Selection s, Clipboard &to); - virtual bool paste(View *v, const Clipboard &from, int frameOffset, + virtual bool paste(View *v, const Clipboard &from, sv_frame_t frameOffset, bool interactive); virtual const Model *getModel() const { return m_model; } @@ -116,10 +116,10 @@ virtual int getCompletion(View *) const { return m_model->getCompletion(); } - virtual bool getValueExtents(float &min, float &max, + virtual bool getValueExtents(double &min, double &max, bool &log, QString &unit) const; - virtual bool getDisplayExtents(float &min, float &max) const; + virtual bool getDisplayExtents(double &min, double &max) const; virtual void toXml(QTextStream &stream, QString indent = "", QString extraAttributes = "") const; @@ -127,17 +127,17 @@ void setProperties(const QXmlAttributes &attributes); /// VerticalScaleLayer and ColourScaleLayer methods - int getYForValue(View *v, float value) const; - float getValueForY(View *v, int y) const; + int getYForValue(View *v, double value) const; + double getValueForY(View *v, int y) const; virtual QString getScaleUnits() const; - QColor getColourForValue(View *v, float value) const; + QColor getColourForValue(View *v, double value) const; protected slots: void recalcSpacing(); protected: - float getValueForY(View *v, int y, int avoid) const; - void getScaleExtents(View *, float &min, float &max, bool &log) const; + double getValueForY(View *v, int y, int avoid) const; + void getScaleExtents(View *, double &min, double &max, bool &log) const; virtual int getDefaultColourHint(bool dark, bool &impose); @@ -158,7 +158,7 @@ int m_colourMap; PlotStyle m_plotStyle; - typedef std::map SpacingMap; + typedef std::map SpacingMap; // region value -> ordering SpacingMap m_spacingMap; @@ -167,7 +167,7 @@ SpacingMap m_distributionMap; int spacingIndexToY(View *v, int i) const; - float yToSpacingIndex(View *v, int y) const; + double yToSpacingIndex(View *v, int y) const; void finish(RegionModel::EditCommand *command) { Command *c = command->finish(); diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/SliceLayer.cpp --- a/layer/SliceLayer.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/SliceLayer.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -119,21 +119,21 @@ if (minbin < 0) minbin = 0; if (maxbin < 0) maxbin = 0; - int sampleRate = m_sliceableModel->getSampleRate(); + sv_samplerate_t sampleRate = m_sliceableModel->getSampleRate(); - int f0 = m_currentf0; - int f1 = m_currentf1; + sv_frame_t f0 = m_currentf0; + sv_frame_t f1 = m_currentf1; RealTime rt0 = RealTime::frame2RealTime(f0, sampleRate); RealTime rt1 = RealTime::frame2RealTime(f1, sampleRate); - range = f1 - f0 + 1; + range = int(f1 - f0 + 1); QString rtrangestr = QString("%1 s").arg((rt1 - rt0).toText().c_str()); if (includeBinDescription) { - float minvalue = 0.f; + float minvalue = 0.0; if (minbin < int(m_values.size())) minvalue = m_values[minbin]; float maxvalue = minvalue; @@ -179,23 +179,23 @@ } } -float -SliceLayer::getXForBin(int bin, int count, float w) const +double +SliceLayer::getXForBin(int bin, int count, double w) const { - float x = 0; + double x = 0; switch (m_binScale) { case LinearBins: - x = (float(w) * bin) / count; + x = (w * bin) / count; break; case LogBins: - x = (float(w) * log10f(bin + 1)) / log10f(count + 1); + x = (w * log10(bin + 1)) / log10(count + 1); break; case InvertedLogBins: - x = w - (float(w) * log10f(count - bin - 1)) / log10f(count); + x = w - (w * log10(count - bin - 1)) / log10(count); break; } @@ -203,7 +203,7 @@ } int -SliceLayer::getBinForX(float x, int count, float w) const +SliceLayer::getBinForX(double x, int count, double w) const { int bin = 0; @@ -214,21 +214,21 @@ break; case LogBins: - bin = int(powf(10.f, (x * log10f(count + 1)) / w) - 1 + 0.0001); + bin = int(pow(10.0, (x * log10(count + 1)) / w) - 1 + 0.0001); break; case InvertedLogBins: - bin = count + 1 - int(powf(10.f, (log10f(count) * (w - x)) / float(w)) + 0.0001); + bin = count + 1 - int(pow(10.0, (log10(count) * (w - x)) / double(w)) + 0.0001); break; } return bin; } -float -SliceLayer::getYForValue(float value, const View *v, float &norm) const +double +SliceLayer::getYForValue(double value, const View *v, double &norm) const { - norm = 0.f; + norm = 0.0; if (m_yorigins.find(v) == m_yorigins.end()) return 0; @@ -236,9 +236,9 @@ int yorigin = m_yorigins[v]; int h = m_heights[v]; - float thresh = getThresholdDb(); + double thresh = getThresholdDb(); - float y = 0.f; + double y = 0.0; if (h <= 0) return y; @@ -246,45 +246,45 @@ case dBScale: { - float db = thresh; - if (value > 0.f) db = 10.f * log10f(fabsf(value)); + double db = thresh; + if (value > 0.0) db = 10.0 * log10(fabs(value)); if (db < thresh) db = thresh; norm = (db - thresh) / -thresh; - y = yorigin - (float(h) * norm); + y = yorigin - (double(h) * norm); break; } case MeterScale: y = AudioLevel::multiplier_to_preview(value, h); - norm = float(y) / float(h); + norm = double(y) / double(h); y = yorigin - y; break; case AbsoluteScale: - value = fabsf(value); + value = fabs(value); // and fall through case LinearScale: default: norm = (value - m_threshold); if (norm < 0) norm = 0; - y = yorigin - (float(h) * norm); + y = yorigin - (double(h) * norm); break; } return y; } -float -SliceLayer::getValueForY(float y, const View *v) const +double +SliceLayer::getValueForY(double y, const View *v) const { - float value = 0.f; + double value = 0.0; if (m_yorigins.find(v) == m_yorigins.end()) return value; int yorigin = m_yorigins[v]; int h = m_heights[v]; - float thresh = getThresholdDb(); + double thresh = getThresholdDb(); if (h <= 0) return value; @@ -294,13 +294,13 @@ case dBScale: { - float db = ((y / h) * -thresh) + thresh; - value = powf(10.f, db/10.f); + double db = ((y / h) * -thresh) + thresh; + value = pow(10.0, db/10.0); break; } case MeterScale: - value = AudioLevel::preview_to_multiplier(lrintf(y), h); + value = AudioLevel::preview_to_multiplier(int(lrint(y)), h); break; case LinearScale: @@ -354,21 +354,21 @@ m_values.clear(); for (int bin = 0; bin < mh; ++bin) { - m_values.push_back(0.f); + m_values.push_back(0.0); } - int f0 = v->getCentreFrame(); + sv_frame_t f0 = v->getCentreFrame(); int f0x = v->getXForFrame(f0); f0 = v->getFrameForX(f0x); - int f1 = v->getFrameForX(f0x + 1); + sv_frame_t f1 = v->getFrameForX(f0x + 1); if (f1 > f0) --f1; // cerr << "centre frame " << v->getCentreFrame() << ", x " << f0x << ", f0 " << f0 << ", f1 " << f1 << endl; int res = m_sliceableModel->getResolution(); - int col0 = f0 / res; + int col0 = int(f0 / res); int col1 = col0; - if (m_samplingMode != NearestSample) col1 = f1 / res; + if (m_samplingMode != NearestSample) col1 = int(f1 / res); f0 = col0 * res; f1 = (col1 + 1) * res - 1; @@ -379,7 +379,7 @@ BiasCurve curve; getBiasCurve(curve); - int cs = curve.size(); + int cs = int(curve.size()); for (int col = col0; col <= col1; ++col) { for (int bin = 0; bin < mh; ++bin) { @@ -394,31 +394,31 @@ ++divisor; } - float max = 0.f; + float max = 0.0; for (int bin = 0; bin < mh; ++bin) { if (m_samplingMode == SampleMean && divisor > 0) { - m_values[bin] /= divisor; + m_values[bin] /= float(divisor); } if (m_values[bin] > max) max = m_values[bin]; } - if (max != 0.f && m_normalize) { + if (max != 0.0 && m_normalize) { for (int bin = 0; bin < mh; ++bin) { m_values[bin] /= max; } } - float nx = xorigin; + double nx = xorigin; ColourMapper mapper(m_colourMap, 0, 1); for (int bin = 0; bin < mh; ++bin) { - float x = nx; + double x = nx; nx = xorigin + getXForBin(bin + 1, mh, w); - float value = m_values[bin]; - float norm = 0.f; - float y = getYForValue(value, v, norm); + double value = m_values[bin]; + double norm = 0.0; + double y = getYForValue(value, v, norm); if (m_plotStyle == PlotLines) { @@ -515,7 +515,7 @@ void SliceLayer::paintVerticalScale(View *v, bool, QPainter &paint, QRect rect) const { - float thresh = m_threshold; + double thresh = m_threshold; if (m_energyScale != LinearScale && m_energyScale != AbsoluteScale) { thresh = AudioLevel::dB_to_multiplier(getThresholdDb()); } @@ -538,7 +538,7 @@ const_cast *>(&m_scalePoints)); if (mult != 1 && mult != 0) { - int log = lrintf(log10f(mult)); + int log = int(lrint(log10(mult))); QString a = tr("x10"); QString b = QString("%1").arg(-log); paint.drawText(3, 8 + paint.fontMetrics().ascent(), a); @@ -627,7 +627,7 @@ cerr << "gain is " << m_gain << ", mode is " << m_samplingMode << endl; - val = lrint(log10(m_gain) * 20.0); + val = int(lrint(log10(m_gain) * 20.0)); if (val < *min) val = *min; if (val > *max) val = *max; @@ -636,11 +636,11 @@ *min = -80; *max = 0; - *deflt = lrintf(AudioLevel::multiplier_to_dB(m_initialThreshold)); + *deflt = int(lrint(AudioLevel::multiplier_to_dB(m_initialThreshold))); if (*deflt < *min) *deflt = *min; if (*deflt > *max) *deflt = *max; - val = lrintf(AudioLevel::multiplier_to_dB(m_threshold)); + val = int(lrint(AudioLevel::multiplier_to_dB(m_threshold))); if (val < *min) val = *min; if (val > *max) val = *max; @@ -757,10 +757,10 @@ SliceLayer::setProperty(const PropertyName &name, int value) { if (name == "Gain") { - setGain(pow(10, float(value)/20.0)); + setGain(powf(10, float(value)/20.0f)); } else if (name == "Threshold") { - if (value == -80) setThreshold(0.0); - else setThreshold(AudioLevel::dB_to_multiplier(value)); + if (value == -80) setThreshold(0.0f); + else setThreshold(float(AudioLevel::dB_to_multiplier(value))); } else if (name == "Colour" && m_plotStyle == PlotFilledBlocks) { setFillColourMap(value); } else if (name == "Scale") { @@ -867,7 +867,7 @@ SliceLayer::getThresholdDb() const { if (m_threshold == 0.0) return -80.f; - float db = AudioLevel::multiplier_to_dB(m_threshold); + float db = float(AudioLevel::multiplier_to_dB(m_threshold)); return db; } @@ -942,7 +942,7 @@ } bool -SliceLayer::getValueExtents(float &, float &, bool &, QString &) const +SliceLayer::getValueExtents(double &, double &, bool &, QString &) const { return false; } diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/SliceLayer.h --- a/layer/SliceLayer.h Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/SliceLayer.h Mon Mar 23 11:26:28 2015 +0000 @@ -62,7 +62,7 @@ virtual void setProperty(const PropertyName &, int value); virtual void setProperties(const QXmlAttributes &); - virtual bool getValueExtents(float &min, float &max, + virtual bool getValueExtents(double &min, double &max, bool &logarithmic, QString &unit) const; virtual bool hasTimeXAxis() const { return false; } @@ -93,7 +93,7 @@ BinScale getBinScale() const { return m_binScale; } void setThreshold(float); - int getThreshold() const { return m_threshold; } + float getThreshold() const { return m_threshold; } void setGain(float gain); float getGain() const; @@ -109,11 +109,11 @@ void modelAboutToBeDeleted(Model *); protected: - virtual float getXForBin(int bin, int totalBins, float w) const; - virtual int getBinForX(float x, int totalBins, float w) const; + virtual double getXForBin(int bin, int totalBins, double w) const; + virtual int getBinForX(double x, int totalBins, double w) const; - virtual float getYForValue(float value, const View *v, float &norm) const; - virtual float getValueForY(float y, const View *v) const; + virtual double getYForValue(double value, const View *v, double &norm) const; + virtual double getValueForY(double y, const View *v) const; virtual QString getFeatureDescriptionAux(View *v, QPoint &, bool includeBinDescription, @@ -144,8 +144,8 @@ mutable std::map m_xorigins; mutable std::map m_yorigins; mutable std::map m_heights; - mutable int m_currentf0; - mutable int m_currentf1; + mutable sv_frame_t m_currentf0; + mutable sv_frame_t m_currentf1; mutable std::vector m_values; }; diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/SpectrogramLayer.cpp --- a/layer/SpectrogramLayer.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/SpectrogramLayer.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -41,8 +41,6 @@ #include - - #include #include @@ -52,6 +50,8 @@ //#define DEBUG_SPECTROGRAM_REPAINT 1 +using std::vector; + SpectrogramLayer::SpectrogramLayer(Configuration config) : m_model(0), m_channel(0), @@ -141,8 +141,8 @@ connectSignals(m_model); connect(m_model, SIGNAL(modelChanged()), this, SLOT(cacheInvalid())); - connect(m_model, SIGNAL(modelChangedWithin(int, int)), - this, SLOT(cacheInvalid(int, int))); + connect(m_model, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), + this, SLOT(cacheInvalid(sv_frame_t, sv_frame_t))); emit modelReplaced(); } @@ -242,11 +242,11 @@ *min = -50; *max = 50; - *deflt = lrintf(log10(m_initialGain) * 20.0);; + *deflt = int(lrint(log10(m_initialGain) * 20.0)); if (*deflt < *min) *deflt = *min; if (*deflt > *max) *deflt = *max; - val = lrintf(log10(m_gain) * 20.0); + val = int(lrint(log10(m_gain) * 20.0)); if (val < *min) val = *min; if (val > *max) val = *max; @@ -255,11 +255,11 @@ *min = -50; *max = 0; - *deflt = lrintf(AudioLevel::multiplier_to_dB(m_initialThreshold)); + *deflt = int(lrint(AudioLevel::multiplier_to_dB(m_initialThreshold))); if (*deflt < *min) *deflt = *min; if (*deflt > *max) *deflt = *max; - val = lrintf(AudioLevel::multiplier_to_dB(m_threshold)); + val = int(lrint(AudioLevel::multiplier_to_dB(m_threshold))); if (val < *min) val = *min; if (val > *max) val = *max; @@ -481,10 +481,10 @@ SpectrogramLayer::setProperty(const PropertyName &name, int value) { if (name == "Gain") { - setGain(pow(10, float(value)/20.0)); + setGain(float(pow(10, float(value)/20.0))); } else if (name == "Threshold") { if (value == -50) setThreshold(0.0); - else setThreshold(AudioLevel::dB_to_multiplier(value)); + else setThreshold(float(AudioLevel::dB_to_multiplier(value))); } else if (name == "Colour Rotation") { setColourRotation(value); } else if (name == "Colour") { @@ -572,7 +572,7 @@ } void -SpectrogramLayer::invalidateImageCaches(int startFrame, int endFrame) +SpectrogramLayer::invalidateImageCaches(sv_frame_t startFrame, sv_frame_t endFrame) { for (ViewImageCache::iterator i = m_imageCaches.begin(); i != m_imageCaches.end(); ++i) { @@ -1049,7 +1049,7 @@ } void -SpectrogramLayer::cacheInvalid(int from, int to) +SpectrogramLayer::cacheInvalid(sv_frame_t from, sv_frame_t to) { #ifdef DEBUG_SPECTROGRAM_REPAINT SVDEBUG << "SpectrogramLayer::cacheInvalid(" << from << ", " << to << ")" << endl; @@ -1074,11 +1074,11 @@ i != m_fftModels.end(); ++i) { const FFTModel *model = i->second.first; - int lastFill = i->second.second; + sv_frame_t lastFill = i->second.second; if (model) { - int fill = model->getFillExtent(); + sv_frame_t fill = model->getFillExtent(); #ifdef DEBUG_SPECTROGRAM_REPAINT SVDEBUG << "SpectrogramLayer::fillTimerTimedOut: extent for " << model << ": " << fill << ", last " << lastFill << ", total " << m_model->getEndFrame() << endl; @@ -1147,7 +1147,7 @@ ColourMapper mapper(m_colourMap, 1.f, 255.f); for (int pixel = 1; pixel < 256; ++pixel) { - m_palette.setColour(pixel, mapper.map(pixel)); + m_palette.setColour((unsigned char)pixel, mapper.map(pixel)); } m_crosshairColour = mapper.getContrastingColour(); @@ -1170,23 +1170,23 @@ int target = pixel + distance; while (target < 1) target += 255; while (target > 255) target -= 255; - newPixels[target] = m_palette.getColour(pixel); + newPixels[target] = m_palette.getColour((unsigned char)pixel); } for (int pixel = 0; pixel < 256; ++pixel) { - m_palette.setColour(pixel, newPixels[pixel]); + m_palette.setColour((unsigned char)pixel, newPixels[pixel]); } m_drawBuffer = QImage(); } unsigned char -SpectrogramLayer::getDisplayValue(View *v, float input) const +SpectrogramLayer::getDisplayValue(View *v, double input) const { int value; - float min = 0.f; - float max = 1.f; + double min = 0.0; + double max = 1.0; if (m_normalizeVisibleArea) { min = m_viewMags[v].getMin(); @@ -1195,20 +1195,20 @@ if (m_colourScale == LinearColourScale //|| // m_colourScale == MeterColourScale) { ) { - max = 0.1f; + max = 0.1; } } - float thresh = -80.f; - - if (max == 0.f) max = 1.f; - if (max == min) min = max - 0.0001f; + double thresh = -80.0; + + if (max == 0.0) max = 1.0; + if (max == min) min = max - 0.0001; switch (m_colourScale) { default: case LinearColourScale: - value = int(((input - min) / (max - min)) * 255.f) + 1; + value = int(((input - min) / (max - min)) * 255.0) + 1; break; case MeterColourScale: @@ -1218,19 +1218,19 @@ case dBSquaredColourScale: input = ((input - min) * (input - min)) / ((max - min) * (max - min)); - if (input > 0.f) { - input = 10.f * log10f(input); + if (input > 0.0) { + input = 10.0 * log10(input); } else { input = thresh; } - if (min > 0.f) { - thresh = 10.f * log10f(min * min); - if (thresh < -80.f) thresh = -80.f; + if (min > 0.0) { + thresh = 10.0 * log10(min * min); + if (thresh < -80.0) thresh = -80.0; } input = (input - thresh) / (-thresh); - if (input < 0.f) input = 0.f; - if (input > 1.f) input = 1.f; - value = int(input * 255.f) + 1; + if (input < 0.0) input = 0.0; + if (input > 1.0) input = 1.0; + value = int(input * 255.0) + 1; break; case dBColourScale: @@ -1238,19 +1238,19 @@ //In any case, we need to have some indication of what the dB //scale is relative to. input = (input - min) / (max - min); - if (input > 0.f) { - input = 10.f * log10f(input); + if (input > 0.0) { + input = 10.0 * log10(input); } else { input = thresh; } - if (min > 0.f) { - thresh = 10.f * log10f(min); - if (thresh < -80.f) thresh = -80.f; + if (min > 0.0) { + thresh = 10.0 * log10(min); + if (thresh < -80.0) thresh = -80.0; } input = (input - thresh) / (-thresh); - if (input < 0.f) input = 0.f; - if (input > 1.f) input = 1.f; - value = int(input * 255.f) + 1; + if (input < 0.0) input = 0.0; + if (input > 1.0) input = 1.0; + value = int(input * 255.0) + 1; break; case PhaseColourScale: @@ -1260,14 +1260,14 @@ if (value > UCHAR_MAX) value = UCHAR_MAX; if (value < 0) value = 0; - return value; + return (unsigned char)value; } -float +double SpectrogramLayer::getEffectiveMinFrequency() const { - int sr = m_model->getSampleRate(); - float minf = float(sr) / m_fftSize; + sv_samplerate_t sr = m_model->getSampleRate(); + double minf = double(sr) / m_fftSize; if (m_minFrequency > 0.0) { int minbin = int((double(m_minFrequency) * m_fftSize) / sr + 0.01); @@ -1278,11 +1278,11 @@ return minf; } -float +double SpectrogramLayer::getEffectiveMaxFrequency() const { - int sr = m_model->getSampleRate(); - float maxf = float(sr) / 2; + sv_samplerate_t sr = m_model->getSampleRate(); + double maxf = double(sr) / 2; if (m_maxFrequency > 0.0) { int maxbin = int((double(m_maxFrequency) * m_fftSize) / sr + 0.1); @@ -1294,16 +1294,16 @@ } bool -SpectrogramLayer::getYBinRange(View *v, int y, float &q0, float &q1) const +SpectrogramLayer::getYBinRange(View *v, int y, double &q0, double &q1) const { Profiler profiler("SpectrogramLayer::getYBinRange"); int h = v->height(); if (y < 0 || y >= h) return false; - int sr = m_model->getSampleRate(); - float minf = getEffectiveMinFrequency(); - float maxf = getEffectiveMaxFrequency(); + sv_samplerate_t sr = m_model->getSampleRate(); + double minf = getEffectiveMinFrequency(); + double maxf = getEffectiveMaxFrequency(); bool logarithmic = (m_frequencyScale == LogFrequencyScale); @@ -1320,16 +1320,16 @@ } bool -SpectrogramLayer::getSmoothedYBinRange(View *v, int y, float &q0, float &q1) const +SpectrogramLayer::getSmoothedYBinRange(View *v, int y, double &q0, double &q1) const { Profiler profiler("SpectrogramLayer::getSmoothedYBinRange"); int h = v->height(); if (y < 0 || y >= h) return false; - int sr = m_model->getSampleRate(); - float minf = getEffectiveMinFrequency(); - float maxf = getEffectiveMaxFrequency(); + sv_samplerate_t sr = m_model->getSampleRate(); + double minf = getEffectiveMinFrequency(); + double maxf = getEffectiveMaxFrequency(); bool logarithmic = (m_frequencyScale == LogFrequencyScale); @@ -1346,14 +1346,14 @@ } bool -SpectrogramLayer::getXBinRange(View *v, int x, float &s0, float &s1) const +SpectrogramLayer::getXBinRange(View *v, int x, double &s0, double &s1) const { - int modelStart = m_model->getStartFrame(); - int modelEnd = m_model->getEndFrame(); + sv_frame_t modelStart = m_model->getStartFrame(); + sv_frame_t modelEnd = m_model->getEndFrame(); // Each pixel column covers an exact range of sample frames: - int f0 = v->getFrameForX(x) - modelStart; - int f1 = v->getFrameForX(x + 1) - modelStart - 1; + sv_frame_t f0 = v->getFrameForX(x) - modelStart; + sv_frame_t f1 = v->getFrameForX(x + 1) - modelStart - 1; if (f1 < int(modelStart) || f0 > int(modelEnd)) { return false; @@ -1363,8 +1363,8 @@ // range of spectrogram windows: int windowIncrement = getWindowIncrement(); - s0 = float(f0) / windowIncrement; - s1 = float(f1) / windowIncrement; + s0 = double(f0) / windowIncrement; + s1 = double(f1) / windowIncrement; return true; } @@ -1372,7 +1372,7 @@ bool SpectrogramLayer::getXBinSourceRange(View *v, int x, RealTime &min, RealTime &max) const { - float s0 = 0, s1 = 0; + double s0 = 0, s1 = 0; if (!getXBinRange(v, x, s0, s1)) return false; int s0i = int(s0 + 0.001); @@ -1389,16 +1389,16 @@ } bool -SpectrogramLayer::getYBinSourceRange(View *v, int y, float &freqMin, float &freqMax) +SpectrogramLayer::getYBinSourceRange(View *v, int y, double &freqMin, double &freqMax) const { - float q0 = 0, q1 = 0; + double q0 = 0, q1 = 0; if (!getYBinRange(v, y, q0, q1)) return false; int q0i = int(q0 + 0.001); int q1i = int(q1); - int sr = m_model->getSampleRate(); + sv_samplerate_t sr = m_model->getSampleRate(); for (int q = q0i; q <= q1i; ++q) { if (q == q0i) freqMin = (sr * q) / m_fftSize; @@ -1409,8 +1409,8 @@ bool SpectrogramLayer::getAdjustedYBinSourceRange(View *v, int x, int y, - float &freqMin, float &freqMax, - float &adjFreqMin, float &adjFreqMax) + double &freqMin, double &freqMax, + double &adjFreqMin, double &adjFreqMax) const { if (!m_model || !m_model->isOK() || !m_model->isReady()) { @@ -1420,10 +1420,10 @@ FFTModel *fft = getFFTModel(v); if (!fft) return false; - float s0 = 0, s1 = 0; + double s0 = 0, s1 = 0; if (!getXBinRange(v, x, s0, s1)) return false; - float q0 = 0, q1 = 0; + double q0 = 0, q1 = 0; if (!getYBinRange(v, y, q0, q1)) return false; int s0i = int(s0 + 0.001); @@ -1432,7 +1432,7 @@ int q0i = int(q0 + 0.001); int q1i = int(q1); - int sr = m_model->getSampleRate(); + sv_samplerate_t sr = m_model->getSampleRate(); bool haveAdj = false; @@ -1445,15 +1445,15 @@ if (!fft->isColumnAvailable(s)) continue; - float binfreq = (float(sr) * q) / m_windowSize; + double binfreq = (double(sr) * q) / m_windowSize; if (q == q0i) freqMin = binfreq; if (q == q1i) freqMax = binfreq; if (peaksOnly && !fft->isLocalPeak(s, q)) continue; - if (!fft->isOverThreshold(s, q, m_threshold * (m_fftSize/2))) continue; - - float freq = binfreq; + if (!fft->isOverThreshold(s, q, float(m_threshold * double(m_fftSize)/2.0))) continue; + + double freq = binfreq; if (s < int(fft->getWidth()) - 1) { @@ -1476,17 +1476,17 @@ bool SpectrogramLayer::getXYBinSourceRange(View *v, int x, int y, - float &min, float &max, - float &phaseMin, float &phaseMax) const + double &min, double &max, + double &phaseMin, double &phaseMax) const { if (!m_model || !m_model->isOK() || !m_model->isReady()) { return false; } - float q0 = 0, q1 = 0; + double q0 = 0, q1 = 0; if (!getYBinRange(v, y, q0, q1)) return false; - float s0 = 0, s1 = 0; + double s0 = 0, s1 = 0; if (!getXBinRange(v, x, s0, s1)) return false; int q0i = int(q0 + 0.001); @@ -1520,13 +1520,13 @@ if (!fft->isColumnAvailable(s)) continue; - float value; + double value; value = fft->getPhaseAt(s, q); if (!have || value < phaseMin) { phaseMin = value; } if (!have || value > phaseMax) { phaseMax = value; } - value = fft->getMagnitudeAt(s, q) / (m_fftSize/2); + value = fft->getMagnitudeAt(s, q) / (m_fftSize/2.0); if (!have || value < min) { min = value; } if (!have || value > max) { max = value; } @@ -1558,7 +1558,7 @@ if (m_frequencyScale == LogFrequencyScale) return 3; - int sr = m_model->getSampleRate(); + sv_samplerate_t sr = m_model->getSampleRate(); int maxbin = m_fftSize / 2; if (m_maxFrequency > 0) { @@ -1573,9 +1573,9 @@ if (minbin >= maxbin) minbin = maxbin - 1; } - float perPixel = - float(v->height()) / - float((maxbin - minbin) / (m_zeroPadLevel + 1)); + double perPixel = + double(v->height()) / + double((maxbin - minbin) / (m_zeroPadLevel + 1)); if (perPixel > 2.8) { return 3; // 4x oversampling @@ -1724,14 +1724,14 @@ MagnitudeRange mag; int x0 = 0, x1 = v->width(); - float s00 = 0, s01 = 0, s10 = 0, s11 = 0; + double s00 = 0, s01 = 0, s10 = 0, s11 = 0; if (!getXBinRange(v, x0, s00, s01)) { - s00 = s01 = m_model->getStartFrame() / getWindowIncrement(); + s00 = s01 = double(m_model->getStartFrame()) / getWindowIncrement(); } if (!getXBinRange(v, x1, s10, s11)) { - s10 = s11 = m_model->getEndFrame() / getWindowIncrement(); + s10 = s11 = double(m_model->getEndFrame()) / getWindowIncrement(); } int s0 = int(std::min(s00, s10) + 0.0001); @@ -1780,7 +1780,7 @@ cerr << "rect is " << rect.x() << "," << rect.y() << " " << rect.width() << "x" << rect.height() << endl; #endif - int startFrame = v->getStartFrame(); + sv_frame_t startFrame = v->getStartFrame(); if (startFrame < 0) m_candidateFillStartFrame = 0; else m_candidateFillStartFrame = startFrame; @@ -1830,7 +1830,7 @@ x0 = rect.left(); x1 = rect.right() + 1; /* - float xPixelRatio = float(fft->getResolution()) / float(zoomLevel); + double xPixelRatio = double(fft->getResolution()) / double(zoomLevel); cerr << "xPixelRatio = " << xPixelRatio << endl; if (xPixelRatio < 1.f) xPixelRatio = 1.f; */ @@ -1881,7 +1881,7 @@ int dxp = dx; if (dxp < 0) dxp = -dxp; - int copy = (cw - dxp) * sizeof(QRgb); + size_t copy = (cw - dxp) * sizeof(QRgb); for (int y = 0; y < ch; ++y) { QRgb *line = (QRgb *)cache.image.scanLine(y); if (dx < 0) { @@ -2106,7 +2106,7 @@ cerr << "x0 " << x0 << ", x1 " << x1 << ", w " << w << ", h " << h << endl; #endif - int sr = m_model->getSampleRate(); + sv_samplerate_t sr = m_model->getSampleRate(); // Set minFreq and maxFreq to the frequency extents of the possibly // zero-padded visible bin range, and displayMinFreq and displayMaxFreq @@ -2137,11 +2137,11 @@ minbin = minbin * zpl; maxbin = (maxbin + 1) * zpl - 1; - float minFreq = (float(minbin) * sr) / fftSize; - float maxFreq = (float(maxbin) * sr) / fftSize; - - float displayMinFreq = minFreq; - float displayMaxFreq = maxFreq; + double minFreq = (double(minbin) * sr) / fftSize; + double maxFreq = (double(maxbin) * sr) / fftSize; + + double displayMinFreq = minFreq; + double displayMaxFreq = maxFreq; if (fftSize != m_fftSize) { displayMinFreq = getEffectiveMinFrequency(); @@ -2154,10 +2154,10 @@ bool logarithmic = (m_frequencyScale == LogFrequencyScale); /* - float yforbin[maxbin - minbin + 1]; + double yforbin[maxbin - minbin + 1]; for (int q = minbin; q <= maxbin; ++q) { - float f0 = (float(q) * sr) / fftSize; + double f0 = (double(q) * sr) / fftSize; yforbin[q - minbin] = v->getYForFrequency(f0, displayMinFreq, displayMaxFreq, logarithmic); @@ -2167,7 +2167,7 @@ bool overallMagChanged = false; #ifdef DEBUG_SPECTROGRAM_REPAINT - cerr << ((float(v->getFrameForX(1) - v->getFrameForX(0))) / increment) << " bin(s) per pixel" << endl; + cerr << ((double(v->getFrameForX(1) - v->getFrameForX(0))) / increment) << " bin(s) per pixel" << endl; #endif if (w == 0) { @@ -2196,22 +2196,22 @@ bool bufferBinResolution = false; if (increment > zoomLevel) bufferBinResolution = true; - int leftBoundaryFrame = -1, leftCropFrame = -1; - int rightBoundaryFrame = -1, rightCropFrame = -1; + sv_frame_t leftBoundaryFrame = -1, leftCropFrame = -1; + sv_frame_t rightBoundaryFrame = -1, rightCropFrame = -1; int bufwid; if (bufferBinResolution) { for (int x = x0; ; --x) { - int f = v->getFrameForX(x); + sv_frame_t f = v->getFrameForX(x); if ((f / increment) * increment == f) { if (leftCropFrame == -1) leftCropFrame = f; else if (x < x0 - 2) { leftBoundaryFrame = f; break; } } } for (int x = x0 + w; ; ++x) { - int f = v->getFrameForX(x); + sv_frame_t f = v->getFrameForX(x); if ((f / increment) * increment == f) { if (rightCropFrame == -1) rightCropFrame = f; else if (x > x0 + w + 2) { rightBoundaryFrame = f; break; } @@ -2222,32 +2222,27 @@ cerr << "Right: crop: " << rightCropFrame << " (bin " << rightCropFrame/increment << "); boundary: " << rightBoundaryFrame << " (bin " << rightBoundaryFrame/increment << ")" << endl; #endif - bufwid = (rightBoundaryFrame - leftBoundaryFrame) / increment; + bufwid = int((rightBoundaryFrame - leftBoundaryFrame) / increment); } else { bufwid = w; } -#ifdef __GNUC__ - int binforx[bufwid]; - float binfory[h]; -#else - int *binforx = (int *)alloca(bufwid * sizeof(int)); - float *binfory = (float *)alloca(h * sizeof(float)); -#endif - + vector binforx(bufwid); + vector binfory(h); + bool usePeaksCache = false; if (bufferBinResolution) { for (int x = 0; x < bufwid; ++x) { - binforx[x] = (leftBoundaryFrame / increment) + x; + binforx[x] = int(leftBoundaryFrame / increment) + x; // cerr << "binforx[" << x << "] = " << binforx[x] << endl; } m_drawBuffer = QImage(bufwid, h, QImage::Format_Indexed8); } else { for (int x = 0; x < bufwid; ++x) { - float s0 = 0, s1 = 0; + double s0 = 0, s1 = 0; if (getXBinRange(v, x + x0, s0, s1)) { binforx[x] = int(s0 + 0.0001); } else { @@ -2263,7 +2258,8 @@ // No longer exists in Qt5: m_drawBuffer.setNumColors(256); for (int pixel = 0; pixel < 256; ++pixel) { - m_drawBuffer.setColor(pixel, m_palette.getColour(pixel).rgb()); + m_drawBuffer.setColor((unsigned char)pixel, + m_palette.getColour((unsigned char)pixel).rgb()); } m_drawBuffer.fill(0); @@ -2271,7 +2267,7 @@ if (m_binDisplay != PeakFrequencies) { for (int y = 0; y < h; ++y) { - float q0 = 0, q1 = 0; + double q0 = 0, q1 = 0; if (!getSmoothedYBinRange(v, h-y-1, q0, q1)) { binfory[y] = -1; } else { @@ -2457,11 +2453,11 @@ SpectrogramLayer::paintDrawBufferPeakFrequencies(View *v, int w, int h, - int *binforx, + const vector &binforx, int minbin, int maxbin, - float displayMinFreq, - float displayMaxFreq, + double displayMinFreq, + double displayMaxFreq, bool logarithmic, MagnitudeRange &overallMag, bool &overallMagChanged) const @@ -2522,10 +2518,10 @@ fft->getNormalizedMagnitudesAt(sx, values, minbin, maxbin - minbin + 1); } else if (m_normalizeHybrid) { fft->getNormalizedMagnitudesAt(sx, values, minbin, maxbin - minbin + 1); - float max = fft->getMaximumMagnitudeAt(sx); + double max = fft->getMaximumMagnitudeAt(sx); if (max > 0.f) { for (int i = minbin; i <= maxbin; ++i) { - values[i - minbin] *= log10(max); + values[i - minbin] = float(values[i - minbin] * log10(max)); } } } else { @@ -2538,22 +2534,22 @@ pi != peakfreqs.end(); ++pi) { int bin = pi->first; - int freq = pi->second; + double freq = pi->second; if (bin < minbin) continue; if (bin > maxbin) break; - float value = values[bin - minbin]; + double value = values[bin - minbin]; if (m_colourScale != PhaseColourScale) { if (!m_normalizeColumns && !m_normalizeHybrid) { - value /= (m_fftSize/2.f); + value /= (m_fftSize/2.0); } - mag.sample(value); + mag.sample(float(value)); value *= m_gain; } - float y = v->getYForFrequency + double y = v->getYForFrequency (freq, displayMinFreq, displayMaxFreq, logarithmic); int iy = int(y + 0.5); @@ -2585,8 +2581,8 @@ SpectrogramLayer::paintDrawBuffer(View *v, int w, int h, - int *binforx, - float *binfory, + const vector &binforx, + const vector &binfory, bool usePeaksCache, MagnitudeRange &overallMag, bool &overallMagChanged) const @@ -2594,7 +2590,7 @@ Profiler profiler("SpectrogramLayer::paintDrawBuffer"); int minbin = int(binfory[0] + 0.0001); - int maxbin = binfory[h-1]; + int maxbin = int(binfory[h-1]); #ifdef DEBUG_SPECTROGRAM_REPAINT cerr << "minbin " << minbin << ", maxbin " << maxbin << "; w " << w << ", h " << h << endl; @@ -2689,10 +2685,10 @@ fft->getNormalizedMagnitudesAt(sx, autoarray, minbin, maxbin - minbin + 1); } else if (m_normalizeHybrid) { fft->getNormalizedMagnitudesAt(sx, autoarray, minbin, maxbin - minbin + 1); - float max = fft->getMaximumMagnitudeAt(sx); + double max = fft->getMaximumMagnitudeAt(sx); for (int i = minbin; i <= maxbin; ++i) { - if (max > 0.f) { - autoarray[i - minbin] *= log10(max); + if (max > 0.0) { + autoarray[i - minbin] = float(autoarray[i - minbin] * log10(max)); } } } else { @@ -2715,45 +2711,45 @@ for (int y = 0; y < h; ++y) { - float sy0 = binfory[y]; - float sy1 = sy0 + 1; + double sy0 = binfory[y]; + double sy1 = sy0 + 1; if (y+1 < h) sy1 = binfory[y+1]; - float value = 0.f; - - if (interpolate && fabsf(sy1 - sy0) < 1.f) { - - float centre = (sy0 + sy1) / 2; - float dist = (centre - 0.5) - lrintf(centre - 0.5); + double value = 0.0; + + if (interpolate && fabs(sy1 - sy0) < 1.0) { + + double centre = (sy0 + sy1) / 2; + double dist = (centre - 0.5) - rint(centre - 0.5); int bin = int(centre); int other = (dist < 0 ? (bin-1) : (bin+1)); if (bin < minbin) bin = minbin; if (bin > maxbin) bin = maxbin; if (other < minbin || other > maxbin) other = bin; - float prop = 1.f - fabsf(dist); - - float v0 = values[bin - minbin]; - float v1 = values[other - minbin]; + double prop = 1.0 - fabs(dist); + + double v0 = values[bin - minbin]; + double v1 = values[other - minbin]; if (m_binDisplay == PeakBins) { if (bin == minbin || bin == maxbin || v0 < values[bin-minbin-1] || - v0 < values[bin-minbin+1]) v0 = 0.f; + v0 < values[bin-minbin+1]) v0 = 0.0; if (other == minbin || other == maxbin || v1 < values[other-minbin-1] || - v1 < values[other-minbin+1]) v1 = 0.f; + v1 < values[other-minbin+1]) v1 = 0.0; } - if (v0 == 0.f && v1 == 0.f) continue; - value = prop * v0 + (1.f - prop) * v1; + if (v0 == 0.0 && v1 == 0.0) continue; + value = prop * v0 + (1.0 - prop) * v1; if (m_colourScale != PhaseColourScale) { if (!m_normalizeColumns) { - value /= (m_fftSize/2.f); + value /= (m_fftSize/2.0); } - mag.sample(value); + mag.sample(float(value)); value *= m_gain; } - peaks[y] = value; + peaks[y] = float(value); } else { @@ -2772,13 +2768,15 @@ if (m_colourScale != PhaseColourScale) { if (!m_normalizeColumns) { - value /= (m_fftSize/2.f); + value /= (m_fftSize/2.0); } - mag.sample(value); + mag.sample(float(value)); value *= m_gain; } - if (value > peaks[y]) peaks[y] = value; //!!! not right for phase! + if (value > peaks[y]) { + peaks[y] = float(value); //!!! not right for phase! + } } } } @@ -2800,7 +2798,7 @@ for (int y = 0; y < h; ++y) { - float peak = peaks[y]; + double peak = peaks[y]; if (m_colourScale != PhaseColourScale && (m_normalizeColumns || m_normalizeHybrid) && @@ -2833,8 +2831,8 @@ // cerr << "SpectrogramLayer: illuminateLocalFeatures(" // << localPos.x() << "," << localPos.y() << ")" << endl; - float s0, s1; - float f0, f1; + double s0, s1; + double f0, f1; if (getXBinRange(v, localPos.x(), s0, s1) && getYBinSourceRange(v, localPos.y(), f0, f1)) { @@ -2859,8 +2857,8 @@ } } -float -SpectrogramLayer::getYForFrequency(const View *v, float frequency) const +double +SpectrogramLayer::getYForFrequency(const View *v, double frequency) const { return v->getYForFrequency(frequency, getEffectiveMinFrequency(), @@ -2868,7 +2866,7 @@ m_frequencyScale == LogFrequencyScale); } -float +double SpectrogramLayer::getFrequencyForY(const View *v, int y) const { return v->getFrequencyForY(y, @@ -2898,14 +2896,14 @@ } bool -SpectrogramLayer::getValueExtents(float &min, float &max, +SpectrogramLayer::getValueExtents(double &min, double &max, bool &logarithmic, QString &unit) const { if (!m_model) return false; - int sr = m_model->getSampleRate(); - min = float(sr) / m_fftSize; - max = float(sr) / 2; + sv_samplerate_t sr = m_model->getSampleRate(); + min = double(sr) / m_fftSize; + max = double(sr) / 2; logarithmic = (m_frequencyScale == LogFrequencyScale); unit = "Hz"; @@ -2913,7 +2911,7 @@ } bool -SpectrogramLayer::getDisplayExtents(float &min, float &max) const +SpectrogramLayer::getDisplayExtents(double &min, double &max) const { min = getEffectiveMinFrequency(); max = getEffectiveMaxFrequency(); @@ -2923,17 +2921,17 @@ } bool -SpectrogramLayer::setDisplayExtents(float min, float max) +SpectrogramLayer::setDisplayExtents(double min, double max) { if (!m_model) return false; // SVDEBUG << "SpectrogramLayer::setDisplayExtents: " << min << "->" << max << endl; if (min < 0) min = 0; - if (max > m_model->getSampleRate()/2.f) max = m_model->getSampleRate()/2.f; + if (max > m_model->getSampleRate()/2.0) max = m_model->getSampleRate()/2.0; - int minf = lrintf(min); - int maxf = lrintf(max); + int minf = int(lrint(min)); + int maxf = int(lrint(max)); if (m_minFrequency == minf && m_maxFrequency == maxf) return true; @@ -2956,7 +2954,7 @@ bool SpectrogramLayer::getYScaleValue(const View *v, int y, - float &value, QString &unit) const + double &value, QString &unit) const { value = getFrequencyForY(v, y); unit = "Hz"; @@ -2964,13 +2962,14 @@ } bool -SpectrogramLayer::snapToFeatureFrame(View *, int &frame, +SpectrogramLayer::snapToFeatureFrame(View *, + sv_frame_t &frame, int &resolution, SnapType snap) const { resolution = getWindowIncrement(); - int left = (frame / resolution) * resolution; - int right = left + resolution; + sv_frame_t left = (frame / resolution) * resolution; + sv_frame_t right = left + resolution; switch (snap) { case SnapLeft: frame = left; break; @@ -3062,7 +3061,7 @@ paint.drawLine(0, cursorPos.y(), cursorPos.x() - 1, cursorPos.y()); paint.drawLine(cursorPos.x(), 0, cursorPos.x(), v->height()); - float fundamental = getFrequencyForY(v, cursorPos.y()); + double fundamental = getFrequencyForY(v, cursorPos.y()); v->drawVisibleText(paint, sw + 2, @@ -3079,7 +3078,7 @@ View::OutlinedText); } - int frame = v->getFrameForX(cursorPos.x()); + sv_frame_t frame = v->getFrameForX(cursorPos.x()); RealTime rt = RealTime::frame2RealTime(frame, m_model->getSampleRate()); QString rtLabel = QString("%1 s").arg(rt.toText(true).c_str()); QString frameLabel = QString("%1").arg(frame); @@ -3098,7 +3097,7 @@ while (harmonic < 100) { - float hy = lrintf(getYForFrequency(v, fundamental * harmonic)); + int hy = int(lrint(getYForFrequency(v, fundamental * harmonic))); if (hy < 0 || hy > v->height()) break; int len = 7; @@ -3112,9 +3111,9 @@ } paint.drawLine(cursorPos.x() - len, - int(hy), + hy, cursorPos.x(), - int(hy)); + hy); ++harmonic; } @@ -3130,10 +3129,10 @@ if (!m_model || !m_model->isOK()) return ""; - float magMin = 0, magMax = 0; - float phaseMin = 0, phaseMax = 0; - float freqMin = 0, freqMax = 0; - float adjFreqMin = 0, adjFreqMax = 0; + double magMin = 0, magMax = 0; + double phaseMin = 0, phaseMax = 0; + double freqMin = 0, freqMax = 0; + double adjFreqMin = 0, adjFreqMax = 0; QString pitchMin, pitchMax; RealTime rtMin, rtMax; @@ -3205,21 +3204,21 @@ } if (haveValues) { - float dbMin = AudioLevel::multiplier_to_dB(magMin); - float dbMax = AudioLevel::multiplier_to_dB(magMax); + double dbMin = AudioLevel::multiplier_to_dB(magMin); + double dbMax = AudioLevel::multiplier_to_dB(magMax); QString dbMinString; QString dbMaxString; if (dbMin == AudioLevel::DB_FLOOR) { dbMinString = tr("-Inf"); } else { - dbMinString = QString("%1").arg(lrintf(dbMin)); + dbMinString = QString("%1").arg(lrint(dbMin)); } if (dbMax == AudioLevel::DB_FLOOR) { dbMaxString = tr("-Inf"); } else { - dbMaxString = QString("%1").arg(lrintf(dbMax)); + dbMaxString = QString("%1").arg(lrint(dbMax)); } - if (lrintf(dbMin) != lrintf(dbMax)) { + if (lrint(dbMin) != lrint(dbMax)) { text += tr("dB:\t%1 - %2").arg(dbMinString).arg(dbMaxString); } else { text += tr("dB:\t%1").arg(dbMinString); @@ -3282,7 +3281,7 @@ int pkw = (m_frequencyScale == LogFrequencyScale ? 10 : 0); int bins = m_fftSize / 2; - int sr = m_model->getSampleRate(); + sv_samplerate_t sr = m_model->getSampleRate(); if (m_maxFrequency > 0) { bins = int((double(m_maxFrequency) * m_fftSize) / sr + 0.1); @@ -3308,17 +3307,17 @@ paint.drawRect(4 + cw - cbw, textHeight * topLines + 4, cbw - 1, ch + 1); QString top, bottom; - float min = m_viewMags[v].getMin(); - float max = m_viewMags[v].getMax(); - - float dBmin = AudioLevel::multiplier_to_dB(min); - float dBmax = AudioLevel::multiplier_to_dB(max); + double min = m_viewMags[v].getMin(); + double max = m_viewMags[v].getMax(); + + double dBmin = AudioLevel::multiplier_to_dB(min); + double dBmax = AudioLevel::multiplier_to_dB(max); if (dBmax < -60.f) dBmax = -60.f; - else top = QString("%1").arg(lrintf(dBmax)); + else top = QString("%1").arg(lrint(dBmax)); if (dBmin < dBmax - 60.f) dBmin = dBmax - 60.f; - bottom = QString("%1").arg(lrintf(dBmin)); + bottom = QString("%1").arg(lrint(dBmin)); //!!! & phase etc @@ -3342,13 +3341,13 @@ for (int i = 0; i < ch; ++i) { - float dBval = dBmin + (((dBmax - dBmin) * i) / (ch - 1)); + double dBval = dBmin + (((dBmax - dBmin) * i) / (ch - 1)); int idb = int(dBval); - float value = AudioLevel::dB_to_multiplier(dBval); + double value = AudioLevel::dB_to_multiplier(dBval); int colour = getDisplayValue(v, value * m_gain); - paint.setPen(m_palette.getColour(colour)); + paint.setPen(m_palette.getColour((unsigned char)colour)); int y = textHeight * topLines + 4 + ch - i; @@ -3382,7 +3381,7 @@ for (int y = 0; y < v->height(); ++y) { - float q0, q1; + double q0, q1; if (!getYBinRange(v, v->height() - y, q0, q1)) continue; int vy; @@ -3394,7 +3393,7 @@ continue; } - int freq = (sr * bin) / m_fftSize; + int freq = int((sr * bin) / m_fftSize); if (py >= 0 && (vy - py) < textHeight - 1) { if (m_frequencyScale == LinearFrequencyScale) { @@ -3430,18 +3429,18 @@ class SpectrogramRangeMapper : public RangeMapper { public: - SpectrogramRangeMapper(int sr, int /* fftsize */) : - m_dist(float(sr) / 2), - m_s2(sqrtf(sqrtf(2))) { } + SpectrogramRangeMapper(sv_samplerate_t sr, int /* fftsize */) : + m_dist(sr / 2), + m_s2(sqrt(sqrt(2))) { } ~SpectrogramRangeMapper() { } - virtual int getPositionForValue(float value) const { - - float dist = m_dist; + virtual int getPositionForValue(double value) const { + + double dist = m_dist; int n = 0; - while (dist > (value + 0.00001) && dist > 0.1f) { + while (dist > (value + 0.00001) && dist > 0.1) { dist /= m_s2; ++n; } @@ -3449,19 +3448,19 @@ return n; } - virtual int getPositionForValueUnclamped(float value) const { + virtual int getPositionForValueUnclamped(double value) const { // We don't really support this return getPositionForValue(value); } - virtual float getValueForPosition(int position) const { + virtual double getValueForPosition(int position) const { // Vertical zoom step 0 shows the entire range from DC -> // Nyquist frequency. Step 1 shows 2^(1/4) of the range of // step 0, and so on until the visible range is smaller than // the frequency step between bins at the current fft size. - float dist = m_dist; + double dist = m_dist; int n = 0; while (n < position) { @@ -3472,7 +3471,7 @@ return dist; } - virtual float getValueForPositionUnclamped(int position) const { + virtual double getValueForPositionUnclamped(int position) const { // We don't really support this return getValueForPosition(position); } @@ -3480,8 +3479,8 @@ virtual QString getUnit() const { return "Hz"; } protected: - float m_dist; - float m_s2; + double m_dist; + double m_s2; }; int @@ -3489,16 +3488,16 @@ { if (!m_model) return 0; - int sr = m_model->getSampleRate(); + sv_samplerate_t sr = m_model->getSampleRate(); SpectrogramRangeMapper mapper(sr, m_fftSize); -// int maxStep = mapper.getPositionForValue((float(sr) / m_fftSize) + 0.001); +// int maxStep = mapper.getPositionForValue((double(sr) / m_fftSize) + 0.001); int maxStep = mapper.getPositionForValue(0); - int minStep = mapper.getPositionForValue(float(sr) / 2); + int minStep = mapper.getPositionForValue(double(sr) / 2); int initialMax = m_initialMaxFrequency; - if (initialMax == 0) initialMax = sr / 2; + if (initialMax == 0) initialMax = int(sr / 2); defaultStep = mapper.getPositionForValue(initialMax) - minStep; @@ -3512,7 +3511,7 @@ { if (!m_model) return 0; - float dmin, dmax; + double dmin, dmax; getDisplayExtents(dmin, dmax); SpectrogramRangeMapper mapper(m_model->getSampleRate(), m_fftSize); @@ -3526,16 +3525,16 @@ { if (!m_model) return; - float dmin = m_minFrequency, dmax = m_maxFrequency; + double dmin = m_minFrequency, dmax = m_maxFrequency; // getDisplayExtents(dmin, dmax); // cerr << "current range " << dmin << " -> " << dmax << ", range " << dmax-dmin << ", mid " << (dmax + dmin)/2 << endl; - int sr = m_model->getSampleRate(); + sv_samplerate_t sr = m_model->getSampleRate(); SpectrogramRangeMapper mapper(sr, m_fftSize); - float newdist = mapper.getValueForPosition(step); - - float newmin, newmax; + double newdist = mapper.getValueForPosition(step); + + double newmin, newmax; if (m_frequencyScale == LogFrequencyScale) { @@ -3560,20 +3559,20 @@ // = dmin.dmax // so newmax = (newdist + sqrtf(newdist^2 + 4dmin.dmax)) / 2 - newmax = (newdist + sqrtf(newdist*newdist + 4*dmin*dmax)) / 2; + newmax = (newdist + sqrt(newdist*newdist + 4*dmin*dmax)) / 2; newmin = newmax - newdist; // cerr << "newmin = " << newmin << ", newmax = " << newmax << endl; } else { - float dmid = (dmax + dmin) / 2; + double dmid = (dmax + dmin) / 2; newmin = dmid - newdist / 2; newmax = dmid + newdist / 2; } - float mmin, mmax; + double mmin, mmax; mmin = 0; - mmax = float(sr) / 2; + mmax = double(sr) / 2; if (newmin < mmin) { newmax += (mmin - newmin); @@ -3585,8 +3584,8 @@ // SVDEBUG << "SpectrogramLayer::setVerticalZoomStep: " << step << ": " << newmin << " -> " << newmax << " (range " << newdist << ")" << endl; - setMinFrequency(lrintf(newmin)); - setMaxFrequency(lrintf(newmax)); + setMinFrequency(int(lrint(newmin))); + setMaxFrequency(int(lrint(newmax))); } RangeMapper * @@ -3600,10 +3599,10 @@ SpectrogramLayer::updateMeasureRectYCoords(View *v, const MeasureRect &r) const { int y0 = 0; - if (r.startY > 0.0) y0 = getYForFrequency(v, r.startY); + if (r.startY > 0.0) y0 = int(getYForFrequency(v, r.startY)); int y1 = y0; - if (r.endY > 0.0) y1 = getYForFrequency(v, r.endY); + if (r.endY > 0.0) y1 = int(getYForFrequency(v, r.endY)); // SVDEBUG << "SpectrogramLayer::updateMeasureRectYCoords: start " << r.startY << " -> " << y0 << ", end " << r.endY << " -> " << y1 << endl; diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/SpectrogramLayer.h --- a/layer/SpectrogramLayer.h Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/SpectrogramLayer.h Mon Mar 23 11:26:28 2015 +0000 @@ -69,7 +69,7 @@ virtual QString getFeatureDescription(View *v, QPoint &) const; - virtual bool snapToFeatureFrame(View *v, int &frame, + virtual bool snapToFeatureFrame(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const; @@ -210,20 +210,20 @@ return ColourHasMeaningfulValue; } - float getYForFrequency(const View *v, float frequency) const; - float getFrequencyForY(const View *v, int y) const; + double getYForFrequency(const View *v, double frequency) const; + double getFrequencyForY(const View *v, int y) const; virtual int getCompletion(View *v) const; virtual QString getError(View *v) const; - virtual bool getValueExtents(float &min, float &max, + virtual bool getValueExtents(double &min, double &max, bool &logarithmic, QString &unit) const; - virtual bool getDisplayExtents(float &min, float &max) const; + virtual bool getDisplayExtents(double &min, double &max) const; - virtual bool setDisplayExtents(float min, float max); + virtual bool setDisplayExtents(double min, double max); - virtual bool getYScaleValue(const View *, int, float &, QString &) const; + virtual bool getYScaleValue(const View *, int, double &, QString &) const; virtual void toXml(QTextStream &stream, QString indent = "", QString extraAttributes = "") const; @@ -243,7 +243,7 @@ protected slots: void cacheInvalid(); - void cacheInvalid(int startFrame, int endFrame); + void cacheInvalid(sv_frame_t startFrame, sv_frame_t endFrame); void preferenceChanged(PropertyContainer::PropertyName name); @@ -310,12 +310,12 @@ { QImage image; QRect validArea; - int startFrame; + sv_frame_t startFrame; int zoomLevel; }; typedef std::map ViewImageCache; void invalidateImageCaches(); - void invalidateImageCaches(int startFrame, int endFrame); + void invalidateImageCaches(sv_frame_t startFrame, sv_frame_t endFrame); mutable ViewImageCache m_imageCaches; /** @@ -328,27 +328,20 @@ mutable QTimer *m_updateTimer; - mutable int m_candidateFillStartFrame; + mutable sv_frame_t m_candidateFillStartFrame; bool m_exiting; void initialisePalette(); void rotatePalette(int distance); - unsigned char getDisplayValue(View *v, float input) const; + unsigned char getDisplayValue(View *v, double input) const; int getColourScaleWidth(QPainter &) const; void illuminateLocalFeatures(View *v, QPainter &painter) const; - float getEffectiveMinFrequency() const; - float getEffectiveMaxFrequency() const; - - struct LayerRange { - int startFrame; - int zoomLevel; - int modelStart; - int modelEnd; - }; + double getEffectiveMinFrequency() const; + double getEffectiveMaxFrequency() const; // Note that the getYBin... methods return the nominal bin in the // un-smoothed spectrogram. This is not necessarily the same bin @@ -356,17 +349,17 @@ // position, if the spectrogram has oversampling smoothing. Use // getSmoothedYBinRange to obtain that. - bool getXBinRange(View *v, int x, float &windowMin, float &windowMax) const; - bool getYBinRange(View *v, int y, float &freqBinMin, float &freqBinMax) const; - bool getSmoothedYBinRange(View *v, int y, float &freqBinMin, float &freqBinMax) const; + bool getXBinRange(View *v, int x, double &windowMin, double &windowMax) const; + bool getYBinRange(View *v, int y, double &freqBinMin, double &freqBinMax) const; + bool getSmoothedYBinRange(View *v, int y, double &freqBinMin, double &freqBinMax) const; - bool getYBinSourceRange(View *v, int y, float &freqMin, float &freqMax) const; + bool getYBinSourceRange(View *v, int y, double &freqMin, double &freqMax) const; bool getAdjustedYBinSourceRange(View *v, int x, int y, - float &freqMin, float &freqMax, - float &adjFreqMin, float &adjFreqMax) const; + double &freqMin, double &freqMax, + double &adjFreqMin, double &adjFreqMax) const; bool getXBinSourceRange(View *v, int x, RealTime &timeMin, RealTime &timeMax) const; - bool getXYBinSourceRange(View *v, int x, int y, float &min, float &max, - float &phaseMin, float &phaseMax) const; + bool getXYBinSourceRange(View *v, int x, int y, double &min, double &max, + double &phaseMin, double &phaseMax) const; int getWindowIncrement() const { if (m_windowHopLevel == 0) return m_windowSize; @@ -380,7 +373,7 @@ Dense3DModelPeakCache *getPeakCache(const View *v) const; void invalidateFFTModels(); - typedef std::pair FFTFillPair; // model, last fill + typedef std::pair FFTFillPair; // model, last fill typedef std::map ViewFFTMap; typedef std::map PeakCacheMap; mutable ViewFFTMap m_fftModels; @@ -393,20 +386,19 @@ bool operator==(const MagnitudeRange &r) { return r.m_min == m_min && r.m_max == m_max; } - bool isSet() const { return (m_min != 0 || m_max != 0); } + bool isSet() const { return (m_min != 0.f || m_max != 0.f); } void set(float min, float max) { - m_min = convert(min); - m_max = convert(max); + m_min = min; + m_max = max; if (m_max < m_min) m_max = m_min; } bool sample(float f) { - unsigned int ui = convert(f); bool changed = false; if (isSet()) { - if (ui < m_min) { m_min = ui; changed = true; } - if (ui > m_max) { m_max = ui; changed = true; } + if (f < m_min) { m_min = f; changed = true; } + if (f > m_max) { m_max = f; changed = true; } } else { - m_max = m_min = ui; + m_max = m_min = f; changed = true; } return changed; @@ -423,16 +415,11 @@ } return changed; } - float getMin() const { return float(m_min) / UINT_MAX; } - float getMax() const { return float(m_max) / UINT_MAX; } + float getMin() const { return m_min; } + float getMax() const { return m_max; } private: - unsigned int m_min; - unsigned int m_max; - unsigned int convert(float f) { - if (f < 0.f) f = 0.f; - if (f > 1.f) f = 1.f; - return (unsigned int)(f * UINT_MAX); - } + float m_min; + float m_max; }; typedef std::map ViewMagMap; @@ -441,16 +428,17 @@ void invalidateMagnitudes(); bool updateViewMagnitudes(View *v) const; bool paintDrawBuffer(View *v, int w, int h, - int *binforx, float *binfory, + const std::vector &binforx, + const std::vector &binfory, bool usePeaksCache, MagnitudeRange &overallMag, bool &overallMagChanged) const; bool paintDrawBufferPeakFrequencies(View *v, int w, int h, - int *binforx, + const std::vector &binforx, int minbin, int maxbin, - float displayMinFreq, - float displayMaxFreq, + double displayMinFreq, + double displayMaxFreq, bool logarithmic, MagnitudeRange &overallMag, bool &overallMagChanged) const; diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/SpectrumLayer.cpp --- a/layer/SpectrumLayer.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/SpectrumLayer.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -301,42 +301,42 @@ } bool -SpectrumLayer::getValueExtents(float &, float &, bool &, QString &) const +SpectrumLayer::getValueExtents(double &, double &, bool &, QString &) const { return false; } -float -SpectrumLayer::getXForBin(int bin, int totalBins, float w) const +double +SpectrumLayer::getXForBin(int bin, int totalBins, double w) const { if (!m_sliceableModel) return SliceLayer::getXForBin(bin, totalBins, w); - float sampleRate = m_sliceableModel->getSampleRate(); - float binfreq = (sampleRate * bin) / (totalBins * 2); + sv_samplerate_t sampleRate = m_sliceableModel->getSampleRate(); + double binfreq = (sampleRate * bin) / (totalBins * 2); return getXForFrequency(binfreq, w); } int -SpectrumLayer::getBinForX(float x, int totalBins, float w) const +SpectrumLayer::getBinForX(double x, int totalBins, double w) const { if (!m_sliceableModel) return SliceLayer::getBinForX(x, totalBins, w); - float sampleRate = m_sliceableModel->getSampleRate(); - float binfreq = getFrequencyForX(x, w); + sv_samplerate_t sampleRate = m_sliceableModel->getSampleRate(); + double binfreq = getFrequencyForX(x, w); return int((binfreq * totalBins * 2) / sampleRate); } -float -SpectrumLayer::getFrequencyForX(float x, float w) const +double +SpectrumLayer::getFrequencyForX(double x, double w) const { - float freq = 0; + double freq = 0; if (!m_sliceableModel) return 0; - int sampleRate = m_sliceableModel->getSampleRate(); + sv_samplerate_t sampleRate = m_sliceableModel->getSampleRate(); - float maxfreq = float(sampleRate) / 2; + double maxfreq = double(sampleRate) / 2; switch (m_binScale) { @@ -345,26 +345,26 @@ break; case LogBins: - freq = powf(10.f, (x * log10f(maxfreq)) / w); + freq = pow(10.0, (x * log10(maxfreq)) / w); break; case InvertedLogBins: - freq = maxfreq - powf(10.f, ((w - x) * log10f(maxfreq)) / w); + freq = maxfreq - pow(10.0, ((w - x) * log10(maxfreq)) / w); break; } return freq; } -float -SpectrumLayer::getXForFrequency(float freq, float w) const +double +SpectrumLayer::getXForFrequency(double freq, double w) const { - float x = 0; + double x = 0; if (!m_sliceableModel) return x; - int sampleRate = m_sliceableModel->getSampleRate(); + sv_samplerate_t sampleRate = m_sliceableModel->getSampleRate(); - float maxfreq = float(sampleRate) / 2; + double maxfreq = double(sampleRate) / 2; switch (m_binScale) { @@ -373,12 +373,12 @@ break; case LogBins: - x = (log10f(freq) * w) / log10f(maxfreq); + x = (log10(freq) * w) / log10(maxfreq); break; case InvertedLogBins: if (maxfreq == freq) x = w; - else x = w - (log10f(maxfreq - freq) * w) / log10f(maxfreq); + else x = w - (log10(maxfreq - freq) * w) / log10(maxfreq); break; } @@ -387,7 +387,7 @@ bool SpectrumLayer::getXScaleValue(const View *v, int x, - float &value, QString &unit) const + double &value, QString &unit) const { if (m_xorigins.find(v) == m_xorigins.end()) return false; int xorigin = m_xorigins.find(v)->second; @@ -398,14 +398,14 @@ bool SpectrumLayer::getYScaleValue(const View *v, int y, - float &value, QString &unit) const + double &value, QString &unit) const { value = getValueForY(y, v); if (m_energyScale == dBScale || m_energyScale == MeterScale) { - if (value > 0.f) { - value = 10.f * log10f(value); + if (value > 0.0) { + value = 10.0 * log10(value); if (value < m_threshold) value = m_threshold; } else value = m_threshold; @@ -420,7 +420,7 @@ bool SpectrumLayer::getYScaleDifference(const View *v, int y0, int y1, - float &diff, QString &unit) const + double &diff, QString &unit) const { bool rv = SliceLayer::getYScaleDifference(v, y0, y1, diff, unit); if (rv && (unit == "dBV")) unit = "dB"; @@ -492,7 +492,7 @@ paint.drawLine(xorigin, cursorPos.y(), v->width(), cursorPos.y()); paint.drawLine(cursorPos.x(), cursorPos.y(), cursorPos.x(), v->height()); - float fundamental = getFrequencyForX(cursorPos.x() - xorigin, w); + double fundamental = getFrequencyForX(cursorPos.x() - xorigin, w); int hoffset = 2; if (m_binScale == LogBins) hoffset = 13; @@ -512,10 +512,10 @@ View::OutlinedText); } - float value = getValueForY(cursorPos.y(), v); - float thresh = m_threshold; - float db = thresh; - if (value > 0.f) db = 10.f * log10f(value); + double value = getValueForY(cursorPos.y(), v); + double thresh = m_threshold; + double db = thresh; + if (value > 0.0) db = 10.0 * log10(value); if (db < thresh) db = thresh; v->drawVisibleText(paint, @@ -534,7 +534,7 @@ while (harmonic < 100) { - float hx = lrintf(getXForFrequency(fundamental * harmonic, w)); + int hx = int(lrint(getXForFrequency(fundamental * harmonic, w))); hx += xorigin; if (hx < xorigin || hx > v->width()) break; @@ -549,9 +549,9 @@ } } - paint.drawLine(int(hx), + paint.drawLine(hx, cursorPos.y(), - int(hx), + hx, cursorPos.y() + len); ++harmonic; @@ -571,21 +571,21 @@ if (genericDesc == "") return ""; - float minvalue = 0.f; + double minvalue = 0.f; if (minbin < int(m_values.size())) minvalue = m_values[minbin]; - float maxvalue = minvalue; + double maxvalue = minvalue; if (maxbin < int(m_values.size())) maxvalue = m_values[maxbin]; if (minvalue > maxvalue) std::swap(minvalue, maxvalue); QString binstr; QString hzstr; - int minfreq = lrintf((minbin * m_sliceableModel->getSampleRate()) / - m_windowSize); - int maxfreq = lrintf((std::max(maxbin, minbin+1) - * m_sliceableModel->getSampleRate()) / - m_windowSize); + int minfreq = int(lrint((minbin * m_sliceableModel->getSampleRate()) / + m_windowSize)); + int maxfreq = int(lrint((std::max(maxbin, minbin+1) + * m_sliceableModel->getSampleRate()) / + m_windowSize)); if (maxbin != minbin) { binstr = tr("%1 - %2").arg(minbin+1).arg(maxbin+1); @@ -606,21 +606,21 @@ } QString dbstr; - float mindb = AudioLevel::multiplier_to_dB(minvalue); - float maxdb = AudioLevel::multiplier_to_dB(maxvalue); + double mindb = AudioLevel::multiplier_to_dB(minvalue); + double maxdb = AudioLevel::multiplier_to_dB(maxvalue); QString mindbstr; QString maxdbstr; if (mindb == AudioLevel::DB_FLOOR) { mindbstr = tr("-Inf"); } else { - mindbstr = QString("%1").arg(lrintf(mindb)); + mindbstr = QString("%1").arg(lrint(mindb)); } if (maxdb == AudioLevel::DB_FLOOR) { maxdbstr = tr("-Inf"); } else { - maxdbstr = QString("%1").arg(lrintf(maxdb)); + maxdbstr = QString("%1").arg(lrint(maxdb)); } - if (lrintf(mindb) != lrintf(maxdb)) { + if (lrint(mindb) != lrint(maxdb)) { dbstr = tr("%1 - %2").arg(mindbstr).arg(maxdbstr); } else { dbstr = tr("%1").arg(mindbstr); @@ -666,7 +666,7 @@ FFTModel *fft = dynamic_cast (const_cast(m_sliceableModel)); - float thresh = (powf(10, -6) / m_gain) * (m_windowSize / 2.f); // -60dB adj + double thresh = (pow(10, -6) / m_gain) * (m_windowSize / 2.0); // -60dB adj int xorigin = getVerticalScaleWidth(v, false, paint) + 1; int w = v->width() - xorigin - 1; @@ -684,7 +684,7 @@ // SVDEBUG << "Showing peaks..." << endl; - int col = v->getCentreFrame() / fft->getResolution(); + int col = int(v->getCentreFrame() / fft->getResolution()); paint.save(); paint.setRenderHint(QPainter::Antialiasing, false); @@ -692,8 +692,8 @@ int peakminbin = 0; int peakmaxbin = fft->getHeight() - 1; - float peakmaxfreq = Pitch::getFrequencyForPitch(128); - peakmaxbin = ((peakmaxfreq * fft->getHeight() * 2) / fft->getSampleRate()); + double peakmaxfreq = Pitch::getFrequencyForPitch(128); + peakmaxbin = int(((peakmaxfreq * fft->getHeight() * 2) / fft->getSampleRate())); FFTModel::PeakSet peaks = fft->getPeakFrequencies (FFTModel::MajorPitchAdaptivePeaks, col, peakminbin, peakmaxbin); @@ -702,12 +702,12 @@ BiasCurve curve; getBiasCurve(curve); - int cs = curve.size(); + int cs = int(curve.size()); - std::vector values; + std::vector values; for (int bin = 0; bin < fft->getHeight(); ++bin) { - float value = m_sliceableModel->getValueAt(col, bin); + double value = m_sliceableModel->getValueAt(col, bin); if (bin < cs) value *= curve[bin]; values.push_back(value); } @@ -719,13 +719,13 @@ // cerr << "bin = " << bin << ", thresh = " << thresh << ", value = " << fft->getMagnitudeAt(col, bin) << endl; - if (!fft->isOverThreshold(col, bin, thresh)) continue; + if (!fft->isOverThreshold(col, bin, float(thresh))) continue; - float freq = i->second; + double freq = i->second; - int x = lrintf(getXForFrequency(freq, w)); + int x = int(lrint(getXForFrequency(freq, w))); - float norm = 0.f; + double norm = 0.f; (void)getYForValue(values[bin], v, norm); // don't need return value, need norm paint.setPen(mapper.map(norm)); @@ -762,8 +762,8 @@ for (int i = 0; i < 128; ++i) { - float f = Pitch::getFrequencyForPitch(i); - int x = lrintf(getXForFrequency(f, w)); + double f = Pitch::getFrequencyForPitch(i); + int x = int(lrint(getXForFrequency(f, w))); x += xorigin; @@ -805,7 +805,7 @@ if (n == 1 || n == 3 || n == 6 || n == 8 || n == 10) { // black notes paint.drawLine(x, h - pkh, x, h); - int rw = lrintf(float(x - px) / 4) * 2; + int rw = int(lrint(double(x - px) / 4) * 2); if (rw < 2) rw = 2; paint.drawRect(x - rw/2, h - pkh, rw, pkh/2); } else if (n == 0 || n == 5) { diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/SpectrumLayer.h --- a/layer/SpectrumLayer.h Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/SpectrumLayer.h Mon Mar 23 11:26:28 2015 +0000 @@ -64,17 +64,17 @@ virtual void setProperty(const PropertyName &, int value); virtual void setProperties(const QXmlAttributes &); - virtual bool getValueExtents(float &min, float &max, + virtual bool getValueExtents(double &min, double &max, bool &logarithmic, QString &unit) const; virtual bool getXScaleValue(const View *v, int x, - float &value, QString &unit) const; + double &value, QString &unit) const; virtual bool getYScaleValue(const View *, int y, - float &value, QString &unit) const; + double &value, QString &unit) const; virtual bool getYScaleDifference(const View *, int y0, int y1, - float &diff, QString &unit) const; + double &diff, QString &unit) const; virtual bool isLayerScrollable(const View *) const { return false; } @@ -123,11 +123,11 @@ virtual void getBiasCurve(BiasCurve &) const; BiasCurve m_biasCurve; - virtual float getXForBin(int bin, int totalBins, float w) const; - virtual int getBinForX(float x, int totalBins, float w) const; + virtual double getXForBin(int bin, int totalBins, double w) const; + virtual int getBinForX(double x, int totalBins, double w) const; - float getFrequencyForX(float x, float w) const; - float getXForFrequency(float freq, float w) const; + double getFrequencyForX(double x, double w) const; + double getXForFrequency(double freq, double w) const; int getWindowIncrement() const { if (m_windowHopLevel == 0) return m_windowSize; diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/TextLayer.cpp --- a/layer/TextLayer.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/TextLayer.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -96,7 +96,7 @@ } bool -TextLayer::getValueExtents(float &, float &, bool &, QString &) const +TextLayer::getValueExtents(double &, double &, bool &, QString &) const { return false; } @@ -114,8 +114,8 @@ { if (!m_model) return TextModel::PointList(); - long frame0 = v->getFrameForX(-150); - long frame1 = v->getFrameForX(v->width() + 150); + sv_frame_t frame0 = v->getFrameForX(-150); + sv_frame_t frame1 = v->getFrameForX(v->width() + 150); TextModel::PointList points(m_model->getPoints(frame0, frame1)); @@ -158,19 +158,19 @@ { if (!m_model) return false; - long a = v->getFrameForX(x - 120); - long b = v->getFrameForX(x + 10); + sv_frame_t a = v->getFrameForX(x - 120); + sv_frame_t b = v->getFrameForX(x + 10); TextModel::PointList onPoints = m_model->getPoints(a, b); if (onPoints.empty()) return false; - float nearestDistance = -1; + double nearestDistance = -1; for (TextModel::PointList::const_iterator i = onPoints.begin(); i != onPoints.end(); ++i) { - int yd = getYForHeight(v, (*i).height) - y; - int xd = v->getXForFrame((*i).frame) - x; - float distance = sqrtf(yd*yd + xd*xd); + double yd = getYForHeight(v, (*i).height) - y; + double xd = v->getXForFrame((*i).frame) - x; + double distance = sqrt(yd*yd + xd*xd); if (nearestDistance == -1 || distance < nearestDistance) { nearestDistance = distance; @@ -198,7 +198,7 @@ } } - long useFrame = points.begin()->frame; + sv_frame_t useFrame = points.begin()->frame; RealTime rt = RealTime::frame2RealTime(useFrame, m_model->getSampleRate()); @@ -220,7 +220,7 @@ //!!! too much overlap with TimeValueLayer/TimeInstantLayer bool -TextLayer::snapToFeatureFrame(View *v, int &frame, +TextLayer::snapToFeatureFrame(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const { @@ -240,7 +240,7 @@ } points = m_model->getPoints(frame, frame); - int snapped = frame; + sv_frame_t snapped = frame; bool found = false; for (TextModel::PointList::const_iterator i = points.begin(); @@ -292,17 +292,17 @@ } int -TextLayer::getYForHeight(View *v, float height) const +TextLayer::getYForHeight(View *v, double height) const { int h = v->height(); return h - int(height * h); } -float +double TextLayer::getHeightForY(View *v, int y) const { int h = v->height(); - return float(h - y) / h; + return double(h - y) / h; } void @@ -310,14 +310,14 @@ { if (!m_model || !m_model->isOK()) return; - int sampleRate = m_model->getSampleRate(); + sv_samplerate_t sampleRate = m_model->getSampleRate(); if (!sampleRate) return; // Profiler profiler("TextLayer::paint", true); int x0 = rect.left(), x1 = rect.right(); - long frame0 = v->getFrameForX(x0); - long frame1 = v->getFrameForX(x1); + sv_frame_t frame0 = v->getFrameForX(x0); + sv_frame_t frame1 = v->getFrameForX(x1); TextModel::PointList points(m_model->getPoints(frame0, frame1)); if (points.empty()) return; @@ -420,13 +420,13 @@ return; } - long frame = v->getFrameForX(e->x()); + sv_frame_t frame = v->getFrameForX(e->x()); if (frame < 0) frame = 0; frame = frame / m_model->getResolution() * m_model->getResolution(); - float height = getHeightForY(v, e->y()); + double height = getHeightForY(v, e->y()); - m_editingPoint = TextModel::Point(frame, height, ""); + m_editingPoint = TextModel::Point(frame, float(height), ""); m_originalPoint = m_editingPoint; if (m_editingCommand) finish(m_editingCommand); @@ -443,15 +443,15 @@ if (!m_model || !m_editing) return; - long frame = v->getFrameForX(e->x()); + sv_frame_t frame = v->getFrameForX(e->x()); if (frame < 0) frame = 0; frame = frame / m_model->getResolution() * m_model->getResolution(); - float height = getHeightForY(v, e->y()); + double height = getHeightForY(v, e->y()); m_editingCommand->deletePoint(m_editingPoint); m_editingPoint.frame = frame; - m_editingPoint.height = height; + m_editingPoint.height = float(height); m_editingCommand->addPoint(m_editingPoint); } @@ -547,17 +547,17 @@ { if (!m_model || !m_editing) return; - long frameDiff = v->getFrameForX(e->x()) - v->getFrameForX(m_editOrigin.x()); - float heightDiff = getHeightForY(v, e->y()) - getHeightForY(v, m_editOrigin.y()); + sv_frame_t frameDiff = v->getFrameForX(e->x()) - v->getFrameForX(m_editOrigin.x()); + double heightDiff = getHeightForY(v, e->y()) - getHeightForY(v, m_editOrigin.y()); - long frame = m_originalPoint.frame + frameDiff; - float height = m_originalPoint.height + heightDiff; + sv_frame_t frame = m_originalPoint.frame + frameDiff; + double height = m_originalPoint.height + heightDiff; -// long frame = v->getFrameForX(e->x()); +// sv_frame_t frame = v->getFrameForX(e->x()); if (frame < 0) frame = 0; frame = (frame / m_model->getResolution()) * m_model->getResolution(); -// float height = getHeightForY(v, e->y()); +// double height = getHeightForY(v, e->y()); if (!m_editingCommand) { m_editingCommand = new TextModel::EditCommand(m_model, tr("Drag Label")); @@ -565,7 +565,7 @@ m_editingCommand->deletePoint(m_editingPoint); m_editingPoint.frame = frame; - m_editingPoint.height = height; + m_editingPoint.height = float(height); m_editingCommand->addPoint(m_editingPoint); } @@ -621,7 +621,7 @@ } void -TextLayer::moveSelection(Selection s, int newStartFrame) +TextLayer::moveSelection(Selection s, sv_frame_t newStartFrame) { if (!m_model) return; @@ -665,9 +665,9 @@ if (s.contains(i->frame)) { - double target = i->frame; - target = newSize.getStartFrame() + - double(target - s.getStartFrame()) * ratio; + double target = double(i->frame); + target = double(newSize.getStartFrame()) + + target - double(s.getStartFrame()) * ratio; TextModel::Point newPoint(*i); newPoint.frame = lrint(target); @@ -717,7 +717,7 @@ } bool -TextLayer::paste(View *v, const Clipboard &from, int /* frameOffset */, bool /* interactive */) +TextLayer::paste(View *v, const Clipboard &from, sv_frame_t /* frameOffset */, bool /* interactive */) { if (!m_model) return false; @@ -745,7 +745,7 @@ TextModel::EditCommand *command = new TextModel::EditCommand(m_model, tr("Paste")); - float valueMin = 0.0, valueMax = 1.0; + double valueMin = 0.0, valueMax = 1.0; for (Clipboard::PointList::const_iterator i = points.begin(); i != points.end(); ++i) { if (i->haveValue()) { @@ -759,7 +759,7 @@ i != points.end(); ++i) { if (!i->haveFrame()) continue; - int frame = 0; + sv_frame_t frame = 0; if (!realign) { @@ -778,9 +778,9 @@ TextModel::Point newPoint(frame); if (i->haveValue()) { - newPoint.height = (i->getValue() - valueMin) / (valueMax - valueMin); + newPoint.height = float((i->getValue() - valueMin) / (valueMax - valueMin)); } else { - newPoint.height = 0.5; + newPoint.height = 0.5f; } if (i->haveLabel()) { diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/TextLayer.h --- a/layer/TextLayer.h Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/TextLayer.h Mon Mar 23 11:26:28 2015 +0000 @@ -36,7 +36,7 @@ virtual QString getFeatureDescription(View *v, QPoint &) const; - virtual bool snapToFeatureFrame(View *v, int &frame, + virtual bool snapToFeatureFrame(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const; @@ -52,12 +52,12 @@ virtual void editDrag(View *v, QMouseEvent *); virtual void editEnd(View *v, QMouseEvent *); - virtual void moveSelection(Selection s, int newStartFrame); + virtual void moveSelection(Selection s, sv_frame_t newStartFrame); virtual void resizeSelection(Selection s, Selection newSize); virtual void deleteSelection(Selection s); virtual void copy(View *v, Selection s, Clipboard &to); - virtual bool paste(View *v, const Clipboard &from, int frameOffset, + virtual bool paste(View *v, const Clipboard &from, sv_frame_t frameOffset, bool interactive); virtual bool editOpen(View *, QMouseEvent *); // on double-click @@ -80,7 +80,7 @@ virtual int getCompletion(View *) const { return m_model->getCompletion(); } - virtual bool getValueExtents(float &min, float &max, + virtual bool getValueExtents(double &min, double &max, bool &logarithmic, QString &unit) const; virtual int getVerticalScaleWidth(View *, bool, QPainter &) const { return 0; } @@ -91,8 +91,8 @@ void setProperties(const QXmlAttributes &attributes); protected: - int getYForHeight(View *v, float height) const; - float getHeightForY(View *v, int y) const; + int getYForHeight(View *v, double height) const; + double getHeightForY(View *v, int y) const; virtual int getDefaultColourHint(bool dark, bool &impose); diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/TimeInstantLayer.cpp --- a/layer/TimeInstantLayer.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/TimeInstantLayer.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -201,7 +201,7 @@ } QString -TimeInstantLayer::getLabelPreceding(int frame) const +TimeInstantLayer::getLabelPreceding(sv_frame_t frame) const { if (!m_model) return ""; SparseOneDimensionalModel::PointList points = m_model->getPreviousPoints(frame); @@ -249,7 +249,7 @@ } bool -TimeInstantLayer::snapToFeatureFrame(View *v, int &frame, +TimeInstantLayer::snapToFeatureFrame(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const { @@ -269,7 +269,7 @@ } points = m_model->getPoints(frame, frame); - int snapped = frame; + sv_frame_t snapped = frame; bool found = false; for (SparseOneDimensionalModel::PointList::const_iterator i = points.begin(); @@ -666,7 +666,7 @@ } void -TimeInstantLayer::moveSelection(Selection s, int newStartFrame) +TimeInstantLayer::moveSelection(Selection s, sv_frame_t newStartFrame) { if (!m_model) return; @@ -712,9 +712,9 @@ if (s.contains(i->frame)) { - double target = i->frame; - target = newSize.getStartFrame() + - double(target - s.getStartFrame()) * ratio; + double target = double(i->frame); + target = double(newSize.getStartFrame()) + + target - double(s.getStartFrame()) * ratio; SparseOneDimensionalModel::Point newPoint(*i); newPoint.frame = lrint(target); @@ -765,7 +765,7 @@ } bool -TimeInstantLayer::paste(View *v, const Clipboard &from, int frameOffset, bool) +TimeInstantLayer::paste(View *v, const Clipboard &from, sv_frame_t frameOffset, bool) { if (!m_model) return false; @@ -798,7 +798,7 @@ if (!i->haveFrame()) continue; - int frame = 0; + sv_frame_t frame = 0; if (!realign) { diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/TimeInstantLayer.h --- a/layer/TimeInstantLayer.h Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/TimeInstantLayer.h Mon Mar 23 11:26:28 2015 +0000 @@ -35,10 +35,10 @@ virtual void paint(View *v, QPainter &paint, QRect rect) const; - virtual QString getLabelPreceding(int) const; + virtual QString getLabelPreceding(sv_frame_t) const; virtual QString getFeatureDescription(View *v, QPoint &) const; - virtual bool snapToFeatureFrame(View *v, int &frame, + virtual bool snapToFeatureFrame(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const; @@ -56,12 +56,12 @@ virtual bool editOpen(View *, QMouseEvent *); - virtual void moveSelection(Selection s, int newStartFrame); + virtual void moveSelection(Selection s, sv_frame_t newStartFrame); virtual void resizeSelection(Selection s, Selection newSize); virtual void deleteSelection(Selection s); virtual void copy(View *v, Selection s, Clipboard &to); - virtual bool paste(View *v, const Clipboard &from, int frameOffset, + virtual bool paste(View *v, const Clipboard &from, sv_frame_t frameOffset, bool interactive); virtual const Model *getModel() const { return m_model; } @@ -92,7 +92,7 @@ virtual bool needsTextLabelHeight() const { return m_model->hasTextLabels(); } - virtual bool getValueExtents(float &, float &, bool &, QString &) const { + virtual bool getValueExtents(double &, double &, bool &, QString &) const { return false; } diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/TimeRulerLayer.cpp --- a/layer/TimeRulerLayer.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/TimeRulerLayer.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -49,7 +49,7 @@ } bool -TimeRulerLayer::snapToFeatureFrame(View *v, int &frame, +TimeRulerLayer::snapToFeatureFrame(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const { if (!m_model) { @@ -60,7 +60,7 @@ bool q; int tick = getMajorTickSpacing(v, q); RealTime rtick = RealTime::fromMilliseconds(tick); - int rate = m_model->getSampleRate(); + sv_samplerate_t rate = m_model->getSampleRate(); RealTime rt = RealTime::frame2RealTime(frame, rate); double ratio = rt / rtick; @@ -68,9 +68,9 @@ int rounded = int(ratio); RealTime rdrt = rtick * rounded; - int left = RealTime::realTime2Frame(rdrt, rate); - resolution = RealTime::realTime2Frame(rtick, rate); - int right = left + resolution; + sv_frame_t left = RealTime::realTime2Frame(rdrt, rate); + resolution = int(RealTime::realTime2Frame(rtick, rate)); + sv_frame_t right = left + resolution; // SVDEBUG << "TimeRulerLayer::snapToFeatureFrame: type " // << int(snap) << ", frame " << frame << " (time " @@ -88,7 +88,7 @@ case SnapNearest: { - if (abs(frame - left) > abs(right - frame)) { + if (labs(frame - left) > labs(right - frame)) { frame = right; } else { frame = left; @@ -147,11 +147,11 @@ if (!m_model || !v) return 1000; - int sampleRate = m_model->getSampleRate(); + sv_samplerate_t sampleRate = m_model->getSampleRate(); if (!sampleRate) return 1000; - long startFrame = v->getStartFrame(); - long endFrame = v->getEndFrame(); + sv_frame_t startFrame = v->getStartFrame(); + sv_frame_t endFrame = v->getEndFrame(); int minPixelSpacing = 50; @@ -201,10 +201,10 @@ if (!m_model || !m_model->isOK()) return; - int sampleRate = m_model->getSampleRate(); + sv_samplerate_t sampleRate = m_model->getSampleRate(); if (!sampleRate) return; - long startFrame = v->getFrameForX(rect.x() - 50); + sv_frame_t startFrame = v->getFrameForX(rect.x() - 50); #ifdef DEBUG_TIME_RULER_LAYER cerr << "start frame = " << startFrame << endl; @@ -213,7 +213,7 @@ bool quarter = false; int incms = getMajorTickSpacing(v, quarter); - int ms = lrint(1000.0 * (double(startFrame) / double(sampleRate))); + int ms = int(lrint(1000.0 * (double(startFrame) / double(sampleRate)))); ms = (ms / incms) * incms - incms; #ifdef DEBUG_TIME_RULER_LAYER @@ -226,8 +226,8 @@ // draw the actual ticks or lines. int minPixelSpacing = 50; - long incFrame = (incms * sampleRate) / 1000; - int incX = incFrame / v->getZoomLevel(); + sv_frame_t incFrame = lrint((incms * sampleRate) / 1000); + int incX = int(incFrame / v->getZoomLevel()); int ticks = 10; if (incX < minPixelSpacing * 2) { ticks = quarter ? 4 : 5; @@ -249,7 +249,7 @@ // re-drawing with a different start frame). double dms = ms; - long frame = lrint((dms * sampleRate) / 1000.0); + sv_frame_t frame = lrint((dms * sampleRate) / 1000.0); frame /= v->getZoomLevel(); frame *= v->getZoomLevel(); // so frame corresponds to an exact pixel diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/TimeRulerLayer.h --- a/layer/TimeRulerLayer.h Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/TimeRulerLayer.h Mon Mar 23 11:26:28 2015 +0000 @@ -41,13 +41,13 @@ void setLabelHeight(LabelHeight h) { m_labelHeight = h; } LabelHeight getLabelHeight() const { return m_labelHeight; } - virtual bool snapToFeatureFrame(View *, int &, int &, SnapType) const; + virtual bool snapToFeatureFrame(View *, sv_frame_t &, int &, SnapType) const; virtual ColourSignificance getLayerColourSignificance() const { return ColourIrrelevant; } - virtual bool getValueExtents(float &, float &, bool &, QString &) const { + virtual bool getValueExtents(double &, double &, bool &, QString &) const { return false; } diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/TimeValueLayer.cpp --- a/layer/TimeValueLayer.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/TimeValueLayer.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -329,7 +329,7 @@ } bool -TimeValueLayer::getValueExtents(float &min, float &max, +TimeValueLayer::getValueExtents(double &min, double &max, bool &logarithmic, QString &unit) const { if (!m_model) return false; @@ -342,7 +342,7 @@ unit = getScaleUnits(); if (m_derivative) { - max = std::max(fabsf(min), fabsf(max)); + max = std::max(fabs(min), fabs(max)); min = -max; } @@ -356,7 +356,7 @@ max = max + 0.5; min = min - 0.5; } else { - float margin = (max - min) / 10.0; + double margin = (max - min) / 10.0; max = max + margin; min = min - margin; } @@ -370,7 +370,7 @@ } bool -TimeValueLayer::getDisplayExtents(float &min, float &max) const +TimeValueLayer::getDisplayExtents(double &min, double &max) const { if (!m_model || shouldAutoAlign()) return false; @@ -384,7 +384,7 @@ } if (m_derivative) { - max = std::max(fabsf(min), fabsf(max)); + max = std::max(fabs(min), fabs(max)); min = -max; } @@ -396,7 +396,7 @@ } bool -TimeValueLayer::setDisplayExtents(float min, float max) +TimeValueLayer::setDisplayExtents(double min, double max) { if (!m_model) return false; @@ -438,7 +438,7 @@ RangeMapper *mapper = getNewVerticalZoomRangeMapper(); if (!mapper) return 0; - float dmin, dmax; + double dmin, dmax; getDisplayExtents(dmin, dmax); int nr = mapper->getPositionForValue(dmax - dmin); @@ -461,23 +461,23 @@ RangeMapper *mapper = getNewVerticalZoomRangeMapper(); if (!mapper) return; - float min, max; + double min, max; bool logarithmic; QString unit; getValueExtents(min, max, logarithmic, unit); - float dmin, dmax; + double dmin, dmax; getDisplayExtents(dmin, dmax); - float newdist = mapper->getValueForPosition(100 - step); + double newdist = mapper->getValueForPosition(100 - step); - float newmin, newmax; + double newmin, newmax; if (logarithmic) { // see SpectrogramLayer::setVerticalZoomStep - newmax = (newdist + sqrtf(newdist*newdist + 4*dmin*dmax)) / 2; + newmax = (newdist + sqrt(newdist*newdist + 4*dmin*dmax)) / 2; newmin = newmax - newdist; #ifdef DEBUG_TIME_VALUE_LAYER @@ -485,7 +485,7 @@ #endif } else { - float dmid = (dmax + dmin) / 2; + double dmid = (dmax + dmin) / 2; newmin = dmid - newdist / 2; newmax = dmid + newdist / 2; } @@ -512,7 +512,7 @@ RangeMapper *mapper; - float min, max; + double min, max; bool logarithmic; QString unit; getValueExtents(min, max, logarithmic, unit); @@ -533,7 +533,7 @@ { if (!m_model) return SparseTimeValueModel::PointList(); - long frame = v->getFrameForX(x); + sv_frame_t frame = v->getFrameForX(x); SparseTimeValueModel::PointList onPoints = m_model->getPoints(frame); @@ -553,7 +553,7 @@ usePoints = nextPoints; } else if (nextPoints.empty()) { // stick with prevPoints - } else if (long(prevPoints.begin()->frame) < v->getStartFrame() && + } else if (prevPoints.begin()->frame < v->getStartFrame() && !(nextPoints.begin()->frame > v->getEndFrame())) { usePoints = nextPoints; } else if (nextPoints.begin()->frame - frame < @@ -574,7 +574,7 @@ } QString -TimeValueLayer::getLabelPreceding(int frame) const +TimeValueLayer::getLabelPreceding(sv_frame_t frame) const { if (!m_model) return ""; SparseTimeValueModel::PointList points = m_model->getPreviousPoints(frame); @@ -602,7 +602,7 @@ } } - long useFrame = points.begin()->frame; + sv_frame_t useFrame = points.begin()->frame; RealTime rt = RealTime::frame2RealTime(useFrame, m_model->getSampleRate()); @@ -629,7 +629,7 @@ } bool -TimeValueLayer::snapToFeatureFrame(View *v, int &frame, +TimeValueLayer::snapToFeatureFrame(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const { @@ -649,7 +649,7 @@ } points = m_model->getPoints(frame, frame); - int snapped = frame; + sv_frame_t snapped = frame; bool found = false; for (SparseTimeValueModel::PointList::const_iterator i = points.begin(); @@ -701,7 +701,7 @@ } bool -TimeValueLayer::snapToSimilarFeature(View *v, int &frame, +TimeValueLayer::snapToSimilarFeature(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const { @@ -716,8 +716,8 @@ SparseTimeValueModel::PointList::const_iterator i; - int matchframe = frame; - float matchvalue = 0.f; + sv_frame_t matchframe = frame; + double matchvalue = 0.0; for (i = close.begin(); i != close.end(); ++i) { if (i->frame > frame) break; @@ -725,10 +725,10 @@ matchframe = i->frame; } - int snapped = frame; + sv_frame_t snapped = frame; bool found = false; bool distant = false; - float epsilon = 0.0001; + double epsilon = 0.0001; i = close.begin(); @@ -753,7 +753,7 @@ if (snap == SnapRight) { if (i->frame > matchframe && - fabsf(i->value - matchvalue) < epsilon) { + fabs(i->value - matchvalue) < epsilon) { snapped = i->frame; found = true; break; @@ -762,7 +762,7 @@ } else if (snap == SnapLeft) { if (i->frame < matchframe) { - if (fabsf(i->value - matchvalue) < epsilon) { + if (fabs(i->value - matchvalue) < epsilon) { snapped = i->frame; found = true; // don't break, as the next may be better } @@ -782,7 +782,7 @@ } void -TimeValueLayer::getScaleExtents(View *v, float &min, float &max, bool &log) const +TimeValueLayer::getScaleExtents(View *v, double &min, double &max, bool &log) const { min = 0.0; max = 0.0; @@ -818,9 +818,9 @@ } int -TimeValueLayer::getYForValue(View *v, float val) const +TimeValueLayer::getYForValue(View *v, double val) const { - float min = 0.0, max = 0.0; + double min = 0.0, max = 0.0; bool logarithmic = false; int h = v->height(); @@ -838,16 +838,16 @@ return int(h - ((val - min) * h) / (max - min)); } -float +double TimeValueLayer::getValueForY(View *v, int y) const { - float min = 0.0, max = 0.0; + double min = 0.0, max = 0.0; bool logarithmic = false; int h = v->height(); getScaleExtents(v, min, max, logarithmic); - float val = min + (float(h - y) * float(max - min)) / h; + double val = min + (double(h - y) * double(max - min)) / h; if (logarithmic) { val = LogRange::map(val); @@ -865,9 +865,9 @@ } QColor -TimeValueLayer::getColourForValue(View *v, float val) const +TimeValueLayer::getColourForValue(View *v, double val) const { - float min, max; + double min, max; bool log; getScaleExtents(v, min, max, log); @@ -900,7 +900,7 @@ { if (!m_model || !m_model->isOK()) return; - int sampleRate = m_model->getSampleRate(); + sv_samplerate_t sampleRate = m_model->getSampleRate(); if (!sampleRate) return; paint.setRenderHint(QPainter::Antialiasing, false); @@ -908,8 +908,8 @@ // Profiler profiler("TimeValueLayer::paint", true); int x0 = rect.left(), x1 = rect.right(); - long frame0 = v->getFrameForX(x0); - long frame1 = v->getFrameForX(x1); + sv_frame_t frame0 = v->getFrameForX(x0); + sv_frame_t frame1 = v->getFrameForX(x1); if (m_derivative) --frame0; SparseTimeValueModel::PointList points(m_model->getPoints @@ -927,15 +927,15 @@ << m_model->getResolution() << " frames" << endl; #endif - float min = m_model->getValueMinimum(); - float max = m_model->getValueMaximum(); + double min = m_model->getValueMinimum(); + double max = m_model->getValueMaximum(); if (max == min) max = min + 1.0; int origin = int(nearbyint(v->height() - (-min * v->height()) / (max - min))); QPoint localPos; - long illuminateFrame = -1; + sv_frame_t illuminateFrame = -1; if (v->shouldIlluminateLocalFeatures(this, localPos)) { SparseTimeValueModel::PointList localPoints = @@ -974,7 +974,7 @@ } } - int prevFrame = 0; + sv_frame_t prevFrame = 0; for (SparseTimeValueModel::PointList::const_iterator i = points.begin(); i != points.end(); ++i) { @@ -983,7 +983,7 @@ const SparseTimeValueModel::Point &p(*i); - float value = p.value; + double value = p.value; if (m_derivative) { SparseTimeValueModel::PointList::const_iterator j = i; --j; @@ -1012,8 +1012,8 @@ } bool haveNext = false; - float nvalue = 0.f; - int nf = v->getModelsEndFrame(); + double nvalue = 0.f; + sv_frame_t nf = v->getModelsEndFrame(); int nx = v->getXForFrame(nf); int ny = y; @@ -1122,11 +1122,11 @@ } else { - float x0 = x + float(w)/2; - float x1 = nx + float(w)/2; + double x0 = x + double(w)/2; + double x1 = nx + double(w)/2; - float y0 = y; - float y1 = ny; + double y0 = y; + double y1 = ny; if (m_plotStyle == PlotDiscreteCurves) { bool nextGap = @@ -1255,7 +1255,7 @@ if (!m_model || m_model->getPoints().empty()) return; QString unit; - float min, max; + double min, max; bool logarithmic; int w = getVerticalScaleWidth(v, false, paint); @@ -1310,12 +1310,12 @@ if (!m_model) return; - long frame = v->getFrameForX(e->x()); - long resolution = m_model->getResolution(); + sv_frame_t frame = v->getFrameForX(e->x()); + int resolution = m_model->getResolution(); if (frame < 0) frame = 0; frame = (frame / resolution) * resolution; - float value = getValueForY(v, e->y()); + double value = getValueForY(v, e->y()); bool havePoint = false; @@ -1336,7 +1336,7 @@ if (!havePoint) { m_editingPoint = SparseTimeValueModel::Point - (frame, value, tr("New Point")); + (frame, float(value), tr("New Point")); } m_originalPoint = m_editingPoint; @@ -1360,12 +1360,12 @@ if (!m_model || !m_editing) return; - long frame = v->getFrameForX(e->x()); - long resolution = m_model->getResolution(); + sv_frame_t frame = v->getFrameForX(e->x()); + int resolution = m_model->getResolution(); if (frame < 0) frame = 0; frame = (frame / resolution) * resolution; - float value = getValueForY(v, e->y()); + double value = getValueForY(v, e->y()); SparseTimeValueModel::PointList points = getLocalPoints(v, e->x()); @@ -1409,7 +1409,7 @@ // m_editingCommand->deletePoint(m_editingPoint); m_editingPoint.frame = frame; - m_editingPoint.value = value; + m_editingPoint.value = float(value); m_editingCommand->addPoint(m_editingPoint); } @@ -1502,11 +1502,11 @@ if (!m_model || !m_editing) return; - long frame = v->getFrameForX(e->x()); + sv_frame_t frame = v->getFrameForX(e->x()); if (frame < 0) frame = 0; frame = frame / m_model->getResolution() * m_model->getResolution(); - float value = getValueForY(v, e->y()); + double value = getValueForY(v, e->y()); if (!m_editingCommand) { m_editingCommand = new SparseTimeValueModel::EditCommand(m_model, @@ -1515,7 +1515,7 @@ m_editingCommand->deletePoint(m_editingPoint); m_editingPoint.frame = frame; - m_editingPoint.value = value; + m_editingPoint.value = float(value); m_editingCommand->addPoint(m_editingPoint); } @@ -1589,7 +1589,7 @@ } void -TimeValueLayer::moveSelection(Selection s, int newStartFrame) +TimeValueLayer::moveSelection(Selection s, sv_frame_t newStartFrame) { if (!m_model) return; @@ -1635,9 +1635,9 @@ if (s.contains(i->frame)) { - double target = i->frame; - target = newSize.getStartFrame() + - double(target - s.getStartFrame()) * ratio; + double target = double(i->frame); + target = double(newSize.getStartFrame()) + + target - double(s.getStartFrame()) * ratio; SparseTimeValueModel::Point newPoint(*i); newPoint.frame = lrint(target); @@ -1691,7 +1691,7 @@ } bool -TimeValueLayer::paste(View *v, const Clipboard &from, int /* frameOffset */, +TimeValueLayer::paste(View *v, const Clipboard &from, sv_frame_t /* frameOffset */, bool interactive) { if (!m_model) return false; @@ -1834,7 +1834,7 @@ if (!i->haveFrame()) continue; - int frame = 0; + sv_frame_t frame = 0; if (!realign) { diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/TimeValueLayer.h --- a/layer/TimeValueLayer.h Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/TimeValueLayer.h Mon Mar 23 11:26:28 2015 +0000 @@ -43,12 +43,12 @@ virtual void paintVerticalScale(View *v, bool, QPainter &paint, QRect rect) const; virtual QString getFeatureDescription(View *v, QPoint &) const; - virtual QString getLabelPreceding(int) const; + virtual QString getLabelPreceding(sv_frame_t) const; - virtual bool snapToFeatureFrame(View *v, int &frame, + virtual bool snapToFeatureFrame(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const; - virtual bool snapToSimilarFeature(View *v, int &frame, + virtual bool snapToSimilarFeature(View *v, sv_frame_t &frame, int &resolution, SnapType snap) const; @@ -66,12 +66,12 @@ virtual bool editOpen(View *v, QMouseEvent *); - virtual void moveSelection(Selection s, int newStartFrame); + virtual void moveSelection(Selection s, sv_frame_t newStartFrame); virtual void resizeSelection(Selection s, Selection newSize); virtual void deleteSelection(Selection s); virtual void copy(View *v, Selection s, Clipboard &to); - virtual bool paste(View *v, const Clipboard &from, int frameOffset, + virtual bool paste(View *v, const Clipboard &from, sv_frame_t frameOffset, bool interactive); virtual const Model *getModel() const { return m_model; } @@ -130,11 +130,11 @@ return m_plotStyle == PlotSegmentation && m_model->hasTextLabels(); } - virtual bool getValueExtents(float &min, float &max, + virtual bool getValueExtents(double &min, double &max, bool &logarithmic, QString &unit) const; - virtual bool getDisplayExtents(float &min, float &max) const; - virtual bool setDisplayExtents(float min, float max); + virtual bool getDisplayExtents(double &min, double &max) const; + virtual bool setDisplayExtents(double min, double max); virtual int getVerticalZoomSteps(int &defaultStep) const; virtual int getCurrentVerticalZoomStep() const; @@ -155,13 +155,13 @@ } /// VerticalScaleLayer and ColourScaleLayer methods - virtual int getYForValue(View *, float value) const; - virtual float getValueForY(View *, int y) const; + virtual int getYForValue(View *, double value) const; + virtual double getValueForY(View *, int y) const; virtual QString getScaleUnits() const; - virtual QColor getColourForValue(View *v, float value) const; + virtual QColor getColourForValue(View *v, double value) const; protected: - void getScaleExtents(View *, float &min, float &max, bool &log) const; + void getScaleExtents(View *, double &min, double &max, bool &log) const; bool shouldAutoAlign() const; SparseTimeValueModel::PointList getLocalPoints(View *v, int) const; @@ -179,8 +179,8 @@ bool m_drawSegmentDivisions; bool m_derivative; - mutable float m_scaleMinimum; - mutable float m_scaleMaximum; + mutable double m_scaleMinimum; + mutable double m_scaleMaximum; void finish(SparseTimeValueModel::EditCommand *command) { Command *c = command->finish(); diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/VerticalScaleLayer.h --- a/layer/VerticalScaleLayer.h Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/VerticalScaleLayer.h Mon Mar 23 11:26:28 2015 +0000 @@ -19,8 +19,8 @@ class VerticalScaleLayer { public: - virtual int getYForValue(View *, float value) const = 0; - virtual float getValueForY(View *, int y) const = 0; + virtual int getYForValue(View *, double value) const = 0; + virtual double getValueForY(View *, int y) const = 0; virtual QString getScaleUnits() const = 0; }; diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/WaveformLayer.cpp --- a/layer/WaveformLayer.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/WaveformLayer.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -153,7 +153,7 @@ *max = 50; *deflt = 0; - val = lrint(log10(m_gain) * 20.0); + val = int(lrint(log10(m_gain) * 20.0)); if (val < *min) val = *min; if (val > *max) val = *max; @@ -222,7 +222,7 @@ WaveformLayer::setProperty(const PropertyName &name, int value) { if (name == "Gain") { - setGain(pow(10, float(value)/20.0)); + setGain(float(pow(10, float(value)/20.0))); } else if (name == "Normalize Visible Area") { setAutoNormalize(value ? true : false); } else if (name == "Channels") { @@ -308,7 +308,7 @@ } void -WaveformLayer::setMiddleLineHeight(float height) +WaveformLayer::setMiddleLineHeight(double height) { if (m_middleLineHeight == height) return; m_middleLineHeight = height; @@ -335,7 +335,7 @@ } bool -WaveformLayer::getValueExtents(float &min, float &max, +WaveformLayer::getValueExtents(double &min, double &max, bool &, QString &unit) const { if (m_scale == LinearScale) { @@ -353,10 +353,10 @@ } int -WaveformLayer::dBscale(float sample, int m) const +WaveformLayer::dBscale(double sample, int m) const { if (sample < 0.0) return dBscale(-sample, m); - float dB = AudioLevel::multiplier_to_dB(sample); + double dB = AudioLevel::multiplier_to_dB(sample); if (dB < -50.0) return 0; if (dB > 0.0) return m; return int(((dB + 50.0) * m) / 50.0 + 0.1); @@ -409,9 +409,9 @@ bool WaveformLayer::getSourceFramesForX(View *v, int x, int modelZoomLevel, - int &f0, int &f1) const + sv_frame_t &f0, sv_frame_t &f1) const { - int viewFrame = v->getFrameForX(x); + sv_frame_t viewFrame = v->getFrameForX(x); if (viewFrame < 0) { f0 = 0; f1 = 0; @@ -435,13 +435,13 @@ float WaveformLayer::getNormalizeGain(View *v, int channel) const { - int startFrame = v->getStartFrame(); - int endFrame = v->getEndFrame(); + sv_frame_t startFrame = v->getStartFrame(); + sv_frame_t endFrame = v->getEndFrame(); - int modelStart = m_model->getStartFrame(); - int modelEnd = m_model->getEndFrame(); + sv_frame_t modelStart = m_model->getStartFrame(); + sv_frame_t modelEnd = m_model->getEndFrame(); - int rangeStart, rangeEnd; + sv_frame_t rangeStart, rangeEnd; if (startFrame < modelStart) rangeStart = modelStart; else rangeStart = startFrame; @@ -469,7 +469,7 @@ range.setAbsmean(std::min(range.absmean(), otherRange.absmean())); } - return 1.0 / std::max(fabsf(range.max()), fabsf(range.min())); + return float(1.0 / std::max(fabs(range.max()), fabs(range.min()))); } void @@ -543,9 +543,9 @@ if (m_middleLineHeight != 0.5) { paint->save(); - float space = m_middleLineHeight * 2; + double space = m_middleLineHeight * 2; if (space > 1.0) space = 2.0 - space; - float yt = h * (m_middleLineHeight - space/2); + double yt = h * (m_middleLineHeight - space/2); paint->translate(QPointF(0, yt)); paint->scale(1.0, space); } @@ -572,9 +572,9 @@ int modelZoomLevel = m_model->getSummaryBlockSize(zoomLevel); - int frame0; - int frame1; - int spare; + sv_frame_t frame0; + sv_frame_t frame1; + sv_frame_t spare; getSourceFramesForX(v, x0, modelZoomLevel, frame0, spare); getSourceFramesForX(v, x1, modelZoomLevel, spare, frame1); @@ -616,7 +616,7 @@ m_effectiveGains[ch] = getNormalizeGain(v, ch); } - float gain = m_effectiveGains[ch]; + double gain = m_effectiveGains[ch]; int m = (h / channels) / 2; int my = m + (((ch - minChannel) * h) / channels); @@ -647,7 +647,7 @@ for (int i = 1; i < n; ++i) { - float val = 0.0, nval = 0.0; + double val = 0.0, nval = 0.0; switch (m_scale) { @@ -710,7 +710,7 @@ range = RangeSummarisableTimeValueModel::Range(); - int f0, f1; + sv_frame_t f0, f1; if (!getSourceFramesForX(v, x, modelZoomLevel, f0, f1)) continue; f1 = f1 - 1; @@ -719,8 +719,8 @@ continue; } - int i0 = (f0 - frame0) / modelZoomLevel; - int i1 = (f1 - frame0) / modelZoomLevel; + sv_frame_t i0 = (f0 - frame0) / modelZoomLevel; + sv_frame_t i1 = (f1 - frame0) / modelZoomLevel; #ifdef DEBUG_WAVEFORM_PAINT cerr << "WaveformLayer::paint: pixel " << x << ": i0 " << i0 << " (f " << f0 << "), i1 " << i1 << " (f " << f1 << ")" << endl; @@ -784,10 +784,10 @@ switch (m_scale) { case LinearScale: - rangeBottom = int( m * greyLevels * range.min() * gain); - rangeTop = int( m * greyLevels * range.max() * gain); - meanBottom = int(-m * range.absmean() * gain); - meanTop = int( m * range.absmean() * gain); + rangeBottom = int(double(m * greyLevels) * range.min() * gain); + rangeTop = int(double(m * greyLevels) * range.max() * gain); + meanBottom = int(double(-m) * range.absmean() * gain); + meanTop = int(double(m) * range.absmean() * gain); break; case dBScale: @@ -963,7 +963,7 @@ int modelZoomLevel = m_model->getSummaryBlockSize(zoomLevel); - int f0, f1; + sv_frame_t f0, f1; if (!getSourceFramesForX(v, x, modelZoomLevel, f0, f1)) return ""; QString text; @@ -1005,18 +1005,18 @@ } bool singleValue = false; - float min, max; + double min, max; if (fabs(range.min()) < 0.01) { min = range.min(); max = range.max(); singleValue = (min == max); } else { - int imin = lrint(range.min() * 10000); - int imax = lrint(range.max() * 10000); + int imin = int(lrint(range.min() * 10000)); + int imax = int(lrint(range.max() * 10000)); singleValue = (imin == imax); - min = float(imin)/10000; - max = float(imax)/10000; + min = double(imin)/10000; + max = double(imax)/10000; } int db = int(AudioLevel::multiplier_to_dB(std::max(fabsf(range.min()), @@ -1025,10 +1025,10 @@ if (!singleValue) { text += tr("\n%1\t%2 - %3 (%4 dB peak)") - .arg(label).arg(min).arg(max).arg(float(db)/100); + .arg(label).arg(min).arg(max).arg(double(db)/100); } else { text += tr("\n%1\t%2 (%3 dB peak)") - .arg(label).arg(min).arg(float(db)/100); + .arg(label).arg(min).arg(double(db)/100); } } @@ -1036,7 +1036,7 @@ } int -WaveformLayer::getYForValue(const View *v, float value, int channel) const +WaveformLayer::getYForValue(const View *v, double value, int channel) const { int channels = 0, minChannel = 0, maxChannel = 0; bool mergingChannels = false, mixingChannels = false; @@ -1078,7 +1078,7 @@ return my - vy; } -float +double WaveformLayer::getValueForY(const View *v, int y, int &channel) const { int channels = 0, minChannel = 0, maxChannel = 0; @@ -1102,13 +1102,13 @@ int my = m + (((channel - minChannel) * h) / channels); int vy = my - y; - float value = 0; - float thresh = -50.f; + double value = 0; + double thresh = -50.f; switch (m_scale) { case LinearScale: - value = float(vy) / m; + value = double(vy) / m; break; case MeterScale: @@ -1116,7 +1116,7 @@ break; case dBScale: - value = (-thresh * float(vy)) / m + thresh; + value = (-thresh * double(vy)) / m + thresh; value = AudioLevel::dB_to_multiplier(value); break; } @@ -1126,7 +1126,7 @@ bool WaveformLayer::getYScaleValue(const View *v, int y, - float &value, QString &unit) const + double &value, QString &unit) const { int channel; @@ -1134,10 +1134,10 @@ if (m_scale == dBScale || m_scale == MeterScale) { - float thresh = -50.f; + double thresh = -50.f; - if (value > 0.f) { - value = 10.f * log10f(value); + if (value > 0.0) { + value = 10.0 * log10(value); if (value < thresh) value = thresh; } else value = thresh; @@ -1152,36 +1152,36 @@ bool WaveformLayer::getYScaleDifference(const View *v, int y0, int y1, - float &diff, QString &unit) const + double &diff, QString &unit) const { int c0, c1; - float v0 = getValueForY(v, y0, c0); - float v1 = getValueForY(v, y1, c1); + double v0 = getValueForY(v, y0, c0); + double v1 = getValueForY(v, y1, c1); if (c0 != c1) { // different channels, not comparable - diff = 0.f; + diff = 0.0; unit = ""; return false; } if (m_scale == dBScale || m_scale == MeterScale) { - float thresh = -50.f; + double thresh = -50.0; if (v1 == v0) diff = thresh; else { if (v1 > v0) diff = v0 / v1; else diff = v1 / v0; - diff = 10.f * log10f(diff); + diff = 10.0 * log10(diff); if (diff < thresh) diff = thresh; } unit = "dBV"; } else { - diff = fabsf(v1 - v0); + diff = fabs(v1 - v0); unit = "V"; } @@ -1217,7 +1217,7 @@ int textHeight = paint.fontMetrics().height(); int toff = -textHeight/2 + paint.fontMetrics().ascent() + 1; - float gain = m_gain; + double gain = m_gain; for (int ch = minChannel; ch <= maxChannel; ++ch) { @@ -1229,14 +1229,14 @@ for (int i = 0; i <= n; ++i) { - float val = 0.0, nval = 0.0; + double val = 0.0, nval = 0.0; QString text = ""; switch (m_scale) { case LinearScale: val = (i * gain) / n; - text = QString("%1").arg(float(i) / n); + text = QString("%1").arg(double(i) / n); if (i == 0) text = "0.0"; else { nval = -val; @@ -1402,7 +1402,7 @@ int WaveformLayer::getCurrentVerticalZoomStep() const { - int val = lrint(log10(m_gain) * 20.0) + 50; + int val = int(lrint(log10(m_gain) * 20.0) + 50); if (val < 0) val = 0; if (val > 100) val = 100; return val; @@ -1411,6 +1411,6 @@ void WaveformLayer::setVerticalZoomStep(int step) { - setGain(pow(10, float(step - 50) / 20.0)); + setGain(powf(10, float(step - 50) / 20.f)); } diff -r 4968bbaf1ed8 -r 26da827e8fb5 layer/WaveformLayer.h --- a/layer/WaveformLayer.h Mon Mar 23 10:04:51 2015 +0000 +++ b/layer/WaveformLayer.h Mon Mar 23 11:26:28 2015 +0000 @@ -156,8 +156,8 @@ * bottom; the default value of 0.5 indicates that it occupies the * whole layer, centred at the middle. */ - void setMiddleLineHeight(float height); - float getMiddleLineHeight() const { return m_middleLineHeight; } + void setMiddleLineHeight(double); + double getMiddleLineHeight() const { return m_middleLineHeight; } /** * Enable or disable aggressive pixmap cacheing. If enabled, @@ -184,14 +184,14 @@ virtual int getCompletion(View *) const; - virtual bool getValueExtents(float &min, float &max, + virtual bool getValueExtents(double &min, double &max, bool &log, QString &unit) const; virtual bool getYScaleValue(const View *v, int y, - float &value, QString &unit) const; + double &value, QString &unit) const; virtual bool getYScaleDifference(const View *v, int y0, int y1, - float &diff, QString &unit) const; + double &diff, QString &unit) const; virtual void toXml(QTextStream &stream, QString indent = "", QString extraAttributes = "") const; @@ -203,7 +203,7 @@ virtual void setVerticalZoomStep(int); protected: - int dBscale(float sample, int m) const; + int dBscale(double sample, int m) const; const RangeSummarisableTimeValueModel *m_model; // I do not own this @@ -211,12 +211,12 @@ int getChannelArrangement(int &min, int &max, bool &merging, bool &mixing) const; - int getYForValue(const View *v, float value, int channel) const; + int getYForValue(const View *v, double value, int channel) const; - float getValueForY(const View *v, int y, int &channel) const; + double getValueForY(const View *v, int y, int &channel) const; bool getSourceFramesForX(View *v, int x, int modelZoomLevel, - int &f0, int &f1) const; + sv_frame_t &f0, sv_frame_t &f1) const; float getNormalizeGain(View *v, int channel) const; @@ -229,7 +229,7 @@ ChannelMode m_channelMode; int m_channel; Scale m_scale; - float m_middleLineHeight; + double m_middleLineHeight; bool m_aggressive; mutable std::vector m_effectiveGains; diff -r 4968bbaf1ed8 -r 26da827e8fb5 svgui.pro --- a/svgui.pro Mon Mar 23 10:04:51 2015 +0000 +++ b/svgui.pro Mon Mar 23 11:26:28 2015 +0000 @@ -25,7 +25,7 @@ DEFINES += HAVE_BZ2 HAVE_FFTW3 HAVE_FFTW3F HAVE_SNDFILE HAVE_SAMPLERATE HAVE_VAMP HAVE_VAMPHOSTSDK HAVE_RUBBERBAND HAVE_LIBLO HAVE_MAD HAVE_ID3TAG } -CONFIG += staticlib qt thread warn_on stl rtti exceptions +CONFIG += staticlib qt thread warn_on stl rtti exceptions c++11 QT += network xml gui widgets TARGET = svgui diff -r 4968bbaf1ed8 -r 26da827e8fb5 view/Overview.cpp --- a/view/Overview.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/view/Overview.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -38,12 +38,12 @@ } void -Overview::modelChangedWithin(int startFrame, int endFrame) +Overview::modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame) { bool zoomChanged = false; - int frameCount = getModelsEndFrame() - getModelsStartFrame(); - int zoomLevel = frameCount / width(); + sv_frame_t frameCount = getModelsEndFrame() - getModelsStartFrame(); + int zoomLevel = int(frameCount / width()); if (zoomLevel < 1) zoomLevel = 1; zoomLevel = getZoomConstraintBlockSize(zoomLevel, ZoomConstraint::RoundUp); @@ -91,7 +91,7 @@ } void -Overview::globalCentreFrameChanged(int +Overview::globalCentreFrameChanged(sv_frame_t #ifdef DEBUG_OVERVIEW f #endif @@ -104,7 +104,7 @@ } void -Overview::viewCentreFrameChanged(View *v, int +Overview::viewCentreFrameChanged(View *v, sv_frame_t #ifdef DEBUG_OVERVIEW f #endif @@ -128,7 +128,7 @@ } void -Overview::viewManagerPlaybackFrameChanged(int f) +Overview::viewManagerPlaybackFrameChanged(sv_frame_t f) { #ifdef DEBUG_OVERVIEW cerr << "Overview[" << this << "]::viewManagerPlaybackFrameChanged(" << f << "): " << f << endl; @@ -167,9 +167,9 @@ cerr << "Overview::paintEvent: width is " << width() << ", centre frame " << m_centreFrame << endl; #endif - int startFrame = getModelsStartFrame(); - int frameCount = getModelsEndFrame() - getModelsStartFrame(); - int zoomLevel = frameCount / width(); + sv_frame_t startFrame = getModelsStartFrame(); + sv_frame_t frameCount = getModelsEndFrame() - getModelsStartFrame(); + int zoomLevel = int(frameCount / width()); if (zoomLevel < 1) zoomLevel = 1; zoomLevel = getZoomConstraintBlockSize(zoomLevel, ZoomConstraint::RoundUp); @@ -178,7 +178,7 @@ emit zoomLevelChanged(m_zoomLevel, m_followZoom); } - int centreFrame = startFrame + m_zoomLevel * (width() / 2); + sv_frame_t centreFrame = startFrame + m_zoomLevel * (width() / 2); if (centreFrame > (startFrame + getModelsEndFrame())/2) { centreFrame = (startFrame + getModelsEndFrame())/2; } @@ -214,21 +214,21 @@ QRect primary; int y = 0; - + for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) { if (!*i) continue; View *w = (View *)*i; - int f0 = w->getFrameForX(0); - int f1 = w->getFrameForX(w->width()); + sv_frame_t f0 = w->getFrameForX(0); + sv_frame_t f1 = w->getFrameForX(w->width()); if (f0 >= 0) { - int rf0 = w->alignToReference(f0); + sv_frame_t rf0 = w->alignToReference(f0); f0 = alignFromReference(rf0); } if (f1 >= 0) { - int rf1 = w->alignToReference(f1); + sv_frame_t rf1 = w->alignToReference(f1); f1 = alignFromReference(rf1); } @@ -273,7 +273,7 @@ Overview::mousePressEvent(QMouseEvent *e) { m_clickPos = e->pos(); - int clickFrame = getFrameForX(m_clickPos.x()); + sv_frame_t clickFrame = getFrameForX(m_clickPos.x()); if (clickFrame > 0) m_dragCentreFrame = clickFrame; else m_dragCentreFrame = 0; m_clickedInRange = true; @@ -301,12 +301,12 @@ if (!m_clickedInRange) return; int xoff = int(e->x()) - int(m_clickPos.x()); - int frameOff = xoff * m_zoomLevel; + sv_frame_t frameOff = xoff * m_zoomLevel; - int newCentreFrame = m_dragCentreFrame; + sv_frame_t newCentreFrame = m_dragCentreFrame; if (frameOff > 0) { newCentreFrame += frameOff; - } else if (newCentreFrame >= int(-frameOff)) { + } else if (newCentreFrame >= -frameOff) { newCentreFrame += frameOff; } else { newCentreFrame = 0; @@ -318,8 +318,8 @@ } if (std::max(m_centreFrame, newCentreFrame) - - std::min(m_centreFrame, newCentreFrame) > int(m_zoomLevel)) { - int rf = alignToReference(newCentreFrame); + std::min(m_centreFrame, newCentreFrame) > m_zoomLevel) { + sv_frame_t rf = alignToReference(newCentreFrame); #ifdef DEBUG_OVERVIEW cerr << "Overview::mouseMoveEvent: x " << e->x() << " and click x " << m_clickPos.x() << " -> frame " << newCentreFrame << " -> rf " << rf << endl; #endif @@ -335,8 +335,8 @@ void Overview::mouseDoubleClickEvent(QMouseEvent *e) { - int frame = getFrameForX(e->x()); - int rf = 0; + sv_frame_t frame = getFrameForX(e->x()); + sv_frame_t rf = 0; if (frame > 0) rf = alignToReference(frame); #ifdef DEBUG_OVERVIEW cerr << "Overview::mouseDoubleClickEvent: frame " << frame << " -> rf " << rf << endl; diff -r 4968bbaf1ed8 -r 26da827e8fb5 view/Overview.h --- a/view/Overview.h Mon Mar 23 10:04:51 2015 +0000 +++ b/view/Overview.h Mon Mar 23 11:26:28 2015 +0000 @@ -41,13 +41,13 @@ virtual QString getPropertyContainerIconName() const { return "panner"; } public slots: - virtual void modelChangedWithin(int startFrame, int endFrame); + virtual void modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame); virtual void modelReplaced(); - virtual void globalCentreFrameChanged(int); - virtual void viewCentreFrameChanged(View *, int); + virtual void globalCentreFrameChanged(sv_frame_t); + virtual void viewCentreFrameChanged(View *, sv_frame_t); virtual void viewZoomLevelChanged(View *, int, bool); - virtual void viewManagerPlaybackFrameChanged(int); + virtual void viewManagerPlaybackFrameChanged(sv_frame_t); protected: virtual void paintEvent(QPaintEvent *e); @@ -65,7 +65,7 @@ QPoint m_clickPos; QPoint m_mousePos; bool m_clickedInRange; - int m_dragCentreFrame; + sv_frame_t m_dragCentreFrame; QTime m_modelTestTime; typedef std::set ViewSet; diff -r 4968bbaf1ed8 -r 26da827e8fb5 view/Pane.cpp --- a/view/Pane.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/view/Pane.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -143,7 +143,7 @@ m_hthumb->setFixedWidth(70); m_hthumb->setFixedHeight(16); m_hthumb->setDefaultValue(0); - m_hthumb->setSpeed(0.6); + m_hthumb->setSpeed(0.6f); connect(m_hthumb, SIGNAL(valueChanged(int)), this, SLOT(horizontalThumbwheelMoved(int))); connect(m_hthumb, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); @@ -320,12 +320,12 @@ return; } - float vmin, vmax, dmin, dmax; + double vmin, vmax, dmin, dmax; if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax) && vmax != vmin) { - float y0 = (dmin - vmin) / (vmax - vmin); - float y1 = (dmax - vmin) / (vmax - vmin); + double y0 = (dmin - vmin) / (vmax - vmin); + double y1 = (dmax - vmin) / (vmax - vmin); m_vpan->blockSignals(true); - m_vpan->setRectExtents(0, 1.0 - y1, 1, y1 - y0); + m_vpan->setRectExtents(0, float(1.0 - y1), 1, float(y1 - y0)); m_vpan->blockSignals(false); m_vpan->show(); } else { @@ -483,7 +483,7 @@ drawFeatureDescription(topLayer, paint); } - int sampleRate = getModelsSampleRate(); + sv_samplerate_t sampleRate = getModelsSampleRate(); paint.setBrush(Qt::NoBrush); if (m_centreLineVisible && @@ -560,7 +560,7 @@ { Layer *scaleLayer = 0; - float min, max; + double min, max; bool log; QString unit; @@ -714,7 +714,7 @@ } void -Pane::drawCentreLine(int sampleRate, QPainter &paint, bool omitLine) +Pane::drawCentreLine(sv_samplerate_t sampleRate, QPainter &paint, bool omitLine) { int fontHeight = paint.fontMetrics().height(); int fontAscent = paint.fontMetrics().ascent(); @@ -969,7 +969,7 @@ { int offset = m_mousePos.x() - m_clickPos.x(); - int origStart = m_editingSelection.getStartFrame(); + sv_frame_t origStart = m_editingSelection.getStartFrame(); int p0 = getXForFrame(origStart) + offset; int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset; @@ -980,15 +980,15 @@ p0 = getXForFrame(m_editingSelection.getStartFrame()); } - int newStart = getFrameForX(p0); - int newEnd = getFrameForX(p1); + sv_frame_t newStart = getFrameForX(p0); + sv_frame_t newEnd = getFrameForX(p1); paint.save(); paint.setPen(QPen(getForeground(), 2)); int fontHeight = paint.fontMetrics().height(); int fontAscent = paint.fontMetrics().ascent(); - int sampleRate = getModelsSampleRate(); + sv_samplerate_t sampleRate = getModelsSampleRate(); QString startText, endText, offsetText; startText = QString("%1").arg(newStart); endText = QString("%1").arg(newEnd); @@ -1037,17 +1037,17 @@ void Pane::drawDurationAndRate(QRect r, const Model *waveformModel, - int sampleRate, QPainter &paint) + sv_samplerate_t sampleRate, QPainter &paint) { int fontHeight = paint.fontMetrics().height(); int fontAscent = paint.fontMetrics().ascent(); if (r.y() + r.height() < height() - fontHeight - 6) return; - int modelRate = waveformModel->getSampleRate(); - int nativeRate = waveformModel->getNativeRate(); - int playbackRate = m_manager->getPlaybackSampleRate(); - int outputRate = m_manager->getOutputSampleRate(); + sv_samplerate_t modelRate = waveformModel->getSampleRate(); + sv_samplerate_t nativeRate = waveformModel->getNativeRate(); + sv_samplerate_t playbackRate = m_manager->getPlaybackSampleRate(); + sv_samplerate_t outputRate = m_manager->getOutputSampleRate(); QString srNote = ""; @@ -1086,7 +1086,7 @@ } bool -Pane::render(QPainter &paint, int xorigin, int f0, int f1) +Pane::render(QPainter &paint, int xorigin, sv_frame_t f0, sv_frame_t f1) { if (!View::render(paint, xorigin + m_scaleWidth, f0, f1)) { return false; @@ -1117,10 +1117,10 @@ } QImage * -Pane::toNewImage(int f0, int f1) +Pane::toNewImage(sv_frame_t f0, sv_frame_t f1) { - int x0 = f0 / getZoomLevel(); - int x1 = f1 / getZoomLevel(); + int x0 = int(f0 / getZoomLevel()); + int x1 = int(f1 / getZoomLevel()); QImage *image = new QImage(x1 - x0 + m_scaleWidth, height(), QImage::Format_RGB32); @@ -1156,7 +1156,7 @@ } QSize -Pane::getImageSize(int f0, int f1) +Pane::getImageSize(sv_frame_t f0, sv_frame_t f1) { QSize s = View::getImageSize(f0, f1); QImage *image = new QImage(100, 100, QImage::Format_RGB32); @@ -1174,12 +1174,12 @@ return QSize(sw + s.width(), s.height()); } -int +sv_frame_t Pane::getFirstVisibleFrame() const { - int f0 = getFrameForX(m_scaleWidth); - int f = View::getFirstVisibleFrame(); - if (f0 < 0 || f0 < long(f)) return f; + sv_frame_t f0 = getFrameForX(m_scaleWidth); + sv_frame_t f = View::getFirstVisibleFrame(); + if (f0 < 0 || f0 < f) return f; return f0; } @@ -1190,10 +1190,10 @@ if (!m_manager) return Selection(); - int testFrame = getFrameForX(x - 5); + sv_frame_t testFrame = getFrameForX(x - 5); if (testFrame < 0) { - testFrame = getFrameForX(x); - if (testFrame < 0) return Selection(); + testFrame = getFrameForX(x); + if (testFrame < 0) return Selection(); } Selection selection = m_manager->getContainingSelection(testFrame, true); @@ -1219,15 +1219,15 @@ bool Pane::canTopLayerMoveVertical() { - float vmin, vmax, dmin, dmax; + double vmin, vmax, dmin, dmax; if (!getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) return false; if (dmin <= vmin && dmax >= vmax) return false; return true; } bool -Pane::getTopLayerDisplayExtents(float &vmin, float &vmax, - float &dmin, float &dmax, +Pane::getTopLayerDisplayExtents(double &vmin, double &vmax, + double &dmin, double &dmax, QString *unit) { Layer *layer = getTopLayer(); @@ -1241,7 +1241,7 @@ } bool -Pane::setTopLayerDisplayExtents(float dmin, float dmax) +Pane::setTopLayerDisplayExtents(double dmin, double dmax) { Layer *layer = getTopLayer(); if (!layer) return false; @@ -1327,7 +1327,7 @@ m_dragCentreFrame = m_centreFrame; m_dragStartMinValue = 0; - float vmin, vmax, dmin, dmax; + double vmin, vmax, dmin, dmax; if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { m_dragStartMinValue = dmin; } @@ -1362,9 +1362,9 @@ } else { - int mouseFrame = getFrameForX(e->x()); + sv_frame_t mouseFrame = getFrameForX(e->x()); int resolution = 1; - int snapFrame = mouseFrame; + sv_frame_t snapFrame = mouseFrame; Layer *layer = getInteractionLayer(); if (layer && !m_shiftPressed) { @@ -1433,7 +1433,7 @@ } void -Pane::schedulePlaybackFrameMove(int frame) +Pane::schedulePlaybackFrameMove(sv_frame_t frame) { m_playbackFrameMoveTo = frame; m_playbackFrameMoveScheduled = true; @@ -1468,7 +1468,7 @@ mouseMoveEvent(e); } - int mouseFrame = e ? getFrameForX(e->x()) : 0; + sv_frame_t mouseFrame = e ? getFrameForX(e->x()) : 0; if (mouseFrame < 0) mouseFrame = 0; if (m_navigating || mode == ViewManager::NavigateMode) { @@ -1854,18 +1854,18 @@ int w = x1 - x0; - int newStartFrame = getFrameForX(x0); + sv_frame_t newStartFrame = getFrameForX(x0); - int visibleFrames = getEndFrame() - getStartFrame(); + sv_frame_t visibleFrames = getEndFrame() - getStartFrame(); if (newStartFrame <= -visibleFrames) { newStartFrame = -visibleFrames + 1; } - if (newStartFrame >= long(getModelsEndFrame())) { + if (newStartFrame >= getModelsEndFrame()) { newStartFrame = getModelsEndFrame() - 1; } - float ratio = float(w) / float(width()); + double ratio = double(w) / double(width()); // cerr << "ratio: " << ratio << endl; int newZoomLevel = (int)nearbyint(m_zoomLevel * ratio); if (newZoomLevel < 1) newZoomLevel = 1; @@ -1875,7 +1875,7 @@ setStartFrame(newStartFrame); QString unit; - float min, max; + double min, max; bool log; Layer *layer = 0; for (LayerList::const_iterator i = m_layerStack.begin(); @@ -1889,15 +1889,15 @@ if (layer) { if (log) { - min = (min < 0.0) ? -log10f(-min) : (min == 0.0) ? 0.0 : log10f(min); - max = (max < 0.0) ? -log10f(-max) : (max == 0.0) ? 0.0 : log10f(max); + min = (min < 0.0) ? -log10(-min) : (min == 0.0) ? 0.0 : log10(min); + max = (max < 0.0) ? -log10(-max) : (max == 0.0) ? 0.0 : log10(max); } - float rmin = min + ((max - min) * (height() - y1)) / height(); - float rmax = min + ((max - min) * (height() - y0)) / height(); + double rmin = min + ((max - min) * (height() - y1)) / height(); + double rmax = min + ((max - min) * (height() - y0)) / height(); cerr << "min: " << min << ", max: " << max << ", y0: " << y0 << ", y1: " << y1 << ", h: " << height() << ", rmin: " << rmin << ", rmax: " << rmax << endl; if (log) { - rmin = powf(10, rmin); - rmax = powf(10, rmax); + rmin = pow(10, rmin); + rmax = pow(10, rmax); } cerr << "finally: rmin: " << rmin << ", rmax: " << rmax << " " << unit << endl; @@ -1946,8 +1946,8 @@ if (m_dragMode == HorizontalDrag || m_dragMode == FreeDrag) { - int frameOff = getFrameForX(e->x()) - getFrameForX(m_clickPos.x()); - int newCentreFrame = m_dragCentreFrame; + sv_frame_t frameOff = getFrameForX(e->x()) - getFrameForX(m_clickPos.x()); + sv_frame_t newCentreFrame = m_dragCentreFrame; if (frameOff < 0) { newCentreFrame -= frameOff; @@ -1975,24 +1975,24 @@ if (m_dragMode == VerticalDrag || m_dragMode == FreeDrag) { - float vmin = 0.f, vmax = 0.f; - float dmin = 0.f, dmax = 0.f; + double vmin = 0.f, vmax = 0.f; + double dmin = 0.f, dmax = 0.f; if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { // cerr << "ydiff = " << ydiff << endl; int ydiff = e->y() - m_clickPos.y(); - float perpix = (dmax - dmin) / height(); - float valdiff = ydiff * perpix; + double perpix = (dmax - dmin) / height(); + double valdiff = ydiff * perpix; // cerr << "valdiff = " << valdiff << endl; if (m_dragMode == UnresolvedDrag && ydiff != 0) { m_dragMode = VerticalDrag; } - float newmin = m_dragStartMinValue + valdiff; - float newmax = m_dragStartMinValue + (dmax - dmin) + valdiff; + double newmin = m_dragStartMinValue + valdiff; + double newmax = m_dragStartMinValue + (dmax - dmin) + valdiff; if (newmin < vmin) { newmax += vmin - newmin; newmin += vmin - newmin; @@ -2077,10 +2077,10 @@ void Pane::dragExtendSelection(QMouseEvent *e) { - int mouseFrame = getFrameForX(e->x()); + sv_frame_t mouseFrame = getFrameForX(e->x()); int resolution = 1; - int snapFrameLeft = mouseFrame; - int snapFrameRight = mouseFrame; + sv_frame_t snapFrameLeft = mouseFrame; + sv_frame_t snapFrameRight = mouseFrame; Layer *layer = getInteractionLayer(); if (layer && !m_shiftPressed) { @@ -2095,7 +2095,7 @@ if (snapFrameLeft < 0) snapFrameLeft = 0; if (snapFrameRight < 0) snapFrameRight = 0; - int min, max; + sv_frame_t min, max; if (m_selectionStartFrame > snapFrameLeft) { min = snapFrameLeft; @@ -2126,7 +2126,7 @@ void Pane::edgeScrollMaybe(int x) { - int mouseFrame = getFrameForX(x); + sv_frame_t mouseFrame = getFrameForX(x); bool doScroll = false; if (!m_manager) doScroll = true; @@ -2135,14 +2135,14 @@ if (m_followPlay != PlaybackScrollContinuous) doScroll = true; if (doScroll) { - int offset = mouseFrame - getStartFrame(); - int available = getEndFrame() - getStartFrame(); - int move = 0; - if (offset >= available * 0.95) { - move = int(offset - available * 0.95) + 1; - } else if (offset <= available * 0.10) { - move = int(available * 0.10 - offset) + 1; - move = -move; + sv_frame_t offset = mouseFrame - getStartFrame(); + sv_frame_t available = getEndFrame() - getStartFrame(); + sv_frame_t move = 0; + if (offset >= double(available) * 0.95) { + move = sv_frame_t(double(offset - available) * 0.95) + 1; + } else if (offset <= double(available) * 0.10) { + move = sv_frame_t(double(available) * 0.10 - double(offset)) + 1; + move = -move; } if (move != 0) { setCentreFrame(m_centreFrame + move); @@ -2199,7 +2199,7 @@ if (relocate) { - int f = getFrameForX(e->x()); + sv_frame_t f = getFrameForX(e->x()); setCentreFrame(f); @@ -2207,7 +2207,7 @@ m_dragStartMinValue = 0; m_dragMode = UnresolvedDrag; - float vmin, vmax, dmin, dmax; + double vmin, vmax, dmin, dmax; if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) { m_dragStartMinValue = dmin; } @@ -2293,7 +2293,7 @@ // Sometimes on Linux we're seeing absurdly extreme angles on // the first wheel event -- discard those entirely - if (abs(m_pendingWheelAngle) > 1000) { + if (abs(m_pendingWheelAngle) >= 600) { m_pendingWheelAngle = 0; return; } @@ -2468,11 +2468,11 @@ void Pane::verticalPannerMoved(float , float y0, float , float h) { - float vmin, vmax, dmin, dmax; + double vmin, vmax, dmin, dmax; if (!getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) return; - float y1 = y0 + h; - float newmax = vmin + ((1.0 - y0) * (vmax - vmin)); - float newmin = vmin + ((1.0 - y1) * (vmax - vmin)); + double y1 = y0 + h; + double newmax = vmin + ((1.0 - y0) * (vmax - vmin)); + double newmin = vmin + ((1.0 - y1) * (vmax - vmin)); // cerr << "verticalPannerMoved: (" << x0 << "," << y0 << "," << w // << "," << h << ") -> (" << newmin << "," << newmax << ")" << endl; setTopLayerDisplayExtents(newmin, newmax); @@ -2483,7 +2483,7 @@ { if (!m_vpan || !m_manager || !m_manager->getZoomWheelsEnabled()) return; - float vmin, vmax, dmin, dmax; + double vmin, vmax, dmin, dmax; QString unit; if (!getTopLayerDisplayExtents(vmin, vmax, dmin, dmax, &unit) || vmax == vmin) { @@ -2493,12 +2493,13 @@ RangeInputDialog dialog(tr("Enter new range"), tr("New vertical display range, from %1 to %2 %4:") .arg(vmin).arg(vmax).arg(unit), - unit, vmin, vmax, this); - dialog.setRange(dmin, dmax); + unit, float(vmin), float(vmax), this); + dialog.setRange(float(dmin), float(dmax)); if (dialog.exec() == QDialog::Accepted) { - dialog.getRange(dmin, dmax); - setTopLayerDisplayExtents(dmin, dmax); + float newmin, newmax; + dialog.getRange(newmin, newmax); + setTopLayerDisplayExtents(newmin, newmax); updateVerticalPanner(); } } @@ -2604,8 +2605,8 @@ int p0 = getXForFrame(m_editingSelection.getStartFrame()) + offset; int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset; - int f0 = getFrameForX(p0); - int f1 = getFrameForX(p1); + sv_frame_t f0 = getFrameForX(p0); + sv_frame_t f1 = getFrameForX(p1); Selection newSelection(f0, f1); diff -r 4968bbaf1ed8 -r 26da827e8fb5 view/Pane.h --- a/view/Pane.h Mon Mar 23 10:04:51 2015 +0000 +++ b/view/Pane.h Mon Mar 23 11:26:28 2015 +0000 @@ -48,13 +48,13 @@ void setCentreLineVisible(bool visible); bool getCentreLineVisible() const { return m_centreLineVisible; } - virtual int getFirstVisibleFrame() const; + virtual sv_frame_t getFirstVisibleFrame() const; virtual int getVerticalScaleWidth() const; - virtual QImage *toNewImage(int f0, int f1); + virtual QImage *toNewImage(sv_frame_t f0, sv_frame_t f1); virtual QImage *toNewImage() { return View::toNewImage(); } - virtual QSize getImageSize(int f0, int f1); + virtual QSize getImageSize(sv_frame_t f0, sv_frame_t f1); virtual QSize getImageSize() { return View::getImageSize(); } virtual void toXml(QTextStream &stream, QString indent = "", @@ -73,7 +73,7 @@ void rightButtonMenuRequested(QPoint position); void dropAccepted(QStringList uriList); void dropAccepted(QString text); - void doubleClickSelectInvoked(int frame); + void doubleClickSelectInvoked(sv_frame_t frame); void regionOutlined(QRect rect); public slots: @@ -119,15 +119,15 @@ void drawVerticalScale(QRect r, Layer *, QPainter &); void drawFeatureDescription(Layer *, QPainter &); - void drawCentreLine(int, QPainter &, bool omitLine); + void drawCentreLine(sv_samplerate_t, QPainter &, bool omitLine); void drawModelTimeExtents(QRect, QPainter &, const Model *); - void drawDurationAndRate(QRect, const Model *, int, QPainter &); + void drawDurationAndRate(QRect, const Model *, sv_samplerate_t, QPainter &); void drawWorkTitle(QRect, QPainter &, const Model *); void drawLayerNames(QRect, QPainter &); void drawEditingSelection(QPainter &); void drawAlignmentStatus(QRect, QPainter &, const Model *, bool down); - virtual bool render(QPainter &paint, int x0, int f0, int f1); + virtual bool render(QPainter &paint, int x0, sv_frame_t f0, sv_frame_t f1); Selection getSelectionAt(int x, bool &closeToLeft, bool &closeToRight) const; @@ -140,10 +140,10 @@ void updateVerticalPanner(); bool canTopLayerMoveVertical(); - bool getTopLayerDisplayExtents(float &valueMin, float &valueMax, - float &displayMin, float &displayMax, + bool getTopLayerDisplayExtents(double &valueMin, double &valueMax, + double &displayMin, double &displayMax, QString *unit = 0); - bool setTopLayerDisplayExtents(float displayMin, float displayMax); + bool setTopLayerDisplayExtents(double displayMin, double displayMax); void dragTopLayer(QMouseEvent *e); void dragExtendSelection(QMouseEvent *e); @@ -152,7 +152,7 @@ Layer *getTopFlexiNoteLayer(); - void schedulePlaybackFrameMove(int frame); + void schedulePlaybackFrameMove(sv_frame_t frame); bool m_identifyFeatures; QPoint m_identifyPoint; @@ -167,10 +167,10 @@ bool m_resizing; bool m_editing; bool m_releasing; - int m_dragCentreFrame; - float m_dragStartMinValue; + sv_frame_t m_dragCentreFrame; + double m_dragStartMinValue; bool m_centreLineVisible; - int m_selectionStartFrame; + sv_frame_t m_selectionStartFrame; Selection m_editingSelection; int m_editingSelectionEdge; mutable int m_scaleWidth; @@ -202,7 +202,7 @@ bool m_mouseInWidget; bool m_playbackFrameMoveScheduled; - int m_playbackFrameMoveTo; + sv_frame_t m_playbackFrameMoveTo; static QCursor *m_measureCursor1; static QCursor *m_measureCursor2; diff -r 4968bbaf1ed8 -r 26da827e8fb5 view/PaneStack.cpp --- a/view/PaneStack.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/view/PaneStack.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -98,7 +98,7 @@ currentIndicator->setScaledContents(true); currentIndicator->setVisible(m_showAccessories); - int initialCentreFrame = -1; + sv_frame_t initialCentreFrame = -1; if (!m_panes.empty()) { initialCentreFrame = m_panes[0].pane->getCentreFrame(); } @@ -156,8 +156,8 @@ this, SLOT(paneDropAccepted(QStringList))); connect(pane, SIGNAL(dropAccepted(QString)), this, SLOT(paneDropAccepted(QString))); - connect(pane, SIGNAL(doubleClickSelectInvoked(int)), - this, SIGNAL(doubleClickSelectInvoked(int))); + connect(pane, SIGNAL(doubleClickSelectInvoked(sv_frame_t)), + this, SIGNAL(doubleClickSelectInvoked(sv_frame_t))); emit paneAdded(pane); emit paneAdded(); @@ -323,13 +323,13 @@ int PaneStack::getPaneCount() const { - return m_panes.size(); + return int(m_panes.size()); } int PaneStack::getHiddenPaneCount() const { - return m_hiddenPanes.size(); + return int(m_hiddenPanes.size()); } void diff -r 4968bbaf1ed8 -r 26da827e8fb5 view/PaneStack.h --- a/view/PaneStack.h Mon Mar 23 10:04:51 2015 +0000 +++ b/view/PaneStack.h Mon Mar 23 11:26:28 2015 +0000 @@ -20,6 +20,8 @@ #include +#include "base/BaseTypes.h" + class QWidget; class QLabel; class QStackedWidget; @@ -93,7 +95,7 @@ void paneDeleteButtonClicked(Pane *pane); - void doubleClickSelectInvoked(int frame); + void doubleClickSelectInvoked(sv_frame_t frame); public slots: void propertyContainerAdded(PropertyContainer *); diff -r 4968bbaf1ed8 -r 26da827e8fb5 view/View.cpp --- a/view/View.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/view/View.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -164,7 +164,7 @@ int View::getPropertyContainerCount() const { - return m_fixedOrderLayers.size() + 1; // the 1 is for me + return int(m_fixedOrderLayers.size()) + 1; // the 1 is for me } const PropertyContainer * @@ -182,7 +182,7 @@ } bool -View::getValueExtents(QString unit, float &min, float &max, bool &log) const +View::getValueExtents(QString unit, double &min, double &max, bool &log) const { bool have = false; @@ -190,8 +190,8 @@ i != m_layerStack.end(); ++i) { QString layerUnit; - float layerMin = 0.0, layerMax = 0.0; - float displayMin = 0.0, displayMax = 0.0; + double layerMin = 0.0, layerMax = 0.0; + double displayMin = 0.0, displayMax = 0.0; bool layerLog = false; if ((*i)->getValueExtents(layerMin, layerMax, layerLog, layerUnit) && @@ -298,36 +298,36 @@ // subclass might override this } -int +sv_frame_t View::getStartFrame() const { return getFrameForX(0); } -int +sv_frame_t View::getEndFrame() const { return getFrameForX(width()) - 1; } void -View::setStartFrame(int f) +View::setStartFrame(sv_frame_t f) { setCentreFrame(f + m_zoomLevel * (width() / 2)); } bool -View::setCentreFrame(int f, bool e) +View::setCentreFrame(sv_frame_t f, bool e) { bool changeVisible = false; if (m_centreFrame != f) { - int formerPixel = m_centreFrame / m_zoomLevel; + int formerPixel = int(m_centreFrame / m_zoomLevel); m_centreFrame = f; - int newPixel = m_centreFrame / m_zoomLevel; + int newPixel = int(m_centreFrame / m_zoomLevel); if (newPixel != formerPixel) { @@ -340,7 +340,7 @@ } if (e) { - int rf = alignToReference(f); + sv_frame_t rf = alignToReference(f); #ifdef DEBUG_VIEW cerr << "View[" << this << "]::setCentreFrame(" << f << "): emitting centreFrameChanged(" @@ -354,16 +354,16 @@ } int -View::getXForFrame(int frame) const +View::getXForFrame(sv_frame_t frame) const { - return (frame - getStartFrame()) / m_zoomLevel; + return int((frame - getStartFrame()) / m_zoomLevel); } -int +sv_frame_t View::getFrameForX(int x) const { int z = m_zoomLevel; - int frame = m_centreFrame - (width()/2) * z; + sv_frame_t frame = m_centreFrame - (width()/2) * z; #ifdef DEBUG_VIEW_WIDGET_PAINT SVDEBUG << "View::getFrameForX(" << x << "): z = " << z << ", m_centreFrame = " << m_centreFrame << ", width() = " << width() << ", frame = " << frame << endl; @@ -373,10 +373,10 @@ return frame + x * z; } -float -View::getYForFrequency(float frequency, - float minf, - float maxf, +double +View::getYForFrequency(double frequency, + double minf, + double maxf, bool logarithmic) const { Profiler profiler("View::getYForFrequency"); @@ -385,20 +385,20 @@ if (logarithmic) { - static float lastminf = 0.0, lastmaxf = 0.0; - static float logminf = 0.0, logmaxf = 0.0; + static double lastminf = 0.0, lastmaxf = 0.0; + static double logminf = 0.0, logmaxf = 0.0; if (lastminf != minf) { lastminf = (minf == 0.0 ? 1.0 : minf); - logminf = log10f(minf); + logminf = log10(minf); } if (lastmaxf != maxf) { lastmaxf = (maxf < lastminf ? lastminf : maxf); - logmaxf = log10f(maxf); + logmaxf = log10(maxf); } if (logminf == logmaxf) return 0; - return h - (h * (log10f(frequency) - logminf)) / (logmaxf - logminf); + return h - (h * (log10(frequency) - logminf)) / (logmaxf - logminf); } else { @@ -407,30 +407,30 @@ } } -float +double View::getFrequencyForY(int y, - float minf, - float maxf, + double minf, + double maxf, bool logarithmic) const { int h = height(); if (logarithmic) { - static float lastminf = 0.0, lastmaxf = 0.0; - static float logminf = 0.0, logmaxf = 0.0; + static double lastminf = 0.0, lastmaxf = 0.0; + static double logminf = 0.0, logmaxf = 0.0; if (lastminf != minf) { lastminf = (minf == 0.0 ? 1.0 : minf); - logminf = log10f(minf); + logminf = log10(minf); } if (lastmaxf != maxf) { lastmaxf = (maxf < lastminf ? lastminf : maxf); - logmaxf = log10f(maxf); + logmaxf = log10(maxf); } if (logminf == logmaxf) return 0; - return pow(10.f, logminf + ((logmaxf - logminf) * (h - y)) / h); + return pow(10.0, logminf + ((logmaxf - logminf) * (h - y)) / h); } else { @@ -580,8 +580,8 @@ this, SLOT(modelCompletionChanged())); connect(layer, SIGNAL(modelAlignmentCompletionChanged()), this, SLOT(modelAlignmentCompletionChanged())); - connect(layer, SIGNAL(modelChangedWithin(int, int)), - this, SLOT(modelChangedWithin(int, int))); + connect(layer, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), + this, SLOT(modelChangedWithin(sv_frame_t, sv_frame_t))); connect(layer, SIGNAL(modelReplaced()), this, SLOT(modelReplaced())); @@ -636,8 +636,8 @@ this, SLOT(modelCompletionChanged())); disconnect(layer, SIGNAL(modelAlignmentCompletionChanged()), this, SLOT(modelAlignmentCompletionChanged())); - disconnect(layer, SIGNAL(modelChangedWithin(int, int)), - this, SLOT(modelChangedWithin(int, int))); + disconnect(layer, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), + this, SLOT(modelChangedWithin(sv_frame_t, sv_frame_t))); disconnect(layer, SIGNAL(modelReplaced()), this, SLOT(modelReplaced())); @@ -692,26 +692,26 @@ View::setViewManager(ViewManager *manager) { if (m_manager) { - m_manager->disconnect(this, SLOT(globalCentreFrameChanged(int))); - m_manager->disconnect(this, SLOT(viewCentreFrameChanged(View *, int))); - m_manager->disconnect(this, SLOT(viewManagerPlaybackFrameChanged(int))); + m_manager->disconnect(this, SLOT(globalCentreFrameChanged(sv_frame_t))); + m_manager->disconnect(this, SLOT(viewCentreFrameChanged(View *, sv_frame_t))); + m_manager->disconnect(this, SLOT(viewManagerPlaybackFrameChanged(sv_frame_t))); m_manager->disconnect(this, SLOT(viewZoomLevelChanged(View *, int, bool))); m_manager->disconnect(this, SLOT(toolModeChanged())); m_manager->disconnect(this, SLOT(selectionChanged())); m_manager->disconnect(this, SLOT(overlayModeChanged())); m_manager->disconnect(this, SLOT(zoomWheelsEnabledChanged())); - disconnect(m_manager, SLOT(viewCentreFrameChanged(int, bool, PlaybackFollowMode))); + disconnect(m_manager, SLOT(viewCentreFrameChanged(sv_frame_t, bool, PlaybackFollowMode))); disconnect(m_manager, SLOT(zoomLevelChanged(int, bool))); } m_manager = manager; - connect(m_manager, SIGNAL(globalCentreFrameChanged(int)), - this, SLOT(globalCentreFrameChanged(int))); - connect(m_manager, SIGNAL(viewCentreFrameChanged(View *, int)), - this, SLOT(viewCentreFrameChanged(View *, int))); - connect(m_manager, SIGNAL(playbackFrameChanged(int)), - this, SLOT(viewManagerPlaybackFrameChanged(int))); + connect(m_manager, SIGNAL(globalCentreFrameChanged(sv_frame_t)), + this, SLOT(globalCentreFrameChanged(sv_frame_t))); + connect(m_manager, SIGNAL(viewCentreFrameChanged(View *, sv_frame_t)), + this, SLOT(viewCentreFrameChanged(View *, sv_frame_t))); + connect(m_manager, SIGNAL(playbackFrameChanged(sv_frame_t)), + this, SLOT(viewManagerPlaybackFrameChanged(sv_frame_t))); connect(m_manager, SIGNAL(viewZoomLevelChanged(View *, int, bool)), this, SLOT(viewZoomLevelChanged(View *, int, bool))); @@ -729,9 +729,9 @@ connect(m_manager, SIGNAL(zoomWheelsEnabledChanged()), this, SLOT(zoomWheelsEnabledChanged())); - connect(this, SIGNAL(centreFrameChanged(int, bool, + connect(this, SIGNAL(centreFrameChanged(sv_frame_t, bool, PlaybackFollowMode)), - m_manager, SLOT(viewCentreFrameChanged(int, bool, + m_manager, SLOT(viewCentreFrameChanged(sv_frame_t, bool, PlaybackFollowMode))); connect(this, SIGNAL(zoomLevelChanged(int, bool)), @@ -763,7 +763,7 @@ } void -View::setViewManager(ViewManager *vm, int initialCentreFrame) +View::setViewManager(ViewManager *vm, sv_frame_t initialCentreFrame) { setViewManager(vm); setCentreFrame(initialCentreFrame, false); @@ -877,18 +877,18 @@ } void -View::modelChangedWithin(int startFrame, int endFrame) +View::modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame) { QObject *obj = sender(); - int myStartFrame = getStartFrame(); - int myEndFrame = getEndFrame(); + sv_frame_t myStartFrame = getStartFrame(); + sv_frame_t myEndFrame = getEndFrame(); #ifdef DEBUG_VIEW_WIDGET_PAINT cerr << "View(" << this << ")::modelChangedWithin(" << startFrame << "," << endFrame << ") [me " << myStartFrame << "," << myEndFrame << "]" << endl; #endif - if (myStartFrame > 0 && endFrame < int(myStartFrame)) { + if (myStartFrame > 0 && endFrame < myStartFrame) { checkProgress(obj); return; } @@ -995,10 +995,10 @@ } void -View::globalCentreFrameChanged(int rf) +View::globalCentreFrameChanged(sv_frame_t rf) { if (m_followPan) { - int f = alignFromReference(rf); + sv_frame_t f = alignFromReference(rf); #ifdef DEBUG_VIEW cerr << "View[" << this << "]::globalCentreFrameChanged(" << rf << "): setting centre frame to " << f << endl; @@ -1008,13 +1008,13 @@ } void -View::viewCentreFrameChanged(View *, int ) +View::viewCentreFrameChanged(View *, sv_frame_t ) { // We do nothing with this, but a subclass might } void -View::viewManagerPlaybackFrameChanged(int f) +View::viewManagerPlaybackFrameChanged(sv_frame_t f) { if (m_manager) { if (sender() != m_manager) return; @@ -1034,7 +1034,7 @@ } void -View::movePlayPointer(int newFrame) +View::movePlayPointer(sv_frame_t newFrame) { #ifdef DEBUG_VIEW cerr << "View(" << this << ")::movePlayPointer(" << newFrame << ")" << endl; @@ -1043,7 +1043,7 @@ if (m_playPointerFrame == newFrame) return; bool visibleChange = (getXForFrame(m_playPointerFrame) != getXForFrame(newFrame)); - int oldPlayPointerFrame = m_playPointerFrame; + sv_frame_t oldPlayPointerFrame = m_playPointerFrame; m_playPointerFrame = newFrame; if (!visibleChange) return; @@ -1081,16 +1081,16 @@ int xold = getXForFrame(oldPlayPointerFrame); update(xold - 4, 0, 9, height()); - int w = getEndFrame() - getStartFrame(); + sv_frame_t w = getEndFrame() - getStartFrame(); w -= w/5; - int sf = (m_playPointerFrame / w) * w - w/8; + sv_frame_t sf = (m_playPointerFrame / w) * w - w/8; if (m_manager && m_manager->isPlaying() && m_manager->getPlaySelectionMode()) { MultiSelection::SelectionList selections = m_manager->getSelections(); if (!selections.empty()) { - int selectionStart = selections.begin()->getStartFrame(); + sv_frame_t selectionStart = selections.begin()->getStartFrame(); if (sf < selectionStart - w / 10) { sf = selectionStart - w / 10; } @@ -1124,8 +1124,8 @@ } if (!somethingGoingOn && shouldScroll) { - int offset = getFrameForX(width()/2) - getStartFrame(); - int newCentre = sf + offset; + sv_frame_t offset = getFrameForX(width()/2) - getStartFrame(); + sv_frame_t newCentre = sf + offset; bool changed = setCentreFrame(newCentre, false); if (changed) { xold = getXForFrame(oldPlayPointerFrame); @@ -1168,35 +1168,35 @@ update(); } -int +sv_frame_t View::getFirstVisibleFrame() const { - int f0 = getStartFrame(); - int f = getModelsStartFrame(); + sv_frame_t f0 = getStartFrame(); + sv_frame_t f = getModelsStartFrame(); if (f0 < 0 || f0 < f) return f; return f0; } -int +sv_frame_t View::getLastVisibleFrame() const { - int f0 = getEndFrame(); - int f = getModelsEndFrame(); + sv_frame_t f0 = getEndFrame(); + sv_frame_t f = getModelsEndFrame(); if (f0 > f) return f; return f0; } -int +sv_frame_t View::getModelsStartFrame() const { bool first = true; - int startFrame = 0; + sv_frame_t startFrame = 0; for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { if ((*i)->getModel() && (*i)->getModel()->isOK()) { - int thisStartFrame = (*i)->getModel()->getStartFrame(); + sv_frame_t thisStartFrame = (*i)->getModel()->getStartFrame(); if (first || thisStartFrame < startFrame) { startFrame = thisStartFrame; @@ -1207,17 +1207,17 @@ return startFrame; } -int +sv_frame_t View::getModelsEndFrame() const { bool first = true; - int endFrame = 0; + sv_frame_t endFrame = 0; for (LayerList::const_iterator i = m_layerStack.begin(); i != m_layerStack.end(); ++i) { if ((*i)->getModel() && (*i)->getModel()->isOK()) { - int thisEndFrame = (*i)->getModel()->getEndFrame(); + sv_frame_t thisEndFrame = (*i)->getModel()->getEndFrame(); if (first || thisEndFrame > endFrame) { endFrame = thisEndFrame; @@ -1230,7 +1230,7 @@ return endFrame; } -int +sv_samplerate_t View::getModelsSampleRate() const { //!!! Just go for the first, for now. If we were supporting @@ -1309,8 +1309,8 @@ else return anyModel; } -int -View::alignFromReference(int f) const +sv_frame_t +View::alignFromReference(sv_frame_t f) const { if (!m_manager || !m_manager->getAlignMode()) return f; Model *aligningModel = getAligningModel(); @@ -1318,8 +1318,8 @@ return aligningModel->alignFromReference(f); } -int -View::alignToReference(int f) const +sv_frame_t +View::alignToReference(sv_frame_t f) const { if (!m_manager->getAlignMode()) return f; Model *aligningModel = getAligningModel(); @@ -1327,17 +1327,17 @@ return aligningModel->alignToReference(f); } -int +sv_frame_t View::getAlignedPlaybackFrame() const { if (!m_manager) return 0; - int pf = m_manager->getPlaybackFrame(); + sv_frame_t pf = m_manager->getPlaybackFrame(); if (!m_manager->getAlignMode()) return pf; Model *aligningModel = getAligningModel(); if (!aligningModel) return pf; - int af = aligningModel->alignFromReference(pf); + sv_frame_t af = aligningModel->alignFromReference(pf); return af; } @@ -1492,7 +1492,7 @@ void View::scroll(bool right, bool lots, bool e) { - int delta; + sv_frame_t delta; if (lots) { delta = (getEndFrame() - getStartFrame()) / 2; } else { @@ -1500,9 +1500,9 @@ } if (right) delta = -delta; - if (int(m_centreFrame) < delta) { + if (m_centreFrame < delta) { setCentreFrame(0, e); - } else if (int(m_centreFrame) - delta >= int(getModelsEndFrame())) { + } else if (m_centreFrame - delta >= getModelsEndFrame()) { setCentreFrame(getModelsEndFrame(), e); } else { setCentreFrame(m_centreFrame - delta, e); @@ -1974,10 +1974,10 @@ paint.setBrush(Qt::NoBrush); } - int sampleRate = getModelsSampleRate(); + sv_samplerate_t sampleRate = getModelsSampleRate(); QPoint localPos; - int illuminateFrame = -1; + sv_frame_t illuminateFrame = -1; bool closeToLeft, closeToRight; if (shouldIlluminateLocalSelection(localPos, closeToLeft, closeToRight)) { @@ -2145,7 +2145,7 @@ int fontHeight = paint.fontMetrics().height(); int fontAscent = paint.fontMetrics().ascent(); - float v0, v1; + double v0, v1; QString u0, u1; bool b0 = false, b1 = false; @@ -2217,7 +2217,7 @@ } bool bd = false; - float dy = 0.f; + double dy = 0.f; QString du; // dimension, height @@ -2228,7 +2228,7 @@ if (du != "") { if (du == "Hz") { int semis; - float cents; + double cents; semis = Pitch::getPitchForFrequencyDifference(v0, v1, ¢s); dys = QString("[%1 %2 (%3)]") .arg(dy).arg(du) @@ -2333,14 +2333,14 @@ } bool -View::render(QPainter &paint, int xorigin, int f0, int f1) +View::render(QPainter &paint, int xorigin, sv_frame_t f0, sv_frame_t f1) { - int x0 = f0 / m_zoomLevel; - int x1 = f1 / m_zoomLevel; + int x0 = int(f0 / m_zoomLevel); + int x1 = int(f1 / m_zoomLevel); int w = x1 - x0; - int origCentreFrame = m_centreFrame; + sv_frame_t origCentreFrame = m_centreFrame; bool someLayersIncomplete = false; @@ -2440,17 +2440,17 @@ QImage * View::toNewImage() { - int f0 = getModelsStartFrame(); - int f1 = getModelsEndFrame(); + sv_frame_t f0 = getModelsStartFrame(); + sv_frame_t f1 = getModelsEndFrame(); return toNewImage(f0, f1); } QImage * -View::toNewImage(int f0, int f1) +View::toNewImage(sv_frame_t f0, sv_frame_t f1) { - int x0 = f0 / getZoomLevel(); - int x1 = f1 / getZoomLevel(); + int x0 = int(f0 / getZoomLevel()); + int x1 = int(f1 / getZoomLevel()); QImage *image = new QImage(x1 - x0, height(), QImage::Format_RGB32); @@ -2468,17 +2468,17 @@ QSize View::getImageSize() { - int f0 = getModelsStartFrame(); - int f1 = getModelsEndFrame(); + sv_frame_t f0 = getModelsStartFrame(); + sv_frame_t f1 = getModelsEndFrame(); return getImageSize(f0, f1); } QSize -View::getImageSize(int f0, int f1) +View::getImageSize(sv_frame_t f0, sv_frame_t f1) { - int x0 = f0 / getZoomLevel(); - int x1 = f1 / getZoomLevel(); + int x0 = int(f0 / getZoomLevel()); + int x1 = int(f1 / getZoomLevel()); return QSize(x1 - x0, height()); } diff -r 4968bbaf1ed8 -r 26da827e8fb5 view/View.h --- a/view/View.h Mon Mar 23 10:04:51 2015 +0000 +++ b/view/View.h Mon Mar 23 11:26:28 2015 +0000 @@ -23,6 +23,7 @@ #include "base/PropertyContainer.h" #include "ViewManager.h" #include "base/XmlExportable.h" +#include "base/BaseTypes.h" // #define DEBUG_VIEW_WIDGET_PAINT 1 @@ -64,13 +65,13 @@ * This is a calculated value based on the centre-frame, widget * width and zoom level. The result may be negative. */ - int getStartFrame() const; + sv_frame_t getStartFrame() const; /** * Set the widget pan based on the given first visible frame. The * frame value may be negative. */ - void setStartFrame(int); + void setStartFrame(sv_frame_t); /** * Return the centre frame of the visible widget. This is an @@ -78,30 +79,30 @@ * frame values (start, end) are calculated from this based on the * zoom and other factors. */ - int getCentreFrame() const { return m_centreFrame; } + sv_frame_t getCentreFrame() const { return m_centreFrame; } /** * Set the centre frame of the visible widget. */ - void setCentreFrame(int f) { setCentreFrame(f, true); } + void setCentreFrame(sv_frame_t f) { setCentreFrame(f, true); } /** * Retrieve the last visible sample frame on the widget. * This is a calculated value based on the centre-frame, widget * width and zoom level. */ - int getEndFrame() const; + sv_frame_t getEndFrame() const; /** * Return the pixel x-coordinate corresponding to a given sample * frame (which may be negative). */ - int getXForFrame(int frame) const; + int getXForFrame(sv_frame_t frame) const; /** * Return the closest frame to the given pixel x-coordinate. */ - int getFrameForX(int x) const; + sv_frame_t getFrameForX(int x) const; /** * Return the pixel y-coordinate corresponding to a given @@ -111,7 +112,7 @@ * * Not thread-safe in logarithmic mode. Call only from GUI thread. */ - float getYForFrequency(float frequency, float minFreq, float maxFreq, + double getYForFrequency(double frequency, double minFreq, double maxFreq, bool logarithmic) const; /** @@ -120,7 +121,7 @@ * * Not thread-safe in logarithmic mode. Call only from GUI thread. */ - float getFrequencyForY(int y, float minFreq, float maxFreq, + double getFrequencyForY(int y, double minFreq, double maxFreq, bool logarithmic) const; /** @@ -163,7 +164,7 @@ * Return the number of layers, regardless of whether visible or * dormant, i.e. invisible, in this view. */ - virtual int getLayerCount() const { return m_layerStack.size(); } + virtual int getLayerCount() const { return int(m_layerStack.size()); } /** * Return the nth layer, counted in stacking order. That is, @@ -172,7 +173,7 @@ * dormant, i.e. invisible. */ virtual Layer *getLayer(int n) { - if (n < int(m_layerStack.size())) return m_layerStack[n]; + if (in_range_for(m_layerStack, n)) return m_layerStack[n]; else return 0; } @@ -229,7 +230,7 @@ } virtual void setViewManager(ViewManager *m); - virtual void setViewManager(ViewManager *m, int initialFrame); + virtual void setViewManager(ViewManager *m, sv_frame_t initialFrame); virtual ViewManager *getViewManager() const { return m_manager; } virtual void setFollowGlobalPan(bool f); @@ -294,34 +295,34 @@ virtual PropertyContainer *getPropertyContainer(int i); // Render the contents on a wide canvas - virtual QImage *toNewImage(int f0, int f1); + virtual QImage *toNewImage(sv_frame_t f0, sv_frame_t f1); virtual QImage *toNewImage(); - virtual QSize getImageSize(int f0, int f1); + virtual QSize getImageSize(sv_frame_t f0, sv_frame_t f1); virtual QSize getImageSize(); virtual int getTextLabelHeight(const Layer *layer, QPainter &) const; - virtual bool getValueExtents(QString unit, float &min, float &max, + virtual bool getValueExtents(QString unit, double &min, double &max, bool &log) const; virtual void toXml(QTextStream &stream, QString indent = "", QString extraAttributes = "") const; // First frame actually in model, to right of scale, if present - virtual int getFirstVisibleFrame() const; - virtual int getLastVisibleFrame() const; + virtual sv_frame_t getFirstVisibleFrame() const; + virtual sv_frame_t getLastVisibleFrame() const; - int getModelsStartFrame() const; - int getModelsEndFrame() const; + sv_frame_t getModelsStartFrame() const; + sv_frame_t getModelsEndFrame() const; typedef std::set ModelSet; ModelSet getModels(); //!!! Model *getAligningModel() const; - int alignFromReference(int) const; - int alignToReference(int) const; - int getAlignedPlaybackFrame() const; + sv_frame_t alignFromReference(sv_frame_t) const; + sv_frame_t alignToReference(sv_frame_t) const; + sv_frame_t getAlignedPlaybackFrame() const; signals: void propertyContainerAdded(PropertyContainer *pc); @@ -334,7 +335,7 @@ void layerModelChanged(); - void centreFrameChanged(int frame, + void centreFrameChanged(sv_frame_t frame, bool globalScroll, PlaybackFollowMode followMode); @@ -344,7 +345,7 @@ public slots: virtual void modelChanged(); - virtual void modelChangedWithin(int startFrame, int endFrame); + virtual void modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame); virtual void modelCompletionChanged(); virtual void modelAlignmentCompletionChanged(); virtual void modelReplaced(); @@ -353,9 +354,9 @@ virtual void layerMeasurementRectsChanged(); virtual void layerNameChanged(); - virtual void globalCentreFrameChanged(int); - virtual void viewCentreFrameChanged(View *, int); - virtual void viewManagerPlaybackFrameChanged(int); + virtual void globalCentreFrameChanged(sv_frame_t); + virtual void viewCentreFrameChanged(View *, sv_frame_t); + virtual void viewManagerPlaybackFrameChanged(sv_frame_t); virtual void viewZoomLevelChanged(View *, int, bool); virtual void propertyContainerSelected(View *, PropertyContainer *pc); @@ -374,12 +375,12 @@ virtual void paintEvent(QPaintEvent *e); virtual void drawSelections(QPainter &); virtual bool shouldLabelSelections() const { return true; } - virtual bool render(QPainter &paint, int x0, int f0, int f1); + virtual bool render(QPainter &paint, int x0, sv_frame_t f0, sv_frame_t f1); virtual void setPaintFont(QPainter &paint); typedef std::vector LayerList; - int getModelsSampleRate() const; + sv_samplerate_t getModelsSampleRate() const; bool areLayersScrollable() const; LayerList getScrollableBackLayers(bool testChanged, bool &changed) const; LayerList getNonScrollableFrontLayers(bool testChanged, bool &changed) const; @@ -398,25 +399,25 @@ // false. bool hasTopLayerTimeXAxis() const; - bool setCentreFrame(int f, bool doEmit); + bool setCentreFrame(sv_frame_t f, bool doEmit); - void movePlayPointer(int f); + void movePlayPointer(sv_frame_t f); void checkProgress(void *object); int getProgressBarWidth() const; // if visible - int m_centreFrame; + sv_frame_t m_centreFrame; int m_zoomLevel; bool m_followPan; bool m_followZoom; PlaybackFollowMode m_followPlay; bool m_followPlayIsDetached; - int m_playPointerFrame; + sv_frame_t m_playPointerFrame; bool m_lightBackground; bool m_showProgress; QPixmap *m_cache; - int m_cacheCentreFrame; + sv_frame_t m_cacheCentreFrame; int m_cacheZoomLevel; bool m_selectionCached; diff -r 4968bbaf1ed8 -r 26da827e8fb5 view/ViewManager.cpp --- a/view/ViewManager.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/view/ViewManager.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -126,7 +126,7 @@ { } -int +sv_frame_t ViewManager::getGlobalCentreFrame() const { #ifdef DEBUG_VIEW_MANAGER @@ -136,7 +136,7 @@ } void -ViewManager::setGlobalCentreFrame(int f) +ViewManager::setGlobalCentreFrame(sv_frame_t f) { #ifdef DEBUG_VIEW_MANAGER cerr << "ViewManager::setGlobalCentreFrame to " << f << endl; @@ -154,7 +154,7 @@ return m_globalZoom; } -int +sv_frame_t ViewManager::getPlaybackFrame() const { if (m_playSource && m_playSource->isPlaying()) { @@ -164,7 +164,7 @@ } void -ViewManager::setPlaybackFrame(int f) +ViewManager::setPlaybackFrame(sv_frame_t f) { if (m_playbackFrame != f) { m_playbackFrame = f; @@ -187,8 +187,8 @@ m_playbackModel = model; } -int -ViewManager::alignPlaybackFrameToReference(int frame) const +sv_frame_t +ViewManager::alignPlaybackFrameToReference(sv_frame_t frame) const { #ifdef DEBUG_VIEW_MANAGER cerr << "ViewManager::alignPlaybackFrameToReference(" << frame << "): playback model is " << m_playbackModel << endl; @@ -196,7 +196,7 @@ if (!m_playbackModel) { return frame; } else { - int f = m_playbackModel->alignToReference(frame); + sv_frame_t f = m_playbackModel->alignToReference(frame); #ifdef DEBUG_VIEW_MANAGER cerr << "aligned frame = " << f << endl; #endif @@ -204,8 +204,8 @@ } } -int -ViewManager::alignReferenceToPlaybackFrame(int frame) const +sv_frame_t +ViewManager::alignReferenceToPlaybackFrame(sv_frame_t frame) const { #ifdef DEBUG_VIEW_MANAGER cerr << "ViewManager::alignReferenceToPlaybackFrame(" << frame << "): playback model is " << m_playbackModel << endl; @@ -213,7 +213,7 @@ if (!m_playbackModel) { return frame; } else { - int f = m_playbackModel->alignFromReference(frame); + sv_frame_t f = m_playbackModel->alignFromReference(frame); #ifdef DEBUG_VIEW_MANAGER cerr << "aligned frame = " << f << endl; #endif @@ -313,8 +313,8 @@ } } -int -ViewManager::constrainFrameToSelection(int frame) const +sv_frame_t +ViewManager::constrainFrameToSelection(sv_frame_t frame) const { MultiSelection::SelectionList sl = getSelections(); if (sl.empty()) return frame; @@ -373,7 +373,7 @@ } Selection -ViewManager::getContainingSelection(int frame, bool defaultToFollowing) const +ViewManager::getContainingSelection(sv_frame_t frame, bool defaultToFollowing) const { return m_selections.getContainingSelection(frame, defaultToFollowing); } @@ -478,7 +478,7 @@ } } -int +sv_samplerate_t ViewManager::getPlaybackSampleRate() const { if (m_playSource) { @@ -487,7 +487,7 @@ return 0; } -int +sv_samplerate_t ViewManager::getOutputSampleRate() const { if (m_playSource) { @@ -559,7 +559,7 @@ } void -ViewManager::viewCentreFrameChanged(int f, bool locked, +ViewManager::viewCentreFrameChanged(sv_frame_t f, bool locked, PlaybackFollowMode mode) { View *v = dynamic_cast(sender()); @@ -590,15 +590,15 @@ } void -ViewManager::seek(int f) +ViewManager::seek(sv_frame_t f) { #ifdef DEBUG_VIEW_MANAGER cerr << "ViewManager::seek(" << f << ")" << endl; #endif if (m_playSource && m_playSource->isPlaying()) { - int playFrame = m_playSource->getCurrentPlayingFrame(); - int diff = std::max(f, playFrame) - std::min(f, playFrame); + sv_frame_t playFrame = m_playSource->getCurrentPlayingFrame(); + sv_frame_t diff = std::max(f, playFrame) - std::min(f, playFrame); if (diff > 20000) { m_playbackFrame = f; m_playSource->play(f); @@ -723,20 +723,20 @@ int ViewManager::scalePixelSize(int pixels) { - static float ratio = 0.f; - if (ratio == 0.f) { - float baseEm; + static double ratio = 0.0; + if (ratio == 0.0) { + double baseEm; #ifdef Q_OS_MAC - baseEm = 17.f; + baseEm = 17.0; #else - baseEm = 15.f; + baseEm = 15.0; #endif - float em = QFontMetrics(QFont()).height(); + double em = QFontMetrics(QFont()).height(); ratio = em / baseEm; } int scaled = int(pixels * ratio + 0.5); - cerr << "scaledSize: " << pixels << " -> " << scaled << " at ratio " << ratio << endl; +// cerr << "scaledSize: " << pixels << " -> " << scaled << " at ratio " << ratio << endl; if (pixels != 0 && scaled == 0) scaled = 1; return scaled; } diff -r 4968bbaf1ed8 -r 26da827e8fb5 view/ViewManager.h --- a/view/ViewManager.h Mon Mar 23 10:04:51 2015 +0000 +++ b/view/ViewManager.h Mon Mar 23 11:26:28 2015 +0000 @@ -26,6 +26,7 @@ #include "base/Selection.h" #include "base/Command.h" #include "base/Clipboard.h" +#include "base/BaseTypes.h" class AudioPlaySource; class Model; @@ -82,17 +83,17 @@ bool isPlaying() const; - int getGlobalCentreFrame() const; // the set method is a slot + sv_frame_t getGlobalCentreFrame() const; // the set method is a slot int getGlobalZoom() const; - int getPlaybackFrame() const; // the set method is a slot + sv_frame_t getPlaybackFrame() const; // the set method is a slot // Only meaningful in solo mode, and used for optional alignment feature Model *getPlaybackModel() const; void setPlaybackModel(Model *); - int alignPlaybackFrameToReference(int) const; - int alignReferenceToPlaybackFrame(int) const; + sv_frame_t alignPlaybackFrameToReference(sv_frame_t) const; + sv_frame_t alignReferenceToPlaybackFrame(sv_frame_t) const; bool haveInProgressSelection() const; const Selection &getInProgressSelection(bool &exclusive) const; @@ -106,7 +107,7 @@ void addSelection(const Selection &selection); void removeSelection(const Selection &selection); void clearSelections(); - int constrainFrameToSelection(int frame) const; + sv_frame_t constrainFrameToSelection(sv_frame_t frame) const; /** * Adding a selection normally emits the selectionChangedByUser @@ -121,7 +122,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; Clipboard &getClipboard() { return m_clipboard; } @@ -166,23 +167,23 @@ * differ from this will play back at the wrong speed -- there is * no per-model resampler. */ - int getPlaybackSampleRate() const; + sv_samplerate_t getPlaybackSampleRate() const; /** * The sample rate of the audio output device. If the playback * sample rate differs from this, everything will be resampled at * the output stage. */ - int getOutputSampleRate() const; + sv_samplerate_t getOutputSampleRate() const; /** * The sample rate of the current main model. This may in theory * differ from the playback sample rate, in which case even the * main model will play at the wrong speed. */ - int getMainModelSampleRate() const { return m_mainModelSampleRate; } + sv_samplerate_t getMainModelSampleRate() const { return m_mainModelSampleRate; } - void setMainModelSampleRate(int sr) { m_mainModelSampleRate = sr; } + void setMainModelSampleRate(sv_samplerate_t sr) { m_mainModelSampleRate = sr; } /** * Take a "design pixel" size and scale it for the actual @@ -242,16 +243,16 @@ signals: /** Emitted when user causes the global centre frame to change. */ - void globalCentreFrameChanged(int frame); + void globalCentreFrameChanged(sv_frame_t frame); /** Emitted when user scrolls a view, but doesn't affect global centre. */ - void viewCentreFrameChanged(View *v, int frame); + void viewCentreFrameChanged(View *v, sv_frame_t frame); /** Emitted when a view zooms. */ void viewZoomLevelChanged(View *v, int zoom, bool locked); /** Emitted when the playback frame changes. */ - void playbackFrameChanged(int frame); + void playbackFrameChanged(sv_frame_t frame); /** Emitted when the output levels change. Values in range 0.0 -> 1.0. */ void outputLevelsChanged(float left, float right); @@ -299,24 +300,24 @@ void activity(QString); public slots: - void viewCentreFrameChanged(int, bool, PlaybackFollowMode); + void viewCentreFrameChanged(sv_frame_t, bool, PlaybackFollowMode); void viewZoomLevelChanged(int, bool); - void setGlobalCentreFrame(int); - void setPlaybackFrame(int); + void setGlobalCentreFrame(sv_frame_t); + void setPlaybackFrame(sv_frame_t); void playStatusChanged(bool playing); protected slots: void checkPlayStatus(); - void seek(int); + void seek(sv_frame_t); //!!! void considerZoomChange(void *, int, bool); protected: AudioPlaySource *m_playSource; - int m_globalCentreFrame; + sv_frame_t m_globalCentreFrame; int m_globalZoom; - mutable int m_playbackFrame; + mutable sv_frame_t m_playbackFrame; Model *m_playbackModel; //!!! - int m_mainModelSampleRate; + sv_samplerate_t m_mainModelSampleRate; float m_lastLeft; float m_lastRight; diff -r 4968bbaf1ed8 -r 26da827e8fb5 widgets/AudioDial.cpp --- a/widgets/AudioDial.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/widgets/AudioDial.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -121,10 +121,10 @@ QPainter paint; - float angle = AUDIO_DIAL_MIN // offset + double angle = AUDIO_DIAL_MIN // offset + (AUDIO_DIAL_RANGE * - (float(QDial::value() - QDial::minimum()) / - (float(QDial::maximum() - QDial::minimum())))); + (double(QDial::value() - QDial::minimum()) / + (double(QDial::maximum() - QDial::minimum())))); int degrees = int(angle * 180.0 / M_PI); int ns = notchSize(); @@ -268,15 +268,15 @@ // Pointer notch... - float hyp = float(width) / 2.0; - float len = hyp - indent; + double hyp = double(width) / 2.0; + double len = hyp - indent; --len; - float x0 = hyp; - float y0 = hyp; + double x0 = hyp; + double y0 = hyp; - float x = hyp - len * sin(angle); - float y = hyp + len * cos(angle); + double x = hyp - len * sin(angle); + double y = hyp + len * cos(angle); c = palette().dark().color(); pen.setColor(isEnabled() ? c.dark(130) : c); @@ -289,27 +289,27 @@ void AudioDial::drawTick(QPainter &paint, - float angle, int size, bool internal) + double angle, int size, bool internal) { - float hyp = float(size) / 2.0; - float x0 = hyp - (hyp - 1) * sin(angle); - float y0 = hyp + (hyp - 1) * cos(angle); + double hyp = double(size) / 2.0; + double x0 = hyp - (hyp - 1) * sin(angle); + double y0 = hyp + (hyp - 1) * cos(angle); // cerr << "drawTick: angle " << angle << ", size " << size << ", internal " << internal << endl; if (internal) { - float len = hyp / 4; - float x1 = hyp - (hyp - len) * sin(angle); - float y1 = hyp + (hyp - len) * cos(angle); + double len = hyp / 4; + double x1 = hyp - (hyp - len) * sin(angle); + double y1 = hyp + (hyp - len) * cos(angle); paint.drawLine(int(x0), int(y0), int(x1), int(y1)); } else { - float len = hyp / 4; - float x1 = hyp - (hyp + len) * sin(angle); - float y1 = hyp + (hyp + len) * cos(angle); + double len = hyp / 4; + double x1 = hyp - (hyp + len) * sin(angle); + double y1 = hyp + (hyp + len) * cos(angle); paint.drawLine(int(x0), int(y0), int(x1), int(y1)); } @@ -350,7 +350,7 @@ updateMappedValue(value); } -void AudioDial::setDefaultMappedValue(float value) +void AudioDial::setDefaultMappedValue(double value) { m_defaultMappedValue = value; if (m_rangeMapper) { @@ -358,7 +358,7 @@ } } -void AudioDial::setMappedValue(float mappedValue) +void AudioDial::setMappedValue(double mappedValue) { if (m_rangeMapper) { int newPosition = m_rangeMapper->getPositionForValue(mappedValue); @@ -387,7 +387,7 @@ } -float AudioDial::mappedValue() const +double AudioDial::mappedValue() const { if (m_rangeMapper) { // SVDEBUG << "AudioDial::mappedValue(): value = " << value() << ", mappedValue = " << m_mappedValue << endl; @@ -464,11 +464,11 @@ if (m_rangeMapper) { - float min = m_rangeMapper->getValueForPosition(minimum()); - float max = m_rangeMapper->getValueForPosition(maximum()); + double min = m_rangeMapper->getValueForPosition(minimum()); + double max = m_rangeMapper->getValueForPosition(maximum()); if (min > max) { - float tmp = min; + double tmp = min; min = max; max = tmp; } @@ -494,7 +494,7 @@ } } - float newValue = QInputDialog::getDouble + double newValue = QInputDialog::getDouble (this, tr("Enter new value"), text, diff -r 4968bbaf1ed8 -r 26da827e8fb5 widgets/AudioDial.h --- a/widgets/AudioDial.h Mon Mar 23 10:04:51 2015 +0000 +++ b/widgets/AudioDial.h Mon Mar 23 11:26:28 2015 +0000 @@ -73,7 +73,7 @@ void setRangeMapper(RangeMapper *mapper); // I take ownership, will delete const RangeMapper *rangeMapper() const { return m_rangeMapper; } - float mappedValue() const; + double mappedValue() const; int defaultValue() const { return m_defaultValue; } @@ -107,14 +107,14 @@ void setValue(int value); - void setDefaultMappedValue(float mappedValue); + void setDefaultMappedValue(double mappedValue); - void setMappedValue(float mappedValue); + void setMappedValue(double mappedValue); void setToDefault(); protected: - void drawTick(QPainter &paint, float angle, int size, bool internal); + void drawTick(QPainter &paint, double angle, int size, bool internal); virtual void paintEvent(QPaintEvent *); // Alternate mouse behavior event handlers. @@ -133,8 +133,8 @@ QColor m_meterColor; int m_defaultValue; - float m_defaultMappedValue; - float m_mappedValue; + double m_defaultMappedValue; + double m_mappedValue; bool m_noMappedUpdate; // Alternate mouse behavior tracking. diff -r 4968bbaf1ed8 -r 26da827e8fb5 widgets/CSVFormatDialog.cpp --- a/widgets/CSVFormatDialog.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/widgets/CSVFormatDialog.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -30,6 +30,7 @@ #include #include +#include #include "base/Debug.h" @@ -62,7 +63,7 @@ exampleFrame->setPalette(palette); QFont fp; - fp.setPointSize(fp.pointSize() * 0.9); + fp.setPointSize(int(floor(fp.pointSize() * 0.9))); // fp.setFixedPitch(true); // fp.setStyleHint(QFont::TypeWriter); // fp.setFamily("Monospaced"); diff -r 4968bbaf1ed8 -r 26da827e8fb5 widgets/CommandHistory.cpp --- a/widgets/CommandHistory.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/widgets/CommandHistory.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -420,14 +420,14 @@ CommandHistory::documentSaved() { closeBundle(); - m_savedAt = m_undoStack.size(); + m_savedAt = int(m_undoStack.size()); } void CommandHistory::clipCommands() { - if ((int)m_undoStack.size() > m_undoLimit) { - m_savedAt -= (m_undoStack.size() - m_undoLimit); + if (int(m_undoStack.size()) > m_undoLimit) { + m_savedAt -= (int(m_undoStack.size()) - m_undoLimit); } clipStack(m_undoStack, m_undoLimit); diff -r 4968bbaf1ed8 -r 26da827e8fb5 widgets/Fader.cpp --- a/widgets/Fader.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/widgets/Fader.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -110,7 +110,7 @@ if (vx > getMaxX()) vx = getMaxX(); if (vx < 0) vx = 0; - float fval = AudioLevel::fader_to_multiplier + float fval = (float)AudioLevel::fader_to_multiplier (vx, getMaxX(), AudioLevel::LongFader); setValue(fval); @@ -132,20 +132,20 @@ Fader::mouseDoubleClickEvent(QMouseEvent *) { bool ok = false; - float min = AudioLevel::fader_to_dB + float min = (float)AudioLevel::fader_to_dB (0, getMaxX(), AudioLevel::LongFader); - float max = AudioLevel::fader_to_dB + float max = (float)AudioLevel::fader_to_dB (getMaxX(), getMaxX(), AudioLevel::LongFader); - float deft = AudioLevel::multiplier_to_dB(m_value); + float deft = (float)AudioLevel::multiplier_to_dB(m_value); - float dB = QInputDialog::getDouble + float dB = (float)QInputDialog::getDouble (this, tr("Enter new fader level"), tr("New fader level, from %1 to %2 dBFS:").arg(min).arg(max), deft, min, max, 3, &ok); if (ok) { - float value = AudioLevel::dB_to_multiplier(dB); + float value = (float)AudioLevel::dB_to_multiplier(dB); setValue(value); emit valueChanged(value); update(); @@ -179,9 +179,9 @@ //!!! needs improvement if (ev->delta() > 0) { - setValue(m_value * 1.1); + setValue(m_value * 1.f); } else { - setValue(m_value / 1.1); + setValue(m_value / 1.f); } update(); @@ -203,7 +203,7 @@ void Fader::setValue(float v) { - float max = AudioLevel::dB_to_multiplier(10.0); + float max = (float)AudioLevel::dB_to_multiplier(10.0); if (v > max) { v = max; @@ -213,7 +213,7 @@ if (m_value != v) { m_value = v; - float db = AudioLevel::multiplier_to_dB(m_value); + float db = (float)AudioLevel::multiplier_to_dB(m_value); QString text; if (db <= AudioLevel::DB_FLOOR) { text = tr("Level: Off"); diff -r 4968bbaf1ed8 -r 26da827e8fb5 widgets/ItemEditDialog.cpp --- a/widgets/ItemEditDialog.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/widgets/ItemEditDialog.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -28,7 +28,7 @@ #include // for FLT_MIN/MAX -ItemEditDialog::ItemEditDialog(int sampleRate, int options, +ItemEditDialog::ItemEditDialog(sv_samplerate_t sampleRate, int options, QString valueUnits, QWidget *parent) : QDialog(parent), m_sampleRate(sampleRate), @@ -76,7 +76,7 @@ m_frameTimeSpinBox->setSuffix(tr(" frames")); subgrid->addWidget(m_frameTimeSpinBox, subrow, 1, 1, 2); connect(m_frameTimeSpinBox, SIGNAL(valueChanged(int)), - this, SLOT(frameTimeChanged(int))); + this, SLOT(frameTimeChanged(sv_frame_t))); ++subrow; @@ -107,7 +107,7 @@ m_frameDurationSpinBox->setSuffix(tr(" frames")); subgrid->addWidget(m_frameDurationSpinBox, subrow, 1, 1, 2); connect(m_frameDurationSpinBox, SIGNAL(valueChanged(int)), - this, SLOT(frameDurationChanged(int))); + this, SLOT(frameDurationChanged(sv_frame_t))); ++subrow; @@ -193,19 +193,19 @@ } void -ItemEditDialog::setFrameTime(int frame) +ItemEditDialog::setFrameTime(sv_frame_t frame) { if (!m_frameTimeSpinBox) return; RealTime rt(RealTime::frame2RealTime(frame, m_sampleRate)); m_realTimeSecsSpinBox->setValue(rt.sec); m_realTimeUSecsSpinBox->setValue(rt.usec()); - m_frameTimeSpinBox->setValue(frame); + m_frameTimeSpinBox->setValue(int(frame)); m_defaultFrame = frame; m_resetButton->setEnabled(false); } -int +sv_frame_t ItemEditDialog::getFrameTime() const { return m_frameTimeSpinBox->value(); @@ -224,19 +224,19 @@ } void -ItemEditDialog::setFrameDuration(int duration) +ItemEditDialog::setFrameDuration(sv_frame_t duration) { if (!m_frameDurationSpinBox) return; RealTime rt(RealTime::frame2RealTime(duration, m_sampleRate)); m_realDurationSecsSpinBox->setValue(rt.sec); m_realDurationUSecsSpinBox->setValue(rt.usec()); - m_frameDurationSpinBox->setValue(duration); + m_frameDurationSpinBox->setValue(int(duration)); m_defaultDuration = duration; m_resetButton->setEnabled(false); } -int +sv_frame_t ItemEditDialog::getFrameDuration() const { return m_frameDurationSpinBox->value(); @@ -267,7 +267,7 @@ float ItemEditDialog::getValue() const { - return m_valueSpinBox->value(); + return float(m_valueSpinBox->value()); } void @@ -287,7 +287,7 @@ } void -ItemEditDialog::frameTimeChanged(int i) +ItemEditDialog::frameTimeChanged(sv_frame_t i) { m_realTimeSecsSpinBox->blockSignals(true); m_realTimeUSecsSpinBox->blockSignals(true); @@ -306,8 +306,8 @@ { RealTime rt = getRealTime(); rt.sec = i; - int frame = RealTime::realTime2Frame(rt, m_sampleRate); - m_frameTimeSpinBox->setValue(frame); + sv_frame_t frame = RealTime::realTime2Frame(rt, m_sampleRate); + m_frameTimeSpinBox->setValue(int(frame)); m_resetButton->setEnabled(true); } @@ -316,13 +316,13 @@ { RealTime rt = getRealTime(); rt.nsec = i * 1000; - int frame = RealTime::realTime2Frame(rt, m_sampleRate); - m_frameTimeSpinBox->setValue(frame); + sv_frame_t frame = RealTime::realTime2Frame(rt, m_sampleRate); + m_frameTimeSpinBox->setValue(int(frame)); m_resetButton->setEnabled(true); } void -ItemEditDialog::frameDurationChanged(int i) +ItemEditDialog::frameDurationChanged(sv_frame_t i) { m_realDurationSecsSpinBox->blockSignals(true); m_realDurationUSecsSpinBox->blockSignals(true); @@ -341,8 +341,8 @@ { RealTime rt = getRealDuration(); rt.sec = i; - int frame = RealTime::realTime2Frame(rt, m_sampleRate); - m_frameDurationSpinBox->setValue(frame); + sv_frame_t frame = RealTime::realTime2Frame(rt, m_sampleRate); + m_frameDurationSpinBox->setValue(int(frame)); m_resetButton->setEnabled(true); } @@ -351,8 +351,8 @@ { RealTime rt = getRealDuration(); rt.nsec = i * 1000; - int frame = RealTime::realTime2Frame(rt, m_sampleRate); - m_frameDurationSpinBox->setValue(frame); + sv_frame_t frame = RealTime::realTime2Frame(rt, m_sampleRate); + m_frameDurationSpinBox->setValue(int(frame)); m_resetButton->setEnabled(true); } diff -r 4968bbaf1ed8 -r 26da827e8fb5 widgets/ItemEditDialog.h --- a/widgets/ItemEditDialog.h Mon Mar 23 10:04:51 2015 +0000 +++ b/widgets/ItemEditDialog.h Mon Mar 23 11:26:28 2015 +0000 @@ -37,17 +37,17 @@ ShowText = 1 << 3 }; - ItemEditDialog(int sampleRate, int options, QString valueUnits = "", + ItemEditDialog(sv_samplerate_t sampleRate, int options, QString valueUnits = "", QWidget *parent = 0); - void setFrameTime(int frame); - int getFrameTime() const; + void setFrameTime(sv_frame_t frame); + sv_frame_t getFrameTime() const; void setRealTime(RealTime rt); RealTime getRealTime() const; - void setFrameDuration(int frame); - int getFrameDuration() const; + void setFrameDuration(sv_frame_t frame); + sv_frame_t getFrameDuration() const; void setRealDuration(RealTime rt); RealTime getRealDuration() const; @@ -59,10 +59,10 @@ QString getText() const; protected slots: - void frameTimeChanged(int); + void frameTimeChanged(sv_frame_t); void realTimeSecsChanged(int); void realTimeUSecsChanged(int); - void frameDurationChanged(int); + void frameDurationChanged(sv_frame_t); void realDurationSecsChanged(int); void realDurationUSecsChanged(int); void valueChanged(double); @@ -70,9 +70,9 @@ void reset(); protected: - int m_sampleRate; - int m_defaultFrame; - int m_defaultDuration; + sv_samplerate_t m_sampleRate; + sv_frame_t m_defaultFrame; + sv_frame_t m_defaultDuration; float m_defaultValue; QString m_defaultText; QSpinBox *m_frameTimeSpinBox; diff -r 4968bbaf1ed8 -r 26da827e8fb5 widgets/LayerTree.cpp --- a/widgets/LayerTree.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/widgets/LayerTree.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -253,7 +253,7 @@ int ModelMetadataModel::rowCount(const QModelIndex &parent) const { - if (!parent.isValid()) return m_models.size(); + if (!parent.isValid()) return int(m_models.size()); return 0; } diff -r 4968bbaf1ed8 -r 26da827e8fb5 widgets/ListInputDialog.cpp --- a/widgets/ListInputDialog.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/widgets/ListInputDialog.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -67,7 +67,7 @@ { for (size_t i = 0; i < m_radioButtons.size(); ++i) { if (m_radioButtons[i]->isChecked()) { - return m_strings[i]; + return m_strings[int(i)]; } } return ""; diff -r 4968bbaf1ed8 -r 26da827e8fb5 widgets/ModelDataTableDialog.cpp --- a/widgets/ModelDataTableDialog.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/widgets/ModelDataTableDialog.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -168,14 +168,14 @@ } void -ModelDataTableDialog::userScrolledToFrame(int frame) +ModelDataTableDialog::userScrolledToFrame(sv_frame_t frame) { QModelIndex index = m_table->getModelIndexForFrame(frame); makeCurrent(index.row()); } void -ModelDataTableDialog::playbackScrolledToFrame(int frame) +ModelDataTableDialog::playbackScrolledToFrame(sv_frame_t frame) { if (m_trackPlayback) { QModelIndex index = m_table->getModelIndexForFrame(frame); diff -r 4968bbaf1ed8 -r 26da827e8fb5 widgets/ModelDataTableDialog.h --- a/widgets/ModelDataTableDialog.h Mon Mar 23 10:04:51 2015 +0000 +++ b/widgets/ModelDataTableDialog.h Mon Mar 23 11:26:28 2015 +0000 @@ -18,6 +18,8 @@ #include +#include "base/BaseTypes.h" + class TabularModel; class ModelDataTableModel; class QTableView; @@ -38,11 +40,11 @@ QToolBar *getPlayToolbar() { return m_playToolbar; } signals: - void scrollToFrame(int frame); + void scrollToFrame(sv_frame_t frame); public slots: - void userScrolledToFrame(int frame); - void playbackScrolledToFrame(int frame); + void userScrolledToFrame(sv_frame_t frame); + void playbackScrolledToFrame(sv_frame_t frame); void addCommand(Command *); protected slots: diff -r 4968bbaf1ed8 -r 26da827e8fb5 widgets/Panner.cpp --- a/widgets/Panner.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/widgets/Panner.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -65,7 +65,7 @@ float unit = m_scrollUnit; if (unit == 0.f) { unit = float(m_rectHeight) / (6 * float(height())); - if (unit < 0.01) unit = 0.01; + if (unit < 0.01f) unit = 0.01f; } if (!up) { @@ -165,24 +165,24 @@ paint.setBrush(hl); - int rw = lrintf((width() - 1) * m_rectWidth); - int rh = lrintf((height() - 1) * m_rectHeight); + int rw = int(lrintf(float(width() - 1) * m_rectWidth)); + int rh = int(lrintf(float(height() - 1) * m_rectHeight)); if (rw < 2) rw = 2; if (rh < 2) rh = 2; - paint.drawRect(lrintf(width() * m_rectX), - lrintf(height() * m_rectY), + paint.drawRect(int(lrintf(float(width()) * m_rectX)), + int(lrintf(float(height()) * m_rectY)), rw, rh); } void Panner::normalise() { - if (m_rectWidth > 1.0) m_rectWidth = 1.0; - if (m_rectHeight > 1.0) m_rectHeight = 1.0; - if (m_rectX + m_rectWidth > 1.0) m_rectX = 1.0 - m_rectWidth; + if (m_rectWidth > 1.f) m_rectWidth = 1.f; + if (m_rectHeight > 1.f) m_rectHeight = 1.f; + if (m_rectX + m_rectWidth > 1.f) m_rectX = 1.f - m_rectWidth; if (m_rectX < 0) m_rectX = 0; - if (m_rectY + m_rectHeight > 1.0) m_rectY = 1.0 - m_rectHeight; + if (m_rectY + m_rectHeight > 1.f) m_rectY = 1.f - m_rectHeight; if (m_rectY < 0) m_rectY = 0; if (!m_defaultsSet) { diff -r 4968bbaf1ed8 -r 26da827e8fb5 widgets/PluginParameterBox.cpp --- a/widgets/PluginParameterBox.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/widgets/PluginParameterBox.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -70,12 +70,12 @@ m_programCombo = new QComboBox; m_programCombo->setMaxVisibleItems - (m_programs.size() < 25 ? m_programs.size() : 20); + (int(m_programs.size() < 25 ? m_programs.size() : 20)); - for (size_t i = 0; i < m_programs.size(); ++i) { + for (int i = 0; in_range_for(m_programs, i); ++i) { m_programCombo->addItem(m_programs[i].c_str()); if (m_programs[i] == currentProgram) { - m_programCombo->setCurrentIndex(i); + m_programCombo->setCurrentIndex(int(i)); } } @@ -88,7 +88,7 @@ offset = 1; } - for (size_t i = 0; i < params.size(); ++i) { + for (int i = 0; in_range_for(params, i); ++i) { QString identifier = params[i].identifier.c_str(); QString name = params[i].name.c_str(); @@ -120,9 +120,9 @@ if (!(hint & PortHint::Logarithmic)) { if (qtz > 0.0) { - imax = lrintf((max - min) / qtz); + imax = int(lrintf((max - min) / qtz)); } else { - qtz = (max - min) / 100.0; + qtz = (max - min) / 100.f; } } @@ -245,19 +245,19 @@ if (ad && ad->rangeMapper()) { - newValue = ad->mappedValue(); + newValue = float(ad->mappedValue()); if (newValue < min) newValue = min; if (newValue > max) newValue = max; if (qtz != 0.0) { - ival = lrintf((newValue - min) / qtz); - newValue = min + ival * qtz; + ival = int(lrintf((newValue - min) / qtz)); + newValue = min + float(ival) * qtz; } } else { - if (qtz == 0.0) { - qtz = (max - min) / 100.0; + if (qtz == 0.f) { + qtz = (max - min) / 100.f; } - newValue = min + ival * qtz; + newValue = min + float(ival) * qtz; } // SVDEBUG << "PluginParameterBox::dialChanged: newValue = " << newValue << endl; @@ -329,8 +329,8 @@ if (params.isQuantized) qtz = params.quantizeStep; if (qtz > 0.0) { - int step = lrintf((value - min) / qtz); - value = min + step * qtz; + int step = int(lrintf(float(value - min) / qtz)); + value = min + float(step) * qtz; } // int imax = 100; @@ -338,10 +338,10 @@ if (qtz > 0.0) { // imax = lrintf((max - min) / qtz); } else { - qtz = (max - min) / 100.0; + qtz = (max - min) / 100.f; } - int ival = lrintf((value - min) / qtz); + int ival = int(lrintf(float(value - min) / qtz)); AudioDial *dial = m_params[identifier].dial; if (dial) { @@ -356,7 +356,7 @@ SVDEBUG << "setting plugin parameter \"" << identifier << "\" to value " << value << endl; - m_plugin->setParameter(identifier.toStdString(), value); + m_plugin->setParameter(identifier.toStdString(), float(value)); updateProgramCombo(); @@ -389,17 +389,17 @@ if (param.isQuantized) qtz = param.quantizeStep; if (qtz == 0.0) { - qtz = (max - min) / 100.0; + qtz = (max - min) / 100.f; } i->second.dial->blockSignals(true); - i->second.dial->setValue(lrintf((value - min) / qtz)); + i->second.dial->setValue(int(lrintf(float(value - min) / qtz))); i->second.dial->blockSignals(false); } if (i->second.combo) { i->second.combo->blockSignals(true); - i->second.combo->setCurrentIndex(lrintf(value)); + i->second.combo->setCurrentIndex(int(lrintf(value))); i->second.combo->blockSignals(false); } @@ -420,7 +420,7 @@ std::string currentProgram = m_plugin->getCurrentProgram(); - for (size_t i = 0; i < m_programs.size(); ++i) { + for (int i = 0; in_range_for(m_programs, i); ++i) { if (m_programs[i] == currentProgram) { m_programCombo->setCurrentIndex(i); } diff -r 4968bbaf1ed8 -r 26da827e8fb5 widgets/PluginParameterDialog.cpp --- a/widgets/PluginParameterDialog.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/widgets/PluginParameterDialog.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -386,10 +386,10 @@ int size = 1024; int increment = 1024; if (fePlugin) { - size = fePlugin->getPreferredBlockSize(); + size = int(fePlugin->getPreferredBlockSize()); cerr << "Feature extraction plugin \"" << fePlugin->getName() << "\" reports preferred block size as " << size << endl; if (size == 0) size = 1024; - increment = fePlugin->getPreferredStepSize(); + increment = int(fePlugin->getPreferredStepSize()); if (increment == 0) { if (fePlugin->getInputDomain() == Vamp::Plugin::TimeDomain) { increment = size; diff -r 4968bbaf1ed8 -r 26da827e8fb5 widgets/PropertyBox.cpp --- a/widgets/PropertyBox.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/widgets/PropertyBox.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -689,7 +689,7 @@ void PropertyBox::playGainChanged(float gain) { - int dialValue = lrint(log10(gain) * 20.0); + int dialValue = int(lrint(log10(gain) * 20.0)); if (dialValue < -50) dialValue = -50; if (dialValue > 50) dialValue = 50; emit changePlayGainDial(dialValue); @@ -703,7 +703,7 @@ PlayParameters *params = m_container->getPlayParameters(); if (!params) return; - float gain = pow(10, float(dialValue) / 20.0); + float gain = float(pow(10, float(dialValue) / 20.0)); if (params->getPlayGain() != gain) { PlayParameterRepository::EditCommand *command = @@ -718,7 +718,7 @@ void PropertyBox::playPanChanged(float pan) { - int dialValue = lrint(pan * 50.0); + int dialValue = int(lrint(pan * 50.0)); if (dialValue < -50) dialValue = -50; if (dialValue > 50) dialValue = 50; emit changePlayPanDial(dialValue); @@ -732,9 +732,9 @@ PlayParameters *params = m_container->getPlayParameters(); if (!params) return; - float pan = float(dialValue) / 50.0; - if (pan < -1.0) pan = -1.0; - if (pan > 1.0) pan = 1.0; + float pan = float(dialValue) / 50.f; + if (pan < -1.f) pan = -1.f; + if (pan > 1.f) pan = 1.f; if (params->getPlayPan() != pan) { PlayParameterRepository::EditCommand *command = @@ -832,7 +832,7 @@ QString extraText; AudioDial *dial = dynamic_cast(w); if (dial) { - float mv = dial->mappedValue(); + double mv = dial->mappedValue(); QString unit = ""; if (dial->rangeMapper()) unit = dial->rangeMapper()->getUnit(); if (unit != "") { diff -r 4968bbaf1ed8 -r 26da827e8fb5 widgets/PropertyStack.cpp --- a/widgets/PropertyStack.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/widgets/PropertyStack.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -172,7 +172,7 @@ // remain in the same order. So we must find this container in the // box list, not in the view. - for (size_t i = 0; i < m_boxes.size(); ++i) { + for (int i = 0; in_range_for(m_boxes, i); ++i) { PropertyContainer *container = m_boxes[i]->getContainer(); if (pc == container) { return i; diff -r 4968bbaf1ed8 -r 26da827e8fb5 widgets/SubdividingMenu.cpp --- a/widgets/SubdividingMenu.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/widgets/SubdividingMenu.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -53,7 +53,7 @@ { m_entriesSet = true; - int total = entries.size(); + int total = int(entries.size()); if (total < m_upperLimit) return; diff -r 4968bbaf1ed8 -r 26da827e8fb5 widgets/Thumbwheel.cpp --- a/widgets/Thumbwheel.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/widgets/Thumbwheel.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -135,7 +135,7 @@ } void -Thumbwheel::setMappedValue(float mappedValue) +Thumbwheel::setMappedValue(double mappedValue) { if (m_rangeMapper) { int newValue = m_rangeMapper->getPositionForValue(mappedValue); @@ -202,7 +202,7 @@ return m_value; } -float +double Thumbwheel::getMappedValue() const { if (m_rangeMapper) { @@ -240,7 +240,7 @@ void Thumbwheel::scroll(bool up) { - int step = lrintf(m_speed); + int step = int(lrintf(m_speed)); if (step == 0) step = 1; if (up) { @@ -327,11 +327,11 @@ if (m_rangeMapper) { - float min = m_rangeMapper->getValueForPosition(m_min); - float max = m_rangeMapper->getValueForPosition(m_max); + double min = m_rangeMapper->getValueForPosition(m_min); + double max = m_rangeMapper->getValueForPosition(m_max); if (min > max) { - float tmp = min; + double tmp = min; min = max; max = tmp; } @@ -357,7 +357,7 @@ } } - float newValue = QInputDialog::getDouble + double newValue = QInputDialog::getDouble (this, tr("Enter new value"), text, @@ -398,10 +398,10 @@ dist = e->y() - m_clickPos.y(); } - float rotation = m_clickRotation + (m_speed * dist) / 100; + float rotation = m_clickRotation + (m_speed * float(dist)) / 100; if (rotation < 0.f) rotation = 0.f; if (rotation > 1.f) rotation = 1.f; - int value = lrintf(m_min + (m_max - m_min) * m_rotation); + int value = int(lrintf(float(m_min) + float(m_max - m_min) * m_rotation)); if (value != m_value) { setValue(value); if (m_tracking) emit valueChanged(getValue()); @@ -426,7 +426,7 @@ void Thumbwheel::wheelEvent(QWheelEvent *e) { - int step = lrintf(m_speed); + int step = int(lrintf(m_speed)); if (step == 0) step = 1; if (e->delta() > 0) { @@ -469,13 +469,13 @@ paint.setRenderHint(QPainter::Antialiasing, true); - float w = width(); - float w0 = 0.5; - float w1 = w - 0.5; + double w = width(); + double w0 = 0.5; + double w1 = w - 0.5; - float h = height(); - float h0 = 0.5; - float h1 = h - 0.5; + double h = height(); + double h0 = 0.5; + double h1 = h - 0.5; for (int i = bw-1; i >= 0; --i) { @@ -504,7 +504,7 @@ paint.setClipRect(subclip); - float radians = m_rotation * 1.5f * M_PI; + double radians = m_rotation * 1.5f * M_PI; // cerr << "value = " << m_value << ", min = " << m_min << ", max = " << m_max << ", rotation = " << rotation << endl; @@ -518,16 +518,16 @@ for (int i = 0; i < notches; ++i) { - float a0 = (2.f * M_PI * i) / notches + radians; - float a1 = a0 + M_PI / (notches * 2); - float a2 = (2.f * M_PI * (i + 1)) / notches + radians; + double a0 = (2.0 * M_PI * i) / notches + radians; + double a1 = a0 + M_PI / (notches * 2); + double a2 = (2.0 * M_PI * (i + 1)) / notches + radians; - float depth = cosf((a0 + a2) / 2); + double depth = cos((a0 + a2) / 2); if (depth < 0) continue; - float x0 = radius * sinf(a0) + w/2; - float x1 = radius * sinf(a1) + w/2; - float x2 = radius * sinf(a2) + w/2; + double x0 = radius * sin(a0) + w/2; + double x1 = radius * sin(a1) + w/2; + double x2 = radius * sin(a2) + w/2; if (x2 < 0 || x0 > w) continue; if (x0 < 0) x0 = 0; @@ -537,7 +537,7 @@ x1 += bw; x2 += bw; - int grey = lrintf(120 * depth); + int grey = int(lrint(120 * depth)); QColor fc = QColor(grey, grey, grey); QColor oc = palette().highlight().color(); @@ -548,9 +548,9 @@ paint.setBrush(oc); - float prop; + double prop; if (i >= notches / 4) { - prop = float(notches - (((i - float(notches) / 4.f) * 4.f) / 3.f)) + prop = double(notches - (((i - double(notches) / 4.f) * 4.f) / 3.f)) / notches; } else { prop = 0.f; diff -r 4968bbaf1ed8 -r 26da827e8fb5 widgets/Thumbwheel.h --- a/widgets/Thumbwheel.h Mon Mar 23 10:04:51 2015 +0000 +++ b/widgets/Thumbwheel.h Mon Mar 23 11:26:28 2015 +0000 @@ -41,7 +41,7 @@ void setRangeMapper(RangeMapper *mapper); // I take ownership, will delete const RangeMapper *getRangeMapper() const { return m_rangeMapper; } - float getMappedValue() const; + double getMappedValue() const; void setShowToolTip(bool show); @@ -61,7 +61,7 @@ void setTracking(bool tracking); void setShowScale(bool show); void setValue(int value); - void setMappedValue(float mappedValue); + void setMappedValue(double mappedValue); void scroll(bool up); void resetToDefault(); @@ -82,7 +82,7 @@ int m_max; int m_default; int m_value; - float m_mappedValue; + double m_mappedValue; bool m_noMappedUpdate; float m_rotation; Qt::Orientation m_orientation; diff -r 4968bbaf1ed8 -r 26da827e8fb5 widgets/TipDialog.cpp --- a/widgets/TipDialog.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/widgets/TipDialog.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -105,7 +105,7 @@ TipDialog::previous() { if (--m_tipNumber < 0) { - m_tipNumber = m_tips.size() - 1; + m_tipNumber = int(m_tips.size()) - 1; } showTip(); diff -r 4968bbaf1ed8 -r 26da827e8fb5 widgets/TransformFinder.cpp --- a/widgets/TransformFinder.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/widgets/TransformFinder.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -225,11 +225,11 @@ if (m_sortedResults.size() < sorted.size()) { m_infoLabel->setText (tr("Found %n description(s) containing %1, showing the first %2 only", - 0, sorted.size()).arg(text).arg(m_sortedResults.size())); + 0, int(sorted.size())).arg(text).arg(m_sortedResults.size())); } else { m_infoLabel->setText (tr("Found %n description(s) containing %1", - 0, sorted.size()).arg(text)); + 0, int(sorted.size())).arg(text)); } return; diff -r 4968bbaf1ed8 -r 26da827e8fb5 widgets/WindowShapePreview.cpp --- a/widgets/WindowShapePreview.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/widgets/WindowShapePreview.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -32,7 +32,7 @@ WindowShapePreview::WindowShapePreview(QWidget *parent) : QFrame(parent), - m_windowType(WindowType(999)) + m_windowType(HanningWindow) { QHBoxLayout *layout = new QHBoxLayout; layout->setMargin(0); @@ -51,7 +51,7 @@ WindowShapePreview::updateLabels() { int step = 24; - int peak = 48; + float peak = 48; int w = step * 4, h = 64; WindowType type = m_windowType; Window windower = Window(type, step * 2); @@ -62,8 +62,8 @@ QPainterPath path; - path.moveTo(0, h - peak + 1); - path.lineTo(w, h - peak + 1); + path.moveTo(0, float(h) - peak + 1); + path.lineTo(w, float(h) - peak + 1); timePainter.setPen(Qt::gray); timePainter.setRenderHint(QPainter::Antialiasing, true); @@ -84,7 +84,7 @@ } } for (int i = 0; i < w; ++i) { - int y = h - int(peak * acc[i] + 0.001) + 1; + int y = h - int(peak * acc[i] + 0.001f) + 1; if (i == 0) path.moveTo(i, y); else path.lineTo(i, y); } @@ -150,7 +150,7 @@ float power = output[i][0] * output[i][0] + output[i][1] * output[i][1]; float db = mindb; if (power > 0) { - db = 20 * log10(power); + db = 20.f * log10f(power); if (first || db > maxdb) maxdb = db; if (first || db < mindb) mindb = db; first = false; @@ -167,8 +167,8 @@ // float ly = h - ((-80.f + -mindb) / maxval) * peak + 1; - path.moveTo(0, h - peak + 1); - path.lineTo(fw, h - peak + 1); + path.moveTo(0, float(h) - peak + 1); + path.lineTo(fw, float(h) - peak + 1); freqPainter.setPen(Qt::gray); freqPainter.setRenderHint(QPainter::Antialiasing, true); @@ -181,12 +181,12 @@ for (int i = 0; i < fftsize/2; ++i) { float power = output[i][0] * output[i][0] + output[i][1] * output[i][1]; - float db = 20 * log10(power); + float db = 20.f * log10f(power); float val = db + -mindb; if (val < 0) val = 0; float norm = val / maxval; - float x = (fw / float(fftsize/2)) * i; - float y = h - norm * peak + 1; + float x = (float(fw) / float(fftsize/2)) * float(i); + float y = float(h) - norm * peak + 1; if (i == 0) path.moveTo(x, y); else path.lineTo(x, y); } diff -r 4968bbaf1ed8 -r 26da827e8fb5 widgets/WindowTypeSelector.cpp --- a/widgets/WindowTypeSelector.cpp Mon Mar 23 10:04:51 2015 +0000 +++ b/widgets/WindowTypeSelector.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -22,9 +22,23 @@ #include "base/Preferences.h" -WindowTypeSelector::WindowTypeSelector(WindowType defaultType, QWidget *parent) : - QFrame(parent), - m_windowType(WindowType(999)) +WindowTypeSelector::WindowTypeSelector(WindowType defaultType) +{ + init(defaultType); +} + +WindowTypeSelector::WindowTypeSelector() +{ + Preferences *prefs = Preferences::getInstance(); + int min = 0, max = 0, deflt = 0; + WindowType type = + WindowType(prefs->getPropertyRangeAndValue("Window Type", &min, &max, + &deflt)); + init(type); +} + +void +WindowTypeSelector::init(WindowType defaultType) { QVBoxLayout *layout = new QVBoxLayout; layout->setMargin(0); @@ -48,15 +62,10 @@ m_windowShape = new WindowShapePreview; m_windowCombo = new QComboBox; - int min = 0, max = 0, deflt = 0, i = 0; int window = int(defaultType); - if (window == 999) { - window = prefs->getPropertyRangeAndValue("Window Type", &min, &max, - &deflt); - } int index = 0; - for (i = 0; i <= 8; ++i) { + for (int i = 0; i <= 8; ++i) { m_windowCombo->addItem(prefs->getPropertyValueLabel("Window Type", m_windows[i])); if (m_windows[i] == window) index = i; diff -r 4968bbaf1ed8 -r 26da827e8fb5 widgets/WindowTypeSelector.h --- a/widgets/WindowTypeSelector.h Mon Mar 23 10:04:51 2015 +0000 +++ b/widgets/WindowTypeSelector.h Mon Mar 23 11:26:28 2015 +0000 @@ -28,8 +28,8 @@ Q_OBJECT public: - WindowTypeSelector(WindowType defaultType = WindowType(999), // 999 -> get from preferences - QWidget *parent = 0); + WindowTypeSelector(WindowType defaultType); + WindowTypeSelector(); // get window type from preferences virtual ~WindowTypeSelector(); WindowType getWindowType() const; @@ -48,6 +48,8 @@ WindowShapePreview *m_windowShape; WindowType *m_windows; WindowType m_windowType; + + void init(WindowType type); }; #endif