0
$\begingroup$

I've seen plenty of examples on how to drive motion of objects in Blender with audio, but I'm trying to do the opposite - drive audio properties based on the motion of objects.

More specifically, I'd like to tie the volume of an audio file to the rate of motion of an object in Blender (length of the displacement vector?) so that it adjusts "automatically".

So if the object is stationary the audio is quiet (or silent). As the object speeds up the volume of the audio would increase in tandem (to some limit of course), and as it slows down the volume would decrease again.

If this is possible, can it also be used to control playback rate as well to affect the pitch of the audio?

Note that, despite my previous question, I am definitely not trying to achieve a Doppler effect here (which would depend on rate of approach/retreat from the viewer).

Thanks!

$\endgroup$
  • $\begingroup$ Have you tried for example driving the volume and or pitch of a speaker object's data? $\endgroup$ – batFINGER Sep 14 at 7:17
  • $\begingroup$ Thanks for that suggestion, I'll definitely look into it. I probably should have mentioned that at my current level of experience the main problem is that I'm not really sure how to start approaching the problem. $\endgroup$ – adlaws Sep 15 at 6:29
  • $\begingroup$ suggestion: if your motion is baked to keyframe you could evaluate past and/or future keyframes to get a motion/acceleration-value. Using this to drive the properties of a speaker as batFINGER suggested would acomplish your goal. check out animation nodes and this answer (blender.stackexchange.com/questions/175287/…) to get a starting point of evaluation a animation curve. Beware, its not the same thing 1:1 but needs some tweaking for your usecase! Sounds like a nice idea, wish you well ;) $\endgroup$ – A M Sep 15 at 8:23
1
$\begingroup$

For anyone else interested in this, the following StackExchange post contains a script which does exactly what I need.

https://blender.stackexchange.com/a/66257/70741

Having never used drivers before, I found this an incredibly useful introduction to them, and I can see myself using them a lot in future - I am, by trade, a programmer, so it kind of suits my mindset I guess.

Basically just follow the instructions there to get the delta X,Y,Z between frames and drive some custom properties dX, dY, and dZ on the moving object - the linked discussion talks you through doing all of this.

Once you've done this, you can use the custom properties in turn to derive the distance of motion between frames as sqrt(dX*dX + dY*dY + dZ*dZ) and drive another custom property distance

Once you've done that, you can use the custom distance property to drive the volume of a speaker object (or whatever else) however you'd like. You can also easily calculate a speed value using the frame rate if you need it (distance was sufficient for me)

You'll likely need to tweak the resulting values to suit your requirements, but it's not that hard to do.

The adjustments are a little "choppy", but I'm pretty sure that can be smoothed out by updating the script to track a moving average over several frames, rather than just between single frames (which I'll be experimenting with next).

Thanks to everyone who dropped by to help out!

| improve this answer | |
$\endgroup$
0
$\begingroup$

The main problem i would say is getting some kind of motion- or speed-value. The idea ist getting the current location and comparing it to some locations in the past or future from the FCurve.
The AddOn Animation Node is used for this here. (Blender 2.9 with AN Version for 2.83 LTS)

The time info node gives the current frame, subtracting or adding some values to it will give it a moment in past or future time. Then you can check for both or multiple locations in the animation FCurve and calculate the distance or median distance. In the current solution only the current frame and last frame is checked (that means the checking of the future frame is redundant at the moment)

Having this motion- or speed-value you have to decide what behavior you want to have in motion or while resting and filter, map, calculate accordingly.

Unfortunatly the Attribute Output Node does set the value in the speaker object correctly but the sound is not affected while playing. The workaround herefore would be to set those current numbers as a Keyframe with the corresponding node.

Heavy inspiration for this workflow comes from Leander in an old question of mine: Continuous rotation in AN with certain control behavior? (Speed)

You can check out how this solution works in the following screenshot. enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ Amazingly detailed answer - thank you! I'll look into this for sure. $\endgroup$ – adlaws Sep 18 at 2:39

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.