*** MUS171 #06 01 20 @0000 Here's a thing I'm going to forget to tell you, so I'll tell it to you now while only the early birds are here while I'm thinking of it. You can set the screen @0015 size of tables. So if the "one size fits all" size that you're all used to is not what you really want...Like in this example you can do something else. In this case my table is too fat and it's not tall @0030 enough. So if I do that one, then I have...Oh, maybe that's too tall for my screen. Anyway. Yeah, not good. All right lets make it 400 pixels tall and 100 pixels wide. @0045 No, looks like I have 300 pixels. All right, there it is. OK. My reason for doing that was @0060 because the bigger you make something vertically, the more accurately you can control it with a mouse, assuming you're controlling all the way down to the pixel, which is the way tables work. Actually they maintain floating point values, which are to high precision. @0075 But when you're editing you can only push them onto a pixel value, which might or might not be available, but it's more likely to be available the bigger you make the thing. So that's a trick. This is just a review from last time. @0090 Right now what we're doing is we're looking at the first seven values of this table. Bring this up to here. And the reason I know that we're doing that is because I'm taking this phaser @0105 which goes from zero to one in value and multiplying it by seven. Which means now you're going from zero to seven. And then values from zero to seven truncate down to values from zero to six, when you truncate them to the greatest @0120 integer below them. And as a result you're looking at the first seven values of the table which are numbered 0, 1, 2, 3, 4, 5, 6. And the others are just there in case you want them later. You don't have to have them in fact I could resize @0135 the table to seven values now, but I might decide that I want a different size sequence later, and I can do that just by changing the number. And now we're looking at , 1, 2, 3, 4, 5, 6, 7, 8, 9 .. @0150 0nine out of the twelve values. Notice that it gets faster as I ask it to use use more values. That's just because the frequency that I'm giving the phaser is setting the period for the entire @0165 sequence and the more notes I stuff in there, the faster the notes are going to be going. Or to put in another way; the more you multiply the phaser by, the faster the output is changing within time, because the more it travels all told. Student: So what's the "0.7" ? Miller: @0180 That is the frequency in hertz of this phaser. Student: What units is that, .7 of what? Miller: It... let's see, it does 0.7 of that sequence @0195 every second. So if I set this to 1, it's one cycle per second, if I set it to 2, it's two cycles per second. So here's 1: [tones] If I say 2 it'll go twice as fast. @0210 Oh, so right now it's every second. 2 is not every two seconds, but every half-second. So 0.7, @0225 what's that? That's one over 0.7 seconds in period. And I don't know why I chose that value. Actually I know why. I tried 0.5 and it was too slow for my taste. @0240 OK. So the purpose.... does everyone understand how this example works? Or, can you formulate questions @0255 if you don't? ... Yeah? Student: Why would you have both the multiplier <<*~>> and the adder <<+~>> after the phasor? Miller: Right, OK, so the multiplier is taking the phaser's output and re-scaling it so that it goes from zero @0270 to seven in this case. And the adder, I'm not using at this point, I'm adding zero which isn't doing anything. But if I wanted to instead of looking at the first seven points, look at the points two through eight or three through nine, I would add something to the scaled value and that would be @0285 reading at that place in the table. Student: Is that a phase-shift? Miller: Yeah... Oh boy -- it's short of a phase shift, but it's also... it's just a shift-shift. Student: So it's like a range-shift maybe? Miller: Right, yeah. This @0300 is worthy of... what's the right word? This is worthy of just mastering in it's own right. This is the general formula for "I want a range and I want it to be seven wide and I want it to start at zero." In general, if you have something that goes from @0315 zero to one and want it to go from A to B, you multiply by (B - A), which is the size of the range, and then you add A to slide it over to where you want it to go. And you do this all the time in computer music. @0330 You can do the opposite as well, which is you have something that's going from A to B, where A and B are numbers, and you want it to go from 0 to 1. ... Because you then want to give it another range, say. So, to do that you would subtract A to make it start at 0, and then it goes from @0345 0 to (B - A), and you would divide by (B - A), so that goes from 0 to 1 . ... Yeah? Student: So, if you add 3, start with 3 will it stop or wrap around? Miller: It'll... Neither. If I give it 3, instead of going @0360 0,1,2,3,4,5,6 it would go 3,4,5,6,7,8,9 . Student: What if you don't have enough values? Miller: Sure I do. I've got twelve numbers in here. Student: What if you don't have them? Miller: Oh, if I didn't? Then, OK, then it's up to the object @0375 tabread~ to figure out what to do with when I give it a number that's out of bounds. And what it does is it simply clips it. That's to say it simply limits it. So it doesn't wrap around. You could make it do that. In fact, if you wanted to make it do that, you would, before this, @0390 you would say, "modulo twelve." <> Which you all learned about in high school, right? So "mod" is a good object. Yeah. And you would do something somewhat different @0405 in signal-land. Because mod works great for integers, but for floating point you might want to have something that's defined a little bit differently from mod. So, that gets us down to there, and then it's just the same @0420 stuff that you know about from before. The reason I'm bringing this up today is because I want to use this as the starting point, because it might be nice to know different ways of getting values in and out of tables, of which there @0435 are a half dozen. And I was having trouble figuring out which one to show you, so I just decided to show you all of them. At least, all of them that I could think of. And because actually it's pedagogically valuable to know them. And we're all about pedagogy here. @0450 So here goes. I have a list. The first thing that you might want to know about is a wonderful object called "tabwrite." In fact, I told you about this, but I didn't tell you all about how to use it -- without a tilde. @0465 And then we give it the table name, which I'll just get from here. And this is a thing which takes two numerical values, which I'll start out by using the number boxes @0480 to specify. And here <> you say which value in the table you want, "3" say, and here <> you say what you want it <> to be. And, tada, you're moving value three around in the table. So, you can see this thing is going up and down @0495 as I'm doing this. OK. This would be kind of--what's the right word?-- "hideous" to have to make a patch that did this to every single value of the table. Because you would need a different tabwrite object for every number that you wanted to set, which would be ugly. @0510 So, you want to do it a little bit more smart than that, for which you will need some objects that might generously be referred to as glue. So, there's some glue involved in using things like tabwrite most effectively. @0525 Glue. So, suppose I wanted the values to be the following, which I'll stick in a message box. Is this what I want to do? OK. I'm not going to use this message box yet. I'm just going to have these values here so that you can see them. @0540 All right. Do I want seven of these things? Yeah. Let's have seven of them. So, now... I'm just making multiples of 110, @0555 because since I spend a lot of time in music studios, I like things to actually belong to the western scale. And 110 is an A. So, these are easy numbers to just sort of fetch out of nowhere that happen @0570 to have at least some reasonable western meaning. And suppose I want to get these values into this table, what would I do? OK. Technique number one. We could use tabwrite. But @0585 of course, I don't really want to type all this stuff in. I want to just have it in a message box. How would I get that to happen? Well, there are things that you can do. One thing is this. ...@0600 Message box.... Saying that the first number is going to be 990, is the same thing as putting a zero here < and then putting a 990 there <>. And a short-hand for doing that, @0615 in Pd anyway, is you can give it a list of values. And what this means to an object like this...What does an object like this mean? -- An object, except for a couple of exceptional objects -- will take a list of numbers @0630 and interpret them to mean, "Put those numbers in the inlets." So, this is saying, "Set the value at slot zero of the table to the number 990. So, this thing jumps up to there. @0645 I don't have a good range with for numbers, do I? Let me change my range, slightly. So, let's go up to 1,500 Hz. All right. @0660 And this is OK, except of course now I can't do this any more. I can just click it. So, it might be nice to know how to do this, but do it in a way that has a variable associated with it, so that I can make that @0675 not be a thing that's known already. So, that's one thing that I want you to just wonder about for a second while I show you something else, which is this: OK. Now, I can say, here are a bunch of message boxes. And @0690 if I had all seven of these that correspond to these numbers, and gave their locations, and if I set them all in sequence to tabwrite, then I would set the table to these values. @0705 So there's the first one, there's the second one. Oh, I didn't connect it. There's the second one, there's the third one. That's ugly. And of course, now yow know that if you just wanted to have some way of doing them all... In fact, I can @0720 bash it to something nonsensical like that: <> ... I could just give myself a button that activated all these message boxes. A message box actually will respond to any message at all -- so a bang would be perfectly all right -- @0735 and will output its contents. So now, (let's bash it again) ... if I whack this button it puts all the values in the table. ... Yeah? Student: Could you connect the other message boxes to the first message box, that sort of thing? Miller: @0750 You can do that. I didn't do that because I was afraid of confusing people, but you could do this: I wouldn't regard this as terribly good style. But why? Because, @0765 in fact, what this is doing is confusing. Because I'm sending this message to this message box which is ignoring it. Someone could look at that and wonder what on earth I was doing. So it's a little bit better to do it the way that I did it, but you could indeed do it that way. ... @0780 Oh, come on. Let me select this other thing.... This is still a little bit ugly. So let me show you the next thing that's a little bit less ugly, which @0795 is this. I can always say, still using tabwrite. I can say, "Pass the following messages, please." @0810 OK, I'll keep going. OK, I'll stop there because I'm going to run out of screen. Now, what this is, is four @0825 messages in a single box which are "delimited," or separated by, commas. So commas are special characters in Pd. There are four special characters in Pd. @0840 The comma, the semicolon, dollar signs, and spaces. Spaces you know about because you just use them to separate things. Commas separate things, but in a way that means to a message box, "Let there be another message now," and it's going to start here, @0855 with this thing. So this is different from this message box because this contains one message with seven numbers and this now contains four separate messages which will all be sent in sequence. @0870 I have to tell you about how long it takes this to happen, but that's perhaps for a little bit later. It doesn't take any time for this to happen, is the short answer. And so this is now a short-handish way of saying, "OK, go ahead and send @0885 these four messages that do this thing." Furthermore you know what order they happen in -- and here <> you don't actually know what order these three things went off in because it really is just whatever order I connected these things in. The order that the things happen in is sometimes very important. @0900 And I've been avoiding getting into situations where the order matters, but I'm going to start making situations like that today, because that's part of the "glue." ... Questions about this? Yeah? Student: @0915 What are the table properties there now for tab.1.20.a ? Miller: Oh. So this is the important stuff ... there are twelve points in it and Y --the vertical axis is @0930 running from 1500 to -1. (I made it -1 so you can see 0). And there are twelve points in it. And this is the screen size of the table which I changed also. Yeah. @0945 All right. Other questions about this? ... Everybody's totally happy. Let me show you another thing that @0960 will save you some typing. If you really just want to put a bunch of numbers in the table, another short-handish way of doing it is to say... Hmm, should I tell you this? Yeah, I can tell you this. OK. Second technique of @0975 doing things, the second flavor of glue that exists in Pd that you'll want to know about: And I'm going show this to you now because it easily confuses with what I'm doing now, and it's different. So right now what I'm doing is I'm sending messages to this object tabwrite. @0990 You can also send messages straight to this object. << the table itself>> And then you're not talking to a particular auxiliary object like tabwrite or tabread~, or what-not. @1005 You're talking straight to whatever the table itself thinks that it likes to do with messages. And what it does is design for what it is. And how you get a message to it is @1020 you say "Send." So let's get an object, and the object is going to be send, and then I'm going to give it the name of the table as an argument. @1035 And then I can actually send it a message which consists of the following stuff: It has a place in the table that we want to put a value in, and then it has the numbers that I want the table to have. Student: @1050 So the number "990" is the starting point where you want the sequence of stuff? Miller: That's right. So this is now... that's on the horizontal axis. @1065 "Starting point 0, please." And these numbers -- any number of numbers that you wish -- are the numbers that you're going to put into the table. All right. This is a good thing because now there's an easy way just to @1080 write numbers into the table. All right. So this -- sorry I have to think about something here. @1095 I'm going to have to start saving parts of this patch because it's too big for the screen. Well maybe this is just what it is for now. ... @1110 OK, so here's technique number one, down here is what looks like a far better technique. Oh, I don't need this any more. That was just to make the example, but here's the thing that actually did it which has all the information. @1125 Now... Sorry, I'm just cleaning up. ... OK, so "send" is the thing which @1140 will allow you to send a message to any named objects. The only object that you've seen so far that has a name is this: array or table. Another thing that can have a name is @1155 an object whose only purpose is in fact to have a name, which is called "receive." So, let me give it a different name. Oh, you know what? This belongs in a different patch. @1170 I'm going to save this patch.<> @1350 And one way of dealing with that is simply to put a send object up here and put a receive object down there, and that way you get the connection and not the awful line going through the patch. Later you'll find that it's even better than that because you can have patches @1365 that have multiple windows in them, and send and receive is a good way to get from one window to some remote, not very directly related window. ... Yeah? Student: So can you send and receive between different patches? Miller: @1380 Yeah. So for instance, here's a new patch and here's an object. I'll give it the same name, and then I'll hook it up to the number. @1395 Now over here, I say send dog. <>. By the way, one thing that you can like about Linux is that you can do this. <> In your computers you have to click @1410 this thing <> to the front and you won't see this<