diff options
author | Richard <q@1bpm.net> | 2025-04-13 18:48:02 +0100 |
---|---|---|
committer | Richard <q@1bpm.net> | 2025-04-13 18:48:02 +0100 |
commit | 9fbf91db06a6d4f4b5cd8bb45389a731bb86bf22 (patch) | |
tree | 291bd79ce340e67affa755a8a6b4f6a83cce93ea /site/udo/sample_level.udo | |
download | apps.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/sample_level.udo')
-rwxr-xr-x | site/udo/sample_level.udo | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/site/udo/sample_level.udo b/site/udo/sample_level.udo new file mode 100755 index 0000000..3aa5b1e --- /dev/null +++ b/site/udo/sample_level.udo @@ -0,0 +1,90 @@ +#ifndef UDO_SAMPLELEVEL
+#define UDO_SAMPLELEVEL ##
+/*
+ Sample level block processing
+
+ This file is part of the SONICS UDO collection by Richard Knight 2024
+ License: GPL-2.0-or-later
+ http://1bpm.net
+*/
+
+opcode smp_hold, a, ak
+ ain, kratio xin
+ aout init 0
+ ktrig metro kr * kratio
+ if (ktrig == 1) then
+ kindex = 0
+ while (kindex < ksmps) do
+ aout[kindex] = ain[kindex]
+ kindex += 1
+ od
+ endif
+ xout aout
+endop
+
+opcode smp_rearrange, aa, iiiij
+ ichops, ichopmin, ichopmax, ifnL, ifnR xin
+ if (ichopmin > ichopmax) then
+ ichopmin = ichopmax
+ endif
+ ilen = ftlen(ifnL)
+ if (ichopmin > ilen) then
+ ichopmin = round(ilen * 0.1)
+ endif
+ if (ichopmax > ilen) then
+ ichopmax = round(ilen * 0.2)
+ endif
+ ichopfn ftgentmp 0, 0, -(ichops * 3), 2, 0
+ index = 0
+ iwriteindex = 0
+ while (index < ichops) do
+ ichoplen = round(random(ichopmin, ichopmax))
+ ichopstart = round(random(0, ilen - ichoplen))
+ tabw_i ichopstart, iwriteindex, ichopfn
+ tabw_i ichoplen, iwriteindex + 1, ichopfn
+ tabw_i round(random(0, ilen - ichoplen)), iwriteindex + 2, ichopfn
+ iwriteindex += 3
+ index += 1
+ od
+ apos lphasor 1
+ kindex1 = 0
+ kinmove init 0
+ while (kindex1 < ftlen(ichopfn)) do
+ kstart tab kindex1, ichopfn
+ klen tab kindex1 + 1, ichopfn
+ kdest tab kindex1 + 2, ichopfn
+ koffset = 0
+ kindex2 = 0
+ while (kindex2 < ksmps) do
+ if (apos[kindex2] >= kdest) then
+ kinmove = 1
+ koffset = apos[kindex2] - kdest
+ endif
+ if (apos[kindex2] >= kdest + klen) then
+ kinmove = 0
+ endif
+ if (kinmove == 1) then
+ apos[kindex2] = kstart + koffset
+ endif
+ kindex2 += 1
+ od
+ kindex1 += 3
+ od
+
+ aL table3 apos, ifnL
+ if (ifnR != -1) then
+ aR table3 apos, ifnR
+ else
+ aR = aL
+ endif
+ xout aL, aR
+endop
+
+opcode smp_rearrange, a, iiii
+ ichops, ichopmin, ichopmax, ifn xin
+ aout, a_ smp_rearrange ichops, ichopmin, ichopmax, ifn
+ xout aout
+endop
+
+#end
+
|