How do i convert linear or dB values into hex values for the mini-DSP in the TLV320AIC CODECs?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
How do i convert linear or dB values into hex values for the mini-DSP in the TLV320AIC CODECs?
Applies to:
TLV320AIC3254-like devices (24-bit C-RAM)
TLV320AIC3111-like devices (16-bit C-RAM)
TASxxxx miniDSP devices (24-bit C-RAM)
To convert from a dB or linear value into a format the device understands it is necessary to understand the data format of the device. The miniDSP devices store user-accessible variables in Coefficient Memory (C-RAM). The bit width of C-RAM may be different from device to device as shown above.
As an example, the volume control volume level is determined by the value stored its C-RAM location. A 0dB volume level (1x gain) corresponds to 0x400000 (24-bit device) or 0x4000 (16-bit device). This means that the volume control assumes a 2.xx format, where the MSB is the sign bit, the MSB-1 is a magnitude bit and xx are the fractional bits. This is a 2's complement format, meaning that numbers will range [0x800000, 0x7FFFFF], where 0x80... is the most negative number and 0x7F...is the most positive number. Some examples:
In general, a number can be converted from decimal to a M.xx format hex value as follows:
ValueHEX = DEC2HEX(ValueDEC x 2N-M), where N is the bit resolution of the memory location.
If the value is provided in decibels (dB), it can be converted as follows:
ValueHEX = DEC2HEX(10Value(dB)/20 x 2N-M)
Note that values greater than 2N-1-1 and less than -2N-1 are out of bounds if converting to hex.
As an example, for the volume control found in PurePath Studio (2.xx format), a gain of 0dB will result in:
ValueHEX = DEC2HEX(100/20 x 224-2) = 0x400000
The table below shows additional values:
Example Volume Control Values in Hex
To convert from hexadecimal back to decimal:
ValueDEC = HEX2DEC(ValueHEX) / 2N-M
To convert a decimal value back to dB:
ValuedB = 20 x log10(ValueDEC)
As an example, 0x400000 (as a 2.xx hexadecimal number) can be converted to linear as follows:
ValueDEC = HEX2DEC(400000) / 224-2 = 1
The dB / Linear to Hexadecimal calculator can be downloaded below: