VoIP: Added cheapie VoIP meter.

This commit is contained in:
Ryan C. Gordon 2008-06-25 05:50:44 +00:00
parent 3958f1099e
commit f8d6828f15
3 changed files with 43 additions and 3 deletions

View File

@ -39,6 +39,7 @@ cvar_t *cl_voipVADThreshold;
cvar_t *cl_voipSend; cvar_t *cl_voipSend;
cvar_t *cl_voipSendTarget; cvar_t *cl_voipSendTarget;
cvar_t *cl_voipGainDuringCapture; cvar_t *cl_voipGainDuringCapture;
cvar_t *cl_voipShowMeter;
cvar_t *voip; cvar_t *voip;
#endif #endif
@ -382,8 +383,9 @@ void CL_CaptureVoip(void)
speexFrames++; speexFrames++;
} }
clc.voipPower = voipPower / (32768.0f * 32768.0f * clc.voipPower = (voipPower / (32768.0f * 32768.0f *
((float) (clc.speexFrameSize * speexFrames))); ((float) (clc.speexFrameSize * speexFrames)))) *
100.0f;
if ((useVad) && (clc.voipPower < cl_voipVADThreshold->value)) { if ((useVad) && (clc.voipPower < cl_voipVADThreshold->value)) {
CL_VoipNewGeneration(); // no "talk" for at least 1/4 second. CL_VoipNewGeneration(); // no "talk" for at least 1/4 second.
@ -3088,7 +3090,8 @@ void CL_Init( void ) {
cl_voipSendTarget = Cvar_Get ("cl_voipSendTarget", "all", 0); cl_voipSendTarget = Cvar_Get ("cl_voipSendTarget", "all", 0);
cl_voipGainDuringCapture = Cvar_Get ("cl_voipGainDuringCapture", "0.2", CVAR_ARCHIVE); cl_voipGainDuringCapture = Cvar_Get ("cl_voipGainDuringCapture", "0.2", CVAR_ARCHIVE);
cl_voipUseVAD = Cvar_Get ("cl_voipUseVAD", "0", CVAR_ARCHIVE); cl_voipUseVAD = Cvar_Get ("cl_voipUseVAD", "0", CVAR_ARCHIVE);
cl_voipVADThreshold = Cvar_Get ("cl_voipVADThreshold", "0.0025", CVAR_ARCHIVE); cl_voipVADThreshold = Cvar_Get ("cl_voipVADThreshold", "0.25", CVAR_ARCHIVE);
cl_voipShowMeter = Cvar_Get ("cl_voipShowMeter", "1", CVAR_ARCHIVE);
voip = Cvar_Get ("voip", "1", CVAR_USERINFO | CVAR_ARCHIVE | CVAR_LATCH); voip = Cvar_Get ("voip", "1", CVAR_USERINFO | CVAR_ARCHIVE | CVAR_LATCH);
// This is a protocol version number. // This is a protocol version number.

View File

@ -343,6 +343,39 @@ void SCR_DrawDemoRecording( void ) {
} }
/*
=================
SCR_DrawVoipMeter
=================
*/
void SCR_DrawVoipMeter( void ) {
char buffer[16];
char string[256];
int limit, i;
if (!cl_voipShowMeter->integer)
return;
if (!cl_voipSend->integer)
return;
limit = (int) (clc.voipPower * 10.0f);
if (limit > 10)
limit = 10;
for (i = 0; i < limit; i++)
buffer[i] = '*';
while (i < 10)
buffer[i++] = ' ';
buffer[i] = '\0';
sprintf( string, "VoIP: [%s]", buffer );
SCR_DrawStringExt( 320 - strlen( string ) * 4, 10, 8, string, g_color_table[7], qtrue, qfalse );
}
/* /*
=============================================================================== ===============================================================================
@ -486,6 +519,9 @@ void SCR_DrawScreenField( stereoFrame_t stereoFrame ) {
// always supply STEREO_CENTER as vieworg offset is now done by the engine. // always supply STEREO_CENTER as vieworg offset is now done by the engine.
CL_CGameRendering(stereoFrame); CL_CGameRendering(stereoFrame);
SCR_DrawDemoRecording(); SCR_DrawDemoRecording();
#if USE_VOIP
SCR_DrawVoipMeter();
#endif
break; break;
} }
} }

View File

@ -416,6 +416,7 @@ extern cvar_t *cl_voipVADThreshold;
extern cvar_t *cl_voipSend; extern cvar_t *cl_voipSend;
extern cvar_t *cl_voipSendTarget; extern cvar_t *cl_voipSendTarget;
extern cvar_t *cl_voipGainDuringCapture; extern cvar_t *cl_voipGainDuringCapture;
extern cvar_t *cl_voipShowMeter;
extern cvar_t *voip; extern cvar_t *voip;
#endif #endif