*** MUS171 #07 01 25 |
@0000 I'm going to be working up to six new objects today if all goes well. But one of them that I just thought of last, I'm going to show you and then not use |
es:@0000 |
@0015 because I just want you to know this exists. It will come in, in its own good time. But you will need it probably before I need it because I know in advance what I'm going to do, and you don't. So your work is going to be more complicated |
es:@0015 |
@0030 than my work. All right: |
es:@0030 |
So if in an object box you type PD, then you get a thing, and when you click on it, you see a sub-window. And the sub-window is yours to put anything that you want in. @0045 And it will stay there. And it'll be a part of the patch. If you close it, it doesn't actually go away. It's still there and still doing whatever it was doing before, so it's a part of the running patch. But it is a part of the running patch that you don't see. |
es:@0045 |
@0060 The reason I'm going to be reaching for it probably first off, is going to be ... |
es:@0060 |
when I have too many tables running around and they start crowding out the functional part of the thing. So a very normal thing to do is @0075 take out all the tables that you are using, the arrays, and stick them in a sub-window so that you don't look at them all the time -- but so that you can look at them whenever you want to check them out. And it's a single click. So I'm trying to be good to people's wrists. OK. So that's all...Yeah. |
es:@0075 |
Student: @0090 Well, is that something where names will get messed up if you have multiple patches going? |
es:@0090 |
Only in one very crazy sense, which is that you can actually send a message to the window, and do something like @0105 open itself. And in that case, it will actually pay attention to its own name. Otherwise this name actually only functions as a thing that it prints up on the window, so you could tell what's what. And especially since your window manager can tell which window is which on the bottom of your screen, |
es:@0105 |
@0120 which is useful. So it's a good thing to name them, although you don't absolutely have to. And name them something that actually has something to do with what you want to put in there, so that you can find it later. The other objects, let's see. You might have already seen this and you might not have. |
es:@0120 |
@0135 There is a thing that looks like a button but isn't. This is actually a kind of number box. I'll use it to turn metronomes on and off pretty soon. But the basic trick is... Let's see. I'm going to |
es:@0135 |
@0150 make a new window and start showing these things off. OK. So, this thing, which you get on the put menu under "toggle, is a kind of number box, which makes numbers |
es:@0150 |
@0165 that are 1 and 0. So "1 and 0" is computer language for "true and false." People who study computer science learn that true and false are constants |
es:@0165 |
@0180 which have a different type from one and zero. But Pd doesn't use "type" so 1 and 0 are either used as numbers or as logical values. In fact it's even better than that. Any number that is not zero in Pd |
es:@0180 |
@0195 like 4*10^-7 -- no .4 * 10^-7 -- that ridiculous number is actually true because its non-zero. ....Yeah. |
es:@0195 |
Student: @0210 So when you use E for an exponent is it capital E or lowercase e? |
es:@0210 |
Oh you can, I think you can use either. Let's see, I didn't think about that ... yeah it typed ... @0225 Oh, it will read either but I think it will represent it using lower case. And most computer languages use either lower or upper E interchangeably. Student: I just wanted to make sure literally I know where there's a difference. |
es:@0225 |
@0240 It depends on the language like big E also could be energy. ... So this is 4e-08 4*10^-8. If you ever want to express a number like that, use exponential notation. ... Is that what it's called? ... |
es:@0240 |
@0255 Use it. And by the way even though the value true when you say it is 1 ... Hello! -- That is horrible. I didn't write this object; it should say 1 when you |
es:@0255 |
@0270 re-click it -- which it doesn't. (So now I have to fix it. Very good. I didn't know that.) Alright. So anyway it transmits whatever value you put into it through, which is correct behavior. But then when you tell it to be on it should probably say 1, instead of some crazy |
es:@0270 |
@0285 value like that. ... Yeah? Student: Is a negative number zero or not? |
es:@0285 |
A negative number is also true. Hello? -- Right, I can't type into that one. I have to get into edit mode. -- Yeah, so zero is @0300 the only falsehood. It is a misconception that people get, when they start programming using floating point numbers, that they can't hold values acurately. Like the integer 5 if you express it as a floating point number is somehow not exactly equal to 5? |
es:@0300 |
@0315 5 is equal exactly to 5 even if it's expressed as a floating point number. However .1 is not equal to .1 when you express it as a floating point number because it becomes a repeating decimal |
es:@0315 |
@0330 in binary and then it will get truncated. But you can represent integers, including 0, exactly using floating point numbers and not get -- not expect -- a truncation error. |
es:@0330 |
Integers do not get truncated below values of plus or minus eight million. @0345 After that they do, because there's only 24 bits of mantissa in the number. And go study computer science if you want to know more about that. OK. So there's the "toggle switch" which is by the way excellent |
es:@0345 |
@0360 for turning metronomes on and off. Which I think I've shown you -- I don't remember if I used the toggle, I don't think I did. So here's a nice metronome and this leads to my next topic. So put a nice bang so we can |
es:@0360 |
@0375 see the metronome going. |
es:@0375 |
All right. And then, so this is a combination of objects that you see _all_ the time. And of course you could @0390 use a number box, but then you would be obliged to scroll the number box up and down to re-start the metronome, which is ugly, whereas this is appropriate. All right. I showed you that so that I can show you this: |
es:@0390 |
@0405 I'm about to call attention to the central source of confusion in all of computer music. Which I've by the way visited a couple of times in the past, and will have to visit again a few times too, which is the distinction between |
es:@0405 |
@0420 doing things with messages and doing things with signals. So, for instance, one way that I've taught you to count to four, or to count to some number, is using signals. I'll do it over here, make a phasor, |
es:@0420 |
@0435 let's count to five, for reasons I'll tell you, I'll explain later. I'll run it at one Hz, and then I will multiply it by 5, |
es:@0435 |
@0450 and then this will generate a sawtooth wave which ranges from zero to just below five in value, and then I can use that for instance to read values in a table -- which I've shown you how to do. So for instance, |
es:@0450 |
@0465 let's make a nice array. And it will be called... oh, boy. OK, "Table 1 25 A" <<t1.25a>>. Oh, I was typing in the wrong place. |
es:@0465 |
@0480 OK. Draw-as: points. Oh, right, and then it forgets to use points, so I have to say it again. You are ... whoa, that was interesting. You have are points, and you have only, let's say, 5 of them now. |
es:@0480 |
@0495 Did that work? That did not work terribly well. Ah, it worked well enough. |
es:@0495 |
OK. Little fence-post bug. It didn't really leave room for the last one, did it? @0510 Let's fix that. Ta-da! OK Table. All right, and now we can do something like, get those values out and use them as the frequency of a tone that we'll listen to. |
es:@0510 |
@0525 So, for instance, let's do a tabread, "T... January 25th, first try." <<tabread~ t1.25.a>> Oh, right. Tilde. |
es:@0525 |
@0540 Because we are signals, this is the thing that I'm trying to warn you not to be confused about. And now we've got something that we can drive a sequencer with. |
es:@0540 |
All right. In fact, I won't go further than just to say, just to do that. And one thing about tabread~ @0555 is that it's truncating these things to integers, which you could do in a variety of other ways, but the table is the thing which truncates to integers that you've seen -- which is why I hauled a table out just there. All right? |
es:@0555 |
Next possibility: Maybe it would be interesting to do this @0570 using messages. That would mean rather than each time the oscillator tells you it's time for a new thing that is going to happen regularly. It waits for you to tell it to "do the next thing please." -- according |
es:@0570 |
@0585 to some other some other source of time or some other source of events. |
es:@0585 |
... Such as this source right here which is a metronome. But it also could just be me doing this by hand. <<clicking the bang object>> Right. @0600 Well you can do that and the way you do it is this: -- This is one of those paradigmatic ways of programming in Pd that is particular to Pd or Max and |
es:@0600 |
@0615 this won't help you do anything except survive using Pd and Max, as far as I know. This is not actual knowledge; this is just craft. OK. So what you do is, so we're going to make a counter and it's going to count up 0,1,2,3,4 ... 0,1,2,3,4 ...0,1,2,3,4 -- like that. |
es:@0615 |
@0630 (Which is therefore repeating with a period of 5.) |
es:@0630 |
How do you do it? Well the first thing you need is a number. And numbers are held at ... -- well I haven't even told you about this object yet. @0645 Have I? You can have storage! OK. You've seen a lot of storage in Pd because when you say "+ 5" or "+" which has an inlet, that inlet is a storage item. |
es:@0645 |
@0660 And so a lot of objects such as + or the osc~ are perfectly happy to store numbers for you which are the parameters or the arguments of their operation. |
es:@0660 |
However sometimes you need to talk about storage explicitly. Which is indeed what is going to happen right now. @0675 And so we need to have a thing which just exists for storing numbers. This also could be a, no. I'm assuming it could be a number box but I think it just has to be what it is -- for what we're going to do next. And in fact now |
es:@0675 |
@0690 I have to apologize because our object count just went up to seven. Maybe we could, oh yes, if we need "mod" too. So your new objects are going to be numerous today. So I'll hold off on |
es:@0690 |
@0705 inflicting new objects on you next time. |
es:@0705 |
What does float do? Float does this. You put a number in @0720 and it says "thank you very much I know my number." This is acting exactly like a regular inlet acts <<the right inlet>>. And then |
es:@0720 |
@0735 when you say bang on this side <<the left inlet>> it says, "What was the number? Please output it." Alright, clearly a very useful object. You could almost do this with "+" because you could actually |
es:@0735 |
@0750 send a bang to plus and as long as the first inlet thinks it's zero then it outputs the second because it will add them. But that would be confusing to look at because it looks like it's an adder and it wouldn't be -- so it's better to actually use the object which is explicitly just doing what we're using it for -- which is storing a |
es:@0750 |
@0765 floating point number. Therefore called "float. ... Yeah? Student: Can you connect metro so that it reads the float object? |
es:@0765 |
What will happen then is -- let me do another thing @0780 which is put a flasher here so that you can see when it's actually outputting because 53 is just 53, but if I send more 53's you won't see anything unless I put this bang here. So now what's happening is the bang is going to flash whenever it gets something |
es:@0780 |
@0795 and this is going to be the number it actually got, which might not change, right? |
es:@0795 |
So what happens when we hit this with a metronome? It just says 53, 53, 53, 53 five times a second. Could be useful. @0810 But, let's see: Here's something that could also be useful. Let's take and every time a number comes out we'll just add one to it. Now we have something cool. |
es:@0810 |
@0825 We've got the genesis of a programming language. If you can count you can do stuff like ... well, you get the idea. |
es:@0825 |
Alright. This is a loop and notice @0840 a few things about this loop. First off, this is uglier than just writing a loop in C would be because when you write a loop in something like C or any programming language that's based on text you actually see the steps of the loop |
es:@0840 |
@0855 in the order they're supposed to happen in, because programming languages tend to go down: statement one, statement two, and so on. |
es:@0855 |
Pd doesn't work that way. Pd goes along the lines and so you have to do a lot of extra nonsense, which is to actually sew the loop together into a loop, alright? @0870 So this is actually not as efficient a way of describing a loop as you would have in C or something like that where you just type eight or nine characters and you've got a loop. OK. Another thing is, |
es:@0870 |
@0885 just to tell you this, usually when you do this you don't bother with this <<connect a number box at the outlet of +>>, you just do this <<connect the output of + directly to the right inlet of float>>. |
es:@0885 |
Oh, by the way, I disconnected it so now it's just 399, but now it's counting again. It's just counting in a way that @0900 uses the property of float, but doesn't include the little thing I put in to demonstrate the float. |
es:@0900 |
This is better because, as you might have already noticed, the more stuff you have flashing or drawing numbers on the screen @0915 the more your CPU time is being eaten by just updating the screen -- Which, of course, is a useful thing for knowing what's going on, but is also competing for your CPU time with the thing |
es:@0915 |
@0930 that you're actually trying to do which is make beautiful music. |
es:@0930 |
So you don't need to have unnecessary boxes and, in fact, it's better not to ... to a point. @0945 And, by the way, if you do want to have a lot of unnecessary number boxes throw them in a sub-window and keep it closed and then Pd doesn't have to draw them and then you won't be eating the CPU time after all. That's an important clue to, "Oh my patch -- which covers five screens and |
es:@0945 |
@0960 you have to scroll in order to see it -- is starting to run slow." |
es:@0960 |
Well, OK, put a bunch of it in a sub-patch and keep it shut. Then it won't be drawing the stuff and then it won't run slow anymore, at least for that reason. Alright, so now, @0975 the first observation about this is this is a bad way of making loops if you're used to using programming languages, but it's what you get in Pd. There's no programming language here. |
es:@0975 |
Second thing is: notice that it actually looks like a tree, @0990 even though it looks like a loop to the untutored eye. This connection is going into the inlet of float, which doesn't cause float to do anything, so that when a bang comes into the |
es:@0990 |
@1005 float the sequence of things that happens is, in some order or another, the number goes out these three lines, one of which is this line which gets added one to it and that gets put into the float. |
es:@1005 |
@1020 That does not affect what the other two people got because this message was output and it's there and the float, when it remembers its new value, will use that to change anything that it might do in the future, but that |
es:@1020 |
@1035 doesn't affect the rest of what happens as a result of passing that message out of its output -- That would be re-entrancy or recursion. You can do recursion, but don't. |
es:@1035 |
@1050 OK, so the reason this works and doesn't give you an infinite loop is because, in fact, this chain of operation actually stops there. |
es:@1050 |
@1065 If I want this not to work ... save this just in case ... <<saving "2.loops.pd">> |
es:@1065 |
11] . OK, we saved it so now I don't feel bad about doing something that might bring Pd to its knees, @1080 depending on the OS. Here, let me take that other line out and just hook it up here. |
es:@1080 |
Then we get error messages about stack overflows. OK and that @1095 does horrible things there. That doesn't work because then the float says "add 1" and the "add 1" says OK do it again and so on and every time the metronome bangs it tries to add 1 to it an infinite number of times. It actually only got up to some number of thousands |
es:@1095 |
@1110 before it just said "give me a break" and stopped, rather than allowing my Pd or even the operating system to crash as would have otherwise happened. |
es:@1110 |
Oh yeah, @1125 and now that we're here loops are great, but the first thing you learned in computer science about making loops is there are three steps to the loop. There's the thing I haven't done. One of the three of which I've done, which is updating |
es:@1125 |
@1140 the thing each time around the loop. I haven't told you how to start it and I haven't told you how to stop it. |
es:@1140 |
In Pd things aren't started and stopped so much as they're always sitting there latently ready to do one thing, whatever it is they do. They're waiting for events to turn them on, so starting and stopping the loop doesn't make sense @1155 in Pd the way it does in a computer language. But initializing variables, which is typical of what you do at the beginning of a loop in a real language, is a useful thing to be able to do and you do it like this. |
es:@1155 |
You say give me a value of zero @1170 please and you put it right in where these numbers go in. Of course, when I whack this zero it's going to happen between two of these bangs because no two things happen simultaneously even though they can happen with a difference |
es:@1170 |
@1185 in time of zero. So time works in ... What's the right word? I don't know the right word -- Time works chunkily in PD. So this will set it to zero and then the next time it gets banged |
es:@1185 |
@1200 out will come zero here. Oh, right. It starts at zero, this loop, or it starts at whatever you put in. It doesn't increment first, it increments after. Alright, there's a loop. Suppose you want it to |
es:@1200 |
@1215 count 0,1,2,3,4 ...0,1,2,3,4 ... and so on like that instead of doing this thing? |
es:@1215 |
There are two ways to do that. There's the way everyone thinks of first, which is to test whether the number equals 5 and if so to bash it to zero. @1230 That is not going to be so great because you're going to see the value 5 and then the value zero unless you're very careful. So let's do it the smart way which is simply to ask for the remainder |
es:@1230 |
@1245 after dividing by 5. |
es:@1245 |
By the way, I've disconnected this so it can't update anymore. It's stuck. Now I'm going to say: .. how about "mod 5" ? Here's the mod object coming at us. @1260 Now we have our wonderful counter that goes from 0 to 4 like that. Now, in fact, if we want to we can do the same operation as here except now we can actually use a tabread |
es:@1260 |
@1275 without a ~, and look at it: |
es:@1275 |
Now we're looking at the five values of the table and I didn't set the range of the table to be, you know, sequencer-type range, so it's just what you're seeing. @1290 Yeah? Student: So that's all mod is, a conditional checking the number? |
es:@1290 |
Well, mod itself is an arithmetic operation. What it is the remainder that you get when you divide the left inlet @1305 by the right inlet. It works in this case because zero, one, two, three, and four give themselves, but five give zero. Student: Is it like "modulus" in java? |
es:@1305 |
Might be. I don't know Java, but could very well be the same thing. @1320 There's only one correct way to do it. It's almost like the percent sign operation in C, except the percent sign operation in C is wrong because |
es:@1320 |
@1335 if you say "-5 % 3" you should get +1 and instead it gives you -2. So mod actually does the mod thing, |
es:@1335 |
@1350 which I hope java's modulus does, but I suspect it doesn't. If you feed it -1, -1 divided by 5 gives you a remainder of 4. |
es:@1350 |
@1365 Why? Because: What's the biggest multiple of 5 that's smaller than minus one. Well, it's -5. Then you have to count up 4 |
es:@1365 |
@1380 from there to get to the actual number, -1, so the remainder is 4. Alright. That's mod. There is a mod~ . |
es:@1380 |
Oh, yes. This @1395 along with tabread and along with + come in control versions and they come in signal versions and there are times when you want to use the one type of thing and there are times that you want to do the other. |
es:@1395 |
@1410 Advantages to doing things in control land? Advantages, I can think of three right off the bat. Potential advantages for doing things the control way: One is that it is much easier to do things irregularly. |
es:@1410 |
@1425 For instance, if you want to count incoming network packets using netreceive, which I won't tell you about. Well, they come in and |
es:@1425 |
@1440 you might regard them as an event, such as an event or a bang. Hey, I'm clicking on the thing. I want to count mouse clicks, same deal. You don't know when they're going to happen, you don't know if they're going to happen at all, and you don't know how many you're going to get. That's |
es:@1440 |
@1455 the sort of thing you can do effectively using messages and less effectively using signals. OK. |
es:@1455 |
That's advantage number one. Advantage number two is that @1470 you can actually hook the things up to a number box and see them, whereas signals you have to work harder to see what they are because they're going by at 44,000 units per second or something like that. So it's not feasible just to put it |
es:@1470 |
@1485 into a number box and look at it. You either have to say print tilde or throw it into a table or an array and look at the waveform or something like that. |
es:@1485 |
So it's much more convenient to debug stuff here. @1500 Third thing is it's much easier to do things conditionally or, rather, it's _possible_ to do things conditionally, I guess I should say. Signals are always happening, but messages -- I haven't |
es:@1500 |
@1515 shown you the primitives for doing this yet -- but you can do things that can take messages and optionally respond to them or not depending on whether they obey certain conditions or whether other things obey certain conditions. |
es:@1515 |
That's a good @1530 thing to be able to do, which is, again, central to what computers know how to do or how people think about programming computers and which is much more appropriate to this regime of messages than it is to this regime of signals. |
es:@1530 |
@1545 So why bother with signals at all? Well, so that you can do computer music because in computer music you eventually have to make sound and that's signals. |
es:@1545 |
So this world <<signals>> is less flexible, but it is @1560 the correct place to be if you want to do something like have an oscillator. There is no osc that doesn't have a tilde. It doesn't make any sense really to do that in message land because it depends on having a sample rate in order to know what to do. |
es:@1560 |
@1575 Questions about this? |
es:@1575 |
So this is what "loop" looks like in some way of thinking -- both in message @1590 land and in signal land. And now that I've told you that, I want to go back... well, back sideways and start looking at tables again as sources of waveforms because |
es:@1590 |
@1605 it is time to start doing sampling. |
es:@1605 |
Sampling is actually no different from waveform oscillators except psychologically, but at times there are things that you want to do with samples that are more easily done using messages @1620 than using just a phasor that rips through things -- including I should say the next assignment, which I don't have the heart to show you because I don't think many of you finished homework 3. ... |
es:@1620 |
I'll show you homework 3 @1635 with the extra credit done correctly this time, at least an output so that you can see what you should be looking for. But Homework 4, at least to do the extra credit thing, I think you are going to really want to do it with messages and not with |
es:@1635 |
@1650 a steady going signal because there might be decision making to do. All right. So this is what this is, and I'm going to save this and then immediately start doing sampling. |
es:@1650 |
@1665 OK. So to do sampling, you will need some new objects. In particular, |
es:@1665 |
@1680 well, yeah you are going to need these two. The soundfiler ... I don't want to show you just yet how to do live recording into Pd because that's going to be another thing. It is going to be easier and anyway more urgent |
es:@1680 |
@1695 to learn how to get sound files in and out of arrays. |
es:@1695 |
I've shown you now I think four ways of getting stuff into arrays including reading from a text file. But of course when you're doing computer music, you're going to have these recorded sound files @1710 that will be in .wav format or .aiff format or whatever it might be. And you're going to want to get it into your array so that you can have them as waveforms -- so that you can play them as samples, say. |
es:@1710 |
So that is a fundamental thing that you might wish to be able to do, and so I'll show you @1725 how you will set about doing it. So let's save this. |
es:@1725 |
Actually both before and after I saved it. I want you to, enjoy the fact that it does live in a directory which here is going to @1740 be my Linux-style home/msp and whatever. And this directory is going to be where Pd looks for file names. You first saw when I used the read message to...arrays, in order to read a |
es:@1740 |
@1755 collection of ASCII numbers, or text numbers into an array. And the same consideration will hold here. The directory that I am in, I've already |
es:@1755 |
@1770 moved...sorry, I've already moved the sound file into the directory that we're in right now. |
es:@1770 |
Which maybe you'll see if I say open, except it only shows PD. Yeah I can't ask it to do all files. @1785 You won't see that. I could go figure out using the finder how to show you the directory contents. But anyway, let's just look at it. |
es:@1785 |
Alright. So we'll make an array, as we always do, as we often have. @1800 I don't know why I bother with that. I'm going to say, let's have 100,000 points. That's a little over two seconds of sound. And it going to be table, January 25th b. <<t1.25b>> Blah, blah, blah. |
es:@1800 |
@1815 OK. And of course, there's this bug where it forgets that I told it...that I wanted points. Don't know why, alright. |
es:@1815 |
Now, to read @1830 sound file into is done by a separate object. You don't pass a message directly to the, array. Instead, you make an object which is called, soundfiler. |
es:@1830 |
@1845 And you send it a message, which is "read" Again, and it's going to have the name of the file... That's the name of the sound file |
es:@1845 |
@1860 that I've got. Then it needs the name of the one or more arrays that I'm going to fill with...the contents of the file. ... |
es:@1860 |
@1875 Tada! So what I did what I just loaded the voice.wav thing in here. If you want voice. |
es:@1875 |
@1890 wav, it's in Pd. For you Macintosh users, you option-click on Pd and show package contents. And go looking in the documentation, there's a thing called voice.wav. Which is this file. Which is included in the Pd distribution, |
es:@1890 |
@1905 just so that some of the example patches in the Pd documentation will work. Also, so that you can have a sample sound file to do stuff with as you start to make patches, before you've worked out your microphone situation. |
es:@1905 |
@1920 The microphone situation is kind of miserable for people who own laptops. For reasons that you might already have discovered. For instance, you can't type and record at the same time because typing makes a very loud noise that goes |
es:@1920 |
@1935 to the microphone and things like that are bad. If you want to do stuff with microphones, give yourself some time to figure out what kind of microphone you need and buy it and how you're going to have to connect it to your computer. It's not going to just happen tomorrow. |
es:@1935 |
@1950 Soundfiler also takes messages to write the thing back to a file. |
es:@1950 |
It likes .wav files, which are the closest thing there @1965 is to a standard PCM (pulse code modulation) file format. It will only deal with PCM files. It doesn't know how to do .mp3s and stuff like that, which are data-reduced using proprietary algorithms. Well, you can find out what they are, but who wants to write the code to deal with that? |
es:@1965 |
@1980 And it will also deal with .aiff files, although .aiff files -- I'm frequently confronted with .aiff files, in one sort or another, where they've changed the header a little bit and Pd cannot |
es:@1980 |
@1995 deal with it anymore. So Pd is not as successful reading the .aiff, which are the Macintosh files, as it is reading the PC files. So if you can't read your file in just convert it to a .wav and it'll be perfectly happy to read it for you. |
es:@1995 |
@2010 The array has no idea what sample rate the thing is that it holds and, with that in mind, soundfiler |
es:@2010 |
@2025 actually ignores the sample rate of the file. A frequent beginner's error is to go off on the web and find some nice file of a dog barking or something, download it, verify it as PCM, but not notice that it's eight kilohertz. A lot of files on the web are eight kilohertz. |
es:@2025 |
@2040 Then if you try to play it at 44k1 it will sound some octaves higher than where you wanted it. Yeah? Student: Can you go to the properties of that table? |
es:@2040 |
Properties of that. @2055 Oh yeah. I should just sort of systematically do that, shouldn't I? So what I've got is Y is ranging from minus one to one and 100,000 points. So if you're operating at 44K |
es:@2055 |
@2070 this is a little over two seconds. The reason I gave it that number was because I happened to know that the sound file it's going to read in was a second and a half or so, so that was kind of a reasonable number of |
es:@2070 |
@2085 points to give it. |
es:@2085 |
Oh yeah. Let's get rid of this. Oh yeah. @2100 "Save contents": If I save the contents now there will be 100,000 numbers in the patch. The patch itself -- I don't know if you noticed, but they tend to be less than a kilobyte at this stage of the game -- so this would multiply the size of the patch by more than 10. |
es:@2100 |
@2115 So when I'm using sound files I don't save the contents. Oh yeah, let's save this. <<saving "3.sampling1.pd">> |
es:@2115 |
@2130 This is going to be three dot sampling one. We'll have many sampling patches; sampling is not just one thing. So now when I reopen this patch from nothing, there it is, but it doesn't have the sample anymore until I do this: <<clicks on the message to soundfiler>> |
es:@2130 |
@2145 Now, the thing I will urge you to do when you're doing this kind of thing is say "loadbang" <<connected to the message box connected to soundfiler>> so that when |
es:@2145 |
@2160 you open the patch the next time it'll open the patch and then the loadbang will say "bang" right when it loads and then it will read the table in. |
es:@2160 |
So this as a complete thing really should have two files. @2175 It should have voice.wav and it should have the patch. The patch shouldn't have voice.wav in it, which would be ugly and messy. Instead, the patch should be set up to read the thing in on load-up. Alright. |
es:@2175 |
@2190 So now that we have that, I'll just actually check that it happens. There it is. I guess your way of verifying that the thing really loaded instead of not is disconnect |
es:@2190 |
@2205 this and see that it's zero again. |
es:@2205 |
Or else if you believe it look at the dialogue window for the array. So this is getting sound files into arrays and, of course, we're doing that so we can act like a sampler. @2220 Alright. Sampling is reading out of the array, which, to start with, I'll do the bad way and then I'll do it the good way. So I gave you this harangue earlier about non-interpolating table |
es:@2220 |
@2235 look-up being a bad way of reading samples or tables and it was hard to actually hear the badness because I was using a sinusoid. |
es:@2235 |
It will be easy to hear the badness when I start using real sounds, I think. @2250 So here now is listening to this sound file, so what we're going to have to do is say "tabread~ t1.25b" . ( |
es:@2250 |
@2265 Not the file name --The name of the table.) OK. Now I'm going to give it a signal which ramps from zero to 100,000 in some appropriate amount of time. |
es:@2265 |
@2280 An easy way to do that... Let's do it wrong first. I'll put a number box here and then we'll listen to it that way. |
es:@2280 |
Just looking at it, this thing has an amplitude of 0.3, @2295 which might be loud in this room, so I'm going to multiply this by another 0.3 to drop it to about 0.01 -ish. It would be better if I did |
es:@2295 |
@2310 something controllable there, but this will do for now. And now we listen to a nice sample. |
es:@2310 |
@2325 What this means is take the 134th point of the table. That's right about here. If I want to hear what this is like after a second had passed I would have to put 44,100 in there. Here's the sound of sample number 44,100 and, yeah, my audio system doesn't like this very much. Alright. |
es:@2325 |
@2340 Yeah? |
es:@2340 |
Student: Is there any particular reason why if I renamed just a random wave file "voice.wav" and put it in a folder, would there be any reason for it to say it could not find the file, there's no such @2355 file or directory? |
es:@2355 |
Beginner's error would be the patch itself doesn't know what directory it lives in. So save the patch into the same directory. The patch should tell you what @2370 directory it is here. If it doesn't say anything there or says slash or something like that then it's looking in the wrong place and the way to fix that is to save it so it will know what directory it belongs to. |
es:@2370 |
@2385 That was a very useful question to ask, because that happens to about two thirds of people the first time they try to read a sample. If indeed that was the thing that just happened to you. [laughs] |
es:@2385 |
@2400 We'll find out. Otherwise, you belong to the other one third that got past that one and hit the next thing, whatever it turns out to be. |
es:@2400 |
So this is bad; you can't just @2415 do this <<mousing over the number>> [repeated booming noise] and expect to hear a nice continuous sound. Why, because you probably know this, but mice update from 50 to 100 times a second, depending on your OS and how hard you're mousing, |
es:@2415 |
@2430 and that's not going to sound like a continuous signal; it's going to just sound like a bunch of glitches. You could like that, of course. |
es:@2430 |
So what we have to do is do something continuous @2445 like this: Maybe we'll say line~ and feed it a message to... Let's see, I'll do this a variety of ways. |
es:@2445 |
@2460 First off, I'll do the stupid thing, which is feed it a message which says jump to zero and then slide to 100,000 |
es:@2460 |
@2475 over how much time. What is that in seconds if it's 100,000 samples? We'll find out: |
es:@2475 |
This is acoustics by the way, you should have learned this in @2490 acoustics class. My favorite calculator program. So what's 100,000 samples, which means we divide it by 44,100, and its |
es:@2490 |
@2505 2.2676 seconds long. If I were not doing this pedagogically, if I were just doing this, I would just make my patch compute this thing automatically, but that would be more boxes messing around |
es:@2505 |
@2520 on the screen, so I wanted to show you this way first. So I wanted to show you this way first. So the appropriate length of time to read from the beginning to the end of the table would be 2,268 milliseconds roughly. Not exactly accurate, but good enough |
es:@2520 |
@2535 for today. 2268. So now I go back here and say you have 2,268 milliseconds to do this. Then we get samples. |
es:@2535 |
@2550 That's "kicksy" KYXY96.5 in case you don't recognize it. |
es:@2550 |
It's KYXY96.5 with some announcer who was announcing some 10 or 15 years ago, so you probably don't recognize it. @2565 Now we'll just... Here's a thing that I've seen people get confused by. If you just say do that you don't get anything |
es:@2565 |
@2580 because the line tilde is currently putting 100,000 out. That's 100,000 volts if you were an analogue synthesizer. You would be arcing at this point. ... |
es:@2580 |
To slide from where it is to @2595 100,000 is basically to continue doing nothing or to continue putting out your 100,000 volts with no variation. So the correct way to hear it again is to go back to zero and then from there to ramp to 100,000 and you get the nice |
es:@2595 |
@2610 ramp. Sorry, it's a little loud. Let me turn it down a little bit. Alright? Now, either to clarify this or to further muddy it, |
es:@2610 |
@2625 depending on whether you personally find this clarifying or muddying, this will be different for different people, this is how you play it backwards. |
es:@2625 |
Let's go to 100,000, that makes the line jump immediately to 100,000, @2640 and then let's ramp to zero in 2,268 milliseconds. Alright. Then you have the other. Oh, and by the way, notice there was a good |
es:@2640 |
@2655 three quarters of a second of silence. It's reading the zeros at the end of the table. Alright. That's useful art. |
es:@2655 |
@2670 OK. Now is it clear to everyone why this is doing what it's doing? |
es:@2670 |
So in one way of thinking, the x-axis here is labeled from zero to 100,000. @2685 The y-axis is the voltage, which comprises the sound itself, and we're asking it to go from left to right and we're giving it an amount of time. So now if I want to play it transposed up by |
es:@2685 |
@2700 a factor of two, that's to say an octave, what would I change and how? Someone said something, but I didn't hear it ... The time! Yeah. So if you want to go twice as fast |
es:@2700 |
@2715 you do the same thing, but you do it in half the time. "1134" Look, all the digits are even. I don't know why. ... And now instead of this: [original "continuous soft and relaxing music"], we get this: "continuous soft and relaxing music [chipmunk-like]. .... |
es:@2715 |
@2730 All right? OK, and now we've basically got the sampler functionality. |
es:@2730 |
And I was telling you this was going to sound horrible. But I have to work harder at this to make it sound @2745 horrible, because actually dropping every other point of the sample that would cause fold-over, but that wouldn't cause the bad fold-over that would make you really think that I was doing something wrong. A good way to make it sound wrong, might be to go at one |
es:@2745 |
@2760 percent wrong speed, like this 2240, that's about a percent too fast, so |
es:@2760 |
@2775 here's the good sound: "continuous soft and relaxing" [volume/audio change] and here's wrong: "continuous soft and relaxing" [volume/audio change, same as before] . Can't hear the problem with it. "continuous soft and relaxing, continuous soft and relaxing" [volume/audio change, still same] . |
es:@2775 |
All right, I can't make it fail. Let's make it fail. OK, @2790 I'll make it fail. What we're going to do, is we're going to put an oscillator in here. |
es:@2790 |
The oscillator's going to have a nice decently high frequency, but not high enough to be painful to most people, I hope. And I'm going to not do it at full blast. I'll do it @2805 at only about .3-ish to have similar amplitude to the sound file. And then we're going to use the fabulous tabwrite~ object, |
es:@2805 |
@2820 and then we need a button to tell it to go. |
es:@2820 |
Yeah, here's a nice sinusoid. All right, @2835 now here's the good sinusoid: |
es:@2835 |
Oh my, that was horrible. Oh so even this is wrong, because this isn't the exact number. So once in about 2,000, @2850 no once in about 6,000 or 7,000 samples this is not working right, and you're even hearing that: And now if I push it a little further off, |
es:@2850 |
That -- @2865 that's the rate at which its dropping samples in order to get it done in a few milliseconds fewer, all right? And that is not, you know, they'd pay you for that in a club but they wouldn't pay you for that in a classical music concert. |
es:@2865 |
Right? @2880 OK, so this: ...could be a good reason to reach for this object here: |
es:@2880 |
Oh, ew! Isn't that horrible? That's me putting out ... I'm still putting out DC here, @2895 except that when I move this, the computer is having to redraw the table, which means putting out zeros because the operating system's getting hungry for samples. And, as a result, I'm hearing a huge |
es:@2895 |
@2910 discontinuity in the sound. [clicking] So that's bad. That would be a good reason to put this thing in a sub-window if I were going to do this during a show. All right, OK, so compare that to this |
es:@2910 |
@2925 let's see, I'm just going to get these, oh, you know what, I'm going to do this right in this one, which has all the good examples, <<changes tabread~ to tabread4~>> and then I'll make the bad one so you can compare it. |
es:@2925 |
@2940 The 4 <<in tabread4~>>, as you might or might not guess, means use four-point interpolation, which means put a cubic polynomial through the four points immediately surrounding the point that you're asking for to give you, theoretically, a more |
es:@2940 |
@2955 accurate estimate of where the function would be at that point if it were a nice four times differentable function. |
es:@2955 |
Anybody's guess whether it really should be such a thing. OK. Now @2970 I'm going to still want that and this. So here now is the bad result. Oh my. Here's the good one. |
es:@2970 |
@2985 Or here's the first error I had. This one. It's the one that made a few dozen errors a second. That's to compare with this. Alright. |
es:@2985 |
@3000 So interpolation is your friend. Four-point interpolation ... Yeah? Student: When did you put the sine wave in the table? |
es:@3000 |
When did I put the sine wave in? I used this network right here. @3015 So now if I want to get the sound file back I would do this. By the way, this is always playing right now, so you hear clicks when I change the table. You should probably have some |
es:@3015 |
@3030 way of muting the amplitude if you were doing this for real. Don't worry, you can make things arbitrarily complicated later to make it nice and clean. Then here's the sinusoid back. |
es:@3030 |
So the moral to this is "@3045 Use tabread4~ instead of tabread~ for reading audio data out of arrays if you want the result to sound clean." Then the other thing |
es:@3045 |
@3060 to be hyper aware of is it might be as dirty as goats and you don't even know it because the sound itself is complicated, so test your patch out with sinusoids first to verify that your patch actually does good things. Otherwise |
es:@3060 |
@3075 you might convince yourself that it sounds great, but it doesn't and you don't know it. |
es:@3075 |
Which is not a good state to be in. So it's better to apply @3090 stringent tests with very simple signals that you hear things clearly. In fact, now that I'm saying that, now that we've got the voice in here I'm not sure it's going to be audible in this room the difference between correctness and incorrectness. |
es:@3090 |
Here's incorrect. @3105 That's dropping the samples at the same rate and you don't even hear it. Maybe you can convince yourself that you hear it, but it even might be true that you're just imagining it. |
es:@3105 |
@3120 I don't think I can hear it at all. That's the wrong one. This is the right one. By the way, let's |
es:@3120 |
@3135 subtract them and we'll get only the error signal. So I'm going to take this one and give it an amplitude of -0.1 and this one an amplitude of +0.1 and start them simultaneously. |
es:@3135 |
@3150 [very soft sound "continuous soft and relaxing"] And there's an error signal for you. That was an aside. If you didn't understand that, don't worry about it. .... Questions about this? |
es:@3150 |
@3165 Yeah? Student: I missed the part where you came up with the third value for the message boxes. |
es:@3165 |
Oh, right. So the message box has two messages in it and it's describing a line segment. @3180 So it's describing a start point, an end point, and a time to do it in and the third value is the value of time over which you ramp. .... Yeah? |
es:@3180 |
Student: So with the previous sample, if you had more objects to go through, @3195 would the signals stay in synch? |
es:@3195 |
Oh, yeah. Right. Yes, if I put a few hundred objects on one side and then three objects @3210 on the other will the signal get faster through the three objects than through the few hundred? The answer is no. However, there are ways that I haven't shown you yet that you can accumulate delays without knowing it, so there's one particular thing to watch out for there. -- |
es:@3210 |
@3225 Which is when you make non-local signal connections sometimes you don't know that they're instantaneous. ... Yeah? Student: Can you explain the interpolation? |
es:@3225 |
Yeah. I should have started out by doing that. @3240 Back in the '70s when I was studying algebra they taught you this because you had to learn how to read tables of logarithms in order to know how to multiply numbers because people didn't have calculators. |
es:@3240 |
@3255 People might be forgiven for not knowing this widely now. Interpolation is the following thing: |
es:@3255 |
You've got a table of logarithms and it's crammed in the last five pages of your Algebra I text or something like maybe Algebra II. @3270 You really want a logarithm to six decimal places of accuracy, say. So how do you do it? You're not going to get it just by looking the lines up in the table because just looking at them one next to the other they're changing by .1 |
es:@3270 |
@3285 percent, say, from each one to the next because there are only perhaps 10,000 of the numbers printed for you. And what you want is one that's between those two numbers. So what do you do? Well, you know how far it is between the two numbers so you just draw a straight line |
es:@3285 |
@3300 segment between them. And you know how far along the segment you want to be and then you can use some elementary algebra or geometry to figure out then where that line segment would be at the exact point that you asked for. |
es:@3300 |
@3315 So in the memory -- and this is in general true about any digital signal processing -- you only know the value of the function of the signal at specific discrete points and sometimes you want to know what it would be between two of the points. |
es:@3315 |
@3330 So how you do it is you say well we'll put a line segment or something like that between the two points of the table and if we're 0.3 of the way between this point and the next one we'll take this value plus 0.3 times the difference from this value to that value. |
es:@3330 |
@3345 OK. Then it gets better because that works OK, but that doesn't work well enough so that you can guarantee that the error's inaudible -- for say, for a |
es:@3345 |
@3360 sinusoid going at a kilohertz in a very good studio. |
es:@3360 |
So you could say: "I know it's between these two points, but I actually want to put a parabola, a @3375 second degree polynomial, between three points to estimate not just the slope between the two points, but also the second derivative." And that might or might not give me an even more accurate value. |
es:@3375 |
@3390 That is called the order of the interpolation -- the degree of the polynomial you're using. |
es:@3390 |
tabread4~ is four-point interpolation, which I think is correctly called third order, which is to say it puts a @3405 cubic polynomial through the four surrounding points surrounding whatever non-existent point you've got. That's what tabread4~ doing for you. |
es:@3405 |
@3420 If you look in the book -- I don't want to go fishing through it right now to find it -- you'll actually find quantitative estimates of how high a frequency you can store in the table and get decent values using tabread4~. |
es:@3420 |
It's actually @3435 not really good enough even though I can't prove it to you in this room. As soon as the period of a sinusoid is at least 32 points here <<in the memory>> it's pretty much a guarantee that tab read four tilde will give you inaudibly |
es:@3435 |
@3450 small errors. But the Nyquist frequency, which is the highest frequency you could possibly represent, has a period of two points and at the Nyquist, even throwing a cubic thing through the four nearest points has trouble giving |
es:@3450 |
@3465 you the values correctly. They'll be incorrect. The good news is that people don't have signals that are loud at the Nyquist frequency very often. So that's not very often a serious problem. |
es:@3465 |
Student: @3480 What does that criterion of 32 samples mean in terms of audio frequencies being OK? |
es:@3480 |
Let's see. So if the period's 32 and you're at 44 kilohertz that means components up to about 1500 Hz will have truly inaudibly small error and components above that will actually fold over @3495 gradually more and more until you get up to 20 kHz, the fold over is getting quite significant. |
es:@3495 |
And if that's a problem, which is usually isn't but could be, @3510 then take the signal and re-sample it, so that its true sample rate isn't 44K1, but it's 196K or a million. I mean, you can sample as high as you want. And, so, you can actually get arbitrarily low errors using |
es:@3510 |
@3525 oversampling here. But, it turns out that at that point, oversampling is a better strategy than adding more points to interpolate. ... I think. In most cases. |
es:@3525 |
Me, in practice, I just use tabread4~ @3540 and don't worry about it. Which is of course what I just told you not to do. But, you should actually check it, and all that kind of stuff. Student: Is there a tabread5~ |
es:@3540 |
No, there isn't. Life's too short @3555 for that one. If you look at the formula for cubic polynomial interpolation, it's already about a line long in C. And the one for 8 points is, you know, a paragraph long. It would be a lot of computation, and it would be a |
es:@3555 |
@3570 serious head-scratcher. And, by the way, at that point, you get into serious questions whether doing a polynomial interpolation is better than doing something else. And so, then, you would have to have all sorts of different flavors and interpolators, some of which were better suited to some frequency ranges |
es:@3570 |
@3585 than others, and then you would be in a morass of horrible detail. |
es:@3585 |
So, my advice is, just don't go there. And I don't even know if anyone has made higher-order interpolators @3600 for PD. If you want one, go looking and if you find one, tell me, because I'm curious too. |
es:@3600 |
All right. So, @3615 I think that's all I better tell you right now about sampling. I'm going to tell you a bunch more later. Oh, I should say one small thing about this, which is, just to tie this |
es:@3615 |
@3630 to what we've seen earlier. This is the message-based way of sampling, which lets you do this kind of stuff. |
es:@3630 |
I just whacked it a few times. Every time I whacked it, it was already running through the sample, but I just @3645 made it stop and go back to the beginning, start over again. So, that's kind of ... that would be appropriate, to for instance, you want to play something every time the network packet comes in or a key goes down on a clavier keyboard, or something like that. You can also drive these things |
es:@3645 |
@3660 in the other way. Which is to say, make the whole thing be a signal network. Like this: Now I need room ... |
es:@3660 |
And I really want this to be part of the same window, for @3675 pedagogical reasons. So I'll just make the window absurdly big. OK, so, another thing that you can do is, take the tabread4~ .. |
es:@3675 |
@3690 and all right, I'll do this. And let's just read it with a phasor, just like I showed you how to do with tables. Of course, you don't really do this, let's see, |
es:@3690 |
@3705 let's give it a frequency, which will be a number, to do this. This, of course, will give us not a lot of anything, because it will be reading the first point of the table over and over again, which gets us nowhere |
es:@3705 |
@3720 until we start multiplying it by something. |
es:@3720 |
And now, just to remind you, if I give you a phasor that goes from zero to one, but I want a phasor that goes from A to B, the thing that I do is multiply by @3735 the size of signal that I want, (B - A), and then add A. Right. So we need now to multiply. That's what I need to do, is rearrange this, so we'll multiply it by something, and I'll just have a number box to decide what, and then we |
es:@3735 |
@3750 will add something ... And now, for instance, if I |
es:@3750 |
@3765 want to say, OK, we'll do 5000 points worth: [sound] That's the "c" out of "continuous." If I want to change where I am ... |
es:@3765 |
Oh, let's go faster. ... @3780 Now, if I want to change where I start, I change this number. [sound] All right. Or in fact |
es:@3780 |
@3795 I could just mouse-over this number box. OK, now let's make this shut up. Actually, I should say, these numbers are in samples, right, because |
es:@3795 |
tabread4~ needs its input in samples, and number boxes @3810 operate as ... they're good for values around zero to 1000 -- because there's a pixel per number. |
es:@3810 |
So, it's a good idea when you're doing this to rearrange the number boxes, by multiplying by some suitable number -- which @3825 this morning anyway, seemed like 100 was a good number. Let's do that. And now we have a much better, much more mousable little sampler. |
es:@3825 |
@3840 OK, so ... |
es:@3840 |
all right, oh, wait. Man. Sorry, but that was wrong. @3855 I want to do it on this side <<left inlet>> -- and by the way, I've polluted the value of 100 in that box, so I'm going to retype the number to make sure it still works. |
es:@3855 |
@3870 [sound] |
es:@3870 |
@3885 OK, enough of that. So, all right, there might be some cleanup work to do if you want to play this in a classical music setting. But, so, what we're doing now is, this <<message network>> |
es:@3885 |
@3900 is the same thing as this <<signal network>>. ... [sound] except that here, it's entirely a signal network. It's a phasor tilde, which is simply scrubbing over and over and over again. It's not going to wait for me to get a message box at this point, it's automated. It's less flexible, |
es:@3900 |
@3915 but at the same time, it's... Well, it's easier to put together and it's easy to do things like change the frequency in the middle of a segment. Like here <<in the message version>> I wouldn't do something like, say, |
es:@3915 |
@3930 have it go up in frequency as it is going through. -- I could, but it would be a lot of work. Here will be easy, I'll just say, let's do this in a half -- once per two seconds -- and we'll say, let's start with a zero, and it will range over |
es:@3930 |
@3945 two seconds <<88200 samples>> -- oh, but I have it in hundreds so that's 882. <<output of the number-box is multiplied by 100>> [Sound ] |
es:@3945 |
So now I can ... <<changing the frequence of phasor~>> ... @3960 And even backwards: Now this would be harder to do with the message boxes. [Sound] |
es:@3960 |
@3975 OK shut it. All right. So that's just the different thing, that's just a different way that you might want to do it. |
es:@3975 |
@3990 And sometimes you want the one and sometimes you want the other. Frequently and unfortunately you might want aspects of one and aspects of the other and you will have to make a difficult decision about which path to take |
es:@3990 |
@4005 and some aspects to what you're doing will be easier and there're others will be things that you wish you and the other regime to be able to do. |
es:@4005 |
And that is, as far as I can tell just sort of a fact of life about computer music. All right, @4020 so it's clear what the distinction is that I'm making. And this one you could change what it is doing in midstream easily but you couldn't jump it back to the beginning... well you can actually because it just bash the phase of the phasor ... but there would be things that will be harder to do this way... |
es:@4020 |
@4035 And there are things that will be harder to do the other way... All right, let me then go back, oh what I want to do is ask for... Well just to make sure that you hear the |
es:@4035 |
@4050 Assignment 3 which is due Thursday and understand what's going on there. Then I'll show you Assignment 4 not to demoralize you but in order to show you why I'm showing you all this. |
es:@4050 |
Let's see, Why don't I do it in the opposite order: Let me show you the Assignment 4 really quickly because I will show it @4065 to you again in more detail later. And then go back to Assignment 3 ... So I'm going to save this and... and close it... and open... And look for: |
es:@4065 |
@4080 Homework 4 is just to... Oh, it doesn't work! Oh because I had a table named "pitches" inside here. All right that means I have to close somebody |
es:@4080 |
@4095 ... this one, no... this one... and this... many to close... Let's close everything. |
es:@4095 |
Oh I have two copies of this open. Wonderful work! <<closes one>> ... Does it work now? @4110 Alright. So we're making the poor radio guy sing a little boogie. |
es:@4110 |
Alright, this is really stupid, but I tried to make it sound good @4125 using a very simple set of objects and couldn't. I could either make it hard to do or else I could make it sound bad and I decided to make it sound bad so it wouldn't be terribly hard to do. If you want it to be hard but sound better ... |
es:@4125 |
@4140 What's bad about that? Well, a lot of things are bad about that. |
es:@4140 |
Here's an alternative thing that sounds a lot better, but is much harder to do, which is @4155 to arrange that it actually make four copies of the sound for every pitch of the boogie -- which is going to require synchronization. Then you get this: [sound] |
es:@4155 |
@4170 So that's a proper sampler in some ways and that will be harder to pull off then just making the thing loop at different speeds, which is the basic homework homework. |
es:@4170 |
@4185 So think about how you want to get there and now I'll go back and play you the other homework assignment, which is really the one due next Tuesday. Oh, yeah? Student: Is that boogie patch going to be on the website? |
es:@4185 |
Well, no ... because this implements it, @4200 so this is my secret now on how I did this. What I'm going to do is put the description of how to do it, like the other homework: I put up the description of what I want the thing to do and sound file showing how it sounds when you've done it right |
es:@4200 |
@4215 and then I make you work out the details to make it work. |
es:@4215 |
Otherwise you just copy and paste the patch and turn it in. So here's the homework for this time, which @4230 also comes in easy and hard forms, but they're actually part of the same patch this time around. Is it this one? [sound] Yeah. I played you this already, |
es:@4230 |
@4245 but I didn't have the extra credit working quite correctly. This is just eight notes. By the way, |
es:@4245 |
@4260 since bringing this out, I told you how to do mtof to convert |
es:@4260 |
@4275 midi numbers to frequencies, but you can probably hear that these are not midi frequencies. |
es:@4275 |
I just made multiples of 110. These are harmonics instead. You don't have to figure out the melody -- Just get the effect and make @4290 your own wonderful little melody. I will say that it works better, as I discovered by trial and error, it works better if you keep the thing within an octave than if you have the thing flying all over the place because ... I don't know. Anyway, |
es:@4290 |
@4305 somehow the phasing effect is more effective if it isn't ... if the intervals when they're out of phase aren't too crazily big. Which means the melody itself has to be in a decently small range. |
es:@4305 |
@4320 This is within a major sixth I think. Yep that's streaming, that's Music 175. Oh and it's also History Of Electronic Music because it's phase music. OK |
es:@4320 |
@4335 here then is ... the stop button -- I should have labeled them. Here's the extra credit -- this is really cruelly difficult. Don't even try this unless you want to be frustrated. |
es:@4335 |
@4350 So here are the ideas: |
es:@4350 |
Take each one of the individual melodies and every third note of it should be a substantially different timbre. That's the same melody as di di di di di di. @4365 Plus at this rate ... |
es:@4365 |
But of course what you hear is [sound] , right. Which is every third one. So you actually hear a sequence of eight things going at this speed instead of the [sound] @4380 the real speed the thing's running at. |
es:@4380 |
OK, the way I did this without using stuff that I haven't shown you how to do: (The mute buttons are not working today at all.)... @4395 The way I did this is I had two different generators: one which was just a sinusoid and the other which had I think third and fourth harmonics and none of the zero-th harmonic (which you can do with cos~ |
es:@4395 |
@4410 and phasor~.) And then if you want to shut it up rather than try to multiply it by a thing that ramps down to zero --which would be hard because it's driven by a phasor -- I just bashed the frequency to zero to make it quiet. |
es:@4410 |
@4425 So each one of them has a frequency that is zero when I want it to shut up and non-zero when I wanted to hear that one. And that's why it sounds so ragged. Those popping sounds that's the sound of a sinusoid or another simple spectrum suddenly |
es:@4425 |
@4440 having it's frequency bashed to zero. You can't really do that. And then make two of those and make them do the same phasing thing.... Let's see, I shut it up and I think |
es:@4440 |
these things two will @4455 start in phase if I just start it up -- OK like that. (No! ... sorry).[sound] So now you can even hear this |
es:@4455 |
@4470 at this speed or actually can hear it at this speed. And you have phasing effects going on in both at both speeds. [sound] |
es:@4470 |
@4485 And so it takes 30 seconds for it to repeat or come back to the initial phase. |
es:@4485 |
@4500 There it is now. ... Oh, there it is. I think. Not sure. Alright. |
es:@4500 |
@4515 If you can do that then you might have something that you enjoy listening to. Also, if you play this over your computer speakers you won't hear those glitches quite so badly because they are low frequency and your little half inch computer speaker won't play that. |
es:@4515 |
That's a @4530 better description of what the assignment is than I gave you last Thursday. This is all up on the website, but frequently I write something on the website and think it's totally clear and then when people read it they don't find it anywhere near as clear as I thought |
es:@4530 |
@4545 it was when I wrote it. So when that happens just ask, either by email or by asking in class. Questions about this? ... Yeah? |
es:@4545 |
Student: @4560 Can you do this with one table for each melody, or does it all have to be one table? |
es:@4560 |
The way I did it ... I wanted to do it in a way that would allow me @4575 to change the two numbers, so I had to work very hard with modular arithmetic. I actually did the whole thing with one eighth note table, but then I did trickery to make it drop two thirds or one third of the values out of the table |
es:@4575 |
@4590 to zero. You actually know the objects to do that, but it might take several hours to figure out. The thing you get out of that is I can now do 7 against ... |
es:@4590 |
@4605 And so on like that. Now it makes sense to make this number two. |
es:@4605 |
@4620 So if you're crazy like me you would do it that way and it would be much, much harder than just what you're suggesting -- which is just have two tables and make it easy. |
es:@4620 |
@4635 But you can have a lot more fun with this one. [sound] |
es:@4635 |
The original assignment @4650 doesn't have anything corresponding to that 2. Yeah, I did it in the same patch so it is working the same way. I think I can make this now be 5 and it should just work. |
es:@4650 |
@4665 No, it doesn't. Why not? Oh, it went to zero. ... Why does that happen? |
es:@4665 |
OK, yeah. @4680 And I figured out where in the sequence to start so that it was interesting with any number from 3 to 8. ... |
es:@4680 |
@4695 So I went much too far in messing around with this. It turns out to be very interesting to play with. But, yeah. Stop at ... what would you say, "Patch responsibly." |
es:@4695 |