diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index c8e18bbb1..000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,31 +0,0 @@ -clone_depth: 1 -version: "{build}" -image: Visual Studio 2017 -platform: - - x86 - - x64 -environment: - matrix: - - compiler: msvc -install: - - cd C:\Tools\vcpkg - - git pull --quiet - - .\bootstrap-vcpkg.bat - - cd %APPVEYOR_BUILD_FOLDER% - - vcpkg install --triplet %PLATFORM%-windows --recurse fftw3 libsamplerate libsndfile lilv lv2 sdl2 - - nuget install clcache -Version 4.1.0 -build_script: - - cd %APPVEYOR_BUILD_FOLDER% - - mkdir build - - cd build - - ps: $env:CMAKE_PLATFORM="$(if ($env:PLATFORM -eq 'x64') { 'x64' } else { '' })" - - ps: $env:QT_SUFFIX="$(if ($env:PLATFORM -eq 'x64') { '_64' } else { '' })" - - cmake -DUSE_COMPILE_CACHE=ON -DCACHE_TOOL=%APPVEYOR_BUILD_FOLDER%/clcache.4.1.0/clcache-4.1.0/clcache.exe -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_PREFIX_PATH=c:/Qt/5.12/msvc2017%QT_SUFFIX% -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_GENERATOR_PLATFORM="%CMAKE_PLATFORM%" .. - - cmake --build . -- /maxcpucount:4 - - cmake --build . --target tests - - cmake --build . --target package -artifacts: - - path: 'build\lmms-*.exe' - name: Installer -cache: - - c:/tools/vcpkg/installed diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 6e879dbee..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,225 +0,0 @@ -version: 2 - -shared: - restore_cache: &restore_cache - restore_cache: - keys: - - ccache-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ .Branch }} - - ccache-{{ arch }}-{{ .Environment.CIRCLE_JOB }} - - ccache-{{ arch }} - save_cache: &save_cache - save_cache: - key: ccache-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ .Branch }}-{{ .BuildNum }} - paths: - - ~/.ccache - restore_homebrew_cache: &restore_homebrew_cache - restore_cache: - keys: - - homebrew-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ .Branch }} - - homebrew-{{ arch }}-{{ .Environment.CIRCLE_JOB }} - - homebrew-{{ arch }} - save_homebrew_cache: &save_homebrew_cache - save_cache: - key: homebrew-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ .Branch }}-{{ .BuildNum }} - paths: - - ~/Library/Caches/Homebrew - - /usr/local/Homebrew - - ccache_stats: &ccache_stats - run: - name: Print ccache statistics - command: | - echo "[ccache config]" - ccache -p - echo "[ccache stats]" - ccache -s - - # Commmon initializing commands - init: &init - run: - name: Initialize - command: | - mkdir -p /tmp/artifacts - # Workaround for failing submodule fetching - git config --global --unset url."ssh://git@github.com".insteadOf || true - if [[ -n "${CIRCLE_PR_NUMBER}" ]] - then - echo "Fetching out merged pull request" - git fetch -u origin refs/pull/${CIRCLE_PR_NUMBER}/merge:pr/merge - git checkout pr/merge - else - echo "Not a pull request" - fi - - # Commmon environment variables - common_environment: &common_environment - QT5: True - CMAKE_OPTS: -DUSE_WERROR=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUSE_CCACHE=ON - CCACHE_MAXSIZE: 500M - CCACHE_LOGFILE: /tmp/artifacts/ccache.log - MAKEFLAGS: -j6 - -jobs: - mingw32: - environment: - <<: *common_environment - docker: - - image: lmmsci/linux.mingw32:18.04 - steps: - - checkout - - *init - - *restore_cache - - run: - name: Building - command: | - mkdir build && cd build - ../cmake/build_win32.sh - make lmms - make - - run: - name: Build tests - command: cd build && make tests - - run: - name: Build installer - command: | - cd build - make package - cp ./lmms-*.exe /tmp/artifacts/ - - store_artifacts: - path: /tmp/artifacts/ - destination: / - - *ccache_stats - - *save_cache - mingw64: - environment: - <<: *common_environment - docker: - - image: lmmsci/linux.mingw64:18.04 - steps: - - checkout - - *init - - *restore_cache - - run: - name: Building - command: | - mkdir build && cd build - ../cmake/build_win64.sh - make - - run: - name: Build tests - command: cd build && make tests - - run: - name: Build installer - command: | - cd build - make package - cp ./lmms-*.exe /tmp/artifacts/ - - store_artifacts: - path: /tmp/artifacts/ - destination: / - - *ccache_stats - - *save_cache - linux.gcc: - docker: - - image: lmmsci/linux.gcc:18.04 - environment: - <<: *common_environment - steps: - - checkout - - *init - - *restore_cache - - run: - name: Configure - command: | - source /opt/qt5*/bin/qt5*-env.sh || true - mkdir build && cd build - cmake .. $CMAKE_OPTS -DCMAKE_INSTALL_PREFIX=./install - - run: - name: Build - command: cd build && make - - run: - name: Build tests - command: cd build && make tests - - run: - name: Run tests - command: build/tests/tests - - *ccache_stats - - run: - name: Build AppImage - command: | - cd build - make install - make appimage || (cat appimage.log && false) - cp ./lmms-*.AppImage /tmp/artifacts/ - - store_artifacts: - path: /tmp/artifacts/ - destination: / - - store_artifacts: - path: build/appimage.log - destination: / - - *save_cache - shellcheck: - docker: - - image: koalaman/shellcheck-alpine:v0.4.6 - steps: - - checkout - - run: - name: Shellcheck - command: shellcheck $(find "./cmake/" -type f -name '*.sh' -o -name "*.sh.in") - macos: - environment: - <<: *common_environment - macos: - xcode: "10.3.0" - steps: - - checkout - - *init - - *restore_homebrew_cache - - *restore_cache - - run: - name: Install Homebrew dependencies - command: | - # uninstall Homebrew's python 2 to prevent errors on brew install - brew uninstall python@2 || true - # Working around for https://github.com/Homebrew/brew/pull/9383 - (git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core" fetch && git merge FETCH_HEAD --ff-only) || true - (git -C "/usr/local/Homebrew" fetch && git merge FETCH_HEAD --ff-only) || true - brew install ccache fftw cmake pkg-config libogg libvorbis lame libsndfile libsamplerate jack sdl libgig libsoundio lilv lv2 stk fluid-synth portaudio fltk qt5 carla - - run: - name: Install nodejs dependencies - command: npm install -g appdmg - - run: - name: Building - command: | - mkdir build && cd build - cmake .. -DCMAKE_INSTALL_PREFIX="../target" -DCMAKE_PREFIX_PATH="$(brew --prefix qt5)" $CMAKE_OPTS -DUSE_WERROR=OFF - make - - run: - name: Build tests - command: cd build && make tests - - run: - name: Run tests - command: build/tests/tests - - run: - name: Build DMG - command: | - cd build - make install - make dmg - cp ./lmms-*.dmg /tmp/artifacts/ - - store_artifacts: - path: /tmp/artifacts/ - destination: / - - *save_cache - - *save_homebrew_cache - - -workflows: - version: 2 - build-and-test: - jobs: - - macos - - mingw32 - - mingw64 - - linux.gcc - - shellcheck diff --git a/.clang-tidy b/.clang-tidy index 0f978c1de..aff46bba6 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,18 @@ --- -Checks: 'bugprone-macro-parentheses,bugprone-macro-repeated-side-effects,modernize-use-override,readability-identifier-naming,readability-misleading-indentation,readability-simplify-boolean-expr,readability-braces-around-statements' +Checks: > + bugprone-macro-parentheses, + bugprone-macro-repeated-side-effects, + modernize-redundant-void-arg, + modernize-use-bool-literals, + modernize-use-emplace, + modernize-use-equals-default, + modernize-use-equals-delete, + modernize-use-override, + performance-trivially-destructible, + readability-identifier-naming, + readability-misleading-indentation, + readability-simplify-boolean-expr, + readability-braces-around-statements WarningsAsErrors: '' HeaderFilterRegex: '' # don't show errors from headers AnalyzeTemporaryDtors: false diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..007842b82 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,252 @@ +--- +name: build +'on': [push, pull_request] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + linux: + name: linux + runs-on: ubuntu-latest + container: lmmsci/linux.gcc:18.04 + env: + CMAKE_OPTS: >- + -DUSE_WERROR=ON + -DCMAKE_BUILD_TYPE=RelWithDebInfo + -DUSE_COMPILE_CACHE=ON + CCACHE_MAXSIZE: 500M + MAKEFLAGS: -j2 + steps: + - name: Update and configure Git + run: | + add-apt-repository ppa:git-core/ppa + apt-get update + apt-get --yes install git + git config --global --add safe.directory "$GITHUB_WORKSPACE" + - name: Check out + uses: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: recursive + - name: Cache ccache data + uses: actions/cache@v3 + with: + key: ccache-${{ github.job }}-${{ github.ref }}-${{ github.run_id }} + restore-keys: | + ccache-${{ github.job }}-${{ github.ref }}- + ccache-${{ github.job }}- + path: ~/.ccache + - name: Configure + run: | + source /opt/qt5*/bin/qt5*-env.sh || true + mkdir build && cd build + cmake .. $CMAKE_OPTS -DCMAKE_INSTALL_PREFIX=./install + - name: Build + run: cmake --build build + - name: Build tests + run: cmake --build build --target tests + - name: Run tests + run: build/tests/tests + - name: Package + run: | + cmake --build build --target install + cmake --build build --target appimage + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: linux + path: build/lmms-*.AppImage + - name: Print ccache statistics + run: | + echo "[ccache config]" + ccache -p + echo "[ccache stats]" + ccache -s + macos: + name: macos + runs-on: macos-11 + env: + CMAKE_OPTS: >- + -DUSE_WERROR=ON + -DCMAKE_BUILD_TYPE=RelWithDebInfo + -DUSE_COMPILE_CACHE=ON + CCACHE_MAXSIZE: 500M + MAKEFLAGS: -j3 + DEVELOPER_DIR: /Applications/Xcode_11.7.app/Contents/Developer + steps: + - name: Check out + uses: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: recursive + - name: Cache ccache data + uses: actions/cache@v3 + with: + key: ccache-${{ github.job }}-${{ github.ref }}-${{ github.run_id }} + restore-keys: | + ccache-${{ github.job }}-${{ github.ref }}- + ccache-${{ github.job }}- + path: ~/Library/Caches/ccache + - name: Install dependencies + run: | + brew install ccache fftw pkg-config libogg libvorbis lame libsndfile \ + libsamplerate jack sdl libgig libsoundio lilv lv2 stk \ + fluid-synth portaudio fltk qt@5 carla + npm install --location=global appdmg + - name: Configure + run: | + mkdir build + cmake -S . \ + -B build \ + -DCMAKE_INSTALL_PREFIX="../target" \ + -DCMAKE_PREFIX_PATH="$(brew --prefix qt5)" \ + $CMAKE_OPTS \ + -DUSE_WERROR=OFF + - name: Build + run: cmake --build build + - name: Build tests + run: cmake --build build --target tests + - name: Run tests + run: build/tests/tests + - name: Package + run: | + cmake --build build --target install + cmake --build build --target dmg + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: macos + path: build/lmms-*.dmg + - name: Print ccache statistics + run: | + echo "[ccache config]" + ccache -p + echo "[ccache stats]" + ccache -s + mingw: + strategy: + fail-fast: false + matrix: + arch: ['32', '64'] + name: mingw${{ matrix.arch }} + runs-on: ubuntu-latest + container: lmmsci/linux.mingw${{ matrix.arch }}:18.04 + env: + CMAKE_OPTS: >- + -DUSE_WERROR=ON + -DCMAKE_BUILD_TYPE=RelWithDebInfo + -DUSE_COMPILE_CACHE=ON + CCACHE_MAXSIZE: 500M + MAKEFLAGS: -j2 + steps: + - name: Update and configure Git + run: | + add-apt-repository ppa:git-core/ppa + apt-get update + apt-get --yes install git + git config --global --add safe.directory "$GITHUB_WORKSPACE" + - name: Check out + uses: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: recursive + - name: Cache ccache data + uses: actions/cache@v3 + with: + key: "ccache-${{ github.job }}-${{ matrix.arch }}-${{ github.ref }}\ + -${{ github.run_id }}" + restore-keys: | + ccache-${{ github.job }}-${{ matrix.arch }}-${{ github.ref }}- + ccache-${{ github.job }}-${{ matrix.arch }}- + path: ~/.ccache + - name: Configure + run: | + mkdir build && cd build + ../cmake/build_win${{ matrix.arch }}.sh + - name: Build + run: cmake --build build + - name: Build tests + run: cmake --build build --target tests + - name: Package + run: cmake --build build --target package + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: mingw${{ matrix.arch }} + path: build/lmms-*.exe + - name: Print ccache statistics + run: | + echo "[ccache config]" + ccache -p + echo "[ccache stats]" + ccache -s + msvc: + strategy: + fail-fast: false + matrix: + arch: ['x86', 'x64'] + name: msvc-${{ matrix.arch }} + runs-on: windows-2019 + env: + qt-version: '5.15.2' + steps: + - name: Check out + uses: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: recursive + - name: Cache vcpkg dependencies + uses: actions/cache@v3 + with: + key: vcpkg-${{ matrix.arch }}-${{ github.ref }}-${{ github.run_id }} + restore-keys: | + vcpkg-${{ matrix.arch }}-${{ github.ref }}- + vcpkg-${{ matrix.arch }}- + path: C:\vcpkg\installed + - name: Install 64-bit Qt + if: matrix.arch == 'x64' + uses: jurplel/install-qt-action@64bdb64f2c14311d23733a8463e5fcbc65e8775e + with: + version: ${{ env.qt-version }} + arch: win64_msvc2019_64 + archives: qtbase qtsvg qttools + cache: true + - name: Install 32-bit Qt + uses: jurplel/install-qt-action@64bdb64f2c14311d23733a8463e5fcbc65e8775e + with: + version: ${{ env.qt-version }} + arch: win32_msvc2019 + archives: qtbase qtsvg qttools + cache: true + set-env: ${{ matrix.arch == 'x86' }} + - name: Install dependencies + run: | + vcpkg install ` + --triplet=${{ matrix.arch }}-windows ` + --host-triplet=${{ matrix.arch }}-windows ` + --recurse ` + fftw3 fltk fluidsynth[sndfile] libsamplerate libsndfile libstk ` + lilv lv2 portaudio sdl2 + - name: Set up build environment + uses: ilammy/msvc-dev-cmd@d8610e2b41c6d0f0c3b4c46dad8df0fd826c68e1 + with: + arch: ${{ matrix.arch }} + - name: Configure + run: | + mkdir build + cmake -S . ` + -B build ` + -G Ninja ` + --toolchain C:/vcpkg/scripts/buildsystems/vcpkg.cmake ` + -DCMAKE_BUILD_TYPE=RelWithDebInfo + - name: Build + run: cmake --build build + - name: Build tests + run: cmake --build build --target tests + - name: Package + run: cmake --build build --target package + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: msvc-${{ matrix.arch }} + path: build\lmms-*.exe diff --git a/.github/workflows/check-strings.yml b/.github/workflows/check-strings.yml deleted file mode 100644 index a19b17b27..000000000 --- a/.github/workflows/check-strings.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: check-strings - -on: [push] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Install python-tinycss2 - run: sudo apt-get install -y python3-tinycss2 - - name: Update submodules - run: git submodule update --init --recursive - - name: Verify check-strings script - run: tests/check-strings/verify - - name: Run check-strings - run: tests/check-strings/check-strings diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 000000000..1d893989e --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,33 @@ +--- +name: checks +'on': [push, pull_request] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + scripted-checks: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install python-tinycss2 + run: sudo apt-get install -y python3-tinycss2 + - name: Update submodules + run: git submodule update --init --recursive + - name: Verify scripted tests + run: tests/scripted/verify + - name: Run check-strings + run: tests/scripted/check-strings + - name: Run check-namespace + run: tests/scripted/check-namespace + shellcheck: + runs-on: ubuntu-latest + container: koalaman/shellcheck-alpine:v0.4.6 + steps: + - name: Check out + uses: actions/checkout@v3 + - name: Run shellcheck + run: | + shellcheck \ + $(find "./cmake/" -type f -name '*.sh' -o -name "*.sh.in") \ + doc/bash-completion/lmms \ + buildtools/update_locales diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d2d92d897..000000000 --- a/.travis.yml +++ /dev/null @@ -1,33 +0,0 @@ -language: cpp -compiler: gcc -dist: xenial -sudo: required -cache: - directories: - - $HOME/apt_mingw_cache - - $HOME/.ccache - - $HOME/pbuilder-bases -matrix: - include: - - env: TYPE=style - - os: linux - - env: TARGET_OS=debian-sid TARGET_DEPLOY=True - git: - depth: false - - env: TARGET_OS=debian-sid TARGET_ARCH=i386 - git: - depth: false - - compiler: clang - env: TARGET_OS=debian-sid - git: - depth: false - - os: osx - osx_image: xcode10.3 -before_install: - # appdmg doesn't work with old Node.js - - if [ "$TRAVIS_OS_NAME" = osx ]; then nvm install 10; fi -install: ${TRAVIS_BUILD_DIR}/.travis/install.sh -script: ${TRAVIS_BUILD_DIR}/.travis/script.sh -after_script: ${TRAVIS_BUILD_DIR}/.travis/after_script.sh -before_deploy: - - if [ "$TARGET_OS" != debian-sid ]; then make package; fi diff --git a/.travis/after_script.sh b/.travis/after_script.sh deleted file mode 100755 index 6d098b636..000000000 --- a/.travis/after_script.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -set -e - -if [ "$TYPE" != 'style' ]; then - ccache -s -fi diff --git a/.travis/ccache.sha256 b/.travis/ccache.sha256 deleted file mode 100644 index e63145466..000000000 --- a/.travis/ccache.sha256 +++ /dev/null @@ -1 +0,0 @@ -0de866bc0ee26de392e037104b174474989a830e2249280a136144baa44557aa ccache_3.2.4-1_amd64.deb diff --git a/.travis/debian_pkgs.sha256 b/.travis/debian_pkgs.sha256 deleted file mode 100644 index ed4e11737..000000000 --- a/.travis/debian_pkgs.sha256 +++ /dev/null @@ -1,3 +0,0 @@ -314ef4af137903dfb13e8c3ef1e6ea56cfdb23808d52ec4f5f50e288c73610c5 pbuilder_0.229.1_all.deb -fa82aa8ed3055c6f6330104deedf080b26778295e589426d4c4dd0f2c2a5defa debootstrap_1.0.95_all.deb -2ef4c09f7841b72f93412803ddd142f72658536dbfabe00e449eb548f432f3f8 debian-archive-keyring_2017.7ubuntu1_all.deb diff --git a/.travis/install.sh b/.travis/install.sh deleted file mode 100755 index a807d032c..000000000 --- a/.travis/install.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -set -e - -if [ "$TYPE" = 'style' ]; then - sudo apt-get -yqq update - sudo apt-get install shellcheck -else - "$TRAVIS_BUILD_DIR/.travis/$TRAVIS_OS_NAME.$TARGET_OS.before_install.sh" - "$TRAVIS_BUILD_DIR/.travis/$TRAVIS_OS_NAME.$TARGET_OS.install.sh" -fi diff --git a/.travis/linux..before_install.sh b/.travis/linux..before_install.sh deleted file mode 100755 index 9bf8aac01..000000000 --- a/.travis/linux..before_install.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -set -e - -sudo add-apt-repository ppa:beineri/opt-qt592-xenial -y - -sudo dpkg --add-architecture i386 -sudo apt-get update -qq || true diff --git a/.travis/linux..install.sh b/.travis/linux..install.sh deleted file mode 100755 index d56645603..000000000 --- a/.travis/linux..install.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -set -e - -PACKAGES="cmake libsndfile-dev fftw3-dev libvorbis-dev libogg-dev libmp3lame-dev - libasound2-dev libjack-jackd2-dev libsdl-dev libsamplerate0-dev libstk0-dev stk - libfluidsynth-dev portaudio19-dev g++-multilib libfltk1.3-dev fluid - libgig-dev libsoundio-dev qt59base qt59translations qt59tools" - -# swh build dependencies -SWH_PACKAGES="perl libxml2-utils libxml-perl liblist-moreutils-perl" - -# VST dependencies -VST_PACKAGES="wine-dev qt59x11extras qtbase5-private-dev libxcb-util0-dev libxcb-keysyms1-dev" - -# LV2 dependencies; libsuil-dev is not required -LV2_PACKAGES="lv2-dev liblilv-dev" - -# Help with unmet dependencies -PACKAGES="$PACKAGES $SWH_PACKAGES $VST_PACKAGES $LV2_PACKAGES libjack-jackd2-0" - -# shellcheck disable=SC2086 -sudo apt-get install -y $PACKAGES diff --git a/.travis/linux..script.sh b/.travis/linux..script.sh deleted file mode 100755 index e75b827ac..000000000 --- a/.travis/linux..script.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash -unset QTDIR QT_PLUGIN_PATH LD_LIBRARY_PATH -# shellcheck disable=SC1091 -source /opt/qt59/bin/qt59-env.sh - -set -e - -mkdir build -cd build - -# shellcheck disable=SC2086 -cmake -DUSE_WERROR=ON -DCMAKE_INSTALL_PREFIX=../target $CMAKE_FLAGS .. -make -j4 -make tests -./tests/tests diff --git a/.travis/linux.debian-sid.before_install.sh b/.travis/linux.debian-sid.before_install.sh deleted file mode 100755 index 89ee51523..000000000 --- a/.travis/linux.debian-sid.before_install.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -sudo apt-get update -qq diff --git a/.travis/linux.debian-sid.install.sh b/.travis/linux.debian-sid.install.sh deleted file mode 100755 index ef8368822..000000000 --- a/.travis/linux.debian-sid.install.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -set -e - -sudo apt-get install -y \ - dpkg \ - pbuilder - -# work around a pbuilder bug which breaks ccache -# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=666525 -# and also missing signing keys in Trusty's debian-archive-keyring -cd /tmp -wget http://archive.ubuntu.com/ubuntu/pool/main/p/pbuilder/pbuilder_0.229.1_all.deb -wget http://archive.ubuntu.com/ubuntu/pool/main/d/debootstrap/debootstrap_1.0.95_all.deb -wget http://archive.ubuntu.com/ubuntu/pool/universe/d/debian-archive-keyring/debian-archive-keyring_2017.7ubuntu1_all.deb -sha256sum -c "$TRAVIS_BUILD_DIR/.travis/debian_pkgs.sha256" -sudo dpkg -i pbuilder_0.229.1_all.deb debootstrap_1.0.95_all.deb debian-archive-keyring_2017.7ubuntu1_all.deb -cd "$OLDPWD" diff --git a/.travis/linux.debian-sid.script.sh b/.travis/linux.debian-sid.script.sh deleted file mode 100755 index 9b8db416c..000000000 --- a/.travis/linux.debian-sid.script.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -set -e - -: "${TARGET_ARCH:=amd64}" - -BASETGZ="$HOME/pbuilder-bases/debian-sid-$TARGET_ARCH.tgz" -MIRROR=http://cdn-fastly.deb.debian.org/debian -KEYRING=/usr/share/keyrings/debian-archive-keyring.gpg - -if [ -z "$TRAVIS_TAG" ] -then - sudo \ - sh -c "echo CCACHEDIR=$HOME/.ccache >> /etc/pbuilderrc" -fi - -if [ "$CC" = clang ] -then - sudo sh -c "echo EXTRAPACKAGES=clang >> /etc/pbuilderrc" -fi - -if [ ! -e "$BASETGZ.stamp" ] -then - mkdir -p "$HOME/pbuilder-bases" - sudo pbuilder --create --basetgz "$BASETGZ" --mirror $MIRROR \ - --distribution sid --architecture $TARGET_ARCH \ - --debootstrapopts --variant=buildd \ - --debootstrapopts --keyring=$KEYRING \ - --debootstrapopts --include=perl - touch "$BASETGZ.stamp" -else - sudo pbuilder --update --basetgz "$BASETGZ" -fi - -sync_version() { - local VERSION - local MMR - local STAGE - local EXTRA - - VERSION=$(git describe --tags --match v[0-9].[0-9].[0-9]*) - VERSION=${VERSION#v} - MMR=${VERSION%%-*} - case $VERSION in - *-*-*-*) - VERSION=${VERSION%-*} - STAGE=${VERSION#*-} - STAGE=${STAGE%-*} - EXTRA=${VERSION##*-} - VERSION=$MMR~$STAGE.$EXTRA - ;; - *-*-*) - VERSION=${VERSION%-*} - EXTRA=${VERSION##*-} - VERSION=$MMR.$EXTRA - ;; - *-*) - STAGE=${VERSION#*-} - VERSION=$MMR~$STAGE - ;; - esac - - sed "1 s/@VERSION@/$VERSION/" -i debian/changelog - echo "Set Debian version to $VERSION" -} - -sync_version - -DIR="$PWD" -cd .. -dpkg-source -b "$DIR" -env -i CC="$CC" CXX="$CXX" sudo pbuilder --build --debbuildopts "--jobs=auto" \ - --basetgz "$BASETGZ" ./*.dsc diff --git a/.travis/linux.win.download.sh b/.travis/linux.win.download.sh deleted file mode 100755 index 2f914f94e..000000000 --- a/.travis/linux.win.download.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -set -e - -CACHE_DIR=$HOME/apt_mingw_cache/$1 -mkdir -p "$CACHE_DIR" - -pushd "$CACHE_DIR" - -# shellcheck disable=SC2086 -apt-get --print-uris --yes install $MINGW_PACKAGES | grep ^\' | cut -d\' -f2 > downloads.list -wget -N --input-file downloads.list - -sudo cp ./*.deb /var/cache/apt/archives/ - -popd diff --git a/.travis/linux.win32.before_install.sh b/.travis/linux.win32.before_install.sh deleted file mode 100755 index e0cfcbafb..000000000 --- a/.travis/linux.win32.before_install.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -set -e - -sudo add-apt-repository ppa:tobydox/mingw-x-trusty -y -sudo apt-get update -qq diff --git a/.travis/linux.win32.install.sh b/.travis/linux.win32.install.sh deleted file mode 100755 index 6e73e7abe..000000000 --- a/.travis/linux.win32.install.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -set -e - -MINGW_PACKAGES="mingw32-x-sdl mingw32-x-libvorbis mingw32-x-fluidsynth mingw32-x-stk - mingw32-x-glib2 mingw32-x-portaudio mingw32-x-libsndfile mingw32-x-fftw - mingw32-x-flac mingw32-x-fltk mingw32-x-libsamplerate - mingw32-x-pkgconfig mingw32-x-binutils mingw32-x-gcc mingw32-x-runtime - mingw32-x-libgig mingw32-x-libsoundio mingw32-x-lame mingw32-x-qt5base" - -# swh build dependencies -SWH_PACKAGES="perl libxml2-utils libxml-perl liblist-moreutils-perl" - -export MINGW_PACKAGES - -"$TRAVIS_BUILD_DIR/.travis/linux.win.download.sh" win32 - -PACKAGES="nsis cloog-isl libmpc3 qt4-linguist-tools mingw32 $MINGW_PACKAGES $SWH_PACKAGES" - -# shellcheck disable=SC2086 -sudo apt-get install -y $PACKAGES - -# ccache 3.2 is needed because mingw32-x-gcc is version 4.9, which causes cmake -# to use @file command line passing, which in turn ccache 3.1.9 doesn't support -pushd /tmp -wget http://archive.ubuntu.com/ubuntu/pool/main/c/ccache/ccache_3.2.4-1_amd64.deb -sha256sum -c "$TRAVIS_BUILD_DIR/.travis/ccache.sha256" -sudo dpkg -i ccache_3.2.4-1_amd64.deb -popd diff --git a/.travis/linux.win32.script.sh b/.travis/linux.win32.script.sh deleted file mode 100755 index 6e930fd9b..000000000 --- a/.travis/linux.win32.script.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash -set -e - -mkdir build -cd build - -export CMAKE_OPTS="$CMAKE_FLAGS -DUSE_WERROR=ON" -../cmake/build_win32.sh - -make -j4 -make tests diff --git a/.travis/linux.win64.before_install.sh b/.travis/linux.win64.before_install.sh deleted file mode 100755 index 083039391..000000000 --- a/.travis/linux.win64.before_install.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -e - -"$TRAVIS_BUILD_DIR/.travis/linux.win32.before_install.sh" diff --git a/.travis/linux.win64.install.sh b/.travis/linux.win64.install.sh deleted file mode 100755 index 99ef7187f..000000000 --- a/.travis/linux.win64.install.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# First, install 32-bit deps -"$TRAVIS_BUILD_DIR/.travis/linux.win32.install.sh" - -MINGW_PACKAGES="mingw64-x-sdl mingw64-x-libvorbis mingw64-x-fluidsynth mingw64-x-stk - mingw64-x-glib2 mingw64-x-portaudio mingw64-x-libsndfile - mingw64-x-fftw mingw64-x-flac mingw64-x-fltk mingw64-x-libsamplerate - mingw64-x-pkgconfig mingw64-x-binutils mingw64-x-gcc mingw64-x-runtime - mingw64-x-libgig mingw64-x-libsoundio mingw64-x-lame mingw64-x-qt5base" - -export MINGW_PACKAGES - -"$TRAVIS_BUILD_DIR/.travis/linux.win.download.sh" win64 - -# shellcheck disable=SC2086 -sudo apt-get install -y $MINGW_PACKAGES diff --git a/.travis/linux.win64.script.sh b/.travis/linux.win64.script.sh deleted file mode 100755 index d81fa9b58..000000000 --- a/.travis/linux.win64.script.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash -set -e - -mkdir build -cd build - -export CMAKE_OPTS="$CMAKE_FLAGS -DUSE_WERROR=ON" -../cmake/build_win64.sh - -make -j4 -make tests diff --git a/.travis/osx..before_install.sh b/.travis/osx..before_install.sh deleted file mode 100755 index 61f25af66..000000000 --- a/.travis/osx..before_install.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -set -e - -brew update -# Python 2 may cause conflicts on dependency installation -brew unlink python@2 || true diff --git a/.travis/osx..install.sh b/.travis/osx..install.sh deleted file mode 100755 index 42bf66aca..000000000 --- a/.travis/osx..install.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -set -e - -PACKAGES="cmake pkg-config libogg libvorbis lame libsndfile libsamplerate lilv lv2 jack sdl libgig libsoundio stk fluid-synth portaudio node fltk qt carla" - -if "${TRAVIS}"; then - PACKAGES="$PACKAGES ccache" -fi - -# removing already installed packages from the list -for p in $(brew list); do - PACKAGES=${PACKAGES//$p/} -done; - -# shellcheck disable=SC2086 -brew install $PACKAGES - -# fftw tries to install gcc which conflicts with travis -brew install fftw --ignore-dependencies - -npm install -g appdmg diff --git a/.travis/osx..script.sh b/.travis/osx..script.sh deleted file mode 100755 index 373e273f4..000000000 --- a/.travis/osx..script.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -set -e - -mkdir build -cd build - -# Workaround; No FindQt5.cmake module exists -CMAKE_PREFIX_PATH="$(brew --prefix qt5)" -export CMAKE_PREFIX_PATH - -# shellcheck disable=SC2086 -cmake -DUSE_WERROR=OFF -DCMAKE_INSTALL_PREFIX=../target $CMAKE_FLAGS .. - -make -j4 -make tests -./tests/tests diff --git a/.travis/script.sh b/.travis/script.sh deleted file mode 100755 index 21d27b080..000000000 --- a/.travis/script.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env bash - -set -e - -if [ "$TYPE" = 'style' ]; then - - # SC2185 is disabled because of: https://github.com/koalaman/shellcheck/issues/942 - # once it's fixed, it should be enabled again - # shellcheck disable=SC2185 - # shellcheck disable=SC2046 - shellcheck $(find -O3 . -maxdepth 3 -type f -name '*.sh' -o -name "*.sh.in") - shellcheck doc/bash-completion/lmms - -else - - export CMAKE_FLAGS="-DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUNDLE_QT_TRANSLATIONS=ON" - - if [ -z "$TRAVIS_TAG" ]; then - export CMAKE_FLAGS="$CMAKE_FLAGS -DUSE_CCACHE=ON" - fi - - "$TRAVIS_BUILD_DIR/.travis/$TRAVIS_OS_NAME.$TARGET_OS.script.sh" - - # Package and upload non-tagged builds - if [ -n "$TRAVIS_TAG" ]; then - # Skip, handled by travis deploy instead - exit 0 - elif [[ $TARGET_OS == win* ]]; then - cd build - make -j4 package - PACKAGE="$(ls lmms-*win*.exe)" - elif [[ $TRAVIS_OS_NAME == osx ]]; then - cd build - make -j4 install > /dev/null - make dmg - PACKAGE="$(ls lmms-*.dmg)" - elif [[ $TARGET_OS != debian-sid ]]; then - cd build - make -j4 install > /dev/null - make appimage - PACKAGE="$(ls lmms-*.AppImage)" - fi - - echo "Uploading $PACKAGE to transfer.sh..." - # Limit the connection time to 3 minutes and total upload time to 5 minutes - # Otherwise the build may hang - curl --connect-timeout 180 --max-time 300 --upload-file "$PACKAGE" "https://transfer.sh/$PACKAGE" || true -fi diff --git a/CMakeLists.txt b/CMakeLists.txt index a3fcf4050..c5de064a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.9) PROJECT(lmms) @@ -22,6 +22,14 @@ ENDIF(COMMAND CMAKE_POLICY) # Import of windows.h breaks min()/max() ADD_DEFINITIONS(-DNOMINMAX) +# CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES is not set correctly for MinGW until +# CMake 3.14.1, so avoid specifying system include directories on affected +# versions. Normal include directories are safe, since GCC ignores them if they +# are already in the built-in search path. +if(MINGW AND CMAKE_VERSION VERSION_LESS "3.14.1") + set(CMAKE_NO_SYSTEM_FROM_IMPORTED TRUE) +endif() + INCLUDE(PluginList) INCLUDE(CheckSubmodules) INCLUDE(AddFileDependencies) @@ -110,6 +118,7 @@ IF(LMMS_BUILD_WIN32) SET(STATUS_ALSA "") SET(STATUS_PULSEAUDIO "") SET(STATUS_SOUNDIO "") + SET(STATUS_SNDIO "") SET(STATUS_WINMM "OK") SET(STATUS_APPLEMIDI "") ELSE(LMMS_BUILD_WIN32) @@ -208,6 +217,8 @@ IF(WANT_LV2) PKG_CHECK_MODULES(LILV lilv-0) ENDIF() IF(NOT LV2_FOUND AND NOT LILV_FOUND) + UNSET(LV2_FOUND CACHE) + UNSET(LILV_FOUND CACHE) FIND_PACKAGE(LV2 CONFIG) FIND_PACKAGE(LILV CONFIG) IF(LILV_FOUND) @@ -295,17 +306,7 @@ ENDIF(WANT_CARLA) # check for SDL2 IF(WANT_SDL) - # Don't look for SDL2main - SET(SDL2_BUILDING_LIBRARY TRUE) - - # Search for SDL2 using config mode first, then fall back to module mode. - # This allows us to use SDL2's own CMake configuration files if available. - FIND_PACKAGE(SDL2 CONFIG QUIET) - IF(NOT TARGET SDL2::SDL2) - UNSET(SDL2_FOUND) - FIND_PACKAGE(SDL2 MODULE) - ENDIF() - + FIND_PACKAGE(SDL2) IF(SDL2_FOUND) SET(LMMS_HAVE_SDL TRUE) SET(LMMS_HAVE_SDL2 TRUE) @@ -356,13 +357,13 @@ ENDIF(WANT_STK) # check for PortAudio IF(WANT_PORTAUDIO) FIND_PACKAGE(Portaudio) - IF(PORTAUDIO_FOUND) + IF(Portaudio_FOUND) SET(LMMS_HAVE_PORTAUDIO TRUE) SET(STATUS_PORTAUDIO "OK") - ELSE(PORTAUDIO_FOUND) + ELSE() SET(STATUS_PORTAUDIO "not found, please install portaudio19-dev (or similar, version >= 1.9) " "if you require PortAudio support") - ENDIF(PORTAUDIO_FOUND) + ENDIF() ENDIF(WANT_PORTAUDIO) # check for libsoundio @@ -485,6 +486,13 @@ ENDIF(WANT_JACK) FIND_PACKAGE(FFTW COMPONENTS fftw3f REQUIRED) # check for FLTK +set(FLTK_SKIP_OPENGL TRUE) +set(FLTK_SKIP_FORMS TRUE) +set(FLTK_SKIP_IMAGES TRUE) +set(FLTK_SKIP_MATH TRUE) +if(MINGW_PREFIX) + set(FLTK_SKIP_FLUID TRUE) +endif() FIND_PACKAGE(FLTK) IF(FLTK_FOUND) SET(STATUS_ZYN "OK") @@ -494,14 +502,14 @@ ENDIF() # check for Fluidsynth IF(WANT_SF2) - PKG_CHECK_MODULES(FLUIDSYNTH fluidsynth>=1.0.7) - IF(FLUIDSYNTH_FOUND) + find_package(FluidSynth 1.1.0) + if(FluidSynth_FOUND) SET(LMMS_HAVE_FLUIDSYNTH TRUE) SET(STATUS_FLUIDSYNTH "OK") - ELSE(FLUIDSYNTH_FOUND) + else() SET(STATUS_FLUIDSYNTH "not found, libfluidsynth-dev (or similar)" "is highly recommended") - ENDIF(FLUIDSYNTH_FOUND) + endif() ENDIF(WANT_SF2) # check for libgig @@ -602,6 +610,16 @@ SET(CMAKE_CXX_FLAGS "${WERROR_FLAGS} ${CMAKE_CXX_FLAGS}") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DLMMS_DEBUG") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DLMMS_DEBUG") +if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.16") + set(NOOP_COMMAND "${CMAKE_COMMAND}" "-E" "true") +else() + set(NOOP_COMMAND "${CMAKE_COMMAND}" "-E" "echo") +endif() +if(STRIP) + set(STRIP_COMMAND "$,${NOOP_COMMAND},${STRIP}>") +else() + set(STRIP_COMMAND "${NOOP_COMMAND}") +endif() # people simply updating git will still have this and mess up build with it FILE(REMOVE include/lmmsconfig.h) diff --git a/cmake/linux/package_linux.sh.in b/cmake/linux/package_linux.sh.in index a1f9ff865..89e500060 100644 --- a/cmake/linux/package_linux.sh.in +++ b/cmake/linux/package_linux.sh.in @@ -6,9 +6,6 @@ # Notes: Will attempt to fetch linuxdeployqt automatically (x86_64 only) # See Also: https://github.com/probonopd/linuxdeployqt/blob/master/BUILDING.md -set -e - -LINUXDEPLOYQT="@CMAKE_BINARY_DIR@/linuxdeployqt" VERBOSITY=2 # 3=debug LOGFILE="@CMAKE_BINARY_DIR@/appimage.log" APPDIR="@CMAKE_BINARY_DIR@/@PROJECT_NAME_UCASE@.AppDir/" @@ -40,8 +37,21 @@ function skipped { echo -e " ${PLAIN}[${YELLOW}skipped${PLAIN}] ${1}" } +# Exit with error message if any command fails +trap "error 'Failed to generate AppImage'; exit 1" ERR + +# Run a command silently, but print output if it fails +function run_and_log { + echo -e "\n\n>>>>> $1" >> "$LOGFILE" + output="$("$@" 2>&1)" + status=$? + echo "$output" >> "$LOGFILE" + [[ $status != 0 ]] && echo "$output" + return $status +} + # Blindly assume system arch is appimage arch -ARCH=$(arch) +ARCH=$(uname -m) export ARCH # Check for problematic install locations @@ -50,35 +60,39 @@ if [ "$INSTALL" == "/usr/local" ] || [ "$INSTALL" == "/usr" ] ; then error "Incompatible CMAKE_INSTALL_PREFIX for creating AppImage: @CMAKE_INSTALL_PREFIX@" fi -echo -e "\nWriting verbose output to \"${LOGFILE}\"" - # Ensure linuxdeployqt uses the same qmake version as cmake -PATH="$(pwd -P)/squashfs-root/usr/bin:$(dirname "@QT_QMAKE_EXECUTABLE@")":$PATH +PATH="$(dirname "@QT_QMAKE_EXECUTABLE@"):$PATH" export PATH +# Use linuxdeployqt from env or in PATH +[[ $LINUXDEPLOYQT ]] || LINUXDEPLOYQT="$(which linuxdeployqt 2>/dev/null)" || true +[[ $APPIMAGETOOL ]] || APPIMAGETOOL="$(which appimagetool 2>/dev/null)" || true + # Fetch portable linuxdeployqt if not in PATH -APPIMAGETOOL="squashfs-root/usr/bin/appimagetool" -echo -e "\nDownloading linuxdeployqt to ${LINUXDEPLOYQT}..." -if env -i which linuxdeployqt > /dev/null 2>&1; then - skipped "System already provides this utility" -else - filename="linuxdeployqt-continuous-$(uname -p).AppImage" +if [[ -z $LINUXDEPLOYQT || -z $APPIMAGETOOL ]]; then + filename="linuxdeployqt-continuous-$ARCH.AppImage" url="https://github.com/probonopd/linuxdeployqt/releases/download/continuous/$filename" - down_file="$(pwd)/$filename" - if [ ! -f "$LINUXDEPLOYQT" ]; then - ln -s "$down_file" "$LINUXDEPLOYQT" - fi - echo " [.......] Downloading ($(uname -p)): ${url}" - wget -N -q "$url" || (rm "$filename" && false) - chmod +x "$LINUXDEPLOYQT" - success "Downloaded $LINUXDEPLOYQT" + echo " [.......] Downloading: ${url}" + wget -N -q "$url" && err=0 || err=$? + case "$err" in + 0) success "Downloaded $PWD/$filename" ;; + # 8 == server issued 4xx error + 8) error "Download failed (perhaps no package available for $ARCH)" ;; + *) error "Download failed" ;; + esac + # Extract AppImage and replace LINUXDEPLOYQT variable with extracted binary # to support systems without fuse # Also, we need to set LD_LIBRARY_PATH, but linuxdepoyqt's AppRun unsets it # See https://github.com/probonopd/linuxdeployqt/pull/370/ - "$LINUXDEPLOYQT" --appimage-extract > /dev/null 2>&1 - LINUXDEPLOYQT="squashfs-root/usr/bin/linuxdeployqt" - success "Extracted $APPIMAGETOOL" + chmod +x "$filename" + ./"$filename" --appimage-extract >/dev/null + success "Extracted $filename" + + # Use the extracted linuxdeployqt and appimagetool + PATH="$(pwd -P)/squashfs-root/usr/bin:$PATH" + [[ $LINUXDEPLOYQT ]] || LINUXDEPLOYQT="$(which linuxdeployqt)" + [[ $APPIMAGETOOL ]] || APPIMAGETOOL="$(which appimagetool)" fi # Make skeleton AppDir @@ -149,12 +163,14 @@ executables="${executables} -executable=${APPDIR}usr/lib/lmms/ladspa/imbeq_1197. executables="${executables} -executable=${APPDIR}usr/lib/lmms/ladspa/pitch_scale_1193.so" executables="${executables} -executable=${APPDIR}usr/lib/lmms/ladspa/pitch_scale_1194.so" +echo -e "\nWriting verbose output to \"${LOGFILE}\"" +echo -n > "$LOGFILE" + # Bundle both qt and non-qt dependencies into appimage format echo -e "\nBundling and relinking system dependencies..." -echo -e ">>>>> linuxdeployqt" > "$LOGFILE" # shellcheck disable=SC2086 -"$LINUXDEPLOYQT" "$DESKTOPFILE" $executables -bundle-non-qt-libs -verbose=$VERBOSITY $STRIP >> "$LOGFILE" 2>&1 +run_and_log "$LINUXDEPLOYQT" "$DESKTOPFILE" $executables -bundle-non-qt-libs -verbose=$VERBOSITY $STRIP success "Bundled and relinked dependencies" # Link to original location so lmms can find them @@ -187,8 +203,7 @@ ln -sr "${APPDIR}/usr/bin/lmms" "${APPDIR}/AppRun" # Create AppImage echo -e "\nFinishing the AppImage..." -echo -e "\n\n>>>>> appimagetool" >> "$LOGFILE" -"$APPIMAGETOOL" "${APPDIR}" "@APPIMAGE_FILE@" >> "$LOGFILE" 2>&1 +run_and_log "$APPIMAGETOOL" "${APPDIR}" "@APPIMAGE_FILE@" success "Created @APPIMAGE_FILE@" echo -e "\nFinished" diff --git a/cmake/modules/BuildPlugin.cmake b/cmake/modules/BuildPlugin.cmake index 675433e63..f8b3d3153 100644 --- a/cmake/modules/BuildPlugin.cmake +++ b/cmake/modules/BuildPlugin.cmake @@ -76,9 +76,13 @@ MACRO(BUILD_PLUGIN PLUGIN_NAME) ADD_DEPENDENCIES(${PLUGIN_NAME} lmms) ENDIF(LMMS_BUILD_APPLE) IF(LMMS_BUILD_WIN32) - IF(STRIP) - ADD_CUSTOM_COMMAND(TARGET ${PLUGIN_NAME} POST_BUILD COMMAND ${STRIP} "$") - ENDIF() + add_custom_command( + TARGET "${PLUGIN_NAME}" + POST_BUILD + COMMAND "${STRIP_COMMAND}" "$" + VERBATIM + COMMAND_EXPAND_LISTS + ) SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES PREFIX "") ENDIF() diff --git a/cmake/modules/DetectMachine.cmake b/cmake/modules/DetectMachine.cmake index 8ac7dacaa..388efeb82 100644 --- a/cmake/modules/DetectMachine.cmake +++ b/cmake/modules/DetectMachine.cmake @@ -63,7 +63,10 @@ IF(WIN32) MESSAGE(WARNING "Unknown target architecture: ${MSVC_TARGET_PLATFORM}") ENDIF() - IF(MSVC_VER VERSION_GREATER 19.20 OR MSVC_VER VERSION_EQUAL 19.20) + IF(MSVC_VER VERSION_GREATER 19.30 OR MSVC_VER VERSION_EQUAL 19.30) + SET(LMMS_MSVC_GENERATOR "Visual Studio 17 2022") + SET(LMMS_MSVC_YEAR 2022) + ELSEIF(MSVC_VER VERSION_GREATER 19.20 OR MSVC_VER VERSION_EQUAL 19.20) SET(LMMS_MSVC_GENERATOR "Visual Studio 16 2019") SET(LMMS_MSVC_YEAR 2019) # Qt only provides binaries for MSVC 2017, but 2019 is binary compatible ELSEIF(MSVC_VER VERSION_GREATER 19.10 OR MSVC_VER VERSION_EQUAL 19.10) diff --git a/cmake/modules/FindFluidSynth.cmake b/cmake/modules/FindFluidSynth.cmake new file mode 100644 index 000000000..fcc00cd7d --- /dev/null +++ b/cmake/modules/FindFluidSynth.cmake @@ -0,0 +1,73 @@ +# Copyright (c) 2022 Dominic Clark +# +# Redistribution and use is allowed according to the terms of the New BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +# Return if we already have FluidSynth +if(TARGET fluidsynth) + set(FluidSynth_FOUND 1) + return() +endif() + +# Attempt to find FluidSynth using PkgConfig +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_check_modules(FLUIDSYNTH_PKG fluidsynth) +endif() + +# Find the library and headers using the results from PkgConfig as a guide +find_path(FluidSynth_INCLUDE_DIR + NAMES "fluidsynth.h" + HINTS ${FLUIDSYNTH_PKG_INCLUDE_DIRS} +) + +find_library(FluidSynth_LIBRARY + NAMES "fluidsynth" + HINTS ${FLUIDSYNTH_PKG_LIBRARY_DIRS} +) + +if(FluidSynth_INCLUDE_DIR AND FluidSynth_LIBRARY) + add_library(fluidsynth UNKNOWN IMPORTED) + set_target_properties(fluidsynth PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${FluidSynth_INCLUDE_DIR}" + ) + + if(VCPKG_INSTALLED_DIR) + include(ImportedTargetHelpers) + _get_vcpkg_library_configs(FluidSynth_IMPLIB_RELEASE FluidSynth_IMPLIB_DEBUG "${FluidSynth_LIBRARY}") + else() + set(FluidSynth_IMPLIB_RELEASE "${FluidSynth_LIBRARY}") + endif() + + if(FluidSynth_IMPLIB_DEBUG) + set_target_properties(fluidsynth PROPERTIES + IMPORTED_LOCATION_RELEASE "${FluidSynth_IMPLIB_RELEASE}" + IMPORTED_LOCATION_DEBUG "${FluidSynth_IMPLIB_DEBUG}" + ) + else() + set_target_properties(fluidsynth PROPERTIES + IMPORTED_LOCATION "${FluidSynth_IMPLIB_RELEASE}" + ) + endif() + + if(EXISTS "${FluidSynth_INCLUDE_DIR}/fluidsynth/version.h") + file(STRINGS + "${FluidSynth_INCLUDE_DIR}/fluidsynth/version.h" + _version_string + REGEX "^#[\t ]*define[\t ]+FLUIDSYNTH_VERSION[\t ]+\".*\"" + ) + string(REGEX REPLACE + "^.*FLUIDSYNTH_VERSION[\t ]+\"([^\"]*)\".*$" + "\\1" + FluidSynth_VERSION_STRING + "${_version_string}" + ) + unset(_version_string) + endif() +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(FluidSynth + REQUIRED_VARS FluidSynth_LIBRARY FluidSynth_INCLUDE_DIR + VERSION_VAR FluidSynth_VERSION_STRING +) diff --git a/cmake/modules/FindLame.cmake b/cmake/modules/FindLame.cmake index e5dc93bd5..c3fb09c5b 100644 --- a/cmake/modules/FindLame.cmake +++ b/cmake/modules/FindLame.cmake @@ -1,16 +1,37 @@ # - Try to find LAME # Once done this will define # -# LAME_FOUND - system has liblame -# LAME_INCLUDE_DIRS - the liblame include directory -# LAME_LIBRARIES - The liblame libraries +# Lame_FOUND - system has liblame +# Lame_INCLUDE_DIRS - the liblame include directory +# Lame_LIBRARIES - The liblame libraries +# mp3lame::mp3lame - an imported target providing lame -find_path(LAME_INCLUDE_DIRS lame/lame.h) -find_library(LAME_LIBRARIES mp3lame) +find_package(mp3lame CONFIG QUIET) + +if(TARGET mp3lame::mp3lame) + # Extract details for find_package_handle_standard_args + get_target_property(Lame_LIBRARIES mp3lame::mp3lame LOCATION) + get_target_property(Lame_INCLUDE_DIRS mp3lame::mp3lame INTERFACE_INCLUDE_DIRECTORIES) +else() + find_path(Lame_INCLUDE_DIRS lame/lame.h) + find_library(Lame_LIBRARIES mp3lame) + + list(APPEND Lame_DEFINITIONS HAVE_LIBMP3LAME=1) + + mark_as_advanced(Lame_INCLUDE_DIRS Lame_LIBRARIES Lame_DEFINITIONS) + + if(Lame_LIBRARIES AND Lame_INCLUDE_DIRS) + add_library(mp3lame::mp3lame UNKNOWN IMPORTED) + + set_target_properties(mp3lame::mp3lame PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Lame_INCLUDE_DIRS}" + INTERFACE_COMPILE_DEFINITIONS "${Lame_DEFINITIONS}" + IMPORTED_LOCATION "${Lame_LIBRARIES}" + ) + endif() +endif() include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Lame DEFAULT_MSG LAME_INCLUDE_DIRS LAME_LIBRARIES) - -list(APPEND LAME_DEFINITIONS -DHAVE_LIBMP3LAME=1) - -mark_as_advanced(LAME_INCLUDE_DIRS LAME_LIBRARIES LAME_DEFINITIONS) +find_package_handle_standard_args(Lame + REQUIRED_VARS Lame_LIBRARIES Lame_INCLUDE_DIRS +) diff --git a/cmake/modules/FindPortaudio.cmake b/cmake/modules/FindPortaudio.cmake index bb6bdf48b..f9c7699f4 100644 --- a/cmake/modules/FindPortaudio.cmake +++ b/cmake/modules/FindPortaudio.cmake @@ -1,36 +1,44 @@ -# - Try to find Portaudio -# Once done this will define -# -# PORTAUDIO_FOUND - system has Portaudio -# PORTAUDIO_INCLUDE_DIRS - the Portaudio include directory -# PORTAUDIO_LIBRARIES - Link these to use Portaudio -# PORTAUDIO_DEFINITIONS - Compiler switches required for using Portaudio -# -# Copyright (c) 2006 Andreas Schneider +# Copyright (c) 2022 Dominic Clark # # Redistribution and use is allowed according to the terms of the New BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. -# +# Try config mode if possible +find_package(portaudio CONFIG QUIET) -if (PORTAUDIO_LIBRARIES AND PORTAUDIO_INCLUDE_DIRS) - # in cache already - set(PORTAUDIO_FOUND TRUE) -else (PORTAUDIO_LIBRARIES AND PORTAUDIO_INCLUDE_DIRS) - include(FindPkgConfig) - pkg_check_modules(PORTAUDIO portaudio-2.0) - if (PORTAUDIO_FOUND) - if (NOT Portaudio_FIND_QUIETLY) - message(STATUS "Found Portaudio: ${PORTAUDIO_LIBRARIES}") - endif (NOT Portaudio_FIND_QUIETLY) - else (PORTAUDIO_FOUND) - if (Portaudio_FIND_REQUIRED) - message(FATAL_ERROR "Could not find Portaudio") - endif (Portaudio_FIND_REQUIRED) - endif (PORTAUDIO_FOUND) +if(TARGET portaudio) + # Extract details for find_package_handle_standard_args + get_target_property(Portaudio_LIBRARY portaudio LOCATION) + get_target_property(Portaudio_INCLUDE_DIR portaudio INTERFACE_INCLUDE_DIRECTORIES) +else() + # Attempt to find PortAudio using PkgConfig, if we have it + find_package(PkgConfig QUIET) + if(PKG_CONFIG_FOUND) + pkg_check_modules(PORTAUDIO_PKG portaudio-2.0) + endif() - # show the PORTAUDIO_INCLUDE_DIRS and PORTAUDIO_LIBRARIES variables only in the advanced view - mark_as_advanced(PORTAUDIO_INCLUDE_DIRS PORTAUDIO_LIBRARIES) + # Find the library and headers using the results from PkgConfig as a guide + find_library(Portaudio_LIBRARY + NAMES "portaudio" + HINTS ${PORTAUDIO_PKG_LIBRARY_DIRS} + ) -endif (PORTAUDIO_LIBRARIES AND PORTAUDIO_INCLUDE_DIRS) + find_path(Portaudio_INCLUDE_DIR + NAMES "portaudio.h" + HINTS ${PORTAUDIO_PKG_INCLUDE_DIRS} + ) + # Create an imported target for PortAudio if we succeeded in finding it. + if(Portaudio_LIBRARY AND Portaudio_INCLUDE_DIR) + add_library(portaudio UNKNOWN IMPORTED) + set_target_properties(portaudio PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Portaudio_INCLUDE_DIR}" + IMPORTED_LOCATION "${Portaudio_LIBRARY}" + ) + endif() +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Portaudio + REQUIRED_VARS Portaudio_LIBRARY Portaudio_INCLUDE_DIR +) diff --git a/cmake/modules/FindSDL2.cmake b/cmake/modules/FindSDL2.cmake index 513578813..3bad1002e 100644 --- a/cmake/modules/FindSDL2.cmake +++ b/cmake/modules/FindSDL2.cmake @@ -1,60 +1,20 @@ # This module defines # SDL2::SDL2, a target providing SDL2 itself -# SDL2::SDL2main, a target providing an entry point for applications # SDL2_LIBRARY, the name of the library to link against # SDL2_FOUND, if false, do not try to link to SDL2 # SDL2_INCLUDE_DIR, where to find SDL.h # -# This module responds to the the flag: -# SDL2_BUILDING_LIBRARY -# If this is defined, then no SDL2::SDL2main target will be created because -# only applications need main(). -# Otherwise, it is assumed you are building an application and this -# module will attempt to locate and set the the proper link flags -# as part of the SDL2::SDL2main target. -# -# Don't forget to include SDLmain.h and SDLmain.m your project for the -# OS X framework based version. (Other versions link to -lSDL2main which -# this module will try to find on your behalf.) Also for OS X, this -# module will automatically add the -framework Cocoa on your behalf. -# -# -# Additional Note: If you see an empty SDL2_LIBRARY in your configuration, it -# means CMake did not find your SDL2 library (SDL2.dll, libsdl2.so, -# SDL2.framework, etc). -# Set SDL2_LIBRARY to point to your SDL2 library, and configure again. -# Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this value -# as appropriate. -# -# -# Modified by Dominic Clark. -# Added modern CMake targets to match those SDL2 itself uses. -# -# $SDL2DIR is an environment variable that would -# correspond to the ./configure --prefix=$SDL2DIR -# used in building SDL2. -# l.e.galup 9-20-02 -# -# Modified by Eric Wing. -# Added code to assist with automated building by using environmental variables -# and providing a more controlled/consistent search behavior. -# Added new modifications to recognize OS X frameworks and -# additional Unix paths (FreeBSD, etc). -# Also corrected the header search path to follow "proper" SDL guidelines. -# Added a search for SDL2main which is needed by some platforms. -# Added a search for threads which is needed by some platforms. -# Added needed compile switches for MinGW. -# # On OSX, this will prefer the Framework version (if found) over others. # People will have to manually change the cache values of # SDL2_LIBRARY to override this selection or set the CMake environment # CMAKE_INCLUDE_PATH to modify the search paths. # -# Note that the header path has changed from SDL2/SDL.h to just SDL.h -# This needed to change because "proper" SDL convention -# is #include "SDL.h", not . This is done for portability -# reasons because not all systems place things in SDL2/ (see FreeBSD). - +# $SDL2DIR is an environment variable that would +# correspond to the ./configure --prefix=$SDL2DIR +# used in building SDL2. +# +# Modified by Eric Wing, l.e.galup, and Dominic Clark +# #============================================================================= # Copyright 2003-2009 Kitware, Inc. # @@ -68,110 +28,91 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -# message("") +# Try config mode first - anything SDL2 itself provides is likely to be more +# reliable than our guesses. +find_package(SDL2 CONFIG QUIET) -SET(SDL2_SEARCH_PATHS - ~/Library/Frameworks - /Library/Frameworks - /usr/local - /usr - /sw # Fink - /opt/local # DarwinPorts - /opt/csw # Blastwave - /opt - ${SDL2_PATH} -) - -FIND_PATH(SDL2_INCLUDE_DIR SDL.h - HINTS - $ENV{SDL2DIR} - PATH_SUFFIXES SDL2 include/SDL2 include - PATHS ${SDL2_SEARCH_PATHS} -) - -if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(PATH_SUFFIXES lib64 lib/x64 lib) -else() - set(PATH_SUFFIXES lib/x86 lib) -endif() - -FIND_LIBRARY(SDL2_LIBRARY - NAMES SDL2 - HINTS - $ENV{SDL2DIR} - PATH_SUFFIXES ${PATH_SUFFIXES} - PATHS ${SDL2_SEARCH_PATHS} -) - -IF(NOT SDL2_BUILDING_LIBRARY) - IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework") - # Non-OS X framework versions expect you to also dynamically link to - # SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms - # seem to provide SDL2main for compatibility even though they don't - # necessarily need it. - FIND_LIBRARY(SDL2MAIN_LIBRARY - NAMES SDL2main - HINTS - $ENV{SDL2DIR} - PATH_SUFFIXES ${PATH_SUFFIXES} - PATHS ${SDL2_SEARCH_PATHS} - ) - ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework") -ENDIF(NOT SDL2_BUILDING_LIBRARY) - -# SDL2 may require threads on your system. -# The Apple build may not need an explicit flag because one of the -# frameworks may already provide it. -# But for non-OSX systems, I will use the CMake Threads package. -IF(NOT APPLE) - FIND_PACKAGE(Threads) -ENDIF(NOT APPLE) - -# MinGW needs an additional link flag, -mwindows -# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -mwindows -IF(MINGW) - SET(MINGW32_LIBRARY mingw32 "-mwindows" CACHE STRING "mwindows for MinGW") -ENDIF(MINGW) - -IF(SDL2_LIBRARY) - ADD_LIBRARY(SDL2::SDL2 UNKNOWN IMPORTED) - SET_TARGET_PROPERTIES(SDL2::SDL2 PROPERTIES - IMPORTED_LOCATION "${SDL2_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}" +if(TARGET SDL2::SDL2) + # Extract details for find_package_handle_standard_args + get_target_property(SDL2_LIBRARY SDL2::SDL2 LOCATION) + get_target_property(SDL2_INCLUDE_DIR SDL2::SDL2 INTERFACE_INCLUDE_DIRECTORIES) +else() + set(SDL2_SEARCH_PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt + ${SDL2_PATH} ) - # For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa. - IF(APPLE) - SET_PROPERTY(TARGET SDL2::SDL2 APPEND PROPERTY - INTERFACE_LINK_OPTIONS "-framework Cocoa" - ) - ENDIF(APPLE) - - # For threads, as mentioned Apple doesn't need this. - # In fact, there seems to be a problem if I used the Threads package - # and try using this line, so I'm just skipping it entirely for OS X. - IF(NOT APPLE AND Threads_FOUND) - SET_PROPERTY(TARGET SDL2::SDL2 APPEND PROPERTY - INTERFACE_LINK_LIBRARIES "Threads::Threads" - ) - ENDIF(NOT APPLE AND Threads_FOUND) -ENDIF(SDL2_LIBRARY) - -IF(NOT SDL2_BUILDING_LIBRARY AND SDL2MAIN_LIBRARY) - ADD_LIBRARY(SDL2::SDL2main STATIC IMPORTED) - SET_TARGET_PROPERTIES(SDL2::SDL2main PROPERTIES - IMPORTED_LOCATION "${SDL2MAIN_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}" + find_path(SDL2_INCLUDE_DIR + NAMES SDL.h + HINTS $ENV{SDL2DIR} ${SDL2_INCLUDE_DIRS} + PATH_SUFFIXES SDL2 include/SDL2 include + PATHS ${SDL2_SEARCH_PATHS} ) - IF(MINGW) - SET_PROPERTY(TARGET SDL2::SDL2main APPEND PROPERTY - INTERFACE_LINK_OPTIONS "${MINGW32_LIBRARY}" + + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(PATH_SUFFIXES lib64 lib/x64 lib) + else() + set(PATH_SUFFIXES lib/x86 lib) + endif() + + find_library(SDL2_LIBRARY + NAMES SDL2 + HINTS $ENV{SDL2DIR} ${SDL2_LIBDIR} + PATH_SUFFIXES ${PATH_SUFFIXES} + PATHS ${SDL2_SEARCH_PATHS} + ) + + # SDL2 may require threads on your system. + # The Apple build may not need an explicit flag because one of the + # frameworks may already provide it. + # But for non-OSX systems, I will use the CMake Threads package. + if(NOT APPLE) + find_package(Threads) + endif() + + if(SDL2_LIBRARY AND SDL2_INCLUDE_DIR) + add_library(SDL2::SDL2 UNKNOWN IMPORTED) + set_target_properties(SDL2::SDL2 PROPERTIES + IMPORTED_LOCATION "${SDL2_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}" ) - ENDIF(MINGW) -ENDIF(NOT SDL2_BUILDING_LIBRARY AND SDL2MAIN_LIBRARY) -# message("") + # For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa. + if(APPLE) + set_property(TARGET SDL2::SDL2 APPEND PROPERTY + INTERFACE_LINK_OPTIONS "-framework Cocoa" + ) + endif() -INCLUDE(FindPackageHandleStandardArgs) + # For threads, as mentioned Apple doesn't need this. + # In fact, there seems to be a problem if I used the Threads package + # and try using this line, so I'm just skipping it entirely for OS X. + if(NOT APPLE AND Threads_FOUND) + set_property(TARGET SDL2::SDL2 APPEND PROPERTY + INTERFACE_LINK_LIBRARIES "Threads::Threads" + ) + endif() -FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR) + if(EXISTS "${SDL2_INCLUDE_DIR}/SDL_version.h") + file(READ "${SDL2_INCLUDE_DIR}/SDL_version.h" _sdl_version_h) + string(REGEX REPLACE ".*#[\t ]*define[\t ]+SDL_MAJOR_VERSION[\t ]+([0-9]+).*" "\\1" SDL2_VERSION_MAJOR "${_sdl_version_h}") + string(REGEX REPLACE ".*#[\t ]*define[\t ]+SDL_MINOR_VERSION[\t ]+([0-9]+).*" "\\1" SDL2_VERSION_MINOR "${_sdl_version_h}") + string(REGEX REPLACE ".*#[\t ]*define[\t ]+SDL_PATCHLEVEL[\t ]+([0-9]+).*" "\\1" SDL2_VERSION_PATCH "${_sdl_version_h}") + set(SDL2_VERSION "${SDL2_VERSION_MAJOR}.${SDL2_VERSION_MINOR}.${SDL2_VERSION_PATCH}") + unset(_sdl_version_h) + endif() + endif() +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(SDL2 + REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR + VERSION_VAR SDL2_VERSION +) diff --git a/cmake/modules/FindSTK.cmake b/cmake/modules/FindSTK.cmake index 6c2f16de4..80ed0da42 100644 --- a/cmake/modules/FindSTK.cmake +++ b/cmake/modules/FindSTK.cmake @@ -1,20 +1,32 @@ -FIND_PATH(STK_INCLUDE_DIR Stk.h /usr/include/stk /usr/local/include/stk ${CMAKE_INSTALL_PREFIX}/include/stk ${CMAKE_FIND_ROOT_PATH}/include/stk) +# Try config mode first +find_package(unofficial-libstk CONFIG QUIET) -FIND_LIBRARY(STK_LIBRARY NAMES stk PATH /usr/lib /usr/local/lib ${CMAKE_INSTALL_PREFIX}/lib ${CMAKE_FIND_ROOT_PATH}/lib) +if(TARGET unofficial::libstk::libstk) + # Extract details for find_package_handle_standard_args + get_target_property(STK_LIBRARY unofficial::libstk::libstk LOCATION) + get_target_property(STK_INCLUDE_DIR unofficial::libstk::libstk INTERFACE_INCLUDE_DIRECTORIES) +else() + find_path(STK_INCLUDE_DIR + NAMES stk/Stk.h + PATH /usr/include /usr/local/include "${CMAKE_INSTALL_PREFIX}/include" "${CMAKE_FIND_ROOT_PATH}/include" + ) -IF (STK_INCLUDE_DIR AND STK_LIBRARY) - SET(STK_FOUND TRUE) -ENDIF (STK_INCLUDE_DIR AND STK_LIBRARY) + find_library(STK_LIBRARY + NAMES stk + PATH /usr/lib /usr/local/lib "${CMAKE_INSTALL_PREFIX}/lib" "${CMAKE_FIND_ROOT_PATH}/lib" + ) + if(STK_INCLUDE_DIR AND STK_LIBRARY) + # Yes, this target name is hideous, but it matches that provided by vcpkg + add_library(unofficial::libstk::libstk UNKNOWN IMPORTED) + set_target_properties(unofficial::libstk::libstk PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${STK_INCLUDE_DIR}" + IMPORTED_LOCATION "${STK_LIBRARY}" + ) + endif() +endif() -IF (STK_FOUND) - IF (NOT STK_FIND_QUIETLY) - MESSAGE(STATUS "Found STK: ${STK_LIBRARY}") - SET(HAVE_STK TRUE) - ENDIF (NOT STK_FIND_QUIETLY) -ELSE (STK_FOUND) - IF (STK_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could not find STK") - ENDIF (STK_FIND_REQUIRED) -ENDIF (STK_FOUND) - +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(STK + REQUIRED_VARS STK_LIBRARY STK_INCLUDE_DIR +) diff --git a/cmake/modules/ImportedTargetHelpers.cmake b/cmake/modules/ImportedTargetHelpers.cmake new file mode 100644 index 000000000..87b3aeedc --- /dev/null +++ b/cmake/modules/ImportedTargetHelpers.cmake @@ -0,0 +1,57 @@ +# Given a library in vcpkg, find appropriate debug and release versions. If only +# one version exists, it is used as the release version, and the debug version +# is not set. +function(_get_vcpkg_library_configs _release_out _debug_out _library) + # We want to do all operations within the vcpkg directory + file(RELATIVE_PATH _lib_relative "${VCPKG_INSTALLED_DIR}" "${_library}") + + # Return early if we're not using vcpkg + if(IS_ABSOLUTE _lib_relative OR _lib_relative MATCHES "^\\.\\./") + set("${_release_out}" "${_library}" PARENT_SCOPE) + return() + endif() + + string(REPLACE "/" ";" _path_bits "${_lib_relative}") + + # Determine whether we were given the debug or release version + list(FIND _path_bits "debug" _debug_index) + if(_debug_index EQUAL -1) + # We have the release version, so use it + set(_release_lib "${_library}") + + # Try to find a debug version too + list(FIND _path_bits "lib" _lib_index) + if(_lib_index GREATER_EQUAL 0) + list(INSERT _path_bits "${_lib_index}" "debug") + list(INSERT _path_bits 0 "${VCPKG_INSTALLED_DIR}") + string(REPLACE ";" "/" _debug_lib "${_path_bits}") + + if(NOT EXISTS "${_debug_lib}") + # Debug version does not exist - only use given version + unset(_debug_lib) + endif() + endif() + else() + # We have the debug version, so try to find a release version too + list(REMOVE_AT _path_bits "${_debug_index}") + list(INSERT _path_bits 0 "${VCPKG_INSTALLED_DIR}") + string(REPLACE ";" "/" _release_lib "${_path_bits}") + + if(NOT EXISTS "${_release_lib}") + # Release version does not exist - only use given version + set(_release_lib "${_library}") + else() + # Release version exists, so use given version as debug + set(_debug_lib "${_library}") + endif() + endif() + + # Set output variables appropriately + if(_debug_lib) + set("${_release_out}" "${_release_lib}" PARENT_SCOPE) + set("${_debug_out}" "${_debug_lib}" PARENT_SCOPE) + else() + set("${_release_out}" "${_release_lib}" PARENT_SCOPE) + unset("${_debug_out}" PARENT_SCOPE) + endif() +endfunction() diff --git a/cmake/modules/PluginList.cmake b/cmake/modules/PluginList.cmake index 151c5bd66..fe98a64b4 100644 --- a/cmake/modules/PluginList.cmake +++ b/cmake/modules/PluginList.cmake @@ -100,7 +100,6 @@ ENDIF() IF(MSVC) SET(MSVC_INCOMPATIBLE_PLUGINS LadspaEffect - ZynAddSubFx ) message(WARNING "Compiling with MSVC. The following plugins are not available: ${MSVC_INCOMPATIBLE_PLUGINS}") LIST(REMOVE_ITEM PLUGIN_LIST ${MSVC_INCOMPATIBLE_PLUGINS}) diff --git a/cmake/modules/VersionInfo.cmake b/cmake/modules/VersionInfo.cmake index 9571514a6..6f4c371f1 100644 --- a/cmake/modules/VersionInfo.cmake +++ b/cmake/modules/VersionInfo.cmake @@ -3,6 +3,13 @@ IF(GIT_FOUND AND NOT FORCE_VERSION) SET(MAJOR_VERSION 0) SET(MINOR_VERSION 0) SET(PATCH_VERSION 0) + + # If this is a GitHub Actions pull request build, get the pull request + # number from the environment and add it to the build metadata + if("$ENV{GITHUB_REF}" MATCHES "refs/pull/([0-9]+)/merge") + list(APPEND BUILD_METADATA "pr${CMAKE_MATCH_1}") + endif() + # Look for git tag information (e.g. Tagged: "v1.0.0", Untagged: "v1.0.0-123-a1b2c3d") # Untagged format: [latest tag]-[number of commits]-[latest commit hash] EXECUTE_PROCESS( @@ -30,28 +37,43 @@ IF(GIT_FOUND AND NOT FORCE_VERSION) ENDIF() # 1 dash total: Dash in latest tag, no additional commits => pre-release IF(TAG_LIST_LENGTH EQUAL 2) + # Get the pre-release stage LIST(GET TAG_LIST 1 VERSION_STAGE) - SET(FORCE_VERSION "${FORCE_VERSION}-${VERSION_STAGE}") + list(APPEND PRERELEASE_DATA "${VERSION_STAGE}") # 2 dashes: Assume untagged with no dashes in latest tag name => stable + commits ELSEIF(TAG_LIST_LENGTH EQUAL 3) # Get the number of commits and latest commit hash LIST(GET TAG_LIST 1 EXTRA_COMMITS) LIST(GET TAG_LIST 2 COMMIT_HASH) - # Bump the patch version + list(APPEND PRERELEASE_DATA "${EXTRA_COMMITS}") + list(APPEND BUILD_METADATA "${COMMIT_HASH}") + # Bump the patch version, since a pre-release (as specified by the extra + # commits) compares lower than the main version alone MATH(EXPR PATCH_VERSION "${PATCH_VERSION}+1") - # Set the version to MAJOR.MINOR.PATCH-EXTRA_COMMITS+COMMIT_HASH - SET(FORCE_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}") - SET(FORCE_VERSION "${FORCE_VERSION}-${EXTRA_COMMITS}+${COMMIT_HASH}") + # Reassemble the main version using the new patch version + set(FORCE_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}") # 3 dashes: Assume untagged with 1 dash in latest tag name => pre-release + commits ELSEIF(TAG_LIST_LENGTH EQUAL 4) - # Get pre-release stage, number of commits, and latest commit hash + # Get the pre-release stage, number of commits, and latest commit hash LIST(GET TAG_LIST 1 VERSION_STAGE) LIST(GET TAG_LIST 2 EXTRA_COMMITS) LIST(GET TAG_LIST 3 COMMIT_HASH) - # Set the version to MAJOR.MINOR.PATCH-VERSION_STAGE.EXTRA_COMMITS+COMMIT_HASH - SET(FORCE_VERSION "${FORCE_VERSION}-${VERSION_STAGE}") - SET(FORCE_VERSION "${FORCE_VERSION}.${EXTRA_COMMITS}+${COMMIT_HASH}") + list(APPEND PRERELEASE_DATA "${VERSION_STAGE}") + list(APPEND PRERELEASE_DATA "${EXTRA_COMMITS}") + list(APPEND BUILD_METADATA "${COMMIT_HASH}") ENDIF() + + # If there is any pre-release data, append it after a hyphen + if(PRERELEASE_DATA) + string(REPLACE ";" "." PRERELEASE_DATA "${PRERELEASE_DATA}") + set(FORCE_VERSION "${FORCE_VERSION}-${PRERELEASE_DATA}") + endif() + + # If there is any build metadata, append it after a plus + if(BUILD_METADATA) + string(REPLACE ";" "." BUILD_METADATA "${BUILD_METADATA}") + set(FORCE_VERSION "${FORCE_VERSION}+${BUILD_METADATA}") + endif() ENDIF() IF(FORCE_VERSION STREQUAL "internal") diff --git a/data/locale/CMakeLists.txt b/data/locale/CMakeLists.txt index 4ce666dcf..f7f9071e7 100644 --- a/data/locale/CMakeLists.txt +++ b/data/locale/CMakeLists.txt @@ -29,9 +29,14 @@ FOREACH(_ts_file ${lmms_LOCALES}) ADD_CUSTOM_TARGET(${_ts_target} COMMAND "${QT_LUPDATE_EXECUTABLE}" -locations none -no-obsolete -I ${CMAKE_SOURCE_DIR}/include/ ${LMMS_SRCS} ${LMMS_UIS} ${CMAKE_SOURCE_DIR}/plugins -ts "\"${_ts_file}\"" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) - ADD_CUSTOM_TARGET(${_qm_target} + add_custom_command( + OUTPUT "${_qm_file}" COMMAND "${QT_LRELEASE_EXECUTABLE}" "${_ts_file}" -qm "${_qm_file}" - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + MAIN_DEPENDENCY "${_ts_file}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + VERBATIM + ) + add_custom_target("${_qm_target}" DEPENDS "${_qm_file}") LIST(APPEND ts_targets "${_ts_target}") LIST(APPEND qm_targets "${_qm_target}") LIST(APPEND QM_FILES "${_qm_file}") diff --git a/data/locale/ar.ts b/data/locale/ar.ts index 8e989509d..1f159c42a 100644 --- a/data/locale/ar.ts +++ b/data/locale/ar.ts @@ -7156,7 +7156,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/bs.ts b/data/locale/bs.ts index 013585b5f..506b401bd 100644 --- a/data/locale/bs.ts +++ b/data/locale/bs.ts @@ -4416,7 +4416,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/ca.ts b/data/locale/ca.ts index 3512b4871..765cf3b60 100644 --- a/data/locale/ca.ts +++ b/data/locale/ca.ts @@ -7155,7 +7155,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/cs.ts b/data/locale/cs.ts index 7951c75b9..0ed175022 100644 --- a/data/locale/cs.ts +++ b/data/locale/cs.ts @@ -7157,7 +7157,7 @@ Poklepejte pro výběr souboru. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/de.ts b/data/locale/de.ts index ef4d94634..51ca7d562 100644 --- a/data/locale/de.ts +++ b/data/locale/de.ts @@ -7156,7 +7156,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/el.ts b/data/locale/el.ts index b543854d3..320a6657f 100644 --- a/data/locale/el.ts +++ b/data/locale/el.ts @@ -7155,7 +7155,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/en.ts b/data/locale/en.ts index b58d27f30..e52ae39ab 100644 --- a/data/locale/en.ts +++ b/data/locale/en.ts @@ -7157,7 +7157,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/eo.ts b/data/locale/eo.ts index b133d8029..005ee8100 100644 --- a/data/locale/eo.ts +++ b/data/locale/eo.ts @@ -7155,7 +7155,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/es.ts b/data/locale/es.ts index 8fb164421..4fc4951ef 100644 --- a/data/locale/es.ts +++ b/data/locale/es.ts @@ -7156,7 +7156,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/eu.ts b/data/locale/eu.ts index 9642a3ff2..25c165f81 100644 --- a/data/locale/eu.ts +++ b/data/locale/eu.ts @@ -7436,7 +7436,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/fa.ts b/data/locale/fa.ts index 4e72345fd..181ca0ca1 100644 --- a/data/locale/fa.ts +++ b/data/locale/fa.ts @@ -7155,7 +7155,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/fr.ts b/data/locale/fr.ts index 85f443309..2c65444a8 100644 --- a/data/locale/fr.ts +++ b/data/locale/fr.ts @@ -7448,7 +7448,7 @@ Double-cliquez pour choisir un fichier. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/gl.ts b/data/locale/gl.ts index 38a80a5da..cf04fd5d4 100644 --- a/data/locale/gl.ts +++ b/data/locale/gl.ts @@ -7155,7 +7155,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/he.ts b/data/locale/he.ts index 783b473b7..ee5a23613 100644 --- a/data/locale/he.ts +++ b/data/locale/he.ts @@ -7156,7 +7156,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/hi_IN.ts b/data/locale/hi_IN.ts index 5ba65acd6..15550231f 100644 --- a/data/locale/hi_IN.ts +++ b/data/locale/hi_IN.ts @@ -7157,7 +7157,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/hu_HU.ts b/data/locale/hu_HU.ts index f82ff12c4..836059946 100644 --- a/data/locale/hu_HU.ts +++ b/data/locale/hu_HU.ts @@ -7162,7 +7162,7 @@ Kattints duplán egy fájl kiválasztásához. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/id.ts b/data/locale/id.ts index b55f6c98c..e381ea726 100644 --- a/data/locale/id.ts +++ b/data/locale/id.ts @@ -7160,7 +7160,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/it.ts b/data/locale/it.ts index 29865352a..ff146d471 100644 --- a/data/locale/it.ts +++ b/data/locale/it.ts @@ -7169,7 +7169,7 @@ Fai doppio click per scegliere un file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/ja.ts b/data/locale/ja.ts index 28fda3123..e10ca5118 100644 --- a/data/locale/ja.ts +++ b/data/locale/ja.ts @@ -7157,7 +7157,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/ka.ts b/data/locale/ka.ts index b48b3f2b0..1956d8d04 100644 --- a/data/locale/ka.ts +++ b/data/locale/ka.ts @@ -7155,7 +7155,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/ko.ts b/data/locale/ko.ts index 78cfbdd5c..7373b5ca9 100644 --- a/data/locale/ko.ts +++ b/data/locale/ko.ts @@ -7160,7 +7160,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/ms_MY.ts b/data/locale/ms_MY.ts index 533efdcad..209d51d10 100644 --- a/data/locale/ms_MY.ts +++ b/data/locale/ms_MY.ts @@ -7155,7 +7155,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/nb.ts b/data/locale/nb.ts index 41865ef0c..3675b7f58 100644 --- a/data/locale/nb.ts +++ b/data/locale/nb.ts @@ -7155,7 +7155,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/nl.ts b/data/locale/nl.ts index 2eaa6b154..ad630a249 100644 --- a/data/locale/nl.ts +++ b/data/locale/nl.ts @@ -7158,7 +7158,7 @@ Dubbelklikken om een bestand te kiezen. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/oc.ts b/data/locale/oc.ts index 8df1aa1a1..58c81c964 100644 --- a/data/locale/oc.ts +++ b/data/locale/oc.ts @@ -7155,7 +7155,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/pl.ts b/data/locale/pl.ts index 340be33d8..bb0c64ede 100644 --- a/data/locale/pl.ts +++ b/data/locale/pl.ts @@ -7441,7 +7441,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/pt.ts b/data/locale/pt.ts index f94f22920..b375e289f 100644 --- a/data/locale/pt.ts +++ b/data/locale/pt.ts @@ -7158,7 +7158,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/ro.ts b/data/locale/ro.ts index ca148f452..eceb45a64 100644 --- a/data/locale/ro.ts +++ b/data/locale/ro.ts @@ -7156,7 +7156,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/ru.ts b/data/locale/ru.ts index 40e385d2c..8235f291f 100644 --- a/data/locale/ru.ts +++ b/data/locale/ru.ts @@ -7178,7 +7178,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/sl.ts b/data/locale/sl.ts index dd9680976..3ad55a4c0 100644 --- a/data/locale/sl.ts +++ b/data/locale/sl.ts @@ -7155,7 +7155,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/sr.ts b/data/locale/sr.ts index a8c1fd96d..9b90164ab 100644 --- a/data/locale/sr.ts +++ b/data/locale/sr.ts @@ -3550,7 +3550,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/sv.ts b/data/locale/sv.ts index 882524c50..4963b07a9 100644 --- a/data/locale/sv.ts +++ b/data/locale/sv.ts @@ -7447,7 +7447,7 @@ Dubbelklicka för att välja en fil. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/tr.ts b/data/locale/tr.ts index fa4ccb696..387be6d8b 100644 --- a/data/locale/tr.ts +++ b/data/locale/tr.ts @@ -7449,7 +7449,7 @@ Bir dosya seçmek için çift tıklayın. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/uk.ts b/data/locale/uk.ts index 84cc81899..50df10e4b 100644 --- a/data/locale/uk.ts +++ b/data/locale/uk.ts @@ -7156,7 +7156,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/zh_CN.ts b/data/locale/zh_CN.ts index 301d54362..63b22df99 100644 --- a/data/locale/zh_CN.ts +++ b/data/locale/zh_CN.ts @@ -7166,7 +7166,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/locale/zh_TW.ts b/data/locale/zh_TW.ts index a190c831c..791a45599 100644 --- a/data/locale/zh_TW.ts +++ b/data/locale/zh_TW.ts @@ -7156,7 +7156,7 @@ Double click to pick a file. - LmmsCore + Engine Generating wavetables diff --git a/data/themes/classic/style.css b/data/themes/classic/style.css index ea3cbf4a2..58ec5dc09 100644 --- a/data/themes/classic/style.css +++ b/data/themes/classic/style.css @@ -11,12 +11,12 @@ QMdiArea { background-image: url(resources:background_artwork.png); } -Knob { +lmms--gui--Knob { qproperty-lineInactiveColor: rgb(120, 120, 120); qproperty-arcInactiveColor: rgba(120, 120, 120, 70); } -AutomationEditor { +lmms--gui--AutomationEditor { background-color: rgb(0, 0, 0); color: #e0e0e0; qproperty-backgroundShade: rgba(255, 255, 255, 15); @@ -70,7 +70,7 @@ QToolTip { color: #4afd85; } -TextFloat { +lmms--gui--TextFloat { border-radius: 4px; background: qlineargradient(spread:reflect, x1:0.5, y1:0.5, x2:0.5, y2:0, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(50, 50, 50, 220)); opacity: 175; @@ -130,18 +130,18 @@ QMenu::indicator:selected { background-color: #747474; } -FileBrowser QCheckBox +lmms--gui--FileBrowser QCheckBox { font-size: 10px; color: white; } -PositionLine { +lmms--gui--PositionLine { qproperty-tailGradient: false; qproperty-lineColor: rgb(255, 255, 255); } -PianoRoll { +lmms--gui--PianoRoll { background-color: rgb(0, 0, 0); qproperty-backgroundShade: rgba( 255, 255, 255, 10 ); qproperty-noteModeColor: rgb( 255, 255, 255 ); @@ -182,7 +182,7 @@ PianoRoll { qproperty-textShadow: rgb( 240, 240, 240 ); } -TabWidget { +lmms--gui--TabWidget { background-color: #5b6571; qproperty-tabText: rgba(255, 255, 255, 180); qproperty-tabTitleText: #fff; @@ -191,13 +191,13 @@ TabWidget { qproperty-tabBorder: #3c434b; } -GroupBox { +lmms--gui--GroupBox { background-color: #5b6571; } /* main toolbar oscilloscope - can have transparent bg now */ -Oscilloscope { +lmms--gui--Oscilloscope { background: none; border: none; qproperty-normalColor: rgb(71, 253, 133); @@ -206,7 +206,7 @@ Oscilloscope { /* main toolbar cpu load widget - this can have transparent bg now */ -CPULoadWidget { +lmms--gui--CPULoadWidget { border: none; background: url(resources:cpuload_bg.png); } @@ -335,19 +335,19 @@ QScrollBar::down-arrow:vertical:disabled { background-image: url(resources:sbarr /* background for song editor and pattern editor */ -TrackContainerView QFrame{ +lmms--gui--TrackContainerView QFrame{ background-color: #49515b; } /* background for track controls */ -TrackView > QWidget { +lmms--gui--TrackView > QWidget { background-color: #5b6571; } /* autoscroll, loop, stop behaviour toggle buttons */ /* track background colors */ -TrackContentWidget { +lmms--gui--TrackContentWidget { qproperty-darkerColor: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb( 50, 50, 50 ), stop:0.33 rgb( 20, 20, 20 ), stop:1 rgb( 15, 15, 15 ) ); qproperty-lighterColor: qlineargradient(x1:0, y1:0, x2:0, y2:1, @@ -359,7 +359,7 @@ TrackContentWidget { /* gear button in tracks */ -TrackOperationsWidget > QPushButton { +lmms--gui--TrackOperationsWidget > QPushButton { max-height: 26px; max-width: 26px; min-height: 26px; @@ -368,7 +368,7 @@ TrackOperationsWidget > QPushButton { border: none; } -TrackOperationsWidget > QPushButton::menu-indicator { +lmms--gui--TrackOperationsWidget > QPushButton::menu-indicator { image: url(resources:trackop.png); subcontrol-origin: padding; subcontrol-position: center; @@ -376,12 +376,12 @@ TrackOperationsWidget > QPushButton::menu-indicator { top: 1px; } -TrackOperationsWidget > QPushButton::menu-indicator:hover { +lmms--gui--TrackOperationsWidget > QPushButton::menu-indicator:hover { image: url(resources:trackop_h.png); } -TrackOperationsWidget > QPushButton::menu-indicator:pressed, -TrackOperationsWidget > QPushButton::menu-indicator:checked { +lmms--gui--TrackOperationsWidget > QPushButton::menu-indicator:pressed, +lmms--gui--TrackOperationsWidget > QPushButton::menu-indicator:checked { image: url(resources:trackop_c.png); position: relative; top: 2px; @@ -395,13 +395,13 @@ TrackOperationsWidget > QPushButton::menu-indicator:checked { /* font sizes */ -Sf2InstrumentView > QLabel { +lmms--gui--Sf2InstrumentView > QLabel { font-size:10px; } /* main toolbar sliders (master vol, master pitch) */ -AutomatableSlider::groove:vertical { +lmms--gui--AutomatableSlider::groove:vertical { background: rgba(0,0,0, 128); border: 1px inset rgba(100,100,100, 64); border-radius: 2px; @@ -409,7 +409,7 @@ AutomatableSlider::groove:vertical { margin: 2px 2px; } -AutomatableSlider::handle:vertical { +lmms--gui--AutomatableSlider::handle:vertical { background: none; border-image: url(resources:main_slider.png); width: 26px; @@ -425,13 +425,13 @@ QTabWidget, QTabWidget QWidget { /* window that shows up when you add effects */ -EffectSelectDialog QScrollArea { +lmms--gui--EffectSelectDialog QScrollArea { background: #5b6571; } /* the inner boxes in LADSPA effect windows */ -EffectControlDialog QGroupBox { +lmms--gui--EffectControlDialog QGroupBox { background: #49515b; margin-top: 1ex; padding: 10px 2px 1px; @@ -441,7 +441,7 @@ EffectControlDialog QGroupBox { /* the inner box titles when present (channel 1, channel 2...) */ -EffectControlDialog QGroupBox::title { +lmms--gui--EffectControlDialog QGroupBox::title { subcontrol-origin: margin; subcontrol-position: top left; background: #7b838d; @@ -531,7 +531,7 @@ QToolButton::menu-button { /* track label buttons - the part that contains the icon and track title */ -TrackLabelButton { +lmms--gui--TrackLabelButton { background-color: #5b6571; color: #c9c9c9; font-size: 11px; @@ -541,7 +541,7 @@ TrackLabelButton { padding: 2px 1px; } -TrackLabelButton:hover { +lmms--gui--TrackLabelButton:hover { background-color: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:0.5, stop:0 #5b6571, stop:0.75 #7b838d, stop:1 #7b838d ); color: white; border: 1px solid rgba(0,0,0,64); @@ -549,7 +549,7 @@ TrackLabelButton:hover { margin: 0px; } -TrackLabelButton:pressed { +lmms--gui--TrackLabelButton:pressed { background: qlineargradient(spread:reflect, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 #49515b, stop:0.3 #5b6571, stop:1 #6b7581 ); color: white; border: 1px solid rgba(0,0,0,64); @@ -557,7 +557,7 @@ TrackLabelButton:pressed { font-weight: bold; } -TrackLabelButton:checked { +lmms--gui--TrackLabelButton:checked { background: qlineargradient(spread:reflect, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 #49515b, stop:0.3 #5b6571, stop:1 #6b7581 ); color: white; border: 1px solid rgba(0,0,0,128); @@ -565,50 +565,52 @@ TrackLabelButton:checked { font-weight: bold; } -TrackLabelButton:checked:hover { +lmms--gui--TrackLabelButton:checked:hover { background-color: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:0.5, stop:0 #5b6571, stop:0.75 #7b838d, stop:1 #7b838d ); } -TrackLabelButton:checked:pressed { +lmms--gui--TrackLabelButton:checked:pressed { background: qlineargradient(spread:reflect, x1:0.5, y1:0, x2:0.5, y2:1, stop:0 #49515b, stop:0.3 #5b6571, stop:1 #6b7581 ); } /* sidebar, sidebar buttons */ -SideBar { +lmms--gui--SideBar { background: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop: 0 #98a2a7, stop: 1.0 #5b646f); } -SideBar QToolButton { +lmms--gui--SideBar QToolButton { font-size: 12px; } /* Instrument plugin list */ -PluginDescWidget { +lmms--gui--PluginDescWidget { background-color: #e0e0e0; color: #404040; border: 1px solid rgb(64, 64, 64); margin: 0px; } -PluginDescWidget:hover { +lmms--gui--PluginDescWidget:hover { background-color: #e0e0e0; } /* piano widget */ -PianoView { +lmms--gui--PianoView { background-color: #14171a; } /* font sizes for text buttons */ -MixerView QPushButton, EffectRackView QPushButton, ControllerRackView QPushButton { +lmms--gui--MixerView QPushButton, +lmms--gui--EffectRackView QPushButton, +lmms--gui--ControllerRackView QPushButton { font-size: 10px; } -MixerLine { +lmms--gui--MixerLine { background: #5b6571; color: #e0e0e0; qproperty-backgroundActive: qlineargradient(spread:reflect, x1:0, y1:0, x2:1, y2:0, @@ -620,13 +622,13 @@ MixerLine { } /* persistent peak markers for fx peak meters */ -Fader { +lmms--gui--Fader { qproperty-peakGreen: rgb( 74, 253, 133); qproperty-peakYellow: rgb(224, 222, 18); qproperty-peakRed: rgb( 255, 100, 100); } -TimeLineWidget { +lmms--gui--TimeLineWidget { /* font-size only supports px and pt. */ font-size: 7pt; /* lengths also support em. This will make sure that the height @@ -654,7 +656,7 @@ QTreeView { alternate-background-color: #747474; } -TrackContainerView QLabel +lmms--gui--TrackContainerView QLabel { background: none; } @@ -662,7 +664,7 @@ TrackContainerView QLabel /* Clips */ /* common clip colors */ -ClipView { +lmms--gui--ClipView { qproperty-mutedColor: rgb( 128, 128, 128 ); qproperty-mutedBackgroundColor: rgb( 80, 80, 80 ); qproperty-selectedColor: rgb( 0, 125, 255 ); @@ -679,7 +681,7 @@ ClipView { } /* MIDI (instrument) clip */ -MidiClipView { +lmms--gui--MidiClipView { background-color: rgb( 119, 199, 216 ); color: rgb( 187, 227, 236 ); @@ -690,24 +692,24 @@ MidiClipView { } /* sample track clip */ -SampleClipView { +lmms--gui--SampleClipView { background-color: rgba(42,51,59,255); color: #FF8F05; } /* automation clip */ -AutomationClipView { +lmms--gui--AutomationClipView { background-color: #99afff; color: rgb( 204, 215, 255 ); } /* pattern clip */ -PatternClipView { +lmms--gui--PatternClipView { background-color: rgb( 128, 182, 175 ); /* default colour for pattern tracks */ } /* Subwindows in MDI-Area */ -SubWindow { +lmms--gui--SubWindow { color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #4b525c, stop: 1.0 #31363d); qproperty-activeColor: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, @@ -717,21 +719,21 @@ SubWindow { } /* Subwindow title text */ -SubWindow > QLabel { +lmms--gui--SubWindow > QLabel { color: rgb( 255, 255, 255 ); font-size: 12px; font-style: normal; } /* SubWindow titlebar button */ -SubWindow > QPushButton { +lmms--gui--SubWindow > QPushButton { background-color: rgba( 255, 255, 255, 0% ); border-width: 0px; border-color: none; border-style: none; } -SubWindow > QPushButton:hover{ +lmms--gui--SubWindow > QPushButton:hover{ background-color: rgba( 255, 255, 255, 15% ); border-width: 1px; border-color: rgba( 0, 0, 0, 20% ); @@ -742,7 +744,7 @@ SubWindow > QPushButton:hover{ /* Plugins */ -TripleOscillatorView Knob { +lmms--gui--TripleOscillatorView lmms--gui--Knob { color: rgb(255, 255, 255); qproperty-outerColor: rgb(255, 255, 255); qproperty-innerRadius: 2; @@ -753,7 +755,7 @@ TripleOscillatorView Knob { } -KickerInstrumentView Knob#smallKnob { +lmms--gui--KickerInstrumentView lmms--gui--Knob#smallKnob { color: #595959; qproperty-outerColor: black; qproperty-innerRadius: 3; @@ -764,7 +766,7 @@ KickerInstrumentView Knob#smallKnob { } -KickerInstrumentView Knob#largeKnob { +lmms--gui--KickerInstrumentView lmms--gui--Knob#largeKnob { color: #0c3b89; qproperty-outerColor: #519fff; qproperty-innerRadius: 12.0; @@ -775,7 +777,7 @@ KickerInstrumentView Knob#largeKnob { } -AudioFileProcessorView Knob { +lmms--gui--AudioFileProcessorView lmms--gui--Knob { color: rgb(240, 147, 14); qproperty-outerColor: rgb(30, 35, 37); qproperty-innerRadius: 4; @@ -785,7 +787,7 @@ AudioFileProcessorView Knob { qproperty-lineWidth: 3; } -OrganicInstrumentView Knob { +lmms--gui--OrganicInstrumentView lmms--gui--Knob { color: rgb(124, 207, 98); qproperty-outerColor: rgb(13, 42, 4); qproperty-innerRadius: 2; @@ -795,13 +797,13 @@ OrganicInstrumentView Knob { qproperty-lineWidth: 1.5; } -OrganicInstrumentView Knob#harmKnob { +lmms--gui--OrganicInstrumentView lmms--gui--Knob#harmKnob { color: rgb(205, 98, 216); qproperty-outerColor: rgb(18, 4, 18); } -OrganicInstrumentView Knob#fx1Knob, -OrganicInstrumentView Knob#volKnob { +lmms--gui--OrganicInstrumentView lmms--gui--Knob#fx1Knob, +lmms--gui--OrganicInstrumentView lmms--gui--Knob#volKnob { color: rgb(157, 157, 157); qproperty-outerColor: rgb(37, 37, 37); qproperty-innerRadius: 4; @@ -811,7 +813,7 @@ OrganicInstrumentView Knob#volKnob { qproperty-lineWidth: 2; } -Sf2InstrumentView Knob { +lmms--gui--Sf2InstrumentView lmms--gui--Knob { color: #ff00ea; qproperty-outerColor: rgb(20, 5, 18); qproperty-innerRadius: 2; @@ -821,7 +823,7 @@ Sf2InstrumentView Knob { qproperty-lineWidth: 2; } -SfxrInstrumentView Knob { +lmms--gui--SfxrInstrumentView lmms--gui--Knob { color: #000; qproperty-outerColor: rgb(194, 177, 145); qproperty-innerRadius: 2; @@ -829,42 +831,42 @@ SfxrInstrumentView Knob { qproperty-lineWidth: 2; } -SfxrInstrumentView Knob#envKnob { +lmms--gui--SfxrInstrumentView lmms--gui--Knob#envKnob { color: #263352; qproperty-outerColor: #4b66a4; } -SfxrInstrumentView Knob#freqKnob { +lmms--gui--SfxrInstrumentView lmms--gui--Knob#freqKnob { color: #1e4a22; qproperty-outerColor: #3c9544; } -SfxrInstrumentView Knob#changeKnob { +lmms--gui--SfxrInstrumentView lmms--gui--Knob#changeKnob { color: #591c1c; qproperty-outerColor: #b23737; } -SfxrInstrumentView Knob#sqrKnob { +lmms--gui--SfxrInstrumentView lmms--gui--Knob#sqrKnob { color: #3b2714; qproperty-outerColor: #724c27; } -SfxrInstrumentView Knob#repeatKnob { +lmms--gui--SfxrInstrumentView lmms--gui--Knob#repeatKnob { color: #292929; qproperty-outerColor: #515151; } -SfxrInstrumentView Knob#phaserKnob { +lmms--gui--SfxrInstrumentView lmms--gui--Knob#phaserKnob { color: #144c4d; qproperty-outerColor: #299899; } -SfxrInstrumentView Knob#filterKnob { +lmms--gui--SfxrInstrumentView lmms--gui--Knob#filterKnob { color: #47224c; qproperty-outerColor: #8e4397; } -OpulenzInstrumentView Knob { +lmms--gui--OpulenzInstrumentView lmms--gui--Knob { color: rgb(128,128,128); qproperty-outerColor: rgb(255,255,255); qproperty-innerRadius: 2; @@ -872,7 +874,7 @@ OpulenzInstrumentView Knob { qproperty-lineWidth: 2; } -SidInstrumentView Knob { +lmms--gui--SidInstrumentView lmms--gui--Knob { color: rgb(113,95,80); qproperty-outerColor: rgb( 255,255,255 ); qproperty-innerRadius: 2; @@ -880,7 +882,7 @@ SidInstrumentView Knob { qproperty-lineWidth: 2; } -WatsynView Knob { +lmms--gui--WatsynView lmms--gui--Knob { qproperty-innerRadius: 1; qproperty-outerRadius: 7; qproperty-centerPointX: 9.5; @@ -888,17 +890,17 @@ WatsynView Knob { qproperty-lineWidth: 2; } -WatsynView Knob#aKnob { +lmms--gui--WatsynView lmms--gui--Knob#aKnob { color: #43b2ff; qproperty-outerColor: #43b2ff; } -WatsynView Knob#bKnob { +lmms--gui--WatsynView lmms--gui--Knob#bKnob { color: #fc5431; qproperty-outerColor: #fc5431; } -WatsynView Knob#mixKnob { +lmms--gui--WatsynView lmms--gui--Knob#mixKnob { color: #43ff82; qproperty-outerColor: #43ff82; qproperty-outerRadius: 13; @@ -906,17 +908,17 @@ WatsynView Knob#mixKnob { qproperty-centerPointY: 15.5; } -WatsynView Knob#mixenvKnob { +lmms--gui--WatsynView lmms--gui--Knob#mixenvKnob { color: #43ff82; qproperty-outerColor: #43ff82; } -WatsynView Knob#xtalkKnob { +lmms--gui--WatsynView lmms--gui--Knob#xtalkKnob { color: #fb50fb; qproperty-outerColor: #fb50fb; } -MonstroView Knob { +lmms--gui--MonstroView lmms--gui--Knob { color: #ffffff; qproperty-outerColor: #aaaaaa; qproperty-outerRadius: 9; @@ -926,7 +928,7 @@ MonstroView Knob { qproperty-lineWidth: 2.5; } -NesInstrumentView Knob { +lmms--gui--NesInstrumentView lmms--gui--Knob { color: #e7231b; qproperty-outerColor: #fff; qproperty-outerRadius: 11.0; @@ -936,7 +938,7 @@ NesInstrumentView Knob { qproperty-lineWidth: 2; } -CompressorControlDialog { +lmms--gui--CompressorControlDialog { qproperty-inVolAreaColor: rgba(209, 216, 228, 17); qproperty-inVolColor: rgba(209, 216, 228, 100); qproperty-outVolAreaColor: rgba(209, 216, 228, 30); @@ -950,7 +952,7 @@ CompressorControlDialog { qproperty-resetColor: rgba(200, 100, 15, 200); } -CompressorControlDialog Knob { +lmms--gui--CompressorControlDialog lmms--gui--Knob { color: #2fcc71; qproperty-outerColor: #2fcc71; qproperty-lineWidth: 2; @@ -958,7 +960,7 @@ CompressorControlDialog Knob { /* palette information */ -LmmsPalette { +lmms--gui--LmmsPalette { qproperty-background: #5b6571; qproperty-windowText: #f0f0f0; qproperty-base: #808080; diff --git a/data/themes/default/style.css b/data/themes/default/style.css index b10e493e7..f4c651c9e 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -40,18 +40,18 @@ QMdiArea { background-color: #111314; } -FileBrowser QCheckBox +lmms--gui--FileBrowser QCheckBox { font-size: 10px; color: white; } -Knob { +lmms--gui--Knob { qproperty-lineInactiveColor: rgb(120, 120, 120); qproperty-arcInactiveColor: rgba(120, 120, 120, 70); } -AutomationEditor { +lmms--gui--AutomationEditor { color: #ffffff; background-color: #141616; qproperty-backgroundShade: rgba(255, 255, 255, 15); @@ -100,7 +100,7 @@ QToolTip { color: #d1d8e4; } -TextFloat { +lmms--gui--TextFloat { background: #040506; color: #d1d8e4; } @@ -168,12 +168,12 @@ QMenu::indicator:selected { background-color: #101213; } -PositionLine { +lmms--gui--PositionLine { qproperty-tailGradient: true; qproperty-lineColor: rgb(255, 255, 255); } -PianoRoll { +lmms--gui--PianoRoll { background-color: #141616; qproperty-backgroundShade: rgba(255, 255, 255, 10); qproperty-noteModeColor: #0bd556; @@ -214,7 +214,7 @@ PianoRoll { qproperty-textShadow: #fff; } -TabWidget { +lmms--gui--TabWidget { background-color: #262b30; qproperty-tabText: rgba(255, 255, 255, 180); qproperty-tabTitleText: #fff; @@ -223,13 +223,13 @@ TabWidget { qproperty-tabBorder: #181b1f; } -GroupBox { +lmms--gui--GroupBox { background-color: #262b30; } /* main toolbar oscilloscope - can have transparent bg now */ -Oscilloscope { +lmms--gui--Oscilloscope { background: none; border: none; qproperty-normalColor: rgb(71, 253, 133); @@ -238,7 +238,7 @@ Oscilloscope { /* main toolbar cpu load widget - this can have transparent bg now */ -CPULoadWidget { +lmms--gui--CPULoadWidget { border: none; background: url(resources:cpuload_bg.png); } @@ -308,7 +308,7 @@ QScrollBar::handle:horizontal:disabled, QScrollBar::handle:vertical:disabled { border: none; } -EffectRackView QScrollBar::handle:vertical:disabled { +lmms--gui--EffectRackView QScrollBar::handle:vertical:disabled { background: #3f4750; border: none; border-radius: 4px; @@ -366,17 +366,17 @@ QScrollBar::left-arrow:horizontal:disabled { background-image: url(resources:sba QScrollBar::right-arrow:horizontal:disabled { background-image: url(resources:sbarrow_right_d.png);} QScrollBar::up-arrow:vertical:disabled { background-image: url(resources:sbarrow_up_d.png);} QScrollBar::down-arrow:vertical:disabled { background-image: url(resources:sbarrow_down_d.png);} -EffectRackView QScrollBar::up-arrow:vertical:disabled { background-image: url(resources:sbarrow_up.png);} -EffectRackView QScrollBar::down-arrow:vertical:disabled { background-image: url(resources:sbarrow_down.png);} +lmms--gui--EffectRackView QScrollBar::up-arrow:vertical:disabled { background-image: url(resources:sbarrow_up.png);} +lmms--gui--EffectRackView QScrollBar::down-arrow:vertical:disabled { background-image: url(resources:sbarrow_down.png);} /* background for song editor and pattern editor */ -TrackContainerView QFrame { +lmms--gui--TrackContainerView QFrame { background-color: #262b30; } /* background for track controls */ -TrackView > QWidget { +lmms--gui--TrackView > QWidget { background-color: #3B424A; } @@ -384,7 +384,7 @@ TrackView > QWidget { /* autoscroll, loop, stop behaviour toggle buttons */ /* track background colors */ -TrackContentWidget { +lmms--gui--TrackContentWidget { qproperty-darkerColor: #0C0E0F; qproperty-lighterColor: #14151A; qproperty-gridColor: #262B30; @@ -394,7 +394,7 @@ TrackContentWidget { /* gear button in tracks */ -TrackOperationsWidget > QPushButton { +lmms--gui--TrackOperationsWidget > QPushButton { max-height: 26px; max-width: 26px; min-height: 26px; @@ -403,7 +403,7 @@ TrackOperationsWidget > QPushButton { border: none; } -TrackOperationsWidget > QPushButton::menu-indicator { +lmms--gui--TrackOperationsWidget > QPushButton::menu-indicator { image: url(resources:trackop.png); subcontrol-origin: padding; subcontrol-position: center; @@ -411,8 +411,8 @@ TrackOperationsWidget > QPushButton::menu-indicator { top: 1px; } -TrackOperationsWidget > QPushButton::menu-indicator:pressed, -TrackOperationsWidget > QPushButton::menu-indicator:checked { +lmms--gui--TrackOperationsWidget > QPushButton::menu-indicator:pressed, +lmms--gui--TrackOperationsWidget > QPushButton::menu-indicator:checked { image: url(resources:trackop.png); position: relative; top: 2px; @@ -420,13 +420,13 @@ TrackOperationsWidget > QPushButton::menu-indicator:checked { /* font sizes */ -Sf2InstrumentView > QLabel { +lmms--gui--Sf2InstrumentView > QLabel { font-size:10px; } /* main toolbar sliders (master vol, master pitch) */ -AutomatableSlider::groove:vertical { +lmms--gui--AutomatableSlider::groove:vertical { background: #040506; border: none; border-radius: 2px; @@ -434,7 +434,7 @@ AutomatableSlider::groove:vertical { margin: 2px 2px; } -AutomatableSlider::handle:vertical { +lmms--gui--AutomatableSlider::handle:vertical { background: none; border-image: url(resources:main_slider.png); width: 26px; @@ -445,13 +445,13 @@ AutomatableSlider::handle:vertical { /* window that shows up when you add effects */ -EffectSelectDialog QScrollArea { +lmms--gui--EffectSelectDialog QScrollArea { background: #262b30; } /* the inner boxes in LADSPA effect windows */ -EffectControlDialog QGroupBox { +lmms--gui--EffectControlDialog QGroupBox { background: #262b30; margin-top: 1ex; padding: 10px 2px 1px; @@ -461,7 +461,7 @@ EffectControlDialog QGroupBox { /* the inner box titles when present (channel 1, channel 2...) */ -EffectControlDialog QGroupBox::title { +lmms--gui--EffectControlDialog QGroupBox::title { subcontrol-origin: margin; subcontrol-position: top center; background: #262b30; @@ -543,7 +543,7 @@ QToolButton::menu-button { /* track label buttons - the part that contains the icon and track title */ -TrackLabelButton { +lmms--gui--TrackLabelButton { background-color: #3B424A; border: 1px solid #3B424A; font-size: 11px; @@ -551,7 +551,7 @@ TrackLabelButton { padding: 2px 1px; } -TrackLabelButton:hover { +lmms--gui--TrackLabelButton:hover { background: #3B424A; border: 1px solid #515B66; border-radius: none; @@ -560,7 +560,7 @@ TrackLabelButton:hover { padding: 2px 1px; } -TrackLabelButton:pressed { +lmms--gui--TrackLabelButton:pressed { background: #262B30; border-radius: none; font-size: 11px; @@ -568,7 +568,7 @@ TrackLabelButton:pressed { padding: 2px 1px; } -TrackLabelButton:checked { +lmms--gui--TrackLabelButton:checked { border: 1px solid #485059; background: #1C1F24; background-image: url(resources:track_shadow_p.png); @@ -578,7 +578,7 @@ TrackLabelButton:checked { padding: 2px 1px; } -TrackLabelButton:checked:pressed { +lmms--gui--TrackLabelButton:checked:pressed { border: 1px solid #2f353b; background: #0e1012; background-image: url(resources:track_shadow_p.png); @@ -589,30 +589,30 @@ TrackLabelButton:checked:pressed { /* sidebar, sidebar buttons */ -SideBar { +lmms--gui--SideBar { subcontrol-position: center; background: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:1, stop:0 #1D2122, stop:1 #262B30); } -SideBar QToolButton { +lmms--gui--SideBar QToolButton { background: none; border: none; font-size: 12px; } -SideBar QToolButton:hover { +lmms--gui--SideBar QToolButton:hover { background: none; border: none; font-size: 12px; } -SideBar QToolButton:pressed { +lmms--gui--SideBar QToolButton:pressed { background: none; border: none; font-size: 12px; } -SideBar QToolButton:checked { +lmms--gui--SideBar QToolButton:checked { background: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:1, stop:0 #4b525b, stop:1 #2f333a); border: none; font-size: 12px; @@ -620,7 +620,7 @@ SideBar QToolButton:checked { /* Instrument plugin list */ -PluginDescWidget { +lmms--gui--PluginDescWidget { border-top: 1px solid #3E474F; border-bottom: 1px solid #101314; border-radius: 2px; @@ -630,24 +630,26 @@ PluginDescWidget { margin: 0px; } -PluginDescWidget:hover { +lmms--gui--PluginDescWidget:hover { background: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:1, stop:0 #7C8799, stop:1 #343840); color: #d1d8e4; } /* piano widget */ -PianoView { +lmms--gui--PianoView { background-color: #14171a; } /* font sizes for text buttons */ -MixerView QPushButton, EffectRackView QPushButton, ControllerRackView QPushButton { +lmms--gui--MixerView QPushButton, +lmms--gui--EffectRackView QPushButton, +lmms--gui--ControllerRackView QPushButton { font-size: 10px; } -MixerLine { +lmms--gui--MixerLine { background: #14161A; color: #d1d8e4; qproperty-backgroundActive: #3B424A; @@ -658,13 +660,13 @@ MixerLine { } /* persistent peak markers for fx peak meters */ -Fader { +lmms--gui--Fader { qproperty-peakGreen: #0ad45c; qproperty-peakYellow: #d6ec52; qproperty-peakRed: #c12038; } -TimeLineWidget { +lmms--gui--TimeLineWidget { /* font-size only supports px and pt. */ font-size: 7pt; /* lengths also support em. This will make sure that the height @@ -700,7 +702,7 @@ QTreeView { alternate-background-color: #111314; } -TrackContainerView QLabel +lmms--gui--TrackContainerView QLabel { background: none; } @@ -708,7 +710,7 @@ TrackContainerView QLabel /* Clips */ /* common clip colors */ -ClipView { +lmms--gui--ClipView { qproperty-mutedColor: rgba(255,255,255,100); qproperty-mutedBackgroundColor: #373d48; qproperty-selectedColor: #006B65; @@ -725,7 +727,7 @@ ClipView { } /* MIDI (instrument) clip */ -MidiClipView { +lmms--gui--MidiClipView { background-color: #21A14F; color: rgba(255,255,255,220); @@ -736,24 +738,24 @@ MidiClipView { } /* sample track clip */ -SampleClipView { +lmms--gui--SampleClipView { background-color: rgba(42,51,59,255); color: #FF8F05; } /* automation clip */ -AutomationClipView { +lmms--gui--AutomationClipView { background-color: #663DE1; color: rgba(255,255,255,90); } /* pattern clip */ -PatternClipView { +lmms--gui--PatternClipView { background-color: #20BDB2; /* default colour for pattern tracks */ } /* Subwindows in MDI-Area */ -SubWindow { +lmms--gui--SubWindow { color: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:1, stop:0 #090909, stop:0.05 #3D454F, stop:1 #262B30); qproperty-activeColor: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:1 stop:0 #090909, stop:0.05 #636c7a, stop:1 #343840); qproperty-textShadowColor: #000; @@ -761,21 +763,21 @@ SubWindow { } /* Subwindow title text */ -SubWindow > QLabel { +lmms--gui--SubWindow > QLabel { color: #d1d8e4; font-size: 12px; font-style: normal; } /* SubWindow titlebar button */ -SubWindow > QPushButton { +lmms--gui--SubWindow > QPushButton { background-color: rgba( 255, 255, 255, 0% ); border-width: 0px; border-color: none; border-style: none; } -SubWindow > QPushButton:hover{ +lmms--gui--SubWindow > QPushButton:hover{ background-color: rgba( 255, 255, 255, 15% ); border-width: 1px; border-color: rgba( 0, 0, 0, 20% ); @@ -786,7 +788,7 @@ SubWindow > QPushButton:hover{ /* Plugins */ -TripleOscillatorView Knob { +lmms--gui--TripleOscillatorView lmms--gui--Knob { color: rgb(255,255,255); qproperty-outerColor: rgb(255,255,255); qproperty-innerRadius: 2; @@ -797,7 +799,7 @@ TripleOscillatorView Knob { } -KickerInstrumentView Knob#smallKnob { +lmms--gui--KickerInstrumentView lmms--gui--Knob#smallKnob { color: #595959; qproperty-outerColor: black; qproperty-innerRadius: 3; @@ -808,7 +810,7 @@ KickerInstrumentView Knob#smallKnob { } -KickerInstrumentView Knob#largeKnob { +lmms--gui--KickerInstrumentView lmms--gui--Knob#largeKnob { color: #0c3b89; qproperty-outerColor: #519fff; qproperty-innerRadius: 12.0; @@ -819,7 +821,7 @@ KickerInstrumentView Knob#largeKnob { } -AudioFileProcessorView Knob { +lmms--gui--AudioFileProcessorView lmms--gui--Knob { color: rgb(240, 147, 14); qproperty-outerColor: rgb(30, 35, 37); qproperty-innerRadius: 4; @@ -829,7 +831,7 @@ AudioFileProcessorView Knob { qproperty-lineWidth: 3; } -OrganicInstrumentView Knob { +lmms--gui--OrganicInstrumentView lmms--gui--Knob { color: rgb(124, 207, 98); qproperty-outerColor: rgb(13, 42, 4); qproperty-innerRadius: 2; @@ -839,13 +841,13 @@ OrganicInstrumentView Knob { qproperty-lineWidth: 1.5; } -OrganicInstrumentView Knob#harmKnob { +lmms--gui--OrganicInstrumentView lmms--gui--Knob#harmKnob { color: rgb(205, 98, 216); qproperty-outerColor: rgb(18, 4, 18); } -OrganicInstrumentView Knob#fx1Knob, -OrganicInstrumentView Knob#volKnob { +lmms--gui--OrganicInstrumentView lmms--gui--Knob#fx1Knob, +lmms--gui--OrganicInstrumentView lmms--gui--Knob#volKnob { color: rgb(157, 157, 157); qproperty-outerColor: rgb(37, 37, 37); qproperty-innerRadius: 4; @@ -855,7 +857,7 @@ OrganicInstrumentView Knob#volKnob { qproperty-lineWidth: 2; } -Sf2InstrumentView Knob { +lmms--gui--Sf2InstrumentView lmms--gui--Knob { color: #ff00ea; qproperty-outerColor: rgb(20, 5, 18); qproperty-innerRadius: 2; @@ -865,7 +867,7 @@ Sf2InstrumentView Knob { qproperty-lineWidth: 2; } -SfxrInstrumentView Knob { +lmms--gui--SfxrInstrumentView lmms--gui--Knob { color: #000; qproperty-outerColor: rgb(194, 177, 145); qproperty-innerRadius: 2; @@ -873,42 +875,42 @@ SfxrInstrumentView Knob { qproperty-lineWidth: 2; } -SfxrInstrumentView Knob#envKnob { +lmms--gui--SfxrInstrumentView lmms--gui--Knob#envKnob { color: #263352; qproperty-outerColor: #4b66a4; } -SfxrInstrumentView Knob#freqKnob { +lmms--gui--SfxrInstrumentView lmms--gui--Knob#freqKnob { color: #1e4a22; qproperty-outerColor: #3c9544; } -SfxrInstrumentView Knob#changeKnob { +lmms--gui--SfxrInstrumentView lmms--gui--Knob#changeKnob { color: #591c1c; qproperty-outerColor: #b23737; } -SfxrInstrumentView Knob#sqrKnob { +lmms--gui--SfxrInstrumentView lmms--gui--Knob#sqrKnob { color: #3b2714; qproperty-outerColor: #724c27; } -SfxrInstrumentView Knob#repeatKnob { +lmms--gui--SfxrInstrumentView lmms--gui--Knob#repeatKnob { color: #292929; qproperty-outerColor: #515151; } -SfxrInstrumentView Knob#phaserKnob { +lmms--gui--SfxrInstrumentView lmms--gui--Knob#phaserKnob { color: #144c4d; qproperty-outerColor: #299899; } -SfxrInstrumentView Knob#filterKnob { +lmms--gui--SfxrInstrumentView lmms--gui--Knob#filterKnob { color: #47224c; qproperty-outerColor: #8e4397; } -OpulenzInstrumentView Knob { +lmms--gui--OpulenzInstrumentView lmms--gui--Knob { color: rgb(128,128,128); qproperty-outerColor: rgb(255,255,255); qproperty-innerRadius: 2; @@ -916,7 +918,7 @@ OpulenzInstrumentView Knob { qproperty-lineWidth: 2; } -SidInstrumentView Knob { +lmms--gui--SidInstrumentView lmms--gui--Knob { color: rgb(113,95,80); qproperty-outerColor: rgb( 255,255,255 ); qproperty-innerRadius: 2; @@ -924,7 +926,7 @@ SidInstrumentView Knob { qproperty-lineWidth: 2; } -WatsynView Knob { +lmms--gui--WatsynView lmms--gui--Knob { qproperty-innerRadius: 1; qproperty-outerRadius: 7; qproperty-centerPointX: 9.5; @@ -932,17 +934,17 @@ WatsynView Knob { qproperty-lineWidth: 2; } -WatsynView Knob#aKnob { +lmms--gui--WatsynView lmms--gui--Knob#aKnob { color: #43b2ff; qproperty-outerColor: #43b2ff; } -WatsynView Knob#bKnob { +lmms--gui--WatsynView lmms--gui--Knob#bKnob { color: #fc5431; qproperty-outerColor: #fc5431; } -WatsynView Knob#mixKnob { +lmms--gui--WatsynView lmms--gui--Knob#mixKnob { color: #43ff82; qproperty-outerColor: #43ff82; qproperty-outerRadius: 13; @@ -950,17 +952,17 @@ WatsynView Knob#mixKnob { qproperty-centerPointY: 15.5; } -WatsynView Knob#mixenvKnob { +lmms--gui--WatsynView lmms--gui--Knob#mixenvKnob { color: #43ff82; qproperty-outerColor: #43ff82; } -WatsynView Knob#xtalkKnob { +lmms--gui--WatsynView lmms--gui--Knob#xtalkKnob { color: #fb50fb; qproperty-outerColor: #fb50fb; } -MonstroView Knob { +lmms--gui--MonstroView lmms--gui--Knob { color: #ffffff; qproperty-outerColor: #aaaaaa; qproperty-outerRadius: 9; @@ -970,7 +972,7 @@ MonstroView Knob { qproperty-lineWidth: 2.5; } -NesInstrumentView Knob { +lmms--gui--NesInstrumentView lmms--gui--Knob { color: #e7231b; qproperty-outerColor: #fff; qproperty-outerRadius: 11.0; @@ -980,7 +982,7 @@ NesInstrumentView Knob { qproperty-lineWidth: 2; } -CompressorControlDialog { +lmms--gui--CompressorControlDialog { qproperty-inVolAreaColor: rgba(209, 216, 228, 17); qproperty-inVolColor: rgba(209, 216, 228, 100); qproperty-outVolAreaColor: rgba(209, 216, 228, 30); @@ -994,7 +996,7 @@ CompressorControlDialog { qproperty-resetColor: rgba(200, 100, 15, 200); } -CompressorControlDialog Knob { +lmms--gui--CompressorControlDialog lmms--gui--Knob { color: #2fcc71; qproperty-outerColor: #2fcc71; qproperty-lineWidth: 2; @@ -1002,7 +1004,7 @@ CompressorControlDialog Knob { /* palette information */ -LmmsPalette { +lmms--gui--LmmsPalette { qproperty-background: #262b30; qproperty-windowText: #1de276; qproperty-base: #101213; diff --git a/doc/bash-completion/lmms b/doc/bash-completion/lmms index 210f184ee..d6a3b7295 100644 --- a/doc/bash-completion/lmms +++ b/doc/bash-completion/lmms @@ -1,6 +1,5 @@ #!/usr/bin/env bash # lmms(1) completion -*- shell-script -*- -# use shellcheck: "shellcheck -e bash " _lmms_array_contains () { diff --git a/include/AboutDialog.h b/include/AboutDialog.h index 93aca988d..c7d65023f 100644 --- a/include/AboutDialog.h +++ b/include/AboutDialog.h @@ -30,6 +30,8 @@ #include "ui_about_dialog.h" +namespace lmms::gui +{ class AboutDialog : public QDialog, public Ui::AboutDialog { @@ -38,6 +40,7 @@ public: } ; +} // namespace lmms::gui #endif diff --git a/include/ActionGroup.h b/include/ActionGroup.h index 226e39136..0fe9d78ed 100644 --- a/include/ActionGroup.h +++ b/include/ActionGroup.h @@ -28,6 +28,9 @@ #include +namespace lmms::gui +{ + /// \brief Convenience subclass of QActionGroup /// /// This class provides the same functionality as QActionGroup, but in addition @@ -54,4 +57,6 @@ private: QList m_actions; }; +} // namespace lmms::gui + #endif diff --git a/include/AudioAlsa.h b/include/AudioAlsa.h index c8452d003..f96dd01c9 100644 --- a/include/AudioAlsa.h +++ b/include/AudioAlsa.h @@ -37,6 +37,8 @@ #include "AudioDevice.h" +namespace lmms +{ class AudioAlsa : public QThread, public AudioDevice { @@ -52,7 +54,7 @@ public: m_deviceName(deviceName), m_deviceDescription(deviceDescription) {} - ~DeviceInfo() {} + ~DeviceInfo() = default; QString const & getDeviceName() const { return m_deviceName; } QString const & getDeviceDescription() const { return m_deviceDescription; } @@ -63,11 +65,11 @@ public: }; - typedef std::vector DeviceInfoCollection; + using DeviceInfoCollection = std::vector; public: AudioAlsa( bool & _success_ful, AudioEngine* audioEngine ); - virtual ~AudioAlsa(); + ~AudioAlsa() override; inline static QString name() { @@ -102,6 +104,8 @@ private: } ; -#endif +} // namespace lmms + +#endif // LMMS_HAVE_ALSA #endif diff --git a/include/AudioAlsaSetupWidget.h b/include/AudioAlsaSetupWidget.h index db88558a7..f68d71e8a 100644 --- a/include/AudioAlsaSetupWidget.h +++ b/include/AudioAlsaSetupWidget.h @@ -35,8 +35,11 @@ class QComboBox; -class LcdSpinBox; +namespace lmms::gui +{ + +class LcdSpinBox; class AudioAlsaSetupWidget : public AudioDeviceSetupWidget { @@ -44,7 +47,7 @@ class AudioAlsaSetupWidget : public AudioDeviceSetupWidget public: AudioAlsaSetupWidget( QWidget * _parent ); - virtual ~AudioAlsaSetupWidget(); + ~AudioAlsaSetupWidget() override; void saveSettings() override; @@ -59,6 +62,8 @@ private: AudioAlsa::DeviceInfoCollection m_deviceInfos; }; -#endif +} // namespace lmms::gui + +#endif // LMMS_HAVE_ALSA #endif diff --git a/include/AudioDevice.h b/include/AudioDevice.h index 627ba470c..6b4e9939a 100644 --- a/include/AudioDevice.h +++ b/include/AudioDevice.h @@ -30,10 +30,13 @@ #include "lmms_basics.h" +class QThread; + +namespace lmms +{ class AudioEngine; class AudioPort; -class QThread; class AudioDevice @@ -153,7 +156,8 @@ private: surroundSampleFrame * m_buffer; -} ; +}; +} // namespace lmms #endif diff --git a/include/AudioDeviceSetupWidget.h b/include/AudioDeviceSetupWidget.h index 9b82300bb..e984651e4 100644 --- a/include/AudioDeviceSetupWidget.h +++ b/include/AudioDeviceSetupWidget.h @@ -27,6 +27,8 @@ #include "TabWidget.h" +namespace lmms::gui +{ class AudioDeviceSetupWidget : public TabWidget { @@ -34,12 +36,13 @@ class AudioDeviceSetupWidget : public TabWidget public: AudioDeviceSetupWidget( const QString & _caption, QWidget * _parent ); - virtual ~AudioDeviceSetupWidget(); + ~AudioDeviceSetupWidget() override = default; virtual void saveSettings() = 0; virtual void show(); }; +} // namespace lmms::gui #endif diff --git a/include/AudioDummy.h b/include/AudioDummy.h index a0f2c528e..30b125b3a 100644 --- a/include/AudioDummy.h +++ b/include/AudioDummy.h @@ -30,6 +30,8 @@ #include "AudioEngine.h" #include "MicroTimer.h" +namespace lmms +{ class AudioDummy : public QThread, public AudioDevice { @@ -41,7 +43,7 @@ public: _success_ful = true; } - virtual ~AudioDummy() + ~AudioDummy() override { stopProcessing(); } @@ -52,17 +54,15 @@ public: } - class setupWidget : public AudioDeviceSetupWidget + class setupWidget : public gui::AudioDeviceSetupWidget { public: setupWidget( QWidget * _parent ) : - AudioDeviceSetupWidget( AudioDummy::name(), _parent ) + gui::AudioDeviceSetupWidget( AudioDummy::name(), _parent ) { } - virtual ~setupWidget() - { - } + ~setupWidget() override = default; void saveSettings() override { @@ -114,5 +114,6 @@ private: } ; +} // namespace lmms #endif diff --git a/include/AudioEngine.h b/include/AudioEngine.h index a86f540cb..71751acb8 100644 --- a/include/AudioEngine.h +++ b/include/AudioEngine.h @@ -26,6 +26,11 @@ #define AUDIO_ENGINE_H #include + +#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0)) + #include +#endif + #include #include #include @@ -39,9 +44,13 @@ #include "PlayHandle.h" +namespace lmms +{ + class AudioDevice; class MidiClient; class AudioPort; +class AudioEngineWorkerThread; const fpp_t MINIMUM_BUFFER_SIZE = 32; @@ -54,10 +63,6 @@ const int BYTES_PER_SURROUND_FRAME = sizeof( surroundSampleFrame ); const float OUTPUT_SAMPLE_MULTIPLIER = 32767.0f; - -class AudioEngineWorkerThread; - - class LMMS_EXPORT AudioEngine : public QObject { Q_OBJECT @@ -361,11 +366,11 @@ public: signals: void qualitySettingsChanged(); void sampleRateChanged(); - void nextAudioBuffer( const surroundSampleFrame * buffer ); + void nextAudioBuffer( const lmms::surroundSampleFrame * buffer ); private: - typedef FifoBuffer Fifo; + using Fifo = FifoBuffer; class fifoWriter : public QThread { @@ -387,7 +392,7 @@ private: AudioEngine( bool renderOnly ); - virtual ~AudioEngine(); + ~AudioEngine() override; void startProcessing(bool needsFifo = true); void stopProcessing(); @@ -464,16 +469,22 @@ private: bool m_changesSignal; unsigned int m_changes; QMutex m_changesMutex; +#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0)) + QRecursiveMutex m_doChangesMutex; +#else QMutex m_doChangesMutex; +#endif QMutex m_waitChangesMutex; QWaitCondition m_changesAudioEngineCondition; QWaitCondition m_changesRequestCondition; bool m_waitingForWrite; - friend class LmmsCore; + friend class Engine; friend class AudioEngineWorkerThread; friend class ProjectRenderer; } ; +} // namespace lmms + #endif diff --git a/include/AudioEngineProfiler.h b/include/AudioEngineProfiler.h index 19f0b612b..38631c6a9 100644 --- a/include/AudioEngineProfiler.h +++ b/include/AudioEngineProfiler.h @@ -30,11 +30,14 @@ #include "lmms_basics.h" #include "MicroTimer.h" +namespace lmms +{ + class AudioEngineProfiler { public: AudioEngineProfiler(); - ~AudioEngineProfiler(); + ~AudioEngineProfiler() = default; void startPeriod() { @@ -57,4 +60,6 @@ private: QFile m_outputFile; }; +} // namespace lmms + #endif diff --git a/include/AudioEngineWorkerThread.h b/include/AudioEngineWorkerThread.h index f86d41c9a..87e2791b1 100644 --- a/include/AudioEngineWorkerThread.h +++ b/include/AudioEngineWorkerThread.h @@ -29,8 +29,12 @@ #include -class AudioEngine; class QWaitCondition; + +namespace lmms +{ + +class AudioEngine; class ThreadableJob; class AudioEngineWorkerThread : public QThread @@ -74,7 +78,7 @@ public: AudioEngineWorkerThread( AudioEngine* audioEngine ); - virtual ~AudioEngineWorkerThread(); + ~AudioEngineWorkerThread() override; virtual void quit(); @@ -115,5 +119,6 @@ private: volatile bool m_quit; } ; +} // namespace lmms #endif diff --git a/include/AudioFileDevice.h b/include/AudioFileDevice.h index c21a55c4c..beee087e7 100644 --- a/include/AudioFileDevice.h +++ b/include/AudioFileDevice.h @@ -31,6 +31,8 @@ #include "AudioDevice.h" #include "OutputSettings.h" +namespace lmms +{ class AudioFileDevice : public AudioDevice { @@ -38,7 +40,7 @@ public: AudioFileDevice(OutputSettings const & outputSettings, const ch_cnt_t _channels, const QString & _file, AudioEngine* audioEngine ); - virtual ~AudioFileDevice(); + ~AudioFileDevice() override; QString outputFile() const { @@ -66,13 +68,9 @@ private: OutputSettings m_outputSettings; } ; +using AudioFileDeviceInstantiaton + = AudioFileDevice* (*)(const QString&, const OutputSettings&, const ch_cnt_t, AudioEngine*, bool&); -typedef AudioFileDevice * ( * AudioFileDeviceInstantiaton ) - ( const QString & outputFilename, - OutputSettings const & outputSettings, - const ch_cnt_t channels, - AudioEngine* audioEngine, - bool & successful ); - +} // namespace lmms #endif diff --git a/include/AudioFileFlac.h b/include/AudioFileFlac.h index 75e86d368..542a2e717 100644 --- a/include/AudioFileFlac.h +++ b/include/AudioFileFlac.h @@ -30,6 +30,9 @@ #include "AudioFileDevice.h" #include +namespace lmms +{ + class AudioFileFlac: public AudioFileDevice { public: @@ -40,7 +43,7 @@ public: AudioEngine* audioEngine ); - virtual ~AudioFileFlac(); + ~AudioFileFlac() override; static AudioFileDevice* getInst(QString const& outputFilename, OutputSettings const& outputSettings, @@ -62,7 +65,7 @@ private: SF_INFO m_sfinfo; SNDFILE* m_sf; - virtual void writeBuffer(surroundSampleFrame const* _ab, + void writeBuffer(surroundSampleFrame const* _ab, fpp_t const frames, float master_gain) override; @@ -71,4 +74,7 @@ private: }; + +} // namespace lmms + #endif //AUDIO_FILE_FLAC_H diff --git a/include/AudioFileMP3.h b/include/AudioFileMP3.h index ab72ed689..290c9ccbf 100644 --- a/include/AudioFileMP3.h +++ b/include/AudioFileMP3.h @@ -34,6 +34,8 @@ #include "lame/lame.h" +namespace lmms +{ class AudioFileMP3 : public AudioFileDevice { @@ -43,7 +45,7 @@ public: bool & successful, const QString & _file, AudioEngine* audioEngine ); - virtual ~AudioFileMP3(); + ~AudioFileMP3() override; static AudioFileDevice * getInst( const QString & outputFilename, OutputSettings const & outputSettings, @@ -56,7 +58,7 @@ public: } protected: - virtual void writeBuffer( const surroundSampleFrame * /* _buf*/, + void writeBuffer( const surroundSampleFrame * /* _buf*/, const fpp_t /*_frames*/, const float /*_master_gain*/ ) override; @@ -69,6 +71,8 @@ private: lame_t m_lame; }; -#endif +} // namespace lmms + +#endif // LMMS_HAVE_MP3LAME #endif diff --git a/include/AudioFileOgg.h b/include/AudioFileOgg.h index 9c7337e9c..18617fa5f 100644 --- a/include/AudioFileOgg.h +++ b/include/AudioFileOgg.h @@ -34,6 +34,8 @@ #include "AudioFileDevice.h" +namespace lmms +{ class AudioFileOgg : public AudioFileDevice { @@ -43,7 +45,7 @@ public: bool & _success_ful, const QString & _file, AudioEngine* audioEngine ); - virtual ~AudioFileOgg(); + ~AudioFileOgg() override; static AudioFileDevice * getInst( const QString & outputFilename, OutputSettings const & outputSettings, @@ -56,7 +58,7 @@ public: private: - virtual void writeBuffer( const surroundSampleFrame * _ab, + void writeBuffer( const surroundSampleFrame * _ab, const fpp_t _frames, const float _master_gain ) override; @@ -107,6 +109,8 @@ private: } ; -#endif +} // namespace lmms + +#endif // LMMS_HAVE_OGGVORBIS #endif diff --git a/include/AudioFileWave.h b/include/AudioFileWave.h index d8e537859..8dd3566f4 100644 --- a/include/AudioFileWave.h +++ b/include/AudioFileWave.h @@ -31,6 +31,8 @@ #include +namespace lmms +{ class AudioFileWave : public AudioFileDevice { @@ -40,7 +42,7 @@ public: bool & successful, const QString & file, AudioEngine* audioEngine ); - virtual ~AudioFileWave(); + ~AudioFileWave() override; static AudioFileDevice * getInst( const QString & outputFilename, OutputSettings const & outputSettings, @@ -54,7 +56,7 @@ public: private: - virtual void writeBuffer( const surroundSampleFrame * _ab, + void writeBuffer( const surroundSampleFrame * _ab, const fpp_t _frames, float _master_gain ) override; @@ -66,4 +68,7 @@ private: SNDFILE * m_sf; } ; + +} // namespace lmms + #endif diff --git a/include/AudioJack.h b/include/AudioJack.h index e74ac4782..263399487 100644 --- a/include/AudioJack.h +++ b/include/AudioJack.h @@ -41,22 +41,30 @@ #include "AudioDeviceSetupWidget.h" class QLineEdit; -class LcdSpinBox; + +namespace lmms +{ + class MidiJack; +namespace gui +{ +class LcdSpinBox; +} + class AudioJack : public QObject, public AudioDevice { Q_OBJECT public: AudioJack( bool & _success_ful, AudioEngine* audioEngine ); - virtual ~AudioJack(); + ~AudioJack() override; // this is to allow the jack midi connection to use the same jack client connection // the jack callback is handled here, we call the midi client so that it can read // it's midi data during the callback AudioJack * addMidiClient(MidiJack *midiClient); - void removeMidiClient(void) { m_midiClient = nullptr; } + void removeMidiClient() { m_midiClient = nullptr; } jack_client_t * jackClient() {return m_client;}; inline static QString name() @@ -66,17 +74,17 @@ public: } - class setupWidget : public AudioDeviceSetupWidget +class setupWidget : public gui::AudioDeviceSetupWidget { public: setupWidget( QWidget * _parent ); - virtual ~setupWidget(); + ~setupWidget() override; - virtual void saveSettings(); + void saveSettings() override; private: QLineEdit * m_clientName; - LcdSpinBox * m_channels; + gui::LcdSpinBox * m_channels; } ; @@ -88,13 +96,13 @@ private slots: private: bool initJackClient(); - virtual void startProcessing(); - virtual void stopProcessing(); - virtual void applyQualitySettings(); + void startProcessing() override; + void stopProcessing() override; + void applyQualitySettings() override; - virtual void registerPort( AudioPort * _port ); - virtual void unregisterPort( AudioPort * _port ); - virtual void renamePort( AudioPort * _port ); + void registerPort( AudioPort * _port ) override; + void unregisterPort( AudioPort * _port ) override; + void renamePort( AudioPort * _port ) override; int processCallback( jack_nframes_t _nframes, void * _udata ); @@ -123,7 +131,7 @@ private: jack_port_t * ports[2]; } ; - typedef QMap JackPortMap; + using JackPortMap = QMap; JackPortMap m_portMap; #endif @@ -132,6 +140,8 @@ signals: } ; -#endif +} // namespace lmms + +#endif // LMMS_HAVE_JACK #endif diff --git a/include/AudioOss.h b/include/AudioOss.h index b1b5d839c..71103586a 100644 --- a/include/AudioOss.h +++ b/include/AudioOss.h @@ -34,17 +34,24 @@ #include "AudioDevice.h" #include "AudioDeviceSetupWidget.h" - -class LcdSpinBox; class QLineEdit; +namespace lmms +{ + +namespace gui +{ +class LcdSpinBox; +} + + class AudioOss : public QThread, public AudioDevice { Q_OBJECT public: AudioOss( bool & _success_ful, AudioEngine* audioEngine ); - virtual ~AudioOss(); + ~AudioOss() override; inline static QString name() { @@ -54,17 +61,17 @@ public: static QString probeDevice(); - class setupWidget : public AudioDeviceSetupWidget +class setupWidget : public gui::AudioDeviceSetupWidget { public: setupWidget( QWidget * _parent ); - virtual ~setupWidget(); + ~setupWidget() override; void saveSettings() override; private: QLineEdit * m_device; - LcdSpinBox * m_channels; + gui::LcdSpinBox * m_channels; } ; @@ -81,7 +88,8 @@ private: } ; - -#endif +} // namespace lmms + +#endif // LMMS_HAVE_OSS #endif diff --git a/include/AudioPort.h b/include/AudioPort.h index 0f6c931d9..5a2645784 100644 --- a/include/AudioPort.h +++ b/include/AudioPort.h @@ -32,6 +32,9 @@ #include "MemoryManager.h" #include "PlayHandle.h" +namespace lmms +{ + class EffectChain; class FloatModel; class BoolModel; @@ -133,5 +136,6 @@ private: } ; +} // namespace lmms #endif diff --git a/include/AudioPortAudio.h b/include/AudioPortAudio.h index 2d78af1c4..3fd32a7ac 100644 --- a/include/AudioPortAudio.h +++ b/include/AudioPortAudio.h @@ -30,9 +30,28 @@ #include "lmmsconfig.h" #include "ComboBoxModel.h" +#ifdef LMMS_HAVE_PORTAUDIO + +# include + +# include "AudioDevice.h" +# include "AudioDeviceSetupWidget.h" + +# if defined paNeverDropInput || defined paNonInterleaved +# define PORTAUDIO_V19 +# else +# define PORTAUDIO_V18 +# endif + +#endif + + +namespace lmms +{ + class AudioPortAudioSetupUtil : public QObject { - Q_OBJECT +Q_OBJECT public slots: void updateBackends(); void updateDevices(); @@ -41,33 +60,24 @@ public slots: public: ComboBoxModel m_backendModel; ComboBoxModel m_deviceModel; -} ; +}; #ifdef LMMS_HAVE_PORTAUDIO -#include - - -#include "AudioDevice.h" -#include "AudioDeviceSetupWidget.h" - -#if defined paNeverDropInput || defined paNonInterleaved -# define PORTAUDIO_V19 -#else -# define PORTAUDIO_V18 -#endif - +namespace gui +{ class ComboBox; class LcdSpinBox; +} class AudioPortAudio : public AudioDevice { public: AudioPortAudio( bool & _success_ful, AudioEngine* audioEngine ); - virtual ~AudioPortAudio(); + ~AudioPortAudio() override; inline static QString name() { @@ -80,26 +90,26 @@ public: unsigned long _framesPerBuffer ); - class setupWidget : public AudioDeviceSetupWidget + class setupWidget : public gui::AudioDeviceSetupWidget { public: setupWidget( QWidget * _parent ); - virtual ~setupWidget(); + ~setupWidget() override; - virtual void saveSettings(); - virtual void show(); + void saveSettings() override; + void show() override; private: - ComboBox * m_backend; - ComboBox * m_device; + gui::ComboBox * m_backend; + gui::ComboBox * m_device; AudioPortAudioSetupUtil m_setupUtil; } ; private: - virtual void startProcessing(); - virtual void stopProcessing(); - virtual void applyQualitySettings(); + void startProcessing() override; + void stopProcessing() override; + void applyQualitySettings() override; #ifdef PORTAUDIO_V19 static int _process_callback( const void *_inputBuffer, void * _outputBuffer, @@ -121,10 +131,10 @@ private: unsigned long _framesPerBuffer, PaTimestamp _outTime, void * _arg ); - typedef double PaTime; - typedef PaDeviceID PaDeviceIndex; + using PaTime = double; + using PaDeviceIndex = PaDeviceID; - typedef struct PaStreamParameters + using PaStreamParameters = struct { PaDeviceIndex device; int channelCount; @@ -133,7 +143,7 @@ private: void *hostApiSpecificStreamInfo; } PaStreamParameters; -#endif +#endif // PORTAUDIO_V19 PaStream * m_paStream; PaStreamParameters m_outputParameters; @@ -149,6 +159,8 @@ private: } ; -#endif +#endif // LMMS_HAVE_PORTAUDIO + +} // namespace lmms #endif diff --git a/include/AudioPulseAudio.h b/include/AudioPulseAudio.h index 3fe098d68..789296e27 100644 --- a/include/AudioPulseAudio.h +++ b/include/AudioPulseAudio.h @@ -36,17 +36,23 @@ #include "AudioDevice.h" #include "AudioDeviceSetupWidget.h" - -class LcdSpinBox; class QLineEdit; +namespace lmms +{ + +namespace gui +{ +class LcdSpinBox; +} + class AudioPulseAudio : public QThread, public AudioDevice { Q_OBJECT public: AudioPulseAudio( bool & _success_ful, AudioEngine* audioEngine ); - virtual ~AudioPulseAudio(); + ~AudioPulseAudio() override; inline static QString name() { @@ -56,17 +62,17 @@ public: static QString probeDevice(); - class setupWidget : public AudioDeviceSetupWidget + class setupWidget : public gui::AudioDeviceSetupWidget { public: setupWidget( QWidget * _parent ); - virtual ~setupWidget(); + ~setupWidget() override; void saveSettings() override; private: QLineEdit * m_device; - LcdSpinBox * m_channels; + gui::LcdSpinBox * m_channels; } ; @@ -94,6 +100,8 @@ private: } ; -#endif +} // namespace lmms + +#endif // LMMS_HAVE_PULSEAUDIO #endif diff --git a/include/AudioSampleRecorder.h b/include/AudioSampleRecorder.h index f5d5985c1..7ad551916 100644 --- a/include/AudioSampleRecorder.h +++ b/include/AudioSampleRecorder.h @@ -31,6 +31,9 @@ #include "AudioDevice.h" +namespace lmms +{ + class SampleBuffer; @@ -38,21 +41,22 @@ class AudioSampleRecorder : public AudioDevice { public: AudioSampleRecorder( const ch_cnt_t _channels, bool & _success_ful, AudioEngine* audioEngine ); - virtual ~AudioSampleRecorder(); + ~AudioSampleRecorder() override; f_cnt_t framesRecorded() const; void createSampleBuffer( SampleBuffer** sampleBuffer ); private: - virtual void writeBuffer( const surroundSampleFrame * _ab, + void writeBuffer( const surroundSampleFrame * _ab, const fpp_t _frames, const float _master_gain ) override; - typedef QList > BufferList; + using BufferList = QList>; BufferList m_buffers; } ; +} // namespace lmms #endif diff --git a/include/AudioSdl.h b/include/AudioSdl.h index 307973013..7e7710a2f 100644 --- a/include/AudioSdl.h +++ b/include/AudioSdl.h @@ -41,12 +41,14 @@ class QLineEdit; +namespace lmms +{ class AudioSdl : public AudioDevice { public: AudioSdl( bool & _success_ful, AudioEngine* audioEngine ); - virtual ~AudioSdl(); + ~AudioSdl() override; inline static QString name() { @@ -55,11 +57,11 @@ public: } - class setupWidget : public AudioDeviceSetupWidget + class setupWidget : public gui::AudioDeviceSetupWidget { public: setupWidget( QWidget * _parent ); - ~setupWidget() override; + ~setupWidget() override = default; void saveSettings() override; @@ -108,6 +110,9 @@ private: } ; -#endif + +} // namespace lmms + +#endif // LMMS_HAVE_SDL #endif diff --git a/include/AudioSndio.h b/include/AudioSndio.h index 94fcfa93b..606850105 100644 --- a/include/AudioSndio.h +++ b/include/AudioSndio.h @@ -36,40 +36,47 @@ #include "AudioDevice.h" #include "AudioDeviceSetupWidget.h" -class LcdSpinBox; class QLineEdit; +namespace lmms +{ + +namespace gui +{ +class LcdSpinBox; +} + class AudioSndio : public QThread, public AudioDevice { Q_OBJECT public: AudioSndio( bool & _success_ful, AudioEngine * _audioEngine ); - virtual ~AudioSndio(); + ~AudioSndio() override; - inline static QString name( void ) + inline static QString name() { return QT_TRANSLATE_NOOP( "AudioDeviceSetupWidget", "sndio" ); } - class setupWidget : public AudioDeviceSetupWidget + class setupWidget : public gui::AudioDeviceSetupWidget { public: setupWidget( QWidget * _parent ); - virtual ~setupWidget(); + ~setupWidget() override = default; - void saveSettings( void ) override; + void saveSettings() override; private: QLineEdit * m_device; - LcdSpinBox * m_channels; + gui::LcdSpinBox * m_channels; } ; private: - void startProcessing( void ) override; - void stopProcessing( void ) override; - void applyQualitySettings( void ) override; - void run( void ) override; + void startProcessing() override; + void stopProcessing() override; + void applyQualitySettings() override; + void run() override; struct sio_hdl *m_hdl; struct sio_par m_par; @@ -78,6 +85,8 @@ private: } ; -#endif /* LMMS_HAVE_SNDIO */ +} // namespace lmms -#endif /* _AUDIO_SNDIO_H */ +#endif // LMMS_HAVE_SNDIO + +#endif // _AUDIO_SNDIO_H diff --git a/include/AudioSoundIo.h b/include/AudioSoundIo.h index 5dbd35250..dc9afe7e4 100644 --- a/include/AudioSoundIo.h +++ b/include/AudioSoundIo.h @@ -37,15 +37,21 @@ #include "AudioDevice.h" #include "AudioDeviceSetupWidget.h" +namespace lmms +{ + +namespace gui +{ class ComboBox; class LcdSpinBox; +} // Exists only to work around "Error: Meta object features not supported for nested classes" class AudioSoundIoSetupUtil : public QObject { Q_OBJECT public: - virtual ~AudioSoundIoSetupUtil(); + virtual ~AudioSoundIoSetupUtil() = default; void *m_setupWidget; public slots: @@ -64,7 +70,7 @@ public: return QT_TRANSLATE_NOOP( "AudioDeviceSetupWidget", "soundio" ); } - class setupWidget : public AudioDeviceSetupWidget + class setupWidget : public gui::AudioDeviceSetupWidget { public: setupWidget( QWidget * _parent ); @@ -78,8 +84,8 @@ public: private: AudioSoundIoSetupUtil m_setupUtil; - ComboBox * m_backend; - ComboBox * m_device; + gui::ComboBox * m_backend; + gui::ComboBox * m_device; ComboBoxModel m_backendModel; ComboBoxModel m_deviceModel; @@ -134,6 +140,9 @@ private: }; -#endif + +} // namespace lmms + +#endif // LMMS_HAVE_SOUNDIO #endif diff --git a/include/AutomatableButton.h b/include/AutomatableButton.h index d7859a10c..d8c58523c 100644 --- a/include/AutomatableButton.h +++ b/include/AutomatableButton.h @@ -30,6 +30,8 @@ #include "AutomatableModelView.h" +namespace lmms::gui +{ class automatableButtonGroup; @@ -40,7 +42,7 @@ class LMMS_EXPORT AutomatableButton : public QPushButton, public BoolModelView public: AutomatableButton( QWidget * _parent, const QString & _name = QString() ); - virtual ~AutomatableButton(); + ~AutomatableButton() override; inline void setCheckable( bool _on ) { @@ -85,7 +87,7 @@ class LMMS_EXPORT automatableButtonGroup : public QWidget, public IntModelView public: automatableButtonGroup( QWidget * _parent, const QString & _name = QString() ); - virtual ~automatableButtonGroup(); + ~automatableButtonGroup() override; void addButton( AutomatableButton * _btn ); void removeButton( AutomatableButton * _btn ); @@ -105,5 +107,6 @@ private: } ; +} // namespace lmms::gui #endif diff --git a/include/AutomatableModel.h b/include/AutomatableModel.h index 2f4b31467..c8f2ab548 100644 --- a/include/AutomatableModel.h +++ b/include/AutomatableModel.h @@ -35,6 +35,10 @@ #include "MemoryManager.h" #include "ModelVisitor.h" + +namespace lmms +{ + // simple way to map a property of a view to a model #define mapPropertyFromModelPtr(type,getfunc,setfunc,modelname) \ public: \ @@ -74,8 +78,7 @@ class LMMS_EXPORT AutomatableModel : public Model, public JournallingObject Q_OBJECT MM_OPERATORS public: - - typedef QVector AutoModelVector; + using AutoModelVector = QVector; enum ScaleType { @@ -85,7 +88,7 @@ public: }; - virtual ~AutomatableModel(); + ~AutomatableModel() override; // Implement those by using the MODEL_IS_VISITABLE macro virtual void accept(ModelVisitor& v) = 0; @@ -416,7 +419,7 @@ private: signals: void initValueChanged( float val ); - void destroyed( jo_id_t id ); + void destroyed( lmms::jo_id_t id ); } ; @@ -500,7 +503,9 @@ public: QString displayValue( const float val ) const override; } ; -typedef QMap AutomatedValueMap; +using AutomatedValueMap = QMap; + +} // namespace lmms #endif diff --git a/include/AutomatableModelView.h b/include/AutomatableModelView.h index a59961185..1e8ef7398 100644 --- a/include/AutomatableModelView.h +++ b/include/AutomatableModelView.h @@ -32,11 +32,14 @@ class QMenu; class QMouseEvent; +namespace lmms::gui +{ + class LMMS_EXPORT AutomatableModelView : public ModelView { public: AutomatableModelView( Model* model, QWidget* _this ); - virtual ~AutomatableModelView() = default; + ~AutomatableModelView() override = default; // some basic functions for convenience AutomatableModel* modelUntyped() @@ -132,5 +135,7 @@ using FloatModelView = TypedModelView; using IntModelView = TypedModelView; using BoolModelView = TypedModelView; +} // namespace lmms::gui + #endif diff --git a/include/AutomatableSlider.h b/include/AutomatableSlider.h index b51ef1e3f..ba11741b5 100644 --- a/include/AutomatableSlider.h +++ b/include/AutomatableSlider.h @@ -31,13 +31,15 @@ #include "AutomatableModelView.h" +namespace lmms::gui +{ class AutomatableSlider : public QSlider, public IntModelView { Q_OBJECT public: AutomatableSlider( QWidget * _parent, const QString & _name = QString() ); - virtual ~AutomatableSlider(); + ~AutomatableSlider() override = default; bool showStatus() { @@ -71,7 +73,8 @@ private slots: } ; -typedef IntModel sliderModel; +using sliderModel = IntModel; +} // namespace lmms::gui #endif diff --git a/include/AutomationClip.h b/include/AutomationClip.h index 22af90ed1..3e253d85f 100644 --- a/include/AutomationClip.h +++ b/include/AutomationClip.h @@ -29,14 +29,25 @@ #include #include +#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0)) + #include +#endif #include "AutomationNode.h" #include "Clip.h" +namespace lmms +{ + class AutomationTrack; class TimePos; +namespace gui +{ +class AutomationClipView; +} // namespace gui + class LMMS_EXPORT AutomationClip : public Clip @@ -50,14 +61,14 @@ public: CubicHermiteProgression } ; - typedef QMap timeMap; - typedef QVector> objectVector; + using timeMap = QMap; + using objectVector = QVector>; using TimemapIterator = timeMap::const_iterator; AutomationClip( AutomationTrack * _auto_track ); AutomationClip( const AutomationClip & _clip_to_copy ); - virtual ~AutomationClip() = default; + ~AutomationClip() override = default; bool addObject( AutomatableModel * _obj, bool _search_dup = true ); @@ -152,7 +163,7 @@ public: static const QString classNodeName() { return "automationclip"; } QString nodeName() const override { return classNodeName(); } - ClipView * createView( TrackView * _tv ) override; + gui::ClipView * createView( gui::TrackView * _tv ) override; static bool isAutomated( const AutomatableModel * _m ); @@ -168,7 +179,7 @@ public: public slots: void clear(); - void objectDestroyed( jo_id_t ); + void objectDestroyed( lmms::jo_id_t ); void flipY( int min, int max ); void flipY(); void flipX( int length = -1 ); @@ -181,7 +192,11 @@ private: // Mutex to make methods involving automation clips thread safe // Mutable so we can lock it from const objects +#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0)) + mutable QRecursiveMutex m_clipMutex; +#else mutable QMutex m_clipMutex; +#endif AutomationTrack * m_autoTrack; QVector m_idsToResolve; @@ -204,7 +219,7 @@ private: static const float DEFAULT_MIN_VALUE; static const float DEFAULT_MAX_VALUE; - friend class AutomationClipView; + friend class gui::AutomationClipView; friend class AutomationNode; } ; @@ -242,4 +257,7 @@ inline int POS(AutomationClip::TimemapIterator it) return it.key(); } + +} // namespace lmms + #endif diff --git a/include/AutomationClipView.h b/include/AutomationClipView.h index 641a58699..b4de7839c 100644 --- a/include/AutomationClipView.h +++ b/include/AutomationClipView.h @@ -29,8 +29,14 @@ #include "ClipView.h" +namespace lmms +{ + class AutomationClip; +namespace gui +{ + class AutomationClipView : public ClipView { @@ -39,7 +45,7 @@ class AutomationClipView : public ClipView public: AutomationClipView( AutomationClip * _clip, TrackView * _parent ); - virtual ~AutomationClipView(); + ~AutomationClipView() override = default; public slots: /// Opens this view's clip in the global automation editor @@ -75,4 +81,8 @@ private: } ; +} // namespace gui + +} // namespace lmms + #endif diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index c655ffcdf..52609416f 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -40,9 +40,16 @@ class QPainter; class QPixmap; class QScrollBar; -class ComboBox; -class Knob; +namespace lmms +{ + class NotePlayHandle; + +namespace gui +{ + +class Knob; +class ComboBox; class TimeLineWidget; @@ -92,7 +99,7 @@ public slots: protected: - typedef AutomationClip::timeMap timeMap; + using timeMap = AutomationClip::timeMap; void keyPressEvent(QKeyEvent * ke) override; void leaveEvent(QEvent * e) override; @@ -128,7 +135,7 @@ protected slots: void setProgressionType(int type); void setTension(); - void updatePosition( const TimePos & t ); + void updatePosition( const lmms::TimePos & t ); void zoomingXChanged(); void zoomingYChanged(); @@ -160,7 +167,7 @@ private: AutomationEditor(); AutomationEditor( const AutomationEditor & ); - virtual ~AutomationEditor(); + ~AutomationEditor() override; static QPixmap * s_toolDraw; static QPixmap * s_toolErase; @@ -234,7 +241,7 @@ private: signals: void currentClipChanged(); - void positionChanged( const TimePos & ); + void positionChanged( const lmms::TimePos & ); } ; @@ -248,7 +255,7 @@ class AutomationEditorWindow : public Editor static const int INITIAL_HEIGHT = 480; public: AutomationEditorWindow(); - ~AutomationEditorWindow(); + ~AutomationEditorWindow() override = default; void setCurrentClip(AutomationClip* clip); const AutomationClip* currentClip(); @@ -293,5 +300,8 @@ private: ComboBox * m_quantizeComboBox; }; +} // namespace gui + +} // namespace lmms #endif diff --git a/include/AutomationNode.h b/include/AutomationNode.h index 6cd445662..11bd6d57d 100644 --- a/include/AutomationNode.h +++ b/include/AutomationNode.h @@ -26,6 +26,9 @@ #ifndef AUTOMATION_NODE_H #define AUTOMATION_NODE_H +namespace lmms +{ + class AutomationClip; @@ -151,5 +154,6 @@ private: float m_outTangent; }; +} // namespace lmms #endif diff --git a/include/AutomationTrack.h b/include/AutomationTrack.h index dc33f76c3..1779bf102 100644 --- a/include/AutomationTrack.h +++ b/include/AutomationTrack.h @@ -29,15 +29,17 @@ #include "Track.h" +namespace lmms +{ class AutomationTrack : public Track { Q_OBJECT public: AutomationTrack( TrackContainer* tc, bool _hidden = false ); - virtual ~AutomationTrack() = default; + ~AutomationTrack() override = default; - virtual bool play( const TimePos & _start, const fpp_t _frames, + bool play( const TimePos & _start, const fpp_t _frames, const f_cnt_t _frame_base, int _clip_num = -1 ) override; QString nodeName() const override @@ -45,10 +47,10 @@ public: return "automationtrack"; } - TrackView * createView( TrackContainerView* ) override; + gui::TrackView * createView( gui::TrackContainerView* ) override; Clip* createClip(const TimePos & pos) override; - virtual void saveTrackSpecificSettings( QDomDocument & _doc, + void saveTrackSpecificSettings( QDomDocument & _doc, QDomElement & _parent ) override; void loadTrackSpecificSettings( const QDomElement & _this ) override; @@ -58,4 +60,6 @@ private: } ; +} // namespace lmms + #endif diff --git a/include/AutomationTrackView.h b/include/AutomationTrackView.h index 5ed993213..18454bec2 100644 --- a/include/AutomationTrackView.h +++ b/include/AutomationTrackView.h @@ -28,18 +28,28 @@ #include "TrackView.h" +namespace lmms +{ + class AutomationTrack; +namespace gui +{ + class AutomationTrackView : public TrackView { public: AutomationTrackView( AutomationTrack* at, TrackContainerView* tcv ); - virtual ~AutomationTrackView() = default; + ~AutomationTrackView() override = default; void dragEnterEvent( QDragEnterEvent * _dee ) override; void dropEvent( QDropEvent * _de ) override; } ; +} // namespace gui + +} // namespace lmms + #endif diff --git a/include/BandLimitedWave.h b/include/BandLimitedWave.h index 1cd8d69ed..588fc4eea 100644 --- a/include/BandLimitedWave.h +++ b/include/BandLimitedWave.h @@ -36,6 +36,9 @@ class QString; #include "Engine.h" #include "AudioEngine.h" +namespace lmms +{ + constexpr int MAXLEN = 11; constexpr int MIPMAPSIZE = 2 << ( MAXLEN + 1 ); constexpr int MIPMAPSIZE3 = 3 << ( MAXLEN + 1 ); @@ -51,29 +54,30 @@ const int TLENS[MAXTBL+1] = { 2 << 0, 3 << 0, 2 << 1, 3 << 1, 2 << 8, 3 << 8, 2 << 9, 3 << 9, 2 << 10, 3 << 10, 2 << 11, 3 << 11 }; -typedef struct +struct WaveMipMap { public: - inline sample_t sampleAt( int table, int ph ) + inline sample_t sampleAt(int table, int ph) { - if( table % 2 == 0 ) - { return m_data[ TLENS[ table ] + ph ]; } + if (table % 2 == 0) { return m_data[TLENS[table] + ph]; } else - { return m_data3[ TLENS[ table ] + ph ]; } + { + return m_data3[TLENS[table] + ph]; + } } - inline void setSampleAt( int table, int ph, sample_t sample ) + inline void setSampleAt(int table, int ph, sample_t sample) { - if( table % 2 == 0 ) - { m_data[ TLENS[ table ] + ph ] = sample; } + if (table % 2 == 0) { m_data[TLENS[table] + ph] = sample; } else - { m_data3[ TLENS[ table ] + ph ] = sample; } + { + m_data3[TLENS[table] + ph] = sample; + } } + private: - sample_t m_data [ MIPMAPSIZE ]; - sample_t m_data3 [ MIPMAPSIZE3 ]; - -} WaveMipMap; - + sample_t m_data[MIPMAPSIZE]; + sample_t m_data3[MIPMAPSIZE3]; +}; QDataStream& operator<< ( QDataStream &out, WaveMipMap &waveMipMap ); @@ -94,8 +98,8 @@ public: NumBLWaveforms }; - BandLimitedWave() {}; - virtual ~BandLimitedWave() {}; + BandLimitedWave() = default; + virtual ~BandLimitedWave() = default; /*! \brief This method converts frequency to wavelength. The oscillate function takes wavelength as argument so * use this to convert your note frequency to wavelength before using it. @@ -163,10 +167,11 @@ public: static bool s_wavesGenerated; - static WaveMipMap s_waveforms [NumBLWaveforms]; + static std::array s_waveforms; static QString s_wavetableDir; }; +} // namespace lmms #endif diff --git a/include/BasicFilters.h b/include/BasicFilters.h index 07cdda06b..836d758b6 100644 --- a/include/BasicFilters.h +++ b/include/BasicFilters.h @@ -43,6 +43,9 @@ #include "interpolation.h" #include "MemoryManager.h" +namespace lmms +{ + template class BasicFilters; template @@ -55,7 +58,7 @@ public: m_sampleRate = sampleRate; clearHistory(); } - virtual ~LinkwitzRiley() {} + virtual ~LinkwitzRiley() = default; inline void clearHistory() { @@ -135,10 +138,10 @@ private: double m_a, m_a0, m_a1, m_a2; double m_b1, m_b2, m_b3, m_b4; - typedef double frame[CHANNELS]; + using frame = std::array; frame m_z1, m_z2, m_z3, m_z4; }; -typedef LinkwitzRiley<2> StereoLinkwitzRiley; +using StereoLinkwitzRiley = LinkwitzRiley<2>; template class BiQuad @@ -149,7 +152,7 @@ public: { clearHistory(); } - virtual ~BiQuad() {} + virtual ~BiQuad() = default; inline void setCoeffs( float a1, float a2, float b0, float b1, float b2 ) { @@ -181,7 +184,7 @@ private: friend class BasicFilters; // needed for subfilter stuff in BasicFilters }; -typedef BiQuad<2> StereoBiQuad; +using StereoBiQuad = BiQuad<2>; template class OnePole @@ -197,7 +200,7 @@ public: m_z1[i] = 0.0; } } - virtual ~OnePole() {} + virtual ~OnePole() = default; inline void setCoeffs( float a0, float b1 ) { @@ -215,7 +218,7 @@ private: float m_a0, m_b1; float m_z1 [CHANNELS]; }; -typedef OnePole<2> StereoOnePole; +using StereoOnePole = OnePole<2>; template class BasicFilters @@ -886,7 +889,7 @@ private: // coeffs for Lowpass_SV (state-variant lowpass) float m_svf1, m_svf2, m_svq; - typedef sample_t frame[CHANNELS]; + using frame = std::array; // in/out history for moog-filter frame m_y1, m_y2, m_y3, m_y4, m_oldx, m_oldy1, m_oldy2, m_oldy3; @@ -913,4 +916,6 @@ private: } ; +} // namespace lmms + #endif diff --git a/include/BufferManager.h b/include/BufferManager.h index 20390644b..57729918e 100644 --- a/include/BufferManager.h +++ b/include/BufferManager.h @@ -29,10 +29,14 @@ #include "lmms_export.h" #include "lmms_basics.h" +namespace lmms +{ + + class LMMS_EXPORT BufferManager { public: - static void init( fpp_t framesPerPeriod ); + static void init( fpp_t fpp ); static sampleFrame * acquire(); // audio-buffer-mgm static void clear( sampleFrame * ab, const f_cnt_t frames, @@ -42,6 +46,12 @@ public: const f_cnt_t offset = 0 ); #endif static void release( sampleFrame * buf ); + +private: + static fpp_t s_framesPerPeriod; }; + +} // namespace lmms + #endif diff --git a/include/CPULoadWidget.h b/include/CPULoadWidget.h index a5da11663..dd2747ef2 100644 --- a/include/CPULoadWidget.h +++ b/include/CPULoadWidget.h @@ -34,12 +34,16 @@ #include "lmms_basics.h" +namespace lmms::gui +{ + + class CPULoadWidget : public QWidget { Q_OBJECT public: CPULoadWidget( QWidget * _parent ); - virtual ~CPULoadWidget(); + ~CPULoadWidget() override = default; protected: @@ -64,4 +68,6 @@ private: } ; +} // namespace lmms::gui + #endif diff --git a/include/CaptionMenu.h b/include/CaptionMenu.h index e6531fe31..f6a2fff25 100644 --- a/include/CaptionMenu.h +++ b/include/CaptionMenu.h @@ -30,6 +30,9 @@ #include "lmms_export.h" +namespace lmms::gui +{ + /// /// \brief A context menu with a caption /// @@ -38,10 +41,10 @@ class LMMS_EXPORT CaptionMenu : public QMenu Q_OBJECT public: CaptionMenu( const QString & _title, QWidget * _parent = 0 ); - virtual ~CaptionMenu(); + ~CaptionMenu() override = default; } ; - +} // namespace lmms::gui #endif diff --git a/include/Clip.h b/include/Clip.h index 7b42fc91b..204a071a7 100644 --- a/include/Clip.h +++ b/include/Clip.h @@ -30,11 +30,20 @@ #include "AutomatableModel.h" +namespace lmms +{ + class Track; -class ClipView; class TrackContainer; + +namespace gui +{ + +class ClipView; class TrackView; +} // namespace gui + class LMMS_EXPORT Clip : public Model, public JournallingObject { @@ -44,7 +53,7 @@ class LMMS_EXPORT Clip : public Model, public JournallingObject mapPropertyFromModel(bool,isSolo,setSolo,m_soloModel); public: Clip( Track * track ); - virtual ~Clip(); + ~Clip() override; inline Track * getTrack() const { @@ -84,6 +93,12 @@ public: return m_length; } + /*! \brief Specify whether or not a TCO automatically resizes. + * + * If a TCO does automatically resize, it cannot be manually + * resized by clicking and dragging its edge. + * + */ inline void setAutoResize( const bool r ) { m_autoResize = r; @@ -116,7 +131,7 @@ public: virtual void movePosition( const TimePos & pos ); virtual void changeLength( const TimePos & length ); - virtual ClipView * createView( TrackView * tv ) = 0; + virtual gui::ClipView * createView( gui::TrackView * tv ) = 0; inline void selectViewOnCreate( bool select ) { @@ -177,4 +192,6 @@ private: } ; +} // namespace lmms + #endif diff --git a/include/ClipView.h b/include/ClipView.h index b3fd20920..8cfb9e7a4 100644 --- a/include/ClipView.h +++ b/include/ClipView.h @@ -36,9 +36,16 @@ class QMenu; class QContextMenuEvent; +namespace lmms +{ + class DataFile; -class TextFloat; class Clip; + +namespace gui +{ + +class TextFloat; class TrackView; @@ -64,7 +71,7 @@ public: const static int BORDER_WIDTH = 2; ClipView( Clip * clip, TrackView * tv ); - virtual ~ClipView(); + ~ClipView() override; bool fixedClips(); @@ -241,4 +248,8 @@ private: } ; +} // namespace gui + +} // namespace lmms + #endif diff --git a/include/Clipboard.h b/include/Clipboard.h index 168134e9d..1c2dcb647 100644 --- a/include/Clipboard.h +++ b/include/Clipboard.h @@ -30,8 +30,9 @@ class QMimeData; -namespace Clipboard +namespace lmms::Clipboard { + enum class MimeType { StringPair, @@ -64,6 +65,7 @@ namespace Clipboard break; } } -} ; + +} // namespace lmms::Clipboard #endif diff --git a/include/ColorChooser.h b/include/ColorChooser.h index ac2a1b62d..5482a9a03 100644 --- a/include/ColorChooser.h +++ b/include/ColorChooser.h @@ -21,19 +21,26 @@ * */ +#ifndef COLOR_CHOOSER_H +#define COLOR_CHOOSER_H + #include #include #include #include #include +namespace lmms::gui +{ + + class ColorChooser: public QColorDialog { public: ColorChooser(const QColor &initial, QWidget *parent): QColorDialog(initial, parent) {}; ColorChooser(QWidget *parent): QColorDialog(parent) {}; //! For getting a color without having to initialise a color dialog - ColorChooser() {}; + ColorChooser() = default; enum class Palette {Default, Track, Mixer}; //! Set global palette via array, checking bounds void setPalette (QVector); @@ -57,3 +64,9 @@ private: //! Generate a nice palette, with adjustable value static QVector nicePalette (int); }; + + +} // namespace lmms::gui + +#endif + diff --git a/include/ComboBox.h b/include/ComboBox.h index 1f7dd43ff..9a0e5a517 100644 --- a/include/ComboBox.h +++ b/include/ComboBox.h @@ -32,12 +32,15 @@ #include "ComboBoxModel.h" #include "AutomatableModelView.h" +namespace lmms::gui +{ + class LMMS_EXPORT ComboBox : public QWidget, public IntModelView { Q_OBJECT public: ComboBox( QWidget* parent = nullptr, const QString& name = QString() ); - virtual ~ComboBox(); + ~ComboBox() override = default; ComboBoxModel* model() { @@ -78,4 +81,6 @@ private slots: } ; +} // namespace lmms::gui + #endif diff --git a/include/ComboBoxModel.h b/include/ComboBoxModel.h index a3c2a082b..0c76620d8 100644 --- a/include/ComboBoxModel.h +++ b/include/ComboBoxModel.h @@ -32,6 +32,8 @@ #include "AutomatableModel.h" #include "embed.h" +namespace lmms +{ class LMMS_EXPORT ComboBoxModel : public IntModel { @@ -45,7 +47,7 @@ public: { } - virtual ~ComboBoxModel() + ~ComboBoxModel() override { clear(); } @@ -85,11 +87,12 @@ public: private: - typedef std::pair > Item; + using Item = std::pair>; std::vector m_items; } ; +} // namespace lmms #endif diff --git a/include/ConfigManager.h b/include/ConfigManager.h index e9b2783ab..fd2967b6a 100644 --- a/include/ConfigManager.h +++ b/include/ConfigManager.h @@ -37,7 +37,11 @@ #include "lmms_export.h" -class LmmsCore; +namespace lmms +{ + + +class Engine; const QString PROJECTS_PATH = "projects/"; const QString TEMPLATE_PATH = "templates/"; @@ -270,7 +274,7 @@ private: ConfigManager(); ConfigManager(const ConfigManager & _c); - ~ConfigManager(); + ~ConfigManager() override; void upgrade_1_1_90(); void upgrade_1_1_91(); @@ -299,11 +303,15 @@ private: unsigned int m_configVersion; QStringList m_recentlyOpenedProjects; - typedef QVector > stringPairVector; - typedef QMap settingsMap; + using stringPairVector = QVector>; + using settingsMap = QMap; settingsMap m_settings; - friend class LmmsCore; + friend class Engine; }; + + +} // namespace lmms + #endif diff --git a/include/ControlLayout.h b/include/ControlLayout.h index 601820107..8c629f8e1 100644 --- a/include/ControlLayout.h +++ b/include/ControlLayout.h @@ -76,9 +76,15 @@ #include #include #include + class QLayoutItem; class QRect; class QString; +class QLineEdit; + + +namespace lmms::gui +{ /** Layout for controls (models) @@ -128,9 +134,11 @@ private: // relevant dimension is width, as later, heightForWidth() will be called // 400 looks good and is ~4 knobs in a row constexpr const static int m_minWidth = 400; - class QLineEdit* m_searchBar; + QLineEdit* m_searchBar; //! name of search bar, must be ASCII sorted before any alpha numerics static constexpr const char* s_searchBarName = "!!searchBar!!"; }; +} // namespace lmms::gui + #endif // CONTROLLAYOUT_H diff --git a/include/Controller.h b/include/Controller.h index 092c684e0..d949cf90c 100644 --- a/include/Controller.h +++ b/include/Controller.h @@ -33,12 +33,20 @@ #include "JournallingObject.h" #include "ValueBuffer.h" -class ControllerDialog; +namespace lmms +{ + class Controller; class ControllerConnection; -typedef QVector ControllerVector; +namespace gui +{ +class ControllerDialog; + +} // namespace gui + +using ControllerVector = QVector; class LMMS_EXPORT Controller : public Model, public JournallingObject { @@ -60,7 +68,7 @@ public: Controller( ControllerTypes _type, Model * _parent, const QString & _display_name ); - virtual ~Controller(); + ~Controller() override; virtual float currentValue( int _offset ); // The per-controller get-value-in-buffers function @@ -132,7 +140,7 @@ public: bool hasModel( const Model * m ) const; public slots: - virtual ControllerDialog * createDialog( QWidget * _parent ); + virtual gui::ControllerDialog * createDialog( QWidget * _parent ); virtual void setName( const QString & _new_name ) { @@ -169,9 +177,12 @@ signals: // The value changed while the audio engine isn't running (i.e: MIDI CC) void valueChanged(); - friend class ControllerDialog; + friend class gui::ControllerDialog; } ; + +} // namespace lmms + #endif diff --git a/include/ControllerConnection.h b/include/ControllerConnection.h index 68fd2dc89..8230971cc 100644 --- a/include/ControllerConnection.h +++ b/include/ControllerConnection.h @@ -37,10 +37,17 @@ #include "JournallingObject.h" #include "ValueBuffer.h" +namespace lmms +{ + class ControllerConnection; -typedef QVector ControllerConnectionVector; +namespace gui +{ +class ControllerConnectionDialog; +} +using ControllerConnectionVector = QVector; class LMMS_EXPORT ControllerConnection : public QObject, public JournallingObject { @@ -50,7 +57,7 @@ public: ControllerConnection(Controller * _controller); ControllerConnection( int _controllerId ); - virtual ~ControllerConnection(); + ~ControllerConnection() override; inline Controller * getController() { @@ -115,8 +122,11 @@ signals: // The value changed while the audio engine isn't running (i.e: MIDI CC) void valueChanged(); - friend class ControllerConnectionDialog; + friend class gui::ControllerConnectionDialog; }; + +} // namespace lmms + #endif diff --git a/include/ControllerConnectionDialog.h b/include/ControllerConnectionDialog.h index 95e55ce79..5565c8a67 100644 --- a/include/ControllerConnectionDialog.h +++ b/include/ControllerConnectionDialog.h @@ -38,7 +38,15 @@ class QLineEdit; class QListView; class QScrollArea; + +namespace lmms +{ + class AutoDetectMidiController; + +namespace gui +{ + class ComboBox; class GroupBox; class TabWidget; @@ -47,14 +55,13 @@ class LedCheckBox; class MidiPortMenu; - class ControllerConnectionDialog : public QDialog { Q_OBJECT public: ControllerConnectionDialog( QWidget * _parent, const AutomatableModel * _target_model ); - virtual ~ControllerConnectionDialog(); + ~ControllerConnectionDialog() override; Controller * chosenController() { @@ -99,4 +106,9 @@ private: AutoDetectMidiController * m_midiController; } ; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/include/ControllerDialog.h b/include/ControllerDialog.h index 05e8f3bfe..4f496ad77 100644 --- a/include/ControllerDialog.h +++ b/include/ControllerDialog.h @@ -30,8 +30,13 @@ #include "ModelView.h" +namespace lmms +{ + class Controller; +namespace gui +{ class ControllerDialog : public QWidget, public ModelView { @@ -39,7 +44,7 @@ class ControllerDialog : public QWidget, public ModelView public: ControllerDialog( Controller * _controller, QWidget * _parent ); - virtual ~ControllerDialog(); + ~ControllerDialog() override = default; signals: @@ -51,4 +56,9 @@ protected: } ; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/include/ControllerRackView.h b/include/ControllerRackView.h index 9ef2d9b7f..904e523dd 100644 --- a/include/ControllerRackView.h +++ b/include/ControllerRackView.h @@ -36,16 +36,24 @@ class QPushButton; class QScrollArea; class QVBoxLayout; -class ControllerView; + +namespace lmms +{ + class Controller; +namespace gui +{ + +class ControllerView; + class ControllerRackView : public QWidget, public SerializingObject { Q_OBJECT public: ControllerRackView(); - virtual ~ControllerRackView(); + ~ControllerRackView() override = default; void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; void loadSettings( const QDomElement & _this ) override; @@ -57,9 +65,9 @@ public: public slots: - void deleteController( ControllerView * _view ); - void onControllerAdded( Controller * ); - void onControllerRemoved( Controller * ); + void deleteController( lmms::gui::ControllerView * _view ); + void onControllerAdded( lmms::Controller * ); + void onControllerRemoved( lmms::Controller * ); protected: void closeEvent( QCloseEvent * _ce ) override; @@ -80,4 +88,8 @@ private: int m_nextIndex; } ; +} // namespace gui + +} // namespace lmms + #endif diff --git a/include/ControllerView.h b/include/ControllerView.h index d1284845e..8b8db0674 100644 --- a/include/ControllerView.h +++ b/include/ControllerView.h @@ -36,6 +36,10 @@ class QLabel; class QPushButton; class QMdiSubWindow; +namespace lmms::gui +{ + + class LedCheckBox; @@ -44,7 +48,7 @@ class ControllerView : public QFrame, public ModelView Q_OBJECT public: ControllerView( Controller * _controller, QWidget * _parent ); - virtual ~ControllerView(); + ~ControllerView() override; inline Controller * getController() { @@ -64,7 +68,7 @@ public slots: void renameController(); signals: - void deleteController( ControllerView * _view ); + void deleteController( lmms::gui::ControllerView * _view ); protected: @@ -81,4 +85,7 @@ private: } ; + +} // namespace lmms::gui + #endif diff --git a/include/Controls.h b/include/Controls.h index 414258368..9ffed465e 100644 --- a/include/Controls.h +++ b/include/Controls.h @@ -34,8 +34,20 @@ class QString; class QWidget; +class QLabel; + +namespace lmms +{ + class AutomatableModel; +namespace gui +{ + +class AutomatableModelView; +class Knob; +class ComboBox; +class LedCheckBox; /** These classes provide @@ -52,15 +64,15 @@ public: virtual void setModel(AutomatableModel* model) = 0; virtual AutomatableModel* model() = 0; - virtual class AutomatableModelView* modelView() = 0; + virtual AutomatableModelView* modelView() = 0; - virtual ~Control(); + virtual ~Control() = default; }; class KnobControl : public Control { - class Knob* m_knob; + Knob* m_knob; public: void setText(const QString& text) override; @@ -68,18 +80,18 @@ public: void setModel(AutomatableModel* model) override; FloatModel* model() override; - class AutomatableModelView* modelView() override; + AutomatableModelView* modelView() override; KnobControl(QWidget* parent = nullptr); - ~KnobControl() override; + ~KnobControl() override = default; }; class ComboControl : public Control { QWidget* m_widget; - class ComboBox* m_combo; - class QLabel* m_label; + ComboBox* m_combo; + QLabel* m_label; public: void setText(const QString& text) override; @@ -87,10 +99,10 @@ public: void setModel(AutomatableModel* model) override; ComboBoxModel* model() override; - class AutomatableModelView* modelView() override; + AutomatableModelView* modelView() override; ComboControl(QWidget* parent = nullptr); - ~ComboControl() override; + ~ComboControl() override = default; }; @@ -104,17 +116,17 @@ public: void setModel(AutomatableModel* model) override; IntModel* model() override; - class AutomatableModelView* modelView() override; + AutomatableModelView* modelView() override; LcdControl(int numDigits, QWidget* parent = nullptr); - ~LcdControl() override; + ~LcdControl() override = default; }; class CheckControl : public Control { QWidget* m_widget; - class LedCheckBox* m_checkBox; + LedCheckBox* m_checkBox; QLabel* m_label; public: @@ -122,12 +134,16 @@ public: QWidget* topWidget() override; void setModel(AutomatableModel* model) override; - BoolModel *model() override; - class AutomatableModelView* modelView() override; + BoolModel* model() override; + AutomatableModelView* modelView() override; CheckControl(QWidget* parent = nullptr); - ~CheckControl() override; + ~CheckControl() override = default; }; +} // namespace gui + +} // namespace lmms + #endif // CONTROLS_H diff --git a/include/CustomTextKnob.h b/include/CustomTextKnob.h index aa7b9d573..cde718810 100644 --- a/include/CustomTextKnob.h +++ b/include/CustomTextKnob.h @@ -4,6 +4,10 @@ #include "Knob.h" +namespace lmms::gui +{ + + class LMMS_EXPORT CustomTextKnob : public Knob { protected: @@ -21,10 +25,13 @@ public: } private: - virtual QString displayValue() const; + QString displayValue() const override; protected: QString m_value_text; } ; + +} // namespace lmms::gui + #endif diff --git a/include/DataFile.h b/include/DataFile.h index 0600e85d4..fb8b2ae3e 100644 --- a/include/DataFile.h +++ b/include/DataFile.h @@ -33,9 +33,14 @@ #include "lmms_export.h" #include "MemoryManager.h" -class ProjectVersion; class QTextStream; +namespace lmms +{ + +class ProjectVersion; + + class LMMS_EXPORT DataFile : public QDomDocument { MM_OPERATORS @@ -56,13 +61,13 @@ public: MidiClip, TypeCount } ; - typedef Types Type; + using Type = Types; DataFile( const QString& fileName ); DataFile( const QByteArray& data ); DataFile( Type type ); - virtual ~DataFile(); + virtual ~DataFile() = default; /// /// \brief validate @@ -131,21 +136,13 @@ private: static const std::vector UPGRADE_VERSIONS; // Map with DOM elements that access resources (for making bundles) - typedef std::map> ResourcesMap; + using ResourcesMap = std::map>; static const ResourcesMap ELEMENTS_WITH_RESOURCES; void upgrade(); void loadData( const QByteArray & _data, const QString & _sourceFile ); - - struct LMMS_EXPORT typeDescStruct - { - Type m_type; - QString m_name; - } ; - static typeDescStruct s_types[TypeCount]; - QString m_fileName; //!< The origin file name or "" if this DataFile didn't originate from a file QDomElement m_content; QDomElement m_head; @@ -155,4 +152,6 @@ private: } ; +} // namespace lmms + #endif diff --git a/include/Delay.h b/include/Delay.h index 5be1ac183..529577d58 100644 --- a/include/Delay.h +++ b/include/Delay.h @@ -32,6 +32,9 @@ #include "interpolation.h" #include "MemoryManager.h" +namespace lmms +{ + // brief usage // Classes: @@ -63,7 +66,7 @@ template class CombFeedback { public: - typedef double frame[CHANNELS]; + using frame = std::array; CombFeedback( int maxDelay ) : m_size( maxDelay ), @@ -134,7 +137,7 @@ private: template class CombFeedfwd { - typedef double frame[CHANNELS]; + using frame = std::array; CombFeedfwd( int maxDelay ) : m_size( maxDelay ), @@ -205,7 +208,7 @@ private: template class CombFeedbackDualtap { - typedef double frame[CHANNELS]; + using frame = std::array; CombFeedbackDualtap( int maxDelay ) : m_size( maxDelay ), @@ -286,7 +289,7 @@ template class AllpassDelay { public: - typedef double frame[CHANNELS]; + using frame = std::array; AllpassDelay( int maxDelay ) : m_size( maxDelay ), @@ -355,9 +358,11 @@ private: }; // convenience typedefs for stereo effects -typedef CombFeedback<2> StereoCombFeedback; -typedef CombFeedfwd<2> StereoCombFeedfwd; -typedef CombFeedbackDualtap<2> StereoCombFeedbackDualtap; -typedef AllpassDelay<2> StereoAllpassDelay; +using StereoCombFeedback = CombFeedback<2>; +using StereoCombFeedfwd = CombFeedfwd<2>; +using StereoCombFeedbackDualtap = CombFeedbackDualtap<2>; +using StereoAllpassDelay = AllpassDelay<2>; + +} // namespace lmms #endif diff --git a/include/DeprecationHelper.h b/include/DeprecationHelper.h index bef4ea9b9..7786665a3 100644 --- a/include/DeprecationHelper.h +++ b/include/DeprecationHelper.h @@ -30,6 +30,9 @@ #include #include +namespace lmms +{ + /** * @brief horizontalAdvance is a backwards-compatible adapter for * QFontMetrics::horizontalAdvance and width functions. @@ -60,4 +63,7 @@ inline QPoint position(QWheelEvent *wheelEvent) return wheelEvent->pos(); #endif } + +} // namespace lmms + #endif // DEPRECATIONHELPER_H diff --git a/include/DetuningHelper.h b/include/DetuningHelper.h index 2157b6ba8..f90af3697 100644 --- a/include/DetuningHelper.h +++ b/include/DetuningHelper.h @@ -29,6 +29,9 @@ #include "InlineAutomation.h" #include "MemoryManager.h" +namespace lmms +{ + class DetuningHelper : public InlineAutomation { Q_OBJECT @@ -39,9 +42,7 @@ public: { } - virtual ~DetuningHelper() - { - } + ~DetuningHelper() override = default; float defaultValue() const override { @@ -61,4 +62,6 @@ public: } ; +} // namespace lmms + #endif diff --git a/include/DrumSynth.h b/include/DrumSynth.h index f7e9b1d4c..98574f2d2 100644 --- a/include/DrumSynth.h +++ b/include/DrumSynth.h @@ -24,22 +24,25 @@ */ -#ifndef _DRUMSYNTH_H__ -#define _DRUMSYNTH_H__ +#ifndef DRUMSYNTH_H +#define DRUMSYNTH_H #include #include "lmms_basics.h" class QString; +namespace lmms +{ + class DrumSynth { public: - DrumSynth() {}; + DrumSynth() = default; int GetDSFileSamples(QString dsfile, int16_t *&wave, int channels, sample_rate_t Fs); private: - float LoudestEnv(void); - int LongestEnv(void); + float LoudestEnv(); + int LongestEnv(); void UpdateEnv(int e, long t); void GetEnv(int env, const char *sec, const char *key, QString ini); @@ -51,4 +54,7 @@ class DrumSynth { }; -#endif + +} // namespace lmms + +#endif // DRUMSYNTH_H diff --git a/include/DspEffectLibrary.h b/include/DspEffectLibrary.h index bf175df6d..eb03e1cf0 100644 --- a/include/DspEffectLibrary.h +++ b/include/DspEffectLibrary.h @@ -31,14 +31,14 @@ #include "lmms_basics.h" -namespace DspEffectLibrary +namespace lmms::DspEffectLibrary { template class MonoBase { public: - typedef class MonoBypass bypassType; + using bypassType = class MonoBypass; static void process( sample_t * * _buf, const f_cnt_t _frames ) { @@ -53,7 +53,7 @@ namespace DspEffectLibrary class StereoBase { public: - typedef class StereoBypass bypassType; + using bypassType = class StereoBypass; static void process( sample_t * * _buf, const f_cnt_t _frames ) { @@ -164,7 +164,7 @@ namespace DspEffectLibrary class Chain : public FX0::bypassType { public: - typedef typename FX0::sample_t sample_t; + using sample_t = typename FX0::sample_t; Chain( const FX0& fx0, const FX1& fx1 = FX1() ) : m_FX0( fx0 ), m_FX1( fx1 ) @@ -329,7 +329,7 @@ namespace DspEffectLibrary } ; -} ; +} // namespace lmms::DspEffectLibrary #endif diff --git a/include/DummyEffect.h b/include/DummyEffect.h index 6bb8c873e..9db45a3e1 100644 --- a/include/DummyEffect.h +++ b/include/DummyEffect.h @@ -31,6 +31,12 @@ #include "EffectControls.h" #include "EffectControlDialog.h" +namespace lmms +{ + +namespace gui +{ + class Knob; @@ -44,6 +50,7 @@ public: } ; +} // namespace gui class DummyEffectControls : public EffectControls { @@ -53,9 +60,7 @@ public: { } - virtual ~DummyEffectControls() - { - } + ~DummyEffectControls() override = default; int controlCount() override { @@ -75,9 +80,9 @@ public: return "DummyControls"; } - EffectControlDialog * createView() override + gui::EffectControlDialog * createView() override { - return new DummyEffectControlDialog( this ); + return new gui::DummyEffectControlDialog( this ); } } ; @@ -95,9 +100,7 @@ public: setName(); } - virtual ~DummyEffect() - { - } + ~DummyEffect() override = default; EffectControls * controls() override { @@ -144,4 +147,6 @@ private: } ; +} // namespace lmms + #endif diff --git a/include/DummyInstrument.h b/include/DummyInstrument.h index ebfcfbefe..a40d8338f 100644 --- a/include/DummyInstrument.h +++ b/include/DummyInstrument.h @@ -35,6 +35,10 @@ #include "AudioEngine.h" +namespace lmms +{ + + class DummyInstrument : public Instrument { public: @@ -43,9 +47,7 @@ public: { } - virtual ~DummyInstrument() - { - } + ~DummyInstrument() override = default; void playNote( NotePlayHandle *, sampleFrame * buffer ) override { @@ -66,11 +68,13 @@ public: return "dummyinstrument"; } - PluginView * instantiateView( QWidget * _parent ) override + gui::PluginView * instantiateView( QWidget * _parent ) override { - return new InstrumentViewFixedSize( this, _parent ); + return new gui::InstrumentViewFixedSize( this, _parent ); } } ; +} // namespace lmms + #endif diff --git a/include/DummyPlugin.h b/include/DummyPlugin.h index 61a399889..1c763ec3e 100644 --- a/include/DummyPlugin.h +++ b/include/DummyPlugin.h @@ -30,6 +30,9 @@ #include "PluginView.h" +namespace lmms +{ + class DummyPlugin : public Plugin { public: @@ -38,9 +41,7 @@ public: { } - virtual ~DummyPlugin() - { - } + ~DummyPlugin() override = default; void saveSettings( QDomDocument &, QDomElement & ) override { @@ -57,12 +58,14 @@ public: protected: - PluginView * instantiateView( QWidget * _parent ) override + gui::PluginView * instantiateView( QWidget * _parent ) override { - return new PluginView( this, _parent ); + return new gui::PluginView( this, _parent ); } } ; +} // namespace lmms + #endif diff --git a/include/Editor.h b/include/Editor.h index d755608a6..1a39ea72f 100644 --- a/include/Editor.h +++ b/include/Editor.h @@ -28,14 +28,17 @@ #include #include +class QAction; + +namespace lmms::gui +{ + static const int Quantizations[] = { 1, 2, 4, 8, 16, 32, 64, 3, 6, 12, 24, 48, 96, 192 }; -class QAction; - class DropToolBar; /// \brief Superclass for editors with a toolbar. @@ -78,7 +81,7 @@ protected: /// \param record If set true, the editor's toolbar will contain record /// buttons in addition to the play and stop buttons. Editor(bool record = false, bool record_step = false); - virtual ~Editor(); + ~Editor() override = default; DropToolBar* m_toolBar; @@ -108,4 +111,6 @@ protected: }; +} // namespace lmms::gui + #endif diff --git a/include/Effect.h b/include/Effect.h index 6d1fea6bf..add1f7158 100644 --- a/include/Effect.h +++ b/include/Effect.h @@ -33,9 +33,19 @@ #include "TempoSyncKnobModel.h" #include "MemoryManager.h" +namespace lmms +{ + class EffectChain; class EffectControls; +namespace gui +{ + +class EffectView; + +} // namespace gui + class LMMS_EXPORT Effect : public Plugin { @@ -45,7 +55,7 @@ public: Effect( const Plugin::Descriptor * _desc, Model * _parent, const Descriptor::SubPluginFeatures::Key * _key ); - virtual ~Effect(); + ~Effect() override; void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; void loadSettings( const QDomElement & _this ) override; @@ -170,7 +180,7 @@ protected: */ void checkGate( double _out_sum ); - PluginView * instantiateView( QWidget * ) override; + gui::PluginView* instantiateView( QWidget * ) override; // some effects might not be capable of higher sample-rates so they can // sample it down before processing and back after processing @@ -221,14 +231,14 @@ private: SRC_STATE * m_srcState[2]; - friend class EffectView; + friend class gui::EffectView; friend class EffectChain; } ; +using EffectKey = Effect::Descriptor::SubPluginFeatures::Key; +using EffectKeyList = Effect::Descriptor::SubPluginFeatures::KeyList; -typedef Effect::Descriptor::SubPluginFeatures::Key EffectKey; -typedef Effect::Descriptor::SubPluginFeatures::KeyList EffectKeyList; - +} // namespace lmms #endif diff --git a/include/EffectChain.h b/include/EffectChain.h index 9ebc4d534..a9da8e530 100644 --- a/include/EffectChain.h +++ b/include/EffectChain.h @@ -30,15 +30,25 @@ #include "SerializingObject.h" #include "AutomatableModel.h" +namespace lmms +{ + class Effect; +namespace gui +{ + +class EffectRackView; + +} // namespace gui + class LMMS_EXPORT EffectChain : public Model, public SerializingObject { Q_OBJECT public: EffectChain( Model * _parent ); - virtual ~EffectChain(); + ~EffectChain() override; void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; void loadSettings( const QDomElement & _this ) override; @@ -59,13 +69,13 @@ public: private: - typedef QVector EffectList; + using EffectList = QVector; EffectList m_effects; BoolModel m_enabledModel; - friend class EffectRackView; + friend class gui::EffectRackView; signals: @@ -73,5 +83,7 @@ signals: } ; +} // namespace lmms + #endif diff --git a/include/EffectControlDialog.h b/include/EffectControlDialog.h index 4a59489da..6389db4a3 100644 --- a/include/EffectControlDialog.h +++ b/include/EffectControlDialog.h @@ -30,15 +30,21 @@ #include "ModelView.h" +namespace lmms +{ + class EffectControls; +namespace gui +{ + class LMMS_EXPORT EffectControlDialog : public QWidget, public ModelView { Q_OBJECT public: EffectControlDialog( EffectControls * _controls ); - virtual ~EffectControlDialog(); + ~EffectControlDialog() override = default; virtual bool isResizable() const {return false;} @@ -54,4 +60,8 @@ protected: } ; +} // namespace gui + +} // namespace lmms + #endif diff --git a/include/EffectControls.h b/include/EffectControls.h index 6af7a7d6c..994145a40 100644 --- a/include/EffectControls.h +++ b/include/EffectControls.h @@ -29,8 +29,16 @@ #include "JournallingObject.h" #include "Effect.h" +namespace lmms +{ + + +namespace gui +{ + class EffectControlDialog; +} // namespace gui class EffectControls : public JournallingObject, public Model { @@ -43,12 +51,10 @@ public: { } - virtual ~EffectControls() - { - } + ~EffectControls() override = default; virtual int controlCount() = 0; - virtual EffectControlDialog * createView() = 0; + virtual gui::EffectControlDialog * createView() = 0; void setViewVisible( bool _visible ) @@ -73,4 +79,7 @@ private: } ; + +} // namespace lmms + #endif diff --git a/include/EffectRackView.h b/include/EffectRackView.h index b590d8eb1..fb68fda68 100644 --- a/include/EffectRackView.h +++ b/include/EffectRackView.h @@ -35,6 +35,9 @@ class QScrollArea; class QVBoxLayout; +namespace lmms::gui +{ + class EffectView; class GroupBox; @@ -44,15 +47,15 @@ class EffectRackView : public QWidget, public ModelView Q_OBJECT public: EffectRackView( EffectChain* model, QWidget* parent = nullptr ); - virtual ~EffectRackView(); + ~EffectRackView() override; static constexpr int DEFAULT_WIDTH = 245; public slots: void clearViews(); - void moveUp( EffectView* view ); - void moveDown( EffectView* view ); - void deletePlugin( EffectView* view ); + void moveUp( lmms::gui::EffectView* view ); + void moveDown( lmms::gui::EffectView* view ); + void deletePlugin( lmms::gui::EffectView* view ); private slots: @@ -83,4 +86,6 @@ private: } ; +} // namespace lmms::gui + #endif diff --git a/include/EffectSelectDialog.h b/include/EffectSelectDialog.h index 19e0ca05f..b0acfb734 100644 --- a/include/EffectSelectDialog.h +++ b/include/EffectSelectDialog.h @@ -34,13 +34,16 @@ namespace Ui { class EffectSelectDialog; } +namespace lmms::gui +{ + class EffectSelectDialog : public QDialog { Q_OBJECT public: EffectSelectDialog( QWidget * _parent ); - virtual ~EffectSelectDialog(); + ~EffectSelectDialog() override; Effect * instantiateSelectedPlugin( EffectChain * _parent ); @@ -65,5 +68,7 @@ private: } ; +} // namespace lmms::gui + #endif diff --git a/include/EffectView.h b/include/EffectView.h index a2509dc5b..90bb54896 100644 --- a/include/EffectView.h +++ b/include/EffectView.h @@ -35,6 +35,9 @@ class QLabel; class QPushButton; class QMdiSubWindow; +namespace lmms::gui +{ + class EffectControlDialog; class Knob; class LedCheckBox; @@ -46,7 +49,7 @@ class EffectView : public PluginView Q_OBJECT public: EffectView( Effect * _model, QWidget * _parent ); - virtual ~EffectView(); + ~EffectView() override; inline Effect * effect() { @@ -68,9 +71,9 @@ public slots: signals: - void moveUp( EffectView * _plugin ); - void moveDown( EffectView * _plugin ); - void deletePlugin( EffectView * _plugin ); + void moveUp( lmms::gui::EffectView * _plugin ); + void moveDown( lmms::gui::EffectView * _plugin ); + void deletePlugin( lmms::gui::EffectView * _plugin ); protected: @@ -90,4 +93,7 @@ private: } ; + +} // namespace lmms::gui + #endif diff --git a/include/Engine.h b/include/Engine.h index 531e24220..b63308cde 100644 --- a/include/Engine.h +++ b/include/Engine.h @@ -34,6 +34,9 @@ #include "lmms_export.h" #include "lmms_basics.h" +namespace lmms +{ + class AudioEngine; class Mixer; class PatternStore; @@ -41,20 +44,13 @@ class ProjectJournal; class Song; class Ladspa2LMMS; +namespace gui +{ +class GuiApplication; +} -// Note: This class is called 'LmmsCore' instead of 'Engine' because of naming -// conflicts caused by ZynAddSubFX. See https://github.com/LMMS/lmms/issues/2269 -// and https://github.com/LMMS/lmms/pull/2118 for more details. -// -// The workaround was to rename Lmms' Engine so that it has a different symbol -// name in the object files, but typedef it back to 'Engine' and keep it inside -// of Engine.h so that the rest of the codebase can be oblivious to this issue -// (and it could be fixed without changing every single file). -class LmmsCore; -typedef LmmsCore Engine; - -class LMMS_EXPORT LmmsCore : public QObject +class LMMS_EXPORT Engine : public QObject { Q_OBJECT public: @@ -110,11 +106,11 @@ public: static void updateFramesPerTick(); - static inline LmmsCore * inst() + static inline Engine * inst() { if( s_instanceOfMe == nullptr ) { - s_instanceOfMe = new LmmsCore(); + s_instanceOfMe = new Engine(); } return s_instanceOfMe; } @@ -130,9 +126,9 @@ private: // small helper function which sets the pointer to NULL before actually deleting // the object it refers to template - static inline void deleteHelper( T * * ptr ) + static inline void deleteHelper(T** ptr) { - T * tmp = *ptr; + T* tmp = *ptr; *ptr = nullptr; delete tmp; } @@ -149,15 +145,17 @@ private: #ifdef LMMS_HAVE_LV2 static class Lv2Manager* s_lv2Manager; #endif - static Ladspa2LMMS * s_ladspaManager; + static Ladspa2LMMS* s_ladspaManager; static void* s_dndPluginKey; // even though most methods are static, an instance is needed for Qt slots/signals - static LmmsCore * s_instanceOfMe; + static Engine* s_instanceOfMe; - friend class GuiApplication; + friend class gui::GuiApplication; }; +} // namespace lmms + #endif diff --git a/include/EnvelopeAndLfoParameters.h b/include/EnvelopeAndLfoParameters.h index 42502800e..534adcbe5 100644 --- a/include/EnvelopeAndLfoParameters.h +++ b/include/EnvelopeAndLfoParameters.h @@ -33,6 +33,15 @@ #include "TempoSyncKnobModel.h" #include "lmms_basics.h" +namespace lmms +{ + +namespace gui +{ + +class EnvelopeAndLfoView; + +} class LMMS_EXPORT EnvelopeAndLfoParameters : public Model, public JournallingObject { @@ -41,13 +50,9 @@ public: class LfoInstances { public: - LfoInstances() - { - } + LfoInstances() = default; - ~LfoInstances() - { - } + ~LfoInstances() = default; inline bool isEmpty() const { @@ -62,14 +67,14 @@ public: private: QMutex m_lfoListMutex; - typedef QList LfoList; + using LfoList = QList; LfoList m_lfos; } ; EnvelopeAndLfoParameters( float _value_for_zero_amount, Model * _parent ); - virtual ~EnvelopeAndLfoParameters(); + ~EnvelopeAndLfoParameters() override; static inline float expKnobVal( float _val ) { @@ -179,8 +184,10 @@ private: void updateLfoShapeData(); - friend class EnvelopeAndLfoView; + friend class gui::EnvelopeAndLfoView; } ; +} // namespace lmms + #endif diff --git a/include/EnvelopeAndLfoView.h b/include/EnvelopeAndLfoView.h index f6d4fd0a8..a82ccf606 100644 --- a/include/EnvelopeAndLfoView.h +++ b/include/EnvelopeAndLfoView.h @@ -33,8 +33,14 @@ class QPaintEvent; class QPixmap; +namespace lmms +{ + class EnvelopeAndLfoParameters; +namespace gui +{ + class automatableButtonGroup; class Knob; class LedCheckBox; @@ -48,7 +54,7 @@ class EnvelopeAndLfoView : public QWidget, public ModelView Q_OBJECT public: EnvelopeAndLfoView( QWidget * _parent ); - virtual ~EnvelopeAndLfoView(); + ~EnvelopeAndLfoView() override; protected: @@ -94,4 +100,8 @@ private: float m_randomGraph; } ; +} // namespace gui + +} // namespace lmms + #endif diff --git a/include/ExportFilter.h b/include/ExportFilter.h index e60faef3a..29efef539 100644 --- a/include/ExportFilter.h +++ b/include/ExportFilter.h @@ -32,11 +32,15 @@ #include "Plugin.h" +namespace lmms +{ + + class LMMS_EXPORT ExportFilter : public Plugin { public: ExportFilter( const Descriptor * _descriptor ) : Plugin( _descriptor, nullptr ) {} - virtual ~ExportFilter() {} + ~ExportFilter() override = default; virtual bool tryExport(const TrackContainer::TrackList &tracks, @@ -63,4 +67,6 @@ private: } ; +} // namespace lmms + #endif diff --git a/include/ExportProjectDialog.h b/include/ExportProjectDialog.h index 06c1e3011..56d039afe 100644 --- a/include/ExportProjectDialog.h +++ b/include/ExportProjectDialog.h @@ -34,6 +34,10 @@ #include "ProjectRenderer.h" #include "RenderManager.h" +namespace lmms::gui +{ + + class ExportProjectDialog : public QDialog, public Ui::ExportProjectDialog { Q_OBJECT @@ -41,12 +45,12 @@ public: ExportProjectDialog( const QString & _file_name, QWidget * _parent, bool multi_export ); protected: - void reject( void ) override; + void reject() override; void closeEvent( QCloseEvent * _ce ) override; private slots: - void startBtnClicked( void ); + void startBtnClicked(); void updateTitleBar( int ); void accept() override; void startExport(); @@ -63,4 +67,8 @@ private: std::unique_ptr m_renderManager; } ; + +} // namespace lmms::gui + + #endif diff --git a/include/FadeButton.h b/include/FadeButton.h index dfffe93a2..d33900913 100644 --- a/include/FadeButton.h +++ b/include/FadeButton.h @@ -31,6 +31,10 @@ #include +namespace lmms::gui +{ + + class FadeButton : public QAbstractButton { Q_OBJECT @@ -40,7 +44,7 @@ public: const QColor & _hold_color, QWidget * _parent ); - virtual ~FadeButton(); + ~FadeButton() override = default; void setActiveColor( const QColor & activated_color ); @@ -71,4 +75,6 @@ private: } ; +} // namespace lmms::gui + #endif diff --git a/include/Fader.h b/include/Fader.h index 86d7f0b96..54acfc57d 100644 --- a/include/Fader.h +++ b/include/Fader.h @@ -55,6 +55,9 @@ #include "AutomatableModelView.h" +namespace lmms::gui +{ + class TextFloat; @@ -69,7 +72,7 @@ public: Fader( FloatModel * _model, const QString & _name, QWidget * _parent ); Fader( FloatModel * _model, const QString & _name, QWidget * _parent, QPixmap * back, QPixmap * leds, QPixmap * knob ); - virtual ~Fader() = default; + ~Fader() override = default; void init(FloatModel * model, QString const & name); @@ -169,4 +172,7 @@ private: } ; +} // namespace lmms::gui + + #endif diff --git a/include/FifoBuffer.h b/include/FifoBuffer.h index 5bbf8b702..d49e367c0 100644 --- a/include/FifoBuffer.h +++ b/include/FifoBuffer.h @@ -28,6 +28,10 @@ #include +namespace lmms +{ + + template class FifoBuffer { @@ -88,4 +92,6 @@ private: } ; +} // namespace lmms + #endif diff --git a/include/FileBrowser.h b/include/FileBrowser.h index d99c619e9..43a0b3331 100644 --- a/include/FileBrowser.h +++ b/include/FileBrowser.h @@ -29,6 +29,9 @@ #include #include #include +#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0)) + #include +#endif #include @@ -37,13 +40,18 @@ class QLineEdit; -class FileItem; +namespace lmms +{ + class InstrumentTrack; -class FileBrowserTreeWidget; class PlayHandle; class TrackContainer; +namespace gui +{ +class FileItem; +class FileBrowserTreeWidget; class FileBrowser : public SideBarWidget { @@ -63,10 +71,10 @@ public: const QString& userDir = "", const QString& factoryDir = ""); - virtual ~FileBrowser() = default; + ~FileBrowser() override = default; private slots: - void reloadTree( void ); + void reloadTree(); void expandItems( QTreeWidgetItem * item=nullptr, QList expandedDirs = QList() ); // call with item=NULL to filter the entire tree bool filterItems( const QString & filter, QTreeWidgetItem * item=nullptr ); @@ -102,7 +110,7 @@ class FileBrowserTreeWidget : public QTreeWidget Q_OBJECT public: FileBrowserTreeWidget( QWidget * parent ); - virtual ~FileBrowserTreeWidget() = default; + ~FileBrowserTreeWidget() override = default; //! This method returns a QList with paths (QString's) of all directories //! that are expanded in the tree. @@ -135,18 +143,23 @@ private: //! This should only be accessed or modified when m_pphMutex is held PlayHandle* m_previewPlayHandle; + +#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0)) + QRecursiveMutex m_pphMutex; +#else QMutex m_pphMutex; +#endif QList getContextActions(FileItem* item, bool songEditor); private slots: void activateListItem( QTreeWidgetItem * item, int column ); - void openInNewInstrumentTrack( FileItem* item, bool songEditor ); - bool openInNewSampleTrack( FileItem* item ); - void sendToActiveInstrumentTrack( FileItem* item ); + void openInNewInstrumentTrack( lmms::gui::FileItem* item, bool songEditor ); + bool openInNewSampleTrack( lmms::gui::FileItem* item ); + void sendToActiveInstrumentTrack( lmms::gui::FileItem* item ); void updateDirectory( QTreeWidgetItem * item ); - void openContainingFolder( FileItem* item ); + void openContainingFolder( lmms::gui::FileItem* item ); } ; @@ -159,7 +172,7 @@ public: Directory( const QString & filename, const QString & path, const QString & filter ); - void update( void ); + void update(); inline QString fullName( QString path = QString() ) { @@ -182,7 +195,7 @@ public: private: - void initPixmaps( void ); + void initPixmaps(); bool addItems( const QString & path ); @@ -243,28 +256,28 @@ public: return QFileInfo(m_path, text(0)).absoluteFilePath(); } - inline FileTypes type( void ) const + inline FileTypes type() const { return( m_type ); } - inline FileHandling handling( void ) const + inline FileHandling handling() const { return( m_handling ); } - inline bool isTrack( void ) const + inline bool isTrack() const { return m_handling == LoadAsPreset || m_handling == LoadByPlugin; } - QString extension( void ); + QString extension(); static QString extension( const QString & file ); private: - void initPixmaps( void ); - void determineFileType( void ); + void initPixmaps(); + void determineFileType(); static QPixmap * s_projectFilePixmap; static QPixmap * s_presetFilePixmap; @@ -281,4 +294,8 @@ private: } ; +} // namespace gui + +} // namespace lmms + #endif diff --git a/include/FileDialog.h b/include/FileDialog.h index 6e29703b8..ed5d2f231 100644 --- a/include/FileDialog.h +++ b/include/FileDialog.h @@ -30,6 +30,10 @@ #include "lmms_export.h" +namespace lmms::gui +{ + + class LMMS_EXPORT FileDialog : public QFileDialog { Q_OBJECT @@ -50,4 +54,7 @@ public: void clearSelection(); }; -#endif // FILEDIALOG_HPP + +} // namespace lmms::gui + +#endif // FILEDIALOG_H diff --git a/include/Graph.h b/include/Graph.h index 2a6fc4f8a..178d1b567 100644 --- a/include/Graph.h +++ b/include/Graph.h @@ -35,8 +35,15 @@ #include "ModelView.h" #include "lmms_basics.h" +namespace lmms +{ + + class graphModel; +namespace gui +{ + class LMMS_EXPORT Graph : public QWidget, public ModelView { @@ -60,7 +67,7 @@ public: int _width = 132, int _height = 104 ); - virtual ~Graph() = default; + ~Graph() override = default; void setForeground( const QPixmap & _pixmap ); @@ -116,6 +123,9 @@ private: } ; +} // namespace gui + + /** @brief 2 dimensional function plot @@ -137,11 +147,11 @@ public: graphModel( float _min, float _max, int _size, - :: Model * _parent, + Model * _parent, bool _default_constructed = false, float _step = 0.0 ); - virtual ~graphModel() = default; + ~graphModel() override = default; // TODO: saveSettings, loadSettings? @@ -187,7 +197,7 @@ public slots: void setWaveToSaw(); void setWaveToSquare(); void setWaveToNoise(); - QString setWaveToUser( ); + QString setWaveToUser(); void smooth(); void smoothNonCyclic(); @@ -211,8 +221,11 @@ private: float m_maxValue; float m_step; - friend class Graph; + friend class gui::Graph; }; + +} // namespace lmms + #endif diff --git a/include/Groove.h b/include/Groove.h index 75d419e57..5750dfcb8 100644 --- a/include/Groove.h +++ b/include/Groove.h @@ -35,6 +35,9 @@ #include "MidiClip.h" #include "SerializingObject.h" +namespace lmms +{ + class Groove : public QObject, public SerializingObject { Q_OBJECT @@ -80,4 +83,6 @@ protected: float m_swingFactor; // = (m_amount / 127) }; +} // namespace lmms + #endif // GROOVE_H diff --git a/include/GrooveExperiments.h b/include/GrooveExperiments.h index 28621d963..a9328fc47 100644 --- a/include/GrooveExperiments.h +++ b/include/GrooveExperiments.h @@ -10,6 +10,9 @@ #include "Note.h" #include "MidiClip.h" +namespace lmms +{ + /** * A groove thats new */ @@ -42,6 +45,10 @@ private: int m_framesPerTick; } ; + +namespace gui +{ + class GrooveExperimentsView : public QWidget { Q_OBJECT @@ -60,4 +67,8 @@ private: } ; +} // namespace gui + +} // namespace lmms + #endif // GROOVEEXPERIMENTS_H diff --git a/include/GrooveFactory.h b/include/GrooveFactory.h index 4c6ecf40a..483764530 100644 --- a/include/GrooveFactory.h +++ b/include/GrooveFactory.h @@ -28,6 +28,9 @@ #include "Groove.h" +namespace lmms +{ + class GrooveFactory { @@ -38,4 +41,6 @@ private: GrooveFactory(); }; +} // namespace lmms + #endif // GROOVEFACTORY_H diff --git a/include/GrooveView.h b/include/GrooveView.h index 74476cc85..1e29d273f 100644 --- a/include/GrooveView.h +++ b/include/GrooveView.h @@ -10,6 +10,9 @@ #include "Groove.h" #include "SerializingObject.h" +namespace lmms::gui +{ + class GrooveView : public QWidget { Q_OBJECT @@ -32,4 +35,6 @@ private: QComboBox * m_comboBox; }; +} // namespace lmms + #endif // GROOVEVIEW_H diff --git a/include/GroupBox.h b/include/GroupBox.h index 77b0ec578..e20db80a6 100644 --- a/include/GroupBox.h +++ b/include/GroupBox.h @@ -34,13 +34,15 @@ class QPixmap; +namespace lmms::gui +{ class GroupBox : public QWidget, public BoolModelView { Q_OBJECT public: GroupBox( const QString & _caption, QWidget * _parent = nullptr ); - virtual ~GroupBox(); + ~GroupBox() override; void modelChanged() override; @@ -70,6 +72,7 @@ private: } ; +} // namespace lmms::gui #endif diff --git a/include/GuiApplication.h b/include/GuiApplication.h index 562358eeb..e0b535240 100644 --- a/include/GuiApplication.h +++ b/include/GuiApplication.h @@ -32,6 +32,9 @@ class QLabel; +namespace lmms::gui +{ + class AutomationEditorWindow; class ControllerRackView; class GrooveView; @@ -48,7 +51,7 @@ class LMMS_EXPORT GuiApplication : public QObject Q_OBJECT; public: explicit GuiApplication(); - ~GuiApplication(); + ~GuiApplication() override; static GuiApplication* instance(); #ifdef LMMS_BUILD_WIN32 @@ -91,4 +94,6 @@ private: // Short-hand function LMMS_EXPORT GuiApplication* getGUI(); +} // namespace lmms::gui + #endif // GUIAPPLICATION_H diff --git a/include/HalfSwing.h b/include/HalfSwing.h index bb1ad2775..c25571fae 100644 --- a/include/HalfSwing.h +++ b/include/HalfSwing.h @@ -10,6 +10,9 @@ #include "Note.h" #include "MidiClip.h" +namespace lmms +{ + /** * A groove thatjust latter half of the HydrogenSwing algo. */ @@ -40,6 +43,10 @@ private: int m_framesPerTick; } ; + +namespace gui +{ + class HalfSwingView : public QWidget { Q_OBJECT @@ -58,4 +65,8 @@ private: } ; +} // namespace gui + +} // namespace lmms + #endif // HALFSWING_H diff --git a/include/HydrogenSwing.h b/include/HydrogenSwing.h index 5dd12877c..11cf470ec 100644 --- a/include/HydrogenSwing.h +++ b/include/HydrogenSwing.h @@ -10,6 +10,9 @@ #include "Note.h" #include "MidiClip.h" +namespace lmms +{ + /** * A groove that mimics Hydrogen drum machine's swing feature */ @@ -42,6 +45,10 @@ private: int m_framesPerTick; } ; + +namespace gui +{ + class HydrogenSwingView : public QWidget { Q_OBJECT @@ -60,4 +67,8 @@ private: } ; +} // namespace gui + +} // namespace lmms + #endif // HYDROGENSWING_H diff --git a/include/ImportFilter.h b/include/ImportFilter.h index ef58cce24..b7a910e5d 100644 --- a/include/ImportFilter.h +++ b/include/ImportFilter.h @@ -30,6 +30,9 @@ #include "Plugin.h" +namespace lmms +{ + class TrackContainer; @@ -39,7 +42,7 @@ class LMMS_EXPORT ImportFilter : public Plugin public: ImportFilter( const QString & _file_name, const Descriptor * _descriptor ); - virtual ~ImportFilter(); + ~ImportFilter() override = default; // tries to import given file to given track-container by having all @@ -109,4 +112,6 @@ private: } ; +} // namespace lmms + #endif diff --git a/include/InlineAutomation.h b/include/InlineAutomation.h index 1ce486fde..435604506 100644 --- a/include/InlineAutomation.h +++ b/include/InlineAutomation.h @@ -29,6 +29,8 @@ #include "AutomationClip.h" #include "shared_object.h" +namespace lmms +{ class InlineAutomation : public FloatModel, public sharedObject { @@ -40,7 +42,7 @@ public: { } - virtual ~InlineAutomation() + ~InlineAutomation() override { if( m_autoClip ) { @@ -95,4 +97,6 @@ private: } ; +} // namespace lmms + #endif diff --git a/include/Instrument.h b/include/Instrument.h index c3cd56272..4e48e2fd6 100644 --- a/include/Instrument.h +++ b/include/Instrument.h @@ -33,6 +33,8 @@ #include "Plugin.h" #include "TimePos.h" +namespace lmms +{ // forward-declarations class InstrumentTrack; @@ -58,7 +60,7 @@ public: Instrument(InstrumentTrack * _instrument_track, const Descriptor * _descriptor, const Descriptor::SubPluginFeatures::Key * key = nullptr); - virtual ~Instrument() = default; + ~Instrument() override = default; // -------------------------------------------------------------------- // functions that can/should be re-implemented: @@ -146,6 +148,10 @@ private: } ; + Q_DECLARE_OPERATORS_FOR_FLAGS(Instrument::Flags) + +} // namespace lmms + #endif diff --git a/include/InstrumentFunctionViews.h b/include/InstrumentFunctionViews.h index 6536a8db7..99ba92031 100644 --- a/include/InstrumentFunctionViews.h +++ b/include/InstrumentFunctionViews.h @@ -30,22 +30,27 @@ #include class QLabel; -class ComboBox; -class GroupBox; -class Knob; -class TempoSyncKnob; + +namespace lmms +{ class InstrumentFunctionArpeggio; class InstrumentFunctionNoteStacking; +namespace gui +{ +class ComboBox; +class GroupBox; +class Knob; +class TempoSyncKnob; class InstrumentFunctionNoteStackingView : public QWidget, public ModelView { Q_OBJECT public: InstrumentFunctionNoteStackingView( InstrumentFunctionNoteStacking* cc, QWidget* parent = nullptr ); - virtual ~InstrumentFunctionNoteStackingView(); + ~InstrumentFunctionNoteStackingView() override; private: @@ -68,7 +73,7 @@ class InstrumentFunctionArpeggioView : public QWidget, public ModelView Q_OBJECT public: InstrumentFunctionArpeggioView( InstrumentFunctionArpeggio* arp, QWidget* parent = nullptr ); - virtual ~InstrumentFunctionArpeggioView(); + ~InstrumentFunctionArpeggioView() override; private: @@ -90,5 +95,8 @@ private: } ; +} // namespace gui + +} // namespace lmms #endif diff --git a/include/InstrumentFunctions.h b/include/InstrumentFunctions.h index e1591ea27..5dcb1114b 100644 --- a/include/InstrumentFunctions.h +++ b/include/InstrumentFunctions.h @@ -31,10 +31,19 @@ #include "TempoSyncKnobModel.h" #include "ComboBoxModel.h" +namespace lmms +{ class InstrumentTrack; class NotePlayHandle; +namespace gui +{ + +class InstrumentFunctionNoteStackingView; +class InstrumentFunctionArpeggioView; + +} class InstrumentFunctionNoteStacking : public Model, public JournallingObject @@ -43,13 +52,14 @@ class InstrumentFunctionNoteStacking : public Model, public JournallingObject public: static const int MAX_CHORD_POLYPHONY = 13; + static const int NUM_CHORD_TABLES = 95; private: - typedef int8_t ChordSemiTones [MAX_CHORD_POLYPHONY]; + using ChordSemiTones = std::array; public: InstrumentFunctionNoteStacking( Model * _parent ); - virtual ~InstrumentFunctionNoteStacking(); + ~InstrumentFunctionNoteStacking() override = default; void processNote( NotePlayHandle* n ); @@ -120,7 +130,7 @@ public: ChordSemiTones m_semiTones; }; - static Init s_initTable[]; + static std::array s_initTable; public: static const ChordTable & getInstance() @@ -149,7 +159,7 @@ private: FloatModel m_chordRangeModel; - friend class InstrumentFunctionNoteStackingView; + friend class gui::InstrumentFunctionNoteStackingView; } ; @@ -171,7 +181,7 @@ public: } ; InstrumentFunctionArpeggio( Model * _parent ); - virtual ~InstrumentFunctionArpeggio(); + ~InstrumentFunctionArpeggio() override = default; void processNote( NotePlayHandle* n ); @@ -207,9 +217,11 @@ private: friend class InstrumentTrack; - friend class InstrumentFunctionArpeggioView; + friend class gui::InstrumentFunctionArpeggioView; } ; +} // namespace lmms + #endif diff --git a/include/InstrumentMidiIOView.h b/include/InstrumentMidiIOView.h index 0530003dd..1a5cd3d19 100644 --- a/include/InstrumentMidiIOView.h +++ b/include/InstrumentMidiIOView.h @@ -30,12 +30,19 @@ #include "ModelView.h" +class QToolButton; + +namespace lmms +{ + +class InstrumentTrack; + +namespace gui +{ class GroupBox; class LcdSpinBox; -class QToolButton; class LedCheckBox; -class InstrumentTrack; class InstrumentMidiIOView : public QWidget, public ModelView @@ -43,7 +50,7 @@ class InstrumentMidiIOView : public QWidget, public ModelView Q_OBJECT public: InstrumentMidiIOView( QWidget* parent ); - virtual ~InstrumentMidiIOView(); + ~InstrumentMidiIOView() override = default; private: @@ -64,4 +71,9 @@ private: LcdSpinBox* m_baseVelocitySpinBox; }; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/include/InstrumentMiscView.h b/include/InstrumentMiscView.h index d04b5ddcc..758220ac4 100644 --- a/include/InstrumentMiscView.h +++ b/include/InstrumentMiscView.h @@ -29,9 +29,16 @@ #include +namespace lmms +{ + +class InstrumentTrack; + +namespace gui +{ + class ComboBox; class GroupBox; -class InstrumentTrack; class LedCheckBox; @@ -64,4 +71,9 @@ private: GroupBox * m_grooveGroupBox; }; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/include/InstrumentPlayHandle.h b/include/InstrumentPlayHandle.h index ac5fc3222..e9516ab19 100644 --- a/include/InstrumentPlayHandle.h +++ b/include/InstrumentPlayHandle.h @@ -30,14 +30,15 @@ #include "NotePlayHandle.h" #include "lmms_export.h" +namespace lmms +{ + class LMMS_EXPORT InstrumentPlayHandle : public PlayHandle { public: InstrumentPlayHandle( Instrument * instrument, InstrumentTrack* instrumentTrack ); - virtual ~InstrumentPlayHandle() - { - } + ~InstrumentPlayHandle() override = default; void play( sampleFrame * _working_buffer ) override @@ -81,4 +82,7 @@ private: } ; + +} // namespace lmms + #endif diff --git a/include/InstrumentSoundShaping.h b/include/InstrumentSoundShaping.h index b037f615a..11ed4f1c4 100644 --- a/include/InstrumentSoundShaping.h +++ b/include/InstrumentSoundShaping.h @@ -27,18 +27,26 @@ #include "ComboBoxModel.h" +namespace lmms +{ + class InstrumentTrack; class EnvelopeAndLfoParameters; class NotePlayHandle; +namespace gui +{ +class InstrumentSoundShapingView; +} + class InstrumentSoundShaping : public Model, public JournallingObject { Q_OBJECT public: InstrumentSoundShaping( InstrumentTrack * _instrument_track ); - virtual ~InstrumentSoundShaping(); + ~InstrumentSoundShaping() override = default; void processAudioBuffer( sampleFrame * _ab, const fpp_t _frames, NotePlayHandle * _n ); @@ -77,9 +85,11 @@ private: static const char *const targetNames[InstrumentSoundShaping::NumTargets][3]; - friend class InstrumentSoundShapingView; + friend class gui::InstrumentSoundShapingView; } ; +} // namespace lmms + #endif diff --git a/include/InstrumentSoundShapingView.h b/include/InstrumentSoundShapingView.h index 06d53232c..aa8aff19d 100644 --- a/include/InstrumentSoundShapingView.h +++ b/include/InstrumentSoundShapingView.h @@ -32,6 +32,9 @@ class QLabel; +namespace lmms::gui +{ + class EnvelopeAndLfoView; class ComboBox; class GroupBox; @@ -44,7 +47,7 @@ class InstrumentSoundShapingView : public QWidget, public ModelView Q_OBJECT public: InstrumentSoundShapingView( QWidget * _parent ); - virtual ~InstrumentSoundShapingView(); + ~InstrumentSoundShapingView() override; void setFunctionsHidden( bool hidden ); @@ -67,4 +70,7 @@ private: } ; + +} // namespace lmms::gui + #endif diff --git a/include/InstrumentTrack.h b/include/InstrumentTrack.h index c183a6f2d..02fa8c297 100644 --- a/include/InstrumentTrack.h +++ b/include/InstrumentTrack.h @@ -40,9 +40,23 @@ #include "Track.h" +namespace lmms +{ + + class Instrument; class DataFile; +namespace gui +{ + +class InstrumentTrackView; +class InstrumentTrackWindow; +class InstrumentMiscView; +class MidiCCRackView; + +} // namespace gui + class LMMS_EXPORT InstrumentTrack : public Track, public MidiEventProcessor { @@ -51,7 +65,7 @@ class LMMS_EXPORT InstrumentTrack : public Track, public MidiEventProcessor mapPropertyFromModel(int,getVolume,setVolume,m_volumeModel); public: InstrumentTrack( TrackContainer* tc ); - virtual ~InstrumentTrack(); + ~InstrumentTrack() override; // used by instrument void processAudioBuffer( sampleFrame * _buf, const fpp_t _frames, @@ -111,17 +125,17 @@ public: } // play everything in given frame-range - creates note-play-handles - virtual bool play( const TimePos & _start, const fpp_t _frames, + bool play( const TimePos & _start, const fpp_t _frames, const f_cnt_t _frame_base, int _clip_num = -1 ) override; // create new view for me - TrackView * createView( TrackContainerView* tcv ) override; + gui::TrackView* createView( gui::TrackContainerView* tcv ) override; // create new track-content-object = clip Clip* createClip(const TimePos & pos) override; // called by track - virtual void saveTrackSpecificSettings( QDomDocument & _doc, + void saveTrackSpecificSettings( QDomDocument & _doc, QDomElement & _parent ) override; void loadTrackSpecificSettings( const QDomElement & _this ) override; @@ -215,6 +229,11 @@ public: return &m_mixerChannelModel; } + BoolModel* useMasterPitchModel() + { + return &m_useMasterPitchModel; + } + void setPreviewMode( const bool ); bool isPreviewMode() const @@ -228,8 +247,8 @@ public: signals: void instrumentChanged(); - void midiNoteOn( const Note& ); - void midiNoteOff( const Note& ); + void midiNoteOn( const lmms::Note& ); + void midiNoteOff( const lmms::Note& ); void nameChanged(); void newNote(); void endNote(); @@ -305,15 +324,18 @@ private: std::unique_ptr m_midiCCEnable; std::unique_ptr m_midiCCModel[MidiControllerCount]; - - friend class InstrumentTrackView; - friend class InstrumentTrackWindow; + friend class gui::InstrumentTrackView; + friend class gui::InstrumentTrackWindow; friend class NotePlayHandle; - friend class InstrumentMiscView; - friend class MidiCCRackView; + friend class gui::InstrumentMiscView; + friend class gui::MidiCCRackView; private slots: void updateGroove(); }; + + +} // namespace lmms + #endif diff --git a/include/InstrumentTrackView.h b/include/InstrumentTrackView.h index d863d6c19..3201f81d6 100644 --- a/include/InstrumentTrackView.h +++ b/include/InstrumentTrackView.h @@ -30,6 +30,10 @@ #include "InstrumentTrack.h" +namespace lmms::gui +{ + + class InstrumentTrackWindow; class Knob; class MidiCCRackView; @@ -42,7 +46,7 @@ class InstrumentTrackView : public TrackView Q_OBJECT public: InstrumentTrackView( InstrumentTrack * _it, TrackContainerView* tc ); - virtual ~InstrumentTrackView(); + ~InstrumentTrackView() override; InstrumentTrackWindow * getInstrumentTrackWindow(); @@ -114,5 +118,7 @@ private: friend class InstrumentTrackWindow; } ; -#endif +} // namespace lmms::gui + +#endif diff --git a/include/InstrumentTrackWindow.h b/include/InstrumentTrackWindow.h index a215e08f9..68750c0b8 100644 --- a/include/InstrumentTrackWindow.h +++ b/include/InstrumentTrackWindow.h @@ -30,6 +30,17 @@ #include "ModelView.h" #include "SerializingObject.h" +class QLabel; +class QLineEdit; +class QWidget; + +namespace lmms +{ + +class InstrumentTrack; + +namespace gui +{ class EffectRackView; class MixerLineLcdSpinBox; @@ -38,7 +49,6 @@ class InstrumentFunctionNoteStackingView; class InstrumentMidiIOView; class InstrumentMiscView; class InstrumentSoundShapingView; -class InstrumentTrack; class InstrumentTrackShapingView; class InstrumentTrackView; class Knob; @@ -46,9 +56,6 @@ class LcdSpinBox; class LeftRightNav; class PianoView; class PluginView; -class QLabel; -class QLineEdit; -class QWidget; class TabWidget; @@ -58,7 +65,7 @@ class InstrumentTrackWindow : public QWidget, public ModelView, Q_OBJECT public: InstrumentTrackWindow( InstrumentTrackView * _tv ); - virtual ~InstrumentTrackWindow(); + ~InstrumentTrackWindow() override; // parent for all internal tab-widgets TabWidget * tabWidgetParent() @@ -157,5 +164,9 @@ private: friend class InstrumentTrackView; } ; -#endif +} // namespace gui + +} // namespace lmms + +#endif diff --git a/include/InstrumentView.h b/include/InstrumentView.h index 838ed2d91..ab18465eb 100644 --- a/include/InstrumentView.h +++ b/include/InstrumentView.h @@ -29,6 +29,10 @@ #include "Instrument.h" #include "PluginView.h" + +namespace lmms::gui +{ + class InstrumentTrackWindow; @@ -66,8 +70,10 @@ class LMMS_EXPORT InstrumentViewFixedSize : public InstrumentView public: using InstrumentView::InstrumentView; - ~InstrumentViewFixedSize() override; + ~InstrumentViewFixedSize() override = default; } ; +} // namespace lmms::gui + #endif diff --git a/include/IoHelper.h b/include/IoHelper.h index 35ee8cb87..96d6aa144 100644 --- a/include/IoHelper.h +++ b/include/IoHelper.h @@ -22,16 +22,32 @@ * */ +#ifndef IO_HELPER_H +#define IO_HELPER_H #include "lmmsconfig.h" #include - #ifdef _WIN32 #include +#endif -std::wstring toWString(const std::string& s) +#ifdef LMMS_BUILD_WIN32 +#include +#else +#ifdef LMMS_HAVE_UNISTD_H +#include +#endif +#endif // LMMS_BUILD_WIN32 + +namespace lmms +{ + + +#ifdef _WIN32 + +inline std::wstring toWString(const std::string& s) { std::wstring ret; int len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), @@ -44,17 +60,11 @@ std::wstring toWString(const std::string& s) MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), s.length(), &ret[0], len); return ret; } + #endif -#ifdef LMMS_BUILD_WIN32 -#include -#else -#ifdef LMMS_HAVE_UNISTD_H -#include -#endif -#endif -FILE* F_OPEN_UTF8(std::string const& fname, const char* mode){ +inline FILE* F_OPEN_UTF8(std::string const& fname, const char* mode){ #ifdef LMMS_BUILD_WIN32 return _wfopen(toWString(fname).data(), toWString(mode).data()); #else @@ -62,7 +72,8 @@ FILE* F_OPEN_UTF8(std::string const& fname, const char* mode){ #endif } -int fileToDescriptor(FILE* f, bool closeFile = true) + +inline int fileToDescriptor(FILE* f, bool closeFile = true) { int fh; if (f == nullptr) {return -1;} @@ -76,3 +87,8 @@ int fileToDescriptor(FILE* f, bool closeFile = true) if (closeFile) {fclose(f);} return fh; } + + +} // namespace lmms + +#endif diff --git a/include/JournallingObject.h b/include/JournallingObject.h index 9e0322591..41ae65295 100644 --- a/include/JournallingObject.h +++ b/include/JournallingObject.h @@ -30,12 +30,14 @@ #include "lmms_basics.h" #include "SerializingObject.h" +namespace lmms +{ class LMMS_EXPORT JournallingObject : public SerializingObject { public: JournallingObject(); - virtual ~JournallingObject(); + ~JournallingObject() override; inline jo_id_t id() const { @@ -58,7 +60,7 @@ public: void addJournalCheckPoint(); - virtual QDomElement saveState( QDomDocument & _doc, + QDomElement saveState( QDomDocument & _doc, QDomElement & _parent ) override; void restoreState( const QDomElement & _this ) override; @@ -99,5 +101,7 @@ private: } ; +} // namespace lmms + #endif diff --git a/include/Keymap.h b/include/Keymap.h index 08a27c473..6286f8362 100644 --- a/include/Keymap.h +++ b/include/Keymap.h @@ -31,6 +31,9 @@ #include "SerializingObject.h" +namespace lmms +{ + class Keymap : public QObject, public SerializingObject { Q_OBJECT @@ -75,4 +78,6 @@ private: float m_baseFreq; //!< frequency of the base note (usually A4 @440 Hz) }; +} // namespace lmms + #endif diff --git a/include/Knob.h b/include/Knob.h index f27328aa9..16ac7ed01 100644 --- a/include/Knob.h +++ b/include/Knob.h @@ -36,6 +36,11 @@ class QPixmap; + +namespace lmms::gui +{ + + class TextFloat; enum knobTypes @@ -206,4 +211,7 @@ private: } ; + +} // namespace lmms::gui + #endif diff --git a/include/Ladspa2LMMS.h b/include/Ladspa2LMMS.h index 28fa25b89..4b7eb2482 100644 --- a/include/Ladspa2LMMS.h +++ b/include/Ladspa2LMMS.h @@ -30,6 +30,9 @@ #include "LadspaManager.h" +namespace lmms +{ + //! Class responsible for sorting found plugins (by LadspaManager) //! into categories class LMMS_EXPORT Ladspa2LMMS : public LadspaManager @@ -65,7 +68,7 @@ public: private: Ladspa2LMMS(); - virtual ~Ladspa2LMMS(); + ~Ladspa2LMMS() override = default; l_sortable_plugin_t m_instruments; l_sortable_plugin_t m_validEffects; @@ -73,8 +76,11 @@ private: l_sortable_plugin_t m_analysisTools; l_sortable_plugin_t m_otherPlugins; - friend class LmmsCore; + friend class Engine; } ; + +} // namespace lmms + #endif diff --git a/include/LadspaBase.h b/include/LadspaBase.h index be4576f55..3feb7d204 100644 --- a/include/LadspaBase.h +++ b/include/LadspaBase.h @@ -29,32 +29,26 @@ #include "LadspaManager.h" #include "Plugin.h" +namespace lmms +{ + + class LadspaControl; - -typedef enum BufferRates -{ +enum buffer_rate_t { CHANNEL_IN, CHANNEL_OUT, AUDIO_RATE_INPUT, AUDIO_RATE_OUTPUT, CONTROL_RATE_INPUT, CONTROL_RATE_OUTPUT -} buffer_rate_t; +}; -typedef enum BufferData -{ - TOGGLED, - ENUM, - INTEGER, - FLOATING, - TIME, - NONE -} buffer_data_t; +enum buffer_data_t { TOGGLED, ENUM, INTEGER, FLOATING, TIME, NONE }; //! This struct is used to hold port descriptions internally //! which where received from the ladspa plugin -typedef struct PortDescription +struct port_desc_t { QString name; ch_cnt_t proc; @@ -70,10 +64,9 @@ typedef struct PortDescription //! This is true iff ladspa suggests logscale //! Note however that the model can still decide to use a linear scale bool suggests_logscale; - LADSPA_Data * buffer; - LadspaControl * control; -} port_desc_t; - + LADSPA_Data* buffer; + LadspaControl* control; +}; inline Plugin::Descriptor::SubPluginFeatures::Key ladspaKeyToSubPluginKey( const Plugin::Descriptor * _desc, @@ -88,4 +81,6 @@ inline Plugin::Descriptor::SubPluginFeatures::Key ladspaKeyToSubPluginKey( } +} // namespace lmms + #endif diff --git a/include/LadspaControl.h b/include/LadspaControl.h index 34f6c9ae2..258a5d8fc 100644 --- a/include/LadspaControl.h +++ b/include/LadspaControl.h @@ -32,8 +32,17 @@ #include "TempoSyncKnobModel.h" #include "ValueBuffer.h" +namespace lmms +{ -typedef struct PortDescription port_desc_t; +struct port_desc_t; + +namespace gui +{ + +class LadspaControlView; + +} // namespace gui class LMMS_EXPORT LadspaControl : public Model, public JournallingObject @@ -42,7 +51,7 @@ class LMMS_EXPORT LadspaControl : public Model, public JournallingObject public: LadspaControl( Model * _parent, port_desc_t * _port, bool _link = false ); - ~LadspaControl(); + ~LadspaControl() override = default; LADSPA_Data value(); ValueBuffer * valueBuffer(); @@ -115,8 +124,11 @@ private: TempoSyncKnobModel m_tempoSyncKnobModel; - friend class LadspaControlView; + friend class gui::LadspaControlView; } ; + +} // namespace lmms + #endif diff --git a/include/LadspaControlView.h b/include/LadspaControlView.h index d2d0ca44d..5dafa4e5c 100644 --- a/include/LadspaControlView.h +++ b/include/LadspaControlView.h @@ -30,19 +30,29 @@ #include "ModelView.h" +namespace lmms +{ + class LadspaControl; +namespace gui +{ class LMMS_EXPORT LadspaControlView : public QWidget, public ModelView { Q_OBJECT public: LadspaControlView( QWidget * _parent, LadspaControl * _ctl ); - virtual ~LadspaControlView(); + ~LadspaControlView() override = default; private: LadspaControl * m_ctl; } ; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/include/LadspaManager.h b/include/LadspaManager.h index a87511161..176526193 100644 --- a/include/LadspaManager.h +++ b/include/LadspaManager.h @@ -40,12 +40,15 @@ #include "lmms_basics.h" +namespace lmms +{ + const float NOHINT = -99342.2243f; -typedef QPair ladspa_key_t; -typedef QPair sortable_plugin_t; -typedef QList l_sortable_plugin_t; -typedef QList l_ladspa_key_t; +using ladspa_key_t = QPair; +using sortable_plugin_t = QPair; +using l_sortable_plugin_t = QList; +using l_ladspa_key_t = QList; /* LadspaManager provides a database of LADSPA plug-ins. Upon instantiation, it loads all of the plug-ins found in the LADSPA_PATH environmental variable @@ -70,15 +73,14 @@ enum LadspaPluginType OTHER }; -typedef struct LadspaManagerStorage +struct LadspaManagerDescription { LADSPA_Descriptor_Function descriptorFunction; uint32_t index; LadspaPluginType type; uint16_t inputChannels; uint16_t outputChannels; -} LadspaManagerDescription; - +}; class LMMS_EXPORT LadspaManager { @@ -339,11 +341,13 @@ private: const LADSPA_PortRangeHint* getPortRangeHint( const ladspa_key_t& _plugin, uint32_t _port ); - typedef QMap - LadspaManagerMapType; + using LadspaManagerMapType = QMap; LadspaManagerMapType m_ladspaManagerMap; l_sortable_plugin_t m_sortedPlugins; } ; + +} // namespace lmms + #endif diff --git a/include/LcdFloatSpinBox.h b/include/LcdFloatSpinBox.h index 034168fbb..ab0de304e 100644 --- a/include/LcdFloatSpinBox.h +++ b/include/LcdFloatSpinBox.h @@ -32,6 +32,9 @@ #include "LcdWidget.h" #include "AutomatableModelView.h" +namespace lmms::gui +{ + class LMMS_EXPORT LcdFloatSpinBox : public QWidget, public FloatModelView { @@ -80,4 +83,6 @@ signals: using LcdFloatSpinBoxModel = FloatModel; +} // namespace lmms::gui + #endif diff --git a/include/LcdSpinBox.h b/include/LcdSpinBox.h index 91ac8b4a7..9c8923763 100644 --- a/include/LcdSpinBox.h +++ b/include/LcdSpinBox.h @@ -29,6 +29,8 @@ #include "LcdWidget.h" #include "AutomatableModelView.h" +namespace lmms::gui +{ class LMMS_EXPORT LcdSpinBox : public LcdWidget, public IntModelView { @@ -38,7 +40,7 @@ public: LcdSpinBox( int numDigits, const QString& style, QWidget* parent, const QString& name = QString() ); - virtual ~LcdSpinBox() = default; + ~LcdSpinBox() override = default; void modelChanged() override { @@ -84,6 +86,8 @@ signals: } ; -typedef IntModel LcdSpinBoxModel; +using LcdSpinBoxModel = IntModel; + +} // namespace lmms::gui #endif diff --git a/include/LcdWidget.h b/include/LcdWidget.h index a04e7ae91..d55cfc017 100644 --- a/include/LcdWidget.h +++ b/include/LcdWidget.h @@ -31,6 +31,9 @@ #include "lmms_export.h" +namespace lmms::gui +{ + class LMMS_EXPORT LcdWidget : public QWidget { Q_OBJECT @@ -45,7 +48,7 @@ public: LcdWidget(int numDigits, const QString& style, QWidget* parent, const QString& name = QString(), bool leadingZero = false); - virtual ~LcdWidget(); + ~LcdWidget() override; void setValue( int value ); void setLabel( const QString& label ); @@ -112,4 +115,6 @@ private: }; +} // namespace lmms::gui + #endif diff --git a/include/LedCheckBox.h b/include/LedCheckBox.h index f5477704f..a215592e6 100644 --- a/include/LedCheckBox.h +++ b/include/LedCheckBox.h @@ -32,6 +32,9 @@ class QPixmap; +namespace lmms::gui +{ + class LMMS_EXPORT LedCheckBox : public AutomatableButton { Q_OBJECT @@ -51,7 +54,7 @@ public: const QString & _name = QString(), LedColors _color = Yellow ); - virtual ~LedCheckBox(); + ~LedCheckBox() override; inline const QString & text() @@ -78,4 +81,7 @@ private: } ; + +} // namespace lmms::gui + #endif diff --git a/include/LeftRightNav.h b/include/LeftRightNav.h index 4f3f4ecbb..df72193dc 100644 --- a/include/LeftRightNav.h +++ b/include/LeftRightNav.h @@ -28,6 +28,9 @@ #include "PixmapButton.h" +namespace lmms::gui +{ + class LeftRightNav : public QWidget { Q_OBJECT @@ -45,4 +48,7 @@ private: PixmapButton m_rightBtn; }; + +} // namespace lmms::gui + #endif \ No newline at end of file diff --git a/include/LfoController.h b/include/LfoController.h index 8fc35fd09..48aee3d30 100644 --- a/include/LfoController.h +++ b/include/LfoController.h @@ -34,11 +34,21 @@ #include "TempoSyncKnobModel.h" #include "Oscillator.h" +namespace lmms +{ + +namespace gui +{ + class automatableButtonGroup; -class Knob; class LedCheckBox; -class TempoSyncKnob; class PixmapButton; +class Knob; +class TempoSyncKnob; + +class LfoControllerDialog; + +} class LfoController : public Controller @@ -47,7 +57,7 @@ class LfoController : public Controller public: LfoController( Model * _parent ); - virtual ~LfoController(); + ~LfoController() override; void saveSettings( QDomDocument & _doc, QDomElement & _this ) override; void loadSettings( const QDomElement & _this ) override; @@ -55,7 +65,7 @@ public: public slots: - ControllerDialog * createDialog( QWidget * _parent ) override; + gui::ControllerDialog * createDialog( QWidget * _parent ) override; protected: @@ -83,18 +93,19 @@ protected slots: void updateSampleFunction(); void updateDuration(); - friend class LfoControllerDialog; + friend class gui::LfoControllerDialog; } ; - +namespace gui +{ class LfoControllerDialog : public ControllerDialog { Q_OBJECT public: LfoControllerDialog( Controller * _controller, QWidget * _parent ); - virtual ~LfoControllerDialog(); + ~LfoControllerDialog() override; protected: @@ -120,4 +131,9 @@ private slots: } ; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/include/LinkedModelGroupViews.h b/include/LinkedModelGroupViews.h index a70480d5c..72598281b 100644 --- a/include/LinkedModelGroupViews.h +++ b/include/LinkedModelGroupViews.h @@ -31,6 +31,19 @@ #include +namespace lmms +{ + + +class LinkedModelGroup; +class LinkedModelGroups; + + +namespace gui +{ + +class Control; + /** @file LinkedModelGroupViews.h See Lv2ViewBase.h for example usage @@ -55,17 +68,17 @@ public: @param colNum numbers of columns for the controls (link LEDs not counted) */ - LinkedModelGroupView(QWidget *parent, class LinkedModelGroup* model, + LinkedModelGroupView(QWidget* parent, LinkedModelGroup* model, std::size_t colNum); - ~LinkedModelGroupView(); + ~LinkedModelGroupView() override = default; //! Reconnect models if model changed - void modelChanged(class LinkedModelGroup *linkedModelGroup); + void modelChanged(LinkedModelGroup* linkedModelGroup); protected: //! Add a control to this widget //! @warning This widget will own this control, do not free it - void addControl(class Control *ctrl, const std::string &id, + void addControl(Control* ctrl, const std::string &id, const std::string& display, bool removable); void removeControl(const QString &key); @@ -94,7 +107,7 @@ protected: ~LinkedModelGroupsView() = default; //! Reconnect models if model changed; to be called by child virtuals - void modelChanged(class LinkedModelGroups* ctrlBase); + void modelChanged(LinkedModelGroups* ctrlBase); private: //! The base class must return the addressed group view, @@ -103,4 +116,8 @@ private: }; +} // namespace gui + +} // namespace lmms + #endif // LINKEDMODELGROUPVIEWS_H diff --git a/include/LinkedModelGroups.h b/include/LinkedModelGroups.h index 770518076..84a216f30 100644 --- a/include/LinkedModelGroups.h +++ b/include/LinkedModelGroups.h @@ -31,6 +31,12 @@ #include "Model.h" +class QDomDocument; +class QDomElement; + +namespace lmms +{ + /** @file LinkedModelGroups.h See Lv2ControlBase.h and Lv2Proc.h for example usage @@ -107,8 +113,8 @@ signals: // (who would kno if the client is Qt, i.e. it may not have slots at all) // In this case you'd e.g. send the UI something like // "/added " - void modelAdded(AutomatableModel* added); - void modelRemoved(AutomatableModel* removed); + void modelAdded(lmms::AutomatableModel* added); + void modelRemoved(lmms::AutomatableModel* removed); public: AutomatableModel* getModel(const std::string& s) @@ -149,7 +155,7 @@ private: class LinkedModelGroups { public: - virtual ~LinkedModelGroups(); + virtual ~LinkedModelGroups() = default; void linkAllModels(); @@ -170,4 +176,6 @@ public: }; +} // namespace lmms + #endif // LINKEDMODELGROUPS_H diff --git a/include/LmmsPalette.h b/include/LmmsPalette.h index a8ee5d1c8..023872254 100644 --- a/include/LmmsPalette.h +++ b/include/LmmsPalette.h @@ -23,11 +23,15 @@ * */ +#ifndef LMMSPALETTE_H +#define LMMSPALETTE_H + #include #include "lmms_export.h" -#ifndef LMMSPALETTE_H -#define LMMSPALETTE_H + +namespace lmms::gui +{ class LMMS_EXPORT LmmsPalette : public QWidget @@ -46,7 +50,7 @@ class LMMS_EXPORT LmmsPalette : public QWidget public: LmmsPalette( QWidget * parent, QStyle * stylearg ); - virtual ~LmmsPalette(); + ~LmmsPalette() override = default; #define ACCESSMET( read, write ) \ QColor read () const; \ @@ -83,5 +87,6 @@ private: +} // namespace lmms::gui #endif diff --git a/include/LmmsStyle.h b/include/LmmsStyle.h index ccf14396c..ae5b65f99 100644 --- a/include/LmmsStyle.h +++ b/include/LmmsStyle.h @@ -30,6 +30,9 @@ #include +namespace lmms::gui +{ + class LmmsStyle : public QProxyStyle { @@ -63,23 +66,21 @@ public: }; LmmsStyle(); - virtual ~LmmsStyle() - { - } + ~LmmsStyle() override = default; - QPalette standardPalette( void ) const override; + QPalette standardPalette() const override; - virtual void drawComplexControl( + void drawComplexControl( ComplexControl control, const QStyleOptionComplex * option, QPainter *painter, const QWidget *widget ) const override; - virtual void drawPrimitive( PrimitiveElement element, + void drawPrimitive( PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0 ) const override; - virtual int pixelMetric( PixelMetric metric, + int pixelMetric( PixelMetric metric, const QStyleOption * option = 0, const QWidget * widget = 0 ) const override; @@ -92,4 +93,7 @@ private: }; + +} // namespace lmms::gui + #endif diff --git a/include/LocaleHelper.h b/include/LocaleHelper.h index c5d9d4c46..b071a1596 100644 --- a/include/LocaleHelper.h +++ b/include/LocaleHelper.h @@ -33,8 +33,9 @@ #include #include -namespace LocaleHelper +namespace lmms::LocaleHelper { + inline double toDouble(QString str, bool* ok = nullptr) { bool isOkay; @@ -62,6 +63,8 @@ inline float toFloat(QString str, bool* ok = nullptr) } return static_cast(d); } -} + + +} // namespace lmms::LocaleHelper #endif // LOCALEHELPER_H diff --git a/include/LocklessAllocator.h b/include/LocklessAllocator.h index d7977480e..adde5fe6f 100644 --- a/include/LocklessAllocator.h +++ b/include/LocklessAllocator.h @@ -28,6 +28,11 @@ #include #include + +namespace lmms +{ + + class LocklessAllocator { public: @@ -62,9 +67,7 @@ public: { } - virtual ~LocklessAllocatorT() - { - } + ~LocklessAllocatorT() override = default; T * alloc() { @@ -79,4 +82,6 @@ public: } ; +} // namespace lmms + #endif diff --git a/include/LocklessList.h b/include/LocklessList.h index 05df56f41..44b718059 100644 --- a/include/LocklessList.h +++ b/include/LocklessList.h @@ -29,6 +29,9 @@ #include +namespace lmms +{ + template class LocklessList { @@ -92,4 +95,6 @@ private: } ; +} // namespace lmms + #endif diff --git a/include/LocklessRingBuffer.h b/include/LocklessRingBuffer.h index 5950b842f..e77c62ccb 100644 --- a/include/LocklessRingBuffer.h +++ b/include/LocklessRingBuffer.h @@ -32,6 +32,9 @@ #include "../src/3rdparty/ringbuffer/include/ringbuffer/ringbuffer.h" +namespace lmms +{ + //! A convenience layer for a realtime-safe and thread-safe multi-reader ringbuffer template class LocklessRingBuffer @@ -43,7 +46,7 @@ public: { m_buffer.touch(); // reserve storage space before realtime operation starts } - ~LocklessRingBuffer() {}; + ~LocklessRingBuffer() = default; std::size_t capacity() const {return m_buffer.maximum_eventual_write_space();} std::size_t free() const {return m_buffer.write_space();} @@ -83,4 +86,7 @@ private: QWaitCondition *m_notifier; }; + +} // namespace lmms + #endif //LOCKLESSRINGBUFFER_H diff --git a/include/Lv2Basics.h b/include/Lv2Basics.h index 0003f83e8..b935e6a02 100644 --- a/include/Lv2Basics.h +++ b/include/Lv2Basics.h @@ -36,6 +36,9 @@ #include #include +namespace lmms +{ + struct LilvNodeDeleter { void operator()(LilvNode* n) { lilv_node_free(n); } @@ -63,5 +66,7 @@ QString qStringFromPortName(const LilvPlugin* plug, const LilvPort* port); //! Return port name as std::string, everything will be freed automatically std::string stdStringFromPortName(const LilvPlugin* plug, const LilvPort* port); +} // namespace lmms + #endif // LMMS_HAVE_LV2 #endif // LV2BASICS_H diff --git a/include/Lv2ControlBase.h b/include/Lv2ControlBase.h index 6b72bec5d..c6b08db8c 100644 --- a/include/Lv2ControlBase.h +++ b/include/Lv2ControlBase.h @@ -37,6 +37,10 @@ #include "lmms_export.h" #include "Plugin.h" +namespace lmms +{ + + class Lv2Proc; class PluginIssue; @@ -155,5 +159,8 @@ private: const LilvPlugin* m_plugin; }; + +} // namespace lmms + #endif // LMMS_HAVE_LV2 #endif // LV2_CONTROL_BASE_H diff --git a/include/Lv2Evbuf.h b/include/Lv2Evbuf.h index 9cf6a6801..9732fc5e1 100644 --- a/include/Lv2Evbuf.h +++ b/include/Lv2Evbuf.h @@ -39,18 +39,24 @@ #include + +namespace lmms +{ + + /** An abstract/opaque LV2 event buffer. */ -typedef struct LV2_Evbuf_Impl LV2_Evbuf; +using LV2_Evbuf = struct LV2_Evbuf_Impl; /** An iterator over an LV2_Evbuf. */ -typedef struct { +struct LV2_Evbuf_Iterator +{ LV2_Evbuf* evbuf; uint32_t offset; -} LV2_Evbuf_Iterator; +}; /** Allocate a new, empty event buffer. @@ -144,6 +150,9 @@ lv2_evbuf_write( LV2_Evbuf_Iterator* iter, uint32_t size, const uint8_t* data); + +} // namespace lmms + #endif // LMMS_HAVE_LV2 #endif // LV2_EVBUF_H diff --git a/include/Lv2Features.h b/include/Lv2Features.h index 272bb3a4d..033273f31 100644 --- a/include/Lv2Features.h +++ b/include/Lv2Features.h @@ -33,6 +33,10 @@ #include #include "Lv2Manager.h" + +namespace lmms +{ + /** Feature container @@ -75,6 +79,9 @@ private: std::map m_featureByUri; }; + +} // namespace lmms + #endif // LMMS_HAVE_LV2 #endif // LV2FEATURES_H diff --git a/include/Lv2Manager.h b/include/Lv2Manager.h index dbea510ce..7c4a4bcb7 100644 --- a/include/Lv2Manager.h +++ b/include/Lv2Manager.h @@ -39,6 +39,9 @@ #include "Plugin.h" +namespace lmms +{ + /* all Lv2 classes in relation (use our "4 spaces per tab rule" to view): @@ -158,6 +161,9 @@ private: bool isSubclassOf(const LilvPluginClass *clvss, const char *uriStr); }; + +} // namespace lmms + #endif // LMMS_HAVE_LV2 #endif // LV2MANAGER_H diff --git a/include/Lv2Options.h b/include/Lv2Options.h index 1453de2ea..32225ea89 100644 --- a/include/Lv2Options.h +++ b/include/Lv2Options.h @@ -41,6 +41,9 @@ #include "Lv2Manager.h" #include "Lv2UridCache.h" +namespace lmms +{ + /** Option container @@ -99,6 +102,9 @@ private: std::map> m_optionValues; }; + +} // namespace lmms + #endif // LMMS_HAVE_LV2 #endif // LV2OPTIONS_H diff --git a/include/Lv2Ports.h b/include/Lv2Ports.h index 529200793..07676fdd4 100644 --- a/include/Lv2Ports.h +++ b/include/Lv2Ports.h @@ -36,8 +36,13 @@ #include "lmms_basics.h" #include "PluginIssue.h" + +namespace lmms +{ + + struct ConnectPortVisitor; -typedef struct LV2_Evbuf_Impl LV2_Evbuf; +using LV2_Evbuf = struct LV2_Evbuf_Impl; namespace Lv2Ports { @@ -87,7 +92,7 @@ struct ConstVisitor virtual void visit(const Lv2Ports::AtomSeq& ) {} virtual void visit(const Lv2Ports::Unknown& ) {} - virtual ~ConstVisitor(); + virtual ~ConstVisitor() = default; }; struct Visitor @@ -99,7 +104,7 @@ struct Visitor virtual void visit(Lv2Ports::AtomSeq& ) {} virtual void visit(Lv2Ports::Unknown& ) {} - virtual ~Visitor(); + virtual ~Visitor() = default; }; struct Meta @@ -134,7 +139,7 @@ struct PortBase : public Meta QString name() const; QString uri() const; - virtual ~PortBase(); + virtual ~PortBase() = default; }; template @@ -200,7 +205,7 @@ private: bool m_sidechain; // the only case when data of m_buffer may be referenced: - friend struct ::ConnectPortVisitor; + friend struct lmms::ConnectPortVisitor; }; struct AtomSeq : public VisitablePort @@ -261,5 +266,8 @@ const Target* dcast(const PortBase* base) } // namespace Lv2Ports + +} // namespace lmms + #endif // LMMS_HAVE_LV2 #endif // LV2PORTS_H diff --git a/include/Lv2Proc.h b/include/Lv2Proc.h index 06185a9ac..31a694044 100644 --- a/include/Lv2Proc.h +++ b/include/Lv2Proc.h @@ -40,6 +40,10 @@ #include "../src/3rdparty/ringbuffer/include/ringbuffer/ringbuffer.h" #include "TimePos.h" + +namespace lmms +{ + class PluginIssue; // forward declare port structs/enums @@ -212,5 +216,8 @@ private: static AutoLilvNode uri(const char* uriStr); }; + +} // namespace lmms + #endif // LMMS_HAVE_LV2 #endif // LV2PROC_H diff --git a/include/Lv2SubPluginFeatures.h b/include/Lv2SubPluginFeatures.h index fee3c3812..9ba2c76cb 100644 --- a/include/Lv2SubPluginFeatures.h +++ b/include/Lv2SubPluginFeatures.h @@ -36,6 +36,10 @@ #include "lmms_export.h" #include "Plugin.h" +namespace lmms +{ + + class LMMS_EXPORT Lv2SubPluginFeatures : public Plugin::Descriptor::SubPluginFeatures { private: @@ -57,6 +61,9 @@ public: const Plugin::Descriptor *desc, KeyList &kl) const override; }; + +} // namespace lmms + #endif // LMMS_HAVE_LV2 #endif diff --git a/include/Lv2UridCache.h b/include/Lv2UridCache.h index e50fd4bab..bae42d318 100644 --- a/include/Lv2UridCache.h +++ b/include/Lv2UridCache.h @@ -31,6 +31,11 @@ #include + +namespace lmms +{ + + //! Cached URIDs for fast access (for use in real-time code) class Lv2UridCache { @@ -65,5 +70,8 @@ private: template<> struct Lv2UridCache::IdForType { static constexpr auto value = Id::atom_Float; }; template<> struct Lv2UridCache::IdForType { static constexpr auto value = Id::atom_Int; }; + +} // namespace lmms + #endif // LMMS_HAVE_LV2 #endif // LV2URIDCACHE_H diff --git a/include/Lv2UridMap.h b/include/Lv2UridMap.h index 39cfcc44f..9db9cb0c2 100644 --- a/include/Lv2UridMap.h +++ b/include/Lv2UridMap.h @@ -35,6 +35,11 @@ #include #include + +namespace lmms +{ + + /** * Complete implementation of the Lv2 Urid Map extension */ @@ -66,5 +71,8 @@ public: LV2_URID_Unmap* unmapFeature() { return &m_unmapFeature; } }; + +} // namespace lmms + #endif // LMMS_HAVE_LV2 #endif // LV2URIDMAP_H diff --git a/include/Lv2ViewBase.h b/include/Lv2ViewBase.h index 6eafbde88..605440814 100644 --- a/include/Lv2ViewBase.h +++ b/include/Lv2ViewBase.h @@ -35,17 +35,30 @@ #include "lmms_export.h" #include "Lv2Basics.h" + +class QPushButton; +class QMdiSubWindow; + +namespace lmms +{ + + class Lv2Proc; class Lv2ControlBase; +namespace gui +{ + +class LedCheckBox; + //! View for one processor, Lv2ViewBase contains 2 of those for mono plugins class Lv2ViewProc : public LinkedModelGroupView { public: //! @param colNum numbers of columns for the controls Lv2ViewProc(QWidget *parent, Lv2Proc *ctrlBase, int colNum); - ~Lv2ViewProc(); + ~Lv2ViewProc() override = default; private: static AutoLilvNode uri(const char *uriStr); @@ -61,9 +74,9 @@ protected: ~Lv2ViewBase(); // these widgets must be connected by child widgets - class QPushButton *m_reloadPluginButton = nullptr; - class QPushButton *m_toggleUIButton = nullptr; - class QPushButton *m_helpButton = nullptr; + QPushButton* m_reloadPluginButton = nullptr; + QPushButton* m_toggleUIButton = nullptr; + QPushButton* m_helpButton = nullptr; void toggleUI(); void toggleHelp(bool visible); @@ -87,10 +100,13 @@ private: //! Numbers of controls per row; must be multiple of 2 for mono effects const int m_colNum = 6; - class QMdiSubWindow* m_helpWindow = nullptr; - class LedCheckBox *m_multiChannelLink; + QMdiSubWindow* m_helpWindow = nullptr; }; +} // namespace gui + +} // namespace lmms + #endif // LMMS_HAVE_LV2 #endif // LV2VIEWBASE_H diff --git a/include/MainApplication.h b/include/MainApplication.h index d28900213..04bc82226 100644 --- a/include/MainApplication.h +++ b/include/MainApplication.h @@ -34,6 +34,11 @@ #include #endif + +namespace lmms::gui +{ + + #if defined(LMMS_BUILD_WIN32) class MainApplication : public QApplication, public QAbstractNativeEventFilter #else @@ -56,4 +61,7 @@ private: QString m_queuedFile; }; + +} // namespace lmms::gui + #endif // MAINAPPLICATION_H diff --git a/include/MainWindow.h b/include/MainWindow.h index 145023161..e093d1082 100644 --- a/include/MainWindow.h +++ b/include/MainWindow.h @@ -37,10 +37,18 @@ class QDomElement; class QGridLayout; class QMdiArea; +namespace lmms +{ + class ConfigManager; + +namespace gui +{ + class PluginView; class SubWindow; class ToolButton; +class GuiApplication; class MainWindow : public QMainWindow @@ -182,7 +190,7 @@ protected: private: MainWindow(); MainWindow( const MainWindow & ); - virtual ~MainWindow(); + ~MainWindow() override; void finalize(); @@ -234,7 +242,7 @@ private: private slots: void browseHelp(); void showTool( QAction * _idx ); - void updateViewMenu( void ); + void updateViewMenu(); void updateConfig( QAction * _who ); void onToggleMetronome(); void onExportProject(); @@ -250,4 +258,9 @@ signals: } ; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/include/MemoryHelper.h b/include/MemoryHelper.h index f5c5bf11b..1def9d9c4 100644 --- a/include/MemoryHelper.h +++ b/include/MemoryHelper.h @@ -27,6 +27,10 @@ #include +namespace lmms +{ + + /** * Helper class to alocate aligned memory and free it. */ @@ -40,5 +44,8 @@ public: private: }; + +} // namespace lmms + #endif diff --git a/include/MemoryManager.h b/include/MemoryManager.h index a5899d922..d50ad173d 100644 --- a/include/MemoryManager.h +++ b/include/MemoryManager.h @@ -32,6 +32,10 @@ #include "lmms_export.h" +namespace lmms +{ + + class LMMS_EXPORT MemoryManager { public: @@ -48,8 +52,10 @@ public: template struct MmAllocator { - typedef T value_type; - template struct rebind { typedef MmAllocator other; }; + using value_type = T; + template struct rebind { + using other = MmAllocator; + }; T* allocate( std::size_t n ) { @@ -61,7 +67,7 @@ struct MmAllocator MemoryManager::free( p ); } - typedef std::vector > vector; + using vector = std::vector>; }; @@ -99,4 +105,7 @@ void MM_FREE(T* ptr) MemoryManager::free(ptr); } + +} // namespace lmms + #endif diff --git a/include/MeterDialog.h b/include/MeterDialog.h index da254c7c7..67dca2568 100644 --- a/include/MeterDialog.h +++ b/include/MeterDialog.h @@ -30,6 +30,9 @@ #include "ModelView.h" +namespace lmms::gui +{ + class LcdSpinBox; @@ -38,7 +41,7 @@ class MeterDialog : public QWidget, public ModelView Q_OBJECT public: MeterDialog( QWidget * _parent, bool _simple = false ); - virtual ~MeterDialog(); + ~MeterDialog() override = default; void modelChanged() override; @@ -49,4 +52,6 @@ private: } ; +} // namespace lmms::gui + #endif diff --git a/include/MeterModel.h b/include/MeterModel.h index 2b98bed0b..c2e715b79 100644 --- a/include/MeterModel.h +++ b/include/MeterModel.h @@ -27,15 +27,18 @@ #include "AutomatableModel.h" +namespace lmms +{ -class MeterModel : public Model + +class LMMS_EXPORT MeterModel : public Model { Q_OBJECT mapPropertyFromModel(int,getNumerator,setNumerator,m_numeratorModel); mapPropertyFromModel(int,getDenominator,setDenominator,m_denominatorModel); public: MeterModel( Model * _parent ); - ~MeterModel(); + ~MeterModel() override = default; void saveSettings( QDomDocument & _doc, QDomElement & _this, const QString & _name ); @@ -62,4 +65,7 @@ private: } ; + +} // namespace lmms + #endif diff --git a/include/MicroTimer.h b/include/MicroTimer.h index 2026619e2..ea74e964d 100644 --- a/include/MicroTimer.h +++ b/include/MicroTimer.h @@ -22,18 +22,21 @@ * */ -#ifndef MICRO_TIMER -#define MICRO_TIMER +#ifndef MICRO_TIMER_H +#define MICRO_TIMER_H #include +namespace lmms +{ + class MicroTimer { using time_point = std::chrono::steady_clock::time_point; public: MicroTimer(); - ~MicroTimer(); + ~MicroTimer() = default; void reset(); int elapsed() const; @@ -43,4 +46,6 @@ private: } ; -#endif +} // namespace lmms + +#endif // MICRO_TIMER_H diff --git a/include/Microtuner.h b/include/Microtuner.h index 9ac732817..dff8f5773 100644 --- a/include/Microtuner.h +++ b/include/Microtuner.h @@ -29,6 +29,9 @@ #include "ComboBoxModel.h" #include "JournallingObject.h" +namespace lmms +{ + class LMMS_EXPORT Microtuner : public Model, public JournallingObject { Q_OBJECT @@ -51,6 +54,7 @@ public: float baseFreq() const; float keyToFreq(int key, int userBaseNote) const; + int octaveSize() const; QString nodeName() const override {return "microtuner";} void saveSettings(QDomDocument & document, QDomElement &element) override; @@ -68,4 +72,6 @@ private: }; +} // namespace lmms + #endif diff --git a/include/MicrotunerConfig.h b/include/MicrotunerConfig.h index 58752026c..690587dd5 100644 --- a/include/MicrotunerConfig.h +++ b/include/MicrotunerConfig.h @@ -35,6 +35,10 @@ class QLineEdit; class QPlainTextEdit; +namespace lmms::gui +{ + + class LMMS_EXPORT MicrotunerConfig : public QWidget, public SerializingObject { Q_OBJECT @@ -89,4 +93,7 @@ private: FloatModel m_baseFreqModel; //!< model for spinbox of currently edited base note frequency }; + +} // namespace lmms::gui + #endif diff --git a/include/Midi.h b/include/Midi.h index 00f3a08af..b76135115 100644 --- a/include/Midi.h +++ b/include/Midi.h @@ -28,6 +28,10 @@ #include "lmms_basics.h" +namespace lmms +{ + + enum MidiEventTypes { // messages @@ -77,8 +81,7 @@ enum MidiMetaEventTypes MidiMetaCustom = 0x80, MidiNotePanning } ; -typedef MidiMetaEventTypes MidiMetaEventType; - +using MidiMetaEventType = MidiMetaEventTypes; enum MidiStandardControllers { @@ -137,4 +140,7 @@ const int MidiMinPanning = -128; const int MidiMinPitchBend = 0; const int MidiMaxPitchBend = 16383; + +} // namespace lmms + #endif diff --git a/include/MidiAlsaRaw.h b/include/MidiAlsaRaw.h index 60bf1e685..57a477264 100644 --- a/include/MidiAlsaRaw.h +++ b/include/MidiAlsaRaw.h @@ -40,12 +40,15 @@ struct pollfd; +namespace lmms +{ + class MidiAlsaRaw : public QThread, public MidiClientRaw { Q_OBJECT public: MidiAlsaRaw(); - virtual ~MidiAlsaRaw(); + ~MidiAlsaRaw() override; static QString probeDevice(); @@ -77,6 +80,9 @@ private: } ; -#endif + +} // namespace lmms + +#endif // LMMS_HAVE_ALSA #endif diff --git a/include/MidiAlsaSeq.h b/include/MidiAlsaSeq.h index bbb3f7242..fa287a409 100644 --- a/include/MidiAlsaSeq.h +++ b/include/MidiAlsaSeq.h @@ -42,12 +42,16 @@ struct pollfd; +namespace lmms +{ + + class MidiAlsaSeq : public QThread, public MidiClient { Q_OBJECT public: MidiAlsaSeq(); - virtual ~MidiAlsaSeq(); + ~MidiAlsaSeq() override; static QString probeDevice(); @@ -66,7 +70,7 @@ public: - virtual void processOutEvent( const MidiEvent & _me, + void processOutEvent( const MidiEvent & _me, const TimePos & _time, const MidiPort * _port ) override; @@ -91,20 +95,20 @@ public: QString sourcePortName( const MidiEvent & ) const override; // (un)subscribe given MidiPort to/from destination-port - virtual void subscribeReadablePort( MidiPort * _port, + void subscribeReadablePort( MidiPort * _port, const QString & _dest, bool _subscribe = true ) override; - virtual void subscribeWritablePort( MidiPort * _port, + void subscribeWritablePort( MidiPort * _port, const QString & _dest, bool _subscribe = true ) override; - virtual void connectRPChanged( QObject * _receiver, + void connectRPChanged( QObject * _receiver, const char * _member ) override { connect( this, SIGNAL( readablePortsChanged() ), _receiver, _member ); } - virtual void connectWPChanged( QObject * _receiver, + void connectWPChanged( QObject * _receiver, const char * _member ) override { connect( this, SIGNAL( writablePortsChanged() ), @@ -113,7 +117,7 @@ public: private slots: - void changeQueueTempo( bpm_t _bpm ); + void changeQueueTempo( lmms::bpm_t _bpm ); void updatePortList(); @@ -149,7 +153,10 @@ signals: } ; -#endif + +} // namespace lmms + +#endif // LMMS_HAVE_ALSA #endif diff --git a/include/MidiApple.h b/include/MidiApple.h index 4ea4805e5..794641e64 100644 --- a/include/MidiApple.h +++ b/include/MidiApple.h @@ -38,6 +38,10 @@ class QLineEdit; +namespace lmms +{ + + class MidiApple : public QObject, public MidiClient { Q_OBJECT @@ -136,7 +140,7 @@ private: QMap m_sourcePortRef; // subscriptions - typedef QMap SubMap; + using SubMap = QMap; SubMap m_inputSubs; SubMap m_outputSubs; @@ -146,7 +150,10 @@ signals: } ; -#endif + +} // namespace lmms + +#endif // LMMS_BUILD_APPLE #endif diff --git a/include/MidiCCRackView.h b/include/MidiCCRackView.h index 982e06048..59f1de020 100644 --- a/include/MidiCCRackView.h +++ b/include/MidiCCRackView.h @@ -6,9 +6,16 @@ #include "Midi.h" #include "SerializingObject.h" -class GroupBox; +namespace lmms +{ + class InstrumentTrack; + +namespace gui +{ + class Knob; +class GroupBox; class MidiCCRackView : public QWidget, public SerializingObject { @@ -37,4 +44,9 @@ private: }; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/include/MidiClient.h b/include/MidiClient.h index 384a664ce..954cd5ef5 100644 --- a/include/MidiClient.h +++ b/include/MidiClient.h @@ -31,9 +31,13 @@ #include "MidiEvent.h" +class QObject; + + +namespace lmms +{ class MidiPort; -class QObject; class TimePos; @@ -41,7 +45,7 @@ class TimePos; class MidiClient { public: - MidiClient(); + MidiClient() = default; virtual ~MidiClient(); // to be implemented by sub-classes @@ -120,8 +124,8 @@ const uint32_t RAW_MIDI_PARSE_BUF_SIZE = 16; class MidiClientRaw : public MidiClient { public: - MidiClientRaw(); - virtual ~MidiClientRaw(); + MidiClientRaw() = default; + ~MidiClientRaw() override = default; // we are raw-clients for sure! bool isRaw() const override @@ -167,6 +171,7 @@ private: } ; +} // namespace lmms #endif diff --git a/include/MidiClip.h b/include/MidiClip.h index 036f2771c..6433ba507 100644 --- a/include/MidiClip.h +++ b/include/MidiClip.h @@ -31,8 +31,17 @@ #include "Note.h" +namespace lmms +{ + + class InstrumentTrack; +namespace gui +{ +class MidiClipView; +} + class LMMS_EXPORT MidiClip : public Clip { @@ -46,7 +55,7 @@ public: MidiClip( InstrumentTrack* instrumentTrack ); MidiClip( const MidiClip& other ); - virtual ~MidiClip(); + ~MidiClip() override; void init(); @@ -100,7 +109,7 @@ public: bool empty(); - ClipView * createView( TrackView * _tv ) override; + gui::ClipView * createView( gui::TrackView * _tv ) override; using Model::dataChanged; @@ -136,13 +145,14 @@ private: MidiClip * adjacentMidiClipByOffset(int offset) const; - friend class MidiClipView; + friend class gui::MidiClipView; signals: - void destroyedMidiClip( MidiClip* ); + void destroyedMidiClip( lmms::MidiClip* ); } ; +} // namespace lmms #endif diff --git a/include/MidiClipView.h b/include/MidiClipView.h index 82e552a8c..1a9809733 100644 --- a/include/MidiClipView.h +++ b/include/MidiClipView.h @@ -26,19 +26,24 @@ #define MIDI_CLIP_VIEW_H #include - #include "ClipView.h" +namespace lmms +{ + class MidiClip; - - + +namespace gui +{ + + class MidiClipView : public ClipView { Q_OBJECT public: MidiClipView( MidiClip* clip, TrackView* parent ); - virtual ~MidiClipView() = default; + ~MidiClipView() override = default; Q_PROPERTY(QColor noteFillColor READ getNoteFillColor WRITE setNoteFillColor) Q_PROPERTY(QColor noteBorderColor READ getNoteBorderColor WRITE setNoteBorderColor) @@ -58,7 +63,7 @@ public: void setMutedNoteBorderColor(QColor const & color) { m_mutedNoteBorderColor = color; } public slots: - MidiClip* getMidiClip(); + lmms::MidiClip* getMidiClip(); void update() override; @@ -68,6 +73,7 @@ protected slots: void resetName(); void changeName(); + void transposeSelection(); protected: @@ -96,7 +102,10 @@ private: bool m_legacySEPattern; } ; - - + + +} // namespace gui + +} // namespace lmms #endif diff --git a/include/MidiController.h b/include/MidiController.h index 74b408f86..500acc5f8 100644 --- a/include/MidiController.h +++ b/include/MidiController.h @@ -33,20 +33,28 @@ #include "MidiPort.h" +namespace lmms +{ + class MidiPort; +namespace gui +{ +class ControllerConnectionDialog; +} + class MidiController : public Controller, public MidiEventProcessor { Q_OBJECT public: MidiController( Model * _parent ); - virtual ~MidiController(); + ~MidiController() override = default; - virtual void processInEvent( const MidiEvent & _me, + void processInEvent( const MidiEvent & _me, const TimePos & _time, f_cnt_t offset = 0 ) override; - virtual void processOutEvent( const MidiEvent& _me, + void processOutEvent( const MidiEvent& _me, const TimePos & _time, f_cnt_t offset = 0 ) override { // No output yet @@ -61,7 +69,7 @@ public: public slots: - ControllerDialog * createDialog( QWidget * _parent ) override; + gui::ControllerDialog* createDialog( QWidget * _parent ) override; void updateName(); @@ -76,10 +84,12 @@ protected: float m_lastValue; float m_previousValue; - friend class ControllerConnectionDialog; + friend class gui::ControllerConnectionDialog; friend class AutoDetectMidiController; } ; +} // namespace lmms + #endif diff --git a/include/MidiDummy.h b/include/MidiDummy.h index f809d3c36..67a91e326 100644 --- a/include/MidiDummy.h +++ b/include/MidiDummy.h @@ -28,15 +28,15 @@ #include "MidiClient.h" +namespace lmms +{ + + class MidiDummy : public MidiClientRaw { public: - MidiDummy() - { - } - virtual ~MidiDummy() - { - } + MidiDummy() = default; + ~MidiDummy() override = default; inline static QString name() { @@ -63,4 +63,6 @@ protected: } ; +} // namespace lmms + #endif diff --git a/include/MidiEvent.h b/include/MidiEvent.h index 29a3c5df6..6c2bfdd55 100644 --- a/include/MidiEvent.h +++ b/include/MidiEvent.h @@ -30,6 +30,9 @@ #include "panning_constants.h" #include "volume.h" +namespace lmms +{ + class MidiEvent { public: @@ -63,16 +66,7 @@ public: m_data.m_sysExDataLen = dataLen; } - MidiEvent( const MidiEvent& other ) : - m_type( other.m_type ), - m_metaEvent( other.m_metaEvent ), - m_channel( other.m_channel ), - m_data( other.m_data ), - m_sysExData( other.m_sysExData ), - m_sourcePort(other.m_sourcePort), - m_source(other.m_source) - { - } + MidiEvent( const MidiEvent& other ) = default; MidiEventTypes type() const { @@ -225,4 +219,6 @@ private: Source m_source; } ; +} // namespace lmms + #endif diff --git a/include/MidiEventProcessor.h b/include/MidiEventProcessor.h index 3ded20430..132a5fc42 100644 --- a/include/MidiEventProcessor.h +++ b/include/MidiEventProcessor.h @@ -29,18 +29,17 @@ #include "MemoryManager.h" #include "TimePos.h" +namespace lmms +{ + // all classes being able to process MIDI-events should inherit from this class MidiEventProcessor { MM_OPERATORS public: - MidiEventProcessor() - { - } + MidiEventProcessor() = default; - virtual ~MidiEventProcessor() - { - } + virtual ~MidiEventProcessor() = default; // to be implemented by inheriting classes virtual void processInEvent( const MidiEvent& event, const TimePos& time = TimePos(), f_cnt_t offset = 0 ) = 0; @@ -48,4 +47,6 @@ public: } ; +} // namespace lmms + #endif diff --git a/include/MidiEventToByteSeq.h b/include/MidiEventToByteSeq.h index fba8cdeb4..f2e36f50a 100644 --- a/include/MidiEventToByteSeq.h +++ b/include/MidiEventToByteSeq.h @@ -30,6 +30,10 @@ #include "lmms_export.h" + +namespace lmms +{ + /** Write MIDI event into byte sequence. @@ -44,4 +48,7 @@ std::size_t LMMS_EXPORT writeToByteSeq( const class MidiEvent& ev, uint8_t* data, std::size_t bufsize ); + +} // namespace lmms + #endif // MIDIEVENTTOBYTESEQ_H diff --git a/include/MidiJack.h b/include/MidiJack.h index f12f9cebf..a4a944b81 100644 --- a/include/MidiJack.h +++ b/include/MidiJack.h @@ -39,17 +39,21 @@ #include "MidiClient.h" +class QLineEdit; + +namespace lmms +{ + constexpr size_t JACK_MIDI_BUFFER_MAX = 64; /* events */ class AudioJack; -class QLineEdit; class MidiJack : public QThread, public MidiClientRaw { Q_OBJECT public: MidiJack(); - virtual ~MidiJack(); + ~MidiJack() override; jack_client_t* jackClient(); @@ -72,8 +76,8 @@ public: protected: - virtual void sendByte( const unsigned char c ); - virtual void run(); + void sendByte( const unsigned char c ) override; + void run() override; private: @@ -93,6 +97,9 @@ private: }; + +} // namespace lmms + #endif // LMMS_HAVE_JACK #endif // MIDIJACK_H diff --git a/include/MidiOss.h b/include/MidiOss.h index 68b970bc5..944359055 100644 --- a/include/MidiOss.h +++ b/include/MidiOss.h @@ -35,13 +35,16 @@ #include "MidiClient.h" +namespace lmms +{ + class MidiOss : public QThread, public MidiClientRaw { Q_OBJECT public: MidiOss(); - virtual ~MidiOss(); + ~MidiOss() override; static QString probeDevice(); @@ -69,7 +72,11 @@ private: } ; -#endif + +} // namespace lmms + + +#endif // LMMS_HAVE_OSS #endif diff --git a/include/MidiPort.h b/include/MidiPort.h index b057f5d6c..7ef9adf90 100644 --- a/include/MidiPort.h +++ b/include/MidiPort.h @@ -34,11 +34,21 @@ #include "TimePos.h" #include "AutomatableModel.h" +namespace lmms +{ class MidiClient; class MidiEvent; class MidiEventProcessor; + +namespace gui +{ + class MidiPortMenu; +class ControllerConnectionDialog; +class InstrumentMidiIOView; + +} // class for abstraction of MIDI-port @@ -57,7 +67,7 @@ class MidiPort : public Model, public SerializingObject mapPropertyFromModel(bool,isReadable,setReadable,m_readableModel); mapPropertyFromModel(bool,isWritable,setWritable,m_writableModel); public: - typedef QMap Map; + using Map = QMap; enum Modes { @@ -66,14 +76,14 @@ public: Output, // from MIDI-event-processor to MIDI-client Duplex // both directions } ; - typedef Modes Mode; + using Mode = Modes; MidiPort( const QString& name, MidiClient* client, MidiEventProcessor* eventProcessor, Model* parent = nullptr, Mode mode = Disabled ); - virtual ~MidiPort(); + ~MidiPort() override; void setName( const QString& name ); @@ -129,8 +139,8 @@ public: void invalidateCilent(); - MidiPortMenu* m_readablePortsMenu; - MidiPortMenu* m_writablePortsMenu; + gui::MidiPortMenu* m_readablePortsMenu; + gui::MidiPortMenu* m_writablePortsMenu; public slots: @@ -165,8 +175,8 @@ private: Map m_writablePorts; - friend class ControllerConnectionDialog; - friend class InstrumentMidiIOView; + friend class gui::ControllerConnectionDialog; + friend class gui::InstrumentMidiIOView; signals: @@ -176,8 +186,8 @@ signals: } ; +using MidiPortList = QList; -typedef QList MidiPortList; - +} // namespace lmms #endif diff --git a/include/MidiPortMenu.h b/include/MidiPortMenu.h index ce39c4aac..215a73d06 100644 --- a/include/MidiPortMenu.h +++ b/include/MidiPortMenu.h @@ -33,13 +33,15 @@ class QAction; +namespace lmms::gui +{ class MidiPortMenu : public QMenu, public ModelView { Q_OBJECT public: MidiPortMenu( MidiPort::Modes _mode ); - virtual ~MidiPortMenu(); + ~MidiPortMenu() override = default; public slots: @@ -57,5 +59,6 @@ private: } ; +} // namespace lmms::gui #endif diff --git a/include/MidiSetupWidget.h b/include/MidiSetupWidget.h index fcaa29408..4021db142 100644 --- a/include/MidiSetupWidget.h +++ b/include/MidiSetupWidget.h @@ -30,6 +30,10 @@ class QLineEdit; +namespace lmms::gui +{ + + class MidiSetupWidget : public TabWidget { Q_OBJECT @@ -53,4 +57,7 @@ private: }; + +} // namespace lmms::gui + #endif diff --git a/include/MidiSndio.h b/include/MidiSndio.h index 2042a16ad..3ebd14d05 100644 --- a/include/MidiSndio.h +++ b/include/MidiSndio.h @@ -32,20 +32,25 @@ #include - #include "MidiClient.h" +struct mio_hdl; + +namespace lmms +{ + + class MidiSndio : public QThread, public MidiClientRaw { Q_OBJECT public: - MidiSndio( void ); - virtual ~MidiSndio(); + MidiSndio(); + ~MidiSndio() override; - static QString probeDevice(void); + static QString probeDevice(); - inline static QString name(void) + inline static QString name() { return QT_TRANSLATE_NOOP("MidiSetupWidget", "sndio MIDI"); } @@ -58,13 +63,16 @@ public: protected: void sendByte(const unsigned char c) override; - void run(void) override; + void run() override; private: - struct mio_hdl *m_hdl; + mio_hdl *m_hdl; volatile bool m_quit; } ; -#endif /* LMMS_HAVE_SNDIO */ -#endif /* _MIDI_SNDIO_H */ +} // namespace lmms + +#endif // LMMS_HAVE_SNDIO + +#endif // _MIDI_SNDIO_H diff --git a/include/MidiSwing.h b/include/MidiSwing.h index 81d11373c..eac4a11d9 100644 --- a/include/MidiSwing.h +++ b/include/MidiSwing.h @@ -9,6 +9,9 @@ #include "Note.h" #include "MidiClip.h" +namespace lmms +{ + /* * A swing groove that adjusts by whole ticks. * Someone might like it, also might be able to save the output to a midi file later. @@ -34,4 +37,6 @@ public: }; +} + #endif // MIDISWING_H diff --git a/include/MidiWinMM.h b/include/MidiWinMM.h index cbb139983..0f2bd0d5f 100644 --- a/include/MidiWinMM.h +++ b/include/MidiWinMM.h @@ -38,6 +38,10 @@ class QLineEdit; +namespace lmms +{ + + class MidiWinMM : public QObject, public MidiClient { Q_OBJECT @@ -130,7 +134,7 @@ private: QMap m_outputDevices; // subscriptions - typedef QMap SubMap; + using SubMap = QMap; SubMap m_inputSubs; SubMap m_outputSubs; @@ -141,7 +145,10 @@ signals: } ; -#endif + +} // namespace lmms + +#endif // LMMS_BUILD_WIN32 #endif diff --git a/include/MixHelpers.h b/include/MixHelpers.h index 872319f82..6599b40ec 100644 --- a/include/MixHelpers.h +++ b/include/MixHelpers.h @@ -27,6 +27,9 @@ #include "lmms_basics.h" +namespace lmms +{ + class ValueBuffer; namespace MixHelpers { @@ -73,7 +76,10 @@ void multiplyAndAddMultiplied( sampleFrame* dst, const sampleFrame* src, float c /*! \brief Multiply dst by coeffDst and add samples from srcLeft/srcRight multiplied by coeffSrc */ void multiplyAndAddMultipliedJoined( sampleFrame* dst, const sample_t* srcLeft, const sample_t* srcRight, float coeffDst, float coeffSrc, int frames ); -} +} // namespace MixHelpers + + +} // namespace lmms #endif diff --git a/include/Mixer.h b/include/Mixer.h index 7a6e3d0ff..ecd864ae7 100644 --- a/include/Mixer.h +++ b/include/Mixer.h @@ -34,8 +34,12 @@ #include +namespace lmms +{ + + class MixerRoute; -typedef QVector MixerRouteVector; +using MixerRouteVector = QVector; class MixerChannel : public ThreadableJob { @@ -98,7 +102,7 @@ class MixerRoute : public QObject Q_OBJECT public: MixerRoute( MixerChannel * from, MixerChannel * to, float amount ); - virtual ~MixerRoute(); + ~MixerRoute() override = default; mix_ch_t senderIndex() const { @@ -139,7 +143,7 @@ class LMMS_EXPORT Mixer : public Model, public JournallingObject Q_OBJECT public: Mixer(); - virtual ~Mixer(); + ~Mixer() override; void mixToChannel( const sampleFrame * _buf, mix_ch_t _ch ); @@ -220,4 +224,6 @@ private: } ; +} // namespace lmms + #endif diff --git a/include/MixerLine.h b/include/MixerLine.h index 4f7f7242f..decd5f3aa 100644 --- a/include/MixerLine.h +++ b/include/MixerLine.h @@ -23,16 +23,18 @@ * */ -#ifndef MIXER_LINE_H -#define MIXER_LINE_H +#ifndef MIXERLINE_H +#define MIXERLINE_H #include - - - class QGraphicsView; class QLineEdit; + +namespace lmms::gui +{ + + class Knob; class LcdWidget; class MixerView; @@ -48,7 +50,7 @@ public: Q_PROPERTY( QColor strokeInnerActive READ strokeInnerActive WRITE setStrokeInnerActive ) Q_PROPERTY( QColor strokeInnerInactive READ strokeInnerInactive WRITE setStrokeInnerInactive ) MixerLine( QWidget * _parent, MixerView * _mv, int _channelIndex); - ~MixerLine(); + ~MixerLine() override; void paintEvent( QPaintEvent * ) override; void mousePressEvent( QMouseEvent * ) override; @@ -113,4 +115,6 @@ private slots: }; +} // namespace lmms::gui + #endif // MIXERLINE_H diff --git a/include/MixerLineLcdSpinBox.h b/include/MixerLineLcdSpinBox.h index 6de8fcb47..bfd6cd5c9 100644 --- a/include/MixerLineLcdSpinBox.h +++ b/include/MixerLineLcdSpinBox.h @@ -27,6 +27,10 @@ #include "LcdSpinBox.h" +namespace lmms::gui +{ + + class TrackView; @@ -37,7 +41,7 @@ public: MixerLineLcdSpinBox(int numDigits, QWidget * parent, const QString& name, TrackView * tv = nullptr) : LcdSpinBox(numDigits, parent, name), m_tv(tv) {} - virtual ~MixerLineLcdSpinBox() {} + ~MixerLineLcdSpinBox() override = default; void setTrackView(TrackView * tv); @@ -49,4 +53,7 @@ private: TrackView * m_tv; }; + +} // namespace lmms::gui + #endif diff --git a/include/MixerView.h b/include/MixerView.h index 6c586a607..a7b1b5191 100644 --- a/include/MixerView.h +++ b/include/MixerView.h @@ -38,6 +38,11 @@ #include "EffectRackView.h" class QButtonGroup; + + +namespace lmms::gui +{ + class MixerLine; class LMMS_EXPORT MixerView : public QWidget, public ModelView, @@ -61,7 +66,7 @@ public: MixerView(); - virtual ~MixerView(); + ~MixerView() override; void keyPressEvent(QKeyEvent * e) override; @@ -131,4 +136,7 @@ private: friend class MixerChannelView; } ; + +} // namespace lmms::gui + #endif diff --git a/include/Model.h b/include/Model.h index 623d3a9f9..567d4ffd7 100644 --- a/include/Model.h +++ b/include/Model.h @@ -30,6 +30,8 @@ #include "lmms_export.h" +namespace lmms +{ class LMMS_EXPORT Model : public QObject { @@ -43,9 +45,7 @@ public: { } - virtual ~Model() - { - } + ~Model() override = default; bool isDefaultConstructed() { @@ -88,5 +88,7 @@ signals: } ; +} // namespace lmms + #endif diff --git a/include/ModelView.h b/include/ModelView.h index 7aad9ce7f..a858dc7ec 100644 --- a/include/ModelView.h +++ b/include/ModelView.h @@ -28,6 +28,8 @@ #include #include "Model.h" +namespace lmms::gui +{ class LMMS_EXPORT ModelView { @@ -81,6 +83,7 @@ private: } ; +} // namespace lmms::gui #endif diff --git a/include/ModelVisitor.h b/include/ModelVisitor.h index f9d156e30..8805e30e2 100644 --- a/include/ModelVisitor.h +++ b/include/ModelVisitor.h @@ -25,6 +25,10 @@ #ifndef MODELVISITOR_H #define MODELVISITOR_H +namespace lmms +{ + + class AutomatableModel; class BoolModel; class IntModel; @@ -43,7 +47,7 @@ public: virtual void visit(FloatModel& m); virtual void visit(ComboBoxModel& m); virtual void visit(TempoSyncKnobModel& m); - virtual ~ModelVisitor(); + virtual ~ModelVisitor() = default; }; class ConstModelVisitor @@ -58,7 +62,10 @@ public: virtual void visit(const FloatModel& m); virtual void visit(const ComboBoxModel& m); virtual void visit(const TempoSyncKnobModel& m); - virtual ~ConstModelVisitor(); + virtual ~ConstModelVisitor() = default; }; + +} // namespace lmms + #endif // MODELVISITOR_H diff --git a/include/NStateButton.h b/include/NStateButton.h index 10cb151ae..4dac1a436 100644 --- a/include/NStateButton.h +++ b/include/NStateButton.h @@ -32,13 +32,16 @@ #include "ToolButton.h" +namespace lmms::gui +{ + class NStateButton : public ToolButton { Q_OBJECT public: NStateButton( QWidget * _parent ); - virtual ~NStateButton(); + ~NStateButton() override; void addState( const QPixmap & _pixmap, const QString & _tooltip = "" ); inline void setGeneralToolTip( const QString & _tooltip ) @@ -72,4 +75,7 @@ private: } ; + +} // namespace lmms::gui + #endif diff --git a/include/Note.h b/include/Note.h index 31ba6995e..464f3906f 100644 --- a/include/Note.h +++ b/include/Note.h @@ -26,6 +26,7 @@ #ifndef NOTE_H #define NOTE_H +#include #include #include "volume.h" @@ -33,6 +34,11 @@ #include "SerializingObject.h" #include "TimePos.h" + +namespace lmms +{ + + class DetuningHelper; @@ -93,7 +99,7 @@ public: panning_t panning = DefaultPanning, DetuningHelper * detuning = nullptr ); Note( const Note & note ); - virtual ~Note(); + ~Note() override; // used by GUI inline void setSelected( const bool selected ) { m_selected = selected; } @@ -243,8 +249,20 @@ private: DetuningHelper * m_detuning; }; +using NoteVector = QVector; -typedef QVector NoteVector; +struct NoteBounds +{ + TimePos start; + TimePos end; + int lowest; + int highest; +}; +std::optional boundsForNotes(const NoteVector& notes); + + +} // namespace lmms + #endif diff --git a/include/NotePlayHandle.h b/include/NotePlayHandle.h index 778acd46e..4969fd84a 100644 --- a/include/NotePlayHandle.h +++ b/include/NotePlayHandle.h @@ -35,12 +35,15 @@ #include "MemoryManager.h" class QReadWriteLock; + +namespace lmms +{ + class InstrumentTrack; class NotePlayHandle; -typedef QList NotePlayHandleList; -typedef QList ConstNotePlayHandleList; - +using NotePlayHandleList = QList; +using ConstNotePlayHandleList = QList; class LMMS_EXPORT NotePlayHandle : public PlayHandle, public Note { @@ -61,7 +64,7 @@ public: OriginArpeggio, /*! created by arpeggio instrument function */ OriginCount }; - typedef Origins Origin; + using Origin = Origins; NotePlayHandle( InstrumentTrack* instrumentTrack, const f_cnt_t offset, @@ -70,7 +73,7 @@ public: NotePlayHandle* parent = nullptr, int midiEventChannel = -1, Origin origin = OriginMidiClip ); - virtual ~NotePlayHandle(); + ~NotePlayHandle() override; void * operator new ( size_t size, void * p ) { @@ -359,4 +362,6 @@ private: }; +} // namespace lmms + #endif diff --git a/include/Oscillator.h b/include/Oscillator.h index da9bea4eb..8727ee39c 100644 --- a/include/Oscillator.h +++ b/include/Oscillator.h @@ -37,6 +37,10 @@ #include "OscillatorConstants.h" #include "SampleBuffer.h" +namespace lmms +{ + + class IntModel; @@ -251,7 +255,7 @@ private: static fftwf_plan s_fftPlan; static fftwf_plan s_ifftPlan; static fftwf_complex * s_specBuf; - static float s_sampleBuffer[OscillatorConstants::WAVETABLE_LENGTH]; + static std::array s_sampleBuffer; static void generateSawWaveTable(int bands, sample_t* table, int firstBand = 1); static void generateTriangleWaveTable(int bands, sample_t* table, int firstBand = 1); @@ -307,4 +311,6 @@ private: } ; +} // namespace lmms + #endif diff --git a/include/OscillatorConstants.h b/include/OscillatorConstants.h index dcdad8dc4..0450c2f17 100644 --- a/include/OscillatorConstants.h +++ b/include/OscillatorConstants.h @@ -30,8 +30,9 @@ #include "lmms_basics.h" -namespace OscillatorConstants +namespace lmms::OscillatorConstants { + // Limit wavetables to the audible audio spectrum const int MAX_FREQ = 20000; // Minimum size of table to have all audible bands for midi note 1 (i.e. 20 000 Hz / 8.176 Hz) @@ -49,9 +50,9 @@ namespace OscillatorConstants // - wave shape: abstract and precise definition of the graph associated with a given type of wave; // - waveform: digital representations the wave shape, a set of waves optimized for use at varying pitches; // - wavetable: a table containing one period of a wave, with frequency content optimized for a specific pitch. - typedef std::array wavetable_t; - typedef std::array waveform_t; -}; + using wavetable_t = std::array; + using waveform_t = std::array; +} // namespace lmms::OscillatorConstants #endif // OSCILLATORCONSTANTS_H diff --git a/include/Oscilloscope.h b/include/Oscilloscope.h index 4072df478..db4cf2b4a 100644 --- a/include/Oscilloscope.h +++ b/include/Oscilloscope.h @@ -31,6 +31,9 @@ #include "lmms_basics.h" +namespace lmms::gui +{ + class Oscilloscope : public QWidget { @@ -40,7 +43,7 @@ public: Q_PROPERTY( QColor clippingColor READ clippingColor WRITE setClippingColor ) Oscilloscope( QWidget * _parent ); - virtual ~Oscilloscope(); + ~Oscilloscope() override; void setActive( bool _active ); @@ -57,7 +60,7 @@ protected: protected slots: - void updateAudioBuffer( const surroundSampleFrame * buffer ); + void updateAudioBuffer( const lmms::surroundSampleFrame * buffer ); private: QColor const & determineLineColor(float level) const; @@ -73,4 +76,7 @@ private: QColor m_clippingColor; } ; + +} // namespace lmms::gui + #endif // OSCILLOSCOPE_H diff --git a/include/OutputSettings.h b/include/OutputSettings.h index 4a375d244..03e3333ac 100644 --- a/include/OutputSettings.h +++ b/include/OutputSettings.h @@ -28,6 +28,11 @@ #include "lmms_basics.h" + +namespace lmms +{ + + class OutputSettings { public: @@ -112,4 +117,7 @@ private: double m_compressionLevel; }; + +} // namespace lmms + #endif diff --git a/include/PathUtil.h b/include/PathUtil.h index b1eec517e..8b1ef1097 100644 --- a/include/PathUtil.h +++ b/include/PathUtil.h @@ -1,3 +1,27 @@ +/* + * PathUtil.h + * + * Copyright (c) 2019-2022 Spekular + * + * This file is part of LMMS - https://lmms.io + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + #ifndef PATHUTIL_H #define PATHUTIL_H @@ -5,7 +29,7 @@ #include -namespace PathUtil +namespace lmms::PathUtil { enum class Base { Absolute, ProjectDir, FactorySample, UserSample, UserVST, Preset, UserLADSPA, DefaultLADSPA, UserSoundfont, DefaultSoundfont, UserGIG, DefaultGIG, @@ -44,6 +68,6 @@ namespace PathUtil //! Defaults to an absolute path if all bases fail. QString LMMS_EXPORT toShortestRelative(const QString & input, bool allowLocal = false); -} +} // namespace lmms::PathUtil #endif diff --git a/include/PatternClip.h b/include/PatternClip.h index a6543267b..f1d0e2557 100644 --- a/include/PatternClip.h +++ b/include/PatternClip.h @@ -28,6 +28,9 @@ #include "Clip.h" +namespace lmms +{ + /*! \brief Dummy clip for PatternTracks * * Only used in the Song (Editor). See PatternStore.h for more info. @@ -36,7 +39,7 @@ class PatternClip : public Clip { public: PatternClip(Track* track); - virtual ~PatternClip() = default; + ~PatternClip() override = default; void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; void loadSettings( const QDomElement & _this ) override; @@ -47,12 +50,13 @@ public: int patternIndex(); - ClipView * createView( TrackView * _tv ) override; + gui::ClipView * createView( gui::TrackView * _tv ) override; private: friend class PatternClipView; } ; +} // namespace lmms #endif diff --git a/include/PatternClipView.h b/include/PatternClipView.h index 9cda17688..d170e4bef 100644 --- a/include/PatternClipView.h +++ b/include/PatternClipView.h @@ -31,15 +31,20 @@ #include "ClipView.h" +namespace lmms +{ + class PatternClip; +namespace gui +{ class PatternClipView : public ClipView { Q_OBJECT public: PatternClipView(Clip* clip, TrackView* tv); - virtual ~PatternClipView() = default; + ~PatternClipView() override = default; public slots: @@ -65,5 +70,8 @@ private: } ; +} // namespace gui + +} // namespace lmms #endif diff --git a/include/PatternEditor.h b/include/PatternEditor.h index 03861c1b0..ffe08e335 100644 --- a/include/PatternEditor.h +++ b/include/PatternEditor.h @@ -30,8 +30,14 @@ #include "Editor.h" #include "TrackContainerView.h" +namespace lmms +{ class PatternStore; + +namespace gui +{ + class ComboBox; @@ -69,14 +75,12 @@ private: }; - - class PatternEditorWindow : public Editor { - Q_OBJECT +Q_OBJECT public: PatternEditorWindow(PatternStore* ps); - ~PatternEditorWindow(); + ~PatternEditorWindow() = default; QSize sizeHint() const override; @@ -90,4 +94,9 @@ private: ComboBox* m_patternComboBox; }; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/include/PatternStore.h b/include/PatternStore.h index e11328c16..7bd377941 100644 --- a/include/PatternStore.h +++ b/include/PatternStore.h @@ -29,6 +29,13 @@ #include "TrackContainer.h" #include "ComboBoxModel.h" +namespace lmms +{ + +namespace gui +{ + class PatternEditorWindow; +} /* * PatternStore is the backend of Pattern Editor: @@ -61,7 +68,7 @@ class LMMS_EXPORT PatternStore : public TrackContainer mapPropertyFromModel(int, currentPattern, setCurrentPattern, m_patternComboBoxModel); public: PatternStore(); - virtual ~PatternStore(); + ~PatternStore() override = default; virtual bool play(TimePos start, const fpp_t frames, const f_cnt_t frameBase, int clipNum = -1); @@ -100,9 +107,11 @@ private: // Where the pattern selection combo box is - friend class PatternEditorWindow; + friend class gui::PatternEditorWindow; } ; +} // namespace lmms + #endif diff --git a/include/PatternTrack.h b/include/PatternTrack.h index c594b4cf5..73ddd4766 100644 --- a/include/PatternTrack.h +++ b/include/PatternTrack.h @@ -31,9 +31,19 @@ #include "Track.h" -class TrackLabelButton; +namespace lmms +{ + class TrackContainer; +namespace gui +{ + +class TrackLabelButton; +class PatternTrackView; + +} // namespace gui + /*! Track type used in the Song (Editor) to reference a pattern in the PatternStore */ class LMMS_EXPORT PatternTrack : public Track @@ -41,14 +51,15 @@ class LMMS_EXPORT PatternTrack : public Track Q_OBJECT public: PatternTrack(TrackContainer* tc); - virtual ~PatternTrack(); + ~PatternTrack() override; + + bool play( const TimePos & _start, const fpp_t _frames, - virtual bool play( const TimePos & _start, const fpp_t _frames, const f_cnt_t _frame_base, int _clip_num = -1 ) override; - TrackView * createView( TrackContainerView* tcv ) override; + gui::TrackView * createView( gui::TrackContainerView* tcv ) override; Clip* createClip(const TimePos & pos) override; - virtual void saveTrackSpecificSettings( QDomDocument & _doc, + void saveTrackSpecificSettings( QDomDocument & _doc, QDomElement & _parent ) override; void loadTrackSpecificSettings( const QDomElement & _this ) override; @@ -83,12 +94,14 @@ protected: private: QList m_disabledTracks; - typedef QMap infoMap; + using infoMap = QMap; static infoMap s_infoMap; - friend class PatternTrackView; + friend class gui::PatternTrackView; } ; +} // namespace lmms + #endif diff --git a/include/PatternTrackView.h b/include/PatternTrackView.h index ecc209f04..b6d33e444 100644 --- a/include/PatternTrackView.h +++ b/include/PatternTrackView.h @@ -29,7 +29,14 @@ #include "TrackView.h" +namespace lmms +{ + class PatternTrack; + +namespace gui +{ + class TrackLabelButton; @@ -38,7 +45,7 @@ class PatternTrackView : public TrackView Q_OBJECT public: PatternTrackView(PatternTrack* pt, TrackContainerView* tcv); - virtual ~PatternTrackView(); + ~PatternTrackView() override; bool close() override; @@ -59,4 +66,8 @@ private: +} // namespace gui + +} // namespace lmms + #endif diff --git a/include/PeakController.h b/include/PeakController.h index 341d4f47a..58d666dd0 100644 --- a/include/PeakController.h +++ b/include/PeakController.h @@ -30,10 +30,13 @@ class QWidget; +namespace lmms +{ + + class PeakControllerEffect; -typedef QVector PeakControllerEffectVector; - +using PeakControllerEffectVector = QVector; class LMMS_EXPORT PeakController : public Controller { @@ -43,7 +46,7 @@ public: PeakControllerEffect *_peak_effect = nullptr ); - virtual ~PeakController(); + ~PeakController() override; void saveSettings( QDomDocument & _doc, QDomElement & _this ) override; void loadSettings( const QDomElement & _this ) override; @@ -56,8 +59,8 @@ public: public slots: - ControllerDialog * createDialog( QWidget * _parent ) override; - void handleDestroyedEffect( ); + gui::ControllerDialog * createDialog( QWidget * _parent ) override; + void handleDestroyedEffect(); void updateCoeffs(); protected: @@ -80,14 +83,15 @@ private: bool m_coeffNeedsUpdate; } ; - +namespace gui +{ class PeakControllerDialog : public ControllerDialog { Q_OBJECT public: PeakControllerDialog( Controller * _controller, QWidget * _parent ); - virtual ~PeakControllerDialog(); + ~PeakControllerDialog() override = default; protected: void contextMenuEvent( QContextMenuEvent * _me ) override; @@ -96,6 +100,11 @@ protected: PeakController * m_peakController; -} ; +}; + + +} // namespace gui + +} // namespace lmms #endif diff --git a/include/PerfLog.h b/include/PerfLog.h index 5d1efc14c..b8cc35f45 100644 --- a/include/PerfLog.h +++ b/include/PerfLog.h @@ -28,6 +28,10 @@ #include #include +namespace lmms +{ + + /// \brief CPU time point /// /// Represents a point in CPU time (not wall-clock time) intended for measuring @@ -70,4 +74,7 @@ class PerfLogTimer PerfTime begin_time; }; + +} // namespace lmms + #endif diff --git a/include/Piano.h b/include/Piano.h index ece3abb06..531bb65a6 100644 --- a/include/Piano.h +++ b/include/Piano.h @@ -28,6 +28,10 @@ #include "Note.h" #include "Model.h" +namespace lmms +{ + + class InstrumentTrack; class MidiEventProcessor; @@ -40,17 +44,17 @@ public: BlackKey } ; - Piano( InstrumentTrack* track ); + Piano(InstrumentTrack* track); - void setKeyState( int key, bool state ); + void setKeyState(int key, bool state); - bool isKeyPressed( int key ) const + bool isKeyPressed(int key) const { return m_pressedKeys[key]; } - void handleKeyPress( int key, int midiVelocity = -1 ); - void handleKeyRelease( int key ); + void handleKeyPress(int key, int midiVelocity = -1); + void handleKeyRelease(int key); InstrumentTrack* instrumentTrack() const { @@ -71,16 +75,19 @@ public: static const unsigned int NumBlackKeys = 53; private: - static bool isValidKey( int key ) + static bool isValidKey(int key) { return key >= 0 && key < NumKeys; } InstrumentTrack* m_instrumentTrack; MidiEventProcessor* m_midiEvProc; - bool m_pressedKeys[NumKeys]; + std::array m_pressedKeys = {}; } ; + +} // namespace lmms + #endif diff --git a/include/PianoRoll.h b/include/PianoRoll.h index f00e8a79c..c1973f407 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -47,13 +47,23 @@ class QString; class QMenu; class QToolButton; -class ComboBox; +namespace lmms +{ + + class NotePlayHandle; class MidiClip; + + +namespace gui +{ + +class ComboBox; class PositionLine; class TextFloat; class TimeLineWidget; + class PianoRoll : public QWidget { Q_OBJECT @@ -186,8 +196,8 @@ protected slots: bool toggleStepRecording(); void stop(); - void startRecordNote( const Note & n ); - void finishRecordNote( const Note & n ); + void startRecordNote( const lmms::Note & n ); + void finishRecordNote( const lmms::Note & n ); void horScrolled( int new_pos ); void verScrolled( int new_pos ); @@ -199,23 +209,23 @@ protected slots: void pasteNotes(); bool deleteSelectedNotes(); - void updatePosition(const TimePos & t ); - void updatePositionAccompany(const TimePos & t ); - void updatePositionStepRecording(const TimePos & t ); + void updatePosition(const lmms::TimePos & t ); + void updatePositionAccompany(const lmms::TimePos & t ); + void updatePositionStepRecording(const lmms::TimePos & t ); void zoomingChanged(); void zoomingYChanged(); void quantizeChanged(); void noteLengthChanged(); void keyChanged(); - void quantizeNotes(QuantizeActions mode = QuantizeBoth); + void quantizeNotes(lmms::gui::PianoRoll::QuantizeActions mode = QuantizeBoth); void updateSemiToneMarkerMenu(); void changeNoteEditMode( int i ); void markSemiTone(int i, bool fromMenu = true); - void hideMidiClip( MidiClip* clip ); + void hideMidiClip( lmms::MidiClip* clip ); void selectRegionFromPixels( int xStart, int xEnd ); @@ -288,7 +298,7 @@ private: PianoRoll(); PianoRoll( const PianoRoll & ); - virtual ~PianoRoll(); + ~PianoRoll() override = default; void autoScroll(const TimePos & t ); @@ -333,7 +343,7 @@ private: static QPixmap * s_toolOpen; static QPixmap* s_toolKnife; - static PianoRollKeyTypes prKeyOrder[]; + static std::array prKeyOrder; static TextFloat * s_textFloat; @@ -484,7 +494,7 @@ private: QBrush m_blackKeyDisabledBackground; signals: - void positionChanged( const TimePos & ); + void positionChanged( const lmms::TimePos & ); } ; @@ -559,4 +569,8 @@ private: }; +} // namespace gui + +} // namespace lmms + #endif diff --git a/include/PianoView.h b/include/PianoView.h index 888549431..7f586809d 100644 --- a/include/PianoView.h +++ b/include/PianoView.h @@ -31,15 +31,20 @@ #include "AutomatableModel.h" #include "ModelView.h" +namespace lmms +{ + class Piano; +namespace gui +{ class PianoView : public QWidget, public ModelView { Q_OBJECT public: PianoView( QWidget * _parent ); - virtual ~PianoView() = default; + ~PianoView() override = default; static int getKeyFromKeyEvent( QKeyEvent * _ke ); @@ -94,4 +99,8 @@ signals: } ; +} // namespace gui + +} // namespace lmms + #endif diff --git a/include/Pitch.h b/include/Pitch.h index 17de48b94..6213ef374 100644 --- a/include/Pitch.h +++ b/include/Pitch.h @@ -27,11 +27,17 @@ #include -typedef int16_t pitch_t; +namespace lmms +{ + +using pitch_t = int16_t; constexpr pitch_t CentsPerSemitone = 100; constexpr pitch_t MinPitchDefault = -CentsPerSemitone; constexpr pitch_t MaxPitchDefault = CentsPerSemitone; constexpr pitch_t DefaultPitch = 0; + +} // namespace lmms + #endif diff --git a/include/PixmapButton.h b/include/PixmapButton.h index e2fb58885..6c37f9112 100644 --- a/include/PixmapButton.h +++ b/include/PixmapButton.h @@ -30,6 +30,9 @@ #include "AutomatableButton.h" +namespace lmms::gui +{ + class LMMS_EXPORT PixmapButton : public AutomatableButton { @@ -37,7 +40,7 @@ class LMMS_EXPORT PixmapButton : public AutomatableButton public: PixmapButton( QWidget * _parent, const QString & _name = QString() ); - virtual ~PixmapButton(); + ~PixmapButton() override = default; void setActiveGraphic( const QPixmap & _pm ); void setInactiveGraphic( const QPixmap & _pm, bool _update = true ); @@ -62,4 +65,7 @@ private: } ; + +} // namespace lmms::gui + #endif diff --git a/include/PlayHandle.h b/include/PlayHandle.h index 6de358acd..542d45871 100644 --- a/include/PlayHandle.h +++ b/include/PlayHandle.h @@ -36,6 +36,9 @@ class QThread; +namespace lmms +{ + class Track; class AudioPort; @@ -49,7 +52,7 @@ public: TypeSamplePlayHandle = 0x04, TypePresetPreviewHandle = 0x08 } ; - typedef Types Type; + using Type = Types; enum { @@ -158,9 +161,9 @@ private: AudioPort * m_audioPort; } ; +using PlayHandleList = QList; +using ConstPlayHandleList = QList; -typedef QList PlayHandleList; -typedef QList ConstPlayHandleList; - +} // namespace lmms #endif diff --git a/include/Plugin.h b/include/Plugin.h index fb9ebd567..6a4d95bb4 100644 --- a/include/Plugin.h +++ b/include/Plugin.h @@ -35,9 +35,18 @@ class QWidget; -class PixmapLoader; -class PluginView; +namespace lmms +{ + class AutomatableModel; +class PixmapLoader; + +namespace gui +{ + +class PluginView; + +} /** Abstract representation of a plugin @@ -127,7 +136,7 @@ public: */ struct Key { - typedef QMap AttributeMap; + using AttributeMap = QMap; inline Key( const Plugin::Descriptor * desc = nullptr, const QString & name = QString(), @@ -170,17 +179,14 @@ public: const PixmapLoader* logo() const; } ; - typedef QList KeyList; - + using KeyList = QList; SubPluginFeatures( Plugin::PluginTypes type ) : m_type( type ) { } - virtual ~SubPluginFeatures() - { - } + virtual ~SubPluginFeatures() = default; virtual void fillDescriptionWidget( QWidget *, const Key * ) const { @@ -228,14 +234,14 @@ public: } ; // typedef a list so we can easily work with list of plugin descriptors - typedef QList DescriptorList; + using DescriptorList = QList; //! Constructor of a plugin //! @param key Sub plugins must pass a key here, optional otherwise. //! See the key() function Plugin(const Descriptor * descriptor, Model * parent, const Descriptor::SubPluginFeatures::Key *key = nullptr); - virtual ~Plugin(); + ~Plugin() override = default; //! Return display-name out of sub plugin or descriptor QString displayName() const override; @@ -244,7 +250,7 @@ public: const PixmapLoader *logo() const; //! Return plugin type - inline PluginTypes type( void ) const + inline PluginTypes type() const { return m_descriptor->type; } @@ -286,11 +292,11 @@ public: static Plugin * instantiate(const QString& pluginName, Model * parent, void *data); //! Create a view for the model - PluginView * createView( QWidget * parent ); + gui::PluginView * createView( QWidget * parent ); protected: //! Create a view for the model - virtual PluginView* instantiateView( QWidget * ) = 0; + virtual gui::PluginView* instantiateView( QWidget * ) = 0; void collectErrorForUI( QString errMsg ); @@ -300,9 +306,10 @@ private: Descriptor::SubPluginFeatures::Key m_key; // pointer to instantiation-function in plugin - typedef Plugin * ( * InstantiationHook )( Model * , void * ); - + using InstantiationHook = Plugin* (*)(Model*, void*); } ; +} // namespace lmms + #endif diff --git a/include/PluginBrowser.h b/include/PluginBrowser.h index 9c74ed643..1f2041cf4 100644 --- a/include/PluginBrowser.h +++ b/include/PluginBrowser.h @@ -33,13 +33,15 @@ class QLineEdit; class QTreeWidget; +namespace lmms::gui +{ class PluginBrowser : public SideBarWidget { Q_OBJECT public: PluginBrowser( QWidget * _parent ); - virtual ~PluginBrowser() = default; + ~PluginBrowser() override = default; private slots: void onFilterChanged( const QString & filter ); @@ -60,7 +62,7 @@ class PluginDescWidget : public QWidget { Q_OBJECT public: - typedef Plugin::Descriptor::SubPluginFeatures::Key PluginKey; + using PluginKey = Plugin::Descriptor::SubPluginFeatures::Key; PluginDescWidget( const PluginKey & _pk, QWidget * _parent ); QString name() const; @@ -81,4 +83,6 @@ private: }; +} // namespace lmms::gui + #endif diff --git a/include/PluginFactory.h b/include/PluginFactory.h index 80627f351..8b8b88b6e 100644 --- a/include/PluginFactory.h +++ b/include/PluginFactory.h @@ -38,6 +38,9 @@ class QLibrary; +namespace lmms +{ + class LMMS_EXPORT PluginFactory { public: @@ -50,11 +53,11 @@ public: bool isNull() const {return ! library;} }; - typedef QList PluginInfoList; - typedef QMultiMap DescriptorMap; + using PluginInfoList = QList; + using DescriptorMap = QMultiMap; PluginFactory(); - ~PluginFactory(); + ~PluginFactory() = default; static void setupSearchPaths(); @@ -105,4 +108,7 @@ private: //Short-hand function LMMS_EXPORT PluginFactory* getPluginFactory(); + +} // namespace lmms + #endif // PLUGINFACTORY_H diff --git a/include/PluginIssue.h b/include/PluginIssue.h index 8bfad5bf1..f0fa275f3 100644 --- a/include/PluginIssue.h +++ b/include/PluginIssue.h @@ -28,6 +28,10 @@ #include #include + +namespace lmms +{ + //! Types of issues that can cause LMMS to not load a plugin //! LMMS Plugins should use this to indicate errors enum PluginIssueType @@ -79,4 +83,7 @@ public: QDebug operator<<(QDebug stream, const PluginIssue& iss); +} // namespace lmms + + #endif // PLUGINISSUE_H diff --git a/include/PluginView.h b/include/PluginView.h index 476d65acf..2c06b9ba2 100644 --- a/include/PluginView.h +++ b/include/PluginView.h @@ -30,6 +30,8 @@ #include "Plugin.h" #include "ModelView.h" +namespace lmms::gui +{ class LMMS_EXPORT PluginView : public QWidget, public ModelView { @@ -43,4 +45,6 @@ public: } ; +} // namespace lmms::gui + #endif diff --git a/include/PositionLine.h b/include/PositionLine.h index e9ec8c3d5..cc1313e57 100644 --- a/include/PositionLine.h +++ b/include/PositionLine.h @@ -28,6 +28,9 @@ #include +namespace lmms::gui +{ + class PositionLine : public QWidget { Q_OBJECT @@ -46,4 +49,6 @@ private: QColor m_lineColor; }; +} // namespace lmms::gui + #endif diff --git a/include/PresetPreviewPlayHandle.h b/include/PresetPreviewPlayHandle.h index fcdecf6b8..dfff0fc21 100644 --- a/include/PresetPreviewPlayHandle.h +++ b/include/PresetPreviewPlayHandle.h @@ -28,6 +28,9 @@ #include "NotePlayHandle.h" +namespace lmms +{ + class DataFile; class InstrumentTrack; @@ -37,7 +40,7 @@ class LMMS_EXPORT PresetPreviewPlayHandle : public PlayHandle { public: PresetPreviewPlayHandle( const QString& presetFile, bool loadByPlugin = false, DataFile *dataFile = 0 ); - virtual ~PresetPreviewPlayHandle(); + ~PresetPreviewPlayHandle() override; inline bool affinityMatters() const override { @@ -64,4 +67,6 @@ private: } ; +} // namespace lmms + #endif diff --git a/include/ProjectJournal.h b/include/ProjectJournal.h index f8b9e642b..31a61755d 100644 --- a/include/ProjectJournal.h +++ b/include/ProjectJournal.h @@ -31,6 +31,11 @@ #include "lmms_basics.h" #include "DataFile.h" + +namespace lmms +{ + + class JournallingObject; @@ -41,7 +46,7 @@ public: static const int MAX_UNDO_STATES; ProjectJournal(); - virtual ~ProjectJournal(); + virtual ~ProjectJournal() = default; void undo(); void redo(); @@ -95,7 +100,7 @@ public: private: - typedef QHash JoIdMap; + using JoIdMap = QHash; struct CheckPoint { @@ -107,7 +112,7 @@ private: jo_id_t joID; DataFile data; } ; - typedef QStack CheckPointStack; + using CheckPointStack = QStack; JoIdMap m_joIDs; @@ -119,5 +124,7 @@ private: } ; +} // namespace lmms + #endif diff --git a/include/ProjectNotes.h b/include/ProjectNotes.h index 03add4b04..4b9476616 100644 --- a/include/ProjectNotes.h +++ b/include/ProjectNotes.h @@ -35,13 +35,16 @@ class QComboBox; class QTextCharFormat; class QTextEdit; +namespace lmms::gui +{ + class LMMS_EXPORT ProjectNotes : public QMainWindow, public SerializingObject { Q_OBJECT public: ProjectNotes(); - virtual ~ProjectNotes(); + ~ProjectNotes() override = default; void clear(); void setText( const QString & _text ); @@ -89,4 +92,6 @@ private: } ; +} // namespace lmms::gui + #endif diff --git a/include/ProjectRenderer.h b/include/ProjectRenderer.h index ce5d6af3c..2ca20569b 100644 --- a/include/ProjectRenderer.h +++ b/include/ProjectRenderer.h @@ -32,6 +32,10 @@ #include "lmms_export.h" +namespace lmms +{ + + class LMMS_EXPORT ProjectRenderer : public QThread { Q_OBJECT @@ -60,7 +64,7 @@ public: const OutputSettings & _os, ExportFileFormats _file_format, const QString & _out_file ); - virtual ~ProjectRenderer(); + ~ProjectRenderer() override = default; bool isReady() const { @@ -72,7 +76,7 @@ public: static QString getFileExtensionFromFormat( ExportFileFormats fmt ); - static const FileEncodeDevice fileEncodeDevices[]; + static const std::array fileEncodeDevices; public slots: void startProcessing(); @@ -96,4 +100,7 @@ private: } ; + +} // namespace lmms + #endif diff --git a/include/ProjectVersion.h b/include/ProjectVersion.h index d72704ba3..5be259c97 100644 --- a/include/ProjectVersion.h +++ b/include/ProjectVersion.h @@ -32,6 +32,10 @@ #include +namespace lmms +{ + + /*! \brief Version number parsing and comparison * * Parses and compares version information. i.e. "1.0.3" < "1.0.10" @@ -75,4 +79,7 @@ inline bool operator>=(const ProjectVersion & v1, const ProjectVersion & v2) { r inline bool operator==(const ProjectVersion & v1, const ProjectVersion & v2) { return ProjectVersion::compare(v1, v2) == 0; } inline bool operator!=(const ProjectVersion & v1, const ProjectVersion & v2) { return ProjectVersion::compare(v1, v2) != 0; } + +} // namespace lmms + #endif diff --git a/include/QuadratureLfo.h b/include/QuadratureLfo.h index b530937b0..42d4d32c0 100644 --- a/include/QuadratureLfo.h +++ b/include/QuadratureLfo.h @@ -27,6 +27,10 @@ #include "lmms_math.h" +namespace lmms +{ + + class QuadratureLfo { public: @@ -93,4 +97,7 @@ private: }; + +} // namespace lmms + #endif // QUADRATURELFO_H diff --git a/include/RaiiHelpers.h b/include/RaiiHelpers.h index bebd91ff9..0cfa2c4ac 100644 --- a/include/RaiiHelpers.h +++ b/include/RaiiHelpers.h @@ -27,6 +27,10 @@ #include #include + +namespace lmms +{ + template class NullableResource { @@ -57,4 +61,6 @@ struct NullableResourceDeleter template using UniqueNullableResource = std::unique_ptr>; +} // namespace lmms + #endif // RAII_HELPERS_H diff --git a/include/RecentProjectsMenu.h b/include/RecentProjectsMenu.h index b3837ee2e..ac3638298 100644 --- a/include/RecentProjectsMenu.h +++ b/include/RecentProjectsMenu.h @@ -1,8 +1,36 @@ +/* + * RecentProjectsMenu.h + * + * Copyright (c) 2004-2022 Tobias Doerffel + * + * This file is part of LMMS - https://lmms.io + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + #ifndef RECENTPROJECTSMENU_H #define RECENTPROJECTSMENU_H #include +namespace lmms::gui +{ + + class RecentProjectsMenu : public QMenu { Q_OBJECT @@ -14,4 +42,7 @@ private slots: void openProject(QAction * _action ); }; + +} // namespace lmms::gui + #endif // RECENTPROJECTSMENU_H diff --git a/include/RemotePlugin.h b/include/RemotePlugin.h index 615cce2c8..96c910d5d 100644 --- a/include/RemotePlugin.h +++ b/include/RemotePlugin.h @@ -28,6 +28,14 @@ #include "RemotePluginBase.h" #include "SharedMemory.h" +#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0)) + #include +#endif + +namespace lmms +{ + + class RemotePlugin; class ProcessWatcher : public QThread @@ -35,7 +43,7 @@ class ProcessWatcher : public QThread Q_OBJECT public: ProcessWatcher( RemotePlugin * ); - virtual ~ProcessWatcher() = default; + ~ProcessWatcher() override = default; void stop() { @@ -62,7 +70,7 @@ class LMMS_EXPORT RemotePlugin : public QObject, public RemotePluginBase Q_OBJECT public: RemotePlugin(); - virtual ~RemotePlugin(); + ~RemotePlugin() override; inline bool isRunning() { @@ -70,7 +78,7 @@ public: return true; #else return m_process.state() != QProcess::NotRunning; -#endif +#endif // DEBUG_REMOTE_PLUGIN } bool init( const QString &pluginExecutable, bool waitForInitDoneMsg, QStringList extraArgs = {} ); @@ -154,7 +162,11 @@ private: QString m_exec; QStringList m_args; +#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0)) + QRecursiveMutex m_commMutex; +#else QMutex m_commMutex; +#endif bool m_splitChannels; SharedMemory m_audioBuffer; @@ -166,7 +178,7 @@ private: #ifndef SYNC_WITH_SHM_FIFO int m_server; QString m_socketFile; -#endif +#endif // not SYNC_WITH_SHM_FIFO friend class ProcessWatcher; @@ -176,9 +188,13 @@ private slots: void processErrored(QProcess::ProcessError err ); } ; + LMMS_EXPORT inline std::string QSTR_TO_STDSTR(QString const& qstr) { return qstr.toStdString(); } + +} // namespace lmms + #endif // REMOTE_PLUGIN_H diff --git a/include/RemotePluginBase.h b/include/RemotePluginBase.h index a5646ad11..e309496bc 100644 --- a/include/RemotePluginBase.h +++ b/include/RemotePluginBase.h @@ -26,7 +26,6 @@ #define REMOTE_PLUGIN_BASE_H #include "MidiEvent.h" -#include "VstSyncData.h" #include #include @@ -38,7 +37,6 @@ #if !(defined(LMMS_HAVE_SYS_IPC_H) && defined(LMMS_HAVE_SEMAPHORE_H)) #define SYNC_WITH_SHM_FIFO -#define USE_QT_SEMAPHORES #ifdef LMMS_HAVE_PROCESS_H #include @@ -47,11 +45,11 @@ #include #include #include -#else +#else // !(LMMS_HAVE_SYS_IPC_H && LMMS_HAVE_SEMAPHORE_H) #ifdef LMMS_HAVE_UNISTD_H #include #endif -#endif +#endif // !(LMMS_HAVE_SYS_IPC_H && LMMS_HAVE_SEMAPHORE_H) #ifdef LMMS_HAVE_LOCALE_H #include @@ -69,9 +67,9 @@ #ifndef SYNC_WITH_SHM_FIFO #include #include -#endif +#endif // SYNC_WITH_SHM_FIFO -#else +#else // BUILD_REMOTE_PLUGIN_CLIENT #include "lmms_export.h" #include #include @@ -81,13 +79,20 @@ #ifndef SYNC_WITH_SHM_FIFO #include #include +#endif // SYNC_WITH_SHM_FIFO + +#endif // BUILD_REMOTE_PLUGIN_CLIENT + +#ifdef SYNC_WITH_SHM_FIFO +#include "SharedMemory.h" #endif -#endif +namespace lmms +{ + #ifdef SYNC_WITH_SHM_FIFO -#include "SharedMemory.h" // sometimes we need to exchange bigger messages (e.g. for VST parameter dumps) // so set a usable value here @@ -336,7 +341,7 @@ private: std::atomic_int m_lockDepth; } ; -#endif +#endif // SYNC_WITH_SHM_FIFO @@ -346,6 +351,7 @@ enum RemoteMessageIDs IdHostInfoGotten, IdInitDone, IdQuit, + IdSyncKey, IdSampleRateInformation, IdBufferSizeInformation, IdInformationUpdated, @@ -384,11 +390,7 @@ public: { } - message( const message & _m ) : - id( _m.id ), - data( _m.data ) - { - } + message( const message & _m ) = default; message( int _id ) : id( _id ), @@ -406,7 +408,7 @@ public: { char buf[32]; sprintf( buf, "%d", _i ); - data.push_back( std::string( buf ) ); + data.emplace_back( buf ); return *this; } @@ -414,7 +416,7 @@ public: { char buf[32]; sprintf( buf, "%f", _f ); - data.push_back( std::string( buf ) ); + data.emplace_back( buf ); return *this; } @@ -528,7 +530,7 @@ public: writeInt( len ); write( _s.c_str(), len ); } -#endif +#endif // SYNC_WITH_SHM_FIFO #ifndef BUILD_REMOTE_PLUGIN_CLIENT inline bool messagesLeft() @@ -560,7 +562,7 @@ public: { return waitDepthCounter() > 0; } -#endif +#endif // BUILD_REMOTE_PLUGIN_CLIENT virtual bool processMessage( const message & _m ) = 0; @@ -665,8 +667,10 @@ private: pthread_mutex_t m_receiveMutex; pthread_mutex_t m_sendMutex; -#endif +#endif // SYNC_WITH_SHM_FIFO } ; +} // namespace lmms + #endif // REMOTE_PLUGIN_BASE_H diff --git a/include/RemotePluginClient.h b/include/RemotePluginClient.h index 94f05af0f..4c5fcc060 100644 --- a/include/RemotePluginClient.h +++ b/include/RemotePluginClient.h @@ -39,6 +39,10 @@ #endif #include "SharedMemory.h" +#include "VstSyncData.h" + +namespace lmms +{ class RemotePluginClient : public RemotePluginBase { @@ -48,11 +52,11 @@ public: #else RemotePluginClient( const char * socketPath ); #endif - virtual ~RemotePluginClient(); + ~RemotePluginClient() override; const VstSyncData* getVstSyncData(); - virtual bool processMessage( const message & _m ); + bool processMessage( const message & _m ) override; virtual void process( const sampleFrame * _in_buf, sampleFrame * _out_buf ) = 0; @@ -121,8 +125,7 @@ private: void doProcessing(); SharedMemory m_audioBuffer; - SharedMemory m_vstSyncShm; - const VstSyncData* m_vstSyncData; + SharedMemory m_vstSyncData; int m_inputCount; int m_outputCount; @@ -170,7 +173,7 @@ private: std::condition_variable m_cv; std::thread m_thread; }; -#endif +#endif // LMMS_BUILD_WIN32 #ifdef SYNC_WITH_SHM_FIFO RemotePluginClient::RemotePluginClient( const std::string& _shm_in, const std::string& _shm_out ) : @@ -179,7 +182,6 @@ RemotePluginClient::RemotePluginClient( const std::string& _shm_in, const std::s RemotePluginClient::RemotePluginClient( const char * socketPath ) : RemotePluginBase(), #endif - m_vstSyncData( nullptr ), m_inputCount( 0 ), m_outputCount( 0 ), m_sampleRate( 44100 ), @@ -208,26 +210,6 @@ RemotePluginClient::RemotePluginClient( const char * socketPath ) : fprintf( stderr, "Could not connect to local server.\n" ); } #endif - - try - { - m_vstSyncShm.attach("usr_bin_lmms"); - m_vstSyncData = m_vstSyncShm.get(); - m_bufferSize = m_vstSyncData->m_bufferSize; - m_sampleRate = m_vstSyncData->m_sampleRate; - } - catch (const std::runtime_error&) - { - // if attaching shared memory fails - sendMessage( IdSampleRateInformation ); - sendMessage( IdBufferSizeInformation ); - if( waitForMessage( IdBufferSizeInformation ).id - != IdBufferSizeInformation ) - { - fprintf( stderr, "Could not get buffer size information\n" ); - } - } - sendMessage( IdHostInfoGotten ); } @@ -250,7 +232,7 @@ RemotePluginClient::~RemotePluginClient() const VstSyncData* RemotePluginClient::getVstSyncData() { - return m_vstSyncData; + return m_vstSyncData.get(); } @@ -265,6 +247,22 @@ bool RemotePluginClient::processMessage( const message & _m ) case IdUndefined: return false; + case IdSyncKey: + try + { + m_vstSyncData.attach(_m.getString(0)); + } + catch (const std::runtime_error& error) + { + debugMessage(std::string{"Failed to attach sync data: "} + error.what() + '\n'); + std::exit(EXIT_FAILURE); + } + m_bufferSize = m_vstSyncData->m_bufferSize; + m_sampleRate = m_vstSyncData->m_sampleRate; + reply_message.id = IdHostInfoGotten; + reply = true; + break; + case IdSampleRateInformation: m_sampleRate = _m.getInt(); updateSampleRate(); @@ -355,4 +353,6 @@ void RemotePluginClient::doProcessing() } +} // namespace lmms + #endif // REMOTE_PLUGIN_CLIENT_H diff --git a/include/RenameDialog.h b/include/RenameDialog.h index 8f526badd..b543963d7 100644 --- a/include/RenameDialog.h +++ b/include/RenameDialog.h @@ -32,13 +32,15 @@ class QLineEdit; +namespace lmms::gui +{ class RenameDialog : public QDialog { Q_OBJECT public: RenameDialog( QString & _string ); - ~RenameDialog(); + ~RenameDialog() override = default; protected: @@ -58,4 +60,6 @@ private: } ; +} // namespace lmms::gui + #endif diff --git a/include/RenderManager.h b/include/RenderManager.h index 935983702..9ec4c511e 100644 --- a/include/RenderManager.h +++ b/include/RenderManager.h @@ -32,6 +32,10 @@ #include "OutputSettings.h" +namespace lmms +{ + + class RenderManager : public QObject { Q_OBJECT @@ -42,7 +46,7 @@ public: ProjectRenderer::ExportFileFormats fmt, QString outputPath); - virtual ~RenderManager(); + ~RenderManager() override; /// Export all unmuted tracks into a single file void renderProject(); @@ -78,4 +82,7 @@ private: QVector m_unmuted; } ; + +} // namespace lmms + #endif diff --git a/include/RingBuffer.h b/include/RingBuffer.h index 46539c0ea..c7db6b4e5 100644 --- a/include/RingBuffer.h +++ b/include/RingBuffer.h @@ -32,6 +32,11 @@ #include "lmms_basics.h" #include "MemoryManager.h" + +namespace lmms +{ + + /** \brief A basic LMMS ring buffer for single-thread use. For thread and realtime safe alternative see LocklessRingBuffer. */ class LMMS_EXPORT RingBuffer : public QObject @@ -48,7 +53,7 @@ public: * \param size The size of the buffer in milliseconds. The actual size will be size + period size */ RingBuffer( float size ); - virtual ~RingBuffer(); + ~RingBuffer() override; @@ -216,4 +221,8 @@ private: volatile unsigned int m_position; }; + + +} // namespace lmms + #endif diff --git a/include/RmsHelper.h b/include/RmsHelper.h index f5f2770fa..19b7da89c 100644 --- a/include/RmsHelper.h +++ b/include/RmsHelper.h @@ -28,6 +28,11 @@ #include "lmms_math.h" + +namespace lmms +{ + + class RmsHelper { public: @@ -91,4 +96,6 @@ private: }; +} // namespace lmms + #endif diff --git a/include/RowTableView.h b/include/RowTableView.h index a7b07c2c8..9934dbade 100644 --- a/include/RowTableView.h +++ b/include/RowTableView.h @@ -27,6 +27,9 @@ #include +namespace lmms::gui +{ + class RowDelegate; @@ -36,7 +39,7 @@ class RowTableView : public QTableView Q_OBJECT public: RowTableView( QWidget * parent = 0 ); - virtual ~RowTableView(); + ~RowTableView() override; void setModel( QAbstractItemModel * model ) override; @@ -51,5 +54,6 @@ private: } ; +} // namespace lmms::gui #endif diff --git a/include/Rubberband.h b/include/Rubberband.h index 21e699d85..d35233b4f 100644 --- a/include/Rubberband.h +++ b/include/Rubberband.h @@ -30,6 +30,9 @@ #include #include +namespace lmms::gui +{ + class selectableObject : public QWidget { @@ -41,9 +44,7 @@ public: { } - virtual ~selectableObject() - { - } + ~selectableObject() override = default; inline void setSelected(bool selected) { @@ -77,7 +78,7 @@ class RubberBand : public QRubberBand { public: RubberBand( QWidget * _parent ); - virtual ~RubberBand(); + ~RubberBand() override = default; QVector selectedObjects() const; QVector selectableObjects() const; @@ -91,5 +92,7 @@ private: }; +} // namespace lmms::gui + #endif diff --git a/include/SampleBuffer.h b/include/SampleBuffer.h index 991d9d140..f4d67859e 100644 --- a/include/SampleBuffer.h +++ b/include/SampleBuffer.h @@ -44,6 +44,9 @@ class QPainter; class QRect; +namespace lmms +{ + // values for buffer margins, used for various libsamplerate interpolation modes // the array positions correspond to the converter_type parameter values in libsamplerate // if there appears problems with playback on some interpolation mode, then the value for that mode @@ -116,7 +119,7 @@ public: friend void swap(SampleBuffer & first, SampleBuffer & second) noexcept; SampleBuffer& operator= (const SampleBuffer that); - virtual ~SampleBuffer(); + ~SampleBuffer() override; bool play( sampleFrame * ab, @@ -281,8 +284,8 @@ public: public slots: void setAudioFile(const QString & audioFile); void loadFromBase64(const QString & data); - void setStartFrame(const f_cnt_t s); - void setEndFrame(const f_cnt_t e); + void setStartFrame(const lmms::f_cnt_t s); + void setEndFrame(const lmms::f_cnt_t e); void setAmplification(float a); void setReversed(bool on); void sampleRateChanged(); @@ -351,5 +354,6 @@ signals: } ; +} // namespace lmms #endif diff --git a/include/SampleClip.h b/include/SampleClip.h index 7c4f9cf60..51225ded8 100644 --- a/include/SampleClip.h +++ b/include/SampleClip.h @@ -27,8 +27,18 @@ #include "Clip.h" +namespace lmms +{ + class SampleBuffer; +namespace gui +{ + +class SampleClipView; + +} // namespace gui + class SampleClip : public Clip { @@ -37,7 +47,7 @@ class SampleClip : public Clip public: SampleClip( Track * _track ); SampleClip( const SampleClip& orig ); - virtual ~SampleClip(); + ~SampleClip() override; SampleClip& operator=( const SampleClip& that ) = delete; @@ -59,14 +69,14 @@ public: TimePos sampleLength() const; void setSampleStartFrame( f_cnt_t startFrame ); void setSamplePlayLength( f_cnt_t length ); - ClipView * createView( TrackView * _tv ) override; + gui::ClipView * createView( gui::TrackView * _tv ) override; bool isPlaying() const; void setIsPlaying(bool isPlaying); public slots: - void setSampleBuffer( SampleBuffer* sb ); + void setSampleBuffer( lmms::SampleBuffer* sb ); void setSampleFile( const QString & _sf ); void updateLength(); void toggleRecord(); @@ -79,7 +89,7 @@ private: BoolModel m_recordModel; bool m_isPlaying; - friend class SampleClipView; + friend class gui::SampleClipView; signals: @@ -88,5 +98,6 @@ signals: } ; +} // namespace lmms #endif diff --git a/include/SampleClipView.h b/include/SampleClipView.h index c18e6ab5a..74873dca7 100644 --- a/include/SampleClipView.h +++ b/include/SampleClipView.h @@ -27,15 +27,24 @@ #include "ClipView.h" + + +namespace lmms +{ + class SampleClip; +namespace gui +{ + + class SampleClipView : public ClipView { Q_OBJECT public: SampleClipView( SampleClip * _clip, TrackView * _tv ); - virtual ~SampleClipView() = default; + ~SampleClipView() override = default; public slots: void updateSample(); @@ -60,5 +69,8 @@ private: } ; +} // namespace gui + +} // namespace lmms #endif diff --git a/include/SamplePlayHandle.h b/include/SamplePlayHandle.h index 04360a26e..69ee3b38d 100644 --- a/include/SamplePlayHandle.h +++ b/include/SamplePlayHandle.h @@ -30,6 +30,10 @@ #include "AutomatableModel.h" #include "PlayHandle.h" +namespace lmms +{ + + class PatternTrack; class SampleClip; class Track; @@ -42,7 +46,7 @@ public: SamplePlayHandle( SampleBuffer* sampleBuffer , bool ownAudioPort = true ); SamplePlayHandle( const QString& sampleFile ); SamplePlayHandle( SampleClip* clip ); - virtual ~SamplePlayHandle(); + ~SamplePlayHandle() override; inline bool affinityMatters() const override { @@ -94,4 +98,6 @@ private: } ; +} // namespace lmms + #endif diff --git a/include/SampleRecordHandle.h b/include/SampleRecordHandle.h index f5ebb2201..5b23f5345 100644 --- a/include/SampleRecordHandle.h +++ b/include/SampleRecordHandle.h @@ -32,6 +32,10 @@ #include "PlayHandle.h" #include "TimePos.h" +namespace lmms +{ + + class PatternTrack; class SampleBuffer; class SampleClip; @@ -42,7 +46,7 @@ class SampleRecordHandle : public PlayHandle { public: SampleRecordHandle( SampleClip* clip ); - virtual ~SampleRecordHandle(); + ~SampleRecordHandle() override; void play( sampleFrame * _working_buffer ) override; bool isFinished() const override; @@ -57,7 +61,7 @@ private: virtual void writeBuffer( const sampleFrame * _ab, const f_cnt_t _frames ); - typedef QList > bufferList; + using bufferList = QList>; bufferList m_buffers; f_cnt_t m_framesRecorded; TimePos m_minLength; @@ -69,4 +73,6 @@ private: } ; +} // namespace lmms + #endif diff --git a/include/SampleTrack.h b/include/SampleTrack.h index 5ca5741b8..8f424178a 100644 --- a/include/SampleTrack.h +++ b/include/SampleTrack.h @@ -30,20 +30,32 @@ #include "Track.h" +namespace lmms +{ + +namespace gui +{ + +class SampleTrackView; +class SampleTrackWindow; + +} // namespace gui + + class SampleTrack : public Track { Q_OBJECT public: SampleTrack( TrackContainer* tc ); - virtual ~SampleTrack(); + ~SampleTrack() override; - virtual bool play( const TimePos & _start, const fpp_t _frames, + bool play( const TimePos & _start, const fpp_t _frames, const f_cnt_t _frame_base, int _clip_num = -1 ) override; - TrackView * createView( TrackContainerView* tcv ) override; + gui::TrackView * createView( gui::TrackContainerView* tcv ) override; Clip* createClip(const TimePos & pos) override; - virtual void saveTrackSpecificSettings( QDomDocument & _doc, + void saveTrackSpecificSettings( QDomDocument & _doc, QDomElement & _parent ) override; void loadTrackSpecificSettings( const QDomElement & _this ) override; @@ -90,11 +102,12 @@ private: - friend class SampleTrackView; - friend class SampleTrackWindow; + friend class gui::SampleTrackView; + friend class gui::SampleTrackWindow; } ; +} // namespace lmms #endif \ No newline at end of file diff --git a/include/SampleTrackView.h b/include/SampleTrackView.h index 7d3e550c2..9921aa735 100644 --- a/include/SampleTrackView.h +++ b/include/SampleTrackView.h @@ -28,8 +28,16 @@ #include "TrackView.h" -class Knob; +namespace lmms +{ + class SampleTrack; + + +namespace gui +{ + +class Knob; class SampleTrackWindow; class TrackLabelButton; @@ -39,7 +47,7 @@ class SampleTrackView : public TrackView Q_OBJECT public: SampleTrackView( SampleTrack* Track, TrackContainerView* tcv ); - virtual ~SampleTrackView(); + ~SampleTrackView() override; SampleTrackWindow * getSampleTrackWindow() { @@ -97,5 +105,8 @@ private: } ; +} // namespace gui + +} // namespace lmms #endif \ No newline at end of file diff --git a/include/SampleTrackWindow.h b/include/SampleTrackWindow.h index 85c175564..d302b2c44 100644 --- a/include/SampleTrackWindow.h +++ b/include/SampleTrackWindow.h @@ -34,10 +34,14 @@ #include "SampleTrack.h" #include "SerializingObject.h" +class QLineEdit; + +namespace lmms::gui +{ + class EffectRackView; class Knob; class MixerLineLcdSpinBox; -class QLineEdit; class SampleTrackView; @@ -46,7 +50,7 @@ class SampleTrackWindow : public QWidget, public ModelView, public SerializingOb Q_OBJECT public: SampleTrackWindow(SampleTrackView * tv); - virtual ~SampleTrackWindow(); + ~SampleTrackWindow() override = default; SampleTrack * model() { @@ -96,4 +100,7 @@ private: +} // namespace lmms::gui + + #endif diff --git a/include/Scale.h b/include/Scale.h index a9321fe40..96159a53c 100644 --- a/include/Scale.h +++ b/include/Scale.h @@ -32,6 +32,9 @@ #include "SerializingObject.h" +namespace lmms +{ + class Interval : public SerializingObject { public: @@ -44,7 +47,7 @@ public: QString getString() const { if (m_denominator) {return QString::number(m_numerator) + "/" + QString::number(m_denominator);} - else {return QString().sprintf("%.4f", m_cents);} + else {return QString("%1").arg(m_cents, 0, 'f', 4);} } void saveSettings(QDomDocument &doc, QDomElement &element) override; @@ -83,4 +86,7 @@ private: }; + +} // namespace lmms + #endif diff --git a/include/SendButtonIndicator.h b/include/SendButtonIndicator.h index 33d8cac64..ec4a90db3 100644 --- a/include/SendButtonIndicator.h +++ b/include/SendButtonIndicator.h @@ -1,13 +1,44 @@ +/* + * SendButtonIndicator.h + * + * Copyright (c) 2014-2022 Tobias Doerffel + * + * This file is part of LMMS - https://lmms.io + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ #ifndef SENDBUTTONINDICATOR_H #define SENDBUTTONINDICATOR_H #include +namespace lmms +{ + class FloatModel; + +namespace gui +{ + class MixerLine; class MixerView; + class SendButtonIndicator : public QLabel { public: @@ -27,4 +58,9 @@ private: FloatModel * getSendModel(); }; + +} // namespace gui + +} // namespace lmms + #endif // SENDBUTTONINDICATOR_H diff --git a/include/SerializingObject.h b/include/SerializingObject.h index aba8c7b0f..e32d5d046 100644 --- a/include/SerializingObject.h +++ b/include/SerializingObject.h @@ -33,6 +33,9 @@ class QDomDocument; class QDomElement; +namespace lmms +{ + class SerializingObjectHook; @@ -96,5 +99,7 @@ private: } ; +} // namespace lmms + #endif diff --git a/include/SetupDialog.h b/include/SetupDialog.h index d0878e462..8973938bf 100644 --- a/include/SetupDialog.h +++ b/include/SetupDialog.h @@ -42,6 +42,11 @@ class QLabel; class QLineEdit; class QSlider; + +namespace lmms::gui +{ + + class TabBar; class SetupDialog : public QDialog @@ -59,7 +64,7 @@ public: }; SetupDialog(ConfigTabs tab_to_open = GeneralSettings); - virtual ~SetupDialog(); + ~SetupDialog() override; protected slots: @@ -90,7 +95,6 @@ private slots: void toggleRunningAutoSave(bool enabled); void toggleSmoothScroll(bool enabled); void toggleAnimateAFP(bool enabled); - void toggleSyncVSTPlugins(bool enabled); void vstEmbedMethodChanged(); void toggleVSTAlwaysOnTop(bool en); void toggleDisableAutoQuit(bool enabled); @@ -159,13 +163,11 @@ private: QString m_vstEmbedMethod; LedCheckBox * m_vstAlwaysOnTopCheckBox; bool m_vstAlwaysOnTop; - bool m_syncVSTPlugins; bool m_disableAutoQuit; - - typedef QMap AswMap; - typedef QMap MswMap; - typedef QMap trMap; + using AswMap = QMap; + using MswMap = QMap; + using trMap = QMap; // Audio settings widgets. QComboBox * m_audioInterfaces; @@ -208,4 +210,8 @@ private: QLabel * restartWarningLbl; }; + + +} // namespace lmms::gui + #endif diff --git a/include/SharedMemory.h b/include/SharedMemory.h index bc649110b..32a40ff25 100644 --- a/include/SharedMemory.h +++ b/include/SharedMemory.h @@ -28,7 +28,12 @@ #include #include -namespace detail { + +namespace lmms +{ + +namespace detail +{ class SharedMemoryImpl; @@ -67,6 +72,7 @@ private: } // namespace detail + template class SharedMemory { @@ -140,4 +146,6 @@ private: detail::SharedMemoryData m_data; }; +} // namespace lmms + #endif // SHARED_MEMORY_H diff --git a/include/SideBar.h b/include/SideBar.h index 7ed52efc3..8755c660a 100644 --- a/include/SideBar.h +++ b/include/SideBar.h @@ -30,6 +30,10 @@ #include class QToolButton; + +namespace lmms::gui +{ + class SideBarWidget; @@ -38,7 +42,7 @@ class SideBar : public QToolBar Q_OBJECT public: SideBar( Qt::Orientation _orientation, QWidget * _parent ); - virtual ~SideBar(); + ~SideBar() override = default; void appendTab( SideBarWidget * _sbw ); @@ -49,9 +53,11 @@ private slots: private: QButtonGroup m_btnGroup; - typedef QMap ButtonMap; + using ButtonMap = QMap; ButtonMap m_widgets; } ; +} // namespace lmms::gui + #endif diff --git a/include/SideBarWidget.h b/include/SideBarWidget.h index 95c6ab9ed..5df3ccb7a 100644 --- a/include/SideBarWidget.h +++ b/include/SideBarWidget.h @@ -31,6 +31,9 @@ class QPushButton; +namespace lmms::gui +{ + class SideBarWidget : public QWidget { @@ -38,7 +41,7 @@ class SideBarWidget : public QWidget public: SideBarWidget( const QString & _title, const QPixmap & _icon, QWidget * _parent ); - virtual ~SideBarWidget(); + ~SideBarWidget() override = default; inline const QPixmap & icon() const { @@ -84,4 +87,7 @@ private: } ; + +} // namespace lmms::gui + #endif diff --git a/include/Song.h b/include/Song.h index 88a491873..25288c1ff 100644 --- a/include/Song.h +++ b/include/Song.h @@ -38,13 +38,23 @@ #include "VstSyncController.h" #include "Groove.h" +namespace lmms +{ class AutomationTrack; +class Groove; class Keymap; class MidiClip; class Scale; + +namespace gui +{ + class TimeLineWidget; -class Groove; +class SongEditor; +class ControllerRackView; + +} const bpm_t MinTempo = 10; @@ -116,7 +126,7 @@ public: { return m_jumped; } - TimeLineWidget * m_timeLine; + gui::TimeLineWidget * m_timeLine; private: float m_currentFrame; @@ -364,12 +374,14 @@ public: void setScale(unsigned int index, std::shared_ptr newScale); void setKeymap(unsigned int index, std::shared_ptr newMap); + const std::string& syncKey() const noexcept { return m_vstSyncController.sharedMemoryKey(); } + public slots: void playSong(); void record(); void playAndRecord(); void playPattern(); - void playMidiClip( const MidiClip * midiClipToPlay, bool loop = true ); + void playMidiClip( const lmms::MidiClip * midiClipToPlay, bool loop = true ); void togglePause(); void stop(); void setPlayPos( tick_t ticks, PlayModes playMode ); @@ -405,7 +417,7 @@ private slots: private: Song(); Song( const Song & ); - virtual ~Song(); + ~Song() override; inline bar_t currentBar() const @@ -500,20 +512,19 @@ private: AutomatedValueMap m_oldAutomatedValues; - friend class LmmsCore; - friend class SongEditor; - friend class mainWindow; - friend class ControllerRackView; + friend class Engine; + friend class gui::SongEditor; + friend class gui::ControllerRackView; signals: void projectLoaded(); void playbackStateChanged(); void playbackPositionChanged(); void lengthChanged( int bars ); - void tempoChanged( bpm_t newBPM ); + void tempoChanged( lmms::bpm_t newBPM ); void timeSignatureChanged( int oldTicksPerBar, int ticksPerBar ); - void controllerAdded( Controller * ); - void controllerRemoved( Controller * ); + void controllerAdded( lmms::Controller * ); + void controllerRemoved( lmms::Controller * ); void updateSampleTracks(); void stopped(); void modified(); @@ -523,4 +534,6 @@ signals: } ; +} // namespace lmms + #endif diff --git a/include/SongEditor.h b/include/SongEditor.h index db52f7352..ea57cc125 100644 --- a/include/SongEditor.h +++ b/include/SongEditor.h @@ -34,14 +34,22 @@ class QLabel; class QScrollBar; +namespace lmms +{ + +class Song; +class ComboBoxModel; + +namespace gui +{ + + class ActionGroup; class AutomatableSlider; class ComboBox; -class ComboBoxModel; class LcdSpinBox; class MeterDialog; class PositionLine; -class Song; class TextFloat; class TimeLineWidget; @@ -58,7 +66,7 @@ public: }; SongEditor( Song * song ); - ~SongEditor(); + ~SongEditor() override = default; void saveSettings( QDomDocument& doc, QDomElement& element ) override; void loadSettings( const QDomElement& element ) override; @@ -74,13 +82,13 @@ public slots: void stopSelectRegion(); void updateRubberband(); - void setEditMode( EditMode mode ); + void setEditMode( lmms::gui::SongEditor::EditMode mode ); void setEditModeDraw(); void setEditModeKnife(); void setEditModeSelect(); void toggleProportionalSnap(); - void updatePosition( const TimePos & t ); + void updatePosition( const lmms::TimePos & t ); void updatePositionLine(); void selectAllClips( bool select ); @@ -215,4 +223,9 @@ private: QAction* m_removeBarAction; }; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/include/StepRecorder.h b/include/StepRecorder.h index 864faef4b..b89fadb15 100644 --- a/include/StepRecorder.h +++ b/include/StepRecorder.h @@ -28,18 +28,26 @@ #include "Note.h" -class MidiClip; -class PianoRoll; class QKeyEvent; class QMouseEvent; + +namespace lmms +{ + +class MidiClip; + +namespace gui +{ +class PianoRoll; class StepRecorderWidget; +} // namespace gui class StepRecorder : public QObject { Q_OBJECT public: - StepRecorder(PianoRoll& pianoRoll, StepRecorderWidget& stepRecorderWidget); + StepRecorder(gui::PianoRoll& pianoRoll, gui::StepRecorderWidget& stepRecorderWidget); void initialize(); void start(const TimePos& currentPosition,const TimePos& stepLength); @@ -81,8 +89,8 @@ class StepRecorder : public QObject bool allCurStepNotesReleased(); - PianoRoll& m_pianoRoll; - StepRecorderWidget& m_stepRecorderWidget; + gui::PianoRoll& m_pianoRoll; + gui::StepRecorderWidget& m_stepRecorderWidget; bool m_isRecording = false; TimePos m_curStepStartPos = 0; @@ -141,4 +149,7 @@ class StepRecorder : public QObject bool m_isStepInProgress = false; }; + +} // namespace lmms + #endif //STEP_RECORDER_H diff --git a/include/StepRecorderWidget.h b/include/StepRecorderWidget.h index 512ab5b35..4067b0001 100644 --- a/include/StepRecorderWidget.h +++ b/include/StepRecorderWidget.h @@ -28,6 +28,9 @@ #include "TimePos.h" +namespace lmms::gui +{ + class StepRecorderWidget : public QWidget { Q_OBJECT @@ -87,7 +90,9 @@ private: const int m_marginRight; signals: - void positionChanged(const TimePos & t); + void positionChanged(const lmms::TimePos & t); } ; +} // namespace lmms::gui + #endif //STEP_RECOREDER_WIDGET_H diff --git a/include/StringPairDrag.h b/include/StringPairDrag.h index 969a12eec..e58b88f90 100644 --- a/include/StringPairDrag.h +++ b/include/StringPairDrag.h @@ -35,13 +35,16 @@ class QPixmap; +namespace lmms::gui +{ + class LMMS_EXPORT StringPairDrag : public QDrag { public: StringPairDrag( const QString & _key, const QString & _value, const QPixmap & _icon, QWidget * _w ); - ~StringPairDrag(); + ~StringPairDrag() override; static bool processDragEnterEvent( QDragEnterEvent * _dee, const QString & _allowed_keys ); @@ -50,4 +53,6 @@ public: } ; +} // namespace lmms::gui + #endif diff --git a/include/SubWindow.h b/include/SubWindow.h index 113db636a..3c73a9dde 100644 --- a/include/SubWindow.h +++ b/include/SubWindow.h @@ -38,6 +38,10 @@ class QPushButton; class QResizeEvent; class QWidget; +namespace lmms::gui +{ + + /** * @brief The SubWindow class * @@ -96,4 +100,8 @@ private slots: void focusChanged( QMdiSubWindow * subWindow ); }; + + +} // namespace lmms::gui + #endif diff --git a/include/SweepOscillator.h b/include/SweepOscillator.h index 0e54e6cce..f113ea0fa 100644 --- a/include/SweepOscillator.h +++ b/include/SweepOscillator.h @@ -28,6 +28,8 @@ #include "Oscillator.h" #include "DspEffectLibrary.h" +namespace lmms +{ template class SweepOscillator @@ -39,9 +41,7 @@ public: { } - virtual ~SweepOscillator() - { - } + virtual ~SweepOscillator() = default; void update( sampleFrame* buf, const fpp_t frames, const float freq1, const float freq2, const float sampleRate ) { @@ -67,4 +67,6 @@ private: } ; +} // namespace lmms + #endif diff --git a/include/TabBar.h b/include/TabBar.h index 46226618b..2395e15f5 100644 --- a/include/TabBar.h +++ b/include/TabBar.h @@ -33,6 +33,10 @@ #include "lmms_export.h" +namespace lmms::gui +{ + + class TabButton; @@ -42,7 +46,7 @@ class LMMS_EXPORT TabBar : public QWidget public: TabBar( QWidget * _parent, QBoxLayout::Direction _dir = QBoxLayout::LeftToRight ); - virtual ~TabBar() = default; + ~TabBar() override = default; TabButton * addTab( QWidget * _w, const QString & _text, int _id, bool _add_stretch = false, @@ -85,4 +89,6 @@ signals: } ; +} // namespace lmms::gui + #endif diff --git a/include/TabButton.h b/include/TabButton.h index ffb425d71..938230a91 100644 --- a/include/TabButton.h +++ b/include/TabButton.h @@ -28,6 +28,9 @@ #include +namespace lmms::gui +{ + class TabButton : public QPushButton { @@ -42,9 +45,7 @@ public: SLOT( slotClicked() ) ); } - ~TabButton() - { - } + ~TabButton() override = default; signals: @@ -63,4 +64,7 @@ private: } ; + +} // namespace lmms::gui + #endif diff --git a/include/TabWidget.h b/include/TabWidget.h index d4a3ec3c9..27a35d2a8 100644 --- a/include/TabWidget.h +++ b/include/TabWidget.h @@ -29,6 +29,9 @@ #include #include +namespace lmms::gui +{ + const int TEXT_TAB_HEIGHT = 14; const int GRAPHIC_TAB_HEIGHT = 17; @@ -40,7 +43,7 @@ public: //! If false, all child widget will be cut down to the TabWidget's size TabWidget( const QString & _caption, QWidget * _parent, bool usePixmap = false, bool resizable = false ); - virtual ~TabWidget() = default; + ~TabWidget() override = default; void addTab( QWidget * w, const QString & name, const char *pixmap = nullptr, int idx = -1 ); @@ -88,7 +91,7 @@ private: QString name; // name for widget int nwidth; // width of name when painting (only valid for text tab) } ; - typedef QMap widgetStack; + using widgetStack = QMap; widgetStack m_widgets; @@ -106,4 +109,7 @@ private: QColor m_tabBorder; // The TabWidget's borders color. } ; + +} // namespace lmms::gui + #endif diff --git a/include/TemplatesMenu.h b/include/TemplatesMenu.h index 049f1f47e..7f425bd2f 100644 --- a/include/TemplatesMenu.h +++ b/include/TemplatesMenu.h @@ -1,15 +1,43 @@ +/* + * TemplatesMenu.h + * + * Copyright (c) 2004-2022 Tobias Doerffel + * + * This file is part of LMMS - https://lmms.io + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ #ifndef TEMPLATESMENU_H #define TEMPLATESMENU_H #include #include + +namespace lmms::gui +{ + + class TemplatesMenu : public QMenu { Q_OBJECT public: TemplatesMenu(QWidget *parent = nullptr); - virtual ~TemplatesMenu() = default; + ~TemplatesMenu() override = default; private slots: static void createNewProjectFromTemplate(QAction * _action); @@ -18,4 +46,7 @@ private slots: }; + +} // namespace lmms::gui + #endif // TEMPLATESMENU_H diff --git a/include/TempoSyncKnob.h b/include/TempoSyncKnob.h index 3e9fc9738..25a3b7e3b 100644 --- a/include/TempoSyncKnob.h +++ b/include/TempoSyncKnob.h @@ -32,6 +32,9 @@ #include "Knob.h" #include "TempoSyncKnobModel.h" +namespace lmms::gui +{ + class MeterDialog; class LMMS_EXPORT TempoSyncKnob : public Knob @@ -39,7 +42,7 @@ class LMMS_EXPORT TempoSyncKnob : public Knob Q_OBJECT public: TempoSyncKnob( knobTypes knobNum, QWidget* parent = nullptr, const QString& name = QString() ); - virtual ~TempoSyncKnob(); + ~TempoSyncKnob() override; const QString & syncDescription(); void setSyncDescription( const QString & _new_description ); @@ -79,4 +82,6 @@ private: +} // namespace lmms::gui + #endif diff --git a/include/TempoSyncKnobModel.h b/include/TempoSyncKnobModel.h index b9512aa1a..1a18486ff 100644 --- a/include/TempoSyncKnobModel.h +++ b/include/TempoSyncKnobModel.h @@ -30,6 +30,17 @@ class QAction; +namespace lmms +{ + +namespace gui +{ + +class TempoSyncKnob; + +} // namespace gui + + class LMMS_EXPORT TempoSyncKnobModel : public FloatModel { Q_OBJECT @@ -52,7 +63,7 @@ public: const float _max, const float _step, const float _scale, Model * _parent, const QString & _display_name = QString() ); - ~TempoSyncKnobModel() override; + ~TempoSyncKnobModel() override = default; void saveSettings( QDomDocument & _doc, QDomElement & _this, const QString& name ) override; void loadSettings( const QDomElement & _this, const QString& name ) override; @@ -72,7 +83,7 @@ public: void setScale( float _new_scale ); signals: - void syncModeChanged( TempoSyncMode _new_mode ); + void syncModeChanged( lmms::TempoSyncKnobModel::TempoSyncMode _new_mode ); void scaleChanged( float _new_scale ); @@ -86,7 +97,7 @@ public slots: protected slots: - void calculateTempoSyncTime( bpm_t _bpm ); + void calculateTempoSyncTime( lmms::bpm_t _bpm ); void updateCustom(); @@ -98,8 +109,10 @@ private: MeterModel m_custom; - friend class TempoSyncKnob; + friend class gui::TempoSyncKnob; } ; +} // namespace lmms + #endif diff --git a/include/TextFloat.h b/include/TextFloat.h index 1df7ed46a..9fdabc06b 100644 --- a/include/TextFloat.h +++ b/include/TextFloat.h @@ -31,15 +31,15 @@ #include "lmms_export.h" +namespace lmms::gui +{ class LMMS_EXPORT TextFloat : public QWidget { Q_OBJECT public: TextFloat(); - virtual ~TextFloat() - { - } + ~TextFloat() override = default; void setTitle( const QString & _title ); void setText( const QString & _text ); @@ -79,4 +79,7 @@ private: }; + +} // namespace lmms::gui + #endif diff --git a/include/ThreadableJob.h b/include/ThreadableJob.h index b2b20e9be..8e714ae19 100644 --- a/include/ThreadableJob.h +++ b/include/ThreadableJob.h @@ -29,6 +29,9 @@ #include +namespace lmms +{ + class ThreadableJob { public: @@ -85,4 +88,6 @@ protected: std::atomic m_state; } ; +} // namespace lmms + #endif diff --git a/include/TimeDisplayWidget.h b/include/TimeDisplayWidget.h index 303ce6d5e..894666970 100644 --- a/include/TimeDisplayWidget.h +++ b/include/TimeDisplayWidget.h @@ -31,13 +31,15 @@ #include "LcdWidget.h" +namespace lmms::gui +{ class TimeDisplayWidget : public QWidget { Q_OBJECT public: TimeDisplayWidget(); - virtual ~TimeDisplayWidget() = default; + ~TimeDisplayWidget() override = default; protected: @@ -55,7 +57,7 @@ private: BarsTicks, DisplayModeCount }; - typedef DisplayModes DisplayMode; + using DisplayMode = DisplayModes; void setDisplayMode( DisplayMode displayMode ); @@ -67,4 +69,6 @@ private: } ; +} // namespace lmms::gui + #endif // TIME_DISPLAY_WIDGET_H diff --git a/include/TimeLineWidget.h b/include/TimeLineWidget.h index 7809c042e..bada25640 100644 --- a/include/TimeLineWidget.h +++ b/include/TimeLineWidget.h @@ -33,6 +33,10 @@ class QPixmap; class QToolBar; + +namespace lmms::gui +{ + class NStateButton; class TextFloat; class SongEditor; @@ -74,7 +78,7 @@ public: TimeLineWidget(int xoff, int yoff, float ppb, Song::PlayPos & pos, const TimePos & begin, Song::PlayModes mode, QWidget * parent); - virtual ~TimeLineWidget(); + ~TimeLineWidget() override; inline QColor const & getBarLineColor() const { return m_barLineColor; } inline void setBarLineColor(QColor const & barLineColor) { m_barLineColor = barLineColor; } @@ -175,7 +179,7 @@ signals: public slots: - void updatePosition( const TimePos & ); + void updatePosition( const lmms::TimePos & ); void updatePosition() { updatePosition( TimePos() ); @@ -247,7 +251,7 @@ private: signals: - void positionChanged( const TimePos & _t ); + void positionChanged( const lmms::TimePos & _t ); void loopPointStateLoaded( int _n ); void positionMarkerMoved(); void loadBehaviourAtStop( int _n ); @@ -255,4 +259,7 @@ signals: } ; + +} // namespace lmms::gui + #endif diff --git a/include/TimePos.h b/include/TimePos.h index 8b758d9b4..808eede25 100644 --- a/include/TimePos.h +++ b/include/TimePos.h @@ -31,6 +31,9 @@ #include "lmms_export.h" #include "lmms_basics.h" +namespace lmms +{ + // note: a bar was erroneously called "tact" in older versions of LMMS const int DefaultTicksPerBar = 192; const int DefaultStepsPerBar = 16; @@ -113,4 +116,6 @@ private: } ; +} // namespace lmms + #endif diff --git a/include/ToolButton.h b/include/ToolButton.h index 2f64d45b8..c173a9052 100644 --- a/include/ToolButton.h +++ b/include/ToolButton.h @@ -28,6 +28,8 @@ #include +namespace lmms::gui +{ class ToolButton : public QToolButton { @@ -41,9 +43,11 @@ public: QToolButton(_parent) { } - virtual ~ToolButton() = default; + ~ToolButton() override = default; } ; +} // namespace lmms::gui + #endif diff --git a/include/ToolPlugin.h b/include/ToolPlugin.h index 8a65147ac..38f4d87b1 100644 --- a/include/ToolPlugin.h +++ b/include/ToolPlugin.h @@ -29,11 +29,16 @@ #include "Plugin.h" + +namespace lmms +{ + + class LMMS_EXPORT ToolPlugin : public Plugin { public: ToolPlugin( const Descriptor * _descriptor, Model * _parent ); - virtual ~ToolPlugin(); + ~ToolPlugin() override = default; // instantiate tool-plugin with given name or return NULL // on failure @@ -42,4 +47,7 @@ public: } ; + +} // namespace lmms + #endif diff --git a/include/ToolPluginView.h b/include/ToolPluginView.h index 2b64caaaf..0b702fd1b 100644 --- a/include/ToolPluginView.h +++ b/include/ToolPluginView.h @@ -28,8 +28,15 @@ #include "PluginView.h" +namespace lmms +{ + class ToolPlugin; +namespace gui +{ + + class LMMS_EXPORT ToolPluginView : public PluginView { public: @@ -38,4 +45,8 @@ public: } ; +} // namespace gui + +} // namespace lmms + #endif diff --git a/include/Track.h b/include/Track.h index d00ac3783..8d756c914 100644 --- a/include/Track.h +++ b/include/Track.h @@ -34,11 +34,21 @@ #include "lmms_basics.h" +namespace lmms +{ + class TimePos; class TrackContainer; -class TrackContainerView; class Clip; + + +namespace gui +{ + class TrackView; +class TrackContainerView; + +} /*! The minimum track height in pixels @@ -60,7 +70,7 @@ class LMMS_EXPORT Track : public Model, public JournallingObject mapPropertyFromModel(bool,isMuted,setMuted,m_mutedModel); mapPropertyFromModel(bool,isSolo,setSolo,m_soloModel); public: - typedef QVector clipVector; + using clipVector = QVector; enum TrackTypes { @@ -75,7 +85,7 @@ public: } ; Track( TrackTypes type, TrackContainer * tc ); - virtual ~Track(); + ~Track() override; static Track * create( TrackTypes tt, TrackContainer * tc ); static Track * create( const QDomElement & element, @@ -93,7 +103,8 @@ public: const f_cnt_t frameBase, int clipNum = -1 ) = 0; - virtual TrackView * createView( TrackContainerView * view ) = 0; + + virtual gui::TrackView * createView( gui::TrackContainerView * view ) = 0; virtual Clip * createClip( const TimePos & pos ) = 0; virtual void saveTrackSpecificSettings( QDomDocument & doc, @@ -233,16 +244,17 @@ private: QColor m_color; bool m_hasColor; - friend class TrackView; + friend class gui::TrackView; signals: void destroyedTrack(); void nameChanged(); - void clipAdded( Clip * ); + void clipAdded( lmms::Clip * ); void colorChanged(); } ; +} // namespace lmms #endif diff --git a/include/TrackContainer.h b/include/TrackContainer.h index 18139a0da..d947094f7 100644 --- a/include/TrackContainer.h +++ b/include/TrackContainer.h @@ -31,17 +31,25 @@ #include "Track.h" #include "JournallingObject.h" +namespace lmms +{ class AutomationClip; class InstrumentTrack; + +namespace gui +{ + class TrackContainerView; +} + class LMMS_EXPORT TrackContainer : public Model, public JournallingObject { Q_OBJECT public: - typedef QVector TrackList; + using TrackList = QVector; enum TrackContainerTypes { PatternContainer, @@ -49,7 +57,7 @@ public: } ; TrackContainer(); - virtual ~TrackContainer(); + ~TrackContainer() override; void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; @@ -96,7 +104,7 @@ public: virtual AutomatedValueMap automatedValuesAt(TimePos time, int clipNum = -1) const; signals: - void trackAdded( Track * _track ); + void trackAdded( lmms::Track * _track ); protected: static AutomatedValueMap automatedValuesFromTracks(const TrackList &tracks, TimePos timeStart, int clipNum = -1); @@ -109,10 +117,11 @@ private: TrackContainerTypes m_TrackContainerType; - friend class TrackContainerView; + friend class gui::TrackContainerView; friend class Track; } ; +} // namespace lmms #endif diff --git a/include/TrackContainerView.h b/include/TrackContainerView.h index 00267bfe8..444420d98 100644 --- a/include/TrackContainerView.h +++ b/include/TrackContainerView.h @@ -39,11 +39,32 @@ class QVBoxLayout; +namespace lmms +{ + class InstrumentTrack; class Track; class TrackContainer; -class TrackView; +class InstrumentLoaderThread : public QThread +{ +Q_OBJECT +public: + InstrumentLoaderThread( QObject *parent = 0, InstrumentTrack *it = 0, + QString name = "" ); + + void run() override; + +private: + InstrumentTrack *m_it; + QString m_name; + QThread *m_containerThread; +}; + +namespace gui +{ + +class TrackView; class TrackContainerView : public QWidget, public ModelView, public JournallingObject, @@ -52,7 +73,7 @@ class TrackContainerView : public QWidget, public ModelView, Q_OBJECT public: TrackContainerView( TrackContainer* tc ); - virtual ~TrackContainerView(); + ~TrackContainerView() override; void saveSettings( QDomDocument & _doc, QDomElement & _this ) override; void loadSettings( const QDomElement & _this ) override; @@ -127,13 +148,14 @@ public: return "trackcontainerview"; } + unsigned int totalHeightOfTracks() const; RubberBand *rubberBand() const; public slots: void realignTracks(); - TrackView * createTrackView( Track * _t ); - void deleteTrackView( TrackView * _tv ); + lmms::gui::TrackView * createTrackView( lmms::Track * _t ); + void deleteTrackView( lmms::gui::TrackView * _tv ); void dropEvent( QDropEvent * _de ) override; void dragEnterEvent( QDragEnterEvent * _dee ) override; @@ -163,7 +185,7 @@ private: { public: scrollArea( TrackContainerView* parent ); - virtual ~scrollArea(); + ~scrollArea() override = default; protected: void wheelEvent( QWheelEvent * _we ) override; @@ -175,7 +197,7 @@ private: friend class TrackContainerView::scrollArea; TrackContainer* m_tc; - typedef QList trackViewList; + using trackViewList = QList; trackViewList m_trackViews; scrollArea * m_scrollArea; @@ -185,27 +207,16 @@ private: RubberBand * m_rubberBand; - - signals: - void positionChanged( const TimePos & _pos ); + void positionChanged( const lmms::TimePos & _pos ); + void tracksRealigned(); } ; -class InstrumentLoaderThread : public QThread -{ - Q_OBJECT -public: - InstrumentLoaderThread( QObject *parent = 0, InstrumentTrack *it = 0, - QString name = "" ); - void run() override; +} // namespace gui -private: - InstrumentTrack *m_it; - QString m_name; - QThread *m_containerThread; -}; +} // namespace lmms #endif diff --git a/include/TrackContentWidget.h b/include/TrackContentWidget.h index d3bf60488..f4a44d2a6 100644 --- a/include/TrackContentWidget.h +++ b/include/TrackContentWidget.h @@ -33,10 +33,16 @@ class QMimeData; -class Track; -class ClipView; -class TrackView; +namespace lmms +{ +class Track; + +namespace gui +{ + +class TrackView; +class ClipView; class TrackContentWidget : public QWidget, public JournallingObject { @@ -50,7 +56,7 @@ class TrackContentWidget : public QWidget, public JournallingObject public: TrackContentWidget( TrackView * parent ); - virtual ~TrackContentWidget(); + ~TrackContentWidget() override = default; /*! \brief Updates the background tile pixmap. */ void updateBackground(); @@ -86,7 +92,7 @@ public: public slots: void update(); - void changePosition( const TimePos & newPos = TimePos( -1 ) ); + void changePosition( const lmms::TimePos & newPos = TimePos( -1 ) ); protected: enum ContextMenuAction @@ -126,7 +132,7 @@ private: TrackView * m_trackView; - typedef QVector clipViewVector; + using clipViewVector = QVector; clipViewVector m_clipViews; QPixmap m_background; @@ -139,5 +145,8 @@ private: } ; +} // namespace gui + +} // namespace lmms #endif diff --git a/include/TrackLabelButton.h b/include/TrackLabelButton.h index a46f418e9..1a8d05e71 100644 --- a/include/TrackLabelButton.h +++ b/include/TrackLabelButton.h @@ -28,6 +28,9 @@ #include +namespace lmms::gui +{ + class TrackView; class TrackRenameLineEdit; @@ -38,7 +41,7 @@ class TrackLabelButton : public QToolButton Q_OBJECT public: TrackLabelButton( TrackView * _tv, QWidget * _parent ); - virtual ~TrackLabelButton(); + ~TrackLabelButton() override = default; public slots: @@ -66,4 +69,7 @@ private: } ; + +} // namespace lmms::gui + #endif diff --git a/include/TrackOperationsWidget.h b/include/TrackOperationsWidget.h index 7680aa7b4..edd9796ac 100644 --- a/include/TrackOperationsWidget.h +++ b/include/TrackOperationsWidget.h @@ -29,6 +29,9 @@ class QPushButton; +namespace lmms::gui +{ + class PixmapButton; class TrackView; @@ -37,7 +40,7 @@ class TrackOperationsWidget : public QWidget Q_OBJECT public: TrackOperationsWidget( TrackView * parent ); - ~TrackOperationsWidget(); + ~TrackOperationsWidget() override = default; protected: @@ -70,8 +73,11 @@ private: friend class TrackView; signals: - void trackRemovalScheduled( TrackView * t ); + void trackRemovalScheduled( lmms::gui::TrackView * t ); } ; + +} // namespace lmms::gui + #endif diff --git a/include/TrackRenameLineEdit.h b/include/TrackRenameLineEdit.h index e681a2d21..4b13ff9b7 100644 --- a/include/TrackRenameLineEdit.h +++ b/include/TrackRenameLineEdit.h @@ -29,6 +29,9 @@ #include +namespace lmms::gui +{ + class TrackRenameLineEdit : public QLineEdit { Q_OBJECT @@ -43,4 +46,6 @@ private: QString m_oldName; } ; +} // namespace lmms::gui + #endif diff --git a/include/TrackView.h b/include/TrackView.h index 4467ecbdb..4b02c8015 100644 --- a/include/TrackView.h +++ b/include/TrackView.h @@ -37,12 +37,20 @@ class QMenu; -class FadeButton; +namespace lmms +{ + class Track; -class TrackContainerView; class Clip; +namespace gui +{ + +class FadeButton; +class TrackContainerView; + + const int DEFAULT_SETTINGS_WIDGET_WIDTH = 224; const int TRACK_OP_WIDTH = 78; // This shaves 150-ish pixels off track buttons, @@ -56,7 +64,7 @@ class TrackView : public QWidget, public ModelView, public JournallingObject Q_OBJECT public: TrackView( Track * _track, TrackContainerView* tcv ); - virtual ~TrackView(); + ~TrackView() override = default; inline const Track * getTrack() const { @@ -161,11 +169,14 @@ private: private slots: - void createClipView( Clip * clip ); + void createClipView( lmms::Clip * clip ); void muteChanged(); } ; +} // namespace gui + +} // namespace lmms #endif diff --git a/include/ValueBuffer.h b/include/ValueBuffer.h index f9869de88..950ad06f0 100644 --- a/include/ValueBuffer.h +++ b/include/ValueBuffer.h @@ -31,11 +31,15 @@ #include "MemoryManager.h" #include "lmms_export.h" +namespace lmms +{ + + class LMMS_EXPORT ValueBuffer : public std::vector { MM_OPERATORS public: - ValueBuffer(); + ValueBuffer() = default; ValueBuffer(int length); void fill(float value); @@ -50,4 +54,7 @@ public: void interpolate(float start, float end); }; + +} // namespace lmms + #endif diff --git a/include/VersionedSaveDialog.h b/include/VersionedSaveDialog.h index bb4894500..79ab516b0 100644 --- a/include/VersionedSaveDialog.h +++ b/include/VersionedSaveDialog.h @@ -32,6 +32,10 @@ #include "Song.h" class QLineEdit; + +namespace lmms::gui +{ + class LedCheckBox; class SaveOptionsWidget : public QWidget { @@ -62,4 +66,7 @@ public slots: void decrementVersion(); }; + +} // namespace lmms::gui + #endif // VERSIONEDSAVEDIALOG_H diff --git a/include/VstSyncController.h b/include/VstSyncController.h index ec7d9820c..c70bc85c8 100644 --- a/include/VstSyncController.h +++ b/include/VstSyncController.h @@ -31,51 +31,35 @@ #include "SharedMemory.h" #include "VstSyncData.h" +namespace lmms +{ + class VstSyncController : public QObject { Q_OBJECT public: VstSyncController(); - ~VstSyncController(); - - void setAbsolutePosition( double ticks ); - - void setPlaybackState( bool enabled ) - { - m_syncData->isPlaying = enabled; - } - - void setTempo( int newTempo ); - - void setTimeSignature( int num, int denom ) - { - m_syncData->timeSigNumer = num; - m_syncData->timeSigDenom = denom; - } - - void startCycle( int startTick, int endTick ); - - void stopCycle() - { - m_syncData->isCycle = false; - } - - void setPlaybackJumped( bool jumped ) - { - m_syncData->m_playbackJumped = jumped; - } + void setAbsolutePosition(double ticks); + void setPlaybackState(bool enabled); + void setTempo(int newTempo); + void setTimeSignature(int num, int denom); + void startCycle(int startTick, int endTick); + void stopCycle(); + void setPlaybackJumped(bool jumped); void update(); + const std::string& sharedMemoryKey() const noexcept { return m_syncData.key(); } private slots: void updateSampleRate(); - private: - VstSyncData* m_syncData; - SharedMemory m_shm; + SharedMemory m_syncData; }; + +} // namespace lmms + #endif diff --git a/include/VstSyncData.h b/include/VstSyncData.h index ac1bed218..baf3fa7a8 100644 --- a/include/VstSyncData.h +++ b/include/VstSyncData.h @@ -26,6 +26,10 @@ #ifndef VST_SYNC_DATA_H #define VST_SYNC_DATA_H +namespace lmms +{ + + // VST sync frequency (in ms), how often will be VST plugin synced // keep it power of two if possible (not used by now) //#define VST_SNC_TIMER 1 @@ -42,7 +46,6 @@ struct VstSyncData int timeSigDenom; bool isPlaying; bool isCycle; - bool hasSHM; float cycleStart; float cycleEnd; bool m_playbackJumped; @@ -55,4 +58,7 @@ struct VstSyncData #endif } ; + +} // namespace lmms + #endif diff --git a/include/aeffectx.h b/include/aeffectx.h index 7cdfcfe7d..a06567ba7 100644 --- a/include/aeffectx.h +++ b/include/aeffectx.h @@ -36,6 +36,7 @@ #define VST_CALL_CONV #endif + template constexpr int32_t CCONST(T a, T b, T c, T d) { @@ -295,9 +296,6 @@ public: } ; - - -typedef intptr_t (VST_CALL_CONV * audioMasterCallback)( AEffect * , int32_t, int32_t, intptr_t, void * , float ); - +using audioMasterCallback = intptr_t (VST_CALL_CONV*)(AEffect*, int32_t, int32_t, intptr_t, void*, float); #endif diff --git a/include/base64.h b/include/base64.h index a0557fe0d..f52d90d13 100644 --- a/include/base64.h +++ b/include/base64.h @@ -30,9 +30,9 @@ #include #include - -namespace base64 +namespace lmms::base64 { + inline void encode( const char * _data, const int _size, QString & _dst ) { @@ -51,6 +51,6 @@ namespace base64 QVariant decode( const QString & _b64, QVariant::Type _force_type = QVariant::Invalid ); -} +} // namespace lmms::base64 #endif diff --git a/include/debug.h b/include/debug.h index f619da666..f2ea29cc1 100644 --- a/include/debug.h +++ b/include/debug.h @@ -33,7 +33,7 @@ #ifndef NDEBUG #define NDEBUG #endif -#endif +#endif // LMMS_DEBUG #include #include diff --git a/include/denormals.h b/include/denormals.h index e08669b2b..e99e767a3 100644 --- a/include/denormals.h +++ b/include/denormals.h @@ -8,26 +8,36 @@ #include #ifdef __GNUC__ #include -#endif +#endif // __GNUC__ +#endif // __SSE__ + + +namespace lmms +{ + +#ifdef __SSE__ // Intel® 64 and IA-32 Architectures Software Developer’s Manual, // Volume 1: Basic Architecture, // 11.6.3 Checking for the DAZ Flag in the MXCSR Register -int inline can_we_daz() { +int inline can_we_daz() +{ alignas(16) unsigned char buffer[512] = {0}; #if defined(LMMS_HOST_X86) _fxsave(buffer); #elif defined(LMMS_HOST_X86_64) _fxsave64(buffer); -#endif +#endif // defined(LLMS_HOST_X86) // Bit 6 of the MXCSR_MASK, i.e. in the lowest byte, // tells if we can use the DAZ flag. return ((buffer[28] & (1 << 6)) != 0); } -#endif + +#endif // __SSE__ // Set denormal protection for this thread. -void inline disable_denormals() { +void inline disable_denormals() +{ #ifdef __SSE__ /* Setting DAZ might freeze systems not supporting it */ if (can_we_daz()) { @@ -35,8 +45,10 @@ void inline disable_denormals() { } /* FTZ flag */ _MM_SET_FLUSH_ZERO_MODE( _MM_FLUSH_ZERO_ON ); -#endif +#endif // __SSE__ } -#endif +} // namespace lmms + +#endif // DENORMALS_H diff --git a/include/embed.h b/include/embed.h index ea3e3417e..03d767b43 100644 --- a/include/embed.h +++ b/include/embed.h @@ -32,6 +32,9 @@ #include "lmms_basics.h" +namespace lmms +{ + namespace embed { @@ -58,13 +61,13 @@ namespace PLUGIN_NAME inline QPixmap getIconPixmap( const QString& _name, int _w = -1, int _h = -1, const char** xpm = nullptr ) { - return embed::getIconPixmap(QString("%1/%2").arg(STRINGIFY(PLUGIN_NAME), _name), _w, _h, xpm); + return embed::getIconPixmap(QString("%1/%2").arg(LMMS_STRINGIFY(PLUGIN_NAME), _name), _w, _h, xpm); } //QString getText( const char * _name ); -} -#endif +} // namespace PLUGIN_NAME +#endif // PLUGIN_NAME class PixmapLoader @@ -93,9 +96,7 @@ public: return( QPixmap() ); } - virtual ~PixmapLoader() - { - } + virtual ~PixmapLoader() = default; virtual QString pixmapName() const { @@ -117,7 +118,7 @@ public: { } - virtual QPixmap pixmap() const + QPixmap pixmap() const override { if( !m_name.isEmpty() ) { @@ -127,14 +128,15 @@ public: return( QPixmap() ); } - virtual QString pixmapName() const + QString pixmapName() const override { - return QString( STRINGIFY(PLUGIN_NAME) ) + "::" + m_name; + return QString( LMMS_STRINGIFY(PLUGIN_NAME) ) + "::" + m_name; } } ; -#endif +#endif // PLUGIN_NAME +} // namespace lmms #endif diff --git a/include/endian_handling.h b/include/endian_handling.h index 09953a0ac..b3d122fa3 100644 --- a/include/endian_handling.h +++ b/include/endian_handling.h @@ -30,6 +30,10 @@ #include "lmms_basics.h" +namespace lmms +{ + + inline bool isLittleEndian() { return( QSysInfo::ByteOrder == QSysInfo::LittleEndian ); @@ -50,4 +54,7 @@ inline int32_t swap32IfBE( int32_t i ) ( ( i & 0x000000ff ) << 24 ) ); } + +} // namespace lmms + #endif diff --git a/include/fft_helpers.h b/include/fft_helpers.h index 88183fb19..8ba0fc7a0 100644 --- a/include/fft_helpers.h +++ b/include/fft_helpers.h @@ -32,6 +32,9 @@ #include #include +namespace lmms +{ + // NOTE: FFT_BUFFER_SIZE should be considered deprecated! // It is used by Eq plugin and some older code here, but this should be a user // switchable parameter, not a constant. Use a value from FFT_BLOCK_SIZES @@ -103,4 +106,7 @@ int LMMS_EXPORT absspec(const fftwf_complex *complex_buffer, float *absspec_buff int LMMS_EXPORT compressbands(const float * _absspec_buffer, float * _compressedband, int _num_old, int _num_new, int _bottom, int _top); + +} // namespace lmms + #endif diff --git a/include/gui_templates.h b/include/gui_templates.h index 073cb50f1..ee0ccdbf6 100644 --- a/include/gui_templates.h +++ b/include/gui_templates.h @@ -32,6 +32,8 @@ #include #include +namespace lmms +{ // return DPI-independent font-size - font with returned font-size has always @@ -65,4 +67,6 @@ inline QFont pointSizeF( QFont _f, float SIZE ) } +} // namespace lmms + #endif diff --git a/include/interpolation.h b/include/interpolation.h index cb324cd76..3a74334e4 100644 --- a/include/interpolation.h +++ b/include/interpolation.h @@ -34,6 +34,9 @@ #include "lmms_constants.h" #include "lmms_math.h" +namespace lmms +{ + inline float hermiteInterpolate( float x0, float x1, float x2, float x3, float frac_pos ) { @@ -135,6 +138,6 @@ inline float lagrangeInterpolate( float v0, float v1, float v2, float v3, float - +} // namespace lmms #endif diff --git a/include/lmms_basics.h b/include/lmms_basics.h index cda591c0d..59a6aa359 100644 --- a/include/lmms_basics.h +++ b/include/lmms_basics.h @@ -35,26 +35,26 @@ #include -typedef int32_t bar_t; -typedef int32_t tick_t; -typedef uint8_t volume_t; -typedef int8_t panning_t; +namespace lmms +{ +using bar_t = int32_t; +using tick_t = int32_t; +using volume_t = uint8_t; +using panning_t = int8_t; -typedef float sample_t; // standard sample-type -typedef int16_t int_sample_t; // 16-bit-int-sample +using sample_t = float; // standard sample-type +using int_sample_t = int16_t; // 16-bit-int-sample +using sample_rate_t = uint32_t; // sample-rate +using fpp_t = int16_t; // frames per period (0-16384) +using f_cnt_t = int32_t; // standard frame-count +using ch_cnt_t = uint8_t; // channel-count (0-SURROUND_CHANNELS) +using bpm_t = uint16_t; // tempo (MIN_BPM to MAX_BPM) +using bitrate_t = uint16_t; // bitrate in kbps +using mix_ch_t = uint16_t; // Mixer-channel (0 to MAX_CHANNEL) -typedef uint32_t sample_rate_t; // sample-rate -typedef int16_t fpp_t; // frames per period (0-16384) -typedef int32_t f_cnt_t; // standard frame-count -typedef uint8_t ch_cnt_t; // channel-count (0-SURROUND_CHANNELS) -typedef uint16_t bpm_t; // tempo (MIN_BPM to MAX_BPM) -typedef uint16_t bitrate_t; // bitrate in kbps -typedef uint16_t mix_ch_t; // Mixer-channel (0 to MAX_CHANNEL) - -typedef uint32_t jo_id_t; // (unique) ID of a journalling object - +using jo_id_t = uint32_t; // (unique) ID of a journalling object // windows headers define "min" and "max" macros, breaking the methods bwloe #undef min @@ -132,8 +132,8 @@ using surroundSampleFrame = std::array; constexpr std::size_t LMMS_ALIGN_SIZE = 16; -#define STRINGIFY(s) STR(s) -#define STR(PN) #PN +#define LMMS_STRINGIFY(s) LMMS_STR(s) +#define LMMS_STR(PN) #PN // Abstract away GUI CTRL key (linux/windows) vs ⌘ (apple) constexpr const char* UI_CTRL_KEY = @@ -143,4 +143,7 @@ constexpr const char* UI_CTRL_KEY = "Ctrl"; #endif + +} // namespace lmms + #endif diff --git a/include/lmms_constants.h b/include/lmms_constants.h index f5a86bc88..7796f6bdf 100644 --- a/include/lmms_constants.h +++ b/include/lmms_constants.h @@ -25,6 +25,10 @@ #ifndef LMMS_CONSTANTS_H #define LMMS_CONSTANTS_H +namespace lmms +{ + + constexpr long double LD_PI = 3.14159265358979323846264338327950288419716939937510; constexpr long double LD_2PI = LD_PI * 2.0; constexpr long double LD_PI_2 = LD_PI * 0.5; @@ -96,4 +100,7 @@ constexpr int ARANGE_LOUD_END = 0; constexpr int ARANGE_SILENT_START = -60; constexpr int ARANGE_SILENT_END = -10; + +} // namespace lmms + #endif diff --git a/include/lmms_math.h b/include/lmms_math.h index aa043170c..db4502f1c 100644 --- a/include/lmms_math.h +++ b/include/lmms_math.h @@ -33,6 +33,9 @@ #include +namespace lmms +{ + #ifdef __INTEL_COMPILER static inline float absFraction( const float _x ) @@ -115,7 +118,7 @@ static inline float absFraction( float _x ) } #endif -#endif +#endif // __INTEL_COMPILER @@ -150,7 +153,7 @@ static inline long double fastFmal( long double a, long double b, long double c #endif #else return a * b + c; -#endif +#endif // FP_FAST_FMAL } //! @brief Takes advantage of fmaf() function if present in hardware @@ -164,7 +167,7 @@ static inline float fastFmaf( float a, float b, float c ) #endif #else return a * b + c; -#endif +#endif // FP_FAST_FMAF } //! @brief Takes advantage of fma() function if present in hardware @@ -323,4 +326,7 @@ static inline T absMin( T a, T b ) return qAbs(a) < qAbs(b) ? a : b; } + +} // namespace lmms + #endif diff --git a/include/panning.h b/include/panning.h index 6f65c8295..1521ec984 100644 --- a/include/panning.h +++ b/include/panning.h @@ -31,6 +31,10 @@ #include "Midi.h" #include "volume.h" +namespace lmms +{ + + inline StereoVolumeVector panningToVolumeVector( panning_t _p, float _scale = 1.0f ) { @@ -49,4 +53,7 @@ inline int panningToMidi( panning_t _p ) ( (float)( MidiMaxPanning - MidiMinPanning ) ) ); } + +} // namespace lmms + #endif diff --git a/include/panning_constants.h b/include/panning_constants.h index cf335ccfb..00a5c3291 100644 --- a/include/panning_constants.h +++ b/include/panning_constants.h @@ -26,9 +26,16 @@ #ifndef PANNING_CONSTANTS_H #define PANNING_CONSTANTS_H +namespace lmms +{ + + constexpr panning_t PanningRight = ( 0 + 100 ); constexpr panning_t PanningLeft = - PanningRight; constexpr panning_t PanningCenter = 0; constexpr panning_t DefaultPanning = PanningCenter; + +} // namespace lmms + #endif diff --git a/include/shared_object.h b/include/shared_object.h index efb8ba5d6..ac45d6cd7 100644 --- a/include/shared_object.h +++ b/include/shared_object.h @@ -28,6 +28,9 @@ #include +namespace lmms +{ + class sharedObject { public: @@ -36,9 +39,7 @@ public: { } - virtual ~sharedObject() - { - } + virtual ~sharedObject() = default; template static T* ref( T* object ) @@ -82,4 +83,7 @@ private: std::atomic_int m_referenceCount; } ; + +} // namespace lmms + #endif diff --git a/include/versioninfo.h b/include/versioninfo.h index 1faab6804..29bf3bea9 100644 --- a/include/versioninfo.h +++ b/include/versioninfo.h @@ -1,9 +1,12 @@ +#ifndef VERSION_INFO_H +#define VERSION_INFO_H + #include "lmms_basics.h" #ifdef __GNUC__ constexpr const char* LMMS_BUILDCONF_COMPILER_VERSION = "GCC " __VERSION__; #elif defined(_MSC_VER) -constexpr const char* LMMS_BUILDCONF_COMPILER_VERSION = "MSVC " STRINGIFY(_MSC_FULL_VER); +constexpr const char* LMMS_BUILDCONF_COMPILER_VERSION = "MSVC " LMMS_STRINGIFY(_MSC_FULL_VER); #else constexpr const char* LMMS_BUILDCONF_COMPILER_VERSION = "unknown compiler"; #endif @@ -47,3 +50,5 @@ constexpr const char* LMMS_BUILDCONF_PLATFORM = "win32"; #ifdef LMMS_BUILD_HAIKU constexpr const char* LMMS_BUILDCONF_PLATFORM = "Haiku"; #endif + +#endif diff --git a/include/volume.h b/include/volume.h index bb9fff228..5223bfa09 100644 --- a/include/volume.h +++ b/include/volume.h @@ -28,13 +28,19 @@ #include "lmms_basics.h" +namespace lmms +{ + + constexpr volume_t MinVolume = 0; constexpr volume_t MaxVolume = 200; constexpr volume_t DefaultVolume = 100; -typedef struct +struct StereoVolumeVector { float vol[2]; -} StereoVolumeVector; +}; + +} // namespace lmms #endif diff --git a/plugins/Amplifier/Amplifier.cpp b/plugins/Amplifier/Amplifier.cpp index 2dfdc9d8c..9344807c4 100644 --- a/plugins/Amplifier/Amplifier.cpp +++ b/plugins/Amplifier/Amplifier.cpp @@ -28,12 +28,15 @@ #include "embed.h" #include "plugin_export.h" +namespace lmms +{ + extern "C" { Plugin::Descriptor PLUGIN_EXPORT amplifier_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "Amplifier", QT_TRANSLATE_NOOP( "PluginBrowser", "A native amplifier plugin" ), "Vesa Kivimäki ", @@ -57,9 +60,6 @@ AmplifierEffect::AmplifierEffect( Model* parent, const Descriptor::SubPluginFeat -AmplifierEffect::~AmplifierEffect() -{ -} @@ -74,7 +74,7 @@ bool AmplifierEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) double outSum = 0.0; const float d = dryLevel(); const float w = wetLevel(); - + const ValueBuffer * volBuf = m_ampControls.m_volumeModel.valueBuffer(); const ValueBuffer * panBuf = m_ampControls.m_panModel.valueBuffer(); const ValueBuffer * leftBuf = m_ampControls.m_leftModel.valueBuffer(); @@ -83,8 +83,8 @@ bool AmplifierEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) for( fpp_t f = 0; f < frames; ++f ) { // qDebug( "offset %d, value %f", f, m_ampControls.m_volumeModel.value( f ) ); - - sample_t s[2] = { buf[f][0], buf[f][1] }; + + auto s = std::array{buf[f][0], buf[f][1]}; // vol knob if( volBuf ) @@ -99,8 +99,8 @@ bool AmplifierEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) } // convert pan values to left/right values - const float pan = panBuf - ? panBuf->value( f ) + const float pan = panBuf + ? panBuf->value( f ) : m_ampControls.m_panModel.value(); const float left1 = pan <= 0 ? 1.0 @@ -111,12 +111,12 @@ bool AmplifierEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) // second stage amplification const float left2 = leftBuf - ? leftBuf->value( f ) + ? leftBuf->value( f ) : m_ampControls.m_leftModel.value(); const float right2 = rightBuf - ? rightBuf->value( f ) + ? rightBuf->value( f ) : m_ampControls.m_rightModel.value(); - + s[0] *= left1 * left2 * 0.01; s[1] *= right1 * right2 * 0.01; @@ -145,3 +145,4 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* parent, void* data ) } +} // namespace lmms \ No newline at end of file diff --git a/plugins/Amplifier/Amplifier.h b/plugins/Amplifier/Amplifier.h index 843c25bdb..38fd07c6f 100644 --- a/plugins/Amplifier/Amplifier.h +++ b/plugins/Amplifier/Amplifier.h @@ -30,14 +30,17 @@ #include "Effect.h" #include "AmplifierControls.h" +namespace lmms +{ + class AmplifierEffect : public Effect { public: AmplifierEffect( Model* parent, const Descriptor::SubPluginFeatures::Key* key ); - virtual ~AmplifierEffect(); - virtual bool processAudioBuffer( sampleFrame* buf, const fpp_t frames ); + ~AmplifierEffect() override = default; + bool processAudioBuffer( sampleFrame* buf, const fpp_t frames ) override; - virtual EffectControls* controls() + EffectControls* controls() override { return &m_ampControls; } @@ -50,4 +53,7 @@ private: } ; + +} // namespace lmms + #endif diff --git a/plugins/Amplifier/AmplifierControlDialog.cpp b/plugins/Amplifier/AmplifierControlDialog.cpp index ad2846edb..226130fcd 100644 --- a/plugins/Amplifier/AmplifierControlDialog.cpp +++ b/plugins/Amplifier/AmplifierControlDialog.cpp @@ -30,6 +30,9 @@ #include "Knob.h" +namespace lmms::gui +{ + AmplifierControlDialog::AmplifierControlDialog( AmplifierControls* controls ) : EffectControlDialog( controls ) @@ -40,30 +43,33 @@ AmplifierControlDialog::AmplifierControlDialog( AmplifierControls* controls ) : setPalette( pal ); setFixedSize( 100, 110 ); - Knob * volumeKnob = new Knob( knobBright_26, this); + auto volumeKnob = new Knob(knobBright_26, this); volumeKnob -> move( 16, 10 ); volumeKnob -> setVolumeKnob( true ); volumeKnob->setModel( &controls->m_volumeModel ); volumeKnob->setLabel( tr( "VOL" ) ); volumeKnob->setHintText( tr( "Volume:" ) , "%" ); - Knob * panKnob = new Knob( knobBright_26, this); + auto panKnob = new Knob(knobBright_26, this); panKnob -> move( 57, 10 ); panKnob->setModel( &controls->m_panModel ); panKnob->setLabel( tr( "PAN" ) ); panKnob->setHintText( tr( "Panning:" ) , "" ); - Knob * leftKnob = new Knob( knobBright_26, this); + auto leftKnob = new Knob(knobBright_26, this); leftKnob -> move( 16, 65 ); leftKnob -> setVolumeKnob( true ); leftKnob->setModel( &controls->m_leftModel ); leftKnob->setLabel( tr( "LEFT" ) ); leftKnob->setHintText( tr( "Left gain:" ) , "%" ); - Knob * rightKnob = new Knob( knobBright_26, this); + auto rightKnob = new Knob(knobBright_26, this); rightKnob -> move( 57, 65 ); rightKnob -> setVolumeKnob( true ); rightKnob->setModel( &controls->m_rightModel ); rightKnob->setLabel( tr( "RIGHT" ) ); rightKnob->setHintText( tr( "Right gain:" ) , "%" ); } + + +} // namespace lmms::gui \ No newline at end of file diff --git a/plugins/Amplifier/AmplifierControlDialog.h b/plugins/Amplifier/AmplifierControlDialog.h index d0d7d0aa3..ad0ed50ca 100644 --- a/plugins/Amplifier/AmplifierControlDialog.h +++ b/plugins/Amplifier/AmplifierControlDialog.h @@ -28,19 +28,27 @@ #include "EffectControlDialog.h" +namespace lmms +{ class AmplifierControls; +namespace gui +{ + class AmplifierControlDialog : public EffectControlDialog { Q_OBJECT public: AmplifierControlDialog( AmplifierControls* controls ); - virtual ~AmplifierControlDialog() - { - } + ~AmplifierControlDialog() override = default; } ; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/Amplifier/AmplifierControls.cpp b/plugins/Amplifier/AmplifierControls.cpp index 70876be11..307730460 100644 --- a/plugins/Amplifier/AmplifierControls.cpp +++ b/plugins/Amplifier/AmplifierControls.cpp @@ -29,6 +29,8 @@ #include "AmplifierControls.h" #include "Amplifier.h" +namespace lmms +{ AmplifierControls::AmplifierControls( AmplifierEffect* effect ) : EffectControls( effect ), @@ -75,6 +77,6 @@ void AmplifierControls::saveSettings( QDomDocument& doc, QDomElement& _this ) } - +} // namespace lmms diff --git a/plugins/Amplifier/AmplifierControls.h b/plugins/Amplifier/AmplifierControls.h index f0f950fd1..573f6f896 100644 --- a/plugins/Amplifier/AmplifierControls.h +++ b/plugins/Amplifier/AmplifierControls.h @@ -29,34 +29,39 @@ #include "EffectControls.h" #include "AmplifierControlDialog.h" +namespace lmms +{ class AmplifierEffect; +namespace gui +{ +class AmplifierControlDialog; +} + class AmplifierControls : public EffectControls { Q_OBJECT public: AmplifierControls( AmplifierEffect* effect ); - virtual ~AmplifierControls() - { - } + ~AmplifierControls() override = default; - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); - inline virtual QString nodeName() const + void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; + inline QString nodeName() const override { return "AmplifierControls"; } - virtual int controlCount() + int controlCount() override { return 4; } - virtual EffectControlDialog* createView() + gui::EffectControlDialog* createView() override { - return new AmplifierControlDialog( this ); + return new gui::AmplifierControlDialog( this ); } @@ -70,9 +75,12 @@ private: FloatModel m_leftModel; FloatModel m_rightModel; - friend class AmplifierControlDialog; + friend class gui::AmplifierControlDialog; friend class AmplifierEffect; } ; + +} // namespace lmms + #endif diff --git a/plugins/AudioFileProcessor/AudioFileProcessor.cpp b/plugins/AudioFileProcessor/AudioFileProcessor.cpp index d3c13511b..2e2d7163b 100644 --- a/plugins/AudioFileProcessor/AudioFileProcessor.cpp +++ b/plugins/AudioFileProcessor/AudioFileProcessor.cpp @@ -47,12 +47,17 @@ #include "embed.h" #include "plugin_export.h" + +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT audiofileprocessor_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "AudioFileProcessor", QT_TRANSLATE_NOOP( "PluginBrowser", "Simple sampler with various settings for " @@ -110,13 +115,6 @@ AudioFileProcessor::AudioFileProcessor( InstrumentTrack * _instrument_track ) : -AudioFileProcessor::~AudioFileProcessor() -{ -} - - - - void AudioFileProcessor::playNote( NotePlayHandle * _n, sampleFrame * _working_buffer ) { @@ -291,7 +289,7 @@ void AudioFileProcessor::loadFile( const QString & _file ) -QString AudioFileProcessor::nodeName( void ) const +QString AudioFileProcessor::nodeName() const { return audiofileprocessor_plugin_descriptor.name; } @@ -312,9 +310,9 @@ int AudioFileProcessor::getBeatLen( NotePlayHandle * _n ) const -PluginView * AudioFileProcessor::instantiateView( QWidget * _parent ) +gui::PluginView* AudioFileProcessor::instantiateView( QWidget * _parent ) { - return new AudioFileProcessorView( this, _parent ); + return new gui::AudioFileProcessorView( this, _parent ); } @@ -341,7 +339,7 @@ void AudioFileProcessor::setAudioFile( const QString & _audio_file, -void AudioFileProcessor::reverseModelChanged( void ) +void AudioFileProcessor::reverseModelChanged() { m_sampleBuffer.setReversed( m_reverseModel.value() ); m_nextPlayStartPoint = m_sampleBuffer.startFrame(); @@ -351,7 +349,7 @@ void AudioFileProcessor::reverseModelChanged( void ) -void AudioFileProcessor::ampModelChanged( void ) +void AudioFileProcessor::ampModelChanged() { m_sampleBuffer.setAmplification( m_ampModel.value() / 100.0f ); } @@ -364,7 +362,7 @@ void AudioFileProcessor::stutterModelChanged() } -void AudioFileProcessor::startPointChanged( void ) +void AudioFileProcessor::startPointChanged() { // check if start is over end and swap values if so if( m_startPointModel.value() > m_endPointModel.value() ) @@ -396,14 +394,14 @@ void AudioFileProcessor::startPointChanged( void ) } -void AudioFileProcessor::endPointChanged( void ) +void AudioFileProcessor::endPointChanged() { // same as start, for now startPointChanged(); } -void AudioFileProcessor::loopPointChanged( void ) +void AudioFileProcessor::loopPointChanged() { // check that loop point is between start-end points and not overlapping with endpoint @@ -426,11 +424,11 @@ void AudioFileProcessor::loopPointChanged( void ) pointChanged(); } -void AudioFileProcessor::pointChanged( void ) +void AudioFileProcessor::pointChanged() { - const f_cnt_t f_start = static_cast( m_startPointModel.value() * ( m_sampleBuffer.frames()-1 ) ); - const f_cnt_t f_end = static_cast( m_endPointModel.value() * ( m_sampleBuffer.frames()-1 ) ); - const f_cnt_t f_loop = static_cast( m_loopPointModel.value() * ( m_sampleBuffer.frames()-1 ) ); + const auto f_start = static_cast(m_startPointModel.value() * m_sampleBuffer.frames()); + const auto f_end = static_cast(m_endPointModel.value() * m_sampleBuffer.frames()); + const auto f_loop = static_cast(m_loopPointModel.value() * m_sampleBuffer.frames()); m_nextPlayStartPoint = f_start; m_nextPlayBackwards = false; @@ -442,6 +440,8 @@ void AudioFileProcessor::pointChanged( void ) +namespace gui +{ QPixmap * AudioFileProcessorView::s_artwork = nullptr; @@ -479,7 +479,7 @@ AudioFileProcessorView::AudioFileProcessorView( Instrument * _instrument, // loop button group - PixmapButton * m_loopOffButton = new PixmapButton( this ); + auto m_loopOffButton = new PixmapButton(this); m_loopOffButton->setCheckable( true ); m_loopOffButton->move( 190, 105 ); m_loopOffButton->setActiveGraphic( PLUGIN_NAME::getIconPixmap( @@ -488,8 +488,7 @@ AudioFileProcessorView::AudioFileProcessorView( Instrument * _instrument, "loop_off_off" ) ); m_loopOffButton->setToolTip(tr("Disable loop")); - - PixmapButton * m_loopOnButton = new PixmapButton( this ); + auto m_loopOnButton = new PixmapButton(this); m_loopOnButton->setCheckable( true ); m_loopOnButton->move( 190, 124 ); m_loopOnButton->setActiveGraphic( PLUGIN_NAME::getIconPixmap( @@ -498,7 +497,7 @@ AudioFileProcessorView::AudioFileProcessorView( Instrument * _instrument, "loop_on_off" ) ); m_loopOnButton->setToolTip(tr("Enable loop")); - PixmapButton * m_loopPingPongButton = new PixmapButton( this ); + auto m_loopPingPongButton = new PixmapButton(this); m_loopPingPongButton->setCheckable( true ); m_loopPingPongButton->move( 216, 124 ); m_loopPingPongButton->setActiveGraphic( PLUGIN_NAME::getIconPixmap( @@ -548,10 +547,10 @@ AudioFileProcessorView::AudioFileProcessorView( Instrument * _instrument, m_waveView = 0; newWaveView(); - connect( castModel(), SIGNAL( isPlaying( f_cnt_t ) ), - m_waveView, SLOT( isPlaying( f_cnt_t ) ) ); + connect( castModel(), SIGNAL( isPlaying( lmms::f_cnt_t ) ), + m_waveView, SLOT( isPlaying( lmms::f_cnt_t ) ) ); - qRegisterMetaType( "f_cnt_t" ); + qRegisterMetaType( "lmms::f_cnt_t" ); setAcceptDrops( true ); } @@ -559,9 +558,6 @@ AudioFileProcessorView::AudioFileProcessorView( Instrument * _instrument, -AudioFileProcessorView::~AudioFileProcessorView() -{ -} @@ -648,9 +644,9 @@ void AudioFileProcessorView::paintEvent( QPaintEvent * ) p.drawPixmap( 0, 0, *s_artwork ); - AudioFileProcessor * a = castModel(); + auto a = castModel(); - QString file_name = ""; + QString file_name = ""; int idx = a->m_sampleBuffer.audioFile().length(); p.setFont( pointSize<8>( font() ) ); @@ -677,7 +673,7 @@ void AudioFileProcessorView::paintEvent( QPaintEvent * ) -void AudioFileProcessorView::sampleUpdated( void ) +void AudioFileProcessorView::sampleUpdated() { m_waveView->updateSampleRange(); m_waveView->update(); @@ -688,7 +684,7 @@ void AudioFileProcessorView::sampleUpdated( void ) -void AudioFileProcessorView::openAudioFile( void ) +void AudioFileProcessorView::openAudioFile() { QString af = castModel()->m_sampleBuffer. openAudioFile(); @@ -703,9 +699,9 @@ void AudioFileProcessorView::openAudioFile( void ) -void AudioFileProcessorView::modelChanged( void ) +void AudioFileProcessorView::modelChanged() { - AudioFileProcessor * a = castModel(); + auto a = castModel(); connect( &a->m_sampleBuffer, SIGNAL( sampleUpdated() ), this, SLOT( sampleUpdated() ) ); m_ampKnob->setModel( &a->m_ampModel ); @@ -1242,7 +1238,7 @@ float AudioFileProcessorWaveView::knob::getValue( const QPoint & _p ) const double dec_fact = ! m_waveView ? 1 : double( m_waveView->m_to - m_waveView->m_from ) / m_waveView->m_sampleBuffer.frames(); - const float inc = ::Knob::getValue( _p ) * dec_fact; + const float inc = Knob::getValue( _p ) * dec_fact; return inc; } @@ -1273,6 +1269,7 @@ bool AudioFileProcessorWaveView::knob::checkBound( double _v ) const } +} // namespace gui @@ -1288,3 +1285,6 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main(Model * model, void *) } + + +} // namespace lmms diff --git a/plugins/AudioFileProcessor/AudioFileProcessor.h b/plugins/AudioFileProcessor/AudioFileProcessor.h index 532a16114..b80954577 100644 --- a/plugins/AudioFileProcessor/AudioFileProcessor.h +++ b/plugins/AudioFileProcessor/AudioFileProcessor.h @@ -35,9 +35,20 @@ #include "SampleBuffer.h" #include "Knob.h" + +namespace lmms +{ + +namespace gui +{ class automatableButtonGroup; -class ComboBox; +class PluginView; +class InstrumentViewFixedSize; +class Knob; class PixmapButton; +class ComboBox; +class AudioFileProcessorView; +} class AudioFileProcessor : public Instrument @@ -45,28 +56,27 @@ class AudioFileProcessor : public Instrument Q_OBJECT public: AudioFileProcessor( InstrumentTrack * _instrument_track ); - virtual ~AudioFileProcessor(); - virtual void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ); - virtual void deleteNotePluginData( NotePlayHandle * _n ); + void playNote( NotePlayHandle * _n, + sampleFrame * _working_buffer ) override; + void deleteNotePluginData( NotePlayHandle * _n ) override; - virtual void saveSettings( QDomDocument & _doc, - QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); + void saveSettings( QDomDocument & _doc, + QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; - virtual void loadFile( const QString & _file ); + void loadFile( const QString & _file ) override; - virtual QString nodeName() const; + QString nodeName() const override; virtual int getBeatLen( NotePlayHandle * _n ) const; - virtual f_cnt_t desiredReleaseFrames() const + f_cnt_t desiredReleaseFrames() const override { return 128; } - virtual PluginView * instantiateView( QWidget * _parent ); + gui::PluginView* instantiateView( QWidget * _parent ) override; public slots: @@ -84,11 +94,11 @@ private slots: signals: - void isPlaying( f_cnt_t _current_frame ); + void isPlaying( lmms::f_cnt_t _current_frame ); private: - typedef SampleBuffer::handleState handleState; + using handleState = SampleBuffer::handleState; SampleBuffer m_sampleBuffer; @@ -104,21 +114,23 @@ private: f_cnt_t m_nextPlayStartPoint; bool m_nextPlayBackwards; - friend class AudioFileProcessorView; + friend class gui::AudioFileProcessorView; } ; +namespace gui +{ class AudioFileProcessorWaveView; -class AudioFileProcessorView : public InstrumentViewFixedSize +class AudioFileProcessorView : public gui::InstrumentViewFixedSize { Q_OBJECT public: AudioFileProcessorView( Instrument * _instrument, QWidget * _parent ); - virtual ~AudioFileProcessorView(); + virtual ~AudioFileProcessorView() = default; void newWaveView(); protected slots: @@ -143,7 +155,7 @@ private: Knob * m_endKnob; Knob * m_loopKnob; - PixmapButton * m_openAudioFileButton; + gui::PixmapButton * m_openAudioFileButton; PixmapButton * m_reverseButton; automatableButtonGroup * m_loopGroup; PixmapButton * m_stutterButton; @@ -174,7 +186,7 @@ public: loop } ; - class knob : public ::Knob + class knob : public Knob { const AudioFileProcessorWaveView * m_waveView; const Knob * m_relatedKnob; @@ -182,7 +194,7 @@ public: public: knob( QWidget * _parent ) : - ::Knob( knobBright_26, _parent ), + Knob( knobBright_26, _parent ), m_waveView( 0 ), m_relatedKnob( 0 ) { @@ -223,7 +235,7 @@ public slots: QWidget::update(); } - void isPlaying( f_cnt_t _current_frame ); + void isPlaying( lmms::f_cnt_t _current_frame ); private: @@ -287,6 +299,8 @@ private: } ; +} // namespace gui +} // namespace lmms #endif diff --git a/plugins/BassBooster/BassBooster.cpp b/plugins/BassBooster/BassBooster.cpp index f01e70720..48e265911 100644 --- a/plugins/BassBooster/BassBooster.cpp +++ b/plugins/BassBooster/BassBooster.cpp @@ -27,12 +27,16 @@ #include "embed.h" #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT bassbooster_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "BassBooster", QT_TRANSLATE_NOOP( "PluginBrowser", "Boost your bass the fast and simple way" ), "Tobias Doerffel ", @@ -61,9 +65,6 @@ BassBoosterEffect::BassBoosterEffect( Model* parent, const Descriptor::SubPlugin -BassBoosterEffect::~BassBoosterEffect() -{ -} @@ -101,7 +102,7 @@ bool BassBoosterEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames m_bbFX.leftFX().setGain( gain ); m_bbFX.rightFX().setGain( gain); - sample_t s[2] = { buf[f][0], buf[f][1] }; + auto s = std::array{buf[f][0], buf[f][1]}; m_bbFX.nextSample( s[0], s[1] ); buf[f][0] = d * buf[f][0] + w * s[0]; @@ -155,3 +156,5 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* parent, void* data ) } + +} // namespace lmms \ No newline at end of file diff --git a/plugins/BassBooster/BassBooster.h b/plugins/BassBooster/BassBooster.h index d3db6e220..ea3ba2d98 100644 --- a/plugins/BassBooster/BassBooster.h +++ b/plugins/BassBooster/BassBooster.h @@ -30,15 +30,17 @@ #include "DspEffectLibrary.h" #include "BassBoosterControls.h" +namespace lmms +{ class BassBoosterEffect : public Effect { public: BassBoosterEffect( Model* parent, const Descriptor::SubPluginFeatures::Key* key ); - virtual ~BassBoosterEffect(); - virtual bool processAudioBuffer( sampleFrame* buf, const fpp_t frames ); + ~BassBoosterEffect() override = default; + bool processAudioBuffer( sampleFrame* buf, const fpp_t frames ) override; - virtual EffectControls* controls() + EffectControls* controls() override { return &m_bbControls; } @@ -60,4 +62,7 @@ private: } ; + +} // namespace lmms + #endif diff --git a/plugins/BassBooster/BassBoosterControlDialog.cpp b/plugins/BassBooster/BassBoosterControlDialog.cpp index f7513e13e..21aacb0f2 100644 --- a/plugins/BassBooster/BassBoosterControlDialog.cpp +++ b/plugins/BassBooster/BassBoosterControlDialog.cpp @@ -32,6 +32,9 @@ #include "Knob.h" +namespace lmms::gui +{ + BassBoosterControlDialog::BassBoosterControlDialog( BassBoosterControls* controls ) : EffectControlDialog( controls ) @@ -42,22 +45,22 @@ BassBoosterControlDialog::BassBoosterControlDialog( BassBoosterControls* control setPalette( pal ); setFixedSize( 120, 60 ); - QVBoxLayout * tl = new QVBoxLayout( this ); + auto tl = new QVBoxLayout(this); tl->addSpacing( 4 ); - QHBoxLayout * l = new QHBoxLayout; + auto l = new QHBoxLayout; - Knob * freqKnob = new Knob( knobBright_26, this); + auto freqKnob = new Knob(knobBright_26, this); freqKnob->setModel( &controls->m_freqModel ); freqKnob->setLabel( tr( "FREQ" ) ); freqKnob->setHintText( tr( "Frequency:" ) , "Hz" ); - Knob * gainKnob = new Knob( knobBright_26, this ); + auto gainKnob = new Knob(knobBright_26, this); gainKnob->setModel( &controls->m_gainModel ); gainKnob->setLabel( tr( "GAIN" ) ); gainKnob->setHintText( tr( "Gain:" ) , "" ); - Knob * ratioKnob = new Knob( knobBright_26, this ); + auto ratioKnob = new Knob(knobBright_26, this); ratioKnob->setModel( &controls->m_ratioModel ); ratioKnob->setLabel( tr( "RATIO" ) ); ratioKnob->setHintText( tr( "Ratio:" ) , "" ); @@ -69,3 +72,6 @@ BassBoosterControlDialog::BassBoosterControlDialog( BassBoosterControls* control tl->addLayout( l ); setLayout( tl ); } + + +} // namespace lmms::gui diff --git a/plugins/BassBooster/BassBoosterControlDialog.h b/plugins/BassBooster/BassBoosterControlDialog.h index ec636e808..6c510282e 100644 --- a/plugins/BassBooster/BassBoosterControlDialog.h +++ b/plugins/BassBooster/BassBoosterControlDialog.h @@ -27,19 +27,26 @@ #include "EffectControlDialog.h" +namespace lmms +{ class BassBoosterControls; +namespace gui +{ class BassBoosterControlDialog : public EffectControlDialog { Q_OBJECT public: BassBoosterControlDialog( BassBoosterControls* controls ); - virtual ~BassBoosterControlDialog() - { - } + ~BassBoosterControlDialog() override = default; } ; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/BassBooster/BassBoosterControls.cpp b/plugins/BassBooster/BassBoosterControls.cpp index 195f00801..cda00043b 100644 --- a/plugins/BassBooster/BassBoosterControls.cpp +++ b/plugins/BassBooster/BassBoosterControls.cpp @@ -28,6 +28,8 @@ #include "BassBoosterControls.h" #include "BassBooster.h" +namespace lmms +{ BassBoosterControls::BassBoosterControls( BassBoosterEffect* effect ) : @@ -66,6 +68,4 @@ void BassBoosterControls::saveSettings( QDomDocument& doc, QDomElement& _this ) } - - - +} // namespace lmms diff --git a/plugins/BassBooster/BassBoosterControls.h b/plugins/BassBooster/BassBoosterControls.h index e7b61348a..bd93a5eb7 100644 --- a/plugins/BassBooster/BassBoosterControls.h +++ b/plugins/BassBooster/BassBoosterControls.h @@ -28,6 +28,8 @@ #include "EffectControls.h" #include "BassBoosterControlDialog.h" +namespace lmms +{ class BassBoosterEffect; @@ -37,25 +39,23 @@ class BassBoosterControls : public EffectControls Q_OBJECT public: BassBoosterControls( BassBoosterEffect* effect ); - virtual ~BassBoosterControls() - { - } + ~BassBoosterControls() override = default; - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); - inline virtual QString nodeName() const + void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; + inline QString nodeName() const override { return "bassboostercontrols"; } - virtual int controlCount() + int controlCount() override { return 3; } - virtual EffectControlDialog* createView() + gui::EffectControlDialog* createView() override { - return new BassBoosterControlDialog( this ); + return new gui::BassBoosterControlDialog( this ); } @@ -68,8 +68,11 @@ private: FloatModel m_gainModel; FloatModel m_ratioModel; - friend class BassBoosterControlDialog; + friend class gui::BassBoosterControlDialog; friend class BassBoosterEffect; } ; + +} // namespace lmms + #endif diff --git a/plugins/BitInvader/BitInvader.cpp b/plugins/BitInvader/BitInvader.cpp index 60c933949..947c6f5d6 100644 --- a/plugins/BitInvader/BitInvader.cpp +++ b/plugins/BitInvader/BitInvader.cpp @@ -42,6 +42,10 @@ #include "plugin_export.h" +namespace lmms +{ + + static const int wavetableSize = 200; static const float defaultNormalizationFactor = 1.0f; @@ -50,7 +54,7 @@ extern "C" Plugin::Descriptor PLUGIN_EXPORT bitinvader_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "BitInvader", QT_TRANSLATE_NOOP( "PluginBrowser", "Customizable wavetable synthesizer" ), @@ -99,10 +103,8 @@ BSynth::~BSynth() sample_t BSynth::nextStringSample( float sample_length ) { - float sample_step = - static_cast( sample_length / ( sample_rate / nph->frequency() ) ); + auto sample_step = static_cast(sample_length / (sample_rate / nph->frequency())); - // check overflow while (sample_realindex >= sample_length) { sample_realindex -= sample_length; @@ -157,8 +159,8 @@ BitInvader::BitInvader( InstrumentTrack * _instrument_track ) : m_graph.setWaveToSine(); lengthChanged(); - connect( &m_sampleLength, SIGNAL( dataChanged( ) ), - this, SLOT( lengthChanged( ) ), Qt::DirectConnection ); + connect( &m_sampleLength, SIGNAL( dataChanged() ), + this, SLOT( lengthChanged() ), Qt::DirectConnection ); connect( &m_graph, SIGNAL( samplesChanged( int, int ) ), this, SLOT( samplesChanged( int, int ) ) ); @@ -167,10 +169,6 @@ BitInvader::BitInvader( InstrumentTrack * _instrument_track ) : -BitInvader::~BitInvader() -{ -} - @@ -299,7 +297,7 @@ void BitInvader::playNote( NotePlayHandle * _n, const fpp_t frames = _n->framesLeftForCurrentPeriod(); const f_cnt_t offset = _n->noteOffset(); - BSynth * ps = static_cast( _n->m_pluginData ); + auto ps = static_cast(_n->m_pluginData); for( fpp_t frame = offset; frame < frames + offset; ++frame ) { const sample_t cur = ps->nextStringSample( m_graph.length() ); @@ -325,15 +323,16 @@ void BitInvader::deleteNotePluginData( NotePlayHandle * _n ) -PluginView * BitInvader::instantiateView( QWidget * _parent ) +gui::PluginView * BitInvader::instantiateView( QWidget * _parent ) { - return( new BitInvaderView( this, _parent ) ); + return( new gui::BitInvaderView( this, _parent ) ); } - +namespace gui +{ BitInvaderView::BitInvaderView( Instrument * _instrument, @@ -471,7 +470,7 @@ BitInvaderView::BitInvaderView( Instrument * _instrument, void BitInvaderView::modelChanged() { - BitInvader * b = castModel(); + auto b = castModel(); m_graph->setModel( &b->m_graph ); m_sampleLengthKnob->setModel( &b->m_sampleLength ); @@ -571,6 +570,7 @@ void BitInvaderView::normalizeToggled( bool value ) } +} // namespace gui extern "C" @@ -584,3 +584,6 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *m, void * ) } + + +} // namespace lmms \ No newline at end of file diff --git a/plugins/BitInvader/BitInvader.h b/plugins/BitInvader/BitInvader.h index 64d5bbfda..a08640e99 100644 --- a/plugins/BitInvader/BitInvader.h +++ b/plugins/BitInvader/BitInvader.h @@ -33,11 +33,18 @@ #include "Graph.h" #include "MemoryManager.h" -class oscillator; +namespace lmms +{ + + +namespace gui +{ class BitInvaderView; class Knob; class LedCheckBox; class PixmapButton; +} + class BSynth { @@ -67,25 +74,25 @@ class BitInvader : public Instrument Q_OBJECT public: BitInvader(InstrumentTrack * _instrument_track ); - virtual ~BitInvader(); + ~BitInvader() override = default; - virtual void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ); - virtual void deleteNotePluginData( NotePlayHandle * _n ); + void playNote( NotePlayHandle * _n, + sampleFrame * _working_buffer ) override; + void deleteNotePluginData( NotePlayHandle * _n ) override; - virtual void saveSettings( QDomDocument & _doc, - QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); + void saveSettings( QDomDocument & _doc, + QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; - virtual QString nodeName() const; + QString nodeName() const override; - virtual f_cnt_t desiredReleaseFrames() const + f_cnt_t desiredReleaseFrames() const override { return( 64 ); } - virtual PluginView * instantiateView( QWidget * _parent ); + gui::PluginView * instantiateView( QWidget * _parent ) override; protected slots: void lengthChanged(); @@ -103,10 +110,12 @@ private: float m_normalizeFactor; - friend class BitInvaderView; + friend class gui::BitInvaderView; } ; +namespace gui +{ class BitInvaderView : public InstrumentViewFixedSize { @@ -115,7 +124,7 @@ public: BitInvaderView( Instrument * _instrument, QWidget * _parent ); - virtual ~BitInvaderView() {}; + ~BitInvaderView() override = default; protected slots: //void sampleSizeChanged( float _new_sample_length ); @@ -130,10 +139,10 @@ protected slots: void noiseWaveClicked(); void usrWaveClicked(); - void smoothClicked( void ); + void smoothClicked( ); private: - virtual void modelChanged(); + void modelChanged() override; Knob * m_sampleLengthKnob; PixmapButton * m_sinWaveBtn; @@ -153,5 +162,8 @@ private: } ; +} // namespace gui + +} // namespace lmms #endif diff --git a/plugins/Bitcrush/Bitcrush.cpp b/plugins/Bitcrush/Bitcrush.cpp index 206f6307d..963e970db 100644 --- a/plugins/Bitcrush/Bitcrush.cpp +++ b/plugins/Bitcrush/Bitcrush.cpp @@ -27,19 +27,23 @@ #include "embed.h" #include "plugin_export.h" +namespace lmms +{ + + const int OS_RATE = 5; const float OS_RATIO = 1.0f / OS_RATE; const float CUTOFF_RATIO = 0.353553391f; const int SILENCEFRAMES = 10; -const float OS_RESAMPLE [5] = { 0.0001490062883964112, 0.1645978376763992, 0.6705063120704088, - 0.1645978376763992, 0.0001490062883964112 }; +const auto OS_RESAMPLE = std::array{0.0001490062883964112f, 0.1645978376763992f, 0.6705063120704088f, + 0.1645978376763992f, 0.0001490062883964112f }; extern "C" { Plugin::Descriptor PLUGIN_EXPORT bitcrush_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "Bitcrush", QT_TRANSLATE_NOOP( "PluginBrowser", "An oversampling bitcrusher" ), "Vesa Kivimäki ", @@ -61,13 +65,13 @@ BitcrushEffect::BitcrushEffect( Model * parent, const Descriptor::SubPluginFeatu m_buffer = MM_ALLOC( Engine::audioEngine()->framesPerPeriod() * OS_RATE ); m_filter.setLowpass( m_sampleRate * ( CUTOFF_RATIO * OS_RATIO ) ); m_needsUpdate = true; - + m_bitCounterL = 0.0f; m_bitCounterR = 0.0f; - + m_left = 0.0f; m_right = 0.0f; - + m_silenceCounter = 0; } @@ -121,7 +125,7 @@ bool BitcrushEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) m_rateCoeffL = ( m_sampleRate * OS_RATE ) / ( rate - diff ); m_rateCoeffR = ( m_sampleRate * OS_RATE ) / ( rate + diff ); - + m_bitCounterL = 0.0f; m_bitCounterR = 0.0f; } @@ -143,9 +147,9 @@ bool BitcrushEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) m_outClip = dbfsToAmp( m_controls.m_outClip.value() ); } m_needsUpdate = false; - + const float noiseAmt = m_controls.m_inNoise.value() * 0.01f; - + // read input buffer and write it to oversampled buffer if( m_rateEnabled ) // rate crushing enabled so do that { @@ -160,15 +164,15 @@ bool BitcrushEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) if( m_bitCounterL > m_rateCoeffL ) { m_bitCounterL -= m_rateCoeffL; - m_left = m_depthEnabled - ? depthCrush( buf[f][0] * m_inGain + noise( buf[f][0] * noiseAmt ) ) + m_left = m_depthEnabled + ? depthCrush( buf[f][0] * m_inGain + noise( buf[f][0] * noiseAmt ) ) : buf[f][0] * m_inGain + noise( buf[f][0] * noiseAmt ); } if( m_bitCounterR > m_rateCoeffR ) { m_bitCounterR -= m_rateCoeffR; - m_right = m_depthEnabled - ? depthCrush( buf[f][1] * m_inGain + noise( buf[f][1] * noiseAmt ) ) + m_right = m_depthEnabled + ? depthCrush( buf[f][1] * m_inGain + noise( buf[f][1] * noiseAmt ) ) : buf[f][1] * m_inGain + noise( buf[f][1] * noiseAmt ); } } @@ -181,17 +185,17 @@ bool BitcrushEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) for( int o = 0; o < OS_RATE; ++o ) { m_buffer[f * OS_RATE + o][0] = m_depthEnabled - ? depthCrush( buf[f][0] * m_inGain + noise( buf[f][0] * noiseAmt ) ) + ? depthCrush( buf[f][0] * m_inGain + noise( buf[f][0] * noiseAmt ) ) : buf[f][0] * m_inGain + noise( buf[f][0] * noiseAmt ); m_buffer[f * OS_RATE + o][1] = m_depthEnabled - ? depthCrush( buf[f][1] * m_inGain + noise( buf[f][1] * noiseAmt ) ) + ? depthCrush( buf[f][1] * m_inGain + noise( buf[f][1] * noiseAmt ) ) : buf[f][1] * m_inGain + noise( buf[f][1] * noiseAmt ); } } } - + // the oversampled buffer is now written, so filter it to reduce aliasing - + for( int f = 0; f < frames * OS_RATE; ++f ) { if( qMax( qAbs( m_buffer[f][0] ), qAbs( m_buffer[f][1] ) ) >= 1.0e-10f ) @@ -214,10 +218,10 @@ bool BitcrushEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) } } } - - + + // now downsample and write it back to main buffer - + double outSum = 0.0; const float d = dryLevel(); const float w = wetLevel(); @@ -234,7 +238,7 @@ bool BitcrushEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) buf[f][1] = d * buf[f][1] + w * qBound( -m_outClip, rsum, m_outClip ) * m_outGain; outSum += buf[f][0]*buf[f][0] + buf[f][1]*buf[f][1]; } - + checkGate( outSum / frames ); return isRunning(); @@ -251,3 +255,6 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* parent, void* data ) } } + + +} // namespace lmms \ No newline at end of file diff --git a/plugins/Bitcrush/Bitcrush.h b/plugins/Bitcrush/Bitcrush.h index f309021e1..a6e5556a2 100644 --- a/plugins/Bitcrush/Bitcrush.h +++ b/plugins/Bitcrush/Bitcrush.h @@ -31,14 +31,19 @@ #include "BitcrushControls.h" #include "BasicFilters.h" + +namespace lmms +{ + + class BitcrushEffect : public Effect { public: BitcrushEffect( Model* parent, const Descriptor::SubPluginFeatures::Key* key ); - virtual ~BitcrushEffect(); - virtual bool processAudioBuffer( sampleFrame* buf, const fpp_t frames ); + ~BitcrushEffect() override; + bool processAudioBuffer( sampleFrame* buf, const fpp_t frames ) override; - virtual EffectControls* controls() + EffectControls* controls() override { return &m_controls; } @@ -78,4 +83,7 @@ private: friend class BitcrushControls; }; + +} // namespace lmms + #endif diff --git a/plugins/Bitcrush/BitcrushControlDialog.cpp b/plugins/Bitcrush/BitcrushControlDialog.cpp old mode 100755 new mode 100644 index 43117f00b..f3dc85470 --- a/plugins/Bitcrush/BitcrushControlDialog.cpp +++ b/plugins/Bitcrush/BitcrushControlDialog.cpp @@ -32,6 +32,10 @@ #include "LedCheckBox.h" #include "Knob.h" +namespace lmms::gui +{ + + BitcrushControlDialog::BitcrushControlDialog( BitcrushControls * controls ) : EffectControlDialog( controls ) { @@ -42,20 +46,20 @@ BitcrushControlDialog::BitcrushControlDialog( BitcrushControls * controls ) : setFixedSize( 181, 128 ); // labels - QLabel * inLabel = new QLabel( tr( "IN" ), this ); + auto inLabel = new QLabel(tr("IN"), this); inLabel->move( 24, 15 ); - - QLabel * outLabel = new QLabel( tr( "OUT" ), this ); + + auto outLabel = new QLabel(tr("OUT"), this); outLabel->move( 139, 15 ); // input knobs - Knob * inGain = new Knob( knobBright_26, this ); + auto inGain = new Knob(knobBright_26, this); inGain->move( 16, 32 ); inGain->setModel( & controls->m_inGain ); inGain->setLabel( tr( "GAIN" ) ); inGain->setHintText( tr( "Input gain:" ) , " dBFS" ); - - Knob * inNoise = new Knob( knobBright_26, this ); + + auto inNoise = new Knob(knobBright_26, this); inNoise->move( 14, 76 ); inNoise->setModel( & controls->m_inNoise ); inNoise->setLabel( tr( "NOISE" ) ); @@ -63,13 +67,13 @@ BitcrushControlDialog::BitcrushControlDialog( BitcrushControls * controls ) : // output knobs - Knob * outGain = new Knob( knobBright_26, this ); + auto outGain = new Knob(knobBright_26, this); outGain->move( 138, 32 ); outGain->setModel( & controls->m_outGain ); outGain->setLabel( tr( "GAIN" ) ); outGain->setHintText( tr( "Output gain:" ) , " dBFS" ); - - Knob * outClip = new Knob( knobBright_26, this ); + + auto outClip = new Knob(knobBright_26, this); outClip->move( 138, 76 ); outClip->setModel( & controls->m_outClip ); outClip->setLabel( tr( "CLIP" ) ); @@ -78,25 +82,25 @@ BitcrushControlDialog::BitcrushControlDialog( BitcrushControls * controls ) : // leds - LedCheckBox * rateEnabled = new LedCheckBox( "", this, tr( "Rate enabled" ), LedCheckBox::Green ); + auto rateEnabled = new LedCheckBox("", this, tr("Rate enabled"), LedCheckBox::Green); rateEnabled->move( 64, 14 ); rateEnabled->setModel( & controls->m_rateEnabled ); rateEnabled->setToolTip(tr("Enable sample-rate crushing")); - - LedCheckBox * depthEnabled = new LedCheckBox( "", this, tr( "Depth enabled" ), LedCheckBox::Green ); + + auto depthEnabled = new LedCheckBox("", this, tr("Depth enabled"), LedCheckBox::Green); depthEnabled->move( 101, 14 ); depthEnabled->setModel( & controls->m_depthEnabled ); depthEnabled->setToolTip(tr("Enable bit-depth crushing")); // rate crushing knobs - Knob * rate = new Knob( knobBright_26, this ); + auto rate = new Knob(knobBright_26, this); rate->move( 59, 32 ); rate->setModel( & controls->m_rate ); rate->setLabel( tr( "FREQ" ) ); rate->setHintText( tr( "Sample rate:" ) , " Hz" ); - - Knob * stereoDiff = new Knob( knobBright_26, this ); + + auto stereoDiff = new Knob(knobBright_26, this); stereoDiff->move( 72, 76 ); stereoDiff->setModel( & controls->m_stereoDiff ); stereoDiff->setLabel( tr( "STEREO" ) ); @@ -104,9 +108,12 @@ BitcrushControlDialog::BitcrushControlDialog( BitcrushControls * controls ) : // depth crushing knob - Knob * levels = new Knob( knobBright_26, this ); + auto levels = new Knob(knobBright_26, this); levels->move( 92, 32 ); levels->setModel( & controls->m_levels ); levels->setLabel( tr( "QUANT" ) ); levels->setHintText( tr( "Levels:" ) , "" ); } + + +} // namespace lmms::gui \ No newline at end of file diff --git a/plugins/Bitcrush/BitcrushControlDialog.h b/plugins/Bitcrush/BitcrushControlDialog.h index c56b94c5a..ac409c0ab 100644 --- a/plugins/Bitcrush/BitcrushControlDialog.h +++ b/plugins/Bitcrush/BitcrushControlDialog.h @@ -29,16 +29,26 @@ #include "EffectControlDialog.h" +namespace lmms +{ + class BitcrushControls; + +namespace gui +{ + class BitcrushControlDialog : public EffectControlDialog { Q_OBJECT public: BitcrushControlDialog( BitcrushControls * controls ); - virtual ~BitcrushControlDialog() - { - } + ~BitcrushControlDialog() override = default; }; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/Bitcrush/BitcrushControls.cpp b/plugins/Bitcrush/BitcrushControls.cpp index 19886aa75..348f1288e 100644 --- a/plugins/Bitcrush/BitcrushControls.cpp +++ b/plugins/Bitcrush/BitcrushControls.cpp @@ -29,6 +29,10 @@ #include "BitcrushControls.h" #include "Bitcrush.h" +namespace lmms +{ + + BitcrushControls::BitcrushControls( BitcrushEffect * eff ) : EffectControls( eff ), @@ -38,7 +42,7 @@ BitcrushControls::BitcrushControls( BitcrushEffect * eff ) : m_outGain( 0.0f, -20.0f, 20.0f, 0.1f, this, tr( "Output gain" ) ), m_outClip( 0.0f, -20.0f, 20.0f, 0.1f, this, tr( "Output clip" ) ), m_rate( 44100.f, 20.f, 44100.f, 1.0f, this, tr( "Sample rate" ) ), - m_stereoDiff( 0.f, 0.f, 50.f, 0.1f, this, tr( "Stereo difference" ) ), + m_stereoDiff( 0.f, -50.f, 50.f, 0.1f, this, tr( "Stereo difference" ) ), m_levels( 256.f, 1.f, 256.f, 0.01f, this, tr( "Levels" ) ), m_rateEnabled( true, this, tr( "Rate enabled" ) ), m_depthEnabled( true, this, tr( "Depth enabled" ) ) @@ -49,9 +53,6 @@ BitcrushControls::BitcrushControls( BitcrushEffect * eff ) : connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( sampleRateChanged() ) ); } -BitcrushControls::~BitcrushControls() -{ -} void BitcrushControls::saveSettings( QDomDocument & doc, QDomElement & elem ) { @@ -86,3 +87,6 @@ void BitcrushControls::sampleRateChanged() { m_effect->sampleRateChanged(); } + + +} // namespace lmms \ No newline at end of file diff --git a/plugins/Bitcrush/BitcrushControls.h b/plugins/Bitcrush/BitcrushControls.h index 02c969196..7514baae9 100644 --- a/plugins/Bitcrush/BitcrushControls.h +++ b/plugins/Bitcrush/BitcrushControls.h @@ -29,6 +29,10 @@ #include "EffectControls.h" #include "BitcrushControlDialog.h" +namespace lmms +{ + + class BitcrushEffect; class BitcrushControls : public EffectControls @@ -36,23 +40,23 @@ class BitcrushControls : public EffectControls Q_OBJECT public: BitcrushControls( BitcrushEffect * eff ); - virtual ~BitcrushControls(); + ~BitcrushControls() override = default; - virtual void saveSettings( QDomDocument & doc, QDomElement & elem ); - virtual void loadSettings( const QDomElement & elem ); - inline virtual QString nodeName() const + void saveSettings( QDomDocument & doc, QDomElement & elem ) override; + void loadSettings( const QDomElement & elem ) override; + inline QString nodeName() const override { return( "bitcrushcontrols" ); } - virtual int controlCount() + int controlCount() override { return( 9 ); } - virtual EffectControlDialog * createView() + gui::EffectControlDialog * createView() override { - return( new BitcrushControlDialog( this ) ); + return( new gui::BitcrushControlDialog( this ) ); } private slots: @@ -75,8 +79,11 @@ private: BoolModel m_rateEnabled; BoolModel m_depthEnabled; - friend class BitcrushControlDialog; + friend class gui::BitcrushControlDialog; friend class BitcrushEffect; }; + +} // namespace lmms + #endif diff --git a/plugins/CarlaBase/Carla.cpp b/plugins/CarlaBase/Carla.cpp index a09b2367d..ef14b7aa4 100644 --- a/plugins/CarlaBase/Carla.cpp +++ b/plugins/CarlaBase/Carla.cpp @@ -58,6 +58,9 @@ #include "embed.h" +namespace lmms +{ + // this doesn't seem to be defined anywhere static const double ticksPerBeat = 48.0; @@ -145,6 +148,7 @@ static const char* host_ui_save_file(NativeHostHandle, bool isDir, const char* t // ----------------------------------------------------------------------- + CarlaInstrument::CarlaInstrument(InstrumentTrack* const instrumentTrack, const Descriptor* const descriptor, const bool isPatchbay) : Instrument(instrumentTrack, descriptor), kIsPatchbay(isPatchbay), @@ -190,8 +194,8 @@ CarlaInstrument::CarlaInstrument(InstrumentTrack* const instrumentTrack, const D fDescriptor->activate(fHandle); // we need a play-handle which cares for calling play() - InstrumentPlayHandle * iph = new InstrumentPlayHandle( this, instrumentTrack ); - Engine::audioEngine()->addPlayHandle( iph ); + auto iph = new InstrumentPlayHandle(this, instrumentTrack); + Engine::audioEngine()->addPlayHandle( iph ); #if CARLA_VERSION_HEX >= CARLA_MIN_PARAM_VERSION // text filter completion @@ -575,7 +579,7 @@ bool CarlaInstrument::handleMidiEvent(const MidiEvent& event, const TimePos&, f_ return true; } -PluginView* CarlaInstrument::instantiateView(QWidget* parent) +gui::PluginView* CarlaInstrument::instantiateView(QWidget* parent) { // Disable plugin focus per https://bugreports.qt.io/browse/QTBUG-30181 #ifndef CARLA_OS_MAC @@ -592,7 +596,7 @@ PluginView* CarlaInstrument::instantiateView(QWidget* parent) //fHost.uiName = strdup(parent->windowTitle().toUtf8().constData()); fHost.uiName = strdup(kIsPatchbay ? "CarlaPatchbay-LMMS" : "CarlaRack-LMMS"); - return new CarlaInstrumentView(this, parent); + return new gui::CarlaInstrumentView(this, parent); } void CarlaInstrument::sampleRateChanged() @@ -602,6 +606,9 @@ void CarlaInstrument::sampleRateChanged() // ------------------------------------------------------------------- +namespace gui +{ + CarlaInstrumentView::CarlaInstrumentView(CarlaInstrument* const instrument, QWidget* const parent) : InstrumentViewFixedSize(instrument, parent), fHandle(instrument->fHandle), @@ -618,8 +625,8 @@ CarlaInstrumentView::CarlaInstrumentView(CarlaInstrument* const instrument, QWid pal.setBrush(backgroundRole(), instrument->kIsPatchbay ? PLUGIN_NAME::getIconPixmap("artwork-patchbay") : PLUGIN_NAME::getIconPixmap("artwork-rack")); setPalette(pal); - QHBoxLayout* l = new QHBoxLayout(this); - l->setContentsMargins( 20, 180, 10, 10 ); + auto l = new QHBoxLayout(this); + l->setContentsMargins( 20, 180, 10, 10 ); l->setSpacing(3); l->setAlignment(Qt::AlignTop); @@ -743,8 +750,8 @@ CarlaParamsView::CarlaParamsView(CarlaInstrumentView* const instrumentView, QWid m_curOutColumn(0), m_curOutRow(0) { - QWidget* centralWidget = new QWidget(this); - QVBoxLayout* verticalLayout = new QVBoxLayout(centralWidget); + auto centralWidget = new QWidget(this); + auto verticalLayout = new QVBoxLayout(centralWidget); // -- Toolbar m_toolBarLayout = new QHBoxLayout(); @@ -787,9 +794,9 @@ CarlaParamsView::CarlaParamsView(CarlaInstrumentView* const instrumentView, QWid m_toolBarLayout->addWidget(m_groupFilterCombo); // -- Input params - QFrame* inputFrame = new QFrame(this); - QVBoxLayout* inputLayout = new QVBoxLayout(inputFrame); - QLabel* inputLabel = new QLabel("Input parameters", inputFrame); + auto inputFrame = new QFrame(this); + auto inputLayout = new QVBoxLayout(inputFrame); + auto inputLabel = new QLabel("Input parameters", inputFrame); m_inputScrollArea = new QScrollArea(inputFrame); m_inputScrollAreaWidgetContent = new QWidget(); @@ -813,9 +820,9 @@ CarlaParamsView::CarlaParamsView(CarlaInstrumentView* const instrumentView, QWid inputLayout->addWidget(m_inputScrollArea); // -- Output params - QFrame* outputFrame = new QFrame(this); - QVBoxLayout* outputLayout = new QVBoxLayout(outputFrame); - QLabel* outputLabel = new QLabel("Output parameters", outputFrame); + auto outputFrame = new QFrame(this); + auto outputLayout = new QVBoxLayout(outputFrame); + auto outputLabel = new QLabel("Output parameters", outputFrame); m_outputScrollArea = new QScrollArea(outputFrame); m_outputScrollAreaWidgetContent = new QWidget(); @@ -839,7 +846,7 @@ CarlaParamsView::CarlaParamsView(CarlaInstrumentView* const instrumentView, QWid outputLayout->addWidget(m_outputScrollArea); // -- QSplitter - QSplitter* splitter = new QSplitter(Qt::Vertical, this); + auto splitter = new QSplitter(Qt::Vertical, this); // -- Add layout and widgets. verticalLayout->addLayout(m_toolBarLayout); @@ -847,9 +854,20 @@ CarlaParamsView::CarlaParamsView(CarlaInstrumentView* const instrumentView, QWid splitter->addWidget(outputFrame); verticalLayout->addWidget(splitter); +#if QT_VERSION < 0x50C00 + // Workaround for a bug in Qt versions below 5.12, + // where argument-dependent-lookup fails for QFlags operators + // declared inside a namepsace. + // This affects the Q_DECLARE_OPERATORS_FOR_FLAGS macro in Instrument.h + // See also: https://codereview.qt-project.org/c/qt/qtbase/+/225348 + + using ::operator|; + +#endif + // -- Sub window - CarlaParamsSubWindow* win = new CarlaParamsSubWindow(getGUI()->mainWindow()->workspace()->viewport(), Qt::SubWindow | - Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint); + auto win = new CarlaParamsSubWindow(getGUI()->mainWindow()->workspace()->viewport(), + Qt::SubWindow | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint); m_carlaInstrumentView->m_paramsSubWindow = getGUI()->mainWindow()->workspace()->addSubWindow(win); m_carlaInstrumentView->m_paramsSubWindow->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); @@ -958,7 +976,7 @@ void CarlaParamsView::filterKnobs() } // Add spacer so all knobs go to top - QSpacerItem* verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); + auto verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); m_inputScrollAreaLayout->addItem(verticalSpacer, m_curRow+1, 0, 1, 1); } @@ -1043,6 +1061,17 @@ void CarlaParamsView::windowResized() void CarlaParamsView::addKnob(uint32_t index) { +#if QT_VERSION < 0x50C00 + // Workaround for a bug in Qt versions below 5.12, + // where argument-dependent-lookup fails for QFlags operators + // declared inside a namepsace. + // This affects the Q_DECLARE_OPERATORS_FOR_FLAGS macro in Instrument.h + // See also: https://codereview.qt-project.org/c/qt/qtbase/+/225348 + + using ::operator|; + +#endif + bool output = m_carlaInstrument->m_paramModels[index]->isOutput(); if (output) { @@ -1111,3 +1140,8 @@ void CarlaParamsView::clearKnobs() m_curOutColumn = 0; m_curOutRow = 0; } + + +} // namespace gui + +} // namespace lmms \ No newline at end of file diff --git a/plugins/CarlaBase/Carla.h b/plugins/CarlaBase/Carla.h index 98662014b..e04444f91 100644 --- a/plugins/CarlaBase/Carla.h +++ b/plugins/CarlaBase/Carla.h @@ -65,8 +65,16 @@ class QLineEdit; class QStringListModel; class QScrollArea; + +namespace lmms +{ + +namespace gui +{ class CarlaParamsView; +class CarlaInstrumentView; class Knob; +} class CarlaParamFloatModel : public FloatModel { @@ -85,7 +93,7 @@ public: return !reg.exactMatch(name); } - inline virtual void loadSettings(const QDomElement& element, const QString& name = QString("value")) override + inline void loadSettings(const QDomElement& element, const QString& name = QString("value")) override { AutomatableModel::loadSettings(element, name); bool mustQuote = mustQuoteName(name); @@ -96,7 +104,7 @@ public: } } - inline virtual void saveSettings(QDomDocument& doc, QDomElement& element, + inline void saveSettings(QDomDocument& doc, QDomElement& element, const QString& name = QString( "value" )) override { if (m_isEnabled) @@ -161,59 +169,6 @@ private: // ------------------------------------------------------------------- -class CarlaParamsSubWindow : public SubWindow -{ - Q_OBJECT - -signals: - void uiClosed(); - void resized(); - -public: - CarlaParamsSubWindow(QWidget * _parent, Qt::WindowFlags windowFlags) : - SubWindow(_parent) - { - setAttribute(Qt::WA_DeleteOnClose, false); - setWindowFlags(windowFlags); - } - - virtual void resizeEvent(QResizeEvent * event) override - { - if (mousePress) { - resizing = true; - } - SubWindow::resizeEvent(event); - } - - virtual void mousePressEvent(QMouseEvent * event) override - { - mousePress = true; - SubWindow::mousePressEvent(event); - } - - virtual void mouseReleaseEvent(QMouseEvent * event) override - { - if (resizing) { - resizing = false; - mousePress = false; - emit resized(); - } - SubWindow::mouseReleaseEvent(event); - } - - virtual void closeEvent(QCloseEvent * event) override - { - emit uiClosed(); - event->accept(); - } - -private: - bool resizing = false; - bool mousePress = false; -}; - -// ------------------------------------------------------------------- - class CARLABASE_EXPORT CarlaInstrument : public Instrument { Q_OBJECT @@ -222,7 +177,7 @@ public: static const uint32_t kMaxMidiEvents = 512; CarlaInstrument(InstrumentTrack* const instrumentTrack, const Descriptor* const descriptor, const bool isPatchbay); - virtual ~CarlaInstrument(); + ~CarlaInstrument() override; // Carla NativeHostDescriptor functions uint32_t handleGetBufferSize() const; @@ -234,13 +189,13 @@ public: intptr_t handleDispatcher(const NativeHostDispatcherOpcode opcode, const int32_t index, const intptr_t value, void* const ptr, const float opt); // LMMS functions - virtual Flags flags() const; - virtual QString nodeName() const; - virtual void saveSettings(QDomDocument& doc, QDomElement& parent); - virtual void loadSettings(const QDomElement& elem); - virtual void play(sampleFrame* workingBuffer); - virtual bool handleMidiEvent(const MidiEvent& event, const TimePos& time, f_cnt_t offset); - virtual PluginView* instantiateView(QWidget* parent); + Flags flags() const override; + QString nodeName() const override; + void saveSettings(QDomDocument& doc, QDomElement& parent) override; + void loadSettings(const QDomElement& elem) override; + void play(sampleFrame* workingBuffer) override; + bool handleMidiEvent(const MidiEvent& event, const TimePos& time, f_cnt_t offset) override; + gui::PluginView* instantiateView(QWidget* parent) override; signals: void uiClosed(); @@ -274,11 +229,67 @@ private: QCompleter* m_paramsCompleter; QStringListModel* m_completerModel; - friend class CarlaInstrumentView; - friend class CarlaParamsView; + friend class gui::CarlaInstrumentView; + friend class gui::CarlaParamsView; }; +// ------------------------------------------------------------------- + +namespace gui +{ + +class CarlaParamsSubWindow : public SubWindow +{ +Q_OBJECT + +signals: + void uiClosed(); + void resized(); + +public: + CarlaParamsSubWindow(QWidget * _parent, Qt::WindowFlags windowFlags) : + SubWindow(_parent) + { + setAttribute(Qt::WA_DeleteOnClose, false); + setWindowFlags(windowFlags); + } + + void resizeEvent(QResizeEvent * event) override + { + if (mousePress) { + resizing = true; + } + SubWindow::resizeEvent(event); + } + + void mousePressEvent(QMouseEvent * event) override + { + mousePress = true; + SubWindow::mousePressEvent(event); + } + + void mouseReleaseEvent(QMouseEvent * event) override + { + if (resizing) { + resizing = false; + mousePress = false; + emit resized(); + } + SubWindow::mouseReleaseEvent(event); + } + + void closeEvent(QCloseEvent * event) override + { + emit uiClosed(); + event->accept(); + } + +private: + bool resizing = false; + bool mousePress = false; +}; + // ------------------------------------------------------------------- class CarlaInstrumentView : public InstrumentViewFixedSize @@ -287,7 +298,7 @@ class CarlaInstrumentView : public InstrumentViewFixedSize public: CarlaInstrumentView(CarlaInstrument* const instrument, QWidget* const parent); - virtual ~CarlaInstrumentView(); + ~CarlaInstrumentView() override; private slots: void toggleUI(bool); @@ -296,8 +307,8 @@ private slots: void paramsUiClosed(); private: - virtual void modelChanged(); - virtual void timerEvent(QTimerEvent*); + void modelChanged() override; + void timerEvent(QTimerEvent*) override; NativePluginHandle fHandle; const NativePluginDescriptor* fDescriptor; @@ -322,7 +333,7 @@ class CarlaParamsView : public InstrumentView Q_OBJECT public: CarlaParamsView(CarlaInstrumentView* const instrumentView, QWidget* const parent); - virtual ~CarlaParamsView(); + ~CarlaParamsView() override; signals: void uiClosed(); @@ -365,4 +376,9 @@ private: QStringListModel* m_groupFilterModel; }; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/CarlaPatchbay/CarlaPatchbay.cpp b/plugins/CarlaPatchbay/CarlaPatchbay.cpp index 0c9ca9f01..e440d4e3f 100644 --- a/plugins/CarlaPatchbay/CarlaPatchbay.cpp +++ b/plugins/CarlaPatchbay/CarlaPatchbay.cpp @@ -28,12 +28,16 @@ #include "plugin_export.h" #include "InstrumentTrack.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT carlapatchbay_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "Carla Patchbay", QT_TRANSLATE_NOOP( "PluginBrowser", "Carla Patchbay Instrument" ), @@ -51,3 +55,6 @@ PLUGIN_EXPORT Plugin* lmms_plugin_main(Model* m, void*) } } + + +} // namespace lmms \ No newline at end of file diff --git a/plugins/CarlaRack/CarlaRack.cpp b/plugins/CarlaRack/CarlaRack.cpp index d8f0ac978..5360baf96 100644 --- a/plugins/CarlaRack/CarlaRack.cpp +++ b/plugins/CarlaRack/CarlaRack.cpp @@ -28,12 +28,16 @@ #include "plugin_export.h" #include "InstrumentTrack.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT carlarack_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "Carla Rack", QT_TRANSLATE_NOOP( "PluginBrowser", "Carla Rack Instrument" ), @@ -51,3 +55,6 @@ PLUGIN_EXPORT Plugin* lmms_plugin_main(Model* m, void*) } } + + +} // namespace lmms diff --git a/plugins/Compressor/Compressor.cpp b/plugins/Compressor/Compressor.cpp index 6728f403f..92123ffd9 100755 --- a/plugins/Compressor/Compressor.cpp +++ b/plugins/Compressor/Compressor.cpp @@ -29,12 +29,16 @@ #include "lmms_math.h" #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT compressor_plugin_descriptor = { - STRINGIFY(PLUGIN_NAME), + LMMS_STRINGIFY(PLUGIN_NAME), "Compressor", QT_TRANSLATE_NOOP("PluginBrowser", "A dynamic range compressor."), "Lost Robot ", @@ -93,11 +97,6 @@ CompressorEffect::CompressorEffect(Model* parent, const Descriptor::SubPluginFea -CompressorEffect::~CompressorEffect() -{ -} - - float CompressorEffect::msToCoeff(float ms) { // Convert time in milliseconds to applicable lowpass coefficient @@ -277,7 +276,7 @@ bool CompressorEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames) float rOutPeak = 0.0; float lInPeak = 0.0; float rInPeak = 0.0; - + const bool midside = m_compressorControls.m_midsideModel.value(); const bool peakmode = m_compressorControls.m_peakmodeModel.value(); const float inBalance = m_compressorControls.m_inBalanceModel.value(); @@ -293,8 +292,8 @@ bool CompressorEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames) for(fpp_t f = 0; f < frames; ++f) { - sample_t drySignal[2] = {buf[f][0], buf[f][1]}; - sample_t s[2] = {drySignal[0] * m_inGainVal, drySignal[1] * m_inGainVal}; + auto drySignal = std::array{buf[f][0], buf[f][1]}; + auto s = std::array{drySignal[0] * m_inGainVal, drySignal[1] * m_inGainVal}; // Calculate tilt filters, to bias the sidechain to the low or high frequencies if (m_tiltVal) @@ -513,7 +512,7 @@ bool CompressorEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames) m_inputBufLoc = 0; } - const float temp[2] = {drySignal[0], drySignal[1]}; + const auto temp = std::array{drySignal[0], drySignal[1]}; s[0] = m_inputBuf[0][m_inputBufLoc]; s[1] = m_inputBuf[1][m_inputBufLoc]; @@ -526,8 +525,8 @@ bool CompressorEffect::processAudioBuffer(sampleFrame* buf, const fpp_t frames) s[1] = drySignal[1]; } - float delayedDrySignal[2] = {s[0], s[1]}; - + auto delayedDrySignal = std::array{s[0], s[1]}; + if (midside)// Convert left/right to mid/side { const float temp = s[0]; @@ -662,3 +661,5 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main(Model* parent, void* data) } + +} // namespace lmms diff --git a/plugins/Compressor/Compressor.h b/plugins/Compressor/Compressor.h index 374f3f8b6..121e0b88f 100755 --- a/plugins/Compressor/Compressor.h +++ b/plugins/Compressor/Compressor.h @@ -31,6 +31,10 @@ #include "Effect.h" +namespace lmms +{ + + constexpr float COMP_LOG = -2.2; class CompressorEffect : public Effect @@ -38,7 +42,7 @@ class CompressorEffect : public Effect Q_OBJECT public: CompressorEffect(Model* parent, const Descriptor::SubPluginFeatures::Key* key); - ~CompressorEffect() override; + ~CompressorEffect() override = default; bool processAudioBuffer(sampleFrame* buf, const fpp_t frames) override; EffectControls* controls() override @@ -145,7 +149,10 @@ private: bool m_redrawThreshold = true; friend class CompressorControls; - friend class CompressorControlDialog; + friend class gui::CompressorControlDialog; } ; + +} // namespace lmms + #endif diff --git a/plugins/Compressor/CompressorControlDialog.cpp b/plugins/Compressor/CompressorControlDialog.cpp index 106aa7a1d..8c6f61bec 100755 --- a/plugins/Compressor/CompressorControlDialog.cpp +++ b/plugins/Compressor/CompressorControlDialog.cpp @@ -39,6 +39,10 @@ #include "MainWindow.h" #include "PixmapButton.h" +namespace lmms::gui +{ + + CompressorControlDialog::CompressorControlDialog(CompressorControls* controls) : EffectControlDialog(controls), m_controls(controls), @@ -202,7 +206,7 @@ CompressorControlDialog::CompressorControlDialog(CompressorControls* controls) : peakButton->setActiveGraphic(PLUGIN_NAME::getIconPixmap("peak_sel")); peakButton->setInactiveGraphic(PLUGIN_NAME::getIconPixmap("peak_unsel")); peakButton->setToolTip(tr("Use absolute value of the input")); - + rmsPeakGroup = new automatableButtonGroup(this); rmsPeakGroup->addButton(rmsButton); rmsPeakGroup->addButton(peakButton); @@ -217,7 +221,7 @@ CompressorControlDialog::CompressorControlDialog(CompressorControls* controls) : midSideButton->setActiveGraphic(PLUGIN_NAME::getIconPixmap("midside_sel")); midSideButton->setInactiveGraphic(PLUGIN_NAME::getIconPixmap("midside_unsel")); midSideButton->setToolTip(tr("Compress mid and side audio")); - + leftRightMidSideGroup = new automatableButtonGroup(this); leftRightMidSideGroup->addButton(leftRightButton); leftRightMidSideGroup->addButton(midSideButton); @@ -510,8 +514,8 @@ void CompressorControlDialog::redrawKnee() { m_p.setPen(QPen(m_kneeColor2, 3)); - float prevPoint[2] = {kneePoint1, kneePoint1}; - float newPoint[2] = {0, 0}; + auto prevPoint = std::array{kneePoint1, kneePoint1}; + auto newPoint = std::array{0.f, 0.f}; // Draw knee curve using many straight lines. for (int i = 0; i < COMP_KNEE_LINES; ++i) @@ -538,7 +542,7 @@ void CompressorControlDialog::redrawKnee() m_p.end(); m_p.begin(&m_kneePixmap2); - + m_p.setCompositionMode(QPainter::CompositionMode_Source); m_p.fillRect(0, 0, m_windowSizeX, m_kneeWindowSizeY, QColor("transparent")); m_p.setCompositionMode(QPainter::CompositionMode_SourceOver); @@ -762,3 +766,6 @@ void CompressorControlDialog::resetCompressorView() m_autoReleaseKnob->move(m_controlsBoxX + 590, m_controlsBoxY + 38); lookaheadButton->move(m_controlsBoxX + 202, m_controlsBoxY + 171); } + + +} // namespace lmms::gui \ No newline at end of file diff --git a/plugins/Compressor/CompressorControlDialog.h b/plugins/Compressor/CompressorControlDialog.h index f20a1d220..1324d7e26 100755 --- a/plugins/Compressor/CompressorControlDialog.h +++ b/plugins/Compressor/CompressorControlDialog.h @@ -31,6 +31,18 @@ #include "EffectControlDialog.h" +class QLabel; + +namespace lmms +{ + +constexpr float COMP_NOISE_FLOOR = 0.000001;// -120 dbFs + +class CompressorControls; + + +namespace gui +{ constexpr int COMP_MILLI_PER_PIXEL = 6; constexpr int MIN_COMP_SCREEN_X = 800; @@ -47,16 +59,11 @@ constexpr int COMP_BOX_Y = 280; constexpr float COMP_GRID_SPACING = 3.f;// 3 db per grid line constexpr float COMP_GRID_MAX = 96.f;// Can't zoom out past 96 db -constexpr float COMP_NOISE_FLOOR = 0.000001;// -120 dbFs - - - class automatableButtonGroup; -class CompressorControls; -class EqFader; class Knob; class PixmapButton; -class QLabel; +class EqFader; + class CompressorControlDialog : public EffectControlDialog { @@ -213,4 +220,10 @@ private: friend class CompressorControls; } ; + + +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/Compressor/CompressorControls.cpp b/plugins/Compressor/CompressorControls.cpp index 01d44c245..81247e900 100755 --- a/plugins/Compressor/CompressorControls.cpp +++ b/plugins/Compressor/CompressorControls.cpp @@ -29,6 +29,8 @@ #include +namespace lmms +{ CompressorControls::CompressorControls(CompressorEffect* effect) : EffectControls(effect), @@ -143,3 +145,4 @@ void CompressorControls::loadSettings(const QDomElement& _this) } +} // namespace lmms \ No newline at end of file diff --git a/plugins/Compressor/CompressorControls.h b/plugins/Compressor/CompressorControls.h index 233b89ddf..852781f38 100755 --- a/plugins/Compressor/CompressorControls.h +++ b/plugins/Compressor/CompressorControls.h @@ -29,6 +29,8 @@ #include "EffectControls.h" +namespace lmms +{ class CompressorEffect; @@ -51,9 +53,9 @@ public: return 28; } - EffectControlDialog* createView() override + gui::EffectControlDialog* createView() override { - return new CompressorControlDialog(this); + return new gui::CompressorControlDialog(this); } private: @@ -93,9 +95,12 @@ private: float m_outPeakL; float m_outPeakR; - friend class CompressorControlDialog; + friend class gui::CompressorControlDialog; friend class CompressorEffect; } ; + +} // namespace lmms + #endif diff --git a/plugins/CrossoverEQ/CrossoverEQ.cpp b/plugins/CrossoverEQ/CrossoverEQ.cpp index 92a3f6a6d..641e06b4e 100644 --- a/plugins/CrossoverEQ/CrossoverEQ.cpp +++ b/plugins/CrossoverEQ/CrossoverEQ.cpp @@ -29,12 +29,16 @@ #include "embed.h" #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT crossovereq_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "Crossover Equalizer", QT_TRANSLATE_NOOP( "PluginBrowser", "A 4-band Crossover Equalizer" ), "Vesa Kivimäki ", @@ -222,3 +226,6 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* parent, void* data ) } } + + +} // namespace lmms \ No newline at end of file diff --git a/plugins/CrossoverEQ/CrossoverEQ.h b/plugins/CrossoverEQ/CrossoverEQ.h index d1f76c1e6..fe9b4541b 100644 --- a/plugins/CrossoverEQ/CrossoverEQ.h +++ b/plugins/CrossoverEQ/CrossoverEQ.h @@ -31,14 +31,18 @@ #include "CrossoverEQControls.h" #include "BasicFilters.h" +namespace lmms +{ + + class CrossoverEQEffect : public Effect { public: CrossoverEQEffect( Model* parent, const Descriptor::SubPluginFeatures::Key* key ); - virtual ~CrossoverEQEffect(); - virtual bool processAudioBuffer( sampleFrame* buf, const fpp_t frames ); + ~CrossoverEQEffect() override; + bool processAudioBuffer( sampleFrame* buf, const fpp_t frames ) override; - virtual EffectControls* controls() + EffectControls* controls() override { return &m_controls; } @@ -74,4 +78,7 @@ private: friend class CrossoverEQControls; }; + +} // namespace lmms + #endif diff --git a/plugins/CrossoverEQ/CrossoverEQControlDialog.cpp b/plugins/CrossoverEQ/CrossoverEQControlDialog.cpp index 7cf2d0c5b..ba32e9dfc 100644 --- a/plugins/CrossoverEQ/CrossoverEQControlDialog.cpp +++ b/plugins/CrossoverEQ/CrossoverEQControlDialog.cpp @@ -32,6 +32,10 @@ #include "Knob.h" #include "Fader.h" +namespace lmms::gui +{ + + CrossoverEQControlDialog::CrossoverEQControlDialog( CrossoverEQControls * controls ) : EffectControlDialog( controls ) { @@ -42,19 +46,19 @@ CrossoverEQControlDialog::CrossoverEQControlDialog( CrossoverEQControls * contro setFixedSize( 167, 178 ); // knobs - Knob * xover12 = new Knob( knobBright_26, this ); + auto xover12 = new Knob(knobBright_26, this); xover12->move( 29, 11 ); xover12->setModel( & controls->m_xover12 ); xover12->setLabel( "1/2" ); xover12->setHintText( tr( "Band 1/2 crossover:" ), " Hz" ); - - Knob * xover23 = new Knob( knobBright_26, this ); + + auto xover23 = new Knob(knobBright_26, this); xover23->move( 69, 11 ); xover23->setModel( & controls->m_xover23 ); xover23->setLabel( "2/3" ); xover23->setHintText( tr( "Band 2/3 crossover:" ), " Hz" ); - - Knob * xover34 = new Knob( knobBright_26, this ); + + auto xover34 = new Knob(knobBright_26, this); xover34->move( 109, 11 ); xover34->setModel( & controls->m_xover34 ); xover34->setLabel( "3/4" ); @@ -65,48 +69,47 @@ CrossoverEQControlDialog::CrossoverEQControlDialog( CrossoverEQControls * contro m_fader_knob = QPixmap( PLUGIN_NAME::getIconPixmap( "fader_knob2" ) ); // faders - Fader * gain1 = new Fader( &controls->m_gain1, tr( "Band 1 gain" ), this, - &m_fader_bg, &m_fader_empty, &m_fader_knob ); + auto gain1 = new Fader(&controls->m_gain1, tr("Band 1 gain"), this, &m_fader_bg, &m_fader_empty, &m_fader_knob); gain1->move( 7, 56 ); gain1->setDisplayConversion( false ); gain1->setHintText( tr( "Band 1 gain:" ), " dBFS" ); - - Fader * gain2 = new Fader( &controls->m_gain2, tr( "Band 2 gain" ), this, - &m_fader_bg, &m_fader_empty, &m_fader_knob ); + + auto gain2 = new Fader(&controls->m_gain2, tr("Band 2 gain"), this, &m_fader_bg, &m_fader_empty, &m_fader_knob); gain2->move( 47, 56 ); gain2->setDisplayConversion( false ); gain2->setHintText( tr( "Band 2 gain:" ), " dBFS" ); - - Fader * gain3 = new Fader( &controls->m_gain3, tr( "Band 3 gain" ), this, - &m_fader_bg, &m_fader_empty, &m_fader_knob ); + + auto gain3 = new Fader(&controls->m_gain3, tr("Band 3 gain"), this, &m_fader_bg, &m_fader_empty, &m_fader_knob); gain3->move( 87, 56 ); gain3->setDisplayConversion( false ); gain3->setHintText( tr( "Band 3 gain:" ), " dBFS" ); - - Fader * gain4 = new Fader( &controls->m_gain4, tr( "Band 4 gain" ), this, - &m_fader_bg, &m_fader_empty, &m_fader_knob ); + + auto gain4 = new Fader(&controls->m_gain4, tr("Band 4 gain"), this, &m_fader_bg, &m_fader_empty, &m_fader_knob); gain4->move( 127, 56 ); gain4->setDisplayConversion( false ); gain4->setHintText( tr( "Band 4 gain:" ), " dBFS" ); // leds - LedCheckBox * mute1 = new LedCheckBox( "", this, tr( "Band 1 mute" ), LedCheckBox::Green ); + auto mute1 = new LedCheckBox("", this, tr("Band 1 mute"), LedCheckBox::Green); mute1->move( 15, 154 ); mute1->setModel( & controls->m_mute1 ); mute1->setToolTip(tr("Mute band 1")); - - LedCheckBox * mute2 = new LedCheckBox( "", this, tr( "Band 2 mute" ), LedCheckBox::Green ); + + auto mute2 = new LedCheckBox("", this, tr("Band 2 mute"), LedCheckBox::Green); mute2->move( 55, 154 ); mute2->setModel( & controls->m_mute2 ); mute2->setToolTip(tr("Mute band 2")); - - LedCheckBox * mute3 = new LedCheckBox( "", this, tr( "Band 3 mute" ), LedCheckBox::Green ); + + auto mute3 = new LedCheckBox("", this, tr("Band 3 mute"), LedCheckBox::Green); mute3->move( 95, 154 ); mute3->setModel( & controls->m_mute3 ); mute3->setToolTip(tr("Mute band 3")); - - LedCheckBox * mute4 = new LedCheckBox( "", this, tr( "Band 4 mute" ), LedCheckBox::Green ); + + auto mute4 = new LedCheckBox("", this, tr("Band 4 mute"), LedCheckBox::Green); mute4->move( 135, 154 ); mute4->setModel( & controls->m_mute4 ); mute4->setToolTip(tr("Mute band 4")); } + + +} // namespace lmms::gui \ No newline at end of file diff --git a/plugins/CrossoverEQ/CrossoverEQControlDialog.h b/plugins/CrossoverEQ/CrossoverEQControlDialog.h index e1e9f013d..9ddb5d9bf 100644 --- a/plugins/CrossoverEQ/CrossoverEQControlDialog.h +++ b/plugins/CrossoverEQ/CrossoverEQControlDialog.h @@ -30,16 +30,22 @@ #include #include "EffectControlDialog.h" +namespace lmms +{ + + class CrossoverEQControls; + +namespace gui +{ + class CrossoverEQControlDialog : public EffectControlDialog { Q_OBJECT public: CrossoverEQControlDialog( CrossoverEQControls * controls ); - virtual ~CrossoverEQControlDialog() - { - } + ~CrossoverEQControlDialog() override = default; private: QPixmap m_fader_bg; @@ -47,4 +53,9 @@ private: QPixmap m_fader_knob; }; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/CrossoverEQ/CrossoverEQControls.cpp b/plugins/CrossoverEQ/CrossoverEQControls.cpp index 19c1163a3..9758d804a 100644 --- a/plugins/CrossoverEQ/CrossoverEQControls.cpp +++ b/plugins/CrossoverEQ/CrossoverEQControls.cpp @@ -27,6 +27,10 @@ #include "CrossoverEQControls.h" #include "CrossoverEQ.h" +namespace lmms +{ + + CrossoverEQControls::CrossoverEQControls( CrossoverEQEffect * eff ) : EffectControls( eff ), m_effect( eff ), @@ -115,3 +119,6 @@ void CrossoverEQControls::sampleRateChanged() { m_effect->sampleRateChanged(); } + + +} // namespace lmms \ No newline at end of file diff --git a/plugins/CrossoverEQ/CrossoverEQControls.h b/plugins/CrossoverEQ/CrossoverEQControls.h index 3823a8370..715311aba 100644 --- a/plugins/CrossoverEQ/CrossoverEQControls.h +++ b/plugins/CrossoverEQ/CrossoverEQControls.h @@ -30,6 +30,9 @@ #include "EffectControls.h" #include "CrossoverEQControlDialog.h" +namespace lmms +{ + class CrossoverEQEffect; class CrossoverEQControls : public EffectControls @@ -37,23 +40,23 @@ class CrossoverEQControls : public EffectControls Q_OBJECT public: CrossoverEQControls( CrossoverEQEffect * eff ); - virtual ~CrossoverEQControls() {} + ~CrossoverEQControls() override = default; - virtual void saveSettings( QDomDocument & doc, QDomElement & elem ); - virtual void loadSettings( const QDomElement & elem ); - inline virtual QString nodeName() const + void saveSettings( QDomDocument & doc, QDomElement & elem ) override; + void loadSettings( const QDomElement & elem ) override; + inline QString nodeName() const override { return( "crossoevereqcontrols" ); } - virtual int controlCount() + int controlCount() override { return( 11 ); } - virtual EffectControlDialog * createView() + gui::EffectControlDialog * createView() override { - return( new CrossoverEQControlDialog( this ) ); + return( new gui::CrossoverEQControlDialog( this ) ); } private slots: @@ -79,8 +82,11 @@ private: BoolModel m_mute3; BoolModel m_mute4; - friend class CrossoverEQControlDialog; + friend class gui::CrossoverEQControlDialog; friend class CrossoverEQEffect; }; + +} // namespace lmms + #endif diff --git a/plugins/Delay/DelayControls.cpp b/plugins/Delay/DelayControls.cpp index d4b3220a9..b31488f72 100644 --- a/plugins/Delay/DelayControls.cpp +++ b/plugins/Delay/DelayControls.cpp @@ -28,6 +28,9 @@ #include "DelayEffect.h" #include "Engine.h" +namespace lmms +{ + DelayControls::DelayControls( DelayEffect* effect ): EffectControls( effect ), m_effect ( effect ), @@ -72,3 +75,6 @@ void DelayControls::changeSampleRate() { m_effect->changeSampleRate(); } + + +} // namespace lmms \ No newline at end of file diff --git a/plugins/Delay/DelayControls.h b/plugins/Delay/DelayControls.h index c912a453e..b9eb663fc 100644 --- a/plugins/Delay/DelayControls.h +++ b/plugins/Delay/DelayControls.h @@ -28,30 +28,31 @@ #include "EffectControls.h" #include "DelayControlsDialog.h" +namespace lmms +{ class DelayEffect; + class DelayControls : public EffectControls { Q_OBJECT public: DelayControls( DelayEffect* effect ); - virtual ~DelayControls() - { - } - virtual void saveSettings( QDomDocument& doc, QDomElement& parent ); - virtual void loadSettings( const QDomElement& _this ); - inline virtual QString nodeName() const + ~DelayControls() override = default; + void saveSettings( QDomDocument& doc, QDomElement& parent ) override; + void loadSettings( const QDomElement& _this ) override; + inline QString nodeName() const override { return "Delay"; } - virtual int controlCount(){ + int controlCount() override{ return 5; } - virtual EffectControlDialog* createView() + gui::EffectControlDialog* createView() override { - return new DelayControlsDialog( this ); + return new gui::DelayControlsDialog( this ); } float m_outPeakL; @@ -69,8 +70,11 @@ private: TempoSyncKnobModel m_lfoAmountModel; FloatModel m_outGainModel; - friend class DelayControlsDialog; + friend class gui::DelayControlsDialog; friend class DelayEffect; }; + +} // namespace lmms + #endif // DELAYCONTROLS_H diff --git a/plugins/Delay/DelayControlsDialog.cpp b/plugins/Delay/DelayControlsDialog.cpp old mode 100755 new mode 100644 index db59b3f39..9a9dea0d4 --- a/plugins/Delay/DelayControlsDialog.cpp +++ b/plugins/Delay/DelayControlsDialog.cpp @@ -31,7 +31,8 @@ #include #include - +namespace lmms::gui +{ DelayControlsDialog::DelayControlsDialog( DelayControls *controls ) : @@ -43,42 +44,42 @@ DelayControlsDialog::DelayControlsDialog( DelayControls *controls ) : setPalette( pal ); setFixedSize( 300, 208 ); - TempoSyncKnob* sampleDelayKnob = new TempoSyncKnob( knobBright_26, this ); + auto sampleDelayKnob = new TempoSyncKnob(knobBright_26, this); sampleDelayKnob->move( 10,14 ); sampleDelayKnob->setVolumeKnob( false ); sampleDelayKnob->setModel( &controls->m_delayTimeModel ); sampleDelayKnob->setLabel( tr( "DELAY" ) ); sampleDelayKnob->setHintText( tr( "Delay time" ) + " ", " s" ); - Knob * feedbackKnob = new Knob( knobBright_26, this ); + auto feedbackKnob = new Knob(knobBright_26, this); feedbackKnob->move( 11, 58 ); feedbackKnob->setVolumeKnob( true) ; feedbackKnob->setModel( &controls->m_feedbackModel); feedbackKnob->setLabel( tr( "FDBK" ) ); feedbackKnob->setHintText( tr ( "Feedback amount" ) + " " , "" ); - TempoSyncKnob * lfoFreqKnob = new TempoSyncKnob( knobBright_26, this ); + auto lfoFreqKnob = new TempoSyncKnob(knobBright_26, this); lfoFreqKnob->move( 11, 119 ); lfoFreqKnob->setVolumeKnob( false ); lfoFreqKnob->setModel( &controls->m_lfoTimeModel ); lfoFreqKnob->setLabel( tr( "RATE" ) ); lfoFreqKnob->setHintText( tr ( "LFO frequency") + " ", " s" ); - TempoSyncKnob * lfoAmtKnob = new TempoSyncKnob( knobBright_26, this ); + auto lfoAmtKnob = new TempoSyncKnob(knobBright_26, this); lfoAmtKnob->move( 11, 159 ); lfoAmtKnob->setVolumeKnob( false ); lfoAmtKnob->setModel( &controls->m_lfoAmountModel ); lfoAmtKnob->setLabel( tr( "AMNT" ) ); lfoAmtKnob->setHintText( tr ( "LFO amount" ) + " " , " s" ); - EqFader * outFader = new EqFader( &controls->m_outGainModel,tr( "Out gain" ), - this, &controls->m_outPeakL, &controls->m_outPeakR ); + auto outFader + = new EqFader(&controls->m_outGainModel, tr("Out gain"), this, &controls->m_outPeakL, &controls->m_outPeakR); outFader->setMaximumHeight( 196 ); outFader->move( 263, 45 ); outFader->setDisplayConversion( false ); outFader->setHintText( tr( "Gain" ), "dBFS" ); - XyPad * pad = new XyPad( this, &controls->m_feedbackModel, &controls->m_delayTimeModel ); + auto pad = new XyPad(this, &controls->m_feedbackModel, &controls->m_delayTimeModel); pad->resize( 200, 200 ); pad->move( 50, 5 ); } @@ -152,3 +153,6 @@ void XyPad::mouseMoveEvent(QMouseEvent *event) m_yModel->setValue( m_yModel->minValue() + ( event->y() * yInc ) ); } } + + +} // namespace lmms::gui \ No newline at end of file diff --git a/plugins/Delay/DelayControlsDialog.h b/plugins/Delay/DelayControlsDialog.h index 4b2c0af41..c7ab58f45 100644 --- a/plugins/Delay/DelayControlsDialog.h +++ b/plugins/Delay/DelayControlsDialog.h @@ -27,17 +27,22 @@ #include "EffectControlDialog.h" +namespace lmms +{ + + class DelayControls; class FloatModel; +namespace gui +{ + class DelayControlsDialog : public EffectControlDialog { Q_OBJECT public: DelayControlsDialog( DelayControls* controls ); - virtual ~DelayControlsDialog() - { - } + ~DelayControlsDialog() override = default; }; class XyPad : public QWidget @@ -45,13 +50,13 @@ class XyPad : public QWidget Q_OBJECT public: XyPad( QWidget *parent = 0, FloatModel *xModel = 0, FloatModel *yModel = 0 ); - ~XyPad() {} + ~XyPad() override = default; protected: - virtual void paintEvent ( QPaintEvent * event ); - virtual void mousePressEvent(QMouseEvent * event ); - virtual void mouseReleaseEvent(QMouseEvent * event); - virtual void mouseMoveEvent(QMouseEvent * event); + void paintEvent ( QPaintEvent * event ) override; + void mousePressEvent(QMouseEvent * event ) override; + void mouseReleaseEvent(QMouseEvent * event) override; + void mouseMoveEvent(QMouseEvent * event) override; private: FloatModel *m_xModel; @@ -59,4 +64,9 @@ private: bool m_acceptInput; }; + +} // namespace gui + +} // namespace lmms + #endif // DELAYCONTROLSDIALOG_H diff --git a/plugins/Delay/DelayEffect.cpp b/plugins/Delay/DelayEffect.cpp index 1377498b0..6db2f38e3 100644 --- a/plugins/Delay/DelayEffect.cpp +++ b/plugins/Delay/DelayEffect.cpp @@ -30,12 +30,16 @@ #include "plugin_export.h" #include "StereoDelay.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT delay_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "Delay", QT_TRANSLATE_NOOP( "PluginBrowser", "A native delay plugin" ), "Dave French ", @@ -87,7 +91,7 @@ bool DelayEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) const float sr = Engine::audioEngine()->processingSampleRate(); const float d = dryLevel(); const float w = wetLevel(); - sample_t dryS[2]; + auto dryS = std::array{}; float lPeak = 0.0; float rPeak = 0.0; float length = m_delayControls.m_delayTimeModel.value(); @@ -166,3 +170,5 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* parent, void* data ) }} + +} // namespace lmms \ No newline at end of file diff --git a/plugins/Delay/DelayEffect.h b/plugins/Delay/DelayEffect.h index c409458ed..b6c090ff0 100644 --- a/plugins/Delay/DelayEffect.h +++ b/plugins/Delay/DelayEffect.h @@ -28,6 +28,9 @@ #include "Effect.h" #include "DelayControls.h" +namespace lmms +{ + class Lfo; class StereoDelay; @@ -35,9 +38,9 @@ class DelayEffect : public Effect { public: DelayEffect(Model* parent , const Descriptor::SubPluginFeatures::Key* key ); - virtual ~DelayEffect(); - virtual bool processAudioBuffer( sampleFrame* buf, const fpp_t frames ); - virtual EffectControls* controls() + ~DelayEffect() override; + bool processAudioBuffer( sampleFrame* buf, const fpp_t frames ) override; + EffectControls* controls() override { return &m_delayControls; } @@ -51,4 +54,7 @@ private: float m_currentLength; }; + +} // namespace lmms + #endif // DELAYEFFECT_H diff --git a/plugins/Delay/Lfo.cpp b/plugins/Delay/Lfo.cpp index 0360263ef..5a449243a 100644 --- a/plugins/Delay/Lfo.cpp +++ b/plugins/Delay/Lfo.cpp @@ -26,7 +26,8 @@ #include - +namespace lmms +{ Lfo::Lfo( int samplerate ) @@ -45,3 +46,6 @@ float Lfo::tick() return output; } + + +} // namespace lmms diff --git a/plugins/Delay/Lfo.h b/plugins/Delay/Lfo.h index 10b7e2fc0..ea8435d13 100644 --- a/plugins/Delay/Lfo.h +++ b/plugins/Delay/Lfo.h @@ -28,13 +28,15 @@ #include "lmms_constants.h" +namespace lmms +{ + + class Lfo { public: Lfo( int samplerate ); - ~Lfo() - { - } + ~Lfo() = default; @@ -77,4 +79,7 @@ private: int m_samplerate; }; + +} // namespace lmms + #endif // LFO_H diff --git a/plugins/Delay/StereoDelay.cpp b/plugins/Delay/StereoDelay.cpp index bdbd63404..e4b8b5641 100644 --- a/plugins/Delay/StereoDelay.cpp +++ b/plugins/Delay/StereoDelay.cpp @@ -25,6 +25,9 @@ #include "StereoDelay.h" #include "lmms_basics.h" +namespace lmms +{ + StereoDelay::StereoDelay( int maxTime, int sampleRate ) { @@ -87,7 +90,4 @@ void StereoDelay::setSampleRate( int sampleRate ) } - - - - +} // namespace lmms diff --git a/plugins/Delay/StereoDelay.h b/plugins/Delay/StereoDelay.h index afea59b9a..0ea0efeed 100644 --- a/plugins/Delay/StereoDelay.h +++ b/plugins/Delay/StereoDelay.h @@ -27,6 +27,10 @@ #include "lmms_basics.h" + +namespace lmms +{ + class StereoDelay { public: @@ -57,4 +61,7 @@ private: float m_maxTime; }; + +} // namespace lmms + #endif // STEREODELAY_H diff --git a/plugins/DualFilter/DualFilter.cpp b/plugins/DualFilter/DualFilter.cpp index 19bed5436..e510109e9 100644 --- a/plugins/DualFilter/DualFilter.cpp +++ b/plugins/DualFilter/DualFilter.cpp @@ -29,12 +29,16 @@ #include "BasicFilters.h" #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT dualfilter_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "Dual Filter", QT_TRANSLATE_NOOP( "PluginBrowser", "A Dual filter plugin" ), "Vesa Kivimäki ", @@ -130,8 +134,8 @@ bool DualFilterEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames const bool enabled1 = m_dfControls.m_enabled1Model.value(); const bool enabled2 = m_dfControls.m_enabled2Model.value(); - - + + // buffer processing loop for( fpp_t f = 0; f < frames; ++f ) @@ -141,9 +145,9 @@ bool DualFilterEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames const float mix1 = 1.0f - mix2; const float gain1 = *gain1Ptr * 0.01f; const float gain2 = *gain2Ptr * 0.01f; - sample_t s[2] = { 0.0f, 0.0f }; // mix - sample_t s1[2] = { buf[f][0], buf[f][1] }; // filter 1 - sample_t s2[2] = { buf[f][0], buf[f][1] }; // filter 2 + auto s = std::array{0.0f, 0.0f}; // mix + auto s1 = std::array{buf[f][0], buf[f][1]}; // filter 1 + auto s2 = std::array{buf[f][0], buf[f][1]}; // filter 2 // update filter 1 if( enabled1 ) @@ -229,3 +233,5 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* parent, void* data ) } + +} // namespace lmms diff --git a/plugins/DualFilter/DualFilter.h b/plugins/DualFilter/DualFilter.h index a8eb82075..c179edbcc 100644 --- a/plugins/DualFilter/DualFilter.h +++ b/plugins/DualFilter/DualFilter.h @@ -31,14 +31,18 @@ #include "DualFilterControls.h" #include "BasicFilters.h" +namespace lmms +{ + + class DualFilterEffect : public Effect { public: DualFilterEffect( Model* parent, const Descriptor::SubPluginFeatures::Key* key ); - virtual ~DualFilterEffect(); - virtual bool processAudioBuffer( sampleFrame* buf, const fpp_t frames ); + ~DualFilterEffect() override; + bool processAudioBuffer( sampleFrame* buf, const fpp_t frames ) override; - virtual EffectControls* controls() + EffectControls* controls() override { return &m_dfControls; } @@ -62,4 +66,7 @@ private: } ; + +} // namespace lmms + #endif diff --git a/plugins/DualFilter/DualFilterControlDialog.cpp b/plugins/DualFilter/DualFilterControlDialog.cpp old mode 100755 new mode 100644 index c6c56befd..81a835901 --- a/plugins/DualFilter/DualFilterControlDialog.cpp +++ b/plugins/DualFilter/DualFilterControlDialog.cpp @@ -31,12 +31,16 @@ #include "ComboBox.h" #include "gui_templates.h" +namespace lmms::gui +{ + + #define makeknob( name, x, y, model, label, hint, unit ) \ Knob * name = new Knob( knobBright_26, this); \ - name -> move( x, y ); \ - name ->setModel( &controls-> model ); \ - name ->setLabel( label ); \ - name ->setHintText( hint, unit ); + (name) -> move( x, y ); \ + (name) ->setModel( &controls-> model ); \ + (name) ->setLabel( label ); \ + (name) ->setHintText( hint, unit ); @@ -60,10 +64,8 @@ DualFilterControlDialog::DualFilterControlDialog( DualFilterControls* controls ) gain1Knob-> setVolumeKnob( true ); gain2Knob-> setVolumeKnob( true ); - LedCheckBox * enabled1Toggle = new LedCheckBox( "", this, - tr( "Filter 1 enabled" ), LedCheckBox::Green ); - LedCheckBox * enabled2Toggle = new LedCheckBox( "", this, - tr( "Filter 2 enabled" ), LedCheckBox::Green ); + auto enabled1Toggle = new LedCheckBox("", this, tr("Filter 1 enabled"), LedCheckBox::Green); + auto enabled2Toggle = new LedCheckBox("", this, tr("Filter 2 enabled"), LedCheckBox::Green); enabled1Toggle -> move( 12, 11 ); enabled1Toggle -> setModel( &controls -> m_enabled1Model ); @@ -72,14 +74,16 @@ DualFilterControlDialog::DualFilterControlDialog( DualFilterControls* controls ) enabled2Toggle -> setModel( &controls -> m_enabled2Model ); enabled2Toggle->setToolTip(tr("Enable/disable filter 2")); - ComboBox * m_filter1ComboBox = new ComboBox( this ); + auto m_filter1ComboBox = new ComboBox(this); m_filter1ComboBox->setGeometry( 19, 70, 137, ComboBox::DEFAULT_HEIGHT ); m_filter1ComboBox->setFont( pointSize<8>( m_filter1ComboBox->font() ) ); m_filter1ComboBox->setModel( &controls->m_filter1Model ); - ComboBox * m_filter2ComboBox = new ComboBox( this ); + auto m_filter2ComboBox = new ComboBox(this); m_filter2ComboBox->setGeometry( 217, 70, 137, ComboBox::DEFAULT_HEIGHT ); m_filter2ComboBox->setFont( pointSize<8>( m_filter2ComboBox->font() ) ); m_filter2ComboBox->setModel( &controls->m_filter2Model ); } + +} // namespace lmms::gui diff --git a/plugins/DualFilter/DualFilterControlDialog.h b/plugins/DualFilter/DualFilterControlDialog.h index f839864d8..629eb2d9a 100644 --- a/plugins/DualFilter/DualFilterControlDialog.h +++ b/plugins/DualFilter/DualFilterControlDialog.h @@ -28,19 +28,28 @@ #include "EffectControlDialog.h" +namespace lmms +{ + class DualFilterControls; +namespace gui +{ + class DualFilterControlDialog : public EffectControlDialog { Q_OBJECT public: DualFilterControlDialog( DualFilterControls* controls ); - virtual ~DualFilterControlDialog() - { - } + ~DualFilterControlDialog() override = default; } ; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/DualFilter/DualFilterControls.cpp b/plugins/DualFilter/DualFilterControls.cpp index 7d54c7c78..e862e6ae1 100644 --- a/plugins/DualFilter/DualFilterControls.cpp +++ b/plugins/DualFilter/DualFilterControls.cpp @@ -32,6 +32,10 @@ #include "embed.h" #include "Engine.h" +namespace lmms +{ + + DualFilterControls::DualFilterControls( DualFilterEffect* effect ) : EffectControls( effect ), m_effect( effect ), @@ -156,6 +160,4 @@ void DualFilterControls::saveSettings( QDomDocument& _doc, QDomElement& _this ) } - - - +} // namespace lmms diff --git a/plugins/DualFilter/DualFilterControls.h b/plugins/DualFilter/DualFilterControls.h index 9713f657a..379f96e32 100644 --- a/plugins/DualFilter/DualFilterControls.h +++ b/plugins/DualFilter/DualFilterControls.h @@ -30,6 +30,10 @@ #include "DualFilterControlDialog.h" #include "ComboBoxModel.h" +namespace lmms +{ + + class DualFilterEffect; @@ -38,25 +42,23 @@ class DualFilterControls : public EffectControls Q_OBJECT public: DualFilterControls( DualFilterEffect* effect ); - virtual ~DualFilterControls() - { - } + ~DualFilterControls() override = default; - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); - inline virtual QString nodeName() const + void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; + inline QString nodeName() const override { return "DualFilterControls"; } - virtual int controlCount() + int controlCount() override { return 11; } - virtual EffectControlDialog* createView() + gui::EffectControlDialog* createView() override { - return new DualFilterControlDialog( this ); + return new gui::DualFilterControlDialog( this ); } @@ -80,9 +82,12 @@ private: FloatModel m_res2Model; FloatModel m_gain2Model; - friend class DualFilterControlDialog; + friend class gui::DualFilterControlDialog; friend class DualFilterEffect; } ; + +} // namespace lmms + #endif diff --git a/plugins/DynamicsProcessor/DynamicsProcessor.cpp b/plugins/DynamicsProcessor/DynamicsProcessor.cpp index 5ead265b2..54f1f0c50 100644 --- a/plugins/DynamicsProcessor/DynamicsProcessor.cpp +++ b/plugins/DynamicsProcessor/DynamicsProcessor.cpp @@ -32,12 +32,16 @@ #include "embed.h" #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT dynamicsprocessor_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "Dynamics Processor", QT_TRANSLATE_NOOP( "PluginBrowser", "plugin for processing dynamics in a flexible way" ), @@ -101,17 +105,17 @@ bool DynProcEffect::processAudioBuffer( sampleFrame * _buf, // variables for effect int i = 0; - float sm_peak[2] = { 0.0f, 0.0f }; + auto sm_peak = std::array{0.0f, 0.0f}; float gain; double out_sum = 0.0; const float d = dryLevel(); const float w = wetLevel(); - + const int stereoMode = m_dpControls.m_stereomodeModel.value(); const float inputGain = m_dpControls.m_inputModel.value(); const float outputGain = m_dpControls.m_outputModel.value(); - + const float * samples = m_dpControls.m_wavegraphModel.samples(); // debug code @@ -139,7 +143,7 @@ bool DynProcEffect::processAudioBuffer( sampleFrame * _buf, for( fpp_t f = 0; f < _frames; ++f ) { - double s[2] = { _buf[f][0], _buf[f][1] }; + auto s = std::array{_buf[f][0], _buf[f][1]}; // apply input gain s[0] *= inputGain; @@ -207,7 +211,7 @@ bool DynProcEffect::processAudioBuffer( sampleFrame * _buf, gain = samples[199]; }; - s[i] *= gain; + s[i] *= gain; s[i] /= sm_peak[i]; } } @@ -244,3 +248,5 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model * _parent, void * _data ) } + +} // namespace lmms diff --git a/plugins/DynamicsProcessor/DynamicsProcessor.h b/plugins/DynamicsProcessor/DynamicsProcessor.h index 34e10287c..576accdcc 100644 --- a/plugins/DynamicsProcessor/DynamicsProcessor.h +++ b/plugins/DynamicsProcessor/DynamicsProcessor.h @@ -30,6 +30,9 @@ #include "Effect.h" #include "DynamicsProcessorControls.h" +namespace lmms +{ + class RmsHelper; @@ -38,11 +41,11 @@ class DynProcEffect : public Effect public: DynProcEffect( Model * _parent, const Descriptor::SubPluginFeatures::Key * _key ); - virtual ~DynProcEffect(); - virtual bool processAudioBuffer( sampleFrame * _buf, - const fpp_t _frames ); + ~DynProcEffect() override; + bool processAudioBuffer( sampleFrame * _buf, + const fpp_t _frames ) override; - virtual EffectControls * controls() + EffectControls * controls() override { return( &m_dpControls ); } @@ -68,7 +71,6 @@ private: } ; - - +} // namespace lmms #endif diff --git a/plugins/DynamicsProcessor/DynamicsProcessorControlDialog.cpp b/plugins/DynamicsProcessor/DynamicsProcessorControlDialog.cpp index e8ac87ab5..4d8758e03 100644 --- a/plugins/DynamicsProcessor/DynamicsProcessorControlDialog.cpp +++ b/plugins/DynamicsProcessor/DynamicsProcessorControlDialog.cpp @@ -32,6 +32,9 @@ #include "Knob.h" #include "PixmapButton.h" +namespace lmms::gui +{ + DynProcControlDialog::DynProcControlDialog( DynProcControls * _controls ) : @@ -44,7 +47,7 @@ DynProcControlDialog::DynProcControlDialog( setPalette( pal ); setFixedSize( 224, 319 ); - Graph * waveGraph = new Graph( this, Graph::LinearNonCyclicStyle, 204, 205 ); + auto waveGraph = new Graph(this, Graph::LinearNonCyclicStyle, 204, 205); waveGraph -> move( 10, 6 ); waveGraph -> setModel( &_controls -> m_wavegraphModel ); waveGraph -> setAutoFillBackground( true ); @@ -55,7 +58,7 @@ DynProcControlDialog::DynProcControlDialog( waveGraph->setGraphColor( QColor( 85, 204, 145 ) ); waveGraph -> setMaximumSize( 204, 205 ); - Knob * inputKnob = new Knob( knobBright_26, this); + auto inputKnob = new Knob(knobBright_26, this); inputKnob -> setVolumeKnob( true ); inputKnob -> setVolumeRatio( 1.0 ); inputKnob -> move( 26, 223 ); @@ -63,21 +66,21 @@ DynProcControlDialog::DynProcControlDialog( inputKnob->setLabel( tr( "INPUT" ) ); inputKnob->setHintText( tr( "Input gain:" ) , "" ); - Knob * outputKnob = new Knob( knobBright_26, this ); + auto outputKnob = new Knob(knobBright_26, this); outputKnob -> setVolumeKnob( true ); outputKnob -> setVolumeRatio( 1.0 ); outputKnob -> move( 76, 223 ); outputKnob->setModel( &_controls->m_outputModel ); outputKnob->setLabel( tr( "OUTPUT" ) ); outputKnob->setHintText( tr( "Output gain:" ) , "" ); - - Knob * attackKnob = new Knob( knobBright_26, this); + + auto attackKnob = new Knob(knobBright_26, this); attackKnob -> move( 24, 268 ); attackKnob->setModel( &_controls->m_attackModel ); attackKnob->setLabel( tr( "ATTACK" ) ); attackKnob->setHintText( tr( "Peak attack time:" ) , "ms" ); - Knob * releaseKnob = new Knob( knobBright_26, this ); + auto releaseKnob = new Knob(knobBright_26, this); releaseKnob -> move( 74, 268 ); releaseKnob->setModel( &_controls->m_releaseModel ); releaseKnob->setLabel( tr( "RELEASE" ) ); @@ -85,28 +88,28 @@ DynProcControlDialog::DynProcControlDialog( //wavegraph control buttons - PixmapButton * resetButton = new PixmapButton( this, tr("Reset wavegraph") ); + auto resetButton = new PixmapButton(this, tr("Reset wavegraph")); resetButton -> move( 162, 223 ); resetButton -> resize( 13, 48 ); resetButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "reset_active" ) ); resetButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "reset_inactive" ) ); resetButton->setToolTip(tr("Reset wavegraph")); - PixmapButton * smoothButton = new PixmapButton( this, tr("Smooth wavegraph") ); + auto smoothButton = new PixmapButton(this, tr("Smooth wavegraph")); smoothButton -> move( 162, 239 ); smoothButton -> resize( 13, 48 ); smoothButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "smooth_active" ) ); smoothButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "smooth_inactive" ) ); smoothButton->setToolTip(tr("Smooth wavegraph")); - PixmapButton * addOneButton = new PixmapButton( this, tr("Increase wavegraph amplitude by 1 dB") ); + auto addOneButton = new PixmapButton(this, tr("Increase wavegraph amplitude by 1 dB")); addOneButton -> move( 131, 223 ); addOneButton -> resize( 13, 29 ); addOneButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "add1_active" ) ); addOneButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "add1_inactive" ) ); addOneButton->setToolTip(tr("Increase wavegraph amplitude by 1 dB")); - PixmapButton * subOneButton = new PixmapButton( this, tr("Decrease wavegraph amplitude by 1 dB") ); + auto subOneButton = new PixmapButton(this, tr("Decrease wavegraph amplitude by 1 dB")); subOneButton -> move( 131, 239 ); subOneButton -> resize( 13, 29 ); subOneButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "sub1_active" ) ); @@ -114,28 +117,28 @@ DynProcControlDialog::DynProcControlDialog( subOneButton->setToolTip(tr("Decrease wavegraph amplitude by 1 dB")); //stereomode switches - PixmapButton * smMaxButton = new PixmapButton( this, tr( "Stereo mode: maximum" ) ); + auto smMaxButton = new PixmapButton(this, tr("Stereo mode: maximum")); smMaxButton -> move( 131, 257 ); smMaxButton -> resize( 78, 17 ); smMaxButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "max_active" ) ); smMaxButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "max_inactive" ) ); smMaxButton->setToolTip(tr("Process based on the maximum of both stereo channels")); - - PixmapButton * smAvgButton = new PixmapButton( this, tr( "Stereo mode: average" ) ); + + auto smAvgButton = new PixmapButton(this, tr("Stereo mode: average")); smAvgButton -> move( 131, 274 ); smAvgButton -> resize( 78, 16 ); smAvgButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "avg_active" ) ); smAvgButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "avg_inactive" ) ); smAvgButton->setToolTip(tr("Process based on the average of both stereo channels")); - PixmapButton * smUnlButton = new PixmapButton( this, tr( "Stereo mode: unlinked" ) ); + auto smUnlButton = new PixmapButton(this, tr("Stereo mode: unlinked")); smUnlButton -> move( 131, 290 ); smUnlButton -> resize( 78, 17 ); smUnlButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "unl_active" ) ); smUnlButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "unl_inactive" ) ); smUnlButton->setToolTip(tr("Process each stereo channel independently")); - - automatableButtonGroup * smGroup = new automatableButtonGroup( this ); + + auto smGroup = new automatableButtonGroup(this); smGroup -> addButton( smMaxButton ); smGroup -> addButton( smAvgButton ); smGroup -> addButton( smUnlButton ); @@ -151,3 +154,5 @@ DynProcControlDialog::DynProcControlDialog( _controls, SLOT( subOneClicked() ) ); } + +} // namespace lmms::gui diff --git a/plugins/DynamicsProcessor/DynamicsProcessorControlDialog.h b/plugins/DynamicsProcessor/DynamicsProcessorControlDialog.h index 29f8288c8..37608d4a3 100644 --- a/plugins/DynamicsProcessor/DynamicsProcessorControlDialog.h +++ b/plugins/DynamicsProcessor/DynamicsProcessorControlDialog.h @@ -28,22 +28,31 @@ #include "EffectControlDialog.h" +namespace lmms +{ + class DynProcControls; +namespace gui +{ + class DynProcControlDialog : public EffectControlDialog { Q_OBJECT public: DynProcControlDialog( DynProcControls * _controls ); - virtual ~DynProcControlDialog() - { - } + ~DynProcControlDialog() override = default; private: } ; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/DynamicsProcessor/DynamicsProcessorControls.cpp b/plugins/DynamicsProcessor/DynamicsProcessorControls.cpp index 263a2a793..541031a3f 100644 --- a/plugins/DynamicsProcessor/DynamicsProcessorControls.cpp +++ b/plugins/DynamicsProcessor/DynamicsProcessorControls.cpp @@ -33,6 +33,9 @@ #include "Engine.h" #include "Song.h" +namespace lmms +{ + #define onedB 1.1220184543019633f @@ -113,7 +116,7 @@ void DynProcControls::saveSettings( QDomDocument & _doc, void DynProcControls::setDefaultShape() { - float shp [200] = { }; + auto shp = std::array{}; for ( int i = 0; i<200; i++) { shp[i] = ((float)i + 1.0f) / 200.0f; @@ -154,5 +157,4 @@ void DynProcControls::subOneClicked() } - - +} // namespace lmms diff --git a/plugins/DynamicsProcessor/DynamicsProcessorControls.h b/plugins/DynamicsProcessor/DynamicsProcessorControls.h index a292b3f9a..cbe109eaf 100644 --- a/plugins/DynamicsProcessor/DynamicsProcessorControls.h +++ b/plugins/DynamicsProcessor/DynamicsProcessorControls.h @@ -30,6 +30,10 @@ #include "DynamicsProcessorControlDialog.h" #include "Graph.h" +namespace lmms +{ + + class DynProcEffect; @@ -45,27 +49,25 @@ public: NumStereoModes }; DynProcControls( DynProcEffect * _eff ); - virtual ~DynProcControls() - { - } + ~DynProcControls() override = default; - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); - inline virtual QString nodeName() const + void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; + inline QString nodeName() const override { return( "dynamicsprocessor_controls" ); } virtual void setDefaultShape(); - virtual int controlCount() + int controlCount() override { return( 6 ); } - virtual EffectControlDialog * createView() + gui::EffectControlDialog * createView() override { - return( new DynProcControlDialog( this ) ); + return( new gui::DynProcControlDialog( this ) ); } @@ -89,9 +91,12 @@ private: graphModel m_wavegraphModel; IntModel m_stereomodeModel; - friend class DynProcControlDialog; + friend class gui::DynProcControlDialog; friend class DynProcEffect; } ; + +} // namespace lmms + #endif diff --git a/plugins/Eq/EqControls.cpp b/plugins/Eq/EqControls.cpp index f33a64675..ad1ffa2ac 100644 --- a/plugins/Eq/EqControls.cpp +++ b/plugins/Eq/EqControls.cpp @@ -30,6 +30,9 @@ #include "EqEffect.h" +namespace lmms +{ + EqControls::EqControls( EqEffect *effect ) : EffectControls( effect ), @@ -149,9 +152,9 @@ void EqControls::loadSettings( const QDomElement &_this ) m_analyseOutModel.loadSettings( _this, "AnalyseOut" ); } -EffectControlDialog*EqControls::createView() +gui::EffectControlDialog* EqControls::createView() { - return new EqControlsDialog( this ); + return new gui::EqControlsDialog( this ); } @@ -202,3 +205,6 @@ void EqControls::saveSettings( QDomDocument &doc, QDomElement &parent ) m_analyseInModel.saveSettings( doc, parent, "AnalyseIn" ); m_analyseOutModel.saveSettings( doc, parent, "AnalyseOut" ); } + + +} // namespace lmms diff --git a/plugins/Eq/EqControls.h b/plugins/Eq/EqControls.h index b314454ea..6db82f3e3 100644 --- a/plugins/Eq/EqControls.h +++ b/plugins/Eq/EqControls.h @@ -28,33 +28,39 @@ #include "EffectControls.h" #include "EqSpectrumView.h" +namespace lmms +{ + class EqEffect; +namespace gui +{ +class EqControlsDialog; +} + class EqControls : public EffectControls { Q_OBJECT public: explicit EqControls( EqEffect* effect ); - virtual ~EqControls() - { - } + ~EqControls() override = default; - virtual void saveSettings ( QDomDocument& doc, QDomElement& parent ); + void saveSettings ( QDomDocument& doc, QDomElement& parent ) override; - virtual void loadSettings ( const QDomElement &_this ); + void loadSettings ( const QDomElement &_this ) override; - inline virtual QString nodeName() const + inline QString nodeName() const override { return "Eq"; } - virtual int controlCount() + int controlCount() override { return 42; } - virtual EffectControlDialog* createView(); + gui::EffectControlDialog* createView() override; float m_inPeakL; float m_inPeakR; @@ -126,7 +132,11 @@ private: BoolModel m_analyseInModel; BoolModel m_analyseOutModel; - friend class EqControlsDialog; + friend class gui::EqControlsDialog; friend class EqEffect; }; + + +} // namespace lmms + #endif // EQCONTROLS_H diff --git a/plugins/Eq/EqControlsDialog.cpp b/plugins/Eq/EqControlsDialog.cpp index 57fdee6f3..6535b61f3 100644 --- a/plugins/Eq/EqControlsDialog.cpp +++ b/plugins/Eq/EqControlsDialog.cpp @@ -38,6 +38,9 @@ #include "EqParameterWidget.h" #include "EqSpectrumView.h" +namespace lmms::gui +{ + EqControlsDialog::EqControlsDialog( EqControls *controls ) : EffectControlDialog( controls ), @@ -49,11 +52,11 @@ EqControlsDialog::EqControlsDialog( EqControls *controls ) : setPalette( pal ); setFixedSize( 500, 500 ); - EqSpectrumView * inSpec = new EqSpectrumView( &controls->m_inFftBands, this ); + auto inSpec = new EqSpectrumView(&controls->m_inFftBands, this); inSpec->move( 26, 17 ); inSpec->setColor( QColor( 77, 101, 242, 150 ) ); - EqSpectrumView * outSpec = new EqSpectrumView( &controls->m_outFftBands, this ); + auto outSpec = new EqSpectrumView(&controls->m_outFftBands, this); outSpec->setColor( QColor( 0, 255, 239, 150 ) ); outSpec->move( 26, 17 ); @@ -69,16 +72,18 @@ EqControlsDialog::EqControlsDialog( EqControls *controls ) : setBand( 6, &controls->m_highShelfActiveModel, &controls->m_highShelfFreqModel, &controls->m_highShelfResModel, &controls->m_highShelfGainModel, QColor(255 ,255, 255), tr( "High-shelf" ), &controls->m_highShelfPeakL, &controls->m_highShelfPeakR,0,0,0,0,0,0 ); setBand( 7, &controls->m_lpActiveModel, &controls->m_lpFreqModel, &controls->m_lpResModel, 0, QColor(255 ,255, 255), tr( "LP" ) ,0,0,0,0,0, &controls->m_lp12Model, &controls->m_lp24Model, &controls->m_lp48Model); - QPixmap * faderBg = new QPixmap( PLUGIN_NAME::getIconPixmap( "faderback" ) ); - QPixmap * faderLeds = new QPixmap( PLUGIN_NAME::getIconPixmap( "faderleds" ) ); - QPixmap * faderKnob = new QPixmap( PLUGIN_NAME::getIconPixmap( "faderknob" ) ); + auto faderBg = new QPixmap(PLUGIN_NAME::getIconPixmap("faderback")); + auto faderLeds = new QPixmap(PLUGIN_NAME::getIconPixmap("faderleds")); + auto faderKnob = new QPixmap(PLUGIN_NAME::getIconPixmap("faderknob")); - EqFader * GainFaderIn = new EqFader( &controls->m_inGainModel, tr( "Input gain" ), this, faderBg, faderLeds, faderKnob, &controls->m_inPeakL, &controls->m_inPeakR ); + auto GainFaderIn = new EqFader(&controls->m_inGainModel, tr("Input gain"), this, faderBg, faderLeds, faderKnob, + &controls->m_inPeakL, &controls->m_inPeakR); GainFaderIn->move( 23, 295 ); GainFaderIn->setDisplayConversion( false ); GainFaderIn->setHintText( tr( "Gain" ), "dBv"); - EqFader * GainFaderOut = new EqFader( &controls->m_outGainModel, tr( "Output gain" ), this, faderBg, faderLeds, faderKnob, &controls->m_outPeakL, &controls->m_outPeakR ); + auto GainFaderOut = new EqFader(&controls->m_outGainModel, tr("Output gain"), this, faderBg, faderLeds, faderKnob, + &controls->m_outPeakL, &controls->m_outPeakR); GainFaderOut->move( 453, 295); GainFaderOut->setDisplayConversion( false ); GainFaderOut->setHintText( tr( "Gain" ), "dBv" ); @@ -87,7 +92,8 @@ EqControlsDialog::EqControlsDialog( EqControls *controls ) : int distance = 126; for( int i = 1; i < m_parameterWidget->bandCount() - 1; i++ ) { - EqFader * gainFader = new EqFader( m_parameterWidget->getBandModels( i )->gain, tr( "" ), this, faderBg, faderLeds, faderKnob, m_parameterWidget->getBandModels( i )->peakL, m_parameterWidget->getBandModels( i )->peakR ); + auto gainFader = new EqFader(m_parameterWidget->getBandModels(i)->gain, tr(""), this, faderBg, faderLeds, + faderKnob, m_parameterWidget->getBandModels(i)->peakL, m_parameterWidget->getBandModels(i)->peakR); gainFader->move( distance, 295 ); distance += 44; gainFader->setMinimumHeight(80); @@ -100,21 +106,21 @@ EqControlsDialog::EqControlsDialog( EqControls *controls ) : distance = 81; for( int i = 0; i < m_parameterWidget->bandCount() ; i++ ) { - Knob * resKnob = new Knob( knobBright_26, this ); + auto resKnob = new Knob(knobBright_26, this); resKnob->move( distance, 440 ); resKnob->setVolumeKnob(false); resKnob->setModel( m_parameterWidget->getBandModels( i )->res ); if(i > 1 && i < 6) { resKnob->setHintText( tr( "Bandwidth: " ) , tr( " Octave" ) ); } else { resKnob->setHintText( tr( "Resonance : " ) , "" ); } - Knob * freqKnob = new Knob( knobBright_26, this ); + auto freqKnob = new Knob(knobBright_26, this); freqKnob->move( distance, 396 ); freqKnob->setVolumeKnob( false ); freqKnob->setModel( m_parameterWidget->getBandModels( i )->freq ); freqKnob->setHintText( tr( "Frequency:" ), "Hz" ); // adds the Number Active buttons - PixmapButton * activeButton = new PixmapButton( this, nullptr ); + auto activeButton = new PixmapButton(this, nullptr); activeButton->setCheckable(true); activeButton->setModel( m_parameterWidget->getBandModels( i )->active ); @@ -137,48 +143,48 @@ EqControlsDialog::EqControlsDialog( EqControls *controls ) : // adds the buttons for Spectrum analyser on/off - LedCheckBox * inSpecButton = new LedCheckBox( this ); + auto inSpecButton = new LedCheckBox(this); inSpecButton->setCheckable(true); inSpecButton->setModel( &controls->m_analyseInModel ); inSpecButton->move( 172, 240 ); - LedCheckBox * outSpecButton = new LedCheckBox( this ); + auto outSpecButton = new LedCheckBox(this); outSpecButton->setCheckable(true); outSpecButton->setModel( &controls->m_analyseOutModel ); outSpecButton->move( 302, 240 ); //hp filter type - PixmapButton * hp12Button = new PixmapButton( this , nullptr ); + auto hp12Button = new PixmapButton(this, nullptr); hp12Button->setModel( m_parameterWidget->getBandModels( 0 )->hp12 ); hp12Button->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "12dB" ) ); hp12Button->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "12dBoff" ) ); hp12Button->move( 79, 298 ); - PixmapButton * hp24Button = new PixmapButton( this , nullptr ); + auto hp24Button = new PixmapButton(this, nullptr); hp24Button->setModel(m_parameterWidget->getBandModels( 0 )->hp24 ); hp24Button->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "24dB" ) ); hp24Button->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "24dBoff" ) ); hp24Button->move( 79 , 328 ); - PixmapButton * hp48Button = new PixmapButton( this , nullptr ); + auto hp48Button = new PixmapButton(this, nullptr); hp48Button->setModel( m_parameterWidget->getBandModels(0)->hp48 ); hp48Button->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "48dB" ) ); hp48Button->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "48dBoff" ) ); hp48Button->move( 79, 358 ); //LP filter type - PixmapButton * lp12Button = new PixmapButton( this , nullptr ); + auto lp12Button = new PixmapButton(this, nullptr); lp12Button->setModel( m_parameterWidget->getBandModels( 7 )->lp12 ); lp12Button->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "12dB" ) ); lp12Button->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "12dBoff" ) ); lp12Button->move( 387, 298 ); - PixmapButton * lp24Button = new PixmapButton( this , nullptr ); + auto lp24Button = new PixmapButton(this, nullptr); lp24Button->setModel( m_parameterWidget->getBandModels( 7 )->lp24 ); lp24Button->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "24dB" ) ); lp24Button->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "24dBoff" ) ); lp24Button->move( 387, 328 ); - PixmapButton * lp48Button = new PixmapButton( this , nullptr ); + auto lp48Button = new PixmapButton(this, nullptr); lp48Button->setModel( m_parameterWidget->getBandModels( 7 )->lp48 ); lp48Button->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "48dB" ) ); lp48Button->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "48dBoff" ) ); @@ -193,13 +199,13 @@ EqControlsDialog::EqControlsDialog( EqControls *controls ) : QObject::connect( m_parameterWidget->getBandModels( 7 )->lp24 , SIGNAL ( dataChanged() ), m_parameterWidget, SLOT( updateHandle())); QObject::connect( m_parameterWidget->getBandModels( 7 )->lp48 , SIGNAL ( dataChanged() ), m_parameterWidget, SLOT( updateHandle())); - automatableButtonGroup *lpBtnGrp = new automatableButtonGroup( this, tr( "LP group" ) ); + auto lpBtnGrp = new automatableButtonGroup(this, tr("LP group")); lpBtnGrp->addButton( lp12Button ); lpBtnGrp->addButton( lp24Button ); lpBtnGrp->addButton( lp48Button ); lpBtnGrp->setModel(&m_controls->m_lpTypeModel); - automatableButtonGroup *hpBtnGrp = new automatableButtonGroup( this, tr( "HP group" ) ); + auto hpBtnGrp = new automatableButtonGroup(this, tr("HP group")); hpBtnGrp->addButton( hp12Button ); hpBtnGrp->addButton( hp24Button ); hpBtnGrp->addButton( hp48Button ); @@ -234,3 +240,6 @@ EqBand* EqControlsDialog::setBand(int index, BoolModel* active, FloatModel* freq filterModels->lp48 = lp48; return filterModels; } + + +} // namespace lmms::gui \ No newline at end of file diff --git a/plugins/Eq/EqControlsDialog.h b/plugins/Eq/EqControlsDialog.h index b79354355..52bb2ae19 100644 --- a/plugins/Eq/EqControlsDialog.h +++ b/plugins/Eq/EqControlsDialog.h @@ -28,10 +28,17 @@ #include "EffectControlDialog.h" +namespace lmms +{ + class BoolModel; class FloatModel; class EqControls; + +namespace gui +{ + class EqBand; class EqParameterWidget; @@ -40,9 +47,7 @@ class EqControlsDialog : public EffectControlDialog Q_OBJECT public: EqControlsDialog( EqControls * controls ); - virtual ~EqControlsDialog() - { - } + ~EqControlsDialog() override = default; EqBand * setBand( EqControls * controls ); @@ -50,11 +55,16 @@ private: EqControls * m_controls; EqParameterWidget * m_parameterWidget; - virtual void mouseDoubleClickEvent(QMouseEvent *event); + void mouseDoubleClickEvent(QMouseEvent *event) override; EqBand *setBand( int index, BoolModel *active, FloatModel *freq, FloatModel *res, FloatModel *gain, QColor color, QString name, float *peakL, float *peakR, BoolModel *hp12, BoolModel *hp24, BoolModel *hp48, BoolModel *lp12, BoolModel *lp24, BoolModel *lp48 ); int m_originalHeight; }; + +} // namespace gui + +} // namespace lmms + #endif // EQCONTROLSDIALOG_H diff --git a/plugins/Eq/EqCurve.cpp b/plugins/Eq/EqCurve.cpp index be664b774..704231284 100644 --- a/plugins/Eq/EqCurve.cpp +++ b/plugins/Eq/EqCurve.cpp @@ -33,6 +33,10 @@ #include "lmms_constants.h" +namespace lmms::gui +{ + + EqHandle::EqHandle( int num, int x, int y ): m_numb( num ), m_width( x ), @@ -815,3 +819,6 @@ void EqCurve::setModelChanged( bool mc ) { m_modelChanged = mc; } + + +} // namespace lmms::gui diff --git a/plugins/Eq/EqCurve.h b/plugins/Eq/EqCurve.h index 6bc3f8871..e01e30841 100644 --- a/plugins/Eq/EqCurve.h +++ b/plugins/Eq/EqCurve.h @@ -28,6 +28,9 @@ #include +namespace lmms::gui +{ + enum{ highpass=1, @@ -52,7 +55,7 @@ public: static float gainToYPixel( float gain, int h, float pixelPerUnitHeight ); static float yPixelToGain( float y, int h, float pixelPerUnitHeight ); - QRectF boundingRect() const; + QRectF boundingRect() const override; QPainterPath getCurvePath(); float getPeakCurve( float x ); float getHighShelfCurve( float x ); @@ -80,13 +83,13 @@ signals: void positionChanged(); protected: - void mousePressEvent( QGraphicsSceneMouseEvent *event ); - void mouseReleaseEvent( QGraphicsSceneMouseEvent *event ); - void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ); - void wheelEvent( QGraphicsSceneWheelEvent *wevent ); - void hoverEnterEvent( QGraphicsSceneHoverEvent *hevent ); - void hoverLeaveEvent( QGraphicsSceneHoverEvent *hevent ); - QVariant itemChange( GraphicsItemChange change, const QVariant &value ); + void mousePressEvent( QGraphicsSceneMouseEvent *event ) override; + void mouseReleaseEvent( QGraphicsSceneMouseEvent *event ) override; + void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) override; + void wheelEvent( QGraphicsSceneWheelEvent *wevent ) override; + void hoverEnterEvent( QGraphicsSceneHoverEvent *hevent ) override; + void hoverLeaveEvent( QGraphicsSceneHoverEvent *hevent ) override; + QVariant itemChange( GraphicsItemChange change, const QVariant &value ) override; private: double calculateGain( const double freq, const double a1, const double a2, const double b0, const double b1, const double b2 ); @@ -117,11 +120,11 @@ class EqCurve : public QGraphicsObject Q_OBJECT public: EqCurve( QList *handle, int x, int y ); - QRectF boundingRect() const; + QRectF boundingRect() const override; void setModelChanged(bool mc); protected: - void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ); + void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget ) override; private: QList *m_handle; @@ -134,4 +137,7 @@ private: float m_scale; }; + +} // namespace lmms::gui + #endif // EQCURVE_H diff --git a/plugins/Eq/EqEffect.cpp b/plugins/Eq/EqEffect.cpp index 3b46143e6..eb168a9f9 100644 --- a/plugins/Eq/EqEffect.cpp +++ b/plugins/Eq/EqEffect.cpp @@ -30,12 +30,16 @@ #include "embed.h" #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT eq_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "Equalizer", QT_TRANSLATE_NOOP( "PluginBrowser", "A native eq plugin" ), "Dave French ", @@ -60,13 +64,6 @@ EqEffect::EqEffect( Model *parent, const Plugin::Descriptor::SubPluginFeatures:: -EqEffect::~EqEffect() -{ -} - - - - bool EqEffect::processAudioBuffer( sampleFrame *buf, const fpp_t frames ) { const int sampleRate = Engine::audioEngine()->processingSampleRate(); @@ -74,7 +71,7 @@ bool EqEffect::processAudioBuffer( sampleFrame *buf, const fpp_t frames ) //wet/dry controls const float dry = dryLevel(); const float wet = wetLevel(); - sample_t dryS[2]; + auto dryS = std::array{}; // setup sample exact controls float hpRes = m_eqControls.m_hpResModel.value(); float lowShelfRes = m_eqControls.m_lowShelfResModel.value(); @@ -363,3 +360,6 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* parent, void* data ) } } + + +} // namespace lmms \ No newline at end of file diff --git a/plugins/Eq/EqEffect.h b/plugins/Eq/EqEffect.h index b94ddef26..2d54c42a2 100644 --- a/plugins/Eq/EqEffect.h +++ b/plugins/Eq/EqEffect.h @@ -28,15 +28,17 @@ #include "EqControls.h" #include "EqFilter.h" +namespace lmms +{ class EqEffect : public Effect { public: EqEffect( Model * parent , const Descriptor::SubPluginFeatures::Key * key ); - virtual ~EqEffect(); - virtual bool processAudioBuffer( sampleFrame * buf, const fpp_t frames ); - virtual EffectControls * controls() + ~EqEffect() override = default; + bool processAudioBuffer( sampleFrame * buf, const fpp_t frames ) override; + EffectControls * controls() override { return &m_eqControls; } @@ -95,4 +97,7 @@ private: void setBandPeaks( EqAnalyser * fft , int ); }; + +} // namespace lmms + #endif // EQEFFECT_H diff --git a/plugins/Eq/EqFader.h b/plugins/Eq/EqFader.h index 0df66f7b7..9db0fbe2d 100644 --- a/plugins/Eq/EqFader.h +++ b/plugins/Eq/EqFader.h @@ -32,6 +32,9 @@ #include "MainWindow.h" #include "TextFloat.h" +namespace lmms::gui +{ + class EqFader : public Fader { @@ -69,9 +72,7 @@ public: - ~EqFader() - { - } + ~EqFader() override = default; private slots: @@ -112,4 +113,8 @@ private: FloatModel* m_model; }; + + +} // namespace lmms::gui + #endif // EQFADER_H diff --git a/plugins/Eq/EqFilter.h b/plugins/Eq/EqFilter.h index 5223fdeda..c64f6d5c3 100644 --- a/plugins/Eq/EqFilter.h +++ b/plugins/Eq/EqFilter.h @@ -28,6 +28,10 @@ #include "BasicFilters.h" #include "lmms_math.h" +namespace lmms +{ + + /// /// \brief The EqFilter class. /// A wrapper for the StereoBiQuad class, giving it freq, res, and gain controls. @@ -177,7 +181,7 @@ protected: class EqHp12Filter : public EqFilter { public : - virtual void calcCoefficents() + void calcCoefficents() override { // calc intermediate @@ -222,7 +226,7 @@ public : class EqLp12Filter : public EqFilter { public : - virtual void calcCoefficents() + void calcCoefficents() override { // calc intermediate @@ -266,7 +270,7 @@ class EqPeakFilter : public EqFilter public: - virtual void calcCoefficents() + void calcCoefficents() override { // calc intermediate float w0 = F_2PI * m_freq / m_sampleRate; @@ -296,7 +300,7 @@ public: setCoeffs( a1, a2, b0, b1, b2 ); } - virtual inline void setParameters( float sampleRate, float freq, float bw, float gain ) + inline void setParameters( float sampleRate, float freq, float bw, float gain ) override { bool hasChanged = false; if( sampleRate != m_sampleRate ) @@ -330,7 +334,7 @@ public: class EqLowShelfFilter : public EqFilter { public : - virtual void calcCoefficents() + void calcCoefficents() override { // calc intermediate @@ -369,7 +373,7 @@ public : class EqHighShelfFilter : public EqFilter { public : - virtual void calcCoefficents() + void calcCoefficents() override { // calc intermediate @@ -454,6 +458,7 @@ protected: }; +} // namespace lmms #endif // EQFILTER_H diff --git a/plugins/Eq/EqParameterWidget.cpp b/plugins/Eq/EqParameterWidget.cpp index a919f2773..fb60322a1 100644 --- a/plugins/Eq/EqParameterWidget.cpp +++ b/plugins/Eq/EqParameterWidget.cpp @@ -38,6 +38,9 @@ #include "lmms_constants.h" +namespace lmms::gui +{ + EqParameterWidget::EqParameterWidget( QWidget *parent, EqControls * controls ) : QWidget( parent ), @@ -53,9 +56,9 @@ EqParameterWidget::EqParameterWidget( QWidget *parent, EqControls * controls ) : m_pixelsPerOctave = EqHandle::freqToXPixel( 10000, m_displayWidth ) - EqHandle::freqToXPixel( 5000, m_displayWidth ); //GraphicsScene and GraphicsView stuff - QGraphicsScene *scene = new QGraphicsScene(); + auto scene = new QGraphicsScene(); scene->setSceneRect( 0, 0, m_displayWidth, m_displayHeigth ); - QGraphicsView *view = new QGraphicsView( this ); + auto view = new QGraphicsView(this); view->setStyleSheet( "border-style: none; background: transparent;" ); view->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); view->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); @@ -245,3 +248,6 @@ EqBand::EqBand() : peakR( 0 ) { } + + +} // namespace lmms::gui \ No newline at end of file diff --git a/plugins/Eq/EqParameterWidget.h b/plugins/Eq/EqParameterWidget.h index 28d01efbe..f80499395 100644 --- a/plugins/Eq/EqParameterWidget.h +++ b/plugins/Eq/EqParameterWidget.h @@ -30,11 +30,19 @@ #include +namespace lmms +{ + class BoolModel; class EqControls; +class FloatModel; + + +namespace gui +{ + class EqCurve; class EqHandle; -class FloatModel; class EqBand { @@ -66,7 +74,7 @@ class EqParameterWidget : public QWidget Q_OBJECT public: explicit EqParameterWidget( QWidget *parent = 0, EqControls * controls = 0 ); - ~EqParameterWidget(); + ~EqParameterWidget() override; QList *m_handleList; const int bandCount() @@ -93,4 +101,10 @@ private slots: void updateModels(); void updateHandle(); }; + + +} // namespace gui + +} // namespace lmms + #endif // EQPARAMETERWIDGET_H diff --git a/plugins/Eq/EqSpectrumView.cpp b/plugins/Eq/EqSpectrumView.cpp index e65a12ea9..aa556490b 100644 --- a/plugins/Eq/EqSpectrumView.cpp +++ b/plugins/Eq/EqSpectrumView.cpp @@ -33,6 +33,10 @@ #include "MainWindow.h" #include "lmms_constants.h" +namespace lmms +{ + + EqAnalyser::EqAnalyser() : m_framesFilledUp ( 0 ), m_energy ( 0 ), @@ -176,6 +180,8 @@ void EqAnalyser::clear() +namespace gui +{ EqSpectrumView::EqSpectrumView(EqAnalyser *b, QWidget *_parent) : QWidget( _parent ), @@ -187,7 +193,7 @@ EqSpectrumView::EqSpectrumView(EqAnalyser *b, QWidget *_parent) : setAttribute( Qt::WA_TranslucentBackground, true ); m_skipBands = MAX_BANDS * 0.5; float totalLength = log10( 20000 ); - m_pixelsPerUnitWidth = width( ) / totalLength ; + m_pixelsPerUnitWidth = width() / totalLength ; m_scale = 1.5; m_color = QColor( 255, 255, 255, 255 ); for ( int i = 0 ; i < MAX_BANDS ; i++ ) @@ -298,3 +304,8 @@ void EqSpectrumView::periodicalUpdate() m_analyser->setActive( isVisible() ); update(); } + + +} // namespace gui + +} // namespace lmms \ No newline at end of file diff --git a/plugins/Eq/EqSpectrumView.h b/plugins/Eq/EqSpectrumView.h index 40a24868d..947c55434 100644 --- a/plugins/Eq/EqSpectrumView.h +++ b/plugins/Eq/EqSpectrumView.h @@ -29,6 +29,9 @@ #include "fft_helpers.h" #include "lmms_basics.h" +namespace lmms +{ + const int MAX_BANDS = 2048; class EqAnalyser @@ -63,22 +66,21 @@ private: }; - +namespace gui +{ class EqSpectrumView : public QWidget { Q_OBJECT public: explicit EqSpectrumView( EqAnalyser *b, QWidget *_parent = 0 ); - virtual ~EqSpectrumView() - { - } + ~EqSpectrumView() override = default; QColor getColor() const; void setColor( const QColor &value ); protected: - virtual void paintEvent( QPaintEvent *event ); + void paintEvent( QPaintEvent *event ) override; private slots: void periodicalUpdate(); @@ -96,4 +98,10 @@ private: float bandToFreq ( int index ); }; + + +} // namespace gui + +} // namespace lmms + #endif // EQSPECTRUMVIEW_H diff --git a/plugins/Flanger/FlangerControls.cpp b/plugins/Flanger/FlangerControls.cpp index 1b4007b38..7402216ee 100644 --- a/plugins/Flanger/FlangerControls.cpp +++ b/plugins/Flanger/FlangerControls.cpp @@ -29,6 +29,8 @@ #include "Engine.h" #include "Song.h" +namespace lmms +{ FlangerControls::FlangerControls( FlangerEffect *effect ) : @@ -91,3 +93,6 @@ void FlangerControls::changedPlaybackState() { m_effect->restartLFO(); } + + +} // namespace lmms diff --git a/plugins/Flanger/FlangerControls.h b/plugins/Flanger/FlangerControls.h index 54ef38a1c..079497962 100644 --- a/plugins/Flanger/FlangerControls.h +++ b/plugins/Flanger/FlangerControls.h @@ -28,6 +28,9 @@ #include "EffectControls.h" #include "FlangerControlsDialog.h" +namespace lmms +{ + class FlangerEffect; @@ -36,22 +39,20 @@ class FlangerControls : public EffectControls Q_OBJECT public: FlangerControls( FlangerEffect* effect ); - virtual ~FlangerControls() - { - } - virtual void saveSettings ( QDomDocument& doc, QDomElement& parent ); - virtual void loadSettings ( const QDomElement &_this ); - inline virtual QString nodeName() const + ~FlangerControls() override = default; + void saveSettings ( QDomDocument& doc, QDomElement& parent ) override; + void loadSettings ( const QDomElement &_this ) override; + inline QString nodeName() const override { return "Flanger"; } - virtual int controlCount() + int controlCount() override { return 7; } - virtual EffectControlDialog* createView() + gui::EffectControlDialog* createView() override { - return new FlangerControlsDialog( this ); + return new gui::FlangerControlsDialog( this ); } private slots: @@ -68,9 +69,12 @@ private: FloatModel m_whiteNoiseAmountModel; BoolModel m_invertFeedbackModel; - friend class FlangerControlsDialog; + friend class gui::FlangerControlsDialog; friend class FlangerEffect; }; + +} // namespace lmms + #endif // FLANGERCONTROLS_H diff --git a/plugins/Flanger/FlangerControlsDialog.cpp b/plugins/Flanger/FlangerControlsDialog.cpp index 3c9b463fb..f35aabfd4 100644 --- a/plugins/Flanger/FlangerControlsDialog.cpp +++ b/plugins/Flanger/FlangerControlsDialog.cpp @@ -29,7 +29,8 @@ #include "LedCheckBox.h" #include "TempoSyncKnob.h" - +namespace lmms::gui +{ FlangerControlsDialog::FlangerControlsDialog( FlangerControls *controls ) : @@ -41,51 +42,54 @@ FlangerControlsDialog::FlangerControlsDialog( FlangerControls *controls ) : setPalette( pal ); setFixedSize( 233, 75 ); - Knob* delayKnob = new Knob( knobBright_26, this ); + auto delayKnob = new Knob(knobBright_26, this); delayKnob->move( 10,10 ); delayKnob->setVolumeKnob( false ); delayKnob->setModel( &controls->m_delayTimeModel ); delayKnob->setLabel( tr( "DELAY" ) ); delayKnob->setHintText( tr( "Delay time:" ) + " ", "s" ); - TempoSyncKnob * lfoFreqKnob = new TempoSyncKnob( knobBright_26, this ); + auto lfoFreqKnob = new TempoSyncKnob(knobBright_26, this); lfoFreqKnob->move( 48,10 ); lfoFreqKnob->setVolumeKnob( false ); lfoFreqKnob->setModel( &controls->m_lfoFrequencyModel ); lfoFreqKnob->setLabel( tr( "RATE" ) ); lfoFreqKnob->setHintText( tr( "Period:" ) , " Sec" ); - Knob * lfoAmtKnob = new Knob( knobBright_26, this ); + auto lfoAmtKnob = new Knob(knobBright_26, this); lfoAmtKnob->move( 85,10 ); lfoAmtKnob->setVolumeKnob( false ); lfoAmtKnob->setModel( &controls->m_lfoAmountModel ); lfoAmtKnob->setLabel( tr( "AMNT" ) ); lfoAmtKnob->setHintText( tr( "Amount:" ) , "" ); - Knob * lfoPhaseKnob = new Knob( knobBright_26, this ); + auto lfoPhaseKnob = new Knob(knobBright_26, this); lfoPhaseKnob->move( 123,10 ); lfoPhaseKnob->setVolumeKnob( false ); lfoPhaseKnob->setModel( &controls->m_lfoPhaseModel ); lfoPhaseKnob->setLabel( tr( "PHASE" ) ); lfoPhaseKnob->setHintText( tr( "Phase:" ) , " degrees" ); - Knob * feedbackKnob = new Knob( knobBright_26, this ); + auto feedbackKnob = new Knob(knobBright_26, this); feedbackKnob->move( 160,10 ); feedbackKnob->setVolumeKnob( true) ; feedbackKnob->setModel( &controls->m_feedbackModel ); feedbackKnob->setLabel( tr( "FDBK" ) ); feedbackKnob->setHintText( tr( "Feedback amount:" ) , "" ); - Knob * whiteNoiseKnob = new Knob( knobBright_26, this ); + auto whiteNoiseKnob = new Knob(knobBright_26, this); whiteNoiseKnob->move( 196,10 ); whiteNoiseKnob->setVolumeKnob( true) ; whiteNoiseKnob->setModel( &controls->m_whiteNoiseAmountModel ); whiteNoiseKnob->setLabel( tr( "NOISE" ) ); whiteNoiseKnob->setHintText( tr( "White noise amount:" ) , "" ); - LedCheckBox * invertCb = new LedCheckBox( tr( "Invert" ), this ); + auto invertCb = new LedCheckBox(tr("Invert"), this); invertCb->move( 10,53 ); } + + +} // namespace lmms::gui diff --git a/plugins/Flanger/FlangerControlsDialog.h b/plugins/Flanger/FlangerControlsDialog.h index 3e27bda47..47f746ef3 100644 --- a/plugins/Flanger/FlangerControlsDialog.h +++ b/plugins/Flanger/FlangerControlsDialog.h @@ -27,16 +27,27 @@ #include "EffectControlDialog.h" +namespace lmms +{ + + class FlangerControls; +namespace gui +{ + + class FlangerControlsDialog : public EffectControlDialog { Q_OBJECT public: FlangerControlsDialog( FlangerControls* controls ); - virtual ~FlangerControlsDialog() - { - } + ~FlangerControlsDialog() override = default; }; + +} // namespace gui + +} // namespace lmms + #endif // FLANGERCONTROLSDIALOG_H diff --git a/plugins/Flanger/FlangerEffect.cpp b/plugins/Flanger/FlangerEffect.cpp index 2668b63c5..9f7200f0e 100644 --- a/plugins/Flanger/FlangerEffect.cpp +++ b/plugins/Flanger/FlangerEffect.cpp @@ -24,16 +24,23 @@ #include "FlangerEffect.h" #include "Engine.h" +#include "MonoDelay.h" +#include "Noise.h" +#include "QuadratureLfo.h" #include "embed.h" #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT flanger_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "Flanger", QT_TRANSLATE_NOOP( "PluginBrowser", "A native flanger plugin" ), "Dave French ", @@ -100,7 +107,7 @@ bool FlangerEffect::processAudioBuffer( sampleFrame *buf, const fpp_t frames ) m_lfo->setOffset( m_flangerControls.m_lfoPhaseModel.value() / 180 * D_PI ); m_lDelay->setFeedback( m_flangerControls.m_feedbackModel.value() ); m_rDelay->setFeedback( m_flangerControls.m_feedbackModel.value() ); - sample_t dryS[2]; + auto dryS = std::array{}; float leftLfo; float rightLfo; for( fpp_t f = 0; f < frames; ++f ) @@ -161,3 +168,6 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* parent, void* data ) } }} + + +} // namespace lmms diff --git a/plugins/Flanger/FlangerEffect.h b/plugins/Flanger/FlangerEffect.h index 630513ade..8428d89a3 100644 --- a/plugins/Flanger/FlangerEffect.h +++ b/plugins/Flanger/FlangerEffect.h @@ -28,9 +28,9 @@ #include "Effect.h" #include "FlangerControls.h" -#include "MonoDelay.h" -#include "Noise.h" -#include "QuadratureLfo.h" + +namespace lmms +{ class MonoDelay; class Noise; @@ -41,9 +41,9 @@ class FlangerEffect : public Effect { public: FlangerEffect( Model* parent , const Descriptor::SubPluginFeatures::Key* key ); - virtual ~FlangerEffect(); - virtual bool processAudioBuffer( sampleFrame *buf, const fpp_t frames ); - virtual EffectControls* controls() + ~FlangerEffect() override; + bool processAudioBuffer( sampleFrame *buf, const fpp_t frames ) override; + EffectControls* controls() override { return &m_flangerControls; } @@ -59,4 +59,7 @@ private: }; + +} // namespace lmms + #endif // FLANGEREFFECT_H diff --git a/plugins/Flanger/MonoDelay.cpp b/plugins/Flanger/MonoDelay.cpp index d43e5b99d..3ec028968 100644 --- a/plugins/Flanger/MonoDelay.cpp +++ b/plugins/Flanger/MonoDelay.cpp @@ -25,6 +25,10 @@ #include "MonoDelay.h" #include "string.h" +namespace lmms +{ + + MonoDelay::MonoDelay( int maxTime , int sampleRate ) { m_buffer = 0; @@ -74,3 +78,6 @@ void MonoDelay::setSampleRate( int sampleRate ) m_buffer = new sample_t[( int )( sampleRate * m_maxTime ) ]; memset( m_buffer, 0, sizeof(float) * ( int )( sampleRate * m_maxTime ) ); } + + +} // namespace lmms diff --git a/plugins/Flanger/MonoDelay.h b/plugins/Flanger/MonoDelay.h index 52898bfe4..2e9324a7d 100644 --- a/plugins/Flanger/MonoDelay.h +++ b/plugins/Flanger/MonoDelay.h @@ -27,6 +27,10 @@ #include "lmms_basics.h" +namespace lmms +{ + + class MonoDelay { public: @@ -57,4 +61,7 @@ private: float m_maxTime; }; + +} // namespace lmms + #endif // MONODELAY_H diff --git a/plugins/Flanger/Noise.cpp b/plugins/Flanger/Noise.cpp index f2acb16fe..263fb7c45 100644 --- a/plugins/Flanger/Noise.cpp +++ b/plugins/Flanger/Noise.cpp @@ -25,6 +25,10 @@ #include "Noise.h" #include "lmms_math.h" +namespace lmms +{ + + Noise::Noise() { inv_randmax = 1.0/FAST_RAND_MAX; /* for range of 0 - 1.0 */ @@ -37,3 +41,6 @@ float Noise::tick() { return (float) ((2.0 * fast_rand() * inv_randmax) - 1.0); } + + +} // namespace lmms \ No newline at end of file diff --git a/plugins/Flanger/Noise.h b/plugins/Flanger/Noise.h index 9a3106f3e..9f6e2f2e1 100644 --- a/plugins/Flanger/Noise.h +++ b/plugins/Flanger/Noise.h @@ -25,6 +25,10 @@ #ifndef NOISE_H #define NOISE_H +namespace lmms +{ + + class Noise { public: @@ -34,4 +38,7 @@ private: double inv_randmax; }; + +} // namespace lmms + #endif // NOISE_H diff --git a/plugins/FreeBoy/FreeBoy.cpp b/plugins/FreeBoy/FreeBoy.cpp index 55c7dd79b..0d639d3a6 100644 --- a/plugins/FreeBoy/FreeBoy.cpp +++ b/plugins/FreeBoy/FreeBoy.cpp @@ -41,6 +41,10 @@ #include "plugin_export.h" +namespace lmms +{ + + const blip_time_t FRAME_LENGTH = 70224; const long CLOCK_RATE = 4194304; @@ -48,7 +52,7 @@ extern "C" { Plugin::Descriptor PLUGIN_EXPORT freeboy_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "FreeBoy", QT_TRANSLATE_NOOP( "PluginBrowser", "Emulation of GameBoy (TM) APU" ), @@ -121,11 +125,6 @@ FreeBoyInstrument::FreeBoyInstrument( InstrumentTrack * _instrument_track ) : } -FreeBoyInstrument::~FreeBoyInstrument() -{ -} - - void FreeBoyInstrument::saveSettings( QDomDocument & _doc, QDomElement & _this ) { @@ -252,7 +251,7 @@ void FreeBoyInstrument::playNote( NotePlayHandle * _n, if ( tfp == 0 ) { - Gb_Apu_Buffer *papu = new Gb_Apu_Buffer(); + auto papu = new Gb_Apu_Buffer(); papu->set_sample_rate( samplerate, CLOCK_RATE ); // Master sound circuitry power control @@ -283,7 +282,7 @@ void FreeBoyInstrument::playNote( NotePlayHandle * _n, _n->m_pluginData = papu; } - Gb_Apu_Buffer *papu = static_cast( _n->m_pluginData ); + auto papu = static_cast(_n->m_pluginData); papu->treble_eq( m_trebleModel.value() ); papu->bass_freq( m_bassModel.value() ); @@ -312,7 +311,7 @@ void FreeBoyInstrument::playNote( NotePlayHandle * _n, data = 128; papu->write_register( fakeClock(), 0xff1a, data ); - int ch3voldata[4] = { 0, 3, 2, 1 }; + auto ch3voldata = std::array{0, 3, 2, 1}; data = ch3voldata[(int)m_ch3VolumeModel.value()]; data = data<<5; papu->write_register( fakeClock(), 0xff1c, data ); @@ -389,7 +388,7 @@ void FreeBoyInstrument::playNote( NotePlayHandle * _n, int const buf_size = 2048; int framesleft = frames; int datalen = 0; - blip_sample_t buf [buf_size*2]; + auto buf = std::array{}; while( framesleft > 0 ) { int avail = papu->samples_avail(); @@ -402,7 +401,7 @@ void FreeBoyInstrument::playNote( NotePlayHandle * _n, datalen = framesleft>avail?avail:framesleft; datalen = datalen>buf_size?buf_size:datalen; - long count = papu->read_samples( buf, datalen*2)/2; + long count = papu->read_samples(buf.data(), datalen * 2) / 2; for( fpp_t frame = 0; frame < count; ++frame ) { @@ -427,12 +426,16 @@ void FreeBoyInstrument::deleteNotePluginData( NotePlayHandle * _n ) -PluginView * FreeBoyInstrument::instantiateView( QWidget * _parent ) +gui::PluginView * FreeBoyInstrument::instantiateView( QWidget * _parent ) { - return( new FreeBoyInstrumentView( this, _parent ) ); + return( new gui::FreeBoyInstrumentView( this, _parent ) ); } +namespace gui +{ + + class FreeBoyKnob : public Knob { public: @@ -676,14 +679,9 @@ FreeBoyInstrumentView::FreeBoyInstrumentView( Instrument * _instrument, } -FreeBoyInstrumentView::~FreeBoyInstrumentView() -{ -} - - void FreeBoyInstrumentView::modelChanged() { - FreeBoyInstrument * p = castModel(); + auto p = castModel(); m_ch1SweepTimeKnob->setModel( &p->m_ch1SweepTimeModel ); m_ch1SweepDirButton->setModel( &p->m_ch1SweepDirModel ); @@ -721,6 +719,9 @@ void FreeBoyInstrumentView::modelChanged() m_graph->setModel( &p->m_graphModel ); } + +} // namespace gui + extern "C" { @@ -735,3 +736,4 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *m, void * ) } +} // namespace lmms \ No newline at end of file diff --git a/plugins/FreeBoy/FreeBoy.h b/plugins/FreeBoy/FreeBoy.h index a6bef0af2..aecd2b188 100644 --- a/plugins/FreeBoy/FreeBoy.h +++ b/plugins/FreeBoy/FreeBoy.h @@ -32,10 +32,19 @@ #include "InstrumentView.h" #include "Graph.h" +namespace lmms +{ + +class NotePlayHandle; + + +namespace gui +{ +class PixmapButton; class FreeBoyInstrumentView; class Knob; -class NotePlayHandle; -class PixmapButton; +} + class FreeBoyInstrument : public Instrument { @@ -43,21 +52,21 @@ class FreeBoyInstrument : public Instrument public: FreeBoyInstrument( InstrumentTrack * _instrument_track ); - virtual ~FreeBoyInstrument(); + ~FreeBoyInstrument() override = default; - virtual void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ); - virtual void deleteNotePluginData( NotePlayHandle * _n ); + void playNote( NotePlayHandle * _n, + sampleFrame * _working_buffer ) override; + void deleteNotePluginData( NotePlayHandle * _n ) override; - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); + void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; - virtual QString nodeName() const; + QString nodeName() const override; - virtual f_cnt_t desiredReleaseFrames() const; + f_cnt_t desiredReleaseFrames() const override; - virtual PluginView * instantiateView( QWidget * _parent ); + gui::PluginView* instantiateView( QWidget * _parent ) override; /*public slots: @@ -107,19 +116,23 @@ private: blip_time_t m_time; blip_time_t fakeClock() { return m_time += 4; } - friend class FreeBoyInstrumentView; + friend class gui::FreeBoyInstrumentView; } ; +namespace gui +{ + + class FreeBoyInstrumentView : public InstrumentViewFixedSize { Q_OBJECT public: FreeBoyInstrumentView( Instrument * _instrument, QWidget * _parent ); - virtual ~FreeBoyInstrumentView(); + ~FreeBoyInstrumentView() override = default; private: - virtual void modelChanged(); + void modelChanged() override; Knob * m_ch1SweepTimeKnob; PixmapButton * m_ch1SweepDirButton; @@ -162,4 +175,8 @@ private: } ; +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/FreeBoy/Gb_Apu_Buffer.cpp b/plugins/FreeBoy/Gb_Apu_Buffer.cpp index 0cd8662ac..ec1a36479 100644 --- a/plugins/FreeBoy/Gb_Apu_Buffer.cpp +++ b/plugins/FreeBoy/Gb_Apu_Buffer.cpp @@ -22,8 +22,9 @@ */ #include "Gb_Apu_Buffer.h" -Gb_Apu_Buffer::Gb_Apu_Buffer() {} -Gb_Apu_Buffer::~Gb_Apu_Buffer() {} +namespace lmms +{ + void Gb_Apu_Buffer::end_frame(blip_time_t end_time) { Gb_Apu::end_frame(end_time); @@ -51,3 +52,5 @@ void Gb_Apu_Buffer::bass_freq(int freq) { m_buf.bass_freq(freq); } + +} // namespace lmms diff --git a/plugins/FreeBoy/Gb_Apu_Buffer.h b/plugins/FreeBoy/Gb_Apu_Buffer.h index 5228b7b8a..760e0920d 100644 --- a/plugins/FreeBoy/Gb_Apu_Buffer.h +++ b/plugins/FreeBoy/Gb_Apu_Buffer.h @@ -27,22 +27,29 @@ #include "Multi_Buffer.h" #include "MemoryManager.h" +namespace lmms +{ + + class Gb_Apu_Buffer : public Gb_Apu { MM_OPERATORS public: - Gb_Apu_Buffer(); - ~Gb_Apu_Buffer(); + Gb_Apu_Buffer() = default; + ~Gb_Apu_Buffer() = default; void end_frame(blip_time_t); blargg_err_t set_sample_rate(long sample_rate, long clock_rate); long samples_avail() const; - typedef blip_sample_t sample_t; + using sample_t = blip_sample_t; long read_samples(sample_t* out, long count); void bass_freq(int freq); private: Stereo_Buffer m_buf; }; + +} // namespace lmms + #endif diff --git a/plugins/GigPlayer/GigPlayer.cpp b/plugins/GigPlayer/GigPlayer.cpp index b2239d895..24073ceea 100644 --- a/plugins/GigPlayer/GigPlayer.cpp +++ b/plugins/GigPlayer/GigPlayer.cpp @@ -55,12 +55,16 @@ #include "embed.h" #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT gigplayer_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "GIG Player", QT_TRANSLATE_NOOP( "PluginBrowser", "Player for GIG files" ), "Garrett Wilson ", @@ -88,7 +92,7 @@ GigInstrument::GigInstrument( InstrumentTrack * _instrument_track ) : m_RandomSeed( 0 ), m_currentKeyDimension( 0 ) { - InstrumentPlayHandle * iph = new InstrumentPlayHandle( this, _instrument_track ); + auto iph = new InstrumentPlayHandle(this, _instrument_track); Engine::audioEngine()->addPlayHandle( iph ); updateSampleRate(); @@ -301,7 +305,7 @@ void GigInstrument::playNote( NotePlayHandle * _n, sampleFrame * ) if( tfp == 0 ) { - GIGPluginData * pluginData = new GIGPluginData; + auto pluginData = new GIGPluginData; pluginData->midiNote = midiNote; _n->m_pluginData = pluginData; @@ -351,10 +355,9 @@ void GigInstrument::play( sampleFrame * _working_buffer ) it->state = PlayingKeyUp; // Notify each sample that the key has been released - for( QList::iterator sample = it->samples.begin(); - sample != it->samples.end(); ++sample ) + for (auto& sample : it->samples) { - sample->adsr.keyup(); + sample.adsr.keyup(); } // Add release samples if available @@ -404,22 +407,17 @@ void GigInstrument::play( sampleFrame * _working_buffer ) } // Fill buffer with portions of the note samples - for( QList::iterator it = m_notes.begin(); it != m_notes.end(); ++it ) + for (auto& note : m_notes) { // Only process the notes if we're in a playing state - if( !( it->state == PlayingKeyDown || - it->state == PlayingKeyUp ) ) + if (!(note.state == PlayingKeyDown || note.state == PlayingKeyUp )) { continue; } - for( QList::iterator sample = it->samples.begin(); - sample != it->samples.end(); ++sample ) + for (auto& sample : note.samples) { - if( sample->sample == nullptr || sample->region == nullptr ) - { - continue; - } + if (sample.sample == nullptr || sample.region == nullptr) { continue; } // Will change if resampling bool resample = false; @@ -430,18 +428,15 @@ void GigInstrument::play( sampleFrame * _working_buffer ) // Resample to be the correct pitch when the sample provided isn't // solely for this one note (e.g. one or two samples per octave) or // we are processing at a different sample rate - if( sample->region->PitchTrack == true || rate != sample->sample->SamplesPerSecond ) + if (sample.region->PitchTrack == true || rate != sample.sample->SamplesPerSecond) { resample = true; // Factor just for resampling - freq_factor = 1.0 * rate / sample->sample->SamplesPerSecond; + freq_factor = 1.0 * rate / sample.sample->SamplesPerSecond; // Factor for pitch shifting as well as resampling - if( sample->region->PitchTrack == true ) - { - freq_factor *= sample->freqFactor; - } + if (sample.region->PitchTrack == true) { freq_factor *= sample.freqFactor; } // We need a bit of margin so we don't get glitching samples = frames / freq_factor + MARGIN[m_interpolation]; @@ -449,11 +444,11 @@ void GigInstrument::play( sampleFrame * _working_buffer ) // Load this note's data sampleFrame sampleData[samples]; - loadSample( *sample, sampleData, samples ); + loadSample(sample, sampleData, samples); // Apply ADSR using a copy so if we don't use these samples when // resampling, the ADSR doesn't get messed up - ADSR copy = sample->adsr; + ADSR copy = sample.adsr; for( f_cnt_t i = 0; i < samples; ++i ) { @@ -468,8 +463,7 @@ void GigInstrument::play( sampleFrame * _working_buffer ) sampleFrame convertBuf[frames]; // Only output if resampling is successful (note that "used" is output) - if( sample->convertSampleRate( *sampleData, *convertBuf, samples, frames, - freq_factor, used ) ) + if (sample.convertSampleRate(*sampleData, *convertBuf, samples, frames, freq_factor, used)) { for( f_cnt_t i = 0; i < frames; ++i ) { @@ -488,8 +482,8 @@ void GigInstrument::play( sampleFrame * _working_buffer ) } // Update note position with how many samples we actually used - sample->pos += used; - sample->adsr.inc( used ); + sample.pos += used; + sample.adsr.inc(used); } } @@ -589,7 +583,7 @@ void GigInstrument::loadSample( GigSample& sample, sampleFrame* sampleData, f_cn // Convert from 16 or 24 bit into 32-bit float if( sample.sample->BitDepth == 24 ) // 24 bit { - uint8_t * pInt = reinterpret_cast( &buffer ); + auto pInt = reinterpret_cast(&buffer); for( f_cnt_t i = 0; i < samples; ++i ) { @@ -621,7 +615,7 @@ void GigInstrument::loadSample( GigSample& sample, sampleFrame* sampleData, f_cn } else // 16 bit { - int16_t * pInt = reinterpret_cast( &buffer ); + auto pInt = reinterpret_cast(&buffer); for( f_cnt_t i = 0; i < samples; ++i ) { @@ -680,18 +674,17 @@ f_cnt_t GigInstrument::getPingPongIndex( f_cnt_t index, f_cnt_t startf, f_cnt_t // A key has been released void GigInstrument::deleteNotePluginData( NotePlayHandle * _n ) { - GIGPluginData * pluginData = static_cast( _n->m_pluginData ); + auto pluginData = static_cast(_n->m_pluginData); QMutexLocker locker( &m_notesMutex ); // Mark the note as being released, but only if it was playing or was just // pressed (i.e., not if the key was already released) - for( QList::iterator i = m_notes.begin(); i != m_notes.end(); ++i ) + for (auto& note : m_notes) { // Find the note by matching pointers to the plugin data - if( i->handle == pluginData && - ( i->state == KeyDown || i->state == PlayingKeyDown ) ) + if (note.handle == pluginData && (note.state == KeyDown || note.state == PlayingKeyDown)) { - i->state = KeyUp; + note.state = KeyUp; } } @@ -703,9 +696,9 @@ void GigInstrument::deleteNotePluginData( NotePlayHandle * _n ) -PluginView * GigInstrument::instantiateView( QWidget * _parent ) +gui::PluginView* GigInstrument::instantiateView( QWidget * _parent ) { - return new GigInstrumentView( this, _parent ); + return new gui::GigInstrumentView( this, _parent ); } @@ -907,6 +900,9 @@ void GigInstrument::updateSampleRate() +namespace gui +{ + class gigKnob : public Knob { @@ -924,7 +920,7 @@ public: GigInstrumentView::GigInstrumentView( Instrument * _instrument, QWidget * _parent ) : InstrumentViewFixedSize( _instrument, _parent ) { - GigInstrument * k = castModel(); + auto k = castModel(); connect( &k->m_bankNum, SIGNAL( dataChanged() ), this, SLOT( updatePatchName() ) ); connect( &k->m_patchNum, SIGNAL( dataChanged() ), this, SLOT( updatePatchName() ) ); @@ -981,16 +977,9 @@ GigInstrumentView::GigInstrumentView( Instrument * _instrument, QWidget * _paren -GigInstrumentView::~GigInstrumentView() -{ -} - - - - void GigInstrumentView::modelChanged() { - GigInstrument * k = castModel(); + auto k = castModel(); m_bankNumLcd->setModel( &k->m_bankNum ); m_patchNumLcd->setModel( &k->m_patchNum ); @@ -1007,7 +996,7 @@ void GigInstrumentView::modelChanged() void GigInstrumentView::updateFilename() { - GigInstrument * i = castModel(); + auto i = castModel(); QFontMetrics fm( m_filenameLabel->font() ); QString file = i->m_filename.endsWith( ".gig", Qt::CaseInsensitive ) ? i->m_filename.left( i->m_filename.length() - 4 ) : @@ -1025,7 +1014,7 @@ void GigInstrumentView::updateFilename() void GigInstrumentView::updatePatchName() { - GigInstrument * i = castModel(); + auto i = castModel(); QFontMetrics fm( font() ); QString patch = i->getCurrentPatchName(); m_patchLabel->setText( fm.elidedText( patch, Qt::ElideLeft, m_patchLabel->width() ) ); @@ -1046,7 +1035,7 @@ void GigInstrumentView::invalidateFile() void GigInstrumentView::showFileDialog() { - GigInstrument * k = castModel(); + auto k = castModel(); FileDialog ofd( nullptr, tr( "Open GIG file" ) ); ofd.setFileMode( FileDialog::ExistingFiles ); @@ -1087,13 +1076,14 @@ void GigInstrumentView::showFileDialog() void GigInstrumentView::showPatchDialog() { - GigInstrument * k = castModel(); + auto k = castModel(); PatchesDialog pd( this ); pd.setup( k->m_instance, 1, k->instrumentTrack()->name(), &k->m_bankNum, &k->m_patchNum, m_patchLabel ); pd.exec(); } +} // namespace gui // Store information related to playing a sample from the GIG file @@ -1396,3 +1386,6 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *m, void * ) } } + + +} // namespace lmms diff --git a/plugins/GigPlayer/GigPlayer.h b/plugins/GigPlayer/GigPlayer.h index 288146b60..20058424b 100644 --- a/plugins/GigPlayer/GigPlayer.h +++ b/plugins/GigPlayer/GigPlayer.h @@ -41,11 +41,21 @@ #include "MemoryManager.h" #include "gig.h" -class GigInstrumentView; + +class QLabel; + + +namespace lmms +{ + + class NotePlayHandle; +namespace gui +{ class PatchesDialog; -class QLabel; +class GigInstrumentView; +} @@ -233,35 +243,35 @@ class GigInstrument : public Instrument public: GigInstrument( InstrumentTrack * _instrument_track ); - virtual ~GigInstrument(); + ~GigInstrument() override; - virtual void play( sampleFrame * _working_buffer ); + void play( sampleFrame * _working_buffer ) override; - virtual void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ); - virtual void deleteNotePluginData( NotePlayHandle * _n ); + void playNote( NotePlayHandle * _n, + sampleFrame * _working_buffer ) override; + void deleteNotePluginData( NotePlayHandle * _n ) override; - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); + void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; - virtual void loadFile( const QString & _file ); + void loadFile( const QString & _file ) override; - virtual AutomatableModel * childModel( const QString & _modelName ); + AutomatableModel * childModel( const QString & _modelName ) override; - virtual QString nodeName() const; + QString nodeName() const override; - virtual f_cnt_t desiredReleaseFrames() const + f_cnt_t desiredReleaseFrames() const override { return 0; } - virtual Flags flags() const + Flags flags() const override { return IsSingleStreamed|IsNotBendable; } - virtual PluginView * instantiateView( QWidget * _parent ); + gui::PluginView* instantiateView( QWidget * _parent ) override; QString getCurrentPatchName(); @@ -283,8 +293,8 @@ private: // Part of the UI QString m_filename; - LcdSpinBoxModel m_bankNum; - LcdSpinBoxModel m_patchNum; + gui::LcdSpinBoxModel m_bankNum; + gui::LcdSpinBoxModel m_patchNum; FloatModel m_gain; @@ -322,7 +332,7 @@ private: // samples void addSamples( GigNote & gignote, bool wantReleaseSample ); - friend class GigInstrumentView; + friend class gui::GigInstrumentView; signals: void fileLoading(); @@ -332,6 +342,8 @@ signals: } ; +namespace gui +{ class GigInstrumentView : public InstrumentViewFixedSize @@ -340,10 +352,10 @@ class GigInstrumentView : public InstrumentViewFixedSize public: GigInstrumentView( Instrument * _instrument, QWidget * _parent ); - virtual ~GigInstrumentView(); + ~GigInstrumentView() override = default; private: - virtual void modelChanged(); + void modelChanged() override; PixmapButton * m_fileDialogButton; PixmapButton * m_patchDialogButton; @@ -367,4 +379,8 @@ protected slots: } ; +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/GigPlayer/PatchesDialog.cpp b/plugins/GigPlayer/PatchesDialog.cpp index 3d75dd216..c78c99f2c 100644 --- a/plugins/GigPlayer/PatchesDialog.cpp +++ b/plugins/GigPlayer/PatchesDialog.cpp @@ -27,6 +27,9 @@ #include +namespace lmms::gui +{ + // Custom list-view item (as for numerical sort purposes...) class PatchItem : public QTreeWidgetItem @@ -39,7 +42,7 @@ public: : QTreeWidgetItem( pListView, pItemAfter ) {} // Sort/compare overriden method. - bool operator< ( const QTreeWidgetItem& other ) const + bool operator< ( const QTreeWidgetItem& other ) const override { int iColumn = QTreeWidgetItem::treeWidget()->sortColumn(); const QString& s1 = text( iColumn ); @@ -104,14 +107,6 @@ PatchesDialog::PatchesDialog( QWidget * pParent, Qt::WindowFlags wflags ) -// Destructor. -PatchesDialog::~PatchesDialog() -{ -} - - - - // Dialog setup loader. void PatchesDialog::setup( GigInstance * pSynth, int iChan, const QString & chanName, @@ -408,3 +403,6 @@ void PatchesDialog::progChanged( QTreeWidgetItem * curr, QTreeWidgetItem * prev // Stabilize the form. stabilizeForm(); } + + +} // namespace lmms::gui diff --git a/plugins/GigPlayer/PatchesDialog.h b/plugins/GigPlayer/PatchesDialog.h index ae00f660a..c4aed9102 100644 --- a/plugins/GigPlayer/PatchesDialog.h +++ b/plugins/GigPlayer/PatchesDialog.h @@ -36,6 +36,10 @@ //---------------------------------------------------------------------------- // qsynthPresetForm -- UI wrapper form. +namespace lmms::gui +{ + + class PatchesDialog : public QDialog, private Ui::PatchesDialog { Q_OBJECT @@ -46,7 +50,7 @@ public: PatchesDialog(QWidget * pParent = 0, Qt::WindowFlags wflags = QFlag(0)); // Destructor. - virtual ~PatchesDialog(); + ~PatchesDialog() override = default; void setup( GigInstance * pSynth, int iChan, const QString & chanName, @@ -60,8 +64,8 @@ public slots: protected slots: - void accept(); - void reject(); + void accept() override; + void reject() override; protected: @@ -88,4 +92,7 @@ private: QLabel * m_patchLabel; }; + +} // namespace lmms::gui + #endif diff --git a/plugins/HydrogenImport/HydrogenImport.cpp b/plugins/HydrogenImport/HydrogenImport.cpp index 7e13d2351..d8f76071a 100644 --- a/plugins/HydrogenImport/HydrogenImport.cpp +++ b/plugins/HydrogenImport/HydrogenImport.cpp @@ -14,12 +14,17 @@ #include "plugin_export.h" #define MAX_LAYERS 4 + +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT hydrogenimport_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "Hydrogen Import", QT_TRANSLATE_NOOP( "PluginBrowser", "Filter for importing Hydrogen files into LMMS" ), @@ -129,9 +134,6 @@ HydrogenImport::HydrogenImport( const QString & _file ) : -HydrogenImport::~HydrogenImport() -{ -} Instrument * ins; bool HydrogenImport::readSong() { @@ -274,7 +276,7 @@ bool HydrogenImport::readSong() QString instrId = LocalFileMng::readXmlString( noteNode, "instrument", 0,false, false ); int i = pattern_count - 1 + existing_patterns; pattern_id[sName] = pattern_count - 1; - MidiClip*p = dynamic_cast( drum_track[instrId]->getClip( i ) ); + auto p = dynamic_cast(drum_track[instrId]->getClip(i)); Note n; n.setPos( nPosition ); if ( (nPosition + 48) <= nSize ) @@ -351,3 +353,5 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *, void * _data ) } + +} // namespace lmms diff --git a/plugins/HydrogenImport/HydrogenImport.h b/plugins/HydrogenImport/HydrogenImport.h index d19d1e8dd..de4709051 100644 --- a/plugins/HydrogenImport/HydrogenImport.h +++ b/plugins/HydrogenImport/HydrogenImport.h @@ -5,6 +5,9 @@ #include "ImportFilter.h" +namespace lmms +{ + class HydrogenImport : public ImportFilter { @@ -12,14 +15,18 @@ public: HydrogenImport( const QString & _file ); bool readSong(); - virtual ~HydrogenImport(); + ~HydrogenImport() override = default; - virtual PluginView * instantiateView( QWidget * ) + gui::PluginView* instantiateView( QWidget * ) override { return( nullptr ); } private: - virtual bool tryImport( TrackContainer* tc ); + bool tryImport( TrackContainer* tc ) override; }; + + +} // namespace lmms + #endif diff --git a/plugins/HydrogenImport/LocalFileMng.h b/plugins/HydrogenImport/LocalFileMng.h index 217f95f34..0aaf7d1c8 100644 --- a/plugins/HydrogenImport/LocalFileMng.h +++ b/plugins/HydrogenImport/LocalFileMng.h @@ -7,6 +7,10 @@ #include #include +namespace lmms +{ + + class LocalFileMng { public: @@ -25,5 +29,9 @@ public: static QDomDocument openXmlDocument( const QString& filename ); std::vector m_allPatternList; }; + + +} // namespace lmms + #endif //LFILEMNG_H diff --git a/plugins/HydrogenImport/local_file_mgr.cpp b/plugins/HydrogenImport/local_file_mgr.cpp index 3ca6572a9..227440501 100644 --- a/plugins/HydrogenImport/local_file_mgr.cpp +++ b/plugins/HydrogenImport/local_file_mgr.cpp @@ -8,6 +8,9 @@ #include "LocalFileMng.h" +namespace lmms +{ + /* New QtXml based methods */ @@ -227,3 +230,5 @@ QDomDocument LocalFileMng::openXmlDocument( const QString& filename ) return doc; } + +} // namespace lmms diff --git a/plugins/Kicker/Kicker.cpp b/plugins/Kicker/Kicker.cpp index de14f4af7..7d4c6fbb0 100644 --- a/plugins/Kicker/Kicker.cpp +++ b/plugins/Kicker/Kicker.cpp @@ -40,12 +40,16 @@ #include "embed.h" #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT kicker_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "Kicker", QT_TRANSLATE_NOOP( "PluginBrowser", "Versatile drum synthesizer" ), @@ -81,13 +85,6 @@ KickerInstrument::KickerInstrument( InstrumentTrack * _instrument_track ) : -KickerInstrument::~KickerInstrument() -{ -} - - - - void KickerInstrument::saveSettings( QDomDocument & _doc, QDomElement & _this ) { @@ -157,11 +154,8 @@ QString KickerInstrument::nodeName() const return kicker_plugin_descriptor.name; } - - -typedef DspEffectLibrary::Distortion DistFX; -typedef KickerOsc > SweepOsc; - +using DistFX = DspEffectLibrary::Distortion; +using SweepOsc = KickerOsc>; void KickerInstrument::playNote( NotePlayHandle * _n, sampleFrame * _working_buffer ) @@ -191,7 +185,7 @@ void KickerInstrument::playNote( NotePlayHandle * _n, _n->noteOff(); } - SweepOsc * so = static_cast( _n->m_pluginData ); + auto so = static_cast(_n->m_pluginData); so->update( _working_buffer + offset, frames, Engine::audioEngine()->processingSampleRate() ); if( _n->isReleased() ) @@ -220,12 +214,14 @@ void KickerInstrument::deleteNotePluginData( NotePlayHandle * _n ) -PluginView * KickerInstrument::instantiateView( QWidget * _parent ) +gui::PluginView * KickerInstrument::instantiateView( QWidget * _parent ) { - return new KickerInstrumentView( this, _parent ); + return new gui::KickerInstrumentView( this, _parent ); } +namespace gui +{ class KickerKnob : public Knob @@ -336,16 +332,9 @@ KickerInstrumentView::KickerInstrumentView( Instrument * _instrument, -KickerInstrumentView::~KickerInstrumentView() -{ -} - - - - void KickerInstrumentView::modelChanged() { - KickerInstrument * k = castModel(); + auto k = castModel(); m_startFreqKnob->setModel( &k->m_startFreqModel ); m_endFreqKnob->setModel( &k->m_endFreqModel ); m_decayKnob->setModel( &k->m_decayModel ); @@ -361,7 +350,7 @@ void KickerInstrumentView::modelChanged() } - +} // namespace gui extern "C" @@ -377,5 +366,4 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model * m, void * ) } - - +} // namespace lmms diff --git a/plugins/Kicker/Kicker.h b/plugins/Kicker/Kicker.h index f63f68c9c..22413c4db 100644 --- a/plugins/Kicker/Kicker.h +++ b/plugins/Kicker/Kicker.h @@ -32,45 +32,50 @@ #include "InstrumentView.h" #include "TempoSyncKnobModel.h" -class Knob; -class LedCheckBox; - +namespace lmms +{ #define KICKER_PRESET_VERSION 1 -class KickerInstrumentView; class NotePlayHandle; +namespace gui +{ +class Knob; +class LedCheckBox; +class KickerInstrumentView; +} + class KickerInstrument : public Instrument { Q_OBJECT public: KickerInstrument( InstrumentTrack * _instrument_track ); - virtual ~KickerInstrument(); + ~KickerInstrument() override = default; - virtual void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ); - virtual void deleteNotePluginData( NotePlayHandle * _n ); + void playNote( NotePlayHandle * _n, + sampleFrame * _working_buffer ) override; + void deleteNotePluginData( NotePlayHandle * _n ) override; - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); + void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; - virtual QString nodeName() const; + QString nodeName() const override; - virtual Flags flags() const + Flags flags() const override { return IsNotBendable; } - virtual f_cnt_t desiredReleaseFrames() const + f_cnt_t desiredReleaseFrames() const override { return( 512 ); } - virtual PluginView * instantiateView( QWidget * _parent ); + gui::PluginView* instantiateView( QWidget * _parent ) override; private: @@ -90,21 +95,24 @@ private: IntModel m_versionModel; - friend class KickerInstrumentView; + friend class gui::KickerInstrumentView; } ; +namespace gui +{ + class KickerInstrumentView : public InstrumentViewFixedSize { Q_OBJECT public: KickerInstrumentView( Instrument * _instrument, QWidget * _parent ); - virtual ~KickerInstrumentView(); + ~KickerInstrumentView() override = default; private: - virtual void modelChanged(); + void modelChanged() override; Knob * m_startFreqKnob; Knob * m_endFreqKnob; @@ -123,5 +131,8 @@ private: } ; +} // namespace gui + +} // namespace lmms #endif diff --git a/plugins/Kicker/KickerOsc.h b/plugins/Kicker/KickerOsc.h index 1375725b3..1accb50a4 100644 --- a/plugins/Kicker/KickerOsc.h +++ b/plugins/Kicker/KickerOsc.h @@ -33,6 +33,9 @@ #include "interpolation.h" #include "MemoryManager.h" +namespace lmms +{ + template class KickerOsc @@ -57,9 +60,7 @@ public: { } - virtual ~KickerOsc() - { - } + virtual ~KickerOsc() = default; void update( sampleFrame* buf, const fpp_t frames, const float sampleRate ) { @@ -107,4 +108,6 @@ private: }; +} // namespace lmms + #endif diff --git a/plugins/LadspaBrowser/LadspaBrowser.cpp b/plugins/LadspaBrowser/LadspaBrowser.cpp index 97282c309..714b3887c 100644 --- a/plugins/LadspaBrowser/LadspaBrowser.cpp +++ b/plugins/LadspaBrowser/LadspaBrowser.cpp @@ -41,13 +41,16 @@ #include "embed.h" #include "plugin_export.h" +namespace lmms +{ + extern "C" { Plugin::Descriptor PLUGIN_EXPORT ladspabrowser_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "LADSPA Plugin Browser", QT_TRANSLATE_NOOP( "PluginBrowser", "List installed LADSPA plugins" ), @@ -79,13 +82,6 @@ LadspaBrowser::LadspaBrowser() : -LadspaBrowser::~LadspaBrowser() -{ -} - - - - QString LadspaBrowser::nodeName() const { return ladspabrowser_plugin_descriptor.name; @@ -93,13 +89,14 @@ QString LadspaBrowser::nodeName() const - +namespace gui +{ LadspaBrowserView::LadspaBrowserView( ToolPlugin * _tool ) : ToolPluginView( _tool ) { - QHBoxLayout * hlayout = new QHBoxLayout( this ); + auto hlayout = new QHBoxLayout(this); hlayout->setSpacing( 0 ); hlayout->setMargin( 0 ); @@ -107,7 +104,7 @@ LadspaBrowserView::LadspaBrowserView( ToolPlugin * _tool ) : m_tabBar->setExclusive( true ); m_tabBar->setFixedWidth( 72 ); - QWidget * ws = new QWidget( this ); + auto ws = new QWidget(this); ws->setFixedSize( 500, 480 ); QWidget * available = createTab( ws, tr( "Available Effects" ), VALID ); @@ -162,24 +159,17 @@ LadspaBrowserView::LadspaBrowserView( ToolPlugin * _tool ) : -LadspaBrowserView::~LadspaBrowserView() -{ -} - - - - QWidget * LadspaBrowserView::createTab( QWidget * _parent, const QString & _txt, LadspaPluginType _type ) { - QWidget * tab = new QWidget( _parent ); + auto tab = new QWidget(_parent); tab->setFixedSize( 500, 400 ); - QVBoxLayout * layout = new QVBoxLayout( tab ); + auto layout = new QVBoxLayout(tab); layout->setSpacing( 0 ); layout->setMargin( 0 ); const QString type = "" + tr( "Type:" ) + " "; - QLabel * title = new QLabel( type + _txt, tab ); + auto title = new QLabel(type + _txt, tab); QFont f = title->font(); f.setBold( true ); title->setFont( pointSize<12>( f ) ); @@ -188,9 +178,9 @@ QWidget * LadspaBrowserView::createTab( QWidget * _parent, const QString & _txt, layout->addWidget( title ); layout->addSpacing( 10 ); - LadspaDescription * description = new LadspaDescription( tab, _type ); - connect( description, SIGNAL( doubleClicked( const ladspa_key_t & ) ), - SLOT( showPorts( const ladspa_key_t & ) ) ); + auto description = new LadspaDescription(tab, _type); + connect( description, SIGNAL( doubleClicked( const ::lmms::ladspa_key_t & ) ), + SLOT( showPorts( const ::lmms::ladspa_key_t & ) ) ); layout->addWidget( description, 1 ); return tab; @@ -199,13 +189,13 @@ QWidget * LadspaBrowserView::createTab( QWidget * _parent, const QString & _txt, -void LadspaBrowserView::showPorts( const ladspa_key_t & _key ) +void LadspaBrowserView::showPorts( const ::lmms::ladspa_key_t & _key ) { LadspaPortDialog ports( _key ); ports.exec(); } +} // namespace gui - - +} // namespace lmms diff --git a/plugins/LadspaBrowser/LadspaBrowser.h b/plugins/LadspaBrowser/LadspaBrowser.h index 69c9d6263..faf1136dd 100644 --- a/plugins/LadspaBrowser/LadspaBrowser.h +++ b/plugins/LadspaBrowser/LadspaBrowser.h @@ -31,19 +31,26 @@ #include "ToolPlugin.h" #include "ToolPluginView.h" -class TabBar; +namespace lmms +{ +namespace gui +{ + + +class TabBar; + class LadspaBrowserView : public ToolPluginView { Q_OBJECT public: LadspaBrowserView( ToolPlugin * _tool ); - virtual ~LadspaBrowserView(); + ~LadspaBrowserView() override = default; public slots: - void showPorts( const ladspa_key_t & _key ); + void showPorts( const ::lmms::ladspa_key_t & _key ); private: @@ -52,29 +59,32 @@ private: QWidget * createTab( QWidget * _parent, const QString & _txt, LadspaPluginType _type ); -} ; +}; + + +} // namespace gui class LadspaBrowser : public ToolPlugin { public: LadspaBrowser(); - virtual ~LadspaBrowser(); + ~LadspaBrowser() override = default; - virtual PluginView * instantiateView( QWidget * ) + gui::PluginView* instantiateView( QWidget * ) override { - return new LadspaBrowserView( this ); + return new gui::LadspaBrowserView( this ); } - virtual QString nodeName() const; + QString nodeName() const override; - virtual void saveSettings( QDomDocument& doc, QDomElement& element ) + void saveSettings( QDomDocument& doc, QDomElement& element ) override { Q_UNUSED(doc) Q_UNUSED(element) } - virtual void loadSettings( const QDomElement& element ) + void loadSettings( const QDomElement& element ) override { Q_UNUSED(element) } @@ -83,4 +93,6 @@ public: } ; +} // namespace lmms + #endif diff --git a/plugins/LadspaBrowser/LadspaDescription.cpp b/plugins/LadspaBrowser/LadspaDescription.cpp index 49c16a695..ff4d74867 100644 --- a/plugins/LadspaBrowser/LadspaDescription.cpp +++ b/plugins/LadspaBrowser/LadspaDescription.cpp @@ -36,6 +36,9 @@ #include "Ladspa2LMMS.h" +namespace lmms::gui +{ + LadspaDescription::LadspaDescription( QWidget * _parent, LadspaPluginType _type ) : @@ -69,20 +72,18 @@ LadspaDescription::LadspaDescription( QWidget * _parent, } QList pluginNames; - for( l_sortable_plugin_t::iterator it = plugins.begin(); - it != plugins.end(); ++it ) + for (const auto& plugin : plugins) { - if( _type != VALID || - manager->getDescription( ( *it ).second )->inputChannels - <= Engine::audioEngine()->audioDev()->channels() ) - { - pluginNames.push_back( ( *it ).first ); - m_pluginKeys.push_back( ( *it ).second ); + ch_cnt_t audioDeviceChannels = Engine::audioEngine()->audioDev()->channels(); + if (_type != VALID || manager->getDescription(plugin.second)->inputChannels <= audioDeviceChannels) + { + pluginNames.push_back(plugin.first); + m_pluginKeys.push_back(plugin.second); } } - QGroupBox * pluginsBox = new QGroupBox( tr( "Plugins" ), this ); - QListWidget * pluginList = new QListWidget( pluginsBox ); + auto pluginsBox = new QGroupBox(tr("Plugins"), this); + auto pluginList = new QListWidget(pluginsBox); pluginList->addItems( pluginNames ); connect( pluginList, SIGNAL( currentRowChanged( int ) ), SLOT( rowChanged( int ) ) ); @@ -90,15 +91,15 @@ LadspaDescription::LadspaDescription( QWidget * _parent, SLOT( onDoubleClicked( QListWidgetItem * ) ) ); ( new QVBoxLayout( pluginsBox ) )->addWidget( pluginList ); - QGroupBox * descriptionBox = new QGroupBox( tr( "Description" ), this ); - QVBoxLayout * descriptionLayout = new QVBoxLayout( descriptionBox ); + auto descriptionBox = new QGroupBox(tr("Description"), this); + auto descriptionLayout = new QVBoxLayout(descriptionBox); descriptionLayout->setSpacing( 0 ); descriptionLayout->setMargin( 0 ); m_scrollArea = new QScrollArea( descriptionBox ); descriptionLayout->addWidget( m_scrollArea ); - QVBoxLayout * layout = new QVBoxLayout( this ); + auto layout = new QVBoxLayout(this); layout->addWidget( pluginsBox ); layout->addWidget( descriptionBox ); @@ -113,85 +114,78 @@ LadspaDescription::LadspaDescription( QWidget * _parent, -LadspaDescription::~LadspaDescription() -{ -} - - - - void LadspaDescription::update( const ladspa_key_t & _key ) { - QWidget * description = new QWidget; + auto description = new QWidget; m_scrollArea->setWidget( description ); - QVBoxLayout * layout = new QVBoxLayout( description ); + auto layout = new QVBoxLayout(description); layout->setSizeConstraint( QLayout::SetFixedSize ); Ladspa2LMMS * manager = Engine::getLADSPAManager(); - QLabel * name = new QLabel( description ); + auto name = new QLabel(description); name->setText( QWidget::tr( "Name: " ) + manager->getName( _key ) ); layout->addWidget( name ); - QWidget * maker = new QWidget( description ); - QHBoxLayout * makerLayout = new QHBoxLayout( maker ); + auto maker = new QWidget(description); + auto makerLayout = new QHBoxLayout(maker); makerLayout->setMargin( 0 ); makerLayout->setSpacing( 0 ); layout->addWidget( maker ); - QLabel * maker_label = new QLabel( maker ); + auto maker_label = new QLabel(maker); maker_label->setText( QWidget::tr( "Maker: " ) ); maker_label->setAlignment( Qt::AlignTop ); - QLabel * maker_content = new QLabel( maker ); + auto maker_content = new QLabel(maker); maker_content->setText( manager->getMaker( _key ) ); maker_content->setWordWrap( true ); makerLayout->addWidget( maker_label ); makerLayout->addWidget( maker_content, 1 ); - QWidget * copyright = new QWidget( description ); - QHBoxLayout * copyrightLayout = new QHBoxLayout( copyright ); + auto copyright = new QWidget(description); + auto copyrightLayout = new QHBoxLayout(copyright); copyrightLayout->setMargin( 0 ); copyrightLayout->setSpacing( 0 ); layout->addWidget( copyright ); - QLabel * copyright_label = new QLabel( copyright ); + auto copyright_label = new QLabel(copyright); copyright_label->setText( QWidget::tr( "Copyright: " ) ); copyright_label->setAlignment( Qt::AlignTop ); - QLabel * copyright_content = new QLabel( copyright ); + auto copyright_content = new QLabel(copyright); copyright_content->setText( manager->getCopyright( _key ) ); copyright_content->setWordWrap( true ); copyrightLayout->addWidget( copyright_label ); copyrightLayout->addWidget( copyright_content, 1 ); - QLabel * requiresRealTime = new QLabel( description ); + auto requiresRealTime = new QLabel(description); requiresRealTime->setText( QWidget::tr( "Requires Real Time: " ) + ( manager->hasRealTimeDependency( _key ) ? QWidget::tr( "Yes" ) : QWidget::tr( "No" ) ) ); layout->addWidget( requiresRealTime ); - QLabel * realTimeCapable = new QLabel( description ); + auto realTimeCapable = new QLabel(description); realTimeCapable->setText( QWidget::tr( "Real Time Capable: " ) + ( manager->isRealTimeCapable( _key ) ? QWidget::tr( "Yes" ) : QWidget::tr( "No" ) ) ); layout->addWidget( realTimeCapable ); - QLabel * inplaceBroken = new QLabel( description ); + auto inplaceBroken = new QLabel(description); inplaceBroken->setText( QWidget::tr( "In Place Broken: " ) + ( manager->isInplaceBroken( _key ) ? QWidget::tr( "Yes" ) : QWidget::tr( "No" ) ) ); layout->addWidget( inplaceBroken ); - QLabel * channelsIn = new QLabel( description ); + auto channelsIn = new QLabel(description); channelsIn->setText( QWidget::tr( "Channels In: " ) + QString::number( manager->getDescription( _key )->inputChannels ) ); layout->addWidget( channelsIn ); - QLabel * channelsOut = new QLabel( description ); + auto channelsOut = new QLabel(description); channelsOut->setText( QWidget::tr( "Channels Out: " ) + QString::number( manager->getDescription( _key )->outputChannels ) ); layout->addWidget( channelsOut ); @@ -215,6 +209,4 @@ void LadspaDescription::onDoubleClicked( QListWidgetItem * _item ) } - - - +} // namespace lmms::gui diff --git a/plugins/LadspaBrowser/LadspaDescription.h b/plugins/LadspaBrowser/LadspaDescription.h index 01495663a..14fcf7d62 100644 --- a/plugins/LadspaBrowser/LadspaDescription.h +++ b/plugins/LadspaBrowser/LadspaDescription.h @@ -35,17 +35,20 @@ class QListWidgetItem; class QScrollArea; +namespace lmms::gui +{ + class LadspaDescription : public QWidget { Q_OBJECT public: LadspaDescription( QWidget * _parent, LadspaPluginType _type ); - virtual ~LadspaDescription(); + ~LadspaDescription() override = default; signals: - void doubleClicked( const ladspa_key_t & ); + void doubleClicked( const ::lmms::ladspa_key_t & ); private: @@ -64,6 +67,6 @@ private slots: } ; - +} // namespace lmms::gui #endif diff --git a/plugins/LadspaBrowser/LadspaPortDialog.cpp b/plugins/LadspaBrowser/LadspaPortDialog.cpp index 20f25ece2..3c0dbabd5 100644 --- a/plugins/LadspaBrowser/LadspaPortDialog.cpp +++ b/plugins/LadspaBrowser/LadspaPortDialog.cpp @@ -33,6 +33,9 @@ #include "Engine.h" #include "Ladspa2LMMS.h" +namespace lmms::gui +{ + LadspaPortDialog::LadspaPortDialog( const ladspa_key_t & _key ) { @@ -42,13 +45,13 @@ LadspaPortDialog::LadspaPortDialog( const ladspa_key_t & _key ) setWindowTitle( tr( "Ports" ) ); setModal( true ); - QVBoxLayout * vlayout = new QVBoxLayout( this ); + auto vlayout = new QVBoxLayout(this); vlayout->setSpacing( 0 ); vlayout->setMargin( 0 ); int pc = manager->getPortCount( _key ); - QTableWidget * settings = new QTableWidget( pc, 7, this ); + auto settings = new QTableWidget(pc, 7, this); QStringList ports; ports.append( tr( "Name" ) ); @@ -64,7 +67,7 @@ LadspaPortDialog::LadspaPortDialog( const ladspa_key_t & _key ) { for( int col = 0; col < 7; ++col ) { - QTableWidgetItem * item = new QTableWidgetItem; + auto item = new QTableWidgetItem; item->setFlags(QFlag(0)); settings->setItem( row, col, item ); } @@ -165,11 +168,4 @@ LadspaPortDialog::LadspaPortDialog( const ladspa_key_t & _key ) -LadspaPortDialog::~LadspaPortDialog() -{ -} - - - - - +} // namespace lmms::gui \ No newline at end of file diff --git a/plugins/LadspaBrowser/LadspaPortDialog.h b/plugins/LadspaBrowser/LadspaPortDialog.h index 3b66e7ec6..946531de8 100644 --- a/plugins/LadspaBrowser/LadspaPortDialog.h +++ b/plugins/LadspaBrowser/LadspaPortDialog.h @@ -31,7 +31,8 @@ #include "LadspaManager.h" - +namespace lmms::gui +{ class LadspaPortDialog : public QDialog @@ -39,11 +40,11 @@ class LadspaPortDialog : public QDialog Q_OBJECT public: LadspaPortDialog( const ladspa_key_t & _key ); - virtual ~LadspaPortDialog(); + ~LadspaPortDialog() override = default; }; - +} // namespace lmms::gui #endif diff --git a/plugins/LadspaEffect/LadspaControlDialog.cpp b/plugins/LadspaEffect/LadspaControlDialog.cpp index a5be83d80..571dbd454 100644 --- a/plugins/LadspaEffect/LadspaControlDialog.cpp +++ b/plugins/LadspaEffect/LadspaControlDialog.cpp @@ -37,6 +37,8 @@ #include "LadspaControlView.h" #include "LedCheckBox.h" +namespace lmms::gui +{ LadspaControlDialog::LadspaControlDialog( LadspaControls * _ctl ) : @@ -44,7 +46,7 @@ LadspaControlDialog::LadspaControlDialog( LadspaControls * _ctl ) : m_effectLayout( nullptr ), m_stereoLink( nullptr ) { - QVBoxLayout * mainLay = new QVBoxLayout( this ); + auto mainLay = new QVBoxLayout(this); m_effectLayout = new QHBoxLayout(); mainLay->addLayout( m_effectLayout ); @@ -54,7 +56,7 @@ LadspaControlDialog::LadspaControlDialog( LadspaControls * _ctl ) : if( _ctl->m_processors > 1 ) { mainLay->addSpacing( 3 ); - QHBoxLayout * center = new QHBoxLayout(); + auto center = new QHBoxLayout(); mainLay->addLayout( center ); m_stereoLink = new LedCheckBox( tr( "Link Channels" ), this ); m_stereoLink->setModel( &_ctl->m_stereoLinkModel ); @@ -65,20 +67,12 @@ LadspaControlDialog::LadspaControlDialog( LadspaControls * _ctl ) : -LadspaControlDialog::~LadspaControlDialog() -{ -} - - - - void LadspaControlDialog::updateEffectView( LadspaControls * _ctl ) { - QList list = findChildren(); - for( QList::iterator it = list.begin(); it != list.end(); - ++it ) + QList groupBoxes = findChildren(); + for (const auto& groupBox : groupBoxes) { - delete *it; + delete groupBox; } m_effectControls = _ctl; @@ -106,16 +100,15 @@ void LadspaControlDialog::updateEffectView( LadspaControls * _ctl ) grouper = new QGroupBox( this ); } - QGridLayout * gl = new QGridLayout( grouper ); + auto gl = new QGridLayout(grouper); grouper->setLayout( gl ); grouper->setAlignment( Qt::Vertical ); - for( control_list_t::iterator it = controls.begin(); - it != controls.end(); ++it ) + for (const auto& control : controls) { - if( (*it)->port()->proc == proc ) + if (control->port()->proc == proc) { - buffer_data_t this_port = (*it)->port()->data_type; + buffer_data_t this_port = control->port()->data_type; if( last_port != NONE && ( this_port == TOGGLED || this_port == ENUM ) && ( last_port != TOGGLED && last_port != ENUM ) ) @@ -123,13 +116,13 @@ void LadspaControlDialog::updateEffectView( LadspaControls * _ctl ) ++row; col = 0; } - gl->addWidget( new LadspaControlView( grouper, *it ), row, col ); + gl->addWidget(new LadspaControlView(grouper, control), row, col); if( ++col == cols ) { ++row; col = 0; } - last_port = (*it)->port()->data_type; + last_port = control->port()->data_type; } } @@ -141,11 +134,10 @@ void LadspaControlDialog::updateEffectView( LadspaControls * _ctl ) m_stereoLink->setModel( &_ctl->m_stereoLinkModel ); } - connect( _ctl, SIGNAL( effectModelChanged( LadspaControls * ) ), - this, SLOT( updateEffectView( LadspaControls * ) ), + connect( _ctl, SIGNAL( effectModelChanged( lmms::LadspaControls * ) ), + this, SLOT( updateEffectView( lmms::LadspaControls * ) ), Qt::DirectConnection ); } - - +} // namespace lmms::gui diff --git a/plugins/LadspaEffect/LadspaControlDialog.h b/plugins/LadspaEffect/LadspaControlDialog.h index 86468112d..8b7adb3aa 100644 --- a/plugins/LadspaEffect/LadspaControlDialog.h +++ b/plugins/LadspaEffect/LadspaControlDialog.h @@ -31,7 +31,17 @@ class QHBoxLayout; + +namespace lmms +{ + class LadspaControls; + + +namespace gui +{ + + class LedCheckBox; @@ -40,11 +50,11 @@ class LadspaControlDialog : public EffectControlDialog Q_OBJECT public: LadspaControlDialog( LadspaControls * _ctl ); - ~LadspaControlDialog(); + ~LadspaControlDialog() override = default; private slots: - void updateEffectView( LadspaControls * _ctl ); + void updateEffectView( lmms::LadspaControls * _ctl ); private: @@ -53,4 +63,9 @@ private: } ; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/LadspaEffect/LadspaControls.cpp b/plugins/LadspaEffect/LadspaControls.cpp index 9399fce03..009e21bf7 100644 --- a/plugins/LadspaEffect/LadspaControls.cpp +++ b/plugins/LadspaEffect/LadspaControls.cpp @@ -28,6 +28,9 @@ #include "LadspaControl.h" #include "LadspaEffect.h" +namespace lmms +{ + LadspaControls::LadspaControls( LadspaEffect * _eff ) : EffectControls( _eff ), @@ -50,20 +53,19 @@ LadspaControls::LadspaControls( LadspaEffect * _eff ) : const bool linked_control = ( m_processors > 1 && proc == 0 ); - for( multi_proc_t::Iterator it = controls.begin(); it != controls.end(); it++ ) + for (const auto& control : controls) { - if( (*it)->proc == proc ) + if (control->proc == proc) { - (*it)->control = new LadspaControl( this, *it, - linked_control ); + control->control = new LadspaControl(this, control, linked_control); - p.append( (*it)->control ); + p.append(control->control); - if( linked_control ) + if (linked_control) { - connect( (*it)->control, SIGNAL( linkChanged( int, bool ) ), - this, SLOT( linkPort( int, bool ) ), - Qt::DirectConnection ); + connect(control->control, SIGNAL(linkChanged(int, bool)), + this, SLOT(linkPort(int, bool)), + Qt::DirectConnection); } } } @@ -74,12 +76,11 @@ LadspaControls::LadspaControls( LadspaEffect * _eff ) : // now link all controls if( m_processors > 1 ) { - for( multi_proc_t::Iterator it = controls.begin(); - it != controls.end(); it++ ) + for (const auto& control : controls) { - if( (*it)->proc == 0 ) + if (control->proc == 0) { - linkPort( ( *it )->control_id, true ); + linkPort(control->control_id, true); } } } @@ -109,12 +110,10 @@ void LadspaControls::saveSettings( QDomDocument & _doc, QDomElement & _this ) multi_proc_t controls = m_effect->getPortControls(); _this.setAttribute( "ports", controls.count() ); - for( multi_proc_t::Iterator it = controls.begin(); - it != controls.end(); it++ ) + for (const auto& control : controls) { - QString n = "port" + QString::number( (*it)->proc ) + - QString::number( (*it)->port_id ); - (*it)->control->saveSettings( _doc, _this, n ); + QString n = "port" + QString::number(control->proc) + QString::number(control->port_id); + control->control->saveSettings(_doc, _this, n); } } @@ -129,12 +128,10 @@ void LadspaControls::loadSettings( const QDomElement & _this ) } multi_proc_t controls = m_effect->getPortControls(); - for( multi_proc_t::Iterator it = controls.begin(); - it != controls.end(); it++ ) + for (const auto& control : controls) { - QString n = "port" + QString::number( (*it)->proc ) + - QString::number( (*it)->port_id ); - (*it)->control->loadSettings( _this, n ); + QString n = "port" + QString::number(control->proc) + QString::number(control->port_id); + control->control->loadSettings(_this, n); } } @@ -190,5 +187,4 @@ void LadspaControls::updateLinkStatesFromGlobal() } - - +} // namespace lmms diff --git a/plugins/LadspaEffect/LadspaControls.h b/plugins/LadspaEffect/LadspaControls.h index 0a157009c..2bef0c856 100644 --- a/plugins/LadspaEffect/LadspaControls.h +++ b/plugins/LadspaEffect/LadspaControls.h @@ -28,9 +28,12 @@ #include "EffectControls.h" #include "LadspaControlDialog.h" +namespace lmms +{ + class LadspaControl; -typedef QVector control_list_t; +using control_list_t = QVector; class LadspaEffect; @@ -40,23 +43,23 @@ class LadspaControls : public EffectControls Q_OBJECT public: LadspaControls( LadspaEffect * _eff ); - virtual ~LadspaControls(); + ~LadspaControls() override; - inline int controlCount() + inline int controlCount() override { return m_controlCount; } - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); - inline virtual QString nodeName() const + void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; + inline QString nodeName() const override { return "ladspacontrols"; } - virtual EffectControlDialog * createView() + gui::EffectControlDialog* createView() override { - return new LadspaControlDialog( this ); + return new gui::LadspaControlDialog( this ); } @@ -75,13 +78,16 @@ private: QVector m_controls; - friend class LadspaControlDialog; + friend class gui::LadspaControlDialog; friend class LadspaEffect; signals: - void effectModelChanged( LadspaControls * ); + void effectModelChanged( lmms::LadspaControls * ); } ; + +} // namespace lmms + #endif diff --git a/plugins/LadspaEffect/LadspaEffect.cpp b/plugins/LadspaEffect/LadspaEffect.cpp index b2e119af7..e5d1c5d69 100644 --- a/plugins/LadspaEffect/LadspaEffect.cpp +++ b/plugins/LadspaEffect/LadspaEffect.cpp @@ -44,12 +44,16 @@ #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT ladspaeffect_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "LADSPA", QT_TRANSLATE_NOOP( "PluginBrowser", "plugin for using arbitrary LADSPA-effects " @@ -126,7 +130,7 @@ void LadspaEffect::changeSampleRate() -bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, +bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames ) { m_pluginMutex.lock(); @@ -150,7 +154,7 @@ bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, } // Copy the LMMS audio buffer to the LADSPA input buffer and initialize - // the control ports. + // the control ports. ch_cnt_t channel = 0; for( ch_cnt_t proc = 0; proc < processorCount(); ++proc ) { @@ -160,10 +164,10 @@ bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, switch( pp->rate ) { case CHANNEL_IN: - for( fpp_t frame = 0; + for( fpp_t frame = 0; frame < frames; ++frame ) { - pp->buffer[frame] = + pp->buffer[frame] = _buf[frame][channel]; } ++channel; @@ -177,15 +181,15 @@ bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, } else { - pp->value = static_cast( + pp->value = static_cast( pp->control->value() / pp->scale ); // This only supports control rate ports, so the audio rates are // treated as though they were control rate by setting the // port buffer to all the same value. - for( fpp_t frame = 0; + for( fpp_t frame = 0; frame < frames; ++frame ) { - pp->buffer[frame] = + pp->buffer[frame] = pp->value; } } @@ -196,9 +200,9 @@ bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, { break; } - pp->value = static_cast( + pp->value = static_cast( pp->control->value() / pp->scale ); - pp->buffer[0] = + pp->buffer[0] = pp->value; break; case CHANNEL_OUT: @@ -235,7 +239,7 @@ bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, case CONTROL_RATE_INPUT: break; case CHANNEL_OUT: - for( fpp_t frame = 0; + for( fpp_t frame = 0; frame < frames; ++frame ) { _buf[frame][channel] = d * _buf[frame][channel] + w * pp->buffer[frame]; @@ -299,7 +303,7 @@ void LadspaEffect::pluginInstantiation() int inputch = 0; int outputch = 0; - LADSPA_Data * inbuf [2]; + std::array inbuf; inbuf[0] = nullptr; inbuf[1] = nullptr; for( ch_cnt_t proc = 0; proc < processorCount(); proc++ ) @@ -307,7 +311,7 @@ void LadspaEffect::pluginInstantiation() multi_proc_t ports; for( int port = 0; port < m_portCount; port++ ) { - port_desc_t * p = new PortDescription; + auto p = new port_desc_t; p->name = manager->getPortName( m_key, port ); p->proc = proc; @@ -459,9 +463,9 @@ void LadspaEffect::pluginInstantiation() ports.append( p ); - // For convenience, keep a separate list of the ports that are used + // For convenience, keep a separate list of the ports that are used // to control the processors. - if( p->rate == AUDIO_RATE_INPUT || + if( p->rate == AUDIO_RATE_INPUT || p->rate == CONTROL_RATE_INPUT ) { p->control_id = m_portControls.count(); @@ -475,7 +479,7 @@ void LadspaEffect::pluginInstantiation() m_descriptor = manager->getDescriptor( m_key ); if( m_descriptor == nullptr ) { - QMessageBox::warning( 0, "Effect", + QMessageBox::warning( 0, "Effect", "Can't get LADSPA descriptor function: " + m_key.second, QMessageBox::Ok, QMessageBox::NoButton ); setOkay( false ); @@ -514,8 +518,8 @@ void LadspaEffect::pluginInstantiation() port, pp->buffer ) ) { - QMessageBox::warning( 0, "Effect", - "Failed to connect port: " + m_key.second, + QMessageBox::warning( 0, "Effect", + "Failed to connect port: " + m_key.second, QMessageBox::Ok, QMessageBox::NoButton ); setDontRun( true ); return; @@ -604,5 +608,4 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model * _parent, void * _data ) } - - +} // namespace lmms diff --git a/plugins/LadspaEffect/LadspaEffect.h b/plugins/LadspaEffect/LadspaEffect.h index a46099f93..8ad4f1411 100644 --- a/plugins/LadspaEffect/LadspaEffect.h +++ b/plugins/LadspaEffect/LadspaEffect.h @@ -33,9 +33,11 @@ #include "LadspaControls.h" #include "LadspaManager.h" +namespace lmms +{ -typedef struct PortDescription port_desc_t; -typedef QVector multi_proc_t; +struct port_desc_t; +using multi_proc_t = QVector; class LadspaEffect : public Effect { @@ -43,14 +45,14 @@ class LadspaEffect : public Effect public: LadspaEffect( Model * _parent, const Descriptor::SubPluginFeatures::Key * _key ); - virtual ~LadspaEffect(); + ~LadspaEffect() override; - virtual bool processAudioBuffer( sampleFrame * _buf, - const fpp_t _frames ); + bool processAudioBuffer( sampleFrame * _buf, + const fpp_t _frames ) override; void setControl( int _control, LADSPA_Data _data ); - virtual EffectControls * controls() + EffectControls * controls() override { return m_controls; } @@ -88,4 +90,7 @@ private: } ; + +} // namespace lmms + #endif diff --git a/plugins/LadspaEffect/LadspaSubPluginFeatures.cpp b/plugins/LadspaEffect/LadspaSubPluginFeatures.cpp index dfd302d6c..8ab50858a 100644 --- a/plugins/LadspaEffect/LadspaSubPluginFeatures.cpp +++ b/plugins/LadspaEffect/LadspaSubPluginFeatures.cpp @@ -35,6 +35,9 @@ #include "Ladspa2LMMS.h" #include "LadspaBase.h" +namespace lmms +{ + LadspaSubPluginFeatures::LadspaSubPluginFeatures( Plugin::PluginTypes _type ) : SubPluginFeatures( _type ) @@ -60,65 +63,65 @@ void LadspaSubPluginFeatures::fillDescriptionWidget( QWidget * _parent, const ladspa_key_t & lkey = subPluginKeyToLadspaKey( _key ); Ladspa2LMMS * lm = Engine::getLADSPAManager(); - QLabel * label = new QLabel( _parent ); + auto label = new QLabel(_parent); label->setText( QWidget::tr( "Name: " ) + lm->getName( lkey ) ); - QLabel* fileInfo = new QLabel( _parent ); + auto fileInfo = new QLabel(_parent); fileInfo->setText( QWidget::tr( "File: %1" ).arg( lkey.first ) ); - QWidget * maker = new QWidget( _parent ); - QHBoxLayout * l = new QHBoxLayout( maker ); + auto maker = new QWidget(_parent); + auto l = new QHBoxLayout(maker); l->setMargin( 0 ); l->setSpacing( 0 ); - QLabel * maker_label = new QLabel( maker ); + auto maker_label = new QLabel(maker); maker_label->setText( QWidget::tr( "Maker: " ) ); maker_label->setAlignment( Qt::AlignTop ); - QLabel * maker_content = new QLabel( maker ); + auto maker_content = new QLabel(maker); maker_content->setText( lm->getMaker( lkey ) ); maker_content->setWordWrap( true ); l->addWidget( maker_label ); l->addWidget( maker_content, 1 ); - QWidget * copyright = new QWidget( _parent ); + auto copyright = new QWidget(_parent); l = new QHBoxLayout( copyright ); l->setMargin( 0 ); l->setSpacing( 0 ); copyright->setMinimumWidth( _parent->minimumWidth() ); - QLabel * copyright_label = new QLabel( copyright ); + auto copyright_label = new QLabel(copyright); copyright_label->setText( QWidget::tr( "Copyright: " ) ); copyright_label->setAlignment( Qt::AlignTop ); - QLabel * copyright_content = new QLabel( copyright ); + auto copyright_content = new QLabel(copyright); copyright_content->setText( lm->getCopyright( lkey ) ); copyright_content->setWordWrap( true ); l->addWidget( copyright_label ); l->addWidget( copyright_content, 1 ); - QLabel * requiresRealTime = new QLabel( _parent ); + auto requiresRealTime = new QLabel(_parent); requiresRealTime->setText( QWidget::tr( "Requires Real Time: " ) + ( lm->hasRealTimeDependency( lkey ) ? QWidget::tr( "Yes" ) : QWidget::tr( "No" ) ) ); - QLabel * realTimeCapable = new QLabel( _parent ); + auto realTimeCapable = new QLabel(_parent); realTimeCapable->setText( QWidget::tr( "Real Time Capable: " ) + ( lm->isRealTimeCapable( lkey ) ? QWidget::tr( "Yes" ) : QWidget::tr( "No" ) ) ); - QLabel * inplaceBroken = new QLabel( _parent ); + auto inplaceBroken = new QLabel(_parent); inplaceBroken->setText( QWidget::tr( "In Place Broken: " ) + ( lm->isInplaceBroken( lkey ) ? QWidget::tr( "Yes" ) : QWidget::tr( "No" ) ) ); - - QLabel * channelsIn = new QLabel( _parent ); + + auto channelsIn = new QLabel(_parent); channelsIn->setText( QWidget::tr( "Channels In: " ) + QString::number( lm->getDescription( lkey )->inputChannels ) ); - QLabel * channelsOut = new QLabel( _parent ); + auto channelsOut = new QLabel(_parent); channelsOut->setText( QWidget::tr( "Channels Out: " ) + QString::number( lm->getDescription( lkey )->outputChannels ) ); } @@ -178,3 +181,5 @@ ladspa_key_t LadspaSubPluginFeatures::subPluginKeyToLadspaKey( , _key->attributes["plugin"] ) ); } + +} // namespace lmms diff --git a/plugins/LadspaEffect/LadspaSubPluginFeatures.h b/plugins/LadspaEffect/LadspaSubPluginFeatures.h index 3f47734f9..c65dce9fe 100644 --- a/plugins/LadspaEffect/LadspaSubPluginFeatures.h +++ b/plugins/LadspaEffect/LadspaSubPluginFeatures.h @@ -31,6 +31,9 @@ #include "LadspaManager.h" #include "Plugin.h" +namespace lmms +{ + class LadspaSubPluginFeatures : public Plugin::Descriptor::SubPluginFeatures { @@ -41,12 +44,15 @@ public: void fillDescriptionWidget( QWidget * _parent, const Key * _key ) const override; - virtual void listSubPluginKeys( const Plugin::Descriptor * _desc, + void listSubPluginKeys( const Plugin::Descriptor * _desc, KeyList & _kl ) const override; static ladspa_key_t subPluginKeyToLadspaKey( const Key * _key ); -} ; +}; + + +} // namespace lmms #endif diff --git a/plugins/LadspaEffect/calf/CMakeLists.txt b/plugins/LadspaEffect/calf/CMakeLists.txt index f5fb632f6..90f506417 100644 --- a/plugins/LadspaEffect/calf/CMakeLists.txt +++ b/plugins/LadspaEffect/calf/CMakeLists.txt @@ -40,10 +40,15 @@ IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") ENDIF() SET_TARGET_PROPERTIES(veal PROPERTIES COMPILE_FLAGS "-fexceptions -O2 -finline-functions ${INLINE_FLAGS}") -# Don't strip if "Debug" or "RelWithDebInfo" -IF(LMMS_BUILD_WIN32 AND NOT CMAKE_BUILD_TYPE MATCHES "Deb") - ADD_CUSTOM_COMMAND(TARGET veal POST_BUILD COMMAND "${STRIP}" "$") -ENDIF() +if(LMMS_BUILD_WIN32) + add_custom_command( + TARGET veal + POST_BUILD + COMMAND "${STRIP_COMMAND}" "$" + VERBATIM + COMMAND_EXPAND_LISTS + ) +endif() IF(NOT LMMS_BUILD_APPLE AND NOT LMMS_BUILD_OPENBSD) SET_TARGET_PROPERTIES(veal PROPERTIES LINK_FLAGS "${LINK_FLAGS} -shared -Wl,-no-undefined") ENDIF() diff --git a/plugins/LadspaEffect/caps/Amp.cc b/plugins/LadspaEffect/caps/Amp.cc index 8bf49fd53..74bde2b75 100644 --- a/plugins/LadspaEffect/caps/Amp.cc +++ b/plugins/LadspaEffect/caps/Amp.cc @@ -388,9 +388,7 @@ AmpV::one_cycle (int frames) v = v * v * .06 + .46; a = filter[0].process (a + normal); - if (0) - a = filter[2].process (a); - + a = g * (a + supply * .001); a = v * tube.transfer_clip (up.upsample (a)); @@ -399,8 +397,7 @@ AmpV::one_cycle (int frames) a = down.process (a); a = filter[1].process (a - normal); - if (1) - a = filter[2].process (a + normal); + a = filter[2].process (a + normal); { for (int o = 1; o < OVERSAMPLE; ++o) diff --git a/plugins/LadspaEffect/caps/CMakeLists.txt b/plugins/LadspaEffect/caps/CMakeLists.txt index 0eff4d5cd..bdcf3a96a 100644 --- a/plugins/LadspaEffect/caps/CMakeLists.txt +++ b/plugins/LadspaEffect/caps/CMakeLists.txt @@ -10,7 +10,13 @@ SET_TARGET_PROPERTIES(caps PROPERTIES PREFIX "") SET_TARGET_PROPERTIES(caps PROPERTIES COMPILE_FLAGS "-O2 -funroll-loops -Wno-write-strings") IF(LMMS_BUILD_WIN32) - ADD_CUSTOM_COMMAND(TARGET caps POST_BUILD COMMAND "${STRIP}" \"$\") + add_custom_command( + TARGET caps + POST_BUILD + COMMAND "${STRIP_COMMAND}" "$" + VERBATIM + COMMAND_EXPAND_LISTS + ) ENDIF(LMMS_BUILD_WIN32) IF(NOT LMMS_BUILD_APPLE AND NOT LMMS_BUILD_OPENBSD) SET_TARGET_PROPERTIES(caps PROPERTIES LINK_FLAGS "${LINK_FLAGS} -shared -Wl,-no-undefined") diff --git a/plugins/LadspaEffect/caps/dsp/Delay.h b/plugins/LadspaEffect/caps/dsp/Delay.h index ab18d894c..29b03fd78 100644 --- a/plugins/LadspaEffect/caps/dsp/Delay.h +++ b/plugins/LadspaEffect/caps/dsp/Delay.h @@ -154,9 +154,6 @@ class DelayTapA int n; fistp (f, n); /* read: n = (int) f; relies on FPTruncateMode */ f -= n; - if (0 && f < .5) - f += 1, - n -= 1; sample_t x = d[n]; f = (1 - f) / (1 + f); diff --git a/plugins/LadspaEffect/cmt/CMakeLists.txt b/plugins/LadspaEffect/cmt/CMakeLists.txt index 7aae5a683..ded7b8958 100644 --- a/plugins/LadspaEffect/cmt/CMakeLists.txt +++ b/plugins/LadspaEffect/cmt/CMakeLists.txt @@ -7,11 +7,19 @@ INSTALL(TARGETS cmt LIBRARY DESTINATION "${PLUGIN_DIR}/ladspa") SET_TARGET_PROPERTIES(cmt PROPERTIES PREFIX "") SET_TARGET_PROPERTIES(cmt PROPERTIES COMPILE_FLAGS "-Wall -O3 -fno-strict-aliasing") -IF(LMMS_BUILD_WIN32 AND NOT CMAKE_BUILD_TYPE MATCHES "Deb") - ADD_CUSTOM_COMMAND(TARGET cmt POST_BUILD COMMAND "${STRIP}" "$") -ELSE() - SET_TARGET_PROPERTIES(cmt PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -fPIC") -ENDIF() +if(LMMS_BUILD_WIN32) + add_custom_command( + TARGET cmt + POST_BUILD + COMMAND "${STRIP_COMMAND}" "$" + VERBATIM + COMMAND_EXPAND_LISTS + ) +endif() + +if(NOT LMMS_BUILD_WIN32) + set_target_properties(cmt PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -fPIC") +endif() IF(NOT LMMS_BUILD_APPLE AND NOT LMMS_BUILD_OPENBSD) SET_TARGET_PROPERTIES(cmt PROPERTIES LINK_FLAGS "${LINK_FLAGS} -shared -Wl,-no-undefined") diff --git a/plugins/LadspaEffect/swh/CMakeLists.txt b/plugins/LadspaEffect/swh/CMakeLists.txt index 131e60373..aec01c22f 100644 --- a/plugins/LadspaEffect/swh/CMakeLists.txt +++ b/plugins/LadspaEffect/swh/CMakeLists.txt @@ -41,6 +41,16 @@ FOREACH(_item ${XML_SOURCES}) TARGET_LINK_LIBRARIES("${_plugin}" m) ENDIF() + if(LMMS_BUILD_WIN32) + add_custom_command( + TARGET "${_plugin}" + POST_BUILD + COMMAND "${STRIP_COMMAND}" "$" + VERBATIM + COMMAND_EXPAND_LISTS + ) + endif(LMMS_BUILD_WIN32) + SET_TARGET_PROPERTIES("${_plugin}" PROPERTIES PREFIX "") SET_TARGET_PROPERTIES("${_plugin}" PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS}") SET_TARGET_PROPERTIES("${_plugin}" PROPERTIES LINK_FLAGS "${LINK_FLAGS}") diff --git a/plugins/LadspaEffect/tap/CMakeLists.txt b/plugins/LadspaEffect/tap/CMakeLists.txt index e0740bd5e..c8d0a4eb8 100644 --- a/plugins/LadspaEffect/tap/CMakeLists.txt +++ b/plugins/LadspaEffect/tap/CMakeLists.txt @@ -11,10 +11,15 @@ FOREACH(_item ${PLUGIN_SOURCES}) ENDIF() INSTALL(TARGETS "${_plugin}" LIBRARY DESTINATION "${PLUGIN_DIR}/ladspa") SET_TARGET_PROPERTIES("${_plugin}" PROPERTIES PREFIX "") - # Don't strip if "Debug" or "RelWithDebInfo" - IF(LMMS_BUILD_WIN32 AND NOT CMAKE_BUILD_TYPE MATCHES "Deb") - ADD_CUSTOM_COMMAND(TARGET "${_plugin}" POST_BUILD COMMAND "${STRIP}" \"$\") - ENDIF() + if(LMMS_BUILD_WIN32) + add_custom_command( + TARGET "${_plugin}" + POST_BUILD + COMMAND "${STRIP_COMMAND}" "$" + VERBATIM + COMMAND_EXPAND_LISTS + ) + endif() IF(NOT MSVC) TARGET_LINK_LIBRARIES("${_plugin}" m) ENDIF() diff --git a/plugins/Lb302/Lb302.cpp b/plugins/Lb302/Lb302.cpp index 949f85510..140b84189 100644 --- a/plugins/Lb302/Lb302.cpp +++ b/plugins/Lb302/Lb302.cpp @@ -68,6 +68,9 @@ // Old config // +namespace lmms +{ + //#define engine::audioEngine()->processingSampleRate() 44100.0f const float sampleRateCutoff = 44100.0f; @@ -77,7 +80,7 @@ extern "C" Plugin::Descriptor PLUGIN_EXPORT lb302_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "LB302", QT_TRANSLATE_NOOP( "PluginBrowser", "Incomplete monophonic imitation TB-303" ), @@ -290,26 +293,26 @@ Lb302Synth::Lb302Synth( InstrumentTrack * _instrumentTrack ) : vca_mode(never_played) { - connect( Engine::audioEngine(), SIGNAL( sampleRateChanged( ) ), - this, SLOT ( filterChanged( ) ) ); + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), + this, SLOT ( filterChanged() ) ); - connect( &vcf_cut_knob, SIGNAL( dataChanged( ) ), - this, SLOT ( filterChanged( ) ) ); + connect( &vcf_cut_knob, SIGNAL( dataChanged() ), + this, SLOT ( filterChanged() ) ); - connect( &vcf_res_knob, SIGNAL( dataChanged( ) ), - this, SLOT ( filterChanged( ) ) ); + connect( &vcf_res_knob, SIGNAL( dataChanged() ), + this, SLOT ( filterChanged() ) ); - connect( &vcf_mod_knob, SIGNAL( dataChanged( ) ), - this, SLOT ( filterChanged( ) ) ); + connect( &vcf_mod_knob, SIGNAL( dataChanged() ), + this, SLOT ( filterChanged() ) ); - connect( &vcf_dec_knob, SIGNAL( dataChanged( ) ), - this, SLOT ( filterChanged( ) ) ); + connect( &vcf_dec_knob, SIGNAL( dataChanged() ), + this, SLOT ( filterChanged() ) ); - connect( &db24Toggle, SIGNAL( dataChanged( ) ), - this, SLOT ( db24Toggled( ) ) ); + connect( &db24Toggle, SIGNAL( dataChanged() ), + this, SLOT ( db24Toggled() ) ); - connect( &dist_knob, SIGNAL( dataChanged( ) ), - this, SLOT ( filterChanged( ))); + connect( &dist_knob, SIGNAL( dataChanged() ), + this, SLOT ( filterChanged())); // SYNTH @@ -346,15 +349,16 @@ Lb302Synth::Lb302Synth( InstrumentTrack * _instrumentTrack ) : filterChanged(); - InstrumentPlayHandle * iph = new InstrumentPlayHandle( this, _instrumentTrack ); + auto iph = new InstrumentPlayHandle(this, _instrumentTrack); Engine::audioEngine()->addPlayHandle( iph ); } Lb302Synth::~Lb302Synth() { - for (int i=0; imove( waveBtnX, waveBtnY ); sawWaveBtn->setActiveGraphic( embed::getIconPixmap( "saw_wave_active" ) ); @@ -872,8 +879,7 @@ Lb302SynthView::Lb302SynthView( Instrument * _instrument, QWidget * _parent ) : sawWaveBtn->setToolTip( tr( "Click here for a saw-wave." ) ); - PixmapButton * triangleWaveBtn = - new PixmapButton( this, tr( "Triangle wave" ) ); + auto triangleWaveBtn = new PixmapButton(this, tr("Triangle wave")); triangleWaveBtn->move( waveBtnX+(16*1), waveBtnY ); triangleWaveBtn->setActiveGraphic( embed::getIconPixmap( "triangle_wave_active" ) ); @@ -882,7 +888,7 @@ Lb302SynthView::Lb302SynthView( Instrument * _instrument, QWidget * _parent ) : triangleWaveBtn->setToolTip( tr( "Click here for a triangle-wave." ) ); - PixmapButton * sqrWaveBtn = new PixmapButton( this, tr( "Square wave" ) ); + auto sqrWaveBtn = new PixmapButton(this, tr("Square wave")); sqrWaveBtn->move( waveBtnX+(16*2), waveBtnY ); sqrWaveBtn->setActiveGraphic( embed::getIconPixmap( "square_wave_active" ) ); @@ -891,8 +897,7 @@ Lb302SynthView::Lb302SynthView( Instrument * _instrument, QWidget * _parent ) : sqrWaveBtn->setToolTip( tr( "Click here for a square-wave." ) ); - PixmapButton * roundSqrWaveBtn = - new PixmapButton( this, tr( "Rounded square wave" ) ); + auto roundSqrWaveBtn = new PixmapButton(this, tr("Rounded square wave")); roundSqrWaveBtn->move( waveBtnX+(16*3), waveBtnY ); roundSqrWaveBtn->setActiveGraphic( embed::getIconPixmap( "round_square_wave_active" ) ); @@ -901,8 +906,7 @@ Lb302SynthView::Lb302SynthView( Instrument * _instrument, QWidget * _parent ) : roundSqrWaveBtn->setToolTip( tr( "Click here for a square-wave with a rounded end." ) ); - PixmapButton * moogWaveBtn = - new PixmapButton( this, tr( "Moog wave" ) ); + auto moogWaveBtn = new PixmapButton(this, tr("Moog wave")); moogWaveBtn->move( waveBtnX+(16*4), waveBtnY ); moogWaveBtn->setActiveGraphic( embed::getIconPixmap( "moog_saw_wave_active" ) ); @@ -911,7 +915,7 @@ Lb302SynthView::Lb302SynthView( Instrument * _instrument, QWidget * _parent ) : moogWaveBtn->setToolTip( tr( "Click here for a moog-like wave." ) ); - PixmapButton * sinWaveBtn = new PixmapButton( this, tr( "Sine wave" ) ); + auto sinWaveBtn = new PixmapButton(this, tr("Sine wave")); sinWaveBtn->move( waveBtnX+(16*5), waveBtnY ); sinWaveBtn->setActiveGraphic( embed::getIconPixmap( "sin_wave_active" ) ); @@ -920,8 +924,7 @@ Lb302SynthView::Lb302SynthView( Instrument * _instrument, QWidget * _parent ) : sinWaveBtn->setToolTip( tr( "Click for a sine-wave." ) ); - PixmapButton * exponentialWaveBtn = - new PixmapButton( this, tr( "White noise wave" ) ); + auto exponentialWaveBtn = new PixmapButton(this, tr("White noise wave")); exponentialWaveBtn->move( waveBtnX+(16*6), waveBtnY ); exponentialWaveBtn->setActiveGraphic( embed::getIconPixmap( "exp_wave_active" ) ); @@ -930,9 +933,7 @@ Lb302SynthView::Lb302SynthView( Instrument * _instrument, QWidget * _parent ) : exponentialWaveBtn->setToolTip( tr( "Click here for an exponential wave." ) ); - - PixmapButton * whiteNoiseWaveBtn = - new PixmapButton( this, tr( "White noise wave" ) ); + auto whiteNoiseWaveBtn = new PixmapButton(this, tr("White noise wave")); whiteNoiseWaveBtn->move( waveBtnX+(16*7), waveBtnY ); whiteNoiseWaveBtn->setActiveGraphic( embed::getIconPixmap( "white_noise_wave_active" ) ); @@ -941,8 +942,7 @@ Lb302SynthView::Lb302SynthView( Instrument * _instrument, QWidget * _parent ) : whiteNoiseWaveBtn->setToolTip( tr( "Click here for white-noise." ) ); - PixmapButton * blSawWaveBtn = - new PixmapButton( this, tr( "Bandlimited saw wave" ) ); + auto blSawWaveBtn = new PixmapButton(this, tr("Bandlimited saw wave")); blSawWaveBtn->move( waveBtnX+(16*9)-8, waveBtnY ); blSawWaveBtn->setActiveGraphic( embed::getIconPixmap( "saw_wave_active" ) ); @@ -951,8 +951,7 @@ Lb302SynthView::Lb302SynthView( Instrument * _instrument, QWidget * _parent ) : blSawWaveBtn->setToolTip( tr( "Click here for bandlimited saw wave." ) ); - PixmapButton * blSquareWaveBtn = - new PixmapButton( this, tr( "Bandlimited square wave" ) ); + auto blSquareWaveBtn = new PixmapButton(this, tr("Bandlimited square wave")); blSquareWaveBtn->move( waveBtnX+(16*10)-8, waveBtnY ); blSquareWaveBtn->setActiveGraphic( embed::getIconPixmap( "square_wave_active" ) ); @@ -961,8 +960,7 @@ Lb302SynthView::Lb302SynthView( Instrument * _instrument, QWidget * _parent ) : blSquareWaveBtn->setToolTip( tr( "Click here for bandlimited square wave." ) ); - PixmapButton * blTriangleWaveBtn = - new PixmapButton( this, tr( "Bandlimited triangle wave" ) ); + auto blTriangleWaveBtn = new PixmapButton(this, tr("Bandlimited triangle wave")); blTriangleWaveBtn->move( waveBtnX+(16*11)-8, waveBtnY ); blTriangleWaveBtn->setActiveGraphic( embed::getIconPixmap( "triangle_wave_active" ) ); @@ -971,8 +969,7 @@ Lb302SynthView::Lb302SynthView( Instrument * _instrument, QWidget * _parent ) : blTriangleWaveBtn->setToolTip( tr( "Click here for bandlimited triangle wave." ) ); - PixmapButton * blMoogWaveBtn = - new PixmapButton( this, tr( "Bandlimited moog saw wave" ) ); + auto blMoogWaveBtn = new PixmapButton(this, tr("Bandlimited moog saw wave")); blMoogWaveBtn->move( waveBtnX+(16*12)-8, waveBtnY ); blMoogWaveBtn->setActiveGraphic( embed::getIconPixmap( "moog_saw_wave_active" ) ); @@ -1004,14 +1001,9 @@ Lb302SynthView::Lb302SynthView( Instrument * _instrument, QWidget * _parent ) : } -Lb302SynthView::~Lb302SynthView() -{ -} - - void Lb302SynthView::modelChanged() { - Lb302Synth * syn = castModel(); + auto syn = castModel(); m_vcfCutKnob->setModel( &syn->vcf_cut_knob ); m_vcfResKnob->setModel( &syn->vcf_res_knob ); @@ -1029,6 +1021,8 @@ void Lb302SynthView::modelChanged() } +} // namespace gui + extern "C" { @@ -1045,3 +1039,4 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model * m, void * ) } +} // namespace lmms diff --git a/plugins/Lb302/Lb302.h b/plugins/Lb302/Lb302.h index f7fa9ea84..3abece98f 100644 --- a/plugins/Lb302/Lb302.h +++ b/plugins/Lb302/Lb302.h @@ -29,8 +29,8 @@ */ -#ifndef LB302_H_ -#define LB302_H_ +#ifndef LB302_H +#define LB302_H #include "DspEffectLibrary.h" #include "Instrument.h" @@ -38,13 +38,23 @@ #include "NotePlayHandle.h" #include +namespace lmms +{ + + static const int NUM_FILTERS = 2; +class NotePlayHandle; + + +namespace gui +{ class automatableButtonGroup; class Knob; class Lb302SynthView; class LedCheckBox; -class NotePlayHandle; +} + class Lb302FilterKnobState { @@ -61,7 +71,7 @@ class Lb302Filter { public: Lb302Filter(Lb302FilterKnobState* p_fs); - virtual ~Lb302Filter() {}; + virtual ~Lb302Filter() = default; virtual void recalc(); virtual void envRecalc(); @@ -82,11 +92,11 @@ class Lb302FilterIIR2 : public Lb302Filter { public: Lb302FilterIIR2(Lb302FilterKnobState* p_fs); - virtual ~Lb302FilterIIR2(); + ~Lb302FilterIIR2() override; - virtual void recalc(); - virtual void envRecalc(); - virtual float process(const float& samp); + void recalc() override; + void envRecalc() override; + float process(const float& samp) override; protected: float vcf_d1, // d1 and d2 are added back into the sample with @@ -108,9 +118,9 @@ class Lb302Filter3Pole : public Lb302Filter Lb302Filter3Pole(Lb302FilterKnobState* p_fs); //virtual void recalc(); - virtual void envRecalc(); - virtual void recalc(); - virtual float process(const float& samp); + void envRecalc() override; + void recalc() override; + float process(const float& samp) override; protected: float kfcn, @@ -140,30 +150,30 @@ class Lb302Synth : public Instrument Q_OBJECT public: Lb302Synth( InstrumentTrack * _instrument_track ); - virtual ~Lb302Synth(); + ~Lb302Synth() override; - virtual void play( sampleFrame * _working_buffer ); - virtual void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ); - virtual void deleteNotePluginData( NotePlayHandle * _n ); + void play( sampleFrame * _working_buffer ) override; + void playNote( NotePlayHandle * _n, + sampleFrame * _working_buffer ) override; + void deleteNotePluginData( NotePlayHandle * _n ) override; - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); + void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; - virtual QString nodeName() const; + QString nodeName() const override; - virtual Flags flags() const + Flags flags() const override { return IsSingleStreamed; } - virtual f_cnt_t desiredReleaseFrames() const + f_cnt_t desiredReleaseFrames() const override { return 0; //4048; } - virtual PluginView * instantiateView( QWidget * _parent ); + gui::PluginView* instantiateView( QWidget * _parent ) override; private: void processNote( NotePlayHandle * n ); @@ -249,7 +259,7 @@ private: int process(sampleFrame *outbuf, const int size); - friend class Lb302SynthView; + friend class gui::Lb302SynthView; NotePlayHandle * m_playingNote; NotePlayHandleList m_notes; @@ -257,16 +267,20 @@ private: } ; +namespace gui +{ + + class Lb302SynthView : public InstrumentViewFixedSize { Q_OBJECT public: Lb302SynthView( Instrument * _instrument, QWidget * _parent ); - virtual ~Lb302SynthView(); + ~Lb302SynthView() override = default; private: - virtual void modelChanged(); + void modelChanged() override; Knob * m_vcfCutKnob; Knob * m_vcfResKnob; @@ -284,4 +298,9 @@ private: } ; -#endif + +} // namespace gui + +} // namespace lmms + +#endif // LB302_H diff --git a/plugins/Lv2Effect/Lv2Effect.cpp b/plugins/Lv2Effect/Lv2Effect.cpp index 3d6a114d1..1a25c718a 100644 --- a/plugins/Lv2Effect/Lv2Effect.cpp +++ b/plugins/Lv2Effect/Lv2Effect.cpp @@ -31,6 +31,8 @@ #include "plugin_export.h" +namespace lmms +{ extern "C" @@ -38,7 +40,7 @@ extern "C" Plugin::Descriptor PLUGIN_EXPORT lv2effect_plugin_descriptor = { - STRINGIFY(PLUGIN_NAME), + LMMS_STRINGIFY(PLUGIN_NAME), "LV2", QT_TRANSLATE_NOOP("PluginBrowser", "plugin for using arbitrary LV2-effects inside LMMS."), @@ -88,8 +90,8 @@ bool Lv2Effect::processAudioBuffer(sampleFrame *buf, const fpp_t frames) { buf[f][0] = d * buf[f][0] + w * m_tmpOutputSmps[f][0]; buf[f][1] = d * buf[f][1] + w * m_tmpOutputSmps[f][1]; - double l = static_cast(buf[f][0]); - double r = static_cast(buf[f][1]); + auto l = static_cast(buf[f][0]); + auto r = static_cast(buf[f][1]); outSum += l*l + r*r; } checkGate(outSum / frames); @@ -107,9 +109,12 @@ extern "C" PLUGIN_EXPORT Plugin *lmms_plugin_main(Model *_parent, void *_data) { using KeyType = Plugin::Descriptor::SubPluginFeatures::Key; - Lv2Effect* eff = new Lv2Effect(_parent, static_cast(_data)); + auto eff = new Lv2Effect(_parent, static_cast(_data)); if (!eff->isValid()) { delete eff; eff = nullptr; } return eff; } } + + +} // namespace lmms diff --git a/plugins/Lv2Effect/Lv2Effect.h b/plugins/Lv2Effect/Lv2Effect.h index b9e4e06b0..521a7df74 100644 --- a/plugins/Lv2Effect/Lv2Effect.h +++ b/plugins/Lv2Effect/Lv2Effect.h @@ -28,6 +28,10 @@ #include "Effect.h" #include "Lv2FxControls.h" +namespace lmms +{ + + class Lv2Effect : public Effect { Q_OBJECT @@ -51,4 +55,7 @@ private: std::vector m_tmpOutputSmps; }; -#endif // LMMS_HAVE_LV2 + +} // namespace lmms + +#endif diff --git a/plugins/Lv2Effect/Lv2FxControlDialog.cpp b/plugins/Lv2Effect/Lv2FxControlDialog.cpp index 267923561..d10c01cd4 100644 --- a/plugins/Lv2Effect/Lv2FxControlDialog.cpp +++ b/plugins/Lv2Effect/Lv2FxControlDialog.cpp @@ -28,6 +28,9 @@ #include "Lv2FxControls.h" +namespace lmms::gui +{ + Lv2FxControlDialog::Lv2FxControlDialog(Lv2FxControls *controls) : EffectControlDialog(controls), @@ -67,3 +70,4 @@ void Lv2FxControlDialog::modelChanged() } +} // namespace lmms::gui \ No newline at end of file diff --git a/plugins/Lv2Effect/Lv2FxControlDialog.h b/plugins/Lv2Effect/Lv2FxControlDialog.h index 3abdb300d..c749dc124 100644 --- a/plugins/Lv2Effect/Lv2FxControlDialog.h +++ b/plugins/Lv2Effect/Lv2FxControlDialog.h @@ -28,8 +28,13 @@ #include "EffectControlDialog.h" #include "Lv2ViewBase.h" +namespace lmms +{ + class Lv2FxControls; +namespace gui +{ class Lv2FxControlDialog : public EffectControlDialog, public Lv2ViewBase { @@ -44,4 +49,8 @@ private: }; +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/Lv2Effect/Lv2FxControls.cpp b/plugins/Lv2Effect/Lv2FxControls.cpp index 99d4162d8..a865151dd 100644 --- a/plugins/Lv2Effect/Lv2FxControls.cpp +++ b/plugins/Lv2Effect/Lv2FxControls.cpp @@ -30,7 +30,8 @@ #include "Lv2Effect.h" #include "Lv2FxControlDialog.h" - +namespace lmms +{ Lv2FxControls::Lv2FxControls(class Lv2Effect *effect, const QString& uri) : @@ -71,9 +72,9 @@ int Lv2FxControls::controlCount() -EffectControlDialog *Lv2FxControls::createView() +gui::EffectControlDialog *Lv2FxControls::createView() { - return new Lv2FxControlDialog(this); + return new gui::Lv2FxControlDialog(this); } @@ -101,3 +102,4 @@ void Lv2FxControls::setNameFromFile(const QString &name) } +} // namespace lmms diff --git a/plugins/Lv2Effect/Lv2FxControls.h b/plugins/Lv2Effect/Lv2FxControls.h index e5449a4f7..952e4db6c 100644 --- a/plugins/Lv2Effect/Lv2FxControls.h +++ b/plugins/Lv2Effect/Lv2FxControls.h @@ -28,8 +28,17 @@ #include "EffectControls.h" #include "Lv2ControlBase.h" +namespace lmms +{ + + class Lv2Effect; +namespace gui +{ +class Lv2FxControlDialog; +} + class Lv2FxControls : public EffectControls, public Lv2ControlBase { @@ -45,7 +54,7 @@ public: } int controlCount() override; - EffectControlDialog *createView() override; + gui::EffectControlDialog* createView() override; private slots: void changeControl(); @@ -54,8 +63,11 @@ private: DataFile::Types settingsType() override; void setNameFromFile(const QString &name) override; - friend class Lv2FxControlDialog; + friend class gui::Lv2FxControlDialog; friend class Lv2Effect; }; + +} // namespace lmms + #endif diff --git a/plugins/Lv2Instrument/Lv2Instrument.cpp b/plugins/Lv2Instrument/Lv2Instrument.cpp index b94e30aef..ae7e37119 100644 --- a/plugins/Lv2Instrument/Lv2Instrument.cpp +++ b/plugins/Lv2Instrument/Lv2Instrument.cpp @@ -40,6 +40,8 @@ #include "plugin_export.h" +namespace lmms +{ extern "C" @@ -47,7 +49,7 @@ extern "C" Plugin::Descriptor PLUGIN_EXPORT lv2instrument_plugin_descriptor = { - STRINGIFY(PLUGIN_NAME), + LMMS_STRINGIFY(PLUGIN_NAME), "LV2", QT_TRANSLATE_NOOP("PluginBrowser", "plugin for using arbitrary LV2 instruments inside LMMS."), @@ -76,17 +78,13 @@ Lv2Instrument::Lv2Instrument(InstrumentTrack *instrumentTrackArg, { if (Lv2ControlBase::isValid()) { -#ifdef LV2_INSTRUMENT_USE_MIDI - for (int i = 0; i < NumKeys; ++i) { m_runningNotes[i] = 0; } -#endif connect(instrumentTrack()->pitchRangeModel(), SIGNAL(dataChanged()), this, SLOT(updatePitchRange()), Qt::DirectConnection); connect(Engine::audioEngine(), &AudioEngine::sampleRateChanged, this, [this](){Lv2ControlBase::reloadPlugin();}); // now we need a play-handle which cares for calling play() - InstrumentPlayHandle *iph = - new InstrumentPlayHandle(this, instrumentTrackArg); + auto iph = new InstrumentPlayHandle(this, instrumentTrackArg); Engine::audioEngine()->addPlayHandle(iph); } } @@ -173,9 +171,9 @@ void Lv2Instrument::play(sampleFrame *buf) -PluginView *Lv2Instrument::instantiateView(QWidget *parent) +gui::PluginView* Lv2Instrument::instantiateView(QWidget *parent) { - return new Lv2InsView(this, parent); + return new gui::Lv2InsView(this, parent); } @@ -213,6 +211,9 @@ void Lv2Instrument::setNameFromFile(const QString &name) +namespace gui +{ + /* Lv2InsView @@ -246,7 +247,7 @@ void Lv2InsView::dragEnterEvent(QDragEnterEvent *_dee) // For mimeType() and MimeType enum class using namespace Clipboard; - void (QDragEnterEvent::*reaction)(void) = &QDragEnterEvent::ignore; + void (QDragEnterEvent::*reaction)() = &QDragEnterEvent::ignore; if (_dee->mimeData()->hasFormat( mimeType( MimeType::StringPair ))) { @@ -285,7 +286,7 @@ void Lv2InsView::modelChanged() } - +} // namespace gui extern "C" { @@ -294,11 +295,12 @@ extern "C" PLUGIN_EXPORT Plugin *lmms_plugin_main(Model *_parent, void *_data) { using KeyType = Plugin::Descriptor::SubPluginFeatures::Key; - Lv2Instrument* ins = new Lv2Instrument( - static_cast(_parent), - static_cast(_data )); + auto ins = new Lv2Instrument(static_cast(_parent), static_cast(_data)); if (!ins->isValid()) { delete ins; ins = nullptr; } return ins; } } + + +} // namespace lmms diff --git a/plugins/Lv2Instrument/Lv2Instrument.h b/plugins/Lv2Instrument/Lv2Instrument.h index bb4f797fa..e9a6cc2fd 100644 --- a/plugins/Lv2Instrument/Lv2Instrument.h +++ b/plugins/Lv2Instrument/Lv2Instrument.h @@ -37,6 +37,15 @@ // currently only MIDI works #define LV2_INSTRUMENT_USE_MIDI +namespace lmms +{ + +namespace gui +{ + +class Lv2InsView; + +} class Lv2Instrument : public Instrument, public Lv2ControlBase { @@ -81,7 +90,7 @@ public: return IsSingleStreamed; #endif } - PluginView *instantiateView(QWidget *parent) override; + gui::PluginView* instantiateView(QWidget *parent) override; private slots: void updatePitchRange(); @@ -92,16 +101,20 @@ private: void setNameFromFile(const QString &name) override; #ifdef LV2_INSTRUMENT_USE_MIDI - int m_runningNotes[NumKeys]; + std::array m_runningNotes = {}; #endif - friend class Lv2InsView; + friend class gui::Lv2InsView; }; +namespace gui +{ + + class Lv2InsView : public InstrumentView, public Lv2ViewBase { - Q_OBJECT +Q_OBJECT public: Lv2InsView(Lv2Instrument *_instrument, QWidget *_parent); @@ -114,4 +127,9 @@ private: }; +} // namespace gui + + +} // namespace lmms + #endif // LV2_INSTRUMENT_H diff --git a/plugins/MidiExport/MidiExport.cpp b/plugins/MidiExport/MidiExport.cpp index a150b424a..0d18d8ae1 100644 --- a/plugins/MidiExport/MidiExport.cpp +++ b/plugins/MidiExport/MidiExport.cpp @@ -5,7 +5,7 @@ * Copyright (c) 2017 Hyunjin Song * * This file is part of LMMS - https://lmms.io - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either @@ -35,12 +35,16 @@ #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT midiexport_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "MIDI Export", QT_TRANSLATE_NOOP( "PluginBrowser", "Filter for exporting MIDI-files from LMMS" ), @@ -63,12 +67,6 @@ MidiExport::MidiExport() : ExportFilter( &midiexport_plugin_descriptor) -MidiExport::~MidiExport() -{ -} - - - bool MidiExport::tryExport(const TrackContainer::TrackList &tracks, const TrackContainer::TrackList &patternStoreTracks, int tempo, int masterPitch, const QString &filename) @@ -83,7 +81,7 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks, int nTracks = 0; - uint8_t buffer[BUFFER_SIZE]; + auto buffer = std::array{}; uint32_t size; for (const Track* track : tracks) if (track->type() == Track::InstrumentTrack) nTracks++; @@ -91,8 +89,8 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks, // midi header MidiFile::MIDIHeader header(nTracks); - size = header.writeToBuffer(buffer); - midiout.writeRawData((char *)buffer, size); + size = header.writeToBuffer(buffer.data()); + midiout.writeRawData((char *)buffer.data(), size); std::vector>> plists; @@ -141,8 +139,8 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks, } processPatternNotes(midiClip, INT_MAX); writeMidiClipToTrack(mtrack, midiClip); - size = mtrack.writeToBuffer(buffer); - midiout.writeRawData((char *)buffer, size); + size = mtrack.writeToBuffer(buffer.data()); + midiout.writeRawData((char *)buffer.data(), size); } if (track->type() == Track::PatternTrack) @@ -159,7 +157,7 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks, QDomElement it = n.toElement(); int pos = it.attribute("pos", "0").toInt(); int len = it.attribute("len", "0").toInt(); - plist.push_back(std::pair(pos, pos+len)); + plist.emplace_back(pos, pos+len); } } std::sort(plist.begin(), plist.end()); @@ -218,27 +216,28 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks, int len = n.toElement().attribute("steps", "1").toInt() * 12; // for each pattern clip of the current pattern track (in song editor) - for (auto it = plist.begin(); it != plist.end(); ++it) + for (const auto& position : plist) { - while (!st.empty() && st.back().second <= it->first) + const auto& [start, end] = position; + while (!st.empty() && st.back().second <= start) { writePatternClip(midiClip, nv, len, st.back().first, pos, st.back().second); pos = st.back().second; st.pop_back(); } - if (!st.empty() && st.back().second <= it->second) + if (!st.empty() && st.back().second <= end) { - writePatternClip(midiClip, nv, len, st.back().first, pos, it->first); - pos = it->first; - while (!st.empty() && st.back().second <= it->second) + writePatternClip(midiClip, nv, len, st.back().first, pos, start); + pos = start; + while (!st.empty() && st.back().second <= end) { st.pop_back(); } } - st.push_back(*it); - pos = it->first; + st.push_back(position); + pos = start; } while (!st.empty()) @@ -255,8 +254,8 @@ bool MidiExport::tryExport(const TrackContainer::TrackList &tracks, ++itr; } } - size = mtrack.writeToBuffer(buffer); - midiout.writeRawData((char *)buffer, size); + size = mtrack.writeToBuffer(buffer.data()); + midiout.writeRawData((char *)buffer.data(), size); } return true; @@ -288,9 +287,9 @@ void MidiExport::writeMidiClip(MidiNoteVector &midiClip, const QDomNode& n, void MidiExport::writeMidiClipToTrack(MTrack &mtrack, MidiNoteVector &nv) { - for (auto it = nv.begin(); it != nv.end(); ++it) + for (const auto& note : nv) { - mtrack.addNote(it->pitch, it->volume, it->time / 48.0, it->duration / 48.0); + mtrack.addNote(note.pitch, note.volume, note.time / 48.0, note.duration / 48.0); } } @@ -303,16 +302,15 @@ void MidiExport::writePatternClip(MidiNoteVector& src, MidiNoteVector& dst, start -= base; end -= base; std::sort(src.begin(), src.end()); - for (auto it = src.begin(); it != src.end(); ++it) + for (const auto& srcNote : src) { - for (int time = it->time + ceil((start - it->time) / len) - * len; time < end; time += len) + for (int time = srcNote.time + ceil((start - srcNote.time) / len) * len; time < end; time += len) { MidiNote note; - note.duration = it->duration; - note.pitch = it->pitch; + note.duration = srcNote.duration; + note.pitch = srcNote.pitch; note.time = base + time; - note.volume = it->volume; + note.volume = srcNote.volume; dst.push_back(note); } } @@ -359,3 +357,5 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *, void * _data ) } + +} // namespace lmms diff --git a/plugins/MidiExport/MidiExport.h b/plugins/MidiExport/MidiExport.h index fd73442b5..1e355e45a 100644 --- a/plugins/MidiExport/MidiExport.h +++ b/plugins/MidiExport/MidiExport.h @@ -33,9 +33,12 @@ class QDomNode; +namespace lmms +{ + const int BUFFER_SIZE = 50*1024; -typedef MidiFile::MIDITrack MTrack; +using MTrack = MidiFile::MIDITrack; struct MidiNote { @@ -50,26 +53,24 @@ struct MidiNote } } ; -typedef std::vector MidiNoteVector; -typedef std::vector::iterator MidiNoteIterator; - - +using MidiNoteVector = std::vector; +using MidiNoteIterator = std::vector::iterator; class MidiExport: public ExportFilter { // Q_OBJECT public: MidiExport(); - ~MidiExport(); + ~MidiExport() override = default; - virtual PluginView *instantiateView(QWidget *) + gui::PluginView* instantiateView(QWidget *) override { return nullptr; } - virtual bool tryExport(const TrackContainer::TrackList &tracks, + bool tryExport(const TrackContainer::TrackList &tracks, const TrackContainer::TrackList &patternTracks, - int tempo, int masterPitch, const QString &filename); + int tempo, int masterPitch, const QString &filename) override; private: void writeMidiClip(MidiNoteVector &midiClip, const QDomNode& n, @@ -85,4 +86,6 @@ private: } ; +} // namespace lmms + #endif diff --git a/plugins/MidiImport/MidiImport.cpp b/plugins/MidiImport/MidiImport.cpp index a57a425a2..6a0314966 100644 --- a/plugins/MidiImport/MidiImport.cpp +++ b/plugins/MidiImport/MidiImport.cpp @@ -4,7 +4,7 @@ * Copyright (c) 2005-2014 Tobias Doerffel * * This file is part of LMMS - https://lmms.io - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either @@ -50,6 +50,10 @@ #include "portsmf/allegro.h" +namespace lmms +{ + + #define makeID(_c0, _c1, _c2, _c3) \ ( 0 | \ ( ( _c0 ) | ( ( _c1 ) << 8 ) | ( ( _c2 ) << 16 ) | ( ( _c3 ) << 24 ) ) ) @@ -61,7 +65,7 @@ extern "C" Plugin::Descriptor PLUGIN_EXPORT midiimport_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "MIDI Import", QT_TRANSLATE_NOOP( "PluginBrowser", "Filter for importing MIDI-files into LMMS" ), @@ -86,13 +90,6 @@ MidiImport::MidiImport( const QString & _file ) : -MidiImport::~MidiImport() -{ -} - - - - bool MidiImport::tryImport( TrackContainer* tc ) { if( openFile() == false ) @@ -101,10 +98,10 @@ bool MidiImport::tryImport( TrackContainer* tc ) } #ifdef LMMS_HAVE_FLUIDSYNTH - if( getGUI() != nullptr && + if (gui::getGUI() != nullptr && ConfigManager::inst()->sf2File().isEmpty() ) { - QMessageBox::information( getGUI()->mainWindow(), + QMessageBox::information(gui::getGUI()->mainWindow(), tr( "Setup incomplete" ), tr( "You have not set up a default soundfont in " "the settings dialog (Edit->Settings). " @@ -114,9 +111,9 @@ bool MidiImport::tryImport( TrackContainer* tc ) "settings dialog and try again." ) ); } #else - if( getGUI() != nullptr ) + if (gui::getGUI() != nullptr) { - QMessageBox::information( getGUI()->mainWindow(), + QMessageBox::information(gui::getGUI()->mainWindow(), tr( "Setup incomplete" ), tr( "You did not compile LMMS with support for " "SoundFont2 player, which is used to add default " @@ -155,17 +152,17 @@ public: ap( nullptr ), lastPos( 0 ) { } - + AutomationTrack * at; AutomationClip * ap; TimePos lastPos; - + smfMidiCC & create( TrackContainer* tc, QString tn ) { if( !at ) { - // Keep LMMS responsive, for now the import runs - // in the main thread. This should probably be + // Keep LMMS responsive, for now the import runs + // in the main thread. This should probably be // removed if that ever changes. qApp->processEvents(); at = dynamic_cast( Track::create( Track::AutomationTrack, tc ) ); @@ -198,7 +195,7 @@ public: lastPos = time; time = time - ap->startPosition(); ap->putValue( time, value, false ); - ap->changeLength( TimePos( time.getBar() + 1, 0 ) ); + ap->changeLength( TimePos( time.getBar() + 1, 0 ) ); return *this; } @@ -217,14 +214,14 @@ public: isSF2( false ), hasNotes( false ) { } - + InstrumentTrack * it; MidiClip* p; Instrument * it_inst; - bool isSF2; + bool isSF2; bool hasNotes; QString trackName; - + smfMidiChannel * create( TrackContainer* tc, QString tn ) { if( !it ) { @@ -234,7 +231,7 @@ public: #ifdef LMMS_HAVE_FLUIDSYNTH it_inst = it->loadInstrument( "sf2player" ); - + if( it_inst ) { isSF2 = true; @@ -245,7 +242,7 @@ public: else { it_inst = it->loadInstrument( "patman" ); - } + } #else it_inst = it->loadInstrument( "patman" ); #endif @@ -305,7 +302,7 @@ bool MidiImport::readSMF( TrackContainer* tc ) const int MIDI_CC_COUNT = 128 + 1; // 0-127 (128) + pitch bend const int preTrackSteps = 2; QProgressDialog pd( TrackContainer::tr( "Importing MIDI-file..." ), - TrackContainer::tr( "Cancel" ), 0, preTrackSteps, getGUI()->mainWindow() ); + TrackContainer::tr("Cancel"), 0, preTrackSteps, gui::getGUI()->mainWindow()); pd.setWindowTitle( TrackContainer::tr( "Please wait..." ) ); pd.setWindowModality(Qt::WindowModal); pd.setMinimumDuration( 0 ); @@ -313,14 +310,17 @@ bool MidiImport::readSMF( TrackContainer* tc ) pd.setValue( 0 ); std::istringstream stream(readAllData().toStdString()); - Alg_seq_ptr seq = new Alg_seq(stream, true); + auto seq = new Alg_seq(stream, true); seq->convert_to_beats(); pd.setMaximum( seq->tracks() + preTrackSteps ); pd.setValue( 1 ); - + // 128 CC + Pitch Bend - smfMidiCC ccs[MIDI_CC_COUNT]; + auto ccs = std::array{}; + + // channel to CC object for program changes + std::unordered_map pcs; // channels can be set out of 256 range // using unordered_map should fix most invalid loads and crashes while loading @@ -328,23 +328,19 @@ bool MidiImport::readSMF( TrackContainer* tc ) // NOTE: unordered_map::operator[] creates a new element if none exists MeterModel & timeSigMM = Engine::getSong()->getTimeSigModel(); - AutomationTrack * nt = dynamic_cast( - Track::create(Track::AutomationTrack, Engine::getSong())); + auto nt = dynamic_cast(Track::create(Track::AutomationTrack, Engine::getSong())); nt->setName(tr("MIDI Time Signature Numerator")); - AutomationTrack * dt = dynamic_cast( - Track::create(Track::AutomationTrack, Engine::getSong())); + auto dt = dynamic_cast(Track::create(Track::AutomationTrack, Engine::getSong())); dt->setName(tr("MIDI Time Signature Denominator")); - AutomationClip * timeSigNumeratorPat = - new AutomationClip(nt); + auto timeSigNumeratorPat = new AutomationClip(nt); timeSigNumeratorPat->setDisplayName(tr("Numerator")); timeSigNumeratorPat->addObject(&timeSigMM.numeratorModel()); - AutomationClip * timeSigDenominatorPat = - new AutomationClip(dt); + auto timeSigDenominatorPat = new AutomationClip(dt); timeSigDenominatorPat->setDisplayName(tr("Denominator")); timeSigDenominatorPat->addObject(&timeSigMM.denominatorModel()); - + // TODO: adjust these to Time.Sig changes - double beatsPerBar = 4; + double beatsPerBar = 4; double ticksPerBeat = DefaultTicksPerBar / beatsPerBar; // Time-sig changes @@ -393,7 +389,7 @@ bool MidiImport::readSMF( TrackContainer* tc ) if( evt->is_update() ) { - printf("Unhandled SONG update: %d %f %s\n", + printf("Unhandled SONG update: %d %f %s\n", evt->get_type_code(), evt->time, evt->get_attribute() ); } } @@ -405,9 +401,9 @@ bool MidiImport::readSMF( TrackContainer* tc ) Alg_track_ptr trk = seq->track( t ); pd.setValue( t + preTrackSteps ); - for( int c = 0; c < MIDI_CC_COUNT; c++ ) + for (auto& cc : ccs) { - ccs[c].clear(); + cc.clear(); } // Now look at events @@ -448,16 +444,16 @@ bool MidiImport::readSMF( TrackContainer* tc ) else if (evt->is_note()) { smfMidiChannel * ch = chs[evt->chan].create( tc, trackName ); - Alg_note_ptr noteEvt = dynamic_cast( evt ); + auto noteEvt = dynamic_cast(evt); int ticks = noteEvt->get_duration() * ticksPerBeat; Note n( (ticks < 1 ? 1 : ticks ), noteEvt->get_start_time() * ticksPerBeat, noteEvt->get_identifier(), noteEvt->get_loud() * (200.f / 127.f)); // Map from MIDI velocity to LMMS volume ch->addNote( n ); - + } - + else if( evt->is_update() ) { smfMidiChannel * ch = chs[evt->chan].create( tc, trackName ); @@ -470,8 +466,12 @@ bool MidiImport::readSMF( TrackContainer* tc ) long prog = evt->get_integer_value(); if( ch->isSF2 ) { - ch->it_inst->childModel( "bank" )->setValue( 0 ); - ch->it_inst->childModel( "patch" )->setValue( prog ); + auto& pc = pcs[evt->chan]; + AutomatableModel* objModel = ch->it_inst->childModel("patch"); + if (pc.at == nullptr) { + pc.create(tc, trackName + " > " + objModel->displayName()); + } + pc.putValue(time, objModel, prog); } else { const QString num = QString::number( prog ); @@ -499,7 +499,7 @@ bool MidiImport::readSMF( TrackContainer* tc ) double cc = evt->get_real_value(); AutomatableModel * objModel = nullptr; - switch( ccid ) + switch( ccid ) { case 0: if( ch->isSF2 && ch->it_inst ) @@ -540,7 +540,7 @@ bool MidiImport::readSMF( TrackContainer* tc ) if( ccs[ccid].at == nullptr ) { ccs[ccid].create( tc, trackName + " > " + ( objModel != nullptr ? - objModel->displayName() : + objModel->displayName() : QString("CC %1").arg(ccid) ) ); } ccs[ccid].putValue( time, objModel, cc ); @@ -549,7 +549,7 @@ bool MidiImport::readSMF( TrackContainer* tc ) } } else { - printf("Unhandled update: %d %d %f %s\n", (int) evt->chan, + printf("Unhandled update: %d %d %f %s\n", (int) evt->chan, evt->get_type_code(), evt->time, evt->get_attribute() ); } } @@ -557,8 +557,8 @@ bool MidiImport::readSMF( TrackContainer* tc ) } delete seq; - - + + for( auto& c: chs ) { if (c.second.hasNotes) @@ -601,7 +601,7 @@ invalid_format: } // search for "data" chunk - while( 1 ) + while( true ) { const int id = readID(); const int len = read32LE(); @@ -654,3 +654,5 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *, void * _data ) } + +} // namespace lmms diff --git a/plugins/MidiImport/MidiImport.h b/plugins/MidiImport/MidiImport.h index 2edcbe926..817d06be8 100644 --- a/plugins/MidiImport/MidiImport.h +++ b/plugins/MidiImport/MidiImport.h @@ -32,28 +32,31 @@ #include "MidiEvent.h" #include "ImportFilter.h" +namespace lmms +{ + class MidiImport : public ImportFilter { Q_OBJECT public: MidiImport( const QString & _file ); - virtual ~MidiImport(); + ~MidiImport() override = default; - virtual PluginView * instantiateView( QWidget * ) + gui::PluginView* instantiateView( QWidget * ) override { return( nullptr ); } private: - virtual bool tryImport( TrackContainer* tc ); + bool tryImport( TrackContainer* tc ) override; bool readSMF( TrackContainer* tc ); bool readRIFF( TrackContainer* tc ); bool readTrack( int _track_end, QString & _track_name ); - void error( void ); + void error(); inline int readInt( int _bytes ) @@ -117,12 +120,13 @@ private: } } - - typedef QVector > EventVector; + using EventVector = QVector>; EventVector m_events; int m_timingDivision; } ; +} // namespace lmms + #endif diff --git a/plugins/MidiImport/portsmf/allegro.h b/plugins/MidiImport/portsmf/allegro.h index 698801f78..ca5859aef 100644 --- a/plugins/MidiImport/portsmf/allegro.h +++ b/plugins/MidiImport/portsmf/allegro.h @@ -287,32 +287,32 @@ public: const char *GetDescription(); // computes a text description of this event // the result is in a static buffer, not thread-safe, just for debugging. Alg_event() { selected = false; } - virtual ~Alg_event() {} + virtual ~Alg_event() = default; } *Alg_event_ptr; typedef class Alg_note : public Alg_event { public: - virtual ~Alg_note(); + ~Alg_note() override; Alg_note(Alg_note *); // copy constructor float pitch; // pitch in semitones (69 = A440) float loud; // dynamic corresponding to MIDI velocity double dur; // duration in seconds (normally to release point) Alg_parameters_ptr parameters; // attribute/value pair list Alg_note() { type = 'n'; parameters = nullptr; } - void show(); + void show() override; } *Alg_note_ptr; typedef class Alg_update : public Alg_event { public: - virtual ~Alg_update() {}; + ~Alg_update() override = default; Alg_update(Alg_update *); // copy constructor Alg_parameter parameter; // an update contains one attr/value pair Alg_update() { type = 'u'; } - void show(); + void show() override; } *Alg_update_ptr; @@ -402,7 +402,7 @@ public: // The destructor does not free events because they are owned // by a track or seq structure. - virtual ~Alg_event_list(); + ~Alg_event_list() override; // Returns the duration of the sequence in beats or seconds double get_beat_dur() { return beat_dur; } @@ -437,7 +437,7 @@ typedef class Alg_beat { public: Alg_beat(double t, double b) { time = t; beat = b; } - Alg_beat() {}; + Alg_beat() = default; double time; double beat; } *Alg_beat_ptr; @@ -535,7 +535,7 @@ class Serial_buffer { ptr = nullptr; len = 0; } - virtual ~Serial_buffer() { } + virtual ~Serial_buffer() = default; long get_posn() { return (long) (ptr - buffer); } long get_len() { return len; } @@ -548,7 +548,7 @@ public: // setting buffer, but it is not the Serial_read_buffer's responsibility // to delete the buffer (owner might want to reuse it), so the destructor // does nothing. - virtual ~Serial_read_buffer() { } + ~Serial_read_buffer() override = default; #if defined(_WIN32) //#pragma warning(disable: 546) // cast to int is OK, we only want low 7 bits //#pragma warning(disable: 4311) // type cast pointer to long warning @@ -588,7 +588,7 @@ typedef class Serial_write_buffer: public Serial_buffer { // This destructor will only run when the program exits, which will only // add overhead to the exit process, but it will eliminate an incorrect // report of memory leakage from automation that doesn't know better. -RBD - virtual ~Serial_write_buffer() { + ~Serial_write_buffer() override { if (buffer) delete [] buffer; } void init_for_write() { ptr = buffer; } @@ -654,7 +654,7 @@ protected: public: void serialize_track(); void unserialize_track(); - virtual Alg_event_ptr const &operator[](int i) { + Alg_event_ptr const &operator[](int i) override { assert(i >= 0 && i < len); return events[i]; } @@ -669,7 +669,7 @@ public: // copy constructor: event_list is copied, map is installed and referenced Alg_track(Alg_event_list_ref event_list, Alg_time_map_ptr map, bool units_are_seconds); - virtual ~Alg_track() { // note: do not call set_time_map(NULL)! + ~Alg_track() override { // note: do not call set_time_map(NULL)! if (time_map) time_map->dereference(); time_map = nullptr; } @@ -1030,11 +1030,11 @@ public: Alg_seq(std::istream &file, bool smf, double *offset_ptr = nullptr); // create from filename Alg_seq(const char *filename, bool smf, double *offset_ptr = nullptr); - virtual ~Alg_seq(); + ~Alg_seq() override; int get_read_error() { return error; } - void serialize(void **buffer, long *bytes); + void serialize(void **buffer, long *bytes) override; void copy_time_sigs_to(Alg_seq *dest); // a utility function - void set_time_map(Alg_time_map *map); + void set_time_map(Alg_time_map *map) override; // encode sequence structure into contiguous, moveable memory block // address of newly allocated memory is assigned to *buffer, which must @@ -1060,22 +1060,22 @@ public: // caller must not delete the result. Alg_track_ptr track(int); - virtual Alg_event_ptr const &operator[](int i); + Alg_event_ptr const &operator[](int i) override; - virtual void convert_to_seconds(); - virtual void convert_to_beats(); + void convert_to_seconds() override; + void convert_to_beats() override; Alg_track_ptr cut_from_track(int track_num, double start, double dur, bool all); - Alg_seq *cut(double t, double len, bool all); + Alg_seq *cut(double t, double len, bool all) override; void insert_silence_in_track(int track_num, double t, double len); - void insert_silence(double t, double len); + void insert_silence(double t, double len) override; Alg_track_ptr copy_track(int track_num, double t, double len, bool all); - Alg_seq *copy(double start, double len, bool all); + Alg_seq *copy(double start, double len, bool all) override; void paste(double start, Alg_seq *seq); - virtual void clear(double t, double len, bool all); - virtual void merge(double t, Alg_event_list_ptr seq); - virtual void silence(double t, double len, bool all); + void clear(double t, double len, bool all) override; + void merge(double t, Alg_event_list_ptr seq) override; + void silence(double t, double len, bool all) override; void clear_track(int track_num, double start, double len, bool all); void silence_track(int track_num, double start, double len, bool all); Alg_event_list_ptr find_in_track(int track_num, double t, double len, @@ -1100,7 +1100,7 @@ public: // add_event takes a pointer to an event on the heap. The event is not // copied, and this Alg_seq becomes the owner and freer of the event. void add_event(Alg_event_ptr event, int track_num); - void add(Alg_event_ptr event) { assert(false); } // call add_event instead + void add(Alg_event_ptr event) override { assert(false); } // call add_event instead // get the tempo starting at beat double get_tempo(double beat); bool set_tempo(double bpm, double start_beat, double end_beat); @@ -1112,7 +1112,7 @@ public: double *num, double *den); // void set_events(Alg_event_ptr *events, long len, long max); void merge_tracks(); // move all track data into one track - void set_in_use(bool flag); // set in_use flag on all tracks + void set_in_use(bool flag) override; // set in_use flag on all tracks } *Alg_seq_ptr, &Alg_seq_ref; diff --git a/plugins/MidiImport/portsmf/allegrosmfrd.cpp b/plugins/MidiImport/portsmf/allegrosmfrd.cpp index a221ca11b..388f4c9c9 100644 --- a/plugins/MidiImport/portsmf/allegrosmfrd.cpp +++ b/plugins/MidiImport/portsmf/allegrosmfrd.cpp @@ -65,36 +65,36 @@ protected: double get_time(); void update(int chan, int key, Alg_parameter_ptr param); - void *Mf_malloc(size_t size) { return malloc(size); } - void Mf_free(void *obj, size_t size) { free(obj); } + void *Mf_malloc(size_t size) override { return malloc(size); } + void Mf_free(void *obj, size_t size) override { free(obj); } /* Methods to be called while processing the MIDI file. */ - void Mf_starttrack(); - void Mf_endtrack(); - int Mf_getc(); - void Mf_chanprefix(int chan); - void Mf_portprefix(int port); - void Mf_eot(); - void Mf_error(char *); + void Mf_starttrack() override; + void Mf_endtrack() override; + int Mf_getc() override; + void Mf_chanprefix(int chan) override; + void Mf_portprefix(int port) override; + void Mf_eot() override; + void Mf_error(char *) override; void Mf_error(const char *); - void Mf_header(int,int,int); - void Mf_on(int,int,int); - void Mf_off(int,int,int); - void Mf_pressure(int,int,int); - void Mf_controller(int,int,int); - void Mf_pitchbend(int,int,int); - void Mf_program(int,int); - void Mf_chanpressure(int,int); + void Mf_header(int,int,int) override; + void Mf_on(int,int,int) override; + void Mf_off(int,int,int) override; + void Mf_pressure(int,int,int) override; + void Mf_controller(int,int,int) override; + void Mf_pitchbend(int,int,int) override; + void Mf_program(int,int) override; + void Mf_chanpressure(int,int) override; void binary_msg(int len, unsigned char *msg, const char *attr_string); - void Mf_sysex(int,unsigned char*); - void Mf_arbitrary(int,unsigned char*); - void Mf_metamisc(int,int,unsigned char*); - void Mf_seqnum(int); - void Mf_smpte(int,int,int,int,int); - void Mf_timesig(int,int,int,int); - void Mf_tempo(int); - void Mf_keysig(int,int); - void Mf_sqspecific(int,unsigned char*); - void Mf_text(int,int,unsigned char*); + void Mf_sysex(int,unsigned char*) override; + void Mf_arbitrary(int,unsigned char*) override; + void Mf_metamisc(int,int,unsigned char*) override; + void Mf_seqnum(int) override; + void Mf_smpte(int,int,int,int,int) override; + void Mf_timesig(int,int,int,int) override; + void Mf_tempo(int) override; + void Mf_keysig(int,int) override; + void Mf_sqspecific(int,unsigned char*) override; + void Mf_text(int,int,unsigned char*) override; }; diff --git a/plugins/MidiImport/portsmf/allegrosmfwr.cpp b/plugins/MidiImport/portsmf/allegrosmfwr.cpp index fefccf12d..eadb4c3ae 100644 --- a/plugins/MidiImport/portsmf/allegrosmfwr.cpp +++ b/plugins/MidiImport/portsmf/allegrosmfwr.cpp @@ -29,7 +29,7 @@ public: class Alg_smf_write { public: Alg_smf_write(Alg_seq_ptr seq); - ~Alg_smf_write(); + ~Alg_smf_write() = default; long channels_per_track; // used to encode track number into chan field // chan is actual_channel + channels_per_track * track_number // default is 100, set this to 0 to merge all tracks to 16 channels @@ -98,11 +98,6 @@ Alg_smf_write::Alg_smf_write(Alg_seq_ptr a_seq) } -Alg_smf_write::~Alg_smf_write() -{ -} - - // sorting is quite subtle due to rounding // For example, suppose times from a MIDI file are exact, but in // decimal round to TW0.4167 Q0.3333. Since the time in whole notes diff --git a/plugins/Monstro/Monstro.cpp b/plugins/Monstro/Monstro.cpp index e95b05030..3a9737fdb 100644 --- a/plugins/Monstro/Monstro.cpp +++ b/plugins/Monstro/Monstro.cpp @@ -38,12 +38,16 @@ #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT monstro_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "Monstro", QT_TRANSLATE_NOOP( "PluginBrowser", "Monstrous 3-oscillator synth with modulation matrix" ), @@ -83,7 +87,7 @@ MonstroSynth::MonstroSynth( MonstroInstrument * _i, NotePlayHandle * _nph ) : m_lfo_next[0] = Oscillator::noiseSample( 0.0f ); m_lfo_next[1] = Oscillator::noiseSample( 0.0f ); - + m_osc1l_last = 0.0f; m_osc1r_last = 0.0f; @@ -107,11 +111,6 @@ MonstroSynth::MonstroSynth( MonstroInstrument * _i, NotePlayHandle * _nph ) : } -MonstroSynth::~MonstroSynth() -{ -} - - void MonstroSynth::renderOutput( fpp_t _frames, sampleFrame * _buf ) { float modtmp; // temp variable for freq modulation @@ -653,14 +652,14 @@ inline void MonstroSynth::updateModulators( float * env1, float * env2, float * { // frames played before const f_cnt_t tfp = m_nph->totalFramesPlayed(); - - float * lfo [2]; - float * env [2]; + + auto lfo = std::array{}; + auto env = std::array{}; lfo[0] = lfo1; lfo[1] = lfo2; env[0] = env1; env[1] = env2; - + for( int i = 0; i < 2; ++i ) { switch( m_lfovalue[i] ) @@ -741,7 +740,7 @@ inline void MonstroSynth::updateModulators( float * env1, float * env2, float * { const f_cnt_t tm = ( tfp + f ) % static_cast( m_lfo_rate[i] ); if( tm == 0 ) - { + { m_lfo_last[i] = m_lfo_next[i]; m_lfo_next[i] = Oscillator::noiseSample( 0.0f ); } @@ -756,9 +755,9 @@ inline void MonstroSynth::updateModulators( float * env1, float * env2, float * { if( tfp + f < m_lfoatt[i] ) lfo[i][f] *= ( static_cast( tfp ) / m_lfoatt[i] ); } - - - + + + ///////////////////////////////////////////// // // // // @@ -766,7 +765,7 @@ inline void MonstroSynth::updateModulators( float * env1, float * env2, float * // // // // ///////////////////////////////////////////// - + for( f_cnt_t f = 0; f < frames; ++f ) { if( m_env_phase[i] < 4.0f && m_nph->isReleased() && f >= m_nph->framesBeforeRelease() ) @@ -1025,11 +1024,6 @@ MonstroInstrument::MonstroInstrument( InstrumentTrack * _instrument_track ) : } -MonstroInstrument::~MonstroInstrument() -{ -} - - void MonstroInstrument::playNote( NotePlayHandle * _n, sampleFrame * _working_buffer ) { @@ -1041,7 +1035,7 @@ void MonstroInstrument::playNote( NotePlayHandle * _n, _n->m_pluginData = new MonstroSynth( this, _n ); } - MonstroSynth * ms = static_cast( _n->m_pluginData ); + auto ms = static_cast(_n->m_pluginData); ms->renderOutput( frames, _working_buffer + offset ); @@ -1304,9 +1298,9 @@ f_cnt_t MonstroInstrument::desiredReleaseFrames() const } -PluginView * MonstroInstrument::instantiateView( QWidget * _parent ) +gui::PluginView* MonstroInstrument::instantiateView( QWidget * _parent ) { - return( new MonstroView( this, _parent ) ); + return( new gui::MonstroView( this, _parent ) ); } @@ -1420,7 +1414,7 @@ void MonstroInstrument::updateLFOAtts() void MonstroInstrument::updateSamplerate() { m_samplerate = Engine::audioEngine()->processingSampleRate(); - + m_integrator = 0.5f - ( 0.5f - INTEGRATOR ) * 44100.0f / m_samplerate; m_fmCorrection = 44100.f / m_samplerate * FM_AMOUNT; m_counterMax = ( m_samplerate * 5 ) / 44100; @@ -1445,6 +1439,10 @@ void MonstroInstrument::updateSlope2() } +namespace gui +{ + + MonstroView::MonstroView( Instrument * _instrument, QWidget * _parent ) : InstrumentViewFixedSize( _instrument, _parent ) @@ -1461,13 +1459,13 @@ MonstroView::MonstroView( Instrument * _instrument, // "tab buttons" - PixmapButton * m_opViewButton = new PixmapButton( this, nullptr ); + auto m_opViewButton = new PixmapButton(this, nullptr); m_opViewButton -> move( 0,0 ); m_opViewButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "opview_active" ) ); m_opViewButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "opview_inactive" ) ); m_opViewButton->setToolTip(tr("Operators view")); - PixmapButton * m_matViewButton = new PixmapButton( this, nullptr ); + auto m_matViewButton = new PixmapButton(this, nullptr); m_matViewButton -> move( 125,0 ); m_matViewButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "matview_active" ) ); m_matViewButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "matview_inactive" ) ); @@ -1482,11 +1480,6 @@ MonstroView::MonstroView( Instrument * _instrument, } -MonstroView::~MonstroView() -{ -} - - void MonstroView::updateLayout() { switch( m_selectedViewGroup->model()->value() ) @@ -1505,7 +1498,7 @@ void MonstroView::updateLayout() void MonstroView::modelChanged() { - MonstroInstrument * m = castModel(); + auto m = castModel(); m_osc1VolKnob-> setModel( &m-> m_osc1Vol ); m_osc1PanKnob-> setModel( &m-> m_osc1Pan ); @@ -1638,7 +1631,7 @@ QWidget * MonstroView::setupOperatorsView( QWidget * _parent ) { // operators view - QWidget * view = new QWidget( _parent ); + auto view = new QWidget(_parent); view-> setFixedSize( 250, 250 ); makeknob( m_osc1VolKnob, KNOBCOL1, O1ROW, tr( "Volume" ), "%", "osc1Knob" ) @@ -1701,46 +1694,47 @@ QWidget * MonstroView::setupOperatorsView( QWidget * _parent ) m_lfo2WaveBox -> setGeometry( 127, LFOROW + 7, 42, ComboBox::DEFAULT_HEIGHT ); m_lfo2WaveBox->setFont( pointSize<8>( m_lfo2WaveBox->font() ) ); - maketsknob( m_lfo2AttKnob, LFOCOL4, LFOROW, tr( "Attack" ), " ms", "lfoKnob" ) - maketsknob( m_lfo2RateKnob, LFOCOL5, LFOROW, tr( "Rate" ), " ms", "lfoKnob" ) - makeknob( m_lfo2PhsKnob, LFOCOL6, LFOROW, tr( "Phase" ), tr( " deg" ), "lfoKnob" ) + maketsknob(m_lfo2AttKnob, LFOCOL4, LFOROW, tr("Attack"), " ms", "lfoKnob") + maketsknob(m_lfo2RateKnob, LFOCOL5, LFOROW, tr("Rate"), " ms", "lfoKnob") + makeknob(m_lfo2PhsKnob, LFOCOL6, LFOROW, tr("Phase"), tr(" deg"), "lfoKnob") - maketsknob( m_env1PreKnob, KNOBCOL1, E1ROW, tr( "Pre-delay" ), " ms", "envKnob" ) - maketsknob( m_env1AttKnob, KNOBCOL2, E1ROW, tr( "Attack" ), " ms", "envKnob" ) - maketsknob( m_env1HoldKnob, KNOBCOL3, E1ROW, tr( "Hold" ), " ms", "envKnob" ) - maketsknob( m_env1DecKnob, KNOBCOL4, E1ROW, tr( "Decay" ), " ms", "envKnob" ) - makeknob( m_env1SusKnob, KNOBCOL5, E1ROW, tr( "Sustain" ), "", "envKnob" ) - maketsknob( m_env1RelKnob, KNOBCOL6, E1ROW, tr( "Release" ), " ms", "envKnob" ) - makeknob( m_env1SlopeKnob, KNOBCOL7, E1ROW, tr( "Slope" ), "", "envKnob" ) + maketsknob(m_env1PreKnob, KNOBCOL1, E1ROW, tr("Pre-delay"), " ms", "envKnob") + maketsknob(m_env1AttKnob, KNOBCOL2, E1ROW, tr("Attack"), " ms", "envKnob") + maketsknob(m_env1HoldKnob, KNOBCOL3, E1ROW, tr("Hold"), " ms", "envKnob") + maketsknob(m_env1DecKnob, KNOBCOL4, E1ROW, tr("Decay"), " ms", "envKnob") - maketsknob( m_env2PreKnob, KNOBCOL1, E2ROW, tr( "Pre-delay" ), " ms", "envKnob" ) - maketsknob( m_env2AttKnob, KNOBCOL2, E2ROW, tr( "Attack" ), " ms", "envKnob" ) - maketsknob( m_env2HoldKnob, KNOBCOL3, E2ROW, tr( "Hold" ), " ms", "envKnob" ) - maketsknob( m_env2DecKnob, KNOBCOL4, E2ROW, tr( "Decay" ), " ms", "envKnob" ) - makeknob( m_env2SusKnob, KNOBCOL5, E2ROW, tr( "Sustain" ), "", "envKnob" ) - maketsknob( m_env2RelKnob, KNOBCOL6, E2ROW, tr( "Release" ), " ms", "envKnob" ) - makeknob( m_env2SlopeKnob, KNOBCOL7, E2ROW, tr( "Slope" ), "", "envKnob" ) + makeknob(m_env1SusKnob, KNOBCOL5, E1ROW, tr("Sustain"), "", "envKnob") + maketsknob(m_env1RelKnob, KNOBCOL6, E1ROW, tr("Release"), " ms", "envKnob") + makeknob(m_env1SlopeKnob, KNOBCOL7, E1ROW, tr("Slope"), "", "envKnob") + + maketsknob(m_env2PreKnob, KNOBCOL1, E2ROW, tr("Pre-delay"), " ms", "envKnob") + maketsknob(m_env2AttKnob, KNOBCOL2, E2ROW, tr("Attack"), " ms", "envKnob") + maketsknob(m_env2HoldKnob, KNOBCOL3, E2ROW, tr("Hold"), " ms", "envKnob") + maketsknob(m_env2DecKnob, KNOBCOL4, E2ROW, tr("Decay"), " ms", "envKnob") + makeknob(m_env2SusKnob, KNOBCOL5, E2ROW, tr("Sustain"), "", "envKnob") + maketsknob(m_env2RelKnob, KNOBCOL6, E2ROW, tr("Release"), " ms", "envKnob") + makeknob(m_env2SlopeKnob, KNOBCOL7, E2ROW, tr("Slope"), "", "envKnob") // mod selector - PixmapButton * m_mixButton = new PixmapButton( view, nullptr ); + auto m_mixButton = new PixmapButton(view, nullptr); m_mixButton -> move( 225, 185 ); m_mixButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "mix_active" ) ); m_mixButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "mix_inactive" ) ); m_mixButton->setToolTip(tr("Mix osc 2 with osc 3")); - PixmapButton * m_amButton = new PixmapButton( view, nullptr ); + auto m_amButton = new PixmapButton(view, nullptr); m_amButton -> move( 225, 185 + 15 ); m_amButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "am_active" ) ); m_amButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "am_inactive" ) ); m_amButton->setToolTip(tr("Modulate amplitude of osc 3 by osc 2")); - PixmapButton * m_fmButton = new PixmapButton( view, nullptr ); + auto m_fmButton = new PixmapButton(view, nullptr); m_fmButton -> move( 225, 185 + 15*2 ); m_fmButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "fm_active" ) ); m_fmButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "fm_inactive" ) ); m_fmButton->setToolTip(tr("Modulate frequency of osc 3 by osc 2")); - PixmapButton * m_pmButton = new PixmapButton( view, nullptr ); + auto m_pmButton = new PixmapButton(view, nullptr); m_pmButton -> move( 225, 185 + 15*3 ); m_pmButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "pm_active" ) ); m_pmButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "pm_inactive" ) ); @@ -1762,7 +1756,7 @@ QWidget * MonstroView::setupMatrixView( QWidget * _parent ) { // matrix view - QWidget * view = new QWidget( _parent ); + auto view = new QWidget(_parent); view-> setFixedSize( 250, 250 ); makeknob( m_vol1env1Knob, MATCOL1, MATROW1, tr( "Modulation amount" ), "", "matrixKnob" ) @@ -1823,6 +1817,10 @@ QWidget * MonstroView::setupMatrixView( QWidget * _parent ) return( view ); } + +} // namespace gui + + extern "C" { @@ -1836,5 +1834,4 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *m, void * ) } - - +} // namespace lmms diff --git a/plugins/Monstro/Monstro.h b/plugins/Monstro/Monstro.h index 98c5d6600..319b7e000 100644 --- a/plugins/Monstro/Monstro.h +++ b/plugins/Monstro/Monstro.h @@ -38,8 +38,6 @@ #include "lmms_math.h" #include "BandLimitedWave.h" -class ComboBox; - // // UI Macros // @@ -66,6 +64,14 @@ class ComboBox; name -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "tinyled_off" ) ); \ name->setToolTip(ttip); +namespace lmms +{ + + +namespace gui +{ + + // UI constants const int O1ROW = 22; const int O2ROW = 22 + 39; @@ -108,6 +114,9 @@ const int MATROW6 = 22 + 39*5; const int OPVIEW = 0; const int MATVIEW = 1; + +} // namespace gui + // waveform enumerators const int WAVE_SINE = 0; const int WAVE_TRI = 1; @@ -154,7 +163,12 @@ const float PW_MIN = 0.25f; const float PW_MAX = 100.0f - PW_MIN; class MonstroInstrument; + +namespace gui +{ class MonstroView; +class ComboBox; +} class MonstroSynth @@ -162,7 +176,7 @@ class MonstroSynth MM_OPERATORS public: MonstroSynth( MonstroInstrument * _i, NotePlayHandle * _nph ); - virtual ~MonstroSynth(); + virtual ~MonstroSynth() = default; void renderOutput( fpp_t _frames, sampleFrame * _buf ); @@ -341,21 +355,21 @@ class MonstroInstrument : public Instrument public: MonstroInstrument( InstrumentTrack * _instrument_track ); - virtual ~MonstroInstrument(); + ~MonstroInstrument() override = default; - virtual void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ); - virtual void deleteNotePluginData( NotePlayHandle * _n ); + void playNote( NotePlayHandle * _n, + sampleFrame * _working_buffer ) override; + void deleteNotePluginData( NotePlayHandle * _n ) override; - virtual void saveSettings( QDomDocument & _doc, - QDomElement & _this ); - virtual void loadSettings( const QDomElement & _this ); + void saveSettings( QDomDocument & _doc, + QDomElement & _this ) override; + void loadSettings( const QDomElement & _this ) override; - virtual QString nodeName() const; + QString nodeName() const override; - virtual f_cnt_t desiredReleaseFrames() const; + f_cnt_t desiredReleaseFrames() const override; - virtual PluginView * instantiateView( QWidget * _parent ); + gui::PluginView* instantiateView( QWidget * _parent ) override; public slots: void updateVolume1(); @@ -564,23 +578,28 @@ private: FloatModel m_sub3lfo2; friend class MonstroSynth; - friend class MonstroView; + friend class gui::MonstroView; }; + +namespace gui +{ + + class MonstroView : public InstrumentViewFixedSize { Q_OBJECT public: MonstroView( Instrument * _instrument, QWidget * _parent ); - virtual ~MonstroView(); + ~MonstroView() override = default; protected slots: void updateLayout(); private: - virtual void modelChanged(); + void modelChanged() override; void setWidgetBackground( QWidget * _widget, const QString & _pic ); QWidget * setupOperatorsView( QWidget * _parent ); @@ -719,4 +738,8 @@ private: }; +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/MultitapEcho/MultitapEcho.cpp b/plugins/MultitapEcho/MultitapEcho.cpp index 4134436bb..05c3f30fe 100644 --- a/plugins/MultitapEcho/MultitapEcho.cpp +++ b/plugins/MultitapEcho/MultitapEcho.cpp @@ -27,12 +27,16 @@ #include "embed.h" #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT multitapecho_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "Multitap Echo", QT_TRANSLATE_NOOP( "PluginBrowser", "A multitap echo delay plugin" ), "Vesa Kivimäki ", @@ -170,3 +174,6 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* parent, void* data ) } } + + +} // namespace lmms \ No newline at end of file diff --git a/plugins/MultitapEcho/MultitapEcho.h b/plugins/MultitapEcho/MultitapEcho.h index 539ae9475..6145b9f86 100644 --- a/plugins/MultitapEcho/MultitapEcho.h +++ b/plugins/MultitapEcho/MultitapEcho.h @@ -31,14 +31,18 @@ #include "RingBuffer.h" #include "BasicFilters.h" +namespace lmms +{ + + class MultitapEchoEffect : public Effect { public: MultitapEchoEffect( Model* parent, const Descriptor::SubPluginFeatures::Key* key ); - virtual ~MultitapEchoEffect(); - virtual bool processAudioBuffer( sampleFrame* buf, const fpp_t frames ); + ~MultitapEchoEffect() override; + bool processAudioBuffer( sampleFrame* buf, const fpp_t frames ) override; - virtual EffectControls* controls() + EffectControls* controls() override { return &m_controls; } @@ -73,4 +77,6 @@ private: }; +} // namespace lmms + #endif diff --git a/plugins/MultitapEcho/MultitapEchoControlDialog.cpp b/plugins/MultitapEcho/MultitapEchoControlDialog.cpp index ac8f480da..dbf428e5f 100644 --- a/plugins/MultitapEcho/MultitapEchoControlDialog.cpp +++ b/plugins/MultitapEcho/MultitapEchoControlDialog.cpp @@ -33,6 +33,9 @@ #include "TempoSyncKnob.h" #include "LcdSpinBox.h" +namespace lmms::gui +{ + MultitapEchoControlDialog::MultitapEchoControlDialog( MultitapEchoControls * controls ) : EffectControlDialog( controls ) @@ -44,10 +47,10 @@ MultitapEchoControlDialog::MultitapEchoControlDialog( MultitapEchoControls * con setFixedSize( 245, 300 ); // graph widgets - - Graph * ampGraph = new Graph( this, Graph::BarStyle, 204, 105 ); - Graph * lpGraph = new Graph( this, Graph::BarStyle, 204, 105 ); - + + auto ampGraph = new Graph(this, Graph::BarStyle, 204, 105); + auto lpGraph = new Graph(this, Graph::BarStyle, 204, 105); + ampGraph->move( 30, 10 ); lpGraph->move( 30, 125 ); @@ -68,34 +71,37 @@ MultitapEchoControlDialog::MultitapEchoControlDialog( MultitapEchoControls * con lpGraph -> setMaximumSize( 204, 105 ); // steps spinbox - - LcdSpinBox * steps = new LcdSpinBox( 2, this, "Steps" ); + + auto steps = new LcdSpinBox(2, this, "Steps"); steps->move( 20, 245 ); steps->setModel( & controls->m_steps ); // knobs - TempoSyncKnob * stepLength = new TempoSyncKnob( knobBright_26, this ); + auto stepLength = new TempoSyncKnob(knobBright_26, this); stepLength->move( 100, 245 ); stepLength->setModel( & controls->m_stepLength ); stepLength->setLabel( tr( "Length" ) ); stepLength->setHintText( tr( "Step length:" ) , " ms" ); - - Knob * dryGain = new Knob( knobBright_26, this ); + + auto dryGain = new Knob(knobBright_26, this); dryGain->move( 150, 245 ); dryGain->setModel( & controls->m_dryGain ); dryGain->setLabel( tr( "Dry" ) ); dryGain->setHintText( tr( "Dry gain:" ) , " dBFS" ); - Knob * stages = new Knob( knobBright_26, this ); + auto stages = new Knob(knobBright_26, this); stages->move( 200, 245 ); stages->setModel( & controls->m_stages ); stages->setLabel( tr( "Stages" ) ); stages->setHintText( tr( "Low-pass stages:" ) , "x" ); // switch led - - LedCheckBox * swapInputs = new LedCheckBox( "Swap inputs", this, tr( "Swap inputs" ), LedCheckBox::Green ); + + auto swapInputs = new LedCheckBox("Swap inputs", this, tr("Swap inputs"), LedCheckBox::Green); swapInputs->move( 20, 275 ); swapInputs->setModel( & controls->m_swapInputs ); swapInputs->setToolTip(tr("Swap left and right input channels for reflections")); } + + +} // namespace lmms::gui diff --git a/plugins/MultitapEcho/MultitapEchoControlDialog.h b/plugins/MultitapEcho/MultitapEchoControlDialog.h index 5ea09877e..e016d1372 100644 --- a/plugins/MultitapEcho/MultitapEchoControlDialog.h +++ b/plugins/MultitapEcho/MultitapEchoControlDialog.h @@ -29,16 +29,27 @@ #include "EffectControlDialog.h" +namespace lmms +{ + + class MultitapEchoControls; +namespace gui +{ + + class MultitapEchoControlDialog : public EffectControlDialog { Q_OBJECT public: MultitapEchoControlDialog( MultitapEchoControls * controls ); - virtual ~MultitapEchoControlDialog() - { - } + ~MultitapEchoControlDialog() override = default; }; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/MultitapEcho/MultitapEchoControls.cpp b/plugins/MultitapEcho/MultitapEchoControls.cpp index 4f2fe63fe..19564ba8a 100644 --- a/plugins/MultitapEcho/MultitapEchoControls.cpp +++ b/plugins/MultitapEcho/MultitapEchoControls.cpp @@ -31,6 +31,9 @@ #include "lmms_math.h" #include "base64.h" +namespace lmms +{ + MultitapEchoControls::MultitapEchoControls( MultitapEchoEffect * eff ) : EffectControls( eff ), @@ -55,11 +58,6 @@ MultitapEchoControls::MultitapEchoControls( MultitapEchoEffect * eff ) : } -MultitapEchoControls::~MultitapEchoControls() -{ -} - - void MultitapEchoControls::saveSettings( QDomDocument & doc, QDomElement & parent ) { m_steps.saveSettings( doc, parent, "steps" ); @@ -178,3 +176,6 @@ void MultitapEchoControls::sampleRateChanged() m_effect->m_sampleRatio = 1.0f / m_effect->m_sampleRate; m_effect->updateFilters( 0, 19 ); } + + +} // namespace lmms diff --git a/plugins/MultitapEcho/MultitapEchoControls.h b/plugins/MultitapEcho/MultitapEchoControls.h index 4696f46d9..bd345bfe5 100644 --- a/plugins/MultitapEcho/MultitapEchoControls.h +++ b/plugins/MultitapEcho/MultitapEchoControls.h @@ -30,6 +30,9 @@ #include "MultitapEchoControlDialog.h" #include "Graph.h" +namespace lmms +{ + class MultitapEchoEffect; @@ -38,11 +41,11 @@ class MultitapEchoControls : public EffectControls Q_OBJECT public: MultitapEchoControls( MultitapEchoEffect * eff ); - virtual ~MultitapEchoControls(); + ~MultitapEchoControls() override = default; - virtual void saveSettings( QDomDocument & doc, QDomElement & parent ); - virtual void loadSettings( const QDomElement & elem ); - inline virtual QString nodeName() const + void saveSettings( QDomDocument & doc, QDomElement & parent ) override; + void loadSettings( const QDomElement & elem ) override; + inline QString nodeName() const override { return( "multitapechocontrols" ); } @@ -50,14 +53,14 @@ public: void setDefaultAmpShape(); void setDefaultLpShape(); - virtual int controlCount() + int controlCount() override { return( 5 ); } - virtual EffectControlDialog * createView() + gui::EffectControlDialog* createView() override { - return( new MultitapEchoControlDialog( this ) ); + return( new gui::MultitapEchoControlDialog( this ) ); } private slots: @@ -83,8 +86,10 @@ private: graphModel m_lpGraph; friend class MultitapEchoEffect; - friend class MultitapEchoControlDialog; + friend class gui::MultitapEchoControlDialog; }; +} // namespace lmms + #endif diff --git a/plugins/Nes/Nes.cpp b/plugins/Nes/Nes.cpp index a84f6e6a4..d47ebd728 100644 --- a/plugins/Nes/Nes.cpp +++ b/plugins/Nes/Nes.cpp @@ -36,12 +36,16 @@ #include "embed.h" #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT nes_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "Nescaline", QT_TRANSLATE_NOOP( "PluginBrowser", "A NES-like synthesizer" ), @@ -99,11 +103,6 @@ NesObject::NesObject( NesInstrument * nes, const sample_rate_t samplerate, NoteP } -NesObject::~NesObject() -{ -} - - void NesObject::renderOutput( sampleFrame * buf, fpp_t frames ) { //////////////////////////////// @@ -386,9 +385,9 @@ void NesObject::renderOutput( sampleFrame * buf, fpp_t frames ) // // // final stage - mixing // // // - //////////////////////////////// - - float pin1 = static_cast( ch1 + ch2 ); + //////////////////////////////// + + auto pin1 = static_cast(ch1 + ch2); // add dithering noise pin1 *= 1.0 + ( Oscillator::noiseSample( 0.0f ) * DITHER_AMP ); pin1 = pin1 / 30.0f; @@ -406,8 +405,7 @@ void NesObject::renderOutput( sampleFrame * buf, fpp_t frames ) pin1 *= NES_MIXING_12; - - float pin2 = static_cast( ch3 + ch4 ); + auto pin2 = static_cast(ch3 + ch4); // add dithering noise pin2 *= 1.0 + ( Oscillator::noiseSample( 0.0f ) * DITHER_AMP ); pin2 = pin2 / 30.0f; @@ -547,24 +545,19 @@ NesInstrument::NesInstrument( InstrumentTrack * instrumentTrack ) : -NesInstrument::~NesInstrument() -{ -} - - void NesInstrument::playNote( NotePlayHandle * n, sampleFrame * workingBuffer ) { const fpp_t frames = n->framesLeftForCurrentPeriod(); const f_cnt_t offset = n->noteOffset(); if ( n->totalFramesPlayed() == 0 || n->m_pluginData == nullptr ) - { - NesObject * nes = new NesObject( this, Engine::audioEngine()->processingSampleRate(), n ); + { + auto nes = new NesObject(this, Engine::audioEngine()->processingSampleRate(), n); n->m_pluginData = nes; } - - NesObject * nes = static_cast( n->m_pluginData ); - + + auto nes = static_cast(n->m_pluginData); + nes->renderOutput( workingBuffer + offset, frames ); applyRelease( workingBuffer, n ); @@ -699,9 +692,9 @@ QString NesInstrument::nodeName() const } -PluginView * NesInstrument::instantiateView( QWidget * parent ) +gui::PluginView* NesInstrument::instantiateView( QWidget * parent ) { - return( new NesInstrumentView( this, parent ) ); + return( new gui::NesInstrumentView( this, parent ) ); } @@ -724,6 +717,8 @@ void NesInstrument::updateFreq3() } +namespace gui +{ QPixmap * NesInstrumentView::s_artwork = nullptr; @@ -848,14 +843,9 @@ NesInstrumentView::NesInstrumentView( Instrument * instrument, QWidget * parent -NesInstrumentView::~NesInstrumentView() -{ -} - - void NesInstrumentView::modelChanged() { - NesInstrument * nes = castModel(); + auto nes = castModel(); m_ch1EnabledBtn->setModel( &nes->m_ch1Enabled ); m_ch1CrsKnob->setModel( &nes->m_ch1Crs ); @@ -912,6 +902,9 @@ void NesInstrumentView::modelChanged() } +} // namespace gui + + extern "C" { @@ -925,4 +918,4 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *m, void * _data ) } - +} // namespace lmms diff --git a/plugins/Nes/Nes.h b/plugins/Nes/Nes.h index f17265c14..91e5e556c 100644 --- a/plugins/Nes/Nes.h +++ b/plugins/Nes/Nes.h @@ -56,6 +56,11 @@ name -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "nesdc_off" ) ); \ name->setToolTip(ttip); + +namespace lmms +{ + + const float NES_SIMPLE_FILTER = 1.0 / 20.0; // simulate nes analog audio output const float NFB = 895000.0f; const float NOISE_FREQS[16] = @@ -76,15 +81,21 @@ const float NES_MIXING_ALL = 1.0 / ( NES_MIXING_12 + NES_MIXING_34 ); // constan const int MIN_WLEN = 4; -class Knob; class NesInstrument; +namespace gui +{ +class Knob; +class NesInstrumentView; +} // namespace gui + + class NesObject { MM_OPERATORS public: NesObject( NesInstrument * nes, const sample_rate_t samplerate, NotePlayHandle * nph ); - virtual ~NesObject(); + virtual ~NesObject() = default; void renderOutput( sampleFrame * buf, fpp_t frames ); void updateVibrato( float * freq ); @@ -200,25 +211,25 @@ class NesInstrument : public Instrument Q_OBJECT public: NesInstrument( InstrumentTrack * instrumentTrack ); - virtual ~NesInstrument(); + ~NesInstrument() override = default; - virtual void playNote( NotePlayHandle * n, - sampleFrame * workingBuffer ); - virtual void deleteNotePluginData( NotePlayHandle * n ); + void playNote( NotePlayHandle * n, + sampleFrame * workingBuffer ) override; + void deleteNotePluginData( NotePlayHandle * n ) override; - virtual void saveSettings( QDomDocument & doc, - QDomElement & element ); - virtual void loadSettings( const QDomElement & element ); + void saveSettings( QDomDocument & doc, + QDomElement & element ) override; + void loadSettings( const QDomElement & element ) override; - virtual QString nodeName() const; + QString nodeName() const override; - virtual f_cnt_t desiredReleaseFrames() const + f_cnt_t desiredReleaseFrames() const override { return( 8 ); } - virtual PluginView * instantiateView( QWidget * parent ); + gui::PluginView* instantiateView( QWidget * parent ) override; public slots: void updateFreq1(); @@ -288,20 +299,24 @@ private: friend class NesObject; - friend class NesInstrumentView; + friend class gui::NesInstrumentView; }; +namespace gui +{ + + class NesInstrumentView : public InstrumentViewFixedSize { Q_OBJECT public: NesInstrumentView( Instrument * instrument, QWidget * parent ); - virtual ~NesInstrumentView(); + ~NesInstrumentView() override = default; private: - virtual void modelChanged(); + void modelChanged() override; // channel 1 PixmapButton * m_ch1EnabledBtn; @@ -360,4 +375,9 @@ private: static QPixmap * s_artwork; }; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/OpulenZ/OpulenZ.cpp b/plugins/OpulenZ/OpulenZ.cpp index da85e2d02..3a18c1e3f 100644 --- a/plugins/OpulenZ/OpulenZ.cpp +++ b/plugins/OpulenZ/OpulenZ.cpp @@ -58,12 +58,16 @@ #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT opulenz_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "OpulenZ", QT_TRANSLATE_NOOP( "PluginBrowser", "2-operator FM Synth" ), @@ -88,7 +92,7 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *m, void * ) QMutex OpulenzInstrument::emulatorMutex; // Weird ordering of voice parameters -const unsigned int adlib_opadd[OPL2_VOICES] = {0x00, 0x01, 0x02, 0x08, 0x09, 0x0A, 0x10, 0x11, 0x12}; +const auto adlib_opadd = std::array{0x00, 0x01, 0x02, 0x08, 0x09, 0x0A, 0x10, 0x11, 0x12}; OpulenzInstrument::OpulenzInstrument( InstrumentTrack * _instrument_track ) : Instrument( _instrument_track, &opulenz_plugin_descriptor ), @@ -211,7 +215,7 @@ OpulenzInstrument::OpulenzInstrument( InstrumentTrack * _instrument_track ) : MOD_CON( trem_depth_mdl ); // Connect the plugin to the audio engine... - InstrumentPlayHandle * iph = new InstrumentPlayHandle( this, _instrument_track ); + auto iph = new InstrumentPlayHandle(this, _instrument_track); Engine::audioEngine()->addPlayHandle( iph ); } @@ -367,7 +371,7 @@ bool OpulenzInstrument::handleMidiEvent( const MidiEvent& event, const TimePos& } break; default: -#ifdef LMMS_DEBUG +#ifdef LMMS_DEBUG printf("Midi CC %02x %02x\n", event.controllerNumber(), event.controllerValue() ); #endif break; @@ -388,9 +392,9 @@ QString OpulenzInstrument::nodeName() const return( opulenz_plugin_descriptor.name ); } -PluginView * OpulenzInstrument::instantiateView( QWidget * _parent ) +gui::PluginView* OpulenzInstrument::instantiateView( QWidget * _parent ) { - return( new OpulenzInstrumentView( this, _parent ) ); + return( new gui::OpulenzInstrumentView( this, _parent ) ); } @@ -530,7 +534,7 @@ void OpulenzInstrument::loadGMPatch() { // Update patch from the models to the chip emulation void OpulenzInstrument::updatePatch() { - unsigned char inst[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + auto inst = std::array{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; inst[0] = ( op1_trem_mdl.value() ? 128 : 0 ) + ( op1_vib_mdl.value() ? 64 : 0 ) + ( op1_perc_mdl.value() ? 0 : 32 ) + // NB. This envelope mode is "perc", not "sus" @@ -579,7 +583,7 @@ void OpulenzInstrument::updatePatch() { #endif - loadPatch(inst); + loadPatch(inst.data()); } // Load an SBI file into the knob models @@ -673,7 +677,8 @@ void OpulenzInstrument::loadFile( const QString& file ) { - +namespace gui +{ OpulenzInstrumentView::OpulenzInstrumentView( Instrument * _instrument, QWidget * _parent ) : @@ -758,7 +763,7 @@ OpulenzInstrumentView::OpulenzInstrumentView( Instrument * _instrument, setPalette( pal ); } OpulenzInstrumentView::~OpulenzInstrumentView() { - // Knobs are QWidgets and our children, so they're + // Knobs are QWidgets and our children, so they're // destroyed automagically } @@ -777,24 +782,23 @@ void OpulenzInstrumentView::updateKnobHints() { // Envelope times in ms: t[0] = 0, t[n] = ( 1<{ + 0.0, 0.2, 0.4, 0.9, 1.8, 3.7, 7.4, 15.0, 30.0, 60.0, 120.0, 240.0, 480.0, - 950.0, 1900.0, 3800.0 + 950.0, 1900.0, 3800.0 }; - const float dr_times[16] = { - 0.0, 1.2, 2.5, 5.0, 10.0, 20.0, 40.0, - 80.0, 160.0, 320.0, 640.0, 1300.0, 2600.0, - 5200.0, 10000.0, 20000.0 - }; - - const int fmultipliers[16] = { - -12, 0, 12, 19, 24, 28, 31, 34, 36, 38, 40, 40, 43, 43, 47, 47 + const auto dr_times = std::array{ + 0.0, 1.2, 2.5, 5.0, 10.0, 20.0, 40.0, + 80.0, 160.0, 320.0, 640.0, 1300.0, 2600.0, + 5200.0, 10000.0, 20000.0 }; - OpulenzInstrument * m = castModel(); - + const auto fmultipliers = std::array{ + -12, 0, 12, 19, 24, 28, 31, 34, 36, 38, 40, 40, 43, 43, 47, 47 + }; + + auto m = castModel(); op1_a_kn->setHintText( tr( "Attack" ), " (" + knobHintHelper(attack_times[(int)m->op1_a_mdl.value()]) + ")"); @@ -816,7 +820,7 @@ void OpulenzInstrumentView::updateKnobHints() void OpulenzInstrumentView::modelChanged() { - OpulenzInstrument * m = castModel(); + auto m = castModel(); // m_patch->setModel( &m->m_patchModel ); op1_a_kn->setModel( &m->op1_a_mdl ); @@ -859,15 +863,17 @@ void OpulenzInstrumentView::modelChanged() connect( &m->op1_d_mdl, SIGNAL( dataChanged() ), this, SLOT( updateKnobHints() ) ); connect( &m->op2_d_mdl, SIGNAL( dataChanged() ), this, SLOT( updateKnobHints() ) ); - connect( &m->op1_r_mdl, SIGNAL( dataChanged() ), this, SLOT( updateKnobHints() ) ); - connect( &m->op2_r_mdl, SIGNAL( dataChanged() ), this, SLOT( updateKnobHints() ) ); + connect( &m->op1_r_mdl, SIGNAL( dataChanged() ), this, SLOT( updateKnobHints() ) ); + connect( &m->op2_r_mdl, SIGNAL( dataChanged() ), this, SLOT( updateKnobHints() ) ); - connect( &m->op1_mul_mdl, SIGNAL( dataChanged() ), this, SLOT( updateKnobHints() ) ); - connect( &m->op2_mul_mdl, SIGNAL( dataChanged() ), this, SLOT( updateKnobHints() ) ); + connect( &m->op1_mul_mdl, SIGNAL( dataChanged() ), this, SLOT( updateKnobHints() ) ); + connect( &m->op2_mul_mdl, SIGNAL( dataChanged() ), this, SLOT( updateKnobHints() ) ); updateKnobHints(); } +} // namespace gui +} // namespace lmms diff --git a/plugins/OpulenZ/OpulenZ.h b/plugins/OpulenZ/OpulenZ.h index 7b4868b4f..1f999252f 100644 --- a/plugins/OpulenZ/OpulenZ.h +++ b/plugins/OpulenZ/OpulenZ.h @@ -31,11 +31,19 @@ #include "Instrument.h" #include "InstrumentView.h" -class automatableButtonGroup; class Copl; + + +namespace lmms +{ + +namespace gui +{ class Knob; class LcdSpinBox; class PixmapButton; +class automatableButtonGroup; +} // This one is a flag, MIDI notes take 7 low bits @@ -51,24 +59,24 @@ class OpulenzInstrument : public Instrument Q_OBJECT public: OpulenzInstrument( InstrumentTrack * _instrument_track ); - virtual ~OpulenzInstrument(); + ~OpulenzInstrument() override; - virtual QString nodeName() const; - virtual PluginView * instantiateView( QWidget * _parent ); + QString nodeName() const override; + gui::PluginView* instantiateView( QWidget * _parent ) override; - virtual Flags flags() const + Flags flags() const override { return IsSingleStreamed | IsMidiBased; } - virtual bool handleMidiEvent( const MidiEvent& event, const TimePos& time, f_cnt_t offset = 0 ); - virtual void play( sampleFrame * _working_buffer ); + bool handleMidiEvent( const MidiEvent& event, const TimePos& time, f_cnt_t offset = 0 ) override; + void play( sampleFrame * _working_buffer ) override; - void saveSettings( QDomDocument & _doc, QDomElement & _this ); - void loadSettings( const QDomElement & _this ); + void saveSettings( QDomDocument & _doc, QDomElement & _this ) override; + void loadSettings( const QDomElement & _this ) override; void loadPatch(const unsigned char inst[14]); void tuneEqual(int center, float Hz); - virtual void loadFile( const QString& file ); + void loadFile( const QString& file ) override; IntModel m_patchModel; @@ -146,15 +154,18 @@ private: }; +namespace gui +{ + class OpulenzInstrumentView : public InstrumentViewFixedSize { Q_OBJECT public: OpulenzInstrumentView( Instrument * _instrument, QWidget * _parent ); - virtual ~OpulenzInstrumentView(); + ~OpulenzInstrumentView() override; LcdSpinBox *m_patch; - void modelChanged(); + void modelChanged() override; Knob *op1_a_kn; Knob *op1_d_kn; @@ -205,4 +216,9 @@ public: }; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/Organic/Organic.cpp b/plugins/Organic/Organic.cpp index c2a6fcce4..6c2cde773 100644 --- a/plugins/Organic/Organic.cpp +++ b/plugins/Organic/Organic.cpp @@ -2,7 +2,7 @@ * Organic.cpp - additive synthesizer for organ-like sounds * * Copyright (c) 2006-2008 Andreas Brandmaier - * + * * This file is part of LMMS - https://lmms.io * * This program is free software; you can redistribute it and/or @@ -41,13 +41,16 @@ #include "plugin_export.h" +namespace lmms +{ + extern "C" { Plugin::Descriptor PLUGIN_EXPORT organic_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "Organic", QT_TRANSLATE_NOOP( "PluginBrowser", "Additive Synthesizer for organ-like sounds" ), @@ -61,14 +64,14 @@ Plugin::Descriptor PLUGIN_EXPORT organic_plugin_descriptor = } -QPixmap * OrganicInstrumentView::s_artwork = nullptr; +QPixmap * gui::OrganicInstrumentView::s_artwork = nullptr; float * OrganicInstrument::s_harmonics = nullptr; /*********************************************************************** * * class OrganicInstrument * -* lmms - plugin +* lmms - plugin * ***********************************************************************/ @@ -87,7 +90,7 @@ OrganicInstrument::OrganicInstrument( InstrumentTrack * _instrument_track ) : m_osc[i] = new OscillatorObject( this, i ); m_osc[i]->m_numOscillators = m_numOscillators; - // Connect events + // Connect events connect( &m_osc[i]->m_oscModel, SIGNAL( dataChanged() ), m_osc[i], SLOT ( oscButtonChanged() ) ); connect( &m_osc[i]->m_harmModel, SIGNAL( dataChanged() ), @@ -111,7 +114,7 @@ OrganicInstrument::OrganicInstrument( InstrumentTrack * _instrument_track ) : m_osc[5]->m_harmonic = log2f( 4.0f ); // . m_osc[6]->m_harmonic = log2f( 5.0f ); // . m_osc[7]->m_harmonic = log2f( 6.0f ); // .*/ - + if( s_harmonics == nullptr ) { s_harmonics = new float[ NUM_HARMONICS ]; @@ -139,10 +142,10 @@ OrganicInstrument::OrganicInstrument( InstrumentTrack * _instrument_track ) : m_osc[i]->updateVolume(); m_osc[i]->updateDetuning(); } - + connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), - this, SLOT( updateAllDetuning() ) ); + this, SLOT( updateAllDetuning() ) ); } @@ -190,7 +193,7 @@ void OrganicInstrument::loadSettings( const QDomElement & _this ) m_osc[i]->m_volModel.loadSettings( _this, "vol" + is ); if( _this.hasAttribute( "detune" + is ) ) { - m_osc[i]->m_detuneModel.setValue( _this.attribute( "detune" ).toInt() * 12 ); + m_osc[i]->m_detuneModel.setValue( _this.attribute( "detune" ).toInt() * 12 ); } else { @@ -198,7 +201,7 @@ void OrganicInstrument::loadSettings( const QDomElement & _this ) } m_osc[i]->m_panModel.loadSettings( _this, "pan" + is ); m_osc[i]->m_oscModel.loadSettings( _this, "wavetype" + is ); - + if( _this.hasAttribute( "newharmonic" + is ) ) { m_osc[i]->m_harmModel.loadSettings( _this, "newharmonic" + is ); @@ -208,7 +211,7 @@ void OrganicInstrument::loadSettings( const QDomElement & _this ) m_osc[i]->m_harmModel.setValue( static_cast( i ) ); } } - + m_volModel.loadSettings( _this, "vol" ); m_fx1Model.loadSettings( _this, "foldback" ); } @@ -227,23 +230,23 @@ void OrganicInstrument::playNote( NotePlayHandle * _n, { const fpp_t frames = _n->framesLeftForCurrentPeriod(); const f_cnt_t offset = _n->noteOffset(); - + if( _n->totalFramesPlayed() == 0 || _n->m_pluginData == nullptr ) { - Oscillator * oscs_l[NUM_OSCILLATORS]; - Oscillator * oscs_r[NUM_OSCILLATORS]; + auto oscs_l = std::array{}; + auto oscs_r = std::array{}; _n->m_pluginData = new oscPtr; for( int i = m_numOscillators - 1; i >= 0; --i ) { - static_cast( _n->m_pluginData )->phaseOffsetLeft[i] + static_cast( _n->m_pluginData )->phaseOffsetLeft[i] = rand() / ( RAND_MAX + 1.0f ); - static_cast( _n->m_pluginData )->phaseOffsetRight[i] + static_cast( _n->m_pluginData )->phaseOffsetRight[i] = rand() / ( RAND_MAX + 1.0f ); - + // initialise ocillators - + if( i == m_numOscillators - 1 ) { // create left oscillator @@ -284,8 +287,8 @@ void OrganicInstrument::playNote( NotePlayHandle * _n, m_osc[i]->m_volumeRight, oscs_r[i + 1] ); } - - + + } static_cast( _n->m_pluginData )->oscLeft = oscs_l[0]; @@ -300,10 +303,10 @@ void OrganicInstrument::playNote( NotePlayHandle * _n, // -- fx section -- - + // fxKnob is [0;1] float t = m_fx1Model.value(); - + for (int i=0 ; i < frames + offset ; i++) { _working_buffer[i][0] = waveshape( _working_buffer[i][0], t ) * @@ -311,7 +314,7 @@ void OrganicInstrument::playNote( NotePlayHandle * _n, _working_buffer[i][1] = waveshape( _working_buffer[i][1], t ) * m_volModel.value() / 100.0f; } - + // -- -- instrumentTrack()->processAudioBuffer( _working_buffer, frames + offset, _n ); @@ -326,7 +329,7 @@ void OrganicInstrument::deleteNotePluginData( NotePlayHandle * _n ) _n->m_pluginData )->oscLeft ); delete static_cast( static_cast( _n->m_pluginData )->oscRight ); - + delete static_cast( _n->m_pluginData ); } @@ -385,19 +388,21 @@ void OrganicInstrument::updateAllDetuning() int OrganicInstrument::intRand( int min, int max ) { -// int randn = min+int((max-min)*rand()/(RAND_MAX + 1.0)); +// int randn = min+int((max-min)*rand()/(RAND_MAX + 1.0)); // cout << randn << endl; int randn = ( rand() % (max - min) ) + min; return( randn ); } -PluginView * OrganicInstrument::instantiateView( QWidget * _parent ) +gui::PluginView * OrganicInstrument::instantiateView( QWidget * _parent ) { - return( new OrganicInstrumentView( this, _parent ) ); + return( new gui::OrganicInstrumentView( this, _parent ) ); } +namespace gui +{ class OrganicKnob : public Knob @@ -412,13 +417,12 @@ public: - OrganicInstrumentView::OrganicInstrumentView( Instrument * _instrument, QWidget * _parent ) : InstrumentViewFixedSize( _instrument, _parent ), m_oscKnobs( nullptr ) { - OrganicInstrument * oi = castModel(); + auto oi = castModel(); setAutoFillBackground( true ); QPalette pal; @@ -448,7 +452,7 @@ OrganicInstrumentView::OrganicInstrumentView( Instrument * _instrument, "randomise_pressed" ) ); m_randBtn->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "randomise" ) ); - + connect( m_randBtn, SIGNAL ( clicked() ), oi, SLOT( randomiseSettings() ) ); @@ -470,15 +474,15 @@ OrganicInstrumentView::~OrganicInstrumentView() void OrganicInstrumentView::modelChanged() { - OrganicInstrument * oi = castModel(); - + auto oi = castModel(); + const float y=91.0f; const float rowHeight = 26.0f; const float x=53.0f; - const float colWidth = 24.0f; + const float colWidth = 24.0f; m_numOscillators = oi->m_numOscillators; - + m_fx1Knob->setModel( &oi->m_fx1Model ); m_volKnob->setModel( &oi->m_volModel ); @@ -486,7 +490,7 @@ void OrganicInstrumentView::modelChanged() { delete[] m_oscKnobs; } - + m_oscKnobs = new OscillatorKnobs[ m_numOscillators ]; // Create knobs, now that we know how many to make @@ -498,7 +502,7 @@ void OrganicInstrumentView::modelChanged() harmKnob->setObjectName( "harmKnob" ); connect( &oi->m_osc[i]->m_harmModel, SIGNAL( dataChanged() ), this, SLOT( updateKnobHint() ) ); - + // setup waveform-knob Knob * oscKnob = new OrganicKnob( this ); oscKnob->move( x + i * colWidth, y ); @@ -506,21 +510,21 @@ void OrganicInstrumentView::modelChanged() this, SLOT( updateKnobHint() ) ); oscKnob->setHintText( tr( "Osc %1 waveform:" ).arg( i + 1 ), QString() ); - + // setup volume-knob - Knob * volKnob = new Knob( knobStyled, this ); + auto volKnob = new Knob(knobStyled, this); volKnob->setVolumeKnob( true ); volKnob->move( x + i * colWidth, y + rowHeight*1 ); volKnob->setFixedSize( 21, 21 ); volKnob->setHintText( tr( "Osc %1 volume:" ).arg( i + 1 ), "%" ); - + // setup panning-knob Knob * panKnob = new OrganicKnob( this ); panKnob->move( x + i * colWidth, y + rowHeight*2 ); panKnob->setHintText( tr("Osc %1 panning:").arg( i + 1 ), "" ); - + // setup knob for fine-detuning Knob * detuneKnob = new OrganicKnob( this ); detuneKnob->move( x + i * colWidth, y + rowHeight*3 ); @@ -543,12 +547,12 @@ void OrganicInstrumentView::modelChanged() void OrganicInstrumentView::updateKnobHint() { - OrganicInstrument * oi = castModel(); + auto oi = castModel(); for( int i = 0; i < m_numOscillators; ++i ) { const float harm = oi->m_osc[i]->m_harmModel.value(); const float wave = oi->m_osc[i]->m_oscModel.value(); - + m_oscKnobs[i].m_harmKnob->setHintText( tr( "Osc %1 harmonic:" ).arg( i + 1 ), " (" + HARMONIC_NAMES[ static_cast( harm ) ] + ")" ); m_oscKnobs[i].m_oscKnob->setHintText( tr( "Osc %1 waveform:" ).arg( i + 1 ), " (" + @@ -557,6 +561,7 @@ void OrganicInstrumentView::updateKnobHint() } +} // namespace gui OscillatorObject::OscillatorObject( Model * _parent, int _index ) : @@ -570,7 +575,7 @@ OscillatorObject::OscillatorObject( Model * _parent, int _index ) : this, tr( "Osc %1 volume" ).arg( _index + 1 ) ), m_panModel( DefaultPanning, PanningLeft, PanningRight, 1.0f, this, tr( "Osc %1 panning" ).arg( _index + 1 ) ), - m_detuneModel( 0.0f, -1200.0f, 1200.0f, 1.0f, + m_detuneModel( 0.0f, -1200.0f, 1200.0f, 1.0f, this, tr( "Osc %1 fine detuning left" ).arg( _index + 1 ) ) { } @@ -578,17 +583,10 @@ OscillatorObject::OscillatorObject( Model * _parent, int _index ) : -OscillatorObject::~OscillatorObject() -{ -} - - - - void OscillatorObject::oscButtonChanged() { - static Oscillator::WaveShapes shapes[] = + static auto shapes = std::array { Oscillator::SineWave, Oscillator::SawWave, @@ -627,8 +625,6 @@ void OscillatorObject::updateDetuning() } - - extern "C" { @@ -643,14 +639,13 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *m, void * ) /* * some notes & ideas for the future of this plugin: - * + * * - 32.692 Hz in the bass to 5919.85 Hz of treble in a Hammond organ * => implement harmonic foldback - * + * m_osc[i].m_oscModel->setInitValue( 0.0f ); - * - randomize preset + * - randomize preset */ - - +} // namespace lmms diff --git a/plugins/Organic/Organic.h b/plugins/Organic/Organic.h index b16b2ef9a..057a4a5b4 100644 --- a/plugins/Organic/Organic.h +++ b/plugins/Organic/Organic.h @@ -34,10 +34,19 @@ class QPixmap; -class Knob; +namespace lmms +{ + + class NotePlayHandle; class Oscillator; + +namespace gui +{ +class Knob; class PixmapButton; +class OrganicInstrumentView; +} // namespace gui const int NUM_OSCILLATORS = 8; const int NUM_HARMONICS = 18; @@ -96,10 +105,10 @@ private: float m_phaseOffsetRight; OscillatorObject( Model * _parent, int _index ); - virtual ~OscillatorObject(); + ~OscillatorObject() override = default; friend class OrganicInstrument; - friend class OrganicInstrumentView; + friend class gui::OrganicInstrumentView; private slots: @@ -115,17 +124,17 @@ class OrganicInstrument : public Instrument Q_OBJECT public: OrganicInstrument( InstrumentTrack * _instrument_track ); - virtual ~OrganicInstrument(); + ~OrganicInstrument() override; - virtual void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ); - virtual void deleteNotePluginData( NotePlayHandle * _n ); + void playNote( NotePlayHandle * _n, + sampleFrame * _working_buffer ) override; + void deleteNotePluginData( NotePlayHandle * _n ) override; - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); + void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; - virtual QString nodeName() const; + QString nodeName() const override; int intRand( int min, int max ); @@ -163,25 +172,28 @@ private: FloatModel m_fx1Model; FloatModel m_volModel; - virtual PluginView * instantiateView( QWidget * _parent ); + gui::PluginView* instantiateView( QWidget * _parent ) override; private slots: void updateAllDetuning(); - friend class OrganicInstrumentView; + friend class gui::OrganicInstrumentView; } ; +namespace gui +{ + class OrganicInstrumentView : public InstrumentViewFixedSize { Q_OBJECT public: OrganicInstrumentView( Instrument * _instrument, QWidget * _parent ); - virtual ~OrganicInstrumentView(); + ~OrganicInstrumentView() override; private: - virtual void modelChanged(); + void modelChanged() override; struct OscillatorKnobs { @@ -199,9 +211,7 @@ private: m_detuneKnob( dt ) { } - OscillatorKnobs() - { - } + OscillatorKnobs() = default; Knob * m_harmKnob; Knob * m_volKnob; @@ -225,4 +235,8 @@ protected slots: }; +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/Patman/Patman.cpp b/plugins/Patman/Patman.cpp index 9268b2919..a8f75db60 100644 --- a/plugins/Patman/Patman.cpp +++ b/plugins/Patman/Patman.cpp @@ -46,13 +46,16 @@ #include "plugin_export.h" +namespace lmms +{ + extern "C" { Plugin::Descriptor PLUGIN_EXPORT patman_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "PatMan", QT_TRANSLATE_NOOP( "PluginBrowser", "GUS-compatible patch instrument" ), @@ -122,7 +125,7 @@ void PatmanInstrument::loadFile( const QString & _file ) -QString PatmanInstrument::nodeName( void ) const +QString PatmanInstrument::nodeName() const { return( patman_plugin_descriptor.name ); } @@ -145,7 +148,7 @@ void PatmanInstrument::playNote( NotePlayHandle * _n, { selectSample( _n ); } - handle_data * hdata = (handle_data *)_n->m_pluginData; + auto hdata = (handle_data*)_n->m_pluginData; float play_freq = hdata->tuned ? _n->frequency() : hdata->sample->frequency(); @@ -168,7 +171,7 @@ void PatmanInstrument::playNote( NotePlayHandle * _n, void PatmanInstrument::deleteNotePluginData( NotePlayHandle * _n ) { - handle_data * hdata = (handle_data *)_n->m_pluginData; + auto hdata = (handle_data*)_n->m_pluginData; sharedObject::unref( hdata->sample ); delete hdata->state; delete hdata; @@ -222,11 +225,11 @@ PatmanInstrument::LoadErrors PatmanInstrument::loadPatch( return( LoadOpen ); } - unsigned char header[239]; + auto header = std::array{}; - if( fread( header, 1, 239, fd ) != 239 || - ( memcmp( header, "GF1PATCH110\0ID#000002", 22 ) - && memcmp( header, "GF1PATCH100\0ID#000002", 22 ) ) ) + if (fread(header.data(), 1, 239, fd ) != 239 || + (memcmp(header.data(), "GF1PATCH110\0ID#000002", 22) + && memcmp(header.data(), "GF1PATCH100\0ID#000002", 22))) { fclose( fd ); return( LoadNotGUS ); @@ -344,7 +347,7 @@ PatmanInstrument::LoadErrors PatmanInstrument::loadPatch( } } - sampleFrame * data = new sampleFrame[frames]; + auto data = new sampleFrame[frames]; for( f_cnt_t frame = 0; frame < frames; ++frame ) { @@ -355,7 +358,7 @@ PatmanInstrument::LoadErrors PatmanInstrument::loadPatch( } } - SampleBuffer* psample = new SampleBuffer( data, frames ); + auto psample = new SampleBuffer(data, frames); psample->setFrequency( root_freq / 1000.0f ); psample->setSampleRate( sample_rate ); @@ -377,7 +380,7 @@ PatmanInstrument::LoadErrors PatmanInstrument::loadPatch( -void PatmanInstrument::unloadCurrentPatch( void ) +void PatmanInstrument::unloadCurrentPatch() { while( !m_patchSamples.empty() ) { @@ -396,20 +399,20 @@ void PatmanInstrument::selectSample( NotePlayHandle * _n ) float min_dist = HUGE_VALF; SampleBuffer* sample = nullptr; - for( QVector::iterator it = m_patchSamples.begin(); it != m_patchSamples.end(); ++it ) + for (const auto& patchSample : m_patchSamples) { - float patch_freq = ( *it )->frequency(); + float patch_freq = patchSample->frequency(); float dist = freq >= patch_freq ? freq / patch_freq : patch_freq / freq; if( dist < min_dist ) { min_dist = dist; - sample = *it; + sample = patchSample; } } - handle_data * hdata = new handle_data; + auto hdata = new handle_data; hdata->tuned = m_tunedModel.value(); if( sample ) { @@ -427,9 +430,9 @@ void PatmanInstrument::selectSample( NotePlayHandle * _n ) -PluginView * PatmanInstrument::instantiateView( QWidget * _parent ) +gui::PluginView * PatmanInstrument::instantiateView( QWidget * _parent ) { - return( new PatmanView( this, _parent ) ); + return( new gui::PatmanView( this, _parent ) ); } @@ -437,8 +440,8 @@ PluginView * PatmanInstrument::instantiateView( QWidget * _parent ) - - +namespace gui +{ PatmanView::PatmanView( Instrument * _instrument, QWidget * _parent ) : @@ -492,14 +495,7 @@ PatmanView::PatmanView( Instrument * _instrument, QWidget * _parent ) : -PatmanView::~PatmanView() -{ -} - - - - -void PatmanView::openFile( void ) +void PatmanView::openFile() { FileDialog ofd( nullptr, tr( "Open patch file" ) ); ofd.setFileMode( FileDialog::ExistingFiles ); @@ -551,7 +547,7 @@ void PatmanView::openFile( void ) -void PatmanView::updateFilename( void ) +void PatmanView::updateFilename() { m_displayFilename = ""; int idx = m_pi->m_patchFile.length(); @@ -635,7 +631,7 @@ void PatmanView::paintEvent( QPaintEvent * ) -void PatmanView::modelChanged( void ) +void PatmanView::modelChanged() { m_pi = castModel(); m_loopButton->setModel( &m_pi->m_loopedModel ); @@ -643,3 +639,8 @@ void PatmanView::modelChanged( void ) connect( m_pi, SIGNAL( fileChanged() ), this, SLOT( updateFilename() ) ); } + + +} // namespace gui + +} // namespace lmms diff --git a/plugins/Patman/Patman.h b/plugins/Patman/Patman.h index 6aa6497aa..acdf4f7ef 100644 --- a/plugins/Patman/Patman.h +++ b/plugins/Patman/Patman.h @@ -23,8 +23,8 @@ */ -#ifndef PATMAN_H_ -#define PATMAN_H_ +#ifndef PATMAN_H +#define PATMAN_H #include "Instrument.h" #include "InstrumentView.h" @@ -32,7 +32,14 @@ #include "AutomatableModel.h" #include "MemoryManager.h" +namespace lmms +{ + +namespace gui +{ class PixmapButton; +class PatmanView; +} // namespace gui #define MODES_16BIT ( 1 << 0 ) @@ -50,26 +57,26 @@ class PatmanInstrument : public Instrument Q_OBJECT public: PatmanInstrument( InstrumentTrack * _track ); - virtual ~PatmanInstrument(); + ~PatmanInstrument() override; - virtual void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ); - virtual void deleteNotePluginData( NotePlayHandle * _n ); + void playNote( NotePlayHandle * _n, + sampleFrame * _working_buffer ) override; + void deleteNotePluginData( NotePlayHandle * _n ) override; - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); + void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; - virtual void loadFile( const QString & _file ); + void loadFile( const QString & _file ) override; - virtual QString nodeName( void ) const; + QString nodeName() const override; - virtual f_cnt_t desiredReleaseFrames( void ) const + f_cnt_t desiredReleaseFrames() const override { return( 128 ); } - virtual PluginView * instantiateView( QWidget * _parent ); + gui::PluginView* instantiateView( QWidget * _parent ) override; public slots: @@ -77,13 +84,13 @@ public slots: private: - typedef struct + struct handle_data { MM_OPERATORS SampleBuffer::handleState* state; bool tuned; SampleBuffer* sample; - } handle_data; + }; QString m_patchFile; QVector m_patchSamples; @@ -102,41 +109,44 @@ private: } ; LoadErrors loadPatch( const QString & _filename ); - void unloadCurrentPatch( void ); + void unloadCurrentPatch(); void selectSample( NotePlayHandle * _n ); - friend class PatmanView; + friend class gui::PatmanView; signals: - void fileChanged( void ); + void fileChanged(); } ; +namespace gui +{ + class PatmanView : public InstrumentViewFixedSize { Q_OBJECT public: PatmanView( Instrument * _instrument, QWidget * _parent ); - virtual ~PatmanView(); + ~PatmanView() override = default; public slots: - void openFile( void ); - void updateFilename( void ); + void openFile(); + void updateFilename(); protected: - virtual void dragEnterEvent( QDragEnterEvent * _dee ); - virtual void dropEvent( QDropEvent * _de ); - virtual void paintEvent( QPaintEvent * ); + void dragEnterEvent( QDragEnterEvent * _dee ) override; + void dropEvent( QDropEvent * _de ) override; + void paintEvent( QPaintEvent * ) override; private: - virtual void modelChanged( void ); + void modelChanged() override; PatmanInstrument * m_pi; QString m_displayFilename; @@ -148,5 +158,8 @@ private: } ; +} // namespace gui -#endif +} // namespace lmms + +#endif // PATMAN_H diff --git a/plugins/PeakControllerEffect/PeakControllerEffect.cpp b/plugins/PeakControllerEffect/PeakControllerEffect.cpp index 672e020c4..d32a22320 100644 --- a/plugins/PeakControllerEffect/PeakControllerEffect.cpp +++ b/plugins/PeakControllerEffect/PeakControllerEffect.cpp @@ -33,12 +33,16 @@ #include "embed.h" #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT peakcontrollereffect_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "Peak Controller", QT_TRANSLATE_NOOP( "PluginBrowser", "Plugin for controlling knobs with sound peaks" ), @@ -157,3 +161,5 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model * _parent, void * _data ) } + +} // namespace lmms diff --git a/plugins/PeakControllerEffect/PeakControllerEffect.h b/plugins/PeakControllerEffect/PeakControllerEffect.h index 4eeddf45d..f2bafedda 100644 --- a/plugins/PeakControllerEffect/PeakControllerEffect.h +++ b/plugins/PeakControllerEffect/PeakControllerEffect.h @@ -29,6 +29,10 @@ #include "Effect.h" #include "PeakControllerEffectControls.h" +namespace lmms +{ + + class PeakController; class PeakControllerEffect : public Effect @@ -36,8 +40,8 @@ class PeakControllerEffect : public Effect public: PeakControllerEffect( Model * parent, const Descriptor::SubPluginFeatures::Key * _key ); - virtual ~PeakControllerEffect(); - virtual bool processAudioBuffer( sampleFrame * _buf, + ~PeakControllerEffect() override; + bool processAudioBuffer( sampleFrame * _buf, const fpp_t _frames ) override; EffectControls * controls() override @@ -78,4 +82,7 @@ private: } ; + +} // namespace lmms + #endif diff --git a/plugins/PeakControllerEffect/PeakControllerEffectControlDialog.cpp b/plugins/PeakControllerEffect/PeakControllerEffectControlDialog.cpp index 044a4c60c..69566a86c 100644 --- a/plugins/PeakControllerEffect/PeakControllerEffectControlDialog.cpp +++ b/plugins/PeakControllerEffect/PeakControllerEffectControlDialog.cpp @@ -35,6 +35,8 @@ #include "LedCheckBox.h" #include "embed.h" +namespace lmms::gui +{ PeakControllerEffectControlDialog::PeakControllerEffectControlDialog( PeakControllerEffectControls * _controls ) : @@ -83,9 +85,9 @@ PeakControllerEffectControlDialog::PeakControllerEffectControlDialog( m_absLed = new LedCheckBox( tr( "Absolute value" ), this ); m_absLed->setModel( &_controls->m_absModel ); - QVBoxLayout * mainLayout = new QVBoxLayout(); - QHBoxLayout * knobLayout = new QHBoxLayout(); - QHBoxLayout * ledLayout = new QHBoxLayout(); + auto mainLayout = new QVBoxLayout(); + auto knobLayout = new QHBoxLayout(); + auto ledLayout = new QHBoxLayout(); knobLayout->addWidget( m_baseKnob ); knobLayout->addWidget( m_amountKnob ); @@ -104,3 +106,5 @@ PeakControllerEffectControlDialog::PeakControllerEffectControlDialog( setLayout( mainLayout ); } + +} // namespace lmms::gui diff --git a/plugins/PeakControllerEffect/PeakControllerEffectControlDialog.h b/plugins/PeakControllerEffect/PeakControllerEffectControlDialog.h index cd6a99d2b..9f5f45223 100644 --- a/plugins/PeakControllerEffect/PeakControllerEffectControlDialog.h +++ b/plugins/PeakControllerEffect/PeakControllerEffectControlDialog.h @@ -28,7 +28,13 @@ #include "EffectControlDialog.h" +namespace lmms +{ + class PeakControllerEffectControls; + +namespace gui +{ class Knob; class LedCheckBox; @@ -39,9 +45,7 @@ class PeakControllerEffectControlDialog : public EffectControlDialog public: PeakControllerEffectControlDialog( PeakControllerEffectControls * _controls ); - virtual ~PeakControllerEffectControlDialog() - { - } + ~PeakControllerEffectControlDialog() override = default; protected: @@ -57,5 +61,8 @@ protected: } ; +} // namespace gui + +} // namespace lmms #endif diff --git a/plugins/PeakControllerEffect/PeakControllerEffectControls.cpp b/plugins/PeakControllerEffect/PeakControllerEffectControls.cpp index d19b15d37..070c9fbb8 100644 --- a/plugins/PeakControllerEffect/PeakControllerEffectControls.cpp +++ b/plugins/PeakControllerEffect/PeakControllerEffectControls.cpp @@ -30,6 +30,9 @@ #include "PeakControllerEffect.h" #include "Song.h" +namespace lmms +{ + PeakControllerEffectControls:: PeakControllerEffectControls( PeakControllerEffect * _eff ) : @@ -104,6 +107,4 @@ void PeakControllerEffectControls::saveSettings( QDomDocument & _doc, } - - - +} // namespace lmms diff --git a/plugins/PeakControllerEffect/PeakControllerEffectControls.h b/plugins/PeakControllerEffect/PeakControllerEffectControls.h index 7706784f0..3bd96b3f9 100644 --- a/plugins/PeakControllerEffect/PeakControllerEffectControls.h +++ b/plugins/PeakControllerEffect/PeakControllerEffectControls.h @@ -29,16 +29,19 @@ #include "EffectControls.h" #include "PeakControllerEffectControlDialog.h" +namespace lmms +{ + + class PeakControllerEffect; + class PeakControllerEffectControls : public EffectControls { Q_OBJECT public: PeakControllerEffectControls( PeakControllerEffect * _eff ); - virtual ~PeakControllerEffectControls() - { - } + ~PeakControllerEffectControls() override = default; void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; void loadSettings( const QDomElement & _this ) override; @@ -51,9 +54,9 @@ public: { return 1; } - EffectControlDialog * createView() override + gui::EffectControlDialog * createView() override { - return new PeakControllerEffectControlDialog( this ); + return new gui::PeakControllerEffectControlDialog( this ); } @@ -69,10 +72,12 @@ private: BoolModel m_absModel; FloatModel m_amountMultModel; - friend class PeakControllerEffectControlDialog; + friend class gui::PeakControllerEffectControlDialog; friend class PeakControllerEffect; } ; +} // namespace lmms + #endif diff --git a/plugins/ReverbSC/ReverbSC.cpp b/plugins/ReverbSC/ReverbSC.cpp index 2d56d7f48..e8dec8fd7 100644 --- a/plugins/ReverbSC/ReverbSC.cpp +++ b/plugins/ReverbSC/ReverbSC.cpp @@ -28,12 +28,16 @@ #define DB2LIN(X) pow(10, X / 20.0f); +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT reverbsc_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "ReverbSC", QT_TRANSLATE_NOOP( "PluginBrowser", "Reverb algorithm by Sean Costello" ), "Paul Batchelor", @@ -58,7 +62,7 @@ ReverbSCEffect::ReverbSCEffect( Model* parent, const Descriptor::SubPluginFeatur sp_dcblock_create(&dcblk[0]); sp_dcblock_create(&dcblk[1]); - + sp_dcblock_init(sp, dcblk[0], Engine::audioEngine()->currentQualitySettings().sampleRateMultiplier() ); sp_dcblock_init(sp, dcblk[1], Engine::audioEngine()->currentQualitySettings().sampleRateMultiplier() ); } @@ -84,7 +88,7 @@ bool ReverbSCEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) SPFLOAT tmpL, tmpR; SPFLOAT dcblkL, dcblkR; - + ValueBuffer * inGainBuf = m_reverbSCControls.m_inputGainModel.valueBuffer(); ValueBuffer * sizeBuf = m_reverbSCControls.m_sizeModel.valueBuffer(); ValueBuffer * colorBuf = m_reverbSCControls.m_colorModel.valueBuffer(); @@ -92,23 +96,21 @@ bool ReverbSCEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) for( fpp_t f = 0; f < frames; ++f ) { - sample_t s[2] = { buf[f][0], buf[f][1] }; + auto s = std::array{buf[f][0], buf[f][1]}; - const SPFLOAT inGain = (SPFLOAT)DB2LIN((inGainBuf ? - inGainBuf->values()[f] - : m_reverbSCControls.m_inputGainModel.value())); - const SPFLOAT outGain = (SPFLOAT)DB2LIN((outGainBuf ? - outGainBuf->values()[f] - : m_reverbSCControls.m_outputGainModel.value())); + const auto inGain + = (SPFLOAT)DB2LIN((inGainBuf ? inGainBuf->values()[f] : m_reverbSCControls.m_inputGainModel.value())); + const auto outGain + = (SPFLOAT)DB2LIN((outGainBuf ? outGainBuf->values()[f] : m_reverbSCControls.m_outputGainModel.value())); s[0] *= inGain; s[1] *= inGain; - revsc->feedback = (SPFLOAT)(sizeBuf ? - sizeBuf->values()[f] + revsc->feedback = (SPFLOAT)(sizeBuf ? + sizeBuf->values()[f] : m_reverbSCControls.m_sizeModel.value()); - revsc->lpfreq = (SPFLOAT)(colorBuf ? - colorBuf->values()[f] + revsc->lpfreq = (SPFLOAT)(colorBuf ? + colorBuf->values()[f] : m_reverbSCControls.m_colorModel.value()); @@ -126,7 +128,7 @@ bool ReverbSCEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) return isRunning(); } - + void ReverbSCEffect::changeSampleRate() { // Change sr variable in Soundpipe. does not need to be destroyed @@ -142,7 +144,7 @@ void ReverbSCEffect::changeSampleRate() sp_dcblock_create(&dcblk[0]); sp_dcblock_create(&dcblk[1]); - + sp_dcblock_init(sp, dcblk[0], Engine::audioEngine()->currentQualitySettings().sampleRateMultiplier() ); sp_dcblock_init(sp, dcblk[1], Engine::audioEngine()->currentQualitySettings().sampleRateMultiplier() ); mutex.unlock(); @@ -154,10 +156,13 @@ extern "C" // necessary for getting instance out of shared lib PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* parent, void* data ) { - return new ReverbSCEffect( - parent, - static_cast(data) + return new ReverbSCEffect( + parent, + static_cast(data) ); } } + + +} // namespace lmms diff --git a/plugins/ReverbSC/ReverbSC.h b/plugins/ReverbSC/ReverbSC.h index 3a7a81e8d..2cb119bff 100644 --- a/plugins/ReverbSC/ReverbSC.h +++ b/plugins/ReverbSC/ReverbSC.h @@ -35,14 +35,19 @@ extern "C" { #include "dcblock.h" } + +namespace lmms +{ + + class ReverbSCEffect : public Effect { public: ReverbSCEffect( Model* parent, const Descriptor::SubPluginFeatures::Key* key ); - virtual ~ReverbSCEffect(); - virtual bool processAudioBuffer( sampleFrame* buf, const fpp_t frames ); + ~ReverbSCEffect() override; + bool processAudioBuffer( sampleFrame* buf, const fpp_t frames ) override; - virtual EffectControls* controls() + EffectControls* controls() override { return &m_reverbSCControls; } @@ -58,4 +63,7 @@ private: friend class ReverbSCControls; } ; + +} // namespace lmms + #endif diff --git a/plugins/ReverbSC/ReverbSCControlDialog.cpp b/plugins/ReverbSC/ReverbSCControlDialog.cpp index 9c5ae7eab..c9ddef384 100644 --- a/plugins/ReverbSC/ReverbSCControlDialog.cpp +++ b/plugins/ReverbSC/ReverbSCControlDialog.cpp @@ -29,6 +29,10 @@ #include "Knob.h" #include "ReverbSCControls.h" +namespace lmms::gui +{ + + ReverbSCControlDialog::ReverbSCControlDialog( ReverbSCControls* controls ) : EffectControlDialog( controls ) { @@ -37,28 +41,31 @@ ReverbSCControlDialog::ReverbSCControlDialog( ReverbSCControls* controls ) : pal.setBrush( backgroundRole(), PLUGIN_NAME::getIconPixmap( "artwork" ) ); setPalette( pal ); setFixedSize( 185, 55 ); - - Knob * inputGainKnob = new Knob( knobBright_26, this); + + auto inputGainKnob = new Knob(knobBright_26, this); inputGainKnob -> move( 16, 10 ); inputGainKnob->setModel( &controls->m_inputGainModel ); inputGainKnob->setLabel( tr( "Input" ) ); inputGainKnob->setHintText( tr( "Input gain:" ) , "dB" ); - Knob * sizeKnob = new Knob( knobBright_26, this); + auto sizeKnob = new Knob(knobBright_26, this); sizeKnob -> move( 57, 10 ); sizeKnob->setModel( &controls->m_sizeModel ); sizeKnob->setLabel( tr( "Size" ) ); sizeKnob->setHintText( tr( "Size:" ) , "" ); - Knob * colorKnob = new Knob( knobBright_26, this); + auto colorKnob = new Knob(knobBright_26, this); colorKnob -> move( 98, 10 ); colorKnob->setModel( &controls->m_colorModel ); colorKnob->setLabel( tr( "Color" ) ); colorKnob->setHintText( tr( "Color:" ) , "" ); - Knob * outputGainKnob = new Knob( knobBright_26, this); + auto outputGainKnob = new Knob(knobBright_26, this); outputGainKnob -> move( 139, 10 ); outputGainKnob->setModel( &controls->m_outputGainModel ); outputGainKnob->setLabel( tr( "Output" ) ); outputGainKnob->setHintText( tr( "Output gain:" ) , "dB" ); } + + +} // namespace lmms::gui \ No newline at end of file diff --git a/plugins/ReverbSC/ReverbSCControlDialog.h b/plugins/ReverbSC/ReverbSCControlDialog.h index 0d9c1f51a..0abc96896 100644 --- a/plugins/ReverbSC/ReverbSCControlDialog.h +++ b/plugins/ReverbSC/ReverbSCControlDialog.h @@ -28,18 +28,27 @@ #include "EffectControlDialog.h" +namespace lmms +{ + class ReverbSCControls; +namespace gui +{ + class ReverbSCControlDialog : public EffectControlDialog { Q_OBJECT public: ReverbSCControlDialog( ReverbSCControls* controls ); - virtual ~ReverbSCControlDialog() - { - } + ~ReverbSCControlDialog() override = default; } ; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/ReverbSC/ReverbSCControls.cpp b/plugins/ReverbSC/ReverbSCControls.cpp index 11c99f665..4784d416d 100644 --- a/plugins/ReverbSC/ReverbSCControls.cpp +++ b/plugins/ReverbSC/ReverbSCControls.cpp @@ -29,6 +29,10 @@ #include "ReverbSC.h" #include "Engine.h" +namespace lmms +{ + + ReverbSCControls::ReverbSCControls( ReverbSCEffect* effect ) : EffectControls( effect ), m_effect( effect ), @@ -64,3 +68,6 @@ void ReverbSCControls::changeSampleRate() { m_effect->changeSampleRate(); } + + +} // namespace lmms diff --git a/plugins/ReverbSC/ReverbSCControls.h b/plugins/ReverbSC/ReverbSCControls.h index 78423ae8d..93f974a21 100644 --- a/plugins/ReverbSC/ReverbSCControls.h +++ b/plugins/ReverbSC/ReverbSCControls.h @@ -29,6 +29,10 @@ #include "ReverbSCControlDialog.h" +namespace lmms +{ + + class ReverbSCEffect; class ReverbSCControls : public EffectControls @@ -36,25 +40,23 @@ class ReverbSCControls : public EffectControls Q_OBJECT public: ReverbSCControls( ReverbSCEffect* effect ); - virtual ~ReverbSCControls() - { - } + ~ReverbSCControls() override = default; - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); - inline virtual QString nodeName() const + void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; + inline QString nodeName() const override { return "ReverbSCControls"; } - virtual int controlCount() + int controlCount() override { return 4; } - virtual EffectControlDialog* createView() + gui::EffectControlDialog* createView() override { - return new ReverbSCControlDialog( this ); + return new gui::ReverbSCControlDialog( this ); } @@ -69,9 +71,12 @@ private: FloatModel m_colorModel; FloatModel m_outputGainModel; - friend class ReverbSCControlDialog; + friend class gui::ReverbSCControlDialog; friend class ReverbSCEffect; } ; + +} // namespace lmms + #endif diff --git a/plugins/Sf2Player/CMakeLists.txt b/plugins/Sf2Player/CMakeLists.txt index be21c0cf2..4679a94bd 100644 --- a/plugins/Sf2Player/CMakeLists.txt +++ b/plugins/Sf2Player/CMakeLists.txt @@ -1,8 +1,13 @@ if(LMMS_HAVE_FLUIDSYNTH) - INCLUDE(BuildPlugin) - INCLUDE_DIRECTORIES(${FLUIDSYNTH_INCLUDE_DIRS} ${SAMPLERATE_INCLUDE_DIRS}) - LINK_DIRECTORIES(${FLUIDSYNTH_LIBRARY_DIRS} ${SAMPLERATE_LIBRARY_DIRS}) - LINK_LIBRARIES(${FLUIDSYNTH_LIBRARIES} ${SAMPLERATE_LIBRARIES}) - BUILD_PLUGIN(sf2player Sf2Player.cpp Sf2Player.h PatchesDialog.cpp PatchesDialog.h PatchesDialog.ui MOCFILES Sf2Player.h PatchesDialog.h UICFILES PatchesDialog.ui EMBEDDED_RESOURCES *.png) -endif(LMMS_HAVE_FLUIDSYNTH) - + include(BuildPlugin) + include_directories(${SAMPLERATE_INCLUDE_DIRS}) + link_directories(${SAMPLERATE_LIBRARY_DIRS}) + link_libraries(${SAMPLERATE_LIBRARIES}) + build_plugin(sf2player + Sf2Player.cpp Sf2Player.h PatchesDialog.cpp PatchesDialog.h PatchesDialog.ui + MOCFILES Sf2Player.h PatchesDialog.h + UICFILES PatchesDialog.ui + EMBEDDED_RESOURCES *.png + ) + target_link_libraries(sf2player fluidsynth) +endif() diff --git a/plugins/Sf2Player/PatchesDialog.cpp b/plugins/Sf2Player/PatchesDialog.cpp index f9c414ac0..9c9a689a0 100644 --- a/plugins/Sf2Player/PatchesDialog.cpp +++ b/plugins/Sf2Player/PatchesDialog.cpp @@ -32,6 +32,9 @@ #include "fluidsynthshims.h" +namespace lmms::gui +{ + // Custom list-view item (as for numerical sort purposes...) class PatchItem : public QTreeWidgetItem @@ -44,7 +47,7 @@ public: : QTreeWidgetItem( pListView, pItemAfter ) {} // Sort/compare overriden method. - bool operator< ( const QTreeWidgetItem& other ) const + bool operator< ( const QTreeWidgetItem& other ) const override { int iColumn = QTreeWidgetItem::treeWidget()->sortColumn(); const QString& s1 = text( iColumn ); @@ -108,12 +111,6 @@ PatchesDialog::PatchesDialog( QWidget *pParent, Qt::WindowFlags wflags ) } -// Destructor. -PatchesDialog::~PatchesDialog() -{ -} - - // Dialog setup loader. void PatchesDialog::setup ( fluid_synth_t * pSynth, int iChan, const QString & _chanName, @@ -261,7 +258,7 @@ void PatchesDialog::accept() // Reject settings (Cancel button slot). -void PatchesDialog::reject (void) +void PatchesDialog::reject () { // Reset selection to initial selection, if applicable... if (m_dirty > 0) @@ -303,7 +300,7 @@ QTreeWidgetItem *PatchesDialog::findProgItem ( int iProg ) // Bank change slot. -void PatchesDialog::bankChanged (void) +void PatchesDialog::bankChanged () { if (m_pSynth == nullptr) return; @@ -381,4 +378,4 @@ void PatchesDialog::progChanged (QTreeWidgetItem * _curr, QTreeWidgetItem * _pre } - +} // namespace lmms::gui diff --git a/plugins/Sf2Player/PatchesDialog.h b/plugins/Sf2Player/PatchesDialog.h index 73b649a2a..5309ce0bf 100644 --- a/plugins/Sf2Player/PatchesDialog.h +++ b/plugins/Sf2Player/PatchesDialog.h @@ -34,6 +34,9 @@ class QLabel; +namespace lmms::gui +{ + //---------------------------------------------------------------------------- // qsynthPresetForm -- UI wrapper form. @@ -47,7 +50,7 @@ public: PatchesDialog(QWidget *pParent = 0, Qt::WindowFlags wflags = QFlag(0)); // Destructor. - virtual ~PatchesDialog(); + ~PatchesDialog() override = default; void setup(fluid_synth_t *pSynth, int iChan, const QString & _chanName, @@ -61,8 +64,8 @@ public slots: protected slots: - void accept(); - void reject(); + void accept() override; + void reject() override; protected: @@ -92,5 +95,7 @@ private: }; +} // namespace lmms::gui + #endif diff --git a/plugins/Sf2Player/Sf2Player.cpp b/plugins/Sf2Player/Sf2Player.cpp index ee9156a0b..ab3729f7d 100644 --- a/plugins/Sf2Player/Sf2Player.cpp +++ b/plugins/Sf2Player/Sf2Player.cpp @@ -49,12 +49,16 @@ #include "embed.h" #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT sf2player_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "Sf2 Player", QT_TRANSLATE_NOOP( "PluginBrowser", "Player for SoundFont files" ), "Paul Giblock ", @@ -111,10 +115,6 @@ Sf2Instrument::Sf2Instrument( InstrumentTrack * _instrument_track ) : m_chorusSpeed( FLUID_CHORUS_DEFAULT_SPEED, 0.29, 5.0, 0.01, this, tr( "Chorus speed" ) ), m_chorusDepth( FLUID_CHORUS_DEFAULT_DEPTH, 0, 46.0, 0.05, this, tr( "Chorus depth" ) ) { - for( int i = 0; i < 128; ++i ) - { - m_notesRunning[i] = 0; - } #if QT_VERSION_CHECK(FLUIDSYNTH_VERSION_MAJOR, FLUIDSYNTH_VERSION_MINOR, FLUIDSYNTH_VERSION_MICRO) >= QT_VERSION_CHECK(1,1,9) @@ -181,8 +181,17 @@ Sf2Instrument::Sf2Instrument( InstrumentTrack * _instrument_track ) : connect( &m_chorusLevel, SIGNAL( dataChanged() ), this, SLOT( updateChorus() ) ); connect( &m_chorusSpeed, SIGNAL( dataChanged() ), this, SLOT( updateChorus() ) ); connect( &m_chorusDepth, SIGNAL( dataChanged() ), this, SLOT( updateChorus() ) ); + + // Microtuning + connect(Engine::getSong(), &Song::scaleListChanged, this, &Sf2Instrument::updateTuning); + connect(Engine::getSong(), &Song::keymapListChanged, this, &Sf2Instrument::updateTuning); + connect(instrumentTrack()->microtuner()->enabledModel(), &Model::dataChanged, this, &Sf2Instrument::updateTuning, Qt::DirectConnection); + connect(instrumentTrack()->microtuner()->scaleModel(), &Model::dataChanged, this, &Sf2Instrument::updateTuning, Qt::DirectConnection); + connect(instrumentTrack()->microtuner()->keymapModel(), &Model::dataChanged, this, &Sf2Instrument::updateTuning, Qt::DirectConnection); + connect(instrumentTrack()->microtuner()->keyRangeImportModel(), &Model::dataChanged, this, &Sf2Instrument::updateTuning, Qt::DirectConnection); + connect(instrumentTrack()->baseNoteModel(), &Model::dataChanged, this, &Sf2Instrument::updateTuning, Qt::DirectConnection); - InstrumentPlayHandle * iph = new InstrumentPlayHandle( this, _instrument_track ); + auto iph = new InstrumentPlayHandle(this, _instrument_track); Engine::audioEngine()->addPlayHandle( iph ); } @@ -278,7 +287,7 @@ void Sf2Instrument::loadFile( const QString & _file ) fluid_preset_t preset; fluid_preset_t *pCurPreset = &preset; #else - fluid_preset_t *pCurPreset; + fluid_preset_t *pCurPreset = nullptr; #endif if ( ( pCurPreset = fluid_sfont_iteration_next_wrapper( pSoundFont, pCurPreset ) ) ) { @@ -471,7 +480,7 @@ QString Sf2Instrument::getCurrentPatchName() fluid_preset_t preset; fluid_preset_t *pCurPreset = &preset; #else - fluid_preset_t *pCurPreset; + fluid_preset_t *pCurPreset = nullptr; #endif while ((pCurPreset = fluid_sfont_iteration_next_wrapper(pSoundFont, pCurPreset))) { @@ -537,6 +546,38 @@ void Sf2Instrument::updateChorus() +void Sf2Instrument::updateTuning() +{ + if (instrumentTrack()->microtuner()->enabledModel()->value()) + { + auto centArray = std::array{}; + double lowestHz = pow(2., -69. / 12.) * 440.;// Frequency of MIDI note 0, which is approximately 8.175798916 Hz + for (int i = 0; i < 128; ++i) + { + // Get desired Hz of note + double noteHz = instrumentTrack()->microtuner()->keyToFreq(i, DefaultBaseKey); + // Convert Hz to cents + centArray[i] = noteHz == 0. ? 0. : 1200. * log2(noteHz / lowestHz); + } + + fluid_synth_activate_key_tuning(m_synth, 0, 0, "", centArray.data(), true); + for (int chan = 0; chan < 16; chan++) + { + fluid_synth_activate_tuning(m_synth, chan, 0, 0, true); + } + } + else + { + fluid_synth_activate_key_tuning(m_synth, 0, 0, "", nullptr, true); + for (int chan = 0; chan < 16; chan++) + { + fluid_synth_activate_tuning(m_synth, chan, 0, 0, true); + } + } +} + + + void Sf2Instrument::reloadSynth() { double tempRate; @@ -604,6 +645,7 @@ void Sf2Instrument::reloadSynth() updateReverbOn(); updateChorusOn(); updateGain(); + updateTuning(); // Reset last MIDI pitch properties, which will be set to the correct values // upon playing the next note @@ -622,21 +664,22 @@ void Sf2Instrument::playNote( NotePlayHandle * _n, sampleFrame * ) } const f_cnt_t tfp = _n->totalFramesPlayed(); + + int masterPitch = instrumentTrack()->useMasterPitchModel()->value() ? Engine::getSong()->masterPitch() : 0; + int baseNote = instrumentTrack()->baseNoteModel()->value(); + int midiNote = _n->midiKey() - baseNote + DefaultBaseKey + masterPitch; - if( tfp == 0 ) + // out of range? + if (midiNote < 0 || midiNote >= 128) { - const float LOG440 = 2.643452676f; + return; + } - int midiNote = (int)floor( 12.0 * ( log2( _n->unpitchedFrequency() ) - LOG440 ) - 4.0 ); - - // out of range? - if( midiNote <= 0 || midiNote >= 128 ) - { - return; - } + if (tfp == 0) + { const int baseVelocity = instrumentTrack()->midiPort()->baseVelocity(); - Sf2PluginData * pluginData = new Sf2PluginData; + auto pluginData = new Sf2PluginData; pluginData->midiNote = midiNote; pluginData->lastPanning = 0; pluginData->lastVelocity = _n->midiVelocity( baseVelocity ); @@ -654,7 +697,7 @@ void Sf2Instrument::playNote( NotePlayHandle * _n, sampleFrame * ) } else if( _n->isReleased() && ! _n->instrumentTrack()->isSustainPedalPressed() ) // note is released during this period { - Sf2PluginData * pluginData = static_cast( _n->m_pluginData ); + auto pluginData = static_cast(_n->m_pluginData); pluginData->offset = _n->framesBeforeRelease(); pluginData->isNew = false; @@ -672,8 +715,13 @@ void Sf2Instrument::noteOn( Sf2PluginData * n ) // get list of current voice IDs so we can easily spot the new // voice after the fluid_synth_noteon() call const int poly = fluid_synth_get_polyphony( m_synth ); - fluid_voice_t * voices[poly]; +#ifndef _MSC_VER + fluid_voice_t* voices[poly]; unsigned int id[poly]; +#else + const auto voices = static_cast(_alloca(poly * sizeof(fluid_voice_t*))); + const auto id = static_cast(_alloca(poly * sizeof(unsigned int))); +#endif fluid_synth_get_voicelist( m_synth, voices, poly, -1 ); for( int i = 0; i < poly; ++i ) { @@ -762,8 +810,8 @@ void Sf2Instrument::play( sampleFrame * _working_buffer ) NotePlayHandle * currentNote = m_playingNotes[0]; for( int i = 1; i < m_playingNotes.size(); ++i ) { - Sf2PluginData * currentData = static_cast( currentNote->m_pluginData ); - Sf2PluginData * iData = static_cast( m_playingNotes[i]->m_pluginData ); + auto currentData = static_cast(currentNote->m_pluginData); + auto iData = static_cast(m_playingNotes[i]->m_pluginData); if( currentData->offset > iData->offset ) { currentNote = m_playingNotes[i]; @@ -772,7 +820,7 @@ void Sf2Instrument::play( sampleFrame * _working_buffer ) // process the current note: // first see if we're synced in frame count - Sf2PluginData * currentData = static_cast( currentNote->m_pluginData ); + auto currentData = static_cast(currentNote->m_pluginData); if( currentData->offset > currentFrame ) { renderFrames( currentData->offset - currentFrame, _working_buffer + currentFrame ); @@ -856,7 +904,7 @@ void Sf2Instrument::renderFrames( f_cnt_t frames, sampleFrame * buf ) void Sf2Instrument::deleteNotePluginData( NotePlayHandle * _n ) { - Sf2PluginData * pluginData = static_cast( _n->m_pluginData ); + auto pluginData = static_cast(_n->m_pluginData); if( ! pluginData->noteOffSent ) // if we for some reason haven't noteoffed the note before it gets deleted, // do it here { @@ -874,15 +922,16 @@ void Sf2Instrument::deleteNotePluginData( NotePlayHandle * _n ) -PluginView * Sf2Instrument::instantiateView( QWidget * _parent ) +gui::PluginView * Sf2Instrument::instantiateView( QWidget * _parent ) { - return new Sf2InstrumentView( this, _parent ); + return new gui::Sf2InstrumentView( this, _parent ); } - +namespace gui +{ class Sf2Knob : public Knob @@ -903,37 +952,36 @@ Sf2InstrumentView::Sf2InstrumentView( Instrument * _instrument, QWidget * _paren // QVBoxLayout * vl = new QVBoxLayout( this ); // QHBoxLayout * hl = new QHBoxLayout(); - Sf2Instrument* k = castModel(); + auto k = castModel(); - connect( &k->m_bankNum, SIGNAL( dataChanged() ), this, SLOT( updatePatchName() ) ); - connect( &k->m_patchNum, SIGNAL( dataChanged() ), this, SLOT( updatePatchName() ) ); + connect(&k->m_bankNum, SIGNAL(dataChanged()), this, SLOT(updatePatchName())); + connect(&k->m_patchNum, SIGNAL(dataChanged()), this, SLOT(updatePatchName())); // File Button - m_fileDialogButton = new PixmapButton( this ); - m_fileDialogButton->setCursor( QCursor( Qt::PointingHandCursor ) ); - m_fileDialogButton->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "fileselect_on" ) ); - m_fileDialogButton->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "fileselect_off" ) ); - m_fileDialogButton->move( 217, 107 ); + m_fileDialogButton = new PixmapButton(this); + m_fileDialogButton->setCursor(QCursor(Qt::PointingHandCursor)); + m_fileDialogButton->setActiveGraphic(PLUGIN_NAME::getIconPixmap("fileselect_on")); + m_fileDialogButton->setInactiveGraphic(PLUGIN_NAME::getIconPixmap("fileselect_off")); + m_fileDialogButton->move(217, 107); - connect( m_fileDialogButton, SIGNAL( clicked() ), this, SLOT( showFileDialog() ) ); + connect(m_fileDialogButton, SIGNAL(clicked()), this, SLOT(showFileDialog())); m_fileDialogButton->setToolTip(tr("Open SoundFont file")); // Patch Button - m_patchDialogButton = new PixmapButton( this ); - m_patchDialogButton->setCursor( QCursor( Qt::PointingHandCursor ) ); - m_patchDialogButton->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "patches_on" ) ); - m_patchDialogButton->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "patches_off" ) ); - m_patchDialogButton->setEnabled( false ); - m_patchDialogButton->move( 217, 125 ); + m_patchDialogButton = new PixmapButton(this); + m_patchDialogButton->setCursor(QCursor(Qt::PointingHandCursor)); + m_patchDialogButton->setActiveGraphic(PLUGIN_NAME::getIconPixmap("patches_on")); + m_patchDialogButton->setInactiveGraphic(PLUGIN_NAME::getIconPixmap("patches_off")); + m_patchDialogButton->setEnabled(false); + m_patchDialogButton->move(217, 125); - connect( m_patchDialogButton, SIGNAL( clicked() ), this, SLOT( showPatchDialog() ) ); + connect(m_patchDialogButton, SIGNAL(clicked()), this, SLOT(showPatchDialog())); m_patchDialogButton->setToolTip(tr("Choose patch")); - // LCDs - m_bankNumLcd = new LcdSpinBox( 3, "21pink", this ); + m_bankNumLcd = new LcdSpinBox(3, "21pink", this); m_bankNumLcd->move(131, 62); // m_bankNumLcd->addTextForValue( -1, "---" ); // m_bankNumLcd->setEnabled( false ); @@ -1050,16 +1098,9 @@ Sf2InstrumentView::Sf2InstrumentView( Instrument * _instrument, QWidget * _paren -Sf2InstrumentView::~Sf2InstrumentView() -{ -} - - - - void Sf2InstrumentView::modelChanged() { - Sf2Instrument * k = castModel(); + auto k = castModel(); m_bankNumLcd->setModel( &k->m_bankNum ); m_patchNumLcd->setModel( &k->m_patchNum ); @@ -1090,7 +1131,7 @@ void Sf2InstrumentView::modelChanged() void Sf2InstrumentView::updateFilename() { - Sf2Instrument * i = castModel(); + auto i = castModel(); QFontMetrics fm( m_filenameLabel->font() ); QString file = i->m_filename.endsWith( ".sf2", Qt::CaseInsensitive ) ? i->m_filename.left( i->m_filename.length() - 4 ) : @@ -1110,7 +1151,7 @@ void Sf2InstrumentView::updateFilename() void Sf2InstrumentView::updatePatchName() { - Sf2Instrument * i = castModel(); + auto i = castModel(); QFontMetrics fm( font() ); QString patch = i->getCurrentPatchName(); m_patchLabel->setText( fm.elidedText( patch, Qt::ElideLeft, m_patchLabel->width() ) ); @@ -1132,7 +1173,7 @@ void Sf2InstrumentView::invalidateFile() void Sf2InstrumentView::showFileDialog() { - Sf2Instrument * k = castModel(); + auto k = castModel(); FileDialog ofd( nullptr, tr( "Open SoundFont file" ) ); ofd.setFileMode( FileDialog::ExistingFiles ); @@ -1172,7 +1213,7 @@ void Sf2InstrumentView::showFileDialog() void Sf2InstrumentView::showPatchDialog() { - Sf2Instrument * k = castModel(); + auto k = castModel(); PatchesDialog pd( this ); @@ -1182,6 +1223,7 @@ void Sf2InstrumentView::showPatchDialog() } +} // namespace gui extern "C" { @@ -1191,5 +1233,7 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *m, void * ) { return new Sf2Instrument( static_cast( m ) ); } - } + + +} // namespace lmms diff --git a/plugins/Sf2Player/Sf2Player.h b/plugins/Sf2Player/Sf2Player.h index aeea1a553..5a88d0f95 100644 --- a/plugins/Sf2Player/Sf2Player.h +++ b/plugins/Sf2Player/Sf2Player.h @@ -36,16 +36,24 @@ #include "LcdSpinBox.h" #include "MemoryManager.h" -class Sf2InstrumentView; -class Sf2Font; -class Knob; -class NotePlayHandle; -class PixmapButton; - -class PatchesDialog; class QLabel; +namespace lmms +{ + + +class Sf2Font; struct Sf2PluginData; +class NotePlayHandle; + +namespace gui +{ +class Knob; +class PixmapButton; +class Sf2InstrumentView; +class PatchesDialog; +} // namespace gui + class Sf2Instrument : public Instrument { @@ -55,35 +63,35 @@ class Sf2Instrument : public Instrument public: Sf2Instrument( InstrumentTrack * _instrument_track ); - virtual ~Sf2Instrument(); + ~Sf2Instrument() override; - virtual void play( sampleFrame * _working_buffer ); + void play( sampleFrame * _working_buffer ) override; - virtual void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ); - virtual void deleteNotePluginData( NotePlayHandle * _n ); + void playNote( NotePlayHandle * _n, + sampleFrame * _working_buffer ) override; + void deleteNotePluginData( NotePlayHandle * _n ) override; - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); + void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; - virtual void loadFile( const QString & _file ); + void loadFile( const QString & _file ) override; - virtual AutomatableModel * childModel( const QString & _modelName ); + AutomatableModel * childModel( const QString & _modelName ) override; - virtual QString nodeName() const; + QString nodeName() const override; - virtual f_cnt_t desiredReleaseFrames() const + f_cnt_t desiredReleaseFrames() const override { return 0; } - virtual Flags flags() const + Flags flags() const override { return IsSingleStreamed; } - virtual PluginView * instantiateView( QWidget * _parent ); + gui::PluginView* instantiateView( QWidget * _parent ) override; QString getCurrentPatchName(); @@ -103,7 +111,7 @@ public slots: void updateChorusOn(); void updateChorus(); void updateGain(); - + void updateTuning(); private: static QMutex s_fontsMutex; @@ -127,14 +135,14 @@ private: QMutex m_synthMutex; QMutex m_loadMutex; - int m_notesRunning[128]; + std::array m_notesRunning = {}; sample_rate_t m_internalSampleRate; int m_lastMidiPitch; int m_lastMidiPitchRange; int m_channel; - LcdSpinBoxModel m_bankNum; - LcdSpinBoxModel m_patchNum; + gui::LcdSpinBoxModel m_bankNum; + gui::LcdSpinBoxModel m_patchNum; FloatModel m_gain; @@ -159,7 +167,7 @@ private: void noteOff( Sf2PluginData * n ); void renderFrames( f_cnt_t frames, sampleFrame * buf ); - friend class Sf2InstrumentView; + friend class gui::Sf2InstrumentView; signals: void fileLoading(); @@ -185,6 +193,9 @@ public: }; +namespace gui +{ + class Sf2InstrumentView : public InstrumentViewFixedSize { @@ -192,10 +203,10 @@ class Sf2InstrumentView : public InstrumentViewFixedSize public: Sf2InstrumentView( Instrument * _instrument, QWidget * _parent ); - virtual ~Sf2InstrumentView(); + ~Sf2InstrumentView() override = default; private: - virtual void modelChanged(); + void modelChanged() override; PixmapButton * m_fileDialogButton; PixmapButton * m_patchDialogButton; @@ -231,5 +242,8 @@ protected slots: } ; +} // namespace gui + +} // namespace lmms #endif diff --git a/plugins/Sf2Player/fluidsynthshims.h b/plugins/Sf2Player/fluidsynthshims.h index 4302256ba..2ccadce8d 100644 --- a/plugins/Sf2Player/fluidsynthshims.h +++ b/plugins/Sf2Player/fluidsynthshims.h @@ -28,6 +28,7 @@ #include + #if FLUIDSYNTH_VERSION_MAJOR < 2 inline const char* fluid_preset_get_name(fluid_preset_t* preset) diff --git a/plugins/Sfxr/Sfxr.cpp b/plugins/Sfxr/Sfxr.cpp index cdce50430..d97217446 100644 --- a/plugins/Sfxr/Sfxr.cpp +++ b/plugins/Sfxr/Sfxr.cpp @@ -52,12 +52,16 @@ float frnd(float range) #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT sfxr_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "sfxr", QT_TRANSLATE_NOOP( "PluginBrowser", "LMMS port of sfxr" ), @@ -84,14 +88,6 @@ SfxrSynth::SfxrSynth( const SfxrInstrument * s ): -SfxrSynth::~SfxrSynth() -{ - -} - - - - void SfxrSynth::resetSample( bool restart ) { if(!restart) @@ -144,11 +140,12 @@ void SfxrSynth::resetSample( bool restart ) if(s->m_phaserSweepModel.value()<0.0f) fdphase=-fdphase; iphase=abs((int)fphase); ipp=0; - for(int i=0;i<1024;i++) - phaser_buffer[i]=0.0f; - - for(int i=0;i<32;i++) - noise_buffer[i]=frnd(2.0f)-1.0f; + + phaser_buffer.fill(0.0f); + for (auto& noiseSample : noise_buffer) + { + noiseSample = frnd(2.0f) - 1.0f; + } rep_time=0; rep_limit=(int)(pow(1.0f-s->m_repeatSpeedModel.value(), 2.0f)*20000+32); @@ -243,8 +240,10 @@ void SfxrSynth::update( sampleFrame * buffer, const int32_t frameNum ) // phase=0; phase%=period; if(s->m_waveFormModel.value()==3) - for(int i=0;i<32;i++) - noise_buffer[i]=frnd(2.0f)-1.0f; + for (auto& noiseSample : noise_buffer) + { + noiseSample = frnd(2.0f) - 1.0f; + } } // base waveform float fp=(float)phase/period; @@ -358,13 +357,6 @@ SfxrInstrument::SfxrInstrument( InstrumentTrack * _instrument_track ) : -SfxrInstrument::~SfxrInstrument() -{ -} - - - - void SfxrInstrument::saveSettings( QDomDocument & _doc, QDomElement & _this ) { _this.setAttribute( "version", "1" ); @@ -475,7 +467,7 @@ void SfxrInstrument::playNote( NotePlayHandle * _n, sampleFrame * _working_buffe // debug code // qDebug( "pFN %d", pitchedFrameNum ); - sampleFrame * pitchedBuffer = new sampleFrame[pitchedFrameNum]; + auto pitchedBuffer = new sampleFrame[pitchedFrameNum]; static_cast(_n->m_pluginData)->update( pitchedBuffer, pitchedFrameNum ); for( fpp_t i=0; i(); + auto s = castModel(); m_attKnob->setModel( &s->m_attModel ); m_holdKnob->setModel( &s->m_holdModel ); @@ -756,7 +751,7 @@ void SfxrInstrumentView::modelChanged() void SfxrInstrumentView::genPickup() { - SfxrInstrument * s = castModel(); + auto s = castModel(); s->resetModels(); s->m_startFreqModel.setValue( 0.4f+frnd(0.5f) ); s->m_attModel.setValue( 0.0f ); @@ -776,7 +771,7 @@ void SfxrInstrumentView::genPickup() void SfxrInstrumentView::genLaser() { - SfxrInstrument * s = castModel(); + auto s = castModel(); s->resetModels(); s->m_waveFormModel.setValue( rnd(2) ); @@ -835,7 +830,7 @@ void SfxrInstrumentView::genLaser() void SfxrInstrumentView::genExplosion() { - SfxrInstrument * s = castModel(); + auto s = castModel(); s->resetModels(); s->m_waveFormModel.setValue( 3 ); @@ -890,7 +885,7 @@ void SfxrInstrumentView::genExplosion() void SfxrInstrumentView::genPowerup() { - SfxrInstrument * s = castModel(); + auto s = castModel(); s->resetModels(); if(rnd(1)) @@ -924,7 +919,7 @@ void SfxrInstrumentView::genPowerup() void SfxrInstrumentView::genHit() { - SfxrInstrument * s = castModel(); + auto s = castModel(); s->resetModels(); s->m_waveFormModel.setValue( rnd(2) ); @@ -954,7 +949,7 @@ void SfxrInstrumentView::genHit() void SfxrInstrumentView::genJump() { - SfxrInstrument * s = castModel(); + auto s = castModel(); s->resetModels(); s->m_waveFormModel.setValue( 0 ); @@ -984,7 +979,7 @@ void SfxrInstrumentView::genJump() void SfxrInstrumentView::genBlip() { - SfxrInstrument * s = castModel(); + auto s = castModel(); s->resetModels(); s->m_waveFormModel.setValue( rnd(1) ); @@ -1006,7 +1001,7 @@ void SfxrInstrumentView::genBlip() void SfxrInstrumentView::randomize() { - SfxrInstrument * s = castModel(); + auto s = castModel(); s->m_startFreqModel.setValue( pow(frnd(2.0f)-1.0f, 2.0f) ); if(rnd(1)) @@ -1067,7 +1062,7 @@ void SfxrInstrumentView::randomize() void SfxrInstrumentView::mutate() { - SfxrInstrument * s = castModel(); + auto s = castModel(); if(rnd(1)) s->m_startFreqModel.setValue( s->m_startFreqModel.value()+frnd(0.1f)-0.05f ); // if(rnd(1)) s->m_minFreqModel.setValue( s->m_minFreqModel.value()+frnd(0.1f)-0.05f ); @@ -1107,7 +1102,7 @@ void SfxrInstrumentView::mutate() void SfxrInstrumentView::previewSound() { - SfxrInstrument* s = castModel(); + auto s = castModel(); InstrumentTrack* it = s->instrumentTrack(); it->silenceAllNotes(); it->processInEvent( MidiEvent( MidiNoteOn, 0, it->baseNoteModel()->value(), MidiDefaultVelocity ) ); @@ -1115,6 +1110,9 @@ void SfxrInstrumentView::previewSound() +} // namespace gui + + extern "C" { @@ -1128,5 +1126,4 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* m, void* ) } - - +} // namespace lmms diff --git a/plugins/Sfxr/Sfxr.h b/plugins/Sfxr/Sfxr.h index a8ce12efe..632ccfebd 100644 --- a/plugins/Sfxr/Sfxr.h +++ b/plugins/Sfxr/Sfxr.h @@ -33,6 +33,9 @@ #include "InstrumentView.h" #include "MemoryManager.h" +namespace lmms +{ + enum SfxrWaves { @@ -60,11 +63,15 @@ const int KNOB_BLOCK_SIZE_Y = 40; +class SfxrInstrument; +namespace gui +{ class automatableButtonGroup; class Knob; class PixmapButton; -class SfxrInstrument; +class SfxrInstrumentView; +} @@ -73,7 +80,7 @@ class SfxrSynth MM_OPERATORS public: SfxrSynth( const SfxrInstrument * s ); - virtual ~SfxrSynth(); + virtual ~SfxrSynth() = default; void resetSample( bool restart ); void update( sampleFrame * buffer, const int32_t frameNum ); @@ -98,7 +105,7 @@ private: float fphase; float fdphase; int iphase; - float phaser_buffer[1024]; + std::array phaser_buffer; int ipp; float noise_buffer[32]; float fltp; @@ -133,7 +140,7 @@ public: { } /* purpose: prevent the initial value of the model from being changed */ - virtual void loadSettings( const QDomElement& element, const QString& name = QString( "value" ) ) + void loadSettings( const QDomElement& element, const QString& name = QString( "value" ) ) override { float oldInitValue = initValue(); FloatModel::loadSettings(element, name); @@ -154,7 +161,7 @@ public: { } /* purpose: prevent the initial value of the model from being changed */ - virtual void loadSettings( const QDomElement& element, const QString& name = QString( "value" ) ) + void loadSettings( const QDomElement& element, const QString& name = QString( "value" ) ) override { float oldInitValue = initValue(); FloatModel::loadSettings(element, name); @@ -169,18 +176,18 @@ class SfxrInstrument : public Instrument Q_OBJECT public: SfxrInstrument(InstrumentTrack * _instrument_track ); - virtual ~SfxrInstrument(); + ~SfxrInstrument() override = default; - virtual void playNote( NotePlayHandle * _n, sampleFrame * _working_buffer ); - virtual void deleteNotePluginData( NotePlayHandle * _n ); + void playNote( NotePlayHandle * _n, sampleFrame * _working_buffer ) override; + void deleteNotePluginData( NotePlayHandle * _n ) override; - virtual void saveSettings( QDomDocument & _doc, - QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); + void saveSettings( QDomDocument & _doc, + QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; - virtual QString nodeName() const; + QString nodeName() const override; - virtual PluginView * instantiateView( QWidget * _parent ); + gui::PluginView* instantiateView( QWidget * _parent ) override; void resetModels(); @@ -217,11 +224,14 @@ private: IntModel m_waveFormModel; - friend class SfxrInstrumentView; + friend class gui::SfxrInstrumentView; friend class SfxrSynth; }; +namespace gui +{ + class SfxrInstrumentView : public InstrumentViewFixedSize { @@ -230,7 +240,7 @@ public: SfxrInstrumentView( Instrument * _instrument, QWidget * _parent ); - virtual ~SfxrInstrumentView() {}; + ~SfxrInstrumentView() override = default; protected slots: void genPickup(); @@ -246,7 +256,7 @@ protected slots: void previewSound(); private: - virtual void modelChanged(); + void modelChanged() override; Knob * m_attKnob; //Attack Time Knob * m_holdKnob; //Sustain Time @@ -300,5 +310,8 @@ private: }; +} // namespace gui + +} // namespace lmms #endif diff --git a/plugins/Sid/SidInstrument.cpp b/plugins/Sid/SidInstrument.cpp index 32b0d7a24..6e7473492 100644 --- a/plugins/Sid/SidInstrument.cpp +++ b/plugins/Sid/SidInstrument.cpp @@ -3,7 +3,7 @@ * * Copyright (c) 2008 Csaba Hruska * Attila Herman - * + * * This file is part of LMMS - https://lmms.io * * This program is free software; you can redistribute it and/or @@ -42,28 +42,32 @@ #include "embed.h" #include "plugin_export.h" +namespace lmms +{ + + #define C64_PAL_CYCLES_PER_SEC 985248 #define NUMSIDREGS 0x19 #define SIDWRITEDELAY 9 // lda $xxxx,x 4 cycles, sta $d400,x 5 cycles #define SIDWAVEDELAY 4 // and $xxxx,x 4 cycles extra -unsigned char sidorder[] = +auto sidorder = std::array {0x15,0x16,0x18,0x17, 0x05,0x06,0x02,0x03,0x00,0x01,0x04, 0x0c,0x0d,0x09,0x0a,0x07,0x08,0x0b, 0x13,0x14,0x10,0x11,0x0e,0x0f,0x12}; -static const char *attackTime[16] = { "2 ms", "8 ms", "16 ms", "24 ms", +static auto attackTime = std::array{ "2 ms", "8 ms", "16 ms", "24 ms", "38 ms", "56 ms", "68 ms", "80 ms", "100 ms", "250 ms", "500 ms", "800 ms", "1 s", "3 s", "5 s", "8 s" }; -static const char *decRelTime[16] = { "6 ms", "24 ms", "48 ms", "72 ms", +static auto decRelTime = std::array{ "6 ms", "24 ms", "48 ms", "72 ms", "114 ms", "168 ms", "204 ms", "240 ms", "300 ms", "750 ms", "1.5 s", "2.4 s", "3 s", "9 s", "15 s", "24 s" }; // release time time in ms -static const int relTime[16] = { 6, 24, 48, 72, 114, 168, 204, 240, 300, 750, +static const auto relTime = std::array{ 6, 24, 48, 72, 114, 168, 204, 240, 300, 750, 1500, 2400, 3000, 9000, 15000, 24000 }; @@ -71,7 +75,7 @@ extern "C" { Plugin::Descriptor PLUGIN_EXPORT sid_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "SID", QT_TRANSLATE_NOOP( "PluginBrowser", "Emulation of the MOS6581 and MOS8580 " "SID.\nThis chip was used in the Commodore 64 computer." ), @@ -112,18 +116,13 @@ VoiceObject::VoiceObject( Model * _parent, int _idx ) : } -VoiceObject::~VoiceObject() -{ -} - - SidInstrument::SidInstrument( InstrumentTrack * _instrument_track ) : Instrument( _instrument_track, &sid_plugin_descriptor ), - // filter + // filter m_filterFCModel( 1024.0f, 0.0f, 2047.0f, 1.0f, this, tr( "Cutoff frequency" ) ), m_filterResonanceModel( 8.0f, 0.0f, 15.0f, 1.0f, this, tr( "Resonance" ) ), m_filterModeModel( LowPass, 0, NumFilterTypes-1, this, tr( "Filter type" )), - + // misc m_voice3OffModel( false, this, tr( "Voice 3 off" ) ), m_volumeModel( 15.0f, 0.0f, 15.0f, 1.0f, this, tr( "Volume" ) ), @@ -136,11 +135,6 @@ SidInstrument::SidInstrument( InstrumentTrack * _instrument_track ) : } -SidInstrument::~SidInstrument() -{ -} - - void SidInstrument::saveSettings( QDomDocument & _doc, QDomElement & _this ) { @@ -173,11 +167,11 @@ void SidInstrument::saveSettings( QDomDocument & _doc, _doc, _this, "test" + is ); } - // filter + // filter m_filterFCModel.saveSettings( _doc, _this, "filterFC" ); m_filterResonanceModel.saveSettings( _doc, _this, "filterResonance" ); m_filterModeModel.saveSettings( _doc, _this, "filterMode" ); - + // misc m_voice3OffModel.saveSettings( _doc, _this, "voice3Off" ); m_volumeModel.saveSettings( _doc, _this, "volume" ); @@ -206,12 +200,12 @@ void SidInstrument::loadSettings( const QDomElement & _this ) m_voice[i]->m_filteredModel.loadSettings( _this, "filtered" + is ); m_voice[i]->m_testModel.loadSettings( _this, "test" + is ); } - - // filter + + // filter m_filterFCModel.loadSettings( _this, "filterFC" ); m_filterResonanceModel.loadSettings( _this, "filterResonance" ); m_filterModeModel.loadSettings( _this, "filterMode" ); - + // misc m_voice3OffModel.loadSettings( _this, "voice3Off" ); m_volumeModel.loadSettings( _this, "volume" ); @@ -233,10 +227,10 @@ f_cnt_t SidInstrument::desiredReleaseFrames() const { const float samplerate = Engine::audioEngine()->processingSampleRate(); int maxrel = 0; - for( int i = 0 ; i < 3 ; ++i ) + for (const auto& voice : m_voice) { - if( maxrel < m_voice[i]->m_releaseModel.value() ) - maxrel = (int)m_voice[i]->m_releaseModel.value(); + if( maxrel < voice->m_releaseModel.value() ) + maxrel = (int)voice->m_releaseModel.value(); } return f_cnt_t( float(relTime[maxrel])*samplerate/1000.0 ); @@ -323,12 +317,12 @@ void SidInstrument::playNote( NotePlayHandle * _n, SID *sid = static_cast( _n->m_pluginData ); int delta_t = clockrate * frames / samplerate + 4; // avoid variable length array for msvc compat - short* buf = reinterpret_cast(_working_buffer + offset); - unsigned char sidreg[NUMSIDREGS]; + auto buf = reinterpret_cast(_working_buffer + offset); + auto sidreg = std::array{}; - for (int c = 0; c < NUMSIDREGS; c++) + for (auto& reg : sidreg) { - sidreg[c] = 0x00; + reg = 0x00; } if( (ChipModel)m_chipModel.value() == sidMOS6581 ) @@ -360,7 +354,7 @@ void SidInstrument::playNote( NotePlayHandle * _n, sidreg[base+1] = (data16>>8)&0x00FF; // pw data16 = (int)m_voice[i]->m_pulseWidthModel.value(); - + sidreg[base+2] = data16&0x00FF; sidreg[base+3] = (data16>>8)&0x000F; // control: wave form, (test), ringmod, sync, gate @@ -369,7 +363,7 @@ void SidInstrument::playNote( NotePlayHandle * _n, data8 += m_voice[i]->m_ringModModel.value()?4:0; data8 += m_voice[i]->m_testModel.value()?8:0; switch( m_voice[i]->m_waveFormModel.value() ) - { + { default: break; case VoiceObject::NoiseWave: data8 += 128; break; case VoiceObject::SquareWave: data8 += 64; break; @@ -400,7 +394,7 @@ void SidInstrument::playNote( NotePlayHandle * _n, data16 = (int)m_filterFCModel.value(); sidreg[21] = data16&0x0007; sidreg[22] = (data16>>3)&0x00FF; - + // res, filt ex,3,2,1 data16 = (int)m_filterResonanceModel.value(); data8 = (data16&0x000F)<<4; @@ -415,7 +409,7 @@ void SidInstrument::playNote( NotePlayHandle * _n, data8 += m_voice3OffModel.value()?128:0; switch( m_filterModeModel.value() ) - { + { default: break; case LowPass: data8 += 16; break; case BandPass: data8 += 32; break; @@ -423,8 +417,8 @@ void SidInstrument::playNote( NotePlayHandle * _n, } sidreg[24] = data8&0x00FF; - - int num = sid_fillbuffer(sidreg, sid,delta_t,buf, frames); + + int num = sid_fillbuffer(sidreg.data(), sid, delta_t, buf, frames); if(num!=frames) printf("!!!Not enough samples\n"); @@ -452,13 +446,16 @@ void SidInstrument::deleteNotePluginData( NotePlayHandle * _n ) -PluginView * SidInstrument::instantiateView( QWidget * _parent ) +gui::PluginView* SidInstrument::instantiateView( QWidget * _parent ) { - return( new SidInstrumentView( this, _parent ) ); + return( new gui::SidInstrumentView( this, _parent ) ); } +namespace gui +{ + class sidKnob : public Knob { @@ -501,19 +498,19 @@ SidInstrumentView::SidInstrumentView( Instrument * _instrument, m_cutKnob->setHintText( tr( "Cutoff frequency:" ), " Hz" ); m_cutKnob->move( 7 + 2*28, 64 ); - PixmapButton * hp_btn = new PixmapButton( this, nullptr ); + auto hp_btn = new PixmapButton(this, nullptr); hp_btn->move( 140, 77 ); hp_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "hpred" ) ); hp_btn->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "hp" ) ); hp_btn->setToolTip(tr("High-pass filter ")); - PixmapButton * bp_btn = new PixmapButton( this, nullptr ); + auto bp_btn = new PixmapButton(this, nullptr); bp_btn->move( 164, 77 ); bp_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "bpred" ) ); bp_btn->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "bp" ) ); bp_btn->setToolTip(tr("Band-pass filter ")); - PixmapButton * lp_btn = new PixmapButton( this, nullptr ); + auto lp_btn = new PixmapButton(this, nullptr); lp_btn->move( 185, 77 ); lp_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "lpred" ) ); lp_btn->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "lp" ) ); @@ -531,13 +528,13 @@ SidInstrumentView::SidInstrumentView( Instrument * _instrument, m_offButton->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "3off" ) ); m_offButton->setToolTip(tr("Voice 3 off ")); - PixmapButton * mos6581_btn = new PixmapButton( this, nullptr ); + auto mos6581_btn = new PixmapButton(this, nullptr); mos6581_btn->move( 170, 59 ); mos6581_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "6581red" ) ); mos6581_btn->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "6581" ) ); mos6581_btn->setToolTip(tr("MOS6581 SID ")); - PixmapButton * mos8580_btn = new PixmapButton( this, nullptr ); + auto mos8580_btn = new PixmapButton(this, nullptr); mos8580_btn->move( 207, 59 ); mos8580_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "8580red" ) ); mos8580_btn->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "8580" ) ); @@ -547,7 +544,7 @@ SidInstrumentView::SidInstrumentView( Instrument * _instrument, m_sidTypeBtnGrp->addButton( mos6581_btn ); m_sidTypeBtnGrp->addButton( mos8580_btn ); - for( int i = 0; i < 3; i++ ) + for( int i = 0; i < 3; i++ ) { Knob *ak = new sidKnob( this ); ak->setHintText( tr("Attack:"), "" ); @@ -573,7 +570,7 @@ SidInstrumentView::SidInstrumentView( Instrument * _instrument, crsk->setHintText( tr("Coarse:"), " semitones" ); crsk->move( 147, 114 + i*50 ); - PixmapButton * pulse_btn = new PixmapButton( this, nullptr ); + auto pulse_btn = new PixmapButton(this, nullptr); pulse_btn->move( 187, 101 + i*50 ); pulse_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "pulsered" ) ); @@ -581,7 +578,7 @@ SidInstrumentView::SidInstrumentView( Instrument * _instrument, PLUGIN_NAME::getIconPixmap( "pulse" ) ); pulse_btn->setToolTip(tr("Pulse wave")); - PixmapButton * triangle_btn = new PixmapButton( this, nullptr ); + auto triangle_btn = new PixmapButton(this, nullptr); triangle_btn->move( 168, 101 + i*50 ); triangle_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "trianglered" ) ); @@ -589,7 +586,7 @@ SidInstrumentView::SidInstrumentView( Instrument * _instrument, PLUGIN_NAME::getIconPixmap( "triangle" ) ); triangle_btn->setToolTip(tr("Triangle wave")); - PixmapButton * saw_btn = new PixmapButton( this, nullptr ); + auto saw_btn = new PixmapButton(this, nullptr); saw_btn->move( 207, 101 + i*50 ); saw_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "sawred" ) ); @@ -597,7 +594,7 @@ SidInstrumentView::SidInstrumentView( Instrument * _instrument, PLUGIN_NAME::getIconPixmap( "saw" ) ); saw_btn->setToolTip(tr("Saw wave")); - PixmapButton * noise_btn = new PixmapButton( this, nullptr ); + auto noise_btn = new PixmapButton(this, nullptr); noise_btn->move( 226, 101 + i*50 ); noise_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "noisered" ) ); @@ -605,15 +602,14 @@ SidInstrumentView::SidInstrumentView( Instrument * _instrument, PLUGIN_NAME::getIconPixmap( "noise" ) ); noise_btn->setToolTip(tr("Noise")); - automatableButtonGroup * wfbg = - new automatableButtonGroup( this ); + auto wfbg = new automatableButtonGroup(this); wfbg->addButton( pulse_btn ); wfbg->addButton( triangle_btn ); wfbg->addButton( saw_btn ); wfbg->addButton( noise_btn ); - PixmapButton * sync_btn = new PixmapButton( this, nullptr ); + auto sync_btn = new PixmapButton(this, nullptr); sync_btn->setCheckable( true ); sync_btn->move( 207, 134 + i*50 ); sync_btn->setActiveGraphic( @@ -622,7 +618,7 @@ SidInstrumentView::SidInstrumentView( Instrument * _instrument, PLUGIN_NAME::getIconPixmap( "sync" ) ); sync_btn->setToolTip(tr("Sync")); - PixmapButton * ringMod_btn = new PixmapButton( this, nullptr ); + auto ringMod_btn = new PixmapButton(this, nullptr); ringMod_btn->setCheckable( true ); ringMod_btn->move( 170, 116 + i*50 ); ringMod_btn->setActiveGraphic( @@ -631,7 +627,7 @@ SidInstrumentView::SidInstrumentView( Instrument * _instrument, PLUGIN_NAME::getIconPixmap( "ring" ) ); ringMod_btn->setToolTip(tr("Ring modulation")); - PixmapButton * filter_btn = new PixmapButton( this, nullptr ); + auto filter_btn = new PixmapButton(this, nullptr); filter_btn->setCheckable( true ); filter_btn->move( 207, 116 + i*50 ); filter_btn->setActiveGraphic( @@ -640,7 +636,7 @@ SidInstrumentView::SidInstrumentView( Instrument * _instrument, PLUGIN_NAME::getIconPixmap( "filter" ) ); filter_btn->setToolTip(tr("Filtered")); - PixmapButton * test_btn = new PixmapButton( this, nullptr ); + auto test_btn = new PixmapButton(this, nullptr); test_btn->setCheckable( true ); test_btn->move( 170, 134 + i*50 ); test_btn->setActiveGraphic( @@ -655,13 +651,9 @@ SidInstrumentView::SidInstrumentView( Instrument * _instrument, } -SidInstrumentView::~SidInstrumentView() -{ -} - void SidInstrumentView::updateKnobHint() { - SidInstrument * k = castModel(); + auto k = castModel(); for( int i = 0; i < 3; ++i ) { @@ -682,7 +674,7 @@ void SidInstrumentView::updateKnobHint() m_releaseModel.value()] ) + ")" ); m_voiceKnobs[i].m_relKnob->setToolTip( decRelTime[(int)k->m_voice[i]->m_releaseModel.value()]); - + m_voiceKnobs[i].m_pwKnob->setHintText( tr( "Pulse width:" )+ " ", " (" + QString::number( (double)k->m_voice[i]-> m_pulseWidthModel.value() / 40.95 ) + "%)" ); @@ -702,7 +694,7 @@ void SidInstrumentView::updateKnobHint() void SidInstrumentView::updateKnobToolTip() { - SidInstrument * k = castModel(); + auto k = castModel(); for( int i = 0; i < 3; ++i ) { m_voiceKnobs[i].m_sustKnob->setToolTip( @@ -722,7 +714,7 @@ void SidInstrumentView::updateKnobToolTip() void SidInstrumentView::modelChanged() { - SidInstrument * k = castModel(); + auto k = castModel(); m_volKnob->setModel( &k->m_volumeModel ); m_resKnob->setModel( &k->m_filterResonanceModel ); @@ -757,22 +749,16 @@ void SidInstrumentView::modelChanged() &k->m_voice[i]->m_testModel ); } - for( int i = 0; i < 3; ++i ) + for (const auto& voice : k->m_voice) { - connect( &k->m_voice[i]->m_attackModel, SIGNAL( dataChanged() ), - this, SLOT( updateKnobHint() ) ); - connect( &k->m_voice[i]->m_decayModel, SIGNAL( dataChanged() ), - this, SLOT( updateKnobHint() ) ); - connect( &k->m_voice[i]->m_releaseModel, SIGNAL( dataChanged() ), - this, SLOT( updateKnobHint() ) ); - connect( &k->m_voice[i]->m_pulseWidthModel, SIGNAL( dataChanged() ), - this, SLOT( updateKnobHint() ) ); - connect( &k->m_voice[i]->m_sustainModel, SIGNAL( dataChanged() ), - this, SLOT( updateKnobToolTip() ) ); - connect( &k->m_voice[i]->m_coarseModel, SIGNAL( dataChanged() ), - this, SLOT( updateKnobToolTip() ) ); + connect(&voice->m_attackModel, SIGNAL(dataChanged()), this, SLOT(updateKnobHint())); + connect(&voice->m_decayModel, SIGNAL(dataChanged()), this, SLOT(updateKnobHint())); + connect(&voice->m_releaseModel, SIGNAL(dataChanged()), this, SLOT(updateKnobHint())); + connect(&voice->m_pulseWidthModel, SIGNAL(dataChanged()), this, SLOT(updateKnobHint())); + connect(&voice->m_sustainModel, SIGNAL(dataChanged()), this, SLOT(updateKnobToolTip())); + connect(&voice->m_coarseModel, SIGNAL(dataChanged()), this, SLOT(updateKnobToolTip())); } - + connect( &k->m_volumeModel, SIGNAL( dataChanged() ), this, SLOT( updateKnobToolTip() ) ); connect( &k->m_filterResonanceModel, SIGNAL( dataChanged() ), @@ -785,7 +771,7 @@ void SidInstrumentView::modelChanged() } - +} // namespace gui extern "C" @@ -801,5 +787,4 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *m, void * ) } - - +} // namespace lmms diff --git a/plugins/Sid/SidInstrument.h b/plugins/Sid/SidInstrument.h index 5f2fa7157..203e52e7b 100644 --- a/plugins/Sid/SidInstrument.h +++ b/plugins/Sid/SidInstrument.h @@ -31,12 +31,19 @@ #include "Instrument.h" #include "InstrumentView.h" +namespace lmms +{ + -class Knob; -class SidInstrumentView; class NotePlayHandle; + +namespace gui +{ +class Knob; class automatableButtonGroup; +class SidInstrumentView; class PixmapButton; +} class VoiceObject : public Model { @@ -51,7 +58,7 @@ public: NumWaveShapes }; VoiceObject( Model * _parent, int _idx ); - virtual ~VoiceObject(); + ~VoiceObject() override = default; private: @@ -68,7 +75,7 @@ private: BoolModel m_testModel; friend class SidInstrument; - friend class SidInstrumentView; + friend class gui::SidInstrumentView; } ; class SidInstrument : public Instrument @@ -90,21 +97,21 @@ public: SidInstrument( InstrumentTrack * _instrument_track ); - virtual ~SidInstrument(); + ~SidInstrument() override = default; - virtual void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ); - virtual void deleteNotePluginData( NotePlayHandle * _n ); + void playNote( NotePlayHandle * _n, + sampleFrame * _working_buffer ) override; + void deleteNotePluginData( NotePlayHandle * _n ) override; - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); + void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; - virtual QString nodeName() const; + QString nodeName() const override; - virtual f_cnt_t desiredReleaseFrames() const; + f_cnt_t desiredReleaseFrames() const override; - virtual PluginView * instantiateView( QWidget * _parent ); + gui::PluginView* instantiateView( QWidget * _parent ) override; /*public slots: @@ -126,21 +133,24 @@ private: IntModel m_chipModel; - friend class SidInstrumentView; + friend class gui::SidInstrumentView; } ; +namespace gui +{ + class SidInstrumentView : public InstrumentViewFixedSize { Q_OBJECT public: SidInstrumentView( Instrument * _instrument, QWidget * _parent ); - virtual ~SidInstrumentView(); + ~SidInstrumentView() override = default; private: - virtual void modelChanged(); + void modelChanged() override; automatableButtonGroup * m_passBtnGrp; automatableButtonGroup * m_sidTypeBtnGrp; @@ -171,9 +181,7 @@ private: m_testButton( testb ) { } - voiceKnobs() - { - } + voiceKnobs() = default; Knob * m_attKnob; Knob * m_decKnob; Knob * m_sustKnob; @@ -200,4 +208,8 @@ protected slots: } ; +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/SpectrumAnalyzer/Analyzer.cpp b/plugins/SpectrumAnalyzer/Analyzer.cpp index e7b23d7b0..de4ac8c68 100644 --- a/plugins/SpectrumAnalyzer/Analyzer.cpp +++ b/plugins/SpectrumAnalyzer/Analyzer.cpp @@ -36,6 +36,9 @@ #include "lmms_basics.h" #include "plugin_export.h" +namespace lmms +{ + extern "C" { Plugin::Descriptor PLUGIN_EXPORT analyzer_plugin_descriptor = @@ -116,3 +119,5 @@ extern "C" { } } + +} // namespace lmms diff --git a/plugins/SpectrumAnalyzer/Analyzer.h b/plugins/SpectrumAnalyzer/Analyzer.h index 57a11d30a..5be1f9ba8 100644 --- a/plugins/SpectrumAnalyzer/Analyzer.h +++ b/plugins/SpectrumAnalyzer/Analyzer.h @@ -34,13 +34,16 @@ #include "SaControls.h" #include "SaProcessor.h" +namespace lmms +{ + //! Top level class; handles LMMS interface and feeds data to the data processor. class Analyzer : public Effect { public: Analyzer(Model *parent, const Descriptor::SubPluginFeatures::Key *key); - virtual ~Analyzer(); + ~Analyzer() override; bool processAudioBuffer(sampleFrame *buffer, const fpp_t frame_count) override; EffectControls *controls() override {return &m_controls;} @@ -70,5 +73,8 @@ private: #endif }; + +} // namespace lmms + #endif // ANALYZER_H diff --git a/plugins/SpectrumAnalyzer/DataprocLauncher.h b/plugins/SpectrumAnalyzer/DataprocLauncher.h index d91e0bedf..4325284c9 100644 --- a/plugins/SpectrumAnalyzer/DataprocLauncher.h +++ b/plugins/SpectrumAnalyzer/DataprocLauncher.h @@ -30,6 +30,10 @@ #include "SaProcessor.h" #include "LocklessRingBuffer.h" +namespace lmms +{ + + class DataprocLauncher : public QThread { public: @@ -49,4 +53,7 @@ private: LocklessRingBuffer *m_inputBuffer; }; + +} // namespace lmms + #endif // DATAPROCLAUNCHER_H diff --git a/plugins/SpectrumAnalyzer/SaControls.cpp b/plugins/SpectrumAnalyzer/SaControls.cpp index 45490f6b3..1ebfcdca3 100644 --- a/plugins/SpectrumAnalyzer/SaControls.cpp +++ b/plugins/SpectrumAnalyzer/SaControls.cpp @@ -29,6 +29,9 @@ #include "Analyzer.h" #include "SaControlsDialog.h" +namespace lmms +{ + SaControls::SaControls(Analyzer *effect) : EffectControls(effect), @@ -121,9 +124,9 @@ SaControls::SaControls(Analyzer *effect) : // Create the SaControlDialog widget which handles display of GUI elements. -EffectControlDialog* SaControls::createView() +gui::EffectControlDialog* SaControls::createView() { - return new SaControlsDialog(this, m_effect->getProcessor()); + return new gui::SaControlsDialog(this, m_effect->getProcessor()); } @@ -174,3 +177,6 @@ void SaControls::saveSettings(QDomDocument &doc, QDomElement &parent) m_zeroPaddingModel.saveSettings(doc, parent, "ZeroPadding"); } + + +} // namespace lmms diff --git a/plugins/SpectrumAnalyzer/SaControls.h b/plugins/SpectrumAnalyzer/SaControls.h index d75156f74..48d8ee96e 100644 --- a/plugins/SpectrumAnalyzer/SaControls.h +++ b/plugins/SpectrumAnalyzer/SaControls.h @@ -30,18 +30,28 @@ //#define SA_DEBUG 1 // define SA_DEBUG to enable performance measurements +namespace lmms +{ + class Analyzer; +namespace gui +{ +class SaControlsDialog; +class SaSpectrumView; +class SaWaterfallView; +} + // Holds all the configuration values class SaControls : public EffectControls { Q_OBJECT public: explicit SaControls(Analyzer* effect); - virtual ~SaControls() {} + ~SaControls() override = default; - EffectControlDialog* createView() override; + gui::EffectControlDialog* createView() override; void saveSettings (QDomDocument& doc, QDomElement& parent) override; void loadSettings (const QDomElement &_this) override; @@ -88,9 +98,13 @@ private: QColor m_colorGrid; //!< color of grid lines QColor m_colorLabels; //!< color of axis labels - friend class SaControlsDialog; - friend class SaSpectrumView; - friend class SaWaterfallView; + friend class gui::SaControlsDialog; + friend class gui::SaSpectrumView; + friend class gui::SaWaterfallView; friend class SaProcessor; }; + + +} // namespace lmms + #endif // SACONTROLS_H diff --git a/plugins/SpectrumAnalyzer/SaControlsDialog.cpp b/plugins/SpectrumAnalyzer/SaControlsDialog.cpp index 7b6adeb1c..c4fc431b1 100644 --- a/plugins/SpectrumAnalyzer/SaControlsDialog.cpp +++ b/plugins/SpectrumAnalyzer/SaControlsDialog.cpp @@ -41,6 +41,10 @@ #include "SaWaterfallView.h" +namespace lmms::gui +{ + + // The entire GUI layout is built here. SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) : EffectControlDialog(controls), @@ -48,15 +52,15 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) m_processor(processor) { // Top level placement of sections is handled by QSplitter widget. - QHBoxLayout *master_layout = new QHBoxLayout; - QSplitter *display_splitter = new QSplitter(Qt::Vertical); + auto master_layout = new QHBoxLayout; + auto display_splitter = new QSplitter(Qt::Vertical); master_layout->addWidget(display_splitter); master_layout->setContentsMargins(2, 6, 2, 8); setLayout(master_layout); // Display splitter top: controls section - QWidget *controls_widget = new QWidget; - QHBoxLayout *controls_layout = new QHBoxLayout; + auto controls_widget = new QWidget; + auto controls_layout = new QHBoxLayout; controls_layout->setContentsMargins(0, 0, 0, 0); controls_widget->setLayout(controls_layout); controls_widget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding); @@ -65,8 +69,8 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) // Basic configuration - QWidget *config_widget = new QWidget; - QGridLayout *config_layout = new QGridLayout; + auto config_widget = new QWidget; + auto config_layout = new QGridLayout; config_widget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); config_widget->setMaximumHeight(m_configHeight); config_widget->setLayout(config_layout); @@ -83,10 +87,12 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) // pause and freeze buttons - PixmapButton *pauseButton = new PixmapButton(this, tr("Pause")); + auto pauseButton = new PixmapButton(this, tr("Pause")); pauseButton->setToolTip(tr("Pause data acquisition")); - QPixmap *pauseOnPixmap = new QPixmap(PLUGIN_NAME::getIconPixmap("play").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - QPixmap *pauseOffPixmap = new QPixmap(PLUGIN_NAME::getIconPixmap("pause").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + auto pauseOnPixmap = new QPixmap( + PLUGIN_NAME::getIconPixmap("play").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + auto pauseOffPixmap = new QPixmap( + PLUGIN_NAME::getIconPixmap("pause").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); pauseOnPixmap->setDevicePixelRatio(devicePixelRatio()); pauseOffPixmap->setDevicePixelRatio(devicePixelRatio()); pauseButton->setActiveGraphic(*pauseOnPixmap); @@ -95,10 +101,12 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) pauseButton->setModel(&controls->m_pauseModel); config_layout->addWidget(pauseButton, 0, 0, 2, 1, Qt::AlignHCenter); - PixmapButton *refFreezeButton = new PixmapButton(this, tr("Reference freeze")); + auto refFreezeButton = new PixmapButton(this, tr("Reference freeze")); refFreezeButton->setToolTip(tr("Freeze current input as a reference / disable falloff in peak-hold mode.")); - QPixmap *freezeOnPixmap = new QPixmap(PLUGIN_NAME::getIconPixmap("freeze").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - QPixmap *freezeOffPixmap = new QPixmap(PLUGIN_NAME::getIconPixmap("freeze_off").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + auto freezeOnPixmap = new QPixmap( + PLUGIN_NAME::getIconPixmap("freeze").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + auto freezeOffPixmap = new QPixmap( + PLUGIN_NAME::getIconPixmap("freeze_off").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); freezeOnPixmap->setDevicePixelRatio(devicePixelRatio()); freezeOffPixmap->setDevicePixelRatio(devicePixelRatio()); refFreezeButton->setActiveGraphic(*freezeOnPixmap); @@ -108,28 +116,28 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) config_layout->addWidget(refFreezeButton, 2, 0, 2, 1, Qt::AlignHCenter); // misc configuration switches - LedCheckBox *waterfallButton = new LedCheckBox(tr("Waterfall"), this); + auto waterfallButton = new LedCheckBox(tr("Waterfall"), this); waterfallButton->setToolTip(tr("Display real-time spectrogram")); waterfallButton->setCheckable(true); waterfallButton->setMinimumSize(70, 12); waterfallButton->setModel(&controls->m_waterfallModel); config_layout->addWidget(waterfallButton, 0, 1); - LedCheckBox *smoothButton = new LedCheckBox(tr("Averaging"), this); + auto smoothButton = new LedCheckBox(tr("Averaging"), this); smoothButton->setToolTip(tr("Enable exponential moving average")); smoothButton->setCheckable(true); smoothButton->setMinimumSize(70, 12); smoothButton->setModel(&controls->m_smoothModel); config_layout->addWidget(smoothButton, 1, 1); - LedCheckBox *stereoButton = new LedCheckBox(tr("Stereo"), this); + auto stereoButton = new LedCheckBox(tr("Stereo"), this); stereoButton->setToolTip(tr("Display stereo channels separately")); stereoButton->setCheckable(true); stereoButton->setMinimumSize(70, 12); stereoButton->setModel(&controls->m_stereoModel); config_layout->addWidget(stereoButton, 2, 1); - LedCheckBox *peakHoldButton = new LedCheckBox(tr("Peak hold"), this); + auto peakHoldButton = new LedCheckBox(tr("Peak hold"), this); peakHoldButton->setToolTip(tr("Display envelope of peak values")); peakHoldButton->setCheckable(true); peakHoldButton->setMinimumSize(70, 12); @@ -137,10 +145,12 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) config_layout->addWidget(peakHoldButton, 3, 1); // frequency: linear / log. switch and range selector - PixmapButton *logXButton = new PixmapButton(this, tr("Logarithmic frequency")); + auto logXButton = new PixmapButton(this, tr("Logarithmic frequency")); logXButton->setToolTip(tr("Switch between logarithmic and linear frequency scale")); - QPixmap *logXOnPixmap = new QPixmap(PLUGIN_NAME::getIconPixmap("x_log").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - QPixmap *logXOffPixmap = new QPixmap(PLUGIN_NAME::getIconPixmap("x_linear").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + auto logXOnPixmap = new QPixmap( + PLUGIN_NAME::getIconPixmap("x_log").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + auto logXOffPixmap = new QPixmap( + PLUGIN_NAME::getIconPixmap("x_linear").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); logXOnPixmap->setDevicePixelRatio(devicePixelRatio()); logXOffPixmap->setDevicePixelRatio(devicePixelRatio()); logXButton->setActiveGraphic(*logXOnPixmap); @@ -149,7 +159,7 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) logXButton->setModel(&controls->m_logXModel); config_layout->addWidget(logXButton, 0, 2, 2, 1, Qt::AlignRight); - ComboBox *freqRangeCombo = new ComboBox(this, tr("Frequency range")); + auto freqRangeCombo = new ComboBox(this, tr("Frequency range")); freqRangeCombo->setToolTip(tr("Frequency range")); freqRangeCombo->setMinimumSize(100, ComboBox::DEFAULT_HEIGHT); freqRangeCombo->setMaximumSize(200, ComboBox::DEFAULT_HEIGHT); @@ -157,10 +167,12 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) config_layout->addWidget(freqRangeCombo, 0, 3, 2, 1); // amplitude: linear / log switch and range selector - PixmapButton *logYButton = new PixmapButton(this, tr("Logarithmic amplitude")); + auto logYButton = new PixmapButton(this, tr("Logarithmic amplitude")); logYButton->setToolTip(tr("Switch between logarithmic and linear amplitude scale")); - QPixmap *logYOnPixmap = new QPixmap(PLUGIN_NAME::getIconPixmap("y_log").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - QPixmap *logYOffPixmap = new QPixmap(PLUGIN_NAME::getIconPixmap("y_linear").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + auto logYOnPixmap = new QPixmap( + PLUGIN_NAME::getIconPixmap("y_log").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + auto logYOffPixmap = new QPixmap( + PLUGIN_NAME::getIconPixmap("y_linear").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); logYOnPixmap->setDevicePixelRatio(devicePixelRatio()); logYOffPixmap->setDevicePixelRatio(devicePixelRatio()); logYButton->setActiveGraphic(*logYOnPixmap); @@ -169,7 +181,7 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) logYButton->setModel(&controls->m_logYModel); config_layout->addWidget(logYButton, 2, 2, 2, 1, Qt::AlignRight); - ComboBox *ampRangeCombo = new ComboBox(this, tr("Amplitude range")); + auto ampRangeCombo = new ComboBox(this, tr("Amplitude range")); ampRangeCombo->setToolTip(tr("Amplitude range")); ampRangeCombo->setMinimumSize(100, ComboBox::DEFAULT_HEIGHT); ampRangeCombo->setMaximumSize(200, ComboBox::DEFAULT_HEIGHT); @@ -177,13 +189,13 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) config_layout->addWidget(ampRangeCombo, 2, 3, 2, 1); // FFT: block size: icon and selector - QLabel *blockSizeLabel = new QLabel("", this); - QPixmap *blockSizeIcon = new QPixmap(PLUGIN_NAME::getIconPixmap("block_size")); + auto blockSizeLabel = new QLabel("", this); + auto blockSizeIcon = new QPixmap(PLUGIN_NAME::getIconPixmap("block_size")); blockSizeIcon->setDevicePixelRatio(devicePixelRatio()); blockSizeLabel->setPixmap(blockSizeIcon->scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); config_layout->addWidget(blockSizeLabel, 0, 4, 2, 1, Qt::AlignRight); - ComboBox *blockSizeCombo = new ComboBox(this, tr("FFT block size")); + auto blockSizeCombo = new ComboBox(this, tr("FFT block size")); blockSizeCombo->setToolTip(tr("FFT block size")); blockSizeCombo->setMinimumSize(100, 22); blockSizeCombo->setMaximumSize(200, 22); @@ -193,13 +205,13 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) connect(&controls->m_blockSizeModel, &ComboBoxModel::dataChanged, [=] {processor->reallocateBuffers();}); // FFT: window type: icon and selector - QLabel *windowLabel = new QLabel("", this); - QPixmap *windowIcon = new QPixmap(PLUGIN_NAME::getIconPixmap("window")); + auto windowLabel = new QLabel("", this); + auto windowIcon = new QPixmap(PLUGIN_NAME::getIconPixmap("window")); windowIcon->setDevicePixelRatio(devicePixelRatio()); windowLabel->setPixmap(windowIcon->scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); config_layout->addWidget(windowLabel, 2, 4, 2, 1, Qt::AlignRight); - ComboBox *windowCombo = new ComboBox(this, tr("FFT window type")); + auto windowCombo = new ComboBox(this, tr("FFT window type")); windowCombo->setToolTip(tr("FFT window type")); windowCombo->setMinimumSize(100, ComboBox::DEFAULT_HEIGHT); windowCombo->setMaximumSize(200, ComboBox::DEFAULT_HEIGHT); @@ -214,8 +226,8 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) // Advanced configuration - QWidget *advanced_widget = new QWidget; - QGridLayout *advanced_layout = new QGridLayout; + auto advanced_widget = new QWidget; + auto advanced_layout = new QGridLayout; advanced_widget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); advanced_widget->setMaximumHeight(m_configHeight); advanced_widget->setLayout(advanced_layout); @@ -224,23 +236,23 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) controls_layout->setStretchFactor(advanced_widget, 10); // Peak envelope resolution - Knob *envelopeResolutionKnob = new Knob(knobSmall_17, this); + auto envelopeResolutionKnob = new Knob(knobSmall_17, this); envelopeResolutionKnob->setModel(&controls->m_envelopeResolutionModel); envelopeResolutionKnob->setLabel(tr("Envelope res.")); envelopeResolutionKnob->setToolTip(tr("Increase envelope resolution for better details, decrease for better GUI performance.")); - envelopeResolutionKnob->setHintText(tr("Draw at most"), tr(" envelope points per pixel")); + envelopeResolutionKnob->setHintText(tr("Maximum number of envelope points drawn per pixel:"), ""); advanced_layout->addWidget(envelopeResolutionKnob, 0, 0, 1, 1, Qt::AlignCenter); // Spectrum graph resolution - Knob *spectrumResolutionKnob = new Knob(knobSmall_17, this); + auto spectrumResolutionKnob = new Knob(knobSmall_17, this); spectrumResolutionKnob->setModel(&controls->m_spectrumResolutionModel); spectrumResolutionKnob->setLabel(tr("Spectrum res.")); spectrumResolutionKnob->setToolTip(tr("Increase spectrum resolution for better details, decrease for better GUI performance.")); - spectrumResolutionKnob->setHintText(tr("Draw at most"), tr(" spectrum points per pixel")); + spectrumResolutionKnob->setHintText(tr("Maximum number of spectrum points drawn per pixel:"), ""); advanced_layout->addWidget(spectrumResolutionKnob, 1, 0, 1, 1, Qt::AlignCenter); // Peak falloff speed - Knob *peakDecayFactorKnob = new Knob(knobSmall_17, this); + auto peakDecayFactorKnob = new Knob(knobSmall_17, this); peakDecayFactorKnob->setModel(&controls->m_peakDecayFactorModel); peakDecayFactorKnob->setLabel(tr("Falloff factor")); peakDecayFactorKnob->setToolTip(tr("Decrease to make peaks fall faster.")); @@ -248,7 +260,7 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) advanced_layout->addWidget(peakDecayFactorKnob, 0, 1, 1, 1, Qt::AlignCenter); // Averaging weight - Knob *averagingWeightKnob = new Knob(knobSmall_17, this); + auto averagingWeightKnob = new Knob(knobSmall_17, this); averagingWeightKnob->setModel(&controls->m_averagingWeightModel); averagingWeightKnob->setLabel(tr("Averaging weight")); averagingWeightKnob->setToolTip(tr("Decrease to make averaging slower and smoother.")); @@ -256,17 +268,17 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) advanced_layout->addWidget(averagingWeightKnob, 1, 1, 1, 1, Qt::AlignCenter); // Waterfall history size - Knob *waterfallHeightKnob = new Knob(knobSmall_17, this); + auto waterfallHeightKnob = new Knob(knobSmall_17, this); waterfallHeightKnob->setModel(&controls->m_waterfallHeightModel); waterfallHeightKnob->setLabel(tr("Waterfall height")); waterfallHeightKnob->setToolTip(tr("Increase to get slower scrolling, decrease to see fast transitions better. Warning: medium CPU usage.")); - waterfallHeightKnob->setHintText(tr("Keep"), tr(" lines")); + waterfallHeightKnob->setHintText(tr("Number of lines to keep:"), ""); advanced_layout->addWidget(waterfallHeightKnob, 0, 2, 1, 1, Qt::AlignCenter); processor->reallocateBuffers(); connect(&controls->m_waterfallHeightModel, &FloatModel::dataChanged, [=] {processor->reallocateBuffers();}); // Waterfall gamma correction - Knob *waterfallGammaKnob = new Knob(knobSmall_17, this); + auto waterfallGammaKnob = new Knob(knobSmall_17, this); waterfallGammaKnob->setModel(&controls->m_waterfallGammaModel); waterfallGammaKnob->setLabel(tr("Waterfall gamma")); waterfallGammaKnob->setToolTip(tr("Decrease to see very weak signals, increase to get better contrast.")); @@ -274,15 +286,15 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) advanced_layout->addWidget(waterfallGammaKnob, 1, 2, 1, 1, Qt::AlignCenter); // FFT window overlap - Knob *windowOverlapKnob = new Knob(knobSmall_17, this); + auto windowOverlapKnob = new Knob(knobSmall_17, this); windowOverlapKnob->setModel(&controls->m_windowOverlapModel); windowOverlapKnob->setLabel(tr("Window overlap")); windowOverlapKnob->setToolTip(tr("Increase to prevent missing fast transitions arriving near FFT window edges. Warning: high CPU usage.")); - windowOverlapKnob->setHintText(tr("Each sample processed"), tr(" times")); + windowOverlapKnob->setHintText(tr("Number of times each sample is processed:"), ""); advanced_layout->addWidget(windowOverlapKnob, 0, 3, 1, 1, Qt::AlignCenter); // FFT zero padding - Knob *zeroPaddingKnob = new Knob(knobSmall_17, this); + auto zeroPaddingKnob = new Knob(knobSmall_17, this); zeroPaddingKnob->setModel(&controls->m_zeroPaddingModel); zeroPaddingKnob->setLabel(tr("Zero padding")); zeroPaddingKnob->setToolTip(tr("Increase to get smoother-looking spectrum. Warning: high CPU usage.")); @@ -293,10 +305,12 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) // Advanced settings button - PixmapButton *advancedButton = new PixmapButton(this, tr("Advanced settings")); + auto advancedButton = new PixmapButton(this, tr("Advanced settings")); advancedButton->setToolTip(tr("Access advanced settings")); - QPixmap *advancedOnPixmap = new QPixmap(PLUGIN_NAME::getIconPixmap("advanced_on").scaled(advButtonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - QPixmap *advancedOffPixmap = new QPixmap(PLUGIN_NAME::getIconPixmap("advanced_off").scaled(advButtonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + auto advancedOnPixmap = new QPixmap(PLUGIN_NAME::getIconPixmap("advanced_on") + .scaled(advButtonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + auto advancedOffPixmap = new QPixmap(PLUGIN_NAME::getIconPixmap("advanced_off") + .scaled(advButtonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); advancedOnPixmap->setDevicePixelRatio(devicePixelRatio()); advancedOffPixmap->setDevicePixelRatio(devicePixelRatio()); advancedButton->setActiveGraphic(*advancedOnPixmap); @@ -350,3 +364,5 @@ QSize SaControlsDialog::sizeHint() const } } + +} // namespace lmms::gui diff --git a/plugins/SpectrumAnalyzer/SaControlsDialog.h b/plugins/SpectrumAnalyzer/SaControlsDialog.h index 8cbb0ecaa..83e12c1bf 100644 --- a/plugins/SpectrumAnalyzer/SaControlsDialog.h +++ b/plugins/SpectrumAnalyzer/SaControlsDialog.h @@ -28,19 +28,26 @@ #include "EffectControlDialog.h" #include "fft_helpers.h" +namespace lmms +{ class SaControls; class SaProcessor; +} + + +namespace lmms::gui +{ + class SaSpectrumView; class SaWaterfallView; - //! Top-level widget holding the configuration GUI and spectrum displays class SaControlsDialog : public EffectControlDialog { Q_OBJECT public: explicit SaControlsDialog(SaControls *controls, SaProcessor *processor); - virtual ~SaControlsDialog() {} + ~SaControlsDialog() override = default; bool isResizable() const override {return true;} QSize sizeHint() const override; @@ -56,4 +63,7 @@ private: SaWaterfallView *m_waterfall; }; + +} // namespace lmms::gui + #endif // SACONTROLSDIALOG_H diff --git a/plugins/SpectrumAnalyzer/SaProcessor.cpp b/plugins/SpectrumAnalyzer/SaProcessor.cpp index 843067988..d7a1dd5fb 100644 --- a/plugins/SpectrumAnalyzer/SaProcessor.cpp +++ b/plugins/SpectrumAnalyzer/SaProcessor.cpp @@ -41,6 +41,9 @@ #include "LocklessRingBuffer.h" #include "SaControls.h" +namespace lmms +{ + SaProcessor::SaProcessor(const SaControls *controls) : m_controls(controls), @@ -196,7 +199,7 @@ void SaProcessor::analyze(LocklessRingBuffer &ring_buffer) if (m_waterfallActive && m_waterfallNotEmpty) { // move waterfall history one line down and clear the top line - QRgb *pixel = (QRgb *)m_history_work.data(); + auto pixel = (QRgb*)m_history_work.data(); std::copy(pixel, pixel + waterfallWidth() * m_waterfallHeight - waterfallWidth(), pixel + waterfallWidth()); @@ -689,3 +692,5 @@ float SaProcessor::yPixelToAmp(float y, unsigned int height) const } } + +} // namespace lmms diff --git a/plugins/SpectrumAnalyzer/SaProcessor.h b/plugins/SpectrumAnalyzer/SaProcessor.h index b331a9c09..66b79788d 100644 --- a/plugins/SpectrumAnalyzer/SaProcessor.h +++ b/plugins/SpectrumAnalyzer/SaProcessor.h @@ -36,6 +36,9 @@ #include "lmms_basics.h" +namespace lmms +{ + template class LocklessRingBuffer; @@ -161,5 +164,9 @@ private: float m_max_execution; #endif }; + + +} // namespace lmms + #endif // SAPROCESSOR_H diff --git a/plugins/SpectrumAnalyzer/SaSpectrumView.cpp b/plugins/SpectrumAnalyzer/SaSpectrumView.cpp index 1feee5cef..0d9c2af87 100644 --- a/plugins/SpectrumAnalyzer/SaSpectrumView.cpp +++ b/plugins/SpectrumAnalyzer/SaSpectrumView.cpp @@ -43,6 +43,9 @@ #include #endif +namespace lmms::gui +{ + SaSpectrumView::SaSpectrumView(SaControls *controls, SaProcessor *processor, QWidget *_parent) : QWidget(_parent), @@ -645,8 +648,8 @@ std::vector> SaSpectrumView::makeLogFreqTics(int low { std::vector> result; int i, j; - int a[] = {10, 20, 50}; // sparse series multipliers - int b[] = {14, 30, 70}; // additional (denser) series + auto a = std::array{10, 20, 50}; // sparse series multipliers + auto b = std::array{14, 30, 70}; // additional (denser) series // generate main steps (powers of 10); use the series to specify smaller steps for (i = 1; i <= high; i *= 10) @@ -843,3 +846,5 @@ void SaSpectrumView::resizeEvent(QResizeEvent *event) m_linearAmpTics = makeLinearAmpTics(m_processor->getAmpRangeMin(), m_processor->getAmpRangeMax()); } + +} // namespace lmms::gui diff --git a/plugins/SpectrumAnalyzer/SaSpectrumView.h b/plugins/SpectrumAnalyzer/SaSpectrumView.h index 70606cc34..e9bb47b1d 100644 --- a/plugins/SpectrumAnalyzer/SaSpectrumView.h +++ b/plugins/SpectrumAnalyzer/SaSpectrumView.h @@ -36,16 +36,25 @@ class QMouseEvent; class QPainter; + +namespace lmms +{ + + class SaControls; class SaProcessor; +namespace gui +{ + + //! Widget that displays a spectrum curve and frequency / amplitude grid class SaSpectrumView : public QWidget { Q_OBJECT public: explicit SaSpectrumView(SaControls *controls, SaProcessor *processor, QWidget *_parent = 0); - virtual ~SaSpectrumView() {} + ~SaSpectrumView() override = default; QSize sizeHint() const override {return QSize(400, 200);} @@ -137,5 +146,11 @@ private: float m_draw_avg; #endif }; + + +} // namespace gui + +} // namespace lmms + #endif // SASPECTRUMVIEW_H diff --git a/plugins/SpectrumAnalyzer/SaWaterfallView.cpp b/plugins/SpectrumAnalyzer/SaWaterfallView.cpp index 36fcbf3bc..598bad725 100644 --- a/plugins/SpectrumAnalyzer/SaWaterfallView.cpp +++ b/plugins/SpectrumAnalyzer/SaWaterfallView.cpp @@ -40,6 +40,10 @@ #include "SaProcessor.h" +namespace lmms::gui +{ + + SaWaterfallView::SaWaterfallView(SaControls *controls, SaProcessor *processor, QWidget *_parent) : QWidget(_parent), m_controls(controls), @@ -341,3 +345,6 @@ void SaWaterfallView::resizeEvent(QResizeEvent *event) { m_timeTics = makeTimeTics(); } + + +} // namespace lmms::gui diff --git a/plugins/SpectrumAnalyzer/SaWaterfallView.h b/plugins/SpectrumAnalyzer/SaWaterfallView.h index b2f815203..5de00d7ad 100644 --- a/plugins/SpectrumAnalyzer/SaWaterfallView.h +++ b/plugins/SpectrumAnalyzer/SaWaterfallView.h @@ -29,10 +29,19 @@ #include -class EffectControlDialog; class QMouseEvent; + +namespace lmms +{ class SaControls; class SaProcessor; +} + +namespace lmms::gui +{ + +class EffectControlDialog; + // Widget that displays a spectrum waterfall (spectrogram) and time labels. class SaWaterfallView : public QWidget @@ -40,7 +49,7 @@ class SaWaterfallView : public QWidget Q_OBJECT public: explicit SaWaterfallView(SaControls *controls, SaProcessor *processor, QWidget *_parent = 0); - virtual ~SaWaterfallView() {} + ~SaWaterfallView() override = default; QSize sizeHint() const override {return QSize(400, 350);} @@ -87,4 +96,8 @@ private: float m_execution_avg; #endif }; + + +} // namespace lmms::gui + #endif // SAWATERFALLVIEW_H diff --git a/plugins/StereoEnhancer/StereoEnhancer.cpp b/plugins/StereoEnhancer/StereoEnhancer.cpp index 6e8661dcb..01e55f2de 100644 --- a/plugins/StereoEnhancer/StereoEnhancer.cpp +++ b/plugins/StereoEnhancer/StereoEnhancer.cpp @@ -28,12 +28,16 @@ #include "embed.h" #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT stereoenhancer_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "StereoEnhancer Effect", QT_TRANSLATE_NOOP( "PluginBrowser", "Plugin for enhancing stereo separation of a stereo input file" ), @@ -81,15 +85,15 @@ StereoEnhancerEffect::~StereoEnhancerEffect() bool StereoEnhancerEffect::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames ) { - + // This appears to be used for determining whether or not to continue processing - // audio with this effect + // audio with this effect double out_sum = 0.0; - + float width; int frameIndex = 0; - - + + if( !isEnabled() || !isRunning() ) { return( false ); @@ -100,7 +104,7 @@ bool StereoEnhancerEffect::processAudioBuffer( sampleFrame * _buf, for( fpp_t f = 0; f < _frames; ++f ) { - + // copy samples into the delay buffer m_delayBuffer[m_currFrame][0] = _buf[f][0]; m_delayBuffer[m_currFrame][1] = _buf[f][1]; @@ -118,7 +122,7 @@ bool StereoEnhancerEffect::processAudioBuffer( sampleFrame * _buf, } //sample_t s[2] = { _buf[f][0], _buf[f][1] }; //Vanilla - sample_t s[2] = { _buf[f][0], m_delayBuffer[frameIndex][1] }; //Chocolate + auto s = std::array{_buf[f][0], m_delayBuffer[frameIndex][1]}; //Chocolate m_seFX.nextSample( s[0], s[1] ); @@ -172,3 +176,5 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model * _parent, void * _data ) } + +} // namespace lmms \ No newline at end of file diff --git a/plugins/StereoEnhancer/StereoEnhancer.h b/plugins/StereoEnhancer/StereoEnhancer.h index 4c7ea6ac6..5872100d3 100644 --- a/plugins/StereoEnhancer/StereoEnhancer.h +++ b/plugins/StereoEnhancer/StereoEnhancer.h @@ -30,16 +30,20 @@ #include "DspEffectLibrary.h" #include "StereoEnhancerControls.h" +namespace lmms +{ + + class StereoEnhancerEffect : public Effect { public: StereoEnhancerEffect( Model * parent, const Descriptor::SubPluginFeatures::Key * _key ); - virtual ~StereoEnhancerEffect(); - virtual bool processAudioBuffer( sampleFrame * _buf, - const fpp_t _frames ); + ~StereoEnhancerEffect() override; + bool processAudioBuffer( sampleFrame * _buf, + const fpp_t _frames ) override; - virtual EffectControls * controls() + EffectControls * controls() override { return( &m_bbControls ); } @@ -59,5 +63,6 @@ private: } ; +} // namespace lmms #endif diff --git a/plugins/StereoEnhancer/StereoEnhancerControlDialog.cpp b/plugins/StereoEnhancer/StereoEnhancerControlDialog.cpp index d86fbc6d7..3f7841706 100644 --- a/plugins/StereoEnhancer/StereoEnhancerControlDialog.cpp +++ b/plugins/StereoEnhancer/StereoEnhancerControlDialog.cpp @@ -26,21 +26,21 @@ #include "StereoEnhancerControlDialog.h" - #include - #include "Knob.h" #include "StereoEnhancerControls.h" +namespace lmms::gui +{ StereoEnhancerControlDialog::StereoEnhancerControlDialog( StereoEnhancerControls * _controls ) : EffectControlDialog( _controls ) { - QHBoxLayout * l = new QHBoxLayout( this ); + auto l = new QHBoxLayout(this); - Knob * widthKnob = new Knob( knobBright_26, this ); + auto widthKnob = new Knob(knobBright_26, this); widthKnob->setModel( &_controls->m_widthModel ); widthKnob->setLabel( tr( "WIDTH" ) ); widthKnob->setHintText( tr( "Width:" ) , " samples" ); @@ -50,3 +50,5 @@ StereoEnhancerControlDialog::StereoEnhancerControlDialog( this->setLayout(l); } + +} // namespace lmms::gui diff --git a/plugins/StereoEnhancer/StereoEnhancerControlDialog.h b/plugins/StereoEnhancer/StereoEnhancerControlDialog.h index 3d1d82bae..459b1fa69 100644 --- a/plugins/StereoEnhancer/StereoEnhancerControlDialog.h +++ b/plugins/StereoEnhancer/StereoEnhancerControlDialog.h @@ -27,19 +27,27 @@ #include "EffectControlDialog.h" +namespace lmms +{ + class StereoEnhancerControls; +namespace gui +{ + + class StereoEnhancerControlDialog : public EffectControlDialog { Q_OBJECT public: StereoEnhancerControlDialog( StereoEnhancerControls * _controls ); - virtual ~StereoEnhancerControlDialog() - { - } + ~StereoEnhancerControlDialog() override = default; }; +} // namespace gui + +} // namespace lmms #endif diff --git a/plugins/StereoEnhancer/StereoEnhancerControls.cpp b/plugins/StereoEnhancer/StereoEnhancerControls.cpp index a844e74f5..3cad94f91 100644 --- a/plugins/StereoEnhancer/StereoEnhancerControls.cpp +++ b/plugins/StereoEnhancer/StereoEnhancerControls.cpp @@ -28,6 +28,9 @@ #include "StereoEnhancerControls.h" #include "StereoEnhancer.h" +namespace lmms +{ + StereoEnhancerControls::StereoEnhancerControls( StereoEnhancerEffect * _eff ) : EffectControls( _eff ), @@ -64,6 +67,4 @@ void StereoEnhancerControls::saveSettings( QDomDocument & _doc, } - - - +} // namespace lmms diff --git a/plugins/StereoEnhancer/StereoEnhancerControls.h b/plugins/StereoEnhancer/StereoEnhancerControls.h index cefed77f9..dea356fdb 100644 --- a/plugins/StereoEnhancer/StereoEnhancerControls.h +++ b/plugins/StereoEnhancer/StereoEnhancerControls.h @@ -28,6 +28,10 @@ #include "EffectControls.h" #include "StereoEnhancerControlDialog.h" +namespace lmms +{ + + class StereoEnhancerEffect; class StereoEnhancerControls : public EffectControls @@ -35,25 +39,23 @@ class StereoEnhancerControls : public EffectControls Q_OBJECT public: StereoEnhancerControls( StereoEnhancerEffect( * _eff ) ); - virtual ~StereoEnhancerControls() - { - } + ~StereoEnhancerControls() override = default; - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); - inline virtual QString nodeName() const + void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; + inline QString nodeName() const override { return( "stereoenhancercontrols" ); } - virtual int controlCount() + int controlCount() override { return( 1 ); } - virtual EffectControlDialog * createView() + gui::EffectControlDialog* createView() override { - return new StereoEnhancerControlDialog( this ); + return new gui::StereoEnhancerControlDialog( this ); } @@ -65,9 +67,11 @@ private: StereoEnhancerEffect * m_effect; FloatModel m_widthModel; - friend class StereoEnhancerControlDialog; + friend class gui::StereoEnhancerControlDialog; } ; +} // namespace lmms + #endif /*_STEREO_ENHANCER_CONTROLS_H*/ diff --git a/plugins/StereoMatrix/StereoMatrix.cpp b/plugins/StereoMatrix/StereoMatrix.cpp index c8a743fe3..2dff69b77 100644 --- a/plugins/StereoMatrix/StereoMatrix.cpp +++ b/plugins/StereoMatrix/StereoMatrix.cpp @@ -28,12 +28,16 @@ #include "embed.h" #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT stereomatrix_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "Stereo Matrix", QT_TRANSLATE_NOOP( "PluginBrowser", "Plugin for freely manipulating stereo output" ), @@ -60,12 +64,6 @@ StereoMatrixEffect::StereoMatrixEffect( -StereoMatrixEffect::~StereoMatrixEffect() -{ -} - - - bool StereoMatrixEffect::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames ) { @@ -121,3 +119,6 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model * _parent, void * _data ) } } + + +} // namespace lmms diff --git a/plugins/StereoMatrix/StereoMatrix.h b/plugins/StereoMatrix/StereoMatrix.h index 39ed4a1ad..ae7a59724 100644 --- a/plugins/StereoMatrix/StereoMatrix.h +++ b/plugins/StereoMatrix/StereoMatrix.h @@ -29,16 +29,20 @@ #include "Effect.h" #include "StereoMatrixControls.h" +namespace lmms +{ + + class StereoMatrixEffect : public Effect { public: StereoMatrixEffect( Model * parent, const Descriptor::SubPluginFeatures::Key * _key ); - virtual ~StereoMatrixEffect(); - virtual bool processAudioBuffer( sampleFrame * _buf, - const fpp_t _frames ); + ~StereoMatrixEffect() override = default; + bool processAudioBuffer( sampleFrame * _buf, + const fpp_t _frames ) override; - virtual EffectControls * controls() + EffectControls* controls() override { return( &m_smControls ); } @@ -51,5 +55,6 @@ private: } ; +} // namespace lmms #endif diff --git a/plugins/StereoMatrix/StereoMatrixControlDialog.cpp b/plugins/StereoMatrix/StereoMatrixControlDialog.cpp index 3899219dd..06ff2a03b 100644 --- a/plugins/StereoMatrix/StereoMatrixControlDialog.cpp +++ b/plugins/StereoMatrix/StereoMatrixControlDialog.cpp @@ -31,6 +31,8 @@ #include "Knob.h" #include "StereoMatrixControls.h" +namespace lmms::gui +{ StereoMatrixControlDialog::StereoMatrixControlDialog( @@ -46,24 +48,26 @@ StereoMatrixControlDialog::StereoMatrixControlDialog( PLUGIN_NAME::getIconPixmap( "artwork" ) ); setPalette( pal ); - - Knob * llKnob = new Knob( knobBright_26, this ); + auto llKnob = new Knob(knobBright_26, this); llKnob->setModel( &_controls->m_llModel ); llKnob->setHintText( tr( "Left to Left Vol:" ) , "" ); llKnob->move( 10, 79 ); - Knob * lrKnob = new Knob( knobBright_26, this ); + auto lrKnob = new Knob(knobBright_26, this); lrKnob->setModel( &_controls->m_lrModel ); lrKnob->setHintText( tr( "Left to Right Vol:" ) , "" ); lrKnob->move( 48, 79 ); - Knob * rlKnob = new Knob( knobBright_26, this ); + auto rlKnob = new Knob(knobBright_26, this); rlKnob->setModel( &_controls->m_rlModel ); rlKnob->setHintText( tr( "Right to Left Vol:" ) , "" ); rlKnob->move( 85, 79 ); - Knob * rrKnob = new Knob( knobBright_26, this ); + auto rrKnob = new Knob(knobBright_26, this); rrKnob->setModel( &_controls->m_rrModel ); rrKnob->setHintText( tr( "Right to Right Vol:" ) , "" ); rrKnob->move( 123, 79 ); } + + +} // namespace lmms::gui diff --git a/plugins/StereoMatrix/StereoMatrixControlDialog.h b/plugins/StereoMatrix/StereoMatrixControlDialog.h index 4de00ec70..56592aa12 100644 --- a/plugins/StereoMatrix/StereoMatrixControlDialog.h +++ b/plugins/StereoMatrix/StereoMatrixControlDialog.h @@ -27,19 +27,27 @@ #include "EffectControlDialog.h" +namespace lmms +{ + class StereoMatrixControls; +namespace gui +{ + class StereoMatrixControlDialog : public EffectControlDialog { Q_OBJECT public: StereoMatrixControlDialog( StereoMatrixControls * _controls ); - virtual ~StereoMatrixControlDialog() - { - } + ~StereoMatrixControlDialog() override = default; }; +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/StereoMatrix/StereoMatrixControls.cpp b/plugins/StereoMatrix/StereoMatrixControls.cpp index 75f513a60..e60b02a8d 100644 --- a/plugins/StereoMatrix/StereoMatrixControls.cpp +++ b/plugins/StereoMatrix/StereoMatrixControls.cpp @@ -28,6 +28,9 @@ #include "StereoMatrixControls.h" #include "StereoMatrix.h" +namespace lmms +{ + StereoMatrixControls::StereoMatrixControls( StereoMatrixEffect * _eff ) : EffectControls( _eff ), @@ -81,3 +84,6 @@ void StereoMatrixControls::saveSettings( QDomDocument & _doc, m_rlModel.saveSettings( _doc, _this, "r-l" ); m_rrModel.saveSettings( _doc, _this, "r-r" ); } + + +} // namespace lmms \ No newline at end of file diff --git a/plugins/StereoMatrix/StereoMatrixControls.h b/plugins/StereoMatrix/StereoMatrixControls.h index 3b89d74d2..5eb506d16 100644 --- a/plugins/StereoMatrix/StereoMatrixControls.h +++ b/plugins/StereoMatrix/StereoMatrixControls.h @@ -28,6 +28,10 @@ #include "EffectControls.h" #include "StereoMatrixControlDialog.h" +namespace lmms +{ + + class StereoMatrixEffect; class StereoMatrixControls : public EffectControls @@ -35,25 +39,23 @@ class StereoMatrixControls : public EffectControls Q_OBJECT public: StereoMatrixControls( StereoMatrixEffect( * _eff ) ); - virtual ~StereoMatrixControls() - { - } + ~StereoMatrixControls() override = default; - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); - inline virtual QString nodeName() const + void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; + inline QString nodeName() const override { return( "stereomatrixcontrols" ); } - virtual int controlCount() + int controlCount() override { return( 1 ); } - virtual EffectControlDialog * createView() + gui::EffectControlDialog* createView() override { - return new StereoMatrixControlDialog( this ); + return new gui::StereoMatrixControlDialog( this ); } @@ -69,10 +71,12 @@ private: FloatModel m_rlModel; FloatModel m_rrModel; - friend class StereoMatrixControlDialog; + friend class gui::StereoMatrixControlDialog; friend class StereoMatrixEffect; } ; +} // namespace lmms + #endif diff --git a/plugins/Stk/Mallets/CMakeLists.txt b/plugins/Stk/Mallets/CMakeLists.txt index a2b5ddf1d..77b7afff2 100644 --- a/plugins/Stk/Mallets/CMakeLists.txt +++ b/plugins/Stk/Mallets/CMakeLists.txt @@ -1,5 +1,7 @@ -INCLUDE(BuildPlugin) -INCLUDE_DIRECTORIES("${STK_INCLUDE_DIR}") -LINK_LIBRARIES(${STK_LIBRARY}) -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions") -BUILD_PLUGIN(malletsstk Mallets.cpp Mallets.h MOCFILES Mallets.h EMBEDDED_RESOURCES artwork.png logo.png) +include(BuildPlugin) +build_plugin(malletsstk + Mallets.cpp Mallets.h + MOCFILES Mallets.h + EMBEDDED_RESOURCES artwork.png logo.png +) +target_link_libraries(malletsstk unofficial::libstk::libstk) diff --git a/plugins/Stk/Mallets/Mallets.cpp b/plugins/Stk/Mallets/Mallets.cpp index 9a4d9ea3a..8aa71d62e 100644 --- a/plugins/Stk/Mallets/Mallets.cpp +++ b/plugins/Stk/Mallets/Mallets.cpp @@ -30,9 +30,9 @@ #include #include -#include "BandedWG.h" -#include "ModalBar.h" -#include "TubeBell.h" +#include +#include +#include #include "AudioEngine.h" #include "ConfigManager.h" @@ -44,12 +44,16 @@ #include "embed.h" #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT malletsstk_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "Mallets", QT_TRANSLATE_NOOP( "PluginBrowser", "Tuneful things to bang on" ), @@ -126,13 +130,6 @@ MalletsInstrument::MalletsInstrument( InstrumentTrack * _instrument_track ): -MalletsInstrument::~MalletsInstrument() -{ -} - - - - void MalletsInstrument::saveSettings( QDomDocument & _doc, QDomElement & _this ) { // ModalBar @@ -345,7 +342,7 @@ void MalletsInstrument::playNote( NotePlayHandle * _n, const fpp_t frames = _n->framesLeftForCurrentPeriod(); const f_cnt_t offset = _n->noteOffset(); - MalletsSynth * ps = static_cast( _n->m_pluginData ); + auto ps = static_cast(_n->m_pluginData); ps->setFrequency( freq ); p = ps->presetIndex(); @@ -377,12 +374,14 @@ void MalletsInstrument::deleteNotePluginData( NotePlayHandle * _n ) -PluginView * MalletsInstrument::instantiateView( QWidget * _parent ) +gui::PluginView * MalletsInstrument::instantiateView( QWidget * _parent ) { - return( new MalletsInstrumentView( this, _parent ) ); + return( new gui::MalletsInstrumentView( this, _parent ) ); } +namespace gui +{ MalletsInstrumentView::MalletsInstrumentView( MalletsInstrument * _instrument, @@ -429,12 +428,6 @@ MalletsInstrumentView::MalletsInstrumentView( MalletsInstrument * _instrument, -MalletsInstrumentView::~MalletsInstrumentView() -{ -} - - - void MalletsInstrumentView::setWidgetBackground( QWidget * _widget, const QString & _pic ) { _widget->setAutoFillBackground( true ); @@ -449,7 +442,7 @@ void MalletsInstrumentView::setWidgetBackground( QWidget * _widget, const QStrin QWidget * MalletsInstrumentView::setupModalBarControls( QWidget * _parent ) { - QWidget * widget = new QWidget( _parent ); + auto widget = new QWidget(_parent); widget->setFixedSize( 250, 250 ); m_hardnessKnob = new Knob( knobVintage_32, widget ); @@ -485,7 +478,7 @@ QWidget * MalletsInstrumentView::setupModalBarControls( QWidget * _parent ) QWidget * MalletsInstrumentView::setupTubeBellControls( QWidget * _parent ) { - QWidget * widget = new QWidget( _parent ); + auto widget = new QWidget(_parent); widget->setFixedSize( 250, 250 ); m_modulatorKnob = new Knob( knobVintage_32, widget ); @@ -522,7 +515,7 @@ QWidget * MalletsInstrumentView::setupTubeBellControls( QWidget * _parent ) QWidget * MalletsInstrumentView::setupBandedWGControls( QWidget * _parent ) { // BandedWG - QWidget * widget = new QWidget( _parent ); + auto widget = new QWidget(_parent); widget->setFixedSize( 250, 250 ); /* m_strikeLED = new LedCheckBox( tr( "Bowed" ), widget ); @@ -556,7 +549,7 @@ QWidget * MalletsInstrumentView::setupBandedWGControls( QWidget * _parent ) void MalletsInstrumentView::modelChanged() { - MalletsInstrument * inst = castModel(); + auto inst = castModel(); m_hardnessKnob->setModel( &inst->m_hardnessModel ); m_positionKnob->setModel( &inst->m_positionModel ); m_vibratoGainKnob->setModel( &inst->m_vibratoGainModel ); @@ -581,7 +574,7 @@ void MalletsInstrumentView::modelChanged() void MalletsInstrumentView::changePreset() { - MalletsInstrument * inst = castModel(); + auto inst = castModel(); int _preset = inst->m_presetsModel.value(); if( _preset < 9 ) @@ -605,6 +598,8 @@ void MalletsInstrumentView::changePreset() } +} // namespace gui + // ModalBar MalletsSynth::MalletsSynth( const StkFloat _pitch, @@ -770,6 +765,4 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model * m, void * ) } - - - +} // namespace lmms diff --git a/plugins/Stk/Mallets/Mallets.h b/plugins/Stk/Mallets/Mallets.h index fb35abb73..f66ac25d0 100644 --- a/plugins/Stk/Mallets/Mallets.h +++ b/plugins/Stk/Mallets/Mallets.h @@ -27,7 +27,7 @@ #ifndef _MALLET_H #define _MALLET_H -#include "Instrmnt.h" +#include #include "ComboBox.h" #include "Instrument.h" @@ -40,10 +40,22 @@ // However in older versions this namespace does not exist, therefore declare it // so this plugin builds with all versions of Stk. namespace stk { } ; + +namespace lmms +{ + + using namespace stk; static const int MALLETS_PRESET_VERSION = 1; + +namespace gui +{ +class MalletsInstrumentView; +} // namespace gui + + class MalletsSynth { public: @@ -148,19 +160,19 @@ class MalletsInstrument : public Instrument Q_OBJECT public: MalletsInstrument( InstrumentTrack * _instrument_track ); - virtual ~MalletsInstrument(); + ~MalletsInstrument() override = default; - virtual void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ); - virtual void deleteNotePluginData( NotePlayHandle * _n ); + void playNote( NotePlayHandle * _n, + sampleFrame * _working_buffer ) override; + void deleteNotePluginData( NotePlayHandle * _n ) override; - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); + void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; - virtual QString nodeName() const; + QString nodeName() const override; - virtual PluginView * instantiateView( QWidget * _parent ); + gui::PluginView* instantiateView( QWidget * _parent ) override; private: @@ -193,10 +205,13 @@ private: bool m_filesMissing; - friend class MalletsInstrumentView; + friend class gui::MalletsInstrumentView; } ; +namespace gui +{ + class MalletsInstrumentView: public InstrumentViewFixedSize { @@ -204,13 +219,13 @@ class MalletsInstrumentView: public InstrumentViewFixedSize public: MalletsInstrumentView( MalletsInstrument * _instrument, QWidget * _parent ); - virtual ~MalletsInstrumentView(); + ~MalletsInstrumentView() override = default; public slots: void changePreset(); private: - virtual void modelChanged(); + void modelChanged() override; void setWidgetBackground( QWidget * _widget, const QString & _pic ); QWidget * setupModalBarControls( QWidget * _parent ); @@ -242,4 +257,9 @@ private: Knob * m_spreadKnob; }; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/TripleOscillator/TripleOscillator.cpp b/plugins/TripleOscillator/TripleOscillator.cpp index 897b03586..25baea208 100644 --- a/plugins/TripleOscillator/TripleOscillator.cpp +++ b/plugins/TripleOscillator/TripleOscillator.cpp @@ -21,7 +21,7 @@ * Boston, MA 02110-1301 USA. * */ - + #include @@ -41,12 +41,16 @@ #include "embed.h" #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT tripleoscillator_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "TripleOscillator", QT_TRANSLATE_NOOP( "PluginBrowser", "Three powerful oscillators you can modulate " @@ -77,10 +81,10 @@ OscillatorObject::OscillatorObject( Model * _parent, int _idx ) : m_fineRightModel( 0.0f, -100.0f, 100.0f, 1.0f, this, tr( "Osc %1 fine detuning right" ).arg( _idx + 1 ) ), m_phaseOffsetModel( 0.0f, 0.0f, 360.0f, 1.0f, this, - tr( "Osc %1 phase-offset" ).arg( _idx+1 ) ), + tr( "Osc %1 phase-offset" ).arg( _idx+1 ) ), m_stereoPhaseDetuningModel( 0.0f, 0.0f, 360.0f, 1.0f, this, tr( "Osc %1 stereo phase-detuning" ).arg( _idx+1 ) ), - m_waveShapeModel( Oscillator::SineWave, 0, + m_waveShapeModel( Oscillator::SineWave, 0, Oscillator::NumWaveShapes-1, this, tr( "Osc %1 wave shape" ).arg( _idx+1 ) ), m_modulationAlgoModel( Oscillator::SignalMix, 0, @@ -216,7 +220,7 @@ void OscillatorObject::updateUseWaveTable() } - + TripleOscillator::TripleOscillator( InstrumentTrack * _instrument_track ) : Instrument( _instrument_track, &tripleoscillator_plugin_descriptor ) @@ -234,13 +238,6 @@ TripleOscillator::TripleOscillator( InstrumentTrack * _instrument_track ) : -TripleOscillator::~TripleOscillator() -{ -} - - - - void TripleOscillator::saveSettings( QDomDocument & _doc, QDomElement & _this ) { for( int i = 0; i < NUM_OF_OSCILLATORS; ++i ) @@ -313,8 +310,8 @@ void TripleOscillator::playNote( NotePlayHandle * _n, { if( _n->totalFramesPlayed() == 0 || _n->m_pluginData == nullptr ) { - Oscillator * oscs_l[NUM_OF_OSCILLATORS]; - Oscillator * oscs_r[NUM_OF_OSCILLATORS]; + auto oscs_l = std::array{}; + auto oscs_r = std::array{}; for( int i = NUM_OF_OSCILLATORS - 1; i >= 0; --i ) { @@ -402,9 +399,9 @@ void TripleOscillator::deleteNotePluginData( NotePlayHandle * _n ) -PluginView * TripleOscillator::instantiateView( QWidget * _parent ) +gui::PluginView* TripleOscillator::instantiateView( QWidget * _parent ) { - return new TripleOscillatorView( this, _parent ); + return new gui::TripleOscillatorView( this, _parent ); } @@ -412,15 +409,18 @@ PluginView * TripleOscillator::instantiateView( QWidget * _parent ) void TripleOscillator::updateAllDetuning() { - for( int i = 0; i < NUM_OF_OSCILLATORS; ++i ) + for (const auto& osc : m_osc) { - m_osc[i]->updateDetuningLeft(); - m_osc[i]->updateDetuningRight(); + osc->updateDetuningLeft(); + osc->updateDetuningRight(); } } +namespace gui +{ + class TripleOscKnob : public Knob { @@ -452,7 +452,7 @@ TripleOscillatorView::TripleOscillatorView( Instrument * _instrument, const int osc_h = 52; // TODO: clean rewrite using layouts and all that... - PixmapButton * pm_osc1_btn = new PixmapButton( this, nullptr ); + auto pm_osc1_btn = new PixmapButton(this, nullptr); pm_osc1_btn->move( mod_x, mod1_y ); pm_osc1_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "pm_active" ) ); @@ -460,7 +460,7 @@ TripleOscillatorView::TripleOscillatorView( Instrument * _instrument, "pm_inactive" ) ); pm_osc1_btn->setToolTip(tr("Modulate phase of oscillator 1 by oscillator 2")); - PixmapButton * am_osc1_btn = new PixmapButton( this, nullptr ); + auto am_osc1_btn = new PixmapButton(this, nullptr); am_osc1_btn->move( mod_x + 35, mod1_y ); am_osc1_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "am_active" ) ); @@ -468,7 +468,7 @@ TripleOscillatorView::TripleOscillatorView( Instrument * _instrument, "am_inactive" ) ); am_osc1_btn->setToolTip(tr("Modulate amplitude of oscillator 1 by oscillator 2")); - PixmapButton * mix_osc1_btn = new PixmapButton( this, nullptr ); + auto mix_osc1_btn = new PixmapButton(this, nullptr); mix_osc1_btn->move( mod_x + 70, mod1_y ); mix_osc1_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "mix_active" ) ); @@ -476,7 +476,7 @@ TripleOscillatorView::TripleOscillatorView( Instrument * _instrument, "mix_inactive" ) ); mix_osc1_btn->setToolTip(tr("Mix output of oscillators 1 & 2")); - PixmapButton * sync_osc1_btn = new PixmapButton( this, nullptr ); + auto sync_osc1_btn = new PixmapButton(this, nullptr); sync_osc1_btn->move( mod_x + 105, mod1_y ); sync_osc1_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "sync_active" ) ); @@ -485,7 +485,7 @@ TripleOscillatorView::TripleOscillatorView( Instrument * _instrument, sync_osc1_btn->setToolTip(tr("Synchronize oscillator 1 with " "oscillator 2" ) ); - PixmapButton * fm_osc1_btn = new PixmapButton( this, nullptr ); + auto fm_osc1_btn = new PixmapButton(this, nullptr); fm_osc1_btn->move( mod_x + 140, mod1_y ); fm_osc1_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "fm_active" ) ); @@ -500,9 +500,7 @@ TripleOscillatorView::TripleOscillatorView( Instrument * _instrument, m_mod1BtnGrp->addButton( sync_osc1_btn ); m_mod1BtnGrp->addButton( fm_osc1_btn ); - - - PixmapButton * pm_osc2_btn = new PixmapButton( this, nullptr ); + auto pm_osc2_btn = new PixmapButton(this, nullptr); pm_osc2_btn->move( mod_x, mod2_y ); pm_osc2_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "pm_active" ) ); @@ -510,7 +508,7 @@ TripleOscillatorView::TripleOscillatorView( Instrument * _instrument, "pm_inactive" ) ); pm_osc2_btn->setToolTip(tr("Modulate phase of oscillator 2 by oscillator 3")); - PixmapButton * am_osc2_btn = new PixmapButton( this, nullptr ); + auto am_osc2_btn = new PixmapButton(this, nullptr); am_osc2_btn->move( mod_x + 35, mod2_y ); am_osc2_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "am_active" ) ); @@ -518,7 +516,7 @@ TripleOscillatorView::TripleOscillatorView( Instrument * _instrument, "am_inactive" ) ); am_osc2_btn->setToolTip(tr("Modulate amplitude of oscillator 2 by oscillator 3")); - PixmapButton * mix_osc2_btn = new PixmapButton( this, nullptr ); + auto mix_osc2_btn = new PixmapButton(this, nullptr); mix_osc2_btn->move( mod_x + 70, mod2_y ); mix_osc2_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "mix_active" ) ); @@ -526,7 +524,7 @@ TripleOscillatorView::TripleOscillatorView( Instrument * _instrument, "mix_inactive" ) ); mix_osc2_btn->setToolTip(tr("Mix output of oscillators 2 & 3")); - PixmapButton * sync_osc2_btn = new PixmapButton( this, nullptr ); + auto sync_osc2_btn = new PixmapButton(this, nullptr); sync_osc2_btn->move( mod_x + 105, mod2_y ); sync_osc2_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "sync_active" ) ); @@ -534,7 +532,7 @@ TripleOscillatorView::TripleOscillatorView( Instrument * _instrument, "sync_inactive" ) ); sync_osc2_btn->setToolTip(tr("Synchronize oscillator 2 with oscillator 3")); - PixmapButton * fm_osc2_btn = new PixmapButton( this, nullptr ); + auto fm_osc2_btn = new PixmapButton(this, nullptr); fm_osc2_btn->move( mod_x + 140, mod2_y ); fm_osc2_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "fm_active" ) ); @@ -556,7 +554,7 @@ TripleOscillatorView::TripleOscillatorView( Instrument * _instrument, int knob_y = osc_y + i * osc_h; // setup volume-knob - Knob * vk = new Knob( knobStyled, this ); + auto vk = new Knob(knobStyled, this); vk->setVolumeKnob( true ); vk->setFixedSize( 28, 35 ); vk->move( 6, knob_y ); @@ -604,7 +602,7 @@ TripleOscillatorView::TripleOscillatorView( Instrument * _instrument, int btn_y = 96 + i * osc_h; - PixmapButton * sin_wave_btn = new PixmapButton( this, nullptr ); + auto sin_wave_btn = new PixmapButton(this, nullptr); sin_wave_btn->move( 128, btn_y ); sin_wave_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "sin_shape_active" ) ); @@ -613,8 +611,7 @@ TripleOscillatorView::TripleOscillatorView( Instrument * _instrument, sin_wave_btn->setToolTip( tr( "Sine wave" ) ); - PixmapButton * triangle_wave_btn = - new PixmapButton( this, nullptr ); + auto triangle_wave_btn = new PixmapButton(this, nullptr); triangle_wave_btn->move( 143, btn_y ); triangle_wave_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "triangle_shape_active" ) ); @@ -623,7 +620,7 @@ TripleOscillatorView::TripleOscillatorView( Instrument * _instrument, triangle_wave_btn->setToolTip( tr( "Triangle wave") ); - PixmapButton * saw_wave_btn = new PixmapButton( this, nullptr ); + auto saw_wave_btn = new PixmapButton(this, nullptr); saw_wave_btn->move( 158, btn_y ); saw_wave_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "saw_shape_active" ) ); @@ -632,7 +629,7 @@ TripleOscillatorView::TripleOscillatorView( Instrument * _instrument, saw_wave_btn->setToolTip( tr( "Saw wave" ) ); - PixmapButton * sqr_wave_btn = new PixmapButton( this, nullptr ); + auto sqr_wave_btn = new PixmapButton(this, nullptr); sqr_wave_btn->move( 173, btn_y ); sqr_wave_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "square_shape_active" ) ); @@ -641,8 +638,7 @@ TripleOscillatorView::TripleOscillatorView( Instrument * _instrument, sqr_wave_btn->setToolTip( tr( "Square wave" ) ); - PixmapButton * moog_saw_wave_btn = - new PixmapButton( this, nullptr ); + auto moog_saw_wave_btn = new PixmapButton(this, nullptr); moog_saw_wave_btn->move( 188, btn_y ); moog_saw_wave_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "moog_saw_shape_active" ) ); @@ -651,7 +647,7 @@ TripleOscillatorView::TripleOscillatorView( Instrument * _instrument, moog_saw_wave_btn->setToolTip( tr( "Moog-like saw wave" ) ); - PixmapButton * exp_wave_btn = new PixmapButton( this, nullptr ); + auto exp_wave_btn = new PixmapButton(this, nullptr); exp_wave_btn->move( 203, btn_y ); exp_wave_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "exp_shape_active" ) ); @@ -660,7 +656,7 @@ TripleOscillatorView::TripleOscillatorView( Instrument * _instrument, exp_wave_btn->setToolTip( tr( "Exponential wave" ) ); - PixmapButton * white_noise_btn = new PixmapButton( this, nullptr ); + auto white_noise_btn = new PixmapButton(this, nullptr); white_noise_btn->move( 218, btn_y ); white_noise_btn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "white_noise_shape_active" ) ); @@ -669,7 +665,7 @@ TripleOscillatorView::TripleOscillatorView( Instrument * _instrument, white_noise_btn->setToolTip( tr( "White noise" ) ); - PixmapButton * uwb = new PixmapButton( this, nullptr ); + auto uwb = new PixmapButton(this, nullptr); uwb->move( 233, btn_y ); uwb->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "usr_shape_active" ) ); @@ -677,7 +673,7 @@ TripleOscillatorView::TripleOscillatorView( Instrument * _instrument, "usr_shape_inactive" ) ); uwb->setToolTip(tr("User-defined wave")); - PixmapButton * uwt = new PixmapButton( this, nullptr ); + auto uwt = new PixmapButton(this, nullptr); uwt->move( 110, btn_y ); uwt->setActiveGraphic( PLUGIN_NAME::getIconPixmap( "wavetable_active" ) ); @@ -686,8 +682,7 @@ TripleOscillatorView::TripleOscillatorView( Instrument * _instrument, uwt->setCheckable(true); uwt->setToolTip(tr("Use alias-free wavetable oscillators.")); - automatableButtonGroup * wsbg = - new automatableButtonGroup( this ); + auto wsbg = new automatableButtonGroup(this); wsbg->addButton( sin_wave_btn ); wsbg->addButton( triangle_wave_btn ); @@ -707,16 +702,9 @@ TripleOscillatorView::TripleOscillatorView( Instrument * _instrument, -TripleOscillatorView::~TripleOscillatorView() -{ -} - - - - void TripleOscillatorView::modelChanged() { - TripleOscillator * t = castModel(); + auto t = castModel(); m_mod1BtnGrp->setModel( &t->m_osc[0]->m_modulationAlgoModel ); m_mod2BtnGrp->setModel( &t->m_osc[1]->m_modulationAlgoModel ); @@ -748,6 +736,7 @@ void TripleOscillatorView::modelChanged() } +} // namespace gui extern "C" @@ -763,4 +752,4 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model* model, void * ) - +} // namespace lmms diff --git a/plugins/TripleOscillator/TripleOscillator.h b/plugins/TripleOscillator/TripleOscillator.h index 944834417..f3290153b 100644 --- a/plugins/TripleOscillator/TripleOscillator.h +++ b/plugins/TripleOscillator/TripleOscillator.h @@ -30,13 +30,23 @@ #include "InstrumentView.h" #include "AutomatableModel.h" +namespace lmms +{ + +class NotePlayHandle; +class SampleBuffer; +class Oscillator; + + +namespace gui +{ class automatableButtonGroup; class Knob; -class NotePlayHandle; -class Oscillator; class PixmapButton; -class SampleBuffer; +class TripleOscillatorView; +} // namespace gui + const int NUM_OF_OSCILLATORS = 3; @@ -47,7 +57,7 @@ class OscillatorObject : public Model Q_OBJECT public: OscillatorObject( Model * _parent, int _idx ); - virtual ~OscillatorObject(); + ~OscillatorObject() override; private: @@ -75,7 +85,7 @@ private: bool m_useWaveTable; friend class TripleOscillator; - friend class TripleOscillatorView; + friend class gui::TripleOscillatorView; private slots: @@ -98,24 +108,24 @@ class TripleOscillator : public Instrument Q_OBJECT public: TripleOscillator( InstrumentTrack * _track ); - virtual ~TripleOscillator(); + ~TripleOscillator() override = default; - virtual void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ); - virtual void deleteNotePluginData( NotePlayHandle * _n ); + void playNote( NotePlayHandle * _n, + sampleFrame * _working_buffer ) override; + void deleteNotePluginData( NotePlayHandle * _n ) override; - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); + void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; - virtual QString nodeName() const; + QString nodeName() const override; - virtual f_cnt_t desiredReleaseFrames() const + f_cnt_t desiredReleaseFrames() const override { return( 128 ); } - virtual PluginView * instantiateView( QWidget * _parent ); + gui::PluginView* instantiateView( QWidget * _parent ) override; protected slots: @@ -133,22 +143,25 @@ private: } ; - friend class TripleOscillatorView; + friend class gui::TripleOscillatorView; } ; +namespace gui +{ + class TripleOscillatorView : public InstrumentViewFixedSize { Q_OBJECT public: TripleOscillatorView( Instrument * _instrument, QWidget * _parent ); - virtual ~TripleOscillatorView(); + ~TripleOscillatorView() override = default; private: - virtual void modelChanged(); + void modelChanged() override; automatableButtonGroup * m_mod1BtnGrp; automatableButtonGroup * m_mod2BtnGrp; @@ -178,9 +191,7 @@ private: m_multiBandWaveTableButton( wt ) { } - OscillatorKnobs() - { - } + OscillatorKnobs() = default; Knob * m_volKnob; Knob * m_panKnob; Knob * m_coarseKnob; @@ -198,5 +209,8 @@ private: } ; +} // namespace gui + +} // namespace lmms #endif diff --git a/plugins/Vectorscope/VecControls.cpp b/plugins/Vectorscope/VecControls.cpp index ede9c77b2..cd0f21f61 100644 --- a/plugins/Vectorscope/VecControls.cpp +++ b/plugins/Vectorscope/VecControls.cpp @@ -29,6 +29,9 @@ #include "VecControlsDialog.h" #include "Vectorscope.h" +namespace lmms +{ + VecControls::VecControls(Vectorscope *effect) : EffectControls(effect), @@ -48,9 +51,9 @@ VecControls::VecControls(Vectorscope *effect) : // Create the VecControlDialog widget which handles display of GUI elements. -EffectControlDialog* VecControls::createView() +gui::EffectControlDialog* VecControls::createView() { - return new VecControlsDialog(this); + return new gui::VecControlsDialog(this); } @@ -68,3 +71,6 @@ void VecControls::saveSettings(QDomDocument &document, QDomElement &element) m_logarithmicModel.saveSettings(document, element, "Logarithmic"); m_highQualityModel.saveSettings(document, element, "HighQuality"); } + + +} // namespace lmms diff --git a/plugins/Vectorscope/VecControls.h b/plugins/Vectorscope/VecControls.h index 04b688e5a..71b1c122e 100644 --- a/plugins/Vectorscope/VecControls.h +++ b/plugins/Vectorscope/VecControls.h @@ -29,18 +29,27 @@ #include "EffectControls.h" +namespace lmms +{ + class Vectorscope; +namespace gui +{ +class VecControlsDialog; +class VectorView; +} + // Holds all the configuration values class VecControls : public EffectControls { Q_OBJECT public: explicit VecControls(Vectorscope *effect); - virtual ~VecControls() {} + ~VecControls() override = default; - EffectControlDialog *createView() override; + gui::EffectControlDialog* createView() override; void saveSettings (QDomDocument &document, QDomElement &element) override; void loadSettings (const QDomElement &element) override; @@ -60,7 +69,11 @@ private: QColor m_colorLabels; QColor m_colorOutline; - friend class VecControlsDialog; - friend class VectorView; + friend class gui::VecControlsDialog; + friend class gui::VectorView; }; + + +} // namespace lmms + #endif // VECCONTROLS_H diff --git a/plugins/Vectorscope/VecControlsDialog.cpp b/plugins/Vectorscope/VecControlsDialog.cpp index f5e740887..97898fe70 100644 --- a/plugins/Vectorscope/VecControlsDialog.cpp +++ b/plugins/Vectorscope/VecControlsDialog.cpp @@ -34,31 +34,34 @@ #include "Vectorscope.h" #include "VectorView.h" +namespace lmms::gui +{ + // The entire GUI layout is built here. VecControlsDialog::VecControlsDialog(VecControls *controls) : EffectControlDialog(controls), m_controls(controls) { - QVBoxLayout *master_layout = new QVBoxLayout; + auto master_layout = new QVBoxLayout; master_layout->setContentsMargins(0, 2, 0, 0); setLayout(master_layout); // Visualizer widget // The size of 768 pixels seems to offer a good balance of speed, accuracy and trace thickness. - VectorView *display = new VectorView(controls, m_controls->m_effect->getBuffer(), 768, this); + auto display = new VectorView(controls, m_controls->m_effect->getBuffer(), 768, this); master_layout->addWidget(display); // Config area located inside visualizer - QVBoxLayout *internal_layout = new QVBoxLayout(display); - QHBoxLayout *config_layout = new QHBoxLayout(); - QVBoxLayout *switch_layout = new QVBoxLayout(); + auto internal_layout = new QVBoxLayout(display); + auto config_layout = new QHBoxLayout(); + auto switch_layout = new QVBoxLayout(); internal_layout->addStretch(); internal_layout->addLayout(config_layout); config_layout->addLayout(switch_layout); // High-quality switch - LedCheckBox *highQualityButton = new LedCheckBox(tr("HQ"), this); + auto highQualityButton = new LedCheckBox(tr("HQ"), this); highQualityButton->setToolTip(tr("Double the resolution and simulate continuous analog-like trace.")); highQualityButton->setCheckable(true); highQualityButton->setMinimumSize(70, 12); @@ -66,7 +69,7 @@ VecControlsDialog::VecControlsDialog(VecControls *controls) : switch_layout->addWidget(highQualityButton); // Log. scale switch - LedCheckBox *logarithmicButton = new LedCheckBox(tr("Log. scale"), this); + auto logarithmicButton = new LedCheckBox(tr("Log. scale"), this); logarithmicButton->setToolTip(tr("Display amplitude on logarithmic scale to better see small values.")); logarithmicButton->setCheckable(true); logarithmicButton->setMinimumSize(70, 12); @@ -76,7 +79,7 @@ VecControlsDialog::VecControlsDialog(VecControls *controls) : config_layout->addStretch(); // Persistence knob - Knob *persistenceKnob = new Knob(knobSmall_17, this); + auto persistenceKnob = new Knob(knobSmall_17, this); persistenceKnob->setModel(&controls->m_persistenceModel); persistenceKnob->setLabel(tr("Persist.")); persistenceKnob->setToolTip(tr("Trace persistence: higher amount means the trace will stay bright for longer time.")); @@ -90,3 +93,6 @@ QSize VecControlsDialog::sizeHint() const { return QSize(275, 300); } + + +} // namespace lmms::gui \ No newline at end of file diff --git a/plugins/Vectorscope/VecControlsDialog.h b/plugins/Vectorscope/VecControlsDialog.h index b76c06ad0..8fee75b4b 100644 --- a/plugins/Vectorscope/VecControlsDialog.h +++ b/plugins/Vectorscope/VecControlsDialog.h @@ -27,15 +27,23 @@ #include "EffectControlDialog.h" +namespace lmms +{ + + class VecControls; +namespace gui +{ + + //! Top-level widget holding the configuration GUI and vector display class VecControlsDialog : public EffectControlDialog { Q_OBJECT public: explicit VecControlsDialog(VecControls *controls); - virtual ~VecControlsDialog() {} + ~VecControlsDialog() override = default; bool isResizable() const override {return true;} QSize sizeHint() const override; @@ -44,4 +52,9 @@ private: VecControls *m_controls; }; + +} // namespace gui + +} // namespace lmms + #endif // VECCONTROLSDIALOG_H diff --git a/plugins/Vectorscope/VectorView.cpp b/plugins/Vectorscope/VectorView.cpp index 93a384891..f856f6429 100644 --- a/plugins/Vectorscope/VectorView.cpp +++ b/plugins/Vectorscope/VectorView.cpp @@ -33,6 +33,9 @@ #include "MainWindow.h" #include "VecControls.h" +namespace lmms::gui +{ + VectorView::VectorView(VecControls *controls, LocklessRingBuffer *inputBuffer, unsigned short displaySize, QWidget *parent) : QWidget(parent), @@ -304,7 +307,7 @@ void VectorView::periodicUpdate() // More of an Easter egg, to avoid cluttering the interface with non-essential functionality. void VectorView::mouseDoubleClickEvent(QMouseEvent *event) { - ColorChooser *colorDialog = new ColorChooser(m_controls->m_colorFG, this); + auto colorDialog = new ColorChooser(m_controls->m_colorFG, this); if (colorDialog->exec()) { m_controls->m_colorFG = colorDialog->currentColor(); @@ -327,3 +330,6 @@ void VectorView::wheelEvent(QWheelEvent *event) ).count(); } + + +} // namespace lmms::gui \ No newline at end of file diff --git a/plugins/Vectorscope/VectorView.h b/plugins/Vectorscope/VectorView.h index 8e88847ab..59ac99a77 100644 --- a/plugins/Vectorscope/VectorView.h +++ b/plugins/Vectorscope/VectorView.h @@ -27,10 +27,16 @@ #include "LocklessRingBuffer.h" +namespace lmms +{ class VecControls; +} //#define VEC_DEBUG +namespace lmms::gui +{ + // Widget that displays a vectorscope visualization of stereo signal. class VectorView : public QWidget @@ -38,7 +44,7 @@ class VectorView : public QWidget Q_OBJECT public: explicit VectorView(VecControls *controls, LocklessRingBuffer *inputBuffer, unsigned short displaySize, QWidget *parent = 0); - virtual ~VectorView() {} + ~VectorView() override = default; QSize sizeHint() const override {return QSize(300, 300);} @@ -74,4 +80,8 @@ private: float m_executionAvg = 0; #endif }; + + +} // namespace lmms::gui + #endif // VECTORVIEW_H diff --git a/plugins/Vectorscope/Vectorscope.cpp b/plugins/Vectorscope/Vectorscope.cpp index b3c2b2dda..b9880691c 100644 --- a/plugins/Vectorscope/Vectorscope.cpp +++ b/plugins/Vectorscope/Vectorscope.cpp @@ -27,11 +27,14 @@ #include "embed.h" #include "plugin_export.h" +namespace lmms +{ + extern "C" { Plugin::Descriptor PLUGIN_EXPORT vectorscope_plugin_descriptor = { - STRINGIFY(PLUGIN_NAME), + LMMS_STRINGIFY(PLUGIN_NAME), "Vectorscope", QT_TRANSLATE_NOOP("PluginBrowser", "A stereo field visualizer."), "Martin Pavelek ", @@ -78,3 +81,5 @@ extern "C" { } } + +} // namespace lmms diff --git a/plugins/Vectorscope/Vectorscope.h b/plugins/Vectorscope/Vectorscope.h index b45ff6de4..54022ab90 100644 --- a/plugins/Vectorscope/Vectorscope.h +++ b/plugins/Vectorscope/Vectorscope.h @@ -28,13 +28,16 @@ #include "LocklessRingBuffer.h" #include "VecControls.h" +namespace lmms +{ + //! Top level class; handles LMMS interface and accumulates data for processing. class Vectorscope : public Effect { public: Vectorscope(Model *parent, const Descriptor::SubPluginFeatures::Key *key); - virtual ~Vectorscope() {}; + ~Vectorscope() override = default; bool processAudioBuffer(sampleFrame *buffer, const fpp_t frame_count) override; EffectControls *controls() override {return &m_controls;} @@ -48,5 +51,8 @@ private: LocklessRingBuffer m_inputBuffer; }; + +} // namespace lmms + #endif // VECTORSCOPE_H diff --git a/plugins/Vestige/Vestige.cpp b/plugins/Vestige/Vestige.cpp index cb1902c66..eab3693b8 100644 --- a/plugins/Vestige/Vestige.cpp +++ b/plugins/Vestige/Vestige.cpp @@ -62,6 +62,8 @@ #include "embed.h" +namespace lmms +{ extern "C" @@ -69,7 +71,7 @@ extern "C" Plugin::Descriptor Q_DECL_EXPORT vestige_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "VeSTige", QT_TRANSLATE_NOOP( "PluginBrowser", "VST-host for using VST(i)-plugins within LMMS" ), @@ -87,6 +89,9 @@ Plugin::Descriptor Q_DECL_EXPORT vestige_plugin_descriptor = } +namespace gui +{ + class vstSubWin : public SubWindow { @@ -98,11 +103,9 @@ public: setWindowFlags( Qt::WindowCloseButtonHint ); } - virtual ~vstSubWin() - { - } + ~vstSubWin() override = default; - virtual void closeEvent( QCloseEvent * e ) + void closeEvent( QCloseEvent * e ) override { // ignore close-events - for some reason otherwise the VST GUI // remains hidden when re-opening @@ -112,6 +115,9 @@ public: }; +} // namespace gui + + class VstInstrumentPlugin : public VstPlugin { public: @@ -124,7 +130,7 @@ public: return; } if ( embedMethod() != "none" ) { - m_pluginSubWindow.reset(new vstSubWin( getGUI()->mainWindow()->workspace() )); + m_pluginSubWindow.reset(new gui::vstSubWin( gui::getGUI()->mainWindow()->workspace() )); VstPlugin::createUI( m_pluginSubWindow.get() ); m_pluginSubWindow->setWidget(pluginWidget()); } else { @@ -144,9 +150,6 @@ private: }; -QPixmap * VestigeInstrumentView::s_artwork = nullptr; -QPixmap * ManageVestigeInstrumentView::s_artwork = nullptr; - VestigeInstrument::VestigeInstrument( InstrumentTrack * _instrument_track ) : Instrument( _instrument_track, &vestige_plugin_descriptor ), @@ -158,7 +161,7 @@ VestigeInstrument::VestigeInstrument( InstrumentTrack * _instrument_track ) : p_subWindow( nullptr ) { // now we need a play-handle which cares for calling play() - InstrumentPlayHandle * iph = new InstrumentPlayHandle( this, _instrument_track ); + auto iph = new InstrumentPlayHandle(this, _instrument_track); Engine::audioEngine()->addPlayHandle( iph ); connect( ConfigManager::inst(), SIGNAL( valueChanged(QString,QString,QString) ), @@ -218,16 +221,16 @@ void VestigeInstrument::loadSettings( const QDomElement & _this ) const QMap & dump = m_plugin->parameterDump(); paramCount = dump.size(); - char paramStr[35]; + auto paramStr = std::array{}; knobFModel = new FloatModel *[ paramCount ]; QStringList s_dumpValues; for( int i = 0; i < paramCount; i++ ) { - sprintf( paramStr, "param%d", i ); - s_dumpValues = dump[ paramStr ].split( ":" ); + sprintf(paramStr.data(), "param%d", i); + s_dumpValues = dump[paramStr.data()].split(":"); knobFModel[i] = new FloatModel( 0.0f, 0.0f, 1.0f, 0.01f, this, QString::number(i) ); - knobFModel[i]->loadSettings( _this, paramStr ); + knobFModel[i]->loadSettings(_this, paramStr.data()); if( !( knobFModel[ i ]->isAutomated() || knobFModel[ i ]->controllerConnection() ) ) { @@ -283,12 +286,12 @@ void VestigeInstrument::saveSettings( QDomDocument & _doc, QDomElement & _this ) if (knobFModel != nullptr) { const QMap & dump = m_plugin->parameterDump(); paramCount = dump.size(); - char paramStr[35]; + auto paramStr = std::array{}; for( int i = 0; i < paramCount; i++ ) { if (knobFModel[i]->isAutomated() || knobFModel[i]->controllerConnection()) { - sprintf( paramStr, "param%d", i); - knobFModel[i]->saveSettings( _doc, _this, paramStr ); + sprintf(paramStr.data(), "param%d", i); + knobFModel[i]->saveSettings(_doc, _this, paramStr.data()); } /* QDomElement me = _doc.createElement( paramStr ); @@ -350,10 +353,10 @@ void VestigeInstrument::loadFile( const QString & _file ) closePlugin(); } m_pluginDLL = PathUtil::toShortestRelative( _file ); - TextFloat * tf = nullptr; - if( getGUI() != nullptr ) + gui::TextFloat * tf = nullptr; + if( gui::getGUI() != nullptr ) { - tf = TextFloat::displayMessage( + tf = gui::TextFloat::displayMessage( tr( "Loading plugin" ), tr( "Please wait while loading the VST plugin..." ), PLUGIN_NAME::getIconPixmap( "logo", 24, 24 ), 0 ); @@ -477,13 +480,17 @@ void VestigeInstrument::closePlugin( void ) -PluginView * VestigeInstrument::instantiateView( QWidget * _parent ) +gui::PluginView * VestigeInstrument::instantiateView( QWidget * _parent ) { - return new VestigeInstrumentView( this, _parent ); + return new gui::VestigeInstrumentView( this, _parent ); } +namespace gui +{ +QPixmap * VestigeInstrumentView::s_artwork = nullptr; +QPixmap * ManageVestigeInstrumentView::s_artwork = nullptr; VestigeInstrumentView::VestigeInstrumentView( Instrument * _instrument, @@ -581,7 +588,7 @@ VestigeInstrumentView::VestigeInstrumentView( Instrument * _instrument, m_selPresetButton = new QPushButton( tr( "" ), this ); m_selPresetButton->setGeometry( 228, 201, 16, 16 ); - QMenu *menu = new QMenu; + auto menu = new QMenu; connect( menu, SIGNAL( aboutToShow() ), this, SLOT( updateMenu() ) ); @@ -598,8 +605,9 @@ VestigeInstrumentView::VestigeInstrumentView( Instrument * _instrument, connect( m_toggleGUIButton, SIGNAL( clicked() ), this, SLOT( toggleGUI() ) ); - QPushButton * note_off_all_btn = new QPushButton( tr( "Turn off all " - "notes" ), this ); + auto note_off_all_btn = new QPushButton(tr("Turn off all " + "notes"), + this); note_off_all_btn->setGeometry( 20, 160, 200, 24 ); note_off_all_btn->setIcon( embed::getIconPixmap( "stop" ) ); note_off_all_btn->setFont( pointSize<8>( note_off_all_btn->font() ) ); @@ -662,13 +670,6 @@ void VestigeInstrumentView::updateMenu( void ) } -VestigeInstrumentView::~VestigeInstrumentView() -{ -} - - - - void VestigeInstrumentView::modelChanged() { m_vi = castModel(); @@ -732,7 +733,7 @@ void VestigeInstrumentView::openPreset() { if ( m_vi->m_plugin != nullptr ) { - m_vi->m_plugin->openPreset( ); + m_vi->m_plugin->openPreset(); bool converted; QString str = m_vi->m_plugin->currentProgramName().section("/", 0, 0); if (str != "") @@ -750,7 +751,7 @@ void VestigeInstrumentView::savePreset() if ( m_vi->m_plugin != nullptr ) { - m_vi->m_plugin->savePreset( ); + m_vi->m_plugin->savePreset(); /* bool converted; QString str = m_vi->m_plugin->presetString().section("/", 0, 0); if (str != "") @@ -797,14 +798,13 @@ void VestigeInstrumentView::previousProgram() void VestigeInstrumentView::selPreset( void ) { - - QAction *action = qobject_cast(sender()); - if (action) - if ( m_vi->m_plugin != nullptr ) { + auto action = qobject_cast(sender()); + if (action && m_vi->m_plugin != nullptr) + { lastPosInMenu = action->data().toInt(); - m_vi->m_plugin->setProgram( action->data().toInt() ); + m_vi->m_plugin->setProgram(action->data().toInt()); QWidget::update(); - } + } } @@ -928,6 +928,17 @@ ManageVestigeInstrumentView::ManageVestigeInstrumentView( Instrument * _instrume QWidget * _parent, VestigeInstrument * m_vi2 ) : InstrumentViewFixedSize( _instrument, _parent ) { +#if QT_VERSION < 0x50C00 + // Workaround for a bug in Qt versions below 5.12, + // where argument-dependent-lookup fails for QFlags operators + // declared inside a namepsace. + // This affects the Q_DECLARE_OPERATORS_FOR_FLAGS macro in Instrument.h + // See also: https://codereview.qt-project.org/c/qt/qtbase/+/225348 + + using ::operator|; + +#endif + m_vi = m_vi2; m_vi->m_scrollArea = new QScrollArea( this ); widget = new QWidget(this); @@ -985,13 +996,13 @@ ManageVestigeInstrumentView::ManageVestigeInstrumentView( Instrument * _instrume hasKnobModel = false; } - char paramStr[35]; + auto paramStr = std::array{}; QStringList s_dumpValues; for( int i = 0; i < m_vi->paramCount; i++ ) { - sprintf( paramStr, "param%d", i); - s_dumpValues = dump[ paramStr ].split( ":" ); + sprintf(paramStr.data(), "param%d", i); + s_dumpValues = dump[paramStr.data()].split(":"); vstKnobs[ i ] = new CustomTextKnob( knobBright_26, this, s_dumpValues.at( 1 ) ); vstKnobs[ i ]->setDescription( s_dumpValues.at( 1 ) + ":" ); @@ -999,9 +1010,9 @@ ManageVestigeInstrumentView::ManageVestigeInstrumentView( Instrument * _instrume if( !hasKnobModel ) { - sprintf( paramStr, "%d", i); - m_vi->knobFModel[ i ] = new FloatModel( LocaleHelper::toFloat(s_dumpValues.at(2)), - 0.0f, 1.0f, 0.01f, castModel(), paramStr ); + sprintf(paramStr.data(), "%d", i); + m_vi->knobFModel[i] = new FloatModel(LocaleHelper::toFloat(s_dumpValues.at(2)), + 0.0f, 1.0f, 0.01f, castModel(), paramStr.data()); } FloatModel * model = m_vi->knobFModel[i]; @@ -1052,7 +1063,7 @@ void ManageVestigeInstrumentView::closeWindow() void ManageVestigeInstrumentView::syncPlugin( void ) { - char paramStr[35]; + auto paramStr = std::array{}; QStringList s_dumpValues; const QMap & dump = m_vi->m_plugin->parameterDump(); float f_value; @@ -1063,8 +1074,8 @@ void ManageVestigeInstrumentView::syncPlugin( void ) // those auto-setted values are not jurnaled, tracked for undo / redo if( !( m_vi->knobFModel[ i ]->isAutomated() || m_vi->knobFModel[ i ]->controllerConnection() ) ) { - sprintf( paramStr, "param%d", i ); - s_dumpValues = dump[ paramStr ].split( ":" ); + sprintf(paramStr.data(), "param%d", i); + s_dumpValues = dump[paramStr.data()].split(":"); f_value = LocaleHelper::toFloat(s_dumpValues.at(2)); m_vi->knobFModel[ i ]->setAutomatedValue( f_value ); m_vi->knobFModel[ i ]->setInitValue( f_value ); @@ -1233,6 +1244,7 @@ void ManageVestigeInstrumentView::paintEvent( QPaintEvent * ) } +} // namespace gui extern "C" @@ -1246,3 +1258,6 @@ Q_DECL_EXPORT Plugin * lmms_plugin_main( Model *m, void * ) } + + +} // namespace lmms diff --git a/plugins/Vestige/Vestige.h b/plugins/Vestige/Vestige.h index 934c26088..0a36c4924 100644 --- a/plugins/Vestige/Vestige.h +++ b/plugins/Vestige/Vestige.h @@ -37,13 +37,22 @@ class QPixmap; class QPushButton; class QScrollArea; - -class CustomTextKnob; -class FloatModel; class QGridLayout; -class PixmapButton; + +namespace lmms +{ + +class FloatModel; class VstPlugin; +namespace gui +{ +class PixmapButton; +class CustomTextKnob; +class VestigeInstrumentView; +class ManageVestigeInstrumentView; +} // namespace gui + class VestigeInstrument : public Instrument { @@ -57,7 +66,7 @@ public: virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); virtual void loadSettings( const QDomElement & _this ); - virtual QString nodeName( void ) const; + virtual QString nodeName() const; virtual void loadFile( const QString & _file ); @@ -68,15 +77,15 @@ public: virtual bool handleMidiEvent( const MidiEvent& event, const TimePos& time, f_cnt_t offset = 0 ); - virtual PluginView * instantiateView( QWidget * _parent ); + virtual gui::PluginView* instantiateView( QWidget * _parent ); protected slots: - void setParameter( Model * action ); + void setParameter( lmms::Model * action ); void handleConfigChange( QString cls, QString attr, QString value ); void reloadPlugin(); private: - void closePlugin( void ); + void closePlugin(); VstPlugin * m_plugin; @@ -90,12 +99,15 @@ private: int paramCount; - friend class VestigeInstrumentView; - friend class ManageVestigeInstrumentView; + friend class gui::VestigeInstrumentView; + friend class gui::ManageVestigeInstrumentView; } ; +namespace gui +{ + class ManageVestigeInstrumentView : public InstrumentViewFixedSize { Q_OBJECT @@ -105,9 +117,9 @@ public: protected slots: - void syncPlugin( void ); - void displayAutomatedOnly( void ); - void setParameter( Model * action ); + void syncPlugin(); + void displayAutomatedOnly(); + void setParameter( lmms::Model * action ); void syncParameterText(); void closeWindow(); @@ -138,20 +150,20 @@ class VestigeInstrumentView : public InstrumentViewFixedSize Q_OBJECT public: VestigeInstrumentView( Instrument * _instrument, QWidget * _parent ); - virtual ~VestigeInstrumentView(); + virtual ~VestigeInstrumentView() = default; protected slots: - void updateMenu( void ); - void openPlugin( void ); - void managePlugin( void ); - void openPreset( void ); - void savePreset( void ); + void updateMenu(); + void openPlugin(); + void managePlugin(); + void openPreset(); + void savePreset(); void nextProgram(); void previousProgram(); - void selPreset( void ); - void toggleGUI( void ); - void noteOffAll( void ); + void selPreset(); + void toggleGUI(); + void noteOffAll(); protected: @@ -161,7 +173,7 @@ protected: private: - virtual void modelChanged( void ); + virtual void modelChanged(); static QPixmap * s_artwork; @@ -184,5 +196,8 @@ private: } ; +} // namespace gui + +} // namespace lmms #endif diff --git a/plugins/Vibed/NineButtonSelector.cpp b/plugins/Vibed/NineButtonSelector.cpp index 618a8e09d..431dbec8b 100644 --- a/plugins/Vibed/NineButtonSelector.cpp +++ b/plugins/Vibed/NineButtonSelector.cpp @@ -29,6 +29,9 @@ #include "CaptionMenu.h" #include "PixmapButton.h" +namespace lmms::gui +{ + NineButtonSelector::NineButtonSelector( QPixmap _button0_on, QPixmap _button0_off, @@ -252,3 +255,6 @@ void NineButtonSelector::contextMenuEvent( QContextMenuEvent * ) CaptionMenu contextMenu( windowTitle(), this ); contextMenu.exec( QCursor::pos() ); } + + +} // namespace lmms::gui diff --git a/plugins/Vibed/NineButtonSelector.h b/plugins/Vibed/NineButtonSelector.h index 96b441031..9c768e996 100644 --- a/plugins/Vibed/NineButtonSelector.h +++ b/plugins/Vibed/NineButtonSelector.h @@ -25,14 +25,20 @@ #ifndef _NINE_BUTTON_SELECTOR_H #define _NINE_BUTTON_SELECTOR_H - #include - #include "AutomatableModelView.h" +namespace lmms +{ +class graphModel; +} + +namespace lmms::gui +{ + + class Knob; class PixmapButton; -class graphModel; class NineButtonSelector: public QWidget , public IntModelView @@ -61,7 +67,7 @@ public: int _default, int _x, int _y, QWidget * _parent); - virtual ~NineButtonSelector(); + ~NineButtonSelector() override; // inline int getSelected() { // return( castModel()->value() ); @@ -80,13 +86,13 @@ public slots: void button6Clicked(); void button7Clicked(); void button8Clicked(); - void contextMenuEvent( QContextMenuEvent * ); + void contextMenuEvent( QContextMenuEvent * ) override; signals: void NineButtonSelection( int ); private: - virtual void modelChanged(); + void modelChanged() override; void updateButton( int ); QList m_buttons; @@ -95,6 +101,8 @@ private: } ; -typedef IntModel NineButtonSelectorModel; +using NineButtonSelectorModel = IntModel; + +} // namespace lmms::gui #endif diff --git a/plugins/Vibed/StringContainer.cpp b/plugins/Vibed/StringContainer.cpp index 0ec38c94f..36dee6da0 100644 --- a/plugins/Vibed/StringContainer.cpp +++ b/plugins/Vibed/StringContainer.cpp @@ -24,6 +24,9 @@ #include "StringContainer.h" +namespace lmms +{ + StringContainer::StringContainer(const float _pitch, const sample_rate_t _sample_rate, @@ -100,3 +103,6 @@ void StringContainer::addString(int _harm, _state ) ); m_exists[_id] = true; } + + +} // namespace lmms \ No newline at end of file diff --git a/plugins/Vibed/StringContainer.h b/plugins/Vibed/StringContainer.h index 503b7c16c..96408c56a 100644 --- a/plugins/Vibed/StringContainer.h +++ b/plugins/Vibed/StringContainer.h @@ -29,6 +29,9 @@ #include "VibratingString.h" #include "MemoryManager.h" +namespace lmms +{ + class StringContainer { @@ -77,4 +80,7 @@ private: QVector m_exists; } ; + +} // namespace lmms + #endif diff --git a/plugins/Vibed/Vibed.cpp b/plugins/Vibed/Vibed.cpp index 0a6f14c2a..9f119aa6e 100644 --- a/plugins/Vibed/Vibed.cpp +++ b/plugins/Vibed/Vibed.cpp @@ -43,12 +43,16 @@ #include "embed.h" #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT vibedstrings_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "Vibed", QT_TRANSLATE_NOOP( "PluginBrowser", "Vibrating string modeler" ), @@ -69,7 +73,7 @@ Vibed::Vibed( InstrumentTrack * _instrumentTrack ) : FloatModel * knob; BoolModel * led; - NineButtonSelectorModel * harmonic; + gui::NineButtonSelectorModel * harmonic; graphModel * graphTmp; for( int harm = 0; harm < 9; harm++ ) @@ -114,7 +118,7 @@ Vibed::Vibed( InstrumentTrack * _instrumentTrack ) : tr( "String %1" ).arg( harm+1 ) ); m_powerButtons.append( led ); - harmonic = new NineButtonSelectorModel( 2, 0, 8, this ); + harmonic = new gui::NineButtonSelectorModel( 2, 0, 8, this ); m_harmonics.append( harmonic ); graphTmp = new graphModel( -1.0, 1.0, __sampleLength, this ); @@ -128,13 +132,6 @@ Vibed::Vibed( InstrumentTrack * _instrumentTrack ) : -Vibed::~Vibed() -{ -} - - - - void Vibed::saveSettings( QDomDocument & _doc, QDomElement & _this ) { @@ -304,8 +301,7 @@ void Vibed::playNote( NotePlayHandle * _n, sampleFrame * _working_buffer ) const fpp_t frames = _n->framesLeftForCurrentPeriod(); const f_cnt_t offset = _n->noteOffset(); - StringContainer * ps = static_cast( - _n->m_pluginData ); + auto ps = static_cast(_n->m_pluginData); for( fpp_t i = offset; i < frames + offset; ++i ) { @@ -340,13 +336,15 @@ void Vibed::deleteNotePluginData( NotePlayHandle * _n ) -PluginView * Vibed::instantiateView( QWidget * _parent ) +gui::PluginView * Vibed::instantiateView( QWidget * _parent ) { - return( new VibedView( this, _parent ) ); + return( new gui::VibedView( this, _parent ) ); } +namespace gui +{ VibedView::VibedView( Instrument * _instrument, @@ -493,7 +491,7 @@ VibedView::VibedView( Instrument * _instrument, m_triangleWaveBtn->setToolTip( tr( "Triangle wave" ) ); connect( m_triangleWaveBtn, SIGNAL ( clicked () ), - this, SLOT ( triangleWaveClicked( ) ) ); + this, SLOT ( triangleWaveClicked() ) ); m_sawWaveBtn = new PixmapButton( this, tr( "Saw wave" ) ); @@ -584,8 +582,8 @@ void VibedView::modelChanged() void VibedView::showString( int _string ) { - Vibed * v = castModel(); - + auto v = castModel(); + m_pickKnob->setModel( v->m_pickKnobs[_string] ); m_pickupKnob->setModel( v->m_pickupKnobs[_string] ); m_stiffnessKnob->setModel( v->m_stiffnessKnobs[_string] ); @@ -679,6 +677,8 @@ void VibedView::contextMenuEvent( QContextMenuEvent * ) } +} // namespace gui + extern "C" { @@ -692,4 +692,4 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *m, void * ) } - +} // namespace lmms diff --git a/plugins/Vibed/Vibed.h b/plugins/Vibed/Vibed.h index 2fee8eaed..75f92157c 100644 --- a/plugins/Vibed/Vibed.h +++ b/plugins/Vibed/Vibed.h @@ -28,35 +28,43 @@ #include "InstrumentView.h" #include "NineButtonSelector.h" +namespace lmms +{ + + +class NotePlayHandle; +class graphModel; + +namespace gui +{ class Graph; class LedCheckBox; -class NotePlayHandle; class VibedView; +} class Vibed : public Instrument { Q_OBJECT public: Vibed( InstrumentTrack * _instrument_track ); - virtual ~Vibed(); - virtual void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ); - virtual void deleteNotePluginData( NotePlayHandle * _n ); + void playNote( NotePlayHandle * _n, + sampleFrame * _working_buffer ) override; + void deleteNotePluginData( NotePlayHandle * _n ) override; - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); + void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; - virtual QString nodeName() const; + QString nodeName() const override; - virtual Flags flags() const + Flags flags() const override { return IsNotBendable; } - virtual PluginView * instantiateView( QWidget * _parent ); + gui::PluginView* instantiateView( QWidget * _parent ) override; private: @@ -71,14 +79,17 @@ private: QList m_powerButtons; QList m_graphs; QList m_impulses; - QList m_harmonics; + QList m_harmonics; static const int __sampleLength = 128; - friend class VibedView; + friend class gui::VibedView; } ; +namespace gui +{ + class VibedView : public InstrumentViewFixedSize { @@ -86,11 +97,11 @@ class VibedView : public InstrumentViewFixedSize public: VibedView( Instrument * _instrument, QWidget * _parent ); - virtual ~VibedView() {}; + ~VibedView() override = default; public slots: void showString( int _string ); - void contextMenuEvent( QContextMenuEvent * ); + void contextMenuEvent( QContextMenuEvent * ) override; protected slots: void sinWaveClicked(); @@ -103,7 +114,7 @@ protected slots: void normalizeClicked(); private: - virtual void modelChanged(); + void modelChanged() override; // String-related @@ -136,4 +147,9 @@ private: }; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/Vibed/VibratingString.cpp b/plugins/Vibed/VibratingString.cpp index fda5c0c5d..e33ef0582 100644 --- a/plugins/Vibed/VibratingString.cpp +++ b/plugins/Vibed/VibratingString.cpp @@ -28,6 +28,9 @@ #include "AudioEngine.h" #include "Engine.h" +namespace lmms +{ + VibratingString::VibratingString( float _pitch, float _pick, @@ -92,7 +95,7 @@ VibratingString::VibratingString( float _pitch, VibratingString::delayLine * VibratingString::initDelayLine( int _len, int _pick ) { - delayLine * dl = new VibratingString::delayLine[_len]; + auto dl = new VibratingString::delayLine[_len]; dl->length = _len; if( _len > 0 ) { @@ -156,3 +159,5 @@ void VibratingString::resample( float *_src, f_cnt_t _src_frames, } } + +} // namespace lmms diff --git a/plugins/Vibed/VibratingString.h b/plugins/Vibed/VibratingString.h index 254e2ebd5..ed7cbe38c 100644 --- a/plugins/Vibed/VibratingString.h +++ b/plugins/Vibed/VibratingString.h @@ -28,6 +28,10 @@ #include "lmms_basics.h" +namespace lmms +{ + + class VibratingString { @@ -267,4 +271,7 @@ private: } ; + +} // namespace lmms + #endif diff --git a/plugins/VstBase/RemoteVstPlugin.cpp b/plugins/VstBase/RemoteVstPlugin.cpp index f2199893a..aaa88f6c8 100644 --- a/plugins/VstBase/RemoteVstPlugin.cpp +++ b/plugins/VstBase/RemoteVstPlugin.cpp @@ -57,7 +57,7 @@ #include #endif -#endif +#endif // LMMS_BUILD_LINUX #ifndef NATIVE_LINUX_VST #define USE_WS_PREFIX @@ -127,16 +127,19 @@ struct ERect using namespace std; -static VstHostLanguages hlang = LanguageEnglish; +static lmms::VstHostLanguages hlang = lmms::LanguageEnglish; static bool EMBED = false; static bool EMBED_X11 = false; static bool EMBED_WIN32 = false; static bool HEADLESS = false; +namespace lmms +{ class RemoteVstPlugin; +} -RemoteVstPlugin * __plugin = nullptr; +lmms::RemoteVstPlugin * __plugin = nullptr; #ifndef NATIVE_LINUX_VST HWND __MessageHwnd = nullptr; @@ -145,6 +148,10 @@ DWORD __processingThreadId = 0; pthread_t __processingThreadId = 0; #endif +namespace lmms +{ + + #ifdef _WIN32 //Returns the last Win32 error, in string format. Returns an empty string if there is no error. std::string GetErrorAsString(DWORD errorMessageID) @@ -468,7 +475,7 @@ private: std::mutex m_shmLock; bool m_shmValid; - typedef std::vector VstMidiEventList; + using VstMidiEventList = std::vector; VstMidiEventList m_midiEvents; bpm_t m_bpm; @@ -484,10 +491,7 @@ private: } ; in * m_in; - - const VstSyncData* m_vstSyncData; - -} ; +}; @@ -516,29 +520,10 @@ RemoteVstPlugin::RemoteVstPlugin( const char * socketPath ) : m_bpm( 0 ), m_currentSamplePos( 0 ), m_currentProgram( -1 ), - m_in( nullptr ), - m_vstSyncData( nullptr ) + m_in( nullptr ) { __plugin = this; - m_vstSyncData = RemotePluginClient::getVstSyncData(); - if( m_vstSyncData == nullptr ) - { - fprintf(stderr, "RemoteVstPlugin.cpp: " - "Failed to initialize shared memory for VST synchronization.\n" - " (VST-host synchronization will be disabled)\n"); - const auto vstSyncData = (VstSyncData*) malloc( sizeof( VstSyncData ) ); - vstSyncData->isPlaying = true; - vstSyncData->timeSigNumer = 4; - vstSyncData->timeSigDenom = 4; - vstSyncData->ppqPos = 0; - vstSyncData->isCycle = false; - vstSyncData->hasSHM = false; - vstSyncData->m_playbackJumped = false; - vstSyncData->m_sampleRate = sampleRate(); - m_vstSyncData = vstSyncData; - } - m_in = ( in* ) new char[ sizeof( in ) ]; m_in->lastppqPos = 0; m_in->m_Timestamp = -1; @@ -565,12 +550,6 @@ RemoteVstPlugin::~RemoteVstPlugin() setResumed( false ); pluginDispatch( effClose ); - if (!m_vstSyncData->hasSHM) - { - delete m_vstSyncData; - m_vstSyncData = nullptr; - } - if( m_libInst != nullptr ) { #ifndef NATIVE_LINUX_VST @@ -904,7 +883,7 @@ void RemoteVstPlugin::initEditor() pluginDispatch(effEditTop); m_x11WindowVisible = true; -#endif +#endif // NATIVE_LINUX_VST } @@ -990,8 +969,7 @@ bool RemoteVstPlugin::load( const std::string & _plugin_file ) } #endif - typedef AEffect * ( VST_CALL_CONV * mainEntryPointer ) - ( audioMasterCallback ); + using mainEntryPointer = AEffect* (VST_CALL_CONV*) (audioMasterCallback); #ifndef NATIVE_LINUX_VST mainEntryPointer mainEntry = (mainEntryPointer) GetProcAddress( m_libInst, "VSTPluginMain" ); @@ -1070,7 +1048,7 @@ void RemoteVstPlugin::process( const sampleFrame * _in, sampleFrame * _out ) return a.deltaFrames < b.deltaFrames; } ); - VstEvents* events = (VstEvents *) eventsBuffer; + auto events = (VstEvents*)eventsBuffer; events->reserved = 0; events->numEvents = m_midiEvents.size(); @@ -1112,16 +1090,16 @@ void RemoteVstPlugin::process( const sampleFrame * _in, sampleFrame * _out ) #ifdef OLD_VST_SDK if( m_plugin->flags & effFlagsCanReplacing ) { -#endif m_plugin->processReplacing( m_plugin, m_inputs, m_outputs, bufferSize() ); -#ifdef OLD_VST_SDK } else { m_plugin->process( m_plugin, m_inputs, m_outputs, bufferSize() ); } +#else + m_plugin->processReplacing(m_plugin, m_inputs, m_outputs, bufferSize()); #endif unlockShm(); @@ -1447,7 +1425,7 @@ struct sBank void RemoteVstPlugin::savePreset( const std::string & _file ) { unsigned int chunk_size = 0; - sBank * pBank = ( sBank* ) new char[ sizeof( sBank ) ]; + auto pBank = (sBank*)new char[sizeof(sBank)]; char progName[ 128 ] = { 0 }; char* data = nullptr; const bool chunky = ( m_plugin->flags & ( 1 << 5 ) ) != 0; @@ -1466,11 +1444,11 @@ void RemoteVstPlugin::savePreset( const std::string & _file ) if (isPreset) { chunk_size = m_plugin->numParams * sizeof( float ); data = new char[ chunk_size ]; - unsigned int* toUIntArray = reinterpret_cast( data ); + auto toUIntArray = reinterpret_cast(data); for ( int i = 0; i < m_plugin->numParams; i++ ) { float value = m_plugin->getParameter( m_plugin, i ); - unsigned int * pValue = ( unsigned int * ) &value; + auto pValue = (unsigned int*)&value; toUIntArray[ i ] = endian_swap( *pValue ); } } else chunk_size = (((m_plugin->numParams * sizeof( float )) + 56)*m_plugin->numPrograms); @@ -1485,7 +1463,7 @@ void RemoteVstPlugin::savePreset( const std::string & _file ) if (!isPreset &&!chunky) pBank->fxMagic = 0x6B427846; pBank->version = 0x01000000; - unsigned int uIntToFile = (unsigned int) m_plugin->uniqueID; + auto uIntToFile = (unsigned int)m_plugin->uniqueID; pBank->fxID = endian_swap( uIntToFile ); uIntToFile = (unsigned int) pluginVersion(); pBank->fxVersion = endian_swap( uIntToFile ); @@ -1548,9 +1526,9 @@ void RemoteVstPlugin::savePreset( const std::string & _file ) void RemoteVstPlugin::loadPresetFile( const std::string & _file ) { void * chunk = nullptr; - unsigned int * pLen = new unsigned int[ 1 ]; + auto pLen = new unsigned int[1]; unsigned int len = 0; - sBank * pBank = (sBank*) new char[ sizeof( sBank ) ]; + auto pBank = (sBank*)new char[sizeof(sBank)]; FILE * stream = F_OPEN_UTF8( _file, "rb" ); if (!stream) { @@ -1602,7 +1580,7 @@ void RemoteVstPlugin::loadPresetFile( const std::string & _file ) pluginDispatch( 24, 1, len, chunk ); else { - unsigned int* toUIntArray = reinterpret_cast( chunk ); + auto toUIntArray = reinterpret_cast(chunk); for (int i = 0; i < pBank->numPrograms; i++ ) { toUInt = endian_swap( toUIntArray[ i ] ); @@ -1656,7 +1634,7 @@ void RemoteVstPlugin::loadPresetFile( const std::string & _file ) void RemoteVstPlugin::loadChunkFromFile( const std::string & _file, int _len ) { - char * chunk = new char[_len]; + auto chunk = new char[_len]; FILE* fp = F_OPEN_UTF8( _file, "rb" ); if (!fp) @@ -1801,86 +1779,71 @@ intptr_t RemoteVstPlugin::hostCallback( AEffect * _effect, int32_t _opcode, return 0; case audioMasterGetTime: + { SHOW_CALLBACK( "amc: audioMasterGetTime\n" ); // returns const VstTimeInfo* (or 0 if not supported) // should contain a mask indicating which // fields are required (see valid masks above), as some // items may require extensive conversions - // Shared memory was initialised? - see song.cpp - //assert( __plugin->m_vstSyncData != nullptr ); + const auto syncData = __plugin->getVstSyncData(); + assert(syncData != nullptr); memset( &_timeInfo, 0, sizeof( _timeInfo ) ); _timeInfo.samplePos = __plugin->m_currentSamplePos; - _timeInfo.sampleRate = __plugin->m_vstSyncData->hasSHM ? - __plugin->m_vstSyncData->m_sampleRate : - __plugin->sampleRate(); + _timeInfo.sampleRate = syncData->m_sampleRate; _timeInfo.flags = 0; - _timeInfo.tempo = __plugin->m_vstSyncData->hasSHM ? - __plugin->m_vstSyncData->m_bpm : - __plugin->m_bpm; - _timeInfo.timeSigNumerator = __plugin->m_vstSyncData->timeSigNumer; - _timeInfo.timeSigDenominator = __plugin->m_vstSyncData->timeSigDenom; + _timeInfo.tempo = syncData->m_bpm; + _timeInfo.timeSigNumerator = syncData->timeSigNumer; + _timeInfo.timeSigDenominator = syncData->timeSigDenom; _timeInfo.flags |= kVstTempoValid; _timeInfo.flags |= kVstTimeSigValid; - if( __plugin->m_vstSyncData->isCycle ) + if (syncData->isCycle) { - _timeInfo.cycleStartPos = __plugin->m_vstSyncData->cycleStart; - _timeInfo.cycleEndPos = __plugin->m_vstSyncData->cycleEnd; + _timeInfo.cycleStartPos = syncData->cycleStart; + _timeInfo.cycleEndPos = syncData->cycleEnd; _timeInfo.flags |= kVstCyclePosValid; _timeInfo.flags |= kVstTransportCycleActive; } - if( __plugin->m_vstSyncData->ppqPos != - __plugin->m_in->m_Timestamp ) + if (syncData->ppqPos != __plugin->m_in->m_Timestamp) { - _timeInfo.ppqPos = __plugin->m_vstSyncData->ppqPos; - __plugin->m_in->lastppqPos = __plugin->m_vstSyncData->ppqPos; - __plugin->m_in->m_Timestamp = __plugin->m_vstSyncData->ppqPos; + _timeInfo.ppqPos = syncData->ppqPos; + __plugin->m_in->lastppqPos = syncData->ppqPos; + __plugin->m_in->m_Timestamp = syncData->ppqPos; } - else if( __plugin->m_vstSyncData->isPlaying ) + else if (syncData->isPlaying) { - if( __plugin->m_vstSyncData->hasSHM ) - { - __plugin->m_in->lastppqPos += - __plugin->m_vstSyncData->m_bpm / 60.0 - * __plugin->m_vstSyncData->m_bufferSize - / __plugin->m_vstSyncData->m_sampleRate; - } - else - { - __plugin->m_in->lastppqPos += - __plugin->m_bpm / 60.0 - * __plugin->bufferSize() - / __plugin->sampleRate(); - } + __plugin->m_in->lastppqPos += + syncData->m_bpm / 60.0 + * syncData->m_bufferSize + / syncData->m_sampleRate; _timeInfo.ppqPos = __plugin->m_in->lastppqPos; } -// _timeInfo.ppqPos = __plugin->m_vstSyncData->ppqPos; +// _timeInfo.ppqPos = syncData->ppqPos; _timeInfo.flags |= kVstPpqPosValid; - if( __plugin->m_vstSyncData->isPlaying ) + if (syncData->isPlaying) { _timeInfo.flags |= kVstTransportPlaying; } - _timeInfo.barStartPos = ( (int) ( _timeInfo.ppqPos / - ( 4 *__plugin->m_vstSyncData->timeSigNumer - / (float) __plugin->m_vstSyncData->timeSigDenom ) ) ) * - ( 4 * __plugin->m_vstSyncData->timeSigNumer - / (float) __plugin->m_vstSyncData->timeSigDenom ); + _timeInfo.barStartPos = ((int) (_timeInfo.ppqPos + / (4 * syncData->timeSigNumer / (float) syncData->timeSigDenom))) + * (4 * syncData->timeSigNumer / (float) syncData->timeSigDenom); _timeInfo.flags |= kVstBarsValid; - if( ( _timeInfo.flags & ( kVstTransportPlaying | kVstTransportCycleActive ) ) != - ( __plugin->m_in->m_lastFlags & ( kVstTransportPlaying | kVstTransportCycleActive ) ) - || __plugin->m_vstSyncData->m_playbackJumped ) + if ((_timeInfo.flags & (kVstTransportPlaying | kVstTransportCycleActive)) + != (__plugin->m_in->m_lastFlags & (kVstTransportPlaying | kVstTransportCycleActive)) + || syncData->m_playbackJumped) { _timeInfo.flags |= kVstTransportChanged; } __plugin->m_in->m_lastFlags = _timeInfo.flags; return (intptr_t) &_timeInfo; + } case audioMasterProcessEvents: SHOW_CALLBACK( "amc: audioMasterProcessEvents\n" ); @@ -1974,7 +1937,7 @@ intptr_t RemoteVstPlugin::hostCallback( AEffect * _effect, int32_t _opcode, // TODO // close window, platform specific handle in return 0; -#endif +#endif // OLD_VST_SDK case audioMasterSizeWindow: { @@ -2158,7 +2121,10 @@ void RemoteVstPlugin::idle() return; } setProcessing( true ); - pluginDispatch( effEditIdle ); + if (!HEADLESS && m_window) + { + pluginDispatch( effEditIdle ); + } setShouldGiveIdle( false ); setProcessing( false ); // We might have received a message whilst idling @@ -2206,7 +2172,10 @@ void RemoteVstPlugin::processUIThreadMessages() #endif if( shouldGiveIdle() ) { - pluginDispatch( effEditIdle ); + if (!HEADLESS && m_window) + { + pluginDispatch( effEditIdle ); + } setShouldGiveIdle( false ); } #ifdef NATIVE_LINUX_VST @@ -2365,7 +2334,7 @@ void RemoteVstPlugin::guiEventLoop() } } } -#endif +#endif // NATIVE_LINUX_VST #ifndef NATIVE_LINUX_VST @@ -2414,11 +2383,17 @@ LRESULT CALLBACK RemoteVstPlugin::wndProc( HWND hwnd, UINT uMsg, return DefWindowProc( hwnd, uMsg, wParam, lParam ); } -#endif + + +#endif // NATIVE_LINUX_VST + +} // namespace lmms int main( int _argc, char * * _argv ) { + using lmms::RemoteVstPlugin; + #ifdef SYNC_WITH_SHM_FIFO if( _argc < 4 ) #else @@ -2430,7 +2405,7 @@ int main( int _argc, char * * _argv ) } #ifndef LMMS_BUILD_WIN32 - const auto pollParentThread = PollParentThread{}; + const auto pollParentThread = lmms::PollParentThread{}; #endif #ifndef NATIVE_LINUX_VST @@ -2446,7 +2421,7 @@ int main( int _argc, char * * _argv ) sched_get_priority_min( SCHED_FIFO ) ) / 2; sched_setscheduler( 0, SCHED_FIFO, &sparam ); #endif -#endif +#endif // LMMS_BUILD_LINUX #ifdef LMMS_BUILD_WIN32 if( !SetPriorityClass( GetCurrentProcess(), HIGH_PRIORITY_CLASS ) ) @@ -2490,32 +2465,32 @@ int main( int _argc, char * * _argv ) if ( embedMethod == "none" ) { - cerr << "Starting detached." << endl; + std::cerr << "Starting detached." << std::endl; EMBED = EMBED_X11 = EMBED_WIN32 = HEADLESS = false; } else if ( embedMethod == "win32" ) { - cerr << "Starting using Win32-native embedding." << endl; + std::cerr << "Starting using Win32-native embedding." << std::endl; EMBED = EMBED_WIN32 = true; EMBED_X11 = HEADLESS = false; } else if ( embedMethod == "qt" ) { - cerr << "Starting using Qt-native embedding." << endl; + std::cerr << "Starting using Qt-native embedding." << std::endl; EMBED = true; EMBED_X11 = EMBED_WIN32 = HEADLESS = false; } else if ( embedMethod == "xembed" ) { - cerr << "Starting using X11Embed protocol." << endl; + std::cerr << "Starting using X11Embed protocol." << std::endl; EMBED = EMBED_X11 = true; EMBED_WIN32 = HEADLESS = false; } else if ( embedMethod == "headless" ) { - cerr << "Starting without UI." << endl; + std::cerr << "Starting without UI." << std::endl; HEADLESS = true; EMBED = EMBED_X11 = EMBED_WIN32 = false; } else { - cerr << "Unknown embed method " << embedMethod << ". Starting detached instead." << endl; + std::cerr << "Unknown embed method " << embedMethod << ". Starting detached instead." << std::endl; EMBED = EMBED_X11 = EMBED_WIN32 = HEADLESS = false; } } @@ -2523,7 +2498,7 @@ int main( int _argc, char * * _argv ) #ifdef NATIVE_LINUX_VST if (EMBED) { - cerr << "Native linux VST works only without embedding." << endl; + std::cerr << "Native linux VST works only without embedding." << std::endl; } #endif @@ -2567,4 +2542,3 @@ int main( int _argc, char * * _argv ) #endif return 0; } - diff --git a/plugins/VstBase/RemoteVstPlugin/CMakeLists.txt b/plugins/VstBase/RemoteVstPlugin/CMakeLists.txt index 43e67f7de..3356ae596 100644 --- a/plugins/VstBase/RemoteVstPlugin/CMakeLists.txt +++ b/plugins/VstBase/RemoteVstPlugin/CMakeLists.txt @@ -89,9 +89,25 @@ if(IS_MINGW) endif() endif() -IF(STRIP) - ADD_CUSTOM_COMMAND(TARGET ${EXE_NAME} POST_BUILD COMMAND "${STRIP}" "$") -ENDIF() +if(LMMS_BUILD_WIN32) + if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.16") + set(NOOP_COMMAND "${CMAKE_COMMAND}" "-E" "true") + else() + set(NOOP_COMMAND "${CMAKE_COMMAND}" "-E" "echo") + endif() + if(STRIP) + set(STRIP_COMMAND "$,${NOOP_COMMAND},${STRIP}>") + else() + set(STRIP_COMMAND "${NOOP_COMMAND}") + endif() + add_custom_command( + TARGET "${EXE_NAME}" + POST_BUILD + COMMAND "${STRIP_COMMAND}" "$" + VERBATIM + COMMAND_EXPAND_LISTS + ) +endif() if(BITNESS EQUAL 32) INSTALL(TARGETS ${EXE_NAME} RUNTIME DESTINATION "${PLUGIN_DIR}/32") diff --git a/plugins/VstBase/VstPlugin.cpp b/plugins/VstBase/VstPlugin.cpp index 61d734675..700a14ac7 100644 --- a/plugins/VstBase/VstPlugin.cpp +++ b/plugins/VstBase/VstPlugin.cpp @@ -111,7 +111,10 @@ private: uchar* m_map; }; -} +} // namespace PE + +namespace lmms +{ enum class ExecutableType { @@ -121,7 +124,7 @@ enum class ExecutableType VstPlugin::VstPlugin( const QString & _plugin ) : m_plugin( PathUtil::toAbsolute(_plugin) ), m_pluginWindowID( 0 ), - m_embedMethod( (getGUI() != nullptr) + m_embedMethod( (gui::getGUI() != nullptr) ? ConfigManager::inst()->vstEmbedMethod() : "headless" ), m_version( 0 ), @@ -179,8 +182,8 @@ VstPlugin::VstPlugin( const QString & _plugin ) : setTempo( Engine::getSong()->getTempo() ); - connect( Engine::getSong(), SIGNAL( tempoChanged( bpm_t ) ), - this, SLOT( setTempo( bpm_t ) ), Qt::DirectConnection ); + connect( Engine::getSong(), SIGNAL( tempoChanged( lmms::bpm_t ) ), + this, SLOT( setTempo( lmms::bpm_t ) ), Qt::DirectConnection ); connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( updateSampleRate() ) ); @@ -372,15 +375,12 @@ void VstPlugin::setParameterDump( const QMap & _pdump ) { message m( IdVstSetParameterDump ); m.addInt( _pdump.size() ); - for( QMap::ConstIterator it = _pdump.begin(); - it != _pdump.end(); ++it ) + for (const auto& str : _pdump) { const VstParameterDumpItem item = { - ( *it ).section( ':', 0, 0 ).toInt(), - "", - LocaleHelper::toFloat((*it).section(':', 2, -1)) - } ; + str.section(':', 0, 0).toInt(), "", LocaleHelper::toFloat(str.section(':', 2, -1)) + }; m.addInt( item.index ); m.addString( item.shortLabel ); m.addFloat( item.value ); @@ -413,13 +413,13 @@ bool VstPlugin::processMessage( const message & _m ) // so this is legal despite MSDN's warning SetWindowLongPtr( (HWND)(intptr_t) m_pluginWindowID, GWLP_HWNDPARENT, - (LONG_PTR) getGUI()->mainWindow()->winId() ); + (LONG_PTR) gui::getGUI()->mainWindow()->winId() ); #endif #ifdef LMMS_BUILD_LINUX XSetTransientForHint( QX11Info::display(), m_pluginWindowID, - getGUI()->mainWindow()->winId() ); + gui::getGUI()->mainWindow()->winId() ); #endif } break; @@ -502,22 +502,16 @@ QWidget *VstPlugin::editor() } -void VstPlugin::openPreset( ) +void VstPlugin::openPreset() { - - FileDialog ofd( nullptr, tr( "Open Preset" ), "", - tr( "Vst Plugin Preset (*.fxp *.fxb)" ) ); - ofd.setFileMode( FileDialog::ExistingFiles ); - if( ofd.exec () == QDialog::Accepted && - !ofd.selectedFiles().isEmpty() ) + gui::FileDialog ofd(nullptr, tr("Open Preset"), "", tr("VST Plugin Preset (*.fxp *.fxb)")); + ofd.setFileMode(gui::FileDialog::ExistingFiles); + if (ofd.exec() == QDialog::Accepted && !ofd.selectedFiles().isEmpty()) { lock(); - sendMessage( message( IdLoadPresetFile ). - addString( - QSTR_TO_STDSTR( - QDir::toNativeSeparators( ofd.selectedFiles()[0] ) ) ) - ); - waitForMessage( IdLoadPresetFile, true ); + sendMessage(message(IdLoadPresetFile).addString(QSTR_TO_STDSTR( + QDir::toNativeSeparators(ofd.selectedFiles()[0])))); + waitForMessage(IdLoadPresetFile, true); unlock(); } } @@ -580,37 +574,37 @@ void VstPlugin::loadParameterDisplays() -void VstPlugin::savePreset( ) +void VstPlugin::savePreset() { QString presName = currentProgramName().isEmpty() ? tr(": default") : currentProgramName(); presName.replace("\"", "'"); // QFileDialog unable to handle double quotes properly - FileDialog sfd( nullptr, tr( "Save Preset" ), presName.section(": ", 1, 1) + tr(".fxp"), - tr( "Vst Plugin Preset (*.fxp *.fxb)" ) ); + gui::FileDialog sfd(nullptr, tr("Save Preset"), presName.section(": ", 1, 1) + tr(".fxp"), + tr("VST Plugin Preset (*.fxp *.fxb)")); - if( p_name != "" ) // remember last directory + if (p_name != "") // remember last directory { - sfd.setDirectory( QFileInfo( p_name ).absolutePath() ); + sfd.setDirectory(QFileInfo(p_name).absolutePath()); } - sfd.setAcceptMode( FileDialog::AcceptSave ); - sfd.setFileMode( FileDialog::AnyFile ); - if( sfd.exec () == QDialog::Accepted && - !sfd.selectedFiles().isEmpty() && sfd.selectedFiles()[0] != "" ) + sfd.setAcceptMode(gui::FileDialog::AcceptSave); + sfd.setFileMode(gui::FileDialog::AnyFile); + if (sfd.exec() == QDialog::Accepted && !sfd.selectedFiles().isEmpty() && sfd.selectedFiles()[0] != "") { QString fns = sfd.selectedFiles()[0]; p_name = fns; if ((fns.toUpper().indexOf(tr(".FXP")) == -1) && (fns.toUpper().indexOf(tr(".FXB")) == -1)) + { fns = fns + tr(".fxb"); - else fns = fns.left(fns.length() - 4) + (fns.right( 4 )).toLower(); + } + else + { + fns = fns.left(fns.length() - 4) + (fns.right(4)).toLower(); + } lock(); - sendMessage( message( IdSavePresetFile ). - addString( - QSTR_TO_STDSTR( - QDir::toNativeSeparators( fns ) ) ) - ); - waitForMessage( IdSavePresetFile, true ); + sendMessage(message(IdSavePresetFile).addString(QSTR_TO_STDSTR(QDir::toNativeSeparators(fns)))); + waitForMessage(IdSavePresetFile, true); unlock(); } } @@ -788,7 +782,7 @@ void VstPlugin::createUI( QWidget * parent ) { parent->setAttribute(Qt::WA_NativeWindow); } - QX11EmbedContainer * embedContainer = new QX11EmbedContainer( parent ); + auto embedContainer = new QX11EmbedContainer(parent); connect(embedContainer, SIGNAL(clientIsEmbedded()), this, SLOT(handleClientEmbed())); embedContainer->embedClient( m_pluginWindowID ); container = embedContainer; @@ -823,3 +817,6 @@ QString VstPlugin::embedMethod() const { return m_embedMethod; } + + +} // namespace lmms diff --git a/plugins/VstBase/VstPlugin.h b/plugins/VstBase/VstPlugin.h index 2317cf3ad..03e732970 100644 --- a/plugins/VstBase/VstPlugin.h +++ b/plugins/VstBase/VstPlugin.h @@ -36,7 +36,8 @@ #include "vstbase_export.h" -class vstSubWin; +namespace lmms +{ class VSTBASE_EXPORT VstPlugin : public RemotePlugin, public JournallingObject @@ -44,7 +45,7 @@ class VSTBASE_EXPORT VstPlugin : public RemotePlugin, public JournallingObject Q_OBJECT public: VstPlugin( const QString & _plugin ); - virtual ~VstPlugin(); + ~VstPlugin() override; void tryLoad( const QString &remoteVstPluginExecutable ); @@ -111,7 +112,7 @@ public: void loadSettings( const QDomElement & _this ) override; void saveSettings( QDomDocument & _doc, QDomElement & _this ) override; - virtual QString nodeName() const override + QString nodeName() const override { return "vstplugin"; } @@ -123,15 +124,15 @@ public: QString embedMethod() const; public slots: - void setTempo( bpm_t _bpm ); + void setTempo( lmms::bpm_t _bpm ); void updateSampleRate(); - void openPreset( void ); + void openPreset(); void setProgram( int index ); void rotateProgram( int offset ); void loadProgramNames(); void loadParameterLabels(); void loadParameterDisplays(); - void savePreset( void ); + void savePreset(); void setParam( int i, float f ); void idleUpdate(); @@ -173,4 +174,6 @@ private: } ; +} // namespace lmms + #endif diff --git a/plugins/VstBase/communication.h b/plugins/VstBase/communication.h index c25b213d1..1f32dd135 100644 --- a/plugins/VstBase/communication.h +++ b/plugins/VstBase/communication.h @@ -27,6 +27,8 @@ #ifndef _COMMUNICATION_H #define _COMMUNICATION_H +namespace lmms +{ struct VstParameterDumpItem @@ -54,7 +56,7 @@ enum VstHostLanguages enum VstRemoteMessageIDs { // vstPlugin -> remoteVstPlugin - IdVstLoadPlugin = IdUserBase, + IdVstLoadPlugin = RemoteMessageIDs::IdUserBase, IdVstClosePlugin, IdVstSetTempo, IdVstSetLanguage, @@ -87,5 +89,6 @@ enum VstRemoteMessageIDs } ; +} // namespace lmms #endif diff --git a/plugins/VstBase/vst_base.cpp b/plugins/VstBase/vst_base.cpp index 67217390a..80cb9d736 100644 --- a/plugins/VstBase/vst_base.cpp +++ b/plugins/VstBase/vst_base.cpp @@ -27,12 +27,16 @@ #include "Plugin.h" #include "vstbase_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor VSTBASE_EXPORT vstbase_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "VST Base", "library for all LMMS plugins dealing with VST-plugins", "Tobias Doerffel ", @@ -45,3 +49,4 @@ Plugin::Descriptor VSTBASE_EXPORT vstbase_plugin_descriptor = } +} // namespace lmms diff --git a/plugins/VstEffect/VstEffect.cpp b/plugins/VstEffect/VstEffect.cpp index df5b18eb9..c3e40cfa7 100644 --- a/plugins/VstEffect/VstEffect.cpp +++ b/plugins/VstEffect/VstEffect.cpp @@ -34,12 +34,16 @@ #include "embed.h" #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT vsteffect_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "VST", QT_TRANSLATE_NOOP( "PluginBrowser", "plugin for using arbitrary VST effects inside LMMS." ), @@ -72,13 +76,6 @@ VstEffect::VstEffect( Model * _parent, -VstEffect::~VstEffect() -{ -} - - - - bool VstEffect::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames ) { if( !isEnabled() || !isRunning () ) @@ -126,10 +123,10 @@ bool VstEffect::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames ) void VstEffect::openPlugin( const QString & _plugin ) { - TextFloat * tf = nullptr; - if( getGUI() != nullptr ) + gui::TextFloat* tf = nullptr; + if( gui::getGUI() != nullptr ) { - tf = TextFloat::displayMessage( + tf = gui::TextFloat::displayMessage( VstPlugin::tr( "Loading plugin" ), VstPlugin::tr( "Please wait while loading VST plugin..." ), PLUGIN_NAME::getIconPixmap( "logo", 24, 24 ), 0 ); @@ -166,3 +163,5 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model * _parent, void * _data ) } + +} // namespace lmms diff --git a/plugins/VstEffect/VstEffect.h b/plugins/VstEffect/VstEffect.h index 7070ffc2f..987b1ecc2 100644 --- a/plugins/VstEffect/VstEffect.h +++ b/plugins/VstEffect/VstEffect.h @@ -31,19 +31,24 @@ #include "Effect.h" #include "VstEffectControls.h" +namespace lmms +{ + + class VstPlugin; + class VstEffect : public Effect { public: VstEffect( Model * _parent, const Descriptor::SubPluginFeatures::Key * _key ); - virtual ~VstEffect(); + ~VstEffect() override = default; - virtual bool processAudioBuffer( sampleFrame * _buf, - const fpp_t _frames ); + bool processAudioBuffer( sampleFrame * _buf, + const fpp_t _frames ) override; - virtual EffectControls * controls() + EffectControls * controls() override { return &m_vstControls; } @@ -61,11 +66,12 @@ private: friend class VstEffectControls; - friend class VstEffectControlDialog; - friend class ManageVSTEffectView; + friend class gui::VstEffectControlDialog; + friend class gui::ManageVSTEffectView; } ; +} // namespace lmms #endif diff --git a/plugins/VstEffect/VstEffectControlDialog.cpp b/plugins/VstEffect/VstEffectControlDialog.cpp index 4e86cc71d..52160af57 100644 --- a/plugins/VstEffect/VstEffectControlDialog.cpp +++ b/plugins/VstEffect/VstEffectControlDialog.cpp @@ -37,6 +37,10 @@ #include #include +namespace lmms::gui +{ + + VstEffectControlDialog::VstEffectControlDialog( VstEffectControls * _ctl ) : EffectControlDialog( _ctl ), m_pluginWidget( nullptr ), @@ -44,7 +48,7 @@ VstEffectControlDialog::VstEffectControlDialog( VstEffectControls * _ctl ) : m_plugin( nullptr ), tbLabel( nullptr ) { - QGridLayout * l = new QGridLayout( this ); + auto l = new QGridLayout(this); l->setContentsMargins( 10, 10, 10, 10 ); l->setVerticalSpacing( 2 ); l->setHorizontalSpacing( 2 ); @@ -69,7 +73,7 @@ VstEffectControlDialog::VstEffectControlDialog( VstEffectControls * _ctl ) : { setWindowTitle( m_plugin->name() ); - QPushButton * btn = new QPushButton( tr( "Show/hide" )); + auto btn = new QPushButton(tr("Show/hide")); if (embed_vst) { btn->setCheckable( true ); @@ -169,7 +173,7 @@ VstEffectControlDialog::VstEffectControlDialog( VstEffectControls * _ctl ) : _ctl->m_selPresetButton->setCursor( Qt::PointingHandCursor ); _ctl->m_selPresetButton->setIcon( embed::getIconPixmap( "stepper-down" ) ); - QMenu * menu = new QMenu; + auto menu = new QMenu; connect( menu, SIGNAL( aboutToShow() ), _ctl, SLOT( updateMenu() ) ); _ctl->m_selPresetButton->setMenu(menu); @@ -202,11 +206,11 @@ VstEffectControlDialog::VstEffectControlDialog( VstEffectControls * _ctl ) : } newSize = std::max(newSize, 250); - QWidget* resize = new QWidget(this); + auto resize = new QWidget(this); resize->resize( newSize, 10 ); - QWidget* space0 = new QWidget(this); + auto space0 = new QWidget(this); space0->resize(8, 10); - QWidget* space1 = new QWidget(this); + auto space1 = new QWidget(this); space1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); QFont f( "Arial", 10 ); @@ -219,7 +223,7 @@ VstEffectControlDialog::VstEffectControlDialog( VstEffectControls * _ctl ) : l->setRowStretch( 5, 1 ); l->setColumnStretch( 1, 1 ); - QToolBar * tb = new QToolBar( this ); + auto tb = new QToolBar(this); tb->resize( newSize , 32 ); tb->addWidget(space0); tb->addWidget( m_rolLPresetButton ); @@ -294,3 +298,5 @@ void VstEffectControlDialog::togglePluginUI( bool checked ) } } + +} // namespace lmms::gui \ No newline at end of file diff --git a/plugins/VstEffect/VstEffectControlDialog.h b/plugins/VstEffect/VstEffectControlDialog.h index dad68ae04..1fb538ca5 100644 --- a/plugins/VstEffect/VstEffectControlDialog.h +++ b/plugins/VstEffect/VstEffectControlDialog.h @@ -29,13 +29,19 @@ #include +class QPixmap; +class QPushButton; +class QLabel; + +namespace lmms +{ class VstEffectControls; class VstPlugin; -class PixmapButton; -class QLabel; -class QPixmap; -class QPushButton; + +namespace gui +{ + class PixmapButton; @@ -44,7 +50,7 @@ class VstEffectControlDialog : public EffectControlDialog Q_OBJECT public: VstEffectControlDialog( VstEffectControls * _controls ); - virtual ~VstEffectControlDialog(); + ~VstEffectControlDialog() override; protected: void paintEvent( QPaintEvent * _pe ) override; @@ -68,4 +74,9 @@ public slots: void togglePluginUI( bool checked ); } ; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/VstEffect/VstEffectControls.cpp b/plugins/VstEffect/VstEffectControls.cpp index 21de98fab..e73530a09 100644 --- a/plugins/VstEffect/VstEffectControls.cpp +++ b/plugins/VstEffect/VstEffectControls.cpp @@ -42,6 +42,8 @@ #include "SubWindow.h" #include +namespace lmms +{ VstEffectControls::VstEffectControls( VstEffect * _eff ) : @@ -81,16 +83,16 @@ void VstEffectControls::loadSettings( const QDomElement & _this ) const QMap & dump = m_effect->m_plugin->parameterDump(); paramCount = dump.size(); - char paramStr[35]; + auto paramStr = std::array{}; knobFModel = new FloatModel *[ paramCount ]; QStringList s_dumpValues; for( int i = 0; i < paramCount; i++ ) { - sprintf( paramStr, "param%d", i ); - s_dumpValues = dump[ paramStr ].split( ":" ); + sprintf(paramStr.data(), "param%d", i); + s_dumpValues = dump[paramStr.data()].split(":"); knobFModel[i] = new FloatModel( 0.0f, 0.0f, 1.0f, 0.01f, this, QString::number(i) ); - knobFModel[i]->loadSettings( _this, paramStr ); + knobFModel[i]->loadSettings(_this, paramStr.data()); if( !( knobFModel[ i ]->isAutomated() || knobFModel[ i ]->controllerConnection() ) ) @@ -132,12 +134,12 @@ void VstEffectControls::saveSettings( QDomDocument & _doc, QDomElement & _this ) if (knobFModel != nullptr) { const QMap & dump = m_effect->m_plugin->parameterDump(); paramCount = dump.size(); - char paramStr[35]; + auto paramStr = std::array{}; for( int i = 0; i < paramCount; i++ ) { if (knobFModel[i]->isAutomated() || knobFModel[i]->controllerConnection()) { - sprintf( paramStr, "param%d", i); - knobFModel[i]->saveSettings( _doc, _this, paramStr ); + sprintf(paramStr.data(), "param%d", i); + knobFModel[i]->saveSettings(_doc, _this, paramStr.data()); } } } @@ -155,9 +157,9 @@ int VstEffectControls::controlCount() -EffectControlDialog *VstEffectControls::createView() +gui::EffectControlDialog* VstEffectControls::createView() { - auto dialog = new VstEffectControlDialog( this ); + auto dialog = new gui::VstEffectControlDialog( this ); dialog->togglePluginUI( m_vstGuiVisible ); return dialog; } @@ -165,13 +167,13 @@ EffectControlDialog *VstEffectControls::createView() -void VstEffectControls::managePlugin( void ) +void VstEffectControls::managePlugin() { if ( m_effect->m_plugin != nullptr && m_subWindow == nullptr ) { - ManageVSTEffectView * tt = new ManageVSTEffectView( m_effect, this); + auto tt = new gui::ManageVSTEffectView(m_effect, this); ctrHandle = (QObject *)tt; } else if (m_subWindow != nullptr) { - if (m_subWindow->widget()->isVisible() == false ) { + if (m_subWindow->widget()->isVisible() == false ) { m_scrollArea->show(); m_subWindow->show(); } else { @@ -185,11 +187,11 @@ void VstEffectControls::managePlugin( void ) -void VstEffectControls::savePreset( void ) +void VstEffectControls::savePreset() { if ( m_effect->m_plugin != nullptr ) { - m_effect->m_plugin->savePreset( ); + m_effect->m_plugin->savePreset(); /* bool converted; QString str = m_vi->m_plugin->currentProgramName().section("/", 0, 0); if (str != "") @@ -202,7 +204,7 @@ void VstEffectControls::savePreset( void ) -void VstEffectControls::updateMenu( void ) +void VstEffectControls::updateMenu() { // get all presets - @@ -219,8 +221,8 @@ void VstEffectControls::updateMenu( void ) to_menu->clear(); for (int i = 0; i < list1.size(); i++) { - QAction* presetAction = new QAction(this); - connect(presetAction, SIGNAL(triggered()), this, SLOT(selPreset())); + auto presetAction = new QAction(this); + connect(presetAction, SIGNAL(triggered()), this, SLOT(selPreset())); presetAction->setText(QString("%1. %2").arg(QString::number(i+1), list1.at(i))); presetAction->setData(i); @@ -237,11 +239,11 @@ void VstEffectControls::updateMenu( void ) -void VstEffectControls::openPreset( void ) +void VstEffectControls::openPreset() { if ( m_effect->m_plugin != nullptr ) { - m_effect->m_plugin->openPreset( ); + m_effect->m_plugin->openPreset(); bool converted; QString str = m_effect->m_plugin->currentProgramName().section("/", 0, 0); if (str != "") @@ -254,7 +256,7 @@ void VstEffectControls::openPreset( void ) -void VstEffectControls::rollPreset( void ) +void VstEffectControls::rollPreset() { if ( m_effect->m_plugin != nullptr ) { @@ -270,7 +272,7 @@ void VstEffectControls::rollPreset( void ) -void VstEffectControls::rolrPreset( void ) +void VstEffectControls::rolrPreset() { if ( m_effect->m_plugin != nullptr ) { @@ -286,16 +288,15 @@ void VstEffectControls::rolrPreset( void ) -void VstEffectControls::selPreset( void ) +void VstEffectControls::selPreset() { - - QAction *action = qobject_cast(sender()); - if (action) - if ( m_effect->m_plugin != nullptr ) { + auto action = qobject_cast(sender()); + if (action && m_effect->m_plugin != nullptr) + { lastPosInMenu = action->data().toInt(); - m_effect->m_plugin->setProgram( lastPosInMenu ); - //QWidget::update(); - } + m_effect->m_plugin->setProgram(lastPosInMenu); + // QWidget::update(); + } } @@ -308,6 +309,9 @@ void VstEffectControls::paintEvent( QPaintEvent * ) +namespace gui +{ + ManageVSTEffectView::ManageVSTEffectView( VstEffect * _eff, VstEffectControls * m_vi ) : m_effect( _eff ) @@ -367,13 +371,13 @@ ManageVSTEffectView::ManageVSTEffectView( VstEffect * _eff, VstEffectControls * hasKnobModel = false; } - char paramStr[35]; + auto paramStr = std::array{}; QStringList s_dumpValues; for( int i = 0; i < m_vi->paramCount; i++ ) { - sprintf( paramStr, "param%d", i); - s_dumpValues = dump[ paramStr ].split( ":" ); + sprintf(paramStr.data(), "param%d", i); + s_dumpValues = dump[paramStr.data()].split(":"); vstKnobs[ i ] = new CustomTextKnob( knobBright_26, widget, s_dumpValues.at( 1 ) ); vstKnobs[ i ]->setDescription( s_dumpValues.at( 1 ) + ":" ); @@ -381,9 +385,9 @@ ManageVSTEffectView::ManageVSTEffectView( VstEffect * _eff, VstEffectControls * if( !hasKnobModel ) { - sprintf( paramStr, "%d", i); - m_vi->knobFModel[ i ] = new FloatModel( LocaleHelper::toFloat(s_dumpValues.at(2)), - 0.0f, 1.0f, 0.01f, _eff, paramStr ); + sprintf(paramStr.data(), "%d", i); + m_vi->knobFModel[i] = new FloatModel(LocaleHelper::toFloat(s_dumpValues.at(2)), + 0.0f, 1.0f, 0.01f, _eff, paramStr.data()); } FloatModel * model = m_vi->knobFModel[i]; @@ -433,9 +437,9 @@ void ManageVSTEffectView::closeWindow() -void ManageVSTEffectView::syncPlugin( void ) +void ManageVSTEffectView::syncPlugin() { - char paramStr[35]; + auto paramStr = std::array{}; QStringList s_dumpValues; const QMap & dump = m_effect->m_plugin->parameterDump(); float f_value; @@ -447,8 +451,8 @@ void ManageVSTEffectView::syncPlugin( void ) if( !( m_vi2->knobFModel[ i ]->isAutomated() || m_vi2->knobFModel[ i ]->controllerConnection() ) ) { - sprintf( paramStr, "param%d", i ); - s_dumpValues = dump[ paramStr ].split( ":" ); + sprintf(paramStr.data(), "param%d", i); + s_dumpValues = dump[paramStr.data()].split(":"); f_value = LocaleHelper::toFloat(s_dumpValues.at(2)); m_vi2->knobFModel[ i ]->setAutomatedValue( f_value ); m_vi2->knobFModel[ i ]->setInitValue( f_value ); @@ -459,7 +463,7 @@ void ManageVSTEffectView::syncPlugin( void ) -void ManageVSTEffectView::displayAutomatedOnly( void ) +void ManageVSTEffectView::displayAutomatedOnly() { bool isAuto = QString::compare( m_displayAutomatedOnly->text(), tr( "Automated" ) ) == 0; @@ -473,7 +477,7 @@ void ManageVSTEffectView::displayAutomatedOnly( void ) { vstKnobs[ i ]->hide(); m_displayAutomatedOnly->setText( "All" ); - } else { + } else { vstKnobs[ i ]->show(); m_displayAutomatedOnly->setText( "Automated" ); } @@ -530,7 +534,7 @@ void ManageVSTEffectView::syncParameterText() ManageVSTEffectView::~ManageVSTEffectView() { if( m_vi2->knobFModel != nullptr ) - { + { for( int i = 0; i < m_vi2->paramCount; i++ ) { delete m_vi2->knobFModel[ i ]; @@ -549,18 +553,18 @@ ManageVSTEffectView::~ManageVSTEffectView() delete [] m_vi2->knobFModel; m_vi2->knobFModel = nullptr; } - + if( m_vi2->m_scrollArea != nullptr ) { delete m_vi2->m_scrollArea; m_vi2->m_scrollArea = nullptr; } - + if( m_vi2->m_subWindow != nullptr ) { m_vi2->m_subWindow->setAttribute( Qt::WA_DeleteOnClose ); m_vi2->m_subWindow->close(); - + if( m_vi2->m_subWindow != nullptr ) { delete m_vi2->m_subWindow; @@ -572,7 +576,6 @@ ManageVSTEffectView::~ManageVSTEffectView() } +} // namespace gui - - - +} // namespace lmms diff --git a/plugins/VstEffect/VstEffectControls.h b/plugins/VstEffect/VstEffectControls.h index c9bd626cd..42178b5b6 100644 --- a/plugins/VstEffect/VstEffectControls.h +++ b/plugins/VstEffect/VstEffectControls.h @@ -30,44 +30,54 @@ #include - -class CustomTextKnob; class QGridLayout; class QPaintEvent; class QPushButton; class QMdiSubWindow; class QScrollArea; + +namespace lmms +{ + + class VstEffect; +namespace gui +{ +class CustomTextKnob; +class ManageVSTEffectView; +class VstEffectControlDialog; +} + class VstEffectControls : public EffectControls { Q_OBJECT public: VstEffectControls( VstEffect * _eff ); - virtual ~VstEffectControls(); + ~VstEffectControls() override; - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); - inline virtual QString nodeName() const + void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; + inline QString nodeName() const override { return "vsteffectcontrols"; } - virtual int controlCount(); + int controlCount() override; - virtual EffectControlDialog * createView(); + gui::EffectControlDialog* createView() override; protected slots: - void updateMenu( void ); - void managePlugin( void ); - void openPreset( void ); - void savePreset( void ); - void rollPreset( void ); - void rolrPreset( void ); - void selPreset( void ); - void setParameter( Model * action ); + void updateMenu(); + void managePlugin(); + void openPreset(); + void savePreset(); + void rollPreset(); + void rolrPreset(); + void selPreset(); + void setParameter( lmms::Model * action ); protected: virtual void paintEvent( QPaintEvent * _pe ); @@ -87,13 +97,15 @@ private: int lastPosInMenu; // QLabel * m_presetLabel; - friend class VstEffectControlDialog; - friend class ManageVSTEffectView; + friend class gui::VstEffectControlDialog; + friend class gui::ManageVSTEffectView; bool m_vstGuiVisible; } ; +namespace gui +{ class ManageVSTEffectView : public QObject @@ -101,13 +113,13 @@ class ManageVSTEffectView : public QObject Q_OBJECT public: ManageVSTEffectView( VstEffect * _eff, VstEffectControls * m_vi ); - virtual ~ManageVSTEffectView(); + ~ManageVSTEffectView() override; protected slots: - void syncPlugin( void ); - void displayAutomatedOnly( void ); - void setParameter( Model * action ); + void syncPlugin(); + void displayAutomatedOnly(); + void setParameter( lmms::Model * action ); void syncParameterText(); void closeWindow(); @@ -132,4 +144,8 @@ private: } ; +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/VstEffect/VstSubPluginFeatures.cpp b/plugins/VstEffect/VstSubPluginFeatures.cpp index b2141cd70..e60fee0c1 100644 --- a/plugins/VstEffect/VstSubPluginFeatures.cpp +++ b/plugins/VstEffect/VstSubPluginFeatures.cpp @@ -30,6 +30,8 @@ #include "VstSubPluginFeatures.h" #include "ConfigManager.h" +namespace lmms +{ VstSubPluginFeatures::VstSubPluginFeatures( Plugin::PluginTypes _type ) : @@ -53,7 +55,7 @@ void VstSubPluginFeatures::fillDescriptionWidget( QWidget * _parent, void VstSubPluginFeatures::listSubPluginKeys( const Plugin::Descriptor * _desc, KeyList & _kl ) const { - QStringList *dlls = new QStringList(); + auto dlls = new QStringList(); const QString path = QString(""); addPluginsFromDir(dlls, path ); // TODO: eval m_type @@ -90,3 +92,5 @@ void VstSubPluginFeatures::addPluginsFromDir( QStringList* filenames, QString pa } } + +} // namespace lmms diff --git a/plugins/VstEffect/VstSubPluginFeatures.h b/plugins/VstEffect/VstSubPluginFeatures.h index 1c6d9cc2a..c5dc87d14 100644 --- a/plugins/VstEffect/VstSubPluginFeatures.h +++ b/plugins/VstEffect/VstSubPluginFeatures.h @@ -31,24 +31,26 @@ #include "Effect.h" #include "Plugin.h" +namespace lmms +{ + class VstSubPluginFeatures : public Plugin::Descriptor::SubPluginFeatures { public: VstSubPluginFeatures( Plugin::PluginTypes _type ); - virtual void fillDescriptionWidget( QWidget * _parent, - const Key * _key ) const; + void fillDescriptionWidget( QWidget * _parent, + const Key * _key ) const override; - virtual void listSubPluginKeys( const Plugin::Descriptor * _desc, - KeyList & _kl ) const; + void listSubPluginKeys( const Plugin::Descriptor * _desc, + KeyList & _kl ) const override; private: void addPluginsFromDir(QStringList* filenames, QString path) const; } ; - - +} // namespace lmms #endif diff --git a/plugins/Watsyn/Watsyn.cpp b/plugins/Watsyn/Watsyn.cpp index 0be4af29a..9ceaaddb8 100644 --- a/plugins/Watsyn/Watsyn.cpp +++ b/plugins/Watsyn/Watsyn.cpp @@ -37,12 +37,16 @@ #include "embed.h" #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT watsyn_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "Watsyn", QT_TRANSLATE_NOOP( "PluginBrowser", "4-oscillator modulatable wavetable synth" ), @@ -322,24 +326,13 @@ WatsynInstrument::WatsynInstrument( InstrumentTrack * _instrument_track ) : } -WatsynInstrument::~WatsynInstrument() -{ -} - - void WatsynInstrument::playNote( NotePlayHandle * _n, sampleFrame * _working_buffer ) { if ( _n->totalFramesPlayed() == 0 || _n->m_pluginData == nullptr ) { - WatsynObject * w = new WatsynObject( - &A1_wave[0], - &A2_wave[0], - &B1_wave[0], - &B2_wave[0], - m_amod.value(), m_bmod.value(), - Engine::audioEngine()->processingSampleRate(), _n, - Engine::audioEngine()->framesPerPeriod(), this ); + auto w = new WatsynObject(&A1_wave[0], &A2_wave[0], &B1_wave[0], &B2_wave[0], m_amod.value(), m_bmod.value(), + Engine::audioEngine()->processingSampleRate(), _n, Engine::audioEngine()->framesPerPeriod(), this); _n->m_pluginData = w; } @@ -348,7 +341,7 @@ void WatsynInstrument::playNote( NotePlayHandle * _n, const f_cnt_t offset = _n->noteOffset(); sampleFrame * buffer = _working_buffer + offset; - WatsynObject * w = static_cast( _n->m_pluginData ); + auto w = static_cast(_n->m_pluginData); sampleFrame * abuf = w->abuf(); sampleFrame * bbuf = w->bbuf(); @@ -361,7 +354,7 @@ void WatsynInstrument::playNote( NotePlayHandle * _n, const float envHold = ( m_envHold.value() * w->samplerate() ) / 1000.0f; const float envDec = ( m_envDec.value() * w->samplerate() ) / 1000.0f; const float envLen = envAtt + envDec + envHold; - const float tfp_ = static_cast( _n->totalFramesPlayed() ); + const auto tfp_ = static_cast(_n->totalFramesPlayed()); // if sample-exact is enabled, use sample-exact calculations... // disabled pending proper implementation of sample-exactness @@ -580,9 +573,9 @@ QString WatsynInstrument::nodeName() const } -PluginView * WatsynInstrument::instantiateView( QWidget * _parent ) +gui::PluginView* WatsynInstrument::instantiateView( QWidget * _parent ) { - return( new WatsynView( this, _parent ) ); + return( new gui::WatsynView( this, _parent ) ); } @@ -662,6 +655,8 @@ void WatsynInstrument::updateWaveB2() } +namespace gui +{ WatsynView::WatsynView( Instrument * _instrument, @@ -722,25 +717,25 @@ WatsynView::WatsynView( Instrument * _instrument, // button groups next. // graph select buttons - PixmapButton * a1_selectButton = new PixmapButton( this, nullptr ); + auto a1_selectButton = new PixmapButton(this, nullptr); a1_selectButton -> move( 4, 121 ); a1_selectButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "a1_active" ) ); a1_selectButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "a1_inactive" ) ); a1_selectButton->setToolTip(tr("Select oscillator A1")); - PixmapButton * a2_selectButton = new PixmapButton( this, nullptr ); + auto a2_selectButton = new PixmapButton(this, nullptr); a2_selectButton -> move( 44, 121 ); a2_selectButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "a2_active" ) ); a2_selectButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "a2_inactive" ) ); a2_selectButton->setToolTip(tr("Select oscillator A2")); - PixmapButton * b1_selectButton = new PixmapButton( this, nullptr ); + auto b1_selectButton = new PixmapButton(this, nullptr); b1_selectButton -> move( 84, 121 ); b1_selectButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "b1_active" ) ); b1_selectButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "b1_inactive" ) ); b1_selectButton->setToolTip(tr("Select oscillator B1")); - PixmapButton * b2_selectButton = new PixmapButton( this, nullptr ); + auto b2_selectButton = new PixmapButton(this, nullptr); b2_selectButton -> move( 124, 121 ); b2_selectButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "b2_active" ) ); b2_selectButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "b2_inactive" ) ); @@ -751,29 +746,29 @@ WatsynView::WatsynView( Instrument * _instrument, m_selectedGraphGroup -> addButton( a2_selectButton ); m_selectedGraphGroup -> addButton( b1_selectButton ); m_selectedGraphGroup -> addButton( b2_selectButton ); - WatsynInstrument * w = castModel(); + auto w = castModel(); m_selectedGraphGroup -> setModel( &w -> m_selectedGraph); // A-modulation button group - PixmapButton * amod_mixButton = new PixmapButton( this, nullptr ); + auto amod_mixButton = new PixmapButton(this, nullptr); amod_mixButton -> move( 4, 50 ); amod_mixButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "amix_active" ) ); amod_mixButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "amix_inactive" ) ); amod_mixButton->setToolTip(tr("Mix output of A2 to A1")); - PixmapButton * amod_amButton = new PixmapButton( this, nullptr ); + auto amod_amButton = new PixmapButton(this, nullptr); amod_amButton -> move( 4, 66 ); amod_amButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "aam_active" ) ); amod_amButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "aam_inactive" ) ); amod_amButton->setToolTip(tr("Modulate amplitude of A1 by output of A2")); - PixmapButton * amod_rmButton = new PixmapButton( this, nullptr ); + auto amod_rmButton = new PixmapButton(this, nullptr); amod_rmButton -> move( 4, 82 ); amod_rmButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "arm_active" ) ); amod_rmButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "arm_inactive" ) ); amod_rmButton->setToolTip(tr("Ring modulate A1 and A2")); - PixmapButton * amod_pmButton = new PixmapButton( this, nullptr ); + auto amod_pmButton = new PixmapButton(this, nullptr); amod_pmButton -> move( 4, 98 ); amod_pmButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "apm_active" ) ); amod_pmButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "apm_inactive" ) ); @@ -786,25 +781,25 @@ WatsynView::WatsynView( Instrument * _instrument, m_aModGroup -> addButton( amod_pmButton ); // B-modulation button group - PixmapButton * bmod_mixButton = new PixmapButton( this, nullptr ); + auto bmod_mixButton = new PixmapButton(this, nullptr); bmod_mixButton -> move( 44, 50 ); bmod_mixButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "bmix_active" ) ); bmod_mixButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "bmix_inactive" ) ); bmod_mixButton->setToolTip(tr("Mix output of B2 to B1")); - PixmapButton * bmod_amButton = new PixmapButton( this, nullptr ); + auto bmod_amButton = new PixmapButton(this, nullptr); bmod_amButton -> move( 44, 66 ); bmod_amButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "bam_active" ) ); bmod_amButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "bam_inactive" ) ); bmod_amButton->setToolTip(tr("Modulate amplitude of B1 by output of B2")); - PixmapButton * bmod_rmButton = new PixmapButton( this, nullptr ); + auto bmod_rmButton = new PixmapButton(this, nullptr); bmod_rmButton -> move( 44, 82 ); bmod_rmButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "brm_active" ) ); bmod_rmButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "brm_inactive" ) ); bmod_rmButton->setToolTip(tr("Ring modulate B1 and B2")); - PixmapButton * bmod_pmButton = new PixmapButton( this, nullptr ); + auto bmod_pmButton = new PixmapButton(this, nullptr); bmod_pmButton -> move( 44, 98 ); bmod_pmButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "bpm_active" ) ); bmod_pmButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "bpm_inactive" ) ); @@ -941,12 +936,6 @@ WatsynView::WatsynView( Instrument * _instrument, } -WatsynView::~WatsynView() -{ -} - - - void WatsynView::updateLayout() { switch( m_selectedGraphGroup->model()->value() ) @@ -1223,7 +1212,7 @@ void WatsynView::loadClicked() void WatsynView::modelChanged() { - WatsynInstrument * w = castModel(); + auto w = castModel(); a1_volKnob -> setModel( &w -> a1_vol ); a2_volKnob -> setModel( &w -> a2_vol ); @@ -1271,6 +1260,7 @@ void WatsynView::modelChanged() } +} // namespace gui @@ -1287,4 +1277,4 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model *m, void * ) } - +} // namespace lmms diff --git a/plugins/Watsyn/Watsyn.h b/plugins/Watsyn/Watsyn.h index b957faef7..3c69be06f 100644 --- a/plugins/Watsyn/Watsyn.h +++ b/plugins/Watsyn/Watsyn.h @@ -34,6 +34,9 @@ #include #include "MemoryManager.h" +namespace lmms +{ + #define makeknob( name, x, y, hint, unit, oname ) \ name = new Knob( knobStyled, this ); \ @@ -74,9 +77,14 @@ const int B1_OSC = 2; const int B2_OSC = 3; const int NUM_OSCS = 4; +class WatsynInstrument; + +namespace gui +{ class automatableButtonGroup; class PixmapButton; -class WatsynInstrument; +class WatsynView; +} class WatsynObject { @@ -131,25 +139,25 @@ class WatsynInstrument : public Instrument Q_OBJECT public: WatsynInstrument( InstrumentTrack * _instrument_track ); - virtual ~WatsynInstrument(); + ~WatsynInstrument() override = default; - virtual void playNote( NotePlayHandle * _n, - sampleFrame * _working_buffer ); - virtual void deleteNotePluginData( NotePlayHandle * _n ); + void playNote( NotePlayHandle * _n, + sampleFrame * _working_buffer ) override; + void deleteNotePluginData( NotePlayHandle * _n ) override; - virtual void saveSettings( QDomDocument & _doc, - QDomElement & _this ); - virtual void loadSettings( const QDomElement & _this ); + void saveSettings( QDomDocument & _doc, + QDomElement & _this ) override; + void loadSettings( const QDomElement & _this ) override; - virtual QString nodeName() const; + QString nodeName() const override; - virtual f_cnt_t desiredReleaseFrames() const + f_cnt_t desiredReleaseFrames() const override { return( 64 ); } - virtual PluginView * instantiateView( QWidget * _parent ); + gui::PluginView* instantiateView( QWidget * _parent ) override; public slots: void updateVolumes(); @@ -288,17 +296,21 @@ private: float B2_wave [WAVELEN]; friend class WatsynObject; - friend class WatsynView; + friend class gui::WatsynView; }; +namespace gui +{ + + class WatsynView : public InstrumentViewFixedSize { Q_OBJECT public: WatsynView( Instrument * _instrument, QWidget * _parent ); - virtual ~WatsynView(); + ~WatsynView() override = default; protected slots: void updateLayout(); @@ -316,7 +328,7 @@ protected slots: void loadClicked(); private: - virtual void modelChanged(); + void modelChanged() override; // knobs Knob * a1_volKnob; @@ -376,4 +388,9 @@ private: }; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/WaveShaper/WaveShaper.cpp b/plugins/WaveShaper/WaveShaper.cpp index be3e943bc..94845e672 100644 --- a/plugins/WaveShaper/WaveShaper.cpp +++ b/plugins/WaveShaper/WaveShaper.cpp @@ -31,12 +31,16 @@ #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT waveshaper_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "Waveshaper Effect", QT_TRANSLATE_NOOP( "PluginBrowser", "plugin for waveshaping" ), @@ -62,13 +66,6 @@ WaveShaperEffect::WaveShaperEffect( Model * _parent, -WaveShaperEffect::~WaveShaperEffect() -{ -} - - - - bool WaveShaperEffect::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames ) { @@ -99,7 +96,7 @@ bool WaveShaperEffect::processAudioBuffer( sampleFrame * _buf, for( fpp_t f = 0; f < _frames; ++f ) { - float s[2] = { _buf[f][0], _buf[f][1] }; + auto s = std::array{_buf[f][0], _buf[f][1]}; // apply input gain s[0] *= *inputPtr; @@ -117,7 +114,7 @@ bool WaveShaperEffect::processAudioBuffer( sampleFrame * _buf, for( i=0; i <= 1; ++i ) { const int lookup = static_cast( qAbs( s[i] ) * 200.0f ); - const float frac = fraction( qAbs( s[i] ) * 200.0f ); + const float frac = fraction( qAbs( s[i] ) * 200.0f ); const float posneg = s[i] < 0 ? -1.0f : 1.0f; if( lookup < 1 ) @@ -125,8 +122,8 @@ bool WaveShaperEffect::processAudioBuffer( sampleFrame * _buf, s[i] = frac * samples[0] * posneg; } else if( lookup < 200 ) - { - s[i] = linearInterpolate( samples[ lookup - 1 ], + { + s[i] = linearInterpolate( samples[ lookup - 1 ], samples[ lookup ], frac ) * posneg; } @@ -171,3 +168,5 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main( Model * _parent, void * _data ) } + +} // namespace lmms diff --git a/plugins/WaveShaper/WaveShaper.h b/plugins/WaveShaper/WaveShaper.h index 4763c40b7..4c63d5806 100644 --- a/plugins/WaveShaper/WaveShaper.h +++ b/plugins/WaveShaper/WaveShaper.h @@ -30,6 +30,8 @@ #include "Effect.h" #include "WaveShaperControls.h" +namespace lmms +{ class WaveShaperEffect : public Effect @@ -37,11 +39,11 @@ class WaveShaperEffect : public Effect public: WaveShaperEffect( Model * _parent, const Descriptor::SubPluginFeatures::Key * _key ); - virtual ~WaveShaperEffect(); - virtual bool processAudioBuffer( sampleFrame * _buf, - const fpp_t _frames ); + ~WaveShaperEffect() override = default; + bool processAudioBuffer( sampleFrame * _buf, + const fpp_t _frames ) override; - virtual EffectControls * controls() + EffectControls * controls() override { return( &m_wsControls ); } @@ -56,7 +58,7 @@ private: } ; - +} // namespace lmms #endif diff --git a/plugins/WaveShaper/WaveShaperControlDialog.cpp b/plugins/WaveShaper/WaveShaperControlDialog.cpp index aede7317e..5ef061fdb 100644 --- a/plugins/WaveShaper/WaveShaperControlDialog.cpp +++ b/plugins/WaveShaper/WaveShaperControlDialog.cpp @@ -33,6 +33,9 @@ #include "PixmapButton.h" #include "LedCheckBox.h" +namespace lmms::gui +{ + WaveShaperControlDialog::WaveShaperControlDialog( WaveShaperControls * _controls ) : @@ -45,7 +48,7 @@ WaveShaperControlDialog::WaveShaperControlDialog( setPalette( pal ); setFixedSize( 224, 274 ); - Graph * waveGraph = new Graph( this, Graph::LinearNonCyclicStyle, 204, 205 ); + auto waveGraph = new Graph(this, Graph::LinearNonCyclicStyle, 204, 205); waveGraph -> move( 10, 6 ); waveGraph -> setModel( &_controls -> m_wavegraphModel ); waveGraph -> setAutoFillBackground( true ); @@ -56,7 +59,7 @@ WaveShaperControlDialog::WaveShaperControlDialog( waveGraph->setGraphColor( QColor( 85, 204, 145 ) ); waveGraph -> setMaximumSize( 204, 205 ); - Knob * inputKnob = new Knob( knobBright_26, this); + auto inputKnob = new Knob(knobBright_26, this); inputKnob -> setVolumeKnob( true ); inputKnob -> setVolumeRatio( 1.0 ); inputKnob -> move( 26, 225 ); @@ -64,7 +67,7 @@ WaveShaperControlDialog::WaveShaperControlDialog( inputKnob->setLabel( tr( "INPUT" ) ); inputKnob->setHintText( tr( "Input gain:" ) , "" ); - Knob * outputKnob = new Knob( knobBright_26, this ); + auto outputKnob = new Knob(knobBright_26, this); outputKnob -> setVolumeKnob( true ); outputKnob -> setVolumeRatio( 1.0 ); outputKnob -> move( 76, 225 ); @@ -72,36 +75,35 @@ WaveShaperControlDialog::WaveShaperControlDialog( outputKnob->setLabel( tr( "OUTPUT" ) ); outputKnob->setHintText( tr( "Output gain:" ), "" ); - PixmapButton * resetButton = new PixmapButton( this, tr("Reset wavegraph") ); + auto resetButton = new PixmapButton(this, tr("Reset wavegraph")); resetButton -> move( 162, 221 ); resetButton -> resize( 13, 46 ); resetButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "reset_active" ) ); resetButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "reset_inactive" ) ); resetButton->setToolTip(tr("Reset wavegraph")); - PixmapButton * smoothButton = new PixmapButton( this, tr("Smooth wavegraph") ); + auto smoothButton = new PixmapButton(this, tr("Smooth wavegraph")); smoothButton -> move( 162, 237 ); smoothButton -> resize( 13, 46 ); smoothButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "smooth_active" ) ); smoothButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "smooth_inactive" ) ); smoothButton->setToolTip(tr("Smooth wavegraph")); - PixmapButton * addOneButton = new PixmapButton( this, tr("Increase wavegraph amplitude by 1 dB") ); + auto addOneButton = new PixmapButton(this, tr("Increase wavegraph amplitude by 1 dB")); addOneButton -> move( 131, 221 ); addOneButton -> resize( 13, 29 ); addOneButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "add1_active" ) ); addOneButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "add1_inactive" ) ); addOneButton->setToolTip(tr("Increase wavegraph amplitude by 1 dB")); - PixmapButton * subOneButton = new PixmapButton( this, tr("Decrease wavegraph amplitude by 1 dB") ); + auto subOneButton = new PixmapButton(this, tr("Decrease wavegraph amplitude by 1 dB")); subOneButton -> move( 131, 237 ); subOneButton -> resize( 13, 29 ); subOneButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "sub1_active" ) ); subOneButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "sub1_inactive" ) ); subOneButton->setToolTip(tr("Decrease wavegraph amplitude by 1 dB")); - LedCheckBox * clipInputToggle = new LedCheckBox( "Clip input", this, - tr( "Clip input" ), LedCheckBox::Green ); + auto clipInputToggle = new LedCheckBox("Clip input", this, tr("Clip input"), LedCheckBox::Green); clipInputToggle -> move( 131, 252 ); clipInputToggle -> setModel( &_controls -> m_clipModel ); clipInputToggle->setToolTip(tr("Clip input signal to 0 dB")); @@ -116,3 +118,5 @@ WaveShaperControlDialog::WaveShaperControlDialog( _controls, SLOT( subOneClicked() ) ); } + +} // namespace lmms::gui diff --git a/plugins/WaveShaper/WaveShaperControlDialog.h b/plugins/WaveShaper/WaveShaperControlDialog.h index be0f10212..e76dcfccc 100644 --- a/plugins/WaveShaper/WaveShaperControlDialog.h +++ b/plugins/WaveShaper/WaveShaperControlDialog.h @@ -28,22 +28,30 @@ #include "EffectControlDialog.h" +namespace lmms +{ class WaveShaperControls; +namespace gui +{ + class WaveShaperControlDialog : public EffectControlDialog { Q_OBJECT public: WaveShaperControlDialog( WaveShaperControls * _controls ); - virtual ~WaveShaperControlDialog() - { - } + ~WaveShaperControlDialog() override = default; private: } ; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/WaveShaper/WaveShaperControls.cpp b/plugins/WaveShaper/WaveShaperControls.cpp index 529cc4289..a03abc2ef 100644 --- a/plugins/WaveShaper/WaveShaperControls.cpp +++ b/plugins/WaveShaper/WaveShaperControls.cpp @@ -33,6 +33,9 @@ #include "Engine.h" #include "Song.h" +namespace lmms +{ + #define onedB 1.1220184543019633f @@ -66,7 +69,7 @@ void WaveShaperControls::loadSettings( const QDomElement & _this ) //load input, output knobs m_inputModel.loadSettings( _this, "inputGain" ); m_outputModel.loadSettings( _this, "outputGain" ); - + m_clipModel.loadSettings( _this, "clipInput" ); //load waveshape @@ -102,7 +105,7 @@ void WaveShaperControls::saveSettings( QDomDocument & _doc, void WaveShaperControls::setDefaultShape() { - float shp [200] = { }; + auto shp = std::array{}; for ( int i = 0; i<200; i++) { shp[i] = ((float)i + 1.0f) / 200.0f; @@ -143,5 +146,4 @@ void WaveShaperControls::subOneClicked() } - - +} // namespace lmms \ No newline at end of file diff --git a/plugins/WaveShaper/WaveShaperControls.h b/plugins/WaveShaper/WaveShaperControls.h index fa0768afd..9473aae5d 100644 --- a/plugins/WaveShaper/WaveShaperControls.h +++ b/plugins/WaveShaper/WaveShaperControls.h @@ -30,6 +30,10 @@ #include "WaveShaperControlDialog.h" #include "Graph.h" +namespace lmms +{ + + class WaveShaperEffect; @@ -38,27 +42,25 @@ class WaveShaperControls : public EffectControls Q_OBJECT public: WaveShaperControls( WaveShaperEffect * _eff ); - virtual ~WaveShaperControls() - { - } + ~WaveShaperControls() override = default; - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); - inline virtual QString nodeName() const + void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; + inline QString nodeName() const override { return( "waveshapercontrols" ); } virtual void setDefaultShape(); - virtual int controlCount() + int controlCount() override { return( 4 ); } - virtual EffectControlDialog * createView() + gui::EffectControlDialog* createView() override { - return( new WaveShaperControlDialog( this ) ); + return( new gui::WaveShaperControlDialog( this ) ); } @@ -78,9 +80,12 @@ private: graphModel m_wavegraphModel; BoolModel m_clipModel; - friend class WaveShaperControlDialog; + friend class gui::WaveShaperControlDialog; friend class WaveShaperEffect; } ; + +} // namespace lmms + #endif diff --git a/plugins/Xpressive/ExprSynth.cpp b/plugins/Xpressive/ExprSynth.cpp index ceb79138e..991e0d3e6 100644 --- a/plugins/Xpressive/ExprSynth.cpp +++ b/plugins/Xpressive/ExprSynth.cpp @@ -39,9 +39,13 @@ #include "exprtk.hpp" #define WARN_EXPRTK qWarning("ExprTk exception") -typedef exprtk::symbol_table symbol_table_t; -typedef exprtk::expression expression_t; -typedef exprtk::parser parser_t; + +namespace lmms +{ + +using symbol_table_t = exprtk::symbol_table; +using expression_t = exprtk::expression; +using parser_t = exprtk::parser; template struct freefunc0 : public exprtk::ifunction @@ -51,7 +55,7 @@ struct freefunc0 : public exprtk::ifunction freefunc0() : exprtk::ifunction(0) { if (optimize) { exprtk::disable_has_side_effects(*this); } } - inline T operator()() + inline T operator()() override { return Functor::process(); } }; template @@ -62,7 +66,7 @@ struct freefunc1 : public exprtk::ifunction freefunc1() : exprtk::ifunction(1) { if (optimize) { exprtk::disable_has_side_effects(*this); } } - inline T operator()(const T& x) + inline T operator()(const T& x) override { return Functor::process(x); } }; @@ -71,7 +75,7 @@ struct IntegrateFunction : public exprtk::ifunction { using exprtk::ifunction::operator(); - virtual ~IntegrateFunction() + ~IntegrateFunction() override { delete [] m_counters; } @@ -89,7 +93,7 @@ struct IntegrateFunction : public exprtk::ifunction clearArray(m_counters,max_counters); } - inline T operator()(const T& x) + inline T operator()(const T& x) override { if (*m_frame == 0) { @@ -126,7 +130,7 @@ struct LastSampleFunction : public exprtk::ifunction { using exprtk::ifunction::operator(); - virtual ~LastSampleFunction() + ~LastSampleFunction() override { delete [] m_samples; } @@ -140,7 +144,7 @@ struct LastSampleFunction : public exprtk::ifunction clearArray(m_samples, history_size); } - inline T operator()(const T& x) + inline T operator()(const T& x) override { if (!std::isnan(x) && !std::isinf(x)) { @@ -182,7 +186,7 @@ struct WaveValueFunction : public exprtk::ifunction m_size(s) {} - inline T operator()(const T& index) + inline T operator()(const T& index) override { return m_vec[(int) ( positiveFraction(index) * m_size )]; } @@ -200,7 +204,7 @@ struct WaveValueFunctionInterpolate : public exprtk::ifunction m_size(s) {} - inline T operator()(const T& index) + inline T operator()(const T& index) override { const T x = positiveFraction(index) * m_size; const int ix = (int)x; @@ -210,7 +214,7 @@ struct WaveValueFunctionInterpolate : public exprtk::ifunction const T *m_vec; const std::size_t m_size; }; -static const unsigned int random_data[257]={ +static const auto random_data = std::array{ 0xd76a33ec, 0x4a767724, 0xb34ebd08 ,0xf4024196, 0x17b426e2, 0x8dc6389a, 0x1b5dcb93 ,0xa771bd3f, 0x078d502e, 0x8980988a, 0x1f64f846 ,0xb5b48ed7, @@ -308,7 +312,7 @@ struct RandomVectorSeedFunction : public exprtk::ifunction { return 0; } - const unsigned int xi = (unsigned int)index; + const auto xi = (unsigned int)index; const unsigned int si = irseed % data_size; const unsigned int sa = irseed / data_size; unsigned int res=rotateLeft(random_data[(xi + 23 * si + 1) % data_size] ^ random_data[(xi / data_size + sa) % data_size],sa % 31 + 1); @@ -316,7 +320,7 @@ struct RandomVectorSeedFunction : public exprtk::ifunction return static_cast(res) / (float)(1 << 31); } - inline float operator()(const float& index,const float& seed) + inline float operator()(const float& index,const float& seed) override { int irseed; if (seed < 0 || std::isnan(seed) || std::isinf(seed)) @@ -341,7 +345,7 @@ struct RandomVectorFunction : public exprtk::ifunction m_rseed(seed) { exprtk::disable_has_side_effects(*this); } - inline float operator()(const float& index) + inline float operator()(const float& index) override { return RandomVectorSeedFunction::randv(index,m_rseed); } @@ -359,7 +363,7 @@ namespace SimpleRandom { return dist(generator); } }; -} +} // namespace SimpleRandom static freefunc0 simple_rand; @@ -373,13 +377,13 @@ public: {} ~ExprFrontData() { - for (int i = 0; i < m_cyclics.size() ; ++i) + for (const auto& cyclic : m_cyclics) { - delete m_cyclics[i]; + delete cyclic; } - for (int i = 0; i < m_cyclics_interp.size() ; ++i) + for (const auto& cyclic : m_cyclics_interp) { - delete m_cyclics_interp[i]; + delete cyclic; } if (m_integ_func) { @@ -522,14 +526,14 @@ ExprFront::ExprFront(const char * expr, int last_func_samples) try { m_data = new ExprFrontData(last_func_samples); - + m_data->m_expression_string = expr; m_data->m_symbol_table.add_pi(); - + m_data->m_symbol_table.add_constant("e", F_E); m_data->m_symbol_table.add_constant("seed", SimpleRandom::generator() & max_float_integer_mask); - + m_data->m_symbol_table.add_function("sinew", sin_wave_func); m_data->m_symbol_table.add_function("squarew", square_wave_func); m_data->m_symbol_table.add_function("trianglew", triangle_wave_func); @@ -573,7 +577,7 @@ bool ExprFront::compile() sstore.disable_all_assignment_ops(); sstore.disable_all_control_structures(); parser_t parser(sstore); - + m_valid=parser.compile(m_data->m_expression_string, m_data->m_expression); } catch(...) @@ -596,7 +600,7 @@ float ExprFront::evaluate() WARN_EXPRTK; } return 0; - + } bool ExprFront::add_variable(const char* name, float& ref) { @@ -630,13 +634,13 @@ bool ExprFront::add_cyclic_vector(const char* name, const float* data, size_t le { if (interp) { - WaveValueFunctionInterpolate *wvf = new WaveValueFunctionInterpolate(data, length); + auto wvf = new WaveValueFunctionInterpolate(data, length); m_data->m_cyclics_interp.push_back(wvf); return m_data->m_symbol_table.add_function(name, *wvf); } else { - WaveValueFunction *wvf = new WaveValueFunction(data, length); + auto wvf = new WaveValueFunction(data, length); m_data->m_cyclics.push_back(wvf); return m_data->m_symbol_table.add_function(name, *wvf); } @@ -753,7 +757,7 @@ void ExprSynth::renderOutput(fpp_t frames, sampleFrame *buf) const float new_freq = m_nph->frequency(); const float freq_inc = (new_freq - m_frequency) / frames; const bool is_released = m_nph->isReleased(); - + expression_t *o1_rawExpr = &(m_exprO1->getData()->m_expression); expression_t *o2_rawExpr = &(m_exprO2->getData()->m_expression); LastSampleFunction * last_func1 = &m_exprO1->getData()->m_last_func; @@ -787,7 +791,7 @@ void ExprSynth::renderOutput(fpp_t frames, sampleFrame *buf) } else { - + if (o2_valid) { o1_rawExpr = o2_rawExpr; @@ -820,3 +824,6 @@ void ExprSynth::renderOutput(fpp_t frames, sampleFrame *buf) WARN_EXPRTK; } } + + +} // namespace lmms \ No newline at end of file diff --git a/plugins/Xpressive/ExprSynth.h b/plugins/Xpressive/ExprSynth.h index 1246058ca..f338b78fc 100644 --- a/plugins/Xpressive/ExprSynth.h +++ b/plugins/Xpressive/ExprSynth.h @@ -32,18 +32,26 @@ #include "Graph.h" #include "MemoryManager.h" -class automatableButtonGroup; +namespace lmms +{ + + class ExprFrontData; +class NotePlayHandle; + +namespace gui +{ +class automatableButtonGroup; class Knob; class LedCheckBox; -class NotePlayHandle; class PixmapButton; +} class ExprFront { public: - typedef float (*ff1data_functor)(void*, float); + using ff1data_functor = float (*)(void*, float); ExprFront(const char* expr, int last_func_samples); ~ExprFront(); bool compile(); @@ -145,5 +153,6 @@ inline void clearArray(T* arr,unsigned int size) } +} // namespace lmms #endif diff --git a/plugins/Xpressive/Xpressive.cpp b/plugins/Xpressive/Xpressive.cpp index bf543c695..18ac8c052 100644 --- a/plugins/Xpressive/Xpressive.cpp +++ b/plugins/Xpressive/Xpressive.cpp @@ -48,9 +48,13 @@ #include "plugin_export.h" +namespace lmms +{ + + extern "C" { -Plugin::Descriptor PLUGIN_EXPORT xpressive_plugin_descriptor = { STRINGIFY( +Plugin::Descriptor PLUGIN_EXPORT xpressive_plugin_descriptor = { LMMS_STRINGIFY( PLUGIN_NAME), "Xpressive", QT_TRANSLATE_NOOP("PluginBrowser", "Mathematical expression parser"), "Orr Dvori", 0x0100, Plugin::Instrument, new PluginPixmapLoader("logo"), nullptr, nullptr }; @@ -107,9 +111,6 @@ Xpressive::Xpressive(InstrumentTrack* instrument_track) : m_outputExpression[1]="expw(integrate(f*atan(500t)*2/pi))*0.5+0.12"; } -Xpressive::~Xpressive() { -} - void Xpressive::saveSettings(QDomDocument & _doc, QDomElement & _this) { // Save plugin version @@ -202,8 +203,9 @@ void Xpressive::playNote(NotePlayHandle* nph, sampleFrame* working_buffer) { if (nph->totalFramesPlayed() == 0 || nph->m_pluginData == nullptr) { - ExprFront *exprO1 = new ExprFront(m_outputExpression[0].constData(),Engine::audioEngine()->processingSampleRate());//give the "last" function a whole second - ExprFront *exprO2 = new ExprFront(m_outputExpression[1].constData(),Engine::audioEngine()->processingSampleRate()); + auto exprO1 = new ExprFront(m_outputExpression[0].constData(), + Engine::audioEngine()->processingSampleRate()); // give the "last" function a whole second + auto exprO2 = new ExprFront(m_outputExpression[1].constData(), Engine::audioEngine()->processingSampleRate()); auto init_expression_step1 = [this, nph](ExprFront* e) { //lambda function to init exprO1 and exprO2 //add the constants and the variables to the expression. @@ -226,10 +228,7 @@ void Xpressive::playNote(NotePlayHandle* nph, sampleFrame* working_buffer) { Engine::audioEngine()->processingSampleRate(), &m_panning1, &m_panning2, m_relTransition.value()); } - - - - ExprSynth *ps = static_cast(nph->m_pluginData); + auto ps = static_cast(nph->m_pluginData); const fpp_t frames = nph->framesLeftForCurrentPeriod(); const f_cnt_t offset = nph->noteOffset(); @@ -242,10 +241,43 @@ void Xpressive::deleteNotePluginData(NotePlayHandle* nph) { delete static_cast(nph->m_pluginData); } -PluginView * Xpressive::instantiateView(QWidget* parent) { - return (new XpressiveView(this, parent)); +gui::PluginView* Xpressive::instantiateView(QWidget* parent) { + return (new gui::XpressiveView(this, parent)); } + +void Xpressive::smooth(float smoothness,const graphModel * in,graphModel * out) +{ + out->setSamples(in->samples()); + if (smoothness>0) + { + const int guass_size = (int)(smoothness * 5) | 1; + const int guass_center = guass_size/2; + const float delta = smoothness; + const float a= 1.0f / (sqrtf(2.0f * F_PI) * delta); + auto const guassian = new float[guass_size]; + float sum = 0.0f; + float temp = 0.0f; + int i; + for (i = 0; i < guass_size; i++ ) + { + temp = (i - guass_center) / delta; + sum += guassian[i] = a * powf(F_E, -0.5f * temp * temp); + } + for (i = 0; i < guass_size; i++ ) + { + guassian[i] = guassian[i] / sum; + } + out->convolve(guassian, guass_size, guass_center); + delete [] guassian; + } +} + + +namespace gui +{ + + class XpressiveKnob: public Knob { public: void setStyle() @@ -259,11 +291,11 @@ public: setLineWidth(3); } XpressiveKnob(QWidget * _parent, const QString & _name) : - Knob(knobStyled, _parent,_name) { + Knob(knobStyled, _parent,_name) { setStyle(); } XpressiveKnob(QWidget * _parent) : - Knob(knobStyled, _parent) { + Knob(knobStyled, _parent) { setStyle(); } @@ -356,7 +388,7 @@ XpressiveView::XpressiveView(Instrument * _instrument, QWidget * _parent) : m_selectedGraphGroup->addButton(m_o1Btn); m_selectedGraphGroup->addButton(m_o2Btn); - Xpressive *e = castModel(); + auto e = castModel(); m_selectedGraphGroup->setModel(&e->selectedGraph()); m_sinWaveBtn = new PixmapButton(this, tr("Sine wave")); @@ -393,7 +425,7 @@ XpressiveView::XpressiveView(Instrument * _instrument, QWidget * _parent) : m_triangleWaveBtn = new PixmapButton(this, tr("Triangle wave")); m_triangleWaveBtn->move(4 + 14, ROW_WAVEBTN); m_triangleWaveBtn->setActiveGraphic( - embed::getIconPixmap("triangle_wave_active")); + embed::getIconPixmap("triangle_wave_active")); m_triangleWaveBtn->setInactiveGraphic( embed::getIconPixmap("triangle_wave_inactive")); m_triangleWaveBtn->setToolTip(tr("Triangle wave")); @@ -408,7 +440,7 @@ XpressiveView::XpressiveView(Instrument * _instrument, QWidget * _parent) : m_whiteNoiseWaveBtn = new PixmapButton(this, tr("White noise")); m_whiteNoiseWaveBtn->move(4 + 14 * 3, ROW_WAVEBTN); m_whiteNoiseWaveBtn->setActiveGraphic( - embed::getIconPixmap("white_noise_wave_active")); + embed::getIconPixmap("white_noise_wave_active")); m_whiteNoiseWaveBtn->setInactiveGraphic( embed::getIconPixmap("white_noise_wave_inactive")); m_whiteNoiseWaveBtn->setToolTip(tr("White noise")); @@ -419,7 +451,7 @@ XpressiveView::XpressiveView(Instrument * _instrument, QWidget * _parent) : m_waveInterpolate->move(2, 230); m_expressionValidToggle = new LedCheckBox("", this, tr("ExpressionValid"), - LedCheckBox::Red); + LedCheckBox::Red); m_expressionValidToggle->move(168, EXPR_TEXT_Y+EXPR_TEXT_H-2); m_expressionValidToggle->setEnabled( false ); @@ -500,31 +532,27 @@ XpressiveView::XpressiveView(Instrument * _instrument, QWidget * _parent) : updateLayout(); } -XpressiveView::~XpressiveView() -{ -} - void XpressiveView::expressionChanged() { - Xpressive * e = castModel(); + auto e = castModel(); QByteArray text = m_expressionEditor->toPlainText().toLatin1(); switch (m_selectedGraphGroup->model()->value()) { - case W1_EXPR: - e->wavesExpression(0) = text; - break; - case W2_EXPR: - e->wavesExpression(1) = text; - break; - case W3_EXPR: - e->wavesExpression(2) = text; - break; - case O1_EXPR: - e->outputExpression(0) = text; - break; - case O2_EXPR: - e->outputExpression(1) = text; - break; + case W1_EXPR: + e->wavesExpression(0) = text; + break; + case W2_EXPR: + e->wavesExpression(1) = text; + break; + case W3_EXPR: + e->wavesExpression(2) = text; + break; + case O1_EXPR: + e->outputExpression(0) = text; + break; + case O2_EXPR: + e->outputExpression(1) = text; + break; } if (m_wave_expr) m_graph->setEnabled(m_smoothKnob->model()->value() == 0 && text.size() == 0); @@ -562,7 +590,7 @@ void XpressiveView::expressionChanged() { if (parse_ok) { e->exprValid().setValue(0); const int length = m_raw_graph->length(); - float * const samples = new float[length]; + auto const samples = new float[length]; for (i = 0; i < length; i++) { t = i / (float) length; samples[i] = expr.evaluate(); @@ -595,39 +623,10 @@ void XpressiveView::expressionChanged() { } } -void Xpressive::smooth(float smoothness,const graphModel * in,graphModel * out) -{ - out->setSamples(in->samples()); - if (smoothness>0) - { - const int guass_size = (int)(smoothness * 5) | 1; - const int guass_center = guass_size/2; - const float delta = smoothness; - const float a= 1.0f / (sqrtf(2.0f * F_PI) * delta); - float * const guassian = new float [guass_size]; - float sum = 0.0f; - float temp = 0.0f; - int i; - for (i = 0; i < guass_size; i++ ) - { - temp = (i - guass_center) / delta; - sum += guassian[i] = a * powf(F_E, -0.5f * temp * temp); - } - for (i = 0; i < guass_size; i++ ) - { - guassian[i] = guassian[i] / sum; - } - out->convolve(guassian, guass_size, guass_center); - delete [] guassian; - } -} - - - void XpressiveView::smoothChanged() { - - Xpressive * e = castModel(); + + auto e = castModel(); float smoothness=0; switch (m_selectedGraphGroup->model()->value()) { case W1_EXPR: @@ -659,7 +658,7 @@ void XpressiveView::smoothChanged() void XpressiveView::graphDrawn() { m_raw_graph->setSamples(m_graph->model()->samples()); - Xpressive * e = castModel(); + auto e = castModel(); switch (m_selectedGraphGroup->model()->value()) { case W1_EXPR: e->W1().copyFrom(m_graph->model()); @@ -675,7 +674,7 @@ void XpressiveView::graphDrawn() } void XpressiveView::modelChanged() { - Xpressive * b = castModel(); + auto b = castModel(); m_expressionValidToggle->setModel( &b->exprValid() ); m_generalPurposeKnob[0]->setModel( &b->parameterA1() ); @@ -691,7 +690,7 @@ void XpressiveView::modelChanged() { } void XpressiveView::updateLayout() { - Xpressive * e = castModel(); + auto e = castModel(); m_output_expr=false; m_wave_expr=false; switch (m_selectedGraphGroup->model()->value()) { @@ -869,6 +868,18 @@ QString XpressiveHelpView::s_helpText= XpressiveHelpView::XpressiveHelpView():QTextEdit(s_helpText) { + +#if QT_VERSION < 0x50C00 + // Workaround for a bug in Qt versions below 5.12, + // where argument-dependent-lookup fails for QFlags operators + // declared inside a namepsace. + // This affects the Q_DECLARE_OPERATORS_FOR_FLAGS macro in Instrument.h + // See also: https://codereview.qt-project.org/c/qt/qtbase/+/225348 + + using ::operator|; + +#endif + setWindowTitle ( "Xpressive Help" ); setTextInteractionFlags ( Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse ); getGUI()->mainWindow()->addWindowedWidget( this ); @@ -887,6 +898,9 @@ void XpressiveView::helpClicked() { } + +} // namespace gui + extern "C" { // necessary for getting instance out of shared lib @@ -897,5 +911,4 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main(Model *m, void *) { } - - +} // namespace lmms diff --git a/plugins/Xpressive/Xpressive.h b/plugins/Xpressive/Xpressive.h index 651660cfe..b91957ac4 100644 --- a/plugins/Xpressive/Xpressive.h +++ b/plugins/Xpressive/Xpressive.h @@ -35,8 +35,13 @@ #include "ExprSynth.h" +class QPlainTextEdit; + +namespace lmms +{ + + class oscillator; -class XpressiveView; const int W1_EXPR = 0; const int W2_EXPR = 1; @@ -47,8 +52,12 @@ const int NUM_EXPRS = 5; class ExprFront; + +namespace gui +{ class SubWindow; -class QPlainTextEdit; +class XpressiveView; +} @@ -57,20 +66,19 @@ class Xpressive : public Instrument Q_OBJECT public: Xpressive(InstrumentTrack* instrument_track ); - virtual ~Xpressive(); - virtual void playNote(NotePlayHandle* nph, - sampleFrame* working_buffer ); - virtual void deleteNotePluginData( NotePlayHandle* nph ); + void playNote(NotePlayHandle* nph, + sampleFrame* working_buffer ) override; + void deleteNotePluginData( NotePlayHandle* nph ) override; - virtual void saveSettings( QDomDocument& _doc, - QDomElement& _this ); - virtual void loadSettings( const QDomElement& _this ); + void saveSettings( QDomDocument& _doc, + QDomElement& _this ) override; + void loadSettings( const QDomElement& _this ) override; - virtual QString nodeName() const; + QString nodeName() const override; - virtual PluginView* instantiateView( QWidget * parent ); + gui::PluginView* instantiateView( QWidget * parent ) override; graphModel& graphO1() { return m_graphO1; } graphModel& graphO2() { return m_graphO2; } @@ -137,6 +145,9 @@ private: } ; +namespace gui +{ + class XpressiveView : public InstrumentViewFixedSize { @@ -145,7 +156,6 @@ public: XpressiveView( Instrument* _instrument, QWidget* _parent ); - virtual ~XpressiveView(); protected: @@ -161,12 +171,12 @@ protected slots: void expWaveClicked(); void usrWaveClicked(); void helpClicked(); - void expressionChanged( ); - void smoothChanged( ); - void graphDrawn( ); + void expressionChanged(); + void smoothChanged(); + void graphDrawn(); private: - virtual void modelChanged(); + void modelChanged() override; Knob *m_generalPurposeKnob[3]; Knob *m_panningKnob[2]; @@ -217,4 +227,9 @@ private: static QString s_helpText; }; + +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/ZynAddSubFx/CMakeLists.txt b/plugins/ZynAddSubFx/CMakeLists.txt index 0c8fa8681..3369a7938 100644 --- a/plugins/ZynAddSubFx/CMakeLists.txt +++ b/plugins/ZynAddSubFx/CMakeLists.txt @@ -1,5 +1,12 @@ +if(NOT FLTK_FOUND) + return() +endif() + INCLUDE(BuildPlugin) +find_package(Threads REQUIRED) +find_package(ZLIB REQUIRED) + set(CMAKE_POSITION_INDEPENDENT_CODE ON) # definitions for ZynAddSubFX @@ -11,40 +18,20 @@ ELSE() ADD_DEFINITIONS(-DOS_WINDOWS) ENDIF() -# do not conflict with LMMS' Controller class -ADD_DEFINITIONS(-DController=ZynController) - # use asm optimizations when on x86 or x86_64 -IF(LMMS_HOST_X86 OR LMMS_HOST_X86_64) +if(NOT MSVC AND (LMMS_HOST_X86 OR LMMS_HOST_X86_64)) ADD_DEFINITIONS(-DASM_F2I_YES) -ENDIF(LMMS_HOST_X86 OR LMMS_HOST_X86_64) +endif() # build ZynAddSubFX with full optimizations -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wno-write-strings -Wno-deprecated-declarations -fpermissive") +if(NOT MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wno-write-strings -Wno-deprecated-declarations -fpermissive") +endif() IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND NOT "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "6.0.0") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-misleading-indentation") ENDIF() -IF(LMMS_BUILD_WIN32) - # link system-libraries - ADD_DEFINITIONS(-DPTW32_STATIC_LIB) - # fix X11 headers errors caused by bug with mingw + c++11 (enable -std=gnu++0x) - SET(CMAKE_CXX_EXTENSIONS ON) -ENDIF(LMMS_BUILD_WIN32) - -SET(FLTK_SKIP_OPENGL TRUE) -SET(FLTK_SKIP_FORMS TRUE) -SET(FLTK_SKIP_IMAGES TRUE) -SET(FLTK_SKIP_MATH TRUE) -IF(MINGW_PREFIX) - SET(FLTK_SKIP_FLUID TRUE) -ENDIF() - -IF(NOT FLTK_FOUND) - RETURN() -ENDIF() - IF(MINGW_PREFIX) SET(FLTK_FLUID_EXECUTABLE "${MINGW_PREFIX}/bin/fluid") ENDIF() @@ -57,13 +44,15 @@ IF(NOT EXISTS ${FLTK_FLUID_EXECUTABLE}) ENDIF() ENDIF() -INCLUDE_DIRECTORIES("${FLTK_INCLUDE_DIR}" - "${CMAKE_CURRENT_SOURCE_DIR}" - ${FFTW3F_INCLUDE_DIRS} - "${CMAKE_CURRENT_BINARY_DIR}" - "${CMAKE_BINARY_DIR}") - -include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/zynaddsubfx/src/UI) +include_directories( + "${FLTK_INCLUDE_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}" + ${FFTW3F_INCLUDE_DIRS} + "${CMAKE_CURRENT_BINARY_DIR}" + "${CMAKE_BINARY_DIR}" + "${CMAKE_SOURCE_DIR}/src/3rdparty/mingw-std-threads" + "${CMAKE_CURRENT_SOURCE_DIR}/zynaddsubfx/src/UI" +) ADD_DEFINITIONS(-DPLUGINVERSION) # removes exit confirmation dialogs etc. in MasterUI.fl add_subdirectory(zynaddsubfx/src/Nio) @@ -116,24 +105,23 @@ SET(zynaddsubfx_core_SRCS zynaddsubfx/src/Synth/PADnote.cpp zynaddsubfx/src/Synth/Resonance.cpp zynaddsubfx/src/Synth/SUBnote.cpp - ) +) +add_library(ZynAddSubFxCoreObjs OBJECT LocalZynAddSubFx.cpp ${zynaddsubfx_core_SRCS}) +add_library(ZynAddSubFxCore INTERFACE) +target_sources(ZynAddSubFxCore INTERFACE + $ + $ +) -IF(LMMS_BUILD_LINUX) - ADD_LIBRARY(ZynAddSubFxCore MODULE LocalZynAddSubFx.cpp ${zynaddsubfx_core_SRCS}) -ELSE() - ADD_LIBRARY(ZynAddSubFxCore SHARED LocalZynAddSubFx.cpp ${zynaddsubfx_core_SRCS}) -ENDIF() -TARGET_LINK_LIBRARIES(ZynAddSubFxCore zynaddsubfx_nio ${FFTW3F_LIBRARIES} ${QT_LIBRARIES} -lz -lpthread) - -TARGET_LINK_LIBRARIES(ZynAddSubFxCore Qt5::Widgets Qt5::Xml) - -IF(LMMS_BUILD_WIN32) - TARGET_LINK_LIBRARIES(ZynAddSubFxCore -lws2_32) - INSTALL(TARGETS ZynAddSubFxCore RUNTIME DESTINATION "${PLUGIN_DIR}") -ELSE(LMMS_BUILD_WIN32) - INSTALL(TARGETS ZynAddSubFxCore LIBRARY DESTINATION "${PLUGIN_DIR}") -ENDIF(LMMS_BUILD_WIN32) +target_link_libraries(ZynAddSubFxCore INTERFACE + ${FFTW3F_LIBRARIES} + ${QT_LIBRARIES} + Qt5::Widgets + Qt5::Xml + Threads::Threads + ZLIB::ZLIB +) LINK_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}/..") IF(LMMS_BUILD_LINUX) @@ -144,10 +132,11 @@ ELSE() SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${PLUGIN_DIR}") ENDIF() BUILD_PLUGIN(zynaddsubfx ZynAddSubFx.cpp ZynAddSubFx.h MOCFILES ZynAddSubFx.h EMBEDDED_RESOURCES artwork.png logo.png) -TARGET_LINK_LIBRARIES(zynaddsubfx -lZynAddSubFxCore) -ADD_DEPENDENCIES(zynaddsubfx ZynAddSubFxCore) +target_link_libraries(zynaddsubfx ZynAddSubFxCore) -IF(WIN32) +if(MSVC) + set(WINRC "${CMAKE_CURRENT_BINARY_DIR}/zynaddsubfx.rc") +elseif(WIN32) SET(WINRC "${CMAKE_CURRENT_BINARY_DIR}/zynaddsubfxrc.obj") ADD_CUSTOM_COMMAND(OUTPUT "${WINRC}" COMMAND "${CMAKE_RC_COMPILER}" @@ -155,14 +144,19 @@ IF(WIN32) "-o\"${CMAKE_CURRENT_BINARY_DIR}/zynaddsubfxrc.obj\"" "-i\"${CMAKE_CURRENT_BINARY_DIR}/zynaddsubfx.rc\"" DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/zynaddsubfx.rc") -ENDIF(WIN32) +endif() # Use libraries in non-standard directories (e.g., another version of Qt) SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) ADD_SUBDIRECTORY("${LMMS_SOURCE_DIR}/src/common" common) -ADD_EXECUTABLE(RemoteZynAddSubFx RemoteZynAddSubFx.cpp ${LMMS_COMMON_SRCS} "${WINRC}") +add_executable(RemoteZynAddSubFx + RemoteZynAddSubFx.cpp + ${LMMS_COMMON_SRCS} + "${WINRC}" + $ +) INSTALL(TARGETS RemoteZynAddSubFx RUNTIME DESTINATION "${PLUGIN_DIR}") # Needed to deploy dependencies of RemoteZynAddSubFx SET_PROPERTY(GLOBAL APPEND PROPERTY PLUGINS_BUILT "RemoteZynAddSubFx") @@ -182,8 +176,7 @@ IF(FLTK_CONFIG AND NOT (LMMS_BUILD_APPLE OR LMMS_BUILD_WIN32)) STRING(REPLACE " " ";" FLTK_FILTERED_LDFLAGS ${FLTK_FILTERED_LDFLAGS}) LIST(REMOVE_ITEM FLTK_FILTERED_LDFLAGS -lX11) ENDIF() -TARGET_LINK_LIBRARIES(RemoteZynAddSubFx zynaddsubfx_gui -lZynAddSubFxCore ${FLTK_FILTERED_LDFLAGS} -lpthread ) -ADD_DEPENDENCIES(RemoteZynAddSubFx ZynAddSubFxCore) +target_link_libraries(RemoteZynAddSubFx ZynAddSubFxCore ${FLTK_FILTERED_LDFLAGS}) if(LMMS_HAVE_LIBRT) target_link_libraries(RemoteZynAddSubFx rt) @@ -199,6 +192,11 @@ ENDIF(LMMS_BUILD_WIN32) IF(LMMS_BUILD_WIN32) - ADD_CUSTOM_COMMAND(TARGET ZynAddSubFxCore POST_BUILD COMMAND "${STRIP}" \"$\") - ADD_CUSTOM_COMMAND(TARGET RemoteZynAddSubFx POST_BUILD COMMAND "${STRIP}" \"$\") + add_custom_command( + TARGET RemoteZynAddSubFx + POST_BUILD + COMMAND "${STRIP_COMMAND}" "$" + VERBATIM + COMMAND_EXPAND_LISTS + ) ENDIF(LMMS_BUILD_WIN32) diff --git a/plugins/ZynAddSubFx/LocalZynAddSubFx.cpp b/plugins/ZynAddSubFx/LocalZynAddSubFx.cpp index ed32339eb..83ef3e9a2 100644 --- a/plugins/ZynAddSubFx/LocalZynAddSubFx.cpp +++ b/plugins/ZynAddSubFx/LocalZynAddSubFx.cpp @@ -22,23 +22,34 @@ * */ -#include +#include "LocalZynAddSubFx.h" -#include "zynaddsubfx/src/Misc/Util.h" -#include #include -#include "LocalZynAddSubFx.h" +#include "lmmsconfig.h" + +#ifdef LMMS_BUILD_WIN32 +# include +# include "IoHelper.h" +#else +# include +#endif #include "MidiEvent.h" #include "zynaddsubfx/src/Nio/NulEngine.h" #include "zynaddsubfx/src/Misc/Master.h" #include "zynaddsubfx/src/Misc/Part.h" +#include "zynaddsubfx/src/Misc/Util.h" - +// Global variable in zynaddsubfx/src/globals.h SYNTH_T* synth = nullptr; + +namespace lmms +{ + + int LocalZynAddSubFx::s_instanceCount = 0; @@ -46,21 +57,8 @@ LocalZynAddSubFx::LocalZynAddSubFx() : m_master( nullptr ), m_ioEngine( nullptr ) { - for( int i = 0; i < NumKeys; ++i ) - { - m_runningNotes[i] = 0; - } - if( s_instanceCount == 0 ) { -#ifdef LMMS_BUILD_WIN32 -#ifndef __WINPTHREADS_VERSION - // (non-portable) initialization of statically linked pthread library - pthread_win32_process_attach_np(); - pthread_win32_thread_attach_np(); -#endif -#endif - initConfig(); synth = new SYNTH_T; @@ -81,7 +79,7 @@ LocalZynAddSubFx::LocalZynAddSubFx() : m_ioEngine = new NulEngine; m_master = new Master(); - m_master->swaplr = 0; + m_master->swaplr = false; } @@ -143,14 +141,20 @@ void LocalZynAddSubFx::loadXML( const std::string & _filename ) { char * f = strdup( _filename.c_str() ); - pthread_mutex_lock( &m_master->mutex ); - m_master->defaults(); - m_master->loadXML( f ); - pthread_mutex_unlock( &m_master->mutex ); + { + const auto lock = std::lock_guard{m_master->mutex}; + m_master->defaults(); + m_master->loadXML( f ); + } m_master->applyparameters(); +#ifdef LMMS_BUILD_WIN32 + _wunlink(toWString(_filename).c_str()); +#else unlink( f ); +#endif + free( f ); } @@ -161,10 +165,11 @@ void LocalZynAddSubFx::loadPreset( const std::string & _filename, int _part ) { char * f = strdup( _filename.c_str() ); - pthread_mutex_lock( &m_master->mutex ); - m_master->part[_part]->defaultsinstrument(); - m_master->part[_part]->loadXMLinstrument( f ); - pthread_mutex_unlock( &m_master->mutex ); + { + const auto lock = std::lock_guard{m_master->mutex}; + m_master->part[_part]->defaultsinstrument(); + m_master->part[_part]->loadXMLinstrument( f ); + } m_master->applyparameters(); @@ -177,14 +182,14 @@ void LocalZynAddSubFx::loadPreset( const std::string & _filename, int _part ) void LocalZynAddSubFx::setPresetDir( const std::string & _dir ) { m_presetsDir = _dir; - for( int i = 0; i < MAX_BANK_ROOT_DIRS; ++i ) + for (auto& bankRootDir : config.cfg.bankRootDirList) { - if( config.cfg.bankRootDirList[i].empty() ) + if (bankRootDir.empty()) { - config.cfg.bankRootDirList[i] = m_presetsDir; + bankRootDir = m_presetsDir; break; } - else if( config.cfg.bankRootDirList[i] == m_presetsDir ) + else if (bankRootDir == m_presetsDir) { break; } @@ -209,9 +214,9 @@ void LocalZynAddSubFx::setLmmsWorkingDir( const std::string & _dir ) void LocalZynAddSubFx::setPitchWheelBendRange( int semitones ) { - for( int i = 0; i < NUM_MIDI_PARTS; ++i ) + for (const auto& part : m_master->part) { - m_master->part[i]->ctl.setpitchwheelbendrange( semitones * 100 ); + part->ctl.setpitchwheelbendrange(semitones * 100); } } @@ -262,8 +267,13 @@ void LocalZynAddSubFx::processMidiEvent( const MidiEvent& event ) void LocalZynAddSubFx::processAudio( sampleFrame * _out ) { +#ifdef _MSC_VER + const auto outputl = static_cast(_alloca(synth->buffersize * sizeof(float))); + const auto outputr = static_cast(_alloca(synth->buffersize * sizeof(float))); +#else float outputl[synth->buffersize]; float outputr[synth->buffersize]; +#endif m_master->GetAudioOutSamples( synth->buffersize, synth->samplerate, outputl, outputr ); @@ -276,3 +286,4 @@ void LocalZynAddSubFx::processAudio( sampleFrame * _out ) } +} // namespace lmms diff --git a/plugins/ZynAddSubFx/LocalZynAddSubFx.h b/plugins/ZynAddSubFx/LocalZynAddSubFx.h index 397fbbe82..f37a3e0f4 100644 --- a/plugins/ZynAddSubFx/LocalZynAddSubFx.h +++ b/plugins/ZynAddSubFx/LocalZynAddSubFx.h @@ -28,9 +28,14 @@ #include "Note.h" class Master; -class MidiEvent; class NulEngine; +namespace lmms +{ + +class MidiEvent; + + class LocalZynAddSubFx { public: @@ -67,10 +72,13 @@ protected: std::string m_presetsDir; - int m_runningNotes[NumKeys]; + std::array m_runningNotes = {}; Master * m_master; NulEngine* m_ioEngine; } ; + +} // namespace lmms + #endif diff --git a/plugins/ZynAddSubFx/RemoteZynAddSubFx.cpp b/plugins/ZynAddSubFx/RemoteZynAddSubFx.cpp index 0c0c0af39..c4d6b71a1 100644 --- a/plugins/ZynAddSubFx/RemoteZynAddSubFx.cpp +++ b/plugins/ZynAddSubFx/RemoteZynAddSubFx.cpp @@ -22,22 +22,25 @@ * */ +#include "RemoteZynAddSubFx.h" + #include #ifdef LMMS_BUILD_WIN32 #include #endif #include +#include "ThreadShims.h" #undef CursorShape // is, by mistake, not undefed in FL #include "RemotePluginClient.h" -#include "RemoteZynAddSubFx.h" #include "LocalZynAddSubFx.h" #include "zynaddsubfx/src/Nio/Nio.h" #include "zynaddsubfx/src/UI/MasterUI.h" +using namespace lmms; class RemoteZynAddSubFx : public RemotePluginClient, public LocalZynAddSubFx { @@ -59,21 +62,21 @@ public: sendMessage( IdInitDone ); waitForMessage( IdInitDone ); - pthread_mutex_init( &m_guiMutex, nullptr ); - pthread_create( &m_messageThreadHandle, nullptr, messageLoop, this ); + m_messageThread = std::thread{&RemoteZynAddSubFx::messageLoop, this}; } - virtual ~RemoteZynAddSubFx() + ~RemoteZynAddSubFx() override { + m_messageThread.join(); Nio::stop(); } - virtual void updateSampleRate() + void updateSampleRate() override { LocalZynAddSubFx::setSampleRate( sampleRate() ); } - virtual void updateBufferSize() + void updateBufferSize() override { LocalZynAddSubFx::setBufferSize( bufferSize() ); } @@ -83,14 +86,13 @@ public: message m; while( ( m = receiveMessage() ).id != IdQuit ) { - pthread_mutex_lock( &m_master->mutex ); + const auto lock = std::lock_guard{m_master->mutex}; processMessage( m ); - pthread_mutex_unlock( &m_master->mutex ); } m_guiExit = true; } - virtual bool processMessage( const message & _m ) + bool processMessage( const message & _m ) override { switch( _m.id ) { @@ -101,9 +103,10 @@ public: case IdHideUI: case IdLoadSettingsFromFile: case IdLoadPresetFile: - pthread_mutex_lock( &m_guiMutex ); - m_guiMessages.push( _m ); - pthread_mutex_unlock( &m_guiMutex ); + { + const auto lock = std::lock_guard{m_guiMutex}; + m_guiMessages.push( _m ); + } break; case IdSaveSettingsToFile: @@ -132,34 +135,24 @@ public: } // all functions are called while m_master->mutex is held - virtual void processMidiEvent( const MidiEvent& event, const f_cnt_t /* _offset */ ) + void processMidiEvent( const MidiEvent& event, const f_cnt_t /* _offset */ ) override { LocalZynAddSubFx::processMidiEvent( event ); } - virtual void process( const sampleFrame * _in, sampleFrame * _out ) + void process( const sampleFrame * _in, sampleFrame * _out ) override { LocalZynAddSubFx::processAudio( _out ); } - static void * messageLoop( void * _arg ) - { - RemoteZynAddSubFx * _this = - static_cast( _arg ); - - _this->messageLoop(); - - return nullptr; - } - void guiLoop(); private: const int m_guiSleepTime; - pthread_t m_messageThreadHandle; - pthread_mutex_t m_guiMutex; + std::thread m_messageThread; + std::mutex m_guiMutex; std::queue m_guiMessages; bool m_guiExit; @@ -189,12 +182,11 @@ void RemoteZynAddSubFx::guiLoop() } if( exitProgram == 1 ) { - pthread_mutex_lock( &m_master->mutex ); + const auto lock = std::lock_guard{m_master->mutex}; sendMessage( IdHideUI ); exitProgram = 0; - pthread_mutex_unlock( &m_master->mutex ); } - pthread_mutex_lock( &m_guiMutex ); + const auto lock = std::lock_guard{m_guiMutex}; while( m_guiMessages.size() ) { RemotePluginClient::message m = m_guiMessages.front(); @@ -219,9 +211,8 @@ void RemoteZynAddSubFx::guiLoop() { ui->refresh_master_ui(); } - pthread_mutex_lock( &m_master->mutex ); + const auto lock = std::lock_guard{m_master->mutex}; sendMessage( IdLoadSettingsFromFile ); - pthread_mutex_unlock( &m_master->mutex ); break; } @@ -235,9 +226,8 @@ void RemoteZynAddSubFx::guiLoop() ui->updatepanel(); ui->refresh_master_ui(); } - pthread_mutex_lock( &m_master->mutex ); + const auto lock = std::lock_guard{m_master->mutex}; sendMessage( IdLoadPresetFile ); - pthread_mutex_unlock( &m_master->mutex ); break; } @@ -245,7 +235,6 @@ void RemoteZynAddSubFx::guiLoop() break; } } - pthread_mutex_unlock( &m_guiMutex ); } Fl::flush(); @@ -271,34 +260,17 @@ int main( int _argc, char * * _argv ) const auto pollParentThread = PollParentThread{}; #endif -#ifdef LMMS_BUILD_WIN32 -#ifndef __WINPTHREADS_VERSION - // (non-portable) initialization of statically linked pthread library - pthread_win32_process_attach_np(); - pthread_win32_thread_attach_np(); -#endif -#endif - - #ifdef SYNC_WITH_SHM_FIFO RemoteZynAddSubFx * remoteZASF = new RemoteZynAddSubFx( _argv[1], _argv[2] ); #else - RemoteZynAddSubFx * remoteZASF = new RemoteZynAddSubFx( _argv[1] ); + auto remoteZASF = new RemoteZynAddSubFx(_argv[1]); #endif remoteZASF->guiLoop(); delete remoteZASF; - -#ifdef LMMS_BUILD_WIN32 -#ifndef __WINPTHREADS_VERSION - pthread_win32_thread_detach_np(); - pthread_win32_process_detach_np(); -#endif -#endif - return 0; } diff --git a/plugins/ZynAddSubFx/RemoteZynAddSubFx.h b/plugins/ZynAddSubFx/RemoteZynAddSubFx.h index edeb42427..6745cb846 100644 --- a/plugins/ZynAddSubFx/RemoteZynAddSubFx.h +++ b/plugins/ZynAddSubFx/RemoteZynAddSubFx.h @@ -27,11 +27,18 @@ #include "RemotePluginBase.h" +namespace lmms +{ + + enum ZasfRemoteMessageIDs { - IdZasfPresetDirectory = IdUserBase, + IdZasfPresetDirectory = RemoteMessageIDs::IdUserBase, IdZasfLmmsWorkingDirectory, IdZasfSetPitchWheelBendRange } ; + +} // namespace lmms + #endif diff --git a/plugins/ZynAddSubFx/ThreadShims.h b/plugins/ZynAddSubFx/ThreadShims.h new file mode 100644 index 000000000..843b50fb5 --- /dev/null +++ b/plugins/ZynAddSubFx/ThreadShims.h @@ -0,0 +1,9 @@ +#include +#include +#include + +#if defined(__MINGW32__) && !defined(_GLIBCXX_HAS_GTHREADS) +# include +# include +# include +#endif diff --git a/plugins/ZynAddSubFx/ZynAddSubFx.cpp b/plugins/ZynAddSubFx/ZynAddSubFx.cpp index b83f055ef..d3d23c65f 100644 --- a/plugins/ZynAddSubFx/ZynAddSubFx.cpp +++ b/plugins/ZynAddSubFx/ZynAddSubFx.cpp @@ -51,12 +51,16 @@ #include "embed.h" #include "plugin_export.h" +namespace lmms +{ + + extern "C" { Plugin::Descriptor PLUGIN_EXPORT zynaddsubfx_plugin_descriptor = { - STRINGIFY( PLUGIN_NAME ), + LMMS_STRINGIFY( PLUGIN_NAME ), "ZynAddSubFX", QT_TRANSLATE_NOOP( "PluginBrowser", "Embedded ZynAddSubFX" ), @@ -80,13 +84,6 @@ ZynAddSubFxRemotePlugin::ZynAddSubFxRemotePlugin() : - -ZynAddSubFxRemotePlugin::~ZynAddSubFxRemotePlugin() -{ -} - - - bool ZynAddSubFxRemotePlugin::processMessage( const message & _m ) { switch( _m.id ) @@ -138,7 +135,7 @@ ZynAddSubFxInstrument::ZynAddSubFxInstrument( this, SLOT( updateResBandwidth() ), Qt::DirectConnection ); // now we need a play-handle which cares for calling play() - InstrumentPlayHandle * iph = new InstrumentPlayHandle( this, _instrumentTrack ); + auto iph = new InstrumentPlayHandle(this, _instrumentTrack); Engine::audioEngine()->addPlayHandle( iph ); connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), @@ -485,15 +482,16 @@ void ZynAddSubFxInstrument::sendControlChange( MidiControllers midiCtl, float va -PluginView * ZynAddSubFxInstrument::instantiateView( QWidget * _parent ) +gui::PluginView* ZynAddSubFxInstrument::instantiateView( QWidget * _parent ) { - return new ZynAddSubFxView( this, _parent ); + return new gui::ZynAddSubFxView( this, _parent ); } - +namespace gui +{ ZynAddSubFxView::ZynAddSubFxView( Instrument * _instrument, QWidget * _parent ) : @@ -505,7 +503,7 @@ ZynAddSubFxView::ZynAddSubFxView( Instrument * _instrument, QWidget * _parent ) "artwork" ) ); setPalette( pal ); - QGridLayout * l = new QGridLayout( this ); + auto l = new QGridLayout(this); l->setContentsMargins( 20, 80, 10, 10 ); l->setVerticalSpacing( 16 ); l->setHorizontalSpacing( 10 ); @@ -568,14 +566,6 @@ ZynAddSubFxView::ZynAddSubFxView( Instrument * _instrument, QWidget * _parent ) - -ZynAddSubFxView::~ZynAddSubFxView() -{ -} - - - - void ZynAddSubFxView::dragEnterEvent( QDragEnterEvent * _dee ) { // For mimeType() and MimeType enum class @@ -621,7 +611,7 @@ void ZynAddSubFxView::dropEvent( QDropEvent * _de ) void ZynAddSubFxView::modelChanged() { - ZynAddSubFxInstrument * m = castModel(); + auto m = castModel(); // set models for controller knobs m_portamento->setModel( &m->m_portamentoModel ); @@ -642,7 +632,7 @@ void ZynAddSubFxView::modelChanged() void ZynAddSubFxView::toggleUI() { - ZynAddSubFxInstrument * model = castModel(); + auto model = castModel(); if( model->m_hasGUI != m_toggleUIButton->isChecked() ) { model->m_hasGUI = m_toggleUIButton->isChecked(); @@ -657,6 +647,7 @@ void ZynAddSubFxView::toggleUI() } +} // namespace gui @@ -673,3 +664,4 @@ PLUGIN_EXPORT Plugin * lmms_plugin_main(Model * m, void *) } +} // namespace lmms diff --git a/plugins/ZynAddSubFx/ZynAddSubFx.h b/plugins/ZynAddSubFx/ZynAddSubFx.h index 10243e373..996c187ee 100644 --- a/plugins/ZynAddSubFx/ZynAddSubFx.h +++ b/plugins/ZynAddSubFx/ZynAddSubFx.h @@ -37,21 +37,27 @@ class QPushButton; +namespace lmms +{ + + class LocalZynAddSubFx; -class ZynAddSubFxView; class NotePlayHandle; + +namespace gui +{ class Knob; class LedCheckBox; - +class ZynAddSubFxView; +} class ZynAddSubFxRemotePlugin : public RemotePlugin { Q_OBJECT public: ZynAddSubFxRemotePlugin(); - virtual ~ZynAddSubFxRemotePlugin(); - virtual bool processMessage( const message & _m ); + bool processMessage( const message & _m ) override; signals: @@ -66,26 +72,26 @@ class ZynAddSubFxInstrument : public Instrument Q_OBJECT public: ZynAddSubFxInstrument( InstrumentTrack * _instrument_track ); - virtual ~ZynAddSubFxInstrument(); + ~ZynAddSubFxInstrument() override; - virtual void play( sampleFrame * _working_buffer ); + void play( sampleFrame * _working_buffer ) override; - virtual bool handleMidiEvent( const MidiEvent& event, const TimePos& time = TimePos(), f_cnt_t offset = 0 ); + bool handleMidiEvent( const MidiEvent& event, const TimePos& time = TimePos(), f_cnt_t offset = 0 ) override; - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); - virtual void loadSettings( const QDomElement & _this ); + void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override; + void loadSettings( const QDomElement & _this ) override; - virtual void loadFile( const QString & _file ); + void loadFile( const QString & _file ) override; - virtual QString nodeName() const; + QString nodeName() const override; - virtual Flags flags() const + Flags flags() const override { return IsSingleStreamed | IsMidiBased; } - virtual PluginView * instantiateView( QWidget * _parent ); + gui::PluginView* instantiateView( QWidget * _parent ) override; private slots: @@ -122,7 +128,7 @@ private: QMap m_modifiedControllers; - friend class ZynAddSubFxView; + friend class gui::ZynAddSubFxView; signals: @@ -131,22 +137,24 @@ signals: } ; +namespace gui +{ + class ZynAddSubFxView : public InstrumentViewFixedSize { Q_OBJECT public: ZynAddSubFxView( Instrument * _instrument, QWidget * _parent ); - virtual ~ZynAddSubFxView(); protected: - virtual void dragEnterEvent( QDragEnterEvent * _dee ); - virtual void dropEvent( QDropEvent * _de ); + void dragEnterEvent( QDragEnterEvent * _dee ) override; + void dropEvent( QDropEvent * _de ) override; private: - void modelChanged(); + void modelChanged() override; QPushButton * m_toggleUIButton; Knob * m_portamento; @@ -165,4 +173,8 @@ private slots: } ; +} // namespace gui + +} // namespace lmms + #endif diff --git a/plugins/ZynAddSubFx/zynaddsubfx b/plugins/ZynAddSubFx/zynaddsubfx index 5a8328bc4..551e816a6 160000 --- a/plugins/ZynAddSubFx/zynaddsubfx +++ b/plugins/ZynAddSubFx/zynaddsubfx @@ -1 +1 @@ -Subproject commit 5a8328bc43ce638b5b5c4d8fbb23fc401c18d2b5 +Subproject commit 551e816a6334fd190c74ce971378063b2757b47b diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7f8a0dfcb..bd543779f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -55,7 +55,7 @@ ADD_GEN_QRC(LMMS_RCC_OUT lmms.qrc # Paths relative to lmms executable FILE(RELATIVE_PATH LIB_DIR_RELATIVE "/${BIN_DIR}" "/${LIB_DIR}") FILE(RELATIVE_PATH PLUGIN_DIR_RELATIVE "/${BIN_DIR}" "/${PLUGIN_DIR}") -ADD_DEFINITIONS(-DLIB_DIR="${LIB_DIR_RELATIVE}" -DPLUGIN_DIR="${PLUGIN_DIR_RELATIVE}" ${PULSEAUDIO_DEFINITIONS} ${PORTAUDIO_DEFINITIONS}) +ADD_DEFINITIONS(-DLIB_DIR="${LIB_DIR_RELATIVE}" -DPLUGIN_DIR="${PLUGIN_DIR_RELATIVE}" ${PULSEAUDIO_DEFINITIONS}) INCLUDE_DIRECTORIES( ${JACK_INCLUDE_DIRS} ${SAMPLERATE_INCLUDE_DIRS} @@ -75,10 +75,6 @@ IF(LMMS_HAVE_WEAKJACK) ADD_DEFINITIONS(-DUSE_WEAK_JACK=1 -DNO_JACK_METADATA=1) ENDIF() -IF(NOT ("${PORTAUDIO_INCLUDE_DIR}" STREQUAL "")) - INCLUDE_DIRECTORIES("${PORTAUDIO_INCLUDE_DIR}") -ENDIF() - IF(NOT ("${PULSEAUDIO_INCLUDE_DIR}" STREQUAL "")) INCLUDE_DIRECTORIES("${PULSEAUDIO_INCLUDE_DIR}") ENDIF() @@ -87,10 +83,6 @@ IF(NOT ("${OGGVORBIS_INCLUDE_DIR}" STREQUAL "")) INCLUDE_DIRECTORIES("${OGGVORBIS_INCLUDE_DIR}") ENDIF() -IF(NOT ("${LAME_INCLUDE_DIRS}" STREQUAL "")) - INCLUDE_DIRECTORIES("${LAME_INCLUDE_DIRS}") -ENDIF() - IF(NOT ("${LV2_INCLUDE_DIRS}" STREQUAL "")) INCLUDE_DIRECTORIES(${LV2_INCLUDE_DIRS}) ENDIF() @@ -170,19 +162,25 @@ if(LMMS_HAVE_LIBRT) list(APPEND EXTRA_LIBRARIES "rt") endif() +if(LMMS_HAVE_PORTAUDIO) + list(APPEND EXTRA_LIBRARIES portaudio) +endif() + +if(LMMS_HAVE_MP3LAME) + list(APPEND EXTRA_LIBRARIES mp3lame::mp3lame) +endif() + SET(LMMS_REQUIRED_LIBS ${LMMS_REQUIRED_LIBS} ${CMAKE_THREAD_LIBS_INIT} ${QT_LIBRARIES} ${ASOUND_LIBRARY} ${SDL_LIBRARY} ${SDL2_LIBRARY} - ${PORTAUDIO_LIBRARIES} ${SOUNDIO_LIBRARY} ${SNDIO_LIBRARIES} ${PULSEAUDIO_LIBRARIES} ${JACK_LIBRARIES} ${OGGVORBIS_LIBRARIES} - ${LAME_LIBRARIES} ${LV2_LIBRARIES} ${SUIL_LIBRARIES} ${LILV_LIBRARIES} diff --git a/src/common/RemotePluginBase.cpp b/src/common/RemotePluginBase.cpp index 9dc2ebec5..a4739a63c 100644 --- a/src/common/RemotePluginBase.cpp +++ b/src/common/RemotePluginBase.cpp @@ -29,6 +29,10 @@ #endif +namespace lmms +{ + + #ifdef SYNC_WITH_SHM_FIFO RemotePluginBase::RemotePluginBase( shmFifo * _in, shmFifo * _out ) : m_in( _in ), @@ -86,10 +90,10 @@ int RemotePluginBase::sendMessage( const message & _m ) writeInt( _m.id ); writeInt( _m.data.size() ); int j = 8; - for( unsigned int i = 0; i < _m.data.size(); ++i ) + for (const auto& str : _m.data) { - writeString( _m.data[i] ); - j += 4 + _m.data[i].size(); + writeString(str); + j += 4 + str.size(); } pthread_mutex_unlock( &m_sendMutex ); #endif @@ -186,3 +190,5 @@ RemotePluginBase::message RemotePluginBase::waitForMessage( return message(); } + +} // namespace lmms diff --git a/src/common/SharedMemory.cpp b/src/common/SharedMemory.cpp index 3c546ac32..005e726ed 100644 --- a/src/common/SharedMemory.cpp +++ b/src/common/SharedMemory.cpp @@ -44,10 +44,12 @@ # include #endif -namespace detail { + +namespace lmms::detail { #if _POSIX_SHARED_MEMORY_OBJECTS > 0 + namespace { template @@ -175,8 +177,7 @@ private: #endif -SharedMemoryData::SharedMemoryData() noexcept -{ } +SharedMemoryData::SharedMemoryData() noexcept = default; SharedMemoryData::SharedMemoryData(std::string&& key, bool readOnly) : m_key{std::move(key)}, @@ -190,7 +191,7 @@ SharedMemoryData::SharedMemoryData(std::string&& key, std::size_t size, bool rea m_ptr{m_impl->get()} { } -SharedMemoryData::~SharedMemoryData() { } +SharedMemoryData::~SharedMemoryData() = default; SharedMemoryData::SharedMemoryData(SharedMemoryData&& other) noexcept : m_key{std::move(other.m_key)}, @@ -198,4 +199,4 @@ SharedMemoryData::SharedMemoryData(SharedMemoryData&& other) noexcept : m_ptr{other.m_ptr} { } -} // namespace detail +} // namespace lmms::detail diff --git a/src/core/AudioEngine.cpp b/src/core/AudioEngine.cpp index eae7c6f20..a91e88f38 100644 --- a/src/core/AudioEngine.cpp +++ b/src/core/AudioEngine.cpp @@ -61,8 +61,10 @@ #include "BufferManager.h" -typedef LocklessList::Element LocklessListElement; +namespace lmms +{ +using LocklessListElement = LocklessList::Element; static thread_local bool s_renderingThread; @@ -90,7 +92,9 @@ AudioEngine::AudioEngine( bool renderOnly ) : m_clearSignal( false ), m_changesSignal( false ), m_changes( 0 ), +#if (QT_VERSION < QT_VERSION_CHECK(5,14,0)) m_doChangesMutex( QMutex::Recursive ), +#endif m_waitingForWrite( false ) { for( int i = 0; i < 2; ++i ) @@ -144,7 +148,7 @@ AudioEngine::AudioEngine( bool renderOnly ) : for( int i = 0; i < m_numWorkers+1; ++i ) { - AudioEngineWorkerThread * wt = new AudioEngineWorkerThread( this ); + auto wt = new AudioEngineWorkerThread(this); if( i < m_numWorkers ) { wt->start( QThread::TimeCriticalPriority ); @@ -184,9 +188,9 @@ AudioEngine::~AudioEngine() MemoryHelper::alignedFree(m_outputBufferRead); MemoryHelper::alignedFree(m_outputBufferWrite); - for( int i = 0; i < 2; ++i ) + for (const auto& input : m_inputBuffer) { - delete[] m_inputBuffer[i]; + delete[] input; } } @@ -311,7 +315,7 @@ void AudioEngine::pushInputFrames( sampleFrame * _ab, const f_cnt_t _frames ) if( frames + _frames > size ) { size = qMax( size * 2, frames + _frames ); - sampleFrame * ab = new sampleFrame[ size ]; + auto ab = new sampleFrame[size]; memcpy( ab, buf, frames * sizeof( sampleFrame ) ); delete [] buf; @@ -1109,7 +1113,7 @@ MidiClient * AudioEngine::tryMidiClients() #ifdef LMMS_HAVE_ALSA if( client_name == MidiAlsaSeq::name() || client_name == "" ) { - MidiAlsaSeq * malsas = new MidiAlsaSeq; + auto malsas = new MidiAlsaSeq; if( malsas->isRunning() ) { m_midiClientName = MidiAlsaSeq::name(); @@ -1120,7 +1124,7 @@ MidiClient * AudioEngine::tryMidiClients() if( client_name == MidiAlsaRaw::name() || client_name == "" ) { - MidiAlsaRaw * malsar = new MidiAlsaRaw; + auto malsar = new MidiAlsaRaw; if( malsar->isRunning() ) { m_midiClientName = MidiAlsaRaw::name(); @@ -1133,7 +1137,7 @@ MidiClient * AudioEngine::tryMidiClients() #ifdef LMMS_HAVE_JACK if( client_name == MidiJack::name() || client_name == "" ) { - MidiJack * mjack = new MidiJack; + auto mjack = new MidiJack; if( mjack->isRunning() ) { m_midiClientName = MidiJack::name(); @@ -1146,7 +1150,7 @@ MidiClient * AudioEngine::tryMidiClients() #ifdef LMMS_HAVE_OSS if( client_name == MidiOss::name() || client_name == "" ) { - MidiOss * moss = new MidiOss; + auto moss = new MidiOss; if( moss->isRunning() ) { m_midiClientName = MidiOss::name(); @@ -1257,7 +1261,7 @@ void AudioEngine::fifoWriter::run() const fpp_t frames = m_audioEngine->framesPerPeriod(); while( m_writing ) { - surroundSampleFrame * buffer = new surroundSampleFrame[frames]; + auto buffer = new surroundSampleFrame[frames]; const surroundSampleFrame * b = m_audioEngine->renderNextBuffer(); memcpy( buffer, b, frames * sizeof( surroundSampleFrame ) ); write( buffer ); @@ -1284,3 +1288,5 @@ void AudioEngine::fifoWriter::write( surroundSampleFrame * buffer ) m_audioEngine->m_waitingForWrite = false; m_audioEngine->m_doChangesMutex.unlock(); } + +} // namespace lmms diff --git a/src/core/AudioEngineProfiler.cpp b/src/core/AudioEngineProfiler.cpp index 837894c79..5fd5a813c 100644 --- a/src/core/AudioEngineProfiler.cpp +++ b/src/core/AudioEngineProfiler.cpp @@ -24,6 +24,8 @@ #include "AudioEngineProfiler.h" +namespace lmms +{ AudioEngineProfiler::AudioEngineProfiler() : m_periodTimer(), @@ -34,11 +36,6 @@ AudioEngineProfiler::AudioEngineProfiler() : -AudioEngineProfiler::~AudioEngineProfiler() -{ -} - - void AudioEngineProfiler::finishPeriod( sample_rate_t sampleRate, fpp_t framesPerPeriod ) { int periodElapsed = m_periodTimer.elapsed(); @@ -61,3 +58,4 @@ void AudioEngineProfiler::setOutputFile( const QString& outputFile ) m_outputFile.open( QFile::WriteOnly | QFile::Truncate ); } +} // namespace lmms diff --git a/src/core/AudioEngineWorkerThread.cpp b/src/core/AudioEngineWorkerThread.cpp index 3d45cbccb..129b3accf 100644 --- a/src/core/AudioEngineWorkerThread.cpp +++ b/src/core/AudioEngineWorkerThread.cpp @@ -37,6 +37,9 @@ #include #endif +namespace lmms +{ + AudioEngineWorkerThread::JobQueue AudioEngineWorkerThread::globalJobQueue; QWaitCondition * AudioEngineWorkerThread::queueReadyWaitCond = nullptr; QList AudioEngineWorkerThread::workerThreads; @@ -177,4 +180,4 @@ void AudioEngineWorkerThread::run() } } - +} // namespace lmms diff --git a/src/core/AutomatableModel.cpp b/src/core/AutomatableModel.cpp index 51733936f..378ccd91e 100644 --- a/src/core/AutomatableModel.cpp +++ b/src/core/AutomatableModel.cpp @@ -33,6 +33,9 @@ #include "ProjectJournal.h" #include "Song.h" +namespace lmms +{ + long AutomatableModel::s_periodCounter = 0; @@ -302,13 +305,13 @@ void AutomatableModel::setValue( const float value ) addJournalCheckPoint(); // notify linked models - for( AutoModelVector::Iterator it = m_linkedModels.begin(); it != m_linkedModels.end(); ++it ) + for (const auto& linkedModel : m_linkedModels) { - if( (*it)->m_setValueDepth < 1 && (*it)->fittedValue( value ) != (*it)->m_value ) + if (linkedModel->m_setValueDepth < 1 && linkedModel->fittedValue(value) != linkedModel->m_value) { - bool journalling = (*it)->testAndSetJournalling( isJournalling() ); - (*it)->setValue( value ); - (*it)->setJournalling( journalling ); + bool journalling = linkedModel->testAndSetJournalling(isJournalling()); + linkedModel->setValue(value); + linkedModel->setJournalling(journalling); } } m_valueChanged = true; @@ -326,7 +329,7 @@ void AutomatableModel::setValue( const float value ) template T AutomatableModel::logToLinearScale( T value ) const { - return castValue( ::logToLinearScale( minValue(), maxValue(), static_cast( value ) ) ); + return castValue( lmms::logToLinearScale( minValue(), maxValue(), static_cast( value ) ) ); } @@ -342,7 +345,7 @@ float AutomatableModel::inverseScaledValue( float value ) const { return m_scaleType == Linear ? value - : ::linearToLogScale( minValue(), maxValue(), value ); + : lmms::linearToLogScale( minValue(), maxValue(), value ); } @@ -364,7 +367,7 @@ void roundAt( T& value, const T& where, const T& step_size ) template void AutomatableModel::roundAt( T& value, const T& where ) const { - ::roundAt(value, where, m_step); + lmms::roundAt(value, where, m_step); } @@ -385,13 +388,12 @@ void AutomatableModel::setAutomatedValue( const float value ) if( oldValue != m_value ) { // notify linked models - for (AutoModelVector::Iterator it = m_linkedModels.begin(); - it != m_linkedModels.end(); ++it) + for (const auto& linkedModel : m_linkedModels) { - if (!((*it)->controllerConnection()) && (*it)->m_setValueDepth < 1 && - (*it)->fittedValue(m_value) != (*it)->m_value) + if (!(linkedModel->controllerConnection()) && linkedModel->m_setValueDepth < 1 && + linkedModel->fittedValue(m_value) != linkedModel->m_value) { - (*it)->setAutomatedValue(value); + linkedModel->setAutomatedValue(value); } } m_valueChanged = true; @@ -477,8 +479,8 @@ void AutomatableModel::linkModel( AutomatableModel* model ) if( !model->hasLinkedModels() ) { - QObject::connect( this, SIGNAL( dataChanged() ), - model, SIGNAL( dataChanged() ), Qt::DirectConnection ); + QObject::connect( this, SIGNAL(dataChanged()), + model, SIGNAL(dataChanged()), Qt::DirectConnection ); } } } @@ -549,9 +551,9 @@ void AutomatableModel::setControllerConnection( ControllerConnection* c ) m_controllerConnection = c; if( c ) { - QObject::connect( m_controllerConnection, SIGNAL( valueChanged() ), - this, SIGNAL( dataChanged() ), Qt::DirectConnection ); - QObject::connect( m_controllerConnection, SIGNAL( destroyed() ), this, SLOT( unlinkControllerConnection() ) ); + QObject::connect( m_controllerConnection, SIGNAL(valueChanged()), + this, SIGNAL(dataChanged()), Qt::DirectConnection ); + QObject::connect( m_controllerConnection, SIGNAL(destroyed()), this, SLOT(unlinkControllerConnection())); m_valueChanged = true; emit dataChanged(); } @@ -730,11 +732,11 @@ float AutomatableModel::globalAutomationValueAt( const TimePos& time ) // of those clips: // find the clips which overlap with the time position QVector clipsInRange; - for( QVector::ConstIterator it = clips.begin(); it != clips.end(); it++ ) + for (const auto& clip : clips) { - int s = ( *it )->startPosition(); - int e = ( *it )->endPosition(); - if( s <= time && e >= time ) { clipsInRange += ( *it ); } + int s = clip->startPosition(); + int e = clip->endPosition(); + if (s <= time && e >= time) { clipsInRange += clip; } } AutomationClip * latestClip = nullptr; @@ -750,13 +752,13 @@ float AutomatableModel::globalAutomationValueAt( const TimePos& time ) { int latestPosition = 0; - for( QVector::ConstIterator it = clips.begin(); it != clips.end(); it++ ) + for (const auto& clip : clips) { - int e = ( *it )->endPosition(); - if( e <= time && e > latestPosition ) + int e = clip->endPosition(); + if (e <= time && e > latestPosition) { latestPosition = e; - latestClip = ( *it ); + latestClip = clip; } } } @@ -798,7 +800,7 @@ float FloatModel::getRoundedValue() const int FloatModel::getDigitCount() const { - float steptemp = step(); + auto steptemp = step(); int digits = 0; while ( steptemp < 1 ) { @@ -824,3 +826,6 @@ QString BoolModel::displayValue( const float val ) const { return QString::number( castValue( scaledValue( val ) ) ); } + + +} // namespace lmms \ No newline at end of file diff --git a/src/core/AutomationClip.cpp b/src/core/AutomationClip.cpp index 300944416..fb2d7dbb0 100644 --- a/src/core/AutomationClip.cpp +++ b/src/core/AutomationClip.cpp @@ -37,6 +37,9 @@ #include +namespace lmms +{ + int AutomationClip::s_quantization = 1; const float AutomationClip::DEFAULT_MIN_VALUE = 0; const float AutomationClip::DEFAULT_MAX_VALUE = 1; @@ -44,7 +47,9 @@ const float AutomationClip::DEFAULT_MAX_VALUE = 1; AutomationClip::AutomationClip( AutomationTrack * _auto_track ) : Clip( _auto_track ), +#if (QT_VERSION < QT_VERSION_CHECK(5,14,0)) m_clipMutex(QMutex::Recursive), +#endif m_autoTrack( _auto_track ), m_objects(), m_tension( 1.0 ), @@ -76,7 +81,9 @@ AutomationClip::AutomationClip( AutomationTrack * _auto_track ) : AutomationClip::AutomationClip( const AutomationClip & _clip_to_copy ) : Clip( _clip_to_copy.m_autoTrack ), +#if (QT_VERSION < QT_VERSION_CHECK(5,14,0)) m_clipMutex(QMutex::Recursive), +#endif m_autoTrack( _clip_to_copy.m_autoTrack ), m_objects( _clip_to_copy.m_objects ), m_tension( _clip_to_copy.m_tension ), @@ -127,8 +134,8 @@ bool AutomationClip::addObject( AutomatableModel * _obj, bool _search_dup ) m_objects += _obj; - connect( _obj, SIGNAL( destroyed( jo_id_t ) ), - this, SLOT( objectDestroyed( jo_id_t ) ), + connect( _obj, SIGNAL(destroyed(lmms::jo_id_t)), + this, SLOT(objectDestroyed(lmms::jo_id_t)), Qt::DirectConnection ); emit dataChanged(); @@ -204,7 +211,7 @@ TimePos AutomationClip::timeMapLength() const if (m_timeMap.isEmpty()) { return one_bar; } timeMap::const_iterator it = m_timeMap.end(); - tick_t last_tick = static_cast(POS(it - 1)); + auto last_tick = static_cast(POS(it - 1)); // if last_tick is 0 (single item at tick 0) // return length as a whole bar to prevent disappearing Clip if (last_tick == 0) { return one_bar; } @@ -367,8 +374,8 @@ void AutomationClip::removeNodes(const int tick0, const int tick1) return; } - TimePos start = TimePos(qMin(tick0, tick1)); - TimePos end = TimePos(qMax(tick0, tick1)); + auto start = TimePos(qMin(tick0, tick1)); + auto end = TimePos(qMax(tick0, tick1)); // Make a list of TimePos with nodes to be removed // because we can't simply remove the nodes from @@ -403,8 +410,8 @@ void AutomationClip::resetNodes(const int tick0, const int tick1) return; } - TimePos start = TimePos(qMin(tick0, tick1)); - TimePos end = TimePos(qMax(tick0, tick1)); + auto start = TimePos(qMin(tick0, tick1)); + auto end = TimePos(qMax(tick0, tick1)); for (auto it = m_timeMap.lowerBound(start), endIt = m_timeMap.upperBound(end); it != endIt; ++it) { @@ -603,7 +610,7 @@ float *AutomationClip::valuesAfter( const TimePos & _time ) const } int numValues = POS(v + 1) - POS(v); - float *ret = new float[numValues]; + auto ret = new float[numValues]; for( int i = 0; i < numValues; i++ ) { @@ -691,7 +698,7 @@ void AutomationClip::flipX(int length) // We swap the inValue and outValue when flipping horizontally tempValue = OUTVAL(it); tempOutValue = INVAL(it); - TimePos newTime = TimePos(length - POS(it)); + auto newTime = TimePos(length - POS(it)); tempMap[newTime] = AutomationNode(this, tempValue, tempOutValue, newTime); @@ -733,7 +740,7 @@ void AutomationClip::flipX(int length) tempValue = OUTVAL(it); tempOutValue = INVAL(it); - TimePos newTime = TimePos(realLength - POS(it)); + auto newTime = TimePos(realLength - POS(it)); tempMap[newTime] = AutomationNode(this, tempValue, tempOutValue, newTime); ++it; @@ -779,15 +786,13 @@ void AutomationClip::saveSettings( QDomDocument & _doc, QDomElement & _this ) _this.appendChild( element ); } - for( objectVector::const_iterator it = m_objects.begin(); - it != m_objects.end(); ++it ) + for (const auto& object : m_objects) { - if( *it ) + if (object) { QDomElement element = _doc.createElement( "object" ); - element.setAttribute( "id", - ProjectJournal::idToSave( ( *it )->id() ) ); - _this.appendChild( element ); + element.setAttribute("id", ProjectJournal::idToSave(object->id())); + _this.appendChild(element); } } } @@ -870,11 +875,11 @@ const QString AutomationClip::name() const -ClipView * AutomationClip::createView( TrackView * _tv ) +gui::ClipView * AutomationClip::createView( gui::TrackView * _tv ) { QMutexLocker m(&m_clipMutex); - return new AutomationClipView( this, _tv ); + return new gui::AutomationClipView( this, _tv ); } @@ -888,20 +893,18 @@ bool AutomationClip::isAutomated( const AutomatableModel * _m ) l += Engine::patternStore()->tracks(); l += Engine::getSong()->globalAutomationTrack(); - for( TrackContainer::TrackList::ConstIterator it = l.begin(); it != l.end(); ++it ) + for (const auto& track : l) { - if( ( *it )->type() == Track::AutomationTrack || - ( *it )->type() == Track::HiddenAutomationTrack ) + if (track->type() == Track::AutomationTrack || track->type() == Track::HiddenAutomationTrack) { - const Track::clipVector & v = ( *it )->getClips(); - for( Track::clipVector::ConstIterator j = v.begin(); j != v.end(); ++j ) + for (const auto& clip : track->getClips()) { - const AutomationClip * a = dynamic_cast( *j ); + const auto a = dynamic_cast(clip); if( a && a->hasAutomation() ) { - for( objectVector::const_iterator k = a->m_objects.begin(); k != a->m_objects.end(); ++k ) + for (const auto& object : a->m_objects) { - if( *k == _m ) + if (object == _m) { return true; } @@ -920,34 +923,31 @@ bool AutomationClip::isAutomated( const AutomatableModel * _m ) */ QVector AutomationClip::clipsForModel( const AutomatableModel * _m ) { - QVector clips; - TrackContainer::TrackList l; - l += Engine::getSong()->tracks(); - l += Engine::patternStore()->tracks(); - l += Engine::getSong()->globalAutomationTrack(); + QVector clips; + TrackContainer::TrackList tracks; + tracks += Engine::getSong()->tracks(); + tracks += Engine::patternStore()->tracks(); + tracks += Engine::getSong()->globalAutomationTrack(); // go through all tracks... - for( TrackContainer::TrackList::ConstIterator it = l.begin(); it != l.end(); ++it ) + for (const auto& track : tracks) { // we want only automation tracks... - if( ( *it )->type() == Track::AutomationTrack || - ( *it )->type() == Track::HiddenAutomationTrack ) + if (track->type() == Track::AutomationTrack || track->type() == Track::HiddenAutomationTrack ) { - // get clips in those tracks.... - const Track::clipVector & v = ( *it )->getClips(); // go through all the clips... - for( Track::clipVector::ConstIterator j = v.begin(); j != v.end(); ++j ) + for (const auto& trackClip : track->getClips()) { - AutomationClip * a = dynamic_cast( *j ); + auto a = dynamic_cast(trackClip); // check that the clip has automation if( a && a->hasAutomation() ) { // now check is the clip is connected to the model we want by going through all the connections // of the clip bool has_object = false; - for( objectVector::const_iterator k = a->m_objects.begin(); k != a->m_objects.end(); ++k ) + for (const auto& object : a->m_objects) { - if( *k == _m ) + if (object == _m) { has_object = true; } @@ -967,24 +967,19 @@ AutomationClip * AutomationClip::globalAutomationClip( AutomatableModel * _m ) { AutomationTrack * t = Engine::getSong()->globalAutomationTrack(); - Track::clipVector v = t->getClips(); - for( Track::clipVector::const_iterator j = v.begin(); j != v.end(); ++j ) + for (const auto& clip : t->getClips()) { - AutomationClip * a = dynamic_cast( *j ); + auto a = dynamic_cast(clip); if( a ) { - for( objectVector::const_iterator k = a->m_objects.begin(); - k != a->m_objects.end(); ++k ) + for (const auto& object : a->m_objects) { - if( *k == _m ) - { - return a; - } + if (object == _m) { return a; } } } } - AutomationClip * a = new AutomationClip( t ); + auto a = new AutomationClip(t); a->addObject( _m, false ); return a; } @@ -997,24 +992,18 @@ void AutomationClip::resolveAllIDs() TrackContainer::TrackList l = Engine::getSong()->tracks() + Engine::patternStore()->tracks(); l += Engine::getSong()->globalAutomationTrack(); - for( TrackContainer::TrackList::iterator it = l.begin(); - it != l.end(); ++it ) + for (const auto& track : l) { - if( ( *it )->type() == Track::AutomationTrack || - ( *it )->type() == Track::HiddenAutomationTrack ) + if (track->type() == Track::AutomationTrack || track->type() == Track::HiddenAutomationTrack) { - Track::clipVector v = ( *it )->getClips(); - for( Track::clipVector::iterator j = v.begin(); - j != v.end(); ++j ) + for (const auto& clip : track->getClips()) { - AutomationClip * a = dynamic_cast( *j ); + auto a = dynamic_cast(clip); if( a ) { - for( QVector::Iterator k = a->m_idsToResolve.begin(); - k != a->m_idsToResolve.end(); ++k ) + for (const auto& id : a->m_idsToResolve) { - JournallingObject * o = Engine::projectJournal()-> - journallingObject( *k ); + JournallingObject* o = Engine::projectJournal()->journallingObject(id); if( o && dynamic_cast( o ) ) { a->addObject( dynamic_cast( o ), false ); @@ -1023,7 +1012,7 @@ void AutomationClip::resolveAllIDs() { // FIXME: Remove this block once the automation system gets fixed // This is a temporary fix for https://github.com/LMMS/lmms/issues/3781 - o = Engine::projectJournal()->journallingObject(ProjectJournal::idFromSave(*k)); + o = Engine::projectJournal()->journallingObject(ProjectJournal::idFromSave(id)); if( o && dynamic_cast( o ) ) { a->addObject( dynamic_cast( o ), false ); @@ -1032,7 +1021,7 @@ void AutomationClip::resolveAllIDs() { // FIXME: Remove this block once the automation system gets fixed // This is a temporary fix for https://github.com/LMMS/lmms/issues/4781 - o = Engine::projectJournal()->journallingObject(ProjectJournal::idToSave(*k)); + o = Engine::projectJournal()->journallingObject(ProjectJournal::idToSave(id)); if( o && dynamic_cast( o ) ) { a->addObject( dynamic_cast( o ), false ); @@ -1183,3 +1172,5 @@ void AutomationClip::generateTangents(timeMap::iterator it, int numToGenerate) it++; } } + +} // namespace lmms \ No newline at end of file diff --git a/src/core/AutomationNode.cpp b/src/core/AutomationNode.cpp index a2906b0d0..eee4df8d2 100644 --- a/src/core/AutomationNode.cpp +++ b/src/core/AutomationNode.cpp @@ -27,6 +27,9 @@ #include "AutomationClip.h" +namespace lmms +{ + // Dummy constructor for the QMap AutomationNode::AutomationNode() : m_clip(nullptr), @@ -107,3 +110,5 @@ void AutomationNode::resetOutValue() // the tangents setOutValue(m_inValue); } + +} // namespace lmms \ No newline at end of file diff --git a/src/core/BandLimitedWave.cpp b/src/core/BandLimitedWave.cpp index 0f83badcf..a7dd650c0 100644 --- a/src/core/BandLimitedWave.cpp +++ b/src/core/BandLimitedWave.cpp @@ -27,7 +27,10 @@ #include -WaveMipMap BandLimitedWave::s_waveforms[4] = { }; +namespace lmms +{ + +std::array BandLimitedWave::s_waveforms = { }; bool BandLimitedWave::s_wavesGenerated = false; QString BandLimitedWave::s_wavetableDir = ""; @@ -270,3 +273,5 @@ moogfile.close(); */ } + +} // namespace lmms \ No newline at end of file diff --git a/src/core/BufferManager.cpp b/src/core/BufferManager.cpp index 248434cf9..ff35e6a19 100644 --- a/src/core/BufferManager.cpp +++ b/src/core/BufferManager.cpp @@ -30,17 +30,20 @@ #include "MemoryManager.h" -static fpp_t framesPerPeriod; - -void BufferManager::init( fpp_t framesPerPeriod ) +namespace lmms { - ::framesPerPeriod = framesPerPeriod; + +fpp_t BufferManager::s_framesPerPeriod; + +void BufferManager::init( fpp_t fpp ) +{ + s_framesPerPeriod = fpp; } sampleFrame * BufferManager::acquire() { - return MM_ALLOC( ::framesPerPeriod ); + return MM_ALLOC( s_framesPerPeriod ); } void BufferManager::clear( sampleFrame *ab, const f_cnt_t frames, const f_cnt_t offset ) @@ -62,3 +65,4 @@ void BufferManager::release( sampleFrame * buf ) MM_FREE( buf ); } +} // namespace lmms diff --git a/src/core/Clip.cpp b/src/core/Clip.cpp index f247b967e..74a168fbd 100644 --- a/src/core/Clip.cpp +++ b/src/core/Clip.cpp @@ -33,6 +33,9 @@ #include "Song.h" +namespace lmms +{ + /*! \brief Create a new Clip * * Creates a new clip for the given track. @@ -145,7 +148,7 @@ void Clip::copyStateTo( Clip *src, Clip *dst ) dst->movePosition( pos ); AutomationClip::resolveAllIDs(); - GuiApplication::instance()->automationEditor()->m_editor->updateAfterClipChange(); + gui::getGUI()->automationEditor()->m_editor->updateAfterClipChange(); } } @@ -197,3 +200,4 @@ bool Clip::hasColor() return usesCustomClipColor() || getTrack()->useColor(); } +} // namespace lmms diff --git a/src/core/Clipboard.cpp b/src/core/Clipboard.cpp index c30b657bb..1dd78f69c 100644 --- a/src/core/Clipboard.cpp +++ b/src/core/Clipboard.cpp @@ -29,8 +29,9 @@ #include "Clipboard.h" -namespace Clipboard +namespace lmms::Clipboard { + const QMimeData * getMimeData() { return QApplication::clipboard()->mimeData( QClipboard::Clipboard ); @@ -49,7 +50,7 @@ namespace Clipboard void copyString( const QString & str, MimeType mT ) { - QMimeData *content = new QMimeData; + auto content = new QMimeData; content->setData( mimeType( mT ), str.toUtf8() ); QApplication::clipboard()->setMimeData( content, QClipboard::Clipboard ); @@ -70,7 +71,7 @@ namespace Clipboard { QString finalString = key + ":" + value; - QMimeData *content = new QMimeData; + auto content = new QMimeData; content->setData( mimeType( MimeType::StringPair ), finalString.toUtf8() ); QApplication::clipboard()->setMimeData( content, QClipboard::Clipboard ); } @@ -90,4 +91,6 @@ namespace Clipboard { return( QString::fromUtf8( mimeData->data( mimeType( MimeType::StringPair ) ) ).section( ':', 1, -1 ) ); } -} + + +} // namespace lmms::Clipboard diff --git a/src/core/ComboBoxModel.cpp b/src/core/ComboBoxModel.cpp index 19d4f576f..f1b1c6b2e 100644 --- a/src/core/ComboBoxModel.cpp +++ b/src/core/ComboBoxModel.cpp @@ -26,6 +26,9 @@ #include +namespace lmms +{ + using std::unique_ptr; using std::move; @@ -69,6 +72,6 @@ int ComboBoxModel::findText( const QString& txt ) const } - +} // namespace lmms diff --git a/src/core/ConfigManager.cpp b/src/core/ConfigManager.cpp index 5444ea834..bfe9e31f1 100644 --- a/src/core/ConfigManager.cpp +++ b/src/core/ConfigManager.cpp @@ -37,6 +37,9 @@ #include "lmmsversion.h" +namespace lmms +{ + // Vector with all the upgrade methods const std::vector ConfigManager::UPGRADE_METHODS = { @@ -336,13 +339,11 @@ const QString & ConfigManager::value(const QString & cls, { if(m_settings.contains(cls)) { - for(stringPairVector::const_iterator it = - m_settings[cls].begin(); - it != m_settings[cls].end(); ++it) + for (const auto& setting : m_settings[cls]) { - if((*it).first == attribute) + if (setting.first == attribute) { - return (*it).second ; + return setting.second; } } } @@ -514,10 +515,10 @@ void ConfigManager::loadConfigFile(const QString & configFile) #endif setBackgroundPicFile(value("paths", "backgroundtheme")); } - else if(getGUI() != nullptr) + else if (gui::getGUI() != nullptr) { - QMessageBox::warning(nullptr, MainWindow::tr("Configuration file"), - MainWindow::tr("Error while parsing configuration file at line %1:%2: %3"). + QMessageBox::warning(nullptr, gui::MainWindow::tr("Configuration file"), + gui::MainWindow::tr("Error while parsing configuration file at line %1:%2: %3"). arg(errorLine). arg(errorCol). arg(errorString)); @@ -563,7 +564,7 @@ void ConfigManager::loadConfigFile(const QString & configFile) } #endif } -#endif +#endif // LMMS_HAVE_STK upgrade(); @@ -606,25 +607,22 @@ void ConfigManager::saveConfigFile() lmms_config.setAttribute("configversion", m_configVersion); doc.appendChild(lmms_config); - for(settingsMap::iterator it = m_settings.begin(); - it != m_settings.end(); ++it) + for (auto it = m_settings.begin(); it != m_settings.end(); ++it) { QDomElement n = doc.createElement(it.key()); - for(stringPairVector::iterator it2 = (*it).begin(); - it2 != (*it).end(); ++it2) + for (const auto& [first, second] : *it) { - n.setAttribute((*it2).first, (*it2).second); + n.setAttribute(first, second); } lmms_config.appendChild(n); } QDomElement recent_files = doc.createElement("recentfiles"); - for(QStringList::iterator it = m_recentlyOpenedProjects.begin(); - it != m_recentlyOpenedProjects.end(); ++it) + for (const auto& recentlyOpenedProject : m_recentlyOpenedProjects) { QDomElement n = doc.createElement("file"); - n.setAttribute("path", *it); + n.setAttribute("path", recentlyOpenedProject); recent_files.appendChild(n); } lmms_config.appendChild(recent_files); @@ -634,6 +632,8 @@ void ConfigManager::saveConfigFile() QFile outfile(m_lmmsRcFile); if(!outfile.open(QIODevice::WriteOnly | QIODevice::Truncate)) { + using gui::MainWindow; + QString title, message; title = MainWindow::tr("Could not open file"); message = MainWindow::tr("Could not open file %1 " @@ -643,7 +643,7 @@ void ConfigManager::saveConfigFile() "the directory containing the " "file and try again!" ).arg(m_lmmsRcFile); - if(getGUI() != nullptr) + if (gui::getGUI() != nullptr) { QMessageBox::critical(nullptr, title, message, QMessageBox::Ok, @@ -734,3 +734,6 @@ unsigned int ConfigManager::legacyConfigVersion() return 2; } } + + +} // namespace lmms diff --git a/src/core/Controller.cpp b/src/core/Controller.cpp index 5cb3218a9..aee6481cc 100644 --- a/src/core/Controller.cpp +++ b/src/core/Controller.cpp @@ -35,6 +35,9 @@ #include "MidiController.h" #include "PeakController.h" +namespace lmms +{ + long Controller::s_periods = 0; QVector Controller::s_controllers; @@ -194,7 +197,7 @@ Controller * Controller::create( ControllerTypes _ct, Model * _parent ) break; case Controller::LfoController: - c = new ::LfoController( _parent ); + c = new class LfoController( _parent ); break; case Controller::PeakController: @@ -203,7 +206,7 @@ Controller * Controller::create( ControllerTypes _ct, Model * _parent ) break; case Controller::MidiController: - c = new ::MidiController( _parent ); + c = new class MidiController( _parent ); break; default: @@ -243,7 +246,7 @@ bool Controller::hasModel( const Model * m ) const { for (QObject * c : children()) { - AutomatableModel * am = qobject_cast(c); + auto am = qobject_cast(c); if( am != nullptr ) { if( am == m ) @@ -291,9 +294,9 @@ QString Controller::nodeName() const -ControllerDialog * Controller::createDialog( QWidget * _parent ) +gui::ControllerDialog * Controller::createDialog( QWidget * _parent ) { - ControllerDialog * d = new ControllerDialog( this, _parent ); + auto d = new gui::ControllerDialog(this, _parent); return d; } @@ -323,7 +326,7 @@ int Controller::connectionCount() const{ } - +} // namespace lmms diff --git a/src/core/ControllerConnection.cpp b/src/core/ControllerConnection.cpp index 03b054629..c65cd8ae9 100644 --- a/src/core/ControllerConnection.cpp +++ b/src/core/ControllerConnection.cpp @@ -31,6 +31,9 @@ #include "Song.h" #include "ControllerConnection.h" +namespace lmms +{ + ControllerConnectionVector ControllerConnection::s_connections; @@ -116,8 +119,8 @@ void ControllerConnection::setController( Controller * _controller ) if( _controller->type() != Controller::DummyController ) { _controller->addConnection( this ); - QObject::connect( _controller, SIGNAL( valueChanged() ), - this, SIGNAL( valueChanged() ), Qt::DirectConnection ); + QObject::connect( _controller, SIGNAL(valueChanged()), + this, SIGNAL(valueChanged()), Qt::DirectConnection ); } m_ownsController = @@ -126,8 +129,8 @@ void ControllerConnection::setController( Controller * _controller ) // If we don't own the controller, allow deletion of controller // to delete the connection if( !m_ownsController ) { - QObject::connect( _controller, SIGNAL( destroyed() ), - this, SLOT( deleteConnection() ) ); + QObject::connect( _controller, SIGNAL(destroyed()), + this, SLOT(deleteConnection())); } } @@ -233,4 +236,4 @@ void ControllerConnection::deleteConnection() - +} // namespace lmms diff --git a/src/core/DataFile.cpp b/src/core/DataFile.cpp index 2fe9b88d9..2e7b21e8b 100644 --- a/src/core/DataFile.cpp +++ b/src/core/DataFile.cpp @@ -50,6 +50,10 @@ #include "lmmsversion.h" +namespace lmms +{ + + static void findIds(const QDomElement& elem, QList& idList); @@ -85,19 +89,27 @@ const std::vector DataFile::UPGRADE_VERSIONS = { "1.2.0-rc3" , "1.3.0" }; -DataFile::typeDescStruct - DataFile::s_types[DataFile::TypeCount] = +namespace { - { DataFile::UnknownType, "unknown" }, - { DataFile::SongProject, "song" }, - { DataFile::SongProjectTemplate, "songtemplate" }, - { DataFile::InstrumentTrackSettings, "instrumenttracksettings" }, - { DataFile::DragNDropData, "dnddata" }, - { DataFile::ClipboardData, "clipboard-data" }, - { DataFile::JournalData, "journaldata" }, - { DataFile::EffectSettings, "effectsettings" }, - { DataFile::MidiClip, "midiclip" } -} ; + struct TypeDescStruct + { + DataFile::Type m_type; + QString m_name; + }; + + const auto s_types = std::array + { + TypeDescStruct{ DataFile::UnknownType, "unknown" }, + TypeDescStruct{ DataFile::SongProject, "song" }, + TypeDescStruct{ DataFile::SongProjectTemplate, "songtemplate" }, + TypeDescStruct{ DataFile::InstrumentTrackSettings, "instrumenttracksettings" }, + TypeDescStruct{ DataFile::DragNDropData, "dnddata" }, + TypeDescStruct{ DataFile::ClipboardData, "clipboard-data" }, + TypeDescStruct{ DataFile::JournalData, "journaldata" }, + TypeDescStruct{ DataFile::EffectSettings, "effectsettings" }, + TypeDescStruct{ DataFile::MidiClip, "midiclip" } + }; +} @@ -139,11 +151,11 @@ DataFile::DataFile( const QString & _fileName ) : QFile inFile( _fileName ); if( !inFile.open( QIODevice::ReadOnly ) ) { - if( getGUI() != nullptr ) + if (gui::getGUI() != nullptr) { QMessageBox::critical( nullptr, - SongEditor::tr( "Could not open file" ), - SongEditor::tr( "Could not open file %1. You probably " + gui::SongEditor::tr( "Could not open file" ), + gui::SongEditor::tr( "Could not open file %1. You probably " "have no permissions to read this " "file.\n Please make sure to have at " "least read permissions to the file " @@ -172,12 +184,6 @@ DataFile::DataFile( const QByteArray & _data ) : -DataFile::~DataFile() -{ -} - - - bool DataFile::validate( QString extension ) { @@ -295,7 +301,7 @@ bool DataFile::writeFile(const QString& filename, bool withResources) { // Small lambda function for displaying errors auto showError = [this](QString title, QString body){ - if (getGUI() != nullptr) + if (gui::getGUI() != nullptr) { QMessageBox mb; mb.setWindowTitle(title); @@ -325,6 +331,8 @@ bool DataFile::writeFile(const QString& filename, bool withResources) const QString fullNameTemp = fullName + ".new"; const QString fullNameBak = fullName + ".bak"; + using gui::SongEditor; + // If we are saving with resources, setup the bundle folder first if (withResources) { @@ -427,7 +435,7 @@ bool DataFile::copyResources(const QString& resourcesDir) // repeating filenames std::list namesList; - ResourcesMap::const_iterator it = ELEMENTS_WITH_RESOURCES.begin(); + auto it = ELEMENTS_WITH_RESOURCES.begin(); // Copy resources and manipulate the DataFile to have local paths to them while (it != ELEMENTS_WITH_RESOURCES.end()) @@ -439,7 +447,7 @@ bool DataFile::copyResources(const QString& resourcesDir) { QDomElement el = list.item(i).toElement(); - std::vector::const_iterator res = it->second.begin(); + auto res = it->second.begin(); // Search for attributes that point to resources while (res != it->second.end()) @@ -533,14 +541,9 @@ bool DataFile::hasLocalPlugins(QDomElement parent /* = QDomElement()*/, bool fir bool skipNode = false; // Skip the nodes allowed to have "local:" attributes, but // still check its children - for - ( - ResourcesMap::const_iterator it = ELEMENTS_WITH_RESOURCES.begin(); - it != ELEMENTS_WITH_RESOURCES.end(); - ++it - ) + for (const auto& element : ELEMENTS_WITH_RESOURCES) { - if (childElement.tagName() == it->first) + if (childElement.tagName() == element.first) { skipNode = true; break; @@ -1319,44 +1322,32 @@ void DataFile::upgrade_1_3_0() // Effect name changes QDomElement attribute = attributes.item( k ).toElement(); - if( attribute.attribute( "name" ) == "file" && - ( attribute.attribute( "value" ) == "calf" || - attribute.attribute( "value" ) == "calf.so" ) ) + const QString attrName = attribute.attribute("name"); + const QString attrVal = attribute.attribute("value"); + const QString plugin = attrName == "plugin" ? attrVal : ""; + + static const std::map pluginNames = { + {"Sidechaincompressor", "SidechainCompressor"}, + {"Sidechaingate", "SidechainGate"}, + {"Multibandcompressor", "MultibandCompressor"}, + {"Multibandgate", "MultibandGate"}, + {"Multibandlimiter", "MultibandLimiter"}, + }; + + if (attrName == "file" && (attrVal == "calf" || attrVal == "calf.so" )) { attribute.setAttribute( "value", "veal" ); } - else if( attribute.attribute( "name" ) == "plugin" && - attribute.attribute( "value" ) == "Sidechaincompressor" ) + + const auto newName = pluginNames.find(plugin); + if (newName != pluginNames.end()) { - attribute.setAttribute( "value", "SidechainCompressor" ); - } - else if( attribute.attribute( "name" ) == "plugin" && - attribute.attribute( "value" ) == "Sidechaingate" ) - { - attribute.setAttribute( "value", "SidechainGate" ); - } - else if( attribute.attribute( "name" ) == "plugin" && - attribute.attribute( "value" ) == "Multibandcompressor" ) - { - attribute.setAttribute( "value", "MultibandCompressor" ); - } - else if( attribute.attribute( "name" ) == "plugin" && - attribute.attribute( "value" ) == "Multibandgate" ) - { - attribute.setAttribute( "value", "MultibandGate" ); - } - else if( attribute.attribute( "name" ) == "plugin" && - attribute.attribute( "value" ) == "Multibandlimiter" ) - { - attribute.setAttribute( "value", "MultibandLimiter" ); + attribute.setAttribute("value", newName->second); } // Handle port changes - if( attribute.attribute( "name" ) == "plugin" && - ( attribute.attribute( "value" ) == "MultibandLimiter" || - attribute.attribute( "value" ) == "MultibandCompressor" || - attribute.attribute( "value" ) == "MultibandGate" ) ) + if (plugin == "MultibandLimiter" || plugin == "MultibandCompressor" || plugin == "MultibandGate") { auto fn = [&](QDomElement& port, int num, QList&, QList& removeList) { @@ -1377,8 +1368,7 @@ void DataFile::upgrade_1_3_0() iterate_ladspa_ports(effect, fn); } - if( attribute.attribute( "name" ) == "plugin" && - ( attribute.attribute( "value" ) == "Pulsator" ) ) + else if (plugin == "Pulsator") { auto fn = [&](QDomElement& port, int num, QList& addList, QList& removeList) { @@ -1421,9 +1411,7 @@ void DataFile::upgrade_1_3_0() iterate_ladspa_ports(effect, fn); } - - if( attribute.attribute( "name" ) == "plugin" && - ( attribute.attribute( "value" ) == "VintageDelay" ) ) + else if (plugin == "VintageDelay") { auto fn = [&](QDomElement& port, int num, QList& addList, QList& ) { @@ -1460,23 +1448,20 @@ void DataFile::upgrade_1_3_0() iterate_ladspa_ports(effect, fn); } - if( attribute.attribute( "name" ) == "plugin" && - ( ( attribute.attribute( "value" ) == "Equalizer5Band" ) - || ( attribute.attribute( "value" ) == "Equalizer8Band" ) - || ( attribute.attribute( "value" ) == "Equalizer12Band" ) ) ) + else if (plugin == "Equalizer5Band" || plugin == "Equalizer8Band" || plugin == "Equalizer12Band") { // NBand equalizers got 4 q nobs inserted. We need to shift everything else... // HOWEVER: 5 band eq has only 2 q nobs inserted (no LS/HS filters) - bool band5 = ( attribute.attribute( "value" ) == "Equalizer5Band" ); + bool band5 = plugin == "Equalizer5Band"; auto fn = [&](QDomElement& port, int num, QList& addList, QList& ) { if(num == 4) { // don't modify port 4, but some other ones: int zoom_port; - if(attribute.attribute( "value" ) == "Equalizer5Band") + if (plugin == "Equalizer5Band") zoom_port = 36; - else if(attribute.attribute( "value" ) == "Equalizer8Band") + else if (plugin == "Equalizer8Band") zoom_port = 48; else // 12 band zoom_port = 64; @@ -1557,8 +1542,7 @@ void DataFile::upgrade_1_3_0() iterate_ladspa_ports(effect, fn); } - if( attribute.attribute( "name" ) == "plugin" && - attribute.attribute( "value" ) == "Saturator" ) + else if (plugin == "Saturator") { auto fn = [&](QDomElement& port, int num, QList&, QList& ) { @@ -1585,8 +1569,7 @@ void DataFile::upgrade_1_3_0() iterate_ladspa_ports(effect, fn); } - if( attribute.attribute( "name" ) == "plugin" && - attribute.attribute( "value" ) == "StereoTools" ) + else if (plugin == "StereoTools") { auto fn = [&](QDomElement& port, int num, QList&, QList& ) { @@ -1602,6 +1585,29 @@ void DataFile::upgrade_1_3_0() }; iterate_ladspa_ports(effect, fn); } + + else if (plugin == "amPitchshift") + { + auto fn = [&](QDomElement& port, int num, QList&, QList& removeList) + { + switch (num) + { + case 0: + port.setTagName("port01"); + break; + case 1: + port.setTagName("port03"); + break; + case 10: + port.setTagName("port11"); + break; + case 11: + port.setTagName("port13"); + break; + } + }; + iterate_ladspa_ports(effect, fn); + } } } } @@ -1884,8 +1890,10 @@ void DataFile::loadData( const QByteArray & _data, const QString & _sourceFile ) } if( line >= 0 && col >= 0 ) { + using gui::SongEditor; + qWarning() << "at line" << line << "column" << errorMsg; - if( getGUI() != nullptr ) + if (gui::getGUI() != nullptr) { QMessageBox::critical( nullptr, SongEditor::tr( "Error in file" ), @@ -1918,18 +1926,20 @@ void DataFile::loadData( const QByteArray & _data, const QString & _sourceFile ) if (root.hasAttribute("creatorversion")) { + using gui::SongEditor; + // compareType defaults to All, so it doesn't have to be set here ProjectVersion createdWith = root.attribute("creatorversion"); ProjectVersion openedWith = LMMS_VERSION; if (createdWith.setCompareType(ProjectVersion::Minor) != openedWith.setCompareType(ProjectVersion::Minor) - && getGUI() != nullptr && root.attribute("type") == "song" + && gui::getGUI() != nullptr && root.attribute("type") == "song" ){ auto projectType = _sourceFile.endsWith(".mpt") ? SongEditor::tr("template") : SongEditor::tr("project"); - TextFloat::displayMessage( + gui::TextFloat::displayMessage( SongEditor::tr("Version difference"), SongEditor::tr("This %1 was created with LMMS %2") .arg(projectType).arg(createdWith.getVersion()), @@ -1973,3 +1983,6 @@ unsigned int DataFile::legacyFileVersion() // Convert the iterator to an index, which is our file version (starting at 0) return std::distance( UPGRADE_VERSIONS.begin(), firstRequiredUpgrade ); } + + +} // namespace lmms diff --git a/src/core/DrumSynth.cpp b/src/core/DrumSynth.cpp index d4f9fe167..bc5455c96 100644 --- a/src/core/DrumSynth.cpp +++ b/src/core/DrumSynth.cpp @@ -37,7 +37,10 @@ #ifdef _MSC_VER //not #if LMMS_BUILD_WIN32 because we have strncasecmp in mingw #define strcasecmp _stricmp -#endif +#endif // _MSC_VER + +namespace lmms +{ using namespace std; @@ -64,7 +67,7 @@ long wavewords, wavemode=0; float mem_t=1.0f, mem_o=1.0f, mem_n=1.0f, mem_b=1.0f, mem_tune=1.0f, mem_time=1.0f; -int DrumSynth::LongestEnv(void) +int DrumSynth::LongestEnv() { long e, eon, p; float l=0.f; @@ -83,7 +86,7 @@ int DrumSynth::LongestEnv(void) } -float DrumSynth::LoudestEnv(void) +float DrumSynth::LoudestEnv() { float loudest=0.f; int i=0; @@ -741,3 +744,5 @@ int DrumSynth::GetDSFileSamples(QString dsfile, int16_t *&wave, int channels, sa return Length; } + +} // namespace lmms \ No newline at end of file diff --git a/src/core/Effect.cpp b/src/core/Effect.cpp index e730db5a5..151eaf13e 100644 --- a/src/core/Effect.cpp +++ b/src/core/Effect.cpp @@ -32,6 +32,9 @@ #include "ConfigManager.h" +namespace lmms +{ + Effect::Effect( const Plugin::Descriptor * _desc, Model * _parent, @@ -63,11 +66,11 @@ Effect::Effect( const Plugin::Descriptor * _desc, Effect::~Effect() { - for( int i = 0; i < 2; ++i ) + for (const auto& state : m_srcState) { - if( m_srcState[i] != nullptr ) + if (state != nullptr) { - src_delete( m_srcState[i] ); + src_delete(state); } } } @@ -121,7 +124,7 @@ Effect * Effect::instantiate( const QString& pluginName, if( dynamic_cast( p ) != nullptr ) { // everything ok, so return pointer - Effect * effect = dynamic_cast( p ); + auto effect = dynamic_cast(p); effect->m_parent = dynamic_cast(_parent); return effect; } @@ -162,9 +165,9 @@ void Effect::checkGate( double _out_sum ) -PluginView * Effect::instantiateView( QWidget * _parent ) +gui::PluginView * Effect::instantiateView( QWidget * _parent ) { - return new EffectView( this, _parent ); + return new gui::EffectView( this, _parent ); } @@ -172,17 +175,15 @@ PluginView * Effect::instantiateView( QWidget * _parent ) void Effect::reinitSRC() { - for( int i = 0; i < 2; ++i ) + for (auto& state : m_srcState) { - if( m_srcState[i] != nullptr ) + if (state != nullptr) { - src_delete( m_srcState[i] ); + src_delete(state); } int error; - if( ( m_srcState[i] = src_new( - Engine::audioEngine()->currentQualitySettings(). - libsrcInterpolation(), - DEFAULT_CHANNELS, &error ) ) == nullptr ) + const int currentInterpolation = Engine::audioEngine()->currentQualitySettings().libsrcInterpolation(); + if((state = src_new(currentInterpolation, DEFAULT_CHANNELS, &error)) == nullptr) { qFatal( "Error: src_new() failed in effect.cpp!\n" ); } @@ -215,3 +216,4 @@ void Effect::resample( int _i, const sampleFrame * _src_buf, } } +} // namespace lmms diff --git a/src/core/EffectChain.cpp b/src/core/EffectChain.cpp index 7b9b3b2db..024ddab64 100644 --- a/src/core/EffectChain.cpp +++ b/src/core/EffectChain.cpp @@ -31,6 +31,9 @@ #include "DummyEffect.h" #include "MixHelpers.h" +namespace lmms +{ + EffectChain::EffectChain( Model * _parent ) : Model( _parent ), @@ -57,10 +60,7 @@ void EffectChain::saveSettings( QDomDocument & _doc, QDomElement & _this ) for( Effect* effect : m_effects) { - if( DummyEffect* dummy = dynamic_cast(effect) ) - { - _this.appendChild( dummy->originalPluginData() ); - } + if (auto dummy = dynamic_cast(effect)) { _this.appendChild(dummy->originalPluginData()); } else { QDomElement ef = effect->saveState( _doc, _this ); @@ -191,12 +191,12 @@ bool EffectChain::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames, b MixHelpers::sanitize( _buf, _frames ); bool moreEffects = false; - for( EffectList::Iterator it = m_effects.begin(); it != m_effects.end(); ++it ) + for (const auto& effect : m_effects) { - if( hasInputNoise || ( *it )->isRunning() ) + if (hasInputNoise || effect->isRunning()) { - moreEffects |= ( *it )->processAudioBuffer( _buf, _frames ); - MixHelpers::sanitize( _buf, _frames ); + moreEffects |= effect->processAudioBuffer(_buf, _frames); + MixHelpers::sanitize(_buf, _frames); } } @@ -213,10 +213,9 @@ void EffectChain::startRunning() return; } - for( EffectList::Iterator it = m_effects.begin(); - it != m_effects.end(); it++ ) + for (const auto& effect : m_effects) { - ( *it )->startRunning(); + effect->startRunning(); } } @@ -240,3 +239,6 @@ void EffectChain::clear() m_enabledModel.setValue( false ); } + + +} // namespace lmms diff --git a/src/core/Engine.cpp b/src/core/Engine.cpp index a46590188..6c8104721 100644 --- a/src/core/Engine.cpp +++ b/src/core/Engine.cpp @@ -37,24 +37,27 @@ #include "BandLimitedWave.h" #include "Oscillator.h" -float LmmsCore::s_framesPerTick; -AudioEngine* LmmsCore::s_audioEngine = nullptr; -Mixer * LmmsCore::s_mixer = nullptr; -PatternStore * LmmsCore::s_patternStore = nullptr; -Song * LmmsCore::s_song = nullptr; -ProjectJournal * LmmsCore::s_projectJournal = nullptr; -#ifdef LMMS_HAVE_LV2 -Lv2Manager * LmmsCore::s_lv2Manager = nullptr; -#endif -Ladspa2LMMS * LmmsCore::s_ladspaManager = nullptr; -void* LmmsCore::s_dndPluginKey = nullptr; - - - - -void LmmsCore::init( bool renderOnly ) +namespace lmms { - LmmsCore *engine = inst(); + +float Engine::s_framesPerTick; +AudioEngine* Engine::s_audioEngine = nullptr; +Mixer * Engine::s_mixer = nullptr; +PatternStore * Engine::s_patternStore = nullptr; +Song * Engine::s_song = nullptr; +ProjectJournal * Engine::s_projectJournal = nullptr; +#ifdef LMMS_HAVE_LV2 +Lv2Manager * Engine::s_lv2Manager = nullptr; +#endif +Ladspa2LMMS * Engine::s_ladspaManager = nullptr; +void* Engine::s_dndPluginKey = nullptr; + + + + +void Engine::init( bool renderOnly ) +{ + Engine *engine = inst(); emit engine->initProgress(tr("Generating wavetables")); // generate (load from file) bandlimited wavetables @@ -89,7 +92,7 @@ void LmmsCore::init( bool renderOnly ) -void LmmsCore::destroy() +void Engine::destroy() { s_projectJournal->stopAllJournalling(); s_audioEngine->stopProcessing(); @@ -123,7 +126,7 @@ void LmmsCore::destroy() -bool LmmsCore::ignorePluginBlacklist() +bool Engine::ignorePluginBlacklist() { const char* envVar = getenv("LMMS_IGNORE_BLACKLIST"); return (envVar && *envVar); @@ -132,7 +135,7 @@ bool LmmsCore::ignorePluginBlacklist() -float LmmsCore::framesPerTick(sample_rate_t sampleRate) +float Engine::framesPerTick(sample_rate_t sampleRate) { return sampleRate * 60.0f * 4 / DefaultTicksPerBar / s_song->getTempo(); @@ -141,7 +144,7 @@ float LmmsCore::framesPerTick(sample_rate_t sampleRate) -void LmmsCore::updateFramesPerTick() +void Engine::updateFramesPerTick() { s_framesPerTick = s_audioEngine->processingSampleRate() * 60.0f * 4 / DefaultTicksPerBar / s_song->getTempo(); } @@ -149,7 +152,7 @@ void LmmsCore::updateFramesPerTick() -void LmmsCore::setDndPluginKey(void *newKey) +void Engine::setDndPluginKey(void *newKey) { Q_ASSERT(static_cast(newKey)); s_dndPluginKey = newKey; @@ -158,7 +161,7 @@ void LmmsCore::setDndPluginKey(void *newKey) -void *LmmsCore::pickDndPluginKey() +void *Engine::pickDndPluginKey() { return s_dndPluginKey; } @@ -166,4 +169,6 @@ void *LmmsCore::pickDndPluginKey() -LmmsCore * LmmsCore::s_instanceOfMe = nullptr; +Engine * Engine::s_instanceOfMe = nullptr; + +} // namespace lmms \ No newline at end of file diff --git a/src/core/EnvelopeAndLfoParameters.cpp b/src/core/EnvelopeAndLfoParameters.cpp index 7dc948e3b..2aa77e6aa 100644 --- a/src/core/EnvelopeAndLfoParameters.cpp +++ b/src/core/EnvelopeAndLfoParameters.cpp @@ -30,6 +30,9 @@ #include "Oscillator.h" +namespace lmms +{ + // how long should be each envelope-segment maximal (e.g. attack)? extern const float SECS_PER_ENV_SEGMENT = 5.0f; // how long should be one LFO-oscillation maximal? @@ -44,11 +47,10 @@ EnvelopeAndLfoParameters::LfoInstances * EnvelopeAndLfoParameters::s_lfoInstance void EnvelopeAndLfoParameters::LfoInstances::trigger() { QMutexLocker m( &m_lfoListMutex ); - for( LfoList::Iterator it = m_lfos.begin(); - it != m_lfos.end(); ++it ) + for (const auto& lfo : m_lfos) { - ( *it )->m_lfoFrame += Engine::audioEngine()->framesPerPeriod(); - ( *it )->m_bad_lfoShapeData = true; + lfo->m_lfoFrame += Engine::audioEngine()->framesPerPeriod(); + lfo->m_bad_lfoShapeData = true; } } @@ -58,11 +60,10 @@ void EnvelopeAndLfoParameters::LfoInstances::trigger() void EnvelopeAndLfoParameters::LfoInstances::reset() { QMutexLocker m( &m_lfoListMutex ); - for( LfoList::Iterator it = m_lfos.begin(); - it != m_lfos.end(); ++it ) + for (const auto& lfo : m_lfos) { - ( *it )->m_lfoFrame = 0; - ( *it )->m_bad_lfoShapeData = true; + lfo->m_lfoFrame = 0; + lfo->m_bad_lfoShapeData = true; } } @@ -129,36 +130,36 @@ EnvelopeAndLfoParameters::EnvelopeAndLfoParameters( instances()->add( this ); - connect( &m_predelayModel, SIGNAL( dataChanged() ), - this, SLOT( updateSampleVars() ), Qt::DirectConnection ); - connect( &m_attackModel, SIGNAL( dataChanged() ), - this, SLOT( updateSampleVars() ), Qt::DirectConnection ); - connect( &m_holdModel, SIGNAL( dataChanged() ), - this, SLOT( updateSampleVars() ), Qt::DirectConnection ); - connect( &m_decayModel, SIGNAL( dataChanged() ), - this, SLOT( updateSampleVars() ), Qt::DirectConnection ); - connect( &m_sustainModel, SIGNAL( dataChanged() ), - this, SLOT( updateSampleVars() ), Qt::DirectConnection ); - connect( &m_releaseModel, SIGNAL( dataChanged() ), - this, SLOT( updateSampleVars() ), Qt::DirectConnection ); - connect( &m_amountModel, SIGNAL( dataChanged() ), - this, SLOT( updateSampleVars() ), Qt::DirectConnection ); + connect( &m_predelayModel, SIGNAL(dataChanged()), + this, SLOT(updateSampleVars()), Qt::DirectConnection ); + connect( &m_attackModel, SIGNAL(dataChanged()), + this, SLOT(updateSampleVars()), Qt::DirectConnection ); + connect( &m_holdModel, SIGNAL(dataChanged()), + this, SLOT(updateSampleVars()), Qt::DirectConnection ); + connect( &m_decayModel, SIGNAL(dataChanged()), + this, SLOT(updateSampleVars()), Qt::DirectConnection ); + connect( &m_sustainModel, SIGNAL(dataChanged()), + this, SLOT(updateSampleVars()), Qt::DirectConnection ); + connect( &m_releaseModel, SIGNAL(dataChanged()), + this, SLOT(updateSampleVars()), Qt::DirectConnection ); + connect( &m_amountModel, SIGNAL(dataChanged()), + this, SLOT(updateSampleVars()), Qt::DirectConnection ); - connect( &m_lfoPredelayModel, SIGNAL( dataChanged() ), - this, SLOT( updateSampleVars() ), Qt::DirectConnection ); - connect( &m_lfoAttackModel, SIGNAL( dataChanged() ), - this, SLOT( updateSampleVars() ), Qt::DirectConnection ); - connect( &m_lfoSpeedModel, SIGNAL( dataChanged() ), - this, SLOT( updateSampleVars() ), Qt::DirectConnection ); - connect( &m_lfoAmountModel, SIGNAL( dataChanged() ), - this, SLOT( updateSampleVars() ), Qt::DirectConnection ); - connect( &m_lfoWaveModel, SIGNAL( dataChanged() ), - this, SLOT( updateSampleVars() ), Qt::DirectConnection ); - connect( &m_x100Model, SIGNAL( dataChanged() ), - this, SLOT( updateSampleVars() ), Qt::DirectConnection ); + connect( &m_lfoPredelayModel, SIGNAL(dataChanged()), + this, SLOT(updateSampleVars()), Qt::DirectConnection ); + connect( &m_lfoAttackModel, SIGNAL(dataChanged()), + this, SLOT(updateSampleVars()), Qt::DirectConnection ); + connect( &m_lfoSpeedModel, SIGNAL(dataChanged()), + this, SLOT(updateSampleVars()), Qt::DirectConnection ); + connect( &m_lfoAmountModel, SIGNAL(dataChanged()), + this, SLOT(updateSampleVars()), Qt::DirectConnection ); + connect( &m_lfoWaveModel, SIGNAL(dataChanged()), + this, SLOT(updateSampleVars()), Qt::DirectConnection ); + connect( &m_x100Model, SIGNAL(dataChanged()), + this, SLOT(updateSampleVars()), Qt::DirectConnection ); - connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), - this, SLOT( updateSampleVars() ) ); + connect( Engine::audioEngine(), SIGNAL(sampleRateChanged()), + this, SLOT(updateSampleVars())); m_lfoShapeData = @@ -401,16 +402,13 @@ void EnvelopeAndLfoParameters::updateSampleVars() Engine::audioEngine()->processingSampleRate(); // TODO: Remove the expKnobVals, time should be linear - const f_cnt_t predelay_frames = static_cast( - frames_per_env_seg * - expKnobVal( m_predelayModel.value() ) ); + const auto predelay_frames = static_cast(frames_per_env_seg * expKnobVal(m_predelayModel.value())); const f_cnt_t attack_frames = qMax( minimumFrames, static_cast( frames_per_env_seg * expKnobVal( m_attackModel.value() ) ) ); - const f_cnt_t hold_frames = static_cast( frames_per_env_seg * - expKnobVal( m_holdModel.value() ) ); + const auto hold_frames = static_cast(frames_per_env_seg * expKnobVal(m_holdModel.value())); const f_cnt_t decay_frames = qMax( minimumFrames, static_cast( frames_per_env_seg * @@ -540,4 +538,4 @@ void EnvelopeAndLfoParameters::updateSampleVars() - +} // namespace lmms diff --git a/src/core/Groove.cpp b/src/core/Groove.cpp index b71e2d73d..22bcc11ba 100644 --- a/src/core/Groove.cpp +++ b/src/core/Groove.cpp @@ -9,6 +9,9 @@ #include "MidiClip.h" #include "Song.h" +namespace lmms +{ + Groove::Groove(QObject *parent) : QObject(parent) { @@ -64,3 +67,5 @@ QWidget * Groove::instantiateView(QWidget * parent) { return new QLabel(""); } + +} // namespace lmms diff --git a/src/core/GrooveExperiments.cpp b/src/core/GrooveExperiments.cpp index 18a8311db..6dc06456c 100644 --- a/src/core/GrooveExperiments.cpp +++ b/src/core/GrooveExperiments.cpp @@ -35,6 +35,9 @@ #include "stdio.h" +namespace lmms +{ + GrooveExperiments::GrooveExperiments(QObject * parent) : Groove(parent) { @@ -123,10 +126,12 @@ int GrooveExperiments::isInTick(TimePos * curStart, const fpp_t frames, const f_ QWidget * GrooveExperiments::instantiateView(QWidget * parent) { - return new GrooveExperimentsView(this, parent); + return new gui::GrooveExperimentsView(this, parent); } +namespace gui +{ // VIEW // @@ -162,3 +167,7 @@ void GrooveExperimentsView::modelChanged() { m_groove->setAmount(m_sliderModel->value()); } + +} // namespace gui + +} // namespace lmms diff --git a/src/core/GrooveFactory.cpp b/src/core/GrooveFactory.cpp index df52891d5..153cd49e6 100644 --- a/src/core/GrooveFactory.cpp +++ b/src/core/GrooveFactory.cpp @@ -8,6 +8,9 @@ #include "HalfSwing.h" #include "HydrogenSwing.h" +namespace lmms +{ + GrooveFactory::GrooveFactory() { } @@ -37,3 +40,4 @@ Groove * GrooveFactory::create(QString grooveType) { return new Groove(); } +} // namespace lmms diff --git a/src/core/HalfSwing.cpp b/src/core/HalfSwing.cpp index 8ebb0ec8f..c8721463a 100644 --- a/src/core/HalfSwing.cpp +++ b/src/core/HalfSwing.cpp @@ -37,6 +37,9 @@ #include "stdio.h" +namespace lmms +{ + HalfSwing::HalfSwing(QObject * parent) : Groove(parent) { @@ -131,10 +134,12 @@ int HalfSwing::isInTick(TimePos * curStart, const fpp_t frames, const f_cnt_t of QWidget * HalfSwing::instantiateView(QWidget * parent) { - return new HalfSwingView(this, parent); + return new gui::HalfSwingView(this, parent); } +namespace gui +{ // VIEW // @@ -170,3 +175,7 @@ void HalfSwingView::modelChanged() { m_swing->setAmount(m_sliderModel->value()); } + +} // namespace gui + +} // namespace lmms diff --git a/src/core/HydrogenSwing.cpp b/src/core/HydrogenSwing.cpp index 9bf05e0e6..a5fe449fd 100644 --- a/src/core/HydrogenSwing.cpp +++ b/src/core/HydrogenSwing.cpp @@ -37,6 +37,9 @@ #include "stdio.h" +namespace lmms +{ + HydrogenSwing::HydrogenSwing(QObject * _parent) : Groove(_parent) { @@ -135,9 +138,12 @@ int HydrogenSwing::isInTick(TimePos * curStart, const fpp_t frames, const f_cnt_ QWidget * HydrogenSwing::instantiateView(QWidget * parent) { - return new HydrogenSwingView(this, parent); + return new gui::HydrogenSwingView(this, parent); } +namespace gui +{ + // VIEW // HydrogenSwingView::HydrogenSwingView(HydrogenSwing * swing, QWidget * parent) : @@ -172,3 +178,7 @@ void HydrogenSwingView::modelChanged() { m_swing->setAmount(m_sliderModel->value()); } + +} // namespace gui + +} // namespace lmms diff --git a/src/core/ImportFilter.cpp b/src/core/ImportFilter.cpp index 6f41756a6..35c34078e 100644 --- a/src/core/ImportFilter.cpp +++ b/src/core/ImportFilter.cpp @@ -33,6 +33,9 @@ #include "ProjectJournal.h" +namespace lmms +{ + using std::unique_ptr; ImportFilter::ImportFilter( const QString & _file_name, @@ -45,12 +48,6 @@ ImportFilter::ImportFilter( const QString & _file_name, -ImportFilter::~ImportFilter() -{ -} - - - void ImportFilter::import( const QString & _file_to_import, TrackContainer* tc ) @@ -117,3 +114,4 @@ bool ImportFilter::openFile() +} // namespace lmms \ No newline at end of file diff --git a/src/core/InlineAutomation.cpp b/src/core/InlineAutomation.cpp index 7df6a2d75..bbea1becb 100644 --- a/src/core/InlineAutomation.cpp +++ b/src/core/InlineAutomation.cpp @@ -27,6 +27,9 @@ #include "InlineAutomation.h" +namespace lmms +{ + void InlineAutomation::saveSettings( QDomDocument & _doc, QDomElement & _parent ) { @@ -58,3 +61,5 @@ void InlineAutomation::loadSettings( const QDomElement & _this ) } } + +} // namespace lmms \ No newline at end of file diff --git a/src/core/Instrument.cpp b/src/core/Instrument.cpp index 9b7267c0d..dde260fdc 100644 --- a/src/core/Instrument.cpp +++ b/src/core/Instrument.cpp @@ -31,6 +31,10 @@ #include "lmms_constants.h" +namespace lmms +{ + + Instrument::Instrument(InstrumentTrack * _instrument_track, const Descriptor * _descriptor, const Descriptor::SubPluginFeatures::Key *key) : @@ -86,7 +90,7 @@ bool Instrument::isFromTrack( const Track * _track ) const static int countZeroCrossings(sampleFrame *buf, fpp_t start, fpp_t frames) { // zero point crossing counts of all channels - int zeroCrossings[DEFAULT_CHANNELS] = {0}; + auto zeroCrossings = std::array{}; // maximum zero point crossing of all channels int maxZeroCrossings = 0; @@ -201,3 +205,6 @@ QString Instrument::fullDisplayName() const { return instrumentTrack()->displayName(); } + + +} // namespace lmms diff --git a/src/core/InstrumentFunctions.cpp b/src/core/InstrumentFunctions.cpp index 1295ed6d2..06e56666c 100644 --- a/src/core/InstrumentFunctions.cpp +++ b/src/core/InstrumentFunctions.cpp @@ -31,9 +31,13 @@ #include "InstrumentTrack.h" #include "PresetPreviewPlayHandle.h" - -InstrumentFunctionNoteStacking::ChordTable::Init InstrumentFunctionNoteStacking::ChordTable::s_initTable[] = +namespace lmms { + +std::array + InstrumentFunctionNoteStacking::ChordTable::s_initTable = + std::array +{{ { QT_TRANSLATE_NOOP( "InstrumentFunctionNoteStacking", "octave" ), { 0, -1 } }, { QT_TRANSLATE_NOOP( "InstrumentFunctionNoteStacking", "Major" ), { 0, 4, 7, -1 } }, { QT_TRANSLATE_NOOP( "InstrumentFunctionNoteStacking", "Majb5" ), { 0, 4, 6, -1 } }, @@ -136,7 +140,7 @@ InstrumentFunctionNoteStacking::ChordTable::Init InstrumentFunctionNoteStacking: { QT_TRANSLATE_NOOP( "InstrumentFunctionNoteStacking", "5" ), { 0, 7, -1 } }, { QT_TRANSLATE_NOOP( "InstrumentFunctionNoteStacking", "Phrygian dominant" ), { 0, 1, 4, 5, 7, 8, 10, -1 } }, { QT_TRANSLATE_NOOP( "InstrumentFunctionNoteStacking", "Persian" ), { 0, 1, 4, 5, 6, 8, 11, -1 } } -} ; +}}; @@ -176,11 +180,9 @@ bool InstrumentFunctionNoteStacking::Chord::hasSemiTone( int8_t semi_tone ) cons InstrumentFunctionNoteStacking::ChordTable::ChordTable() : QVector() { - for( int i = 0; - i < static_cast( sizeof s_initTable / sizeof *s_initTable ); - i++ ) + for (const auto& chord : s_initTable) { - push_back( Chord( s_initTable[i].m_name, s_initTable[i].m_semiTones ) ); + push_back(Chord(chord.m_name, chord.m_semiTones)); } } @@ -218,10 +220,6 @@ InstrumentFunctionNoteStacking::InstrumentFunctionNoteStacking( Model * _parent -InstrumentFunctionNoteStacking::~InstrumentFunctionNoteStacking() -{ -} - @@ -331,11 +329,6 @@ InstrumentFunctionArpeggio::InstrumentFunctionArpeggio( Model * _parent ) : -InstrumentFunctionArpeggio::~InstrumentFunctionArpeggio() -{ -} - - void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n ) @@ -374,8 +367,8 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n ) const int total_range = range * cnphv.size(); // number of frames that every note should be played - const f_cnt_t arp_frames = (f_cnt_t)( m_arpTimeModel.value() / 1000.0f * Engine::audioEngine()->processingSampleRate() ); - const f_cnt_t gated_frames = (f_cnt_t)( m_arpGateModel.value() * arp_frames / 100.0f ); + const auto arp_frames = (f_cnt_t)(m_arpTimeModel.value() / 1000.0f * Engine::audioEngine()->processingSampleRate()); + const auto gated_frames = (f_cnt_t)(m_arpGateModel.value() * arp_frames / 100.0f); // used for calculating remaining frames for arp-note, we have to add // arp_frames-1, otherwise the first arp-note will not be setup @@ -556,3 +549,6 @@ void InstrumentFunctionArpeggio::loadSettings( const QDomElement & _this ) m_arpDirectionModel.loadSettings( _this, "arpdir" ); m_arpModeModel.loadSettings( _this, "arpmode" ); } + + +} // namespace lmms diff --git a/src/core/InstrumentPlayHandle.cpp b/src/core/InstrumentPlayHandle.cpp index 71ac555b3..8c272cd47 100644 --- a/src/core/InstrumentPlayHandle.cpp +++ b/src/core/InstrumentPlayHandle.cpp @@ -26,9 +26,16 @@ #include "InstrumentPlayHandle.h" #include "InstrumentTrack.h" +namespace lmms +{ + + InstrumentPlayHandle::InstrumentPlayHandle( Instrument * instrument, InstrumentTrack* instrumentTrack ) : PlayHandle( TypeInstrumentPlayHandle ), m_instrument( instrument ) { setAudioPort( instrumentTrack->audioPort() ); } + + +} // namespace lmms \ No newline at end of file diff --git a/src/core/InstrumentSoundShaping.cpp b/src/core/InstrumentSoundShaping.cpp index e3ab82c0e..edf3b403c 100644 --- a/src/core/InstrumentSoundShaping.cpp +++ b/src/core/InstrumentSoundShaping.cpp @@ -34,6 +34,9 @@ #include "Instrument.h" #include "InstrumentTrack.h" +namespace lmms +{ + const float CUT_FREQ_MULTIPLIER = 6000.0f; const float RES_MULTIPLIER = 2.0f; @@ -104,11 +107,6 @@ InstrumentSoundShaping::InstrumentSoundShaping( -InstrumentSoundShaping::~InstrumentSoundShaping() -{ -} - - float InstrumentSoundShaping::volumeLevel( NotePlayHandle* n, const f_cnt_t frame ) @@ -377,4 +375,4 @@ void InstrumentSoundShaping::loadSettings( const QDomElement & _this ) - +} // namespace lmms diff --git a/src/core/JournallingObject.cpp b/src/core/JournallingObject.cpp index 729303c67..802f4291e 100644 --- a/src/core/JournallingObject.cpp +++ b/src/core/JournallingObject.cpp @@ -29,6 +29,8 @@ #include "ProjectJournal.h" #include "Engine.h" +namespace lmms +{ JournallingObject::JournallingObject() : @@ -140,3 +142,4 @@ void JournallingObject::changeID( jo_id_t _id ) } +} // namespace lmms diff --git a/src/core/Keymap.cpp b/src/core/Keymap.cpp index a50abfaf2..6683919fe 100644 --- a/src/core/Keymap.cpp +++ b/src/core/Keymap.cpp @@ -29,6 +29,10 @@ #include "Note.h" +namespace lmms +{ + + Keymap::Keymap() : m_description(tr("empty")), m_firstKey(0), @@ -121,11 +125,11 @@ void Keymap::saveSettings(QDomDocument &document, QDomElement &element) element.setAttribute("base_key", m_baseKey); element.setAttribute("base_freq", m_baseFreq); - for (int i = 0; i < m_map.size(); i++) + for (int value : m_map) { QDomElement degree = document.createElement("degree"); element.appendChild(degree); - degree.setAttribute("value", m_map[i]); + degree.setAttribute("value", value); } } @@ -149,3 +153,6 @@ void Keymap::loadSettings(const QDomElement &element) node = node.nextSibling(); } } + + +} // namespace lmms diff --git a/src/core/Ladspa2LMMS.cpp b/src/core/Ladspa2LMMS.cpp index 950e4bf0d..24dfc76f1 100644 --- a/src/core/Ladspa2LMMS.cpp +++ b/src/core/Ladspa2LMMS.cpp @@ -27,14 +27,17 @@ #include "Ladspa2LMMS.h" +namespace lmms +{ + + Ladspa2LMMS::Ladspa2LMMS() { l_sortable_plugin_t plugins = getSortedPlugins(); - for( l_sortable_plugin_t::iterator it = plugins.begin(); - it != plugins.end(); ++it ) + for (const auto& plugin : plugins) { - ladspa_key_t key = (*it).second; + ladspa_key_t key = plugin.second; LadspaManagerDescription * desc = getDescription( key ); if( desc->type == SOURCE ) @@ -78,12 +81,6 @@ Ladspa2LMMS::Ladspa2LMMS() -Ladspa2LMMS::~Ladspa2LMMS() -{ -} - - - QString Ladspa2LMMS::getShortName( const ladspa_key_t & _key ) { QString name = getName( _key ); @@ -126,3 +123,6 @@ QString Ladspa2LMMS::getShortName( const ladspa_key_t & _key ) return name; } + + +} // namespace lmms diff --git a/src/core/LadspaControl.cpp b/src/core/LadspaControl.cpp index 4d3faeda7..7e8e92623 100644 --- a/src/core/LadspaControl.cpp +++ b/src/core/LadspaControl.cpp @@ -30,6 +30,9 @@ #include "LadspaControl.h" #include "LadspaBase.h" +namespace lmms +{ + LadspaControl::LadspaControl( Model * _parent, port_desc_t * _port, bool _link ) : @@ -43,8 +46,8 @@ LadspaControl::LadspaControl( Model * _parent, port_desc_t * _port, { if( m_link ) { - connect( &m_linkEnabledModel, SIGNAL( dataChanged() ), - this, SLOT( linkStateChanged() ), + connect( &m_linkEnabledModel, SIGNAL(dataChanged()), + this, SLOT(linkStateChanged()), Qt::DirectConnection ); } @@ -53,8 +56,8 @@ LadspaControl::LadspaControl( Model * _parent, port_desc_t * _port, case TOGGLED: m_toggledModel.setInitValue( static_cast( m_port->def ) ); - connect( &m_toggledModel, SIGNAL( dataChanged() ), - this, SLOT( ledChanged() ) ); + connect( &m_toggledModel, SIGNAL(dataChanged()), + this, SLOT(ledChanged())); if( m_port->def == 1.0f ) { m_toggledModel.setValue( true ); @@ -71,8 +74,8 @@ LadspaControl::LadspaControl( Model * _parent, port_desc_t * _port, m_port->min ) / 400 ); m_knobModel.setInitValue( static_cast( m_port->def ) ); - connect( &m_knobModel, SIGNAL( dataChanged() ), - this, SLOT( knobChanged() ) ); + connect( &m_knobModel, SIGNAL(dataChanged()), + this, SLOT(knobChanged())); // TODO: careful: we must prevent saved scales m_knobModel.setScaleLogarithmic( m_port->suggests_logscale ); break; @@ -84,8 +87,8 @@ LadspaControl::LadspaControl( Model * _parent, port_desc_t * _port, && m_port->max == 10.0f ? 4000.0f : ( m_port->suggests_logscale ? 8000000.0f : 800000.0f ) ) ); m_knobModel.setInitValue( m_port->def ); - connect( &m_knobModel, SIGNAL( dataChanged() ), - this, SLOT( knobChanged() ) ); + connect( &m_knobModel, SIGNAL(dataChanged()), + this, SLOT(knobChanged())); // TODO: careful: we must prevent saved scales m_knobModel.setScaleLogarithmic( m_port->suggests_logscale ); break; @@ -95,8 +98,8 @@ LadspaControl::LadspaControl( Model * _parent, port_desc_t * _port, ( m_port->max - m_port->min ) / 800.0f ); m_tempoSyncKnobModel.setInitValue( m_port->def ); - connect( &m_tempoSyncKnobModel, SIGNAL( dataChanged() ), - this, SLOT( tempoKnobChanged() ) ); + connect( &m_tempoSyncKnobModel, SIGNAL(dataChanged()), + this, SLOT(tempoKnobChanged())); // TODO: careful: we must prevent saved scales m_tempoSyncKnobModel.setScaleLogarithmic( m_port->suggests_logscale ); break; @@ -109,13 +112,6 @@ LadspaControl::LadspaControl( Model * _parent, port_desc_t * _port, -LadspaControl::~LadspaControl() -{ -} - - - - LADSPA_Data LadspaControl::value() { switch( m_port->data_type ) @@ -379,5 +375,4 @@ void LadspaControl::setLink( bool _state ) } - - +} // namespace lmms diff --git a/src/core/LadspaManager.cpp b/src/core/LadspaManager.cpp index 851ae007e..8c3ab8f97 100644 --- a/src/core/LadspaManager.cpp +++ b/src/core/LadspaManager.cpp @@ -36,6 +36,9 @@ #include "PluginFactory.h" +namespace lmms +{ + LadspaManager::LadspaManager() { @@ -56,19 +59,15 @@ LadspaManager::LadspaManager() ladspaDirectories.push_back( "/Library/Audio/Plug-Ins/LADSPA" ); #endif - for( QStringList::iterator it = ladspaDirectories.begin(); - it != ladspaDirectories.end(); ++it ) + for (const auto& ladspaDirectory : ladspaDirectories) { // Skip empty entries as QDir will interpret it as the working directory - if ((*it).isEmpty()) { continue; } - QDir directory( ( *it ) ); + if (ladspaDirectory.isEmpty()) { continue; } + QDir directory(ladspaDirectory); QFileInfoList list = directory.entryInfoList(); - for( QFileInfoList::iterator file = list.begin(); - file != list.end(); ++file ) + for (const auto& f : list) { - const QFileInfo & f = *file; - if( !f.isFile() || - f.fileName().right( 3 ).toLower() != + if(!f.isFile() || f.fileName().right( 3 ).toLower() != #ifdef LMMS_BUILD_WIN32 "dll" #else @@ -83,9 +82,7 @@ LadspaManager::LadspaManager() if( plugin_lib.load() == true ) { - LADSPA_Descriptor_Function descriptorFunction = - ( LADSPA_Descriptor_Function ) plugin_lib.resolve( - "ladspa_descriptor" ); + auto descriptorFunction = (LADSPA_Descriptor_Function)plugin_lib.resolve("ladspa_descriptor"); if( descriptorFunction != nullptr ) { addPlugins( descriptorFunction, @@ -100,10 +97,9 @@ LadspaManager::LadspaManager() } l_ladspa_key_t keys = m_ladspaManagerMap.keys(); - for( l_ladspa_key_t::iterator it = keys.begin(); - it != keys.end(); ++it ) + for (const auto& key : keys) { - m_sortedPlugins.append( qMakePair( getName( *it ), *it ) ); + m_sortedPlugins.append(qMakePair(getName(key), key)); } std::sort( m_sortedPlugins.begin(), m_sortedPlugins.end() ); } @@ -155,8 +151,7 @@ void LadspaManager::addPlugins( continue; } - LadspaManagerDescription * plugIn = - new LadspaManagerDescription; + auto plugIn = new LadspaManagerDescription; plugIn->descriptorFunction = _descriptor_func; plugIn->index = pluginIndex; plugIn->inputChannels = getPluginInputs( descriptor ); @@ -715,3 +710,6 @@ bool LadspaManager::cleanup( const ladspa_key_t & _plugin, } return( false ); } + + +} // namespace lmms diff --git a/src/core/LfoController.cpp b/src/core/LfoController.cpp index 947fd5e22..495ae54d4 100644 --- a/src/core/LfoController.cpp +++ b/src/core/LfoController.cpp @@ -31,6 +31,10 @@ #include "Song.h" +namespace lmms +{ + + LfoController::LfoController( Model * _parent ) : Controller( Controller::LfoController, _parent, tr( "LFO Controller" ) ), m_baseModel( 0.5, 0.0, 1.0, 0.001, this, tr( "Base value" ) ), @@ -47,20 +51,20 @@ LfoController::LfoController( Model * _parent ) : m_userDefSampleBuffer( new SampleBuffer ) { setSampleExact( true ); - connect( &m_waveModel, SIGNAL( dataChanged() ), - this, SLOT( updateSampleFunction() ), Qt::DirectConnection ); + connect( &m_waveModel, SIGNAL(dataChanged()), + this, SLOT(updateSampleFunction()), Qt::DirectConnection ); - connect( &m_speedModel, SIGNAL( dataChanged() ), - this, SLOT( updateDuration() ), Qt::DirectConnection ); - connect( &m_multiplierModel, SIGNAL( dataChanged() ), - this, SLOT( updateDuration() ), Qt::DirectConnection ); - connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), - this, SLOT( updateDuration() ) ); + connect( &m_speedModel, SIGNAL(dataChanged()), + this, SLOT(updateDuration()), Qt::DirectConnection ); + connect( &m_multiplierModel, SIGNAL(dataChanged()), + this, SLOT(updateDuration()), Qt::DirectConnection ); + connect( Engine::audioEngine(), SIGNAL(sampleRateChanged()), + this, SLOT(updateDuration())); - connect( Engine::getSong(), SIGNAL( playbackStateChanged() ), - this, SLOT( updatePhase() ) ); - connect( Engine::getSong(), SIGNAL( playbackPositionChanged() ), - this, SLOT( updatePhase() ) ); + connect( Engine::getSong(), SIGNAL(playbackStateChanged()), + this, SLOT(updatePhase())); + connect( Engine::getSong(), SIGNAL(playbackPositionChanged()), + this, SLOT(updatePhase())); updateDuration(); } @@ -220,12 +224,10 @@ QString LfoController::nodeName() const -ControllerDialog * LfoController::createDialog( QWidget * _parent ) +gui::ControllerDialog * LfoController::createDialog( QWidget * _parent ) { - return new LfoControllerDialog( this, _parent ); + return new gui::LfoControllerDialog( this, _parent ); } - - - +} // namespace lmms diff --git a/src/core/LinkedModelGroups.cpp b/src/core/LinkedModelGroups.cpp index d0bcd8cfd..83bebc2a0 100644 --- a/src/core/LinkedModelGroups.cpp +++ b/src/core/LinkedModelGroups.cpp @@ -22,15 +22,18 @@ * */ -#include "LinkedModelGroups.h" - #include #include +#include "LinkedModelGroups.h" + + #include "AutomatableModel.h" +namespace lmms +{ /* LinkedModelGroup @@ -137,11 +140,6 @@ bool LinkedModelGroup::containsModel(const QString &name) const -LinkedModelGroups::~LinkedModelGroups() {} - - - - void LinkedModelGroups::linkAllModels() { LinkedModelGroup* first = getGroup(0); @@ -182,3 +180,5 @@ void LinkedModelGroups::loadSettings(const QDomElement& that) } } + +} // namespace lmms diff --git a/src/core/LocklessAllocator.cpp b/src/core/LocklessAllocator.cpp index 07aaa0c14..919093906 100644 --- a/src/core/LocklessAllocator.cpp +++ b/src/core/LocklessAllocator.cpp @@ -33,6 +33,9 @@ #include #endif +namespace lmms +{ + static const size_t SIZEOF_SET = sizeof( int ) * 8; @@ -162,3 +165,6 @@ invalid: } ++m_available; } + + +} // namespace lmms \ No newline at end of file diff --git a/src/core/MemoryHelper.cpp b/src/core/MemoryHelper.cpp index 8ac2700f3..de80ef770 100644 --- a/src/core/MemoryHelper.cpp +++ b/src/core/MemoryHelper.cpp @@ -26,6 +26,10 @@ #include "lmms_basics.h" #include "MemoryHelper.h" +namespace lmms +{ + + /** * Allocate a number of bytes and return them. * @param byteNum is the number of bytes @@ -63,3 +67,5 @@ void MemoryHelper::alignedFree( void* _buffer ) } } + +} // namespace lmms diff --git a/src/core/MemoryManager.cpp b/src/core/MemoryManager.cpp index 01fdfd5d6..bd3168f14 100644 --- a/src/core/MemoryManager.cpp +++ b/src/core/MemoryManager.cpp @@ -28,6 +28,10 @@ #include #include "rpmalloc.h" +namespace lmms +{ + + /// Global static object handling rpmalloc intializing and finalizing struct MemoryManagerGlobalGuard { MemoryManagerGlobalGuard() { @@ -75,3 +79,6 @@ void MemoryManager::free(void * ptr) Q_ASSERT_X(rpmalloc_is_thread_initialized(), "MemoryManager::free", "Thread not initialized"); return rpfree(ptr); } + + +} // namespace lmms diff --git a/src/core/MeterModel.cpp b/src/core/MeterModel.cpp index 7bf61958d..d9e5c0343 100644 --- a/src/core/MeterModel.cpp +++ b/src/core/MeterModel.cpp @@ -27,27 +27,21 @@ #include "AutomationClip.h" -MeterModel::MeterModel( ::Model * _parent ) : +namespace lmms +{ + +MeterModel::MeterModel( Model * _parent ) : Model( _parent ), m_numeratorModel( 4, 1, 32, this, tr( "Numerator" ) ), m_denominatorModel( 4, 1, 32, this, tr( "Denominator" ) ) { - connect( &m_numeratorModel, SIGNAL( dataChanged() ), - this, SIGNAL( dataChanged() ), Qt::DirectConnection ); - connect( &m_denominatorModel, SIGNAL( dataChanged() ), - this, SIGNAL( dataChanged() ), Qt::DirectConnection ); + connect( &m_numeratorModel, SIGNAL(dataChanged()), + this, SIGNAL(dataChanged()), Qt::DirectConnection ); + connect( &m_denominatorModel, SIGNAL(dataChanged()), + this, SIGNAL(dataChanged()), Qt::DirectConnection ); } - - -MeterModel::~MeterModel() -{ -} - - - - void MeterModel::reset() { m_numeratorModel.setValue( 4 ); @@ -78,6 +72,4 @@ void MeterModel::loadSettings( const QDomElement & _this, } - - - +} // namespace lmms diff --git a/src/core/MicroTimer.cpp b/src/core/MicroTimer.cpp index ba94f1c9a..499ba8dd3 100644 --- a/src/core/MicroTimer.cpp +++ b/src/core/MicroTimer.cpp @@ -1,5 +1,8 @@ #include "MicroTimer.h" +namespace lmms +{ + using namespace std; using namespace std::chrono; @@ -11,10 +14,6 @@ MicroTimer::MicroTimer() reset(); } -MicroTimer::~MicroTimer() -{ -} - void MicroTimer::reset() { begin = steady_clock::now(); @@ -25,3 +24,5 @@ int MicroTimer::elapsed() const auto now = steady_clock::now(); return std::chrono::duration_cast>(now - begin).count(); } + +} // namespace lmms diff --git a/src/core/Microtuner.cpp b/src/core/Microtuner.cpp index b384cf390..9c5ab871b 100644 --- a/src/core/Microtuner.cpp +++ b/src/core/Microtuner.cpp @@ -33,6 +33,9 @@ #include "Scale.h" #include "Song.h" +namespace lmms +{ + Microtuner::Microtuner() : Model(nullptr, tr("Microtuner")), @@ -105,6 +108,17 @@ float Microtuner::keyToFreq(int key, int userBaseNote) const return middleFreq * intervals[scaleDegree].getRatio() * pow(octaveRatio, keymapOctave + scaleOctave); } +int Microtuner::octaveSize() const +{ + const int keymapSize = Engine::getSong()->getKeymap(currentKeymap())->getSize(); + if (keymapSize > 0) + { + return keymapSize; + } + + // Determine octave size from the scale if the keymap isn't in use. + return Engine::getSong()->getScale(currentScale())->getIntervals().size() - 1; +} /** * \brief Update scale name displayed in the microtuner scale list. @@ -165,3 +179,6 @@ void Microtuner::loadSettings(const QDomElement &element) m_keymapModel.loadSettings(element, "keymap"); m_keyRangeImportModel.loadSettings(element, "range_import"); } + + +} // namespace lmms diff --git a/src/core/MidiSwing.cpp b/src/core/MidiSwing.cpp index 6f742a37d..f5fd40ccc 100644 --- a/src/core/MidiSwing.cpp +++ b/src/core/MidiSwing.cpp @@ -27,6 +27,9 @@ #include "MidiSwing.h" +namespace lmms +{ + MidiSwing::MidiSwing(QObject * parent) : Groove(parent) { @@ -89,3 +92,5 @@ static int applyMidiSwing(int posInEight) if (posInEight == 5) return 5; return 0; } + +} // namespace lmms diff --git a/src/core/MixHelpers.cpp b/src/core/MixHelpers.cpp index 816104061..02f3d8775 100644 --- a/src/core/MixHelpers.cpp +++ b/src/core/MixHelpers.cpp @@ -38,7 +38,7 @@ static bool s_NaNHandler; -namespace MixHelpers +namespace lmms::MixHelpers { /*! \brief Function for applying MIXOP on all sample frames */ @@ -281,7 +281,7 @@ struct AddMultipliedStereoOp dst[1] += src[1] * m_coeffs[1]; } - float m_coeffs[2]; + std::array m_coeffs; } ; @@ -309,7 +309,7 @@ struct MultiplyAndAddMultipliedOp dst[1] = dst[1]*m_coeffs[0] + src[1]*m_coeffs[1]; } - float m_coeffs[2]; + std::array m_coeffs; } ; @@ -328,5 +328,5 @@ void multiplyAndAddMultipliedJoined( sampleFrame* dst, run<>( dst, srcLeft, srcRight, frames, MultiplyAndAddMultipliedOp(coeffDst, coeffSrc) ); } -} +} // namespace lmms::MixHelpers diff --git a/src/core/Mixer.cpp b/src/core/Mixer.cpp index bf72c42a4..52ce2732c 100644 --- a/src/core/Mixer.cpp +++ b/src/core/Mixer.cpp @@ -36,6 +36,10 @@ #include "SampleTrack.h" #include "TrackContainer.h" // For TrackContainer::TrackList typedef +namespace lmms +{ + + MixerRoute::MixerRoute( MixerChannel * from, MixerChannel * to, float amount ) : m_from( from ), m_to( to ), @@ -47,11 +51,6 @@ MixerRoute::MixerRoute( MixerChannel * from, MixerChannel * to, float amount ) : } -MixerRoute::~MixerRoute() -{ -} - - void MixerRoute::updateName() { m_amount.setDisplayName( @@ -294,7 +293,7 @@ void Mixer::deleteChannel( int index ) { if( t->type() == Track::InstrumentTrack ) { - InstrumentTrack* inst = dynamic_cast( t ); + auto inst = dynamic_cast(t); int val = inst->mixerChannelModel()->value(0); if( val == index ) { @@ -310,7 +309,7 @@ void Mixer::deleteChannel( int index ) } else if( t->type() == Track::SampleTrack ) { - SampleTrack* strk = dynamic_cast( t ); + auto strk = dynamic_cast(t); int val = strk->mixerChannelModel()->value(0); if( val == index ) { @@ -388,15 +387,13 @@ void Mixer::moveChannelLeft( int index ) TrackContainer::TrackList songTrackList = Engine::getSong()->tracks(); TrackContainer::TrackList patternTrackList = Engine::patternStore()->tracks(); - TrackContainer::TrackList trackLists[] = {songTrackList, patternTrackList}; - for(int tl=0; tl<2; ++tl) + for (const auto& trackList : {songTrackList, patternTrackList}) { - TrackContainer::TrackList trackList = trackLists[tl]; - for(int i=0; itype() == Track::InstrumentTrack ) + if (track->type() == Track::InstrumentTrack) { - InstrumentTrack * inst = (InstrumentTrack *) trackList[i]; + auto inst = (InstrumentTrack*)track; int val = inst->mixerChannelModel()->value(0); if( val == a ) { @@ -407,9 +404,9 @@ void Mixer::moveChannelLeft( int index ) inst->mixerChannelModel()->setValue(a); } } - else if( trackList[i]->type() == Track::SampleTrack ) + else if (track->type() == Track::SampleTrack) { - SampleTrack * strk = (SampleTrack *) trackList[i]; + auto strk = (SampleTrack*)track; int val = strk->mixerChannelModel()->value(0); if( val == a ) { @@ -448,13 +445,13 @@ MixerRoute * Mixer::createChannelSend( mix_ch_t fromChannel, mix_ch_t toChannel, MixerChannel * from = m_mixerChannels[fromChannel]; MixerChannel * to = m_mixerChannels[toChannel]; - for( int i=0; im_sends.size(); ++i ) + for (const auto& send : from->m_sends) { - if( from->m_sends[i]->receiver() == to ) + if (send->receiver() == to) { // simply adjust the amount - from->m_sends[i]->amount()->setValue( amount ); - return from->m_sends[i]; + send->amount()->setValue(amount); + return send; } } @@ -470,7 +467,7 @@ MixerRoute * Mixer::createRoute( MixerChannel * from, MixerChannel * to, float a return nullptr; } Engine::audioEngine()->requestChangeInModel(); - MixerRoute * route = new MixerRoute( from, to, amount ); + auto route = new MixerRoute(from, to, amount); // add us to from's sends from->m_sends.append( route ); @@ -494,11 +491,11 @@ void Mixer::deleteChannelSend( mix_ch_t fromChannel, mix_ch_t toChannel ) MixerChannel * to = m_mixerChannels[toChannel]; // find and delete the send entry - for( int i = 0; i < from->m_sends.size(); ++i ) + for (const auto& send : from->m_sends) { - if( from->m_sends[i]->receiver() == to ) + if (send->receiver() == to) { - deleteChannelSend( from->m_sends[i] ); + deleteChannelSend(send); break; } } @@ -545,9 +542,9 @@ bool Mixer::checkInfiniteLoop( MixerChannel * from, MixerChannel * to ) // follow sendTo's outputs recursively looking for something that sends // to sendFrom - for( int i=0; i < to->m_sends.size(); ++i ) + for (const auto& send : to->m_sends) { - if( checkInfiniteLoop( from, to->m_sends[i]->receiver() ) ) + if (checkInfiniteLoop(from, send->receiver())) { return true; } @@ -745,13 +742,13 @@ void Mixer::saveSettings( QDomDocument & _doc, QDomElement & _this ) if( ch->m_hasColor ) mixch.setAttribute( "color", ch->m_color.name() ); // add the channel sends - for( int si = 0; si < ch->m_sends.size(); ++si ) + for (const auto& send : ch->m_sends) { QDomElement sendsDom = _doc.createElement( QString( "send" ) ); mixch.appendChild( sendsDom ); - sendsDom.setAttribute( "channel", ch->m_sends[si]->receiverIndex() ); - ch->m_sends[si]->amount()->saveSettings( _doc, sendsDom, "amount" ); + sendsDom.setAttribute("channel", send->receiverIndex()); + send->amount()->saveSettings(_doc, sendsDom, "amount"); } } } @@ -827,3 +824,6 @@ void Mixer::validateChannelName( int index, int oldIndex ) m_mixerChannels[index]->m_name = tr( "Channel %1" ).arg( index ); } } + + +} // namespace lmms diff --git a/src/core/Model.cpp b/src/core/Model.cpp index 597d0340d..dd277bc4e 100644 --- a/src/core/Model.cpp +++ b/src/core/Model.cpp @@ -24,6 +24,8 @@ #include "Model.h" +namespace lmms +{ QString Model::fullDisplayName() const { @@ -46,5 +48,5 @@ QString Model::fullDisplayName() const - +} // namespace lmms diff --git a/src/core/ModelVisitor.cpp b/src/core/ModelVisitor.cpp index 4036f56e0..665e16983 100644 --- a/src/core/ModelVisitor.cpp +++ b/src/core/ModelVisitor.cpp @@ -28,6 +28,10 @@ #include "ComboBoxModel.h" #include "TempoSyncKnobModel.h" +namespace lmms +{ + + void ModelVisitor::visit(BoolModel &m) { up(m); } void ModelVisitor::visit(IntModel &m) { up(m); } void ModelVisitor::visit(FloatModel &m) { up(m); } @@ -40,5 +44,4 @@ void ConstModelVisitor::visit(const FloatModel &m) { up(m); } void ConstModelVisitor::visit(const ComboBoxModel &m) { up(m); } void ConstModelVisitor::visit(const TempoSyncKnobModel &m) { up(m); } -ModelVisitor::~ModelVisitor() {} -ConstModelVisitor::~ConstModelVisitor() {} +} // namespace lmms \ No newline at end of file diff --git a/src/core/Note.cpp b/src/core/Note.cpp index cba02ee9e..e4e5f0e5d 100644 --- a/src/core/Note.cpp +++ b/src/core/Note.cpp @@ -30,6 +30,9 @@ #include "Note.h" #include "DetuningHelper.h" +namespace lmms +{ + Note::Note( const TimePos & length, const TimePos & pos, int key, volume_t volume, panning_t panning, @@ -232,3 +235,35 @@ bool Note::withinRange(int tickStart, int tickEnd) const return pos().getTicks() >= tickStart && pos().getTicks() <= tickEnd && length().getTicks() != 0; } + + + + +/*! \brief Get the start/end/bottom/top positions of notes in a vector + * + * Returns no value if there are no notes + */ +std::optional boundsForNotes(const NoteVector& notes) +{ + if (notes.empty()) { return std::nullopt; } + + TimePos start = notes.front()->pos(); + TimePos end = start; + int lower = notes.front()->key(); + int upper = lower; + + for (const Note* note: notes) + { + // TODO should we assume that NoteVector is always sorted correctly, + // so first() always has the lowest time position? + start = std::min(start, note->pos()); + end = std::max(end, note->endPos()); + lower = std::min(lower, note->key()); + upper = std::max(upper, note->key()); + } + + return NoteBounds{start, end, lower, upper}; +} + + +} // namespace lmms diff --git a/src/core/NotePlayHandle.cpp b/src/core/NotePlayHandle.cpp index 2a4cf8f12..e87637476 100644 --- a/src/core/NotePlayHandle.cpp +++ b/src/core/NotePlayHandle.cpp @@ -33,6 +33,9 @@ #include "Instrument.h" #include "Song.h" +namespace lmms +{ + NotePlayHandle::BaseDetuning::BaseDetuning( DetuningHelper *detuning ) : m_value( detuning ? detuning->automationClip()->valueAt( 0 ) : 0 ) { @@ -440,9 +443,9 @@ float NotePlayHandle::volumeLevel( const f_cnt_t _frame ) void NotePlayHandle::mute() { // mute all sub-notes - for( NotePlayHandleList::Iterator it = m_subNotes.begin(); it != m_subNotes.end(); ++it ) + for (const auto& subNote : m_subNotes) { - ( *it )->mute(); + subNote->mute(); } m_muted = true; } @@ -454,9 +457,9 @@ int NotePlayHandle::index() const { const PlayHandleList & playHandles = Engine::audioEngine()->playHandles(); int idx = 0; - for( PlayHandleList::ConstIterator it = playHandles.begin(); it != playHandles.end(); ++it ) + for (const auto& playHandle : playHandles) { - const NotePlayHandle * nph = dynamic_cast( *it ); + const auto nph = dynamic_cast(playHandle); if( nph == nullptr || nph->m_instrumentTrack != m_instrumentTrack || nph->isReleased() || nph->hasParent() ) { continue; @@ -478,9 +481,9 @@ ConstNotePlayHandleList NotePlayHandle::nphsOfInstrumentTrack( const InstrumentT const PlayHandleList & playHandles = Engine::audioEngine()->playHandles(); ConstNotePlayHandleList cnphv; - for( PlayHandleList::ConstIterator it = playHandles.begin(); it != playHandles.end(); ++it ) + for (const auto& playHandle : playHandles) { - const NotePlayHandle * nph = dynamic_cast( *it ); + const auto nph = dynamic_cast(playHandle); if( nph != nullptr && nph->m_instrumentTrack == _it && ( ( nph->isReleased() == false && nph->hasParent() == false ) || _all_ph == true ) ) { cnphv.push_back( nph ); @@ -524,13 +527,13 @@ void NotePlayHandle::updateFrequency() if (m_instrumentTrack->m_microtuner.enabled()) { // custom key mapping and scale: get frequency from the microtuner - const float detuneMaster = detune + masterPitch; + const auto transposedKey = key() + masterPitch; - if (m_instrumentTrack->isKeyMapped(key())) + if (m_instrumentTrack->isKeyMapped(transposedKey)) { - const auto frequency = m_instrumentTrack->m_microtuner.keyToFreq(key(), baseNote); - m_frequency = frequency * powf(2.f, (detuneMaster + instrumentPitch / 100) / 12.f); - m_unpitchedFrequency = frequency * powf(2.f, detuneMaster / 12.f); + const auto frequency = m_instrumentTrack->m_microtuner.keyToFreq(transposedKey, baseNote); + m_frequency = frequency * powf(2.f, (detune + instrumentPitch / 100) / 12.f); + m_unpitchedFrequency = frequency * powf(2.f, detune / 12.f); } else { @@ -586,9 +589,9 @@ void NotePlayHandle::resize( const bpm_t _new_tempo ) m_frames = (f_cnt_t)new_frames; m_totalFramesPlayed = (f_cnt_t)( completed * new_frames ); - for( NotePlayHandleList::Iterator it = m_subNotes.begin(); it != m_subNotes.end(); ++it ) + for (const auto& subNote : m_subNotes) { - ( *it )->resize( _new_tempo ); + subNote->resize(_new_tempo); } } @@ -603,7 +606,7 @@ void NotePlayHandleManager::init() { s_available = MM_ALLOC( INITIAL_NPH_CACHE ); - NotePlayHandle * n = MM_ALLOC( INITIAL_NPH_CACHE ); + auto n = MM_ALLOC(INITIAL_NPH_CACHE); for( int i=0; i < INITIAL_NPH_CACHE; ++i ) { @@ -646,11 +649,11 @@ void NotePlayHandleManager::release( NotePlayHandle * nph ) void NotePlayHandleManager::extend( int c ) { s_size += c; - NotePlayHandle ** tmp = MM_ALLOC( s_size ); + auto tmp = MM_ALLOC(s_size); MM_FREE( s_available ); s_available = tmp; - NotePlayHandle * n = MM_ALLOC( c ); + auto n = MM_ALLOC(c); for( int i=0; i < c; ++i ) { @@ -663,3 +666,6 @@ void NotePlayHandleManager::free() { MM_FREE(s_available); } + + +} // namespace lmms diff --git a/src/core/Oscillator.cpp b/src/core/Oscillator.cpp index 16b99bb5f..189dede6e 100644 --- a/src/core/Oscillator.cpp +++ b/src/core/Oscillator.cpp @@ -38,6 +38,9 @@ #include "fft_helpers.h" +namespace lmms +{ + void Oscillator::waveTableInit() { @@ -175,7 +178,7 @@ void Oscillator::generateFromFFT(int bands, sample_t* table) //ifft fftwf_execute(s_ifftPlan); //normalize and copy to result buffer - normalize(s_sampleBuffer, table, OscillatorConstants::WAVETABLE_LENGTH, 2*OscillatorConstants::WAVETABLE_LENGTH + 1); + normalize(s_sampleBuffer.data(), table, OscillatorConstants::WAVETABLE_LENGTH, 2*OscillatorConstants::WAVETABLE_LENGTH + 1); } void Oscillator::generateAntiAliasUserWaveTable(SampleBuffer *sampleBuffer) @@ -202,15 +205,15 @@ sample_t Oscillator::s_waveTables fftwf_plan Oscillator::s_fftPlan; fftwf_plan Oscillator::s_ifftPlan; fftwf_complex * Oscillator::s_specBuf; -float Oscillator::s_sampleBuffer[OscillatorConstants::WAVETABLE_LENGTH]; +std::array Oscillator::s_sampleBuffer; void Oscillator::createFFTPlans() { Oscillator::s_specBuf = ( fftwf_complex * ) fftwf_malloc( ( OscillatorConstants::WAVETABLE_LENGTH * 2 + 1 ) * sizeof( fftwf_complex ) ); - Oscillator::s_fftPlan = fftwf_plan_dft_r2c_1d(OscillatorConstants::WAVETABLE_LENGTH, s_sampleBuffer, s_specBuf, FFTW_MEASURE ); - Oscillator::s_ifftPlan = fftwf_plan_dft_c2r_1d(OscillatorConstants::WAVETABLE_LENGTH, s_specBuf, s_sampleBuffer, FFTW_MEASURE); + Oscillator::s_fftPlan = fftwf_plan_dft_r2c_1d(OscillatorConstants::WAVETABLE_LENGTH, s_sampleBuffer.data(), s_specBuf, FFTW_MEASURE ); + Oscillator::s_ifftPlan = fftwf_plan_dft_c2r_1d(OscillatorConstants::WAVETABLE_LENGTH, s_specBuf, s_sampleBuffer.data(), FFTW_MEASURE); // initialize s_specBuf content to zero, since the values are used in a condition inside generateFromFFT() for (int i = 0; i < OscillatorConstants::WAVETABLE_LENGTH * 2 + 1; i++) { @@ -231,7 +234,7 @@ void Oscillator::generateWaveTables() // Generate tables for simple shaped (constructed by summing sine waves). // Start from the table that contains the least number of bands, and re-use each table in the following // iteration, adding more bands in each step and avoiding repeated computation of earlier bands. - typedef void (*generator_t)(int, sample_t*, int); + using generator_t = void (*)(int, sample_t*, int); auto simpleGen = [](WaveShapes shape, generator_t generator) { const int shapeID = shape - FirstWaveShapeTable; @@ -814,4 +817,4 @@ inline sample_t Oscillator::getSample( } - +} // namespace lmms diff --git a/src/core/PathUtil.cpp b/src/core/PathUtil.cpp index 24d9c8992..03ec465a9 100644 --- a/src/core/PathUtil.cpp +++ b/src/core/PathUtil.cpp @@ -7,9 +7,9 @@ #include "Engine.h" #include "Song.h" -namespace PathUtil +namespace lmms::PathUtil { - Base relativeBases[] = { Base::ProjectDir, Base::FactorySample, Base::UserSample, Base::UserVST, Base::Preset, + auto relativeBases = std::array{ Base::ProjectDir, Base::FactorySample, Base::UserSample, Base::UserVST, Base::Preset, Base::UserLADSPA, Base::DefaultLADSPA, Base::UserSoundfont, Base::DefaultSoundfont, Base::UserGIG, Base::DefaultGIG, Base::LocalDir }; @@ -121,7 +121,7 @@ namespace PathUtil //Check if it's a factory sample QString factoryPath = baseLocation(Base::FactorySample) + input; QFileInfo factoryInfo(factoryPath); - if (factoryInfo.exists()) { assumedBase = Base::FactorySample; } + if (factoryInfo.exists()) { assumedBase = Base::FactorySample; } //Check if it's a VST QString vstPath = baseLocation(Base::UserVST) + input; @@ -187,4 +187,5 @@ namespace PathUtil } return basePrefix(shortestBase) + relativeOrAbsolute(absolutePath, shortestBase); } -} + +} // namespace lmms::PathUtil diff --git a/src/core/PatternClip.cpp b/src/core/PatternClip.cpp index d88ef5224..9af9bda6a 100644 --- a/src/core/PatternClip.cpp +++ b/src/core/PatternClip.cpp @@ -31,6 +31,9 @@ #include "PatternStore.h" #include "PatternTrack.h" +namespace lmms +{ + PatternClip::PatternClip(Track* track) : Clip(track) @@ -80,19 +83,20 @@ void PatternClip::loadSettings(const QDomElement& element) toggleMute(); } - // for colors saved in 1.3-onwards - if( element.hasAttribute( "color" ) && !element.hasAttribute( "usestyle" ) ) + if (element.hasAttribute("color")) { - useCustomClipColor( true ); - setColor( element.attribute( "color" ) ); - } - - // for colors saved before 1.3 - else if(element.hasAttribute("color")) - { - setColor(QColor(element.attribute("color").toUInt())); - - // usestyle attribute is no longer used + if (!element.hasAttribute("usestyle")) + { + // for colors saved in 1.3-onwards + setColor(element.attribute("color")); + useCustomClipColor(true); + } + else + { + // for colors saved before 1.3 + setColor(QColor(element.attribute("color").toUInt())); + useCustomClipColor(element.attribute("usestyle").toUInt() == 0); + } } else { @@ -109,7 +113,10 @@ int PatternClip::patternIndex() -ClipView* PatternClip::createView(TrackView* tv) +gui::ClipView* PatternClip::createView(gui::TrackView* tv) { - return new PatternClipView(this, tv); + return new gui::PatternClipView(this, tv); } + + +} // namespace lmms diff --git a/src/core/PatternStore.cpp b/src/core/PatternStore.cpp index c16726777..f91c42b72 100644 --- a/src/core/PatternStore.cpp +++ b/src/core/PatternStore.cpp @@ -30,6 +30,8 @@ #include "PatternTrack.h" #include "Song.h" +namespace lmms +{ PatternStore::PatternStore() : @@ -48,13 +50,6 @@ PatternStore::PatternStore() : -PatternStore::~PatternStore() -{ -} - - - - bool PatternStore::play(TimePos start, fpp_t frames, f_cnt_t offset, int clipNum) { bool notePlayed = false; @@ -257,3 +252,5 @@ AutomatedValueMap PatternStore::automatedValuesAt(TimePos time, int clipNum) con return TrackContainer::automatedValuesAt(time + (TimePos::ticksPerBar() * clipNum), clipNum); } + +} // namespace lmms \ No newline at end of file diff --git a/src/core/PeakController.cpp b/src/core/PeakController.cpp index c46123507..a9215325e 100644 --- a/src/core/PeakController.cpp +++ b/src/core/PeakController.cpp @@ -34,6 +34,10 @@ #include "EffectChain.h" #include "plugins/PeakControllerEffect/PeakControllerEffect.h" +namespace lmms +{ + + PeakControllerEffectVector PeakController::s_effects; int PeakController::m_getCount; int PeakController::m_loadCount; @@ -49,14 +53,14 @@ PeakController::PeakController( Model * _parent, setSampleExact( true ); if( m_peakEffect ) { - connect( m_peakEffect, SIGNAL( destroyed( ) ), - this, SLOT( handleDestroyedEffect( ) ) ); + connect( m_peakEffect, SIGNAL(destroyed()), + this, SLOT(handleDestroyedEffect())); } - connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( updateCoeffs() ) ); - connect( m_peakEffect->attackModel(), SIGNAL( dataChanged() ), - this, SLOT( updateCoeffs() ), Qt::DirectConnection ); - connect( m_peakEffect->decayModel(), SIGNAL( dataChanged() ), - this, SLOT( updateCoeffs() ), Qt::DirectConnection ); + connect( Engine::audioEngine(), SIGNAL(sampleRateChanged()), this, SLOT(updateCoeffs())); + connect( m_peakEffect->attackModel(), SIGNAL(dataChanged()), + this, SLOT(updateCoeffs()), Qt::DirectConnection ); + connect( m_peakEffect->decayModel(), SIGNAL(dataChanged()), + this, SLOT(updateCoeffs()), Qt::DirectConnection ); m_coeffNeedsUpdate = true; } @@ -123,7 +127,7 @@ void PeakController::updateCoeffs() } -void PeakController::handleDestroyedEffect( ) +void PeakController::handleDestroyedEffect() { // possible race condition... //printf("disconnecting effect\n"); @@ -247,11 +251,10 @@ QString PeakController::nodeName() const -ControllerDialog * PeakController::createDialog( QWidget * _parent ) +gui::ControllerDialog * PeakController::createDialog( QWidget * _parent ) { - return new PeakControllerDialog( this, _parent ); + return new gui::PeakControllerDialog( this, _parent ); } - - +} // namespace lmms diff --git a/src/core/PerfLog.cpp b/src/core/PerfLog.cpp index 951c6d842..490567448 100644 --- a/src/core/PerfLog.cpp +++ b/src/core/PerfLog.cpp @@ -35,6 +35,11 @@ # include #endif + +namespace lmms +{ + + PerfTime::PerfTime() : m_real(-1) { @@ -129,3 +134,6 @@ void PerfLogTimer::end() // Invalidate so destructor won't call print another log entry begin_time = PerfTime(); } + + +} // namespace lmms \ No newline at end of file diff --git a/src/core/Piano.cpp b/src/core/Piano.cpp index 62680efa7..82323526e 100644 --- a/src/core/Piano.cpp +++ b/src/core/Piano.cpp @@ -41,9 +41,13 @@ #include "InstrumentTrack.h" +namespace lmms +{ + + /*! The black / white order of keys as they appear on the keyboard. */ -static const Piano::KeyTypes KEY_ORDER[] = +static const auto KEY_ORDER = std::array { // C CIS D DIS Piano::WhiteKey, Piano::BlackKey, Piano::WhiteKey, Piano::BlackKey, @@ -58,16 +62,11 @@ static const Piano::KeyTypes KEY_ORDER[] = * * \param _it the InstrumentTrack window to attach to */ -Piano::Piano( InstrumentTrack* track ) : - Model( nullptr ), /*!< base class ctor */ - m_instrumentTrack( track ), - m_midiEvProc( track ) /*!< the InstrumentTrack Model */ +Piano::Piano(InstrumentTrack* track) : + Model(nullptr), /*!< base class ctor */ + m_instrumentTrack(track), + m_midiEvProc(track) /*!< the InstrumentTrack Model */ { - for( int i = 0; i < NumKeys; ++i ) - { - m_pressedKeys[i] = false; - } - } /*! \brief Turn a key on or off @@ -75,9 +74,9 @@ Piano::Piano( InstrumentTrack* track ) : * \param key the key number to change * \param state the state to set the key to */ -void Piano::setKeyState( int key, bool state ) +void Piano::setKeyState(int key, bool state) { - if( isValidKey( key ) ) + if (isValidKey(key)) { m_pressedKeys[key] = state; @@ -92,15 +91,15 @@ void Piano::setKeyState( int key, bool state ) * * \param key the key being pressed */ -void Piano::handleKeyPress( int key, int midiVelocity ) +void Piano::handleKeyPress(int key, int midiVelocity) { - if( midiVelocity == -1 ) + if (midiVelocity == -1) { midiVelocity = m_instrumentTrack->midiPort()->baseVelocity(); } - if( isValidKey( key ) ) + if (isValidKey(key)) { - m_midiEvProc->processInEvent( MidiEvent( MidiNoteOn, -1, key, midiVelocity ) ); + m_midiEvProc->processInEvent(MidiEvent(MidiNoteOn, -1, key, midiVelocity)); m_pressedKeys[key] = true; } } @@ -113,18 +112,18 @@ void Piano::handleKeyPress( int key, int midiVelocity ) * * \param key the key being releassed */ -void Piano::handleKeyRelease( int key ) +void Piano::handleKeyRelease(int key) { - if( isValidKey( key ) ) + if (isValidKey(key)) { - m_midiEvProc->processInEvent( MidiEvent( MidiNoteOff, -1, key, 0 ) ); + m_midiEvProc->processInEvent(MidiEvent(MidiNoteOff, -1, key, 0)); m_pressedKeys[key] = false; } } -bool Piano::isBlackKey( int key ) +bool Piano::isBlackKey(int key) { int keyCode = key % KeysPerOctave; @@ -132,8 +131,10 @@ bool Piano::isBlackKey( int key ) } -bool Piano::isWhiteKey( int key ) +bool Piano::isWhiteKey(int key) { - return !isBlackKey( key ); + return !isBlackKey(key); } + +} // namespace lmms \ No newline at end of file diff --git a/src/core/PlayHandle.cpp b/src/core/PlayHandle.cpp index 1c5f90ef0..168121e0f 100644 --- a/src/core/PlayHandle.cpp +++ b/src/core/PlayHandle.cpp @@ -30,6 +30,9 @@ #include +namespace lmms +{ + PlayHandle::PlayHandle(const Type type, f_cnt_t offset) : m_type(type), m_offset(offset), @@ -71,3 +74,5 @@ sampleFrame* PlayHandle::buffer() { return m_bufferReleased ? nullptr : reinterpret_cast(m_playHandleBuffer); }; + +} // namespace lmms \ No newline at end of file diff --git a/src/core/Plugin.cpp b/src/core/Plugin.cpp index 7772bffde..edc183c23 100644 --- a/src/core/Plugin.cpp +++ b/src/core/Plugin.cpp @@ -35,6 +35,10 @@ #include "DummyPlugin.h" #include "AutomatableModel.h" #include "Song.h" +#include "PluginFactory.h" + +namespace lmms +{ static PixmapLoader dummyLoader; @@ -70,13 +74,6 @@ Plugin::Plugin(const Descriptor * descriptor, Model * parent, const -Plugin::~Plugin() -{ -} - - - - template T use_this_or(T this_param, T or_param) { @@ -183,7 +180,6 @@ AutomatableModel * Plugin::childModel( const QString & ) -#include "PluginFactory.h" Plugin * Plugin::instantiateWithKey(const QString& pluginName, Model * parent, const Descriptor::SubPluginFeatures::Key *key, bool keyFromDnd) @@ -218,7 +214,7 @@ Plugin * Plugin::instantiate(const QString& pluginName, Model * parent, Plugin* inst; if( pi.isNull() ) { - if( getGUI() != nullptr ) + if (gui::getGUI() != nullptr) { QMessageBox::information( nullptr, tr( "Plugin not found" ), @@ -240,7 +236,7 @@ Plugin * Plugin::instantiate(const QString& pluginName, Model * parent, } else { - if( getGUI() != nullptr ) + if (gui::getGUI() != nullptr) { QMessageBox::information( nullptr, tr( "Error while loading plugin" ), @@ -265,9 +261,9 @@ void Plugin::collectErrorForUI( QString errMsg ) -PluginView * Plugin::createView( QWidget * parent ) +gui::PluginView * Plugin::createView( QWidget * parent ) { - PluginView * pv = instantiateView( parent ); + gui::PluginView * pv = instantiateView( parent ); if( pv != nullptr ) { pv->setModel( this ); @@ -312,3 +308,4 @@ QDomElement Plugin::Descriptor::SubPluginFeatures::Key::saveXML( +} // namespace lmms diff --git a/src/core/PluginFactory.cpp b/src/core/PluginFactory.cpp index 879af542c..81a6122d1 100644 --- a/src/core/PluginFactory.cpp +++ b/src/core/PluginFactory.cpp @@ -34,17 +34,22 @@ #include "ConfigManager.h" #include "Plugin.h" +// QT qHash specialization, needs to be in global namespace +qint64 qHash(const QFileInfo& fi) +{ + return qHash(fi.absoluteFilePath()); +} + +namespace lmms +{ + + #ifdef LMMS_BUILD_WIN32 QStringList nameFilters("*.dll"); #else QStringList nameFilters("lib*.so"); #endif -qint64 qHash(const QFileInfo& fi) -{ - return qHash(fi.absoluteFilePath()); -} - std::unique_ptr PluginFactory::s_instance; PluginFactory::PluginFactory() @@ -53,10 +58,6 @@ PluginFactory::PluginFactory() discoverPlugins(); } -PluginFactory::~PluginFactory() -{ -} - void PluginFactory::setupSearchPaths() { // Adds a search path relative to the main executable if the path exists. @@ -251,3 +252,6 @@ const QString PluginFactory::PluginInfo::name() const { return descriptor ? descriptor->name : QString(); } + + +} // namespace lmms diff --git a/src/core/PluginIssue.cpp b/src/core/PluginIssue.cpp index 7d43586f5..f8ae06bc7 100644 --- a/src/core/PluginIssue.cpp +++ b/src/core/PluginIssue.cpp @@ -26,6 +26,10 @@ #include "PluginIssue.h" +namespace lmms +{ + + const char *PluginIssue::msgFor(const PluginIssueType &it) { switch (it) @@ -91,8 +95,6 @@ bool PluginIssue::operator<(const PluginIssue &other) const } - - QDebug operator<<(QDebug stream, const PluginIssue &iss) { stream << PluginIssue::msgFor(iss.m_issueType); @@ -103,4 +105,7 @@ QDebug operator<<(QDebug stream, const PluginIssue &iss) return stream; } +} // namespace lmms + + diff --git a/src/core/PresetPreviewPlayHandle.cpp b/src/core/PresetPreviewPlayHandle.cpp index a0e5da445..6a5b86424 100644 --- a/src/core/PresetPreviewPlayHandle.cpp +++ b/src/core/PresetPreviewPlayHandle.cpp @@ -35,6 +35,9 @@ #include +namespace lmms +{ + // invisible track-container which is needed as parent for preview-channels class PreviewTrackContainer : public TrackContainer { @@ -50,9 +53,7 @@ public: m_previewInstrumentTrack->setPreviewMode( true ); } - virtual ~PreviewTrackContainer() - { - } + ~PreviewTrackContainer() override = default; QString nodeName() const override { @@ -274,4 +275,4 @@ bool PresetPreviewPlayHandle::isPreviewing() } - +} // namespace lmms diff --git a/src/core/ProjectJournal.cpp b/src/core/ProjectJournal.cpp index 3d1e9078a..bc1fee5c0 100644 --- a/src/core/ProjectJournal.cpp +++ b/src/core/ProjectJournal.cpp @@ -29,6 +29,9 @@ #include "JournallingObject.h" #include "Song.h" +namespace lmms +{ + //! Avoid clashes between loaded IDs (have the bit cleared) //! and newly created IDs (have the bit set) static const int EO_ID_MSB = 1 << 23; @@ -46,13 +49,6 @@ ProjectJournal::ProjectJournal() : -ProjectJournal::~ProjectJournal() -{ -} - - - - void ProjectJournal::undo() { while( !m_undoCheckPoints.isEmpty() ) @@ -206,3 +202,4 @@ void ProjectJournal::stopAllJournalling() +} // namespace lmms diff --git a/src/core/ProjectRenderer.cpp b/src/core/ProjectRenderer.cpp index 323fdd6c9..da6c729c8 100644 --- a/src/core/ProjectRenderer.cpp +++ b/src/core/ProjectRenderer.cpp @@ -34,18 +34,23 @@ #include "AudioFileMP3.h" #include "AudioFileFlac.h" -const ProjectRenderer::FileEncodeDevice ProjectRenderer::fileEncodeDevices[] = + +namespace lmms { - { ProjectRenderer::WaveFile, + +const std::array ProjectRenderer::fileEncodeDevices +{ + + FileEncodeDevice{ ProjectRenderer::WaveFile, QT_TRANSLATE_NOOP( "ProjectRenderer", "WAV (*.wav)" ), ".wav", &AudioFileWave::getInst }, - { ProjectRenderer::FlacFile, + FileEncodeDevice{ ProjectRenderer::FlacFile, QT_TRANSLATE_NOOP("ProjectRenderer", "FLAC (*.flac)"), ".flac", &AudioFileFlac::getInst }, - { ProjectRenderer::OggFile, + FileEncodeDevice{ ProjectRenderer::OggFile, QT_TRANSLATE_NOOP( "ProjectRenderer", "OGG (*.ogg)" ), ".ogg", #ifdef LMMS_HAVE_OGGVORBIS @@ -54,7 +59,7 @@ const ProjectRenderer::FileEncodeDevice ProjectRenderer::fileEncodeDevices[] = nullptr #endif }, - { ProjectRenderer::MP3File, + FileEncodeDevice{ ProjectRenderer::MP3File, QT_TRANSLATE_NOOP( "ProjectRenderer", "MP3 (*.mp3)" ), ".mp3", #ifdef LMMS_HAVE_MP3LAME @@ -66,7 +71,7 @@ const ProjectRenderer::FileEncodeDevice ProjectRenderer::fileEncodeDevices[] = // Insert your own file-encoder infos here. // Maybe one day the user can add own encoders inside the program. - { ProjectRenderer::NumFileFormats, nullptr, nullptr, nullptr } + FileEncodeDevice{ ProjectRenderer::NumFileFormats, nullptr, nullptr, nullptr } } ; @@ -103,13 +108,6 @@ ProjectRenderer::ProjectRenderer( const AudioEngine::qualitySettings & qualitySe -ProjectRenderer::~ProjectRenderer() -{ -} - - - - // Little help function for getting file format from a file extension // (only for registered file-encoders). ProjectRenderer::ExportFileFormats ProjectRenderer::getFileFormatFromExtension( @@ -226,8 +224,8 @@ void ProjectRenderer::updateConsoleProgress() { const int cols = 50; static int rot = 0; - char buf[80]; - char prog[cols+1]; + auto buf = std::array{}; + auto prog = std::array{}; for( int i = 0; i < cols; ++i ) { @@ -235,14 +233,15 @@ void ProjectRenderer::updateConsoleProgress() } prog[cols] = 0; - const char * activity = (const char *) "|/-\\"; - memset( buf, 0, sizeof( buf ) ); - sprintf( buf, "\r|%s| %3d%% %c ", prog, m_progress, + const auto activity = (const char*)"|/-\\"; + std::fill(buf.begin(), buf.end(), 0); + sprintf(buf.data(), "\r|%s| %3d%% %c ", prog.data(), m_progress, activity[rot] ); rot = ( rot+1 ) % 4; - fprintf( stderr, "%s", buf ); + fprintf( stderr, "%s", buf.data() ); fflush( stderr ); } +} // namespace lmms diff --git a/src/core/ProjectVersion.cpp b/src/core/ProjectVersion.cpp index 6f3dcddbe..b6ee2843f 100644 --- a/src/core/ProjectVersion.cpp +++ b/src/core/ProjectVersion.cpp @@ -28,6 +28,8 @@ #include "ProjectVersion.h" +namespace lmms +{ ProjectVersion::ProjectVersion(QString version, CompareType c) : @@ -135,3 +137,6 @@ int ProjectVersion::compare(ProjectVersion v1, ProjectVersion v2) { return compare(v1, v2, std::min(v1.getCompareType(), v2.getCompareType())); } + + +} // namespace lmms \ No newline at end of file diff --git a/src/core/RemotePlugin.cpp b/src/core/RemotePlugin.cpp index a70ce0a31..14c6f3f32 100644 --- a/src/core/RemotePlugin.cpp +++ b/src/core/RemotePlugin.cpp @@ -36,6 +36,7 @@ #include "BufferManager.h" #include "AudioEngine.h" #include "Engine.h" +#include "Song.h" #include #include @@ -71,6 +72,9 @@ HANDLE getRemotePluginJob() #endif // LMMS_BUILD_WIN32 +namespace lmms +{ + // simple helper thread monitoring our RemotePlugin - if process terminates // unexpectedly invalidate plugin so LMMS doesn't lock up ProcessWatcher::ProcessWatcher( RemotePlugin * _p ) : @@ -135,7 +139,9 @@ RemotePlugin::RemotePlugin() : #endif m_failed( true ), m_watcher( this ), - m_commMutex( QMutex::Recursive ), +#if (QT_VERSION < QT_VERSION_CHECK(5,14,0)) + m_commMutex(QMutex::Recursive), +#endif m_splitChannels( false ), m_audioBufferSize( 0 ), m_inputCount( DEFAULT_CHANNELS ), @@ -170,14 +176,14 @@ RemotePlugin::RemotePlugin() : } #endif - connect( &m_process, SIGNAL( finished( int, QProcess::ExitStatus ) ), - this, SLOT( processFinished( int, QProcess::ExitStatus ) ), + connect( &m_process, SIGNAL(finished(int,QProcess::ExitStatus)), + this, SLOT(processFinished(int,QProcess::ExitStatus)), Qt::DirectConnection ); - connect( &m_process, SIGNAL( errorOccurred( QProcess::ProcessError ) ), - this, SLOT( processErrored( QProcess::ProcessError ) ), + connect( &m_process, SIGNAL(errorOccurred(QProcess::ProcessError)), + this, SLOT(processErrored(QProcess::ProcessError)), Qt::DirectConnection ); - connect( &m_process, SIGNAL( finished( int, QProcess::ExitStatus ) ), - &m_watcher, SLOT( quit() ), Qt::DirectConnection ); + connect( &m_process, SIGNAL(finished(int,QProcess::ExitStatus)), + &m_watcher, SLOT(quit()), Qt::DirectConnection ); } @@ -304,6 +310,7 @@ bool RemotePlugin::init(const QString &pluginExecutable, } #endif + sendMessage(message(IdSyncKey).addString(Engine::getSong()->syncKey())); resizeSharedProcessingMemory(); if( waitForInitDoneMsg ) @@ -373,7 +380,7 @@ bool RemotePlugin::process( const sampleFrame * _in_buf, sampleFrame * _out_buf } else { - sampleFrame * o = (sampleFrame *) m_audioBuffer.get(); + auto o = (sampleFrame*)m_audioBuffer.get(); for( ch_cnt_t ch = 0; ch < inputs; ++ch ) { for( fpp_t frame = 0; frame < frames; ++frame ) @@ -416,8 +423,7 @@ bool RemotePlugin::process( const sampleFrame * _in_buf, sampleFrame * _out_buf } else { - sampleFrame * o = (sampleFrame *) ( m_audioBuffer.get() + - m_inputCount*frames ); + auto o = (sampleFrame*)(m_audioBuffer.get() + m_inputCount * frames); // clear buffer, if plugin didn't fill up both channels BufferManager::clear( _out_buf, frames ); @@ -571,3 +577,6 @@ bool RemotePlugin::processMessage( const message & _m ) return true; } + + +} // namespace lmms diff --git a/src/core/RenderManager.cpp b/src/core/RenderManager.cpp index a0de888f4..56b4ce9d7 100644 --- a/src/core/RenderManager.cpp +++ b/src/core/RenderManager.cpp @@ -30,6 +30,10 @@ #include "Song.h" +namespace lmms +{ + + RenderManager::RenderManager( const AudioEngine::qualitySettings & qualitySettings, const OutputSettings & outputSettings, @@ -53,8 +57,8 @@ RenderManager::~RenderManager() void RenderManager::abortProcessing() { if ( m_activeRenderer ) { - disconnect( m_activeRenderer.get(), SIGNAL( finished() ), - this, SLOT( renderNextTrack() ) ); + disconnect( m_activeRenderer.get(), SIGNAL(finished()), + this, SLOT(renderNextTrack())); m_activeRenderer->abortProcessing(); } restoreMutedState(); @@ -96,9 +100,8 @@ void RenderManager::renderTracks() const TrackContainer::TrackList & tl = Engine::getSong()->tracks(); // find all currently unnmuted tracks -- we want to render these. - for( auto it = tl.begin(); it != tl.end(); ++it ) + for (const auto& tk : tl) { - Track* tk = (*it); Track::TrackTypes type = tk->type(); // Don't render automation tracks @@ -110,9 +113,8 @@ void RenderManager::renderTracks() } const TrackContainer::TrackList t2 = Engine::patternStore()->tracks(); - for( auto it = t2.begin(); it != t2.end(); ++it ) + for (const auto& tk : t2) { - Track* tk = (*it); Track::TrackTypes type = tk->type(); // Don't render automation tracks @@ -147,13 +149,13 @@ void RenderManager::render(QString outputPath) if( m_activeRenderer->isReady() ) { // pass progress signals through - connect( m_activeRenderer.get(), SIGNAL( progressChanged( int ) ), - this, SIGNAL( progressChanged( int ) ) ); + connect( m_activeRenderer.get(), SIGNAL(progressChanged(int)), + this, SIGNAL(progressChanged(int))); // when it is finished, render the next track. // if we have not queued any tracks, renderNextTrack will just clean up - connect( m_activeRenderer.get(), SIGNAL( finished() ), - this, SLOT( renderNextTrack() ) ); + connect( m_activeRenderer.get(), SIGNAL(finished()), + this, SLOT(renderNextTrack())); m_activeRenderer->startProcessing(); } @@ -200,3 +202,6 @@ void RenderManager::updateConsoleProgress() } } } + + +} // namespace lmms \ No newline at end of file diff --git a/src/core/RingBuffer.cpp b/src/core/RingBuffer.cpp index 3fe1feeb7..3f1ee7236 100644 --- a/src/core/RingBuffer.cpp +++ b/src/core/RingBuffer.cpp @@ -28,6 +28,9 @@ #include "Engine.h" #include "MixHelpers.h" +namespace lmms +{ + RingBuffer::RingBuffer( f_cnt_t size ) : m_fpp( Engine::audioEngine()->framesPerPeriod() ), @@ -88,11 +91,11 @@ void RingBuffer::setSamplerateAware( bool b ) { if( b ) { - connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( updateSamplerate() ), Qt::UniqueConnection ); + connect( Engine::audioEngine(), SIGNAL(sampleRateChanged()), this, SLOT(updateSamplerate()), Qt::UniqueConnection ); } else { - disconnect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( updateSamplerate() ) ); + disconnect( Engine::audioEngine(), SIGNAL(sampleRateChanged()), this, SLOT(updateSamplerate())); } } @@ -314,3 +317,4 @@ void RingBuffer::updateSamplerate() } +} // namespace lmms diff --git a/src/core/SampleBuffer.cpp b/src/core/SampleBuffer.cpp index e09dd5198..677366fdb 100644 --- a/src/core/SampleBuffer.cpp +++ b/src/core/SampleBuffer.cpp @@ -61,6 +61,8 @@ #include "FileDialog.h" +namespace lmms +{ SampleBuffer::SampleBuffer() : m_userAntiAliasWaveTable(nullptr), @@ -367,7 +369,7 @@ void SampleBuffer::update(bool keepSettings) QString message = tr("Audio files are limited to %1 MB " "in size and %2 minutes of playing time" ).arg(fileSizeMax).arg(sampleLengthMax); - if (getGUI() != nullptr) + if (gui::getGUI() != nullptr) { QMessageBox::information(nullptr, title, message, QMessageBox::Ok); @@ -536,7 +538,7 @@ size_t qfileReadCallback(void * ptr, size_t size, size_t n, void * udata ) int qfileSeekCallback(void * udata, ogg_int64_t offset, int whence) { - QFile * f = static_cast(udata); + auto f = static_cast(udata); if (whence == SEEK_CUR) { @@ -592,7 +594,7 @@ f_cnt_t SampleBuffer::decodeSampleOGGVorbis( f_cnt_t frames = 0; - QFile * f = new QFile(fileName); + auto f = new QFile(fileName); if (f->open(QFile::ReadOnly) == false) { delete f; @@ -670,7 +672,7 @@ f_cnt_t SampleBuffer::decodeSampleOGGVorbis( return frames; } -#endif +#endif // LMMS_HAVE_OGGVORBIS @@ -725,9 +727,7 @@ bool SampleBuffer::play( m_sampleRate / Engine::audioEngine()->processingSampleRate(); // calculate how many frames we have in requested pitch - const f_cnt_t totalFramesForCurrentPitch = static_cast( - (endFrame - startFrame) / freqFactor - ); + const auto totalFramesForCurrentPitch = static_cast((endFrame - startFrame) / freqFactor); if (totalFramesForCurrentPitch == 0) { @@ -1067,7 +1067,7 @@ void SampleBuffer::visualize( float maxData = -1; float minData = 1; - float rmsData[2] = {0, 0}; + auto rmsData = std::array{}; // Find maximum and minimum samples within range for (int i = 0; i < fpp && frame + i <= last; ++i) @@ -1121,7 +1121,7 @@ void SampleBuffer::visualize( QString SampleBuffer::openAudioFile() const { - FileDialog ofd(nullptr, tr("Open audio file")); + gui::FileDialog ofd(nullptr, tr("Open audio file")); QString dir; if (!m_audioFile.isEmpty()) @@ -1144,7 +1144,7 @@ QString SampleBuffer::openAudioFile() const } // change dir to position of previously opened file ofd.setDirectory(dir); - ofd.setFileMode(FileDialog::ExistingFiles); + ofd.setFileMode(gui::FileDialog::ExistingFiles); // set filters QStringList types; @@ -1256,7 +1256,7 @@ void flacStreamEncoderMetadataCallback( b->write((const char *) metadata, sizeof(*metadata)); } -#endif +#endif // LMMS_HAVE_FLAC_STREAM_ENCODER_H @@ -1312,12 +1312,12 @@ QString & SampleBuffer::toBase64(QString & dst) const base64::encode(baWriter.buffer().data(), baWriter.buffer().size(), dst); -#else /* LMMS_HAVE_FLAC_STREAM_ENCODER_H */ +#else // LMMS_HAVE_FLAC_STREAM_ENCODER_H base64::encode((const char *) m_data, m_frames * sizeof(sampleFrame), dst); -#endif /* LMMS_HAVE_FLAC_STREAM_ENCODER_H */ +#endif // LMMS_HAVE_FLAC_STREAM_ENCODER_H return dst; } @@ -1329,8 +1329,8 @@ SampleBuffer * SampleBuffer::resample(const sample_rate_t srcSR, const sample_ra { sampleFrame * data = m_data; const f_cnt_t frames = m_frames; - const f_cnt_t dstFrames = static_cast((frames / (float) srcSR) * (float) dstSR); - SampleBuffer * dstSB = new SampleBuffer(dstFrames); + const auto dstFrames = static_cast((frames / (float)srcSR) * (float)dstSR); + auto dstSB = new SampleBuffer(dstFrames); sampleFrame * dstBuf = dstSB->m_origData; // yeah, libsamplerate, let's rock with sinc-interpolation! @@ -1459,7 +1459,7 @@ void flacStreamDecoderErrorCallback( // what to do now?? } -#endif +#endif // LMMS_HAVE_FLAC_STREAM_DECODER_H void SampleBuffer::loadFromBase64(const QString & data) @@ -1515,7 +1515,7 @@ void SampleBuffer::loadFromBase64(const QString & data) m_origData = MM_ALLOC( m_origFrames); memcpy(m_origData, dst, dsize); -#endif +#endif // LMMS_HAVE_FLAC_STREAM_DECODER_H delete[] dst; @@ -1587,3 +1587,5 @@ SampleBuffer::handleState::~handleState() { src_delete(m_resamplingData); } + +} // namespace lmms diff --git a/src/core/SampleClip.cpp b/src/core/SampleClip.cpp index 46bb6e6b7..6396d49f3 100644 --- a/src/core/SampleClip.cpp +++ b/src/core/SampleClip.cpp @@ -31,6 +31,11 @@ #include "SampleTrack.h" #include "TimeLineWidget.h" + +namespace lmms +{ + + SampleClip::SampleClip( Track * _track ) : Clip( _track ), m_sampleBuffer( new SampleBuffer ), @@ -42,30 +47,30 @@ SampleClip::SampleClip( Track * _track ) : // we need to receive bpm-change-events, because then we have to // change length of this Clip - connect( Engine::getSong(), SIGNAL( tempoChanged( bpm_t ) ), - this, SLOT( updateLength() ), Qt::DirectConnection ); - connect( Engine::getSong(), SIGNAL( timeSignatureChanged( int,int ) ), - this, SLOT( updateLength() ) ); + connect( Engine::getSong(), SIGNAL(tempoChanged(lmms::bpm_t)), + this, SLOT(updateLength()), Qt::DirectConnection ); + connect( Engine::getSong(), SIGNAL(timeSignatureChanged(int,int)), + this, SLOT(updateLength())); //care about positionmarker - TimeLineWidget * timeLine = Engine::getSong()->getPlayPos( Engine::getSong()->Mode_PlaySong ).m_timeLine; + gui::TimeLineWidget* timeLine = Engine::getSong()->getPlayPos( Engine::getSong()->Mode_PlaySong ).m_timeLine; if( timeLine ) { - connect( timeLine, SIGNAL( positionMarkerMoved() ), this, SLOT( playbackPositionChanged() ) ); + connect( timeLine, SIGNAL(positionMarkerMoved()), this, SLOT(playbackPositionChanged())); } //playbutton clicked or space key / on Export Song set isPlaying to false - connect( Engine::getSong(), SIGNAL( playbackStateChanged() ), - this, SLOT( playbackPositionChanged() ), Qt::DirectConnection ); + connect( Engine::getSong(), SIGNAL(playbackStateChanged()), + this, SLOT(playbackPositionChanged()), Qt::DirectConnection ); //care about loops - connect( Engine::getSong(), SIGNAL( updateSampleTracks() ), - this, SLOT( playbackPositionChanged() ), Qt::DirectConnection ); + connect( Engine::getSong(), SIGNAL(updateSampleTracks()), + this, SLOT(playbackPositionChanged()), Qt::DirectConnection ); //care about mute Clips - connect( this, SIGNAL( dataChanged() ), this, SLOT( playbackPositionChanged() ) ); + connect( this, SIGNAL(dataChanged()), this, SLOT(playbackPositionChanged())); //care about mute track - connect( getTrack()->getMutedModel(), SIGNAL( dataChanged() ), - this, SLOT( playbackPositionChanged() ), Qt::DirectConnection ); + connect( getTrack()->getMutedModel(), SIGNAL(dataChanged()), + this, SLOT(playbackPositionChanged()), Qt::DirectConnection ); //care about Clip position - connect( this, SIGNAL( positionChanged() ), this, SLOT( updateTrackClips() ) ); + connect( this, SIGNAL(positionChanged()), this, SLOT(updateTrackClips())); switch( getTrack()->trackContainer()->type() ) { @@ -97,7 +102,7 @@ SampleClip::SampleClip(const SampleClip& orig) : SampleClip::~SampleClip() { - SampleTrack * sampletrack = dynamic_cast( getTrack() ); + auto sampletrack = dynamic_cast(getTrack()); if ( sampletrack ) { sampletrack->updateClips(); @@ -175,7 +180,7 @@ void SampleClip::toggleRecord() void SampleClip::playbackPositionChanged() { Engine::audioEngine()->removePlayHandlesOfTypes( getTrack(), PlayHandle::TypeSamplePlayHandle ); - SampleTrack * st = dynamic_cast( getTrack() ); + auto st = dynamic_cast(getTrack()); st->setPlayingClips( false ); } @@ -184,7 +189,7 @@ void SampleClip::playbackPositionChanged() void SampleClip::updateTrackClips() { - SampleTrack * sampletrack = dynamic_cast( getTrack() ); + auto sampletrack = dynamic_cast(getTrack()); if( sampletrack) { sampletrack->updateClips(); @@ -287,15 +292,15 @@ void SampleClip::loadSettings( const QDomElement & _this ) if( sampleFile().isEmpty() && _this.hasAttribute( "data" ) ) { m_sampleBuffer->loadFromBase64( _this.attribute( "data" ) ); + if (_this.hasAttribute("sample_rate")) + { + m_sampleBuffer->setSampleRate(_this.attribute("sample_rate").toInt()); + } } changeLength( _this.attribute( "len" ).toInt() ); setMuted( _this.attribute( "muted" ).toInt() ); setStartTimeOffset( _this.attribute( "off" ).toInt() ); - if ( _this.hasAttribute( "sample_rate" ) ) { - m_sampleBuffer->setSampleRate( _this.attribute( "sample_rate" ).toInt() ); - } - if( _this.hasAttribute( "color" ) ) { useCustomClipColor( true ); @@ -316,7 +321,10 @@ void SampleClip::loadSettings( const QDomElement & _this ) -ClipView * SampleClip::createView( TrackView * _tv ) +gui::ClipView * SampleClip::createView( gui::TrackView * _tv ) { - return new SampleClipView( this, _tv ); + return new gui::SampleClipView( this, _tv ); } + + +} // namespace lmms diff --git a/src/core/SamplePlayHandle.cpp b/src/core/SamplePlayHandle.cpp index f82f5dbf4..77658e1d8 100644 --- a/src/core/SamplePlayHandle.cpp +++ b/src/core/SamplePlayHandle.cpp @@ -31,6 +31,8 @@ #include "SampleClip.h" #include "SampleTrack.h" +namespace lmms +{ SamplePlayHandle::SamplePlayHandle( SampleBuffer* sampleBuffer , bool ownAudioPort ) : @@ -148,5 +150,4 @@ f_cnt_t SamplePlayHandle::totalFrames() const } - - +} // namespace lmms diff --git a/src/core/SampleRecordHandle.cpp b/src/core/SampleRecordHandle.cpp index cc0ce1635..edebd27fd 100644 --- a/src/core/SampleRecordHandle.cpp +++ b/src/core/SampleRecordHandle.cpp @@ -32,6 +32,10 @@ #include "debug.h" +namespace lmms +{ + + SampleRecordHandle::SampleRecordHandle( SampleClip* clip ) : PlayHandle( TypeSamplePlayHandle ), m_framesRecorded( 0 ), @@ -111,7 +115,7 @@ void SampleRecordHandle::createSampleBuffer( SampleBuffer** sampleBuf ) { const f_cnt_t frames = framesRecorded(); // create buffer to store all recorded buffers in - sampleFrame * data = new sampleFrame[frames]; + auto data = new sampleFrame[frames]; // make sure buffer is cleaned up properly at the end... sampleFrame * data_ptr = data; @@ -136,7 +140,7 @@ void SampleRecordHandle::createSampleBuffer( SampleBuffer** sampleBuf ) void SampleRecordHandle::writeBuffer( const sampleFrame * _ab, const f_cnt_t _frames ) { - sampleFrame * buf = new sampleFrame[_frames]; + auto buf = new sampleFrame[_frames]; for( f_cnt_t frame = 0; frame < _frames; ++frame ) { for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) @@ -148,4 +152,4 @@ void SampleRecordHandle::writeBuffer( const sampleFrame * _ab, const f_cnt_t _fr } - +} // namespace lmms diff --git a/src/core/Scale.cpp b/src/core/Scale.cpp index 394377e28..df0effe6b 100644 --- a/src/core/Scale.cpp +++ b/src/core/Scale.cpp @@ -27,6 +27,9 @@ #include #include +namespace lmms +{ + Interval::Interval(float cents) : m_numerator(0), @@ -72,7 +75,7 @@ void Interval::loadSettings(const QDomElement &element) Scale::Scale() : m_description(tr("empty")) { - m_intervals.push_back(Interval(1, 1)); + m_intervals.emplace_back(1, 1); } Scale::Scale(QString description, std::vector intervals) : @@ -121,3 +124,6 @@ void Scale::loadSettings(const QDomElement &element) node = node.nextSibling(); } } + + +} // namespace lmms diff --git a/src/core/SerializingObject.cpp b/src/core/SerializingObject.cpp index bc79eb920..9487ebef5 100644 --- a/src/core/SerializingObject.cpp +++ b/src/core/SerializingObject.cpp @@ -26,7 +26,8 @@ #include "SerializingObject.h" - +namespace lmms +{ SerializingObject::SerializingObject() : m_hook( nullptr ) @@ -110,4 +111,4 @@ void SerializingObject::loadSettings( const QDomElement& element ) Q_UNUSED(element) } - +} // namespace lmms diff --git a/src/core/Song.cpp b/src/core/Song.cpp index 4aa7e1ece..d553534b0 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -60,6 +60,9 @@ #include "PeakController.h" +namespace lmms +{ + tick_t TimePos::s_ticksPerBar = DefaultTicksPerBar; @@ -99,28 +102,28 @@ Song::Song() : m_loopRenderRemaining(1), m_oldAutomatedValues() { - for(int i = 0; i < Mode_Count; ++i) m_elapsedMilliSeconds[i] = 0; - connect( &m_tempoModel, SIGNAL( dataChanged() ), - this, SLOT( setTempo() ), Qt::DirectConnection ); - connect( &m_tempoModel, SIGNAL( dataUnchanged() ), - this, SLOT( setTempo() ), Qt::DirectConnection ); - connect( &m_timeSigModel, SIGNAL( dataChanged() ), - this, SLOT( setTimeSignature() ), Qt::DirectConnection ); + for (double& millisecondsElapsed : m_elapsedMilliSeconds) { millisecondsElapsed = 0; } + connect( &m_tempoModel, SIGNAL(dataChanged()), + this, SLOT(setTempo()), Qt::DirectConnection ); + connect( &m_tempoModel, SIGNAL(dataUnchanged()), + this, SLOT(setTempo()), Qt::DirectConnection ); + connect( &m_timeSigModel, SIGNAL(dataChanged()), + this, SLOT(setTimeSignature()), Qt::DirectConnection ); - connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, - SLOT( updateFramesPerTick() ) ); + connect( Engine::audioEngine(), SIGNAL(sampleRateChanged()), this, + SLOT(updateFramesPerTick())); - connect( &m_masterVolumeModel, SIGNAL( dataChanged() ), - this, SLOT( masterVolumeChanged() ), Qt::DirectConnection ); -/* connect( &m_masterPitchModel, SIGNAL( dataChanged() ), - this, SLOT( masterPitchChanged() ) );*/ + connect( &m_masterVolumeModel, SIGNAL(dataChanged()), + this, SLOT(masterVolumeChanged()), Qt::DirectConnection ); +/* connect( &m_masterPitchModel, SIGNAL(dataChanged()), + this, SLOT(masterPitchChanged()));*/ - qRegisterMetaType( "Note" ); + qRegisterMetaType( "lmms::Note" ); setType( SongContainer ); - for (int i = 0; i < MaxScaleCount; i++) {m_scales[i] = std::make_shared();} - for (int i = 0; i < MaxKeymapCount; i++) {m_keymaps[i] = std::make_shared();} + for (auto& scale : m_scales) {scale = std::make_shared();} + for (auto& keymap : m_keymaps) {keymap = std::make_shared();} } @@ -147,12 +150,11 @@ void Song::masterVolumeChanged() void Song::setTempo() { Engine::audioEngine()->requestChangeInModel(); - const bpm_t tempo = ( bpm_t ) m_tempoModel.value(); + const auto tempo = (bpm_t)m_tempoModel.value(); PlayHandleList & playHandles = Engine::audioEngine()->playHandles(); - for( PlayHandleList::Iterator it = playHandles.begin(); - it != playHandles.end(); ++it ) + for (const auto& playHandle : playHandles) { - NotePlayHandle * nph = dynamic_cast( *it ); + auto nph = dynamic_cast(playHandle); if( nph && !nph->isReleased() ) { nph->lock(); @@ -188,7 +190,7 @@ void Song::setTimeSignature() void Song::savePos() { - TimeLineWidget * tl = m_playPos[m_playMode].m_timeLine; + gui::TimeLineWidget* tl = m_playPos[m_playMode].m_timeLine; if( tl != nullptr ) { @@ -322,7 +324,7 @@ void Song::processNextBuffer() } const f_cnt_t framesUntilNextPeriod = framesPerPeriod - frameOffsetInPeriod; - const f_cnt_t framesUntilNextTick = static_cast(std::ceil(framesPerTick - frameOffsetInTick)); + const auto framesUntilNextTick = static_cast(std::ceil(framesPerTick - frameOffsetInTick)); // We want to proceed to the next buffer or tick, whichever is closer const auto framesToPlay = std::min(framesUntilNextPeriod, framesUntilNextTick); @@ -638,6 +640,8 @@ void Song::stop() return; } + using gui::TimeLineWidget; + // To avoid race conditions with the processing threads Engine::audioEngine()->requestChangeInModel(); @@ -853,6 +857,8 @@ AutomatedValueMap Song::automatedValuesAt(TimePos time, int clipNum) const void Song::clearProject() { + using gui::getGUI; + Engine::projectJournal()->setJournalling( false ); if( m_playing ) @@ -1010,6 +1016,8 @@ void Song::createNewProjectFromTemplate( const QString & templ ) // load given song void Song::loadProject( const QString & fileName ) { + using gui::getGUI; + QDomNode node; m_loadingProject = true; @@ -1239,6 +1247,8 @@ void Song::loadProject( const QString & fileName ) // only save current song as filename and do nothing else bool Song::saveProjectFile(const QString & filename, bool withResources) { + using gui::getGUI; + DataFile dataFile( DataFile::SongProject ); m_savingProject = true; @@ -1323,9 +1333,9 @@ void Song::saveControllerStates( QDomDocument & doc, QDomElement & element ) // save settings of controllers QDomElement controllersNode = doc.createElement( "controllers" ); element.appendChild( controllersNode ); - for( int i = 0; i < m_controllers.size(); ++i ) + for (const auto& controller : m_controllers) { - m_controllers[i]->saveState( doc, controllersNode ); + controller->saveState(doc, controllersNode); } } @@ -1369,9 +1379,9 @@ void Song::saveScaleStates(QDomDocument &doc, QDomElement &element) QDomElement scalesNode = doc.createElement("scales"); element.appendChild(scalesNode); - for (int i = 0; i < MaxScaleCount; i++) + for (const auto& scale : m_scales) { - m_scales[i]->saveState(doc, scalesNode); + scale->saveState(doc, scalesNode); } } @@ -1394,9 +1404,9 @@ void Song::saveKeymapStates(QDomDocument &doc, QDomElement &element) QDomElement keymapsNode = doc.createElement("keymaps"); element.appendChild(keymapsNode); - for (int i = 0; i < MaxKeymapCount; i++) + for (const auto& keymap : m_keymaps) { - m_keymaps[i]->saveState(doc, keymapsNode); + keymap->saveState(doc, keymapsNode); } } @@ -1575,3 +1585,6 @@ void Song::setKeymap(unsigned int index, std::shared_ptr newMap) emit keymapListChanged(index); Engine::audioEngine()->doneChangeInModel(); } + + +} // namespace lmms diff --git a/src/core/StepRecorder.cpp b/src/core/StepRecorder.cpp index 29675d5b2..e8f31f644 100644 --- a/src/core/StepRecorder.cpp +++ b/src/core/StepRecorder.cpp @@ -27,12 +27,16 @@ #include "PianoRoll.h" +namespace lmms +{ + + using std::min; using std::max; const int REMOVE_RELEASED_NOTE_TIME_THRESHOLD_MS = 70; -StepRecorder::StepRecorder(PianoRoll& pianoRoll, StepRecorderWidget& stepRecorderWidget): +StepRecorder::StepRecorder(gui::PianoRoll& pianoRoll, gui::StepRecorderWidget& stepRecorderWidget): m_pianoRoll(pianoRoll), m_stepRecorderWidget(stepRecorderWidget), m_midiClip(nullptr) @@ -367,3 +371,5 @@ StepRecorder::StepNote* StepRecorder::findCurStepNote(const int key) return nullptr; } + +} // namespace lmms \ No newline at end of file diff --git a/src/core/TempoSyncKnobModel.cpp b/src/core/TempoSyncKnobModel.cpp index a85ca2e9f..6fb457f2c 100644 --- a/src/core/TempoSyncKnobModel.cpp +++ b/src/core/TempoSyncKnobModel.cpp @@ -31,6 +31,10 @@ #include "Song.h" +namespace lmms +{ + + TempoSyncKnobModel::TempoSyncKnobModel( const float _val, const float _min, const float _max, const float _step, const float _scale, Model * _parent, @@ -41,21 +45,14 @@ TempoSyncKnobModel::TempoSyncKnobModel( const float _val, const float _min, m_scale( _scale ), m_custom( _parent ) { - connect( Engine::getSong(), SIGNAL( tempoChanged( bpm_t ) ), - this, SLOT( calculateTempoSyncTime( bpm_t ) ), + connect( Engine::getSong(), SIGNAL(tempoChanged(lmms::bpm_t)), + this, SLOT(calculateTempoSyncTime(lmms::bpm_t)), Qt::DirectConnection ); } -TempoSyncKnobModel::~TempoSyncKnobModel() -{ -} - - - - void TempoSyncKnobModel::setTempoSync( QAction * _item ) { setTempoSync( _item->data().toInt() ); @@ -154,8 +151,8 @@ void TempoSyncKnobModel::setSyncMode( TempoSyncMode _new_mode ) m_tempoSyncMode = _new_mode; if( _new_mode == SyncCustom ) { - connect( &m_custom, SIGNAL( dataChanged() ), - this, SLOT( updateCustom() ), + connect( &m_custom, SIGNAL(dataChanged()), + this, SLOT(updateCustom()), Qt::DirectConnection ); } } @@ -181,8 +178,4 @@ void TempoSyncKnobModel::updateCustom() } - - - - - +} // namespace lmms diff --git a/src/core/TimePos.cpp b/src/core/TimePos.cpp index 4a22a1eb9..f3b09474d 100644 --- a/src/core/TimePos.cpp +++ b/src/core/TimePos.cpp @@ -27,6 +27,9 @@ #include "MeterModel.h" +namespace lmms +{ + TimeSig::TimeSig( int num, int denom ) : m_num(num), m_denom(denom) @@ -216,3 +219,6 @@ double TimePos::ticksToMilliseconds(double ticks, bpm_t beatsPerMinute) // 60 * 1000 / 48 = 1250 return ( ticks * 1250 ) / beatsPerMinute; } + + +} // namespace lmms \ No newline at end of file diff --git a/src/core/ToolPlugin.cpp b/src/core/ToolPlugin.cpp index 6c2b0fed7..137029137 100644 --- a/src/core/ToolPlugin.cpp +++ b/src/core/ToolPlugin.cpp @@ -26,6 +26,10 @@ #include "ToolPlugin.h" +namespace lmms +{ + + ToolPlugin::ToolPlugin( const Descriptor * _descriptor, Model * _parent ) : Plugin( _descriptor, _parent ) { @@ -34,13 +38,6 @@ ToolPlugin::ToolPlugin( const Descriptor * _descriptor, Model * _parent ) : -ToolPlugin::~ToolPlugin() -{ -} - - - - ToolPlugin * ToolPlugin::instantiate( const QString & _plugin_name, Model * _parent ) { Plugin * p = Plugin::instantiate( _plugin_name, _parent, nullptr ); @@ -56,3 +53,5 @@ ToolPlugin * ToolPlugin::instantiate( const QString & _plugin_name, Model * _par return nullptr; } + +} // namespace lmms \ No newline at end of file diff --git a/src/core/Track.cpp b/src/core/Track.cpp index d3418ea33..084f302f8 100644 --- a/src/core/Track.cpp +++ b/src/core/Track.cpp @@ -43,6 +43,9 @@ #include "Song.h" +namespace lmms +{ + /*! \brief Create a new (empty) track object * * The track object is the whole track, linking its contents, its @@ -106,14 +109,14 @@ Track * Track::create( TrackTypes tt, TrackContainer * tc ) switch( tt ) { - case InstrumentTrack: t = new ::InstrumentTrack( tc ); break; - case PatternTrack: t = new ::PatternTrack( tc ); break; - case SampleTrack: t = new ::SampleTrack( tc ); break; + case InstrumentTrack: t = new class InstrumentTrack( tc ); break; + case PatternTrack: t = new class PatternTrack( tc ); break; + case SampleTrack: t = new class SampleTrack( tc ); break; // case EVENT_TRACK: // case VIDEO_TRACK: - case AutomationTrack: t = new ::AutomationTrack( tc ); break; + case AutomationTrack: t = new class AutomationTrack( tc ); break; case HiddenAutomationTrack: - t = new ::AutomationTrack( tc, true ); break; + t = new class AutomationTrack( tc, true ); break; default: break; } @@ -223,10 +226,9 @@ void Track::saveSettings( QDomDocument & doc, QDomElement & element ) } // now save settings of all Clip's - for( clipVector::const_iterator it = m_clips.begin(); - it != m_clips.end(); ++it ) + for (const auto& clip : m_clips) { - ( *it )->saveState( doc, element ); + clip->saveState(doc, element); } } @@ -509,13 +511,11 @@ void Track::insertBar( const TimePos & pos ) { // we'll increase the position of every Clip, positioned behind pos, by // one bar - for( clipVector::iterator it = m_clips.begin(); - it != m_clips.end(); ++it ) + for (const auto& clip : m_clips) { - if( ( *it )->startPosition() >= pos ) + if (clip->startPosition() >= pos) { - ( *it )->movePosition( (*it)->startPosition() + - TimePos::ticksPerBar() ); + clip->movePosition(clip->startPosition() + TimePos::ticksPerBar()); } } } @@ -531,11 +531,11 @@ void Track::removeBar( const TimePos & pos ) { // we'll decrease the position of every Clip, positioned behind pos, by // one bar - for( clipVector::iterator it = m_clips.begin(); it != m_clips.end(); ++it ) + for (const auto& clip : m_clips) { - if( ( *it )->startPosition() >= pos ) + if (clip->startPosition() >= pos) { - (*it)->movePosition((*it)->startPosition() - TimePos::ticksPerBar()); + clip->movePosition(clip->startPosition() - TimePos::ticksPerBar()); } } } @@ -553,15 +553,14 @@ bar_t Track::length() const { // find last end-position tick_t last = 0; - for( clipVector::const_iterator it = m_clips.begin(); it != m_clips.end(); ++it ) + for (const auto& clip : m_clips) { - if( Engine::getSong()->isExporting() && - ( *it )->isMuted() ) + if (Engine::getSong()->isExporting() && clip->isMuted()) { continue; } - const tick_t cur = ( *it )->endPosition(); + const tick_t cur = clip->endPosition(); if( cur > last ) { last = cur; @@ -584,12 +583,11 @@ void Track::toggleSolo() const TrackContainer::TrackList & tl = m_trackContainer->tracks(); bool soloBefore = false; - for( TrackContainer::TrackList::const_iterator it = tl.begin(); - it != tl.end(); ++it ) + for (const auto& track : tl) { - if( *it != this ) + if (track != this) { - if( ( *it )->m_soloModel.value() ) + if (track->m_soloModel.value()) { soloBefore = true; break; @@ -601,37 +599,36 @@ void Track::toggleSolo() // Should we use the new behavior of solo or the older/legacy one? const bool soloLegacyBehavior = ConfigManager::inst()->value("app", "sololegacybehavior", "0").toInt(); - for( TrackContainer::TrackList::const_iterator it = tl.begin(); - it != tl.end(); ++it ) + for (const auto& track : tl) { - if( solo ) + if (solo) { // save mute-state in case no track was solo before - if( !soloBefore ) + if (!soloBefore) { - ( *it )->m_mutedBeforeSolo = ( *it )->isMuted(); + track->m_mutedBeforeSolo = track->isMuted(); } // Don't mute AutomationTracks (keep their original state) unless we are on the sololegacybehavior mode - if( *it == this ) + if (track == this) { - ( *it )->setMuted( false ); + track->setMuted(false); } - else if( soloLegacyBehavior || ( *it )->type() != AutomationTrack ) + else if (soloLegacyBehavior || track->type() != AutomationTrack) { - ( *it )->setMuted( true ); + track->setMuted(true); } - if( *it != this ) + if (track != this) { - ( *it )->m_soloModel.setValue( false ); + track->m_soloModel.setValue(false); } } - else if( !soloBefore ) + else if (!soloBefore) { // Unless we are on the sololegacybehavior mode, only restores the // mute state if the track isn't an Automation Track - if( soloLegacyBehavior || ( *it )->type() != AutomationTrack ) + if (soloLegacyBehavior || track->type() != AutomationTrack) { - ( *it )->setMuted( ( *it )->m_mutedBeforeSolo ); + track->setMuted(track->m_mutedBeforeSolo); } } } @@ -656,3 +653,4 @@ BoolModel *Track::getMutedModel() return &m_mutedModel; } +} // namespace lmms \ No newline at end of file diff --git a/src/core/TrackContainer.cpp b/src/core/TrackContainer.cpp index 6c52b41af..0347773ed 100644 --- a/src/core/TrackContainer.cpp +++ b/src/core/TrackContainer.cpp @@ -41,6 +41,10 @@ #include "MainWindow.h" #include "TextFloat.h" +namespace lmms +{ + + TrackContainer::TrackContainer() : Model( nullptr ), JournallingObject(), @@ -67,9 +71,9 @@ void TrackContainer::saveSettings( QDomDocument & _doc, QDomElement & _this ) // save settings of each track m_tracksMutex.lockForRead(); - for( int i = 0; i < m_tracks.size(); ++i ) + for (const auto& track : m_tracks) { - m_tracks[i]->saveState( _doc, _this ); + track->saveState(_doc, _this); } m_tracksMutex.unlock(); } @@ -87,14 +91,14 @@ void TrackContainer::loadSettings( const QDomElement & _this ) static QProgressDialog * pd = nullptr; bool was_null = ( pd == nullptr ); - if( !journalRestore && getGUI() != nullptr ) + if (!journalRestore && gui::getGUI() != nullptr) { if( pd == nullptr ) { pd = new QProgressDialog( tr( "Loading project..." ), tr( "Cancel" ), 0, Engine::getSong()->getLoadingTrackCount(), - getGUI()->mainWindow() ); + gui::getGUI()->mainWindow()); pd->setWindowModality( Qt::ApplicationModal ); pd->setWindowTitle( tr( "Please wait..." ) ); pd->show(); @@ -111,9 +115,9 @@ void TrackContainer::loadSettings( const QDomElement & _this ) QEventLoop::AllEvents, 100 ); if( pd->wasCanceled() ) { - if ( getGUI() != nullptr ) + if (gui::getGUI() != nullptr) { - TextFloat::displayMessage( tr( "Loading cancelled" ), + gui::TextFloat::displayMessage( tr( "Loading cancelled" ), tr( "Project loading was cancelled." ), embed::getIconPixmap( "project_file", 24, 24 ), 2000 ); @@ -156,9 +160,9 @@ int TrackContainer::countTracks( Track::TrackTypes _tt ) const { int cnt = 0; m_tracksMutex.lockForRead(); - for( int i = 0; i < m_tracks.size(); ++i ) + for (const auto& track : m_tracks) { - if( m_tracks[i]->type() == _tt || _tt == Track::NumTrackTypes ) + if (track->type() == _tt || _tt == Track::NumTrackTypes) { ++cnt; } @@ -234,10 +238,9 @@ void TrackContainer::clearAllTracks() bool TrackContainer::isEmpty() const { - for( TrackList::const_iterator it = m_tracks.begin(); - it != m_tracks.end(); ++it ) + for (const auto& track : m_tracks) { - if( !( *it )->getClips().isEmpty() ) + if (!track->getClips().isEmpty()) { return false; } @@ -330,3 +333,5 @@ AutomatedValueMap TrackContainer::automatedValuesFromTracks(const TrackList &tra return valueMap; }; + +} // namespace lmms diff --git a/src/core/ValueBuffer.cpp b/src/core/ValueBuffer.cpp index 687bd3c15..01003dc3b 100644 --- a/src/core/ValueBuffer.cpp +++ b/src/core/ValueBuffer.cpp @@ -2,8 +2,9 @@ #include "interpolation.h" -ValueBuffer::ValueBuffer() -{} +namespace lmms +{ + ValueBuffer::ValueBuffer(int length) : std::vector(length) @@ -41,3 +42,6 @@ void ValueBuffer::interpolate(float start, float end_) return linearInterpolate( start, end_, i++ / length()); }); } + + +} // namespace lmms diff --git a/src/core/VstSyncController.cpp b/src/core/VstSyncController.cpp index efe295d7a..c4b59eb6f 100644 --- a/src/core/VstSyncController.cpp +++ b/src/core/VstSyncController.cpp @@ -28,6 +28,7 @@ #include #include +#include #include "AudioEngine.h" #include "ConfigManager.h" @@ -35,36 +36,20 @@ #include "RemotePlugin.h" -VstSyncController::VstSyncController() : - m_syncData( nullptr ) +namespace lmms { - if( ConfigManager::inst()->value( "ui", "syncvstplugins" ).toInt() ) - { - connect( Engine::audioEngine(), SIGNAL( sampleRateChanged() ), this, SLOT( updateSampleRate() ) ); - try - { - m_shm.create("usr_bin_lmms"); - m_syncData = m_shm.get(); - } - catch (const std::runtime_error& error) - { - qWarning() << "Failed to allocate shared memory for VST sync:" << error.what(); - } - } - else - { - qWarning( "VST sync support disabled in your configuration" ); - } - if( m_syncData == nullptr ) +VstSyncController::VstSyncController() +{ + try { - m_syncData = new VstSyncData; - m_syncData->hasSHM = false; + m_syncData.create(QUuid::createUuid().toString().toStdString()); } - else + catch (const std::runtime_error& error) { - m_syncData->hasSHM = true; + qCritical() << "Failed to allocate shared memory for VST sync:" << error.what(); + return; } m_syncData->isPlaying = false; @@ -72,23 +57,16 @@ VstSyncController::VstSyncController() : m_syncData->timeSigNumer = 4; m_syncData->timeSigDenom = 4; + connect(Engine::audioEngine(), &AudioEngine::sampleRateChanged, this, &VstSyncController::updateSampleRate); updateSampleRate(); } -VstSyncController::~VstSyncController() +void VstSyncController::setAbsolutePosition(double ticks) { - if( m_syncData->hasSHM == false ) - { - delete m_syncData; - } -} + if (!m_syncData) { return; } - - -void VstSyncController::setAbsolutePosition( double ticks ) -{ #ifdef VST_SNC_LATENCY m_syncData->ppqPos = ( ( ticks + 0 ) / 48.0 ) - m_syncData->m_latency; #else @@ -98,8 +76,19 @@ void VstSyncController::setAbsolutePosition( double ticks ) -void VstSyncController::setTempo( int newTempo ) +void VstSyncController::setPlaybackState(bool enabled) { + if (!m_syncData) { return; } + + m_syncData->isPlaying = enabled; +} + + + +void VstSyncController::setTempo(int newTempo) +{ + if (!m_syncData) { return; } + m_syncData->m_bpm = newTempo; #ifdef VST_SNC_LATENCY @@ -110,8 +99,20 @@ void VstSyncController::setTempo( int newTempo ) -void VstSyncController::startCycle( int startTick, int endTick ) +void VstSyncController::setTimeSignature(int num, int denom) { + if (!m_syncData) { return; } + + m_syncData->timeSigNumer = num; + m_syncData->timeSigDenom = denom; +} + + + +void VstSyncController::startCycle(int startTick, int endTick) +{ + if (!m_syncData) { return; } + m_syncData->isCycle = true; m_syncData->cycleStart = startTick / (float)48; m_syncData->cycleEnd = endTick / (float)48; @@ -119,8 +120,28 @@ void VstSyncController::startCycle( int startTick, int endTick ) +void VstSyncController::stopCycle() +{ + if (!m_syncData) { return; } + + m_syncData->isCycle = false; +} + + + +void VstSyncController::setPlaybackJumped(bool jumped) +{ + if (!m_syncData) { return; } + + m_syncData->m_playbackJumped = jumped; +} + + + void VstSyncController::update() { + if (!m_syncData) { return; } + m_syncData->m_bufferSize = Engine::audioEngine()->framesPerPeriod(); #ifdef VST_SNC_LATENCY @@ -132,6 +153,8 @@ void VstSyncController::update() void VstSyncController::updateSampleRate() { + if (!m_syncData) { return; } + m_syncData->m_sampleRate = Engine::audioEngine()->processingSampleRate(); #ifdef VST_SNC_LATENCY @@ -140,6 +163,4 @@ void VstSyncController::updateSampleRate() } - - - +} // namespace lmms diff --git a/src/core/audio/AudioAlsa.cpp b/src/core/audio/AudioAlsa.cpp index 1cea301b9..8b3eb32be 100644 --- a/src/core/audio/AudioAlsa.cpp +++ b/src/core/audio/AudioAlsa.cpp @@ -32,6 +32,8 @@ #include "ConfigManager.h" #include "Engine.h" +namespace lmms +{ AudioAlsa::AudioAlsa( bool & _success_ful, AudioEngine* _audioEngine ) : AudioDevice( qBound( @@ -293,9 +295,9 @@ void AudioAlsa::applyQualitySettings() void AudioAlsa::run() { - surroundSampleFrame * temp = new surroundSampleFrame[audioEngine()->framesPerPeriod()]; - int_sample_t * outbuf = new int_sample_t[audioEngine()->framesPerPeriod() * channels()]; - int_sample_t * pcmbuf = new int_sample_t[m_periodSize * channels()]; + auto temp = new surroundSampleFrame[audioEngine()->framesPerPeriod()]; + auto outbuf = new int_sample_t[audioEngine()->framesPerPeriod() * channels()]; + auto pcmbuf = new int_sample_t[m_periodSize * channels()]; int outbuf_size = audioEngine()->framesPerPeriod() * channels(); int outbuf_pos = 0; @@ -538,4 +540,6 @@ int AudioAlsa::setSWParams() return 0; // all ok } -#endif +} // namespace lmms + +#endif // LMMS_HAVE_ALSA diff --git a/src/core/audio/AudioDevice.cpp b/src/core/audio/AudioDevice.cpp index 145e6b471..5fb58a1b0 100644 --- a/src/core/audio/AudioDevice.cpp +++ b/src/core/audio/AudioDevice.cpp @@ -29,7 +29,8 @@ #include "ConfigManager.h" #include "debug.h" - +namespace lmms +{ AudioDevice::AudioDevice( const ch_cnt_t _channels, AudioEngine* _audioEngine ) : m_supportsCapture( false ), @@ -267,3 +268,4 @@ bool AudioDevice::hqAudio() const } +} // namespace lmms \ No newline at end of file diff --git a/src/core/audio/AudioFileDevice.cpp b/src/core/audio/AudioFileDevice.cpp index e7d78bc36..f80d4a00f 100644 --- a/src/core/audio/AudioFileDevice.cpp +++ b/src/core/audio/AudioFileDevice.cpp @@ -29,6 +29,8 @@ #include "ExportProjectDialog.h" #include "GuiApplication.h" +namespace lmms +{ AudioFileDevice::AudioFileDevice( OutputSettings const & outputSettings, const ch_cnt_t _channels, @@ -38,6 +40,8 @@ AudioFileDevice::AudioFileDevice( OutputSettings const & outputSettings, m_outputFile( _file ), m_outputSettings(outputSettings) { + using gui::ExportProjectDialog; + setSampleRate( outputSettings.getSampleRate() ); if( m_outputFile.open( QFile::WriteOnly | QFile::Truncate ) == false ) @@ -52,7 +56,7 @@ AudioFileDevice::AudioFileDevice( OutputSettings const & outputSettings, "file and try again!" ).arg( _file ); - if( getGUI() != nullptr ) + if (gui::getGUI() != nullptr) { QMessageBox::critical( nullptr, title, message, QMessageBox::Ok, @@ -87,3 +91,4 @@ int AudioFileDevice::writeData( const void* data, int len ) return -1; } +} // namespace lmms diff --git a/src/core/audio/AudioFileFlac.cpp b/src/core/audio/AudioFileFlac.cpp index aa6d8e214..6af063683 100644 --- a/src/core/audio/AudioFileFlac.cpp +++ b/src/core/audio/AudioFileFlac.cpp @@ -31,6 +31,9 @@ #include "endian_handling.h" #include "AudioEngine.h" +namespace lmms +{ + AudioFileFlac::AudioFileFlac(OutputSettings const& outputSettings, ch_cnt_t const channels, bool& successful, QString const& file, AudioEngine* audioEngine): AudioFileDevice(outputSettings,channels,file,audioEngine), m_sf(nullptr) @@ -93,7 +96,7 @@ void AudioFileFlac::writeBuffer(surroundSampleFrame const* _ab, fpp_t const fram if (depth == OutputSettings::Depth_24Bit || depth == OutputSettings::Depth_32Bit) // Float encoding { - std::unique_ptr buf{ new sample_t[frames*channels()] }; + auto buf = std::vector(frames * channels()); for(fpp_t frame = 0; frame < frames; ++frame) { for(ch_cnt_t channel=0; channel(buf.get()),frames); + sf_writef_float(m_sf, static_cast(buf.data()), frames); } else // integer PCM encoding { - std::unique_ptr buf{ new int_sample_t[frames*channels()] }; - convertToS16(_ab, frames, master_gain, buf.get(), !isLittleEndian()); - sf_writef_short(m_sf, static_cast(buf.get()), frames); + auto buf = std::vector(frames * channels()); + convertToS16(_ab, frames, master_gain, buf.data(), !isLittleEndian()); + sf_writef_short(m_sf, static_cast(buf.data()), frames); } } @@ -124,3 +127,5 @@ void AudioFileFlac::finishEncoding() sf_close(m_sf); } } + +} // namespace lmms \ No newline at end of file diff --git a/src/core/audio/AudioFileMP3.cpp b/src/core/audio/AudioFileMP3.cpp index 088cd6eda..4930e9ad6 100644 --- a/src/core/audio/AudioFileMP3.cpp +++ b/src/core/audio/AudioFileMP3.cpp @@ -30,6 +30,8 @@ #include +namespace lmms +{ AudioFileMP3::AudioFileMP3( OutputSettings const & outputSettings, const ch_cnt_t channels, @@ -130,4 +132,6 @@ void AudioFileMP3::tearDownEncoder() lame_close(m_lame); } -#endif +} // namespace lmms + +#endif // LMMS_HAVE_MP3LAME diff --git a/src/core/audio/AudioFileOgg.cpp b/src/core/audio/AudioFileOgg.cpp index d9aa8b4f0..d61e27da8 100644 --- a/src/core/audio/AudioFileOgg.cpp +++ b/src/core/audio/AudioFileOgg.cpp @@ -38,6 +38,8 @@ #include "AudioEngine.h" +namespace lmms +{ AudioFileOgg::AudioFileOgg( OutputSettings const & outputSettings, const ch_cnt_t channels, @@ -268,6 +270,8 @@ void AudioFileOgg::finishEncoding() } -#endif +} // namespace lmms + +#endif // LMMS_HAVE_OGGVORBIS diff --git a/src/core/audio/AudioFileWave.cpp b/src/core/audio/AudioFileWave.cpp index 1fce2fe48..b78b04403 100644 --- a/src/core/audio/AudioFileWave.cpp +++ b/src/core/audio/AudioFileWave.cpp @@ -28,6 +28,8 @@ #include "AudioEngine.h" +namespace lmms +{ AudioFileWave::AudioFileWave( OutputSettings const & outputSettings, const ch_cnt_t channels, bool & successful, @@ -102,7 +104,7 @@ void AudioFileWave::writeBuffer( const surroundSampleFrame * _ab, if( bitDepth == OutputSettings::Depth_32Bit || bitDepth == OutputSettings::Depth_24Bit ) { - float * buf = new float[_frames*channels()]; + auto buf = new float[_frames * channels()]; for( fpp_t frame = 0; frame < _frames; ++frame ) { for( ch_cnt_t chnl = 0; chnl < channels(); ++chnl ) @@ -116,7 +118,7 @@ void AudioFileWave::writeBuffer( const surroundSampleFrame * _ab, } else { - int_sample_t * buf = new int_sample_t[_frames * channels()]; + auto buf = new int_sample_t[_frames * channels()]; convertToS16( _ab, _frames, _master_gain, buf, !isLittleEndian() ); @@ -136,3 +138,4 @@ void AudioFileWave::finishEncoding() } } +} // namespace lmms \ No newline at end of file diff --git a/src/core/audio/AudioJack.cpp b/src/core/audio/AudioJack.cpp index 6bc039a50..222ebf10d 100644 --- a/src/core/audio/AudioJack.cpp +++ b/src/core/audio/AudioJack.cpp @@ -40,6 +40,8 @@ #include "MidiJack.h" +namespace lmms +{ AudioJack::AudioJack( bool & _success_ful, AudioEngine* _audioEngine ) : AudioDevice( qBound( @@ -59,8 +61,8 @@ AudioJack::AudioJack( bool & _success_ful, AudioEngine* _audioEngine ) : _success_ful = initJackClient(); if( _success_ful ) { - connect( this, SIGNAL( zombified() ), - this, SLOT( restartAfterZombified() ), + connect( this, SIGNAL(zombified()), + this, SLOT(restartAfterZombified()), Qt::QueuedConnection ); } @@ -102,7 +104,7 @@ void AudioJack::restartAfterZombified() { m_active = false; startProcessing(); - QMessageBox::information( getGUI()->mainWindow(), + QMessageBox::information(gui::getGUI()->mainWindow(), tr( "JACK client restarted" ), tr( "LMMS was kicked by JACK for some reason. " "Therefore the JACK backend of LMMS has been " @@ -111,7 +113,7 @@ void AudioJack::restartAfterZombified() } else { - QMessageBox::information( getGUI()->mainWindow(), + QMessageBox::information(gui::getGUI()->mainWindow(), tr( "JACK server down" ), tr( "The JACK server seems to have been shutdown " "and starting a new instance failed. " @@ -337,7 +339,7 @@ void AudioJack::renamePort( AudioPort * _port ) #endif } } -#endif +#endif // AUDIO_PORT_SUPPORT } @@ -440,7 +442,7 @@ int AudioJack::staticProcessCallback( jack_nframes_t _nframes, void * _udata ) void AudioJack::shutdownCallback( void * _udata ) { - AudioJack * _this = static_cast( _udata ); + auto _this = static_cast(_udata); _this->m_client = nullptr; _this->zombified(); } @@ -460,17 +462,17 @@ AudioJack::setupWidget::setupWidget( QWidget * _parent ) : m_clientName = new QLineEdit( cn, this ); m_clientName->setGeometry( 10, 20, 160, 20 ); - QLabel * cn_lbl = new QLabel( tr( "Client name" ), this ); + auto cn_lbl = new QLabel(tr("Client name"), this); cn_lbl->setFont( pointSize<7>( cn_lbl->font() ) ); cn_lbl->setGeometry( 10, 40, 160, 10 ); - LcdSpinBoxModel * m = new LcdSpinBoxModel( /* this */ ); + auto m = new gui::LcdSpinBoxModel(/* this */); m->setRange( DEFAULT_CHANNELS, SURROUND_CHANNELS ); m->setStep( 2 ); m->setValue( ConfigManager::inst()->value( "audiojack", "channels" ).toInt() ); - m_channels = new LcdSpinBox( 1, this ); + m_channels = new gui::LcdSpinBox( 1, this ); m_channels->setModel( m ); m_channels->setLabel( tr( "Channels" ) ); m_channels->move( 180, 20 ); @@ -498,6 +500,6 @@ void AudioJack::setupWidget::saveSettings() +} // namespace lmms - -#endif +#endif // LMMS_HAVE_JACK diff --git a/src/core/audio/AudioOss.cpp b/src/core/audio/AudioOss.cpp index 76df85adc..5166bad79 100644 --- a/src/core/audio/AudioOss.cpp +++ b/src/core/audio/AudioOss.cpp @@ -57,6 +57,8 @@ #include "ConfigManager.h" +namespace lmms +{ static const QString PATH_DEV_DSP = #if defined(__NetBSD__) || defined(__OpenBSD__) @@ -217,7 +219,7 @@ QString AudioOss::probeDevice() if( QFileInfo( dev ).isWritable() == false ) { int instance = -1; - while( 1 ) + while( true ) { dev = PATH_DEV_DSP + QString::number( ++instance ); if( !QFileInfo( dev ).exists() ) @@ -290,8 +292,8 @@ void AudioOss::applyQualitySettings() void AudioOss::run() { - surroundSampleFrame * temp = new surroundSampleFrame[audioEngine()->framesPerPeriod()]; - int_sample_t * outbuf = new int_sample_t[audioEngine()->framesPerPeriod() * channels()]; + auto temp = new surroundSampleFrame[audioEngine()->framesPerPeriod()]; + auto outbuf = new int_sample_t[audioEngine()->framesPerPeriod() * channels()]; while( true ) { @@ -321,17 +323,17 @@ AudioOss::setupWidget::setupWidget( QWidget * _parent ) : m_device = new QLineEdit( probeDevice(), this ); m_device->setGeometry( 10, 20, 160, 20 ); - QLabel * dev_lbl = new QLabel( tr( "Device" ), this ); + auto dev_lbl = new QLabel(tr("Device"), this); dev_lbl->setFont( pointSize<7>( dev_lbl->font() ) ); dev_lbl->setGeometry( 10, 40, 160, 10 ); - LcdSpinBoxModel * m = new LcdSpinBoxModel( /* this */ ); + auto m = new gui::LcdSpinBoxModel(/* this */); m->setRange( DEFAULT_CHANNELS, SURROUND_CHANNELS ); m->setStep( 2 ); m->setValue( ConfigManager::inst()->value( "audiooss", "channels" ).toInt() ); - m_channels = new LcdSpinBox( 1, this ); + m_channels = new gui::LcdSpinBox( 1, this ); m_channels->setModel( m ); m_channels->setLabel( tr( "Channels" ) ); m_channels->move( 180, 20 ); @@ -358,5 +360,7 @@ void AudioOss::setupWidget::saveSettings() } -#endif +} // namespace lmms + +#endif // LMMS_HAVE_OSS diff --git a/src/core/audio/AudioPort.cpp b/src/core/audio/AudioPort.cpp index b83e6b418..4bbf509d8 100644 --- a/src/core/audio/AudioPort.cpp +++ b/src/core/audio/AudioPort.cpp @@ -31,6 +31,8 @@ #include "MixHelpers.h" #include "BufferManager.h" +namespace lmms +{ AudioPort::AudioPort( const QString & _name, bool _has_effect_chain, FloatModel * volumeModel, FloatModel * panningModel, @@ -247,3 +249,5 @@ void AudioPort::removePlayHandle( PlayHandle * handle ) } m_playHandleLock.unlock(); } + +} // namespace lmms \ No newline at end of file diff --git a/src/core/audio/AudioPortAudio.cpp b/src/core/audio/AudioPortAudio.cpp index 1bc137dac..0f5a4122f 100644 --- a/src/core/audio/AudioPortAudio.cpp +++ b/src/core/audio/AudioPortAudio.cpp @@ -27,6 +27,10 @@ #include "AudioPortAudio.h" #ifndef LMMS_HAVE_PORTAUDIO +namespace lmms +{ + + void AudioPortAudioSetupUtil::updateBackends() { } @@ -38,6 +42,9 @@ void AudioPortAudioSetupUtil::updateDevices() void AudioPortAudioSetupUtil::updateChannels() { } + + +} // namespace lmms #endif #ifdef LMMS_HAVE_PORTAUDIO @@ -50,6 +57,9 @@ void AudioPortAudioSetupUtil::updateChannels() #include "ComboBox.h" #include "AudioEngine.h" +namespace lmms +{ + AudioPortAudio::AudioPortAudio( bool & _success_ful, AudioEngine * _audioEngine ) : AudioDevice( qBound( @@ -322,7 +332,7 @@ int AudioPortAudio::_process_callback( Q_UNUSED(_timeInfo); Q_UNUSED(_statusFlags); - AudioPortAudio * _this = static_cast (_arg); + auto _this = static_cast(_arg); return _this->process_callback( (const float*)_inputBuffer, (float*)_outputBuffer, _framesPerBuffer ); } @@ -407,17 +417,19 @@ void AudioPortAudioSetupUtil::updateChannels() AudioPortAudio::setupWidget::setupWidget( QWidget * _parent ) : AudioDeviceSetupWidget( AudioPortAudio::name(), _parent ) { + using gui::ComboBox; + m_backend = new ComboBox( this, "BACKEND" ); m_backend->setGeometry( 64, 15, 260, ComboBox::DEFAULT_HEIGHT ); - QLabel * backend_lbl = new QLabel( tr( "Backend" ), this ); + auto backend_lbl = new QLabel(tr("Backend"), this); backend_lbl->setFont( pointSize<7>( backend_lbl->font() ) ); backend_lbl->move( 8, 18 ); m_device = new ComboBox( this, "DEVICE" ); m_device->setGeometry( 64, 35, 260, ComboBox::DEFAULT_HEIGHT ); - QLabel * dev_lbl = new QLabel( tr( "Device" ), this ); + auto dev_lbl = new QLabel(tr("Device"), this); dev_lbl->setFont( pointSize<7>( dev_lbl->font() ) ); dev_lbl->move( 8, 38 ); @@ -432,11 +444,11 @@ AudioPortAudio::setupWidget::setupWidget( QWidget * _parent ) : m_channels->setLabel( tr( "Channels" ) ); m_channels->move( 308, 20 );*/ - connect( &m_setupUtil.m_backendModel, SIGNAL( dataChanged() ), - &m_setupUtil, SLOT( updateDevices() ) ); + connect( &m_setupUtil.m_backendModel, SIGNAL(dataChanged()), + &m_setupUtil, SLOT(updateDevices())); - connect( &m_setupUtil.m_deviceModel, SIGNAL( dataChanged() ), - &m_setupUtil, SLOT( updateChannels() ) ); + connect( &m_setupUtil.m_deviceModel, SIGNAL(dataChanged()), + &m_setupUtil, SLOT(updateChannels())); m_backend->setModel( &m_setupUtil.m_backendModel ); m_device->setModel( &m_setupUtil.m_deviceModel ); @@ -447,11 +459,11 @@ AudioPortAudio::setupWidget::setupWidget( QWidget * _parent ) : AudioPortAudio::setupWidget::~setupWidget() { - disconnect( &m_setupUtil.m_backendModel, SIGNAL( dataChanged() ), - &m_setupUtil, SLOT( updateDevices() ) ); + disconnect( &m_setupUtil.m_backendModel, SIGNAL(dataChanged()), + &m_setupUtil, SLOT(updateDevices())); - disconnect( &m_setupUtil.m_deviceModel, SIGNAL( dataChanged() ), - &m_setupUtil, SLOT( updateChannels() ) ); + disconnect( &m_setupUtil.m_deviceModel, SIGNAL(dataChanged()), + &m_setupUtil, SLOT(updateChannels())); } @@ -496,8 +508,10 @@ void AudioPortAudio::setupWidget::show() AudioDeviceSetupWidget::show(); } +} // namespace lmms -#endif + +#endif // LMMS_HAVE_PORTAUDIO diff --git a/src/core/audio/AudioPulseAudio.cpp b/src/core/audio/AudioPulseAudio.cpp index 5f82b64dc..bac997075 100644 --- a/src/core/audio/AudioPulseAudio.cpp +++ b/src/core/audio/AudioPulseAudio.cpp @@ -35,6 +35,8 @@ #include "gui_templates.h" #include "Engine.h" +namespace lmms +{ static void stream_write_callback(pa_stream *s, size_t length, void *userdata) { @@ -150,7 +152,7 @@ static void stream_state_callback( pa_stream *s, void * userdata ) /* This is called whenever the context status changes */ static void context_state_callback(pa_context *c, void *userdata) { - AudioPulseAudio * _this = static_cast( userdata ); + auto _this = static_cast(userdata); switch( pa_context_get_state( c ) ) { case PA_CONTEXT_CONNECTING: @@ -245,7 +247,7 @@ void AudioPulseAudio::run() else { const fpp_t fpp = audioEngine()->framesPerPeriod(); - surroundSampleFrame * temp = new surroundSampleFrame[fpp]; + auto temp = new surroundSampleFrame[fpp]; while( getNextBuffer( temp ) ) { } @@ -264,8 +266,8 @@ void AudioPulseAudio::run() void AudioPulseAudio::streamWriteCallback( pa_stream *s, size_t length ) { const fpp_t fpp = audioEngine()->framesPerPeriod(); - surroundSampleFrame * temp = new surroundSampleFrame[fpp]; - int_sample_t* pcmbuf = (int_sample_t *)pa_xmalloc( fpp * channels() * sizeof(int_sample_t) ); + auto temp = new surroundSampleFrame[fpp]; + auto pcmbuf = (int_sample_t*)pa_xmalloc(fpp * channels() * sizeof(int_sample_t)); size_t fd = 0; while( fd < length/4 && m_quit == false ) @@ -313,17 +315,17 @@ AudioPulseAudio::setupWidget::setupWidget( QWidget * _parent ) : m_device = new QLineEdit( AudioPulseAudio::probeDevice(), this ); m_device->setGeometry( 10, 20, 160, 20 ); - QLabel * dev_lbl = new QLabel( tr( "Device" ), this ); + auto dev_lbl = new QLabel(tr("Device"), this); dev_lbl->setFont( pointSize<7>( dev_lbl->font() ) ); dev_lbl->setGeometry( 10, 40, 160, 10 ); - LcdSpinBoxModel * m = new LcdSpinBoxModel( /* this */ ); + auto m = new gui::LcdSpinBoxModel(/* this */); m->setRange( DEFAULT_CHANNELS, SURROUND_CHANNELS ); m->setStep( 2 ); m->setValue( ConfigManager::inst()->value( "audiopa", "channels" ).toInt() ); - m_channels = new LcdSpinBox( 1, this ); + m_channels = new gui::LcdSpinBox( 1, this ); m_channels->setModel( m ); m_channels->setLabel( tr( "Channels" ) ); m_channels->move( 180, 20 ); @@ -349,6 +351,7 @@ void AudioPulseAudio::setupWidget::saveSettings() QString::number( m_channels->value() ) ); } +} // namespace lmms -#endif +#endif // LMMS_HAVE_PULSEAUDIO diff --git a/src/core/audio/AudioSampleRecorder.cpp b/src/core/audio/AudioSampleRecorder.cpp index a33308c99..f60248c50 100644 --- a/src/core/audio/AudioSampleRecorder.cpp +++ b/src/core/audio/AudioSampleRecorder.cpp @@ -29,6 +29,9 @@ #include "debug.h" +namespace lmms +{ + AudioSampleRecorder::AudioSampleRecorder( const ch_cnt_t _channels, bool & _success_ful, @@ -57,10 +60,9 @@ AudioSampleRecorder::~AudioSampleRecorder() f_cnt_t AudioSampleRecorder::framesRecorded() const { f_cnt_t frames = 0; - for( BufferList::ConstIterator it = m_buffers.begin(); - it != m_buffers.end(); ++it ) + for (const auto& buffer : m_buffers) { - frames += ( *it ).second; + frames += buffer.second; } return frames; } @@ -72,7 +74,7 @@ void AudioSampleRecorder::createSampleBuffer( SampleBuffer** sampleBuf ) { const f_cnt_t frames = framesRecorded(); // create buffer to store all recorded buffers in - sampleFrame * data = new sampleFrame[frames]; + auto data = new sampleFrame[frames]; // make sure buffer is cleaned up properly at the end... sampleFrame * data_ptr = data; @@ -99,7 +101,7 @@ void AudioSampleRecorder::createSampleBuffer( SampleBuffer** sampleBuf ) void AudioSampleRecorder::writeBuffer( const surroundSampleFrame * _ab, const fpp_t _frames, const float ) { - sampleFrame * buf = new sampleFrame[_frames]; + auto buf = new sampleFrame[_frames]; for( fpp_t frame = 0; frame < _frames; ++frame ) { for( ch_cnt_t chnl = 0; chnl < DEFAULT_CHANNELS; ++chnl ) @@ -111,4 +113,4 @@ void AudioSampleRecorder::writeBuffer( const surroundSampleFrame * _ab, } - +} // namespace lmms diff --git a/src/core/audio/AudioSdl.cpp b/src/core/audio/AudioSdl.cpp index d62678b49..e73ccadc1 100644 --- a/src/core/audio/AudioSdl.cpp +++ b/src/core/audio/AudioSdl.cpp @@ -34,6 +34,9 @@ #include "ConfigManager.h" #include "gui_templates.h" +namespace lmms +{ + AudioSdl::AudioSdl( bool & _success_ful, AudioEngine* _audioEngine ) : AudioDevice( DEFAULT_CHANNELS, _audioEngine ), m_outBuf( new surroundSampleFrame[audioEngine()->framesPerPeriod()] ) @@ -222,7 +225,7 @@ void AudioSdl::applyQualitySettings() void AudioSdl::sdlAudioCallback( void * _udata, Uint8 * _buf, int _len ) { - AudioSdl * _this = static_cast( _udata ); + auto _this = static_cast(_udata); _this->sdlAudioCallback( _buf, _len ); } @@ -301,19 +304,19 @@ void AudioSdl::sdlAudioCallback( Uint8 * _buf, int _len ) m_convertedBufPos += min_len; m_convertedBufPos %= m_convertedBufSize; } -#endif +#endif // LMMS_HAVE_SDL2 } #ifdef LMMS_HAVE_SDL2 void AudioSdl::sdlInputAudioCallback(void *_udata, Uint8 *_buf, int _len) { - AudioSdl * _this = static_cast( _udata ); + auto _this = static_cast(_udata); _this->sdlInputAudioCallback( _buf, _len ); } void AudioSdl::sdlInputAudioCallback(Uint8 *_buf, int _len) { - sampleFrame *samples_buffer = (sampleFrame *) _buf; + auto samples_buffer = (sampleFrame*)_buf; fpp_t frames = _len / sizeof ( sampleFrame ); audioEngine()->pushInputFrames (samples_buffer, frames); @@ -328,7 +331,7 @@ AudioSdl::setupWidget::setupWidget( QWidget * _parent ) : m_device = new QLineEdit( dev, this ); m_device->setGeometry( 10, 20, 160, 20 ); - QLabel * dev_lbl = new QLabel( tr( "Device" ), this ); + auto dev_lbl = new QLabel(tr("Device"), this); dev_lbl->setFont( pointSize<7>( dev_lbl->font() ) ); dev_lbl->setGeometry( 10, 40, 160, 10 ); @@ -337,13 +340,6 @@ AudioSdl::setupWidget::setupWidget( QWidget * _parent ) : -AudioSdl::setupWidget::~setupWidget() -{ -} - - - - void AudioSdl::setupWidget::saveSettings() { ConfigManager::inst()->setValue( "audiosdl", "device", @@ -351,5 +347,7 @@ void AudioSdl::setupWidget::saveSettings() } -#endif +} // namespace lmms + +#endif // LMMS_HAVE_SDL diff --git a/src/core/audio/AudioSndio.cpp b/src/core/audio/AudioSndio.cpp index 114e01460..a8ea34ce1 100644 --- a/src/core/audio/AudioSndio.cpp +++ b/src/core/audio/AudioSndio.cpp @@ -40,6 +40,8 @@ #include "ConfigManager.h" +namespace lmms +{ AudioSndio::AudioSndio(bool & _success_ful, AudioEngine * _audioEngine) : AudioDevice( qBound( @@ -124,7 +126,7 @@ AudioSndio::~AudioSndio() } -void AudioSndio::startProcessing( void ) +void AudioSndio::startProcessing() { if( !isRunning() ) { @@ -133,13 +135,13 @@ void AudioSndio::startProcessing( void ) } -void AudioSndio::stopProcessing( void ) +void AudioSndio::stopProcessing() { stopProcessingThread( this ); } -void AudioSndio::applyQualitySettings( void ) +void AudioSndio::applyQualitySettings() { if( hqAudio() ) { @@ -152,7 +154,7 @@ void AudioSndio::applyQualitySettings( void ) } -void AudioSndio::run( void ) +void AudioSndio::run() { surroundSampleFrame * temp = new surroundSampleFrame[audioEngine()->framesPerPeriod()]; int_sample_t * outbuf = new int_sample_t[audioEngine()->framesPerPeriod() * channels()]; @@ -188,13 +190,13 @@ AudioSndio::setupWidget::setupWidget( QWidget * _parent ) : dev_lbl->setFont( pointSize<6>( dev_lbl->font() ) ); dev_lbl->setGeometry( 10, 40, 160, 10 ); - LcdSpinBoxModel * m = new LcdSpinBoxModel( /* this */ ); + gui::LcdSpinBoxModel * m = new gui::LcdSpinBoxModel( /* this */ ); m->setRange( DEFAULT_CHANNELS, SURROUND_CHANNELS ); m->setStep( 2 ); m->setValue( ConfigManager::inst()->value( "audiosndio", "channels" ).toInt() ); - m_channels = new LcdSpinBox( 1, this ); + m_channels = new gui::LcdSpinBox( 1, this ); m_channels->setModel( m ); m_channels->setLabel( tr( "Channels" ) ); m_channels->move( 180, 20 ); @@ -202,13 +204,7 @@ AudioSndio::setupWidget::setupWidget( QWidget * _parent ) : } -AudioSndio::setupWidget::~setupWidget() -{ - -} - - -void AudioSndio::setupWidget::saveSettings( void ) +void AudioSndio::setupWidget::saveSettings() { ConfigManager::inst()->setValue( "audiosndio", "device", m_device->text() ); @@ -217,4 +213,6 @@ void AudioSndio::setupWidget::saveSettings( void ) } -#endif /* LMMS_HAVE_SNDIO */ +} // namespace lmms + +#endif // LMMS_HAVE_SNDIO diff --git a/src/core/audio/AudioSoundIo.cpp b/src/core/audio/AudioSoundIo.cpp index c8ef04542..633808204 100644 --- a/src/core/audio/AudioSoundIo.cpp +++ b/src/core/audio/AudioSoundIo.cpp @@ -36,6 +36,9 @@ #include "ComboBox.h" #include "AudioEngine.h" +namespace lmms +{ + AudioSoundIo::AudioSoundIo( bool & outSuccessful, AudioEngine * _audioEngine ) : AudioDevice( qBound( DEFAULT_CHANNELS, @@ -342,10 +345,6 @@ void AudioSoundIo::writeCallback(int frameCountMin, int frameCountMax) } } -AudioSoundIoSetupUtil::~AudioSoundIoSetupUtil() -{ -} - void AudioSoundIoSetupUtil::reconnectSoundIo() { ((AudioSoundIo::setupWidget *)m_setupWidget)->reconnectSoundIo(); @@ -452,14 +451,14 @@ AudioSoundIo::setupWidget::setupWidget( QWidget * _parent ) : { m_setupUtil.m_setupWidget = this; - m_backend = new ComboBox( this, "BACKEND" ); + m_backend = new gui::ComboBox( this, "BACKEND" ); m_backend->setGeometry( 64, 15, 260, 20 ); QLabel * backend_lbl = new QLabel( tr( "Backend" ), this ); backend_lbl->setFont( pointSize<7>( backend_lbl->font() ) ); backend_lbl->move( 8, 18 ); - m_device = new ComboBox( this, "DEVICE" ); + m_device = new gui::ComboBox( this, "DEVICE" ); m_device->setGeometry( 64, 35, 260, 20 ); QLabel * dev_lbl = new QLabel( tr( "Device" ), this ); @@ -489,7 +488,7 @@ AudioSoundIo::setupWidget::setupWidget( QWidget * _parent ) : reconnectSoundIo(); - bool ok = connect( &m_backendModel, SIGNAL( dataChanged() ), &m_setupUtil, SLOT( reconnectSoundIo() ) ); + bool ok = connect( &m_backendModel, SIGNAL(dataChanged()), &m_setupUtil, SLOT(reconnectSoundIo())); assert(ok); m_backend->setModel( &m_backendModel ); @@ -498,7 +497,7 @@ AudioSoundIo::setupWidget::setupWidget( QWidget * _parent ) : AudioSoundIo::setupWidget::~setupWidget() { - bool ok = disconnect( &m_backendModel, SIGNAL( dataChanged() ), &m_setupUtil, SLOT( reconnectSoundIo() ) ); + bool ok = disconnect( &m_backendModel, SIGNAL(dataChanged()), &m_setupUtil, SLOT(reconnectSoundIo())); assert(ok); if (m_soundio) { @@ -519,4 +518,7 @@ void AudioSoundIo::setupWidget::saveSettings() ConfigManager::inst()->setValue( "audiosoundio", "out_device_raw", configDeviceRaw); } -#endif + +} // namespace lmms + +#endif // LMMS_HAVE_SOUNDIO diff --git a/src/core/base64.cpp b/src/core/base64.cpp index c04300dcf..b1c26b610 100644 --- a/src/core/base64.cpp +++ b/src/core/base64.cpp @@ -28,7 +28,7 @@ #include #include -namespace base64 +namespace lmms::base64 { @@ -54,5 +54,4 @@ QVariant decode( const QString & _b64, QVariant::Type _force_type ) } -} ; - +} // namespace lmms::base64 diff --git a/src/core/fft_helpers.cpp b/src/core/fft_helpers.cpp index 9e49c5544..63088f655 100644 --- a/src/core/fft_helpers.cpp +++ b/src/core/fft_helpers.cpp @@ -29,6 +29,10 @@ #include #include "lmms_constants.h" +namespace lmms +{ + + /* Returns biggest value from abs_spectrum[spec_size] array. * * return -1 on error, otherwise the maximum value @@ -212,3 +216,6 @@ int compressbands(const float *absspec_buffer, float *compressedband, int num_ol return 0; } + + +} // namespace lmms diff --git a/src/core/lv2/Lv2Basics.cpp b/src/core/lv2/Lv2Basics.cpp index b6be53a2c..ab5db6ef1 100644 --- a/src/core/lv2/Lv2Basics.cpp +++ b/src/core/lv2/Lv2Basics.cpp @@ -26,6 +26,9 @@ #ifdef LMMS_HAVE_LV2 +namespace lmms +{ + QString qStringFromPluginNode(const LilvPlugin* plug, LilvNode* (*getFunc)(const LilvPlugin*)) { @@ -45,5 +48,7 @@ std::string stdStringFromPortName(const LilvPlugin* plug, const LilvPort* port) lilv_node_as_string(AutoLilvNode(lilv_port_get_name(plug, port)).get())); } +} // namespace lmms + #endif // LMMS_HAVE_LV2 diff --git a/src/core/lv2/Lv2ControlBase.cpp b/src/core/lv2/Lv2ControlBase.cpp index 3c8ccbf8a..3ab8b278c 100644 --- a/src/core/lv2/Lv2ControlBase.cpp +++ b/src/core/lv2/Lv2ControlBase.cpp @@ -35,6 +35,8 @@ #include "Lv2Proc.h" +namespace lmms +{ Plugin::PluginTypes Lv2ControlBase::check(const LilvPlugin *plugin, @@ -87,7 +89,7 @@ Lv2ControlBase::Lv2ControlBase(Model* that, const QString &uri) : -Lv2ControlBase::~Lv2ControlBase() {} +Lv2ControlBase::~Lv2ControlBase() = default; @@ -109,7 +111,7 @@ const LinkedModelGroup *Lv2ControlBase::getGroup(std::size_t idx) const void Lv2ControlBase::copyModelsFromLmms() { - for (auto& c : m_procs) { c->copyModelsFromCore(); } + for (const auto& c : m_procs) { c->copyModelsFromCore(); } } @@ -117,7 +119,7 @@ void Lv2ControlBase::copyModelsFromLmms() { void Lv2ControlBase::copyModelsToLmms() const { - for (auto& c : m_procs) { c->copyModelsToCore(); } + for (const auto& c : m_procs) { c->copyModelsToCore(); } } @@ -125,7 +127,8 @@ void Lv2ControlBase::copyModelsToLmms() const void Lv2ControlBase::copyBuffersFromLmms(const sampleFrame *buf, fpp_t frames) { unsigned firstChan = 0; // tell the procs which channels they shall read from - for (auto& c : m_procs) { + for (const auto& c : m_procs) + { c->copyBuffersFromCore(buf, firstChan, m_channelsPerProc, frames); firstChan += m_channelsPerProc; } @@ -146,7 +149,7 @@ void Lv2ControlBase::copyBuffersToLmms(sampleFrame *buf, fpp_t frames) const { void Lv2ControlBase::run(fpp_t frames) { - for (auto& c : m_procs) { c->run(frames); } + for (const auto& c : m_procs) { c->run(frames); } } @@ -209,10 +212,11 @@ bool Lv2ControlBase::hasNoteInput() const void Lv2ControlBase::handleMidiInputEvent(const MidiEvent &event, const TimePos &time, f_cnt_t offset) { - for (auto& c : m_procs) { c->handleMidiInputEvent(event, time, offset); } + for (const auto& c : m_procs) { c->handleMidiInputEvent(event, time, offset); } } +} // namespace lmms #endif // LMMS_HAVE_LV2 diff --git a/src/core/lv2/Lv2Evbuf.cpp b/src/core/lv2/Lv2Evbuf.cpp index 0c9081815..acfb9b8aa 100644 --- a/src/core/lv2/Lv2Evbuf.cpp +++ b/src/core/lv2/Lv2Evbuf.cpp @@ -36,6 +36,10 @@ #include +namespace lmms +{ + + struct LV2_Evbuf_Impl { uint32_t capacity; uint32_t atom_Chunk; @@ -53,8 +57,7 @@ LV2_Evbuf* lv2_evbuf_new(uint32_t capacity, uint32_t atom_Chunk, uint32_t atom_Sequence) { // FIXME: memory must be 64-bit aligned - LV2_Evbuf* evbuf = (LV2_Evbuf*)malloc( - sizeof(LV2_Evbuf) + sizeof(LV2_Atom_Sequence) + capacity); + auto evbuf = (LV2_Evbuf*)malloc(sizeof(LV2_Evbuf) + sizeof(LV2_Atom_Sequence) + capacity); evbuf->capacity = capacity; evbuf->atom_Chunk = atom_Chunk; evbuf->atom_Sequence = atom_Sequence; @@ -151,8 +154,7 @@ lv2_evbuf_get(LV2_Evbuf_Iterator iter, } LV2_Atom_Sequence* aseq = &iter.evbuf->buf; - LV2_Atom_Event* aev = (LV2_Atom_Event*)( - (char*)LV2_ATOM_CONTENTS(LV2_Atom_Sequence, aseq) + iter.offset); + auto aev = (LV2_Atom_Event*)((char*)LV2_ATOM_CONTENTS(LV2_Atom_Sequence, aseq) + iter.offset); *frames = aev->time.frames; *type = aev->body.type; @@ -175,8 +177,7 @@ lv2_evbuf_write(LV2_Evbuf_Iterator* iter, return false; } - LV2_Atom_Event* aev = (LV2_Atom_Event*)( - (char*)LV2_ATOM_CONTENTS(LV2_Atom_Sequence, aseq) + iter->offset); + auto aev = (LV2_Atom_Event*)((char*)LV2_ATOM_CONTENTS(LV2_Atom_Sequence, aseq) + iter->offset); aev->time.frames = frames; aev->body.type = type; @@ -190,4 +191,7 @@ lv2_evbuf_write(LV2_Evbuf_Iterator* iter, return true; } + +} // namespace lmms + #endif // LMMS_HAVE_LV2 diff --git a/src/core/lv2/Lv2Features.cpp b/src/core/lv2/Lv2Features.cpp index 74d2415b0..be7fb6e28 100644 --- a/src/core/lv2/Lv2Features.cpp +++ b/src/core/lv2/Lv2Features.cpp @@ -32,6 +32,10 @@ #include "Lv2Manager.h" +namespace lmms +{ + + bool Lv2Features::isFeatureSupported(const char* featName) { return Engine::getLv2Manager()->isFeatureSupported(featName); @@ -83,9 +87,9 @@ void Lv2Features::createFeatureVectors() // create pointer vector (for lilv_plugin_instantiate) m_featurePointers.reserve(m_features.size() + 1); - for(std::size_t i = 0; i < m_features.size(); ++i) + for (const auto& feature : m_features) { - m_featurePointers.push_back(&m_features[i]); + m_featurePointers.push_back(&feature); } m_featurePointers.push_back(nullptr); } @@ -101,5 +105,7 @@ void *&Lv2Features::operator[](const char *featName) } +} // namespace lmms + #endif // LMMS_HAVE_LV2 diff --git a/src/core/lv2/Lv2Manager.cpp b/src/core/lv2/Lv2Manager.cpp index 09870a90b..b1391b065 100644 --- a/src/core/lv2/Lv2Manager.cpp +++ b/src/core/lv2/Lv2Manager.cpp @@ -42,6 +42,8 @@ #include "PluginIssue.h" +namespace lmms +{ const std::set Lv2Manager::pluginBlacklist = @@ -56,7 +58,77 @@ const std::set Lv2Manager::pluginBlacklist = "http://calf.sourceforge.net/plugins/StereoTools", "http://calf.sourceforge.net/plugins/TapeSimulator", "http://calf.sourceforge.net/plugins/TransientDesigner", - "http://calf.sourceforge.net/plugins/Vinyl" + "http://calf.sourceforge.net/plugins/Vinyl", + + // Visualization, meters, and scopes etc., won't work until we have gui support + "http://distrho.sf.net/plugins/ProM", + "http://distrho.sf.net/plugins/glBars", + "http://gareus.org/oss/lv2/meters#spectr30mono", + "http://gareus.org/oss/lv2/meters#spectr30stereo", + "http://gareus.org/oss/lv2/meters#bitmeter", + "http://gareus.org/oss/lv2/meters#BBCM6", + "http://gareus.org/oss/lv2/meters#BBCmono", + "http://gareus.org/oss/lv2/meters#BBCstereo", + "http://gareus.org/oss/lv2/meters#DINmono", + "http://gareus.org/oss/lv2/meters#DINstereo", + "http://gareus.org/oss/lv2/meters#EBUmono", + "http://gareus.org/oss/lv2/meters#EBUstereo", + "http://gareus.org/oss/lv2/meters#EBUr128", + "http://gareus.org/oss/lv2/meters#BBCM6", + "http://gareus.org/oss/lv2/meters#dr14mono", + "http://gareus.org/oss/lv2/meters#dr14stereo", + "http://gareus.org/oss/lv2/meters#K12mono", + "http://gareus.org/oss/lv2/meters#K12stereo", + "http://gareus.org/oss/lv2/meters#K14mono", + "http://gareus.org/oss/lv2/meters#K14stereo", + "http://gareus.org/oss/lv2/meters#K20mono", + "http://gareus.org/oss/lv2/meters#K20stereo", + "http://gareus.org/oss/lv2/meters#NORmono", + "http://gareus.org/oss/lv2/meters#NORstereo", + "http://gareus.org/oss/lv2/meters#COR", + "http://gareus.org/oss/lv2/meters#dBTPmono", + "http://gareus.org/oss/lv2/meters#dBTPstereo", + "http://gareus.org/oss/lv2/meters#TPnRMSmono", + "http://gareus.org/oss/lv2/meters#TPnRMSstereo", + "http://gareus.org/oss/lv2/meters#VUmono", + "http://gareus.org/oss/lv2/meters#VUstereo", + "http://gareus.org/oss/lv2/meters#goniometer", + "http://gareus.org/oss/lv2/meters#stereoscope", + "http://gareus.org/oss/lv2/meters#SigDistHist", + "http://gareus.org/oss/lv2/tuna#one", + "http://gareus.org/oss/lv2/tuna#two", + "http://gareus.org/oss/lv2/sisco#Mono", + "http://gareus.org/oss/lv2/sisco#Stereo", + "http://gareus.org/oss/lv2/spectra#Mono", + "http://gareus.org/oss/lv2/convoLV2#Mono", + "http://gareus.org/oss/lv2/convoLV2#MonoToStereo", + "http://gareus.org/oss/lv2/convoLV2#Stereo", + "http://gareus.org/oss/lv2/zeroconvolv#CfgMono", + "http://gareus.org/oss/lv2/zeroconvolv#CfgMonoToStereo", + "http://gareus.org/oss/lv2/zeroconvolv#CfgStereo", + "http://gareus.org/oss/lv2/zeroconvolv#Mono", + "http://gareus.org/oss/lv2/zeroconvolv#MonoToStereo", + "http://gareus.org/oss/lv2/zeroconvolv#Stereo", + "http://lsp-plug.in/plugins/lv2/latency_meter", + "http://lsp-plug.in/plugins/lv2/spectrum_analyzer_x1", + "http://lsp-plug.in/plugins/lv2/spectrum_analyzer_x2", + "http://lsp-plug.in/plugins/lv2/phase_detector", + "http://lsp-plug.in/plugins/lv2/profiler_mono", + "http://lsp-plug.in/plugins/lv2/profiler_stereo", + "http://invadarecords.com/plugins/lv2/meter", + "http://guitarix.sourceforge.net/plugins/gxtuner#tuner", + "https://github.com/jpcima/ADLplug", + "https://github.com/HiFi-LoFi/KlangFalter", + "https://github.com/klangfreund/SpectrumAnalyser", + "https://github.com/klangfreund/lufsmeter", + "https://github.com/laixinyuan/StereoSourceSepartion", + "urn:juce:TalFilter2", + "urn:juce:Vex", + "http://zynaddsubfx.sourceforge.net", + "http://geontime.com/geonkick/single", + + // unstable + "urn:juced:DrumSynth" }; @@ -260,6 +332,6 @@ bool Lv2Manager::isSubclassOf(const LilvPluginClass* clvss, const char* uriStr) } - +} // namespace lmms #endif // LMMS_HAVE_LV2 diff --git a/src/core/lv2/Lv2Options.cpp b/src/core/lv2/Lv2Options.cpp index e941165f0..36281ee63 100644 --- a/src/core/lv2/Lv2Options.cpp +++ b/src/core/lv2/Lv2Options.cpp @@ -29,6 +29,10 @@ #include +namespace lmms +{ + + std::set Lv2Options::s_supportedOptions; @@ -90,4 +94,6 @@ void Lv2Options::initOption(LV2_URID key, uint32_t size, LV2_URID type, } +} // namespace lmms + #endif // LMMS_HAVE_LV2 diff --git a/src/core/lv2/Lv2Ports.cpp b/src/core/lv2/Lv2Ports.cpp index 4db7f3e2a..1ce1d6956 100644 --- a/src/core/lv2/Lv2Ports.cpp +++ b/src/core/lv2/Lv2Ports.cpp @@ -35,7 +35,9 @@ #include "Lv2Manager.h" #include "Lv2Evbuf.h" -namespace Lv2Ports { + +namespace lmms::Lv2Ports +{ @@ -350,16 +352,7 @@ void AtomSeq::Lv2EvbufDeleter::operator()(LV2_Evbuf *n) { lv2_evbuf_free(n); } -// make the compiler happy, give each class with virtuals -// a function (the destructor here) which is in a cpp file -PortBase::~PortBase() {} -ConstVisitor::~ConstVisitor() {} -Visitor::~Visitor() {} - - - - -} // namespace Lv2Ports +} // namespace lmms::Lv2Ports #endif // LMMS_HAVE_LV2 diff --git a/src/core/lv2/Lv2Proc.cpp b/src/core/lv2/Lv2Proc.cpp index 59f84befe..cbb4be2d2 100644 --- a/src/core/lv2/Lv2Proc.cpp +++ b/src/core/lv2/Lv2Proc.cpp @@ -45,6 +45,8 @@ #include "MidiEventToByteSeq.h" +namespace lmms +{ // container for everything required to store MIDI events going to the plugin @@ -63,8 +65,8 @@ Plugin::PluginTypes Lv2Proc::check(const LilvPlugin *plugin, { unsigned maxPorts = lilv_plugin_get_num_ports(plugin); enum { inCount, outCount, maxCount }; - unsigned audioChannels[maxCount] = { 0, 0 }; // audio input and output count - unsigned midiChannels[maxCount] = { 0, 0 }; // MIDI input and output count + auto audioChannels = std::array{}; // audio input and output count + auto midiChannels = std::array{}; // MIDI input and output count const char* pluginUri = lilv_node_as_uri(lilv_plugin_get_uri(plugin)); //qDebug() << "Checking plugin" << pluginUri << "..."; @@ -245,11 +247,11 @@ void Lv2Proc::copyModelsFromCore() ev.time.frames(Engine::framesPerTick()) + ev.offset; uint32_t type = Engine::getLv2Manager()-> uridCache()[Lv2UridCache::Id::midi_MidiEvent]; - uint8_t buf[4]; - std::size_t bufsize = writeToByteSeq(ev.ev, buf, sizeof(buf)); + auto buf = std::array{}; + std::size_t bufsize = writeToByteSeq(ev.ev, buf.data(), buf.size()); if(bufsize) { - lv2_evbuf_write(&iter, atomStamp, type, bufsize, buf); + lv2_evbuf_write(&iter, atomStamp, type, bufsize, buf.data()); } } } @@ -363,7 +365,7 @@ void Lv2Proc::handleMidiInputEvent(const MidiEvent &event, const TimePos &time, else { qWarning() << "Warning: Caught MIDI event for an Lv2 instrument" - << "that can not hande MIDI... Ignoring"; + << "that can not handle MIDI... Ignoring"; } } @@ -498,7 +500,7 @@ void Lv2Proc::createPort(std::size_t portNum) { case Lv2Ports::Type::Control: { - Lv2Ports::Control* ctrl = new Lv2Ports::Control; + auto ctrl = new Lv2Ports::Control; if (meta.m_flow == Lv2Ports::Flow::Input) { AutoLilvNode node(lilv_port_get_name(m_plugin, lilvPort)); @@ -540,9 +542,7 @@ void Lv2Proc::createPort(std::size_t portNum) break; case Lv2Ports::Vis::Enumeration: { - ComboBoxModel* comboModel - = new ComboBoxModel( - nullptr, dispName); + auto comboModel = new ComboBoxModel(nullptr, dispName); LilvScalePoints* sps = lilv_port_get_scale_points(m_plugin, lilvPort); LILV_FOREACH(scale_points, i, sps) @@ -576,18 +576,14 @@ void Lv2Proc::createPort(std::size_t portNum) } case Lv2Ports::Type::Audio: { - Lv2Ports::Audio* audio = - new Lv2Ports::Audio( - static_cast( - Engine::audioEngine()->framesPerPeriod()), - portIsSideChain(m_plugin, lilvPort) - ); + auto audio = new Lv2Ports::Audio(static_cast(Engine::audioEngine()->framesPerPeriod()), + portIsSideChain(m_plugin, lilvPort)); port = audio; break; } case Lv2Ports::Type::AtomSeq: { - Lv2Ports::AtomSeq* atomPort = new Lv2Ports::AtomSeq; + auto atomPort = new Lv2Ports::AtomSeq; { AutoLilvNode uriAtomSupports(Engine::getLv2Manager()->uri(LV2_ATOM__supports)); @@ -754,11 +750,9 @@ struct ConnectPortVisitor : public Lv2Ports::Visitor connectPort((audio.mustBeUsed()) ? audio.m_buffer.data() : nullptr); } void visit(Lv2Ports::Unknown&) override { connectPort(nullptr); } - ~ConnectPortVisitor() override; + ~ConnectPortVisitor() override = default; }; -ConnectPortVisitor::~ConnectPortVisitor() {} - // !This function must be realtime safe! // use createPort to create any port before connecting void Lv2Proc::connectPort(std::size_t num) @@ -839,4 +833,6 @@ AutoLilvNode Lv2Proc::uri(const char *uriStr) } +} // namespace lmms + #endif // LMMS_HAVE_LV2 diff --git a/src/core/lv2/Lv2SubPluginFeatures.cpp b/src/core/lv2/Lv2SubPluginFeatures.cpp index 8fb908cb1..4fb377b1c 100644 --- a/src/core/lv2/Lv2SubPluginFeatures.cpp +++ b/src/core/lv2/Lv2SubPluginFeatures.cpp @@ -35,6 +35,9 @@ #include "Lv2Basics.h" #include "Lv2Manager.h" +namespace lmms +{ + const LilvPlugin *Lv2SubPluginFeatures::getPlugin( const Plugin::Descriptor::SubPluginFeatures::Key &k) @@ -69,23 +72,23 @@ void Lv2SubPluginFeatures::fillDescriptionWidget(QWidget *parent, { const LilvPlugin *plug = getPlugin(*k); - QLabel *label = new QLabel(parent); + auto label = new QLabel(parent); label->setText(QWidget::tr("Name: ") + pluginName(plug)); - QLabel *label2 = new QLabel(parent); + auto label2 = new QLabel(parent); label2->setText(QWidget::tr("URI: ") + lilv_node_as_uri(lilv_plugin_get_uri(plug))); - QWidget *maker = new QWidget(parent); - QHBoxLayout *l = new QHBoxLayout(maker); + auto maker = new QWidget(parent); + auto l = new QHBoxLayout(maker); l->setMargin(0); l->setSpacing(0); - QLabel *maker_label = new QLabel(maker); + auto maker_label = new QLabel(maker); maker_label->setText(QWidget::tr("Maker: ")); maker_label->setAlignment(Qt::AlignTop); - QLabel *maker_content = new QLabel(maker); + auto maker_content = new QLabel(maker); maker_content->setText( qStringFromPluginNode(plug, lilv_plugin_get_author_name)); maker_content->setWordWrap(true); @@ -93,17 +96,17 @@ void Lv2SubPluginFeatures::fillDescriptionWidget(QWidget *parent, l->addWidget(maker_label); l->addWidget(maker_content, 1); - QWidget *copyright = new QWidget(parent); + auto copyright = new QWidget(parent); l = new QHBoxLayout(copyright); l->setMargin(0); l->setSpacing(0); copyright->setMinimumWidth(parent->minimumWidth()); - QLabel *copyright_label = new QLabel(copyright); + auto copyright_label = new QLabel(copyright); copyright_label->setText(QWidget::tr("Copyright: ")); copyright_label->setAlignment(Qt::AlignTop); - QLabel *copyright_content = new QLabel(copyright); + auto copyright_content = new QLabel(copyright); copyright_content->setText(""); copyright_content->setWordWrap(true); l->addWidget(copyright_label); @@ -179,5 +182,8 @@ void Lv2SubPluginFeatures::listSubPluginKeys(const Plugin::Descriptor *desc, } } + +} // namespace lmms + #endif // LMMS_HAVE_LV2 diff --git a/src/core/lv2/Lv2UridCache.cpp b/src/core/lv2/Lv2UridCache.cpp index 3392f9bd2..746878afb 100644 --- a/src/core/lv2/Lv2UridCache.cpp +++ b/src/core/lv2/Lv2UridCache.cpp @@ -39,6 +39,10 @@ #define LV2_BUF_SIZE__nominalBlockLength LV2_BUF_SIZE_PREFIX "nominalBlockLength" #endif +namespace lmms +{ + + uint32_t Lv2UridCache::operator[](Lv2UridCache::Id id) const { Q_ASSERT(id != Id::size); @@ -67,6 +71,9 @@ Lv2UridCache::Lv2UridCache(UridMap &mapper) for(uint32_t urid : m_cache) { Q_ASSERT(urid != noIdYet); } } + +} // namespace lmms + #endif // LMMS_HAVE_LV2 diff --git a/src/core/lv2/Lv2UridMap.cpp b/src/core/lv2/Lv2UridMap.cpp index 7e4fa864f..ecc28693f 100644 --- a/src/core/lv2/Lv2UridMap.cpp +++ b/src/core/lv2/Lv2UridMap.cpp @@ -27,15 +27,19 @@ #ifdef LMMS_HAVE_LV2 +namespace lmms +{ + + static LV2_URID staticMap(LV2_URID_Map_Handle handle, const char* uri) { - UridMap* map = static_cast(handle); + auto map = static_cast(handle); return map->map(uri); } static const char* staticUnmap(LV2_URID_Unmap_Handle handle, LV2_URID urid) { - UridMap* map = static_cast(handle); + auto map = static_cast(handle); return map->unmap(urid); } @@ -95,5 +99,8 @@ const char *UridMap::unmap(LV2_URID urid) return (idx < m_unMap.size()) ? m_unMap[idx] : nullptr; } + +} // namespace lmms + #endif // LMMS_HAVE_LV2 diff --git a/src/core/main.cpp b/src/core/main.cpp index 953995b67..da13181fe 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -120,13 +120,13 @@ void consoleMessageHandler(QtMsgType type, QByteArray localMsg = msg.toLocal8Bit(); fprintf(stderr, "%s\n", localMsg.constData()); } -#endif +#endif // LMMS_BUILD_WIN32 inline void loadTranslation( const QString & tname, - const QString & dir = ConfigManager::inst()->localeDir() ) + const QString & dir = lmms::ConfigManager::inst()->localeDir() ) { - QTranslator * t = new QTranslator( QCoreApplication::instance() ); + auto t = new QTranslator(QCoreApplication::instance()); QString name = tname + ".qm"; if (t->load(name, dir)) @@ -252,6 +252,8 @@ int noInputFileError() int main( int argc, char * * argv ) { + using namespace lmms; + #ifdef LMMS_DEBUG_FPE // Enable exceptions for certain floating point results // FE_UNDERFLOW is disabled for the time being @@ -359,7 +361,7 @@ int main( int argc, char * * argv ) #endif QCoreApplication * app = coreOnly ? new QCoreApplication( argc, argv ) : - new MainApplication( argc, argv ); + new gui::MainApplication(argc, argv); AudioEngine::qualitySettings qs( AudioEngine::qualitySettings::Mode_HighQuality ); OutputSettings os( 44100, OutputSettings::BitRateSettings(160, false), OutputSettings::Depth_16Bit, OutputSettings::StereoMode_JointStereo ); @@ -774,7 +776,7 @@ int main( int argc, char * * argv ) printf( "Notice: could not set realtime priority.\n" ); } #endif -#endif +#endif // LMMS_HAVE_SCHED_H #endif #ifdef LMMS_BUILD_WIN32 @@ -827,14 +829,14 @@ int main( int argc, char * * argv ) } // create renderer - RenderManager * r = new RenderManager( qs, os, eff, renderOut ); + auto r = new RenderManager(qs, os, eff, renderOut); QCoreApplication::instance()->connect( r, - SIGNAL( finished() ), SLOT( quit() ) ); + SIGNAL(finished()), SLOT(quit())); // timer for progress-updates - QTimer * t = new QTimer( r ); - r->connect( t, SIGNAL( timeout() ), - SLOT( updateConsoleProgress() ) ); + auto t = new QTimer(r); + r->connect( t, SIGNAL(timeout()), + SLOT(updateConsoleProgress())); t->start( 200 ); if( profilerOutputFile.isEmpty() == false ) @@ -854,6 +856,8 @@ int main( int argc, char * * argv ) } else // otherwise, start the GUI { + using namespace lmms::gui; + new GuiApplication(); // re-intialize RNG - shared libraries might have srand() or @@ -1007,7 +1011,7 @@ int main( int argc, char * * argv ) // instances of LMMS. if( autoSaveEnabled ) { - getGUI()->mainWindow()->autoSaveTimerReset(); + gui::getGUI()->mainWindow()->autoSaveTimerReset(); } } diff --git a/src/core/midi/MidiAlsaRaw.cpp b/src/core/midi/MidiAlsaRaw.cpp index 883d31e96..23364fc01 100644 --- a/src/core/midi/MidiAlsaRaw.cpp +++ b/src/core/midi/MidiAlsaRaw.cpp @@ -29,6 +29,10 @@ #ifdef LMMS_HAVE_ALSA +namespace lmms +{ + + MidiAlsaRaw::MidiAlsaRaw() : MidiClientRaw(), m_inputp( &m_input ), @@ -101,7 +105,7 @@ void MidiAlsaRaw::sendByte( unsigned char c ) void MidiAlsaRaw::run() { - unsigned char buf[128]; + auto buf = std::array{}; //int cnt = 0; while( m_quit == false ) { @@ -145,7 +149,7 @@ void MidiAlsaRaw::run() { continue; } - err = snd_rawmidi_read( m_input, buf, sizeof( buf ) ); + err = snd_rawmidi_read(m_input, buf.data(), buf.size()); if( err == -EAGAIN ) { continue; @@ -169,5 +173,7 @@ void MidiAlsaRaw::run() } -#endif +} // namespace lmms + +#endif // LMMS_HAVE_ALSA diff --git a/src/core/midi/MidiAlsaSeq.cpp b/src/core/midi/MidiAlsaSeq.cpp index b04964843..760840c77 100644 --- a/src/core/midi/MidiAlsaSeq.cpp +++ b/src/core/midi/MidiAlsaSeq.cpp @@ -31,6 +31,10 @@ #ifdef LMMS_HAVE_ALSA + +namespace lmms +{ + const int EventPollTimeOut = 250; @@ -97,14 +101,14 @@ MidiAlsaSeq::MidiAlsaSeq() : snd_seq_start_queue( m_seqHandle, m_queueID, nullptr ); changeQueueTempo( Engine::getSong()->getTempo() ); - connect( Engine::getSong(), SIGNAL( tempoChanged( bpm_t ) ), - this, SLOT( changeQueueTempo( bpm_t ) ), Qt::DirectConnection ); + connect( Engine::getSong(), SIGNAL(tempoChanged(lmms::bpm_t)), + this, SLOT(changeQueueTempo(lmms::bpm_t)), Qt::DirectConnection ); // initial list-update updatePortList(); - connect( &m_portListUpdateTimer, SIGNAL( timeout() ), - this, SLOT( updatePortList() ) ); + connect( &m_portListUpdateTimer, SIGNAL(timeout()), + this, SLOT(updatePortList())); // we check for port-changes every second m_portListUpdateTimer.start( 1000 ); @@ -160,7 +164,7 @@ void MidiAlsaSeq::processOutEvent( const MidiEvent& event, const TimePos& time, // HACK!!! - need a better solution which isn't that easy since we // cannot store const-ptrs in our map because we need to call non-const // methods of MIDI-port - it's a mess... - MidiPort* p = const_cast( port ); + auto p = const_cast(port); snd_seq_event_t ev; snd_seq_ev_clear( &ev ); @@ -237,7 +241,7 @@ void MidiAlsaSeq::applyPortMode( MidiPort * _port ) m_seqMutex.lock(); // determine port-capabilities - unsigned int caps[2] = { 0, 0 }; + auto caps = std::array{}; switch( _port->mode() ) { @@ -349,8 +353,7 @@ QString MidiAlsaSeq::sourcePortName( const MidiEvent & _event ) const { if( _event.sourcePort() ) { - const snd_seq_addr_t * addr = - static_cast( _event.sourcePort() ); + const auto addr = static_cast(_event.sourcePort()); return portName( m_seqHandle, addr ); } return MidiClient::sourcePortName( _event ); @@ -458,7 +461,7 @@ void MidiAlsaSeq::run() // watch the pipe and sequencer input events int pollfd_count = snd_seq_poll_descriptors_count( m_seqHandle, POLLIN ); - struct pollfd * pollfd_set = new struct pollfd[pollfd_count + 1]; + auto pollfd_set = new struct pollfd[pollfd_count + 1]; snd_seq_poll_descriptors( m_seqHandle, pollfd_set + 1, pollfd_count, POLLIN ); pollfd_set[0].fd = m_pipe[0]; @@ -693,5 +696,7 @@ void MidiAlsaSeq::updatePortList() } -#endif +} // namespace lmms + +#endif // LMMS_HAVE_ALSA diff --git a/src/core/midi/MidiApple.cpp b/src/core/midi/MidiApple.cpp index 66a996d0f..01836c50b 100644 --- a/src/core/midi/MidiApple.cpp +++ b/src/core/midi/MidiApple.cpp @@ -36,6 +36,11 @@ #include + +namespace lmms +{ + + const unsigned int SYSEX_LENGTH=1024; MidiApple::MidiApple() : @@ -625,6 +630,6 @@ char * MidiApple::getFullName(MIDIEndpointRef &endpoint_ref) } -#endif - +} // namespace lmms +#endif // LMMS_BUILD_APPLE diff --git a/src/core/midi/MidiClient.cpp b/src/core/midi/MidiClient.cpp index 109e01fd6..78691de6f 100644 --- a/src/core/midi/MidiClient.cpp +++ b/src/core/midi/MidiClient.cpp @@ -27,12 +27,8 @@ #include "MidiPort.h" -MidiClient::MidiClient() +namespace lmms { -} - - - MidiClient::~MidiClient() { @@ -103,30 +99,16 @@ void MidiClient::subscribeWritablePort( MidiPort* , const QString& , bool ) -MidiClientRaw::MidiClientRaw() -{ -} - - - - -MidiClientRaw::~MidiClientRaw() -{ -} - - - - void MidiClientRaw::parseData( const unsigned char c ) { /*********************************************************************/ /* 'Process' system real-time messages */ /*********************************************************************/ /* There are not too many real-time messages that are of interest here. - * They can occur anywhere, even in the middle of a noteon message! + * They can occur anywhere, even in the middle of a noteon message! * Real-time range: 0xF8 .. 0xFF * Note: Real-time does not affect (running) status. - */ + */ if( c >= 0xF8 ) { if( c == MidiSystemReset ) @@ -142,13 +124,13 @@ void MidiClientRaw::parseData( const unsigned char c ) /* 'Process' system common messages (again, just skip them) */ /*********************************************************************/ /* There are no system common messages that are of interest here. - * System common range: 0xF0 .. 0xF7 + * System common range: 0xF0 .. 0xF7 */ if( c > 0xF0 ) { /* MIDI spec say: To ignore a non-real-time message, just discard all * data up to the next status byte. And our parser will ignore data - * that is received without a valid status. + * that is received without a valid status. * Note: system common cancels running status. */ m_midiParseData.m_status = 0; return; @@ -204,14 +186,14 @@ void MidiClientRaw::parseData( const unsigned char c ) /*********************************************************************/ /* Send the event */ /*********************************************************************/ - /* The event is ready-to-go. About 'running status': - * + /* The event is ready-to-go. About 'running status': + * * The MIDI protocol has a built-in compression mechanism. If several * similar events are sent in-a-row, for example note-ons, then the * event type is only sent once. For this case, the last event type * (status) is remembered. * We simply keep the status as it is, just reset the parameter counter. - * If another status byte comes in, it will overwrite the status. + * If another status byte comes in, it will overwrite the status. */ m_midiParseData.m_midiEvent.setType(static_cast(m_midiParseData.m_status)); m_midiParseData.m_midiEvent.setChannel(m_midiParseData.m_channel); @@ -221,12 +203,15 @@ void MidiClientRaw::parseData( const unsigned char c ) case MidiNoteOff: case MidiNoteOn: case MidiKeyPressure: - case MidiChannelPressure: - case MidiProgramChange: m_midiParseData.m_midiEvent.setKey(m_midiParseData.m_buffer[0]); m_midiParseData.m_midiEvent.setVelocity(m_midiParseData.m_buffer[1]); break; + case MidiChannelPressure: + case MidiProgramChange: + m_midiParseData.m_midiEvent.setParam(0, m_midiParseData.m_buffer[0]); + break; + case MidiControlChange: m_midiParseData.m_midiEvent.setControllerNumber(m_midiParseData.m_buffer[0]); m_midiParseData.m_midiEvent.setControllerValue( m_midiParseData.m_buffer[1]); @@ -239,7 +224,7 @@ void MidiClientRaw::parseData( const unsigned char c ) m_midiParseData.m_midiEvent.setPitchBend((m_midiParseData.m_buffer[1] * 128) | m_midiParseData.m_buffer[0]); break; - default: + default: // Unlikely return; } @@ -252,9 +237,9 @@ void MidiClientRaw::parseData( const unsigned char c ) void MidiClientRaw::processParsedEvent() { - for( int i = 0; i < m_midiPorts.size(); ++i ) + for (const auto& midiPort : m_midiPorts) { - m_midiPorts[i]->processInEvent( m_midiParseData.m_midiEvent ); + midiPort->processInEvent(m_midiParseData.m_midiEvent); } } @@ -286,7 +271,7 @@ void MidiClientRaw::processOutEvent(const MidiEvent& event, const TimePos&, cons // Taken from Nagano Daisuke's USB-MIDI driver -static const unsigned char REMAINS_F0F6[] = +static const auto REMAINS_F0F6 = std::array { 0, /* 0xF0 */ 2, /* 0XF1 */ @@ -297,7 +282,7 @@ static const unsigned char REMAINS_F0F6[] = 1 /* 0XF6 */ } ; -static const unsigned char REMAINS_80E0[] = +static const auto REMAINS_80E0 = std::array { 3, /* 0x8X Note Off */ 3, /* 0x9X Note On */ @@ -324,3 +309,5 @@ int MidiClientRaw::eventLength( const unsigned char event ) } return 1; } + +} // namespace lmms \ No newline at end of file diff --git a/src/core/midi/MidiController.cpp b/src/core/midi/MidiController.cpp index 91d0dd782..fbd48e945 100644 --- a/src/core/midi/MidiController.cpp +++ b/src/core/midi/MidiController.cpp @@ -28,6 +28,9 @@ #include "AudioEngine.h" #include "MidiController.h" +namespace lmms +{ + MidiController::MidiController( Model * _parent ) : Controller( Controller::MidiController, _parent, tr( "MIDI Controller" ) ), @@ -37,15 +40,8 @@ MidiController::MidiController( Model * _parent ) : m_previousValue( 0.0f ) { setSampleExact( true ); - connect( &m_midiPort, SIGNAL( modeChanged() ), - this, SLOT( updateName() ) ); -} - - - - -MidiController::~MidiController() -{ + connect( &m_midiPort, SIGNAL(modeChanged()), + this, SLOT(updateName())); } @@ -146,11 +142,11 @@ QString MidiController::nodeName() const -ControllerDialog * MidiController::createDialog( QWidget * _parent ) +gui::ControllerDialog* MidiController::createDialog( QWidget * _parent ) { return nullptr; } - +} // namespace lmms diff --git a/src/core/midi/MidiEventToByteSeq.cpp b/src/core/midi/MidiEventToByteSeq.cpp index 98f0541d0..6ef302c30 100644 --- a/src/core/midi/MidiEventToByteSeq.cpp +++ b/src/core/midi/MidiEventToByteSeq.cpp @@ -29,6 +29,10 @@ #include "MidiEvent.h" +namespace lmms +{ + + std::size_t writeToByteSeq( const MidiEvent& ev, uint8_t *data, std::size_t bufsize) { @@ -105,3 +109,5 @@ std::size_t writeToByteSeq( return size; } + +} // namespace lmms diff --git a/src/core/midi/MidiJack.cpp b/src/core/midi/MidiJack.cpp index fdf194889..145a72ecc 100644 --- a/src/core/midi/MidiJack.cpp +++ b/src/core/midi/MidiJack.cpp @@ -35,10 +35,13 @@ #include "Engine.h" #include "MainWindow.h" +namespace lmms +{ + /* callback functions for jack */ static int JackMidiProcessCallback(jack_nframes_t nframes, void *arg) { - MidiJack *jmd = (MidiJack *)arg; + auto jmd = (MidiJack*)arg; if (nframes <= 0) return (0); @@ -55,7 +58,7 @@ static void JackMidiShutdown(void *arg) QString msg_short = MidiJack::tr("JACK server down"); //: When JACK(JACK Audio Connection Kit) disconnects, it will show the following message (dialog message) QString msg_long = MidiJack::tr("The JACK server seems to be shuted down."); - QMessageBox::information( getGUI()->mainWindow(), msg_short, msg_long ); + QMessageBox::information(gui::getGUI()->mainWindow(), msg_short, msg_long); } MidiJack::MidiJack() : @@ -228,4 +231,6 @@ void MidiJack::run() } } +} // namespace lmms + #endif // LMMS_HAVE_JACK diff --git a/src/core/midi/MidiOss.cpp b/src/core/midi/MidiOss.cpp index faf6453a2..848bac705 100644 --- a/src/core/midi/MidiOss.cpp +++ b/src/core/midi/MidiOss.cpp @@ -30,6 +30,9 @@ #include "ConfigManager.h" +namespace lmms +{ + MidiOss::MidiOss() : MidiClientRaw(), @@ -106,6 +109,6 @@ void MidiOss::run() } -#endif - +} // namespace lmms +#endif // LMMS_HAVE_OSS diff --git a/src/core/midi/MidiPort.cpp b/src/core/midi/MidiPort.cpp index 40460f434..63ca817e0 100644 --- a/src/core/midi/MidiPort.cpp +++ b/src/core/midi/MidiPort.cpp @@ -32,6 +32,11 @@ #include "Note.h" #include "Song.h" + +namespace lmms +{ + + static MidiDummy s_dummyClient; @@ -64,12 +69,12 @@ MidiPort::MidiPort( const QString& name, m_readableModel.setValue( m_mode == Input || m_mode == Duplex ); m_writableModel.setValue( m_mode == Output || m_mode == Duplex ); - connect( &m_readableModel, SIGNAL( dataChanged() ), - this, SLOT( updateMidiPortMode() ), Qt::DirectConnection ); - connect( &m_writableModel, SIGNAL( dataChanged() ), - this, SLOT( updateMidiPortMode() ), Qt::DirectConnection ); - connect( &m_outputProgramModel, SIGNAL( dataChanged() ), - this, SLOT( updateOutputProgram() ), Qt::DirectConnection ); + connect( &m_readableModel, SIGNAL(dataChanged()), + this, SLOT(updateMidiPortMode()), Qt::DirectConnection ); + connect( &m_writableModel, SIGNAL(dataChanged()), + this, SLOT(updateMidiPortMode()), Qt::DirectConnection ); + connect( &m_outputProgramModel, SIGNAL(dataChanged()), + this, SLOT(updateOutputProgram()), Qt::DirectConnection ); // when using with non-raw-clients we can provide buttons showing @@ -80,8 +85,8 @@ MidiPort::MidiPort( const QString& name, updateWritablePorts(); // we want to get informed about port-changes! - m_midiClient->connectRPChanged( this, SLOT( updateReadablePorts() ) ); - m_midiClient->connectWPChanged( this, SLOT( updateWritablePorts() ) ); + m_midiClient->connectRPChanged( this, SLOT(updateReadablePorts())); + m_midiClient->connectWPChanged( this, SLOT(updateWritablePorts())); } updateMidiPortMode(); @@ -373,9 +378,9 @@ void MidiPort::updateReadablePorts() m_readablePorts.clear(); const QStringList& wp = m_midiClient->readablePorts(); // now insert new ports and restore selections - for( QStringList::ConstIterator it = wp.begin(); it != wp.end(); ++it ) + for (const auto& port : wp) { - m_readablePorts[*it] = ( selectedPorts.indexOf( *it ) != -1 ); + m_readablePorts[port] = (selectedPorts.indexOf(port) != -1); } emit readablePortsChanged(); @@ -399,9 +404,9 @@ void MidiPort::updateWritablePorts() m_writablePorts.clear(); const QStringList & wp = m_midiClient->writablePorts(); // now insert new ports and restore selections - for( QStringList::ConstIterator it = wp.begin(); it != wp.end(); ++it ) + for (const auto& port : wp) { - m_writablePorts[*it] = ( selectedPorts.indexOf( *it ) != -1 ); + m_writablePorts[port] = (selectedPorts.indexOf(port) != -1); } emit writablePortsChanged(); @@ -422,3 +427,6 @@ void MidiPort::invalidateCilent() { m_midiClient = &s_dummyClient; } + + +} // namespace lmms \ No newline at end of file diff --git a/src/core/midi/MidiSndio.cpp b/src/core/midi/MidiSndio.cpp index 4acd2827e..e644113b2 100644 --- a/src/core/midi/MidiSndio.cpp +++ b/src/core/midi/MidiSndio.cpp @@ -34,7 +34,11 @@ #include "ConfigManager.h" -MidiSndio::MidiSndio( void ) : +namespace lmms +{ + + +MidiSndio::MidiSndio() : MidiClientRaw(), m_quit( false ) { @@ -70,7 +74,7 @@ MidiSndio::~MidiSndio() } -QString MidiSndio::probeDevice( void ) +QString MidiSndio::probeDevice() { QString dev = ConfigManager::inst()->value( "MidiSndio", "device" ); @@ -84,7 +88,7 @@ void MidiSndio::sendByte( const unsigned char c ) } -void MidiSndio::run( void ) +void MidiSndio::run() { struct pollfd pfd; nfds_t nfds; @@ -111,4 +115,7 @@ void MidiSndio::run( void ) } } -#endif /* LMMS_HAVE_SNDIO */ + +} // namespace lmms + +#endif // LMMS_HAVE_SNDIO diff --git a/src/core/midi/MidiWinMM.cpp b/src/core/midi/MidiWinMM.cpp index 80ebea964..811e0842c 100644 --- a/src/core/midi/MidiWinMM.cpp +++ b/src/core/midi/MidiWinMM.cpp @@ -27,6 +27,10 @@ #ifdef LMMS_BUILD_WIN32 +namespace lmms +{ + + MidiWinMM::MidiWinMM() : MidiClient(), m_inputDevices(), @@ -299,4 +303,6 @@ void MidiWinMM::openDevices() } -#endif +} // namespace lmms + +#endif // LMMS_BUILD_WIN32 diff --git a/src/gui/ActionGroup.cpp b/src/gui/ActionGroup.cpp index 5b40bd204..053bb556d 100644 --- a/src/gui/ActionGroup.cpp +++ b/src/gui/ActionGroup.cpp @@ -24,6 +24,9 @@ #include "ActionGroup.h" +namespace lmms::gui +{ + ActionGroup::ActionGroup(QObject* parent) : QActionGroup(parent) { connect(this, SIGNAL(triggered(QAction*)), this, SLOT(actionTriggered_(QAction*))); @@ -53,3 +56,5 @@ void ActionGroup::actionTriggered_(QAction* action) emit triggered(actions().indexOf(action)); } + +} // namespace lmms::gui \ No newline at end of file diff --git a/src/gui/AudioAlsaSetupWidget.cpp b/src/gui/AudioAlsaSetupWidget.cpp index 26da660da..4ea6d4c58 100644 --- a/src/gui/AudioAlsaSetupWidget.cpp +++ b/src/gui/AudioAlsaSetupWidget.cpp @@ -33,6 +33,8 @@ #include "LcdSpinBox.h" #include "gui_templates.h" +namespace lmms::gui +{ AudioAlsaSetupWidget::AudioAlsaSetupWidget( QWidget * _parent ) : AudioDeviceSetupWidget( AudioAlsa::name(), _parent ), @@ -65,11 +67,11 @@ AudioAlsaSetupWidget::AudioAlsaSetupWidget( QWidget * _parent ) : SIGNAL(currentIndexChanged(int)), SLOT(onCurrentIndexChanged(int))); - QLabel * dev_lbl = new QLabel( tr( "DEVICE" ), this ); + auto dev_lbl = new QLabel(tr("DEVICE"), this); dev_lbl->setFont( pointSize<7>( dev_lbl->font() ) ); dev_lbl->setGeometry( 10, 40, 160, 10 ); - LcdSpinBoxModel * m = new LcdSpinBoxModel( /* this */ ); + auto m = new LcdSpinBoxModel(/* this */); m->setRange( DEFAULT_CHANNELS, SURROUND_CHANNELS ); m->setStep( 2 ); m->setValue( ConfigManager::inst()->value( "audioalsa", @@ -116,4 +118,6 @@ void AudioAlsaSetupWidget::onCurrentIndexChanged(int index) } -#endif +} // namespace lmms::gui + +#endif // LMMS_HAVE_ALSA diff --git a/src/gui/AudioDeviceSetupWidget.cpp b/src/gui/AudioDeviceSetupWidget.cpp index feba3f1b0..b78800cec 100644 --- a/src/gui/AudioDeviceSetupWidget.cpp +++ b/src/gui/AudioDeviceSetupWidget.cpp @@ -24,18 +24,18 @@ #include "AudioDeviceSetupWidget.h" +namespace lmms::gui +{ AudioDeviceSetupWidget::AudioDeviceSetupWidget(const QString & caption, QWidget * parent) : TabWidget(TabWidget::tr("Settings for %1").arg(tr(caption.toUtf8())), parent) { } -AudioDeviceSetupWidget::~AudioDeviceSetupWidget() -{ -} - void AudioDeviceSetupWidget::show() { parentWidget()->show(); QWidget::show(); } + +} // namespace lmms::gui \ No newline at end of file diff --git a/src/gui/AutomatableModelView.cpp b/src/gui/AutomatableModelView.cpp index 082022d35..52ee1ed7e 100644 --- a/src/gui/AutomatableModelView.cpp +++ b/src/gui/AutomatableModelView.cpp @@ -38,9 +38,12 @@ #include "AutomationEditor.h" +namespace lmms::gui +{ + static float floatFromClipboard(bool* ok=nullptr); -AutomatableModelView::AutomatableModelView( ::Model* model, QWidget* _this ) : +AutomatableModelView::AutomatableModelView( Model* model, QWidget* _this ) : ModelView( model, _this ), m_conversionFactor( 1.0 ) { @@ -52,20 +55,20 @@ void AutomatableModelView::addDefaultActions( QMenu* menu ) { AutomatableModel* model = modelUntyped(); - AutomatableModelViewSlots* amvSlots = new AutomatableModelViewSlots( this, menu ); + auto amvSlots = new AutomatableModelViewSlots(this, menu); menu->addAction( embed::getIconPixmap( "reload" ), AutomatableModel::tr( "&Reset (%1%2)" ). arg( model->initValue() * m_conversionFactor ). arg( m_unit ), - model, SLOT( reset() ) ); + model, SLOT(reset())); menu->addSeparator(); menu->addAction( embed::getIconPixmap( "edit_copy" ), AutomatableModel::tr( "&Copy value (%1%2)" ). arg( model->value() * m_conversionFactor ). arg( m_unit ), - amvSlots, SLOT( copyToClipboard() ) ); + amvSlots, SLOT(copyToClipboard())); bool canPaste = true; const float valueToPaste = floatFromClipboard(&canPaste); @@ -75,7 +78,7 @@ void AutomatableModelView::addDefaultActions( QMenu* menu ) arg( m_unit ) : AutomatableModel::tr( "&Paste value"); QAction* pasteAction = menu->addAction( embed::getIconPixmap( "edit_paste" ), - pasteDesc, amvSlots, SLOT( pasteFromClipboard() ) ); + pasteDesc, amvSlots, SLOT(pasteFromClipboard())); pasteAction->setEnabled(canPaste); menu->addSeparator(); @@ -83,12 +86,12 @@ void AutomatableModelView::addDefaultActions( QMenu* menu ) menu->addAction( embed::getIconPixmap( "automation" ), AutomatableModel::tr( "Edit song-global automation" ), amvSlots, - SLOT( editSongGlobalAutomation() ) ); + SLOT(editSongGlobalAutomation())); menu->addAction( QPixmap(), AutomatableModel::tr( "Remove song-global automation" ), amvSlots, - SLOT( removeSongGlobalAutomation() ) ); + SLOT(removeSongGlobalAutomation())); menu->addSeparator(); @@ -96,7 +99,7 @@ void AutomatableModelView::addDefaultActions( QMenu* menu ) { menu->addAction( embed::getIconPixmap( "edit-delete" ), AutomatableModel::tr( "Remove all linked controls" ), - amvSlots, SLOT( unlinkAllModels() ) ); + amvSlots, SLOT(unlinkAllModels())); menu->addSeparator(); } @@ -117,16 +120,16 @@ void AutomatableModelView::addDefaultActions( QMenu* menu ) contMenu->addAction( embed::getIconPixmap( "controller" ), AutomatableModel::tr("Edit connection..."), - amvSlots, SLOT( execConnectionDialog() ) ); + amvSlots, SLOT(execConnectionDialog())); contMenu->addAction( embed::getIconPixmap( "cancel" ), AutomatableModel::tr("Remove connection"), - amvSlots, SLOT( removeConnection() ) ); + amvSlots, SLOT(removeConnection())); } else { menu->addAction( embed::getIconPixmap( "controller" ), AutomatableModel::tr("Connect to controller..."), - amvSlots, SLOT( execConnectionDialog() ) ); + amvSlots, SLOT(execConnectionDialog())); } } @@ -170,7 +173,7 @@ void AutomatableModelView::mousePressEvent( QMouseEvent* event ) { if( event->button() == Qt::LeftButton && event->modifiers() & Qt::ControlModifier ) { - new StringPairDrag( "automatable_model", QString::number( modelUntyped()->id() ), QPixmap(), widget() ); + new gui::StringPairDrag( "automatable_model", QString::number( modelUntyped()->id() ), QPixmap(), widget() ); event->accept(); } else if( event->button() == Qt::MidButton ) @@ -199,7 +202,7 @@ AutomatableModelViewSlots::AutomatableModelViewSlots( AutomatableModelView* amv, QObject(), m_amv( amv ) { - connect( parent, SIGNAL( destroyed() ), this, SLOT( deleteLater() ), Qt::QueuedConnection ); + connect( parent, SIGNAL(destroyed()), this, SLOT(deleteLater()), Qt::QueuedConnection ); } @@ -212,7 +215,7 @@ void AutomatableModelViewSlots::execConnectionDialog() AutomatableModel* m = m_amv->modelUntyped(); m->displayName(); - ControllerConnectionDialog d( getGUI()->mainWindow(), m ); + gui::ControllerConnectionDialog d( getGUI()->mainWindow(), m ); if( d.exec() == 1 ) { @@ -227,7 +230,7 @@ void AutomatableModelViewSlots::execConnectionDialog() // New else { - ControllerConnection* cc = new ControllerConnection(d.chosenController()); + auto cc = new ControllerConnection(d.chosenController()); m->setControllerConnection( cc ); //cc->setTargetName( m->displayName() ); } @@ -303,3 +306,5 @@ static float floatFromClipboard(bool* ok) return getString( MimeType::Default ).toFloat(ok); } + +} // namespace lmms::gui diff --git a/src/gui/ControlLayout.cpp b/src/gui/ControlLayout.cpp index 0885c3c44..7e0976c94 100644 --- a/src/gui/ControlLayout.cpp +++ b/src/gui/ControlLayout.cpp @@ -80,6 +80,10 @@ #include #include + +namespace lmms::gui +{ + constexpr const int ControlLayout::m_minWidth; ControlLayout::ControlLayout(QWidget *parent, int margin, int hSpacing, int vSpacing) @@ -305,10 +309,11 @@ int ControlLayout::smartSpacing(QStyle::PixelMetric pm) const if (!parent) { return -1; } else if (parent->isWidgetType()) { - QWidget *pw = static_cast(parent); + auto pw = static_cast(parent); return pw->style()->pixelMetric(pm, nullptr, pw); } else { return static_cast(parent)->spacing(); } } +} // namespace lmms::gui diff --git a/src/gui/ControllerDialog.cpp b/src/gui/ControllerDialog.cpp index f854ab1b9..344898808 100644 --- a/src/gui/ControllerDialog.cpp +++ b/src/gui/ControllerDialog.cpp @@ -28,6 +28,9 @@ #include "ControllerDialog.h" #include "Controller.h" +namespace lmms::gui +{ + ControllerDialog::ControllerDialog( Controller * _controller, QWidget * _parent ) : @@ -38,12 +41,6 @@ ControllerDialog::ControllerDialog( Controller * _controller, -ControllerDialog::~ControllerDialog() -{ -} - - - void ControllerDialog::closeEvent( QCloseEvent * _ce ) { _ce->ignore(); @@ -52,4 +49,4 @@ void ControllerDialog::closeEvent( QCloseEvent * _ce ) - +} // namespace lmms::gui diff --git a/src/gui/ControllerRackView.cpp b/src/gui/ControllerRackView.cpp index 2b597e1c2..54c325dc6 100644 --- a/src/gui/ControllerRackView.cpp +++ b/src/gui/ControllerRackView.cpp @@ -38,8 +38,11 @@ #include "LfoController.h" #include "SubWindow.h" +namespace lmms::gui +{ -ControllerRackView::ControllerRackView( ) : + +ControllerRackView::ControllerRackView() : QWidget(), m_nextIndex(0) { @@ -50,7 +53,7 @@ ControllerRackView::ControllerRackView( ) : m_scrollArea->setPalette( QApplication::palette( m_scrollArea ) ); m_scrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); - QWidget * scrollAreaWidget = new QWidget( m_scrollArea ); + auto scrollAreaWidget = new QWidget(m_scrollArea); m_scrollAreaLayout = new QVBoxLayout( scrollAreaWidget ); m_scrollAreaLayout->addStretch(); scrollAreaWidget->setLayout( m_scrollAreaLayout ); @@ -61,14 +64,14 @@ ControllerRackView::ControllerRackView( ) : m_addButton = new QPushButton( this ); m_addButton->setText( tr( "Add" ) ); - connect( m_addButton, SIGNAL( clicked() ), - this, SLOT( addController() ) ); + connect( m_addButton, SIGNAL(clicked()), + this, SLOT(addController())); Song * song = Engine::getSong(); - connect( song, SIGNAL( controllerAdded( Controller* ) ), SLOT( onControllerAdded( Controller* ) ) ); - connect( song, SIGNAL( controllerRemoved( Controller* ) ), SLOT( onControllerRemoved( Controller* ) ) ); + connect( song, SIGNAL(controllerAdded(lmms::Controller*)), SLOT(onControllerAdded(lmms::Controller*))); + connect( song, SIGNAL(controllerRemoved(lmms::Controller*)), SLOT(onControllerRemoved(lmms::Controller*))); - QVBoxLayout * layout = new QVBoxLayout(); + auto layout = new QVBoxLayout(); layout->addWidget( m_scrollArea ); layout->addWidget( m_addButton ); this->setLayout( layout ); @@ -90,13 +93,6 @@ ControllerRackView::ControllerRackView( ) : -ControllerRackView::~ControllerRackView() -{ -} - - - - void ControllerRackView::saveSettings( QDomDocument & _doc, QDomElement & _this ) { @@ -143,10 +139,10 @@ void ControllerRackView::onControllerAdded( Controller * controller ) { QWidget * scrollAreaWidget = m_scrollArea->widget(); - ControllerView * controllerView = new ControllerView( controller, scrollAreaWidget ); + auto controllerView = new ControllerView(controller, scrollAreaWidget); - connect( controllerView, SIGNAL( deleteController( ControllerView * ) ), - this, SLOT( deleteController( ControllerView * ) ), Qt::QueuedConnection ); + connect( controllerView, SIGNAL(deleteController(lmms::gui::ControllerView*)), + this, SLOT(deleteController(lmms::gui::ControllerView*)), Qt::QueuedConnection ); m_controllerViews.append( controllerView ); m_scrollAreaLayout->insertWidget( m_nextIndex, controllerView ); @@ -212,3 +208,5 @@ void ControllerRackView::closeEvent( QCloseEvent * _ce ) _ce->ignore(); } + +} // namespace lmms::gui diff --git a/src/gui/ControllerView.cpp b/src/gui/ControllerView.cpp index a3b1a7934..3e3f4b9d1 100644 --- a/src/gui/ControllerView.cpp +++ b/src/gui/ControllerView.cpp @@ -40,6 +40,9 @@ #include "MainWindow.h" #include "SubWindow.h" +namespace lmms::gui +{ + ControllerView::ControllerView( Controller * _model, QWidget * _parent ) : QFrame( _parent ), @@ -51,20 +54,20 @@ ControllerView::ControllerView( Controller * _model, QWidget * _parent ) : this->setFrameStyle( QFrame::StyledPanel ); this->setFrameShadow( QFrame::Raised ); - QVBoxLayout *vBoxLayout = new QVBoxLayout(this); + auto vBoxLayout = new QVBoxLayout(this); - QHBoxLayout *hBox = new QHBoxLayout(); + auto hBox = new QHBoxLayout(); vBoxLayout->addLayout(hBox); - QLabel *label = new QLabel( "" + _model->displayName() + "", this); + auto label = new QLabel("" + _model->displayName() + "", this); QSizePolicy sizePolicy = label->sizePolicy(); sizePolicy.setHorizontalStretch(1); label->setSizePolicy(sizePolicy); hBox->addWidget(label); - QPushButton * controlsButton = new QPushButton( tr( "Controls" ), this ); - connect( controlsButton, SIGNAL( clicked() ), SLOT( editControls() ) ); + auto controlsButton = new QPushButton(tr("Controls"), this); + connect( controlsButton, SIGNAL(clicked()), SLOT(editControls())); hBox->addWidget(controlsButton); @@ -83,8 +86,8 @@ ControllerView::ControllerView( Controller * _model, QWidget * _parent ) : m_subWindow->setWindowIcon( m_controllerDlg->windowIcon() ); - connect( m_controllerDlg, SIGNAL( closed() ), - this, SLOT( closeControls() ) ); + connect( m_controllerDlg, SIGNAL(closed()), + this, SLOT(closeControls())); m_subWindow->hide(); @@ -138,7 +141,7 @@ void ControllerView::deleteController() void ControllerView::renameController() { bool ok; - Controller * c = castModel(); + auto c = castModel(); QString new_name = QInputDialog::getText( this, tr( "Rename controller" ), tr( "Enter the new name for this controller" ), @@ -173,9 +176,12 @@ void ControllerView::contextMenuEvent( QContextMenuEvent * ) QPointer contextMenu = new CaptionMenu( model()->displayName(), this ); contextMenu->addAction( embed::getIconPixmap( "cancel" ), tr( "&Remove this controller" ), - this, SLOT( deleteController() ) ); - contextMenu->addAction( tr("Re&name this controller"), this, SLOT( renameController() )); + this, SLOT(deleteController())); + contextMenu->addAction( tr("Re&name this controller"), this, SLOT(renameController())); contextMenu->addSeparator(); contextMenu->exec( QCursor::pos() ); delete contextMenu; } + + +} // namespace lmms::gui \ No newline at end of file diff --git a/src/gui/Controls.cpp b/src/gui/Controls.cpp index 246b08734..8c007ee99 100644 --- a/src/gui/Controls.cpp +++ b/src/gui/Controls.cpp @@ -34,11 +34,8 @@ #include "Knob.h" - - -Control::~Control() {} - - +namespace lmms::gui +{ void KnobControl::setText(const QString &text) { m_knob->setLabel(text); } @@ -57,10 +54,6 @@ AutomatableModelView* KnobControl::modelView() { return m_knob; } KnobControl::KnobControl(QWidget *parent) : m_knob(new Knob(parent)) {} -KnobControl::~KnobControl() {} - - - void ComboControl::setText(const QString &text) { m_label->setText(text); } @@ -79,15 +72,12 @@ ComboControl::ComboControl(QWidget *parent) : m_label(new QLabel(m_widget)) { m_combo->setFixedSize(64, ComboBox::DEFAULT_HEIGHT); - QVBoxLayout* vbox = new QVBoxLayout(m_widget); + auto vbox = new QVBoxLayout(m_widget); vbox->addWidget(m_combo); vbox->addWidget(m_label); m_combo->repaint(); } -ComboControl::~ComboControl() {} - - void CheckControl::setText(const QString &text) { m_label->setText(text); } @@ -108,13 +98,11 @@ CheckControl::CheckControl(QWidget *parent) : m_checkBox(new LedCheckBox(nullptr, QString(), LedCheckBox::Green)), m_label(new QLabel(m_widget)) { - QVBoxLayout* vbox = new QVBoxLayout(m_widget); + auto vbox = new QVBoxLayout(m_widget); vbox->addWidget(m_checkBox); vbox->addWidget(m_label); } -CheckControl::~CheckControl() {} - @@ -136,5 +124,5 @@ LcdControl::LcdControl(int numDigits, QWidget *parent) : { } -LcdControl::~LcdControl() {} +} // namespace lmms::gui diff --git a/src/gui/EffectControlDialog.cpp b/src/gui/EffectControlDialog.cpp index d7d5b4054..1e0fbb802 100644 --- a/src/gui/EffectControlDialog.cpp +++ b/src/gui/EffectControlDialog.cpp @@ -28,6 +28,9 @@ #include "EffectControlDialog.h" #include "EffectControls.h" +namespace lmms::gui +{ + EffectControlDialog::EffectControlDialog( EffectControls * _controls ) : QWidget( nullptr ), @@ -41,13 +44,6 @@ EffectControlDialog::EffectControlDialog( EffectControls * _controls ) : -EffectControlDialog::~EffectControlDialog() -{ -} - - - - void EffectControlDialog::closeEvent( QCloseEvent * _ce ) { _ce->ignore(); @@ -55,6 +51,4 @@ void EffectControlDialog::closeEvent( QCloseEvent * _ce ) } - - - +} // namespace lmms::gui diff --git a/src/gui/EffectRackView.cpp b/src/gui/EffectRackView.cpp index f6bac18e2..75cac67dc 100644 --- a/src/gui/EffectRackView.cpp +++ b/src/gui/EffectRackView.cpp @@ -34,17 +34,20 @@ #include "GroupBox.h" +namespace lmms::gui +{ + EffectRackView::EffectRackView( EffectChain* model, QWidget* parent ) : QWidget( parent ), ModelView( nullptr, this ) { - QVBoxLayout* mainLayout = new QVBoxLayout( this ); + auto mainLayout = new QVBoxLayout(this); mainLayout->setMargin( 5 ); m_effectsGroupBox = new GroupBox( tr( "EFFECTS CHAIN" ) ); mainLayout->addWidget( m_effectsGroupBox ); - QVBoxLayout* effectsLayout = new QVBoxLayout( m_effectsGroupBox ); + auto effectsLayout = new QVBoxLayout(m_effectsGroupBox); effectsLayout->setSpacing( 0 ); effectsLayout->setContentsMargins( 2, m_effectsGroupBox->titleBarHeight() + 2, 2, 2 ); @@ -57,12 +60,12 @@ EffectRackView::EffectRackView( EffectChain* model, QWidget* parent ) : effectsLayout->addWidget( m_scrollArea ); - QPushButton* addButton = new QPushButton; + auto addButton = new QPushButton; addButton->setText( tr( "Add effect" ) ); effectsLayout->addWidget( addButton ); - connect( addButton, SIGNAL( clicked() ), this, SLOT( addEffect() ) ); + connect( addButton, SIGNAL(clicked()), this, SLOT(addEffect())); m_lastY = 0; @@ -152,28 +155,27 @@ void EffectRackView::update() QVector view_map( qMax( fxChain()->m_effects.size(), m_effectViews.size() ), false ); - for( QVector::Iterator it = fxChain()->m_effects.begin(); - it != fxChain()->m_effects.end(); ++it ) + for (const auto& effect : fxChain()->m_effects) { int i = 0; - for( QVector::Iterator vit = m_effectViews.begin(); - vit != m_effectViews.end(); ++vit, ++i ) + for (const auto& effectView : m_effectViews) { - if( ( *vit )->model() == *it ) + if (effectView->model() == effect) { view_map[i] = true; break; } + ++i; } if( i >= m_effectViews.size() ) { - EffectView * view = new EffectView( *it, w ); - connect( view, SIGNAL( moveUp( EffectView * ) ), - this, SLOT( moveUp( EffectView * ) ) ); - connect( view, SIGNAL( moveDown( EffectView * ) ), - this, SLOT( moveDown( EffectView * ) ) ); - connect( view, SIGNAL( deletePlugin( EffectView * ) ), - this, SLOT( deletePlugin( EffectView * ) ), + auto view = new EffectView(effect, w); + connect( view, SIGNAL(moveUp(lmms::gui::EffectView*)), + this, SLOT(moveUp(lmms::gui::EffectView*))); + connect( view, SIGNAL(moveDown(lmms::gui::EffectView*)), + this, SLOT(moveDown(lmms::gui::EffectView*))); + connect( view, SIGNAL(deletePlugin(lmms::gui::EffectView*)), + this, SLOT(deletePlugin(lmms::gui::EffectView*)), Qt::QueuedConnection ); view->show(); m_effectViews.append( view ); @@ -235,13 +237,11 @@ void EffectRackView::addEffect() update(); // Find the effectView, and show the controls - for( QVector::Iterator vit = m_effectViews.begin(); - vit != m_effectViews.end(); ++vit ) + for (const auto& effectView : m_effectViews) { - if( ( *vit )->effect() == fx ) + if (effectView->effect() == fx) { - ( *vit )->editControls(); - + effectView->editControls(); break; } } @@ -256,11 +256,11 @@ void EffectRackView::modelChanged() { //clearViews(); m_effectsGroupBox->setModel( &fxChain()->m_enabledModel ); - connect( fxChain(), SIGNAL( aboutToClear() ), this, SLOT( clearViews() ) ); + connect( fxChain(), SIGNAL(aboutToClear()), this, SLOT(clearViews())); update(); } - +} // namespace lmms::gui diff --git a/src/gui/EffectView.cpp b/src/gui/EffectView.cpp index 11d95cb2e..fed1ce4e9 100644 --- a/src/gui/EffectView.cpp +++ b/src/gui/EffectView.cpp @@ -40,6 +40,9 @@ #include "TempoSyncKnob.h" +namespace lmms::gui +{ + EffectView::EffectView( Effect * _model, QWidget * _parent ) : PluginView( _model, _parent ), m_bg( embed::getIconPixmap( "effect_plugin" ) ), @@ -82,13 +85,12 @@ EffectView::EffectView( Effect * _model, QWidget * _parent ) : if( effect()->controls()->controlCount() > 0 ) { - QPushButton * ctls_btn = new QPushButton( tr( "Controls" ), - this ); + auto ctls_btn = new QPushButton(tr("Controls"), this); QFont f = ctls_btn->font(); ctls_btn->setFont( pointSize<8>( f ) ); ctls_btn->setGeometry( 150, 14, 50, 20 ); - connect( ctls_btn, SIGNAL( clicked() ), - this, SLOT( editControls() ) ); + connect( ctls_btn, SIGNAL(clicked()), + this, SLOT(editControls())); m_controlView = effect()->controls()->createView(); if( m_controlView ) @@ -108,8 +110,8 @@ EffectView::EffectView( Effect * _model, QWidget * _parent ) : flags &= ~Qt::WindowMaximizeButtonHint; m_subWindow->setWindowFlags( flags ); - connect( m_controlView, SIGNAL( closed() ), - this, SLOT( closeEffects() ) ); + connect( m_controlView, SIGNAL(closed()), + this, SLOT(closeEffects())); m_subWindow->hide(); } @@ -191,14 +193,14 @@ void EffectView::contextMenuEvent( QContextMenuEvent * ) QPointer contextMenu = new CaptionMenu( model()->displayName(), this ); contextMenu->addAction( embed::getIconPixmap( "arp_up" ), tr( "Move &up" ), - this, SLOT( moveUp() ) ); + this, SLOT(moveUp())); contextMenu->addAction( embed::getIconPixmap( "arp_down" ), tr( "Move &down" ), - this, SLOT( moveDown() ) ); + this, SLOT(moveDown())); contextMenu->addSeparator(); contextMenu->addAction( embed::getIconPixmap( "cancel" ), tr( "&Remove this plugin" ), - this, SLOT( deletePlugin() ) ); + this, SLOT(deletePlugin())); contextMenu->addSeparator(); contextMenu->exec( QCursor::pos() ); delete contextMenu; @@ -234,3 +236,5 @@ void EffectView::modelChanged() m_autoQuit->setModel( &effect()->m_autoQuitModel ); m_gate->setModel( &effect()->m_gateModel ); } + +} // namespace lmms::gui diff --git a/src/gui/FileBrowser.cpp b/src/gui/FileBrowser.cpp index a67dc52ee..4ef41217d 100644 --- a/src/gui/FileBrowser.cpp +++ b/src/gui/FileBrowser.cpp @@ -59,6 +59,10 @@ #include "StringPairDrag.h" #include "TextFloat.h" +namespace lmms::gui +{ + + enum TreeWidgetItemTypes { TypeFileItem = QTreeWidgetItem::UserType, @@ -111,24 +115,22 @@ FileBrowser::FileBrowser(const QString & directories, const QString & filter, addContentCheckBox(); } - QWidget * searchWidget = new QWidget( contentParent() ); + auto searchWidget = new QWidget(contentParent()); searchWidget->setFixedHeight( 24 ); - QHBoxLayout * searchWidgetLayout = new QHBoxLayout( searchWidget ); + auto searchWidgetLayout = new QHBoxLayout(searchWidget); searchWidgetLayout->setMargin( 0 ); searchWidgetLayout->setSpacing( 0 ); m_filterEdit = new QLineEdit( searchWidget ); m_filterEdit->setPlaceholderText( tr("Search") ); m_filterEdit->setClearButtonEnabled( true ); - connect( m_filterEdit, SIGNAL( textEdited( const QString & ) ), - this, SLOT( filterItems( const QString & ) ) ); + connect( m_filterEdit, SIGNAL( textEdited( const QString& ) ), + this, SLOT( filterItems( const QString& ) ) ); - QPushButton * reload_btn = new QPushButton( - embed::getIconPixmap( "reload" ), - QString(), searchWidget ); + auto reload_btn = new QPushButton(embed::getIconPixmap("reload"), QString(), searchWidget); reload_btn->setToolTip( tr( "Refresh list" ) ); - connect( reload_btn, SIGNAL( clicked() ), this, SLOT( reloadTree() ) ); + connect( reload_btn, SIGNAL(clicked()), this, SLOT(reloadTree())); searchWidgetLayout->addWidget( m_filterEdit ); searchWidgetLayout->addSpacing( 5 ); @@ -140,7 +142,7 @@ FileBrowser::FileBrowser(const QString & directories, const QString & filter, addContentWidget( m_fileBrowserTreeWidget ); // Whenever the FileBrowser has focus, Ctrl+F should direct focus to its filter box. - QShortcut *filterFocusShortcut = new QShortcut( QKeySequence( QKeySequence::Find ), this, SLOT(giveFocusToFilter()) ); + auto filterFocusShortcut = new QShortcut(QKeySequence(QKeySequence::Find), this, SLOT(giveFocusToFilter())); filterFocusShortcut->setContext(Qt::WidgetWithChildrenShortcut); reloadTree(); @@ -197,7 +199,7 @@ bool FileBrowser::filterItems( const QString & filter, QTreeWidgetItem * item ) } -void FileBrowser::reloadTree( void ) +void FileBrowser::reloadTree() { QList expandedDirs = m_fileBrowserTreeWidget->expandedDirs(); const QString text = m_filterEdit->text(); @@ -215,9 +217,9 @@ void FileBrowser::reloadTree( void ) if (!paths.isEmpty()) { - for (QStringList::iterator it = paths.begin(); it != paths.end(); ++it) + for (const auto& path : paths) { - addItems(*it); + addItems(path); } } expandItems(nullptr, expandedDirs); @@ -237,7 +239,7 @@ void FileBrowser::expandItems( QTreeWidgetItem * item, QList expandedDi { it->setExpanded( true ); } - Directory *d = dynamic_cast ( it ); + auto d = dynamic_cast(it); if (d) { d->update(); @@ -286,13 +288,11 @@ void FileBrowser::addItems(const QString & path ) bool orphan = true; for( int i = 0; i < m_fileBrowserTreeWidget->topLevelItemCount(); ++i ) { - Directory * d = dynamic_cast( - m_fileBrowserTreeWidget->topLevelItem( i ) ); + auto d = dynamic_cast(m_fileBrowserTreeWidget->topLevelItem(i)); if( d == nullptr || cur_file < d->text( 0 ) ) { // insert before item, we're done - Directory *dd = new Directory( cur_file, path, - m_filter ); + auto dd = new Directory(cur_file, path, m_filter); m_fileBrowserTreeWidget->insertTopLevelItem( i,dd ); dd->update(); // add files to the directory orphan = false; @@ -315,8 +315,7 @@ void FileBrowser::addItems(const QString & path ) { // it has not yet been added yet, so it's (lexically) // larger than all other dirs => append it at the bottom - Directory *d = new Directory( cur_file, - path, m_filter ); + auto d = new Directory(cur_file, path, m_filter); d->update(); m_fileBrowserTreeWidget->addTopLevelItem( d ); } @@ -368,19 +367,21 @@ FileBrowserTreeWidget::FileBrowserTreeWidget(QWidget * parent ) : QTreeWidget( parent ), m_mousePressed( false ), m_pressPos(), - m_previewPlayHandle( nullptr ), - m_pphMutex( QMutex::Recursive ) + m_previewPlayHandle( nullptr ) +#if (QT_VERSION < QT_VERSION_CHECK(5,14,0)) + ,m_pphMutex(QMutex::Recursive) +#endif { setColumnCount( 1 ); headerItem()->setHidden( true ); setSortingEnabled( false ); - connect( this, SIGNAL( itemDoubleClicked( QTreeWidgetItem *, int ) ), - SLOT( activateListItem( QTreeWidgetItem *, int ) ) ); - connect( this, SIGNAL( itemCollapsed( QTreeWidgetItem * ) ), - SLOT( updateDirectory( QTreeWidgetItem * ) ) ); - connect( this, SIGNAL( itemExpanded( QTreeWidgetItem * ) ), - SLOT( updateDirectory( QTreeWidgetItem * ) ) ); + connect( this, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), + SLOT(activateListItem(QTreeWidgetItem*,int))); + connect( this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), + SLOT(updateDirectory(QTreeWidgetItem*))); + connect( this, SIGNAL(itemExpanded(QTreeWidgetItem*)), + SLOT(updateDirectory(QTreeWidgetItem*))); #if QT_VERSION < QT_VERSION_CHECK(5, 12, 2) && defined LMMS_BUILD_WIN32 // Set the font for the QTreeWidget to the Windows System font to make sure that @@ -405,7 +406,7 @@ QList FileBrowserTreeWidget::expandedDirs( QTreeWidgetItem * item ) con // Add expanded top level directories. if (it->isExpanded() && (it->type() == TypeDirectoryItem)) { - Directory *d = static_cast ( it ); + auto d = static_cast(it); dirs.append( d->fullName() ); } @@ -438,7 +439,7 @@ void FileBrowserTreeWidget::keyPressEvent(QKeyEvent * ke ) else if (vertical || horizontal || preview || insert) { stopPreview(); } // Try to get the currently selected item as a FileItem - FileItem * file = dynamic_cast(currentItem()); + auto file = dynamic_cast(currentItem()); // If it's null (folder, separator, etc.), there's nothing left for us to do if (file == nullptr) { return; } @@ -499,7 +500,7 @@ void FileBrowserTreeWidget::focusOutEvent(QFocusEvent* fe) void FileBrowserTreeWidget::contextMenuEvent(QContextMenuEvent * e ) { - FileItem * file = dynamic_cast( itemAt( e->pos() ) ); + auto file = dynamic_cast(itemAt(e->pos())); if( file != nullptr && file->isTrack() ) { QMenu contextMenu( this ); @@ -517,12 +518,12 @@ void FileBrowserTreeWidget::contextMenuEvent(QContextMenuEvent * e ) [=]{ openContainingFolder(file); } ); - QAction* songEditorHeader = new QAction( tr("Song Editor"), nullptr ); + auto songEditorHeader = new QAction(tr("Song Editor"), nullptr); songEditorHeader->setDisabled(true); contextMenu.addAction( songEditorHeader ); contextMenu.addActions( getContextActions(file, true) ); - QAction* patternEditorHeader = new QAction(tr("Pattern Editor"), nullptr); + auto patternEditorHeader = new QAction(tr("Pattern Editor"), nullptr); patternEditorHeader->setDisabled(true); contextMenu.addAction(patternEditorHeader); contextMenu.addActions( getContextActions(file, false) ); @@ -545,20 +546,14 @@ QList FileBrowserTreeWidget::getContextActions(FileItem* file, bool so tr("Send to new instrument track"); QString shortcutMod = songEditor ? "" : UI_CTRL_KEY + QString(" + "); - QAction* toInstrument = new QAction( - instrumentAction + tr(" (%2Enter)").arg(shortcutMod), - nullptr - ); + auto toInstrument = new QAction(instrumentAction + tr(" (%2Enter)").arg(shortcutMod), nullptr); connect(toInstrument, &QAction::triggered, [=]{ openInNewInstrumentTrack(file, songEditor); }); result.append(toInstrument); if (songEditor && fileIsSample) { - QAction* toSampleTrack = new QAction( - tr("Send to new sample track (Shift + Enter)"), - nullptr - ); + auto toSampleTrack = new QAction(tr("Send to new sample track (Shift + Enter)"), nullptr); connect(toSampleTrack, &QAction::triggered, [=]{ openInNewSampleTrack(file); }); result.append(toSampleTrack); @@ -592,7 +587,7 @@ void FileBrowserTreeWidget::mousePressEvent(QMouseEvent * me ) // } } - FileItem * f = dynamic_cast(i); + auto f = dynamic_cast(i); if(f != nullptr) { previewFileItem(f); } } @@ -620,7 +615,7 @@ void FileBrowserTreeWidget::previewFileItem(FileItem* file) embed::getIconPixmap("sample_file", 24, 24), 0); // TODO: this can be removed once we do this outside the event thread qApp->processEvents(QEventLoop::ExcludeUserInputEvents); - SamplePlayHandle* s = new SamplePlayHandle(fileName); + auto s = new SamplePlayHandle(fileName); s->setDoneMayReturnTrue(false); newPPH = s; delete tf; @@ -685,7 +680,7 @@ void FileBrowserTreeWidget::mouseMoveEvent( QMouseEvent * me ) // make sure any playback is stopped mouseReleaseEvent( nullptr ); - FileItem * f = dynamic_cast( itemAt( m_pressPos ) ); + auto f = dynamic_cast(itemAt(m_pressPos)); if( f != nullptr ) { switch( f->type() ) @@ -802,7 +797,7 @@ void FileBrowserTreeWidget::handleFile(FileItem * f, InstrumentTrack * it) void FileBrowserTreeWidget::activateListItem(QTreeWidgetItem * item, int column ) { - FileItem * f = dynamic_cast( item ); + auto f = dynamic_cast(item); if( f == nullptr ) { return; @@ -815,9 +810,7 @@ void FileBrowserTreeWidget::activateListItem(QTreeWidgetItem * item, } else if( f->handling() != FileItem::NotSupported ) { - InstrumentTrack * it = dynamic_cast( - Track::create(Track::InstrumentTrack, Engine::patternStore()) - ); + auto it = dynamic_cast(Track::create(Track::InstrumentTrack, Engine::patternStore())); handleFile( f, it ); } } @@ -829,8 +822,7 @@ void FileBrowserTreeWidget::openInNewInstrumentTrack(TrackContainer* tc, FileIte { if(item->isTrack()) { - InstrumentTrack * it = dynamic_cast( - Track::create(Track::InstrumentTrack, tc)); + auto it = dynamic_cast(Track::create(Track::InstrumentTrack, tc)); handleFile(item, it); } } @@ -855,8 +847,7 @@ bool FileBrowserTreeWidget::openInNewSampleTrack(FileItem* item) if (item->type() != FileItem::SampleFile) { return false; } // Create a new sample track for this sample - SampleTrack* sampleTrack = static_cast( - Track::create(Track::SampleTrack, Engine::getSong())); + auto sampleTrack = static_cast(Track::create(Track::SampleTrack, Engine::getSong())); // Add the sample clip to the track Engine::audioEngine()->requestChangeInModel(); @@ -896,9 +887,7 @@ void FileBrowserTreeWidget::sendToActiveInstrumentTrack( FileItem* item ) // instrument-track while( w.hasPrevious() ) { - InstrumentTrackWindow * itw = - dynamic_cast( - w.previous()->widget() ); + auto itw = dynamic_cast(w.previous()->widget()); if( itw != nullptr && itw->isHidden() == false ) { handleFile( item, itw->model() ); @@ -912,7 +901,7 @@ void FileBrowserTreeWidget::sendToActiveInstrumentTrack( FileItem* item ) void FileBrowserTreeWidget::updateDirectory(QTreeWidgetItem * item ) { - Directory * dir = dynamic_cast( item ); + auto dir = dynamic_cast(item); if( dir != nullptr ) { dir->update(); @@ -953,7 +942,7 @@ Directory::Directory(const QString & filename, const QString & path, -void Directory::initPixmaps( void ) +void Directory::initPixmaps() { if( s_folderPixmap == nullptr ) { @@ -977,7 +966,7 @@ void Directory::initPixmaps( void ) -void Directory::update( void ) +void Directory::update() { if( !isExpanded() ) { @@ -990,20 +979,17 @@ void Directory::update( void ) { m_dirCount = 0; // for all paths leading here, add their items - for( QStringList::iterator it = m_directories.begin(); - it != m_directories.end(); ++it ) + for (const auto& directory : m_directories) { int filesBeforeAdd = childCount() - m_dirCount; - if( addItems( fullName( *it ) ) && - ( *it ).contains( - ConfigManager::inst()->dataDir() ) ) + if(addItems(fullName(directory)) && directory.contains(ConfigManager::inst()->dataDir())) { // factory file directory is added // note: those are always added last int filesNow = childCount() - m_dirCount; if(filesNow > filesBeforeAdd) // any file appended? { - QTreeWidgetItem * sep = new QTreeWidgetItem; + auto sep = new QTreeWidgetItem; sep->setText( 0, FileBrowserTreeWidget::tr( "--- Factory files ---" ) ); @@ -1043,8 +1029,7 @@ bool Directory::addItems(const QString & path ) bool orphan = true; for( int i = 0; i < childCount(); ++i ) { - Directory * d = dynamic_cast( - child( i ) ); + auto d = dynamic_cast(child(i)); if( d == nullptr || cur_file < d->text( 0 ) ) { // insert before item, we're done @@ -1140,7 +1125,7 @@ FileItem::FileItem(const QString & name, const QString & path ) : -void FileItem::initPixmaps( void ) +void FileItem::initPixmaps() { if( s_projectFilePixmap == nullptr ) { @@ -1215,7 +1200,7 @@ void FileItem::initPixmaps( void ) -void FileItem::determineFileType( void ) +void FileItem::determineFileType() { m_handling = NotSupported; @@ -1283,7 +1268,7 @@ void FileItem::determineFileType( void ) -QString FileItem::extension( void ) +QString FileItem::extension() { return extension( fullName() ); } @@ -1295,3 +1280,6 @@ QString FileItem::extension(const QString & file ) { return QFileInfo( file ).suffix().toLower(); } + + +} // namespace lmms::gui \ No newline at end of file diff --git a/src/gui/GuiApplication.cpp b/src/gui/GuiApplication.cpp index 0829bfd80..3370cbc6e 100644 --- a/src/gui/GuiApplication.cpp +++ b/src/gui/GuiApplication.cpp @@ -51,6 +51,19 @@ #include #endif +namespace lmms +{ + + +namespace gui +{ + +GuiApplication* getGUI() +{ + return GuiApplication::instance(); +} + + GuiApplication* GuiApplication::s_instance = nullptr; GuiApplication* GuiApplication::instance() @@ -58,10 +71,7 @@ GuiApplication* GuiApplication::instance() return s_instance; } -GuiApplication* getGUI() -{ - return GuiApplication::instance(); -} + GuiApplication::GuiApplication() { @@ -81,11 +91,11 @@ GuiApplication::GuiApplication() QDir::addSearchPath("artwork", ConfigManager::inst()->defaultThemeDir()); QDir::addSearchPath("artwork", ":/artwork"); - LmmsStyle* lmmsstyle = new LmmsStyle(); + auto lmmsstyle = new LmmsStyle(); QApplication::setStyle(lmmsstyle); - LmmsPalette* lmmspal = new LmmsPalette(nullptr, lmmsstyle); - QPalette* lpal = new QPalette(lmmspal->palette()); + auto lmmspal = new LmmsPalette(nullptr, lmmsstyle); + auto lpal = new QPalette(lmmspal->palette()); QApplication::setPalette( *lpal ); LmmsStyle::s_palette = lpal; @@ -249,3 +259,8 @@ QFont GuiApplication::getWin32SystemFont() return QFont( QString::fromUtf8( metrics.lfMessageFont.lfFaceName ), pointSize ); } #endif + + +} // namespace gui + +} // namespace lmms diff --git a/src/gui/LadspaControlView.cpp b/src/gui/LadspaControlView.cpp index 9b539ff21..38ad4a146 100644 --- a/src/gui/LadspaControlView.cpp +++ b/src/gui/LadspaControlView.cpp @@ -33,13 +33,16 @@ #include "TempoSyncKnob.h" +namespace lmms::gui +{ + LadspaControlView::LadspaControlView( QWidget * _parent, LadspaControl * _ctl ) : QWidget( _parent ), ModelView( _ctl, this ), m_ctl( _ctl ) { - QHBoxLayout * layout = new QHBoxLayout( this ); + auto layout = new QHBoxLayout(this); layout->setMargin( 0 ); layout->setSpacing( 0 ); @@ -59,8 +62,7 @@ LadspaControlView::LadspaControlView( QWidget * _parent, { case TOGGLED: { - LedCheckBox * toggle = new LedCheckBox( - m_ctl->port()->name, this, QString(), LedCheckBox::Green ); + auto toggle = new LedCheckBox(m_ctl->port()->name, this, QString(), LedCheckBox::Green); toggle->setModel( m_ctl->toggledModel() ); layout->addWidget( toggle ); if( link != nullptr ) @@ -118,11 +120,4 @@ LadspaControlView::LadspaControlView( QWidget * _parent, -LadspaControlView::~LadspaControlView() -{ -} - - - - - +} // namespace lmms::gui diff --git a/src/gui/LfoControllerDialog.cpp b/src/gui/LfoControllerDialog.cpp index 672e22ed5..64602cd74 100644 --- a/src/gui/LfoControllerDialog.cpp +++ b/src/gui/LfoControllerDialog.cpp @@ -32,6 +32,10 @@ #include "TempoSyncKnob.h" #include "PixmapButton.h" +namespace lmms::gui +{ + + const int CD_ENV_KNOBS_LBL_Y = 11; const int CD_KNOB_X_SPACING = 32; @@ -77,7 +81,7 @@ LfoControllerDialog::LfoControllerDialog( Controller * _model, QWidget * _parent m_phaseKnob->move( CD_LFO_PHASE_CD_KNOB_X, CD_LFO_CD_KNOB_Y ); m_phaseKnob->setHintText( tr( "Phase offset:" ) , "" + tr( " degrees" ) ); - PixmapButton * sin_wave_btn = new PixmapButton( this, nullptr ); + auto sin_wave_btn = new PixmapButton(this, nullptr); sin_wave_btn->move( CD_LFO_SHAPES_X, CD_LFO_SHAPES_Y ); sin_wave_btn->setActiveGraphic( embed::getIconPixmap( "sin_wave_active" ) ); @@ -86,8 +90,7 @@ LfoControllerDialog::LfoControllerDialog( Controller * _model, QWidget * _parent sin_wave_btn->setToolTip( tr( "Sine wave" ) ); - PixmapButton * triangle_wave_btn = - new PixmapButton( this, nullptr ); + auto triangle_wave_btn = new PixmapButton(this, nullptr); triangle_wave_btn->move( CD_LFO_SHAPES_X + 15, CD_LFO_SHAPES_Y ); triangle_wave_btn->setActiveGraphic( embed::getIconPixmap( "triangle_wave_active" ) ); @@ -96,7 +99,7 @@ LfoControllerDialog::LfoControllerDialog( Controller * _model, QWidget * _parent triangle_wave_btn->setToolTip( tr( "Triangle wave" ) ); - PixmapButton * saw_wave_btn = new PixmapButton( this, nullptr ); + auto saw_wave_btn = new PixmapButton(this, nullptr); saw_wave_btn->move( CD_LFO_SHAPES_X + 30, CD_LFO_SHAPES_Y ); saw_wave_btn->setActiveGraphic( embed::getIconPixmap( "saw_wave_active" ) ); @@ -105,7 +108,7 @@ LfoControllerDialog::LfoControllerDialog( Controller * _model, QWidget * _parent saw_wave_btn->setToolTip( tr( "Saw wave" ) ); - PixmapButton * sqr_wave_btn = new PixmapButton( this, nullptr ); + auto sqr_wave_btn = new PixmapButton(this, nullptr); sqr_wave_btn->move( CD_LFO_SHAPES_X + 45, CD_LFO_SHAPES_Y ); sqr_wave_btn->setActiveGraphic( embed::getIconPixmap( "square_wave_active" ) ); @@ -114,8 +117,7 @@ LfoControllerDialog::LfoControllerDialog( Controller * _model, QWidget * _parent sqr_wave_btn->setToolTip( tr( "Square wave" ) ); - PixmapButton * moog_saw_wave_btn = - new PixmapButton( this, nullptr ); + auto moog_saw_wave_btn = new PixmapButton(this, nullptr); moog_saw_wave_btn->move( CD_LFO_SHAPES_X, CD_LFO_SHAPES_Y + 15 ); moog_saw_wave_btn->setActiveGraphic( embed::getIconPixmap( "moog_saw_wave_active" ) ); @@ -124,7 +126,7 @@ LfoControllerDialog::LfoControllerDialog( Controller * _model, QWidget * _parent moog_saw_wave_btn->setToolTip( tr( "Moog saw wave" ) ); - PixmapButton * exp_wave_btn = new PixmapButton( this, nullptr ); + auto exp_wave_btn = new PixmapButton(this, nullptr); exp_wave_btn->move( CD_LFO_SHAPES_X + 15, CD_LFO_SHAPES_Y + 15 ); exp_wave_btn->setActiveGraphic( embed::getIconPixmap( "exp_wave_active" ) ); @@ -133,7 +135,7 @@ LfoControllerDialog::LfoControllerDialog( Controller * _model, QWidget * _parent exp_wave_btn->setToolTip( tr( "Exponential wave" ) ); - PixmapButton * white_noise_btn = new PixmapButton( this, nullptr ); + auto white_noise_btn = new PixmapButton(this, nullptr); white_noise_btn->move( CD_LFO_SHAPES_X + 30, CD_LFO_SHAPES_Y + 15 ); white_noise_btn->setActiveGraphic( embed::getIconPixmap( "white_noise_wave_active" ) ); @@ -149,8 +151,8 @@ LfoControllerDialog::LfoControllerDialog( Controller * _model, QWidget * _parent m_userWaveBtn->setInactiveGraphic( embed::getIconPixmap( "usr_wave_inactive" ) ); connect( m_userWaveBtn, - SIGNAL( doubleClicked() ), - this, SLOT( askUserDefWave() ) ); + SIGNAL(doubleClicked()), + this, SLOT(askUserDefWave())); m_userWaveBtn->setToolTip( tr( "User-defined shape.\nDouble click to pick a file." ) ); @@ -164,33 +166,23 @@ LfoControllerDialog::LfoControllerDialog( Controller * _model, QWidget * _parent m_waveBtnGrp->addButton( white_noise_btn ); m_waveBtnGrp->addButton( m_userWaveBtn ); + auto x1 = new PixmapButton(this, nullptr); + x1->move(CD_LFO_MULTIPLIER_X, CD_LFO_SHAPES_Y + 7); + x1->setActiveGraphic(embed::getIconPixmap("lfo_x1_active")); + x1->setInactiveGraphic(embed::getIconPixmap("lfo_x1_inactive")); + x1->setToolTip(tr("Multiply modulation frequency by 1")); - PixmapButton * x1 = new PixmapButton( this, nullptr ); - x1->move( CD_LFO_MULTIPLIER_X, CD_LFO_SHAPES_Y +7); - x1->setActiveGraphic( embed::getIconPixmap( - "lfo_x1_active" ) ); - x1->setInactiveGraphic( embed::getIconPixmap( - "lfo_x1_inactive" ) ); - x1->setToolTip( - tr( "Mutliply modulation frequency by 1" )); + auto x100 = new PixmapButton(this, nullptr); + x100->move(CD_LFO_MULTIPLIER_X, CD_LFO_SHAPES_Y - 8); + x100->setActiveGraphic(embed::getIconPixmap("lfo_x100_active")); + x100->setInactiveGraphic(embed::getIconPixmap("lfo_x100_inactive")); + x100->setToolTip(tr("Multiply modulation frequency by 100")); - PixmapButton * x100 = new PixmapButton( this, nullptr ); - x100->move( CD_LFO_MULTIPLIER_X, CD_LFO_SHAPES_Y - 8 ); - x100->setActiveGraphic( embed::getIconPixmap( - "lfo_x100_active" ) ); - x100->setInactiveGraphic( embed::getIconPixmap( - "lfo_x100_inactive" ) ); - x100->setToolTip( - tr( "Mutliply modulation frequency by 100" )); - - PixmapButton * d100 = new PixmapButton( this, nullptr ); - d100->move( CD_LFO_MULTIPLIER_X, CD_LFO_SHAPES_Y + 22 ); - d100->setActiveGraphic( embed::getIconPixmap( - "lfo_d100_active" ) ); - d100->setInactiveGraphic( embed::getIconPixmap( - "lfo_d100_inactive" ) ); - d100->setToolTip( - tr( "Divide modulation frequency by 100" )); + auto d100 = new PixmapButton(this, nullptr); + d100->move(CD_LFO_MULTIPLIER_X, CD_LFO_SHAPES_Y + 22); + d100->setActiveGraphic(embed::getIconPixmap("lfo_d100_active")); + d100->setInactiveGraphic(embed::getIconPixmap("lfo_d100_inactive")); + d100->setToolTip(tr("Divide modulation frequency by 100")); m_multiplierBtnGrp = new automatableButtonGroup( this ); m_multiplierBtnGrp->addButton( x1 ); @@ -240,14 +232,14 @@ void LfoControllerDialog::contextMenuEvent( QContextMenuEvent * ) // should be replaced by Model::displayName contextMenu->addAction( embed::getIconPixmap( "arp_up_on" ), tr( "Move &up" ), - this, SLOT( moveUp() ) ); + this, SLOT(moveUp())); contextMenu->addAction( embed::getIconPixmap( "arp_down_on" ), tr( "Move &down" ), - this, SLOT( moveDown() ) ); + this, SLOT(moveDown())); contextMenu->addSeparator(); contextMenu->addAction( embed::getIconPixmap( "cancel" ), tr( "&Remove this plugin" ), - this, SLOT( deletePlugin() ) ); + this, SLOT(deletePlugin())); contextMenu->exec( QCursor::pos() ); delete contextMenu; */ @@ -268,3 +260,4 @@ void LfoControllerDialog::modelChanged() } +} // namespace lmms::gui diff --git a/src/gui/LinkedModelGroupViews.cpp b/src/gui/LinkedModelGroupViews.cpp index 8cac826eb..f77edcdb9 100644 --- a/src/gui/LinkedModelGroupViews.cpp +++ b/src/gui/LinkedModelGroupViews.cpp @@ -29,6 +29,9 @@ #include "ControlLayout.h" #include "LinkedModelGroups.h" +namespace lmms::gui +{ + /* LinkedModelGroupViewBase @@ -52,11 +55,6 @@ LinkedModelGroupView::LinkedModelGroupView(QWidget* parent, -LinkedModelGroupView::~LinkedModelGroupView() {} - - - - void LinkedModelGroupView::modelChanged(LinkedModelGroup *group) { // reconnect models @@ -88,13 +86,13 @@ void LinkedModelGroupView::addControl(Control* ctrl, const std::string& id, { if (ctrl) { - QWidget* box = new QWidget(this); - QHBoxLayout* boxLayout = new QHBoxLayout(box); + auto box = new QWidget(this); + auto boxLayout = new QHBoxLayout(box); boxLayout->addWidget(ctrl->topWidget()); if (removable) { - QPushButton* removeBtn = new QPushButton; + auto removeBtn = new QPushButton; removeBtn->setIcon( embed::getIconPixmap( "discard" ) ); QObject::connect(removeBtn, &QPushButton::clicked, this, [this,ctrl](bool){ @@ -169,3 +167,4 @@ void LinkedModelGroupsView::modelChanged(LinkedModelGroups *groups) } +} // namespace lmms::gui diff --git a/src/gui/LmmsPalette.cpp b/src/gui/LmmsPalette.cpp index e0b356d7a..48d6de0df 100644 --- a/src/gui/LmmsPalette.cpp +++ b/src/gui/LmmsPalette.cpp @@ -28,6 +28,9 @@ #include "LmmsPalette.h" +namespace lmms::gui +{ + LmmsPalette::LmmsPalette( QWidget * parent, QStyle * stylearg ) : QWidget( parent ), @@ -49,10 +52,6 @@ LmmsPalette::LmmsPalette( QWidget * parent, QStyle * stylearg ) : ensurePolished(); } -LmmsPalette::~LmmsPalette() -{ -} - #define ACCESSMET( read, write ) \ QColor LmmsPalette:: read () const \ { return m_##read ; } \ @@ -90,4 +89,4 @@ QPalette LmmsPalette::palette() const } - +} // namespace lmms::gui diff --git a/src/gui/LmmsStyle.cpp b/src/gui/LmmsStyle.cpp index 2882b9572..060a97811 100644 --- a/src/gui/LmmsStyle.cpp +++ b/src/gui/LmmsStyle.cpp @@ -23,6 +23,7 @@ * */ +#include #include #include @@ -33,6 +34,11 @@ #include "LmmsStyle.h" + +namespace lmms::gui +{ + + QPalette * LmmsStyle::s_palette = nullptr; QLinearGradient getGradient( const QColor & _col, const QRectF & _rect ) @@ -66,9 +72,10 @@ QLinearGradient getGradient( const QColor & _col, const QRectF & _rect ) QLinearGradient darken( const QLinearGradient & _gradient ) { QGradientStops stops = _gradient.stops(); - for (int i = 0; i < stops.size(); ++i) { - QColor color = stops.at(i).second; - stops[i].second = color.lighter(133); + for (auto& stop : stops) + { + QColor color = stop.second; + stop.second = color.lighter(133); } QLinearGradient g = _gradient; @@ -138,7 +145,7 @@ LmmsStyle::LmmsStyle() : -QPalette LmmsStyle::standardPalette( void ) const +QPalette LmmsStyle::standardPalette() const { if( s_palette != nullptr) { return * s_palette; } @@ -156,8 +163,7 @@ void LmmsStyle::drawComplexControl( ComplexControl control, // fix broken titlebar styling on win32 if( control == CC_TitleBar ) { - const QStyleOptionTitleBar * titleBar = - qstyleoption_cast(option ); + const auto titleBar = qstyleoption_cast(option); if( titleBar ) { QStyleOptionTitleBar so( *titleBar ); @@ -211,8 +217,8 @@ void LmmsStyle::drawPrimitive( PrimitiveElement element, int a50 = static_cast( a100 * .6 ); int a25 = static_cast( a100 * .33 ); - QLine lines[4]; - QPoint points[4]; + auto lines = std::array{}; + auto points = std::array{}; // black inside lines // 50% @@ -226,7 +232,7 @@ void LmmsStyle::drawPrimitive( PrimitiveElement element, rect.left() + 1, rect.bottom() - 2); lines[3] = QLine(rect.right() - 1, rect.top() + 2, rect.right() - 1, rect.bottom() - 2); - painter->drawLines(lines, 4); + painter->drawLines(lines.data(), 4); // black inside dots black.setAlpha(a50); @@ -235,7 +241,7 @@ void LmmsStyle::drawPrimitive( PrimitiveElement element, points[1] = QPoint(rect.left() + 2, rect.bottom() - 2); points[2] = QPoint(rect.right() - 2, rect.top() + 2); points[3] = QPoint(rect.right() - 2, rect.bottom() - 2); - painter->drawPoints(points, 4); + painter->drawPoints(points.data(), 4); // outside lines - shadow @@ -246,7 +252,7 @@ void LmmsStyle::drawPrimitive( PrimitiveElement element, rect.right() - 2, rect.top()); lines[1] = QLine(rect.left(), rect.top() + 2, rect.left(), rect.bottom() - 2); - painter->drawLines(lines, 2); + painter->drawLines(lines.data(), 2); // outside corner dots - shadow // 75% @@ -254,7 +260,7 @@ void LmmsStyle::drawPrimitive( PrimitiveElement element, painter->setPen(QPen(shadow, 0)); points[0] = QPoint(rect.left() + 1, rect.top() + 1); points[1] = QPoint(rect.right() - 1, rect.top() + 1); - painter->drawPoints(points, 2); + painter->drawPoints(points.data(), 2); // outside end dots - shadow // 50% @@ -264,7 +270,7 @@ void LmmsStyle::drawPrimitive( PrimitiveElement element, points[1] = QPoint(rect.left(), rect.top() + 1); points[2] = QPoint(rect.right() - 1, rect.top()); points[3] = QPoint(rect.left(), rect.bottom() - 1); - painter->drawPoints(points, 4); + painter->drawPoints(points.data(), 4); // outside lines - highlight @@ -275,7 +281,7 @@ void LmmsStyle::drawPrimitive( PrimitiveElement element, rect.right() - 2, rect.bottom()); lines[1] = QLine(rect.right(), rect.top() + 2, rect.right(), rect.bottom() - 2); - painter->drawLines(lines, 2); + painter->drawLines(lines.data(), 2); // outside corner dots - highlight // 75% @@ -283,7 +289,7 @@ void LmmsStyle::drawPrimitive( PrimitiveElement element, painter->setPen(QPen(highlight, 0)); points[0] = QPoint(rect.left() + 1, rect.bottom() - 1); points[1] = QPoint(rect.right() - 1, rect.bottom() - 1); - painter->drawPoints(points, 2); + painter->drawPoints(points.data(), 2); // outside end dots - highlight // 50% @@ -293,7 +299,7 @@ void LmmsStyle::drawPrimitive( PrimitiveElement element, points[1] = QPoint(rect.right(), rect.bottom() - 1); points[2] = QPoint(rect.left() + 1, rect.bottom()); points[3] = QPoint(rect.right(), rect.top() + 1); - painter->drawPoints(points, 4); + painter->drawPoints(points.data(), 4); } else { @@ -368,3 +374,6 @@ void LmmsStyle::hoverColors( bool sunken, bool hover, bool active, QColor& color blend = QColor( 33, 33, 33 ); } } + + +} // namespace lmms::gui diff --git a/src/gui/Lv2ViewBase.cpp b/src/gui/Lv2ViewBase.cpp index 1ae12beed..4347c37cd 100644 --- a/src/gui/Lv2ViewBase.cpp +++ b/src/gui/Lv2ViewBase.cpp @@ -47,6 +47,8 @@ #include "SubWindow.h" +namespace lmms::gui +{ Lv2ViewProc::Lv2ViewProc(QWidget* parent, Lv2Proc* ctrlBase, int colNum) : @@ -124,11 +126,6 @@ Lv2ViewProc::Lv2ViewProc(QWidget* parent, Lv2Proc* ctrlBase, int colNum) : -Lv2ViewProc::~Lv2ViewProc() {} - - - - AutoLilvNode Lv2ViewProc::uri(const char *uriStr) { return Engine::getLv2Manager()->uri(uriStr); @@ -139,9 +136,9 @@ AutoLilvNode Lv2ViewProc::uri(const char *uriStr) Lv2ViewBase::Lv2ViewBase(QWidget* meAsWidget, Lv2ControlBase *ctrlBase) { - QGridLayout* grid = new QGridLayout(meAsWidget); + auto grid = new QGridLayout(meAsWidget); - QHBoxLayout* btnBox = new QHBoxLayout(); + auto btnBox = new QHBoxLayout(); if (/* DISABLES CODE */ (false)) { m_reloadPluginButton = new QPushButton(QObject::tr("Reload Plugin"), @@ -172,7 +169,7 @@ Lv2ViewBase::Lv2ViewBase(QWidget* meAsWidget, Lv2ControlBase *ctrlBase) LILV_FOREACH(nodes, itr, props.get()) { const LilvNode* node = lilv_nodes_get(props.get(), itr); - QLabel* infoLabel = new QLabel(lilv_node_as_string(node)); + auto infoLabel = new QLabel(lilv_node_as_string(node)); infoLabel->setWordWrap(true); infoLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding); @@ -248,4 +245,6 @@ AutoLilvNode Lv2ViewBase::uri(const char *uriStr) } +} // namespace lmms::gui + #endif // LMMS_HAVE_LV2 diff --git a/src/gui/MainApplication.cpp b/src/gui/MainApplication.cpp index 64aeb73a5..ab45ce304 100644 --- a/src/gui/MainApplication.cpp +++ b/src/gui/MainApplication.cpp @@ -31,6 +31,10 @@ #include "MainWindow.h" #include "Song.h" +namespace lmms::gui +{ + + MainApplication::MainApplication(int& argc, char** argv) : QApplication(argc, argv), m_queuedFile() @@ -46,7 +50,7 @@ bool MainApplication::event(QEvent* event) { case QEvent::FileOpen: { - QFileOpenEvent * fileEvent = static_cast(event); + auto fileEvent = static_cast(event); // Handle the project file m_queuedFile = fileEvent->file(); if(Engine::getSong()) @@ -101,4 +105,7 @@ bool MainApplication::nativeEventFilter(const QByteArray& eventType, } return false; } -#endif +#endif // LMMS_BUILD_WIN32 + + +} // namespace lmms::gui diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 2bb1ae599..706d63e27 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -75,14 +75,17 @@ #include "lmmsversion.h" +namespace lmms::gui +{ + #if !defined(LMMS_BUILD_WIN32) && !defined(LMMS_BUILD_APPLE) && !defined(LMMS_BUILD_HAIKU) //Work around an issue on KDE5 as per https://bugs.kde.org/show_bug.cgi?id=337491#c21 void disableAutoKeyAccelerators(QWidget* mainWindow) { using DisablerFunc = void(*)(QWidget*); QLibrary kf5WidgetsAddon("KF5WidgetsAddons", 5); - DisablerFunc setNoAccelerators = - reinterpret_cast(kf5WidgetsAddon.resolve("_ZN19KAcceleratorManager10setNoAccelEP7QWidget")); + auto setNoAccelerators + = reinterpret_cast(kf5WidgetsAddon.resolve("_ZN19KAcceleratorManager10setNoAccelEP7QWidget")); if(setNoAccelerators) { setNoAccelerators(mainWindow); @@ -105,19 +108,19 @@ MainWindow::MainWindow() : #endif setAttribute( Qt::WA_DeleteOnClose ); - QWidget * main_widget = new QWidget( this ); - QVBoxLayout * vbox = new QVBoxLayout( main_widget ); + auto main_widget = new QWidget(this); + auto vbox = new QVBoxLayout(main_widget); vbox->setSpacing( 0 ); vbox->setMargin( 0 ); - QWidget * w = new QWidget( main_widget ); - QHBoxLayout * hbox = new QHBoxLayout( w ); + auto w = new QWidget(main_widget); + auto hbox = new QHBoxLayout(w); hbox->setSpacing( 0 ); hbox->setMargin( 0 ); - SideBar * sideBar = new SideBar( Qt::Vertical, w ); + auto sideBar = new SideBar(Qt::Vertical, w); - QSplitter * splitter = new QSplitter( Qt::Horizontal, w ); + auto splitter = new QSplitter(Qt::Horizontal, w); splitter->setChildrenCollapsible( false ); ConfigManager* confMgr = ConfigManager::inst(); @@ -248,8 +251,8 @@ MainWindow::MainWindow() : // See autoSaveTimerReset() in MainWindow.h } - connect( Engine::getSong(), SIGNAL( playbackStateChanged() ), - this, SLOT( updatePlayPauseIcons() ) ); + connect( Engine::getSong(), SIGNAL(playbackStateChanged()), + this, SLOT(updatePlayPauseIcons())); connect(Engine::getSong(), SIGNAL(stopped()), SLOT(onSongStopped())); @@ -295,11 +298,11 @@ void MainWindow::finalize() // project-popup-menu - QMenu * project_menu = new QMenu( this ); + auto project_menu = new QMenu(this); menuBar()->addMenu( project_menu )->setText( tr( "&File" ) ); project_menu->addAction( embed::getIconPixmap( "project_new" ), tr( "&New" ), - this, SLOT( createNewProject() ), + this, SLOT(createNewProject()), QKeySequence::New ); auto templates_menu = new TemplatesMenu( this ); @@ -307,48 +310,48 @@ void MainWindow::finalize() project_menu->addAction( embed::getIconPixmap( "project_open" ), tr( "&Open..." ), - this, SLOT( openProject() ), + this, SLOT(openProject()), QKeySequence::Open ); project_menu->addMenu(new RecentProjectsMenu(this)); project_menu->addAction( embed::getIconPixmap( "project_save" ), tr( "&Save" ), - this, SLOT( saveProject() ), + this, SLOT(saveProject()), QKeySequence::Save ); project_menu->addAction( embed::getIconPixmap( "project_save" ), tr( "Save &As..." ), - this, SLOT( saveProjectAs() ), + this, SLOT(saveProjectAs()), Qt::CTRL + Qt::SHIFT + Qt::Key_S ); project_menu->addAction( embed::getIconPixmap( "project_save" ), tr( "Save as New &Version" ), - this, SLOT( saveProjectAsNewVersion() ), + this, SLOT(saveProjectAsNewVersion()), Qt::CTRL + Qt::ALT + Qt::Key_S ); project_menu->addAction( embed::getIconPixmap( "project_save" ), tr( "Save as default template" ), - this, SLOT( saveProjectAsDefaultTemplate() ) ); + this, SLOT(saveProjectAsDefaultTemplate())); project_menu->addSeparator(); project_menu->addAction( embed::getIconPixmap( "project_import" ), tr( "Import..." ), this, - SLOT( onImportProject() ) ); + SLOT(onImportProject())); project_menu->addAction( embed::getIconPixmap( "project_export" ), tr( "E&xport..." ), this, - SLOT( onExportProject() ), + SLOT(onExportProject()), Qt::CTRL + Qt::Key_E ); project_menu->addAction( embed::getIconPixmap( "project_export" ), tr( "E&xport Tracks..." ), this, - SLOT( onExportProjectTracks() ), + SLOT(onExportProjectTracks()), Qt::CTRL + Qt::SHIFT + Qt::Key_E ); project_menu->addAction( embed::getIconPixmap( "midi_file" ), tr( "Export &MIDI..." ), this, - SLOT( onExportProjectMidi() ), + SLOT(onExportProjectMidi()), Qt::CTRL + Qt::Key_M ); // Prevent dangling separator at end of menu per https://bugreports.qt.io/browse/QTBUG-40071 @@ -356,40 +359,39 @@ void MainWindow::finalize() project_menu->addSeparator(); #endif project_menu->addAction( embed::getIconPixmap( "exit" ), tr( "&Quit" ), - qApp, SLOT( closeAllWindows() ), + qApp, SLOT(closeAllWindows()), Qt::CTRL + Qt::Key_Q ); - - QMenu * edit_menu = new QMenu( this ); + auto edit_menu = new QMenu(this); menuBar()->addMenu( edit_menu )->setText( tr( "&Edit" ) ); m_undoAction = edit_menu->addAction( embed::getIconPixmap( "edit_undo" ), tr( "Undo" ), - this, SLOT( undo() ), + this, SLOT(undo()), QKeySequence::Undo ); m_redoAction = edit_menu->addAction( embed::getIconPixmap( "edit_redo" ), tr( "Redo" ), - this, SLOT( redo() ), + this, SLOT(redo()), QKeySequence::Redo ); // Ensure that both (Ctrl+Y) and (Ctrl+Shift+Z) activate redo shortcut regardless of OS defaults if (QKeySequence(QKeySequence::Redo) != QKeySequence(Qt::CTRL + Qt::Key_Y)) { - new QShortcut( QKeySequence( Qt::CTRL + Qt::Key_Y ), this, SLOT(redo()) ); + new QShortcut( QKeySequence( Qt::CTRL + Qt::Key_Y ), this, SLOT(redo())); } if (QKeySequence(QKeySequence::Redo) != QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Z )) { - new QShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_Z ), this, SLOT(redo()) ); + new QShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_Z ), this, SLOT(redo())); } edit_menu->addSeparator(); edit_menu->addAction( embed::getIconPixmap( "setup_general" ), tr( "Settings" ), - this, SLOT( showSettingsDialog() ) ); - connect( edit_menu, SIGNAL(aboutToShow()), this, SLOT(updateUndoRedoButtons()) ); + this, SLOT(showSettingsDialog())); + connect( edit_menu, SIGNAL(aboutToShow()), this, SLOT(updateUndoRedoButtons())); m_viewMenu = new QMenu( this ); menuBar()->addMenu( m_viewMenu )->setText( tr( "&View" ) ); - connect( m_viewMenu, SIGNAL( aboutToShow() ), - this, SLOT( updateViewMenu() ) ); + connect( m_viewMenu, SIGNAL(aboutToShow()), + this, SLOT(updateViewMenu())); connect( m_viewMenu, SIGNAL(triggered(QAction*)), this, SLOT(updateConfig(QAction*))); @@ -404,26 +406,26 @@ void MainWindow::finalize() if( !m_toolsMenu->isEmpty() ) { menuBar()->addMenu( m_toolsMenu )->setText( tr( "&Tools" ) ); - connect( m_toolsMenu, SIGNAL( triggered( QAction * ) ), - this, SLOT( showTool( QAction * ) ) ); + connect( m_toolsMenu, SIGNAL(triggered(QAction*)), + this, SLOT(showTool(QAction*))); } // help-popup-menu - QMenu * help_menu = new QMenu( this ); + auto help_menu = new QMenu(this); menuBar()->addMenu( help_menu )->setText( tr( "&Help" ) ); // May use offline help if( true ) { help_menu->addAction( embed::getIconPixmap( "help" ), tr( "Online Help" ), - this, SLOT( browseHelp() ) ); + this, SLOT(browseHelp())); } else { help_menu->addAction( embed::getIconPixmap( "help" ), tr( "Help" ), - this, SLOT( help() ) ); + this, SLOT(help())); } // Prevent dangling separator at end of menu per https://bugreports.qt.io/browse/QTBUG-40071 @@ -431,55 +433,35 @@ void MainWindow::finalize() help_menu->addSeparator(); #endif help_menu->addAction( embed::getIconPixmap( "icon_small" ), tr( "About" ), - this, SLOT( aboutLMMS() ) ); + this, SLOT(aboutLMMS())); // create tool-buttons - ToolButton * project_new = new ToolButton( - embed::getIconPixmap( "project_new" ), - tr( "Create new project" ), - this, SLOT( createNewProject() ), - m_toolBar ); + auto project_new = new ToolButton( + embed::getIconPixmap("project_new"), tr("Create new project"), this, SLOT(createNewProject()), m_toolBar); - ToolButton * project_new_from_template = new ToolButton( - embed::getIconPixmap( "project_new_from_template" ), - tr( "Create new project from template" ), - this, SLOT( emptySlot() ), - m_toolBar ); + auto project_new_from_template = new ToolButton(embed::getIconPixmap("project_new_from_template"), + tr("Create new project from template"), this, SLOT(emptySlot()), m_toolBar); project_new_from_template->setMenu( templates_menu ); project_new_from_template->setPopupMode( ToolButton::InstantPopup ); - ToolButton * project_open = new ToolButton( - embed::getIconPixmap( "project_open" ), - tr( "Open existing project" ), - this, SLOT( openProject() ), - m_toolBar ); + auto project_open = new ToolButton( + embed::getIconPixmap("project_open"), tr("Open existing project"), this, SLOT(openProject()), m_toolBar); - - ToolButton * project_open_recent = new ToolButton( - embed::getIconPixmap( "project_open_recent" ), - tr( "Recently opened projects" ), - this, SLOT( emptySlot() ), m_toolBar ); + auto project_open_recent = new ToolButton(embed::getIconPixmap("project_open_recent"), + tr("Recently opened projects"), this, SLOT(emptySlot()), m_toolBar); project_open_recent->setMenu( new RecentProjectsMenu(this) ); project_open_recent->setPopupMode( ToolButton::InstantPopup ); - ToolButton * project_save = new ToolButton( - embed::getIconPixmap( "project_save" ), - tr( "Save current project" ), - this, SLOT( saveProject() ), - m_toolBar ); + auto project_save = new ToolButton( + embed::getIconPixmap("project_save"), tr("Save current project"), this, SLOT(saveProject()), m_toolBar); - - ToolButton * project_export = new ToolButton( - embed::getIconPixmap( "project_export" ), - tr( "Export current project" ), - this, - SLOT( onExportProject() ), - m_toolBar ); + auto project_export = new ToolButton( + embed::getIconPixmap("project_export"), tr("Export current project"), this, SLOT(onExportProject()), m_toolBar); m_metronomeToggle = new ToolButton( embed::getIconPixmap( "metronome" ), tr( "Metronome" ), - this, SLOT( onToggleMetronome() ), + this, SLOT(onToggleMetronome()), m_toolBar ); m_metronomeToggle->setCheckable(true); m_metronomeToggle->setChecked(Engine::audioEngine()->isMetronomeActive()); @@ -495,68 +477,36 @@ void MainWindow::finalize() // window-toolbar - ToolButton * song_editor_window = new ToolButton( - embed::getIconPixmap( "songeditor" ), - tr( "Song Editor" ) + " (Ctrl+1)", - this, SLOT( toggleSongEditorWin() ), - m_toolBar ); + auto song_editor_window = new ToolButton(embed::getIconPixmap("songeditor"), tr("Song Editor") + " (Ctrl+1)", this, + SLOT(toggleSongEditorWin()), m_toolBar); song_editor_window->setShortcut( Qt::CTRL + Qt::Key_1 ); - - ToolButton* pattern_editor_window = new ToolButton( - embed::getIconPixmap("pattern_track_btn"), - tr("Pattern Editor") + " (Ctrl+2)", - this, SLOT(togglePatternEditorWin()), - m_toolBar); + auto pattern_editor_window = new ToolButton(embed::getIconPixmap("pattern_track_btn"), + tr("Pattern Editor") + " (Ctrl+2)", this, SLOT(togglePatternEditorWin()), m_toolBar); pattern_editor_window->setShortcut(Qt::CTRL + Qt::Key_2); - - ToolButton * piano_roll_window = new ToolButton( - embed::getIconPixmap( "piano" ), - tr( "Piano Roll" ) + - " (Ctrl+3)", - this, SLOT( togglePianoRollWin() ), - m_toolBar ); + auto piano_roll_window = new ToolButton( + embed::getIconPixmap("piano"), tr("Piano Roll") + " (Ctrl+3)", this, SLOT(togglePianoRollWin()), m_toolBar); piano_roll_window->setShortcut( Qt::CTRL + Qt::Key_3 ); - ToolButton * automation_editor_window = new ToolButton( - embed::getIconPixmap( "automation" ), - tr( "Automation Editor" ) + - " (Ctrl+4)", - this, - SLOT( toggleAutomationEditorWin() ), - m_toolBar ); + auto automation_editor_window = new ToolButton(embed::getIconPixmap("automation"), + tr("Automation Editor") + " (Ctrl+4)", this, SLOT(toggleAutomationEditorWin()), m_toolBar); automation_editor_window->setShortcut( Qt::CTRL + Qt::Key_4 ); - ToolButton * mixer_window = new ToolButton( - embed::getIconPixmap( "mixer" ), - tr( "Mixer" ) + " (Ctrl+5)", - this, SLOT( toggleMixerWin() ), - m_toolBar ); + auto mixer_window = new ToolButton( + embed::getIconPixmap("mixer"), tr("Mixer") + " (Ctrl+5)", this, SLOT(toggleMixerWin()), m_toolBar); mixer_window->setShortcut( Qt::CTRL + Qt::Key_5 ); - ToolButton * controllers_window = new ToolButton( - embed::getIconPixmap( "controller" ), - tr( "Show/hide controller rack" ) + - " (Ctrl+6)", - this, SLOT( toggleControllerRack() ), - m_toolBar ); + auto controllers_window = new ToolButton(embed::getIconPixmap("controller"), + tr("Show/hide controller rack") + " (Ctrl+6)", this, SLOT(toggleControllerRack()), m_toolBar); controllers_window->setShortcut( Qt::CTRL + Qt::Key_6 ); - ToolButton * project_notes_window = new ToolButton( - embed::getIconPixmap( "project_notes" ), - tr( "Show/hide project notes" ) + - " (Ctrl+7)", - this, SLOT( toggleProjectNotesWin() ), - m_toolBar ); + auto project_notes_window = new ToolButton(embed::getIconPixmap("project_notes"), + tr("Show/hide project notes") + " (Ctrl+7)", this, SLOT(toggleProjectNotesWin()), m_toolBar); project_notes_window->setShortcut( Qt::CTRL + Qt::Key_7 ); - ToolButton * microtuner_window = new ToolButton( - embed::getIconPixmap( "microtuner" ), - tr( "Microtuner configuration" ) + - " (Ctrl+8)", - this, SLOT( toggleMicrotunerWin() ), - m_toolBar ); + auto microtuner_window = new ToolButton(embed::getIconPixmap("microtuner"), + tr("Microtuner configuration") + " (Ctrl+8)", this, SLOT(toggleMicrotunerWin()), m_toolBar); microtuner_window->setShortcut( Qt::CTRL + Qt::Key_8 ); m_toolBarLayout->addWidget( song_editor_window, 1, 1 ); @@ -613,7 +563,7 @@ void MainWindow::finalize() // reset window title every time we change the state of a subwindow to show the correct title for( const QMdiSubWindow * subWindow : workspace()->subWindowList() ) { - connect( subWindow, SIGNAL( windowStateChanged(Qt::WindowStates,Qt::WindowStates) ), this, SLOT( resetWindowTitle() ) ); + connect( subWindow, SIGNAL(windowStateChanged(Qt::WindowStates,Qt::WindowStates)), this, SLOT(resetWindowTitle())); } } @@ -646,7 +596,7 @@ void MainWindow::addSpacingToToolBar( int _size ) SubWindow* MainWindow::addWindowedWidget(QWidget *w, Qt::WindowFlags windowFlags) { // wrap the widget in our own *custom* window that patches some errors in QMdiSubWindow - SubWindow *win = new SubWindow(m_workspace->viewport(), windowFlags); + auto win = new SubWindow(m_workspace->viewport(), windowFlags); win->setAttribute(Qt::WA_DeleteOnClose); win->setWidget(w); if (w && w->sizeHint().isValid()) {win->resize(w->sizeHint());} @@ -757,7 +707,7 @@ void MainWindow::saveWidgetState( QWidget * _w, QDomElement & _de ) // If the widget is a SubWindow, then we can make use of the getTrueNormalGeometry() method that // performs the same as normalGeometry, but isn't broken on X11 ( see https://bugreports.qt.io/browse/QTBUG-256 ) - SubWindow *asSubWindow = qobject_cast(_w); + auto asSubWindow = qobject_cast(_w); QRect normalGeom = asSubWindow != nullptr ? asSubWindow->getTrueNormalGeometry() : _w->normalGeometry(); bool visible = _w->isVisible(); @@ -1143,7 +1093,7 @@ void MainWindow::updateViewMenu() // not on top -> top <-> invisible m_viewMenu->addAction(embed::getIconPixmap( "songeditor" ), tr( "Song Editor" ) + "\tCtrl+1", - this, SLOT( toggleSongEditorWin() ) + this, SLOT(toggleSongEditorWin()) ); m_viewMenu->addAction(embed::getIconPixmap("pattern_track"), tr("Pattern Editor") + "\tCtrl+2", @@ -1151,35 +1101,35 @@ void MainWindow::updateViewMenu() ); m_viewMenu->addAction(embed::getIconPixmap( "piano" ), tr( "Piano Roll" ) + "\tCtrl+3", - this, SLOT( togglePianoRollWin() ) + this, SLOT(togglePianoRollWin()) ); m_viewMenu->addAction(embed::getIconPixmap( "automation" ), tr( "Automation Editor" ) + "\tCtrl+4", this, - SLOT( toggleAutomationEditorWin()) + SLOT(toggleAutomationEditorWin()) ); m_viewMenu->addAction(embed::getIconPixmap( "mixer" ), tr( "Mixer" ) + "\tCtrl+5", - this, SLOT( toggleMixerWin() ) + this, SLOT(toggleMixerWin()) ); m_viewMenu->addAction(embed::getIconPixmap( "controller" ), tr( "Controller Rack" ) + "\tCtrl+6", - this, SLOT( toggleControllerRack() ) + this, SLOT(toggleControllerRack()) ); m_viewMenu->addAction(embed::getIconPixmap( "project_notes" ), tr( "Project Notes" ) + "\tCtrl+7", - this, SLOT( toggleProjectNotesWin() ) + this, SLOT(toggleProjectNotesWin()) ); m_viewMenu->addAction(embed::getIconPixmap( "microtuner" ), tr( "Microtuner" ) + "\tCtrl+8", - this, SLOT( toggleMicrotunerWin() ) + this, SLOT(toggleMicrotunerWin()) ); m_viewMenu->addSeparator(); m_viewMenu->addAction(embed::getIconPixmap( "fullscreen" ), tr( "Fullscreen" ) + "\tF11", - this, SLOT( toggleFullscreen() ) + this, SLOT(toggleFullscreen()) ); m_viewMenu->addSeparator(); @@ -1735,3 +1685,6 @@ void MainWindow::onProjectFileNameChanged() { this->resetWindowTitle(); } + + +} // namespace lmms::gui diff --git a/src/gui/MicrotunerConfig.cpp b/src/gui/MicrotunerConfig.cpp index 307369a19..316bf54d6 100644 --- a/src/gui/MicrotunerConfig.cpp +++ b/src/gui/MicrotunerConfig.cpp @@ -50,6 +50,9 @@ #include "Song.h" #include "SubWindow.h" +namespace lmms::gui +{ + MicrotunerConfig::MicrotunerConfig() : QWidget(), @@ -65,20 +68,20 @@ MicrotunerConfig::MicrotunerConfig() : setWindowTitle(tr("Microtuner")); // Organize into 2 main columns: scales and keymaps - QGridLayout *microtunerLayout = new QGridLayout(); + auto microtunerLayout = new QGridLayout(); microtunerLayout->setSpacing(2); // ---------------------------------- // Scale sub-column // - QLabel *scaleLabel = new QLabel(tr("Scale:")); + auto scaleLabel = new QLabel(tr("Scale:")); microtunerLayout->addWidget(scaleLabel, 0, 0, 1, 2, Qt::AlignBottom); for (unsigned int i = 0; i < MaxScaleCount; i++) { m_scaleComboModel.addItem(QString::number(i) + ": " + Engine::getSong()->getScale(i)->getDescription()); } - ComboBox *scaleCombo = new ComboBox(); + auto scaleCombo = new ComboBox(); scaleCombo->setModel(&m_scaleComboModel); microtunerLayout->addWidget(scaleCombo, 1, 0, 1, 2); connect(&m_scaleComboModel, &ComboBoxModel::dataChanged, [=] {updateScaleForm();}); @@ -87,8 +90,8 @@ MicrotunerConfig::MicrotunerConfig() : m_scaleNameEdit->setToolTip(tr("Scale description. Cannot start with \"!\" and cannot contain a newline character.")); microtunerLayout->addWidget(m_scaleNameEdit, 2, 0, 1, 2); - QPushButton *loadScaleButton = new QPushButton(tr("Load")); - QPushButton *saveScaleButton = new QPushButton(tr("Save")); + auto loadScaleButton = new QPushButton(tr("Load")); + auto saveScaleButton = new QPushButton(tr("Save")); microtunerLayout->addWidget(loadScaleButton, 3, 0, 1, 1); microtunerLayout->addWidget(saveScaleButton, 3, 1, 1, 1); connect(loadScaleButton, &QPushButton::clicked, [=] {loadScaleFromFile();}); @@ -99,21 +102,21 @@ MicrotunerConfig::MicrotunerConfig() : m_scaleTextEdit->setToolTip(tr("Enter intervals on separate lines. Numbers containing a decimal point are treated as cents.\nOther inputs are treated as integer ratios and must be in the form of \'a/b\' or \'a\'.\nUnity (0.0 cents or ratio 1/1) is always present as a hidden first value; do not enter it manually.")); microtunerLayout->addWidget(m_scaleTextEdit, 4, 0, 2, 2); - QPushButton *applyScaleButton = new QPushButton(tr("Apply scale")); + auto applyScaleButton = new QPushButton(tr("Apply scale")); microtunerLayout->addWidget(applyScaleButton, 6, 0, 1, 2); connect(applyScaleButton, &QPushButton::clicked, [=] {applyScale();}); // ---------------------------------- // Mapping sub-column // - QLabel *keymapLabel = new QLabel(tr("Keymap:")); + auto keymapLabel = new QLabel(tr("Keymap:")); microtunerLayout->addWidget(keymapLabel, 0, 2, 1, 2, Qt::AlignBottom); for (unsigned int i = 0; i < MaxKeymapCount; i++) { m_keymapComboModel.addItem(QString::number(i) + ": " + Engine::getSong()->getKeymap(i)->getDescription()); } - ComboBox *keymapCombo = new ComboBox(); + auto keymapCombo = new ComboBox(); keymapCombo->setModel(&m_keymapComboModel); microtunerLayout->addWidget(keymapCombo, 1, 2, 1, 2); connect(&m_keymapComboModel, &ComboBoxModel::dataChanged, [=] {updateKeymapForm();}); @@ -122,8 +125,8 @@ MicrotunerConfig::MicrotunerConfig() : m_keymapNameEdit->setToolTip(tr("Keymap description. Cannot start with \"!\" and cannot contain a newline character.")); microtunerLayout->addWidget(m_keymapNameEdit, 2, 2, 1, 2); - QPushButton *loadKeymapButton = new QPushButton(tr("Load")); - QPushButton *saveKeymapButton = new QPushButton(tr("Save")); + auto loadKeymapButton = new QPushButton(tr("Load")); + auto saveKeymapButton = new QPushButton(tr("Save")); microtunerLayout->addWidget(loadKeymapButton, 3, 2, 1, 1); microtunerLayout->addWidget(saveKeymapButton, 3, 3, 1, 1); connect(loadKeymapButton, &QPushButton::clicked, [=] {loadKeymapFromFile();}); @@ -135,40 +138,40 @@ MicrotunerConfig::MicrotunerConfig() : microtunerLayout->addWidget(m_keymapTextEdit, 4, 2, 1, 2); // Mapping ranges - QGridLayout *keymapRangeLayout = new QGridLayout(); + auto keymapRangeLayout = new QGridLayout(); microtunerLayout->addLayout(keymapRangeLayout, 5, 2, 1, 2, Qt::AlignCenter | Qt::AlignTop); - LcdSpinBox *firstKeySpin = new LcdSpinBox(3, nullptr, tr("First key")); + auto firstKeySpin = new LcdSpinBox(3, nullptr, tr("First key")); firstKeySpin->setLabel(tr("FIRST")); firstKeySpin->setToolTip(tr("First MIDI key that will be mapped")); firstKeySpin->setModel(&m_firstKeyModel); keymapRangeLayout->addWidget(firstKeySpin, 0, 0); - LcdSpinBox *lastKeySpin = new LcdSpinBox(3, nullptr, tr("Last key")); + auto lastKeySpin = new LcdSpinBox(3, nullptr, tr("Last key")); lastKeySpin->setLabel(tr("LAST")); lastKeySpin->setToolTip(tr("Last MIDI key that will be mapped")); lastKeySpin->setModel(&m_lastKeyModel); keymapRangeLayout->addWidget(lastKeySpin, 0, 1); - LcdSpinBox *middleKeySpin = new LcdSpinBox(3, nullptr, tr("Middle key")); + auto middleKeySpin = new LcdSpinBox(3, nullptr, tr("Middle key")); middleKeySpin->setLabel(tr("MIDDLE")); middleKeySpin->setToolTip(tr("First line in the keymap refers to this MIDI key")); middleKeySpin->setModel(&m_middleKeyModel); keymapRangeLayout->addWidget(middleKeySpin, 0, 2); - LcdSpinBox *baseKeySpin = new LcdSpinBox(3, nullptr, tr("Base key")); + auto baseKeySpin = new LcdSpinBox(3, nullptr, tr("Base key")); baseKeySpin->setLabel(tr("BASE N.")); baseKeySpin->setToolTip(tr("Base note frequency will be assigned to this MIDI key")); baseKeySpin->setModel(&m_baseKeyModel); keymapRangeLayout->addWidget(baseKeySpin, 1, 0); - LcdFloatSpinBox *baseFreqSpin = new LcdFloatSpinBox(4, 3, tr("Base note frequency")); + auto baseFreqSpin = new LcdFloatSpinBox(4, 3, tr("Base note frequency")); baseFreqSpin->setLabel(tr("BASE NOTE FREQ")); baseFreqSpin->setModel(&m_baseFreqModel); baseFreqSpin->setToolTip(tr("Base note frequency")); keymapRangeLayout->addWidget(baseFreqSpin, 1, 1, 1, 2); - QPushButton *applyKeymapButton = new QPushButton(tr("Apply keymap")); + auto applyKeymapButton = new QPushButton(tr("Apply keymap")); microtunerLayout->addWidget(applyKeymapButton, 6, 2, 1, 2); connect(applyKeymapButton, &QPushButton::clicked, [=] {applyKeymap();}); @@ -283,9 +286,9 @@ void MicrotunerConfig::updateKeymapForm() m_keymapTextEdit->setPlainText(""); const std::vector &map = newMap->getMap(); - for (std::size_t i = 0; i < map.size(); i++) + for (int value : map) { - if (map[i] >= 0) {m_keymapTextEdit->appendPlainText(QString::number(map[i]));} + if (value >= 0) {m_keymapTextEdit->appendPlainText(QString::number(value));} else {m_keymapTextEdit->appendPlainText("x");} } QTextCursor tmp = m_keymapTextEdit->textCursor(); @@ -314,7 +317,11 @@ bool MicrotunerConfig::validateScaleForm() if (name.contains('\n')) {fail(tr("Scale name cannot contain a new-line character")); return false;} // check intervals - QStringList input = m_scaleTextEdit->toPlainText().split('\n', QString::SkipEmptyParts); + #if (QT_VERSION >= QT_VERSION_CHECK(5,14,0)) + QStringList input = m_scaleTextEdit->toPlainText().split('\n', Qt::SkipEmptyParts); + #else + QStringList input = m_scaleTextEdit->toPlainText().split('\n', QString::SkipEmptyParts); + #endif for (auto &line: input) { if (line.isEmpty()) {continue;} @@ -358,7 +365,11 @@ bool MicrotunerConfig::validateKeymapForm() if (name.contains('\n')) {fail(tr("Keymap name cannot contain a new-line character")); return false;} // check key mappings - QStringList input = m_keymapTextEdit->toPlainText().split('\n', QString::SkipEmptyParts); + #if (QT_VERSION >= QT_VERSION_CHECK(5,14,0)) + QStringList input = m_keymapTextEdit->toPlainText().split('\n', Qt::SkipEmptyParts); + #else + QStringList input = m_keymapTextEdit->toPlainText().split('\n', QString::SkipEmptyParts); + #endif for (auto &line: input) { if (line.isEmpty()) {continue;} @@ -386,9 +397,13 @@ bool MicrotunerConfig::applyScale() if (!validateScaleForm()) {return false;}; std::vector newIntervals; - newIntervals.push_back(Interval(1, 1)); + newIntervals.emplace_back(1, 1); +#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0)) + QStringList input = m_scaleTextEdit->toPlainText().split('\n', Qt::SkipEmptyParts); +#else QStringList input = m_scaleTextEdit->toPlainText().split('\n', QString::SkipEmptyParts); +#endif for (auto &line: input) { if (line.isEmpty()) {continue;} @@ -396,7 +411,7 @@ bool MicrotunerConfig::applyScale() QString firstSection = line.section(QRegExp("\\s+|/"), 0, 0, QString::SectionSkipEmpty); if (firstSection.contains('.')) // cent mode { - newIntervals.push_back(Interval(firstSection.toFloat())); + newIntervals.emplace_back(firstSection.toFloat()); } else // ratio mode { @@ -406,7 +421,7 @@ bool MicrotunerConfig::applyScale() { den = line.split('/').at(1).section(QRegExp("\\s+"), 0, 0, QString::SectionSkipEmpty).toInt(); } - newIntervals.push_back(Interval(num, den)); + newIntervals.emplace_back(num, den); } } @@ -430,7 +445,11 @@ bool MicrotunerConfig::applyKeymap() std::vector newMap; +#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0)) + QStringList input = m_keymapTextEdit->toPlainText().split('\n', Qt::SkipEmptyParts); +#else QStringList input = m_keymapTextEdit->toPlainText().split('\n', QString::SkipEmptyParts); +#endif for (auto &line: input) { if (line.isEmpty()) {continue;} @@ -651,3 +670,6 @@ void MicrotunerConfig::closeEvent(QCloseEvent *ce) else {hide();} ce->ignore(); } + + +} // namespace lmms::gui diff --git a/src/gui/MidiCCRackView.cpp b/src/gui/MidiCCRackView.cpp index f7bf98e81..7e0d71f78 100644 --- a/src/gui/MidiCCRackView.cpp +++ b/src/gui/MidiCCRackView.cpp @@ -38,6 +38,9 @@ #include "MainWindow.h" #include "SubWindow.h" +namespace lmms::gui +{ + MidiCCRackView::MidiCCRackView(InstrumentTrack * track) : QWidget(), @@ -61,21 +64,21 @@ MidiCCRackView::MidiCCRackView(InstrumentTrack * track) : subWin->hide(); // Main window layout - QVBoxLayout *mainLayout = new QVBoxLayout(this); + auto mainLayout = new QVBoxLayout(this); // Knobs GroupBox - Here we have the MIDI CC controller knobs for the selected track m_midiCCGroupBox = new GroupBox(tr("MIDI CC Knobs:")); // Layout to keep scrollable area under the GroupBox header - QVBoxLayout *knobsGroupBoxLayout = new QVBoxLayout(); + auto knobsGroupBoxLayout = new QVBoxLayout(); knobsGroupBoxLayout->setContentsMargins(5, 16, 5, 5); m_midiCCGroupBox->setLayout(knobsGroupBoxLayout); // Scrollable area + widget + its layout that will have all the knobs - QScrollArea *knobsScrollArea = new QScrollArea(); - QWidget *knobsArea = new QWidget(); - QGridLayout *knobsAreaLayout = new QGridLayout(); + auto knobsScrollArea = new QScrollArea(); + auto knobsArea = new QWidget(); + auto knobsAreaLayout = new QGridLayout(); knobsArea->setLayout(knobsAreaLayout); knobsScrollArea->setWidget(knobsArea); @@ -130,3 +133,6 @@ void MidiCCRackView::saveSettings(QDomDocument & doc, QDomElement & parent) void MidiCCRackView::loadSettings(const QDomElement &) { } + + +} // namespace lmms::gui diff --git a/src/gui/MidiSetupWidget.cpp b/src/gui/MidiSetupWidget.cpp index 7298eb558..4f620fb0e 100644 --- a/src/gui/MidiSetupWidget.cpp +++ b/src/gui/MidiSetupWidget.cpp @@ -30,6 +30,11 @@ #include "ConfigManager.h" #include "gui_templates.h" + +namespace lmms::gui +{ + + MidiSetupWidget::MidiSetupWidget(const QString & caption, const QString & configSection, const QString & devName, QWidget * parent) : TabWidget(TabWidget::tr("Settings for %1").arg(tr(caption.toUtf8())), parent), @@ -43,7 +48,7 @@ MidiSetupWidget::MidiSetupWidget(const QString & caption, const QString & config m_device = new QLineEdit(devName, this); m_device->setGeometry(10, 20, 160, 20); - QLabel * dev_lbl = new QLabel(tr("Device"), this); + auto dev_lbl = new QLabel(tr("Device"), this); dev_lbl->setFont(pointSize<7>(dev_lbl->font())); dev_lbl->setGeometry(10, 40, 160, 10); } @@ -65,3 +70,6 @@ void MidiSetupWidget::show() parentWidget()->setVisible(visible); QWidget::setVisible(visible); } + + +} // namespace lmms::gui diff --git a/src/gui/MixerLine.cpp b/src/gui/MixerLine.cpp index 6c0cc5bc3..030ea892e 100644 --- a/src/gui/MixerLine.cpp +++ b/src/gui/MixerLine.cpp @@ -44,12 +44,16 @@ #include "SendButtonIndicator.h" #include "Song.h" +namespace lmms::gui +{ + + bool MixerLine::eventFilter( QObject *dist, QEvent *event ) { // If we are in a rename, capture the enter/return events and handle them if ( event->type() == QEvent::KeyPress ) { - QKeyEvent * keyEvent = static_cast(event); + auto keyEvent = static_cast(event); if( keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return ) { if( m_inRename ) @@ -116,7 +120,7 @@ MixerLine::MixerLine( QWidget * _parent, MixerView * _mv, int _channelIndex ) : m_renameLineEdit->setReadOnly( true ); m_renameLineEdit->installEventFilter( this ); - QGraphicsScene * scene = new QGraphicsScene(); + auto scene = new QGraphicsScene(); scene->setSceneRect( 0, 0, 33, MixerLineHeight ); m_view = new QGraphicsView( this ); @@ -130,8 +134,8 @@ MixerLine::MixerLine( QWidget * _parent, MixerView * _mv, int _channelIndex ) : proxyWidget->setRotation( -90 ); proxyWidget->setPos( 8, 145 ); - connect( m_renameLineEdit, SIGNAL( editingFinished() ), this, SLOT( renameFinished() ) ); - connect( &Engine::mixer()->mixerChannel( m_channelIndex )->m_muteModel, SIGNAL( dataChanged() ), this, SLOT( update() ) ); + connect( m_renameLineEdit, SIGNAL(editingFinished()), this, SLOT(renameFinished())); + connect( &Engine::mixer()->mixerChannel( m_channelIndex )->m_muteModel, SIGNAL(dataChanged()), this, SLOT(update())); } @@ -247,18 +251,18 @@ void MixerLine::contextMenuEvent( QContextMenuEvent * ) QPointer contextMenu = new CaptionMenu( Engine::mixer()->mixerChannel( m_channelIndex )->m_name, this ); if( m_channelIndex != 0 ) // no move-options in master { - contextMenu->addAction( tr( "Move &left" ), this, SLOT( moveChannelLeft() ) ); - contextMenu->addAction( tr( "Move &right" ), this, SLOT( moveChannelRight() ) ); + contextMenu->addAction( tr( "Move &left" ), this, SLOT(moveChannelLeft())); + contextMenu->addAction( tr( "Move &right" ), this, SLOT(moveChannelRight())); } - contextMenu->addAction( tr( "Rename &channel" ), this, SLOT( renameChannel() ) ); + contextMenu->addAction( tr( "Rename &channel" ), this, SLOT(renameChannel())); contextMenu->addSeparator(); if( m_channelIndex != 0 ) // no remove-option in master { - contextMenu->addAction( embed::getIconPixmap( "cancel" ), tr( "R&emove channel" ), this, SLOT( removeChannel() ) ); + contextMenu->addAction( embed::getIconPixmap( "cancel" ), tr( "R&emove channel" ), this, SLOT(removeChannel())); contextMenu->addSeparator(); } - contextMenu->addAction( embed::getIconPixmap( "cancel" ), tr( "Remove &unused channels" ), this, SLOT( removeUnusedChannels() ) ); + contextMenu->addAction( embed::getIconPixmap( "cancel" ), tr( "Remove &unused channels" ), this, SLOT(removeUnusedChannels())); contextMenu->addSeparator(); QMenu colorMenu(tr("Color"), this); @@ -456,3 +460,6 @@ void MixerLine::randomizeColor() Engine::getSong()->setModified(); update(); } + + +} // namespace lmms::gui diff --git a/src/gui/MixerView.cpp b/src/gui/MixerView.cpp index 15a24721f..62d4cb7ce 100644 --- a/src/gui/MixerView.cpp +++ b/src/gui/MixerView.cpp @@ -46,6 +46,10 @@ #include "SubWindow.h" #include "TrackContainer.h" // For TrackContainer::TrackList typedef +namespace lmms::gui +{ + + MixerView::MixerView() : QWidget(), ModelView( nullptr, this ), @@ -65,7 +69,7 @@ MixerView::MixerView() : setWindowIcon( embed::getIconPixmap( "mixer" ) ); // main-layout - QHBoxLayout * ml = new QHBoxLayout; + auto ml = new QHBoxLayout; // Set margins ml->setContentsMargins( 0, 4, 0, 0 ); @@ -109,7 +113,7 @@ MixerView::MixerView() : public: ChannelArea( QWidget * parent, MixerView * mv ) : QScrollArea( parent ), m_mv( mv ) {} - ~ChannelArea() {} + ~ChannelArea() override = default; void keyPressEvent( QKeyEvent * e ) override { m_mv->keyPressEvent( e ); @@ -127,10 +131,10 @@ MixerView::MixerView() : ml->addWidget( channelArea, 1, Qt::AlignTop ); // show the add new mixer channel button - QPushButton * newChannelBtn = new QPushButton( embed::getIconPixmap( "new_channel" ), QString(), this ); + auto newChannelBtn = new QPushButton(embed::getIconPixmap("new_channel"), QString(), this); newChannelBtn->setObjectName( "newChannelBtn" ); newChannelBtn->setFixedSize( mixerLineSize ); - connect( newChannelBtn, SIGNAL( clicked() ), this, SLOT( addNewChannel() ) ); + connect( newChannelBtn, SIGNAL(clicked()), this, SLOT(addNewChannel())); ml->addWidget( newChannelBtn, 0, Qt::AlignTop ); @@ -143,8 +147,8 @@ MixerView::MixerView() : updateGeometry(); // timer for updating faders - connect( getGUI()->mainWindow(), SIGNAL( periodicUpdate() ), - this, SLOT( updateFaders() ) ); + connect( getGUI()->mainWindow(), SIGNAL(periodicUpdate()), + this, SLOT(updateFaders())); // add ourself to workspace @@ -164,9 +168,9 @@ MixerView::MixerView() : MixerView::~MixerView() { - for (int i=0; itracks(); TrackContainer::TrackList patternStoreTracks = Engine::patternStore()->tracks(); - TrackContainer::TrackList trackLists[] = {songTracks, patternStoreTracks}; - for(int tl=0; tl<2; ++tl) + for (const auto& trackList : {songTracks, patternStoreTracks}) { - TrackContainer::TrackList trackList = trackLists[tl]; - for(int i=0; itype() == Track::InstrumentTrack ) + if (track->type() == Track::InstrumentTrack) { - InstrumentTrack * inst = (InstrumentTrack *) trackList[i]; + auto inst = (InstrumentTrack*)track; inst->mixerChannelModel()->setRange(0, m_mixerChannelViews.size()-1,1); } - else if( trackList[i]->type() == Track::SampleTrack ) + else if (track->type() == Track::SampleTrack) { - SampleTrack * strk = (SampleTrack *) trackList[i]; + auto strk = (SampleTrack*)track; strk->mixerChannelModel()->setRange(0, m_mixerChannelViews.size()-1,1); } @@ -307,7 +309,7 @@ MixerView::MixerChannelView::MixerChannelView(QWidget * _parent, MixerView * _mv embed::getIconPixmap( "led_off" ) ); m_soloBtn->setCheckable( true ); m_soloBtn->move( 9, m_fader->y()-21); - connect(&mixerChannel->m_soloModel, SIGNAL( dataChanged() ), + connect(&mixerChannel->m_soloModel, SIGNAL(dataChanged()), _mv, SLOT ( toggledSolo() ), Qt::DirectConnection ); m_soloBtn->setToolTip(tr("Solo this channel")); @@ -441,12 +443,12 @@ void MixerView::deleteUnusedChannels() int channel = 0; if (t->type() == Track::InstrumentTrack) { - InstrumentTrack* inst = dynamic_cast(t); + auto inst = dynamic_cast(t); channel = inst->mixerChannelModel()->value(); } else if (t->type() == Track::SampleTrack) { - SampleTrack *strack = dynamic_cast(t); + auto strack = dynamic_cast(t); channel = strack->mixerChannelModel()->value(); } inUse[channel] = true; @@ -618,3 +620,6 @@ void MixerView::updateFaders() } } } + + +} // namespace lmms::gui diff --git a/src/gui/ModelView.cpp b/src/gui/ModelView.cpp index 055f0846d..b2536fd9c 100644 --- a/src/gui/ModelView.cpp +++ b/src/gui/ModelView.cpp @@ -26,6 +26,8 @@ #include "ModelView.h" +namespace lmms::gui +{ ModelView::ModelView( Model* model, QWidget* widget ) : @@ -88,9 +90,10 @@ void ModelView::doConnections() { if( m_model != nullptr ) { - QObject::connect( m_model, SIGNAL( dataChanged() ), widget(), SLOT( update() ) ); - QObject::connect( m_model, SIGNAL( propertiesChanged() ), widget(), SLOT( update() ) ); + QObject::connect( m_model, SIGNAL(dataChanged()), widget(), SLOT(update())); + QObject::connect( m_model, SIGNAL(propertiesChanged()), widget(), SLOT(update())); } } +} // namespace lmms::gui diff --git a/src/gui/PeakControllerDialog.cpp b/src/gui/PeakControllerDialog.cpp index 923467d7e..11564a2d3 100644 --- a/src/gui/PeakControllerDialog.cpp +++ b/src/gui/PeakControllerDialog.cpp @@ -32,6 +32,9 @@ #include "PeakController.h" +namespace lmms::gui +{ + PeakControllerDialog::PeakControllerDialog( Controller * _model, QWidget * _parent ) : ControllerDialog( _model, _parent ) @@ -42,7 +45,7 @@ PeakControllerDialog::PeakControllerDialog( Controller * _model, QWidget * _pare setToolTip(tr("LFO Controller")); - QLabel * l = new QLabel( this ); + auto l = new QLabel(this); l->setText( "Use FX's controls" ); l->move(10, 10); @@ -52,12 +55,6 @@ PeakControllerDialog::PeakControllerDialog( Controller * _model, QWidget * _pare -PeakControllerDialog::~PeakControllerDialog() -{ -} - - - /* void effectView::closeEffects() { @@ -87,3 +84,4 @@ void PeakControllerDialog::modelChanged() } +} // namespace lmms::gui \ No newline at end of file diff --git a/src/gui/PluginBrowser.cpp b/src/gui/PluginBrowser.cpp index 649d6bb56..a19c80df0 100644 --- a/src/gui/PluginBrowser.cpp +++ b/src/gui/PluginBrowser.cpp @@ -37,6 +37,9 @@ #include "StringPairDrag.h" #include "PluginFactory.h" +namespace lmms::gui +{ + PluginBrowser::PluginBrowser( QWidget * _parent ) : SideBarWidget( tr( "Instrument Plugins" ), @@ -48,7 +51,7 @@ PluginBrowser::PluginBrowser( QWidget * _parent ) : addContentWidget( m_view ); - QVBoxLayout * view_layout = new QVBoxLayout( m_view ); + auto view_layout = new QVBoxLayout(m_view); view_layout->setMargin( 5 ); view_layout->setSpacing( 5 ); @@ -60,7 +63,7 @@ PluginBrowser::PluginBrowser( QWidget * _parent ) : m_view ); hint->setWordWrap( true ); - QLineEdit * searchBar = new QLineEdit( m_view ); + auto searchBar = new QLineEdit(m_view); searchBar->setPlaceholderText( "Search" ); searchBar->setMaxLength( 64 ); searchBar->setClearButtonEnabled( true ); @@ -71,8 +74,8 @@ PluginBrowser::PluginBrowser( QWidget * _parent ) : m_descTree->setIndentation( 10 ); m_descTree->setSelectionMode( QAbstractItemView::NoSelection ); - connect( searchBar, SIGNAL( textEdited( const QString & ) ), - this, SLOT( onFilterChanged( const QString & ) ) ); + connect( searchBar, SIGNAL( textEdited( const QString& ) ), + this, SLOT( onFilterChanged( const QString& ) ) ); view_layout->addWidget( hint ); view_layout->addWidget( searchBar ); @@ -117,8 +120,7 @@ void PluginBrowser::onFilterChanged( const QString & filter ) for (int itemIndex = 0; itemIndex < itemCount; ++itemIndex) { QTreeWidgetItem * item = root->child( itemIndex ); - PluginDescWidget * descWidget = static_cast - (m_descTree->itemWidget( item, 0)); + auto descWidget = static_cast(m_descTree->itemWidget(item, 0)); if (descWidget->name().contains(filter, Qt::CaseInsensitive)) { item->setHidden( false ); @@ -285,9 +287,4 @@ void PluginDescWidget::mousePressEvent( QMouseEvent * _me ) } - - - - - - +} // namespace lmms::gui diff --git a/src/gui/ProjectNotes.cpp b/src/gui/ProjectNotes.cpp index 428720ee9..f131a017c 100644 --- a/src/gui/ProjectNotes.cpp +++ b/src/gui/ProjectNotes.cpp @@ -44,6 +44,9 @@ #include "Song.h" +namespace lmms::gui +{ + ProjectNotes::ProjectNotes() : QMainWindow( getGUI()->mainWindow()->workspace() ) @@ -58,12 +61,12 @@ ProjectNotes::ProjectNotes() : clear(); connect( m_edit, - SIGNAL( currentCharFormatChanged( const QTextCharFormat & ) ), - this, SLOT( formatChanged( const QTextCharFormat & ) ) ); -// connect( m_edit, SIGNAL( currentAlignmentChanged( int ) ), -// this, SLOT( alignmentChanged( int ) ) ); - connect( m_edit, SIGNAL( textChanged() ), - Engine::getSong(), SLOT( setModified() ) ); + SIGNAL( currentCharFormatChanged( const QTextCharFormat& ) ), + this, SLOT( formatChanged( const QTextCharFormat& ) ) ); +// connect( m_edit, SIGNAL(currentAlignmentChanged(int)), +// this, SLOT(alignmentChanged(int))); + connect( m_edit, SIGNAL(textChanged()), + Engine::getSong(), SLOT(setModified())); setupActions(); @@ -81,13 +84,6 @@ ProjectNotes::ProjectNotes() : -ProjectNotes::~ProjectNotes() -{ -} - - - - void ProjectNotes::clear() { m_edit->setHtml( tr( "Enter project notes here" ) ); @@ -117,31 +113,31 @@ void ProjectNotes::setupActions() a = new QAction( embed::getIconPixmap( "edit_undo" ), tr( "&Undo" ), this ); a->setShortcut( tr( "%1+Z" ).arg(UI_CTRL_KEY) ); - connect( a, SIGNAL( triggered() ), m_edit, SLOT( undo() ) ); + connect( a, SIGNAL(triggered()), m_edit, SLOT(undo())); tb->addAction( a ); a = new QAction( embed::getIconPixmap( "edit_redo" ), tr( "&Redo" ), this ); a->setShortcut( tr( "%1+Y" ).arg(UI_CTRL_KEY) ); - connect( a, SIGNAL( triggered() ), m_edit, SLOT( redo() ) ); + connect( a, SIGNAL(triggered()), m_edit, SLOT(redo())); tb->addAction( a ); a = new QAction( embed::getIconPixmap( "edit_copy" ), tr( "&Copy" ), this ); a->setShortcut( tr( "%1+C" ).arg(UI_CTRL_KEY) ); - connect( a, SIGNAL( triggered() ), m_edit, SLOT( copy() ) ); + connect( a, SIGNAL(triggered()), m_edit, SLOT(copy())); tb->addAction( a ); a = new QAction( embed::getIconPixmap( "edit_cut" ), tr( "Cu&t" ), this ); a->setShortcut( tr( "%1+X" ).arg(UI_CTRL_KEY) ); - connect( a, SIGNAL( triggered() ), m_edit, SLOT( cut() ) ); + connect( a, SIGNAL(triggered()), m_edit, SLOT(cut())); tb->addAction( a ); a = new QAction( embed::getIconPixmap( "edit_paste" ), tr( "&Paste" ), this ); a->setShortcut( tr( "%1+V" ).arg(UI_CTRL_KEY) ); - connect( a, SIGNAL( triggered() ), m_edit, SLOT( paste() ) ); + connect( a, SIGNAL(triggered()), m_edit, SLOT(paste())); tb->addAction( a ); @@ -151,8 +147,8 @@ void ProjectNotes::setupActions() m_comboFont->setEditable( true ); QFontDatabase db; m_comboFont->addItems( db.families() ); - connect( m_comboFont, SIGNAL( activated( const QString & ) ), - m_edit, SLOT( setFontFamily( const QString & ) ) ); + connect( m_comboFont, SIGNAL( activated( const QString& ) ), + m_edit, SLOT( setFontFamily( const QString& ) ) ); m_comboFont->lineEdit()->setText( QApplication::font().family() ); m_comboSize = new QComboBox( tb ); @@ -163,8 +159,8 @@ void ProjectNotes::setupActions() { m_comboSize->addItem( QString::number( *it ) ); } - connect( m_comboSize, SIGNAL( activated( const QString & ) ), - this, SLOT( textSize( const QString & ) ) ); + connect( m_comboSize, SIGNAL( activated( const QString& ) ), + this, SLOT( textSize( const QString& ) ) ); m_comboSize->lineEdit()->setText( QString::number( QApplication::font().pointSize() ) ); @@ -172,28 +168,27 @@ void ProjectNotes::setupActions() tr( "&Bold" ), this ); m_actionTextBold->setShortcut( tr( "%1+B" ).arg(UI_CTRL_KEY) ); m_actionTextBold->setCheckable( true ); - connect( m_actionTextBold, SIGNAL( triggered() ), this, - SLOT( textBold() ) ); + connect( m_actionTextBold, SIGNAL(triggered()), this, + SLOT(textBold())); m_actionTextItalic = new QAction( embed::getIconPixmap( "text_italic" ), tr( "&Italic" ), this ); m_actionTextItalic->setShortcut( tr( "%1+I" ).arg(UI_CTRL_KEY) ); m_actionTextItalic->setCheckable( true ); - connect( m_actionTextItalic, SIGNAL( triggered() ), this, - SLOT( textItalic() ) ); + connect( m_actionTextItalic, SIGNAL(triggered()), this, + SLOT(textItalic())); m_actionTextUnderline = new QAction( embed::getIconPixmap( "text_under" ), tr( "&Underline" ), this ); m_actionTextUnderline->setShortcut( tr( "%1+U" ).arg(UI_CTRL_KEY) ); m_actionTextUnderline->setCheckable( true ); - connect( m_actionTextUnderline, SIGNAL( triggered() ), this, - SLOT( textUnderline() ) ); + connect( m_actionTextUnderline, SIGNAL(triggered()), this, + SLOT(textUnderline())); - - QActionGroup * grp = new QActionGroup( tb ); - connect( grp, SIGNAL( triggered( QAction * ) ), this, - SLOT( textAlign( QAction * ) ) ); + auto grp = new QActionGroup(tb); + connect( grp, SIGNAL(triggered(QAction*)), this, + SLOT(textAlign(QAction*))); m_actionAlignLeft = new QAction( embed::getIconPixmap( "text_left" ), tr( "&Left" ), m_edit ); @@ -227,8 +222,8 @@ void ProjectNotes::setupActions() QPixmap pix( 16, 16 ); pix.fill( Qt::black ); m_actionTextColor = new QAction( pix, tr( "&Color..." ), this ); - connect( m_actionTextColor, SIGNAL( triggered() ), this, - SLOT( textColor() ) ); + connect( m_actionTextColor, SIGNAL(triggered()), this, + SLOT(textColor())); tb->addWidget( m_comboFont ); tb->addWidget( m_comboSize ); @@ -409,3 +404,5 @@ void ProjectNotes::closeEvent( QCloseEvent * _ce ) } _ce->ignore(); } + +} // namespace lmms::gui diff --git a/src/gui/RowTableView.cpp b/src/gui/RowTableView.cpp index 9830354be..be4824016 100644 --- a/src/gui/RowTableView.cpp +++ b/src/gui/RowTableView.cpp @@ -29,6 +29,10 @@ #include +namespace lmms::gui +{ + + class RowDelegate : public QStyledItemDelegate { public: @@ -37,13 +41,13 @@ public: m_table( table ) { } - virtual void paint( QPainter * painter, + void paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const override; protected: - virtual void initStyleOption( QStyleOptionViewItem * option, + void initStyleOption( QStyleOptionViewItem * option, const QModelIndex & index ) const override; @@ -135,5 +139,4 @@ void RowTableView::keyPressEvent( QKeyEvent * event ) } - - +} // namespace lmms::gui diff --git a/src/gui/SampleTrackWindow.cpp b/src/gui/SampleTrackWindow.cpp index 0ef22a01d..78b899a09 100644 --- a/src/gui/SampleTrackWindow.cpp +++ b/src/gui/SampleTrackWindow.cpp @@ -43,7 +43,10 @@ #include "SubWindow.h" #include "TabWidget.h" #include "TrackLabelButton.h" - + +namespace lmms::gui +{ + SampleTrackWindow::SampleTrackWindow(SampleTrackView * tv) : QWidget(), @@ -53,27 +56,27 @@ SampleTrackWindow::SampleTrackWindow(SampleTrackView * tv) : { // init own layout + widgets setFocusPolicy(Qt::StrongFocus); - QVBoxLayout * vlayout = new QVBoxLayout(this); + auto vlayout = new QVBoxLayout(this); vlayout->setMargin(0); vlayout->setSpacing(0); - TabWidget* generalSettingsWidget = new TabWidget(tr("GENERAL SETTINGS"), this); + auto generalSettingsWidget = new TabWidget(tr("GENERAL SETTINGS"), this); - QVBoxLayout* generalSettingsLayout = new QVBoxLayout(generalSettingsWidget); + auto generalSettingsLayout = new QVBoxLayout(generalSettingsWidget); generalSettingsLayout->setContentsMargins(8, 18, 8, 8); generalSettingsLayout->setSpacing(6); - QWidget* nameWidget = new QWidget(generalSettingsWidget); - QHBoxLayout* nameLayout = new QHBoxLayout(nameWidget); + auto nameWidget = new QWidget(generalSettingsWidget); + auto nameLayout = new QHBoxLayout(nameWidget); nameLayout->setContentsMargins(0, 0, 0, 0); nameLayout->setSpacing(2); // setup line edit for changing sample track name m_nameLineEdit = new QLineEdit; m_nameLineEdit->setFont(pointSize<9>(m_nameLineEdit->font())); - connect(m_nameLineEdit, SIGNAL(textChanged(const QString &)), - this, SLOT(textChanged(const QString &))); + connect(m_nameLineEdit, SIGNAL(textChanged(const QString&)), + this, SLOT(textChanged(const QString&))); m_nameLineEdit->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred)); nameLayout->addWidget(m_nameLineEdit); @@ -81,8 +84,7 @@ SampleTrackWindow::SampleTrackWindow(SampleTrackView * tv) : generalSettingsLayout->addWidget(nameWidget); - - QGridLayout* basicControlsLayout = new QGridLayout; + auto basicControlsLayout = new QGridLayout; basicControlsLayout->setHorizontalSpacing(3); basicControlsLayout->setVerticalSpacing(0); basicControlsLayout->setContentsMargins(0, 0, 0, 0); @@ -99,7 +101,7 @@ SampleTrackWindow::SampleTrackWindow(SampleTrackView * tv) : basicControlsLayout->addWidget(m_volumeKnob, 0, 0); basicControlsLayout->setAlignment(m_volumeKnob, widgetAlignment); - QLabel *label = new QLabel(tr("VOL"), this); + auto label = new QLabel(tr("VOL"), this); label->setStyleSheet(labelStyleSheet); basicControlsLayout->addWidget(label, 1, 0); basicControlsLayout->setAlignment(label, labelAlignment); @@ -160,11 +162,6 @@ SampleTrackWindow::SampleTrackWindow(SampleTrackView * tv) : subWin->hide(); } -SampleTrackWindow::~SampleTrackWindow() -{ -} - - void SampleTrackWindow::setSampleTrackView(SampleTrackView* tv) { @@ -271,3 +268,6 @@ void SampleTrackWindow::loadSettings(const QDomElement& element) m_stv->m_tlb->setChecked(true); } } + + +} // namespace lmms::gui diff --git a/src/gui/SendButtonIndicator.cpp b/src/gui/SendButtonIndicator.cpp index 6772f6289..cd1996c45 100644 --- a/src/gui/SendButtonIndicator.cpp +++ b/src/gui/SendButtonIndicator.cpp @@ -5,6 +5,10 @@ #include "MixerLine.h" #include "MixerView.h" +namespace lmms::gui +{ + + QPixmap * SendButtonIndicator::s_qpmOff = nullptr; QPixmap * SendButtonIndicator::s_qpmOn = nullptr; @@ -62,3 +66,6 @@ void SendButtonIndicator::updateLightStatus() { setPixmap( getSendModel() == nullptr ? *s_qpmOff : *s_qpmOn ); } + + +} // namespace lmms::gui diff --git a/src/gui/SideBar.cpp b/src/gui/SideBar.cpp index 92b7d8884..e03b38b43 100644 --- a/src/gui/SideBar.cpp +++ b/src/gui/SideBar.cpp @@ -29,6 +29,9 @@ #include "SideBar.h" #include "SideBarWidget.h" +namespace lmms::gui +{ + // internal helper class allowing to create QToolButtons with // vertical orientation @@ -41,7 +44,7 @@ public: { } - virtual ~SideBarButton() = default; + ~SideBarButton() override = default; Qt::Orientation orientation() const { @@ -91,15 +94,8 @@ SideBar::SideBar( Qt::Orientation _orientation, QWidget * _parent ) : setIconSize( QSize( 16, 16 ) ); m_btnGroup.setExclusive( false ); - connect( &m_btnGroup, SIGNAL( buttonClicked( QAbstractButton * ) ), - this, SLOT( toggleButton( QAbstractButton * ) ) ); -} - - - - -SideBar::~SideBar() -{ + connect( &m_btnGroup, SIGNAL(buttonClicked(QAbstractButton*)), + this, SLOT(toggleButton(QAbstractButton*))); } @@ -107,7 +103,7 @@ SideBar::~SideBar() void SideBar::appendTab( SideBarWidget *widget ) { - SideBarButton *button = new SideBarButton( orientation(), this ); + auto button = new SideBarButton(orientation(), this); button->setText( " " + widget->title() ); button->setIcon( widget->icon() ); button->setLayoutDirection( Qt::RightToLeft ); @@ -164,5 +160,4 @@ void SideBar::toggleButton( QAbstractButton * button ) } - - +} // namespace lmms::gui diff --git a/src/gui/SideBarWidget.cpp b/src/gui/SideBarWidget.cpp index ab827f8d1..cf0233af1 100644 --- a/src/gui/SideBarWidget.cpp +++ b/src/gui/SideBarWidget.cpp @@ -30,6 +30,9 @@ #include "embed.h" +namespace lmms::gui +{ + SideBarWidget::SideBarWidget( const QString & _title, const QPixmap & _icon, QWidget * _parent ) : @@ -52,13 +55,6 @@ SideBarWidget::SideBarWidget( const QString & _title, const QPixmap & _icon, -SideBarWidget::~SideBarWidget() -{ -} - - - - void SideBarWidget::paintEvent( QPaintEvent * ) { QPainter p( this ); @@ -92,6 +88,4 @@ void SideBarWidget::resizeEvent( QResizeEvent * ) } - - - +} // namespace lmms::gui diff --git a/src/gui/StringPairDrag.cpp b/src/gui/StringPairDrag.cpp index 6aa5da170..54f52c784 100644 --- a/src/gui/StringPairDrag.cpp +++ b/src/gui/StringPairDrag.cpp @@ -35,6 +35,10 @@ #include "Clipboard.h" +namespace lmms::gui +{ + + StringPairDrag::StringPairDrag( const QString & _key, const QString & _value, const QPixmap & _icon, QWidget * _w ) : QDrag( _w ) @@ -54,7 +58,7 @@ StringPairDrag::StringPairDrag( const QString & _key, const QString & _value, setPixmap( _icon ); } QString txt = _key + ":" + _value; - QMimeData * m = new QMimeData(); + auto m = new QMimeData(); m->setData( mimeType( MimeType::StringPair ), txt.toUtf8() ); setMimeData( m ); exec( Qt::LinkAction, Qt::LinkAction ); @@ -111,3 +115,6 @@ QString StringPairDrag::decodeValue( QDropEvent * _de ) { return Clipboard::decodeValue( _de->mimeData() ); } + + +} // namespace lmms::gui \ No newline at end of file diff --git a/src/gui/SubWindow.cpp b/src/gui/SubWindow.cpp index df3fe0047..78e4f586c 100644 --- a/src/gui/SubWindow.cpp +++ b/src/gui/SubWindow.cpp @@ -37,6 +37,8 @@ #include "embed.h" +namespace lmms::gui +{ SubWindow::SubWindow( QWidget *parent, Qt::WindowFlags windowFlags ) : @@ -61,7 +63,7 @@ SubWindow::SubWindow( QWidget *parent, Qt::WindowFlags windowFlags ) : m_closeBtn->setCursor( Qt::ArrowCursor ); m_closeBtn->setAttribute( Qt::WA_NoMousePropagation ); m_closeBtn->setToolTip( tr( "Close" ) ); - connect( m_closeBtn, SIGNAL( clicked( bool ) ), this, SLOT( close() ) ); + connect( m_closeBtn, SIGNAL(clicked(bool)), this, SLOT(close())); m_maximizeBtn = new QPushButton( embed::getIconPixmap( "maximize" ), QString(), this ); m_maximizeBtn->resize( m_buttonSize ); @@ -69,7 +71,7 @@ SubWindow::SubWindow( QWidget *parent, Qt::WindowFlags windowFlags ) : m_maximizeBtn->setCursor( Qt::ArrowCursor ); m_maximizeBtn->setAttribute( Qt::WA_NoMousePropagation ); m_maximizeBtn->setToolTip( tr( "Maximize" ) ); - connect( m_maximizeBtn, SIGNAL( clicked( bool ) ), this, SLOT( showMaximized() ) ); + connect( m_maximizeBtn, SIGNAL(clicked(bool)), this, SLOT(showMaximized())); m_restoreBtn = new QPushButton( embed::getIconPixmap( "restore" ), QString(), this ); m_restoreBtn->resize( m_buttonSize ); @@ -77,7 +79,7 @@ SubWindow::SubWindow( QWidget *parent, Qt::WindowFlags windowFlags ) : m_restoreBtn->setCursor( Qt::ArrowCursor ); m_restoreBtn->setAttribute( Qt::WA_NoMousePropagation ); m_restoreBtn->setToolTip( tr( "Restore" ) ); - connect( m_restoreBtn, SIGNAL( clicked( bool ) ), this, SLOT( showNormal() ) ); + connect( m_restoreBtn, SIGNAL(clicked(bool)), this, SLOT(showNormal())); // QLabel for the window title and the shadow effect m_shadow = new QGraphicsDropShadowEffect(); @@ -94,7 +96,7 @@ SubWindow::SubWindow( QWidget *parent, Qt::WindowFlags windowFlags ) : setWindowFlags( Qt::SubWindow | Qt::WindowMaximizeButtonHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint | Qt::CustomizeWindowHint ); - connect( mdiArea(), SIGNAL( subWindowActivated( QMdiSubWindow* ) ), this, SLOT( focusChanged( QMdiSubWindow* ) ) ); + connect( mdiArea(), SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(focusChanged(QMdiSubWindow*))); } @@ -378,3 +380,6 @@ void SubWindow::resizeEvent( QResizeEvent * event ) m_trackedNormalGeom.setSize( event->size() ); } } + + +} // namespace lmms::gui \ No newline at end of file diff --git a/src/gui/ToolPluginView.cpp b/src/gui/ToolPluginView.cpp index a85a7ff6d..de553519c 100644 --- a/src/gui/ToolPluginView.cpp +++ b/src/gui/ToolPluginView.cpp @@ -32,6 +32,9 @@ #include "GuiApplication.h" #include "MainWindow.h" +namespace lmms::gui +{ + ToolPluginView::ToolPluginView( ToolPlugin * _toolPlugin ) : PluginView( _toolPlugin, nullptr ) @@ -44,3 +47,4 @@ ToolPluginView::ToolPluginView( ToolPlugin * _toolPlugin ) : } +} // namespace lmms::gui diff --git a/src/gui/clips/AutomationClipView.cpp b/src/gui/clips/AutomationClipView.cpp index f11885893..6fa91efdb 100644 --- a/src/gui/clips/AutomationClipView.cpp +++ b/src/gui/clips/AutomationClipView.cpp @@ -41,6 +41,9 @@ #include "Engine.h" +namespace lmms::gui +{ + QPixmap * AutomationClipView::s_clip_rec = nullptr; AutomationClipView::AutomationClipView( AutomationClip * _clip, @@ -49,10 +52,10 @@ AutomationClipView::AutomationClipView( AutomationClip * _clip, m_clip( _clip ), m_paintPixmap() { - connect( m_clip, SIGNAL( dataChanged() ), - this, SLOT( update() ) ); - connect( getGUI()->automationEditor(), SIGNAL( currentClipChanged() ), - this, SLOT( update() ) ); + connect( m_clip, SIGNAL(dataChanged()), + this, SLOT(update())); + connect( getGUI()->automationEditor(), SIGNAL(currentClipChanged()), + this, SLOT(update())); setAttribute( Qt::WA_OpaquePaintEvent, true ); @@ -68,13 +71,6 @@ AutomationClipView::AutomationClipView( AutomationClip * _clip, -AutomationClipView::~AutomationClipView() -{ -} - - - - void AutomationClipView::openInAutomationEditor() { if(getGUI() != nullptr) @@ -170,8 +166,7 @@ void AutomationClipView::flipX() void AutomationClipView::constructContextMenu( QMenu * _cm ) { - QAction * a = new QAction( embed::getIconPixmap( "automation" ), - tr( "Open in Automation editor" ), _cm ); + auto a = new QAction(embed::getIconPixmap("automation"), tr("Open in Automation editor"), _cm); _cm->insertAction( _cm->actions()[0], a ); connect(a, SIGNAL(triggered()), this, SLOT(openInAutomationEditor())); _cm->insertSeparator( _cm->actions()[1] ); @@ -179,42 +174,38 @@ void AutomationClipView::constructContextMenu( QMenu * _cm ) _cm->addSeparator(); _cm->addAction( embed::getIconPixmap( "edit_erase" ), - tr( "Clear" ), m_clip, SLOT( clear() ) ); + tr( "Clear" ), m_clip, SLOT(clear())); _cm->addSeparator(); _cm->addAction( embed::getIconPixmap( "reload" ), tr( "Reset name" ), - this, SLOT( resetName() ) ); + this, SLOT(resetName())); _cm->addAction( embed::getIconPixmap( "edit_rename" ), tr( "Change name" ), - this, SLOT( changeName() ) ); + this, SLOT(changeName())); _cm->addAction( embed::getIconPixmap( "record" ), tr( "Set/clear record" ), - this, SLOT( toggleRecording() ) ); + this, SLOT(toggleRecording())); _cm->addAction( embed::getIconPixmap( "flip_y" ), tr( "Flip Vertically (Visible)" ), - this, SLOT( flipY() ) ); + this, SLOT(flipY())); _cm->addAction( embed::getIconPixmap( "flip_x" ), tr( "Flip Horizontally (Visible)" ), - this, SLOT( flipX() ) ); + this, SLOT(flipX())); if( !m_clip->m_objects.isEmpty() ) { _cm->addSeparator(); - QMenu * m = new QMenu( tr( "%1 Connections" ). - arg( m_clip->m_objects.count() ), _cm ); - for( AutomationClip::objectVector::iterator it = - m_clip->m_objects.begin(); - it != m_clip->m_objects.end(); ++it ) + auto m = new QMenu(tr("%1 Connections").arg(m_clip->m_objects.count()), _cm); + for (const auto& object : m_clip->m_objects) { - if( *it ) + if (object) { - a = new QAction( tr( "Disconnect \"%1\"" ). - arg( ( *it )->fullDisplayName() ), m ); - a->setData( ( *it )->id() ); + a = new QAction(tr("Disconnect \"%1\"").arg(object->fullDisplayName()), m); + a->setData(object->id()); m->addAction( a ); } } - connect( m, SIGNAL( triggered( QAction * ) ), - this, SLOT( disconnectObject( QAction * ) ) ); + connect( m, SIGNAL(triggered(QAction*)), + this, SLOT(disconnectObject(QAction*))); _cm->addMenu( m ); } } @@ -280,8 +271,8 @@ void AutomationClipView::paintEvent( QPaintEvent * ) / (float) m_clip->timeMapLength().getBar() : pixelsPerBar(); - const float min = m_clip->firstObject()->minValue(); - const float max = m_clip->firstObject()->maxValue(); + const auto min = m_clip->firstObject()->minValue(); + const auto max = m_clip->firstObject()->maxValue(); const float y_scale = max - min; const float h = ( height() - 2 * BORDER_WIDTH ) / y_scale; @@ -307,7 +298,7 @@ void AutomationClipView::paintEvent( QPaintEvent * ) if( it+1 == m_clip->getTimeMap().end() ) { const float x1 = POS(it) * ppTick; - const float x2 = (float)( width() - BORDER_WIDTH ); + const auto x2 = (float)(width() - BORDER_WIDTH); if( x1 > ( width() - BORDER_WIDTH ) ) break; // We are drawing the space after the last node, so we use the outValue if( gradient() ) @@ -438,9 +429,7 @@ void AutomationClipView::dropEvent( QDropEvent * _de ) QString val = StringPairDrag::decodeValue( _de ); if( type == "automatable_model" ) { - AutomatableModel * mod = dynamic_cast( - Engine::projectJournal()-> - journallingObject( val.toInt() ) ); + auto mod = dynamic_cast(Engine::projectJournal()->journallingObject(val.toInt())); if( mod != nullptr ) { bool added = m_clip->addObject( mod ); @@ -508,3 +497,6 @@ void AutomationClipView::scaleTimemapToFit( float oldMin, float oldMax ) m_clip->generateTangents(); } + + +} // namespace lmms::gui diff --git a/src/gui/clips/ClipView.cpp b/src/gui/clips/ClipView.cpp index 1e154f155..e2da11439 100644 --- a/src/gui/clips/ClipView.cpp +++ b/src/gui/clips/ClipView.cpp @@ -52,6 +52,9 @@ #include "TrackContainerView.h" #include "TrackView.h" +namespace lmms::gui +{ + /*! The width of the resize grip in pixels */ @@ -118,12 +121,12 @@ ClipView::ClipView( Clip * clip, setAcceptDrops( true ); setMouseTracking( true ); - connect( m_clip, SIGNAL( lengthChanged() ), - this, SLOT( updateLength() ) ); - connect( getGUI()->songEditor()->m_editor->zoomingModel(), SIGNAL( dataChanged() ), this, SLOT( updateLength() ) ); - connect( m_clip, SIGNAL( positionChanged() ), - this, SLOT( updatePosition() ) ); - connect( m_clip, SIGNAL( destroyedClip() ), this, SLOT( close() ) ); + connect( m_clip, SIGNAL(lengthChanged()), + this, SLOT(updateLength())); + connect( getGUI()->songEditor()->m_editor->zoomingModel(), SIGNAL(dataChanged()), this, SLOT(updateLength())); + connect( m_clip, SIGNAL(positionChanged()), + this, SLOT(updatePosition())); + connect( m_clip, SIGNAL(destroyedClip()), this, SLOT(close())); setModel( m_clip ); connect(m_clip, SIGNAL(colorChanged()), this, SLOT(update())); @@ -422,7 +425,7 @@ void ClipView::setColor(const QColor* color) void ClipView::dragEnterEvent( QDragEnterEvent * dee ) { TrackContentWidget * tcw = getTrackView()->getTrackContentWidget(); - TimePos clipPos = TimePos( m_clip->startPosition() ); + TimePos clipPos{m_clip->startPosition()}; if( tcw->canPasteSelection( clipPos, dee ) == false ) { @@ -462,7 +465,7 @@ void ClipView::dropEvent( QDropEvent * de ) if( m_trackView->trackContainerView()->allowRubberband() == true ) { TrackContentWidget * tcw = getTrackView()->getTrackContentWidget(); - TimePos clipPos = TimePos( m_clip->startPosition() ); + TimePos clipPos{m_clip->startPosition()}; if( tcw->pasteSelection( clipPos, de ) == true ) { @@ -498,16 +501,16 @@ void ClipView::dropEvent( QDropEvent * de ) */ void ClipView::updateCursor(QMouseEvent * me) { - SampleClip * sClip = dynamic_cast(m_clip); + auto sClip = dynamic_cast(m_clip); // If we are at the edges, use the resize cursor - if ((me->x() > width() - RESIZE_GRIP_WIDTH && !me->buttons() && !m_clip->getAutoResize()) - || (me->x() < RESIZE_GRIP_WIDTH && !me->buttons() && sClip && !m_clip->getAutoResize())) + if (!me->buttons() && !m_clip->getAutoResize() && !isSelected() + && ((me->x() > width() - RESIZE_GRIP_WIDTH) || (me->x() < RESIZE_GRIP_WIDTH && sClip))) { setCursor(Qt::SizeHorCursor); } // If we are in the middle on knife mode, use the knife cursor - else if (sClip && m_trackView->trackContainerView()->knifeMode()) + else if (sClip && m_trackView->trackContainerView()->knifeMode() && !isSelected()) { setCursor(m_cursorKnife); } @@ -535,18 +538,16 @@ DataFile ClipView::createClipDataFiles( DataFile dataFile( DataFile::DragNDropData ); QDomElement clipParent = dataFile.createElement("clips"); - typedef QVector clipViewVector; - for( clipViewVector::const_iterator it = clipViews.begin(); - it != clipViews.end(); ++it ) + for (const auto& clipView : clipViews) { // Insert into the dom under the "clips" element - Track* clipTrack = ( *it )->m_trackView->getTrack(); + Track* clipTrack = clipView->m_trackView->getTrack(); int trackIndex = tc->tracks().indexOf( clipTrack ); QDomElement clipElement = dataFile.createElement("clip"); clipElement.setAttribute( "trackIndex", trackIndex ); clipElement.setAttribute( "trackType", clipTrack->type() ); clipElement.setAttribute( "trackName", clipTrack->name() ); - ( *it )->m_clip->saveState( dataFile, clipElement ); + clipView->m_clip->saveState(dataFile, clipElement); clipParent.appendChild( clipElement ); } @@ -631,7 +632,7 @@ void ClipView::mousePressEvent( QMouseEvent * me ) setInitialOffsets(); if( !fixedClips() && me->button() == Qt::LeftButton ) { - SampleClip * sClip = dynamic_cast( m_clip ); + auto sClip = dynamic_cast(m_clip); const bool knifeMode = m_trackView->trackContainerView()->knifeMode(); if ( me->modifiers() & Qt::ControlModifier && !(sClip && knifeMode) ) @@ -744,7 +745,7 @@ void ClipView::mousePressEvent( QMouseEvent * me ) if (m_action == Split) { m_action = NoAction; - SampleClip * sClip = dynamic_cast( m_clip ); + auto sClip = dynamic_cast(m_clip); if (sClip) { setMarkerEnabled( false ); @@ -752,7 +753,7 @@ void ClipView::mousePressEvent( QMouseEvent * me ) } } } - else if( me->button() == Qt::MidButton ) + else if( me->button() == Qt::MiddleButton ) { if( me->modifiers() & Qt::ControlModifier ) { @@ -793,10 +794,9 @@ void ClipView::mouseMoveEvent( QMouseEvent * me ) // Collect all selected Clips QVector so = m_trackView->trackContainerView()->selectedObjects(); - for( auto it = so.begin(); it != so.end(); ++it ) + for (const auto& selectedClip : so) { - ClipView * clipv = - dynamic_cast( *it ); + auto clipv = dynamic_cast(selectedClip); if( clipv != nullptr ) { clipViews.push_back( clipv ); @@ -860,8 +860,7 @@ void ClipView::mouseMoveEvent( QMouseEvent * me ) for( QVector::iterator it = so.begin(); it != so.end(); ++it ) { - ClipView* clipv = - dynamic_cast( *it ); + auto clipv = dynamic_cast(*it); if( clipv == nullptr ) { continue; } clips.push_back( clipv->m_clip ); int index = std::distance( so.begin(), it ); @@ -909,14 +908,14 @@ void ClipView::mouseMoveEvent( QMouseEvent * me ) TimePos initialLength = m_initialClipEnd - m_initialClipPos; TimePos offset = TimePos( l - initialLength ).quantize( snapSize ); // Don't resize to less than 1 tick - TimePos min = TimePos( initialLength % snapLength ); + auto min = TimePos(initialLength % snapLength); if (min < 1) min += snapLength; m_clip->changeLength( qMax( min, initialLength + offset) ); } } else { - SampleClip * sClip = dynamic_cast( m_clip ); + auto sClip = dynamic_cast(m_clip); if( sClip ) { const int x = mapToParent( me->pos() ).x() - m_initialMousePos.x(); @@ -943,7 +942,7 @@ void ClipView::mouseMoveEvent( QMouseEvent * me ) { // Otherwise, resize in fixed increments // Don't resize to less than 1 tick TimePos initialLength = m_initialClipEnd - m_initialClipPos; - TimePos minLength = TimePos( initialLength % snapLength ); + auto minLength = TimePos(initialLength % snapLength); if (minLength < 1) minLength += snapLength; TimePos offset = TimePos(t - m_initialClipPos).quantize( snapSize ); t = qMin( m_initialClipEnd - minLength, m_initialClipPos + offset ); @@ -972,7 +971,7 @@ void ClipView::mouseMoveEvent( QMouseEvent * me ) } else if( m_action == Split ) { - SampleClip * sClip = dynamic_cast( m_clip ); + auto sClip = dynamic_cast(m_clip); if (sClip) { setCursor( m_cursorKnife ); setMarkerPos( knifeMarkerPos( me ) ); @@ -1154,7 +1153,7 @@ QVector ClipView::getClickedClips() selection.reserve( sos.size() ); for( auto so: sos ) { - ClipView *clipv = dynamic_cast ( so ); + auto clipv = dynamic_cast(so); if( clipv != nullptr ) { selection.append( clipv ); @@ -1204,7 +1203,7 @@ void ClipView::paste() using namespace Clipboard; // If possible, paste the selection on the TimePos of the selected Track and remove it - TimePos clipPos = TimePos( m_clip->startPosition() ); + TimePos clipPos{m_clip->startPosition()}; TrackContentWidget *tcw = getTrackView()->getTrackContentWidget(); @@ -1243,8 +1242,7 @@ bool ClipView::canMergeSelection(QVector clipvs) void ClipView::mergeClips(QVector clipvs) { // Get the track that we are merging Clips in - InstrumentTrack* track = - dynamic_cast(clipvs.at(0)->getTrackView()->getTrack()); + auto track = dynamic_cast(clipvs.at(0)->getTrackView()->getTrack()); if (!track) { @@ -1268,7 +1266,7 @@ void ClipView::mergeClips(QVector clipvs) const TimePos earliestPos = (*earliestClipV)->getClip()->startPosition(); // Create a clip where all notes will be added - MidiClip* newMidiClip = dynamic_cast(track->createClip(earliestPos)); + auto newMidiClip = dynamic_cast(track->createClip(earliestPos)); if (!newMidiClip) { qWarning("Warning: Failed to convert Clip to MidiClip on mergeClips"); @@ -1281,7 +1279,7 @@ void ClipView::mergeClips(QVector clipvs) for (auto clipv: clipvs) { // Convert ClipV to MidiClipView - MidiClipView* mcView = dynamic_cast(clipv); + auto mcView = dynamic_cast(clipv); if (!mcView) { @@ -1336,11 +1334,9 @@ void ClipView::setInitialOffsets() { QVector so = m_trackView->trackContainerView()->selectedObjects(); QVector offsets; - for( QVector::iterator it = so.begin(); - it != so.end(); ++it ) + for (const auto& selectedClip : so) { - ClipView * clipv = - dynamic_cast( *it ); + auto clipv = dynamic_cast(selectedClip); if( clipv == nullptr ) { continue; @@ -1502,3 +1498,6 @@ QColor ClipView::getColorForDisplay( QColor defaultColor ) // Return color to caller return c; } + + +} // namespace lmms::gui diff --git a/src/gui/clips/MidiClipView.cpp b/src/gui/clips/MidiClipView.cpp index 987d1fe14..e3ef9fd20 100644 --- a/src/gui/clips/MidiClipView.cpp +++ b/src/gui/clips/MidiClipView.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -36,6 +37,11 @@ #include "MidiClip.h" #include "PianoRoll.h" #include "RenameDialog.h" +#include "TrackView.h" + +namespace lmms::gui +{ + MidiClipView::MidiClipView( MidiClip* clip, TrackView* parent ) : ClipView( clip, parent ), @@ -48,8 +54,8 @@ MidiClipView::MidiClipView( MidiClip* clip, TrackView* parent ) : // TODO if this option is ever added to the GUI, rename it to legacysepattern m_legacySEPattern(ConfigManager::inst()->value("ui", "legacysebb", "0").toInt()) { - connect( getGUI()->pianoRoll(), SIGNAL( currentMidiClipChanged() ), - this, SLOT( update() ) ); + connect( getGUI()->pianoRoll(), SIGNAL(currentMidiClipChanged()), + this, SLOT(update())); if( s_stepBtnOn0 == nullptr ) { @@ -140,43 +146,103 @@ void MidiClipView::changeName() +void MidiClipView::transposeSelection() +{ + const auto selection = getClickedClips(); + + // Calculate the key boundries for all clips + int highest = 0; + int lowest = NumKeys - 1; + for (ClipView* clipview: selection) + { + if (auto mcv = qobject_cast(clipview)) + { + if (auto bounds = boundsForNotes(mcv->getMidiClip()->notes())) + { + lowest = std::min(bounds->lowest, lowest); + highest = std::max(bounds->highest, highest); + } + } + } + + int semitones = QInputDialog::getInt(this, tr("Transpose"), tr("Semitones to transpose by:"), + /*start*/ 0, /*min*/ -lowest, /*max*/ (NumKeys - 1 - highest)); + + if (semitones == 0) { return; } + + // TODO make this not crash + // Engine::getSong()->addJournalCheckPoint(); + + QSet m_changedTracks; + for (ClipView* clipview: selection) + { + auto mcv = qobject_cast(clipview); + if (!mcv) { continue; } + + auto clip = mcv->getMidiClip(); + if (clip->notes().empty()) { continue; } + + auto track = clipview->getTrackView()->getTrack(); + if (!m_changedTracks.contains(track)) + { + track->addJournalCheckPoint(); + m_changedTracks.insert(track); + } + + for (Note* note: clip->notes()) + { + note->setKey(note->key() + semitones); + } + emit clip->dataChanged(); + } + // At least one clip must have notes to show the transpose dialog, so something *has* changed + Engine::getSong()->setModified(); +} + + + + void MidiClipView::constructContextMenu( QMenu * _cm ) { - QAction * a = new QAction( embed::getIconPixmap( "piano" ), - tr( "Open in piano-roll" ), _cm ); - _cm->insertAction( _cm->actions()[0], a ); - connect( a, SIGNAL( triggered( bool ) ), - this, SLOT( openInPianoRoll() ) ); + bool isBeat = m_clip->type() == MidiClip::BeatClip; - QAction * b = new QAction( embed::getIconPixmap( "ghost_note" ), - tr( "Set as ghost in piano-roll" ), _cm ); + auto a = new QAction(embed::getIconPixmap("piano"), tr("Open in piano-roll"), _cm); + _cm->insertAction( _cm->actions()[0], a ); + connect( a, SIGNAL(triggered(bool)), + this, SLOT(openInPianoRoll())); + + auto b = new QAction(embed::getIconPixmap("ghost_note"), tr("Set as ghost in piano-roll"), _cm); if( m_clip->empty() ) { b->setEnabled( false ); } _cm->insertAction( _cm->actions()[1], b ); - connect( b, SIGNAL( triggered( bool ) ), - this, SLOT( setGhostInPianoRoll() ) ); + connect( b, SIGNAL(triggered(bool)), + this, SLOT(setGhostInPianoRoll())); _cm->insertSeparator( _cm->actions()[2] ); _cm->addSeparator(); _cm->addAction( embed::getIconPixmap( "edit_erase" ), - tr( "Clear all notes" ), m_clip, SLOT( clear() ) ); + tr( "Clear all notes" ), m_clip, SLOT(clear())); + if (!isBeat) + { + _cm->addAction(embed::getIconPixmap("scale"), tr("Transpose"), this, &MidiClipView::transposeSelection); + } _cm->addSeparator(); _cm->addAction( embed::getIconPixmap( "reload" ), tr( "Reset name" ), - this, SLOT( resetName() ) ); + this, SLOT(resetName())); _cm->addAction( embed::getIconPixmap( "edit_rename" ), tr( "Change name" ), - this, SLOT( changeName() ) ); + this, SLOT(changeName())); - if ( m_clip->type() == MidiClip::BeatClip ) + if (isBeat) { _cm->addSeparator(); _cm->addAction( embed::getIconPixmap( "step_btn_add" ), - tr( "Add steps" ), m_clip, SLOT( addSteps() ) ); + tr( "Add steps" ), m_clip, SLOT(addSteps())); _cm->addAction( embed::getIconPixmap( "step_btn_remove" ), - tr( "Remove steps" ), m_clip, SLOT( removeSteps() ) ); + tr( "Remove steps" ), m_clip, SLOT(removeSteps())); _cm->addAction( embed::getIconPixmap( "step_btn_duplicate" ), - tr( "Clone Steps" ), m_clip, SLOT( cloneSteps() ) ); + tr( "Clone Steps" ), m_clip, SLOT(cloneSteps())); } } @@ -616,3 +682,6 @@ void MidiClipView::paintEvent( QPaintEvent * ) painter.drawPixmap( 0, 0, m_paintPixmap ); } + + +} // namespace lmms::gui diff --git a/src/gui/clips/PatternClipView.cpp b/src/gui/clips/PatternClipView.cpp index f865f778b..477a90052 100644 --- a/src/gui/clips/PatternClipView.cpp +++ b/src/gui/clips/PatternClipView.cpp @@ -35,32 +35,34 @@ #include "PatternStore.h" #include "RenameDialog.h" +namespace lmms::gui +{ + + PatternClipView::PatternClipView(Clip* _clip, TrackView* _tv) : ClipView( _clip, _tv ), m_patternClip(dynamic_cast(_clip)), m_paintPixmap() { - connect( _clip->getTrack(), SIGNAL( dataChanged() ), - this, SLOT( update() ) ); + connect( _clip->getTrack(), SIGNAL(dataChanged()), + this, SLOT(update())); setStyle( QApplication::style() ); } void PatternClipView::constructContextMenu(QMenu* _cm) { - QAction* a = new QAction(embed::getIconPixmap("pattern_track"), - tr("Open in Pattern Editor"), - _cm ); + auto a = new QAction(embed::getIconPixmap("pattern_track"), tr("Open in Pattern Editor"), _cm); _cm->insertAction( _cm->actions()[0], a ); - connect( a, SIGNAL( triggered( bool ) ), - this, SLOT( openInPatternEditor() ) ); + connect( a, SIGNAL(triggered(bool)), + this, SLOT(openInPatternEditor())); _cm->insertSeparator( _cm->actions()[1] ); _cm->addSeparator(); _cm->addAction( embed::getIconPixmap( "reload" ), tr( "Reset name" ), - this, SLOT( resetName() ) ); + this, SLOT(resetName())); _cm->addAction( embed::getIconPixmap( "edit_rename" ), tr( "Change name" ), - this, SLOT( changeName() ) ); + this, SLOT(changeName())); } @@ -188,3 +190,6 @@ void PatternClipView::update() ClipView::update(); } + + +} // namespace lmms::gui diff --git a/src/gui/clips/SampleClipView.cpp b/src/gui/clips/SampleClipView.cpp index 80b0e6ef2..e21a7e30b 100644 --- a/src/gui/clips/SampleClipView.cpp +++ b/src/gui/clips/SampleClipView.cpp @@ -35,6 +35,10 @@ #include "Song.h" #include "StringPairDrag.h" +namespace lmms::gui +{ + + SampleClipView::SampleClipView( SampleClip * _clip, TrackView * _tv ) : ClipView( _clip, _tv ), m_clip( _clip ), @@ -70,7 +74,7 @@ void SampleClipView::constructContextMenu(QMenu* cm) /*contextMenu.addAction( embed::getIconPixmap( "record" ), tr( "Set/clear record" ), - m_clip, SLOT( toggleRecord() ) );*/ + m_clip, SLOT(toggleRecord()));*/ cm->addAction( embed::getIconPixmap("flip_x"), @@ -136,7 +140,7 @@ void SampleClipView::mousePressEvent( QMouseEvent * _me ) { if( _me->button() == Qt::MiddleButton && _me->modifiers() == Qt::ControlModifier ) { - SampleClip * sClip = dynamic_cast( getClip() ); + auto sClip = dynamic_cast(getClip()); if( sClip ) { sClip->updateTrackClips(); @@ -153,7 +157,7 @@ void SampleClipView::mouseReleaseEvent(QMouseEvent *_me) { if( _me->button() == Qt::MiddleButton && !_me->modifiers() ) { - SampleClip * sClip = dynamic_cast( getClip() ); + auto sClip = dynamic_cast(getClip()); if( sClip ) { sClip->playbackPositionChanged(); @@ -338,7 +342,7 @@ bool SampleClipView::splitClip( const TimePos pos ) m_clip->getTrack()->addJournalCheckPoint(); m_clip->getTrack()->saveJournallingState( false ); - SampleClip * rightClip = new SampleClip ( *m_clip ); + auto rightClip = new SampleClip(*m_clip); m_clip->changeLength( splitPos - m_initialClipPos ); @@ -351,3 +355,6 @@ bool SampleClipView::splitClip( const TimePos pos ) } else { return false; } } + + +} // namespace lmms::gui diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index 998af4be8..db56557a4 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -62,6 +62,9 @@ #include "TimeLineWidget.h" +namespace lmms::gui +{ + QPixmap * AutomationEditor::s_toolDraw = nullptr; QPixmap * AutomationEditor::s_toolErase = nullptr; QPixmap * AutomationEditor::s_toolDrawOut = nullptr; @@ -107,11 +110,11 @@ AutomationEditor::AutomationEditor() : m_crossColor(0, 0, 0), m_backgroundShade(0, 0, 0) { - connect( this, SIGNAL( currentClipChanged() ), - this, SLOT( updateAfterClipChange() ), + connect( this, SIGNAL(currentClipChanged()), + this, SLOT(updateAfterClipChange()), Qt::QueuedConnection ); - connect( Engine::getSong(), SIGNAL( timeSignatureChanged( int, int ) ), - this, SLOT( update() ) ); + connect( Engine::getSong(), SIGNAL(timeSignatureChanged(int,int)), + this, SLOT(update())); setAttribute( Qt::WA_OpaquePaintEvent, true ); @@ -119,15 +122,15 @@ AutomationEditor::AutomationEditor() : setLayoutDirection( Qt::LeftToRight ); m_tensionModel = new FloatModel(1.0, 0.0, 1.0, 0.01); - connect( m_tensionModel, SIGNAL( dataChanged() ), - this, SLOT( setTension() ) ); + connect( m_tensionModel, SIGNAL(dataChanged()), + this, SLOT(setTension())); for (auto q : Quantizations) { m_quantizeModel.addItem(QString("1/%1").arg(q)); } - connect( &m_quantizeModel, SIGNAL(dataChanged() ), - this, SLOT( setQuantization() ) ); + connect( &m_quantizeModel, SIGNAL(dataChanged()), + this, SLOT(setQuantization())); m_quantizeModel.setValue( m_quantizeModel.findText( "1/8" ) ); if (s_toolYFlip == nullptr) @@ -147,22 +150,22 @@ AutomationEditor::AutomationEditor() : Song::Mode_PlayAutomationClip ), m_currentPosition, Song::Mode_PlayAutomationClip, this ); - connect( this, SIGNAL( positionChanged( const TimePos & ) ), - m_timeLine, SLOT( updatePosition( const TimePos & ) ) ); - connect( m_timeLine, SIGNAL( positionChanged( const TimePos & ) ), - this, SLOT( updatePosition( const TimePos & ) ) ); + connect( this, SIGNAL( positionChanged( const lmms::TimePos& ) ), + m_timeLine, SLOT( updatePosition( const lmms::TimePos& ) ) ); + connect( m_timeLine, SIGNAL( positionChanged( const lmms::TimePos& ) ), + this, SLOT( updatePosition( const lmms::TimePos& ) ) ); // init scrollbars m_leftRightScroll = new QScrollBar( Qt::Horizontal, this ); m_leftRightScroll->setSingleStep( 1 ); - connect( m_leftRightScroll, SIGNAL( valueChanged( int ) ), this, - SLOT( horScrolled( int ) ) ); + connect( m_leftRightScroll, SIGNAL(valueChanged(int)), this, + SLOT(horScrolled(int))); m_topBottomScroll = new QScrollBar( Qt::Vertical, this ); m_topBottomScroll->setSingleStep( 1 ); m_topBottomScroll->setPageStep( 20 ); - connect( m_topBottomScroll, SIGNAL( valueChanged( int ) ), this, - SLOT( verScrolled( int ) ) ); + connect( m_topBottomScroll, SIGNAL(valueChanged(int)), this, + SLOT(verScrolled(int))); // init pixmaps if (s_toolDraw == nullptr) @@ -345,7 +348,7 @@ void AutomationEditor::drawLine( int x0In, float y0, int x1In, float y1 ) int x0 = Note::quantized( x0In, AutomationClip::quantization() ); int x1 = Note::quantized( x1In, AutomationClip::quantization() ); int deltax = qAbs( x1 - x0 ); - float deltay = qAbs( y1 - y0 ); + auto deltay = qAbs(y1 - y0); int x = x0; float y = y0; int xstep; @@ -959,15 +962,14 @@ void AutomationEditor::paintEvent(QPaintEvent * pe ) // print value numbers int font_height = p.fontMetrics().height(); - Qt::Alignment text_flags = - (Qt::Alignment)( Qt::AlignRight | Qt::AlignVCenter ); + auto text_flags = (Qt::Alignment)(Qt::AlignRight | Qt::AlignVCenter); if( validClip() ) { if( m_y_auto ) { - int y[] = { grid_bottom, TOP_MARGIN + font_height / 2 }; - float level[] = { m_minLevel, m_maxLevel }; + auto y = std::array{grid_bottom, TOP_MARGIN + font_height / 2}; + auto level = std::array{m_minLevel, m_maxLevel}; for( int i = 0; i < 2; ++i ) { const QString & label = m_clip->firstObject() @@ -1836,7 +1838,7 @@ AutomationEditorWindow::AutomationEditorWindow() : // Edit mode buttons DropToolBar *editActionsToolBar = addDropToolBarToTop(tr("Edit actions")); - ActionGroup* editModeGroup = new ActionGroup(this); + auto editModeGroup = new ActionGroup(this); QAction* drawAction = editModeGroup->addAction(embed::getIconPixmap("edit_draw"), tr("Draw mode (Shift+D)")); drawAction->setShortcut(Qt::SHIFT | Qt::Key_D); drawAction->setChecked(true); @@ -1861,7 +1863,7 @@ AutomationEditorWindow::AutomationEditorWindow() : // Interpolation actions DropToolBar *interpolationActionsToolBar = addDropToolBarToTop(tr("Interpolation controls")); - ActionGroup* progression_type_group = new ActionGroup(this); + auto progression_type_group = new ActionGroup(this); m_discreteAction = progression_type_group->addAction( embed::getIconPixmap("progression_discrete"), tr("Discrete progression")); @@ -1896,7 +1898,7 @@ AutomationEditorWindow::AutomationEditorWindow() : // Zoom controls DropToolBar *zoomToolBar = addDropToolBarToTop(tr("Zoom controls")); - QLabel * zoom_x_label = new QLabel( zoomToolBar ); + auto zoom_x_label = new QLabel(zoomToolBar); zoom_x_label->setPixmap( embed::getIconPixmap( "zoom_x" ) ); m_zoomingXComboBox = new ComboBox( zoomToolBar ); @@ -1911,11 +1913,10 @@ AutomationEditorWindow::AutomationEditorWindow() : m_zoomingXComboBox->setModel( &m_editor->m_zoomingXModel ); - connect( &m_editor->m_zoomingXModel, SIGNAL( dataChanged() ), - m_editor, SLOT( zoomingXChanged() ) ); + connect( &m_editor->m_zoomingXModel, SIGNAL(dataChanged()), + m_editor, SLOT(zoomingXChanged())); - - QLabel * zoom_y_label = new QLabel( zoomToolBar ); + auto zoom_y_label = new QLabel(zoomToolBar); zoom_y_label->setPixmap( embed::getIconPixmap( "zoom_y" ) ); m_zoomingYComboBox = new ComboBox( zoomToolBar ); @@ -1931,8 +1932,8 @@ AutomationEditorWindow::AutomationEditorWindow() : m_zoomingYComboBox->setModel( &m_editor->m_zoomingYModel ); - connect( &m_editor->m_zoomingYModel, SIGNAL( dataChanged() ), - m_editor, SLOT( zoomingYChanged() ) ); + connect( &m_editor->m_zoomingYModel, SIGNAL(dataChanged()), + m_editor, SLOT(zoomingYChanged())); zoomToolBar->addWidget( zoom_x_label ); zoomToolBar->addWidget( m_zoomingXComboBox ); @@ -1943,7 +1944,7 @@ AutomationEditorWindow::AutomationEditorWindow() : // Quantization controls DropToolBar *quantizationActionsToolBar = addDropToolBarToTop(tr("Quantization controls")); - QLabel * quantize_lbl = new QLabel( m_toolBar ); + auto quantize_lbl = new QLabel(m_toolBar); quantize_lbl->setPixmap( embed::getIconPixmap( "quantize" ) ); m_quantizeComboBox = new ComboBox( m_toolBar ); @@ -1964,11 +1965,6 @@ AutomationEditorWindow::AutomationEditorWindow() : } -AutomationEditorWindow::~AutomationEditorWindow() -{ -} - - void AutomationEditorWindow::setCurrentClip(AutomationClip* clip) { // Disconnect our old clip @@ -2011,7 +2007,7 @@ void AutomationEditorWindow::setCurrentClip(AutomationClip* clip) if (clip) { connect(clip, SIGNAL(dataChanged()), this, SLOT(update())); - connect( clip, SIGNAL( dataChanged() ), this, SLOT( updateWindowTitle() ) ); + connect( clip, SIGNAL(dataChanged()), this, SLOT(updateWindowTitle())); connect(clip, SIGNAL(destroyed()), this, SLOT(clearCurrentClip())); connect(m_flipXAction, SIGNAL(triggered()), clip, SLOT(flipX())); @@ -2033,9 +2029,7 @@ void AutomationEditorWindow::dropEvent( QDropEvent *_de ) QString val = StringPairDrag::decodeValue( _de ); if( type == "automatable_model" ) { - AutomatableModel * mod = dynamic_cast( - Engine::projectJournal()-> - journallingObject( val.toInt() ) ); + auto mod = dynamic_cast(Engine::projectJournal()->journallingObject(val.toInt())); if (mod != nullptr) { bool added = m_editor->m_clip->addObject( mod ); @@ -2107,3 +2101,6 @@ void AutomationEditorWindow::updateWindowTitle() setWindowTitle( tr( "Automation Editor - %1" ).arg( m_editor->m_clip->name() ) ); } + + +} // namespace lmms::gui diff --git a/src/gui/editors/Editor.cpp b/src/gui/editors/Editor.cpp index f9ab600bf..7091c094b 100644 --- a/src/gui/editors/Editor.cpp +++ b/src/gui/editors/Editor.cpp @@ -33,6 +33,10 @@ #include +namespace lmms::gui +{ + + void Editor::setPauseIcon(bool displayPauseIcon) { // If we're playing, show a pause icon @@ -54,7 +58,7 @@ DropToolBar * Editor::addDropToolBar(Qt::ToolBarArea whereToAdd, QString const & DropToolBar * Editor::addDropToolBar(QWidget * parent, Qt::ToolBarArea whereToAdd, QString const & windowTitle) { - DropToolBar *toolBar = new DropToolBar(parent); + auto toolBar = new DropToolBar(parent); addToolBar(whereToAdd, toolBar); toolBar->setMovable(false); toolBar->setFloatable(false); @@ -129,11 +133,6 @@ Editor::Editor(bool record, bool stepRecord) : addButton(m_stopAction, "stopButton"); } -Editor::~Editor() -{ - -} - QAction *Editor::playAction() const { return m_playAction; @@ -169,3 +168,4 @@ void DropToolBar::dropEvent(QDropEvent* event) +} // namespace lmms::gui diff --git a/src/gui/editors/PatternEditor.cpp b/src/gui/editors/PatternEditor.cpp index 818c454f6..b2d2f5c3f 100644 --- a/src/gui/editors/PatternEditor.cpp +++ b/src/gui/editors/PatternEditor.cpp @@ -40,6 +40,8 @@ #include "MidiClip.h" +namespace lmms::gui +{ PatternEditor::PatternEditor(PatternStore* ps) : @@ -69,12 +71,11 @@ void PatternEditor::removeSteps() { TrackContainer::TrackList tl = model()->tracks(); - for( TrackContainer::TrackList::iterator it = tl.begin(); - it != tl.end(); ++it ) + for (const auto& track : tl) { - if( ( *it )->type() == Track::InstrumentTrack ) + if (track->type() == Track::InstrumentTrack) { - MidiClip* p = static_cast((*it)->getClip(m_ps->currentPattern())); + auto p = static_cast(track->getClip(m_ps->currentPattern())); p->removeSteps(); } } @@ -177,12 +178,11 @@ void PatternEditor::makeSteps( bool clone ) { TrackContainer::TrackList tl = model()->tracks(); - for( TrackContainer::TrackList::iterator it = tl.begin(); - it != tl.end(); ++it ) + for (const auto& track : tl) { - if( ( *it )->type() == Track::InstrumentTrack ) + if (track->type() == Track::InstrumentTrack) { - MidiClip* p = static_cast((*it)->getClip(m_ps->currentPattern())); + auto p = static_cast(track->getClip(m_ps->currentPattern())); if( clone ) { p->cloneSteps(); @@ -199,7 +199,7 @@ void PatternEditor::makeSteps( bool clone ) void PatternEditor::cloneClip() { // Get the current PatternTrack id - PatternStore* ps = static_cast(model()); + auto ps = static_cast(model()); const int currentPattern = ps->currentPattern(); PatternTrack* pt = PatternTrack::findPatternTrack(currentPattern); @@ -270,7 +270,7 @@ PatternEditorWindow::PatternEditorWindow(PatternStore* ps) : trackAndStepActionsToolBar->addAction(embed::getIconPixmap("add_automation"), tr("Add automation-track"), m_editor, SLOT(addAutomationTrack())); - QWidget* stretch = new QWidget(m_toolBar); + auto stretch = new QWidget(m_toolBar); stretch->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); trackAndStepActionsToolBar->addWidget(stretch); @@ -286,24 +286,18 @@ PatternEditorWindow::PatternEditorWindow(PatternStore* ps) : connect(&ps->m_patternComboBoxModel, SIGNAL(dataChanged()), m_editor, SLOT(updatePosition())); - - QAction* viewNext = new QAction(this); + auto viewNext = new QAction(this); connect(viewNext, SIGNAL(triggered()), m_patternComboBox, SLOT(selectNext())); viewNext->setShortcut(Qt::Key_Plus); addAction(viewNext); - QAction* viewPrevious = new QAction(this); + auto viewPrevious = new QAction(this); connect(viewPrevious, SIGNAL(triggered()), m_patternComboBox, SLOT(selectPrevious())); viewPrevious->setShortcut(Qt::Key_Minus); addAction(viewPrevious); } -PatternEditorWindow::~PatternEditorWindow() -{ -} - - QSize PatternEditorWindow::sizeHint() const { return {minimumWidth() + 10, 300}; @@ -327,3 +321,6 @@ void PatternEditorWindow::stop() { Engine::getSong()->stop(); } + + +} // namespace lmms::gui \ No newline at end of file diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index bafede415..5f294d6e8 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -73,10 +73,15 @@ #include "FileDialog.h" -using std::move; +namespace lmms +{ -typedef AutomationClip::timeMap timeMap; +using timeMap = AutomationClip::timeMap; + + +namespace gui +{ // some constants... const int INITIAL_PIANOROLL_WIDTH = 970; @@ -124,7 +129,7 @@ QPixmap* PianoRoll::s_toolKnife = nullptr; TextFloat * PianoRoll::s_textFloat = nullptr; -static QString s_noteStrings[12] = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"}; +static std::array s_noteStrings {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"}; static QString getNoteString(int key) { @@ -132,7 +137,7 @@ static QString getNoteString(int key) } // used for drawing of piano -PianoRoll::PianoRollKeyTypes PianoRoll::prKeyOrder[] = +std::array PianoRoll::prKeyOrder { PR_WHITE_KEY_SMALL, PR_BLACK_KEY, PR_WHITE_KEY_BIG, PR_BLACK_KEY, PR_WHITE_KEY_SMALL, PR_WHITE_KEY_SMALL, PR_BLACK_KEY, PR_WHITE_KEY_BIG, @@ -222,19 +227,19 @@ PianoRoll::PianoRoll() : m_noteEditMenu->clear(); for( int i = 0; i < m_nemStr.size(); ++i ) { - QAction * act = new QAction( m_nemStr.at(i), this ); + auto act = new QAction(m_nemStr.at(i), this); connect( act, &QAction::triggered, [this, i](){ changeNoteEditMode(i); } ); m_noteEditMenu->addAction( act ); } m_semiToneMarkerMenu = new QMenu( this ); - QAction* markSemitoneAction = new QAction( tr("Mark/unmark current semitone"), this ); - QAction* markAllOctaveSemitonesAction = new QAction( tr("Mark/unmark all corresponding octave semitones"), this ); - QAction* markScaleAction = new QAction( tr("Mark current scale"), this ); - QAction* markChordAction = new QAction( tr("Mark current chord"), this ); - QAction* unmarkAllAction = new QAction( tr("Unmark all"), this ); - QAction* copyAllNotesAction = new QAction( tr("Select all notes on this key"), this); + auto markSemitoneAction = new QAction(tr("Mark/unmark current semitone"), this); + auto markAllOctaveSemitonesAction = new QAction(tr("Mark/unmark all corresponding octave semitones"), this); + auto markScaleAction = new QAction(tr("Mark current scale"), this); + auto markChordAction = new QAction(tr("Mark current chord"), this); + auto unmarkAllAction = new QAction(tr("Unmark all"), this); + auto copyAllNotesAction = new QAction(tr("Select all notes on this key"), this); connect( markSemitoneAction, &QAction::triggered, [this](){ markSemiTone(stmaMarkCurrentSemiTone); }); connect( markAllOctaveSemitonesAction, &QAction::triggered, [this](){ markSemiTone(stmaMarkAllOctaveSemiTones); }); @@ -246,8 +251,8 @@ PianoRoll::PianoRoll() : markScaleAction->setEnabled( false ); markChordAction->setEnabled( false ); - connect( this, SIGNAL(semiToneMarkerMenuScaleSetEnabled(bool)), markScaleAction, SLOT(setEnabled(bool)) ); - connect( this, SIGNAL(semiToneMarkerMenuChordSetEnabled(bool)), markChordAction, SLOT(setEnabled(bool)) ); + connect( this, SIGNAL(semiToneMarkerMenuScaleSetEnabled(bool)), markScaleAction, SLOT(setEnabled(bool))); + connect( this, SIGNAL(semiToneMarkerMenuChordSetEnabled(bool)), markChordAction, SLOT(setEnabled(bool))); m_semiToneMarkerMenu->addAction( markSemitoneAction ); m_semiToneMarkerMenu->addAction( markAllOctaveSemitonesAction ); @@ -296,42 +301,42 @@ PianoRoll::PianoRoll() : Song::Mode_PlayMidiClip ), m_currentPosition, Song::Mode_PlayMidiClip, this ); - connect( this, SIGNAL( positionChanged( const TimePos & ) ), - m_timeLine, SLOT( updatePosition( const TimePos & ) ) ); - connect( m_timeLine, SIGNAL( positionChanged( const TimePos & ) ), - this, SLOT( updatePosition( const TimePos & ) ) ); + connect( this, SIGNAL( positionChanged( const lmms::TimePos& ) ), + m_timeLine, SLOT( updatePosition( const lmms::TimePos& ) ) ); + connect( m_timeLine, SIGNAL( positionChanged( const lmms::TimePos& ) ), + this, SLOT( updatePosition( const lmms::TimePos& ) ) ); // white position line follows timeline marker m_positionLine = new PositionLine(this); //update timeline when in step-recording mode - connect( &m_stepRecorderWidget, SIGNAL( positionChanged( const TimePos & ) ), - this, SLOT( updatePositionStepRecording( const TimePos & ) ) ); + connect( &m_stepRecorderWidget, SIGNAL( positionChanged( const lmms::TimePos& ) ), + this, SLOT( updatePositionStepRecording( const lmms::TimePos& ) ) ); // update timeline when in record-accompany mode connect( Engine::getSong()->getPlayPos( Song::Mode_PlaySong ).m_timeLine, - SIGNAL( positionChanged( const TimePos & ) ), + SIGNAL( positionChanged( const lmms::TimePos& ) ), this, - SLOT( updatePositionAccompany( const TimePos & ) ) ); + SLOT( updatePositionAccompany( const lmms::TimePos& ) ) ); // TODO /* connect( engine::getSong()->getPlayPos( Song::Mode_PlayPattern ).m_timeLine, - SIGNAL( positionChanged( const TimePos & ) ), + SIGNAL( positionChanged( const lmms::TimePos& ) ), this, - SLOT( updatePositionAccompany( const TimePos & ) ) );*/ + SLOT( updatePositionAccompany( const lmms::TimePos& ) ) );*/ removeSelection(); // init scrollbars m_leftRightScroll = new QScrollBar( Qt::Horizontal, this ); m_leftRightScroll->setSingleStep( 1 ); - connect( m_leftRightScroll, SIGNAL( valueChanged( int ) ), this, - SLOT( horScrolled( int ) ) ); + connect( m_leftRightScroll, SIGNAL(valueChanged(int)), this, + SLOT(horScrolled(int))); m_topBottomScroll = new QScrollBar( Qt::Vertical, this ); m_topBottomScroll->setSingleStep( 1 ); m_topBottomScroll->setPageStep( 20 ); - connect( m_topBottomScroll, SIGNAL( valueChanged( int ) ), this, - SLOT( verScrolled( int ) ) ); + connect( m_topBottomScroll, SIGNAL(valueChanged(int)), this, + SLOT(verScrolled(int))); // setup zooming-stuff for( float const & zoomLevel : m_zoomLevels ) @@ -339,8 +344,8 @@ PianoRoll::PianoRoll() : m_zoomingModel.addItem( QString( "%1\%" ).arg( zoomLevel * 100 ) ); } m_zoomingModel.setValue( m_zoomingModel.findText( "100%" ) ); - connect( &m_zoomingModel, SIGNAL( dataChanged() ), - this, SLOT( zoomingChanged() ) ); + connect( &m_zoomingModel, SIGNAL(dataChanged()), + this, SLOT(zoomingChanged())); // zoom y for (float const & zoomLevel : m_zoomYLevels) @@ -358,37 +363,40 @@ PianoRoll::PianoRoll() : } m_quantizeModel.setValue( m_quantizeModel.findText( "1/16" ) ); - connect( &m_quantizeModel, SIGNAL( dataChanged() ), - this, SLOT( quantizeChanged() ) ); + connect( &m_quantizeModel, SIGNAL(dataChanged()), + this, SLOT(quantizeChanged())); // Set up note length model m_noteLenModel.addItem( tr( "Last note" ), std::make_unique( "edit_draw" ) ); - const QString pixmaps[] = { "whole", "half", "quarter", "eighth", + const auto pixmaps = std::array{"whole", "half", "quarter", "eighth", "sixteenth", "thirtysecond", "triplethalf", "tripletquarter", "tripleteighth", - "tripletsixteenth", "tripletthirtysecond" } ; + "tripletsixteenth", "tripletthirtysecond"}; for( int i = 0; i < NUM_EVEN_LENGTHS; ++i ) { auto loader = std::make_unique( "note_" + pixmaps[i] ); - m_noteLenModel.addItem( "1/" + QString::number( 1 << i ), ::move(loader) ); + m_noteLenModel.addItem( "1/" + QString::number( 1 << i ), std::move(loader) ); } for( int i = 0; i < NUM_TRIPLET_LENGTHS; ++i ) { auto loader = std::make_unique( "note_" + pixmaps[i+NUM_EVEN_LENGTHS] ); - m_noteLenModel.addItem( "1/" + QString::number( (1 << i) * 3 ), ::move(loader) ); + m_noteLenModel.addItem( "1/" + QString::number( (1 << i) * 3 ), std::move(loader) ); } m_noteLenModel.setValue( 0 ); // Note length change can cause a redraw if Q is set to lock - connect( &m_noteLenModel, SIGNAL( dataChanged() ), - this, SLOT( noteLengthChanged() ) ); + connect( &m_noteLenModel, SIGNAL(dataChanged()), + this, SLOT(noteLengthChanged())); // Set up key selection dropdown m_keyModel.addItem(tr("No key")); // Use piano roll note strings for key dropdown - for (int i = 0; i < 12; i++) { m_keyModel.addItem(s_noteStrings[i]); } + for (const auto& noteString : s_noteStrings) + { + m_keyModel.addItem(noteString); + } m_keyModel.setValue(0); // start with "No key" connect(&m_keyModel, &ComboBoxModel::dataChanged, this, &PianoRoll::keyChanged); @@ -409,8 +417,8 @@ PianoRoll::PianoRoll() : // connect scale change to key change so it auto-highlights with scale as well connect(&m_scaleModel, &ComboBoxModel::dataChanged, this, &PianoRoll::keyChanged); // change can update m_semiToneMarkerMenu - connect( &m_scaleModel, SIGNAL( dataChanged() ), - this, SLOT( updateSemiToneMarkerMenu() ) ); + connect( &m_scaleModel, SIGNAL(dataChanged()), + this, SLOT(updateSemiToneMarkerMenu())); // Set up chord model m_chordModel.addItem( tr("No chord") ); @@ -425,22 +433,22 @@ PianoRoll::PianoRoll() : m_chordModel.setValue( 0 ); // change can update m_semiToneMarkerMenu - connect( &m_chordModel, SIGNAL( dataChanged() ), - this, SLOT( updateSemiToneMarkerMenu() ) ); + connect( &m_chordModel, SIGNAL(dataChanged()), + this, SLOT(updateSemiToneMarkerMenu())); setFocusPolicy( Qt::StrongFocus ); setFocus(); setMouseTracking( true ); - connect( &m_scaleModel, SIGNAL( dataChanged() ), - this, SLOT( updateSemiToneMarkerMenu() ) ); + connect( &m_scaleModel, SIGNAL(dataChanged()), + this, SLOT(updateSemiToneMarkerMenu())); - connect( Engine::getSong(), SIGNAL( timeSignatureChanged( int, int ) ), - this, SLOT( update() ) ); + connect( Engine::getSong(), SIGNAL(timeSignatureChanged(int,int)), + this, SLOT(update())); //connection for selecion from timeline - connect( m_timeLine, SIGNAL( regionSelectedFromPixels( int, int ) ), - this, SLOT( selectRegionFromPixels( int, int ) ) ); + connect( m_timeLine, SIGNAL(regionSelectedFromPixels(int,int)), + this, SLOT(selectRegionFromPixels(int,int))); // Set up snap model m_snapModel.addItem(tr("Nudge")); @@ -553,9 +561,9 @@ void PianoRoll::markSemiTone(int i, bool fromMenu) { // lets erase all of the ones that match this by octave QList::iterator i; - for (int ix = 0; ix < aok.size(); ++ix) + for (int octave : aok) { - i = std::find(m_markedSemiTones.begin(), m_markedSemiTones.end(), aok.at(ix)); + i = std::find(m_markedSemiTones.begin(), m_markedSemiTones.end(), octave); if (i != m_markedSemiTones.end()) { m_markedSemiTones.erase(i); @@ -620,11 +628,6 @@ void PianoRoll::markSemiTone(int i, bool fromMenu) } -PianoRoll::~PianoRoll() -{ -} - - void PianoRoll::setGhostMidiClip( MidiClip* newMidiClip ) { // Expects a pointer to a MIDI clip or nullptr. @@ -633,7 +636,7 @@ void PianoRoll::setGhostMidiClip( MidiClip* newMidiClip ) { for( Note *note : newMidiClip->notes() ) { - Note * new_note = new Note( note->length(), note->pos(), note->key() ); + auto new_note = new Note(note->length(), note->pos(), note->key()); m_ghostNotes.push_back( new_note ); } emit ghostClipSet( true ); @@ -649,7 +652,7 @@ void PianoRoll::loadGhostNotes( const QDomElement & de ) QDomNode node = de.firstChild(); while( !node.isNull() ) { - Note * n = new Note; + auto n = new Note; n->restoreState( node.toElement() ); n->setVolume(DefaultVolume); m_ghostNotes.push_back( n ); @@ -908,12 +911,12 @@ void PianoRoll::setCurrentMidiClip( MidiClip* newMidiClip ) resizeEvent( nullptr ); // make sure to always get informed about the MIDI clip being destroyed - connect( m_midiClip, SIGNAL( destroyedMidiClip( MidiClip* ) ), this, SLOT( hideMidiClip( MidiClip* ) ) ); + connect( m_midiClip, SIGNAL(destroyedMidiClip(lmms::MidiClip*)), this, SLOT(hideMidiClip(lmms::MidiClip*))); - connect( m_midiClip->instrumentTrack(), SIGNAL( midiNoteOn( const Note& ) ), this, SLOT( startRecordNote( const Note& ) ) ); - connect( m_midiClip->instrumentTrack(), SIGNAL( midiNoteOff( const Note& ) ), this, SLOT( finishRecordNote( const Note& ) ) ); + connect( m_midiClip->instrumentTrack(), SIGNAL( midiNoteOn( const lmms::Note& ) ), this, SLOT( startRecordNote( const lmms::Note& ) ) ); + connect( m_midiClip->instrumentTrack(), SIGNAL( midiNoteOff( const lmms::Note& ) ), this, SLOT( finishRecordNote( const lmms::Note& ) ) ); connect( m_midiClip, SIGNAL(dataChanged()), this, SLOT(update())); - connect( m_midiClip->instrumentTrack()->pianoModel(), SIGNAL( dataChanged() ), this, SLOT( update() ) ); + connect( m_midiClip->instrumentTrack()->pianoModel(), SIGNAL(dataChanged()), this, SLOT(update())); connect(m_midiClip->instrumentTrack()->firstKeyModel(), SIGNAL(dataChanged()), this, SLOT(update())); connect(m_midiClip->instrumentTrack()->lastKeyModel(), SIGNAL(dataChanged()), this, SLOT(update())); @@ -988,20 +991,20 @@ void PianoRoll::drawNoteRect( QPainter & p, int x, int y, } // Volume - float const volumeRange = static_cast(MaxVolume - MinVolume); - float const volumeSpan = static_cast(n->getVolume() - MinVolume); + auto const volumeRange = static_cast(MaxVolume - MinVolume); + auto const volumeSpan = static_cast(n->getVolume() - MinVolume); float const volumeRatio = volumeSpan / volumeRange; int volVal = qMin( 255, 100 + static_cast( volumeRatio * 155.0f) ); // Panning - float const panningRange = static_cast(PanningRight - PanningLeft); - float const leftPanSpan = static_cast(PanningRight - n->getPanning()); - float const rightPanSpan = static_cast(n->getPanning() - PanningLeft); + auto const panningRange = static_cast(PanningRight - PanningLeft); + auto const leftPanSpan = static_cast(PanningRight - n->getPanning()); + auto const rightPanSpan = static_cast(n->getPanning() - PanningLeft); float leftPercent = qMin( 1.0f, leftPanSpan / panningRange * 2.0f ); float rightPercent = qMin( 1.0f, rightPanSpan / panningRange * 2.0f ); - QColor col = QColor( noteCol ); + QColor col{noteCol}; QPen pen; if( n->selected() ) @@ -1307,16 +1310,25 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke) int direction = (ke->key() == Qt::Key_Up ? +1 : -1); if( ( ke->modifiers() & Qt::ControlModifier ) && m_action == ActionNone ) { - // shift selection up an octave + // shift selection by one octave // if nothing selected, shift _everything_ if (hasValidMidiClip()) { - shiftSemiTone( 12 * direction ); + // An octave could potentially be greater or less than twelve semitones if the microtuner is in use. + const auto microtuner = m_midiClip->instrumentTrack()->microtuner(); + if (microtuner->enabled()) + { + shiftSemiTone(microtuner->octaveSize() * direction); + } + else + { + shiftSemiTone(12 * direction); + } } } else if((ke->modifiers() & Qt::ShiftModifier) && m_action == ActionNone) { - // Move selected notes up by one semitone + // Move selected notes by one semitone if (hasValidMidiClip()) { shiftSemiTone( 1 * direction ); @@ -3651,8 +3663,8 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) } // set line colors - QColor editAreaCol = QColor(m_lineColor); - QColor currentKeyCol = QColor(m_beatLineColor); + auto editAreaCol = QColor(m_lineColor); + auto currentKeyCol = QColor(m_beatLineColor); editAreaCol.setAlpha( 64 ); currentKeyCol.setAlpha( 64 ); @@ -4738,7 +4750,7 @@ PianoRollWindow::PianoRollWindow() : DropToolBar *notesActionsToolBar = addDropToolBarToTop( tr( "Edit actions" ) ); // init edit-buttons at the top - ActionGroup* editModeGroup = new ActionGroup( this ); + auto editModeGroup = new ActionGroup(this); QAction* drawAction = editModeGroup->addAction( embed::getIconPixmap( "edit_draw" ), tr( "Draw mode (Shift+D)" ) ); QAction* eraseAction = editModeGroup->addAction( embed::getIconPixmap( "edit_erase" ), tr("Erase mode (Shift+E)" ) ); QAction* selectAction = editModeGroup->addAction( embed::getIconPixmap( "edit_select" ), tr( "Select mode (Shift+S)" ) ); @@ -4751,15 +4763,15 @@ PianoRollWindow::PianoRollWindow() : selectAction->setShortcut( Qt::SHIFT | Qt::Key_S ); pitchBendAction->setShortcut( Qt::SHIFT | Qt::Key_T ); - connect( editModeGroup, SIGNAL( triggered( int ) ), m_editor, SLOT( setEditMode( int ) ) ); + connect( editModeGroup, SIGNAL(triggered(int)), m_editor, SLOT(setEditMode(int))); // Quantize combo button - QToolButton* quantizeButton = new QToolButton(notesActionsToolBar); - QMenu* quantizeButtonMenu = new QMenu(quantizeButton); + auto quantizeButton = new QToolButton(notesActionsToolBar); + auto quantizeButtonMenu = new QMenu(quantizeButton); - QAction* quantizeAction = new QAction(embed::getIconPixmap("quantize"), tr("Quantize"), this); - QAction* quantizePosAction = new QAction(tr("Quantize positions"), this); - QAction* quantizeLengthAction = new QAction(tr("Quantize lengths"), this); + auto quantizeAction = new QAction(embed::getIconPixmap("quantize"), tr("Quantize"), this); + auto quantizePosAction = new QAction(tr("Quantize positions"), this); + auto quantizeLengthAction = new QAction(tr("Quantize lengths"), this); connect(quantizeAction, &QAction::triggered, [this](){ m_editor->quantizeNotes(); }); connect(quantizePosAction, &QAction::triggered, [this](){ m_editor->quantizeNotes(PianoRoll::QuantizePos); }); @@ -4787,11 +4799,9 @@ PianoRollWindow::PianoRollWindow() : m_fileToolsButton->setPopupMode(QToolButton::InstantPopup); // Import / export - QAction* importAction = new QAction(embed::getIconPixmap("project_import"), - tr("Import clip"), m_fileToolsButton); + auto importAction = new QAction(embed::getIconPixmap("project_import"), tr("Import clip"), m_fileToolsButton); - QAction* exportAction = new QAction(embed::getIconPixmap("project_export"), - tr("Export clip"), m_fileToolsButton); + auto exportAction = new QAction(embed::getIconPixmap("project_export"), tr("Export clip"), m_fileToolsButton); m_fileToolsButton->addAction(importAction); m_fileToolsButton->addAction(exportAction); @@ -4804,22 +4814,19 @@ PianoRollWindow::PianoRollWindow() : // Copy + paste actions DropToolBar *copyPasteActionsToolBar = addDropToolBarToTop( tr( "Copy paste controls" ) ); - QAction* cutAction = new QAction(embed::getIconPixmap( "edit_cut" ), - tr( "Cut (%1+X)" ).arg(UI_CTRL_KEY), this ); + auto cutAction = new QAction(embed::getIconPixmap("edit_cut"), tr("Cut (%1+X)").arg(UI_CTRL_KEY), this); - QAction* copyAction = new QAction(embed::getIconPixmap( "edit_copy" ), - tr( "Copy (%1+C)" ).arg(UI_CTRL_KEY), this ); + auto copyAction = new QAction(embed::getIconPixmap("edit_copy"), tr("Copy (%1+C)").arg(UI_CTRL_KEY), this); - QAction* pasteAction = new QAction(embed::getIconPixmap( "edit_paste" ), - tr( "Paste (%1+V)" ).arg(UI_CTRL_KEY), this ); + auto pasteAction = new QAction(embed::getIconPixmap("edit_paste"), tr("Paste (%1+V)").arg(UI_CTRL_KEY), this); cutAction->setShortcut( Qt::CTRL | Qt::Key_X ); copyAction->setShortcut( Qt::CTRL | Qt::Key_C ); pasteAction->setShortcut( Qt::CTRL | Qt::Key_V ); - connect( cutAction, SIGNAL( triggered() ), m_editor, SLOT( cutSelectedNotes() ) ); - connect( copyAction, SIGNAL( triggered() ), m_editor, SLOT( copySelectedNotes() ) ); - connect( pasteAction, SIGNAL( triggered() ), m_editor, SLOT( pasteNotes() ) ); + connect( cutAction, SIGNAL(triggered()), m_editor, SLOT(cutSelectedNotes())); + connect( copyAction, SIGNAL(triggered()), m_editor, SLOT(copySelectedNotes())); + connect( pasteAction, SIGNAL(triggered()), m_editor, SLOT(pasteNotes())); copyPasteActionsToolBar->addAction( cutAction ); copyPasteActionsToolBar->addAction( copyAction ); @@ -4830,32 +4837,30 @@ PianoRollWindow::PianoRollWindow() : m_editor->m_timeLine->addToolButtons( timeLineToolBar ); // -- Note modifier tools - QToolButton * noteToolsButton = new QToolButton(m_toolBar); + auto noteToolsButton = new QToolButton(m_toolBar); noteToolsButton->setIcon(embed::getIconPixmap("tool")); noteToolsButton->setPopupMode(QToolButton::InstantPopup); - QAction * glueAction = new QAction(embed::getIconPixmap("glue"), - tr("Glue"), noteToolsButton); + auto glueAction = new QAction(embed::getIconPixmap("glue"), tr("Glue"), noteToolsButton); connect(glueAction, SIGNAL(triggered()), m_editor, SLOT(glueNotes())); glueAction->setShortcut( Qt::SHIFT | Qt::Key_G ); - QAction * knifeAction = new QAction(embed::getIconPixmap("edit_knife"), - tr("Knife"), noteToolsButton); + auto knifeAction = new QAction(embed::getIconPixmap("edit_knife"), tr("Knife"), noteToolsButton); connect(knifeAction, &QAction::triggered, m_editor, &PianoRoll::setKnifeAction); knifeAction->setShortcut( Qt::SHIFT | Qt::Key_K ); - - QAction* fillAction = new QAction(embed::getIconPixmap("fill"), tr("Fill"), noteToolsButton); + + auto fillAction = new QAction(embed::getIconPixmap("fill"), tr("Fill"), noteToolsButton); connect(fillAction, &QAction::triggered, [this](){ m_editor->fitNoteLengths(true); }); fillAction->setShortcut(Qt::SHIFT | Qt::Key_F); - QAction* cutOverlapsAction = new QAction(embed::getIconPixmap("cut_overlaps"), tr("Cut overlaps"), noteToolsButton); + auto cutOverlapsAction = new QAction(embed::getIconPixmap("cut_overlaps"), tr("Cut overlaps"), noteToolsButton); connect(cutOverlapsAction, &QAction::triggered, [this](){ m_editor->fitNoteLengths(false); }); cutOverlapsAction->setShortcut(Qt::SHIFT | Qt::Key_C); - QAction* minLengthAction = new QAction(embed::getIconPixmap("min_length"), tr("Min length as last"), noteToolsButton); + auto minLengthAction = new QAction(embed::getIconPixmap("min_length"), tr("Min length as last"), noteToolsButton); connect(minLengthAction, &QAction::triggered, [this](){ m_editor->constrainNoteLengths(false); }); - QAction* maxLengthAction = new QAction(embed::getIconPixmap("max_length"), tr("Max length as last"), noteToolsButton); + auto maxLengthAction = new QAction(embed::getIconPixmap("max_length"), tr("Max length as last"), noteToolsButton); connect(maxLengthAction, &QAction::triggered, [this](){ m_editor->constrainNoteLengths(true); }); noteToolsButton->addAction(glueAction); @@ -4872,7 +4877,7 @@ PianoRollWindow::PianoRollWindow() : DropToolBar *zoomAndNotesToolBar = addDropToolBarToTop( tr( "Zoom and note controls" ) ); - QLabel * zoom_lbl = new QLabel( m_toolBar ); + auto zoom_lbl = new QLabel(m_toolBar); zoom_lbl->setPixmap( embed::getIconPixmap( "zoom_x" ) ); m_zoomingComboBox = new ComboBox( m_toolBar ); @@ -4880,7 +4885,7 @@ PianoRollWindow::PianoRollWindow() : m_zoomingComboBox->setFixedSize( 64, ComboBox::DEFAULT_HEIGHT ); m_zoomingComboBox->setToolTip( tr( "Horizontal zooming") ); - QLabel * zoom_y_lbl = new QLabel(m_toolBar); + auto zoom_y_lbl = new QLabel(m_toolBar); zoom_y_lbl->setPixmap(embed::getIconPixmap("zoom_y")); m_zoomingYComboBox = new ComboBox(m_toolBar); @@ -4889,7 +4894,7 @@ PianoRollWindow::PianoRollWindow() : m_zoomingYComboBox->setToolTip(tr("Vertical zooming")); // setup quantize-stuff - QLabel * quantize_lbl = new QLabel( m_toolBar ); + auto quantize_lbl = new QLabel(m_toolBar); quantize_lbl->setPixmap( embed::getIconPixmap( "quantize" ) ); m_quantizeComboBox = new ComboBox( m_toolBar ); @@ -4898,7 +4903,7 @@ PianoRollWindow::PianoRollWindow() : m_quantizeComboBox->setToolTip( tr( "Quantization") ); // setup note-len-stuff - QLabel * note_len_lbl = new QLabel( m_toolBar ); + auto note_len_lbl = new QLabel(m_toolBar); note_len_lbl->setPixmap( embed::getIconPixmap( "note" ) ); m_noteLenComboBox = new ComboBox( m_toolBar ); @@ -4913,7 +4918,7 @@ PianoRollWindow::PianoRollWindow() : m_keyComboBox->setToolTip(tr("Key")); // setup scale-stuff - QLabel * scale_lbl = new QLabel( m_toolBar ); + auto scale_lbl = new QLabel(m_toolBar); scale_lbl->setPixmap( embed::getIconPixmap( "scale" ) ); m_scaleComboBox = new ComboBox( m_toolBar ); @@ -4922,7 +4927,7 @@ PianoRollWindow::PianoRollWindow() : m_scaleComboBox->setToolTip( tr( "Scale") ); // setup chord-stuff - QLabel * chord_lbl = new QLabel( m_toolBar ); + auto chord_lbl = new QLabel(m_toolBar); chord_lbl->setPixmap( embed::getIconPixmap( "chord" ) ); m_chordComboBox = new ComboBox( m_toolBar ); @@ -4931,7 +4936,7 @@ PianoRollWindow::PianoRollWindow() : m_chordComboBox->setToolTip( tr( "Chord" ) ); // setup snap-stuff - QLabel* snapLbl = new QLabel(m_toolBar); + auto snapLbl = new QLabel(m_toolBar); snapLbl->setPixmap(embed::getIconPixmap("gridmode")); m_snapComboBox = new ComboBox(m_toolBar); @@ -4944,29 +4949,29 @@ PianoRollWindow::PianoRollWindow() : m_clearGhostButton->setIcon( embed::getIconPixmap( "clear_ghost_note" ) ); m_clearGhostButton->setToolTip( tr( "Clear ghost notes" ) ); m_clearGhostButton->setEnabled( false ); - connect( m_clearGhostButton, SIGNAL( clicked() ), m_editor, SLOT( clearGhostClip() ) ); - connect( m_editor, SIGNAL( ghostClipSet( bool ) ), this, SLOT( ghostClipSet( bool ) ) ); + connect( m_clearGhostButton, SIGNAL(clicked()), m_editor, SLOT(clearGhostClip())); + connect( m_editor, SIGNAL(ghostClipSet(bool)), this, SLOT(ghostClipSet(bool))); // Wrap label icons and comboboxes in a single widget so when // the window is resized smaller in width it hides both - QWidget * zoom_widget = new QWidget(); - QHBoxLayout * zoom_hbox = new QHBoxLayout(); + auto zoom_widget = new QWidget(); + auto zoom_hbox = new QHBoxLayout(); zoom_hbox->setContentsMargins(0, 0, 0, 0); zoom_hbox->addWidget(zoom_lbl); zoom_hbox->addWidget(m_zoomingComboBox); zoom_widget->setLayout(zoom_hbox); zoomAndNotesToolBar->addWidget(zoom_widget); - QWidget * zoomY_widget = new QWidget(); - QHBoxLayout * zoomY_hbox = new QHBoxLayout(); + auto zoomY_widget = new QWidget(); + auto zoomY_hbox = new QHBoxLayout(); zoomY_hbox->setContentsMargins(0, 0, 0, 0); zoomY_hbox->addWidget(zoom_y_lbl); zoomY_hbox->addWidget(m_zoomingYComboBox); zoomY_widget->setLayout(zoomY_hbox); zoomAndNotesToolBar->addWidget(zoomY_widget); - QWidget * quantize_widget = new QWidget(); - QHBoxLayout * quantize_hbox = new QHBoxLayout(); + auto quantize_widget = new QWidget(); + auto quantize_hbox = new QHBoxLayout(); quantize_hbox->setContentsMargins(0, 0, 0, 0); quantize_hbox->addWidget(quantize_lbl); quantize_hbox->addWidget(m_quantizeComboBox); @@ -4974,8 +4979,8 @@ PianoRollWindow::PianoRollWindow() : zoomAndNotesToolBar->addSeparator(); zoomAndNotesToolBar->addWidget(quantize_widget); - QWidget * note_widget = new QWidget(); - QHBoxLayout * note_hbox = new QHBoxLayout(); + auto note_widget = new QWidget(); + auto note_hbox = new QHBoxLayout(); note_hbox->setContentsMargins(0, 0, 0, 0); note_hbox->addWidget(note_len_lbl); note_hbox->addWidget(m_noteLenComboBox); @@ -4983,8 +4988,8 @@ PianoRollWindow::PianoRollWindow() : zoomAndNotesToolBar->addSeparator(); zoomAndNotesToolBar->addWidget(note_widget); - QWidget * scale_widget = new QWidget(); - QHBoxLayout * scale_hbox = new QHBoxLayout(); + auto scale_widget = new QWidget(); + auto scale_hbox = new QHBoxLayout(); scale_hbox->setContentsMargins(0, 0, 0, 0); scale_hbox->addWidget(scale_lbl); // Add the key selection between scale label and key @@ -4994,8 +4999,8 @@ PianoRollWindow::PianoRollWindow() : zoomAndNotesToolBar->addSeparator(); zoomAndNotesToolBar->addWidget(scale_widget); - QWidget * chord_widget = new QWidget(); - QHBoxLayout * chord_hbox = new QHBoxLayout(); + auto chord_widget = new QWidget(); + auto chord_hbox = new QHBoxLayout(); chord_hbox->setContentsMargins(0, 0, 0, 0); chord_hbox->addWidget(chord_lbl); chord_hbox->addWidget(m_chordComboBox); @@ -5006,8 +5011,8 @@ PianoRollWindow::PianoRollWindow() : zoomAndNotesToolBar->addSeparator(); zoomAndNotesToolBar->addWidget( m_clearGhostButton ); - QWidget* snapWidget = new QWidget(); - QHBoxLayout* snapHbox = new QHBoxLayout(); + auto snapWidget = new QWidget(); + auto snapHbox = new QHBoxLayout(); snapHbox->setContentsMargins(0, 0, 0, 0); snapHbox->addWidget(snapLbl); snapHbox->addWidget(m_snapComboBox); @@ -5022,8 +5027,8 @@ PianoRollWindow::PianoRollWindow() : setCurrentMidiClip( nullptr ); // Connections - connect( m_editor, SIGNAL( currentMidiClipChanged() ), this, SIGNAL( currentMidiClipChanged() ) ); - connect( m_editor, SIGNAL( currentMidiClipChanged() ), this, SLOT( updateAfterMidiClipChange() ) ); + connect( m_editor, SIGNAL(currentMidiClipChanged()), this, SIGNAL(currentMidiClipChanged())); + connect( m_editor, SIGNAL(currentMidiClipChanged()), this, SLOT(updateAfterMidiClipChange())); } @@ -5053,8 +5058,8 @@ void PianoRollWindow::setCurrentMidiClip( MidiClip* clip ) { setWindowTitle( tr( "Piano-Roll - %1" ).arg( clip->name() ) ); m_fileToolsButton->setEnabled(true); - connect( clip->instrumentTrack(), SIGNAL( nameChanged() ), this, SLOT( updateAfterMidiClipChange()) ); - connect( clip, SIGNAL( dataChanged() ), this, SLOT( updateAfterMidiClipChange() ) ); + connect( clip->instrumentTrack(), SIGNAL(nameChanged()), this, SLOT(updateAfterMidiClipChange())); + connect( clip, SIGNAL(dataChanged()), this, SLOT(updateAfterMidiClipChange())); } else { @@ -5166,10 +5171,10 @@ void PianoRollWindow::saveSettings( QDomDocument & doc, QDomElement & de ) if (m_editor->m_markedSemiTones.length() > 0) { QDomElement markedSemiTonesRoot = doc.createElement("markedSemiTones"); - for (int ix = 0; ix < m_editor->m_markedSemiTones.size(); ++ix) + for (int markedSemiTone : m_editor->m_markedSemiTones) { QDomElement semiToneNode = doc.createElement("semiTone"); - semiToneNode.setAttribute("key", m_editor->m_markedSemiTones.at(ix)); + semiToneNode.setAttribute("key", markedSemiTone); markedSemiTonesRoot.appendChild(semiToneNode); } de.appendChild(markedSemiTonesRoot); @@ -5349,3 +5354,8 @@ void PianoRollWindow::updateStepRecordingIcon() m_toggleStepRecordingAction->setIcon(embed::getIconPixmap("record_step_off")); } } + + +} // namespace gui + +} // namespace lmms diff --git a/src/gui/editors/PositionLine.cpp b/src/gui/editors/PositionLine.cpp index c91a82abe..7dd8b3b13 100644 --- a/src/gui/editors/PositionLine.cpp +++ b/src/gui/editors/PositionLine.cpp @@ -29,6 +29,9 @@ #include "Song.h" +namespace lmms::gui +{ + PositionLine::PositionLine(QWidget* parent) : QWidget(parent), m_hasTailGradient(false), @@ -43,7 +46,7 @@ PositionLine::PositionLine(QWidget* parent) : void PositionLine::paintEvent(QPaintEvent* pe) { QPainter p(this); - QColor c = QColor(m_lineColor); + auto c = QColor(m_lineColor); // If width is 1, we don't need a gradient if (width() == 1) @@ -95,3 +98,6 @@ void PositionLine::zoomChange(float zoom) update(); } + + +} // namespace lmms::gui diff --git a/src/gui/editors/Rubberband.cpp b/src/gui/editors/Rubberband.cpp index b0bd5cc06..9c5e9c0dc 100644 --- a/src/gui/editors/Rubberband.cpp +++ b/src/gui/editors/Rubberband.cpp @@ -26,6 +26,9 @@ #include "Rubberband.h" +namespace lmms::gui +{ + RubberBand::RubberBand( QWidget * _parent ) : QRubberBand( Rectangle, _parent ) @@ -35,13 +38,6 @@ RubberBand::RubberBand( QWidget * _parent ) : -RubberBand::~RubberBand() -{ -} - - - - QVector RubberBand::selectedObjects() const { QVector so = selectableObjects(); @@ -81,17 +77,12 @@ QVector RubberBand::selectableObjects() const QList l = parentWidget()->findChildren(); - for( QList::iterator it = l.begin(); it != l.end(); - ++it ) + for (const auto& obj : l) { - so.push_back( *it ); + so.push_back(obj); } return( so ); } - - - - - +} // namespace lmms::gui diff --git a/src/gui/editors/SongEditor.cpp b/src/gui/editors/SongEditor.cpp index 4a598478c..b00995f60 100644 --- a/src/gui/editors/SongEditor.cpp +++ b/src/gui/editors/SongEditor.cpp @@ -55,6 +55,10 @@ #include "TimeLineWidget.h" #include "TrackView.h" +namespace lmms::gui +{ + + const QVector SongEditor::m_zoomLevels = { 0.125f, 0.25f, 0.5f, 1.0f, 2.0f, 4.0f, 8.0f, 16.0f }; @@ -85,23 +89,26 @@ SongEditor::SongEditor( Song * song ) : m_song->m_playPos[Song::Mode_PlaySong], m_currentPosition, Song::Mode_PlaySong, this ); - connect( this, SIGNAL( positionChanged( const TimePos & ) ), + connect( this, SIGNAL( positionChanged( const lmms::TimePos& ) ), m_song->m_playPos[Song::Mode_PlaySong].m_timeLine, - SLOT( updatePosition( const TimePos & ) ) ); - connect( m_timeLine, SIGNAL( positionChanged( const TimePos & ) ), - this, SLOT( updatePosition( const TimePos & ) ) ); - connect( m_timeLine, SIGNAL( regionSelectedFromPixels( int, int ) ), - this, SLOT( selectRegionFromPixels( int, int ) ) ); - connect( m_timeLine, SIGNAL( selectionFinished() ), - this, SLOT( stopRubberBand() ) ); + SLOT( updatePosition( const lmms::TimePos& ) ) ); + connect( m_timeLine, SIGNAL( positionChanged( const lmms::TimePos& ) ), + this, SLOT( updatePosition( const lmms::TimePos& ) ) ); + connect( m_timeLine, SIGNAL(regionSelectedFromPixels(int,int)), + this, SLOT(selectRegionFromPixels(int,int))); + connect( m_timeLine, SIGNAL(selectionFinished()), + this, SLOT(stopRubberBand())); + + // when tracks realign, adjust height of position line + connect(this, &TrackContainerView::tracksRealigned, this, &SongEditor::updatePositionLine); m_positionLine = new PositionLine(this); static_cast( layout() )->insertWidget( 1, m_timeLine ); - connect( m_song, SIGNAL( playbackStateChanged() ), - m_positionLine, SLOT( update() ) ); - connect( this, SIGNAL( zoomingValueChanged( float ) ), - m_positionLine, SLOT( zoomChange( float ) ) ); + connect( m_song, SIGNAL(playbackStateChanged()), + m_positionLine, SLOT(update())); + connect( this, SIGNAL(zoomingValueChanged(float)), + m_positionLine, SLOT(zoomChange(float))); // Ensure loop markers snap to same increments as clips. Zoom & proportional // snap changes are handled in zoomingChanged() and toggleProportionalSnap() @@ -126,8 +133,8 @@ SongEditor::SongEditor( Song * song ) : tr( "High quality mode" ), nullptr, nullptr, tb ); hq_btn->setCheckable( true ); - connect( hq_btn, SIGNAL( toggled( bool ) ), - this, SLOT( setHighQuality( bool ) ) ); + connect( hq_btn, SIGNAL(toggled(bool)), + this, SLOT(setHighQuality(bool))); hq_btn->setFixedWidth( 42 ); getGUI()->mainWindow()->addWidgetToToolBar( hq_btn, 1, col ); #endif @@ -147,7 +154,7 @@ SongEditor::SongEditor( Song * song ) : getGUI()->mainWindow()->addSpacingToToolBar( 10 ); - QLabel * master_vol_lbl = new QLabel( tb ); + auto master_vol_lbl = new QLabel(tb); master_vol_lbl->setPixmap( embed::getIconPixmap( "master_volume" ) ); m_masterVolumeSlider = new AutomatableSlider( tb, @@ -160,14 +167,14 @@ SongEditor::SongEditor( Song * song ) : m_masterVolumeSlider->setTickInterval( 50 ); m_masterVolumeSlider->setToolTip(tr("Master volume")); - connect( m_masterVolumeSlider, SIGNAL( logicValueChanged( int ) ), this, - SLOT( setMasterVolume( int ) ) ); - connect( m_masterVolumeSlider, SIGNAL( sliderPressed() ), this, - SLOT( showMasterVolumeFloat()) ); - connect( m_masterVolumeSlider, SIGNAL( logicSliderMoved( int ) ), this, - SLOT( updateMasterVolumeFloat( int ) ) ); - connect( m_masterVolumeSlider, SIGNAL( sliderReleased() ), this, - SLOT( hideMasterVolumeFloat() ) ); + connect( m_masterVolumeSlider, SIGNAL(logicValueChanged(int)), this, + SLOT(setMasterVolume(int))); + connect( m_masterVolumeSlider, SIGNAL(sliderPressed()), this, + SLOT(showMasterVolumeFloat())); + connect( m_masterVolumeSlider, SIGNAL(logicSliderMoved(int)), this, + SLOT(updateMasterVolumeFloat(int))); + connect( m_masterVolumeSlider, SIGNAL(sliderReleased()), this, + SLOT(hideMasterVolumeFloat())); m_mvsStatus = new TextFloat; m_mvsStatus->setTitle( tr( "Master volume" ) ); @@ -179,30 +186,29 @@ SongEditor::SongEditor( Song * song ) : getGUI()->mainWindow()->addSpacingToToolBar( 10 ); - - QLabel * master_pitch_lbl = new QLabel( tb ); + auto master_pitch_lbl = new QLabel(tb); master_pitch_lbl->setPixmap( embed::getIconPixmap( "master_pitch" ) ); master_pitch_lbl->setFixedHeight( 64 ); - m_masterPitchSlider = new AutomatableSlider( tb, tr( "Master pitch" ) ); + m_masterPitchSlider = new AutomatableSlider( tb, tr( "Global transposition" ) ); m_masterPitchSlider->setModel( &m_song->m_masterPitchModel ); m_masterPitchSlider->setOrientation( Qt::Vertical ); m_masterPitchSlider->setPageStep( 1 ); m_masterPitchSlider->setTickPosition( QSlider::TicksLeft ); m_masterPitchSlider->setFixedSize( 26, 60 ); m_masterPitchSlider->setTickInterval( 12 ); - m_masterPitchSlider->setToolTip(tr("Master pitch")); - connect( m_masterPitchSlider, SIGNAL( logicValueChanged( int ) ), this, - SLOT( setMasterPitch( int ) ) ); - connect( m_masterPitchSlider, SIGNAL( sliderPressed() ), this, - SLOT( showMasterPitchFloat() ) ); - connect( m_masterPitchSlider, SIGNAL( logicSliderMoved( int ) ), this, - SLOT( updateMasterPitchFloat( int ) ) ); - connect( m_masterPitchSlider, SIGNAL( sliderReleased() ), this, - SLOT( hideMasterPitchFloat() ) ); + m_masterPitchSlider->setToolTip(tr("Global transposition")); + connect( m_masterPitchSlider, SIGNAL(logicValueChanged(int)), this, + SLOT(setMasterPitch(int))); + connect( m_masterPitchSlider, SIGNAL(sliderPressed()), this, + SLOT(showMasterPitchFloat())); + connect( m_masterPitchSlider, SIGNAL(logicSliderMoved(int)), this, + SLOT(updateMasterPitchFloat(int))); + connect( m_masterPitchSlider, SIGNAL(sliderReleased()), this, + SLOT(hideMasterPitchFloat())); m_mpsStatus = new TextFloat; - m_mpsStatus->setTitle( tr( "Master pitch" ) ); + m_mpsStatus->setTitle( tr( "Global transposition" ) ); m_mpsStatus->setPixmap( embed::getIconPixmap( "master_pitch" ) ); getGUI()->mainWindow()->addWidgetToToolBar( master_pitch_lbl ); @@ -211,8 +217,8 @@ SongEditor::SongEditor( Song * song ) : getGUI()->mainWindow()->addSpacingToToolBar( 10 ); // create widget for oscilloscope- and cpu-load-widget - QWidget * vc_w = new QWidget( tb ); - QVBoxLayout * vcw_layout = new QVBoxLayout( vc_w ); + auto vc_w = new QWidget(tb); + auto vcw_layout = new QVBoxLayout(vc_w); vcw_layout->setMargin( 0 ); vcw_layout->setSpacing( 0 ); @@ -232,10 +238,10 @@ SongEditor::SongEditor( Song * song ) : m_leftRightScroll->setSingleStep( 1 ); m_leftRightScroll->setPageStep( 20 ); static_cast( layout() )->addWidget( m_leftRightScroll ); - connect( m_leftRightScroll, SIGNAL( valueChanged( int ) ), - this, SLOT( scrolled( int ) ) ); - connect( m_song, SIGNAL( lengthChanged( int ) ), - this, SLOT( updateScrollBar( int ) ) ); + connect( m_leftRightScroll, SIGNAL(valueChanged(int)), + this, SLOT(scrolled(int))); + connect( m_song, SIGNAL(lengthChanged(int)), + this, SLOT(updateScrollBar(int))); connect(m_leftRightScroll, SIGNAL(valueChanged(int)),this, SLOT(updateRubberband())); connect(contentWidget()->verticalScrollBar(), SIGNAL(valueChanged(int)),this, SLOT(updateRubberband())); connect(m_timeLine, SIGNAL(selectionFinished()), this, SLOT(stopSelectRegion())); @@ -248,10 +254,10 @@ SongEditor::SongEditor( Song * song ) : } m_zoomingModel->setInitValue( m_zoomingModel->findText( "100%" ) ); - connect( m_zoomingModel, SIGNAL( dataChanged() ), - this, SLOT( zoomingChanged() ) ); - connect( m_zoomingModel, SIGNAL( dataChanged() ), - m_positionLine, SLOT( update() ) ); + connect( m_zoomingModel, SIGNAL(dataChanged()), + this, SLOT(zoomingChanged())); + connect( m_zoomingModel, SIGNAL(dataChanged()), + m_positionLine, SLOT(update())); //Set up snapping model, 2^i for ( int i = 3; i >= -4; i-- ) @@ -278,10 +284,6 @@ SongEditor::SongEditor( Song * song ) : -SongEditor::~SongEditor() -{ -} - void SongEditor::saveSettings( QDomDocument& doc, QDomElement& element ) { MainWindow::saveWidgetState( parentWidget(), element ); @@ -432,7 +434,7 @@ void SongEditor::updateRubberband() //are clips in the rect of selection? for (auto &it : findChildren()) { - ClipView * clip = dynamic_cast(it); + auto clip = dynamic_cast(it); if (clip) { auto indexOfTrackView = trackViews().indexOf(clip->getTrackView()); @@ -514,11 +516,9 @@ void SongEditor::keyPressEvent( QKeyEvent * ke ) else if( ke->key() == Qt::Key_Delete || ke->key() == Qt::Key_Backspace ) { QVector so = selectedObjects(); - for( QVector::iterator it = so.begin(); - it != so.end(); ++it ) + for (const auto& selectedClip : so) { - ClipView * clipv = - dynamic_cast( *it ); + auto clipv = dynamic_cast(selectedClip); clipv->remove(); } } @@ -729,7 +729,7 @@ void SongEditor::showMasterPitchFloat( void ) void SongEditor::updateMasterPitchFloat( int new_val ) { - m_mpsStatus->setText( tr( "Value: %1 semitones").arg( new_val ) ); + m_mpsStatus->setText( tr( "Value: %1 keys").arg( new_val ) ); } @@ -761,14 +761,14 @@ static inline void animateScroll( QScrollBar *scrollBar, int newVal, bool smooth else { // do smooth scroll animation using QTimeLine - QTimeLine *t = scrollBar->findChild(); + auto t = scrollBar->findChild(); if( t == nullptr ) { t = new QTimeLine( 600, scrollBar ); t->setFrameRange( scrollBar->value(), newVal ); - t->connect( t, SIGNAL( finished() ), SLOT( deleteLater() ) ); + t->connect( t, SIGNAL(finished()), SLOT(deleteLater())); - scrollBar->connect( t, SIGNAL( frameChanged( int ) ), SLOT( setValue( int ) ) ); + scrollBar->connect( t, SIGNAL(frameChanged(int)), SLOT(setValue(int))); t->start(); } @@ -829,7 +829,7 @@ void SongEditor::updatePosition( const TimePos & t ) m_positionLine->hide(); } - m_positionLine->setFixedHeight( height() ); + updatePositionLine(); } @@ -837,7 +837,7 @@ void SongEditor::updatePosition( const TimePos & t ) void SongEditor::updatePositionLine() { - m_positionLine->setFixedHeight( height() ); + m_positionLine->setFixedHeight(totalHeightOfTracks()); } @@ -994,7 +994,7 @@ SongEditorWindow::SongEditorWindow(Song* song) : DropToolBar *zoomToolBar = addDropToolBarToTop(tr("Zoom controls")); - QLabel * zoom_lbl = new QLabel( m_toolBar ); + auto zoom_lbl = new QLabel(m_toolBar); zoom_lbl->setPixmap( embed::getIconPixmap( "zoom" ) ); //Set up zooming-stuff @@ -1009,7 +1009,7 @@ SongEditorWindow::SongEditorWindow(Song* song) : zoomToolBar->addWidget( m_zoomingComboBox ); DropToolBar *snapToolBar = addDropToolBarToTop(tr("Snap controls")); - QLabel * snap_lbl = new QLabel( m_toolBar ); + auto snap_lbl = new QLabel(m_toolBar); snap_lbl->setPixmap( embed::getIconPixmap( "quantize" ) ); //Set up quantization/snapping selector @@ -1024,7 +1024,7 @@ SongEditorWindow::SongEditorWindow(Song* song) : m_setProportionalSnapAction->setCheckable(true); m_setProportionalSnapAction->setChecked(false); connect(m_setProportionalSnapAction, SIGNAL(triggered()), m_editor, SLOT(toggleProportionalSnap())); - connect(m_setProportionalSnapAction, SIGNAL(triggered()), this, SLOT(updateSnapLabel()) ); + connect(m_setProportionalSnapAction, SIGNAL(triggered()), this, SLOT(updateSnapLabel())); snapToolBar->addWidget( snap_lbl ); snapToolBar->addWidget( m_snappingComboBox ); @@ -1140,6 +1140,9 @@ void SongEditorWindow::adjustUiAfterProjectLoad() // it, it's very annyoing to manually bring up the song editor each time getGUI()->mainWindow()->workspace()->setActiveSubWindow( qobject_cast( parentWidget() ) ); - connect( qobject_cast( parentWidget() ), SIGNAL( focusLost() ), this, SLOT( lostFocus() ) ); + connect( qobject_cast( parentWidget() ), SIGNAL(focusLost()), this, SLOT(lostFocus())); m_editor->scrolled(0); } + + +} // namespace lmms::gui diff --git a/src/gui/editors/StepRecorderWidget.cpp b/src/gui/editors/StepRecorderWidget.cpp index 679901b0e..ffb45aa53 100644 --- a/src/gui/editors/StepRecorderWidget.cpp +++ b/src/gui/editors/StepRecorderWidget.cpp @@ -26,6 +26,9 @@ #include "TextFloat.h" #include "embed.h" +namespace lmms::gui +{ + StepRecorderWidget::StepRecorderWidget( QWidget * parent, const int ppb, @@ -168,3 +171,5 @@ void StepRecorderWidget::updateBoundaries() //(no need to change top and left as they are static) } + +} // namespace lmms::gui \ No newline at end of file diff --git a/src/gui/editors/TimeLineWidget.cpp b/src/gui/editors/TimeLineWidget.cpp index f5159d640..12b6a11f5 100644 --- a/src/gui/editors/TimeLineWidget.cpp +++ b/src/gui/editors/TimeLineWidget.cpp @@ -36,6 +36,9 @@ #include "GuiApplication.h" #include "TextFloat.h" +namespace lmms::gui +{ + QPixmap * TimeLineWidget::s_posMarkerPixmap = nullptr; @@ -85,12 +88,12 @@ TimeLineWidget::TimeLineWidget( const int xoff, const int yoff, const float ppb, setMouseTracking(true); m_pos.m_timeLine = this; - QTimer * updateTimer = new QTimer( this ); - connect( updateTimer, SIGNAL( timeout() ), - this, SLOT( updatePosition() ) ); + auto updateTimer = new QTimer(this); + connect( updateTimer, SIGNAL(timeout()), + this, SLOT(updatePosition())); updateTimer->start( 1000 / 60 ); // 60 fps - connect( Engine::getSong(), SIGNAL( timeSignatureChanged( int,int ) ), - this, SLOT( update() ) ); + connect( Engine::getSong(), SIGNAL(timeSignatureChanged(int,int)), + this, SLOT(update())); } @@ -118,23 +121,23 @@ void TimeLineWidget::setXOffset(const int x) void TimeLineWidget::addToolButtons( QToolBar * _tool_bar ) { - NStateButton * autoScroll = new NStateButton( _tool_bar ); + auto autoScroll = new NStateButton(_tool_bar); autoScroll->setGeneralToolTip( tr( "Auto scrolling" ) ); autoScroll->addState( embed::getIconPixmap( "autoscroll_on" ) ); autoScroll->addState( embed::getIconPixmap( "autoscroll_off" ) ); - connect( autoScroll, SIGNAL( changedState( int ) ), this, - SLOT( toggleAutoScroll( int ) ) ); + connect( autoScroll, SIGNAL(changedState(int)), this, + SLOT(toggleAutoScroll(int))); - NStateButton * loopPoints = new NStateButton( _tool_bar ); + auto loopPoints = new NStateButton(_tool_bar); loopPoints->setGeneralToolTip( tr( "Loop points" ) ); loopPoints->addState( embed::getIconPixmap( "loop_points_off" ) ); loopPoints->addState( embed::getIconPixmap( "loop_points_on" ) ); - connect( loopPoints, SIGNAL( changedState( int ) ), this, - SLOT( toggleLoopPoints( int ) ) ); - connect( this, SIGNAL( loopPointStateLoaded( int ) ), loopPoints, - SLOT( changeState( int ) ) ); + connect( loopPoints, SIGNAL(changedState(int)), this, + SLOT(toggleLoopPoints(int))); + connect( this, SIGNAL(loopPointStateLoaded(int)), loopPoints, + SLOT(changeState(int))); - NStateButton * behaviourAtStop = new NStateButton( _tool_bar ); + auto behaviourAtStop = new NStateButton(_tool_bar); behaviourAtStop->addState( embed::getIconPixmap( "back_to_zero" ), tr( "After stopping go back to beginning" ) ); @@ -144,10 +147,10 @@ void TimeLineWidget::addToolButtons( QToolBar * _tool_bar ) "started" ) ); behaviourAtStop->addState( embed::getIconPixmap( "keep_stop_position" ), tr( "After stopping keep position" ) ); - connect( behaviourAtStop, SIGNAL( changedState( int ) ), this, - SLOT( toggleBehaviourAtStop( int ) ) ); - connect( this, SIGNAL( loadBehaviourAtStop( int ) ), behaviourAtStop, - SLOT( changeState( int ) ) ); + connect( behaviourAtStop, SIGNAL(changedState(int)), this, + SLOT(toggleBehaviourAtStop(int))); + connect( this, SIGNAL(loadBehaviourAtStop(int)), behaviourAtStop, + SLOT(changeState(int))); behaviourAtStop->changeState( BackToStart ); _tool_bar->addWidget( autoScroll ); @@ -423,3 +426,6 @@ void TimeLineWidget::mouseReleaseEvent( QMouseEvent* event ) if ( m_action == SelectSongClip ) { emit selectionFinished(); } m_action = NoAction; } + + +} // namespace lmms::gui diff --git a/src/gui/editors/TrackContainerView.cpp b/src/gui/editors/TrackContainerView.cpp index 04034074e..351fe8295 100644 --- a/src/gui/editors/TrackContainerView.cpp +++ b/src/gui/editors/TrackContainerView.cpp @@ -44,8 +44,36 @@ #include "GuiApplication.h" #include "PluginFactory.h" +namespace lmms +{ + using namespace std; + +InstrumentLoaderThread::InstrumentLoaderThread( QObject *parent, InstrumentTrack *it, QString name ) : + QThread( parent ), + m_it( it ), + m_name( name ) +{ + m_containerThread = thread(); +} + + + + +void InstrumentLoaderThread::run() +{ + Instrument *i = m_it->loadInstrument(m_name, nullptr, + true /*always DnD*/); + QObject *parent = i->parent(); + i->setParent( 0 ); + i->moveToThread( m_containerThread ); + i->setParent( parent ); +} + +namespace gui +{ + TrackContainerView::TrackContainerView( TrackContainer * _tc ) : QWidget(), ModelView( nullptr, this ), @@ -61,12 +89,12 @@ TrackContainerView::TrackContainerView( TrackContainer * _tc ) : m_tc->setHook( this ); //keeps the direction of the widget, undepended on the locale setLayoutDirection( Qt::LeftToRight ); - QVBoxLayout * layout = new QVBoxLayout( this ); + auto layout = new QVBoxLayout(this); layout->setMargin( 0 ); layout->setSpacing( 0 ); layout->addWidget( m_scrollArea ); - QWidget * scrollContent = new QWidget; + auto scrollContent = new QWidget; m_scrollLayout = new QVBoxLayout( scrollContent ); m_scrollLayout->setMargin( 0 ); m_scrollLayout->setSpacing( 0 ); @@ -80,10 +108,10 @@ TrackContainerView::TrackContainerView( TrackContainer * _tc ) : setAcceptDrops( true ); - connect( Engine::getSong(), SIGNAL( timeSignatureChanged( int, int ) ), - this, SLOT( realignTracks() ) ); - connect( m_tc, SIGNAL( trackAdded( Track * ) ), - this, SLOT( createTrackView( Track * ) ), + connect( Engine::getSong(), SIGNAL(timeSignatureChanged(int,int)), + this, SLOT(realignTracks())); + connect( m_tc, SIGNAL(trackAdded(lmms::Track*)), + this, SLOT(createTrackView(lmms::Track*)), Qt::QueuedConnection ); } @@ -123,9 +151,9 @@ TrackView * TrackContainerView::addTrackView( TrackView * _tv ) { m_trackViews.push_back( _tv ); m_scrollLayout->addWidget( _tv ); - connect( this, SIGNAL( positionChanged( const TimePos & ) ), + connect( this, SIGNAL( positionChanged( const lmms::TimePos& ) ), _tv->getTrackContentWidget(), - SLOT( changePosition( const TimePos & ) ) ); + SLOT( changePosition( const lmms::TimePos& ) ) ); realignTracks(); return( _tv ); } @@ -230,12 +258,13 @@ void TrackContainerView::realignTracks() m_scrollArea->widget()->setFixedHeight( m_scrollArea->widget()->minimumSizeHint().height()); - for( trackViewList::iterator it = m_trackViews.begin(); - it != m_trackViews.end(); ++it ) + for (const auto& trackView : m_trackViews) { - ( *it )->show(); - ( *it )->update(); + trackView->show(); + trackView->update(); } + + emit tracksRealigned(); } @@ -246,10 +275,9 @@ TrackView * TrackContainerView::createTrackView( Track * _t ) //m_tc->addJournalCheckPoint(); // Avoid duplicating track views - for( trackViewList::iterator it = m_trackViews.begin(); - it != m_trackViews.end(); ++it ) + for (const auto& trackView : m_trackViews) { - if ( ( *it )->getTrack() == _t ) { return ( *it ); } + if (trackView->getTrack() == _t) { return trackView; } } return _t->createView( this ); @@ -282,15 +310,11 @@ const TrackView * TrackContainerView::trackViewAt( const int _y ) const // debug code // qDebug( "abs_y %d", abs_y ); - for( trackViewList::const_iterator it = m_trackViews.begin(); - it != m_trackViews.end(); ++it ) + for (const auto& trackView : m_trackViews) { const int y_cnt1 = y_cnt; - y_cnt += ( *it )->height(); - if( abs_y >= y_cnt1 && abs_y < y_cnt ) - { - return( *it ); - } + y_cnt += trackView->height(); + if (abs_y >= y_cnt1 && abs_y < y_cnt) { return trackView; } } return( nullptr ); } @@ -319,10 +343,9 @@ void TrackContainerView::setPixelsPerBar( int ppb ) m_ppb = ppb; // tell all TrackContentWidgets to update their background tile pixmap - for( trackViewList::Iterator it = m_trackViews.begin(); - it != m_trackViews.end(); ++it ) + for (const auto& trackView : m_trackViews) { - ( *it )->getTrackContentWidget()->updateBackground(); + trackView->getTrackContentWidget()->updateBackground(); } } @@ -371,11 +394,8 @@ void TrackContainerView::dropEvent( QDropEvent * _de ) QString value = StringPairDrag::decodeValue( _de ); if( type == "instrument" ) { - InstrumentTrack * it = dynamic_cast( - Track::create( Track::InstrumentTrack, - m_tc ) ); - InstrumentLoaderThread *ilt = new InstrumentLoaderThread( - this, it, value ); + auto it = dynamic_cast(Track::create(Track::InstrumentTrack, m_tc)); + auto ilt = new InstrumentLoaderThread(this, it, value); ilt->start(); //it->toggledInstrumentTrackButton( true ); _de->accept(); @@ -384,9 +404,7 @@ void TrackContainerView::dropEvent( QDropEvent * _de ) || type == "soundfontfile" || type == "vstpluginfile" || type == "patchfile" ) { - InstrumentTrack * it = dynamic_cast( - Track::create( Track::InstrumentTrack, - m_tc ) ); + auto it = dynamic_cast(Track::create(Track::InstrumentTrack, m_tc)); PluginFactory::PluginInfoAndKey piakn = getPluginFactory()->pluginSupportingExtension(FileItem::extension(value)); Instrument * i = it->loadInstrument(piakn.info.name(), &piakn.key); @@ -397,9 +415,7 @@ void TrackContainerView::dropEvent( QDropEvent * _de ) else if( type == "presetfile" ) { DataFile dataFile( value ); - InstrumentTrack * it = dynamic_cast( - Track::create( Track::InstrumentTrack, - m_tc ) ); + auto it = dynamic_cast(Track::create(Track::InstrumentTrack, m_tc)); it->setSimpleSerializing(); it->loadSettings( dataFile.content().toElement() ); //it->toggledInstrumentTrackButton( true ); @@ -459,13 +475,6 @@ TrackContainerView::scrollArea::scrollArea( TrackContainerView * _parent ) : -TrackContainerView::scrollArea::~scrollArea() -{ -} - - - - void TrackContainerView::scrollArea::wheelEvent( QWheelEvent * _we ) { // always pass wheel-event to parent-widget (song-editor @@ -482,23 +491,17 @@ void TrackContainerView::scrollArea::wheelEvent( QWheelEvent * _we ) -InstrumentLoaderThread::InstrumentLoaderThread( QObject *parent, InstrumentTrack *it, QString name ) : - QThread( parent ), - m_it( it ), - m_name( name ) +unsigned int TrackContainerView::totalHeightOfTracks() const { - m_containerThread = thread(); + unsigned int heightSum = 0; + for (auto & trackView : m_trackViews) + { + heightSum += trackView->getTrack()->getHeight(); + } + return heightSum; } +} // namespace gui - -void InstrumentLoaderThread::run() -{ - Instrument *i = m_it->loadInstrument(m_name, nullptr, - true /*always DnD*/); - QObject *parent = i->parent(); - i->setParent( 0 ); - i->moveToThread( m_containerThread ); - i->setParent( parent ); -} +} // namespace lmms diff --git a/src/gui/embed.cpp b/src/gui/embed.cpp index 6ce4b5bd7..d934adcde 100644 --- a/src/gui/embed.cpp +++ b/src/gui/embed.cpp @@ -28,7 +28,7 @@ #include #include "embed.h" -namespace embed +namespace lmms::embed { QPixmap getIconPixmap(const QString& pixmapName, @@ -86,6 +86,4 @@ QString getText( const char * name ) } -} - - +} // namespace lmms::embed diff --git a/src/gui/instrument/EnvelopeAndLfoView.cpp b/src/gui/instrument/EnvelopeAndLfoView.cpp index 3ca55c9a8..df0e1120d 100644 --- a/src/gui/instrument/EnvelopeAndLfoView.cpp +++ b/src/gui/instrument/EnvelopeAndLfoView.cpp @@ -42,11 +42,17 @@ #include "TextFloat.h" #include "Track.h" +namespace lmms +{ extern const float SECS_PER_ENV_SEGMENT; extern const float SECS_PER_LFO_OSCILLATION; +namespace gui +{ + + const int ENV_GRAPH_X = 6; const int ENV_GRAPH_Y = 6; @@ -160,29 +166,28 @@ EnvelopeAndLfoView::EnvelopeAndLfoView( QWidget * _parent ) : m_lfoAmountKnob->move( LFO_AMOUNT_KNOB_X, LFO_KNOB_Y ); m_lfoAmountKnob->setHintText( tr( "Modulation amount:" ), "" ); - - PixmapButton * sin_lfo_btn = new PixmapButton( this, nullptr ); + auto sin_lfo_btn = new PixmapButton(this, nullptr); sin_lfo_btn->move( LFO_SHAPES_X, LFO_SHAPES_Y ); sin_lfo_btn->setActiveGraphic( embed::getIconPixmap( "sin_wave_active" ) ); sin_lfo_btn->setInactiveGraphic( embed::getIconPixmap( "sin_wave_inactive" ) ); - PixmapButton * triangle_lfo_btn = new PixmapButton( this, nullptr ); + auto triangle_lfo_btn = new PixmapButton(this, nullptr); triangle_lfo_btn->move( LFO_SHAPES_X+15, LFO_SHAPES_Y ); triangle_lfo_btn->setActiveGraphic( embed::getIconPixmap( "triangle_wave_active" ) ); triangle_lfo_btn->setInactiveGraphic( embed::getIconPixmap( "triangle_wave_inactive" ) ); - PixmapButton * saw_lfo_btn = new PixmapButton( this, nullptr ); + auto saw_lfo_btn = new PixmapButton(this, nullptr); saw_lfo_btn->move( LFO_SHAPES_X+30, LFO_SHAPES_Y ); saw_lfo_btn->setActiveGraphic( embed::getIconPixmap( "saw_wave_active" ) ); saw_lfo_btn->setInactiveGraphic( embed::getIconPixmap( "saw_wave_inactive" ) ); - PixmapButton * sqr_lfo_btn = new PixmapButton( this, nullptr ); + auto sqr_lfo_btn = new PixmapButton(this, nullptr); sqr_lfo_btn->move( LFO_SHAPES_X+45, LFO_SHAPES_Y ); sqr_lfo_btn->setActiveGraphic( embed::getIconPixmap( "square_wave_active" ) ); @@ -196,10 +201,10 @@ EnvelopeAndLfoView::EnvelopeAndLfoView( QWidget * _parent ) : m_userLfoBtn->setInactiveGraphic( embed::getIconPixmap( "usr_wave_inactive" ) ); - connect( m_userLfoBtn, SIGNAL( toggled( bool ) ), - this, SLOT( lfoUserWaveChanged() ) ); + connect( m_userLfoBtn, SIGNAL(toggled(bool)), + this, SLOT(lfoUserWaveChanged())); - PixmapButton * random_lfo_btn = new PixmapButton( this, nullptr ); + auto random_lfo_btn = new PixmapButton(this, nullptr); random_lfo_btn->move( LFO_SHAPES_X+60, LFO_SHAPES_Y ); random_lfo_btn->setActiveGraphic( embed::getIconPixmap( "random_wave_active" ) ); @@ -528,4 +533,6 @@ void EnvelopeAndLfoView::lfoUserWaveChanged() +} // namespace gui +} // namespace lmms \ No newline at end of file diff --git a/src/gui/instrument/InstrumentFunctionViews.cpp b/src/gui/instrument/InstrumentFunctionViews.cpp index c10b7d349..99c68a5ed 100644 --- a/src/gui/instrument/InstrumentFunctionViews.cpp +++ b/src/gui/instrument/InstrumentFunctionViews.cpp @@ -35,6 +35,9 @@ #include "TempoSyncKnob.h" +namespace lmms::gui +{ + InstrumentFunctionNoteStackingView::InstrumentFunctionNoteStackingView( InstrumentFunctionNoteStacking* cc, QWidget* parent ) : QWidget( parent ), ModelView( nullptr, this ), @@ -43,17 +46,17 @@ InstrumentFunctionNoteStackingView::InstrumentFunctionNoteStackingView( Instrume m_chordsComboBox( new ComboBox() ), m_chordRangeKnob( new Knob( knobBright_26 ) ) { - QHBoxLayout* topLayout = new QHBoxLayout( this ); + auto topLayout = new QHBoxLayout(this); topLayout->setMargin( 0 ); topLayout->addWidget( m_chordsGroupBox ); - QGridLayout* mainLayout = new QGridLayout( m_chordsGroupBox ); + auto mainLayout = new QGridLayout(m_chordsGroupBox); mainLayout->setContentsMargins( 8, 18, 8, 8 ); mainLayout->setColumnStretch( 0, 1 ); mainLayout->setHorizontalSpacing( 20 ); mainLayout->setVerticalSpacing( 1 ); - QLabel* chordLabel = new QLabel( tr( "Chord:" ) ); + auto chordLabel = new QLabel(tr("Chord:")); chordLabel->setFont( pointSize<8>( chordLabel->font() ) ); m_chordRangeKnob->setLabel( tr( "RANGE" ) ); @@ -105,11 +108,11 @@ InstrumentFunctionArpeggioView::InstrumentFunctionArpeggioView( InstrumentFuncti m_arpDirectionComboBox( new ComboBox() ), m_arpModeComboBox( new ComboBox() ) { - QHBoxLayout* topLayout = new QHBoxLayout( this ); + auto topLayout = new QHBoxLayout(this); topLayout->setMargin( 0 ); topLayout->addWidget( m_arpGroupBox ); - QGridLayout* mainLayout = new QGridLayout( m_arpGroupBox ); + auto mainLayout = new QGridLayout(m_arpGroupBox); mainLayout->setContentsMargins( 8, 18, 8, 8 ); mainLayout->setColumnStretch( 0, 1 ); mainLayout->setHorizontalSpacing( 20 ); @@ -142,14 +145,13 @@ InstrumentFunctionArpeggioView::InstrumentFunctionArpeggioView( InstrumentFuncti m_arpGateKnob->setLabel( tr( "GATE" ) ); m_arpGateKnob->setHintText( tr( "Arpeggio gate:" ), tr( "%" ) ); - - QLabel* arpChordLabel = new QLabel( tr( "Chord:" ) ); + auto arpChordLabel = new QLabel(tr("Chord:")); arpChordLabel->setFont( pointSize<8>( arpChordLabel->font() ) ); - QLabel* arpDirectionLabel = new QLabel( tr( "Direction:" ) ); + auto arpDirectionLabel = new QLabel(tr("Direction:")); arpDirectionLabel->setFont( pointSize<8>( arpDirectionLabel->font() ) ); - QLabel* arpModeLabel = new QLabel( tr( "Mode:" ) ); + auto arpModeLabel = new QLabel(tr("Mode:")); arpModeLabel->setFont( pointSize<8>( arpModeLabel->font() ) ); mainLayout->addWidget( arpChordLabel, 0, 0 ); @@ -201,4 +203,4 @@ void InstrumentFunctionArpeggioView::modelChanged() - +} // namespace lmms::gui diff --git a/src/gui/instrument/InstrumentMidiIOView.cpp b/src/gui/instrument/InstrumentMidiIOView.cpp index c85ee75be..8d7cf9dda 100644 --- a/src/gui/instrument/InstrumentMidiIOView.cpp +++ b/src/gui/instrument/InstrumentMidiIOView.cpp @@ -37,6 +37,9 @@ #include "LcdSpinBox.h" #include "MidiClient.h" +namespace lmms::gui +{ + InstrumentMidiIOView::InstrumentMidiIOView( QWidget* parent ) : QWidget( parent ), @@ -44,12 +47,12 @@ InstrumentMidiIOView::InstrumentMidiIOView( QWidget* parent ) : m_rpBtn( nullptr ), m_wpBtn( nullptr ) { - QVBoxLayout* layout = new QVBoxLayout( this ); + auto layout = new QVBoxLayout(this); layout->setMargin( 5 ); m_midiInputGroupBox = new GroupBox( tr( "ENABLE MIDI INPUT" ) ); layout->addWidget( m_midiInputGroupBox ); - QHBoxLayout* midiInputLayout = new QHBoxLayout( m_midiInputGroupBox ); + auto midiInputLayout = new QHBoxLayout(m_midiInputGroupBox); midiInputLayout->setContentsMargins( 8, 18, 8, 8 ); midiInputLayout->setSpacing( 4 ); @@ -70,17 +73,17 @@ InstrumentMidiIOView::InstrumentMidiIOView( QWidget* parent ) : midiInputLayout->addWidget( m_fixedInputVelocitySpinBox ); midiInputLayout->addStretch(); - connect( m_midiInputGroupBox->ledButton(), SIGNAL( toggled( bool ) ), - m_inputChannelSpinBox, SLOT( setEnabled( bool ) ) ); - connect( m_midiInputGroupBox->ledButton(), SIGNAL( toggled( bool ) ), - m_fixedInputVelocitySpinBox, SLOT( setEnabled( bool ) ) ); + connect( m_midiInputGroupBox->ledButton(), SIGNAL(toggled(bool)), + m_inputChannelSpinBox, SLOT(setEnabled(bool))); + connect( m_midiInputGroupBox->ledButton(), SIGNAL(toggled(bool)), + m_fixedInputVelocitySpinBox, SLOT(setEnabled(bool))); m_midiOutputGroupBox = new GroupBox( tr( "ENABLE MIDI OUTPUT" ) ); layout->addWidget( m_midiOutputGroupBox ); - QHBoxLayout* midiOutputLayout = new QHBoxLayout( m_midiOutputGroupBox ); + auto midiOutputLayout = new QHBoxLayout(m_midiOutputGroupBox); midiOutputLayout->setContentsMargins( 8, 18, 8, 8 ); midiOutputLayout->setSpacing( 4 ); @@ -115,12 +118,12 @@ InstrumentMidiIOView::InstrumentMidiIOView( QWidget* parent ) : midiOutputLayout->addWidget( m_fixedOutputNoteSpinBox ); midiOutputLayout->addStretch(); - connect( m_midiOutputGroupBox->ledButton(), SIGNAL( toggled( bool ) ), - m_fixedOutputVelocitySpinBox, SLOT( setEnabled( bool ) ) ); - connect( m_midiOutputGroupBox->ledButton(), SIGNAL( toggled( bool ) ), - m_outputProgramSpinBox, SLOT( setEnabled( bool ) ) ); - connect( m_midiOutputGroupBox->ledButton(), SIGNAL( toggled( bool ) ), - m_fixedOutputNoteSpinBox, SLOT( setEnabled( bool ) ) ); + connect( m_midiOutputGroupBox->ledButton(), SIGNAL(toggled(bool)), + m_fixedOutputVelocitySpinBox, SLOT(setEnabled(bool))); + connect( m_midiOutputGroupBox->ledButton(), SIGNAL(toggled(bool)), + m_outputProgramSpinBox, SLOT(setEnabled(bool))); + connect( m_midiOutputGroupBox->ledButton(), SIGNAL(toggled(bool)), + m_fixedOutputNoteSpinBox, SLOT(setEnabled(bool))); if( !Engine::audioEngine()->midiClient()->isRaw() ) { @@ -141,16 +144,15 @@ InstrumentMidiIOView::InstrumentMidiIOView( QWidget* parent ) : midiOutputLayout->insertWidget( 0, m_wpBtn ); } -#define PROVIDE_CUSTOM_BASE_VELOCITY_UI -#ifdef PROVIDE_CUSTOM_BASE_VELOCITY_UI - GroupBox* baseVelocityGroupBox = new GroupBox( tr( "CUSTOM BASE VELOCITY" ) ); + auto baseVelocityGroupBox = new GroupBox(tr("CUSTOM BASE VELOCITY")); layout->addWidget( baseVelocityGroupBox ); - QVBoxLayout* baseVelocityLayout = new QVBoxLayout( baseVelocityGroupBox ); + auto baseVelocityLayout = new QVBoxLayout(baseVelocityGroupBox); baseVelocityLayout->setContentsMargins( 8, 18, 8, 8 ); baseVelocityLayout->setSpacing( 6 ); - QLabel* baseVelocityHelp = new QLabel( tr( "Specify the velocity normalization base for MIDI-based instruments at 100% note velocity." ) ); + auto baseVelocityHelp + = new QLabel(tr("Specify the velocity normalization base for MIDI-based instruments at 100% note velocity.")); baseVelocityHelp->setWordWrap( true ); baseVelocityHelp->setFont( pointSize<8>( baseVelocityHelp->font() ) ); @@ -161,9 +163,8 @@ InstrumentMidiIOView::InstrumentMidiIOView( QWidget* parent ) : m_baseVelocitySpinBox->setEnabled( false ); baseVelocityLayout->addWidget( m_baseVelocitySpinBox ); - connect( baseVelocityGroupBox->ledButton(), SIGNAL( toggled( bool ) ), - m_baseVelocitySpinBox, SLOT( setEnabled( bool ) ) ); -#endif + connect( baseVelocityGroupBox->ledButton(), SIGNAL(toggled(bool)), + m_baseVelocitySpinBox, SLOT(setEnabled(bool))); layout->addStretch(); } @@ -171,16 +172,10 @@ InstrumentMidiIOView::InstrumentMidiIOView( QWidget* parent ) : -InstrumentMidiIOView::~InstrumentMidiIOView() -{ -} - - - void InstrumentMidiIOView::modelChanged() { - MidiPort * mp = castModel(); + auto mp = castModel(); m_midiInputGroupBox->setModel( &mp->m_readableModel ); m_inputChannelSpinBox->setModel( &mp->m_inputChannelModel ); @@ -192,9 +187,7 @@ void InstrumentMidiIOView::modelChanged() m_fixedOutputNoteSpinBox->setModel( &mp->m_fixedOutputNoteModel ); m_outputProgramSpinBox->setModel( &mp->m_outputProgramModel ); -#ifdef PROVIDE_CUSTOM_BASE_VELOCITY_UI m_baseVelocitySpinBox->setModel( &mp->m_baseVelocityModel ); -#endif if( m_rpBtn ) { @@ -206,3 +199,5 @@ void InstrumentMidiIOView::modelChanged() } } + +} // namespace lmms::gui diff --git a/src/gui/instrument/InstrumentMiscView.cpp b/src/gui/instrument/InstrumentMiscView.cpp index ad22c51a2..ae7bd85cd 100644 --- a/src/gui/instrument/InstrumentMiscView.cpp +++ b/src/gui/instrument/InstrumentMiscView.cpp @@ -36,21 +36,26 @@ #include "LedCheckBox.h" +namespace lmms::gui +{ + + InstrumentMiscView::InstrumentMiscView(InstrumentTrack *it, QWidget *parent) : QWidget(parent) { - QVBoxLayout *layout = new QVBoxLayout(this); + auto layout = new QVBoxLayout(this); layout->setMargin(5); // Master pitch toggle - m_pitchGroupBox = new GroupBox(tr("MASTER PITCH")); + m_pitchGroupBox = new GroupBox(tr("GLOBAL TRANSPOSITION")); m_pitchGroupBox->setModel(&it->m_useMasterPitchModel); layout->addWidget(m_pitchGroupBox); - QHBoxLayout *masterPitchLayout = new QHBoxLayout(m_pitchGroupBox); + auto masterPitchLayout = new QHBoxLayout(m_pitchGroupBox); masterPitchLayout->setContentsMargins(8, 18, 8, 8); - QLabel *tlabel = new QLabel(tr("Enables the use of master pitch")); + auto tlabel = new QLabel(tr("Enables the use of global transposition")); + tlabel->setWordWrap(true); tlabel->setFont(pointSize<8>(tlabel->font())); masterPitchLayout->addWidget(tlabel); @@ -59,17 +64,17 @@ InstrumentMiscView::InstrumentMiscView(InstrumentTrack *it, QWidget *parent) : m_microtunerGroupBox->setModel(it->m_microtuner.enabledModel()); layout->addWidget(m_microtunerGroupBox); - QVBoxLayout *microtunerLayout = new QVBoxLayout(m_microtunerGroupBox); + auto microtunerLayout = new QVBoxLayout(m_microtunerGroupBox); microtunerLayout->setContentsMargins(8, 18, 8, 8); - QLabel *scaleLabel = new QLabel(tr("Active scale:")); + auto scaleLabel = new QLabel(tr("Active scale:")); microtunerLayout->addWidget(scaleLabel); m_scaleCombo = new ComboBox(); m_scaleCombo->setModel(it->m_microtuner.scaleModel()); microtunerLayout->addWidget(m_scaleCombo); - QLabel *keymapLabel = new QLabel(tr("Active keymap:")); + auto keymapLabel = new QLabel(tr("Active keymap:")); microtunerLayout->addWidget(keymapLabel); m_keymapCombo = new ComboBox(); @@ -97,3 +102,6 @@ InstrumentMiscView::InstrumentMiscView(InstrumentTrack *it, QWidget *parent) : // Fill remaining space layout->addStretch(); } + + +} // namespace lmms::gui diff --git a/src/gui/instrument/InstrumentSoundShapingView.cpp b/src/gui/instrument/InstrumentSoundShapingView.cpp index 47dc389aa..dd5c14a09 100644 --- a/src/gui/instrument/InstrumentSoundShapingView.cpp +++ b/src/gui/instrument/InstrumentSoundShapingView.cpp @@ -34,6 +34,8 @@ #include "TabWidget.h" +namespace lmms::gui +{ const int TARGETS_TABWIDGET_X = 4; const int TARGETS_TABWIDGET_Y = 5; @@ -135,4 +137,5 @@ void InstrumentSoundShapingView::modelChanged() - + +} // namespace lmms::gui diff --git a/src/gui/instrument/InstrumentTrackWindow.cpp b/src/gui/instrument/InstrumentTrackWindow.cpp index 6c4acbfa1..70c11976a 100644 --- a/src/gui/instrument/InstrumentTrackWindow.cpp +++ b/src/gui/instrument/InstrumentTrackWindow.cpp @@ -69,6 +69,10 @@ #include "TrackLabelButton.h" +namespace lmms::gui +{ + + const int INSTRUMENT_WIDTH = 254; const int INSTRUMENT_HEIGHT = INSTRUMENT_WIDTH; const int PIANO_HEIGHT = 80; @@ -85,27 +89,27 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) : // init own layout + widgets setFocusPolicy( Qt::StrongFocus ); - QVBoxLayout * vlayout = new QVBoxLayout( this ); + auto vlayout = new QVBoxLayout(this); vlayout->setMargin( 0 ); vlayout->setSpacing( 0 ); - TabWidget* generalSettingsWidget = new TabWidget( tr( "GENERAL SETTINGS" ), this ); + auto generalSettingsWidget = new TabWidget(tr("GENERAL SETTINGS"), this); - QVBoxLayout* generalSettingsLayout = new QVBoxLayout( generalSettingsWidget ); + auto generalSettingsLayout = new QVBoxLayout(generalSettingsWidget); generalSettingsLayout->setContentsMargins( 8, 18, 8, 8 ); generalSettingsLayout->setSpacing( 6 ); - QWidget* nameAndChangeTrackWidget = new QWidget( generalSettingsWidget ); - QHBoxLayout* nameAndChangeTrackLayout = new QHBoxLayout( nameAndChangeTrackWidget ); + auto nameAndChangeTrackWidget = new QWidget(generalSettingsWidget); + auto nameAndChangeTrackLayout = new QHBoxLayout(nameAndChangeTrackWidget); nameAndChangeTrackLayout->setContentsMargins( 0, 0, 0, 0 ); nameAndChangeTrackLayout->setSpacing( 2 ); // setup line edit for changing instrument track name m_nameLineEdit = new QLineEdit; m_nameLineEdit->setFont( pointSize<9>( m_nameLineEdit->font() ) ); - connect( m_nameLineEdit, SIGNAL( textChanged( const QString & ) ), - this, SLOT( textChanged( const QString & ) ) ); + connect( m_nameLineEdit, SIGNAL( textChanged( const QString& ) ), + this, SLOT( textChanged( const QString& ) ) ); m_nameLineEdit->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred)); nameAndChangeTrackLayout->addWidget(m_nameLineEdit, 1); @@ -113,23 +117,32 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) : // set up left/right arrows for changing instrument m_leftRightNav = new LeftRightNav(this); - connect( m_leftRightNav, SIGNAL( onNavLeft() ), this, - SLOT( viewPrevInstrument() ) ); - connect( m_leftRightNav, SIGNAL( onNavRight() ), this, - SLOT( viewNextInstrument() ) ); + connect( m_leftRightNav, SIGNAL(onNavLeft()), this, + SLOT(viewPrevInstrument())); + connect( m_leftRightNav, SIGNAL(onNavRight()), this, + SLOT(viewNextInstrument())); // m_leftRightNav->setShortcuts(); nameAndChangeTrackLayout->addWidget(m_leftRightNav); generalSettingsLayout->addWidget( nameAndChangeTrackWidget ); - - - QGridLayout* basicControlsLayout = new QGridLayout; + auto basicControlsLayout = new QGridLayout; basicControlsLayout->setHorizontalSpacing(3); basicControlsLayout->setVerticalSpacing(0); basicControlsLayout->setContentsMargins(0, 0, 0, 0); +#if QT_VERSION < 0x50C00 + // Workaround for a bug in Qt versions below 5.12, + // where argument-dependent-lookup fails for QFlags operators + // declared inside a namepsace. + // This affects the Q_DECLARE_OPERATORS_FOR_FLAGS macro in Instrument.h + // See also: https://codereview.qt-project.org/c/qt/qtbase/+/225348 + + using ::operator|; + +#endif + QString labelStyleSheet = "font-size: 6pt;"; Qt::Alignment labelAlignment = Qt::AlignHCenter | Qt::AlignTop; Qt::Alignment widgetAlignment = Qt::AlignHCenter | Qt::AlignCenter; @@ -142,7 +155,7 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) : basicControlsLayout->addWidget( m_volumeKnob, 0, 0 ); basicControlsLayout->setAlignment( m_volumeKnob, widgetAlignment ); - QLabel *label = new QLabel( tr( "VOL" ), this ); + auto label = new QLabel(tr("VOL"), this); label->setStyleSheet( labelStyleSheet ); basicControlsLayout->addWidget( label, 1, 0); basicControlsLayout->setAlignment( label, labelAlignment ); @@ -203,10 +216,10 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) : basicControlsLayout->addWidget( label, 1, 6); basicControlsLayout->setAlignment( label, labelAlignment ); - QPushButton* saveSettingsBtn = new QPushButton( embed::getIconPixmap( "project_save" ), QString() ); + auto saveSettingsBtn = new QPushButton(embed::getIconPixmap("project_save"), QString()); saveSettingsBtn->setMinimumSize( 32, 32 ); - connect( saveSettingsBtn, SIGNAL( clicked() ), this, SLOT( saveSettingsBtnClicked() ) ); + connect( saveSettingsBtn, SIGNAL(clicked()), this, SLOT(saveSettingsBtnClicked())); saveSettingsBtn->setToolTip(tr("Save current instrument track settings in a preset file")); @@ -231,8 +244,8 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) : m_ssView = new InstrumentSoundShapingView( m_tabWidget ); // FUNC tab - QWidget* instrumentFunctions = new QWidget( m_tabWidget ); - QVBoxLayout* instrumentFunctionsLayout = new QVBoxLayout( instrumentFunctions ); + auto instrumentFunctions = new QWidget(m_tabWidget); + auto instrumentFunctionsLayout = new QVBoxLayout(instrumentFunctions); instrumentFunctionsLayout->setMargin( 5 ); m_noteStackingView = new InstrumentFunctionNoteStackingView( &m_track->m_noteStacking ); m_arpeggioView = new InstrumentFunctionArpeggioView( &m_track->m_arpeggio ); @@ -330,13 +343,13 @@ void InstrumentTrackWindow::modelChanged() m_nameLineEdit->setText( m_track->name() ); - m_track->disconnect( SIGNAL( nameChanged() ), this ); - m_track->disconnect( SIGNAL( instrumentChanged() ), this ); + m_track->disconnect( SIGNAL(nameChanged()), this ); + m_track->disconnect( SIGNAL(instrumentChanged()), this ); - connect( m_track, SIGNAL( nameChanged() ), - this, SLOT( updateName() ) ); - connect( m_track, SIGNAL( instrumentChanged() ), - this, SLOT( updateInstrumentView() ) ); + connect( m_track, SIGNAL(nameChanged()), + this, SLOT(updateName())); + connect( m_track, SIGNAL(instrumentChanged()), + this, SLOT(updateInstrumentView())); m_volumeKnob->setModel( &m_track->m_volumeModel ); m_panningKnob->setModel( &m_track->m_panningModel ); @@ -679,3 +692,5 @@ void InstrumentTrackWindow::adjustTabSize(QWidget *w) w->setMinimumSize(INSTRUMENT_WIDTH - 4, INSTRUMENT_HEIGHT - 4 - 1); } + +} // namespace lmms::gui diff --git a/src/gui/instrument/InstrumentView.cpp b/src/gui/instrument/InstrumentView.cpp index eaa49df10..fe2c04cfb 100644 --- a/src/gui/instrument/InstrumentView.cpp +++ b/src/gui/instrument/InstrumentView.cpp @@ -29,6 +29,8 @@ #include "InstrumentTrack.h" #include "InstrumentTrackWindow.h" +namespace lmms::gui +{ InstrumentView::InstrumentView( Instrument * _Instrument, QWidget * _parent ) : PluginView( _Instrument, _parent ) @@ -57,14 +59,14 @@ void InstrumentView::setModel( Model * _model, bool ) { ModelView::setModel( _model ); instrumentTrackWindow()->setWindowIcon( model()->logo()->pixmap() ); - connect( model(), SIGNAL( destroyed( QObject * ) ), this, SLOT( close() ) ); + connect( model(), SIGNAL(destroyed(QObject*)), this, SLOT(close())); } } -InstrumentTrackWindow * InstrumentView::instrumentTrackWindow( void ) +InstrumentTrackWindow * InstrumentView::instrumentTrackWindow() { return( dynamic_cast( parentWidget()->parentWidget() ) ); @@ -73,7 +75,5 @@ InstrumentTrackWindow * InstrumentView::instrumentTrackWindow( void ) -InstrumentViewFixedSize::~InstrumentViewFixedSize() -{ -} +} // namespace lmms::gui \ No newline at end of file diff --git a/src/gui/instrument/PianoView.cpp b/src/gui/instrument/PianoView.cpp index 78962d938..7478c8204 100644 --- a/src/gui/instrument/PianoView.cpp +++ b/src/gui/instrument/PianoView.cpp @@ -56,9 +56,13 @@ #include "StringPairDrag.h" +namespace lmms::gui +{ + + /*! The scale of C Major - white keys only. */ -Keys WhiteKeys[] = +auto WhiteKeys = std::array { Key_C, Key_D, Key_E, Key_F, Key_G, Key_A, Key_H } ; @@ -137,11 +141,11 @@ PianoView::PianoView(QWidget *parent) : m_pianoScroll->setValue(Octave_3 * Piano::WhiteKeysPerOctave); // and connect it to this widget - connect( m_pianoScroll, SIGNAL( valueChanged( int ) ), - this, SLOT( pianoScrolled( int ) ) ); + connect( m_pianoScroll, SIGNAL(valueChanged(int)), + this, SLOT(pianoScrolled(int))); // create a layout for ourselves - QVBoxLayout * layout = new QVBoxLayout( this ); + auto layout = new QVBoxLayout(this); layout->setSpacing( 0 ); layout->setMargin( 0 ); layout->addSpacing( PIANO_BASE+PW_WHITE_KEY_HEIGHT ); @@ -207,7 +211,7 @@ int PianoView::getKeyFromKeyEvent( QKeyEvent * _ke ) case 13: return 30; // = case 27: return 31; // ] } -#endif +#endif // LMMS_BUILD_WIN32 #if defined(LMMS_BUILD_LINUX) || defined(LMMS_BUILD_OPENBSD) || defined(LMMS_BUILD_FREEBSD) switch( k ) { @@ -288,7 +292,7 @@ int PianoView::getKeyFromKeyEvent( QKeyEvent * _ke ) case 29: return 27; // 0 = d'# case 35: return 28; // P = e' } -#endif +#endif // LMMS_BUILD_APPLE return -100; } @@ -982,5 +986,5 @@ void PianoView::paintEvent( QPaintEvent * ) } - +} // namespace lmms::gui diff --git a/src/gui/menus/MidiPortMenu.cpp b/src/gui/menus/MidiPortMenu.cpp index 1cdb43f68..b1ddf71c9 100644 --- a/src/gui/menus/MidiPortMenu.cpp +++ b/src/gui/menus/MidiPortMenu.cpp @@ -26,6 +26,8 @@ #include "MidiPortMenu.h" #include "gui_templates.h" +namespace lmms::gui +{ MidiPortMenu::MidiPortMenu( MidiPort::Modes _mode ) : @@ -33,32 +35,26 @@ MidiPortMenu::MidiPortMenu( MidiPort::Modes _mode ) : m_mode( _mode ) { setFont( pointSize<9>( font() ) ); - connect( this, SIGNAL( triggered( QAction * ) ), - this, SLOT( activatedPort( QAction * ) ) ); + connect( this, SIGNAL(triggered(QAction*)), + this, SLOT(activatedPort(QAction*))); } -MidiPortMenu::~MidiPortMenu() -{ -} - - - void MidiPortMenu::modelChanged() { - MidiPort * mp = castModel(); + auto mp = castModel(); if( m_mode == MidiPort::Input ) { - connect( mp, SIGNAL( readablePortsChanged() ), - this, SLOT( updateMenu() ) ); + connect( mp, SIGNAL(readablePortsChanged()), + this, SLOT(updateMenu())); } else if( m_mode == MidiPort::Output ) { - connect( mp, SIGNAL( writablePortsChanged() ), - this, SLOT( updateMenu() ) ); + connect( mp, SIGNAL(writablePortsChanged()), + this, SLOT(updateMenu())); } updateMenu(); } @@ -85,7 +81,7 @@ void MidiPortMenu::activatedPort( QAction * _item ) void MidiPortMenu::updateMenu() { - MidiPort * mp = castModel(); + auto mp = castModel(); const MidiPort::Map & map = ( m_mode == MidiPort::Input ) ? mp->readablePorts() : mp->writablePorts(); clear(); @@ -99,6 +95,6 @@ void MidiPortMenu::updateMenu() } - +} // namespace lmms::gui diff --git a/src/gui/menus/RecentProjectsMenu.cpp b/src/gui/menus/RecentProjectsMenu.cpp index dc7b3bd2b..050450dd0 100644 --- a/src/gui/menus/RecentProjectsMenu.cpp +++ b/src/gui/menus/RecentProjectsMenu.cpp @@ -10,15 +10,19 @@ #include "GuiApplication.h" #include "MainWindow.h" +namespace lmms::gui +{ + + RecentProjectsMenu::RecentProjectsMenu(QWidget *parent) : QMenu(tr( "&Recently Opened Projects" ), parent) { setIcon(embed::getIconPixmap( "project_open_recent" )); - connect( this, SIGNAL( aboutToShow() ), - this, SLOT(fillMenu() ) ); - connect( this, SIGNAL( triggered( QAction * ) ), - this, SLOT(openProject(QAction * ) ) ); + connect( this, SIGNAL(aboutToShow()), + this, SLOT(fillMenu())); + connect( this, SIGNAL(triggered(QAction*)), + this, SLOT(openProject(QAction*))); } @@ -76,3 +80,6 @@ void RecentProjectsMenu::openProject(QAction * _action ) mainWindow->setCursor( Qt::ArrowCursor ); } } + + +} // namespace lmms::gui \ No newline at end of file diff --git a/src/gui/menus/TemplatesMenu.cpp b/src/gui/menus/TemplatesMenu.cpp index 9f89e3a9f..a73c81071 100644 --- a/src/gui/menus/TemplatesMenu.cpp +++ b/src/gui/menus/TemplatesMenu.cpp @@ -8,14 +8,19 @@ #include "GuiApplication.h" #include "MainWindow.h" + +namespace lmms::gui +{ + + TemplatesMenu::TemplatesMenu(QWidget *parent) : QMenu(tr("New from template"), parent) { setIcon(embed::getIconPixmap("project_new")); - connect( this, SIGNAL( aboutToShow() ), SLOT( fillTemplatesMenu() ) ); - connect( this, SIGNAL( triggered( QAction * ) ), - SLOT( createNewProjectFromTemplate( QAction * ) ) ); + connect( this, SIGNAL(aboutToShow()), SLOT(fillTemplatesMenu())); + connect( this, SIGNAL(triggered(QAction*)), + SLOT(createNewProjectFromTemplate(QAction*))); } @@ -67,3 +72,6 @@ void TemplatesMenu::addTemplatesFromDir( const QDir& dir ) { #endif } } + + +} // namespace lmms::gui diff --git a/src/gui/modals/AboutDialog.cpp b/src/gui/modals/AboutDialog.cpp index e3f016b5e..6c6b435eb 100644 --- a/src/gui/modals/AboutDialog.cpp +++ b/src/gui/modals/AboutDialog.cpp @@ -29,6 +29,8 @@ #include "versioninfo.h" +namespace lmms::gui +{ AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent), @@ -58,3 +60,5 @@ AboutDialog::AboutDialog(QWidget* parent) : involvedLabel->setPlainText( embed::getText( "CONTRIBUTORS" ) ); } + +} // namespace lmms::gui \ No newline at end of file diff --git a/src/gui/modals/ColorChooser.cpp b/src/gui/modals/ColorChooser.cpp index b25aa97be..d178debe5 100644 --- a/src/gui/modals/ColorChooser.cpp +++ b/src/gui/modals/ColorChooser.cpp @@ -24,6 +24,8 @@ #include +namespace lmms::gui +{ //! Set global palette via array, checking bounds @@ -91,3 +93,6 @@ QVector ColorChooser::nicePalette (int base) } return result; } + + +} // namespace lmms::gui diff --git a/src/gui/modals/ControllerConnectionDialog.cpp b/src/gui/modals/ControllerConnectionDialog.cpp index cab90a53f..149303da8 100644 --- a/src/gui/modals/ControllerConnectionDialog.cpp +++ b/src/gui/modals/ControllerConnectionDialog.cpp @@ -45,6 +45,9 @@ #include "embed.h" +namespace lmms +{ + class AutoDetectMidiController : public MidiController { public: @@ -57,9 +60,7 @@ public: } - virtual ~AutoDetectMidiController() - { - } + ~AutoDetectMidiController() override = default; void processInEvent( const MidiEvent& event, const TimePos& time, f_cnt_t offset = 0 ) override @@ -80,7 +81,7 @@ public: // model has none. MidiController* copyToMidiController( Model* parent ) { - MidiController* c = new MidiController( parent ); + auto c = new MidiController(parent); c->m_midiPort.setInputChannel( m_midiPort.inputChannel() ); c->m_midiPort.setInputController( m_midiPort.inputController() ); c->subscribeReadablePorts( m_midiPort.readablePorts() ); @@ -121,6 +122,8 @@ private: +namespace gui +{ ControllerConnectionDialog::ControllerConnectionDialog( QWidget * _parent, const AutomatableModel * _target_model ) : @@ -138,8 +141,8 @@ ControllerConnectionDialog::ControllerConnectionDialog( QWidget * _parent, // Midi stuff m_midiGroupBox = new GroupBox( tr( "MIDI CONTROLLER" ), this ); m_midiGroupBox->setGeometry( 8, 10, 240, 80 ); - connect( m_midiGroupBox->model(), SIGNAL( dataChanged() ), - this, SLOT( midiToggled() ) ); + connect( m_midiGroupBox->model(), SIGNAL(dataChanged()), + this, SLOT(midiToggled())); m_midiChannelSpinBox = new LcdSpinBox( 2, m_midiGroupBox, tr( "Input channel" ) ); @@ -159,17 +162,17 @@ ControllerConnectionDialog::ControllerConnectionDialog( QWidget * _parent, m_midiGroupBox, tr("Auto Detect") ); m_midiAutoDetectCheckBox->setModel( &m_midiAutoDetect ); m_midiAutoDetectCheckBox->move( 8, 60 ); - connect( &m_midiAutoDetect, SIGNAL( dataChanged() ), - this, SLOT( autoDetectToggled() ) ); + connect( &m_midiAutoDetect, SIGNAL(dataChanged()), + this, SLOT(autoDetectToggled())); // when using with non-raw-clients we can provide buttons showing // our port-menus when being clicked if( !Engine::audioEngine()->midiClient()->isRaw() ) { m_readablePorts = new MidiPortMenu( MidiPort::Input ); - connect( m_readablePorts, SIGNAL( triggered( QAction * ) ), - this, SLOT( enableAutoDetect( QAction * ) ) ); - ToolButton * rp_btn = new ToolButton( m_midiGroupBox ); + connect( m_readablePorts, SIGNAL(triggered(QAction*)), + this, SLOT(enableAutoDetect(QAction*))); + auto rp_btn = new ToolButton(m_midiGroupBox); rp_btn->setText( tr( "MIDI-devices to receive " "MIDI-events from" ) ); rp_btn->setIcon( embed::getIconPixmap( "piano" ) ); @@ -182,8 +185,8 @@ ControllerConnectionDialog::ControllerConnectionDialog( QWidget * _parent, // User stuff m_userGroupBox = new GroupBox( tr( "USER CONTROLLER" ), this ); m_userGroupBox->setGeometry( 8, 100, 240, 60 ); - connect( m_userGroupBox->model(), SIGNAL( dataChanged() ), - this, SLOT( userToggled() ) ); + connect( m_userGroupBox->model(), SIGNAL(dataChanged()), + this, SLOT(userToggled())); m_userController = new ComboBox( m_userGroupBox, "Controller" ); m_userController->setGeometry( 10, 24, 200, ComboBox::DEFAULT_HEIGHT ); @@ -191,10 +194,10 @@ ControllerConnectionDialog::ControllerConnectionDialog( QWidget * _parent, { m_userController->model()->addItem( c->name() ); } - connect( m_userController->model(), SIGNAL( dataUnchanged() ), - this, SLOT( userSelected() ) ); - connect( m_userController->model(), SIGNAL( dataChanged() ), - this, SLOT( userSelected() ) ); + connect( m_userController->model(), SIGNAL(dataUnchanged()), + this, SLOT(userSelected())); + connect( m_userController->model(), SIGNAL(dataChanged()), + this, SLOT(userSelected())); // Mapping functions @@ -207,24 +210,20 @@ ControllerConnectionDialog::ControllerConnectionDialog( QWidget * _parent, // Buttons - QWidget * buttons = new QWidget( this ); + auto buttons = new QWidget(this); buttons->setGeometry( 8, 240, 240, 32 ); - QHBoxLayout * btn_layout = new QHBoxLayout( buttons ); + auto btn_layout = new QHBoxLayout(buttons); btn_layout->setSpacing( 0 ); btn_layout->setMargin( 0 ); - - QPushButton * select_btn = new QPushButton( - embed::getIconPixmap( "add" ), - tr( "OK" ), buttons ); - connect( select_btn, SIGNAL( clicked() ), - this, SLOT( selectController() ) ); - - QPushButton * cancel_btn = new QPushButton( - embed::getIconPixmap( "cancel" ), - tr( "Cancel" ), buttons ); - connect( cancel_btn, SIGNAL( clicked() ), - this, SLOT( reject() ) ); + + auto select_btn = new QPushButton(embed::getIconPixmap("add"), tr("OK"), buttons); + connect( select_btn, SIGNAL(clicked()), + this, SLOT(selectController())); + + auto cancel_btn = new QPushButton(embed::getIconPixmap("cancel"), tr("Cancel"), buttons); + connect( cancel_btn, SIGNAL(clicked()), + this, SLOT(reject())); btn_layout->addStretch(); btn_layout->addSpacing( 10 ); @@ -250,8 +249,8 @@ ControllerConnectionDialog::ControllerConnectionDialog( QWidget * _parent, m_midiGroupBox->model()->setValue( true ); // ensure controller is created midiToggled(); - - MidiController * cont = (MidiController*)( cc->getController() ); + + auto cont = (MidiController*)(cc->getController()); m_midiChannelSpinBox->model()->setValue( cont->m_midiPort.inputChannel() ); m_midiControllerSpinBox->model()->setValue( cont->m_midiPort.inputController() ); @@ -371,7 +370,7 @@ void ControllerConnectionDialog::midiToggled() m_readablePorts->setModel( &m_midiController->m_midiPort ); } - connect( m_midiController, SIGNAL( valueChanged() ), this, SLOT( midiValueChanged() ) ); + connect( m_midiController, SIGNAL(valueChanged()), this, SLOT(midiValueChanged())); } } m_midiAutoDetect.setValue( enabled ); @@ -440,5 +439,6 @@ void ControllerConnectionDialog::enableAutoDetect( QAction * _a ) +} // namespace gui - +} // namespace lmms diff --git a/src/gui/modals/EffectSelectDialog.cpp b/src/gui/modals/EffectSelectDialog.cpp index b4bd3af4a..9ce3f90b6 100644 --- a/src/gui/modals/EffectSelectDialog.cpp +++ b/src/gui/modals/EffectSelectDialog.cpp @@ -34,6 +34,10 @@ #include +namespace lmms::gui +{ + + EffectSelectDialog::EffectSelectDialog( QWidget * _parent ) : QDialog( _parent ), ui( new Ui::EffectSelectDialog ), @@ -94,27 +98,27 @@ EffectSelectDialog::EffectSelectDialog( QWidget * _parent ) : m_model.setSourceModel( &m_sourceModel ); m_model.setFilterCaseSensitivity( Qt::CaseInsensitive ); - connect( ui->filterEdit, SIGNAL( textChanged( const QString & ) ), - &m_model, SLOT( setFilterFixedString( const QString & ) ) ); - connect( ui->filterEdit, SIGNAL( textChanged( const QString & ) ), - this, SLOT( updateSelection() ) ); - connect( ui->filterEdit, SIGNAL( textChanged( const QString & ) ), - SLOT( sortAgain() ) ); + connect( ui->filterEdit, SIGNAL( textChanged( const QString& ) ), + &m_model, SLOT( setFilterFixedString( const QString& ) ) ); + connect( ui->filterEdit, SIGNAL( textChanged( const QString& ) ), + this, SLOT(updateSelection())); + connect( ui->filterEdit, SIGNAL( textChanged( const QString& ) ), + SLOT(sortAgain())); ui->pluginList->setModel( &m_model ); // setup selection model - QItemSelectionModel * selectionModel = new QItemSelectionModel( &m_model ); + auto selectionModel = new QItemSelectionModel(&m_model); ui->pluginList->setSelectionModel( selectionModel ); - connect( selectionModel, SIGNAL( currentRowChanged( const QModelIndex &, + connect( selectionModel, SIGNAL( currentRowChanged( const QModelIndex&, const QModelIndex & ) ), - SLOT( rowChanged( const QModelIndex &, const QModelIndex & ) ) ); - connect( ui->pluginList, SIGNAL( doubleClicked( const QModelIndex & ) ), - SLOT( acceptSelection() ) ); + SLOT( rowChanged( const QModelIndex &, const QModelIndex& ) ) ); + connect( ui->pluginList, SIGNAL( doubleClicked( const QModelIndex& ) ), + SLOT(acceptSelection())); // try to accept current selection when pressing "OK" - connect( ui->buttonBox, SIGNAL( accepted() ), - this, SLOT( acceptSelection() ) ); + connect( ui->buttonBox, SIGNAL(accepted()), + this, SLOT(acceptSelection())); ui->filterEdit->setClearButtonEnabled( true ); ui->pluginList->verticalHeader()->setSectionResizeMode( @@ -189,14 +193,14 @@ void EffectSelectDialog::rowChanged( const QModelIndex & _idx, { m_descriptionWidget = new QWidget; - QHBoxLayout *hbox = new QHBoxLayout( m_descriptionWidget ); + auto hbox = new QHBoxLayout(m_descriptionWidget); Plugin::Descriptor const & descriptor = *( m_currentSelection.desc ); const PixmapLoader* pixLoa = m_currentSelection.logo(); if (pixLoa) { - QLabel *logoLabel = new QLabel( m_descriptionWidget ); + auto logoLabel = new QLabel(m_descriptionWidget); logoLabel->setPixmap(pixLoa->pixmap()); logoLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); @@ -204,18 +208,18 @@ void EffectSelectDialog::rowChanged( const QModelIndex & _idx, hbox->setAlignment( logoLabel, Qt::AlignTop); } - QWidget *textualInfoWidget = new QWidget( m_descriptionWidget ); + auto textualInfoWidget = new QWidget(m_descriptionWidget); hbox->addWidget(textualInfoWidget); - QVBoxLayout * textWidgetLayout = new QVBoxLayout( textualInfoWidget); + auto textWidgetLayout = new QVBoxLayout(textualInfoWidget); textWidgetLayout->setMargin( 4 ); textWidgetLayout->setSpacing( 0 ); if ( m_currentSelection.desc->subPluginFeatures ) { - QWidget *subWidget = new QWidget(textualInfoWidget); - QVBoxLayout * subLayout = new QVBoxLayout( subWidget ); + auto subWidget = new QWidget(textualInfoWidget); + auto subLayout = new QVBoxLayout(subWidget); subLayout->setMargin( 4 ); subLayout->setSpacing( 0 ); m_currentSelection.desc->subPluginFeatures-> @@ -232,7 +236,7 @@ void EffectSelectDialog::rowChanged( const QModelIndex & _idx, } else { - QLabel *label = new QLabel(m_descriptionWidget); + auto label = new QLabel(m_descriptionWidget); QString labelText = "

" + tr("Name") + ": " + QString::fromUtf8(descriptor.displayName) + "

"; labelText += "

" + tr("Description") + ": " + qApp->translate( "PluginBrowser", descriptor.description ) + "

"; labelText += "

" + tr("Author") + ": " + QString::fromUtf8(descriptor.author) + "

"; @@ -271,6 +275,4 @@ void EffectSelectDialog::updateSelection() } - - - +} // namespace lmms::gui diff --git a/src/gui/modals/EffectSelectDialog.ui b/src/gui/modals/EffectSelectDialog.ui index f8e773486..b0433e66c 100644 --- a/src/gui/modals/EffectSelectDialog.ui +++ b/src/gui/modals/EffectSelectDialog.ui @@ -24,7 +24,7 @@
- + 500 diff --git a/src/gui/modals/ExportProjectDialog.cpp b/src/gui/modals/ExportProjectDialog.cpp index 151d25237..1f937c374 100644 --- a/src/gui/modals/ExportProjectDialog.cpp +++ b/src/gui/modals/ExportProjectDialog.cpp @@ -31,6 +31,8 @@ #include "MainWindow.h" #include "OutputSettings.h" +namespace lmms::gui +{ ExportProjectDialog::ExportProjectDialog( const QString & _file_name, QWidget * _parent, bool multi_export=false ) : @@ -77,14 +79,14 @@ ExportProjectDialog::ExportProjectDialog( const QString & _file_name, cbIndex++; } } - + int const MAX_LEVEL=8; for(int i=0; i<=MAX_LEVEL; ++i) { QString info=""; if ( i==0 ){ info = tr( "( Fastest - biggest )" ); } else if ( i==MAX_LEVEL ){ info = tr( "( Slowest - smallest )" ); } - + compLevelCB->addItem( QString::number(i)+" "+info, QVariant(i/static_cast(MAX_LEVEL)) @@ -96,8 +98,8 @@ ExportProjectDialog::ExportProjectDialog( const QString & _file_name, compressionWidget->setVisible(false); #endif - connect( startButton, SIGNAL( clicked() ), - this, SLOT( startBtnClicked() ) ); + connect( startButton, SIGNAL(clicked()), + this, SLOT(startBtnClicked())); } @@ -157,8 +159,8 @@ void ExportProjectDialog::startExport() static_cast(interpolationCB->currentIndex()), static_cast(oversamplingCB->currentIndex()) ); - const int samplerates[5] = { 44100, 48000, 88200, 96000, 192000 }; - const bitrate_t bitrates[6] = { 64, 128, 160, 192, 256, 320 }; + const auto samplerates = std::array{44100, 48000, 88200, 96000, 192000}; + const auto bitrates = std::array{64, 128, 160, 192, 256, 320}; bool useVariableBitRate = checkBoxVariableBitRate->isChecked(); @@ -188,14 +190,14 @@ void ExportProjectDialog::startExport() Engine::getSong()->setRenderBetweenMarkers( renderMarkersCB->isChecked() ); Engine::getSong()->setLoopRenderCount(loopCountSB->value()); - connect( m_renderManager.get(), SIGNAL( progressChanged( int ) ), - progressBar, SLOT( setValue( int ) ) ); - connect( m_renderManager.get(), SIGNAL( progressChanged( int ) ), - this, SLOT( updateTitleBar( int ) )); - connect( m_renderManager.get(), SIGNAL( finished() ), - this, SLOT( accept() ) ) ; - connect( m_renderManager.get(), SIGNAL( finished() ), - getGUI()->mainWindow(), SLOT( resetWindowTitle() ) ); + connect( m_renderManager.get(), SIGNAL(progressChanged(int)), + progressBar, SLOT(setValue(int))); + connect( m_renderManager.get(), SIGNAL(progressChanged(int)), + this, SLOT(updateTitleBar(int))); + connect( m_renderManager.get(), SIGNAL(finished()), + this, SLOT(accept())) ; + connect( m_renderManager.get(), SIGNAL(finished()), + getGUI()->mainWindow(), SLOT(resetWindowTitle())); if ( m_multiExport ) { @@ -294,3 +296,5 @@ void ExportProjectDialog::updateTitleBar( int _prog ) getGUI()->mainWindow()->setWindowTitle( tr( "Rendering: %1%" ).arg( _prog ) ); } + +} // namespace lmms::gui diff --git a/src/gui/modals/FileDialog.cpp b/src/gui/modals/FileDialog.cpp index 79f1ca5e0..512d7179f 100644 --- a/src/gui/modals/FileDialog.cpp +++ b/src/gui/modals/FileDialog.cpp @@ -31,6 +31,10 @@ #include "FileDialog.h" +namespace lmms::gui +{ + + FileDialog::FileDialog( QWidget *parent, const QString &caption, const QString &directory, const QString &filter ) : QFileDialog( parent, caption, directory, filter ) @@ -100,8 +104,10 @@ QString FileDialog::getOpenFileName(QWidget *parent, void FileDialog::clearSelection() { - QListView *view = findChild(); + auto view = findChild(); Q_ASSERT( view ); view->clearSelection(); } + +} // namespace lmms::gui \ No newline at end of file diff --git a/src/gui/modals/RenameDialog.cpp b/src/gui/modals/RenameDialog.cpp index cb427b2c0..381064f39 100644 --- a/src/gui/modals/RenameDialog.cpp +++ b/src/gui/modals/RenameDialog.cpp @@ -28,6 +28,8 @@ #include "RenameDialog.h" +namespace lmms::gui +{ RenameDialog::RenameDialog( QString & _string ) : @@ -41,21 +43,15 @@ RenameDialog::RenameDialog( QString & _string ) : m_stringLE->setText( _string ); m_stringLE->setGeometry ( 10, 5, 220, 20 ); m_stringLE->selectAll(); - connect( m_stringLE, SIGNAL( textChanged( const QString & ) ), this, - SLOT( textChanged( const QString & ) ) ); - connect( m_stringLE, SIGNAL( returnPressed() ), this, - SLOT( accept() ) ); + connect( m_stringLE, SIGNAL( textChanged( const QString& ) ), this, + SLOT( textChanged( const QString& ) ) ); + connect( m_stringLE, SIGNAL(returnPressed()), this, + SLOT(accept())); } -RenameDialog::~RenameDialog() -{ -} - - - void RenameDialog::resizeEvent (QResizeEvent * event) { m_stringLE->setGeometry ( 10, 5, width() - 20, 20 ); @@ -80,3 +76,6 @@ void RenameDialog::textChanged( const QString & _new_string ) { m_stringToEdit = _new_string; } + + +} // namespace lmms::gui \ No newline at end of file diff --git a/src/gui/modals/SetupDialog.cpp b/src/gui/modals/SetupDialog.cpp index 035912a47..5140a63b5 100644 --- a/src/gui/modals/SetupDialog.cpp +++ b/src/gui/modals/SetupDialog.cpp @@ -68,11 +68,15 @@ #include "MidiWinMM.h" +namespace lmms::gui +{ + + constexpr int BUFFERSIZE_RESOLUTION = 32; inline void labelWidget(QWidget * w, const QString & txt) { - QLabel * title = new QLabel(txt, w); + auto title = new QLabel(txt, w); QFont f = title->font(); f.setBold(true); title->setFont(pointSize<12>(f)); @@ -132,8 +136,6 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : m_vstEmbedMethod(ConfigManager::inst()->vstEmbedMethod()), m_vstAlwaysOnTop(ConfigManager::inst()->value( "ui", "vstalwaysontop").toInt()), - m_syncVSTPlugins(ConfigManager::inst()->value( - "ui", "syncvstplugins", "1").toInt()), m_disableAutoQuit(ConfigManager::inst()->value( "ui", "disableautoquit", "1").toInt()), m_NaNHandler(ConfigManager::inst()->value( @@ -168,16 +170,15 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : const int YDelta = 18; // Main widget. - QWidget * main_w = new QWidget(this); - + auto main_w = new QWidget(this); // Vertical layout. - QVBoxLayout * vlayout = new QVBoxLayout(this); + auto vlayout = new QVBoxLayout(this); vlayout->setSpacing(0); vlayout->setMargin(0); // Horizontal layout. - QHBoxLayout * hlayout = new QHBoxLayout(main_w); + auto hlayout = new QHBoxLayout(main_w); hlayout->setSpacing(0); hlayout->setMargin(0); @@ -187,26 +188,19 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : m_tabBar->setFixedWidth(72); // Settings widget. - QWidget * settings_w = new QWidget(main_w); + auto settings_w = new QWidget(main_w); settings_w->setFixedSize(360, 360); // General widget. - QWidget * general_w = new QWidget(settings_w); - QVBoxLayout * general_layout = new QVBoxLayout(general_w); + auto general_w = new QWidget(settings_w); + auto general_layout = new QVBoxLayout(general_w); general_layout->setSpacing(10); general_layout->setMargin(0); labelWidget(general_w, tr("General")); - - auto addLedCheckBox = [&XDelta, &YDelta, this]( - const QString &ledText, - TabWidget* tw, - int& counter, - bool initialState, - const char* toggledSlot, - bool showRestartWarning - ){ - LedCheckBox * checkBox = new LedCheckBox(ledText, tw); + auto addLedCheckBox = [&XDelta, &YDelta, this](const QString& ledText, TabWidget* tw, int& counter, + bool initialState, const char* toggledSlot, bool showRestartWarning) { + auto checkBox = new LedCheckBox(ledText, tw); counter++; checkBox->move(XDelta, YDelta * counter); checkBox->setChecked(initialState); @@ -217,13 +211,10 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : } }; - int counter = 0; // GUI tab. - TabWidget * gui_tw = new TabWidget( - tr("Graphical user interface (GUI)"), general_w); - + auto gui_tw = new TabWidget(tr("Graphical user interface (GUI)"), general_w); addLedCheckBox(tr("Display volume as dBFS "), gui_tw, counter, m_displaydBFS, SLOT(toggleDisplaydBFS(bool)), true); @@ -252,9 +243,7 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : counter = 0; // Projects tab. - TabWidget * projects_tw = new TabWidget( - tr("Projects"), general_w); - + auto projects_tw = new TabWidget(tr("Projects"), general_w); addLedCheckBox(tr("Compress project files by default"), projects_tw, counter, m_MMPZ, SLOT(toggleMMPZ(bool)), true); @@ -266,21 +255,31 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : projects_tw->setFixedHeight(YDelta + YDelta * counter); // Language tab. - TabWidget * lang_tw = new TabWidget( - tr("Language"), general_w); + auto lang_tw = new TabWidget(tr("Language"), general_w); lang_tw->setFixedHeight(48); - QComboBox * changeLang = new QComboBox(lang_tw); + auto changeLang = new QComboBox(lang_tw); changeLang->move(XDelta, 20); QDir dir(ConfigManager::inst()->localeDir()); QStringList fileNames = dir.entryList(QStringList("*.qm")); for(int i = 0; i < fileNames.size(); ++i) { - // Get locale extracted by filename. + // Extract ISO-639 language code from filename fileNames[i].truncate(fileNames[i].lastIndexOf('.')); + // Skip invalid language codes + QLocale locale(fileNames[i]); + if (locale.language() == QLocale::C) + { + continue; + } + // Display the native language name or fallback to the English name + QString langName = locale.nativeLanguageName(); + if (langName.isEmpty()) + { + langName = QLocale::languageToString(locale.language()); + } m_languages.append(fileNames[i]); - QString lang = QLocale(m_languages.last()).nativeLanguageName(); - changeLang->addItem(lang); + changeLang->addItem(langName); } // If language unset, fallback to system language when available. @@ -322,8 +321,8 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : // Performance widget. - QWidget * performance_w = new QWidget(settings_w); - QVBoxLayout * performance_layout = new QVBoxLayout(performance_w); + auto performance_w = new QWidget(settings_w); + auto performance_layout = new QVBoxLayout(performance_w); performance_layout->setSpacing(10); performance_layout->setMargin(0); labelWidget(performance_w, @@ -331,8 +330,7 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : // Autosave tab. - TabWidget * auto_save_tw = new TabWidget( - tr("Autosave"), performance_w); + auto auto_save_tw = new TabWidget(tr("Autosave"), performance_w); auto_save_tw->setFixedHeight(106); m_saveIntervalSlider = new QSlider(Qt::Horizontal, auto_save_tw); @@ -364,8 +362,7 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : connect(m_runningAutoSave, SIGNAL(toggled(bool)), this, SLOT(toggleRunningAutoSave(bool))); - QPushButton * autoSaveResetBtn = new QPushButton( - embed::getIconPixmap("reload"), "", auto_save_tw); + auto autoSaveResetBtn = new QPushButton(embed::getIconPixmap("reload"), "", auto_save_tw); autoSaveResetBtn->setGeometry(320, 70, 28, 28); connect(autoSaveResetBtn, SIGNAL(clicked()), this, SLOT(resetAutoSave())); @@ -377,8 +374,7 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : counter = 0; // UI effect vs. performance tab. - TabWidget * ui_fx_tw = new TabWidget( - tr("User interface (UI) effects vs. performance"), performance_w); + auto ui_fx_tw = new TabWidget(tr("User interface (UI) effects vs. performance"), performance_w); addLedCheckBox(tr("Smooth scroll in song editor"), ui_fx_tw, counter, m_smoothScroll, SLOT(toggleSmoothScroll(bool)), false); @@ -391,8 +387,7 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : counter = 0; // Plugins tab. - TabWidget * plugins_tw = new TabWidget( - tr("Plugins"), performance_w); + auto plugins_tw = new TabWidget(tr("Plugins"), performance_w); m_vstEmbedLbl = new QLabel(plugins_tw); m_vstEmbedLbl->move(XDelta, YDelta * ++counter); @@ -429,9 +424,6 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : connect(m_vstAlwaysOnTopCheckBox, SIGNAL(toggled(bool)), this, SLOT(toggleVSTAlwaysOnTop(bool))); - addLedCheckBox(tr("Sync VST plugins to host playback"), plugins_tw, counter, - m_syncVSTPlugins, SLOT(toggleSyncVSTPlugins(bool)), false); - addLedCheckBox(tr("Keep effects running even without input"), plugins_tw, counter, m_disableAutoQuit, SLOT(toggleDisableAutoQuit(bool)), false); @@ -447,16 +439,15 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : // Audio widget. - QWidget * audio_w = new QWidget(settings_w); - QVBoxLayout * audio_layout = new QVBoxLayout(audio_w); + auto audio_w = new QWidget(settings_w); + auto audio_layout = new QVBoxLayout(audio_w); audio_layout->setSpacing(10); audio_layout->setMargin(0); labelWidget(audio_w, tr("Audio")); // Audio interface tab. - TabWidget * audioiface_tw = new TabWidget( - tr("Audio interface"), audio_w); + auto audioiface_tw = new TabWidget(tr("Audio interface"), audio_w); audioiface_tw->setFixedHeight(56); m_audioInterfaces = new QComboBox(audioiface_tw); @@ -464,10 +455,10 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : // Ifaces-settings-widget. - QWidget * as_w = new QWidget(audio_w); + auto as_w = new QWidget(audio_w); as_w->setFixedHeight(60); - QHBoxLayout * as_w_layout = new QHBoxLayout(as_w); + auto as_w_layout = new QHBoxLayout(as_w); as_w_layout->setSpacing(0); as_w_layout->setMargin(0); @@ -541,20 +532,18 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : setCurrentIndex(m_audioInterfaces->findText(audioDevName)); m_audioIfaceSetupWidgets[audioDevName]->show(); - connect(m_audioInterfaces, SIGNAL(activated(const QString &)), - this, SLOT(audioInterfaceChanged(const QString &))); + connect(m_audioInterfaces, SIGNAL(activated(const QString&)), + this, SLOT(audioInterfaceChanged(const QString&))); // Advanced setting, hidden for now if(false) { - LedCheckBox * useNaNHandler = new LedCheckBox( - tr("Use built-in NaN handler"), audio_w); + auto useNaNHandler = new LedCheckBox(tr("Use built-in NaN handler"), audio_w); useNaNHandler->setChecked(m_NaNHandler); } // HQ mode LED. - LedCheckBox * hqaudio = new LedCheckBox( - tr("HQ mode for output audio device"), audio_w); + auto hqaudio = new LedCheckBox(tr("HQ mode for output audio device"), audio_w); hqaudio->move(10, 0); hqaudio->setChecked(m_hqAudioDev); connect(hqaudio, SIGNAL(toggled(bool)), @@ -562,8 +551,7 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : // Buffer size tab. - TabWidget * bufferSize_tw = new TabWidget( - tr("Buffer size"), audio_w); + auto bufferSize_tw = new TabWidget(tr("Buffer size"), audio_w); bufferSize_tw->setFixedHeight(76); m_bufferSizeSlider = new QSlider(Qt::Horizontal, bufferSize_tw); @@ -583,8 +571,7 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : m_bufferSizeLbl->setGeometry(10, 40, 200, 24); setBufferSize(m_bufferSizeSlider->value()); - QPushButton * bufferSize_reset_btn = new QPushButton( - embed::getIconPixmap("reload"), "", bufferSize_tw); + auto bufferSize_reset_btn = new QPushButton(embed::getIconPixmap("reload"), "", bufferSize_tw); bufferSize_reset_btn->setGeometry(320, 40, 28, 28); connect(bufferSize_reset_btn, SIGNAL(clicked()), this, SLOT(resetBufferSize())); @@ -602,26 +589,25 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : // MIDI widget. - QWidget * midi_w = new QWidget(settings_w); - QVBoxLayout * midi_layout = new QVBoxLayout(midi_w); + auto midi_w = new QWidget(settings_w); + auto midi_layout = new QVBoxLayout(midi_w); midi_layout->setSpacing(10); midi_layout->setMargin(0); labelWidget(midi_w, tr("MIDI")); // MIDI interface tab. - TabWidget * midiiface_tw = new TabWidget( - tr("MIDI interface"), midi_w); + auto midiiface_tw = new TabWidget(tr("MIDI interface"), midi_w); midiiface_tw->setFixedHeight(56); m_midiInterfaces = new QComboBox(midiiface_tw); m_midiInterfaces->setGeometry(10, 20, 240, 28); // Ifaces-settings-widget. - QWidget * ms_w = new QWidget(midi_w); + auto ms_w = new QWidget(midi_w); ms_w->setFixedHeight(60); - QHBoxLayout * ms_w_layout = new QHBoxLayout(ms_w); + auto ms_w_layout = new QHBoxLayout(ms_w); ms_w_layout->setSpacing(0); ms_w_layout->setMargin(0); @@ -685,13 +671,12 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : m_midiInterfaces->setCurrentIndex(m_midiInterfaces->findText(midiDevName)); m_midiIfaceSetupWidgets[midiDevName]->show(); - connect(m_midiInterfaces, SIGNAL(activated(const QString &)), - this, SLOT(midiInterfaceChanged(const QString &))); + connect(m_midiInterfaces, SIGNAL(activated(const QString&)), + this, SLOT(midiInterfaceChanged(const QString&))); // MIDI autoassign tab. - TabWidget * midiAutoAssign_tw = new TabWidget( - tr("Automatically assign MIDI controller to selected track"), midi_w); + auto midiAutoAssign_tw = new TabWidget(tr("Automatically assign MIDI controller to selected track"), midi_w); midiAutoAssign_tw->setFixedHeight(56); m_assignableMidiDevices = new QComboBox(midiAutoAssign_tw); @@ -720,9 +705,9 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : // Paths widget. - QWidget * paths_w = new QWidget(settings_w); + auto paths_w = new QWidget(settings_w); - QVBoxLayout * paths_layout = new QVBoxLayout(paths_w); + auto paths_layout = new QVBoxLayout(paths_w); paths_layout->setSpacing(10); paths_layout->setMargin(0); @@ -730,39 +715,31 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : // Paths scroll area. - QScrollArea * pathsScroll = new QScrollArea(paths_w); + auto pathsScroll = new QScrollArea(paths_w); pathsScroll->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); pathsScroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // Path selectors widget. - QWidget * pathSelectors = new QWidget(paths_w); + auto pathSelectors = new QWidget(paths_w); const int txtLength = 284; const int btnStart = 300; // Path selectors layout. - QVBoxLayout * pathSelectorsLayout = new QVBoxLayout; + auto pathSelectorsLayout = new QVBoxLayout; pathSelectorsLayout->setSpacing(10); - auto addPathEntry = [&](const QString &caption, - const QString& content, - const char* setSlot, - const char* openSlot, - QLineEdit*& lineEdit, - const char* pixmap = "project_open") - { - TabWidget * newTw = new TabWidget(caption, - pathSelectors); + auto addPathEntry = [&](const QString& caption, const QString& content, const char* setSlot, const char* openSlot, + QLineEdit*& lineEdit, const char* pixmap = "project_open") { + auto newTw = new TabWidget(caption, pathSelectors); newTw->setFixedHeight(48); lineEdit = new QLineEdit(content, newTw); lineEdit->setGeometry(10, 20, txtLength, 16); - connect(lineEdit, SIGNAL(textChanged(const QString &)), + connect(lineEdit, SIGNAL(textChanged(const QString&)), this, setSlot); - QPushButton * selectBtn = new QPushButton( - embed::getIconPixmap(pixmap, 16, 16), - "", newTw); + auto selectBtn = new QPushButton(embed::getIconPixmap(pixmap, 16, 16), "", newTw); selectBtn->setFixedSize(24, 24); selectBtn->move(btnStart, 16); connect(selectBtn, SIGNAL(clicked()), this, openSlot); @@ -772,37 +749,37 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : }; addPathEntry(tr("LMMS working directory"), m_workingDir, - SLOT(setWorkingDir(const QString &)), + SLOT(setWorkingDir(const QString&)), SLOT(openWorkingDir()), m_workingDirLineEdit); addPathEntry(tr("VST plugins directory"), m_vstDir, - SLOT(setVSTDir(const QString &)), + SLOT(setVSTDir(const QString&)), SLOT(openVSTDir()), m_vstDirLineEdit); addPathEntry(tr("LADSPA plugins directories"), m_ladspaDir, - SLOT(setLADSPADir(const QString &)), + SLOT(setLADSPADir(const QString&)), SLOT(openLADSPADir()), m_ladspaDirLineEdit, "add_folder"); addPathEntry(tr("SF2 directory"), m_sf2Dir, - SLOT(setSF2Dir(const QString &)), + SLOT(setSF2Dir(const QString&)), SLOT(openSF2Dir()), m_sf2DirLineEdit); #ifdef LMMS_HAVE_FLUIDSYNTH addPathEntry(tr("Default SF2"), m_sf2File, - SLOT(setSF2File(const QString &)), + SLOT(setSF2File(const QString&)), SLOT(openSF2File()), m_sf2FileLineEdit); #endif addPathEntry(tr("GIG directory"), m_gigDir, - SLOT(setGIGDir(const QString &)), + SLOT(setGIGDir(const QString&)), SLOT(openGIGDir()), m_gigDirLineEdit); addPathEntry(tr("Theme directory"), m_themeDir, - SLOT(setThemeDir(const QString &)), + SLOT(setThemeDir(const QString&)), SLOT(openThemeDir()), m_themeDirLineEdit); addPathEntry(tr("Background artwork"), m_backgroundPicFile, - SLOT(setBackgroundPicFile(const QString &)), + SLOT(setBackgroundPicFile(const QString&)), SLOT(openBackgroundPicFile()), m_backgroundPicFileLineEdit); @@ -843,8 +820,8 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : hlayout->addSpacing(10); // Extras widget and layout. - QWidget * extras_w = new QWidget(this); - QHBoxLayout * extras_layout = new QHBoxLayout(extras_w); + auto extras_w = new QWidget(this); + auto extras_layout = new QHBoxLayout(extras_w); extras_layout->setSpacing(0); extras_layout->setMargin(0); @@ -854,16 +831,12 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : restartWarningLbl->hide(); // OK button. - QPushButton * ok_btn = new QPushButton( - embed::getIconPixmap("apply"), - tr("OK"), extras_w); + auto ok_btn = new QPushButton(embed::getIconPixmap("apply"), tr("OK"), extras_w); connect(ok_btn, SIGNAL(clicked()), this, SLOT(accept())); // Cancel button. - QPushButton * cancel_btn = new QPushButton( - embed::getIconPixmap("cancel"), - tr("Cancel"), extras_w); + auto cancel_btn = new QPushButton(embed::getIconPixmap("cancel"), tr("Cancel"), extras_w); connect(cancel_btn, SIGNAL(clicked()), this, SLOT(reject())); @@ -944,8 +917,6 @@ void SetupDialog::accept() m_vstEmbedComboBox->currentData().toString()); ConfigManager::inst()->setValue("ui", "vstalwaysontop", QString::number(m_vstAlwaysOnTop)); - ConfigManager::inst()->setValue("ui", "syncvstplugins", - QString::number(m_syncVSTPlugins)); ConfigManager::inst()->setValue("ui", "disableautoquit", QString::number(m_disableAutoQuit)); ConfigManager::inst()->setValue("audioengine", "audiodev", @@ -1126,12 +1097,6 @@ void SetupDialog::toggleAnimateAFP(bool enabled) } -void SetupDialog::toggleSyncVSTPlugins(bool enabled) -{ - m_syncVSTPlugins = enabled; -} - - void SetupDialog::vstEmbedMethodChanged() { m_vstEmbedMethod = m_vstEmbedComboBox->currentData().toString(); @@ -1396,3 +1361,6 @@ void SetupDialog::showRestartWarning() { restartWarningLbl->show(); } + + +} // namespace lmms::gui diff --git a/src/gui/modals/VersionedSaveDialog.cpp b/src/gui/modals/VersionedSaveDialog.cpp index 1bdea502a..0c61df9f2 100644 --- a/src/gui/modals/VersionedSaveDialog.cpp +++ b/src/gui/modals/VersionedSaveDialog.cpp @@ -34,6 +34,10 @@ #include "LedCheckBox.h" +namespace lmms::gui +{ + + VersionedSaveDialog::VersionedSaveDialog( QWidget *parent, QWidget *saveOptionsWidget, const QString &caption, @@ -45,20 +49,20 @@ VersionedSaveDialog::VersionedSaveDialog( QWidget *parent, setFileMode( QFileDialog::AnyFile ); // Create + and - buttons - QPushButton *plusButton( new QPushButton( "+", this) ); + auto plusButton(new QPushButton("+", this)); plusButton->setToolTip( tr( "Increment version number" ) ); - QPushButton *minusButton( new QPushButton( "-", this ) ); + auto minusButton(new QPushButton("-", this)); minusButton->setToolTip( tr( "Decrement version number" ) ); plusButton->setFixedWidth(horizontalAdvance(plusButton->fontMetrics(), "+") + 30); minusButton->setFixedWidth(horizontalAdvance(minusButton->fontMetrics(), "+") + 30); // Add buttons to grid layout. For doing this, remove the lineEdit and // replace it with a HBox containing lineEdit and the buttons. - QGridLayout *layout = dynamic_cast( this->layout() ); + auto layout = dynamic_cast(this->layout()); QWidget *lineEdit = findChild(); layout->removeWidget( lineEdit ); - QHBoxLayout* hLayout( new QHBoxLayout() ); + auto hLayout(new QHBoxLayout()); hLayout->addWidget( lineEdit ); hLayout->addWidget( plusButton ); hLayout->addWidget( minusButton ); @@ -76,8 +80,8 @@ VersionedSaveDialog::VersionedSaveDialog( QWidget *parent, } // Connect + and - buttons - connect( plusButton, SIGNAL( clicked() ), this, SLOT( incrementVersion() )); - connect( minusButton, SIGNAL( clicked() ), this, SLOT( decrementVersion() )); + connect( plusButton, SIGNAL(clicked()), this, SLOT(incrementVersion())); + connect( minusButton, SIGNAL(clicked()), this, SLOT(decrementVersion())); } @@ -189,3 +193,6 @@ SaveOptionsWidget::SaveOptionsWidget(Song::SaveOptions &saveOptions) { setLayout(layout); } + + +} // namespace lmms::gui diff --git a/src/gui/tracks/AutomationTrackView.cpp b/src/gui/tracks/AutomationTrackView.cpp index ec44ba937..53e022c15 100644 --- a/src/gui/tracks/AutomationTrackView.cpp +++ b/src/gui/tracks/AutomationTrackView.cpp @@ -23,8 +23,7 @@ * */ - #include "AutomationTrackView.h" - +#include "AutomationTrackView.h" #include "AutomationClip.h" #include "AutomationTrack.h" #include "embed.h" @@ -33,18 +32,19 @@ #include "StringPairDrag.h" #include "TrackContainerView.h" #include "TrackLabelButton.h" - + +namespace lmms::gui +{ AutomationTrackView::AutomationTrackView( AutomationTrack * _at, TrackContainerView* tcv ) : TrackView( _at, tcv ) { setFixedHeight( 32 ); - TrackLabelButton * tlb = new TrackLabelButton( this, - getTrackSettingsWidget() ); - tlb->setIcon( embed::getIconPixmap( "automation_track" ) ); - tlb->move( 3, 1 ); - tlb->show(); - setModel( _at ); + auto tlb = new TrackLabelButton(this, getTrackSettingsWidget()); + tlb->setIcon(embed::getIconPixmap("automation_track")); + tlb->move(3, 1); + tlb->show(); + setModel(_at); } void AutomationTrackView::dragEnterEvent( QDragEnterEvent * _dee ) @@ -61,9 +61,7 @@ void AutomationTrackView::dropEvent( QDropEvent * _de ) QString val = StringPairDrag::decodeValue( _de ); if( type == "automatable_model" ) { - AutomatableModel * mod = dynamic_cast( - Engine::projectJournal()-> - journallingObject( val.toInt() ) ); + auto mod = dynamic_cast(Engine::projectJournal()->journallingObject(val.toInt())); if( mod != nullptr ) { TimePos pos = TimePos( trackContainerView()-> @@ -80,10 +78,13 @@ void AutomationTrackView::dropEvent( QDropEvent * _de ) } Clip * clip = getTrack()->createClip( pos ); - AutomationClip * autoClip = dynamic_cast( clip ); + auto autoClip = dynamic_cast(clip); autoClip->addObject( mod ); } } update(); } + + +} // namespace lmms::gui diff --git a/src/gui/tracks/FadeButton.cpp b/src/gui/tracks/FadeButton.cpp index c40569c21..2f4727e5e 100644 --- a/src/gui/tracks/FadeButton.cpp +++ b/src/gui/tracks/FadeButton.cpp @@ -30,6 +30,9 @@ #include "FadeButton.h" +namespace lmms::gui +{ + const float FadeDuration = 300; @@ -52,11 +55,6 @@ FadeButton::FadeButton(const QColor & _normal_color, - -FadeButton::~FadeButton() -{ -} - void FadeButton::setActiveColor(const QColor & activated_color) { m_activatedColor = activated_color; @@ -164,3 +162,6 @@ QColor FadeButton::fadeToColor(QColor startCol, QColor endCol, QElapsedTimer tim return col; } + + +} // namespace lmms::gui diff --git a/src/gui/tracks/InstrumentTrackView.cpp b/src/gui/tracks/InstrumentTrackView.cpp index b58144956..5daa51381 100644 --- a/src/gui/tracks/InstrumentTrackView.cpp +++ b/src/gui/tracks/InstrumentTrackView.cpp @@ -48,6 +48,10 @@ #include "TrackLabelButton.h" +namespace lmms::gui +{ + + InstrumentTrackView::InstrumentTrackView( InstrumentTrack * _it, TrackContainerView* tcv ) : TrackView( _it, tcv ), m_window( nullptr ), @@ -62,14 +66,14 @@ InstrumentTrackView::InstrumentTrackView( InstrumentTrack * _it, TrackContainerV m_tlb->move( 3, 1 ); m_tlb->show(); - connect( m_tlb, SIGNAL( toggled( bool ) ), - this, SLOT( toggleInstrumentWindow( bool ) ) ); + connect( m_tlb, SIGNAL(toggled(bool)), + this, SLOT(toggleInstrumentWindow(bool))); - connect( _it, SIGNAL( nameChanged() ), - m_tlb, SLOT( update() ) ); + connect( _it, SIGNAL(nameChanged()), + m_tlb, SLOT(update())); - connect(ConfigManager::inst(), SIGNAL(valueChanged(QString, QString, QString)), - this, SLOT(handleConfigChange(QString, QString, QString))); + connect(ConfigManager::inst(), SIGNAL(valueChanged(QString,QString,QString)), + this, SLOT(handleConfigChange(QString,QString,QString))); // creation of widgets for track-settings-widget int widgetWidth; @@ -124,12 +128,12 @@ InstrumentTrackView::InstrumentTrackView( InstrumentTrack * _it, TrackContainerV m_midiOutputAction = m_midiMenu->addAction( "" ); m_midiInputAction->setCheckable( true ); m_midiOutputAction->setCheckable( true ); - connect( m_midiInputAction, SIGNAL( changed() ), this, - SLOT( midiInSelected() ) ); - connect( m_midiOutputAction, SIGNAL( changed() ), this, - SLOT( midiOutSelected() ) ); - connect( &_it->m_midiPort, SIGNAL( modeChanged() ), - this, SLOT( midiConfigChanged() ) ); + connect( m_midiInputAction, SIGNAL(changed()), this, + SLOT(midiInSelected())); + connect( m_midiOutputAction, SIGNAL(changed()), this, + SLOT(midiOutSelected())); + connect( &_it->m_midiPort, SIGNAL(modeChanged()), + this, SLOT(midiConfigChanged())); } m_midiInputAction->setText( tr( "Input" ) ); @@ -141,7 +145,7 @@ InstrumentTrackView::InstrumentTrackView( InstrumentTrack * _it, TrackContainerV this, SLOT(toggleMidiCCRack())); m_activityIndicator = new FadeButton( QApplication::palette().color( QPalette::Active, - QPalette::Background), + QPalette::Window), QApplication::palette().color( QPalette::Active, QPalette::BrightText ), QApplication::palette().color( QPalette::Active, @@ -150,14 +154,14 @@ InstrumentTrackView::InstrumentTrackView( InstrumentTrack * _it, TrackContainerV m_activityIndicator->setGeometry( widgetWidth-2*24-11, 2, 8, 28 ); m_activityIndicator->show(); - connect( m_activityIndicator, SIGNAL( pressed() ), - this, SLOT( activityIndicatorPressed() ) ); - connect( m_activityIndicator, SIGNAL( released() ), - this, SLOT( activityIndicatorReleased() ) ); - connect( _it, SIGNAL( newNote() ), - m_activityIndicator, SLOT( activate() ) ); - connect( _it, SIGNAL( endNote() ), - m_activityIndicator, SLOT( noteEnd() ) ); + connect( m_activityIndicator, SIGNAL(pressed()), + this, SLOT(activityIndicatorPressed())); + connect( m_activityIndicator, SIGNAL(released()), + this, SLOT(activityIndicatorReleased())); + connect( _it, SIGNAL(newNote()), + m_activityIndicator, SLOT(activate())); + connect( _it, SIGNAL(endNote()), + m_activityIndicator, SLOT(noteEnd())); setModel( _it ); } @@ -362,9 +366,9 @@ QMenu * InstrumentTrackView::createMixerMenu(QString title, QString newMixerLabe title = title.arg( channelIndex ).arg( mixerChannel->m_name ); } - QMenu *mixerMenu = new QMenu( title ); + auto mixerMenu = new QMenu(title); - mixerMenu->addAction( newMixerLabel, this, SLOT( createMixerLine() ) ); + mixerMenu->addAction( newMixerLabel, this, SLOT(createMixerLine())); mixerMenu->addSeparator(); for (int i = 0; i < Engine::mixer()->numChannels(); ++i) @@ -384,3 +388,5 @@ QMenu * InstrumentTrackView::createMixerMenu(QString title, QString newMixerLabe return mixerMenu; } + +} // namespace lmms::gui diff --git a/src/gui/tracks/PatternTrackView.cpp b/src/gui/tracks/PatternTrackView.cpp index 7571cd1db..be039ba79 100644 --- a/src/gui/tracks/PatternTrackView.cpp +++ b/src/gui/tracks/PatternTrackView.cpp @@ -31,6 +31,9 @@ #include "PatternTrack.h" #include "TrackLabelButton.h" +namespace lmms::gui +{ + PatternTrackView::PatternTrackView(PatternTrack* pt, TrackContainerView* tcv) : TrackView(pt, tcv), m_patternTrack(pt) @@ -43,8 +46,8 @@ PatternTrackView::PatternTrackView(PatternTrack* pt, TrackContainerView* tcv) : m_trackLabel->setIcon( embed::getIconPixmap("pattern_track")); m_trackLabel->move( 3, 1 ); m_trackLabel->show(); - connect( m_trackLabel, SIGNAL( clicked( bool ) ), - this, SLOT( clickedTrackLabel() ) ); + connect( m_trackLabel, SIGNAL(clicked(bool)), + this, SLOT(clickedTrackLabel())); setModel(pt); } @@ -74,3 +77,6 @@ void PatternTrackView::clickedTrackLabel() getGUI()->patternEditor()->parentWidget()->show(); getGUI()->patternEditor()->setFocus(Qt::ActiveWindowFocusReason); } + + +} // namespace lmms::gui diff --git a/src/gui/tracks/SampleTrackView.cpp b/src/gui/tracks/SampleTrackView.cpp index a73724911..08ddee863 100644 --- a/src/gui/tracks/SampleTrackView.cpp +++ b/src/gui/tracks/SampleTrackView.cpp @@ -42,6 +42,10 @@ #include "TrackLabelButton.h" +namespace lmms::gui +{ + + SampleTrackView::SampleTrackView( SampleTrack * _t, TrackContainerView* tcv ) : TrackView( _t, tcv ) { @@ -49,7 +53,7 @@ SampleTrackView::SampleTrackView( SampleTrack * _t, TrackContainerView* tcv ) : m_tlb = new TrackLabelButton(this, getTrackSettingsWidget()); m_tlb->setCheckable(true); - connect(m_tlb, SIGNAL(clicked( bool )), + connect(m_tlb, SIGNAL(clicked(bool)), this, SLOT(showEffects())); m_tlb->setIcon(embed::getIconPixmap("sample_track")); m_tlb->move(3, 1); @@ -130,7 +134,7 @@ QMenu * SampleTrackView::createMixerMenu(QString title, QString newMixerLabel) title = title.arg(channelIndex).arg(mixerChannel->m_name); } - QMenu *mixerMenu = new QMenu(title); + auto mixerMenu = new QMenu(title); mixerMenu->addAction(newMixerLabel, this, SLOT(createMixerLine())); mixerMenu->addSeparator(); @@ -164,7 +168,7 @@ void SampleTrackView::showEffects() void SampleTrackView::modelChanged() { - SampleTrack * st = castModel(); + auto st = castModel(); m_volumeKnob->setModel(&st->m_volumeModel); TrackView::modelChanged(); @@ -202,7 +206,7 @@ void SampleTrackView::dropEvent(QDropEvent *de) * TimePos::ticksPerBar()) + trackContainerView()->currentPosition() ).quantize(1.0); - SampleClip * sClip = static_cast(getTrack()->createClip(clipPos)); + auto sClip = static_cast(getTrack()->createClip(clipPos)); if (sClip) { sClip->setSampleFile(value); } } } @@ -232,3 +236,6 @@ void SampleTrackView::assignMixerLine(int channelIndex) getGUI()->mixerView()->setCurrentMixerLine(channelIndex); } + + +} // namespace lmms::gui diff --git a/src/gui/tracks/TrackContentWidget.cpp b/src/gui/tracks/TrackContentWidget.cpp index 36bbd4096..74ab016ea 100644 --- a/src/gui/tracks/TrackContentWidget.cpp +++ b/src/gui/tracks/TrackContentWidget.cpp @@ -44,6 +44,9 @@ #include "TrackView.h" +namespace lmms::gui +{ + /*! Alternate between a darker and a lighter background color every 4 bars */ const int BARS_PER_GROUP = 4; @@ -68,8 +71,8 @@ TrackContentWidget::TrackContentWidget( TrackView * parent ) : setAcceptDrops( true ); connect( parent->trackContainerView(), - SIGNAL( positionChanged( const TimePos & ) ), - this, SLOT( changePosition( const TimePos & ) ) ); + SIGNAL( positionChanged( const lmms::TimePos& ) ), + this, SLOT( changePosition( const lmms::TimePos& ) ) ); setStyle( QApplication::style() ); @@ -79,14 +82,6 @@ TrackContentWidget::TrackContentWidget( TrackView * parent ) : -/*! \brief Destroy this trackContentWidget - * - * Destroys the trackContentWidget. - */ -TrackContentWidget::~TrackContentWidget() -{ -} - @@ -179,11 +174,10 @@ void TrackContentWidget::removeClipView( ClipView * clipv ) */ void TrackContentWidget::update() { - for( clipViewVector::iterator it = m_clipViews.begin(); - it != m_clipViews.end(); ++it ) + for (const auto& clipView : m_clipViews) { - ( *it )->setFixedHeight( height() - 1 ); - ( *it )->update(); + clipView->setFixedHeight(height() - 1); + clipView->update(); } QWidget::update(); } @@ -205,28 +199,20 @@ void TrackContentWidget::changePosition( const TimePos & newPos ) setUpdatesEnabled( false ); // first show clip for current pattern... - for( clipViewVector::iterator it = m_clipViews.begin(); - it != m_clipViews.end(); ++it ) + for (const auto& clipView : m_clipViews) { - if ((*it)->getClip()->startPosition().getBar() == curPattern) + if (clipView->getClip()->startPosition().getBar() == curPattern) { - ( *it )->move( 0, ( *it )->y() ); - ( *it )->raise(); - ( *it )->show(); - } - else - { - ( *it )->lower(); + clipView->move(0, clipView->y()); + clipView->raise(); + clipView->show(); } + else { clipView->lower(); } } // ...then hide others to avoid flickering - for( clipViewVector::iterator it = m_clipViews.begin(); - it != m_clipViews.end(); ++it ) + for (const auto& clipView : m_clipViews) { - if ((*it)->getClip()->startPosition().getBar() != curPattern) - { - ( *it )->hide(); - } + if (clipView->getClip()->startPosition().getBar() != curPattern) { clipView->hide(); } } setUpdatesEnabled( true ); return; @@ -243,11 +229,9 @@ void TrackContentWidget::changePosition( const TimePos & newPos ) const float ppb = m_trackView->trackContainerView()->pixelsPerBar(); setUpdatesEnabled( false ); - for( clipViewVector::iterator it = m_clipViews.begin(); - it != m_clipViews.end(); ++it ) + for (const auto& clipView : m_clipViews) { - ClipView * clipv = *it; - Clip * clip = clipv->getClip(); + Clip* clip = clipView->getClip(); clip->changeLength( clip->length() ); @@ -257,17 +241,15 @@ void TrackContentWidget::changePosition( const TimePos & newPos ) ( te >= begin && te <= end ) || ( ts <= begin && te >= end ) ) { - clipv->move( static_cast( ( ts - begin ) * ppb / - TimePos::ticksPerBar() ), - clipv->y() ); - if( !clipv->isVisible() ) + clipView->move(static_cast((ts - begin) * ppb / TimePos::ticksPerBar()), clipView->y()); + if (!clipView->isVisible()) { - clipv->show(); + clipView->show(); } } else { - clipv->move( -clipv->width()-10, clipv->y() ); + clipView->move(-clipView->width() - 10, clipView->y()); } } setUpdatesEnabled( true ); @@ -461,10 +443,9 @@ bool TrackContentWidget::pasteSelection( TimePos clipPos, const QMimeData * md, // Unselect the old group const QVector so = m_trackView->trackContainerView()->selectedObjects(); - for( QVector::const_iterator it = so.begin(); - it != so.end(); ++it ) + for (const auto& obj : so) { - ( *it )->setSelected( false ); + obj->setSelected(false); } @@ -473,7 +454,7 @@ bool TrackContentWidget::pasteSelection( TimePos clipPos, const QMimeData * md, float snapSize = getGUI()->songEditor()->m_editor->getSnapSize(); // All clips should be offset the same amount as the grabbed clip - TimePos offset = TimePos(clipPos - grabbedClipPos); + auto offset = TimePos(clipPos - grabbedClipPos); // Users expect clips to "fall" backwards, so bias the offset offset -= TimePos::ticksPerBar() * snapSize / 2; // The offset is quantized (rather than the positions) to preserve fine adjustments @@ -722,3 +703,6 @@ void TrackContentWidget::setGridColor( const QBrush & c ) //! \brief CSS theming qproperty access method void TrackContentWidget::setEmbossColor( const QBrush & c ) { m_embossColor = c; } + + +} // namespace lmms::gui diff --git a/src/gui/tracks/TrackLabelButton.cpp b/src/gui/tracks/TrackLabelButton.cpp index 3388fe9fb..3f1b45871 100644 --- a/src/gui/tracks/TrackLabelButton.cpp +++ b/src/gui/tracks/TrackLabelButton.cpp @@ -38,7 +38,8 @@ #include "TrackRenameLineEdit.h" #include "TrackView.h" - +namespace lmms::gui +{ TrackLabelButton::TrackLabelButton( TrackView * _tv, QWidget * _parent ) : QToolButton( _parent ), @@ -61,22 +62,17 @@ TrackLabelButton::TrackLabelButton( TrackView * _tv, QWidget * _parent ) : setFixedSize( 160, 29 ); m_renameLineEdit->move( 30, ( height() / 2 ) - ( m_renameLineEdit->sizeHint().height() / 2 ) ); m_renameLineEdit->setFixedWidth( width() - 33 ); - connect( m_renameLineEdit, SIGNAL( editingFinished() ), this, SLOT( renameFinished() ) ); + connect( m_renameLineEdit, SIGNAL(editingFinished()), this, SLOT(renameFinished())); } setIconSize( QSize( 24, 24 ) ); - connect( m_trackView->getTrack(), SIGNAL( dataChanged() ), this, SLOT( update() ) ); - connect( m_trackView->getTrack(), SIGNAL( nameChanged() ), this, SLOT( nameChanged() ) ); + connect( m_trackView->getTrack(), SIGNAL(dataChanged()), this, SLOT(update())); + connect( m_trackView->getTrack(), SIGNAL(nameChanged()), this, SLOT(nameChanged())); } -TrackLabelButton::~TrackLabelButton() -{ -} - - void TrackLabelButton::rename() @@ -109,6 +105,7 @@ void TrackLabelButton::renameFinished() { if( !( ConfigManager::inst()->value( "ui", "compacttrackbuttons" ).toInt() ) ) { + m_renameLineEdit->clearFocus(); m_renameLineEdit->hide(); if( m_renameLineEdit->text() != "" ) { @@ -192,8 +189,7 @@ void TrackLabelButton::paintEvent( QPaintEvent * _pe ) { if( m_trackView->getTrack()->type() == Track::InstrumentTrack ) { - InstrumentTrack * it = - dynamic_cast( m_trackView->getTrack() ); + auto it = dynamic_cast(m_trackView->getTrack()); const PixmapLoader * pl; auto get_logo = [](InstrumentTrack* it) -> const PixmapLoader* { @@ -240,3 +236,6 @@ QString TrackLabelButton::elideName( const QString &name ) QString elidedName = metrics.elidedText( name, Qt::ElideRight, maxTextWidth ); return elidedName; } + + +} // namespace lmms::gui diff --git a/src/gui/tracks/TrackOperationsWidget.cpp b/src/gui/tracks/TrackOperationsWidget.cpp index 4b56282a6..ddbd2eacd 100644 --- a/src/gui/tracks/TrackOperationsWidget.cpp +++ b/src/gui/tracks/TrackOperationsWidget.cpp @@ -47,6 +47,9 @@ #include "TrackContainerView.h" #include "TrackView.h" +namespace lmms::gui +{ + /*! \brief Create a new trackOperationsWidget * * The trackOperationsWidget is the grip and the mute button of a track. @@ -60,9 +63,9 @@ TrackOperationsWidget::TrackOperationsWidget( TrackView * parent ) : setToolTip(tr("Press <%1> while clicking on move-grip " "to begin a new drag'n'drop action." ).arg(UI_CTRL_KEY) ); - QMenu * toMenu = new QMenu( this ); + auto toMenu = new QMenu(this); toMenu->setFont( pointSize<9>( toMenu->font() ) ); - connect( toMenu, SIGNAL( aboutToShow() ), this, SLOT( updateMenu() ) ); + connect( toMenu, SIGNAL(aboutToShow()), this, SLOT(updateMenu())); setObjectName( "automationEnabled" ); @@ -103,13 +106,13 @@ TrackOperationsWidget::TrackOperationsWidget( TrackView * parent ) : m_soloBtn->show(); m_soloBtn->setToolTip(tr("Solo")); - connect( this, SIGNAL( trackRemovalScheduled( TrackView * ) ), + connect( this, SIGNAL(trackRemovalScheduled(lmms::gui::TrackView*)), m_trackView->trackContainerView(), - SLOT( deleteTrackView( TrackView * ) ), + SLOT(deleteTrackView(lmms::gui::TrackView*)), Qt::QueuedConnection ); - connect( m_trackView->getTrack()->getMutedModel(), SIGNAL( dataChanged() ), - this, SLOT( update() ) ); + connect( m_trackView->getTrack()->getMutedModel(), SIGNAL(dataChanged()), + this, SLOT(update())); connect(m_trackView->getTrack(), SIGNAL(colorChanged()), this, SLOT(update())); } @@ -117,13 +120,6 @@ TrackOperationsWidget::TrackOperationsWidget( TrackView * parent ) : -/*! \brief Destroy an existing trackOperationsWidget - * - */ -TrackOperationsWidget::~TrackOperationsWidget() -{ -} - @@ -175,7 +171,7 @@ void TrackOperationsWidget::paintEvent( QPaintEvent * pe ) { QPainter p( this ); - p.fillRect( rect(), palette().brush(QPalette::Background) ); + p.fillRect(rect(), palette().brush(QPalette::Window)); if( m_trackView->getTrack()->useColor() && ! m_trackView->getTrack()->getMutedModel()->value() ) { @@ -199,7 +195,7 @@ bool TrackOperationsWidget::confirmRemoval() .arg(m_trackView->getTrack()->name()); QString messageTitleRemoveTrack = tr("Confirm removal"); QString askAgainText = tr("Don't ask again"); - QCheckBox* askAgainCheckBox = new QCheckBox(askAgainText, nullptr); + auto askAgainCheckBox = new QCheckBox(askAgainText, nullptr); connect(askAgainCheckBox, &QCheckBox::stateChanged, [this](int state){ // Invert button state, if it's checked we *shouldn't* ask again ConfigManager::inst()->setValue("ui", "trackdeletionwarning", state ? "0" : "1"); @@ -327,29 +323,29 @@ void TrackOperationsWidget::updateMenu() toMenu->clear(); toMenu->addAction( embed::getIconPixmap( "edit_copy", 16, 16 ), tr( "Clone this track" ), - this, SLOT( cloneTrack() ) ); + this, SLOT(cloneTrack())); toMenu->addAction( embed::getIconPixmap( "cancel", 16, 16 ), tr( "Remove this track" ), - this, SLOT( removeTrack() ) ); + this, SLOT(removeTrack())); if( ! m_trackView->trackContainerView()->fixedClips() ) { - toMenu->addAction( tr( "Clear this track" ), this, SLOT( clearTrack() ) ); + toMenu->addAction( tr( "Clear this track" ), this, SLOT(clearTrack())); } if (QMenu *mixerMenu = m_trackView->createMixerMenu(tr("Channel %1: %2"), tr("Assign to new Mixer Channel"))) { toMenu->addMenu(mixerMenu); } - if (InstrumentTrackView * trackView = dynamic_cast(m_trackView)) + if (auto trackView = dynamic_cast(m_trackView)) { toMenu->addSeparator(); toMenu->addMenu(trackView->midiMenu()); } if( dynamic_cast( m_trackView ) ) { - toMenu->addAction( tr( "Turn all recording on" ), this, SLOT( recordingOn() ) ); - toMenu->addAction( tr( "Turn all recording off" ), this, SLOT( recordingOff() ) ); + toMenu->addAction( tr( "Turn all recording on" ), this, SLOT(recordingOn())); + toMenu->addAction( tr( "Turn all recording off" ), this, SLOT(recordingOff())); } toMenu->addSeparator(); @@ -366,12 +362,12 @@ void TrackOperationsWidget::updateMenu() void TrackOperationsWidget::toggleRecording( bool on ) { - AutomationTrackView * atv = dynamic_cast( m_trackView ); + auto atv = dynamic_cast(m_trackView); if( atv ) { for( Clip * clip : atv->getTrack()->getClips() ) { - AutomationClip * ap = dynamic_cast( clip ); + auto ap = dynamic_cast(clip); if( ap ) { ap->setRecording( on ); } } atv->update(); @@ -391,3 +387,5 @@ void TrackOperationsWidget::recordingOff() toggleRecording( false ); } + +} // namespace lmms::gui diff --git a/src/gui/tracks/TrackRenameLineEdit.cpp b/src/gui/tracks/TrackRenameLineEdit.cpp index b68af3141..dab827ff9 100644 --- a/src/gui/tracks/TrackRenameLineEdit.cpp +++ b/src/gui/tracks/TrackRenameLineEdit.cpp @@ -30,6 +30,8 @@ #include +namespace lmms::gui +{ TrackRenameLineEdit::TrackRenameLineEdit( QWidget * parent ) : @@ -59,3 +61,6 @@ void TrackRenameLineEdit::keyPressEvent( QKeyEvent * ke ) QLineEdit::keyPressEvent( ke ); } + + +} // namespace lmms::gui \ No newline at end of file diff --git a/src/gui/tracks/TrackView.cpp b/src/gui/tracks/TrackView.cpp index 888af3c5f..0aabc705d 100644 --- a/src/gui/tracks/TrackView.cpp +++ b/src/gui/tracks/TrackView.cpp @@ -45,6 +45,9 @@ #include "ClipView.h" +namespace lmms::gui +{ + /*! \brief Create a new track View. * * The track View is handles the actual display of the track, including @@ -71,7 +74,7 @@ TrackView::TrackView( Track * track, TrackContainerView * tcv ) : m_trackSettingsWidget.setAutoFillBackground( true ); - QHBoxLayout * layout = new QHBoxLayout( this ); + auto layout = new QHBoxLayout(this); layout->setMargin( 0 ); layout->setSpacing( 0 ); layout->addWidget( &m_trackOperationsWidget ); @@ -85,25 +88,25 @@ TrackView::TrackView( Track * track, TrackContainerView * tcv ) : setAttribute( Qt::WA_DeleteOnClose, true ); - connect( m_track, SIGNAL( destroyedTrack() ), this, SLOT( close() ) ); + connect( m_track, SIGNAL(destroyedTrack()), this, SLOT(close())); connect( m_track, - SIGNAL( clipAdded( Clip * ) ), - this, SLOT( createClipView( Clip * ) ), + SIGNAL(clipAdded(lmms::Clip*)), + this, SLOT(createClipView(lmms::Clip*)), Qt::QueuedConnection ); - connect( &m_track->m_mutedModel, SIGNAL( dataChanged() ), - &m_trackContentWidget, SLOT( update() ) ); + connect( &m_track->m_mutedModel, SIGNAL(dataChanged()), + &m_trackContentWidget, SLOT(update())); connect(&m_track->m_mutedModel, SIGNAL(dataChanged()), this, SLOT(muteChanged())); - connect( &m_track->m_soloModel, SIGNAL( dataChanged() ), - m_track, SLOT( toggleSolo() ), Qt::DirectConnection ); + connect( &m_track->m_soloModel, SIGNAL(dataChanged()), + m_track, SLOT(toggleSolo()), Qt::DirectConnection ); // create views for already existing clips - for( Track::clipVector::iterator it = m_track->m_clips.begin(); it != m_track->m_clips.end(); ++it ) + for (const auto& clip : m_track->m_clips) { - createClipView( *it ); + createClipView(clip); } m_trackContainerView->addTrackView( this ); @@ -112,12 +115,6 @@ TrackView::TrackView( Track * track, TrackContainerView * tcv ) : -/*! \brief Destroy this track View. - * - */ -TrackView::~TrackView() -{ -} @@ -193,7 +190,7 @@ void TrackView::modelChanged() { m_track = castModel(); Q_ASSERT( m_track != nullptr ); - connect( m_track, SIGNAL( destroyedTrack() ), this, SLOT( close() ) ); + connect( m_track, SIGNAL(destroyedTrack()), this, SLOT(close())); m_trackOperationsWidget.m_muteBtn->setModel( &m_track->m_mutedModel ); m_trackOperationsWidget.m_soloBtn->setModel( &m_track->m_soloModel ); ModelView::modelChanged(); @@ -446,3 +443,6 @@ void TrackView::setIndicatorMute(FadeButton* indicator, bool muted) QPalette::ColorRole role = muted ? QPalette::Highlight : QPalette::BrightText; indicator->setActiveColor(QApplication::palette().color(QPalette::Active, role)); } + + +} // namespace lmms::gui diff --git a/src/gui/widgets/AutomatableButton.cpp b/src/gui/widgets/AutomatableButton.cpp index 80d127877..6e9cd23e4 100644 --- a/src/gui/widgets/AutomatableButton.cpp +++ b/src/gui/widgets/AutomatableButton.cpp @@ -31,6 +31,8 @@ #include "StringPairDrag.h" +namespace lmms::gui +{ AutomatableButton::AutomatableButton( QWidget * _parent, const QString & _name ) : @@ -124,7 +126,7 @@ void AutomatableButton::mousePressEvent( QMouseEvent * _me ) if( m_group ) { // A group, we must get process it instead - AutomatableModelView* groupView = (AutomatableModelView*)m_group; + auto groupView = (AutomatableModelView*)m_group; new StringPairDrag( "automatable_model", QString::number( groupView->modelUntyped()->id() ), QPixmap(), widget() ); @@ -190,10 +192,9 @@ automatableButtonGroup::automatableButtonGroup( QWidget * _parent, automatableButtonGroup::~automatableButtonGroup() { - for( QList::iterator it = m_buttons.begin(); - it != m_buttons.end(); ++it ) + for (const auto& button : m_buttons) { - ( *it )->m_group = nullptr; + button->m_group = nullptr; } } @@ -244,8 +245,8 @@ void automatableButtonGroup::activateButton( AutomatableButton * _btn ) void automatableButtonGroup::modelChanged() { - connect( model(), SIGNAL( dataChanged() ), - this, SLOT( updateButtons() ) ); + connect( model(), SIGNAL(dataChanged()), + this, SLOT(updateButtons())); IntModelView::modelChanged(); updateButtons(); } @@ -266,4 +267,4 @@ void automatableButtonGroup::updateButtons() - +} // namespace lmms::gui diff --git a/src/gui/widgets/AutomatableSlider.cpp b/src/gui/widgets/AutomatableSlider.cpp index f44732de1..7e1be0e06 100644 --- a/src/gui/widgets/AutomatableSlider.cpp +++ b/src/gui/widgets/AutomatableSlider.cpp @@ -30,6 +30,8 @@ #include "CaptionMenu.h" +namespace lmms::gui +{ AutomatableSlider::AutomatableSlider( QWidget * _parent, @@ -40,19 +42,15 @@ AutomatableSlider::AutomatableSlider( QWidget * _parent, { setWindowTitle( _name ); - connect( this, SIGNAL( valueChanged( int ) ), - this, SLOT( changeValue( int ) ) ); - connect( this, SIGNAL( sliderMoved( int ) ), - this, SLOT( moveSlider( int ) ) ); + connect( this, SIGNAL(valueChanged(int)), + this, SLOT(changeValue(int))); + connect( this, SIGNAL(sliderMoved(int)), + this, SLOT(moveSlider(int))); } -AutomatableSlider::~AutomatableSlider() -{ -} - @@ -107,8 +105,8 @@ void AutomatableSlider::modelChanged() { QSlider::setRange( model()->minValue(), model()->maxValue() ); updateSlider(); - connect( model(), SIGNAL( dataChanged() ), - this, SLOT( updateSlider() ) ); + connect( model(), SIGNAL(dataChanged()), + this, SLOT(updateSlider())); } @@ -140,5 +138,5 @@ void AutomatableSlider::updateSlider() - +} // namespace lmms::gui diff --git a/src/gui/widgets/CPULoadWidget.cpp b/src/gui/widgets/CPULoadWidget.cpp index 4cc6bca9f..799e037ef 100644 --- a/src/gui/widgets/CPULoadWidget.cpp +++ b/src/gui/widgets/CPULoadWidget.cpp @@ -32,6 +32,10 @@ #include "Engine.h" +namespace lmms::gui +{ + + CPULoadWidget::CPULoadWidget( QWidget * _parent ) : QWidget( _parent ), m_currentLoad( 0 ), @@ -47,18 +51,14 @@ CPULoadWidget::CPULoadWidget( QWidget * _parent ) : m_temp = QPixmap( width(), height() ); - connect( &m_updateTimer, SIGNAL( timeout() ), - this, SLOT( updateCpuLoad() ) ); + connect( &m_updateTimer, SIGNAL(timeout()), + this, SLOT(updateCpuLoad())); m_updateTimer.start( 100 ); // update cpu-load at 10 fps } -CPULoadWidget::~CPULoadWidget() -{ -} - @@ -102,7 +102,4 @@ void CPULoadWidget::updateCpuLoad() } - - - - +} // namespace lmms::gui \ No newline at end of file diff --git a/src/gui/widgets/CaptionMenu.cpp b/src/gui/widgets/CaptionMenu.cpp index bfd743d0d..bfcd3003e 100644 --- a/src/gui/widgets/CaptionMenu.cpp +++ b/src/gui/widgets/CaptionMenu.cpp @@ -26,6 +26,8 @@ #include "CaptionMenu.h" +namespace lmms::gui +{ CaptionMenu::CaptionMenu( const QString & _title, QWidget * _parent ) : @@ -38,6 +40,5 @@ CaptionMenu::CaptionMenu( const QString & _title, QWidget * _parent ) : -CaptionMenu::~CaptionMenu() -{ -} + +} // namespace lmms::gui diff --git a/src/gui/widgets/ComboBox.cpp b/src/gui/widgets/ComboBox.cpp index 181256b96..bdf78ccce 100644 --- a/src/gui/widgets/ComboBox.cpp +++ b/src/gui/widgets/ComboBox.cpp @@ -36,6 +36,8 @@ #include "embed.h" #include "gui_templates.h" +namespace lmms::gui +{ QPixmap * ComboBox::s_background = nullptr; QPixmap * ComboBox::s_arrow = nullptr; @@ -70,8 +72,8 @@ ComboBox::ComboBox( QWidget * _parent, const QString & _name ) : setFont( pointSize<9>( font() ) ); m_menu.setFont( pointSize<8>( m_menu.font() ) ); - connect( &m_menu, SIGNAL( triggered( QAction * ) ), - this, SLOT( setItem( QAction * ) ) ); + connect( &m_menu, SIGNAL(triggered(QAction*)), + this, SLOT(setItem(QAction*))); setWindowTitle( _name ); doConnections(); @@ -80,10 +82,6 @@ ComboBox::ComboBox( QWidget * _parent, const QString & _name ) : -ComboBox::~ComboBox() -{ -} - void ComboBox::selectNext() @@ -249,6 +247,6 @@ void ComboBox::setItem( QAction* item ) } - +} // namespace lmms::gui diff --git a/src/gui/widgets/CustomTextKnob.cpp b/src/gui/widgets/CustomTextKnob.cpp index 149b3494b..9f6e19b90 100644 --- a/src/gui/widgets/CustomTextKnob.cpp +++ b/src/gui/widgets/CustomTextKnob.cpp @@ -1,5 +1,9 @@ #include "CustomTextKnob.h" +namespace lmms::gui +{ + + CustomTextKnob::CustomTextKnob( knobTypes _knob_num, QWidget * _parent, const QString & _name, const QString & _value_text ) : Knob( _knob_num, _parent, _name ), m_value_text( _value_text ) {} @@ -12,3 +16,6 @@ QString CustomTextKnob::displayValue() const { return m_description.trimmed() + m_value_text; } + + +} // namespace lmms::gui diff --git a/src/gui/widgets/Fader.cpp b/src/gui/widgets/Fader.cpp index f569aa550..f853ff707 100644 --- a/src/gui/widgets/Fader.cpp +++ b/src/gui/widgets/Fader.cpp @@ -56,6 +56,9 @@ #include "ConfigManager.h" #include "TextFloat.h" +namespace lmms::gui +{ + TextFloat * Fader::s_textFloat = nullptr; QPixmap * Fader::s_back = nullptr; @@ -165,7 +168,7 @@ void Fader::mouseMoveEvent( QMouseEvent *mouseEvent ) float delta = dy * ( model()->maxValue() - model()->minValue() ) / (float) ( height() - ( *m_knob ).height() ); - const float step = model()->step(); + const auto step = model()->step(); float newValue = static_cast( static_cast( ( m_startValue + delta ) / step + 0.5 ) ) * step; model()->setValue( newValue ); @@ -478,3 +481,6 @@ void Fader::setPeakYellow( const QColor & c ) { m_peakYellow = c; } + + +} // namespace lmms::gui \ No newline at end of file diff --git a/src/gui/widgets/Graph.cpp b/src/gui/widgets/Graph.cpp index 71e8375ee..53a0a130d 100644 --- a/src/gui/widgets/Graph.cpp +++ b/src/gui/widgets/Graph.cpp @@ -30,6 +30,11 @@ #include "SampleBuffer.h" #include "Oscillator.h" +namespace lmms +{ + +namespace gui +{ Graph::Graph( QWidget * _parent, graphStyle _style, int _width, int _height ) : @@ -45,13 +50,13 @@ Graph::Graph( QWidget * _parent, graphStyle _style, int _width, setAcceptDrops( true ); setCursor( Qt::CrossCursor ); - graphModel * gModel = castModel(); + auto gModel = castModel(); - QObject::connect( gModel, SIGNAL( samplesChanged( int, int ) ), - this, SLOT( updateGraph( int, int ) ) ); + QObject::connect( gModel, SIGNAL(samplesChanged(int,int)), + this, SLOT(updateGraph(int,int))); - QObject::connect( gModel, SIGNAL( lengthChanged( ) ), - this, SLOT( updateGraph( ) ) ); + QObject::connect( gModel, SIGNAL(lengthChanged()), + this, SLOT(updateGraph())); } void Graph::setForeground( const QPixmap &_pixmap ) @@ -428,13 +433,13 @@ void Graph::dragEnterEvent( QDragEnterEvent * _dee ) void Graph::modelChanged() { - graphModel * gModel = castModel(); + auto gModel = castModel(); - QObject::connect( gModel, SIGNAL( samplesChanged( int, int ) ), - this, SLOT( updateGraph( int, int ) ) ); + QObject::connect( gModel, SIGNAL(samplesChanged(int,int)), + this, SLOT(updateGraph(int,int))); - QObject::connect( gModel, SIGNAL( lengthChanged( ) ), - this, SLOT( updateGraph( ) ) ); + QObject::connect( gModel, SIGNAL(lengthChanged()), + this, SLOT(updateGraph())); } @@ -451,8 +456,10 @@ void Graph::updateGraph() } +} // namespace gui + graphModel::graphModel( float _min, float _max, int _length, - ::Model * _parent, bool _default_constructed, float _step ) : + Model* _parent, bool _default_constructed, float _step ) : Model( _parent, tr( "Graph" ), _default_constructed ), m_samples( _length ), m_length( _length ), @@ -581,7 +588,7 @@ void graphModel::setWaveToNoise() QString graphModel::setWaveToUser() { - SampleBuffer * sampleBuffer = new SampleBuffer; + auto sampleBuffer = new SampleBuffer; QString fileName = sampleBuffer->openAndSetWaveformFile(); if( fileName.isEmpty() == false ) { @@ -744,6 +751,4 @@ void graphModel::drawSampleAt( int x, float val ) } - - - +} // namespace lmms diff --git a/src/gui/widgets/GrooveView.cpp b/src/gui/widgets/GrooveView.cpp index fa865999b..cb07d8299 100644 --- a/src/gui/widgets/GrooveView.cpp +++ b/src/gui/widgets/GrooveView.cpp @@ -17,6 +17,9 @@ #include "MidiSwing.h" +namespace lmms::gui +{ + GrooveView::GrooveView(QWidget * parent) : QWidget(parent) { @@ -132,3 +135,5 @@ void GrooveView::setView(Groove * groove) m_layout->addWidget(view); } + +} // namespace lmms::gui diff --git a/src/gui/widgets/GroupBox.cpp b/src/gui/widgets/GroupBox.cpp index b8378d54f..b5187de25 100644 --- a/src/gui/widgets/GroupBox.cpp +++ b/src/gui/widgets/GroupBox.cpp @@ -34,6 +34,9 @@ #include "gui_templates.h" +namespace lmms::gui +{ + GroupBox::GroupBox( const QString & _caption, QWidget * _parent ) : QWidget( _parent ), @@ -101,3 +104,6 @@ void GroupBox::paintEvent( QPaintEvent * pe ) p.setFont( pointSize<8>( font() ) ); p.drawText( 22, m_titleBarHeight, m_caption ); } + + +} // namespace lmms::gui diff --git a/src/gui/widgets/Knob.cpp b/src/gui/widgets/Knob.cpp index 96ef6fec8..049a86be1 100644 --- a/src/gui/widgets/Knob.cpp +++ b/src/gui/widgets/Knob.cpp @@ -48,6 +48,10 @@ #include "StringPairDrag.h" #include "TextFloat.h" + +namespace lmms::gui +{ + TextFloat * Knob::s_textFloat = nullptr; @@ -511,7 +515,7 @@ void Knob::contextMenuEvent( QContextMenuEvent * ) addDefaultActions( &contextMenu ); contextMenu.addAction( QPixmap(), model()->isScaleLogarithmic() ? tr( "Set linear" ) : tr( "Set logarithmic" ), - this, SLOT( toggleScale() ) ); + this, SLOT(toggleScale())); contextMenu.addSeparator(); contextMenu.exec( QCursor::pos() ); } @@ -545,9 +549,7 @@ void Knob::dropEvent( QDropEvent * _de ) } else if( type == "automatable_model" ) { - AutomatableModel * mod = dynamic_cast( - Engine::projectJournal()-> - journallingObject( val.toInt() ) ); + auto mod = dynamic_cast(Engine::projectJournal()->journallingObject(val.toInt())); if( mod != nullptr ) { AutomatableModel::linkModels( model(), mod ); @@ -705,7 +707,7 @@ void Knob::wheelEvent(QWheelEvent * we) void Knob::setPosition( const QPoint & _p ) { const float value = getValue( _p ) + m_leftOver; - const float step = model()->step(); + const auto step = model()->step(); const float oldValue = model()->value(); @@ -825,11 +827,11 @@ void Knob::doConnections() { if( model() != nullptr ) { - QObject::connect( model(), SIGNAL( dataChanged() ), - this, SLOT( friendlyUpdate() ) ); + QObject::connect( model(), SIGNAL(dataChanged()), + this, SLOT(friendlyUpdate())); - QObject::connect( model(), SIGNAL( propertiesChanged() ), - this, SLOT( update() ) ); + QObject::connect( model(), SIGNAL(propertiesChanged()), + this, SLOT(update())); } } @@ -864,3 +866,6 @@ void convertPixmapToGrayScale(QPixmap& pixMap) } pixMap.convertFromImage(temp); } + + +} // namespace lmms::gui diff --git a/src/gui/widgets/LcdFloatSpinBox.cpp b/src/gui/widgets/LcdFloatSpinBox.cpp index 22b4d5509..e57012e10 100644 --- a/src/gui/widgets/LcdFloatSpinBox.cpp +++ b/src/gui/widgets/LcdFloatSpinBox.cpp @@ -43,6 +43,9 @@ #include "gui_templates.h" #include "MainWindow.h" +namespace lmms::gui +{ + LcdFloatSpinBox::LcdFloatSpinBox(int numWhole, int numFrac, const QString& name, QWidget* parent) : FloatModelView(new FloatModel(0, 0, 0, 0, nullptr, name, true), this), @@ -73,14 +76,14 @@ LcdFloatSpinBox::LcdFloatSpinBox(int numWhole, int numFrac, const QString& style void LcdFloatSpinBox::layoutSetup(const QString &style) { // Assemble the LCD parts - QHBoxLayout *lcdLayout = new QHBoxLayout(); + auto lcdLayout = new QHBoxLayout(); m_wholeDisplay.setSeamless(false, true); m_fractionDisplay.setSeamless(true, false); lcdLayout->addWidget(&m_wholeDisplay); - QLabel *dotLabel = new QLabel("", this); + auto dotLabel = new QLabel("", this); QPixmap dotPixmap(embed::getIconPixmap(QString("lcd_" + style + "_dot").toUtf8().constData())); dotLabel->setPixmap(dotPixmap.copy(0, 0, dotPixmap.size().width(), dotPixmap.size().height() / 2)); lcdLayout->addWidget(dotLabel); @@ -91,7 +94,7 @@ void LcdFloatSpinBox::layoutSetup(const QString &style) lcdLayout->setSpacing(0); // Add space for label - QVBoxLayout *outerLayout = new QVBoxLayout(); + auto outerLayout = new QVBoxLayout(); outerLayout->addLayout(lcdLayout); outerLayout->addSpacing(9); outerLayout->setContentsMargins(0, 0, 0, 0); @@ -241,3 +244,6 @@ void LcdFloatSpinBox::paintEvent(QPaintEvent*) p.drawText(width() / 2 - p.fontMetrics().width(m_label) / 2, height() - 1, m_label); } } + + +} // namespace lmms::gui diff --git a/src/gui/widgets/LcdSpinBox.cpp b/src/gui/widgets/LcdSpinBox.cpp index ef0d08aae..b53d7ddb5 100644 --- a/src/gui/widgets/LcdSpinBox.cpp +++ b/src/gui/widgets/LcdSpinBox.cpp @@ -31,6 +31,8 @@ #include "CaptionMenu.h" +namespace lmms::gui +{ LcdSpinBox::LcdSpinBox( int numDigits, QWidget* parent, const QString& name ) : LcdWidget( numDigits, parent, name ), @@ -106,7 +108,7 @@ void LcdSpinBox::mouseMoveEvent( QMouseEvent* event ) int dy = event->globalY() - m_lastMousePos.y(); if( dy ) { - float fdy = static_cast(dy); + auto fdy = static_cast(dy); if( event->modifiers() & Qt::ShiftModifier ) { fdy = qBound( -4.f, fdy/4.f, 4.f ); } @@ -169,3 +171,4 @@ void LcdSpinBox::enterValue() } } +} // namespace lmms::gui diff --git a/src/gui/widgets/LcdWidget.cpp b/src/gui/widgets/LcdWidget.cpp index c947f7720..0f5e13466 100644 --- a/src/gui/widgets/LcdWidget.cpp +++ b/src/gui/widgets/LcdWidget.cpp @@ -34,7 +34,8 @@ #include "gui_templates.h" - +namespace lmms::gui +{ LcdWidget::LcdWidget(QWidget* parent, const QString& name, bool leadingZero) : LcdWidget(1, parent, name, leadingZero) @@ -163,13 +164,12 @@ void LcdWidget::paintEvent( QPaintEvent* ) } // Digits - for( int i=0; i < m_display.length(); i++ ) + for (const auto& digit : m_display) { - int val = m_display[i].digitValue(); + int val = digit.digitValue(); if( val < 0 ) { - if( m_display[i] == '-' ) - val = 11; + if (digit == '-') val = 11; else val = 10; } @@ -290,3 +290,4 @@ void LcdWidget::initUi(const QString& name , const QString& style) updateSize(); } +} // namespace lmms::gui diff --git a/src/gui/widgets/LedCheckBox.cpp b/src/gui/widgets/LedCheckBox.cpp index 832d7da46..1be072815 100644 --- a/src/gui/widgets/LedCheckBox.cpp +++ b/src/gui/widgets/LedCheckBox.cpp @@ -31,8 +31,11 @@ #include "embed.h" #include "gui_templates.h" +namespace lmms::gui +{ -static const QString names[LedCheckBox::NumColors] = + +static const auto names = std::array { "led_yellow", "led_green", "led_red" } ; @@ -127,6 +130,4 @@ void LedCheckBox::onTextUpdated() } - - - +} // namespace lmms::gui diff --git a/src/gui/widgets/LeftRightNav.cpp b/src/gui/widgets/LeftRightNav.cpp index a76b4ec6d..30f7106d3 100644 --- a/src/gui/widgets/LeftRightNav.cpp +++ b/src/gui/widgets/LeftRightNav.cpp @@ -28,6 +28,9 @@ #include "LeftRightNav.h" #include "embed.h" +namespace lmms::gui +{ + LeftRightNav::LeftRightNav(QWidget *parent) : QWidget(parent), @@ -90,3 +93,6 @@ void LeftRightNav::setShortcuts(const QKeySequence &leftShortcut, const QKeySequ m_leftBtn.setToolTip(tr("Previous (%1)").arg(leftShortcut.toString())); m_rightBtn.setToolTip(tr("Next (%1)").arg(rightShortcut.toString())); } + + +} // namespace lmms::gui diff --git a/src/gui/widgets/MeterDialog.cpp b/src/gui/widgets/MeterDialog.cpp index deeeb0599..938177dce 100644 --- a/src/gui/widgets/MeterDialog.cpp +++ b/src/gui/widgets/MeterDialog.cpp @@ -33,17 +33,20 @@ #include "gui_templates.h" #include "LcdSpinBox.h" +namespace lmms::gui +{ + MeterDialog::MeterDialog( QWidget * _parent, bool _simple ) : QWidget( _parent ), ModelView( nullptr, this ) { - QVBoxLayout * vlayout = new QVBoxLayout( this ); + auto vlayout = new QVBoxLayout(this); vlayout->setSpacing( 0 ); vlayout->setMargin( 0 ); - QWidget * num = new QWidget( this ); - QHBoxLayout * num_layout = new QHBoxLayout( num ); + auto num = new QWidget(this); + auto num_layout = new QHBoxLayout(num); num_layout->setSpacing( 0 ); num_layout->setMargin( 0 ); @@ -55,7 +58,7 @@ MeterDialog::MeterDialog( QWidget * _parent, bool _simple ) : if( !_simple ) { - QLabel * num_label = new QLabel( tr( "Meter Numerator" ), num ); + auto num_label = new QLabel(tr("Meter Numerator"), num); QFont f = num_label->font(); num_label->setFont( pointSize<7>( f ) ); num_layout->addSpacing( 5 ); @@ -63,9 +66,8 @@ MeterDialog::MeterDialog( QWidget * _parent, bool _simple ) : } num_layout->addStretch(); - - QWidget * den = new QWidget( this ); - QHBoxLayout * den_layout = new QHBoxLayout( den ); + auto den = new QWidget(this); + auto den_layout = new QHBoxLayout(den); den_layout->setSpacing( 0 ); den_layout->setMargin( 0 ); @@ -80,8 +82,7 @@ MeterDialog::MeterDialog( QWidget * _parent, bool _simple ) : if( !_simple ) { - QLabel * den_label = new QLabel( tr( "Meter Denominator" ), - den ); + auto den_label = new QLabel(tr("Meter Denominator"), den); QFont f = den_label->font(); den_label->setFont( pointSize<7>( f ) ); den_layout->addSpacing( 5 ); @@ -100,17 +101,15 @@ MeterDialog::MeterDialog( QWidget * _parent, bool _simple ) : -MeterDialog::~MeterDialog() -{ -} - void MeterDialog::modelChanged() { - MeterModel * mm = castModel(); + auto mm = castModel(); m_numerator->setModel( &mm->numeratorModel() ); m_denominator->setModel( &mm->denominatorModel() ); } + +} // namespace lmms::gui diff --git a/src/gui/widgets/MixerLineLcdSpinBox.cpp b/src/gui/widgets/MixerLineLcdSpinBox.cpp index bdf8ac8f9..06eb823c0 100644 --- a/src/gui/widgets/MixerLineLcdSpinBox.cpp +++ b/src/gui/widgets/MixerLineLcdSpinBox.cpp @@ -29,6 +29,10 @@ #include "GuiApplication.h" #include "TrackView.h" +namespace lmms::gui +{ + + void MixerLineLcdSpinBox::setTrackView(TrackView * tv) { m_tv = tv; @@ -64,3 +68,6 @@ void MixerLineLcdSpinBox::contextMenuEvent(QContextMenuEvent* event) addDefaultActions(contextMenu); contextMenu->exec(QCursor::pos()); } + + +} // namespace lmms::gui diff --git a/src/gui/widgets/NStateButton.cpp b/src/gui/widgets/NStateButton.cpp index 41832138b..4fbcc0d65 100644 --- a/src/gui/widgets/NStateButton.cpp +++ b/src/gui/widgets/NStateButton.cpp @@ -28,6 +28,9 @@ #include "NStateButton.h" +namespace lmms::gui +{ + NStateButton::NStateButton( QWidget * _parent ) : ToolButton( _parent ), @@ -92,3 +95,6 @@ void NStateButton::mousePressEvent( QMouseEvent * _me ) } ToolButton::mousePressEvent( _me ); } + + +} // namespace lmms::gui \ No newline at end of file diff --git a/src/gui/widgets/Oscilloscope.cpp b/src/gui/widgets/Oscilloscope.cpp index 30296b805..bec45c162 100644 --- a/src/gui/widgets/Oscilloscope.cpp +++ b/src/gui/widgets/Oscilloscope.cpp @@ -36,6 +36,9 @@ #include "embed.h" #include "BufferManager.h" +namespace lmms::gui +{ + Oscilloscope::Oscilloscope( QWidget * _p ) : QWidget( _p ), @@ -88,20 +91,20 @@ void Oscilloscope::setActive( bool _active ) if( m_active ) { connect( getGUI()->mainWindow(), - SIGNAL( periodicUpdate() ), - this, SLOT( update() ) ); + SIGNAL(periodicUpdate()), + this, SLOT(update())); connect( Engine::audioEngine(), - SIGNAL( nextAudioBuffer( const surroundSampleFrame* ) ), - this, SLOT( updateAudioBuffer( const surroundSampleFrame* ) ) ); + SIGNAL(nextAudioBuffer(const lmms::surroundSampleFrame*)), + this, SLOT(updateAudioBuffer(const lmms::surroundSampleFrame*)) ); } else { disconnect( getGUI()->mainWindow(), - SIGNAL( periodicUpdate() ), - this, SLOT( update() ) ); + SIGNAL(periodicUpdate()), + this, SLOT(update())); disconnect( Engine::audioEngine(), - SIGNAL( nextAudioBuffer( const surroundSampleFrame* ) ), - this, SLOT( updateAudioBuffer( const surroundSampleFrame* ) ) ); + SIGNAL( nextAudioBuffer( const lmms::surroundSampleFrame* ) ), + this, SLOT( updateAudioBuffer( const lmms::surroundSampleFrame* ) ) ); // we have to update (remove last waves), // because timer doesn't do that anymore update(); @@ -204,4 +207,4 @@ QColor const & Oscilloscope::determineLineColor(float level) const } - +} // namespace lmms::gui diff --git a/src/gui/widgets/PixmapButton.cpp b/src/gui/widgets/PixmapButton.cpp index 9bedfe1b5..13c09c52e 100644 --- a/src/gui/widgets/PixmapButton.cpp +++ b/src/gui/widgets/PixmapButton.cpp @@ -30,6 +30,8 @@ #include "PixmapButton.h" #include "embed.h" +namespace lmms::gui +{ PixmapButton::PixmapButton( QWidget * _parent, const QString & _name ) : @@ -45,10 +47,6 @@ PixmapButton::PixmapButton( QWidget * _parent, const QString & _name ) : -PixmapButton::~PixmapButton() -{ -} - @@ -142,6 +140,4 @@ QSize PixmapButton::sizeHint() const } - - - +} // namespace lmms::gui diff --git a/src/gui/widgets/TabBar.cpp b/src/gui/widgets/TabBar.cpp index 30822c85f..d3c1fa0c5 100644 --- a/src/gui/widgets/TabBar.cpp +++ b/src/gui/widgets/TabBar.cpp @@ -28,6 +28,9 @@ #include "gui_templates.h" +namespace lmms::gui +{ + TabBar::TabBar( QWidget * _parent, QBoxLayout::Direction _dir ) : QWidget( _parent ), @@ -51,8 +54,8 @@ TabButton * TabBar::addTab( QWidget * _w, const QString & _text, int _id, } QString caption = ( _text_is_tooltip ) ? QString( "" ) : _text; // create tab-button - TabButton * b = new TabButton( caption, _id, this ); - connect( b, SIGNAL( clicked( int ) ), this, SLOT( tabClicked( int ) ) ); + auto b = new TabButton(caption, _id, this); + connect( b, SIGNAL(clicked(int)), this, SLOT(tabClicked(int))); b->setIconSize( QSize( 48, 48 ) ); b->setFixedSize( 64, 64 ); b->show(); @@ -229,9 +232,4 @@ bool TabBar::allHidden() } - - - - - - +} // namespace lmms::gui diff --git a/src/gui/widgets/TabWidget.cpp b/src/gui/widgets/TabWidget.cpp index 07889c331..106387e42 100644 --- a/src/gui/widgets/TabWidget.cpp +++ b/src/gui/widgets/TabWidget.cpp @@ -35,6 +35,9 @@ #include "embed.h" #include "gui_templates.h" +namespace lmms::gui +{ + TabWidget::TabWidget(const QString & caption, QWidget * parent, bool usePixmap, bool resizable) : QWidget( parent ), @@ -149,7 +152,7 @@ bool TabWidget::event(QEvent *event) if ( event->type() == QEvent::ToolTip ) { - QHelpEvent *helpEvent = static_cast(event); + auto helpEvent = static_cast(event); int idx = findTabAtPos( & helpEvent->pos() ); @@ -197,10 +200,9 @@ void TabWidget::resizeEvent( QResizeEvent * ) { if (!m_resizable) { - for ( widgetStack::iterator it = m_widgets.begin(); - it != m_widgets.end(); ++it ) + for (const auto& widget : m_widgets) { - ( *it ).w->setFixedSize( width() - 4, height() - m_tabbarHeight ); + widget.w->setFixedSize(width() - 4, height() - m_tabbarHeight); } } } @@ -317,11 +319,10 @@ QSize TabWidget::minimumSizeHint() const if (m_resizable) { int maxWidth = 0, maxHeight = 0; - for ( widgetStack::const_iterator it = m_widgets.begin(); - it != m_widgets.end(); ++it ) + for (const auto& widget : m_widgets) { - maxWidth = std::max(maxWidth, it->w->minimumSizeHint().width()); - maxHeight = std::max(maxHeight, it->w->minimumSizeHint().height()); + maxWidth = std::max(maxWidth, widget.w->minimumSizeHint().width()); + maxHeight = std::max(maxHeight, widget.w->minimumSizeHint().height()); } // "-1" : // in "addTab", under "Position tab's window", the widget is @@ -339,11 +340,10 @@ QSize TabWidget::sizeHint() const if (m_resizable) { int maxWidth = 0, maxHeight = 0; - for ( widgetStack::const_iterator it = m_widgets.begin(); - it != m_widgets.end(); ++it ) + for (const auto& widget : m_widgets) { - maxWidth = std::max(maxWidth, it->w->sizeHint().width()); - maxHeight = std::max(maxHeight, it->w->sizeHint().height()); + maxWidth = std::max(maxWidth, widget.w->sizeHint().width()); + maxHeight = std::max(maxHeight, widget.w->sizeHint().height()); } // "-1" : // in "addTab", under "Position tab's window", the widget is @@ -415,3 +415,6 @@ void TabWidget::setTabBorder( const QColor & c ) { m_tabBorder = c; } + + +} // namespace lmms::gui diff --git a/src/gui/widgets/TempoSyncKnob.cpp b/src/gui/widgets/TempoSyncKnob.cpp index bb4faea26..86ee6df3c 100644 --- a/src/gui/widgets/TempoSyncKnob.cpp +++ b/src/gui/widgets/TempoSyncKnob.cpp @@ -37,6 +37,10 @@ #include "SubWindow.h" +namespace lmms::gui +{ + + TempoSyncKnob::TempoSyncKnob( knobTypes _knob_num, QWidget * _parent, const QString & _name ) : @@ -71,10 +75,10 @@ void TempoSyncKnob::modelChanged() { m_custom->setModel( &model()->m_custom ); } - connect( model(), SIGNAL( syncModeChanged( TempoSyncMode ) ), - this, SLOT( updateDescAndIcon() ) ); - connect( this, SIGNAL( sliderMoved( float ) ), - model(), SLOT( disableSync() ) ); + connect( model(), SIGNAL(syncModeChanged(lmms::TempoSyncKnobModel::TempoSyncMode)), + this, SLOT(updateDescAndIcon())); + connect( this, SIGNAL(sliderMoved(float)), + model(), SLOT(disableSync())); updateDescAndIcon(); } @@ -97,8 +101,8 @@ void TempoSyncKnob::contextMenuEvent( QContextMenuEvent * ) if( limit / 8.0f <= model()->maxValue() ) { - connect( syncMenu, SIGNAL( triggered( QAction * ) ), - model(), SLOT( setTempoSync( QAction * ) ) ); + connect( syncMenu, SIGNAL(triggered(QAction*)), + model(), SLOT(setTempoSync(QAction*))); syncMenu->addAction( embed::getIconPixmap( "note_none" ), tr( "No Sync" ) )->setData( (int) TempoSyncKnobModel::SyncNone ); if( limit / 0.125f <= model()->maxValue() ) @@ -142,7 +146,7 @@ void TempoSyncKnob::contextMenuEvent( QContextMenuEvent * ) (int) TempoSyncKnobModel::SyncThirtysecondNote ); syncMenu->addAction( embed::getIconPixmap( "dont_know" ), tr( "Custom..." ), - this, SLOT( showCustom() ) + this, SLOT(showCustom()) )->setData( (int) TempoSyncKnobModel::SyncCustom ); contextMenu.addSeparator(); @@ -308,4 +312,4 @@ void TempoSyncKnob::showCustom() - +} // namespace lmms::gui diff --git a/src/gui/widgets/TextFloat.cpp b/src/gui/widgets/TextFloat.cpp index 5a93b55c6..99eb5531f 100644 --- a/src/gui/widgets/TextFloat.cpp +++ b/src/gui/widgets/TextFloat.cpp @@ -31,6 +31,9 @@ #include "GuiApplication.h" #include "MainWindow.h" +namespace lmms::gui +{ + TextFloat::TextFloat() : QWidget( getGUI()->mainWindow(), Qt::ToolTip ), @@ -78,7 +81,7 @@ void TextFloat::setPixmap( const QPixmap & _pixmap ) void TextFloat::setVisibilityTimeOut( int _msecs ) { - QTimer::singleShot( _msecs, this, SLOT( hide() ) ); + QTimer::singleShot( _msecs, this, SLOT(hide())); show(); } @@ -89,7 +92,7 @@ TextFloat * TextFloat::displayMessage( const QString & _msg, int _timeout, QWidget * _parent, int _add_y_margin ) { QWidget * mw = getGUI()->mainWindow(); - TextFloat * tf = new TextFloat; + auto tf = new TextFloat; if( _parent != nullptr ) { tf->moveGlobal( _parent, QPoint( _parent->width() + 2, 0 ) ); @@ -103,7 +106,7 @@ TextFloat * TextFloat::displayMessage( const QString & _msg, int _timeout, if( _timeout > 0 ) { tf->setAttribute( Qt::WA_DeleteOnClose, true ); - QTimer::singleShot( _timeout, tf, SLOT( close() ) ); + QTimer::singleShot( _timeout, tf, SLOT(close())); } return( tf ); } @@ -199,4 +202,4 @@ void TextFloat::updateSize() - +} // namespace lmms::gui diff --git a/src/gui/widgets/TimeDisplayWidget.cpp b/src/gui/widgets/TimeDisplayWidget.cpp index bde9e7dfe..cefa0fa8f 100644 --- a/src/gui/widgets/TimeDisplayWidget.cpp +++ b/src/gui/widgets/TimeDisplayWidget.cpp @@ -31,6 +31,8 @@ #include "Song.h" +namespace lmms::gui +{ TimeDisplayWidget::TimeDisplayWidget() : QWidget(), @@ -53,8 +55,8 @@ TimeDisplayWidget::TimeDisplayWidget() : // update labels of LCD spinboxes setDisplayMode( m_displayMode ); - connect( getGUI()->mainWindow(), SIGNAL( periodicUpdate() ), - this, SLOT( updateTime() ) ); + connect( getGUI()->mainWindow(), SIGNAL(periodicUpdate()), + this, SLOT(updateTime())); } void TimeDisplayWidget::setDisplayMode( DisplayMode displayMode ) @@ -127,3 +129,5 @@ void TimeDisplayWidget::mousePressEvent( QMouseEvent* mouseEvent ) } } } + +} // namespace lmms::gui \ No newline at end of file diff --git a/src/gui/widgets/ToolButton.cpp b/src/gui/widgets/ToolButton.cpp index 6dea411d8..366fd21f2 100644 --- a/src/gui/widgets/ToolButton.cpp +++ b/src/gui/widgets/ToolButton.cpp @@ -25,6 +25,9 @@ #include "ToolButton.h" +namespace lmms::gui +{ + ToolButton::ToolButton( const QPixmap & _pixmap, const QString & _tooltip, QObject * _receiver, const char * _slot, @@ -35,8 +38,11 @@ ToolButton::ToolButton( const QPixmap & _pixmap, const QString & _tooltip, if( _receiver != nullptr && _slot != nullptr ) { - connect( this, SIGNAL( clicked() ), _receiver, _slot ); + connect( this, SIGNAL(clicked()), _receiver, _slot ); } setToolTip(_tooltip); setIcon( _pixmap ); } + + +} // namespace lmms::gui \ No newline at end of file diff --git a/src/lmmsconfig.h.in b/src/lmmsconfig.h.in index 30fbfdf3f..d130d6fc2 100644 --- a/src/lmmsconfig.h.in +++ b/src/lmmsconfig.h.in @@ -53,25 +53,3 @@ #cmakedefine LMMS_HAVE_STRING_H #cmakedefine LMMS_HAVE_PROCESS_H #cmakedefine LMMS_HAVE_LOCALE_H - -/* defines for libsamplerate */ - - -/* Target processor clips on negative float to int conversion. */ -#cmakedefine CPU_CLIPS_NEGATIVE 1 -#ifndef CPU_CLIPS_NEGATIVE -#define CPU_CLIPS_NEGATIVE 0 -#endif - -/* Target processor clips on positive float to int conversion. */ -#cmakedefine CPU_CLIPS_POSITIVE 1 -#ifndef CPU_CLIPS_POSITIVE -#define CPU_CLIPS_POSITIVE 0 -#endif - -/* Define if you have C99's lrint function. */ -#cmakedefine HAVE_LRINT 1 - -/* Define if you have C99's lrintf function. */ -#cmakedefine HAVE_LRINTF 1 - diff --git a/src/tracks/AutomationTrack.cpp b/src/tracks/AutomationTrack.cpp index 65d34b884..deb6f763c 100644 --- a/src/tracks/AutomationTrack.cpp +++ b/src/tracks/AutomationTrack.cpp @@ -29,6 +29,9 @@ #include "AutomationTrackView.h" #include "AutomationClip.h" +namespace lmms +{ + AutomationTrack::AutomationTrack( TrackContainer* tc, bool _hidden ) : Track( _hidden ? HiddenAutomationTrack : Track::AutomationTrack, tc ) @@ -45,9 +48,9 @@ bool AutomationTrack::play( const TimePos & time_start, const fpp_t _frames, -TrackView * AutomationTrack::createView( TrackContainerView* tcv ) +gui::TrackView* AutomationTrack::createView( gui::TrackContainerView* tcv ) { - return new AutomationTrackView( this, tcv ); + return new gui::AutomationTrackView( this, tcv ); } @@ -55,7 +58,7 @@ TrackView * AutomationTrack::createView( TrackContainerView* tcv ) Clip* AutomationTrack::createClip(const TimePos & pos) { - AutomationClip* p = new AutomationClip(this); + auto p = new AutomationClip(this); p->movePosition(pos); return p; } @@ -79,3 +82,6 @@ void AutomationTrack::loadTrackSpecificSettings( const QDomElement & _this ) setMuted( false ); } } + + +} // namespace lmms diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index 96472132e..6e370b05a 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -40,6 +40,9 @@ #include "Pitch.h" #include "Song.h" +namespace lmms +{ + InstrumentTrack::InstrumentTrack( TrackContainer* tc ) : Track( Track::InstrumentTrack, tc ), @@ -309,9 +312,9 @@ void InstrumentTrack::processCCEvent(int controller) // Does nothing if the LED is disabled if (!m_midiCCEnable->value()) { return; } - uint8_t channel = static_cast(midiPort()->realOutputChannel()); - uint16_t cc = static_cast(controller); - uint16_t value = static_cast(m_midiCCModel[controller]->value()); + auto channel = static_cast(midiPort()->realOutputChannel()); + auto cc = static_cast(controller); + auto value = static_cast(m_midiCCModel[controller]->value()); // Process the MIDI CC event as an input event but with source set to Internal // so we can know LMMS generated the event, not a controller, and can process it during @@ -626,10 +629,9 @@ void InstrumentTrack::setName( const QString & _new_name ) void InstrumentTrack::updateBaseNote() { Engine::audioEngine()->requestChangeInModel(); - for( NotePlayHandleList::Iterator it = m_processHandles.begin(); - it != m_processHandles.end(); ++it ) + for (const auto& processHandle : m_processHandles) { - ( *it )->setFrequencyUpdate(); + processHandle->setFrequencyUpdate(); } Engine::audioEngine()->doneChangeInModel(); } @@ -699,7 +701,7 @@ bool InstrumentTrack::play( const TimePos & _start, const fpp_t _frames, const float frames_per_tick = Engine::framesPerTick(); clipVector clips; - ::PatternTrack * pattern_track = nullptr; + class PatternTrack * pattern_track = nullptr; if( _clip_num >= 0 ) { Clip * clip = getClip( _clip_num ); @@ -716,10 +718,9 @@ bool InstrumentTrack::play( const TimePos & _start, const fpp_t _frames, } // Handle automation: detuning - for( NotePlayHandleList::Iterator it = m_processHandles.begin(); - it != m_processHandles.end(); ++it ) + for (const auto& processHandle : m_processHandles) { - ( *it )->processTimePos( _start ); + processHandle->processTimePos(_start); } if ( clips.size() == 0 ) @@ -734,14 +735,12 @@ bool InstrumentTrack::play( const TimePos & _start, const fpp_t _frames, bool played_a_note = false; // will be return variable - for( clipVector::Iterator it = clips.begin(); it != clips.end(); ++it ) + for (const auto& clip : clips) { - MidiClip* c = dynamic_cast( *it ); + auto c = dynamic_cast(clip); // everything which is not a MIDI clip won't be played // A MIDI clip playing in the Piano Roll window will always play - if(c == nullptr || - (Engine::getSong()->playMode() != Song::Mode_PlayMidiClip - && (*it)->isMuted())) + if (c == nullptr || (Engine::getSong()->playMode() != Song::Mode_PlayMidiClip && clip->isMuted())) { continue; } @@ -843,7 +842,7 @@ void InstrumentTrack::updateGroove() Clip* InstrumentTrack::createClip(const TimePos & pos) { - MidiClip* p = new MidiClip(this); + auto p = new MidiClip(this); p->movePosition(pos); return p; } @@ -851,9 +850,9 @@ Clip* InstrumentTrack::createClip(const TimePos & pos) -TrackView * InstrumentTrack::createView( TrackContainerView* tcv ) +gui::TrackView* InstrumentTrack::createView( gui::TrackContainerView* tcv ) { - return new InstrumentTrackView( this, tcv ); + return new gui::InstrumentTrackView( this, tcv ); } @@ -976,7 +975,7 @@ void InstrumentTrack::loadTrackSpecificSettings( const QDomElement & thisElement } else if(node.nodeName() == "instrument") { - typedef Plugin::Descriptor::SubPluginFeatures::Key PluginKey; + using PluginKey = Plugin::Descriptor::SubPluginFeatures::Key; PluginKey key(node.toElement().elementsByTagName("key").item(0).toElement()); if (reuseInstrument) @@ -1132,3 +1131,5 @@ void InstrumentTrack::autoAssignMidiDevice(bool assign) } } + +} // namespace lmms diff --git a/src/tracks/MidiClip.cpp b/src/tracks/MidiClip.cpp index 7a5fb657d..e5bff8b6f 100644 --- a/src/tracks/MidiClip.cpp +++ b/src/tracks/MidiClip.cpp @@ -35,10 +35,13 @@ -QPixmap * MidiClipView::s_stepBtnOn0 = nullptr; -QPixmap * MidiClipView::s_stepBtnOn200 = nullptr; -QPixmap * MidiClipView::s_stepBtnOff = nullptr; -QPixmap * MidiClipView::s_stepBtnOffLight = nullptr; +namespace lmms +{ + +QPixmap * gui::MidiClipView::s_stepBtnOn0 = nullptr; +QPixmap * gui::MidiClipView::s_stepBtnOn200 = nullptr; +QPixmap * gui::MidiClipView::s_stepBtnOff = nullptr; +QPixmap * gui::MidiClipView::s_stepBtnOffLight = nullptr; @@ -65,9 +68,9 @@ MidiClip::MidiClip( const MidiClip& other ) : m_clipType( other.m_clipType ), m_steps( other.m_steps ) { - for( NoteVector::ConstIterator it = other.m_notes.begin(); it != other.m_notes.end(); ++it ) + for (const auto& note : other.m_notes) { - m_notes.push_back( new Note( **it ) ); + m_notes.push_back(new Note(*note)); } init(); @@ -90,10 +93,9 @@ MidiClip::~MidiClip() { emit destroyedMidiClip( this ); - for( NoteVector::Iterator it = m_notes.begin(); - it != m_notes.end(); ++it ) + for (const auto& note : m_notes) { - delete *it; + delete note; } m_notes.clear(); @@ -107,16 +109,16 @@ void MidiClip::resizeToFirstTrack() // Resize this track to be the same as existing tracks in the pattern const TrackContainer::TrackList & tracks = m_instrumentTrack->trackContainer()->tracks(); - for(unsigned int trackID = 0; trackID < tracks.size(); ++trackID) + for (const auto& track : tracks) { - if(tracks.at(trackID)->type() == Track::InstrumentTrack) + if (track->type() == Track::InstrumentTrack) { - if(tracks.at(trackID) != m_instrumentTrack) + if (track != m_instrumentTrack) { unsigned int currentClip = m_instrumentTrack-> getClips().indexOf(this); m_steps = static_cast - (tracks.at(trackID)->getClip(currentClip)) + (track->getClip(currentClip)) ->m_steps; } break; @@ -129,8 +131,8 @@ void MidiClip::resizeToFirstTrack() void MidiClip::init() { - connect( Engine::getSong(), SIGNAL( timeSignatureChanged( int, int ) ), - this, SLOT( changeTimeSignature() ) ); + connect( Engine::getSong(), SIGNAL(timeSignatureChanged(int,int)), + this, SLOT(changeTimeSignature())); saveJournallingState( false ); updateLength(); @@ -151,13 +153,11 @@ void MidiClip::updateLength() tick_t max_length = TimePos::ticksPerBar(); - for( NoteVector::ConstIterator it = m_notes.begin(); - it != m_notes.end(); ++it ) + for (const auto& note : m_notes) { - if( ( *it )->length() > 0 ) + if (note->length() > 0) { - max_length = qMax( max_length, - ( *it )->endPos() ); + max_length = qMax(max_length, note->endPos()); } } changeLength( TimePos( max_length ).nextFullBar() * @@ -172,13 +172,11 @@ TimePos MidiClip::beatClipLength() const { tick_t max_length = TimePos::ticksPerBar(); - for( NoteVector::ConstIterator it = m_notes.begin(); - it != m_notes.end(); ++it ) + for (const auto& note : m_notes) { - if( ( *it )->length() < 0 ) + if (note->length() < 0) { - max_length = qMax( max_length, - ( *it )->pos() + 1 ); + max_length = qMax(max_length, note->pos() + 1); } } @@ -196,10 +194,10 @@ TimePos MidiClip::beatClipLength() const Note * MidiClip::addNote( const Note & _new_note, const bool _quant_pos ) { - Note * new_note = new Note( _new_note ); - if( _quant_pos && getGUI()->pianoRoll() ) + auto new_note = new Note(_new_note); + if (_quant_pos && gui::getGUI()->pianoRoll()) { - new_note->quantizePos( getGUI()->pianoRoll()->quantization() ); + new_note->quantizePos(gui::getGUI()->pianoRoll()->quantization()); } instrumentTrack()->lock(); @@ -244,13 +242,11 @@ void MidiClip::removeNote( Note * _note_to_del ) Note * MidiClip::noteAtStep( int _step ) { - for( NoteVector::Iterator it = m_notes.begin(); it != m_notes.end(); - ++it ) + for (const auto& note : m_notes) { - if( ( *it )->pos() == TimePos::stepPosition( _step ) - && ( *it )->length() < 0 ) + if (note->pos() == TimePos::stepPosition(_step) && note->length() < 0) { - return *it; + return note; } } return nullptr; @@ -269,10 +265,9 @@ void MidiClip::rearrangeAllNotes() void MidiClip::clearNotes() { instrumentTrack()->lock(); - for( NoteVector::Iterator it = m_notes.begin(); it != m_notes.end(); - ++it ) + for (const auto& note : m_notes) { - delete *it; + delete note; } m_notes.clear(); instrumentTrack()->unlock(); @@ -319,10 +314,8 @@ void MidiClip::splitNotes(NoteVector notes, TimePos pos) addJournalCheckPoint(); - for (int i = 0; i < notes.size(); ++i) + for (const auto& note : notes) { - Note* note = notes.at(i); - int leftLength = pos.getTicks() - note->pos(); int rightLength = note->length() - leftLength; @@ -402,10 +395,9 @@ void MidiClip::saveSettings( QDomDocument & _doc, QDomElement & _this ) _this.setAttribute( "steps", m_steps ); // now save settings of all notes - for( NoteVector::Iterator it = m_notes.begin(); - it != m_notes.end(); ++it ) + for (const auto& note : m_notes) { - ( *it )->saveState( _doc, _this ); + note->saveState( _doc, _this ); } } @@ -445,7 +437,7 @@ void MidiClip::loadSettings( const QDomElement & _this ) if( node.isElement() && !node.toElement().attribute( "metadata" ).toInt() ) { - Note * n = new Note; + auto n = new Note; n->restoreState( node.toElement() ); m_notes.push_back( n ); } @@ -551,9 +543,9 @@ void MidiClip::removeSteps() -ClipView * MidiClip::createView( TrackView * _tv ) +gui::ClipView * MidiClip::createView( gui::TrackView * _tv ) { - return new MidiClipView( this, _tv ); + return new gui::MidiClipView( this, _tv ); } @@ -566,11 +558,11 @@ void MidiClip::updatePatternTrack() Engine::patternStore()->updatePatternTrack(this); } - if( getGUI() != nullptr - && getGUI()->pianoRoll() - && getGUI()->pianoRoll()->currentMidiClip() == this ) + if (gui::getGUI() != nullptr + && gui::getGUI()->pianoRoll() + && gui::getGUI()->pianoRoll()->currentMidiClip() == this) { - getGUI()->pianoRoll()->update(); + gui::getGUI()->pianoRoll()->update(); } } @@ -579,10 +571,9 @@ void MidiClip::updatePatternTrack() bool MidiClip::empty() { - for( NoteVector::ConstIterator it = m_notes.begin(); - it != m_notes.end(); ++it ) + for (const auto& note : m_notes) { - if( ( *it )->length() != 0 ) + if (note->length() != 0) { return false; } @@ -596,13 +587,11 @@ bool MidiClip::empty() void MidiClip::changeTimeSignature() { TimePos last_pos = TimePos::ticksPerBar() - 1; - for( NoteVector::ConstIterator cit = m_notes.begin(); - cit != m_notes.end(); ++cit ) + for (const auto& note : m_notes) { - if( ( *cit )->length() < 0 && ( *cit )->pos() > last_pos ) + if (note->length() < 0 && note->pos() > last_pos) { - last_pos = ( *cit )->pos()+TimePos::ticksPerBar() / - TimePos::stepsPerBar(); + last_pos = note->pos() + TimePos::ticksPerBar() / TimePos::stepsPerBar(); } } last_pos = last_pos.nextFullBar() * TimePos::ticksPerBar(); @@ -610,3 +599,6 @@ void MidiClip::changeTimeSignature() last_pos.getBar() * TimePos::stepsPerBar() ); updateLength(); } + + +} // namespace lmms diff --git a/src/tracks/PatternTrack.cpp b/src/tracks/PatternTrack.cpp index 243c9d3af..9fcc2c831 100644 --- a/src/tracks/PatternTrack.cpp +++ b/src/tracks/PatternTrack.cpp @@ -33,6 +33,9 @@ #include "PlayHandle.h" +namespace lmms +{ + PatternTrack::infoMap PatternTrack::s_infoMap; @@ -48,7 +51,7 @@ PatternTrack::PatternTrack(TrackContainer* tc) : Engine::patternStore()->setCurrentPattern(patternNum); Engine::patternStore()->updateComboBox(); - connect( this, SIGNAL( nameChanged() ), + connect( this, SIGNAL(nameChanged()), Engine::patternStore(), SLOT(updateComboBox())); } @@ -106,13 +109,12 @@ bool PatternTrack::play( const TimePos & _start, const fpp_t _frames, TimePos lastPosition; TimePos lastLen; - for( clipVector::iterator it = clips.begin(); it != clips.end(); ++it ) + for (const auto& clip : clips) { - if( !( *it )->isMuted() && - ( *it )->startPosition() >= lastPosition ) + if (!clip->isMuted() && clip->startPosition() >= lastPosition) { - lastPosition = ( *it )->startPosition(); - lastLen = ( *it )->length(); + lastPosition = clip->startPosition(); + lastLen = clip->length(); } } @@ -126,9 +128,9 @@ bool PatternTrack::play( const TimePos & _start, const fpp_t _frames, -TrackView* PatternTrack::createView(TrackContainerView* tcv) +gui::TrackView* PatternTrack::createView(gui::TrackContainerView* tcv) { - return new PatternTrackView(this, tcv); + return new gui::PatternTrackView(this, tcv); } @@ -136,7 +138,7 @@ TrackView* PatternTrack::createView(TrackContainerView* tcv) Clip* PatternTrack::createClip(const TimePos & pos) { - PatternClip* pc = new PatternClip(this); + auto pc = new PatternClip(this); pc->movePosition(pos); return pc; } @@ -178,15 +180,11 @@ void PatternTrack::loadTrackSpecificSettings(const QDomElement& _this) { const int src = _this.attribute("sourcepattern").toInt(); const int dst = s_infoMap[this]; - TrackContainer::TrackList tl = - Engine::patternStore()->tracks(); // copy clips of all tracks from source pattern (at bar "src") to destination // clips (which are created if they do not exist yet) - for( TrackContainer::TrackList::iterator it = tl.begin(); - it != tl.end(); ++it ) + for (const auto& track : Engine::patternStore()->tracks()) { - Clip::copyStateTo( ( *it )->getClip( src ), - ( *it )->getClip( dst ) ); + Clip::copyStateTo(track->getClip(src), track->getClip(dst)); } setName( tr( "Clone of %1" ).arg( _this.parentNode().toElement().attribute( "name" ) ) ); @@ -231,8 +229,8 @@ PatternTrack* PatternTrack::findPatternTrack(int pattern_num) void PatternTrack::swapPatternTracks(Track* track1, Track* track2) { - PatternTrack* t1 = dynamic_cast(track1); - PatternTrack* t2 = dynamic_cast(track2); + auto t1 = dynamic_cast(track1); + auto t2 = dynamic_cast(track2); if( t1 != nullptr && t2 != nullptr ) { qSwap( s_infoMap[t1], s_infoMap[t2] ); @@ -240,3 +238,6 @@ void PatternTrack::swapPatternTracks(Track* track1, Track* track2) Engine::patternStore()->setCurrentPattern(s_infoMap[t1]); } } + + +} // namespace lmms \ No newline at end of file diff --git a/src/tracks/SampleTrack.cpp b/src/tracks/SampleTrack.cpp index b1fd4c406..af5cbef6d 100644 --- a/src/tracks/SampleTrack.cpp +++ b/src/tracks/SampleTrack.cpp @@ -40,6 +40,9 @@ #include "volume.h" +namespace lmms +{ + SampleTrack::SampleTrack(TrackContainer* tc) : Track(Track::SampleTrack, tc), @@ -73,8 +76,9 @@ bool SampleTrack::play( const TimePos & _start, const fpp_t _frames, m_audioPort.effects()->startRunning(); bool played_a_note = false; // will be return variable + clipVector clips; - ::PatternTrack * pattern_track = nullptr; + class PatternTrack * pattern_track = nullptr; if( _clip_num >= 0 ) { if (_start > getClip(_clip_num)->length()) @@ -98,7 +102,7 @@ bool SampleTrack::play( const TimePos & _start, const fpp_t _frames, for( int i = 0; i < numOfClips(); ++i ) { Clip * clip = getClip( i ); - SampleClip * sClip = dynamic_cast( clip ); + auto sClip = dynamic_cast(clip); if( _start >= sClip->startPosition() && _start < sClip->endPosition() ) { @@ -131,9 +135,9 @@ bool SampleTrack::play( const TimePos & _start, const fpp_t _frames, setPlaying(nowPlaying); } - for( clipVector::Iterator it = clips.begin(); it != clips.end(); ++it ) + for (const auto& clip : clips) { - SampleClip * st = dynamic_cast( *it ); + auto st = dynamic_cast(clip); if( !st->isMuted() ) { PlayHandle* handle; @@ -143,12 +147,12 @@ bool SampleTrack::play( const TimePos & _start, const fpp_t _frames, { return played_a_note; } - SampleRecordHandle* smpHandle = new SampleRecordHandle( st ); + auto smpHandle = new SampleRecordHandle(st); handle = smpHandle; } else { - SamplePlayHandle* smpHandle = new SamplePlayHandle( st ); + auto smpHandle = new SamplePlayHandle(st); smpHandle->setVolumeModel( &m_volumeModel ); smpHandle->setPatternTrack(pattern_track); handle = smpHandle; @@ -166,9 +170,9 @@ bool SampleTrack::play( const TimePos & _start, const fpp_t _frames, -TrackView * SampleTrack::createView( TrackContainerView* tcv ) +gui::TrackView * SampleTrack::createView( gui::TrackContainerView* tcv ) { - return new SampleTrackView( this, tcv ); + return new gui::SampleTrackView( this, tcv ); } @@ -176,7 +180,7 @@ TrackView * SampleTrack::createView( TrackContainerView* tcv ) Clip * SampleTrack::createClip(const TimePos & pos) { - SampleClip * sClip = new SampleClip(this); + auto sClip = new SampleClip(this); sClip->movePosition(pos); return sClip; } @@ -237,7 +241,7 @@ void SampleTrack::setPlayingClips( bool isPlaying ) for( int i = 0; i < numOfClips(); ++i ) { Clip * clip = getClip( i ); - SampleClip * sClip = dynamic_cast( clip ); + auto sClip = dynamic_cast(clip); sClip->setIsPlaying( isPlaying ); } } @@ -249,3 +253,6 @@ void SampleTrack::updateMixerChannel() { m_audioPort.setNextMixerChannel( m_mixerChannelModel.value() ); } + + +} // namespace lmms diff --git a/tests/QTestSuite.h b/tests/QTestSuite.h index e0bd164ed..6cd27f5aa 100644 --- a/tests/QTestSuite.h +++ b/tests/QTestSuite.h @@ -10,7 +10,7 @@ class QTestSuite : public QObject Q_OBJECT public: explicit QTestSuite(QObject *parent = 0); - ~QTestSuite(); + ~QTestSuite() override; static QList suites(); diff --git a/tests/check-strings/README.md b/tests/check-strings/README.md deleted file mode 100644 index 94828b770..000000000 --- a/tests/check-strings/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Check strings - -This tool checks for invalid strings not necessarily in the code. - -Background: When you move a lot of classes and files, the code may be OK, but -many strings outside the code (translations, style.css, .gitmodules etc.) may -still need to be updated. This script checks whether these strings are still -matching the code. - -Content: - -* `check-strings`: Script to check for invalid strings -* `verify`: Script verifying `check-strings` -* expectation.txt: Expectation file for verify script - diff --git a/tests/check-strings/expectation.txt b/tests/check-strings/expectation.txt deleted file mode 100644 index 53b9ae65e..000000000 --- a/tests/check-strings/expectation.txt +++ /dev/null @@ -1,81 +0,0 @@ - -# .gitmodules - -Error: .gitmodules: Directory does not exist: plugins/sid/resid - -# locale - -Error: data/locale: Source file does not exist: ../../src/gui/BBClipView.cpp -Error: data/locale: Source file does not exist: ../../src/gui/editors/BBEditor.cpp -Error: data/locale: Source file does not exist: ../../src/tracks/BBTrack.cpp -Error: data/locale: Source file does not exist: plugins/SpectrumAnalyzer/SpectrumAnalyzer.cpp -Error: data/locale: Source file does not exist: plugins/SpectrumAnalyzer/SpectrumAnalyzerControlDialog.cpp -Error: data/locale: Source file does not exist: plugins/SpectrumAnalyzer/SpectrumAnalyzerControls.cpp -Error: data/locale: Source file does not exist: plugins/flp_import/FlpImport.cpp -Error: data/locale: Source file does not exist: plugins/opl2/opl2instrument.cpp -Error: data/locale: Source file does not exist: plugins/papu/papu_instrument.cpp -Error: data/locale: Source file does not exist: plugins/sid/sid_instrument.cpp -Error: data/locale: Source file does not exist: src/gui/editors/BBEditor.cpp -Error: data/locale: Source file does not exist: src/gui/widgets/VisualizationWidget.cpp -Error: data/locale: Source file does not exist: src/tracks/BBTrack.cpp -Error: data/locale: Class does not exist in source code: BBClipView -Error: data/locale: Class does not exist in source code: BBEditor -Error: data/locale: Class does not exist in source code: BBTrack -Error: data/locale: Class does not exist in source code: SpectrumAnalyzerControlDialog -Error: data/locale: Class does not exist in source code: SpectrumAnalyzerControls -Error: data/locale: Class does not exist in source code: VisualizationWidget -Error: data/locale: Class does not exist in source code: mixerLineLcdSpinBox -Error: data/locale: Class does not exist in source code: opl2instrument -Error: data/locale: Class does not exist in source code: opl2instrumentView -Error: data/locale: Class does not exist in source code: papuInstrument -Error: data/locale: Class does not exist in source code: papuInstrumentView -Error: data/locale: Class does not exist in source code: pluginBrowser -Error: data/locale: Class does not exist in source code: sidInstrument -Error: data/locale: Class does not exist in source code: sidInstrumentView - -# themes - -Error: data/themes/classic/style.css: Class does not exist in source code: PluginDescList -Error: data/themes/classic/style.css: Class does not exist in source code: effectLabel -Error: data/themes/classic/style.css: Class does not exist in source code: nameLabel -Error: data/themes/classic/style.css: Class does not exist in source code: opl2instrumentView -Error: data/themes/classic/style.css: Class does not exist in source code: sidInstrumentView -Error: data/themes/default/style.css: Class does not exist in source code: PluginDescList -Error: data/themes/default/style.css: Class does not exist in source code: effectLabel -Error: data/themes/default/style.css: Class does not exist in source code: nameLabel -Error: data/themes/default/style.css: Class does not exist in source code: opl2instrumentView -Error: data/themes/default/style.css: Class does not exist in source code: sidInstrumentView - -# patches (checks only plugins/) - -Error: debian/patches/clang.patch: Source file does not exist: plugins/LadspaEffect/calf/src/calf/metadata.h -Error: debian/patches/clang.patch: Source file does not exist: plugins/LadspaEffect/calf/src/calf/modules_comp.h -Error: debian/patches/clang.patch: Source file does not exist: plugins/LadspaEffect/calf/src/calf/modules_limit.h -Error: debian/patches/clang.patch: Source file does not exist: plugins/LadspaEffect/calf/src/calf/modules_mod.h -Error: debian/patches/clang.patch: Source file does not exist: plugins/LadspaEffect/calf/src/calf/organ.h -Error: debian/patches/clang.patch: Source file does not exist: plugins/LadspaEffect/calf/src/calf/preset.h -Error: debian/patches/clang.patch: Source file does not exist: plugins/LadspaEffect/calf/src/calf/primitives.h -Error: debian/patches/clang.patch: Source file does not exist: plugins/LadspaEffect/calf/src/metadata.cpp -Error: debian/patches/clang.patch: Source file does not exist: plugins/LadspaEffect/swh/flanger_1191.c -Error: debian/patches/clang.patch: Source file does not exist: plugins/LadspaEffect/swh/gsm/short_term.c -Error: debian/patches/clang.patch: Source file does not exist: plugins/LadspaEffect/swh/multivoice_chorus_1201.c -Error: debian/patches/clang.patch: Source file does not exist: plugins/LadspaEffect/swh/retro_flange_1208.c -Error: debian/patches/clang.patch: Source file does not exist: plugins/LadspaEffect/swh/vynil_1905.c -Error: debian/patches/clang.patch: Source file does not exist: plugins/delay/stereodelay.cpp -Error: debian/patches/clang.patch: Source file does not exist: plugins/opl2/fmopl.c - -# debian docs (only one string) - - -# debian/copyright - -Error: debian/copyright: Glob/Path does not exist: data/projects/CoolSongs/Saber-* -Error: debian/copyright: Glob/Path does not exist: plugins/LadspaEffect/calf/src/calf/vumeter.h -Error: debian/copyright: Glob/Path does not exist: plugins/LadspaEffect/swh/gsm/* -Error: debian/copyright: Glob/Path does not exist: plugins/LadspaEffect/swh/util/pitchscale.c -Error: debian/copyright: Glob/Path does not exist: plugins/LadspaEffect/swh/vocoder_1337.c -Error: debian/copyright: Glob/Path does not exist: plugins/opl2/fmopl.* - -# summary - -59 errors. diff --git a/tests/check-strings/verify b/tests/check-strings/verify deleted file mode 100755 index bffcc1a59..000000000 --- a/tests/check-strings/verify +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/python3 - -import subprocess -from pathlib import Path -import tempfile -import os - -lmms_main_path = Path(__file__).resolve().parent.parent.parent - -res = subprocess.run(['git', 'rev-parse', 'HEAD'], capture_output=True, text=True, check=True) -head = res.stdout.rstrip() - -# test with a stable LMMS ref to always get the same expectations -ref = 'f56fc68b669b59f525ad133a0376feaba2a1a4ec' - -# find out a remote URL where we can fetch "ref" from -res = subprocess.run(['git', 'rev-parse', '-q', '--verify', ref+'^{commit}'], capture_output=True, text=True) -if res.returncode == 0: - remote = str(lmms_main_path) -else: - res = subprocess.run(['git', 'remote', 'get-url', 'origin'], capture_output=True, text=True) - if res.returncode == 0: - remote = res.stdout.rstrip() - else: - res = subprocess.run(['git', 'remote', 'get-url', 'upstream'], capture_output=True, text=True) - if res.returncode == 0: - remote = res.stdout.rstrip() - else: - raise RuntimeError( - "Sorry, I can find ref " + ref + " neither in the repo nor in the remotes \"origin\" and \"upstream\"") - -with tempfile.TemporaryDirectory() as tmpdir: - os.chdir(tmpdir) - # get the repo and its submodules - subprocess.run(['git', 'init'], check=True) - subprocess.run(['git', 'remote', 'add', 'origin', remote], check=True) - subprocess.run(['git', 'fetch', '--depth=1', 'origin', ref, head], check=True) - subprocess.run(['git', 'checkout', ref], check=True) - subprocess.run(['git', 'submodule', 'update', '--depth=1', '--init'], check=True) - # checkout the CURRENT check-strings, because it is subject-under-test - subprocess.run(['git', 'checkout', head, 'tests/check-strings/check-strings'], check=True) - # run script - res = subprocess.run([str(lmms_main_path / 'tests' / 'check-strings' / 'check-strings')], - capture_output=True, text=True) - print('--->8--- Script output BEGIN --->8---') - print(res.stdout) - print('--->8--- Script output END --->8---') - if res.stderr: - print('--->8--- Script error output BEGIN --->8---') - print(res.stderr) - print('--->8--- Script error output END --->8---') - # make sure script returned "error" (because we test for errors) and that the output is as expected - if res.returncode == 0: - raise RuntimeError("Script \"check-strings\" no errors, but errors were expected") - else: - if res.stdout != open(str(lmms_main_path / 'tests' / 'check-strings' / 'expectation.txt')).read(): - raise RuntimeError("Script \"check-strings\" returned with different output than in expectation.txt") - -# if we made it until here without an exception, all tests have been passed -print("SUCCESS") diff --git a/tests/main.cpp b/tests/main.cpp index b2c21b79a..6d375e6c6 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -9,7 +9,7 @@ int main(int argc, char* argv[]) { new QCoreApplication(argc, argv); - Engine::init(true); + lmms::Engine::init(true); int numsuites = QTestSuite::suites().size(); qDebug() << ">> Will run" << numsuites << "test suites"; diff --git a/tests/scripted/README.md b/tests/scripted/README.md new file mode 100644 index 000000000..7d0c11162 --- /dev/null +++ b/tests/scripted/README.md @@ -0,0 +1,24 @@ +# Scripted checks + +The checks in this directory are not C++ unit tests, but simple scripts that +check the code for issues. + +## Verify + +[verify](verify) is a verification script for the scripts in this folder. + +## Check strings + +[check-strings](check-strings) checks for invalid strings not necessarily in +the code. + +Background: When you move a lot of classes and files, the code may be OK, but +many strings outside the code (translations, style.css, .gitmodules etc.) may +still need to be updated. This script checks whether these strings are still +matching the code. + +## Check namespace + +[check-namespace](check-namespace) checks namespaces and a few related things +like `#ifdef`s. + diff --git a/tests/scripted/check-namespace b/tests/scripted/check-namespace new file mode 100755 index 000000000..a816f0d7b --- /dev/null +++ b/tests/scripted/check-namespace @@ -0,0 +1,199 @@ +#!/usr/bin/python3 + +# This script checks the code for namespace related issues +# Note: This script is not perfect. It can not parse all LMMS files, +# and does not contain a complete C++ parser. If you encounter +# difficulties with this tests, it could be a fault of your +# changes, but it could also be a fault of this script. + +import re +import subprocess +import sys +from pathlib import Path +from typing import NamedTuple + + +# types + +class BlockType: + pass + + +IF_MACRO = BlockType() +HEADER_GUARD = BlockType() +CODE_BLOCK = BlockType() +EXTERN = BlockType() + + +class Expectation(NamedTuple): + type: BlockType + statement: str # expected end statement + name: str # expected name in comment + + +# global variables + +errors = 0 + + +# functions + +def caption(my_str): + print(f'\n# {my_str}\n') + + +def error(where, match, my_str): + global errors + errors += 1 + if match: + line = match.string[:match.start()].count('\n') + 1 # first line is 1 + where = f'{where}:{line}' + print(f'Error: {where}: {my_str}') + + +if not Path('.gitmodules').is_file(): + print('You need to call this script from the LMMS top directory') + exit(1) + +result = subprocess.run(['git', 'ls-files', '*.[ch]', '*.[ch]pp', ':!tests/*'], + capture_output=True, text=True, check=True) + +known_no_namespace_lmms = { + # main.cpp + 'src/core/main.cpp', + # nothing to set under a namespace + 'include/debug.h', + 'include/versioninfo.h', + 'plugins/CarlaBase/CarlaConfig/config.h', + 'plugins/CarlaBase/DummyCarla.cpp', + # unclear why it has no namespace + 'plugins/ZynAddSubFx/RemoteZynAddSubFx.cpp', +} + +exclude_files = re.compile( + # not ours: + 'include/(aeffectx|fenv|ladspa).h|' + 'plugins/LadspaEffect/(calf|caps|cmt|swh|tap)/|' + 'plugins/MidiExport/MidiFile.hpp|' + 'plugins/ReverbSC/[a-z]|' + 'plugins/Sf2Player/fluidsynthshims.h|' + '/portsmf/|' + # only forward to headers that are not ours: + 'plugins/ZynAddSubFx/ThreadShims.h' +) + +files = [Path(f) for f in result.stdout.splitlines() if not exclude_files.search(f)] + +# Debug argument +if len(sys.argv) > 1: + files = [Path(arg) for arg in sys.argv[1:]] + +statement_pattern = re.compile( + # Capture comments first to prevent them from matching any other regex + # Include next line if line ends with backslash + r'/[*](.|\n)*?[*]/|//(.*\\\n)*.*|' + + # Macro with <30 lines and no other #if inside needs no end comment + # Match here to prevent from matching next regex + # With a (?!negative lookahead) we can allow all # except the ones followed by "if" + r'^ *# *(?Pifn?def)(?=(([^#\n]|#(?!if|endif))*\n){,30} *# *endif)|' + # Macro followed by name or comment + # With (?P...) you can do a backreference to \name later + r'^ *# *(?Pifn?def|endif)(( *// *| +)(?P\w+))?|' + # Other macros where we don't want the argument + r'^ *# *(?Pinclude|if|el(se|if))|' + + # Namespace that contains no other braces needs no end comment + # With a (?=lookahead) we can let the "namespace" part be eaten by the parser + # but save the braces and their content for later so they can be matched again + r'^ *namespace *[\w:]*\s*(?={[^{}]*})|' + # Start of named namespace, extern "C" or just a opening brace + r'(^ *(namespace +(?P[\w:]+)|(?Pextern *"C"))\s*)?(?P{)|' + # End of namespace including comment, or just a closing brace + r'(?P})( *// *namespace +(?P[\w:]+))?' + + # In all the regexes above match both tab and space when a space is used + r''.replace(' ', r'[\t ]'), + # Make ^ match on every line, not just beginning of file + re.MULTILINE) + +# Comments and whitespace followed by header guard +header_guard_pattern = re.compile(r'^(/[*](.|\n)*?[*]/|//.*|\s)*#\s*(ifndef|pragma\s+once)') + +# Namespace lmms +namespace_pattern = re.compile(r'^\s*namespace\s+lmms', re.MULTILINE) + +# +# the real code +# + +caption('namespace checks') + +for cur_file in files: + if cur_file.is_file(): + cur_text = cur_file.read_text(errors='replace') + + if cur_file.as_posix() not in known_no_namespace_lmms: + namespace_pattern.search(cur_text) or error(cur_file, None, f'File has no namespace lmms') + + header_guard = str(cur_file).endswith('.h') + expectations = [] # type: list[Expectation] + + if header_guard: + if not header_guard_pattern.match(cur_text): + error(cur_file, None, 'First statement should be header guard') + header_guard = False + + for m in statement_pattern.finditer(cur_text): + # Find the matched regex group + statement = m.group('opening_brace') or m.group('closing_brace') + if not statement: + statement = '#' + (m.group('macro') or m.group('named_macro') or m.group('short_macro') or '') + if not statement: + continue + + # Start statements + if statement == '{': + etype = EXTERN if m.group('extern') else CODE_BLOCK + expectations.append(Expectation(etype, '}', m.group('namespace'))) + elif statement.startswith('#if'): + etype = HEADER_GUARD if header_guard else IF_MACRO + expectations.append(Expectation(etype, '#endif', m.group('macro_name'))) + header_guard = False + + # End statements + elif statement == '#endif' or statement.startswith('#el') or statement == '}': + if not expectations: + error(cur_file, m, f'Unexpected {statement}') + break + if statement.startswith('#el') and expectations[-1].statement == '#endif': + # After an #else or #elif the comment is no longer mandatory, since it's hard to define + expectations[-1] = Expectation(IF_MACRO, '#endif', '') + # Don't pop the expectations, we are still waiting for the #endif + continue + exp = expectations.pop() + name = m.group('macro_name') or m.group('namespace_end') or '' + if statement != exp.statement: + error(cur_file, m, f'Expected {exp.statement} before {statement}') + break + # Require no end comment for header guard + elif exp.type is HEADER_GUARD and not name: + continue + elif exp.name and name != exp.name: + comment = 'namespace ' if exp.type is CODE_BLOCK else '' + error(cur_file, m, f'Missing comment // {comment}{exp.name}') + + # Extra checks + elif statement == '#include': + if any(True for e in expectations if e.type is CODE_BLOCK): + error(cur_file, m, '#include inside a code block') + + else: + # Leftover expected statements + for exp in reversed(expectations): + error(cur_file, None, f'Expected {exp.statement} before end of file') + +caption('summary') + +print(f'{str(errors)} errors.') +exit(1 if errors > 0 else 0) diff --git a/tests/check-strings/check-strings b/tests/scripted/check-strings similarity index 90% rename from tests/check-strings/check-strings rename to tests/scripted/check-strings index d5b0260db..5504cc588 100755 --- a/tests/check-strings/check-strings +++ b/tests/scripted/check-strings @@ -91,6 +91,21 @@ for c in sorted(classes_found): caption('themes') + +GUI_NAMESPACE_PREFIX = "lmms--gui" + + +def unscope_classname(stylesheet, cname): + # Strip the namespace part from the given class name, + # while expecting it to have one in the first place. + SCOPE_TOKEN = "--" + i = cname.rfind(SCOPE_TOKEN) + len(SCOPE_TOKEN) + + assert i>=0 + + return cname[i:] + + for theme in sorted([d for d in Path('data/themes').iterdir() if d.is_dir()]): classes_in_sheet = set() stylesheet = theme / 'style.css' @@ -101,7 +116,10 @@ for theme in sorted([d for d in Path('data/themes').iterdir() if d.is_dir()]): for c in rule.prelude: if c.type == 'ident' and not class_found: if is_our_class(c.value): - classes_in_sheet.add(c.value) + if str(c.value).startswith(GUI_NAMESPACE_PREFIX): + classes_in_sheet.add(unscope_classname(stylesheet, c.value)) + else: + error(str(stylesheet), f"Namespace prefix missing from class {c.value}") class_found = True # After whitespace or comma comes a new class elif c.type == 'whitespace' or (c.type == 'literal' and c.value == ','): diff --git a/tests/scripted/verify b/tests/scripted/verify new file mode 100755 index 000000000..3f6d60103 --- /dev/null +++ b/tests/scripted/verify @@ -0,0 +1,263 @@ +#!/usr/bin/python3 + +import subprocess +from pathlib import Path +import tempfile +import os + + +def set_git_config(): + """Set local git identity, but only in local repo (to not overwrite user settings)""" + """Also, fix git issue: fatal: transport 'file' not allowed""" + subprocess.run(['git', 'config', 'user.name', 'James Bond']) + subprocess.run(['git', 'config', 'user.email', '007@sis.gov.uk']) + subprocess.run(['git', 'config', '--global', 'protocol.file.allow', 'always']) + + +def create_file(filename: str, file_content: str): + """Create a file in the current directory and adds it to git""" + Path(filename).parent.mkdir(parents=True, exist_ok=True) + with open(filename, "w") as textfile: + print(file_content, file=textfile) + subprocess.run(['git', 'add', filename], check=True) + + +class ScriptTest(): + def __init__(self, scriptpath: Path): + self.scriptpath = Path(scriptpath) + + def __enter__(self): + """Create temporary, minimal test environment, and change to it""" + self.lmms_tmpdir = tempfile.TemporaryDirectory(dir='.') + os.chdir(self.lmms_tmpdir.name) + # prerequirements + Path('data/themes').mkdir(parents=True) + subprocess.run(['git', 'init', '-b', 'main'], check=True) + set_git_config() + subprocess.run(['git', 'submodule', 'add', '../../carla', 'plugins/CarlaBase/carla'], check=True) + create_file('src/core/classes.cpp', 'namespace lmms {\nclass TestClass\n}') + create_file('debian/lmms-common.docs', '') + create_file('debian/copyright', '') + create_file('data/locale/de.ts', + '\n' + ' \n' + ' TestClass\n' + ' \n' + ' \n' + ' About LMMS\n' + ' Über LMMS\n' + ' \n' + '\n' + '\n') + subprocess.run(['git', 'commit', '-m', 'Initial commit'], check=True) + return self + + def __exit__(self, type, value, traceback): + """Leave and destroy temporary test environment""" + os.chdir('..') + self.lmms_tmpdir.cleanup() + + def expect(self, expectation: str): + """Check if "expectation" is in the output""" + if expectation not in self.result.stdout: + raise RuntimeError(f'Expected "{expectation}" in script output') + + def run(self, expected_returncode: int = 1): # default: something goes wrong ("to the safe side") + """Run the script, check the exit code and store the result""" + self.result = subprocess.run([str(self.scriptpath)], capture_output=True, text=True) + print('--->8--- Script output BEGIN --->8---') + print(self.result.stdout) + print('--->8--- Script output END --->8---') + if self.result.stderr: + print('--->8--- Script error output BEGIN --->8---') + print(self.result.stderr) + print('--->8--- Script error output END --->8---') + # make sure script returned "error" (because we test for errors) and that the output is as expected + if self.result.returncode != expected_returncode: + raise RuntimeError(f"Script \"check-strings\" returned {self.result.returncode}, " + f"but {expected_returncode} expected") + + +lmms_main_path = Path(__file__).resolve().parent.parent.parent + +with tempfile.TemporaryDirectory() as tmpdir: + os.chdir(tmpdir) + check_strings = lmms_main_path / 'tests' / 'scripted' / 'check-strings' + check_namespace = lmms_main_path / 'tests' / 'scripted' / 'check-namespace' + + # create dummy carla repo + Path('carla').mkdir() + os.chdir('carla') + subprocess.run(['git', 'init', '-b', 'main'], check=True) + set_git_config() + create_file('README.md', 'hello world') + subprocess.run(['git', 'commit', '-m', 'Initial commit'], check=True) + os.chdir('..') + + Path('lmms').mkdir() + os.chdir('lmms') + + # minimal working example + with ScriptTest(check_strings) as test: + test.run(0) # exitcode 0 - no errors expected + test.expect('0 errors') + + with ScriptTest(check_strings) as test: + create_file('data/locale/fr.ts', + '\n' + ' \n' + ' TestClass\n' + ' \n' + ' \n' + ' About LMMS\n' + ' À propos de LMMS\n' + ' \n' + '\n' + '\n') + test.run() + test.expect('Error: data/locale: Source file does not exist: ../../src/core/non-existent.cpp') + test.expect('1 errors') + + with ScriptTest(check_strings) as test: + create_file('data/locale/fr.ts', + '\n' + ' \n' + ' NonExistentClass\n' + ' \n' + ' \n' + ' About LMMS\n' + ' À propos de LMMS\n' + ' \n' + '\n' + '\n') + test.run() + test.expect('Error: data/locale: Class does not exist in source code: NonExistentClass') + test.expect('1 errors') + + with ScriptTest(check_strings) as test: + create_file('data/themes/classic/style.css', + 'lmms--gui--NonExistentClass {' + '\tcolor: #d1d8e4;\n' + '}') + test.run() + test.expect('Error: data/themes/classic/style.css: Class does not exist in source code: NonExistentClass') + test.expect('1 errors') + + with ScriptTest(check_strings) as test: + create_file('debian/patches/clang.patch', '/plugins/non-existent-file') + test.run() + test.expect('Error: debian/patches/clang.patch: Source file does not exist: plugins/non-existent-file') + test.expect('1 errors') + + with ScriptTest(check_strings) as test: + create_file('debian/lmms-common.docs', '/plugins/caps.html') + test.run() + test.expect('Error: debian/lmms-common.docs: Path does not exist: /plugins/caps.html') + test.expect('1 errors') + + with ScriptTest(check_strings) as test: + create_file('debian/copyright', 'Files: NonExistent') + test.run() + test.expect('Error: debian/copyright: Glob/Path does not exist: NonExistent') + test.expect('1 errors') + + with ScriptTest(check_namespace) as test: + # minimal working example + test.run(0) # exitcode 0 - no errors expected + test.expect('0 errors') + + create_file('01_OddBraceWithinMacro.cpp', ''' + #if HAS_EVEN_BRACES + namespace lmms {} + #endif + namespace lmms { + #if HAS_ODD_BRACE + } + #endif + ''') + create_file('02_IncludeInCodeBlock.cpp', ''' + #include + extern "C" { + #include "alright.c" + } + namespace lmms { + #include + } + ''') + create_file('03_MacroComments.h', ''' + #ifndef HEADER_GUARD_NEEDS_NO_COMMENT + #define HEADER_GUARD_NEEDS_NO_COMMENT + #ifdef HAS_NESTED_NEEDS_COMMENT + #ifdef SHORT_NO_NESTED_NEEDS_NO_COMMENT + namespace lmms {} + #endif + #endif + #ifdef HAS_COMMENT + #ifdef SHORT_NO_NESTED_NEEDS_NO_COMMENT + #else + #endif + #endif // HAS_COMMENT + #endif + ''') + create_file('04_NamespaceComments.cpp', ''' + namespace lmms { + namespace ShortNamespace { + class WithDeclarationsOnly; + } + namespace LongNamespace { + class WithDefinition { + int x; + }; + } + } // namespace lmms + ''') + create_file('05_NoHeaderGuard.h', ''' + #include + namespace lmms {} + ''') + create_file('06_PragmaButNoLmms.h', ''' + // should not cause header guard warning + #pragma once + namespace not_lmms {} + ''') + create_file('07_MismatchingEndifName.h', ''' + #ifndef ABC_H + namespace lmms { + \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n + } + #endif // XYZ_H + ''') + create_file('08_MismatchingNamespaceEndName.h', ''' + #ifndef ABC_H + namespace lmms { + {} + } // namespace smml + #endif // ABC_H + ''') + create_file('09_NoEndifAfterElseIsOk.cpp', ''' + #ifdef XYZ + namespace lmms { + \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n + } + #else + namespace lmms { + \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n + } + #endif + ''') + test.run() + test.expect('8 errors') + test.expect(''' +Error: 01_OddBraceWithinMacro.cpp:7: Expected #endif before } +Error: 02_IncludeInCodeBlock.cpp:7: #include inside a code block +Error: 03_MacroComments.h:8: Missing comment // HAS_NESTED_NEEDS_COMMENT +Error: 04_NamespaceComments.cpp:10: Missing comment // namespace LongNamespace +Error: 05_NoHeaderGuard.h: First statement should be header guard +Error: 06_PragmaButNoLmms.h: File has no namespace lmms +Error: 07_MismatchingEndifName.h:36: Missing comment // ABC_H +Error: 08_MismatchingNamespaceEndName.h:5: Missing comment // namespace lmms +''') + + +# if we made it until here without an exception, all tests have been passed +print("SUCCESS") diff --git a/tests/src/core/AutomatableModelTest.cpp b/tests/src/core/AutomatableModelTest.cpp index d84d89db4..78b9069b5 100644 --- a/tests/src/core/AutomatableModelTest.cpp +++ b/tests/src/core/AutomatableModelTest.cpp @@ -43,6 +43,8 @@ private slots: // tests //! but no downcast or any other casts void CastTests() { + using namespace lmms; + ComboBoxModel comboModel; AutomatableModel* amPtr = &comboModel; QVERIFY(nullptr == amPtr->dynamicCast()); // not a parent class @@ -60,6 +62,8 @@ private slots: // tests void LinkTests() { + using namespace lmms; + BoolModel m1(false), m2(false); QObject::connect(&m1, SIGNAL(dataChanged()), diff --git a/tests/src/core/ProjectVersionTest.cpp b/tests/src/core/ProjectVersionTest.cpp index e52088f6f..2d066dca5 100644 --- a/tests/src/core/ProjectVersionTest.cpp +++ b/tests/src/core/ProjectVersionTest.cpp @@ -32,6 +32,8 @@ class ProjectVersionTest : QTestSuite private slots: void ProjectVersionComparisonTests() { + using namespace lmms; + QVERIFY(ProjectVersion("1.1.0", ProjectVersion::Minor) > "1.0.3"); QVERIFY(ProjectVersion("1.1.0", ProjectVersion::Major) < "2.1.0"); QVERIFY(ProjectVersion("1.1.0", ProjectVersion::Release) > "0.2.1"); diff --git a/tests/src/core/RelativePathsTest.cpp b/tests/src/core/RelativePathsTest.cpp index 3f1712e1b..3b5d023d0 100644 --- a/tests/src/core/RelativePathsTest.cpp +++ b/tests/src/core/RelativePathsTest.cpp @@ -36,6 +36,8 @@ class RelativePathsTest : QTestSuite private slots: void PathUtilComparisonTests() { + using namespace lmms; + QFileInfo fi(ConfigManager::inst()->factorySamplesDir() + "/drums/kick01.ogg"); QVERIFY(fi.exists()); diff --git a/tests/src/tracks/AutomationTrackTest.cpp b/tests/src/tracks/AutomationTrackTest.cpp index 5adafbb0f..2bf875992 100644 --- a/tests/src/tracks/AutomationTrackTest.cpp +++ b/tests/src/tracks/AutomationTrackTest.cpp @@ -49,6 +49,8 @@ private slots: void testClipLinear() { + using namespace lmms; + AutomationClip c(nullptr); c.setProgressionType(AutomationClip::LinearProgression); c.putValue(0, 0.0, false); @@ -64,6 +66,8 @@ private slots: void testClipDiscrete() { + using namespace lmms; + AutomationClip c(nullptr); c.setProgressionType(AutomationClip::DiscreteProgression); c.putValue(0, 0.0, false); @@ -77,6 +81,8 @@ private slots: void testClips() { + using namespace lmms; + FloatModel model; auto song = Engine::getSong(); @@ -111,6 +117,8 @@ private slots: void testLengthRespected() { + using namespace lmms; + FloatModel model; auto song = Engine::getSong(); @@ -136,6 +144,8 @@ private slots: void testInlineAutomation() { + using namespace lmms; + auto song = Engine::getSong(); InstrumentTrack* instrumentTrack = @@ -160,6 +170,8 @@ private slots: void testPatternTrack() { + using namespace lmms; + auto song = Engine::getSong(); auto patternStore = Engine::patternStore(); PatternTrack patternTrack(song); @@ -197,6 +209,8 @@ private slots: void testGlobalAutomation() { + using namespace lmms; + // Global automation should not have priority, see https://github.com/LMMS/lmms/issues/4268 // Tests regression caused by 75077f6200a5aee3a5821aae48a3b8466ed8714a auto song = Engine::getSong();