Gain Function with adjustable roll-off
Hi all,
I am trying to get my head around the graphical programming in Sigma Studio and am stumbling on a "simple" algorithm:
I need a roll-off gain, that is: the gain itself is decreased in every sample-run by a constant value. E.g.:
t=0: Gain = 1, roll-off = 0.9
t=1 Gain = 0.9
t=2 Gain = 0.81
---
The roll-off value changes over time and can also get > 1.0.
The gain value itsefl which is applied on the signal is limited by a comparison to a constant.
I tried something similar to the adder with feedback of its output which keeps it's internal value constant.
But with a multiplier, this does not work since the first feedback value is always zero ...
Any ideas?
Thanks in advance an best regards,
Rainer
Audio Signal Processors
software
Sigma Studio 2.3+
Sigma Studio+ 2.0
SigmaDSP Audio Processors
adau1466
Show More
Hello Rainer,
I think I will need a lot more info to get this straight of what you want to do.
It is easy to take an output, use the "Feedback" cell then run that into a multiplier to multiply by "1" then feed that to the gain control.
But the initial value is tricky to do and then in only a few samples it will be down to zero so how do you reset it?
I think there will be several ways to do this but the details of what exactly you need is important for me to understand.
I hate to ask but I will need some more details.
Dave T
Hello Dave,
thanks for the quick response.
I am doing a kind of P- or PD controller for a speaker, modelling the coil temperature.
The temperature model uses (kind of) downsampling to be able to implement long time constants with the given number precision.
Let's think of a P-controller, to keep it simple:
When the modelled coil temperature exceeds the max allowed value, the gain needs to be reduced until the temperature decreases to the allowed value. Depending on the amount of temperature overshoot, a roll-off factor delta_gain is calculated which is applied to the gain. In every cycle, this gain is reduced by this delta_gain factor.
Something like
delta_gain = 1 + delta_T * P
gain = gain * delta_gain
gain = min (1.0, gain)
delta_gain has to be very close to 1 for long time constants so I'll probably have to run this at a lower sampling frequency as well.
I implemented something with a multiplier, a feedback and an AB-In-CD-Out block.
To circumvent the problem with the first feedback output being zero, I fed the AB-In-CD block with the multiplier output, compared it with 0 and used the multiplier input in that case (emulating a 1 as the feedback output). I don't like it ...
Basically, what I need is a gain with an external input that controls the slope of the gain, simply stated. Would be nice if ADI could implement that. Oh, and with lower and upper boundaries for the final gain value, please
Edit: forgot to mention that I tried a second approach feeding the delta_gain value into a General 2nd Order block using only the coefficients b0 and a1 to implement a 1st order lowpass. An additional clipper keeps the resulting gain values in the allowed boundaries. Same problem with number precision, here.
Can you work with this information?
Best regards,
Rainer
Hello Rainer,
Thanks, Yes, your response helps to better understand what you are doing.
You should not have to go through the trouble of going to a lower sampling rate because you have to filter before and after. You are not going to be doing much at that lower rate so in my opinion it is not enough reason to go through the hassle of changing rates.
What you are describing is somewhat already in the library. But there are some little details that might not work for you.
You can use an envelope generator. The peak ones will not work because the rise time in instantaneous but the RMS ones have a time constant that sets the rise time and has a decay time constant to control the decay. In this case the hold time should probably be set to zero. So this will track the level coming high level in over a long time constant. When the signal goes lower then the decay time will take over and slowly lower the level. I can see your goal is to measure the power and knowing the details of how much the temperature will rise with X level input and then the amount of heat dissipation will be the factor of how fast it will cool down when the signal goes down.
Gosh, you can really get into the weeds on this. Because, if the level stays loud for too long, more power going into the voice coil than dissipates then the temperature will continue to rise. I suppose even higher than the power level coming in. I guess I will have to leave these details to you but let me give you some examples that I think may help you get further.
I had done this example program to show how to get an RC curve and time constant that is equal going up or down. So in this example I compare the stock Peak Envelope generator, then MS generator, (It is labeled as "Signal Envelope" in the toolbox). I compare these stock envelope generators with my RC curve version built with more primitive blocks. I think you will be interested with that one since it works in a similar way that you describe.
In my example project I had measured a rise and fall time of over 4 minutes so you can get a long time constant. I suppose you might be able to cascade one of these into another one to multiply the length of time?
Anyhow, have a look. My version is in a hierarchy block which will make it super easy to export and import into another project. You can right click on the board and save it in a file and load it into your project.
7824.ADAU1452 RC Curve Up and Down Same TC.dspproj
Dave T
Thanks Dave for the elaborate response and for sharing your project.
I will definitely take a look into it but first, I have to enjoy my weekend
Best regards,
Rainer
Hi Dave,
I imported your project into Sigma Studio 2.3+ and re-did it for an EVAL ADAU1466.
Very nice, the outcome is close to that of the "Running Avg" block. Feeding it with a sine of level 1.0 results in (roughly) 0.63 where I had expected 0.707.
I slightly changed the first stage and replaced the "Abs" block with squaring the input signal resulting in an equivalent to the power signal. Then, the output is very close to that of the "RMS Envelope" (0.5 when feeding a sine of 1.0 and 0.125 when feeding a sine of 0.5).
That's very useful, thank you!
But still, I'm missing the gain function with the adjustable roll-off. If I could only program that myself. I've been working with Sharcs for more than 10 years, now ...
I think I'll be doing an approximation of (1+x)^n for small x using sum and feedback.
Best regards,
Rainer
Hello Rainer,
I know there will be a way to do what you want to do but I have to better understand what it is and how it will work? We can put in a test to prevent the first value from being a zero. But if it is a roll-off, then I would thing you are inverting and subtracting a small amount from the input? In that case a zero would not matter. If you are obtaining the reciprocal and then multiplying then of course a zero would not work.
There is so much you can do with the graphical interface and the more primitive blocks. I just apologize that I do not "see" what it is you are trying to do.
I would say to start a new thread but that was the topic of this tread!
If you could explain this further? Perhaps draw a diagram of what you want to do?
Dave T
Hello Dave,
thanks for getting back to this.
Meanwhile, we dediced to abandon the Sigma DSP and replace it with a Sharc. I found it enjoying but tedious and time consuming to move the very basic blocks around and trying to find out what they're doing by trial and error and time is short. The second step of trying to parametrize the algorithms and allow live control I didn't want to go.
So, for me there's no need to dig deeper into this issue.
Nevertheless, a very brief description of what I'd have liked to use:
a gain control with an adjustable slope allowing very low values (e.g, 0.1 dB / s) and boundary values (e.g. 0 dB | -60 dB) to prevent it going to -infinity (dB).
Best regards,
Rainer
Please log in to reply.