Mercurial > hg > tony
changeset 403:cc33cdb114f6
Merge from cxx11 branch
author | Chris Cannam |
---|---|
date | Mon, 23 Mar 2015 11:26:28 +0000 |
parents | 1610b2b03203 (current diff) a0eedd10dee3 (diff) |
children | 51a51a174fe7 5bedf83681ed |
files | .hgsubstate src/Analyser.cpp src/Analyser.h src/MainWindow.cpp version.h |
diffstat | 12 files changed, 408 insertions(+), 116 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgsubstate Mon Mar 23 10:17:09 2015 +0000 +++ b/.hgsubstate Mon Mar 23 11:26:28 2015 +0000 @@ -2,6 +2,6 @@ d16f0fd6db6104d87882bc43788a3bb1b0f8c528 dataquay 4cbbd87a8c7f95ccac8e7900eef4f08bbdbb032f pyin 553a5f65ef64811747a6613f759622d655db63c1 sv-dependency-builds -2185d52b475892d631c8903075786430226c7620 svapp -c4898e57eea502546201700e773585e157641611 svcore -4968bbaf1ed87860df7d8a4bc68e0c89f122dbab svgui +aa6fb3516e281bae6f9f57f368427374b9138b05 svapp +5c5d4863b42849fdc0e2062858a0c4acc725047b svcore +26da827e8fb52d5fa599b05c01e9360481fdccb9 svgui
--- a/acinclude.m4 Mon Mar 23 10:17:09 2015 +0000 +++ b/acinclude.m4 Mon Mar 23 11:26:28 2015 +0000 @@ -112,3 +112,147 @@ ]) +# 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 <bkoz@redhat.com> +# Copyright (c) 2012 Zack Weinberg <zackw@panix.com> +# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu> +# Copyright (c) 2014 Alexey Sokolov <sokolov@google.com> +# +# 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 <typename T> + 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<check<bool>> right_angle_brackets; + + int a; + decltype(a) b; + + typedef check<int> check_type; + check_type c; + check_type&& cr = static_cast<check_type&&>(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 +]) + +
--- a/configure Mon Mar 23 10:17:09 2015 +0000 +++ b/configure Mon Mar 23 11:26:28 2015 +0000 @@ -681,6 +681,7 @@ EGREP GREP CXXCPP +HAVE_CXX11 MKDIR_P INSTALL_DATA INSTALL_SCRIPT @@ -3469,6 +3470,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 <typename T> + 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<check<bool>> right_angle_brackets; + + int a; + decltype(a) b; + + typedef check<int> check_type; + check_type c; + check_type&& cr = static_cast<check_type&&>(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 <typename T> + 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<check<bool>> right_angle_brackets; + + int a; + decltype(a) b; + + typedef check<int> check_type; + check_type c; + check_type&& cr = static_cast<check_type&&>(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' @@ -4222,9 +4363,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"
--- a/configure.ac Mon Mar 23 10:17:09 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"
--- a/platform-dataquay.pri Mon Mar 23 10:17:09 2015 +0000 +++ b/platform-dataquay.pri Mon Mar 23 11:26:28 2015 +0000 @@ -23,6 +23,7 @@ DEFINES -= USE_REDLAND QMAKE_CXXFLAGS -= -I/usr/include/rasqal -I/usr/include/raptor2 +QMAKE_CXXFLAGS -= -Werror EXTRALIBS -= -lrdf DEFINES += USE_SORD
--- a/src/Analyser.cpp Mon Mar 23 10:17:09 2015 +0000 +++ b/src/Analyser.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -158,14 +158,14 @@ } bool -Analyser::getDisplayFrequencyExtents(float &min, float &max) +Analyser::getDisplayFrequencyExtents(double &min, double &max) { if (!m_layers[Spectrogram]) return false; return m_layers[Spectrogram]->getDisplayExtents(min, max); } bool -Analyser::setDisplayFrequencyExtents(float min, float max) +Analyser::setDisplayFrequencyExtents(double min, double max) { if (!m_layers[Spectrogram]) return false; m_layers[Spectrogram]->setDisplayExtents(min, max); @@ -420,8 +420,8 @@ if (params) params->setPlayPan(1); connect(flexiNoteLayer, SIGNAL(modelCompletionChanged()), this, SLOT(layerCompletionChanged())); - connect(flexiNoteLayer, SIGNAL(reAnalyseRegion(int, int, float, float)), - this, SLOT(reAnalyseRegion(int, int, float, float))); + connect(flexiNoteLayer, SIGNAL(reAnalyseRegion(sv_frame_t, sv_frame_t, float, float)), + this, SLOT(reAnalyseRegion(sv_frame_t, sv_frame_t, float, float))); connect(flexiNoteLayer, SIGNAL(materialiseReAnalysis()), this, SLOT(materialiseReAnalysis())); } @@ -430,7 +430,7 @@ } void -Analyser::reAnalyseRegion(int frame0, int frame1, float freq0, float freq1) +Analyser::reAnalyseRegion(sv_frame_t frame0, sv_frame_t frame1, float freq0, float freq1) { cerr << "Analyser::reAnalyseRegion(" << frame0 << ", " << frame1 << ", " << freq0 << ", " << freq1 << ")" << endl; @@ -506,19 +506,22 @@ t.setBlockSize(2048); if (range.isConstrained()) { - t.setParameter("minfreq", range.min); - t.setParameter("maxfreq", range.max); + t.setParameter("minfreq", float(range.min)); + t.setParameter("maxfreq", float(range.max)); t.setBlockSize(4096); } // get time stamps that align with the 256-sample grid of the original extraction - int startSample = ceil(sel.getStartFrame()*1.0/256) * 256; - int endSample = ceil(sel.getEndFrame()*1.0/256) * 256; + const sv_frame_t grid = 256; + sv_frame_t startSample = (sel.getStartFrame() / grid) * grid; + if (startSample < sel.getStartFrame()) startSample += grid; + sv_frame_t endSample = (sel.getEndFrame() / grid) * grid; + if (endSample < sel.getEndFrame()) endSample += grid; if (!range.isConstrained()) { - startSample -= 4*256; // 4*256 is for 4 frames offset due to timestamp shift - endSample -= 4*256; + startSample -= 4*grid; // 4*256 is for 4 frames offset due to timestamp shift + endSample -= 4*grid; } else { - endSample -= 9*256; // MM says: not sure what the CHP plugin does there + endSample -= 9*grid; // MM says: not sure what the CHP plugin does there } RealTime start = RealTime::frame2RealTime(startSample, m_fileModel->getSampleRate()); RealTime end = RealTime::frame2RealTime(endSample, m_fileModel->getSampleRate()); @@ -802,12 +805,12 @@ } void -Analyser::getEnclosingSelectionScope(int f, int &f0, int &f1) +Analyser::getEnclosingSelectionScope(sv_frame_t f, sv_frame_t &f0, sv_frame_t &f1) { FlexiNoteLayer *flexiNoteLayer = qobject_cast<FlexiNoteLayer *>(m_layers[Notes]); - int f0i = f, f1i = f; + sv_frame_t f0i = f, f1i = f; int res = 1; if (!flexiNoteLayer) {
--- a/src/Analyser.h Mon Mar 23 10:17:09 2015 +0000 +++ b/src/Analyser.h Mon Mar 23 11:26:28 2015 +0000 @@ -55,8 +55,8 @@ void setIntelligentActions(bool); - bool getDisplayFrequencyExtents(float &min, float &max); - bool setDisplayFrequencyExtents(float min, float max); + bool getDisplayFrequencyExtents(double &min, double &max); + bool setDisplayFrequencyExtents(double min, double max); // Return completion %age for initial analysis -- 100 means it's done int getInitialAnalysisCompletion(); @@ -100,14 +100,14 @@ float getPan(Component c) const; void setPan(Component c, float pan); - void getEnclosingSelectionScope(int f, int &f0, int &f1); + void getEnclosingSelectionScope(sv_frame_t f, sv_frame_t &f0, sv_frame_t &f1); struct FrequencyRange { FrequencyRange() : min(0), max(0) { } - FrequencyRange(float min_, float max_) : min(min_), max(max_) { } + FrequencyRange(double min_, double max_) : min(min_), max(max_) { } bool isConstrained() const { return min != max; } - float min; - float max; + double min; + double max; bool operator==(const FrequencyRange &r) { return min == r.min && max == r.max; } @@ -218,7 +218,7 @@ protected slots: void layerAboutToBeDeleted(Layer *); void layerCompletionChanged(); - void reAnalyseRegion(int, int, float, float); + void reAnalyseRegion(sv_frame_t, sv_frame_t, float, float); void materialiseReAnalysis(); protected:
--- a/src/MainWindow.cpp Mon Mar 23 10:17:09 2015 +0000 +++ b/src/MainWindow.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -185,8 +185,8 @@ // variable m_paneStack->setLayoutStyle(PaneStack::NoPropertyStacks); m_paneStack->setShowPaneAccessories(false); - connect(m_paneStack, SIGNAL(doubleClickSelectInvoked(int)), - this, SLOT(doubleClickSelectInvoked(int))); + connect(m_paneStack, SIGNAL(doubleClickSelectInvoked(sv_frame_t)), + this, SLOT(doubleClickSelectInvoked(sv_frame_t))); scroll->setWidget(m_paneStack); m_overview = new Overview(frame); @@ -1279,7 +1279,7 @@ void MainWindow::moveByOneNote(bool right, bool doSelect) { - int frame = m_viewManager->getPlaybackFrame(); + sv_frame_t frame = m_viewManager->getPlaybackFrame(); cerr << "MainWindow::moveByOneNote startframe: " << frame << endl; bool isAtSelectionBoundary = false; @@ -1302,22 +1302,20 @@ if (points.empty()) return; FlexiNoteModel::PointList::iterator i = points.begin(); - std::set<int> snapFrames; + std::set<sv_frame_t> snapFrames; snapFrames.insert(0); while (i != points.end()) { snapFrames.insert(i->frame); snapFrames.insert(i->frame + i->duration + 1); ++i; } - std::set<int>::iterator i2; - if (snapFrames.find(frame) == snapFrames.end()) - { + std::set<sv_frame_t>::iterator i2; + if (snapFrames.find(frame) == snapFrames.end()) { // we're not on an existing snap point, so go to previous snapFrames.insert(frame); } i2 = snapFrames.find(frame); - if (right) - { + if (right) { i2++; if (i2 == snapFrames.end()) i2--; } else { @@ -1554,9 +1552,9 @@ void MainWindow::editDisplayExtents() { - float min, max; - float vmin = 0; - float vmax = getMainModel()->getSampleRate() /2; + double min, max; + double vmin = 0; + double vmax = getMainModel()->getSampleRate() /2; if (!m_analyser->getDisplayFrequencyExtents(min, max)) { //!!! @@ -1566,13 +1564,16 @@ RangeInputDialog dialog(tr("Set frequency range"), tr("Enter new frequency range, from %1 to %2 Hz.\nThese values will be rounded to the nearest spectrogram bin.") .arg(vmin).arg(vmax), - "Hz", vmin, vmax, this); - dialog.setRange(min, max); + "Hz", float(vmin), float(vmax), this); + dialog.setRange(float(min), float(max)); if (dialog.exec() == QDialog::Accepted) { - dialog.getRange(min, max); + float fmin, fmax; + dialog.getRange(fmin, fmax); + min = fmin; + max = fmax; if (min > max) { - float tmp = max; + double tmp = max; max = min; min = tmp; } @@ -2305,9 +2306,9 @@ } void -MainWindow::doubleClickSelectInvoked(int frame) +MainWindow::doubleClickSelectInvoked(sv_frame_t frame) { - int f0, f1; + sv_frame_t f0, f1; m_analyser->getEnclosingSelectionScope(frame, f0, f1); cerr << "MainWindow::doubleClickSelectInvoked(" << frame << "): [" << f0 << "," << f1 << "]" << endl; @@ -2392,11 +2393,11 @@ return; } - int f0 = pane->getFrameForX(r.x()); - int f1 = pane->getFrameForX(r.x() + r.width()); + sv_frame_t f0 = pane->getFrameForX(r.x()); + sv_frame_t f1 = pane->getFrameForX(r.x() + r.width()); - float v0 = spectrogram->getFrequencyForY(pane, r.y() + r.height()); - float v1 = spectrogram->getFrequencyForY(pane, r.y()); + double v0 = spectrogram->getFrequencyForY(pane, r.y() + r.height()); + double v1 = spectrogram->getFrequencyForY(pane, r.y()); cerr << "MainWindow::regionOutlined: frame " << f0 << " -> " << f1 << ", frequency " << v0 << " -> " << v1 << endl; @@ -2627,14 +2628,14 @@ { PlaySpeedRangeMapper mapper(0, 200); - float percent = m_playSpeed->mappedValue(); - float factor = mapper.getFactorForValue(percent); + double percent = m_playSpeed->mappedValue(); + double factor = mapper.getFactorForValue(percent); cerr << "speed = " << position << " percent = " << percent << " factor = " << factor << endl; bool something = (position != 100); - int pc = lrintf(percent); + int pc = int(lrint(percent)); if (!something) { contextHelpChanged(tr("Playback speed: Normal")); @@ -2700,14 +2701,14 @@ void MainWindow::audioGainChanged(int position) { - float level = m_gainAudio->mappedValue(); - float gain = powf(10, level / 20.0); + double level = m_gainAudio->mappedValue(); + double gain = pow(10, level / 20.0); cerr << "gain = " << gain << " (" << position << " dB)" << endl; contextHelpChanged(tr("Audio Gain: %1 dB").arg(position)); - m_analyser->setGain(Analyser::Audio, gain); + m_analyser->setGain(Analyser::Audio, float(gain)); updateMenuStates(); } @@ -2739,14 +2740,14 @@ void MainWindow::pitchGainChanged(int position) { - float level = m_gainPitch->mappedValue(); - float gain = powf(10, level / 20.0); + double level = m_gainPitch->mappedValue(); + double gain = pow(10, level / 20.0); cerr << "gain = " << gain << " (" << position << " dB)" << endl; contextHelpChanged(tr("Pitch Gain: %1 dB").arg(position)); - m_analyser->setGain(Analyser::PitchTrack, gain); + m_analyser->setGain(Analyser::PitchTrack, float(gain)); updateMenuStates(); } @@ -2778,14 +2779,14 @@ void MainWindow::notesGainChanged(int position) { - float level = m_gainNotes->mappedValue(); - float gain = powf(10, level / 20.0); + double level = m_gainNotes->mappedValue(); + double gain = pow(10, level / 20.0); cerr << "gain = " << gain << " (" << position << " dB)" << endl; contextHelpChanged(tr("Notes Gain: %1 dB").arg(position)); - m_analyser->setGain(Analyser::Notes, gain); + m_analyser->setGain(Analyser::Notes, float(gain)); updateMenuStates(); } @@ -2817,14 +2818,14 @@ void MainWindow::audioPanChanged(int position) { - float level = m_panAudio->mappedValue(); - float pan = level/100.f; + double level = m_panAudio->mappedValue(); + double pan = level/100.0; cerr << "pan = " << pan << " (" << position << ")" << endl; contextHelpChanged(tr("Audio Pan: %1").arg(position)); - m_analyser->setPan(Analyser::Audio, pan); + m_analyser->setPan(Analyser::Audio, float(pan)); updateMenuStates(); } @@ -2856,14 +2857,14 @@ void MainWindow::pitchPanChanged(int position) { - float level = m_panPitch->mappedValue(); - float pan = level/100.f; + double level = m_panPitch->mappedValue(); + double pan = level/100.0; cerr << "pan = " << pan << " (" << position << ")" << endl; contextHelpChanged(tr("Pitch Pan: %1").arg(position)); - m_analyser->setPan(Analyser::PitchTrack, pan); + m_analyser->setPan(Analyser::PitchTrack, float(pan)); updateMenuStates(); } @@ -2895,14 +2896,14 @@ void MainWindow::notesPanChanged(int position) { - float level = m_panNotes->mappedValue(); - float pan = level/100.f; + double level = m_panNotes->mappedValue(); + double pan = level/100.0; cerr << "pan = " << pan << " (" << position << ")" << endl; contextHelpChanged(tr("Notes Pan: %1").arg(position)); - m_analyser->setPan(Analyser::Notes, pan); + m_analyser->setPan(Analyser::Notes, float(pan)); updateMenuStates(); } @@ -2939,7 +2940,7 @@ } bool haveSelection = false; - int startFrame = 0, endFrame = 0; + sv_frame_t startFrame = 0, endFrame = 0; if (m_viewManager && m_viewManager->haveInProgressSelection()) { @@ -2997,9 +2998,9 @@ } void -MainWindow::sampleRateMismatch(int /* requested */, - int /* actual */, - bool /* willResample */) +MainWindow::sampleRateMismatch(sv_samplerate_t , + sv_samplerate_t , + bool ) { updateDescriptionLabel(); } @@ -3191,7 +3192,8 @@ void MainWindow::modelRegenerationFailed(QString layerName, - QString transformName, QString message) + QString transformName, + QString message) { if (message != "") { @@ -3342,34 +3344,35 @@ { if (!getMainModel()) return; - int frame = m_viewManager->getPlaybackFrame(); + sv_frame_t frame = m_viewManager->getPlaybackFrame(); ++frame; - size_t sr = getMainModel()->getSampleRate(); + sv_samplerate_t sr = getMainModel()->getSampleRate(); // The step is supposed to scale and be as wide as a step of // m_defaultFfwdRwdStep seconds at zoom level 720 and sr = 44100 - size_t framesPerPixel = m_viewManager->getGlobalZoom(); - size_t defaultZoom = (720 * 44100) / sr; - - float scaler = (framesPerPixel * 1.0f) / defaultZoom; - - + int framesPerPixel = m_viewManager->getGlobalZoom(); + + double defaultZoom = (720 * 44100) / sr; + double scaler = framesPerPixel / defaultZoom; + RealTime step = m_defaultFfwdRwdStep * scaler; + frame = RealTime::realTime2Frame - (RealTime::frame2RealTime(frame, sr) + m_defaultFfwdRwdStep * scaler, sr); - if (frame > int(getMainModel()->getEndFrame())) { + (RealTime::frame2RealTime(frame, sr) + step, sr); + + if (frame > getMainModel()->getEndFrame()) { frame = getMainModel()->getEndFrame(); } - + if (frame < 0) frame = 0; if (m_viewManager->getPlaySelectionMode()) { - frame = m_viewManager->constrainFrameToSelection(size_t(frame)); + frame = m_viewManager->constrainFrameToSelection(frame); } m_viewManager->setPlaybackFrame(frame); - if (frame == (int)getMainModel()->getEndFrame() && + if (frame == getMainModel()->getEndFrame() && m_playSource && m_playSource->isPlaying() && !m_viewManager->getPlayLoopMode()) { @@ -3382,27 +3385,30 @@ { if (!getMainModel()) return; - int frame = m_viewManager->getPlaybackFrame(); + sv_frame_t frame = m_viewManager->getPlaybackFrame(); if (frame > 0) --frame; - size_t sr = getMainModel()->getSampleRate(); + sv_samplerate_t sr = getMainModel()->getSampleRate(); // The step is supposed to scale and be as wide as a step of // m_defaultFfwdRwdStep seconds at zoom level 720 and sr = 44100 - size_t framesPerPixel = m_viewManager->getGlobalZoom(); - size_t defaultZoom = (720 * 44100) / sr; - - float scaler = (framesPerPixel * 1.0f) / defaultZoom; + int framesPerPixel = m_viewManager->getGlobalZoom(); + + double defaultZoom = (720 * 44100) / sr; + double scaler = framesPerPixel / defaultZoom; + RealTime step = m_defaultFfwdRwdStep * scaler; + frame = RealTime::realTime2Frame - (RealTime::frame2RealTime(frame, sr) - m_defaultFfwdRwdStep * scaler, sr); - if (frame < int(getMainModel()->getStartFrame())) { + (RealTime::frame2RealTime(frame, sr) - step, sr); + + if (frame < getMainModel()->getStartFrame()) { frame = getMainModel()->getStartFrame(); } if (frame < 0) frame = 0; if (m_viewManager->getPlaySelectionMode()) { - frame = m_viewManager->constrainFrameToSelection(size_t(frame)); + frame = m_viewManager->constrainFrameToSelection(frame); } m_viewManager->setPlaybackFrame(frame);
--- a/src/MainWindow.h Mon Mar 23 10:17:09 2015 +0000 +++ b/src/MainWindow.h Mon Mar 23 11:26:28 2015 +0000 @@ -27,7 +27,7 @@ Q_OBJECT public: - MainWindow(bool withAudioOutput = true, bool withSonification = true, bool withSpectrogram = true); + MainWindow(bool withAudioOutput = true, bool withSonification = true, bool withSpectrogram = true); virtual ~MainWindow(); signals: @@ -85,7 +85,7 @@ virtual void precisionAnalysisToggled(); virtual void lowampAnalysisToggled(); - virtual void doubleClickSelectInvoked(int); + virtual void doubleClickSelectInvoked(sv_frame_t); virtual void abandonSelection(); virtual void paneAdded(Pane *); @@ -133,7 +133,7 @@ virtual void decreaseNotesPan(); virtual void restoreNormalNotesPan(); - virtual void sampleRateMismatch(int, int, bool); + virtual void sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool); virtual void audioOverloadPluginDisabled(); virtual void audioTimeStretchMultiChannelDisabled(); @@ -231,7 +231,7 @@ KeyReference *m_keyReference; VersionTester *m_versionTester; - int m_selectionAnchor; + sv_frame_t m_selectionAnchor; bool m_withSonification; bool m_withSpectrogram;
--- a/src/main.cpp Mon Mar 23 10:17:09 2015 +0000 +++ b/src/main.cpp Mon Mar 23 11:26:28 2015 +0000 @@ -101,14 +101,7 @@ virtual bool event(QEvent *event) { -// Avoid warnings/errors with -Wextra because we aren't explicitly -// handling all event types (-Wall is OK with this because of the -// default but the stricter level insists) -#pragma GCC diagnostic ignored "-Wswitch-enum" - - switch (event->type()) { - case QEvent::FileOpen: - { + if (event->type() == QEvent::FileOpen) { QString path = static_cast<QFileOpenEvent *>(event)->file(); if (m_readyForFiles) { handleFilepathArgument(path, NULL); @@ -116,8 +109,7 @@ m_filepathQueue.append(path); } return true; - } - default: + } else { return QApplication::event(event); } }