From b86ead7e39f8d95e070045581feec97ce7d142f6 Mon Sep 17 00:00:00 2001 From: Michael Ganss Date: Thu, 27 Jun 2019 16:53:50 +0200 Subject: [PATCH] Add clip creation feature --- Aicd.amxd | Bin 59481 -> 57354 bytes acid.js | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/Aicd.amxd b/Aicd.amxd index 4148c71d2fd8e6c2088f783d812cc3af1cd55fac..534daccdf47a3ee2d3da6eabc892a86c3074df70 100644 GIT binary patch delta 3652 zcma)92~bq$9iO)%vdg&~!lJ-q5fvoMyLXpsVm%N>s;KCg#AAguLbzG+iq&M2sOf0H zpCOIfC>rT#6H|RL(XkV8(n*?_c+{Aglr{oZ+v&6+rnN_GNWbrUy9+3Zd9(B0xBu(= zfB*aY?DClByT`OmH2w8@d#aDq+EJKWS?g(OsrS@*TN*u;UOS)1+gCNLx93D!%w~JD zx6(&JkMgqO5OR2z3M-d%;+u>yaPW~RdRapgUlXIcWQUr=J2f{Y(nPd}#-TJl3NZ_3 znOp*{WNnKM(8v-cmC+U&AL;Y1XX5QuYwH@}NiX7@IGDZ$2NU@iL3B8&OhKSBMFE`| z@wOmCW3#u>TVKUf#)UpFV>UV6bf*Z_*uqIac=(aTp=~N_t0|?7FS??q&1m*|eBKt` z!`FM)@f5|ctM;woeQUgY<=Wb8^s8kbr^w zs1T-RUvYXwtEX19=kRv&m5^JYVS7OazC92hLUlp;jEu3A)Q%G;Q{gBv8(@z--jGmU zRum~R_A6WtsW$bZC^RrUj!) zGbwJght*g#(IHW1xrtv>ZPfLYg*cRiM;W?b&bJ0A4Bv=?L}gF7&z~(`-|Xu3#l$g; zds@hgDVj2hh9c8YWs#=mjTJbY4!w;N6XFpb_AOeS@l*$WlR28hi?Q(p8HN8^ZpDg% zs<5!qoGJ}N)fo)c}}i2hju#4UsnNkGv5picWU`I24LRz6D=LeP$gJDQFB0 z&*22jj`{nLG*y#Pw3nDAej)yCeIX(!aX6whjvxZ+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`L16w@xtd>Fw 0 ? liveSteps[i - 1] : null; + if (!fixGate && step.gate === 0) continue; + if (previousStep !== null && previousStep.pitch === step.pitch && previousStep.slide === 1 && (fixGate || previousStep.gate === 1)) { + // slide and same pitch as previous step -> extend duration of previous note + if (step.slide === 1) + previousNote.Duration += 0.25; + } else { + var note = new Note(step.pitch, i / 4.0, step.slide === 1 ? 0.375 : 0.125, step.velocity); + notes.push(note); + previousNote = note; + } + } + + return notes; +} + +function clip() { + var track = new LiveAPI("this_device canonical_parent"); + var clipSlots = track.getcount("clip_slots"); + var clipSlot; + + var firstClip = null; + + for (var clipSlotNum = 0; clipSlotNum < clipSlots; clipSlotNum++) { + clipSlot = new LiveAPI("this_device canonical_parent clip_slots " + clipSlotNum); + var hasClip = clipSlot.get("has_clip").toString() !== "0"; + if (!hasClip) break; + } + + if (clipSlotNum === clipSlots) { + // have to create new clip slot (scene) + var set = new LiveAPI("live_set"); + set.call("create_scene", -1); + clipSlot = new LiveAPI("this_device canonical_parent clip_slots " + clipSlotNum); + } + + var beats = Math.ceil(patternLength / 4); + clipSlot.call("create_clip", beats); + var clip = new LiveAPI("this_device canonical_parent clip_slots " + clipSlotNum + " clip"); + var notes = generateMidi(); + + setNotes(clip, notes); +} + +function setNotes(clip, notes) { + clip.call("set_notes"); + clip.call("notes", notes.length); + + for (var i = 0; i < notes.length; i++) { + var note = notes[i]; + clip.call("note", note.Pitch, note.Start.toFixed(4), note.Duration.toFixed(4), note.Velocity, note.Muted); + } + + clip.call("done"); +}