Fixing files.
This commit is contained in:
parent
ca5b08077e
commit
7193bba693
12 changed files with 34 additions and 63 deletions
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "Parser.h"
|
||||
#include "StringViewHelpers.h"
|
||||
#include "filesystem.h"
|
||||
#include "compat/filesystem.h"
|
||||
#include <iostream>
|
||||
#include <string_view>
|
||||
#include <absl/flags/parse.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 <absl/container/flat_hash_map.h>
|
||||
#include <mutex>
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#pragma once
|
||||
#include <atomic>
|
||||
#include "Debug.h"
|
||||
#include "compat/inline.h"
|
||||
|
||||
template <class Owner>
|
||||
class LeakDetector {
|
||||
|
|
@ -59,7 +60,7 @@ private:
|
|||
};
|
||||
std::atomic<int> count { 0 };
|
||||
};
|
||||
static inline ObjectCounter objectCounter;
|
||||
static SFZ_INLINE ObjectCounter objectCounter;
|
||||
};
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
|
@ -69,4 +70,4 @@ private:
|
|||
LeakDetector<Class> leakDetector;
|
||||
#else
|
||||
#define LEAK_DETECTOR(Class)
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#pragma once
|
||||
#include "compat/inline.h"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <random>
|
||||
|
|
@ -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<Type> / 4 };
|
|||
template <class Type>
|
||||
constexpr Type sqrtTwo { 1.414213562373095048801688724209698078569671875376948073176 };
|
||||
template <class Type>
|
||||
constexpr Type sqrtTwoInv { 0.707106781186547524400844362104849039284835937688474036588 };
|
||||
constexpr Type sqrtTwoInv { 0.707106781186547524400844362104849039284835937688474036588 };
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
#include <chrono>
|
||||
#include <array>
|
||||
|
||||
#include "compat/inline.h"
|
||||
namespace sfz
|
||||
{
|
||||
inline std::array<std::chrono::steady_clock::time_point, 128> noteOnTimes { };
|
||||
inline std::array<uint8_t, 128> lastNoteVelocities { };
|
||||
SFZ_INLINE std::array<std::chrono::steady_clock::time_point, 128> noteOnTimes { };
|
||||
SFZ_INLINE std::array<uint8_t, 128> lastNoteVelocities { };
|
||||
inline void noteOn(int noteNumber, uint8_t velocity)
|
||||
{
|
||||
if (noteNumber >= 0 && noteNumber < 128) {
|
||||
|
|
@ -31,4 +31,4 @@ namespace sfz
|
|||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ using svmatch_results = std::match_results<absl::string_view::const_iterator>;
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#pragma once
|
||||
#include "Opcode.h"
|
||||
#include "filesystem.h"
|
||||
#include "compat/filesystem.h"
|
||||
#include <map>
|
||||
#include <regex>
|
||||
#include <string>
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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<Opcode>& 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;
|
||||
|
|
|
|||
|
|
@ -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(<filesystem>))
|
||||
#include <filesystem>
|
||||
#elif __cplusplus >= 201103L
|
||||
#include <experimental/filesystem>
|
||||
namespace std {
|
||||
namespace filesystem = std::experimental::filesystem;
|
||||
}
|
||||
#else
|
||||
#error no filesystem support
|
||||
#endif
|
||||
Loading…
Add table
Reference in a new issue