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 // COMMANDLINEOPTION: Sound: -nosound disables sound (including CD audio)
216 if (COM_CheckParm("-nosound") || COM_CheckParm("-safe"))
219 snd_mempool = Mem_AllocPool("sound", 0, NULL);
221 // COMMANDLINEOPTION: Sound: -simsound runs sound mixing but with no output
222 if (COM_CheckParm("-simsound"))
225 Cmd_AddCommand("play", S_Play);
226 Cmd_AddCommand("play2", S_Play2);
227 Cmd_AddCommand("playvol", S_PlayVol);
228 Cmd_AddCommand("stopsound", S_StopAllSoundsC);
229 Cmd_AddCommand("soundlist", S_SoundList);
230 Cmd_AddCommand("soundinfo", S_SoundInfo_f);
231 Cmd_AddCommand("snd_restart", S_Restart_f);
233 Cvar_RegisterVariable(&nosound);
234 Cvar_RegisterVariable(&snd_precache);
235 Cvar_RegisterVariable(&snd_initialized);
236 Cvar_RegisterVariable(&snd_streaming);
237 Cvar_RegisterVariable(&bgmbuffer);
238 Cvar_RegisterVariable(&ambient_level);
239 Cvar_RegisterVariable(&ambient_fade);
240 Cvar_RegisterVariable(&snd_noextraupdate);
241 Cvar_RegisterVariable(&snd_show);
242 Cvar_RegisterVariable(&_snd_mixahead);
243 Cvar_RegisterVariable(&snd_swapstereo); // LordHavoc: for people with backwards sound wiring
245 Cvar_SetValueQuick(&snd_initialized, true);
247 known_sfx = Mem_Alloc(snd_mempool, MAX_SFX*sizeof(sfx_t));
250 SND_InitScaletable ();
252 ambient_sfx[AMBIENT_WATER] = S_PrecacheSound ("ambience/water1.wav", false, true);
253 ambient_sfx[AMBIENT_SKY] = S_PrecacheSound ("ambience/wind2.wav", false, true);
255 total_channels = MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS; // no statics
256 memset(channels, 0, MAX_CHANNELS * sizeof(channel_t));
262 // =======================================================================
264 // =======================================================================
272 sfx_t *S_GetCached (const char *name, qboolean stdpath)
274 char namebuffer [MAX_QPATH];
278 if (!snd_initialized.integer)
282 Host_Error("S_GetCached: NULL");
284 // Add the default sound directory to the path
285 len = snprintf (namebuffer, sizeof (namebuffer), stdpath ? "sound/%s" : "%s", name);
286 if (len >= sizeof (namebuffer))
287 Host_Error ("S_GetCached: sound name too long (%s)", name);
289 for(i = 0;i < num_sfx;i++)
290 if(!strcmp(known_sfx[i].name, namebuffer))
291 return &known_sfx[i];
302 sfx_t *S_FindName (const char *name, qboolean stdpath)
306 if (!snd_initialized.integer)
309 sfx = S_GetCached (name, stdpath);
311 // If we haven't allocated a sfx_t struct for it yet
314 if (num_sfx == MAX_SFX)
315 Sys_Error ("S_FindName: out of sfx_t");
317 sfx = &known_sfx[num_sfx++];
318 memset (sfx, 0, sizeof(*sfx));
319 snprintf (sfx->name, sizeof (sfx->name), stdpath ? "sound/%s" : "%s", name);
331 void S_TouchSound (const char *name, qboolean stdpath)
335 sfx = S_FindName (name, stdpath);
337 // Set the "used" flag for this sound
339 sfx->flags |= SFXFLAG_USED;
347 Reset the "used" flag of all precached sounds
350 void S_ClearUsed (void)
354 for (i = 0; i < num_sfx; i++)
355 known_sfx[i].flags &= ~SFXFLAG_USED;
363 Free all precached sounds without the "used" flag
366 void S_PurgeUnused (void)
371 for (i = 0; i < num_sfx; i++)
374 if (! (sfx->flags & SFXFLAG_USED))
386 sfx_t *S_PrecacheSound (const char *name, qboolean complain, qboolean stdpath)
390 if (!snd_initialized.integer)
393 sfx = S_FindName (name, stdpath);
395 if (!nosound.integer && snd_precache.integer)
396 S_LoadSound(sfx, complain);
402 //=============================================================================
408 Picks a channel based on priorities, empty slots, number of channels
411 channel_t *SND_PickChannel(int entnum, int entchannel)
418 // Check for replacement sound, or find the best one to replace
420 life_left = 0x7fffffff;
421 for (ch_idx=NUM_AMBIENTS ; ch_idx < NUM_AMBIENTS + MAX_DYNAMIC_CHANNELS ; ch_idx++)
423 ch = &channels[ch_idx];
424 if (entchannel != 0 // channel 0 never overrides
425 && ch->entnum == entnum
426 && (ch->entchannel == entchannel || entchannel == -1) )
427 { // always override sound from same entity
428 first_to_die = ch_idx;
432 // don't let monster sounds override player sounds
433 if (ch->entnum == cl.viewentity && entnum != cl.viewentity && ch->sfx)
436 // don't override looped sounds
437 if ((ch->flags & CHANNELFLAG_FORCELOOP) != 0 ||
438 (ch->sfx != NULL && ch->sfx->loopstart >= 0))
441 if (ch->end - paintedtime < life_left)
443 life_left = ch->end - paintedtime;
444 first_to_die = ch_idx;
448 if (first_to_die == -1)
451 if (channels[first_to_die].sfx)
452 channels[first_to_die].sfx = NULL;
454 return &channels[first_to_die];
461 Spatializes a channel
464 void SND_Spatialize(channel_t *ch, int isstatic)
466 vec_t dist, scale, pan;
469 // anything coming from the view entity will always be full volume
470 // LordHavoc: make sounds with ATTN_NONE have no spatialization
471 if (ch->entnum == cl.viewentity || ch->dist_mult == 0)
473 ch->leftvol = ch->master_vol;
474 ch->rightvol = ch->master_vol;
478 // update sound origin if we know about the entity
479 if (ch->entnum > 0 && cls.state == ca_connected && cl_entities[ch->entnum].state_current.active)
481 //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]);
482 VectorCopy(cl_entities[ch->entnum].state_current.origin, ch->origin);
483 if (cl_entities[ch->entnum].state_current.modelindex && cl.model_precache[cl_entities[ch->entnum].state_current.modelindex]->soundfromcenter)
484 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);
487 // calculate stereo seperation and distance attenuation
488 Matrix4x4_Transform(&listener_matrix, ch->origin, source_vec);
489 dist = VectorNormalizeLength(source_vec);
491 scale = ch->master_vol * (1.0 - (dist * ch->dist_mult));
493 pan = scale * source_vec[1];
494 // calculate the volumes
495 ch->leftvol = (int) (scale + pan);
496 ch->rightvol = (int) (scale - pan);
499 // LordHavoc: allow adjusting volume of static sounds
502 ch->leftvol *= snd_staticvolume.value;
503 ch->rightvol *= snd_staticvolume.value;
507 ch->leftvol = bound(0, ch->leftvol, 255);
508 ch->rightvol = bound(0, ch->rightvol, 255);
512 // =======================================================================
513 // Start a sound effect
514 // =======================================================================
516 int S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation)
518 channel_t *target_chan, *check;
523 if (!sound_started || !sfx || !sfx->fetcher || nosound.integer)
528 // pick a channel to play on
529 target_chan = SND_PickChannel(entnum, entchannel);
534 memset (target_chan, 0, sizeof(*target_chan));
535 VectorCopy(origin, target_chan->origin);
536 target_chan->dist_mult = attenuation / sound_nominal_clip_dist;
537 target_chan->master_vol = vol;
538 target_chan->entnum = entnum;
539 target_chan->entchannel = entchannel;
540 SND_Spatialize(target_chan, false);
542 // LordHavoc: spawn the sound anyway because the player might teleport to it
543 //if (!target_chan->leftvol && !target_chan->rightvol)
544 // return; // not audible at all
547 if (!S_LoadSound (sfx, true))
549 target_chan->sfx = NULL;
550 return -1; // couldn't load the sound's data
553 target_chan->sfx = sfx;
554 target_chan->flags = CHANNELFLAG_NONE;
555 target_chan->pos = 0.0;
556 target_chan->end = paintedtime + sfx->total_length;
557 target_chan->lastptime = paintedtime;
559 // if an identical sound has also been started this frame, offset the pos
560 // a bit to keep it from just making the first one louder
561 check = &channels[NUM_AMBIENTS];
562 for (ch_idx=NUM_AMBIENTS ; ch_idx < NUM_AMBIENTS + MAX_DYNAMIC_CHANNELS ; ch_idx++, check++)
564 if (check == target_chan)
566 if (check->sfx == sfx && !check->pos)
568 // LordHavoc: fixed skip calculations
569 skip = 0.1 * sfx->format.speed;
570 if (skip > sfx->total_length)
571 skip = sfx->total_length;
573 skip = rand() % skip;
574 target_chan->pos += skip;
575 target_chan->end -= skip;
580 return (target_chan - channels);
583 void S_StopChannel (unsigned int channel_ind)
587 if (channel_ind >= total_channels)
590 ch = &channels[channel_ind];
593 if (ch->sfx->fetcher != NULL)
595 snd_fetcher_end_t fetcher_end = ch->sfx->fetcher->end;
596 if (fetcher_end != NULL)
604 void S_PauseChannel (unsigned int channel_ind, qboolean toggle)
607 channels[channel_ind].flags |= CHANNELFLAG_PAUSED;
609 channels[channel_ind].flags &= ~CHANNELFLAG_PAUSED;
612 void S_LoopChannel (unsigned int channel_ind, qboolean toggle)
615 channels[channel_ind].flags |= CHANNELFLAG_FORCELOOP;
617 channels[channel_ind].flags &= ~CHANNELFLAG_FORCELOOP;
620 void S_StopSound(int entnum, int entchannel)
624 for (i = 0; i < MAX_DYNAMIC_CHANNELS; i++)
625 if (channels[i].entnum == entnum && channels[i].entchannel == entchannel)
632 void S_StopAllSounds(qboolean clear)
636 for (i = 0; i < total_channels; i++)
639 total_channels = MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS; // no statics
640 memset(channels, 0, MAX_CHANNELS * sizeof(channel_t));
646 void S_StopAllSoundsC(void)
648 S_StopAllSounds(true);
651 void S_PauseGameSounds (void)
655 for (i = 0; i < total_channels; i++)
660 if (ch->sfx != NULL && ! (ch->flags & CHANNELFLAG_LOCALSOUND))
661 ch->flags |= CHANNELFLAG_PAUSED;
665 void S_ResumeGameSounds (void)
669 for (i = 0; i < total_channels; i++)
674 if (ch->sfx != NULL && ! (ch->flags & CHANNELFLAG_LOCALSOUND))
675 ch->flags &= ~CHANNELFLAG_PAUSED;
679 void S_SetChannelVolume (unsigned int ch_ind, float fvol)
681 channels[ch_ind].master_vol = fvol * 255;
685 void S_ClearBuffer(void)
689 if (!sound_started || !shm)
692 if (shm->format.width == 1)
707 while ((hresult = pDSBuf->lpVtbl->Lock(pDSBuf, 0, gSndBufSize, (LPVOID*)&pData, &dwSize, NULL, NULL, 0)) != DS_OK)
709 if (hresult != DSERR_BUFFERLOST)
711 Con_Print("S_ClearBuffer: DS::Lock Sound Buffer Failed\n");
718 Con_Print("S_ClearBuffer: DS: couldn't restore buffer\n");
724 memset(pData, clear, shm->samples * shm->format.width);
726 pDSBuf->lpVtbl->Unlock(pDSBuf, pData, dwSize, NULL, 0);
733 int setsize = shm->samples * shm->format.width;
734 char *buf = shm->buffer;
739 // on i586/i686 optimized versions of glibc, glibc *wrongly* IMO,
740 // reads the memory area before writing to it causing a seg fault
741 // since the memory is PROT_WRITE only and not PROT_READ|PROT_WRITE
742 // memset(shm->buffer, clear, shm->samples * shm->samplebits/8);
752 void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation)
759 if (total_channels == MAX_CHANNELS)
761 Con_Print("total_channels == MAX_CHANNELS\n");
765 if (!S_LoadSound (sfx, true))
768 if (sfx->loopstart == -1)
769 Con_DPrintf("Quake compatibility warning: Static sound \"%s\" is not looped\n", sfx->name);
771 ss = &channels[total_channels++];
772 memset(ss, 0, sizeof(*ss));
773 ss->flags = CHANNELFLAG_FORCELOOP;
775 VectorCopy (origin, ss->origin);
776 ss->master_vol = vol;
777 ss->dist_mult = (attenuation/64) / sound_nominal_clip_dist;
778 ss->end = paintedtime + sfx->total_length;
779 ss->lastptime = paintedtime;
781 SND_Spatialize (ss, true);
785 //=============================================================================
789 S_UpdateAmbientSounds
792 void S_UpdateAmbientSounds (void)
797 qbyte ambientlevels[NUM_AMBIENTS];
799 // LordHavoc: kill ambient sounds until proven otherwise
800 for (ambient_channel = 0 ; ambient_channel < NUM_AMBIENTS;ambient_channel++)
801 channels[ambient_channel].sfx = NULL;
803 if (ambient_level.value <= 0 || !cl.worldmodel || !cl.worldmodel->brush.AmbientSoundLevelsForPoint)
806 cl.worldmodel->brush.AmbientSoundLevelsForPoint(cl.worldmodel, listener_origin, ambientlevels, sizeof(ambientlevels));
808 // calc ambient sound levels
809 for (ambient_channel = 0 ; ambient_channel< NUM_AMBIENTS ; ambient_channel++)
811 if (ambient_sfx[ambient_channel] &&
812 (ambient_sfx[ambient_channel]->flags & SFXFLAG_SILENTLYMISSING))
814 chan = &channels[ambient_channel];
815 chan->flags |= CHANNELFLAG_FORCELOOP;
816 chan->sfx = ambient_sfx[ambient_channel];
818 vol = ambient_level.value * ambientlevels[ambient_channel];
822 // don't adjust volume too fast
823 if (chan->master_vol < vol)
825 chan->master_vol += host_realframetime * ambient_fade.value;
826 if (chan->master_vol > vol)
827 chan->master_vol = vol;
829 else if (chan->master_vol > vol)
831 chan->master_vol -= host_realframetime * ambient_fade.value;
832 if (chan->master_vol < vol)
833 chan->master_vol = vol;
836 chan->leftvol = chan->rightvol = chan->master_vol;
845 Called once each time through the main loop
848 void S_Update(const matrix4x4_t *listenermatrix)
850 unsigned int i, j, total;
851 channel_t *ch, *combine;
853 if (!snd_initialized.integer || (snd_blocked > 0))
856 Matrix4x4_Invert_Simple(&listener_matrix, listenermatrix);
857 Matrix4x4_OriginFromMatrix(listenermatrix, listener_origin);
859 // update general area ambient sound sources
860 S_UpdateAmbientSounds ();
864 // update spatialization for static and dynamic sounds
865 ch = channels+NUM_AMBIENTS;
866 for (i=NUM_AMBIENTS ; i<total_channels; i++, ch++)
870 SND_Spatialize(ch, i >= MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS); // respatialize channel
871 if (!ch->leftvol && !ch->rightvol)
874 // try to combine static sounds with a previous channel of the same
875 // sound effect so we don't mix five torches every frame
877 if (i > MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS)
879 // see if it can just use the last one
880 if (combine && combine->sfx == ch->sfx)
882 combine->leftvol += ch->leftvol;
883 combine->rightvol += ch->rightvol;
884 ch->leftvol = ch->rightvol = 0;
888 combine = channels+MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS;
889 for (j=MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS ; j<i; j++, combine++)
890 if (combine->sfx == ch->sfx)
893 if (j == total_channels)
899 combine->leftvol += ch->leftvol;
900 combine->rightvol += ch->rightvol;
901 ch->leftvol = ch->rightvol = 0;
911 if (snd_show.integer)
915 for (i=0 ; i<total_channels; i++, ch++)
916 if (ch->sfx && (ch->leftvol || ch->rightvol) )
919 Con_Printf("----(%u)----\n", total);
926 void GetSoundtime(void)
930 static int oldsamplepos;
933 fullsamples = shm->samples / shm->format.channels;
935 // it is possible to miscount buffers if it has wrapped twice between
936 // calls to S_Update. Oh well.
937 samplepos = SNDDMA_GetDMAPos();
939 if (samplepos < oldsamplepos)
941 buffers++; // buffer wrapped
943 if (paintedtime > 0x40000000)
944 { // time to chop things off to avoid 32 bit limits
946 paintedtime = fullsamples;
947 S_StopAllSounds (true);
950 oldsamplepos = samplepos;
952 soundtime = buffers * fullsamples + samplepos / shm->format.channels;
955 void IN_Accumulate (void);
957 void S_ExtraUpdate (void)
964 if (snd_noextraupdate.integer)
965 return; // don't pollute timings
974 if (!sound_started || (snd_blocked > 0))
980 // check to make sure that we haven't overshot
981 if (paintedtime < soundtime)
982 paintedtime = soundtime;
984 // mix ahead of current position
985 endtime = soundtime + _snd_mixahead.value * shm->format.speed;
986 samps = shm->samples >> (shm->format.channels - 1);
987 if (endtime > (unsigned int)(soundtime + samps))
988 endtime = soundtime + samps;
991 // if the buffer was lost or stopped, restore it and/or restart it
997 if (pDSBuf->lpVtbl->GetStatus (pDSBuf, &dwStatus) != DS_OK)
998 Con_Print("Couldn't get sound buffer status\n");
1000 if (dwStatus & DSBSTATUS_BUFFERLOST)
1001 pDSBuf->lpVtbl->Restore (pDSBuf);
1003 if (!(dwStatus & DSBSTATUS_PLAYING))
1004 pDSBuf->lpVtbl->Play(pDSBuf, 0, 0, DSBPLAY_LOOPING);
1009 S_PaintChannels (endtime);
1015 ===============================================================================
1019 ===============================================================================
1022 static void S_Play_Common(float fvol, float attenuation)
1029 while (i<Cmd_Argc())
1031 if (!strrchr(Cmd_Argv(i), '.'))
1032 snprintf(name, sizeof(name), "%s.wav", Cmd_Argv(i));
1034 strlcpy(name, Cmd_Argv(i), sizeof(name));
1035 sfx = S_PrecacheSound(name, true, true);
1037 // If we need to get the volume from the command line
1040 fvol = atof(Cmd_Argv(i+1));
1046 ch_ind = S_StartSound(-1, 0, sfx, listener_origin, fvol, attenuation);
1048 channels[ch_ind].flags |= CHANNELFLAG_LOCALSOUND;
1054 S_Play_Common (1.0f, 1.0f);
1059 S_Play_Common (1.0f, 0.0f);
1062 void S_PlayVol(void)
1064 S_Play_Common (-1.0f, 0.0f);
1067 void S_SoundList(void)
1074 for (sfx=known_sfx, i=0 ; i<num_sfx ; i++, sfx++)
1076 if (sfx->fetcher != NULL)
1078 size = sfx->mempool->totalsize;
1080 Con_Printf ("%c%c(%2db, %6s) %8i : %s\n",
1081 (sfx->loopstart >= 0) ? 'L' : ' ',
1082 (sfx->flags & SFXFLAG_STREAMED) ? 'S' : ' ',
1083 sfx->format.width * 8,
1084 (sfx->format.channels == 2) ? "stereo" : "mono",
1089 Con_Printf("Total resident: %i\n", total);
1093 void S_LocalSound (const char *sound, qboolean stdpath)
1098 if (!snd_initialized.integer || nosound.integer)
1101 sfx = S_PrecacheSound (sound, true, stdpath);
1104 Con_Printf("S_LocalSound: can't precache %s\n", sound);
1108 ch_ind = S_StartSound (cl.viewentity, 0, sfx, vec3_origin, 1, 1);
1110 channels[ch_ind].flags |= CHANNELFLAG_LOCALSOUND;