- char namebuffer[256];
- byte *data;
- wavinfo_t info;
- int len;
- float stepscale;
- sfxcache_t *sc;
- byte stackbuf[1*1024]; // avoid dirtying the cache heap
-
-// see if still in memory
- sc = Cache_Check (&s->cache);
- if (sc)
- return sc;
-
-//Con_Printf ("S_LoadSound: %x\n", (int)stackbuf);
-// load it in
- strcpy(namebuffer, "sound/");
- strcat(namebuffer, s->name);
-
-// Con_Printf ("loading %s\n",namebuffer);
-
- data = COM_LoadStackFile(namebuffer, stackbuf, sizeof(stackbuf), false);
-
- if (!data)
- {
- Con_Printf ("Couldn't load %s\n", namebuffer);
- return NULL;
- }
-
- info = GetWavinfo (s->name, data, com_filesize);
- // LordHavoc: stereo sounds are now allowed (intended for music)
- if (info.channels < 1 || info.channels > 2)
- {
- Con_Printf ("%s has an unsupported number of channels (%i)\n",s->name, info.channels);
- return NULL;
- }
- /*
- if (info.channels != 1)
- {
- Con_Printf ("%s is a stereo sample\n",s->name);
- return NULL;
- }
- */
-
- stepscale = (float)info.rate / shm->speed;
- len = info.samples / stepscale;
-
- len = len * info.width * info.channels;
-
- sc = Cache_Alloc ( &s->cache, len + sizeof(sfxcache_t), s->name);
- if (!sc)
- return NULL;
-
- sc->length = info.samples;
- sc->loopstart = info.loopstart;
- sc->speed = info.rate;
- sc->width = info.width;
- sc->stereo = info.channels == 2;
-
- ResampleSfx (s, sc->speed, sc->width, data + info.dataofs);
-
- return sc;
-}
-
-
-
-/*
-===============================================================================