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_automel.udo | 89 ++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100755 site/udo/fnml/instrument_automel.udo (limited to 'site/udo/fnml/instrument_automel.udo') diff --git a/site/udo/fnml/instrument_automel.udo b/site/udo/fnml/instrument_automel.udo new file mode 100755 index 0000000..437acc0 --- /dev/null +++ b/site/udo/fnml/instrument_automel.udo @@ -0,0 +1,89 @@ +#ifndef UDO_FNMI_AUTOMEL +#define UDO_FNMI_AUTOMEL ## + +#include "sequencing_table.udo" +#include "sequencing_melodic.udo" +#include "bussing.udo" + +instr _play_fnmi_automel1 + icollectionid = p4 + Sbus = p5 + ifreqmult = p6 + inote = mel_randomnote() + if (random(0, 1) >= 0.5) then + inote += 12 + endif + + idowaveset = (random(0, 1) >= 0.8) ? 1 : 0 + if (idowaveset == 1) then + if (random(0, 1) >= 0.6) then + p3 *= random(1.2, 1.8) + endif + endif + + ifileid, ipitchratio sounddb_mel_nearestnote icollectionid, inote + ifn, ichannels, iduration, irmsnorm sounddb_get ifileid + + ireadtype = round(random(0, 2)) + + if (ireadtype == 0) then + aL, aR loscil 1, ipitchratio * ifreqmult, ifn, 1 + else + atime line 0, p3, iduration * random(0.5, 1) + if (ireadtype == 1) then + imincerfftsize = pow(2, round(random(8, 11))) + aL, aR mincer atime, random(0.7, 1.1), ipitchratio * ifreqmult, ifn, 0, imincerfftsize + elseif (ireadtype == 2) then + iwsize = random(441, 4410) + aL, aR sndwarpst 1, atime, ipitchratio * ifreqmult * (ftsr(ifn) / sr), ifn, 0, iwsize, iwsize * 0.1, 4, gifnHalfSine, 1 + endif + endif + aamp linseg 1, p3*0.9, 1, p3*0.1, 0 + + if (random(0, 1) >= 0.6) then + aL, aR ringmod1 aL, aR, cpsmidinn(inote) * 2 + endif + + aL *= aamp + aR *= aamp + if (idowaveset == 1) then + kwaveseta line 0, p3, round(random(2, 5)) + aL waveset aL, kwaveseta + aR waveset aR, kwaveseta + endif + if (random(0, 1) >= 0.7) then + aL distort aL, 0.5, gifnSine + aR distort aR, 0.5, gifnSine + aL *= 0.4 + aR *= 0.4 + endif + + bus_mix(Sbus, aL, aR) +endin + +/* + aL, aR automel1 icollectionid1, kchance=1, kdivisions=4, icollectionid2=icollectionid1, kfreqmult=1 +*/ +opcode automel1, aa, iVJjJ + icollectionid1, kchance, kdivisions, icollectionid2, kfreqmult xin + kdivisions = (kdivisions == -1) ? 4 : kdivisions + kfreqmult = (kfreqmult == -1) ? 1 : kfreqmult + kcollectionid init icollectionid1 + Sbus = sprintf("fnmautomel%d", uniqueid()) + ktrig seq_table gifn_tabseq_all, 0, 4, kchance + instrnum = nstrnum("_play_fnmi_automel1") + uniquefrac() + if (ktrig == 1 && active:k(instrnum) == 0) then + if (icollectionid2 != -1) then + if (random:k(0, 1) >= 0.5) then + kcollectionid = icollectionid1 + else + kcollectionid = icollectionid2 + endif + endif + schedulek(instrnum, 0, gkseq_quartertime * random:k(0.5, 4), kcollectionid, Sbus, kfreqmult) + endif + aL, aR bus_read Sbus + xout aL, aR +endop + +#end -- cgit v1.2.3