Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Richard Gobeille
EDuke32
Commits
dd8c088f
Commit
dd8c088f
authored
Jan 20, 2021
by
Evan Ramos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure that cvars adjusting sound settings re-initialize what they need to
parent
9ee394fb
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
95 additions
and
18 deletions
+95
-18
source/audiolib/include/fx_man.h
source/audiolib/include/fx_man.h
+5
-0
source/audiolib/include/music.h
source/audiolib/include/music.h
+7
-0
source/audiolib/src/fx_man.cpp
source/audiolib/src/fx_man.cpp
+16
-6
source/duke3d/src/menus.cpp
source/duke3d/src/menus.cpp
+4
-4
source/duke3d/src/osdcmds.cpp
source/duke3d/src/osdcmds.cpp
+60
-7
source/duke3d/src/sounds.cpp
source/duke3d/src/sounds.cpp
+1
-1
source/duke3d/src/sounds.h
source/duke3d/src/sounds.h
+2
-0
No files found.
source/audiolib/include/fx_man.h
View file @
dd8c088f
...
...
@@ -63,6 +63,11 @@ void FX_InitCvars(void);
int
FX_Shutdown
(
void
);
int
FX_GetDevice
(
void
);
/* returns true only after program startup */
static
FORCE_INLINE
int
FX_WarmedUp
(
void
)
{
return
ASS_PCMSoundDriver
!=
ASS_AutoDetect
;
}
int
FX_Play
(
char
*
ptr
,
uint32_t
ptrlength
,
int
loopstart
,
int
loopend
,
int
pitchoffset
,
...
...
source/audiolib/include/music.h
View file @
dd8c088f
...
...
@@ -33,6 +33,7 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
#define __MUSIC_H
#include "compat.h"
#include "sndcards.h"
extern
int
MUSIC_ErrorCode
;
...
...
@@ -112,6 +113,12 @@ int MUSIC_StopSong(void);
int
MUSIC_PlaySong
(
char
*
song
,
int
songsize
,
int
loopflag
,
const
char
*
fn
=
nullptr
);
void
MUSIC_Update
(
void
);
/* returns true only after program startup */
static
FORCE_INLINE
int
MUSIC_WarmedUp
(
void
)
{
return
ASS_MIDISoundDriver
!=
ASS_AutoDetect
;
}
extern
char
SF2_BankFile
[
BMAX_PATH
];
extern
int
SF2_EffectSampleBlockSize
;
...
...
source/audiolib/src/fx_man.cpp
View file @
dd8c088f
...
...
@@ -68,7 +68,7 @@ static int osdcmd_cvar_set_audiolib(osdcmdptr_t parm)
if
(
parm
->
numparms
==
0
)
{
#ifdef _WIN32
if
(
!
Bstrcasecmp
(
parm
->
name
,
"mus_
win
mm_device"
))
if
(
!
Bstrcasecmp
(
parm
->
name
,
"mus_mm
e
_device"
))
WinMMDrv_MIDI_PrintDevices
();
#endif
#if defined RENDERTYPESDL && SDL_MAJOR_VERSION >= 2
...
...
@@ -79,7 +79,17 @@ static int osdcmd_cvar_set_audiolib(osdcmdptr_t parm)
if
(
r
!=
OSDCMD_OK
||
parm
->
numparms
<
1
)
return
r
;
if
(
!
Bstrcasecmp
(
parm
->
name
,
"mus_emidicard"
))
if
(
ASS_MIDISoundDriver
==
ASS_OPL3
&&
!
Bstrcasecmp
(
parm
->
name
,
"mus_emidicard"
))
MIDI_Restart
();
#ifdef _WIN32
else
if
(
ASS_MIDISoundDriver
==
ASS_WinMM
&&
!
Bstrcasecmp
(
parm
->
name
,
"mus_mme_device"
))
MIDI_Restart
();
#endif
#ifdef __linux__
else
if
(
ASS_MIDISoundDriver
==
ASS_ALSA
&&
(
!
Bstrcasecmp
(
parm
->
name
,
"mus_alsa_clientid"
)
||
!
Bstrcasecmp
(
parm
->
name
,
"mus_alsa_portid"
)))
MIDI_Restart
();
#endif
else
if
(
ASS_MIDISoundDriver
==
ASS_SF2
&&
(
!
Bstrcasecmp
(
parm
->
name
,
"mus_sf2_bank"
)
||
!
Bstrcasecmp
(
parm
->
name
,
"mus_sf2_sampleblocksize"
)))
MIDI_Restart
();
else
if
(
!
Bstrcasecmp
(
parm
->
name
,
"mus_al_stereo"
))
AL_SetStereo
(
AL_Stereo
);
...
...
@@ -111,14 +121,14 @@ void FX_InitCvars(void)
static
osdcvardata_t
cvars_audiolib
[]
=
{
{
"mus_emidicard"
,
"force a specific EMIDI instrument set"
,
(
void
*
)
&
ASS_EMIDICard
,
CVAR_INT
|
CVAR_FUNCPTR
,
-
1
,
10
},
#ifdef __linux__
{
"mus_alsa_clientid"
,
"specify the ALSA MIDI client ID"
,
(
void
*
)
&
ALSA_ClientID
,
CVAR_INT
,
0
,
255
},
{
"mus_alsa_portid"
,
"specify the ALSA MIDI port ID"
,
(
void
*
)
&
ALSA_PortID
,
CVAR_INT
,
0
,
15
},
{
"mus_alsa_clientid"
,
"specify the ALSA MIDI client ID"
,
(
void
*
)
&
ALSA_ClientID
,
CVAR_INT
|
CVAR_FUNCPTR
,
0
,
255
},
{
"mus_alsa_portid"
,
"specify the ALSA MIDI port ID"
,
(
void
*
)
&
ALSA_PortID
,
CVAR_INT
|
CVAR_FUNCPTR
,
0
,
15
},
#endif
{
"mus_al_additivemode"
,
"enable/disable alternate additive AdLib timbre mode"
,
(
void
*
)
&
AL_AdditiveMode
,
CVAR_BOOL
,
0
,
1
},
{
"mus_al_postamp"
,
"controls post-synthesization OPL3 volume amplification"
,
(
void
*
)
&
AL_PostAmp
,
CVAR_INT
,
0
,
3
},
{
"mus_al_stereo"
,
"enable/disable OPL3 stereo mode"
,
(
void
*
)
&
AL_Stereo
,
CVAR_BOOL
|
CVAR_FUNCPTR
,
0
,
1
},
{
"mus_sf2_bank"
,
"SoundFont 2 (.sf2) bank filename"
,
(
void
*
)
SF2_BankFile
,
CVAR_STRING
,
0
,
sizeof
(
SF2_BankFile
)
-
1
},
{
"mus_sf2_sampleblocksize"
,
"number of samples per effect processing block"
,
(
void
*
)
&
SF2_EffectSampleBlockSize
,
CVAR_INT
,
1
,
64
},
{
"mus_sf2_bank"
,
"SoundFont 2 (.sf2) bank filename"
,
(
void
*
)
SF2_BankFile
,
CVAR_STRING
|
CVAR_FUNCPTR
,
0
,
sizeof
(
SF2_BankFile
)
-
1
},
{
"mus_sf2_sampleblocksize"
,
"number of samples per effect processing block"
,
(
void
*
)
&
SF2_EffectSampleBlockSize
,
CVAR_INT
|
CVAR_FUNCPTR
,
1
,
64
},
#ifdef _WIN32
{
"mus_mme_device"
,
"select Windows MME MIDI output device"
,
(
void
*
)
&
WinMM_DeviceID
,
CVAR_INT
|
CVAR_FUNCPTR
,
-
1
,
WinMMDrv_MIDI_GetNumDevices
()
-
1
},
#endif
...
...
source/duke3d/src/menus.cpp
View file @
dd8c088f
...
...
@@ -3484,7 +3484,7 @@ static void Menu_EntryLinkActivate(MenuEntry_t *entry)
||
(
musicdevice
==
ASS_ALSA
&&
(
size_t
)
alsadevice
<
alsadevices
.
size
()
&&
(
ALSA_ClientID
!=
alsadevices
[
alsadevice
].
clntid
||
ALSA_PortID
!=
alsadevices
[
alsadevice
].
portid
))
#endif
)
)
{
S_MusicShutdown
();
S_SoundShutdown
();
...
...
@@ -3506,10 +3506,10 @@ static void Menu_EntryLinkActivate(MenuEntry_t *entry)
{
int
const
needsReInit
=
(
ud
.
config
.
MusicDevice
!=
musicdevice
||
(
musicdevice
==
ASS_SF2
&&
Bstrcmp
(
SF2_BankFile
,
sf2bankfile
))
#ifdef __linux__
||
(
musicdevice
==
ASS_ALSA
&&
(
size_t
)
alsadevice
<
alsadevices
.
size
()
&&
(
ALSA_ClientID
!=
alsadevices
[
alsadevice
].
clntid
||
ALSA_PortID
!=
alsadevices
[
alsadevice
].
portid
))
||
(
musicdevice
==
ASS_ALSA
&&
(
size_t
)
alsadevice
<
alsadevices
.
size
()
&&
(
ALSA_ClientID
!=
alsadevices
[
alsadevice
].
clntid
||
ALSA_PortID
!=
alsadevices
[
alsadevice
].
portid
))
#endif
);
);
AL_Stereo
=
opl3stereo
;
Bstrcpy
(
SF2_BankFile
,
sf2bankfile
);
...
...
source/duke3d/src/osdcmds.cpp
View file @
dd8c088f
...
...
@@ -383,6 +383,7 @@ static int osdcmd_noclip(osdcmdptr_t UNUSED(parm))
static
int
osdcmd_restartsound
(
osdcmdptr_t
UNUSED
(
parm
))
{
UNREFERENCED_CONST_PARAMETER
(
parm
);
S_SoundShutdown
();
S_MusicShutdown
();
...
...
@@ -1330,9 +1331,12 @@ static int osdcmd_purgesaves(osdcmdptr_t UNUSED(parm))
static
int
osdcmd_cvar_set_game
(
osdcmdptr_t
parm
)
{
static
char
const
prefix_snd
[]
=
"snd_"
;
static
char
const
prefix_mus
[]
=
"mus_"
;
int
const
r
=
osdcmd_cvar_set
(
parm
);
if
(
r
!=
OSDCMD_OK
)
return
r
;
if
(
r
!=
OSDCMD_OK
||
parm
->
numparms
<
1
)
return
r
;
if
(
!
Bstrcasecmp
(
parm
->
name
,
"r_upscalefactor"
))
{
...
...
@@ -1370,6 +1374,55 @@ static int osdcmd_cvar_set_game(osdcmdptr_t parm)
{
videoSetPalette
(
ud
.
brightness
>>
2
,
g_player
[
myconnectindex
].
ps
->
palette
,
0
);
}
else
if
(
!
Bstrcasecmp
(
parm
->
name
,
"snd_enabled"
)
||
!
Bstrcasecmp
(
parm
->
name
,
"snd_numvoices"
))
{
if
(
!
FX_WarmedUp
())
return
r
;
S_SoundShutdown
();
S_SoundStartup
();
S_ClearSoundLocks
();
}
else
if
(
!
Bstrncasecmp
(
parm
->
name
,
prefix_snd
,
ARRAY_SIZE
(
prefix_snd
)
-
1
))
{
if
(
!
FX_WarmedUp
())
return
r
;
if
(
ASS_MIDISoundDriver
==
ASS_OPL3
||
ASS_MIDISoundDriver
==
ASS_SF2
||
MusicIsWaveform
)
{
// music that we generate and send through sound
S_MusicShutdown
();
S_SoundShutdown
();
S_SoundStartup
();
S_MusicStartup
();
S_ClearSoundLocks
();
if
(
ud
.
config
.
MusicToggle
)
S_RestartMusic
();
}
else
{
S_SoundShutdown
();
S_SoundStartup
();
S_ClearSoundLocks
();
}
}
else
if
(
!
Bstrncasecmp
(
parm
->
name
,
prefix_mus
,
ARRAY_SIZE
(
prefix_mus
)
-
1
))
{
if
(
!
MUSIC_WarmedUp
())
return
r
;
S_MusicShutdown
();
S_MusicStartup
();
if
(
ud
.
config
.
MusicToggle
)
S_RestartMusic
();
}
else
if
(
!
Bstrcasecmp
(
parm
->
name
,
"hud_scale"
)
||
!
Bstrcasecmp
(
parm
->
name
,
"hud_statusbarmode"
)
||
!
Bstrcasecmp
(
parm
->
name
,
"r_rotatespritenowidescreen"
))
...
...
@@ -1566,8 +1619,8 @@ int32_t registerosdcommands(void)
{
"in_mousexscale"
,
"scale modifier for mouse x axis"
,
(
void
*
)
&
CONTROL_MouseAxesScale
[
0
],
CVAR_INT
,
0
,
65536
},
{
"in_mouseyscale"
,
"scale modifier for mouse y axis"
,
(
void
*
)
&
CONTROL_MouseAxesScale
[
1
],
CVAR_INT
,
0
,
65536
},
{
"mus_enabled"
,
"music subsystem"
CVAR_BOOL_OPTSTR
,
(
void
*
)
&
ud
.
config
.
MusicToggle
,
CVAR_BOOL
,
0
,
1
},
{
"mus_device"
,
"music device"
,
(
void
*
)
&
ud
.
config
.
MusicDevice
,
CVAR_INT
,
0
,
ASS_NumSoundCards
},
{
"mus_enabled"
,
"music subsystem"
CVAR_BOOL_OPTSTR
,
(
void
*
)
&
ud
.
config
.
MusicToggle
,
CVAR_BOOL
|
CVAR_FUNCPTR
,
0
,
1
},
{
"mus_device"
,
"music device"
,
(
void
*
)
&
ud
.
config
.
MusicDevice
,
CVAR_INT
|
CVAR_FUNCPTR
,
0
,
ASS_NumSoundCards
},
{
"mus_volume"
,
"controls music volume"
,
(
void
*
)
&
ud
.
config
.
MusicVolume
,
CVAR_INT
,
0
,
255
},
{
"osdhightile"
,
"use content pack assets for console text if available"
CVAR_BOOL_OPTSTR
,
(
void
*
)
&
osdhightile
,
CVAR_BOOL
,
0
,
1
},
...
...
@@ -1590,11 +1643,11 @@ int32_t registerosdcommands(void)
{
"skill"
,
"changes the game skill setting"
,
(
void
*
)
&
ud
.
m_player_skill
,
CVAR_INT
|
CVAR_FUNCPTR
|
CVAR_NOSAVE
/*|CVAR_NOMULTI*/
,
0
,
5
},
{
"snd_ambience"
,
"ambient sounds"
CVAR_BOOL_OPTSTR
,
(
void
*
)
&
ud
.
config
.
AmbienceToggle
,
CVAR_BOOL
,
0
,
1
},
{
"snd_enabled"
,
"sound effects"
CVAR_BOOL_OPTSTR
,
(
void
*
)
&
ud
.
config
.
SoundToggle
,
CVAR_BOOL
,
0
,
1
},
{
"snd_enabled"
,
"sound effects"
CVAR_BOOL_OPTSTR
,
(
void
*
)
&
ud
.
config
.
SoundToggle
,
CVAR_BOOL
|
CVAR_FUNCPTR
,
0
,
1
},
{
"snd_fxvolume"
,
"volume of sound effects"
,
(
void
*
)
&
ud
.
config
.
FXVolume
,
CVAR_INT
,
0
,
255
},
{
"snd_mixrate"
,
"sound mixing rate"
,
(
void
*
)
&
ud
.
config
.
MixRate
,
CVAR_INT
,
0
,
48000
},
{
"snd_numchannels"
,
"the number of sound channels"
,
(
void
*
)
&
ud
.
config
.
NumChannels
,
CVAR_INT
,
0
,
2
},
{
"snd_numvoices"
,
"the number of concurrent sounds"
,
(
void
*
)
&
ud
.
config
.
NumVoices
,
CVAR_INT
,
1
,
MAXVOICES
},
{
"snd_mixrate"
,
"sound mixing rate"
,
(
void
*
)
&
ud
.
config
.
MixRate
,
CVAR_INT
|
CVAR_FUNCPTR
,
0
,
48000
},
{
"snd_numchannels"
,
"the number of sound channels"
,
(
void
*
)
&
ud
.
config
.
NumChannels
,
CVAR_INT
|
CVAR_FUNCPTR
,
0
,
2
},
{
"snd_numvoices"
,
"the number of concurrent sounds"
,
(
void
*
)
&
ud
.
config
.
NumVoices
,
CVAR_INT
|
CVAR_FUNCPTR
,
1
,
MAXVOICES
},
#ifdef ASS_REVERSESTEREO
{
"snd_reversestereo"
,
"reverses the stereo channels"
,
(
void
*
)
&
ud
.
config
.
ReverseStereo
,
CVAR_BOOL
,
0
,
1
},
#endif
...
...
source/duke3d/src/sounds.cpp
View file @
dd8c088f
...
...
@@ -33,7 +33,7 @@ int32_t g_numEnvSoundsPlaying, g_highestSoundIdx;
static
char
*
MusicPtr
;
static
int32_t
MusicIsWaveform
;
int32_t
MusicIsWaveform
;
static
int32_t
MusicVoice
=
-
1
;
static
bool
MusicPaused
;
...
...
source/duke3d/src/sounds.h
View file @
dd8c088f
...
...
@@ -63,6 +63,8 @@ extern char g_soundlocks[MAXSOUNDS];
extern
sound_t
g_sounds
[
MAXSOUNDS
];
extern
int32_t
g_numEnvSoundsPlaying
,
g_highestSoundIdx
;
extern
int32_t
MusicIsWaveform
;
int
A_CheckSoundPlaying
(
int
spriteNum
,
int
soundNum
);
int
A_PlaySound
(
int
soundNum
,
int
spriteNum
);
void
S_Callback
(
intptr_t
num
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment