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

How to extract maximum value from "Max and Hold" for calculation?

SigmaDSP & SigmaStudio AriLunden Feb 6, 2013 00:00 5 replies Original on forum ↗
Subscribe
AriLunden Question
Feb 6, 2013 00:00

Hello,

I'm using 'Max and Hold' to find the maximum value of the signal between two zero crossings and that works.

Now I need to use that maximum value to scale another signal accordingly. The other signal would be scaled like: arbitrarily_set_constant/found_maximum_value=scaling_factor.

How would I go about that? Kind of stuck here, never done this before. I'm working with ADAU1701.

Thanks,

Ari

Audio Signal Processors

max_and_hold

SigmaDSP Audio Processors

adau1701

ADIApproved Reply
Feb 6, 2013 00:00

There is a division block that is a bit of an expensive computation (in terms of instructions required), but it should get you the division you need. You can then wire the output of that either to a multiplier (for instant level changes) or to a slew volume control (for a slewing volume change, avoiding discontinuities in the audio signal that would result in audible artifacts).

Multiply:

https://ez.analog.com/cfs-file/__key/communityserver-discussions-components-files/396/9323d412503889c83cc693634d655cc9.html

Slew:

e7f846d55c396caaddd22646c1b4f531.png
e7f846d55c396caaddd22646c1b4f531.png
e7f846d55c396caaddd22646c1b4f531.png-137x104.png
e7f846d55c396caaddd22646c1b4f531.png-137x104.png
af8935a7bf1d601f16f1253259f2c792.png
af8935a7bf1d601f16f1253259f2c792.png
af8935a7bf1d601f16f1253259f2c792.png-142x87.png
af8935a7bf1d601f16f1253259f2c792.png-142x87.png
ADIApproved Reply
Feb 6, 2013 00:00

Hi Ari:

If I may ask, what are you doing? There might be easier ways to do what you are trying to do. As Brett mentions, a division is expensive in the 1st 2 generations of SigmaDSP.

Miguel

AriLunden Reply
Feb 6, 2013 00:00

Hi,

I tried the division + multiply scheme, but it didn't give what I was looking for. The problem is that in that form the calculation is done continuously. The attached pic hopefully explains bit better what I have in my mind.

The code is currently made to work with the positive part of signal only. The test signal is a two tone sine. Because of the coarse resolution of real time plot window, it looks like something else.

It might first look like why I just don't use 'gain', but the idea is to scale only the 'half cycles' that go over certain limit.

Thanks,

Ari

db58b3a18045bb97fa395eca2fa25ae1.jpg
db58b3a18045bb97fa395eca2fa25ae1.jpg
db58b3a18045bb97fa395eca2fa25ae1.jpg-450x277.jpg
db58b3a18045bb97fa395eca2fa25ae1.jpg-450x277.jpg
KJBob Reply
Feb 14, 2013 00:00

Hi Ari,

You can do your desired function by searching through a delay for the next peak. The results for positive excursions only appear like this:

This method appears like a FIR filter, except each tap doesn't directy contribute to the output. Instead, the taps drive logic that finds each positive-going zero crossing, then looks backward through the delay for the next upcoming peak. This is latched and used to calculate the gain for the entire excursion. The logic surrounding the delay cells is shown below:

I used 50 of these to form a delay about 1mS long, enough to find the peaks in signals as low as about 300Hz.

If you want this behavior for both positive and negative peaks, and can tolerate some error when adapting to new peaks, a simple limiter (under Dynamics) would work fine and be a whole lot simpler. Otherwise, you can have a look at the above method by downloading this project into SigmaStudio.

Bob

1f8e54781919f0b10d8f80a16c6185ab.jpg
1f8e54781919f0b10d8f80a16c6185ab.jpg
1f8e54781919f0b10d8f80a16c6185ab.jpg-450x242.jpg
1f8e54781919f0b10d8f80a16c6185ab.jpg-450x242.jpg
2ea629a50867131c9690a3ca05c78570.jpg
2ea629a50867131c9690a3ca05c78570.jpg
2ea629a50867131c9690a3ca05c78570.jpg-450x216.jpg
2ea629a50867131c9690a3ca05c78570.jpg-450x216.jpg
AriLunden Reply
Feb 19, 2013 00:00

Hi Bob,

Took a while to wrap my head around this, but I think I got it. Very clever solution.

Thanks,

Ari