 Those who were at the last talk, worst song in the history of music, hold my beer. We also have sound houses where we practice and demonstrate all sounds and their generation. We have harmonies which you have not. Now those words published by Francis Bacon in 1627 either foresaw generative music or perhaps even willed it into being because Daphne Orham pinned those up to her wall at the BBC Radio Phonic Workshop and when she left there the studio she founded was indeed called the Sound House and her dreams of graphic scores, creating sounds were realised but this is not the story of Daphne Orham's Oramics Machine and the BBC Radio Phonic Workshop though I do know it. You might get the reference but really it was a passage in Douglas Adams' first Dirk gently book that maybe got me onto the idea that mathematics could generate images and those images themselves could generate sounds. That's not the quote. I shouldn't spoiler it but the protagonist finds himself in a room where every point in space there is a new music and later still I found myself at Finsbury Park's Hinoima, the malediction club where I learnt that noise could indeed count as music and that is documented very well by Jennifer Wallace in her home Fight Your Own War but for all this grand talk of Daphne Orham or perhaps Mirzbo and influences I must warn you that the songs, the sounds I heard on those fateful nights they didn't really sound anything like these sounds. This is just a tribute. Sorry. In advance. Yeah it's a swindle, I've got form for this. Two years ago I was here doing Lorenz Attractor sounds in Oblique Strategies Against Humanity. Don't worry about the links if you, my slideshare is on every page and you can have these slides in almost but not entirely the wrong fonts. Last year I was at, so Oblique Strategies Against Humanity was mostly Lorenz Attractor sounds. There were some Lorenz Attractor sounds at Char last year with indiscreet music but it was mostly cellular automata. People kept saying they liked the Lorenz Attractor sounds which was hardly fair so there won't be any Lorenz Attractor sounds today. Anyway, this is where the story really starts. I bought a scarf. I bought a generative one-dimensional Wolfram Cellular Automata scarf. Well I didn't buy it, I funded it. It has actually shipped, I shall have it in time for the autumn. So that was produced by one Fabien Serrière who's name I probably just mangled. So in order to check the progress of my scarf I looked at a video of hers on Strangeloop, the papers we love section, and I was introduced to generative seashell patterns and a book called The Algorithmic Beauty of Seashells. So go and watch the Strangeloop video, it's probably much more, well there's no noise at least or there's very good knitting machine noise, it's probably better than my noises. I tried to get my revenge on Fabien. Although the generative mollusk patterns you're going to see work on a sort of basis of diffusion of pigments and inhibitors and hormones and such like, there is in fact a certain lizard where the automata works on the basis of one cell, one pixel. So there's a paper in nature and a research group did tracking of these lizards as they walked around their tank so they tracked each lizard and mapped its scale patterns and deduced from that the underlying automata, so it literally is one scale, one pixel. And I was mailing her last night in fact. I said, well, oh great, my scarf's coming, I'm doing a thing at EMF. Have you heard about these lizards? No, could I have a knitted generative lizard? Well, if you send me the code, did I just volunteer for the soft toy industry? I think I have. If you want to go and find the Algorithmic Beauty of Seashells, I'd recommend finding its second hand because at least the vendor there will tell you if it comes with the CD, with the software on it. But thanks again Springer. It does appear to be available new on the Springer website. Unfortunately, when you click through to the place where it says download the supplementary materials, there's no mention of any software. So I've no idea if those new additions come with the software. And this is in fact part of a series. There's the Algorithmic Beauty of Seaweed, Sponges and Corals. These also seem to come in multiple e-book additions, one more expensive than the other. One probably a sort of cheaper, grottier rendering of the PDF perhaps, I don't know. But the Algorithmic Beauty of Plants, there's a legitimate PDF you can find out of that and they've got all their code. It's a reasonably complete piece of software that comes with the book. There are various options for visualization, the colors, the geometry of the display. And there are reasonably complex options for setting up the initial conditions of the simulations and even how they change over time. It's quite a piece of work, but basic. Fabian took quite heroic efforts to avoid re-implementing or running the original code with virtualization. That in itself is quite a story to behold. But let's look at this. We're iterating over multiple substances, J8 and JS. We're going to go sub to old decay and do something stateful and hateful. So very slowly this has been turning into something approaching a proper Python module and you can just iterate over the mollusk pattern, which is in fact sort of turning legacy code into more modern Python. It's my day job, so I ought to be capable. The cool hormone function or rather the line afterwards is interesting. We're a mysterious sea for hormone concentration that's only defined within an if statement that may or may not fire. And you think, oh, what's that going to be? But then you look to the top and you see that just like Fortran, the variable will be initialized as floating points on the basis of which letter of the alphabet it starts with. But hang on, we're dividing by it. It's divided by zero by default, lovely. But these things do work. So there's my Python oliver porphyria mollusk next to a photograph of the real thing. I don't know if you believe in synchronicities, but the oliver porphyria looks rather like the viciously venomous cone snail, one of the most venomous creatures in the world apparently. And I know this because I went to the Natural History Museum Venom exhibition and it turned out that two friends who I knew worked at the Natural History Museum in fact devote their time to snails. And then there was someone at the London Pi Data event talking about the generative geometry of the shells and the shapes of the cells themselves. And somebody got a tattoo of a snail on their neck so it seems to be somehow destined to produce generative mollusk sounds. And the way this thing works is you have a number of substances that diffuse. That's the bit I managed to vectorize in NumPy and they interact with each other. And oliver porphyria, I believe, you have what I believe is called an activator inhibitor reaction. So there's various couplings between the substances as they diffuse and one of them is the pigment. But before we make mollusk sounds, a little diversion. The thing on the left is a Gauss map. Can this microphone go higher so I can actually look at the audience? I've managed it, thank you. That's better, I can see my slides in you at the same time. So we're going to have a recurrence relation. We're going to pick a fairly arbitrary initial value of x, feed it into the simple expression on the right which has two parameters, alpha and beta and the next x is going to be generated from the previous one. And we're going to generate a sequence of x values, maybe chuck away the first view as transients and we're going to slowly build up a histogram. So there are regions where the system visits quite frequently and there are places where it doesn't go at all. And we're going to take that histogram and treat it as a slice of an image and the height of the histogram is going to be the intensity of the image. And we're going to vary the beta parameter and scan across a whole set of these slices and build up a single image. And then we're going to change the alpha parameter slightly, scan beta back down again, make a new image and that's going to produce, well, a video, an animation. So beta's varying on the horizontal axis, scanning up and down and alpha is varying through time. And we're going to abuse Fourier transforms and treat those histograms on the bifurcation diagram as spectra. So if you imagine the bar graph visualization you might have on your audio player or your spectrum analyzer, we're going to run that in reverse with NumPy's real FFT library. Now, the points of a Fourier transform is we're going to assume that a signal is periodic and we're going to build a spectrum for it. Well, we've already established that we're having varying spectra. So for the short-time inverse Fourier transform we treat a bit, cheat a bit rather, and we're going to take each histogram, inverse Fourier transform it, multiply it by a vaguely Gaussian bell shaped looking window function that it's not Gaussian. I believe I used the Blackman-Harris. We're going to create a series of those audio signals, superimpose them and play on. So the right channel is going to be the left channel played backwards, and I'll see if I can get the video going and assault you with it. Nice mouse. Let's see if this falls screens correctly. Thank you! Wait for the... Oh, I wonder if F5 will work. Let me get my mouse back. I can see... I just can't get it back to my laptop. Oh, nearly there. It was too quick. Oh, thank you. That's better. I'm going to unplug the laptop and do audio from my music player from now on. So there's a pop, that's not part of the show. Yeah, that was a little bit of a cheat. If you know anything about Fourier transforms you undoubtedly know that you need complex spectra and all we had was a single array of real values. I'm not going to explain about DC and Nyquist and how you pack a complex frequency spectrum so that its inverse Fourier transform gives you a real signal. No, not today. In this ungodly hour of the morning. Yeah, suffice it to say, as I mentioned we have multiple substances in the Oliva porphyra simulation. Well, we can take the real amplitudes from the activator part, which is what generally gets sort of plotted with a threshold to produce the image. The inhibitor concentration on the mollusk will use that to be the imaginary amplitude. And we're going to do exactly the same thing. We're going to treat these things as histograms and the centre of the histogram, the point on the spectrum where there's as much amplitude to the left, to the right, sort of the centre of mass, that's going to pan the signal from left to right and when that crosses the x-axis, when it's balanced, will trigger yet another mollusk and that one has gasp for active substances. So the left channel will be the activator on an inhibitor and the right channel will be two other substances whose names or functions I can't quite remember. I think one of them is to do with called extinction. For some reason I have decided to call this next one Wheelkeeper Welk, come in the hillside. No, sorry. Damn thing. Surprise. Yes, that was originally three minutes, but a friend of mine gave it the official Lovecraftian ethnomusicology seal of approval so you've given him to blame for it stretching out to four. No, no Lorenz attractor noises, but I can talk about them. The circuit on the right is done by Paul Horowitz of Horowitz and Hill Art of Electronics fame and I did build one and it's the rat's nest to the bottom left and a very nice person at the London hackspace let me attach it to his galvos and his laser and it produced a rather nice laser Lorenz attractor at the top. Unfortunately the sort of speed that gives you decent persistence of vision doesn't necessarily give you particularly interesting sounds even if you attach those signals as control voltages of analog synths. And there are other problems. There's a big nasty rotary switch for switching the capacitors to change the speed and if you think well what if I wanted two Lorenz attractors one slightly shifted to pick up the sensitive dependence on the initial conditions and what if I wanted to vary the parameters so that would be either digital parts or messing around with transconductance amplifiers or whatever to have control voltages changing the parameters of the attractor. I haven't abandoned it but it all got a little bit gritty. So here's a list of things I have tried or haven't yet tried. First thing I did in fact was SVG and web audio in the browser which people quite liked apparently. I have tried controlling super-collider via overtone which is written in Clojure. I might come back to that in fact and redo the SVG in browser stuff in Clojure script just for my idea of fun anyway. You can start implementing things in C++ as LV2 plugins which probably no one has heard of or the sort of the methadone to Eurorack and modular synths is a thing called VCVrack. I hardly recommend you go to the VCVrack workshop because I won't be there because I'll be going you know safe in the knowledge that I won't be there because I'll be going well can we have Lorenz attractors? No, but I'd better go off and write one in C then. So eventually I gave in and just resorted to taking the variables coming out of a Lorenz attractor, the signals quantizing them to 128 midi notes and shoving them down some analog synths. I called that Merry Christmas, Mr. Lorenz. Well of course I did, it's the sort of thing I do and annoyingly people quite liked it even though I thought it was a rather dodgy compromise or that quantization. Or you can cheat. If you run your Lorenz attractor generator on a Raspberry Pi you can take the signal out via the GPIO pins and use it to run some cheap and fairly cheerful digital-to-analog converters. Now there are proper DACs available for the Pi but they're audio DACs and I want much more slowly varying signals than audio which would probably be high-pass filtered out and we're going to take the output of those and then use them to drive some proper analog synths. So not a Lorenz attractor as threatened or as promised but Duffing's oscillator instead. So that's a Duffing oscillator. It represents a damped oscillator. So alpha is the springiness of the springy bit of metal. Beta represents the non-linearity of that springy bit of metal and it's been shaken and omega in that equation is the frequency with which the driving frequency with which the system is being shaken. So I tried it. I went out and acquired some DACs. I wanted nice temporal resolution, good dynamic range so lots of bits, preferably I2C instead of the Pi's SPI bus through-hole, steady as a rock but I sold it with this and I wanted it cheap. This is what you want. This is what you get. This is what you want. This is what you get. I ended up for being cheap with a 10-bit 2-channel SPI DACs. Never mind. And it came out all quantized and spotty anyway but having considered ripple currents and RC passive filters for literally seconds I went to the first blog post on the subject I could find and then ignored it and just grabbed the first complete set of resistors and capacitors I could find, filtered the output of the DAC and I got a nice fairly smooth looking duffing oscillator which you see below. So that's now sufficiently analog I think. Yeah, that's proper analog now. So that did get shoved into analog since we've got two DACs, two channels so we can have two duffing attractors slightly shifted. Frequency and the modulation of that frequency will come from one attractor and the other attractor will modulate amplitude and filter cutoff and as is my obsession, when things cross axes, X or Y it will trigger either the high or low tom or open and closed hats on my cheap and cheerful Korg Volka Beats drum machine. So I'll play you out with duffing oscillator noises instead of Lorentz ones eventually. If new order can get away with pressing play and walking off I can't see why I shouldn't either. But sure, I was technically the last act on the largest stage so I kind of sort of headlined a festival by mistake. So thank you for your attention. If there's time for questions, I'll take questions or I can generally be found in Miliways. It's smoked brisket tonight by a challenge coin. So if we do have any questions then I can come round and bring a mic. There was one thing I would like to ask. In terms of the samples that you've provided today are these quite heavily curated or do you just kind of allow the device to produce what it produces and then sort of present that? Plausible deniability. This thing I said at Char that people picked up on you've got to give the algorithm a fair chance at sounding terrible. It wasn't me, I'm not responsible. In fact those sounds were mostly pretty dry. The only thing I did with my cheap and cheerful Korg Chaos pedal was that given the duffing oscillator is based on a spring I think spring reverb is kind of fitting. Everything sounds better if you slap tape echo or reverb all over it. But in fact that was the only one that I cheated on. I normally slap some sort of reverb over the bifurcation diagram but this time I couldn't be bothered. So that was dry as well. It was only the last sounds came out of any sort of analog physical music making device. Everything else was just hot out of the Python console. Okay well thank you very much again to Charles Greenway for that talk on generative music and mollusks.