Create a "capture buffer" "
CallIdirectsoundcapture8: createcapturebufferMethod To create a capture buffer.
One of the parameters of this method is a dscbufferdesc struct that describes the features of the desired buffer. The last member of this struct is a waveformatex struct. This struct must be initialized in a specific WAV format.
NOTE: If your applicationProgramCapture these sounds while playing the sound. When the format of the capture buffer is different from that of the primary buffer, the creation of the capture buffer will fail. The reason is that some sound cards only have a single clock frequency and do not support capturing and playing at two different frequencies.
The following function creates a buffer to capture data in one second. Note: To pass in an interface for capturing device objects as a parameter, this interface must pass throughDirectsoundcapturecreate8Instead of using the previousDirectsoundcapturecreateFunction; otherwise, the buffer does not support the idirectsoundcapturebuffer8 interface.
Code
Hresult createcapturebuffer (lpdirectsoundcapture8 PDSC,
Lpdirectsoundcapturebuffer8 * Ppdscb8)
{
Hresult hr;
Dscbufferdesc dscbd;
Lpdirectsoundcapturebuffer pdscb;
Waveformatex WFX =
{Wave_format_pcm, 2 , 44100 , 176400 , 4 , 16 , 0 };
// Wformattag, nchannels, nsamplespersec, mavgbytespersec,
// Nblockalign, wbitspersample, cbsize
If (Null = PDSC) | (Null = Ppdscb8 )) Return E_invalidarg;
Dscbd. dwsize = Sizeof (Dscbufferdesc );
Dscbd. dwflags = 0 ;
Dscbd. dwbufferbytes = WFX. navgbytespersec;
Dscbd. dwreserved = 0 ;
Dscbd. lpwfxformat = & WFX;
Dscbd. dwfxcount = 0 ;
Dscbd. lpdscfxdesc = NULL;
If (Succeeded (HR = PDSC -> Createcapturebuffer ( & Dscbd, & Pdscb, null )))
{
HR = Pdscb -> QueryInterface (iid_idirectsoundcapturebuffer8, (lpvoid * ) Ppdscb8 );
Pdscb -> Release ();
}
Return HR;
}
View others:
statement
1. enumerate "capturing devices"
2. create "capture device object"
3. "Capture device" performance
4. create a "Capture buffer"
5. "Capture buffer" Information
6. "buffer capturing" Notification
7. "buffer capturing" effect
8. use "Capture buffer"
9. write to WAV file