30typedef struct wavinfo_s
138 memset (&info, 0,
sizeof(info));
148 if (!(
data_p && !strncmp((
const char *)
data_p+8,
"WAVE", 4)))
168 Con_Print(
"Microsoft PCM format only\n");
188 if (!strncmp ((
const char *)
data_p + 28,
"mark", 4))
234 int i, len = numsampleframes * sfx->format.channels;
235 if (sfx->format.width == 2)
237 const short *
bufs = (
const short *)sfx->fetcher_data + firstsampleframe * sfx->format.channels;
238 for (
i = 0;
i < len;
i++)
239 outsamplesfloat[
i] =
bufs[
i] * (1.0f / 32768.0f);
243 const signed char *bufb = (
const signed char *)sfx->fetcher_data + firstsampleframe * sfx->format.channels;
244 for (
i = 0;
i < len;
i++)
245 outsamplesfloat[
i] = bufb[
i] * (1.0f / 128.0f);
274 const unsigned char *inb;
278 if (sfx->fetcher !=
NULL)
287 if (memcmp (
data,
"RIFF", 4) || memcmp (
data + 8,
"WAVE", 4))
294 Con_Printf (
"Loading WAV file \"%s\"\n", filename);
299 Con_Printf(
"%s has an unsupported number of channels (%i)\n",sfx->name, info.
channels);
306 sfx->format.speed = info.
rate;
307 sfx->format.width = info.
width;
308 sfx->format.channels = info.
channels;
311 sfx->total_length = info.
samples;
312 sfx->memsize += filesize;
313 len = info.
samples * sfx->format.channels * sfx->format.width;
315 outb = (
unsigned char *)sfx->fetcher_data;
321 for (
i = 0;
i < len;
i += 2)
330 memcpy(outb, inb, len);
336 for (
i = 0;
i < len;
i++)
337 outb[
i] = inb[
i] - 0x80;
341 sfx->loopstart = sfx->total_length;
344 sfx->loopstart =
min(sfx->loopstart, sfx->total_length);
345 sfx->flags &= ~SFXFLAG_STREAMED;
short BuffLittleShort(const unsigned char *buffer)
Extract a little endian 16bit short from the given buffer.
int BuffLittleLong(const unsigned char *buffer)
Extract a little endian 32bit int from the given buffer.
void Con_Print(const char *msg)
Prints to all appropriate console targets, and adds timestamps.
void Con_Printf(const char *fmt,...)
Prints to all appropriate console targets.
unsigned char * FS_LoadFile(const char *path, mempool_t *pool, qbool quiet, fs_offset_t *filesizepointer)
GLint GLint GLint GLsizei GLsizei GLenum format
GLsizeiptr const GLvoid * data
static unsigned char * data_p
static wavinfo_t GetWavinfo(char *name, unsigned char *wav, int wavlength)
static int GetLittleLong(void)
static void FindNextChunk(const char *name)
static short GetLittleShort(void)
static unsigned char * iff_end
static void WAV_FreeSfx(sfx_t *sfx)
const snd_fetcher_t wav_fetcher
static unsigned char * last_chunk
static void FindChunk(const char *name)
static unsigned char * iff_data
qbool S_LoadWavFile(const char *filename, sfx_t *sfx)
static void WAV_GetSamplesFloat(channel_t *ch, sfx_t *sfx, int firstsampleframe, int numsampleframes, float *outsamplesfloat)
#define Mem_Alloc(pool, size)