Comparing the linear level of two signals is fairly simple in SigmaStudio. You can basically calculate the envelope of each signal (using peak, MS, or running average), and then subtract the two outputs to find the linear difference in amplitude.

However, what about if you want to compare two signals to see if their RMS levels are a certain number of decibels apart? Logarithmic calculations are more difficult.

If you'd like to use this functionality, then the RMS Table is exactly what you need. However, in order to implement it correctly, you'll need to manipulate SigmaDSP's number representation to get it to work. Essentially, you need to map the logarithmic scale to the linear scale before performing the comparison. I'll show you how it works.

The RMS Table has 33 points in it. Each point maps to an RMS level spaced 3 dB apart from its neighbor. This table mapping is shown below RMS_Table_Mapping.txt (it's also in the help file).

So, the RMS level of the input is measured, compared to the points on the table, and with some interpolation, the proper value is output. For example, if my input is at -61.5 dB RMS, then the points corresponding to -63 dB and -60 dB will be chosen, and the output will be a kind of interpolation between those two points, and the output will basically be the mean of the value at -63 dB and the value at -60 dB.

In any event, that's a bit too much detail for this example. Basically, you need to create your list of output values that will correspond to each of those inputs - the goal is to map the logarithmic value (i.e. detected RMS level in dB) to a linear value that's easier to work with.

The natural idea would be to just start at -90, -87, -84, etc... and enter those values directly in your table, but since the SigmaDSP's number system can only represent values between +16 and -16, that's not an option. So, for my project, I decided to just start at 0.1 and increment by 0.1 on each index. What you're essentially doing here is taking an RMS measurement and mapping it to a linear value so it can be easily added/subtracted. For lack of a better system, I simply picked the index number and divided it by ten in order to make it fit SigmaDSP's number system.

It may be a little confusing, but the main point is this: We're essentially representing the dB value using arbitrary numbers that work with the number format in the DSP. The important thing is to remember that for the scale I picked, a difference of 3 dB RMS maps to a step of 0.1 in the linear scale.

Here's the completed table:

Next, I set up one RMS table for each input. Each cell must have the exact same settings for this to work - using the Cell Settings Copy/Paste options from the right-click menu is a good way to ensure this. Next, I need to compare the outputs of each table. This is accomplished using a subtraction cell. Because I want to check to make sure the difference of the two signals' amplitudes exceeds a certain amount, and not necessarily that one is greater than or less than the other, I use an absolute value cell to make sure this difference is always positive. Finally, I use a logic AB comparison cell to determine if the result of that subtraction (i.e. the difference of the two signals' RMS levels) exceeds some threshold.

The completed flow looks like this:

So, here's an example that you can test in the project: If my 1st input is measuring -3 dB RMS, then its table will output 3.0 (see table above). If my 2nd input is measuring -15 dB RMS, then its table will output 2.6. Then I can simply linearly subtract these signals and find that the difference is 0.4. Because I've mapped a linear change of 0.1 to represent 3 dB, I cal calculate that a linear change of 0.4 means a change of 12 dB. Thus, you can see that -3 dB and -15 dB are indeed 12 dB apart. It works!

Next, in the logic cell, I can compare that 0.4 value to any threshold I choose (for example I will choose 0.2, or 6 dB). I can then tell the logic cell to output different control signals based on the result of the conditional. Since, in this example, 0.4 is greater than 0.2 (i.e. 12 dB is greater than 6 dB), my logic cell tells me that the conditional is true. Indeed, the difference of 12 dB is greater than my threshold of 6 dB.

Please try this out using the attached project. It was built using an ADAU1781 SigmaDSP but could easily be ported to other processors. If the two input signals have a difference of 6 dB or greater, then the logic cell will output a '1', signifying that the condition is met.