# More Math Library Feedback Needed



## andreasOL (Apr 20, 2011)

Hi Bob

in my scripts I use

Get_db
SinCos

in note callbacks (for equal power crossfading).

Cheers,
Andreas


----------



## Big Bob (Apr 20, 2011)

Hi Andreas,

Producing Fast versions of SinCos and Get_db will be among the easiest because SinCos is limited to 1001 input values while Get_db has only 10,000 input values. Therefore, both of these functions can be implemented with lookup tables that are under the current KSP array size limit (32K) and can therefore be done without interpolation or multi-array techniques.

I can easily include fast versions of these two routines in the K4 update of the Math Library. Thanks for your input.

Rejoice,

Bob


----------



## Big Bob (Apr 23, 2011)

Hi Tuwa,

There is no such function currently in the Math Library so I don't think you could be asking me to produce a faster version of it :lol: 

Or, are you perhaps synthesizing some kind of S shape using combinations of the existing library functions?

Or, maybe you are asking if I could add a new function to the Library? If so, I would need a lot more information about the function. For example, can you provide me with an accurate graphical representation of the function or some kind of formula that tracks it, etc. Just saying it's S shaped or has an S Taper is not sufficient information.

Maybe you could clarify what it is you are asking for :? 

Rejoice,

Bob


----------



## TuwaSni (Apr 25, 2011)

Big Bob @ Sat Apr 23 said:


> Hi Tuwa,
> 
> There is no such function currently in the Math Library so I don't think you could be asking me to produce a faster version of it :lol:
> 
> ...



Bob,

Actually I have created tables to implement this functionality - basically a modified version of an angle value offset and a level offset cos function. I think it would be a great addition to the math lib.

TS


----------



## EvilDragon (Apr 26, 2011)

I think he wants an S-curve generator, where you could adjust the curvature of the S-shape, going from linear to very concave-convex shape, changing from concave to convex (or vice versa, depending on the sign of input curvature parameter) at midpoint...


----------



## Big Bob (Apr 26, 2011)

EvilDragon @ Tue Apr 26 said:


> I think he wants an S-curve generator, where you could adjust the curvature of the S-shape, going from linear to very concave-convex shape, changing from concave to convex (or vice versa, depending on the sign of input curvature parameter) at midpoint...



Thanks Mario,

Maybe so, but, I still want to see either an analytical or graphical illustration. Data, data, as Sherlock Holmes said, 'I cannot deduce without data' :lol: So far all I've gotten out of this is the function has something to do with a 'rubbery' letter S :roll: I'm too old and tired to try to cobble together a mathematical function from such minimal input :lol: 

Besides all that, I started this thread to find out what *existing* math functions you guys might be using tables to speed up. Instead this seems to be a call for adding a new function to the library so maybe it should be posted in a different thread?

Rejoice,

Bob


----------



## TuwaSni (Apr 28, 2011)

[quote:8cf1b11b1b="Big Bob @ Mon Apr 25, 2011 4:07 pm"]Hi Tuwa,

You're still being pretty skimpy ò Ž   {€M Ž   {ƒÅ Ž   {ƒÛ Ž   {„ Ž   {„w Ž   {‰% Ž   {‰= Ž   {‰S Ž   {‰† Ž   {ë Ž   {Ž Ž   {Ž? Ž   {Žw Ž   {V Ž   {m Ž   {® Ž   {à Ž   {ù Ž   {‘X Ž   {’í Ž   {“ Ž   {–} Ž   {–® Ž   {—; Ž   {—} Ž   { Ž   {5 Ž   {a Ž   {­ Ž   {ž¦ Ž   {žÊ Ž   {Ÿa Ž   { Ø Ž   {¤‰ Ž   {¤Ë Ž   {¤ù Ž   {¤û Ž   {¥¶ Ž   {¦ Ž   {¦ Ž   {¦‘ Ž   {§K Ž   {§¹ Ž   {¨x Ž   {¨‚ Ž   {ªJ Ž   {«* Ž   {¬Y Ž   {¬Í Ž   {­½ Ž   {­Ê Ž   {®© Ž   {®ó Ž   {± Ž   {±  Ž   {²x Ž   {²ö Ž   {³ Ž   {³ Ž   {· Ž   {·È Ž   {º Ž   {º! Ž   {¾a Ž   {¿ Ž   {Ãï Ž   {Çj Ž   {Ç{ Ž   {Ç… Ž   {È~ Ž   {ÈÓ Ž   {Îô Ž   {Ï„ Ž   {ÕL Ž   {Õ^ Ž   {Õ Ž   {Õª Ž   {×Ò Ž   {×ë Ž   {Ù^ Ž   {Ùt Ž   {Ú2 Ž   {ÚŠ Ž   {à“ Ž   {á$ Ž   {ãT Ž   {ãŽ Ž   {åb Ž   {å Ž   {ç· Ž   {çÆ Ž   {éÄ Ž   {éÞ Ž   {ê Ž   {ê! Ž   {ëã Ž   {ì Ž   {ì. Ž   {ì_ Ž   {ñ( Ž   {ñ¡ Ž   {û× Ž   {ü Ž   {üš Ž   {ü± Ž   |‡ Ž   |Ò Ž   |	ñ Ž   |
( Ž   | Ž   | Ž   |!K              ò Ž   |.U Ž   |.² Ž   |4 Ž   |4# Ž   |6ž Ž   |7 Ž   |85 Ž   |8` Ž   |Cñ Ž   |DB Ž   |EŠ Ž   |Eº Ž   |J Ž   |Jš Ž   |K‡ Ž   |MÆ Ž   |NZ Ž   |Oç Ž   |P+ Ž   |PÔ Ž   |QI Ž   |V¢ Ž   |VË Ž   |Y Ž   |_G Ž   |_M Ž   |_  Ž   |_´ Ž   |aò Ž   |bš Ž   |d­ Ž   |dÉ Ž   |fw Ž   |gè Ž   |n' Ž   |n Ž   |q• Ž   |s Ž   |u2 Ž   |un Ž   |ye Ž   |yy Ž   ||¢ Ž   ||Ì Ž   |ˆ8 Ž   |ˆu Ž   |ˆë Ž   |‰ Ž   |‰„ Ž   |‰¾ Ž   |Š² Ž   |‹ä Ž   |‘‡ Ž   |‘ª Ž   |“K Ž   |“Í Ž   |›* Ž   |›H Ž   |ŸÌ Ž   |Ÿð Ž   |  Ž   |  Ž   |¡  Ž   |¡W Ž   |£O Ž   |£n Ž   |¦‹ Ž   |¦§ Ž   |¦Ç Ž   |¦ê Ž   |¨m Ž   |¨¼ Ž   |©! Ž   |©U Ž   |¯ Ž   |¯@ Ž   |µÅ Ž   |¶$ Ž   |¹ Ž   |¹ Ž   |½S Ž   |¾2 Ž   |Â Ž   |Â1 Ž   |ÃÐ Ž   |Ä€ Ž   |Æ? Ž   |Æx Ž   |Ç Ž   |Ç0 Ž   |ÈÍ Ž   |É Ž   |Ò¬ Ž   |ÒÜ Ž   |Óš Ž   |Ó¯ Ž   |Õ% Ž   |Õ£ Ž   |Ù Ž   |Ù~ Ž   |Ùç Ž   |Ùú Ž   |Ú! Ž   |ÚÝ Ž   |Û3 Ž   |à… Ž   |àõ Ž   |áÒ Ž   |ëy Ž   |ë¥ Ž   |ó Ž   |ó^              ò Ž   |÷* Ž   |ú# Ž   |új Ž   |ÿt Ž   }  Ž   }S Ž   }ä Ž   }"½ Ž   }"Â Ž   }-3 Ž   }-› Ž   }4V Ž   }4À Ž   }9Ø Ž   }:6 Ž   }F4 Ž   }FJ Ž   }Fd Ž   }F Ž   }F™ Ž   }F¼ Ž   }G" Ž   }Gs Ž   }O Ž   }O~ Ž   }Rl Ž   }Rí Ž   }ZH Ž   }Zn Ž   }^• Ž   }^â Ž   }`2 Ž   }`¥ Ž   }b Ž   }bm Ž   }fV Ž   }fs Ž   }gY Ž   }g– Ž   }h• Ž   }hÖ Ž   }iv Ž   }iÓ Ž   }sš Ž   }sÎ Ž   }sÿ Ž   }t Ž   }uÚ Ž   }uç Ž   }v3 Ž   }v> Ž   }w Ž   }w Ž   }Á Ž   }ã Ž   }‹ü Ž   }Œ@ Ž   }Ž½ Ž   }Žö Ž   }1 Ž   }H Ž   }Ø Ž   } Ž   }¥ Ž   }Ó Ž   }š Ž   }šã Ž   }œ Ž   }œ6 Ž   }œi Ž   }œ¥ Ž   }– Ž   }® Ž   }žj Ž   }Ÿ& Ž   }ŸM Ž   }Ÿ Ž   }¡Ñ Ž   }¡ÿ Ž   }¢‘ Ž   }¢Ç Ž


----------



## Big Bob (Apr 28, 2011)

OK, I'll take a look at this when I get some time. Right now I'm still working on speeding up the library and then I have one or two other things in my queue. So, it may be a little while but I'll drop a post when I know something.

Rejoice,

Bob


----------



## PeterMalick (May 7, 2011)

I finally feel that I'm ready to take a look at Big Bob's Math Library...

Am I missing something, or have all the links to the library and documentation disappeared?


----------



## Big Bob (May 7, 2011)

Hi Peter,

I thought the V215 package was still on Thonex's website but maybe Andrew took it down because it's probably been a long time since anyone has downloaded it. 

I would post it for you but I presume you want the whole package with the Equal-Power-Crossfade tutorial and the Technical Guide? If so, the zipped package is around 740KB which is too large to post on this forum. However, if you PM me with your email address I can send it to you.

Rejoice,

Bob


----------



## Big Bob (May 13, 2011)

> Hi Bob,
> 
> Here are some equations -
> 
> ...



Hi Tuwa,

I'm just about at that point with the Math Library update where I can take a look at this but, let me clarify a few things:

I think perhaps the log formulae have an extraneous minus one? It seems to me that, for example, the up curve for 0.5 <= X <= 1.0 should be Y = [log2(2*X)]/2 + 0.5 so that the Log itself will swing from 0 to 1.0 (rather than Log(0)..Log(1) since Log(0) is not defined. I presume this is just a typo?

A second thing that may be worth clarifying is the output format. Your formulae imply volume ratio might be the format you want for output. So, for example, we might concoct a function such as:

function *SXFade1*(xfv,morph,VR1,VR2) 
where xfv is the crossfade variable 0 <= xfv <= 1000
and morph is also a variable in the range 0 <= morph <= 1000 
VR1 is the output volume ratio for the up curve and VR2 is the volume ratio for the down curve, let's say scaled by 10000. 

Thus VR1 will swing from 0 to 10000 and VR2 will swing from 10000 to 0 as xfv swings from 0 to 1000 and, with morph = 0, the curve will track your sin/cos function. With morph = 1000, the curves will be linear.

Similarly, we can concoct a function *SXFade2* that will behave the same but the curvature will track your log/exp curves.

With the VR scaled by 10000, if you want to control a K4 function that requires a mdb control value, you can simply use the library function *VR_to_mdb* without any need to rescale since VR_to_mdb expects VR to be scaled by 10000.

Let me know if I'm correct about the log function typo and whether or not my suggested format and scaling is the sort of thing you had in mind.

Rejoice,

Bob

EDIT: My range selection for xfv is kind of arbitrary but if you are always going to use a 0..127 MIDI controller as input to this function, we could choose a power of 2 instead. But this is really just a matter of some pre-scaling so I just chose 0..1000 to track with the SinCos library function.


----------



## Big Bob (May 17, 2011)

Hey Tuwa,

My time window for working on this is rather narrow, so I'm bumping this post up to hopefully get your attention.

Bob


----------



## TuwaSni (May 17, 2011)

Big Bob @ Fri May 13 said:


> > Hi Bob,
> >
> > Here are some equations -
> >
> > ...



Hi Tuwa,

I'm just about at that point with the Math Library update where I cò þ   ×çW þ   ØÝ þ   Ø þ   ØD þ   ØDJ þ   ØDy þ   ØD§ þ   ØF þ   ØFê þ   Øt$ þ   Øtx þ   Ø~n þ   Ø: þ   ØB þ   ØL þ   Ø–ü þ   Ø—! þ   Ø Š þ   Ø ï þ   Ø«m þ   Ø«… þ   ØÏ+ þ   ØÏ• þ   Øûá þ   Øü7 þ   ÙW þ   Ùò þ   Ù2 þ   ÙP‘ þ   ÙP· þ   ÙžE þ   ÙžÝ þ   Ù¢1 þ   Ù¢ó þ   Ù¤	 þ   Ù¤, þ   Ù¹½ þ   Ù¹ÿ þ   ÙË$ þ   ÙË§ þ   ÙÙŒ þ   ÙÙú þ   Ùà> þ   Ùà¡ þ   Ú þ   Úˆ þ   Ú&] þ   Ú&‘ þ   Ú(z þ   Ú(Ï þ   Ú+ð þ   Ú, þ   Ú9Š þ   Ú:+ þ   ÚO þ   ÚO™ þ   ÚU< þ   ÚUŽ þ   Úp{ þ   Úp½ þ   ÚtÌ þ   Útê þ   Úƒn þ   Úƒ† þ   Ú‡± þ   Ú‡ü þ   Ú¡O þ   Ú¡s þ   Úî“ þ   Úîè þ   Úÿš þ   Úÿ® þ   Û ‹ þ   Û µ þ   Ûn þ   Ûn© þ   Ûoâ þ   Ûp  þ   Û’´ þ   Û“( þ   Û•/ þ   Û•Ê þ   Û˜m þ   Û˜¼ þ   ÛŸò þ   Û = þ   Û ª þ   Û ³ þ   Û Í þ   Û ä þ   ÛÉß þ   ÛÊ* þ   ÛÌ¡ þ   ÛÍC þ   ÛßX þ   ÛßÌ þ   Ûø þ   ÛøP þ   Ü­ þ   Ü  þ   Üó þ   ÜM þ   Ü þ   Üw þ   Ü" þ   Ü"“ þ   Ünî þ   Ünú þ   Üˆ„ þ   ÜˆÄ þ   Ü¢R þ   Ü¢o              ò þ   Ü³m þ   ÜÎ” þ   ÜÎ£ þ   ÜÝ\ þ   ÜÝŠ þ   ÜíÓ þ   Üíü þ   Üîý þ   Üï( þ   ÜïS þ   Üït þ   Ýƒ þ   Ý“ þ   Ýƒ	 þ   Ýƒ] þ   Ý” þ   Ý”U þ   Ýå{ þ   Ýå• þ   Þ[ þ   Þm þ   Þµ þ   ÞÈ þ   Þ þ   Þ( þ   Þ0è þ   Þ1 þ   Þ1A þ   Þ1Œ þ   Þ4§ þ   Þ5 þ   ÞE( þ   ÞE9 þ   ÞKˆ þ   ÞK® þ   ÞNB þ   ÞNR þ   Þ§à þ   Þ¨+ þ   Þ©é þ   Þª	 þ   ÞÚb þ   ÞÚ§ þ   ÞÞ( þ   ÞÞy þ   Þøù þ   Þù) þ   Þùb þ   Þù¢ þ   ÞÿÛ þ   ß  þ   ß’ þ   ß² þ   ß¼ þ   ß þ   ß"œ þ   ß# þ   ß^ þ   ß^* þ   ß~Ê þ   ß~ß þ   ßì@ þ   ßìu þ   à/Ð þ   à0? þ   ànù þ   ào2 þ   à¨œ þ   à©+ þ   àÀ þ   àÀ© þ   àÈU þ   àÈw þ   àÎÞ þ   àÎð þ   àâˆ þ   àâÆ þ   àä¯ þ   àäÐ þ   àí) þ   àíF þ   àùb þ   àù« þ   áÿ þ   á0 þ   á+‘ þ   á+ª þ   á1 þ   á1¨ þ   áFÉ þ   áFë þ   áH± þ   áH× þ   áI þ   áI[ þ   ác  þ   ác8 þ   áce þ   ácŠ þ   ác³ þ   ácï þ   áfî þ   ág þ   ázÅ þ   ází þ   á~¤ þ   á~° þ   á@ þ   áb þ   á¡c þ   á¡† þ   á§%              ò þ   âý þ   âP þ   â7 þ   âÊ þ   â1è þ   â1ÿ þ   â4V þ   â4¬ þ   â7À þ   â8< þ   âMV þ   âM| þ   âO© þ   âOÚ þ   âUf þ   âUº þ   âV$ þ   âVO þ   âVú þ   âW: þ   â] þ   â]R þ   â^n þ   â^º þ   âe› þ   âfD þ   âvD þ   âv— þ   â™Ú þ   âš þ   â×9 þ   â×Ž þ


----------



## Big Bob (May 18, 2011)

Hi Tuwa,

I'm attaching a demo instrument/script that you can use to examine the proposed S-Curve implementation. I've included the two functions you asked for plus I added two more. The 3rd function is a more-symetrical variation of your exp/log function and the 4th function is an equal-power implementation. All four functions provide morphing control.

To use the demo, select the desired XFade curve with the drop-down menu and the selected curve will be displayed graphically. You can use the Morph knob to set the degree of linearization and the graphical display will track it giving you immediate visual feedback.

For more precise curve inspection you can use the X knob in the lower-right corner to set any normalized X value from 0.000 to 1.000 and you will see the corresponding normalized Yup and Ydn values for the selected curve and Morph setting.

I've also attached the source code for the demo script. You won't be able to compile this script because it imports V402 of the Math Library which I haven't released yet. However, you may still find this script useful to study the proposed implementation of these functions.

Please let me know if there is anything you might want to change about the way these functions are implemented.

Rejoice,

Bob

BTW Anyone else whose interested in crossfading, S-shaped or otherwise, please feel free to download the attached demo and play with it. Your feedback is always welcome.


----------



## Big Bob (May 19, 2011)

Hi Tuwa,

Regarding your PM about the log function. I wondered about this from the get go. First, your posted equations had an extraneous minus one which I called to your attention.

Next I wondered about your notation because usually when someone writes Log(2X) with no further qualification, they mean Log10(2X) but, if I used Log10(2X) as X swings from 0.5 to 1.0, Log10(2X) would swing from 0 to 0.3010 or so. So, I had to assume you actually meant Log2(2X). So when I asked you about the -1 problem, I specifically asked if you meant the binary Log2(2X) rather than Log10(2X - 1).

When I actually implemented the Log2(2X) you had seemed to want, it didn't look right to me since you had described the curve as 'steeper'. This even prompted me to suggest the 3rd variation with the exp-exp format.

After looking at your latest PM to me about using the range from Log(1) to Log(10) to get the 2:1 range, I again thought I had better clarify that you mean base 10 for the logs? But, since you haven't responded to my reply PM yet, I thought I would take a chance that you do mean Log10.

That being the case, let me clarify the math I have used to implement this. In all the following equations, Log will always mean base 10.

let p = 18X - 8 so that as X swings from 0.5 to 1.0, p will swing from 1 to 10 and thus Log(p) will swing from 0 to 1.

Then, the expressions for Y are given by:

(1) Y = 0.5 +/- 0.5Log(p) where + is for the up curve and - is for the down curve.

To then scale Y by 10000, we can write:

(2) Y' = 5000 +/- 5000*Log(p) where Y' = 10000*Y

Now, since xv = 1000*X, we can rewrite (2) as

(3) Y' = 5000 +/- 5000*Log[18*xv -8000] -/+15000

Now, let Q = 18*xv - 8000 and, since the library function for Log10 returns lgx = 10000*Log10, we can write:

(4) Yup = lgx/2 - 10000 where lgx = 10000*Log(Q)
(5) Ydn = 20000 - lgx/2

I have implemented the foregoing and I'm posting the new .nki and script named S-Curve2 and SXFade2.txt. I think this curve now looks much more like you had intended all along.

Please let me know if this is now correct.

Rejoice,

Bob


----------



## Big Bob (May 21, 2011)

Hey Tuwa,

Where are you? I'm waiting for some feedback from you, is the exp-log s-curve now the way you had wanted it? And, is it now safe to incorporate these functions into the library (which itself will take a little time) or is there some final tweaking you want to do yet? :roll: 

I need some response from you soon now so I can get this library update finished and get on to other things :lol:

Rejoice,

Bob


----------



## TuwaSni (May 23, 2011)

Big Bob @ Sat May 21 said:


> Hey Tuwa,
> 
> Where are you? I'm waiting for some feedback from you, is the exp-log s-curve now the way you had wanted it? And, is it now safe to incorporate these functions into the library (which itself will take a little time) or is there some final tweaking you want to do yet? :roll:
> 
> ...



Bob, yes the log10(18x - 8 ) is what I originally had in mind. I tried to load the nki but kept getting an unspecified error. I think perhaps I need the 4.02 math lib. Anyway to get it? And where to put it?

BTW - many thanks for spending the time and effort on this.

Tuwa Sni


----------



## Big Bob (May 23, 2011)

Hi Tuwa,

Try downloading the .zip again, I just tried it again and everything is fine. The .nki loads without a problem. I'm using K4.2.2 how about you?

Unfortunately I can't let you have V402 yet because it's still in a state of flux however, the .nki should allow you to check the curves.

After downloading it again, please let me know if you still can't get it to load. Or PM me with your email address and I'll send it to you directly.

I would appreciate it if you could monitor this thread more frequently because I want to get this wrapped up soon.

Rejoice,

Bob


----------



## TuwaSni (May 24, 2011)

Bob,

I'm still on 4.13 - in the middle of processing libs. I'll set up another boot drive and install 4.22 and check things out. It'll take a day or so. Don't let me catching up delay anything for you - let's assume everything OK unless I report back otherwise. I have complete confidence.

Tuwa


----------



## Big Bob (May 24, 2011)

OK, I'll go ahead then. However, I don't think that this little demo uses anything that wasn't in K4.1.3. But, since I wrote the .nki file from K4.2, I guess NI won't load it into a prior version, huh? You would think when the versions are so close that you could go a little backwards :shock: 

Were you able to load the prior version of this demo? If so, this one should also load. 

Rejoice,

Bob


----------



## TuwaSni (May 24, 2011)

Big Bob @ Tue May 24 said:


> OK, I'll go ahead then. However, I don't think that this little demo uses anything that wasn't in K4.1.3. But, since I wrote the .nki file from K4.2, I guess NI won't load it into a prior version, huh? You would think when the versions are so close that you could go a little backwards :shock:
> 
> Were you able to load the prior version of this demo? If so, this one should also load.
> 
> ...



Bob,

Updated to K4.22 and viola! It looks great! Two thumbs up from here! Again - many thanks. Be sure to let us know when ML V4 is ready.

Tuwa


----------



## EvilDragon (May 24, 2011)

Kontakt was NEVER forwards compatible, IIRC.


----------



## Big Bob (May 24, 2011)

> Bob,
> 
> Updated to K4.22 and viola! It looks great! Two thumbs up from here! Again - many thanks. Be sure to let us know when ML V4 is ready.
> 
> Tuwa



Great o-[][]-o I'm glad to hear I can proceed full speed ahead :lol: 



> Kontakt was NEVER forwards compatible, IIRC.



Hi Mario,

I knew that one cannot load K4 .nkis into K3, nor K3 into K2, etc. But I guess I didn't realize that even minor updates wouldn't be useable with the prior version. I suppose NI must compare the .nki encoded Version # with the Kontakt version you are running and if the app version is smaller (by any amount) they just won't load it on general principles (even if the file format hasn't changed) :roll: 

BTW Elighten me, what does IIRC stand for? :oops: 

Rejoice,

Bob


----------



## kotori (May 25, 2011)

Big Bob @ Wed May 25 said:


> BTW Elighten me, what does IIRC stand for? :oops:


It stands for If I Recall Correctly IIRC


----------



## Big Bob (May 25, 2011)

Hi Nils,

Thanks for the enlightenment :idea: 

I wonder if I ever knew this before? But, even if I did, I'm pretty sure I won't remember this the next time I see it either :lol: 

Rejoice,

Bob


----------

