1 00:00:00,644 --> 00:00:04,174 *** MUS171 #05 01 18 (Lecture 05) 2 00:00:05,844 --> 00:00:13,359 This is the familiar network where you have an oscillator with a controllable amplitude. 3 00:00:13,459 --> 00:00:18,869 Amplitude of course you control by multiplying the output of the oscillator, that's the easy way to do it. 4 00:00:19,159 --> 00:00:25,865 And the frequency of the oscillator you control by sending it the appropriate input. 5 00:00:26,440 --> 00:00:30,272 So here it is: [Tone] 6 00:00:30,272 --> 00:00:38,127 You can do them both simultaneously, maybe not. Wizard of Oz. 7 00:00:38,510 --> 00:00:53,646 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. 8 00:00:53,746 --> 00:01:02,077 "Delay" you can abbreviate as "del"; there are abbreviations for some of the most frequently used objects. 9 00:01:02,843 --> 00:01:06,483 And it's going to become important in this particular case. You'll see why. 10 00:01:13,189 --> 00:01:23,727 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. 11 00:01:24,685 --> 00:01:29,283 You don't want to necessarily slide to the note, if you want to start a note at the beginning of something. 12 00:01:29,646 --> 00:01:31,905 You might want to have it just jump there. 13 00:01:32,893 --> 00:01:37,693 So this is now a button that makes sure that we're at 440 when we turn this thing on. [Tone] 14 00:01:38,258 --> 00:01:45,882 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. 15 00:01:45,599 --> 00:01:51,246 It's still playing A-440, this oscillator is, but we don't care about it. 16 00:01:51,246 --> 00:01:53,505 So now a...[Tone] 17 00:01:59,435 --> 00:02:04,799 You do want one of those -- it also turns this off, right? 18 00:02:05,646 --> 00:02:09,740 So hit that button and turn it off. 19 00:02:10,588 --> 00:02:14,682 So you want it to slide to 440 and turn it off. 20 00:02:17,505 --> 00:02:19,588 Ah! That sounded horrible. 21 00:02:19,800 --> 00:02:21,570 Let's not do that! OK. 22 00:02:22,191 --> 00:02:34,938 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. 23 00:02:35,204 --> 00:02:48,217 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. 24 00:02:48,317 --> 00:02:50,183 Because, why? 25 00:02:50,283 --> 00:03:00,806 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. 26 00:03:01,071 --> 00:03:08,189 So now what's going to happen is every time I press the button ... yeah, I should do this 27 00:03:08,289 --> 00:03:09,039 (puts indicators that show the delays being triggered) 28 00:03:09,145 --> 00:03:15,094 Every time you press the button you start a sequence of delays going. [Tone][Over sound] 29 00:03:23,858 --> 00:03:35,968 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. 30 00:03:36,871 --> 00:03:44,626 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. 31 00:03:44,726 --> 00:03:47,070 If you changed your mind about what you wanted to do. 32 00:03:47,170 --> 00:03:56,524 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. 33 00:03:56,624 --> 00:04:04,332 If you decide that you want to connect to the delays successively one to the next, then that won't necessarily be true, 34 00:04:04,432 --> 00:04:16,336 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. 35 00:04:16,655 --> 00:04:21,967 So it is a good thing not to daisy chain your delays, but to have them all come off the same source like that. 36 00:04:22,232 --> 00:04:25,791 Now I'm going to make beautiful music. 37 00:04:28,234 --> 00:04:29,987 That's going to be, nothing? 38 00:04:30,093 --> 00:04:31,687 Oh, it's going to be a rest. 39 00:04:32,165 --> 00:04:34,236 ... Yeah, that'll suit fine. 40 00:04:34,449 --> 00:04:39,336 And then they'll go over there, and then they'll wait another second. 41 00:04:39,436 --> 00:04:40,823 I won't even put that delay in there. 42 00:04:41,460 --> 00:04:52,774 It should be 2500. And here it'll go back down to A and here we'll stop. 43 00:04:53,464 --> 00:05:02,866 And now, here's one of the things that's problematic about patching, and I will show you strategies later to deal with this: 44 00:05:02,813 --> 00:05:06,318 Your patches get messy after you've done a certain amount of stuff. 45 00:05:06,690 --> 00:05:08,443 Technique number one: 46 00:05:08,602 --> 00:05:09,824 Turn the font size down. 47 00:05:10,090 --> 00:05:19,119 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. 48 00:05:19,172 --> 00:05:22,094 I haven't shown you how to do that either, but that's all coming. 49 00:05:22,200 --> 00:05:26,502 And now if I have this right I'll have this this beautiful composition. [Tone] 50 00:05:30,805 --> 00:05:33,644 Ta-da! The marching demons in the Wizard of Oz. 51 00:05:33,886 --> 00:05:37,869 So this is how to make sequences that do things like control amplitudes and frequencies. 52 00:05:41,660 --> 00:05:48,673 Questions about this? -- What I did and why? ... Yeah?? 53 00:05:49,174 --> 00:05:56,021 Student: I forgot, for the first number in these messages is for frequency? There's a .03 there. 54 00:05:56,021 --> 00:05:57,691 Oh! OK, yes. 55 00:05:57,691 --> 00:05:58,693 That's the thing. 56 00:05:58,928 --> 00:06:02,504 These numbers, what they are depends on where you put them. 57 00:06:03,329 --> 00:06:06,134 Or rather, how they're interpreted depends on where you put them. 58 00:06:06,300 --> 00:06:10,810 So these numbers are frequencies by virtue of the fact that they're talking through this line to this oscillator. 59 00:06:10,910 --> 00:06:16,586 But these other numbers are amplitudes because they're talking and this line is getting multiplied by the oscillator. 60 00:06:16,531 --> 00:06:21,152 So even though the data goes down, in some sense the meaning bubbles up. 61 00:06:21,372 --> 00:06:25,167 Student: So it's on the line that goes amplitude and then time...? 62 00:06:26,047 --> 00:06:30,393 Right. -- Or value and time or target and time. 63 00:06:30,393 --> 00:06:38,534 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. 64 00:06:38,644 --> 00:06:42,770 Student: So it's another process that determines what they're lined up to. 65 00:06:42,870 --> 00:06:52,726 ... Yeah. Other questions? ... No? I'll leave this then and get onto fun topics. 66 00:06:52,836 --> 00:06:56,467 Not that this isn't a fun topic, but there are other fun topics. ... 67 00:06:59,162 --> 00:07:04,388 I'll just do a "Save As", remember the font size and start all over again. 68 00:07:06,259 --> 00:07:09,174 I'll just do three... table... Oh, no, wait. 69 00:07:09,274 --> 00:07:14,895 I neglected to tell you a bunch of things last time. 70 00:07:16,215 --> 00:07:23,421 Table oscillators first, and then units, psychoacoustic units which is MIDI units of pitch versus frequencies, 71 00:07:23,521 --> 00:07:39,098 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. 72 00:07:39,263 --> 00:07:51,750 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. 73 00:07:51,860 --> 00:07:55,766 OK, so we're going to do phase and tables. (saving "3.phaseandtables.pd") 74 00:07:56,591 --> 00:07:58,241 Do this one. 75 00:08:00,387 --> 00:08:07,648 And, we don't need any of this except the time for that, so. 76 00:08:08,473 --> 00:08:16,834 But we'll keep this around for this, just to be able to use it. 77 00:08:17,164 --> 00:08:22,775 But... here's where I'll stop, maybe on this. 78 00:08:23,545 --> 00:08:28,441 So the first thing to comment on is the following: 79 00:08:28,661 --> 00:08:34,162 There is an object, whose name is phasor, which generates phases. 80 00:08:34,327 --> 00:08:37,517 These are not useful things to listen to. 81 00:08:37,617 --> 00:08:40,983 In fact, let me prove to you this is not useful to listen to by playing it.[Tone] 82 00:08:41,468 --> 00:08:42,468 This is a bad sound. 83 00:08:42,743 --> 00:08:50,279 The reason is that it sounds like a mosquito is what's called fold-over. 84 00:08:50,499 --> 00:08:52,369 Well, there are several reasons it sounds like a mosquito. 85 00:08:52,644 --> 00:09:03,536 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. 86 00:09:03,591 --> 00:09:17,343 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. 87 00:09:18,168 --> 00:09:26,640 What it sounds like is just not exactly a stable quality of the signal. 88 00:09:27,410 --> 00:09:29,005 It sounds like it's fluttering a little bit. 89 00:09:29,105 --> 00:09:31,150 That is fold-over. 90 00:09:31,920 --> 00:09:39,236 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. 91 00:09:39,291 --> 00:09:46,993 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. 92 00:09:49,193 --> 00:09:53,319 So now why am I showing you this, then? 93 00:09:53,374 --> 00:09:56,894 Because you use it to do things like look up wavetables. 94 00:09:57,664 --> 00:10:02,395 To show you this, I have to get out my array so you can see what's happening. 95 00:10:02,505 --> 00:10:03,660 I'll do that now. 96 00:10:03,990 --> 00:10:07,181 Sorry this is getting repetitive, but it is what it is. 97 00:10:10,591 --> 00:10:11,746 I'll call it 98 00:10:12,021 --> 00:10:14,717 (the Array) "array.1.18a" 99 00:10:15,047 --> 00:10:19,668 And then just going to use a nice tabwrite~ write it. 100 00:10:20,768 --> 00:10:25,883 Wow. I shouldn't really have given a long name, should I? 101 00:10:25,983 --> 00:10:28,029 "array.1.18a" ... 102 00:10:28,129 --> 00:10:35,565 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. 103 00:10:35,730 --> 00:10:38,810 I'll show you a better way later, but that will wait. 104 00:10:38,920 --> 00:10:52,177 So now, one of the things the phasors do that makes ...oh! Duh! I thought it was me. 105 00:00:00,000 --> 00:00:00,000 It actually was me but at a deeper level. 106 00:10:55,588 --> 00:10:58,173 Here's a crucial thing to get: 107 00:10:58,503 --> 00:11:00,924 Here's a sawtooth wave... 108 00:11:01,804 --> 00:11:04,719 notice how there are bad kinks in this? 109 00:11:04,884 --> 00:11:06,150 That's actually graphics. 110 00:11:06,315 --> 00:11:18,086 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... 111 00:11:19,462 --> 00:11:29,803 Since we're at 44,100 points per second, 440 Hertz means how many samples per cycle? 112 00:11:30,848 --> 00:11:32,774 100 and a fraction, I think, if I'm doing this right. 113 00:11:32,939 --> 00:11:35,754 (41,100 samples/second)/(440 cycles/second) = 100.22 samples/cycle ) 114 00:11:36,404 --> 00:11:38,274 So it's (a cycle is) about 100 samples long. 115 00:11:38,714 --> 00:11:43,115 Oh yeah, it's about a hundred samples long 'cause the table's about a 100 samples big. 116 00:11:44,435 --> 00:11:52,136 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. 117 00:11:52,356 --> 00:11:53,952 (A cycle is usually 100 samples but sometimes -- approximately every fifth cycle -- it's 101 samples.) 118 00:11:54,282 --> 00:12:01,213 It's not a decent periodic signal, really, it's a sawtooth wave being represented digitally and it sounds bad. 119 00:12:02,258 --> 00:12:10,564 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: 120 00:12:10,784 --> 00:12:17,935 Phasor and cosine are both objects you haven't seen yet. 121 00:12:18,155 --> 00:12:28,937 The cos takes whatever goes into it and reports its cosine, or outputs its cosine. [Tone] 122 00:12:31,852 --> 00:12:33,393 And that's when you get this kind of thing: 123 00:12:36,088 --> 00:12:37,848 That's a nice sinusoid. 124 00:12:41,754 --> 00:12:47,310 So your cosine is not a sine, because cosine is the simple function and sine is the complicated function to deal with. 125 00:12:47,695 --> 00:12:50,775 There's only one wavetable, so it became cosine. 126 00:12:50,875 --> 00:13:00,952 With an oscillator, really, you've seen this as osc~. The osc~ is in some sense equivalent to (phasor and cosine). 127 00:13:01,052 --> 00:13:10,578 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. 128 00:13:10,678 --> 00:13:23,945 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. 129 00:13:24,000 --> 00:13:28,841 And I happened to click it just at a moment when it was going from 0 to 1 in the space of the window. 130 00:13:29,061 --> 00:13:32,857 But if I do it again, you'll see in fact that it's just moving between those two values. 131 00:13:33,077 --> 00:13:34,507 That was an accidental click. 132 00:13:38,082 --> 00:13:41,933 Now, this is interesting because you don't have to use cosines. 133 00:13:42,098 --> 00:13:44,298 You can use other waveforms. 134 00:13:44,683 --> 00:13:47,874 And what would be another good waveform? 135 00:13:48,149 --> 00:14:05,311 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: 136 00:14:05,476 --> 00:14:13,398 Multiply the phasor by two so that it doesn't sweep from 0 to 1, It sweeps from 0 to 2. 137 00:14:13,398 --> 00:14:22,254 And then, when I connect that, you hear [Tone] the octave. 138 00:14:23,244 --> 00:14:26,160 So, there's twice as fast as this. [Tone] 139 00:14:26,435 --> 00:14:29,295 Well, "twice as fast," that might be confusing. 140 00:14:29,460 --> 00:14:33,476 What's really happening is, think of this as a function. 141 00:14:33,576 --> 00:14:43,817 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. 142 00:14:43,917 --> 00:14:48,713 As the phasor's output goes from 0 to 1, this goes from 0 to two and so this thing goes through two cycles. 143 00:14:48,713 --> 00:14:51,628 So, you're looking up the second harmonic. 144 00:14:52,398 --> 00:14:59,275 So, now you can do groups of harmonically related sinusoids. 145 00:14:59,440 --> 00:15:13,082 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. 146 00:15:14,402 --> 00:15:20,838 This is a very simple ... What's the right word? 147 00:15:21,168 --> 00:15:40,256 ... 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. 148 00:15:42,456 --> 00:15:43,996 Phasor has memory. 149 00:15:44,106 --> 00:15:47,352 It has to remember its phase from sample to sample. 150 00:15:47,572 --> 00:15:48,892 So, it is an effective integrator. 151 00:15:49,277 --> 00:15:55,933 The frequency that you put it tells it how much it's going to add to each previous sample to make the next one. 152 00:15:57,253 --> 00:15:59,894 cos~ doesn't have any memory. 153 00:15:59,894 --> 00:16:04,129 It's just a pure function that takes whatever you put in and puts something out. 154 00:16:04,294 --> 00:16:11,610 So, phasor is the real oscillator here and cos~ is a wavetable that the oscillator is indexing. 155 00:16:12,656 --> 00:16:23,327 And furthermore, this combination of (phasor and cos~) is what you previously have known as osc~. All right? 156 00:16:23,822 --> 00:16:26,243 Now, I told you that so I can tell you this next thing: 157 00:16:28,058 --> 00:16:29,763 You can make your own tables up. 158 00:16:30,643 --> 00:16:34,164 Here's where, at least in some respects, things start to get fun. 159 00:16:34,384 --> 00:16:38,894 So, how am I going to do this so it's in the right space? 160 00:16:39,830 --> 00:16:42,690 There, I can't see that so I'm going to cheat a little bit. 161 00:16:42,965 --> 00:16:48,576 I'm going to make a window as big as I possibly can so I can keep this font. 162 00:16:49,841 --> 00:16:52,702 That will hopefully make something that can be understood. 163 00:16:53,582 --> 00:17:04,363 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. 164 00:17:10,029 --> 00:17:16,300 ... And this is now going to be a table, "tab.1.18" 165 00:17:16,355 --> 00:17:19,711 -- Sorry. That's a bad name. Everything is bad about this ... 166 00:17:19,811 --> 00:17:24,111 Here's the graph. Yep. We're happy. 167 00:17:25,817 --> 00:17:27,027 Everything is good. 168 00:17:27,192 --> 00:17:31,482 Now, last time I did this, I forgot that I asked you to do the points instead of polygons. 169 00:17:31,702 --> 00:17:33,573 Points. So check that we did. 170 00:17:33,738 --> 00:17:35,498 I forgot, OK. 171 00:17:36,488 --> 00:17:40,724 Now, we have something which we can edit and it's just a bunch of numbers. 172 00:17:41,274 --> 00:17:46,335 8 of them. 173 00:17:46,830 --> 00:17:52,606 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. 174 00:17:52,771 --> 00:17:54,366 There are other ways. 175 00:17:54,421 --> 00:17:56,126 You can have text in a file. 176 00:18:03,662 --> 00:18:05,037 You can, if you want to, save the properties and somewhere in here it gives you the opportunity to... 177 00:18:06,358 --> 00:18:08,063 What does it do? 178 00:18:08,448 --> 00:18:09,768 What does it allow you to do? 179 00:18:09,868 --> 00:18:11,418 Edit this in by... 180 00:18:11,693 --> 00:18:13,124 Oh, got 'em .. where am I now? 181 00:18:13,784 --> 00:18:15,654 I'm looking for features that isn't there -- OK. 182 00:18:15,764 --> 00:18:19,670 I'll show you how to get numbers in there in a good way later. 183 00:18:19,780 --> 00:18:21,705 That's going to be a whole other thing. 184 00:18:21,870 --> 00:18:25,610 So, I just put a waveform in here. 185 00:18:25,710 --> 00:18:27,536 Now, what I can do is say, "Oh. 186 00:18:27,371 --> 00:18:30,231 Let's listen to it by..." 187 00:18:33,917 --> 00:18:36,667 Some pedagogical sense tells me I should do this first. 188 00:18:37,107 --> 00:18:44,863 We're going to read out of the table and the table is going to be "tab.1.18a." 189 00:18:45,523 --> 00:18:48,219 Notice, I did not put a tilde in. 190 00:18:48,384 --> 00:18:52,730 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. 191 00:18:52,950 --> 00:18:56,415 And then, I'm going to add a tilde and we're going to be operating with signals. 192 00:18:56,415 --> 00:18:58,395 So, on that 193 00:19:00,376 --> 00:19:02,961 Input number ... and beside it 194 00:19:09,232 --> 00:19:12,312 So, I'm using a Macintosh keyboard on a Linux machine. 195 00:19:12,643 --> 00:19:16,823 The little Apple key doesn't do anything in Linux. 196 00:19:16,923 --> 00:19:18,583 It doesn't think it's an Apple. 197 00:19:18,693 --> 00:19:23,919 So, I give it numbers like 0and it gives me this value. 198 00:19:24,019 --> 00:19:28,320 I give it a number 1 and it gives me this value and so on like that. 199 00:19:28,485 --> 00:19:32,831 And now, I can just go sweeping through the thing looking at the values in the table. 200 00:19:32,776 --> 00:19:35,471 So, we've got storage. 201 00:19:38,551 --> 00:19:42,292 Not only storage, but storage of as many numbers as you want to put in the array. 202 00:19:43,007 --> 00:19:46,858 Student: How come when you go negative three, it still gives you a value? 203 00:19:46,968 --> 00:19:48,453 Yes, thank you. 204 00:19:48,288 --> 00:19:52,744 What happens when I go off the end of the table is, it says, "Well, that's OK. 205 00:19:52,844 --> 00:19:56,484 I'll just give you the closest point to what you had." 206 00:19:56,649 --> 00:20:03,690 So, in general, Pd's approach to errors -- this is not good computer science -- is it just puts guardrails on everything. 207 00:20:04,185 --> 00:20:06,000 So, if you divide by 0, it doesn't give you an error. 208 00:20:06,100 --> 00:20:12,712 It just gives you 0. If you try to read off the (end of the) array .. Actually, there's several things it could have done. 209 00:20:12,812 --> 00:20:15,077 It doesn't give you an error because then you wouldn't hear anything. 210 00:20:15,177 --> 00:20:18,652 It's better to hear something that's wrong than not to hear anything. Maybe. 211 00:20:19,698 --> 00:20:28,829 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." 212 00:20:29,654 --> 00:20:33,505 That (wraparound) is done using a different object in Pd. 213 00:20:34,000 --> 00:20:40,601 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. 214 00:20:41,096 --> 00:20:46,927 Instead, it simply says, "If you're between 0 and 7, it will read the value out of the table. 215 00:20:47,202 --> 00:20:51,712 And if you're in excess of 7 or below 0, it will simply give you the last or the first value." 216 00:20:53,198 --> 00:20:54,628 Which is good enough for us right now. 217 00:20:54,628 --> 00:20:58,093 Furthermore, if I give it a number like, let's see... 218 00:20:58,193 --> 00:21:05,795 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. 219 00:21:05,795 --> 00:21:08,270 That's the modular arithmetic way of counting. 220 00:21:08,325 --> 00:21:12,286 The other thing is, if I give it a half, what should it do? 221 00:21:14,871 --> 00:21:18,722 That's a trick question on two levels. ... ... Yeah?? 222 00:21:18,832 --> 00:21:21,142 Student: You can give it a 1, possibly. 223 00:21:21,307 --> 00:21:22,957 Or you can give it less than 1? 224 00:21:23,067 --> 00:21:24,662 Well between this and this. 225 00:21:24,882 --> 00:21:33,629 So, you could just do what you said, which is to say, just call it 1 or just call it 0. 226 00:21:33,739 --> 00:21:41,715 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? 227 00:21:42,650 --> 00:21:44,410 Another thing that... ... Yeah?? 228 00:21:44,520 --> 00:21:46,336 Student: Could it do interpolation? 229 00:21:46,436 --> 00:21:48,536 Another thing it can do is interpolation. 230 00:21:48,646 --> 00:21:51,891 But then, the question is, how many points of interpolation should you do? 231 00:21:51,946 --> 00:21:56,237 And if it's two points, there's really only one good interpolation algorithm. 232 00:21:56,072 --> 00:22:02,618 But when you have four or 8 points, there are several different ways of interpolating that have different properties. -- 233 00:22:02,718 --> 00:22:04,873 So, it just doesn't interpolate. 234 00:22:04,983 --> 00:22:12,685 If I give it numbers between 0 and one, it declines to act smart. 235 00:22:12,785 --> 00:22:20,386 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. 236 00:22:20,496 --> 00:22:26,602 Student: So, if you were to go below this number now, does it round down or does it just round one of them up? 237 00:22:26,987 --> 00:22:33,753 It rounds down. Oh, yes. There's no memory again so it doesn't know what I asked it previously. 238 00:22:34,028 --> 00:22:40,464 So, everything is as if there's no yesterday and it always rounds toward minus infinity. 239 00:22:40,574 --> 00:22:46,240 Actually, in table land, it only counts from 0. So it rounds towards 0, we'll call it. OK? 240 00:22:48,275 --> 00:22:50,255 If you wanted to... ... Yeah?? 241 00:22:50,355 --> 00:22:55,701 Student: Can you go and put the numbers in again? 242 00:22:56,196 --> 00:23:06,263 Yes. I'm trying to decide which is the best way to show you how to do that and which requires the least constructs. 243 00:23:06,538 --> 00:23:14,019 There are about five ways of doing it and I didn't realize I was going to have to do that today. 244 00:23:14,119 --> 00:23:18,749 So, I didn't think in advance about which one to show you so I'll get back to that. 245 00:23:19,245 --> 00:23:22,655 You will eventually want to be able to do things like throw values in a table. 246 00:23:23,755 --> 00:23:32,557 Oh! There's a tabwrite~ you can see here, so you can guess that there might be a tabwrite 'without a tilde'. But it's not. 247 00:23:34,152 --> 00:23:35,527 Remind me to get back to this. 248 00:23:35,692 --> 00:23:38,112 The tabwrite is not a tabwrite~ without a tilde. -- 249 00:23:38,112 --> 00:23:44,823 It doesn't turn out to make sense to just write sequentially through the table in message land so it works differently. 250 00:23:45,263 --> 00:23:47,079 So, here's tabread. 251 00:23:47,189 --> 00:24:05,341 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. 252 00:24:08,972 --> 00:24:11,117 Why don't I hear anything? 253 00:24:11,217 --> 00:24:14,363 Do I look surprised that I don't hear anything? 254 00:24:14,473 --> 00:24:16,838 I'm not trying to project surprise here. 255 00:24:19,534 --> 00:24:22,009 What are the values coming out of phasor? 256 00:24:23,054 --> 00:24:26,080 0 to 1, not inclusive. 257 00:24:26,180 --> 00:24:28,280 And what does tabread~ do? 258 00:24:28,280 --> 00:24:30,425 It rounds down to the nearest integer. 259 00:24:30,645 --> 00:24:42,032 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. 260 00:24:42,692 --> 00:24:51,823 So, if I want to hear something, I would take this phasor and multiply its output by the size of the table. 261 00:25:01,945 --> 00:25:03,815 Oh. Here's a thing: 262 00:25:05,741 --> 00:25:10,856 You will learn various ways of making your patches not occupy a huge amount of space. 263 00:25:11,021 --> 00:25:18,337 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. 264 00:25:19,053 --> 00:25:25,929 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. 265 00:25:26,094 --> 00:25:29,944 This is the way that I normally do this when I'm working. 266 00:25:31,539 --> 00:25:36,490 Now, I'm going to say, "Multiply by the size of the table, please." 267 00:25:36,655 --> 00:25:38,525 Oh, I forgot to put a space. 268 00:25:44,576 --> 00:25:46,282 Oh, hey! Sorry. 269 00:25:46,282 --> 00:25:51,122 I need a tilde because I need a signal multiplier because there's a signal coming out of phasor~. 270 00:25:51,287 --> 00:25:55,303 And now, this is sounding better than the phasor. 271 00:26:00,859 --> 00:26:02,839 And I have a little timbre-editor. 272 00:26:05,700 --> 00:26:14,391 This is not beautiful sounds yet because there are discontinuities in the table. 273 00:26:14,556 --> 00:26:15,876 Let's turn this off. 274 00:26:16,041 --> 00:26:18,626 Student: Doesn't the table go from from 0 to 7, though? 275 00:26:18,626 --> 00:26:20,277 Instead of 8? 276 00:26:20,222 --> 00:26:21,652 Ah, thank you, right. 277 00:26:21,652 --> 00:26:23,302 So, why am I going up to 8? 278 00:26:23,357 --> 00:26:35,349 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. 279 00:26:35,449 --> 00:26:47,891 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. 280 00:26:48,111 --> 00:27:05,934 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. 281 00:27:06,099 --> 00:27:07,529 Is that clear? 282 00:27:08,189 --> 00:27:16,825 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. 283 00:27:16,925 --> 00:27:23,811 So you can think of the horizontal axis here as going from 0 to 8. 284 00:27:25,297 --> 00:27:40,644 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. 285 00:27:41,634 --> 00:27:53,186 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: 286 00:27:53,131 --> 00:28:00,337 8. This will change when we start interpolating the table, because then there will be fewer values that are useful. 287 00:28:02,207 --> 00:28:04,352 But that will happen later. ... 288 00:28:05,948 --> 00:28:09,798 Next thing about this, what if... 289 00:28:11,283 --> 00:28:13,979 There is one way of getting values into the table. 290 00:28:13,649 --> 00:28:15,739 But we can do it anyway. 291 00:28:15,794 --> 00:28:18,435 Let's put a sinusoid in here. 292 00:28:18,655 --> 00:28:21,955 I am going to be a little sloppy, but not terribly sloppy. 293 00:28:22,120 --> 00:28:37,137 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? 294 00:28:37,247 --> 00:28:57,435 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. 295 00:28:57,600 --> 00:28:59,306 That will be the frequency for an oscillator. 296 00:28:59,406 --> 00:29:04,256 And then I'm going to write that into the table. 297 00:29:10,692 --> 00:29:22,519 This is called "tab.1.18a" ... confusing, all of the above ... OK. Write it. 298 00:29:22,739 --> 00:29:27,745 And there is our nice sinusoid. 299 00:29:27,800 --> 00:29:31,375 Oh, that didn't appear... 'The first value in the table is hidden by the top border of the table.' ... 300 00:29:31,485 --> 00:29:48,483 Oh, yeah, I started this oscillator up and it had initial phase 0 and its frequency happens to be such that it repeats every 8 samples, so every single time I whack the button it will see it on a 64-sample boundary for technical reasons. 301 00:29:48,318 --> 00:29:51,508 And I am always going to see a phase that is magically 0 here. 302 00:29:51,453 --> 00:29:53,984 That is a weird accident. 303 00:29:54,809 --> 00:29:59,430 And now I have this nice table which will sound just like a sinusoid when I play it for you. [tone] 304 00:30:01,730 --> 00:30:02,730 ... NOT. 305 00:30:04,160 --> 00:30:08,616 This is in fact not a sinusoid but it is the function which is... 306 00:30:09,001 --> 00:30:14,282 the same points as the sinusoid every eighth of the cycle, but flat everywhere between it. 307 00:30:14,382 --> 00:30:17,527 And that is not very sinusoidal. 308 00:30:17,627 --> 00:30:29,904 If you did a Fourier analysis of this you would see mostly this nice sinusoid but then you would see a very jagged difference between that and the sinusoid it's imitating. 309 00:30:29,739 --> 00:30:37,495 And that jagged function would have lots of high frequency information in it which would sound like ... that kind of stuff. [tone] 310 00:30:37,990 --> 00:30:48,662 It is even better ... Because now if I go up in frequency. [more tones] -- I'm not going to make you hear a whole number of them; I'm not that bad. 311 00:30:48,662 --> 00:30:51,743 How would you make that better? 312 00:30:51,963 --> 00:30:54,713 Put in more points, maybe. 313 00:30:54,813 --> 00:31:04,284 So now we can say... Yeah, so let's get the "Properties" out. 314 00:31:04,174 --> 00:31:16,936 I'm going to say the number of points I want ... I don't know, 1,024 -- I am just making up a number. 315 00:31:16,771 --> 00:31:19,687 Oh, I don't have to use a power of two if I don't want to. 316 00:31:19,632 --> 00:31:27,443 Let's make it 1,000. That's just a bad reflex of mine. OK, 1,000 points. 317 00:31:27,543 --> 00:31:36,574 Now, the points that were there are still there and it's going to sound horrible if you listen to it. [original tone] 318 00:31:36,674 --> 00:31:38,004 It's just using the first table. 319 00:31:38,170 --> 00:31:40,370 Now I'm going to use 1,000 of them. 320 00:31:41,745 --> 00:31:44,770 First I am going to put a sinusoid in. 321 00:31:50,261 --> 00:31:52,582 OK, there is a good sinusoid with lots of points in it, right? 322 00:31:53,242 --> 00:32:06,114 And now I have to remember to change this 8 to 1,000. Now there's your sinusoid. [tone] 323 00:32:08,204 --> 00:32:10,184 Don't buy this sinusoid. 324 00:32:10,954 --> 00:32:21,076 This sounds good under our current listening conditions, but if you think about it, the error here is going to be on the order of 1,000 ... well it's going to... 325 00:32:21,406 --> 00:32:24,762 the phase is going to be off by a thousandth of a cycle or so. 326 00:32:24,541 --> 00:32:31,693 So there is going to be a little lookup error in the amount that you get here which will be something like 2*pi/1000 . 327 00:32:33,398 --> 00:32:40,879 And that sounds quiet but that's about a part in a hundred. 'extraneous room noise here' 328 00:32:40,824 --> 00:32:45,114 In other words this thing is making its error on the order of part in a hundred. 329 00:32:45,280 --> 00:32:48,745 And that is loud -- that's minus 40dB. 330 00:32:48,690 --> 00:32:55,346 And if you want to hear it, I can prove that that's bad. 331 00:32:55,346 --> 00:33:04,918 I will give you that at much lower frequencies and then you will hear a characteristic computer music error... 332 00:33:05,193 --> 00:33:10,418 Let's make it...20 ? ... All right,we'll start it at 55 Hertz. 333 00:33:15,919 --> 00:33:18,175 I can't hear anything wrong yet. 334 00:33:22,355 --> 00:33:24,555 Can you hear bacon frying in there? 335 00:33:27,141 --> 00:33:28,461 I don't hear anything wrong. 336 00:33:30,496 --> 00:33:35,667 I guarantee you will hear the problem if you listen to this carefully. 337 00:33:37,757 --> 00:33:44,083 I am going to turn the whole thing up to prove that this is bad. 338 00:33:45,459 --> 00:33:50,409 Leave it there and I am going to turn the volume up a little bit. 339 00:33:52,280 --> 00:33:54,095 Before I destroy these speakers. 340 00:34:12,413 --> 00:34:13,953 Hear that stuff? 341 00:34:18,794 --> 00:34:26,935 When you are in a good listening environment, you will hear that a lot louder than you hear it here with this all these fans and everything else. 342 00:34:27,045 --> 00:34:39,697 And what that is is about 40dB down from the sound of the sinusoid, but I am moving the sound of the sinusoid out of the way so that all you hear is the forty decibel down nonsense. [tone] 343 00:34:44,207 --> 00:34:47,508 Furthermore, it's still there when you do this kind of stuff. 344 00:34:48,113 --> 00:34:49,983 You might be able to hear it, and you might not. 345 00:34:50,093 --> 00:34:55,704 But if you listen to this in a good studio, you will hear it and it will not be appropriate, not be a good thing. 346 00:34:55,704 --> 00:35:01,865 Furthermore, that was only a nice sinusoid here. 347 00:35:01,975 --> 00:35:06,871 And of course the reason we are doing table look up is so we can do other stuff besides sinusoids. 348 00:35:06,816 --> 00:35:11,821 And "other stuff besides sinusoids" has higher harmonics in it, perhaps. 349 00:35:12,097 --> 00:35:21,833 So in fact what about the, what about if the signal that I put in here had a little bit of energy in the harmonic? 350 00:35:23,318 --> 00:35:26,839 Then what would I be listening to? [tone] 351 00:35:28,984 --> 00:35:30,139 This stuff. [sliding tones] 352 00:35:32,670 --> 00:35:36,685 You could want this, but you might not want it too. 353 00:35:40,041 --> 00:35:41,636 Let me shut that off. 354 00:35:42,021 --> 00:35:51,207 So whatever you put into that wavetable to the tenth harmonic didn't sound like a sinusoid, it sounded like that thing. 355 00:35:52,033 --> 00:35:56,653 And the hundredth harmonic sounded a whole lot worse. 356 00:35:57,533 --> 00:36:04,299 Questions? ... So table lookup is not the panacea that... 357 00:36:04,519 --> 00:36:07,710 well, sorry -- Table look up is not trouble free. 358 00:36:07,875 --> 00:36:12,496 You have to pay your dues and figure out how you are going to use this effectively. 359 00:36:12,496 --> 00:36:24,763 And cos~, that one is a table lookup that happens to be a cosine that's worked out in such a way that it gives you nineteen bits of precision, which is usually good enough. 360 00:36:24,818 --> 00:36:29,768 And so if you can live with cosines you will not have to deal with this situation. 361 00:36:29,823 --> 00:36:33,619 But there are moments when you will have to do real table lookup. 362 00:36:33,509 --> 00:36:43,080 In particular as soon as you have a sample going into the computer ... As soon as you're doing a recording you're putting a recorded sound in here and then playing that back using an oscillator, or using a sampler. 363 00:36:43,180 --> 00:36:50,561 You will have to deal with the issue of how well you are interpolating it and what kind of numerical accuracy you are getting out of it. 364 00:36:51,221 --> 00:36:58,593 We can avoid that for right now because basically, we are not going to be careful about that yet. 365 00:36:58,813 --> 00:37:02,388 I am going to show you that I think next week when we get into how to do sampling. 366 00:37:02,488 --> 00:37:04,424 And right now I will just go back to... 367 00:37:04,534 --> 00:37:09,924 OK, this looks good and now we can have a quick look at what waveforms sound like.[tone] 368 00:37:16,580 --> 00:37:19,606 Here's a nice pulse. 369 00:37:21,806 --> 00:37:24,336 It's one of the simple waveforms. 370 00:37:27,032 --> 00:37:31,212 And that's sort of "pulse width modulation," if I could draw something perfectly horizontal here. 371 00:37:32,258 --> 00:37:34,513 There is that kind of thing. 372 00:37:38,143 --> 00:37:40,124 Triangle waves like this: 373 00:37:44,029 --> 00:37:45,460 And so on. ... 374 00:37:46,230 --> 00:37:48,980 Maybe you want to have a better way of putting things in wavetables than this, right? 375 00:37:49,080 --> 00:37:50,465 So that is all programming. 376 00:37:52,996 --> 00:37:57,396 And I am going to show you pretty soon how to record a sample. 377 00:37:57,616 --> 00:38:05,263 But for right now, this is by and large how most of computer music works. 378 00:38:05,483 --> 00:38:06,968 You generate phases. 379 00:38:07,298 --> 00:38:16,649 Which is done by, typically by eventually, a phasor object ... at some point inside your patch there's going to be one of these generating phase. 380 00:38:16,814 --> 00:38:22,260 And then at some point you are designing or finding waveforms. 381 00:38:22,095 --> 00:38:30,786 You could be adding up partials to make a Fourier-synthesized waveform, or you could be recording a waveform, or you could have some for some other reason. 382 00:38:31,281 --> 00:38:41,458 And that typically finds its way into storage into an array, and then you look the array up using the phasor. 383 00:38:41,558 --> 00:38:47,069 In other words, the phasor generates the index that changes your array that is telling you what the waveform is. 384 00:38:47,169 --> 00:39:02,416 And then you are playing it and you're making a tone whose timbre depends on the waveform and whose amplitude and frequency depend on what you multiply the table lookup by at the output. 385 00:39:02,516 --> 00:39:06,927 So here I am controlling amplitude, and here I am controlling frequency. 386 00:39:07,147 --> 00:39:25,520 Frequency control is going into the phasor and amplitude control is happening at the output of tabread~. And these three objects are replacing the one object osc~, the oscillator. 387 00:39:34,321 --> 00:39:36,081 You can deal with that right? 388 00:39:36,466 --> 00:39:39,162 And now we can do all three... 389 00:39:40,922 --> 00:39:43,452 So let me save this and make another one. (saving "4.moretables.pd") 390 00:39:43,452 --> 00:39:48,293 So I can get rid of some of this. 391 00:40:04,190 --> 00:40:11,837 So tables can be waveforms, or they can be other computer music items. 392 00:40:12,057 --> 00:40:16,292 And one thing you can imagine wanting to do is make this thing be... 393 00:40:16,402 --> 00:40:20,088 either the amplitude or the pitch of something changing in time. 394 00:40:20,143 --> 00:40:23,608 Let's make it amplitude to start with because that will be easier to hear. 395 00:40:23,608 --> 00:40:28,119 And then I will show you how you can control pitch using a table. 396 00:40:31,530 --> 00:40:34,170 So I am going to make a nice envelope. 397 00:40:40,221 --> 00:40:46,327 So now we have an oscillator, and I am going to tell the oscillator to go very slowly. 398 00:40:46,437 --> 00:40:55,458 But rather than listen to this as the output, I am going refer this as the amplitude of something else. 399 00:41:00,739 --> 00:41:08,010 What? ... So we're going to take this and... 400 00:41:08,110 --> 00:41:13,941 just by convention I have been putting the amplitudes to the right, so we'll continue doing that. 401 00:41:14,326 --> 00:41:15,536 Like this. 402 00:41:19,552 --> 00:41:22,357 So I am giving myself a way to turn the thing on and off too. 403 00:41:22,522 --> 00:41:30,278 But meanwhile I am going to multiply a regular oscillator by this: [Tone] Ta-da. 404 00:41:46,506 --> 00:41:57,232 This is not perfect ... This is not a perfectly good example. 405 00:41:57,332 --> 00:42:06,804 This is now taking what is in here 'tab.1.18.a' and making an oscillator out of it that is running at three cycles per second, 406 00:42:06,904 --> 00:42:10,654 and is then multiplying that by this oscillator 'osc~ 220'. 407 00:42:10,874 --> 00:42:20,116 And I asked it for, well just by drawing I asked it for something that goes up quickly and comes down more slowly. ... Yeah? 408 00:42:20,336 --> 00:42:23,802 Student: What is the "*~ 1000" doing? 409 00:42:24,682 --> 00:42:25,682 Ah, right. 410 00:42:25,782 --> 00:42:40,689 So this phasor is outputting values from 0 to 1. And the table needs an input which is in points; and there are a thousand points here. 411 00:42:40,744 --> 00:42:45,805 So this is an adjustment to the range which is the size of this table. 412 00:42:47,180 --> 00:42:54,166 Or another example -- This is more along the lines of classical electronic music. 413 00:42:54,716 --> 00:42:56,421 Let's go back. 414 00:42:59,337 --> 00:43:05,883 This is kind of a bad example but I'll look at it anyway just to see the badness in a bad example. 415 00:43:06,103 --> 00:43:07,643 And now: 416 00:43:11,769 --> 00:43:15,674 Table Controlling Pitch -- Why not? 417 00:43:15,774 --> 00:43:16,444 'saving "5.table-pitch.pd' 418 00:43:16,609 --> 00:43:24,366 I haven't changing the name of the tables ... So I have to get the "Properties" anyway .. Points? 419 00:43:24,310 --> 00:43:32,232 -- I'm going to change it back to ... what? -- 12 . 420 00:43:35,422 --> 00:43:44,719 I'll make it "d" now. 'array is named tab.1.18d' 421 00:43:46,369 --> 00:43:53,850 Change that to "d" 'in the tabread~ box'. So now we have a nice oscillator that is reading this table. 422 00:43:53,950 --> 00:44:23,664 And it's giving us values that are ranging from -1 to 1 ... but I want to change that -- Let's make it have a range that is appropriate to frequencies, which might be 1000 to 0. ... So now everything at the bottom is 0. I can't edit it now ? 423 00:44:29,000 --> 00:44:33,786 ... Let's see what I can do about this ...I'm going to put something in. 424 00:44:36,591 --> 00:44:39,837 Here's how to generate a 0 without any object ... 425 00:44:40,882 --> 00:44:43,962 Student: It should be "1.18.d" -- "tab.1.18.d" 426 00:44:44,018 --> 00:44:45,063 Oh, thank you. "d" 427 00:44:46,768 --> 00:44:59,420 That didn't do any thing either ... Sorry I am just trying to get this thing through to where I can edit it, and I am not succeeding. 428 00:44:59,520 --> 00:45:00,905 That didn't do anything either. 429 00:45:00,950 --> 00:45:01,950 That's "tab.1.18.d" 'not array.1.18.d' 430 00:45:02,280 --> 00:45:06,351 How about I just put some value into here directly? 431 00:45:10,421 --> 00:45:18,068 ... 57 ... All right! Now this is nothing to listen to. 432 00:45:18,178 --> 00:45:23,898 These values are now ranging from 0 to 1000 so they are too big to use for amplitudes. 433 00:45:23,733 --> 00:45:26,539 But they are perfectly good to use for frequencies. 434 00:45:26,484 --> 00:45:35,285 So we could for instance, instead of using this as the amplitude of the oscillator, we can do the frequency of the oscillator. 435 00:45:38,035 --> 00:45:39,301 And .... [tone] 436 00:45:41,766 --> 00:45:46,342 Oh!? ... You know what? We need to change this: 437 00:45:47,662 --> 00:45:53,163 'output range of phasor changed from 1000 to 12'. 'varies the values by writing in the table tab.1.18d' 438 00:46:05,705 --> 00:46:08,400 So this is an old electronic music trope. 439 00:46:08,500 --> 00:46:13,516 For those of you who listen to old electronic music like from the era of Morton Subotnick and those kind of people. 440 00:46:13,846 --> 00:46:18,522 This is called a sequencer, an analog sequencer even though it is digital. 441 00:46:18,522 --> 00:46:27,818 Because the way analog sequencers used to work is they used to have a collection, typically of twelve, occasionally of sixteen voltages that you would set with knobs. 442 00:46:28,038 --> 00:46:32,494 And then you would give it usually a trigger and ask it to advance it to the next voltage. 443 00:46:32,659 --> 00:46:34,694 That was an analog synth board. 444 00:46:34,859 --> 00:46:39,810 This is how to make that sort of thing using digital technology. 445 00:46:39,910 --> 00:46:49,436 And by the way everything is in Hertz, so this is 0 to 1000. And this kind of doesn't work very well for specifying pitches. 446 00:46:49,326 --> 00:46:53,287 In fact, you will notice that all of the pitches were within a couple of octaves of each other. 447 00:46:53,452 --> 00:47:04,288 That is because from a quarter of the way up to all of the way up is two octaves because each octave is doubling. 448 00:47:04,388 --> 00:47:14,740 So if this is a thousand, an octave down is 500, an octave down is 250. So this is an ugly scale to be trying to do musical pitches on. 449 00:47:15,015 --> 00:47:17,656 That is going to bring me to the next topic which is: 450 00:47:17,766 --> 00:47:20,406 units in computer music. ... 451 00:47:22,496 --> 00:47:28,602 So now what you have seen so far in 45 minutes is two objects really. 452 00:47:28,702 --> 00:47:31,573 Well, maybe three, mostly two. 453 00:47:31,518 --> 00:47:46,040 phasor~ and tabread~ -- whose jobs are to remember where you are and scan through something, which is the basic thing an oscillator does and to hold and retrieve values. 454 00:47:46,140 --> 00:47:50,440 And these values ... So far you know how to get them in by using tabwrite~ -- 455 00:47:51,211 --> 00:47:54,181 And I am going to tell you about the best way when I figure out what the best way is. 456 00:47:54,291 --> 00:48:00,452 But I am going to do units first, because we need units badly now so that you can start making music. 457 00:48:00,947 --> 00:48:05,183 So just try to make this thing do a C major scale. 458 00:48:05,293 --> 00:48:10,629 First off, a twelve note system isn't a good choice. 459 00:48:10,739 --> 00:48:12,719 So let's just use the first eight points. 460 00:48:12,829 --> 00:48:16,239 Right! ...so nobody said that you had to use the entire table. [tones] 461 00:48:19,705 --> 00:48:28,231 So if you use some smaller number ... depends on the size of the table. 462 00:48:29,221 --> 00:48:30,541 [changing the output range of the phasor to less than 12. changed to 6] 463 00:48:30,927 --> 00:48:32,467 Now you get the first 6 values of the table. 464 00:48:32,742 --> 00:48:35,712 Now I've got a more powerful scheme because ... 465 00:48:36,867 --> 00:48:38,188 ... Add to this ... "+~" 466 00:48:58,761 --> 00:49:02,776 Now what I am doing is I am looking at a little window inside the table of six notes. 467 00:49:04,426 --> 00:49:06,187 And I am sliding the window over. 468 00:49:08,552 --> 00:49:10,753 If I change the value from 6 ... 469 00:49:28,630 --> 00:49:31,931 Now it's multiplied by 0; I am not getting anything at all. 470 00:49:32,536 --> 00:49:35,451 But if I add 0 multiplied by twelve, that is the original thing.[tones] ... 471 00:49:36,992 --> 00:49:39,742 [changes phasor output from 12 to 3. Tones change] 472 00:49:40,622 --> 00:49:51,018 Oh yeah, right! So I am only ranging through 3 values, if I'm doing that once per second, that happens at a much slower speed than if I range over 12 values in a second. 473 00:49:51,734 --> 00:49:52,944 Why a second? 474 00:49:53,054 --> 00:49:57,179 Because this phasor is going at 1 Hertz so it is doing that. 475 00:49:58,830 --> 00:50:02,790 And then if I say, look at three points, it is doing three points per second. 476 00:50:02,680 --> 00:50:08,841 But if I tell it to do twelve it is doing twelve points per second. 477 00:50:09,721 --> 00:50:13,902 Student: What does it sound like if the phasor is at 2Hz? 478 00:50:14,342 --> 00:50:15,497 Two? 479 00:50:15,662 --> 00:50:21,988 Let's try 440. ... All right, so let's see. 480 00:50:22,153 --> 00:50:24,024 Let's turn it on again. 481 00:50:24,684 --> 00:50:26,114 First off -- 2: [tone] 482 00:50:41,571 --> 00:50:50,262 The rule is that when you are doing things faster than 30-ish times a second you don't hear them as individual events. 483 00:50:50,372 --> 00:50:54,388 And so all that you can possibly hear them as is sound I guess. 484 00:50:54,553 --> 00:51:00,054 And so now we are changing the sound of the thing by playing them supersonic with melody.[tone, varying with frequencies of phasor] 485 00:51:25,523 --> 00:51:28,108 Now if we say -1 Hz? 486 00:51:29,318 --> 00:51:32,289 ... It is going backwards from right to left. 487 00:51:34,489 --> 00:51:35,864 Backwards. 488 00:51:39,935 --> 00:51:59,958 Meanwhile ... Adding does that: Furthermore, let's say I add even a fraction ... 3.5: 489 00:52:00,288 --> 00:52:12,280 And then it is four long, but it is actually not aligned with points in the table, so it hits 3 in the middle of it and then 2 at the outside, that you get 1/2 of. 490 00:52:34,228 --> 00:52:35,228 Oh, right: 491 00:52:35,383 --> 00:52:39,454 If you run off the end of the table, it's kind of just your tough luck. ... 492 00:52:40,939 --> 00:52:44,294 Whoops, now we are really off. ... 493 00:52:45,285 --> 00:52:50,731 There are twelve points in the table; let's make it fall off like this: 494 00:52:50,831 --> 00:52:55,406 You're getting the last four points on the table and then it is sticking on the fourth one. 495 00:53:06,793 --> 00:53:10,313 Now you know how to make computer music. 496 00:53:11,249 --> 00:53:15,649 Actually, this is even more like '60s-style analog music. 497 00:53:15,539 --> 00:53:19,940 This is stuff that you would hear out of the San Francisco Tape Music Center 498 00:53:20,105 --> 00:53:21,315 [Morton Subotnick, Ramon Sender et al.] 499 00:53:21,480 --> 00:53:23,295 That belonged to a certain generation. 500 00:53:23,681 --> 00:53:25,936 Many of those people are still alive, by the way. 501 00:53:26,036 --> 00:53:28,576 You can send them emails. 502 00:53:29,236 --> 00:53:32,592 Questions about this? Is it clear what I just did? ... Yeah? 503 00:53:35,287 --> 00:53:40,953 Student: I'm not too clear on the +~. You said it moved the window? 504 00:53:41,888 --> 00:53:54,045 OK, yeah. Meaning in some sense it bubbles up from the bottom in the sense that for tabread~ I have to provide a number which will tell it where it's going to look. 505 00:53:55,365 --> 00:54:05,267 See, if you think of those numbers as living horizontally from 0 up to 11 and then 12 being that you put in twelve but the integer is never twelve -- really 0 to 11. 506 00:54:07,247 --> 00:54:19,184 Now if I say, for instance, take the phasor, which ranges from 0 to 1, and multiply it by 5 then I'm going from 0 to five which means I'm scanning through the first 5 points in the table. 507 00:54:19,459 --> 00:54:24,520 If I add now 2 to that, it adds two to those points -- to that range. 508 00:54:24,620 --> 00:54:33,431 Well, actually it adds two to every value, which de facto adds two to the range of possible values that those results occupy. 509 00:54:33,531 --> 00:54:45,368 In that case, after I've done that, the phasor which went from 0 to 1 goes from 0 to five now goes from 2 to 7 and therefore reads points 2, 3, 4, 5, and 6 -- which gives you five points in the table. 510 00:54:46,083 --> 00:54:50,428 Student: Then that number 12, is that arbitrary? 511 00:54:50,428 --> 00:54:53,399 That's arbitrary/historical. 512 00:54:54,224 --> 00:54:59,450 If you go look at an old synth they typically have 12 on them. ... ... Yeah?? 513 00:55:00,440 --> 00:55:06,161 Student: Just to make sure ... Do you need a tabwrite~ to mess around with [manually changing] the graph? 514 00:55:06,546 --> 00:55:18,923 I'm running this version 43 test three, which doesn't let you edit the thing when the graph goes outside of the bounds and I had a negative number in there and I changed the range so that I couldn't edit anymore. 515 00:55:19,023 --> 00:55:21,728 So I threw that in [the number-box input] so I could bash it to a constant. 516 00:55:21,828 --> 00:55:33,335 Now that I have it, it's kind of useful because I can now say "Just play A 440 please" and it giving me consistently A 440.[tone] 517 00:55:41,146 --> 00:55:53,633 I was going to put some message boxes in to try to make a nice sequence of pitches in the table but then I realized that I'd have to press them all within a few 44,000ths of a second ... and that wasn't going to work terribly well. ... Yeah?? 518 00:55:34,985 --> 00:55:40,816 It's boring; in fact, I could, no let's not do that. 519 00:55:55,503 --> 00:55:59,079 Student: The oscillator for the tabread~ is that 220? 520 00:56:01,224 --> 00:56:04,965 Thank you. Yeah; that 220 is obsolete. 521 00:56:05,065 --> 00:56:07,385 It got overridden by the input. 522 00:56:08,155 --> 00:56:11,731 Student: Can you input something to an oscillator that already has a value? 523 00:56:11,896 --> 00:56:14,206 It forgets the value and adopts the value. 524 00:56:14,316 --> 00:56:21,082 Except if I disconnected the input it would jump back to the 220 and then you'd be even more confused. 525 00:56:21,182 --> 00:56:23,998 So it's best not to have that 220 there. 526 00:56:27,848 --> 00:56:29,058 Bad style. 527 00:56:29,333 --> 00:56:30,489 Student: Can you show the properties for the table? 528 00:56:31,259 --> 00:56:32,304 [tab.1.18.d] 529 00:56:32,799 --> 00:56:34,009 OK, so take this one here? 530 00:56:36,209 --> 00:56:47,761 So ... its size is 12. I don't mind "Save Contents" because it will add 48 bytes or something ... 531 00:56:49,466 --> 00:56:59,643 The X range is from 0 to 12. Oh, by the way, if you change this and if it agrees with this range when you change it it'll update this range for you. 532 00:56:59,533 --> 00:57:01,238 You don't have to set that. 533 00:57:01,348 --> 00:57:11,855 Here I wanted to go from 1,000 at the top to 0 at the bottom -- which is a reasonable range of pitches but not the only possible range. 534 00:57:21,206 --> 00:57:22,416 Let's see. 535 00:57:22,516 --> 00:57:32,263 I'm going to next talk about units. 536 00:57:33,143 --> 00:57:39,029 And to do that I think what I would do, I'm going to save this now as patch number 7 537 00:57:39,304 --> 00:57:43,319 because I'm going to have to have a patch number six in the middle. 538 00:57:47,225 --> 00:57:55,421 So by the time we get to 7 we're going to be putting MIDI numbers into the table instead of frequencies in Hz -- which will make everyone breathe a sigh of relief. 539 00:57:55,696 --> 00:57:59,767 But meanwhile, I have to go back one. 540 00:57:59,712 --> 00:58:02,627 Student: You are putting all of these patches on the website, right? 541 00:58:02,563 --> 00:58:03,563 Oh, yeah. 542 00:58:05,653 --> 00:58:14,784 ... Yeah, I believe it's true the patches from last Thursday are on the website, but if you look and don't see them it's because I forgot to put them up and I need to... 543 00:58:16,269 --> 00:58:18,140 So they're not there? 544 00:58:18,415 --> 00:58:19,900 ... I need to put them up! I'm sorry. 545 00:58:20,065 --> 00:58:21,440 I'm forgetful. 546 00:58:22,155 --> 00:58:25,621 So now we're just going to talk about units. 547 00:58:27,216 --> 00:58:38,713 To talk about units we don't need this stuff, but we still need our nice oscillator and our multiplier. 548 00:58:39,318 --> 00:58:44,544 There. Same thing as always. 549 00:58:46,084 --> 00:58:48,284 Now, the objects of interest are as follows: 550 00:58:48,384 --> 00:58:58,791 The one that's the easiest to understand probably is "MIDI-to-frequency" [mtof] and its companion, "frequency-to-MIDI." 551 00:58:59,451 --> 00:59:10,672 For mtof, you just give it a number and out comes the frequency in Hz that would correspond to that value in MIDI. 552 00:59:11,168 --> 00:59:27,285 For instance, 69 is the MIDI number which is associated with the A above middle C which is sometimes called A440. So this is a pitch and this is the value in Hertz. 553 00:59:27,670 --> 00:59:37,957 The pitches are good to use because you can look at two of them and know exactly what the interval is between them, that is the musical distance between them. 554 00:59:38,507 --> 00:59:42,137 You can't necessarily do that with two of these numbers [frequencies] 555 00:59:42,302 --> 00:59:48,793 Like if I gave you 261.62 and this [440] you wouldn't necessarily know right off the bat that's a major sixth, if I've got it right. 556 00:59:49,619 --> 00:59:59,630 But here if I say OK give me a major sixth that's 60 to 69 then you can know that. 557 01:00:00,125 --> 01:00:04,746 So, for instance, if you want to make oscillators make a chord. ... 558 01:00:04,846 --> 01:00:11,732 First off -- before I even do that, let's just play this: [tone] (changes with inputs to mtof) 559 01:00:18,883 --> 01:00:24,714 I'm too lazy to get the piano out, but if I whacked A I believe I would hear the same pitch as I heard here. 560 01:00:24,814 --> 01:00:30,930 There is one situation in which that wouldn't be true which is if I was wrong about the sample rate of my conversion hardware. 561 01:00:30,985 --> 01:00:33,240 That's probably right. 562 01:00:33,350 --> 01:00:38,906 So now, for instance, if I want to play [tones] a musical sixth or seventh tone. 563 01:00:43,252 --> 01:00:46,332 It's a much easier job than multiplying by one and a half. 564 01:00:48,972 --> 01:01:01,624 Now if we want to go up by a musical third here that's easier than multiplying by that ratio, which is a number that you all know from acoustics. 565 01:01:02,229 --> 01:01:07,895 What's a tempered major third interval ... or the ratio? 566 01:01:10,260 --> 01:01:15,321 That's not the easiest possible computation you could be doing. ... ... Yeah?? 567 01:01:15,376 --> 01:01:17,907 Student: How did you change the number so quickly? 568 01:01:18,127 --> 01:01:19,722 Oh, how did I change it so quickly? 569 01:01:19,832 --> 01:01:24,453 I click on this thing and then I start typing and I hit enter. 570 01:01:26,488 --> 01:01:30,118 And, I've had a lot of practice. 571 01:01:31,769 --> 01:01:45,356 So 12 half steps are a factor of two, so four half steps is a factor of 2^1/3 because 4 is 1/3 of 12. So the cube-root of 2 is the musical major third, tempered. 572 01:01:52,012 --> 01:01:53,772 That's weird, isn't it? 573 01:01:54,487 --> 01:02:00,978 ... I tritone the easiest one of all besides an octave. 574 01:02:01,078 --> 01:02:10,055 Even though it's the worst interval -- It's the square-root of two, 6 half-steps out of 12. They're all irrational except for the octave. (all the half-steps) 575 01:02:19,021 --> 01:02:31,023 OK, so here to make, for instance, a nice major chord, just as an example, you could say, 576 01:02:31,123 --> 01:02:57,087 "All right I will take this frequency and I will multiply it by 1.25 and by 1.5." That's 5/4 and then it is 3/2. Those are the musical perfect third and perfect fifth, perfect major third and perfect fifth. ... 577 01:02:57,252 --> 01:03:00,607 Now let's see if it's going to work for me. [tones](major chord at various frequencies) 578 01:03:11,499 --> 01:03:17,220 That's OK as long as you're doing tempered chords and you happen to know those numbers. 579 01:03:17,494 --> 01:03:39,443 More musicians know these numbers in half step and they would rather do the whole thing -- instead of in frequencies -- in pitch -- Where going up a major third is not multiplying by a ratio (which is what you do to frequency), but it is adding the number of steps. ( 580 01:03:39,543 --> 01:03:41,643 Because pitch is in steps or in notes.) 581 01:03:41,743 --> 01:03:47,969 We can say in steps. 582 01:03:48,574 --> 01:03:55,725 So here we say "+ ..." -- How many half-steps are in a major third? -- Four. 583 01:03:56,221 --> 01:04:03,262 And in a fifth? -- 7. 584 01:04:09,367 --> 01:04:12,228 This might or might not be easier: [tone] 585 01:04:16,684 --> 01:04:19,654 And by the way, it's no longer a perfect major chord. 586 01:04:19,764 --> 01:04:21,194 It is a tempered chord. 587 01:04:22,954 --> 01:04:26,145 It sounds different, especially here because there's some distortion. 588 01:04:26,255 --> 01:04:29,995 If there weren't any distortion I don't think you'd hear that beat. [tone] ... Yeah?? 589 01:04:34,561 --> 01:04:37,147 Student: What's the 69 thing again? 590 01:04:37,247 --> 01:04:49,468 Oh, thank you. 69, this is the MIDI pitch which corresponds to A440. I should probably tell you about the MIDI scale. 591 01:04:49,568 --> 01:04:52,384 Student: That's pre-specified already? 592 01:04:52,549 --> 01:04:53,549 That's pre-specified. 593 01:04:53,484 --> 01:04:59,590 That was specified by the musical instrument digital interface standards board back in the '80s, I think. 594 01:04:59,810 --> 01:05:03,055 This is basically never going to change. 595 01:05:03,155 --> 01:05:04,816 60 is middle C. 596 01:05:04,761 --> 01:05:09,987 Why 60? Because they wanted all the pitches to be positive numbers. 597 01:05:09,876 --> 01:05:28,854 In fact, they wanted to fit the whole thing in a 7-bit word, so everything is between 0 and 127. The definition of MIDI pitch is that 60 is middle C and values that are not 60 are counting away from middle C up or down in half steps. 598 01:05:29,515 --> 01:05:37,106 So a major chord in middle C. [tone] Going up a half step, add 1 ... 599 01:05:41,891 --> 01:05:44,807 Subtracting 1, going down a half step. [tones] ... Yeah? 600 01:05:48,712 --> 01:05:51,573 Student: Does a MIDI have to be integers? 601 01:05:51,903 --> 01:05:54,763 If it's real MIDI it does, but we don't have to obey that. 602 01:05:56,799 --> 01:06:00,044 60.5 (a quarter-tone above middle C) [tone] 603 01:06:05,600 --> 01:06:10,386 Why do you call one half of a step a quarter tone? 604 01:06:10,331 --> 01:06:14,566 That is music history that we just have to live with. 605 01:06:14,731 --> 01:06:20,342 Along with the fact that they used letters A to G and five of them have sharps and the other two don't. 606 01:06:20,452 --> 01:06:26,943 ... all that stuff we inherited from people who thought differently from how we think. 607 01:06:29,969 --> 01:06:36,239 I hope you prefer typing 64 and 70 to typing 261.62 -- you don't see the whole thing here. -- 608 01:06:36,404 --> 01:06:40,255 And those numbers which are frequencies that I don't even know. 609 01:06:44,436 --> 01:06:50,542 And just for the sake of being thorough: 610 01:06:50,652 --> 01:07:00,058 If you ever want to get back, there is a frequency-to-MIDI. (ftom) And that will do this for you: 611 01:07:05,504 --> 01:07:10,950 It will figure out what you have to say in order to get a given frequency. 612 01:07:12,325 --> 01:07:16,065 So if I happen to know that the thing I am listening to... 613 01:07:16,725 --> 01:07:24,592 let's see, to avoid re-using the number 60 ... suppose we're in Europe and we've got line-current to listen to, which is 50 Hz. 614 01:07:25,197 --> 01:07:37,629 So that is pitch 31.35, which is, let's see thirty ... 60 is middle C ... Then 31.35 is a G, a little bit north. 615 01:07:38,674 --> 01:07:41,699 Which is the sound of a ground loop in Europe. -- 616 01:07:43,074 --> 01:07:47,145 So Hertz to MIDI to Hertz. 617 01:07:47,255 --> 01:07:53,306 If you have an integer here, you are not always going to get an integer here and vice versa. 618 01:07:54,516 --> 01:08:10,194 The only situation where both of these happen to be an integer is when you use numbers like 220 or 440, which correspond to A, which is 69, or 57, or 45, etc. ... Yeah?? 619 01:08:12,834 --> 01:08:27,741 Student: This may be pretty unrelated -- But do you have any idea why they arranged it so that notes in MIDI are like 69 for A 440 and then they have negative numbers which correspond to Hz? 620 01:08:28,346 --> 01:08:29,502 Oh yeah, right. 621 01:08:29,666 --> 01:08:35,717 ... Yeah. So what is MIDI 0 here? It's 8 Hertz and change. 622 01:08:36,103 --> 01:08:43,308 So if you want something to go at four Hertz you have to say, go down an octave from 0 in MIDI, which is -12 MIDI. 623 01:08:43,474 --> 01:08:45,289 Isn't that horrible? 624 01:08:45,389 --> 01:08:50,790 And this is a perfectly reasonable vibrato rate, in fact a good vibrato rate is -6 or so. 625 01:08:51,395 --> 01:08:57,611 By the time you get up into non-negative MIDI frequencies you are really too fast for doing nice vibrato. 626 01:08:57,501 --> 01:09:04,047 Why did they do that? -- Because pitch originally was supposed to live on an 88-key keyboard. 627 01:09:04,157 --> 01:09:08,667 Because this was invented by instrument manufacturers. They thought about selling keyboards. 628 01:09:08,667 --> 01:09:14,443 So they invented a 7-bit protocol that can describe 88 keys. 629 01:09:15,048 --> 01:09:21,649 You can do that in a variety of ways like you can count the bottom of the piano as being 0. But what they wanted was for middle C... 630 01:09:21,759 --> 01:09:24,620 Well, for C's in general to be multiples of twelve. 631 01:09:24,730 --> 01:09:27,150 That makes the arithmetic easy. 632 01:09:27,975 --> 01:09:34,191 So then you could make the bottom of the piano be -3 ... No, you can't do negative numbers -- That's an A, usually. 633 01:09:34,246 --> 01:09:45,028 So then it could be 9. ... But in fact they made it 21 so that middle C would be about halfway up the range from 0 to 127 I guess. 634 01:09:47,118 --> 01:09:48,603 Anyway ... It works OK. 635 01:09:48,658 --> 01:09:53,554 The highest frequency you can talk MIDI into talking about... 636 01:09:53,884 --> 01:10:01,145 I can set the width of the number box; occasionally you have to. ... 637 01:10:01,420 --> 01:10:04,061 So you will have trouble specifying pitches above... -- 638 01:10:04,171 --> 01:10:10,772 ooh. That went the wrong way. 639 01:10:10,872 --> 01:10:19,683 You can't describe things in classical MIDI, hardware midi, above this pitch here, which is not going to bother any musicians. 640 01:10:19,903 --> 01:10:25,349 Oh and by the way, 0 - Even though 8 Hertz as a frequency is subsonic. 641 01:10:25,449 --> 01:10:29,914 So we did cover the range of hearing decently well, although not perfectly. 642 01:10:30,685 --> 01:10:36,075 And of course you can go out of the range negatively, you can also go out of the range positively. 643 01:10:36,571 --> 01:10:41,796 200 MIDI is almost a megaHertz. 644 01:10:44,272 --> 01:10:52,193 1000 MIDI is almost 10^26 Hertz. 645 01:10:53,238 --> 01:10:57,694 It's exponential -- every time you add twelve here, you are doubling this number. 646 01:10:57,804 --> 01:11:02,260 Student: How do you get that number box? 647 01:11:07,705 --> 01:11:14,306 Here? Oh, I just clicked on it and it said one, 0, 0, enter and then it did it for me. 648 01:11:14,416 --> 01:11:16,506 Student: The width of the number box, though? 649 01:11:16,672 --> 01:11:22,172 Oh, right, OK. ... Yeah, yeah. So this thing? 650 01:11:22,272 --> 01:11:26,188 This is because my number box by default is only five units wide. 651 01:11:26,353 --> 01:11:31,689 And I went into properties and told it to make this one 8 units wide so that I could see bigger numbers. 652 01:11:31,634 --> 01:11:36,640 It is a trade off of screen space versus range of numbers you can see. 653 01:11:37,025 --> 01:11:39,225 Actually five is almost never the right number. 654 01:11:39,225 --> 01:11:48,521 It is almost always either 3 or else it's 8. Five is almost an anti-...almost a local-minimum of utility. 655 01:11:49,016 --> 01:11:54,792 And of course, minus a thousand is a very low frequency. 656 01:11:54,892 --> 01:12:01,338 Like a once-in-the-age-of-the-universe type frequency. 657 01:12:01,503 --> 01:12:05,794 So that is units of frequency and pitch. 658 01:12:05,684 --> 01:12:21,086 So MIDI is a unit of pitch, and that is suitable for describing musical intervals because when you add some fixed number of steps to a pitch you move by the interval no matter where you are. 659 01:12:21,361 --> 01:12:25,157 ... Whereas frequency has a more dubious range... 660 01:12:25,322 --> 01:12:34,123 the audible frequencies anyway, roughly speaking, range from 20 to 20,000. So it is a more unruly scale for typing numbers in. 661 01:12:35,168 --> 01:12:41,054 And that is all I should say about that. 662 01:12:41,274 --> 01:12:48,040 Oh, if you want to have an interval, you multiply the frequency by a number to get the interval, as opposed to adding. 663 01:12:48,150 --> 01:12:52,166 And this is in fact exponentiation. 664 01:12:52,331 --> 01:12:57,282 It is a normalized kind of exponentiation so that adding here is the same as multiplying here. 665 01:12:57,382 --> 01:13:03,112 Because when you add something to something that you are going to exponentiate, you multiply. 666 01:13:05,863 --> 01:13:14,829 Similarly to pitch and MIDI, we have objects for doing amplitudes. 667 01:13:16,480 --> 01:13:22,476 And I have been using these numbers like 0.03 for amplitudes all quarter so far. 668 01:13:22,696 --> 01:13:29,461 Now we can start using amplitudes in decibels, which might also be a nice range from 0 to 100-ish. 669 01:13:29,561 --> 01:13:44,919 So the objects in question are called "decibels to root mean square." (dbtorms) That is a horrible name, isn't it? 670 01:13:44,864 --> 01:13:52,125 "Root mean square to decibels." (rmstodb) 671 01:13:54,050 --> 01:13:58,946 I don't know a better name for these, but this is not a good name. 672 01:13:59,606 --> 01:14:04,172 100 decibels corresponds to one volt, if you like. 673 01:14:05,107 --> 01:14:14,348 And then every increment of 10 db is a multiple of ten in power. 674 01:14:16,549 --> 01:14:24,690 Multiplying power by 10 means multiplying amplitude by square root of 10. 675 01:14:25,515 --> 01:14:29,751 Because power is proportional to the square of linear amplitude. 676 01:14:30,135 --> 01:14:39,157 A good measure of linear amplitude is root mean square, which means "the square root of the average of the squares of the sample." -- 677 01:14:39,267 --> 01:14:41,247 "Mean" means "average" in this context. 678 01:14:41,412 --> 01:14:42,732 So that root mean square is: 679 01:14:42,832 --> 01:14:47,078 "Take your signal, square it, take the mean and then take the square root of it." 680 01:14:47,518 --> 01:14:50,434 That is what the letters are and that stands for. 681 01:14:51,369 --> 01:15:02,315 And decibels-to-rms means get this thing (100) and make it that or get 90 (which is ten fewer and turn it into 1/(square-root of 10) (316) ... which you all know by heart. 682 01:15:02,205 --> 01:15:10,402 And then 80 then becomes [1/(square-root of 10)]^2 because we divided by the square root of ten twice. -- 683 01:15:10,512 --> 01:15:12,987 And that means dividing by ten. 684 01:15:13,812 --> 01:15:20,908 And now you can see why it is a reflex of mine to always say 0.03...that's about 70 db. . 685 01:15:20,853 --> 01:15:30,755 3 is about the square root of ten, .1 is a tenth, .03 is about ten to the minus three halves and so on like that. 686 01:15:30,975 --> 01:15:35,815 It's 10 db every time you multiply by three-ish. Yup. 687 01:15:36,035 --> 01:15:43,187 Student: Aside from just knowing that knowledge, is there any practical benefits to what you just showed us? 688 01:15:43,076 --> 01:15:50,613 The dbtorms? Well, there's this ... Now I can stop doing this and start doing... 689 01:15:50,558 --> 01:15:56,884 Ooh, I'm going to have to introduce a new object and there are only five minutes to go. I don't know if I should do this. 690 01:15:56,829 --> 01:16:07,610 In fact, what I'll do is I'll quit doing the niceties and just give myself a number box. Like this. 691 01:16:10,526 --> 01:16:16,137 Now I can say "Give me seventy db please," -- and you can't hear anything because I don't have any pitch here. [tone] 692 01:16:18,997 --> 01:16:35,279 So this seventy is an easier thing to think in terms of than this 0.03. Not only is that easier, but also at this point I've got something that operates reasonably as a control. 693 01:16:36,985 --> 01:16:41,935 I can mouse on this without having to hit the shift key -- that is a good thing. 694 01:16:41,935 --> 01:16:57,393 And furthermore, every time I push this by a fixed amount, like 10, say, it gets the same amount louder as the last time I pushed it by 10. Or I can take it down. 695 01:17:00,363 --> 01:17:08,009 So if you like ... five db, five or 10 db is a musical dynamic. 696 01:17:07,954 --> 01:17:15,270 And if you think in terms of there are six dynamics all the way from triple-f (fff) to triple-p (ppp). 697 01:17:15,436 --> 01:17:25,007 If you think that is a 35-decibel range of loudnesses, then then make it be 5db per dynamic. 698 01:17:25,227 --> 01:17:32,653 And then you've got a decent way of controlling dynamic that doesn't have you typing lots of decimals. 699 01:17:33,533 --> 01:17:47,615 Unfortunately, what this would mean is that 0 should be 10^-5. But the dbtorms object cheats, and when you say 0 it gives you a true 0 out so you can just turn the thing off. 700 01:17:48,000 --> 01:17:59,717 That's important -- because otherwise, it being digital, even if you had an amplitude of 10^-10, it might be doing 0 crossings, and it might still make its way to your speaker. 701 01:17:59,827 --> 01:18:07,858 So 0 is true 0, but as soon as you get off of 0, it gets to real numbers that are too small to show. 702 01:18:08,188 --> 01:18:12,479 ... Yeah, I need to make this number box fatter again. 703 01:18:20,235 --> 01:18:30,962 Now 0 is 0, but one db is about 10^-5; 20 db 10^-4 (.0001) and so on like that. 704 01:18:38,498 --> 01:18:41,633 And negative db you just truncated to 0. 705 01:18:41,743 --> 01:18:47,024 You can tell this thing more than 100db --I'm not going to do it right now, because it's connected to sound. 706 01:18:47,079 --> 01:19:03,362 But if 100 db is an amplitude of 1, then 120 db is an amplitude of 10, which is too loud to play, but not too loud to think about; maybe you are going to attenuate it later. 707 01:19:03,307 --> 01:19:07,322 And 140 is an amplitude of 100 and so on like that. 708 01:19:13,978 --> 01:19:18,049 Questions about that ... in 30 seconds? 709 01:19:18,544 --> 01:19:28,555 So those are acoustical units, and that was table lookups and phasors.