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

Change Filter Boost parameter via I2C commands

SigmaDSP & SigmaStudio Stomper85 Mar 24, 2022 00:00 5 replies Original on forum ↗
Subscribe
Stomper85 Question
Mar 24, 2022 00:00

I have a parametric EQ Block with 3 Biquad Filters:

Now I want to change Boost via I2C Command to let's say 15 (from the 10 above). Later this should happen via I2C write command from MCU.

so now I get following Commands as output from the Sigma Studio:

An online biquad coefficient calculator says that this only changes the coefficients A0 and A2.

So I expected either all parameters get updated but only A0 and A2 changing, or only A0 and A2 gets updated.

But as you can see the output is different to what I expected.

I also do not understand the naming scheme exactly. Does Param Name: PEQ1Chan20xx correspond to My Filter 1, PEQ1Chan21xx to Filter 2 and so on?

This would make some sense but as I do not change filter 1 and 3 only the 21 should change. But it is changing many more parameters.

So my conclusion is... I do not fully understand what is happening there. Is there more maths in the background, what I cannot se in the window?

But why does this happen and how can I derive an algorithm to change this at runtime?

I want the user to be able to give a boost value between 0 and 10 dB by a knob. How can I translate this Boost value to the correct coefficents?

Or is the only way to build a lookup table?

Thanks and best regards

pastedimage1648163586824v1.png
pastedimage1648163586824v1.png
pastedimage1648163773390v2.png
pastedimage1648163773390v2.png
Rocha Reply
Mar 28, 2022 00:00

Hi,

You need calculate each filter ( then get 4 needed bytes value for each parameter ( B2, B1, B0, A2, A1 ) total is 20 bytes , so you will need the folowing:
48000hz ( fs from your project )
74 hz ( frequency you want to boost )
1.41 factor ( quality factor )
0 gain
0..10 Boost
Low shelf ( Filter type )

With all values, do calculation and you will have 20 bytes as result, that is ready to send to your DSP, if you need change frequeny too, you can, just keep filter address same.

i have write an realtime javascript web page, that can helps you with that, you can see it at this website also code examples is available.

As you want to use a knob, you have the folowing options:

1) Use analog potentiometer, then read analog value from your microprocessor input, calculate desired filter, then send bytes to DSP

2) Use rotary encoder, read value, calculate desired filter, then send bytes to DSP

3) Use html User UI to do that ( if your processor have network access and an http server)

Please note

( Some DSPs needs to write 5 bytes to safeload, ont this case, send 0x00 + 0xXX + 0xXX + 0xXX + 0xXX ) where XX is each byte value of each parameter.

Using rotary encoder, you can have at same time Html User Interface too.

Not all filter types requires/have same parameters, it may difer from one to another.

Best regards..

Stomper85 Reply
Mar 30, 2022 00:00

The Code generator looks pretty nice! I guess this helps me out.

Thanks a lot, I will test this in the next few days!

Best regards

DaveThib Reply
Mar 30, 2022 00:00

Hello,

I just want to clarify one small thing with what Rocha said in a couple of places.

Rocha said:
then send 5 bytes to DSP

It actually is five WORDS not bytes. Each word is 32 bits so each word is four bytes with 20 total bytes being written to the DSP. With this DSP you must send the data in full words or it will not write the data into memory. If you only send it 1,2 or 3 bytes then it will think it is an incomplete message and will ignore the data.

The exception is with registers. Most of the registers are 16 bits so in that case you can write two bytes in one I2C message and the data will be written to the part. With the filter coefficients, those are all in parameter RAM and those are all 32 bit storage locations.

Dave T

Rocha Reply
Mar 30, 2022 00:00

Thanks DaveThib for your clarify.

I have corrected my post, so for future, users can see it correctly,

About Code Gerenator/Online Calculator, this info is already correct.

DaveThib Reply
Mar 30, 2022 00:00

Thanks!

I appreciate your help and information. It was just that I have seen people have problems due to this.

Dave T