Go Several structures commonly used in dsound development

Source: Internet
Author: User

 WaveFormatEx

WaveFormatEx

{

WORD wFormatTag;

WORD nchannels;

DWORD nsamplespersec;

DWORD navgbytespersec;

WORD nblockalign;

WORD wBitsPerSample;

WORD cbsize;

};

This structure defines the format of the wave audio data. Only the general format information contained in all audio is included in this structure, and for formats that require additional information, the structure is included and as the first parameter.

Member variables

wFormatTag

Wave sound format. The format label is the one that Microsoft has registered for some compression algorithms, and the full format label list is defined in Mmreg.h. For mono or dual-channel PCM data, this value must be WAVE_FORMAT_PCM

Nchannels

The number of channels for wave data. Mono is used for non-stereo, and stereo uses two channels.

Nsamplespersec

Sample rate, unit Hz. If the wFormatTag is WAVE_FORMAT_PCM, the average value is 8.0K, 11.025K, 22.05K, or 44.1K. For non-PCM formats, this variable must be calculated by the manufacturer's specification of the format label.

Navgbytespersec

Average data transfer rate. If the format label is WAVE_FORMAT_PCM, the value must be equal to the product of the year samplespersec and Blockalign. For non-PCM formats, this variable must be calculated by the manufacturer's specification of the format label.

nBlockAlign

Chunk queue, Unit bytes. A chunk queue is the smallest cell for a format. If the format is WAVE_FORMAT_PCM or wave_format_extensible, the value must be equal to the product of Nchannels and wBitsPerSample divided by 8. For non-PCM formats, this variable must be calculated by the manufacturer's specification of the format label.

The software must perform a double nblockalign byte at a time. Writing and reading data from a device must be at the beginning of a chunk.

wBitsPerSample

The bytes per sample. If the format label is WAVE_FORMAT_PCM, the value must be equal to 8 or 16. For non-PCM formats, this variable must be calculated by the manufacturer's specification of the format label. If the format label is wave_format_extensible, this value can be a multiple of any 8. Some compression schemes cannot define this value, so it can be 0.

cbsize

Size, in units of bytes. The results of the WAVEFORMATEX structure are hooked up as additional format information. This information can be used in non-PCM format to store the attributes of additional format tags. If there is no additional information, this member must be set to 0. For the WAVE_FORMAT_PCM format, this member is ignored for this format only.

DSBufferDesc

DSBufferDesc

{

DWORD dwsize;

DWORD DwFlags;

DWORD dwbufferbytes;

DWORD dwreserved;

Lpwaveformatex Lpwfxformat;

GUID Guid3dalgorithm;

};

This structure describes the properties of a new buffer object. The IDirectSound8::CreateSoundBuffer and DirectSoundFullDuplexCreate8 functions are used. In order to be compatible with DX7 or earlier DX, earlier versions of this structure DSBUFFERDESC1 still exist in Dsound.h.

Member variables

dwsize

The size of the structure, in bytes. This member must be defined before the struct is used.

DwFlags

Defines the compatibility capability of buffers, the following values can be defined

Value

Description

Dsbcaps_ctrl3d

Buffers have 3D control compatibility. cannot be bound to Dsbcaps_ctrlpan and cannot be set with the buffer set in Lpwfxformat for stereo format.

Dsbcaps_ctrlfrequency

Can change the frequency

Dsbcaps_ctrlfx

Supports special effects processing. The buffer must be large enough to hold at least dsbsize_fx_min milliseconds of data.

Dsbcaps_ctrlpan

Compatibility with panel control. Cannot bind with Dsbcaps_ctrl3d flag bit

Dsbcaps_ctrlpositionnotify

The buffer has position notification capability. See Remarks.

Dsbcaps_ctrlvolume

You can control the volume.

Dsbcaps_getcurrentposition2

The Idirectsoundbuffer8::getcurrentpositionmethod uses the new behavior of the play cursor. In DirectSound in DirectX 1, the play cursor is significantly ahead of the actual playing sound on emulated sound cards; It was directly behind the write cursor. Now, if the DSBCAPS_GETCURRENTPOSITION2 flag are specified, the application can get a more accurate play cursor. IF This flag was not specified, the old behavior was preserved for compatibility. Note that this flag affects only emulated the sound cards. If a DirectSound driver is present, the play cursor was accurate for DirectSound in all versions of DirectX.

Dsbcaps_globalfocus

The global buffer flag. Set this flag bit, if the user switches focus to other programs, even if the new program also uses Dsound, the program can continue to play its buffer. One exception is that the program that is switched to uses the DSSCL_WRITEPRIMARY flag as the coordination level. In this case, the global sound of other programs is also not audible.

Dsbcaps_locdefer

Buffers can be assigned to hardware or software resources while they are playing. This flag bit can only be set using the sound-managed buffer.

Dsbcaps_lochardware

The buffer must use a hardware mix. If the device does not support hardware mixing or the required hardware memory is not available, the IDirectSound8::CreateSoundBuffer method will fail. The program must ensure that the mixing channel can be used for the buffer, this situation is not guaranteed. If Dsbcaps_locsoftware and this flag bit are not specified, the buffer takes precedence over this flag bit. Hardware buffers are not supported on 64-bit operating systems.

Dsbcaps_locsoftware

This buffer must be in software memory, using a software mixer, even if dsbcaps_static is specified and hardware resources are available.

Dsbcaps_mute3datmaxdistance

The sound was reduced to silence at the maximum distance. The buffer would stop playing when the maximum distance are exceeded, so then processor time is not wasted. Applies only to software buffers.

Dsbcaps_primarybuffer

The buffer is a primary buffer. If This value isn't specified, a secondary sound buffer is created. Cannot is combined with DSBCAPS_CTRLFX.

Dsbcaps_static

The buffer is placed in on-board hardware memory, if available. No error occurs if such memory is not available. This flag have no effect on cards using the PCI bus. Cannot is combined with DSBCAPS_CTRLFX.

Dsbcaps_stickyfocus

TThe buffer has sticky focus. If the user switches to another application is not using DirectSound, the application's normal buffers is muted, but sticky Focus buffers is still audible.

Transferred from: http://blog.sina.com.cn/s/blog_4de8abbb01000atg.html

Go Several structures commonly used in dsound development

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.