Skip to content

Commit

Permalink
Use more precise conversion for fp32le sound buffers, fix \cl_nodelta…
Browse files Browse the repository at this point in the history
… cvar description
  • Loading branch information
Eugene committed Oct 30, 2022
1 parent 10c975a commit 6fe4ff1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion code/client/cl_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ void CL_InitInput( void ) {
Cmd_AddCommand ("-mlook", IN_MLookUp);

cl_nodelta = Cvar_Get( "cl_nodelta", "0", CVAR_DEVELOPER );
Cvar_SetDescription( cl_nodelta, "Disables delta compression on uploaded user commands." );
Cvar_SetDescription( cl_nodelta, "Flag server to disable delta compression on server snapshots." );
cl_debugMove = Cvar_Get( "cl_debugMove", "0", 0 );
Cvar_CheckRange( cl_debugMove, "0", "2", CV_INTEGER );
Cvar_SetDescription( cl_debugMove, "Prints a graph of view angle deltas.\n 0: Disabled\n 1: Yaw\n 2: Pitch" );
Expand Down
14 changes: 8 additions & 6 deletions code/client/snd_mix.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,16 +349,18 @@ static void S_TransferPaintBuffer( int endtime, byte *buffer )

if ( dma.samplebits == 32 && dma.isfloat )
{
const float rdiv = 1.0f / (32768.0f * 256.0f - 128.0f); // 8388480.0f
float *out = (float *) pbuf;
while ( count-- > 0 )
{
val = *p >> 8;
val = *p;
p += step;
if (val > 0x7fff)
val = 0x7fff;
else if (val < -32767) /* clamp to one less than max to make division max out at -1.0f. */
val = -32767;
out[out_idx] = ((float) val) / 32767.0f;
if (val > 0x7fff00) {
val = 0x7fff00;
} else if (val < -32768 * 256) {
val = -32768 * 256;
}
out[out_idx] = (float)(val + 128) * rdiv;
out_idx = (out_idx + 1) & out_mask;
}
}
Expand Down

0 comments on commit 6fe4ff1

Please sign in to comment.