Author |
Message |
PHOBoS
Joined: Jan 14, 2010 Posts: 5591 Location: Moon Base
Audio files: 705
|
Posted: Sun Jan 13, 2019 3:10 pm Post subject:
Conway's Game of Life Subject description: and other cellular automata |
|
|
IT'S ALIVE!
I thought it would be nice to have a general thread to discuss how cellular automata can be used for music and how to create them.
In case you have no idea what I am talking about:
"A cellular automaton consists of a regular grid of cells, each in one of a finite number of states, such as on and off (in contrast to a
coupled map lattice). The grid can be in any finite number of dimensions. For each cell, a set of cells called its neighborhood is defined
relative to the specified cell. An initial state (time t = 0) is selected by assigning a state for each cell. A new generation is created
(advancing t by 1), according to some fixed rule (generally, a mathematical function) that determines the new state of each cell in
terms of the current state of the cell and the states of the cells in its neighborhood." - source: wikipedia
The most well known cellular automaton is probably Conway's Game Of Life. I don't remember when I first came across it
but I have always been intrigued by it. The rule set if very simple:
1. Any live cell with fewer than two live neighbors dies, as if by underpopulation.
2. Any live cell with two or three live neighbors lives on to the next generation.
3. Any live cell with more than three live neighbors dies, as if by overpopulation.
4. Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction.
Despite these simple rules it is capable of creating very complex patterns. The most basic ones die out or end in a stable state but
there are also patterns that oscillate, move across the grid, clone themselves or birth new patterns, reflect or destroy and a whole lot
more. If you want to see some amazing examples go visit the conwaylife forum.
It can also create some nice psychedelic patterns by bending the rules a bit: https://www.youtube.com/watch?v=XVVyjIbypwM
or how about a clock: https://www.youtube.com/watch?v=3NDAZ5g4EuU
I haven't really looked into what is available when it comes to creating music but I know there is a Game of Life module for wren.
And here's a trigger sequencer based on life: https://www.youtube.com/watch?v=rErT5oEnW5M
So it can be used to create trigger signals and you could use it to create midi data or control voltages but maybe there are other interesting
possibilities. I was thinking that it would also be nice to just use it as a visualizer responding to music. Again this could be done with midi,
triggers, or cv's, maybe something similar to a spectrum analyzer based on frequencies.
Game of Life isn't the only automaton of course and you can create all kinds of rule sets with different results, you can also add dimensions
or use different shaped grids. For those who like to simulate logic circuits there is wireworld. _________________ "My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube |
|
Back to top
|
|
|
blue hell
Site Admin
Joined: Apr 03, 2004 Posts: 24079 Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320
|
Posted: Sun Jan 13, 2019 4:04 pm Post subject:
|
|
|
good idea pho .. I've fixed the Wren link BTW to www.bluehell.nl (instead of bluehell.electro-music.com).
The wren version makes sequences on the green outputs as well as control values on the blue outputs.
Do you only want game of life stuff here or other cellular autmatons too? _________________ Jan
also .. could someone please turn down the thermostat a bit.
|
|
Back to top
|
|
|
PHOBoS
Joined: Jan 14, 2010 Posts: 5591 Location: Moon Base
Audio files: 705
|
|
Back to top
|
|
|
PHOBoS
Joined: Jan 14, 2010 Posts: 5591 Location: Moon Base
Audio files: 705
|
Posted: Sun Jan 13, 2019 7:56 pm Post subject:
|
|
|
* this is probably going to be one of those long posts that hardly anyone understands or cares to read, but I'll give it a try *
One reason I started this thread is of course because I'd like to make a hardware version of Conway's Game of Life. It's been brewing in the
back of my mind for a while and I couldn't resist any longer. The most efficient way of doing it is with a microprocessor and I'll probably do that
but I was curious what it would take to make it without one. The idea is to make single cells with 8 inputs and 1 output that can be linked together.
Initially I thought of using logic chips, it is afterall just 0's and 1's. Synchronization is easy to do with a latch before the output so all cells can be
clocked from a single source, although it could also be interesting to make an asynchronous version so each cell has a build in oscillator with a
different frequency. However, decoding the 8 inputs is not that easy or at least takes quite some logic gates to accomplish. I did figure out a way
to do it with some adders and also found some similar circuits here. Another way would be to use some logic gates to link a couple of muxes together
which gives the option of changing the rule set. You need a lot more than 1 cell to actually make it useful though so the circuit should be very small
and that's just not going to work with pure digital logic.
There is another way that I had been thinking about which is analog. The hardest part to do digital is to determine how many inputs are high
for which you need a majority gate. Analog this is quite easy to make with a resistor network and a comparator or in this case 3 of them.
So that's what I did and I came up with a working circuit
Version 1 was the first working idea and version 2 is a further developed even smaller one but the input section is the same on both. The 8 inputs
(from neighboring cells) are each connected to a resistor network that forms a voltage divider with a 9th resistor to GND. I initially added this resistor
because I was thinking of using diodes on the inputs but it turned out to be very useful when calculating the appropriate resistor values. For every
input that is high the output voltage of this network rises by 1/9 * V. With all the inputs low the output is 0/9 * V, with 1 input high it is 1/9 * V,
with 2 inputs high it is 2/9 * V, etc all the way up to 8/9 * V. (The circuit is designed for signal voltages that are the same as the supply voltage 'V'
but since it is all about ratios the actual value of this voltage doesn't really matter)
I slightly rewrote the rules (but they function the same) which translates into 4 useful voltages:
< 2/9 * V: Any cell with fewer than two live neighbors dies.
= 2/9 * V: Any cell with two live neighbors doesn't change state (lives on, or stays dead)
= 3/9 * V: Any cell with three live neighbors lives (lives on, or becomes a live cell)
> 3/9 * V: Any cell with more than three live neighbors dies.
3 comparators are needed to turn these 4 voltages into useful (digital) signals.
These are configured in such a way that the treshold levels lie exactly between 2 of the voltages for reliable triggering.
the first comparator (U1d) triggers when the voltage is between 1/9 and 2/9, which is 3/18 * V
the second comparator (U1c) triggers when the voltage is between 2/9 and 3/9 which is 5/18 * V
the third comparator (U1b) triggers when the voltage is between 3/9 and 4/9 which is 7/18 * V
just for "fun" let's use a voltage of 5V
0 inputs high 0/9 * 5 = 0V
1 input high: 1/9 * 5 = 0.56V
- first comparator triggers at 3/18 * 5 = 0.83V
2 inputs high: 2/9 * 5 = 1:11V
- second comparator triggers at 5/18 * 5 = 1.39V
3 inputs high: 3/9 * 5 = 1.66V
- third comparator triggers at 7/18 * 5 = 1.94V
4 inputs high: 4/9 * 5 = 2.22V
5 inputs high: 5/9 * 5 = 2.78V
....
To create the correct voltages for the treshold levels the resistors need to have a ratio of 3/18, 2/18, 2/18, 11/18,
which is very convenient because the E24 series contains resistors of 30K, 20K and 110K (33K, 22K, 120K should also work fine)
This results in the following bits (for version 1):
- less than 2 live neighbors: 000
- exactly 2 live neighbors: 001
- exaclty 3 live neighbors: 011
- more than 3 live neighbors: 111
All that's left is to translate these signals to a 0 or 1 according to the rules and my first idea was to use a mux for this:
000 -> 0
001 -> depends on the current state so the output of the cell is fed back into this input of the mux.
011 -> 1
111 -> 0
The output of the mux is then fed into a latch so that a new state appears on every low to high clk transition. Because it is important
that the output stays as close to the supply voltage as possible I connected the LED to the /Q output so that it doesn't cause a voltage
drop on the Q output. (The LED goes on when /Q is 0). Using a transistor as a buffer would be a nicer solution but I tried to keep the
component count as low as possible.
Although version 1 works I couldn't shake the feeling that there might be a way to do it without the mux, maybe by using the spare latch
and/or comparator.
I had to bend my mind a bit but today I figured it out
Note that for version 2 the inputs of the 3rd comparator are swapped which results in:
- less than 2 live neighbors: 100
- exactly 2 live neighbors: 101
- exaclty 3 live neighbors: 111
- more than 3 live neighbors: 011
however, this isn't really true as the comparators have an open collector output, so it's actually:
- less than 2 live neighbors: X00
- exactly 2 live neighbors: X0X
- exaclty 3 live neighbors: XXX
- more than 3 live neighbors: 0XX
(X is a floating state)
A nice thing with open collector outputs is that you can connect them together without shorting the outputs. Comparators 1 and 3 are directly
connected together and with the pullup resistor and diode on the output of comparator 2 this results in the following states:
- less than 2 live neighbors: 0
- exactly 2 live neighbors: X
- exaclty 3 live neighbors: 1
- more than 3 live neighbors: 0
The output from the cell is also connected to this point through a resistor so when the output of comparators 1 or 3 is low it is pulled to GND
and when the output is floating (exactly 2 live neighbors) it is whatever the current output state is. When it is pulled high by the resistor on
the output of comparator 2 it forms a voltage divider with the resistor feeding back from the output which results in a level between 0 and 1
if the output is low. This is why the extra comparator (U1a) is used. The output of this comparator is connected to the latch as in version 1.
but wait there is more,..
Because there was still an unused latch I wondered if it could be used to make a switch that can toggle the cell between dead or alive with
a single button for programming the initial state. The idea being that you could make cells with illuminated push buttons. This got a little bit
more complicated than I hoped because the latch remains in the last state it was set and doesn't follow the output. So if the last state was 0
and the ouput of the cell is 0 nothing happens, neither would it work if both are 1. To solve this I added 2 AND gates made with diode logic.
In practise it is still not efficient because you need quite a lot of cells and its use is very limited compared to what you can do with a microprocessor.
The costs can also go up pretty fast. I think a cell might be doable for about 2,- maybe a bit more with a dedicated PCB although those can be pretty
cheap when kept small and this would be a nice circuit for SMD components. But with a 8x8 matrix this already adds up to 128,- (without fancy
illuminated buttons) compared to say an arduino with an 8x8 led matrix which could be done for < 5,- which is also a lot smaller. Not to mention that
so far it only lights up some LEDs so if you want to use it for music you need some extra circuitry.
I am still a bit tempted to create a very small matrix though but I am not sure yet how to connect cells together without using jumper wires,
I think you'd need some sort of octagon or circular shape, on the other hand jumper wires might look nice (but it needs a lot).
Of course you could also make cells with a single microprocessor each or even better the kits that adafruit sells which can be linked and each have
a 4x4 matrix. This also solves the problem of how to connect them without jumper wires. But in the end a single microprocessor will be the most
efficient and versatile option. I do have another idea though which I might actually be able to build and doesn't require a microprocessor but I
need to bend my mind a bit further to figure out if it is possible.
TL;DR I designed a circuit for Conway's Game of Life cells which can be linked together and now I need a cup of tea.
Description: |
|
Filesize: |
70.88 KB |
Viewed: |
649 Time(s) |
This image has been reduced to fit the page. Click on it to enlarge. |
|
Description: |
|
Filesize: |
69.95 KB |
Viewed: |
673 Time(s) |
This image has been reduced to fit the page. Click on it to enlarge. |
|
_________________ "My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube |
|
Back to top
|
|
|
Grumble
Joined: Nov 23, 2015 Posts: 1294 Location: Netherlands
Audio files: 30
|
Posted: Mon Jan 14, 2019 12:27 am Post subject:
|
|
|
Really nice idea!
I have been pondering about something similar for quite some time now, but mostly the ideas didn't work out, but I'm still playing with the idea of having a melodic sequence that is more or less defined by the preceding chord(s) added with some form of randomness.
Like HERE _________________ my synth |
|
Back to top
|
|
|
blue hell
Site Admin
Joined: Apr 03, 2004 Posts: 24079 Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320
|
Posted: Mon Jan 14, 2019 12:39 am Post subject:
|
|
|
Brilliant .. heh .. and now I'm late for work _________________ Jan
also .. could someone please turn down the thermostat a bit.
|
|
Back to top
|
|
|
PHOBoS
Joined: Jan 14, 2010 Posts: 5591 Location: Moon Base
Audio files: 705
|
Posted: Mon Jan 14, 2019 8:52 am Post subject:
|
|
|
@Grumble
interesting, I hadn't seen that thread. I only read the first post sofar but I think I understand what you are trying to do.
Very similar to something I'd like to do which is have something create semi-random melodies that actually sound musical
based on a set of rules (I see how it ties in with this). Instead of something simple like the game of life the new note(s)
would be based on several previous iterations instead of just the last one. It would probably also require some sort of repetition.
The rules would be based on musical theory which is where I'd get stuck at the moment as I don't know enough of it.
If I did I would actually know what keys to press when jamming In that regard it reminds of making a cheat sheet for
a school test (which I never did of couse) where you learn by creating it so that you don't actualy need it anymore once finished.
One of the things I would love to do is my own (automated) interpretation of Crater Dust.
It would also be nice to do this with a couple of people where everyone creates a patch or system that plays it and they all
get mixed together live. You could even send something like midi data over the internet so they can somewhat communicate
with eachother.
@Blue Hell
Thanks for taking the time to read, I hope there was something inspiring in there
Another interesting video I recently watched (which might have been responsible for getting back into this)
is this one from numberphile https://www.youtube.com/watch?v=_UtCli1SgjI
I love the pattern created by the the Fredkin Replicator (starting at 14:10) _________________ "My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube |
|
Back to top
|
|
|
Grumble
Joined: Nov 23, 2015 Posts: 1294 Location: Netherlands
Audio files: 30
|
|
Back to top
|
|
|
elmegil
Joined: Mar 20, 2012 Posts: 2177 Location: Chicago
Audio files: 16
|
|
Back to top
|
|
|
PHOBoS
Joined: Jan 14, 2010 Posts: 5591 Location: Moon Base
Audio files: 705
|
Posted: Mon Jan 14, 2019 12:47 pm Post subject:
|
|
|
interesting,that will come in useful some day
ah that is similar to this one but with a slighly different ruleset.
would love to see your notes if you figure out where somewhere is. Last edited by PHOBoS on Mon Jan 14, 2019 12:50 pm; edited 1 time in total |
|
Back to top
|
|
|
elmegil
Joined: Mar 20, 2012 Posts: 2177 Location: Chicago
Audio files: 16
|
Posted: Mon Jan 14, 2019 12:50 pm Post subject:
|
|
|
It never got implemented, so.... notes are probably worth what they're written on |
|
Back to top
|
|
|
Grumble
Joined: Nov 23, 2015 Posts: 1294 Location: Netherlands
Audio files: 30
|
Posted: Mon Jan 14, 2019 2:19 pm Post subject:
|
|
|
On ‘the other side’ is a thread going on about self generating patches might be interresting to read _________________ my synth |
|
Back to top
|
|
|
PHOBoS
Joined: Jan 14, 2010 Posts: 5591 Location: Moon Base
Audio files: 705
|
|
Back to top
|
|
|
PHOBoS
Joined: Jan 14, 2010 Posts: 5591 Location: Moon Base
Audio files: 705
|
|
Back to top
|
|
|
Grumble
Joined: Nov 23, 2015 Posts: 1294 Location: Netherlands
Audio files: 30
|
Posted: Tue Jan 15, 2019 3:11 pm Post subject:
|
|
|
nice! maybe usable for a crater dust just have three of these running independently from eachother _________________ my synth |
|
Back to top
|
|
|
MapacheRaper
Joined: Feb 15, 2018 Posts: 166 Location: Spain
|
Posted: Tue Jan 15, 2019 7:33 pm Post subject:
|
|
|
|
|
Back to top
|
|
|
RingMad
Joined: Jan 15, 2011 Posts: 427 Location: Montreal, Canada
Audio files: 4
|
Posted: Thu Jan 17, 2019 5:25 am Post subject:
|
|
|
Great stuff!
I have been fascinated with this cellular automata and cybernetics stuff for years, although I never really understood it much. I like the idea of a "living" circuit that could generate music by itself. In fact, I see Lunettas a bit like that... even though they are based on logic circuits (which also fascinate me), one can have complex patterns.
(pure randomness is not very interesting musically, a certain amount of repetition and variation is)
A couple of years ago I was sketching some ideas using a network of 3-input logic gates made with the 4051 LUT circuit (also discovered by JingleJoe as the 4051 ANY gate), and triangles and vertices of platonic solids. But then I realized that the system was fixed and would produce no variation ever, so I abandoned the whole thing.
There was a simple XOR chain circuit that I used in a Lunetta thing. It was by "ezekiel" over on the former The Sound of Logic forum, and it apparently implemented Wolfram Rule 90 C.A. That's the closest I got and ever will get to implementing any C.A. stuff.
But I will enjoy seeing/hearing what you people come up with.
.:james:. |
|
Back to top
|
|
|
Grumble
Joined: Nov 23, 2015 Posts: 1294 Location: Netherlands
Audio files: 30
|
Posted: Thu Jan 17, 2019 7:59 am Post subject:
|
|
|
PhoBos wrote: | The rules would be based on musical theory which is where I'd get stuck at the moment as I don't know enough of it. |
I have just the thing for you!
Description: |
|
Download |
Filename: |
music-composition-for-dummies.pdf |
Filesize: |
7.78 MB |
Downloaded: |
548 Time(s) |
Description: |
|
Download |
Filename: |
music-theory-for-dummies.pdf |
Filesize: |
7.87 MB |
Downloaded: |
10525 Time(s) |
_________________ my synth |
|
Back to top
|
|
|
PHOBoS
Joined: Jan 14, 2010 Posts: 5591 Location: Moon Base
Audio files: 705
|
Posted: Thu Jan 17, 2019 8:12 am Post subject:
|
|
|
yeah it can be tricky to find a nice balance between pure random and structured. I guess the mind likes patterns but also surprises.
When I make music on a computer I often try to add variations between every measure. Not so much that it's all over the place
but just enough to keep it interesting without being too prominent.
Quote: | I like the idea of a "living" circuit that could generate music by itself | .
If you take the "living" part a bit too literal you'll end up with cellF
thanks for the PDF's Grumble! I'll check it out. _________________ "My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube |
|
Back to top
|
|
|
PHOBoS
Joined: Jan 14, 2010 Posts: 5591 Location: Moon Base
Audio files: 705
|
Posted: Fri Feb 01, 2019 9:02 am Post subject:
|
|
|
PHOBoS wrote: | I do have another idea though which I might actually be able to build and doesn't require a microprocessor but I
need to bend my mind a bit further to figure out if it is possible. |
This other idea was using an EPROM since I now have a lot of those (thanks jan )
Decoding the inputs to the appropriate output state according to the game of life rules is easy to do, it's pretty much just the data from "Life in Gray".
What I wondered about is if I could also put the latch function in it by feeding back some data outputs to the address inputs. Does that work ?
Well, yes and no. I did some experiments and kept getting some weird oscillations. Initially I thought I might have made an error somewhere and had
two addresses pointing to eachother but that wasn't the case. I am not exactly sure what causes it but I though it might have something to do with the
slew rate of the outputs which causes the input to get a state between 0 and 1. So I tested with putting some schmitt triggers between the outputs and
inputs and that did indeed get rid of the oscillations. However the idea was using just an EPROM without any need for an extra chip so if I need some schmitt
triggers I might aswell just use a latch instead. I tested this aswell and that works fine but needing an EPROM and a latch per cell does get a bit too silly.
I think I should be able to do 4 cells with a single 512Kb EPROM though and I do have a bunch of octal latches aswell (thanks jan ). Of course you still
need a lot of them but maybe someday I design some PCB's and actually build it as some sort of art project.
For now I switched to an arduino and an 8x8 LED matrix. I did some tests with it creating simple midi note on/off signals and the next thing I want
to add is a midi input. The idea being to have some sort of game of life based arpeggiator where you play some notes and it generates new notes from
it. I am not sure yet how to implement it as you need a couple of cells to be turned on that are next to eachother otherwise they just die out. I guess
I could have it generate different 'sprites' for each note. _________________ "My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube |
|
Back to top
|
|
|
blue hell
Site Admin
Joined: Apr 03, 2004 Posts: 24079 Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320
|
Posted: Fri Feb 01, 2019 10:44 am Post subject:
|
|
|
Ah good to see that stuff being used :-) _________________ Jan
also .. could someone please turn down the thermostat a bit.
|
|
Back to top
|
|
|
PHOBoS
Joined: Jan 14, 2010 Posts: 5591 Location: Moon Base
Audio files: 705
|
|
Back to top
|
|
|
Grumble
Joined: Nov 23, 2015 Posts: 1294 Location: Netherlands
Audio files: 30
|
Posted: Fri Feb 01, 2019 12:43 pm Post subject:
|
|
|
wow! that last video, amazing _________________ my synth |
|
Back to top
|
|
|
blue hell
Site Admin
Joined: Apr 03, 2004 Posts: 24079 Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320
|
Posted: Fri Feb 01, 2019 3:45 pm Post subject:
|
|
|
What I've found useful additions for generating music :
- add a fault rate, every so often flip the result of the calculation, this will cause a stuck pattern to eventually continue.
- count the live cells, and when that drops below a certain number fill the grid at random with :
- a controllable random density.
- make row outputs on each of the rows of the grid, and run a cursor over that grid from left to right. Whenever the cursor hits a live cell it will output a pulse on the row output. This will give you as many inter-related pattern sequencers as you have rows. (and could add column patterns too with some logic combination on the cell values)
- Sum the number of live cells in each column, and run a cursor over the grid. Whenever the cursor steps calculate the sum of live cells in the column. Some rules can then be applied to that sum .. I have linear sum, exponential sum (like an R2R networrk on the column cells), lowest index, average index, etc. This will be nice to control pitch or cutoff frequency. And could add row sumes too).
- there are alternate rules as well, like : highlife, daynight, 2x2, 34life, amoeba, gnarl, seeds, serviettes, stains, pseudo, move, starwars, inverse (pixel color inversion), and more .. use google :-)
- A reverse input, to reverse the cursor direction.
- You may want to make a toroid out of the grid by connectiong top to bottom and left to right, so when stuff runs off it will come back on the other side.
- When doing a software version its easy to make a large game, but it could be interesting to set a limited number of rows / columns to be actually used. _________________ Jan
also .. could someone please turn down the thermostat a bit.
|
|
Back to top
|
|
|
PHOBoS
Joined: Jan 14, 2010 Posts: 5591 Location: Moon Base
Audio files: 705
|
|
Back to top
|
|
|
|