User-defineble functions with args?

Discuss Lemur and share techniques.
Post Reply
stk
Newbie
Posts: 13
Joined: 04 Apr 2014 23:09
Location: rat city, australia
Contact:

User-defineble functions with args?

Post by stk »

Hi,
Couldn't find anything in the doco but wanted to make sure I'm not missing something -
Is it possible to define functions/scripts with arguments/parameters?

eg:

Code: Select all

function sendIt(note, velocity, foo, bar) {
    ...
}
..would be great for code maintenance.

Cheers,
skye
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

Re: User-defineble functions with args?

Post by Softcore »

9.6 Defining and Using Functions

In addition to built-in functions and operators, you may define your own mathematical functions
to use in User-defined Variables and expressions. Here’s how to do it:
Select your projects folder in the Project panel, and click the Create Expression button to create a
new Expression.
The Expression is created at the level of the hierarchy you have currently selected. If you have an
Object selected it will be an Expression local to that Object. If you have the Pojects folder selected
the Expression will go there and be available for use anywhere in the Project.
• Type the name of the function and its arguments in parentheses. For example, to define a
function named cubed that takes one argument, you would type:
• Click OK and go to the Script panel to type in the definition of your function as an
expression. You can reference other variables if needed. The example below just multiplies
the function argument a by itself twice to raise the input to the third power.
The newly declared function appears in the Project panel with a Blue dot to indicate it is a function.
How to use the new function? Let’s try it out on a simple Fader: create a Fader Object, make it
horizontal for a change (by stretching it horizontally) name it Cubic and check both its label and
value checkboxes in its properties tab.


Lemur USER GUIDE - page 69
stk
Newbie
Posts: 13
Joined: 04 Apr 2014 23:09
Location: rat city, australia
Contact:

Re: User-defineble functions with args?

Post by stk »

Ah yes, my apologies, I just found that and came back here to edit my original post, to find your reply :)

Don't know how I missed it in the first place, my only excuse is that it was horribly hot when I was searching and my brain was kind of melting.. Thanks!

Cheers,
skye
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

Re: User-defineble functions with args?

Post by Softcore »

No probs! Took me a while to find it too, even though I knew it existed! ;)
Phil999
Regular
Posts: 919
Joined: 11 Jan 2012 01:53

Re: User-defineble functions with args?

Post by Phil999 »

personally I didn't know about it. Thank you.

Oh and if someone knows of a template with self-defined functions, please name it here. I'm interested for what purpose it is used.
Formant+Eurorack, PPG wave 2.2, Korg MS-20, etc., EWI 4000s, QuNeo, etc., Mixbus32c, u-he, MadronaLabs, Samplemodeling, NI, etc., iPad2/4/Pro
midimockup
Newbie
Posts: 41
Joined: 08 Nov 2012 15:55

Re: User-defineble functions with args?

Post by midimockup »

Holy moly. After years of using Lemur, I totally missed this. Thank you!!!
ndivuyo
Regular
Posts: 278
Joined: 23 May 2014 00:24

Re: User-defineble functions with args?

Post by ndivuyo »

Yea my girlfriend showed me this a few months ago and I was: Ohhhhhhhhh! Handy!
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

Re: User-defineble functions with args?

Post by Softcore »

Hello guys! I 've seen Antonio Blanca using custom functions all the time.

ndivuyo, your girlfriend showed you a Lemur feature? She's a keeper!!!!! ;)

Phil, obviously, such a feature is needed when you require the same function all over your project.....

Here is a very VERY rough example I could think of! ;)
Attachments
customFunctionExample.jzml
(24.24 KiB) Downloaded 66 times
Post Reply