Skip to content

WIP: Additional CON commands to control sound volume

Dino Bollinger requested to merge dibollinger/eduke32:sound_control into master

EDIT: I need to go over this again, I overlooked a bunch of things like an idiot.

In relation to issue #85, I have experimented with some commands to allow volume control of sounds and voices through CON.

definesoundv <soundID> <file> <pitch_lower> <pitch_upper> <priority> <type> <distance> <volume>:
This is an extension of the definesound command that allows scripts to specify the volume of a sound to be played. It utilizes the volume field of the sound_t struct that is normally always set to fix16_one when defining a new sound in CON. The only additional parameter is the last one, which defines the volume of the sound. (The <distance> parameter is the distance from which a sound can be heard as in definesound, which is currently mislabeled as <volume> on the eduke32 wiki.)

I'm not sure about the step size or the range of values that the <volume> parameter should accept. I've set the range to [0, 4096], where 1024 is transformed to fix16_one == 65536, but this isn't set in stone. I think a chosen upper bound is sensible because the value could theoeretically go much higher.

The application of this command would be that one can define multiple sounds with differing volumes, or being able to adjust the volume of a sound slightly without having to edit the source file directly.

setactorsoundvolume <spriteID> <soundID> <newVolume>:
Allows scripts to change the volume of currently active sounds, which are addressed based on sprite and sound ID. It is intended to work similarly to setactorsoundpitch to allow the volume of individual sounds that are either currently playing, or about to start playing to be altered. Same value range as for definesoundv.The application of this command would be to allow individual voices to play at different volumes on a per-case basis.

setglobalsoundvolume <soundID> <newVolume>:
Alters the volume of all future instances of the corresponding sound ID. This simply changes the defined volume for the sound in the g_sounds array, thus having all future instances of this sound play at this volume. An application of this would be to have multiple sounds play more silent during battle while a character speaks. However a downside is that this persists between maps and episode launches. I'm still suggesting it as a possibility however.

I'm submitting this as a WIP because it's not at all set in stone, and because I would like some feedback on whether this is a good idea or not, whether the implementation is appropriate etc.. Functionality to change the sound volume is very much desired in the large ongoing Duke mods from what I gather.

Attached is a number of scripts to test these commands, which can be triggered using the ALT-FIRE key: soundvolume_samples.zip

Edited by Dino Bollinger

Merge request reports