예제 #1
0
/*
============
S_Respatialize

Change the volumes of all the playing sounds for changes in their positions
============
*/
void SOrig_Respatialize( int entityNum, const vec3_t head, vec3_t axis[ 3 ], int inwater )
{
	int       i;
	channel_t *ch;
	vec3_t    origin;

	if ( !s_soundStarted || s_soundMuted )
	{
		return;
	}

	listener_number = entityNum;
	VectorCopy( head, listener_origin );
	VectorCopy( axis[ 0 ], listener_axis[ 0 ] );
	VectorCopy( axis[ 1 ], listener_axis[ 1 ] );
	VectorCopy( axis[ 2 ], listener_axis[ 2 ] );

	// update spatialization for dynamic sounds
	ch = s_channels;

	for ( i = 0; i < MAX_CHANNELS; i++, ch++ )
	{
		if ( !ch->thesfx )
		{
			continue;
		}

		// anything coming from the view entity will always be full volume
		if ( ch->entnum == listener_number )
		{
			ch->leftvol = ch->master_vol;
			ch->rightvol = ch->master_vol;
		}
		else
		{
			if ( ch->fixed_origin )
			{
				VectorCopy( ch->origin, origin );
			}
			else
			{
				VectorCopy( loopSounds[ ch->entnum ].origin, origin );
			}

			S_SpatializeOrigin( origin, ch->master_vol, &ch->leftvol, &ch->rightvol );
		}
	}

	// add loopsounds
	S_AddLoopSounds();
}
예제 #2
0
파일: snd_dma.c 프로젝트: brugal/wolfcamql
/*
============
S_Base_Respatialize

Change the volumes of all the playing sounds for changes in their positions
============
*/
static void S_Base_Respatialize( int entityNum, const vec3_t head, const vec3_t axis[3], int inwater ) {
	int			i;
	channel_t	*ch;
	vec3_t		origin;

	if ( !s_soundStarted || s_soundMuted ) {
		return;
	}

	listener_number = entityNum;
	//Com_Printf("%s()  %d\n", __FUNCTION__, entityNum);
	VectorCopy(head, listener_origin);
	VectorCopy(axis[0], listener_axis[0]);
	VectorCopy(axis[1], listener_axis[1]);
	VectorCopy(axis[2], listener_axis[2]);

	// update spatialization for dynamic sounds	
	ch = s_channels;
	for ( i = 0 ; i < MAX_CHANNELS ; i++, ch++ ) {
		if ( !ch->thesfx ) {
			continue;
		}
		// local and first person sounds will always be full volume
		if (ch->fullVolume) {
			ch->leftvol = ch->master_vol;
			ch->rightvol = ch->master_vol;
		} else {
			if (ch->fixed_origin) {
				VectorCopy( ch->origin, origin );
			} else {
				VectorCopy( loopSounds[ ch->entnum ].origin, origin );
			}

			S_SpatializeOrigin (origin, ch->master_vol, &ch->leftvol, &ch->rightvol);
		}
	}

	// add loopsounds
	S_AddLoopSounds ();
}
예제 #3
0
파일: dma.c 프로젝트: icanhas/yantar
/* Change the volumes of all the playing sounds for changes in their positions */
static void
S_Base_Respatialize(int entityNum, const Vec3 head, Vec3 axis[3],
                    int inwater)
{
    int i;
    Channel	*ch;
    Vec3		origin;

    UNUSED(inwater);

    if(!s_soundStarted || s_soundMuted)
        return;
    listener_number = entityNum;
    copyv3(head, listener_origin);
    copyv3(axis[0], listener_axis[0]);
    copyv3(axis[1], listener_axis[1]);
    copyv3(axis[2], listener_axis[2]);

    /* update spatialization for dynamic sounds */
    ch = s_channels;
    for(i = 0; i < MAX_CHANNELS; i++, ch++) {
        if(!ch->thesfx)
            continue;
        /* anything coming from the view entity will always be full volume */
        if(ch->entnum == listener_number) {
            ch->leftvol = ch->master_vol;
            ch->rightvol = ch->master_vol;
        } else {
            if(ch->fixed_origin)
                copyv3(ch->origin, origin);
            else
                copyv3(loopSounds[ ch->entnum ].origin,
                       origin);

            S_SpatializeOrigin (origin, ch->master_vol, &ch->leftvol,
                                &ch->rightvol);
        }
    }
    S_AddLoopSounds ();
}
예제 #4
0
/*
============
S_Update

Called once each time through the main loop
============
*/
void S_Update(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up)
{
	int			i;
	int			total;
	channel_t	*ch;
	channel_t	*combine;

	if (!sound_started)
		return;

	// if the laoding plaque is up, clear everything
	// out to make sure we aren't looping a dirty
	// dma buffer while loading
	if (cls.disable_screen)
	{
		S_ClearBuffer ();
		return;
	}

	// rebuild scale tables if volume is modified
	if (s_volume->modified)
		S_InitScaletable ();

	VectorCopy(origin, listener_origin);
	VectorCopy(forward, listener_forward);
	VectorCopy(right, listener_right);
	VectorCopy(up, listener_up);

	combine = NULL;

	// update spatialization for dynamic sounds	
	ch = channels;
	for (i=0 ; i<MAX_CHANNELS; i++, ch++)
	{
		if (!ch->sfx)
			continue;
		if (ch->autosound)
		{	// autosounds are regenerated fresh each frame
			memset (ch, 0, sizeof(*ch));
			continue;
		}
		S_Spatialize(ch);         // respatialize channel
		if (!ch->leftvol && !ch->rightvol)
		{
			memset (ch, 0, sizeof(*ch));
			continue;
		}
	}

	// add loopsounds
	S_AddLoopSounds ();

	//
	// debugging output
	//
	if (s_show->value)
	{
		total = 0;
		ch = channels;
		for (i=0 ; i<MAX_CHANNELS; i++, ch++)
			if (ch->sfx && (ch->leftvol || ch->rightvol) )
			{
				Com_Printf ("%3i %3i %s\n", ch->leftvol, ch->rightvol, ch->sfx->name);
				total++;
			}
		
		Com_Printf ("----(%i)---- painted: %i\n", total, paintedtime);
	}

#ifdef OGG_SUPPORT
//	Com_DPrintf ("S_Update: calling S_UpdateBackgroundTrack\n");	// debug
	S_UpdateBackgroundTrack ();	//  Knightmare added
#endif

// mix some sound
	S_Update_();
}
예제 #5
0
/*
============
S_Update

Called once each time through the main loop
============
*/
void S_Base_Update( void ) {
	int			i;
	vec3_t		origin;
	int			total;
	channel_t	*ch;

	if ( !s_soundStarted || s_soundMuted ) {
//		Com_DPrintf ("not started or muted\n");
		return;
	}

	// update spatialization for dynamic sounds
	if (respatialize) {
		respatialize = qfalse;

		ch = s_channels;
		for ( i = 0 ; i < MAX_CHANNELS ; i++, ch++ ) {
			if ( !ch->thesfx ) {
				continue;
			}

			// local and first person sounds will always be full volume
			if (ch->fullVolume) {
				ch->leftvol = ch->master_vol;
				ch->rightvol = ch->master_vol;
			} else {
				if (ch->fixed_origin) {
					VectorCopy( ch->origin, origin );
				} else {
					VectorCopy( loopSounds[ ch->entnum ].origin, origin );
				}

				S_SpatializeOrigin (origin, ch->master_vol, &ch->leftvol, &ch->rightvol);
			}
		}

		// add loopsounds
		S_AddLoopSounds ();
	}

	//
	// debugging output
	//
	if ( s_show->integer == 2 ) {
		total = 0;
		ch = s_channels;
		for (i=0 ; i<MAX_CHANNELS; i++, ch++) {
			if (ch->thesfx && (ch->leftvol || ch->rightvol) ) {
				Com_Printf ("%d %d %s\n", ch->leftvol, ch->rightvol, ch->thesfx->soundName);
				total++;
			}
		}
		
		Com_Printf ("----(%i)---- painted: %i\n", total, s_paintedtime);
	}

	// add raw data from streamed samples
	S_UpdateBackgroundTrack();

	// mix some sound
	S_Update_();
}