Stuck with a SynthEdit project?

Tag: Float function

The Float Fuction module.

This is a useful GUI module. It saves using conversion from GUI to DSP and back to GUI if you need to use math functions on a GUI float value. It works like the DSP Float Function module, with one notable difference, like most GUI modules it works in both directions. So as well as the A conversion formula, you need to specify the B conversion formula which is the inverse of the A formula;
so if the B formula was A*100, then the A formula must be B/100.
Note:
The A formula is applied to the value received by Plug B and is output from plug A The B formula is applied to the value received by Plug A and is output from plug B.
Note: If you only need the conversion to work in one direction, then there is no need to bother with the inverse formula.
Note: If either the A or B function is left as an empty string or the value 0, signal flow from that pin will be disabled.

Inverse functions; links to more information.

For those who don’t understand Inverse Functions and how to find the inverse of a function, there is detailed information and explanantions of Inverse Functions on these websites;
About inverse functions
Another article on inverse functions
Online inverse fuction calculator (Wolfram Alpha)

Supported Math functions:

All the frequently used math functions are supported; multiply, divide, add, subtract, power, sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, exp, log, log10, sqrt, floor, ceil, abs, hypot, deg, rad, sgn, min, max.

Example Float function usage.

Suppose you want to have a knob control’s readout display the slider value from 0 to 100, but you want to keep the actual control value in the default 0 to 10 range.
This allows you to alter the displayed value, and by using the inverse function we are also allowing the user to enter a value (between 0 and 100) in the text box to change the control knob’s position and output, but still keep the control value inside it’s default range.
The formula and it’s inverse can either be entered into the modules properties panel, or supplied as a text string to the appropriate plugs.

How the VU Meter uses Float Function.

Another use for the GUI Float Function is demonstrated in the VU Meter.
We take the Audio input, and feed it into the Volts to Float module where the signal level is converted to floating point at a rate optimised for DSP, which will also give a suitable response time for the meter to be useful (Conversion rate = 60Hz), and the type of response is set to dB VU to suit a VU meter readout.
The next step is to use a PatchMemory Float Out3 to convert the data from Audio/DSP to GUI, and to take the value output (not the Animation Position output) and feed it via the Float Function with these values for the Formulae:
Formula A= B-18
Formula B= A+18
From here the data is sent via the dB to Animation module to convert the data to fit the scale used for the VU meter, this is where we finally use Animation Position to move the “meter” to the position that matches the Audio input on the VU “scale”.
The actual meter we see on the panel uses two Image2 modules. The top one which displays the meter needle is connected to the Animation Position data, and the lower Image has no connections as it’s just the meter scale.

Attack, Decay, and Release time display using Float Function.

We can also use the Float Function to display the Attack, Decay, or Release time of the ADSR modules. The layout below does the job quite neatly. (You could use all stock modules but then you won’t have the text append function, or control over how the Value and Label Text Entry look on the Panel).
Applying the math formulae for the conversion.
The formula to convert the Volts (or in our case, GUI float, as it’s not yet DSP Volts) to ADSR timing is 10^(A*0.4-3)
Because we want to convert the Float Value to ADSR timings the converted value needs to appear on the B Plug, so this is formula B.
To convert a text entry to the Float Value for the ADSR timing we need to the inverse of this formula as Formula A which is (3+log10(B))/0.4
Both the Formulae.
Formula A is (3+log10(B))/0.4
Formula B is 10^(A*0.4-3)
If you study these two formulae carefully you can see just what is meant by an Inverse Formula, we are just working out how to perform the exact reverse of the original math function. (Add becomes subtract, multiply becomes divide and so on. It may seem at first look a bit random, but there is a logical structure in finding the inverse of a math formula…)
Having both the A and B formulas allows you to control these times from either the knob or the text entry box.

SynthEdit Sub Controls:- Part 3 Data Manipulation

These modules change the value of a GUI variable. They may or may
not also convert the value from one GUI data type to another.

This is a module of limited use except in the SynthEdit VU Meter prefab. (“Unfortunately the ‘dB to animation’ module is specific to the SynthEdit VU Meter image, which is copied off real VU Meters and is not any kind of ‘nice’ formula. It can’t be used on meters with a different scale.Jeff McClintock.)

These modules provide a generic conversion function. Both audio processing and GUI versions are provided.

The supported functions are shown below:
*, /, +, -, ^, sin, cos, tan, asin, acos, atan, sinh, cosh, tanh , exp, log, log10, sqrt, floor, ceil, abs, hypot, deg, rad, sgn, min, max. This list applies to both the DSP and GUI modules.

DSP/Audio Float Function

DSP Float function

Left Hand Side Plugs:
-> A:- (Floating Point) Input value
-> Formula: B=:- (Text) Function applied to the signal flow from B to A for example B= A*2
Right Hand Side Plugs:
-> B:- (Floating point) Output Value
The audio version (as usual) sends data in just one direction.
For example to double the amplitude of a ‘float’ signal, open the properties screen, enter the formula – A * 2.

GUI Float Function:

GUI Float Function

The GUI function module is similar except it works in both directions, so you have two formulae Usually Formula B will be the inverse of Formula A.  For example if you wanted a text entry to display a knob’s value as ranging from 1-100, you could enter formula B=A*100, so it follows that Formula B should be the inverse which is B=A/100

Left Hand Side Plugs:
-> A:- (Floating Point) Input value
-> Formula: A=:- (Text) Function applied to signal flow from A to B
-> Formula: B=:- (Text) Function applied to signal flow from B to A
Note: If either the A or B function is left as an empty string or the value 0, signal flow from that pin will be disabled.
Right Hand Side Plugs:
<- B:- (Floating point) Output Value

An example of using these modules is shown below in the SynthEdit VU Meter prefab. We take the Audio input, and feed it into the Volts to Float module where the signal level is converted to floating point at a rate optimised for DSP, which will also give a suitable response time for the meter to be useful (Conversion rate = 60hZ), and the type of response is dB VU to suit a VU meter readout.
The next step is to use a PatchMemory Float Out3 to convert the data from Audio/DSP to GUI, and to take the value output (not the Animation Position output) and feed it via the Float Function with these values for the Formulae:

Formula A= B-18
Formula B= A+18
From here the data is sent via the dB to Animation module to convert the data to fit the scale used for the VU meter, this is where we finally use Animation Position to move the “meter” to the position that matches the Audio input on the VU “scale”.
The actual meter we see on the panel uses two Image2 modules. The top one which displays the meter needle is connected to the Animation Position data, and the lower Image has no connections as it’s just the meter scale.

VU Meter


These modules convert from one data type to another, without affecting the value.
I’m not including the BLOB datatype converters as this is a rather specialist data format which is used for Audio analysis etc.
Bool to Float: Converts a Boolean input to a Floating Point value. For example: False =0, True =10
Bool to Int: Converts a Boolean input to an Integer output. False = 0, True = 1
Bool to Text: Converts a Boolean Input to the equivalent Text string. False = False, True = True.
Float to Bool: =<0 = False, >0 =True
Float to Double: Converts ordinary 32bit floating Point values to 64bit Floating Point values (Double Precision)
Float to Integer: converts the Floating Point input to the nearest whole number. For example a Floating Point value of 3.4 would output Integer 3, and a Floating Point value of 3.6 would result in an Integer output of 4.
Float to Text: Converts a Floating point value to a numeric Text string, so 3.1415962 will display these numbers in a text box. The number of digits after the decimal point is set by the Decimal Places plug so with Decimal Places set to 3 the input value will be truncated 3.141.
Int to Bool: Converts an Integer input to an Boolean output. 0 = False, 1= True.
Int to Float: Converts an Integer value to a Floating Point value (The starting point being Integer the result will obviously be a whole number).
Int to Text: Converts an Integer value to a numeric Text string.