1.1.4.6.6 DRV_WM8904_VolumeSet Function
void DRV_WM8904_VolumeSet(DRV_HANDLE handle, DRV_WM8904_CHANNEL channel, uint8_t volume);
Summary
This function sets the volume for WM8904 Codec.
Description
This function sets the volume value from 0-255.
The codec has DAC value to volume range mapping as :- 00 H : +12dB FF H : -115dB
In order to make the volume value to dB mapping monotonically increasing from 00 to FF, re-mapping is introduced which reverses the volume value to dB mapping as well as normalizes the volume range to a more audible dB range.
The current driver implementation assumes that all dB values under -60 dB are inaudible to the human ear.
Re-Mapped values 00 H : -60 dB FF H : +12 dB
Preconditions
The DRV_WM8904_Initialize routine must have been called for the specified WM8904 driver instance.
DRV_WM8904_Open must have been called to obtain a valid opened device handle.
Parameters
Parameters | Description |
---|---|
handle | A valid open-instance handle, returned from the driver's open routine |
channel | argument indicating Left or Right or Both channel volume to be modified |
volume | volume value specified in the range 0-255 (0x00 to 0xFF) |
Returns
None
Remarks
None.
Example
_// myAppObj is an application specific object._
MY_APP_OBJ myAppObj;
uint8_t mybuffer[MY_BUFFER_SIZE]; DRV_BUFFER_HANDLE bufferHandle;
_// myWM8904Handle is the handle returned // by the DRV_WM8904_Open function._
DRV_WM8904_VolumeSet(myWM8904Handle,DRV_WM8904_CHANNEL_LEFT, 120);
C
void DRV_WM8904_VolumeSet(DRV_HANDLE handle, DRV_WM8904_CHANNEL channel, uint8_t volume);