*** MUS171 #01 01 04 @0000Miller: The purpose of this course is to show you how to -- well, "show" I'm not sure is the right word -- @0015is to enable you to make your own computer music applications, in the sense of designing electronic music instruments. What that means, in a sense, is making your computer do what a guitar or a drum set does when you @0030do things to it, so that the thing is running in real time. It's making sound, and you walk up to it and do things to it, and that changes the sound that it makes. For instance, it might be silent until you start doing something and then it starts making noise. Then you've got an instrument @0045that does something that responds to how you're trying to get it to do things. So this is a particular... This thing, this idea of using computers to make computer music instruments is, @0060in some sense, sort of the trunk of the whole field of computer music, at least the way I see it. Computer music grew out of, or maybe it's a part of, the field which could be called electronic music, which started, depending on how you think of it, maybe in the late 1900s -- @0075maybe in 1948 when the first tape recorder music started getting made. Well, you could put other kinds of dates on it. And the whole field of electronic music is basically people inventing ways @0090of making music with electronic gear as opposed to acoustic instruments. It wasn't obvious, at first, when computers showed up on the scene that computers would eventually, essentially, supplant all of the other @0105electronic musical instruments that exist, which means the tape recorder, the synthesizer, all that kind of good stuff. But nowadays, everything that you could have found in an electronic music studio in the '50s, or '60s, or the '90s @0120is a piece of software on a screen on your computer with a couple of very important provisos. Proviso number one is that a computer makes a rotten musical instrument in the sense that you can't strum it, or whap it, or any of those good things that you can do with acoustic instruments. @0135I'm not going to do a whole lot of talking about designing hardware interfaces for making computers that respond more naturally to musical impulses. The reason I'm not going to talk about that is because it's its own subject. And @0150it's also a rather various subject. Different people have completely different approaches to designing interfaces to computers. It's such a wide, disorganized field that it's hard to figure out how to make a syllabus out of it in the first place. So I'm just sort of going to ignore that and, @0165to the extent that I need to actuate my computer, I'm going to be using keyboards, and a mouse, and the microphone. All right. So other than that aspect of just getting inputs into the computer, I think @0180that everything that you do now in electronic music, you at least can do on your computer. So a couple of things about that, OK. First off, what does making music @0195with computers split up into as a set of things that you can do? And my own taxonomy of what you do with computers to make them into computer instruments are that there are three basic things that you might want to know how to do. One is @0210synthesize sounds. What that means, at least what that means to me, is that you write down an algebraic equation and it has a variable in it for time. As time passes you just plug different numbers into the time slot, and out comes a sinusoid @0225or whatever it is that you told the equation to make, and then you get to hear it, right? And if you came up studying mathematics like I did, this is paradise, right? Any equation you can think of, you can listen to. So that is synthesis, @0240synthesizing sound. That comes out of a long tradition of making stuff, like oscillators and filters that have existed for at least 100 years for doing that, before computers really came on the computer music scene. @0255A second thing is what I think people usually call either processing or signal processing, which is a misnomer because signal processing means many other things besides what it means to computer musicians. But at least if you're in a room @0270with computer musicians and when someone says signal processing, what they tend to mean is something that takes a sound in and changes it into something else to go out. The most ubiquitous example, I think, is @0285sampling, where you take a microphone up to something and make a recording, and then you have a button that you press that plays it back. And the only transformation is that you heard it at a different time from when you recorded it. That's a perfectly good transformation, right? @0300In chapter seven, I think it is, you will find all sorts of things to do with that particular kind of transformation. OK. That's item number two. One was synthesis. Two is signal processing. Three is @0315analysis, the idea of taking a sound that goes in and boiling it down to a set of parameters that describes what that sound is, or some aspect of what that sound is. A very simple example of that is an envelope follower, which will tell you whether @0330someone started playing an instrument or not, or more generally, tell you whether there seems to be sound coming into a microphone right now or not. And you would use that, for instance, if you wanted to find out if someone was walking into a room so you could turn the lights on @0345automatically. Put up a microphone, hook it into an envelope follower, and then have it turn the lights on when the amplitude of the sound reaches a certain level. So that's analysis. That doesn't sound as interesting as synthesis or processing because there's no sound @0360output, there's just sound input. I hope you'll find out that there's a whole world of cool stuff you can do with that as well. In terms of mental block-diagrams, if you want to think about what this all means: Synthesis is, you have a box @0375and it has an output. But the input was something that isn't sound; the output is sound. Analysis is, you have a box that has a sound input but not an output, and then Processing is a thing where you have both input and output. @0390What I'm going to do to start with is start with synthesis because it's the easiest thing to get your computers to do. Why? Because it's much easier to deal with speakers than it is to deal with microphones for reasons that I don't really understand very well. @0405But I want to give you some time to get used to how to get your microphones and your computers to be friends. That might make it more appropriate to wait a few weeks before, or however many weeks we can afford to wait, @0420before we start doing that kind of stuff... And just to make the gesture, I didn't bring a microphone today, although there will be microphones in the room later on. What do I have to tell you? I have to tell you some organizational things about the course that @0435are boring but that you need to know. There's a website, and the website tells you all the boring stuff that you need to know about the course. The website will somewhat change in time. @0450What it does now is it tells you, week by week, what I believe the topics to be that this course will consist of. Most of the time I'm actually able to do what I was planning to do, @0465but sometimes it has to change for one reason or another. So this is not a guarantee that this is what we're going to manage to do, but hopefully it's what we'll do. What you'll find is that as the quarter drags on there are going to be @0480a certain number of assignments, which are things that you have to do with a computer that demonstrate that you have mastered one or another technique that is the topic of the week. The first one of these is due @0495a week from Thursday, that's to say Thursday of week two, and that is a tight deadline. The assignment itself is very simple, I hope. What that requires you to do is get software loaded onto your computer @0510and figure out how to deal with the mechanisms for turning homework in, which you probably know better than I do. But leave time to figure all this stuff out. What this means is that you should be doing this right now so that @0525when things start going wrong you can ask for help and you can try to figure out what to do to get things to work for you. To that end, there are office hours. Both Joe, the teaching assistant, and I will @0540have office hours on Tuesdays because the homework is going to be due on Thursdays. I think that's the most effective way of running it. Joe will be here but I'm not sure in what room yet. The room number, @0555I think, might be changing, but he will be here from 2:00 to 3:00 on Tuesdays. I will be here after classes on Tuesdays, which will be when I find everyone most exhausted. Anyway, that's another possible way to find out what's going on. @0570The course has a textbook, sort of. Again, the textbook is -- where did I put it? The textbook is online, @0585and it doesn't look like a book, but here's a PDF version and a PostScript version, and then there's a nice HTML version. You can even download a nice tarball with the HTML version, and you can download all the examples @0600that are described in the book, which are patches in Pd. Or you can download -- don't do this -- download all the figures in the book, which are also patches in Pd, if you really want to laugh at what Pd can do. @0615It would be hard to do it quick. So that is textbook, and what I'm going to try to do, although I've been-- Yeah? Student: What's the website? Miller: Oh. What's the website? The URL is here. @0630That's the URL you want. Although, you can get there very easily because you Google "Puckette" and then you see Courses, and then you see the first one is Music 171. @0645I didn't want to insult your intelligences by printing out the syllabus. Well, actually, if you have trouble accessing the web, come see me and I'll print you out @0660a copy. But it won't help you so much because it's going to change. On that subject, I want to not forget to say one thing, which is if you don't have easy access to a computer and/or the network, please come see me @0675after class today so that we can figure out how to get that solved. There are various things that we can do to try to get you to a computer. I don't know what it's going to be yet because we'll just have to do it case by case. The polls say that 99 percent of students now @0690have computers, so I'm going to assume that you do until you tell me that you don't. If you don't, do please come tell me because otherwise you will be in serious trouble, and it is fixable. OK, @0705so that's the course web page. The next thing, this is what you know more about than I do. The system for turning in assignments is WebCT, which probably all of you have suffered through. Right? [laughter] @0720I last touched this in 2004, and it was a real bear. I think they've made it a little better now. It's actually better than anything else that I've seen. The reason it has to exist at all, @0735as opposed to just having everyone put homework up on a wiki, is because legally we're not allowed to let other people see your homework assignments. The whole thing is basically just to protect confidentiality, as far as I can tell. There's no other reason to have all this infrastructure. @0750In fact, I would love it if one of you could try this. If one of you who actually is online, if you could actually go to WebCT and see if you can log in to the course. So this is the @0765WebCT login. Actually, I think you do webct.ucsd.edu. It's not going to do this for you what it does for me. Student: It's not showing up. Miller: It's not showing up? In what sense? Student: : @0780After you log in it tells you what classes you have on WebCT. It's not on that page. Miller: And you don't have 171 as one of your classes? Student: Not yet. Miller: OK. I was worried about that because I asked for the class roster and I got not a single student in it. I have to call in @0795to WebCT to ask them if there's something that I should have been doing that I haven't done yet, which is probably going to turn out to be the reason. Sorry. OK. So this is not going to be an urgent issue until a week from Thursday when it's time to actually @0810upload stuff because I'm not using WebCT to make stuff available to you. I'm just using it to collect stuff. So for this week, the thing that really is urgent is another thing that I hope some of you will try because maybe this will fail, too. [laughter] @0825Which is see if you can download Pd and get it to run. This is going to be a little bit less obvious because I'm going to have to show you some things before you @0840can find out whether you're even successfully running Pd. So go back and say something I didn't say. There is a software package that you will be using for the course which is Pure Data, or Pd, and you get it from my website. @0855It will run on your computer, unless you have something really strange. It will even run on your iPhone, but that version of it is not on my website for that one. I'll tell you if you care. @0870You can run on Android, too. So you can have a lot of fun with this, but right now we're just going to be using the standard one on the computer and making things easy. So to do that, you do this. Or there's several things you can do. @0885I'm going to show you what I normally do, but your mileage may vary. The link is on the website, although you can also find this through my home page if you want to do that. There's all this good @0900stuff, and here is Pure Data. You can be conservative and use version 42, which works, or you can have fun and use version 43, which sort of works. [laughter] @0915But which does all sorts of new stuff. Yeah. OK. There's one thing I know that doesn't work in 43 which you're not going to get for another week, so I will try to fix that by the time you get it. @0930Anyway, I'll tell you with this one I can, which is when I told you what the object is that doesn't work right. Anyway, I'm going to be using 43. In fact let's just do this. @0945If you have a Macintosh that's more than six years old, you will want this funny version. Otherwise, you will want one of these, Mac OSX. Can I ask for a show of hands, @0960this is just out of curiosity, well, actually it matters somewhat but mostly curiosity, how many of you have, as your primary computer, a Macintosh? Wow. OK, how many of you have @0975the primary computer of a PC running Windows software? OK, so maybe 80 to 20, something like that. How many of you are running something else? One, two, @0990three. [laughter] Very good. The reason I brought the Macintosh today -- actually there are two reasons -- the honest reason is that a Linux box doesn't have DVI out so I'm kind of stuck with it now on compatibility mode. @1005The other reason is that I want to look like you guys are looking today, but then by Thursday you're going to be watching me play with Linux instead of OSX. All of the OSX lore, unless I decide really to punish you and bring the PC in. [laughter] @1020We'll see. No promises though. We're going to be Macintosh today. We're going to grab Pd, the scary one, and I think... I don't know what you do with these things. @1035Let's just tell it... I know. [laughter] I usually save it, and then I get into a shell, and then I type TAR, space, XZF, space, blah, blah. You probably don't want @1050to know how to do that so I'm going to try to pretend I'm a regular computer user. One of you is trying this, right, so that you can see if it's actually working? What did it do? Student: I don't know. Miller: @1065I think I just... I thought it opened? Student: No, your window just froze. Miller: See I just did that. It already did that to somebody already. Student: It's in the new Balance folder, I think. Miller: What is that? It probably threw it either on the desktop @1080or in the home drive. Oh, I'm running Pd. [laughter] Oh, look. It looks like I've got all this good stuff and now I don't know which of these is the one I just downloaded. Student: Right there. [laughter] Miller: @1095Let's get maybe this one. Student: Left hand side, left hand side. Miller: This must be it right here. All right, this is the one that I had to start with today. [laughter] Sorry, I don't think it will hurt you to have more than one. Then you just do this. That's the easy part @1110and then maybe this will happen, maybe not. One thing that I've noticed, the first time you do this on any computer, sometimes it seems to take 30 seconds for Pd to start up. So if you click it and it does nothing for 30 seconds, I don't know what that is, but that's @1125Steve Jobs doing that for you. [laughter] Student: Will Pd Extended work? Miller: Yes. Oh, thank you. Another thing that you can do, which will be more fun, is go get Pd Extended as opposed to Pd Pd. In fact, it's so much fun @1140I'm going to do this for you, too. The problem is I've forgotten where the... Oh, so we just do... Get in the browser, and then we say, Pd Extended. @1155Pd Extended, Pure Data downloads, Pd community site. I don't know what the difference is between that and that. All right. @1170This is the redoubtable Hans-Christoph Steiner, who is a person who aggregates-- well, does many, many things for Pd including actually spearheading Pd's Release 43. @1185But he's also making the so-called Pd Extended installers. For those of you who know what's going on with Pd and/or Macs, they have various kinds of objects in them. Pd itself ships with a couple hundred objects, and @1200Pd Extended ships maybe with a couple thousand objects in it. So you have lots and lots and lots more stuff to play with in Pd Extended, if you can figure out where to find it. [laughter] Once in a while I actually reach... You know, @1215I don't want to make a Butterworth filter. They've got Butterworth filters in it. So there are things which you care about which you can get in Pd Extended that are sometimes really worth getting. The other thing about that is when you want to make graphics, Pd has an extension @1230called GEM, the Graphics Environment for Multimedia, which will allow you to make graphics and also to shoot video and analyze it. Basically do with video the same things that Pd will do with audio. It's not really part of this course, but @1245Pd Extended has that. You can go make movies or whatever you want to do with it. I'll show you a little bit of that just as a teaser in week 10 when we're reaching out a little bit in the subject. So, Pd Extended. @1260The last time I did this it was very easy, so I'm hoping this will still be here. So download Pd 42. This is the one that works. Pd Extended 43 @1275is up there somewhere, too. So if you want Pd Extended in its natural state, you can do that. But anyway, I think what I do is click this, and it says, "Go to virtual online application." @1290Oh, yes. I want to open it with... Oh, it's a disc. All right. @1305I'll say something interesting for 38 seconds. Actually I sort of know this is going to work because I already have one of these things. It worked the first time. @1320Meanwhile, nothing will happen until... Now it's doing a clean-up. ... [laughter] No, OK. All right. @1335 @1350So I don't know why that was just faking me out. All right, we're done. @1365So disc images are things you click on like anything else in Mac. New? OK, I'll leave. [laughter] And ta-da, we have a disc that consists of, well, @1380no one. [laughter] As it starts, you can ignore it. It's quick when I do it the right way. So this is the Pd Extended application and I didn't do that, I just did this. [laughter] @1395Why? Because you don't really want to throw stuff into your applications folder. @1410I won't explain all the reasons you shouldn't mess with your applications folder. You'll have to guess. [laughter] Then it takes too long to do runs. @1425This is all the stuff that it either loaded or didn't load, and that's good. But now we're running Pd Extended. More about that later if you want to find out about that. Let's get out of here now and get back to being @1440vanilla. Take that, get rid of it, take that, get rid of it. Get rid of this. All right. @1455It's all free so you can throw it away any time you want. [laughter] So, next step. Now you've downloaded Pd. Has anyone actually done this? So, next step is, @1470see if it's working for you. Of course, it should start when you click it and it should also make sound when you ask it to make sound. Actually, that's the real step that means you're doing computer music. To do that, to find out @1485whether that's happening, there are two places that you should think about looking. I always go to the impatient place first. The impatient place is, go to Media and say "test audio and midi" and up comes @1500a Pd patch. This is a Pd document, first one you've seen so far I guess, and this has indicators @1515that say whether sound was coming in to your computer. These are numbers and decibels which you learned about in musical acoustics last quarter. These are in decibels with 100 being full blast. I don't have a microphone so this is the noise level on the audio @1530input device in my computer. There's nothing plugged in. So, I have a signal-to-noise ratio of, compute that and it's... Student: @1545Four minus. Miller: So the loudest signal I could get would be 100 here and I'm looking at 28. So the signal-to-noise ratio is 100 minus 28, which is 72. Which, there's not audio hardware supplied. @1560That's bad. OK. Now the other thing that you want to know... OK so, but sound is coming in. I like to seeing that better than I like seeing zero. What I really like seeing is one or two, which means I've got decent audio hardware. Now I can make sound, which is to say I can @1575ask the test tone to go on, and this is in decibels too, again, with 100 being full blast. So a good place to start is 60.[tone sounds] Now you hear a nice A440. Or here's 80.[tone sounds] @1590I always do 60 first because you never really know where the speakers are set.[tone sounds] While I was... Yeah, there it was.[tone sounds] Now, what I didn't show you was, before most of you came in, I @1605connected my computer to the audio system in this room along with the projector. So what you're hearing now is the computer's line output...[tone sounds] ...talking to my stereo. And any of you who has a stereo can do the same thing, and that's a better way. @1620That or headphones would be a better way to operate than using the little speakers that are on the computer. Yeah? Student: Did you say the lower the number the better? Miller: Well here, yeah. If there's nothing plugged in, the lower the number the better. But @1635if you have a laptop, your laptop might have a microphone. So you might not just be looking at the electrical noise level on your equipment, but you might actually be looking at sound. If that's the case, then when you say things that number goes, up. Then you get really happy because @1650you got audio and then you can start making cool processing actions. I'll say that this will happen to you, the first audio process you actually make will suffer from horrible feedback if you're using the microphone with speakers on the... @1665Yeah, like that. [laughter] Because the mike is very close to the speaker, right? And so the sound comes out of the speaker and back through, like that. If you want to control that, plug in a pair of headphones, which usually will mute the microphones. Then you can listen to what it's doing and @1680the microphone will work properly, I think. Depends on, you know, your mileage may vary. The other thing, just telling you about this, I want to just tell you the basics about getting started. @1695When you do this...[tone sounds] ...and that happens, it's great. But it's possible to do this and not have the sound coming out. Then there are things that you might want to do to figure out why, whether you have sound or not, and that all is here, @1710under Pd. So this window popped up when I set the test audio and midi. By the way, this will be possible to do but not useful. I could have two of these up at once and they'll be fighting each other. So don't do that. @1725So then in Pd, that was in media, audio and midi. In Pd, you get preferences which have audio settings. We're not going to talk about midi today. And audio settings @1740are what sample rate we're running at and a magical number, which I should tell you about, and what audio devices, and what number of channels. Now I can do things that will cause everything to break. Let's have @1755eight channels of output. All of a sudden, nothing happens. Maybe, I hope, I have an error message. I have lots of error messages. [laughter] @1770It didn't even give me the proper error message so I can't do it. So this is the "can't do it" mode. You don't see anything here and you don't hear anything coming out. That just means that your audio device didn't get opened. That could happen for all @1785sorts of reasons, which are hard to disambiguate. But in that case it was me asking for something impossible like that. Also if I ask for megahertz out, I don't think it's going to agree. @1800Can't do that. So you have to ask for something reasonable. And the standard CD sample rate is 44K1. [tone sounds] @1815Now we're back to being happy with the input now. The other thing that can go wrong is you could... You can't make it not be happy right now. @1830You can have this thing dialed in on a device that is no longer plugged into your computer. You buy a USB audio device, you plug it in, you tell Pd to use it. Then you unplug the device, it no longer exists, Pd starts up, you can't find it. Then you @1845see here it's just a little circle which has nothing in it. You just have to click on that and select the thing that you really want. The other thing that I want to tell you is this number here, the delay, @1860this is the spooky setting that matters but which is hard to figure out how to deal with. This is a number which is 80 milliseconds or up, if you're using Bill Gates' software. Or it's @187520 to 30 if you're using whatever his name is, Bill Jobs', Steven Jobs' thing. [laughter] Or you can get it down to about 10 on Linux. This is the amount of time that passes between when sound @1890comes in the machine and when it comes back out. And if you try to make this too low, Pd should be showing you errors, which I'll see if I can find here. [tone sounds] Do you hear that? @1905Let's see here. I'm running 43. On 42 you would see a red light saying digital @1920IO errors. I'm trying to resize the window. It's too big for this stuff. Can't do it. OK. No, it's not there. All right. Never mind. @1935I don't know where you see the error. You just hear the error. Here it is. [tone sounds] And that's because I asked for a delay that is smaller than my hardware can provide. @1950Oh, I did a 15 and now it's clean. But now let's see if we can do 15 to 1. So the smaller that number is, the faster the tablet. That matters because you don't want to do something @1965to your computer and then wait a second before you hear the output. You want it to happen as -- Well, you want to have it happen with a small enough delay that it sounds like it's happening at the same time. Which, depending on your musical chops and which instrument you play, @1980might vary between five and 30 milliseconds. What this means is that Macintosh latency's 15 to 20 milliseconds, maybe, or 25, are barely acceptable and the Window's latencies that you get @1995are basically unacceptable. And I can tell you that that's only the built-in audio hardware on those devices. I have seen Windows boxes get very little latency by professional audio hardware you put on it. @2010So if you're a real gear-head and want to buy the gear, you can gear your way out of the problem. Although you can also just take this, plug it into your machine, and turn it into Linux, @2025which is what I would do. [tone sounds] Sorry to belabor all this, but this is important because you have like eight days, nine days to get this all happening and be turning in homework. So I want to make @2040this as painless as humanly possible. Questions about all this? I know I've forgotten things. Yeah? Student: So what you're telling me is that the latency... Which one's the latency? Like between Windows and Mac, is it the @2055hardware on there or the processing speed? Miller: No, it's certainly not the hardware because you can fix the problems by loading Linux on the same hardware. @2070I can't even generalize and tell you something that's really true in every possible case, but in some sense the audio... Well, audio systems consist of layers of stuff on top of stuff-- the driver and the @2085API and the Pd itself -- and they all have various amounts of buffering they do, buffering meaning the amount of memory that they allocate in order to deal with being on time with everything. So when you write something to a computer's audio output, you don't @2100just write the next sample that has to go out. You write several or many milliseconds in advance so that the audio hardware can be throwing them out while you're off thinking about email or something. So that then, when you get back to writing a sample, you're still ahead of what it's doing. @2115So there is a first in/first out buffer sitting in your audio output driver. It's throwing stuff out here, and you're preparing stuff for it to throw out, and you're staying ahead. But you're stopping every @2130once in a while because the OS is not treating you right and it is still reading. If it reads something before you wrote it, then you will hear bad noise. In fact you'll exactly this kind of bad sound now. [tone sounds] In general, you'll hear this sort of bad noise I'm just giving you. @2145This is a paradigmatic sound. So why would one @2160operating system or one audio application program interface require more buffering than another? You have make enough buffering to deal with whatever your operating system can do for you, in terms of calling you @2175back in short periods of time, and that is from the OS. But also, different writers of audio software are sometimes more or less conservative in the way they design these things. So in truth, Windows is overdesigned. @2190It could be a great deal racier, maybe one time in a million, fail. They can't fail one time in a million because they'll get phone calls. So they just make the buffer real long so the phone doesn't ring. @2205So, there's that. Now I can start doing stuff, I think. Are there questions before I actually start doing stuff? @2220So do, please, before Thursday, get this downloaded and running so that you're not discovering that you can't do your homework next weekend or something. So next thing is this, what is this thing good for? @2235So what I am going to do is make a patch that makes a sound. Then I'm going to go back and do some theory, simply because I think it might be better to @2250see the thing happen first and hear the theory afterwards. So what I am doing also is I'm simultaneously surreptitiously teaching you how to use pure data. The real content, of course, isn't Pure Data. It's the technique of @2265audio synthesis processing and analysis, which in fact you could do in software packages other than Pd. If you want to know about lots of possible software packages, I know them all. I can tell you all sorts of stuff you can do @2280with a computer, in some other context. I am going to just select a ridiculous font to start with. The basic thing you do is you put @2295stuff on the screen so there's this nice menu I can click. What I am going to do today is going to be limited to two kinds of things that you can put down. One is going to be objects. Of course, that really means 200 different things because I have to type in @2310what kind of objects they're going to be. So that's going to be where I live most of the time. The other thing is I'm going to need a button later on. So first off, I'm going to make an object. It shows up and I can... OK. @2325Here's the thing. This has a dotted outline that says that there's nobody in there right now. In fact, if I tell it, let's be some object that doesn't exist, it'll still say, "Nah, there's nobody there." In fact, it even got mad at me. @2340Now I'll just ask it to do something it knows how to do. There's an oscillator, and oscillators take as an argument... Yeah. @2355So I'm going to ask it to play A. So you've had musical acoustics and you all know that 440 hertz is A above middle C, right? That's one of those physical constants, like the speed of light, that people just don't touch. You just have that. @2370Now we're going to say what amplitude we want. So I'm going to put in another object. I'm doing this in the slow way now. I'll show you the fast way later. Put another object and put it down here. Then I'm going to type @2385 "times tilde," I should say, and ask it, let's only be a tenth of a hold for the blast sine wave. OK. I'm going to crack the book in a moment and show you in waveforms what we're talking about here. But for @2400right now just talking over this, this is putting out a full blast 440 hertz sine wave. By the way, you might know this intuitively, but these things are inputs up here and @2415this is an output. I'm going to hook the output of the oscillator to the input of times 0.1. What that is going to do is it's going to take the amplitude of this and reduce it from full blast to a tenth of full blast. What's full @2430blast? 100. Then I'm going to say put another object and this one is going to be -- this is kind of not well named -- it's going to be the "digital analogue convertor." That's the @2445person in your computer who takes those numbers and turns them into voltages. Now I'm going to say... [tone sounds] Oh, wow, it just worked. @2460Take the output of this thing and put it into speakers. That's to say make it available to the audio output of my computer, which by the way is connected to the speaker. Now how do I make it shut up? @2475There's this control here which says whether you're computing DSP or not. DSP, I don't know if that's a good name, is "digital signal processing," and that turns the network on and off. @2490That's the fastest way to get silence if something's happening too loud. That's important so there's a key accelerator: The slash turns it on and period turns it off. Oh, command slash is on and command period @2505is off, which you can think of as mute. It's not really mute, but you can think of it that way for now. All right. Now the other thing that I should have mentioned is that when you start Pd, @2520this thing is turned off. The reason it was on just now is not because I surreptitiously turned it on, but because the test tones, which I've already had out, automatically turns the DSP on so that it can make noise. @2535As a result, I was using the fact that DSP was still running, even though I'd closed the test tone. So this thing stays on regardless of whether I have the patches open or shut. I can close this patch and it won't change the status of whether DSP was @2550running or not. So this is more software. No, this is half software and half theory now. DSP running, what that means is every object whose @2565name ends in a tilde, if DSP is running, is computing 44,100 numbers per second. Or a number of numbers per second equal to the sample rate, I should say. @2580But 44K1 in and out. What that means is that when this is turned on, this output contains a stream of numbers, one every 44,100th of a second. @2595Let's say one every 22 microseconds. All right. And furthermore, each of one these things is doing that. It's using all of its inputs. It's receiving inputs at the same rate. If nothing is connected to one of these inputs, the input is... @2610All right, that's a complexity. If nothing is coming to an input that expects audio, the input is zero. I'm going to have to repeat in @2625several different ways distinctions between these streams of audio and things which happen sporadically, which sometimes we call "control" or "not audio." But what you're seeing right @2640now is connections between the audio output of the oscillator and the audio input. And what you have to know is this input expects audio and this input expects not audio. It expects messages, which I will tell you about later. @2655All right. So this network is -- I should say, these connections are like carrying numbers when it's turned on and they're not carrying numbers when it's turned off. @2670This input actually does expect an audio. It expects this audio signal. For instance, if I have this on I can break this. To cut a connection, select the connection, which turns it blue, @2685then hit command X. So if you want to try the other output, do that, or both. You can have fan out if you want. @2700While we're at it, you can have fan in. What's the interval between this frequency and that frequency? Any takers? What's the ratio @2715between those two numbers? Three to two. And that's what interval on the piano or musical scale? Yes, a fifth. [tone sounds] Ta-da, mathematics @2730turned into music! So the reason I did that was not to tell you what a fifth was, but just to show that you can hook two people into an audio input and it will just add them for you. Over here, @2745here's another thing you can do to demonstrate psychoacoustics effects. [tone sounds] All right, so I'm going to shut this up and talk a little bit more. @2760Is this all clear, what I've done so far? To do this, basically you do what you do with a computer, which is you sort of flail with stuff and find out what it does. But let me do a little bit of the flailing for you @2775so that you can expect things to happen when they do. The most confusing thing that will happen is this. You will reach to move something, like this, and it will move. @2790And you will be happy. Then you will release it and then you will click it again. Then you won't be able to move it anymore. It won't move. Now I'm editing the text. @2805What do you do? Well, if you're in this state, which is editing the text, and if you want to move the thing, deselect it and then move it. This is second nature to me, but everyone has to do this the first time @2820and it will confuse you for a second. So you can immediately move something that's not selected, but when you select something, when you release the mouse, the text is selected for you to edit the text, which is more than likely what you're going to want to be doing. But in case you really just wanted to move the thing, @2835then you have to deselect it so that you can move it after you deselect it. Also, you can select something by clicking on it, which selects the text, or you can select something as part of a region, @2850and that doesn't select the text. That just selects the objects. Then you can move things. Am I going too slow? Yeah. All right. @2865OK. So also, you can select a single thing as a group using the group selector thing, and again, it just selects the object. OK. Next thing @2880is this. I want to show you what this actually really is, and to do that I have to introduce two new objects. While I'm at it, I'm going to tell you there is, of course, a key-accelerator for putting an object @2895and it's "command-1", and then I can say "print." This is object number four. So I believe in the first week you're going to see about 10 kinds of objects. What I try to do is limit it to @2910five a day. First day is going to be iffy because we're already up to four. But theoretically, we will not be learning lots of objects all at once, but they will be coming out at a steady rate. So right now, we've seen the oscillator, OSC tilde, @2925we've seen the multiplier, we've seen the output, and now we've seen print tilde. What I'm going to do is I'm going to show you what the oscillator is doing by hooking it up to the print. Now logically, the first thing that you @2940would expect this to do would be to print out 44,100 numbers a second, but it turns out that that would choke any computer in the world to try to print that stuff. Plus you wouldn't want to see it. So instead of doing that, what it does is it waits until you tell it to please print the next @2955glob of data, and it prints it globs at a time. So now what we're going to do is we're going to put the bang under it, which is a button. Oh, let me do that slower. So put, I've been putting objects, but I'm going to put this thing down now. @2970 And it is a thing which... And now I have to let out more of the truth. OK. I'm being very careful, trying to let out bits of truth very slowly. So see now that this line that I connected is only one pixel wide, @2985 instead of two pixels wide, where this one is. In other words, these are nice dark lines here, but this is a lighter line. That is to tell you that this is not carrying an audio signal, but is @3000for control. It's for sending messages. Messages are things which happen at specific times, as opposed to signals or audio signals, which are happening continuously. The message that this thing @3015sends out is: Every time you click on it, out comes a message. The message just tells it to do their thing. In this case, it says do you print, please? @3030What has happened? Oh, because I have this turned off. Now I'm going to turn it on. [tone sounds] And now it prints out. Every time I whack it, it prints out a new collection of data. [tone sounds] @3045So print tilde's job is every time you ask it to, it will print you out the next block of data. @3060So there's built-in knowledge about what Pd is doing here, which is that Pd doesn't actually really just compute one audio sample at a time. It computes them in batches of, by default, 64 samples. @3075And let's see if we can get this thing shut off. It should make a nice space with these numbers printed out. So this is 64 consecutive numbers of a sinusoid, which is to say, @3090a sine wave, which is the thing coming out of OSC tilde. This is basically the first and most truthful tool at your disposal for finding out what's going on inside of @3105a patch that's doing audio. It's clunky and stupid, because this amounts to about 1.45 milliseconds of sound. So looking at this wouldn't actually tell you much @3120about what really is coming down in there. But if you tried to see it, it would be too much data. Anyway, you can see that good things are true about this thing. What's the maximum amplitude? It's about one. @3135Here's an almost one right there. So what you're looking at is just numbers, but if you graphed them you would see a rising and falling part of a sinusoid. Now let me get you to the book and show you what this is @3150in a picture. You can make Pd make pictures, but I don't want to teach you how to do that yet because there's too much detail involved. So I'm just going to provide data off of them . @3165Where was I? Don't want to do that. I want to do this. Yeah. All right, good. OK. So I told you there's a textbook. This is the textbook. You can buy this if you want to spend, I think it's $79, @3180and they did a good job of printing it. But you don't need to buy it because you can just look at it on the web, which is more convenient. But if you want to read it in a hammock, you can buy it. You can spend $80 and buy the thing, or print it out. @3195But don't tell them I told you to print it out. I'm skipping some stuff, which maybe I should go back to, but here's a picture of what a digitized audio sample looks like in graph language. @3210There are two pictures here because this is what you want, in some sense. What you want to make the speaker cone do is to move like that. The speaker cones live in continuous time wher time isn't split up into @3225trenches of 22 microseconds a hit. So the computer's representation of this, however, is split up into screen time and therefore if you graph it, it would look something like that. This audio signal has a @3240frequency and an amplitude. This is in fact exactly what would come out if you gave the appropriate frequency to an OSC tilde object. It varies between positive one and negative one. That @3255has no units. That's an arbitrary scale. But I should tell you that if you put something that's more than one or less than minus one at your audio output, that's to say if you feed @3270something that's out of that range to DAC tilde, then your computer will not be able to play it correctly. It will click. So this is the full audio range of your computer's audio output. How does Pd know that? Pd just asks @3285the computer, what range do you want to feed your DAC in? And it normalizes that to one. All right. The frequency that you would do this at is manifested in how many of these samples @3300it takes for the thing to make an entire cycle. This is all acoustics, right? In fact, what this is if you give it an equation is one of these things. @3315It's an amplitude times the cosine -- you could use sine, but I'm using cosine here -- of the frequency times the sample number plus a phase. So if you take one of these things and graph it, you will see @3330something like what you saw graphed down there. Furthermore, you can change the numbers a, which is the amplitude, or omega, which is the frequency, or phi, which is the initial phase, and you can change the way that it looks @3345in one way or another. n is the sample number, and that is the horizontal axis here. I'm insulting your intelligence here. @3360This is all it is though. All you do is you do this and say we'll change that equation and we get all confused. I've done this for 30 years and it never gets old. So what is omega here? @3375Well omega was enough so that after 20 samples the thing comes around and cycles. So omega is two pi over 20. Omega is the frequency out there. @3390So N is the number of the sample and this is the thing which controls the frequency, but it's the physical frequency of the thing as an array of numbers. It's not a heard frequency, and you can convert that @3405to the frequency-frequency by a simple formula. The frequency you hear is the omega, is the angular frequency is what that's called. @3420Time and sample rate divided by two pi, and that's how you make a sinusoid. So if you want it to be louder, change A. Or -- and here's why, @3435for this I have to go back to the patch -- if someone gives you a sinusoid and if you want to change its amplitude, all you have to do is multiply it by the ratio of the two amplitudes. That is, multiply it by the gain you want, gain meaning the difference between the two amplitudes. @3450So what that means is what is coming out of this equation, what's coming out of this oscillator right now. @3465Omega is two pi times 440 divided by 44,100, whatever that number is, and @3480A is one. The amplitude of the output of this thing is one. So what this is really putting out is the cosine of omega times the n, and forget the phase for now. Time is just passing and we don't know what the phase is right now. @3495But if we want to change this amplitude, if I gave you just cosine of omega, if you said, "No, I want 0.1 times the cosine of omega," in other words, I want something with an amplitude of 0.1 instead of one, then @3510the solution is to multiply the thing by 0.1. That multiplies it this way. It changes the amplitude. It doesn't do this. That would be... Yeah? Student: So if you were in your print command, @3525like your oscillators, then just having them separate, would that, instead of going all the way to one and down to negative one, would it just go up to 0.1 and down to negative 0.1? Miller: Yeah. Thank you, because I actually meant to do that but didn't. So I think what you're asking is, @3540"What if I just print the output of this?" Right? Student: Right. Miller: Yeah. OK, good. So it'll do that, and I forgot to turn... Oh, so nothing happened because the audio is turned off. So I'll turn audio on and it will say, "Oh, I need @3555to print something." [tone sounds] Yeah, there. Now what we see is kind of ugly. I'm sorry the spaces aren't worked right. But what you see is something that's going up to about 0.1. It is 0.9998, instead of one. So these numbers @3570are these numbers divided by 10. Except that I asked it a different time and so actually they are like them but they're not exactly the same as those divided by 10, some of the phase. All right? @3585Is that all clear? OK. Now without anything besides those things, @3600what have we got? We'll do those two. @3615I'm going to raise the total count of objects to five, but not in a very interesting way. I just need an adder. @3630Now what I'm going to do is I'm going to take the oscillator and have it be zero plus 440. Let me check if that gives us the same thing. Yeah. There's zero coming in here and we're adding @3645440 to it, so it comes out here as 440 volts, if this were an analog synthesizer, 440 volt signal. The oscillator then is giving us a signal that's plus or minus one volt, but it's changing 440 times a second. @3660The reason I did that is so that I can do this, take another oscillator, or get another oscillator. Oh, I'm doing this without telling you what I'm doing. I'm selecting this object without selecting the text and I'm hitting command D, which duplicates it. @3675It duplicates it and leaves it selected without the text selected, so that's very convenient for me to move it. This one I'm going to say six. And by the way, the machine duplicated it, too. @3690Look at this from a different perspective. Come on. Yeah, by the way, let's multiply that by something. No, let's not yet. Let's just leave it. @3705See what we get. Anyone want to guess what this is going to sound like? All right, I'll show you. [tone sounds] @3720So it's the oscillator on that. Oh, I can just connect it and show you. There is the sinusoid and here is the sinusoid. Its frequency is changing @3735once a second. It's going up to... OK, so here's an oscillator and it's going at six cycles per second, and what's its amplitude? Student: One. Miller: One, right. OK. @3750So then when we add 440, out comes not the 440 volts, but a varying voltage which varies from 339 to 441. That variation repeats six times @3765per second because this thing is happening at six cycles per second. But in fact, to make this an easier thing to hear, I will say let's multiply that @3780by five. This can be ugly, but we're going to do it. This will be quite audible. [tone sounds] Not quite as ugly as I want it to be. So now we're varying @3795between 435 and 445 hertz. Now of course, since it's a computer, you can tell it to do anything you want. [tone sounds] @3810It sounds like it's doing two pitches at once, to me anyway. But I'm in a weird place because I'm getting an echo from the speaker sounding. OK, let's do this. [tone sounds] Or, no... [tone sounds] @3825OK, let's not do that. So it's a computer, it'll do anything you tell it to, if it was a good idea or not. It doesn't matter to it. @3840And furthermore, it won't hurt you because what comes out won't be more than outside the range of the DAC. So as long as you don't crank your stereo or your headphones, you won't injure yourself doing this. @3855I think that what's going on here is it changes its speed to vibrato. I need it more to make this obvious. Right. I'm sorry, this is ugly now. So this is just how fast @3870it's going, once per second, twice per second and so on. You know what I didn't tell you? When you start typing in an object like this, it doesn't immediately change it to the new object. It @3885only does that when you click off of it to deselect the text. And furthermore, if you do something bad like this and then it would say, oh, @3900I couldn't create that. Then it prints the dotted line to tell me the object would be bad. But it kept the connection so that I don't have to remake a connection when I fix the problem. The problem here is that OSC tilde has a name that only @3915works when there's no space in its interior. For those of you who are computer scientists, space is "the delimiter." That is essentially the only delimiter that you have to deal with. @3930So don't try to make an object if its name has a space in it. Student: So just a question about the setup. So the amplitude for the OSC tilde is one, right? Miller: Right. Student: @3945And we times it by 30. Miller: Right. Student: So that makes the amplitude for the 440 between 410 and 470. Is that right? Miller: Right, and that's changing three times a second. Then that's becoming the frequency for the oscillator. @3960I didn't tell you something important. Frequently, objects will give you the choice of specifying their input or connecting to their input to set it. Here I've said "oscillator" which means @3975we're just going to take a signal and specify what our frequency's going to be. [tone sounds] But here I'm saying "oscillator" but I know what the frequency is. It's three, so I'm just going to keep it on. There's another way in too, which is that you can change these in messages, but I'm not @3990going to try to tell you that. Student: Is there a map of all the names of the objects that we learned? Miller: If you really want to see it, you say "Help." Right-click on it and you @4005can get help and help within a patch, which tells you everything you want to know about it. OK, so that was help. @4020So if you want to have multiplier help, you do that. Then if you right-click on the canvas and say help -- the canvas meaning the document but not @4035any of the objects in the document -- then you will get this lovely patch that someone else made. It will tell you everything in this very carefully organized order. But this will only be the first 200 objects, @4050which are the ones that you get before you get Pd Extended. More than one... [laughter] That's funny. @4065I didn't see any specific examples but I'm just about sure that there are two copies of this thing here. Never mind, I'm sorry. There really is @4080this much stuff. Well, sorry, it's just what it is. Maybe there are more than 200 objects now. So that will tell you everything that you might need to know. If we're doing @409510 a week, at the end of the 10 weeks you'll know 100 of those objects. You don't need to know them all. I know them all, but you're not me. [laughter] @4110Basically, with about 100 of them, you can do a whole lot of stuff. And then there will be an occasional thing that you can't do with those 100 that will require that you find another one out and thereabouts. So what happens is that there will be a period @4125of intense learning objects, like 10 a week. After a while, you won't need 10 new objects, there won't be any more and things will calm down. Other questions? Yeah. Student: How do you get the print thing to work again? Miller: @4140OK. So oh, yeah, there's a thing I didn't tell you, which is fundamental. The patch can be in two different... Sorry. The interface of the patch can be in two different states, which are sometimes @4155called "run mode" or "edit mode." If I try to click this thing now, I'm just editing the patch, and that doesn't click on it. It just moved it, right? So what I have to do is put myself @4170into run mode, which I do here. Let's get out of edit mode. Now edit mode is no longer... Whoops! [laughter] It is still on. [tone sounds] [laughter] Miller: OK. Well, this is version 43. @4185You tend to get what you pay for. [laughter] Anyway, the indication is what the cursor looks like. So right now what you see is an arrow. And if I do that again, you will see an arrow again. [laughter] Like now. Now it's just being happy. [laughter] All right. @4200You cannot get out of edit mode. [laughter] That's cool. OK, well, I'm expecting to see stuff like this because we're in pre-release. Student: Does the shortcut work, Apple-E? Miller: @4215Oh, the shortcut works great. So the shortcut, you just hit DSP, command E, or Apple E. And then it goes back and forth between modes, except that this is a thing that Hans has driven, and just torn hair out of his head over it. @4230You don't actually see the new state until you move the cursor. Because some smart person at Apple thought you would never have the cursor change unless you reached it, unless you changed wherever the cursor is. So what you have to do is change @4245the mode, but then you have to jiggle the cursor to see that you are in the other mode. Isn't that horrible? That's only on Macintosh, so only 80 percent of you are going to have this trouble like we're having today. [laughter] Student: 90 percent. Miller: OK. So anyway, @4260we're just moving to make sure this is what you think it is. When you're in the run mode, which is not edit mode, you can click this thing and get it to do its thing. And of course, sorry, we also have to turn on audio. [tone sounds] @4275Of course, there's a reason why I'm not on audio. Let's see. Let's just do this. So now we can turn the thing on but not hear it. Now we're running so I can do this. But if I can get @4290back into edit mode, like this, then I can click it all I want. Although, sometimes you can hold the command key down and click it. And it will say, it's as if you were in run mode. @4305So the command key operates as a sort of shift into run mode thing, if you can remember that. I never remember it, so I just toggle the mode. Other questions? Did that answer yours? Student: Yes. Miller: @4320OK. Yeah? Student: I just want to make sure I understand print and DAC tilde. Print within run mode, when you click it, it creates a graphical mathematical representation of that patch, is that right? Miller: @4335Well, not even graphical. It just prints the numbers out. Student: All right. And then the DAC tilde, then the time is...? Miller: OK, so the DAC tilde, that takes whatever the signal is... [tone sounds] ...and puts it there. So it @4350causes it to appear as an audio output. So this is, print the values out so I can see them, and this is, play them so I can hear them. Student: Is that abbreviated for something? Miller: DAC? It's "digital-to-analog converter," and that @4365used to be what people called it. There actually is a DAC in your machine, but people never seem to use that term anymore. So, yeah. Yeah? Student: It only prints the first 64 though, right? Miller: It only prints the next 64, until you whack it. @4380Of course, if you really wanted to... No, never mind. I could ask it to print more. Yeah? Student: Do you have a limit in the inputs and outputs? Miller: You mean as to amplitude @4395or the number of inputs or....? Student: Just how many things you can enter. Miller: Oh, no. Student: You can have more inputs than objects? Miller: Yeah. Oh, wait. Add more than just an object, meaning... I think what your question was, was how many other things could I run into this... Student: Right. Miller: ...into these fixed objects. @4410But I can do that and you'd never have to stop. But could I make the object itself have more inputs? Each object has its own schematics about what its inputs and outputs mean. Some of them actually do have variable numbers, but you won't see those for a couple of weeks. @4425Other questions? These are good questions, by the way. Yeah? Student: You said that the right input was an input for messages? So if you try to put an input, like with an audio, to that, it won't work? Miller: Yeah. Student: @4440You have to keep it to the left. Miller: Yeah. So for these particular objects, the right input is... Yeah, OK. So we'll get there, because there'll be other things where there will be more than one audio input. @4455Sometimes you'll want to multiply two audio signals or something like that. And I'd be scared to tell you that right now. I'll tell you about that on Thursday. Student: Is this only one channel right now? Like, left only? Miller: I've only been using the left side, mostly. When I'm working @4470at home, I use both sides... [tone sounds] ...because it irritates me to hear every sound out of just one side of the thing. You know, it's just what you like. Yeah? Student: So there's no spaces unless you put a number in there? @4485You just have the space to put the number. Miller: Right. Student: Because otherwise you just get the domino effect. Miller: Right. Yeah. One way I can have it fail is to add a space right in one. So I'd be looking for an object named OSC and I didn't see one. @4500The other thing I could do wrong would be to not put a space there and so it would look for an object named "OSC tilde three" which doesn't exist. Student: Are there any defaults if you don't put a number in there? Miller: Yeah, zero. [laughter] @4515You can add zero to something, you could multiply by zero. But if you don't fill that number in, then the other inlet becomes an audio inlet. @4530Then you can run an audio signal in there instead. I wasn't going to tell you that. If I just want to just multiply by something else, then I just don't say what multiplies by this thing @4545and then it becomes an audio input. Then you can be multiplying two of the audio signals. That's really for next time, but that's the thing you would do. Yeah? Student: @4560I have a question. Why does the print object not have two inlets? Why are you going just inlets down this way to the right? Miller: Yeah, isn't that stupid? OK. So @4575inputs to objects can have various functionalities, and one of the particular things that you can send an input is an audio signal. But there are other things you can send as an audio signal input as well. Of course if a thing had @4590two different audio signal inputs, then we'd have to have two different inlets in order to be able to disambiguate them. But if it takes two things that are different, like the message in an audio signal, then you get away with these in the same inlet. If there was less @4605clutter on the screen, you'd just combine them. That's the simple answer. Other questions? All right. Go look at the homework assignment. I don't know if my machine is going to be able to play it. @4620But it's going to be to do this. [tone sounds] Firefox... I don't know if I bookmarked it. [tone sounds] And somewhere down here... You get @4635your assignment here, which is to do this. Now I don't know if this is going to play correctly, so... [tone sounds] It's lame. All it is, @4650is just a musical fourth that gets louder and softer. It's checking whether you can control amplitudes and frequencies, and understand the difference between them. And it's checking whether you can actually get around the oscillator, and the multiplier, and the adder. @4665Basically what this amounts to is understanding oscillators, frequencies and amplitudes -- and being able to kick Pd on -- which is probably going to be the hard part. Student: @4680When we turn in homework we'll be turning in all of this? Miller: Oh. To turn the homework in, just upload the patch you made. And I will give you more details about how the patch should act in order to conserve the TA's sanity. @4695There should be a clear way to turn it on, that sort of thing. But more about that next time.