Updated the constants to please Clang
This commit is contained in:
parent
a798ac7393
commit
99c3e8878f
2 changed files with 34 additions and 35 deletions
|
|
@ -112,6 +112,9 @@ inline float midiNoteFrequency(const int noteNumber)
|
||||||
return 440.0f * std::pow(2.0f, (noteNumber - 69) / 12.0f);
|
return 440.0f * std::pow(2.0f, (noteNumber - 69) / 12.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr double pi() { return std::acos(-1); }
|
template<class Type>
|
||||||
constexpr double twoPi() { return 2*pi(); }
|
constexpr Type pi { 3.141592653589793238462643383279502884 };
|
||||||
constexpr double piTwo() { return pi()/2; }
|
template<class Type>
|
||||||
|
constexpr Type twoPi { 2*pi<Type> };
|
||||||
|
template<class Type>
|
||||||
|
constexpr Type piTwo { pi<Type>/2 };
|
||||||
|
|
@ -1,25 +1,24 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "ADSREnvelope.h"
|
#include "ADSREnvelope.h"
|
||||||
#include "StereoBuffer.h"
|
|
||||||
#include "StereoSpan.h"
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "Region.h"
|
#include "Region.h"
|
||||||
#include "absl/types/span.h"
|
|
||||||
#include "SIMDHelpers.h"
|
#include "SIMDHelpers.h"
|
||||||
#include "SfzHelpers.h"
|
#include "SfzHelpers.h"
|
||||||
|
#include "StereoBuffer.h"
|
||||||
|
#include "StereoSpan.h"
|
||||||
|
#include "absl/types/span.h"
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace sfz
|
namespace sfz {
|
||||||
{
|
class Voice {
|
||||||
class Voice
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
Voice() = delete;
|
Voice() = delete;
|
||||||
Voice(const CCValueArray& ccState)
|
Voice(const CCValueArray& ccState)
|
||||||
: ccState(ccState) {}
|
: ccState(ccState)
|
||||||
enum class TriggerType
|
|
||||||
{
|
{
|
||||||
|
}
|
||||||
|
enum class TriggerType {
|
||||||
NoteOn,
|
NoteOn,
|
||||||
NoteOff,
|
NoteOff,
|
||||||
CC
|
CC
|
||||||
|
|
@ -126,7 +125,7 @@ public:
|
||||||
|
|
||||||
void fillWithData(StereoSpan<float> buffer)
|
void fillWithData(StereoSpan<float> buffer)
|
||||||
{
|
{
|
||||||
StereoSpan<const float> source([&]() -> StereoBuffer<float> & {
|
const StereoSpan<const float> source([&]() -> StereoBuffer<float>& {
|
||||||
if (dataReady)
|
if (dataReady)
|
||||||
return *fileData;
|
return *fileData;
|
||||||
else
|
else
|
||||||
|
|
@ -145,7 +144,7 @@ public:
|
||||||
if (region->sample != "*sine")
|
if (region->sample != "*sine")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float step = baseFrequency * twoPi() / sampleRate;
|
float step = baseFrequency * twoPi<float> / sampleRate;
|
||||||
::linearRamp<float>(tempSpan1.first(buffer.size()), sourcePosition * step, step);
|
::linearRamp<float>(tempSpan1.first(buffer.size()), sourcePosition * step, step);
|
||||||
::sin<float>(tempSpan1, buffer.left());
|
::sin<float>(tempSpan1, buffer.left());
|
||||||
absl::c_copy(buffer.left(), buffer.right().begin());
|
absl::c_copy(buffer.left(), buffer.right().begin());
|
||||||
|
|
@ -154,8 +153,7 @@ public:
|
||||||
|
|
||||||
bool checkOffGroup(int delay [[maybe_unused]], uint32_t group) noexcept
|
bool checkOffGroup(int delay [[maybe_unused]], uint32_t group) noexcept
|
||||||
{
|
{
|
||||||
if (region != nullptr && triggerType == TriggerType::NoteOn && region->offBy && *region->offBy == group)
|
if (region != nullptr && triggerType == TriggerType::NoteOn && region->offBy && *region->offBy == group) {
|
||||||
{
|
|
||||||
// TODO: release
|
// TODO: release
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -185,8 +183,7 @@ public:
|
||||||
|
|
||||||
void reset()
|
void reset()
|
||||||
{
|
{
|
||||||
if (region != nullptr)
|
if (region != nullptr) {
|
||||||
{
|
|
||||||
DBG("Reset voice with sample " << region->sample);
|
DBG("Reset voice with sample " << region->sample);
|
||||||
}
|
}
|
||||||
region = nullptr;
|
region = nullptr;
|
||||||
|
|
@ -197,8 +194,7 @@ public:
|
||||||
private:
|
private:
|
||||||
Region* region;
|
Region* region;
|
||||||
|
|
||||||
enum class State
|
enum class State {
|
||||||
{
|
|
||||||
idle,
|
idle,
|
||||||
playing,
|
playing,
|
||||||
release
|
release
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue