Hi,

The highest value for Single Volume is 1 and smallest is 0 based on the capture window in Sigma studio. In my case, the user can change the volume but I couldn't find any formula to map the dB to decimal and hex values.

Where or how can I do it?

Thanks,

Semi

Hello Semi,

The value of the volume control is derived from the formula for dB, 20log(x)=dB.

Note that this formula is usually used to get the ratio of two voltages with one of them being the reference, 20log(V/Vref) = dB

Since we are not dealing with voltages until we convert it using a DAC, the reference is 1. So 1V output is a digital full scale if it were to be output with a DAC using a 1V reference. So we can drop the unit of "V" and keep it unit-less until the DAC.

So to get the gain using an input in dB you calculate this: ( I will give a few examples)

Example 1:

0dB = 20 log(x), with x being the gain value in the SigmaDSP.

0/20 = log(x), divide by 20

10^(0/20) = x, Get the anti-log

1 = x, Put this (0db) into SigmaStudio GUI and you will see this value loaded.

Example 2:

-6dB = 20 log(x)

-6/20 = log(x)

10^(-0.3) = x

0.5011872 = x

Example 3:

-42dB = 20log(x)

-42/20 = log(x)

10^(-2.1) = x

0.00794328 = x. (now in The DSP this value is a little off. There are some round-off errors when the numbers start getting smaller)

You can see this by using the parameter window that is part of the capture window.

You see this was when I set it for -6dB. In this screenshot you cannot see the column headings but it is the data displayed in three formats. The first is in Hex. Then in 5.23 format, then in 28.0 integer format. You see the 0.5011872 which is what we calculated -6db to be.

Now, realistically, this is not practical at all for a small micro-controller to calculate these anti-logs! So unless the application is using a very high powered controller, or a personal computer, then the use of look-up tables will be the way to do it. This can be implemented in two ways.

1) You can use a look-up table in the micro-controller to come up with the values required.

2) You can use a look-up table in SigmaStudio and let SigmaStudio do the math. Then all the controller has to do is send an integer value for which index in the table to use to control a volume cell.

to implement this you use a standard lookup table set to integer input values and to output in fractional values. The table you can set to dB values to aid in inputting the values. You set the number of indexes and you are done. You need to have a source to feed these indexes to the table. This is done with a DC cell set to integer format. The value you put in this box will be the default value once you compile the program and run it. Once it is running the micro-controller only needs to change the integer value of the DC cell and the rest all happens like magic!

Here is what it looks like:

When you click on the "table" button this table opens up. Select the dB check box and enter the values in dB.

You see I filled in the first few entries.

The only detail is that you must be sure that a valid index is sent to this cell. An out-of-range input will have unpredictable results.

Here is a link to the Wiki page where this is explained.

Index Lookup Table [Analog Devices Wiki]

I hope this helps. I know it is a long tutorial I just typed.

Dave T