Nyquist plugin for envelope inversion

Hello,
I am looking for a possibilty to invert the envelope of a sound file (y-axis).
So that high amplitudes will be muted and low amplitudes will be amplified.

I tried working with plugins like hyperexp (where every amplitude is muted or amplified to about the same level)
and other Compressor effects but as I am totally new on Nyquist, it is hard to figure in which way i can analyze the envelope and write a function for the inversion of the data.

As far as i understand i need 3 steps.

  • Analysing the sound file to get the data of the amplitudes
  • Write a function to set new values for each amplitude automatically
  • Apply the new values on the sound file to output the inverted envelope

For the first point i tried (linear-to-db signal) but i could not find out in which range the data is output to get the right function for the inversion. For the last point i thougt a (vector) should do it, but as I said Im not really into it.

Anyones got a hint? Guess it would not be very difficult if i was more familiar with Nyquist.

Have a look at “Pop Mute”. It does something very similar to what you are asking. Missing features - Audacity Support

Examples below are for mono tracks. The can be expanded to work with stereo tracks later if required, but it is simpler to start with mono tracks.

For the first step you need some sort of “envelope follower”. That is, to track the amplitude of the input.
A simple way to do that is with the function snd-avg Nyquist Functions
For example, if you select a (mono) track and apply the code (using the “Nyquist Prompt” effect):

(setq step 100)
(snd-avg s step step op-peak)

The first thing that you will notice with this is that the output length will be very much shorter than the selected audio.
What it is doing is looking at the peak level in each successive 100 samples, thus each sample of the output represents 100 samples of the input. If you zoom in on the result you will see that it has the same “shape” (envelope) as the input.
Setting “step” to a larger value will make the envelope smoother as it is then riding over a larger number of samples.

(For a more sophisticated envelope follower, see snd-follow Nyquist Functions)

If you invert that (output) signal and add 1.0, it will become like an upside down envelope.

(setq step 100)
(setf env (snd-avg s step step op-peak))
(setf env (sum 1 (mult -1 env)))

The upside down envelope can then be applied to the original audio as a scaling factor (multiplication factor).

(setq step 100)
(setf env (snd-avg s step step op-peak))
(setf env (sum 1 (mult -1 env)))
(mult s env)

Is that enough to get you started?

I’m looking for a program that changes from moment to moment the envelope of a track, preferably with automation: setting the time, beaten, frame = 32 or 64? Already exists?

Are you asking about “envelope inversion”? If not, please start a new topic.
As your question stands, it is not clear what you mean.