envelope tracking

Roman Thilenius's icon

i often use

peakamp~ (<-metro)
sig~
slide~


in old patches to find the envelope of the input signal.

is there a way of doing the same without leaving signal domain?

any other thoughts?

James Bradbury's icon

rectify your signal, then smooth it. Do what you want with it after that.

Here is an example of a simple onset detector with a schmidt trigger.

Max Patch
Copy patch and select New From Clipboard in Max.

Roby Steinmetzer's icon

This is what I always use:

Max Patch
Copy patch and select New From Clipboard in Max.

Roman Thilenius's icon

i am staying away from the usual lowpassfiltering (straight peak outline, nothing about power at all) , because my aim is to demodulate/modulate the envelope independly from the "content" - and it should work for any material.

creating a signal-only version of peakamp~ seems to be impossible unless you want to use you all of your CPU for it?




volker böhm's icon

Hi @Roby Steinmetzer you probably want a 90 degree phase shift between your two squared signals, no?
For this, you'd have to use both outlets of hilbert~, as the correct phase difference is only achieved between the two outlets - not between the inlet and one of the outlets.

James Bradbury's icon

i dont really understand why you need peak amplitude of each vector. If you want to do peakamp~ at signal rate there are libraries for doing it.

Pedro Santos's icon

James, just a hint: to rectify you could use the abs~ object, no need to use *~ and then sqrt~.

James Bradbury's icon

I am aware of the abs~ object. It is cheaper to do *~ -> sqrt~.

https://en.wikipedia.org/wiki/Transcendental_function

Roman Thilenius's icon

.
compiled third party objects are out of question. :)

no no, not each vector, but in a range of around 10-80 milliseconds.

volker böhm's icon

@Roman Thilenius
if you really need this functionality, it's pretty easy to do it with gen~.

Roman Thilenius's icon

gen~ also falls under "third party" here. plus there are sanctions against it because it supports cuba.


Roby Steinmetzer's icon

Hi Volker, to be honest, I don't have the slightest idea how all this works.
I use this patch for years, I don't even remember where I got it from.
Could you post a patch that shows a corrected version? Thanks.

Roman Thilenius's icon

btw of ocurse i am using rampsmooth, not slide (1st post)

volker böhm's icon

Hi Roby, looks like your patch tries to calculate the "instantaneous amplitude". For this you need to construct an analytic signal. Then you can calculate the magnitude from it's real and imaginary parts.
The [hilbert~] object delivers two signals that have 90 degree phase difference. The phase shift towards the orginal input signal is (i believe) frequency dependant, and not useful in this application.
The instantaneous amplitude is mostly used to demodulate signals that have been modulated onto a simple, narrow-band carrier (like a sinusoid), e.g for broadcast.
It can be used for wide-band signals (music) if followed by an averager - like in your patch.
Don't know if this performs any better than simply squaring/rectifiying + averaging, though.

Max Patch
Copy patch and select New From Clipboard in Max.

Roby Steinmetzer's icon

Thanks Volker for taking the time to clarify this and for the example patch. As far as I can see from a quick (visual) comparison, both patches show the same result. So I guess, for a simple envelope following task, both are usable.