
LastWrittenByte := LastWrittenByte + 512 ĭSCurrentBuffer.Unlock(FirstPart, 512, SecondPart, 0) LockResult := DSCurrentBuffer.Lock(LastWrittenByte, 512, DSBLOCK_ENTIREBUFFER) LastWrittenByte := FirstLength, SecondPart, SecondLength) Įlse // If it isn't playing, set play cursor position to the start of buffer and lock the entire buffer Move(AudioData, SecondPart^, SecondLength) LastWrittenByte := LastWrittenByte + FirstLength Move(AudioData, FirstPart^, FirstLength)

If (Status and DSBSTATUS_PLAYING) = DSBSTATUS_PLAYING then // If it is playing, request the next segment of the buffer for writingĭSCurrentBuffer.Lock(LastWrittenByte, 512, DSBLOCK_FROMWRITECURSOR) Input data is converted to audio data here, not relevant to the question itself. I write this data to my Secondary Buffer as follows: var Wfx.nAvgBytesPerSec := fFrequency * 2 // SamplesPerSec * BlockAlignīufferDesc.dwSize := SizeOf(DSBUFFERDESC) īufferDesc.dwFlags := (DSBCAPS_GLOBALFOCUS or DSBCAPS_GETCURRENTPOSITION2 orīufferDesc.lpwfxFormat := DSInterface.CreateSoundBuffer(BufferDesc, DSCurrentBuffer, nil) of Wfx.nBlockAlign := 2 // Channels * (BitsPerSample/8) When the Indata event is triggered by these other pieces of code, I'm essentially dropped into a procedure with the Audio Data as a parameter.ĭSCurrentBuffer was initialized as follows: SizeOf(DSBUFFERDESC)) I have packets coming in over the network at approximately 30ms intervals containing audio data that is decoded into raw wav data by other parts of the application.

Back again with yet another DirectSound question, this one regarding the ways DirectSound Buffers can be used:
