sfizz/src/sfizz/Config.h

104 lines
3.8 KiB
C
Raw Normal View History

2020-01-25 10:04:31 +01:00
// SPDX-License-Identifier: BSD-2-Clause
2020-01-25 13:13:07 +01:00
// This code is part of the sfizz library and is licensed under a BSD 2-clause
// license. You should have receive a LICENSE.md file along with the code.
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
2019-08-30 13:07:37 +02:00
#pragma once
#ifdef _WIN32
// There's a spurious min/max function in MSVC that makes everything go badly...
2020-02-02 21:30:26 +01:00
#ifndef NOMINMAX
#define NOMINMAX 1
#endif
#define _SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING
#endif
#include "absl/strings/string_view.h"
2020-01-05 00:58:28 +01:00
#include <cstddef>
2020-01-28 21:42:15 +01:00
#include <cstdint>
2019-08-30 13:07:37 +02:00
namespace sfz {
enum class Oversampling: int {
x1 = 1,
x2 = 2,
x4 = 4,
x8 = 8
};
2019-08-30 13:07:37 +02:00
namespace config {
constexpr float defaultSampleRate { 48000 };
constexpr float maxSampleRate { 192000 };
2019-08-30 13:07:37 +02:00
constexpr int defaultSamplesPerBlock { 1024 };
2019-12-17 22:48:06 +01:00
constexpr int maxBlockSize { 8192 };
2020-05-07 20:48:18 +02:00
constexpr int bufferPoolSize { 6 };
2020-03-29 17:37:30 +02:00
constexpr int stereoBufferPoolSize { 4 };
constexpr int indexBufferPoolSize { 2 };
2019-11-30 16:32:43 +01:00
constexpr int preloadSize { 8192 };
2020-02-28 01:17:38 +01:00
constexpr int loggerQueueSize { 256 };
constexpr int voiceLoggerQueueSize { 256 };
2020-01-19 19:02:06 +01:00
constexpr bool loggingEnabled { false };
constexpr size_t numChannels { 2 };
2019-12-03 21:30:00 +01:00
constexpr int numBackgroundThreads { 4 };
constexpr int numVoices { 64 };
constexpr unsigned maxVoices { 256 };
constexpr unsigned smoothingSteps { 512 };
2020-04-18 21:01:56 +02:00
constexpr uint8_t gainSmoothing { 5 };
constexpr unsigned powerTableSizeExponent { 11 };
2020-05-05 23:18:08 +02:00
constexpr int maxFilePromises { maxVoices };
2019-12-17 22:49:16 +01:00
constexpr int allSoundOffCC { 120 };
constexpr int resetCC { 121 };
constexpr int allNotesOffCC { 123 };
constexpr int omniOffCC { 124 };
constexpr int omniOnCC { 125 };
2020-03-26 00:12:30 +01:00
constexpr float halfCCThreshold { 0.5f };
2019-08-30 13:07:37 +02:00
constexpr int centPerSemitone { 100 };
2020-03-31 22:14:48 +02:00
constexpr float virtuallyZero { 0.001f };
constexpr float fastReleaseDuration { 0.01f };
2019-08-30 13:07:37 +02:00
constexpr char defineCharacter { '$' };
constexpr Oversampling defaultOversamplingFactor { Oversampling::x1 };
2019-08-30 13:07:37 +02:00
constexpr float A440 { 440.0 };
constexpr size_t powerHistoryLength { 16 };
constexpr float filteredEnvelopeCutoff { 5 };
constexpr uint16_t numCCs { 512 };
constexpr int maxCurves { 256 };
constexpr int chunkSize { 1024 };
2020-05-30 10:41:50 +02:00
constexpr unsigned int defaultAlignment { 16 };
constexpr int filtersInPool { maxVoices * 2 };
2020-05-16 00:07:27 +02:00
constexpr int excessFileFrames { 8 };
2020-05-08 00:20:28 +02:00
/**
* @brief The threshold for age stealing.
* In percentage of the voice's max age.
*/
constexpr float stealingAgeCoeff { 0.5f };
/**
* @brief The threshold for envelope stealing.
* In percentage of the sum of all envelopes.
*/
constexpr float stealingEnvelopeCoeff { 0.5f };
constexpr int filtersPerVoice { 2 };
constexpr int eqsPerVoice { 3 };
2020-04-07 16:12:29 +02:00
constexpr int oscillatorsPerVoice { 9 };
2020-02-09 16:49:19 +01:00
constexpr float noiseVariance { 0.25f };
/**
Minimum interval in frames between recomputations of coefficients of the
modulated filter. The lower, the more CPU resources are consumed.
*/
constexpr int filterControlInterval { 16 };
/**
Default metadata for MIDIName documents
*/
const absl::string_view midnamManufacturer { "The Sfizz authors" };
const absl::string_view midnamModel { "Sfizz" };
2020-02-26 21:09:34 +01:00
/**
Limit of how many "fxN" buses are accepted (in SFZv2, maximum is 4)
*/
constexpr int maxEffectBuses { 256 };
// Wavetable constants; amplitude values are matched to reference
static constexpr unsigned tableSize = 1024;
static constexpr double amplitudeSine = 0.625;
static constexpr double amplitudeTriangle = 0.625;
static constexpr double amplitudeSaw = 0.515;
static constexpr double amplitudeSquare = 0.515;
2019-08-30 13:07:37 +02:00
} // namespace config
2019-11-30 00:52:15 +01:00
} // namespace sfz