mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-26 20:11:47 +00:00
Clean up stuff, make volume work again
This commit is contained in:
parent
7adf2159f6
commit
374d032a6b
4 changed files with 25 additions and 12 deletions
|
|
@ -676,8 +676,7 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
|
|||
/// Hardware renderer: OpenGL
|
||||
#define GL_SHADERS
|
||||
|
||||
/// Default volume for songs that don't have "volume" set via musicdef
|
||||
/// TODO: Remove this once all songs are ported
|
||||
#define DEFAULT_MUSICDEF_VOLUME 25
|
||||
/// Divide volume of music and sounds by this much (loudest sounds on earth)
|
||||
#define VOLUME_DIVIDER 4
|
||||
|
||||
#endif // __DOOMDEF__
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ void I_UpdateSoundParams(INT32 handle, UINT8 vol, UINT8 sep, UINT8 pitch);
|
|||
|
||||
\return void
|
||||
*/
|
||||
void I_SetSfxVolume(UINT8 volume);
|
||||
void I_SetSfxVolume(int volume);
|
||||
|
||||
/// ------------------------
|
||||
// MUSIC SYSTEM
|
||||
|
|
@ -227,7 +227,7 @@ void I_ResumeSong(void);
|
|||
|
||||
\return void
|
||||
*/
|
||||
void I_SetMusicVolume(UINT8 volume);
|
||||
void I_SetMusicVolume(int volume);
|
||||
|
||||
boolean I_SetSongTrack(INT32 track);
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,12 @@
|
|||
// mask used to indicate sound origin is player item pickup
|
||||
#define PICKUP_SOUND 0x8000
|
||||
|
||||
//
|
||||
#define SOUND_VOLUME_RANGE 256
|
||||
#define MAX_SOUND_VOLUME 255
|
||||
|
||||
#define DEFAULT_MUSICDEF_VOLUME ( 100 / VOLUME_DIVIDER )
|
||||
|
||||
extern consvar_t stereoreverse;
|
||||
extern consvar_t cv_soundvolume, cv_digmusicvolume;//, cv_midimusicvolume;
|
||||
extern consvar_t cv_numChannels;
|
||||
|
|
|
|||
|
|
@ -84,7 +84,9 @@ static UINT32 stutter_threshold_user;
|
|||
static UINT32 stutter_threshold;
|
||||
|
||||
static Mix_Music *music;
|
||||
static UINT8 music_volume, sfx_volume, internal_volume;
|
||||
static int music_volume;
|
||||
static int sfx_volume;
|
||||
static int internal_volume;
|
||||
static float loop_point;
|
||||
static float song_length; // length in seconds
|
||||
static boolean songpaused;
|
||||
|
|
@ -494,7 +496,9 @@ void I_FreeSfx(sfxinfo_t *sfx)
|
|||
INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority, INT32 channel)
|
||||
{
|
||||
//UINT8 volume = (((UINT16)vol + 1) * (UINT16)sfx_volume) / 62; // (256 * 31) / 62 == 127
|
||||
int volume = ( vol + 1 ) / 8;/* reduce to 1/4, 256 / 8 = 128 / 4 = 32 */
|
||||
const int scale = SOUND_VOLUME_RANGE / MIX_MAX_VOLUME;
|
||||
const int divider = VOLUME_DIVIDER * scale;
|
||||
const int volume = ( vol + 1 ) / divider * sfx_volume / 100;
|
||||
INT32 handle = Mix_PlayChannel(channel, S_sfx[id].data, 0);
|
||||
Mix_Volume(handle, volume);
|
||||
Mix_SetPanning(handle, min((UINT16)(0xff-sep)<<1, 0xff), min((UINT16)(sep)<<1, 0xff));
|
||||
|
|
@ -521,7 +525,7 @@ void I_UpdateSoundParams(INT32 handle, UINT8 vol, UINT8 sep, UINT8 pitch)
|
|||
(void)pitch;
|
||||
}
|
||||
|
||||
void I_SetSfxVolume(UINT8 volume)
|
||||
void I_SetSfxVolume(int volume)
|
||||
{
|
||||
sfx_volume = volume;
|
||||
}
|
||||
|
|
@ -530,9 +534,8 @@ void I_SetSfxVolume(UINT8 volume)
|
|||
/// Music Utilities
|
||||
/// ------------------------
|
||||
|
||||
static UINT32 get_real_volume(UINT8 volume)
|
||||
static UINT32 get_real_volume(int volume)
|
||||
{
|
||||
(void)volume;
|
||||
#ifdef _WIN32
|
||||
if (I_SongType() == MU_MID)
|
||||
// HACK: Until we stop using native MIDI,
|
||||
|
|
@ -540,10 +543,15 @@ static UINT32 get_real_volume(UINT8 volume)
|
|||
return ((UINT32)31*128/31); // volume = 31
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// convert volume to mixer's 128 scale
|
||||
// then apply internal_volume as a percentage
|
||||
//return ((UINT32)volume*128/31) * (UINT32)internal_volume / 100;
|
||||
return MIX_MAX_VOLUME * musicdef_volume / 100 * internal_volume / 100;
|
||||
return MIX_MAX_VOLUME
|
||||
* musicdef_volume / 100
|
||||
* internal_volume / 100
|
||||
* volume / 100;
|
||||
}
|
||||
}
|
||||
|
||||
static UINT32 get_adjusted_position(UINT32 position)
|
||||
|
|
@ -1237,7 +1245,7 @@ void I_ResumeSong(void)
|
|||
songpaused = false;
|
||||
}
|
||||
|
||||
void I_SetMusicVolume(UINT8 volume)
|
||||
void I_SetMusicVolume(int volume)
|
||||
{
|
||||
if (!I_SongPlaying())
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue