Forums > MaxMSP

melody, inverse and permutation

October 6, 2010 | 2:26 pm

Hi,

I’m trying to experiment with random melody creation, so I built a very very simple patch to create a melody and replay it as it was, inverted and permutated. I have two things not clear in my mind:
1) is there a way to make it simpler? i mean… it works but it looks complicated to me, no?
2) i don’t know why when playing computer MIDI instr it works, but if i send those messages to an external sampler inverse and permutated play on channel 16. always.

Any idea?
thanks

– Pasted Max Patch, click to expand. –

October 6, 2010 | 4:21 pm

i cant look at max5 code, but this seems a lot of code for inversion … something
like [map 60 72 72 60] should perform a (very simple) melody inversion already.


October 6, 2010 | 9:10 pm

I don’t have the [vs.between] abstraction/external, could you post/link to it?

lh


October 6, 2010 | 10:21 pm

ops, here it is.

Attachments:
  1. vs.between.pat

March 20, 2011 | 8:29 am

hi,
you probably found your way already, but i wanted to do similar things and found a little snippet of code online and put in a js object. maybe helpful?

patch:

– Pasted Max Patch, click to expand. –

code for js:
var arr = new Array();
var output = new Array();

permute = function(v, m){
for(var p = -1, j, k, f, r, l = v.length, q = 1, i = l + 1; –i; q *= i);
for(x = [new Array(l), new Array(l), new Array(l), new Array(l)], j = q, k = l + 1, i = -1;
++i < l; x[2][i] = i, x[1][i] = x[0][i] = j /= --k);
for(r = new Array(q); ++p < q;)
for(r[p] = new Array(l), i = -1; ++i < l; !--x[1][i] && (x[1][i] = x[0][i],
x[2][i] = (x[2][i] + 1) % l), r[p][i] = m ? x[3][i] : v[x[3][i]])
for(x[3][i] = x[2][i], f = 0; !f; f = !f)
for(j = i; j; x[3][--j] == x[2][i] && (x[3][i] = x[2][i] = (x[2][i] + 1) % l, f = 1));
return r;
};

function list(){
arr = permute( arrayfromargs(arguments), 0);
for(i=0;i


March 20, 2011 | 9:41 am

Hi.
You might want to try bach ( http://www.bachproject.net ), a library of objects and patches for algorithmic composition. There are several tutorials dealing with melodics transformations.

best
aa


March 20, 2011 | 6:14 pm

Hi,

I just had a look, didn’t know about it. Nice work!
Since a while I’m using FTM a lot, doesn’t seem to integrate nicely though, because of several reasons (data issues, ftm_object doesn’t go through unharmed). But it implements lots of things I would like to have at my disposal in FTM, so I’ll probably use it for these little things that you wanna do sometimes (like calculating all permutations of a series of five notes, see the above).

Thanks,

l.


Viewing 7 posts - 1 through 7 (of 7 total)