melody, inverse and permutation
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
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.
I don't have the [vs.between] abstraction/external, could you post/link to it?
lh
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:
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
}
//+ Jonas Raoni Soares Silva
//@ http://jsfromhell.com/array/permute [rev. #1]
//adapted for Max/MSP use
hth,
l.
Hi.
You might want to try bach ( www.bachproject.net ), a library of objects and patches for algorithmic composition. There are several tutorials dealing with melodics transformations.
best
aa
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.