aboutsummaryrefslogtreecommitdiffstats
path: root/alc/effects/vmorpher.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-12-21 21:11:25 -0800
committerChris Robinson <[email protected]>2020-12-24 22:49:55 -0800
commit0d3b041aa25cefb16b6ef2e5d0ad0a2f93986a92 (patch)
treef8988a7f43dea7bf4df48c4e6b2ca7e5f431da46 /alc/effects/vmorpher.cpp
parenteedc42890fa1358a6639051a39f7e73f8d4d3b07 (diff)
Avoid AL types and enums in the effect processors
Diffstat (limited to 'alc/effects/vmorpher.cpp')
-rw-r--r--alc/effects/vmorpher.cpp50
1 files changed, 27 insertions, 23 deletions
diff --git a/alc/effects/vmorpher.cpp b/alc/effects/vmorpher.cpp
index d8c71d16..aade1ea0 100644
--- a/alc/effects/vmorpher.cpp
+++ b/alc/effects/vmorpher.cpp
@@ -25,10 +25,10 @@
#include <algorithm>
#include <functional>
-#include "al/auxeffectslot.h"
#include "alcmain.h"
#include "alcontext.h"
#include "alu.h"
+#include "effectslot.h"
namespace {
@@ -44,22 +44,22 @@ namespace {
#define WAVEFORM_FRACONE (1<<WAVEFORM_FRACBITS)
#define WAVEFORM_FRACMASK (WAVEFORM_FRACONE-1)
-inline float Sin(ALuint index)
+inline float Sin(uint index)
{
constexpr float scale{al::MathDefs<float>::Tau() / WAVEFORM_FRACONE};
return std::sin(static_cast<float>(index) * scale)*0.5f + 0.5f;
}
-inline float Saw(ALuint index)
+inline float Saw(uint index)
{ return static_cast<float>(index) / float{WAVEFORM_FRACONE}; }
-inline float Triangle(ALuint index)
+inline float Triangle(uint index)
{ return std::fabs(static_cast<float>(index)*(2.0f/WAVEFORM_FRACONE) - 1.0f); }
-inline float Half(ALuint) { return 0.5f; }
+inline float Half(uint) { return 0.5f; }
-template<float (&func)(ALuint)>
-void Oscillate(float *RESTRICT dst, ALuint index, const ALuint step, size_t todo)
+template<float (&func)(uint)>
+void Oscillate(float *RESTRICT dst, uint index, const uint step, size_t todo)
{
for(size_t i{0u};i < todo;i++)
{
@@ -126,10 +126,10 @@ struct VmorpherState final : public EffectState {
float TargetGains[MAX_OUTPUT_CHANNELS]{};
} mChans[MaxAmbiChannels];
- void (*mGetSamples)(float*RESTRICT, ALuint, const ALuint, size_t){};
+ void (*mGetSamples)(float*RESTRICT, uint, const uint, size_t){};
- ALuint mIndex{0};
- ALuint mStep{1};
+ uint mIndex{0};
+ uint mStep{1};
/* Effects buffers */
alignas(16) float mSampleBufferA[MAX_UPDATE_SAMPLES]{};
@@ -142,12 +142,14 @@ struct VmorpherState final : public EffectState {
void process(const size_t samplesToDo, const al::span<const FloatBufferLine> samplesIn,
const al::span<FloatBufferLine> samplesOut) override;
- static std::array<FormantFilter,4> getFiltersByPhoneme(ALenum phoneme, float frequency, float pitch);
+ static std::array<FormantFilter,4> getFiltersByPhoneme(VMorpherPhenome phoneme,
+ float frequency, float pitch);
DEF_NEWDEL(VmorpherState)
};
-std::array<FormantFilter,4> VmorpherState::getFiltersByPhoneme(ALenum phoneme, float frequency, float pitch)
+std::array<FormantFilter,4> VmorpherState::getFiltersByPhoneme(VMorpherPhenome phoneme,
+ float frequency, float pitch)
{
/* Using soprano formant set of values to
* better match mid-range frequency space.
@@ -156,41 +158,43 @@ std::array<FormantFilter,4> VmorpherState::getFiltersByPhoneme(ALenum phoneme, f
*/
switch(phoneme)
{
- case AL_VOCAL_MORPHER_PHONEME_A:
+ case VMorpherPhenome::A:
return {{
{( 800 * pitch) / frequency, 1.000000f}, /* std::pow(10.0f, 0 / 20.0f); */
{(1150 * pitch) / frequency, 0.501187f}, /* std::pow(10.0f, -6 / 20.0f); */
{(2900 * pitch) / frequency, 0.025118f}, /* std::pow(10.0f, -32 / 20.0f); */
{(3900 * pitch) / frequency, 0.100000f} /* std::pow(10.0f, -20 / 20.0f); */
}};
- case AL_VOCAL_MORPHER_PHONEME_E:
+ case VMorpherPhenome::E:
return {{
{( 350 * pitch) / frequency, 1.000000f}, /* std::pow(10.0f, 0 / 20.0f); */
{(2000 * pitch) / frequency, 0.100000f}, /* std::pow(10.0f, -20 / 20.0f); */
{(2800 * pitch) / frequency, 0.177827f}, /* std::pow(10.0f, -15 / 20.0f); */
{(3600 * pitch) / frequency, 0.009999f} /* std::pow(10.0f, -40 / 20.0f); */
}};
- case AL_VOCAL_MORPHER_PHONEME_I:
+ case VMorpherPhenome::I:
return {{
{( 270 * pitch) / frequency, 1.000000f}, /* std::pow(10.0f, 0 / 20.0f); */
{(2140 * pitch) / frequency, 0.251188f}, /* std::pow(10.0f, -12 / 20.0f); */
{(2950 * pitch) / frequency, 0.050118f}, /* std::pow(10.0f, -26 / 20.0f); */
{(3900 * pitch) / frequency, 0.050118f} /* std::pow(10.0f, -26 / 20.0f); */
}};
- case AL_VOCAL_MORPHER_PHONEME_O:
+ case VMorpherPhenome::O:
return {{
{( 450 * pitch) / frequency, 1.000000f}, /* std::pow(10.0f, 0 / 20.0f); */
{( 800 * pitch) / frequency, 0.281838f}, /* std::pow(10.0f, -11 / 20.0f); */
{(2830 * pitch) / frequency, 0.079432f}, /* std::pow(10.0f, -22 / 20.0f); */
{(3800 * pitch) / frequency, 0.079432f} /* std::pow(10.0f, -22 / 20.0f); */
}};
- case AL_VOCAL_MORPHER_PHONEME_U:
+ case VMorpherPhenome::U:
return {{
{( 325 * pitch) / frequency, 1.000000f}, /* std::pow(10.0f, 0 / 20.0f); */
{( 700 * pitch) / frequency, 0.158489f}, /* std::pow(10.0f, -16 / 20.0f); */
{(2700 * pitch) / frequency, 0.017782f}, /* std::pow(10.0f, -35 / 20.0f); */
{(3800 * pitch) / frequency, 0.009999f} /* std::pow(10.0f, -40 / 20.0f); */
}};
+ default:
+ break;
}
return {};
}
@@ -218,12 +222,12 @@ void VmorpherState::update(const ALCcontext *context, const EffectSlot *slot,
if(mStep == 0)
mGetSamples = Oscillate<Half>;
- else if(props->Vmorpher.Waveform == AL_VOCAL_MORPHER_WAVEFORM_SINUSOID)
+ else if(props->Vmorpher.Waveform == VMorpherWaveform::Sinusoid)
mGetSamples = Oscillate<Sin>;
- else if(props->Vmorpher.Waveform == AL_VOCAL_MORPHER_WAVEFORM_SAWTOOTH)
- mGetSamples = Oscillate<Saw>;
- else /*if(props->Vmorpher.Waveform == AL_VOCAL_MORPHER_WAVEFORM_TRIANGLE)*/
+ else if(props->Vmorpher.Waveform == VMorpherWaveform::Triangle)
mGetSamples = Oscillate<Triangle>;
+ else /*if(props->Vmorpher.Waveform == VMorpherWaveform::Sawtooth)*/
+ mGetSamples = Oscillate<Saw>;
const float pitchA{std::pow(2.0f,
static_cast<float>(props->Vmorpher.PhonemeACoarseTuning) / 12.0f)};
@@ -256,10 +260,10 @@ void VmorpherState::process(const size_t samplesToDo, const al::span<const Float
const size_t td{minz(MAX_UPDATE_SAMPLES, samplesToDo-base)};
mGetSamples(mLfo, mIndex, mStep, td);
- mIndex += static_cast<ALuint>(mStep * td);
+ mIndex += static_cast<uint>(mStep * td);
mIndex &= WAVEFORM_FRACMASK;
- auto chandata = std::addressof(mChans[0]);
+ auto chandata = std::begin(mChans);
for(const auto &input : samplesIn)
{
auto& vowelA = chandata->Formants[VOWEL_A_INDEX];