Kontakt Script 'Return To Zero' help.

Sampler and Sampling discussion (techniques, tips and tricks, etc.)
Post Reply New Topic
RELATED
PRODUCTS

Post

Hey Everyone,

I've been doing a very basic thing with a script in order to define random detune values. I also setup a knob that defines a time parameter for the wait function. My goal is to create a sense of gravity around the random value so that the detuning slowly (over the course of what's defined by the Time knob) moves back to zero.

I'm stuck trying to implement the 'gravity' portion of this. I don't know if anyone can help or even if this is simple to implement.

Here's where I'm at:

Code: Select all

on init
declare ui_knob $Time (1,1000,1000)
	set_knob_defval($Time,10)
	$Time := 10
	move_control($Time,6,2)
	make_persistent ($Time)
	declare $fine
	declare ui_label $label3 (1,1)
	set_text ($label3, "Fine: 0 cent")
end on

on note
	$fine := random(5,10)
		change_tune ($EVENT_ID, $fine*1000,0)
		set_text ($label3, "Fine: " & $fine & " cent")
end on
This is purely for my own interest and in no way related to anything commercial so I figured it would be above board to seek some help.

Thanks everyone!

Post

The drift away and gravitate back needs to be in the algorithm.

Currently you have just a random drifting force.
So add another force pulling back, which gets stronger the further it is away from zero. Quadratic functions fit that purpose.

Let's see whether you can come up with an algorithm for that... (mind you, this is your project, not mine)
We are the KVR collective. Resistance is futile. You will be assimilated. Image
My MusicCalc is served over https!!

Post

indeed my project and thank you for the input! I'll have to dig deeper in order to understand quadratic functions but its an opportunity to learn. I didn't even consider that it would have to be weighted in proportion to how large the deviation is. Very clever.

Thanks again for your guidance!

Post

To name it, this can be described as (or is close to) "easing in", or "easing out", in the coding litterature.
Because i didn't heard about quadratic or other techniques before, i used to simply write one cosinus/sinus function to produce similar results, but then the ease is slow as a pendulum near its edges.
Some very clear examples of other different options :
https://stackoverflow.com/questions/831 ... g-function

Post Reply

Return to “Samplers, Sampling & Sample Libraries”