Stuck with a SynthEdit project?

Tag: Patch Memory

Notes about Sub Controls

Introduction:
Sub controls provide a more customized user interface than standard controls but require more expertise to use effectively. They provide a lower-level access to the various visual elements on your control panel.
There are some basic rules that need to be followed to use them with a minimum of problems.

Controls vs. Sub-Controls- Why have Sub Controls?

Before sub-controls, SynthEdit provided only pre-made controls, like the Slider Control. To understand sub-controls, it’s useful to understand how a control works.

For example the Slider:
A slider has several interacting components…
Lets have a look at the custom made slider below. The original SE slider control is included as a comparison (this control cannot be opened up-it’s one of the old ones, (so it can’t be modified without C++ coding).

Moving the slider updates the numeric text readout and vice-versa. So there’s a bi-directional connection between the two sub-components.
Your computer typically updates its graphics 60 times per second yet the output of the is at audio-rate signal (typically 44,100 or more samples per second). So it follows that there’s a rate-conversion happening inside this module.
You can’t open up the original slider to see what’s going on inside, but here’s one I put together to demonstrate what goes on:

The current position of the slider is stored in the patch-memory, and the slider will move automatically to reflect the current patch. We need to find a way of displaying the output value of the control. That’s done with the Float to Text, and the ED Text Entry modules.
The Output from the module can take various forms. Here I have included three types of data that I think I’ll find useful:
1) DSP Volts out, 2) DSP Floating Point out, and 3) GUI Floating Point out.
So you can already see how we can “personalize” and add functions to our controls in this way..

The focal point is the Patch Memory module. This handles the communication between the graphical (GUI) elements (with blue backgrounds) and the audio-processing (DSP) elements (with grey backgrounds).
The Patch Memory module also handles any MIDI Automation of the control and handles switching between any presets (patches).

With the traditional Slider the layout of the elements was fixed. There’s no way, say, to put the numeric readout at the top. But now I have this Sub Control slider I can move the elements around at will. However using the Sub Control I just created then I can modify and move elements around as I like.

Moving the elements of the Sub Control around

The purpose behind Sub-Controls.

The purpose of sub-controls is to split up the control into its constituent parts. As you saw with the slider Sub Control, this is a way of giving far you more flexibility over the appearance of your controls.

The first and focal point is the Patch Memory module. It handles the communication between the graphical elements (on the left with blue backgrounds) and the audio-processing elements (on the right with grey backgrounds). The patch mem module also handles any MIDI Automation of the control and handles switching between presets (patches).
The second type of module here is the graphics controls. The Bitmap Image and the Text entry boxes. These accept user input and display the control’s current value. Graphical elements use the Patch-Mem module as a ‘hub’. Input to any object is reflected back to the others, keeping them always in sync.
The third type of module here is datatype conversion. For example the Text-to-Float module. It’s purpose is to bridge the Patch-Mem module’s numeric (float) value with the Text-entry module (which otherwise would be used perhaps for entering a file-name).

You can see from the arrow heads in the picture below that the GUI Floating Point pins (blue background) are bi-directional. This ties in with the expected behavior.

Bi directional GUI data flow

Updating the numeric-entry box moves the knob and vice-versa. These signals are not sampled like audio signals but are event-driven. Event driven means that the control only sends data and uses the CPU when being moved, at all other times it does nothing. Compared to an audio (DSP) signal, the knob thus generates data at a much slower rate, and only when actually needed.

The signal leaves the Patch-Memory module via the Value Out plug as an audio connection, but it’s still sending data at the slower rate generated by the PC’s graphics system. This is why we include the next stage the Float To Volts module.
The Float-to-Volt smooths out, and up-samples our Floating Point data to a true audio-rate signal suitable for controlling SynthEdit’s various audio modules.
In SynthEdit these audio rate signals are called Voltages because SynthEdit is simulating an old-school Voltage controlled Synthesizer.
The Float-to-Volts module gives you control over how smooth the conversion should be. Less smoothing uses less CPU, but the resulting audio changes (especially with filters) may sound ‘stepped’ or ‘zippered’.
There is another reason this module must be included- without it the data rates will be miss-matched and updates in control position lost resulting in jerky or glitchy changes to the audio modules.

The general structure of a Sub-Control patch is:
[Graphical Control]<—>[datatype Converter]<—>[Patch Mem]—>[Audio modules]

Customizing.
You can see that the numeric input is optional, just delete it if you don’t need it. Same with the rotating knob image. Also you can now place the elements however you like.

Some of the settings available and what they do:
Hint:- Provides for ‘Tooltips’, the popup yellow boxes that appear when you mouse-over the control.
Menu Items and Menu Selection:- Provides a context menu (right-click menu). Type the menu items as a comma-separated list. e.g. “Set to Center=1, Randomize”. These will appear on the context menu, along with SynthEdit’s menu entries.
The ‘Menu Selection’ pin outputs the user’s selection as an integer. e.g. if the user clicks ‘Set to Center’ the pin goes to 1. After any selection the pin returns quickly to zero. Always number your item list from 1 otherwise the first item will always output 0 (which is no different from ‘no-selection’).
Editable:- You can use this with Text Entry boxes to stop uses from changing a label by accident, or to prevent values being entered into a control’s value box.
Greyed:- You can use this with a Text Entry box to indicate that control is not currently relevant.

Efficiency.
GUI Modules:
As you know modules with blue backgrounds are ‘GUI Modules’ (Graphical User Interface Modules). These are designed to process user-input (mouse clicks and text entry etc.). These are not intended to process audio signals. On multicore systems they will usually run on a core separate from the audio processing, this allows the audio modules to take priority when the CPU is under load.
Hybrid GUI/DSP modules:
Modules with both blue and grey pins (like the Patch Memory Modules) are hybrid modules. Internally they consist of two parts running simultaneously in separate processes. Communication between the two parts is complex and is thus more CPU intensive than between other modules.

Don’t use audio modules to process GUI signals

In general aim to keep your use of hybrid modules to the absolute minimum.
For example:
Suppose you want to increase a knob’s display to range between 0 and 100, your might think to use the standard Multiplier module. Being an Audio module, this requires an extra conversion via a patch-mem or similar. A much more efficient method is to use a ‘pure‘ GUI solution like the Float-Scaler module.
This will: 1) keep your circuit simpler and 2) your CPU usage far lower.

Use caution with GUI connections into Containers

Sub Controls are only active when the control panel window is open. When you close the control panel, the sub-controls immediately become inactive.
Not only this but GUI plugs communicate only with modules visible in the same window, so if you are passing controls though another container, you must set that containers properties so with the “Controls on Parent” are visible, otherwise the GUI signals will not pass through the container.
This behavior is in support of the new VST3 standards.

Example:- A Knob image is inside a Container, which is connected to a Patch Memory outside the control’s container. Unless the Container is set so that the Panel View is visible the knob cannot not respond to mouse movements and appears ‘frozen’, the Volt Meter and Vector Bar won’t respond to any control movements.

Sending GUI data through a container equals problems
These container settings block the data

However as soon as we change the relevant settings on the Container – Patch Mem the controls spring into life: (see below)

Changing the container settings lets the data through.
The settings that do work.


Note: The structure view will always have this issue, but if the knob’s container has ‘Controls on Parent’ set it will work fine on the Panel view.
The reason is:- With ‘Control on Parent’ set, the knob is displayed on it’s parent container’s window, which the same container the PatchMem is in.
This is confusing- So if possible, always keep your GUI connections within the same container. If you do need GUI connections into a container, you can often get the structure view working too…
For this the container’s ‘Show on Module’ needs to be set. This makes the knob visible in the same window as the Patch Mem which means the data connection works, but there’s still a catch. The right-hand window’s knob still won’t work properly. As it’s effectively a sub-container. There’s no way you can get the Patch Memory module visible in that window.

Summary: Sub controls in a container will work fine on the Panel view provided the container has ‘Show on Parent’ set.
They control may not always respond in the structure view but you can often
(but not always) fix the problem with the ‘Show on Module’ setting.

GUI modules need to be seen

Sub Controls function only while their Container’s Panel is open. i.e. if you close you synth’s panel, those sub controls become inactive.
Therefore never rely on GUI modules to process audio signals. The exception is hybrid modules (Patch Memory) which will continue to provide patch-selection and automation functions via their audio pins.

Avoid splitters
Due to a design mistake, SynthEdit 1.0 had the Container’s ‘Control on Parent’ pin on the wrong side. This made it impossible to connect it to a Patch Mem module (needed for save/recall of paged panel settings).
The ‘Bool Splitter’ was introduced to fix this problem, but the bool splitter causes problems of it’s own. The bool splitter ‘reflects’ any one input signal back out it’s other inputs, this is a bad design because it is not clear which module is in control of the others. The result is modules ‘fighting’ each other for control. Symptoms include ‘flakey’ inconsistent behavior and patches not saved/recalled correctly.
3rd party module developers have sometimes copied SynthEdit’s example and released modules that rely on the use of splitters. This is not their fault, however if at all possible avoid using splitters.

Prefabs worth studying.
SynthEdit’s Insert/Controls menu has several good examples. The Joystick module shows how to make any type of horizontal slider, vertical slider, or two-axis Joystick. Hint: For Sliders – use the resize handles to restrict the area of movement to a narrow strip.

Visual Indicators.
The LED2 prefab is a template for any type of indicator or meter. Notable is it’s clever use of a transparent overlay image to dim the light, and the use of the Tinted Image module to provide for any color light.

Synthedit Sub Controls Part 2:- Patch Memory

I think these modules are worth a separate page all on their own, as they are quite an “in depth” subject, and can be a source of confusion for beginners.

The rules of using Patch Memory.

Rule 1 Avoid splitters (redirectors)
Due to a design mistake, SynthEdit 1.0 had the Container’s ‘Control on Parent’ pin on the wrong side. This made it impossible to connect it to a Patch Mem module (needed for save/recall of paged panel settings).
The ‘Bool Splitter’ was introduced to fix this problem, but the bool splitter causes problems of it’s own. The bool splitter ‘reflects‘ any one input signal back out it’s other inputs, this is a bad design because it is not clear which module is in control of the others. The result is modules ‘fighting‘ each other for control. Symptoms include ‘flakey‘ inconsistent behavior and patches not saved/recalled correctly.
3rd party module developers have sometimes copied SynthEdit’s example and released modules that rely on the use of splitters. This is not their fault, however if at all possible avoid using splitters.

Rule 2: The second rule of Patch Memory is: The first wire connected to the ‘Value Out’ plug always resets the Parameter. The Value, Name and Range of the parameter are taken from whatever module you are connecting to. To avoid this behaviour when replacing a wire – connect the new wire first before disconnecting the old one.

Rule 3: Do not connect a Patch Memory to the Polyphony Control module. The Polyphony control is itself a type of Patch Memory, so if you do it will cause data conflicts and the two modules will “fight” over which is doing what.

Rule 4: Never use more than one Patch Memory for each control in a Sub-Control since this can cause some very unpredictable data conflicts and extremely strange behaviors in your GUI controls.

The Patch Memory modules are the hub around which you will construct any
Sub-Control prefab. They are the link from your controls (GUI) to the audio side (DSP) of SynthEdit. They are also an Integral part of the system for creating and saving patches in the finished VST.
What the Patch Memory can and cannot do.
1) GUI to DSP Link: They are the interface (bridge) between the DSP (Audio Processing) side, and the GUI controls and graphics.
2) Storing values for Presets: They allow the storing of values as a preset to “remember” the state or position of a control.
3) Store the value ranges of controls: Patch memory when used for Sub-Controls can be used to set the Minimum and Maximum values of the knob, switch, slider etc. This is useful as the default range is 0 to 10, but by using a Patch Memory Float or Integer the Minimum and Maximum can be set to any useful range.
The Patch Memory Txt modules will only accept a single default value.
4) Use the correct type: There is one Patch Memory for each datatype, divided into input and output controls. Don’t fall into the trap of trying to use float Patch Memory for everything!
5) Limited Data Size: When using Patch Memory modules for passing large block of Data between modules (BLOB data is a good example) for samplers (for example) there is a limit to the maximum side of the block of data.
6) No Math or other processing: A Patch Memory Float module cannot handle any maths functions, changes to the number of digits after the decimal point. This must be handled by external modules. It just stores the 32bit Float value, and converts it to a DSP Float value. This applies also to the Text and Integer modules.
Important Note: Data passed through a Patch Memory (especially BLOB) must never exceed 5Mb in size. V1.4 and it’s plug-ins will crash as as soon as the data maximum is exceeded.
SynthEdit 1.5 is now much better behaved in this respect, it will now not pass the data through the Patch Memory at all, but will not crash. So we still have the 5Mb Data limit but SE and it’s VST plug ins handle the limit in a more stable manner. This limit applies to all the Patch Memory modules.

Note: In the Headings below I just refer to each of the two basic types of module as PatchMemory “Data-Type” 3 or PatchMemory “Data-type” Out3 where Data-Type is for example Integer, or Text to save loads of repetition.

GUI in – DSP out.

PatchMemory Float3 module

These are the modules that take a GUI data input, and convert them to a DSP output, for example the module shown above will take the Position of an Image used as a control, convert it so data suitable for DSP output on the Value Out Plug.

DSP in – GUI out.

PatchMemory Float Out3 module

These are the modules that take a DSP data input, and convert them to a GUI output, for example the module shown above will take the value on the Value In plug, convert it so data suitable for GUI output on the Value, and Animation Position plugs.
Value In:
The Value In plug is always a DSP data plug receiving data from DSP to be sent to the GUI side.
Value out:
The Value Out plug is always a DSP data plug sending data from the GUI modules to the DSP side.

Send or Receive? Which way does the data flow?

This is somewhat confusing and counter intuitive for newcomers to SE but these are the rules for Patch Memory module names:
A Patch Memory Out module always Inputs data from a DSP module.
A Patch Memory Module always Outputs data to a DSP Module.

Note: GUI plugs are bi-directional, they send and receive.
Note: The first wire connected to the ‘Value Out’ plug resets the Parameters. The Value, Name and Range of the parameter are taken from whatever module you are connecting to. To avoid and complications caused by this behaviour when replacing a connection:- always connect the new wire first before disconnecting the old one

Typical use of a  PatchMemory Float3

One of the basic and easy to understand of PatchMemory uses is it’s use in the Knob prefab included in the SynthEdit control modules.
1) The Animation Position plug on the Patch Memory is linked to both of the Image2 modules (the body of the knob, and the shiny cap) as we want these to move together.
Note: Although the Tinted Bitmap Image has an Animation Position plug It’s not used here, as we don’t want the scale for the knob to move.
2) The Patch Memory Float3 module serves three main purposes:
a) To link all the modules together
b) It memorizes the position of the knob
c) It allows us to convert the position of the image of a knob into a Floating Point value, which is output as a DSP value (hence the grey background). This allows us to use the position of image to output a Voltage which can be used to control (for example) the cut-off frequency of a filter module.
3) The Animation Position plugs are always scaled from 0 to 1 as a default, whereas both the Value, and Value Out plugs have the value scaled up to the default 0 to 10 range required for controlling DSP modules.
4) The Text Entry4 module allows us to display a title adjacent to the control knob.
Float to Volts conversion.
The Float to Volts module is included to convert the Floating point output of the Patch Memory to a suitable Data stream for DSP modules. this allows us to set the response speed of the control, so that there is a smooth output signal sent to the DSP controls.
Menu Items, and Menu Selection plugs.
These can be used to set up a Right Click menu for the control knob.

Our two important plugs here are Choice and Item List: Choice is the Integer which refers to the Item from the Item List that is being chosen.
Defining the list:
The list is set up as a text string in the Properties for the module. Each entry is given an ID number starting at 0
Note: the first item is always 0. So if you are choosing pre-defined options from another module, so a typical list could be: Sine=0,Saw=1,Triangle=3,Pulse=4
This is referred to as an “Enumerated List”
There must be no spaces in the list, unless the Item name specifically has a space in it such as “White Noise”.
Note: The last entry is not followed by a comma or period.
Example:
A pop-up menu system is shown below.
If we don’t define a list then the list entries will be read directly from the Oscillator module (OK we expect the Value Out plugs to be uni-directional, but in the case of this module it can extract the item list from the Module that this plug is connected to-trust me it does!)
Limiting our choices:
If we want to limit the choices available in the list then we need to pre-define our list. This is done in the properties for the Popup Menu module.
Note: You must define the list options before connecting the Popup Menu to any other modules, otherwise the Choice and Item List entry boxes will be “greyed out”, and the list will be defined by the Patch Memory List3 and the module it’s reading the list items from.
In this case we use the list: Sine=0,Saw=1,Triangle=3,Pulse=4 which limits the choices available by leaving out Ramp=2,White Noise=5,Pink Noise=6.
The choice option requires no programming, it just selects the ID number from the list supplied.
This system will work with any DSP module that uses the green List Entry plug. Just remember that the first item in the enumerated list will be 0, and not 1.

This is how the properties panel for the Popup Menu module should read: (Unless you want different options of course)

Programmers notes about Patch Mem:

The range attributes are specified in the xml for the parameter, they are called minVal maxVal, the default range being 0 to 10.

A patch memory is pretty much a ‘stub’ box module containing a SE entity called a Parameter. The module simply communicates to the parameter value using its plugs. A parameter is in effect a memory whose value is stored in presets and which changes for every preset, and can of course be of int, float, bool, blob or string type.

By using xml, a parameter can be linked to either GUI or DSP plugs. The linked pin(s) won’t be exposed, but are used for sending or receiving data to/from the parameter. Therefore, a parameter also allows communication between GUI and DSP.

You must keep in mind that when the GUI is closed, the GUI part of a module (including a PM) effectively does not exist. However, a parameter can still transmit its value to any DSP input plug it is linked to, or receive the value from a DSP output plug it is linked to. Once the GUI is opened (but not until then), it will transmit its value to a GUI plug it is linked to.