aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/effects
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-05-25 08:17:37 -0700
committerChris Robinson <[email protected]>2019-05-25 08:17:37 -0700
commitebf33b7c6b747b647eb2177080dc6f46db89867b (patch)
tree8956a70fe8b3153624129172c12ac12fffa603f3 /Alc/effects
parent219f818b165d6997d6a2f1f8f0c5f88ba68a5db2 (diff)
Avoid some uses of RESTRICT
Diffstat (limited to 'Alc/effects')
-rw-r--r--Alc/effects/chorus.cpp45
1 files changed, 27 insertions, 18 deletions
diff --git a/Alc/effects/chorus.cpp b/Alc/effects/chorus.cpp
index 74b46a10..d12d2484 100644
--- a/Alc/effects/chorus.cpp
+++ b/Alc/effects/chorus.cpp
@@ -44,28 +44,37 @@ enum class WaveForm {
Triangle
};
-void GetTriangleDelays(ALint *delays, ALsizei offset, ALsizei lfo_range, ALfloat lfo_scale,
- ALfloat depth, ALsizei delay, ALsizei todo)
+void GetTriangleDelays(ALint *delays, const ALsizei start_offset, const ALsizei lfo_range,
+ const ALfloat lfo_scale, const ALfloat depth, const ALsizei delay, const ALsizei todo)
{
- std::generate_n<ALint*RESTRICT>(delays, todo,
- [&offset,lfo_range,lfo_scale,depth,delay]() -> ALint
- {
- offset = (offset+1)%lfo_range;
- return fastf2i((1.0f - std::abs(2.0f - lfo_scale*offset)) * depth) + delay;
- }
- );
+ ASSUME(start_offset >= 0);
+ ASSUME(lfo_range > 0);
+ ASSUME(todo > 0);
+
+ ALsizei offset{start_offset};
+ auto gen_lfo = [&offset,lfo_range,lfo_scale,depth,delay]() -> ALint
+ {
+ offset = (offset+1)%lfo_range;
+ return fastf2i((1.0f - std::abs(2.0f - lfo_scale*offset)) * depth) + delay;
+ };
+ std::generate_n(delays, todo, gen_lfo);
}
-void GetSinusoidDelays(ALint *delays, ALsizei offset, ALsizei lfo_range, ALfloat lfo_scale,
- ALfloat depth, ALsizei delay, ALsizei todo)
+void GetSinusoidDelays(ALint *delays, const ALsizei start_offset, const ALsizei lfo_range,
+ const ALfloat lfo_scale, const ALfloat depth, const ALsizei delay, const ALsizei todo)
{
- std::generate_n<ALint*RESTRICT>(delays, todo,
- [&offset,lfo_range,lfo_scale,depth,delay]() -> ALint
- {
- offset = (offset+1)%lfo_range;
- return fastf2i(std::sin(lfo_scale*offset) * depth) + delay;
- }
- );
+ ASSUME(start_offset >= 0);
+ ASSUME(lfo_range > 0);
+ ASSUME(todo > 0);
+
+ ALsizei offset{start_offset};
+ auto gen_lfo = [&offset,lfo_range,lfo_scale,depth,delay]() -> ALint
+ {
+ ASSUME(delay >= 0);
+ offset = (offset+1)%lfo_range;
+ return fastf2i(std::sin(lfo_scale*offset) * depth) + delay;
+ };
+ std::generate_n(delays, todo, gen_lfo);
}
struct ChorusState final : public EffectState {