bah, forgot these

This commit is contained in:
Bill Currie 2010-08-11 23:46:28 +00:00 committed by Jeff Teunissen
parent 3499f5257f
commit 1c985bc925
6 changed files with 27 additions and 14 deletions

View file

@ -121,9 +121,6 @@ struct sfxbuffer_s {
*/ */
void (*setpos) (sfxbuffer_t *buffer, unsigned int pos); void (*setpos) (sfxbuffer_t *buffer, unsigned int pos);
sfx_t *sfx; //!< owning sfx_t instance sfx_t *sfx; //!< owning sfx_t instance
/** resampler state information
*/
void *state;
/** Sample data. The block at the beginning of the buffer (size depends on /** Sample data. The block at the beginning of the buffer (size depends on
sample size) sample size)
*/ */
@ -137,13 +134,15 @@ struct sfxstream_s {
void *file; //!< handle for "file" representing the stream void *file; //!< handle for "file" representing the stream
wavinfo_t wavinfo; //!< description of sound data wavinfo_t wavinfo; //!< description of sound data
unsigned pos; //!< position of next frame full stream unsigned pos; //!< position of next frame full stream
/** resampler state information */
void *state;
/** Resample raw data into internal format. /** Resample raw data into internal format.
\param sc buffer to write resampled sound (sfxstream_s::buffer) \param sc buffer to write resampled sound (sfxstream_s::buffer)
\param data raw sample data \param data raw sample data
\param length number of frames to resample \param length number of frames to resample
\param prev pointer to end of last resample for smoothing \param prev pointer to end of last resample for smoothing
*/ */
void (*resample)(sfxbuffer_t *, float *, int); int (*resample)(sfxbuffer_t *, float *, int);
/** Read data from the stream. /** Read data from the stream.
\param file handle for "file" representing the stream \param file handle for "file" representing the stream
(sfxstream_s::file) (sfxstream_s::file)

View file

@ -10,6 +10,12 @@ plugin_ldflags= @plugin_ldflags@ -module
plugin_libadd= @plugin_libadd@ plugin_libadd= @plugin_libadd@
EXEEXT= EXEEXT=
noinst_PROGRAMS= testsound
testsound_SOURCES= testsound.c
testsound_LDADD= $(top_builddir)/libs/audio/libQFsound.la
testsound_DEPENDENCIES= $(top_builddir)/libs/audio/libQFsound.la
plugin_LTLIBRARIES= @CD_PLUGIN_TARGETS@ plugin_LTLIBRARIES= @CD_PLUGIN_TARGETS@
noinst_LTLIBRARIES= @CD_PLUGIN_STATIC@ noinst_LTLIBRARIES= @CD_PLUGIN_STATIC@
lib_LTLIBRARIES= @CD_TARGETS@ @SND_TARGETS@ lib_LTLIBRARIES= @CD_TARGETS@ @SND_TARGETS@

View file

@ -386,7 +386,7 @@ s_updateAmbientSounds (void)
if (!snd_ambient) if (!snd_ambient)
return; return;
// calc ambient sound levels // calc ambient sound levels
if (!*snd_render_data.worldmodel) if (!snd_render_data.worldmodel || !*snd_render_data.worldmodel)
return; return;
l = Mod_PointInLeaf (listener_origin, *snd_render_data.worldmodel); l = Mod_PointInLeaf (listener_origin, *snd_render_data.worldmodel);
@ -462,7 +462,8 @@ s_spatialize (channel_t *ch)
ch->oldphase = ch->phase; ch->oldphase = ch->phase;
// anything coming from the view entity will always be full volume // anything coming from the view entity will always be full volume
if (ch->entnum == *snd_render_data.viewentity) { if (!snd_render_data.viewentity
|| ch->entnum == *snd_render_data.viewentity) {
ch->leftvol = ch->master_vol; ch->leftvol = ch->master_vol;
ch->rightvol = ch->master_vol; ch->rightvol = ch->master_vol;
ch->phase = 0; ch->phase = 0;

View file

@ -178,9 +178,18 @@ read_samples (sfxbuffer_t *buffer, int count)
if (stream->resample) { if (stream->resample) {
float *data = alloca (size); float *data = alloca (size);
int c;
if (stream->read (stream->file, data, frames, info) != frames) if (stream->read (stream->file, data, frames, info) != frames)
Sys_Printf ("%s r\n", sfx->name); Sys_Printf ("%s r\n", sfx->name);
stream->resample (buffer, data, frames); c = stream->resample (buffer, data, frames);
if (c < count) {
data = buffer->data + (buffer->head + c - 1) * info->channels;
while (c++ < count) {
memcpy (data + info->channels, data,
info->channels * sizeof (float));
}
}
} else { } else {
float *data = buffer->data + buffer->head * info->channels; float *data = buffer->data + buffer->head * info->channels;
if (stream->read (stream->file, data, frames, info) != frames) if (stream->read (stream->file, data, frames, info) != frames)

View file

@ -84,11 +84,11 @@ SND_Resample (sfxbuffer_t *sc, float *data, int length)
check_buffer_integrity (sc, outwidth, __FUNCTION__); check_buffer_integrity (sc, outwidth, __FUNCTION__);
} }
static void static int
SND_ResampleStream (sfxbuffer_t *sc, float *data, int length) SND_ResampleStream (sfxbuffer_t *sc, float *data, int length)
{ {
SRC_DATA src_data; SRC_DATA src_data;
SRC_STATE *state = (SRC_STATE *) sc->state; SRC_STATE *state = (SRC_STATE *) sc->sfx->data.stream->state;
int outcount; int outcount;
double stepscale; double stepscale;
@ -106,6 +106,7 @@ SND_ResampleStream (sfxbuffer_t *sc, float *data, int length)
src_data.end_of_input = 0; //XXX src_data.end_of_input = 0; //XXX
src_process (state, &src_data); src_process (state, &src_data);
return src_data.output_frames_gen;
} }
void void
@ -130,14 +131,12 @@ SND_SetupResampler (sfxbuffer_t *sc, int streamed)
sfxstream_t *stream = sc->sfx->data.stream; sfxstream_t *stream = sc->sfx->data.stream;
if (snd_shm->speed == inrate) { if (snd_shm->speed == inrate) {
sc->state = 0; stream->state = 0;
stream->resample = 0; stream->resample = 0;
} else { } else {
sc->state = src_new (SRC_LINEAR, info->channels, &err); stream->state = src_new (SRC_LINEAR, info->channels, &err);
stream->resample = SND_ResampleStream; stream->resample = SND_ResampleStream;
} }
} else {
sc->state = 0;
} }
} }

View file

@ -139,7 +139,6 @@ SND_SFX_StreamOpen (sfx_t *sfx, void *file,
memcpy ((byte *) stream->buffer.data + size, "\xde\xad\xbe\xef", 4); memcpy ((byte *) stream->buffer.data + size, "\xde\xad\xbe\xef", 4);
stream->file = file; stream->file = file;
stream->sfx = new_sfx; stream->sfx = new_sfx;
stream->resample = SND_Resample;
stream->read = read; stream->read = read;
stream->seek = seek; stream->seek = seek;