Trying to make voicechat controls more intuitive. Added a sender-side mic boost (cl_voip_micamp, default 2).

Use +voip to send voice (internally just sets cl_voip_send cvar, which can be used directly to force sending on). cl_voip_play to disable playback.
There is still no way to mute specific players.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3658 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2010-11-15 03:37:29 +00:00
parent 1cf4aed554
commit a738de2c29
3 changed files with 47 additions and 11 deletions

View file

@ -975,7 +975,7 @@ qboolean SNDDMA_InitCapture (void)
}
/*minsamples is a hint*/
unsigned int DSOUND_UpdateCapture(unsigned char *buffer, unsigned int minbytes, unsigned int maxbytes)
unsigned int DSOUND_UpdateCapture(qboolean enable, unsigned char *buffer, unsigned int minbytes, unsigned int maxbytes)
{
HRESULT hr;
LPBYTE lpbuf1 = NULL;
@ -987,7 +987,7 @@ unsigned int DSOUND_UpdateCapture(unsigned char *buffer, unsigned int minbytes,
DWORD readPos;
long filled;
if (!snd_capture.ival)
if (!enable)
{
if (DSCaptureBuffer)
{
@ -1045,5 +1045,5 @@ unsigned int DSOUND_UpdateCapture(unsigned char *buffer, unsigned int minbytes,
}
return filled;
}
unsigned int (*pDSOUND_UpdateCapture) (unsigned char *buffer, unsigned int minbytes, unsigned int maxbytes) = &DSOUND_UpdateCapture;
unsigned int (*pDSOUND_UpdateCapture) (qboolean enable, unsigned char *buffer, unsigned int minbytes, unsigned int maxbytes) = &DSOUND_UpdateCapture;
#endif

View file

@ -97,8 +97,6 @@ cvar_t snd_samplebits = CVARAF( "s_bits", "16",
cvar_t snd_playersoundvolume = CVARAF( "s_localvolume", "1",
"snd_localvolume", 0); //sugested by crunch
cvar_t snd_capture = CVARAF( "s_capture", "0",
"snd_capture", 0);
cvar_t snd_linearresample = CVARAF( "s_linearresample", "1",
"snd_linearresample", 0);
cvar_t snd_linearresample_stream = CVARAF( "s_linearresample_stream", "0",
@ -107,6 +105,12 @@ cvar_t snd_linearresample_stream = CVARAF( "s_linearresample_stream", "0",
cvar_t snd_usemultipledevices = CVARAF( "s_multipledevices", "0",
"snd_multipledevices", 0);
#ifdef VOICECHAT
cvar_t cl_voip_send = CVAR("cl_voip_send", "0");
cvar_t cl_voip_play = CVAR("cl_voip_play", "1");
cvar_t cl_voip_micamp = CVAR("cl_voip_micamp", "2");
#endif
extern vfsfile_t *rawwritefile;
@ -277,7 +281,7 @@ void S_ParseVoiceChat(void)
unsigned char seq;
seq = MSG_ReadByte();
bytes = MSG_ReadShort();
if (bytes > sizeof(data))
if (bytes > sizeof(data) || !cl_voip_play.ival)
{
MSG_ReadSkip(bytes);
return;
@ -319,13 +323,13 @@ void S_ParseVoiceChat(void)
s_speex.decseq[sender] += newseq;
if (drops)
Con_Printf("%i dropped audio frames\n", drops);
Con_DPrintf("%i dropped audio frames\n", drops);
if (decodesamps > 0)
S_RawAudio(sender, (qbyte*)decodebuf, 11025, decodesamps, 1, 2);
}
unsigned int (*pDSOUND_UpdateCapture) (unsigned char *buffer, unsigned int minbytes, unsigned int maxbytes);
unsigned int (*pDSOUND_UpdateCapture) (qboolean enable, unsigned char *buffer, unsigned int minbytes, unsigned int maxbytes);
void S_TransmitVoiceChat(unsigned char clc, sizebuf_t *buf)
{
static unsigned char capturebuf[32768];
@ -336,11 +340,13 @@ void S_TransmitVoiceChat(unsigned char clc, sizebuf_t *buf)
unsigned int encpos;//in bytes
unsigned short *start;
unsigned char initseq;//in frames
unsigned int i;
float micamp = cl_voip_micamp.value;
//add new drivers in order or desirability.
if (pDSOUND_UpdateCapture)
{
capturepos += pDSOUND_UpdateCapture((unsigned char*)capturebuf + capturepos, 64, sizeof(capturebuf) - capturepos);
capturepos += pDSOUND_UpdateCapture(cl_voip_send.ival, (unsigned char*)capturebuf + capturepos, 64, sizeof(capturebuf) - capturepos);
}
else
{
@ -357,6 +363,14 @@ void S_TransmitVoiceChat(unsigned char clc, sizebuf_t *buf)
qspeex_preprocess_run(s_speex.preproc, start);
if (micamp != 1)
{
for (i = 0; i < s_speex.framesize; i++)
{
start[i] *= micamp;
}
}
qspeex_bits_reset(&s_speex.encbits);
qspeex_encode_int(s_speex.encoder, start, &s_speex.encbits);
outbuf[outpos] = qspeex_bits_write(&s_speex.encbits, outbuf+outpos+1, sizeof(outbuf) - (outpos+1));
@ -377,6 +391,15 @@ void S_TransmitVoiceChat(unsigned char clc, sizebuf_t *buf)
memmove(capturebuf, capturebuf + encpos, capturepos-encpos);
capturepos -= encpos;
}
void S_Voip_Enable_f(void)
{
Cvar_Set(&cl_voip_send, "1");
}
void S_Voip_Disable_f(void)
{
Cvar_Set(&cl_voip_send, "0");
}
#endif
@ -779,7 +802,13 @@ void S_Init (void)
Cvar_Register(&snd_buffersize, "Sound controls");
Cvar_Register(&snd_samplebits, "Sound controls");
Cvar_Register(&snd_capture, "Sound controls");
#ifdef VOICECHAT
Cvar_Register(&cl_voip_send, "Voice Chat");
Cvar_Register(&cl_voip_play, "Voice Chat");
Cvar_Register(&cl_voip_micamp, "Voice Chat");
Cmd_AddCommand("+voip", S_Voip_Enable_f);
Cmd_AddCommand("-voip", S_Voip_Disable_f);
#endif
Cvar_Register(&snd_inactive, "Sound controls");

View file

@ -94,6 +94,10 @@ cvar_t sv_realiphostname_ipv4 = SCVAR("sv_realiphostname_ipv4", "");
cvar_t sv_realiphostname_ipv6 = SCVAR("sv_realiphostname_ipv6", "");
cvar_t sv_realip_timeout = SCVAR("sv_realip_timeout", "10");
#ifdef VOICECHAT
cvar_t sv_voip = CVAR("sv_voip", "1");
#endif
char sv_votinggroup[] = "server voting";
@ -2111,7 +2115,7 @@ void SV_VoiceReadPacket(void)
/*read the data from the client*/
bytes = MSG_ReadShort();
ring = &voice.ring[voice.write & (VOICE_RING_SIZE-1)];
if (bytes > sizeof(ring->data) || host_client->ismuted)
if (bytes > sizeof(ring->data) || host_client->ismuted || !sv_voip.ival)
{
MSG_ReadSkip(bytes);
return;
@ -6358,6 +6362,9 @@ SV_UserInit
*/
void SV_UserInit (void)
{
#ifdef VOICECHAT
Cvar_Register (&sv_voip, cvargroup_serverpermissions);
#endif
#ifdef SERVERONLY
Cvar_Register (&cl_rollspeed, "Prediction stuff");
Cvar_Register (&cl_rollangle, "Prediction stuff");