mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-01-20 16:31:19 +00:00
Einige fixes für das Soundsystem
This commit is contained in:
parent
67ef502a93
commit
f20f8bddf4
4 changed files with 117 additions and 122 deletions
|
@ -53,9 +53,9 @@ vec3_t listener_forward;
|
||||||
vec3_t listener_right;
|
vec3_t listener_right;
|
||||||
vec3_t listener_up;
|
vec3_t listener_up;
|
||||||
|
|
||||||
qboolean s_registering;
|
static qboolean s_registering;
|
||||||
|
|
||||||
int soundtime;
|
static int soundtime;
|
||||||
int paintedtime;
|
int paintedtime;
|
||||||
|
|
||||||
/* during registration it is possible to have more sounds
|
/* during registration it is possible to have more sounds
|
||||||
|
@ -77,8 +77,8 @@ cvar_t *s_volume;
|
||||||
cvar_t *s_testsound;
|
cvar_t *s_testsound;
|
||||||
cvar_t *s_loadas8bit;
|
cvar_t *s_loadas8bit;
|
||||||
cvar_t *s_khz;
|
cvar_t *s_khz;
|
||||||
cvar_t *s_show;
|
|
||||||
cvar_t *s_mixahead;
|
cvar_t *s_mixahead;
|
||||||
|
cvar_t *s_show;
|
||||||
|
|
||||||
int s_rawend;
|
int s_rawend;
|
||||||
portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES];
|
portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES];
|
||||||
|
@ -98,12 +98,11 @@ void S_SoundInfo_f(void) {
|
||||||
Com_Printf("%5d samplebits\n", dma.samplebits);
|
Com_Printf("%5d samplebits\n", dma.samplebits);
|
||||||
Com_Printf("%5d submission_chunk\n", dma.submission_chunk);
|
Com_Printf("%5d submission_chunk\n", dma.submission_chunk);
|
||||||
Com_Printf("%5d speed\n", dma.speed);
|
Com_Printf("%5d speed\n", dma.speed);
|
||||||
Com_Printf("0x%x dma buffer\n", dma.buffer);
|
Com_Printf("%p dma buffer\n", dma.buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void S_Init (void) {
|
void S_Init (void) {
|
||||||
cvar_t *cv;
|
cvar_t *cv;
|
||||||
s_pendingplays.next = NULL;
|
|
||||||
|
|
||||||
Com_Printf("\n------- sound initialization -------\n");
|
Com_Printf("\n------- sound initialization -------\n");
|
||||||
|
|
||||||
|
@ -141,7 +140,6 @@ void S_Init (void) {
|
||||||
Com_Printf ("sound sampling rate: %i\n", dma.speed);
|
Com_Printf ("sound sampling rate: %i\n", dma.speed);
|
||||||
|
|
||||||
S_StopAllSounds ();
|
S_StopAllSounds ();
|
||||||
|
|
||||||
OGG_Init();
|
OGG_Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,32 +156,27 @@ void S_Shutdown(void) {
|
||||||
if (!sound_started)
|
if (!sound_started)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
OGG_Shutdown();
|
// free all sounds
|
||||||
|
for (i=0, sfx=known_sfx ; i < num_sfx ; i++,sfx++)
|
||||||
Cmd_RemoveCommand("ogg_init");
|
{
|
||||||
Cmd_RemoveCommand("ogg_shutdown");
|
|
||||||
|
|
||||||
SNDDMA_Shutdown();
|
|
||||||
|
|
||||||
sound_started = 0;
|
|
||||||
|
|
||||||
Cmd_RemoveCommand("play");
|
|
||||||
Cmd_RemoveCommand("stopsound");
|
|
||||||
Cmd_RemoveCommand("soundlist");
|
|
||||||
Cmd_RemoveCommand("soundinfo");
|
|
||||||
|
|
||||||
/* free all sounds */
|
|
||||||
for (i=0, sfx=known_sfx ; i < num_sfx ; i++,sfx++) {
|
|
||||||
if (!sfx->name[0])
|
if (!sfx->name[0])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (sfx->cache)
|
if (sfx->cache)
|
||||||
Z_Free (sfx->cache);
|
Z_Free (sfx->cache);
|
||||||
|
|
||||||
memset (sfx, 0, sizeof(*sfx));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset (known_sfx, 0, sizeof(known_sfx));
|
||||||
|
|
||||||
num_sfx = 0;
|
num_sfx = 0;
|
||||||
|
sound_started = 0;
|
||||||
|
|
||||||
|
OGG_Shutdown();
|
||||||
|
SNDDMA_Shutdown();
|
||||||
|
|
||||||
|
Cmd_RemoveCommand("soundlist");
|
||||||
|
Cmd_RemoveCommand("soundinfo");
|
||||||
|
Cmd_RemoveCommand("play");
|
||||||
|
Cmd_RemoveCommand("stopsound");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -223,8 +216,11 @@ sfx_t *S_FindName (char *name, qboolean create) {
|
||||||
num_sfx++;
|
num_sfx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strlen(name) >= MAX_QPATH-1)
|
||||||
|
Com_Error (ERR_FATAL, "Sound name too long: %s", name);
|
||||||
|
|
||||||
sfx = &known_sfx[i];
|
sfx = &known_sfx[i];
|
||||||
memset (sfx, 0, sizeof(*sfx));
|
sfx->truename = NULL;
|
||||||
strcpy (sfx->name, name);
|
strcpy (sfx->name, name);
|
||||||
sfx->registration_sequence = s_registration_sequence;
|
sfx->registration_sequence = s_registration_sequence;
|
||||||
|
|
||||||
|
@ -252,7 +248,7 @@ sfx_t *S_AliasName (char *aliasname, char *truename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
sfx = &known_sfx[i];
|
sfx = &known_sfx[i];
|
||||||
memset (sfx, 0, sizeof(*sfx));
|
sfx->cache = NULL;
|
||||||
strcpy (sfx->name, aliasname);
|
strcpy (sfx->name, aliasname);
|
||||||
sfx->registration_sequence = s_registration_sequence;
|
sfx->registration_sequence = s_registration_sequence;
|
||||||
sfx->truename = s;
|
sfx->truename = s;
|
||||||
|
@ -291,12 +287,13 @@ void S_EndRegistration (void) {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (sfx->registration_sequence != s_registration_sequence) {
|
if (sfx->registration_sequence != s_registration_sequence) {
|
||||||
/* don't need this sound */
|
if (sfx->cache) // it is possible to have a leftover
|
||||||
if (sfx->cache) /* it is possible to have a leftover */
|
Z_Free (sfx->cache); // from a server that didn't finish loading
|
||||||
Z_Free (sfx->cache); /* from a server that didn't finish loading */
|
if (sfx->truename)
|
||||||
|
Z_Free (sfx->truename); // memleak fix from echon
|
||||||
memset (sfx, 0, sizeof(*sfx));
|
|
||||||
|
|
||||||
|
sfx->cache = NULL;
|
||||||
|
sfx->name[0] = 0;
|
||||||
} else {
|
} else {
|
||||||
/* make sure it is paged in, this is a relict of the late 90th */
|
/* make sure it is paged in, this is a relict of the late 90th */
|
||||||
if (sfx->cache) {
|
if (sfx->cache) {
|
||||||
|
@ -483,7 +480,7 @@ void S_IssuePlaysound (playsound_t *ps) {
|
||||||
else
|
else
|
||||||
ch->dist_mult = ps->attenuation * 0.0005f;
|
ch->dist_mult = ps->attenuation * 0.0005f;
|
||||||
|
|
||||||
ch->master_vol = ps->volume;
|
ch->master_vol = (int)ps->volume;
|
||||||
ch->entnum = ps->entnum;
|
ch->entnum = ps->entnum;
|
||||||
ch->entchannel = ps->entchannel;
|
ch->entchannel = ps->entchannel;
|
||||||
ch->sfx = ps->sfx;
|
ch->sfx = ps->sfx;
|
||||||
|
@ -503,8 +500,8 @@ void S_IssuePlaysound (playsound_t *ps) {
|
||||||
struct sfx_s *S_RegisterSexedSound (entity_state_t *ent, char *base) {
|
struct sfx_s *S_RegisterSexedSound (entity_state_t *ent, char *base) {
|
||||||
int n;
|
int n;
|
||||||
char *p;
|
char *p;
|
||||||
|
int len;
|
||||||
struct sfx_s *sfx;
|
struct sfx_s *sfx;
|
||||||
fileHandle_t *f;
|
|
||||||
char model[MAX_QPATH];
|
char model[MAX_QPATH];
|
||||||
char sexedFilename[MAX_QPATH];
|
char sexedFilename[MAX_QPATH];
|
||||||
char maleFilename[MAX_QPATH];
|
char maleFilename[MAX_QPATH];
|
||||||
|
@ -522,7 +519,7 @@ struct sfx_s *S_RegisterSexedSound (entity_state_t *ent, char *base) {
|
||||||
p = strchr(model, '/');
|
p = strchr(model, '/');
|
||||||
|
|
||||||
if (p)
|
if (p)
|
||||||
*p = 0;
|
p[0] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,19 +532,22 @@ struct sfx_s *S_RegisterSexedSound (entity_state_t *ent, char *base) {
|
||||||
sfx = S_FindName (sexedFilename, false);
|
sfx = S_FindName (sexedFilename, false);
|
||||||
|
|
||||||
if (!sfx) {
|
if (!sfx) {
|
||||||
/* no, so see if it exists */
|
// no, so see if it exists
|
||||||
FS_FOpenFile (&sexedFilename[1], (fileHandle_t *)&f, FS_READ);
|
//FS_FOpenFile (&sexedFilename[1], &f, false);
|
||||||
|
len = FS_LoadFile (&sexedFilename[1], NULL);
|
||||||
if (f) {
|
if (len != -1)
|
||||||
/* yes, close the file and register it */
|
{
|
||||||
FS_FCloseFile ((size_t)f);
|
// yes, close the file and register it
|
||||||
|
//FS_FCloseFile (f);
|
||||||
sfx = S_RegisterSound (sexedFilename);
|
sfx = S_RegisterSound (sexedFilename);
|
||||||
|
}
|
||||||
} else {
|
else
|
||||||
/* no, revert to the male sound in the pak0.pak */
|
{
|
||||||
Com_sprintf (maleFilename, sizeof(maleFilename), "player/%s/%s", "male", base+1);
|
// no, revert to the male sound in the pak0.pak
|
||||||
|
Com_sprintf (maleFilename, sizeof(maleFilename), "player/male/%s", base+1);
|
||||||
sfx = S_AliasName (sexedFilename, maleFilename);
|
sfx = S_AliasName (sexedFilename, maleFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return sfx;
|
return sfx;
|
||||||
|
@ -617,14 +617,10 @@ void S_StartSound(vec3_t origin, int entnum, int entchannel, sfx_t *sfx, float f
|
||||||
|
|
||||||
if (!timeofs)
|
if (!timeofs)
|
||||||
ps->begin = paintedtime;
|
ps->begin = paintedtime;
|
||||||
|
|
||||||
else
|
else
|
||||||
ps->begin = (int)(start + timeofs * dma.speed);
|
ps->begin = (int)(start + timeofs * dma.speed);
|
||||||
|
|
||||||
if(s_pendingplays.next == NULL) {
|
ps->volume = fvol*255;
|
||||||
s_pendingplays = *ps;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* sort into the pending sound list */
|
/* sort into the pending sound list */
|
||||||
for (sort = s_pendingplays.next ;
|
for (sort = s_pendingplays.next ;
|
||||||
|
@ -652,7 +648,7 @@ void S_StartLocalSound (char *sound) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
S_StartSound (NULL, cl.playernum+1, 0, sfx, 1, 1, 0);
|
S_StartSound (NULL, cl.playernum+1, 0, sfx, 1, ATTN_NONE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void S_ClearBuffer (void) {
|
void S_ClearBuffer (void) {
|
||||||
|
@ -672,15 +668,7 @@ void S_ClearBuffer (void) {
|
||||||
SNDDMA_BeginPainting ();
|
SNDDMA_BeginPainting ();
|
||||||
|
|
||||||
if (dma.buffer) {
|
if (dma.buffer) {
|
||||||
int i;
|
memset(dma.buffer, clear, dma.samples * dma.samplebits/8);
|
||||||
unsigned char *ptr = (unsigned char *)dma.buffer;
|
|
||||||
|
|
||||||
i = dma.samples * dma.samplebits/8;
|
|
||||||
|
|
||||||
while (i--) {
|
|
||||||
*ptr = clear;
|
|
||||||
ptr++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SNDDMA_Submit ();
|
SNDDMA_Submit ();
|
||||||
|
@ -724,6 +712,7 @@ void S_AddLoopSounds (void) {
|
||||||
sfxcache_t *sc;
|
sfxcache_t *sc;
|
||||||
int num;
|
int num;
|
||||||
entity_state_t *ent;
|
entity_state_t *ent;
|
||||||
|
vec3_t origin;
|
||||||
|
|
||||||
if (cl_paused->value)
|
if (cl_paused->value)
|
||||||
return;
|
return;
|
||||||
|
@ -757,9 +746,10 @@ void S_AddLoopSounds (void) {
|
||||||
num = (cl.frame.parse_entities + i)&(MAX_PARSE_ENTITIES-1);
|
num = (cl.frame.parse_entities + i)&(MAX_PARSE_ENTITIES-1);
|
||||||
ent = &cl_parse_entities[num];
|
ent = &cl_parse_entities[num];
|
||||||
|
|
||||||
|
CL_GetEntitySoundOrigin(ent->number, origin);
|
||||||
|
|
||||||
/* find the total contribution of all sounds of this type */
|
/* find the total contribution of all sounds of this type */
|
||||||
S_SpatializeOrigin (ent->origin, 255.0f, SOUND_LOOPATTENUATE,
|
S_SpatializeOrigin (ent->origin, 255.0f, SOUND_LOOPATTENUATE, &left_total, &right_total);
|
||||||
&left_total, &right_total);
|
|
||||||
|
|
||||||
for (j=i+1 ; j<cl.frame.num_entities ; j++) {
|
for (j=i+1 ; j<cl.frame.num_entities ; j++) {
|
||||||
if (sounds[j] != sounds[i])
|
if (sounds[j] != sounds[i])
|
||||||
|
@ -915,7 +905,6 @@ void S_Update(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up) {
|
||||||
int i;
|
int i;
|
||||||
int total;
|
int total;
|
||||||
channel_t *ch;
|
channel_t *ch;
|
||||||
channel_t *combine;
|
|
||||||
|
|
||||||
if (!sound_started)
|
if (!sound_started)
|
||||||
return;
|
return;
|
||||||
|
@ -924,7 +913,7 @@ void S_Update(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up) {
|
||||||
out to make sure we aren't looping a dirty
|
out to make sure we aren't looping a dirty
|
||||||
dma buffer while loading */
|
dma buffer while loading */
|
||||||
if (cls.disable_screen) {
|
if (cls.disable_screen) {
|
||||||
S_ClearBuffer ();
|
S_ClearBuffer();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -937,7 +926,6 @@ void S_Update(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up) {
|
||||||
VectorCopy(right, listener_right);
|
VectorCopy(right, listener_right);
|
||||||
VectorCopy(up, listener_up);
|
VectorCopy(up, listener_up);
|
||||||
|
|
||||||
combine = NULL;
|
|
||||||
|
|
||||||
/* update spatialization for dynamic sounds */
|
/* update spatialization for dynamic sounds */
|
||||||
ch = channels;
|
ch = channels;
|
||||||
|
@ -976,7 +964,6 @@ void S_Update(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up) {
|
||||||
|
|
||||||
Com_Printf ("----(%i)---- painted: %i\n", total, paintedtime);
|
Com_Printf ("----(%i)---- painted: %i\n", total, paintedtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mix some sound */
|
/* mix some sound */
|
||||||
S_Update_();
|
S_Update_();
|
||||||
|
|
||||||
|
@ -1064,8 +1051,15 @@ void S_Play(void) {
|
||||||
} else
|
} else
|
||||||
strncpy(name, Cmd_Argv(i), sizeof(name)-1);
|
strncpy(name, Cmd_Argv(i), sizeof(name)-1);
|
||||||
|
|
||||||
|
if (strstr(name, "..") || name[0] == '/' || name[0] == '\\') {
|
||||||
|
Com_Printf ("Bad filename %s\n", name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
sfx = S_RegisterSound(name);
|
sfx = S_RegisterSound(name);
|
||||||
|
{
|
||||||
S_StartSound(NULL, cl.playernum+1, 0, sfx, 1.0, 1.0, 0);
|
S_StartSound(NULL, cl.playernum+1, 0, sfx, 1.0, 1.0, 0);
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1075,36 +1069,32 @@ void S_SoundList(void) {
|
||||||
sfx_t *sfx;
|
sfx_t *sfx;
|
||||||
sfxcache_t *sc;
|
sfxcache_t *sc;
|
||||||
int size, total;
|
int size, total;
|
||||||
|
int numsounds;
|
||||||
|
|
||||||
total = 0;
|
total = 0;
|
||||||
|
numsounds = 0;
|
||||||
|
|
||||||
for (sfx=known_sfx, i=0 ; i<num_sfx ; i++, sfx++) {
|
for (sfx=known_sfx, i=0 ; i<num_sfx ; i++, sfx++)
|
||||||
if (!sfx->registration_sequence)
|
{
|
||||||
|
if (!sfx->name[0])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
sc = sfx->cache;
|
sc = sfx->cache;
|
||||||
|
if (sc)
|
||||||
if (sc) {
|
{
|
||||||
size = sc->length*sc->width*(sc->stereo+1);
|
size = sc->length*sc->width*(sc->stereo+1);
|
||||||
total += size;
|
total += size;
|
||||||
|
Com_Printf("%s(%2db) %8i : %s\n", sc->loopstart != -1 ? "L" : " ", sc->width*8, size, sfx->name);
|
||||||
if (sc->loopstart >= 0)
|
}
|
||||||
Com_Printf ("L");
|
|
||||||
|
|
||||||
else
|
else
|
||||||
Com_Printf (" ");
|
{
|
||||||
|
|
||||||
Com_Printf("(%2db) %6i : %s\n",sc->width*8, size, sfx->name);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if (sfx->name[0] == '*')
|
if (sfx->name[0] == '*')
|
||||||
Com_Printf(" placeholder : %s\n", sfx->name);
|
Com_Printf(" placeholder : %s\n", sfx->name);
|
||||||
|
|
||||||
else
|
else
|
||||||
Com_Printf(" not loaded : %s\n", sfx->name);
|
Com_Printf(" not loaded : %s\n", sfx->name);
|
||||||
}
|
}
|
||||||
|
numsounds++;
|
||||||
}
|
}
|
||||||
|
Com_Printf ("Total resident: %i bytes (%.2f MB) in %d sounds\n", total, (float)total / 1024 / 1024, numsounds);
|
||||||
Com_Printf ("Total resident: %i\n", total);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,6 @@
|
||||||
#include "../header/client.h"
|
#include "../header/client.h"
|
||||||
#include "header/local.h"
|
#include "header/local.h"
|
||||||
|
|
||||||
int cache_full_cycle;
|
|
||||||
byte *S_Alloc (int size);
|
|
||||||
|
|
||||||
void ResampleSfx (sfx_t *sfx, int inrate, int inwidth, byte *data) {
|
void ResampleSfx (sfx_t *sfx, int inrate, int inwidth, byte *data) {
|
||||||
int outcount;
|
int outcount;
|
||||||
int srcsample;
|
int srcsample;
|
||||||
|
@ -50,6 +47,15 @@ void ResampleSfx (sfx_t *sfx, int inrate, int inwidth, byte *data) {
|
||||||
stepscale = (float)inrate / dma.speed; /* this is usually 0.5, 1, or 2 */
|
stepscale = (float)inrate / dma.speed; /* this is usually 0.5, 1, or 2 */
|
||||||
|
|
||||||
outcount = (int)(sc->length / stepscale);
|
outcount = (int)(sc->length / stepscale);
|
||||||
|
|
||||||
|
if (outcount == 0)
|
||||||
|
{
|
||||||
|
Com_Printf ("ResampleSfx: Invalid sound file '%s' (zero length)\n", sfx->name);
|
||||||
|
Z_Free (sfx->cache);
|
||||||
|
sfx->cache = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
sc->length = outcount;
|
sc->length = outcount;
|
||||||
|
|
||||||
if (sc->loopstart != -1)
|
if (sc->loopstart != -1)
|
||||||
|
@ -154,7 +160,6 @@ sfxcache_t *S_LoadSound (sfx_t *s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
len = len * info.width * info.channels;
|
len = len * info.width * info.channels;
|
||||||
|
|
||||||
sc = s->cache = Z_Malloc (len + sizeof(sfxcache_t));
|
sc = s->cache = Z_Malloc (len + sizeof(sfxcache_t));
|
||||||
|
|
||||||
if (!sc) {
|
if (!sc) {
|
||||||
|
|
|
@ -105,24 +105,14 @@ void S_TransferPaintBuffer(int endtime) {
|
||||||
pbuf = (unsigned long *)dma.buffer;
|
pbuf = (unsigned long *)dma.buffer;
|
||||||
|
|
||||||
if (s_testsound->value) {
|
if (s_testsound->value) {
|
||||||
static float x = 0.05;
|
|
||||||
static float y = 0.0001;
|
|
||||||
int i;
|
int i;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
x += y;
|
// write a fixed sine wave
|
||||||
|
|
||||||
if (x > 0.15)
|
|
||||||
y = -0.0001;
|
|
||||||
|
|
||||||
else if (x < 0.0005)
|
|
||||||
y = 0.0001;
|
|
||||||
|
|
||||||
/* write a fixed sine wave */
|
|
||||||
count = (endtime - paintedtime);
|
count = (endtime - paintedtime);
|
||||||
|
|
||||||
for (i=0 ; i<count ; i++)
|
for (i=0 ; i<count ; i++)
|
||||||
paintbuffer[i].left = paintbuffer[i].right = (int)((float)sin((paintedtime+i)*0.1f)*20000*256);
|
paintbuffer[i].left = paintbuffer[i].right = (int)((float)sin((paintedtime+i)*0.1f)*20000*256);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dma.samplebits == 16 && dma.channels == 2) {
|
if (dma.samplebits == 16 && dma.channels == 2) {
|
||||||
|
@ -185,7 +175,7 @@ void S_PaintChannels(int endtime) {
|
||||||
int ltime, count;
|
int ltime, count;
|
||||||
playsound_t *ps;
|
playsound_t *ps;
|
||||||
|
|
||||||
snd_vol = s_volume->value*256;
|
snd_vol = (int)(s_volume->value*256);
|
||||||
|
|
||||||
while (paintedtime < endtime) {
|
while (paintedtime < endtime) {
|
||||||
/* if paintbuffer is smaller than DMA buffer */
|
/* if paintbuffer is smaller than DMA buffer */
|
||||||
|
@ -195,24 +185,29 @@ void S_PaintChannels(int endtime) {
|
||||||
end = paintedtime + PAINTBUFFER_SIZE;
|
end = paintedtime + PAINTBUFFER_SIZE;
|
||||||
|
|
||||||
/* start any playsounds */
|
/* start any playsounds */
|
||||||
while (1) {
|
if (endtime - paintedtime > PAINTBUFFER_SIZE)
|
||||||
|
end = paintedtime + PAINTBUFFER_SIZE;
|
||||||
|
|
||||||
|
// start any playsounds
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
ps = s_pendingplays.next;
|
ps = s_pendingplays.next;
|
||||||
|
|
||||||
if (ps == NULL)
|
if (ps == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (ps == &s_pendingplays)
|
if (ps == &s_pendingplays)
|
||||||
break; /* no more pending sounds */
|
break; // no more pending sounds
|
||||||
|
if (ps->begin <= paintedtime)
|
||||||
if (ps->begin <= paintedtime) {
|
{
|
||||||
S_IssuePlaysound (ps);
|
S_IssuePlaysound (ps);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps->begin < end)
|
if (ps->begin < end)
|
||||||
end = ps->begin; /* stop here */
|
end = ps->begin; // stop here
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* clear the paint buffer */
|
/* clear the paint buffer */
|
||||||
|
@ -232,8 +227,7 @@ void S_PaintChannels(int endtime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( ; i<end ; i++) {
|
for ( ; i<end ; i++) {
|
||||||
paintbuffer[i-paintedtime].left =
|
paintbuffer[i-paintedtime].left = paintbuffer[i-paintedtime].right = 0;
|
||||||
paintbuffer[i-paintedtime].right = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,6 +293,11 @@ void S_InitScaletable (void) {
|
||||||
int i, j;
|
int i, j;
|
||||||
int scale;
|
int scale;
|
||||||
|
|
||||||
|
if (s_volume->value > 2.0f)
|
||||||
|
Cvar_Set ("s_volume", "2");
|
||||||
|
else if (s_volume->value < 0)
|
||||||
|
Cvar_Set ("s_volume", "0");
|
||||||
|
|
||||||
s_volume->modified = false;
|
s_volume->modified = false;
|
||||||
|
|
||||||
for (i=0 ; i<32 ; i++) {
|
for (i=0 ; i<32 ; i++) {
|
||||||
|
|
|
@ -54,14 +54,14 @@ int GetLittleLong(void) {
|
||||||
void FindNextChunk(char *name) {
|
void FindNextChunk(char *name) {
|
||||||
while (1) {
|
while (1) {
|
||||||
data_p=last_chunk;
|
data_p=last_chunk;
|
||||||
|
data_p += 4;
|
||||||
|
|
||||||
if (data_p >= iff_end) {
|
if (data_p >= iff_end)
|
||||||
/* didn't find the chunk */
|
{
|
||||||
data_p = NULL;
|
data_p = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
data_p += 4;
|
|
||||||
iff_chunk_len = GetLittleLong();
|
iff_chunk_len = GetLittleLong();
|
||||||
|
|
||||||
if (iff_chunk_len < 0) {
|
if (iff_chunk_len < 0) {
|
||||||
|
@ -153,7 +153,8 @@ wavinfo_t GetWavinfo (char *name, byte *wav, int wavlength) {
|
||||||
FindNextChunk ("LIST");
|
FindNextChunk ("LIST");
|
||||||
|
|
||||||
if (data_p) {
|
if (data_p) {
|
||||||
if (!strncmp ((const char *)data_p + 28, "mark", 4)) {
|
if ((data_p - wav) + 32 <= wavlength && !strncmp ((const char *)data_p + 28, "mark", 4))
|
||||||
|
{
|
||||||
/* this is not a proper parse, but it works with cooledit... */
|
/* this is not a proper parse, but it works with cooledit... */
|
||||||
data_p += 24;
|
data_p += 24;
|
||||||
i = GetLittleLong (); /* samples in loop */
|
i = GetLittleLong (); /* samples in loop */
|
||||||
|
@ -182,7 +183,7 @@ wavinfo_t GetWavinfo (char *name, byte *wav, int wavlength) {
|
||||||
} else
|
} else
|
||||||
info.samples = samples;
|
info.samples = samples;
|
||||||
|
|
||||||
info.dataofs = data_p - wav;
|
info.dataofs = (int)(data_p - wav);
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue