Normalize in gen~ like the normalize~ object

Recall the Coll's icon

Hello, I was wondering if there is a way to normalize in gen~, like the normalize~ object works.

Graham Wakefield's icon

The description of normalize~ explains how it works:

  1. it keeps track of the largest peak of the input received so far (or since the last 'reset' message)

  2. it has a max output parameter, and divides this by the largest peak so far, to get a scaling factor

  3. it outputs the input multiplied by this scaling factor

We can do all of this in gen~.

For (1), first we care about absolute magnitude, so use abs then send this into a maximum fed back through a history to track the largest peak so far. If you want to add reset functionality, insert a switch 0 into the feedback loop, triggered by another input.

For (2) you can use a param limit and divide by the output of (1), and for (3) multiply this by the input to get the output.

Recall the Coll's icon

Thank you very much for the detailed reply.

lizard+++'s icon

normalizer.mp4

Hello Graham

Let's say i have a phasor from outside the gen patch and i wish to use that as reset signal. (in2)

This phasor is reading buffers in another gen patch and it is passed together with the data read from buffers (so when phasor is 0 also in1 is 0 as i am reading waveforms that start at 0.)

i would like to state this:

stage1 (when phasor is 0 for the first time)

the normalizing multiplier is 1.

stage2 (while phasor is different from 0)

check for maximum and calculate the new normalizing multiplier.

stage3 (when phasor is 0 again as in1)

change the old multiplier with the new one and apply it

reset the max value to 0.

go back to stage2

Hope i explained it well, but i attach a vid of what i'm trying to achieve. is it possible to code such a process in gen?

Graham Wakefield's icon

A phasor is hardly ever exactly zero, but we can easily derive a trigger when a phasor wraps by just looking for any sample to sample change that is absolutely greater than 0.5 (which will catch both positive and negative frequency wraps. You can do that with phasor -> delta -> abs -> > 0.5 for example.

You can use this trigger to sample & hold a value of choice using a latch operator: send the trigger to the right inlet of the latch.

So, send the normalizing multiplier to the left inlet of the latch, and the output of this will only update once at the end of each phasor ramp.

The same phasor trigger can be used to reset the normalize calculation, but you'll want to insert a history between them so that it doesn't reset until after the latch has updated. (Or vice versa, insert a history before the input of the latch. Either works.)

lizard+++'s icon

Hi!

Thank you so much for the fast reply, it works perfectly now, the latch was what i was missing out.

I'm porting some of my designs in gen to use them in rnbo later. Gen is great, God bless you for making it.

:heart