ΣSigmaStudio Ask AI Русский Log in

(ADAU1452) How to calculate the gain and how to convert the double value to 4 bytes DSP data??

SigmaDSP & SigmaStudio nick Jiang Apr 26, 2020 00:00 1 replies Original on forum ↗
Subscribe
nick Jiang Question
Apr 26, 2020 00:00

DEAR Sirs,

I am using ADAU1452 and now meet 2 questions: How to calculate the gain and how to convert the double value to 4 bytes data to write into the DSP.

for example: I can get the data from sigmastudio as below shows:

A.

master volume =-20dB

<Value>0.100000023841858

<Data>0x00, 0x19, 0x99, 0x9A,

B.

master volume =-30dB

<Value>0.0316227674484253 ------------> how to calculate this value??

<Data>0x00, 0x08, 0x18, 0x6E, -------------->how to convert??

use the above data from sigmastudio to contorl the ADAU1452 is not convenient. so I want to use MCU to calculate the data,

but i don know the method. Is there any document or method???

thanks very much!

Audio Signal Processors

adau1452

SigmaDSP Audio Processors

sport

7230.pastedimage1587873539654v1.png
7230.pastedimage1587873539654v1.png
ADIApproved Reply
Jun 10, 2020 00:00

Hello,

I do not know which microcontroller you are using, so here is an Arduino-compatible function:

void write_volume_control(double dBGain) {

double linearGain = pow(10, dBGain / 20); // convert dB gain to linear gain; these are the "values" in SigmaStudio

uint32_t fixedPointGain = uint32_t(linearGain * (0x01 << 24)); // convert linear gain to fixed point 8.24

byte registerVals[] = {byte(fixedPointGain >> 24), byte(fixedPointGain >> 16),

byte(fixedPointGain >> 8), byte(fixedPointGain)}; // extract each byte

// Now you have a variable called registerVals which holds these arrays.

// The LSBs may be different due to quantization error in the microcontroller, but that's ok.

// If you are using SigmaStudio exported files and have implemented the macros, you can use the following to write the data to the DSP:

SIGMA_WRITE_REGISTER_BLOCK(0, MOD_SINGLE_VOLUME_ALG0_TARGET_ADDR, 4, registerVals); // write to DSP

}

Does this answer your question?

Joshua