# Smoothing tables



## kotori (Aug 14, 2006)

Here's a simple recipe for smoothing table values (useful when the user paint curves using the mouse):
````*function* smooth_array(array, smoothness)
``````*declare* i
``````*declare* j``
``````*for* i := 1 *to* smoothness````
````````*for* j := 1 *to* num_elements(array)-2
``````````array[j] := (array[j-1] + array[j] + array[j+1]) / 3
````````*end for*````
``````*end for*
````*end function*

smoothness should be an integer greater than or equal to one. The greater the smoother the result.


----------



## Thonex (Aug 14, 2006)

Awesome!!!

How hard would it be to set an "auto gain" function whereby it would "normalize" the curve so that the maximum value would still be 127?

Cheers,

T


----------



## kotori (Aug 14, 2006)

Thonex @ Mon Aug 14 said:


> Awesome!!!
> 
> How hard would it be to set an "auto gain" function whereby it would "normalize" the curve so that the maximum value would still be 127?
> 
> ...



That's pretty easy - best way is to use a separate normalize function to keep things modular:
````*function* normalize_array(array, max_val)
``````*declare* found_max
``````*declare* i
``````found_max := array[0]
``````*for* i := 1 *to* num_elements(array)-1
````````*if* array_ > found_max
``````````found_max := array
````````*end if*
``````*end for*
``````*for* i := 0 *to* num_elements(array)-1
````````array := array * max_val / found_max
``````*end for*
````*end function*__

Cheers,
Nils_


----------



## Thonex (Aug 14, 2006)

kotori @ Mon Aug 14 said:


> Thonex @ Mon Aug 14 said:
> 
> 
> > Awesome!!!
> ...


_


Thanks Nils  

You bring so much to this forum.... thanks for all your contributions. If ever you come to Los Angeles, Craig and I and the rest of the LA VI-Control gang will take you out for dinner and make sure you have a great time! 

Cheers,

T_


----------



## kotori (Aug 15, 2006)

Thonex @ Tue Aug 15 said:


> Thanks Nils
> 
> You bring so much to this forum.... thanks for all your contributions. If ever you come to Los Angeles, Craig and I and the rest of the LA VI-Control gang will take you out for dinner and make sure you have a great time!
> 
> ...


Wow, what an offer!  
That's very kind of you. Thanks.

Cheers,
Nils


----------



## Dynamitec (Oct 12, 2006)

Hi!

I did small changes to Nils script to normalize tables with negative values too.

*function* normalize_array(array, max_val)
````*declare* found_max
````*declare* i
````found_max := array[0]
````*for* i := 1 *to* num_elements(array)-1
````````*if* abs(array_) > found_max
````````````found_max := abs(array)
````````*end if*
````*end for*
````*for* i := 0 *to* num_elements(array)-1
````````array := array * max_val / found_max
````*end for*
*end function* __

In fact i just insert two abs() functions._


----------



## Fernando Warez (Oct 13, 2006)

What is this for? :???:


----------



## amplayer (Oct 30, 2006)

This may be seen as a stupid noob question, but here goes:

If I create a table with a mouse and Kontakt's brain-dead rescaling window, and then save it as a preset, I still don't know how this array could be passed to the script function. How do you pass the array to the function? Is the array somehow available as a system variable or something?


----------



## Nickie Fønshauge (Oct 31, 2006)

amplayer,

Nils' script is for smoothing script tables, not modulation tables.


----------



## amplayer (Oct 31, 2006)

Nickie Fønshauge @ Tue Oct 31 said:


> amplayer,
> 
> Nils' script is for smoothing script tables, not modulation tables.



Thank you.

Does anyone here know of a good way to generate modulation tables?
The Kontakt interface is barely usable. It would be much easier if these tables could be generated with a different program or even a text editor. However, I don't know what the format is that NI used to store these tables. Does anyone know or have a suggestion?


----------



## kotori (Oct 31, 2006)

amplayer @ Tue Oct 31 said:


> Does anyone here know of a good way to generate modulation tables?
> The Kontakt interface is barely usable. It would be much easier if these tables could be generated with a different program or even a text editor. However, I don't know what the format is that NI used to store these tables. Does anyone know or have a suggestion?



Please see this thread.

/Nils


----------



## amplayer (Oct 31, 2006)

kotori @ Tue Oct 31 said:


> amplayer @ Tue Oct 31 said:
> 
> 
> > Does anyone here know of a good way to generate modulation tables?
> ...



Wow! That looks fantastic. Unfortunately, since I run Kontakt on a Mac, I can't use it.
Perhaps somebody would be kind enough to port it to OS X like they did for your excellent editor.

Anyway, I certainly would like to thank you for your generous gifts to the Kontakt community.

By the way, the reason I wanted it is for crossfading multisamples. I can't believe NI only provides an auto-xfade function, and then you can't even see what the crossfade numbers are or edit them in any way.


----------



## Thonex (Oct 31, 2006)

Amplayer,

In the mean time, if you have a lot of x-fades you need to do, it might be a good idea to spend the extra time to come up with some smooth curves by hand and then save them as presets. Once you've done a few that work well, you can start deleting the "crappy" ones.

Or find a friend with a PC and have them run a bunch Nils' auto curves and have them save them as presets and create a patch with a bunch of groups having the different curves that can then be saved as presets.

Just a thought.

Cheers,

T


----------

