Random 'round robin'?

Is there an easy way to generate a random number that ... doesn't repeat?!

I know this is probably harder than it sounds (!)

This is my script so far - it's for triggering random effects in Shaperbox VST. Works great, but sometimes repeats the same note. Be nice if it didn't!

var rnd = Math.round(Math.random()*8) + 1 
var sendnote = rnd + 60
send("midi:fx", "/note", 1, sendnote, 127)

Thanks in advance for your thoughts.

Sorry, my previous attempt had an issue, but this one is working.

Code for the onCreate prop:

locals.randomNote = (note) => {
  let newNote
  do {
    newNote = Math.round(Math.random() * 8) + 61
  } while (note == newNote)
  locals.lastNote = newNote
  return newNote

Code for the onValue prop:

const sendNote = locals.randomNote(locals.lastNote)
send("midi:fx", "/note", 1, sendnote, 127)


1 Like

Agh this is amazing! Thanks so much


:pray: :pray: :pray: