Browse Source

Add reverb option to sound emitters. Rename EAXReverbProperties.

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

10
korman/properties/modifiers/region.py

@ -402,7 +402,7 @@ class PlasmaReverbRegion(PlasmaModifierProperties):
eax_listener.softRegion = bo.plasma_modifiers.softvolume.get_key(exporter, so) eax_listener.softRegion = bo.plasma_modifiers.softvolume.get_key(exporter, so)
if self.preset == "CUSTOM": if self.preset == "CUSTOM":
# Someone's feeling exceedingly confident today... # Someone's feeling exceedingly confident today...
props = EaxReverbProperties() props = EAXReverbProperties()
props.environment = 26 props.environment = 26
props.environmentSize = self.environment_size props.environmentSize = self.environment_size
props.environmentDiffusion = self.environment_diffusion props.environmentDiffusion = self.environment_diffusion
@ -425,13 +425,13 @@ class PlasmaReverbRegion(PlasmaModifierProperties):
props.lfReference = self.lf_reference props.lfReference = self.lf_reference
flags = 0 flags = 0
for flag in self.flags: for flag in self.flags:
flags |= getattr(EaxReverbProperties, flag) flags |= getattr(EAXReverbProperties, flag)
props.flags = flags props.flags = flags
eax_listener.listenerProps = props eax_listener.listenerProps = props
elif self.preset == "MORE": 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: else:
eax_listener.listenerProps = getattr(EaxReverbProperties, "REVERB_PRESET_" + self.preset) eax_listener.listenerProps = getattr(EAXReverbProperties, "REVERB_PRESET_" + self.preset)
class PlasmaSoftVolume(idprops.IDPropMixin, PlasmaModifierProperties): class PlasmaSoftVolume(idprops.IDPropMixin, PlasmaModifierProperties):
@ -562,7 +562,7 @@ class PlasmaSubworldRegion(PlasmaModifierProperties):
def export(self, exporter, bo, so): def export(self, exporter, bo, so):
# Due to the fact that our subworld modifier can produce both RidingAnimatedPhysical # 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. # Start by surveying the lay of the land.
from_sub, to_sub = bo.plasma_object.subworld, self.subworld from_sub, to_sub = bo.plasma_object.subworld, self.subworld
from_isded = exporter.physics.is_dedicated_subworld(from_sub) from_isded = exporter.physics.is_dedicated_subworld(from_sub)

25
korman/properties/modifiers/sound.py

@ -152,6 +152,16 @@ class PlasmaSound(idprops.IDPropMixin, bpy.types.PropertyGroup):
options={"ANIMATABLE"}, options={"ANIMATABLE"},
subtype="PERCENTAGE") 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_in = PointerProperty(type=PlasmaSfxFade, options=set())
fade_out = PointerProperty(type=PlasmaSfxFade, options=set()) fade_out = PointerProperty(type=PlasmaSfxFade, options=set())
@ -290,6 +300,21 @@ class PlasmaSound(idprops.IDPropMixin, bpy.types.PropertyGroup):
else: else:
sound.channel = plWin32Sound.kRightChannel 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! # Whew, that was a lot of work!
return sound.key return sound.key

8
korman/ui/modifiers/sound.py

@ -101,3 +101,11 @@ def soundemit(modifier, layout, context):
col.separator() col.separator()
col.label("Soft Region:") col.label("Soft Region:")
col.prop(sound, "sfx_region", text="") 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