Skip to content

Commit

Permalink
Fix to use <numbers> for π
Browse files Browse the repository at this point in the history
This is a fix because the build was broken.
  • Loading branch information
ryukau committed Oct 11, 2024
1 parent 29ac62d commit 4e0c8a8
Show file tree
Hide file tree
Showing 21 changed files with 511 additions and 495 deletions.
3 changes: 2 additions & 1 deletion ClangSynth/source/parameter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#pragma once

#include <memory>
#include <numbers>
#include <string>
#include <vector>

Expand Down Expand Up @@ -362,7 +363,7 @@ struct GlobalParameter : public ParameterInterface {
auto indexStr = std::to_string(idx);
value[ID::lfoWavetable0 + idx] = std::make_unique<LinearValue>(
Scales::wavetableAmp.invmap(
std::sin(SomeDSP::twopi * idx / double(nLfoWavetable))),
std::sin(double(2) * std::numbers::pi_v<double> * idx / double(nLfoWavetable))),
Scales::wavetableAmp, (lfoWavetableLabel + indexStr).c_str(), Info::kCanAutomate);
}
value[ID::lfoInterpolation] = std::make_unique<UIntValue>(
Expand Down
8 changes: 5 additions & 3 deletions CubicPadSynth/source/parameter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@
#pragma once

#include <memory>
#include <numbers>
#include <string>
#include <vector>

#include "../../common/dsp/constants.hpp"
#include "../../common/parameterInterface.hpp"

#ifdef TEST_DSP
#include "../../test/value.hpp"
#include "../../test/value.hpp"
#else
#include "../../common/value.hpp"
#include "../../common/value.hpp"
#endif

constexpr int32_t nOvertone = 360;
Expand Down Expand Up @@ -216,7 +217,8 @@ struct GlobalParameter : public ParameterInterface {
for (size_t idx = 0; idx < nLFOWavetable; ++idx) {
auto indexStr = std::to_string(idx + 1);
value[ID::lfoWavetable0 + idx] = std::make_unique<LinearValue>(
Scales::lfoWavetable.invmap(sin(SomeDSP::twopi * idx / double(nLFOWavetable))),
Scales::lfoWavetable.invmap(
std::sin(double(2) * std::numbers::pi_v<double> * idx / double(nLFOWavetable))),
Scales::lfoWavetable, (lfoWavetableLabel + indexStr).c_str(), Info::kCanAutomate);
}

Expand Down
9 changes: 5 additions & 4 deletions EsPhaser/source/parameter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@
#pragma once

#include <memory>
#include <numbers>
#include <string>
#include <vector>

#include "../../common/parameterInterface.hpp"

#ifdef TEST_DSP
#include "../../test/value.hpp"
#include "../../test/value.hpp"
#else
#include "../../common/value.hpp"
#include "../../common/value.hpp"
#endif

namespace Steinberg {
Expand Down Expand Up @@ -102,8 +103,8 @@ struct GlobalParameter : public ParameterInterface {
value[ID::stereoOffset] = std::make_unique<LinearValue>(
0.5, Scales::phase, "stereoOffset", Info::kCanAutomate);
value[ID::cascadeOffset] = std::make_unique<LinearValue>(
Scales::cascadeOffset.invmap(SomeDSP::twopi / 16.0), Scales::cascadeOffset,
"cascadeOffset", Info::kCanAutomate);
Scales::cascadeOffset.invmap(double(2) * std::numbers::pi_v<double> / 16.0),
Scales::cascadeOffset, "cascadeOffset", Info::kCanAutomate);
value[ID::stage]
= std::make_unique<UIntValue>(15, Scales::stage, "stage", Info::kCanAutomate);

Expand Down
4 changes: 2 additions & 2 deletions FDNCymbal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
cmake_minimum_required(VERSION 3.20)


include(../common/cmake/non_simd.cmake)

Expand Down
3 changes: 2 additions & 1 deletion GlitchSprinkler/source/parameter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ struct GlobalParameter : public ParameterInterface {
Scales::defaultScale.invmap(ratio), Scales::defaultScale,
("polynomialPointX" + indexStr).c_str(), Info::kCanAutomate);
value[ID::polynomialPointY0 + idx] = std::make_unique<LinearValue>(
Scales::polynomialPointY.invmap(0.5 * std::sin(SomeDSP::twopi * ratio)),
Scales::polynomialPointY.invmap(
0.5 * std::sin(double(2) * std::numbers::pi_v<double> * ratio)),
Scales::polynomialPointY, ("polynomialPointY" + indexStr).c_str(),
Info::kCanAutomate);
}
Expand Down
8 changes: 5 additions & 3 deletions LightPadSynth/source/parameter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@
#pragma once

#include <memory>
#include <numbers>
#include <string>
#include <vector>

#include "../../common/dsp/constants.hpp"
#include "../../common/parameterInterface.hpp"

#ifdef TEST_DSP
#include "../../test/value.hpp"
#include "../../test/value.hpp"
#else
#include "../../common/value.hpp"
#include "../../common/value.hpp"
#endif

constexpr int32_t nOvertone = 360;
Expand Down Expand Up @@ -216,7 +217,8 @@ struct GlobalParameter : public ParameterInterface {
for (size_t idx = 0; idx < nLFOWavetable; ++idx) {
auto indexStr = std::to_string(idx + 1);
value[ID::lfoWavetable0 + idx] = std::make_unique<LinearValue>(
Scales::lfoWavetable.invmap(sin(SomeDSP::twopi * idx / double(nLFOWavetable))),
Scales::lfoWavetable.invmap(
std::sin(double(2) * std::numbers::pi_v<double> * idx / double(nLFOWavetable))),
Scales::lfoWavetable, (lfoWavetableLabel + indexStr).c_str(), Info::kCanAutomate);
}

Expand Down
4 changes: 3 additions & 1 deletion LongPhaser/source/parameter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#pragma once

#include <memory>
#include <numbers>
#include <string>
#include <vector>

Expand Down Expand Up @@ -145,7 +146,8 @@ struct GlobalParameter : public ParameterInterface {
for (size_t idx = 0; idx < nLfoWavetable; ++idx) {
auto indexStr = std::to_string(idx);
value[ID::lfoWavetable0 + idx] = std::make_unique<LinearValue>(
Scales::bipolarScale.invmap(sin(SomeDSP::twopi * idx / double(nLfoWavetable))),
Scales::bipolarScale.invmap(
std::sin(double(2) * std::numbers::pi_v<double> * idx / double(nLfoWavetable))),
Scales::bipolarScale, (lfoWavetableLabel + indexStr).c_str(), Info::kCanAutomate);
}
value[ID::lfoTempoSync] = std::make_unique<UIntValue>(
Expand Down
4 changes: 3 additions & 1 deletion OrdinaryPhaser/source/parameter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#pragma once

#include <memory>
#include <numbers>
#include <string>
#include <vector>

Expand Down Expand Up @@ -148,7 +149,8 @@ struct GlobalParameter : public ParameterInterface {
for (size_t idx = 0; idx < nLfoWavetable; ++idx) {
auto indexStr = std::to_string(idx);
value[ID::lfoWavetable0 + idx] = std::make_unique<LinearValue>(
Scales::bipolarScale.invmap(sin(SomeDSP::twopi * idx / double(nLfoWavetable))),
Scales::bipolarScale.invmap(
std::sin(double(2) * std::numbers::pi_v<double> * idx / double(nLfoWavetable))),
Scales::bipolarScale, (lfoWavetableLabel + indexStr).c_str(), Info::kCanAutomate);
}
value[ID::lfoInterpolation] = std::make_unique<UIntValue>(
Expand Down
4 changes: 3 additions & 1 deletion ParallelDetune/source/parameter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#pragma once

#include <memory>
#include <numbers>
#include <string>
#include <vector>

Expand Down Expand Up @@ -185,7 +186,8 @@ struct GlobalParameter : public ParameterInterface {
for (size_t idx = 0; idx < nLfoWavetable; ++idx) {
auto indexStr = std::to_string(idx);
value[ID::lfoWavetable0 + idx] = std::make_unique<LinearValue>(
Scales::bipolarScale.invmap(sin(SomeDSP::twopi * idx / double(nLfoWavetable))),
Scales::bipolarScale.invmap(
sin(double(2) * std::numbers::pi_v<double> * idx / double(nLfoWavetable))),
Scales::bipolarScale, (lfoWavetableLabel + indexStr).c_str(), Info::kCanAutomate);
}
value[ID::lfoInterpolation] = std::make_unique<UIntValue>(
Expand Down
4 changes: 3 additions & 1 deletion PitchShiftDelay/source/parameter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#pragma once

#include <memory>
#include <numbers>
#include <string>
#include <vector>

Expand Down Expand Up @@ -117,7 +118,8 @@ struct GlobalParameter : public ParameterInterface {
for (size_t idx = 0; idx < nLfoWavetable; ++idx) {
auto indexStr = std::to_string(idx);
value[ID::lfoWavetable0 + idx] = std::make_unique<LinearValue>(
Scales::lfoWavetable.invmap(sin(SomeDSP::twopi * idx / double(nLfoWavetable))),
Scales::lfoWavetable.invmap(
std::sin(double(2) * std::numbers::pi_v<double> * idx / double(nLfoWavetable))),
Scales::lfoWavetable, (lfoWavetableLabel + indexStr).c_str(), Info::kCanAutomate);
}
value[ID::lfoTempoSync] = std::make_unique<UIntValue>(
Expand Down
13 changes: 7 additions & 6 deletions TestBedSynth/source/parameter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <array>
#include <memory>
#include <numbers>
#include <string>
#include <vector>

Expand Down Expand Up @@ -190,11 +191,11 @@ struct GlobalParameter : public ParameterInterface {

value[ID::osc0Waveform0 + idx] = std::make_unique<LinearValue>(
Scales::bipolarScale.invmap(
std::sin(SomeDSP::twopi * idx / double(nOscWavetable))),
std::sin(double(2) * std::numbers::pi_v<double> * idx / double(nOscWavetable))),
Scales::bipolarScale, ("lfo0Waveform" + indexStr).c_str(), Info::kCanAutomate);
value[ID::osc1Waveform0 + idx] = std::make_unique<LinearValue>(
Scales::bipolarScale.invmap(
std::sin(SomeDSP::twopi * idx / double(nOscWavetable))),
std::sin(double(2) * std::numbers::pi_v<double> * idx / double(nOscWavetable))),
Scales::bipolarScale, ("lfo1Waveform" + indexStr).c_str(), Info::kCanAutomate);
}

Expand Down Expand Up @@ -323,11 +324,11 @@ struct GlobalParameter : public ParameterInterface {

value[ID::lfo0Waveform0 + idx] = std::make_unique<LinearValue>(
Scales::bipolarScale.invmap(
std::sin(SomeDSP::twopi * idx / double(nLfoWavetable))),
std::sin(double(2) * std::numbers::pi_v<double> * idx / double(nLfoWavetable))),
Scales::bipolarScale, ("lfo0Waveform" + indexStr).c_str(), Info::kCanAutomate);
value[ID::lfo1Waveform0 + idx] = std::make_unique<LinearValue>(
Scales::bipolarScale.invmap(
std::sin(SomeDSP::twopi * idx / double(nLfoWavetable))),
std::sin(double(2) * std::numbers::pi_v<double> * idx / double(nLfoWavetable))),
Scales::bipolarScale, ("lfo1Waveform" + indexStr).c_str(), Info::kCanAutomate);
}

Expand Down Expand Up @@ -357,11 +358,11 @@ struct GlobalParameter : public ParameterInterface {

value[ID::waveMod0Gain0 + idx] = std::make_unique<LinearValue>(
Scales::bipolarScale.invmap(
std::sin(SomeDSP::twopi * idx / double(nLfoWavetable))),
std::sin(double(2) * std::numbers::pi_v<double> * idx / double(nLfoWavetable))),
Scales::bipolarScale, ("waveMod0Gain" + indexStr).c_str(), Info::kCanAutomate);
value[ID::waveMod1Gain0 + idx] = std::make_unique<LinearValue>(
Scales::bipolarScale.invmap(
std::sin(SomeDSP::twopi * idx / double(nLfoWavetable))),
std::sin(double(2) * std::numbers::pi_v<double> * idx / double(nLfoWavetable))),
Scales::bipolarScale, ("waveMod1Gain" + indexStr).c_str(), Info::kCanAutomate);
value[ID::waveMod0Delay0 + idx] = std::make_unique<UIntValue>(
idx / double(nLfoWavetable - 1), Scales::waveModDelay,
Expand Down
4 changes: 2 additions & 2 deletions common/dsp/scale.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ template<typename T> class SemitoneScale {
T getMin() { return minToZero ? 0 : minFreq; }
T getMax() { return maxFreq; }

inline T noteToFreq(T note) { return T(440) * std::exp2((note - 69) / T(12)); }
inline T freqToNote(T freq) { return T(69) + T(12) * std::log2(freq / T(440)); }
inline T noteToFreq(T note) const { return T(440) * std::exp2((note - 69) / T(12)); }
inline T freqToNote(T freq) const { return T(69) + T(12) * std::log2(freq / T(440)); }

protected:
bool minToZero;
Expand Down
Loading

0 comments on commit 4e0c8a8

Please sign in to comment.