# Xml Based Pattern Recognition

**URL:** <https://forum.renoise.com/t/xml-based-pattern-recognition/22440>\
**Category:** Renoise XML Fileformats & Tools\
**Created:** [June 16, 2008, 11:11pm UTC](https://forum.renoise.com/t/xml-based-pattern-recognition/22440 "2008-06-16T23:11:30Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![danoise](https://forum.renoise.com/user_avatar/forum.renoise.com/danoise/32/64_2.png) [@danoise](https://forum.renoise.com/u/danoise)\
**Post date:** [June 16, 2008, 11:11pm UTC](https://forum.renoise.com/t/xml-based-pattern-recognition/22440/1 "2008-06-16T23:11:30Z")

</div>

I’ve got this idea that relates to the concept of “clips” in Renoise: from the discussion I’ve had with Pysj, it has become clear that if we ever were to have arranger-like features, everything in a song/pattern would need to be interpreted as a clip, on some level. Which is all well and good. It’s quite easy to imagine a workflow where you start a new song, add some notes, they become a clip, et cetera.

But how about loading an “old” song, from the days before clips were invented? That song would still need to converted into clips, and I just don’t like the idea of having each track in each pattern become a seperate clip, it would result in way too many clips, and totally without regard to what was actually going on inside these tracks.

So, what I am talking about is a way to look for patterns within the song data (as in information patterns, not just pattern editor data), which could then be used as a starting point for further (clip) editing! I’ve got a lot of ideas already for note/value-based interpretations, and a pretty good understanding of regular expressions, yet I think this is slightly more complicated than the average text-based search & replace script - and a reasonable performance would be important too.

So, what language would be best, how would one go about such a thing in the first place? Pointers needed?  
Edit: and no suggestions about using c++ - I’m actually thinking about using actionscript ::

---

<div class="post-metadata">

**Author:** ![Icarus](https://forum.renoise.com/user_avatar/forum.renoise.com/icarus/32/671_2.png) [@Icarus](https://forum.renoise.com/u/Icarus)\
**Post date:** [June 17, 2008, 8:36am UTC](https://forum.renoise.com/t/xml-based-pattern-recognition/22440/2 "2008-06-17T08:36:15Z")

</div>

danoise,

First, if I remember correctly and understood correctly, the clips discussion gave me the impression that clips are in ADDITION to notes, and not replacing them altogether.

So loading old songs, should play as usual, and only if you want to add clips to that new song, you select your bunch of notes, and “make a clip”.

If I did not understand correctly, then I am very worried about that clips idea.

Now, if I got your coding question at the end right, you are looking for a small programming language to test your theories. If so, I strongly recommend Autohotkey. It is excellent for:

1. creating advanced batch files
2. creating fast utilities
3. manipulating windows / mouse / keyboard / clipboard and other windows elements
4. creating full blown applications (although without the bells and whistles that visual studio gives you)

This is a very easy installation, and there is no studio environment to work in - you just use your favorite text editor.

See [http://autohotkey.com](http://autohotkey.com)

If you choose to try it out, I am happy to assist and be your “getting started” guide ![:)](https://files.renoise.com/forum/emoticons/default/smile.gif)

P.S. FlicFlac and RPG (see signature) were made with autohotkey.

---

<div class="post-metadata">

**Author:** ![taktik](https://forum.renoise.com/user_avatar/forum.renoise.com/taktik/32/3823_2.png) [@taktik](https://forum.renoise.com/u/taktik)\
**Post date:** [June 17, 2008, 9:38am UTC](https://forum.renoise.com/t/xml-based-pattern-recognition/22440/3 "2008-06-17T09:38:19Z")

</div>

Wouldnt

1. make a clip for each pattern track which is not empty
2. divide (clone) each non empty pattern track clip into X parts if the X parts are equal

(X should be maybe simply be 4, but could also be dependent on the speed/pattern lenght)

not be enough and super simple?

Everything else should and could be IMHO done manually.

---

<div class="post-metadata">

**Author:** ![danoise](https://forum.renoise.com/user_avatar/forum.renoise.com/danoise/32/64_2.png) [@danoise](https://forum.renoise.com/u/danoise)\
**Post date:** [June 17, 2008, 2:38pm UTC](https://forum.renoise.com/t/xml-based-pattern-recognition/22440/4 "2008-06-17T14:38:59Z")

</div>

> [@Icarus](#):
>
> danoise,
> 
> First, if I remember correctly and understood correctly, the clips discussion gave me the impression that clips are in ADDITION to notes, and not replacing them altogether.
> 
> So loading old songs, should play as usual, and only if you want to add clips to that new song, you select your bunch of notes, and “make a clip”.
> 
> If I did not understand correctly, then I am very worried about that clips idea.

Yes, everything is made into clips. But you really shouldn’t be worried, since clip functionality is completely transparent until you decide to register a clip. How would you ever be able to see an “old” song, if it wasn’t somehow interpreted as clips? IMO It’s just about making a good starting point.

> [@Icarus](#):
>
> Wouldnt
> 
> 1. make a clip for each pattern track which is not empty
> 2. divide (clone) each non empty pattern track clip into X parts if the X parts are equal
> 
> (X should be maybe simply be 4, but could also be dependent on the speed/pattern lenght)
> 
> not be enough and super simple?
> 
> Everything else should and could be IMHO done manually.

Yes, that’s very much like what I had in mind.  
This picture depict a song with four tracks, where each track has been divided into clips of varying length.  
Let’s say that first track is a beat, second track a bassline, third track a solo/synth thing, and the fourth track contains some percussion:  
  
Now, the beat in the first track will repeat over the course of two patterns, so it’s spanning both of them. The bassline, on the other hand, fit nicely inside a single pattern, so it’s repeated four times. For the synth/solo track, we never found any repeating pattern, so the entire synth track is made into a single clip. Finally, the percussion part is found to repeat two times per pattern, so that makes a total of 8 identical clips over the course of the song.

At least, this is what I had in mind. It’s not restricted to diving into (x) parts, results really depend on what’s going on inside each track.

---

<div class="post-metadata">

**Author:** ![Transcender](https://forum.renoise.com/letter_avatar/transcender/32/6_449c533f586939b6e5f246632a46421f.png) [@Transcender](https://forum.renoise.com/u/Transcender)\
**Post date:** [June 17, 2008, 2:43pm UTC](https://forum.renoise.com/t/xml-based-pattern-recognition/22440/5 "2008-06-17T14:43:01Z")

</div>

My preferred approach to the entire issue of clips would be to focus more on what happens at the actual (pre-)pattern cursor rather than what happens from the perspective of (post-)arranging data. As I see it, although I’m not a coder, clips would be best utilized by Renoise in idle mode, at the most CPU friendly stage: when manually entering data into the pattern.

I’d just add the xml tag XX or something that easy to the xrns structure, and let XX be the external clips referrer – i.e. which script to process the xml. All processing would then be done in post-mode via a button or menu item (e.g. “Render clip tags to static pattern data” or something like that).

I recorded a small .swf [video](http://www.sendspace.com/file/2pug86) ([alt](http://www.speedyshare.com/847425769.html) link) to better illustrate what I mean. The idea is simply to have an external script read (recognize?) the note(s) and value(s) 00-99 in the volume column, render the appropriate xml and then insert into the pattern. In this video, the script enters chords based on which rootkey value the user enters in the Renoise pattern row. Which type of chord to be formed is based on the (temporary) value in the volume column (10 is major, 20 is minor, etc).

---

<div class="post-metadata">

**Author:** ![danoise](https://forum.renoise.com/user_avatar/forum.renoise.com/danoise/32/64_2.png) [@danoise](https://forum.renoise.com/u/danoise)\
**Post date:** [June 17, 2008, 2:57pm UTC](https://forum.renoise.com/t/xml-based-pattern-recognition/22440/6 "2008-06-17T14:57:39Z")

</div>

> [@Transcender](#):
>
> As I see it, although I’m not a coder, clips would be best utilized by Renoise in idle mode, at the most CPU friendly stage: when manually entering data into the pattern.

Yes, that would make a lot of sense. So, which clips are picked out is based on pattern data, with the processing all happening in the background. To gain control of clips (instead of having them in this state of flux), you simply choose to register them.

---

<div class="post-metadata">

**Author:** ![dac514](https://forum.renoise.com/user_avatar/forum.renoise.com/dac514/32/100_2.png) [@dac514](https://forum.renoise.com/u/dac514)\
**Post date:** [June 17, 2008, 3:10pm UTC](https://forum.renoise.com/t/xml-based-pattern-recognition/22440/7 "2008-06-17T15:10:47Z")

</div>

I’m working on a [open source CMS](http://www.sux0r.org/) with one of the ideas being a Naive Bayesian classification system to substitute blog style “tagging.” Sourcecode for the base/parent Naive Bayesian class can be viewed [here.](http://sux0r.cvs.sourceforge.net/sux0r/sux0r2/includes/suxNaiveBayesian.php?view=log) This class works as follows:

> [@](#):
>
> A vector is a list of categories. You must have at least two categories in a vector to do Naive Bayesian classification.
> 
> For example, a vector named Feelings could have the categories Happy, Sad and Angry. A vector named Filter could have the categories Spam and Not-Spam.
> 
> In contrast, you wouldn’t put Spam in the Feelings vector because it doesn’t belong to that list of categories.

I’ve been holding my tongue and reading “identifying clips” for the last few weeks, wondering if Naive Bayes could be used here too? There could be a pre-trained data set, to identify basic patterns, and the user could train their own clips to supplement the categories and vectors.

This is all very theoretical, and would need to be complemented with non-bayesian results, but it would be cool to try?

The big challenge is Naive Bayes works well words / languages but I don’t know to begin translating it to identifying patterns and storing those as tokens.

---

<div class="post-metadata">

**Author:** ![danoise](https://forum.renoise.com/user_avatar/forum.renoise.com/danoise/32/64_2.png) [@danoise](https://forum.renoise.com/u/danoise)\
**Post date:** [June 19, 2008, 10:25am UTC](https://forum.renoise.com/t/xml-based-pattern-recognition/22440/8 "2008-06-19T10:25:59Z")

</div>

Thanks for inspiration. During my tour of the Naive Bayesian world I came across many interesting places, and [friendly creatures](http://www.convo.co.uk/x02/).

Now, while an actual implementation of such a principle might be overkill (after all, we’re not looking for probable matches, but actual matches), many aspects are still valid. Especially the way that the class starts by collecting information, and reducing it’s complexity / standardizing it, before any actual processing is done.

What I’ll do next is to try and define what we want to look for, based on what (I think) clips should be capable of.  
1: exact matches based on entered pattern data (varying length with max/min size boundaries).  
2: matches that are transposed versions of an original theme (but which one is the original?)  
3: combine extracted data with automation data (looking for automation envelopes should be optional)

---

<div class="post-metadata">

**Author:** ![dac514](https://forum.renoise.com/user_avatar/forum.renoise.com/dac514/32/100_2.png) [@dac514](https://forum.renoise.com/u/dac514)\
**Post date:** [June 19, 2008, 1:36pm UTC](https://forum.renoise.com/t/xml-based-pattern-recognition/22440/9 "2008-06-19T13:36:55Z")

</div>

> [@danoise](#):
>
> I came across many interesting places, and [friendly creatures](http://www.convo.co.uk/x02/).

Haha, that’s pretty cool.
