Fixing files.
This commit is contained in:
parent
511ee9bf05
commit
377e35e88f
12 changed files with 34 additions and 63 deletions
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
#include "Parser.h"
|
#include "Parser.h"
|
||||||
#include "StringViewHelpers.h"
|
#include "StringViewHelpers.h"
|
||||||
#include "filesystem.h"
|
#include "compat/filesystem.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <absl/flags/parse.h>
|
#include <absl/flags/parse.h>
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
#include "LeakDetector.h"
|
#include "LeakDetector.h"
|
||||||
#include "AudioBuffer.h"
|
#include "AudioBuffer.h"
|
||||||
#include "Voice.h"
|
#include "Voice.h"
|
||||||
#include "filesystem.h"
|
#include "compat/filesystem.h"
|
||||||
#include "readerwriterqueue.h"
|
#include "readerwriterqueue.h"
|
||||||
#include <absl/container/flat_hash_map.h>
|
#include <absl/container/flat_hash_map.h>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include "Debug.h"
|
#include "Debug.h"
|
||||||
|
#include "compat/inline.h"
|
||||||
|
|
||||||
template <class Owner>
|
template <class Owner>
|
||||||
class LeakDetector {
|
class LeakDetector {
|
||||||
|
|
@ -59,7 +60,7 @@ private:
|
||||||
};
|
};
|
||||||
std::atomic<int> count { 0 };
|
std::atomic<int> count { 0 };
|
||||||
};
|
};
|
||||||
static inline ObjectCounter objectCounter;
|
static SFZ_INLINE ObjectCounter objectCounter;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
|
@ -69,4 +70,4 @@ private:
|
||||||
LeakDetector<Class> leakDetector;
|
LeakDetector<Class> leakDetector;
|
||||||
#else
|
#else
|
||||||
#define LEAK_DETECTOR(Class)
|
#define LEAK_DETECTOR(Class)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "compat/inline.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
@ -59,8 +60,8 @@ inline constexpr Type mag2db(Type in)
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Random {
|
namespace Random {
|
||||||
static inline std::random_device randomDevice;
|
static SFZ_INLINE std::random_device randomDevice;
|
||||||
static inline std::mt19937 randomGenerator { randomDevice() };
|
static SFZ_INLINE std::mt19937 randomGenerator { randomDevice() };
|
||||||
} // namespace Random
|
} // namespace Random
|
||||||
|
|
||||||
inline float midiNoteFrequency(const int noteNumber)
|
inline float midiNoteFrequency(const int noteNumber)
|
||||||
|
|
@ -79,4 +80,4 @@ constexpr Type piFour { pi<Type> / 4 };
|
||||||
template <class Type>
|
template <class Type>
|
||||||
constexpr Type sqrtTwo { 1.414213562373095048801688724209698078569671875376948073176 };
|
constexpr Type sqrtTwo { 1.414213562373095048801688724209698078569671875376948073176 };
|
||||||
template <class Type>
|
template <class Type>
|
||||||
constexpr Type sqrtTwoInv { 0.707106781186547524400844362104849039284835937688474036588 };
|
constexpr Type sqrtTwoInv { 0.707106781186547524400844362104849039284835937688474036588 };
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include "compat/inline.h"
|
||||||
namespace sfz
|
namespace sfz
|
||||||
{
|
{
|
||||||
inline std::array<std::chrono::steady_clock::time_point, 128> noteOnTimes { };
|
SFZ_INLINE std::array<std::chrono::steady_clock::time_point, 128> noteOnTimes { };
|
||||||
inline std::array<uint8_t, 128> lastNoteVelocities { };
|
SFZ_INLINE std::array<uint8_t, 128> lastNoteVelocities { };
|
||||||
inline void noteOn(int noteNumber, uint8_t velocity)
|
inline void noteOn(int noteNumber, uint8_t velocity)
|
||||||
{
|
{
|
||||||
if (noteNumber >= 0 && noteNumber < 128) {
|
if (noteNumber >= 0 && noteNumber < 128) {
|
||||||
|
|
@ -31,4 +31,4 @@ namespace sfz
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,8 @@ sfz::Opcode::Opcode(absl::string_view inputOpcode, absl::string_view inputValue)
|
||||||
: opcode(inputOpcode)
|
: opcode(inputOpcode)
|
||||||
, value(inputValue)
|
, 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;
|
int returnedValue;
|
||||||
absl::string_view parameterView = inputOpcode;
|
absl::string_view parameterView = inputOpcode;
|
||||||
parameterView.remove_prefix(lastCharIndex + 1);
|
parameterView.remove_prefix(lastCharIndex + 1);
|
||||||
|
|
@ -39,4 +40,4 @@ sfz::Opcode::Opcode(absl::string_view inputOpcode, absl::string_view inputValue)
|
||||||
}
|
}
|
||||||
trimInPlace(value);
|
trimInPlace(value);
|
||||||
trimInPlace(opcode);
|
trimInPlace(opcode);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,8 @@ using svmatch_results = std::match_results<absl::string_view::const_iterator>;
|
||||||
|
|
||||||
void removeCommentOnLine(absl::string_view& line)
|
void removeCommentOnLine(absl::string_view& line)
|
||||||
{
|
{
|
||||||
auto position = line.find("//");
|
auto position = line.find("//");
|
||||||
if (position != line.npos)
|
if (position != line.npos)
|
||||||
line.remove_suffix(line.size() - position);
|
line.remove_suffix(line.size() - position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "Opcode.h"
|
#include "Opcode.h"
|
||||||
#include "filesystem.h"
|
#include "compat/filesystem.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
@ -32,11 +32,11 @@
|
||||||
|
|
||||||
namespace sfz {
|
namespace sfz {
|
||||||
namespace Regexes {
|
namespace Regexes {
|
||||||
inline static std::regex includes { R"V(#include\s*"(.*?)".*$)V", std::regex::optimize };
|
SFZ_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 };
|
SFZ_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 };
|
SFZ_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 };
|
SFZ_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 opcodeParameters { R"(([a-zA-Z0-9_]+?)([0-9]+)$)", std::regex::optimize };
|
||||||
}
|
}
|
||||||
|
|
||||||
class Parser {
|
class Parser {
|
||||||
|
|
|
||||||
|
|
@ -298,7 +298,8 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
||||||
break;
|
break;
|
||||||
case hash("amp_velcurve_"):
|
case hash("amp_velcurve_"):
|
||||||
if (opcode.parameter && Default::ccRange.containsWithEnd(*opcode.parameter)) {
|
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);
|
velocityPoints.emplace_back(*opcode.parameter, *value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -771,4 +772,4 @@ float sfz::Region::velocityCurve(uint8_t velocity) const noexcept
|
||||||
}
|
}
|
||||||
|
|
||||||
return gain;
|
return gain;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,8 @@ inline absl::string_view trim(absl::string_view s)
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr uint64_t Fnv1aBasis = 0x811C9DC5;
|
constexpr uint64_t Fnv1aBasis = 0x811C9DC5;
|
||||||
inline constexpr uint64_t Fnv1aPrime = 0x01000193;
|
constexpr uint64_t Fnv1aPrime = 0x01000193;
|
||||||
|
|
||||||
inline constexpr uint64_t hash(absl::string_view s, uint64_t h = Fnv1aBasis)
|
inline constexpr uint64_t hash(absl::string_view s, uint64_t h = Fnv1aBasis)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ void sfz::Synth::clear()
|
||||||
numMasters = 0;
|
numMasters = 0;
|
||||||
numCurves = 0;
|
numCurves = 0;
|
||||||
fileTicket = -1;
|
fileTicket = -1;
|
||||||
defaultSwitch = absl::nullopt;
|
defaultSwitch = absl::nullopt;
|
||||||
for (auto& state : ccState)
|
for (auto& state : ccState)
|
||||||
state = 0;
|
state = 0;
|
||||||
ccNames.clear();
|
ccNames.clear();
|
||||||
|
|
@ -150,10 +150,12 @@ void sfz::Synth::handleControlOpcodes(const std::vector<Opcode>& members)
|
||||||
ccNames.emplace_back(*member.parameter, member.value);
|
ccNames.emplace_back(*member.parameter, member.value);
|
||||||
break;
|
break;
|
||||||
case hash("Default_path"): [[fallthrough]];
|
case hash("Default_path"): [[fallthrough]];
|
||||||
case hash("default_path"):
|
case hash("default_path"): {
|
||||||
if (auto newPath = std::filesystem::path(member.value); std::filesystem::exists(newPath))
|
auto newPath = std::filesystem::path(member.value);
|
||||||
|
if (std::filesystem::exists(newPath))
|
||||||
rootDirectory = newPath;
|
rootDirectory = newPath;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
// Unsupported control opcode
|
// Unsupported control opcode
|
||||||
ASSERTFALSE;
|
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