aboutsummaryrefslogtreecommitdiff
path: root/site/udo/quad.udo
diff options
context:
space:
mode:
authorRichard <q@1bpm.net>2025-04-13 18:48:02 +0100
committerRichard <q@1bpm.net>2025-04-13 18:48:02 +0100
commit9fbf91db06a6d4f4b5cd8bb45389a731bb86bf22 (patch)
tree291bd79ce340e67affa755a8a6b4f6a83cce93ea /site/udo/quad.udo
downloadapps.csound.1bpm.net-9fbf91db06a6d4f4b5cd8bb45389a731bb86bf22.tar.gz
apps.csound.1bpm.net-9fbf91db06a6d4f4b5cd8bb45389a731bb86bf22.tar.bz2
apps.csound.1bpm.net-9fbf91db06a6d4f4b5cd8bb45389a731bb86bf22.zip
initial
Diffstat (limited to 'site/udo/quad.udo')
-rwxr-xr-xsite/udo/quad.udo79
1 files changed, 79 insertions, 0 deletions
diff --git a/site/udo/quad.udo b/site/udo/quad.udo
new file mode 100755
index 0000000..bd9abc3
--- /dev/null
+++ b/site/udo/quad.udo
@@ -0,0 +1,79 @@
+#ifndef UDO_QUAD
+#define UDO_QUAD ##
+/*
+ Quadrophonic setup and tools
+
+ This file is part of the SONICS UDO collection by Richard Knight 2025
+ License: GPL-2.0-or-later
+ http://1bpm.net
+*/
+#define QUAD ##
+#include "wavetables.udo"
+vbaplsinit 2, 4, 45, 135, 225, 314 ; or 0, 90, 180, 270
+
+opcode cart2apol, ii, ii
+ ix, iy xin
+ idistance = sqrt(pow(ix, 2) + pow(iy, 2))
+ idegrees = taninv(iy / ix) * (180 / (22 / 7)) - 90
+ if (qnan(idegrees) == 1) then
+ idegrees = 0
+ endif
+ xout idegrees, idistance
+endop
+
+opcode cart2apol, kk, kk
+ kx, ky xin
+ kdistance = sqrt:k(pow:k(kx, 2) + pow:k(ky, 2))
+ kdegrees = taninv:k(ky / kx) * (180 / (22 / 7)) - 90
+ if (qnan:k(kdegrees) == 1) then
+ kdegrees = 0
+ endif
+ xout kdegrees, kdistance
+endop
+
+opcode quadify, aaaa, akO
+ ain, kangle, kbleed xin
+ a1, a2, a3, a4 vbap ain, kangle, 0, kbleed * 100
+ xout a1, a2, a3, a4
+endop
+
+opcode quadify, aaaa, aakOO
+ aL, aR, kangle, kspreadangle, kbleed xin
+ kbleed *= 100
+ aL1, aL2, aL3, aL4 vbap aL, kangle - kspreadangle, 0, kbleed
+ aR1, aR2, aR3, aR4 vbap aR, kangle + kspreadangle, 0, kbleed
+ xout aL1 + aR1, aL2 + aR2, aL3 + aR3, aL4 + aR4
+endop
+
+opcode _quadify_random_params, kk, 0
+ kangle init random(0, 359)
+ kbleed init random(0, 15)
+ ktime init random(1, 10)
+ krate = 1 / ktime
+ ktrig metro krate
+ if (ktrig == 1) then
+ ktime = random:k(1, 10)
+ kangle = random:k(0, 359)
+ kbleed = random:k(0, 15)
+ endif
+
+ kanglep portk kangle, ktime
+ kbleedp portk kbleed, ktime
+ xout kanglep, kbleedp
+endop
+
+opcode quadify_random, aaaa, a
+ ain xin
+ kangle, kbleed _quadify_random_params
+ a1, a2, a3, a4 quadify ain, kangle, kbleed
+ xout a1, a2, a3, a4
+endop
+
+opcode quadify_random, aaaa, aa
+ aL, aR xin
+ kangle, kbleed _quadify_random_params
+ a1, a2, a3, a4 quadify aL, aR, kangle, kbleed
+ xout a1, a2, a3, a4
+endop
+
+#end