fractal sequencer
I just got a fuzzy idea about building a fractal sequencer. just wanted to see what kind of inputs people would have on this before i start.
i was thinking a normal sequencing window for writing a melody, and then some kind of midi processing where the melody gets stretched at different time scales (and maybe transposed too (if it should be real fractal every tone in the main melody should be build of the same melody in a smaller time scale and transposed and the same for the tones in that melody but i im not sure i want to make it that complex right now). There should then be controls for how many "layers" the melody should be repeated for, the duration of the melody and probably something else.
Anyone have any inputs or tips on how to go about this?
Thanks
the way you describe it already goes in the right direction; brake up things into smaller parts, then buiild module by module, plug-in by plug-in.
changing the tempo is [- ] to the clock and transposing the key is [+ ] to the note number.
so first build a clock, then a trigger, then see how you want to organize the modulation inputs.
i am not so sure if any "fractal" modulation actually contains iterations and "childs" (or how useful they are for generating meloldies), but one form of self-similarity is of course always contained.
a mixture of a henon attractor and a second modulator (which might be linear of repetive as well, like a calssic LFO) will provide you a wonderful source to generate thosands of different cadences out of a previosly repetive melody loop.
-110
thanks for the reply! im not exactly sure what you mean in the modulation part?
also how do i build a simple fractal melody generator if i want that instead of a manually written melody?
1. with modulation i mean the modulation of the original sequence.
2. you could start with a random-generated fixed melody - or use some live algorithm (such as the henon attractor mentioned above) and then truncate its floating point output to integers which then can be used as note numbers.
i believe that melodies between 5-8 notes work best for what you have in mind. but you should also try to use a whole group of 15 or so different fixed melodies, and then switch between them based on your whatever fractal algorithm.
Thanks!
You might want to check out Per Norgard's Infinity Series. It's an integer sequence that generates a series of numbers with fractal characteristics, i.e.. it displays self-similarity at various scales.
There are a few ways to calculate the series. I've attached on for you to try out. You input the index to the place in the series and the patch calculates the value of the series at that index. Try counting by fours, eights, etc. to see the self-similarity of the series (with some interesting variations. The series stays with a reasonable lower and upper bounds so you can easily map it to a scale of your choice.
Norgard used this series extensively in his symphonic and chamber works with really very beautiful results.
Best,
Kenneth.
UPDATE: the patcher I uploaded has a bug. Please use this one as it actually works. The previous one was spitting out intermediate products of the calculation as well as the correct integer at the selected index. This one is tested and working as designed.
It's late... but here it is.
BTW: Two Norgard works worth a listen that make significant use of the series are his 2nd Symphony and a chamber piece Voyage Into the Golden Screen.
You may want to check-out this: http://www.ohlife.it/index.php/musicians/15-max4life
It's a patch I wrote which produces music out of the famous "Conway's Game of Life" algorithm.
My main point is: we have an algorithm producing "generative" of "automated" music, but I would like to make it "playable" by a human musician through:
- the run-time tweaking of its parameters
- the real-time use of its MIDI output
- the use of effects on its audio output.
Actually you can see my patch as an external object (written in C) implementing the algorithm itself, surrounded by other stuff feeding it and manipulating its output.
Writing a similar external object implementing fractal algorithms should be relatively easy.
If you are interested, my patch is available, and I would be glad to elaborate.
Nicola
i would like to add that the use of pure integer serialism makes a "valid" "fractal approach, but fractals with a pure integer number of dimensions are a special case of fractals only.
so this means that you miss 99% of the fun.
on the one hand pure integer fits very well to musical events and makes it easy to contruct or generate something useful.
on the other hand the result is very predictable and very repetitive.
if you want to know how different the melodies will sound, google for a picture of a lame sierpinski figure and compare it against the beauty of mandelbrot renderings. :)
Thanks for the replies! Will check out Per Nørgaard. And he's danish too. Would be glad to see your patch Nicola. I actually just bought Eric lyons book about writing externals so i might look into that.
Im fine with it being very simpel melodies so pure intiger fractals is good for now
Kenneth the patch you attached is very close to what i want to make. Where i can just input numbers from 1-16 or more and it outputs a series. Do you know of anything more like this? Doesn't have to be a patch, maybe just a simple basic concept i could read about?
actually the perfect melody producing algorithm for me would have "index" (1,2...), "variation" (1,2... which produces a different series) and range (1,2... which defines how many notes the melody has)
that sounds like a good plan.
and to recieve something really organic you could allow a bit of variance/random whenever a new child or loop starts.
i.e. you can put something like "transpose for 3 halftones, or for 5 halftones with a chance of 10%" for every iteration or the major branch.
Thats a good idea, but first i need to figure out how to make the basics. Any idea? L-systems? The variations should contain all possible variations of a melody with the given note range
... and the given index range probably. So first the duration and note range of the melody is defined, and then all possible melodies can be selected when feeding the "variation" parameter a number. It should probably also include variations with 0's (non played notes).
And then i will look into the fractal sequencer part afterwards.
MK, here is my patch, including the new external object and some associated JS. Hope you like it and you find it of some interest regarding your idea. You might want to follow the suggestions I give here: http://www.ohlife.it/index.php/musicians/15-max4life
Here is a post about the Project: https://cycling74.com/project/chasing-life-on-max/#.Vy4OPhV96WY
And here some audio examples: https://soundcloud.com/ndebello
Please note that I am currently trying to submit it as a Mac Standalone in the Mac AppStore: the binary itself has already been approved, bit I got it rejected because of some "File Menu" issues I am trying to solve right now.
Nicola
the method (and terminus) of "fractal" once was used to build extremly complex things (animated geometric figures) based on quite simple formulas.
so any approach to use the same method now in order to create something very simple (a melody?) is ... a bit crazy.
for a quick start you could run some integer series to learn how to tame them to become musically interesting data.
i wouldnt call the results "fractal", simply because there is the (older) terminology of "serialism" in music. but it is statistically very close.
I associated a completely arbitrary and self-devised way to generate notes to the famous Conway's Game of Life algorithm, and I am currently trying to do the same with the Flocking algorithm.
In the case of Game of Life the result turned out to be very musical and very playable, at least in my humble opinion.
I guess that in the case of a fractal formula the only important points would be (again): how to associate note-on events and note-off events, and how to "extract" some playable parameters aimed to be tweaked in real-time.
Just my 2 cents...
Nicola
Roman im not thinking the melody should be fractal. That part was just the simple idea of playing the melody in layers at different durations and transposes. But i would like to have a melody generator where you choose duration and note range and then all possible outcomes is available. The outcoming notes can be assigned to a scale afterwards to make it more musical. I'll try to figure it out, but if you have an idea on how to do it, please let me know
here is my old thue/morse sequence style generator.
it allows you to convert the index input (1, 2, 3,...) to its binary, tertiary,... representation, then counts how often a certain digit is contained in this number and outputs it as the result.
6 (decimal) --> 110 (binary) --> contains the digit 1 how often: 2
6 (decimal) --> 20 (tertiary) --> contains the digit 1 how often: 0
6 (decimal) --> 20 (tertiary) --> contains the digit 2 how often: 1
feel free to count the index backwards... or only in multiples of 3.
:)
-110
but parts of the ruleset which generates the melody should be fractal, isn t it? and that is absolutely enough to complete the task.
a tree also contains "green", "bigger than my car", "inhabitated by 1000 bugs and a bird" - and not only statistical similarities with a formula describing how its leaves and shoots grow in termins of size, angel and position.
-110
stuff like this is very useful, too, but difficult to manage in realtime situations.
https://oeis.org/A038574 "Write n in ternary, sort digits into increasing order. "
series performing a modulo operation at the end are useful for deterministic tasks such as changing the instrument or transposing for one octave:
If the variations parametre inhabits all possible outcomes, some of the outcomes will have fractal characteristics i guess.
I think i know what you mean. When i combine enough of these simple systems/parts the result hopefully ends up being interesting but neither organic or too simplistic.
I dont get the link you send
exactly.
when using algorithms, never forget that you are the composer and the algorithm is only a tool.
you have the constitutional right to tweka the result to your liking.
-110
I still have no idea how to actually make it though...
too many options?
Just not familiar enough with max to know how to go about it. I know what it should do
I think its the variations part. How to choose the possible outcomes from the set duration and note range, which a single integer
i mean, note range (how many notes the melody should consist of, from 1 to 12 or maybe more) should be controlled by a integer and duration (how long the series is) should be controlled by an integer and variation, which is the hard part i think, should be controlled by an integer. So if the note range is 3 and the duration is 4, two variations could be [1, 2, 3, 1] and [1, 1, 2, 3] for example
and [0, 1, 3, 0] would be a variation too, if 0's (non played notes) is included too
and now build a patch which does that.
the trick is to just start patching.
Hi M.K.,
Everything you asked for in your first post here is included in that patch. Do a close reading of the details on Norgard's practice on the link I provided. Here it is again: http://www.pernoergaard.dk/eng/ideer/hierarkisk.html
In that first post you referred to the fractal qualities of self-similarity (the pattern is contained with a pattern is contained within a pattern..... ) and scale invariance (the pattern appears at different levels of scale). The infinity sequence you can generate with the patch I posted gives you both of those. Accessing these features of the sequence is as simple as counting. The basic, and most simple, way of using the patch is to simply feed it the output of a counter: 0 1 2 3 4 . . . This will generate, as output, the infinity sequence. Embedded in that sequence are the self similarity and scale invariance characteristics. On examination the sequence reveals repeated versions of itself in both its original and inverted forms as well as transposed. One way to start exploring this is to enter a sequence of integers to the inlet of the patch that count by 4 or 16 or 64 or... you see the pattern. To count by 4s, multiply the output of a counter by 4, to count by 16s multiply the counter's output by 16, etc. To combine these as layers of a musical flow use separate infinityseriesvalue objects for each thread of the musical fabric, feeding them the appropriate integer count at the appropriate time. This gives you the classical variations of inversion and transposition. Count backwards through the series and you get retrograde and retrograde inversion. Work with subsets of the series that you find interesting as melodic figures or themes and repeat them with variations and in counterpoint with other figures/themes derived from the series. There's so much to explore and discover there.
Another, by now canonic, example of a musical fractal is 1/f noise. It turns out that music exhibits a similar 1/f distribution in several of its dimensions, pitch contour, rhythmic quality, loudness variations in performances, etc.
See this article from Scientific American that introduced the idea to the wider public back in the 80's.
The algorithm for generating a sequence of numbers that exhibit a 1/f that Gardner shared with us is interesting. It's based on a hierarchical ordering of random values at several levels of scale (sound familiar?). And, it's a similar to Ken Perlin's original approach to generating fractal noise for use in procedural computer graphics.
Then there's the fractal form of the harmonic series to play with in terms of melodic construction and harmonic function... but that's another story. Check out the Table of Pythagoras, Harry Partch's Genesis of a Music.
Enjoy!
Kenneth.
I wrote an external in C, and a very trivial patch around it. The external runs the classic Mandelbrot formula, and outputs:
col, row, and a value which is equal to maxColors % iteration
The inputs are self-explained in the patch.
Is there somebody more skilled than me in Max graphics willing to add the drawing part, including mapping those values to a color palette?
Please note that so far the object outputs 0 if "black" must be painted.
I was wandering if changing it to -1 or whatever...
Of course all the usual "zooming" stuff is missing so far, but it's just to give it a try...
After that, I (we) can devise some kind of (layered) notes production, if you folks think that is of some interest.
Nicola
roman, sorry if this is a stupid question but how can i recreate your thue morse sequencer so it outputs more values than 0 and 1? 4 values for instance 0, 1, 2, 3
it does that; it is the "system" parameter. supports up to 9.
originallly planned up to hexadecimal, but then you´d run out of outlets one day. :)
watch out that the"focus" is not set to a bigger value than the "system". auto limiting this numberbox is missing in this version (i once lost tons of updated bpatchers)
big fun is when you let several of them control each other instead of using a counter.
also try out what happens when you do * 95 to the counter input and things like that.
>>Is there somebody more skilled than me in Max graphics willing to add the drawing part
nicola can you provide me some quasi-code for the formula? i always wanted to have a mandelbrot generator (as max patch), but failed interpreting what i found about how it works. :)
Roman, I would be glad to share. But let me share also some other things. First of all, I deserve no credit for the Mandelbrot formula psuedo-code! i got it form here: http://jonisalonen.com/2013/lets-draw-the-mandelbrot-set/, so the credits go to them!
Here it is:
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
double c_re = (col - width/2.0)*4.0/width;
double c_im = (row - height/2.0)*4.0/width;
double x = 0, y = 0;
int iteration = 0;
while (x*x+y*y
I just implemented (in C Language) a first version coming directly from the pseudo-code above, I added some inlets and outlets management, and got the "fractalc.mxo" external I attached to my previous post.
But I noticed that this code is very heavy on the performance side if I simply BANG it to run as it is (with a single BANG), so I devised a new solution.
I developed a new version in which I BANG it continuously using the Global Transport and the "metro" object, but of course I let it run (each time) only for a pre-selected (configurable) number of "row" and "col" iterations. Here is my piece of code:
int maxColors;
int row, col, height, width, maxIter, step, retIter;
double x_new, c_re, c_im;
iterQuantum = myQuantum;
maxColors = myColors;
maxIter = myIterations;
height = myHeight;
width = myWidth;
step = myStep;
while (glRow < height) {
while (glCol < width) {
c_re = (glCol - width/(step/2))*step/width;
c_im = (glRow - height/(step/2))*step/width;
retIter = game(x,c_re,c_im,step,maxIter);
if (retIter < maxIter) myintout123(x, glCol, glRow, (maxColors % retIter));
else myintout123(x, glCol, glRow, 0);
glCol++;
if (((glCol % iterQuantum) == 0) || (glCol == width)) { if (glCol == width) glCol = 0; break; }
}
glRow++;
if (((glRow % iterQuantum) == 0) || (glRow == height)) { if (glRow == height) glRow = 0; break; }
}
Please note that:
- glRow and glCol are global
- all the variables named "mySOMETHING" come from the inlets
- the game() function contains the remaining "while" cycle you can find in the pseudo-code above
I will post the new versions as soon as I manage to (kind of) complete them.
Nicola
after i asked yesterdasy i googled again for it (which i didnt do for some 8 years) and actually found a few.
and i noticed that the main issue is probably that i am trying to "generalize" the method which was originally made for 2d graphics while understanding and coding it at the same time.
what i am trying to say is this: i would like to avoid to start with a plotted graphics version, as i feel that this means coding 90% stuff which i have to remove later anyway (when my aim will be note numbers, modulation signals, or lists of ASCII...)
maybe my approach is wrong?
would be great if you could create a simple model as max code using only basic max objects. or eventually this does not make sense at all, we will see. :)
btw my other problem with these things is to work with complex numbers in max. mainly because i dont really understand them anyway. i will only understand them when i see the finished code and i can code this stuff only if i understand complex numbers.
}
if (iteration < max) putpixel(col, row, colors[iterations]);
else putpixel(col, row, black);
}
}
in my context (composition) i would not renver black but just send out a "finished" flag (usually a bang at an extra outlet) when the max number of iterations is done.
this, and that i have to set up a few numbers at the beginning (a constant of 0 for the start, and two variables one of range -1 1 and one of range 0 2.5 or so) are the only two things i understand in the mandelbrot and julia algos i find online.
if unavoidable i will not exclude the use of matrixes (...jitter 1.3)
"step" in second example means that you offer the user to jump to somewhere insetad of counting linear?
Roman wrote:
> "step" in second example means that you offer the user to jump to somewhere insetad of counting linear?
If your question refers to something you could change in real-time, the answer is NO. So far it is simply a coefficient included in the formula that becomes a configurable initial parameter.
Nicola
Roman wrote:
> in my context (composition) i would not renver black but just send out
> a "finished" flag (usually a bang at an extra outlet) when the max
> number of iterations is done.
That's my approach too. Those two lines of code are simply the "original" ones drawing the points of the Mandelbrot set in a certain color.
The REAL and MAIN point (in my opinion) is actually how to relate them to the production of MIDI notes events.
Nicola
Roman wrote:
> maybe my approach is wrong?
>
> would be great if you could create a simple model as max code
> using only basic max objects. or eventually this does not make
> sense at all, we will see. :)
Not at all. The graphical part is simply a nice visualisation of the VERY "rules" that are actually playing the notes.
One interesting reason to use it (in my opinion): playing alive. It is a great add-on for an audience, if put on a big screen for example.
Nicola