Add per-sound volume support to audiolib. This allows you to control the volume of sounds independently from the distance-based system exposed through CON. To use this, you must define your sounds via the .def syntax and set the "volume" property--default is 1.0.

git-svn-id: https://svn.eduke32.com/eduke32@7117 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2018-10-25 23:32:14 +00:00
parent 98f42cba6f
commit 374a09536d
16 changed files with 297 additions and 352 deletions

View file

@ -134,18 +134,18 @@ static wavefmt_t FX_DetectFormat(char const * const ptr, uint32_t length)
return fmt;
}
int32_t FX_Play(char *ptr, uint32_t length, int32_t loopstart, int32_t loopend, int32_t pitchoffset,
int32_t vol, int32_t left, int32_t right, int32_t priority, uint32_t callbackval)
int32_t FX_Play(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t loopend, int32_t pitchoffset,
int32_t vol, int32_t left, int32_t right, int32_t priority, float volume, uint32_t callbackval)
{
static int32_t(*const func[])(char *, uint32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint32_t) =
static int32_t(*const func[])(char *, uint32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, float, uint32_t) =
{ NULL, NULL, MV_PlayVOC, MV_PlayWAV, MV_PlayVorbis, MV_PlayFLAC, MV_PlayXA, MV_PlayXMP };
EDUKE32_STATIC_ASSERT(FMT_MAX == ARRAY_SIZE(func));
wavefmt_t const fmt = FX_DetectFormat(ptr, length);
wavefmt_t const fmt = FX_DetectFormat(ptr, ptrlength);
int handle =
(func[fmt]) ? func[fmt](ptr, length, loopstart, loopend, pitchoffset, vol, left, right, priority, callbackval) : -1;
(func[fmt]) ? func[fmt](ptr, ptrlength, loopstart, loopend, pitchoffset, vol, left, right, priority, volume, callbackval) : -1;
if (handle <= MV_Ok)
{
@ -156,18 +156,18 @@ int32_t FX_Play(char *ptr, uint32_t length, int32_t loopstart, int32_t loopend,
return handle;
}
int32_t FX_Play3D(char *ptr, uint32_t length, int32_t loophow, int32_t pitchoffset, int32_t angle, int32_t distance,
int32_t priority, uint32_t callbackval)
int32_t FX_Play3D(char *ptr, uint32_t ptrlength, int32_t loophow, int32_t pitchoffset, int32_t angle, int32_t distance,
int32_t priority, float volume, uint32_t callbackval)
{
static int32_t (*const func[])(char *, uint32_t, int32_t, int32_t, int32_t, int32_t, int32_t, uint32_t) =
static int32_t (*const func[])(char *, uint32_t, int32_t, int32_t, int32_t, int32_t, int32_t, float, uint32_t) =
{ NULL, NULL, MV_PlayVOC3D, MV_PlayWAV3D, MV_PlayVorbis3D, MV_PlayFLAC3D, MV_PlayXA3D, MV_PlayXMP3D };
EDUKE32_STATIC_ASSERT(FMT_MAX == ARRAY_SIZE(func));
wavefmt_t const fmt = FX_DetectFormat(ptr, length);
wavefmt_t const fmt = FX_DetectFormat(ptr, ptrlength);
int handle =
(func[fmt]) ? func[fmt](ptr, length, loophow, pitchoffset, angle, distance, priority, callbackval) : -1;
(func[fmt]) ? func[fmt](ptr, ptrlength, loophow, pitchoffset, angle, distance, priority, volume, callbackval) : -1;
if (handle <= MV_Ok)
{