[SOLVED] Math for Modulating parameters with Audio
-
Hello,
I am in the process of rewriting some patches I did years ago. One of the functions was to use audio to modulate things like position, scale etc based on audio. I did not want simple additive amplitude modulation, I wanted the modulation to wiggle back and forth from the current value of the parameter like an audio wave.
One method I used was a bit of math combining the amplitude with the random wave at 60hz. I think I split the random value in half, anything under 50 was - and anything over 50 was positive. Then multiplied this with the audio and scaled it with an "influence" parameter to move stuff around.
The other was using a version of an overlay transfer but i'm not sure that was successful.
Edit: I found a cleaner version of this formula online:
// For 'a' base layer, 'b' top layer.
if (a < 0.5) { result = 2 * a * b;
} else { result = 1 - 2 * (1 - a) * (1 - b);
}It's a combination of a multiply transfer math for values under .5 and a screen transfer math for values over .5
is there a better way to accomplish this?
-
Edit: I found a cleaner version of this formula online:
// For 'a' base layer, 'b' top layer.
if (a < 0.5) { result = 2 * a * b; } else { result = 1 - 2 * (1 - a) * (1 - b); }
It's a combination of a multiply transfer math for values under .5 and a screen transfer math for values over .5
I don't think it's quite the right thing.
-
I figured it out. Sinusoidal modulation:
modulatedParameterValue = parameterBaseValue + Math.sin(currentPhase) * modulationDepth * audioAmplitude;I use a wave generator to supply the phase and it really looks super cool. With a smoother on the other side of it I can get a tone of great audio reactive modulations.
-
I'm very interested to know what this looks like in practice.
Also, I realized that this User Actor that I originally got from @mark and then modified might be useful for similar use cases as well (though probably not for your exact use case).