Exemplo n.º 1
0
/*
* S_StartSound
*/
static void S_StartSound( sfx_t *sfx, const vec3_t origin, int entNum, int channel, float fvol, float attenuation )
{
	src_t *src;

	if( !sfx )
		return;

	src = S_AllocSource( SRCPRI_ONESHOT, entNum, channel );
	if( !src )
		return;

	source_setup( src, sfx, SRCPRI_ONESHOT, entNum, channel, fvol, attenuation );

	if( src->attenuation )
	{
		if( origin )
			VectorCopy( origin, src->origin );
		else
			src->isTracking = qtrue;
	}

	source_spatialize( src );

	qalSourcePlay( src->source );
}
Exemplo n.º 2
0
/*
* source_loop
*/
static void source_loop( int priority, sfx_t *sfx, int entNum, float fvol, float attenuation )
{
	src_t *src;
	qboolean new_source = qfalse;

	if( !sfx )
		return;

	if( entNum < 0 )
		return;

	// Do we need to start a new sound playing?
	if( !entlist[entNum].src )
	{
		src = S_AllocSource( priority, entNum, 0 );
		if( !src )
			return;
		new_source = qtrue;
	}
	else if( entlist[entNum].src->sfx != sfx )
	{
		// Need to restart. Just re-use this channel
		src = entlist[entNum].src;
		source_kill( src );
		new_source = qtrue;
	}
	else
	{
		src = entlist[entNum].src;
	}

	if( new_source )
	{
		source_setup( src, sfx, priority, entNum, -1, fvol, attenuation );
		qalSourcei( src->source, AL_LOOPING, AL_TRUE );
		src->isLooping = qtrue;

		entlist[entNum].src = src;
	}

	qalSourcef( src->source, AL_GAIN, src->fvol * s_volume->value );

	qalSourcef( src->source, AL_REFERENCE_DISTANCE, s_attenuation_refdistance );
	qalSourcef( src->source, AL_MAX_DISTANCE, s_attenuation_maxdistance );
	qalSourcef( src->source, AL_ROLLOFF_FACTOR, attenuation );

	if( new_source )
	{
		if( src->attenuation )
			src->isTracking = qtrue;

		source_spatialize( src );

		qalSourcePlay( src->source );
	}

	entlist[entNum].touched = qtrue;
}
Exemplo n.º 3
0
static void music_source_get( void )
{
    // Allocate a source at high priority
    src = S_AllocSource( SRCPRI_STREAM, -2, 0 );
    if( !src )
        return;

    S_LockSource( src );
    source = S_GetALSource( src );

    qalSource3f( source, AL_POSITION, 0.0, 0.0, 0.0 );
    qalSource3f( source, AL_VELOCITY, 0.0, 0.0, 0.0 );
    qalSource3f( source, AL_DIRECTION, 0.0, 0.0, 0.0 );
    qalSourcef( source, AL_ROLLOFF_FACTOR, 0.0 );
    qalSourcei( source, AL_SOURCE_RELATIVE, AL_TRUE );
    qalSourcef( source, AL_GAIN, s_musicvolume->value );
}
Exemplo n.º 4
0
/*
* S_StartLocalSound
*/
void S_StartLocalSound( const char *name )
{
	sfx_t *sfx;
	src_t *src;

	src = S_AllocSource( SRCPRI_LOCAL, -1, S_CHANNEL_AUTO );
	if( !src )
		return;

	sfx = S_RegisterSound( name );
	if( !sfx )
		return;

	source_setup( src, sfx, SRCPRI_LOCAL, -1, S_CHANNEL_AUTO, 1.0, ATTN_NONE );
	qalSourcei( src->source, AL_SOURCE_RELATIVE, AL_TRUE );

	qalSourcePlay( src->source );
}