[@] *** MUS171 #01 01 04 (Lecture 01) [@] The purpose of this course is to show you how to -- well, "show" I'm not sure is the right word -- is 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 do 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 that 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, in 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 1800s -- maybe 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 of 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 electronic 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 is 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. [@] I'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 it'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, to the extent that I need to actuate my computer, I'm going to be using keyboards, and a mouse, and the microphone. [@] So other than that aspect of just getting inputs into the computer, I think that 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 with 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 synthesize 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 or 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, synthesizing 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. [@] A 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 with 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 sampling, 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 perfect transformation, right? [@] In 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 analysis, 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 someone 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 automatically. [@] 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 output, 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 and 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. [@] What 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. [@] But 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, before 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 are 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. [@] What 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, but 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 a 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 a 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 and 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 when 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 have 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, I 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. [@] The course has a textbook, sort of. [@] Again, the textbook is -- where did I put it? [@] The textbook is online, and 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 that 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. [@] It 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? [@] Oh. What's the website? [@] The URL is here. [@] That'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. [@] I 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 a 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 after 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 have 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, so 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? Yeah. [@] I 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, as 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. [@] In 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 WebCT 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. [@] It's not showing up? [@] In what sense? [@] Student: : After you log in it tells you what classes you have on WebCT. [@] It's not on that page. [@] And you don't have 171 as one of your classes? [@] Student: Not yet. [@] 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 to 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. [@] So this is not going to be an urgent issue until a week from Thursday when it's time to actually upload 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. [@] Which 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 can 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. [@] It 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. [@] You 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. [@] I'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 stuff, 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. [@] But which does all sorts of new stuff. [@] 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. [@] Anyway, 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. [@] If 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, this 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 the 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, three. 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. [@] The 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. [@] We'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. [@] Let's just tell it... I know. [@] 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 to 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. [@] I think I just... [@] I thought it opened? [@] Student: No, your window just froze. [@] See I just did that. [@] It already did that to somebody already. [@] Student: It's in the new Balance folder, I think. [@] What is that? [@] It probably threw it either on the desktop or in the home drive. [@] Oh, I'm running PD. [@] 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. [@] Let's get maybe this one. [@] Student: Left hand side, left hand side. [@] This must be it right here. [@] All right, this is the one that I had to start with today. [@] Sorry, I don't think it will hurt you to have more than one. [@] Then you just do this. [@] That's the easy part and 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 Steve Jobs doing that for you. [@] Student: Will Pd Extended work? [@] 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 I'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. [@] PD Extended, Pure Data downloads, Pd community site. [@] I don't know what the difference is between that and that. [@] This 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. But 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 Pd 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. [@] Once in a while I actually reach... [@] You know, I 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 called 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 Pd 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. [@] The 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 is 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." [@] Oh, yes. [@] I want to open it with... [@] Oh, it's a disc. [@] I'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. [@] Meanwhile, nothing will happen until... Now it's doing a clean-up. ... [@] All right, we're done. [@] So disc images are things you click on like anything else in that. [@] New? OK, I'll leave. [@] And ta-da, we have a disc that consists of, well, no one. [@] As it starts, you can ignore it. [@] It's quick when I do it directly. [@] So this is the Pd Extended application and I didn't do that, I just did this. [@] Why? Because you don't really want to throw stuff into your applications folder. [@] I won't explain all the reasons you shouldn't mess with your applications folder. [@] You'll have to guess. [@] Then it takes too long to do runs. [@] This 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 vanilla. [@] Take that, get rid of it, take that, get rid of it. [@] Get rid of this. [@] It's all free so you can throw it away any time you want. [@] So, next step. [@] Now you've downloaded PD. [@] Has anyone actually done this? [@] So, next step is, see 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 whether 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 a Pd patch. [@] This is a Pd document, first one you've seen so far I guess, and this has indicators that 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 input device in my computer. [@] There's nothing plugged in. [@] So, I have a signal-to-noise ratio of, compute that and it's... [@] Student: Four minus. [@] 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. [@] That's bad. [@] 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 ask 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. [@] Now you hear a nice A440. Or here's 80. [@] I always do 60 first because you never really know where the speakers are set. [@] While I was... [@] Yeah, there it was. [@] Now, what I didn't show you was, before most of you came in, I connected 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... talking to my stereo. [@] And any of you who has a stereo can do the same thing, and that's a better way. [@] That 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? [@] Well here, yeah. [@] If there's nothing plugged in, the lower the number the better. [@] But if 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 you 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... [@] Yeah, like that. [@] 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 the 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. [@] When you do this... 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, under 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. [@] So 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 are 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 eight channels about right here. [@] All of a sudden, nothing happens. [@] Maybe, I hope, I have an error message. [@] I have lots of error messages. [@] It 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 sorts 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. [@] Can't do that. [@] So you have to ask for something reasonable. [@] And the standard CD sample rate is 44K1. [@] Now 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. [@] You 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 see 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, this 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 20 to 30 if you're using whatever his name is, Bill Jobs', Steven Jobs' thing. [@] Or you can get it down to about 10 on Linux. [@] This is the amount of time that passes between when sound comes in the machine and when it comes back out. [@] And if you try to make this too low, Pd shouldn't be showing you errors, which I'll see if I can find here. [@] Do you hear that? [@] Let's see here. [@] I'm running 43. On 42 you would see a red light saying digital IO errors. [@] I'm trying to resize the window. [@] It's too big for this stuff. [@] Can't do it. ... No, it's not there. [@] All right. Never mind. [@] I don't know where you see the error. [@] You just hear the error. [@] Here it is. [@] And that's because I asked for a delay that is smaller than my hardware can provide. [@] Oh, I did a 15 and now it's cleaned. [@] 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 to 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, might 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 are 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. [@] So 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, which is what I would do. [@] 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 this 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 hardware on there or the processing speed? [@] No, it's certainly not the hardware because you can fix the problems by loading Linux on the same hardware. [@] I 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 API 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 just 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. [@] So 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 once 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. [@] In general, you'll hear this sort of bad noise I'm just giving you. [@] This is a paradigmatic sound. [@] So why would one operating 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 back in short periods of time, and that is in 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. [@] It 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. [@] So, there's that. [@] Now I can start doing stuff, I think. [@] Are there questions before I actually start doing stuff? [@] So 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? [@] So 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 see the thing happen first and then make a theory out of it. [@] 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 audio 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 with 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 stuff 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 what 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... [@] Here'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. [@] Now I'll just ask it to do something it knows how to do. [@] There's an oscillator, and oscillators take as an argument... [@] So 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. [@] Now 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 times tilde, I should say, and ask it, let's only be a tenth of a hold for the blast sine wave. [@] I'm going to crack the book in a moment and show you in waveforms what we're talking about here. [@] But for right 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 this 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 blast? [@] 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 person in your computer who takes those numbers and turns them into voltages. [@] Now I'm going to say... [@] Oh, wow, it just worked. [@] Take 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? [@] There'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. [@] That'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 is off, which you can think of as mute. [@] It's not really mute, but you can think of it that way for now. [@] Now the other thing that I should have mentioned is that when you start PD, this 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. [@] As 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 running 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 name 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. [@] But 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. [@] Let's say one every 22 microseconds. [@] 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... [@] All 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 several 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 now 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. [@] 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. [@] This 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, then hit command X. [@] So if you want to try the other output, do that, or both. [@] You can have fan out if you want. [@] While 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 between those two numbers? [@] Three to two. [@] And that's what interval on the piano or musical scale? [@] Yes, a fifth. [@] Ta-da, mathematics turned 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, here's another thing you can do to demonstrate psychoacoustics effects. [@] All right, so I'm going to shut this up and talk a little bit more. [@] Is 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 so 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. [@] And 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. [@] What 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 and 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, then 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, and that doesn't select the text. [@] That just selects the objects. [@] Then you can move things. [@] Am I going too slow? [@] ... Yeah. [@] So also, you can select a single thing as a group using the group selector thing, and again, it just selects the object. [@] Next thing is 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 and 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 five 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, we'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 would 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 glob 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. [@] And it is a thing which... [@] And now I have to let out more of the truth. [@] 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, 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 for 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 sends 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? [@] What has happened? [@] Oh, because I have this turned off. [@] Now I'm going to turn it on. [@] And now it prints out. [@] Every time I whack it, it prints out a new collection of data. [@] So print tilde's job is every time you ask it to, it will print you out the next block of data. [@] So 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. [@] And 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, a 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 a 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 about 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. [@] Here'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 in 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 . [@] Where was I? [@] Don't want to do that. [@] I want to do this. ... Yeah. [@] All right, good. [@] 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, and 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. [@] But 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. [@] There 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 trenches 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 frequency 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 has 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 something 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 the computer, what range do you want to feed your DAC in? [@] And it normalizes that to one. [@] The frequency that you would do this at is manifested in how many of these samples it 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. [@] It'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 something 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 in one way or another. [@] n is the sample number, and that is the horizontal axis here. [@] I'm insulting your upper intelligence here. [@] This 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? [@] Well 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. [@] So 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 to the frequency-frequency by a simple formula. [@] The frequency you hear is the omega, is the angular frequency is what that's called. [@] Time 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, for 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. [@] So what that means is what is coming out of this equation, what's coming out of this oscillator right now. [@] Omega is two pi times 440 divided by 44,100, whatever that number is, and a 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. [@] But 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 the 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, like 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? [@] Yeah. [@] Thank you, because I actually meant to do that but didn't. [@] So I think what you're asking is, "What if I just print the output of this?" Right? [@] Student: Right. 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 to print something." ... 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 are 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. [@] Is that all clear? [@] Now without anything besides those things, what have we got? [@] We'll do those two. [@] I'm going to raise the total count of objects to five, but not in a very interesting way. [@] I just need an adder. [@] Now 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. [@] So this is stupid. [@] There's zero coming in here and we're adding 440 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. [@] The 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. [@] It 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 did sample it, too. [@] Look 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. [@] See what we get. [@] Anyone want to guess what this is going to sound like? [@] All right, I'll show you. [@] So 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 once 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. [@] One, right. [@] So 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 per 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 by five. [@] This can be ugly, but we're going to do it. [@] This will be quite audible. [@] Not quite as ugly as I want it to be. [@] So now we're varying between 435 and 445 hertz. [@] Now of course, since it's a computer, you can tell it to do anything you want. [@] It 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. [@] Or, no... [@] OK, 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. [@] And 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. [@] I think that what's going on here is it changes its speed to vibrato. [@] I need it more to make this obvious. [@] I'm sorry, this is ugly now. [@] So this is just how fast it'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 only 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, I 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 works 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. [@] So 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? [@] Right. [@] Student: And we times it by 30? [@] Right. [@] Student: So that makes the amplitude for the 440 between 410 and 470. Is that right? [@] Right, and that's changing three times a second. [@] Then that's becoming the frequency for the oscillator. [@] I 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 we're just going to take a signal and specify what our frequency's going to be. [@] 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 going to try to tell you that. [@] Student: Is there a map of all the names of the outputs that we learned? [@] If you really want to see it, you say Help. [@] Right-click on it and you can get help and help within a patch, which tells you everything you want to know about it. [@] OK, so that was help. [@] So 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 any 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, which are the ones that you get before you get Pd Extended. [@] More than one... [@] That's funny. [@] I 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 this 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 10 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. [@] Basically, 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 of 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? [@] So oh, yeah, there's a thing I didn't tell you, which is fundamental. [@] The patch can be in two different... [@] The interface of the patch can be in two different states, which are sometimes called 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 into run mode, which I do here. [@] Let's get out of edit mode. [@] Now edit mode is no longer... Whoops! It is still on. [@] Well, this is version 43. You tend to get what you pay for. [@] 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. [@] Like now. [@] Now it's just being happy. [@] You cannot get out of edit mode. [@] 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? [@] Oh, 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. [@] You 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 the 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. [@] Student: 90 percent. [@] So anyway, we'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. [@] Of 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 back 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. [@] So 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. [@] ... 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? [@] Well, not even graphical. [@] It just prints the numbers out. [@] Student: All right. And then the DAC tilde, then the time is...? [@] OK, so the dac~, that takes whatever the signal is... and puts it there. [@] So it causes 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? [@] DAC? It's digital-to-analog converter, and that used 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? [@] It only prints the next 64, until you whack it. [@] Of 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? [@] You mean as to amplitude or the number of includes or....? [@] Student: Just how many things you can enter. [@] Oh, no. [@] Student: You can have more inputs than objects? [@] 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. [@] ...into these fixed objects. [@] But 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. [@] Other 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? [@] Yeah. [@] Student: You have to keep it to the left. [@] 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. [@] Sometimes 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? [@] I've only been using the left side, mostly. [@] When I'm working at home, I use both sides... [@] 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? You just have the space to put the number? [@] Right. [@] Student: Because otherwise you just get the domino effect. [@] 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. [@] The other thing I could do wrong would be to not put a space there and so it would look for an object named "osc~3" which doesn't exist. [@] Student: Are there any defaults if you don't put a number in there? [@] Yeah, zero. [@] You 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. [@] Then 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 and 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: Why does the print object not have two inlets? Why don't you have a data inlet on the right? [@] ... Yeah, isn't that stupid? [@] Inputs 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 two 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 clutter on the screen, you'd just combine them. [@] That's the simple answer. [@] Other questions? [@] Go look at the homework assignment. [@] I don't know if my machine is going to be able to play it. [@] But it's going to be to do this. [@] Firefox... [@] I don't know if I bookmarked it. [@] And somewhere down here... [@] You get your assignment here, which is to do this. [@] Now I don't know if this is going to play correctly, so... [@] It's lame. [@] All it is, is 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. [@] Basically 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: When we turn in homework we'll be turning in all of this? [@] 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. [@] There should be a clear way to turn it on, that sort of thing. [@] But more about that next time. [@] *** MUS171 #02 01 06(Lecture 02) [@] This is the stuff that's in store for today.( [@] Indicating the Pd patch on the screen.) [@] What I want to do is several things at once. [@] I need you to just look at the practical aspects of running and surviving .pd. [@] How many of you are trying to run Pd and not succeeding? Three. [@] One of you emailed me, I forgot who, and didn't have - four - didn't have sound coming out. [@] Student: I figured that out. [@] Oh. [@] Student: It was weird. [@] It didn't show me any numbers though with the outputs. [@] But when I did the test tone after a little bit of a restart on the computer, it came up. [@] It was kind of strange. [@] Something like that's been happening to me today, it hasn't happened before, which is that I had to try twice to get it to run. [@] Student: I use the version 43 instead of 42 because that looks more familiar from the one we looked at in class. [@] I think I'm running 42 right now. [@] I'll tell you one thing that doesn't work in 43 in case you run the 43. This is something I still can't figure out how to fix. [@] Anyone else for whom it's not working, can you tell me what symptoms you're getting? [@] Student: It wouldn't allow me to put in objects. [@] It wouldn't allow you to put in objects? [@] Student: On the clip menu everything was greyed out. [@] Maybe you're looking at .pd's window here and trying to do put, and for that you need to be actually talking to a real document. [@] I didn't actually say this but this is pd's print-out window (which exists mostly when Pd is actually runnng.) [@] You can have this but it won't be doing anything until you have some number of patches open, and you can have one or more patches open and they're all running, all at the same time. [@] Furthermore, they can talk to each other, so you should be aware of that possibility. [@] Other problems? [@] Student: I can get single sign-wave to play. [@] When I try to put in another oscillator I have to get crazy. [@] I can clip and then it's just gone. [@] I think I might know what happened to you and that's something that I'm going to try and address today. [@] It could be that what they're doing was numerically outside of the range of the possible values that you can convert, and there were ways that you could do that that would cause it to make silence. [@] And that's a "gotcha" that I want to try to help you avoid today if I can succeed. [@] Other issues? [@] Student: I'm just having problems downloading Pd on my computer. [@] PC? [@] Student: Yeah. PC. [@] I've got a PC today and I'm not sure if I'll have the same problems as you, but if you see me doing something that you're not doing, that might help. [@] Otherwise, see me after class today. [@] Student: Do you know if there's a 64-bit version of Pd compiled for Ubuntu? [@] Ubuntu? The last I heard, someone had a machine and they were going to compile it on but no one knew when it was really going to work. [@] You might have to compile it yourself. [@] OK, so, next matter. [@] I have another thing to sort of just check off which is, in class didn't exist as far as WebCT was concerned on Tuesday, but that should be fixed now. [@] Is it decently clear how you would upload assignments? [@] I have one slight comment to make which is that it's possible to get confused downloading patches on the web. [@] I actually don't know if I'm on the network, so I don't know if I can show you this, but I can tell you this: [@] If you see a patch on the web such as, for instance, the patch that I saved from Tuesday which is on the website for the course. [@] You could click it and it will download you a nice patch, or you can click it and you will see this bizarre text in your browser. [@] If you click and see the text in your browser that's because Pd patches are, in fact, text files, and if your browser sees that it's text, it might just decide to show you the text instead of saving it to another file. [@] This is not a problem. [@] Just save it as a file anyway and make sure it ends in ".pd" and then tell your computer the ".pd" things are your puredata documents -- and then you're happy again. [@] Iregularly get e-mail "I tried to download this patch and I just saw gibberish on my screen." [@] OK; patches are gibberish and you just saw your patch. [@] If you're curious, by the way, you get to look and see what patches are. [@] They're just text files and they just have gibberish in them that describes how you can make a patch. [@] And, furthermore, those of you who get too excitable too late at night, if you learn what those messages are you can generate those messages from Pd and you can make patches that build themselves. [@] I'm not going to show you how to do that, though. [@] I'll have to figure that out, or, everyone on the web is doing it. [@] Just so I can shut this window down, I'm going to put this up as a sort of review for today. [@] What I want to show you now are two other objects ... Wait, I forgot something. [@] I actually gave you six objects last time because there was also the push-button. [@] This is my resume from last time and what we're doing this time is another control which is a number box. [@] It suddenly means now that you can make wonderful analog synthesis type sounds. [@] Arrays which are graphs which you can do this with. [@] These things are functional objects which I will grab and use as needed as we get through today's stuff. [@] Today's stuff is mostly going to be figuring out what went wrong with the last time. [@] So now what I'm going to do is, watch this, it's ctl-alt-backspace, that is equivalent of, "save as." [@] I am going to give myself a new file name so that I can make a new check point. [@] This will be built and I will try it, I will try to save these things before I erase major portions so that you can see, in a progression, what happened as we went through a day. [@] Now, review, let me just make the patches that last time very quickly and show you how you can see what they're doing and then go on from there. [@] So oscillator 440 Hertz please, and then I will say, oh... [@] If you have an object selected and if you hit the key accelerator for making a new object, it doesn't just make a new object but it makes a new object and connects it the previous one. [@] It doesn't matter to you now, but late at night when your make hundreds, and hundreds of objects. [@] You will get to like this feature, most people like it. [@] You're going to multiply by 0.1, a tenth, and then I am going to send this out to the digital analog converter. [@] I am going to turn the beep off, this is the cooler "hello world" hash. [@] Now, what I am going to do, is show you not just how to print stuff but how to grab it. [@] To print stuff, which is from last time is a print object, which is a print-tilde by the way, because it prints with a single input. [@] Now, I am going to talk to this 0.1 thing and then I am going to make it a push button. [@] This is the thing that I forgot to tell you first the first seventy minutes of the other class. [@] It is that you're not going to get very far just trying to click this button like this because I am in edit mode and I want to get into run mode, and then I can click it and have stuff happen. [@] Except, nothing happens because DSP is off. [@] These are the numbers correspond to one 64-sample buffer of digital sound and my apology about the horrible format. [@] Now, another thing that you might wish to be able to do is see it, as in a oscilloscope or as in a sound editor. [@] I am going to introduce that because I am going to be using it to go back and make sure everyone understands about amplitudes, frequencies and modulation again. [@] Even what the word modulation means, so to do that ... (New materials start now.) [@] There is a wonderful object, called an "array" which you can get down here. ( [@] on the menu). This is unfortunate, there is a thing (also on the menu) called "graph" which is a rectangle that you can throw arrays inside. [@] This is a array which is the thing you throw inside the rectangle, which more like the thing that you want, because "graph" will just give you a empty rectangle and idea how to stick an array inside it. ( [@] Well, there are ways; I am not going to tell you yet.) [@] So ... get an array like this. -- [@] And it immediately says "I want to know all this nonsense about the array." [@] The important nonsense is, "What is its name going to be?" [@] I am not going to tell you yet all about pd's naming -- how Pd treats names is a subject all to itself. [@] But, I am just going to use a name for now. [@] In fact "array1" sounds good to me right now. [@] And a size: this is the number of points that the array is going to have, so that number would be, for instance, at our sample rate if I want a whole second of sound I would have to ask for 44,100 points here. [@] As a general thing, Pd doesn't know much about sound. [@] It does know that a second of sound require say 44k1 points == anyway that number could change because the sample rate of the computer might change while Pd is running. [@] It doesn't make sense to ask for a array to hold a second of sound. [@] So, you have to go on and tell it numerically how much sound you want in the array. [@] In the same spirit, that you had to tell the oscillator how many cycles per second it had to vibrate in order to make you a nice A440. Well, what I call A440 is just a concert A4. [@] So here I don't want 44,100 points, I want a 1,000 points just for now. [@] This is aesthetics but I prefer points to polygons. [@] "Polygons" means it draws little segments between the points, and points means it just draws the points. [@] So I am going to choose "points" because it's me and that is my preference. [@] And I am going to say "OK." [@] And it says OK and it draws me a thing. [@] So, I am not in edit mode, so lets get in edit mode and look around. [@] It says "Hi my name is array one and my values are all zero" [@] By default these values range from -1 to 1, which the same range as audio is, which is a good thing. [@] For instance it is a good thing because I can now use that to graph what's coming out of this network and show you what it looks like as an audio signal. [@] Let me do it wrong again, in the same way as I did the other thing wrong. [@] I am going to need another push button and I am going to need an object whose name is "tabwrite~." That's an ugly name but it fits in a series with a bunch of other names so it has to be named the way it is. [@] Then I am going to say "What table," that's to say array we are going to write to. [@] Nomenclature: in computer music arrays were called tables, this has been true since 1958 and there is confusion in Pd as to whether something should be called a table to be true to its computer music roots or to be called array which is what the thing really is, which is just bunch of things all the same type. [@] The name kind of flops, back and forth, between things that say table or tabwrite~ and a things that say "array." [@] I apologize -- you never know what's going to happen if you develop something for 20 years. [@] Now, I am going to listen to this thing by connecting it here. [@] Notice again, as I mentioned last time: [@] These are skinny wires that hold or carry messages and these are fat wires which carry signals -- and those are different animals: [@] Signals are happening all the time, and messages are happening only sporadically. [@] Now I'm going to click this forgetting that I have to lock the patch. [@] So I'll lock the patch, then I'll click it, and nothing happens. [@] Why? [@] Student: DSP is off. [@] DSP is off! Go up here, turn on DSP. [@] That's why I left this thing on the screen. [@] Then, ta-da -- [@] We are looking at the network output . OK, so now DSP is off but we just wrote into the array. [@] In the same spirit as for the print~ object, this thing has an audio input but what it does is something that it does sporadically, that's to say when you want it to do it. [@] You have to send it a message ("trigger," if you like) to say "do your thing." [@] Doing your thing" amounts to commencing to record the audio signal that is coming in and continuing to record until you reach the end of the array, at which point you stop. [@] It doesn't loop around. [@] You can make it loop around, but by default it just does it once. [@] Student: What was the shortcut for DSP again? [@] What? [@] Student: What was the shortcut for turning it on? [@] Oh, the shortcut for DSP. [@] I don't even know if this is documented. [@] Ctrl-slash turns DSP on [@] and Ctrl-. turns it off. [@] "ctrl-." is fairly standard Macintosh language, and the slash is just next to the dot. [@] ... Yeah? [@] Student: How did you get the array to look like that? [@] To look like that? [@] Student: Yeah, you did it by writing the top. [@] When I turn my DSP on it didn't do that. [@] Yes, OK. [@] I did two things. [@] One is, I clicked the tab, I clicked this button. [@] I did that while I was out of edit mode. [@] Student: Oh, OK. [@] In fact if I do it again... [@] Oh, nothing happened because DSP is still off. [@] We'll turn DSP on. [@] Student: OK. [@] So I was just in edit mode. [@] With DSP on, each time I click it it'll make a new recording. [@] You know what, I should really... [@] It's all right. [@] Do it the easy way. [@] ... Yeah? [@] Student: How do you edit array1? [@] How do you edit array1 ... [@] Student: if I want to change its size. [@] Oh, I see, if you want to change the size. ... [@] I was going to forget to say this and, by the way, this is very confusing. [@] If you have more than a one button mouse, left click. [@] If you have a Macintosh that only gives you one button, I think you command-click, or option-click. [@] I forget. [@] It gives you properties or open or help and do properties. [@] Open means, "hi, I'm a sub-patch and I only contain this." [@] That's good for other things. [@] Properties is going to do this: [@] It's going to give you (watch out) two windows because there really are two things here. [@] There's the array, which is the squiggly line, and then there's the graph, which is the rectangle it's in. [@] So when I asked it to make an array, it made me an array and a graph and put the array in the graph. [@] By the way, there's no intellectual content in any of this. [@] This is just Pd lore. [@] So this is the array. [@] This has to do with the points in there. [@] Since there are thousands of them that I can ask it, oh, let's have 2,000 of them. [@] Then I'll say "apply" here. [@] It's going to be a little embarrassing because you can only have 1,000 good points and then the other 1,000 are now zeroed. [@] It did have the decency to change the bounds of the graph so that the array still fits in it, but that's about all it did for us. [@] Now I'll do back to 1,000, like that. [@] "OK" means "apply then disappear." [@] Then the other thing is--what's that graph thing doing? [@] Just left, so let's start over. [@] Oh, and I'm drawing a polygon ... [@] 41] OK, now let's get the properties back so we can see not just the arrays but the Canvas properties. [@] Now, here we can say the X... [@] OK, X and Y really mean the horizontal and vertical axis. [@] X is going to range from zero to 1,000. That means this point here is point zero and this point here is actually 999 because there are 1,000 points. [@] If I change that -- you don't need to remember this-- you get the following embarrassing result-- Your graph wants 2,000 points but the array only has 1,000 so it looks stupid. [@] I could also say, oh, the range is only 700, say. [@] Then we get... [@] It doesn't do it. [@] Oh, yes, because I'm running .43 and there's a bug, so we say "no." [@] If the array doesn't fit in the graph... [@] In .43 it doesn't draw it. [@] That's bad, and it's going to take me hours to fix it because there's something subtle wrong there. [@] If your thing isn't drawing, it's because it doesn't fit in the graph. [@] My apologies. [@] Go back to 42 if you really need to see it. [@] Somehow I didn't realize that was running .43. [@] OK, we're going to cancel this. [@] Oh, except I'm going to do this: [@] The Y range goes from 1 to -1. Isn't that ugly? [@] That's because computers think numbers go up that way, whereas mathematicians think numbers go up that way, or graphs think numbers go up that way. [@] You have to say, yeah, I could say it goes from minus one to one but everything would be upside down and it would be confusing. [@] For right now I'm going to say we'll go from 2 to -2 so that you can see the thing drops in size because now this is 2 and that's -2. There are ways of getting the thing to show you what its bounds are but, let's leave it that way. [@] I'm going to just leave it like this. [@] Just to belabor a point, let me disconnect this so I can have DSP running and not listen to it. [@] I just ask it to graph the output of the oscillator and not the output of the multiplier so you can see what a full blast oscillator looks like. [@] Now recall, I have the graph -- that's the rectangle -- going from 2 to -2 . The signal, the oscillator signal, ranges in value from -1 to 1, which is full blast as far as the computer is concerned. [@] You can make signals that are more than full blast. [@] These numbers are all floating points, so you can have numbers that go up to 10^37 or something like that. [@] Your speakers can't play those. [@] And it's a good thing, because you would vaporize the planet if you could. [@] But as long as what goes out is between minus one and plus one, then your computer will, I hope, faithfully turn that into voltages that your earphones or your stereo can deal with. [@] Just for, hadn't got these things... [@] OK, this is the moment I think perhaps, to save this patch and continue. [@] Played it, and I'm going to save "3.signalrange. [@] pd" as the range, the signal range. [@] I'm going to now show you what happens when you... [@] Oh, I'm going to turn the volume down in the room before I do this. [@] And I'm just going to play the oscillator full blast into the speaker, or in the mixer. [@] But the mixer's volume is going to be down, so we won't lose our eardrums. [@] And then, I'll show you what happens when you add another one, which will cause things to malfunction in a novel way, which actually, you might have already heard a couple times. [@] So, let's see. [@] I don't want this anymore. [@] Don't want this anymore. [@] And I'm going to turn the volume down. [@] OK, then I'm going to connect this to this. [@] Actually, what I should do is turn them off. [@] It's too much for the mixer. [@] You can hear already, there's not a clean sinusoid. [@] But let's, we'll pretend it's a clean sinusoid because I'm about to make it even worse. [@] I'm going to say, "OK, that's good." [@] And I also want to go and get 550, which is a perfect third above 440. First off, I'll get... [@] OK, hear that? [@] Now, ready, set... [@] What happened? [@] Student: Clipping. [@] Clipped. [@] ... Yeah, yeah, OK. [@] There's some, those of you with digital audio experience know what's going on here. [@] But I'll graph it for you to show you what's really happening at the level of the signal, and to do that I have to introduce the final object for the day, which is clip~. And this is a, one of those minority objects which, it just, sometimes you just need it. [@] But those times are maybe only once a week or so. [@] So here it is, click. [@] This is the, clipping is, it's a term that... [@] I don't know how old it is, but it certainly dates back to the old analog electronic days. [@] It simply means what happens when signal goes out of the range of the audio device that is receiving it. [@] So if the standard thing about clipping is you can hook an electric guitar up to an amplifier and overdrive the tubes. [@] And if you overdrive the tube, well there is a maximum or minimum current the tube can put through. [@] And beyond that, it just says, [@] "Well, I'm clipped. I can't go any further, so I'm just going to stop right where I am." [@] So it's like in this building, if you ask for floor minus one or floor four on the elevator, you won't get it. [@] You only get floors one through three, because that's where the elevator goes. [@] It's the same deal. [@] So for instance, I'm going to clip between minus one and one, which is an exact imitation of what actually happens when the audio goes out of your computer, because the range of possibilities is minus one to one, and if it's out of the range, it is simply clipped to the range. [@] And if I knew that, and if I for instance, add these two oscillators together... [@] Before I do that, I'm going to do this. [@] Push that one, here we go. [@] So here's the first thing. [@] Oh, right. [@] We're only listening to one of them, so let me play you both of them and show you both of... [@] So what's really happening is the periods of the two oscillators that we have are short. [@] If each of them is fitting 20 or 25 cycles, then the thing... [@] What you can see is that the thing itself is repeating at its much lower rate, which is in fact the, what is it now? [@] It's the greatest common factor of those two frequencies, if you like, or the least common multiple of those two periods. [@] Or, now, finally, I'll show you what the computer... Let me show you. [@] Or to show you what the computer really is playing, let's look at it this way. [@] Rather than add it right into the tab where I will add the clipper and the tabwrite~, and then do that. Aha! [@] Now, the signal that you saw before ... [@] Even though the signal that you saw before was clearly periodic with this period, you didn't hear that period because in fact, in its internal structure, it really only had two components, each of which had a much shorter period, and your ear resolved those. [@] It didn't hear, it didn't make a difference to... [@] It just heard the individual harmonics; it couldn't fuse them, right? [@] 25] At least my ear couldn't. [@] But if you clip it, you'd make that be no longer true. [@] There's simply no possible way you can hear the signals having any period other than the period in this that it's got. [@] ... Yeah? [@] Student: How do you get the little toggle-light? [@] This? Oh, this is not a toggle. [@] This is the button which is called "bang." [@] Oh, and if you go to toggle, you'll get another rectangular thing, but it's a toggle switch which goes on and off when you press it. [@] That's related. [@] So this is clipping, and this is what your audio hardware does to you. [@] Now, let me show you how you can make your life even worse. [@] I think this happened to one of you, but I'm not sure. [@] I'm just operating on a guess now. [@] So I'm going to say if you've got an oscillator like this... [@] And now, I'm going to listen to my nice A440. [@] And then I'm going to add another oscillator here. ... [@] Oh, that's not what I wanted. [@] Oh, yeah. I miscalculated. [@] Add another one: Oops! What happened here ... is this: [@] Let's see ... OK, so let me put in the, let me get that something into, yeah now we are clipping. [@] Actually I can save some steps by just listening to the clip at the output. [@] Now we get this, and this a problem because it is the sum of a sinusoid and another sinusoid that has zero frequency and zero phase, which means output is one volt... [@] And the result is.... [@] that half of the cycle is below 1 still - the half that was from zero to minus one is now going from 1 to 0, and the half that was going from 1 to 0 is now going from 2 to 1, and it's getting clipped. [@] In fact, when you learn how to control this, you can have a lot of fun because you can do this controllably and you can change the timbre of sounds by selectively clipping more or less of it, and this, for you electric guitarists, is the bias knob on your Ampeg amplifier thing [laughter] . Fender doesn't give you the bias knob, but the other manufacturers do. [@] Now I'm going to add another one. [@] And what do you know? [@] The patient died, [@] and the reason - worse - the reason why the patient dies is because now, the entire sinusoid here is above positive one, and so it got clipped to plus one, and so the result is a signal that you can't hear, you an only smell it, because it will melt your speaker. [@] Speakers, theoretically will go down to zero Ohm's of DC and your stereo probably wouldn't do this to your speaker, but if it could, then you would have to call the fire department or something. [@] So this is [tone] this is how to make your life hard by making signals that are out of range, and, oops, that's interesting. [@] And so, the first thing you hear is funny distortion, but you don't know whether the funny distortion is your patch, or whether it's just because your earphones are bad or something like that, and then when the signal goes away all together, then you still don't know which it is, but it's very possibly that it might be this. [@] It might be a good idea to equip yourself with one of these things at the same stage as you are making your output. [@] So, for instance, one thing that might be a really good idea would be: [@] Whatever we do, we'll just put a nice adder at the bottom. [@] It doesn't matter whether you're adding more than one thing or not. [@] This adder really is just here to remind me that whatever's going out the DAC, it's going to go out the tabwrite~ -- it's going to be graphable as well. [@] So now if I for instance do this, then I can both see it and hear it. [@] Now, when you're turning in homework. ... [@] Oh, good. [@] Student: What's the adder for? [@] Because I didn't see anything. [@] What did it do? [@] Oh, what's the adder for? [@] The adder is there because when I change, when I add or take out stuff, I'm going to hook it into the adder instead of hooking it into the DAC and into the tabwrite~. And then that way I'm not going to forget to add something into the DAC that I didn't add into the tabwrite~. So really I'm adding zero. [@] Student: OK. [@] I'm going to explain more about adders in a second, but all I'm doing really is adding zero onto the signal, so I'm just wasting operations really. [@] The reason I'm doing that at all is so that I can do stuff like this. [@] In fact it doesn't even matter which - you wouldn't need an adder in Pd at all because signals automatically add anyway. -- [@] Well OK, that's not quite true as I will tell you next. [@] Any questions about that? ... Yeah? [@] Student: Wait, so, is the adder unnecessary? Like can you just... [@] The adder's unnecessary. [@] It's only there so if I make a connection to it it makes the connection both to the dac~ and to the tabwrite~ too. [@] And I could do that in a spiffier way, but I'd have to use another object. [@] So what I'm going to do is I'm going to put this patch in a nice state so you might be able to remember what I was doing... [@] This patch is going to get saved, and then I'm going to make a new thing <>. Sorry - that's for later. [@] Take an oscillator and control it with a number box like this, and then you've got a patch that operates like this.[tone] [@] You know what... [@] is that loud enough for people to hear? [@] Or should I turn it up? [@] So what's happening now is instead of having 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. [@] 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. [@] 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 -- 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. [@] 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 from -- OK, right, so let me do this while we're here. [@] This is a message. [@] This is a number box. [@] 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 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: [@] 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, 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 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... ( [@] I'll leave this for now. [@] Let's go here.) [@] So, things that have frequencies that correspond to pitches that we all know. [@] 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. [@] 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, I don't want to, I want this to be zero so we're not changing anymore, just combine... [tones] [@] Now I've got... OK? [laughter] [@] Now that would 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 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. ... Yeah? [@] Student: Can you go over one more time the difference between putting the number after the oscillator, after the osc~, vs putting it above? [@] OK, good. [@] And in fact, I was inadvertently a little confusing here, because I 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? [@] And those are overriding it, yeah. [@] So this is an initializer. [@] And it's a better style. [@] In fact, 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 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. [@] 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 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. [@] 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. [@] Actually, let me save this. [@] Let me save this and give it a name, which will be... [@] This is patch number two, and that's going to be, "2.oscillator" [@] 18] But now I'm going to save as patch three. [@] And now we're going to start talking about phase. [@] <> [@] 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. [@] 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 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. [@] And I'm going to test it, so... [tones] ... Yeah, there it is. [@] OK, more beautiful music. [@] 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. [@] 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 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. [@] 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. [@] 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 up and down. [@] 27]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 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 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 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 'duplicate', which will in effect copy any amount of patch that you want. [@] So I'm going to now go back ... and make an oscillator with a number controlling its 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, 440 here. [@] Play. [tone] ... Yeah? [@] Student: How do you copy the objects once you've selected them? [@] Command-d, or it's up in edit there. [@] Oh, control-d for me, but command-d for you ... [@] 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 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] [@] Now, I'm going to go 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. [@] Come on. [@] Now I've got a nice little attack-maker. [@] 04] . Well, it makes an attack if I hit it at the right moment. [@] But if I hit it at the wrong moment, 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 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 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 worth of stuff in it. [@] And so 44,100 -- that's a second's worth of sound. [@] Oh yeah, let's change the name. [@] Actually, I'm just going to... [@] do that. -- [@] New name "seeme2". [@] All right, let's record it. [tone] [@] Student: You want "tabwrite~ seeme2" not "seeme" , no? [@] 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. [@] 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 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 a second. [@] So I'm going to move them really close to each other. [@] There. Look at that. [@] This is what happens when you have a nice sinusoid going and you say, "Now make the phase be 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 -- or one source of clicks.... Yeah? [@] Student: Could you put the bang into the message-box? [@] Sure enough. ... 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] [@] 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 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 ... 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 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 start graphing and then, 400 milliseconds later, it is going to set the phase of the oscillator to zero. [@] 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 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 the same. [@] That's to say every time I whack the button I will have a nice consistent result starting 400 milliseconds in. [@] So you cannot put your guitar into this delay. [@] 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? [@] Yes. Thank you. [@] So delay: what it does is when you send it a trigger, it sends you the trigger, the amount of delay later. [@] 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. ... [@] And now if I graph that... [tones] [@] One, two. [@] Why was that stupid? [@] 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. [@] 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, 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. <> We'll make a smart sequencer later. [@] The dumb sequencer is going to look like this. [@] Get rid of this, don't need that. [@] 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 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. [@] And then another 150 milliseconds later, and then another 150 milliseconds later, and then let's just go back down. [@] 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 we'll play it. [arpeggio A minor chord] [@] All right, now we've got Beethoven. [laughter] [@] Not really ... [@] And of course, the punch line. [@] Let's just take this one and connect it over here. [@] Now we've got... [A minor chord arpeggio starts looping] [@] Whoops, I did something wrong. [@] Oh yeah, I know what I did wrong. [@] I need another delay before I loop it, don't I? [@] So another 150 milliseconds later, I'll go back around. [Arpeggio loops with all notes evenly spaced] [laughter] [@] Do this at home and not here, all right? [laughter] [@] In fact, I will try not to play that anymore now. [@] Oh, there are little things that maybe you could want to be able to stop this. [@] 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: [@] 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 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). [@] 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 computations are happening at a specific instance 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. [@] 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. [@] I can do this. [@] I need a start button, but then I could always just have buttons that show me what's happening. [@] ... Yeah, this is going to be painful. [@] Let's not do the whole thing, but I'll just do these two. [@] All right, OK. [@] 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 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. [@] 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. [@] 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. [@] It's hard to see because of the messy crossing lines. [@] But one thing is it's causing this bang push-button to flash. [@] 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 ,,, 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? [@] 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 worth of the audio signal. [@] Am I going too slow? [@] No, all right, OK, good. [@] So to go back, if you like, the 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. [@] 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. [@] 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 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 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 end of that arm of that graph for 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 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. [@] Just to select everything that is in the tree, hanging from that delay object. [@] Make that be a tree and not have 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, 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, 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 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. [@] 08] . Sometimes it's better than other times depending on the OS and in particular the things you're dong. [@] 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 number box, the one on the left, if you like, tells the other one be 96, 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. [@] 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... [@] 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, 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. [@] 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 in a different way. [@] So when I do this... [@] let's take a nice signal and multiply it by five. [@] There are a lot of reasons you should not try to do something like this. [@] 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.] [@] It says "DSP loop detected. [@] Some tilde ..." -- 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 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 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 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 efficiently. [@] What it really does is it -- it doesn't exactly pre-compile it, 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. [@] 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, 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, 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. [@] That's a useful tool. [@] So that's a loop, and this is a loop -- they both are. [@] 12] . 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. [@] 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. [@] 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? [@] 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. [@] I'm not going to do it because I've already had enough of that. [@] Students: Aw. [laughter] [@] If you want to hear more of that you have to make it yourself. [@] But then use headphones. [laughter] [@] All right, questions about this? [@] 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? [@] 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. ( [@] Let's see, let me save this, and did I...? [@] ... Yeah, OK, I can go back to this example (3.phase. [@] pd). So I'm going to go back a little bit. [@] Oh, let's save this "0.objects.pd" . OK. [@] 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 so that -- ooh, interesting. [@] Oh, right. [tone] [@] Let's see. This we need to be a "1", I think. [@] ... Yeah, there it is. [@] 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 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. [@] 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 I could have set the phase to minus one-quarter of this. [@] This is exactly the same thing. [tone] [@] 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, 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 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 other phase to -.24 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: Can you make an example of two oscillators out of phase? [@] 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 ... 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 to peak up while the other peaks down, then set them a half cycle apart. [@] And this you'll want to do using message boxes. [@] Message boxes are the right tool for doing this, because 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: On the homework are we graded on whether it's solved simply or not? [@] 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. [@] 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, 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] [@] ...depending 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. [@] Sounds distorted? [@] Oh, so you're probably not doing it right, yet.[laughter] [@] 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 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 blast into the back, its 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? [@] 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. [@] 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 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. [@] Other questions? [@] Student: How is it possible to find out it's phase of a signal? [@] How would you offset. [@] Oh, oh right. [@] So, how do you find out the offset ... 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 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~ 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? [@] WebCT believes that it's due at 3:3 [@] 0. 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 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? [@] 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 while I'm talking. [laughter] [@] I don't think he will. [@] So, it seems like you've probably got until five. [@] T/A: It's safe to plan on 5PM. [@] Right. [laughter] [@] But come to office hours after class and I can help you. [@] Maybe you can be done before 3:3 [@] 0. 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 we can set things. [@] Other questions? [@] I want to quickly show you another object just because... [@] 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. [@] And this is an object which takes two numbers in -- Let me get a number box. [@] 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 this stuff in the patch, so right now I'll just leave it. [@] This (metro) is an object which when you turn it on, does this [bang-light on metro output blinks]. 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 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 which means every 500 milliseconds which is twice a second.... Yeah? [@] Student: What is the "400" in the box where you have "metro 400?" [@] This initializes the amount that you are -- oh right, I should probably 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 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 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 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. [@] 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, its a metro of 500. [@] Student: Why doesn't the number 400 change, but the number in a number-box does change? [@] OK, yeah. [@] So this thing here (number in a number-box) -- This is a control ... What's the word? [@] 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 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. [@] 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 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, 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 and object boxes. [@] OK, now to slightly further confuse the situation: [@] 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 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 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, 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, 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 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? [@] Yes, I did that just to show you what was happening. [@] ... Yeah, 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. [@] All right, well. ... Yeah?? [@] Student: Can you connect the metro to an oscillator? ... [@] 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] [@] 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. [@] Now just to be bad about it ... [tone changes] [@] Now I can make a motorboat sound. [@] What I'm doing is I'm changing the phase of the oscillator. [@] Offsetting the phase of the oscillator which is causing a discontinuity in the sound. [@] Let's see, let's shut this thing up. ... Yeah?? [@] Student: On my computer my number boxes always just go up by integers? [@] 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. [@] And if you don't then your scrolling in ones. ... Any questions? [@] So now, what would happen if you took this metronome and well whatever it is, every 100 milliseconds now I'm just going to set the oscillator to three Hertz. [tone] [@] Well the oscillator 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. [tone changes] [@] You can have two of them and make them fight. [@] So let's make this one go at some nice other speed like 161.8, and you all know that number, right? [@] And now we'll hook that up, too... [@] "No, E!" "No, A!" "No, E!" right? [@] That's Compositional Algorithms 101. ... You can think about why that did what it did.[laughter] [@] 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. [@] 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. [@] Now, 10 times a second we're bashing 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 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] [@] This is now 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 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. [@] 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. [@] Is that clear? [@] So this shows, in some way, the essential difference between 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 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 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 tree of messages that descends from this metronome setting. [@] Is that clear? [@] And a good part of computer music is thinking of 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 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 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 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 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 repertoire of stuff you can put together and make a meaningful access. [@] 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. [@] And furthermore, it's a little bit artificial to separate them at all. [@] All right, so review of what happened today. [@] A lot happened today. [@] 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, 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 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. [@] 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. [@] 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 what you want to do is this -- let's see, let's turn these things off because otherwise it's going to be nuts. [@] Now I have a nice frequency. [@] Now what I am going to do 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: a value, and a time to obtain the value at. [@] So here's on and here's off in a second. [@] Now I have the following wonderful thing: (turn DSP on) [@] There's my 220 Hertz ... and there's my 220 Hertz shutting off. [@] There are 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. [@] They are actually quite free form although 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, [@] and this is the amount of time we're going to attain it in." [@] So that this is a faster one: [tone] ... as opposed to this. [tone] [@] So this is the way we make sounds that turn on 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? [@] Oh, it's 1000 milliseconds and that's the amount of time that it took to rise. [@] And what I intended to do and 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 ... Sorry, this is going to be over in just a second. [@] And we're going to graph the line~ : [tone] Ta-da! There's what a line does. [@] 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. [@] So now what's happening is the line is sitting at zero. [@] So I asked it now to go up to one and 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 its target value of one. [@] And furthermore, I can now tell it to turn off. [tone fades out] [@] And then it waits 400 milliseconds and then goes out. [@] This is your way of getting stuff to start and stop. [@] It's kind of one of those peaceful things that musicians need to be able to do with their sounds. [@] And more about this next time, maybe. [@] It's time to stop for now. [@] *** MUS171 #04 01 13 (Lecture 04) [@] The new objects for today are going to be... [@] my memory's long here... [@] we're going to find out. [@] Six of them since you only got four last time. [@] What I want to do is I have two things in the program today which are not absolutely to develop new theory but to continue showing you manipulative level things that we might want to do. [@] What they are are, first off, oscillators are the same thing as, let's see, what's an oscillator look like here. [@] Do not be confused by the fact that OSC and COS are anagrams. [@] osc~ is oscillator and cos~ is a thing which just takes the cosine of what we're looking at. [@] Actually, if you give the input in cycles -- so it's the cosine of two pi times the thing. [@] And phasor is the other thing that you need if you want to make an oscillator and someone gives you the cosine function. [@] I'll try to explain that in comprehensible terms later and when you see that then you'll actually understand what an oscillator is and does. [@] Then, various conversion things: [@] frequency back and forth to midi and RMS back and forth to decibels. [@] These are the things that you really use at least at the first cut in order to be able to control pitches and amplitudes in human readable ways. [@] So up until today I've been giving you amplitudes that look like 0.1 and stuff like that which is a perfectly reasonable way to operate, but most people would prefer to use some kind of reasonable amplitude units. [@] So stage two in learning how to do that is knowing the usual psychoacoustics or acoustics measure of amplitudes and frequencies which are going to be... [@] or frequencies, maybe, which is not really a unit but which seems to be the easiest way to describe what that is and decibels which you learned about in physics. [@] Alright, so that's units... [@] So, with that in mind, I'm acutely aware that I used about five minutes of the very end of the last class to suddenly introduce the line~ object. [@] So I want to go back over that review-ishly and try to make sure everyone uses it and wants to use it. [@] There will be more about how to use this thing effectively, that's to say programmaticly, that I won't be able to tell you today because I won't have all the GUI objects to be able to do that. [@] But I can at least keep at it at the sort of level of preplanned, here are the breakpoints, and here's what I want to do on this level. [@] Alright? [@] So the usual patch that we've been operating on, or make it the usual kind of patch, is - make a frequency, - multiply it by something to control the amplitude (which until now has been an oscillator because we didn't have line~). But now that we have line~, pretty much for the rest of time were going to be using this (line~) or objects derived from it for controlling amplitudes instead of oscillators which are not usually amplitude controllers really. [@] Alright so line~ does something which at the end of last class I was hurriedly trying to show that I will just develop that again - probably somewhat differently in order to emphasize it. [@] So what we have here is a nice table with 44,100 elements in it, so that it holds a second of a sound sample at the rate that we operate at. [@] And that way we can do things like -- First off let's look at the oscillator and we'll see what 440 Hertz looks like if you graph a second of it. [@] Wait a second before you see it and then you see if I were honest I would tell you that there aren't actually 440 cycles being graphed here. [@] What's really happening is there aren't 440 pixels in that part of the screen so it's graphing some incorrectly unsampled version of that waveform. [@] But nonetheless you just get a sense that it just fills this table that is the rampage between -1 and +1. Which is indeed what the output of an oscillator looks like. [@] If you want to see it well you have to give this thing some much lower value. [@] And then you'll see a reasonable number of cycles but on the other hand when I play it to you wont hear anything. [@] Because 10 Hertz is below the audible frequency range. [@] Alright, so we go back to this. [@] And now what I want to do is graph what line~ does. [@] So lets turn it on and lets graph it. [@] Well that was kind of stupid. [@] The graph actually falls right on top of the rectangle that holds it. [@] So if you want to actually see it maybe I should look do this -- I don't know how to do this in any good pedagogical way. [@] I could make the table go from -2 to 2 which I've done a couple of times. [@] There now your looking at it. ... Yes? [@] Student: What's the "300" in the message boxes going to line~? [@] OK, yes I've got to get to that. [@] So the 300 is the amount of time in milliseconds that it takes to obtain the value that I gave it as a target. [@] So here the target is zero and the time is 300. [@] Student: Because it takes 300 milliseconds to from 1 to 0? [@] That's right or from wherever it was to zero because if it is at zero, I asked it to do that which means it has to go from zero to zero which means it just flattens. [@] Or -- to make it painfully obvious -- we'll put a delay on the message, like this. [@] I didn't do that right; I didn't tell it how much to delay, did I? [@] So we'll delay another 400 milliseconds. [@] I'm going to turn it off and then, there it is: [tone]. Alright, so this is what line~ does. [@] It starts where ever it was and when you send it a message -- so the message arrives, "0.95 300" arrives, at this point in time. [@] Because I started graphing 400 milliseconds earlier than I sent that message, and line~'s way of responding to that message is to ramp up to its target value, which is almost a one, and do that in the next 300 milliseconds. [@] It doesn't look like it, but this should be 4/10ths of it, and this should be 3/10ths of it. [@] Something bothers me here ... it doesn't really look that way to me right now. [@] But maybe it is. ... I'm looking at it from real close, too. [@] Who knows. [@] Alright! Or conversely, sorry to insult your intelligence, but, he'll do the same thing to get back down. [@] Oh, but with a different button. [@] But now, of course, if I do .this ... -- nothing happens because I stopped DSP! ... (Oh, this is going to be very confusing. [@] The delay sent the message anyway, and then this thing happened, and it all happened while DSP wasn't running. [@] It effect the same moments, but that wasn't what I wanted to show you.) [@] I wanted to show you this: [@] Going up in here; here's what it looks like to go down -- and here's what it looks like if to go up and down. [@] And pretty soon you will be building synthesizers. [@] Oops, what did I just do? [@] I wanted to make this a smaller delay. ... [@] Let's do this for real. [@] What we're going to do is turn it on after 100 milliseconds and then turn it off after another 400. Wow, there it is. [@] Alright, now someone who doesn't understand this, ask a question. [@] Or do you just need to stare at it? [@] That's a possibility too. [@] Or is this just clear? [@] Probably not. [@] What's not clear about it, first off is that you can't actually see from a patch what objects are doing the good thing right now and what aren't. [@] That's a problem that no one will ever be able to solve. [@] But what's happened was, you could pretend these things aren't here because they are not happening right now. [@] Let's actually cut this. [@] Actually, let's just throw the whole thing out; we don't need it. [@] So now what we have is... [@] I'm going to save this. [@] This is a good moment. [@] So what happened is I hit the button, 100 milliseconds later a message comes out of this delay, a bang message comes out of this delay and does this, which means over the next 300 milliseconds we're going up. [@] Then, how long does it stay at 0.95? [@] Student: 100. [@] The remaining 100 milliseconds between this 300 and this 400 because, another 400 milliseconds later, this message clicks. ... Yes? [@] Student: Bang? [@] Yes. Well ...Delay sends a bang, which causes this message box to send a message "0 300" to the same line~, therefore it goes down. [@] And the whole thing fits within a second, so we got to see it all. ... Yeah? [@] Student: It doesn't make sense. Could you just go over exactly line~ again, what the function of it does? [laughter] [@] ... Yeah. So... [@] Student: Could it replace something you've done before? [@] Oh. There were examples earlier where we did things like this. [@] Let me break this for a second. And do this: osc~ oscillator a couple of Hertz. Multiply by that. [@] And that's an amplitude control. [@] This is another amplitude control. [@] But it is an amplitude control that let's you tell it whatever you want to do really, as opposed to just sitting there and just doing something by itself (as osc~ does). So, answer number one is osc~ could be used as an audio generator or as a level control by using it to multiply by another oscillator or something else. [@] And line~ also could be used as a straight signal and you would hear a thump. [@] Or you can use it as a level control by multiplying it by something that you want to hear. [@] line~ makes this kind of waveform. [@] In contrast to osc~, which makes this kind of waveform. [@] Now I need another button to press just for graphing. [@] So there is what the oscillator does. [@] So oscillators make sinusoids. [@] And line~ makes line segments. [@] Student: You said something about you can take the line~ and a signal and make it sound like an oscillator? ... Yeah, Maybe I shouldn't have said that. [@] If you want a kick drum sound? [@] Make one of these. [tone] [@] Sorry. Make one of what I just did -- not one of what you just heard. [@] I shouldn't be telling you this. [@] This is not good computer music here. [@] But you can listen to the line~ object, right? [@] And if I do this people won't hear a thing and they can just see the speaker come move a little bit. [@] Maybe, not even. [@] But if you do this real fast -- like, if I replace these numbers with tiny numbers, like this. [@] Let's replace this by 4 and make all these numbers, you know about 2. Then I've got a nice sound that puts out. [@] That's this. Oh. There it is. [@] That's the sound of a pulse. [@] You can't really see it in detail, but that's a ramp that's going up in two milliseconds, then it's staying at the top for two milliseconds, then it's coming back down. [@] Six milliseconds wide, which means that the bandwidth of it is .. well never mind, it's audible. [@] It happens fast enough that you can hear. [@] Student: Then that number is the amplitude? [@] The first number, yeah. [@] 0.95 is the height here. [@] Amplitude is one of these terms that can mean anything ... But amplitude here is just how big it is in some sense. [@] So yes it's the amplitude. [@] Student: Could you make that .95 be -.95? [@] Like this. ... Anyone want to predict what that will sound like? ... Yeah? [@] Student: Won't it sound the same? [@] ... Yeah. Looks different, but sounds the same. [@] By the way, there's no reason that your ears couldn't have been designed in such a way that that would sound different. [@] That's a way that you can encode secret information in a signal that no one can hear. [@] You've got the sign as a completely inaudible -- but very present -- parameter. [@] So there's that. [@] Let's get back to reality here. [@] Anyway, let me go back to real reality, which is I'm going to go back to using this as an envelope in some kind of a reasonable way. [@] Now you didn't hear this because I just played the output of the line~, not the thing that is having its amplitude controlled by that. [@] But you can imagine that if you took a sinusoid and multiplied it by a signal that started at 0 and gradually went up to 1-ish and then went back down to 0 that you would hear the sinusoid turn on and off. [@] That's what you heard before, which is this sound. [@] Furthermore, it might be helpful to graph that. [@] Student: Can you tell us how you have the parameters of that "x1-13" array set? [@] Oh. The array is going from minus one to one and it's 44,100 points, which means one second. [@] I have it graphing points and not lines, I think. [@] Oh wait, it doesn't look like I'm doing that right so maybe that's not true. [@] One little thing about that, there's another good thing in the properties of an array which is that there's someplace where you select whether you want to save its contents. [@] OK, here it is: [@] "Save contents." [@] If you un-check that then it will not pollute your patch with 44,100 values of whatever is sitting in your array. [@] And then when you load the patch, it'll be zeros and your patch will be many many lines smaller, which might be a good thing as soon as you start putting large values in arrays. [@] Student: Do you know of problems or quirks with dragging the properties window on a Macintosh? [@] On a Macintosh? [@] ... Yeah, you have the test version from December, maybe you still can. [@] This sounds eerily familiar but I thought this problem had gone away. [@] I've seen this, I saw this last year so I should go back to worrying about that. [@] I suspect that there might be weirdnesses for OS 10.4 if you have an old Mac but now? [@] -- because I heard some reports about that. [@] So I don't know, maybe I should look at it later. [@] I know what it would look like because I think I've seen it but it's odd that it's still happening. [@] So, yes, everyone else: [@] On a Mac, when you do this and get the properties do you have a way of moving the properties out of the way? [@] Because... [@] no, that's not good. [@] I've had it on Macintosh's sometimes happen that you get the two, these two dialogues show up and the array properties are right behind the canvas properties and, furthermore, you don't get the area that allows you to drag the windows so that you can't move it. [@] Student: On my Mac, you can. [@] You can... [@] You can't ... OK, so it's 50/50 whether you can move it or not. [laughs] OK, I better go looking at this. [@] What you are looking at now is not the output of a line~ but the result of multiplying it by the oscillator . You've seen what the oscillator's output looks like, it's got a constant amplitude of one and it's batting up and down rapidly. [@] Now what we have is nothing because no matter what's coming out of here you're multiplying it by zero, you're getting zero. [@] And that's nothing for the first 100 milliseconds until the thing ramps up and then there's a period of 100 milliseconds, (it's not too clear) where the thing is flat, and then there's a period of three hundred milliseconds where it goes back down. [@] And this is what the output of a well-formed computer-music-style instrument should look like. [@] It should turn on in a gentle way. [@] At least it shouldn't turn on by just turning on, and then it should turn off by just turning off here. [@] So bad computer music style might be to - be to do something like this. [@] Actually I'll just simulate it. [@] Suppose I either didn't put the line in or just put the thing right in the multiplier like this - yeah, here. [@] I'm just trying to figure out how not to be confusing -- Maybe the least confusing thing is I'll put times of zero here (for the line~ objects.) [@] Now we have a computer music instrument that makes a pop when it turns on and off. [@] Differently, to boot. [@] What you see is every time that I whack it I get something somewhat different. [@] It jumps from zero to some value. [@] Whose value depends on what phase the oscillator happened to be at, at the moment I clicked the button. [@] Or actually, at the moment the computer decided I had clicked the button. [@] And so at that particular time we didn't get a huge click because the value was relatively close to zero right when I whacked it, but if I whack it again - That one really was smooth on but it was not smooth off. [@] You just get what you get. [@] There it was bad - it jumped almost to full blast right at the outset. [@] This is a good way to make annoying sounds. [@] As a rule of thumb, this is either a function of psychoacoustics or personal preference, depending on your philosophy. [@] If you give this thing at least five milliseconds to go up and down, you will get something that most people don't perceive as having a click at the beginning and the end. [@] And that, in my opinion, is about as fast an attack as you should have on something if you don't want to have a snapping sound, or a click. [@] Unfortunately, that number is not a constant of nature. [@] That number depends on the frequency of the oscillator. [@] For low frequency tones, like 50 Hertz-ish, you will still hear an ugly popping sound even at this speed, and you'll have to make this number larger. [@] So then it's a question: [@] how do people who play bass, play their instruments? [@] It doesn't take 20 milliseconds for a bass to start sounding. [@] And so there is this ramp of 20 milliseconds and yet the bass, when you pluck a string, doesn't click. [@] There is a reason for that but I'll try to explain that later on. [@] It is possible to make things that go on quickly without clicking even if they have bass frequencies. [@] But you will have to be smarter than what I've taught you to be so far in order to pull that one off. [@] In particular you should make it so that the phase of the oscillator is something appropriate for quickly starting up, when it starts. [@] So we have a sort of barely acceptable computer music instrument here. [@] And while were doing computer music lets make this delay be just the rise time which is five and lets make this delay the half second. [@] Now we have the standard computer music bell. [@] This is incorrect by the way. [@] There is no bell that decays linearly. [@] What would be the correct decay shape for a bell? [@] Logarithmic? [@] Well yeah, logarithmic that's one way to say it. [@] It should be a falling exponential. [@] Which is to say, if you took the logarithm of it you should see a straight line going down. [@] It's an amazing fact that a mass-and-spring system. [@] Like the ones you studied in Music 170 as they decay they lose a fixed number of decibels per second. [@] So if you believe in decibels as a psychoacoustic measure, the rate of drop off is actually constant whn you listen to it. [@] Which is why bells work as musical instruments in some sense. [@] This doesn't work it sort of hangs in the air and then ends in this sort of -- I don't know what. [@] That doesn't sound right. [@] It sounds like it was ringing for a while and then someone damped it. [@] As opposed to someone let it ring. [@] And if I graphed the logarithm of this which would be how you heard it. [@] In other words if I graphed it in decibels. [@] It shouldn't take the log of this. [@] Well it could take the log of of this: [@] This is now this is showing the envelope generator again. [@] If I took the logarithm out of this you would see something that started off not quite level but then suddenly started dropping precipitously later on. [@] Until finally here it hits minus infinity because the logarithm of 0 is divergent. [@] Questions about what I just put down? [@] I'll probably say this again and again, in many different ways. ... Yeah? [@] Student: So, how would you change it to logarithmic decay? [@] ... Yeah, how would you make it be logarithmic? [@] Oh that's a good one! I intend to bend your ears very seriously about that in the coming weeks. [@] There are five or six ways you can do it. [@] Depending on the exact spin that you want to try. [@] One thing that you could do is you could say, ... Oh you know what? [@] I'd have to use an object here that I'm not ready to use yet. [@] So let me go on to units because once I've talked a bit more about the psychoacoustic units then I can answer questions like that a little bit better. [@] Other questions? ... Yeah? [@] Student: In the line~ the "500" was 500 milliseconds. What is the 44,100 number? [@] Oooh, that is a good question. [@] Units in Pd are confusing. [@] 44,100 is the numbers of samples in a second. [@] 500 is the number of milliseconds in a half second and sometimes in Pd-Land time is in samples, and sometimes time is in milliseconds. [@] This is just kind of unfortunate, I don't know anyway around this situation. [@] PD here doesn't actually believe that the axis here is time, this is really just an array of numbers. [@] Which of course you could treat as an audio sample which is the way I'm treating it right now. [@] But it could be probabilities or it could be weather data or anything. [@] If you want to use this to store a sound, the natural thing to do is have the horizontal axis be samples of which each one is 1/n-th of a second where 'n' is the sample rate. [@] And that number varies - if that number were always the same things would be a lot easier, but in fact sample rates vary depending on what you're trying to do. [@] If you want to find about a dolphin's songs you should not operate at 44k1. You should operate at a couple hundred thousand at least. [@] That explains the value 44,100, which was the size of this array which we set in the panel where you set the size of the array. [@] Here, these are values of time, which are of interest to line~. So another part of the answer to that question is that different objects - for instance, line~, or osc~, take their inputs to mean different things depending on their functions. [@] So for osc~, its input is setting the frequency of that object. [@] And line~ -- when I'm sending it messages like this -- the message is interpreted as, "This is an output value which itself is in arbitrary units, which matters to the next object down. [@] The second value is a time which is in milliseconds. [@] And that is possible, because line~ is a thing which actually runs in time, and so it has access to what the real value of time is so it can operate on a time unit as opposed to a unit of samples. [@] Student: Could you use line~ to set the frequency of an oscillator? [@] Yeah. That's a fun idea. You could use line~ to set the frequency of an oscillator. The answer is yes you can and why not. [@] Now these are not good frequencies for an oscillator, right? [@] So, 440 and lets make it a half second. [@] So, now I'll turn it on [plays tone and modulates pitch by an octave.] [@] Now we've got full computer music, right? [laughter]. [@] Well, never mind that comment ... You can hook anything to anything. [@] The only restrictions being is that there is a distinction of type, which is to say something can be a number which is happening at the time of messages, or something can be an audio signal, which is something that comes out of a ~ object. ... Yeah? [@] Student: Could that line~ there be a message line. [@] Is there also a message version of line? [@] There is. [@] You could do this: [@] Watch this connection when I change that -- Boing! -- It turns into a message line! Now, you'll get a wonderful effect [plays tone]. Let's make that a smaller number. [@] No, it's too small [plays tone]. You can almost hear it now. [@] Hear an arpeggio? [@] The reason it's arpeggiating like that - I'll put it more in your face [makes adjustments to line values]. The reason you hear those values in the middle ... This thing, which I wasn't going to tell you about, is a version of line~ which puts out messages at a fixed rate. [@] What rate? [@] The rate that defaults to 20 milliseconds. [@] Why 20 milliseconds? [@] Because people used to use this to control midi devices and if you try to ram more than 50 messages (per second) down a midi device line you can get in trouble for various reasons. [@] So, this (message-version of line) exists. [@] And anyway sending a message to osc~ changes its frequency just fine, but it changes it in a way that happens right when it's going to happen, as opposed to doing it continuously the way a signal would. [@] Another way of seeing that is our old friend, print. [@] First off, there's nothing coming out of line, but if I tell it to ramp up to 880 ...[showing the Pd window] ... whoops. [@] It's already at 880. That wasn't a good example; I'll ramp it back down. [@] And, it says, "oh, OK. [@] 20 milliseconds later they're here and here", and this is the arpeggio that you heard which was too fast to be able to hear very well [playing a series of frequencies]. The version I showed you before which is [plays frequency pattern] this smooth one. [@] Was that clear to everyone? [@] Student: So, line is discrete and line~ is continuous? [@] ... Yeah, line~ makes it into an audio signal, which for practical purposes is continuous. [@] In fact I think using the word "continuous" is a bit of a lie because it's really just "continuously at the sample rate." [@] Oh yeah and we can do that here to, and this is going to be rotten. [@] Let's do 100 here. [@] I don't hear anything wrong. [@] If we listen to this over headphones you wouldn't like it though. [@] Can't hear it in this room I don't think, at least I can't. [@] What you should hear is a gritty sound that's called "zipper noise," which is the effect of this thing now. [@] So you have five steps, going from zero to .95, and this thing is changing discontinuously, which is therefore a click, like this. [@] Let's see, so here's the crude way to turn things on and off. <> [@] OK, so if you do it this way you have the same thing, but each of the jumps is only a fifth as large so they're a great deal quieter and buried in the sound of the oscillator, but if you do that with your headphones you can hear something bad. [@] It's actually, it's easy to track problems down when things are really bad, but when things are only just a little bad like that, then you will have to listen to your thing very much more carefully and more critically on order to be able to find find the problem. [@] It's better if you can to avoid getting into that situation. [@] So that's line, as opposed to line~, which would do it correctly. [@] Student: The message at the top is every tenth of a second? After you click it, it takes a tenth of a second to go to 110, is that right? [@] ... So, you''re referring to this network over here, I'm assuming? [@] Oh -- these two, oh OK. [@] So what's happening here is - Right. [@] Over the next tenth of a second when I whack it, it ramps from wherever it is up to the value, or down to the value I gave it. [@] Student: So assuming you just turn on the DSP ... So what's the starting value? [@] Zero. So now, for instance if I'm playing the sound and I say 'OK give me a new one of these, it's putting out zeros until I decide to send a message telling it to do something else. [@] Now that we've done that, remember that I showed you how to do rudimentary frequency modulation? [@] (This isn't exactly an aside, this is an embellishment.) [@] So we save as, [Saving "3.fmagain.pd"] and we're going to say three FM again. [@] And now let's see - lets get rid of - sorry, OK. I don't need this anymore. [@] What I need is another oscillator whose frequency is ... -- I'm going to recreate as much like the old values as I the old ones I can remember. [@] So I'm going to add 440 to another oscillator in order to create this oscillator. [@] And that other oscillator is going to be an oscillator with an amplitude control. [@] So lets get these two things out -- oh these three things out. [@] So this is an amplitude controlled oscillator. [@] That's all you really need to do it. [@] So here now if I listen to that like this I get, whoops I don't have the off button sorry. [@] There's that and now we're going to take that instead of setting it up to an amplitude of 1-ish I'm going to set it up to an amplitude of 1,000-ish. [@] Do not play this through the speaker. [@] And meanwhile I'm going to make it slower so you can hear what's happening. [@] And what I'm going to do to this, is I'm going to add 440 to it and make it be the frequency of another oscillator. [@] Let's just make sure this is off. [@] And I'm going to clean it up a little bit so that you can see a little better what's going on. [@] Alright, Ocsillator. [@] Now what were listening to is this oscillator right now its playing at 440 Hertz and this is going to apply vibrato to it. [@] Vibrato is going to be at the audio frequency also at 440 Hertz and its going to have amplitude of zero up to 1000. OK. [@] And that's the sound that I incorrectly said was 60's computer music. [@] This was invented or published in 1973 so this is 70's computer music not 60's computer music. [@] That's a correction from last week. [@] My apologies to John Chowning if he ever sees this video. [@] Oh, John Chowning is the originator of the frequency modulation technique, as we all know. [@] And anyone who has a cell phones uses FM all day long. [@] For which I once heard John say he was sorry. ... [@] -- Now this is an excellent moment to ask if you understand what's going on or not. [@] Let me tell you one useful thing ... [@] Student: Can you say what the graph parameters are? [@] The graph parameters -- OK. [@] I didn't actually graph anything just now. [@] The graph parameters are properties. [@] It's got a name (x1-13) it's got size 44,100 and I am saving contents which I probably shouldn't and I have these polygons despite the fact that I might need points. [@] Whoops, I closed the other thing too. [@] And then the "canvas" -- that is to say the graph that it's in -- the horizontal range is set so that it holds the array. [@] You can change that but- [@] Student: Doesn't the array actually have 44,101 points? [@] Oh, OK. So arrays actually are indexed starting with zero, C-style. [@] So really the graph could have been from 0 to 44,099 but what would that change? [@] That might move one thing over one pixel. [@] Also, I mean you also can lie to it. [@] You can say "I want you to start graphing at 1000 please." [@] You probably should do this ... and then it's all very good except the thing is - Oh, look at that. [@] I just destroyed it. [@] What did I just do? Hmm. Can't see it anymore. [@] I didn't want it that way anyway. [@] So what's happening here is: [@] first off this thing is repeating every... [@] hmm, I don't know how to describe this... [@] OK, this is an oscillator nominally which is operating at 440 Hertz and I'm applying vibrato but the vibrato itself is repeating every 440 Hertz. [@] What that means is that rather than changing the heard-pitch of the thing, I'm changing the pitch so fast that it's actually changing the waveform. [@] Or, to put it another way, the result is repeating still every 440th of a second. [@] The thing's repeating at 440 Hertz still even though its pitch nominally is changing, it's happening within a cycle and the cycle is always the same period so we don't hear any change in pitch when we start applying vibrato [the original 440 Hertz oscillator alone] [then ramping-in the vibrato changes the timbre.] [@] So, if we're not changing the amplitude, and we're not changing the pitch then old psychoacoustics joke is: [@] If something isn't amplitude and it isn't pitch, then it must be timbre. [@] So we're making a timbrel variation on the sound and there are ways of describing mathematically what's happening here which I won't go into but I will go so far as to graph these waveforms so that you can see the vibrato in action. [@] And it's a good thing. [@] To do that now, I have now to change the parameters of the table. [@] "Properties" -- OK. [@] So let's have the thing only be 1,000 points now. [@] ... Let's see. Let's graph just the output of the oscillator without worrying about the amplitude. [@] And ... it won't do it! .. Because I have to do something else. [@] This is the old 43-test bug. ... Yeah, question? [@] Student: Does that 440 in the oscillator add to 2000? [@] It does, yeah. Oh, yes. Thinking of it that way, the first oscillator is 2,000 volts right now. [@] It's actually varying from plus or minus 2,000 volts and I'm adding an offset to that, so it's varying from +2,440 and - 1,560. ... Yeah? [@] Student: Sorry, could you explain the values in the message box and what goes to the *~? [@] This is going to be the target value that line~ gets, so if I graph the line~ output it would be 2,000 units north. [@] Student: But that 2000 ... what units is it in? [@] Oh, what unit is it in? It's in whatever units the thing I put it to is taking it to be. [@] In other words, it's really just a pure number. [@] The units only become relevant when you use it for something, which is down here. [@] So it's really just knowledge about the patch that this is all operating in Hertz and the reason it's operating in Hertz is because this oscillator wants the thing in Hertz, or cycles per second. ... Yeah?? [@] Student: 2,000 is the amplitude connected to the value of the oscillator, right? [@] That's right. [@] And that's why "amplitude" is such a slippery word. [@] It's both an amplitude, but it's an amplitude that's in Hertz. [@] Student: It's a magnitude. [@] A magnitude? ... Yeah. This is a question. [@] I think of amplitudes as being able to be positive and negative and magnitude as being the absolute value of the amplitude. [@] That might be a local usage of mine. It's the usage that's in my book. [@] It's also what the quantum mechanician would say, I think. [@] Student: If that's 2,000 Hertz then it's not oscillating at 440 ... why doesn't the pitch change? [@] That's right. And yet the change that I'm making in the frequency of the oscillator is varying, but it's varying in such a way it all adds up to no variation because there's as much positive as there is negative. [@] So half the cycle here this thing is adding to the frequency, the other half is taking away from the frequency, so the average frequency is still 440 even though it's going up to much higher than that and down to something negative. [@] Let me see how you graph it. Let me graph it. [@] Hang on to your questions for just a second. [@] I'm just going to change it [the Y-range] to +2, -2 again. [@] OK, so now we're looking at the oscillator, but we're not changing the frequency. [@] So now you see the period of the oscillator is from, for instance here to here. [@] So it's about 2/5ths of this number line. [@] OK, I changed the window by the way, so that it's at 250 points now. [@] So it's a very short amount of time in the life of this sound. [@] Now I'm going to send the oscillator up to amplitude 2,000. I'm not going to graph that (first oscillator), because it would go through the roof. [@] But you can still now look at the output of this (second) oscillator, and then you get - OK now, this requires some explanation. [@] It still has the same cycle, but let me ... - Before I give it 2,000, let me give it some smaller number like 440. No, smaller than that.... [@] OK, here, this is easier to understand. [@] So you see it's still cycling from here to here. [@] That it's going too fast, and then after that , it's going too slow. [@] It's going faster here because at this moment in the cycle, this oscillator was positive, and therefore was adding to the frequency. [@] So it sped up to some frequency much higher than 440 Hertz. [@] But then over this period of time, it has slowed down to some frequency much lower than 440 Hertz. [@] And on average, over the cycle, the frequency was 440, and so it actually made it through the cycle in the correct amount of time. [@] But it did it in a non-uniform way, whose result therefore was not at all a sinusoid. [@] And then if you listen to it, you won't hear a sinusoid, you will hear some other waveform that has some other partials, because waveforms have partials. [@] Now what was your question? [@] Student: What would you do if you only wanted magnitude, you wanted the lowest value to be 0, instead of going between positive and negative? [@] Oh, yeah, there's a couple of ways you could do that. [@] You could take the absolute value. [@] Which means negative values simply be negated so they become positive. [@] Or you could slide the whole thing up by adding one to it. [@] And then you would just see the entire waveform do that. [@] Oh, that would be if you added one to this oscillator. [@] This oscillator right now has an amplitude of 330 but I'm adding 440 to it. [@] So if I graphed it I it would go up to positive in fact. [@] It's all ranging from 110 to 770. [@] Student: So those are all magnitudes? [@] ... Yeah, in my way of using amplitude and magnitude I would say that magnitude is the amplitude because the number is a positive real number, whose absolute value is itself. [@] But I would never say something like that except to confuse someone. [@] Goal achieved [laughs]. So these are amplitudes which are variously positive and negative. [@] But if you add enough to a sinusoid - if you add enough of a constant to a sinusoid it would be positive and the samples would all be positive. [@] Student: Then you wouldn't have phase issues? [@] Oh boy you always have phase issues. [@] But they would be different phase issues. -- [@] But that probably didn't answer your question very well did it? [@] Student: Sort of. [@] I can just look at it on the computer. [@] ... Yeah, I think the gist of it, you're confusing yourself by using the word magnitude. [@] Student: I just wanted all of the values to be positive. [@] But how would that help you? [@] ... Yeah I think I could do that to this and then the frequencies wouldn't - whats the right way of saying this. [@] Obscure it, the results would be complicated. [@] ... Yeah OK. [@] So OK. So now if I make this value bigger, let's try 1000. [@] Student: You don't have a second value in the message to line~ , where you have 1000 as the first value? [@] How long does that line~ take to ramp up? [@] Zero. That just means "do it right now please." [@] So this is equivalent to "1000 space 0." And now we have the following hilarious sinusoid which did get around to phase zero once in the cycle but in fact was going -- you can't see it right now. [@] I'm going to just scramble the phase a little bit and see if we get a better one. [@] Oh, there we go. Alright. [@] So at some point it hits zero phase and then it goes racing along until at some point it decides "No I went a little bit too far ;lets go backwards." [@] And so I think at this portion of the waveform I think it's actually a negative frequency going backwards until it decides to come backwards enough to rush forward at superior speed. [@] So by pushing the - OK. [@] So what I did was I made this oscillator have amplitude 1000 which therefore is so great that even after you add 440, you have both positive and negative values. [@] And therefore you see the thing wrapping both forward and backwards in the cycle. [@] Student: Can we hear what that sounds like? [@] Yeah. In fact, you can do more of it. [@] So now I'm going to ramp it up to 5,000 and then graph it. [@] ... Yeah --2,000, sorry. [@] ... Yeah, yeah. [@] Alright. [@] Let's make it 5,000. Oof -- There maybe I shouldn't be graphing points after all. [@] Let's go back to graphing this stupid way with polygons. [@] Polygons are better if you have smaller numbers of points. --- [@] There we go. [@] This is the classical, pedagogical waveform that we show when you show frequency modulation. [@] The thing is wrapping forward crazily and then wrapping backward crazily to add up to just one cycle forward. ... Yeah?? [@] Student: Does the oscillator still output 440 Hertz even when 5,000 is added to it's frequency? [@] Sample this oscillator and the oscillator's frequency is averaging 440, but it's varying by 5,000 around that average, which means it's rarely in the vicinity of 440 anymore. [@] It's just being scattered all over the place. [@] Student: How does the first value of 440 fit in? [@] Oh, this is getting added to this oscillator. [@] Oh, you mean this 440 on top? [@] Oh, that's a good question. [@] What if I make this 440 something different? [@] Let's turn it off first. [@] So now we're listening to the same thing. [@] Then turn on the variation: [@] Now what we have is something that looks like this: There's the original tone, which is an octave higher. [@] Now what I'm doing is I'm varying the frequency at a rate so that it evens out completely only over two cycles. [@] So the resulting period is in fact 1/220th and not 1/440th. [@] So this (220) is the frequency at which this thing is changing. [@] Now the variations are taking twice as long to cycle, but this (440) is still the center frequency, which could be some other number if we wanted to. ... Yeah?? [@] Student: How does the line~ control the changes? [@] The line~ controls how widely it's varying around the center value of 440. [@] Student: And the starting frequency of 220 controls how quickly those changes happen? [@] It's how quickly the variations happen. [@] ... Yeah! Yeah, yeah that's it. [@] So the frequency of this oscillator is 440 with disturbances. [@] The disturbances have both an amplitude and they have a speed. [@] So the speed is 220 times a second and the size of the disturbance is 5000 or whatever it is that I set it to. [@] Student: And its 5000 Hertz? [@] ... Yeah, because it's being used as Hertz because oscillator is ... These magnitudes are eventually finding their way down here and then they're being used as Hertz. [@] But I could use this to read a sample or something like that and then the units would be different. ... Yeah?? [@] Student: Is the 5000 frequency really just wave shaping? [@] It is FM modulation. [@] It's frequency modulation. [@] Which is "FM." [@] You could even think of it being as overdrive in something too, but I'm not sure what. [@] ... Yeah maybe, I'll talk more about wave shaping and over-driving and stuff later on. [@] It is a sort of overdrive. [@] Now OK, so gravy on the cake is why don't we just make this thing be something we can control. [@] Like this: [@] ...Now I'll go back to the original(440). The amplitude now is 1000 and now I'll start changing the frequency continuously. [@] Alright, oh so this, now looks like this. [@] And you don't see a period in fact, you have to wait an entire second I think, no, you have to wait a fifth of a second before the thing all wraps around. [@] So now you get something which is a nice inharmonic tone. [@] And you can analyze this and find out what the frequencies of the inharmonic partials are which I think we'll manage to get into in week six or seven, but here I'm showing that this is a thing that you can do. [@] Now, of course the amplitude can still be varied, the amplitude of the modulating oscillator can be varied and then you get ... one of these good 1970's computer-music sounds. ... Yeah? [@] Student: Instead of making line~ do it in five seconds can you do it in one second? [@] Oh yeah OK. All right speed it up. [@] Now, this is going to sound bad with these values ... [speeded up variation plays]. [@] Student: That doesn't sound bad. [@] That sounds awesome! [@] OK ... I guess you could like that ... [laughter]. What I don't like about it is that you hear this little wah-wah effect as it's changing and you can't get that wah-wah effect out. [@] And it's cool for the first five minutes but then you get really tired of it. [@] And you can't iron it out -- you just have to turn to a different sysnthesis method at that point. [@] Most people who use FM, don't use these kinds of values. [@] They're good pedagogically, because there's no way you can miss hearing it. [@] If you keep these values upon the order of this (440) or maybe even twice as much as this, you don't get that wah-wah, but you still get a timbrel variation. -- [@] But you don't get a whole lot of high partials, so then, if you want high partials but not the wah-wah then you have to think a little harder. [@] There are five or six ways I can tell you of proceeding. [@] But, that happens later. [@] Other questions about this? [@] There's a homework assignment for next time which is on the (~msp) website, but I haven't made the WebCT upload-yoohah yet. [@] The homework assignment is actually not to do FM, but is something that you will need line~ for, which is to make a collection of four oscillators which makes a tone and breaks up into two tones. [@] After you've enjoyed it for awhile. [@] Let's see if I can actually find it ... The gotcha is I don't think I'm going to be able to get my computer to play this. [@] This is a graph that shows you how you can do the thing. [@] Which you will not be able to hear because I'm not configured ../ It's playing out some other audio device that I don't know how to control. [@] You'll hear it if you play it. [@] It will start out as a nice tone. [@] This is a time versus frequency plot, which is a way of describing how you might wish the partials of the sound which would be sinusoidal components which would add up to make a sound -- if you believe that sounds are made up of sinusoids, which they could be. [@] So, what I'm describing here is how the frequencies of a bunch of sinusoidal components might change in time. [@] If you played this and, for instance, -- the amplitudes, they're not shown here, but if you made the amplitudes all equal -- when you play these four you will hear a tone. [@] At least if the four sinusoids start at the same time, you'll hear a tone, whose frequency would be that of the fundamental -- which I think I suggested might want to be 220 Hertz. [@] And so if that were true this would be 220, 440, 660, 880. And you would hear a nice tone until this thing happened. [@] At which point a wonderful psychoacoustic effect would take place. [@] Which is your ear would quit being able to hear this as a tone. [@] You would still hear this and this being fused as a single tone at this frequency, although its timbre would change because it would no longer enjoy even harmonics anymore. [@] And meanwhile you would hear this, these two. ... [@] Oh, what's the interval between this partial and that partial? [@] Student: Is that the ratio? [@] What's the interval? [@] Two to one is the ratio. [@] ... Yeah, so an interval is a ratio, really. [@] So the interval of two to one is called an octave, in Music Land. [@] So since these are an octave apart, they in fact could also function as a tone at this frequency that has two partials. [@] And you will hear that tone as soon as this thing starts sliding away, because your ear will no longer allow it to hide behind these partials to be considered part of this tone. [@] So what you'll hear is a single tone that bifurcates into two tones paradoxically. [@] One of them consisting only of odd harmonics, harmonics number one and three. [@] And the other consisting of harmonics one and two of a different pitch. [@] And that's a wonderful thing to contemplate. [@] I didn't bring it along this time, but next time I'll play you some music by Jean-Claude Risset which uses that in interesting ways. [@] Basically, you can design timbres that you can tear apart and make series of pitches out of. [@] Or collections of pitches out of. [@] It's fascinating. [@] And, it is indeed 60's computer music, because that was stuff that they did even before they had access to frequency modulation. [@] So this has nothing to do with FM. [@] You can do this just with additive synthesis. [@] Sorry -- "additive synthesis" is what computer musicians say when they're talking about making a bunch of oscillators and adding their results. [@] So you can make this by adding four oscillators up. [@] And now that you know about line~, you can arrange for the frequencies of oscillators to slide from value to value. [@] And of course you should make the whole thing turn on in a smooth way and then do this, and then turn off. [@] And that will require also that you have delay objects because you want the ramp up to start here but then you want the change in frequency to start here and then you want a ramp down to start over here. [@] Student: You need the other objects with line~ and delay, too? [@] Yeah, and oscillators. It's, basically, you just practice with the objects that you all know about. ... Yeah? [@] Student: So line~ can ramp the volume down too? [@] Oh, how would you ramp the thing down? [@] ... You can't show it, I'm not graphing amplitudes here but frequencies. [@] So I would have to make a separate graph to show how the amplitudes would change. [@] And, yeah, just have a line~ multiplied by the whole wreck. [@] And then it, after an appropriate delay you send that to a nice message zero with a time value. [@] And then it would turn off. [@] And then when you do that you will have full access to all of additive synthesis. [@] At that point you can make more complicated ... -- Well, OK, your patches will be horrible if you actually try to do it without introducing some automation. [@] But you will at least in principle have control over over the structure of the harmonics, or enharmonic partials of any sound that you want to make. [@] Which could be powerful. [@] *** MUS171 #05 01 18 (Lecture 05) [@] This is the familiar network where you have an oscillator with a controllable amplitude. [@] Amplitude of course you control by multiplying the output of the oscillator, that's the easy way to do it. [@] And the frequency of the oscillator you control by sending it the appropriate input. [@] So here it is: [Tone] [@] You can do them both simultaneously, maybe not. Wizard of Oz. [@] And if you want to sequence that, why you don't get some delay objects, so maybe the good way to do this is give yourself a button, and then you can have delays. [@] "Delay" you can abbreviate as "del"; there are abbreviations for some of the most frequently used objects. [@] And it's going to become important in this particular case. You'll see why. [@] So let's have the button turn this on, and have it to be at 440. The recording will jump to 440; I'll tell you why in a second. [@] You don't want to necessarily slide to the note, if you want to start a note at the beginning of something. [@] You might want to have it just jump there. [@] So this is now a button that makes sure that we're at 440 when we turn this thing on. [Tone] [@] When you turn something off, you don't have to do anything to its pitch, because just turning the amplitude of the thing by multiplying it by 0 turns it off. [@] It's still playing A-440, this oscillator is, but we don't care about it. [@] So now a...[Tone] [@] You do want one of those -- it also turns this off, right? [@] So hit that button and turn it off. [@] So you want it to slide to 440 and turn it off. [@] Ah! That sounded horrible. [@] Let's not do that! OK. [@] So now what we're going to do is make a nice little sequence by having "delay 500" successively, which will be setting these delays every 500 milliseconds. [@] As a matter of survival, if you're going to have a bunch of delays, don't daisy-chain them but have them all come off of the button or whatever triggered them. [@] Because, why? [@] Because that way when you start it again it restarts all the delays and you won't have messages trickling down the delays when you're no longer trying to do certain things. [@] So now what's going to happen is every time I press the button ... yeah, I should do this [@] <> [@] Every time you press the button you start a sequence of delays going. [Tone][Over sound] [@] And furthermore, here's a subtlety, when you start a delay, if it was already started, it forgets the previous time it had been started for and resets it to the new time you're starting for. [@] That's a good way for a delay object to behave, because then it doesn't go off and do something in the wrong order, because you told it to do something and then changed your mind later. [@] If you changed your mind about what you wanted to do. [@] It is now only doing the new thing, so you can actually believe that things are going to do what you ask them to when you start something -- if you connect to the delay this way. [@] If you decide that you want to connect to the delays successively one to the next, then that won't necessarily be true, each one will set the next one off, and if you reset the first one, depending on what phase the others are in, they'll continue doing their things, and then you'll have different delays fighting each other for control of your oscillators, which will not be as good. [@] So it is a good thing not to daisy chain your delays, but to have them all come off the same source like that. [@] Now I'm going to make beautiful music. [@] That's going to be, nothing? [@] Oh, it's going to be a rest. [@] ... Yeah, that'll suit fine. [@] And then they'll go over there, and then they'll wait another second. [@] I won't even put that delay in there. [@] It should be 2500. And here it'll go back down to A and here we'll stop. [@] And now, here's one of the things that's problematic about patching, and I will show you strategies later to deal with this: [@] Your patches get messy after you've done a certain amount of stuff. [@] Technique number one: [@] Turn the font size down. [@] Other techniques are going to be use more than one window, but I haven't shown you how, and also use names for things so that everything doesn't have to be a connection. [@] I haven't shown you how to do that either, but that's all coming. [@] And now if I have this right I'll have this this beautiful composition. [Tone] [@] Ta-da! The marching demons in the Wizard of Oz. [@] So this is how to make sequences that do things like control amplitudes and frequencies. [@] Questions about this? -- What I did and why? ... Yeah?? [@] Student: I forgot, for the first number in these messages is for frequency? There's a .03 there. [@] Oh! OK, yes. [@] That's the thing. [@] These numbers, what they are depends on where you put them. [@] Or rather, how they're interpreted depends on where you put them. [@] So these numbers are frequencies by virtue of the fact that they're talking through this line to this oscillator. [@] But these other numbers are amplitudes because they're talking and this line is getting multiplied by the oscillator. [@] So even though the data goes down, in some sense the meaning bubbles up. [@] Student: So it's on the line that goes amplitude and then time...? [@] Right. -- Or value and time or target and time. [@] I think of it as target, because it's the place where the line will eventually be, or the thing that the line will eventually be emitting, I guess is the right word after the time elapses. [@] Student: So it's another process that determines what they're lined up to. [@] ... Yeah. Other questions? ... No? I'll leave this then and get onto fun topics. [@] Not that this isn't a fun topic, but there are other fun topics. ... [@] I'll just do a "Save As", remember the font size and start all over again. [@] I'll just do three... table... Oh, no, wait. [@] I neglected to tell you a bunch of things last time. [@] Yes, right. [@] Table oscillators first, and then units, psychoacoustic units which is MIDI units of pitch versus frequencies, and decibels versus linear amplitudes, which I will show you after I show you the basic yoga of table lookup in computer music -- Well, phase generation and table lookup, which is how oscillators are made, which is the bread and butter of computer music. [@] And the fact that it's taken me five classes to get here says something either about the indirectness with which I'm approaching the thing, or the fact that perhaps it is actually more complicated than I'm thinking to myself it was supposed to be. [@] OK, so we're going to do phase and tables. <> [@] Do this one. [@] And, we don't need any of this except the time for that, so. [@] But we'll keep this around for this, just to be able to use it. [@] But... here's where I'll stop, maybe on this. [@] So the first thing to comment on is the following: [@] There is an object, whose name is phasor, which generates phases. [@] These are not useful things to listen to. [@] In fact, let me prove to you this is not useful to listen to by playing it.[Tone] [@] This is a bad sound. [@] The reason is that it sounds like a mosquito is what's called fold-over. [@] Well, there are several reasons it sounds like a mosquito. [@] But the reason it sounds bad in computer music ears is because of fold-over, the fact that this signal is not a good band-limited signal that is limited to 22 kiloHertz and a half. [@] It is an un-bounded signal that has theoretically an infinite trail of partials, and in a digital environment such as in any computer music environment, you will hear various kinds of badness happen. [@] What it sounds like is just not exactly a stable quality of the signal. [@] It sounds like it's fluttering a little bit. [@] That is fold-over. [@] There are better examples of fold-over that I could show you, but they would be piercingly ugly to listen to and I don't really want to deal with them. [@] Go look at the Pd documentation; you'll see a wonderful fold-over generating patch which will make you jump out of your chair and spit out your gum. [@] So now why am I showing you this, then? [@] Because you use it to do things like look up wavetables. [@] To show you this, I have to get out my array so you can see what's happening. [@] I'll do that now. [@] Sorry this is getting repetitive, but it is what it is. [@] I'll call it [@] <> "array.1.18a" [@] And then just going to use a nice tabwrite~ write it. [@] Wow. I shouldn't really have given a long name, should I? [@] "array.1.18a" ... [@] I don't want these to fight with each other if you happen to load more than one of these up while you're looking at old patches, which is why I'm making these awful names. [@] I'll show you a better way later, but that will wait. [@] So now, one of the things the phasors do that makes ...oh! Duh! I thought it was me. [@] It actually was me but at a deeper level. [@] Here's a crucial thing to get: [@] Here's a sawtooth wave... [@] notice how there are bad kinks in this? [@] That's actually graphics. [@] But there are bad kinks in the thing, because sometimes when the thing wraps around, actually let's go to 440, sometimes when the thing wraps around... [@] Since we're at 44,100 points per second, 440 Hertz means how many samples per cycle? [@] 100 and a fraction, I think, if I'm doing this right. [@] <<41,100 samples/second)/(440 cycles/second) = 100.22 samples/cycle >> [@] So it's <> about 100 samples long. [@] Oh yeah, it's about a hundred samples long 'cause the table's about a 100 samples big. [@] But it's not exactly 100 samples long from the bottom to the top, it's just that sometimes it's 100 samples and sometimes it's 101 samples. [@] <> [@] It's not a decent periodic signal, really, it's a sawtooth wave being represented digitally and it sounds bad. [@] What you do to make it sound good is you use it to look up a table such as ... -- And here's object number two for today: [@] Phasor and cosine are both objects you haven't seen yet. [@] The cos takes whatever goes into it and reports its cosine, or outputs its cosine. [Tone] [@] And that's when you get this kind of thing: [@] That's a nice sinusoid. [@] So your cosine is not a sine, because cosine is the simple function and sine is the complicated function to deal with. [@] There's only one wavetable, so it became cosine. [@] With an oscillator, really, you've seen this as osc~. The osc~ is in some sense equivalent to (phasor and cosine). Phasor is an object which just generates a phase that goes from left to right if you'd like, a certain number of times a second you specify, for instance by an input. [@] And cosine is a table lookup which if you give it 0, it gives you 1; if you give it 1/2, it gives you -1. And if you give it 1, it gives you 1 again. [@] And I happened to click it just at a moment when it was going from 0 to 1 in the space of the window. [@] But if I do it again, you'll see in fact that it's just moving between those two values. [@] That was an accidental click. [@] Now, this is interesting because you don't have to use cosines. [@] You can use other waveforms. [@] And what would be another good waveform? [@] Well, for instance, I could ask for the cosine of twice the thing which would be two cycles of the cosine wave and do that like this: [@] Multiply the phasor by two so that it doesn't sweep from 0 to 1, It sweeps from 0 to 2. [@] And then, when I connect that, you hear [Tone] the octave. [@] So, there's twice as fast as this. [Tone] [@] Well, "twice as fast," that might be confusing. [@] What's really happening is, think of this as a function. [@] This function is a cosine of twice the input which is to say it doesn't just go from one, to minus one, to one once as the phasor's output goes from 0 to 1. [@] As the phasor's output goes from 0 to 1, this goes from 0 to two and so this thing goes through two cycles. [@] So, you're looking up the second harmonic. [@] So, now you can do groups of harmonically related sinusoids. [@] You can build up tones out of amplitudes of individual harmonics by combining cos~, and cos~ of the octave with the cos~ of the twelfth, and so on ... like that until you get tired of making the patch. [@] This is a very simple ... What's the right word? [@] ... a very simple example of using wavetables, of using waveforms, specifying waveforms, which are things which you index by giving it a number from 0 to 1 so this phasor does repeatedly at some number of times per second given by its frequency. [@] Phasor has memory. [@] It has to remember its phase from sample to sample. [@] So, it is an effective integrator. [@] The frequency that you put it tells it how much it's going to add to each previous sample to make the next one. [@] cos~ doesn't have any memory. [@] It's just a pure function that takes whatever you put in and puts something out. [@] So, phasor is the real oscillator here and cos~ is a wavetable that the oscillator is indexing. [@] And furthermore, this combination of (phasor and cos~) is what you previously have known as osc~. All right? [@] Now, I told you that so I can tell you this next thing: [@] You can make your own tables up. [@] Here's where, at least in some respects, things start to get fun. [@] So, how am I going to do this so it's in the right space? [@] There, I can't see that so I'm going to cheat a little bit. [@] I'm going to make a window as big as I possibly can so I can keep this font. [@] That will hopefully make something that can be understood. [@] I'm going to make another table and I'm going to give it, again, I didn't think in advance, I'm going to give it 8 points. [@] ... And this is now going to be a table, "tab.1.18" [@] -- Sorry. That's a bad name. Everything is bad about this ... [@] Here's the graph. Yep. We're happy. [@] Everything is good. [@] Now, last time I did this, I forgot that I asked you to do the points instead of polygons. [@] Points. So check that we did. [@] I forgot, OK. [@] Now, we have something which we can edit and it's just a bunch of numbers. [@] 8 of them. [@] So, you've seen all of this before except I don't know if you've seen me drawing one, but that's one way of getting things into the table. [@] There are other ways. [@] You can have text in a file. [@] You can, if you want to, save the properties and somewhere in here it gives you the opportunity to... [@] What does it do? [@] What does it allow you to do? [@] Edit this in by... [@] Oh, got 'em .. where am I now? [@] I'm looking for features that isn't there -- OK. [@] I'll show you how to get numbers in there in a good way later. [@] That's going to be a whole other thing. [@] So, I just put a waveform in here. [@] Now, what I can do is say, "Oh. [@] Let's listen to it by..." [@] Some pedagogical sense tells me I should do this first. [@] We're going to read out of the table and the table is going to be "tab.1.18a." [@] Notice, I did not put a tilde in. [@] I'm going to do this just with messages to start with because it's going to be easier to understand what's going on. [@] And then, I'm going to add a tilde and we're going to be operating with signals. [@] So, on that [@] 07] Input number ... and beside it [@] So, I'm using a Macintosh keyboard on a Linux machine. [@] The little Apple key doesn't do anything in Linux. [@] It doesn't think it's an Apple. [@] So, I give it numbers like 0and it gives me this value. [@] I give it a number 1 and it gives me this value and so on like that. [@] And now, I can just go sweeping through the thing looking at the values in the table. [@] So, we've got storage. [@] Not only storage, but storage of as many numbers as you want to put in the array. [@] Student: How come when you go negative three, it still gives you a value? [@] Yes, thank you. [@] What happens when I go off the end of the table is, it says, "Well, that's OK. [@] I'll just give you the closest point to what you had." [@] So, in general, Pd's approach to errors -- this is not good computer science -- is it just puts guardrails on everything. [@] So, if you divide by 0, it doesn't give you an error. [@] It just gives you 0. If you try to read off the <> array ... Actually, there's several things it could have done. [@] It doesn't give you an error because then you wouldn't hear anything. [@] It's better to hear something that's wrong than not to hear anything. Maybe. [@] You could also say that "if I gave you a negative value, the thing that you should do is wrap around to the other end as if you were an endlessly repeating waveform." [@] That <> is done using a different object in Pd. [@] The table doesn't do that and if you want that, you have to use an object called "wrap" which I will introduce later if needed. [@] Instead, it simply says, "If you're between 0 and 7, it will read the value out of the table. [@] And if you're in excess of 7 or below 0, it will simply give you the last or the first value." [@] Which is good enough for us right now. [@] Furthermore, if I give it a number like, let's see... [@] If I give it 0 as the first value, and the last value is 7 because there are 8 numbers -- That's one possible way of counting. [@] That's the modular arithmetic way of counting. [@] The other thing is, if I give it a half, what should it do? [@] That's a trick question on two levels. ... ... Yeah?? [@] Student: You can give it a 1, possibly. [@] Or you can give it less than 1? [@] Well between this and this. [@] So, you could just do what you said, which is to say, just call it 1 or just call it 0. [@] Oh! And then, should you round, in other words, if I give it a half should round it up to one, or should it just truncate it down to 0? [@] Another thing that... ... Yeah?? [@] Student: Could it do interpolation? [@] Another thing it can do is interpolation. [@] But then, the question is, how many points of interpolation should you do? [@] And if it's two points, there's really only one good interpolation algorithm. [@] But when you have four or 8 points, there are several different ways of interpolating that have different properties. -- [@] So, it just doesn't<>. [@] If I give it numbers between 0 and one, it declines to act smart. [@] It simply truncates the 0 and gives you that value until I hit one, at which point, it gives you the next value and so on. [@] Student: So, if you were to go below this number now, does it round down or does it just round one of them up? [@] It rounds down. Oh, yes. There's no memory again so it doesn't know what I asked it previously. [@] So, everything is as if there's no yesterday and it always rounds toward minus infinity. [@] Actually, in table land, it only counts from 0. So it rounds towards 0, we'll call it. OK? [@] If you wanted to... ... Yeah?? [@] Student: Can you go and put the numbers in again? [@] Yes. I'm trying to decide which is the best way to show you how to do that and which requires the least constructs. [@] There are about five ways of doing it and I didn't realize I was going to have to do that today. [@] So, I didn't think in advance about which one to show you so I'll get back to that. [@] You will eventually want to be able to do things like throw values in a table. [@] Oh! There's a tabwrite~ you can see here, so you can guess that there might be a tabwrite <>. But it's not. [@] Remind me to get back to this. [@] The tabwrite is not a tabwrite~ without a tilde. -- [@] It doesn't turn out to make sense to just write sequentially through the table in message land so it works differently. [@] So, here's tabread. [@] Now, you could say, "tabread~" And now that you've heard everything that you've heard, you know exactly what will happen when I run a phasor into tabread~ and then, listen to the result. [@] Why don't I hear anything? [@] Do I look surprised that I don't hear anything? [@] I'm not trying to project surprise here. [@] What are the values coming out of phasor? [@] 0 to 1, not inclusive. [@] And what does tabread~ do? [@] It rounds down to the nearest integer. [@] The nearest integer down is always 0 so we're getting out solid, whatever that number was, -.21 and the mixer is then forgetting it because it's AC-coupled. [@] So, if I want to hear something, I would take this phasor and multiply its output by the size of the table. [@] Oh. Here's a thing: [@] You will learn various ways of making your patches not occupy a huge amount of space. [@] Something that I do but you don't have to, is when you're multiplying by a line, you put the line next to the multiplier instead of above it. [@] And if you do that consistently, then you learn to expect it and then it looks normal when you do this, even though, this line almost looks like it's going up. [@] This is the way that I normally do this when I'm working. [@] Now, I'm going to say, "Multiply by the size of the table, please." [@] Oh, I forgot to put a space. [@] Oh, hey! Sorry. [@] I need a tilde because I need a signal multiplier because there's a signal coming out of phasor~. [@] And now, this is sounding better than the phasor. [@] And I have a little timbre-editor. [@] This is not beautiful sounds yet because there are discontinuities in the table. [@] Let's turn this off. [@] Student: Doesn't the table go from from 0 to 7, though? [@] Instead of 8? [@] Ah, thank you, right. [@] So, why am I going up to 8? [@] It's because if I went from 0 to 7 you would never hear this last value because the phasor would go from 0 to 7 but it would never get to 7 because the exact value of 7 would wrap it down to 0. [@] So if I want to read the entire table, I want to go all the way to 8 even though I know nominally the table stops at 7. So it's confusing for two reasons that cancel each other out. [@] There are 8 things in the table so 0 to 8 sounds natural until you realize that actually they're indexed from 0 to 7. So it sounds like you should go only to 7. But in truth you should still go to 8 because otherwise you wouldn't get any of the 7 because it would not do it. [@] Is that clear? [@] That is either clear or not depending on whether you could follow about three different facts that I introduced in the last half hour all at once. [@] So you can think of the horizontal axis here as going from 0 to 8. [@] In fact I think of it that way, even though the place where the individual points live are just in integers from 0 to 8 which are 0,1,2,3,4,5,6 and 7 -- but not 8, because then there would be nine of them. [@] And furthermore, for it to "spend just as much time," if you like, between 7 and 8 as it does between 0 and 1, you should multiply the phasor's output by the whole number 8 -- the number of points: [@] 8. This will change when we start interpolating the table, because then there will be fewer values that are useful. [@] But that will happen later. ... [@] Next thing about this, what if... [@] There is one way of getting values into the table. [@] But we can do it anyway. [@] Let's put a sinusoid in here. [@] I am going to be a little sloppy, but not terribly sloppy. [@] We're going to say, osc~, and I'm going to give it a frequency which is equal to (the sample rate)/8, so that its period in samples is 8. Right? [@] And I'm going to be lazy and say, give me a message box which gives me the sample rate which I believe to be 44,100. And then I will say divide it by 8, the number of samples in the table. [@] That will be the frequency for an oscillator. [@] And then I'm going to write that into the table. [@] This is called "tab.1.18a" ... confusing, all of the above ... OK. Write it. [@] And there is our nice sinusoid. [@] Oh, that didn't appear... <> except I'm going to make it be variable. [@] Let's see, I'm going to need some room. [@] I can still reuse all that. [@] And this needs to go to here, so that I have room up here. [@] Pull this down, make the window bigger. [@] So now what I'm going to do is I'm going to make a number box, and I'm going to arrange for the table to play -- starting at the number box -- a few samples: [@] So, to do that, what we're going to want is to generate something like this, number, comma, and then another number in a certain amount of time. [@] Except that the numbers are going to be variable. [@] So, for instance, the numbers might be ... let's start at 10,000, and then let's go another 1,000, and let's take a hundred milliseconds. [@] So, these two, if I did them in sequence, would go click, and what this is, sounds nice and metallic. [@] That's me doing a consonant, probably, and it's at the wrong speed, because I have to be careful about speed here. [@] Now, how would I do that, except make the 10,000 variable?l [@] Well, it's not so hard, all we have to do is we have to use the wonderful trigger object to generate two messages. [@] One of the messages will go straight through, the other one we're going to add 100 to it, and then pack it in order to make a message to hit 100. So that's going to be like this. [@] So this one, instead of doing this, we're just going to run this straight in. [@] This one is going to be a packed message using the pack object, and what we're going to pack is going to start with zero and 100, and this, except we're going to replace the value of zero with something. [@] And, the value that we're going to replace is going to be whatever this thing is, plus 1000. And now, we have to send a message in here and there, and we should do it in the right order. [@] So, we should use a trigger object. [@] Trigger: -- OK, these are all objects you've seen, although you haven't seen them done this way, so I'm doing a sort of review. [@] So first off, we're going to send the value as a floating-point number to the line then, and immediately after, we're going to send a value which is 1,000 more. [@] But it's going to be in a packed message, with 100. And now if I say 10,000, I get my sound back. [sound] [@] OK -- This isn't moving very much. [@] So, let's do some labor-saving and multiply it by 100. Now, this value is too big. [@] Now, what we're doing, is we're scratching through the sample. [@] It's such a horrible pitch, you can't even tell what's happening -- or I can't. [@] So I'm going to say, do this in about a fifth of the time that I said before. [@] Now I've got a pretty powerful tool. [@] Because I can do this: [@] It's got problems, right, which we're going to have to work on. [sound] [@] But notice now, I can say: [@] here is the very beginning -- this is your question now. [@] Here's the very beginning of it. [@] If I want to know exactly what the beginning was, maybe I should subtract this 1,000 from here. [@] But it's close enough. [@] And, I don't know of a better way, actually, of finding the beginning... [@] I don't know a better, simple way of finding the beginning of the sound than just looking for it audibly like that. [@] Question? [@] Student: Can you go over "trigger" one more time? [@] Yeah. Good idea. [@] So, trigger, I've introduced and I think the last time it was triggered with two bangs, as a way of making two message boxes be in the correct order. [@] And now I'm using a slight twist on the trigger object, which is that it will take whatever message you put in, and output that message from right to left, in right to left order. [@] Let's see ... it looks like this to you. [@] And it will put out variously floating-point numbers or bangs, which are messages that don't have any data, or lists, in case your message has more than one number in it. [@] And so in this case, what it's doing is it's interpreting this as a floating-point number each time, which is appropriate. [@] And it's first putting the number 2,700 out here, and then it's putting it out here, so that it can get 100 added to it and get packed with the value 40. So that, if I want to see what's happening to the line (with a print object, no tilde needed, just the regular old message print). I can do this: [@] Now, the print is hooked up exactly the same as the line object, which is down here. [@] Student: What does the number 40 represent in the pack? [@] 40 is the amount of time. [@] So what I'm sending the line is these two messages. [@] 2,700 -- That came from this 27 when I multiplied it by 100. [@] And then the other message is going to be a target value of the time. [@] The target value is computed by adding 1,000 to whatever the start time was, and the time I just gave as 40. [@] And now, of course, 40 milliseconds isn't the right amount of time for 1,000 samples to last. [@] But I just remembered that we went to the trouble of finding out that 100,000 samples is 2,268 milliseconds. [@] So, really here for 1,000 we should use one hundredth of that which is really 22.6. It's not gonna be exactly right for technical reasons. [sound] [@] Now I've got a little scratcher! [ Recording: "This is your brain..."] ... Yeah? [@] Student: Why exactly do you want to pack this? [@] Oh. Why do I want to pack these? [@] So that the message itself can have two values in it, because line~ wants to get a message (which is target and amount of time) in a single message. [@] Student: [@] So that's why your packing ... So, pack automatically replaces the zero? [@] Yes. So the zero initializes input but is getting replaced every time I put a new number in. [@] In fact I can replace this <> by setting numbers in here too. [@] Student: Could you hypothetically send the trigger also to the right inlet of pack and so whatever you are sending to that zero you're also just sending to the right inlet? ...You know how you're getting 40,200 plus a thousand... [@] You mean make a thing that has this number twice? [@] Student: Yes. You can do that but you can also do it wrong, like this: [@] (This won't sound good but I'll do it just for the sake of the argument.) [@] I do that and I'll put a number in here and I get the correct value and whatever the previous correct value was. [@] So now we have one of these situations where if you put a message in here that generates output and then if you put a message in there it updates the inlet. [@] But you want to update the inlet first so that that value will be there when the outlet comes. [@] Student: I forgot about that ... [@] Right, and to do that you need another trigger object. [@] Student: If you put another parameter in there as well will that create another inlet, so that you can control that, too? [@] Yes, and I think line~ doesn't care about that: [@] I'll give it another value. ... [@] Oh, let's not do this anymore. <> [sound] [@] Right now it's making messages with three values. [@] The thing about that is that there aren't very many objects running on Pd that can meaningfully deal with three numbers at a time. [@] They are all designed to be as elemental or as elementary -- as atomic as they can be. [@] In general, when you are just using objects and forming messages for them pack with two numbers is all you're going to need. [@] However, when you make instruments yourselves that might have 100 parameters in them to describe a voice, you might find yourself packing all those 100 parameters into a big mondo message. [@] Eventually it's going to be interesting to be able to use pack with large numbers or at least medium sized numbers of parameters. [@] Student: If that's the case would you use Pd window, that hidden window to do that and just have those with you? [@] Yeah, by that point you would be keeping everything under the hood. Yeah, in a big way. [@] And we'll get there but maybe not even in the first quarter of this. [@] ... Other questions? [@] If everyone is happy with this... I can't believe you actually all understand what is going on. [@] Student: ... wouldn't say "all" ... [@] OK, well my plans for the rest of the day are to make this more complicated. [@] Because of course, it would be useful to be able to do things like actually control the transposition. [@] When you buy a sampler you sample something and then you hit C and you hear the original thing so you hit G and you want to hear it in transposed to fifth and that sort of thing, So I want to talk about transposition and how to do it. [@] Now the other thing which is perhaps, even more fundamentally important, is how to keep it from [sounds] making those clicks. [@] And there are several ways of doing that. [@] I want to show you two of them. [@] What I think I should do is start with the transposition. [@] The sounds will still be kind of revolting but at least you'll see how it's possible to transpose stuff. [@] Then after that I'll start in on trying to work on the clicks. [@] Alright. [@] Transposition stuff. [@] Transposition: It's not so easy to necessarily hear how much this is being transposed by because you might not know what the original... [@] Does everyone know what transposition is? [@] That's a musical term. [@] That means the change in pitch that you get when you read out the sampler, compared to what you put into it. [@] At least that's what it means in sampler land. [@] What I am going to do is get rid of this because we are not going to get here so fast, but I''m going to put that in a future window. <> [@] What this is that we will come back to is using a phasor object to drive a sampler. [@] Which, you in fact saw for the first time on Tuesday but I haven't shown you for instance how to do things like affect the transposition in this way of doing sampling. [@] So we've seen two ways of operating samplers in the same way as we have seen two ways of reading sequences back. [@] One of which is this way, which is the signaling way which is generated, as I mentioned, well, which if you look all the way over to the top of the network here, you'll typically see a phasor~ object. [@] The other way of doing it is to just use messages. [@] In which case, you can do things in more irregular ways. [@] But there is sometimes more to think about when you're doing the messages that just doing phasors. [@] So this, which is maybe even conceptually simpler, I'm going to get rid of and go back to the more complicated thing. [@] Meanwhile, let's see. [@] I'll just set a good example by putting a high pass filter there and this, we might need this later. [@] So what we're going to do to start with is just listen to a nice sample: [tone] . [@] It's just me saying "Oh" because I can't sing. [@] This is about G [plays G on piano], just by accident. [@] OK, so that's what's in this file. [@] And now what I want to do is say "OK, that was a nice G, but I want to hear an A." [plays A on piano]. All right. [@] Question: How do you get from G to A? [@] Well, you transpose. [@] How do you transpose? [@] OK, choice! So we know basically how to transpose. [@] We know that rather than do this, we should do this <> : [tone] [@] We should do it in approximately 12 percent less than this; it's going to be 1850-ish. [tone] . [@] No! Bad, bad, bad, bad, bad. [@] I'm trying to do math in my head and not doing it well. [tone pairs] [@] There is maybe a major second for you; it's not really exact. [@] A major second, OK, you learn this in acoustics, a minor second is six percent. [@] It's actually 1.059 to 1. (That's the twelfth root of 2, which I use every day.) [laughter] [@] And what I was trying to do here was divide by (the square of the twelfth root of two), which I didn't quite get. [@] I finally just did it by ear. [@] So here's the original sound [tone] -- That's G. [@] This one, if I did it right, would be an A. [tone] Sorry about the bad singing. [@] So what's happening is I could have changed this value of 100,000. I could, say, just go, whatever, 12 percent further than 100,000 in that amount of time. [@] But then when I started making extreme transformations down I might not get to the end of the table and so I might not like that so much. [@] So instead, it's easier to, say, go to a place that I know is beyond the end of the table. [@] In fact, when I'm doing this for myself, I usually take this into millions so that it's beyond any table that I would be likely to use. [@] And then, compute the amount of time that you really should do that in in milliseconds. [@] There are a couple of ways you could do that. [@] I could either do this explicitly with logarithms. [@] Or I could do it the less brainy way, which is I could reach for mtof and operate that way. [@] So I'll do that because that's easier to think about. [@] Or rather, I don't know, I find this easier to think about. [@] Maybe you will, too. [@] So here is how you do this: [@] So mtof "midi to frequency" is a thing which allows you to take a number, which is a frequency ... -- This is a number in MIDI and it converts it into a frequency. [@] So for instance, if I feed it 60, I find the number of hertz in middle C. [@] If I feed it 61, I'll be six percent faster, and so on like that. [@] And now I'm realizing -- I'm trying to be as simple as possible. [@] So I'm going to go back on my earlier promise to do this correctly in order to do it more simply in the following way: [@] So what I'm going to do is say, "OK, we're going to go to 100,000 in 2268 milliseconds, all right. ..." [@] Except that my value of 100,000 is going to be different. [@] I want to fix it so that when I say 60, it will be 100,000 all right. [@] But if I say 61, it will be six percent more and so on like that. [@] How do I do that? Well, it's easy. [@] I just change 261.6... whatever it is to 100,000. To do that -- it's a rescaling -- a simple-minded way of doing it is just divide by what it was and multiply it by what you want it to be. [@] This is the other number I use every day, the number of hertz in middle C. [@] And then you can multiply by 100,000. [@] And then, I'm going to, why don't I set a good example and leave this network here. <> [@] All right, so I'm going to reach for this trigger. [@] This trigger gives me a value, which goes here. [@] And then it gives me the... [@] I'm going to stick this in here. [@] And what I want it to do is I want it to say zero. [@] And then I want it to say this value packed with the amount of time which is 2268. [@] So, lose all this. [@] I think I want the print object still. ... [@] x Let's see, what's a good... [@] And here I just want a bang <>. Don't need this anymore. [@] So, in fact, it would be better if I put all this in one place. There. [@] So, when I get a bang, I want to go to the value zero -- that's the beginning of the table. [@] And then afterward I'm going to pack the amount of time, which will replace zero with the wonderful amount of time, 2268, this is all well and ... now, G: [@] [tone; and tones at various successive keys] [laughter] [@] Student: I'm lost. I'm lost with the bang. I got how you're setting and transposing, but why the bang? [@] OK, let me answer that first, because that's specific, and then I'll try to answer. [@] "I'm lost," which is more general. [@] So, the specific question is, why would you put a bang on here, and float out here. [@] OK, so this is a message box, which will put out 0, no matter what goes in. [@] So, in fact, I could have put in a bang, or a floating point number, or a list of numbers -- or anything -- and out would have come the message "0". [@] I put bang here as a matter of style, because I didn't want to put float, because it was just going to be ignored anyway. [@] And so, it was simpler to think of it just as being bang. [@] So, bang is just a message that doesn't have any numerical value associated with it. [@] It's the equivalent of the keyword "void" in C. [@] So, what happens is, whenever I say a number here, [tones] sorry... [@] Whenever I say a number here, stuff happens. (Which is why I should print this number out. I should display this for you, so you can enjoy it.) [@] 60 again. Sorry. And the width will be seven, it might be a big number. [@] Tada. Ooh. Truncation error. You won't hear that. [@] So, stuff happens, and this number comes out -- 100,000 -- which is the number of samples ... which is the number I want to put here. [@] Oh, yes. [@] Right, I need my print object again. [@] So, now, this print object is showing us exactly what's happening to the line~. Let's get rid of all of this. [@] We've got this in the previous patch; it's not doing anything right now. [@] So, 60 went in here, and it got converted, it got turned into 100,000 and then trigger says "first, send a bang to here," which outputs the message zero, which causes line~ to jump to zero, which causes tabread~ to read the first element. [@] Then, this gets the number 100,000 because I asked for a floating point number, which is just a number. [@] So, this is now the message 100002 (sorry about the two), and then we pack that with 2268, and so then what we see is the message, which is "100000 2268" . So this pair of messages got printed out, I think. [@] Oh, I see. Maybe I don't... Maybe I connected the print afterward. [@] So... It gets two messages: [@] It's "0," and then "100000 2268". [@] Student: So basically, this time, we're transposing by... instead of changing the amount of seconds it takes with the line~ object, by changing the amount of samples? [@] And the reason I did that, was because it made the math simpler, not because it made the patch better. ... Yeah? [@] Student: Is there a samples per second, kind of like, M2F kind of thing? You just kind of bypass the math? [@] No. No, there isn't. [@] Basically, there are no primitives that would make this easier, although I could tell you how to make it a little bit more complicated. [@] So, now there are two things to understand, I guess: [@] One is, the bit that, this bit here, the stuff that's actually making the sound, which is to say sequencing two messages for the line~, and making the sampler read. [@] The other thing to understand is how on earth I'm computing this value. [@] So this is the value that you have to stick here, in order to get the right transposition. [@] And now, to answer your question a little bit better, I want this value to be proportional to this value, and not in proportion to its inverse. [@] I didn't want to have to divide by something. [@] It could, bxsut it would be more work. [@] Student: How do you get the 100,002 again? [@] Well, it got it for me. [@] What I did was I said I want 60 to go to 100,000. So, this is... [@] So, now what you're asking is what is the design of this collection of objects. [@] There really are only three objects here that are doing stuff. [@] There's the midi-to-frequency <> and then there's a rescaling, which is these two objects: [@] We divide by the number of Hertz in middle C, and we multiply by 100000. So, what is happening here is we know that these numbers coming up have the correct proportions, so that we can do musical scales or musical intervals. [@] Why, because mtof, if I, for instance, add 12 to the value here. [tones] [@] <<12 steps for octave, doubles frequency>> [@] It multiplies its result by two. [@] So mtof is the thing which takes 12 steps and turns it into "multiplied by two" in Hertz." [@] Or, if you like, it takes the keys of a piano and converts them to Hertz. [@] So that you move up 12 keys on the piano and it doubles the value. [@] Now that we have the ability to do that... [@] And that's just this object which does the math for us that does that. [@] It's not so bad, it's -- I can tell you the expression. [@] It's just an exponentiation, except it's scaled correctly. [@] Then, what we say is "OK, I want those proportions. [@] That's to say I want 72 to be twice what 60 is. [@] I want 48 to be a half of what 60 is," and so on like that. [@] But, anyway, I want 60 to give me 100,000. So how do I do that? [@] I just have to multiply by the number, which is 100,000 over 261.62. Well, that's kind of... [@] Ah, what's the right word? [@] I could do that. [@] I could divide 100,000 by 261.62; but I've found it more pedagogically transparent, hopefully, to use two objects so that I divide by 261.62 to get a transposition. [@] And then multiply by this because I want a transposition of 1 to give me a value of 100,000. [@] So, in fact, I should have been showing you two numbers. [@] First off, this number is the interval from 60. So if I get 60... [tone] I .. get 1.0 there. [@] If I really did it right. -- [@] I think this is 261.626. Those two's are getting my goat. [tone] [@] This is as close as I'll get -- Now we're within a part per million or so. [@] A couple parts per million. [@] So we divide by 261.626. That's just so that 60 gives us 1. And, by the way, now we're in floating point land. [@] You're never going to represent this value exactly. [@] It's irrational anyway. [@] So instead, we just get as close as we can in floating point land to it. [@] So now 60 goes to 1. So 72 will go to 2, for instance.[tone]; 84 would go to 4; 96 would go to 8; And so on, like that. 48 goes to a half. [@] And then harder values. [@] There was 60 again, which goes to 1. [@] Go up a fifth and you go to 67, which is MIDI for G above Middle C, and that turns into roughly 1.5 [tone] [@] ...because seven semitones is roughly a factor, a multiple of 1.5 to 1 -- but not exactly. [laughter] ... Yeah?? [@] Student: If you go too low, though, it's going to start flipping like this. You don't have enough samples? [@] Well, it'll just stop after two seconds, even if it doesn't get to the end of the sample. [@] So if I say, yeah, do 24. [tone] Stops after two seconds. Oh! It stops at... [@] Student: While you heard it, it was like tut-tut-tut-tut-tut... [@] Right. This is now - what is that? [@] Three octaves below Middle C? [@] So I was droning along at 100 Hertz, and you divide that by eight and you get about 12, which is an audible rate. [sound playing] [@] Maybe that's 12 Hertz-ish. [@] Oh, and so that's one-eighth transposition, down by a factor of eight. [@] And an eighth of 100,000 is this number, which is the amount we go in the table, which only gets us to about here. [@] Somewhere in there. [@] And it takes that 2.2 seconds to do it, but it originally it would have taken 100,000 samples. [@] Student: So it's not playing the whole clip? It's only playing a portion of the clip? [@] ... Yeah. [@] Student: So you're not really transposing. Transposing would be playing the whole thing, but in a different key or in a different frequency. [@] ... Yeah. So it's transposing it, but then it's cutting the transposition off after two seconds. [@] Student: So if you would have to ... [@] ... Yeah. I could have done it the other way, which is I could have said, "Go to the end of the table and compute the amount of time that you do." [@] But then I would have had to divide by this number, which would have been an extra trigger object. [@] I didn't want to make it any more complicated than it already is. ... [@] ... Yeah?? [@] Student: When you're multiplying by 100,000, what is that number representing an amount of? So that's the number of samples at... [@] If you were at unit transposition -- that's to say, if you were playing the original sound back -- that is the number of samples that you would play in 2,268 milliseconds. [@] So the value of 100,000 is, in fact, arbitrary. [@] I chose that in some other context two days ago, and now I'm just sticking with that value because I happen to know that 100,000 samples at 44 Kilohertz corresponds to this number of milliseconds. [@] Student: Which is a little more than two seconds. [@] A bit over, yeah. [@] Somewhat over two seconds. [@] Student: Can you review tabread4~? [@] ... Yeah, OK. [@] So tabread4~ is a... [@] Let's see, so it's doing a read into the array whose name is t1.27a, which is over here. [@] And what goes in are the x-values, that's to say where you want to be in the array. [@] And it is in samples. [@] And what comes out is just what value is in the array there, which is the vertical axis in this graph. ... [@] ... Yeah?? [@] Student: Is it possible to do a transposition without the time stretch? [@] Well, yeah. It's more work. [@] But, actually, you all ready sort of heard it because what I showed you in the previous patch, I was able to do little bits of samples in the table, you heard it going backwards and forwards, but it was ugly. [@] So, to do that and make it pretty is actually hard. [@] We might get there in a couple weeks or we might not, depending on whether it turns out to be a good use of our time. [@] I'm not sure. ... Yeah? [@] Student: Are there cases where you want to use tabread~ rather than tabread4~ ? [@] Yes. The best example I know of is back in sequencer land. [@] I think we're go here ... "5.table.pitch" -- this one. [@] Sampler![tone] . [@] Now let's make this use tabread4~ four [tones] <> . [@] Well, you could want that, but if you want it to sound like a classic synthesizer you really want tabread~. [@] So, tabread4~ on the other hand, that's what you want to use if you want a clean audio sound of reading a sample out. [@] Student: What is the "hip~ 3" object in the patch? [@] "hip~" Yeah. -- "high pass filter." [@] Let me show you, now that I'm in this context, one place where it's really good to have this. [@] One thing that you can do is run off the end of the table, so let's go back to playing the original position [tone] . Now I have a rather bad thing because, if I disconnect this- you hear that click? [@] Actually, I could make that worse. [@] What's the first sample of the table? [@] There it is. [@] It's not that much worse. [@] The reason that you hear that click is because tabread~ is constantly giving me the last value in the table. [@] So, the line~, is giving me a 100,000 right now. [@] Let's just verify this. [@] We need a bang for this. [@] So, look at that. [@] We have a 100,000 (1 X 10^5) coming out of the line. [@] That's appropriate because I asked it to go there in 2268 milliseconds. [@] Then we say tabread4~ and it says "OK. [@] That's fine", and I'm going to give you 0.03... blah, blah, blah -- this amount. ( [@] That's the value of the table in it's location that corresponds to 99,999, which is the last point on the table.) [@] And that, when you disconnect it or connect it, sounds like a click because it goes between that and zero. [@] So, how do we get rid of this? [@] We say "hip~ 3". The "3" is just a good number which is well under 20 -- which is the bottom limit of human hearing, luckily. [@] Print tilde here said these numbers, and then if I talk to hit tilde I get these numbers which are much, much smaller. [@] They're down to truncation error. [@] It might even be turning into a zero? [@] ... No, it won't go below that. [@] So, the high pass filter essentially cleaned up the DC value, the constant value of .03 that we had before, as a result of which, I can now disconnect it and connect it without hearing it. [@] Although I haven't told you about hip~ I systematically put a 3 Hertz, high pass filter in front of the digital to analog converter and before and after the analog to digital converter, every time I make a patch it's going to deal with audio. [@] If my patch is going to drive a DC motor I don't do it, but that doesn't happen very often. [@] Almost always I have "hip~ 3" somewhere in the signal path. [@] Student: I was going to ask what the "3" coresponded to, but it's 3 Hertz? [@] It's three Hertz. [@] What that means is it's way below 20 hertz, so far below 20 hertz that by the time 20 hertz happens, we're so far away from the filter's roll off that it's not transmitting a signal. [@] Engineers use values up to about 10 for that. [@] It's a low cut-off. [@] Student: But if we can't hear it, then what's the point of it? [@] Well, a point of it is if I had a bunch of these voices, and they were all stopped in the same way, but if their outputs all added up to something more than one-- not only would I not hear anything, but even if I played a sound out in some other part of the patch, I wouldn't hear it because everything would be above the output max of the digital-to-analog converter. [@] Here's a thing you might not want to do-- it's good review. [@] Can we get a toggle and then make a metronome? [@] Sorry about this: [@] I'm going to make something that will annoy you. [@] Out will come MIDI 60 [tone] , twice a second. [@] Now that's really annoying -- We're not going to do that. [@] Oh, and we don't need this print anymore. [beat track sound] OK? [@] So, we know what's coming out of this thing.[laughter] [@] Now what I'm going to do is show you how to make it hurt. [@] I'm going to do another one of these. [@] I'm not going to even remember to connect anything to it, but I'm going to connect it with a bad volume. [@] Now I'm going to start annoying you again. [tones] [@] That is the sound of my sample getting shoved up against the very top of the possible output range of my converter hardware. [@] It's always called distortion, but sometimes this is called a bias. [@] This is a knob on your expensive guitar amplifier, expensive tube amp. [@] It does that to the guitar sound. [@] Student: How does that relate to the high pass frequency filter? [@] Oh, OK. So, I might have done this by accident, somehow, but if, [tones] on the other hand, I had a high-pass filter there, then I can give this as much bias as I want, and it filters it out. [@] It's gone, so I can still hear this thing going. [@] What happened there was this thing is putting out 0.06 V. [@] So, this is now putting out 60 V, too much for my hardware. [@] But this <> is taking the DC out of it, which is therefore returning it to zero, because everything that's happening here is DC. [@] It's flat-lined; it's not changing with time. [@] Student: When you're increasing the bias, is the speaker cone also going out towards its maximum travel? [@] It should be, except that I have faith in the cheapness of the mixing hardware that we have here, and it's almost certainly AC coupled. [@] So that, in fact, there is an implied hip~ somewhere in the hardware. [@] Student: OK. [@] Otherwise I could actually literally push the speaker out its cone. [@] Well, probably the amplifier wouldn't allow me to do that anyway, but it would be bad because DC speakers' resistance goes down, and so you can actually burn your speaker out if it would actually send that voltage to the speakers. [@] I have long experience with this brand of mixer because I'm cheap too. [@] I know that it won't actually do that to me, neither will your home stereo. [@] It's more expensive to build DC-coupled stuff. ... [@] ... Yeah?? [@] Student: Is it possible to write your own objects, like the mtof? ... Someone was saying before about the samples-to-frequency, because that's just a simple conversion? [@] Sure. Yeah; it's just an arithmetic expression. [@] You could just make an object that does it. [@] That is the subject, or a subject among others, of Tom Erbe's seminar that he gives in the Fall on Programming for Musical Applications. [@] Although, you can just sort of learn how to do it. [@] Just go find a Pd object that someone's written, see how it's done by example, and just go from there. [@] There are some thousands of them on the web. ... [@] Any questions? [@] So, what happened was two things that were kind of jumbled together. [@] One is this high-pass filtering notion, which is a good way of dealing with DC offset problems in signals -- Which will come in. ( [@] This is one good way of making yourself a DC offset without wanting to-- having a sampler and just have it stuck in a location in the sample; but there are many others.) [@] In particular, if I, for instance, just say "Give me an oscillator," it now has a phase of zero because it starts at the top of the cycle. [@] It's putting out "1" constantly. [@] If I put that out my dac~, that will mess up the sound of the rest of the patch. [@] Frequency modulation and wave shaping-- I've shown you frequency modulation, although I need to show it to you again more controllably-- they have a tendency to have DC as part of their spectrum. [@] It's not the only thing they put out, but they will put out some DC as well as everything else. [@] As a result, if you are playing them, you probably want to put one of these things <> in the chain somewhere. [@] So that's this object and then the other thing was this way of talking about transposition of samples. [@] Done in a way that hopefully is as simple as possible which is to say that you first get yourself from pitch to frequency and then correct. [@] So that its in the range that you want which is 100,000 corresponds to no transposition. [@] And the reason I've decided that 60 should correspond to no transposition is just because that's a habit: [@] Middle C by default is no transposition on a sample. [@] And 60 is the MIDI value for Middle C. [@] Questions about this? [@] ... Yeah? [@] Student: Is there a way to change the slope of the filter. [@] In this particular filter is the most simple minded well second most simple minded filter in the world and the only thing you can change is the cut-off point. [@] It always has a 3 dB per octave roll off. [@] So it's the cheapest, simplest possible low cut filter you can get. [@] You can get better ones but then you land in a region where there are actually thousands of designs of filters. [@] There are at least dozens of them available in Pd. [@] And you would have to spend some time figuring out what characteristics you wanted. [@] I wouldn't be able to just give you a quick answer. [@] Other questions about that? [@] So what I want to do now is first off mention that of course this was playing the entire sample but you can play bits of samples as well. [@] And what I should do is start another window showing you an example of playing a bit of a sample. [@] That will be interesting because it will make it much much more important to be able to control the clicks that naturally happen at the beginnings and ends of samples. [@] So that should be kind of the next thing to worry about. [@] So what I'm going to do is save as, going to hang on to this thing. [@] And I thought it was before that but, four. <> [@] I won't get this far but I'll start it anyway to do enveloping the sampl. [@] The first thing I want to do is say, OK rather than making 100,000 I want to make ... no, lets do 10,000 points. [@] And lets do it in this amount of time. [@] See how this sounds. [tones] Pretty good. [@] I should say here that this is not a good practice. [@] I'm taking a very short amount of time here and time is quantized. [@] Rather I should say line~ has a quantization in its actions which is 64 samples. [@] So this is not a terribly accurate way to make a sampler because this will be quantized to about 1 1/2 which would be noticeably out of tune if we're actually being careful about it. [@] So this is just going to be a bad example right now because I just want to show you an envelope. [@] That is that: [@] The problem is that it clicks every time you use it. [@] And we would like it not to do that. [@] So how do we deal with that? [@] In the usual obvious way, you multiply it by a line~. And the thing that you multiply by is the output of a tabread4~. [@] Student: I thought you were high pass filtering that? [@] Oh I am high pass filtering that but I'm changing the value I put into to the high filter which gets us to the step function which we still hear -- although then it takes it out. [@] Anyway, let's get rid of this and let's multiply it by a line~. And now there will be two line~'s running around. [@] And so there will be plenty of opportunity to get confused. [@] The first one, let's see ... [@] ... This one now what were going to do is were going to say you are at 0 please and lets go up to a value of 1 and do it in a certain amount of time. [@] Which will be 50 milliseconds. [@] And then after a certain delay we can turn it back off. [@] And now I get something which allows me to put values in here: [@] Whoa?! What did I just do... [@] I didn't want it to do that -- Send this to zero: [tones] Ah, no clicks! [@] So before it was this [tones] and after is this [tones]. All right. [@] Now who can tell me why this will stop working, the next thing I do? [@] I'm going to do scroll on this thing and it's going to make my clicks after all. [@] Anyway. And why does that happen? [@] Student: You're going faster than the delay? [@] ... Yeah. I'm not waiting for this, I'm not waiting for the end of a note before I start another one. [@] So let me back up, and carefully explain what's happening. [@] What's happening is, we're starting the tabread~ and we're giving it two messages which tell it to jump to a point and then to slide to another point. [@] At the same time we're doing that, we're muting this line: [@] We're making it jump to 0; and then we're ramping it up to 1 in 50 milliseconds. [@] And then, a 100 milliseconds later, we ramp it back down to zero. [@] So that it's safely back down, before the end of this segment. [@] So the thing goes up. [@] It sits there at it's apex for 50 milliseconds because we started it but then a 100 milliseconds later, we started sending it back down. [@] But meanwhile, if I don't wait that whole 150 milliseconds before I send another message. [modulating sounds] [@] It will bash the value zero discontinuously, and that will sound like a click. [@] So, actually, it's a little harder than this. [@] What you really should do is ... What you really should do - I'm thinking of a simple way to explain this. [@] First off, what we have to do is remember the value we want. [@] Because we are not going to be able to use it immediately. [@] So we're going to take the value and stick it in a nice F-box. [@] Like this. [@] That's step one. [@] At the same time as that, we will mute the value of the line~. What that means is that we will send it down to zero, and do it very quickly. [@] And now I will go ahead and do bad style and just send the floating point number straight into the message box. [@] Then we will start a delay of five milliseconds. [@] After which, we do the rest of it using the floating point value. [@] Like that. [@] Now I have to clean this up. [@] I don't think we need that zero anymore, because we already did that. [@] So now, what's happening? [@] You know what? [@] Let me make it a little bit better style and put it back in. [@] So that you can see it all in order. [@] So, first thing, first step is to mute the thing. [@] So whatever is happening when I ask it to play a new voice it doesn't do anything except mute the old one. [@] Because it might be playing something and the new one is going to start at zero. [@] And if we don't then ramp it to zero, we're going to hear a click because it will jump to zero. [@] So, we spend five milliseconds covering up for ourselves by muting whatever was happening previously. [@] And then; and by the way, the next thing to do is take the floating point number and store it because five milliseconds later, we're going to need it. [@] And five milliseconds later -- "del" is short for delay -- five milliseconds later we will get the value out of the float and then we will do the previous thing, which is bang this to turn the line on and do all this choreography for this line. [@] Now if we do that we have: [sound notes changing without clicks] [@] Not perfect, but it's at least decreased. [@] Now let me move this down so you can actually see where the lines are going. [@] So, this is now an almost complete and almost acceptable sampler. [@] In the sense that I can throw pitches at it and it will play samples back. [sound of sample] [@] And this is... ... Yeah? [@] Student: In your "trigger bang float bang" is the float doing anything, or...? [@] Yeah. This float corresponds to this outlet, and it is being remembered. ... [@] So the "float" object - I think this showed up last Tuesday. -- [@] This is an object which remembers values and then when you give a bang which, the delay will put out, it restores the value. [@] There are other ways to cause a number to get delayed. [@] But in general, when you want to do something after a certain amount of time and have the thing that you had before, you have to store it. [@] So this is maybe conceptually the simplest way of doing it. [@] Now the next thing that you might want to do is: [@] gee we got a sampler, let's make it a 100 voice polyphonic. [@] So lets just copy and paste this thing a hundred times? [@] .... No, you want to do something different. [@] So that's coming. [@] But actually I think what's going to have to happen next time is more careful talk about envelopes, and pitches, and transpositions, and stuff like that. [@] Because I'm sure there are a whole lot of misconceptions to clear up. [@] So this is using line~ and messages, as opposed to using a phasor to look through a sampler. [@] I didn't even show you how to de-clicks sampler that are operating from phasors. [@] There's a totally different strategy for doing that. [@] *** MUS171 #09 02 01 (Lecture 09) [@] What I'm going to try to do today is push on through designing samplers -- both from the point of view of having them message-activated and the point of view of having them run from phasors. [@] What happened last time -- which might be worth a quick review is: [@] a sampler which is able to make samples with a desired transposition and a desired size of place in the sample that you're going to play back, driven from messages -- in such a way that you can do things like start notes. ( [@] You can regard samples to be things that can play notes.) [@] And I just grabbed a copy of that patch. [@] Oh, this is the patch after I edited it to put it up on the website. [@] So this is a bit cleaner than what you saw in class. <> [@] But this is pretty much where we got. [@] The situation was this: There's a tabread4~, which is playing the sound, [@] and the sounds are being turned on -- not by a phasor object ... [@] In other words the control, the impetus of the patch isn't coming from tilde objects -- from objects that make streaming samples -- but from messages. [@] And in this case, there's a metronome, which is spitting out copies of some pitch. [tone] [@] There you go. [tone] [@] Let's turn that off. [@] Oh, this is now going to be the pitch of the thing. [@] Did you hear it? [tone] [@] So what's happening is, there's a metronome twice a second, a number is coming out. [@] Oh right, number boxes: [@] If you send a number box a bang, such as comes out of the metronome it simply outputs what the number was. [@] So also I can also output it just by mousing on the number box itself. [tone] [@] And there was work to do, which I always review for you if you are curious about it. [@] But for the moment the idea was to figure out how far you were going to go in a fixed amount of time. [@] And so what happens to the tabread4~, is it eventually sends a message to tell it to go somewhere in a certain amount of time. [@] The time is computed to be the number of seconds you want to go 100,000 samples in. <>. So I just got out a calculator and found that out. [@] There was this number <<2268>> of milliseconds. [@] And now so if you gave it 100,000 that would mean you were playing the thing back in its own speed. [@] And then also we could compute other speeds and get intervals from that. [@] And then it got all Music 170-ish, trying to figure out what numbers to throw in there. [@] ... Questions about that? [@] Student: How do you select the part of the audio to output? [@] Oh. Right. Like I didn't say that, in fact. [@] How do you select what part of the audio? [@] Really, there are two messages going in -- which in fact perhaps I should print. [@] So, let's make a print object. [@] A regular message print object because all of this is being done with messages. [@] So, yeah. [@] Actually I'm just realizing, looking at it, that it's always starting from the beginning. [@] So here, we say 60. [tone] [@] And what comes out is first the message 0 and then the message "slide to 100,000 (approximately) in the correct amount of time."<<2268 milliseconds>> [@] And this is the only number in the pair of messages that will change when you ask it for a different pitch you will compute a different value of that. [@] So, in fact I have shown you other ways of making samplers, where you could go in and select where to hit play. [@] And you could easily adapt this to do that: [@] What you could do if you want to start somewhere other than 0 you would add whatever the number is to this 0. And you would also add it to this number here. [@] And then you would have a thing that had a controllable offset in the sample, right? [@] The other thing that's potentially confusing about this is that you don't hear an entire 2.-something second long sound. [@] When the thing happens you only hear something that lasts a few milliseconds. [tone] [@] And that's happening because the thing is being enveloped, so the signal processing network that you see really is: [@] this line is generating the addresses of the samples in this array here. [@] This line here is turning the thing on and off -- well, fading it and out -- it's being used as an "envelope generator," in classical synthesizer-speak. [@] So this is a thing, which starts at 0, ramps up. [@] Oh! I should print that for you too. [@] How about we do this? [@] This is going to be the, what do we call that, address. [@] And this is going to be the line controlling the envelope. [@] And the envelope ... This line~ which is doing the envelope is getting messages, here, here, and there. [@] So I should show you all three of those. [@] You won't actually see the timing but you will at least see the sequence. [@] I'll hit this again ...[tone] [@] Now go look at the Pd window ... And now what you have is: [@] -- Oh yeah, I didn't tell you but you can feed print an argument, ask it to say instead of "print:" "something:". So, the envelope generator is getting sent to 0. And then after five milliseconds of wait, of delay, it sets the address to 0 and the envelope generator starts ramping up. [@] The reason to have that delay is so that you don't hear the address get reset to 0. So what is happening is when you give it a number it doesn't actually start playing a new sample for five milliseconds. [@] Because it has to take care of whatever might have been happening before. [@] Then after another ... -- oh right so these three things, I'm not sure why they're in that order. [@] But at any rate these things should be roughly at the same time. [@] The address should be zeroed out and then should be ramped to a 100,000. And meanwhile the envelope generator should be turned back on at whatever speed. [@] At a speed which is controlled by whatever attack time you want. [@] And then after you're ready to end the note, which is some time in the future, you turn the envelope generator back off. [@] And the address is still ramping at that point. [@] It certainly is in this case, because it's only in a tenth of a second in. [@] But the fact that you multiply it by zero means that whatever is happening to the array, the tabread4~ is not being heard. [@] And so the thing is effectively turned off. [@] So again as with oscillators, if you want to turn something off, you don't actually turn the oscillator off in general. [@] But the better way to do it is to cut the amplitude off by multiplying by something that you ramp to 0. And so that's happening here with this line~. And now, what bothers me about this, I guess it's all right ... OK. [@] Are there questions about this. [@] I have to take the print object out because I think people are OK with it. [@] So there are two topics today. [@] And they take this thing in a different directions. -- [@] Each of which is an important direction, but this is the starting point. [@] But they don't actually have anything to do with each other. [@] The first one is, going back and showing how to make something similar but deriving it from the phasor~ object, in case you want to make a looping sampler that's driven from a signal. [@] And the second thing to show you is a more interesting and general thing, which is how to make polyphonic stuff in general: [@] That's to say, "Now I've got a nice voice of this, what would I do if I wanted to have eight of these?" [@] And be able to play a chord or what-not -- a sequence that might be polyphonic. [@] And what I want to do is, since it's simpler, is go over the phasor~ -driven thing first. [@] And then that should be easy but then the polyphonic voice allocation could be hard. [@] So that can come afterward. [@] So, I can close this and move on to the next thing? [@] This is from last week. <> ... OK, there are things that I haven't done here ... This is stolen from a patch that you saw sometime last week, I think. [@] And this is the way of reading from a tabread4~ if -- instead of having a line~ generate entities into it (that is to say locations or addresses) -- you want to use a phasor~ to drive it. [@] Now, line~ will go from anything to anything depending on what messages you send it, but phasor~ goes always from 0 to 1 -- It's just a phase generator and phase is considered in cycles. [@] So, with phasor~ you'll then have to take it and renormalize its output to reach where it is that you want it to go. [@] so here is the... [@] let's see, we get the table now, so stupid of me to close that other one ... Oh, still there. [@] So you don't have the... [@] this is what happens when you move a patch from one directory to another that uses other files. ... [@] The other thing that's wrong is that I made it bigger in order to put it on the web, now it won't fit on my screen anymore. [@] So what I have to do is go copy this thing. [@] Now, do I have the other window? [@] I just wanted to get this thing to read. [@] Actually that's OK. [@] I'm going to get it along with this stuff which might be using. [@] I'm going to close that and get over here where we're actually working and put that down, get it out of the way. [@] All right! ... So, now we're back where we were before. [@] In fact I am going to get properties out here ... well I'm going to do that later ... so this has a bad name -- but we'll live. [@] So, this now is a thing where you tell it how many per second you want, so 5 per second maybe, and then you tell it how big a sample you want it to read in that amount of time. [@] Let's see, it's in hundreds of samples, so I'm going to ask it to read a whole second's worth. << [@] 441 X 100 = 44,100 samples>> Oh, so this is one per second then. [@] Now we listen to this:[tone] [@] So this is just a looping sampler, but it's a looping sampler that doesn't have a metronome that has to generate messages to make it start up. [@] Instead it's a looping sampler that loops just because phasor~ likes to loop. [@] Here, again, you could wish to fix the problem that whenever it loops it has a discontinuity in the sound. [@] So to emphasize that discontinuity let me make the thing go faster and have less. [@] That would be 882 [tone] ... Woah!? 88.2 [@] Looking for a bad click. ... Can't hear the clicks in there. [@] There is a click, but it's getting lost in the sound. [@] Maybe if I make it shorter it'll be more obvious? I'm not sure. [@] Oh -- There we go! OK, this is a bad setting because I think I put it right where it was breathing in. [@] But if you start moving around the sample maybe ... [tone] [@] I'm trying to find something that has a useful sound and has a click; I'm not succeeding. ... [@] There we go!x All right. [@] So there's a nice sample. [@] This would be a nice thing to be able to have, but it would be nice to be able to have it without the clicks. [@] The clicks, by the way ... If we go faster than 30 a second they won't sound like individual clicks, but they'll still be a part of the sound. [@] It'll just make the sound, sound buzzy, so now we've got a nice little buzz generator. [@] So this is a useful tool, but this would be more useful perhaps if it didn't sound buzzy. [@] That buzziness is the same issue as the fact that it was clicking when it was going slower. [@] Is it clear what I'm doing? [@] I don't think I gave you this particular collection of window size and speed before ... But what's happening is this number here is being added to the output of the phasor that's already been ranged. [@] So when I'm changing this value I'm changing where in the table it is. [@] Meanwhile, this portion of it is doing nothing but generating a ramp that is repeating at 76 times per second, so that's controlling the pitch that you hear. [@] This is controlling how much of the sample you get. [@] A wonderful thing happens when you change that now. [tone] [@] That kind of stuff. [@] OK, now I'll explain a little bit better why that sounds like that later. [@] You can sort of explain that, although it takes a little bit of work. [@] So let me go back down to a reasonable speed, perhaps 10 a second. [@] At this point I can find the place where it makes it click. Nice. Diesel motor. [@] Anyway, there's a click and now I'm going to try to get rid of it. [@] The way you're going to get rid of it is you're going to envelope, but it's not going to be easy to envelope this using the line~ because you don't have a source of messages that will tell line~ to do its thing. [@] With some work you could do it and if you really wanted to you would use the "threshold~" object to try to get a message out when this phasor~ crossed a certain threshold, but you'd have to figure out where in the phasor you'd want to start doing the thing and so on. [@] It would be a lot of work. [@] So less work is just to do the smart signal based thing. ... Yeah?? [@] Student: How does the 0 in "pack 0 50" get used to turn the volume on and off? [@] Oh, thank you. Yep -- This turns it on and off. [@] So this "pack 0 50" -- this 0 is getting overwritten by 1 or 0 depending on whether I turn this thing on or off. ( [@] That relies on the fact that the toggle switch or the toggle itself outputs numbers, which are 1 or 0 depending on whether it's on or off.) [@] OK. ... [@] ... Yeah?? [@] Student: Have you written comments for this patch as well? [@] Well, I write the comments when I put them up on the website. [@] So it happens afterward, except that last Tuesday never got commented. [@] But if you go looking on the website now you should be finding stuff like this. [@] But they're telegraphic comments. [@] What I'll do is I'll make a copy of this and fix it so you can see the before and after. [@] Oh, you know what? [@] This is the first of the objects I'll introduce for the day:< [@] > which is "Make a sub-window please." [@] Actually, I've already shown you this, but I'm going to be using it again today so I'll reintroduce it. [@] There we go. [@] Put it here here, All right. [@] Put it in a more decent place. [@] And by the way, here we have a sample. [@] So now we have a sub-patch, which has the sample in it so, you don't have to look at it, right? [@] Now, so what we're going to do is again, going to be to multiply the tabread4~ by something, which will make it not click. [@] The only difference is that the multiplication won't be by a line~ output. [@] It will have to be by something else. [@] And what? [@] Well, the answer is deceptively simple: [@] So, phasor ... Phasor is going from 0 to 1 and you want it to be 0 at the beginning. [@] And then you want to go up to some value like 1. And then you want to stay at 1 for a while, perhaps and then you want to go back down to 0. All right? [@] Well you could do that algebraically in a variety of different ways. [@] The simplest way to do it would be this: [@] So recall that if you just ... [@] Oh!-- Did I tell you about cos~? [@] I think I threatened to tell you about this, or I didn't, did I? [@] I should've. [@] If I told you about cos~, it would have been first week. [@] This is a thing which takes things from 0 to 1 and turns them into the cosine of 0 to 1. [@] In fact, at this point, it would be a good thing to have another table to just look at the output. [@] So what I'll do is put another table, an array. [@] It's going to be... [@] I don't know what, "scope"? [@] And it needs to have ... I don't know ... some samples in it. [@] I'll make it a tenth of a second. <<4410 samples>> [@] Let's see. Here we are. [@] And now, for instance if I look at what the phasor's putting out... [@] Let's see, OK. [@] Put a button in it so we can see it. [@] Phasor will be putting out 0 's until I give it a frequency. [@] Let's give it a frequency of 20 and then we'll see: [@] A sawtooth wave! -- And I made this thing be a tenth of a second long ... maybe that's a little bit not enough ... [@] Since I made this thing be 20 Hertz -- 20 cycles per second -- there are two cycles within one-tenth of a second. [@] It's all correct, right? [@] So now, if I just take the cosine of that... [pause] [@] I'll get that sort of thing. [@] And that's all right, except... [@] Oh, and its value is 1 at the beginning and end of the phasor. [@] So when the phasor amplitude is 0 or 1, the cosine puts out 1. Right. ... [@] ... Yeah?? [@] Student: It gives you the opposite of the phasor~? [@] Yeah. So now what you need to do is get it to put 0 out instead of 1. So you need to put it upside down. [@] So the way to do this is then to multiply it by -1/2 ... [@] You can't actually see the fact that it got multiplied by minus a half because you don't see that these points are now the 0-points of phase. [@] If I'd made it graph both the phasor~ and the cos~, you could see that. [@] Now that we've got that we can adjust it so that it goes down to 0 instead of going down to -1/2. We can do that by just adding point .5 ... [@] And then, tada! -- We've got a thing that starts at 0, ramps up to 1, and then ramps back down to 0. ... This takes a bit of thought to get figured out, so I should stop here and make sure everyone's with us. [@] Should I try to graph the phasor, too? [@] Why not? [@] What we'll do is let's put another array, but I'll put it in the previous graph. [@] I'll say this is going to be the same size. <> [@] OK, now we have two things getting shown in the same graph. [@] Now what I'm going to do is make two "tabwrite~" 's controlled by the same button so you can see both of them simultaneously. [@] I'm going to show you the phasor~ and the result. [@] So the phasor is going from 0 to 1 like this and then jumping back down to 0 and the cosine wave that I'm making is going through 0 when the phasor is at either end of its trajectory. [@] The original cosine was not suitable because it had two flaws. [@] One is it didn't stop at 0, it went all the way negative, and the second thing is it wasn't at its least value at the transition point of the phasor where you want the thing to be off. [@] This hits its maximum. [@] So the first step is to invert it by multiplying it by minus a half. [@] That gives you this. [@] Now we've got the thing hitting its minimum when the phasor changes phase from 1 to 0, so this is a good thing, but it's not at 0 anymore. [@] It's at -1/2 . So now we're going to add 1/2 and then instead of going from -1/2 to +1/2, it goes from 0 to 1. If you want to be fancier you could ask for the thing to have a different transition shape or have a different amount of time that it transitions from 0 to one instead of the entire half of the cycle that this one takes to transition from 0 to 1. But for right now I'm just going to do the simplest possible thing, which is just this. [@] So this is multiplying by -1/2 -- And then adding 1/2 gives you this. [@] This thing, the cosine ... This cosine is sometimes called a "raised cosine." [@] It has a name: [@] It's sometimes called the Hann Window and people use it also to multiply snippets of signal by before they take a Fourier transform of it in order to do either a frequency domain analysis of it or convolve it with something else or something like that. [@] So you will see this trick of taking a cosine wave and raising it so that it's tangent to the horizontal axis and then multiplying it by a signal in order to control how it acts at both ends of it -- [@] We'll see that again over the course of this and the next quarter. [@] So one cycle of this is called a Hann Window sometimes. <>. There's a cycle there. [@] What this patch is doing is doing them end to end. [@] So you can think of the patch not as just making continuous sound but also, if you like, as making a succession of Hann Windows -- a "pulse train" if you like -- which is pulsing every time the phasor cycles and the maximum pulse is in the middle of the cycle of the phasor. [@] ... Yeah?? [@] Student: So if you used that signal as an index to the table, it would read out at varying pitch? [@] If we use this to generate the index into the table that's exactly what would happen. [@] And that would be interesting. [@] I don't want to hear it right now, but that would be a thing to try. [@] The reason I'm doing this is so we can take the original sample output, the sound output, and multiply by this, in order to control its amplitude. [@] So instead of going into the tabread4~ to control the location that it's reading at, I'll take this thing and multiply it by the output. [@] Let's see. [@] I should get these two to have the same values. [@] This is 10. This is 14. This is 86. ... So here's the original one [sound] and here's the windowed one. [sound] [@] Now, you could either like this more or less. [@] This is not a thing that you have to do because this is right and the other thing's wrong. [@] It's just that this has a spectrum that more correctly imitates the spectrum or sound of the original sound that we had. [@] Whereas this [sound] has got more highs. [@] And you can like that, but it also has more distortion in some sense because you hear something that wasn't really present in the original sample. [@] 54] Any questions about this? [@] ... Yeah? [@] Student: Isn't it possible to just filter out the high frequency noise? [@] It is. Yeah, right. So that's another whole thing you could do. [@] Rather than take this thing and take the highs out by windowing it, you could also take the highs out by low-pass filtering it. [@] But you would also take the highs of the original sample out. [@] Whereas here, if the original sample has highs they'll still be there when you window it. ( [@] They'll be different in some way, but they'll still be there.) [@] ... Other questions? [@] So this, multiplication by this window -- I'm going to clean this up a little bit so you can see a little bit better what's happening; I'm going to make this not collide with itself -- So this is the same as that; what I added was this multiplier and that corresponds to the multiplying by the line~ in the other realization of the sampler. [@] It just had to be done differently because ...<> This line, which is the envelope generator which is controlling the other one... [@] This was feasible because I had a sequence of messages here generated by a metronome. [@] In the other one I didn't have the sequence of messages because it was generated by a phasor~, which is operating continuously -- it's an audio signal. [@] So I had to do something different. [@] This <> is perhaps more flexible, but at the same time it's more complicated and there are also some disadvantages to it. [@] In particular, these messages happen between audio samples. [@] In fact, they happen between blocks of audio samples. [@] So what really happens downstairs in Pd is that Pd grinds out 64 samples at a time in order to be efficient and these messages actually happen on the 64-sample boundaries. [@] Pd tries to hide this fact. [@] But at the same time what that means is you don't have sample-accuracy in when the tabread4~ actually started reading the sample. [@] So if you want that level of accuracy it's more appropriate, I think, to use the signal approach rather than this approach. [@] On the other hand, if you've got MIDI coming in to start things out you don't have that accuracy anyway and this is the better approach. [@] So they just both coexist and you have to get a sense of when to try one and when to try the other. [@] It's clear what the distinction is between those two? [@] So that's kind of done, this. [@] Now what I'm going to do, not to belabor this anymore because now I can launch a whole diatribe about how to make different window shapes and that can be a lot of fun, but that's for a little bit later on in the quarter I think. [@] But now I want to start working on polyphonic voice allocation so we can turn thiese thing into fun instruments that you can run and play chords. [@] So to do that the main tool is going to be the fact that you can put things in sub-patches with an interesting twist -- and this is all Pd lore as opposed to real computer knowledge ... [@] The twist is that in Pd you can ask it to have a patch loaded from a different file into a sub-window and if you do that then you can have multiple copies of the sub-window and when you edit one of them they will all be edited in a way that stays coherent. [@] This doesn't sound all that important yet because, obviously, you can make eight copies of something and if you want to change it you can just change it in all the eight copies, but it will become important as things become more complicated to be able to keep things coherent. [@] The way to do that is very simple in principle and then in the details it gets complicated, so first I'll show you the simplicity in principle and then I'll make everything unbearably complicated, for the next half hour. [@] What I'm going to do is save this. ... [@] I think, for pedagogical reasons, it would be smarter to start with the other flavor of sampler, which I already closed. [@] So this one: [@] <<"2.01/0.sampling. [@] envelope. [@] pd">> -- Except that I'm going to rebuild it for the most part. [@] But just for now ... It's called "0.sampling. [@] envelope" -- What we're going to do is make a new patch and then we're going to put an object in. [@] We're just going to say "0.sampling. [@] envelope" . Then, if I open this, I get my nice patch. [@] Furthermore, if I ask for several of these, I have copies of zero <<"0.sampling.envelope">>. [@] (Notice I'm getting all sorts of errors because I'm doing things that I shouldn't do.) [@] Things that are named -- You shouldn't have copies of that have the same name because how do you distinguish it? [@] So that's basically it -- I mean, that's how you cause a patch to load other patches. [@] Now if I wanted a five- or eight-voice sampler I would load eight of these things and then I would do the hard part, which is figuring out how to get messages into them appropriately to do what it is I wanted to do. [@] So if someone says "Play three notes" I don't want it to tell the same voice to play all three notes. [@] I want to choose three of the voices and assign one note to each of those voices. [@] Then I have to have them be able not to be mixed up about which one is doing what. [@] That takes bookkeeping and attention to detail, which I will now show you how to deal with. [@] Questions on what I've done so far? [@] ... Yeah? [@] Student: With the sub-patch, if you want to re-edit it after you make it is that a problem? [@] It's OK, but here's the thing: [@] I can edit this and it won't have been edited in the other one until I hit "save" in this one and then when I save it the others will all have the same edit. [@] Then the others have the same change. [@] Notice, by the way, this one didn't read the sound files because I told it to read it in a message by name and it didn't know which one of these tables I meant when I named it because they all have the same name, so we have to deal with that. [@] Right now, my way of dealing with it is going to be brute force and stupid. [@] I'm going to take this and get rid of it -- By the way I hit "save" so I get rid of it in all three of them. [@] And then go back and do what I should have done before. <>. Put it here. [@] By the way, I'll just whack the loadbang action so we'll get it. [@] So now we have three things, all of which amount to sub-patch. [@] Oh, I just made a bad mistake. [@] I actually saved this patch. [@] Well, it's all right, it's a copy from another day so the original patch is still there. [@] So now we have two different kinds of sub-patches: [@] This one <<0.sampling. [@] envelope>> is called by a file name and this one <> is called by saying "pd" and this one <> will be saved as part of this patch. [@] So anything that I put inside here is part of this document and if I change something in here the change is reflected by ... Let me save this thing so I don't get in trouble later. [@] <<"3.poly-sampler.pd">> [@] This is going to be three. [@] I'm going to be optimistic and call it a polyphonic sampler. [@] Now what we need to do is get messages into sampling envelope <<0.sampling. [@] envelope>> to cause it to do things. [@] In fact, since it's a polyphonic sampler, let me do something that's going to be essential for our mental health: [@] which is to have the array actually be this one <> [@] Whoops, don't have it. [@] All right, I wasn't going to tell you this, but rather than move that one in <> I'm just going to call it by its relative path name. [@] <<"../1.17/oh.wav">> [@] I'll fix this later. I'm going to have that be the loadbang action. [@] That's because I want to be able to have different pitches of it and have you be able to hear it and if it's saying ... if we have another three whatever -- "...soft and relaxing..." [@] it's going to be harder to hear what's going on. [@] So now if I want to hear one voice of it, for instance, I can go in here and say 60. There it is. [tone] [@] So now I have a nice monophonic sample. Cool. [@] Now how do I make it polyphonic? [@] First off, we probably shouldn't have the metronome in here, but what we should have is an "inlet". Now, when I say inlet notice it puts an inlet in this box. [@] In fact, when I save this box it's going to put an inlet on all three of them and that inlet corresponds to the fact that I said "inlet", which is an object whose purpose is to put an inlet on the patch if it ever gets called as a sub-patch -- as an "abstraction." [@] So this is one of two ways you can get the messages and signals into and out of sub-patches, which is you just make inlets and outlets in there and connect them. [@] I should say at some point there is such a thing as inlet and also inlet~, like this -- which is the signal version of it which makes an inlet that expects audio signals. [@] That's a different thing from making an inlet that expects messages. [@] You'll see that later in gory detail. [@] I'm going to try to keep things simple today. -- [@] Just do "inlet". [@] So now this is kind of cool. [@] Save this and close it. [@] Now I've got something where I can say, for instance, number ... [tones at different pitches]. That's ugly! [@] Maybe I should go in and make the envelope be a little more assertive: [@] Like this: [tone] [@] So 50 milliseconds was too slow for having the voice start in that particular instance. [@] Now, for instance, if I want nice major chords I'll say OK why don't we add 4 to be up a musical third. [@] Actually, let's make it simpler conceptually. [@] Then add 7 which is a musical fifth. [@] This is just to prove to you that this thing is actually polyphonic. [@] Now if I say 60 I get the whole triad. [sequence of triads at different pitches] I forget who it was ... [@] Conlon Nancarrow has a lot of music that sounds like this. [@] Anyway, you've all heard this kind of sound, right? [@] Questions about this? [@] ... Yeah? [@] Student: Can you send the message to all the copies? [@] ... Yeah, you have to connect it to the copies or somehow distribute the messages to the copies because this copy is actually going to be doing this pitch, and so on. [@] ... Yeah?? [@] Student: Did you say how you're copying/pasting those groups of objects? [@] Oh. Control-D for duplicate. [@] Any time you have something that's selected you can hit control-D and it duplicates the whole thing. [@] You can even do it to a whole thing like that. [@] Oh, gee, now I've got two of them so I can even do this: [@] Well, actually, I can have as many of these now as my computer ha run. [@] You haven't had any trouble with your computer not being able to run things yet probably, but now you will be able to make yourself trouble having your computer actually run everything. [@] ... Yeah?? [@] Student: Is the abstraction, with an inlet, like a regular Pd object? [@] If you like, it's a whole new kind of object that I made today, that's not part of Pd but it's part of my private library. [@] Student: If you wanted to choose the order that they play, could you put one dac~ at the bottom? [@] There are two things you can do along those lines. [@] Student: If you put a patch for each note ...? [@] ... Yeah, but it would be smarter to have just a single one and have a sequence of different pitches going to it, because you don't need them to overlap. [@] In other words, it's easier to control something, if you have a monophonic synthesizer, to send it sequence of things than it is to have a polyphonic thing that follows each other. [@] For instance, if you want to say "do, re, mi" and get a trumpeter to do it you don't get three trumpeters and tell each one to play a note. [@] Student: Not polyphonically ... [@] ... Yeah. On the other hand, you can, for instance, ask it to do these things arpeggiated: [@] This is a slight aside .. but there is a wonderful object called "pipe" which remembers numbers and puts them out after a delay. [@] So if you want to make rounds or canons do this... [@] This is not exactly an answer to your question, but it's a related idea. [@] Now if I hit 60 you get: [arpeggio major chord] [@] And now what it'll do, it'll be a major cord. [tone]. [@] Student: How is "pipe" different from "delay". [@] Yup, how is "pipe" different from "delay"? [@] "Pipe" will remember as many numbers as ... -- OK, first off -- "delay" gives you bangs and "pipe" will actually remember numbers. [@] Pipe will remember as many numbers as you give it so that you can do this: [tone] . [@] And you'll get -- oh that's not a good example because it's too fast. [@] Let's make it be a second; then two seconds. [@] Oh wait, there's too much going on, so let me just not have this third one. [@] So now I'll say. [sequence of tone pairs] So what's happening? [@] Oh I should do it this way. [@] This thing remembers numbers, but it also can remember more than one number at a time so that it will remember a whole sequence of things that happens. [@] So it's actually a memory object as opposed to "delay" which doesn't remember stuff. [@] This is useful. [@] It's not as useful as you think it's going to be, because it doesn't turn out to be a generally ... that frequent that you want to have exactly the same sequence of stuff come out after a delay of time. [@] I mean occasionally you want it, but it's more likely that you want to do something that varies how things change in such a way that pipe no longer becomes the right solution. [@] And there's no way to sort of build it out into something better -- It just is what it is. [@] Also, when you send a whole bunch of stuff in then suddenly you might say, "Well actually, why don't you just forget the third and fifth things that I told you but remember all the others." [@] But there's no way in pipe to do that. [@] And so the designing pattern in the computer music ... it's actually not good to have, to schedule, a whole bunch of stuff under the feature and then have it happen. [@] It's better to always schedule the very next thing that's going to happen in case you're going to change the tempo or change some other aspect of what you're going to do -- because then you might find out that all that stuff you scheduled you might have to re-compute anyway. [@] So pipe does the wrong thing, which is just schedule a whole bunch of stuff into the future. [@] So, that was just sort of an answer to the question as opposed to useful information. [@] So here's now, back to the triad generator: [@] Other questions about this? [@] Let's see, why is this not useful? [@] What's the next thing you would want to do? [@] ... Hook it up to a keyboard maybe, but I don't have a keyboard so that's not a problem for me right now. [@] How about changing the lengths of the notes or changing other qualities of them. [@] Right now they're short and kind of brutal, and maybe we would want to do something that would allow you to say well "Make me a chord that lasts a half second or a second long," -- have that be another parameter. [@] That's kind of a typical thing that you might wish to do. [@] So would you want to have a whole bunch of different inlets to this thing? [@] Maybe not because if I decided to have like 10 inlets to control 10 different aspects of how the sampler works -- This doesn't have 10 controls on it, it has maybe five or six things controlled right now. -- [@] But by the time you have eight of these and maybe a half dozen inlets on this you have a lot of wires running around. [@] You're going to really want to just pack and unpack, which are things that will allow you to take numbers and combine them into messages that have more than one value in them so that you can not have wires flying all over the place, each one of which just carries one number. [@] So let me just make the thing now: [@] Why don't I save this one, or rather leave this one the way it is and work on a new one.<> [@] Save as four. [@] Sample duration. [@] So now ".samping. [@] envelope" -- If I go changing it it's going to change it for both of these patches, which could be a good thing, but for right now it's not going to be a good thing. [@] So I'm going to save it as something else. [@] Go in here and say save as. [@] Now it's going to be "sampler-voice-with-duration. [@] pd" That's a terrible idea because now we're going to have to type that whole thing out. [@] And if I get one letter wrong it'll fail.... [@] Now my plan is going to be: [@] I'm going to put lists of two numbers in and the numbers are going to be a pitch and a duration. [@] The pitch will be just what it is and the duration will be in milliseconds. [@] It's going to be easy, right? [@] I'm going to want more of these later, but for right now let's just have one of them. [@] So what we're going to do is here we're going to have to use the pack object to put messages together. [@] To start with, let's just do it the most simple-minded way, which is to pack two numbers, one of which is going to supply the duration and one of which is going to supply the pitch. [@] So now I'm going to say duration 1,000 and pitch 60 and it's going to last a second, right? [@] No. Because? ... Why doesn't this work? [@] Student: The duration doesn't get to the subpatch? [@] Yeah, it's sort of that. I'm even being more simple minded. [@] I didn't change the abstraction to do anything to the second number, so of course it can't do anything with it. [@] I didn't fix it. So go in here: [@] (If a number box gets a message with two numbers it just takes the first number. [@] You could do a variety of different things, but that's the way it does it.) [@] So what we want to do is just unpack the other number. [@] Move this here. [@] So that's all we need is an unpack object, which by default expects two numbers. [@] This one is now going to be a duration in milliseconds, which I think is just going to be the value of this delay. [@] Tada! Oh, delay: [@] The first inlet you send a bang to will schedule a bang to come out after the amount of delay and the second inlet changes the delay time so it <> receives numbers. [@] As a shortcut, you can feed it a number into the first inlet and that will not only set the delay time but also arm the delay. [@] In other words, also schedule the set-off. [@] But this is the more readable way of doing it. [@] I'm just going to set the number here and then all this stuff is going to happen which, by the way, is going to start the delay off. [@] So I'm going to save that. [@] Maybe it's already going to work. [@] Dig! That was too easy! It's still true that when I tell it something new it has to steal the voice from the old one. [@] Oh, "stealing voice" -- that's MIDI talk. " [@] Voice stealing" is when you have a thing here which is a "voice." [@] Voices, that's borrowed from chorale talk. [@] A voice is a person standing up saying something... [@] But in computer music talk it's a thing that's able to make one pitch at a time. [@] The idea here is that each pitch is going to be made by one of several identical sub-patches. [@] So that's what "voice" is. [@] So "stealing the voice" means if I have the thing playing and suddenly give it another pitch before the first one is done, I want it to cleanly stop playing the previous one and start playing the new one. [@] All the machinery is already in there to do that. [@] What we have to do then is mute the thing by taking the line~ that drives the output and ramping it hurriedly to zero and then resetting the location of the array to the beginning and starting the whole thing over. [@] Now we've got everything we need to do this polyphonically except for one other thing which is this: [@] Now suppose I want to be able to give it a bunch of numbers and have it not steal the same one, but allocate a new voice each time so we can hear them all separately. [@] Then what you need to do -- and this is going to be work -- then what we need to do is have a bank of these and have each time you give it a new one choose a different one of them to send a message to. [@] It's like an automobile distributor, which will send a spark to the cylinder that's supposed to go off next. [@] So we know how to generate those numbers just fine. [@] That's this kind of patch, which you've already seen: [@] You need a floating point number "float" and then a "+ 1" -- That makes a loop. [@] Let me just make that loop first and you can see what that's good for. [@] That's counting, but now what we're going to do is we're going to say we want some number of voices. [@] I'll just make there be eight. [@] That's a reasonable number. [@] So what I really want to do is count to eight. [@] Let's say "+ 1" all right, but then modulo eight "mod 8." Then we're counting 0 through 7. Let's see. [@] I have to introduce a new object now -- I'll just do that. [@] I won't do the simple one, I'll do the one that we're really going to need. [@] There's an object sitting here called "route," which looks at messages and simply routes them according to what the first number in the message is. [@] So, for instance, if I give it the number 0 through 7 to look for, if I give it a 7 it puts it out this outlet, but if I give it a 0 it puts it out that one. [@] 1, 2, 3, 4, 5, 6, ... 7, 0, and so on. [@] It has, by the way, eight outputs because there's a last one which is what it outputs if it doesn't match any of the numbers I gave it -- which is always a possibility. [@] I didn't have to give it exactly these numbers. [@] I could have said I only care about numbers five and six or something like that. [@] But in this case I want all the possible numbers this can generate to make outputs. [@] Now it's even worse than that because what I really want to do is have route ... I'm going to just demonstrate this ... I want to have route take this kind of message and somehow route that message according to this number. [@] So what I need is a message with three objects in it. [@] So we're going to have to have pack with three numbers in it. [@] The first number's going to have to be the number we route according to. [@] The second and third numbers are going to be these numbers here <> except that I want the thing to change whenever I wiggle this number <>, just to make it easy. [@] So what I really want is whenever I get message out of here it's going to stuff these values in here and then make this thing go. [@] So to do that I have to unpack it again. [@] This look ridiculous that we're doing pack followed by unpack, but actually that happens all the time that you have to do that. [@] This is now the value of 1,000, so we'll put it there. [@] This is the value 58 and we'll put it here. [@] Then we're going to bang that, but we care what order we do those two things in because we want to bang this after this number has gone in. [@] So we need our old friend trigger. [@] I'll use the abbreviation trigger bang float <<"t b f".>> Let's see. [@] I'm going to bang this, but meanwhile we're going to throw this in here. [@] And then let's just look at that to see how we're doing. Print. [@] Now each time I give it a new number, out comes a triple of numbers which consists of: [@] the voice it chose and then the pitch I gave it and then the duration I gave it. [@] This would be an excellent moment to stop and fish for questions ... [@] Student: What is the "route" actually doing there? [@] Ah, yeah. I'm not using that yet. [@] What that's going to be good for is: [@] This first number is going to be which of the eight sub-windows I want to send a message to and route is going to do that for us. ... Yeah?? [@] Student: Does route send the whole message it gets? [@] No. It'll strip the number. [@] So that's the next thing to do is just send this thing in here. [@] So I'm going to call this "before" and "AFTER." [@] Oh, sorry about the caps. [@] Caps lock. [@] Now we start doing this. [@] Actually, "AFTER" came before, but anyway -- whenever the message starts with 0, the "route 0" matched and it came out here. [@] By the way, it gave me the other two numbers, which is what I want to feed the sub-patch with. [@] Now we're done because. ( [@] I'm going to leave that there.) [@] Now we just make eight of these and have them talk to this. [@] Are we going to get it all on one screen? [@] I could have chosen a smaller number. [@] But no. So I'm going to make eight of these. [@] You can tell I've done this before. [@] I know which way to organize them. [@] Let's see. I didn't make the right number of them though yet. [@] Computer scientists hate this because I'm actually manually iterating something and, of course, the program should be smart to do the work of doing these connections for me. [tone] [@] Now I've got polyphonic sampling. [@] Or actually to really prove this is doing what I think it's doing let's give it a nice chord like this: [@] 60. Notice the commas. [@] That means send both messages please. [@] All right, this will be horrifying. [@] You can put it right there. [tone, laughter] Tada! [@] So what's happening here is this is the same thing if I had somehow managed to simultaneously type all these numbers I wanted here. [@] So each one of these things generates a message and, in fact, you see here what it did to them. [tone] [@] I don't know, but whatever that was, six numbers... [@] oh wait it starts here, each got assigned a voice number and then here are the six pitches that you see that I typed in there and here's the durations I asked for. [@] More on this next time. [@] *** MUS171 #10 02 03 (Lecture 10) [@] There's one sonic aspect of sampling that I didn't stop and explain as well as I wanted to explain last time. [@] So, I want to go back and ... just do it harder. [@] And that is the business about, if you have a looping sampler, there are two regimes in which you can hear the thing: [@] One is where you have the sampler playing back, either looped or not looped but at least slowly enough that you hear individual starts and stops as events. ... [@] And that would mean perhaps playing fewer than 30 different things a second. [@] So, here the example would be. .. [@] Whoops, that's not a good example. [audio tone] [@] So, now you just hear one of the dude's phonemes six times a second. [@] This by the way, is a copy -- annotated and then partly de-annotated -- of one of the patches that I made last class. [@] And this is up on the Web. [@] And my purpose in making the patch was to show you how to add the "envelope generator shaping" to a phasor. [@] But now what I want to do is -- continuing to look at the phasor-driven sampler, because it's the more appropriate way to look at this -- [@] to compare again what happens at low and high frequencies of phasor. [@] What happens at low frequencies is kind of exactly what you would expect, which is ... [audio tone] [@] You hear stuff at a certain number of times per second, and furthermore ... OK, so what's happening here is this 34 is the beginning place. [@] Oh, it's in 100s of samples, which means 441 of these make a second. ... Back to normal. [@] So, what's happening is we're looking at this array, and we're looking, starting at whatever 34 corresponds to here. [@] And then we are sliding forward 78 of them. [@] ( ... Is that me shaking? How is that happening? ) [@] Student: Maybe it's just an earthquake. [@] (I think we were having a nice little earthquake. [@] We just invented a new kind of seismograph. [@] Maybe I'm wrong; maybe it's something totally anodyne. ) [@] So this 78 is now being multiplied by the phasor, so the phasor is going from 0 to one, and now we're making the phasor have a range, which, in 100s, anyway, starts at 34 and goes to 34 plus 78. So, this is the amount of sample you hear each time. [@] So that ...[audio tone] [@] Once you've got the units right, anyway. [@] If this thing times this thing equals 1, you've got the straight-ahead transposition, that is to say, the original pitch. [@] And what would that be? [@] Actually, let me change the unit so that it's easier to think about. [@] I'm going to make this be units of 441, so that these are hundredths of a second. [@] And now this'll be something like nine, and this'll be something like 20. [audio tone] [@] ... Yeah, there we go. [@] So now what's happening is this is .17 seconds, because 441 samples is 0.01 seconds at our sample rate. [@] And this .17, that times 6, if you multiply it out in your head, turns out to be very close to 1. [@] Actually, one-sixth is, as you all know, 0.1666, so we'll do this: [@] And now we'll get the original transposition. [@] This number in hundredths, that is to say, 0.1666 repeating, times six is 1. And now if I choose some other pair of numbers which also multiplies out to 1, such as make that five and make that 20 hundredths ...[audio tone] [@] Then I've changed the speed at which the thing's happening but I haven't changed pitch that you hear, or the transposition that you hear, of the sample. [@] Is it clear why this is working? [@] So, the transposition that you're hear is proportional both to this number. [audio tone] ... [@] ... and also this number. [@] Next thing about that is this: [@] This is what you hear these numbers are below about 30. That is to say, the number of things you can hear as happening as discrete events. [@] So even if I push this to 20 and drop this to five. .. Oops![audio tone] ... [@] And find a good place ... You hear the event as a repeating thing but if I push this past about 30 you won't anymore. [@] I don't know 30. It's iffy. [@] But of course, this is a very particular spiky part of the sample. [@] If I get somewhere else in the sample. .. [audio tone] [@] It becomes very hard to hear that as a sequence of things and easy to hear as just a continuum. [@] If I push this higher, then at some point your perception of this as having a pitch becomes more important than your perception of it as number of times per second. [@] This is just acoustics, if you do anything repeatedly fast enough it becomes a pitch. [@] For instance, if I want to use this Western-style musically we'd want a MIDI to frequency converter. ... [@] make another number box ... Then I can say, "Well, play that for me at play it at middle C, please. " [@] Which is 261 Hertz and now we've got middle C. [audio tone] [@] I could check it on the piano if I cared. [@] Oh yeah, let's go down an octave. [@] That's a little too harsh. [@] Oh. Why does that sound so ugly? [@] There's something going on here that I don't understand. [@] That should be a smoother sound than that, but we'll go for it for now. [@] If I ever find my mistake I'll tell you. [@] So, at this point, we're playing five milliseconds of sample at a time. [@] But we're transposing up a quite a bit because we're playing 130 of these per second. [@] So really, this should last something under one millisecond. [@] Should last about .7 milliseconds, I think. [@] Oh, this will sound better now, maybe. [@] ... Yeah, there we go. [audio tone] [@] All right. [@] Then, we have the sample as before:d [@] [audio tone] [@] Those are timbres taken from the voice. [@] In fact, I could even try to move this continuously, except I'm going to get in trouble. [@] You'll see. [audio tone] [@] It's a little ugly because you hear it click every time this thing changes discontinuously. [audio tone] [@] So, let's go find "soft" ... [@] And now, when you heard it coursing over the sample, then you heard the timbres or the vowel and consonants of the original sample going by. [@] So, right now, you can sort of believe that this thing. [audio tone] [@] Is the "O," the short O of soft. [@] That's of course, assuming I'm playing everything at the correct speed. [@] In other words, I've made this and this multiply to approximately one. [@] I didn't check that it was exactly. [@] Oh, I could. [@] I could! Nah, let's not ... I could take this and divide 1000 by it, and put that there. [@] Actually, that would be a good thing to do because I'm going to have to do it later. [@] So, to do that, we're going to divide something, but we're not going to divide it by 100. We want to divide 100 by it. [@] And, that's the thing I haven't shown you how to do yet. [@] But, it's not hard. [@] So, what you want to do is you want to take 100. Control-alt-2. Sorry, 100. We're going to take 100 divided by this, right? [@] Because it's in hundreds of samples. [@] So, we're going to take this and put it here. [@] But then, we're going to have to bang the 100. And so, we need our old friend trigger to make the thing get banged at the appropriate time. [@] So now we say, "Trigger, bang, float. " [@] Let's make this be reasonable. OK. [@] And now, I'll show you. [@] Oh,, rather than show it to you, I'm just going to use it. And, you'll see. [@] So now, I'll say, "48 again, please." And, tada! [@] It computed the exact value, which was 100 divided by this, which is the number of 100ths of a second, which would be the period if this is the frequency. [@] This would be a good place to stop for questions. [@] Student: Can you explain the abbreviation? [@] <<"t b f">> [@] Oh. OK. So, this is an abbreviation for "trigger bang float". [@] And, what trigger does is two things: [@] It formats messages for you -- [@] So, there's a floating point message coming in. [@] And, what we want coming out is a bang here to send this 100, and then actually, before that a floating point number, which is whatever we sent in. [@] So, this divide needs to receive 100 here. [@] And then, it needs to receive this 130.8 here. [@] But, the divide divides when it receives this number <>. And so, it needs to receive this number <> after it has already gotten that one <> -- so that it will do the division correctly. [@] Sorry, there are two questions. [@] You first? [@] Student: So what's the purpose of the bang? [@] Well, the bang is simply to get this 100 to send out, because if this 100 doesn't get sent out, this thing will never divide. [@] Student: So there's a bang and a float? [@] It sends the float, and then it sends a bang, which sends this 100. [@] Student: And that's going to be top down, or? [@] Uh, let's see. [@] This is going to be 100 over this floating point number. [@] OK, let me see if I can make this into a more synthetic example. [@] Let's make a copy of this. [@] All right. [@] So a number comes in, number comes out. [@] And whatever I put in, what comes out should be 100 divided by this number. [@] OK, so how do I do that? [@] The number goes in, and I ask it first to put the number in -- OK, this is the divider. [@] So what I need to do with the divider is first put five in here <> and then put 100 in there <>, so the thing will do 100 divided by five. [@] ... Yeah ... lots of questions. Let's see, I don't even know who to ask. OK? [@] Student: So, the float, how do you know it goes in first? [@] Oh, trigger is defined to put its outputs out in right-to-left order. [@] In general, objects that have multiple outlets that spit out messages at the same time (another example would be unpack) always do it from right to left order, so that you know what order they're coming into a subsequent box in. [@] OK. This order doesn't mean that time is passing. [@] All this happens in one instant of time, or to put it a different way, between two audio samples, but the same two. [@] In other words, it happens in a moment that isn't allocated any time of its own. [@] And yet it has an order, because you have to have this thing go in the correct order, otherwise you could never program. [@] Pd is not a programming language, and this is asking Pd to do a programming language-ish thing, which it can do. [@] But obviously, if you just had BASIC or C or something like that, you could do this particular thing a lot easier. [@] You just say, "100 divided by f," or whatever it is. [@] But since we're in a graphical programming language, it's great for doing things like bashing signals around like that. [@] And it's a little clunky for doing things like saying, "100 over f. " [@] This is the easiest way I know how to do that. [@] There are others. [@] Other questions about that? [@] .... Yeah? [@] Student: So, for when you're changing the range for the plus value, so if you wanted to. ... [@] Not put this object value back to this top half. [@] This value, OK. [@] Student: Yeah. [@] You just have to unpack or on the line? [@] Or if you wanted not to click? [@] Wanted not to click. [@] In other words. .. [@] Oh, you mean, if I wanted these things to be their values when the patch shows up? [@] Student: Yeah, like cycle through that 60 times or so. .. [@] Oh, I see. ... Yeah. [@] So right now I haven't done anything to automate that. [@] I've just left it as a number box. [@] But in fact, that could be messages coming in from some other place if I wanted to. [@] And then I could use the number box to override it, or I could just have it be what it is. [@] But it's easiest, just for the purposes of showing the patch, it's easiest to have everything just be controlled by hand. [@] ... Yeah?? [@] Student: Now if you put more floats in there? [@] And you put a metronome in there? [@] Can you create a loop to sequence things? [@] Sure. [@] Well, OK, sure, there would be some work to do, because. .. [@] If for instance, I had a bunch of numbers in a message, like that. ... [@] If I sent those to this, for instance, this number would become 1. [@] And then it would become 3 and then it would become 5 and then it would become 7. And 7 would win. [@] If I wanted it to do those things and have it be 1, then 3 at a later moment in time, and then 5 and then 7, which would be more like a sequence. .. [@] Then the easiest way to do that would be to store those numbers in a table or an array, and then read them out of the array using a metronome. ... [@] ... Yeah?? [@] Student: So, outlets send from right to left, but inside a message box left to right? [@] Ooh! Yeah; outlets are right to left. [@] Things inside a message box are left to right or in order that they are as text. [@] Student: Oh. OK. [@] Yeah, that's confusing, isn't it? It never occurred to me to think about those two things in the same thought. ... Yeah?? [@] Student: Can we depend on everything other than the trigger having regular order from the outlets? [@] Well, what you can't do, or what you can't depend on, is this: [@] ... I might have shown you this already. [@] I can't remember ... I'm going to take this number and just square by multiplying it by itself, and I'll do it that way. [@] This doesn't work because this multiplier got these two values all right, but it got this value first and that value afterward, and as a result it did the wrong multiply. [@] So, to make that guaranteed you would put a trigger in to make sure everything happened in the order that you wanted. [@] In other words, you would say .... Oh, I'll keep the wrong one and the right one. [@] You would say ... [@] ... OK, "trigger float float" . And now we know that this float will come first <> and this float will come second <>. And then it will do my squaring job right, whereas here it didn't. [@] Student: So not objects other than trigger are right to left though, like unpack? [@] Yes. If the outlets are all, what's the right word? [@] Well, an example of something that doesn't do that is "route" because it doesn't ever put something out more than one outlet as a result of a single message. [@] But things that do put out more than one thing as a result of a single method, such as "trigger" or "unpack" -- or "notein" if you're doing MIDI ... I don't have a lot of other examples here. [@] ... those are all arranged from right to left. [@] That's simply because right to left is appropriate for inlets because it's best to get things left last. ... Yeah?? [@] Student: Would it be one multiply by a parameter and then add, would you have to make that separation? [@] Yeah. It gets ugly. What's a good example of that? [@] Yeah. I have a good example, but it's too complicated and I'd have to explain it. [@] If you want to do A + (B * C) for instance. [@] OK, so you put B and C into the multiplier and then you have A and you want to put it into an adder. [@] Then you have to decide OK, do I want that number to change every time I change any of A, B, or C or do I want it to change only when C changes or so on like that? [@] You could want it either way. [@] For instance, if you're playing a MIDI keyboard and you want to transpose, when you change the transposition you don't want it to replay the note. [@] That just means you want the next note you play to have the new transposition. [@] So, in that case it would be appropriate not to recalculate the pitches of all the notes because you changed the transposition. Maybe. [@] But in other situations, you actually want the output to change when any of the inputs change so it's always correct according to the last inputs. [@] Those are just two different situations. [@] So, you can get Pd to do it one way or the other. [@] The way to get it always to follow what you do is to use triggers everywhere that you need to in order to make sure that everybody's leftmost inlet gets whacked last and then everything will stay up to date. [@] That was a little abstract, but we'll hit examples of that I think later on, I think, in the quarter -- especially if I go back and show you pitch to MIDI conversion in general. [@] Any other questions? [@] That was useful because I think there were a bunch of things I wasn't saying that I should have been saying which that helped clear up. [@] So, now what we have is I've got this number here and I'm computing 100 divided by it to put here. [@] So now, I can do this kind of thing. [audio tone] [@] It's not perfectly smooth, but it's now figuring out what I have to put here to put timbre. [@] In order to get the sample to play back at the recorded speed, regardless of how many times per second I'm asking it to play back. [@] So, the faster I ask it to play back, the less of it I can play back each time if I'm trying to constrain the speed. [@] Now the other thing to mention about this is that ...[audio tone] [@] Now we've got a nice pitch and now we could just go and change this segment size without changing the number of times per second and then we get this kind of thing. [@] Notice there are clicks in the sound. [@] That's because when I change this discontinuously or when I change this according to the mouse it changes the thing I'm multiplying the phasor by, so it causes the read into the table here to move discontinuously, which is a click. [@] So if I want to do this correctly I'd have to use a line object to de-click this. [@] Nonetheless, I now have my first nice timbre whammy-bar that you can use to make wonderful computer music. [@] In other words, this is the first example, (except for that attempt that I made to explain FM, which I shouldn't have ever done ...) This is the first example of a situation where you can change a control and it will actually make an audible change to the timbre of the sound. [@] Which, of course, is what computer music was supposed to be about back in the day. [@] There will be many more examples of this, because eventually you will be able to make filters and frequency modulation -- once I get that straightened out -- and other things like that. [@] Right now, the reason this is happening, I can actually show you using this table. [@] So, just for emphasis sake. .. [audio tone] [@] If we go down to a frequency where you can actually hear the things then what I'm doing is actually changing the size of the sample we're playing, which is changing the transposition. [@] But then if you make that happen at an audible rate then we're changing the transposition again, but it doesn't change the pitch that you hear. [audio tone] [@] ... Because the pitch that you hear is now no longer the pitch of the original sample. [@] But it is the new pitch from just being imposed on it by the fact that I'm reading it at a fast rate. [@] And that is in fact a continuum. [audio tone] [@] So for instance you can say ...[tones] And now I have a continuous way of moving back and forth between pitchy sounds and sampled sounds. [audio tone] [@] And that a lot of people heard for the first time when Fatboy Slim did that song "The Rockafeller Skank" -- That was this. [@] OK, questions about that? [@] Student: Was he actually using Pd? [@] No. [audience laughter] [@] But he wasn't using Supercollider either -- He was using commercial stuff. [@] All right. [audio tone] [@] So now, this, which becomes a transposition when we do it slow, is a timbre-change when you do it fast. [audio tone] [@] And another way of seeing that is to take this thing and graph it. [@] Which is what I now propose to do by using these graphs over here. [@] So I'm going to keep the phasor and instead of graphing the envelope, which is what this graph is here to do earlier ... [@] I just want to graph the output of the tabread~ object. [@] Oh yuck! --- Oh, I see. [@] I've got this thing so high that the graphing doesn't look good. [@] So let's change the properties here. [@] I had 44 -- that's a tenth of a second. [@] I'm going to need like a 50th of a second. [@] So let's make this a thousand. [@] <<"Size" in the Array Properties of Array "scope">> That's actually a 44.1th of a second. [@] And let's see. [@] Will this work? [@] Still looks, oh whoops! I didn't do that quite right, I need to change this too <<"X range in the Canvas Properties>>. ... Oh, and this! <<"Size" in the Array Properties of Array "scope2">> [@] Sorry -- I've got two arrays in there <<"scope" "scope2">> which is why I got confused. [@] So OK now what we see is there's a nice phasor and it's going at 48 times a second. [@] And each time it goes you see the same waveform, which is in fact the waveform which is stolen from the original recording. [@] And now if I ask it to graph again, you'll see that it's in a different place, because I don't know how to make the graph start right when the thing wraps around. [@] ... That's for later ... But you can see that it's the same waveform. [@] Now if I say, "OK, do that but make this number larger. [@] In other words, make there be more of the sample. " [@] Actually, let's have there be less of the sample first. [@] I'll drop it to one. [@] Then when I graph it, you'll see that there was just less waveform stuffed into there. ... [@] Is this clear? [@] Now you can do wonderful things because, what would happen if you just stuck a sinusoid in here? [@] Actually, that would be a useful thing to be able to do, so let's do it. [@] So now what we're going to do is we're going to say, "tabwrite~" and I give the name of the thing, Table "t2.03a" ... [@] Now I'm just going take a nice sinusoid, maybe 110 Hertz, so it won't be too different from the sound of the dude's voice. [@] And I don't want it to be quite that loud because I don't have a good volume control, so I'm going to protect us by multiplying this by some smallish number. [@] And now we need a button to make this thing happen. [@] Wait two seconds ... And sinusoid! -- although you can't really see it as such. [@] And now here: [@] <> Sinusoid! [@] Except, of course, the sinusoid has a discontinuity every time we restart the sample. [@] And now the bigger a chunk I read hear of the sample, the more cycles of the sinusoid have to slap into the same amount of time. [@] If you can imagine what that sounds like, it's got this period, so the pitch of it isn't changing, but you can tell by looking at it that it's got a lot of stuff at this frequency and maybe not a whole lot of stuff at fundamental. [@] So now if we listen to it. .. [audio tone] [@] We've made ourselves a nice little formant. ... [@] Is that clear? [@] Student: Are those pops because of that repeating ... ? [@] ... Yeah, the pops happen whenever I change this. [@] And what that does is that changes the amount I'm multiplying this phasor by. [@] If I happened to do that right when the phasor was at 0, it wouldn't make a discontinuous change. [@] Student: So you're re-ranging? [@] As it is, it gets up to a half or something like that, and then suddenly it re-ranges, and that pushes it off to a different value. [@] I'll show you things about that later ... after I've stuffed all these more fundamental ideas into your heads. [@] The object you want is "sample and hold" because you want to sample this number only when the phasor changes cycles. [@] But, of course, the thing that I had originally was not a sinusoid, it was the man's voice. [@] Then you get this look and this sound: [audio tone] [@] And, of course, different parts of the sound file different things, but they all have the same basic behavior. [@] All right. ... [@] So that is basically a thing about sampling that everyone can use. ... [@] Questions about this before I go on to other things? [@] What I want to do now is go back to polyphony and voice management, which I started talking about last time, but about which there is much more to say. [@] Everyone's tired of this topic anyway. ... Yeah?? [@] Student: Are you going to put these patches online? [@] Oh Sure. Yeah, this one is going to be patch ... I have to change the order of these because I didn't plan very well . [@] But all the patches up until last time are up on the web. [@] It takes me a day or two, but I eventually get around to putting good comments on that actually mean something, when I'm putting them up. [@] Yeah -- this is a good trick. [@] So now I have several matters to go over. [@] First off, here's the example of a multiple-voice sampler: [audio tone] [@] That was the thing I showed you guys last time. [@] The basic deal was, the new objects you needed were ... First off,x just the notion of having a so-called abstraction. [@] That's to say, being able to put a Pd patch inside a box, which would, in fact, be a sub-window. [@] And "route", which is this object, which takes a message in with any number of numbers and looks at the first numbers and, depending on what it is, puts it out one of the several outputs. [@] Since there are eight arguments here there's nine outputs because there's one for if it didn't match anything. ( [@] That way you can gang several route objects together. ) [@] Although here I happen to know that this number will always be 0 to seven because I have this "mod 8" here. [@] This is an example of polyphonic voice allocation and there are other examples of things that you can do with polyphonic voice allocation -- which I will actually show you by taking you through some pre-existing patches. [@] -- a slight departure from the custom. [@] So, this right now is just a copy of what there was last time. [@] The first thing I want to mention before I go ripping through the pre-existing examples is a thing about abstractions I haven't told you about, which is this: [@] Here's another abstraction. [@] Get in edit mode ... You can do something like. .. [@] Well, I have an abstraction, which I moved into this directory beforehand, called "output~". This is interesting because it's not just an abstraction that has a patch inside it, but it also has controls, which it printed on its "faceplate", if you like. [@] So, this is a technique for being able to make things like modular synthesizers give you -- which are modules with audio inputs and outputs, but which also have controls like knobs. [@] So, I'm just going to tell you now that this thing exists and how you can deal with it. [@] First off, it's just an object like any other, so I can retype this and it would become some other kind of object. [@] But this is a particular kind of abstraction, which does this for us. [@] If you want to see inside it, it is not good enough to click on it because clicking on it means doing that kind of thing<>. Oh yeah, by the way, this is an output level in decibels and you would use this if you wanted to have a patch whose output level you could control on the fly, which is a good thing to be able to do. [@] The other thing about this is, of course you might want to be able to see what's inside it, but clicking on it doesn't do that because clicking on it does that kind of stuff. [@] So instead, you control click or right click depending on what kind of mouse you have and say "Open. " [@] Then you will see the contents of the thing as an abstraction. [@] Then it's nothing much more than what you've seen already except there are some tricks here that I haven't told you about yet which I hope to tell you about today. [@] Then closing it's the same as it always is. [@] You just close it. [@] All right. [@] This has a name. [@] It's called a "graph on parent" abstraction -- the reason being that it shows a certain portion of its GUI objects, its controls, on its own surface as an object. [@] You can learn how to make these and so on. [@] Well, OK ... You would say... [@] "Properties" . <> Notice here it says "Graph-On-Parent"? [@] You have to click that and then that turns your abstraction into one of these things, but then there are things you might want to set that I have to explain in detail later. [@] I'm telling you that because I'm going to take you through some patches that are going to use this and I want you to know about this thing's existence. [@] If you want to use this you have to get this thing and copy it into your own directory. [@] I'll throw it up on the website, but it is also on all of your computers because it's actually in Pd, in the help patches. [@] And that is in fact, where we're heading next. [@] I've been studiously avoiding the help patches because I've been building everything from scratch, but by the time we're getting into voice-banking stuff, some of the examples maybe are better just looked at and described than they are built up from scratch, because ... [@] ... you have to do several things at once and get them all working together. [@] So, I'm just going to close this and open some other patches that do other things. ... [@] So, in Pd, if you say, "Help," one of the things you can get is this: [@] "Browser". And the browser has far too much stuff in it, but if you go looking for "Pure Data" ... -- Oh, by the way, if you have Pd Extended this really has a lot of stuff. [@] Right now it merely has a bunch of useless stuff. [@] "Pure Data" .. "audio examples/" -- Oh right, there's a manual. [@] This has a bunch of HTML stuff, which is very telegraphic and, what's the right word? [@] "Short". "control examples" -- later. [@] "audio examples" -- which are examples about how to do synthesis, processing, and analysis of sounds. -- [@] These examples correspond to the textbook, which I haven't been referring to very religiously, but we're now somewhere in chapter four of the textbook, talking about voice allocation. [@] The A's are all chapter one, the B's chapter 2 and so on like that. [@] And so, all of this stuff, if you want to see more description of what it's about and how it works and why, look in the book in chapter four and the book actually talks about all of these patches in some detail. [@] The things I wanted to show you were, for instance. ... [@] "additive synthesis". <> [@] Here's the reason I showed you output is because we're now going to be starting to use output to set the. ... [bell tone] [@] Volumes of things. [@] Notice these values are in decibels, which means 100 is full-blast and 75 is likely to be quiet. [bell tones] [@] So typically I put these close to 100. [bell tones] [@] This means nothing to people who weren't in the computer-music scene in the sixties and seventies, and then it means a lot because this is one of the classical computer-music designs done by Jean-Claude Risset at Bell Laboratories in Murray Hill back in the day when people were first doing things with computers. [@] And what it is. .. [@] let's see if I can make it sound better. [bell tones] [@] It's called a Risset Bell. [@] And it's just Jean-Claude Risset having found some parameters somewhere that make a nice. .. [bell tones] [@] ...bell sound, that can do that kind of stuff, or this kind of stuff, [bell tones] [@] Or of course, this kind of stuff. [bell tones] [@] Actually, better yet. .. [bell tones] Ta-da! [@] It's not rocket science. [@] What it is .. the old term for this was "additive synthesis." [@] It's a synthesis technique that you all know because all you do is add up oscillators. [@] And the oscillators in the examples I've shown you have all been tuned to multiples of a fundamental frequency so that they all fuse into a harmonic sound. [@] In this case it's additive synthesis in the sense that it's a bunch of sinusoidal oscillators being added together, but the oscillators are imitating the modes of vibration of a bell. [@] Although, I don't know if this corresponds to a real bell. ...[bell tones] [@] ...or something fanciful. [bell tones] [@] And, the controls that you get are going to correspond exactly to the controls you saw in the sampler example last time, which is, you get to control pitch and duration. [@] Differences between this and the previous example -- There are going to be a couple of differences when you get into the voices, but there's a huge conceptual difference: [@] Which is that this isn't a polyphonic instrument. [@] It only plays one note. [@] But there's still voices, adding up to that one note. [@] And the voices are, instead of making different notes, making different partials which added up into a single note. [@] It's polyphony in one way of thinking, because it's realized like a polyphonic instrument. [@] But psychologically, it's monophonic. [@] So it's showing the use of voicing and abstractions, in a non voice-allocating way. [@] A key difference between this and the previous example is there's no route object. [@] In the previous example, you decided every time you asked to play a note, which of the voices was going to play it. [@] Here, all the voices play every single note. ... [@] ... Yeah?? [@] Student: And those voices are the partial voices? [@] Yes, right. [@] So now I have to show you what's in there. [@] Student: So do we'll look inside the patch? [@] Yeah. Next thing is, notice that I'm feeding the thing arguments. [@] I'll tell you what the arguments mean in a moment when I show you what's inside it. [@] But when you have an abstraction -- which is to say an object which is a separate patch being written into a window -- [@] Usually, not quite always, but in most situations -- You're going to want to throw in arguments to specialize it to do one thing or another. [@] For instance in this case, each of these partials has to know which partial it is, so they don't all decide to play the first partial together. [@] They each have to play different partials. [@] So each one of them has to know which partial it is. [@] And to do that, you have to pass each one arguments that disambiguate them. [@] That tell them how they are going to be specialized. [@] Other huge difference and a small related difference to the huge difference: [@] There aren't wires going into these things and inlets. [@] So the mechanism for getting messages inside here is not inlets, it's "send" and "receive". [@] ... For the simple reason that, and here's the small conceptual difference, frequency and duration and trigger are being sent separately in this design. [@] I thought, at the time, this was actually a simplifying this, although I don't know now whether I think it's more simple or more complicated. [@] So in this particular design you give it any pitch and any duration you want and then you say, "OK go ahead" and then it does it for you. [@] You could now take a packed pair of "pitch and duration" and make it act like the previous one if you used an unpack and a trigger in order to send messages in the right order to duration and frequency and trigger. [@] So, what's going to happen inside here is each one of these things is going to have a receive frequency and a receive duration, which will tell it the global frequency and duration of the tone, and then it's going to have another receive for trigger, which will set the thing off. [@] All right. [@] Now, just to hearken back to Music 170 for a moment: [@] This is imitating how a bell actually vibrates. [@] One way, maybe the best way, of thinking how a metallic object would vibrate is you strike it and in striking it you activate the modes of vibration the thing has. [@] Those are functions of the shape and construction of the object itself, not of how you whacked it. [@] They don't move. [@] But the modes each have a frequency and a time constant. [@] The frequency is how fast the mode vibrates and the time constant is how fast it's damped: [@] whether it vibrates forever, which it would do if it had no damping at all, or whether it dies out very, very quickly. [@] So what's happening here is we're pretending there's a metal object that has 11 modes in it, each of which has a different frequency and a different damping. [@] But then there are global frequency and duration (which is damping), controls that are multiplied by each one's individual frequency and damping factor. [@] Now, to go look inside "partial", which I've been putting off: [@] Here's how you do a partial. [@] This is being done in gory detail in the most careful explained, boring, pedagogical possible way. [@] Let's see. I can do this. [@] I haven't told you this and probably shouldn't tell you this now, but line~ generates line segments and if you want a line segment to feel like an exponential just raise it to the fourth power. [@] Then instead of going down like this in time <> it goes down like this in time <>. Then it's not exactly an exponential, but it's pretty good. [@] What that means exactly is explained in chapter 1 of the book, so you can look it up if you don't believe me. [@] But the signal processing aspect of this is being done here. [@] All right, so what you see is an oscillator and a line~. [@] I'm raising the line~ to the fourth power so it will go down more exponentially than just a line segment would. [@] Then I'm multiplying it by the oscillator then I'm introducing a new object, "throw~", which I'll not dwell on right now. [@] I didn't even tell you about send~ ... This is a way of avoiding having an outlet by asking a Pd to set up a "summing bus." [@] In other words, what's happening is somewhere there's a "catch~ sum", which is automatically going to get the sum of all these signals. [@] It's a good thing, but it's not a thing that you absolutely need to know right now, so I'm going to not dwell on it but just sort of say that's what's happening. [@] This is like dac~. In fact, it could be dac~ except that I wanted to be able to use the "output" thing I showed you earlier. [@] So, instead of just putting the dac right here I put a "throw~" and it all collects in this "catch~" and then it goes to this output object where I'm controlling the amplitude for output. [@] All right. [@] Student: Can you play them all at the same time? [@] Actually, it's so I can control the volumes of them all in parallel. ... [@] OK, so this is controlling globally the amplitude of the thing by virtue of the fact that each one of these partials, using the "throw~" object, has added itself at full strength to this "catch~", which then is going to be sent to the "output~" which will control its amplitude. [@] So that's controlling all the amplitudes in parallel. [@] ... Yeah?? [@] Student: So it's like a send and receive for multiple things going to the send box? [@] Right. So send and receive work for messages. [@] There's a send~ and a receive~ for signals, but in audio signal land the situation's a little bit more complicated. [@] Because it would not be clear what to do if you had a bunch of sends and a bunch of receives. [@] In message land, you just send all the sends to all the receives. [@] Student: So like a patch bay? [@] Yeah. It is exactly like the patch bay. [@] So here what's happening is all of the throws are throwing to the single catch. [@] There's a fan-in thing, which is a summing bus, which is done by throw~ and catch~. And there's also a fan-out mechanism, which is accomplished by send~ and receive~, which I haven't shown you. ... [@] Student: So you can sequence them as well, going into the catch? [@] No. It's like cables. So they're happening in parallel. [@] So sequence. ... Yeah. Only messages can be sequenced. [@] Signals can't really be sequenced; they're all happening all the time -- which is one of the good reasons to have messages around. [@] Now the partial, is showing off ... so the arguments to this partial were these numbers: " 1, 1, 0.56, and 0". [@] Those numbers are what showed up here. ... Oh, there. [@] So these numbers 1, 1, 0.56, 0, which are customizing this particular partial, are displayed here. <> [@] And they are expanded by $1. Where did $1 go? [@] Here. .. No, sorry. That was wrong. [@] I don't see $1 yet ... Here! In object boxes if you put a "$" sign, it is the argument you got called with as an abstraction. [@] And here there is one of the half dozen truly hard to understand things about Pd. [@] Because dollar signs are also available inside message boxes, except that they have a different function inside message boxes than they do inside objects. [@] This is all for a good reason because conceptually it is all very simple, even though it looks completely arbitrary and stupid. [@] So, what I want to do is show you ... Just to help confuse you now, I'm going to show you message boxes with dollar signs inside. [@] So, "1 2 3" -- We all know what this will do. [@] Let's see I'll put a number in. [@] And I'll print it out. [@] And then, no matter what I put in, the print out says, "Hi, I was 1, 2, and 3." All right. [@] You can't even see that this was getting repeated. [@] Oh, I'll hit alt again. [@] Alt, alt, alt. OK. [@] Now suppose I want these numbers to vary as a function of this <>. I can say, for instance $1. << 1 $1 3 >>. And $1 means, give me the value that was the number that came in this message box. [@] I haven't shown you this because it was possible to do this already with pack. [@] So, the easy way of getting this effect -- I had to do it once before when I had to do it in order to make triples of those numbers that went to the voices of the polyphonic sampler, two days ago. [@] So this is another function of dollar signs. [@] You can put a dollar sign inside a message and it will insert the number that you put in, as part of the message. [@] And the 1 here, the $1, is which of these numbers it is. [@] If for instance, I gave it a packed message ... Let's see this example. [@] Now $1 is 45. That and $2 is 78. Those of you who have programmed shell scripts in either Macintosh-land or Linux, this is exactly the same argument expansion that holds in Shell scripts. [@] Also, I think perl may look this way, I'm not sure about that. [@] The computer scientists have a name for this type of expansion, but I forget what it is. ... [@] ... Yeah?? [@] Student: Can you add another inlet to the message box? [@] No. You could in Max, but here you actually have to use a pack object. ... [@] So for instance, here's another perfectly good way to make a message that has a bunch of variables in it. [@] And now actually, at this point, I could now do this. [@] And now I could set $2 this way, and $1 this way. OK. [@] Since you have already seen pack this is not something that you need. [@] You will need it later perhaps, because certain things like. .. [@] Oh right -- tables: [@] If you want to tell a table what size it is, you say "resize" and then you give it a number. [@] If you want that number to be a variable, then you have to say "re-size $1" inside a message box. [@] That's the only way to generate that kind of message. [@] So this is a more general facility than pack. [@] And as a result, it runs a little slower than pack too, so it's not necessarily the right way to do things in every case. [@] Now I told you that because I'm trying to confuse so that you will later on be enlightened. [@] The confusing thing is this. [@] If you put $1 inside a message box, or "$anything" inside a message box, it means the incoming message that's making me now send the message, right? [@] Because message boxes take messages in and then send messages out. [@] Object boxes, what you put in an object box, is a message. [@] It's a message whereby Pd makes the object and that message can have dollar sign arguments in it, too, but those dollar sign arguments are the arguments to the patch because the patch is running the message to make the object. ... [@] ... Yeah?? [@] Student: Can you send object names that are variables inside? [@] Create? [@] ... Yeah, if you really want to. [@] For instance, "apply + 5", if you're a list person. [@] Well, let's make a nice thing called "apply". -- You don't want to do this. -- [@] Apply is now going to say, " $1, $2" . " Oh, come on, let me type in there. [@] All right. [@] Then I'll make an inlet and an outlet just for fun. [@] Pd hates me for doing this. [@] It has no idea what $1 means in an object box like this. [@] But now if I retype this I now have a nice little "plus five" thing. [@] OK, Go find a use for that ... Oh, does it actually work? [@] I don't think I've done this in a decade, so. [@] It works. [@] ... Yeah, don't do it. [@] It's stupid. ... [@] Oh yeah, dollar signs can either be numbers or they can be symbols. [@] "Symbols", which means strings, things that aren't numbers like file names or names of objects like "+". [@] Those are different kinds of data. [@] For the most part I've only been using numbers except in the very rare occasions where I've had to specify a file name, like voice.wav [@] I'm doing that on purpose. [@] I'm trying not to get any deeper into the soup of language complexity than one absolutely has to, to do computer music. [@] So this is message boxes and that apply example, was object boxes, but it was object boxes in such an abstruse example that I don't want to talk about anymore. [@] Oh, almost saving there, which is bad. [@] Don't want to put it there. [@] Let's just not save this. [@] This is better explained somewhere else probably. [@] That was all to say this ... Next it's time to say, "What do these things mean?" [@] This thing, this thing, that thing, and that thing. [@] Well, this is a relative amplitude. [@] This is a relative duration, this is a relative frequency, and this is a de-tune, which is to say a frequency offset, a frequency that's added to it. [@] So we're talking about individual sinusoids, which are imitating individual modes at the sound of the bell. [@] So each mode might have a different amplitude. [@] That's actually not acoustically correct because the amplitude would depend on how you struck the thing, but we're just pretending now. [@] So each one is given its own amplitude, its own time constant, its own damping, which, in this example, just because Risset did it this way, is realized simply by changing the overall duration of the amount of time it rings. [@] The correct thing to do, acoustically, would be to have it be a dying exponential and to have it go on forever, but that's not practical, so we just give each partial a duration. [@] So ... first argument is amplitude, second argument is duration, third argument is frequency. [@] Now I have to tell you something else. [@] All these things, well not all these things, but the duration and the frequency are also controlled globally by the controls in the outer patch, which was here. [audio tone] [@] So there's a pitch and a duration. [@] Those are things, which once they've gotten to the right units, will have to be multiplied by the relative frequencies in order to figure out the real frequency to give the partial. [@] So this partial, which has a relative frequency of 0.56, what that really means is that it's 0.56 times the global frequency that I asked the bell to be. [@] So that when I change this frequency the frequencies of all the partials change in parallel. [audio tone] [@] All right. [@] So how do we do that? [@] What that means is we're going to have to take this thing which is being sent and multiply it by this number and that will become the frequency that we send the oscillator. [@] Except I didn't tell you another thing. [@] You get a de-tune in here, which is after you multiply this factor by the global frequency then add an offset so that the partials can be paired in beating combinations. [@] This is all just history. [@] You can read this in books like the book by Charles Dodge. <> [@] Here are 2 partials that have the same relative frequency, but one of them has an offset of nothing and the other has an offset of 1 Hertz. [@] So, after they compute their base frequencies, this one adds 1 Hertz to itself so that it will beat with this one once per second, according to another principle you saw in Music 170. OK. [@] So how do you do that? [@] What that means is that the oscillator that's inside here will get a frequency, in fact, which is 0.56 times this frequency plus this offset. [@] So is that true? [@] So, here we are: [@] Every time we get a trigger we re-compute the frequency. [@] Oh, by the way, the thing is designed so that you hit the trigger and then you can start mousing away at the frequency -- [@] And it doesn't change the frequency of the bell while it's ringing. [@] Which, you know, is one possible way you could design the instrument. [@] It's the way the original instrument worked, so maybe it's a good way for us to do it. [@] OK, so this is $1, this is $2, this is $3, and this is $4. Those are the arguments that we've got as a sub-object, as an abstraction. [@] So $3 is a. .. [@] $3 will come out. .. [@] OK, this, we're just going to store $3, and then when this thing gives us a bang, we will read $3. [@] Oh, this is one voice that I'm triggering now, not the whole bell. [audio tone] [@] And $3 will come out here, it's 0.56, and it's going to get multiplied by a value, which is "receive frequency", <> which got sent from the main patch. [@] And then we're going to add $4, which is 0, which is the de-tuning. [@] And that is the frequency for the oscillator. [@] And all that stuff got done as messages, you can see the thin traces, and then the oscillator then is the first thing in this chain that makes an audio signal. [@] All right. [@] That's the easy part. [@] Well, it's the easy part -- it does have two variables controlling it as opposed to one, but it's easy in the sense that now you just feed it as the frequency of the oscillator. [@] The amplitude control, as you know, things have to get turned on and then turned off, and so the amplitude control has more pussy-footing around setting the amplitude. [@] So I'll show you that next. [@] That's this: [@] ... So the amplitude is being controlled by line~. [@] Now, the amplitude ... There are two things that are being told us that are relevant to the amplitude: [@] One is the first argument of the abstraction, this one here, is the relative amplitude of this voice. [@] And the other is the length of time, the relative duration of the voice, because to know how to do an envelope generator you're going to have to know how high to make it, which is the amplitude that you're going to reach, and then you have to know how long to make it. [@] So here's the line~ that's going to do it, and by the way, I raised the line~ to the fourth power, I didn't say how -- But if you take a signal and square it, then you get the signal to the second power. [@] And then if you take that thing and square it, then you get the signal to the fourth power. [@] And why fourth power, not squared? [@] Just so the thing will really hug 0 and go up like that, because that resembles more the exponential curve that this thing would really be doing in real life. [@] It's just hand-waving. [@] There is no deep psycho-acoustical truth to this that I know of. [@] So what we have to do is configure or confect two messages to line~. This is a little bit like what we had to do for the sampler, except in the opposite order. [@] You have to turn it on and then we have to turn it off. [@] In the sampler actually, we had to do three things. [@] We had to mute and then turn it on, and then turn it off. [@] So this is simpler than the sampler in terms of the sequence of the operations that has to take place. [@] OK. So the attack portion over here is: [@] Look up $1 which is our amplitude. -- [@] The attack portion is just going to go up to the amplitude and do it in five milliseconds, come what may. [@] Why five milliseconds? It's a fast attack but it's not quite a clipped attack. ... Yeah?? [@] Student: What is happening to the dollar sign going in there? [@] The dollar sign? OK. [@] So the dollar sign tells the float to substitute one of these arguments to the abstraction. [@] Student: I mean it's in there trying to get a number? [@] ... Yeah. So $1 gets this one, $2 gets that one, $3 gets that one and so on. [@] Student: It's a "positional argument." [@] It's a "positional argument." That's the correct word for it. [@] Student: OK. [@] A positional parameter? A "positional parameter" ? I'm not sure. [@] So this one, when it's built -- this is going to be float 1. And when it gets a bang, out is going to come the number 1. So this is just going to be 1. We're going to multiply by 0.1 to save our ears. [@] Everything is going to get multiplied by 0.1 in parallel. [@] And then because we are going to raise this to the fourth power ... [@] ... We should probably take the fourth root of this, so when it gets raised by the fourth power, it's the right number. [@] So to take a fourth root, you take a square root twice. [@] And then here, I didn't have to do this; I should have done this. [@] I think in the current context anyway "pack 0 5", which would then take this value and would replace 0 with it and then pack a 5 which would be the number of milliseconds the line would ramp to that value in. [@] But instead, because I had just spent pages in the book describing this $1 madness, at this point it seemed appropriate to put dollar signs in messages. [@] And so this is, "Make a message whose value is this number and then f5." And here it is again -- the distinction between objects and messages and dollar signs: [@] Dollar sign inside an object means "in the context of when the patch is created, you have to build this thing." [@] And so the dollar sign is evaluated when the patch is created. [@] And it's created with these arguments. [@] Dollar sign here <> is in the context of the message that it is sent, which is the thing which causes to send a message itself. [@] So this is in the "run-time context" if you like, and this is in the "build-time context", or something like that. ... Yeah? [@] Student: Why do you need the trigger there when one of the bang has gone through? [@] You don't. The only reason that trigger's there is to make this thing a little prettier. [@] Oh, it's psychological; it's to group these two things. [@] But, in fact, it has no function because you're quite right, this delay would ensure this thing happens after this thing anyway. [@] If only this existed and not that then you would get this: [audio tone] [@] The attack shape of the envelope and no decay shape. [audio tone] I'm going to do this to make it shut up. ... [@] As it is, you do that and then you decay and decaying is actually easier than attacking. [@] It is ... We wait five milliseconds because the attack took five milliseconds. [@] We wait for the line~ to get up to its apex and then we start the decay portion of the envelope, which is: [@] Look up the duration. -- [@] OK, so the attack is five milliseconds regardless of the duration. -- [@] The decay, now, we know what the target is, it's going to go down to 0 so it'll shut up. [@] But what we don't know yet is how long it's going to take in order to get there. [@] That, we have to now compute. [@] So we're going to make a message again, but whereas the message in this case had a constant time but a variable amount that it went up. [@] In this case it has a constant that it goes down to, which is 0, but a variable amount of time to do it in. [@] How do you compute that? [@] Well, after five milliseconds when it's time to start doing this, pick up the value $2, which is this value. ( [@] It's 1 here, but it will be different numbers for the different partials.) [@] Multiply it by the global duration. [@] That was sent to us there. [@] Student: Was it 800? [@] ... Yeah, it's 800. So this duration is 800. But this is now 1, so this is going to be 1 times 800, which is 800 again, so this will be the message "0 800". [@] So that means this thing should last eight tenths of a second. [audio tone] [@] Hard to tell because it dies out inaudibly. [@] Now if I get another one out, this one, this one will be higher and lower. [audio tones] [@] There's a longish one. [@] Here's a short-ish one with a higher pitch and a shorter decay. [audio tone] [@] That's because here, the arguments are ... we're louder. [@] We're a relative loudness of 1.46, relative duration only a quarter as long. [@] So this thing lasts 1 quarter as long as the other one did. [@] Then the frequency is 2 as opposed to this frequency, which was 0.56, so it's almost two octaves up. .... [@] ... Yeah?? [@] Student: Decays can multiply by the total duration message, I'm still confused about that $1. I understand that $2, that's the parameter, but partials, the second one, what's coming out of that? [@] So what goes in here is $2. $2 here is 0.25, so it's going to multiply 0.25 by 800, which is duration, so it will get 200 here. [@] So this will become the message 0 200. [@] Student: And the other one is computed? [@] The other one here. ... [@] I don't know what the amplitude is, but it would be that number 5. So this is 0 200 and blah 5 -- something 5. All right. [@] So if you hear all these things together. [audio tone] ... [@] You get beautiful computer music. [audio tone] [@] There's some psycho-acoustics there, too. [@] You can pick this up; this was in the help browser, "D07.additive. [@] pd" This is the first example in the Pd examples, I think, of something that does multiple voices and there are two others of note here that I want to show you, that I will get to next time. [@] Oh, homework. [@] The homework is just what you've heard done. [@] Do I have the patch that does it? [@] I can't remember. ... Missed it ... Close that. [@] This is wrong. [audio tone] [@] Oh, there it is: [audio tone] [@] Isn't that its own antithesis? [audio tone] [@] So you all know how to do this because it's nothing but a looping sample, you're just going to have to figure out how to get it the appropriate original pitch, but last a lot longer than it would have lasted. [@] And envelope it so it doesn't sound buzzy. [@] So, it's a straightforward application of what I've been showing you the past couple of days. [@] *** MUS171 #11 02 08 (Lecture 11) [@] What I'm going to do right now, is just start with Pd lore and move into modulation stuff. [@] But the Pd lore here, the multiple-voice thing ... This corresponds roughly to Chapter 4 of the book. [@] And then when we get into modulation that's going to be Chapter 5. Designer spectra are Chapter 6. And then delays is Chapter 7. Filters is Chapter 8. [@] So it's all pretty much according to the syllabus -- theoretically. [@] The first thing about that is... [@] I don't know if you guys looked at this or not, but are there questions about how this whole thing works now? [@] So, this what you are looking at is one of these.<> [@] And in this particular situation, I've avoided having leads going into or lines, connections going into and of the sub-patches. [@] I'm using non-local connections everywhere, which are in the form of receive~ and throw~. So one thing that I want to do today is talk about local and non-local connections and what they are good for and how you can make them. [@] Local connections -- by that I mean just making lines between things in a single window. [@] And non-local connections meaning things like ... throw~ and catch~ are some of these -- [@] I'm just going to proceed by example. [@] So, just to remind you: [@] the thing that is most likely to be confusing to you about this patch is an important thing to be confused about -- so that you can try to get unconfused about it over time -- which is the dollar-sign mechanism and how its use spins out differently in object boxes versus message boxes. [@] So in object boxes like this one. [@] "$3" 0.56 because that's what was thrown this thing as arguments when it was made. [@] Whereas message boxes, this $1 is whatever comes down this line because that's what is thrown to it as arguments when that message is passed, which is to say when the message box is sent a message -- as opposed to when the thing was made. [@] The deeper truth is that objects really are messages. [@] These are messages that go to a special factory object if you like, which just makes objects for Pd itself. [@] So there is actually one unified thing in Pd, by which messages get passed down lines and by which also these objects get built. [@] And if you look a little deeper into it, you'll find out that you can use that fact to make patches that change themselves like that -- if you care about that kind of thing. [@] That's the main bit of stuff about this that you might not have known before. ... Yeah? [@] Student: When you were making that abstraction, how would you make multiple inlets and outlets for them? [@] I think the next example will make that clear, and there's some funny stuff about that I have to show you. [@] ... Yeah. --- [@] Actually rather than wait for the next example to make that clear, let me just show you what the answer is and then when the example comes up, you will see it in that context. [@] That might be better. [@] So, abstractions are a form of sub-patch. [@] So, this window is actually inside this box. [@] And you can make this box have inlets and outlets and this window will be able to get the inlets and throw things to the outlets. [@] But you don't have to use the abstraction mechanism to make that be true. [@] So there are two possible ways of having whole patches inside objects: [@] One of which is this way, which is you just name a file. [@] The file's name is "partial. [@] pd" . The other of them is simpler: [@] Let's see, let's make a new patch. [@] And the simpler thing is this -- You can just say, "pd" and then give it a name. ( [@] A name without any spaces in it, as usual, because in Pd spaces are delimiters between arguments.) [@] And now this thing is inside this box -- in the same way as was true with the so-called "abstractions" that you saw in that other example. [@] The word "abstraction" refers to the fact that you are in fact loading a patch into a sub-window as opposed to just editing it yourself into the patch that called it. [@] So here we can do things like this: [@] Let's give ourselves an object and call it an inlet. [@] And that, as soon as I made it, it made one of these things happen <>. And furthermore, if I make more of them, they show up as I'm making them. [@] And the same is true for outlets. [@] Oh, just to confuse matters further, you can have inlets and outlets, but they can come in control and signal varieties. [@] If you say inlet~ and outlet~, then you can put audio signals into and get audio signals out of the inlets and outlets. [@] Otherwise you're doing messages. [@] And you can't mix them, unfortunately. <> That's a limitation. [@] So the other thing about that is, well, all right, let's get a nice number box here. [@] And we'll make a stupid patch, which is, it just takes whatever comes in and throws it out at the output. [@] In fact, I can even do better than that. [@] I can say, oscillate at 440, and I'll make that talk to this. [@] It won't go to this one <> because it's an inlet, not an inlet~. But this one it can connect to <> because that's a signal one. [@] And maybe, if I have the file here <> ... I can say "output~" ... yes! And now we've got a great little, pass-through of a sinusoid voltage. [@] It doesn't work! [@] Oh. Why didn't it work? [@] ... I didn't hear you, but ... yeah. That's it. [@] It's like, duh, let's do this: [@] <> [@] And then we have a little pass-through thing. [@] Similarly here, we've got messages going in, and again, duh, but let's do it. [@] Now we've got that going on. [@] Now, how do you know which is which? [@] It's stupid, but, it's the only possible way you could do it: [@] These things, however they appear from left to right is how these appear from left to right there. [@] So I could do this. [@] And now I've got sort of a little brain-melt device. [@] And you can do that too. [@] That's the only way you could really do it. [@] It'd still work ... in other words, moving things around shouldn't change how the thing functions. [@] And the only way to not change how it functions is to sort of fix it so it functions the same. [@] So it actually switches the inlets and the outlets around in real time as you're moving the objects around. [@] There's no other real way to do it. [@] All right, so that's inlets and outlets, and maybe answered your question about how you figure out which is which. [@] They're proportionally spaced across here. [@] There's one other little thing to know, which is this. [@] If I said Pd and then had a bunch of inlets and outlets like this, (this will happen to you eventually even if it hasn't happened yet) at some point you get to the point where it's just black with inlets and outlets. [@] And then how do you know what you're connecting to? [@] And the answer is really stupid. [@] The answer is, just give it a nice long argument like that, so that they get spaced out. [@] And if the name you gave it wasn't long enough, just add some hyphens to it or something to make it long enough. [@] Some day there'll be a way of controlling the widths, but right now, the width of a box is just the width of the text that it fits into, so if you want to change it, you just change the width of the thing. [@] That's enough of that. [@] So that's inlets and outlets and sub-patches. [@] And the other things that I want you to be able to know is that the, sort of collection of new objects that we're dealing with that have to do with getting stuff into and out of sub-patches, one collection of things was indeed inlets and outlets and, oh, I said tilde but, inlet~ and outlet~. And then there's also, I've already shown you throw~ and catch~, which are things that set up summing buses. [@] The place that showed up was here, inside the "partial" again: [@] The last thing that happens is we do a throw~ to .. and then you give it a name, which is "sum." [@] This is like making a table or making a send. [@] This defines a thing whose name is "sum". And then anyone who wants to can refer to it by saying catch~ and then the word "sum" again. [@] And that in this patch is done down here: [@] "catch~ sum" and then output~. (All right, this can't be earthquakes, this is just vibrations of some other kind.) ... [@] And there's more, probably, which I explained last time. [@] And you can now look it up on the DVD, so I won't repeat it. [@] So I want to move to another example that just shows you how to arrange copies of the sub-patch, which are made using the abstraction mechanism in a couple of other different ways just to give you programming paradigms, if you like, or ways of putting things together. [@] None of these is the sort of "final answer" to how you should do this. [@] These are all sort of alternatives that you will find a personal style that attracts to one or another and so on like that. [@] This one is D07. I think there are two others in the series. [@] Here's a cool trick: [@] This is an added synthesis patch that allows you to draw a spectrum. [@] Why isn't this letting me move it? [@] ... Yeah, there we go. [@] So this is not drawing a waveform; this is drawing a spectrum. [@] So I can do this and get stuff that has plenty of high frequencies or I can do this and get the low frequencies instead. [@] Or, if you like, I can put in formants and I can pretend that I'm making vocal synthesis. [@] Vocal synthesis is more believable if it's moving around in pitch like that. [@] So what's happening here is there must be an abstraction somewhere because we have a whole bunch of oscillators. [@] Each one is playing a partial of this. [@] I think there might be 36 partials in this sound. [@] OK, how do I make this shut up? [@] Over here. Scroll. [@] There! There's an oscillator bank which, just to be on the sane side, I put in a sub-patch and it consists of an abstraction called spectrum-partial of which there are 30 voices. [@] What does the abstraction do? [@] Well, what it has to be able to do is figure out what pitch it should have and then go to this table and find the point which is at the pitch and figure out what its amplitude should be. [@] So what's happening here is the pitches are all determined simply by find out what the fundamental pitch and I know what partial I am I can compute my pitch, but I also want to know what my amplitude is and the amplitude is being set by this table, which I can then change. [@] So this is a way of, I don't know what, it's a sort of a super Hammond organ, if you'd like. [@] So how would you do that? [@] So, again, we're using the throw~ and catch~ mechanism for getting the audio signals in and out; and send and receive in order to get messages in and out. [@] Again, just as in the bell example, we have a problem disambiguating what we're doing so that each one of them can make its own partial and not have all 30 of them make the same partial. [@] So the one that gets the argument 25 should do the 25th partial and so on like that. [@] So you have to be able to do that using the dollar-sign mechanism, that's to say the argument passing mechanism for abstractions, which is that this $1 expands to the number 1, but in the window which is this next one it will expand to 2 and so on like that. [@] So then what are we going to do? [@] One little thing that I should probably say first because it's a detail, but it's a fundamental detail, is this: [@] there's no way in particular in Pd that you can get told when a table changes value. [@] It's something that ought to be there, but just isn't. [@] So this thing does the incorrect thing -- according to computer science -- of polling. [@] That's to say, what it does is -- some number times a second -- each of the oscillators looks at the table in order to figure out what its amplitude should be. [@] From somewhere, which I can show you later, there's a "send poll-table" that has just a metronome sending bangs that are going out (at some 30 times per second I think.) ... [@] Questions? [@] Student: What is moses? [@] Oh, I haven't told you moses. OK, so moses. Here we go. [@] We'll get the help on it: [@] moses is this: you put a number in and if it's bigger than the argument it goes out one output and if it's less than the argument it goes out the other. [@] It's a reference to the Red Sea thing. [@] You can change the value 10 by changing this argument, so if I want 30 to be this split-point then I do that and things 30 and more go this way and things up to 29 go out there. [@] It's also floating point, so 29 and a half goes out there, but as soon as we hit 30 we'll get it out here. [@] So that's moses. [@] moses is similar to route. [@] Route is another thing which takes messages in and puts it out in a different place depending on what the message is. [@] The difference is that moses is restricted to only two outputs, because it's a different kind of a thing, And it only takes numbers, it doesn't take entire messages. [@] So there's moses, which, by the way -- now that I've done that -- I should put on the new objects list. [@] And this one we actually really saw today -- "random" I'm not sure we'll get to yet. [@] Something like that. [@] Good question. [@] Are there other objects here? [@] No, not that I see. [@] I think I told you about tabread4~, which is a signal object which reads tables interpolatingly. [@] Well, you can do it with messages just by not putting a tilde there. [@] dbtorms, I think I told you about that. [@] So what happens here it this thing is getting banged 30 times a second and every time that happens we're going to make a decision about what our amplitude is. [@] Meanwhile, there is pitch to figure out. [@] The pitch is simpler because the pitch is just what got set to by the number box. [@] The pitch of this thing depends. [@] The frequency of the oscillator which is one partial can be computed by looking at the pitch which is sent from this message box out here. Pitch. [@] Now we were looking in the oscillator bank and then we were looking at spectrum-partial 1. There's pitch coming back. [@] Then we do mtof to figure out what is Hertz, but then this oscillator is not going to play at the fundamental frequency, it's going to play at some multiple of the fundamental given by the partial number. [@] So here is partial number 1, so we multiply by 1, but if it was partial 30 we'd multiply by 30 to figure out what the frequency really is that the oscillator is going to play. ... [@] Is this clear? [@] Student: One more time. [@] One more time? So there are thirty of these things. [@] What we're going to do is we're going to make a sound by adding up 30 sinusoids which will be two different partials of the fundamental frequencies that we want. [@] Here's the fundamental frequency. [@] $1 is the number of the partial that we're now looking at, and this number goes from 1 to 30, depending on which of these boxes we're in, in the oscillator bank: [@] 1 through 30. And, I'll do this later but that's the frequency in Hertz which will go down, and all were going to see down there is an oscillator. [@] Oscillator "osc~", times "*~" -- and then there's a throw~ that you can't see but this is scrolled off the screen. ... [@] Other questions? ... Yeah? [@] Student: The moses after the tabread4 ... what does that do? [@] What does this do? [@] Oh, yeah I'll have to get to that. [@] But I'll be in two words and then I'll tell you later: [@] "Basically silence." [@] Zero should go to silence and not just zero dB. [@] So it splits zero off and makes it true zero as opposed to converting. [@] Other questions? [@] Or just general, global cloudy confusion? [@] Student: The "r"'s are abbreviations for "receive" [@] "receives" -- yeah. ... [@] So this is now going to an oscillator and multiplier which is getting multiplied by the gain of this oscillator -- the amplitude of this oscillator. [@] And then it's ... then there's a throw~ down here that you don't see. [@] The fun part is all this stuff where we compute what amplitude the oscillator should have. [@] And that -- Recall, I want to be able to draw that in the table. [@] And so what that means is I should figure out where that oscillator should be in the table. [@] And then do a read in the table to see how high the thing should be above nothing. [@] So how do you do that? [@] Oh ... Choice --This is a designer's choice. [@] What should the horizontal units of the table be. [@] Should they be Hertz or should they be MIDI or something else? [@] In this particular case it turned out to be more effective or more appropriate to put it in MIDI units. [@] So that the table itself, when you look at it, is arranged by pitch and not by frequency. [@] Why? Because if it were frequency you'd be using half the table just to describe everything from 2K to 4K or something like that and then there would be a lot of detail in the lower parts that you wouldn't be able to see because it would be too squashed together. [@] So pitch is better. [@] And I even labeled it here. [@] These are MIDI numbers, which are MIDI pitches, so that 60 here corresponds to 260 hertz. [@] This stuff here is all very low frequency. [@] But up here these are frequencies which are reasonable for formants of a vowel or something like that. [@] In fact I did this so that I could just play with vocal synthesis. [@] So if you want to do vocal synthesis with this you would figure out where you want the resonance of an imaginary vocal tract to be. [@] And then you would put bumps at the points at the frequencies of those resonances and then you would make those -- Oscillators that land at those frequencies would be louder. [@] Alright; is that decently clear? [@] So again if we want these to be addressed in meeting units then what we need to do is after we found the frequency of the oscillator that you want, OK. [@] We're going to get the pitch back. [@] So what's happening here is every time we get a bang in poll-table we're going to figure out an amplitude so we're going to have to then get the value of the frequency. [@] We've seen this before in envelope generator controls where you have a delay, but after the delay you want to set something off with a variable message. [@] The only way to be able to do that is to be able to store the value of the variable that you're going to have to recall after the delay. [@] This is a similar situation where someone gave us the pitch at one moment in time, but someone's asking us to use it in another. [@] So we use a float object which stores the frequency so we can get the frequency back when we need it in order to compute the amplitude. [@] So frequency is changing only at the moment when we change the values in the number box which controls the pitch of the sound, whereas the amplitude is changing on a different clock, which is whenever we go poll the table. [@] 41] Alright; so then we recall the pitch, which is in pitch units. [@] We convert it back to pitch here. [@] The frequency, which is in cycles per second or Hertz, that's appropriate for talking to the oscillator, but for looking up the amplitude in the table we should be indexed by MIDI pitch because that was the more convenient way to have the table be arranged. [@] So we just convert from frequency back to midi, so here we have this kind of odd sequence of steps, which you might find in more than one place actually. [@] Look at a pitch but change it to frequency but then multiply it by a partial number and then change it back to pitch. [@] There are alternative ways of doing that, but that's maybe the conceptually simplest way of finding the pitch of a partial of a note. [@] Alright. [@] Then I'll tell you about this a little later. [@] If whammybar is 0 that means nothing happens here because we subtract 0, but that's a way of taking the whole table and sliding it backward and forward it we want, but it's not necessary. [@] We're going to get the pitch back out and we're going to read a proposed amplitude out of the spectrum table. [@] It turned out to be a good idea to have a 50 dB throw from the bottom of the table to the top. [@] Why 50? Because 50 turns out to be just a good number between very loud and very soft. [@] 100 is too much. 100 is the difference between deafening and inaudible, whereas 50 is the difference between up and down in audio. [@] Actually, if you want proof of that go look at a mixer and go look at the dB scale and you'll see they like a throw of about 50 dB as opposed to 100. Sort of standard mixers, typically. [@] There's the moses object: [@] If we get a positive number out of here. [@] Now, let me show you where that's happening. [@] It's here. [@] So what's being said is if this number's 0 or even negative, if I'm being sloppy about it, we want to get true 0 out so we can really shut it up, at one frequency or another. [@] But if it's positive we want to take that number and consider it as decibels going from 50 to 100. [@] Why 50 to 100? [@] That's because Pd has this sort of informal standard of 100 dB is full blast. [@] That's enforced or suggested by the dbtorms object, where if you say 100 dB it will say 1. It's an arbitrary thing. [@] 100 decibels can be any loudness that you want it to if you're just talking relative levels, but in Pd the convention is to have 100 decibels mean 1, or full blast. [@] So these values go from 0 to 50 on the table, so what we're going to do is add 50 to it to get from 50 to 100 and then we're going to convert that into a linear amplitude and then we're ready to multiply the oscillator by that to make it the amplitude of the oscillator. [@] That happens like this: [@] Get back in the voice of the abstraction. [@] So if it's 0, that's to say if it's less than 1, we're just going to make the amplitude be 0. [@] If it's one or more then we're going to add 50 to it and run dbtorms. [@] So zero comes out true zero, but one will get added 50 to it and then dbtorms will give us roughly 0.003, -50 dB, so there will be non-zero values ranging from 0.003 all the way up to 1. In fact, it's not strictly limited to 1 because if I drew the table out of bounds, above the top, then it would be more than 1. ... Yeah? [@] Student: If you have a negative number going into moses, is that still...? [@] It will still go out this side. [@] It will still give us 0. OK. [@] Then to make it sound good, pack 30 or some value to it. [@] Who knows which value is best? [@] What that does is that will mean whatever amplitude we computed will become the first element of a two-element message with 30 and that will be appropriate to send line~ to multiply by. [@] Alright; questions about that? [@] So now, just getting back to whammybar ... So what's happening here is we're going to look something up in the tabread4. If we want to, in some sense, slide the table over conceptually all we have to do is slide the read point back the same amount we want to pretend the table is sliding. [@] What we would like to be able to do is take the table and move it up and down in pitch, which is to say to transpose the entire spectrum -- [@] Just a good thing to be able to do. [@] To do that, we simply transpose, in some sense, or we offset the value that we use as an x-value for reading into the table. [@] So what's happening then is: [@] if the oscillator is playing at middle C, that's all right. [@] If the whammy bar says 12, that means we look back here, or if the whammy bar says -12, that means we look forward here. [@] Before we look it up in the table. [@] And then, the result is... [@] That the whammy bar does this to the spectrum. [frequency shifting offset in tone] [@] All right, so that's another simple... [@] It's a demonstration of using the abstraction mechanism for making a powerful additive synthesis instrument. [@] If you were doing this for real, like making it stageworthy, you wouldn't want to make yourself edit the table by hand while you were playing. [@] You would want to prepare a bunch of tables and be able to switch them or something like that. [@] That would be a whole thing, to plan out how to you want to do and to learn how to make it playable. [@] So this is only a demonstration of the concept, it's not a real instrument yet. ... [@] Questions about this before I close it and get on to the next thing? No? [@] Closing in on the next thing. ... This was an aside, but should I save this? [@] Oh boy, wrong place. ... so that was the table.spectrum.pd example. [@] Now this is more entertainment than it is actual elucidation. [@] But here's another example of using, oh let's see... [sound of a continuous "falling" note] [@] This is something you've probably heard in Music 170. [@] I think it's correct to call this the famous Shepard-Risset tone. [@] It doesn't sound like much until you listen to it for a while and then it starts to sound impossible. [@] This is of historic interest because computer musicians were able to make this and analog synthesizer hackers were not able to make this because it requires accuracy and control, of a level that you can't get out of an analog synthesizer. [@] And this is not the world's best Shepard tone. [@] This is just me working the studio one night... [tone fades] [@] What it is, is a spin on what you saw last time, which is that the table... ( [@] It is not even using a table, but it looks like a bell curve.) [@] And then the sinusoidal frequencies are sliding from right to left if you like, and moving up, as you heard it sliding from high to low frequencies and working their way up the bell curve. [@] Then back down in such a way that you always hear the descent but you never hear people disappear at the bottom because they're inaudibly quiet at that point. [@] And furthermore, the tones are arranged so that they are each an octave above the previous one. [@] So that no matter what you think the fundamental pitch is or whatever your ear tells you the fundamental pitch is, everybody else is a perfectly good harmonic of it. [@] And so as a result, especially you don't listen to it too carefully and if it isn't too loud, you have this perfectly fused sound that sounds like it has a single pitch, except that the pitch is paradoxical at some points. [@] You have to change your mind about what octave you are hearing it at. [@] So that's the Shepard-Risset tone. [@] How it's done is basically a spin on the other one, but there is more math in it, so I will spare you all the math because it's the same principle. [@] Oh. I did one other thing here but I will show you this out of the next example, rather than this one -- which is: [@] rather than using throw and catch. -- I don't know which of these is better style. -- [@] You can use throw~ inside an abstraction and catch~ outside of it to collect the results of an abstraction. [@] Or, you could do what I call "summing bus" or what I think is generally called a "summing bus" -- which is, each voice adds itself to to all the previous voices so that the output is the accumulation of all the voices, one after the others. [@] It's easier to see what is going on when we do this. [@] By the way here's a reverberator: [@] "rev2~" if you're tired of all those dry sounds in your headphones and want a reverberator -- Grab this guy. [@] I'll tell you about that more in a few weeks. [@] But I will show you how to actually do that in the next example, because it's simpler. [@] The next example is... [@] Oh. Should I do this? [@] No. I'm going to skip that. [@] There's much to know about samplers. [@] Here's a design of a somewhat more general sampler than you've seen so far. [@] The samplers that you've seen so far have been of two flavors. [@] One of which was driven by a line~ object and started with a message that we start reading from a wavetable or an array from a given point to another point over a period of time. [@] The other flavor that you saw was driven by a phasor~ and that was better adapted to looping. [@] This is the sampler that doesn't loop. [@] And it's an elaboration of the idea of the sampler so that you can control all sorts of parameters that can vary one sound from another. [@] So it was even there in what you've seen before. [@] Everything except -- Oh, everything that you see there. [@] It was implicit that you could change the amplitude of the voice of a sample, or its duration: [@] I showed you how to make them turn on and off using an envelope generator, but of course that means you could have parameters that would actually control that, as opposed to just sort of specify it in the patch. [@] The start location, or perhaps you could call it the "onset" into the sample, would be... -- [@] If it was "continuous soft and relaxing," is whether you want the word "soft: [@] or the word "relaxing" -- that's the start location. [@] The "sample number" - I haven't told you about this, but you can direct tabread4~ to choose one of a collection of arrays by name, by sending it messages. [@] Duration you know, amplitude you know. [@] So everything else is just what it was. [@] Now, how do I ... where are the messages that do things? [@] ... I lost the example messages. [@] Well, we can just do it. [@] OK, so you send to a thing called note... [@] In order not to introduce yet another object, I'm just going to say "send note" and send it something. [@] The things you send it are over here: [@] So we make a message which is a pitch, an amplitude, a duration and so on like that. [@] So let's just say, pitch, amplitude, duration is going to be 60, amplitudes and dB 80, duration is in milliseconds. [@] There's a sample number, there's a ... [@] There's sample numbers, start location, rise and decay time. [@] 08] here, so sample number; start time would be the beginning, rise time and then stop time. [@] And nothing happens - oh! Still nothing happens, let me see if I have turn this thing on. [@] Oh yeah, yeah. [@] Come on. [@] There it is! Let me give it a little more juice. [@] OK there's a nice sample. [@] Here, just to show you what's going on, you can change now various things. [@] Here's a different pitch: [tone sounds]. [@] I showed you changing the amplitude before. [@] Here's changing the duration. [@] Here's changing the sample number. [@] Alright. -- [@] There are two samples in there. [@] This is more subtle because this is a bell sound, but I can ask it to play something in the middle of the bell sound instead of the beginning, two seconds later. [@] That's the sound. [@] The rule about bells is that the higher partials tend to fade more quickly than the lower ones, statistically anyway, so if I go into the bell two seconds I'll get a sound more like that than like this. [@] Finally, if I want to change the attack time, say to a second, then I should make this be two seconds long so that you can hear it, then you get. [@] Same thing with the decay. [@] I can make the delay 1000 milliseconds long, now make the note be short, like 100. That's interesting. [@] I guess it sounded different, but it didn't sound different enough. [@] Let's make it 3000 long. [tone sound and fades slowly] [@] While I'm at this, there is always the dollar-sign mechanism for doing things like this. [@] Suppose I want to be able to change the pitch quickly, but just move the rest of the things constant. [@] Do this kind of thing. ... [@] Nice keyboard. [@] Or if I have the voice in there then I can make a thing that played different parts of the voice depending on the number of options there are. [@] This is, again, the message box: [@] This $1 in the context of a message means this value, which is 71, is getting a thing replaced with. [@] Now, without telling you all the gory details, I'll tell you a few of the gory details about how this thing is done. [@] So the first thing to note is -- Oh boy, this is more complicated than it needs to be. [@] The first thing that's happening is, we are making ourselves a bang before all the arguments of the message. [@] So a note is coming in here, and we're unpacking it. [@] Then we are going to pack something which consists of the note, but we're also going to choose a voice number, which will choose which one of the 8 sample voices to play. [@] You've seen this pack and route combination before, in the example from February 3rd, I think ... where I was doing the first polyphonic thing with an abstraction already had this, I believe. [@] So what's happening here is that whatever these seven numbers are, we're going to add an eighth number in the beginning and then we're going to pack it into a message with eight values. [@] Then we're going to route according to the first one. [@] That is going to be a message for the sample voice. [@] Now, the sample voice, this is an abstraction, now, which is made for just for this one patch, is working by adding itself to the previous one, so this is a summing bus again. [@] Now I can show you what the summing bus looks like. [@] There's a lot of stuff here to look at, but I'll start with this. [@] Here's how you make a summing bus. [@] It's really stupid. [@] You just take whatever came in inlet~, and add yourself to it. [@] So whatever you had to do to compute the sample it's getting added to this inlet, and then it's going to become the outlet. [@] If you make an abstraction that's designed like that, then you can just stack them up and put them one to the next. [@] Then they add themselves up into the sum of all the voices. [@] So I'm not going to try to tell you how everything in here works because you'll all fall asleep. [@] But the basic idea is the same as what you've seen before. [@] which is that there's an inlet here which is corresponding to what comes in from the route object. [@] Except that's the second inlet. [@] The first inlet is the inlet for the summing bus. [@] So this thing has two inlets and one outlet. [@] This is a signal inlet which corresponds to the inlet~ you saw, which was the summing bus inlet~. And that gets added to whatever computes and that goes there. [@] Meanwhile in here come messages, one message per note. [@] And each message consists of, what was it: [@] pitch, amplitude, onset, duration, sample number, and then the location of the sample, rise and fall. [@] And then using techniques that mostly you know, but using more mathematics than I've thrown at you before, compute messages that you send to a line~. And I decided to make this a vline~ -- for reasons that I'll try to explain later. [@] But the basic deal is you just work. [@] You make a patch, and eventually messages go to this vline~, which is generating indices into the tabread4~. This vline~ is making amplitudes, and this vline~ is getting multiplied by it to control the overall amplitude. [@] There are two amplitude controls here. [@] And I don't want to give you all the details, because it's just going to be too much. [@] I'm just going to show you this as the overall design strategy for the instrument. [@] And this is explained step by step in the book if you want to see all this in gory detail -- gorier detail than I want to do right now. [@] This is about the craft of making a decent, good, working sampler, which is harder than the basic things that I've shown you so far. [@] So that pretty much concludes the basic tools for making abstractions and how you use the basic mechanisms for doing abstractions, which are the dollar-sign mechanism, inlets and outlets, and the route object, and then all those objects like send and receive, throw and catch -- and the one I haven't shown you yet is the signal version of send and receive, because we haven't needed it yet. [@] Now, change of subject. [@] So that's abstractions. [@] Oh, before I change the subject ... How's the homework going for Thursday? [@] Or that's another change of subject. [@] Should I show you the homework again and see if there are questions about it? [@] I see one nod anyway. [@] Let me do that real quick. [@] Student: Is there going to be an extra credit for this week? [@] I haven't been able to think of one. [@] The thing I thought was going to work as an extra credit just sounded cruddy. [@] And then I could think of ways of fixing it, but they all were much too much work to ask you to do, so I ended up not being able to think of one. [@] Student: OK. [@] OK, so here it is -- just so you can hear it and see it again. [@] Do we want to save, no. [@] So we're done with the help browser. [@] Oh dear, am I going to be able to find this now? [@] ... There. [@] Does it work? [@] ... Yeah. [audio clip plays "soft and relaxing" ultra-slow] [@] So that is -- I think; I'd have to go look -- but it's driven by a phasor, if I remember correctly. [@] No, no, no. -- [@] I didn't do that. [@] I made it driven by a line~, because it was easy to figure out how to do it that way. [@] And basically all it is is a bunch of chunks of a sample that are gradually moving forward. [audio clip plays] [@] And frequency and size are how big the grain is - which, by the way changes the pitch -- is because if you read more of the thing in a fixed amount of time, you get more transposition. [@] The frequency is of course how many of them happen per second. [@] And part of the trick here is, you've also got something that can make actual pitches. [@] So this is a fast way to have a lot of fun with samples. [@] But see if you could just get it to do this thing:["soft and relaxing" ultra-slow] because then you already will have made yourself able to do all the rest. [@] That's clear? [@] That is for Thursday, and I couldn't think of a good extra credit to ask for. [@] The extra credit I wanted to ask for was to make three of them and have it be in a major triad or something like that. [@] But then when you listen to it, it's just hash. [@] You can't actually tell what going on. [@] It's too thick, sonically. [@] You could fix that but it requires things you don't know about yet. [@] The homework for next week - this is looking in the future - is just a simple exercise - well, "simple" ... It's a first exercise about polyphonic voice allocation. [example music] [@] I decided to make something as different as possible from the "continuous soft and relaxing ..." [@] This is no more complicated than it sounds like. [@] It turns out that if you play a siusoid and then make it decay, it has this sort of wet reverberant sound, just because one's used to hearing the sounds of decaying things, and reverberant spaces, I guess. [@] So it has this very sort of drippy sound. [@] Although that's nothing but just plain old sinusoidal oscillators, exactly like the ones I've shown you. [@] If you leave them running it sounds dry and ugly, but then if you turn it on and then quickly fade it out, then it starts sounding like this. [example music] [@] Except -- I should say that you can probably tell -- there's more than one sound happening at once. [@] You wouldn't be able to do this with one oscillator because, in fact, at any given time there are ten of these things sounding at once. [@] This is a 12-voice machine that I've made for this. [@] So what's happening now is there are notes being generated ... There's a speed, which is controlled by a metronome; there's a duration -- exactly as in the Risset bell. [@] So now you can make sort of classic computer-music sounds. [@] And the other thing that I thought was useful immediately was being able to change the bass frequency. [@] This is actually quite easy to do. [@] It's just conceptually fun. [@] It's easier than this last one, I guarantee you. [@] Student: Why is the metronome set up so that larger numbers slow down? [@] It seems kind of counter-intuitive ... [@] OK, so the metro object takes an argument which is the milliseconds between things, so really the question would be why is the metronome object designed that way. [@] It's so that you can get exact values out of it. [@] Since the scheduler works in units of time instead of units of tempo ... If you say, for instance, 1,000 to it it really will come down once every second, but if you're doing tempo then if you say 1,001, what's that a tempo of? [@] It's 59.9 something, but then there would be a round-off error. [@] So the fundamental metro object does that simply so that you can do things that are exact and repeatable. [@] Why didn't I make this thing do the right thing and be 120 be: [@] "120 means two per second", and so on? [@] It's because that would have been making me work harder. [@] You can do it. [@] It's easy to compute what you should feed the metronome to get a specific tempo. [@] You just take the thing and divide it into 60,000 and I could explain why, but what that means is 60 should go to one second, which is 1,000 and 120 should go to 500 and so on. [@] So you're dividing (60,000 by the metronomic value) to get the milliseconds you feed the metronome. [@] But that's adding another step to the homework that you have to do that wasn't really part of the homework or wasn't part of the idea anyway. [@] So yeah, you can do it either way. [@] The one object I haven't told you about that will make this possible ... Obviously there's a sequence of pitches there; I've shown you how to make repeating sequences. [@] But this is even stupider than that. [@] This is just random numbers. [@] They are random numbers with a particular range, which you probably can't hear, but it's two octaves. [@] So how would you do that? [@] This would be the moment to just show you something. [@] Here's a new patch ... font 16 point "OK" and we're going to save it, not here but back in the website since you'll see it. [@] <> [@] Randomness: So this is an aesthetic fault-line in computer music. [@] The word "random" or the word "stochastic" has musical baggage when you use it. [@] So we're going to forget all the musical baggage associated with randomness and just consider this as a technique rather than as a musical statement. [@] So here's how randomness works: [@] You just say "random" and then give it a range <<25 in this example>>. [@] And then every time you give it a bang in, which I'll just give myself a bang object to do now, out will come a number which is between 0 and 24 inclusive, so that there are 25 possible values. [@] Stupid. Usually that's all you do. [@] Every once in a while you have to actually explicitly give it a seed, because you have two of them, and you want them to have exactly the same random sequence as each other. [@] Silly as that might sound, it does happen that you want to do that sometimes. [@] So you can seed these things. That's stuff that you can find out in the help window. [@] But 99 times out of a 100, just the object itself is what you want. [@] And now, for instance, just to make, first off, to make random pitches, do that and add some base pitch. <<"+ [@] 60" in this example>> Oh, right, what does that do? [@] That gives us random numbers between 60 and 84, I think, inclusive, right, 60, 85 -- but 84 really, because this only goes up to 24. And now that could be something that we feed to midi to frequency <>, and then to an oscillator, and then to a output. [@] And now we have Idiot's Delight: [sound of random notes with every click of the bang] [@] Student: Why are there 24 values and you specified "25" to "random"? [@] Oh. These numbers coming out of here range from 0 to 24; there are 25 possible values when 0 is included. [@] And why 25? Because that's two octaves, including the two end points, if you're talking chromatic. [@] Right, if you're talking all the keys, not just the white keys. [@] If you want to work harder, figure out how to make this work only with the keys in a given scale, that would be something that I don't want to tell you how to do right now. [@] You can use modular arithmetic to do it, but you'd have to actually think about music theory to get there. [@] And that would be a thing. [@] So there's randomness. -- [@] Oh, and this is randomness the way it sounded in the 1960's: [sound plays] [@] And while we're here, it's a good point to mention the existence of micro-tonality. [@] That's the difference between this -- Oh, let me just make this be a musical fifth wide. [@] OK, so now we have: [sound plays]. Stuff like that. [@] -- Let me make a nice metronome so you can hear this systematically. [@] And that really wants a toggle to turn it on and off. ... [@] I'm doing this so that I can compare it to another thing: [sound plays] [@] OK, now if you could do it fast enough, you could play those pitches on a piano. [@] Because they are all integers. [@] But if you didn't want integers, if you really wanted to sound like an analog synthesizer, you could do this: [@] Now, random number generators in general make random numbers that are integers, even if it looks like it's making something other than integers, the pseudo-random number generator in the computer is really making integers. [@] So true to that, random really does only make integers. [@] But we can say, "Why don't we have a random thing that goes from 0 to 700?" [@] x And then we're going to divide by 100. [@] Or should I make it 800? [@] Let's do 800 just to be ... simpler. [@] So "random 800" and divided by 100 is the same thing as random 8, except that here a perfectly good value would be 50, and that would turn into 0.5, which won't come out of this one. [@] So this now is [sound plays] , the chromatic version, and this is going to be the micro-tonal version. [sound plays] [@] Can you hear the difference? [@] That's the genuine, almost the continuous collection of possible pitches, as opposed to this, which is [sound plays] ... which is cycling back and forth between the same eight pitches over and over again. [@] So that's randomness and a sort of a note about quantization that might inform how you would choose random numbers. [@] Another thing to think about, another thing that you might want to do here, now that you've got nice random numbers, is use a table to have random numbers that are chosen from a set of possibilities that you might have pre-arranged. [@] And that table you would set up in the same way as you set up the sequencer table from many weeks earlier. [@] And then you could choose randomly from a collection of pitches that you chose, and could even change dynamically, if you want. [@] So now you have easy way to make standard MIDI-art kinds of things. [@] That's randomness, and that is only there so that you can know how to do this, because the only thing that you don't know how to do about this yet is generating all these pitches. [sound plays] ... And all it was was something like this. [@] ... Yeah?? [@] Student: My output box comes out as a slider. [@] How do I get it to come out as a number box? [@] Oh, you've got Pd extended. [@] Someone wrote another kind of output~ thing. [@] You have to go get this one. ... [@] You know what, it's on the website, so if you look at the sample patches from any time in the last week or two, there will be one of these. [@] And if you put that in the same directory as the patch you're working on that will be read first and it will give you one of these instead of the one you're getting. [@] Student: It's on the DVD, too. [@] Oh, and it's on the DVD, too. [@] There's probably nothing wrong with the other one. [@] It's probably better. [@] Alright, done that. [@] Now I'm going to shift gears entirely and start talking about modulation. [@] The first thing to know about modulation is this: [@] this is something I've mentioned before, but not really made much out of. [@] So we're going to make this "4.ring. [@] modulation". Ring modulation is the following idea. [@] This is really, really simple, except you can do a lot with it. [@] Take two oscillators and multiply them. [@] So right now we're just re-creating something you've seen already once. [@] So I'm going to make number boxes to set the frequencies. [@] The first one will just be a reasonable frequency for listening to the pitch A; so it's going to be 440. The second one is whatever I give it, which will be a medium frequency to change the amplitude -- this is like from day one -- and then higher values make the sound split.[variety of sounds with different frequency settings] [@] So there are several ways of thinking about this: [@] One of them is that you know that if you have two different sinusoids at different frequencies that you hear they'll beat together, at least at the frequency they're close. [@] So you can think of that as a sinusoid multiplied by another sinusoid. [@] In fact, it's a trigonometric identity. [@] But you can apply it backward. [@] You can take this thing and make it beat by multiplying it by an oscillator. [@] What that is is it's mathematically equal to two other sinusoids, one at 338 and one at 442. Then if you make this go faster they split further and further apart until you can hear them at two separate pitches. [@] That's a good thing. [@] The good thing about it is not that you can make two oscillators out of one because, of course, you could've done that by adding them, but that you can take anything you want to and do that to it. [@] For instance, let's just do it live: [@] So now instead of the oscillator I'm just going to use the microphone. [@] Risky choice. ... [@] Microphone, microphone ... OK. [@] Does the microphone work? [@] Oh boy does it work! [@] Hello. I'm talking into the microphone. [@] Why do we hear that? [@] Because I haven't turned this on. [@] Hello, hello? [@] This is not good because I'm not going to be able to do anything else than have myself be heard. [@] OK, there's probably a button here. [@] There is a monitor switch; let's use it. [@] Hello, hello? [@] Good. It went away. [@] Alright, so now let's turn this to zero. [@] So nothing comes out because I'm sending sound to the computer, but it's not sending out. ( [@] I had my audio interface on "monitor" before.) [@] Now we turn this on. [@] OK, so this is my voice being amplified through the patch. [@] So now I can do anything that I want to to it. [@] In particular I can make it start beating. ... [@] So now we have "tremolo" ... So if I make a nice long tone then you get that. [@] So now the fun part is: [@] So now we've got nice monster voices from a sixties TV show. [@] What happened there is kind of cool. [@] Whatever pitch I'm going at has not just itself but it has a bunch of harmonics in it. [@] If it was just a sinusoid you would just hear two pitches split off, but, in fact, a harmonic tone is a bunch of sinusoids and each one of them is going to get split off, but they're going to get split off by a fixed frequency deviation. [@] Suppose I happen to be talking at 100 hertz, which is a typical droning frequency for my voice right now. [@] So this thing is going to turn that into 100 + 53 and 100 - 53. Then the first overtone or the second harmonic at 200 Hertz goes to 253 and 200 - 53, which is 147. So if I put 100 hertz in, the original overtones are 100, 200, 300, 400 and then what comes out is 37, then I get 147, then 153, then 247, then 253, and so on like that. [@] And I'm not sure if this is really 100 Hertz [voice changes in microphone] but it's, it's not going to be harmonic it's going to be computer-music. [sings a tone] Oh, you know what, if I happen to hit twice 53 which is 106 then I get a nice harmonic sound again: [sings Aaaahhhh] [@] ... which is an octave down from where I started. [stops singing] Which is cool but if I want to do that in a robust way I would have to figure out what the pitch was and constantly adjust the 53. You can do that; I can show you how to do that later. [@] Student: On the right output, is that stereo? [@] Yes. That's the other channel; I'm only running into the left channel on this mic so there is nothing coming out of it. [@] But then if I do a different pitch [sings tone] You just don't have things that line up in harmonic series so you have something that would be more typical of a bell tone, except I can't make a bell sound because I would have to make my voice envelope like that and I don't think it's physiologically possible. [@] But it's a thing that's an inharmonic spectrum as the spectrum of the bell might be. [@] If I took that: [sings tone] and sampled it and then enveloped it I could make bellish sounds maybe. [@] Or crude bellish sounds I should say. [@] This is actually a very general and powerful technique even though it looks stupid. [@] You just take anything that you want and multiply it by an oscillator and it takes the frequencies and slides them both to the left and right. [@] With very carefully designed filters you can actually separate the part that slides to the left from the part that slides to the right. [@] But that is stuff from Chapter 8; you don't get to see that just yet. [@] As it is, it is already pretty powerful. ... [@] Questions about this? [@] So another example would be; lets make a very simple computer music instrument: [@] So now I want to make, in the simplest possible way, a sound that has some interesting overtones that's just made out of an oscillator. [@] So we're going to be doing all of this stuff again. [@] Except I'm not going to do it to my voice; I'm going to do it to an instrument. [@] So let's design the instrument first. [@] The instrument is going to be... [@] We'll take an oscillator and then just act stupid with it. [@] We're just going to clip it between some decent negative value and some decent positive value. [@] OK and now I'll just play this now so you can hear it: [@] Whoa, nothing. [pause] [@] Whoa look at that, that's not going to work. <> [oscillator works] [@] Oh OK that's not so exciting is it? [@] Let's drop this a little bit. [@] There we go. [@] Now what's happening, I showed you this before in a different context. [@] All we're doing is were taking the oscillator which is a sinusoid and clipping the bottom and top. [@] That's a very simple waveshaping kind of way to make a different kind of waveform. [@] And that by the way -- that's a big topic which I will give you some mathematics about in the next couple of sessions. [@] But right now I'm just going to do that and have it be a nice sound. [@] Alright. [@] and now this sound that we have I want to take and "ring modulate". So now we have the same sound but now [with additional frequencies] sound that's being modulated. [@] That's not a very good choice of frequencies. [noise] So this is a very fast way of making inharmonic spectra out of harmonic ones. [@] And this you know, it doesn't look like much but if you listen to electronic or especially computer music of the last -- especially actually the period 60's through 90's -- This is going to suffuse everything because people got very excited about being able to make inharmonic spectra having been imprisoned largely to harmonic spectra plus an occasional bell for most of the history of music. [@] So people made music-theory kinds of thoughts about how the inharmonic spectra could mix and whether there could be consonant or dissonant intervals between sounds that didn't have pitches but had just spectra like this:[sounds] [@] And so that's a rich source of musical inspiration that was brought on by the electronic and the computer music eras. [@] So this is the sort of general direction that we'll go in now. [@] Having seen the multiple voice thing, the abstraction mechanism. [@] The next thing is learning how to design sounds using the techniques of modulation and waveshaping. -- [@] which are represented here by this multiplier and this clip~. [@] *** MUS171 #12 02 10 (Lecture 12) [@] So this is now Chapter 5 of the book. [@] Oh, let's get the book out while we're at it. [@] What happens now will correspond pretty closely to the material in Chapter 5, so that you theoretically can actually find out by looking in the book, what's going on. [@] Which has not always been true up until now because I have been operating in a exploratory, make-patches-as-you-go mode. [@] But, now that the basic notions of how to make patches and figure out what they're doing have been covered. [@] I'm going to try to be a little bit more, whatever you call it ... a little bit closer to the written thing in the book, because that way it'll be much easier for you to make correlations between the book and what's going on in the class. [@] So nothing in the book is actually wrong. [@] Nothing in class has been terribly wrong, as far as I know, either. [@] But there haven't been perfect correspondences. [@] In fact, people who have been writing, have been making looping samplers for today's homework have been looking in the book to figure out how to do the enveloping. [@] The book does it differently from how I did it in class, so that you now know two different ways of doing enveloping and you might not know how they're different -- which I'm not going to try to clear up right now because it's too weird. [@] But what I do want to do is start referring to stuff in the book as I go through the next few patches, because it's just going to make the next thing a little easier than it would have been otherwise, I think. [@] Book ... So the place we're at is this chapter on modulation, and I'll get to this in a second. [@] But to talk about modulation, you have to talk, or be ready to talk, about spectra. [@] So think about things as having spectra and I'll tell you more about the words that one uses to describe spectra in a moment. [@] But first I will go back to the patch that I was working just in the last 15 minutes of the class on Tuesday, and go into somewhat more detail about what patch is actually doing and why the sounds that it makes sound the way they do -- in a very hand-waving kind of way, before I show you more quantitatively what's going on. [@] So here's the patch up. [@] This is the fourth patch from last class, and I just realized this morning I haven't put these patches up on the web. [@] I'm sorry, I haven't done that comment-and-put-it-up-on-the-web thing. [@] So you haven't seen these patches except in class so far. [@] Basically, what happened in class was... [@] The first thing was take a microphone and multiply the microphone signal by an oscillator to mess up its periodicity. [@] And then it was time to go back and explain a little bit more carefully what was going on. [@] And so, to do that, I had to make a thing that had some kind of wave form so that I could then multiply that by a sinusoid and mess it up and show you how you can think about that. [@] There are many ways of thinking about it. [@] So here's the patch again, cleaned up. [@] Basically, the patch on the left is something that you saw in week one or two, which is about clipping and what it does to wave forms. [@] So if I show you that, this is a nice, clipped sinusoid. [@] Oh why don't I fix it so I can clip as I please, so that you can see how that's going. ... [@] So, for instance, if I tell it the top of the clip is going to be 1, then we're, what we're doing is we're allowing the thing to go down to -0.2... Oh, that's just for, just to be clear, I'll put it in the -0.2. Now the value's going down to -.2, but all the way up to 1. And if I made this thing be -1, then you would see the original sinusoid that didn't get clipped. [@] And this is an example of waveshaping. [@] It's taking a perfectly good sinusoid, or in fact, some other thing, but the first thing to think about what happens to a sinusoid when you do this to it and putting it through some function or other. [@] If the function were linear, or a Y=M*X + B kind of function, then you would just get a sinusoid out. [@] It would have a different offset and a different amplitude. [@] But if you give it some kind of nonlinear function -- in particular, the function that is represented by clip~ -- then out comes something that's quite different. [@] The function that clip~ is giving us right now, if you graphed it ... OK, so clip~ ... right now it's clipping from 0 to 1. ... [@] If you clip from 0 to 1, you can think of that as a function with a graph. [@] The graph looks horizontal. [@] For negative inputs, it's zero. [@] From zero to one, it follows the input, so it looks like Y = X, and then, starting at one again, it's flat again, and one. [@] And so it looks like a sloppy step function. [@] So it's not linear. [@] And if you -- you'll see this in gory detail later, but the basic deal is that -- when you put a sinusoid through a nonlinear transfer function, as we call it, then what comes out as not a sinusoid. [@] And when it's not a sinusoid, then it has a spectrum, it doesn't have just one partial in it. [@] I guess that's almost a tautology. [@] So what comes out of the oscillator here is repeating itself every 110th of a second. [@] In other words, it's repeating 110 times a second. [@] So, since this is just a function, it doesn't have any memory in it, what comes out is doomed to repeat at exactly the same period, if not even less. [@] In other words, when the oscillator gives you the same value at two different moments in time, the function has to give out two similar values, too. [@] So if you put a periodic function in to clip~, you're going to get a periodic function out, with the same period. [@] So, what that means is that if you listen to the original sound, it has a pitch: [tone] Low A. [@] And when you listen to the result of clipping, it's got the same pitch. [tone] [@] But it's got partials. [@] This is a special case, actually. ... [@] Oh, I showed this because it's simple, but it's got a very strong octave just because of the way it, happened to be set up. [@] And if I do something like that, then you'll hear... [tones] [@] Just basically what you heard before, except it has a different timbre, which is to say it has different partials. [tones] [@] And this is basic, this is how in electronic music, you make... [@] Well, this is one, this is the most generally used thing in electronic music that I'm aware of, for making things that have partials that have strengths that you try to control in one way or another. [@] But in order to control them, you have to do math. [@] In order to do it, you just throw something into a nonlinear function at will and you get it out. [@] The history of this is that guitarists in the '40s and '50s started actually not over driving their amps, but messing up their speakers. [@] I believe the first example of distortion guitar was some jazz guitarist who decided to take a knife or a pencil maybe, and just bash the cone of his amplifier speakers, so that it would sound fuzzy. [laughs] And it works! [@] In a very loose way of speaking, what that's doing is making the amplifier no longer be a linear thing and start being a nonlinear thing. [@] In other words, it's a thing where you put two signals in and what comes out is not the sum of what it would have been for the two signals separately. [@] And anything that has that kind of property has the ability to infuse new frequencies into the sound that might not have been present there before. [@] OK, now, it's time probably to start talking about spectra and more graph-y, graph-y/comprehensible way, so that I can now show you something about what's actually happening. -- [@] Before I do that, I have to finish showing you, we've just finished reviewing, or bringing back out the patch from last time, because I didn't show you the other thing that you can do. [@] So here's the... [tone starts, stops] [@] ...thing that has partials. [@] And here's a thing that has partials... [tone] [@] ...that is also being ring modulated. [tone stops] [@] And what I did was, what I played you before was, sounds like this: [tone] [@] Well, not quite like that. [@] More like that. [tones stop] [@] Sounds where you would take some sound in and just destroy its periodicity by... [tones start, stop] [@] Basically multiplying it by the wrong sinusoid. [@] Well, "wrong" -- a sinusoid that has a different period from the sound of the original, from the original wave form that's getting graphed. [@] But of course... [@] So here's the wave forms that we're putting in. [@] Here's this: [tone] [@] What this is doing is taking this nice wave form and sometimes sending it through positively, sometimes sending it through negatively, and sometimes going through zero when it's doing its main work. [@] And you just get a funky sound, a funky waveform like that. [@] It's artistic. [@] Now, of course, it would be true that if this sound happened to be periodic, with the same period that we started with: [@] Now, it's still an interesting wave form, but now the wave form looks periodic. [@] And in fact, it has the same period as the sound that we just modulated. [@] Way different waveform, but the same period. [@] Or to listen to them, here's what we just modulated: [tone] [@] Sorry, that's the signal that was that sinusoid clipped. [@] And here's the same thing, ring modulated: [tones alternating] [@] So now you can imagine taking... [@] Oh, I didn't tell you the rest... [@] OK, so now let's try 660. [tones] [@] Let's leave it on .. try different multiples of 110. [varying tones] [@] Oops. Sorry. Can't type that well. [@] So let's leave it here, and I'll show you that... [@] turn it off for a second. [@] OK, now we've got something that... [@] Hmm, still got the same period. [@] It can't help but have the same period because both of these things -- although this thing has six cycles within the same period of time, which is 1/110th of a second, it's still true that after a 110th of a second, it's come back to where it was. [@] It just happens to be the sixth time it's done that. [@] So, it's still true that every 110th of a second, which is about this length, both the clipped oscillator here and this oscillator, which I'm multiplying by -- that's the ring modulating oscillator -- both of those have, have come back to where they were before. [@] And so we still have no choice but to have a signal which is periodic... [@] Well, a signal which repeats every 110th of a second -- which, except for in special cases, will have... [tones start, stop] [@] Will have the same pitch as the original that we started with. [tones] [@] So there's the sinusoid. [@] Here's the clipped sinusoid. [@] Oops [tones start, stop] [@] And here's the clipped sinusoid times ring modulation:[tones start, stop] [@] When you learn how to do this, or when you learn how to think about this, you can make literally almost anything that you want. [@] There are all sorts of tricks to, well, mental tricks to try and figure out what you do, in terms of what kinds of functions and what kinds of things to multiply to get specific kinds of effects. [@] And so, first off, I want to show you more theoretical aspects of just, what's happened to the sound from the point of view of the spectrum. [@] And then I'll go through and start working on actually building spectra, according to desiderata out of this tool box. [@] 44] Those are the subjects of Chapters 5 and 6 of the book. [@] Probably, this will take a couple weeks. [@] So, the first thing that we need in order to be able to discuss this intelligently, is to be able to look at spectra of signals. [@] I'm going to just ask you to take a certain thing for granted, which is that you can measure the spectrum of a signal and graph it. [@] What I can do is make a sort of definition of what the spectrum of a signal is. [@] Let's see where is my ... There. [@] I'm going to ride roughshod over some of the details here. [@] This patch is in "Audio Examples." [@] This is the first patch in Chapter 5. This is a patch that says, "Sorry, but we have to do these spectra." [@] When it's time to actually measure the spectra of things using a patch and understand how that thing is being done, that's in Chapter 9 of the book. [@] So, what we're doing is we're borrowing results from the future, in order just to be able to see spectra. [@] And, what do spectra look like? [@] OK, so, signals have waveforms and signals have spectra. [@] What I've done here is just made a very simple additive synthesis instrument that does this: [tones] [@] ... There's a frequency coming in here -- it's just a standard receive. [@] And we're multiplying this frequency by the numbers 0 through 5. Why 0 ? [@] -- For completeness sake, and in order to explain a very strange thing about the spectra of sinusoids that I can't hide from you. [@] I just have to explain it. [@] So, I'm going to come out with it, right at the beginning. [@] And, so, the ones that you can hear are fundamental, octave and so on, like that, right?[tones] [@] Now what we can do, in this patch anyway, is we can start graphing the spectra and the waveforms of these things. [@] So, here's the fundamental. [@] It has a waveform, which is just a sinusoid of the appropriate frequency, and it has a spectrum which, one graphs. [@] There are various ways that you can do this, but one can graph it in terms of the partial numbers, that's to say, the multiple of whatever the fundamental frequency is that we're playing at.[tones] [@] ... Yeah, I don't know what order to tell you this in ... So, let me just make another spectrum and play it for you, or, show it to you. [tones] [@] Here, now, I've turned the first, second, and third and fourth harmonics on, and so on like that. [@] Now here's the funny part. [@] I can turn this partial on that doesn't have any sound, because it's just constant, because it has a frequency of zero. [@] It adds something to the spectrum, too. ( [@] By the way, my computer's gagging right now; but just let it gag.) [@] Now, there's a weird thing that will basically just kind of bite you once in a while when you're trying to do something and something comes out wrong: [@] A sinusoid that happens to have a frequency of zero, you can assign it a strength in the spectrum, but the most correct way to assign it strength is to give it a strength of 1 as opposed to 1/2 for the other sinusoids. [@] That's to say sinusoids of nonzero frequency. [@] Chapter 8 will explain why, for the first time. [@] I'll tell you what it is for those of you who like mathematics or know about mathematics: [@] Sinusoids actually have two frequencies in them; one positive and one negative. [@] They don't act like quantum theory, where all the frequencies are positive. [@] They can be real-valued and the only way you can have a real-valued sinusoid is to have positive and negative frequencies of equal strengths and negative ... equal strengths -- talk about the phases later -- and negative frequencies. [@] So, really, although I don't show it on this table, this oscillator has a peak at frequency 1, relative frequency 1, and a peak at relative frequency -1. You can't perceive it but it's there. [@] And, the reason this is double is because here, those two peaks coincide. [@] For those of you who've gone as far as, maybe, second-semester calculus, sin(omega t) = [( e^(i omega t) + e^(-i omega t) ) / 2] . [@] -- In other words, a sinusoid has two complex exponentials and each of them has an amplitude of one-half. [@] <> [@] So, if you don't want to know the equation, here's what it looks like. [@] This is the truth. [@] And there's no possible way that ... well, you can sort of pretend it's not true by saying, "Oh, it's just frequency zero and we'll just make it the same height." [@] But, all of the stuff that we try to do later will be wrong if we do that, because DC does come crawling into signals and if you don't account for it correctly you will get wrong answers. [@] That's the thing about the spectra of sinusoids. [@] Oh, yeah and while we're here, this is worth looking at: [@] When you turn all the partials on, you get a wonderful thing which is called a "pulse train". Or I believe this is the Dirichlet kernel. [@] It's a collection of sinusoids, all of which have equal strengths -- except that this one is double because of funny stuff. [@] But, anyway, this is just DC, which I was just talking about, the height of the thing, the DC amount of the thing, which we could make arguments about. [@] The more partials we put in, the more close this will become to a perfect pulse train. [@] Engineers will actually talk about infinitely thin pulses, which consist of all the possible harmonics. [@] You wouldn't do that in computer music, because some of them would have higher frequencies than the Nyquist frequency, and they would fold over and you would have trouble. [@] So, you don't make pure pulse trains in computer music. [@] You try to make band-limited pulse trains, that's to say, pulse trains that only go out to a certain number of partials, in order to have your computer be able to deal with it. [@] And this is what those pulse trains look like. [@] I'LL turn a couple off so that you could see the progression. [@] Here's a pulse train with three partials, actually, 0, 1 and 2. And then the more partials that you throw on of equal strength, the skinnier and taller the peak gets, and the more wiggles -- "ripples" the engineers WOULD call that -- you will see between pulses. [@] So, that's a pulse train. [@] That's just a qualitative thing to know about, because you will see pulse trains again in the future. [@] Now, the reason I'm telling you this is to be able to tell you what happens when you do things like apply a non-linear function to a sinusoid or multiply some complicated spectrum by a sinusoid. [@] Now, the next thing I'm going to do is... [@] I'll stick to these, and then I'll start telling you more of the whole truth later. [@] (I'm going to save this, you probably can't do this, but, if you're actually writing the thing, you can save your own help files. Let's see. Help. Browse. ...) [@] Now we're going to look at "E02.ring.modulation" ... [@] Ring modulation; now what I'm going to do is make a nice "spectrum-knowledgeable" -- is that the right word -- pep speech about ring modulation. [@] So here, now, what's happening is the following: [@] We're going to go back, and we're going to look at our nice bunch of sinusoids that has a nice spectrum,like this. [@] Oh, yeah. [@] I can actually ask this one to graph repeatedly on a metronome so that I can change things live. [@] This is idiot's delight now. [@] I can make funny spectra and look at their waveforms in spectrum. [@] Now, what we're going to do, gee whiz, we're going to multiply this thing by an oscillator. [@] The oscillator is going to have a frequency, and - I'm cheating a little bit about the frequencies here. [@] Because, to make it very easy to analyze, I'm choosing a frequency that's a simple multiple of the sample rate. [@] So, I'm not going to talk about exactly what the frequency's values are, just relatively. [@] So, if I say in "f/16" -- if this is the frequency f, if I say (- Oh, can we hear this? [@] Let's listen to it. ... Yeah.)[tones] [@] OK, now we're hearing it, and now, if I say, "Well, let's make this thing be eight." [@] Oh no wait, let me get this: [@] Now we have a sinusoid, and now we're going to start multiplying it by an oscillator. [@] And, as you know, what that does is that splits the sound up into two frequencies,because that's what ring modulation does to sinusoids, as described last time. [@] One way of thinking of that is, beating is the same thing as having two neighboring sinusoids. [@] It's a mathematical formula. [@] But, it also means that, if someone gives you this: [changes a tone], and says, [@] "Give me two of those, and make them be split in frequency," -- you just multiply by a sinusoid that has non-zero frequency and you get that: [new tone playing] [@] Oh, and by the way, now you see why it starts to make sense to talk about negative and positive frequencies. [@] Because, in fact, this thing has negative and positive frequencies in it and that is why this peak that you saw split into two peaks. [@] It's because the negative frequency of one, by multiplying with it, drops the frequency, and the positive one added to the frequency. [@] And, furthermore, when I set that frequency to zero, [@] The two collide and then I get that.[original tone but louder] [@] Now, I'm playing tricks with phase here. [@] If I do something like make these two beat against each other. [@] I just asked this thing to do one-hundredth, one one hundredth. [@] Now, we have the two things beating very slowly. [@] And, what you have is, from one point of view, two sidebands that are separated, but, from another point of view, you have an amplitude that's changing. [@] In fact, now, I can say, "Multiply it by an oscillator frequency zero." [@] But, I no longer have the good situation where these two add up. [@] They add up wrong. [@] Why did that happen? [@] Actually, there are two reasons why that happened. [@] This is sometimes called "interference." [@] This is an interference effect, from one point of view. [@] These two things have phases, such that, when we combine them, depending on when you do it, depending on exactly when you combine them they might have different relative phases. [@] And then, when they add up, they won't add up to twice the amplitude. [@] They'll add up just to some amplitude or other, which might be anywhere from zero to twice, depending on whether they interfere constructively or destructively. [@] Student: You said the multiplying oscillator will have frequency f/16? [@] That's just my pedagogical choice of decent step to use. [@] Student: How do you set it? [@] So, the patch is computing this thing called "frequency step," and it's actually setting that to a fundamental over 16,and that's hidden in some sub-patch. [@] Probably in here. [@] And the only reason I did that was just so that when you go into the patch and start mousing on it, you get decent range. [@] There's nothing special about 16. -- Now how could I actually make this thing behave itself? [@] Maybe I just can't now. [tones] [@] Good. So I just tried again and got a better match. [@] So we can now pretend that the thing's in phase again. [@] So then, it follows that if you had a few other sinusoids, [tone changes].. (Here's why I used 16 so that you can see the original spectrum and you could also see the splitting and they would appear on the same picture and with reasonable spacings.) [@] Now I'll say, let's make the frequency step be 1/16 again ... or rather 2/16. And now what we've done is we've taken each one of those three peaks and split them separately into side bands. [@] Let me shut this up for a second and talk about that. [@] This process, if you think of this as a function of what goes in -- so a signal goes in and a signal goes out, and so what's happening is it's some kind of function. [@] That's in a loose way of speaking. [@] It's a linear function. [@] In fact, it's nothing but times tilde. [@] But it's times tilde times a signal not times a scale or a thing that's changing in time. [@] That's a linear operation. [@] What that implies -- It implies many things, but for right now what that implies is that if you took two signals in or here three signals in and added them up...( [@] oh, yeah. [@] I didn't tell you this did I? [@] If you hook a bunch of signals into a single inlet, they are added automatically. [@] I think I mentioned that at one point, but maybe it's a good moment to say it again.) [@] So this is now multiplying the sum of these things by this original oscillator. [@] Now I'm talking about linearity. [@] One good thing about linearity is that, in this case, given to us by the distributive principle. [@] If you call this thing, I don't know what, call these things A, B, C, and F here, then F(A + B + C) is the same thing as (F x A) + (F x B) + (F x C); and that's the distributive rule. [@] And what that is saying here is that if you take two or three signals and you superpose them, that's to say add them, and then multiply them by this modulating oscillator, you get as a result the sum of what you would have got putting them in individually. [@] This was not to be taken for granted. [@] So here what you saw was that we had (-- oh, I turned it off) [tones] [@] We had originally this signal going in and if you multiply by an oscillator of frequency zero we see at least a multiple of that coming out. [@] And it turns out that although I didn't have to be true, the result of ring modulating this is the sum of the result of ring modulating the individual ones. [tones] OK. [@] Is that clear? [@] Examples of things that are linear in this way, obviously, multiplication although here we're multiplying by something that's not constant in time. [@] And the other example that you'll see later is filters. [@] Well, I introduced a filter quickly but I haven't told you about filters in detail. [@] But filters also are, at least in their usual form, are things that are linear in the sense that you put two signals in and you will get out the sum of what you put in individually. [@] As a detail also, any kind of linear function like this, you can multiply the input by some constant. [@] For instance, double the input or multiply the input by i or anything else that you want and what comes out will be that many times stronger or weaker than the signal went in too. [@] In other words, linear things respect changes in amplitude and will give you the same relative changes in amplitudes on output. [@] In general, that's not true of nonlinear things. [@] What's a nonlinear thing you've seen very recently? [@] Student: Wave shaping is it? [@] ... Yeah, the wave shaping example. [@] This clip (oh, where did I put it?) [@] This clip tilde operation was not linear -- and as a result, let's see... [@] well one thing that happened about that was the oscillator that you put in (I haven't said enough to explain this well yet)... The oscillator that you put in, if you change it's amplitude you will not just change the amplitude of the output and give you the same thing louder. [@] It will give you a different signal altogether. [@] So I'll go back and belabor that point with you in a few minutes. [@] So this is ring modulation and oh, right, special case again: [@] What happens if we pull the zero frequency signal in? [tones] [@] So now we have the same thing as we had before except I threw in frequency zero which has double amplitude. [@] And now when I start modulating that, it does the correct thing which is again, it gives me two side bands [tones] each of which has half the strength but, of course, the original was twice as high. [@] And also, this one we only see one of because the other one is negative frequency. [@] And it's even worse than that because, and this is hard to see very well, but as I start pushing the frequency of modulation up ... [tone changes] oops, oh yes. [@] A funny thing happens when you hit a half -- so 8: [@] Now what's happening is the original signal had peaks here, here, here and here. [@] So, (oops, I pulled the table over but I didn't pull the labels over. [@] They might be useful later. [@] Like that, OK.[tones] [@] So, if I modulate it, that is to say, multiply by an oscillator of half the frequency, this thing gets a side band up here and this one gets a side band that is halfway down and those two will collide. [@] And when they do, they will superpose. [@] And furthermore, depending on the phase, they will sometimes superpose into something stronger and sometimes superpose into something weaker. [@] And now the next funny thing is... [@] let me turn the DC off. [@] Actually, let me just have one of them again. [@] OK, so here's the nice original signal. ...[tones] [@] OK, so now we'll start pushing the frequency up. [@] Then we'll split it into two partials again. [@] And as we keep going up, what's going to happen when we hit zero? [@] Well, we're going to keep going, but we have a doppelganger who is going to come back the other way. [@] So what you saw, if you just sort of think of things in terms of characters, is this peak just bounced off of the vertical axis. [@] What happened mathematically might better be described as you don't see the negative frequencies, but there is also a peak here and a peak there. [@] And this peak kept on charging towards the negative as they were getting split further and further. [@] But the one that was already negative charged back the other way and turned to positive. [@] And there is a special case right when I ask the thing to modulate it so that it goes to zero frequency. [@] Oh, I didn't do it right. [@] Oh yes, that is 32: [@] Then we get a different strength again because now we have two peaks. [@] Again, the negative and the positive frequency peaks coincide. [@] And now we get another situation where the phase is controlling how the two act. [@] So here again, depending on the phase, we'll get one or another strength. [@] Oh dig! I almost got it turned off. [@] And that's just what that is. [@] If you want to control that exactly, you have to control exactly the relative phases of the two things that you're multiplying. [@] ... Questions about that? [@] So in general, ring modulation, sometimes people use to mean multiplication by any old thing. [@] But ring modulation in the simplest sense is "multiplying by an oscillator that's putting out a sinusoid." [@] What it does: if you give it a spectrum that just can be described as a bunch of peaks, is it takes each peak and splits them. [@] And furthermore, as the peaks go further and further away from the original, sometimes they bounce off of the zero frequency. [@] And meanwhile, when any two peaks coincide, they coincide but they don't necessarily add amplitudes. [@] They do something -- bound only by the triangle inequality. [@] So, to make you the nice full picture ... [tones] there's kind of a typical ring modulation output spectrum. [@] And if you wanted to really go into it, this is several, this is two and change times the fundamental frequency. [@] And so the DC peak got thrown all the way out here and meanwhile all the other peaks got sort of scattered around in that particular way. ... Yes? [@] Student: Can you say something more about negative frequencies? [@] Well yes, negative frequencies... [@] In general, what ends up happening -- Everything, for technical reasons, ends up being symmetrical about the frequency zero. [@] So that anytime you make a negative frequency you hear it as a positive frequency. [@] So the general rule is that the frequencies you hear here are the frequencies that went in plus this frequency and minus this frequency. [@] Except that when you compute the frequency minus that frequency, if that is a negative result, flip it around to positive, take the absolute value of it, take what you would get. [@] Now I want to talk taxonomically about spectra a little bit more so that I can have more terms to tell you more qualitatively what sorts of things you can get out of this. [@] Now this is all still just what happens when you multiply a signal by a sinusoid. [@] So one thing that your ears told you was that here, when we multiplied by this sinusoid ... (oh, I think I have to just turn this all off. [@] I'm not sure I'm going to be able to get rid of this all together. [@] Let's see...) [@] OK, so what happened here was when I told it to multiply by a decently low frequency sinusoid, and by the way, I chose the same frequency as the frequency of the thing I'm modulating by, then I get something like that in the waveform and I get something that ... I can't show you the spectrum of this in this patch right now, but it sounds not terribly different from the original sound, which is something like this.[tones] [@] But as the frequency goes up, the sidebands are being pushed further and further out. [@] Furthermore the sidebands that are negative are getting pushed further and further out, furthermore, the sidebands that are negative are getting pushed further and further out because they're wrapping around. [@] And that becomes more and more true as you go up, so that you get sort of a knot of frequencies that gets higher and higher. [@] Unfortunately, you can't just use this in its current state to make a nice sweeping filter kind of effect. [@] Because if I slide this from 660 down to 550, it was harmonic at the outset and it's harmonic at the end, but it goes through a whole bunch of inharmonic results intermediate. [@] You have to do something smarter if you want then to be able to make continuous changes between these. [@] Now, to show you something about how you can predict that. [@] You have to go make more pictures. [@] But now, it's better to show pictures, that are just dead pictures in the photo, as opposed to this live demonstration. [@] So, here, first off, talking about spectra. [@] I've been using some terms without defining them, and other terms I want to define right now. [@] In general, a spectrum ... a spectrum, at least for our purposes, is going to be a description of how strong the frequency content, or how strong a sound is at all the possible frequencies. [@] This is what a ... this is something that you could talk about it, for a sound or for light. [@] This is a representation that ignores time. [@] So, right now, we're just going to sort of pussyfoot over the fact that time is changing and this spectrum could be changing in time, which is not a mathematically correct thing to talk about, but which is in fact the thing that you have to talk about when you're talking about sounds, because they do change in time. [@] So, we're just going to forget about that, for now, and we'll deal with that a little bit later. [@] Or maybe we'll let Tom Erbe deal with that in Music 172, I'm not sure. [@] So, the basic deal is that spectra consist of a description of how loud the various frequencies are that make up a sound, but there's a more fundamental distinction, which is, is the sound to be regarded as being made up of a discrete set of frequencies, or in fact is it a continuous frequency thing like white light, or like noise. [@] So, in sound land, you can make ... you can -- by either playing a string instrument or whacking a bell -- you can make things that have, perhaps an infinite but at least a countable collection of frequencies in them, and if you restrict yourself to the Nyquist frequency, there will be a finite set of them. [@] Or, you can have something like noise, which I haven't told you much about yet, but noise could be better described as consisting of a solid mass of sound at all frequencies. [@] And, the distinction there, is between a discrete spectrum, like these two, and a continuous spectrum, like this. [@] This looks like a dense discrete one, but I'm trying to describe a continuous one there. [@] I haven't even shown you how to make noise yet, but just type noise~ into an object and you'll get noise, but you won't be able to do much with it yet. [@] So, noise is available. [@] Noisy sounds -- which are also sounds that you would get just by regular operations like this -- are sounds that you can't describe as being objects that have a fixed set of vibrational modes that sit there and vibrate and you can listen to them. [@] For some deep reason, your ear loves things that vibrate in modes, and is built to be able to separate sounds that are distinguished by the fact that they have different modes of vibration in them. [@] You can argue about why that would be, but it might have something to do with being able to hear people speak. [@] Because there are modes of vibration that you set up in your throat, and your throat makes noise, and you can use that modality to hear someone speaking over background noise. [@] Your ear has been very well-developed to do that, and that hearing facility, but I think was probably originally for listening to voices, turns out to be what makes music possible as well. [@] Music in the sense of things that have pitches. [@] So, continuous noisy spectra are things that aren't described that way -- aren't described as things that just have modes that vibrate, but rather things that generate sound because of heat or whatever, some kind of random motion, as opposed to a vibrational motion. [@] I'm waving my hands pretty much -- both metaphorically and physically here. [@] So, that's the difference between a discrete spectrum and a continuous spectrum. [@] And those two terms are not exactly accurate uses of mathematical terms. [@] If you happen to have a discrete spectrum like this, oh, whether you have a discrete or a continuous spectrum, you always have ... you can always pretend that you have a thing which is called a spectral envelope. [@] Which is an imaginary curve that you draw over the spectrum to describe what the spectrum looks like as a shape, as opposed to ... as opposed to what? [@] Well, OK, so the spectral envelope is this line here, or this ... what do we say, this curve here that I drew. [@] Which actually is the same curve for all three of these examples. [@] The envelope is in some sense, an idealized description of what the spectrum looks like shape-ishly, as opposed to in the details of where the frequencies are. [@] So, to speak very loosely, the spectral envelope is in some ways related to the timbre of the sound in a way that's independent of the positioning of the frequency components which make the sound up, which could be discrete or continuous. [@] So, this would sound noisy, and this would sound pitched. [@] And this would sound -- oh, yeah, right. [@] Next thing: [@] If you have a discrete spectrum - that's to say a spectrum that can be said to be consisting of a bunch of different frequencies that you can just write out, so that they'd be finite, up to a finite frequency - then you can say, "Is it a harmonic or an inharmonic spectrum?" [@] What that is saying is, "Are the frequencies that we see multiples of a fundamental frequency?" [@] These terms are loose because we're talking psychoacoustics here, in some ways. [@] But, for something to be harmonic, it's frequencies should be multiples of a thing that you can hear as a pitch, which means maybe above 50-ish Hertz and below 4000-ish Hertz. [@] That's hand-wavey, too, because you can hear pitches down to 25 or 30 Hertz, but it gets harder . If it is true that all the frequencies that you see are multiples of some fundamental that looks somewhere between 50-ish and 4000-ish Hertz, then, multiples, then you can say this is a harmonic spectrum. [@] And, if you took such a sound and looked at it as a signal in time, you would see a repeating waveform. [@] So, there's this great fact about repeating waveforms, which is if you look at their spectrum, you will see a harmonic spectrum. [@] And the frequencies present in the spectrum will all be multiples of a frequency which is the fundamental frequency, which is [1 /(period of the repeating waveform)]. OK? [@] And that's acoustics. [@] Oh, and for interesting reasons, both a cylindrical air column and a string stuck between two things, turns out to make harmonic spectra, because miraculously enough, the various modes of vibration of either an air column or a string are all multiples of the fundamental frequency. [@] Student: It's integer multiples, right? [@] Oh, thank you. Integer multiples, not just multiples. ... Yeah. [@] I probably have been saying "multiples," meaning "integer multiples" all day. [laughs] This is why you need two mathematicians in a room. [@] The mathematician's worst enemy is unstated assumptions. ... [@] Inharmonic spectra are spectra whose component frequencies are not describable as integer multiples of a good fundamental. [@] And that would be typical of, say, a metal object that you whack and vibrate it. [@] A metal bar, or a bell, or that sort of thing. [@] Solid, vibrating objects that aren't strings I guess tend to have this effect. [@] So, we saw a patch that imitates a bell, the Risset bell patch. [@] And, if you look at those frequencies, the point five six and the one point four, I think, those are not all integer multiples for one good candidate for a pitch, and so, as a result, you hear an inharmonic sound. [@] You can ascribe a pitch to it, but it's a different thing from a harmonic sound. [@] And, if you look at it in time, you wouldn't see a repeating waveform. [@] So, the spectral envelope is a handy way to determine, or just describe the shape of the thing. [@] Then in the shape, you can color it in with either a harmonic or inharmonic discrete spectrum or with a continuous spectrum. [@] And, that's not a complete description of sound, by any means, but that's a working description of sort of a first layer of distinctions that you could make between different large classes of sound for making brutal distinctions. ... [@] Questions about this? ... Yeah? [@] Student: You know ...we aren't not talking about enharmonic, right? [@] Because last week we talked about inharmonic. [@] "Inharmonic" means it's not harmonic, right? [@] ... Yeah, and anharmonic, I don't know what it means. [@] I ought to. [@] I mean, etymologically, it means ... [@] Student: It's like techno transposition in notes. [@] It's like C-sharp to D-flat. [@] Those are enharmonics? [@] Student: "En." [@] Enharomonic's, E-N. [@] Oh, E-N. [@] Oh, oh, oh, oh, oh, yeah. [@] OK, I'm from Tennessee, where we don't make differences in pronunciation between E-N and I-N. [laughter] [@] ... Yeah, sorry. [@] So, yeah, I don't know about that term at all. [@] That's a music term, and I don't have a license for talking about that kind of stuff. [@] Student: So inharmonic just means it's not harmonic right? [@] It's a different term. [@] ... Yeah, yeah, it just means "not harmonic." [@] And then there's "anharmonic," which means, "doesn't know about harmonicity," but I'm not sure how you're supposed to use that term, so I stay away from it. [@] So there's that. [@] Now to go... actually, let me stay here. [@] Now, using that language, I think I have to go to the next thing ... I'm going to skip the equations, and reach for another picture. ... [@] This is stuff that I just described to you being shown in a good text-y way as opposed to a demonstrate-y way. [@] This is non-moving pictures that just show peak-splitting because of multiplication of sinusoids, in all of the cases. [@] But, what I really want to do is get down to this picture, yeah. [@] Here, now, is a way of thinking about what happens to both the frequency content and the spectral envelope of a sound when you ring-modulate it. [@] So, we're taking a sound here, and for the sake of argument, I'm starting with a harmonic sound, and I'm not assuming that the sound doesn't have a zero frequency component, because that might be a useful thing to have in the sound. [@] And, anyways, some things will get it, regardless of whether we wanted it there or not, for reasons that will show up later. [@] Now, we will take that and multiply it by a nice sinusoid with a low frequency -- a frequency that's small compared to the fundamental frequency of this harmonic sound. [@] And, this is now showing the spectrum of an imaginary harmonic sound, right? [@] So, then what's going to happen is, oh, let's see. [@] So, all right. [@] This peak turned into that peak. [@] This peak turned into these two peaks here. [@] There and there. [@] This one turned into these two peaks here and here. [@] This one turned into these two peaks here and here, this one turned into these two peaks and this one turned into these two peaks. [@] And then, either to clarify or to obfuscate the matter, I'm not sure which, I tried to draw a spectral envelope through all the peaks that wraps around through zero frequency. [@] In other words, the peaks that were going down, I drew one part of the curve through, and the peaks that are moving up, I drew the other part of the curve through. [@] In order to describe really, in order to try to represent really the fact that what we're looking at is just the positive frequency portion of a thing, which has negative frequencies as well, but happens to have symmetry about the zero frequency axis. [@] But we can see that, although we lost amplitude here, well, we lost amplitude, but we also got extra peaks. [@] And you could talk about the power, and blah-blah -- That will come. [@] But by and large, the spectral envelope of this is something like a constant times the spectral envelope of that, and we could argue about whether this spectral envelope should be regarded as a half of this one, or just equal to it, because there are more peaks here. [@] And nobody will ever tell you whether throwing a whole bunch more peaks into something should mean that you should make the spectral envelope look higher or not. [@] No one knows how to talk about that. [@] Spectral envelope is a completely imaginary concept, only useful for trying to make descriptions like this. [@] And the good thing about this way of representing it is that it works when you start talking about modulating by, or making the modulating frequency be very high. [@] So, the thought experiment here is that we're taking this signal and multiplying it by a sinusoid, exactly as in the working patch that I showed you, and now we'll make the sinusoid we were multiplying by be so high that it's actually higher than most of the peaks in the original signal. [@] So here is the modulating frequency here. [@] This is the thing that DC turned into. [@] And this first partial turned into these two. [@] Now, that was these two, but as we pushed this thing further up, this one got pulled into zero and bounced off it, and now became two positive frequencies. [@] And furthermore, this thing pulled most of the spectrum with it, except for this very last peak, which is still ... this peak here still hasn't "wrapped around through zero," as some people say, but it's still positive. [@] So now what we have is a radical change in the spectral envelope. [@] We took the spectral envelope, but thinking of the spectral envelope as being a ... as extending into negative frequencies as well as positive frequencies, we're taking the entire spectrum envelope and hauling it out into some different place. [@] Furthermore, if this modulating frequency happened to be chosen to be a multiple of this fundamental, then all of these peaks would land on multiples of the fundamental too. [@] And again, we would get something that had this as a fundamental. [@] It just would have a radically different spectral envelope. [@] Which would be the spectral envelope unfolded and then pulled out. [@] And that is why that thing sounded the way it sounded ... that thing being over on the separate page. [@] That's what's happening when we're doing this.[tone] [@] Oops. That's this: [tone] [@] What we're doing now, is we're taking this signal, which has whatever spectrum it has, and we're multiplying it by something whose fundamental frequency is seven times the original fundamental, that's pulling it way out into high frequency land, and meanwhile, now we're hearing it and its mirror image. [@] And you can do this with anything. ... [@] Questions? [@] --- Oh, right. [@] The other thing about that is, here is the waveform, if you want to see that. [@] This waveform also does the right thing as you multiply by ... here's a low one, and here's a very high one: [@] As you multiply by a faster and faster sinusoid, our original thing which looked like this, turns into a more and more wiggly waveform, which is also consonant, or in agreement with, the fact that we're hearing progressively higher and higher frequency content, even though we're not really hearing this pitch as such, the pitch of this frequency. [@] Student: If you're supposedly clipping at negative 0.2 then how come you can see frequencies below? [@] Isn't it clipping everything below negative 0.2? [@] That's not a frequency. That's ... [@] Student: Amplitude. [@] ... Yeah. That's an amplitude. [@] So, oh right. So here, why do you see things below there? [@] It's because we're multiplying by this oscillator, that ranges in value from +1 to -1. And so, these large negative values are when the original waveform was up high, but then got multiplied by -1. So this is minus 0.2, which is getting multiplied by this sinusoid, so it's ranging from minus two to positive two, because this is ranging from 1 to -1. [@] ... This is stiff medicine, I know. [@] OK, but if you get your head around this stuff then you can make all kinds of cool sounds, so it's good to be able to do. ... [@] As a, not quite a "slight aside" ... OK, here's a sound.[tone] [@] If I happen to choose not... [@] Oh, let me go back to, let me go back to 110. [change tone] [@] All right, here's this sound. [@] What would happen if I said not 110 and not 220, but halfway between them, which would be 165? [change tone] [@] It goes down an octave which, let me graph it for you. [@] What now is going to happen is that every other waveform of this is going to catch this, being negative what it was before. [@] And as a result, it'll be whatever it is followed by itself upside down, followed by itself right side up, and so on. [@] And one way to think of that is that it then has twice the period, because you have to wait for the right side up one to repeat, which takes twice as long. [@] So that would explain why the pitch went down by an octave. [tone] [@] See, here's the original: [change tone] [@] And here's that: [alternating tones] [@] And furthermore, over here, one can explain that by... [tones] [@] Come on, that was kind of cool. [@] So, let's make this 8. [tone] [@] So here's the original sound. [tone] [@] And here's the sound being ring-modulated by something an octave below, - that's to say half the frequency. [tone] [@] And now we've got... [@] Not only did we get the thing down an octave. [@] But we've got a thing that only has odd harmonics. [@] We have 1/2 and 3/2 and 5/2 and so on -- times the original frequency. [@] Because each peak, the peak that was 1 times the original frequency -- became 0.5 and 1.5. The next one became 1.5 and 2.5, and so on. [@] And all the side bands crashed into each other to give you, again, the same number... [@] Well, the same number +1 of partials as we had originally. [@] Roughly the same spectral envelope, because we're ring modulating by a relatively low frequency and so, because of this picture, we didn't change the spectral envelope very much. [@] But we changed the placement of the partials. [@] And in particular, as a special case, we replaced the partials with ones that are placed at an octave below but odd harmonics. [@] So that's a thing that you can do with ring modulation. [@] If you only knew what the pitch of someone's voice was, or the frequency of someone's voice was -- the fundamental frequency -- then you could divide that by 2 and multiply it by their voice and you would drop their voice down an octave, and you would roughly be respecting the spectral envelope of the original voice. ... [@] So, since that's a good thing to be able to do, let's do it. [@] That actually shows up in another one of these examples. [@] ... Yeah, this is the example right here. [@] So, with apologies, here is our favorite radio announcer:[tone] [@] Oops. Let me get rid of this. Shut up. Let's get rid of this now. [tone stops] [@] All right, now "Continuous soft and relaxing..." can come back. [@] OK, I haven't told you about this ... but there are objects in Pd that will try to determine the pitch of sounds. [@] One is called fiddle. [@] Oh, "looper", yeah. [@] This is just a sample looper, just like you know about. [@] There's the sample, we've got a phasor. [@] Not even doing anything special, I'm just multiplying the phasor by 44,100 and then reading the table. [@] Very sloppy. [@] And then we're hearing this: [@] Recording: "continuous soft ... continuous soft ..." [@] And then if we take that and figure out what its pitch is, using the wonderful fiddle object... [@] And by the way, maybe we should... [@] This is pitch and amplitude pair, there's stuff to do here that I would have to describe fiddle to tell you how to do in detail, but you get the help window for fiddle and see it. [@] But anyway, it's pitch and amplitude pairs that we'll unpack to just get the pitch. [@] Then we use moses to get rid of pitch estimates that are 0, because that meant it just failed to find the pitch altogether. [@] And then we have a nice number, which we can convert from MIDI to frequency and then we can multiply it by a half. [@] So that's... [@] So you take the fundamental frequency of something and multiply it by a half, you're an octave down. [@] And then, that can be the frequency of an oscillator that we will multiply by the radio announcer. [@] And then I, just to make it louder, I multiply by two, and then you get this. [@] Recording: "continuous soft ... continuous soft" [@] See, here's the original. [recording starts, stops] [@] And here is the octave down, but only odd harmonics: [recording] [@] And then if you want the whole thing, you add them together. [recording] [@] This is, the funny thing about this example was... [recording] [@] The fellow's voice actually goes all the way out 50 Hertz anyway. [@] So first off, we're giving fiddle a real workout. [@] But second, the frequencies that you hear coming out, could be going down to 25-ish Hertz, which are just monstrously low, even for this guy. [recording] [@] The other thing to know... [@] OK, so the general rule is "Multiply by oscillators with relatively low frequencies, you maintain roughly the spectral envelope, but change the the component frequencies." [@] And as a result, you heard... [recording] [@] ...the same vowels coming out as the original. [@] You can... [recording] [@] It's intelligible speech still ... I don't know how you, I'd have to give you some real speech so that you'd, so you could decide whether it's intelligible or not, because we've heard that so much that, who knows what it is now in your ears? [@] But at any rate, it would be intelligible speech if you put intelligible speech in, because the spectral envelope is roughly speaking preserved by multiplying, or ring modulating, by a relatively low frequency sinusoid. [@] It didn't move things around very much in distance, but it changes the component frequencies. [@] The other thing, or an other thing that you can do is say, "OK, let's just multiply him by an oscillator that is 15 times the fundamental frequency." [@] Now, what that'll do is that'll take whatever he's got and throw it up into, well... [@] So, if he's going, he's ranging from 50 to 80 Hertz, so that times 15 is... [@] Something like a kilohertz to 1500 Hertz. [@] That's taking all the nice, those nice low frequencies in his voice and turning into things that aren't low frequencies, right? [@] And then you get this. [@] Let me turn the original off.[recording] [@] So now you can get, not exactly chipmunking but aliasing ... And still, you can sort of persuade yourself you hear the same pitches. [@] And actually, this is also good to add to the original. [@] Then you get... [recording] [@] This is sort of monstrous. [recording] [@] Something that, I don't know, the sound of someone talking through a paper plate, or something like that. [@] OK, so that's... [@] ... Yeah?? [@] Student: So is this how the octave dividers from the '60s, the pedals they had back then worked? [@] Or is it different altogether? [@] I'm not dead sure about this, but I think what they did was something simpler, which was, they assumed the incoming sound was a sinusoid and they put it through a triggered flip-flop, a D flip-flop. [@] Student: OK. [@] And that would be electronics. [@] It doesn't work as well when you do that. [@] But on the other hand, if the guitarist is very careful, he can get it to behave, OK? [@] And there's a wonderful solo in Led Zeppelin to prove it. [@] This is much easier to get to work than that ... and if you've tried any of those old pedals, you'll know what I'm talking about. [@] Oh, and another thing about it is that this only works with a monophonic signal. [@] If I gave this a signal that had two different pitches in it, as if, for instance, if you played two strings on an instrument together, this wouldn't be good for dropping that by an octave. [@] For this to work, we're assuming that the signal coming in is periodic, or almost periodic. [@] Otherwise, it'll do something else. [@] Put another way, it's a perfectly linear process, so to two strings it will do exactly what it does the individual strings, added up. [@] Except that -- you've got to choose one pitch to modulate it by: [@] Which of the two pitches of the strings you're going to choose? [@] So you can get one of the strings to go down an octave, and the other string turns into something else. [@] So that's just a sort of a cheap thrill with ring modulation. [@] OK. ... [@] So are there any questions about this before I go back to the original example? [@] ... Yeah? [@] Student: Can you explain how the modulation makes the frequencies co-incide? [@] OK. I can show you that happening here, I hope. [tones] [@] Oh, wait, let me turn this off now. [@] So now what's happening is, as I increase the frequency of the oscillator that modulates by, each of these things... [@] each of these things turns into two side bands. [@] If I want this side band to crash into this side band to superpose with it as one frequency, I would make this thing be exactly half of the fundamental, so that each one of them would come halfway over and then they would meet. [@] And that, we do this way: [@] Oh, there: [@] Student: So if you put in 24, would that all sound similar? [@] ... Yeah, you're right. [@] Except, again, now, OK, so 24, let's see. [@] We're doing half integers times 16, right? [@] So 8, 24, 40, 56. I can't do, oh, 72? [@] ... Yeah, there we go. [@] Now 88, right? [@] As opposed to the multiples of 16... Turn it off. [tones stop] [@] OK, so again... [@] Oh, actually, changing this by a multiple of the fundamental even, of the fundamental frequency will give you another spectrum that, which lies down on the same frequencies in some sense as the other. [@] In other words, if I start adding or subtracting multiples of the fundamentals of this, I'll make other spectra which will line up with the spectrum I just got. [@] And that could be the original frequency if these are actually integers, or it could be half the original frequency if those are half-integers or something else inharmonic, if they were something else, like three.[tone] [@] Now I can make more spectra with these frequencies by adding 16 again, which is... [tone] [@] Which is being normalized to one. [@] So one to 35... [tone] [@] 35 plus 16, anyone? 41? ... Oh, 51. Thanks. Ooh, sounds better. [@] 41 was wrong, right? 51's good. [@] And so on, like that.[tones stop] [@] Are there questions about that? [@] ... OK, next matter. [@] This will go on until we're done, I guess. [@] This is going to go on for, probably about four lectures' worth. [@] I should say, there aren't very many things to do; there's just lots of ramifications of a very small number of things. [@] So really, all we're doing for the nonce is taking oscillators, running them through non-linear functions, and then multiplying things together, sometimes adding things together. [@] It's now perhaps time to go back to this original clip example.[tones] [@] This is a clip of sinusoid, and, by the way, you know this already, you can now get timbres by changing what you clip by. [@] That's these waveforms here. [@] If you were smart, you could harness that to give yourself a collection of timbres, all of which are harmonic. [@] If you do it right, you can start talking about things like, "What's the relative concentration of energy in low versus high harmonics in a sound like that?" [@] That might give you ways of making qualitative changes that you'd want in spectra. [@] What happens when you do this? [@] The only way of describing what happens when you do this that is easy to understand-- well, there are two things that are easy to understand; one is that clipping is distortion. [@] That people understood perfectly well in the 50's and 60's. [@] The other thing is that you can also think mathematically about what happens when you apply non-linear functions to oscillators. [@] The simplest non-linear function that you might want to apply would be simply squaring. [@] Where we're going now is we're going to work ourselves up into functions by just talking about polynomials-- that's to say, the original signal, which is itself, it squared, it cubed, it to the fourth power, and so on. [@] It turns out that it's very easy to analyze what that does to the frequency content of things. [@] Then, if you get a more complicated function-- if you can approximate it with a polynomial-- then you can come up with a description of what the non-linear function does. [@] Furthermore, if you're smart, if you want to do something, you can dream up a polynomial that might do that for you -- or make a function that it approximates -- Apply that function, and get a desired effect. [@] We'll start out inductively by saying, "Here's an oscillator..." ... [@] "Save-as" now <> So, now we're just going to try the simplest possible thing, which is to take the original signal and square it. [@] Let's see if we can get rid of this, so I can show you this and the clipped one, and give you these for comparison. [@] To square something, all you have to do is multiply it by itself. [@] Now, squaring things does funny things to their amplitudes. [@] If I took this thing and doubled it in amplitude, then, after I squared it, it would quadruple in the amplitude. [@] This is a thing which does not respect changes in amplitude. [@] Well, it respects it in the sense of getting louder when it gets louder in some sense, but other than that, it doesn't do the thing that you might wish. [@] It does something better. [@] Here's the original oscillator, which I want to graph for you: [@] Here's that oscillator squared. [@] Here the period is about a half of the table, and here, if I show the thing squared, it changed. [@] It's still a sinusoid-- I can prove that it's still a sinusoid - I can play it for you. [@] Here's the original: [tones] [@] And here's that signal squared [tones] . Isn't that interesting? [@] Furthermore, that agrees with what we see. [@] Here's the sin of omega t, where omega is the angular frequency, and here is the [sin of omega t]^2 Actually, let's say [cos(omega t)]^2 There's a relation which says that the cosine squared of theta is half of the quantity (one plus the cosine of two theta.) [@] That was Algebra II, I think, right? [@] So, everyone's forgotten it. [@] It's a special case of the master trigonometric identity for computer music, which is cos(A) times cos(B) is a 1/2 [cos(A + B) + cos(A-B)] That's the thing that describes ring modulation, and it also describes what's happening here. [@] You see that the half is the fact that it now ranges in value from zero to one. [@] It's now one-half plus a sinusoid of amplitude of one-half, and that sinusoid has twice the frequency of the original sinusoid. [@] The reason it sounds just as strong is psychoacoustics; it's because your ears are much more sensitive to this frequency than to that one. [@] At some other frequency range, it might sound a little quieter. [@] *** MUS171 #13 02 15 (Lecture 13) [@] Here's a sequencer [musical tones] of which I've made a simple example. [@] I'm sorry, this is a little boring because it's another 16 tone sequencer. [@] But this one, if you listen to it carefully [musical tones] acts (not quite ...) like an analogue synth. [@] You can't really get an analogue synth to do this exact thing but you can get kind of close to it. [@] I'll slow it down. [@] musical tones] The basic deal is the timbre of the sound is changing during the life of the sound. [@] So it doesn't just go beep, beep, beep like a Hammond organ; the sound is brighter at the beginning than at the end. [@] It actually... [@] I can slow it down some more: There. [@] So you can hear how the sound is brighter at the beginning than it is at the end. [@] Now, there are two fundamental ways in electronic music that one does this -- of which you know one. [@] The one that people reach for, if they are used to working in studios, is a filter. [@] But I haven't told you about filters yet and I might not even be able to tell you about filters in this quarter depending on how things go. [@] The other way is by waveshaping -just the technique that you've seen so far. [@] Those of you who've played electric guitars probably noticed that if you put your amplifier in overdrive then the volume control on your guitar is actually a tone control because the more you saturate the amplifier the more brilliant the tone becomes in some sense. [@] That's the same technique as what computer musicians call "waveshaping." [@] And that's what's happening in this patch here:[musical tones] [@] So this is just nothing but a sinusoid going through a skillfully chosen transfer function -- not that skillfully actually. [@] And the thing that changes the timbre of the output is -- just changing the amplitude of the input. [@] So if you... [@] Well, I'll show you this in the patch. [@] But the basic trick to making timbres with music using computers, the simplest way of doing it is called "waveshaping" where you take anything that you want which you presume is some kind of periodic function (but the sinusoid is perfectly good), control its amplitude, and then pass it through a non linear transfer function. [@] And then probably control its amplitude again so you can turn the thing on and off. [@] Then the first amplitude control actually changes the timbre of the sound. [@] And I can prove it my example. [@] Oh, actually, before I prove it by example, what I'll do is start this back up and show you what the controls are that I put on it. [musical tones] There is of course the speed control. [@] The duration ... [@] You all know how to make envelope generators. [@] Envelope generators are just line~ objects with messages that turn them on and off, which you saw in the polyphonic example. [@] Actually, the homework that is due this coming Thursday has an envelope generator in it, which you need in order to be able to turn sinusoids on and turn them off in the way that ramps in time. [@] So this is that same thing almost: [music] [@] It's actually a monophonic instrument. [@] There's no polyphony in here at all, which is therefore more what like what an analog synthesizer would have done. [@] The sequencer is nothing but looking up a nice table using a metronome, and modular arithmetic to go through the table, exactly like in the previous example, I think. [@] And the timbre variation is happening just using an envelope generator. [@] And I'm not even bothering to control the amplitude except right at the output here. [music] [@] And this is just change in the timing on the wave generator. [music] [@] And it's useful to be able to change this. [@] And that's it. [@] That is the whole thing. [@] And you know you can turn this thing on and run the tape and sound like Morton Subotnick sort of -- not quite exactly. [@] The extra credit example is similar. ( [@] Actually, I'm sorry this is not as imaginative as I was hoping.) [@] It is the same extra credit as during homework three. [@] But homework three was almost impossible to do. [@] Did anyone actually do the extra credit for homework three? [@] That was the eight-note sequencer where every third note had to have a different timbre? [@] Which was just hard, right? [@] I hope it was. [@] It was hard for me, so I hope that it was hard for you. [@] If you do that but drive it with a metronome, everything becomes a great deal easier. [@] You just didn't have that way of doing things before.[music] [@] So now it is very easy to do this kind of stuff. [music] [@] And all this changing now, I am not having to do any weirdness about turning oscillators on and off; that is just changing the parameters that go to the envelope generator that is controlling the thing, which I am going to define later as the "index of modulation." [@] That is, the amplitude of the sinusoid that you are putting into the waveshaping function. [@] So that is homework number seven, which is due on the 24th, a week from Thursday. [@] You of course are all still working on homework six, and that's cool. [@] But I want to show you that, so that you will have some context or some sense of direction as I show you again painfully or what do you say, didactically through the ABC's of waveshaping. [@] This is the the most popular. [@] If you look at waveshaping in it's most general form, it's probably the most popular way there is making timbres with computers. [@] And so there is a fair amount to know about it. [@] Although, there is a great deal more not to know about it because, it turns out that in most situations, what waveshaping does is mathematically very difficult or intractable to analyze. [@] So, you can use simple examples, to sort of guide your way through designing instruments. [@] And then when you're designing real instruments, the simple examples will give you intuition but they won't give you exact answers that apply to complicated situations. [@] So the example that you've already seen is this one: [@] take a sound, clip it from any two numbers, I think I was using -0.2 and 1, and then listen to it. [@] And out comes a sound that's clearly not a sinusoid. [@] One observation -- Oh, let me show you the other function that you've seen first and then make an observation, actually, two observations. [@] First observation is the very simplest one which is, how would you make a time varying timbre using this technique? [@] And the answer is just what I said, take this thing and multiply it by something that varies in time, so multiply it by the output of a line~. ... [@] So we're going to multiply this by the output of a line~ and then clip it. [@] And the line~'s going to be control. [@] Let's see, in this case just a plain old linear control is going to be good so I'm just going to take whatever I have and pack it with a decent interval of time and just make there be a number box. [@] Let's have it in hundredths though. [@] And now we have, this is not going to be great or anything like that, this is just going to be sort of basic. [@] So the oscillator itself, of course, when I multiply by nothing, nothing comes out. [@] So if I multiply by say 0. 1, here's the oscillator. [@] Oops, it's very quiet. [@] Oh, I'm going to cheat and make it louder at the amp. [@] I'm not sure that's a good idea or not. [@] We'll see. [@] Oh, sorry. [@] I don't want to do that. [@] I'm doing something stupid. [@] This is how to teach yourself how powerful your amplifier is, but I don't want to know how powerful this amplifier is. [@] I'm dividing by a hundred! I did not want to put zero point one, I meant 10. So now I'm going to go back, turn this down and do this right. [@] So 10. There we go. [@] Sinusoid, right? [@] Now you all know this, but as I turn this up if I put 100 here this is multiplying by one and therefore I would get that sound: [@] And, of course, sounds in between. [@] Here are sounds in between. [@] So now I have the very simplest possible whammybar that would control timbre. [@] Right, oh yeah and it of course if it's negative, negative amplitudes are the sum of its positive. [@] So if I was doing this in a way that, if I were doing this for someone to use I would make this thing have a range. [@] Like I don't know zero to 500 so that it won't go negative and then I can have this. [@] This does not work. [@] Computer music instrument. [@] This is a little dull but it's only dull because well the main reason its dull is because there's only one function so far. [@] Right, so what can you do with this? [@] First off let's try other functions besides clipping. [@] So I'm going to just copy this clip functions so I can get it back later. [@] And meanwhile I'm going to do stupider things like for instance take the signal and square it by applying it by itself. [@] And now I get nothing and as I turn it on I get and as I showed you last time it goes up an octave. [@] Because when you square something well there are two ways of thinking about this, why that happens. [@] The way I told you last time is oh it's just a trigonometric identity. [@] The square of the cos(omega t) is nothing but [cos(2 omega t) + 1] / 2 -- Which means if you square a pure sinusoid you will get something at double the frequency. [@] If you take the sound of your guitar and square it you will not get a thing that is an octave up. [@] That only works for pure sinusoids. [@] A guitar signal or any other kind of real signal which you record will have overtones and those overtones will when you square them will not just get squared individually they will look at something else. [@] Meanwhile I should tell you something else about this which is this is good but in general with non linear transfer functions. ( [@] Oh let's get the actually while I'm here let's get the clip thing back. [@] I can leave this here and have the clip too.) [@] So I'm going to put this over to the clip thing and I''m going to make another output obviously so you can listen to that too. [@] Minus something plus something I don't know. [@] Now let's hear it [@] Oh yeah turn this up so were clipping now. [@] Now here's the thing about that: [@] If you take two oscillators and give them two different frequencies and add them. ... [@] (By the way I mentioned this once in passing and I should have mentioned it again: If you connect two signals to an inlet they will be added.) [@] Now if I want to give this thing say something else a fifth up so let's get this at 325 oh, no, Oh right, it's, yeah. [@] This is it. [@] Sorry that's not a fifth up that's some other interval or whatever that is. [@] OK so that's a thing you enter two sinusoids so now when I start pushing it to a point where they eclipse I get some of this stuff:[musical tone] right? [@] Well, OK, clip~ is a non linear function and when you send signals to non linear functions not only do sinusoids turn into things that are not pure sinusoids anymore -- that's called "harmonic distortion" in Stereo Review. [@] The other thing that happens is when you take the two different sinusoids or give a signal that has more than one sinusoid component in it, they will, as it's called, "intermodulate." [@] What that means mathematically, well hand-wavily mathematically, is that there will be distortion products which are not just functions of the one and the other but cross products of the two. [@] So to go back to the simple example ... So if this was the complicated example would be [musical tone] . Oh yeah, with the clipping function. [musical tone] ... The simple example is going back to just squaring the thing. ... [@] Why don't we hear anything now? [@] Oh yeah, I've turned this thing off. [@] OK, so I'll push it all the way up. [@] So now we're going to hear [musical note] . Oh yeah, good. [@] So now, with the clip~ function, by putting a low amplitude in I was able was able to use just the linear portion of the clip function. [@] So the clip function, if you graph it as a function, is flat and then linear and then flat. [@] Because clip just lets the value through until it clips. [@] So if you don't let it clip, you give it a value that's less than the value at which it clips, then everything that goes in will go out. [@] And in particular, here the sum of two sinusoids [musical tone] is just two sinusoids again. [@] Oops, sorry. I didn't turn the volume up for that to be true. [@] And then as I push it up again that "distortion" products, "intermodulation" products as the stereo people would call it. [@] So for in the (squared) sinusoid case, the thing is not linear anywhere. [@] In fact, if you like the sinusoid is... sorry. If you square a sinusoid that means your lookup function is a parabola. [@] And the place where a parabola is least like a line, if you like, is right at the origin where it doesn't have any slope. [@] So here, 250 and 325, those are these pitches. [musical notes] But here they are [musical tone] --- not there at all. [@] What there is, is this sound [musical tone] . That's an octave above this. [@] Furthermore, you get an octave above this [musical tone] . OK, so now you've got [musical tone] ... [@] And then if I put them together you'll get another pitch which is about [musical tones], and another one which is [musical tone] something like that. [@] I can't get down that low, right? [musical tones] [@] -- Two other pitches that were not there in the original. [@] Actually, none of the four pitches that you hear. [@] What pitches do you hear. [@] I hope you hear, oh let's make it this is better than a real example because its harmonic to the point that you can actually find [@] so like that and then [piano] you hear those four pitches sorry, duh. [@] What happened? [@] Well this oscillator by itself made one pitch and it also make DC by the way. [@] This one also made a pitch and it made DC. [@] But as you all know (A + B)^2 is [ A^2 + B^2 + 2 AB ]. [@] That means you get the square of the first one and the square of the second one. [@] But even more you get a product of the two. [@] So yeah, one component of the output of this squaring function is this times this. [@] The crossterm. [@] And that crossterm is what's called "intermodulation." [@] And these two pitches [piano] -- those two pitches were just double the original pitches and these two pitches [piano] were the sum of the two frequencies and the difference of the two frequencies. [@] All right, oh, you've already even seen this because if you multiply two oscillators that's ring modulation. [@] So what you get is the sum and the product of the frequency. [@] So here you get the sum of these two frequencies which is whatever that is 575, you get the difference which is 75 and then you get double this and double that. [@] Of course if we gave it a harmonic sound, like gave 500 here. [@] then we're going to get just a nice harmonic sound. [@] there components frequency are going to be double 250 which is 500 double 500 which is 1000. But also, 500 minus 250 which is 250 again and 500 plus 250 which is 750. So you actually get 250, 500, 750 and 1000. ... Questions about this? [@] ... Yeah?? [@] Student: I don't get how these cosine's give you sums and difference frequencies. [@] ... Yeah, so it's two times the cos ... What I really should have a blackboard or should use a blackboard but it's going to be a mess if I do. [@] So this is the, what's coming out of here is the cosine(250 2 pi t). What's coming out of here is the cos(500 2 pi t). And when you multiply those two it's the cosine of one thing, times the cosine of another -- which is half the (cosine of the sum) + (coseine of the difference). That's the trig function you need. [@] Where do I have that written down? [@] Let's see. [@] That's in the book somewhere, but I'm not going to be able to remember where, right now. [@] So that's why you get the sum and difference frequency. [@] ... Yeah, I'll go try to figure that out. [@] It should be at the very beginning of chapter five. [@] Actually, you know what? [@] ... It's such an important formula. [@] This is the fundamental formula of computer music, so it's... [@] let's see. [@] I'll go here, maybe I can actually go back to modulation and go to multiplying audio signals, and there it is. [@] This is more than you need. [@] This is showing you a cosine including the phase, and another cosine including the phase term and then it's this mess. [@] But in fact, it is cosine of the sum of the two frequencies with another phase, and it is cosine of the differences of the two frequencies with another phase. [@] And did I find my way back to where I wanted to be? [@] OK, here. This is a picture of squaring the signal, and what it looks like, when you square a signal. [@] See it becomes positive. [@] And this is the transfer function. [@] This is clipping transfer function that I was just talking about here: [@] Here, and this is what the waveform should have looked like earlier, except I drew a symmetric one and in the patch I did a non-symmetrical. [@] Important detail about that... [@] ... Yeah, I can demonstrate this, I think. [@] I mentioned that it's a very special case that the oscillator went up by an octave, when I squared it, but in fact if I did any even function that I wanted here... [@] What's another good even function? Let's see... absolute value? [@] I hope that there is one of these... [@] Good. ... Yeah, this is not going to sound nice. [@] This is what happens in analog electronics when you take your nice sinusoidal oscillator, and put it through a full wave rectifier. [@] The absolute value is, if it's positive it lets it through, and if it's negative it negates it so that it's positive again. [@] And when we do that... [@] Let's see I did not do this real well. [@] We'll do it like this. [@] Sorry, so this thing is not working right now because it does not have an input. [@] So now, once more. [@] Oh, let's get rid of this, and let's also be able to hear the original so that you can get that original pitch in your ear again. [@] Here's the original pitch. [musical tones] And here's the original pitch with taking the absolute value of it. [musical tones] It goes up an octave. [@] OK, this sounds mysterious until you think about it, and then it sounds stupid. [@] So, why is it stupid? [@] The oscillator itself --I'll graph the oscillator's output. [@] OK, there's an oscillator for you, amplitude 1. It spends half of its time being positive and half of its time being negative. [@] Now we're going to take this and put it through an even function. [@] That is to say, a function whose output for negative values is the same as its output for positive values. [@] An example of an even function is the second of these two examples:. [@] Y = X squared. [@] That is an even function. [@] It's the simplest even function. [@] No, the second simplest even function ... How about the function f(X)=1 ? [laughter] [@] The voltage you get when you hook your electrocardiogram to a dead patient. [@] All right. [laughter] [@] That is an even function. [@] OK, this is the next even function up, if you're thinking in terms of polynomials, which is one possible series of functions that we could look up. [@] In fact, that is the one that we're going to talk about later. [@] So it's even. [@] That means if you put a positive number in or a negative number in, the same thing happens. [@] And lo and behold, the positive part of the sinusoid that goes in, gives you whatever it is. [@] And the negative part gives you whatever it is all over again, because it's the same. [@] So, the result is the same for the first half period as for the second half period. [@] As a result of that, it had to go up an octave, because it's period suddenly dropped by a factor of two. [@] So that's a more general statement about why squaring a sinusoid, sent the sound up an octave. [@] And in general, that would happen if you had a sinusoidal input -- [@] or if you had any other kind of input, half of whose cycle was the opposite of its other half. [@] If you studied acoustics really well, you probably didn't hear this. [@] But those are things that only have odd harmonics in them. [@] If you do that, if you send one of those things into an even function, you will get something that is an octave up. [@] Because what happens on the left hand side is exactly the same as what happens on the right hand side. [@] Now, if it were true that the function for the negative value was in fact, the negative of what it was for the positive values, then you would get the rest of possibilities. [@] The rest is the odd harmonics. [@] Those are the things you didn't hear for even functions and so, hand-wavily you might think, that odd harmonics would be a thing that you might get by sending a sinusoid into an odd function. [@] In fact, it turns out to be true. [@] An example of an odd function that you just saw was this one. [@] So now for negative values, you get negative of what you have got for positive values. [@] And as a result, when you send a sinusoid in, the result has the same period as you had before. [@] And furthermore, the result still has the property that the second half of the waveform is the additive inverse of the first half of the waveform. [@] So it's something and then it's minus it and then something and then it's minus it. [@] And if you think about what harmonics would have that symmetry. [@] The first harmonic does, it's positive and then it's negative. [@] The second harmonic loses, because it does the thing, and then it does it again. [@] So it's the same for the second half of the cycle as the first. [@] The third harmonic goes up down up, and then it goes down up down. [@] And so if you squeeze the third harmonic into the cycle, it will again have the property that the first half is the negative of the second half. [@] That will be true for harmonics one, three, five, seven, nine, and so on. [@] All of the odd ones. [@] As a result of which, if you make a wave-form like this, which is -- It doesn't have to be positive followed by negative, it just has to be whatever-it-is followed by minus whatever-it-is, so that if it's a negative in the first half, it's positive in the second half. [@] Then you will have something with only odd harmonics and the typical sound that that makes, let's see: [@] OK, so this clip was, I made it un-symmetrical deliberately in order to avoid having this happen, because I didn't want to be confusing or something. [@] But I'll now be confusing. [@] I'll clip between -0.2 and +0.2 two. [@] And now we want to graph this so I can prove that it's doing what I'm telling you it's doing. [@] Now we can listen to it. [@] So here's the original: [tone] [@] And here is the waveshaped one: [musical tones] [@] And it has that, you know, clarinet-y, held-nose kind of a sound that one associates with sounds that have odd harmonics. [@] By the way, don't let anyone tell you that clarinet sounds are typified by having strong, odd harmonics. [@] That's true for the first 18 half-tones of the clarinet, if I'm not mistaken, after which it's not true anymore. [@] As soon as the little hole goes open, that quits being how it acts anymore. [@] But it is true for the low notes, that you get these kind of notes for clarinet. [@] And for the first 30 years of electronic music, whenever anyone made a timbre like this, that just happened to have, for symmetry reasons, mostly odd harmonics, they said, "Oh, it sounds like a clarinet." [@] And so now you can find clarinet voices on your organs or synthesizers or so on. [@] And it's just things that happen to have that symmetry, regardless of whether it sounds like a clarinet or not. [@] To any reasonable pair of years this doesn't sound like a clarinet at all, it sounds like a very cheap computer music instrument. [@] Oh, and what does it look like? [@] Ta-da! What I showed you before. [@] And it does have the correct symmetry for having odd harmonics. [@] Now, why am I belaboring this point? [@] Because now, I've shown you how you can make odd harmonics... [musical tones] [@] ...and even harmonics. [musical tones] [@] Oh, yeah, I should show you that as a waveform. [@] That was the one where I took the absolute value of the sinusoid. [@] And now the thing can't go through 0 because we're taking the absolute value. [@] So the second half of it is flipped upside down so it's positive again. [@] And that of course had to go up an octave. [@] And now -- and this is an idea that I think that might be originally due to Don Buchla. [@] At any rate the oldest synth I know that knows about this is Buchla's old modulator synth -- Now we have something where we can control the relative strength of the even and odd partials. [@] Questions about this? ... Yeah? [@] Student: Could you set the relative amplitudes so you add the harmonics and get back the original sinusoid? [@] The original sinusoid. No, no. ... So one way of thinking of that is one of these only has odd harmonics and the other only even. [@] So adding them is simply introducing different frequencies which won't in fact ever cancel each other out. [@] However you could make a waveshaping function ... [@] You could make two waveshaping functions each of which is horribly nonlinear but whose sum happened to just be the identity function. -- [@] In which case you actually would have two funky timbres whose sum is the original sinusoid. [@] I don't know if that would be useful but you could do it. ... [@] So this is sort of, so this is just sort of "phenomenological" if that's the word. " [@] Experimental, intuitive." [@] This is just very general observations about what kinds of wave forms might come out when you do things. [@] So far what we've got is that putting two things in will cause distortion products which are sums and differences of the incoming frequencies. [@] Or maybe sums and differences of multiples of the incoming frequencies. [@] That was what we got when we took these two things in and where we added these two together and started waveshaping. [@] And then we're getting stuff like this. [musical noise] [@] Oh right, I was going to make this 325 again .. so now we have complicated sound and more complicated sound right here [musical noise] Oh interesting. [@] They're probably no common frequencies although I can't swear to it. [@] So that, oh, let's look at it: [@] Isn't that cool. [@] This is the absolute value. [@] This is the sum of two sinusoids full wave rectified. [@] That's old fashioned talk. [@] So you can imagine every other one of these loads being negative in sign before it got waveshaped. [@] And then every other one, this one [musical noise] is the same thing clipped so it looks like this: [@] All right, another observation that is just right there on the surface: [@] Different kinds of waveshaping functions have different behaviors when you change amplitudes, in terms of the overall amplitude that comes out. [@] So, if you take the absolute value of something, the louder the signal goes in, the louder you will get out. [@] Pretty much, if you double the signal, in fact there aren't very many oh, real valued functions. [@] Something where if you double the input, it doubles the output. [@] The only ones that I know of are the identity function and the absolute value and combinations of those. [@] Although if you think in the complex plane you got a whole bunch more. [laughter] [@] And that's a very rich source of ideas. [@] If you clip, clipping things means that no matter what you put in, the result can't get louder than between -0.2 and +0.2 in this case. [@] Which means we have a very... [@] what's the right word? [@] ... We have a very "predictable" instrument in terms of what kind of amplitude will come out. [@] All right, that's good, or that could be good. [@] In particular if you got the ... well this is the thing that you get if you put an electric guitar in an amplifier and overdrive it. [@] The cool thing is the amplifier can't push the tubes harder than full on and full off. [@] As a result there's this sort of basic loudest thing that you will get out of the thing no matter what you do on the incoming side -- including feedback. [@] You can do feedback ... if you put it through a linear system, could eventually grow without bounds. ... [@] If you put it through something that's being clipped, you know it will stop somewhere, and then you will get something that hopefully is at the level that you want. [@] It's still true, it's true of all these things that -- particularly true of this one -- that we still have this nice timbre control which is:[musical tones] louder and gives you a sharper timbre and furthermore, gives you interestingly enough, a louder sound. [@] So, even though the difference in power between this [musical tones] and this is tiny. [musical tones] This is actually louder than that. [@] Not a lot, but substantially, and the reason for that is psychoacoustic mumbo-jumbo. [@] Specifically, the loudness at which you hear something is in some sense, the sum of the loudness of the signal in all of the different critical bands that it has energy in. [@] And so even without substantially changing the energy of the signal, it can just spread the energy out over more critical bands. [@] The result will sound a great deal louder -- because putting a quarter as much energy in four different bands is much, much louder than putting the entire thing in one band. [@] So bandwidth makes loudness in psychoacoustics. [@] And here what we're doing is we have an instrument which changes loudness. [musical tones] -- More by changing band width than changing the acoustical power of the signal that you are listening to. [@] So if you have ... if your bassist isn't loud enough, you don't get very far by just pushing the bass up, because you just hit the limit of your cabinet. [@] But if you add some overtones, then the bass can be a great deal louder. [@] And if you're mixing music and you want the bass to be audible, even if you're playing it on a boom box, don't just push the fundamental, because it won't come out that speaker. [laughter] [@] Add some harmonics, that will make it loud. [@] And people will think, "oh, that deep bass" even though the actual low frequencies which are the actual fundamental and the low harmonics of the bass aren't even present. [@] Same thing is true, even more so with ear buds. [@] Learning how to do that is an art, not a science. [@] OK. [musical tones] So there's that. ... Questions about this? [@] Now, I'm going to get a little more mathematical. [@] So this was all experimental stuff, with stuff like absolute value and clip, which by the way are functions which are not pleasant to approximate with polynomials that are not analytic functions. [@] But now we are going to take the opposite approach altogether and start talking about polynomials because they are the things that we can analyze the most easily when we're talking about waveshaping. [@] So the first example of a polynomial that I showed you was just squaring, the first nontrivial example. [@] And this was the example, or this was the thing that allowed you to just... [@] It takes the thing and bashes it up an octave. [@] OK, so this is an even function, so it had to get bashed up an octave. [@] An odd function would be ... take this thing and cube it. [@] So we'll take the square and then multiply it by the original signal again, and then it's cubed. [@] In fact, while we're at it, let's make a few of these. [@] So now the results, the outputs of these multipliers are going to be the squares, the third power, fourth power, fifth power, and sixth power of the original signal. [@] Now raising this signal to the sixth power could give you a huge amplitude, except for the fact that this oscillator gives you values between -1 and 1. And no matter what power you raise that to, it's still going to be minus one and one (positive power, anyway). And so, let's see. [@] Let's turn this on and turn up the bass and [musical tones] so here we go. [@] So here's the first power of the signal which is just itself:[tone] Here's the square: [tone] quieter by the way. [@] Here's the cube. [tone] They are getting quieter. [@] Why are they getting quieter now? [@] I'll show you. [@] There's the fourth power, fifth power. [@] You know what? [@] They are getting quieter at the point where I want to get. ... [@] Oh, duh! -- I'm not doing what I said I was doing. [@] I just want to make this full blast so they have all the same amplitudes. [@] I'm sorry. [@] So that was 24 ... That was a _quarter_ going into there and so a quarter to the fourth power was going to be a tiny little signal. [@] Now I am going to try this again, but I'm going to turn it way down. [@] So the original signal: [tone] Square: [tone] Cube: [tone] OK. [@] Fourth power: [tone] Fifth power:[tone] Sixth power: [tone] Seventh power: [tone] OK. [@] So, seventh power compared to third power is this:[tone] All right? [@] So if you just had something that could freely move between the different powers of the function you could have a nice timbre whammybar. [@] However... [@] Oh and let me quickly graph what happens when you take ...Let's take a look at the seventh power of the thing: [tone] [@] So that is this thing. Now if we look at it we will see ... Yeah? [@] Student: You've got an extra connection ... over to tabwrite~ [@] Oh. Thank you. [@] I don't want that trace there. [@] There you go. [@] I was getting worried because math tells me that this thing should still be between plus and minus one, it was reaching outside there. [@] And when that happens usually you're doing something wrong. [@] So, here's the seventh power of a sinusoid, and it is sort of looking like a pulse train, where every other pulse is negated. [@] And in fact if I take an even power of it, it looks like a pulse train again so, accept that, now every other pulse is going the same way. [@] Going in the positive direction -- every pulse is going in the positive direction. [@] That is the even/odd thing again. [@] Furthermore let's do this. ... [@] Actually ... I'm going to listen to this for a second: [tone] [@] As I mentioned, or as I showed with the clipping operation, clip. [@] So, here: [tone] ... As I change the value, or as I change the volume or the amplitude of the sound that I am clipping that changes the timbre. [tone] [@] That is going to be true in general of ... Non-linear functions. [@] So here too, and I'm really scared of this one. [@] But here too... [tone] Whoops sorry. [tone] Still hearing this one. [@] Hmm. Turn off. [@] There we go. [tone] [@] Well, really it is not so clear. [tone] But in fact the higher harmonics are somehow growing at a steeper rate than the lower harmonics. [@] I can show you that to you better a little bit later when I show you some more math. [@] So this thing does have a varying timbre but the problem is that the amplitude is changing in such a way that you don't hear the timbral change because the amplitude is dominating it. [@] There might be ways you could deal with that. [@] You might be able to predict what amplitude you should get and divide by it and I'll let you think about that. [@] So now to go back to the equations and pictures for a second. [@] So this is the waveshaping chapter and then ... [@] A little bit further down here is an analysis of what happens when you actually take powers of the signal. [@] Oh yeah here's me figuring out what happens when you take two different sinusoids and square the sum and show the intermodulation products. [@] But, I already talked about that. [@] Here now is, is it? [@] ... Yeah, here now is what happens when you just take a nice sinusoid, cos(omega n) omega) --where n is the number samples that have gone by -- and start raising it to powers. [@] And this is just algebraic idiot's delight. [@] The first one is cosine times cosine is (a half plus a half cosine double) right. [@] And in general the cosine of A times the cosine of B is half (the cosine of the sum plus the cosine of the difference). [@] And so here what happens when you cube it you can think of multiplying the square by the original one. [@] And so you have to multiply this term by this term and this term by this term separately and then add them. [@] So this one just gives you a half of cosine omega n again. [@] Which to confuse the matter I wrote as a quarter of the cosine of the minus omega 'n' plus a quarter of the cosine of the plus omega'n'. That's because that's the way to write it down so that the pattern will come clear later. [@] And here the cosine of omega 'n' times the cosine of two omega 'n' that's the cosine of omega 'n' plus the cosine of three omega 'n' and that generated the other half of this one. [@] The other quarter of cosine of omega 'n' and one quarter times cosine two omega'n'. We've all seen Pascal's triangle right? [@] We're doing Pascal's triangle in harmonics. [@] So the next one is, all right so the lowest frequency is minus two omega 'n' and the highest frequency is plus four omega 'n'. It's centered around omega 'n' and not around zero. [@] And now we have 1331 all divided by 8. Those are the probabilities of getting zero one two or three heads in three tosses. [@] And meanwhile the signals that have those amplitudes -- instead of probabilities -- are -2, 0, 2 and 4 times the original frequency. [@] This is the fourth power so it's an even function. [@] So we're seeing, in mathematics, what I told you before by handwaving. [@] Which is: [@] That you only see even frequencies when you take the even function. [@] And now the next one, not to belabor the point -- that's as far as we are going to go. [@] Divided by 16 now and it's -3, -1, +1, +4, and +5. So one interesting thing about this is if you look at the highest frequency, which occurs all the way to the right. [@] The frequency of the highest harmonic is going up one step each time you raise the thing to a higher power. [@] Now someone I'm not sure who but it might have been Marc Lebrun in like the early 70's, thought about this and realized that, if you were smart, you could just isolate these individual frequencies by picking up the correct polynomials. [@] In fact the correct polynomials were easy to think of because they had been known for I don't know how many hundred of years. [@] They're called "Chebyshev polynomials." [@] And Chebyshev polynomials are what you get if you say, "I just want the cosine of five omega 'n' and I don't want this other stuff." [@] So how am I going to get rid of it. [@] Well it's easy. [@] I'll get rid of this one by subtracting out twice this whole thing. [@] So instead of taking x to the fifth, I'll take x to the fifth minus twice x to the fourth. [@] And that won't have any of this. -- [@] Oh wait, I'm telling you the wrong thing. [@] There is no cosine four omega 'n' here. [@] There's only three. [@] So there's five, three which comes in twice and then one which comes in twice. [@] So we can get rid of the three. [@] Cosine three omega term by subtracting some suitable multiple of this (which I can't do in my head.) [@] And then we can even get rid of the cosine omega 'n' after that by subtracting a suitable multiple of the first one. [@] So there is a polynomial out there which is something times x to the fifth plus something times x cubed plus something times x. [@] Which has a property that you put a cosine in to get exactly the cosine of five times it out. [@] All right, and since seeing is believing I made a patch to do that. [@] Here's a picture of I believe the fifth one. [@] This is a polynomial that I stuck inside a wavetable. [@] How would do you do that? [@] Its work but you can look inside the patch to see how I did it. [@] And I'm just using tabread4~ -- your old friend -- to read values of this polynomial. [@] And then here is nothing but a nice oscillator going in times an amplitude control which I'm going to call the "index." [@] And if the index is one that is to say if I just put this thing at amplitude one -- ooh, there's stuff here going on, that I'll explain when I have the actual patch out. ... [@] Then out will come the fifth harmonic. [@] I'll get the patch out and show you what happens. [@] If I can figure out how to get the patch out. ... Here. [@] So the patch is in the tedious but essential help browser: [@] We're in Chapter 5 so they start with E and it's going to be the Chebyshev. [@] pd . By the way this is all stuff I think that you've seen. [@] Here it is and here is the sound of, let's turn it all the way up, here is the sound of whatever this is. [@] So what we're doing is we're computing different polynomials to put in the table and I am realizing now that it's too bad I didn't also have a linear polynomial. [@] Let's just draw one. [@] There's the original pitch. [@] If I had actually made the patch that would be a cleaner sound. [@] There's the oscillator going through just the function y = x. [@] Here is the thing going through a suitably designed parabola ... So before you saw more sort of just thoughtlessly square this thing in order to give you the octave. [@] Here this is the polynomial (x^2 - 1)/2 -- which has the wonderful property that it goes between +1 to -1 to +1. [@] And you can compute it if you want but if you apply that to a sinusoid you will get the second harmonic term and you won't get the DC term that you got when you just squared the thing. [@] If you just square the sinusoid you get double frequency and then you get DC term. [@] If you just subtract the appropriate thing from the thing then you get just the second harmonic term and nothing else. [@] So now I have polynomials that will take an oscillator, just take a pure sinusoid, and make pure harmonics out of it. [@] Furthermore (Let's go get this one.) ... [@] Depending on the amplitude of the sinusoid that you put in you get different timbres. [@] So what I told you is only true in fact for a unit-amplitude sinusoid. [@] Of course if I put in a zero amplitude sinusoid I have to get out nothing. [@] I get probably some DC I'm not surem, but no sound. [@] And in between I get a range of timbres which [tone] sounds like that. [@] So we're starting to make computer music here. [@] And similarly for all of the others this is an even one which therefore will sound an octave up, ... and so on like that. [@] So this is what in the early 70's people thought would revolutionize computer music. [@] Because no one would ever need to do anything besides this for building timbres -- Until people realized that actually static timbres aren't interesting. [@] It's variable timbres that are interesting. [@] And furthermore, although you get to control exactly what you want this thing to be when you take it all the way to the end like that <>, you don't really get to specify in addition what it does on the way up there. [@] It just does whatever that polynomial does and there's no choice about the polynomials: [@] There's exactly one polynomial that will give you that thing at the end. [@] So in fact you have to be smarter than this if you want to make timbres that actually vary the way you want them to. [@] And how smart do you have to be? [@] You have to proceed by special case. [@] Everything is a special case from here on out. [@] Particular kinds of functions, and particular ways of using them, and combining different ones of these will be useful for making different things. [@] And that will be something that I can't really even give you a summary of. [@] It's just a whole field of inquiry. .... [@] Questions about this? ... Yeah? [@] Student: So would we be able to see physical modeling in these terms? [@] Are there polynomials or functions that would be able to... [@] Oh boy ... [@] Student: I was thinking of one synthesizer that I used to have where you could change the modulation and have a waveform definition pattern. [@] Really, it would sound actually like an paranormal entity. [@] It was just an oddity. Let me you what, a really breathy sound? Hmm. [@] Student: Sounded like it was breathing. It's got this similar thing to... [@] Mm-hm. That might have been. Was it a Yamaha DL-1? [@] Student: No it was a... [@] No, you're not old enough to have one of those. [laughter] [@] Student: I know the DL1 but it was a Korg Platinum synthesizer. [@] Oh that one, I don't know. [@] Since Yamaha licensed something from Stanford, I don't thing Korg was actually using so-called physical modeling. [@] Although, it really wasn't physical modeling in the first place. [@] Student: OK. [@] So I fact I don't know what is was. [@] But to be honest that Yamaha thing, that's the original synthesizer that described itself, as physical modeling, didn't work at all. [@] It was a completely different principle of operation. [@] Student: Mm-hm. [@] And so this is the easiest way into making varieties of timbres. [@] There are other interesting but more complicated ones too, and you can spend decades learning them all if you want. [@] So, there is that. [@] What I want to do is make another observation. [@] So, just continuing to look at special cases, right? [@] So what are some good functions that you could think of trying that aren't polynomials? [@] ... Oh! So the problem with polynomials is this: [@] You don't see it because I've only shown you the part of the polynomial that happens to be the good part of the Chebyshev polynomial. [@] Of course, this is a fifth degree polynomial. [@] It's leading term is x^5 and so it's going to shoot out of the screen just as soon as I get two tenths of a point to either side of the part that you are looking at. [@] It's coiled up tight right in that little rectangle, but that's the only place where it is well behaved. [@] So polynomials, even though they are simple to think about, are actually very ill behaved in terms of the amplitude that you get out when you start putting freely varying amplitudes in. [@] That is almost the opposite situation from the clipping functions. [@] I don't know if they even have names, but functions like clip~, where no matter how hard you punch the input, the output is limited to a specific kind of value. [@] And there the only thing is, that is not really an analytic function. [@] That is to say, it's not describable very well as a power series, so I can't really tell you by using this kind of mathematical analysis what it's going to do to the signal. [@] In fact, I don't have anything beside hand-waving sort of descriptive analyses of what clipping does to signals. [@] There are analytic, that is to say easy-to-approximate-by-polynomial functions, which do reach asymptotes -- like arctangent. [@] But take the arctangent function and take the first ten elements of the Taylor series, and then plot them, and the result will not look like arctangent. [@] It will look like arctangent in the neighborhood of zero and then of course, since it is a tenth degree polynomial, it will shoot off to plus and minus infinity. [@] Oh, sorry. [@] The terms are all odd so it would be nineteenth degree polynomials. [@] So...[laughter] So as soon as you get out a very little bit past the well-behaved portion, it's going to blow up horribly, right? [@] So how do you get something? [@] -- Actually let's do the simplest analytic function, which just blows up horribly anyway, which is the exponential function: [@] It turns out that the simplest -- well the simplest analytic functions are polynomials -- but the exponential function is a good one to think about because its turn out you can analyze what happens when you send signals through exponentials; and decent well-behaved things happen. [@] So let me show you that. [@] Let's see. [@] Actually, I'm going to cheat and show you this off of the prepared patch rather than build this for you. [@] Because I don't want to build, well. [@] There is an exp~ object so you can just exponentiate anything you want. [@] But there is stuff to do in order to exponentiate things well, as just opposed to just exponentiating them. [@] So, how do you exponentiate something well? [@] So, here's a picture of an exponential table. [@] Since we're doing computer music, we're going to run the thing through a digital analog converter. [@] So we would like things to be bounded, and the way to make exponentials be bounded is just look at the part of where the exponent is negative. [@] And then it's all going to vary between 0 and 1. [@] So this is the function e^(-x) graphed from 0 to 10. So, down here if you could see it this would be e^(-10), which is tiny. [@] And now what we're going to do is use this as a waveshaping function, but we're going to be smart about it. [@] And the smartness is this: [@] Rather than to look in the middle of the function, where the thing is about e^(-5) -- I mean we could do that. [@] We could have a waveshaping function, and the thing would be e^(-5) which is, I forget ... it's maybe a hundredth or so ... so we'd multiply the result by a hundred so we could hear it. [@] And then you would increase the "index", that is to say increase the the amplitude of the sinusoid we look up. ... [@] And then we would start going up this thing on one side and then we would start clipping madly or do something bad ... Anyway it wouldn't be correct. [@] Or at least it wouldn't be the exponential. [@] Also the amplitude would grow in some very unruly way. [@] So, rather than do that, the smart thing to do here is to take the sinusoid but actually don't just center it around zero -- because then it'll go negative and that will either be clipped or be growing quickly, depending on how you realize it. [@] But do the following real simple thing: [@] Have the sinusoid be arranged so that it reaches from zero to whatever point you wish. [@] So now what's going to happen is rather than look .... Let me show you this in a picture: [@] So going back to, where did it go? Here, going back to here. [@] So these functions are all being read around the middle of the function. [@] The simpler example was just squaring. [@] Oh, wait, that was the other window. [@] Here in this wave shaping example, we're putting a sinusoid in and a sinusoid is variously positive and negative. [@] But the result is centered around zero. [@] And were just leaving it centered around zero. [@] Not moving that center as we change the amplitude. [@] When we change and when instead we use ... [@] When we use a function like this its smarter to have the thing grow from the left-hand margin of function out -- so whatever the amplitude the sinusoid is we will adjust the center of it so that it reaches from zero to somewhere, instead of just reaching between plus and minus something. [@] So instead of reading around the center we'll read starting here, around whatever point we need to read around to get it started here. [@] How do you do that? [@] You just take the oscillator and add 1 to it. [@] So then instead of ranging from -1 to +1 like the oscillator does, it will now range from 0 to 2. And now it would be correct at that point to divide by 2, so it will range from zero to one but I'm throwing care to the wind at this point. [@] And now the index is again a number -- it's in tenths now -- which controls the amplitude of that result before we go reading it in the table. [@] At some point I want to remember to tell you why I'm doing this... [@] But this times 100 because this is in fact 1000 points representing ten. [@] In other words I have ten points in the table for every unit of input for the exponential function (so that when I do the look up it will be decently accurate.) [@] So this is correcting for the units at the table. [@] And then we will read it out of the table and then we will start graphing it. [@] So let's graph it: [@] Here's the spectrum. [@] Oh, you saw spectra ... This is the spectrum of what you get when you have a zero amplitude reading into this, which is therefore putting out solid value of one. [@] So the index is zero; so this oscillator is multiplied by zero; so zero is going in here. [@] So the result is 1 -- whose waveform looks like that, which you don't see, and whose spectrum looks like a peak at DC, zero frequency. [@] And then as we increase the index now what happens is: [@] When the original sinusoid is at its negative peak, (so that when adding 1 you get 0) then you get 1 . But meanwhile as it reaches out to wherever it goes it goes down to some which will get closer and closer to 0. [@] Furthermore the hotter you make the signal going in, the less time it spends in the neighborhood of the peak here and the more time it spends out here in this neighborhood where everything is almost zero. [@] And hence the skinnier this pulse gets. [@] So I think this is the good way to make a pulse train in computer music. [@] But there are other ways of making pulse trains. [@] This is a pulse train; you can in fact compute these amplitudes and they turn out to be Bessel functions of the second kind, if I'm giving you the right nonsense. [@] But basically you can look at them intuitively and see that what's happening is there's a peak here and the energy is moving out so there's an increasing band width. [@] Furthermore, as you tweak this peak, the peak itself lasts less and less time. [@] And so in a very non-rigorous way of thinking. [@] the frequencies present in that should be growing linearly as the peak gets squeezed which is to say linearly as this number goes up ... if I'm not doing that wrong. [@] So as this number goes up the energy gets spread over progressively more and more hormonals. [@] And so to listen to it you get nothing if you send the index to zero because it's all DC you can't hear it. [@] And then you add index you get this: [sound changing] [@] Computer musicians hear that and they say oh that's a brass tone. [@] And actually if you look at how brass spectra changes you put more and more pressure into the brass instrument they do actually spread out in this sort of way. [@] See if we can see any more harmonics ... Well, you probably can't see the harmonics, while I'm changing it very well. ... [@] So the basic idea is the harmonics will spread out fatter and fatter and to a certain point you will not hear the thing get quieter even though the power of the signal is dropping because it's spending less of its time away from zero, because of the psychacoustic affect I told you before -- the energy is spreading out into more frequencies. [@] So up to a certain index you actually hear a decently nearly constant amount of sound. [@] That will quit being true when I get up past two or three hundred here. [@] In fact, I decided to protect users from this. [@] But now I'm going to unprotect us. [@] Saying let's just go all the way up to whatever value we want. [@] And now we get that: [wider range of tambres] . And then, eventually ... [@] All right, let's just change the scale. [even wider range of tones] Ta da. [@] That's something that people used to do with low-pass filters. [@] They'd take a standard analog synthesizer kind of waveform and send it into a low pass filter, and you can get that kind of effect. [@] Here in computer music land it's easier to get it this way. [@] Although, people still reach for the analog way of doing it anyhow because it has a particular quality of sound that makes people nostalgic for the 50s and 60s, 60s in particular. [@] But this is now [tone plays] a very simple but very effective way of making one collection of timbres using waveshaping. ... [@] Questions about this? ... Yeah? [@] Student: Is there a mathematical description of what's happening as you increase the index? [@] Yeah. It's even better than that. [@] There's a couple pages of mathematical analysis of what this should do. [@] And what I can tell you about that is this: [@] The Taylor series for the exponential has this wonderful property that for very small... [@] OK, so everyone knows Taylor series for e^x ... right? [@] Student: No. [laughs] [@] OK, I was kidding. I know. [@] 1 + x + x^2/2 + x^3/6 (6=3!) + x^4/4! + x^5/5! and so on. [@] So the denominators are going up crazily so that by the time you get to... [@] Anyway, the coefficients of the terms go off very rapidly. [@] Now one interesting thing about that function is that if you say, "What's the loudest monomial in that series." [@] So if you put in zero you get 1 plus a bunch of 0's, so the loudest thing is the 1. "If you put in values between 1 and 2 -- If you think about it, between 1 and 2, x is bigger than 1 < [@] but x is bigger than x^2/2 >>. So between 1 and 2, x is the dominant term." [@] Between 2 and 3 x^2/2 is the dominant term. [@] Between 3 and 4 x^3/6 is the dominant term ... and so on. [@] So you can think of the Taylor series of the exponential, as a sort of polynomial whose degree goes up as you push the input up -- in the sense that the dominating term going further and further out the series as the value of the input is going up. [@] This is a good way of thinking about it -- for positive numbers going up. ( [@] Negative? [@] ... stranger situation -- because they're canceling each other out.) [@] So in one way of thinking then, the bigger a number you put in, the higher harmonics you're going to get. [@] Because as I showed you before as as you start raising the cosine or start raising a sinusoid to higher and higher powers you get those collections of terms that were spreading out in frequency. [@] That was this picture here: [@] Whoa, come back. [@] Oh, where did I put it? [@] I think I put it here, yeah. [@] No, wrong, it was just here. [@] This stuff: [@] So see how the bandwidth of this is going up as you raise it to higher and higher exponentials. [@] Well that suggests that the exponential, if you expedentiate something the you'll get a mixture of these things and whichever one is dominant will be the loudest thing in the mix. [@] So you should expect to see something whose band width increases linearly in fact with the strength of the signal that you're putting in. [@] Hmm ... that's not quite right. [@] But I won't tell you why it's not quite right. ( [@] The bandwidth of Pascal's triangle does not go out linearly, it goes like the square root of n, because it's the standard deviation of a collection of coin tosses.) [@] But at any rate, you see these things: [@] Each weighted according to how important this term is in the Taylor series. [@] That would be true for any Taylor series -- you can think of it that way. [@] And for the exponential in particular -- since it has this very simple behavior of which term is the most important -- you just get a widening and a flattening of the thing as the signal gets louder. [@] And that's exactly what you saw here: [@] Pushing this coefficient up made the thing get wider. [@] Now, I'm pulling a fast one here because of course that analysis assumed that I was centered around zero. [@] In fact, what I'm doing is pushing the thing over so that it only reaches zero at the loudest point. [@] But in fact, the exponential function, if you slide an input over, you're simply rescaling the output. [@] That is the quality ... that's what exponentials are. [@] They are the same as themselves rescaled when you move to the left and right. [@] And so, in fact that I am sliding the thing over in order to control the amplitude is simply rescaling in the perfectly appropriate way to get the thing. [@] Not only to have the band width property that I told you about, but also to have a well behaved amplitude as the index of modulation is going up and down. [@] So at this point, the exponential should your all time favorite waveshaping function to try out. [@] Except for this one kind of inconvenient thing, which is that... [tone] [@] The overall power of the signal can be rather small if you average over the entire length of the period. [@] That is not going to be a problem if you have good audio equipment. [@] But if you don't have such good audio equipment, you won't necessarily be able to reproduce these functions as well as you would be able to reproduce something whose power was distributed nicely in time over the entire wave form. [@] So things that are pulse-y, are great until you put them through a boom box, and then -- [@] They are not quite so great anymore. [@] So this is good thing for the studio but you might want to mess with phasors or something before you actually put this on a record. [@] Do people use the word "record" anymore? [laughter] ... [@] I don't know. [@] Never mind. OK. [laughter] [@] This is closely related ... So what were the other Taylor series you all were made to learn in Calculus besides exponential? [@] ... All right? [@] Student: Maclaurin. [@] Oh, well, the Maclaurin series. [@] They are a different series altogether. [@] Didn't you have to memorize sine and cosine as Taylor series? [@] Student: No. [@] No one took you over those coals, did they? OK. [laughter] [@] ... Yeah, and then there's De Moivre's theorem ... if I've got the right neme... [@] which tells you that ... Sines and cosines are nothing but exponentials except that they're exponentials of complex numbers in linear combinations. [@] And in fact, the same kind of reasoning I show you here should suggest also instead of using an exponential as a look up function, you might be able to use sine or cosine and get something like similar results. [@] And in fact you do you and it's even better than that because you're going to get results that you have heard before. [@] Because... [@] Am I going to explain this? [@] ... Yeah. [@] Because you can reduce mathematically phase modulations to waveshaping by functions that are sine and cosine. [@] So let me just demonstrate that: [@] You've seen basically three classes of functions I think. [@] You've seen things that consist of linear segments -- that's the clipping function and the absolute value. [@] Those are hard to analyze in terms of frequency content but are easy to describe in terms of waveform. [@] So they're good pedagogical things. [@] Also the clipping thing sounds familiar because you've all heard overdrive. [@] Polynomials. And then finally transcendental functions which have Taylor series which therefore can be approximated or thought of in terms of polynomials. [@] So the two transcendental functions that we're going to mess with is first this exponential and second, let's go back to the one that I'm building here: [@] What we just saw was E5 and E6 here. [@] Now I'm going to quit using the examples and start just exampling myself. [@] So here I'm going to save this and do a save as and this one is now going to be three sinusoid. <> [@] So here what we're going to do is throw out this nice polynomial machine and do something much simpler which is say "cos~" And now we have, yeah -- you heard DC that's the sound of DC right there. [@] And now if I turn the index on [tone] you get this kind of sound. [@] And that sound should be strictly like frequency modulation. [@] Because basically it's essentially the same thing as frequency modulation. [@] All right, now cosine is an even function which implies that what comes out will be an octave up because yeah, so there's the original [tone] and here's the cosine [tone]. It's an octave higher because it has only even harmonics. [@] If you want to change that you just do this: [@] Why don't we add some number to that? [@] And since we have about one minute I'm not going to. [@] Oh, since we have one minute I'm going to really be fast and loose and just duplicate this one. [@] Now we're going to add. [@] I'll have time to explain this better next time but if I give you a quarter cycle through then it's the... [@] actually it's -sine instead of cosine. [@] And now I'm using an odd function so I'll get the odd harmonics. [@] And in general for values between here and there we'll get mixtures of the two. [@] So now we have something like this: [tone] -- which is more FM-ee actually than it was before. [@] That's something you know ... You've all heard that sound probably That's the old FM sound that we heard over and over again in the seventies. [@] I'll go back to this example next time because I haven't really described this in enough detail to make it clear what's going on. ... [@] *** MUS171 #14 02 17 (Lecture 14) [@] Here's the final projects thing with the web page: [@] There's a month to go, and this should be like a two week kind of a final project. [@] The idea is not to have you working all quarter for it, which is part of why I've been stalling. [@] So the way the rest of the course goes is there'll be one more assignment after... [@] This is assignment seven. [@] Oh, I'm sorry, assignment seven is due a week from Thursday, right. [@] And then there'll be one more assignment after that. [@] Assignment seven is up on the web, and assignment eight will... [@] well, let's see, I have to think some about that. [@] And then the final project, I came up with some possibilities, but basically the idea is come up with a patch and be prepared to come show your patch to the class. [@] The patch could be one of a bunch of a different things. [@] Ideas that I had were... [@] I'm not sure this first one is a real good idea, but... [@] make a thing that actually is a patch where you hit start and it plays a piece of music using synthesis techniques that you've learned. [@] I have to teach you one technique in order to make that possible, which is how to sequence. [@] I've shown you how to do looping sequencers, but I haven't shown you the more general sequencing techniques we need. [@] So that will be one thing that I shoe-horn in at some point maybe in the next week. [@] I'm not sure. [@] The next one is kind of the obvious one. [@] Make a nice 4/4 drum machine slash sequencer. [@] I went and dug one up just to entertain you with. [@] This is good; this isn't real syllabus stuff anyway so I can be doing this now. [@] Here's me making a drum sequencer: [music] [@] This uses all sorts of synthesis techniques you don't know. [@] So yours won't sound like this. [@] Notice that it doesn't do the same thing every time through. [@] The interesting thing, the thing that's fun about making these things is figuring out when to throw what with what probability in order to make something happen. [@] Because you can make these very -- You can make these lame very easily. [laughs] In fact you might think this is lame. [@] So. No comment. [music] [@] That was actually me trying to design a synthesis technique, and the synthesis technique didn't go very far, but the drum machine sounded cool so that's ... [laughs] I haven't listened to this in about five years. [@] But, drum machines. [@] Even people like me make drum machines sometimes. [@] So there's that. [@] Another example of something is do the "Switched On Bach," by which I mean go find some nice two-part invention on the web somewhere. [@] Figure out how to get Pd to play it. [@] That might be the hard part. [@] What I did, I had to do this once because someone put me up to learning a piece of classical music. [@] And I don't read music, so I went and found it on the web so that I could learn it by ear. [laughs] So, you can do this... Here. [@] You'll see this in more detail when I start showing you how to sequence again. [@] Here's a nice sequence. [@] This is a text file that contains times, pitches, and cumulative times. [@] You can make these files. [@] You can get them on the web from various sites, and they're in various formats. [@] And then you can teach Pd how to read them. [@] So I made a little sequence out of that. [@] I made a little polyphonic synth that could play that sequence. [@] This really sounds horrible; this'll make you feel good because yours is going to sound better than this almost no matter what you do. [@] Especially since it doesn't do anything! Let's get a pre-set... [@] Ah, here it is.[music] [@] That's an old lute piece from the 1500s that I just had to know for some really weird, stupid reason that I can't explain to you. [@] Weird things happen when you work in music departments. [laughter] [@] All right, so this is the "Switched On Bach" style project example where you just, you know, go make something that sounds like Walter Carlos. [@] Except of course it doesn't sound like Walter Carlos, because no matter how hard you try you will not be able to sound like Walter Carlos. [@] And you can indeed -- the very best things to grab are those two-part inventions, because they're easy to make sound good. [@] Those two-part inventions meaning the ones by Bach. [@] There's that. [@] So those were just examples that I happened to have of times that I had to do these things. [@] Just to show you that these are real projects that you might actually profit from being able to do. [@] At least if you're in my line of work. [@] So that was the: [@] "make a patch that plays the, blah blah blah..." [@] Here's a cool one that will make you impress your friends. [@] Make a nice little laptop instrument that you can take to a bar and get people to dance to. [@] Laptop instruments I think, are things where... [@] the things that you see when you go to entertainment venues where someone is staring into a laptop. [@] And they see the screen and you don't, or if you do you see a whole bunch of nonsense that's their screen, that means nothing. [@] The basic deal is you have something where you can mouse and keyboard away, and that changes something that typically is based on a loop that's modified by parameters that you set -- by moving sliders up and down or whatever it might be. [@] That's a good thing to do. [@] And that could be based on sampling or whatever. [@] I didn't put up the following idea, because I haven't thought it through well enough to know whether it's a good project or not: [@] Make a mash-up. [@] Find two pieces that are in compatible tempos and keys, and make a looping patch that allows you to superimpose them and change them around. [@] That would be a good thing. [@] But I don't know how to make that sound good and I'm not sure if you do it it will sound good, so I'm not sure that's a really good suggestion. [@] You don't know how to do this because I'm not going to tell you. [@] Tom might: [@] Think of something you weren't able to do in Pd, whatever it might be, and write a C object to do it and make that a new Pd object. [@] I won't go into that except to say that there are thousands of these running around. [@] They're not hard to do and if you want to see some of them they're all over the Pd source code and also there are hundreds of examples plus websites that tell you how to do this on the web. [@] But don't do this unless you know how to code C pretty well because otherwise you will have to learn how to code C, which you cannot really do in four weeks. [@] Make a melodyne. [@] This is fun. [@] It is not easy to do because, well, the hardness is not because it's inherently hard to do. [@] It's actually stupidly easy, but you have to have a pitch shifter handy and I haven't told you how to make a pitch shifter, and you also have to figure out what the pitch is of the thing that's going in so that you can figure out how much you have to correct it. [@] Then you have to make an algorithm that, given any pitch, figures out what the nearest pitch is that it could have been supposed to be. [@] So what you do is you say "the allowable pitches are the C major scale." [@] Alright. [@] And the current pitch that I'm getting is, who knows, 110 Hertz. [@] Well, that's not a real pitch, sorry -- 120 Hertz. [@] What's the nearest white key to that? [@] Figure that out and then make a pitch shifter to change the pitch by that amount then you can talk into it and it will sing, well sort of sing, it'll talk back at you in the C major scale. [@] Then you'll have a melodyne and you can sell it. ... [@] Actually, probably not because I think there are probably hundreds of them on the web now. " [@] Melodyne" by the way, is a trade name, but people use it generically just to mean something that whacks your pitch into something it's not. [@] Then you can go from there. [@] You can go wild from there because you can add a keyboard and make it allow you to play ornaments on things .... or what-not. [@] All sorts of good stuff you can do once you have this. [@] But the two things I haven't told you is how to find what the pitch of the sound is and then how to change the pitch of the sound. [@] Both of those are techniques that I will try to squeeze into the rest of the quarter, but I don't know if I will be able to. [@] Think of something else. [@] Oh, you know what? [@] Something else: [@] Go buy one of those Arduino hoo-ha's and make a little physical device that has buttons or knobs that allows you to give yourself a physical synthesizer and control interface. [@] Student: Arduino? [@] Oh, the usual one is called Arduino. [@] What I do is I go to sparkfun. [@] com and you can buy processors for like, it depends, but $20-ish and you can build little circuits out of them that are anything that you want. [@] You can make robots or sensor arrays or what-not. [@] And that really should be the subject of a different course. [@] And, also, you shouldn't do that unless you're able to deal with voltages and solder and things like that. [@] So don't do that unless you think you know what it entails. ... [@] Anyway, that would be another thing that would be perfectly cool, but I predict that most of you are going to want to make a drum machine or an interactive, playable laptop instrument or something like that and that's just cool because, actually, 30 different drum machines are going to have 30 different personalities. It'll be fun. [@] Questions about this? [@] This is all up on the web now. [@] Well, what this is so far is up on the web and if you have questions about it ask me and probably that means I should put something else up that says something more about what's going on. [@] So that's the final project -- It's a presentation. [@] We are now still doing modulation, continued waveshaping. [@] Waveshaping and not wave packets yet -- although I might get into that today depending on timing. [@] Because what I want to do is make sure everyone is on the same page just about the waveshaping thing first and then we'll proceed from there time permitting. [@] The other sort of organizational thing that I'm succeeding in not forgetting to say is the following. [@] I have two trips coming up and there will be a substitute teacher the next two Tuesdays: [@] Cooper Baker who is a graduate student who is also an expert Pd programmer and computer musician and circuit builder and many other things, who has a lot of good things to say and show will talk, I believe, next Tuesday about frequency modulation, assuming the syllabus works. [@] Then depending how it all works we'll be talking about delays the Tuesday after that and I will try to make it dovetail with the syllabus as closely as I can. [@] I'm still not sure how that's going to work with the taping scheme. [@] Also, taping: [@] All of these classes are taped thanks to Joe and you can get them, so don't forget if you need to review that's one possible way of doing it, which might be useful. [@] Questions about all that before I just jump in and patch away? [@] Or things I forgot to say? OK. [@] So now what I'm going to do is ... I showed you a sort of mathematical way of thinking of all this stuff last time, but this time I propose simply to go straight in and deal with it at the level of patch because -- just on the theory that if you change your teaching style every week it either makes everything totally coherent or else it makes everything totally incoherent... [@] depending on your point of view. [@] So this is where we go at the end of the last class where, let's see, I'm going to give us 110 Hertz which is a low A. [@] And then we were taking that signal and messing with its amplitude and then reading the cosine of it and that was giving us this kind of signal. [@] Let's see. ... [@] I'm going to do is give us both channels. [@] I don't know why. [@] Turn this on then turn this on. Yes. [@] So in goes sinusoid, out comes signal like that and the good thing about this signals is it changes timbre when you change the amplitude. [@] There are two things happening here that I mentioned last time: [@] One is, yeah, non-linear things like cosine don't react to doubling the input by doubling the output. [@] They react to doubling the input by changing the output. [@] And that's maybe most easily described as a change in waveform. [@] The other thing I wanted to do was graph this so that you can see some sort of representation of what this is. [@] Woah! Oh yeah ... I'm listening to that and I'm graphing that. [@] Here it is. [@] This might remind you of what happened when I used the exponential look-up function last time which is if you give it an index of nothing you don't hear anything because we're multiplying it by 0, this adder's adding 0 too -- I haven't got there yet-- and now we're taking the cosine of 0, which is 1 -- so the thing is just sitting at the top of the table being constant 1. And then as we push this up we start getting sound and the thing starts acting like a pulse train except it's not because instead of reading an exponential we're reading at cosine. [@] So that after a certain point, well, so this is the most pulse-trainy it looks -- But notice that it doesn't just sit at zero it does the next thing, which is rising again. [@] So now the waveform that we've got is: [@] we're making a sinusoid and we're reading the cosine wave, but we're reading not only the first lobe of it, if you'd like, which is to say it goes from minus one up to one, that's at zero, and back down to minus one, but we're making it go past that amplitude a half thing and therefore it's giving us the next wiggle, if you like. [@] Oh, I should put this in a metronome so you can see it. [@] Well, maybe I shouldn't. I will. [@] Let's not do it to crazily fast. [@] And now I need a nice toggle. [@] So, by the way, the reason this is changing, of course, is because the cosine is at a different phase each time the metronome goes off. [@] Meanwhile, as I change the amplitude of the cosine the waveform changes because it's reading more and more cycles of the cosine wave it's looking up in. [@] Actually, I should turn the frequency down so you can see it more clearly. [@] So now we have ... nothing ... turning into something looking kind of sinusoidal but not, and then turning into progressively higher and higher frequencies. [@] And you can almost tell just by looking at this that this should have high frequencies in it, although I don't know a simple theorem that says that the more a thing wiggles up and down the more high frequencies it has. [@] Even so, it's clearly true that if you make something like this it's going to have some high frequencies that it didn't have when it looked more like this. [@] Whoops. What did I do wrong? I didn't hit the return. Like that. [@] So that's the amplitude-to-timbre change. [@] The good thing about the cosine as a waveshaping thing is that no matter what you do to this index, it gives you out roughly the same power. [@] So even if you ask it to make some ridiculous index -- All right, how about 10,000? [@] All right. [@] Well, OK. [@] But we can tell that it was basically, I mean, it ranges from -1 to 1 and, you know, the power of that thing is going to be roughly the same as the power of the original cosine wave. [@] That's a good thing for building computer music instruments because it means that you can put it into your amplifier and expect decent results to come out. [@] The previous example, which was the exponential, sort of did that except that, actually, let me get it out and show it to you. [@] Let's see. [@] I'm going to save this and close it because I haven't changed the name of the table. [@] I changed the name of the table. [@] Let's see. [@] This is 17. Alright. [@] Do that. [@] Now we can actually open the other one and they won't fight. [@] 2.15 ... There it was. [@] This one now, oh, wrong. -- [@] Oh, I'm sorry. [@] I'm looking in the wrong place. [@] Where I wanted to look was in the help. [@] We were doing this and then we were looking at "E" -- exponential. [@] Sorry. This is the real one. [@] Now we have this situation where we can listen to the sound ... Oh yeah -- give it an index. [@] Now it makes waveforms like this, but the trick is here if you start giving it extreme values here, which I didn't allow you to type because I didn't want to reveal this right away. ... [@] 2,000. At some point you're going to notice that this thing doesn't have a whole lot of power and it's going to start fading out. [@] So 20,000. Now it's getting quieter. [@] So this is not terribly well behaved from the point of view of the power of the signal, although it's not too bad psychoacoustically, for the usual reasons. [@] Using the cosine is much more gentle to your audio hardware because it pretty much gives you the same signal power no matter what you do to it except in extreme situations like almost zero. [@] So the next thing about this is this: [@] Let's see. [@] Let's go back down to something reasonable and let's listen to it. [@] So we can also ask for the cosine or for sine by moving by 25 percent down the waveform and then we have this change and then we have this stuff in-between, which is changing the even and odd harmonics. [@] That could even be a useful thing to listen to. [@] So that's exploiting the fact that the cosine is even, the sine is odd and if you just graph the cosine and changing the place that you look at, just moving the origin, you can move continuously between being an even and odd function. [@] That's a good thing. [@] That's a property that the exponential wouldn't have. [@] As a sort of sneak preview, OK. [@] So sneak preview -- This will last about five minutes: [@] How to think about frequency modulation in these same terms. [@] Alright. [@] Let me just do a save here, or save as because I don't have to ruin my patch. [@] So what I'll do is I'll make two exactly equivalent frequency modulation patches: [@] one the correct way to do it and the other the way that allows you to actually think about what it is and what it does. [@] So frequency modulation is this. [@] First I'll do the classical one. [@] Give yourself an oscillator. [@] Oh, actually, let's do the whole thing. [@] Let's see. [@] I'm going to get rid of this. [@] This is now an amplitude controlled oscillator here. [@] So I'm going to make myself a copy of that. [@] Let's see. [@] Does this work? [@] I'll give it a frequency then an amplitude and amplitude -- Sound! [@] Now, next idea is what if we took this and took another one and used this one to control or to mess with the phase of the other one? [@] How would you do that? [@] So we need another oscillator whose phase we can mess with, so we can't actually do that by just doing the simplest form oscillator with osc~ -- we have to split that into cosine and phase. [@] So we'll do that. [@] So now this one's going to be an oscillator alright, but it's going to ... oh dear. [@] I don't know where to put this. ... [@] I really need to put it on the other side. [@] OK. This one I can leave alone and this one I'm going to make the phasor and the cosine separate. [@] So there's a cosine and then we're going to say phasor. [@] Alright. [@] And this now is just another oscillator. [@] It looks like we can't hear it. [@] Alright. [@] Except we can't hear it. [@] Why not? [@] Am I doing something wrong? [@] Now what we're going to do is take this oscillator and use it to mess up the phase of this oscillator by adding it to the phase. [@] I should put a plus~ to be explicit about it, but I'm going to be lazy and not do that. [@] Then I'm going to move this up here so you can see what's going on. [@] Alright. [@] That's as well as I'm going to be able to make it. [@] So now we'll listen to this one. [@] This one, to start with, I'm just going to make it run at six Hertz then I'm going to do that to it. [@] Oh, let's make this higher. [@] So now what we're doing, this is not what I showed you in the first couple of weeks of class when I showed you, "Oh here's an oscillator and here's another oscillator changing the frequency of that one." [@] Here, instead, I've taken this oscillator and split it up into a phasor and cosine so I can add this other oscillator not to the frequency, but the phase. [@] Why? Because that's the way that people do it. ... [@] You know, there are two reasons to do this. Well, three. ... Yeah?? [@] Student: Couldn't you accomplish the same thing by adding it into the second inlet of the oscillator? [@] No ... Because the second inlet of the oscillator takes messages to set the phase, but then the phase starts taking off from there, so the signal itself doesn't add in. [@] It won't take a signal to offset the phase. [@] So you have to explicitly do it this way. [@] OK. So why don't you just have an oscillator here instead of separating it and then just changing the frequency? [@] The original reason, I think, was because this was once implemented in fixed point hardware and it turns out that if you put the thing up here you have to put it in units of frequency, so you have to have the values in hundreds or thousands and that wasn't a good kind of an amplitude to give this oscillator if you were working with hardware whose maximum amplitude might be one. [@] So people figured out that by changing the phase directly instead of changing the frequency you got to give this thing a much, much smaller amplitude for the same amount of modulation. [@] So this is almost equivalent to putting this thing in here, except you have to give it much smaller amplitudes. -- [@] Here I have an amplitude of 10 and it's already giving me plenty of modulation, much more so than if I had taken that and put it here. [@] I won't do that now -- in a minute. [@] And, again, the more you give it the deeper it gets. [@] And then if I change this oscillator to an audible frequency then we get this kind of stuff. [@] This is what people sell you when they sell you a frequency modulation instrument, although to be completely pedantic about it, this is a phase-modulation instrument. [@] Another reason for doing phase-modulation instead of frequency modulation is it's better behaved if you're not using sinusoids but other waveforms or if you are using more than one modulator or more than one carrier. [@] In other words, if you're making more than two oscillators, if you're making a more complicated network with five or six oscillators talking to each other, for various technical reasons it's better to operate on phase than on frequency as well. [@] Alright. [@] So this is the incorrectly called frequency modulator, which is a phase-modulation instrument. [@] I think this is mostly what Cooper will talk to you about next Tuesday, but by smartly choosing these two frequencies and this so-called "index of modulation" you can make all these wonderful sounds. [@] And you're not limited to only two of these. [@] You can make bunches more and then you can be smart about how you design the sound. [@] There's a book about that that came out in the '70s or '80s so you can find out lots of stuff about just frequency modulation. [@] Well, not to go too far down that route... [@] Why am I talking about this now? [@] Because this is equivalent to one of these, so you can think about that by thinking about waveshaping -- if you're careful. [@] So the careful way of thinking about this as waveshaping is the following: [@] this is the cosine of the sum of two signals, one is a phasor and the other is a sinusoid, OK, but the cosine of the sum of two things is equal to the usual formula: cos(A + B) = cos(A)*cos(B) - sin(A)*sin(B). So we could rewrite this network -- And I'll only do the cosine half, I won't do the sine half just to save sanity. [@] (OK. I need a new window anyway. So make new window. Oh wait. You know what? This is a new window. I can just erase this.) [@] Another way of thinking about this is we'll take the cosine of this and we'll take the cosine of that and we'll multiply them. [@] Let's get rid of this because we don't need it anymore... [@] So here's taking the cosine of the oscillator. [@] That's taking the cosine of this side. [@] Now we'll take the cosine of the phasor. [@] That's one of these. [@] Then we'll multiply. [@] So I'll cut these off and then I'll just say times~. [@] And here, of course, there's another simplification we can make: [@] Phasor and cosine, we're not sticking anything extra here, so this actually could just be an oscillator -- So this is equivalent to just saying osc~. And now look what we've got: We've got exactly that waveshaping instrument that I told you about before, which is: Take an oscillator and change its amplitude and take the cosine of it and then multiply that by this oscillator. [@] And you've seen that before -- That's ring modulation. [@] So frequency modulation is equivalent to two networks like this because the other one would have to use sine instead of cosine, but basically it's an oscillator, take the cosine, that does this, and then multiply it by some other cosine and then you get these sounds. [@] Those sounds are pretty much the same kind of sounds as these sounds, although I'm pulling a fast one on your because I'm not really checking that they're exactly the same. [@] But, morally speaking, that's about the same deal. [@] So frequency modulation you can understand by understanding waveshaping and ring modulation and, again, the word modulation just means change and computer musicians use it to mean all sorts of things. [@] So don't consider ring modulation and frequency modulation as being in any way related except for the fact that they both use the word modulation for artificial reasons. [@] Ring modulation is this multiplication thing. [@] Ring modulation is linear, but it is not time invariant, so it is able to make new frequencies out of old frequencies. [@] That will get explained in more detail later, I think. [@] Then this is running this oscillator with an amplitude control through a non-linear function and this amplitude control corresponds exactly to this thing, which is called the "index of modulation" over in this thing, which is where we're doing phase modulation. [@] So now modulation means ring, frequency, phase, and then something else. [@] ... Questions about this? [@] Student: I have a question. Does a DX7 use this phase modulation? [@] Yeah. Except they have six so-called "operators" instead of two. [@] I don't know why they call them operators. They're just oscillators. [@] Then you get to make various networks of the six. [@] There's some circuitry that allows you to re-route signals. [@] But, yes, basically this is what's happening inside a DX7 for those of you who know what a DX7 is. [@] They came out in '84 maybe ... Yeah. Now it's called a cell phone. [@] So this is the relationship between waveshaping and frequency modulation, however, it is a special case of waveshaping because it's this cosine function here. [@] If you threw any other function in besides cosine you would no longer have this identity that the sum of it means multiplying two of them. [@] In other words, this trigonometric identity would work out differently if it were not cosine, but some other function -- Then this wouldn't work. [@] So this kind of waveshaping followed by modulation is a much more general way of doing things, in some respects, than frequency modulation is. [@] In fact, I guess this is the moment to say this: [@] What would happen if you just made this thing be exponential instead? [@] So what hat means is we go back to our patch. ( [@] I threw it out. [@] OK so I'm going to save this. ) [@] What I'm going to do is go back and get help and get that exponential patch again, the exponential waveshaping patch, and do the same thing to it to see what we get. [@] Whoops, sorry. [@] Go back here. [@] I don't want to build it because I don't want to go through the hassle of making this function. [@] I'm just being stupid because I could just use exp~ couldn't I? [@] OK. Let me be smart now. [@] I'm going to get rid of this. [@] Oh, wait, I want all this graphing stuff. [@] I'm going to keep this because I want to graph this for you. [@] So we're going to save this as then we're going to go back over. [@] So this'll be three. <> [@] So now what I'm going to do, OK, so reminder: [@] What this path does is this kind of sound and this kind of waveform. [@] So there's the waveform up there. [@] It hates me because I've got too much stuff on the screen. [@] There's the waveform for you and here's the spectrum. [@] And to make it clear what's going to happen next I'm going to try to move this over so that you can see the whole spectrum pretty much. [@] Alright. [@] Now what I propose to do is to take this. -- [@] Oh, by the way, the reason you hear these skips in the sound is because it's using CPU time to graph these tables, which is making my little machine hate itself. [@] If you want to have tables that are changing while you're computing stuff put the tables in a sub-window and close it so your machine doesn't have to graph it so you won't get these skips. [@] But I'm being pedagogical, so I'm leaving everything out here on the main page where everyone can see it. [@] OK. So now I did the table lookup. [@] Now I'm going to operate exactly as before, which is to say I'm going to multiply this by a nice sinusoid. [@] So what that means is we'll say times <<*~>> Oh, I made one. [@] Well, get this one. [@] Here's an oscillator, here's an amplitude thing. [@] Oh, but I don't need this. [@] I just need a number and this is no longer index. [@] This is now a ring modulator. [@] Oscillator times ... Now we look at it and listen to it: [@] So nothing's different yet, but if I start changing this now I get classic ring modulation. [@] Well, it's just going to be what it is. [@] So each one of these peaks is split into two peaks because that's what ring modulation does to a spectrum. [@] This is the spectrum and this is the waveform and we're multiplying rather slowly. [@] This thing is not really showing the waveform as it's changing because it's really going up and down 15 times a second, but if I make this higher then eventually you'll start seeing... [@] Oh, drat -- I want that thing to be limited. [@] There we go. OK. Let me see if I can get it exact. [@] So now what we have is a sinusoid which I tuned just by ear to be the second harmonic of the pulse train, and now if I start pushing the index up I get a hat shaped function, which is centered around this frequency and, in fact, I can make that whatever I want. [@] I can slide this thing wherever I want and have this sort of hat shaped spectrum move to whatever location I want it. [@] So now this is controlling bandwidth and this is controlling center frequency of the spectrum. [@] "Bandwidth" is a term you will hear a lot in computer music. [@] It just means the width of the band, but bands in this case are ranges of frequencies. [@] That, I think, is radio terminology originally like the "FM band." [@] So in this case what we're talking about is a band of frequencies like that. [@] Why would that be a "band"? [@] ... Never mind. [@] The center of the band is being controlled by this ring modulating oscillator. [@] This is what happened to DC. [@] So if I send the oscillator to frequency zero the biggest peak is at DC, right? [@] This peak then got aliased out somewhere here and then these peaks got aliased out to DC plus and minus those frequencies. [@] Or, to put it another way, there are negative frequencies in this thing that I'm not graphing and when we multiply it by a sinusoid which then moves it over, it actually moves it over like that, then we see the negative frequencies, as well as the positive ones showing up, which is this. [@] Oh, we don't see any negative frequencies until this one bounces off. [@] Then there's the sound. [@] Now, these are perfectly nice, harmonic sounds as long I choose these things just right, like that number I found. [@] OK. So this is going to put out a pitch, which is controlled by this fundamental. [@] I don't know when this fundamental's being computed, so I can't use it. [@] This fundamental must be something about half this, like 170 something, but I think it was computed using load bang, so I don't think if I use it now it's going to give me a new value. [@] What else can I say about this? [@] What does it look like in the time domain? [@] I guess what I should do is ... Let me stop modulating it. [@] So there's our nice pulse train and I'll skinny it up so that the pulse is decently small like that. [@] Then when I start multiplying it by an oscillator, just to see what happens I'll give it a very high frequency here -- 5,000. Now, what we see is that there is a pulse train. [@] Every time this thing makes a pulse, which it does every cycle, you get a pulse times this oscillator and I asked this oscillator to go very, very fast so that you can see it, but what's happening here is just a bunch of pulses, one after the other. [@] Now the center frequency's way off the screen here so you can't see the spectrum anymore. [@] But you can sort of guess what this thing should sound like. [@] Its period should be from here to here. [@] (That's the smallest interval at which you can see repetition). [@] So that period's being controlled by this fundamental frequency, as long as this one's a multiple of it, which it's not so I'm pulling a slight fast one here. [@] Meanwhile, if you think about what frequencies are present in this as a signal, they're mostly high. [@] They're mostly these frequencies here and that agrees with the general observation about ring modulation, which is if you ring modulate by a very high frequency it takes whatever you've got and slides it to where you can sort of see it as a clump of frequencies around the modulated frequency. [@] So another observation about this is that... [@] ... Questions about this? [@] Is everybody completely confused now? [@] There's nothing complicated about this patch, but the complexity is all in how you analyze what it does and that is typical, unfortunately, of electronic music, which is putting three or for modules together that quickly leads to a situation where it takes hours or days to explain what the thing is actually doing. [@] That's just what it is. [@] And unfortunately you have to go through the explanation because I don't know any other way to be able to design things with a some notion of what they're going to do. [@] Student: Can we hear what it sounds like? [@] Oh gosh! If you really want to. [@] Sounds like something out of Poème électronique. <> [@] Most of these are inharmonic, but every once in a while I'll hit a multiple of this and get a harmonic sound, but you can't even really tell the difference. [@] Well, there are theories of perception that say -- I don't know if they're true -- that basically the first ten harmonics are the things that your ears will use to try to determine the pitch of the thing and then after that your ear hears that there's energy there, but you won't use the pitches of the harmonics to tell you what the pitch of the original sound is. [@] So here, don't do this, but I could take this thing and add it to the modulated sound and now you hear a nice sound with a fundamental and some nice high harmonics. [@] And those high harmonics they don't have anything to do with that sound -- They're just whatever frequencies they are, but your ear can't tell that so it just accepts it. [@] All right. [@] Don't tell anyone I told you that. [@] Oh, actually, it's not as useful a fact to know as all that because, in fact, what you'd really like to do is make things that can change _controllably_ between stuff that has low frequencies in it and not. [@] And, of course, as soon as I change this thing so that some low frequencies come in you're going to hear the fact that they're mis-tuned and then you're not going to believe that that's a harmonic tone any more. [@] So you would have to work harder if you want to make a general instrument that would allows you to do thiskind of thing. [@] And I want to show you how to do that, but maybe not right now because ... Why? [@] Because there are two ways of doing it and they're equally important and I don't know how to fit both of them into one half of a class. [@] So what I want to do is show you things that will be useful for doing final projects. [@] So there's stuff that doesn't fit in the syllabus that's just lore about how to use Pd, so what I want to do now for the rest of this class is show you Pd lore that is of use for just building stuff. [@] The most important thing that I haven't told you how to do yet is sequencing. [@] Well, I've told you how to do two kinds of sequences -- both of which are table based. [@] The thing that you do is make a counter and you make the counter count through the table. [@] It can either be a phasor reading a table as a signal or it can be a metronome driving something that increments. [@] That's a way of making a 1960's kind of sequencer and it's appropriate for driving monophonic synthesizers and then for polyphonic stuff, OK, there's a certain place you can go with it, but it's not going to like do general polyphonic sequencing for you. [@] So how would you make something that's actually capable of polyphonic sequencing? [@] There are many ways, but I'll show you one that is just the second most general -- the third most general. [@] Something that's about the right level of complexity to get most people's needs, but without having to spend hours and days learning how to do it. [@] So here it is: What I'm going to do is make a new window and give it a name. [@] It's going to be 4 ...sequencer. <> [@] So the object that does sequencing, in the most general form that I want to deal with right now is called "qlist". This is probably a misuse of the word "qlist." ( [@] Let's make it have a decent font...) [@] But we can call it that anyway. [@] What a qlist is is a bunch of messages in Pd language that can have ... I have to tell you some things I haven't told you: [@] First off, message boxes. [@] Messages boxes and receives: [@] I've shown you how to do this so far: I've shown you how to do "send name1", "send name2". Then we'll have "receive" s. [@] Oh, "s" and "r" are short for "send" and "receive". And now I'm just going to put numbers here so that you can see that this is a way of making a non-local connection. [@] All right. [@] So my reason for showing you this is so that I can now show you the following very strange thing: [@] Let's get a message. [@] First off, let's make it just have a number in it and do this. [@] Oh wait, that's the same number. [@] OK. That's all good. [@] In fact, I showed you another thing which is that you can have commas. [@] And here, if you do that, you will send those three messages and you'll just see the last value, even though the number box actually attained all three of those values, all in a zero period of time. [@] OK. You've seen one other syntactic element of message boxes, which is the dollar-sign. [@] That's the thing that allows you to have an incoming number that changes the message. [@] There's one other syntactic thing available for message boxes and that is that you can have messages separated semicolons -- and by convention I put a carriage return in here. [@] So now if we do this, what we're doing is we're saying the message is 56 and then there's another message which is 67, but that message is going to be sent to the object named "name2" or the objects named "name2" -- all of them, if there are more than one. [@] So comma means begin a new message. [@] Semicolon means begin a new message and, by the way, this message is not going to go to this outlet at all; it's going to go this other object. [@] ... Yeah?? [@] Student: So if we didn't have name2 there would it go to name1? [@] No. It would try to find an object named 67 and that's not a legal name for an object because it's a number and so then I should see an error message. [@] I hope I get an error message. [@] It just says "float no such object." [@] Oh, that's horrible. [@] Anyway, yeah. [@] So there's no such object as 67. It's not letting me do that. [@] So you have to give it the name of a destination. [@] Next thing. [@] We don't really even have to use this first one. [@] We can just say "no message at all, thanks, but name1 gets a message 67 and name2 gets a message 34" and then when we whack that those two messages go out. [@] Now, this is starting to look useful I hope. [@] Now we can do this kind of stuff. [@] So it's almost a preset mechanism. [@] Not quite. ... Yeah? [@] Student: Do you need to have a semicolon in front of it like that? Can you put name1 123 semicolon then name2 221 semicolon and would that work? [@] Yeah. You have to have the semicolon otherwise there will be a message "name1 123" and that will come out this outlet, so the first semicolon means the name of a receiver follows and the receiver is this. [@] So this is really a strange, ugly syntax. [@] But it's what it is. [@] It's consistent. [@] It's logical even though it looks weird. [@] Now I showed you that so I could show you this: [@] This is cool and this will allow you to have any number of parameters in a patch. [@] So I could now make an FM instrument and give the carrier frequency, well, I'm using names I haven't described. [@] You know, the frequency of the two oscillators, those could have names, and then the index of modulation could have a name, the amplitude could have a name. [@] I could make it six operator and I could have, I don't know, 12 names and that would all be cool. [@] And then I can put them all in this one message box and just whack the message box once and all those values would go off to all the right things. [@] I probably should have told you this before. [@] You know, this becomes almost inescapably important as soon as your patch reaches a certain level of complexity. [@] While we're here, it's always good when you have a patch more than a certain amount of complexity to have a button which is just "reset." [@] So you probably have already had the experience of starting a patch up and not have it doing the thing it was doing when you last closed it. [@] This is your friend for being able to get things to go back to startes that you know about and it's often worthwhile having one of these things hooked up to a load bang so that every time your patch opens up the values are as you wish them to be when the patch loads up. [@] All right. [@] So this is not computer music knowledge. [@] This is just Pd lore and when you change to some other programming language this will be different. [@] Now, about qlist: [@] So this allows you to do everything you could possibly want except for sequencin And now if you wanted to do sequencing with this I could tell you how to do it using delays. [@] Well, you already know. [@] You just make a whole bunch of message boxes separated by delays. [@] Yeah. And, in fact, let me show you the first ever Max patch, which I've imported into Pd, which does exactly that. [@] I'm just doing this to horrify you. [@] So we're going to go back to here. [@] "Repertory" because this is going to be public. [@] We're going to go look at Pluton. [@] This is on the web, by the way. [@] If you download the "Pd repertory project" you can look at all these scary patches. [@] This is going to be "manoury-pluton" and then we're going to have a patch called "pluton. [@] pd" This is a 45 minute long piece of music. [@] Maybe 48. And here's -- I'll get one at random -- here's section 31. It has a queue, which is a number, and then it has sub-patches and this sub-patch has events numbe 1, 2, 3 and 4 in it. [@] So we'll get an inlet and we'll select 1, 2, 3, and 4 and each one of them is going to have message boxes sending parameters to values. [@] You can make message boxes like this. [@] You will tear your hair out after a certain amount of time keeping track of when you changed what because obviously this could lead to horrible messes. [@] If you go looking in the right place, this is not a good example, but if I find a good example you'll find delays in here. [@] Nope. Nope. OK. 21. Here we go. [@] Oh, bad, bad, bad -- Wrong section. [@] Two. ... Yeah. Here we go. [@] So why don't we, on event 5, do all of this good stuff, but after a delay of 5 seconds we'll start at the other sequencer, whatever that is. [@] OK. So now we have the ability to wait until event number 5 comes in, never mind who's figuring out what queue we're on, but you can think there might be a queue number 5, so there's an incrementer in there somewhere. [@] And event number 5 means do this, I shouldn't do that, and then after 5 seconds do this. [@] But what if someone did event number 6 before those 5 seconds had elapsed? [@] Then you would have event 5 then part of event 6 then part of event 5 happening. [@] What if this thing started something that this thing was supposed to stop? [@] Then instead of starting and stopping it would stop and start and then you would have the thing playing for the rest of the piece, which you didn't want, right? [@] So you'd better stop this delay when the next puppy comes in or else it's going to go off. [@] And then it gets worse. [@] OK. So this is making sequencers using message boxes. [@] You can do it, but -- not pleasant. [@] Also, you will not be able to download a text file from the Internet and have it be that, right? [@] So that was Pluton. [@] I'm not going to show you more about that just now. [@] So there's a better way, which is to make a qlist. [@] A qlist is read from a text file, I should say, and the text file has a bunch of messages in it that are separated by numbers that are event numbers -- or actually that are times I should say. [@] So qlist acts like this. [@] First off, you have to be able to read files in. [@] So I'm going to make a message box that says "read sequence1.txt" and I'm going to give it an extent ".txt" because on some kinds of machines if your file isn't named something. [@] txt it doesn't know it's a text file. [@] Now I'm going to make a text file named sequence1. You all have Macintoshes and you will get out the text editor and it will not make a text file by default. [@] It'll make a "rich text file." [@] You've got to make a real text file and there's something in the text editor on the mac that lets you do this, but I've forgotten what it is and it takes some finding. [@] OK. I don't need this anymore. ... This thing is just an orphan, so let's get rid of it. [@] Now what I'm going to do is make a nice file. [@] Are we in the right directory? [@] Yes. I'll "nedit." OK. [@] Text editor: Now I'm going to say message one. OK. [@] So "name1 45;" "name2 67;" and then let's wait a second and then let's do name1 back to 0 just to make it look like it's turning off. [@] OK? Oops, I don't want that space there. [@] And notice I'm putting semicolons after every line because semicolon is the delimiter here -- just like in message boxes and if you forget then it will not do the right thing for you. [@] Did I say sequence or sequence1? [@] I thought I said sequence1 ... [@] Then let's go back and get the patch. [@] I've got all this junk open that I don't want. [@] Yeah, of course I want to save. ... Yeah. [@] Now we say "read" and meanwhile let's just check, make sure we didn't get any errors. [@] We didn't get any errors, good. [@] Oh, and of course if I had said the wrong thing here then I would get some horrible ... Then it would say "message file." [@] Yeah, right. OK. So this is good. [@] We believe that this is working right. [@] Now what can we do? [@] We can just say bang.. [@] And then it says boing, right, and there's the sequence. [@] So do it again? [@] Idiot's delight now. [@] OK so name1 and name2 are the "receive"s and now we hit the qlist and there's the first message and there's the second and those are the two messages or the two pairs of messages I've put in this file. ,,, [@] Where's the file now? [@] I think I must have closed it. There. [@] So that is the easiest way to sequence stuff in Pd. [@] And you can combine this with ... oh, these can be any kind of messages you want, so you can combine this with line~ objects to do things that ramp or whatnot. [@] I mean, anything you can do with messages. [@] You can cofect things that have messages with bunches of arguments and then use unpack to get them out. [@] Which one would do a lot of, actually ,when you really are doing this. [@] What else should I say about this? [@] Other messages qlist takes: [@] I don't know if, well ... "print" 's a good message. [@] When you tell the thing to print itself, out on the Pd window comes everything the things has -- sorry about the back slashes. [@] That's a good way of checking whether the thing is what you wanted to do. [@] And finally, and now we are going to be living dangerously. ... [@] If you want to make a nice loop out of this you could do something like this. [@] Let's go back... [@] where's the text file again? Here. [@] Let's say we want to do this and then we want it to loop. [@] So I'm going to say after another second -- By the way I could either have the semicolon or not here for technical reasons, but I'm going to put it just to be simple. [@] And then I'm going to say "restart bang." [@] Semicolon just to be complete. [@] Oh, this is not a really good idea is it? [@] How am I going tt ever be able to stop this? [@] Student: Is there a "stop" message? [@] There is, actually. [@] That will work. [@] We'll do this: [@] "stop" ... Let's just check; so I should be able to say "bing" ...and the third thing is going to be an error message, because there's nobody named "restart." [@] Oh, I ditn's get an error. [@] Oh I didn't save ... This is the sort of thing that happens -- you've got to save this, then you've got to tell it to read the sequence, and then you can tell it to do this stuff ... "bing" .. "bing" and then the error there" "restart: [@] no such object" And now I can say "receive restart" and that's just going to bang the qlist -- I'll make if flash by hooking it through the button. [@] I hope this works: Yeah! [@] So now, you have another way of making the step sequencer, if you wanted to. [@] There's one little thing about this, one more mesage that you might like, which is that you can set the tempo. [@] Let's do it this way: [@] $1, recall is, in a message box, in the message box context, $1 is just "take the value and stick it in the message." [@] So here if I say 1 it's going to be "tempo 1, which should be the original tempo, and if I double it it does that for me: [@] ... And then "stop" doesn't stop it! -- because it doesn't have a method for stop... [@] I think it's called "rewind", actually. Good. [@] Why is it called "rewind"? Because there's more that you can do that I'm not telling you about. [@] You can, if you want to, single-step through the messages instead of having it sequence through them. [@] So to do that you send it "rewind" and then "next" and then you can control your own timing instead of using qlists' own timing and that would be useful if you wanted to make something that had random variations in the timing or some algorithmic way of controlling timing besides just the numbers in the qlist itself. [@] Given the fact that there's this "tempo" message here we could set the tempo to 1/1000 and then just have this thing be in beats like one beat instead of 1,000 milliseconds and that would work fine. -- [@] Although when I'm starting out I just always do it in milliseconds because it's easier to think about that, I think. [@] You don't have to agree with that. [@] Oh, since everything else in Pd is in milliseconds it might just be easier to have them be coherent as opposed to having them be different in the qlist from everywhere else. [@] So that's the qlist object, which is key to making sequences. ... [@] ... Yeah?? [@] Student: Can you explain the $1 in the "tempo" message? [@] Oh yeah. [@] This is a very confusing thing. [@] So what I'll do is I'll print these out and give it a couple of tempi like that: [@] ... and then it makes messages and the messages are what you put in there except that $1 has substituted for it the value of the first argument that went in. [@] So this is the way that you can make messages that vary inside a single message box. [@] And furthermore, if you have a packed message with several numbers in it they can be addressed as $1, $2, $3 and so on so you can have multi-dimensional variability. [@] You haven't had to do this much because you haven't seen very many objects which are complicated enough where they take a bunch of different messages like this. [@] For the most part, messages are always just numbers because usually simple objects only do one kind of thing, or at least one kind of thing per inlet, so numbers suffice as a message passing language, but an object like qlist it has a bunch of state, there are a bunch of things you might wish to ask it to do like rewind and go to the next thing and change its tempo and so on. [@] And then you need a bunch of different kinds of messages like this and then you need message boxes that can put together messages that have both words and numbers in them, symbols and numbers, and have them still be variable. [@] So I've been avoiding doing this for reasons of sanity, but that's there and ready to get used. ... [@] Other questions about this? [@] ... Yeah? [@] Student: What are the outlets of qlist? [@] The outlets are useful if you want to make your own sequencer. [@] This one gets a bang whenever qlist finishes, if you want to know that. [@] Actually, I could have made this loop in a different way by just doing that. [@] This one doesn't get anything when qlist is being used as sequencer by itself, but if you single step it, if you say 'next,' it goes up to the next number and then outputs the number here. [@] So, instead of having it interpret that number at time, you grab the number or numbers and interpret them to be whatever you want them to be. [@] That's how you would make your own sequencer out of qlist, that might do something more manual. [@] And there's too much information in the help window for qlist that will tell you all this. [@] The easy way to get confused with qlist is to change the sequence in this text file and then forget to tell it to reread the new sequence. [@] Also, if you read in a new sequence, I believe it will insist on rewinding itself, so it won't be able to continue playing the sequence if you change the sequence while it's playing. [@] With one exception, this is able to do all of your sequencing needs. [@] The one exception is that all these names are global, name1 and name2 and so on. [@] If you wanted to have a bunch of instances of a patch, each of which was using a qlist to control different variables that were "local," or dependent on the patch, then the qlist wouldn't suffice to do this. [@] You would have to reach for a lower-level tool that allowed you to get those things and play with them yourself. [@] There are ways of doing that. [@] In fact, if you get the qlist help window, it will send you on to the thing called "text file", which gives you less automation and lets you build more general things than what the qlist can do for you. [@] So, just to review where we're at, because we only have 5 minutes - that's not enough time to go start doing wave packets or whatever it's going to be next. [@] Next time is going to be frequency modulation from more of a 'how to do it' standpoint. [@] How to make sounds out of it as opposed to simply with the theory is. [@] I've tried to fit that into this tale about waveshaping, which is what the last couple of things have been about, and ring modulation. [@] Where we are in the book is now Chapter 5-ish/Chapter 6. Chapter 6, I think, is what I'm going to squeeze down to a day or two, and that will be Thursday of next week if it's only one day. [@] The topic there is going to be how to go back and use that combination of waveshaping and ring modulation in a way that would allow you to be able to move the energy around from peak to peak without having this problem not having things be harmonic when they're between two multiples of the same frequency. [@] That's an important thing to be able to do, and there are several techniques for doing it. [@] I think what I want to do is show you two of them 00 although I have to think very carefully about whether I can fit it in a reasonable amount of time. [@] So, that would be next Thursday. [@] Meanwhile, you see, I think, what you need to be able to see in order to do things that have sequences. [@] That's sort of where we are. [@] And in book land, I've taken you pretty much all the way through modulation because this thing about frequency and phase modulation is that rampage I went on about FM earlier. [@] Then I'm going to give short shrift to this next one, as I call it, "designer spectra" -- That's just my own fanciful title. [@] But that's going to be about how to make peaks in the energy spectrum independently of whether the sound that you're making is harmonic or inharmonic. [@] That's what's coming up next. [@] I've been looking in there, trying to make a plan as to how to do it but I haven't succeeded. [@] Then, starting the week after next is going to be time shifts and delays. [@] That's going to be how you make the standard delay effects, but also how you design reverberators and also how you do delay tricks like pitch shifting, phasing, and chorus effects and what not. [@] That will probably take a week. [@] Then, by week 10, it will be time to look at GEM and that will probably be the rest of the quarter. [@] *** MUS171 #15 02 22 (Lecture 15) [@] Last time we ended up doing sequencing. [@] But before we showed the sequencer, there was talk about waveshaping and frequency modulation and, in particular, there was a patch that tried to show the equivalence of waveshaping and frequency modulation synthesis. [@] Actually, what I'll do is I'll get that patch out just to remind you that it was there. [@] That would have been 2.17 FM. <> [@] Here is the fixed-up patch with a smaller font size, but you can see that this is making the point that over here there is waveshaping and ring modulation which was making sounds. [@] Do we have sound? [@] I didn't check the sound yet. That was really smart of me. Sound. Carrier frequency. [@] And that, hopefully, you're willing to believe sounds something like what happens when I do frequency modulation, which is this thing where you take an oscillator like this, and start changing its frequency, but then start changing its frequency fast enough to get this sort of thing: [@] So that is the well-known sound of frequency modulation, and this patch was a description of why you could think about frequency modulation as waveshaping. [@] And if you want to know what the spectrum of a frequency-modulated sound is, that's to say if you want to know the strengths of all the partials are that it can make and what their frequencies are, then you can analyze it by thinking about what this patch would do. [@] That leads you into engineering mathematics -- You have to know Bessel functions, which I don't want to tell you right now. [@] So Bessel functions aside, and in fact all of this aside, what I'll do this time is just go back to the basic frequency-modulation patch, build it from scratch, and show you what it's good for, just in terms of sound making. [@] The punch line is going to be that it's a thing which combines two oscillators. [@] But, of course, you can combine 50 oscillators and all sorts of frequency-modulating networks where each one modulates the frequency of some other one, and then finally you listen to some oscillator at the bottom. [@] So frequency modulation is this very extensible, very complicatable thing. [@] So I'm going to get rid of this and start from scratch. [@] Just to be nice and pedagogical again. [@] So let's see. [@] We have an output device. [@] I'm just going to start with oscillator ... So the oscillator is ... let's get a frequency going, which is just a number. [@] And then we're going to say that's going to be the frequency. [@] Just to be pedantic, what I'm going to do is make the oscillator out of a phasor. [@] Phasor is the actual oscillator; it's the thing that remembers what the phase was previously and gives you the next phase every time that time moves forward. [@] Whereas, cosine is the thing which is the wave form. [@] It is actually done internally with a table lookup, so you can think of this as being generalizable by table lookup kinds of objects. [@] Anyway, here is an oscillator divided up into the oscillator part and the wavetable part. [@] And it sounds like it always used to sound, and this is a good check to make sure our computer is still working. 440, OK. [@] Now, we're going to take this and we're going to start messing with its frequency. [@] And, again, just to be as pedagogical and as didactic as I possibly can, I'm going to do this in two different ways and make a claim about how they can be thought of as equivalent, -- if you ignore a couple of minor problems. [@] So the first thing is, we're going to take this in order to take us ... oh you know what? [@] Before I do that, even before I duplicate it. [@] Of course anytime you have an oscillator, you're likely to want to control its amplitude, and I'm going to want to control the amplitudes of all these oscillators. [@] So we're going to get a multiplier and a line~. Line~ because I want to make everything to sound nice and the line~ is going to get messages (I'm thinking back up the tree now ... ) so the messages are going to be packed. [@] Some amount of time that I'm going to make the line~ ramp at, and that's going to now be a control which I control with a number box. [@] Let me get this number box over here. [@] So now what we have... [@] sorry, this is all very repetitious... [@] so now what we have is the 440 Hertz tone. [@] I can listen to it at my favorite listening level but I can also turn it on and off _that_ way. [@] Now, we have an amplitude controlled oscillator. [@] And now I'm going to make frequency modulation out of it in two different ways. [@] So the first way is going to be by doing the real frequency-modulation thing: [@] Which is to say I'll take this oscillator, but the input of the oscillator is going to be another oscillator. [@] So it's going to be something plus 440. So I need to now have an adder. [@] And what I'm going to add to it is going to be a whole other oscillator. [@] So I'm going to take this oscillator and make it nice and compact because we're going to have several of these up on the screen very soon, unfortunately. [@] So let's get another one of these puppies, put it up here. [@] I didn't mean to do that scrolling thing. ... [@] And now this one is going to be added to the frequency of the other oscillator, right? [@] Sorry; this is boring ... [@] So now we're going to say this one is going to talk to us, and we'll control its amplitude ... Oh and we need this 440, it's not in the plus yet. [@] And now, this oscillator and I forgot, of course to make a nice number box to set its frequency. [@] This is the modulating oscillator, which now can get a frequency and an amplitude. [@] And now I don't know if it's audible but that's now making vibrato, or with different parameters, it's making frequency modulation. [@] OK? So that's a thing. [@] And now you can think of this as being two different oscillators. [@] In fact I'm going to put this close to this oscillator, so that you can see them as being essentially the same thing, this could have been plus 120, but I'm just not going to be that didactic. [@] So this oscillator now, if you think of it as an oscillator, it has a constant and a variable part to its frequency. [@] And it has a thing for controlling its amplitude, and then it multiplies and that's it, right? [@] Oh yes, before I forget, I have to tell you one other bit of Pd lore that I probably haven't said before, which is: [@] It would be natural if we tried to do this: We'll take this thing and disconnect it and just run the signal and the message into the phasor, expecting Pd to add these things automatically. [@] This will badly confuse Pd because Pd is seeing messages here and seeing a signal here. [@] The phasor has to decide whether this inlet is a signal inlet or a message inlet. [@] And what it will do, in this case, is it will actually decide, "Gee, I'm a signal inlet because there's a signal connected to me, and these messages are superfluous." [@] If these messages were not superfluous -- that's to say if it just remembered these messages -- then you could get in some awfully bad problems because someone could send a number five into this phasor and you could forget it and have this phasor around with a number five and hook stuff into it, and wonder why everything is five or Hertz off. [@] So instead of allowing that to happen, when you have a signal and a message connection to the same thing, the message connections are simply ignored. [@] So, now we have this rather embarrassing fact that this thing is now playing at 576 Hertz if I do this: [@] But if I connect this to it, it forgets the 576 Hertz because that got overridden by the incoming signal. [@] So signals override messages. [@] And that is why if you want these two things to add, it's not OK -- or it won't work -- just to put them in the same inlet as if they were both signals. [@] If they're both signals, they'll be added for you automatically. [@] But if one of them is a signal and the other is control, Pd will not know what to do, and so you have to add explicitly, like that, which is how I had it before. [@] So, that's a detail about Pd that can very easily be confusing so I wanted to be very overcautious about that. [@] Now, the whole point to this exercise is to take this and to show you how to do it another way. [@] And the reason for this is because the other way is the way it's actually done in practice. [@] Which is: [@] You take this oscillator; but instead of having it be an oscillator with extra input for frequency, you make it an oscillator with an extra input for phase. [@] What that means is you have your phasor first, which is making phase, but meanwhile you can add your own phase to it. [@] Actually, it's going to be better to work it this way: [@] So now what we have is ... how do I make this< ... It seems unavoidable to add an extra object to make the oscillator uglier but I guess that's just what it is. [@] Now what we have is an oscillator with two inputs once again. [@] Well one of them is just a number box, but this is now controlling the amplitude, and this is controlling the frequency, all right? [@] And in fact, if I just tell this 440 and this something reasonable, I should hear the sound again: Good. [@] But, now the addition is not being added to the frequency, but it is being added to the phase, which is the stuff that's between the phasor and the cosine. [@] And this is the point of splitting oscillator up into a phasor and a cosine 10 minutes ago, which was that I wanted to be able to get in there and add something in between the phasor and the cosine in which the osc~ doesn't have an inlet to do. [@] And therefore, I have to rewrite it in this more elementary form, or in terms of these more elementary objects. [@] Now, so this is an oscillator with a frequency control signal input. [@] This is an oscillator with a phase control frequency input. [@] And again, I can just do all the same stuff. [@] This up here is an oscillator without any controls at all. [@] It's just being an oscillator. [@] And now I can do this: [@] Let's see, just to try and get equivalent results, let's turn this on. [@] Let's see.... [@] So now we hear that one. [@] You know what? [@] I need to be a little louder. OK? [@] Oscillator. -- And now I'll make this do the same thing. 0.3, oscillator. [@] Oops, sorry. Left this on. Let's turn that off. [@] And we have the same thing. [@] Now, we can make vibrato out of either of these two oscillators. [@] This one, it's obvious how to do it. [@] We'll take this thing and make it go six times per second -- five times per second. [@] Oh, sorry. Five times per second is the right one. [@] And then there's a depth here. [@] And for instance, just so that we can... all right, let's just do it by ear. [@] So we'll do 10 Hertz, which is a... [@] No, five Hertz, vibrato. [@] Not totally unreasonable setting. [@] Let's do that over here. [@] Can you make vibrato by adding a sinusoid to the phase of the thing, instead of adding a sinusoid to the frequency? [@] The answer is, unless the answer changes, the answer is you can do exactly the same thing. [@] Because what a phasor really does is integrate the input over time. [@] What that means is that I'm putting signals in here. [@] And if I put a signal here, for instance, a constant signal on my 440, what the phasor does is it fixes it so that its slope is proportional to 440 Hertz. [@] Or to put it in another way, what the phasor does really is: [@] at every point it simply adds to its previous output, which is its phase, an increment -- a phase-increment which is proportional to the frequency. [@] So what it's doing is adding in values of frequency sample by sample, accumulating them. [@] And of course, there's a little detail that when it hits 1, it wraps back around at 0 and that's really for numerical accuracy more than any other thing. [@] If we had infinite numerical accuracy, the phasor could simply be a straight line going off to infinity. [@] So, if a phasor's an integrator, integration is linear. [@] So we're integrating 440 and that gives us a nice ramp but we also can integrate a sinusoid and integral of a sinusoid as you all learned in calculus is another sinusoid. [@] So that the indefinite integral of the cosine function is sine and indefinite integral of sine is -cosine. [@] So either way integration just changes the phase and actually the amplitude. [@] But why? [@] Because depending on the frequency, there will be a different constant in there when you do the integration or differentiation. [@] That's calculus; I'm not supposed to use calculus here. [@] Why don't you forget I just said that? [@] OK, so at any rate ... What that is saying is that if I am adding, if I want to simulate adding a cosine to the frequency of the oscillator, I could do it by adding a cosine of a different phase and amplitude to the phase of the oscillator. [@] In other words, I could add the thing here or I could add its incremental sum here. [@] And in fact if you don't believe it, I'll play it for you and then you'll have to believe it. [@] So now I'll make this thing be five Hertz. [@] It will be in the same frequency, but I'll have to give it a different value here. [@] I don't know what it's going to be, yet, but it's going to be much smaller. [@] Like that. [@] So now I claim this signal is - what's the right word -- is "similar" to this signal. [@] Oops. Give me that signal. [@] In fact, we can even make them be the same by ear. [@] Now this one had to have an amplitude of five because we're going to range from 440 +5 Hertz down to 440 -5 Hertz. [@] This one had to have a much smaller amplitude because all we had to change this phase by was how much that 6 Hertz could get you in the one-fifth of a second it takes this oscillator to cycle. [@] That's hand waving, but in fact this has to be in the order of a fifth as big as this because this frequency is five. [@] This number is actually going to be 5/(2*pi). And now is it really true that one / 2Ï€ is about 0.13. Now we have to find this out because otherwise, we won't ever know. [@] Free open-source mathematics package. [@] 0.159, 0.16 roughly. [@] So this number I claim, this number here is this number divided by five because the faster this thing goes, the less it accumulates; so, the faster this is going, the more you have to divide by. [@] I'm arguing by proportion and not by actual equations, right? [@] So what we have over here is going to be inversely proportional to the frequency. [@] Proportional to this number because we're trying to get the same sound and I'm just going to tell you that the factor that you have to throw in is 2*piÏ€ -- which you will get out of calculus class if you go there. [@] So to try to see if this still holds, I'll try some other number here: [@] I'm sorry. [@] Yes, this is a frequency. [@] Now 30, and now I'll choose some horrendous value here. [@] Now, I'll see if I can get that same sound over here and see if it's still true. [@] So we're going to thirty, and that... [@] oh my! That was too easy. [@] Is that the same sound? [@] No, it has to go up higher. [@] Does that sound similar? Maybe. [@] So let's take this thing and divide it by 30 and divide it by 2 piÏ€ and see if we get that, right? [@] 70 divided by 30 divided by my 2 pi ... 0.37 -- 0.38. [@] Ears are wonderful things. Your ears can do better mathematics than your eyes. [@] Oh, yeah. That's actually true. [@] I don't know how accurate your eyes are for seeing things spatially, or seeing colors, or seeing frequencies, but your ear can hear three cents difference in frequency which, let's see, three cents is a 30th of an octave and you have roughly ten octave range of hearing. [@] So that's a part of 3,000. That's the most accurate sense that you have in your body. [@] That's not bad. [@] It's fast, too. [@] It's faster than vision. << [@] Note -- the quick estimates here should be refined as follows: [@] There are 100 cents in a half-step, and 12 half steps in an octave. [@] So there are 1200 cents in an octave. [@] If human hearing is 10 octaves then there are 12,000 cents total in the range of human hearing. [@] So being able to distinguish a difference of 3 cents is 3/12,000 or 1 part in 4,000. >> [@] So anyway, let's go back to where we are here. [@] So, what I'm claiming, although I'm just giving this to your ears, I'm doing the mathematics out, is that we can change the frequency or we can change the phase; and as long as it is true that the thing that we're modulating by happens to be a sinusoid... [@] Why does it have to be a sinusoid for this to be true? [@] Because I made this hand-waving argument about you have to put the integral of this thing in here to get the same effect. [@] In other words, whatever you have here, you have to accumulate it here. [@] And it turns out that if you accumulate a sinusoid by adding up values cumulatively, you get another sinusoid and that's a wonderful property of sinusoids that, in this case, makes it possible for us to rearrange this thing from this form to this form. [@] But that only works for sinusoids. [@] It does not work for other waveforms. [@] For other waveforms it turns out that this is a better thing to compute than this. [@] And I don't know how to explain why very well. [@] But this is more likely to give you what you want than this. [@] I'm not going to try to explain that. [@] Too complicated to get into. [@] Anyway, here's another good thing about this form. [@] I've probably already let the cat out of the bag. [@] This is the way it's always done in hardware. [@] Why? For the unobvious reason and the very interesting reason that good values of amplitude of oscillators that you use to modulate are in the same range as good values for listening to this stuff. [@] In other words, if you take these numbers that you have to choose in order to make this thing sound right are much larger than these numbers that you have to choose to make this thing sound right, the amplitudes have to be down here, but the widths of frequency deviation have to be on the order of the frequency itself to have a reasonable effect, which is again saying why you have to divide this thing by this thing to get how strong an effect it is. [@] Here, the proportionality to the frequency is already built-in. [@] So, for instance here, what I could say is, this is the same thing as deviating this thing not by 0.38 Hertz. [@] This is deviating this frequency by 70 Hertz. [@] This is going from 440 plus 70 down to 440 -70. [@] This one is going from 440 to what? [@] Well, we heard the same thing. [@] So in fact, it's going approximately from 440 plus 70 to 440 -70. But -- this is a better way of saying it. [@] It's going 440 plus or -0.38 -- 38 percent of itself divided by 2 piÏ€. So forgetting the 2Ï€pi -- because 2 piÏ€ is close to one -- this is the proportional depth of frequency modulation, whereas this is the absolute depth. [@] And the proportion depth is a better unit to be talking about frequency modulation in. [laughs] [@] Stony dead silence. Exactly what we want. Every professor wants stony dead silence when they talk. ... [@] Now, with that as an excuse, now I can actually take the entire left-hand side of the patch and erase it and do something else instead, which is to take the right hand side of the patch and populate it with other stuff. [@] Before I do that, I'm going to do something else, which is this: [@] I'm going to show you the spectrum of this again. [@] This is going to be another proof that these things are sort of similar. [@] In fact, this is going to be a test of whether our ears or our eyes are better at finding the similarity. [@] So what I'm going to do is do a little deus ex machina again. [@] We have to go back ... (Ignore the fact that you saw the future in that open dialogue ... ) [@] live-spectrum. [@] pd, <> Here we are. [@] OK, this is a nice patch which I developed for totally different reasons and which I do not want to explain. [@] This patch, which you can get if you download the patches for the day, let's you do the good stuff like "Hi I'm a spectrum and..." [@] Here we go -- ADC: [@] OK I will not dwell on this because I will end up talking for hours about the wonderful properties of spectra of voices, but what you see here... [@] Anyhow, I'm not going to not be able to stop myself from doing this: [voice in microphone] [@] There is a spectrum. [@] This is the like the spectral analyzer I had out for talking about waveshaping a couple of sessions ago, but this is a real one which doesn't care that I use exactly frequencies which are aligned to the filter bank that I used to measure the spectrum. [@] Never mind what all that was. ... [@] This is a general spectrum estimator in which peaks just look like peaks that can move up and down continuously without getting messed up. [@] Good enough. [@] All right, And I stopped it now. [@] What's really happening is that every twentieth of a second, this thing is making a new nice picture and showing us a new spectrum. [@] Now the reason I'm hauled this out is not to show off the spectrum of my voice so much as it is to show off the spectrum of frequency modulations. [@] So what I'm going to do is I'm going to take this patch and use a wonderful feature of Pd -- which is you that can send and receive signals from one patch to another -- to make it listen to this patch. " [@] send~ spectraph" [@] And I'm doing this so that we can look at the spectrum. [@] So now here's the wonderful frequency modulating sound that I just made, and here is its spectrum, if I can find that window again. ... Ta-da! [@] The choice of frequencies I made was good for our ears to be able to find the same bunch of junk, but it's not so great for looking at. [@] So I'll go change the parameters later to show you how this is all affected. [@] What I'm going to do now is check that this spectrum that we're looking at right now is actually kind of the same thing in these two techniques of doing frequency modulation. [@] So there's the one and here's the other. [@] So, remember what this graph looks like, and now we do this one, and we get -- approximately the same thing. [@] So that's another non-proof, another sort of demonstration without proof, that in fact what we're doing here is in some sense equivalent to what we're doing here. [@] You heard it -- Now you see it, in some sense. [@] Now I'm going to get rid of this and we're just going to be looking at spectra of frequency modulation networks. [@] And I'm making room because this is going to grow as always. [@] Stuff never shrinks. ... Save. [@] So now we listen to this and we're looking at the spectrum. [@] And so now, as we remember, and if we turn this down to say zero, we're looking at a sinusoid which looks like a peak in frequency land. [@] And now as we turn this back on ... so one thing you see is that the thing is getting fatter and fatter and fatter, the bigger I push the deviations in the frequency. [@] Now, the other thing that we sort of already know is - let's get a bigger frequency, like a hundred, so we can see it. [@] The spacing of the peaks that we have here is set by the modulating frequency. [@] So, terminology: [@] I've been sloppy about not defining my terms as I use them, which is unfortunately normal for me. [@] So this is an oscillator. [@] This, in common speech is called the "carrier oscillator." [@] And this oscillator is called the "modulating oscillator." [@] And I think, although I can't swear to this, that this goes back to the days of radio where FM was a way that you got signals from a radio station to a radio receiver, and this signal, the carrier signal -- would be whatever it will be... [@] 92.5, right? [@] Whatever radio station you listen to, you dial in the carrier frequency and this modulating frequency would be the frequency or frequencies that would be present and the signal which you're listening to on the radio. [@] So that's why this is called a "modulating frequency." [@] And so this, your FM radio, doesn't sound like this when the announcer is silent, only because this frequency is 92 megaHertz say -- it's too high to hear. [@] These frequencies would be audio. [@] In this case they're both audio, they're both in the audio range, 20 to 20k. [@] And again. [@] As we change the strength of the modulating oscillator, what we see is that the spectrum that we started with grows limbs. [@] And, furthermore, what we see is that those limbs don't move around; that is to say, they don't shift left or right. [@] They stay in the same place, but they change amplitude. [@] Oh yeah, negative does something similar to positive, as usual. [@] And where are these things? [@] Well, everyone knows -- but I'll tell you anyway. [@] So this frequency here is 440, and these are 440 plus and minus a hundred, plus and -200, and so or to put it on the way: [@] All of these peaks are separated by 100 Hertz from each other. [@] And the other thing about that is if one of these things lands negative, an oscillator oscillating in a negative frequency is the same thing as an oscillator possibly with a different phase oscillating in a positive frequency because we can only hear the real part of these things. [@] And so, if I push this amplitude so that peaks further and further out from the center get energy, at a certain point I'll start to see funny stuff in the low frequencies because the peaks will start... [@] New peaks will start appearing. [@] You can't see it with these choices of frequencies. [@] Sorry, I'm going to now increase all these frequencies. [@] Let's go up to E <<660 Hz>> and this will be 200 Hertz. [@] Try it again. Yes. [@] So now you see there's the carrier frequency. [@] Here are side bands which are -- I don't know why they're called "side bands." [@] But these are peaks which describe frequencies that are present in the signal that are 660 plus and -200 Hertz. [@] So this is 460 (660 - 200). This is 260, this is 60, and furthermore, there is going to be one that is -140, which is 60 -200. And -140 is the same thing as positive 140, if it's the frequency of an oscillator. [@] So you see, there's a peak trying to grow here and that peak is 140 Hertz. [@] Furthermore, I can put more and more energy into it, and it's not just that we're going to get energy at 140, but we'll get energy at 340 and 540. Those are actually minus, well, morally speaking; these are -140, -340, and -540 Hertz. [@] But we see them as positive. [@] So the amplitudes depend on this amplitude here. [@] And the frequencies are all fixed forever, immutable. [@] Now, one other piece of terminology before I forget to say it, which is that these things all have names: [@] This is the "carrier oscillator" so this is the "carrier frequency." [@] This is the "modulating oscillator," so this is the "modulation frequency." [@] This is the amplitude of the "modulating oscillator," which is also known as the "index of modulation." [@] People who were talking about waveshaping back in the 70's stole the word "index," I think, from FM and started using it to describe waveshaping. [@] So in a waveshaping setup, where you have oscillator, multiplier, and non-linear table lookup, that multiplier there could also be called the "index" of waveshaping. [@] So "index" sort of means either the amplitude of an oscillator before you do something non-linear to it, like this or like waveshaping; or it could mean how much you're messing the sound up by doing something non-linear to it, which is the same thing by what amplitude you throw it through this non-linear thing ... sort of -- I'm coasting over details there. [@] So what does it sound like? [@] The original tone and then you get this kind of stuff. [@] You can get all the partials you want. [@] Notice that the sort of characteristic pattern of frequency modulation: [@] Which is that after a certain point the partials start appearing in pairs because negative frequency and positive frequencies ones are both going in an arithmetic sequence with the same separation. [@] So you should get this sort of one-two one-two one-two kind of pattern. [@] The other thing about it is the amplitudes of these things... ( [@] OK, let me drop the frequency again.) [@] So I made the modulation frequency large then to show you all the reflection about zero, which happens in frequency. [@] But the other thing to wonder about is how do the amplitudes act? [@] OK they're Bessel functions, you've all heard that ... but how do they act empirically? [@] The answer is: [@] first off, the thing gets fatter and fatter as you push up the index of modulation, which is the amplitude of the modulation oscillator. [@] The energy starts at the center frequency, and it goes out so the signal picks up bandwidth. [@] The FCC gets very excited about that because, of course, if you have two radio stations, the sum of their bandwidths ought not to be more than the distance between the two frequencies, or else they'll be cross-talking. [@] So, now talking about amplitudes, then, yes ... The amplitudes arrange themselves so that more and more energy appears further and further out from the center frequency. [@] But without these frequencies changing, it's just that the amplitudes are changing in such a way to make the frequency appear to be spreading. [@] And the other thing is that: [@] OK, to start with, you get nice, normal reasonable stuff like this. [@] And it even sounds reasonable, I'm not sure but ... [@] Now, that sounds horrible, but that's because I chose bad frequencies for the nice picture, right? [@] So the other odd thing that starts happening is that as you push the frequency harder, the carrier frequency, the center peak, which is the peak at the carrier frequency, loses energy, but it looks like it's actually giving energy off to its side bands, which you couldx sort of pretend is happening. -- [@] These are side bands. [@] But it actually ends up giving all of its energy off into the side bands. [@] So as we push the index further, we actually lose the center frequency altogether. [@] It happens at an index of about 0.38. I don't actually know what that number is. [@] I've tried to figure it out once but I think it's just a number. [@] There's a number of which you just don't you don't have any carrier frequency left at all. [@] But you have nothing but side bands. [@] Furthermore, if you push it further, that amplitude which was going down keeps going down and goes negative. [@] But, of course, negative amplitudes are the same thing as positive amplitudes. [@] So we're going back to zero. [@] So the evolution of the amplitude of the first one is that it goes from large to zero to negative to zero to up to zero, to down and so on like that. [@] Meanwhile, watch this partial. [@] Actually, these two will have the same amplitudes so watch either one of them. [@] And they start from zero, and they start going up. [@] That's all right, but at a certain point, they hit their maximum and start dropping, too. [@] And, furthermore, they will eventually go through zero, as well. [@] Furthermore, the next ones will go through zero, as well, and so on like that so that you'll actually even have this sort of a wave or even a sequence of waves of energy going out from the frequency of the original fundamental. [@] So this is the original carrier frequency. [@] Now we have one lump here and another lump there. [@] And if we start pushing the modulation index - index of modulation - up higher, you'll see more and more of these waves and you'll hear these partials appearing and disappearing in amplitude. [@] And that gives you a characteristic sound that you can sort of describe as a rolling sound. -- [@] Which, you know, you can think that sounds cool or you could just sort of think that sounds like the bad side of FM, depending what kinds of sounds you like. [@] But I will say that if you listen to John Chowning's music, which is worth doing, John Chowning being the person who invented frequency modulation as a synthesis technique for music, you'll find that his indices ... I can't tell you a lot... [@] You'll find that the beginning of his first piece, the indices of modulation all very nice and small but then he sort of starts feeling his oats and the indices start going up. -- [@] So, never mind I said that. [@] Anyhow, these are the nice sort of classical sounds that have nice, smooth spectra that just sort of have a peak. [@] And then you can get the funny sounds that are just complicated; fraught full of energy all over the place, which sound like this: [@] So the easy way of describing it, describing what's going on, is this sets the center of the energy -- this is the carrier frequency, which says where the energy is going to be centered. [@] And this talks about the bandwidth, and not the extent to which the energy is spread out over other partials besides the carrier frequency. [@] And this is the spacing of the partials. [@] And, of course, now good things happen when you ask for the carrier frequency -- (220 say)-- and the modulating frequency to be multiples of each other. [@] Now we've set up a situation where the carrier frequency and the modulating frequency are the same. [@] And so to start with, we have this and now as we push the index up, the first sideband over here is going to be DC -- zero frequency -- and we won't hear it. [@] The next one will be twice the fundamental, which will be up here, and, in fact, no matter how often you add and subtract integer multiples of 220 to 220, you get another integer multiple of 220. And so what we have here, no matter what, is going to be periodic. [@] And its period is going to be consistent with the frequency of 220, that is to say this period will be 1/220th of a second. [@] And this is the sound that a 1973 sounded to those computer musicians like a trumpet. [@] So if you say "Make a computer music trumpet," that's the sound. [@] Now, how do you make the computer music clarinet? [@] We'll just make this one be 440 like I did start with, and now the first peak is 220. But then you get 220 plus 440, which is 660, (220 - 440) is -220. So the reflection of this peak lands right where it was and furthermore every multiple, that is (220 plus or minus any integer times 440) is 220, or 660 or -- whatever that number is -- five times 220, which is 1100, and so on like that. [@] And so now we have a sound that has only odd harmonics. [@] And that, ladies and gentlemen, is the computer music clarinet from 1973. [@] So you've got your trumpet, 220. -- A trumpet is "modulating frequency equals carrier frequency," and the clarinet is "modulating frequency is twice the carrier frequency." [@] Here's another thing about that: [@] I set the carrier frequency to be 220, and then we saw that all the possible peaks that could arise in the side band would be odd number multiples of 220. But that could also be true if that number were 660, or 1100. [@] All I'm doing is I'm taking the carrier frequency and I'm placing it either here or here or here or here. [@] And the result is always the same collection of possible harmonics. [@] The timbre changes. [@] What's the next one? [@] ... Got to add 440 ... 1540. So what I'm doing is I'm moving the carrier frequency to occupy different peaks in the spectrum, but the spacing is always given as 440 and so the spectrum itself stays the same. [@] In general, this is true: [@] No matter what these two numbers are, you could then add this number into that one or subtract it from it, and you would get different amplitudes, but you would get the same frequencies of the partials present. [@] So now for instance and maybe this is kind of obvious -- you can play additive synthesis games with frequency modulation by choosing carrier frequencies which are chosen to be lying on a desired spectrum. [@] The spectrum, though, of course, has to be a spectrum that you can get from FM in the first place. [@] Then you can through if voices of FM along any of these possible center frequencies and add them and you will get more complicated FM instruments, that still obey that same spacing of frequency. [@] And there are two simple ones that work well. [@] This is the odd harmonic one and then there is the normal one -- the "trumpet" one, as I called it. [@] So now, the carrier and modulator frequencies are the same. [@] But again, now I can take the frequency of the modulating oscillator and add it to the carrier oscillator any number of times, and I get these kinds of sounds. [@] Notice, the fundamental is the same, it's 220. But there are twice as many peaks in the spectrum; the other spectrum only had the odd peaks, and this one now has all the integer multiples of 220. [@] And also enjoy how -- since I chose a reasonable index of modulation that's below that wonderful number 0.37 something -- the peak is always going to lie where I put the carrier oscillator. [@] Not really, but sort of. [@] The peak is sort of here. [@] Let's try another one. ... [@] Maybe we'll drop this back a little further, for that really to be true. [@] Oh, right -- Sorry: [@] 0.37 is where the peak actually disappeared -- but there's also some point at which this peak quits being the tallest. [@] And I don't know where that is; that's some smaller number. [@] So now we have 220, 440, 660, and now you can see that you can make spectra that variously have their energies centered in different places and you can superpose them. [@] What about the phases? [@] The story about phases is ugly and you should look in the book if you want to find out how the phases operate. [@] But the short answer is if you work it out so that the phases below the carrier frequency are all in phase, are all like cosine, then the ones up on the other side are like cosine, too, except that they are alternating in sign. [@] I don't know a good, simpler explanation for why such a thing would happen, so phase is a mess. [@] Just try not to think about phase. [@] Pretend it's on your side, or something. [@] And if you do care about phase, don't do frequency modulation, but do something that has a simpler spectrum than this. [@] So the complexity of the spectrum here comes from two things: [@] One is that you get that rolling effect as the index of modulation goes up -- that sort of chaotic in-and-out of various frequencies. [@] And the other thing that is odd about it is -- you don't see it -- but the phases of these things are not terribly well-behaved. [@] The good thing is that the amplitude of what comes out is really, really well-behaved. [@] No matter what you do to the frequency or phase of this oscillator, you can modulate this oscillator until kingdom come, it's never going to get outside of the range from -0.3 to +0.3. And so it's going to be good to your Fender Dual Showman amp -- in a way that some other algorithms that were chosen to have phase coherence here might not do for you. [@] And there, the example would be the phase-aligned formant synthesis technique which is described in Chapter 6 -- which shows you how to make these spectra with very nicely controllable amplitudes and phases of partials but which has another Achilles' heel, which is that it gets very spiky and very bad for amplifiers. [@] I don't know any way of getting both good amplitude and phase behavior and getting a signal whose behavior -- just in terms of what it ranges from and what percentage of the time it's actually giving you good energy -- are both controllable simultaneously. [@] I don't know how you do that. [@] Now, next thing about this ... Picturing yourself at Stanford University back in '73 ... This only cost us two oscillators, that's to say it only took Chowning an hour of computation to hear about five seconds of two-operator FM back in the day on his Foonly F4 computer -- if I remember it correctly. << [@] Chowning may have used an earlier model of Foonly ...>> [@] So why don't we make the thing take an hour and a half to get our five seconds of sound ... and add another oscillator! Where are we going to add it? [@] Well, let's add it ... [@] OK, well we know what would happen if we add one down here. [@] We could figure out what would happen pretty quickly if we add another one down here. [@] OK, so we'll need an adder now. [@] So we put these puppies down here. [@] And then I'm going to just add them because I might be adding other stuff in, too. [@] So here's a thing. I'm going to look at it, too. Good. [@] So if I had another one of these things with other parameters -- but I'll reuse the modulating oscillator and just give myself two carrier oscillators and add them, what then would happen? [@] Well, we know what spectrum this thing is going to make. [@] Well, at least we know how to talk about what kind of spectrum this thing makes. [@] And this one is just another of the same thing so it does the same thing, too, right? [@] And so now, we just superpose the two spectra, and now we have more control over the timbre of the sound. ( [@] The light -- the wonderful motion-controlled (room) light -- either concluding that we're not moving enough or that we're moving too much. [@] We will never know. ...) [@] So what happened there was -- maybe this is just too obvious for words but -- I'm reusing the signal but in fact I would have gotten the same thing that had two of these oscillators with the same parameters, more or less. [@] What's happening here is I'm just adding, I'm just using two carrier oscillators and what's coming out is just the sound of what would have happened if I'd done the two carrier oscillators separately and that's kind of obvious now that you look at it, right? [@] Except that if I were one of those crazy people who likes to do frequency modulation with waveforms that weren't pure sinusoids, one way that I could think about what that would be doing is I could think of the non-sinusoidal waveform as being a sum of sinusoids of different frequencies. [@] And then you could think of the oscillator itself as being an additive synthesis, an equivalent additive synthesis patch that might have an infinitude of oscillators being added into it but anyway you could simulate any waveform you want with additive synthesis. [@] I'm not going to prove that right now. [@] And so this would be a good description of what happens when you have a non-sinusoidal waveform as a carrier oscillator, which, by the way, the FCC cannot be happy about. [@] That's OK, we're not radiating too much here other than acoustically. [@] So that is adding another carrier oscillator. [@] Now, what we can think about is... [@] Oh, terminology: [@] By the time you do this, then you're starting to get the idea that these oscillators and these controllable phases are building blocks, in a sense. [@] And for some reason, the Yamaha Corporation got to calling these things "operators." [@] So this is three-operator FM. [@] And of course, three-operator FM, you could invent other technologies. [@] And, in fact, I'll show you another couple that could also be three-operator FM. [@] The famous DX-7 synthesizer that was FM for the masses for the first time was six-operator FM. [@] So imagine all the good cool things you could do with six of these piling up together in different ways. [@] And the thing that made that all possible was the fact that it was phase modulation, as opposed to frequency modulation, so that the units that you describe the amplitudes in were all compatible. [@] In other words, you didn't have to go choosing crazy different ranges of numbers for different oscillators. [@] So you could manage them very easily, even in old fashioned 1980's architectures -- 70's even. ... [@] OK, so go back. [@] So that was putting the oscillator there - the extra oscillator. [@] I could take this "operator" if you want. [@] I could take the extra operator and put it up here and you still have three-operator FM. [@] But now what we have is the two other oscillators. ( [@] Let's see how we get it so we can see all this. [@] There's not much hope anymore. [@] So I can make this thing take less vertical space. [@] We're just not going to be able to do very well.) [@] So let me turn all of these things off and let's see what we get. [@] The carrier frequency is 440 and I'm going to choose two modulating frequencies: [@] 220, and here I'm going to choose a different one. [@] What's a good choice? 550. [@] So now, both of these oscillators are turned off in the sense that their amplitudes are zero. [@] So now we just hear the carrier frequency, and now we know what this oscillator will do to it -- Sorry! -- I forgot the shift key. [@] There. That's two-operator FM. [@] Here's what the other one does: [@] The other one is 550, so I'm going to make it 550. -- And then it does this. [@] Isn't that sweet? [@] Maybe it's sweet, maybe not, depending on how you feel about it. [@] So just to be painfully slow about this: [@] There's 440. There's 440 - 550 which is plus 110; and then this is 440 + 550 which is 990. This is this one plus 550, so it's 660. [@] So we got 110, 440, 660, 990, and so on. [@] It's 1, 4, 6, 9, 11 and so on times the fundamental frequency of 110. That's kind of cool. [@] And it sounds like this. [@] And now, how do you think about what happens when you do both of these together? [@] It turns out to be strikingly easy. [@] Let's do it this way. [@] Let's start with the 550: [@] So if someone gave you a two-operator FM network that was a sinusoid modulating but was a carrier that had a complex waveform, you could think of that as a sum of simpler two-operator FM modules, where modulator was always a sinusoid and the carrier is always a sinusoid because those imaginary carriers would just arrange them to add up to a complex waveform. [@] This thing you can think of and analyze in exactly the same way, because you can combine these two. [@] These are the ones we're listening to right now. [@] You can think of this thing, whatever it is, it's periodic with 110 Hertz period. [@] And so it itself is a thing that at least in your mind you could describe as a sum of sinusoidal oscillators and here are the frequencies that they're at. [@] And we could even, if you wanted to, write down a bad formula for what their amplitudes were. [@] And now when we start taking this complex waveform and modulating it with this sinusoid, what will happen is that it will act like each of these peaks was independently getting modulated. [@] And then we wouldl get this extraordinary complicated thing, which is each of these peaks sprouting its own side bands. [@] And of course, the sidebands are all mixed up in each other because the first two sidebands of this peak are here and here, but the first two sidebands of this peak are here -- and I'm not sure where to say the other one is, probably here again. [@] I'm not sure. [@] And so now, we get all of the frequencies, which are... [@] OK, so to go back. [@] Now what we have is: [@] This is two-operator FM. [@] If I turn this one off, so now it's just these two, right? [@] So it's 440 plus or minus an integer multiple of 550. [@] Now each one of those you can think of is being the carrier frequencies for a new two-operator FM setup and whatever these frequencies are, like this 440 again will sprout 440 plus or minus integer multiples of this. [@] So in sum, what you get out of the whole thing is 440 plus or minus any integer times this plus or minus any integer times that, which is potentially a very nice thick spectrum. [@] So we have that sound, and now we add this sound and we get this kind of stuff. [@] And now, it's idiot's delight. [@] We have basically all the spectra that we can possibly wish for and the only thing that we can wish for that we don't have is some way of actually getting from one desired spectrum to another in a continuous and ergonomic way -- or thinkable way, understandable way, comprehensible way. ... [@] So you throw numbers in here and you get spectra. [@] You can say where the frequencies are, and that's all right. [@] But if someone tells you, "I got this spectrum. Can you make FM do it for me?" [@] And then you just say, "Hmm." [laughs] [@] There are papers out about that because people in the early '70's got really excited about that, "Oh FM, that's this very powerful synthesis technique. [@] Let's take the sound of this real trumpet, analyze it and then figure out how we're going to stuff parameters into these FM networks to sound like a real trumpet that was analyzed." [@] And the answer is you can get this waveform when you get that well, not even but you can imitate. [@] You can get a bad imitation or a vague imitation of one set of partial strengths and of another. [@] And then you can try to get to continuously from the one to the other, but then you will find that the parameters that you had to do for this aren't actually in the neighborhood of the parameter that you had to get for that. [@] They're somewhere else, in some mountain range of horrible parameter choices. [@] And as a result, you can't actually make continuous paths and get between spectra in any desirable way that you could wish -- as a general rule. [@] So FM turns out to not be nirvana in terms of synthesizing sounds -- for the simple reason that if someone gives you a sound and asked you synthesize it with FM, it is usually just not possible. [@] So what would you do? [@] Well, you can go back and do additive synthesis, probably the easiest way to do that. [@] OK, so this now is three-operator FM, with two of the operators... ( [@] Sorry these are oscillators but we call them operators now because that's what they call them), operating on the third one. [@] And now, of course, you can also say, "Oh cool. ..." [@] Let me explain quickly again the asymmetry of this design or of this picture. [@] This oscillator is like these others, except that I haven't thrown this adder in. [@] I'm just saving real estate because I'm going to... [@] It's going to be a tree structure, it's going to be a tree structure today. [@] And so, somebody's going to be on top, someone's going to be on the leaf because you can't have a tree without leaves, as far as I know. [@] And so this is going to be leaf. [@] So now what we're going to do is we're going to say, "No. [@] I don't want this thing to modulate this oscillator down here. [@] I want it to modulate this oscillator over here." [@] And then what do you get? [@] Well, you get yet another spectrum. ... [@] And even less of any reasonable way of describing what that spectrum is, except to say this. ... [@] No, you can't even think about this. ... [@] Don't even try to put this in your brains. [@] This is another thing and you can do it because it's easy to do. [@] But trying to analyze what this does and I think it's just going to be hopeless. [@] So, just don't try it. [@] Al right, let me tell you how hopeless it is: [@] Analyze these two and you'll get an infinite number of frequencies here, which are this frequency plus or minus multiples of this frequency. [@] Now, this thing, then you could regard as an equivalent to an additive synthesis network with an infinite number of oscillators in it. [@] Each of those is modulating this thing. [@] And I told you how to think about two oscillators modulating this thing, which gave you a doubly infinite set of peaks. [@] Well this thing gives you, then, an infinitely infinite set of peaks because each of these infinite number of peaks is independently separately modulating this one. [@] And their indices of modulation, furthermore, are given by the amplitudes of the components of this pair, which themselves are moving in this horribly complicated way. [@] So the whole thing is just completely beyond sort of any rational analysis at this point. [@] But you can dial right up on your DX-7 and say you can enjoy all day and people have gotten good intuitively at making sounds out of this thing, even though it's impossible to understand what's going on [@] So there is FM operators and all that stuff. [@] Now, just to go back quickly to the question of... ( [@] Maybe I don't need this one anymore.) [@] Going back now to this thing, I said rather a simple thing about this which is that the frequencies present are this thing plus or minus integer multiples of this plus or minus whole number multiples of this, I can even say. [@] Now, it turned out that all of those things were multiples of one number, which is 110, and you can tell from by looking at that this plus N times that always ends with integers that are all going to be multiples of 110. That's cool, right? [@] If I gave you any two numbers here, and said "What is the number of that this plus or minus N times this is always an integer multiple of?" [@] The answer is going to be, I think the answer is always going to be, and the best thing that you can get is going to be the greatest common factor of these two numbers. [@] Greatest common divisor of these two, the GCD of them -- which is in this case, 110. But in this case, the greatest common factor of these two numbers is one. [@] And so even though it looks nice now, this thing, if you want to wait until this thing repeats, you have to wait an entire second because after a second this thing will have moved, this thing will have done 551 cycles and this thing will have done 440 cycles and you'll be back to where we were. [@] But there's no other point at which these two phases both will be equal to what they were before. [@] And just pushing this index a little bit, now we can do the usual cheap thrill FM thing which is walk through all of the wonderful frequencies. [@] Should I make this a little louder? [@] So if you've ever heard sounds like these, they're not atypical of frequency modulation synthesis. [@] And of course there's a special case where this one and this one happen to be close to integer multiples of something else. [@] So in this case, we have positive and negative things that we didn't quite line up and so they're beating but this number, I believe, is about 3/2 of this number, is that true? [@] 290 ... so half of that is a hundred forty five. [@] So three halves of this is ... I think -- 435 [@] ... Yeah, so now what we have is 150 Hertz coming out. [@] Actually we've got odd harmonics again, oddly enough. [@] So every once in a while, if we sweep either of these two, you will hit a situation, a sort of syzygy where these peaks whack into each other and do something nice -- well, sparse in terms of spectrum, and then you get those sounds. [@] And between those sounds you get all the very juicy, creamy sounds in between. [@] So as you're looking at the spectrum, you can imagine these peaks actually just moving through each other like ghosts through a wall. [@] So that, in a nutshell, is the story of frequency modulation. [@] Let's see what do I have to tell you other than what I've just said that's important? [@] That's what it is. [@] So things to take home about this are: [@] First off, this is real easy to do and it's a cheap thrill, it's in yourself, that's how cheap a thrill it is. [@] What do I mean by that? [@] It's so cheap that you can do it in silicon using very few watts or microwatts, even. [@] So it becomes a very easy thing to build circuits to do, which is why you hear a whole lot of it. [@] It's very well behaved in terms of the amplitudes that you get out because of the fact that finally what you're looking at always ends in this cosine function. [@] So the behavior is good. [@] You control the amplitude because in the end it's really just an oscillator with a changing frequency. [@] The gotcha is you don't know how to do anything with it, other than the very simplest things, with any sort of actual predictability. [@] The only way of finding things out about FM is to develop an intuition on how to get cool things out of FM, which people of course have spent many years doing because there are lots of people who spend all their time programming. ... [@] ... Yeah, literally there are people who spend all their time programming, myself and sounds sound like trumpets and pianos and bells and all that good stuff. [@] And you can enjoy their work and millions of people can enjoy their work, too. [@] But if you want to do it, you can count on spending many years messing around with these things yourself. [@] Maybe that would be good, maybe it wouldn't. [@] Depending on what you think do you want to do with your lives .. [@] That's it. [@] That is the entire story of frequency modulation, unless I've forgotten something important. [@] I don't think I have. [@] We're done. [@] *** MUS171 #16 02 24 (Lecture 16) [@] This is a... -- [@] I will come back and present this later. [@] You had to do this with sinusoids before, as way of learning abstractions. [@] So, this is the same, essentially the same thing except that, the synthesis technique is one that uses delay lines and in fact, some of you already know this: [@] If you want to make tones like this, you just play a little white noise or something into a recirculating delay line. [@] For those of you who don't know it, you will see it today. [@] So, if you don't know how to make this timbre, you will know soon how to make it. [@] This idea is attributed to two people working at Stanford, Karplus and Strong. <> [@] It is called Karplus-Strong synthesis and it turns out that it is great for making harpsichordy kinds of sounds like that. [@] And you can push in a couple of ways but then, pretty much, it will give you that very recognizable timbre. [@] And if you ever hear that, you just say; "Oh, that is Karplus-Strong." [@] And that is kind of it. [@] Although this is a good thing as a source for filtering. [@] What I did was I just fixed it so that it has a controllable duration and has a controllable base pitch just as before. [@] And this is a random melody but you can elaborate on that all you want. [@] So, that is... [@] now with that in your heads ... That is a thing that you do with delay lines. [@] But, what I am going to do is show you more in general what delay lines are, like what is the range of experience that you can create using a delay line. [@] A delay line simply takes something in and it puts it out at some amount of time later. [@] Or, at the present time, it is putting out what it got at some previous moment. [@] And to do it, the simplest possible example might be ... Let's just use the microphone to start with just because it will be upsetting. [@] So, what you do to make a delay is two things: [@] First off, you make a delay line. [@] And to do that, the thing is "delwrite~" . And you have to give it a name because delays, like arrays and like send and receive pairs, are things that other things refer to and they have to be able to find them by name. [@] So, I will say delwrite~ and then give it a name and you also have to tell it ... Since it has to make space you have to tell it how much space to make. [@] Unlike arrays -- delays really are just arrays. [@] But, unlike arrays, delays are things that have signal running continuously through them so that they actually have a notion of sample rate. [@] And, as a result, in a delay line, you specify not in the number of samples but in the number of milliseconds, which is the usual time unit. [@] So, I am going to ask for a five-second long delay just because I cannot imagine to running more than that. [@] And then, you just say "delay read" (delread~). Give it a delay name that matches the writing delay line and then give it any amount of delay that you wish to have the thing delay by. [@] And furthermore, that is a thing that you can control using numbers. [@] I should make a number box. ... [@] So, here is the whole patch. [@] I will just take the delay read and throw it to the output. ( [@] It is complaining to me. Why? That is me. [@] That is this window generating problems.) [@] And now maybe ... If my mic is on, "Hello," yep. [@] So now, what you hear is me a second previously. [@] This is a good way to really reduce the intelligibility of speech by the way. [@] So, if you want to change that, you don't even have to specify the initial value. [@] There is no storage associated with reading a delay line; it is just getting storage that was made by the delay write. [@] And so, almost as in the signal versions of send and receive, the delay write defines the delay line and then you may have as many as delay reads as you want reading from it. [@] So, for instance here, I can dial up the amount of delay that I want in milliseconds. [@] So, here is 132 millisecond delay: [@] And so on like that. [@] Zero just means ..well, actually, if you say negative, it makes it zero; it cannot get less than that. [@] And I will make that a little bit better by actually giving it a range. [@] So, zero is the shortest delay you can make which isn't ... Well, which is basically the delay of getting through the audio system the computer has, plus Pd. [@] And, then you get various things: [@] So, certain delay times are just enough to make you queasy but not enough that you can actually hear the delay and then along right here, you get problems with speech intelligibility because there are a lot of phonemes of speech particularly the consonants that typically are over in less than 50 milliseconds and so, if you present a delayed copy of speech, you are squashing those phonemes out and mixing them with their neighbors which ruins the intelligibility of the speech. [@] And, that becomes near total when you push it up to 100 milliseconds in which case you get a nice echo. [@] Well, for thinking about it, 100 milliseconds ... Sound goes about a foot in millisecond. [@] So, 100 milliseconds is 100 feet; so, that is the echo from a wall that is 50 feet away from you. [@] I am just going to save this as it is right now. [@] It is very simple, but this is the basic deal about delay. Yes. [@] I am going to save this except I am going to save a slightly modified form of it which is going to be this: [@] -- Just to emphasize how "delay read" 's can reuse the same delay line. [@] Now, we have the two speakers. [@] Each of which can have a different delay and then you have this. [Clicking sound] [@] Alright. [@] And now, you play an instrument into that ... I can't hear anything ... Don't worry about that. [@] Of course, delays are great effects and of course you are going to want to turn it up so that you can really hear it and that's when you'll get feedback. [@] So delay networks are very feedback prone; that would be a good thing to worry about. [@] So, this is a very simple delay patch, which I will just save. [@] And then move on to the next ... Yeah? [@] Student: What is the 5000 in the "delwrite~ delay1 5000" ? [@] Thank you. Yes. So, the 5000 -- that is the amount of delay line that delay write created in milliseconds. [@] So, in order to make a delay line, delwrite~ has to allocate memory because it has to continually be remembering the last five seconds of whatever came in to it and so, you tell it how much memory you want to grab and you can ask it for hours, all right? [@] But, I don't know any situation which you will need to. ... [@] ... Yeah?? [@] Student: So, would that be a "tail" then? [@] It isn't really a tail. ... [@] What is a tail? [@] ... I don't know how to answer that. [@] So, tails are things that happen after a sound. [@] So, yes because it is creating space for making something come back after it is gone. [@] But, you could make tails in other ways as far as you could make a purely... [@] you could make an oscillator-based synthesizer that had a tail and then you wouldn't need a delay line to do it. [@] So, really what the delay line is ... you can think of it as a circular buffer or as a loop of tape. [@] So, what you are doing is you are writing. [@] The memory is arranged in a circle and not in a segment and it was writing around on the circle continuously so that five seconds later, you rewrite the same thing that you had written before and so on like that. [@] But, in a given moment in time, you can look back up to five seconds in the past and it will still be there. ... [@] Now, next thing about that is this: [@] People immediately think of the idea of making recirculating delays and what I will do for pedagogical reasons is I will just make a very stupid design for a recirculating delay first and then I will start making it a little bit smarter. [@] So, the stupid thing that I could do is this: [@] Let's make this be a thousand and let's test the delay line ... Is it working? OK. [@] Then we will turn it up a little bit. [@] Now, what I am going to do is connect the delread~ back to the delwrite~ so then I will say something like, "You will never forget this." [sound repeats continuously through the delay loop] [laughter] [@] Let's get that out of there. [@] So, it is still there, right? [@] I just turned... [laughter] [@] Actually, this is making a perfect digital copy of the thing so that it really literally will be the same thing tomorrow or next year until I of course destroy the patch which I will want to do pretty soon. [@] Notice that I disconnected the ADC object from it. [@] That is because, in this design, I have a little bit of a disadvantage because, well, there is... [turns on repeating sound] [@] There is another thing that is going to happen which is that I can add other stuff into it: [@] "This either." [repeating sound with added material] [@] And furthermore, if I keep letting that happen, then eventually, I will just get salad, right? [@] And then, it will just be too much. [@] And so, what you would really want to patch and be able to do isn't just... [playback] [@] ...not just that, but maybe first off, it might be interesting to be able to have subsequent echoes to be quieter than the original ones. [@] And/or it might be a very good idea to be able to have your patch actually arranged in such a way that you could control whether you are sending a signal to it or not, alright? [@] That would be the send delay loop. [@] Alright. [@] So, now...[loop plays] So, you got this... [@] So, let's do this. [@] Now, a couple of things: [@] One thing, this is programming style and this is little personal -- I have a tendency to try to put delwrite~'s higher on the screen than delread~ 's, so that the delay reads downward and then this line that went from the output of delread~ back up to the delwrite~ is then feedback. [@] And it looks like feedback when you connect the output of something lower in a patch to the input of something higher in the patch. [@] You don't have to do it that way because of course you could jumble around with it anyway you want. [@] But, if you do it that way, it is easier to remember what you are doing. [@] which you could think is a good thing. [@] Now that I've done that, what I really wanted to do is make this controllable in the sort of obvious ways. [@] I will go as far as to do that and then, I will save that and go on to make another one with gain. [@] So, the important thing here is that, we want to be able to turn the input on and off so let's multiply it by... [@] I could be brutal and multiply each by a toggle switch. [@] By the way, just to be pedagogical again, I am going to explicitly add these two signals. [@] Oh, I can't without destroying my beautiful delay loop. ... ( [@] Oh, I can. [@] Watch this ...) [@] We're going to turn DSP off. [@] Now the delay line is just sitting there and now, I can disconnect this. [@] If you can't follow this, this is just, it is silly. [@] Don't worry about it. [laughter] [@] Now, I am going to put a little plus in there. [@] The patch is turned off while I am doing all of this editing, right? [@] And now, I am going to hook this up. -- [@] Oh, except I want to be able to control the feedback path to. [@] So, let's do another one of these. [@] I am going to be sloppy with this one. [@] So, the delread~ will go to a multiplier. [@] The ADC will also go to a multiplier. [@] Alright; I am going just to be sloppy and I am not going to use line~ 's. [@] I am just going to use toggles. [@] If we were doing this for serious, we would use line~ 's So, now there is a delay time which we've set the two toggles. [@] And right now, with this one, I want to be recirculating this one not. [@] And I will turn it back on: [recirculating audio] [@] And now, I got something where I can just say whatever I want. [Whistling] [Recirculating audio] [@] And finally, I can do this and get the thing shut up so, I can start over. [@] "This is another one." [recirculating audio] [@] Alright? [@] I should have done this with line~ 's instead of the toggles -- So, I will leave you to think about all these little details . Why? [@] Because these are just amplitude controls like any other. [@] Is it clear what this patch is doing? [@] It does need a couple of comments. [@] This control should have names and they should be on the patch. [@] So, this is going to be "recirculation." [@] And, this one is going to be, I think the right thing to call this is just "send." [@] In other words, this is a control. [@] This is a send to the delay line. -- [@] Which isn't to be confused with the "return." [@] This is a sound engineering language: [@] You call a "send" the gain by which you send some incoming signal to some kind of effect and then you would call a "return," the gain by which you would take the output of the effect and put it in whatever speakers you have. [@] So, I don't have any return control. [@] Well, maybe this is a return control -- it's semantics. [@] But here is a send control for sure and here is the recirculation ... [@] So, this is the basic recirculating delay line. [@] Now, I am going to save this. [@] Sorry. Know what? Can I add one more thing to this patch? [@] This has an ADC. [@] If you are using laptops and the built-in microphones, you have a disadvantage because your mic is real close to your speaker. [@] So, I am going to introduce a new object just to be able to play this thing with a nice test signal. [@] And it's going to be noise~ . I am going to be a little careful about this one and I am going to multiply it by some small number. [@] So, what is noise~? [@] Noise is this: [@] Well, you all know: [noise sound] All right. [@] This is a very 1960s pseudorandom white noise, all right? [@] It isn't truly randomness, but it is essentially what could be if you had true randomness for normal purposes. [@] And the strict definition of it is a stream of samples, each sample of which is a new random number completely regardless of every sample that has proceeded it. [@] So, it is a memoryless, noise-generator. [@] And if I am not lying to you, the range is from -1 to 1 . It does not have any DC in the long term. [@] Now, that is the good thing to be using with this for a very pedagogically sound reason -- which is that I want to talk a little bit about frequency responses of these things and you will be able to hear frequency responses if I use noise as the input signal. [@] So, what I am going to do is ... In fact, why don't I simplify the patch; I'll just make it so you can hear the noise if you want. [@] This is another "send." [@] This is the "noise send" I guess you could call it. [@] OK, we have noise. [noise] [@] Now, what I am going to do is compare that noise to this noise that we have here. [@] Now, both the noise and the delayed noise are being heard in the same speaker. [@] And now, I am going to turn the delay time down to something like 10 and then you get something cool. [noise containing varying tone] [@] So, in went noise and out came something that had an audible pitch. [@] This is the first example that you have seen at how you would make a filter. [@] I have actually hauled out filters before because I've needed a high pass filter for a couple of reasons in various spots in the past, but this is actually a filter with how the filter works. [@] And, what the filter does ... Well OK, I will say what the filter does in two different ways. [@] One thing that the filter does is it takes the incoming sound and lets you hear it but also lets you hear it with a delay. [@] So, you hear two copies of signal with seven-ish milliseconds between them. [@] Another thing that you hear is that certain frequencies are accentuated in the output and certain other frequencies are not. [@] And that is the aspect of filtering that makes us call it "filters" -- the idea that different frequencies that come in are passed through more willingly than other frequencies. ... [@] ... Yeah?? [@] Student: For the noise~, what does the inlet do? [@] Nothing. [@] I was too lazy to... [@] I just forgot when I was writing it to tell Pd to suppress drawing the inlet, so it just has the inlet. [@] ADC also has an inlet that does nothing.[laughter] [@] There might be one or two others and every once in a while that question comes up Pd-list. [@] So, the moral is, doing nothing is often not quite nothing enough. ... [@] So, Just to analyze what this thing does... [@] So, let's make it for ease of thinking about it, let's make this thing 10 milliseconds: [@] So, now we hear a pitch and, what would that pitch be? [@] Well, OK. [@] To think about that, what would happen when you put certain sinusoids...? [@] -- Oh, rats. I am skipping some theoretical stuff. [@] So, I am not explaining that you can think of incoming sound as consisting of sinusoidal components. [@] When and in what sense you can do that is something that the audio engineers just sort of assume and which I will not tell you more about than just to assume it, all right? [@] Because the mathematics is hairy. [@] So, assuming that you think that some very complicated signal like noise~ might actually consist or be describable as a sum of different sinusoids of different frequencies. [@] And, of course, it's folk knowledge that white noise really is every single frequency with equal amplitude just like white light could be every single optical frequency at the same amplitude although it isn't because it depends what temperature is. [@] But, that is another thing that we don't have to worry about. [@] White noise in audio land really is a signal which contains every frequency that the digital signal can represent and it contains them all with equal amplitudes and we will just sort of forget about DC and the Nyquist for now because these might be special cases. [@] So, if you think of that that way, then what about some possible component frequency of the noise signal? [@] For instance, what if there were a 100 Hertz sinusoids sitting in there? [@] Well, you would hear the 100-Hertz sinusoid here and you would hear the 100-Hertz sinusoid one period later because the period of 100-Hertz sinusoid is 10 milliseconds. [@] And so you will get the same signal coming out of here for 100-Hertz sinusoid as you get coming out of here and so it would be doubled in amplitude and sound somewhat louder. [@] If I put in 50 Hertz, then something different happens because 10 milliseconds in a 50 Hertz signal ... the 50-Hertz signal has a period of 20 milliseconds. [@] So, 10 milliseconds is long enough to wait for the sinusoid to change sign -- No matter what phase it had at the outset, it is going to be minus what it was by a half-period later. [@] So, what that means is that, at 50 Hertz, this signal has the amplitude which is exactly the negative of the amplitude of this signal -- and they cancel each other out. [@] And since we're adding -- since we're putting it out both here and here at the same amplitude -- we're not putting anything out at 50 Hertz. [@] Now, if you want me to really prove that ... prove it? [@] -- prove it as in a laboratory. [@] Let's make nice oscillator and let's ask it to play 50 Hertz for us. [@] And then I will turn it up here although maybe not all the way to 92. 50 Hertz is kind of low, all right. [@] And then I will turn it up here too. [@] Dig -- It went away. [@] I hope this is maybe on the tape. [@] Oh, you know what ... let's do the same experiment, but let's do it at a lower delay and a higher frequency. [@] So, now, what I am going to do is make the delay be a mere 2 milliseconds. [@] Now, we got it back ... but I am going to make the oscillator to be 250 Hertz. [@] So, now you can hear the oscillator just fine if I just play at... [tone at 250 Hz] [@] ...but if I add the delayed copy, then it goes away. [@] Alright? [@] If on the other hand I had the oscillator going at 500 Hertz, then, if I add the delayed copy, it just makes it louder, 6dB louder to be explicit, and so on. [500 Hz tone] [@] So, just proving this thing with oscillators -- which is a perfectly respectful way to find out what a filter does, by the way. [@] What happened is, oh, at DC -- I didn't tell what happens at DC. [@] But of course, if you put a constant signal on delay line, we will get the same thing out after any delay that you want. [@] And so they will add: [@] the delayed copy will be the same as the original. [@] So, very low frequencies will come out.[rising tones] [@] But, by the time I hit 250, it will be gone. [@] And then, by the time I go to 500...[tones changing pitch and amplitude] [@] ...It comes back at double strength. [@] And then at 750, it goes away again. [@] Now, that is worth stopping and worrying about for a second. [@] Why did that happened for 750? [@] So, what is the easiest way to do the math here ... [@] So, 250 Hertz, this one: [@] the period of this is four milliseconds and the delay line is two milliseconds which is one-half of a period; all right? [@] If I make this 750, then the period of that is ... 750, right. [@] If it were 1000 it would be 1 millisecond, so it is 750, so it is 4/3 of a millisecond; a millisecond and a third. [@] And then, if you make a delayed copy two milliseconds later, ... A period is a millisecond and a third. [@] So, how many periods then fit in two milliseconds? [@] I was trying to make this easy to do in one's head, but it isn't. [@] I'm sorry. [@] It's one-and-a-half period: [@] We have one and a third millisecond, that is four-thirds, and then a half of that again is two-thirds. [@] And four-thirds plus two-thirds is six-thirds or 2. This is one-and-a-half of these periods. [@] So, what that means is that we're hearing here and we're and hearing it there, not a half period later but one-and-a-half period later which for practical purposes is the same thing. [@] Similarly, if I go to a thousand, now the period is 1 millisecond, and 2 (milliseconds) is then two periods. [@] So, 2 -- that number is fixed for now -- is a 1/2 period of this one. [@] It is 1 period of this one. [@] It is 1.5 periods of this one. [@] It is 2 periods of this one. [@] It is 2.5 periods of this one ... and so on. [@] Oops! What happened --Why do I hear that? [@] -- The reason I hear it is truncation error. [@] This is 2 milliseconds, but we're running at a rate of 44K1, so the delay isn't exactly 2 milliseconds -- and so, I didn't succeed in notching it out exactly. [@] And so you hear a very quiet little tone; it might be 40 DB down. [@] But you are hearing the error in the allowable length of the delay line. [@] So, there is a thing about delay lines that I have to tell you about: [@] -- A thing about delread~ that I have to tell you about, which is this: [@] It will read an old sample of the signal that is going down the delwrite~. But, it is limited to integer numbers of samples of delay. [@] It won't interpolate for you, try to guess what thing would be at say "5-1/2 samples ago." [@] It will either do 5 samples ago or 6 samples ago. [@] So, going back to this example: [@] Truncation error is sort to give me the lie ... Well, I will continue the experiment anyway. [@] So: -- 250? [@] No. -- 500? [@] Got it. -- 750? [@] No. -- 1000? [@] Yes. -- 1250? [@] Almost no. -- 1500? [@] Yes. -- 1750? [@] Almost no (still there). -- 2000? [@] Yes. ... [@] So, the things that got through were 500, 1000, 1500 and 2000 -- And seeing the pattern, it's going to be all the multiples of 500. And all of the numbers in half-way in between those multiples, integer multiples of 500 -- [@] -- All the half integer multiples of 500 -- like 250, 750, 1250 and so on -- are getting "notched out" as an audio engineer would say. [@] They are getting canceled out by the delayed copy. [@] Now, going back to the example of noise ... (Should I add that? [@] ... I should add it. ) [@] This is the oscillator send. [@] And then I will just make a separate one for the noise, so that it's all nice and clear. [@] So, I'll put an adder here and I will make yet another one which is a noise~. Ah ... it is going to fit? [@] (Duplicate ... all right. [@] It's getting messy. [@] We're going have to stop real soon.) [@] Of course, it's "noise" not "oise" ... Now, we're going to add that; and then we're going to throw that in here. ... ( [@] By the way, I am being a little sloppy there. [@] I am using this inlet of add to be another add. [@] So, this is a stylistic thing for me: [@] You just put a plus~, then you throw as much stuff into it as you want, it's making it clear that it is all getting added anyway. [@] Better than just throwing it all in the inlet here, for some reason.) [@] So, now, we're sending the oscillator ... we're listening to ... want to hear it here ... [@] And now, we're going to hear the oscillator: [tone] We're going to check this.... [@] The amplitudes by the way need to be exactly the same for this to work perfectly. [@] All right, so that was the oscillator example. [@] And here is the noise example: [filtered noise sound] [noise] [@] And then, you get a thing which is roughly 500 Hertz which, you know, it isn't too far from the C above middle C here: [piano] [@] So, that is the 500 Hertz tone, sort of. -- [@] You could compare it to what happens when I make the oscillator to be 500 Hertz. [@] Observations about this? [@] (I am going to save this and now really, it's time for me to start a new patch because it is getting too crowded. [@] This is the end of this patch.) [@] So, observation about this: [@] This is a linear process. [@] The "linear process" meaning: [@] Taking a signal and making a delayed copy of it and adding the two or even not. [@] So ... adding any number of delayed copies of the signal to the original signal is a linear process in the sense that: [@] If you add two signals in, you will get the result of what happens if you put the two signals in separately. [@] It is furthermore time-invariant which on means: [@] If you put something into the network now or if you put it in a minute later or a second later, you will get the same thing out as if you just put the original thing and just done the whole thing a second later. [@] You could have things that are not time-invariant. [@] A very good example of something that isn't time-invariant is multiplying by a sinusoid, that's to say ring modulation. [@] Because at one moment it is putting the thing through positive, and one moment it's putting the thing through negative. [@] So, if you put an impulse into it at some point, it would be positive or negative or nothing depending on when you put the impulse in. [@] So, that isn't time-invariant. [@] This is time-invariant. [@] If you put an impulse in here at any time or any other time, you will get the same thing out, simply at that time. [@] It is a property of linear time-invariant systems that you can fully describe them by finding out what they do to sinusoids. [@] The way in the past that we have generated frequencies that weren't present in an incoming signal ... [@] ... So, there have been lots of examples where you have an oscillator and then you make different frequencies come out either by multiplying it by another oscillator, which isn't time-invariant -- or by running it through a nonlinear so called "transfer function" which is waveshaping. [@] Each of those things is capable of generating frequencies that aren't present in the original signal. [@] But it is in general true about a linear time-invariant transformation that if you put a sinusoid in, you will get a sinusoid out of that same frequency. ... [@] ... Yeah?? [@] Student: Would you explain time-invariance again? [@] So, time-invariant is this: [@] It's a process and it has an input and output. [@] And so ... Make an input, run the process and get the output. [@] And now, I will make the input delayed by any amount of time you want and apply the same process, you will get the output delayed by the same amount. [@] So, the laws of physics are believed ... are probably ... time-invariant. [@] Because if you drop an apple today or drop an apple tomorrow, the same thing happens -- although it happens a day later. [@] Student: And then explain why multiplying by an oscillator isn't time-invariant. [@] Because it depends on what phase that oscillator's at? [@] ... Yeah, right. [@] Student: Got it. [@] So, I am not going to try to explain why a linear time-invariant system has this wonderful property. [@] But, good things about these .... Well, it would be good if your amplifier was linear and time-invariant ... [@] It would also be good if your speaker system was, right? [@] Because if you heard frequencies coming out of your speaker that weren't in the recording or thing that you are generating, then you would think that there is something wrong with the speaker. [@] Like you would call it "harmonic distortion" or something like that. [@] Linear time-invariance doesn't make up frequencies for you. [@] It does however, or can however, change the amplitude of sounds at different frequencies. [@] In other words, it can change amplitude in a frequency-dependent way. [@] And this is a very simple example of that, where I am throwing in sinusoids and the happy ones that are multiples of 500 are getting doubled in amplitude and the ones that are happening between them are getting zeroed in amplitude. [@] So, that is a thing which we would call a "filter" -- or I don't know what, historically. [@] But everyone I think has this folk knowledge of what a filter should be and do. [@] And this is basically how you make filters. [@] You make them out of delays. [@] So, delays now ... I don't want to change the patch, but I will... [@] Let's go back to doing the "send" thing ... We're sending and oh yes ... so, I why don't I make the patch even more readable than it was by doing the same thing to all the three sources, which is to say adding them up like that: [@] That didn't make the patch very much more readable ... Then I can lower these ... there. ... [@] So now, here is the original patch maybe, let's see: [@] I have to make it a little louder before this is good for anything. [@] So, now this is my voice being filtered in the same way and you, might be able to tell that there is some kind of timbral variation. [@] Actually, you will hear it clearly if I turn the filtering off. [@] So here's original voice. ( [@] You hear some proximity effect because the mic is too close to my voice and the gain is too low.) [@] But, it is basically what is going in. [@] And here is now the filtered result: [@] Which is, you know, 500, <> 1500 and 2500 accentuated everything else, other frequencies not. [@] Or, yeah ... You could now say, "Let me have this as a continuously variable process... [@] So, "Aaaahhhh," --- I don't if you can tell anything's going on there. [@] But, what you are hearing is a varying filter. [@] I am doing this in a rather sloppy way. [@] In fact, I can do it in a more easy to understand way by using noise again with less amplitude. [noise] [@] And now, we can do that sort of stuff [frequencies in the noise change] ...OK. [@] And, that is changing the frequency response of the filter. [@] What is a "frequency response?" [@] Frequency response is a name for, at any given frequency, what is the gain of a filter? [@] So, the frequency response is a curve or it is a function of frequency -- which in this case has a shape like that: [@] Has peaks at multiples of a fixed frequency. [@] And you can change that fixed frequency, which is therefore changing the frequency response of the filter in its very audible way. [@] Now, that is what the filter is doing for you when you have very short delays. [@] Let's go back to voice now. [@] This is a thing which either can give you this kind of effect, "Hello." ... "Hello." [@] So, now, we're doing something that you hear in the time domain. [@] So, that now, the delay time now is more than the magic 30 milliseconds which is something like the threshold of what you will hear as a time interval. [@] So, if it is more than 30 milliseconds, you get this: [@] And if it is less than 30-ish milliseconds, you will start getting things that are describable as filters. [@] And, by the way, notice, I've been sloppy about this without explaining to you that this is a problem. [@] But, of course, if you test this thing carefully, you will hear that it does that: [jitters] when you change the delay time, all right? [@] That's exactly the same effect as if you were using an array as a sample, as a recorded sound, and suddenly jumped from one spot in the recorded sound to another without controlling it by enveloping it somehow. [@] And, it is that for the same reason almost -- which is that if you change the delay, you are stopping playing the thing at one delay, you are starting playing it discontinuously another delay. [@] It is almost exactly the same thing if you picked the needle up on a recording and dropped it somewhere else instantaneously; it would cause a discontinuity in the signal. [@] And, that wasn't a problem before because I was changing it by small enough amounts. [@] I was doing this with the shift-key. [@] You can still hear that it's a problem but I was able to sort of talk over it hide the zipper-noise effect. [@] But, now that I have sensitized it you should hear it. [@] Well, that is this patch in gory detail. [@] I haven't turned the recirculation back on since I have been doing this for a good reason -- which is that the recirculation made since when I had the delay time up to some large value ... [@] So, the recirculation example was, I had 1000 here. [@] And then I could do something like: [@] Turn on the recirculation and then give it a couple puffs of, say an oscillator. [@] So, now I can just say [injects the oscillator sound] [@] This is now back to what I did at the very beginning of the class which is just a recirculating delay network. ... [@] Where you don't want to be putting things through in a continuous way -- which is what I have been doing, when I've been describing the way this thing acts as a filter. [@] You can actually think of this is a filter, but it would be a really good filter because its frequency response would be infinite at any frequency except one that was very carefully chosen to be notched out. [@] So, to put that another way: [@] For instance, if I just put DC into it, if I just put a signal that had a constant value of 1: It would just add on to itself then it would continue doing that forever and eventually, we will have an arbitrarily large number coming out. [@] So, this is out of the range of operation where you really will think of it as a filter. [@] This is using it as something else -- I am not sure what. [@] So, delay lines are usable as filters but there are delay effects which would be unstable if you left them in place for any amount of time and so you can't regard them as a thing which you can do in a continuous way and time. [@] And therefore, you probably should not use them as filters but as other things. ... [@] Questions about this? [@] Student: How would you remove the zipper-noise from the changing delays ... ? [@] How would you remove the zipper noise? [@] I've been saving that for a little later because there are couple of ways you can do it any way that you want. ... [@] ... Yeah?? [@] Student: Can you find the delay you need to get a particular pitch? [@] You can do it. [@] In fact, you have to do it to be able to do the homework. [laughter] [@] So, what's the formula. So, for instance, if I wanted to do middle C... [@] Student: Calculate a formula? [@] Well, yeah ... And I've been resisting hauling out the exper~ object which allows you to just type out formulas -- which is of course a great thing to be able to do but there's syntax. [@] I haven't yet found a thing that's really been unavoidable. [@] But, how would you compute? [@] ...OK, so 1 Hertz should correspond to a thousand. ... [@] 2 Hertz should correspond to 500, and so on like that. [@] So, the general formula is: [@] this thing should be 1000 divided by the frequency in Hertz; and to divide a thousand by something, so it is... [@] This is worth knowing how to do: [@] So, here is a number. [@] We're going to convert it to frequency, MIDI-to-frequency <>. And then, that's going to give us a nice number again which I will look at. [@] But, now what I want to do is take 1000 divided by that. [@] So, to do that, OK. [@] So, I need 1000 down here, which is a message because I don't want that value to change; and then I want to divide that by this number: [@] I will take 1000 divided by this, but we have to then bang the 1000 after we put this number in and so, we need a ..? [@] Trigger! Yup, trigger, bang, float and I usually space this like this when I am doing this. [@] I think that is decently readable. [@] And now, we do this! -- Destroy the coherence of our patch. [@] And now, I say, "middle C, please" and it says, "Yeah you want 3.822 milliseconds." [@] And theoretically, now, if we play noise to this ... get these two gains the same. [@] ... Yeah. That should be this pitch. Middle C. [piano sound] [@] One other thing I should warn you bad about this. [@] This is abstruse and weird: [@] There is a minimum amount of delay that you can get into a recirculating network for a technical reason which is that Pd does everything in blocks of 64 audio samples just to save computation. [@] As a result of which -- since the delwrite~ needs the delread~ 's output to be able to write into it -- that output is a block and so, the minimum amount of delay which you could have in this loop is one block worth. [@] And, without trying to explain that and you better than I have already, what I am going to do is to show you that ... everything is hunky-dory until you get up to a certain delay here: [noise with changing components] [@] And then, it stops. [@] Stops right at ... I think, it stops right at 1.45. And that 1.45 is the number of milliseconds in 64 samples at 44,100 sample rate, if you compute that. -- ( [@] You don't have to compute that now. [@] I hit that number a lot because, well, it is the length of a block of 64 samples of time.) [@] That also is the numerical accuracy of the line object if you ask it to do something in a specific time. [@] The time actually will be the nearest one of these -- which can be a limitation. [@] And if that is a limitation, go look up the vline object, which corrects for that. [@] So, I did promise you I was not going to add stuff to this patch. [@] So what I'm going to do... [@] I am going to save this. [@] What can I do? [@] I kind of ought to leave this in; so, I am going to use a send here. [@] I don't know how I am going to deal with making this be a readable patch when I try to put it up on the web. [laughter] For now, we'll just do this. ... [@] "r" is short for "receive" ... so I should use "s" here to be clear. [@] So, there's that. [@] Now, the next topic is what if you want to have a recirculating delay and not have it last forever the way I had it last in this example? [@] And of course, it is easy -- You just take it and multiply it by some gain that is less than 1 each time around. [@] But, even though that is easy, I want to show it you because it has interesting ramifications and there are actually things that you can think about it. [@] So, now I am going to "Save As" .. that was 3.delay-recirculate. [@] So, this is going to be 4 delay gain recirculate. <>. Sorry, long name. [@] Here, what I am going to do... [@] see, I am not sure what incoming signals we need.... [@] So, now, what I am going to do is I am going to make one where the assumption is that we're always recirculating. [@] So, instead of having the recirculating be on and off, I will make it be a nice number box. [@] And in fact, I think what I want to do is have the number to be in one-hundredths for sanity sake. [@] And now that I have done that, so, I am going to increase the... [@] well, actually, let's be middle C still. [@] And now, I am going to say "noise please." [@] It is going in there. [@] So, we can listen to it. [noise] [@] OK, now all you hear there is unfiltered white noise because the noise is going in... ( [@] You know what? [@] I am going to make an improvement to the patch. [@] I'm going to listen to the output of this adder. [@] And, now, we still hear it. [@] ... Yeah. [noise] So, now, we're putting noise in. [@] We're not putting the oscillator in or the, ADC -- just noise. [@] And the noise is getting multiplied by 0 as it gets read and then recirculated, so we hear nothing but the original noise. [@] As I turn this value up, I get more and more recirculation which gives me a more and more nearly pure tone. [filtered noise changes] [@] .. I am going to stay away from a hundred for now. [@] So, now, to go back to, not 1000 this time ... how about 150? [@] Now, I am going to go back to talking into it. [@] So, now, I am talking into thing and you hear just my voice with no delay. [@] And now, I turn up the recirculation. [sound] [@] And now, everything that you hear has several copies. [@] And now, this is the thing that you heard probably in piano country ... push my input gain up .. [sound] [piano sound] [@] At least from where I'm hearing, I don't here the effect at all. [@] But, I am afraid to turn it up, so that's no longer true because at some point, we're going to get feedback and then it's going to be bad because I will be over there. ... [@] Actually, I have a switch, but I am not sure I would think in time for that ... [@] So, here are these these delays. [@] And now, what is happening right now is that each delay is 63 percent as loud as the previous one. [@] Oh, this is it: "Hey, you guys! don't listen to that." [laughter] [@] OK, so the bigger I make this, the longer the sound stays around until I foolishly push this past a hundred: [sound increasing in volume] And then it actually grows. [@] And, you don't want to leave it like that. [@] That is an unstable filter; right? [@] Filters can be unstable and what happens when you have an unstable filter? [@] Pretty soon everything is just, "waakrraak," [@] So, you can do it. [@] It's mathematically possible. [@] But it might not be want you want really. [@] So, this now is making a recirculating delay. [@] So things about it: [@] It's is very feedback prone. [@] Use with caution. [@] It also it is a bit of a special effect and it is way overused. [@] The other thing about it is -- This is close to what you do it from an artificial reverberation. [@] So, if you wanted to make me sound like I was speaking in a church or a music hall, or something like that, you would do something like this except that you would want the echoes to be a lot closer to each other in time like this. [@] "Hello." [sound] [@] And then, you have to turn the recirculation up. [@] And then we get something a little bit unexpected, some feedback here. [@] Re-direct the audio ... yeah "cardio" mic. [@] If you do this, theoretically, you are not getting any direct signal out of the speaker. [@] Doesn't really work, you can at least hope it does. [@] So, now, it isn't a nice continual reverb sound at all. [@] It's got a pitch. [@] The reason I dropped the delay time into something short ... right now, it's 13 milliseconds. [@] The reason I dropped that was so that the echoes would be close to each other. [@] Because when this was a larger value in milliseconds. ( [@] I am going to drop this a little bit now.) [@] Then, you just heard... [echo] then you heard a bunch of echoes ... So, this isn't a nice reverberator because you know ... You play a trumpet through that ...? [@] Sounds like "Come Together" ... But, if I decide to try to make that echo denser, then I can get...[sound] [@] I'm down below the magic value of 30 and I start getting pitches again. [sound] [@] In fact, at this point, I can just dial this thing up like this: [@] "Hello, this is your professor on drugs ..." [laughter] [@] Now, all I am doing is filtering ... So, there is some things I haven't told you about this: [@] It was perfectly filtering before I put the recirculation in. [@] But, you noticed that when I put the recirculation in, then the filtering got a lot stronger. [@] That is the loose way of saying it. [@] What really happened was I replaced the non-recirculating filter with a different filter which is recirculating which has the property that can have a very, very sharp resonances which you will perceive as pitches. [@] And this is the Karplus-Strong technique that I referenced in the homework at the beginning of the class. [@] This is a thing which -- no matter what you put into it -- out comes ... [sound] [@] A thing that is happening at the pitch that you dialed up here. [@] And furthermore, what you do is reflected in a timbre of what comes out. [@] So different kinds of impulses going in give you different timbres coming out. [sound] [@] It's a little bit like what happens on a stringed instrument when you pluck it: [@] Those of you who play guitar, when you pluck the string, the sound of the tone is pretty much the sound of the pluck dying out. [@] Of course, the higher frequencies die a little faster than the lower -- so that isn't quite true. [@] But, the moment that you get to really control the timbre of a guitar or piano string is just when it gets hit -- because after that it's just ringing -- [@] It's doing it's own thing after that. [@] And, this is ... Well; it's a fairly close imitation of that process. [@] It is at least a conceptual imitation of it, where you put the signal on the string. [@] It runs down the string and comes back up and you get it again and every time it goes by, you get it again, right? [@] So, a guitar or a stringed instrument,, in some sense, you could think out as being a recirculating delay line. [@] And that turns out only to be an approximation. [@] But, it's a good enough approximation to capture certain aspects of it. [@] Here, try as you might, it is going to be hard to make this actually sound like a guitar... [sound] [@] It sounds like... [@] It sounds like a computer trying to be a guitar. [@] If you give it something that has more high frequencies... [@] Then, you can almost get, make yourself believe that you are hearing a struck string of some sort like a string being hit without mallet of some sort. [@] And, furthermore, if you could -- I am not going to build a patch to do this right now .-= but, if you could turn this noise on and off very, very rapidly so that you made a burst of noise, then you would get a very sharp signal that would sound -- in the same way that that FM tones sounds like a clarinet -- [@] That would sound like a harpsichord. [@] And in fact, that is exactly what I did in my patch here which is the homework demonstration patch ... which I might still have up. [@] Let's see ... looks like I got rid of it. [@] So let's go get it again. [@] So, this thing: [harpsichord music] [@] So, the homework is simply to take this principle and build it into nice polyphonic instrument so that it can do something reminiscent of homework 6, two weeks ago. [@] And of course, you will be tired of that stupid random melody, so you can make something more fun. [@] ... Yeah?? [@] Student: With this process, is this kind of like a basis for vocoder? [@] It sounds a lot like a vocoder. [@] In particular ... Well, the thing it makes a sound like a vocoder is when you put your voice into it. [@] You can almost think of it as an alternative to vocooder. [@] It will not do it anymore. [@] Sure enough. [@] So, why don't I hear anything now? [@] That is weird. [@] Let's turn DSP off. "Hello." [@] Student: Is there a preview switch on your port? [@] There might be. [@] I'm not going to look for it now. [@] I think there is probably a monitor switch down there that's turned on, all right. [@] Sorry about that. [@] So let's ignore that for now and what I will do is just start sending the ADC to this and now we get: "Hello." [@] So now this: So the question is, "Is this a vocoder?" [@] And the answer for me is -- First off: A vocoder usually lets you put the sound in that this thing is forcing you just to be -- pitch of 60. So, a vocoder's a more powerful thing than this in some ways -- in a lot of important ways. [@] Another thing is that if you compare this to the standard vocoder sound, the vocoder sound is a great deal more local in time. [@] So, this does not respond real fast. [@] In particular, it does not shut up real fast when you stop talking. [@] So everything gets squashed out over a certain period of time, which a good vocoder wouldn't do to you. [@] So, you could, you know ... This is almost, this is a "cheap wannabe vocoder." ... [@] Any questions about that? [@] ... Yeah. [@] Student: Right now, you have only the recirculated sound. [@] How would you combine that with the original audio? [@] Oh, that would be easy. [@] You would just... [@] Student: It is just like ADC? [@] You'ld get another level control, yeah and then you get the ADC and just send it straight out like that and then, this would be the so called "dry signal" in audio parlance and this would be the "wet signal." [@] Student: Can you put them together? [@] You could; so you could add the ADC into this and then ... Yeah. [@] You could do that. So, it's more a question of just how you wanted to define that, or how you want the interface to be, all right. [@] Because basically, it boils down to two different levels, one or another. [@] So, the thing that I want to tell you about the -- I am realizing, 15 minutes left ... Do I really want to explain why the frequency responses is what it is, or do I want to not touch that with a pole? [@] I am going to tell you how you would find out and I am going to avoid going into the gory details -- for the simple reason that it might be useful to come back to this in two weeks' time and so it will have been nice to have gotten started and then ... Anyway, if I never manage to follow up on it, then you've at least seen where you can find more about it. [@] So, this is now a tour through theory. [@] So, let's go over here: Book. [@] So, we're now on Chapter 7 of the book which is time shifts and delays. [@] Chapter 8 of the book is Filters. [@] And filters are really, as I've explained, they really just a psychological... [@] they're point of view on time shifts. [@] In other words, filters are made out of combining signals with time delayed copies of themselves, including the possibility of recirculation -- which as you've seen simply has the effect adding more and more copies in it. [@] Basically, it just adds a train of copies, instead of a single copy, if you make the thing recirculate. [@] So, if you learn all about time delays, time shifting (which is time delaying if you make it a real time process)... If you know all about that then one of the things you can ask is, "What is the frequency response of the network?" [@] And a good definition of a filter I think is: [@] It is a delay network that was designed in order to give us particular frequency or phase response, usually frequency response. [@] So, one thing that you want to know about in delays is how did you predict the frequency response and then when you are doing filtering, it's not just how do you predict the frequency response but, [@] "I want a frequency response that acts like this. How would I set about designing a filter that had that?" [@] So, filter design in some sense turns the question around: [@] Whereas, in a delay, if you are just making delay networks, you might just sort of ask, "What would the response be?" [@] In the filter thing, you posit the response and work backwards to get a delay network that does it for you. [@] At least, that is the way I think of it. [@] So, delay networks have other things that you can talk about, about them, besides the frequency response but I just want to talk about that for now in order to prepare for whatever little bits of filtering we're able to get into in the last week pf class, before we do GEM -- which is of course what everyone really wants to see. [@] And, what I want to do is just talk about -- I'm going to take this slightly out of order because I am going to motivate the jive about complex numbers by showing you first how you think about time shifts and how they change the phase of a thing. [@] So, just to do the hand-waving thing: [@] Of course, shifting a signal in time such as delaying it, changes the phases of all the component sinusoids. ( [@] And of course, I shouldn't say "of course" there because that is presupposing the deep thing that you think that you can think about a signal as being the sum of sinusoids in the first place.) [@] But, if you could, and if you have something linear and time-invariant, which we do, so that we're not making up frequencies that we didn't have before and so on like that ... Then you can say "Yes. [@] I will just describe what this thing would do to a sinusoid and that will describe what it does to anything." [@] So, then we say. [@] All right, we're just going to send sinusoids down our delay network and ask what happens then." [@] And the answer is: [@] you put it down a delay and you get out a sinusoid of the same amplitude and a different phase. [@] And, then if you, for instance, add that to a non-delayed copy of the signal, then you will get phase cancellation or not depending on the relationship between the two phases you got. [@] So, if you can predict the phase, then you can go do the math and work out what that response is going to be. [@] So, how do you predict the phase? [@] Well, it is easy: [@] The frequency of a sinusoid is just how much the phase changes from one sample to the next. [@] So --and if you do it in appropriate units --the phase change associated with the delay of say, D samples which is going to be D times the frequency, actually, -D times the frequency of the sinusoid that you put in. [@] Why minus? [@] Because if you delay it, then you listen to what it was earlier in time, so it is actually phased backwards. [@] But, if you think too hard about that, then you will get mixed up. [@] So, it is best to just sort of remember it's minus D times the frequency -- If you express the frequency as degrees or radians per sample - which is the good way to describe frequencies in filter design land. [@] So, time shifts and phase changes: [@] What is a time shift? [@] A time shift is just, "I give you a signal X and you give me a signal Y which is X, D samples ago." [@] And N is just now. [@] N is the number 1, 2, 3, 4, and so on. [@] And then, what happens when you time shift a? [@] -- Oh! Now, I have to go back. [@] OK ... So, I am motivating complex numbers. [@] If you have a real-valued sinusoid, it is ugly, it is cosine of omega N plus pi ... So, call it cosine of omega N ... It's the cosine of something, maybe there's an amplitude ... If I gave you a sinusoid that contained only a positive frequency, it would be complex valued sinusoid with a simpler formula. [@] Which is that: [@] The nth sample, so "X sub N" -- that's the Nth sample of my sinusoid -- is some constant amplitude times a complex number raised to the nth power. [@] That's all it is. [@] So, a sinusoid is an exponential exponential sequence. [@] And then, it's really easy to say what happens when you delay it. [@] Because if you take an exponential sequence and delay it -- You've all had to do this, because you had to add exponential sequences in high school -- "geometric sequences" they're called. [@] So, adding geometric series: [@] What you do is consider what happens when you just delay it and then subtract it off from the original and you just get a multiple of the original and so you know how to deal with it. [@] And so, this thing ... clearly, if you substituted -- if you said "Y of N is X of (N - D)" -- in other words, you delayed it D times, all you would be doing is you would just be dividing by Z^D. [@] Now, a possible misconception that you would have here is that Z isn't going to be an ordinary number like 1/2. Because of course, (1/2)^N is not a good sinusoid -- that's a dying exponential. [@] A good number to raise to the Nth, to do that, would be a complex number which lives on the unit circle. [@] So, now, I have to go back and show you complex numbers -- so that this can apply to sinusoids. [@] So, now, we can go back. ... [@] So, what I did is I sneak previewed time shifts and and phase changes to show you that I wanted to have a nice exponential sequence so that I would know what time shifts would do to it. [@] 51] And, I was trying to compare that with what happens if you just looked at real numbers and then you had to say cos(omega N) and then when you say cos(omega (N-D)) -- then you have to use the cosine sum-angle formula and your formulas grow much faster. [@] So, you will be much happier with what it is in complex land. ... [@] Now, what I want to do is show you, without going into the how and the why and everything else of it: [@] Here is what Z is, alright. [@] So, this is the complex plane. [@] The complex plane is the thing which you forgot after you got out of pre-calc. right? [@] This is the real axis. [@] This is the imaginary axis. [@] Complex numbers in general have a real part and imaginary part which puts them somewhere on the plane because you can think of them as coordinates. [@] And so, instead of a "number line" in real land, we have a "number plane" for the complex numbers. [@] And everything that is good about the real numbers (almost) is still true about the complex numbers: [@] You can multiply and add and all the usual good rules hold. [@] 1 of course has a real part of 1 and an imaginary part of 0. And in general, if you make a number which lives on the unit circle -- That is to say: [@] The real part and imaginary part, if you add their squares up give you 1. -- [@] So, that is the circle which is maybe: [@] " A^2 + B^2 = 1 ". This is called a unit complex number and it turns out that if you take one of these unit complex numbers and square it, all you do is you get that angle further on the circle. [@] So, numbers on the real line, here, if you start multiplying them, they start going in and out. [@] Numbers that are on the unit circle in the complex plane -- if you start multiplying them, they stay on the unit circle and all you do is you change their angle. [@] So, complex numbers know all about trigonometry. [@] They just do trig for you. [@] That's why we use them in fact -- so we don't have to do trig. [@] So, in particular, if I for instance, consider the sequence 1. Z, Z^2, Z^3 etc. ... -- [@] I didn't tell you this, but actually, this angle is the same as this angle -- or this arc is the same as that arc is the same as this arc and so on. [@] So, if I gave you the sequence of numbers 1, Z, Z^2 and so on, you would be going at a constant rate around the unit circle. [@] And then, if you only looked at how that projected on the real axis, you would see a nice sinusoid. [@] It would look like cos(omega N), if omega was this angle from here up to Z. [@] That's called the "argument" of Z if you like. [@] But, you could just call it the angle of Z. -- [@] And that would be the frequency, in radians per sample, of your complex sinusoid. [@] So, this picture says that 1, Z, Z^2, blah-blah-blah is a sinusoid which happens to have zero phase at the beginning of time which is here ... [@] And, it also happens to have unit amplitude. [@] And now, if you take that and multiply it by some arbitrary complex number, capital A, which is an amplitude -- It's a complex amplitude; it has not just a size but also a direction. [@] Then you would get a sequence of numbers, A, A Z, A Z^2, ... They would be advancing at the same angle but they would have a different amplitude and different phase. [@] So, these numbers here, A, A Z, A Z^2 and so on ... That is the most general form for a sinusoid. [@] That's the output of a oscillator in general -- a sinusoidal oscillator. [@] 54] And furthermore, it has this very simple mathematical form which you can do stuff with. [@] In particular, you can delay it -- Because delays just mean you rotate it, by some multiple times the angle omega. [@] Furthermore, you can add two of them: [@] If the frequency of the two is the same, if one of their amplitudes is A out this way and the other is an amplitude B out that way, you just add A and B as complex numbers, which is a vector sum. [@] And get, and you see graphically what the amplitude and phase will be of the sum of those two sinusoids. [@] So, that's all delay networks do. [@] They delay things and they superpose them, which is to say they add them up. [@] And you know what delays do now -- they just rotate. [@] And you know what adding does -- it just adds, but it adds as vectors. [@] And now now you have the tools that you need to predict the frequency response and phase response, for that matter, of any kind of delay network that I can throw at you. [@] So that's the pep talk, which is enough for now. [@] If there is some time, especially when we get into filters as such, I'll want to try to show you how you would translate that into like a nice bandpass filter for your synth. [@] But it is all here basically. [@] This is what the engineers all do when they're designing those filters, Moog, Buchla ... -- all this stuff. ... [@] ... Yeah?? [@] Student: So, with like a low pass filter. ... [@] I don't fully understand this description, but filters that you showed us before was kind of like a notch filter, where you notch one frequency and strengthen the other one. [@] How would a low pass filter delay be chosen ...? [@] So first off, it's a comb filter. [@] So whatever you see, it repeats itself every so often depending on the period. [@] Student: Yeah, got it. [@] The smaller the period of the delay line, the smaller the length of the delay line, the more separated those things get. [@] Until if you make a delay line one sample, you would only get one hump and it reaches all the way from 0 to Nyquist. [@] Student: OK. [@] And so, that is how you get its notch widths to peak. [@] But then, how do you get to move around? [@] And that is a little bit harder; but you just need to be able to shift and correct back the frequency. [@] Student: And how do you get like a low pass and a high pass? [@] A low pass? [@] Well, it's a comb filter. [@] The comb filter had a response of 2 at DC and had a response of 0 at the first notch. [@] So, you put that first notch at the Nyquist and it goes from 2 at 0 -- at DC -- to 0 at the Nyquist. [@] Then we change the recirculation to get it sharper, to push it more towards DC. [@] A little hand-wavey, but that's basically what happens. [@] And then, when you want to move the peak off of 0 -- then you have to work harder. [@] *** MUS171 #17 03 01 (Lecture 17) [@] displayed time + approx :0 [@] 6 is transcript-time [@] This is where we got last time, with the exception that I added some nice comments to try to make it clear what was going on. [@] We got as far as to make a recirculating delay network. [@] And, I demonstrated that you could consider this either as a thing that does things in time or a thing that does filtering -- which is to say changing the frequency content of a sound; in other words, making some frequencies loud and others less loud. [@] So, to be overly pedantic, I'll just go ahead and re-demonstrate that quickly. [@] So, here's noise: [noise] [@] And, here is noise recirculating. [@] It's a recirculating delay; I'm going to recirculate the delay. [@] Oh, the delay will be 10 milliseconds long, and I'll recirculate it, multiplying by some number that's less than 1. [@] So, we're going to multiply now by 88 percent. [@] And, now what we're going to hear is a tone. [noise tone emphasizing 100Hz] [@] And, that tone, if I checked it on a piano -- which I don't have one of right here -- it would be at 100 Hertz. [@] Because a 10 millisecond period corresponds to 100 cycles per second. [@] Or, to put it another way, anything that comes in to this thing is going to come out, and then come out again at 10 milliseconds later, and almost as loud. [@] And then, again, 10 milliseconds yet later. [@] So, everything that comes in, it's going to come out, almost repeating itself, every 10 milliseconds, which will therefore sound like a thing that's at 100 Hertz. [@] And, that would be true for delay times that go up to some 30 milliseconds, or tones that go down to 33 Hertz. [filtered noise varying] [@] You can almost say [hums] down an octave there. [@] Then, below that you can't really hear a pitch any more. [changing noise] [@] You just hear some kind of thing in time. [@] So, now, getting rid of the noise and turning on the famous microphone. ... [@] Is this going to work now? [@] I didn't test this. [@] Hello. [recirculating sound from microphone] [@] Oh, yeah! So, now this is a nice recirculating delay with voice coming in. [@] And what you hear is echoes every 84 milliseconds, which is what? [@] -- 12 times a second or something like that, which you hear as an amount of time [snaps fingers] and not as a frequency. [@] If I make those echoes be close to each other in time, like 20 milliseconds away from each other, then you no longer hear that as [snaps] as a series in time, but instead you hear it as a nice pitch. [@] And now we get...[tones generated by voice in microphone] "Sort of a poor-man's vocoder ..." [@] ... which is just me talking through a comb filter. [@] A "comb" filter is just another word for a delay network that likes frequencies that are multiples of a certain fundamental frequency. [@] In this case, this comb filter likes frequencies that are multiples of 50 because 50 Hertz corresponds to 20 milliseconds here. [@] It's called a "comb filter" because if you look at the frequency response of this thing, considered as a filter, there's a peak every 50 Hertz, regularly. [@] That looks like a comb of some sort. [@] Looking forward ... elaborating this idea in the future, we'll be able to design arbitrary filters with desired frequency responses. [@] But, right now all I'm doing is reinforcing the notion that this thing can be considered as a filter -- which is a thing which will take any sinusoid and then give you a sinusoid out at the same frequency, but perhaps at a different amplitude. [@] That's a filter. [@] Or, you can consider it as just a delay network, which is a thing which makes echoes. [@] Those two things are really the same thing, except that they're psychologically different and the parameters that you put into it might make it act more like the one thing or like the other -- or seem like more like the one thing or the other. [@] So, there's that. ( [@] Let's not even worry about that any more.) [@] Now what I want to do... [@] Oh, yes, I do want to say one thing before I leave here, which is that this is a "linear time invariant" network, as the engineers will call it. [@] And, what that implies is that if I put a nice sinusoid in, at any given frequency, like 50 Hertz -- nah, 100 Hertz -- out will come a nice sinusoid of the same frequency that went in. [100Hz tone plays] [@] There's no way that a recirculating delay network -- or any kind of delay network that doesn't have time varying stuff in it -- can take a sinusoid of any given frequency and put out a sinusoid of some other frequency. ( [@] If you put a color of light into a filter, or into a prism, or any other optics like that, you get the same color light out, if it's monochromatic.) [@] That's a thing which we count on because it makes it possible for... [@] Well, your ears seem to like to segregate sounds that come in by frequency, and so, if something sort of leaves frequency to where they are, it doesn't make different frequencies out of incoming frequencies, then you can say that your ear might hear a very clear relationship between what goes in and what goes out. [@] Maybe. I'm hopeful that that's true anyway. [@] Now, what I want to do is get into some practical stuff that you can do with delay networks. [@] The first thing that I want to comment on is this: [@] (Let's see. [@] What I'm going to do is do a "Save as," and start all over again, because for this next example, I actually want to make a non-recirculating delay.) [@] Instead, what I want it to do is be something where I can change the delay time. [@] So, we'll call it "delay-time-change. [@] pd" <>. [@] There it is, and now we're going to make in non-recirculating which means I don't care about the gain any more... as it turns out. [@] I don't care about listening to the original sound. [@] I just want to take the original sound and throw it into the delay line. [@] Let's rename the delay line, just so you can have both patches open at once if you want. [@] We don't need this pitch calculation anymore. [@] Go away... [@] Whatever that is down there get rid of it... [@] OK, And then we're going to read with the delay time given. [@] And then we're just going to listen to it. [@] Like that. [@] So am I doing anything stupid? [@] Find out soon. [@] And so I'll do the brutal thing of putting a sinusoid in. [@] In fact I'll give it a nice 440 Hertz sinusoid. [@] And now we hear: [tone starts] A 440. Very good. [@] Actually... [tone fades out] make that a little bit louder at the mixer so that I don't have to do anything funny. [tone starts] OK, and now we're going to change the delay time. [@] OK, so a 440 Hertz sinusoid comes in and you hear it 20 milliseconds late. [@] You don't hear the fact that you heard it 20 milliseconds late. [@] It's coming out as a perfectly clean 440 Hertz sinusoid except that the phase is different. [@] And that's just what that is. [@] Now we start changing the delay time though and we get something else. [tone begins to stutter] -- Which is ugliness. [@] And the reason for that ugliness is very simple: [@] It's just that if you change the delay time, it's the same thing as if you were reading from a wavetable and you suddenly changed the location of the wavetable that you were reading from. [@] That would make discontinuous change in the amplitude or in the signal. [@] And you will hear that discontinuous change as a == ["zippered" tone starts] click. [@] Just to throw out a warning, of course if I was listening to noise ... [white noise starts] I could change this delay time and you can't hear the click. [@] Because there's no correlation between one sample of white noise and the next sample anyway. [@] So the fact that you changed the place that you listen to it from doesn't sound like anything different from how the noise sounds to start with. [@] I'm telling you this because you're going to make networks. [@] And they're going to sound great because you're going to make them with some noisy signal like an overdriven electric guitar or something like that. [@] And you're not going to know that you're actually doing this to your signal: ["zippered" tone starts] ... until [tone stops] [@] someone with better ears or more experienced ears than you points it out to you or something horrible like that. [@] So test your stuff with sinusoids, which are the most punishing signal that you could possibly put through a thing. [@] Even though it's the simplest signal too. [@] So that you can tell whether your patch is clean or dirty. ( [@] Oh yeah let me get rid of this comment which is superfluous and this one too.) [@] Now. So let's make an application: [@] What I'm going to do is take my nice incoming sound and I'm going to listen to it... [@] oh, great I'll do it here for clarity's sake. [@] I'll do this with a microphone now just to annoy you all. ... [@] What we're going to do is take the incoming sound which is the microphone. [@] I'm going to talk into the microphone and see if it's [voice begins being amplified] amplifying my voice correctly. [@] OK great. [@] Slight delay but that's all right. [@] And now I'm going to give you a delayed copy of it: [amplified voice begins to be delayed] "Hello." [@] And now it's obviously far too late. [@] So here's my voice and here's my voice ... and here's my voice delayed. [@] But now I'm going to say, "Can I change this delay time with the mouse and get away with it?" [@] So now I'm on a different delay. [@] And well ... Never mind I thought it was going to be more forgiving than that. [@] But my voice is already low enough and dull enough that changing the delay time is very, very bad and nasty. [@] So I didn't succeed in demonstrating something where you can change the delay time and think it was clean -- and in fact wasn't. [@] -- I can do that and you don't hear the problem. [@] If you want to have a delay line where you can change the time, then you have to work. [@] And the work that you have to do is really better described as Pd lore than described as anything theoretical. [@] So now we're going to enter into Pd lore. [@] Actually this is computer music lore, because if we were using some other software from Pd this would also be necessary and you would do almost exactly the same thing. [@] And the same thing is this: [@] Before I do it right let me do it wrong another way. [@] It's always fun to do things wrong. [@] Let's make it change smoothly. [@] I'm afraid I'm being repetitious here because I think I already showed you this for samples. [@] But I'm going to take this thing and just line it. [@] So we'll say pack the thing with 100 milliseconds of packing. [@] And then I'll make a nice line. [@] And then I'll put the delread~ on. [@] Sorry I'm really belaboring points here today but this is... [voice amplification starts] "Belaboring point." [@] There's a delay and now I'm going to say 'ahh' and change the delay. [@] So 'ahhhhhh'. -- Did NOT help. [@] OK the reason that didn't help is because the line is not an audio signal -- it's only updating every 20 milliseconds. [@] And so you're just hearing 50 problems a second instead of however many problems a second I was generating with the mouse. [@] No better. [@] Watch Pd do something wrong just while I'm thinking of it. [@] Really at this point, I got a nice error here. [@] There's a signal coming out of this line, but delread~ doesn't want a signal, and so I got an error message here which you don't see very often. [@] "Signal outlet connected to non-signal inlet (ignored.)" [@] What that means is this thing was line (without a tilde) which is a control object. [@] And I was able to connect it, and then I changed it to something else that it wasn't able to connect, but it didn't have the heart to disconnect it because I might want to change it back.. [@] But, nonetheless, it's not working right now. [@] This thing really should turn red and blink or something like that. [@] Also, by the way, you don't see this all the time because usually the order in which you do this is you get the object built, and then you try to connect it, and then Pd just won't let you connect it. [@] That's probably the correct thing to do in that kind of situation. [@] Anyway, you saw that happen. [@] This is not going to work either. [@] Is there a version of delread~ that I could plunk a signal into? [@] The answer is "yes." [@] There's one called "variable delay." <> [@] (This started out in a different language where this wasn't such an ugly acronym.) [@] Variable delay is a delay object whose input expects a signal instead of a control message. [@] And, as a consequence of that, it does two things that delread~ does not do. [@] The first thing is it's willing to change its delay time every single sample. [@] Then there's another thing that immediately comes up which is that if you're going to be changing delay times from one to another in a continuous way, actually one sample of accuracy isn't enough to make the result clean. [@] So variable delay has to interpolate the incoming samples to possibly simulate delays that are not an integer number of samples. [@] So delread~, the non-interpolating control-message delay, will always give you a delay that's actually an integer number of samples. [@] And you can get pretty close to whatever delay time you want, like within 20-ish microseconds, better than that maybe. [@] But variable delay, vd~, will actually make a four point interpolation of the stuff that's in the delay line. [@] The delay line's actually a storage area. [@] It will go and find four points and make a four point interpolation among those points to try to guess what the sample ought to have been that is in between the samples and the delay line that corresponds to exactly the delay that you asked for. [@] The advantage, of course, is that the delay time is exact or as exact as floating point allows you to be. [@] The disadvantage is that it costs more -- there's more computation involved. [@] Also, if you do that, that interpolation has its own frequency response which is not perfectly flat. [@] So you will not get a signal whose spectrum is exactly the same. [@] This thing, because of the interpolation, will drop off in high frequencies somewhat. [@] And that's a bad thing which you can control by raising your sample rate, but which is always going to be there whenever you interpolate. [@] However, going back to the good stuff, now what happens when I change the delay time is it does the right stuff. [@] We have a delay going, and now we're going to start to change the delay. [@] In fact, I'm going to say "ahh" and change the delay. [@] "Ahh." [inflected] Ahhh. Good. [@] Now we have a wonderful patch that let's you generate other pitches than the pitch that you put in. [@] That contradicts what I said before -- except what I said before was you couldn't go changing anything in the network if you want sinusoids that come in to always come out of the same frequency. [@] Now, I'm changing something -- it's no longer time invariant -- and as a result, that nice property of "stuff that doesn't change in time" is no longer there, and now we're making other frequencies. [@] Well, what about that? [@] Now that I've done that, I'm going to stop irritating everyone and go back to the sinusoid. [@] Let's turn this down; turn on the sinusoid. [@] Here's the sinusoid. [tone sounds] It's 440 Hertz for you, again. [@] Then if I listen to the delayed copy of it, [tone] same pitch, but of course if I change the delay time, [tone] I'm changing the pitch. [@] Well, that's cool. [@] That should make you immediately think, "I can do all kinds of things with this. [@] I can take someone who sings in a monotone and make them sing a melody or vice versa. [@] I could take something that came out of melody and turn it into a monotone, things like that." [@] Well, you sort of can. [@] In fact, I'm going to work toward that. [@] However, first off, it might be nice to have an idea about what that frequency is. [@] In other words, how would you predict what that frequency should be? [@] Why would you want to do that? [@] So that you can get whatever frequency you want... [@] Oh, frequency: [@] What comes out is a transposition of what goes in, so as in a sampler, it's probably appropriate to talk about what kind of transposition you're getting. [@] That's to say what kind of change in the frequency or relative change in the frequency. -- [@] What is the frequency multiplied by? [@] That's a transposition. [@] To make that painfully obvious, I'm going to throw in a pair of oscillators, and you'll hear a nice interval which will be a fifth because I'm going to tune this one up to 660. [@] Let's see. Do we hear a fifth? ... Yeah. [@] And now when I start playing it with a delay when I start messing the pitches up you will still hear that the pitches are related to each other. [@] It's always a fifth moving up and down in parallel. [@] That's the same thing as saying, "Yeah, the frequencies all got multiplied by some constant or multiplied by some number rather than maybe added to some number like a ring modulation might have done to it or something like that. [@] Multiplied by what number?" [@] is the next question. [@] To answer that I have to do something a little bit more... [@] What's the right word? [@] ...a little bit more "controlled" than this. [@] Right now I'm just sort of mousing willy nilly at this number box. [@] But in fact what I should consider doing. ... [@] Oh, you know what? Let's save this. Oh no. It's OK. [@] We'll set delay time. [@] And now we have a way of making delay times up here. [@] You know what? I'll call the delay time down here. [@] And then I'm going to make some message boxes so I can do stuff. [@] So I'm going to say, for instance ... let's jump to 100 and go up to... [@] We'll go to delay time of 0. Well, I can't really get down to 0 really. [@] Am I going to tell you all this? [@] I'm going to... [@] I'm just going to cheat. [@] I'm just going to ignore the problem. [@] I'm going to go down the delay time to zero and I'm going to gradually go up to a delay of 1 second. [@] How long am I going to do it? [@] ... Take a second to do it. [@] Oops sorry. [@] That needs to be a pair. [@] And now I will put in the nice sinusoid. [@] So this is an alternative to that. [@] So now I'm going to... [@] This is the sinusoid. [@] Oops sorry. [@] Let's get rid of this one again. [@] And now I'm going to start the delay line changing and you all know what you're going to hear, right? [@] Uh, bad! -- A beautiful bad example. [@] laughs] That was not my plan. [@] What did I just do? [@] I just made the delay line shrink at exactly the same length that time was passing in such a way as I slowed the thing down to stop it entirely. [@] This is wonderful but this is not what I really want to do. [@] Let's go up to one half second and take one second to do it. [@] And now we say: [@] Now what you hear is for the period of one second it drops by an octave. [@] And what if I wanted to... [@] OK So now you've seen two examples. [@] One is I was able to stop it altogether and the other is I was able to slow it down by a factor of two. [@] Why did it slow down? [@] Well, there are two moments in time here that might be appropriate to think of: [@] One is the moment where the thing starts and one is the moment where where it ends. [@] I'm thinking about time in... [@] I'm thinking about so-called "real time" that is the time at which the sound is coming out of the delay line. [@] That's real time for us. [@] A second real time passes while the delay time starts at nothing and goes up to 500. But this line is being asked to jump to zero and then to ramp to 500. [@] In that second of time how much of that sinusoid do we hear? [@] Well, ... At the outset you hear the sinusoid that is coming in at the same moment as you're listening to it. [@] A second later you're listening to the sinusoid as it had been one half second earlier than that, which is to say only one half second after you started listening to it. [@] So you succeeded in slowing the sinusoid down by a factor of two because you only heard the one half second of it that went into the delay line between the original time -0 and the time a second later, -500. [@] Rather than trying to explain that better, I'll make another example which is this: [@] Let's go to 100. Wait. [@] What's a good number? [@] Let's go to 333 milliseconds--one third of a second. [@] The delay starts at zero and then it ends up at one-third of a second. [@] So how much of the sinusoid do you hear? [@] You hear the other two-thirds of the second of the sinusoid, which is to say: [@] there's one third of a second we haven't heard yet because at the end of the process the delay line is a third of a second long so we didn't hear the last third of a second of the sinusoid. [@] You've only got the other two-thirds. [@] So we all know what that is as an interval. [@] It means going down to fifth. [@] So now when I whack this it goes down to fifth. [@] So now if keep on whacking this I could get it down to a fifth and I could get it to stay there, right? [@] Sort of.... [@] While we're at it. [@] Now we have a nice tool for changing pitches. [@] So now we can listen. [@] Let's see. [@] I'll shut this up and I'll be me. [@] Hello I'm talking. [@] You'll hear me talking in fifth below the frequency that I'm speaking now. [@] So I just made a nice wonderful object that transposes my voice down a musical fifth. [@] Oh, yeah, I played you already what it sounded like when I ring-modulated my voice, which made it an inharmonic sound, usually, because there might be some weird interval between the voice I was speaking in and the frequency of the ring modulator, back when I was ring-modulating my voice. [@] We saw similar things when we were doing frequency modulation two lectures ago. [@] And now what you're getting is a thing which is different from that. [@] Because it takes the voice and maintains the relationshipss between the partials that were in the voice, but moves them all down proportionally by the same amount, so that their relationship stays the same. ... [@] So that the partials going in have frequencies with ratios of one to two to three to four to five and so on, and those ratios are fixed, even though the frequencies of the partials are being multiplied each by two-thirds. [@] This is a favorite trick of Laurie Anderson's, if you've seen her perform. [@] However, there's a little bit of a problem here, [sound] because if you listen, try to understand what I'm saying here. [@] First off there are clicks all the time because [sound] I'm having to change the delay time constantly. [@] Oh, why don't I just never stop? [@] I want the thing to go down a musical fifth, and I want it to last forever. [@] So, we'll say, I don't know, we'll go on for a million milliseconds, which is 20 minutes. [@] And we'll do that over three million milliseconds, which is an hour. [@] And now I can talk for the ... better make the delay line really long now, right? [@] Like instead of five seconds, maybe ... I don't know how long to make this before I run out of memory, but let's just live dangerously. [@] So, now we have five million samples of delay. [@] Oh, it hates me. [@] It's reaching for five million samples within memory right now. [@] Is it going to succeed, or am I going to have to give up? [@] I hear my disk drive. ... [laughs] It did it. [@] OK, so we now have a delay line that has five million samples in it, [sound - echo] And of course you hear me only on the second delay line, because I'm only using whatever I asked for. [@] But now, I can start giving you a lecture and it's all going to be all transposed down by a musical fifth. [@] Everything would be perfect -- except that there's one terrible problem -- it's that it's getting later and later and the whole lecture now will not last 80 minutes, but would last four-thirds of 80 minutes, if I'm computing right, which is longer than we have in this room. [laughs] [@] Or, to put it another way, well duh, the delay time is getting longer and longer and longer. [@] And now just for fun, "hello." [@] We'll just give ourselves a bomb that will wake us up in a few seconds. [@] This is not a good way to do pifth-shift if you want to regard that as a real-time process. [@] How would you ... OK, so maybe we should go back to the other thing and be continually resetting the delay time to smaller values, [sound] but then of course the smaller values ... But then you couldn't do it without clicking. [@] So what would you do? [@] The answer could be, you change it, but you shut it up while you're changing it. [@] And then you let it start off again. [@] And now, let me try to explain this better: [@] OK, so, going back to ... oh yes, and I'm going to do this two different ways, too, as I do a little bit too much of. ... [@] Oh, you know what, I can get rid of this delay line; I don't like what this is doing to my disk drive. [@] So, I'm going to go back to using a reasonable amount of memory here. [@] And you didn't see this, so I'm just going to erase this from the record. [@] I'm going to lose this idea. [@] What we're going to do instead is make the delay line get quiet -- change to zero, and then get louder again and then start changing. [@] Let's see, let me even make a simpler example than this. [@] So, what I'm going to do is I'm going to ... So, I'm going to show you two different things: [@] OK, so first off, this was cool, and we're going to save it, and then we're going to do a "Save as", and we're going to go back to regular old ... How about 3.delay-time-change..., [@] and then I'm going to make more ... going to make a ridiculous, file name ... I'm going to use an envelope generator to change the delay time cleanly. <> [@] So, now we're going to go back to delread~ . ... for simplicity's sake. [@] So, we no longer have the right to put this line~ in here (and it's complaining to us, but I'm going to get rid of this.) [@] Now, I'm going to try to ... Yeah. [@] OK, that's good. [@] Let's get the number box out again. [@] OK, now we're back at the situation where ... [tone] we can't change the delay time without making the noises. [@] So, what if I wanted to change the delay time, but not have the bad noise? [@] The answer is we mute the sound and then once the sound is good and muted we change the delay time and then we unmute the sound. [@] So to do that we're going to have to multiply it by a ramp generator in order to mute it. [@] (My disk drive is still is still churning after that five million point delay line. My computer has indigestion right now.) [@] Oh right. And now this line of course we know how to turn it off. [@] We throw it a message that says go to zero and take some amount of time. [@] I don't know how long--maybe 10 milliseconds. [@] That again is a value that you're going to have to find depending on what kind of signal you're throwing in. [@] And then we have a nice thing to turn it on. [@] This is an on/off switch. [@] See if this works so far. [@] So there is sound. [sound] OK. [@] Idiot's delight right now. [@] So what we're going to do is every time this thing changes, we want to first say "zero" and then change it and then when we change it at the same time after its quiet we can then ramp the amplitude back up. [@] So what will happen is after a delay of a second... [@] So let's get a nice delay object out. [@] Sorry after a delay of... [@] So what I want to do is I want to make does this: [@] [sound] It mutes the thing, changes the delay time to whatever we want and then turns it back on. [@] So whenever the number comes in we're not going to change the delay time at all right away. [@] What we're going to do is we're going to... [@] let's see... [@] we're going to send a... just... Sorry this is... I'm going to be a little bit pedantic here. [@] I'm going to send a bang off to this nice shut-up button. [@] Now I have this wonderful network which has the property that when I try to change the delay time it just mutes it and it stays off forever, right? [@] We don't have everything built yet. [@] And then after a delay of ten... [@] So we'll bang this delay of ten and then we'll turn it back on. [@] And now we have a wonderful patch that whenever we change the delay time it just turns the thing off and turns it back on which you can hear a little bit. [sound] [@] The only problem with this is that -- first off I can't really ramp very nicely with it because it has to mute and unmute it very, very quickly. [@] It sounds ugly. [@] But I can still change it like that. [@] It's yea OK. [@] As long as I'm putting something complicated through we get away with that. [@] But it didn't actually change the delay time. [@] Nobody's talking to the del read and of course I can't just send the delay time in right away because at the time I'm sending the delay in, it hasn't succeeded in muting yet. [@] It sent this message to start muting but I really need this thing to come in ten milliseconds later after this thing has shut up. [@] So let's take the signal and store it and then when the del 10 is done is when we send the new value of the signal delay. [@] All right this is going to need a little bit of cleaning up before it is really palatable. [@] But now we have something where we can change the delay time and it's smooth. [@] So now for instance and to prove you that the delay time is actually changing, I can now use it as real time thing: [sound] So now you hear this nice delay. [@] And now the delay goes away. [@] And now the delay becomes a second. [@] Oops. And now the delay is a second. [@] And now it's very short. [@] So now I can change delay times on my voice, and it won't make that ugly sound. [@] All right; so this is a good thing. [@] This is a good way if you want to make yourself a delay effect to be able to change a delay time and not have people complain at you because it sounded ugly. [@] Now to go back: [@] The previous patch, I actually got the variable delay object out and it's showing off Doppler shift. [@] And then I was saying, "Oh it would be cool if you could use that Doppler shift thing to make a pitch shifter." [@] That's to say a thing where I could sing in at some pitch now it becomes a continuous singing at other pitch without having a delay time that was gradually either growing or shrinking. [@] So let's apply this principle to a variable delay line. [@] So the variable delay is changing all the time. [@] You can change the delay just fine without having badness. [@] But the thing that causes badness is when you cause the delay time to change discontinuously, which you had to do periodically. [@] So let's see. [@] Now what I need next is actually closer to this patch from the previous one. [@] So I'll start with this one. [@] OK now we're going to make a proto pitch shifter. ... [@] That's number four now. [@] We're being productive today. [@] We might actually get up to five or six patches. <> [@] OK so now what we're going to do is go back to variable delay land. [@] That means we need to drive it with a nice line~ object. [@] So this is no longer just going to bash a discontinuously changing value into a float. [@] Instead we have a nice line~. And now what we're going to do... [@] The patch that I'm now going to make is for pedagogical purposes. [@] I would not be likely to use this. [@] I'm going to show you how to do this better. [@] So what I have to tell you is I'm going to do something deliberately sort of OK, but this is going to be replaced by something substantially better in a few minutes, OK. [@] So, the not quite so great thing is this: [@] We have this nice message box, for instance I had zero and I grew up to 333 in a second. [@] And this had the property that... [@] so I'm just going to check this and make sure I'm still where I was. [sounds] So here we are. [@] Now we have a thing that takes my words dashes it down a fifth, musical fifth. [@] Oh, yeah. [@] I have to remember by the way to tell you how to compute these numbers to do your own intervals because not every interval is a fifth, right? [@] And now what we're going do is, well everything was cool except that going back to the sinusoid again to demonstrate this. [@] You hear a click every time you... [@] well you might hear a click depending on the phase every time you reset this thing. [@] So that's bad, but of course we now know what to do about that which is we just... [@] OK shut this off while we're... [@] We just send off a bang to the... [@] that's bad because that's going to make two bangs. [@] Let's give ourselves a nice button. [@] So the button is going to mute the thing and it's going to set this new... [@] No! It's not going to do that. [@] It's going to happen after a delay, isn't it? [@] Then the button is going to set the delay off. [@] So now what's happening is... [@] Let's see if I can make this readable. ... [@] It's not great. [@] Whenever I press the button what happens immediately is the line~ gets muted and then what happens after 10 milliseconds is I restart this process of changing the delay line continuously and I unmute the output. [@] Now I have a bad but partly serviceable pitch shifter, which can shift us down a nice musical fifth. [@] Except of course if I forget to keep whacking the button eventually it goes back up. [@] By the way, no matter what I put in here if I keep going in this way I will never do anything other than... [@] Well, is this true? [@] I can transpose down in a clear way and get all sorts of intervals transposed downward. [@] Oh yeah, how about 200 then. [@] There's a musical perfect third for you, want it? [@] How would I make the thing transpose up? [@] You can't go down from zero, so rather than do this you would start at some value like 200 and ramp down to zero over time, so that the length of the delay line is decreasing instead of increasing. [@] And then we get... [@] Anyone want to guess what interval we're going to get now? [@] -- A perfect minor third up. [@] So, why did it go up? [@] The delay time decreased -- it decreased from 200 down to zero, so over the period of one second we quit hearing something that was 200 milliseconds old and gradually got to where we were hearing real time, at a delay zero. [@] So we heard 1.2 seconds worth of sinusoid in a mere one second of time which means we heard it at five... [@] no, at six fifths at one and a fifth times the rate. [@] That's to say it's 1.2 seconds divided by 1 second worth of sinusoid that we heard over one second of time. [@] We heard it 1.2/1 times too fast -- 1.2 times normal speed. [@] In general, if this amount of time is one second, then the amount that we hear is this minus this plus one... [@] oh, plus one second. [@] So this is actually a fifth of a second. [@] So in units, what we get is... [@] the transposition is one plus, OK. [@] One, because time is always moving forward, so if you do nothing at all then you get as much out as you put in. [@] So it's one plus this minus this -- is the ratio by which the frequency went up. [@] And if you give these three things names then you can make a formula. [@] So, if the delay time is increasing, the pitch is going down if the delay time is decreasing the pitch is going up. [@] By the way everyone will immediately use the word "Doppler" to describe this. [@] This is a sort of Doppler shift. [@] This is the Doppler shift that corresponds to, not the one that you'd normally hear which is you're sitting on a park bench and an ambulance goes by. [@] That's the source moving and you are the listener and the delay time is the air. [@] Simply the air carrying the sound from the signal source to you. [@] A better metaphor here is there's something emitting a sound that's fixed and you're moving -- because you're changing the delay of which you're listening to it. [@] But at the same time that's Doppler shift. [@] You can hear it if you're running around on a bicycle or something like that and listen to someone who's stationary blowing a car horn, however that's not as often... [@] that doesn't happen as often as you're hearing the horn stationary instead. [@] But it's Doppler shift anyway. [@] And this is the formula for Doppler shift too if you want. [@] Should I tell you this? [@] You can even have a Doppler shift that is so intense that it turns the sound around backwards. [@] So imagine that someone was sitting here talking and what they were saying was so unpleasant that you were running away from that person at twice the speed of sound. [@] You all know the speed of sound, right. [@] It's well, it's a foot a millisecond. [@] 1,000 feet per second, roughly speaking. [@] So, you're high-tailing it 2,000 feet per second away from your professor. [@] And as a result, you're hearing everything that the professor is saying, backwards. [@] Because, you're actually ... the sound is sitting there in the air waiting for you to hear it, but you're traveling at twice the speed of the sound, so you're hearing the sound as it's getting further and further away, further and further down the delay line. [@] Oh, we can even do that. Watch. [@] I can make this delay line do that, by saying, we're going to start with no delay at all, and then we're going to run two seconds of time away in one second. [@] Let's see if I can do this. [@] And then I say anything at all, like "fruitcake." ... [@] And nothing comes out. [sound] ... Fruitcake, and it didn't work, oh, I didn't put the comma in. [@] Also, this is terrible, I'm making all sorts of distortion, because I'm being sloppy about the sound OK now let's see. [@] I hear something. Test. Test. [@] What? [Echo] Oh, I have speak before you start running away from me. ... [@] So, you're going to hear it forward then backward, like this. [@] "Jelly beans." [@] Oh, it didn't work. [@] What's going on? [@] Jelly beans. [@] Jelly beans. ... [@] "I'm changing my voice to go around backwards." [@] Oh, and that was feedback -- ignore that. [@] So, that is a transposition factor of -1. In other words, I'm running the sound around backward by changing ... by making the delay line get bigger -- faster than time is even moving. ... [@] So, that was a slight digression. [@] And so anyway, let's go back to this thing. [@] So to make a very cheap pitch shifter, we would say metronome ... I don't know, chose some number of times a second we're going to do this. [@] Maybe 10 times a second. ... [@] And now, everything that I do will be transposed. [sound] OK. [@] Transposer, pitch shifter. [@] Very nice. [@] This is kind of a bad pitch shifter, although it's working. ... [@] Let's make a slightly better pitch shifter by ... So, it's a little bad that the thing is actually dropping out completely. [@] But what you might wish to do is have two delay lines and be cross-fading them, so that the sound is continuously working, even when you wish be changing the delay line. [@] And you can do that, but maybe it would be better before we do that to prepare the example by changing the way we're doing this anyway ... in the following way. [@] So, let's do a "Save As." [@] I'm going to switch now, instead of using a line~, to using a phasor to drive the delay time. [@] Oh, yeah. [@] And why ... you're going to be able to figure out why immediately when I show it to you. ... [@] I'm going to quit doing this for now, because this is not really going to work for us. [@] So, for right now, I'm just going to cheat and say multiply by 1. That's to remind me that later on I'm going want to control the amplitude again. [@] But meanwhile, I'm just going to drive the line~ with a nice phasor. [@] And it's going to have some nice frequency going in. [@] And if I just throw this right in, (I didn't even have a line~.) If we just throw this right in, it's going to vary between 0 and 1, which is going to be interpreted as milliseconds down here, which is not so great. [@] So, we're going to have to change the range to something reasonable. [@] And I will make that be a message box, too. <>. [@] And at this point, I should say that I don't actually know what order this delwrite~, and this delread~ are occurring in. [@] So, it would be appropriate at this point to add a couple of milliseconds because there could be a 64 sample delay engendered by the fact that this delwrite~ might happen before this delread~. [@] There's other Pd lore that I'm going to avoid telling you about, how to force that into happen right. [@] But now, I'm just going to add a nice delay, which ideally should be at least a couple of milliseconds. [@] Maybe I'll take that away later and see if it hurts us. [@] And now, let's see, we'll go once a second, and we'll have it vary by, let's say, 200 milliseconds, and then we will throw a nice sinusoid in there, which we listen to, and out comes:[sound] you all know it. [@] And out comes, you all know it. [@] So, it's going to be a if I got it right, [sound] down a minor, a major third. [@] Tada! Ooh! Bad example! This example, this was too good. [@] I can change the delay discontinuously by one second, and because there are exactly 440 cycles in this thing in a second I got away without any discontinuities at all. [@] Don't try this at home -- Or let me show you what could go wrong if you did. [@] Let's try 440 and a half. [@] Everything's going great. [@] We're transposing, but there's a discontinuity every second when this phasor resets. [@] OK, so I'll go back to 440 to pretend it's working nice. [@] And now I have a nice continuous control over the pitch shift. [@] And, in fact, the shift of the pitch I can compute, I think. ... [@] so this number is really a fifth if it's in seconds -- it's 200 milliseconds. ( [@] Oh, this is interpreting its input as milliseconds.) [@] So what's happening now is: [@] So the phasor is happening in an amount of time, which is one over this, and it's happening and it's changing by this amount every time. [@] So the transposition that comes out ... The transposition factor is one if there's nothing happening at all. [@] That's to say, when the phasor isn't moving at all. [@] But if the phasor is moving the thing is being increased by 1 ... (Sorry, that's the 1 which is just oneness because time is passing.) [@] 1 minus the product of the phasor frequency and the phasor amplitude. [@] So in this case it's one minus one fifth because this is in Hertz and this is in milliseconds, so this is really 0.2, so this is one times 0.2, which is one fifth, and one minus one fifth is four fifths, which is down a major third. [@] Now you know how to compute, no matter what this is, what it should do. [@] Let's see: [sound] [@] So this is now one minus two fifths, which is three fifths, which is a major sixth. [@] Oh yeah. [@] Let's play the original here. [@] So, transposition equals 1 minus product of phasor frequency and phasor amplitude. [@] And then you can work that backward any way you want. [@] Now the next thing is ... let's get rid of the clicks. [@] Oh, you don't hear the clicks because I fudged it here, but now if I change either this frequency or this. [@] Oh, yeah. [@] Oh, minus three means the phasor's phasing backwards, of course. [@] If I change this, I might be changing the delay time by an amount that's not an integer number of cycles and as a result I'm getting clicks, which is kind of bad. [@] So I do have a thing that can continuously change frequency -- But it's clicking like all get-out and that's not something that I want. [@] Another thing about this is, of course, since the delay is ranging between zero and 121 or whatever this range is, there's going to be a delay between when you do something and when you hear it, which could be a problem. [@] For instance, when I start loading my voice in or actually click into it. [@] There's a delay there. [@] So I've got the transposition OK, but I've got delays as well. [@] The delay's actually varying between zero and 121 milliseconds. [@] So that's OK. [@] We can make this number be as small as we want. [@] Let's make it 10 milliseconds. [@] So here's the sinusoid again to test this. [@] So now by the time I give it enough frequency to give it a decent transposition I've had to drive this value up high because this value is small and the transposition is controlled by this product. [@] As a result, I have more and more problems, more and more discontinuities per second. [@] So there's going to be a trade off in pitch shifting between the size of the delay I'm willing to tolerate and the speed of changing it that I'm willing to tolerate. [@] In fact, it's going to become even clearer that this is a trade off when I fix it so that it doesn't click anymore. [@] So to fix it so it doesn't click anymore -- and this I think has already happened ... Ehat's a good way to take a nice phasor and turn it into a signal that will shut up right when the phasor jumps from one back down to zero, or in this case jumps from zero to one because I'm running it backwards? [@] There are a lot of possible answers to that. [@] One thing is you can design a parabola that goes from zero up and then back down to zero as you go from zero to one. [@] The thing that people do most often -- that I see, anyway -- is they use just the best quadrant they can find of the nice cosine function. [@] "Quadrant"'s the wrong word. [@] So cosine, if you feed it zero you get one out. [@] This is cosine of 2 pi of its input, or cosine of its input in cycles. [@] So from minus a quarter to positive a quarter the cosine goes from zero back down to zero. [@] That's one half cycle of the cosine and it's the one half cycle that's positive. [@] There's another half cycle that's negative that comes right after that or before it. [@] So how do I get that nice cycle out of this phasor, or half cycle out of this phasor? [@] This is going from zero to one and I want to go from minus a quarter to a quarter. [@] So, in general, if you want to change the range of something first you decide how big you want the range to be and multiply it by that: [@] So I want the range to be a half big because it has to reach from minus a quarter to plus a quarter and then I have to subtract a quarter to get it in the right place. [@] Let me say that more clearly: [@] So, this varies from zero to one. [@] Now it varies from zero to a half. [@] And, now it varies from zero minus a quarter to a half minus a quarter -- So, it goes from minus a quarter to plus a quarter. [@] Now we just run this thing through it, and then we just multiply. [@] Ooh. And, it doesn't let us connect, because Pd is cool and that times ones said, "I want control inputs there" -- which I don't any more. [@] Let's go back to something reasonable: [@] 10th of a second; a Hertz. [@] Here's the sound going in. [tone plays] And, here's the sound going out. [different tone plays] Pretty good. [@] Hmm, would be pretty good if it weren't changing its amplitude all the time. [@] Well, there are ways of dealing with this. [@] Certainly the way that's easiest to describe to deal with this is the following: [@] Let's see. [@] I'm going to take these things and get them out here. [@] You'll see why in a second. [@] Let's make another one of these things, and let's make it run out of phase from this one. [@] So that, whenever this one is quiet, the other one is loud and vice versa.[tones playing] [@] So, how do you do that? [@] OK, so this is all good review stuff. [@] How do you make a phasor that's a half cycle out from this phasor? [@] This goes from zero to one, so we could always say, add a half. [@] That means we go from a half up to one and a half. [@] And, then if we wrap that... [@] Then if we say "wrap~", then... [@] This warrants explanation: [@] So, this goes from zero to one. [@] This goes from a half to one and a half. [@] This wrap~ leaves the part that goes from a half up to one, but then the part that goes from one up to one and a half becomes a straight line segment that goes from zero to a half. [@] Draw this out on a piece of paper if you don't believe me, but the result is just line segments, the same as this. [@] But, this thing changes value discontinuously whenever this thing crosses a half, because that's when this crosses one, and that's when the wrap changes its mind about what integer to subtract. [@] So now, we've got ourselves a nice out of phase phasor. [@] And, we can use our out of phase phasor. ( [@] Let's see. [@] I'll need to be compact here. [@] Maybe I just don't have to be so compact. [@] Let's move this stuff out of the way somehow. [@] Don't need that any more, move this whole thing over. [@] Now do I have room to have another one of these? [@] Not quite yet.) [@] So, I'm just going to take this whole thing, including the multiplier, and make another copy of it running out of phase. [@] And, I'm going to reuse these number boxes, like this. [@] So that I'm multiplying and adding by the same numbers as before. [@] I could clean this up, but don't know how. [@] The right thing to do would be to do this and move things around, but maybe this is clearer for now. [@] So, now we have two transposers and one of them is jumping when the other one is being stable. [@] The jumping one, of course, has been faded out in order to allow it to jump. [@] So, one is always fading in while the other is fading out. [@] Oh, yes. [@] In listening to just the first one to start with: [tone sounds] [@] It's doing that for us. [@] Let's try to make them faster. [@] On the other one, if we listen to it alone, is doing something similar... [tones playing] Whoops -- except I have to repeat these things because I didn't put them in the objects yet. [@] And now, if you add them together... [@] We get something that's not quite as variable in time. [@] It's not perfect, but it's a little bit better. [@] And now, again, we can continuously vary the pitch that's coming out. [@] We can also drop the amount that it's changing the delay by. [@] Of course, in that case, we have to move the phasor faster in order to get a fixed transposition. [@] OK, so let's go back to listening to the voice: [@] So, this is close to the classic pitch shifting algorithm. [@] So, now we're shifting pitch and we have decently small delay and a reasonable transposition. [@] And, we can go up, like this, and so on, like that. [@] And we can make silly sounds by transposing up an octave or two, which I won't get into. [@] It will sound like a chipmunk. [@] So, this is a classic kind of a patch you could call a "pitch shifter." [@] People frequently call these harmonizers, but the word "harmonizer" is a brand name, so call it a "pitch shifter" if you want to be generic. [@] Let me just show you where this shows up in the help browser because you might care how to compute appropriate numbers to stick in the phasor and the delay line yourselves. [@] Of course, I did all that work, and if I were a good didactic person I would make you all do this work too. [@] But instead I'm just going to show you how you find the answer. [@] You go down to the delay examples and you find the... [@] there's a delay G09.pitchshift. [@] And just get this patch out. [@] And this is a fabulous patch which... <> [@] -- Well anyways, I think it's fabulous. [@] Which plays... [sound plays] plays a nice bell. [sound] [@] That's Johnathan Harvey's bell sound there -- And lets you transpose it. [@] Any number of well OK... [@] it's computed in half tones. [@] OK now, let's turn this thing off so I can talk about it. [@] So here, the only thing that I've added to what I just showed you, here's the phasor and and the wrap~ and all the good stuff that you just saw. [@] The only... [@] ... Yeah, I did exactly the same thing. [@] Oh, I did this in the opposite order, sorry. [@] Work it out; it's the same deal. [@] The thing that I changed here was that I actually went to the trouble of figuring out what frequency you would give this phasor in order to get a transposition that you would specify in half tones -- which is the western unit for pitch shift. [@] So here, for instance, if I say I want to go up seven half tones, that means I want to play it 1.5 times, well almost 1.5 times the normal speed. [@] So a ratio of a fifth, a musical fifth is seven half tones. [@] So C, C#, D, D sharp, E, F, F sharp, G -- seven -- seven half tones. [@] That's this 7 right here and that is a factor of roughly one and a half and how do you figure out what you should feed the phasor? [@] Well, you're going to multiply the phasor by some number which is here called the "window," that's this number here. [@] Let's see if I can show it to you in the old patch. [@] Here's a help browser, go over here. [@] So, I multiplied the phasor by this number which is the range of delay change and once the units were fixec, 1 minus the product of this and this was the transposition as a factor. [@] So, if I give you the transposition as a factor then you can do that algebra backward and that will tell you what you should feed the phasor as a frequency if you already also know this delay change -- which here I'm calling the window size in milliseconds. [@] So, if I set this to a 100 milliseconds say, that's a tenth of a second, then this number here is a tenth. [@] Here I'm correcting to seconds from milliseconds, so here's the delay time in seconds... [@] This is the delay change in seconds. [@] And if I wanted to change by this factor that means I have to add in frequency .498 to it, so I subtract one to get that by .498. And then because rising delay times transpose down, I have to multiply by -1, or to put new way, I have to subtract what I'm going to get here to get the transposition. [@] So I'm going to need to run the phasor backwards to transpose up. [@] So, in fact I have to transpose it by this number times 10 because this number is divided by this number in seconds. [@] And what's this? [@] This is taking half tones and changing it into a factor and this number is the logarithm to the logarithm to the base two of one twelfth. [@] You can compute that; you can pull out your pocket calculator -- if anyone still has one of those -- to find that out for sure. [@] I didn't do this in my head, I pulled out a calculator to get that number. [@] So this now is one of those that I just showed but packaged and engineered in such a way that you can get any desired transposition which you specify in half tones. [@] And as before, there is this wonderful trade off: [@] Let's listen to it. [sounds begin] If I want a fixed... [@] let's see, you can't change. ( [@] I'm sorry. [@] I'm going to just turn DSP on and off here to control this because I can't have the volume control and these things up simultaneously.) [@] But now, if I want to do the same thing... [@] Oh right, when you hear this you hear a sort of... [plays sound] Well, you don't hear the real problem here. [@] The problem here is going to be that since there are two delay lines that are different by one half of this window size, 50 milliseconds. [@] Everything that happens in it happens twice, 50 milliseconds apart -- which if we were putting voice through this it would be an annoying thing. [@] However if you try to fix that by making this delay time itself smaller, then you can watch here it has to make the thing run faster to get the same transposition. [@] I'll make a big 20, say and then it has to multiply this by five. [@] And now we're getting the same transposition... [plays sound] That was interesting. [@] That sounds modulated because this thing is changing so quickly that this envelope is raising the amplitude of it this many times a second. [@] That's causing amplitude modulation of sound which we hear as frequency aliasing. -- [@] Which I guess in the bells, since the bell is inharmonic anyway that's not such a clear example. ... as I can make out of my voice. [@] Let's do that. Since after all it is computer I can tell it do anything I want to. [@] Let's just use me instead of the bell now for a minute or two. [@] And now let's see. We turn it on. [@] And now you're listening to your [sound modification] professor transposed. [@] And now if I make a nice big window you can get a decent clean sound. [sound] "Ahhh".... Not great. [@] But anyway it's only changing one and a half Hertz now. [@] So it's not terribly messed-up. [sound] "Dohhh". Still pretty messed-up. [@] But anyway also if I make a speech into it. [@] Hello this is speech. [@] You can hear that everything is replicated twice -- s twentieth of a second apart. [@] Actually clicks are even better than speech for this. [@] That's messed-up clicks coming through because there are two copies of every click because I had to make two of these delay lines because they are crossfading in and out in order to cover for the fact that they're having to change discontinuously while this is going on. [@] So then I make this delay time smaller but then this number has to get higher and then you get another problem. [@] This is transposition but... [@] I don't know why I'm getting away with this. ... [@] Well this contradicts what I'm trying to tell you. [@] I was able to get outrageously small delays here. [@] Ohhh"..... Yeah. [@] But it's just inharmonic now -- although you can't really hear it. [@] You can't really hear the inharmonicity. [@] I have to play it with an instrumental sound and I don't have an instrument handy. [@] But this would be a problematic setting too because this number is too small which is pushing this is pushing this frequency too high to be good. [@] So either this number is too large or this number is too large and you will never get both of them simultaneously small with such a crazy transposition. [@] People usually use pitch shifters with small transpositions like a half tone or a whole tone like this. [@] And then you can get both this number and this number decently small simultaneously like maybe this-ish. [@] Those are almost kind of reasonable numbers to be feeding in to both of these inputs. [@] But for larger transpositions you have to either get a ridiculous window size which is the maximum size of the delay or a ridiculous frequency of interchange and you will get gradually more and more aliased sounds as you do this. [@] So in the interest of time I'm going to skip over the rest of the lore of making cool things out of delay lines although there are other cool things that you can make out of delay lines. [@] I will just mention the existence of one of them because it's a good thing: [@] You can make artificial reverberators out of delay lines. [@] I do want to save this and I'm going to close that to get it out of here. [@] I'm going to go back and get my help browser and just go get something that shows off a nice reverberator, just so that you know it can be done. [@] There are library reverberators even in Pd Vanilla which you can get. [@] But this one is the pedagogical reverberator which just shows how you make reverberations. [@] Here's the test input again. [@] Let's see. [@] This patch is designed in such a way that you make this pitch move around and it shuts up when you stop moving the thing because... [@] well you'll see why. [@] Now we're going to reverberate it and we're going to hear reverberation. [@] And reverberation sounds like this: [@] You can guess how I might have done this. [@] It's recirculating delay lines. [@] But the standard recirculating delay line has a limitation in that you either make a delay line real short and you get frequency response funniness or you make a delay line really long and then you hear individual echoes. [@] Here... Let's use me again... [@] Here you don't have that trouble so much. [@] So now let's see: [@] Now you have me being reverberated. [@] But you don't so much hear... [@] Sorry that's not going to be good. [@] You don't so much hear individual delays -- although this is not a perfect one -- as much as you just hear reverberation -- That is to say sound that's sticking around after the sound, like it would in a real room. [@] And the way you do it, not to put too fine a point on it, is you have bunches of delay lines reading and writing in a complicated network which you have to think hard about. [@] This is all explained in gory wonderful detail in the book why this thing works and why it's stable and how you would design it. [@] All I'm going to do is just sort of say this exists. [@] Go find out how to do it yourself, or if you just want reverb just say "reverb two" <> for instance, -- I'll give it a nice big nonsensical argument just to make the box big. [@] Now you get a nice reverberator with inputs to control various things about it. [@] And there is a nice help thing on there. [@] This is nice abstraction which I built just for making a reverberation in case you just want a reverberation. [@] It's there for you to use. [@] Rev1 is experimental and strange. [@] Rev3 is higher quality than rev2. There's a collection of three reverberators that you can choose from. [@] And get the help window and check them out if you want to find out how to use them. [@] And the theory is in the book; and I'm going to skip it because we have many other things to find out about. [@] We have many other things to deal with than this and it's now time to stop. [@] Next time I have to start talking about filters, which are the other point of view on delay lines where you in fact might find yourself designing delay lines with a specific frequency response in mind. [@] *** MUS171 #18 03 03 (Lecture 18) [@] So I'm going to use as my jumping off point the wonderful recirculating comb filter thing and start with one detail about Pd that you might want to know about. [@] So here's the sound. [@] This is the Karplus-Strong instrument. [@] Well, not exactly the Karplus-Strong -- This is noise going into a recirculating comb filter. [@] Now the thing that I want to do with this -- we've had enough delays now. [@] But what I want to do is use delays as a way of motivating filters. [@] Because indeed this is a filter you're hearing - There's white noise going in and there's this stuff coming out. [@] And that's by virtue of the fact that from one point of view, at least, the delay network that we are putting the white noise through is filtering it. [@] It has a different gain for different frequencies. [@] It doesn't have a flat frequency response. [@] It has a comb-shaped filter frequency response if you like, which is why we call this particular thing a comb filter. [@] The comb filter is the one filter that you can explain easily without having to say anything mathematical, or excessively mathematical. [@] The basic deal is that if you just put a single sample in here -- If you made a signal that was 0 except that it had one impulse of sample at one point, then you can imagine what would happen: [@] The impulse would come out and then the delay later would come out a little smaller, then the delay later again would come out of the smaller and is one, and you would have a sequence of impulses at a fixed length from each other and you would hear a pitch. [@] Or you could say what were the frequencies present in that sequence of pulses, and you would see that certain frequencies were present much, much more heavily than others were. [@] Or you can do what I'm doing here and just throw white noise at it, and notice that something quite different from when white noise comes out. [@] And two things that you can vary are the selectivity of the filter, that is to say there's no selectivity at all. [@] and here's total selectivity, and here's something in between, and also the delay time is now controlling the frequencies that the filter likes. [@] The trouble with this as a the thing is that it really only does that one thing -- that no matter what frequency you ask for it will let through that frequency and all of its multiples, thereby deserving the name comb filter. [@] But that's not everything that you can possible want a filter to do. [@] A very standard thing that you would like a filter to be able to do is simply attenuate higher frequencies but let lower frequencies through, or vice versa. [@] And this not a thing that you can use in any direct way to do that kind of thing. [@] So before I go on about how to use this way of thinking to design filters more in general, let me pop up one level and say I'm going to tell you a little about filter design but not the whole story. [@] If you look at the textbook, the longest chapter is about filter design because there are dozens of different kinds of filter designs -- or dozens of kinds of different filters that have different design methodologies. [@] And you would be studying for years if you want to study all of them and even just making a decent cross-section of this is a lot of work -- and basically more stuff than we could possibly crowd in the three days of classes that remain. [@] Even if we didn't want to mess with GEM and a couple of other things too next week, which is going to take precedence. [@] So, I'm not going to do the whole filter design yoga. [@] I'm just going to tell you how you think about it and also show you how to just use filters in case you don't want to get involved with the filter design yourself -- which might be most of you anyway. [@] So, there will be theory but there's also just going to be hand-waving, "here's how we do stuff" kinds of stuff that's less honest but more useful somehow. [@] So in preparation for that, first thing that I want to tell you is a little bit about Pd lore, which is the following thing. [@] I mentioned a week ago that as it turns out there's a maximum pitch you can possibly get out of this thing, which corresponds to the smallest delay -- the smallest recirculating delay -- that you can possibly get, which is 64 samples, which at 44.1 kilohertz is about 1.45 milliseconds, which corresponds to the 700 and something Hertz. [@] So the frequency -- the resonant frequency -- of this particular filter is one over the delay time. [@] The shorter the delay time, the higher the frequency, and 1.45 milliseconds corresponds to 700 cycles per second. [@] So that is an artificial constraint that is brought about by the fact that there's blocking. [@] In other words, this is a thing that's easy to say and parrot and it takes a little bit of thinking to understand it. [@] If everything is crunching samples and blocks, then this thing creates the read which has to happen before the write It doesn't look that way but this thing is reading delays before this thing is writing them because there are dark lines from here through there, but there are no dark line from here to there. [@] So the real order of operation is delay read, multiply, add an output, delay write. [@] The fact that you have to read a whole block of 64 samples, which by the way is only for run-time efficiency sake, dictates that if you're going to now read a bunch of stuff and then write it, you have to write it 64 samples into the future. [@] In other words, think of a block of 64 samples now we're going to compute some other stuff we have to compute. [@] We can't compute anything earlier than the next 64 samples than the one you just had computed when you read those. [@] And so you're going to have the minimum, a delay of 64 samples and if you want to scoop into your own past, which is what this network wants you to do. [@] Usually that's fine but in situations like this, sometimes you don't want that to be true. [@] And if you don't like this and you want to fix it, then you can do the following thing, which I hope to demonstrate right now and talk for some time: [@] You can maintain local control of block sizes by making sub-windows of patches and using a special object which is called block~ to set the block size of the sub-window. [@] So here, what we would do is we would say "object please." [@] Let's get ... I'm going to call it "small block." [@] This is now a sub patch and what I'm going to do is dump some of this stuff into this sub patch. [@] Let's do it this way. [@] Let's dump ... Let's just grab all this stuff. [@] Here's a receive, so I could put that in there. [@] But this should be an inlet. [@] We're going to make a sub patch here so let's do this. [@] And not good. ... [@] Cut ... Paste. [@] So here now is the recirculating part of the delay network. [@] I'm not sure if this is a good idea. [@] But now, to be clearer, I'm going to put it in the order that really will be sorted in, which is to say it has to read first, and then do its stuff, and then write. [@] The delay write is the object which formally at least doesn't have any output because its output is to write the thing into the delay line. [@] Like DAC~, the same kind of deal. [@] Now, we're going to want to hear the result so what I'll do is make there be an outlet – a signal style outlet which we'll use to hear the output of whatever this thing is. [@] And that by the way is going to create this outlet here on the containing object, and so now we're going to listen to this like this: [@] (And meanwhile there are two inputs that we need: The recirculation gain. [@] No, the delay time we had controlled out there, so the recirculation gain will be an inlet of the message type. [@] And that, right here, and then meanwhile we'll have a signal to add to it, which we already had, which will be an inlet~ which we're going to add to it like that. [@] It's better to do this. [@] So what I did was I put the inlets in order so the signal inlet is first and then the control inlet and I did that so that you would see a clear signal chain. [@] And then this control is going to go there. [@] Now, let's check if we actually have the same thing as we had before, maybe. [@] We still have the same problem; you can't get anywhere above whatever pitch that is. [@] And now, I'll go in here: [@] This is the sub patch, and say ... (This is why I put this all in a sub patch.) [@] So I'll say block. [@] And in fact, I'm going to be extreme today and say let's have a block size of 1. If you care, which you might not yet but you will someday, this a rule of thumb: [@] A typical amount of overhead for getting into and out of tilde objects in Pd or in other kind of block things is about 20 samples worth of crunch. [@] That depends on the objects. [@] So that's not a hard and fast rule. [@] A 64-sample block size means that you are paying for about 80 samples worth of computation per 64, and one sample block size means you're paying for maybe 20-ish samples instead of one. [@] So this thing only has about 120th of the complete efficiency of the surrounding patch. [@] This could be a good reason not to do this just for no reason at all. [@] But of course, if you want to do something like what I'm doing here, read something out of the delay line and then do something to it right back in, that might be something you want to do at a lower block size so that you can have a smaller delay in the loop. [@] And now, we can check whether that actually happened. [@] Student: So block's basically dictating how much power is going into that? [@] Or how much computing time? [@] Sort of. [@] So what it really is doing is, it's saying, every time Pd wants you to compute 64 samples -- or every time your parent window wants you to compute 64 samples to be totally accurate -- instead of computing all 64 samples in one block, you will compute 64 blocks of one sample each. [@] So what happens normally inside Pd is when you ask it to do something like this, then this, then this, it does 64 samples of this, followed by 64 samples of this, followed by 64 samples of that. [@] And you can see this using the print~ object. [@] Print~ will print out however many samples it does in one blocks' worth of computation. [@] That's where the 64 samples come from the print~ prints out for you. [@] If you say "block~ 1" , instead of doing 64 samples of this and 64 of that, and 64 of that, and so on, it will do one – 1 – 1 – 1 and it will go around the loop 64 times, which is a lot more work. [@] About 20 times as much work, but is nonetheless what you have to do if you wanted to make a very short recirculating delay line. [@] The shortest possible recirculating delay line you can have in digital land is 1 sample. [@] In other words, there's no possible way when you're reading this thing that you can read the current sample because it hasn't been written yet. [@] But you can read theoretically the very previous sample that got written here if the block size is as small as one. [@] Now having done that, we're going to close this. [@] Now that we've done that, then we get the ability to have hugely high pitches. [@] In fact, the highest pitch you can ask for, I think, is the sample rate. [@] Let's see if that's really true. [@] Well, the pitch is 1 over the delay. [@] And if the delay is one sample and the pitch is the sample rate. [@] What does it mean for the pitch to be at the sample rate? [@] It does not mean that there's a pitch in the sample rate because that frequency doesn't exist. [@] There aren't any frequencies above the Nyquist. [@] So if you like this nice comb filter and the comb filter has peaks at all multiples of the fixed frequency that you choose. [@] But if you make that frequency be the sample rate, then one tooth of the comb reaches all the way from 0 to Nyquist and the next tooth of the comb reaches from Nyquist up past the sample rate and doesn't exist. [@] So what we've done is we've taken a comb filter and turned it into a one lobe comb filter, or a one-tooth comb filter, if you like, because there's only one room for one tooth, whose center frequency, by the way, or frequencies DC, zero. [@] So the frequencies that a comb filter allows through are zero and then the resonant frequency, which is one over the delay time, and then twice the resonant frequency, and so on. [@] And all those frequencies there are above the Nyquist except for DC -- zero. [@] So now what we've created is not what I just told you. [@] So let's do it, let's turn this on and make the thing be as high as I can get it. [@] Before I do that, let's make this thing fatter so we can look at it. [@] So let's have an 8, a wide one. [@] Now say just go on up to the sample rate. [@] Actually, if it's higher than the sample rate, I know that there can't be a delay of less than one sample. [@] So it's going to be a one-sample delay we'll have so the resonant frequency will be the sample rate which doesn't exist. [@] Or isn't a proper frequency. [@] So now we have noise, but here's the original noise, and here's the comb-filtered noise. [@] So I told you the frequency where the good gain is at zero. [@] What that means is that we've designed ourselves a low-pass filter. [@] So, a low-pass filter in some sense is a special case, a weird- special case of a comb filter where you set the frequency of the comb filter to be the sample rate. [@] Actually 100 is not a good number to use because that's unstable. [@] Let's go down to 99 or so. [@] That's good. [@] Now, at this point, we could actually graph this but I don't want to be too pedantic about things. [@] But you could now analyze what would happen if we did something like put an impulse into this filter. [@] So an impulse would be a signal which has one sample that's non-zero followed by a bunch of zeros and preceded by a bunch of zeros, too. [@] So it's quiet for all time, except that some time there's maybe a unit sample, whose value is 1 with values in one of them, then silent again for all time. [@] This is a signal which you use just for a thought experiment to see what this filter does. [@] And what it does it very simple: [@] So here's the design again: Each sample, we take what was there in the previous sample, ... thinking about the first sample when the impulse comes in, out here is zero because the filter is sitting at zero, it's at rest. [@] In comes an impulse, that's to say there's one sample. [@] So there's one sample whose value is 1. So out goes 1, and by the way 1 gets written to the delay line. [@] 1 then comes out of here and it gets multiplied by 0.99 – what the thing is set to now. [@] So that says 0.99 so out goes 0.99, and it gets added to 0 because the impulse is over now. [@] So it's 1, .99, and then 0.99^2, and 0.99^3, and so on like that. [@] So it's a falling exponential. [@] Now that raises an interesting question. [@] First off, I haven't told you this but an impulse is not the same thing as white noise. [@] But an impulse, if you think about it in terms of frequency content has all frequencies present. [@] Why? Because from one point of view, what's a frequency it doesn't have >... or from another point of view it doesn't have any time duration so it can't have any one frequency louder than any other because it doesn't know what time is. -- [@] That's a hand-waving argument. [@] But it actually works if we you make it rigorous. [@] What comes out is this thing, which is sort of a lump, which has a duration which is longer or shorter, depending on how you set the coefficient of the filter. [@] In other words, if I set this to 0.99, it will take something like a hundred samples to drop off by a factor of e and if I set it to 0.98, by the way I'm using numbers close to one so that you see a nice good exponential. [@] So I say 0.98, then it takes 50 samples to drop off by a factor of e and so on like that. [@] A falling exponential always has the same shape, if you like, except that it's getting squashed or stretched out in frequency, depending on the coefficient. [@] And furthermore, if you think about that, the slower you play that exponential, that's to say, the closer you get the coefficient to 1, or the longer that so-called impulse response lasted, the more low frequencies you would have compared to high frequencies. [@] Because the slower you'd be playing the thing, the more lows you have -- Slow something down you get more lows. ( [@] That also is a hand-waving argument.) [@] So, in some sense, you shouldn't be surprised at the fact just from that description of what the impulse response is ... You shouldn't be surprised at the idea that as you push the gain toward one, the thing gradually loses its high frequencies or picks up low frequencies compared to high frequencies. [@] You could ask for a better one or you can also ask for other stuff. [@] But to talk about that, I have to talk about how we talk about filters a little bit. [@] So the trajectory so far has been I started with this recirculating comb filter and I showed you the block~ object it allows to have one that's just 1 sample. [@] And then I showed you that hey presto what we really have is a low-pass filter. [@] So let me now go to silly picture land and show you how I'm talking about these things. [@] Student: Can I ask a question? [@] Yeah. [@] Student: So I think it's now easy for me in my experiences with filters, they always seem to be things that add or subtract to the signal, like to any one sample in place. I don't know quite how to describe it, but what you're showing is takes what happens in one sample and then seems to add information to the subsequent samples because it's got a delay. Is that the way that all filters work? [@] It is. [@] Student: So it's actually ... when you filter something, you can low pass filter something you're actually ... You're making it last longer. [@] Yep. In some sense. [@] In other words, if you had a very, very short sound or utterance, and put it through a filter almost of any sort, you end up with something longer than you started with. [@] An extreme example is if you've messed around with an analog synth -- Try putting something impulsive into a band pass filter and set the Q way up. ( [@] I'll tell you guys about what that stuff is later.) [@] And then you can hear it ring, so you can put in just an impulse, and out comes Ping! Like that, and you can make it last longer, depending on how high you set the Q. [@] The thing resonates -- rings. [@] And filters in general are things that ring or sit there, whatever you call it. [@] Usually, for most reasonable settings of the filter, what it does –- the impulse response of the filter is short enough and time it that it doesn't become a factor. [@] But you can set yourself up in situations where it indeed is a factor. [@] I can show you an example of that maybe later on. [@] With luck. [@] So here's just how one talks about filters. [@] And this is just terminology. [@] I haven't shown you actually how to make it into stuff except for that low-pass filter, but I haven't even really analyzed that in depth, yet. [@] But these are just sort of qualitative terms that sometimes have units on them. [@] But here's what a low-pass filter is, as you describe it to an audio engineer. [@] Usually what you say is there is a particular ... So going to the store and buy a filter ... They'll say, "What cut-off frequency do you want?" [@] That is an oversimplification of what a filter really is because no physical filter ever will allow some frequencies through, and then completely block out other frequencies, and just basically have just one frequency, which is a cut-off frequency. [@] But there really is, in most people's way of describing it, a range over which a filter gets from its pass band to its stop band. [@] So the bands are just ranges of frequencies. [@] That is old fashioned radio talk. [@] And so a low-pass filter is the one that has a pass-band and a stop-band, and then there's a transition band, which is where you don't know what the filter is doing. [@] It is somewhere between the two. [@] And then you can talk about the quality of the filter in terms of ... "Give me a filter and I want the transition band to be real skinny," or ... "I want the" ... other terms ... "ripple" ..." You want the thing to ideally have an absolutely flat frequency response in the pass-band, but it doesn't ever really in practice. [@] It always goes up and down. [@] Anything that goes up and down, if you're an economist or an engineer looking at a function and it has maxima and a minima, you call it "ripple." [@] Or sometimes you call it cycles, even if it's not. [@] So engineers will call this "ripple." [@] It's just the fact that in any real filter, the frequency response will go up and down slightly, at least slightly, before it starts heading out in the transition band. [@] And then in the stop band you can say "What is the stop band attenuation?" [@] That is to say this isn't ripple anymore, this is just stuff that still gets through in the stop-band; it isn't called "ripple." [@] You don't care about there being a flat frequency response there; you just care for it to be gone. [@] And so all you care about is what's the maximum value here compared to the value here, whatever you call that. [@] So there's a stop band attenuation. [@] And these things are all trading off against each other and off the complexity of the filter. [@] You don't want to have arbitrarily complex filters, partly because they will ring forever. [@] The amount of time the filter rings very roughly speaking is 1 over the transition bandwidth. [@] So if you want a very clean transition band to have a very ringy filter. [@] So you will typically trade, you will care more about this and less about that. [@] Or maybe you will care a whole lot about this like if you're designing a low-pass filter for a digital to analog converter, you will care about having a nice flat frequency response there. [@] Or you might care about having this thing very low. [@] Or not, depending on what you need. [@] So you make those things part of the specification of your filter and some poor engineer runs off and ... well, actually cranks up some piece of code that designs a nice filter that does this for you. [@] And hopefully it's a decently simple filter and not a complicated one. [@] Not so much because you care about the computation time, but because you care about things like numerical accuracy, which tends to be more difficult to control as the filter gets more complicated. [@] So there's language -- which one uses to talk about low-pass, and in fact high-pass filters. [@] A high-pass filter is the same thing as this, except that the pass band is up here and the stop band is down there. [@] And other stuff: Next. How to talk about band-pass filters: [@] Here's a picture of what you might think of as a band-pass filter specification. [@] So there you have two different stop-bands. [@] You want it to stop stuff below and above the region you're interested in. [@] There's, of course, because in reality we have transition band -- which we don't know about -- That's where the filters get in from the stop to the pass-band. [@] And then there's ripple again. [@] So a band-pass filter is like a low or high-pass filter, except that the pass-band has both a low and a high frequency cut-off. [@] And it's correspondingly harder to design. [@] And a stop-band is the same as the pass band, except that there is a stop-band in the middle and there are pass-bands on the outside. [@] And then you call it a "stop band," or sometimes a "notch filter." [@] Student: So essentially graphic equalizers and the bunch of band-pass? [@] It's worse. [@] Graphic equalizers, you want them to be absolutely flat when you have all the sliders in the middle. [@] You will never be able to design these so that you can add them up and get exactly flat, and say end up designing a completely different class of filters to use in an equalizer, which I will show you in a second. [@] So that's terminology for that. [@] And now, the stupid terminology for band-pass, this is if you buy an analog synthesizer, you don't talk about the pass-band any more. [@] What you talk about is the "center frequency," which is the middle of the pass-band and the pass-band itself is kind of ugly. [@] I mean you could describe this filter in terms of two transition regions and all the rest of it, but you don't. [@] What you really describe a simple band-pass filter as is as having a center frequency and a bandwidth. [@] So the band is just the part of it where you think the thing is allowing the signal through, and the band width, in this kind of a filter, typically is measured by saying, "Find the peak and then choose some arbitrary number, which is usually three." [@] Then you say, "go to the right until the thing drops three decibels. " [@] "Now go to the left" ... sorry, whatever the left or right are ... "Then go the other way until it drops three decibels." [@] And then you will see a region of the thing which is characterized by the fact that it's within three decibels of its peak. [@] And that's a way of just talking about bandwidth of a filter, if no one has specified a ripple value or what-not. [@] And so then, basically, for describing a filter like that, it's adequate to describe just the center frequency and bandwidth. [@] And sometimes people call this the "3 dB bandwidth" to say that we chose that arbitrary number 3 to talk about it. [@] There's another knob that you get on a synth, which is called a Q – which stands for "Quality." [@] And the Q of a filter is a thing which is designed so that as you increase the value of Q, the filter itself gets sharper. [@] I can't tell you in any very simple way why that would be a measured, the quality of the filter, so don't worry about that. [@] The quality is then defined so it should go up as the bandwidth goes down and the textbook definition of the Q of the filter is it's the center frequency divided by the bandwidth. [@] And that's a good unit to use because if you're designing -- for instance for analog synthesizer or another kind of application like that -- if you're designing a filter, that you would want to change the center of frequency of, it might actually be a good thing for the bandwidth to be maintained as a fraction of the center frequency, instead of being maintained as a constant. [@] You could imagine them both, you could imagine a filter that sweeps the bandwidth, stays the same. [@] But then if you think about it, that filter would sound more selective if you tuned it up into high frequencies than in the low. [@] If the bandwidth is 15 Hertz, and if you say that the center frequency of a 100, that's a very fat filter but if the bandwidth is 50 and you say the center frequency is going to be a thousand, then 50/1000 is a very small variation, and then you hear it is a very sharp pitch. [@] To put that another way, if you wanted a filter whose bandwidth was one half-tone ... That would be a reasonable thing to ask for if that would be a filter that was sharp enough that you would hear as a pitch basically, to a pair of Western ears. [@] So if you want the filter to sound like middle C, you'd like its 3 dB points to be halfway from C to C-sharp, and halfway from C down to B. [@] That would be a C filter. [@] That turns out to be a Q of 17. That's to say a half-tone is a 6% increase in frequency or change in frequency. [@] And 1/6% is about 17. So middle C over whatever middle C has to change by when you get to the next one over is about 17. And that's true if you chose middle C or any other pitch on the piano. [@] It's always going to be true that proportionally to one part in 17 gets you to the cracks between you and the next two keys. [@] So Q = 17 is a one half-tone wide filter. [@] So if you make the controls on your filter be center frequency Q just what the synth manufacturers typically do, then it's good you can set the thing to a higher or lower center frequency that has the same perceived width, which is the width as a percentage of the center frequency. [@] Another example of a useful value of Q is what if you set the filter to be about a critical bandwidth, or a critical band wide? [@] "Critical bands" are these psychoacoustic things, which are typified roughly ... They're things you learned about in Music 170 that I don't want to try to explain because then you'd be talking psychoacoustics and then you'd get into arguments because no one can really make measurements about psychoacoustics. ... [@] But a critical band is roughly a third of an octave. [@] And the reason you see all these third-octave filter banks and, by the way, if you go buy an equalizer, then it will be third-octave, right? [@] That third-octave is the critical band. [@] A third of an octave is, again, a number of half-tones, four half-tones. [@] And so that corresponds to a Q of something like four-ish. [@] So a Q of four is about a third of an octave -- Still, no matter the center frequency you choose. [@] So those are reasonable values of Q. [@] Having told you all that, that's all I want to, tell you about taxonomy of filters. [@] I'm going to tell you one other thing, which is to answer your question better about equalizers: [@] There are other filters running aroud besides low-pass and bandpass, which are filters where you specify not that it be 1 in the good part and 0 in the bad part, but that it simply have a higher gain in one frequency range than in another. [@] The simplest of these is called a "shelving filter." [@] For a shelving filter, you say, "what's going to be the frequency at which it transits the transitions?" [@] It's "transition frequency." [@] And then you say, "What do you want the gain to be at low frequencies? [@] What do you want the gain to be at higher frequencies? [@] And roughly what frequency does it make its transition between the two?" [@] And if you have one of those, then you've got something you can use to boost or cut the bass or to boost or cut the treble, depending on where you set the transition frequency. [@] So those are things like the treble and bass controls on old fashioned stereo amplifiers -- maybe they still make those. [@] Or the low and high shelving filters on your equalizers. -- [@] whether the equalizer, by the way, is a parametric one or a graphic one. [@] Then you need all the filters in between. [@] To do that, you have an out of band gain and an in band gain. [@] So that if you set the in band and out of band gains both to be 1, then the filter will be nothing for you. [@] But then you ask i6 "Make the out of band always be 1," which is an appropriate thing to do, but "Make the in band gain be +5 decibels" or "-5 decibels" -- which would mean push or attenuate this particular frequency band. [@] And there the things you would specify would be "where's the center frequency>" and "what's the bandwidth?" [@] which is to say "over what range of frequencies are we going to push it up or down?" [@] And those are things that you've all seen because they're on any parametric equalizer. [@] That's not the same thing as the band-pass filter on your synthesizer. [@] So for some reasons, synthesizer manufacturers love the band-pass filters whereas mixer manufacturers love the shelving and peaking filters. [@] This is called a "peaking filter" because it makes you a peak. [@] They call them "peaking" filters, that's the word. [@] The typical mixer thing is you've got a shelving filter for the highs and shelving filter for the lows and two usually peaking filters for pushing or pulling away from some frequency range in the middle. -- [@] So that's how people talk about filters. [@] Student: Do these also work with delays? [@] Yeah. So all of these things are things that in digital land -- in analog there's a whole different way of thinking about them -- but in digital land these are things that are made with delay networks, in which the delay time is always one sample. [@] And as a result, they're horribly inefficient to make as patches because you have to set the block size down to 1. So the only time that you make one of these in a patch is if you needed some special weird nonlinear filter thing that you couldn't build out of the building blocks that you already have that someone else coded up in C for you – Which you can do, and which I have done ... I had to do just last Fall one time. [@] But usually, you can get by with the filters that pre-exist. [@] And usually, of course, the reason that people code of these filters up is because it's horribly inefficient to make patches that make these filters -- because of the block size. [@] Now the next reason you don't do these things themselves is because the math gets genuinely complicated to make these things. [@] The basic deal about making low-pass, high-pass, and band-pass, and peaking and shelving filters is not so bad. [@] And Chapter 8, goes a certain distance into that. [@] But then when you start getting into" make it just so" kinds of things, then pages and pages of math or huge software packages to do the design. [@] So I want to give you some idea of the theoretical framework in which that is done, but not really go down that even as far as Chapter 8 does, for the lack of adequate time. [@] What I'm going to do is I'm going to haul out some existing filters from Pd to show you what they do and then I'll try to go back and explain what's happening on the inside. [@] So what we'll do is we'll trace our steps backwards because what I did to start today off was I started with the comb filter and showed you how to make the simplest possible low-pass filter out of it. [@] Now what I want to do is just grab some filters and start seeing what they do, and then try to justify how you would build them by how they act. [@] And then I will show you some actual math in the complex plane, and then you will all fall asleep, and then I will see you again next Tuesday. [@] Let's see if we can do this. [@] Filters: ... So we're now going to say patch #4. <> [@] So I'll just get some filters out. [@] And maybe it's just as well to have .. this is just an all-purpose input generator thing; we'll leave that and we'll just start messing with filters and see what they do. ( [@] I have to get rid of this, and I'm going to get rid of "pd small-block" ... And I'm just going to start hauling some of these out. [@] So there's nice low-pass filter. [@] Let's get ourselves something just to hear the original sound, in case I will need to A/B it. [@] We got that going; so we've got white noise; good. [@] So the low-pass filter... [@] you can get an argument which is the cut-off frequency in Hertz. [@] Or, what's maybe better here is ... we'll get one of these things. [@] Let's get this thing. [@] So to prevent confusion now, I'm going to get rid of this. [@] And now we just have low-pass filter. [@] And while we're at it, let's get two more of these. [@] How's that? [@] So then we'll get a nice simple high-pass filter and a nice band-pass filter. [@] Band-pass filter, as I mentioned, has two things that you might want to control, which is the center frequency and a Q. [@] "Q" for quality. [@] And so what I'm going to do is get a nice thing that I will constrain to be positive ... and have that be the quality. [@] There's that: [white noise] Low-pass: This is what I showed you before. [@] There's noise. [@] And now we turn the cut-off frequency down and you hear a drop off in the highs. [@] This is not exactly the filter I built you before because it's normalized differently. [@] This one is normalized so that it has unit gain at zero frequency, or DC. [@] Whereas the thing that I showed you before, the recirculating comb filter, it might have a very nice high gain at DC (Imagine feeding that thing all 1's, but if it has 0.99 feedback, what's going to come out is much larger than one. [@] I think it will be a 100.) So you could divide by that number that it would put out. [@] And then you would get something that puts out the same amount of DC as you put in. [@] But of course it puts out less of everything else, because it's a low-pass filter. [@] So then you get that effect. [sound of white noise through low-pass filter] [@] A thing about this which I will go into a little bit more later maybe, is that this is a control, that's to say a message, input. [@] And so I wouldn't be able to take a nice line~ until kind of envelope generator and throw it in there and get the right output. [@] To do that, you'd have to go somewhere else, get a different filter. [@] But these are optimized to be computationally very inexpensive and simple. [@] This one is the high-pass filter whose job is to do the opposite. [@] So the higher you push this, the less low frequency stuff you have. [@] It's not general true but in this particular case it is true that the high-pass is exactly what you would get if you subtracted the low-pass from the original signal. [@] Actually, there's a numerical accuracy issue that I'm covering up. -- [@] You wouldn't actually be informed of it that way for numerical reasons but in fact conceptually this is just input minus that. [@] That is no longer true when you get to any more interesting filter than just this very simplest one. [@] Band-pass filter: [@] This is the one that you buy on your synthesizer. [@] You decide a value of Q. [@] So the number 17 came up ... so I'll say "Set your Q to 17 please and the center frequency of 69." And then we hear A. [@] I hope that's A. [@] Anyway, if I push this up or down, you just get pitches out. [@] So a Q of 17 is half-step wide. [@] A nice sharp filter might be a Q of a hundred. [@] That's asking right now the ... let's see ... go back to 69, which is A so if the center frequency is 440 and the Q is 100, that's to say that the bandwidth is 4.4 Hertz. [@] The bandwidth being 4.4 Hertz you can also think of as the fact that there is a ... (You can hear that the thing's changing; it's not a sinusoid. [@] It's tumbling or fluctuating. [@] The speed of fluctuation of this amplitude is roughly 4.4 Hertz. [@] That's to say it's roughly the bandwidth of the filter.) [@] So if you don't want the thing to sound like it's fluctuating, you would send this Q up to something much higher. [@] But, of course, the less stuff you let through, the less power you will hear if you put white noise or something like that in. [@] So now, why don't we just take this and multiply it by 791 so that you will pick back up the gain that we lost? [@] Watch yourself when you're doing this, but let's turn this down first. [@] Now let me show you how to normalize this nicely for white noise. [@] Actually, there are several ways you could think of to do this. [@] What I'm going to do is, I'm going to take this number, and add one to it, and then multiply that by the filtered sound. [@] Let's start with a Q of 1 so that nothing silly happens. [@] Right: Q of 1. It's basically an octave wide. [@] So in other words, if the center of frequency is 440, so is the bandwidth, and so it reaches from 220 to maybe maybe 660. I told you a quarter-octave here is about a critical band's worth of noise. [@] Now we're kind of in kind of Frank Zappa "Nanook of the North" land ... Here's the half-tone filter: [@] -- And here's the very sharp filter: -- This is super sharp: And now we're making pitches out of noise. [@] While we're here ... notice that this sucker rings ... In fact, I have told you how to make an impulse, have I? [@] What's a good way to make an impulse? [@] Student: Couldn't you just use tabread~ and an array? [@] Oh! -- That's probably better than what I was going to do. [@] Let's do that. [@] Let's make ourselves a nice impulse. [@] So we're going to make ourselves a nice table.... [@] I'm going to save some time and say "table" and give it a name and a size. [@] I don't know... << [@] table foo 10 >> And then I'm going to say a message: [@] " semicolon foo start at location 0 and we're going to be 1 and then all 0's". There's an impulse: It doesn't look like an impulse because it's drawn using segments instead of lines; but the first number is 1 and the rest of the numbers are 0. And then we can say "tabplay~" -- This is the simplest, stupidest possible way to play a table back. [@] This one you just bang it and out comes the table. [@] And then you have an impulse generator. Cool. [@] Now let's stick this in my little adder so that we can see what it does to these various filters. [@] Here it is: [@] So now the center frequency of the filter is just the frequency that we hear. [@] And furthermore, this Q or "quality" of the filter ... (Oh, that was a thousand... [@] Sorry -- you can't see that.) [@] I'll make it a hundred now. [sound] Or I'll make it 17, which is the half-tone filter.[sound] This controls directly the length of ringing of the filter. [@] In fact, you can quantify that: [@] In another way of thinking, the Q describes the number of times the filter rings before it drops down to a factor of the e in and amplitude. [@] Why e? Just because life's that way. [@] So that means, by the way, that the higher the frequency I give the filter, the shorter the ringing will be, because it rings a certain number of cycles. [@] It will ring now a thousand cycles as opposed to a thousand milliseconds or something. [@] So the higher one -- a the thousand cycles up there doesn't last as long as the thousand cycles down here say. [@] So Q is the length of ringing of the filters in cycles. [@] Or Q is the frequency divided by the bandwidth ... Frequency divided by bandwidth, which is the sharpness. [@] So Q is also like the width of the peak? [@] So the higher the Q is the narrow the peak is. [@] Q is the "narrowness" of the peak. [@] But it's the narrowness of the peak compared to the center of frequency. [@] So if you push the center of frequency out, the peak will get fatter, too, for a fixed Q. ... [@] And now that I've told you this, you know almost exactly how to build this band-pass filter: [@] Because all you would have to do is arrange to make some kind of a delay network that rings sinusoidally -- when you hit it with an impulse. [@] And then you have a band-pass filter because you have what I have here, which is a band-pass filter. [@] That's not very good mathematics. ... [@] Another way of thinking about filters: [@] filters are resonant bodies. [@] They're masses on springs. [@] If you like, they're bodies of air inside resonating bodies, which have resonant frequencies like Helmholtz resonators do, or whatever you might wish to make resonate. [@] You can think of them as masses on springs. [@] So to make a mass on a spring, you would make something that when you hit it, acts like a sinusoid that's damped. [@] And now I can tell you why they call it "quality." [@] If you think of it as a mass on a spring ... as I've told you, the lower the Q is the faster the thing is damped; or the higher the Q is, the longer it vibrates. [@] The quality is in fact the percentage of the energy of the filter it maintains all over a cycle, or is related to that -- It's not equal to that but it goes up with that. [@] In other words, the leakier the filter is, the more resistance you have in the thing and the more damped it is: [@] The lower the "quality" that it circulates in some sense. [@] That's why it's Q. [@] So how do you build this? [@] Well, remember I was telling you about complex numbers last time. [@] You were hoping we wouldn't get into that... [@] How would you make something act like a sinusoid? [@] I told you that sinusoid is nothing but something that's getting multiplied by a constant. [@] But because the constant is a complex number that's on the unit circle, say, the thing is going around a circle, instead of dropping towards zero. [@] The low-pass filter that I showed you that was the comb filter that had a delay of 1, the trick was you took whatever the previous sample was and multiplied it by 0.99 say, and put it back in. [@] And that gives you a very nice low-pass filter; it gives you a thing which when you give it an impulse, give you an exponentially dying response. [@] If instead of multiplying it by a real number, like 0.99, you multiplied it by a complex number, that had a modulus or an amplitude or absolute values slightly less than 1, but also had an angle to it so that it wasn't real, then every time you multiplied it in, it would continue to spiral around the origin. [@] And in fact would spiral into it, assuming that you made the gain, that's to say the absolute value of complex number, less than 1 -- Which you really ought to do; otherwise it would be unstable. [@] So if you wanted the filter to ring forever, that's the easy thing to design: [@] You just choose any complex number on the unit circle and just multiply the previous sample by that, and by gum, they will just go around the unit circle forever. [@] In fact, that's so good that you can use that for an oscillator. [@] And Max Matthews spent a year building oscillators out of this concept ... it was really cool. [@] So here's how you do it: [@] (So this is the menagerie. [@] Let's lose that, and I'll open the previous patch again, and I'll save it as number five, delay circulating complex. <> [@] (I have to do it again, I'm sorry. ... Did I lose everything? [@] So let's close this. [@] What I'll do is I'll make a nice subpatch; then I will put the delay recirculating hoohah into this subpatch like this. [@] And then I'll clean it up like this. [@] We're being sloppy and unfortunate here ...) And then I had a nice inlet~ ... And that was going to get added to it ... that changes now. [@] And then we have an outlet that allowed us to listen to it. [@] Here we're going to put this stuff in here. [@] And then we're going to listen to the output, like this. [@] There it is; there, roughly speaking, is what we had before. [@] Now what we're going to do is we're going to take this thing and, instead of multiplying it by real number, we'll multiply this by a complex number. ( [@] This is Algebra 2 or maybe pre-Calculus.) [@] So complex numbers have a real part and an imaginary part. [@] So let's say "delay-real". I'm going to tell it to write a delay time of zero. ... [@] the delread~ should say something, I'll say have 1 millisecond. [@] But I didn't give it anything to the delread~ -- There's no input there, which means "Read the shortest possible delay that you can read, which is one sample." [@] Oh! That's assuming I remember to do this: [@] "block~1" Now, we'll do the same thing for the imaginary part. [@] We'll have a nice delay for it. [@] So what that means is we'll do another delread~ and another delwrite~. It will fill the whole screen very soon here... [@] And this will be the imaginary part. [@] Same thing with the delwrite~ ... And I'll say, "You have a millisecond too, but we'll only use one sample's worth." [@] So we'll eventually take the inlet and add it to this. [@] But the multiplication step is going to be interesting: [@] So to multiply complex numbers ... So first off, we do an inlet to have the complex number come in. [@] And that inlet is going to have two components. [@] So let's just say inlet here and inlet there. ( [@] Those could be signals or they could be control values. [@] I'll just say control for right now.) [@] And now, to do a complex multiply, you multiply the real part by the real part. [@] And you multiply the imaginary part by the imaginary part. [@] And what do you do to these two numbers? [@] Does anyone remember? [@] -- You add them backwards: [@] You subtract them. [@] The reason you subtract them is because i X i should be -1 -- because that's what it is, -1. So you take the real times the real minus the imaginary times the imaginary -- and that's the real part of the product. [@] The imaginary part of the product -- ... (See I've done this a few times, I know what I'm going to have to do ...) is you take the real part of one of them, and the imaginary part of the other -- that's imaginary. [@] And you also take the imaginary part of one and the real part of the other -- and that's imaginary. [@] And by the way, if I didn't do this exactly right, this is going to go unstable and blow up. [@] So don't make a mistake when you're doing this. [@] Actually I should say it differently: [@] "Turn the volume down when you make networks like this -- until you really believe they work." [@] We're going to say "save." ... [@] And, since Cooper was kind enough to introduce the expr object, I'm going to use an expression to compute what the complex number is going to be. [@] What I want to do is specify an angle and a magnitude. [@] So, just for talking, I'll call the magnitude "R" and the angle "theta." [@] So the real part of the complex numbers is going to be R cosine theta. [@] So "f1" the first one will be R, and the second one will be theta. [@] And then the imaginary part of this complex number will be R sine theta. [@] And what's R going to be? [@] R can be anything that you want, except that it sure better be less than 1. So I'm going to do one of these things, and I'm going to restrict this to only go up to 100 -- We'll allow ourselves to actually have the thing right on the unit circle. [@] That's R. [@] Now theta should be the frequency ... So how do you figure out what theta is, the angle of the thing? [@] A simple way of thinking is: [@] the sample rate means go all the way around the circle every sample, so that you stay in one place. [@] So you take the frequency that you want, and if the frequency were the sample rate you would want 2 pi, which is all the way around. [@] So you take the frequency and multiply by (2 pi divided by the sample rate.) [@] And I will just do that without saying much about it. [@] I'm too lazy to compute 2 pi to more than 4 places in my head. ... [@] Then we'll divide by 44,100 which is our sample rate. [@] And that will now be theta. ( [@] By the way it would be good to see this just to make sure we're doing it right.) [@] And furthermore, it would be nice if we change this that we recompute both the expr's so we should use a trigger to tell the expr's to recompute when they get these. [@] And furthermore, it would be really good now to look at those numbers. [@] There's the real part. [@] And here's the imaginary part. [@] So what I've done in very simple terms is ... Let's turn this off, choose a gain of 1/2 to start with ... -- I've made something that does ... nothing ?! [@] What did I do wrong? [@] Student: You're sending that trigger output instead of the expr ... [@] Thank you. [@] Hoo-hoo, boy! Dig! There are people who are not asleep yet. [laughter] [@] And is it working? [@] It sort of looks like it's ... Right -- this is good. [@] So now, if I tell it: [@] "Your frequency's close to 0," basically the real part is the 1/2. I've made the magnitude 1/2 so that it wouldn't blow up for now. [@] And I'm just seeing if we go around the unit circle decently well. [@] So for frequency 0, we should see a real part of 1/2 and an imaginary part of nothing. [@] If I tell it "Nyquist" it should go halfway around the circle and be -.50 . Oh where's Nyquist? [@] -- Nyquist is go down here and say 22050. And a half of Nyquist is pure imaginary. ( [@] That's a small number which wasn't 0. So it said "+" because it couldn't write it out in exponential notation. [@] That's kind of bad ...) ... So, anyway, basically as I start increasing the frequency, it starts wending its way around the circle with radius 1/2. And now if we listen to that: [@] Let's put noise through it -- Less than convincing, huh? [@] But of course this is a high value of Q ... So push it close to the unit circle now -- and we've got a band-pass filter! [@] Now that was a hand-wavy kind of band-pass filter design job. [@] But the punch line is: [@] The center frequency of the band-pass filter is nothing but the angle, or "argument", of a complex number that you use to multiply inside the looping comb filter. [@] As a result of which, if I gave this an impulse ... Where did I put my impulse? [@] That was in that previous window ... Let's "save as". ... So let me go back and grab the impulse generator. ... [@] I'm too lazy to make that again ... If I put an impulse into this you would hear the thing ring -- You would have to because in fact I designed it to be something that rings when you send an impulse into it. [@] I designed this band-pass filter basically by imitating the behavior of the band-pass filter that we observed when we just put an impulse in it. -- [@] And that behavior was that it rang. [@] So here's a thing that rings and when we put noise in then ... This recirculation gain controls how long it rings; And furthermore, let's turn this off for a second... [@] Let's send the recirculating gain all the way up to 1. Careful now ... I'll just put in a little noise and then stop it -- And tada! We now you now have a nice oscillator -- which is ringing 40 Hertz but I could change that now if I wanted to. [@] And throwing white noise in just how loud it gets ... [@] It hates me for some reason. [@] Something's wrong. [@] Something's not working real-time. [@] I'm abusing it in some way here, probably with the recirculation. [@] So there is a recirculating gain that's flat on. [@] That's to say the Q of infinity. [@] Or if I want to make the recirculating gain less than one ... maybe .99 ... That's not close enough to 1 to let you hear it ring, is it? [@] .. But if made it real close to one – Let's make it 99.99 – Now I've got this: [@] It's a nice, very high Q, (It's a Q of 10,000, I think. ) -- [@] a high Q resonating band-pass filter, also known as an oscillator. [@] Of sorts. [@] That's the basic yoga of designing filters. ... [@] What questions do you have about this just right now? [@] I should show you the internals again ... [@] Student: If you make the delay to small will the system crash? [@] It will make it the smallest delay it can pull off, which is 1 sample. [@] Or actually it's 1 block and since I've set the block size to 1 sample, in this case it's 1 sample. ... [@] Well, it's 1 sample so it's 22 microseconds. [@] That's one way to think of it. [@] You wouldn't be able to get the computer's audio latency down that low at all. [@] A typical computer audio latency might be 10 milliseconds or something. ... [@] It just wouldn't be able to do it -- I mean, where's it going to get its number; there's no place to look. [@] So either it does nothing, or else it does something arbitrary -- which could be crash, I don't know. [@] The typical design style of Pd is if you ask it for something out of bounds, it just gives you the thing within bounds which is closest to what you asked for. [@] So what's happening here is we have a complex number, which we're representing as the real and imaginary part -- as separate real numbers. [@] So we're using two delay lines to manage that pair of numbers which are the two axes or two "coordinates" of a complex number if you like. [@] And each time through the delay -- every sample -- what we do is of course we add the inlet~ in and we add it as if it were a real number -- which is to say we add it only to the real part. [@] And meanwhile, we take the previous sample and multiply it by a complex number, which is coming in these two inlets. [@] So this is a complex multiplication here. [@] And that number that's coming in, we wanted to specify in polar co-ordinates -- that is to say specify as an absolute value and an "argument" or angle. [@] Student: Why is the outlet only connected to the real part? [@] In other words, why are we only listening to the real part? [@] That's a real good question. [@] We can listen to that, or the imaginary part. [@] A trouble with this whole discussion is that I've been pretending that you can listen to complex valued signals – which, of course, there's no way you can do -- because air pressure is a real number. [@] But you could, if you wanted to, just listen to the imaginary part of it as if it were a real number. [@] And you would get, as it turns out, you would get a slightly different filter, for technical reasons. [@] It's not hugely different. ... [@] So instead of getting this; let's make some reasonable number ... So there is the real part and here is the imaginary part: [@] It turns out that the real part has all the highs in it and the imaginary part doesn't. [@] To put it another way, this is a band-pass filter and this is a low-pass filter, but they're both resonant. [@] So you actually most of what the old Moog VCF gave you. [@] Student: Can we hear what the low-pass filter sounds like on the complex side? [@] ... Yeah. [@] Now let's see. [@] So here's this ... not really different ... yeah, kind of different. [@] So that's the true band-pass there, I think. [@] I'm sorry, this is low-pass, this is true band-pass. [@] Student: Can we hear it sweep? [@] The frequency? [@] Oh, this thing, right? [@] As opposed to this. [@] That's interesting. [@] The high frequencies are getting masked up there. [@] Sounds like they're losing energy. [@] But I don't think they are really. [@] Student: Can we hear them both together? [@] ... Yeah ... I don't know what that would give you but ... Of course maybe it's a little louder ... it's just something in between. [@] So I'll grab the picture of the complex plane next time and show you what this looks like in a complex plane in slightly more detail. [@] And then we'll just get off into applications of filters. ... [@] So that's it for today. [@] *** MUS171 #19 03 08 (Lecture 19) [@] Someone asked a really cogent question, which is grading weighting: [@] What's the weight of the final versus all the homeworks. [@] And the answer is the final is worth two homeworks. [@] So out of 100%, the homeworks are all 10% and the final is 20%. [@] The grading, whatever you call it, is the way it will be graded is the same as your homeworks, except that of course you will only have something like three minutes per person to look at the finals, assuming that there are 53 of you, which is how many people were signed up last I saw. [@] Although all I see now 10? [laughs] But of course it's only three minutes after the beginning of the hour, so people will wander in. [@] So I think what we're going to do is set up some kind of a tag team thing where we'll set up a couple of tables and allow someone to be presenting while someone else is fumbling with their laptop. [@] And I'll ask this again later, but if you have a patch but don't have a laptop, then you'll want to use a laptop that I'll provide. [@] But all of my laptops are running screwy OSs, so we're going to have to work on that, I'm not sure. [@] Maybe Joe's got a laptop that's got a normal OS that you guys know about. [@] Oh you do. [@] We might hit Joe didn't show up. [@] The other Joe -- grown-up Joe. [@] I want to do one thing to finish off filters, although it being only one thing doesn't make it necessarily short. [@] I'm not sure how it's going to work. [@] The first thing is an observation, which is that you can put delays on things. [@] So filters are made out of delays. [@] So I'm going to make observation number one just using delays, so you can see and hear it with long delays -- that's to say audible ones. [@] And then I'll go back and show you how it spins out with filters proper. [@] And then I will drag all of you to complex plane again one more time just to show you how this spins out in calculations, which you can actually calculate the frequency response of any filter in the world. [@] Maybe. [@] So the main observation I want to make is this: [@] I'll make the recirculating delay loop, which is cool, and then I'll show you how to make the delays go away again. [@] I didn't actually realize this worked until last year. (... [@] Wait, I don't want to do this.) [@] So what we're going to do is we're going to take a signal to add a delay to it. [@] OK, signal. [@] Let's see. [@] Let's just do the microphone for now. [@] So do we have a microphone going? [@] Microphone, so that we can do things like have the delays now. [@] Is that amplifying, still? [@] Because it shouldn't be. [@] OK, that's me not knowing how to deal with my mixer. [@] So anyway, I can drown it out by doing this: [@] So microphone. [@] Now, what I'm going to do is make a nice delay just like you've seen before. [@] So what that is, is you say delwrite~ -- I'm just going to call it delay 1 <<"del1">>. And we can give this a nice long time because we'll maybe want to set the time that we read it from. [@] And then we'll have a delread~ Snd we'll give it a nice delay time that we can hear, like a fifth of a second. [@] And I want this thing to have a gain maybe of less than one, so I'm going to say... [@] (Sorry. I'm just realizing ... Ah, it's all right...) [@] OK, so I'm going to multiply it by some gain, and that's going to be a control. [@] So I'll put down a nice number box. [@] It might be good to have it in hundredths. [@] So I'm going to say "divide by a hundred." [@] That will be the gain of that, and we'll listen to it to see how it all works. OK? [@] So now if this network does what I think it does, we'll hear me and then --It doesn't do anything?! [@] Oh, Duh: <> Here's the echo, and the echo has a volume that I can control. [@] Let's do something reasonable. That's all right. [@] Just set this to 0. "Hello" -- Back to normal. [@] So delay line. [@] Now, how would you make this delay go away? [@] Now why would you want this delay go away -- To make a point. [@] The point is some delay networks have inverses. [@] That means that some filters have inverses because filters are delay networks. [@] So I want toshow you how to invert a filter. [@] And this is good because ... and there's a reason this is good ... Oh! -- Because it turns out that I can tell you how to figure out the frequency response of this network real fast. [@] Basically you already sort of know what it is because the resonant frequency ... It's going to be a comb filter, and so it will have peaks at multiples of 5 Hertz in this particular example. [@] And if you want to do the math, you can even figure out what shape the peaks have as a function of this gain here. [@] So if it's 0, it's flat. [@] And if it's a hundred, then it's notching completely out 2.5 Hertz, and doubling 5 Hertz. [@] And in between, it's doing something in between. [@] And you can compute that. [@] And then if you can compute that, you can compute the one of its inverse -- because it's just going to be 1 over it. [@] First off, let me make the add explicit so we can talk about this as a single thing. [@] So either it's a delay network or it's a filter, depending on how you think of it. [@] And now, we're going to run very quickly out of space, so I'm going to just sort of -- squeeze it. There. [@] So what's the opposite of this? [@] The opposite of this is the following thing: [@] We're going to take the filter again. [@] Oh, yeah, so how would you get rid of that echo? [@] Well, all you have to do is you would make the same echo --you'd have to use a different delay line to make the echo, of course. [@] So name it "del2." And then we're just going to subtract it. [@] So we'll take this thing and multiply it by minus one ... and have that control this: [@] And then if I take this signal... [@] So here's a signal with a delay on it. [@] Let's see if this works... [@] "So we're still talking and we're now making a delay..." [@] So now if I subtract that, that would make it go away, right? [@] The answer is: [@] "Try again!" So what happens is, we'll take this thing and we'll make an echo of it that is minus the same multiple of the original. -- [@] And then we'll try it. [@] And then we get... [@] So -- what I forgot was ... there are two delayed copies coming out of here and they're separated by a fifth of a second <<200 milliseconds>>. And then I subtract that off. [@] But of course it subtracts not only the original but it subtracts the delayed copy off. [@] So what I really get is signal minus the signal that is _400_ milliseconds late. [@] Oops! Right? [@] So how do I really get rid of it? [@] The answer is I'll make it recirculate. [@] So I'll take the signal. [@] The signal now has a delayed copy. [@] Now I'll subtract the delayed copy, but that will subtract another twice-delayed copy, so I'll subtract it out and that will make a three-times delayed copy, and I'll subtract that out and it will make it a four-times delayed copy, and so on. [@] And eventually I'll get them all subtracted out and there'll be nothing. [@] And the easy way to do this is to make this delay line recirculating. [@] So what I'm going to do is, rather than just add the delayed signal into the original signal, I'll take the delayed signal, add it to the original signal, and feed it back. [@] This is now a recirculating delay. [@] Oh ... can I prove that? [@] Let's see if this is actually working as a recirculating delay by listening to it alone. [@] OK, we have clarity problems here. [@] So there's the non-recirculating delay, here's a recirculating delay. [@] If I did it right. [@] And I'm going to listen to it and make sure it really is a recirculating delay. [@] By the way, it's got a negative feedback coefficient. [@] -- recirculating delay. [@] Now if I take that recirculating delay and apply it to this delay, so I took out the original signal and now I'm putting in a signal and itself delayed times 86%. And now we're listening to both delays and we've got rid of the delay. [@] One caveat about this that will immediately have occurred to you: [@] Of course, if I made this gain more than 1, then to get rid of it I would need a recirculating delay with a gain more than 1, and that would be unstable. [@] As a result, if I made this gain more than 1, at least this approach to finding the inverse filter is going to fail. ... [@] But maybe we should not worry so much about that. [@] The next thing is ... So now I have a delay network that is just giving us the same thing, and slight observation is we could make this gain negative, and the same thing holds: [@] Now what we've got is the recirculating delay has a gain of 74% and the non-recirculating delay is subtracting a copy of it. [@] This is actually easier to think about than the other case. [@] And again, as you hear, I got rid of the delay that we had before. [@] Now I've told you this, although I don't think I've really emphasized this. [@] Linear time-invariant things like this commute. [@] So let's get this up here. [@] What I'm going to do now is switch the order of the two delay lines. [@] So now what we're going to have is, the original signal will go into this delay line, and it has 74% feedback. [@] And now we have the recirculating version: [@] And now I'm going to take that and throw that into this network here - the non-recirculating one. [@] In fact, to save our sanity, maybe I should make them agree spatially with what I'm doing. [@] So let's do this now. [@] So now we have a recirculating delay, that you just heard. [@] And then we have a non recirculating delay that we will put this into and then we will listen to the output. [@] And now -- Doh!? [@] Why is it delaying? [@] "Hello!"What am I doing wrong? [@] Interesting. [@] I have no explanation as to why this isn't canceling out. [@] Just to be sure that I'm not going crazy... [@] So I'm adding ... So I'm sending this thing into this delay line. [@] Oh, that's not the output of the delay. [@] Sorry, I did this wrong. [@] I wanted this thing here. [@] This is the output of the recirculating delay. [@] Now, we have nothing again! No delay. [@] Now a quick analysis of the situation: [@] (Sorry, I don't know how to make this neat.) [@] This is maybe easier to understand than the other one. [@] So now what I've done is almost miraculous. [@] I have this messy recirculating delay network, which you put instantaneous sound in and out comes a thing that lasts forever, right? [@] And here is a nice thing that cuts that infinite train of delays out, entirely. [@] Cancels it out. [@] Why did that happen? [@] That happened because ... One way of thinking about it is -- When you studied geometric series in high school, they taught you that all you have to do to figure out the sum of a geometric series is you take the thing and multiply it by that number and that makes all the terms match up to all the terms but the first one, and then you subtract it and they all cancel out. [@] The exact same thing happens here. [@] The result of this network is a train of delays, each one 77% as loud as the previous one, or having 77% of the amplitude of the previous one. [@] And then, of course, if you apply a delay that takes the original signal and subtracts 77% of it, that on the first one cancels out the second one. [@] And that delay of the second one cancels out the third one, and that on the third one cancels out the fourth one, and so on. [@] Or to put it another way, this recirculating delay makes a train of echos, each of which is dying out exponentially. [@] Take that whole thing and delay it -- the same delay time -- and multiply it by minus 77%, then you cancel out perfectly the infinite train of echos. [@] And the only reason you should believe this is because you just saw me pull it off in a patch. [@] You might think that this means that now you whenever you have a recording that was done in a bad space, all you have to do is make the inverse of that space. Right? [@] So rooms are basically delay lines in a sense. [@] So whenever you talk in a room, when you put a microphone somewhere or a pair of ears somewhere, you hear just a bunch of delayed copies of the sound -- In a very hand-wavy way of describing acoustics, right? [@] So all you have to do is make the network that cancels out all those delays and you could zero out the effect of any kind of room acoustics that you wanted to. [@] And start all over. [@] So you made a nice recording of someone, but they were playing in a horrible acoustic space. [@] Just take the space out. [@] And then you can apply any other kind of treatment to it that you want, from the original raw signal. [@] Two things wrong with that: [@] One is notice that this only worked... [@] For recirculating delays, I think it's fair to say for any stable recirculating delay, you can make the inverse of it and get rid of it. [@] For non recirculating delays, you can only invert the thing if the echo is softer than the original sound. [@] When that spins out into a real acoustic situation, it turns into a statement that you don't actually know, or you don't know in advance that the inverse filter of whatever your room is, is a stable filter. [@] A stable filter is, for instance, a recirculating delay that has a gain of less than one. [@] An unstable one is going to have a gain bigger than one. [@] So there might not be a stable inverse to a real live situation. [@] The other thing is that you can't do it because, first off, you can never measure perfectly what the response of the room is. [@] Second off, the sound source is always moving. [@] You almost can't get a sound source to stay completely still. [@] And even if the sound source were perfectly still, the air temperature and air density in the room is constantly changing because there are air currents. [@] And as a result, the reverberation, the response of the room is always changing -- enough that if you canceled out the reverberation of the room at any given instant of time, it wouldn't be good for any other given other instant in time. [@] So you'd be out cold. [@] So people have been chasing this fool's dream of trying to get rid of -- or trying to inverse-filter -- reverberant patterns for decades. [@] Conveniently forgetting, or inconveniently forgetting, that it's actually pretty well-nigh impossible to do. [@] However, in this nice completely artificial, simple setup, you can do it completely. [@] I told you that the reason that this was going to be interesting was because now we can make inverse filters. [@] That's OK. [@] But we can analyze the frequency response of a recirculating filter if we can analyze the frequency response of a non-recirculating filter. [@] So to make that audible, let me get rid of the microphone -- put in some noise. [@] But I now have to drop the delay time of the filter so this will be clear. [@] So I'll put a number into the delread~ read objects to change their delay times to something tiny like 2 milliseconds. [@] Then we put noise in. [@] And if I do it right... [@] I get 92% recirculation. [@] Oh, I'm changing the wrong one ... So now we've got a nice comb filter. [@] And now I can take that filter and invert it and reconstruct the original sound. [@] But what that also means is that this filter and this filter - I'll play now the original noise going into this filter like this: [@] So here's the inverse filter, if you like. [@] This filter [sound] is the inverse of this filter. [sound] This filter's kind of ugly-sounding [sound], but it's the inverse of that one. [@] And I told you that that was going to be easy because we can analyze this rather easily, and it will take more work to analyze this one. [@] Now, when we take engineering courses or other kinds of signal processing or signal analysis kind of courses -- signals and systems -- they will make you do algebra to analyze this system. [@] And what I'm doing is trying to avoid the algebra by just sort of analyzing it out of thin air -- by making this claim about these two systems being inverses. [@] I should tell you a thing about this: [@] This is a perfectly good filter. [@] I could make one that has the exact same frequency response as that one, simply by exchanging the two delayed copies. [@] So right now it's the original signal, and then it's minus 92% of the delayed copy. [@] But I could take -92% of the original copy and then full-blast the delayed copy and that would sound exactly the same. [@] But that filter would not be invertible because the second echo is louder than the first one. [@] So if I try to make a recirculating filter to cancel the echo out, it would be unstable. [@] There are two different forms of this filter. [@] One of which, the one I've shown you here, it is invertible. [@] And the other way that you could put it together, which is backwards in time, is not invertible -- Or at least it's not invertible with a stable causal filter. [@] How would you analyze the frequency response of this thing? [@] Well, I've sort of told you ... In fact, you can almost do it in your head if we say the gain is flat-out 1. Yeah, if the gain here is either 1 or it's -1, then we can make a claim about what the frequency response should be pretty easily. -- [@] Think of putting a cosine wave in ... What comes out is a cosine wave and itself delayed. [@] And the sum of the cosine wave and a delayed copy of that is trig -- which you can handle -- not quite in your head -- but it's pretty easy to do. [@] However, when this gain is not 1, it takes a little bit more work. [@] So I'm going to draw you a picture to show you how you might think about that. [@] As usual, as soon as the trig gets hard, the right thing to do is avoid dealing with the trig by jumping into the complex plane. [@] So we will spend ten minutes looking at the complex plane, and we then will forget the complex plane forever -- unless I can end up showing you the Fourier transform next time. [@] But maybe we won't have time for that. [@] So here is the thing that I just showed you. [@] Now, this is how Chapter 8 of the book. [@] We've set all the delay times equal to 1 now because we're making filters. [@] So the deal there is that comb filters are filters -- perfectly all right. [@] But if you make comb filter whose first resonant frequency is the whole sample rate, then it doesn't act like a comb filter at all; it acts like something that only does its thing once in the entire audible frequency range. [@] It doesn't do the combing thing. [@] So this is the way you do a filter. [@] And here what I'm doing is making a number capital Q for reasons that well ... you'll see in the book ... I had to name the variables carefully. [@] And then we'll subtract that from the incoming signal. [@] The reason that we're subtracting here is because -- as shown in the patch -- by convention... [@] ... Yeah, it's convention. [@] By convention, you think of the recirculating filter, this one, as having the positive coefficient. [@] It doesn't have to, but I make its coefficient negative if I wanted to. [@] Like that. [@] All the same good things would happen: [@] We have that and this and those two things are still inverse filters. [@] But by convention, when one usese the recirculating coefficient as the variable that one names capital P or capital Q, depending on whether we're recirculating or not. [@] So as a result, since we're going to be talking about inverse filters, the inverse filter is going to be subtracting -- subtracting some coefficient times its delread~ . [@] To tie this in with last time: [@] Of course this is a real-valued comb filter, and one of the things that I showed you last time is how to make a recirculating comb filter whose feedback coefficient was a _complex_ number. [@] And there is, in fact, no reason that all that this number has to be real number -- It could be complex number. [@] I just made it real number so that I could make the network easily and show you this inverse property. [@] But if we were using complex numbers -- which means pairs of delay lines, and then doing complex arithmetic on them -- Then all of this stuff would still hold. [@] And then we could be doing things like making bandpass and stop-band filters. [@] So now, in fact over here,.. (If you're reading through Chapter 8 while I'm doing this, these are already complex numbers. [@] The hypothetical reader of the book is completely bathed in complex analysis by this time.) [@] Now, here then is how you analyze that: [@] I'm going to skip the equations and just show you what you get. [@] So this Q -- Here is a complex number. [@] And this is the recirculation of a -- if you think of a pair of filters that are inverse, this was either going to be the recirculating coefficient of the inverse of the recirculating filter or it's going to be just the coefficient of the non-recirculating filter except it's going to be with the minus sign. [@] So the minus sign is still up here. [@] So what happens up here? [@] So again, we imagine that we are going to put a sinusoid into the system. [@] And a sinusoid in complex number land means the following thing. [@] You choose a good number Z, a capital Z, which is on the unit circle. [@] So here's the number Z. [@] And the number Z encodes the frequency of a sinusoid. [@] So now you think that the sinusoid is the points 1, Z, Z^2, Z^3, Z^4, Z^5, and so on forever. [@] And of course, when we listen to this, we're just going to take the real part. [@] So we're going to project that onto the real axis and it's going to look like a cosine. [@] But in truth, the real signal, the thing that's happening underneath, is that there is complex number spinning around the unit circle. [@] And the trick is that each new sample is simply Z times the previous one. [@] So now we know how to talk about delaying that 1 sample. [@] Delaying it a sample is simply dividing the signal by Z. [@] Why dividing? [@] Because if you have 1, Z, Z^2 ..., and if you delay it, you get ... 1, Z, Z^2, <> and that's 1/Z times the signal that you have delayed. [@] That's confusing, but it's important to remember that "one over." <<1/Z>> [@] 1/Z, by the way, is just this number down here, which is what you get when you take Z and reflect it around the unit circle, Z to the -1 power. [@] So it's down here: [@] So now what we have is the original signal, which is the signal times 1, and then we have the signal times Z^-1 because we delayed it, and times Q because we multiplied it by Q in the network. << [@] 1 - Q Z^(-1)>> So let's go back to the network and just check. [@] So here is QZ-1. Here's Z-1, which is the delay, and here's Q. [@] And we're going to subtract. [@] Now this isn't even figurative -- This is figurative when you're in electrical engineering, but this is real for us because we're thinking that we're putting a complex sinusoid into this. [@] So this really is multiplication by 1/Z or Z^-1. And this really is multiplication by Q. [@] And this is just subtraction. [@] So here is the left side of the thing, and here is the right side of the thing, which is the signal multiplied by Q Z^-1. In other words, the signal is multiplied by 1, and it's multiplied by Q ^Z-1, then you subtract the two. [@] So it's ( 1 - Q Z^-1 ) which is to say it is a complex number which gets from here to here. [@] So if you think of it as a vector, it's the short vector which starts here and points there. [@] The way I drew it, it looks like that's a very small number. [@] But the number, in fact, is in the range from 0 to 2. And this amplitude, this thing,( 1- Q Z^-1 ) -- Its size, its absolute value is the gain - the frequency response of the filter at the frequency Z. [@] So Q is a parameter of the filter. [@] You can control it but you can treat it like a constant. [@] Z is the thing which depends on the frequency that's going in. [@] In fact, you think of a signal perhaps as consisting of many or even an infinitude of sinusoidal components going in. [@] all with different values of Z. [@] So Q is fixed and Z is everything at once in some sense. [@] And the easy way to think about that is not to think about how Q Z^-1 changes, but to multiply the whole thing by Z to get this picture. [@] So now we have Z, which encodes the frequency of the sinusoid, and here's Q, which is the coefficient. [@] And now as we imagine looking at values of Z that could range all the way around the unit circle, you see there's an area of the unit circle where the values of Z are close to Q -- and those are areas where the gain of the filter is low, it's small. [@] And around here on the other side, the gains of the filter are large. [@] And the gain of the filter in fact is nothing but the absolute value of this complex number, that's to say the length of that segment. [@] Furthermore, if you want to think about it, you can also get the phase response of it -- it's the angle of this thing. [@] So if you care about phases, which well ... maybe you care about -- but you don't have to worry about that yet -- you know how to get the phase out of this diagram? [@] ... Yeah? [@] Student: So is Q fixed there, it's fixed in space there? Even as Z travels around and Z-Q will change? [@] That's right. [@] So Q is the filter parameter -- it's the knob. [@] Z is the frequency that you're thinking about going through the filter. [@] And this is a way of thinking about for all possible values of Z, What does the filter do? [@] And the answer is it multiplies it by that. [@] Student: So what is (Q Z^-1) ? [@] This. This part of the diagram is explaining why this part of the diagram makes sense. [@] So this is the real response of the filter. [@] But this is harder to think about because this point is moving around. [@] This point is not fixed. [@] It's easier to think about the thing just rotating the whole thing about the Z so that this point is fixed and this point is moving, instead of having this point fixed and this point moving. [@] Although you could think about it either way. [@] This is the way engineers think about it. [@] Now, the punch line to this is... [@] Well, there are two punch lines. [@] First off, if I took a bunch of filters and put them in a series (Only if I put them in series; parallel would be a mess.) ... [@] but series. [@] And if all of them had this form, then I could tell you what the frequency response of the whole mess was, because you would simply multiply the frequency response of each stage in turn. [@] So now we can analyze the behavior of complicated filters using the behavior of simple filters. [@] Or to put it another way, that could give us way of of designing complicated filters. [@] Because we might want to design that filter with several stages in order to accomplish something or other. [@] Of course, we're not really going to get there, but that's the thing that people think about. [@] The other cool thing is this: [@] Going back to the beginning of the lecture ... this is non-recirculating filters. [@] But of course I've told you and showed you that recirculating filters can be thought of as the inverse of non-recirculating filters. [@] So here's the non-recirculating filter. [@] And the recirculating filter, which is the inverse of that, is this filter: [@] (I have to go forward one. [@] I have to go forward two, sorry. ... [@] Sorry, I didn't have the diagram. [@] Never mind that.) [@] You know what it should look like. [@] It should look like this, except that you're recirculating the output of the delay line to the input and we're multiplying by Q and adding at the input of the delay line, instead of subtracting at the output. [@] Or to put it another way, we can go back to the patch: [@] It realizes that this is the recirculating filter where we are: Delaying, we're multiplying by something, and then we're adding. [@] This is the non-recirculating one where we're: [@] Delaying, we're multiplying by minus the thing and adding -- in other words we're multiplying by something and subtracting. [@] And those two things are inverses. [@] And what that implies is that for the non-recirculating filter, the frequency response is the length of this segment, which changes as Z changes, which encodes the frequency. < [@] Z encodes the frequency>> And for the recirculating one, the inverse of it, the frequency response is one over this. <<[1/(1 - Q Z^-1)]>> [@] So the non-recirculating filter has a notch right where Q points towards Z, and the recirculating one has a peak where that happens. [@] And what's the smallest value that this thing can be, the shortest this segment can be? [@] It's when Q lines right up with Z. [@] And so that is 1 minus the absolute value of Q -- in other words the amount that Q fails to be right on the unit circle. [@] And so what that shows is that the recirculating filter has a greater and greater gain ... the closer Q gets to the unit circle, the greater the gain of the recirculating filter is right at the choice of Z which lines up with Q. [@] So the angle of Q chooses either the notch frequency of the non-recirculating filter, or the resonant frequency of the recirculating filter. [@] And the absolute value of Q, this radius here called r ... < [@] > -- controls the gain of the filter. [@] So with those two rules -- and with a lot of messing around -- you can design filters to any kind of specifications you want -- just by making assemblies of recirculating and non-recirculating filters with various coefficients. [@] But in particular, you can do the thing that I showed you last time, which is you can make a recirculating filter that resonates at any given frequency. [@] And the way I described that last time was: [@] You know what the impulse response should be -- It should look like a damped sinusoid. [@] And I know how to make a damped sinusoid because I can just make this funny recirculating complex filter. [@] Just by pure thought, you can think about what the impulse response of that should be -- which is ringing. [@] And therefore that recirculating delay line would act as a resonant filter. [@] Now what I'm doing is showing you analytically why that same recirculating delay line acts as resonant filter. [@] It's the same filter that I made last time, but I'm coming at it with a completely different line of reasoning now. [@] This is the correct line of reasoning -- in the sense that now you can take this and actually go compute things. [@] Wwhereas what I showed you last time was just sort of a phenomenological explanation of what's going on -- like picking shells up on the beach or something. [@] ... Questions about this? [@] This is pretty much it for filter theory, I think. [@] ... Yeah, because I don't know how to show you much more without... [@] After that, it's just details, but the details go on and on and on. [@] For instance, how would you design now a peaking filter, which is a filter that, around an area here has a little bump that either bumps up or bumps down, but around the rest of the circle it's basically 1-ish? [@] Well, the answer is you put a recirculating filter and a non-recirculating filter with their coefficients at the same angle, put them rather close to each other, and therefore anyone out here is about the same distance from both of them, and therefore the gain there is about one, because the two distances are almost the same and you're dividing -- because one's recirculating and one's not. [@] But in this neighborhood, if you put one of them closer than the other, then you can make the thing have a positive or negative gain, depending on the ratio of the two distances. [@] And that's your peaking filter. [@] And reasoning like that. [@] You can make it as complicated as you want, but it's thoughts like that get you through all the elementary filters that people use every day in computer music. [@] So this is a much better way of thinking about it than is the sort of phenomenological: [@] "Make something that rings." [@] Because you can actually do reasoning on this complex plane and in a way that allows you actually figure out that would make the filter do something that you want. [@] Oh, and furthermore, I just told you how to make a peaking filter: [@] It's a recirculating and a non-recirculating filter. [@] Now if you set the two coefficients to be exactly the same, those filters are exact inverses. [@] And so that's how you get away with putting all these filters in series in an audio chain. [@] It's actually true that when you set the gain of a peaking filter to 0 dB -- neither up nor down -- so that the recirculating and the non-recirculating coefficients are exactly the same, the filter is unity. [@] It is as if there were no filter there at all. [@] And you can put a hundred of these things in series and it won't change the original signal. [@] And so that's why you can actually have things like graphic equalizers that don't completely destroy your signals, because each one of those filters is actually nothing if you zero it out. [@] ... Questions about this? [@] So that's filter design. [@] And study with Tom or Shlomo and learn all the deep stuff if you want to go further in this. [@] Now what I'm going to do drop this entire line of inquiry and start talking about graphics. [@] Audience Member: [@] These results you've shown are all from complex analysis? [@] I might need to find some books on that. [@] I wonder if it's the simplest approach? [@] Yes, this is called the Z plane, just because one uses the letter Z to describe the complex number on the unit circle. [@] ... Yeah, indeed. [@] This is something that I wake up every morning wondering about. [@] And the good news is you didn't have to know any calculus to do this. [@] You do have to do complex arithmetic, that's to say you have to understand about angles and magnitudes of complex numbers, but you don't need calculus. [@] Although, sometimes calculus helps later on. [@] This is all high school mathematics. [@] In fact, I've probably already said this, but this is the reason high school mathematics is interesting; so that you can do computer music. [laughter] [@] You cannot do banking, even. [@] Bankers don't do algebra or geometry, but computer musicians use that all the time, and this is exactly how it comes up. [@] So people should teach you computer music in high school because that would make the mathematics interesting and make it stick with people. [@] But that will only matter if you become a high school mathematics teacher in your futures. [@] So I'm going to save this. ... [@] And I've pretty much finished making all the points that I want to make about this. [@] So how we're going to go work with graphics. [@] Now I have to tell you something about graphics programming, which is that I don't do a lot of it. [@] So I'm not exactly the right person to teach you this. [@] You'll see. [@] I can't make great examples, because I'm not a person that does this kind of thing, and there are a lot of people who do. [@] So I'm going to quit here. [@] And I'm actually going to change directories. [@] And furthermore, I'm going to run GEM, and not Pd. [@] First thing about GEM -- You probably already see this ... when you start up ... If you downloaded Pd-extended as opposed to Pd, then you have GEM. [@] And in fact, when Pd-extended starts up, you see all this kind of stuff. [@] This is Pd loading GEM. [@] GEM is a library that is larger than Pd, I believe, that Pd reads and uses to define a whole collection of new objects. [@] Describing that depends on... [@] I haven't said something I didn't say, which is that: [@] In Pd, most of the objects that I've shown you have been built-in objects. [@] In fact I think all of them have been. [@] But if you type it the name is something in Pd that Pd doesn't know about, (And if it's not an abstraction -- that is to say that if it's not the name of a patch.) ... [@] anoother thing that it could be is a name of a file which is an object file which Pd will load in to define a new object. [@] So you can make objects in Pd that are C-code that fit inside boxes and do things that you want them to do instead of the things that I thought you might want to do with the built-in objects. [@] GEM is the... [@] So the name stands for the Graphics Environment for Multimedia. [@] This is by Mark Danks and is now managed by IOhannes Zmoelnig. [@] And all these names are also people who work on this. [@] What GEM is, is a collection of something like 200 objects that pertain to graphics in some way or another. [@] Graphics in GEM-land is the thing which is called OpenGL. [@] OpenGL -- it's the name of either a worldview or of an API, which regards computer graphics as being "drawing polygons in space." [@] That sounds really stupid until you find out that what you can actually do with it, which is not drawing polygons in space, but it is drawing one polygon in space and pasting images onto it. [@] So I'll show you how all this works. [@] There are two points of view on computer graphics: [@] One is the 3-D point of view which is "Everything has a model." [@] The thing that you do if you make a dinosaur or something like that -- A dinosaur is a bunch of triangles which are a bunch of vertices, which few points in space, and a bunch of segments between them that describe polygons. [@] And then, if you want to render a nice dinosaur on your screens - it's called "rendering" -- for each one of those triangles that is described, you ask the computer to paint a picture of that triangle, except of course if it's wholly or partially occluded by some triangle that's in front of it, then you would paint the one in front of it in that place instead of the one behind. [@] So you do hiding and all that kind of stuff. [@] And this is exceedingly popular as a way of thinking of computer graphics, basically because of the influence of two industries. [@] One is Hollywood, which started making high-budget, three-dimensional rendered animated films like "Toy Story" or "Up." [@] And the other thing is computer games. [@] There are the interesting computer games and the stupid ones... [@] The interesting ones are the ones that have a thought component to them, And the stupid ones are the ones where you're chasing things around and shooting at them. [@] And if you want to make a computer game where you chase something around and shoot at it, it turns out that 3-D rendering is a very good way of making that appear realistic. [@] And so basically the first-person shooter games, FPS games, and Hollywood movies are the basic reason to have three-dimensional graphics. [@] Now, personally, turn your ears off, because I'm going to express a aesthetic opinion here: [@] I think both of those things are aesthetically bankrupt. [@] But they're there and, furthermore, both of those things aree multi-billion dollar industries. [@] So if you know how to do this kind of stuff, you can actually make money at it. [@] GEM is OpenGL, which is the Open Graphics Library, which was originally called the Graphics Library. [@] It's one of two or three competing APIs which the world uses for for doing 3-D rendering. [@] However all of the 3-D rendering things ended up having to work with images as well. [@] So why isn't all that stuff images? [@] Well, because, as I've told you but then got lost trying to explain, there really are two points of view on making pictures with computers. [@] One is draw a 3-D model, which is what OpenGL and these other things are designed to do. [@] And the other is to think of it as painting on a screen. [@] In other words, the screen consists of a bunch of pixels. [@] It's flat. [@] And what you're really doing is you're concerned with the color of each of the pixels. [@] And then the tools that are of interest are video cameras, because video cameras make images, they don't make 3-D models. [@] And tools like compositing, which is to say taking one image and painting onto it with another image, which could by, the way be the image of a blob made by a paintbrush, so that you could regard painting as a compositing operation where you put bits of one image, which is actually just paint, onto another image, which is the actual canvas that you're painting. [@] So OpenGL has a huge facility for doing image processing in this second sense, which is called "texture mapping." [@] Why? Because the only reason for doing images if you're back in chasing dinosaurs around in some computer game, the reason for having images is so that you could paint the images onto the skins of the dinosaurs to make them look scaly. [@] That's called "texture mapping." [@] You don't really want to have your dinosaur to look like a bunch of green polygons running around. [@] You want it to look like dinosaur skin. [@] So what you do is you gohire artist to make a picture of what a dinosaurs might look like and you take that picture and you tile it onto the body of the dinosaur -- all over -- in a way that doesn't make it obvious that it's repeating. [@] And that's called "texture mapping." [@] So to make a 3-D picture... -- [@] Is this stuff that you all know? [@] Sort of? [@] Maybe I'm repeating things here. ... [@] So to make a 3-D image, really, you make a model but then you paint a texture on the model and texture on the image. [@] And so there are image processing things which are basically there's 3-D texture mapping but they allow you also to do things like taking in parts of images and compositing them onto the other images and stuff like that. [@] And those are the cool things that you can do with GEM, as it turns out, at least from my point of view. [@] So now what I'm going to attempt to do -- and this is dangerous because I don't really know what I'm doing -- is show you the basic tools in GEM for making shapes and for mapping textures onto them. [@] Just to maximize the embarrassment, I'm going to do this from nothing so that you can see everything that you have to do in order to make a GEM object. [@] And then I'll fall back on some prepared ones because - you'll see ... Things don't just work the first time in GEM because there are more details to keep track of than there are in audio land. [@] So what we're going to do is make a new window and before I do anything, I'm going to save it, and it's going to be 0.gemtrythis. [@] <> [@] And I'm going to call it .Pd even though maybe it should be called .GEM. -- [@] It's going to be a Pd patch but there are going to be a bunch of new objects which are GEM objects. [@] So the first one is going to be this thing ... The first thing is, we need is a window to put the graphics output in. [@] And there's an object called "gemwin", whose purpose in life is to maintain a window that will be the image that Pd makes. [@] And it takes messages, and messages are something like "dimension," which allows you to say how big you want the thing to be. [@] So maybe 300x by 200y. [@] I'm going to make it really small because my screen doesn't have much resolution. [@] And that is just going to tell the GEM window how big a thing it should make, and there's a "create" message that makes it and there will be a "destroy" message that gets rid of it. [@] There's other stuff here that I'm not telling you about. [@] So tell it what dimensions and create a window. [@] And ta-da -- we have now a nice window -- which is just being a window that doesn't know what it's doing. [@] It's just sitting there being a space on the screen. [@] It isn't even being managed by the window manager right now. [@] The nnext thing to do is to be able to throw it messages to start it and stop it. [@] And the obvious thing to do would be to put a toggle. [@] So you can send it the number 1, and the number 1 starts it rendering if you've even said so. [@] So now it's rendering, which means that it can redraw itself -- and it's just redrawing black every time it gets redrawn now. [@] And then if I turn it off, then it's not rendering anymore and that it's just being catatonic like it was before. [@] Now me, when I'm making patches, I don't do this, I do this: [@] It turns out that as soon as you create a window, it's time start rendering. [@] And if you want to stop rendering you'd probably want to get rid of the window, too. [@] So I alwsys just do that, "creating and on" or "off and destroy." << [@] create, 1>><0, destroy>> [@] Now, making objects: [@] So I told everything's a polygon. [@] So I'm going to show you as an easy-to-manage polygon that won't do much for you. [@] And then I'll show you a complicated polygon that will do more stuff for you, but it will take a lot of work. [@] The easy one is a rectangle, and the complicated one is a triangle. [@] Why? I'll show you... [@] Rectangle is this: Say "rectangle", and then we'll give it dimensions. [@] And then we've to say -- And here's the thing that I have trouble explaining. [@] But I'll just try to explain it: [@] Now what you need is to have, in some sense, the equivalent of the adc~ object -- The thing which just starts things rolling. [@] So rectangle is an object which doesn't -- It looks like it has an output, but it doesn't. [@] It's at the bottom of a chain of things that we will do, which is we will first off make a source of messages that will go down this chain of objects. [@] And eventually the chain will terminate in the rectangle, which is the command to draw something. [@] The top of the thing is an artificial object which is called "gemhead." [@] So we will have a gemhead at the top everything -- which is called a "GEM chain." [@] Now we have a rectangle. [@] This is insulting your intelligences but ... Rectangles have dimensions. [@] And so now we've got graphics. [@] So now you can immediately tell that you could make patches that have abstractions that have thousands and millions of these things and start making Piet Mondrian paintings and stuff like that. [@] In fact, you can do anything with this now. Almost. [@] Now this is, however, a little bit stupid because the rectangle is white and there's some other things stupid about it ... Let me tell you something good to know. [@] The dimensions in GEM roughly speaking: [@] Everything is in three dimensions, although you don't see it yet. [@] And this rectangle is on the Z=0 plane. [@] Z is this direction, Z is positive towards you and negative away from you. ( [@] I hope -- I'll find out if I'm wrong.) [@] This is Y and this is X. [@] And at Z = 0, you can see X and Y, if I remember correctly, between positive and negative 3. Now why positive and negative 3? [@] It's because that's the way the coordinate system is set up. [@] It's a thing that you could change, but you think of that as the camera. [@] In other words, there's a virtual camera looking at this scene, and that camera has a particular lens length and all that kind of stuff. [@] But it is such that this ranges from plus to minus 3 at Z=0. [@] Let's see if that's actually true. [@] So I'll make the thing three. [@] Three means three units wide. [@] So we'll make it six units wide to fill screen. [@] So there's that. [@] Now, first thing that you might wish to do - well, there are a bunch --would be to change the color. [@] Anyway, it's a thing you'll eventually wish to do. [@] Now we start with all the 200 objects: [@] I've shown you three objects, now we'll start with the other 197. How about "colorRGB" ... [@] I have to say very soon I'm going to have to go consulting the help files, because all these objects have lots of inlets and have lots of complicated things that you can do with them. [@] But right now, I'm just going to fly with this and hope for the best. [@] So if I remember correctly, RGB are actually these three inlets, and their values range from 0 to 1. (I'll find out if this is right or not as soon as I start doing this. [@] I'm wrong.) [@] Change that to 1. Let me get rid of this. [@] We're going to just not know what the last inlet does, and do this instead: [@] So this is also confusing because the color is white, which is: [@] R, G, and B are all equal to 1 to start with. [@] And so I had to actually send it 0's in order to turn it off. [@] The inlets do not necessarily start out at zero in GEM. [@] Although they almost always will in Pd. [@] So here's red, here's green - wait, no. Sorry. And of course blue. [@] And now everyone knows this but ... Take red and green and you get ooh -- Sort of yellow. [@] So this is video color rules, where colors add; they don't subtract. [@] That isn't yellow either, is it? [@] Better than the other. [@] And exactly what color you get depends on your projector or your screen. [@] In fact I have a radically different color here than what you're looking at. [@] So there's all that. [@] What is happening here is the following thing: [@] Maybe you all can understand this, but this is a thing that I find very, very mysterious. [@] The way GL thinks and the way GEM plays into GL... ( [@] OpenGL is the API that GEM is talking to. [@] API is an "applications programming interface," - It's just a bunch of function calls as far as we're concerned.) [@] The way the API thinks about life is, you don't just render things. ( [@] So this is rendering a rectangle here, and you can say "render a rectangle." [@] But before you render the rectangle, you're allowed to do all kinds of nonsense which are called "transformations." [@] Transformations are things like rotating or translating the object in space, changing its color. ( [@] Now why is that a transformation? [@] I don't know, but it is.) [@] And making it not opaque, make it partly transparent. [@] And worse yet, unbelievably wrong -- but this is not Mark Danks' fault, this is OpenGL's design that's just weird: [@] Another transformation of an object consists of saying what texture it's going to have mapped onto it as it's rendered. [@] So to put it another way, you go waltzing down this GEM chain until you get to the last thing, which is a command to draw something, which is a drawing command. [@] But you collect all sorts of detritus along the way. [@] And the detritus is things like rotations, translations, color changes, transparency changes, and textures. [@] So this right now is the color thing. [@] And I believe it's true that if you do it again, it would simply replace the color with the new one. ( [@] I shouldn't be doing this, but we'll see...) [@] Now this color is white. [@] This color will simply overwrote that color. [@] So as I told you, you can translate or rotate. [@] So how about "translateXYZ"? [@] Sorry ... this is painfully stupid, isn't it. [@] Now while we're here, if you want to do animations, the obvious way to think about doing animations is to make an object and then start it flying it around. [@] Don't do that. [@] It's just stupid. [@] This is a stupid animation. [@] A good animation is representing motion by drawing things in sequence, which is not the same thing as drawing a thing and making it move around. [@] But the people who designed OpenGL were convinced that the right way to animate something would just be to make something and make it fly around. [@] And so there are all these wonderful things in OpenGL for making things fly around. [@] Next one, of course, we have translations. [@] But of course, we're also going to have to have rotations. [@] This one, I think, you can actually say "rotateXYZ." [@] So rotation: [@] There are many ways that you could represent a rotation, but one possible way is as a 3-vector. [@] By the way, it's a complete coincidence that the same number color dimensions is the same thing as the number of spatial dimensions. [@] That didn't have to be true. [@] That's our eyes didn't actually choose the number 3. But that's the number we have, right? [@] So rotating about XYZ is the following thing. [@] You specify a vector and the magnitude of the vector is going to be the amount of rotation. [@] What units do you suppose OpenGL would have proposed for that? [@] If colors are going to be from zero to one, the obvious thing to do is have the rotation be in degrees, right? [@] No. But that's what they did. [@] So, for instance, if you want to rotate the thing on the plane that you're looking at, what you're doing is you're rotating about the Z-axis. [@] We're going to describe the vector normal <> to which you're rotating, and furthermore, the length of that vector is going to be how much you're rotating. [@] So here, we're rotating about Z. [@] And notice by the way some crud in the image. [@] This staircase thing is called aliasing, and that's bad. [@] You can fix that, but I'm not going to show you just right now. [@] The other thing is you can also rotate like other axes and now suddenly you get to see the fact that you're being three-dimensional. [@] Now, this is a perspective drawing of the nice rectangle whose top edge is at 140 at whose bottom edge is pointing away from you. [@] And compound rotations can be compound things. [@] Now this is interesting for about 30 seconds and then it's profoundly boring. [@] So next I'm going to make two of these, so you can see how GEM thinks the things should superpose. [@] Let's see now what's happening> This one ... They're the same size. [@] We're going to rotate this one. [@] Oh my! I have to tell you something about my computer. [@] A pixel in this direction isn't the same size as the pixel in this direction. [@] Anyway -- I didn't tell it to make it a square window. [@] Probably that's what's really going on right now: [@] Since my window isn't square -- In fact why don't I make my window square because I'm going to be confusing here. [@] So you would never actually make a square window, but I'll make a square one so that you still only see the aspect ratio problem. [@] So this shape should be the same that shape and I think it's not, but I think that's because my aspect ratio is messed up. [@] The aspect ratio is whether the pixels are square or rectangular. [@] So now we have two things. [@] Now, who said that the yellow rectangle is behind the white one? [@] ... OK, so why is the yellow one behind the red one? [@] Because I did this first. [@] That's not good. [@] It would be better to tell these gemhead's in what order they should be rendered. [@] What's really happening is that the yellow rectangle is being rendered first and then the red rectangle is being rendered. [@] So that even though they are at exactly the same location, pretty much space, the red one shows one on top. [@] You can actually specify that by putting numbers here which are priorities, which would be the order in which that the things are going to be rendered. [@] But rather than worry about that right now, I'm going to start translating again in the Z direction. [@] I'm translating the yellow one. [@] And I'm going to move it toward us, and then away from us. [@] You get two options. [@] What is that? [@] "Z buffering" is I guess what you call this, where one thing is in front of or behind another. [@] Or, to belabor the point horribly, let's take this thing and rotate it about X. [@] Now we have sort of an engineering drawing where we have this piece of metal going through a slot on this piece of metal or something like that. [@] Now basically this is the way 3-D rendering works: [@] You draw stuff and then this stuff occludes other stuff -- that's the basic deal. [@] Now comes the risky part. [@] Let's start putting textures on these thing. [@] And the reason for wanting to do this is just so that we can actually start working with images, which is much more interesting than working with shapes in space. ... [@] At least in my opinion. [@] So to do that -- and this is really strange, I guess. [@] It's not really stupid, but it's just strange. [@] So I'm going to do yet another thing, which is to tell the thing that it has a texture. [@] Now that is called "pix_texture". [@] And what's the texture going to be? [@] What this thing does, pix_texture, is it says "Whatever the image is, that's what you're going to texture map on." [@] But what is the image? [@] There's no way to specify that directly, and so what you do is just say "Part of the environment that we're having is there is a current image and the image is going to be set by pix_image -- this object." [@] And furthermore, this object takes a message. [@] The message is going to be "open test1.jpg." <> [@] So I'm going to do this and I'm going to try to explain what it is. [@] So pix_image is a thing which is memory, which contains an image which we can read the image in. [@] It didn't work?! [@] Why can't I do this? [@] You know what, I'm going to cheat. [@] I'm going to go look and see. [@] So we say pix_image open pix_texture. [@] There's nothing wrong with this... [@] Oh! "temp1" ! So why didn't I get an error message? [@] Oh, right! The error message goes... ( [@] Right! ... I got this earlier today and forgot: [@] The error message getss thrown on the "standard error console". Bad bad ...) [@] So we're going to say "temp1.jpg". And then do we get anything? [@] OK, it's happy ... (Where's the rendering window ... It's gone because ... There -- Ha!) [@] OK, so let me go back and make this thing be white. [@] So that you can see the image in all its glory. [@] Here's the image. [@] It's a stupid image, but you know, someone found this somewhere on the road... [@] Mark I think found it on the web somewhere. [@] And now what's happening is: [@] This image is being texture-mapped onto that nice rectangle. [@] So the operation is done in the following way: [@] You have a pix_image, which is a buffer which contains the image. [@] And pix_image's job is simply to say, "All right. [@] If anyone needs an image, I've got an image and it's in this buffer." [@] And then pix_texture's job is to say, "Has anyone got an image? [@] If so, let's texture map it." [@] And of course the person that's got the image is this one. [@] So that becomes the image that gets texture-mapped. [@] And that's the basic way that this thing gets mapped through. [@] Now images are cool ... But where do images come from? [@] Images come basically from three possible places that I'm aware of right now. [@] The medium cool one is files, the really cool one is the camera, or your camera -- so you can take your camera and make it show up on this thing. [@] And then the uber-cool one is: [@] You can take the two images and composite them into a third image, so that you can actually work on various kinds of image synthesis, like you can take an image and punch it into a part of another image and blah, blah like that. [@] I'm not going to have time to describe this in detail today, but I'll try to show you some of these examples next time. [@] And finally, on some OS's -- maybe all Os's now, I'm not sure -- you can take whatever you just rendered, make that an image and save it -- which is a way then of being able to paint stuff and haul it off screen into an image and then be able to use that as raw material in something else. [@] So, with all that, you have a ready source of a whole bunch of images that you can use in recursive ways to build up cool visual effects of one sort or another. ... Yeah? [@] Student: Can this run while you're running audios and stuff? [@] Yes! And furthermore, although I'm not ready to talk about it -- Well, I don't have time to talk about this because we have two minutes left. [@] But furthermore, the two can be throwing information back and forth to each other. [@] So you can. ... -- [@] I tried to get this demo working today and couldn't. [@] But maybe by Thursday I will ... You can take the camera and point it at something and turn that into sound, like a waveform or a spectrum, or you can have a sound going into a microphone and have that effect how an image is happening -- Like ... make an image jump around when you have a signal coming in to the microphone. [@] A lot of people have worked hard on coming up with cool and interesting ways of using this musically and visually. [@] Some people call this "visual music" when you actually make designs that consist of both images and sound that are changing in time. [@] Although, of course, that's a music-centric name to give it. [@] But the name "visual music" I think dates back almost a hundred years now. -- [@] So it's not like the inventor of GEM thought that term up. [@] ... Yeah, so now you can all go out into clubs and make money because people will pay to dance to images jumping around the screen -- until they suddenly realize that that's not something you really dance effectively to and then it'll go out of fashion and then you won't be able to make money this way any more. [laughter] [@] So more on this next time. [@] *** MUS171 #20 03 10 (Lecture 20) [@] We'll finish up with GEM today. [@] This is an example of taking audio and graphics and in some sense, bridging the divide between them. [@] And this is a very good patch for you to load on your laptops while your professor drones away. [laughter] Basically, well, you can tell exactly what's happening. [@] So, as I was saying, GEM is all about polygons. [@] And what you see here is a bunch of polygons. [@] But so far, I've shown you two rectangles, so this is a whole sample with a whole mess. [@] So what I want to do is just sort of show you how you put together something very simple like this. [@] And 've got to say, this is not going to win you any prizes being able to do this kind of thing. [@] But the interesting stuff that I think that you can do with GEM, with geometric kind of modeling like this is things where you algorithmically generate hundreds of thousands or millions of polygons to make shapes or other kinds of collections of stuff in space. [@] And, I don't have any good examples of that sitting here right now. [@] So, I'm not going to try to develop one. [@] Instead, I'm just going to show you this kind of very simple sort of generating example of "OK, here's how you would use audio analysis to drive a picture." [@] And then, we'll just sort of leave GEM for future years. [@] And then I have five other topics in Pd that I'm not going to have time to do properly, so I want to mention that they exist and give each one of them maybe 10-ish minutes each. [@] That will be plenty for today. [@] And then, we're going to be done for the quarter -- except of course for final projects. [@] So, the plan for today is not just one thing: [@] It's a bunch of things but each of them is only just kind of on the surface. [@] One is, I'm going to finish up with GEM with this example. [@] And then, the example actually, has is an example using audio analysis and there are lots and lots of things that you can do with analyzing sounds. [@] And so, I want to show you the basic tools that Pd has available for doing audio analysis and some of the things that you can do with that. [@] And then, there are other things that you might want to know about which I will tell you about as I get to them; but, basically, four other classes of things. [@] Each of these are just sort of quick topics. [@] "netreceive and netsend" is making network connections between computers. [@] "readsf~ writesf~" is spooling audio to and from disc so that you can do things like make sound with Pd and have the sound file afterward. [@] And, Pd~ is a trick for doing Pd with multiprocessing. [@] It's a way of having Pd sprout child Pd's that can run on other processors. [@] So, each of those things takes a few minutes to describe and then they're done. [@] Fourier analysis and re-synthesis: [@] I'm going to just show you one very simple example of this, but this is a thing which you could easily study for months or years. [@] In fact, it's true that most people have to study this and think they learn it and then come back a year later and realize that there's actually another point of view on it that you wanted to know it from. [@] And so on for three or four iterations before you really have enough points of view down that you really believe that you know Fourier analysis and synthesis fluently. [@] So, this is a thing that which I want to tell you the existence of, it will not start actually going on. [@] Because it is just a big thing. [@] But, anyway, back to the GEM example. , [@] so what's happening? [@] Every time I talk, the sound is going to the microphone. [@] So, we're having to do two things. [@] Really, we are, measuring the loudness of a sound. [@] That's a technique which is old and it dates back to the, at least to the analog synthesizer days, it's called "envelope following" and it's one of the three kinds of analysis that I am going to be showing you in some more detail next time. [@] But at least now, what I'll do is show you how it works into this example. [@] So, envelope following. [@] This is kind of a mess. [@] I like actually running sound files because if you have a recording of your favorite politician giving a speech, this is a great way to listen to that. [@] So, what I am going to do is try to figure out where all the stuff is... ( [@] Not there. [@] Come on. [@] What am I doing wrong? [@] Got that, got that. [@] Audio in. [@] Oh, "pd works" . Here we are. [@] This is the real thing.) , [@] so what does a bird consist of? [@] So, last but not least is going to be "pd sound" where we are actually getting the loudness of the sound coming into the microphone. [@] So, I'm going to save that because for continuity sake, I will just talk about the graphics first -- even though the flow of information is from sound to graphics. [@] So, I'm going to be going upstream in information flow here for a few minutes. [@] So, what would you do? [@] Well, these things are all, well, these, I'll do this in some detail. [@] This, these hundred rectangles are going to be the bird's body. [@] So, part of the trick to drawing the bird is making this shape, which is a very irregular shape that you can't make very simply out of polygons. [@] So there is a thing for making a hundred polygons that makes that shape that I'll show you. [@] Then, there are isolated things which are... [@] Let's see. [@] This thing is a rectangle, this twig that it's sitting on. [@] The legs are I believe trapezoids although I have to go check. [@] And, these eyes are actually hexagons. [@] That's cheesy, but that's what I did. [@] And this beak is three triangles. [@] There are two triangles for the top part of it and just one triangle for the bottom. [@] And, those triangles are the only thing in the whole thing that's moving; and in fact, the only thing that's moving in this, are four points in space which are: [@] First off, the two sides of the beak which are [clapping noises 06:3 [@] 3] chosen at random whenever it finds a new attack. [@] So that, basically, the width of the beak is sort of changing word by word except it's not working too great right now. [@] And then the, you can tell that the two points in front of the beak -- which if there's no sound going at all are one point there. [@] There are two points which lie on a vertical segment and they're some fixed point plus and minus the envelope value that is coming in from the incoming sound. [@] So, these two are random, but are set off by attacks and sound. [@] And these two are the continuously changing envelope. [@] That's the whole deal. [@] So, how do you do it? [@] What I want to do is find some simple stuff first and then show you the complicated stuff. [@] So, here is simple stuff: [@] I told you that everything is triangles and then of course here, I'm making a four vertex polygon which is a quadrilateral. [@] If you make quadrilaterals in OpenGL or GEM, make sure that the four points are coplanar because it will do the wrong thing if you give it a skewed quadrilateral, that's a quadrilateral whose vertices are not planar. [@] In this case, almost everywhere, the Z value... <