From 63526834f0fabb944c94a4a9c77704022f4ae9b4 Mon Sep 17 00:00:00 2001 From: Jrius <2261279+Jrius@users.noreply.github.com> Date: Sun, 30 May 2021 19:19:41 +0200 Subject: [PATCH] Add reverb option to sound emitters. Rename EAXReverbProperties. --- korman/properties/modifiers/region.py | 10 +++++----- korman/properties/modifiers/sound.py | 25 +++++++++++++++++++++++++ korman/ui/modifiers/sound.py | 8 ++++++++ 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/korman/properties/modifiers/region.py b/korman/properties/modifiers/region.py index dd4fa59..73eb95c 100644 --- a/korman/properties/modifiers/region.py +++ b/korman/properties/modifiers/region.py @@ -402,7 +402,7 @@ class PlasmaReverbRegion(PlasmaModifierProperties): eax_listener.softRegion = bo.plasma_modifiers.softvolume.get_key(exporter, so) if self.preset == "CUSTOM": # Someone's feeling exceedingly confident today... - props = EaxReverbProperties() + props = EAXReverbProperties() props.environment = 26 props.environmentSize = self.environment_size props.environmentDiffusion = self.environment_diffusion @@ -425,13 +425,13 @@ class PlasmaReverbRegion(PlasmaModifierProperties): props.lfReference = self.lf_reference flags = 0 for flag in self.flags: - flags |= getattr(EaxReverbProperties, flag) + flags |= getattr(EAXReverbProperties, flag) props.flags = flags eax_listener.listenerProps = props elif self.preset == "MORE": - eax_listener.listenerProps = getattr(EaxReverbProperties, "REVERB_PRESET_" + self.preset_more) + eax_listener.listenerProps = getattr(EAXReverbProperties, "REVERB_PRESET_" + self.preset_more) else: - eax_listener.listenerProps = getattr(EaxReverbProperties, "REVERB_PRESET_" + self.preset) + eax_listener.listenerProps = getattr(EAXReverbProperties, "REVERB_PRESET_" + self.preset) class PlasmaSoftVolume(idprops.IDPropMixin, PlasmaModifierProperties): @@ -562,7 +562,7 @@ class PlasmaSubworldRegion(PlasmaModifierProperties): def export(self, exporter, bo, so): # Due to the fact that our subworld modifier can produce both RidingAnimatedPhysical - # and [HK|PX]Subworlds depending on the situation, this could get hairy, fast. + # and [HK|PX]Subworlds depending on the situation, this could get hairy, fast. # Start by surveying the lay of the land. from_sub, to_sub = bo.plasma_object.subworld, self.subworld from_isded = exporter.physics.is_dedicated_subworld(from_sub) diff --git a/korman/properties/modifiers/sound.py b/korman/properties/modifiers/sound.py index 71b37fd..c933b7a 100644 --- a/korman/properties/modifiers/sound.py +++ b/korman/properties/modifiers/sound.py @@ -152,6 +152,16 @@ class PlasmaSound(idprops.IDPropMixin, bpy.types.PropertyGroup): options={"ANIMATABLE"}, subtype="PERCENTAGE") + use_reverb = BoolProperty(name="Reverberation", + description="Allow the sound to be affected by reverberation regions", + default=False, + options=set()) + reverb_amount = IntProperty(name="Reverb amount", + description="Amount of reverb to apply to this sound (at 0, reverb volume reduced by 100 dB)", + min=0, max=100, default=100, + options=set(), + subtype="PERCENTAGE") + fade_in = PointerProperty(type=PlasmaSfxFade, options=set()) fade_out = PointerProperty(type=PlasmaSfxFade, options=set()) @@ -290,6 +300,21 @@ class PlasmaSound(idprops.IDPropMixin, bpy.types.PropertyGroup): else: sound.channel = plWin32Sound.kRightChannel + # Reverb/EAX + if self.use_reverb: + eax = sound.eaxSettings + eax.enable = True + # Occlusion: the minimum is -100 dB (but the value is multiplied by 100 in EAX's API) + eax.room = int(-10000 * (1 - (self.reverb_amount / 100.0))) + + # I couldn't get doppler effect working ingame, nor could I figure out how soft + # starts/ends are supposed to work in conjunction with the soft region. + # If you have more infos about those, feel free to share. + + # Make sure we use sensible defaults for soft starts/ends + eax.softStarts.reset() + eax.softEnds.reset() + # Whew, that was a lot of work! return sound.key diff --git a/korman/ui/modifiers/sound.py b/korman/ui/modifiers/sound.py index f80fae6..50cd0ed 100644 --- a/korman/ui/modifiers/sound.py +++ b/korman/ui/modifiers/sound.py @@ -101,3 +101,11 @@ def soundemit(modifier, layout, context): col.separator() col.label("Soft Region:") col.prop(sound, "sfx_region", text="") + + layout.separator() + split = layout.split() + col = split.column() + col.prop(sound, "use_reverb") + if sound.use_reverb: + col = split.column() + col.prop(sound, "reverb_amount", text="Reverb Amount")