Example #1
0
/*
* S_Init
*/
static bool S_Init( void *hwnd, int maxEntities, bool verbose )
{
	if( !SNDDMA_Init( hwnd, verbose ) )
		return false;
	
	s_active = true;
	s_last_update_time = 0;

	if( verbose )
		Com_Printf( "Sound sampling rate: %i\n", dma.speed );

	SNDOGG_Init( verbose );

	num_loopsfx = 0;

	memset( raw_sounds, 0, sizeof( raw_sounds ) );

	S_InitScaletable();

	// highfrequency attenuation filter
	s_lpf_cw = S_LowpassCW( HQ_HF_FREQUENCY, dma.speed );

	S_ClearSoundTime();

	S_StopAllSounds( true, true );

	S_LockBackgroundTrack( false );

	return true;
}
Example #2
0
/*
================
S_Init
================
*/
void S_Init (void)
{
	cvar_t	*cv;

	Com_Printf("\n------- sound initialization -------\n");

	cv = Cvar_Get ("s_initsound", "1", 0);
	if (!cv->value)
		Com_Printf ("not initializing.\n");
	else
	{
		s_volume = Cvar_Get ("s_volume", "0.7", CVAR_ARCHIVE);
		s_khz = Cvar_Get ("s_khz", "22", CVAR_ARCHIVE);	// Knightmare- increased from 11
		s_loadas8bit = Cvar_Get ("s_loadas8bit", "0", CVAR_ARCHIVE);	// Knightmare- changed from 1
		s_mixahead = Cvar_Get ("s_mixahead", "0.2", CVAR_ARCHIVE);
		s_show = Cvar_Get ("s_show", "0", 0);
		s_testsound = Cvar_Get ("s_testsound", "0", 0);
		s_primary = Cvar_Get ("s_primary", "0", CVAR_ARCHIVE);	// win32 specific
	#ifdef OGG_SUPPORT
		s_musicvolume = Cvar_Get ("s_musicvolume", "1.0", CVAR_ARCHIVE); // Knightmare added
	#endif

		Cmd_AddCommand("play", S_Play);
		Cmd_AddCommand("stopsound", S_StopAllSounds);
		Cmd_AddCommand("soundlist", S_SoundList);
		Cmd_AddCommand("soundinfo", S_SoundInfo_f);
	#ifdef OGG_SUPPORT
		Cmd_AddCommand("ogg_restart", S_OGG_Restart); // Knightmare added
	#endif

		if (!SNDDMA_Init())
			return;

		S_InitScaletable ();

		sound_started = 1;
		num_sfx = 0;

		soundtime = 0;
		paintedtime = 0;

		Com_Printf ("sound sampling rate: %i\n", dma.speed);

		S_StopAllSounds ();
	}

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

	Com_Printf("------------------------------------\n");
}
Example #3
0
// Called once each time through the main loop
void S_Update(const CVec3 &origin, const CVec3 &right)
{
	int		i;

	if (!sound_started) return;

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

	listener_origin = origin;
	listener_right  = right;

	// update spatialization for dynamic sounds
	channel_t *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
	AddLoopSounds();

	// debugging output
	if (s_show->integer == 2)
	{
		int total = 0;
		for (i = 0, ch = channels; i < MAX_CHANNELS; i++, ch++)
			if (ch->sfx && (ch->leftvol || ch->rightvol) )
			{
				appPrintf("%3i %3i %s\n", ch->leftvol, ch->rightvol, *ch->sfx->Name);
				total++;
			}

		appPrintf("----(%i)---- painted: %i\n", total, paintedtime);
	}

// mix some sound
	S_Update_();
}
Example #4
0
/*
================
S_Init
================
*/
void S_Init(void)
{
    cvar_t * cv;
    Com_Printf("---- Sound initialization ----\n");

    cv = Cvar_Get("s_initsound", "1", 0);
    if (!cv->value)
    {
        Com_Printf("not initializing.\n");
    }
    else
    {
        s_volume = Cvar_Get("s_volume", "0.7", CVAR_ARCHIVE);
        s_khz = Cvar_Get("s_khz", "11", CVAR_ARCHIVE);
        s_loadas8bit = Cvar_Get("s_loadas8bit", "1", CVAR_ARCHIVE);
        s_mixahead = Cvar_Get("s_mixahead", "0.2", CVAR_ARCHIVE);
        s_show = Cvar_Get("s_show", "0", 0);
        s_testsound = Cvar_Get("s_testsound", "0", 0);
        s_primary = Cvar_Get("s_primary", "0", CVAR_ARCHIVE); // win32 specific

        Cmd_AddCommand("play", S_Play);
        Cmd_AddCommand("stopsound", S_StopAllSounds);
        Cmd_AddCommand("soundlist", S_SoundList);
        Cmd_AddCommand("soundinfo", S_SoundInfo_f);

        if (!SNDDMA_Init())
        {
            return;
        }

        S_InitScaletable();

        sound_started = 1;
        num_sfx = 0;

        soundtime = 0;
        paintedtime = 0;

        Com_Printf("sound sampling rate: %i\n", dma.speed);

        S_StopAllSounds();
    }

    Com_Printf("------------------------------------\n");
}
Example #5
0
void S_Init(void)
{
	cvar_t *cv = Cvar_Get("nosound", "0", 0);
	if (cv->integer)
		appPrintf(S_CYAN"Sound disabled\n");
	else
	{
CVAR_BEGIN(vars)
		CVAR_VAR(s_volume, 0.7, CVAR_ARCHIVE),
		CVAR_VAR(s_khz, 22, CVAR_ARCHIVE),
		CVAR_VAR(s_loadas8bit, 0, CVAR_ARCHIVE),
		CVAR_VAR(s_reverse_stereo, 0, CVAR_ARCHIVE),
		CVAR_VAR(s_mixahead, 0.2, CVAR_ARCHIVE),
		CVAR_VAR(s_show, 0, 0),
		CVAR_VAR(s_testsound, 0, 0),
		CVAR_VAR(s_primary, 0, CVAR_ARCHIVE)		//?? win32 specific
CVAR_END

		Cvar_GetVars(ARRAY_ARG(vars));

		appPrintf("\n------- Sound initialization -------\n");

		if (!SNDDMA_Init()) return;

		RegisterCommand("play", S_Play_f);
		RegisterCommand("stopsound", S_StopAllSounds_f);
		RegisterCommand("soundlist", S_SoundList_f);
		RegisterCommand("soundinfo", S_SoundInfo_f);

		S_InitScaletable();

		sound_started = true;
		num_sfx = 0;

		soundtime   = 0;
		paintedtime = 0;

		appPrintf("sound sampling rate: %d\n", dma.speed);

		S_StopAllSounds_f();

		appPrintf("------------------------------------\n");
	}
}
Example #6
0
/*
================
S_Init
================
*/
void S_Init (void)
{
	cvar_t	*cv;

	Com_Printf("\n------- sound initialization -------\n");

	Cvar_Subsystem( CVAR_SYSTEM_SOUND );
	cv = Cvar_Get ("s_initsound", "1", CVAR_LATCHED);
	if (!cv->integer) {
		Com_Printf ("not initializing.\n");
		Com_Printf("------------------------------------\n");
		Cvar_Subsystem( CVAR_SYSTEM_GENERIC );
		return;
	}

	s_volume = Cvar_Get ("s_volume", "0.7", CVAR_ARCHIVE);
	s_khz = Cvar_Get ("s_khz", "22", CVAR_ARCHIVE|CVAR_LATCHED);
	s_loadas8bit = Cvar_Get ("s_loadas8bit", "0", CVAR_ARCHIVE|CVAR_LATCHED);
	s_mixahead = Cvar_Get ("s_mixahead", "0.2", CVAR_ARCHIVE);
	s_show = Cvar_Get ("s_show", "0", 0);
	s_testsound = Cvar_Get ("s_testsound", "0", 0);
	s_primary = Cvar_Get ("s_primary", "0", CVAR_ARCHIVE|CVAR_LATCHED);	// win32 specific

	s_swapstereo = Cvar_Get( "s_swapstereo", "0", CVAR_ARCHIVE );
	s_ambient = Cvar_Get ("s_ambient", "1", 0);
	s_oldresample = Cvar_Get ("s_oldresample", "0", CVAR_LATCHED);

#ifdef USE_OPENAL
	s_openal_device				= Cvar_Get("s_openal_device",				"",				CVAR_ARCHIVE|CVAR_LATCHED);
	s_openal_dopplerFactor		= Cvar_Get("s_openal_dopplerfactor",		"1",			CVAR_ARCHIVE);
	s_openal_dopplerVelocity	= Cvar_Get("s_openal_dopplervelocity",		"16384",		CVAR_ARCHIVE);
	s_openal_driver				= Cvar_Get("s_openal_driver",				AL_DRIVERNAME,	CVAR_ARCHIVE|CVAR_LATCHED);
	s_openal_errorCheck			= Cvar_Get("s_openal_errorcheck",			"0",			CVAR_ARCHIVE);
	s_openal_maxDistance		= Cvar_Get("s_openal_maxdistance",			"8192",			CVAR_ARCHIVE);
	s_openal_rollOffFactor		= Cvar_Get("s_openal_rollofffactor",		"1",			CVAR_ARCHIVE);
#endif

	Cvar_Subsystem( CVAR_SYSTEM_GENERIC );

#ifdef USE_OPENAL
	alSound = false;
	if (cv->integer == 2) {
		if(ALSnd_Init()) {
			alSound = true;
		} else {
			Com_Printf("Falling back to to normal sound\n");
		}
	}

	s_registration_sequence = 1;

	if (alSound || SNDDMA_Init())
#else
	if (SNDDMA_Init())
#endif
	{
		S_InitScaletable ();

		sound_started = true;
		num_sfx = 0;

		soundtime = 0;
		paintedtime = 0;

		Com_Printf ("sound sampling rate: %i\n", dma.speed);

		S_StopAllSounds ();

		Cmd_AddCommand("play", S_Play_f);
		Cmd_AddCommand("stopsound", S_StopAllSounds);
		Cmd_AddCommand("soundlist", S_SoundList_f);
		Cmd_AddCommand("soundinfo", S_SoundInfo_f);
	}

	Com_Printf("------------------------------------\n");
}
Example #7
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_();
}