nojanath / SublimeKSP

Fork of Nils Liberg's SublimeKSP plugin. See README for details.
GNU General Public License v3.0
90 stars 18 forks source link

XOR operator #55

Closed magneto538 closed 1 year ago

magneto538 commented 7 years ago

When I type .xor., SublimeKSP highlights it as if it was an actual operator, but Kontakt does not support it, thus the compilation fails.

Might be a good idea to add the operator to the compiler so that if I write .xor. it would be compiled as .and. .not. (which is exactly the same thing).

andreasOL16 commented 7 years ago

hmm...

a b a .xor. b a .and. .not. b
0 0 0 0
0 1 1 0
1 0 1 1
1 1 0 0
magneto538 commented 7 years ago

What about:

.not. (a .and. b)

andreasOL16 commented 7 years ago
a b a .and. b .not. (a .and. b)
0 0 0 1
0 1 0 1
1 0 0 1
1 1 1 0

Well, this too trivial for a guessing game :-) There are a few ways to synthesize xor, depending on what elements you have (if you were to assemble it in hardware with logic circuits). But one other logic function (.and. or .or.) and an inverter is too little. Just write down the truth table and check

magneto538 commented 7 years ago

Here we go.

(a .and. .not. b) .or. (.not. a .and. b)

a b a .and. .not. b .not. a .and. b ... .or. ...
0 0 0 0 0
0 1 0 1 1
1 0 1 0 1
1 1 0 0 0
andreasOL16 commented 7 years ago

Right, this is one variant that works. As far as I have seen you need three logic functions to simulate .xor. (here: two .and. and one .or.) plus negations.

magneto538 commented 7 years ago

Yep. All the operations in Boolean algebra are based on AND, OR and NOT, so any advanced operation (such as XOR) is based entirely on combinations of these three operators.

ghost commented 4 years ago

Just wanted to add that in Big Bob's maths library he has an XOR function which returns the equivalent of: (a .or. b) - (a .and. b)

mkruselj commented 2 years ago

It would actually be better if Kontakt supported it in the first place. 🙂

That miiiiiight or might not happen, so I'm not sure if I should actually remove this syntax coloring from SublimeKSP, for the time being...

mkruselj commented 1 year ago

Coming natively to Kontakt relatively soon. 🙂