From e062e7c86cf24906414960d9679c4db97d1dd97e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Mu=C3=B1oz?= Date: Sun, 22 Oct 2023 18:00:10 +0200 Subject: [PATCH 1/4] Fix delay sync level display text now adapted to song resolution (#637) * Fix delay sync level display text now adapted to song resolution * Dbt format --- .../mod_controllable_audio.cpp | 42 +++++-------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/src/deluge/model/mod_controllable/mod_controllable_audio.cpp b/src/deluge/model/mod_controllable/mod_controllable_audio.cpp index 8b15db5217..8f8aba0418 100644 --- a/src/deluge/model/mod_controllable/mod_controllable_audio.cpp +++ b/src/deluge/model/mod_controllable/mod_controllable_audio.cpp @@ -1990,38 +1990,18 @@ void ModControllableAudio::switchDelaySyncLevel() { // Note: SYNC_LEVEL_NONE (value 0) can't be selected delay.syncLevel = (SyncLevel)((delay.syncLevel) % SyncLevel::SYNC_LEVEL_256TH + 1); //cycle from 1 to 9 (omit 0) - char const* displayText; - switch (delay.syncLevel) { - case SYNC_LEVEL_2ND: - displayText = "2nd"; - break; - case SYNC_LEVEL_4TH: - displayText = "4th"; - break; - case SYNC_LEVEL_8TH: - displayText = "8th"; - break; - case SYNC_LEVEL_16TH: - displayText = "16th"; - break; - case SYNC_LEVEL_32ND: - displayText = "32nd"; - break; - case SYNC_LEVEL_64TH: - displayText = "64th"; - break; - case SYNC_LEVEL_128TH: - displayText = "128th"; - break; - case SYNC_LEVEL_256TH: - displayText = "256th"; - break; - - default: //SYNC_LEVEL_WHOLE - displayText = "1-bar"; - break; + char* buffer = shortStringBuffer; + currentSong->getNoteLengthName(buffer, (uint32_t)3 << (SYNC_LEVEL_256TH - delay.syncLevel)); + if (display->haveOLED()) { + // Need to delete "-notes" from the name + std::string noteName(buffer); + std::string cleanName = noteName.substr(0, noteName.find("-notes")); + display->displayPopup(cleanName.c_str()); + } + else { + // 7 Seg just display it + display->displayPopup(buffer); } - display->displayPopup(displayText); } void ModControllableAudio::switchLPFMode() { From 1743f263ff9ef61ce3c0eec974a8b65351485cd7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 23 Oct 2023 09:14:43 -0400 Subject: [PATCH 2/4] Bump gitpython from 3.1.31 to 3.1.37 in /scripts/toolchain (#639) (#641) --- scripts/toolchain/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/toolchain/requirements.txt b/scripts/toolchain/requirements.txt index 126fd228c7..6ebd4cb11b 100644 --- a/scripts/toolchain/requirements.txt +++ b/scripts/toolchain/requirements.txt @@ -3,7 +3,7 @@ setuptools==68.0.0 SCons==4.5.2 smmap==5.0.0 gitdb==4.0.10 -GitPython==3.1.31 +GitPython==3.1.37 pyserial==3.5 ansi==0.3.6 kconfiglib==14.1.0 From b03b7c8c0eff0ac421b1ae4afe8739abce06562d Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 23 Oct 2023 18:34:57 +0200 Subject: [PATCH 3/4] mod matrix: update display to changed values (#642) Also adjust the position if it became invalid after deleting the last patch cable in the list. fixes #428 --- src/deluge/gui/menu_item/patch_cables.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/deluge/gui/menu_item/patch_cables.cpp b/src/deluge/gui/menu_item/patch_cables.cpp index d706935219..acc269baf5 100644 --- a/src/deluge/gui/menu_item/patch_cables.cpp +++ b/src/deluge/gui/menu_item/patch_cables.cpp @@ -18,22 +18,26 @@ void PatchCables::beginSession(MenuItem* navigatedBackwardFrom) { currentValue = 0; if (navigatedBackwardFrom != nullptr) { - PatchCableSet* set = soundEditor.currentParamManager->getPatchCableSet(); currentValue = savedVal; - if (savedVal >= set->numPatchCables) { - currentValue = 0; - } } if (display->haveOLED()) { scrollPos = std::max((int32_t)0, currentValue - 1); } - renderOptions(); readValueAgain(); } void PatchCables::readValueAgain() { + PatchCableSet* set = soundEditor.currentParamManager->getPatchCableSet(); + if (currentValue >= set->numPatchCables) { + // The last patch cable was deleted and it was selected, need to adjust + currentValue = std::max(0, set->numPatchCables - 1); + scrollPos = std::max((int32_t)0, currentValue - 1); + } + + renderOptions(); + if (display->haveOLED()) { renderUIsForOled(); } From c3f1d36a384cbc9fc00648e154e4c042f2c832c6 Mon Sep 17 00:00:00 2001 From: Katherine Whitlock Date: Tue, 24 Oct 2023 11:12:33 -0400 Subject: [PATCH 4/4] General CMake cleanup (#635) * General CMake improvements * Make extra warnings optional (for now) * Remove section sorting * Update functions.h for better inlining * Fix formatting --------- Co-authored-by: Paul Freund --- .clang-tidy | 2 +- .clangd | 2 +- CMakeLists.txt | 140 +++++++++++------------ scripts/cmake/CMakeToolchainDeluge.cmake | 11 +- src/definitions_cxx.hpp | 10 +- src/deluge/CMakeLists.txt | 13 +-- src/deluge/util/functions.h | 71 ++++++------ src/deluge/version.h.in | 20 +++- 8 files changed, 136 insertions(+), 133 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 43822b3fa4..b4b568d756 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -5,9 +5,9 @@ Checks: > clang-diagnostic-*, clang-analyzer-*, cppcoreguidelines-*, - cppcoreguidelines-*, readability-*, modernize-*, + bugprone-*, llvm-include-order, performance-for-range-copy, performance-implicit-conversion-in-loop, diff --git a/.clangd b/.clangd index 69f8584ab0..b0a836dd71 100644 --- a/.clangd +++ b/.clangd @@ -1,3 +1,3 @@ CompileFlags: Add: [-Wno-unknown-argument, -Wno-unknown-warning-option] - Remove: [-mthumb-interwork] + Remove: [-mthumb-interwork, -fanalyzer] diff --git a/CMakeLists.txt b/CMakeLists.txt index 176c42ad54..c6ad0b4c6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,18 +10,6 @@ project(Deluge include(ProcessorCount) ProcessorCount(HOST_NUM_CORES) -# Check for IPO support -include(CheckIPOSupported) -check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT error) - -if(IPO_SUPPORTED) - set(CMAKE_INTERPROCEDURAL_OPTIMIZATION - $<$:OFF> - $<$:ON> - $<$:ON> - ) -endif() - # Create our version string set(RELEASE_TYPE "dev" CACHE STRING "The type of releasepack to build") set_property(CACHE RELEASE_TYPE PROPERTY STRINGS dev nightly alpha beta rc release) @@ -80,66 +68,15 @@ else() set(EXECUTABLE_VERSION_SUFFIX "") endif(ENABLE_VERSIONED_OUTPUT) -# Global compilation options -add_compile_options( - - # Feature flags - -fdiagnostics-parseable-fixits - -fsigned-char - - # Debug symbols - $<$:-g> # Include - $<$:-ggdb> # Include - $<$:-g> # Include - $<$:-s> # Strip - - # Optimization level - $<$:-Og> - $<$:-O2> - $<$:-O2> - -fno-inline-functions - # Link time optimizations - $<$:-flto> - $<$:-flto> - -ffunction-sections - -fdata-sections - - # C++ stuff - $<$:-fno-rtti> - $<$:-fno-exceptions> - $<$:-fno-use-cxa-atexit> - $<$:-fno-threadsafe-statics> - - # ASM stuff - $<$:-x> - $<$:assembler-with-cpp> -) - -add_link_options( - -T ${PROJECT_SOURCE_DIR}/linker_script_rz_a1l.ld - LINKER:--gc-sections - - -nostartfiles # Don't emit startfiles - -estart # Set the entrypoint to 'start' (see RZA1/compiler/asm/start.S) -) - -# RTT Debug options +# RTT option option(ENABLE_RTT "Enable RTT output" ON) + +# SYSEX Load option option(ENABLE_SYSEX_LOAD "Enable loading firmware over midi sysex" OFF) # Colored output -option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." ON) - -if(FORCE_COLORED_OUTPUT) - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - message(STATUS "Forcing colors for GCC") - add_compile_options(-fdiagnostics-color=always) - add_link_options(-fdiagnostics-color=always) - elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - message(STATUS "Forcing colors for Clang") - add_compile_options(-fcolor-diagnostics) - endif() -endif(FORCE_COLORED_OUTPUT) +set(CMAKE_COLOR_DIAGNOSTICS ON) +add_compile_options($<$:-fansi-escape-codes>) # ##### Documentation generation ####### # check if Doxygen is installed @@ -181,6 +118,38 @@ else(DOXYGEN_FOUND) "Please install from https://github.com/doxygen/doxygen/releases") endif(DOXYGEN_FOUND) +# Global compilation options +add_compile_options( + + # Feature flags + -fdiagnostics-parseable-fixits + -fsigned-char + + # Debug symbols + $<$:-ggdb3> # Include + + # Optimization level + $<$:-Og> + $<$:-O2> + -fno-inline-functions + + # Link time optimizations + $<$:-flto=auto> + $<$:-fuse-linker-plugin> + -ffunction-sections + -fdata-sections + + # C++ stuff + $<$:-fno-rtti> + $<$:-fno-exceptions> + $<$:-fno-use-cxa-atexit> + $<$:-fno-threadsafe-statics> + + # ASM stuff + $<$:-x> + $<$:assembler-with-cpp> +) + # Add libraries add_subdirectory(lib) @@ -195,15 +164,20 @@ add_subdirectory(src) # ) +option(MAINTAINER_MODE "Enables all warnings and errors" OFF) + # Project-only compile options (warnings, etc.) target_compile_options(deluge PUBLIC + $<$,$>:-fanalyzer> # static analysis # Warnings - # $<$:-Wextra> # TODO: Enable when ready - # $<$:-Wall> # TODO: Enable when ready - # $<$:-Wpedantic> # TODO: Enable when ready + $<$:-Wextra> + $<$:-Wall> + $<$:-Wabi> + $<$:-Wpedantic> $<$:-Wnull-dereference> $<$:-Wno-psabi> + $<$:-Wno-unused-parameter> $<$:-Werror=write-strings> @@ -214,13 +188,12 @@ target_compile_options(deluge PUBLIC # tracked for diagnostic usage. We have a 32k stack so it's not that important # primarily concerned with unbounded stack use $<$:-Wstack-usage=2000> - $<$:-Wstack-usage=2000> - $<$:-Wstack-usage=2000> + $<$:-Wstack-usage=2000> ) set_target_properties(deluge PROPERTIES - C_STANDARD 11 + C_STANDARD 17 C_STANDARD_REQUIRED ON CXX_STANDARD 20 CXX_STANDARD_REQUIRED ON @@ -236,8 +209,27 @@ set(NMDUMP_FILE $/deluge${EXECUTABLE_VERSION_SUFFIX}.nmdump) # add link options to generate memory map target_link_options(deluge PUBLIC + -T ${PROJECT_SOURCE_DIR}/linker_script_rz_a1l.ld LINKER:-Map=${MAP_FILE} LINKER:--cref + LINKER:--gc-sections + LINKER:--entry=start # Set the entrypoint to 'start' (see RZA1/compiler/asm/start.S) + + $<$:LINKER:--strip-all> # Strip + + -nostartfiles # Don't emit startfiles + + # Print details + LINKER:--warn-common + LINKER:--stats + #$<$:LINKER:--print-memory-usage> + + # Link-Time Optimization + $<$:-flto=auto> + $<$:-fuse-linker-plugin> + + # Coloring + $<$:-fdiagnostics-color=always> ) # generate .bin firmware file diff --git a/scripts/cmake/CMakeToolchainDeluge.cmake b/scripts/cmake/CMakeToolchainDeluge.cmake index e4900de7f3..88338b4d73 100644 --- a/scripts/cmake/CMakeToolchainDeluge.cmake +++ b/scripts/cmake/CMakeToolchainDeluge.cmake @@ -39,21 +39,20 @@ set(CMAKE_STRIP ${ARM_TOOLCHAIN_BIN_PATH}/arm-none-eabi-strip${TOOLCHAIN_ set(CMAKE_NM ${ARM_TOOLCHAIN_BIN_PATH}/arm-none-eabi-nm${TOOLCHAIN_EXT} CACHE FILEPATH "Path to list symbols.") set(CMAKE_OBJDUMP ${ARM_TOOLCHAIN_BIN_PATH}/arm-none-eabi-objdump${TOOLCHAIN_EXT} CACHE FILEPATH "Path to dump objects.") -set(CMAKE_ASM_FLAGS_RELEASE "-O2 -DNDEBUG" CACHE STRING "Flags used by the ASM compiler during RELEASE builds." FORCE) -set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG" CACHE STRING "Flags used by the C compiler during RELEASE builds." FORCE) -set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG" CACHE STRING "Flags used by the C++ compiler during RELEASE builds." FORCE) +set(CMAKE_ASM_FLAGS_RELEASE "-DNDEBUG" CACHE STRING "Flags used by the ASM compiler during RELEASE builds." FORCE) +set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG" CACHE STRING "Flags used by the C compiler during RELEASE builds." FORCE) +set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG" CACHE STRING "Flags used by the C++ compiler during RELEASE builds." FORCE) set(CMAKE_EXE_LINKER_FLAGS "--specs=nano.specs --specs=rdimon.specs" CACHE STRING "Flags used by the linker during all build types.") # Architecture set(ARCH_FLAGS -mcpu=cortex-a9 - #-march=armv7-a + -mfpu=neon + -mfloat-abi=hard -marm -mthumb-interwork -mlittle-endian - -mfloat-abi=hard - -mfpu=neon ) add_compile_options(${ARCH_FLAGS}) add_link_options(${ARCH_FLAGS}) diff --git a/src/definitions_cxx.hpp b/src/definitions_cxx.hpp index b5ad645c65..1590dbd86d 100644 --- a/src/definitions_cxx.hpp +++ b/src/definitions_cxx.hpp @@ -18,6 +18,7 @@ #pragma once #include "definitions.h" #include "util/misc.h" +#include "version.h" #include #include #include @@ -58,15 +59,6 @@ #define PITCH_DETECT_DEBUG_LEVEL 0 -struct SemVer { - uint8_t major; - uint8_t minor; - uint8_t patch; - // NOTE: below needs C++20 - //auto operator<=>(const SemVer &) const = default -}; -constexpr SemVer kCommunityFirmwareVersion{1, 0, 0}; - // FIXME: These need to be nuked and all references in the codebase removed in prep for the Community Firmware v1.0.0 release // correspondingly, we should probably we storing the semver version in three bytes in the flash rather than trying to compress // it all to one (see above class) diff --git a/src/deluge/CMakeLists.txt b/src/deluge/CMakeLists.txt index 0d9493475a..56e9bb853b 100644 --- a/src/deluge/CMakeLists.txt +++ b/src/deluge/CMakeLists.txt @@ -29,19 +29,18 @@ target_link_libraries(deluge PUBLIC ) target_compile_definitions(deluge PUBLIC - $<$:IN_HARDWARE_DEBUG=1> - $<$:ENABLE_TEXT_OUTPUT=1> - $<$:IN_HARDWARE_DEBUG=1> - $<$:ENABLE_TEXT_OUTPUT=1> + $<$:IN_HARDWARE_DEBUG=1> + $<$:ENABLE_TEXT_OUTPUT=1> ) if(ENABLE_RTT) message(STATUS "RTT enabled for deluge") target_compile_definitions(deluge PUBLIC - $<$:HAVE_RTT=1> - $<$:HAVE_RTT=1> + $<$:HAVE_RTT=1> + ) + target_link_libraries(deluge PUBLIC + $<$:RTT> ) - target_link_libraries(deluge PUBLIC RTT) endif(ENABLE_RTT) if(ENABLE_SYSEX_LOAD) diff --git a/src/deluge/util/functions.h b/src/deluge/util/functions.h index 4342d4755d..6194345b9f 100644 --- a/src/deluge/util/functions.h +++ b/src/deluge/util/functions.h @@ -21,6 +21,7 @@ #include "fatfs/ff.h" #include "util/fixedpoint.h" #include "util/lookuptables/lookuptables.h" +#include #include #include #include @@ -42,7 +43,7 @@ extern int32_t paramNeutralValues[]; void functionsInit(); -static inline void intToString(int32_t number, char* buffer) { +[[gnu::always_inline]] static inline void intToString(int32_t number, char* buffer) { intToString(number, buffer, 1); } @@ -59,7 +60,7 @@ void byteToHex(uint8_t number, char* buffer); uint8_t hexToByte(char const* firstChar); // bits must be *less* than 32! I.e. 31 or less -inline int32_t signed_saturate_operand_unknown(int32_t val, int32_t bits) { +[[gnu::always_inline]] inline int32_t signed_saturate_operand_unknown(int32_t val, int32_t bits) { // Despite having this switch at the per-audio-sample level, it doesn't introduce any slowdown compared to just always saturating by the same amount! switch (bits) { @@ -107,28 +108,28 @@ inline int32_t signed_saturate_operand_unknown(int32_t val, int32_t bits) { } template -inline int32_t lshiftAndSaturate(int32_t val) { +[[gnu::always_inline]] inline int32_t lshiftAndSaturate(int32_t val) { return signed_saturate<32 - lshift>(val) << lshift; } // lshift must be greater than 0! Not 0 -inline int32_t lshiftAndSaturateUnknown(int32_t val, uint8_t lshift) { +[[gnu::always_inline]] inline int32_t lshiftAndSaturateUnknown(int32_t val, uint8_t lshift) { return signed_saturate_operand_unknown(val, 32 - lshift) << lshift; } -static constexpr uint32_t charsToIntegerConstant(char a, char b, char c, char d) { +[[gnu::always_inline]] constexpr uint32_t charsToIntegerConstant(char a, char b, char c, char d) { return (static_cast(a)) | (static_cast(b) << 8) | (static_cast(c) << 16) | (static_cast(d) << 24); } -static constexpr uint16_t charsToIntegerConstant(char a, char b) { +[[gnu::always_inline]] constexpr uint16_t charsToIntegerConstant(char a, char b) { return (static_cast(a)) | (static_cast(b) << 8); } /** * replace asterix with a digit * Only works for single digits */ -static void asterixToInt(char* str, int32_t i) { +[[gnu::always_inline]] constexpr void asterixToInt(char* str, int32_t i) { while (*str != 0) { if (*str == '*') { *str = (char)('0' + i); @@ -227,7 +228,7 @@ bool paramNeedsLPF(int32_t p, bool fromAutomation); int32_t shiftVolumeByDB(int32_t oldValue, float offset); int32_t quickLog(uint32_t input); -static void convertFloatToIntAtMemoryLocation(uint32_t* pos) { +[[gnu::always_inline]] constexpr void convertFloatToIntAtMemoryLocation(uint32_t* pos) { //*(int32_t*)pos = *(float*)pos * 2147483648; @@ -243,8 +244,8 @@ static void convertFloatToIntAtMemoryLocation(uint32_t* pos) { *pos = outputValue; } -static int32_t floatToInt(float theFloat) { - uint32_t readValue = *(uint32_t*)&theFloat; +[[gnu::always_inline]] constexpr int32_t floatToInt(float theFloat) { + uint32_t readValue = std::bit_cast(theFloat); int32_t exponent = (int32_t)((readValue >> 23) & 255) - 127; int32_t outputValue = (exponent >= 0) ? 2147483647 : (uint32_t)((readValue << 8) | 0x80000000) >> (-exponent); @@ -256,7 +257,7 @@ static int32_t floatToInt(float theFloat) { return outputValue; } -static int32_t floatBitPatternToInt(uint32_t readValue) { +[[gnu::always_inline]] constexpr int32_t floatBitPatternToInt(uint32_t readValue) { int32_t exponent = (int32_t)((readValue >> 23) & 255) - 127; int32_t outputValue = (exponent >= 0) ? 2147483647 : (uint32_t)((readValue << 8) | 0x80000000) >> (-exponent); @@ -269,8 +270,8 @@ static int32_t floatBitPatternToInt(uint32_t readValue) { } // input must not have any extra bits set than numBitsInInput specifies -inline int32_t interpolateTableSigned(uint32_t input, int32_t numBitsInInput, const int16_t* table, - int32_t numBitsInTableSize = 8) { +[[gnu::always_inline]] inline int32_t interpolateTableSigned(uint32_t input, int32_t numBitsInInput, + const int16_t* table, int32_t numBitsInTableSize = 8) { int32_t whichValue = input >> (numBitsInInput - numBitsInTableSize); int32_t rshiftAmount = numBitsInInput - 16 - numBitsInTableSize; uint32_t rshifted; @@ -289,9 +290,10 @@ uint32_t interpolateTableInverse(int32_t tableValueBig, int32_t numBitsInLookupO // input must not have any extra bits set than numBitsInInput specifies // Output of this function (unlike the regular 1d one) is only +- 1073741824 -inline int32_t interpolateTableSigned2d(uint32_t inputX, uint32_t inputY, int32_t numBitsInInputX, - int32_t numBitsInInputY, const int16_t* table, int32_t numBitsInTableSizeX, - int32_t numBitsInTableSizeY) { +[[gnu::always_inline]] inline int32_t interpolateTableSigned2d(uint32_t inputX, uint32_t inputY, + int32_t numBitsInInputX, int32_t numBitsInInputY, + const int16_t* table, int32_t numBitsInTableSizeX, + int32_t numBitsInTableSizeY) { int32_t whichValue = inputY >> (numBitsInInputY - numBitsInTableSizeY); @@ -316,7 +318,7 @@ inline int32_t interpolateTableSigned2d(uint32_t inputX, uint32_t inputY, int32_ } template -inline int32_t getTanH(int32_t input) { +[[gnu::always_inline]] inline int32_t getTanH(int32_t input) { uint32_t workingValue; if (saturationAmount) @@ -338,7 +340,8 @@ inline int32_t getTanH(int32_t input) { return interpolateTableSigned(workingValue, 32, tanHSmall, 8) >> (saturationAmount + 2); } -inline int32_t getTanHAntialiased(int32_t input, uint32_t* lastWorkingValue, uint32_t saturationAmount) { +[[gnu::always_inline]] inline int32_t getTanHAntialiased(int32_t input, uint32_t* lastWorkingValue, + uint32_t saturationAmount) { uint32_t workingValue = (uint32_t)lshiftAndSaturateUnknown(input, saturationAmount) + 2147483648u; @@ -348,15 +351,15 @@ inline int32_t getTanHAntialiased(int32_t input, uint32_t* lastWorkingValue, uin return toReturn; } -inline int32_t getSine(uint32_t phase, uint8_t numBitsInInput = 32) { +[[gnu::always_inline]] inline int32_t getSine(uint32_t phase, uint8_t numBitsInInput = 32) { return interpolateTableSigned(phase, numBitsInInput, sineWaveSmall, 8); } -inline int32_t getSquare(uint32_t phase, uint32_t phaseWidth = 2147483648u) { +[[gnu::always_inline]] inline int32_t getSquare(uint32_t phase, uint32_t phaseWidth = 2147483648u) { return ((phase >= phaseWidth) ? (-2147483648) : 2147483647); } -inline int32_t getSquareSmall(uint32_t phase, uint32_t phaseWidth = 2147483648u) { +[[gnu::always_inline]] inline int32_t getSquareSmall(uint32_t phase, uint32_t phaseWidth = 2147483648u) { return ((phase >= phaseWidth) ? (-1073741824) : 1073741823); } @@ -366,13 +369,13 @@ inline int32_t getSquareSmall(uint32_t phase, uint32_t phaseWidth = 2147483648u) phase *= multiplier; */ -inline int32_t getTriangleSmall(uint32_t phase) { +[[gnu::always_inline]] inline int32_t getTriangleSmall(uint32_t phase) { if (phase >= 2147483648u) phase = -phase; return phase - 1073741824; } -inline int32_t getTriangle(uint32_t phase) { +[[gnu::always_inline]] inline int32_t getTriangle(uint32_t phase) { return ((phase < 2147483648u) ? 2 : -2) * phase + 2147483648u; //return getTriangleSmall(phase) << 1; } @@ -387,11 +390,11 @@ int32_t getDecay4(uint32_t input, uint8_t numBitsInInput); extern uint32_t z, w, jcong; -inline uint8_t getRandom255() { +[[gnu::always_inline]] inline uint8_t getRandom255() { return CONG >> 24; } -inline int32_t getNoise() { +[[gnu::always_inline]] inline int32_t getNoise() { return CONG; } @@ -502,14 +505,14 @@ inline void colorCopy(uint8_t* dest, uint8_t* src, uint8_t intensity, uint8_t br dest[2] = (uint8_t)((src[2] * intensity / 255) / brightnessDivider); } -inline int32_t increaseMagnitude(int32_t number, int32_t magnitude) { +[[gnu::always_inline]] inline int32_t increaseMagnitude(int32_t number, int32_t magnitude) { if (magnitude >= 0) return number << magnitude; else return number >> (-magnitude); } -inline int32_t increaseMagnitudeAndSaturate(int32_t number, int32_t magnitude) { +[[gnu::always_inline]] inline int32_t increaseMagnitudeAndSaturate(int32_t number, int32_t magnitude) { if (magnitude > 0) return lshiftAndSaturateUnknown(number, magnitude); else @@ -523,27 +526,27 @@ int32_t divide_round_negative(int32_t dividend, int32_t divisor); void dissectIterationDependence(int32_t probability, int32_t* getDivisor, int32_t* getWhichIterationWithinDivisor); int32_t encodeIterationDependence(int32_t divisor, int32_t iterationWithinDivisor); -inline uint32_t swapEndianness32(uint32_t input) { +[[gnu::always_inline]] inline uint32_t swapEndianness32(uint32_t input) { int32_t out; asm("rev %0, %1" : "=r"(out) : "r"(input)); return out; } -inline uint32_t swapEndianness2x16(uint32_t input) { +[[gnu::always_inline]] inline uint32_t swapEndianness2x16(uint32_t input) { int32_t out; asm("rev16 %0, %1" : "=r"(out) : "r"(input)); return out; } -inline int32_t getMagnitudeOld(uint32_t input) { +[[gnu::always_inline]] inline int32_t getMagnitudeOld(uint32_t input) { return 32 - clz(input); } -inline int32_t getMagnitude(uint32_t input) { +[[gnu::always_inline]] inline int32_t getMagnitude(uint32_t input) { return 31 - clz(input); } -inline bool isPowerOfTwo(uint32_t input) { +[[gnu::always_inline]] inline bool isPowerOfTwo(uint32_t input) { return (input == 1 << getMagnitude(input)); } @@ -559,12 +562,12 @@ void getNoteLengthNameFromMagnitude(char* text, int32_t magnitude, bool clarifyP bool doesFilenameFitPrefixFormat(char const* fileName, char const* filePrefix, int32_t prefixLength); int32_t fresultToDelugeErrorCode(FRESULT result); -inline void writeInt16(char** address, uint16_t number) { +[[gnu::always_inline]] inline void writeInt16(char** address, uint16_t number) { *(uint16_t*)*address = number; *address += 2; } -inline void writeInt32(char** address, uint32_t number) { +[[gnu::always_inline]] inline void writeInt32(char** address, uint32_t number) { *(uint32_t*)*address = number; *address += 4; } diff --git a/src/deluge/version.h.in b/src/deluge/version.h.in index 4f3ec1198e..9ed8c8b38e 100644 --- a/src/deluge/version.h.in +++ b/src/deluge/version.h.in @@ -1,3 +1,21 @@ #pragma once +#include +#include -constexpr char const * kFirmwareVersionString = "@BUILD_VERSION_STRING@"; +struct SemVer { + uint8_t major; + uint8_t minor; + uint8_t patch; + + auto operator<=>(const SemVer&) const = default; +}; + +// clang-format off +constexpr SemVer kCommunityFirmwareVersion { + @PROJECT_VERSION_MAJOR@, + @PROJECT_VERSION_MINOR@, + @PROJECT_VERSION_PATCH@, +}; +//clang-format on + +constexpr char const* kFirmwareVersionString = "@BUILD_VERSION_STRING@";