Browse Source

Add reverb option to sound emitters. Rename EAXReverbProperties.

pull/253/head
Jrius 4 years ago
parent
commit
63526834f0
  1. 8
      korman/properties/modifiers/region.py
  2. 25
      korman/properties/modifiers/sound.py
  3. 8
      korman/ui/modifiers/sound.py

8
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):

25
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

8
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")

Loading…
Cancel
Save