I am animating certain objects in a scene using audio in animation nodes. The current setup makes my models react in a very aggressive way to the audio.

Is there a simple way to smooth the reaction to it? I know that for some this might be a simple math problem but I haven't been able to wrap my head around a solution yet.


Edit: I have played around with the attack and release settings but they're not working as I would expect them to.

enter image description here

  • $\begingroup$ Welcome to StackExchange! What is your current setup? $\endgroup$ – Omar Emara Apr 15 '19 at 15:25
  • $\begingroup$ Hi @OmarAhmad. I added an image in as an edit. Thank you for your warm welcome. $\endgroup$ – Glen Montanaro Apr 16 '19 at 9:01

As you have guessed, the Attack and Release are the values that controls the smoothness of the visualization. But there are couple of things to note:

  • An attack or a release value of 1 doesn't mean maximum smoothness. It means the values will nearly never change. So use the values responsibly, don't just enter values arbitrary and expect things to work. Usually, a release value around 0.6 and a low attack value works best.
  • In order for Animation Nodes to compute the spectrum at a certain frame, a number of preceding frames have to be computed in order to perform the smoothing. The number of frames computed is exposed in the Advanced Node Settings as the Smoothing Samples option. Higher values means more accurate smoothing, however, all values higher than a certain value converge to the same result. So don't increase this value too much, it will needlessly increase the execution time.
  • There is a theoretical limitation on the smoothing capabilities of the node. So you may not always get the result you are looking for. This is especially apparent in songs with a high tempo (BPM).

To have a better understanding of the inner workings on the node. I present a somewhat messy explanation. The names Attack and Release come from the concept of ADSR Envelope in music synthesis, which is short for Attack, Delay, Sustain, and Release. When you press a key on a piano, the Attack of the note is the time taken to reach the peak of the note, so a small attack value means the note reach its peak faster and snappier while a high attack value means the note reach its peak slowly and more smoothly. Similarly, the release is the time taken for the note to stop after the key is release.

In the context of music visualization, the attack and release usually have different interpretation. Lets say at frame zero, we computed the spectrum to be 10, and at frame one we computed the spectrum to be 3. This is a decrease of 7 units in just one frame! This certainly won't look good! So, instead, we give the user a "smoothed value", this value is a linear combination between the computed value and the value computed at the previous frame. The factor of the linear combination is the attack or the release value depending on whether the value increased (attack) or decreased (release). Since the value in our example decrease from 10 to 3, then the release values is utilized. And instead of giving the user 3 which implies a decrease of 7, we give the user $10 - 7(1 - \delta)$ where $\delta$ is the release value. A high value of $\delta$ translates to an output closer to 10 (Which we interpret as smoothing because it is a lower decrease) and a lower value of $\delta$ translates to an output closer to 3.

| improve this answer | |
  • $\begingroup$ Thank you for your detailed explanation. I wasn't aware of the smoothing sample control, that greatly helped the visual and upon playing a bit more responsibly with A and R I got a much better result. $\endgroup$ – Glen Montanaro Apr 16 '19 at 11:39
  • $\begingroup$ One interesting realisation is that initially I was expecting A and R to be measured in s or ms but if their functionality is related to the amount of smooth samples the user has set, maybe getting to compute them in real world units would exclude the need for the user to have to find an optimum setting for the smooth samples. I'm not sure if I'm making much sense. $\endgroup$ – Glen Montanaro Apr 16 '19 at 11:46
  • $\begingroup$ @GlenMontanaro Expressing A and R in time units is problematic, since we are merely performing spectral analysis on a discrete data. And the data is usually multiple overlapping notes. I agree than the current values aren't exactly user friendly, I will try to implement another smoothing system that is more predictable. Perhaps using absolute step sizes. Feel free to suggest another approach. Not sure why you got the idea that they depend on the number of samples, they don't. $\endgroup$ – Omar Emara Apr 16 '19 at 13:39
  • $\begingroup$ I must have misunderstood your explanation about the workings of the smoothing system. If absolute step sizes would be based on time then making A and R into time units should become easier, unless I've misunderstood the way the smoothing system works. Thank you very much for this amazing useful work. $\endgroup$ – Glen Montanaro Apr 16 '19 at 14:53

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.