*** MUS171 #13 02 15 Miller: @0000 Here's a sequencer [musical tones] of which I've made a simple example. I'm sorry, this is a little boring because it's another 16 tone sequencer. But this one, if you @0015 listen to it carefully [musical tones] acts (not quite ...) like an analogue synth. You can't really get an analogue synth to do this exact thing but you can get kind of close to it. I'll slow it down. [musical tones] @0030 The basic deal is the timbre of the sound is changing during the life of the sound. So it doesn't just go beep, beep, beep like a Hammond organ; the sound is brighter at the beginning than at the end. It actually... @0045 I can slow it down some more: There. So you can hear how the sound is brighter at the beginning than it is at the end. @0060 Now, there are two fundamental ways in electronic music that one does this -- of which you know one. The one that people reach for, if they are used to working in studios, is a filter. But I haven't told you @0075 about filters yet and I might not even be able to tell you about filters in this quarter depending on how things go. The other way is by waveshaping -just the technique that you've seen so far. Those of you who've played electric guitars probably noticed that if you @0090 put your amplifier in overdrive then the volume control on your guitar is actually a tone control because the more you saturate the amplifier the more brilliant the tone becomes in some sense. @0105 That's the same technique as what computer musicians call "waveshaping." And that's what's happening in this patch here:[musical tones] So this is just nothing but a sinusoid @0120 going through a skillfully chosen transfer function -- not that skillfully actually. And the thing that changes the timbre of the output is -- just changing the amplitude of the input. @0135 So if you... Well, I'll show you this in the patch. But the basic trick to making timbres with music using computers, the simplest way of doing it is called "waveshaping" where you take anything that you want @0150 which you presume is some kind of periodic function (but the sinusoid is perfectly good), control its amplitude, and then pass it through a non linear transfer function. And then probably control its amplitude again so you can turn the thing on and off. Then the first amplitude control @0165 actually changes the timbre of the sound. And I can prove it my example. Oh, actually, before I prove it by example, what I'll do is start this back up and show you what the controls are that I put on it. [musical tones] @0180 There is of course the speed control. The duration ... You all know how to make envelope generators. Envelope generators are just line~ objects with messages that turn them on and off, which you saw in the @0195 polyphonic example. Actually, the homework that is due this coming Thursday has an envelope generator in it, which you need in order to be able to turn sinusoids on and turn them off in the way that ramps in time. @0210 So this is that same thing almost: [music] Miller: It's actually a monophonic instrument. There's no polyphony in here at all, which is therefore more what like what an analog synthesizer would have done. The sequencer is nothing but looking up a nice table using a metronome, @0225 and modular arithmetic to go through the table, exactly like in the previous example, I think. And the timbre variation is happening just using an envelope generator. And I'm not even bothering to control the amplitude except right at the output here. [music] Miller: @0240 And this is just change in the timing on the wave generator. [music] Miller: And it's useful to be able to change this. And that's it. That is the whole thing. And you know you can turn this thing on and run the tape @0255 and sound like Morton Subotnick sort of -- not quite exactly. The extra credit example is similar. (Actually, I'm sorry this is not as @0270 imaginative as I was hoping.) It is the same extra credit as during homework three. But homework three was almost impossible to do. Did anyone actually do the extra credit for homework three? That was the eight-note sequencer where every third note @0285 had to have a different timbre? Which was just hard, right? I hope it was. It was hard for me, so I hope that it was hard for you. If you do that but drive it with a metronome, everything becomes a great deal easier. You just didn't have that @0300 way of doing things before.[music] Miller: So now it is very easy to do this kind of stuff. [music] Miller: @0315 And all this changing now, I am not having to do any weirdness about turning oscillators on and off; that is just changing the parameters that go to the envelope generator that is controlling the thing, which I am going to define later as the "index of modulation." @0330 That is, the amplitude of the sinusoid that you are putting into the waveshaping function. So that is homework number seven, which is due on the 24th, a week from Thursday. You of course are @0345 all still working on homework six, and that's cool. But I want to show you that, so that you will have some context or some sense of direction as I show you again painfully or what do you say, @0360 didactically through the ABC's of waveshaping. This is the the most popular. If you look at waveshaping in it's most general form, it's probably the most @0375 popular way there is making timbres with computers. And so there is a fair amount to know about it. Although, there is a great deal more not to know about it because, it turns out that in most situations, what waveshaping does is mathematically very difficult or intractable @0390 to analyze. So, you can use simple examples, to sort of guide your way through designing instruments. And then when you're designing real instruments, the simple examples will give you intuition but they won't give you exact answers that apply to complicated situations. @0405 So the example that you've already seen is this one: take a sound, clip it from any two numbers, I think I was using -0.2 and 1, @0420 and then listen to it. And out comes a sound that's clearly not a sinusoid. One @0435 observation -- Oh, let me show you the other function that you've seen first and then make an observation, actually, two observations. First observation is the very simplest one which is, @0450 how would you make a time varying timbre using this technique? And the answer is just what I said, take this thing and multiply it by something that varies in time, so multiply it by the output of a line~. ... @0465 So we're going to multiply this by the output of a line~ and then clip it. @0480 And the line~'s going to be control. Let's see, in this case just a plain old linear control is going to be good so I'm just going to take whatever I have and pack it with a decent interval of time and just make there be a number box. @0495 Let's have it in hundredths though. All right. And now we have, this is not going to be great or anything like that, this is just going to be sort of basic. @0510 So the oscillator itself, of course, when I multiply by nothing, nothing comes out. So if I multiply by say 0.1, here's the oscillator. Oops, it's very quiet. @0525 Oh, I'm going to cheat and make it louder at the amp. I'm not sure that's a good idea or not. We'll see. OK. Oh, sorry. I don't want to do that. @0540 I'm doing something stupid. This is how to teach yourself how powerful your amplifier is, but I don't want to know how powerful this amplifier is. OK. I'm dividing by a hundred! I did not want to put zero point one, I meant 10. So now I'm going to go back, turn this down and do this right. @0555 OK. So 10. There we go. Sinusoid, right? Now you all know this, but as I turn this up if I put 100 here this is multiplying by one and therefore I would get that sound: @0570 And, of course, sounds in between. Here are sounds in between. So now I have the very simplest possible whammybar that would control timbre. Right, oh yeah and it of course if it's negative, negative amplitudes @0585 are the sum of its positive. So if I was doing this in a way that, if I were doing this for someone to use I would make this thing have a range. Like I don't know zero to 500 so that it won't go negative and then I can have this. @0600 This does not work. All right. Computer music instrument. This is a little dull but it's only dull because well the main reason its dull is because there's only one function @0615 so far. Right, so what can you do with this? OK. First off let's try other functions besides clipping. So I'm going to just copy this clip functions so I can get it back later. And meanwhile I'm going to do stupider things @0630 like for instance take the signal and square it by applying it by itself. And now I get nothing and as I turn it on I get and as I showed you last time it goes up an octave. @0645 Because when you square something well there are two ways of thinking about this, why that happens. The way I told you last time is oh it's just a trigonometric identity. The square of the cos(omega t) @0660 is nothing but [cos(2 omega t) + 1] / 2 -- Which means if you square a pure sinusoid you will get something at double the frequency. If you take the sound of your @0675 guitar and square it you will not get a thing that is an octave up. That only works for pure sinusoids. A guitar signal or any other kind of real signal which you record will have overtones and those overtones will @0690 when you square them will not just get squared individually they will look at something else. Meanwhile I should tell you something else about this which is this is good but in general @0705 with non linear transfer functions. (Oh let's get the actually while I'm here let's get the clip thing back. I can leave this here and have the clip too.) So I'm going to put this over to the clip thing @0720 and I''m going to make another output obviously so you can listen to that too. Minus something plus something I don't know. @0735 Now let's hear it Oh yeah turn this up so were clipping now. Now here's the thing about that: If you take two oscillators and give them @0750 two different frequencies and add them. ... (By the way I mentioned this once in passing and I should have mentioned it again: If you connect two signals to an inlet they @0765 will be added.) Now if I want to give this thing say something else a fifth up so let's get this at 325 oh, no, Oh right, it's, yeah. This is it. Sorry that's not a fifth up that's some other interval or whatever that is. @0780 OK so that's a thing you enter two sinusoids so now when I start pushing it to a point that they clip I get some of this stuff:[musical tone] right? @0795 Well, OK, clip~ is a non linear function and when you send signals to non linear functions not only do sinusoids turn into things that are not pure sinusoids anymore -- that's called "harmonic distortion" in Stereo Review. @0810 The other thing that happens is when you take the two different sinusoids or give a signal that has more than one sinusoid component in it, they will, as it's called, "intermodulate." What that means mathematically, well hand-wavily @0825 mathematically, is that there will be distortion products which are not just functions of the one and the other but cross products of the two. So to go back to the simple example ... So if this was the complicated example would be [musical tone] . @0840 Oh yeah, with the clipping function. [musical tone] ... The simple example is going back to just squaring the thing. ... Why don't we hear anything now? @0855 Oh yeah, I've turned this thing off. OK, so I'll push it all the way up. So now we're going to hear [musical note] . Oh yeah, good. So now, with the clip~ function, @0870 by putting a low amplitude in I was able was able to use just the linear portion of the clip function. So the clip function, if you graph it as a function, is flat and then linear and then flat. Because clip just lets the value @0885 through until it clips. So if you don't let it clip, you give it a value that's less than the value at which it clips, then everything that goes in will go out. And in particular, here the sum of two sinusoids [musical tone] @0900 is just two sinusoids again. Oops, sorry. I didn't turn the volume up for that to be true. OK? And then as I push it up again that "distortion" products, "intermodulation" products as the stereo people would call it. So for in the (squared) sinusoid case, @0915 the thing is not linear anywhere. In fact, if you like the sinusoid is...sorry. If you square a sinusoid that means your lookup function is a parabola. And the place where a parabola is least like a line, if you like, is right @0930 at the origin where it doesn't have any slope. So here, 250 and 325, those are these pitches. [musical notes] But here they are [musical tone] --- not there at all. @0945 What there is, is this sound [musical tone] . That's an octave above this. Furthermore, you get an octave above this [musical tone] . OK, so now you've got [musical tone] ... @0960 And then if I put them together you'll get another pitch which is about [musical tones], and another one which is [musical tone] something like that. I can't get down that low, right? [musical tones] -- @0975 Two other pitches that were not there in the original. Actually, none of the four pitches that you hear. What pitches do you hear. I hope you hear, oh let's make it this is better than a real example because @0990 its harmonic to the point that you can actually find so like that and then [piano] you hear those four pitches sorry, duh. @1005 OK. What happened? Well this oscillator by itself made one pitch and it also make DC by the way. @1020 This one also made a pitch and it made DC. But as you all know (A + B)^2 is [ A^2 + B^2 + 2 AB ]. That means you get the square of the first one and the square of the second one. But even more you get @1035 a product of the two. So yeah, one component of the output of this squaring function is this times this. @1050 The crossterm. And that crossterm is what's called "intermodulation." And these two pitches [piano] -- those two pitches were just double the original pitches and these two pitches [piano] @1065 were the sum of the two frequencies and the difference of the two frequencies. All right, oh, you've already even seen this because if you multiply two oscillators that's ring modulation. So what you get @1080 is the sum and the product of the frequency. So here you get the sum of these two frequencies which is whatever that is 575, you get the difference which is 75 and then you get double this and double that. All right. @1095 Of course if we gave it a harmonic sound, like gave 500 here. then we're going to get just a nice harmonic sound. @1110 And there, the component frequencies are going to be double 250 which is 500 double 500 which is 1000. But also, 500 minus 250 which is 250@1125 again and 500 plus 250 which is 750. So you actually get 250, 500, 750 and 1000. ... Questions about this? Yeah? Student: @1140 I don't get how these cosine's give you sums and difference frequencies. Miller: Yeah, so it's two times the cos ... What I really should have a blackboard or should use a blackboard but it's going to be a mess if I do. @1155 So this is the, what's coming out of here is the cosine(250 2 pi t). What's coming out of here is the cos(500 2 pi t). And when you multiply those two it's the @1170 cosine of one thing, times the cosine of another -- which is half the (cosine of the sum) + (cosine of the difference). That's the trig function you need. @1185 Where do I have that written down? Let's see. That's in the book somewhere, but I'm not going to be able to remember where, right now. So that's why you get the sum and difference frequency. Yeah, I'll go try to figure that out. It should be at the very beginning @1200 of chapter five. Actually, you know what? ... It's such an important formula. This is the fundamental formula of computer music, so it's... let's see. I'll go here, maybe I can actually go back to modulation @1215 and go to multiplying audio signals, and there it is. This is more than you need. @1230 This is showing you a cosine including the phase, and another cosine including the phase term and then it's this mess. But in fact, it is cosine of the sum of the two frequencies with another phase, and it is cosine of the differences of the two frequencies @1245 with another phase. OK. All right. And did I find my way back to where I wanted to be? Yeah. OK, here. This is a picture of squaring the signal, and what it looks like, @1260 when you square a signal. See it becomes positive. And this is the transfer function. This is clipping transfer function that I was just talking about here: Here, and this is what the waveform should have looked like earlier, except I drew a symmetric one and in the patch @1275 I did a non-symmetrical. Important detail about that... Yeah, I can demonstrate this, I think. I mentioned that it's a very @1290 special case that the oscillator went up by an octave, when I squared it, but in fact if I did any even function that I wanted here... What's another good even function? Let's see... @1305 absolute value? I hope that there is one of these... Good. Yeah, this is not going to sound nice. This is what happens in analog electronics when you take your nice sinusoidal oscillator, @1320 and put it through a full wave rectifier. The absolute value is, if it's positive it lets it through, and if it's negative it negates it so that it's positive again. OK. And when we do that...Let's see I did not do this real well. @1335 OK. We'll do it like this. Sorry, so this thing is not working right now because it does not have an input. So now, once more. Oh, let's get rid of this, and let's also be able to hear the original so that you can get that original pitch @1350 in your ear again. Here's the original pitch. [musical tones] And here's the original pitch with taking the absolute value of it. [musical tones] It goes up an octave. OK, @1365 this sounds mysterious until you think about it, and then it sounds stupid. So, why is it stupid? The oscillator itself --I'll graph the oscillator's output. OK, there's an oscillator @1380 for you, amplitude 1. It spends half of its time being positive and half of its time being negative. Now we're going to take this and put it through an even function. That is to say, a function whose output for negative values is the same as its output for positive values. @1395 An example of an even function is the second of these two examples:. Y = X squared. That is an even function. @1410 It's the simplest even function. No, the second simplest even function ... How about the function f(X)=1 ? [laughter] Miller: @1425 The voltage you get when you hook your electrocardiogram to a dead patient. All right. [laughter] Miller: That is an even function. OK, this is the next even function up, if you're thinking in terms of polynomials, which is one possible series of functions that we could look up. In fact, @1440 that is the one that we're going to talk about later. OK. So it's even. That means if you put a positive number in or a negative number in, the same thing happens. And lo and behold, the positive part of the sinusoid that goes in, gives you whatever it is. And the negative part gives you @1455 whatever it is all over again, because it's the same. So, the result is the same for the first half period as for the second half period. As a result of that, it had to go up an octave, @1470 because it's period suddenly dropped by a factor of two. All right. So that's a more general statement about why squaring a sinusoid, sent the sound up an octave. And in general, that would @1485 happen if you had a sinusoidal input -- or if you had any other kind of input, half of whose cycle was the opposite of its other half. That's... yeah. If you studied acoustics really well, you probably didn't hear this. But those are things that only have odd harmonics @1500 in them. If you do that, if you send one of those things into an even function, you will get something that is an octave up. Because what happens on the left hand side is exactly the same as what happens on the right hand side. @1515 All right. Now, if it were true that the function for the negative value was in fact, the negative of what it was for the positive values, then you would get the rest of possibilities. The rest is the odd harmonics. @1530 Those are the things you didn't hear for even functions and so, hand-wavily you might think, that odd harmonics would be a thing that you might get by sending a sinusoid into an odd function. In fact, it turns out to be true. An example @1545 of an odd function that you just saw was this one. So now for negative values, you get negative of what you have got for positive values. And as a result, @1560 when you send a sinusoid in, the result has the same period as you had before. And furthermore, the result still has the property that the second half of the waveform is the additive inverse of the first half of the waveform. @1575 So it's something and then it's minus it and then something and then it's minus it. And if you think about what harmonics would have that symmetry. The first harmonic does, it's positive and then it's negative. The second harmonic @1590 loses, because it does the thing, and then it does it again. So it's the same for the second half of the cycle as the first. The third harmonic goes up down up, and then it goes down up down. And so if you @1605 squeeze the third harmonic into the cycle, it will again have the property that the first half is the negative of the second half. That will be true for harmonics one, three, five, seven, nine, and so on. All of the odd ones. As a result of which, if you make @1620 a waveform like this, which is -- It doesn't have to be positive followed by negative, it just has to be whatever-it-is followed by minus whatever-it-is, so that if it's a negative in the first half, it's positive in the second half. Then you will have something with only odd harmonics and the typical sound @1635 that that makes, let's see: OK, so this clip was, I made it un-symmetrical deliberately in order to avoid having this happen, because I didn't want to be confusing or something. But I'll now be confusing. @1650 I'll clip between -0.2 and +0.2 two. And now we want to graph this so I can prove that it's doing what I'm telling you it's doing. Now we can listen to it. @1665 So here's the original: [tone] Miller: And here is the waveshaped one: [musical tones] Miller: And it has that, you know, clarinet-y, @1680 held-nose kind of a sound that one associates with sounds that have odd harmonics. By the way, don't let anyone tell you that clarinet sounds are typified by having strong, odd harmonics. That's true for the first @1695 18 half-tones of the clarinet, if I'm not mistaken, after which it's not true anymore. As soon as the little hole goes open, that quits being how it acts anymore. But it is @1710 true for the low notes, that you get these kind of notes for clarinet. And for the first 30 years of electronic music, whenever anyone made a timbre like this, that just happened to have, for symmetry reasons, mostly odd harmonics, they said, "Oh, it sounds like a clarinet." And so now you can find clarinet voices @1725 on your organs or synthesizers or so on. And it's just things that happen to have that symmetry, regardless of whether it sounds like a clarinet or not. To any reasonable pair of ears this doesn't sound like a clarinet at all, it sounds like a very cheap computer music instrument. @1740 Oh, and what does it look like? Ta-da. What I showed you before. And it does have the correct symmetry for having odd harmonics. Now, why am I belaboring this point? Because now, I've shown you how you can make odd harmonics... [musical tones] Miller: ...@1755 and even harmonics. [musical tones] Miller: Oh, yeah, I should show you that as a waveform. That was the one where I took the absolute value of the sinusoid. And now the thing @1770 can't go through 0 because we're taking the absolute value. So the second half of it is flipped upside down so it's positive again. All right. And that of course had to go up an octave. And now -- and this @1785 is an idea that I think that might be originally due to Don Buchla. At any rate the oldest synth I know that knows about this is Buchla's old modulator synth -- Now we have something where we can control the relative strength of @1800 the even and odd partials. ... Questions about this, yeah. Student: @1815 Could you set the relative amplitudes so you add the harmonics and get back the original sinusoid? Miller: @1830 The original sinusoid. No, no. Yeah, so one way of thinking of that is one of these only has odd harmonics and the other only even. So adding them is simply introducing different frequencies @1845 which won't in fact ever cancel each other out. However you could make a waveshaping function ... You could make two waveshaping functions each of which is horribly nonlinear but @1860 whose sum happened to just be the identity function. -- In which case you actually would have two funky timbres whose sum is the original sinusoid. I don't know if that would be useful but you could do it. ... @1875 So this is sort of, so this is just sort of "phenomenological" if that's the word. "Experimental," "intuitive." This is just very general @1890 observations about what kinds of wave forms might come out when you do things. So far what we've got is that putting two things in will cause distortion products which are sums and differences of the incoming frequencies. Or maybe sums and differences @1905 of multiples of the incoming frequencies. That was what we got when we took these two things in and where we added these two together and started waveshaping. And then we're getting stuff like this. [musical noise] Oh right, I was going to make this @1920 325 again .. so now we have complicated sound and more complicated sound right here [musical noise] Oh interesting. They're probably no common frequencies although I can't swear to it. @1935 So that, oh, let's look at it: Isn't that cool. This is the absolute value. This is the sum of two sinusoids full wave rectified. @1950 That's old fashioned talk. So you can imagine every other one of these lobes being negative in sign before it got waveshaped. And then every other one, this one @1965 [musical noise] is the same thing clipped so it looks like this: All right, another observation @1980 that is just right there on the surface: Different kinds of waveshaping functions have different behaviors when you change amplitudes, in terms of the overall amplitude that comes out. So, if you @1995 take the absolute value of something, the louder the signal goes in, the louder you will get out. All right. Pretty much, if you double the signal, in fact there aren't very many oh, real @2010 valued functions like this. Something where if you double the input, it doubles the output. The only ones that I know of are the identity function and the absolute value and combinations of those. Although if you think in the complex plane you got a whole bunch more. [laughter] @2025 And that's a very rich source of ideas. If you clip, clipping things means that no matter what you put in, the result can't get louder than between -0.2 and +0.2 in this case. Which means @2040 we have a very... what's the right word? ... We have a very "predictable" instrument in terms of what kind of amplitude will come out. All right, that's good, or that could be good. In particular if you got the ... @2055 well this is the thing that you get if you put an electric guitar in an amplifier and overdrive it. The cool thing is the amplifier can't push the tubes harder than full on and full off. As a result there's this sort of basic loudest thing that you will get out of the thing no matter what you do @2070 on the incoming side -- including feedback. You can do feedback ... if you put it through a linear system, could eventually grow without bounds. ... If you put it through something that's being clipped, you know it will stop somewhere, and then you will get something @2085 that hopefully is at the level that you want. It's still true, it's true of all these things that -- particularly true of this one -- @2100 that we still have this nice timbre control which is:[musical tones] louder and gives you a sharper timbre and furthermore, gives you interestingly enough, a louder sound. @2115 So, even though the difference in power between this [musical tones] and this is tiny. [musical tones] This is actually louder than that. Not a lot, but substantially, and the reason @2130 for that is psychoacoustic mumbo-jumbo. Specifically, the loudness at which you hear something is in some sense, the sum of the loudness of the signal in all of the different critical bands that it has energy in. @2145 And so even without substantially changing the energy of the signal, it can just spread the energy out over more critical bands. The result will sound a great deal louder -- because putting a quarter as much energy in four different bands is much, much louder than putting the entire thing in one band. @2160 So bandwidth makes loudness in psychoacoustics. And here what we're doing is we actually have an instrument which changes loudness. [musical tones] -- More by changing band width than changing the acoustical power of the signal @2175 that you are listening to. So if you have ... if your bassist isn't loud enough, you don't get very far by just pushing the bass up, because you just hit the limit of your cabinet. But if you @2190 add some overtones, then the bass can be a great deal louder. And if you're mixing music and you want the bass to be audible, even if you're playing it on a boom box, don't just push the fundamental, because it won't come out that speaker. [laughter] Add some harmonics, @2205 that will make it loud. And people will think, "oh, that deep bass" even though the actual low frequencies which are the actual fundamental and the low harmonics of the bass aren't even present. Same thing is true, even more so with ear buds. All right. @2220 Learning how to do that is an art, not a science. OK. [musical tones] So there's that. ... Questions about this? OK. Now, I'm going to get a little more mathematical. @2235 So this was all experimental stuff, with stuff like absolute value and clip, which by the way are functions which are not pleasant to approximate with polynomials that are not analytic functions. @2250 But now we are going to take the opposite approach altogether and start talking about polynomials because they are the things that we can analyze the most easily when we're talking about waveshaping. So the first example of a polynomial that I showed you was just squaring, @2265 the first nontrivial example. And this was the example, or this was the thing that allowed you to just... @2280 It takes the thing and bashes it up an octave. OK, so this is an even function, so it had to get bashed up an octave. An odd function would be ... take this thing and cube it. So we'll take the square and then multiply it by @2295 the original signal again, and then it's cubed. In fact, while we're at it, let's make a few of these. @2310 All right. So now the results, the outputs of these multipliers are going to be the squares, the third power, fourth power, fifth power, and sixth power @2325 of the original signal. Now raising this signal to the sixth power could give you a huge amplitude, except for the fact that this oscillator gives you values between -1 and 1. And no matter @2340 what power you raise that to, it's still going to be minus one and one (positive power, anyway). And so, let's see. Let's turn this on and turn up the bass and [musical tones] so here we go. @2355 So here's the first power of the signal which is just itself:[tone] Here's the square: [tone] quieter by the way. Here's the cube. [tone] They are getting quieter. Why are they getting quieter now? @2370 I'll show you. There's the fourth power, fifth power. You know what? They are getting quieter at the point where I want to get. ... Oh, duh! -- I'm not doing what I said I was doing. I just want to make this full blast so they have all the same amplitudes. I'm sorry. @2385 So that was 24 ... That was a _quarter_ going into there and so a quarter to the fourth power was going to be a tiny little signal. Now I am going to try this again, but I'm going to turn it way down. OK. So the original signal: [tone] @2400 Square: [tone] Cube: [tone] OK. Fourth power: [tone] Fifth power:[tone] Sixth power: [tone] @2415 Seventh power: [tone] OK. So, seventh power compared to third power is this:[tone] All right? So if you just had something that could freely move @2430 between the different powers of the function you could have a nice timbre whammybar. All right. However... Oh and let me quickly graph what happens when you take ...Let's take a look at the seventh power of the thing: [tone] @2445 So that is this thing. Now if we look at it we will see, huh? Student: You've got an extra connection ... over to tabwrite~ Miller: Oh. Thank you. @2460 I don't want that trace there. There we go. I was getting worried because math tells me that this thing should still be between plus and minus one, it was reaching outside there. And when that happens usually you're doing something wrong. OK. So, @2475 here's the seventh power of a sinusoid, and it is sort of looking like a pulse train, where every other pulse is negated. And in fact if I take an even power of it, it looks like a pulse train again so, accept that, @2490 now every other pulse is going the same way. Going in the positive direction -- every pulse is going in the positive direction. That is the even/odd thing again. @2505 Furthermore let's do this. ... Actually ... I'm going to listen to this for a second: [tone] As I mentioned, or as I showed with the clipping operation, clip. @2520 OK. So, here: [tone] ... As I change the value, or as I change the volume or the amplitude of the sound that I am clipping that changes the timbre. [tone] That is going to be true in general of ... Non-linear functions. So here too, and I'm really scared of this one. @2535 But here too... [tone] Whoops sorry. [tone] Still hearing this one. Hmm. Turn off. There we go. [tone] @2550 Well, really it is not so clear. [tone] But in fact the higher harmonics are somehow growing at a steeper rate than the lower harmonics. I can show you that to you better @2565 a little bit later when I show you some more math. So this thing does have a varying timbre but the problem is that the amplitude is changing in such a way that you don't hear the timbral change because the amplitude is dominating it. @2580 There might be ways you could deal with that. You might be able to predict what amplitude you should get and divide by it and I'll let you think about that. So now to go back to the equations and pictures for a second. @2595 So this is the waveshaping chapter and then ... A little bit further down here is an analysis of what happens @2610 when you actually take powers of the signal. Oh yeah here's me figuring out what happens when you take two different sinusoids and square the sum and show @2625 the intermodulation products. But, I already talked about that. Here now is, is it? ... Yeah, here now is what happens when you just take a nice sinusoid, cos(omega n) omega) --@2640 where n is the number samples that have gone by -- and start raising it to powers. And this is just algebraic idiot's delight. The first one is cosine times cosine is (a half plus a half cosine double) right. @2655 And in general the cosine of A times the cosine of B is half (the cosine of the sum plus the cosine of the difference). And so here what happens when you cube it you can think of multiplying the square by the original one. @2670 And so you have to multiply this term by this term and this term by this term separately and then add them. So this one just gives you a half of cosine omega n again. Which @2685 to confuse the matter I wrote as a quarter of the cosine of the minus omega 'n' plus a quarter of the cosine of the plus omega'n'. That's because that's the way to write it down so that the pattern will come clear later. And here the cosine @2700 of omega 'n' times the cosine of two omega 'n' that's the cosine of omega 'n' plus the cosine of three omega 'n' and that generated the other half of this one. The other quarter of cosine of omega 'n' and one quarter times cosine two omega'n'. We've all seen Pascal's @2715 triangle right? We're doing Pascal's triangle in harmonics. OK. So the next one is, all right so the lowest frequency is minus two omega 'n' and the highest frequency is plus four omega 'n'. It's centered around omega 'n' and not around zero. All right. @2730 And now we have 1331 all divided by 8. Those are the probabilities of getting zero one two or three heads in three tosses. OK. And meanwhile the signals that have those amplitudes -- @2745 instead of probabilities -- are -2, 0, 2 and 4 times the original frequency. This is the fourth power so it's an even function. So we're seeing, in mathematics, what I told you before by handwaving. Which is: That you only see even frequencies @2760 when you take the even function. And now the next one, not to belabor the point -- that's as far as we are going to go. Divided by 16 now and it's -3, -1, +1, +4, and +5. @2775 So one interesting thing about this is if you look at the highest frequency, which occurs all the way to the right. The frequency of the highest harmonic is going up one step each time you raise the thing to a higher power. @2790 Now someone I'm not sure who but it might have been Marc Lebrun in like the early 70's, thought about this and realized that, if you were smart, you could @2805 just isolate these individual frequencies by picking up the correct polynomials. In fact the correct polynomials were easy to think of because they had been known for I don't know how many hundred of years. @2820 They're called "Chebyshev polynomials." And Chebyshev polynomials are what you get if you say, "I just want the cosine of five omega 'n' and I don't want this other stuff." So how am I going to get rid of it. @2835 Well it's easy. I'll get rid of this one by subtracting out twice this whole thing. So instead of taking x to the fifth, I'll take x to the fifth minus twice x to the fourth. And that won't have any of this. -- @2850 Oh wait, I'm telling you the wrong thing. There is no cosine four omega 'n' here. There's only three. OK. So there's five, three which comes in twice and then one which comes in twice. So we can get rid of the three. Cosine three omega term by subtracting @2865 some suitable multiple of this (which I can't do in my head.) And then we can even get rid of the cosine omega 'n' after that by subtracting a suitable multiple of the first one. So there is a polynomial out there which is something times x to the fifth plus something times x cubed @2880 plus something times x. Which has a property that you put a cosine in to get exactly the cosine of five times it out. All right, and since seeing is believing I made @2895 a patch to do that. Here's a picture of I believe the fifth one. This is a polynomial that I stuck inside a wavetable. How would do you do that? Its work but you can look inside the patch to see how I did it. @2910 And I'm just using tabread4~ -- your old friend -- to read values of this polynomial. And then here is nothing but a nice oscillator going in times an @2925 amplitude control which I'm going to call the "index." And if the index is one that is to say if I just put this thing at amplitude one -- ooh, there's stuff here going on, that I'll explain when I have the actual patch out. ... Then out will come the fifth harmonic. @2940 I'll get the patch out and show you what happens. If I can figure out how to get the patch out. ... Here. So the patch is in the tedious but essential help browser: @2955 We're in Chapter 5 so they start with E and it's going to be the Chebyshev.pd . By the way this is all stuff I think that you've seen. @2970 Here it is and here is the sound of, let's turn it all the way up, here is the sound of whatever this is. @2985 So what we're doing is we're computing different polynomials to put in the table and I am realizing now that it's too bad I didn't also have a linear polynomial. Let's just draw one. @3000 There's the original pitch. If I had actually made the patch that would be a cleaner sound. There's the oscillator going through just the function y = x. Here is the thing going through a suitably designed parabola ... @3015 So before you saw more sort of just thoughtlessly square this thing in order to give you the octave. Here this is the polynomial (x^2 - 1)/2 -- which has @3030 the wonderful property that it goes between +1 to -1 to +1. And you can compute it if you want but if you apply that to a sinusoid you will get the second harmonic term and you won't get the DC term that you got when you just squared the thing. @3045 If you just square the sinusoid you get double frequency and then you get DC term. If you just subtract the appropriate thing from the thing then you get just the second harmonic term and nothing else. @3060 So now I have polynomials that will take an oscillator, just take a pure sinusoid, and make pure harmonics out of it. Furthermore (Let's go get this one.) ... @3075 Depending on the amplitude of the sinusoid that you put in you get different timbres. So what I told you is only true in fact for a @3090 unit-amplitude sinusoid. Of course if I put in a zero amplitude sinusoid I have to get out nothing. I get probably some DC I'm not surem, but no sound. And in between I get a range of timbres which [tone] sounds like that. @3105 OK. So we're starting to make computer music here. And similarly for all of the others this is an even one which therefore will sound an octave up, ... @3120 and so on like that. So this is what in the early 70's people thought would revolutionize computer music. Because no one would ever need to do anything besides this for building timbres -- @3135 Until people realized that actually static timbres aren't interesting. It's variable timbres that are interesting. And furthermore, although you get to control exactly what you want this thing to be when you take it all the way to the end like that <>, you don't really @3150 get to specify in addition what it does on the way up there. It just does whatever that polynomial does and there's no choice about the polynomials: There's exactly one polynomial that will give you that thing at the end. All right. So in fact you have to be smarter than this if you want to make timbres @3165 that actually vary the way you want them to. And how smart do you have to be? You have to proceed by special case. Everything is a special case from here on out. Particular kinds of functions, and particular ways of using them, and combining different ones of these @3180 will be useful for making different things. And that will be something that I can't really even give you a summary of. It's just a whole field of inquiry. .... Questions about this? Yeah. Student: So would we @3195 be able to see physical modeling in these terms? Are there polynomials or functions that would be able to... Miller: Oh boy ... Student: I was thinking of one synthesizer that I used to have where you could change the modulation and have a waveform definition pattern. @3210 Really, it would sound actually like an paranormal entity. It was just an oddity. Let me you what, a really breathy sound? Miller: Hmm. Student: Sounded like it was breathing. It's got this similar thing to... Miller: Mm-hm. That might have been. Was it a Yamaha DL-1? Student: @3225 No it was a... Miller: No, you're not old enough to have one of those. [laughter] Student: I know the DL1 but it was a Korg Platinum synthesizer. Miller: Oh that one, I don't know. Since Yamaha @3240 licensed something from Stanford, I don't thing Korg was actually using so-called physical modeling. Although, it really wasn't physical modeling in the first place. Student: OK. Miller: So I fact I don't know what is was. Yeah. @3255 But to be honest that Yamaha thing, that's the original synthesizer that described itself, as physical modeling, didn't work at all. It was a completely different principle of operation. Student: Mm-hm. Miller: And so this is the @3270 easiest way into making varieties of timbres. There are other interesting but more complicated ones too, and you can spend decades learning them all if you want. Miller: OK. So, there is that. @3285 What I want to do is make another observation. OK. So, just continuing to look at special cases, right? So what are some good functions that you could think of trying that aren't polynomials? ... Oh! So the problem with polynomials is this: @3300 You don't see it because I've only shown you the part of the polynomial that happens to be the good part of the Chebyshev polynomial. Of course, this is a fifth degree polynomial. It's leading term is x^5 and so it's going to shoot @3315 out of the screen just as soon as I get a few tenths of a point to either side of the part that you are looking at. All right. It's coiled up tight right in that little rectangle, but that's the only place where it is well behaved. @3330 OK. So polynomials, even though they are simple to think about, are actually very ill behaved in terms of the amplitude that you get out when you start putting freely varying amplitudes in. That is almost the @3345 opposite situation from the clipping functions. I don't know if they even have names, but functions like clip~, where no matter how hard you punch the input, the output is limited to a specific kind of value. And there the only thing is, that is not @3360 really an analytic function. That is to say, it's not describable very well as a power series, so I can't really tell you by using this kind of mathematical analysis what it's going to do to the signal. In fact, I don't have anything beside hand-waving sort of descriptive analyses of what clipping does @3375 to signals. There are analytic, that is to say easy-to-approximate-by-polynomial functions, which do reach asymptotes -- like arctangent. @3390 But take the arctangent function and take the first ten elements of the Taylor series, and then plot them, and the result will not look like arctangent. It will look like arctangent @3405 in the neighborhood of zero and then of course, since it is a tenth degree polynomial, it will shoot off to plus and minus infinity. Oh, sorry. The terms are all odd so it would be nineteenth degree polynomials. So...[laughter] Miller: So as soon as you get out @3420 a very little bit past the well-behaved portion, it's going to blow up horribly, right? OK. So how do you get something? -- Actually let's do the simplest analytic function, which just blows up horribly anyway, which is the @3435 exponential function: Miller: It turns out that the simplest -- well the simplest analytic functions are polynomials -- but the exponential function is a good one to think about because its turn out you can analyze what happens when you @3450 send signals through exponentials; and decent well-behaved things happen. So let me show you that. Let's see. Actually, I'm going to cheat and show you @3465 this off of the prepared patch rather than build this for you. Because I don't want to build, well. @3480 There is an exp~ object so you can just exponentiate anything you want. But there is stuff to do in order to exponentiate things well, as just opposed to just exponentiating them. So, how do you exponentiate something well? @3495 So, here's a picture of an exponential table. Since we're doing computer music, we're going to run the thing through a digital analog converter. So we would like things to be bounded, and the way to make exponentials be bounded is just look at the part of where the exponent is negative. @3510 And then it's all going to vary between 0 and 1. So this is the function e^(-x) graphed from 0 to 10. So, down here if you could see it this would be e^(-10), which is tiny. And @3525 now what we're going to do is use this as a waveshaping function, but we're going to be smart about it. And the smartness is this: Rather than to look in the middle of the function, where the thing is about e^(-5) -- @3540 I mean we could do that. We could have a waveshaping function, and the thing would be e^(-5) which is, I forget ... it's maybe a hundredth or so ... so we'd multiply the result by a hundred so we could hear it. And then you would increase the "index", @3555 that is to say increase the the amplitude of the sinusoid we look up. ... And then we would start going up this thing on one side and then we would start clipping madly or do something bad ... Anyway it wouldn't be correct. @3570 Or at least it wouldn't be the exponential. Also the amplitude would grow in some very unruly way. So, rather than do that, the smart thing to do here is to take the sinusoid but actually don't just center it around zero -- because then it'll @3585 go negative and that will either be clipped or be growing quickly, depending on how you realize it. But do the following real simple thing: Have the sinusoid be arranged so that it reaches from zero to whatever point you wish. @3600 So now what's going to happen is rather than look .... Let me show you this in a picture: OK. So going back to, where did it go? Here, going back to here. @3615 So these functions are all being read around the middle of the function. The simpler example was just squaring. Oh, wait, that was the other window. @3630 Here in this wave shaping example, we're putting a sinusoid in and a sinusoid is variously positive and negative. But the result is centered around zero. And were just leaving it centered around zero. Not moving that center as we change @3645 the amplitude. When we change and when instead we use ... @3660 When we use a function like this its smarter to have the thing grow from the left-hand margin of function out -- so whatever the amplitude the sinusoid is we will adjust the center of it so that it reaches from zero @3675 to somewhere, instead of just reaching between plus and minus something. So instead of reading around the center we'll read starting here, around whatever point we need to read around to get it started here. How do you do that? You just take @3690 the oscillator and add 1 to it. So then instead of ranging from -1 to +1 like the oscillator does, it will now range from 0 to 2. And now it would be @3705 correct at that point to divide by 2, so it will range from zero to one but I'm throwing care to the wind at this point. And now the index is again a number -- it's in tenths now -- which controls the amplitude of that result before we go @3720 reading it in the table. At some point I want to remember to tell you why I'm doing this... But this times 100 because this is in fact 1000 points @3735 representing ten. In other words I have ten points in the table for every unit of input for the exponential function (so that when I do the look up it will be decently accurate.) So this is correcting for the units at the table. And then we will read it @3750 out of the table and then we will start graphing it. So let's graph it: Here's the spectrum. Oh, you saw spectra ... This is the spectrum of what you get when you have a zero amplitude reading into this, which is therefore putting @3765 out solid value of one. So the index is zero; so this oscillator is multiplied by zero; so zero is going in here. So the result is 1 -- whose waveform looks like @3780 that, which you don't see, and whose spectrum looks like a peak at DC, zero frequency. And then as we increase the index now what happens is: @3795 When the original sinusoid is at its negative peak, (so that when adding 1 you get 0) then you get 1 . But meanwhile as it @3810 reaches out to wherever it goes it goes down to some which will get closer and closer to 0. Furthermore the hotter you make the signal going in, @3825 the less time it spends in the neighborhood of the peak here and the more time it spends out here in this neighborhood where everything is almost zero. And hence the skinnier @3840 this pulse gets. So I think this is the good way to make a pulse train in computer music. But there are other ways of making pulse trains. This is a pulse train; you can in fact compute these @3855 amplitudes and they turn out to be Bessel functions of the second kind, if I'm giving you the right nonsense. But basically you can look at them @3870 intuitively and see that what's happening is there's a peak here and the energy is moving out so there's an increasing band width. Furthermore, as you tweak this peak, the peak itself lasts @3885 less and less time. And so in a very non-rigorous way of thinking. the frequencies present in that should be growing linearly as the peak gets squeezed which is to say linearly as this number goes up ... @3900 if I'm not doing that wrong. So as this number goes up the energy gets spread over progressively more and more hormonics. And so to listen to it you get nothing if you @3915 send the index to zero because it's all DC you can't hear it. And then you add index you get this: [sound changing. Computer musicians hear that @3930 and they say oh that's a brass tone. And actually if you look at how brass spectra change as you put more and more pressure into the brass instrument they do actually spread out @3945 in this sort of way. See if we can see any more harmonics ... Well, you probably can't see the harmonics, while I'm changing it very well. ... @3960 So the basic idea is the harmonics will spread out fatter and fatter and to a certain point you will not @3975 hear the thing get quieter even though the power of the signal is dropping because it's spending less of its time away from zero, because of the psychacoustic affect I told you before -- the energy is spreading out into more frequencies. So up to a certain index @3990 you actually hear a decently nearly constant amount of sound. That will quit being true when I get up past two or three hundred here. In fact, @4005 I decided to protect users from this. But now I'm going to unprotect us. Saying let's just go all the way up to whatever value we want. And now we get that: [wider range of tambres] . @4020 And then, eventually ... All right, let's just change the scale. [even wider range of tones] @4035 Ta da. That's something that people used to do with low-pass filters. @4050 They'd take a standard analog synthesizer kind of waveform and send it into a low pass filter, and you can get that kind of effect. Here in computer music land it's easier to get it this way. Although, people still reach for the analog way of doing it b@4065 anyhow because it has a particular quality of sound that makes people nostalgic for the 50s and 60s, 60s in particular. OK. But this is now [tone plays] a very simple but very effective way of making one collection of timbres @4080 using waveshaping. ... Questions about this? ... Yeah? Student: Is there a mathematical description of what's happening as you increase the index? Miller: Yeah. It's even better than that. There's a couple pages of mathematical analysis of what this should do. @4095 And what I can tell you about that is this: The Taylor series for the exponential has this wonderful property that for very small... OK, so everyone knows Taylor series for e^x ... right? Student: @4110 No. [laughs] Miller: OK, I was kidding. I know. 1 + x + x^2/2 + x^3/6 (6=3!) + x^4/4! + x^5/5! @4125 and so on. So the denominators are going up crazily so that by the time you get to... . Anyway, the coefficients of the terms @4140 go off very very rapidly. Now one interesting thing about that function is that if you say, "What's the loudest monomial in that series?" @4155 So if you put in zero you get 1 plus a bunch of 0's, so the loudest thing is the 1. "If you put in values between 1 and 2 -- If you think about it, between 1 and 2, x is bigger than 1 < but x is bigger than x^2/2 >>. @4170 So between 1 and 2, x is the dominant term." Between 2 and 3 x^2/2 is the dominant term. Between 3 and 4 x^3/6 is the dominant term ... and so on. @4185 So you can think of the Taylor series of the exponential, as a sort of polynomial whose degree goes up as you push the input up -- in the sense that the dominating term going further and further out the series as the value of the input is going up. @4200 This is a good way of thinking about it -- for positive numbers going up. (Negative? ... stranger situation -- because they're canceling each other out.) So in one way of thinking then, the bigger a number you put in, @4215 the higher harmonics you're going to get. ... Because as I showed you before as as you start raising the cosine or start raising a sinusoid to higher and higher powers you get @4230 those collections of terms that were spreading out in frequency. That was this picture here: Whoa, come back. Oh, where did I put it? @4245 I think I put it here, yeah. No, wrong, it was just here. This stuff: So see how the bandwidth @4260 of this thing is going up as you raise it to higher and higher exponentials. Well that suggests that the exponential, if you expedentiate something the you'll get a mixture of these things and whichever one of these is @4275 dominant will be the loudest thing in the mix. So you should expect to see something whose band width increases linearly in fact with the strength of the signal that you're putting in. @4290 Hmm ... that's not quite right. But I won't tell you why it's not quite right. (The bandwidth of Pascal's triangle does not go out linearly, it goes like the square root of n, because it's the standard deviation of a collection of coin tosses.) @4305 But at any rate, you see these things: Each weighted according to how important this term is in the Taylor series. That would be true for any Taylor series -- you can think of it that way. And for the exponential in particular -- since it @4320 has this very simple behavior of which term is the most important -- you just get a widening and a flattening of the thing as the signal gets louder. And that's exactly what you saw here: @4335 Pushing this coefficient up made the thing get wider. Now, I'm pulling a fast one here because of course that analysis assumed that I was centered around zero. @4350 In fact, what I'm doing is pushing the thing over so that it only reaches zero at the loudest point. But in fact, the exponential function, if you slide an input over, you're simply rescaling the output. That is the quality ... that's what @4365 exponentials are. They are the same as themselves rescaled when you move to the left and right. And so, in fact that I am sliding the thing over in order to control the amplitude is simply rescaling in the perfectly appropriate way to get the thing. @4380 Not only to have the bandwidth property that I told you about, but also to have a well behaved amplitude as the index of modulation is going up and down. So at this point, the exponential should your all time favorite @4395 waveshaping function to try out. Except for this one kind of inconvenient thing, which is that... [tone] Miller: The overall power of the signal can be rather small @4410 if you average over the entire length of the period. That is not going to be a problem if you have good audio equipment. But if you don't have such good audio equipment, you won't necessarily @4425 be able to reproduce these functions as well as you would be able to reproduce something whose power was distributed nicely in time over the entire wave form. So things that are pulse-y, are great until you put them through a boom box, and then -- They are not quite @4440 so great anymore. So this is good thing for the studio but you might want to mess with phasors or something before you actually put this on a record. Do people use the word record anymore? [laughter] ... I don't know. Never mind. OK. [laughter] Miller: @4455 This is closely related ... So what were the other Taylor series you all were made to learn in Calculus besides exponential? ... All right? Student: Maclaurin. Miller: Oh, well, the Maclaurin series. They are a different series altogether. @4470 Didn't you have to memorize sine and cosine as Taylor series? Student: No. Miller: No. No one took you over those coals, did they? OK. [laughter] Miller: @4485 All right. Yeah, and then there's De Moivre's theorem ... if I've got the right neme... which tells you that ... Sines and cosines are nothing but exponentials except that they're exponentials of complex numbers in linear combinations. And in fact, @4500 the same kind of reasoning I show you here should suggest also instead of using an exponential as a look up function, you might be able to use sine or cosine and get something like similar results. And in fact you do you @4515 and it's even better than that because you're going to get results that you have heard before. Because... Am I going to explain this? ... Yeah. Because you can reduce mathematically phase modulations @4530 to waveshaping by functions that are sine and cosine. So let me just demonstrate that: OK. You've seen basically three classes of functions @4545 I think. You've seen things that consist of linear segments -- that's the clipping function and the absolute value. Those are hard to analyze in terms of frequency content but are easy to describe in terms of waveform. So they're good pedagogical things. Also @4560 the clipping thing sounds familiar because you've all heard overdrive. -- Polynomials. And then finally transcendental functions which have Taylor series which therefore can be approximated or thought of in terms of polynomials. So @4575 the two transcendental functions that we're going to mess with is first this exponential and second, let's go back to the one that I'm building here: @4590 What we just saw was E5 and E6 here. Now I'm going to quit using the examples and start just exampling myself. OK. So here I'm going to save this and do a save as and this one is now going to be three sinusoid. <> @4605 OK. So here what we're going to do is throw out this nice polynomial machine and do something much simpler which is @4620 say "cos~" And now we have, yeah -- you heard DC that's the sound of DC right there. @4635 All right. And now if I turn the index on [tone] you get this kind of sound. And that sound should be strictly like frequency modulation. Because basically it's essentially the same thing as frequency modulation. All right, @4650 now cosine is an even function which implies that what comes out will be an octave up because yeah, so there's the original [tone] @4665 and here's the cosine [tone]. It's an octave higher because it has only even harmonics. If you want to change that you just do this: Why don't we add some number to that? And since we have about one minute @4680 I'm not going to. Oh, since we have one minute I'm going to really be fast and loose and just duplicate this one. Now we're going to add. @4695 I'll have time to explain this better next time but if I give you a quarter cycle through then it's the... @4710 actually it's -sine instead of cosine. And now I'm using an odd function so I'll get the odd harmonics. And in general for values between here and there we'll get mixtures of the two. So now we have @4725 something like this: [tone] -- which is more FM-ee actually than it was before. OK. That's something you know ... You've all heard that sound probably That's the old FM sound that we heard @4740 over and over again in the seventies. I'll go back to this example next time because I haven't really described this in enough detail to make it clear what's going on. ...