PDA

View Full Version : Didn't know where to post this, here WAVEFORMATEX....help



incognito
05-22-2002, 09:54 PM
I have a problem with WAVEFORMATEX, I know how to assign values to it and everything......for example


WAVEFORMATEX waveFormat;

waveFormat.wFormatTag = WAVE_FORMAT_PCM;
waveFormat.nChannels = 2;
waveFormat.nSamplesPerSec = 44100;
waveFormat.wBitsPerSample = 16;
waveFormat.nBlockAlign = waveFormat.nChannels * (waveFormat.wBitsPerSample/8);
waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAlign;
waveFormat.cbSize = 0;


First of, I haven't finished the chapter on Direct Sound.....but I've skimmed ahead and don't see this being mentioned again, so I want to know how is are these formats assigned to a sound buffer or sound object. I mean after you fill out all this information how do you assign it to something? Thank you in advance.

incognito
05-23-2002, 01:16 PM
sorry to bump but is that I still haven't found the answer to this question, I've searched the board and the internet and still nothing.

Sorensen
05-23-2002, 02:12 PM
This is dependent on the DirectSound version you are programming for but it'll probably be something along the lines of -


pointerToYourDirectSoundBuffer->SetFormat(pToYourWAVEFORMATEX);

incognito
05-23-2002, 02:19 PM
What's the last parameter for? 0? I am using Direct X 7.0

incognito
05-23-2002, 02:27 PM
Get it now........:D hey do you know of any place where I can find all the definitions to the Direct X Functions?

Sorensen
05-23-2002, 02:31 PM
>What's the last parameter for? 0?

Sorry I edited it as I was merging 2 functions into one. The last parameter for CreateSoundBuffer() is NULL.

>I am using Direct X 7.0

You may have searched the internet high and low, but the information you require is in perhaps the most obvious place. Try the Direct X 7.0 help file - DirectSound Tutorial 1, Step 1 : Set Up DirectSound. It contains all the information you require.

incognito
05-23-2002, 02:45 PM
Thanks man it took me a while to find, but I finally got it......
umm, I found this one...

hr = (*lplpDsb)->lpVtbl->SetFormat(*lplpDsb, &wf);

Just don't know what this lpVtbl is for.

incognito
05-23-2002, 02:51 PM
Because I see that in some other functions that I didn't see using that before on the book. What does this mean? Is that like extra in there or something.......lpVtbl

Sorensen
05-23-2002, 02:53 PM
>Just don't know what this lpVtbl is for.

That's for using Direct X in straight C. To access functions through pointers to COM objects you need to go via a pointer to a table of functions (as C doesn't support functions in structs without doing something along these lines).

If you're using C++ anyway then you either need to use C++ documentation or ignore the lpVtbl bit.

incognito
05-23-2002, 02:55 PM
Thanks I'll stick for ignoring it for now......:D

Sorensen
05-23-2002, 03:00 PM
You'll also have to ignore the first parameter in any function that uses the Vtable as this is silently passed in C++.

incognito
05-23-2002, 03:02 PM
You mean out of......(*lplpDsb, &wf);

to ignore *lplpDsb?

Thanks that outta save me a lot of hair on my head and headaches.