I'm trying to drive a shape key by baking an audio file to an F-curve. However, although the audio is normalized to -.1 dB, the peaks of the baked curve are far too low, and never even get close to 1. I need to highest peak to give the shape key a value of exactly 1, and the lowest to give the shape key a value of exactly 0, so I need to scale the F-curve and possibly also move it up or down a bit. To do this, I need to find the maximum and minimum values of the baked F-curve. How can I achieve this?
I've partially solved this by using some external programs.
First I edited the audio in Audacity, to get a curve shape I was happy with. I won't go in to the detailed workflow, as this would be beyond the scope of this site. What I did was basically applying a series of compression, normalization and amplification filters.
Secondly I resampled the audio to 32-bit floating point, as it seems Blender doesn't correctly map 16-bit integers to values between 0 and 1. For this I used SoX.
sox <infile> -b 32 -e floating-point <outfile>
(I could do both with either program, but I find SoX to be better at resampling and Audacity more intuitive, as I can see the changes directly affecting the shape of the curve).
Then, in Blender, I created an object (in this case an icosphere) and added a keyframe (in this case to the Z location) at frame 1.
Then, in the graph editor,
Bake Sound to F-curves
Experiment with the different settings. I used an attack time of 0 and left the others to their defaults. Increasing the attack time may make the curve smoother, but it may also introduce clipping below 1.0, if the curve starts decaying before the attack time has passed. Likewise the release time may introduce clipping above 0.0, if the curve turns upwards before the release time has passed.
Here's what I got
The animation gets a bit jumpy. This is mainly caused by resampling the audio to the framerate (e.g. resampling from 44100 samples/second from a CD source to 25 samples/second for a PAL DVD).
I'm afraid that the accepted answer to this question, while feasible, is a long and hard-to-tweak workaround. Also, a similar (later) question has a good answer here. To summarize what's there, and what I've read elsewhere, there are three options:
Create a custom property, bake your sound to the property, then create a driver with a simple python expression to drive other properties at the required scale. This is what I did. More details in the link above.
Use the Sound Drivers add-on. (I haven't tried it, but it looks nice!)
After baking, un-bake the sound to a normal F-Curve. Then you can scale it or edit details.
Good luck!!! :)