Audio problem :-/

Hi!

I’ve got a audio problem, it sounds output is a bit strange, at
the moment. I hope you can help me. (You’ll be mentioned in the
credits :wink: )

I’ve got two structs (sample, datas). a_data[] is going to contain
the raw sound data, which I converted to the actual settings.
sample[] is used to define the different channels without
having the sound data in memory multiple times. (i’ve got just ~10
sounds which will be used all the time). int num is the index of
the belonging a_data[].

My Mixer function is called V_MachHin (see below). Perhaps it isn’t
a mixer problem but a wave-loading problem (V_LoadWave, see below
V_MachHin).

thanks is advance.
G?nther

—CODE STARTS HERE

struct sample
{
int num;
Uint32 dpos;
Uint32 dlen;
} sounds[NUM_SOUNDS];

struct datas
{
Uint8 data;
Uint32 dpos;
Uint32 dlen;
} a_data[2];

void V_MachHin (void foobar, Uint8 stream, int len)
{
/
*** (MIXER) *****/
int i;
Uint32 amount;

Uint8 *pnt;
int k, l, m;

for (i=0; i<NUM_SOUNDS; ++i)
{
amount = sounds[i].dlen-sounds[i].dpos;
if (amount <= 0) continue;
if (amount > len)
{
amount = len;
}

  k = sounds[i].num;
  l = sounds[i].dpos;
  pnt = &(a_data[k].data);


  SDL_MixAudio( stream,
  	    &pnt[l],
  	    amount, SDL_MIX_MAXVOLUME );
  sounds[i].dpos += amount;
}

}

V_LoadWave (char file, int index)
{
/
**** debug-style, still got some printf’s in it *****/
SDL_AudioSpec wave;
Uint8 *data;
Uint32 dlen;
SDL_AudioCVT cvt;

SDL_LoadWAV( file, &wave, &data, &dlen );

printf( “SDL_BuildAudioCVT = %d\n”,
SDL_BuildAudioCVT(&cvt, wave.format, wave.channels, wave.freq,
found.format, found.channels, found.freq ) );

printf(“wave : format %d channels %d freq %d\n”,
wave.format, wave.channels, wave.freq);
printf(“found: format %d channels %d freq %d\n”,
found.format, found.channels, found.freq);

cvt.len = dlen;
cvt.buf = (Uint8 ) malloc(cvt.lencvt.len_mult);
memcpy(cvt.buf, data, cvt.len);
printf (“SDL_CA = %d\n”, SDL_ConvertAudio(&cvt) );

printf(“cvt.buf : %d %d %d %d”, cvt.buf[1], cvt.buf[2], cvt.buf[3]);

SDL_FreeWAV(data);

a_data[index].dlen = cvt.len_cvt;
a_data[index].dpos = 0;
a_data[index].data = *(cvt.buf);
}

—CODE ENDS HERE–
±------------------------------+
| .~. |
| / V \ |
| /( )\ |
±------------^^-^^-------------+
| @gnoack_at_guentherno |
| http://www.guenthernoack.de |
±------------------------------+
| F?R BANNERTAUSCH iMMER BEREiT |
±------------------------------+