*** MUS171 #03 01 11 @0000 OK, just to respond to one question. Especially if you have a PC, if you turn pd on and you don't get that nice @0015 computer sine tone, but get a beeping on and off sound like a truck backing up. That is because PCs have horrible audio latencies and you will need to have this delay number up @0030 to some nice high number like that. Or maybe even one time with a, what was it, Vista machine. I had to do this on the laptop to get the thing to operate correctly. So @0045 lesson one, don't use Vista, and lesson number two is if you don't get a solid audio output then that's a good place to change something. Increasing that will make the audio more robust, but will make everything react more slowly. @0060 So it won't be as pleasant to use. Another thing that you can do if your audio insists on hating itself, is @0075 you can ask it not to use audio input. You can do it that way or you can do it by saying, "Hi, I have zero channels of input." And that will @0090 run pd normally, except that whatever audio input device you have won't be getting used in your -- you haven't used audio input anyway yet, so it doesn't matter. But when you do you will, you'll make your computer's life slightly easier by not using that. @0105 But on the other hand it would be nice to be able to use audio input because it will show up later in this class. So that would be a temporary measure to try to improve things if you're having trouble. So yeah, put some horrible number like 100 or 300 up there. @0120 This is in PCs, Macintoshes don't seem to have this disease. Although Macintoshes do want this number to be at least 20 most of the time. All right, questions about the homework. @0135 Three of you came up before class and had specific kinds of things to ask about the homework assignment. So it seems like it's a good moment to see if you have other questions that I could just answer to the group. But there are office hours after class, too. So if you don't @0150 want to ask it in front of everyone else just come up and see me after Yeah? Student: Why are you multiplying a 220 Hertz oscillator by a lower frequency oscillator?@0165 Miller: @0180 OK. So yeah, so why do you have to multiply two oscillators? So this gets back to the example from last time, which rather than dig up, I'll just do it again because that'll slow me down a little bit and make me explain it. @0195 So what we'll do is we'll make an oscillator. What I'll do is I'll make a nice 440 Hertz oscillator which we'll be able to hear. To start with, I'll fix it @0210 so that you just hear it without any control at all really. [tone] Miller: @0225 All right. So this is the way to play an oscillator without losing your speakers. Now what I'm going to do is try to respond to you by controlling the amplitude, @0240 which is this: Multiply this thing as a signal. That means with a tilde object by some other oscillator. Let's make the amplitude -- all right. I'll just type the numbers in to start with. @0255 So here's changing amplitude. All right? And here is changing the amplitude real fast. @0270 I think this is what you're asking. It doesn't change the amplitude. It changes the frequency. Now this is psychoacoustics, which means it's not science really. [laughter] Miller: What I'm doing here is @0285 I'm changing the amplitude of the thing 330 times per second. You could think of that as a time varying amplitude, but it's too fast for you to perceive. But now you can use a different fact, which is that the product of two sinusoids is the sum of two @0300 other sinusoids at different frequencies. So in a confusing way of describing the situation, you can multiply something by a signal to change either its amplitude or its frequency, depending on how you do it. If you @0315 multiply it by something that's varying slowly in time... Let's see. Let's shut this thing up. If you multiply by something that's varying slowly in time -- that doesn't have a physical definition by the way, whatever that means -- then you will hear the thing changing in amplitude. @0330 If it's changing quickly in time, especially if it's changing repeatedly and quickly in time, then you will hear something else, which is new frequencies being introduced, which is one of the possible things that electronic musicians call modulation, although @0345 it's not the only one. Does that answer your question at all? Student: Yeah. Because my original conception of the oscillator object was with the number afterward. @0360 Because you know when you first did it you just changed that number/frequency. So I was having a hard time understanding in my head the difference between changing frequncies and changing the amplitude. Miller: Right. @0375 OK. So maybe what I should do also while I'm at this is get set up to graph this thing again. Sorry. This is repetition, but I don't think it's bad repetition. I'm going to use the "Put" thing and click on "array." It's going to have a name like... @0390 Let's see what I'm going to call this "seeme". OK, and I'm going to have a second -- ooh, how long am I going to make this? I'm going to make it a 1000 samples to start with. @0405 I like points, so I'm going to say, "OK." Oh, and I've got to fix it so that it goes from -2 to 2 because @0420 I fixed the bug last night, and if you download you will have the bug-fixed version now, on the test version, if you do, I haven't fixed it here yet. So you're going to be cautious. I made the table now which @0435 means I need a button. Sorry, I know you've seen this all before. And I need to tabwrite~. @0450 It needs to know the name of the table it is going to write into. It needs two things. It needs a message to tell it to write and it needs a signal... And nothing happens, why? Because I turned it off.@0465 [tone] Miller: There, oh, look at that, isn't that cool? That's not a sinusoid times another sinusoid in the way you'd look at it. It's a sinusoid plus a sinusoid. But that's because I chose this thing funny. @0480 Here's something where you can sort of see it, I think. [tone] Miller: Yeah. And now, you hear those gaps in the sound? @0495 That's because I have a very slow processor. And I have to add to my delay. OK, here we are. OK. So now what we see is that if you can imagine there's a sinusoid being multiplied by @0510 this other sinusoid. This one is going at 440 cycles a second, and this one is going 10 cycles a second, and the half cycle's about this long, if I can use the mouse to point to it. What you hear right now is the nether region @0525 between beating and hearing two pitches. I hear two pitches, but I also hear beating at the same time. Just, I don't know what, that's getting on the wrong side of the uncertainty principle. But if you want to only hear the two tones, make this number at least 30. @0540 [tone changes] Miller: And then, it looks like a sinusoid with changing amplitude, like your ear resolves the two sinusoids. The sum of that thing is maybe two different pitches that are about a musical @0555 second apart. Yeah? Student: Is there a way to keep the volume from getting so loud, for headphones to protect your ears? Miller: That's what this @0570 is doing. (The *~) Student: Yeah I know, but just something about that _really_ keeps the volume from blowing up. Miller: OK. ... So do this. Student: You go smaller? Miller: Yeah. Make it a hundredth. Oh yeah. So it's acoustics again. .1 is -20 dB. @0585 .01 is -40 dB. Student: OK. Right. Miller: Now the thing about that is, if you're having to pull it down that far, what's going to happen when somebody sends something of magnitude 100 @0600 into here? You're still going to get one and you're going to get a nice loud sound that you don't like. So you can also, if you want to, protect your ears by adding a clip object here. @0615 Maybe from -10 to 10. I'll show you how to do this in more sophisticated ways later, but now what we've got is... @0630 Actually, this is when I can turn the volume up in the room. (Oh, I don't hear a thing because I turned it off anyway. ...) OK. So now if I put out something with unit amplitude @0645 what will come out is -40 dB, and furthermore, even if I make a horrible mistake and the numbers here are in the thousands, which does sometimes happen -- especially when you have a divide (/~), this is going to happen -- then clip it to some reasonable range. @0660 And in this case, if we clip it to between -10 and 10, and then if we divide by 100, then we know that no matter how crazy the thing is that we put in, it's not going to be outside of the range, plus or minus a tenth, which might be a safe headphone range @0675 for the computer. Rather than do that, typically what I do is I make sure that the volume on my amplifier is down so that no matter how stupid I am making the patch, @0690 it can't make more than a certain full blast volume. So my way of protecting my ears is -- which is important for musicians, especially -- make the loudest noise that you care to make -- For instance, get out your test tone. @0705 Do this. [loud tone] Miller: @0720 And get this thing to be as loud as it's ever going to be. [very loud tone] Miller: And verify that that isn't unduly painful. So I didn't leave it up there for long, but that right now, what you just heard is the loudest thing that's going @0735 to come out of these speakers, period, with the audio system the way that it's set up right now. And that way, when I do something stupid, like take my white noise generator and stick it right into the jack, it won't make me jump out of my chair. @0750 I probably emphasize this more than it's really necessary to emphasize, but computer musicians surprise themselves a lot by turning things up because they don't hear them, turning them up because they don't hear them, and then turning them on and discovering @0765 that they've, meanwhile, that they've pushed them quite a few too many dB. Maybe some of you have had that experience already. OK? So that's sort of survival technique. Let's see, what else here? Yeah. @0780 That's about all I should say about that. Other questions or comments? Yeah? Student: Still having problems not getting any sound. Miller: @0795 OK. Did you, do you have the 42 working version or the 43 test version? Student: 42 Miller: OK. Good, so problem number one isn't happening. @0810 You have to have DSP on. In other words, check the pd window. And see that this, ooh, it's off for me right now, but that has to be on. Student: Make sure the patch is not in edit-mode. Miller: @0825 OK. Yeah, it's good. Yeah. All right, then what else could be wrong? If you're actually clicking this, oh, someone said make sure the patch is not in edit mode. Then next thing is obviously if I did @0840 something like misspelled this: (/tabwrite~ instead of tabwrite~) then it wouldn't happen. But then I would get an error message on the pd window, I think. Miller: @0855 Oh, yeah, thank you. Oh, that is interesting. [tone] Miller: Yeah, there we go. So look on the pd window and see if there are any helpful error messages. @0870 Yeah, OK, show me after class, it's got to be something, it's probably something that I'll have to tell you all about Thursday because it's probably @0885 something important that I've forgotten to say, but I don't know what it is yet. OK. Other questions? It's all good. ... Yeah? Student: Is the syllabus available through WebCT? Miller: No, not as far as I know. @0900 Why, can you not get the syllabus? Student: I was looking there for information. Miller: What's happening? Student: The syllabus wasn't there. Miller: Yeah, WebCT should just have a pointer to the syllabus link. Student: OK. Miller: Yeah. @0915 That's the thing. I haven't actually learned WebCT yet. So if you're using the chat thing to try to chat with me I probably didn't see it because I'm not cultivated in that way yet. (laughs)OK. @0930 Other questions? OK, next things to talk about. So, again, @0945 there are two things, one is pd lore, and one is actual signal processing knowledge, which I'll be developing simultaneously. So a bit of pd lore now is going to be more about messages and doing computations @0960 using messages, which is to say the sporadic control things that are not audio signals that go down the wires that are only one pixel big instead of two pixels big. So this is a control message here, and this is a signal message here, @0975 or signal, if you like, that's a continuously flowing piece of audio. What I want to tell you now is that -- oh, so, first off, one thing that you know from last time is that you can take an oscillator and control it. Whoops (puts a message-object). @0990 Sorry - that's for later. Take an oscillator and control it with a number box like this, and then you've got a patch operates like this.[tone] Miller: @1005 You know what... is that loud enough for people to hear? Or should I turn it up? All right. So what's happening now is instead of having @1020 the oscillator be an oscillator space and then a number to initialize the frequency to something, I'm running a number into the oscillator, which is in the form of messages. The oscillator's input actually can take signals, or messages, either way. @1035 But it wants numbers. These are messages, and you can tell that among other things by the fact that it's a one pixel wide as opposed to a two pixel wide one. And that's just the thing about number boxes, they don't know about audio signals, there's just nothing really they can do with them. @1050 OK. Next thing is, if you want to do something like, say -- oh, let me do it this way .. If you want to fix it so that you can predetermine -- @1065 So that you can predetermine some number to put here, you can use another thing, which is called a message-box, and I'll just put a couple of values in. @1080 And now I have a thing which is a push button. But unlike this push button, out comes a message which has a number in it when you click it. Now, this is different @1095 from -- OK, right, so let me do this while we're here. This is a message. This is a number box. @1110 And this is an object. And the thing that distinguishes them is the borders on them. This is supposed to look like a flag, which is... I mean, using only five pixels, or trying to make a representation @1125 of that. This is supposed to look like a punch card, and this is just a box to be the simplest possible shape, because it's used frequently, a frequently used thing. What this is about, is the number -- OK, now we're not in edit mode-- The number-box does this: @1140 You click on it, and you drag, or you click on it and type to give it values. It's a thing which will generate the messages which have numbers in them. This other thing (message-box) is a thing which lets you type a message in which you just click on and get the message. This is good, @1155 because very frequently you want to send something a message, you already know what the message is going to be. You don't want to oblige the user of the patch, such as yourself, to have to @1170 type the number in, because you know what the number is going to be. So now, if I have a collection of pitches that I want to hear... @1185 (I'll leave this for now. Let's go here.) So, things that have frequencies that correspond to pitches that we all know. @1200 How about 261.62, that's middle C, and how about a low A? These are just easy-to-remember ones. And the higher A. @1215 And if you know A, then you know the frequency of E, sort of. I'm avoiding having to actually show you how do the math to do this correctly. That'll happen either Thursday or next Tuesday, I would say. OK, @1230 I don't want to, I want this to be zero so we're not changing anymore, just combine... [tones] Miller: Now I've got... OK? [laughter] Miller: Now that would @1245 not be a good thing to do with a number box. Because to make those four notes, I'd have to type those numbers in at musical speed, so it wouldn't work. So almost the only reasonable thing that @1260 you can do if you're going to do something like have a musical scale that you want to use is put the numbers somewhere you can get them. And the simplest way of doing that is put them in a message box. All right. Yeah? Student: Can you go over one more time the difference between @1275 putting the number after the oscillator, after the osc~, vs putting it above? Miller: OK, good. And in fact, I was inadvertently a little confusing here, because I @1290 left the number here. This number is sitting there, so that this thing that it was creating was 440, but then I was changing the number by putting these other numbers into it. Student: They're overriding? Miller: And those are overriding it, yeah. So this is an initializer. And it's a better style. In fact, @1305 if you're going to change something, not to initialize it, so that it doesn't look like it's 440. Then for instance, it might be 261 or 162, instead. So that's one thing about that. Another thing @1320 is that you can put messages or signals into the oscillator. And some of the examples from last Thursday had us putting a signal into the oscillator in order to control the oscillator's frequency. @1335 So there again, putting a number into the oscillator's first inlet, which is its inlet for frequency, sets the frequency, be it by a number like this or by an audio signal which is a stream of numbers. Now the next thing to mention is @1350 that there are two inlets up here, and I've never told you what the other inlet is good for. It is a thing for initializing "phase." And initializing phase does not mean that... OK, let's see. @1365 OK, so what is phase? Phase is a number which, if you like, it varies in time and varies from say, 0 to 2*pi as a thing cycles. So if I -- let's get rid of this multiplier now, it's going to just be confusing. @1380 Actually, let me save this. Let me save this and give it a name, which will be... This is patch number two, and @1395 that's going to be, "2.oscillator" But now I'm going to save as patch three. And now we're going to start talking about phase. (Saves 3.phase.pd). @1410 All right? OK. By the way, I'm putting these patches up on the website, although I did that a little bit belatedly last time, the patches from Thursday only showed up on Sunday. @1425 So if you're looking for them before then, you didn't see them because I hadn't done them yet. Actually, I just forgot. So if you don't see them after class and want them, send me an email and remind me to put them up, because this is the sort of thing that I forget to do. OK, so now, now that I saved it @1440 I can get rid of this, because you've got this in the other patch. And in fact, I'm tired of the thing being so quiet, so I'm going to do something, I'm going to make it louder. OK? And I'm going to test it, so... [tones] Miller: Yeah, there it is. @1455 OK, more beautiful music, all right. Now, phase. OK, so phase is a... Oh, right, I want to graph this, I'm sorry. Yeah, can I put this one on this. I'm going to graph it from here. @1470 So we're now looking at A 440. So the phase is a number which -- OK, you can regard this thing as starting at any point during the cycle. A mathematically easy place to think of the cycle starting @1485 is at the top, because then everything is a cosine, and cosines are mathematically simpler than sines, for a reason I'll tell you later if you want to know. So you can, but since this is arbitrary, but I'm going to assume that the cycle is starting here. @1500 And the cycle then proceeds from the top down to the bottom and back up to the top. And there is a number called phase, which you don't see here, which is going from 0 to 2*pi every time the oscillator is oscillating. @1515 So if you like, the old metaphor is, imagine that you're in the dark and this bicycle wheel is spinning and there's a light on it, and you're looking straight along the plane of the wheel so you see the light going @1530 up and down. The phase is the angle of the wheel, which you don't see, so you don't see the wheel of the thing, so you see the light going up and down. The phase is the angle of the bicycle wheel, which you don't see. And the thing that you do see is the cosine of the phase, which is the thing that bounces up and down. Later, I'll show you how you can actually generate @1545 phases as audio signals and put them into things, in order to control this process in greater detail. But right now I'm not going to do that, it's more detail than we can deal with right now. I'm just going to mention that phase is a thing which @1560 you can initialize, but then the oscillator itself maintains the phase with changes in time. And now what I want to do is... maybe, let's... Yeah, right. I probably should have kept @1575 the other oscillator. OK, so we'll do this. A duplicate... Oh, yeah. If you haven't found out yet, the fastest way to make an object is to select one, without selecting its text, and then hit @1590 'duplicate', which will in effect copy any amount of patch that you want. So I'm going to now go back, sorry, and make an oscillator with a number controlling its @1605 frequency, and then I'm going to play it. So, multiply to control the amplitude, then we'll hear the output. I'll show you why in a second, I hope. OK, so I'm going to set one Hertz here, @1620 440 here. Play. [tone] Miller: All right. Yeah? Student: How do you copy the objects once you've selected them? Miller: Command-d, or it's up in edit there. @1635 Oh, control-d for me, but command-d for you, all right. OK, now next thing is this oscillator, of course, also has a phase which is going from 0 to 2*pi once a second. You can change the phase, but @1650 the phase is also always changing. So let's make this number -- let's make it slower, so that you can hear what's going on. I'll make it cycle every four seconds. OK. [tone] Miller: Now, I'm going to go @1665 into the other inlet. Let's see, get a message box, because I was telling you about that. And I'll make something that just bashes the phase to zero. @1680 Come on. All right. Now I've got a nice little attack-maker. Well, it makes an attack if I hit it at the right moment. But if I hit it at the wrong moment, @1695 and the thing was at phase zero anyway it doesn't change anything, so I don't hear anything that it wasn't already doing. Now I'm trying to figure out how I can, oh yeah. OK now I can graph this for you, but I will have to just graph @1710 this, I think. And furthermore because it's moving slowly, oh, but I'll still use it here. Because it's moving slowly, I'll make the table be huge, so that you can @1725 see things that are happening slowly. So in fact, let's put this back at one. And then, I'm going to make this thing happen at properties that will make it have a whole second's @1740 worth of stuff in it. And so 44,100 -- that's a second's worth of sound. Oh yeah, let's change the name. @1755 Actually, I'm just going to... do that, all right. New name "seeme2". Right. @1770 All right, let's record it. [tone] Student: You want "tabwrite~ seeme2" not "seeme" , no? Miller: Oh, thank you, yeah. Let's make it talk to the right array. Now, if I tell it to record, I could wait a second before I see it. @1785 It doesn't show the thing to you until it's finished recording into the array. Which is why you make the arrays kind of short if you want to see things quickly. So, now what we're seeing is, every time I whack it, I'm going to see one second @1800 of just this amplitude-controlling sinusoid. Now, I am going to set the phase of it. Do you hear that stuff? That is this. Let's see. Now I have to click this and then click that within @1815 a second. So I'm going to move them really close to each other. [laughter] Miller: There. Look at that. This is what happens when you have a nice sinusoid going and you say, "Now make the phase be @1830 zero, please." It makes the phase zero, all right, which means there is a discontinuity in the sound. Which, in computer music lore, means that you will here a click. So, discontinuities, or "step functions," are clicks -- @1845 or one source of clicks. Yeah? Student: Could you put the bang into the message-box? Miller: Sure enough. Yeah. So I could do this. I'll do even a little bit better in a second, but let's do that for now. So now let's listen to that again. [tone] Miller: @1860 Now I'll say, "Set the phase, please." It set the phase and started graphing it at exactly the same time. So now, any time I hit it, I will hear something. I'll hear @1875 a discontinuity in sound. Actually, you are hearing two. One is when I make a discontinuity by doing this. The other is a second later when it graphs the table. (I've really got a slow processor.) So ... @1890 now I have made a triggered oscilloscope, for those of you who have studied physics. Now, let me do something even better. Introducing the "delay" object. So this is going to be @1905 an object that's called delay. I am going to say, "Delay 400." 400 milliseconds of delay. So now what I am going to do is have my nice button @1920 start graphing and then, 400 milliseconds later, it is going to set the phase of the oscillator to zero. @1935 Now, no matter what I do, I hear discontinuity four-tenths of a second after I whack the button. Notice that this part of the table is changing, but @1950 at a fixed 400 milliseconds into the table, it sets the phase to zero and thereafter ( -- whoa! Every once in a while, something like that will happen. Thereafter, the thing is always @1965 the same. That's to say every time I whack the button I will have a nice consistent result starting 400 milliseconds in. All right, so you cannot put your guitar into this delay. @1980 There's another one for that, which I'll show you later. This is a delay for messages. What that means is that, I'll show you. Student: There's no "message" for that comment now, right? Miller: Yes. Thank you. @1995 So delay, what it does is when you send it a trigger, it sends you the trigger, the amount of delay later. @2010 So if you've been following me, what I'll do now is I'll say, "This delay, let's make it a longer delay, like two seconds." OK, now zero, one, two. Whoops, I didn't count right. All right, @2025 OK. And now if I graph that... [tones] Miller: One, two. Why was that stupid? @2040 It didn't hit until after the thing had finished writing into the array. The array is one second long, the phase is getting set after two seconds. It's hopeless, I'm not going to see anything. You can hear it though. OK, good. @2055 So, are people following this? This is important, because this is how you would set about making sequences, things that have an order in time. For instance, @2070 this is going to get crowded. OK, let me save this, I'm going to do a "save as" again. So now we'll make a dumb sequencer. (Saving 4.dumb.seq.pd) @2085 We'll make a smart sequencer later. The dumb sequencer is going to look like this. Get rid of this, don't need that. @2100 So I have this nice A Minor chord here, so I'm going to make the thing arpeggiate, all right? It's going to be easy, right? All we're going to do is we're going to have a nice button... Let's see, I don't want this anymore. I'm going to have the button @2115 bash us to low A, and then, I don't know, 150 milliseconds later... How do I know what number to use? -- I've done a lot of this. @2130 And then another 150 milliseconds later, and then another 150 milliseconds later, and then @2145 let's just go back down. Yeah. OK, this is, let's see. Take the output of that, the input of that, then just go... Let's see, this might work. All right, so now @2160 we'll play it. [arpeggio A minor chord] Miller: All right, now we've got Beethoven. [laughter] Miller: Not really, OK. And of course, the punch line. @2175 Let's just take this one and connect it over here. Now we've got... [A minor chord arpeggio starts looping] Miller: Whoops, I did something wrong. Oh yeah, I know what I did wrong. I need another delay before I loop it, don't I? Miller: @2190 So another 150 milliseconds later, I'll go back around. [Arpeggio loops with all notes evenly spaced] [laughter] Miller: @2205 OK. Do this at home and not here, all right? [laughter] Miller: In fact, I will try not to play that anymore now. OK. Oh, there are little things that maybe you could want to be able to stop this. @2220 There's only one way I can stop this right now with what you know, which is to break one of the connections and wait for it to run out. There are ways, but we'll get there when we get there. But now what's happening is the following thing: @2235 There are two parts of the patch. There's the part of the patch that's giving control, there's a part of the patch that's doing signal processing. The part that's doing control... And by the way, that's jargon. Control and signal processing aren't @2250 really two different things that you can do, they're all part of one thing. But in pd Land, you think of it as two things as being two different things simply because they're two different computer science-ish constructs that represent them. OK, so let's see. I don't need this. (deletes two unused bangs from the patch). @2265 OK, so what's happening is the control stuff is all this. The signal stuff is all this (and maybe this -- I don't know how to characterize the array.) And the control @2280 computations are happening at a specific instances in time. In fact, it's happening about seven times a second, because this is about a seventh of a second. And what is happening here is... Oh, let me show you what's happening here. Let's get rid of one of these buttons. @2295 Let's be even clearer: put that button here. Yeah ... what a mess -- let's see. Let's not do that, let's do this... That little mistake, oh, it's OK. @2310 I can do this. I need a start button, but then I could always just have buttons that show me what's happening. @2325 Yeah, this is going to be painful. Let's not do the whole thing, but I'll just do these two. All right, OK. @2340 So now, there are messages flying around in a very particular choreographed way. So each one of those delays is the source of a message, if you like, and what that message does... So the message's @2355 formal name is "bang." Oh, I can print it out for you. Let's make an object, we just call print, and you'll see what this message looks like, and just we print it into there. All right. @2370 So bang is just a word that means "I don't have any numbers for you, but do it anyway." In other words, well, you wouldn't just say a space or something like that to say a trigger. @2385 You have to have something to print there. So bang is just a verb that says "Whatever it is you normally do it's time to do it right now." It's a trigger, if you like. And this message bang is coming out of the delay and it's doing three things. @2400 It's hard to see because of the messy crossing lines. But one thing is it's causing this bang push-button to flash. @2415 Another thing that it's doing is it's sending a bang to this message box 261.62 and what is that doing in exchange? It is putting out -- oh my ... @2430 Oh yes, right. So there are two messages coming into here (message-box 261.2) -- from this delay and from that other delay further over. Anytime either one of those things goes off, it's getting printed here, and we're getting that number out. Yeah? Student: Can you connect the osc~ to print? Miller: @2445 It'll complain. It won't even connect it because "print" expects control messages. However, I could put a print~ after that, and then I would be looking at the audio -- you know, 64 samples @2460 worth of the audio signal. Am I going too slow? No, all right, OK, good. So to go back, if you like, the @2475 outlet of this delay, this -- whatever you hook up here "talks to a tree." That's to say a graph without any loops of stuff. And the stuff is what happens when that thing goes off. @2490 And the tree stops whenever you either change from being a control message to a signal. Or it stops whenever you put it into something that doesn't do anything as a result. @2505 I'll show you lots of ways that things can "not-do anything" as a result of things. That's going to happen later. So if you like, the tree of things that depend from this bang outlet consists of this delay, which by the way doesn't do anything @2520 so the tree doesn't go further through that. So what this tree is is everything that happens right when that bang happens. And not stuff that happens later as an indirect result of it. So this delay, when it receives a bang, its job @2535 when it receives a bang is to schedule itself for 150 milliseconds into the future. So it does that scheduling job which is a side effect in computer science language. And meanwhile, it returns, which is to say that's the @2550 end of that arm of that graph or that sub-graph, or sub-tree, I should call it. There are three things. First off there's the bang, and then there's the delay. Then there is this message box which @2565 puts out a number and that number goes down to the oscillator. And that's the entire chain of events that takes place when this delay goes off. So I should -- OK. Let's see... shift. @2580 Just to select everything that is in the tree, hanging from that delay object. Make that be a tree and not have @2595 loops in it. Because if you put a loop in there, then pd will try in a zero amount of time to do an infinite amount of stuff, which is traverse the loop as if it were a tree. And pd will then think hard, @2610 and then after a while, depending on the speed of your machine, it'll complain and say stack overflow, for technical reasons. So for instance if you want to see me do that, @2625 I'll get a nice number and hook it up to another number and do it back like that. This is illegal. But pd can't really sense this so it didn't stop me from editing it @2640 because the editor doesn't know that something bad is going to happen. But something bad is going to happen. When I put a number in here... Oh, yeah, I get stack overflows. It was actually pretty good at detecting it that time. . Sometimes it's better than other times depending on the OS and in particular the things you're doing. @2655 So your mileage will vary. You can bring pd to its knees this way. Why was this not a good thing to do? The first message box, sorry the first number box, the one on the left, if you like, tells the other one be 96, @2670 and by the way, output 96 and then return. After that you're done, right? For computer scientists it's a depth-first tree traversal. @2685 So the message box on the right then says "Oh, I just got a message 96, what I'm going to do now is tell the... sorry, I'm going to tell the number box on the left to change itself to 96." It already was but no matter, change it, repeat it anyway. And then that one says, "OK, @2700 before I'm done I want you to change to 96." And the other one says, "OK, that's good, before I'm done I want you to change to 96." And so on and so forth. It's an infinite loop. It's actually a recursive loop, but it's theoretically infinite. And pd couldn't deal with it because eventually it ran out of memory. @2715 In other words, recursion involves pushing stack values. You can also not make loops out of signals; signals hate loops too, but they hate them @2730 in a different way. So when I do this... let's take a nice signal and multiply it by five. OK. There are a lot of reasons you should not try to do something like this. @2745 And after that's done I'll multiply by five, and after that's done I'll multiply by five again and so on. And now -- Why didn't I get an error? Oh, because I turned it off. [starts DSP and playing the arpeggio chord etc.] Miller: It says "DSP loop detected. Some tilde ..." -- @2760 and then something I can't read, you can do it and find out. This is not the same kind of loop as that because notice we have fat connections here, and thin connections there. The error is found at different times. Here @2775 pd was smart enough to figure out that there was an error because it's much more able to analyze what will happen as a result of the signal analysis, or signal flow than messages. Why? Because if messages contain decision making objects, then to @2790 analyze a message computation, you would have to analyze a Turing machine, which is formally impossible. Signals are analyzed as a graph. You simply know that a signal crunches a number every sample. So there's no @2805 decision making to be done which can be second guessed. And so you can predict in advance how it's going to happen. This is important because it allows pd to operate on the signals very, very efficiently. What it really does is it -- it doesn't exactly pre-compile it, @2820 but it essentially figures out in advance what it's going to have to do for the signal network, and it sets it up to do it very optimally. So it analyzes this. It knows how this thing is going to act. And so it knows how to do it. @2835 How to linearize it, how to make it happen in order. And, gee whiz, it discovers that there's no possible way to do it because you have to have finished each one them before you can start the other. And so neither of them can ever be run. So that's an error, @2850 and that can't be done. What will happen to you when you make that error is those two things just won't be run, and the rest of your patch will run. But if you see that, it means that you're doing something wrong, and you should probably find out what it is. By the way, @2865 you can always say, "find last error," and if pd is able to figure out what object created the last error it will go to that window and turn that object blue for you -- select that object for you. @2880 That's a useful tool. So that's a loop, and this is a loop -- they both are. @2895 Now this is not a loop in that sense, even though it looks like one. I didn't make it look like one very well. But maybe I could do this. Well, I don't know how to make this patch pretty so you can see it. @2910 But what's happening now is each delay's output is going to the next one's input and so on, ad infinitum, until the last one's going back into the first one. That's not a loop because the delay, when it receives a message, does not as a result put a message out. Instead it schedules a message for the future. @2925 So in a sense it's the end of the line. It doesn't have any direct effect to put a bang into a delay. Questions about this? @2940 I promised you I wasn't going to play it anymore, but here's how you make the thing have a controllable tempo. You would just put these numbers into the delay. @2955 I'm not going to do it because I've already had enough of that. Students: Aw. [laughter] Miller: If you want to hear more of that you have to make it yourself. But then use headphones. [laughter] Miller: All right, questions about this? @2970 That is a lot of information, some of which was a little bit abstract. And I'll try to find ways of stubbing our toes on this again later. Yeah? Student: When you input a number to an osc~ for phase, is it assuming it's that number *pi, or how does it work? Miller: @2985 Ooh, thank you. Yes, OK. So I should have told you that right when I was telling you about setting phases of oscillators -- The only thing I ever set the phase to was zero. @3000 (Let's see, let me save this, and did I...? Yeah, OK, I can go back to this example (3.phase.pd). @3015 So I'm going to go back a little bit. @3030 Oh, let's save this "0.objects.pd" . OK. @3045 So the dumb sequencer, we're now going to close and tell it goodbye for a while. And now I'm going to go back here (3.phase.pd) and start setting phases of the oscillator. We'll go back to only waiting four-tenths of a second @3060 so that -- ooh, interesting. Oh, right. [tone] Miller: Let's see. This we need to be a "1", I think. Yeah, there it is. OK. @3075 So this number is not in radians, but in (radians/2*pi). It's relative; it's in "cycles." So if I want to have this thing @3090 look like a sinusoid, I'd want to go to three-quarters of a cycle in, .75. Now what I've done, OK, let me see if I can explain this. @3105 Now what I've done is I've set the phase of this oscillator to three-quarters, which means another quarter of a cycle in we will be at one. And, let's see, equivalently @3120 I could have set the phase to minus one-quarter of this. This is exactly the same thing. [tone] Miller: @3135 So minus a quarter is also a quarter of a cycle before the beginning of the cycle. And this is how I would set the thing to the phase of the sinusoid. If I say positive a quarter here, @3150 it sets us up to one quarter past the peak, which to say, it's at zero now, but it's at zero on the way down. And if I set it at a half, then it will be @3165 at the negative peak. So that's how phase goes. Now if you want to make two things be a sine and a cosine, so you can make something move in a circle parametrically, set one of the phases to zero -- that's the cosine -- and the @3180 other phase to -.25 or .75 for the sine. And then you'll have two things that are out of phase. It's 90 degrees out of phase, if you like, or pi/2 radians or one-quarter cycle -- which is the way pd thinks about it. Student: @3195 Can you make an example of two oscillators out of phase? Miller: Oh, all right. How would you get two of them to be out of phase? Why don't you do this -- why don't you set one of them to... OK, you're going to have to have two oscillators ... @3210 So you can set their phases to whatever you want to. So what's out of phase? If you want one of them to be peaking while the other goes through zero then give them two numbers that differ by a quarter cycle. Or, if you want one of them @3225 to peak up while the other peaks down, then set them a half cycle apart. Yeah. And this you'll want to do using message boxes. Message boxes are the right tool for doing this, because @3240 that's where you can put a number in that will happen without someone having to type the number in while they're using the patch. Student: @3255 On the homework are we graded on whether it's solved simply or not? Miller: No, we're not going to have a good grading policy the first time around, because you're just going to be sighting the thing in. @3270 So basically, for the first homework, if the thing works it's full credit, regardless of whether you were elegant or inelegant. And then, we will discuss after that, or the TA and I will talk, @3285 Joe and I will talk, and we'll try to figure out what to do after that. We'll either decide to make simple, elegant patches be worth more than ugly, horrible patches, or we'll decide that ugly horrible patches are worth more than elegant patches... [laughter] Miller: ...depending @3300 on what seems to be pedagogically the most appropriate choice. But for right now, just get it to work, and that's good. Student: On the timing problem, my sounds are distorted or at the wrong pitch. Miller: @3315 @3330 Sounds distorted? Oh, so you're probably not doing it right, yet.[laughter] Miller: OK, so good. So there are two things there. One is: what's the difference between those two sounds and can you hear it, which you've already got that, which is it sounds @3345 distorted, and it also sounding at the wrong pitch. Why is it sounding distorted is for reasons that I explained Thursday, you're overloading something. I don't know what, because I don't see the patch. But either you are putting two sinusoids at full @3360 blast into the DAC -- *ts range is from minus one to one. And if you are adding two full-blast sinusoids into it, you are going outside of the range of minus one to one, and there will be clipping. Student: Can it put the result through clipping? Miller: @3375 If you put a clip on, then it'll just clip, and you'll still hear the distortion. You have to actually put the amplitudes down to where you can play it without distorting. The other thing is, even if your patch is formally correct, depending on your audio hardware, it might distort. @3390 But, your TA knows this, and so his audio will not be distorted. So if it sounds distorted on your computer, it's just conceivable that it will sound clean on his. But if it sounds distorted @3405 on his computer, it already sounded distorted on your computer. There's a syllogism in there somewhere, but I can't spit it out right now. All right. Other questions? Student: @3420 How is it possible to find out it's phase of a signal? Miller: How would you offset. Oh, oh right. So, how do you find out the offset ... @3435 OK. I think what you're asking is how do you find out what the phase of an oscillator is while it's running. So that you could change it to something else, and it could depend on what you find. You need another object -- two other objects that I haven't told you about -- to be able to do that. They are phasor~, because you actually have to @3450 deal with the phase of the number. And snapshot~ , which is the "Look at a signal to see where it's at" object. And those will come up probably next week. Maybe phasor~ shows up tomorrow, -- sorry, on Thursday -- but snapshot~ @3465 not until next week. So you can set things right now, but you can't, like, query your patches as to how the signal processing is doing programatically yet. Student: What is the deadline for turning in the homework on WebCT? Miller: WebCT believes that it's @3480 due at 3:30. So that means that if it doesn't show up at 3:30, WebCT will flag it late. WebCT won't even take it if it's more than a week late. And, we haven't yet set the schedule of @3495 when we will grade it, but you should get it done before grading starts, because it's much, much easier for the TA to grade it all in one batch. Student: So we might not need to have it by 3:30 as long as it's before the grading starts? Miller: @3510 My guess is that Joe won't be able to download it until five, because he's going to be sitting in class. But on the other hand, if he gets bored he might actually decide to start downloading it @3525 while I'm talking. [laughter] Miller: I don't think he will. So, it seems like you've probably got until five. TA: It's safe to plan on 5PM. Miller: Right. [laughter] Miller: But come to office hours @3540 after class and I can help you. Maybe you can be done before 3:30. Yeah. Other questions? Oh, right, we haven't decided how late late is, or we don't have a late policy yet. All this we have to figure out how the class works before @3555 we can set things. Other questions? All right. I want to quickly show you another object just because... @3570 well, you'll see why. So this (in the patch) is the delay object. There is also another one which is called "metro" which is the metronome. @3585 And this is an object which takes two numbers in -- Let me get a number box. @3600 Oh you know what, let's do "save as," as this is going to be confusing now. So now we're going to save "5.metro.pd". And I don't know whether to leave all @3615 this stuff in the patch, so right now I'll just leave it. OK. This (metro) is an object which when you turn it on, does this [bang-light on metro output blinks]. @3630 And when you turn it off it, does that. All right, that's useful, and furthermore you can control -- sorry, yeah. I'll leave this "400" in here for now. But you can control the number of times @3645 per second it happens. So "1000" means it's every millisecond. And then if I want to double the tempo I should halve this number and make it 500 @3660 which means every 500 milliseconds which is twice a second. Yeah? Student: What is the "400" in the box where you have "metro 400?" Miller: This initializes the amount that you are -- oh right, I should probably @3675 sort of say something about initialization. So anytime you give an object an argument like "delay 400," or "metro 400" or "+ 400," or even "osc~ 400," the argument, -- the "400" or whatever number it is -- is an initializer @3690 for the parameter that the object uses if there's one parameter. If there's more than one parameter, you might want to give it more than one number. (But you haven't seen that happen yet.) I think I've been trying to do things in an order that @3705 allows me to start things gently. So what this is saying is when this object is created it's going to be 400. But when I send this number in it will change it to 500. Now let me confuse you a little bit. In order to try to @3720 unconfuse you. It's not universally true that the number that you initialize this to is changed by this inlet. In the case of metro, this is a thing which turns it on and off. @3735 And any number that's not zero means on and any number that is zero means off. This is the new value of 400 up here which is now 500. So right now it's not a metro of 400. Morally speaking, @3750 its a metro of 500. Student: Why doesn't the number 400 change, but the number in a number-box does change? Miller: OK, yeah. So this thing here (number in a number-box) -- This is a control ... What's the word? @3765 It's a control in the GUI sense of the word. It's a thing which shows its state and allows you to mouse its state to change it. These things: messages and objects -- are things that you type a text in and it defines what they are @3780 forever. So the number, you actually don't type this number in when you create it. In fact, in edit mode you can't even edit that number. It's a thing whose job is to change numbers at runtime. @3795 These other things -- you put these things in at edit time, and they are what they are while the patch is running. And so this is, yeah right. So this (number-box) is when your playing the patch @3810 and making the sound change and trying to make people dance. You have the patched locked at that point. You're not developing your patch anymore. So you're using the number box and the button and other things like that to be running the patch, @3825 basically, changing the state of the patch. But the functionality of the patch -- the computer program that the patch is -- is determined by the topology. That is to say, how things are connected together. It's also determined by what particular things you type into the message @3840 and object boxes. OK, now to slightly further confuse the situation: @3855 Another example of a thing being initialized that came up earlier is that you can initialize an oscillator to a frequency -- like that. But now to change that frequency you would put messages @3870 into the frequency inlet, which is the first inlet. The oscillator as a tilde object, it's a signal processing object. It doesn't take messages to start and stop. Or to do it's thing @3885 the way the metronome does. All it does is take messages to modify what it does, which is to say its frequency. It's always running. It doesn't need to be turned on. That's because its a tilde object. So in general, tilde objects, @3900 the first inlet, the leftmost inlet, is usually the thing that you can control by -- sorry, here -- usually the thing that you can control by changing the argument. Whereas in objects like metro, @3915 this number is being controlled by this inlet (right inlet) because this (the other, left inlet) is used to turn everything on and off. There are no very good generalizations. Objects are all designed to be as coherent as they can be. But there is a limit @3930 to how coherent they can be, because they all have radically different functions depending on what types of things they are. So that's something you just have to remember. Student: Did you connect the bang to the metro just for a visual? Miller: Yes, I did that just to show you what was happening. Yeah, @3945 so this would be doing the same thing if I had this connected to it or not. Objects don't know what they're connected to. They just put their output out there, and if there's nobody connected to it then the output doesn't get used. And if there are 50 things connected to it the output does a lot of work. @3960 All right, well. Yeah? Student: Can you connect the metro to an oscillator? Miller: Yeah, so a couple of, so let's... @3975 All right, I can think of nice and ugly ways of making that happen. Like for instance, what if I actually used this patch. Let's turn it on and listen to it. [tone] Miller: OK. @3990 So there's this oscillator, it's at three Hertz. Now I'm going to just set the thing to something every 400 milliseconds, sorry, every 500 milliseconds. OK. Now just to be @4005 bad about it ... [tone changes] Miller: Now I can make a motorboat sound. What I'm doing is I'm changing the phase of the oscillator. @4020 Offsetting the phase of the oscillator which is causing a discontinuity in the sound. OK. Let's see, let's shut this thing up. @4035 All right. Yeah? Student: On my computer my number boxes always just go up by integers? Miller: Oh, yes, that came up before, but I said it kind of fast: If you hit the shift key while you're scrolling it, you're scrolling in hundredths. @4050 And if you don't then your scrolling in ones. Any questions? All right. So now, what would happen if you took this metronome and well @4065 whatever it is, every 100 milliseconds now I'm just going to set the oscillator to three Hertz. [tone] Miller: Well the oscillator @4080 was already at three Hertz. So it doesn't do anything to set the oscillator to three Hertz. So it stays at three Hertz. So that has no effect. On the other hand, don't try this at home. @4095 [tone changes] Miller: You can have two of them and make them fight. So let's make this one go at some nice other speed like @4110 161.8, and you all know that number, right? And now we'll hook that up, too... "No, E!" "No, A!" "No, E!" right? @4125 That's Compositional Algorithms 101. Yeah, you can think about why that did what it did.[laughter] Miller: @4140 OK, but I should tell you what it did, which is this. These two things are putting out bangs. They're putting them out at different rates. One of them is happening 10 times a second. @4155 One of them is happening [10 X (1 + sqrt(5/2))] times per second -- the golden ratio. I just chose that because it always sounds good when the metronomes have the golden ratio. OK. Now, 10 times a second we're bashing @4170 the frequency to 220 "A". And some other number of times a second we're bashing it to 330 "E". In fact, if we want to see what that's doing, we could just say, actually show me the frequency of this oscillator. And then we have this @4185 schizoid frequency here. Student: It looks like an animated "2" and "3". Oh yeah! 2 and 3. All right, yeah, there's ASCII art to be gotten here, isn't it? [laughter] Miller: Right, OK. This is now @4200 having two different inputs to the oscillator, which are telling it to do different things. And they don't get added or anything like that. They would get added if they were signals, but since they are messages @4215 which happen at different times, it doesn't make sense to add them. And so instead, it just becomes a situation where whoever sets it last wins. So if someone is opening a door and someone else is closing a door, is the door open or closed? Well, it depends on who got there most recently. @4230 So the last person to set it wins. And meanwhile what you hear is the thing changing between the two values in whatever tempo it makes to get the two things to happen at different times. @4245 Is that clear? OK, all right. So this shows, in some way, the essential difference between @4260 the sporadic control message computations and signal computations. If you want to do something that has to do with decision making or has to do with events that happen in time, like waiting @4275 for network packets, or waiting a certain amount of time, or waiting until a keyboard key goes down or something like that, you are in Message Land. And message rules are that when something comes out of something, like this metronome generates @4290 events and the event traverses the tree of everything that is connected to it until it gets to something that doesn't respond, but simply changes its state or does something by side effect. At which point we have done that @4305 tree of messages that descends from this metronome setting. All right. Is that clear? And a good part of computer music is thinking of @4320 cool networks for controlling these signal processing networks. One thing about that is it takes brains of an entirely different sort to know how to make good control structures from knowing how @4335 to make good signal processing structures. Signal processing structures are -- it's very mathematical. You need to be able to deal with trig and stuff like that. You need to be able to think about spectra of sounds. For doing control, actually @4350 knowledge doesn't seem to help you very much. No one really has a good way of theorizing about how people should control computers and computer music applications. And as a result, you just sort of learn a collection of techniques which might @4365 involve how to respond to external events. How to make decisions. How to generate random numbers. How to solve problems involving constraints. And so on like that. I don't even know how to make the list. But what that @4380 looks like is like the field of combinatorics. Just a whole bunch of different things that are different ideas that you have to know a lot of in order to be effective at it. And you just have to wait until you've seen a bunch of things or invented a whole bunch of things, and then you have a nice @4395 repertoire of stuff you can put together and make a meaningful patches. So both of those things are things that take a tremendous amount of work to acquire well. The signal processing you can do in a more systematic kind of a way I think than the control aspect of it. @4410 And furthermore, it's a little bit artificial to separate them at all. OK. All right, so review of what happened today. A lot happened today. @4425 OK. So the new stuff you saw was these messages. And then I got to show you how you could like make things, like sets of numbers that you could then call up at different times. There were, @4440 I think, there should have been three new objects, but I can't remember what they were. They were delay and metronome. And I think that's all I've shown you. Oh, I forgot @4455 to show you one, and I don't have time now. I'll tell you what it is: I also meant to show you this wonderful object here, "line~" which is your all-purpose ramp generator. @4470 So I'll start showing you that in detail next time. Actually, since we have five minutes, I'll show you what it does and whet your appetite, and then you can get help on it. Then I'll show you in detail how to use it next time. This is the better amplitude control object. @4485 So we've been using oscillators to control amplitude -- I'll come clean now -- just because I didn't want to introduce another object right away. But it's not really the thing that you do all the time, use an oscillator to control the amplitude of another oscillator. More often @4500 what you want to do is this -- let's see, let's turn these things off because otherwise it's going to be nuts. OK. Thanks. Now I have a nice frequency. Now what I am going to do @4515 is a -- don't need this, don't need that, don't need this -- and line. And line is going to now have a message going into it. And the message is going to have two numbers. I haven't told you about this yet: @4530 a value, and a time to obtain the value at. So here's on and here's off in a second. Now I have @4545 the following wonderful thing: (turn DSP on) Miller: There's my 220 Hertz ... and there's my 220 Hertz shutting off. All right. There are @4560 several new concepts here. One thing is message boxes can have more than one number. And so messages don't necessarily consist only of numbers. Miller: They are actually quite free form although @4575 a lot of the time messages are just numbers. line~ will interpret a message with two numbers to mean, "This is the value we're going to attain. This is the amount of time we're going to attain it in." So that this is a faster one:@4590 [tone] Miller: ... as opposed to this. So this is the way we make sounds that turn on @4605 and off when we want them to, as opposed to just when the oscillator's phase changes appropriately. Yeah? Student: Where did you get the value of "1000" from for the message? Miller: Oh, it's 1000 milliseconds and that's the amount of time that it took to rise. And what I intended to do and @4620 got lost in details instead was graph this for you, the same way as I was doing before. Let's see, we're going to need delay, draw button ... @4635 Sorry, this is going to be over in just a second. And we're going to graph the line~ : [tone] Miller: Ta-da. There's what a line does. @4650 It sits there doing nothing until you tell it to do something. And 400 milliseconds later I told it to go up to 1 in 100 milliseconds. @4665 So now what's happening is the line is sitting at zero. Miller: @4680 So I asked it now to go up to 1 in 100 milliseconds, and what it did was, it starts graphing. 400 milliseconds later it says, "Line turn on." It turns on. It takes it a tenth of a second to reach @4695 its target value of one. And furthermore, I can now tell it to turn off. [tone fades out] Miller: And then it waits 400 milliseconds and then goes out. This is your @4710 way of getting stuff to start and stop. It's kind of one of those useful things that musicians need to be able to do with their sounds. And more about this next time, maybe. It's time to stop @4725 for now.