Delphi

OpenAL

Tutorials

Lesson #4 (sharing buffers)

If you want the same sound multiple times then there is no need loading that sound many times. You just can share the buffer used.

Change the numsources to 4, but leave the numbuffers at 3. Add a name for the new source:
walk2 = 3;

In the oncreate event we need to init the new source like this:
SourcePos[0] := -8.0;
SourcePos[1] := 0.0;
SourcePos[2] := -8.0;
AlSourcei ( source[walk2], AL_BUFFER, buffer[walk]);
AlSourcef ( source[walk2], AL_PITCH, 1.0 );
AlSourcef ( source[walk2], AL_GAIN, 0.2 );
AlSourcefv ( source[walk2], AL_POSITION, @sourcepos);
AlSourcefv ( source[walk2], AL_VELOCITY, @sourcevel);
AlSourcei ( source[walk2], AL_LOOPING, AL_TRUE);

You see instead of using buffer[walk2] we use buffer[walk] again. If you want you could use the same walk sound again and again.

For playing the new source it is easiest to create some new buttons for playing and stopping it.

If you feel up to it you really should change the way sourcepos and sourcevel are used. Instead of sharing it for all sounds you should give each source its own sourcepos and sourcevel.