From 7193bba69300952b9474b14bfe7b7384bcafee56 Mon Sep 17 00:00:00 2001 From: redtide Date: Thu, 19 Sep 2019 02:29:43 +0200 Subject: [PATCH] Fixing files. --- clients/sfzprint.cpp | 2 +- sfizz/FilePool.h | 2 +- sfizz/LeakDetector.h | 5 +++-- sfizz/MathHelpers.h | 7 ++++--- sfizz/MidiState.h | 8 ++++---- sfizz/Opcode.cpp | 5 +++-- sfizz/Parser.cpp | 4 ++-- sfizz/Parser.h | 12 ++++++------ sfizz/Region.cpp | 5 +++-- sfizz/StringViewHelpers.h | 4 ++-- sfizz/Synth.cpp | 8 +++++--- sfizz/filesystem.h | 35 ----------------------------------- 12 files changed, 34 insertions(+), 63 deletions(-) delete mode 100644 sfizz/filesystem.h diff --git a/clients/sfzprint.cpp b/clients/sfzprint.cpp index 5a15f833..91ab76ff 100644 --- a/clients/sfzprint.cpp +++ b/clients/sfzprint.cpp @@ -23,7 +23,7 @@ #include "Parser.h" #include "StringViewHelpers.h" -#include "filesystem.h" +#include "compat/filesystem.h" #include #include #include diff --git a/sfizz/FilePool.h b/sfizz/FilePool.h index 69f5c7cf..1c6c7f59 100644 --- a/sfizz/FilePool.h +++ b/sfizz/FilePool.h @@ -27,7 +27,7 @@ #include "LeakDetector.h" #include "AudioBuffer.h" #include "Voice.h" -#include "filesystem.h" +#include "compat/filesystem.h" #include "readerwriterqueue.h" #include #include diff --git a/sfizz/LeakDetector.h b/sfizz/LeakDetector.h index 948c374a..9d50500d 100644 --- a/sfizz/LeakDetector.h +++ b/sfizz/LeakDetector.h @@ -24,6 +24,7 @@ #pragma once #include #include "Debug.h" +#include "compat/inline.h" template class LeakDetector { @@ -59,7 +60,7 @@ private: }; std::atomic count { 0 }; }; - static inline ObjectCounter objectCounter; + static SFZ_INLINE ObjectCounter objectCounter; }; #ifndef NDEBUG @@ -69,4 +70,4 @@ private: LeakDetector leakDetector; #else #define LEAK_DETECTOR(Class) -#endif \ No newline at end of file +#endif diff --git a/sfizz/MathHelpers.h b/sfizz/MathHelpers.h index e67acb5b..7452eb20 100644 --- a/sfizz/MathHelpers.h +++ b/sfizz/MathHelpers.h @@ -22,6 +22,7 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once +#include "compat/inline.h" #include #include #include @@ -59,8 +60,8 @@ inline constexpr Type mag2db(Type in) } namespace Random { -static inline std::random_device randomDevice; -static inline std::mt19937 randomGenerator { randomDevice() }; +static SFZ_INLINE std::random_device randomDevice; +static SFZ_INLINE std::mt19937 randomGenerator { randomDevice() }; } // namespace Random inline float midiNoteFrequency(const int noteNumber) @@ -79,4 +80,4 @@ constexpr Type piFour { pi / 4 }; template constexpr Type sqrtTwo { 1.414213562373095048801688724209698078569671875376948073176 }; template -constexpr Type sqrtTwoInv { 0.707106781186547524400844362104849039284835937688474036588 }; \ No newline at end of file +constexpr Type sqrtTwoInv { 0.707106781186547524400844362104849039284835937688474036588 }; diff --git a/sfizz/MidiState.h b/sfizz/MidiState.h index ea8a178e..84eab5d5 100644 --- a/sfizz/MidiState.h +++ b/sfizz/MidiState.h @@ -1,10 +1,10 @@ #include #include - +#include "compat/inline.h" namespace sfz { - inline std::array noteOnTimes { }; - inline std::array lastNoteVelocities { }; + SFZ_INLINE std::array noteOnTimes { }; + SFZ_INLINE std::array lastNoteVelocities { }; inline void noteOn(int noteNumber, uint8_t velocity) { if (noteNumber >= 0 && noteNumber < 128) { @@ -31,4 +31,4 @@ namespace sfz return 0; } -} \ No newline at end of file +} diff --git a/sfizz/Opcode.cpp b/sfizz/Opcode.cpp index f75ce0e9..3b502c57 100644 --- a/sfizz/Opcode.cpp +++ b/sfizz/Opcode.cpp @@ -28,7 +28,8 @@ sfz::Opcode::Opcode(absl::string_view inputOpcode, absl::string_view inputValue) : opcode(inputOpcode) , value(inputValue) { - if (const auto lastCharIndex = inputOpcode.find_last_not_of("1234567890"); lastCharIndex != inputOpcode.npos) { + const auto lastCharIndex = inputOpcode.find_last_not_of("1234567890"); + if (lastCharIndex != inputOpcode.npos) { int returnedValue; absl::string_view parameterView = inputOpcode; parameterView.remove_prefix(lastCharIndex + 1); @@ -39,4 +40,4 @@ sfz::Opcode::Opcode(absl::string_view inputOpcode, absl::string_view inputValue) } trimInPlace(value); trimInPlace(opcode); -} \ No newline at end of file +} diff --git a/sfizz/Parser.cpp b/sfizz/Parser.cpp index d3d8e471..60e3716b 100644 --- a/sfizz/Parser.cpp +++ b/sfizz/Parser.cpp @@ -33,8 +33,8 @@ using svmatch_results = std::match_results; void removeCommentOnLine(absl::string_view& line) { - auto position = line.find("//"); - if (position != line.npos) + auto position = line.find("//"); + if (position != line.npos) line.remove_suffix(line.size() - position); } diff --git a/sfizz/Parser.h b/sfizz/Parser.h index 009c360e..7c300a25 100644 --- a/sfizz/Parser.h +++ b/sfizz/Parser.h @@ -23,7 +23,7 @@ #pragma once #include "Opcode.h" -#include "filesystem.h" +#include "compat/filesystem.h" #include #include #include @@ -32,11 +32,11 @@ namespace sfz { namespace Regexes { - inline static std::regex includes { R"V(#include\s*"(.*?)".*$)V", std::regex::optimize }; - inline static std::regex defines { R"(#define\s*(\$[a-zA-Z0-9]+)\s+([a-zA-Z0-9]+)(?=\s|$))", std::regex::optimize }; - inline static std::regex headers { R"(<(.*?)>(.*?)(?=<|$))", std::regex::optimize }; - inline static std::regex members { R"(([a-zA-Z0-9_]+)=([a-zA-Z0-9-_#.&\/\s\\\(\),\*]+)(?![a-zA-Z0-9_]*=))", std::regex::optimize }; - inline static std::regex opcodeParameters { R"(([a-zA-Z0-9_]+?)([0-9]+)$)", std::regex::optimize }; + SFZ_INLINE static std::regex includes { R"V(#include\s*"(.*?)".*$)V", std::regex::optimize }; + SFZ_INLINE static std::regex defines { R"(#define\s*(\$[a-zA-Z0-9]+)\s+([a-zA-Z0-9]+)(?=\s|$))", std::regex::optimize }; + SFZ_INLINE static std::regex headers { R"(<(.*?)>(.*?)(?=<|$))", std::regex::optimize }; + SFZ_INLINE static std::regex members { R"(([a-zA-Z0-9_]+)=([a-zA-Z0-9-_#.&\/\s\\\(\),\*]+)(?![a-zA-Z0-9_]*=))", std::regex::optimize }; + SFZ_INLINE static std::regex opcodeParameters { R"(([a-zA-Z0-9_]+?)([0-9]+)$)", std::regex::optimize }; } class Parser { diff --git a/sfizz/Region.cpp b/sfizz/Region.cpp index d9f98b62..e6126be5 100644 --- a/sfizz/Region.cpp +++ b/sfizz/Region.cpp @@ -298,7 +298,8 @@ bool sfz::Region::parseOpcode(const Opcode& opcode) break; case hash("amp_velcurve_"): if (opcode.parameter && Default::ccRange.containsWithEnd(*opcode.parameter)) { - if (auto value = readOpcode(opcode.value, Default::ampVelcurveRange); value) + auto value = readOpcode(opcode.value, Default::ampVelcurveRange); + if (value) velocityPoints.emplace_back(*opcode.parameter, *value); } break; @@ -771,4 +772,4 @@ float sfz::Region::velocityCurve(uint8_t velocity) const noexcept } return gain; -} \ No newline at end of file +} diff --git a/sfizz/StringViewHelpers.h b/sfizz/StringViewHelpers.h index 22b127ab..d4a5add0 100644 --- a/sfizz/StringViewHelpers.h +++ b/sfizz/StringViewHelpers.h @@ -49,8 +49,8 @@ inline absl::string_view trim(absl::string_view s) return s; } -inline constexpr uint64_t Fnv1aBasis = 0x811C9DC5; -inline constexpr uint64_t Fnv1aPrime = 0x01000193; +constexpr uint64_t Fnv1aBasis = 0x811C9DC5; +constexpr uint64_t Fnv1aPrime = 0x01000193; inline constexpr uint64_t hash(absl::string_view s, uint64_t h = Fnv1aBasis) { diff --git a/sfizz/Synth.cpp b/sfizz/Synth.cpp index 4ef6eaef..b1aade21 100644 --- a/sfizz/Synth.cpp +++ b/sfizz/Synth.cpp @@ -113,7 +113,7 @@ void sfz::Synth::clear() numMasters = 0; numCurves = 0; fileTicket = -1; - defaultSwitch = absl::nullopt; + defaultSwitch = absl::nullopt; for (auto& state : ccState) state = 0; ccNames.clear(); @@ -150,10 +150,12 @@ void sfz::Synth::handleControlOpcodes(const std::vector& members) ccNames.emplace_back(*member.parameter, member.value); break; case hash("Default_path"): [[fallthrough]]; - case hash("default_path"): - if (auto newPath = std::filesystem::path(member.value); std::filesystem::exists(newPath)) + case hash("default_path"): { + auto newPath = std::filesystem::path(member.value); + if (std::filesystem::exists(newPath)) rootDirectory = newPath; break; + } default: // Unsupported control opcode ASSERTFALSE; diff --git a/sfizz/filesystem.h b/sfizz/filesystem.h deleted file mode 100644 index 7d5f5c14..00000000 --- a/sfizz/filesystem.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2019, Paul Ferrand -// All rights reserved. - -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: - -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. - -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#pragma once - -#if defined(__cpp_lib_filesystem) || (defined(__has_include) && __has_include()) - #include -#elif __cplusplus >= 201103L - #include - namespace std { - namespace filesystem = std::experimental::filesystem; - } -#else - #error no filesystem support -#endif