From 9fbf91db06a6d4f4b5cd8bb45389a731bb86bf22 Mon Sep 17 00:00:00 2001 From: Richard Date: Sun, 13 Apr 2025 18:48:02 +0100 Subject: initial --- site/udo/fnml/instrument_tikclay.udo | 118 +++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100755 site/udo/fnml/instrument_tikclay.udo (limited to 'site/udo/fnml/instrument_tikclay.udo') diff --git a/site/udo/fnml/instrument_tikclay.udo b/site/udo/fnml/instrument_tikclay.udo new file mode 100755 index 0000000..73a6e5d --- /dev/null +++ b/site/udo/fnml/instrument_tikclay.udo @@ -0,0 +1,118 @@ +#ifndef UDO_FNMI_TIKCLAY +#define UDO_FNMI_TIKCLAY ## + +#include "sounddb.udo" +#include "bussing.udo" +#include "wavetables.udo" +#include "uniqueid.udo" +#include "sequencing_melodic.udo" + +gitikfn_clay[], gicl_clay sounddb_getcollection "Clay.Hit" + +instr _tik_clay_play + instanceid = p4 + ifileid = p5 + ipitch = p6 + iwsize = p7 + irandw = p8 + ipan = p9 + iresonfreq = p10 + idoreson = p11 + + ifn = gisounddb[ifileid][0] + idur = gisounddb[ifileid][2] + istart = idur * random(0, 0.1) + atime linseg istart, p3, idur*0.9 + kamp linseg 1, p3*0.8, 1, p3*0.2, 0 + aL, aR sndwarpst 1, atime, ipitch, ifn, istart, iwsize, irandw, 2, gifnHalfSine, 1 + + if (idoreson == 1) then + aLr resony aL, iresonfreq, 6, 16, 10 + aRr resony aR, iresonfreq, 6, 16, 10 + aL balance aLr, aL + aR balance aRr, aR + endif + + ilpf = random(2000, 22050) + aL butterlp aL, ilpf + aR butterlp aR, ilpf + bus_mix(sprintf("tikclayaudio%d", instanceid), aL*ipan*kamp, aR*(1-ipan)*kamp) +endin + + +instr _tik_clay_item + instanceid = p4 + index = p5 + kreset init 1 + + kfreq = chnget:k(sprintf("tikclay_%d_%d", instanceid, index)) + + if (kfreq == 0) then + if (kreset == 0) then + kreset = 1 + endif + kplaying = 0 + else + kplaying = 1 + endif + + if (kreset == 1) then + kfileid = gitikfn_clay[round:k(random:k(0, lenarray:k(gitikfn_clay) - 1))] + kdur = random:k(0.4, 1.3) * gisounddb[kfileid][2] + kpitch = random:k(0.1, 2.2) + kwsize = random:k(44, 441) + krandw = kwsize / 10 + kpan = random:k(0, 1) + kresonfreq = cpsmidinn:k(mel_randomnote:k()) * 2 + if (random:k(0, 1) >= 0.5) then + kresonfreq *= 2 + endif + kreset = 0 + endif + + if (kplaying == 1) then + kmetro metro kfreq, random(0, 1) + if (kmetro == 1) then + kresonchance = chnget:k(sprintf("tikclay_resonchance_%d", instanceid)) + kdoreson = (random:k(0, 0.99999) < kresonchance) ? 1 : 0 + schedulek "_tik_clay_play", 0, kdur, instanceid, kfileid, kpitch, kwsize, krandw, kpan, kresonfreq, kdoreson + endif + endif +endin + + +opcode tik_clay_bank, iaa, i + inum xin + + icollection[] = gitikfn_clay + instanceid = uniqueid() + + iusedinstruments[] uniqueinstrnums "_tik_clay_item", inum + + index = 0 + ifileindex = 0 + while (index < lenarray(iusedinstruments)) do + ifileid = icollection[ifileindex] + + schedule iusedinstruments[index], 0, p3, instanceid, index + if (ifileindex + 1 < lenarray(icollection)) then + ifileindex += 1 + else + ifileindex = 0 + endif + index += 1 + od + + if (release:k() == 1) then + kindex = 0 + while (kindex < lenarray(iusedinstruments)) do + turnoff2 iusedinstruments[kindex], 4, 1 + kindex += 1 + od + endif + + aL, aR bus_read sprintf("tikclayaudio%d", instanceid) + xout instanceid, aL, aR +endop + +#end -- cgit v1.2.3