Next: Csound Blocks, Previous: Score editor, Up: Widgets reference
The function editor is a workspace for mathematical operations relative to one-dimensional functions, such as envelopes or sound waves.
Functions can be edited, combined and exported to different formats.
The editor starts blank. From the contextual menu, "add function from library" provides a submenu of predefined functions. Choose any one to add it
A function can also be added by directly inputing its equation. Use the "add function" item to open an input area. The function equation must be entered there with "x" as a variable and in Smalltalk format.
For example
x sqrt 1 + x x abs log ((((x + 0.5) * 500) * (((10 * x) fractionPart) sin)) sin)
Note that Smalltalk has no concept of mathematical operator precedence !
For example
1 + 2 * x
is actually
3 * x
so take care to write
1 + (2 * x)
The editor can display several functions. Each function has its own submenu in the main contextual menu. From there, the "set color" item lets you choose the display color.
The displayed area is modified by dragging the mouse. Dragging with [SHIFT] pressed scales the area with respect to its lower left corner.
Keys + and - (or menu items "zoom in" & "zoom out") also scale the displayed area.
Most functions from the library have parameters. For example add two functions: from the "basic functions" submenu, take "sine" and "sineWithPoint". If your editor was blank they should appear as "f1" and "f2" in the contextual menu.
The first item in both "f1" and "f2" menus is actually a menu itself. For "f1", it lets you set the value for the parameters "freq" and "amp", that is the frequency and amplitude of the sine wave. For "f2", it gives access to the single parameter "point" which is the position for the first extremum of the sine wave. Change the values for these parameters and see how the functions change.
When adding a function by inputing its equation, you can reference the already displayed functions using their name.
For example if you have the two functions "f1" and "f2" from the previous chapter, you can input
f1 + f2
which displays the function x -> f1(x) + f2(x)
The operator "<=" allows the composition of functions; try
f1 <= f2
to display the function x -> f1(f2(x))
Related muO documentation:
(muo-doc "Function editor example") (muo-doc "Function editor example 2")
For technical details about what functions really are in Squeak, see http://www.zogotounga.net/comp/squeak/functionaltalk.htm
From a function submenu, the item "edit as envelope" crops the currently displayed section of the function and convert it into an envelope by breaking it into linear segment. The function editor becomes an envelope editor. see Envelope editor.
Beware that this is a destructive operation: you will not be able to come back to the function editor. You may clone the widget before conversion though (see Widgets).
Use the "tolerance" item in the bottom of the contextual menu for setting the variation threshold used when breaking the function. The smaller it is, the more precise is the conversion.