1. 程式人生 > >音效卡 PCM資料格式

音效卡 PCM資料格式


ThewaveOutSetVolumefunction sets the volume level of the specified waveform-audio output device.
Volume-level values range from 0x0 (silence) to 0xFFFF (maximum volume) and are interpreted logarithmically.

dwVolume

New volume setting. The low-order word contains the left-channel volume setting, and the high-order word contains the right-channel setting. A value of 0xFFFF represents full volume, and a value of 0x0000 is silence.

If a device does not support both left and right volume control, the low-order word of dwVolume specifies the volume level, and the high-order word is ignored.




PCM Waveform-Audio Data Format

The lpData member of the WAVEHDR structure pointsetts to the waveform-audio data samples. 

 For 8-bit PCM data, each sample is represented by a single unsigned data byte. For 16-bit PCM data, each sample is represented by a 16-bit signed value. The following table summarizes the maximum, minimum, and midpoint values for PCM waveform-audio data.

Data format Maximum value Minimum value Midpoint value
8-bit PCM 255 (0xFF) 0 128 (0x80)
16-bit PCM 32,767 (0x7FFF) –32,768 (0x8000) 0

PCM Data Packing


PCM waveform-audio format Description
8-bit mono Each sample is 1 byte that corresponds to a single audio channel. Sample 1 is followed by samples 2, 3, 4, and so on.
8-bit stereo Each sample is 2 bytes. Sample 1 is followed by samples 2, 3, 4, and so on. For each sample, the first byte is channel 0 (the left channel) and the second byte is channel 1 (the right channel).
16-bit mono Each sample is 2 bytes. Sample 1 is followed by samples 2, 3, 4, and so on. For each sample, the first byte is the low-order byte of channel 0 and the second byte is the high-order byte of channel 0.
16-bit stereo Each sample is 4 bytes. Sample 1 is followed by samples 2, 3, 4, and so on. For each sample, the first byte is the low-order byte of channel 0 (left channel); the second byte is the high-order byte of channel 0; the third byte is the low-order byte of channel 1 (right channel); and the fourth byte is the high-order byte of channel 1.