Updated the constants to please Clang

This commit is contained in:
paulfd 2019-08-24 15:50:55 +02:00
parent a798ac7393
commit 99c3e8878f
2 changed files with 34 additions and 35 deletions

View file

@ -112,6 +112,9 @@ inline float midiNoteFrequency(const int noteNumber)
return 440.0f * std::pow(2.0f, (noteNumber - 69) / 12.0f);
}
constexpr double pi() { return std::acos(-1); }
constexpr double twoPi() { return 2*pi(); }
constexpr double piTwo() { return pi()/2; }
template<class Type>
constexpr Type pi { 3.141592653589793238462643383279502884 };
template<class Type>
constexpr Type twoPi { 2*pi<Type> };
template<class Type>
constexpr Type piTwo { pi<Type>/2 };

View file

@ -1,25 +1,24 @@
#pragma once
#include "ADSREnvelope.h"
#include "StereoBuffer.h"
#include "StereoSpan.h"
#include "Globals.h"
#include "Region.h"
#include "absl/types/span.h"
#include "SIMDHelpers.h"
#include "SfzHelpers.h"
#include "StereoBuffer.h"
#include "StereoSpan.h"
#include "absl/types/span.h"
#include <atomic>
#include <memory>
namespace sfz
{
class Voice
{
namespace sfz {
class Voice {
public:
Voice() = delete;
Voice(const CCValueArray& ccState)
: ccState(ccState) {}
enum class TriggerType
: ccState(ccState)
{
}
enum class TriggerType {
NoteOn,
NoteOff,
CC
@ -126,7 +125,7 @@ public:
void fillWithData(StereoSpan<float> buffer)
{
StereoSpan<const float> source([&]() -> StereoBuffer<float> & {
const StereoSpan<const float> source([&]() -> StereoBuffer<float>& {
if (dataReady)
return *fileData;
else
@ -145,7 +144,7 @@ public:
if (region->sample != "*sine")
return;
float step = baseFrequency * twoPi() / sampleRate;
float step = baseFrequency * twoPi<float> / sampleRate;
::linearRamp<float>(tempSpan1.first(buffer.size()), sourcePosition * step, step);
::sin<float>(tempSpan1, buffer.left());
absl::c_copy(buffer.left(), buffer.right().begin());
@ -154,8 +153,7 @@ public:
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
return true;
}
@ -185,8 +183,7 @@ public:
void reset()
{
if (region != nullptr)
{
if (region != nullptr) {
DBG("Reset voice with sample " << region->sample);
}
region = nullptr;
@ -197,8 +194,7 @@ public:
private:
Region* region;
enum class State
{
enum class State {
idle,
playing,
release