80.3.10 Changing Pitch and Playback Rate

Some waveform output devices can vary the pitch and the playback rate of waveform data. Not all waveform devices support pitch and playback-rate changes. See “Determining Capabilities of Waveform Output Devices,” earlier in this chapter, for information on how to determine if a particular waveform device supports pitch and playback rate changes.

The differences between changing pitch and playback rate are:

Changing the playback rate is performed by the device-driver and does not require specialized hardware. The sample rate is not changed, but the driver interpolates by skipping or synthesizing samples. For example, if the playback rate is changed by a factor of two, the driver skips every other sample.

Changing the pitch requires specialized hardware. The playback rate and sample rate are not changed.

Windows provides the following functions to query and set waveform pitch and playback rates:

Function Description

waveOutGetPitch Gets the pitch for the specified waveform output device.
waveOutGetPlaybackRate Gets the playback rate for the specified waveform output device.
waveOutSetPitch Sets the pitch for the specified waveform output device.
waveOutSetPlaybackRate Sets the playback rate for the specified waveform output device.

The pitch and playback rates are changed by a factor specified with a fixed-point number packed into a DWORD. The upper 16 bits specify the integer part; the lower 16 bits specify the fractional part of the number. For example, the value 1.5 is represented as 0x00018000L. The value 0.75 is represented as 0x0000C000L. A value of 1.0 (0x00010000) means the pitch or playback rate is unchanged.