2016-12-01 17:50:48 +00:00
|
|
|
/*
|
2018-06-14 10:05:23 +00:00
|
|
|
Copyright 2016-2018 Marco "eukara" Hladik
|
|
|
|
|
|
|
|
MIT LICENSE
|
2016-12-01 17:50:48 +00:00
|
|
|
|
2018-06-14 10:05:23 +00:00
|
|
|
Permission is hereby granted, free of charge, to any person
|
|
|
|
obtaining a copy of this software and associated documentation
|
|
|
|
files (the "Software"), to deal in the Software without
|
|
|
|
restriction, including without limitation the rights to use,
|
|
|
|
copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
sell copies of the Software, and to permit persons to whom the
|
|
|
|
Software is furnished to do so, subject to the following conditions:
|
2016-12-01 17:50:48 +00:00
|
|
|
|
2018-06-14 10:05:23 +00:00
|
|
|
The above copyright notice and this permission notice shall be
|
|
|
|
included in all copies or substantial portions of the Software.
|
2016-12-01 17:50:48 +00:00
|
|
|
|
2018-06-14 10:05:23 +00:00
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
|
|
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
|
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
|
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
OTHER DEALINGS IN THE SOFTWARE.
|
2016-12-01 17:50:48 +00:00
|
|
|
*/
|
|
|
|
|
2017-11-13 17:03:23 +00:00
|
|
|
typedef struct {
|
|
|
|
string sSample;
|
|
|
|
float fLength;
|
|
|
|
} sound_t;
|
2016-12-01 17:50:48 +00:00
|
|
|
|
2017-11-13 17:03:23 +00:00
|
|
|
sound_t *sndVOX;
|
|
|
|
var int iVOXCount;
|
|
|
|
var int iVOXPos;
|
|
|
|
var float fSampleTime = 0.0f;
|
|
|
|
|
|
|
|
void Sound_PlayVOX( string sMessage ) {
|
|
|
|
if ( iVOXCount ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
iVOXCount = tokenize( sMessage );
|
|
|
|
sndVOX = memalloc( sizeof( sound_t ) * iVOXCount );
|
|
|
|
|
|
|
|
for ( int i = 0; i < iVOXCount; i++ ) {
|
|
|
|
sndVOX[i].sSample = sprintf( "vox/%s.wav", argv( i ) );
|
|
|
|
sndVOX[i].fLength = soundlength( sndVOX[i].sSample );
|
|
|
|
}
|
|
|
|
fSampleTime = time;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Sound_ProcessWordQue( void ) {
|
2017-11-18 21:21:39 +00:00
|
|
|
if ( cltime < 2 ) {
|
|
|
|
return;
|
|
|
|
}
|
2017-11-13 17:03:23 +00:00
|
|
|
if ( iVOXCount ) {
|
|
|
|
if ( fSampleTime < time ) {
|
|
|
|
localcmd( sprintf( "play %s\n", sndVOX[ iVOXPos ].sSample ) );
|
|
|
|
iVOXPos++;
|
|
|
|
|
|
|
|
if ( iVOXPos == iVOXCount ) {
|
|
|
|
memfree( sndVOX );
|
|
|
|
iVOXCount = 0;
|
|
|
|
iVOXPos = 0;
|
|
|
|
} else {
|
|
|
|
fSampleTime = time + sndVOX[ iVOXPos ].fLength;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-06-14 10:05:23 +00:00
|
|
|
}
|