Logic

If you have ever heard somebody talk about programming you might know that it involves a lot of if-else-than. When coding you often want to check if something is happening (the user presses a key) and then you want the computer to do something for you. 

We basically set conditions and write down what the computer should do when these conditions are met. This is called logic and this article will teach you how to use logic in Wire.

Before you start with this article you should understand what a Boolean is. If you don’t know this yet, make sure you check out our article on data types. 


Greater than thou!

The most basic logic operations are comparisons. You might want to check if a slider is above a certain value or within a given range. We have a lot of nodes that do this. These nodes all output a boolean (true or false) when the condition is met or not.


The Greater node outputs TRUE when its right inlet is higher than its left inlet and FALSE when this is not or no longer the case.

The Within node outputs TRUE when the incoming value lays within its min and max parameters.

Other nodes in this category are Less, Equal, Not Equal and Outside.


Logic Gates

At some point you might want to compare not one, but multiple values. For this we have a whole suite of nodes called logic gates. These nodes work only with booleans and are often placed after your comparison.  The most common two are And and Or.


The And node outputs TRUE when both its left and right inlet are TRUE. 

You might have an effect that depends on the BPM as well as oscillators. But as learned in our oscillator article you might want to limit the frequency at some point. Maybe you want to check if the BPM and the frequency are not greater than a certain value. Logic nodes are great for building in these kinds of safeties.

The Or node outputs TRUE when either its left or right inlet is TRUE. But outputs FALSE when both or neither inlets are TRUE.

Other nodes in this category are Xor, Nor and Nand.


Logic Conversion

There are a few ways you can convert your logic data. 


Toggle will turn triggers into booleans and If will turn booleans into triggers. 

This works great if you want to turn beat triggers into logic operations or use the result of a logic operation to blow up that Attack Release or Random node.


The Not gate can be used to inverse the boolean (true because false and vice versa). This can be useful to create reverse bypasses on video effect nodes.


On Change is a node that sends out a boolean when the incoming value changes.
This node is particularly useful when doing logic operations with a signal flow.


Example

In this example we use multiple simple logic operations to have a rectangle rotate, scale and change color based on its position.


--begin-wire-patch--2496.3oc4ak0aaijD9uBgd1MQeej2z4hAX.1AwYvrKFLOPK1xhanHU3QbxD3+6a0M0AkE0gsTVXgUFvVhpX2rqup95ppt7O5MMOKyNsJIOqr2G9yezaVQ9B3Mj65kWWsrtp2ecWupb3Jz65kj4uvy2sQL7dhwWIFdG43qkCuQPwc8Js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r.gGOnOe3fQ39iGeUNEoWXlUWXowG4H9ZEdZizdU4MTMIcNO265VKHQ0rXXysn33xlct7NHqR4swix2VW9xVFrR4bQ9JDBCbLHBAU0hcTDpjZlFxmBqoueqJEUcI8ax0wuB2DAHUFpLFIkHVov7JRPCEhMbmd5ndT7glwH9DE3awmfQBNQLPQXi6SFbs8n1qKfH9t.hraJeq6IvVZcm03uj4U652OpcSnVp1w.2SmA58lSJS8NUqC57PMWgEZMX6vg4VRk2Qdc3PGkxapumMNcAW3dNtqJn0pmWOqdi3baAJt1DxL.O01ttqw4B.eBGvXAnEOATK0FCh22LDoo8GfLbCiKwLFmi+4zHTGnO65tinNfvaag32RWUzjgjC9XcUnlrpDX+PHE4GQwIE6MO6suXiI2CIUw1k6zpf6I4uE4NXsAIUAi7h971FG9U16cE1x7z5S8j0Le261F94Us87qZd5dySU2aUpXPxDMsYSiQHP.QEtd9hwMR7IZB39TIhqFIQFsnOv5LRLZHivGLQ01Jj7lJ7nGOib.5gqBHuEVb78DHMbQqai7ynPk6PasyiSKaxVQ43sLI+r2I4tdKgg2VbTKnYDzLxqfPBRuPw4BoRqHdHuIpICNDSg7L4Jsfb7M7GOj6JA8HFDL8.IZnTOfKGqw3caGb56rFy727czzc83++ce991adWWuao0XAreODX9IRDsOki3imnQ84hwn9SlLfCrOiTCm7dt4c+GMsLiCHDu83StcBOoiSB70fx+OOxjc0ImDka9WB4ZEJh7M1Mss7sey4OHzmYsceMvmVN0h3Vs.EgowHFeFjL8roQJtM3RwO2trG+f+na3Fe89oM8AiSmpuP172BS64h2Kh91qb3c2w4N3IYu1AOI6m8VDtzZvpsW7H+iGLouBxesu.YvTi6Ds0fQr.Su7ywty7W2c+APOeLZCF1+hPLTrgpMxFs2guETW2S2lt+g+.87JYWJB0EM7AO+7+EnUwyl--end-wire-patch--


In Verbindung stehende Artikel