Randomize Functions

The idea is simple: the notes within a track’s selection are randomly changed based on a user defined mask.

Like this:

C-3

C-4


G-3

A#4

would (possibly) become after the randomization of the above selected notes:

G-3

C-3


A#4

C-4

or (possibly) like this (assuming the mask also alters the time position of the notes within the selection range):

G-3
C-3
C-4



A#4

I think you get the idea…

For the record: I realize that Renoise already has a “Randomize” function for the effects column. But it doesn’t work with notes or their positions, so I think the above suggestion is proper to make.

Randomizing value effects never seemed an interesting feature to me, but randomizing notes really seems useless to me. COuld you make me an example of a possible field of use?

The field of use I was primarily thinking of was melody making. Often, I find myself inspired by similar functions in, say, Reason’s matrix device. The ability to quickly re-arrange (by randomizing) a selection of notes through a mask (see my two examples above) is anything but useless for me.

The only field of use i can think of as to create a sort of ring modulating or filter channel for another real instrument.
But in that case you could copy the track as well to a new pattern and then up or down the whole range a few semitones using Advanced edit.

I get it, a random ostinato generator of sorts. I’d certainly use it.

This type of stuff will be possible in the next version via XML though I’d imagine…

Well maybe not, but this kind of code could even be written by a simple php script.
Just copy the selection to clipboard, paste it in the php form and then copy the output back to the clipboard and paste it to Renoise.
There are so many modifications you can do through php. (That’s why Pulsar suggested to use PHP-GTK as development environment because with PHP-Gtk and Glade you can design gui concepts around it.)

I’ll just show a few excerpts of songdata:
A track containing multiple notes

<lines><line>0:D#302..F2,A#302D1F3,D#402D1F3</line><line>2:D#302..F2,A#302D1F2,D#402D1F2</line><line>4:D#302D5..,A#3027CF5,D#402D5..,0D04</line><line>5:OFF......,---......,OFF......</line><line>8:D#3027AF2,A#302D1F2,D#402D1F2</line><line>10:D#302D1F2,A#3027FF1,D#402D1F2</line><line>28:F#3027C..,C#4027AD1,F#4027AD1</line><line>30:G#3027F..,D#4027CD1,G#4027CD1</line><line>32:C#402..F2,F-402D1F3,A#402D1F3</line><line>34:C#402..F2,F-402D1F2,A#402D1F2</line><line>36:C#402D5..,F-4027CF5,A#402D5..</line><line>37:OFF......,---......,OFF......</line><line>40:C#4027AF2,F-402D1F2,A#402D1F2</line><line>42:C#402D1F2,F-4027FF1,G#402D1F2</line><line>58:A#3027FF1,F-402F1D1,A#402F1D1</line><line>59:OFF......,OFF......,G#4027F..</line><line>60:---..7F..,---..7CD1,C#4027FD1</line><line>62:---......,---......,OFF......</line></lines>  
  

A track containing only an effect and a noteoff:

  
<lines><line>0:1F00</line><line>63:OFF......</line></lines>  
  

A track containing a note and effect and only an effect:

  
<lines><line>0:C-400....,1F00</line><line>48:1F01</line></lines>  
  

I guess you get the picture what to scan the code for and which things to hussle up and you can obviously see how rows are stored.
Start learning PHP i should say.

Yes indeed, I already use PHP everyday in my work and can’t wait to make weirdo Renoise data with it.

Screw PHP… I’m gonna write some kickass Renoise song mangling apps in VB.Net… WITH A REAL INTERFACE :P

I actually like the idea of randomizing note order… I could find much use in that… on that note, I’ve got another idea to feed your brain with, but I’m gonna post it in a separate thread.

And how would Mac OS users benefit from your client application then?
A real interface is not always as portable as you want it to be.

drum kits!

if you could randomise the note values using a drum kit instrument, you could create random drum patterns. this feature would tide me over until a beatslicing feature is added :D

Does anyone actually want this? It would be something like this in PHP5.

  
EDIT: Scroll down...  
  

The xrns_merge.php script could be modified to do this quite easily…

Well, here’s something completely useless… enjoy?

  
EDIT: Scroll down...  
  

MP3 example of this script run on a VST heavy XRNS.

Before: http://www.nullwhore.com/dactemp/before.mp3
After: http://www.nullwhore.com/dactemp/after.mp3

Most of the work involves unpacking and packing the song. The important code is:

  
  
function randomize_note() {  
  
 $letter = 'ABCDEFG';  
 $symbol = '-#';  
 $number = '0123456789';  
  
 $random = '';   
 $random .= substr($letter, mt_rand(0, strlen($letter)-1), 1);   
 if ($random == 'B' || $random == 'E') $random .= '-';  
 else $random .= substr($symbol, mt_rand(0, strlen($symbol)-1), 1);   
 $random .= substr($number, mt_rand(0, strlen($number)-1), 1);  
  
 return $random;   
  
}  
  
foreach ($sx1->PatternPool->Patterns->Pattern as $p) {  
 foreach ($p->Tracks->PatternTrack as $x) {  
 if ($x->Lines->Line) {  
 foreach ($x->Lines->Line as $y) {  
 if ($y->NoteColumns->NoteColumn) {  
 foreach ($y->NoteColumns->NoteColumn as $z) {  
 if ($z->Note && $z->Note != 'OFF') {  
 $z->Note = randomize_note();  
 }  
 }  
 }  
 }  
 }  
 }  
}  
  

If you have a look at xrns_merge.php, you could probably use simplexml_append() and simplexml_insert_before() to implement a few more tricks. Fine tune the randomize_notes() for a less random something… There’s ton you, the reader, can do here. Go nuts!

EDIT: I read the first post, just now, lol. This script does not do what is described by the original poster. This script changes every single note in a song to a random value. Sorry if that wasn’t clear. I just read “randomize notes” and went off from there. I think what is being asked isn’t much more work. 1) Scan the PatternTrack once and store all the notes in an $array. 2) Randomize the $array 3) Rewind, scan the PatternTrack again and pop the values from $array into the notes. In fact, here’s some working code that you can replace the randomize section above with to get that result:

  
$array = array();  
foreach ($sx1->PatternPool->Patterns->Pattern as $p) {  
 foreach ($p->Tracks->PatternTrack as $x) {  
 if ($x->Lines->Line) {  
 foreach ($x->Lines->Line as $y) {  
 if ($y->NoteColumns->NoteColumn) {  
 foreach ($y->NoteColumns->NoteColumn as $z) {  
 if ($z->Note && $z->Note != 'OFF') {  
 $array[] = $z->Note;  
 }  
 }  
 }  
 }  
  
 shuffle($array);  
  
 foreach ($x->Lines->Line as $y) {  
 if ($y->NoteColumns->NoteColumn) {  
 foreach ($y->NoteColumns->NoteColumn as $z) {  
 if ($z->Note && $z->Note != 'OFF') {   
 $z->Note = '' . array_pop($array);  
 }  
 }  
 }  
 }   
  
 }  
 }   
}  
  

Seriously, someone else, why not try? It’s fun! (…almost)

Scripts have moved:
http://www.trotch.com/xrns_scripts/

Why did I miss this stuff before? Dac, this is really cool stuff! Keep it going. :)

Edit: Now I just have to figure out how to randomize the notes according within the borders of certain tone scales (so they still will be “musically correct”)… Hmm…

Pseudo code follows, this is untested and theoretical, but the idea shoukd work, i leave it up to you to wait that I do something or, better yet, you hack your own script.

  
function randomize_note($note) {  
  
 // Run a regular expression on $note, example:  
 // preg_match('/[a-gA-G]{1}?[\-\#]{1}?\d+/', $note, $matches);   
 // This will create $matches[]   
 // $matches[0] will be the letter aka [a-gA-G]{1}? which means match range a-g or A-G 1 time non-greedy mode   
 // $matches[1] will be the symbol aka [\-\#]{1}?which means match - or # 1 time non-greedy mode  
 // $matches[2] will be the number aka \d+ which means match 1 or more digit  
 // with those three items, you can determine what the note is, and apply an algorithm to change it.   
 // EDIT:  
 // Assuming the note doesn't need to be validated, the following is much easier:  
 // $matches = str_split($note);  
  
 return $random;   
  
}  
  
foreach ($sx1->PatternPool->Patterns->Pattern as $p) {  
 foreach ($p->Tracks->PatternTrack as $x) {  
 if ($x->Lines->Line) {  
 foreach ($x->Lines->Line as $y) {  
 if ($y->NoteColumns->NoteColumn) {  
 foreach ($y->NoteColumns->NoteColumn as $z) {  
 if ($z->Note && $z->Note != 'OFF') {  
 $z->Note = randomize_note($z->Note);  
 }  
 }  
 }  
 }  
 }  
 }  
}  
  

Good times.

But that’s how I create my perc-loops! lol
I just bash away at the fookin’ keyboard, then put me cursor on the instrument number and re-bash.
I’d be GREAT if this were to be in Renoise to just hit a simple button and voila : random notes with random instrument numbers.
Ofcourse then I also quickly add some effects and flipflop! change some settings. :)

I’m positive Aphex Twin wrote some little apps himself to randomize his beats. There’s NO WAY those beats are in his head like that.