2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 // snd_dma.c -- main control for any streaming sound output device
27 extern DWORD gSndBufSize;
28 extern LPDIRECTSOUND pDS;
29 extern LPDIRECTSOUNDBUFFER pDSBuf;
38 void S_SoundList(void);
40 void S_StopAllSounds(qboolean clear);
41 void S_StopAllSoundsC(void);
43 void S_ClearBuffer (void);
46 // =======================================================================
47 // Internal sound data & structures
48 // =======================================================================
50 channel_t channels[MAX_CHANNELS];
51 unsigned int total_channels;
54 cvar_t snd_initialized = { CVAR_READONLY, "snd_initialized", "0"};
55 cvar_t snd_streaming = { CVAR_SAVE, "snd_streaming", "1"};
57 // pointer should go away
58 volatile dma_t *shm = 0;
61 vec3_t listener_origin;
62 matrix4x4_t listener_matrix;
63 vec_t sound_nominal_clip_dist=1000.0;
64 mempool_t *snd_mempool;
71 //LordHavoc: increased the client sound limit from 512 to 4096 for the Nehahra movie
73 sfx_t *known_sfx; // allocated [MAX_SFX]
76 sfx_t *ambient_sfx[NUM_AMBIENTS];
78 int sound_started = 0;
80 cvar_t bgmvolume = {CVAR_SAVE, "bgmvolume", "1"};
81 cvar_t volume = {CVAR_SAVE, "volume", "0.7"};
82 cvar_t snd_staticvolume = {CVAR_SAVE, "snd_staticvolume", "1"};
84 cvar_t nosound = {0, "nosound", "0"};
85 cvar_t snd_precache = {0, "snd_precache", "1"};
86 cvar_t bgmbuffer = {0, "bgmbuffer", "4096"};
87 cvar_t ambient_level = {0, "ambient_level", "0.3"};
88 cvar_t ambient_fade = {0, "ambient_fade", "100"};
89 cvar_t snd_noextraupdate = {0, "snd_noextraupdate", "0"};
90 cvar_t snd_show = {0, "snd_show", "0"};
91 cvar_t _snd_mixahead = {CVAR_SAVE, "_snd_mixahead", "0.1"};
92 cvar_t snd_swapstereo = {CVAR_SAVE, "snd_swapstereo", "0"};
95 // ====================================================================
96 // User-setable variables
97 // ====================================================================
101 // Fake dma is a synchronous faking of the DMA progress used for
102 // isolating performance in the renderer. The fakedma_updates is
103 // number of times S_Update() is called per second.
106 qboolean fakedma = false;
107 int fakedma_updates = 15;
110 void S_SoundInfo_f(void)
112 if (!sound_started || !shm)
114 Con_Print("sound system not started\n");
118 Con_Printf("%5d stereo\n", shm->format.channels - 1);
119 Con_Printf("%5d samples\n", shm->samples);
120 Con_Printf("%5d samplepos\n", shm->samplepos);
121 Con_Printf("%5d samplebits\n", shm->format.width * 8);
122 Con_Printf("%5d speed\n", shm->format.speed);
123 Con_Printf("%p dma buffer\n", shm->buffer);
124 Con_Printf("%5u total_channels\n", total_channels);
127 void S_UnloadSounds(void)
130 for (i = 0;i < num_sfx;i++)
131 S_UnloadSound(known_sfx + i);
134 void S_LoadSounds(void)
137 for (i = 0;i < num_sfx;i++)
138 S_LoadSound(known_sfx + i, false);
143 if (!snd_initialized.integer)
147 memset((void *)shm, 0, sizeof(*shm));
149 // create a piece of DMA memory
153 shm->format.width = 2;
154 shm->format.speed = 22050;
155 shm->format.channels = 2;
156 shm->samples = 32768;
158 shm->buffer = Mem_Alloc(snd_mempool, shm->format.channels * shm->samples * shm->format.width);
164 Con_Print("S_Startup: SNDDMA_Init failed.\n");
173 Con_DPrintf("Sound sampling rate: %i\n", shm->format.speed);
177 S_StopAllSounds(true);
180 void S_Shutdown(void)
188 Mem_Free(shm->buffer);
196 void S_Restart_f(void)
209 Con_DPrint("\nSound Initialization\n");
211 Cvar_RegisterVariable(&volume);
212 Cvar_RegisterVariable(&bgmvolume);
213 Cvar_RegisterVariable(&snd_staticvolume);
215 if (COM_CheckParm("-nosound") || COM_CheckParm("-safe"))
218 snd_mempool = Mem_AllocPool("sound", 0, NULL);
220 if (COM_CheckParm("-simsound"))
223 Cmd_AddCommand("play", S_Play);
224 Cmd_AddCommand("play2", S_Play2);
225 Cmd_AddCommand("playvol", S_PlayVol);
226 Cmd_AddCommand("stopsound", S_StopAllSoundsC);
227 Cmd_AddCommand("soundlist", S_SoundList);
228 Cmd_AddCommand("soundinfo", S_SoundInfo_f);
229 Cmd_AddCommand("snd_restart", S_Restart_f);
231 Cvar_RegisterVariable(&nosound);
232 Cvar_RegisterVariable(&snd_precache);
233 Cvar_RegisterVariable(&snd_initialized);
234 Cvar_RegisterVariable(&snd_streaming);
235 Cvar_RegisterVariable(&bgmbuffer);
236 Cvar_RegisterVariable(&ambient_level);
237 Cvar_RegisterVariable(&ambient_fade);
238 Cvar_RegisterVariable(&snd_noextraupdate);
239 Cvar_RegisterVariable(&snd_show);
240 Cvar_RegisterVariable(&_snd_mixahead);
241 Cvar_RegisterVariable(&snd_swapstereo); // LordHavoc: for people with backwards sound wiring
243 Cvar_SetValueQuick(&snd_initialized, true);
245 known_sfx = Mem_Alloc(snd_mempool, MAX_SFX*sizeof(sfx_t));
248 SND_InitScaletable ();
250 ambient_sfx[AMBIENT_WATER] = S_PrecacheSound ("ambience/water1.wav", false, true);
251 ambient_sfx[AMBIENT_SKY] = S_PrecacheSound ("ambience/wind2.wav", false, true);
253 total_channels = MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS; // no statics
254 memset(channels, 0, MAX_CHANNELS * sizeof(channel_t));
260 // =======================================================================
262 // =======================================================================
270 sfx_t *S_GetCached (const char *name, qboolean stdpath)
272 char namebuffer [MAX_QPATH];
276 if (!snd_initialized.integer)
280 Host_Error("S_GetCached: NULL");
282 // Add the default sound directory to the path
283 len = snprintf (namebuffer, sizeof (namebuffer), stdpath ? "sound/%s" : "%s", name);
284 if (len >= sizeof (namebuffer))
285 Host_Error ("S_GetCached: sound name too long (%s)", name);
287 for(i = 0;i < num_sfx;i++)
288 if(!strcmp(known_sfx[i].name, namebuffer))
289 return &known_sfx[i];
300 sfx_t *S_FindName (const char *name, qboolean stdpath)
304 if (!snd_initialized.integer)
307 sfx = S_GetCached (name, stdpath);
309 // If we haven't allocated a sfx_t struct for it yet
312 if (num_sfx == MAX_SFX)
313 Sys_Error ("S_FindName: out of sfx_t");
315 sfx = &known_sfx[num_sfx++];
316 memset (sfx, 0, sizeof(*sfx));
317 snprintf (sfx->name, sizeof (sfx->name), stdpath ? "sound/%s" : "%s", name);
329 void S_TouchSound (const char *name, qboolean stdpath)
333 sfx = S_FindName (name, stdpath);
335 // Set the "used" flag for this sound
337 sfx->flags |= SFXFLAG_USED;
345 Reset the "used" flag of all precached sounds
348 void S_ClearUsed (void)
352 for (i = 0; i < num_sfx; i++)
353 known_sfx[i].flags &= ~SFXFLAG_USED;
361 Free all precached sounds without the "used" flag
364 void S_PurgeUnused (void)
369 for (i = 0; i < num_sfx; i++)
372 if (! (sfx->flags & SFXFLAG_USED))
384 sfx_t *S_PrecacheSound (const char *name, qboolean complain, qboolean stdpath)
388 if (!snd_initialized.integer)
391 sfx = S_FindName (name, stdpath);
393 if (!nosound.integer && snd_precache.integer)
394 S_LoadSound(sfx, complain);
400 //=============================================================================
406 Picks a channel based on priorities, empty slots, number of channels
409 channel_t *SND_PickChannel(int entnum, int entchannel)
416 // Check for replacement sound, or find the best one to replace
418 life_left = 0x7fffffff;
419 for (ch_idx=NUM_AMBIENTS ; ch_idx < NUM_AMBIENTS + MAX_DYNAMIC_CHANNELS ; ch_idx++)
421 ch = &channels[ch_idx];
422 if (entchannel != 0 // channel 0 never overrides
423 && ch->entnum == entnum
424 && (ch->entchannel == entchannel || entchannel == -1) )
425 { // always override sound from same entity
426 first_to_die = ch_idx;
430 // don't let monster sounds override player sounds
431 if (ch->entnum == cl.viewentity && entnum != cl.viewentity && ch->sfx)
434 // don't override looped sounds
435 if ((ch->flags & CHANNELFLAG_FORCELOOP) != 0 ||
436 (ch->sfx != NULL && ch->sfx->loopstart >= 0))
439 if (ch->end - paintedtime < life_left)
441 life_left = ch->end - paintedtime;
442 first_to_die = ch_idx;
446 if (first_to_die == -1)
449 if (channels[first_to_die].sfx)
450 channels[first_to_die].sfx = NULL;
452 return &channels[first_to_die];
459 Spatializes a channel
462 void SND_Spatialize(channel_t *ch, int isstatic)
464 vec_t dist, scale, pan;
467 // anything coming from the view entity will always be full volume
468 // LordHavoc: make sounds with ATTN_NONE have no spatialization
469 if (ch->entnum == cl.viewentity || ch->dist_mult == 0)
471 ch->leftvol = ch->master_vol;
472 ch->rightvol = ch->master_vol;
476 // update sound origin if we know about the entity
477 if (ch->entnum > 0 && cls.state == ca_connected && cl_entities[ch->entnum].state_current.active)
479 //Con_Printf("-- entnum %i origin %f %f %f neworigin %f %f %f\n", ch->entnum, ch->origin[0], ch->origin[1], ch->origin[2], cl_entities[ch->entnum].state_current.origin[0], cl_entities[ch->entnum].state_current.origin[1], cl_entities[ch->entnum].state_current.origin[2]);
480 VectorCopy(cl_entities[ch->entnum].state_current.origin, ch->origin);
481 if (cl_entities[ch->entnum].state_current.modelindex && cl.model_precache[cl_entities[ch->entnum].state_current.modelindex]->soundfromcenter)
482 VectorMAMAM(1.0f, ch->origin, 0.5f, cl.model_precache[cl_entities[ch->entnum].state_current.modelindex]->normalmins, 0.5f, cl.model_precache[cl_entities[ch->entnum].state_current.modelindex]->normalmaxs, ch->origin);
485 // calculate stereo seperation and distance attenuation
486 Matrix4x4_Transform(&listener_matrix, ch->origin, source_vec);
487 dist = VectorNormalizeLength(source_vec);
489 scale = ch->master_vol * (1.0 - (dist * ch->dist_mult));
491 pan = scale * source_vec[1];
492 // calculate the volumes
493 ch->leftvol = (int) (scale + pan);
494 ch->rightvol = (int) (scale - pan);
497 // LordHavoc: allow adjusting volume of static sounds
500 ch->leftvol *= snd_staticvolume.value;
501 ch->rightvol *= snd_staticvolume.value;
505 ch->leftvol = bound(0, ch->leftvol, 255);
506 ch->rightvol = bound(0, ch->rightvol, 255);
510 // =======================================================================
511 // Start a sound effect
512 // =======================================================================
514 int S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation)
516 channel_t *target_chan, *check;
521 if (!sound_started || !sfx || !sfx->fetcher || nosound.integer)
526 // pick a channel to play on
527 target_chan = SND_PickChannel(entnum, entchannel);
532 memset (target_chan, 0, sizeof(*target_chan));
533 VectorCopy(origin, target_chan->origin);
534 target_chan->dist_mult = attenuation / sound_nominal_clip_dist;
535 target_chan->master_vol = vol;
536 target_chan->entnum = entnum;
537 target_chan->entchannel = entchannel;
538 SND_Spatialize(target_chan, false);
540 // LordHavoc: spawn the sound anyway because the player might teleport to it
541 //if (!target_chan->leftvol && !target_chan->rightvol)
542 // return; // not audible at all
545 if (!S_LoadSound (sfx, true))
547 target_chan->sfx = NULL;
548 return -1; // couldn't load the sound's data
551 target_chan->sfx = sfx;
552 target_chan->flags = CHANNELFLAG_NONE;
553 target_chan->pos = 0.0;
554 target_chan->end = paintedtime + sfx->total_length;
555 target_chan->lastptime = paintedtime;
557 // if an identical sound has also been started this frame, offset the pos
558 // a bit to keep it from just making the first one louder
559 check = &channels[NUM_AMBIENTS];
560 for (ch_idx=NUM_AMBIENTS ; ch_idx < NUM_AMBIENTS + MAX_DYNAMIC_CHANNELS ; ch_idx++, check++)
562 if (check == target_chan)
564 if (check->sfx == sfx && !check->pos)
566 // LordHavoc: fixed skip calculations
567 skip = 0.1 * sfx->format.speed;
568 if (skip > sfx->total_length)
569 skip = sfx->total_length;
571 skip = rand() % skip;
572 target_chan->pos += skip;
573 target_chan->end -= skip;
578 return (target_chan - channels);
581 void S_StopChannel (unsigned int channel_ind)
585 if (channel_ind >= total_channels)
588 ch = &channels[channel_ind];
591 if (ch->sfx->fetcher != NULL)
593 snd_fetcher_end_t fetcher_end = ch->sfx->fetcher->end;
594 if (fetcher_end != NULL)
602 void S_PauseChannel (unsigned int channel_ind, qboolean toggle)
605 channels[channel_ind].flags |= CHANNELFLAG_PAUSED;
607 channels[channel_ind].flags &= ~CHANNELFLAG_PAUSED;
610 void S_LoopChannel (unsigned int channel_ind, qboolean toggle)
613 channels[channel_ind].flags |= CHANNELFLAG_FORCELOOP;
615 channels[channel_ind].flags &= ~CHANNELFLAG_FORCELOOP;
618 void S_StopSound(int entnum, int entchannel)
622 for (i = 0; i < MAX_DYNAMIC_CHANNELS; i++)
623 if (channels[i].entnum == entnum && channels[i].entchannel == entchannel)
630 void S_StopAllSounds(qboolean clear)
634 for (i = 0; i < total_channels; i++)
637 total_channels = MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS; // no statics
638 memset(channels, 0, MAX_CHANNELS * sizeof(channel_t));
644 void S_StopAllSoundsC(void)
646 S_StopAllSounds(true);
649 void S_PauseGameSounds (void)
653 for (i = 0; i < total_channels; i++)
658 if (ch->sfx != NULL && ! (ch->flags & CHANNELFLAG_LOCALSOUND))
659 ch->flags |= CHANNELFLAG_PAUSED;
663 void S_ResumeGameSounds (void)
667 for (i = 0; i < total_channels; i++)
672 if (ch->sfx != NULL && ! (ch->flags & CHANNELFLAG_LOCALSOUND))
673 ch->flags &= ~CHANNELFLAG_PAUSED;
677 void S_SetChannelVolume (unsigned int ch_ind, float fvol)
679 channels[ch_ind].master_vol = fvol * 255;
683 void S_ClearBuffer(void)
687 if (!sound_started || !shm)
690 if (shm->format.width == 1)
705 while ((hresult = pDSBuf->lpVtbl->Lock(pDSBuf, 0, gSndBufSize, (LPVOID*)&pData, &dwSize, NULL, NULL, 0)) != DS_OK)
707 if (hresult != DSERR_BUFFERLOST)
709 Con_Print("S_ClearBuffer: DS::Lock Sound Buffer Failed\n");
716 Con_Print("S_ClearBuffer: DS: couldn't restore buffer\n");
722 memset(pData, clear, shm->samples * shm->format.width);
724 pDSBuf->lpVtbl->Unlock(pDSBuf, pData, dwSize, NULL, 0);
731 int setsize = shm->samples * shm->format.width;
732 char *buf = shm->buffer;
737 // on i586/i686 optimized versions of glibc, glibc *wrongly* IMO,
738 // reads the memory area before writing to it causing a seg fault
739 // since the memory is PROT_WRITE only and not PROT_READ|PROT_WRITE
740 // memset(shm->buffer, clear, shm->samples * shm->samplebits/8);
750 void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation)
757 if (total_channels == MAX_CHANNELS)
759 Con_Print("total_channels == MAX_CHANNELS\n");
763 if (!S_LoadSound (sfx, true))
766 if (sfx->loopstart == -1)
767 Con_DPrintf("Quake compatibility warning: Static sound \"%s\" is not looped\n", sfx->name);
769 ss = &channels[total_channels++];
770 memset(ss, 0, sizeof(*ss));
771 ss->flags = CHANNELFLAG_FORCELOOP;
773 VectorCopy (origin, ss->origin);
774 ss->master_vol = vol;
775 ss->dist_mult = (attenuation/64) / sound_nominal_clip_dist;
776 ss->end = paintedtime + sfx->total_length;
777 ss->lastptime = paintedtime;
779 SND_Spatialize (ss, true);
783 //=============================================================================
787 S_UpdateAmbientSounds
790 void S_UpdateAmbientSounds (void)
795 qbyte ambientlevels[NUM_AMBIENTS];
797 // LordHavoc: kill ambient sounds until proven otherwise
798 for (ambient_channel = 0 ; ambient_channel < NUM_AMBIENTS;ambient_channel++)
799 channels[ambient_channel].sfx = NULL;
801 if (ambient_level.value <= 0 || !cl.worldmodel || !cl.worldmodel->brush.AmbientSoundLevelsForPoint)
804 cl.worldmodel->brush.AmbientSoundLevelsForPoint(cl.worldmodel, listener_origin, ambientlevels, sizeof(ambientlevels));
806 // calc ambient sound levels
807 for (ambient_channel = 0 ; ambient_channel< NUM_AMBIENTS ; ambient_channel++)
809 if (ambient_sfx[ambient_channel] &&
810 (ambient_sfx[ambient_channel]->flags & SFXFLAG_SILENTLYMISSING))
812 chan = &channels[ambient_channel];
813 chan->flags |= CHANNELFLAG_FORCELOOP;
814 chan->sfx = ambient_sfx[ambient_channel];
816 vol = ambient_level.value * ambientlevels[ambient_channel];
820 // don't adjust volume too fast
821 if (chan->master_vol < vol)
823 chan->master_vol += host_realframetime * ambient_fade.value;
824 if (chan->master_vol > vol)
825 chan->master_vol = vol;
827 else if (chan->master_vol > vol)
829 chan->master_vol -= host_realframetime * ambient_fade.value;
830 if (chan->master_vol < vol)
831 chan->master_vol = vol;
834 chan->leftvol = chan->rightvol = chan->master_vol;
843 Called once each time through the main loop
846 void S_Update(const matrix4x4_t *listenermatrix)
848 unsigned int i, j, total;
849 channel_t *ch, *combine;
851 if (!snd_initialized.integer || (snd_blocked > 0))
854 Matrix4x4_Invert_Simple(&listener_matrix, listenermatrix);
855 Matrix4x4_OriginFromMatrix(listenermatrix, listener_origin);
857 // update general area ambient sound sources
858 S_UpdateAmbientSounds ();
862 // update spatialization for static and dynamic sounds
863 ch = channels+NUM_AMBIENTS;
864 for (i=NUM_AMBIENTS ; i<total_channels; i++, ch++)
868 SND_Spatialize(ch, i >= MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS); // respatialize channel
869 if (!ch->leftvol && !ch->rightvol)
872 // try to combine static sounds with a previous channel of the same
873 // sound effect so we don't mix five torches every frame
875 if (i > MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS)
877 // see if it can just use the last one
878 if (combine && combine->sfx == ch->sfx)
880 combine->leftvol += ch->leftvol;
881 combine->rightvol += ch->rightvol;
882 ch->leftvol = ch->rightvol = 0;
886 combine = channels+MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS;
887 for (j=MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS ; j<i; j++, combine++)
888 if (combine->sfx == ch->sfx)
891 if (j == total_channels)
897 combine->leftvol += ch->leftvol;
898 combine->rightvol += ch->rightvol;
899 ch->leftvol = ch->rightvol = 0;
909 if (snd_show.integer)
913 for (i=0 ; i<total_channels; i++, ch++)
914 if (ch->sfx && (ch->leftvol || ch->rightvol) )
917 Con_Printf("----(%u)----\n", total);
924 void GetSoundtime(void)
928 static int oldsamplepos;
931 fullsamples = shm->samples / shm->format.channels;
933 // it is possible to miscount buffers if it has wrapped twice between
934 // calls to S_Update. Oh well.
935 samplepos = SNDDMA_GetDMAPos();
937 if (samplepos < oldsamplepos)
939 buffers++; // buffer wrapped
941 if (paintedtime > 0x40000000)
942 { // time to chop things off to avoid 32 bit limits
944 paintedtime = fullsamples;
945 S_StopAllSounds (true);
948 oldsamplepos = samplepos;
950 soundtime = buffers * fullsamples + samplepos / shm->format.channels;
953 void IN_Accumulate (void);
955 void S_ExtraUpdate (void)
962 if (snd_noextraupdate.integer)
963 return; // don't pollute timings
972 if (!sound_started || (snd_blocked > 0))
978 // check to make sure that we haven't overshot
979 if (paintedtime < soundtime)
980 paintedtime = soundtime;
982 // mix ahead of current position
983 endtime = soundtime + _snd_mixahead.value * shm->format.speed;
984 samps = shm->samples >> (shm->format.channels - 1);
985 if (endtime > (unsigned int)(soundtime + samps))
986 endtime = soundtime + samps;
989 // if the buffer was lost or stopped, restore it and/or restart it
995 if (pDSBuf->lpVtbl->GetStatus (pDSBuf, &dwStatus) != DS_OK)
996 Con_Print("Couldn't get sound buffer status\n");
998 if (dwStatus & DSBSTATUS_BUFFERLOST)
999 pDSBuf->lpVtbl->Restore (pDSBuf);
1001 if (!(dwStatus & DSBSTATUS_PLAYING))
1002 pDSBuf->lpVtbl->Play(pDSBuf, 0, 0, DSBPLAY_LOOPING);
1007 S_PaintChannels (endtime);
1013 ===============================================================================
1017 ===============================================================================
1020 static void S_Play_Common(float fvol, float attenuation)
1027 while (i<Cmd_Argc())
1029 if (!strrchr(Cmd_Argv(i), '.'))
1030 snprintf(name, sizeof(name), "%s.wav", Cmd_Argv(i));
1032 strlcpy(name, Cmd_Argv(i), sizeof(name));
1033 sfx = S_PrecacheSound(name, true, true);
1035 // If we need to get the volume from the command line
1038 fvol = atof(Cmd_Argv(i+1));
1044 ch_ind = S_StartSound(-1, 0, sfx, listener_origin, fvol, attenuation);
1046 channels[ch_ind].flags |= CHANNELFLAG_LOCALSOUND;
1052 S_Play_Common (1.0f, 1.0f);
1057 S_Play_Common (1.0f, 0.0f);
1060 void S_PlayVol(void)
1062 S_Play_Common (-1.0f, 0.0f);
1065 void S_SoundList(void)
1072 for (sfx=known_sfx, i=0 ; i<num_sfx ; i++, sfx++)
1074 if (sfx->fetcher != NULL)
1076 size = sfx->mempool->totalsize;
1078 Con_Printf ("%c%c(%2db, %6s) %8i : %s\n",
1079 (sfx->loopstart >= 0) ? 'L' : ' ',
1080 (sfx->flags & SFXFLAG_STREAMED) ? 'S' : ' ',
1081 sfx->format.width * 8,
1082 (sfx->format.channels == 2) ? "stereo" : "mono",
1087 Con_Printf("Total resident: %i\n", total);
1091 void S_LocalSound (const char *sound, qboolean stdpath)
1096 if (!snd_initialized.integer || nosound.integer)
1099 sfx = S_PrecacheSound (sound, true, stdpath);
1102 Con_Printf("S_LocalSound: can't precache %s\n", sound);
1106 ch_ind = S_StartSound (cl.viewentity, 0, sfx, vec3_origin, 1, 1);
1108 channels[ch_ind].flags |= CHANNELFLAG_LOCALSOUND;