Original Post
All right, as I can't get CSound working without strange linking errors that I can't get around, I'm trying to work with DirectSound objects directly. I just updated to the Feb 2006 SDK so I'm completely up to date now. The documentation I'm using is here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/dx9_directsound_programming_guide.asp Here's what I've got so far: Here's where I'm stuck. At Buffer Basics > Filling and Playing Static Buffers (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/Filling_and_Playing_Static_Buffers.asp), there's a piece right after the 'if' statement that I stopped at that uses memcpy: memcpy(lpvWrite, pbData, dwLength); Leave it to Microsoft to not document what "pbData" is. Can anyone tell me what this should be? Here's what MS's code looks like:
CoInitialize(NULL);
if(FAILED(CoCreateInstance(CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER,
IID_IDirectSound8, (LPVOID*)&pSound)))
return false;
if(FAILED(pSound->Initialize(NULL))) return false;
if(FAILED(pSound->SetCooperativeLevel(*(window->gethWnd()),DSSCL_PRIORITY))) return false;
//Set up WAV format structure
memset(&waveFormat, 0, sizeof(WAVEFORMATEX));
waveFormat.wFormatTag = WAVE_FORMAT_PCM;
waveFormat.nChannels = 2;
waveFormat.nSamplesPerSec = 22050;
waveFormat.nBlockAlign = 4;
waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAlign;
waveFormat.wBitsPerSample = 16;
//Set up buffer desc structer
memset(&bufferDesc, 0, sizeof(DSBUFFERDESC));
bufferDesc.dwSize = sizeof(DSBUFFERDESC);
bufferDesc.dwFlags = DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY
| DSBCAPS_GLOBALFOCUS;
bufferDesc.dwBufferBytes = 3 * waveFormat.nAvgBytesPerSec; //Hold 3 seconds of data
// in the buffer
bufferDesc.lpwfxFormat = &waveFormat
//Create buffer
LPDIRECTSOUNDBUFFER pDsb = NULL;
if(FAILED(pSound->CreateSoundBuffer(&bufferDesc, &pDsb, NULL)))
return false;
pDsb->QueryInterface(IID_IDirectSoundBuffer8, (LPVOID*)pSecondaryBuffer);
pDsb->Release();
//Fill the static buffer (secondary)
LPVOID lpvWrite;
DWORD dwLength;
if(DS_OK==pSecondaryBuffer->Lock(
0,
0,
&lpvWrite,
&dwLength,
NULL,
NULL,
DSBLOCK_ENTIREBUFFER))
{
LPVOID lpvWrite;
DWORD dwLength;
if (DS_OK == lpdsbStatic->Lock(
0, // Offset at which to start lock.
0, // Size of lock; ignored because of flag.
&lpvWrite, // Gets address of first part of lock.
&dwLength, // Gets size of first part of lock.
NULL, // Address of wraparound not needed.
NULL, // Size of wraparound not needed.
DSBLOCK_ENTIREBUFFER)) // Flag.
{
memcpy(lpvWrite, pbData, dwLength);
lpdsbStatic->Unlock(
lpvWrite, // Address of lock start.
dwLength, // Size of lock.
NULL, // No wraparound portion.
0); // No wraparound size.
}
else
(
ErrorHandler(); // Add error-handling here.
}