Files
xod/docs/guide/program-structure

title
title
Program Structure

Program Structure

Programs in XOD are quite similar to electronic circuits. Whereas to build an electronic circuit you use various electronic components and connect them with wires, in a XOD program you use nodes and connect them with links.

Example patch

Nodes

What a node does depends on its type. Like in reality there are ICs to control motors, amplify audio signals, store data, in XOD there are many types of nodes available. It is easy to create your own as well.

Some nodes represent physical devices like LED or digital thermometer, other are used to transform and filter data. Here are few examples:

You place nodes youve chosen for your program into slots to be later connected with links.

Pins, inputs, and outputs

Nodes alone are black boxes. To interact with them they expose pins. Think of pins as of sockets, ports, IC legs, jack-connectors.

A pin can be either input or output. Once you feed an input with a new value the node is evaluated. As a reaction it can update values of its output pins or perform some interaction with real world, e.g. change a motor speed.

Some nodes send an output on their own as a reaction to some external event. For example the clock node sends output with regular time intervals.

Pins are depicted as holes with short labels. Inputs are placed on a darker background and outputs are placed on a lighter background.

Nodes inputs and outputs

Nodes talk to each other by transmitting values over links. A link is a kind of wire that you use to connect one node output to another node input.

Values in XOD are quite similar to electric signals. However unlike their electric counterparts they could carry not only a primitive voltage value, but more sensible data like arbitrary numbers and text strings. Learn more about values in Data Types article.

In digital electronics voltage values are switched discretely and their change usually accompanied by some kind of clock signal. The clock signal is seen as a sequence of “moments” which are defined by observing falling or rising signal edges on the clock line. Interactions and changes actually happen at that moments. I.e. a digital circuit is static until a new clock signal would appear.

Behavior of values in XOD is very much similar. Values change and propogate instantly. These cascade updates of values are called transactions. And things that play a role of clock signals are called pulses in XOD. Execution Model article describes all principles in detail.

There are few rules that define which pins are allowed to be linked and which are not. They are intuitive enough, although for a formal description you can see Linking Rules.

Patches

Nodes linked together form a patch. Patches are like modules, documents, files in other systems.

You would have a single patch in a simple project and for complex projects youd likely to have many.

What makes a patch pretty interesting is that once youve created it you can use it as a new type of node on other patches! Thats the main idea behind XOD extensibility.

You use special terminal nodes to denote input and output pins when the patch is used as a node.

Photo by cutwithflourish.

Note If youve heard of modular synthesizers they are very similar to XOD programs. The nodes are modules, the links are CV cables with banana connectors, the patches are rack chassis for modules.

Modular synth