From 8dad679dd05a8bbd9efd6b4bd2f35fb902133d28 Mon Sep 17 00:00:00 2001 From: Chris Robinson <chris.kcat@gmail.com> Date: Thu, 12 Oct 2023 05:14:00 -0700 Subject: Add convolution effect properties to rotate ambisonic responses --- al/effects/convolution.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'al/effects/convolution.cpp') diff --git a/al/effects/convolution.cpp b/al/effects/convolution.cpp index 8e850fd3..a9426ce4 100644 --- a/al/effects/convolution.cpp +++ b/al/effects/convolution.cpp @@ -83,6 +83,8 @@ void Convolution_getParamfv(const EffectProps *props, ALenum param, float *vals) EffectProps genDefaultProps() noexcept { EffectProps props{}; + props.Convolution.OrientAt = {0.0f, 0.0f, -1.0f}; + props.Convolution.OrientUp = {0.0f, 1.0f, 0.0f}; return props; } -- cgit v1.2.3 From d1acb001a5c4779d382838fb02660ba9aa10e4cc Mon Sep 17 00:00:00 2001 From: Chris Robinson <chris.kcat@gmail.com> Date: Thu, 12 Oct 2023 06:28:12 -0700 Subject: Add an orientation property for convolution reverb Only affects ambisonic (B-Format and UHJ) formats --- al/effects/convolution.cpp | 30 ++++++++++++++++++++++++++---- alc/inprogext.h | 3 ++- 2 files changed, 28 insertions(+), 5 deletions(-) (limited to 'al/effects/convolution.cpp') diff --git a/al/effects/convolution.cpp b/al/effects/convolution.cpp index a9426ce4..494950b7 100644 --- a/al/effects/convolution.cpp +++ b/al/effects/convolution.cpp @@ -36,12 +36,25 @@ void Convolution_setParamf(EffectProps* /*props*/, ALenum param, float /*val*/) param}; } } -void Convolution_setParamfv(EffectProps *props, ALenum param, const float *vals) +void Convolution_setParamfv(EffectProps *props, ALenum param, const float *values) { switch(param) { + case AL_CONVOLUTION_REVERB_ORIENTATION_SOFT: + if(!(std::isfinite(values[0]) && std::isfinite(values[1]) && std::isfinite(values[2]) + && std::isfinite(values[3]) && std::isfinite(values[4]) && std::isfinite(values[5]))) + throw effect_exception{AL_INVALID_VALUE, "Property 0x%04x value out of range", param}; + + props->Convolution.OrientAt[0] = values[0]; + props->Convolution.OrientAt[1] = values[1]; + props->Convolution.OrientAt[2] = values[2]; + props->Convolution.OrientUp[0] = values[3]; + props->Convolution.OrientUp[1] = values[4]; + props->Convolution.OrientUp[2] = values[5]; + break; + default: - Convolution_setParamf(props, param, vals[0]); + Convolution_setParamf(props, param, values[0]); } } @@ -71,12 +84,21 @@ void Convolution_getParamf(const EffectProps* /*props*/, ALenum param, float* /* param}; } } -void Convolution_getParamfv(const EffectProps *props, ALenum param, float *vals) +void Convolution_getParamfv(const EffectProps *props, ALenum param, float *values) { switch(param) { + case AL_CONVOLUTION_REVERB_ORIENTATION_SOFT: + values[0] = props->Convolution.OrientAt[0]; + values[1] = props->Convolution.OrientAt[1]; + values[2] = props->Convolution.OrientAt[2]; + values[3] = props->Convolution.OrientUp[0]; + values[4] = props->Convolution.OrientUp[1]; + values[5] = props->Convolution.OrientUp[2]; + break; + default: - Convolution_getParamf(props, param, vals); + Convolution_getParamf(props, param, values); } } diff --git a/alc/inprogext.h b/alc/inprogext.h index 2fa425bb..a595721d 100644 --- a/alc/inprogext.h +++ b/alc/inprogext.h @@ -44,7 +44,8 @@ void AL_APIENTRY alFlushMappedBufferDirectSOFT(ALCcontext *context, ALuint buffe #ifndef AL_SOFT_convolution_reverb #define AL_SOFT_convolution_reverb #define AL_EFFECT_CONVOLUTION_REVERB_SOFT 0xA000 -#define AL_EFFECTSLOT_STATE_SOFT 0x199D +#define AL_CONVOLUTION_REVERB_ORIENTATION_SOFT 0x100F /* same as AL_ORIENTATION */ +#define AL_EFFECTSLOT_STATE_SOFT 0x199E typedef void (AL_APIENTRY*LPALAUXILIARYEFFECTSLOTPLAYSOFT)(ALuint slotid) AL_API_NOEXCEPT17; typedef void (AL_APIENTRY*LPALAUXILIARYEFFECTSLOTPLAYVSOFT)(ALsizei n, const ALuint *slotids) AL_API_NOEXCEPT17; typedef void (AL_APIENTRY*LPALAUXILIARYEFFECTSLOTSTOPSOFT)(ALuint slotid) AL_API_NOEXCEPT17; -- cgit v1.2.3 From 5b86b80591ce85869716885ca393e080f6f72685 Mon Sep 17 00:00:00 2001 From: Chris Robinson <chris.kcat@gmail.com> Date: Thu, 12 Oct 2023 06:42:32 -0700 Subject: Rename the convolution reverb effect to just convolution While the common use case, convolution can do more than just reverb, and it nicely shortens the name. --- al/auxeffectslot.cpp | 2 +- al/effect.cpp | 4 ++-- al/effects/convolution.cpp | 4 ++-- alc/context.cpp | 2 +- alc/export_list.h | 2 +- alc/inprogext.h | 8 ++++---- examples/alconvolve.c | 32 ++++++++++++++++---------------- 7 files changed, 27 insertions(+), 27 deletions(-) (limited to 'al/effects/convolution.cpp') diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp index 33252410..fb646389 100644 --- a/al/auxeffectslot.cpp +++ b/al/auxeffectslot.cpp @@ -230,7 +230,7 @@ EffectSlotType EffectSlotTypeFromEnum(ALenum type) case AL_EFFECT_EAXREVERB: return EffectSlotType::EAXReverb; case AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT: return EffectSlotType::DedicatedLFE; case AL_EFFECT_DEDICATED_DIALOGUE: return EffectSlotType::DedicatedDialog; - case AL_EFFECT_CONVOLUTION_REVERB_SOFT: return EffectSlotType::Convolution; + case AL_EFFECT_CONVOLUTION_SOFT: return EffectSlotType::Convolution; } ERR("Unhandled effect enum: 0x%04x\n", type); return EffectSlotType::None; diff --git a/al/effect.cpp b/al/effect.cpp index c4b06407..3e48e91b 100644 --- a/al/effect.cpp +++ b/al/effect.cpp @@ -74,7 +74,7 @@ const EffectList gEffectList[16]{ { "vmorpher", VMORPHER_EFFECT, AL_EFFECT_VOCAL_MORPHER }, { "dedicated", DEDICATED_EFFECT, AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT }, { "dedicated", DEDICATED_EFFECT, AL_EFFECT_DEDICATED_DIALOGUE }, - { "convolution", CONVOLUTION_EFFECT, AL_EFFECT_CONVOLUTION_REVERB_SOFT }, + { "convolution", CONVOLUTION_EFFECT, AL_EFFECT_CONVOLUTION_SOFT }, }; bool DisabledEffects[MAX_EFFECTS]; @@ -113,7 +113,7 @@ constexpr EffectPropsItem EffectPropsList[] = { { AL_EFFECT_VOCAL_MORPHER, VmorpherEffectProps, VmorpherEffectVtable }, { AL_EFFECT_DEDICATED_DIALOGUE, DedicatedEffectProps, DedicatedEffectVtable }, { AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT, DedicatedEffectProps, DedicatedEffectVtable }, - { AL_EFFECT_CONVOLUTION_REVERB_SOFT, ConvolutionEffectProps, ConvolutionEffectVtable }, + { AL_EFFECT_CONVOLUTION_SOFT, ConvolutionEffectProps, ConvolutionEffectVtable }, }; diff --git a/al/effects/convolution.cpp b/al/effects/convolution.cpp index 494950b7..3e7885f8 100644 --- a/al/effects/convolution.cpp +++ b/al/effects/convolution.cpp @@ -40,7 +40,7 @@ void Convolution_setParamfv(EffectProps *props, ALenum param, const float *value { switch(param) { - case AL_CONVOLUTION_REVERB_ORIENTATION_SOFT: + case AL_CONVOLUTION_ORIENTATION_SOFT: if(!(std::isfinite(values[0]) && std::isfinite(values[1]) && std::isfinite(values[2]) && std::isfinite(values[3]) && std::isfinite(values[4]) && std::isfinite(values[5]))) throw effect_exception{AL_INVALID_VALUE, "Property 0x%04x value out of range", param}; @@ -88,7 +88,7 @@ void Convolution_getParamfv(const EffectProps *props, ALenum param, float *value { switch(param) { - case AL_CONVOLUTION_REVERB_ORIENTATION_SOFT: + case AL_CONVOLUTION_ORIENTATION_SOFT: values[0] = props->Convolution.OrientAt[0]; values[1] = props->Convolution.OrientAt[1]; values[2] = props->Convolution.OrientAt[2]; diff --git a/alc/context.cpp b/alc/context.cpp index 8c930056..ffc2743e 100644 --- a/alc/context.cpp +++ b/alc/context.cpp @@ -75,7 +75,7 @@ std::vector<std::string_view> getContextExtensions() noexcept "AL_SOFT_block_alignment", "AL_SOFT_buffer_length_query", "AL_SOFT_callback_buffer", - "AL_SOFTX_convolution_reverb", + "AL_SOFTX_convolution_effect", "AL_SOFT_deferred_updates", "AL_SOFT_direct_channels", "AL_SOFT_direct_channels_remix", diff --git a/alc/export_list.h b/alc/export_list.h index cefe7a09..2ef0d777 100644 --- a/alc/export_list.h +++ b/alc/export_list.h @@ -820,7 +820,7 @@ inline const EnumExport alcEnumerations[]{ DECL(AL_UNPACK_AMBISONIC_ORDER_SOFT), - DECL(AL_EFFECT_CONVOLUTION_REVERB_SOFT), + DECL(AL_EFFECT_CONVOLUTION_SOFT), DECL(AL_EFFECTSLOT_STATE_SOFT), DECL(AL_FORMAT_UHJ2CHN8_SOFT), diff --git a/alc/inprogext.h b/alc/inprogext.h index a595721d..a145b8e4 100644 --- a/alc/inprogext.h +++ b/alc/inprogext.h @@ -41,10 +41,10 @@ void AL_APIENTRY alFlushMappedBufferDirectSOFT(ALCcontext *context, ALuint buffe #define AL_UNPACK_AMBISONIC_ORDER_SOFT 0x199D #endif -#ifndef AL_SOFT_convolution_reverb -#define AL_SOFT_convolution_reverb -#define AL_EFFECT_CONVOLUTION_REVERB_SOFT 0xA000 -#define AL_CONVOLUTION_REVERB_ORIENTATION_SOFT 0x100F /* same as AL_ORIENTATION */ +#ifndef AL_SOFT_convolution_effect +#define AL_SOFT_convolution_effect +#define AL_EFFECT_CONVOLUTION_SOFT 0xA000 +#define AL_CONVOLUTION_ORIENTATION_SOFT 0x100F /* same as AL_ORIENTATION */ #define AL_EFFECTSLOT_STATE_SOFT 0x199E typedef void (AL_APIENTRY*LPALAUXILIARYEFFECTSLOTPLAYSOFT)(ALuint slotid) AL_API_NOEXCEPT17; typedef void (AL_APIENTRY*LPALAUXILIARYEFFECTSLOTPLAYVSOFT)(ALsizei n, const ALuint *slotids) AL_API_NOEXCEPT17; diff --git a/examples/alconvolve.c b/examples/alconvolve.c index 94b978b5..8580d443 100644 --- a/examples/alconvolve.c +++ b/examples/alconvolve.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -/* This file contains an example for applying convolution reverb to a source. */ +/* This file contains an example for applying convolution to a source. */ #include <assert.h> #include <inttypes.h> @@ -39,9 +39,9 @@ #include "common/alhelpers.h" -#ifndef AL_SOFT_convolution_reverb -#define AL_SOFT_convolution_reverb -#define AL_EFFECT_CONVOLUTION_REVERB_SOFT 0xA000 +#ifndef AL_SOFT_convolution_effect +#define AL_SOFT_convolution_effect +#define AL_EFFECT_CONVOLUTION_SOFT 0xA000 #endif @@ -278,19 +278,19 @@ static int UpdatePlayer(StreamPlayer *player) } -/* CreateEffect creates a new OpenAL effect object with a convolution reverb - * type, and returns the new effect ID. +/* CreateEffect creates a new OpenAL effect object with a convolution type, and + * returns the new effect ID. */ static ALuint CreateEffect(void) { ALuint effect = 0; ALenum err; - printf("Using Convolution Reverb\n"); + printf("Using Convolution\n"); - /* Create the effect object and set the convolution reverb effect type. */ + /* Create the effect object and set the convolution effect type. */ alGenEffects(1, &effect); - alEffecti(effect, AL_EFFECT_TYPE, AL_EFFECT_CONVOLUTION_REVERB_SOFT); + alEffecti(effect, AL_EFFECT_TYPE, AL_EFFECT_CONVOLUTION_SOFT); /* Check if an error occurred, and clean up if so. */ err = alGetError(); @@ -423,10 +423,10 @@ int main(int argc, char **argv) if(InitAL(&argv, &argc) != 0) return 1; - if(!alIsExtensionPresent("AL_SOFTX_convolution_reverb")) + if(!alIsExtensionPresent("AL_SOFTX_convolution_effect")) { CloseAL(); - fprintf(stderr, "Error: Convolution revern not supported\n"); + fprintf(stderr, "Error: Convolution effect not supported\n"); return 1; } @@ -500,11 +500,11 @@ int main(int argc, char **argv) alGenAuxiliaryEffectSlots(1, &slot); /* Set the impulse response sound buffer on the effect slot. This allows - * effects to access it as needed. In this case, convolution reverb uses it - * as the filter source. NOTE: Unlike the effect object, the buffer *is* - * kept referenced and may not be changed or deleted as long as it's set, - * just like with a source. When another buffer is set, or the effect slot - * is deleted, the buffer reference is released. + * effects to access it as needed. In this case, convolution uses it as the + * filter source. NOTE: Unlike the effect object, the buffer *is* kept + * referenced and may not be changed or deleted as long as it's set, just + * like with a source. When another buffer is set, or the effect slot is + * deleted, the buffer reference is released. * * The effect slot's gain is reduced because the impulse responses I've * tested with result in excessively loud reverb. Is that normal? Even with -- cgit v1.2.3 From c7ce77634ffeb9dc84c4435aed3dac59b042bfbd Mon Sep 17 00:00:00 2001 From: Chris Robinson <chris.kcat@gmail.com> Date: Thu, 12 Oct 2023 07:03:21 -0700 Subject: Add missing include --- al/effects/convolution.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'al/effects/convolution.cpp') diff --git a/al/effects/convolution.cpp b/al/effects/convolution.cpp index 3e7885f8..9c091e53 100644 --- a/al/effects/convolution.cpp +++ b/al/effects/convolution.cpp @@ -1,6 +1,8 @@ #include "config.h" +#include <cmath> + #include "AL/al.h" #include "alc/inprogext.h" -- cgit v1.2.3