Sign in to follow this  
toan1982

How to copy source/data of LDIRECTSOUNDBUFFER to LDIRECTSOUNDBUFFER8 variable.

Recommended Posts

Hi all Directsound have two samples: One is soundFX and other is DuplexFilter sample In soundFX, the app used LDIRECTSOUNDBUFFER8 with purpose are using setFX function. But in DuplexFilter, app used LDIRECTSOUNDBUFFER for capture and playback at the same time. Now , I would like to combine two sample. I would like to capture and add effect and playback sound ( my voice through microphone) at the same time? Can i do this? I have tried to do as follow: first i will have m_pDSBCapture, a capture sound buffer, (from my voice) with type is LDIRECTSOUNDBUFFER and m_pDSBOutput, a output sound buffer, is same type. I also have a m_pDSB8 with type is LDIRECTSOUNDBUFFER8 . Now, i want to copy data from m_pDSBCapture or m_pDSBOutput to m_pDSB8 so that i can call setFX and Play function for m_pDSB8 . How can i do this??? I call m_pDSBOutput->QueryInterface( IID_IDirectSoundBuffer8, (LPVOID*) &m_pDSB8 ) ) ) then is failed. Can anyone show me solution? Do you have sample source do this? Thanks

Share this post


Link to post
Share on other sites
You really shouldn't use both. You should standardize on IDirectSoundBuffer8. You can use IDirectSoundBuffer::DuplicateSoundBuffer(). It's also available for IDirectSoundBuffer8.

It's fairly simple to change the DuplexFilter sample to use IDirectSoundBuffer8. Just take the buffer creation code from the soundFX sample and replace the creation code in the DuplexFilter sample with it.

Share this post


Link to post
Share on other sites
Thank you,

i will call IDirectSoundBuffer::DuplicateSoundBuffer()to copy data source from LDirectsoundBuffer variable to LDirectsoundBuffer8 variable, right?
If right, can i set effect sound for LDirectsoundBuffer8 var by call SetFX function? Because these are process realtime, capture and add effect and playback at the same time, so i wonder can i do that with directsound?

Can you help me more?

Share this post


Link to post
Share on other sites
Quote:

i will call IDirectSoundBuffer::DuplicateSoundBuffer()to copy data source from LDirectsoundBuffer variable to LDirectsoundBuffer8 variable, right?

Careful with that. Duplicating the sound buffer only duplicates the read/write pointers, volume control, etc. It DOES NOT duplicate the data, it shares it.

Quote:

If right, can i set effect sound for LDirectsoundBuffer8 var by call SetFX function?

I don't believe you can. The duplicate function is only supported for buffers that do not have sound fx controls. You may be able to add sound effect control after duplicating, but it doesn't seem like that is possible.

Quote:

Because these are process realtime, capture and add effect and playback at the same time, so i wonder can i do that with directsound?

I would suggest having 2 buffers. Capture into one buffer, then lock it and copy the data into another buffer. This "other" buffer will support your sound effects and play the sound as you like.

Hope that helps.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this