0
$\begingroup$

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?

$\endgroup$
  • $\begingroup$ did you try the Envelope or Limit modifiers $\endgroup$ – Chebhou Feb 9 '15 at 3:59
  • $\begingroup$ @Chebhou The problem is that baked F-curves can't be edited, so I'll need to use the F-curve for a custom property and use that as input for a driver for the shape key. I did try the bake action as per my own suggestion in a comment to this question, but that only bakes the location, rotation and scale. $\endgroup$ – user7952 Feb 9 '15 at 4:06
  • $\begingroup$ if this solve your problem write an answer F-Curve Amplification $\endgroup$ – Chebhou Feb 9 '15 at 11:53
  • 1
    $\begingroup$ @Chebhou I couldn't get that to work. The speaker tools don't show up in the addons, although it's installed. However, I tried resampling the audio to 32 bit float, and suddenly the height of the baked curve was a lot more to my liking, and possibly with some edits, eg compressions and/or normalizations, I may get what I'm after. It looks like Blender doesn't map unsigned 16 bit integers correctly. Perhaps I should file a bug report about that. I'll do some further experimenting, and if I'm able to get close enough, I'll post it as an answer. $\endgroup$ – user7952 Feb 9 '15 at 13:03
  • $\begingroup$ That should be signed 16-bit integers. This is the most commonly used format for .wav and .mp3. $\endgroup$ – user7952 Feb 9 '15 at 21:12
1
$\begingroup$

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, Key > Bake Sound to F-curves
enter image description here
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
enter image description here
enter image description here

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).

$\endgroup$
1
$\begingroup$

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:

  1. 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.

  2. Use the Sound Drivers add-on. (I haven't tried it, but it looks nice!)

  3. After baking, un-bake the sound to a normal F-Curve. Then you can scale it or edit details.

Good luck!!! :)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy