Normalizing audio signal for ADC input
What you are asking for is a non-linear operation, so will add distortion.

The details are all in the tradeoffs you haven't told us about, particularly response time.  For example, suppose there is a loud passage, then it gets quieter.  What metric do you use to decide this quiet isn't part of the signal that you want to keep, like a person pausing between words?  Are you allowed to look ahead (store signal, then play back later)?  If not, how long is long enough to decide that quiet is the new normal?  Notice that you don't get to say "instantly", since audio is iherently AC, which will have regular zero crossings.

People have been dealing with these issues and making these tradeoffs in various ways for a long time, before there were even transistors.  Look up something called AGC (automatic gain control).

Otherwise, without a real spec, there is little we can help with.