0:47

So let's talk about stochastic composition versus chance.

Â It kinda comes down to a couple of key questions here.

Â One is how many random decisions are we making?

Â Because if we're making a lot of random decisions of not just five or

Â ten but hundreds or even thousands of random decisions, then,

Â we have the ability to really shape the probability distribution of

Â those random numbers in a meaningful way.

Â So that they're not just coming out with an even chance of any number coming out.

Â But if we stack the odds basically, if we make some odds more likely than others,

Â if we do that enough, then we're going to actually be able to hear that, and

Â hear the effect of that in the music.

Â So if we make enough random decisions, we have this ability to use

Â stochastic techniques to control the distribution of those random decisions and

Â the results of them and shape the music that way.

Â The other thing that we can think about is how are those decisions structured?

Â In other words, are we just kind of blindly taking the random numbers that

Â come out and then using those to kind of, you feed into function arguments,

Â or some effects value, or something like that?

Â Or are we thinking really carefully about the mapping that's behind these?

Â Kind of how are we taking this and bringing it in a musically

Â sensible way that supports what we're trying to do in music.

Â So I'm gonna walk through both of these as we refine the example that we built in

Â the last video to make it more an example Stochastic composition and

Â less an example of Chance composition.

Â So the first thing I want to talk about are probably distributions.

Â So far, we've been using things like the random function from Python, and

Â we've had uniform distributions where every outcome is just as likely

Â to arise as any other outcome.

Â So with random, you're just as likely to get any number between zero and

Â one as any other number.

Â They're all equally likely.

Â Same way as if you flip a coin, you're just as likely to you get heads or tails.

Â So you might get three heads in a row or even ten tails if you feel really lucky.

Â But if you do thousands and thousands of coin flips, eventually,

Â you're gonna converge on a uniform distribution where you've gotten

Â just about the same number of heads and tails.

Â Same thing is true with random.

Â What we're gonna look at now is a different

Â kind of probability distribution, a Gaussian Distribution.

Â You've all probably seen something like this bell curve-like thing before,

Â where you have a central value which is kinda the one that's maximally likely to

Â come back, and then some kind of slope out from there.

Â And so, as you get towards the edges, things become decreasingly likely,

Â so you're very unlikely to get these values.

Â You're very unlikely to get those values, you're very likely to get that,

Â then you're pretty likely to get those, and those, and so on and forth.

Â So we can use the gauss function in Python to create one of these

Â Gaussian Distributions, so

Â that we can control the likelihood of different outcomes coming through.

Â And we specify in terms of two different arguments, one is the mean,

Â which is the central number here, And the second one is the standard deviation,

Â which controls the slope of this, essentially.

Â So the higher the number, kind of the flatter that becomes, and

Â the more is under the bell of that curve.

Â So now let's look at the script that we wrote in the last video to try to make

Â Maximally random choices about what sounds to use and

Â where to place them in [INAUDIBLE].

Â And where going to use a Gaussian distribution on our start times.

Â So, that we try to clump a lot of our sounds and

Â make them really dense in the middle and have the music be a little bit thinner or

Â sparser in the beginning and in the end.

Â So, I need to go to the start timeline here and

Â random is giving me a uniform distribution.

Â So I don't wanna use that anymore.

Â going to delete that.

Â I still want the one plus because I want to make sure all my sounds start at

Â measure one or later.

Â But i'm going to use Gals command now,

Â Gals function to create galaxy distribution,

Â sent it around eight and spreading by a factor of three.

Â So that's all I really need to do to create a galaxy distribution here.

Â But I am going to make a couple of other small changes.

Â I'm gonna create more sounds.

Â And this way we get, that distribution will come through even better, and

Â we'll be able to see it better.

Â And I'm gonna spread that across more tracks.

Â Again, to keep the...

Â Since I have more sounds here I wanna keep the chance of,

Â of overlap on the same track of two sounds, as low as possible.

Â So, I'll go ahead and run that.

Â 5:54

So it still sounds very random, but

Â we are hearing these changes in density according to the Gaussian Distribution.

Â And so I want to look at this second question,

Â we've covered the distribution part of this, and this is

Â kind of a macro level attempt to create a sense of a large scale form to it.

Â Cuz, you know, this kind of diagram also corresponds to something we see in music

Â a lot, an arch form, where you kind of build up tension or density.

Â Towards the middle are some climactic point piece,

Â and then you decrease it again towards the end.

Â So we've done something along those lines by creating this calcium

Â distribution in terms of the density of our sounds,

Â how many sounds are happening at any given time?

Â But we've left something out, and

Â that's that We've kind of ignored the meter of the music here.

Â A DAW is very good in giving us a timing grid.

Â And all these sound files were created with a tempo and a meter in mind.

Â And we've kind of ignored that because we're randomizing the starting point to

Â a floating point number so

Â it can start from any point in the middle of the measure.

Â So, what I want to do is try to bring back some of that sense Of beats, and meter,

Â and tempo of this music.

Â Now I wanted to bring in some math functions to do that.

Â So here is some common functions in the math library in Python.

Â So this is a whole other API, where if we wanted to use we would use it we would

Â start off our Python script with this line "from math import *".

Â Then we get all these things like sines, and cosines, and tangents and

Â things like that.

Â I want, in particular, just use One simple function right now, floor of x.

Â That basically returns an integer that's the highest integer that's still

Â less than whatever x is.

Â So if x is 1.25,

Â the floor of it is gonna be a one.

Â If x is 3.14159, floor.

Â is going to be three and so on and so forth.

Â Okay, so now let's apply some of those ideas about quantization.

Â to our script to have the starting and

Â end times of each of our sounds align with beats and measures of music.

Â So the first thing I'm going to do is I have to import the math library so

Â I can use the math functions from Python that I want.

Â So I'm going to add a line up here for math import *.

Â And the next thing I need to do is look at my start time,

Â so I've got the gauss in distribution, I want to keep that.

Â But I wanted to always start at the beginning of the measure.

Â So I'm gonna use the floor function from the Python math library to do that.

Â So, the gauss function is gonna generate a floating point number and

Â the floor function is basically gonna take of the decimal points.

Â So it's the lowest integer,

Â that's the integer just below whatever number I have there, so if we start off.

Â With an integer that's 3.547,

Â when I apply the floor function it's just gonna be 3.

Â And now let's look at the end time, my duration here.

Â So I'm using random still here.

Â So it's gonna be a random floating point number between 0 and 1.

Â But I wanna quanize this so it lasts a certain number of beats now instead.

Â So I'm gonna use rand int instead to give me an integer between two and four.

Â So rand int will either return two or three or four and

Â multiply that by zero point two five.

Â And what that's doing is I basically

Â have either zero point two give times two, zero point two five Times three.

Â Or 0.25 times 4.

Â So 0.25 times 2 would be two beats.

Â 0.25 times 3 it means it will last three beats.

Â And 0.25 times 4 will be four beats which is a full measure.

Â So each time we're going to start at the beginning of the measure,

Â that is the four function is doing for us.

Â And we're gonna end after either 2, 3, or 4 beats.

Â So let's go ahead and run this, and see what happens.

Â 9:58

And again I'm gonna hide the code view so we can see all the tracks at once.

Â And you can see how the starts are always aligning with the starts of measures.

Â And the ends are always a lining with either B3, 4 or

Â the start of the next measure.

Â So, let's listen to this.

Â [MUSIC]

Â So we're still

Â hearing these

Â changes according

Â to the Gaussian

Â distribution and the density.

Â But we're also hearing a sense of meter, a sense of some kind of regular pulse going

Â through this because the sounds are always starting at the beginnings of measures and

Â lasting a particular number of beats.

Â I wanna just talk about an important historical example of stochastic

Â composition.

Â This is a Greek composer named Iannis Xenakis.

Â He actually helped develop a software program called ST.

Â Which stood for stochastic music.

Â And he wrote a number of pieces with this.

Â This piece is called ST/10.

Â Which meant it was written for ten musicians.

Â And he wrote this in 1962.

Â And the way this worked was his program actually didn't generate sound it just

Â generated note data.

Â Things like start time,

Â what instrument in that ensemble of ten musicians is playing the note.

Â What its pitch is, what its duration is, what its dynamic is.

Â And he loved glissandis, so there were actually a few different

Â parameters that controlled where there was a glissandi, and

Â if so, whether it was up or down, and how Farms going and things like that.

Â And once you got that new data out of the computer, you transcribed it, not so

Â different from what Hiller and Isaacson did with ELIAC suite, that we look at in

Â the first video in this module, to transcribe this new data onto a musical

Â score, that musicians could then rehearse and perform on traditional instruments.

Â and there's sarcastic decisions being made throughout as you can control things like

Â the parameter of this note data that we just discussed above.

Â The density of notes in a particular section,

Â how long a section is of the music and so on and so forth.

Â You can use a variety of different distributions including normal and

Â galaxy distributions that we looked at here Now and to make one final point here.

Â Which is that stochastic music is not limited to a kind of avant-garde or

Â experimental musical practices.

Â Just yesterday I was playing on my iPad Garage Band with my son.

Â and he opened up this smart drum instrument on it where you actually

Â drag pictures of drums onto a grid and

Â the y axis of where you place them controls the dynamic.

Â The x axis is complex on one side and simple on the other and so

Â you're controlling this sarcastic aspect of how Each drum within the selection

Â of different drum samples is playing how dense it's being triggered.

Â And then as if that's not enough,

Â there's a little picture of a dice at the bottom of th screen.

Â If you hit the dice, it will randomly place different instruments in different

Â places on this grid, to create a new drum pattern for you.

Â So the The kind of consumer purpose of it in a program like that seems to be that

Â everyone wants their own kind of unique drum pattern.

Â But they don't necessarily want to program it from scratch,

Â the way we might in a pattern sequencer.

Â So this kind of stochastic approach gives people the ability to generate over and

Â over and over again, until they find something that they like, or

Â to tweak the parameters of each of things until they find something that they like.

Â So to review what we've done in this video, we've talked about the differences

Â between chance and stochastic music in terms of distributions and mappings.

Â We've looked at probability distributions, such as Gaussian distributions

Â As a way to structure chance decisions into a more stochastic approach.

Â And we also looked at math functions, like the floor function,

Â to help us quantize and kind of use the metrical grid to perform

Â different kinds of mappings with our random numbers.

Â And then finally we looked at the music Iannis Xenakis As an example of stochastic

Â techniques in composition.

Â In the next video, we're gonna look at a very different approach to algorithmic

Â composition in the form of process music.

Â