EDIT: JF posted a solution at the link below. Very nice!
I am attempting to delay a signal by the length of the period and then normalize that signal by the using the largest value found during that same period. This way, each discrete period of audio is multiplied to full scale.
My WIP patch is attached with comments.
I will run down the basic idea I have here..
1. Using contents of gen~.zerox to obtain zero crossing and period length information.
2. Using sah, >p, and history to obtain the largest value (I think the issue is here).
3. Dividing 1 by the largest value in the period to obtain my multiplier.
4. Delaying the signal by the period length and normalizing it by the multiplier.
What I think I need to do is reset the sah object so a new largest value can be found every period, but I can't figure out how to do this. I attempted to bring this set of objects into codebox and reset it using an if statement but had no success. I think the answer to this is simple but its eluding me..
edit: I also will need a way to save the last biggest value as a variable in codebox and output that to normalize the delayed, previous period after sah is reset and it is busy obtaining the current period's largest value.