Skip to content

Commit

Permalink
Make some functions constexpr
Browse files Browse the repository at this point in the history
  • Loading branch information
kcat committed Jan 15, 2024
1 parent 6ce391e commit 92b9a40
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion al/effects/autowah.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace {

EffectProps genDefaultProps() noexcept
constexpr EffectProps genDefaultProps() noexcept
{
AutowahProps props{};
props.AttackTime = AL_AUTOWAH_DEFAULT_ATTACK_TIME;
Expand Down
8 changes: 4 additions & 4 deletions al/effects/chorus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static_assert(FlangerMaxDelay >= AL_FLANGER_MAX_DELAY, "Flanger max delay too sm
static_assert(AL_CHORUS_WAVEFORM_SINUSOID == AL_FLANGER_WAVEFORM_SINUSOID, "Chorus/Flanger waveform value mismatch");
static_assert(AL_CHORUS_WAVEFORM_TRIANGLE == AL_FLANGER_WAVEFORM_TRIANGLE, "Chorus/Flanger waveform value mismatch");

inline std::optional<ChorusWaveform> WaveformFromEnum(ALenum type)
constexpr std::optional<ChorusWaveform> WaveformFromEnum(ALenum type) noexcept
{
switch(type)
{
Expand All @@ -36,7 +36,7 @@ inline std::optional<ChorusWaveform> WaveformFromEnum(ALenum type)
}
return std::nullopt;
}
inline ALenum EnumFromWaveform(ChorusWaveform type)
constexpr ALenum EnumFromWaveform(ChorusWaveform type)
{
switch(type)
{
Expand All @@ -46,7 +46,7 @@ inline ALenum EnumFromWaveform(ChorusWaveform type)
throw std::runtime_error{"Invalid chorus waveform: "+std::to_string(static_cast<int>(type))};
}

EffectProps genDefaultChorusProps() noexcept
constexpr EffectProps genDefaultChorusProps() noexcept
{
ChorusProps props{};
props.Waveform = WaveformFromEnum(AL_CHORUS_DEFAULT_WAVEFORM).value();
Expand All @@ -58,7 +58,7 @@ EffectProps genDefaultChorusProps() noexcept
return props;
}

EffectProps genDefaultFlangerProps() noexcept
constexpr EffectProps genDefaultFlangerProps() noexcept
{
FlangerProps props{};
props.Waveform = WaveformFromEnum(AL_FLANGER_DEFAULT_WAVEFORM).value();
Expand Down
2 changes: 1 addition & 1 deletion al/effects/compressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace {

EffectProps genDefaultProps() noexcept
constexpr EffectProps genDefaultProps() noexcept
{
CompressorProps props{};
props.OnOff = AL_COMPRESSOR_DEFAULT_ONOFF;
Expand Down
2 changes: 1 addition & 1 deletion al/effects/convolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace {

EffectProps genDefaultProps() noexcept
constexpr EffectProps genDefaultProps() noexcept
{
ConvolutionProps props{};
props.OrientAt = {0.0f, 0.0f, -1.0f};
Expand Down
4 changes: 2 additions & 2 deletions al/effects/dedicated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@

namespace {

EffectProps genDefaultDialogProps() noexcept
constexpr EffectProps genDefaultDialogProps() noexcept
{
DedicatedDialogProps props{};
props.Gain = 1.0f;
return props;
}

EffectProps genDefaultLfeProps() noexcept
constexpr EffectProps genDefaultLfeProps() noexcept
{
DedicatedLfeProps props{};
props.Gain = 1.0f;
Expand Down
2 changes: 1 addition & 1 deletion al/effects/distortion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace {

EffectProps genDefaultProps() noexcept
constexpr EffectProps genDefaultProps() noexcept
{
DistortionProps props{};
props.Edge = AL_DISTORTION_DEFAULT_EDGE;
Expand Down
2 changes: 1 addition & 1 deletion al/effects/echo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace {
static_assert(EchoMaxDelay >= AL_ECHO_MAX_DELAY, "Echo max delay too short");
static_assert(EchoMaxLRDelay >= AL_ECHO_MAX_LRDELAY, "Echo max left-right delay too short");

EffectProps genDefaultProps() noexcept
constexpr EffectProps genDefaultProps() noexcept
{
EchoProps props{};
props.Delay = AL_ECHO_DEFAULT_DELAY;
Expand Down
2 changes: 1 addition & 1 deletion al/effects/equalizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace {

EffectProps genDefaultProps() noexcept
constexpr EffectProps genDefaultProps() noexcept
{
EqualizerProps props{};
props.LowCutoff = AL_EQUALIZER_DEFAULT_LOW_CUTOFF;
Expand Down
6 changes: 3 additions & 3 deletions al/effects/fshifter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace {

std::optional<FShifterDirection> DirectionFromEmum(ALenum value)
constexpr std::optional<FShifterDirection> DirectionFromEmum(ALenum value) noexcept
{
switch(value)
{
Expand All @@ -30,7 +30,7 @@ std::optional<FShifterDirection> DirectionFromEmum(ALenum value)
}
return std::nullopt;
}
ALenum EnumFromDirection(FShifterDirection dir)
constexpr ALenum EnumFromDirection(FShifterDirection dir)
{
switch(dir)
{
Expand All @@ -41,7 +41,7 @@ ALenum EnumFromDirection(FShifterDirection dir)
throw std::runtime_error{"Invalid direction: "+std::to_string(static_cast<int>(dir))};
}

EffectProps genDefaultProps() noexcept
constexpr EffectProps genDefaultProps() noexcept
{
FshifterProps props{};
props.Frequency = AL_FREQUENCY_SHIFTER_DEFAULT_FREQUENCY;
Expand Down
6 changes: 3 additions & 3 deletions al/effects/modulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace {

std::optional<ModulatorWaveform> WaveformFromEmum(ALenum value)
constexpr std::optional<ModulatorWaveform> WaveformFromEmum(ALenum value) noexcept
{
switch(value)
{
Expand All @@ -30,7 +30,7 @@ std::optional<ModulatorWaveform> WaveformFromEmum(ALenum value)
}
return std::nullopt;
}
ALenum EnumFromWaveform(ModulatorWaveform type)
constexpr ALenum EnumFromWaveform(ModulatorWaveform type)
{
switch(type)
{
Expand All @@ -42,7 +42,7 @@ ALenum EnumFromWaveform(ModulatorWaveform type)
std::to_string(static_cast<int>(type))};
}

EffectProps genDefaultProps() noexcept
constexpr EffectProps genDefaultProps() noexcept
{
ModulatorProps props{};
props.Frequency = AL_RING_MODULATOR_DEFAULT_FREQUENCY;
Expand Down
2 changes: 1 addition & 1 deletion al/effects/null.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace {

EffectProps genDefaultProps() noexcept
constexpr EffectProps genDefaultProps() noexcept
{
EffectProps props{};
return props;
Expand Down
2 changes: 1 addition & 1 deletion al/effects/pshifter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace {

EffectProps genDefaultProps() noexcept
constexpr EffectProps genDefaultProps() noexcept
{
PshifterProps props{};
props.CoarseTune = AL_PITCH_SHIFTER_DEFAULT_COARSE_TUNE;
Expand Down
4 changes: 2 additions & 2 deletions al/effects/reverb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace {

EffectProps genDefaultProps() noexcept
constexpr EffectProps genDefaultProps() noexcept
{
ReverbProps props{};
props.Density = AL_EAXREVERB_DEFAULT_DENSITY;
Expand Down Expand Up @@ -53,7 +53,7 @@ EffectProps genDefaultProps() noexcept
return props;
}

EffectProps genDefaultStdProps() noexcept
constexpr EffectProps genDefaultStdProps() noexcept
{
ReverbProps props{};
props.Density = AL_REVERB_DEFAULT_DENSITY;
Expand Down
10 changes: 5 additions & 5 deletions al/effects/vmorpher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace {

std::optional<VMorpherPhenome> PhenomeFromEnum(ALenum val)
constexpr std::optional<VMorpherPhenome> PhenomeFromEnum(ALenum val) noexcept
{
#define HANDLE_PHENOME(x) case AL_VOCAL_MORPHER_PHONEME_ ## x: \
return VMorpherPhenome::x
Expand Down Expand Up @@ -60,7 +60,7 @@ std::optional<VMorpherPhenome> PhenomeFromEnum(ALenum val)
return std::nullopt;
#undef HANDLE_PHENOME
}
ALenum EnumFromPhenome(VMorpherPhenome phenome)
constexpr ALenum EnumFromPhenome(VMorpherPhenome phenome)
{
#define HANDLE_PHENOME(x) case VMorpherPhenome::x: return AL_VOCAL_MORPHER_PHONEME_ ## x
switch(phenome)
Expand Down Expand Up @@ -100,7 +100,7 @@ ALenum EnumFromPhenome(VMorpherPhenome phenome)
#undef HANDLE_PHENOME
}

std::optional<VMorpherWaveform> WaveformFromEmum(ALenum value)
constexpr std::optional<VMorpherWaveform> WaveformFromEmum(ALenum value) noexcept
{
switch(value)
{
Expand All @@ -110,7 +110,7 @@ std::optional<VMorpherWaveform> WaveformFromEmum(ALenum value)
}
return std::nullopt;
}
ALenum EnumFromWaveform(VMorpherWaveform type)
constexpr ALenum EnumFromWaveform(VMorpherWaveform type)
{
switch(type)
{
Expand All @@ -122,7 +122,7 @@ ALenum EnumFromWaveform(VMorpherWaveform type)
std::to_string(static_cast<int>(type))};
}

EffectProps genDefaultProps() noexcept
constexpr EffectProps genDefaultProps() noexcept
{
VmorpherProps props{};
props.Rate = AL_VOCAL_MORPHER_DEFAULT_RATE;
Expand Down

0 comments on commit 92b9a40

Please sign in to comment.