*** MUS171 #11 02 08
Miller: @0000What I'm going to do right now, is just start with Pd lore and move into modulation stuff. But the Pd lore here, the multiple-voice thing ...
es:@0000
@0015This corresponds roughly to Chapter 4 of the book. And then when we get into modulation that's going to be Chapter 5. Designer spectra are Chapter 6. And then delays is Chapter 7. Filters is Chapter 8.
es:@0015
So it's all pretty much @0030according to the syllabus -- theoretically. The first thing about that is... I don't know if you guys looked at this or not, but are there questions about how this whole thing works now? So,
es:@0030
@0045this what you are looking at is one of these.<<one of the "partial" subpatch/abstractions from "D7.additive.pd">> And in this particular situation, I've avoided having leads going into or lines, connections going into and of the sub-patches.
es:@0045
@0060I'm using non-local connections everywhere, which are in the form of receive~ and throw~. So one thing that I want to do today is talk about local and non-local connections
es:@0060
@0075and what they are good for and how you can make them. Local connections -- by that I mean just making lines between things in a single window. And non-local connections meaning things like ... throw~ and catch~ are some of these --
es:@0075
@0090I'm just going to proceed by example. So, just to remind you: the thing that is most likely to be confusing to you about this patch is an important thing to be confused about -- so that you can try to get unconfused about it over time -- which is
es:@0090
@0105the dollar-sign mechanism and how its use spins out differently in object boxes versus message boxes.
es:@0105
All right. So in object boxes like this one. "$3" @0120means 0.56 because that's what was thrown this thing as arguments when it was made. Whereas message boxes, this $1 is whatever comes down this line because that's what is thrown to it as arguments when that message is passed,
es:@0120
@0135which is to say when the message box is sent a message -- as opposed to when the thing was made.
es:@0135
The deeper truth is that objects really are messages. These are messages that go to a special factory object if you like, which just makes objects @0150for Pd itself. So there is actually one unified thing in Pd, by which messages get passed down lines and by which also these objects get built. And if you look a little deeper into it, you'll find out that you can use that fact to make patches that
es:@0150
@0165change themselves like that -- if you care about that kind of thing. All right.
es:@0165
Miller: That's the main bit of stuff about this that you might @0180not have known before. Yeah. Student: When you were making that abstraction, how would you make multiple inlets and outlets for them?
es:@0180
Miller: I think the next example will make that clear, and there's some funny stuff about that I have to show you. Yeah. --- @0195Actually rather than wait for the next example to make that clear, let me just show you what the answer is and then when the example comes up, you will see it in that context. That might be better.
es:@0195
Miller: OK. So, abstractions are a form of sub-patch. @0210So, this window is actually inside this box. And you can make this box have inlets and outlets and this window will be able to get the inlets and throw things to the outlets. But you don't have to
es:@0210
@0225use the abstraction mechanism to make that be true. So there are two possible ways of having whole patches inside objects:
es:@0225
One of which is this way, which is you just name a file. @0240The file's name is "partial.pd" . The other of them is simpler: Let's see, let's make a new patch. And the simpler thing is this --
es:@0240
@0255You can just say, "pd" and then give it a name. (A name without any spaces in it, as usual, because in Pd spaces are delimiters between arguments.)
es:@0255
@0270And now this thing is inside this box -- in the same way as was true with the so-called "abstractions" that you saw in that other example.
es:@0270
The word "abstraction" refers to the fact that you are in fact loading a patch into a sub-window as opposed to just editing it @0285yourself into the patch that called it. So here we can do things like this: Let's give ourselves an object and call it an inlet. And that, as soon as I made it, it made one of these things happen <<cause an inlet to appear on the "my-subpatch" object in the original patch window>>.
es:@0285
@0300And furthermore, if I make more of them, they show up as I'm making them. And the same is true for outlets.
es:@0300
@0315Oh, just to confuse matters further, you can have inlets and outlets, but they can come in control and signal varieties.
es:@0315
@0330If you say inlet~ and outlet~, then you can put audio signals into and get audio signals out of the inlets and outlets. Otherwise you're doing messages. And you can't mix them, unfortunately. <<on the same inlet or outlet>>
es:@0330
@0345That's a limitation. So the other thing about that is, well, all right, let's get a nice number box here. And we'll make a stupid patch, which is, it just takes whatever comes in and throws it out at the output. In fact, I can even do better than that.
es:@0345
@0360I can say, oscillate at 440, and I'll make that talk to this. It won't go to this one <<the rightmost inlet>> because it's an inlet, not an inlet~. But this one it can connect to <<the leftmost inlet>> because that's a signal one.
es:@0360
@0375And maybe, if I have the file here <<for output~>> ... I can say "output~" ... yes! And now we've got a great little, pass-through of a sinusoid voltage. It doesn't work!
es:@0375
Oh. @0390Why didn't it work? ... I didn't hear you, but ... yeah. That's it. It's like, duh, let's do this: <<connect the inlet~ in the subpatch to the outlet~>> And then we have a little pass-through thing.
es:@0390
@0405OSimilarly here, we've got messages going in, and again, duh, but let's do it. Now we've got that going on. Now, how do
es:@0405
@0420you know which is which? It's stupid, but, it's the only possible way you could do it:
es:@0420
These things, however they appear from left to right is how these appear from left to right there. Yeah. @0435So I could do this. And now I've got sort of a little brain-melt device. And you can do that too.
es:@0435
@0450That's the only way you could really do it. It'd still work ... in other words, moving things around shouldn't change how the thing functions.
es:@0450
And the only way to not change how @0465it functions is to sort of fix it so it functions the same. So it actually switches the inlets and the outlets around in real time as you're moving the objects around. There's no other real way to do it. All right, so that's inlets and outlets, and
es:@0465
@0480maybe answered your question about how you figure out which is which. They're proportionally spaced across here.
es:@0480
There's one other little thing to know, which is this. If I said Pd and then had a bunch of inlets and outlets like this, (this will happen @0495to you eventually even if it hasn't happened yet) at some point you get to the point where it's just black with inlets and outlets. And then how do you know what you're connecting to?
es:@0495
@0510And the answer is really stupid. The answer is, just give it a nice long argument like that, so that they get spaced out.
es:@0510
And if the name you gave it wasn't long enough, just add some hyphens to it or something to make it long enough. @0525Some day there'll be a way of controlling the widths, but right now, the width of a box is just the width of the text that it fits into, so if you want to change it, you just change the width of the thing. Yeah.
es:@0525
@0540That's enough of that. So that's inlets and outlets and sub-patches.
es:@0540
And the other @0555things that I want you to be able to know is that the, sort of collection of new objects that we're dealing with that have to do with getting stuff into and out of sub-patches, one collection of things was indeed inlets and
es:@0555
@0570outlets and, oh, I said tilde but, inlet~ and outlet~. And then there's also, I've already shown you throw~ and catch~, which are things that set up summing buses.
es:@0570
The place that showed up was here, @0585inside the "partial" again: The last thing that happens is we do a throw~ to .. and then you give it a name, which is "sum."
es:@0585
@0600This is like making a table or making a send. This defines a thing whose name is "sum". And then anyone who wants to can refer to it by saying catch~ and then
es:@0600
@0615the word "sum" again. And that in this patch is done down here:
es:@0615
"catch~ sum" and then output~. (All right, this can't be earthquakes, this is just vibrations of some other kind.) ... @0630And there's more, probably, which I explained last time. And you can now look it up on the DVD, so I won't repeat it. OK.
es:@0630
So I want to move to another example that just shows you @0645how to arrange copies of the sub-patch, which are made using the abstraction mechanism in a couple of other different ways just to give you programming paradigms, if you like, or ways of putting things together.
es:@0645
@0660None of these is the sort of "final answer" to how you should do this.
es:@0660
These are all sort of alternatives that you will find a personal style that attracts to one or another and so on like that. This one is @0675D07. I think there are two others in the series. Here's a
es:@0675
@0690cool trick: This is an additive synthesis patch
es:@0690
@0705that allows you to draw a spectrum. Why isn't this letting me move it? ... Yeah, there we go.
es:@0705
@0720 [...]
es:@0720
@0735So this is not drawing a waveform; this is drawing a spectrum. So I can do this and get stuff that has plenty of high frequencies or I can do this and get the low frequencies
es:@0735
@0750instead. Or, if you like, I can put in formants and I can pretend that I'm making vocal synthesis.
es:@0750
@0765Vocal synthesis is more believable if it's moving around in pitch like that. So what's happening here is there must be an abstraction somewhere because we have a whole bunch of oscillators.
es:@0765
@0780Each one is playing a partial of this. I think there might be 36 partials in this sound. OK, how do I make this shut up? Over here. Scroll. There!
es:@0780
@0795There's an oscillator bank which, just to be on the sane side, I put in a sub-patch and
es:@0795
@0810it consists of an abstraction called spectrum-partial of which there are 30 voices. What does the abstraction do?
es:@0810
Well, what it has to be able to do is figure out what pitch it should have and then go @0825to this table and find the point which is at the pitch and figure out what its amplitude should be.
es:@0825
So what's happening here is the pitches are all determined simply by find out what the fundamental pitch and I know what partial I am @0840I can compute my pitch, but I also want to know what my amplitude is and the amplitude is being set by this table, which I can then change. So this is a way of,
es:@0840
@0855I don't know what, it's a sort of a super Hammond organ, if you'd like.
es:@0855
So how would you do that? So, again, we're using the throw~ and catch~ mechanism for getting the audio signals in and out; and send and receive in order to get messages in and out. @0870Again, just as in the bell example, we have a problem disambiguating what we're doing so that each one of them can make its own partial and not have all
es:@0870
@088530 of them make the same partial.
es:@0885
So the one that gets the argument 25 should do the 25th partial and so on like that. So you have to be able to do that using the dollar-sign mechanism, that's to say the argument passing mechanism for abstractions, which is @0900that this $1 expands to the number 1, but in the window which is this next one it will expand to 2 and so on like that. So then what are we going to do?
es:@0900
@0915One little thing that I should probably say first because it's a detail, but it's a fundamental detail, is this: there's no way in particular in Pd that you can get told when a table changes value.
es:@0915
@0930It's something that ought to be there, but just isn't. So this thing does the incorrect thing -- according to computer science -- of polling.
es:@0930
That's to say, what it does is -- some number times a second -- each of the oscillators looks at @0945the table in order to figure out what its amplitude should be. From somewhere, which I can show you later, there's a "send poll-table" that has just a metronome sending bangs that are going out (at some 30 times per second I think.) ...
es:@0945
@0960Questions? Student: What is moses?
es:@0960
Miller: Oh, I haven't told you moses. Yeah. OK, so moses. Here we go. We'll get the help on it. @0975 moses is this: you put a number in and if it's bigger than the argument it goes out one output and if it's less than the argument it goes out the other. It's a reference to the Red Sea thing.
es:@0975
@0990You can change the value 10 by changing this argument, so if I want 30 to be this split-point then I do that and things 30 and more go this way and things up to 29 go out there.
es:@0990
It's also floating point, so @100529 and a half goes out there, but as soon as we hit 30 we'll get it out here. So that's moses. moses is
es:@1005
@1020similar to route.
es:@1020
Route is another thing which takes messages in and puts it out in a different place depending on what the message is. The difference is that moses is restricted to only two outputs, because it's a different kind of a thing, @1035And it only takes numbers, it doesn't take entire messages. So there's moses, which, by the way -- now that I've done that -- I should put on the new objects list.
es:@1035
@1050And this one we actually really saw today -- "random" I'm not sure we'll get to yet.
es:@1050
Miller: @1065Something like that. OK. Good question.
es:@1065
@1080Are there other objects here? No, not that I see. I think I told you about tabread4~, which is a signal object which reads tables interpolatingly. Well, you can do it with messages just
es:@1080
@1095by not putting a tilde there. dbtorms, I think I told you about that. OK. So what happens here it this thing is getting banged 30 times a second and every time that happens we're going to make
es:@1095
@1110a decision about what our amplitude is.
es:@1110
Meanwhile, there is pitch to figure out. The pitch is simpler because the pitch is just what got set to by the number box. The pitch of this thing depends. The frequency of the oscillator which is one partial @1125can be computed by looking at the pitch which is sent from this message box out here. Pitch. OK. Now we were looking in the oscillator bank and then
es:@1125
@1140we were looking at spectrum-partial 1. There's pitch coming back. Then we do mtof to figure out what is Hertz, but then this oscillator is not going to play at the fundamental frequency, it's going to play at some multiple of the fundamental given by
es:@1140
@1155the partial number. So here is partial number 1, so we multiply by 1, but if it was partial 30 we'd multiply by 30 to figure out what the frequency really is that the oscillator is going to play. ... Is this clear?
es:@1155
Student: @1170One more time.
es:@1170
Miller: One more time? OK. So there are thirty of these things. What we're going to do is we're going to make a sound by adding up 30 sinusoids which will be two different partials of the fundamental frequencies @1185that we want. Here's the fundamental frequency. $1 is the number of the partial that we're now looking at, and this number goes from 1 to 30, depending on which of these boxes we're in, in the oscillator bank:
es:@1185
@12001 through 30. And, I'll do this later but that's the frequency in Hertz which will go down, and all were going to see down there is an oscillator.
es:@1200
@1215Oscillator "osc~", times "*~" -- and then there's a throw~ that you can't see but this is scrolled off the screen. ... Other questions? Yeah?
es:@1215
Student: The moses after the tabread4 ... @1230What does that do?
es:@1230
Miller: What does this do? Oh, yeah I'll have to get to that. But I'll be in two words and then I'll tell you later: "Basically silence." Zero should go to silence and not just zero dB. @1245So it splits zero off and makes it true zero as opposed to converting. Other questions? Or just general, global cloudy confusion?
es:@1245
Student: @1260The "r"'s are abbreviations for "receive"
es:@1260
Miller: "receives" -- yeah. ... So this is now going to an oscillator and multiplier which is getting multiplied by the @1275gain of this oscillator -- the amplitude of this oscillator. And then it's ... then there's a throw~ down here that you don't see. OK. The fun part is all this stuff where we compute what amplitude the oscillator should have. And that --
es:@1275
@1290Recall, I want to be able to draw that in the table. And so what that means is I should figure out where that oscillator should be in the table. And then do a read in the table to see how high the thing should be above
es:@1290
@1305nothing. So how do you do that? OK. Oh ... Choice --This is a designer's choice. What should the horizontal units of the table be. Should they be Hertz or should they be MIDI or something else?
es:@1305
@1320In this particular case it turned out to be more effective or more appropriate to put it in MIDI units. So that the table itself, when you look at it, is arranged by pitch and not by frequency.
es:@1320
@1335Why? Because if it were frequency you'd be using half the table just to describe everything from 2K to 4K or something like that and then there would be a lot of detail in the lower parts that you wouldn't be able to see because it would be too squashed together. So pitch is better.
es:@1335
@1350And I even labeled it here. These are MIDI numbers, which are MIDI pitches, so that 60 here corresponds to 260 hertz. This stuff here is all very low frequency. But up here these are frequencies which are reasonable for formants
es:@1350
@1365of a vowel or something like that. In fact I did this so that I could just play with vocal synthesis. So if you want to do vocal synthesis with this you would figure out where you want the resonance of an imaginary vocal tract to be.
es:@1365
@1380And then you would put bumps at the points at the frequencies of those resonances and then you would make those -- Oscillators that land at those frequencies would be louder. Alright;
es:@1380
@1395is that decently clear? OK. So again if we want these to be addressed in MIDI units then what we need to do is after we found the frequency of the oscillator
es:@1395
@1410that you want, OK. We're going to get the pitch back.
es:@1410
So what's happening here is every time we get a bang in poll-table we're going to figure out an amplitude so we're going to have to then get the value of the frequency. We've seen this before in envelope generator controls where @1425you have a delay, but after the delay you want to set something off with a variable message.
es:@1425
The only way to be able to do that is to be able to store the value of the variable that you're going to have to recall after the delay. This is a similar situation where someone gave us the pitch at one moment in time, but @1440someone's asking us to use it in another. So we use a float object which stores the frequency so we can get the frequency back when we need it in order to compute the amplitude. So frequency is changing only at the moment when we
es:@1440
@1455change the values in the number box which controls the pitch of the sound, whereas the amplitude is changing on a different clock, which is whenever we go poll the table.
es:@1455
Alright; @1470then we recall the pitch, which is in pitch units. We convert it back to pitch here. The frequency, which is in cycles per second or Hertz, that's appropriate for talking to the oscillator, but
es:@1470
@1485for looking up the amplitude in the table we should be indexed by MIDI pitch because that was the more convenient way to have the table be arranged.
es:@1485
So we just convert from frequency back to midi, so here we have this kind of odd sequence of steps, which you might @1500find in more than one place actually. Look at a pitch but change it to frequency but then multiply it by a partial number and then change it back to pitch. There are alternative ways of doing that, but that's maybe the conceptually simplest way of
es:@1500
@1515finding the pitch of a partial of a note. Alright. Then I'll tell you about this a little later.
es:@1515
If whammybar is 0 that means nothing happens here because we subtract 0, but @1530that's a way of taking the whole table and sliding it backward and forward it we want, but it's not necessary. We're going to get the pitch back out and we're going to read a proposed amplitude out of the spectrum table. It
es:@1530
@1545turned out to be a good idea to have a 50 dB throw from the bottom of the table to the top. Why 50? Because 50 turns out to be just a good number between very loud and very soft.
es:@1545
100 is @1560too much. 100 is the difference between deafening and inaudible, whereas 50 is the difference between up and down in audio. Actually, if you want proof of that go look at a mixer and go look at
es:@1560
@1575the dB scale and you'll see they like a throw of about 50 dB as opposed to 100. Sort of standard mixers, typically. There's the moses object: If we get a positive number out of here. Now, let me show you where
es:@1575
@1590that's happening. It's here.
es:@1590
So what's being said is if this number's 0 or even negative, if I'm being sloppy about it, we want to get true 0 out so we can really shut it up, at one frequency or another. But if it's positive we want to take that number and consider it @1605as decibels going from 50 to 100.
es:@1605
Why 50 to 100? That's because Pd has this sort of informal standard of 100 dB is full blast. That's enforced or suggested @1620by the dbtorms object, where if you say 100 dB it will say 1. It's an arbitrary thing. 100 decibels can be any loudness that you want it to if you're just talking relative levels, but in Pd the convention is to have 100 decibels
es:@1620
@1635mean 1, or full blast.
es:@1635
So these values go from 0 to 50 on the table, so what we're going to do is add 50 to it to get from 50 to 100 and then we're going to convert that into a @1650linear amplitude and then we're ready to multiply the oscillator by that to make it the amplitude of the oscillator. That happens like this: Get back in the voice of the abstraction.
es:@1650
@1665So if it's 0, that's to say if it's less than 1, we're just going to make the amplitude be 0.
es:@1665
If it's one or more then we're going to add 50 to it and run dbtorms. So zero comes out true zero, @1680but 1 will get added 50 to it and then dbtorms will give us roughly 0.003, -50 dB, so there will be non-zero values ranging from 0.003 all the way up to 1.
es:@1680
@1695In fact, it's not strictly limited to 1 because if I drew the table out of bounds, above the top, then it would be more than 1. ... Yeah? Student: If you have a negative number going into moses, is that still...?
es:@1695
Miller: @1710It will still go out this side. It will still give us 0. OK. Then to make it sound good, pack 30 or some value to it. Who knows which value is best? What that does
es:@1710
@1725is that will mean whatever amplitude we computed will become the first element of a two-element message with 30 and that will be appropriate to send line~ to multiply by. Alright;
es:@1725
@1740questions about that?
es:@1740
So now, just getting back to whammybar ... So what's happening here is we're going to look something up in the tabread4. If we want to, in some sense, @1755slide the table over conceptually all we have to do is slide the read point back the same amount we want to pretend the table is sliding. What we would like to be able to do is take the table and move it up and down in pitch, which is to say to transpose the entire spectrum --
es:@1755
Just a good thing to be able @1770to do. To do that, we simply transpose, in some sense, or we offset the value that we use as an x-value for reading into the table.
es:@1770
So what's happening then is: @1785if the oscillator is playing at middle C, that's all right. If the whammy bar says 12, that means we look back here, or if the whammy bar says -12, that means we look forward here. Before we look it up in the table. And then, the result is...
es:@1785
Miller: @1800That the whammy bar does this to the spectrum. [frequency shifting offset in tone]
es:@1800
Miller: All right, @1815so that's another simple-ish... It's a demonstration of using the abstraction mechanism for making a powerful additive synthesis instrument. If you were doing this for real, like
es:@1815
@1830making it stageworthy, you wouldn't want to make yourself edit the table by hand while you were playing. You would want to prepare a bunch of tables and be able to switch them or something like that. That would be a whole thing, to plan out how to you want to do and to
es:@1830
@1845learn how to make it playable. So this is only a demonstration of the concept, it's not a real instrument yet. ... Questions about this before I close it and get on to the next thing?
es:@1845
Miller: @1860No. All right. Closing in on the next thing. ... This was an aside, but should
es:@1860
@1875I save this? Oh boy, wrong place. ...
es:@1875
Miller: @1890[...]
es:@1890
@1905OK. so that was the
es:@1905
@1920table.spectrum.pd example. Now this is more entertainment than it is actual elucidation. But here's another example of using,
es:@1920
@1935oh let's see... [sound of a continuous "falling" note] Miller: This is something you've probably heard in Music 170.
es:@1935
Miller: I think it's correct to call this the famous @1950Shepard-Risset tone. It doesn't sound like much until you listen to it for a while and then it starts to sound impossible. This is of historic interest because computer
es:@1950
@1965musicians were able to make this and analog synthesizer hackers were not able to make this because it requires accuracy and control, of a level that you can't get out of an analog synthesizer.
es:@1965
@1980And this is not the world's best Shepard tone. This is just me working the studio one night... [tone fades]
es:@1980
Miller: What it is, is a spin on what you saw last time, which is that the table... @1995(It is not even using a table, but it looks like a bell curve.) And then the sinusoidal frequencies are sliding from right to left if you like, and moving up, as you heard it sliding from high to low frequencies
es:@1995
@2010and working their way up the bell curve. Then back down in such a way that you always hear the descent but you never hear people disappear at the bottom because they're inaudibly quiet at that point.
es:@2010
And furthermore, the tones are arranged so that they are each an octave above the previous one. @2025So that no matter what you think the fundamental pitch is or whatever your ear tells you the fundamental pitch is, everybody else is a perfectly good harmonic of it.
es:@2025
And so as a result, especially you don't listen to it too carefully and if it isn't too loud, you have this @2040perfectly fused sound that sounds like it has a single pitch, except that the pitch is paradoxical at some points. You have to change your mind about what octave you are hearing it at. So that's the Shepard-Risset tone.
es:@2040
@2055How it's done is basically a spin on the other one, but there is more math in it, so I will spare you all the math because it's the same principle.
es:@2055
Oh. I did one other thing here but I will show you this out of the next example, rather than this one -- which is: @2070rather than using throw and catch. -- I don't know which of these is better style. -- ... You can use throw~ inside an abstraction and catch~ outside of it to collect the results of an abstraction. Or, you could do
es:@2070
@2085what I call "summing bus" or what I think is generally called a "summing bus" -- which is, each voice adds itself to to all the previous voices so that the output is the accumulation of all the voices, one after the other.
es:@2085
@2100It's easier to see what is going on when we do this. By the way here's a reverberator: "rev2~" if you're tired of all those dry sounds in your headphones and want a reverberator -- Grab this guy.
es:@2100
Miller: @2115I'll tell you about that more in a few weeks. OK. But I will show you how to actually do that in the next example, because it's simpler. The next example is... Oh. Should I do this?
es:@2115
@2130No. I'm going to skip that. There's much to know about samplers. Here's a design of a somewhat more
es:@2130
@2145general sampler than you've seen so far. The samplers that you've seen so far have been of two flavors. One of which was driven by a line~ object and started with a message that we start reading from a wavetable
es:@2145
@2160or an array from a given point to another point over a period of time.
es:@2160
The other flavor that you saw was driven by a phasor~ and that was better adapted to looping. This is the sampler that doesn't loop. And it's @2175an elaboration of the idea of the sampler so that you can control all sorts of parameters that can vary one sound from another. So it was even there in what you've seen before. Everything
es:@2175
@2190except -- Oh, everything that you see there. It was implicit that you could change the amplitude of the voice of a sample, or its duration: I showed you how to make them turn on and off using an envelope generator, but of course
es:@2190
@2205that means you could have parameters that would actually control that, as opposed to just sort of specify it in the patch.
es:@2205
The start location, or perhaps you could call it the "onset" into the sample, would be... -- If it was "continuous soft and relaxing," is whether you want the word "soft" @2220or the word "relaxing" -- that's the start location. The "sample number" - I haven't told you about this, but you can direct tabread4~ to choose one of a collection of arrays by name,
es:@2220
@2235by sending it messages.
es:@2235
Duration you know, amplitude you know. So everything else is just what it was. @2250Now, how do I ... where are the messages that do things? ... I lost the example messages.
es:@2250
@2265Well, we can just do it.
es:@2265
OK, so you send to a thing called note... @2280In order not to introduce yet another object, I'm just going to say "send note" and send it something. The things you send it are over here: ...
es:@2280
@2295So we make a message which is a pitch, an amplitude, a duration and so on like that.
es:@2295
@2310So let's just say, pitch, amplitude, duration is going to be 60, amplitudes and dB 80, duration is in milliseconds. There's a sample number, there's a ...
es:@2310
@2325There's sample numbers, start location, rise and decay time.
es:@2325
So sample number; start time would be the beginning, @2340rise time and then stop time.
es:@2340
And nothing happens - oh! Still nothing happens, let me see if I have turn this thing on. @2355Oh yeah, yeah. There it is! Let me give it a little more juice.
es:@2355
@2370OK there's a nice sample. Here, just to show you what's going on, you can change now various things.
es:@2370
@2385Here's a different pitch: [tone sounds]. I showed you changing the amplitude before. Here's changing the duration.
es:@2385
@2400Here's changing the sample number. Alright. -- There are two samples in there.
es:@2400
@2415This is more subtle because this is a bell sound, but I can ask it to play something in the middle of the bell sound instead of the beginning, two seconds later. That's the sound.
es:@2415
@2430The rule about bells is that the higher partials tend to fade more quickly than the lower ones, statistically anyway, so if I go into the bell two seconds I'll get a sound more like that than like this.
es:@2430
@2445Finally, if I want to change the attack time, say to a second, then I should make this be two seconds long so that you can hear it, then you get.
es:@2445
@2460Same thing with the delay. I can make the delay 1000 milliseconds long, now make the note be short, like 100.
es:@2460
@2475That's interesting. I guess it sounded different, but it didn't sound different enough. Let's make it 3000 long. [tone sound and fades slowly]
es:@2475
@2490 While I'm at this, there is always the dollar-sign mechanism for doing things like this. Suppose I want to be able to change the pitch quickly, but just move the rest of the things constant. Do this
es:@2490
@2505kind of thing. ... Nice keyboard.
es:@2505
@2520Or if I have the voice in there then I can make a thing that played different parts of the voice depending on the number of options there are.
es:@2520
This is, again, the message box: This $1 in the context of a message means @2535this value, which is 71, is getting a thing replaced with. Now, without telling you all the gory details, I'll tell you a few of the gory details about how this thing is done.
es:@2535
@2550The first thing to note is -- Oh boy, this is more complicated than it needs to be.
es:@2550
The first thing that's happening is, @2565we are making ourselves a bang before all the arguments of the message. So a note is coming in here, and we're unpacking it. Then we are going to pack something which consists of the note, but we're also going to choose a
es:@2565
@2580voice number, which will choose which one of the 8 sample voices to play.
es:@2580
You've seen this pack and route combination before, in the example from February 3rd, I think ... @2595where I was doing the first polyphonic thing with an abstraction already had this, I believe. OK. So what's happening here is that whatever these seven numbers are, we're going to add an eighth number in the beginning and then we're going to pack it into
es:@2595
@2610a message with eight values. Then we're going to route according to the first one. That is going to be a message for the sample voice.
es:@2610
Now, the sample voice, this is an abstraction, now, which is @2625made for just for this one patch, is working by adding itself to the previous one, so this is a summing bus again. Now I can show you what the summing bus looks like. There's a lot of stuff here to look at, but
es:@2625
@2640I'll start with this.
es:@2640
Here's how you make a summing bus. It's really stupid. You just take whatever came in inlet~, and add yourself to it. So whatever you had to do to compute the sample it's getting added to this inlet, and then it's going to become the outlet. @2655If you make an abstraction that's designed like that, then you can just stack them up and put them one to the next. Then they add themselves up into the sum of all the voices.
es:@2655
All right. So I'm not going to try to tell you how @2670everything in here works because you'll all fall asleep. But the basic idea is the same as what you've seen before. which is that there's an inlet here which is corresponding to what comes in from the
es:@2670
@2685route object. Except that's the second inlet. The first inlet is the inlet for the summing bus. So this thing has two inlets and one outlet. This is a signal inlet which corresponds to the inlet~ you saw,
es:@2685
@2700which was the summing bus inlet~. And that gets added to whatever computes and that goes there.
es:@2700
Meanwhile in here come messages, one message per note. And each message consists of, what was it: pitch, @2715amplitude, onset, duration, sample number, and then the location of the sample, rise and fall. And then using techniques that mostly you know, but using more mathematics than I've thrown at you
es:@2715
@2730before, compute messages that you send to a line~. And I decided to make this a vline~ -- for reasons that I'll try to explain later. But the basic deal is you just work. You make a patch, and
es:@2730
@2745eventually messages go to this vline~, which is generating indices into the tabread4~. This vline~ is making amplitudes, and this vline~ is getting multiplied
es:@2745
@2760by it to control the overall amplitude. There are two amplitude controls here. OK. And I don't want to give you all the details, because it's just going to be too much. I'm just going to show you this as the overall design strategy for the instrument.
es:@2760
And this is @2775explained step by step in the book if you want to see all this in gory detail -- gorier detail than I want to do right now. This is about the craft of making a decent, good, working sampler, which is harder than the basic
es:@2775
@2790things that I've shown you so far.
es:@2790
So that pretty much concludes the basic tools for making abstractions and how you use the basic mechanisms for doing abstractions, which are the dollar-sign @2805mechanism, inlets and outlets, and the route object, and then all those objects like send and receive, throw and catch -- and the one I haven't shown you yet is the signal version of send and receive, because we haven't needed it yet.
es:@2805
@2820All right. Now, change of subject. So that's abstractions. Oh, before I change the subject ... How's the homework going
es:@2820
@2835for Thursday? Or that's another change of subject. Should I show you the homework again and see if there are questions about it? I see one nod anyway.
es:@2835
@2850Let me do that real quick. Student: Is there going to be an extra credit for this week?
es:@2850
Miller: I haven't been able to think of one. The thing I thought was going to work as an extra credit just sounded cruddy. And then I could think of ways of fixing it, but they all were much too much work to ask you to do, so @2865I ended up not being able to think of one. Student: OK.
es:@2865
Miller: OK, so here it is -- just so you can hear it and see it again. Do we want to save, no. So we're done with the help browser. @2880Oh dear, am I going to be able to find this now? ... There. All right. Does it work? Yeah. [audio clip plays "soft and relaxing" ultra-slow]
es:@2880
@2895 [....]
es:@2895
@2910 [...]
es:@2910
@2925So that is -- I think; I'd have to go look -- but it's driven by a phasor,
es:@2925
@2940if I remember correctly. No, no, no. -- I didn't do that. I made it driven by a line~, because it was easy to figure out how to do it that way. And basically all it is is a bunch of chunks of a sample that are gradually moving forward. [audio clip plays]
es:@2940
@2955And frequency and size are how big the grain is - which, by the way changes the pitch -- is because if you read more of the thing in a fixed amount of time, you get more
es:@2955
@2970transposition. The frequency is of course how many of them happen per second. And part of the trick here is, you've also got something that can make
es:@2970
@2985actual pitches. So this is a fast way to have a lot of fun with samples.
es:@2985
But see if you could just get it to do this thing:["soft and relaxing" ultra-slow] @3000because then you already will have made yourself able to do all the rest. That's clear? That is for
es:@3000
@3015Thursday, and I couldn't think of a good extra credit to ask for. The extra credit I wanted to ask for was to make three of them and have it be in a major triad or something like that. But then when you listen to it, it's just hash. You can't actually tell what going on. It's too thick, sonically. You could fix that but it
es:@3015
@3030requires things you don't know about yet.
es:@3030
OK. The homework for next week - this is looking in the future - is just a simple exercise - @3045well, "simple" ... It's a first exercise about polyphonic voice allocation. [example music]
es:@3045
Miller: I decided to make something as different as possible @3060from the "continuous soft and relaxing ..."
es:@3060
. This is no more complicated than it sounds like. It turns out that if you play a siusoid and then make it decay, it has this sort of wet reverberant sound, @3075just because one's used to hearing the sounds of decaying things, and reverberant spaces, I guess.
es:@3075
So it has this very sort of drippy sound. Although that's nothing but just plain old sinusoidal oscillators, exactly like the ones I've shown you. If you leave them running it sounds dry and ugly, but @3090then if you turn it on and then quickly fade it out, then it starts sounding like this. [example music]
es:@3090
Miller: Except -- I should say that you can probably tell -- there's more than one sound happening at once. You wouldn't be able to do this with one oscillator because, in fact, at any given time there are @3105ten of these things sounding at once. This is a 12-voice machine that I've made for this.
es:@3105
So what's happening now is there are notes being generated ... There's a speed, which is controlled by a metronome; @3120there's a duration -- exactly as in the Risset bell. So now you can make sort of classic computer-music sounds. And the other thing that I thought was useful
es:@3120
@3135immediately was being able to change the bass frequency. This is actually quite easy to do. It's just conceptually fun.
es:@3135
@3150It's easier than this last one, I guarantee you. Student: Why is the metronome set up so that larger numbers slow down? It seems kind of counter-intuitive ...
es:@3150
Miller: OK, so the metro object @3165takes an argument which is the milliseconds between things, so really the question would be why is the metronome object designed that way. It's so that you can get exact values out of it.
es:@3165
@3180Since the scheduler works in units of time instead of units of tempo ... If you say, for instance, 1,000 to it it really will come down once every second, but
es:@3180
@3195if you're doing tempo then if you say 1,001, what's that a tempo of?
es:@3195
It's 59.9 something, but then there would be a round-off error. So the @3210fundamental metro object does that simply so that you can do things that are exact and repeatable. Why didn't I make this thing do the right thing and be 120 be: "120 means two per second", and so on? It's because that would have been making me work harder.
es:@3210
@3225You can do it. It's easy to compute what you should feed the metronome to get a specific tempo.
es:@3225
You just take the thing and divide it into 60,000 and I could explain why, but what that means is 60 should go to @3240one second, which is 1,000 and 120 should go to 500 and so on. So you're dividing (60,000 by the metronomic value) to get the milliseconds you feed the metronome. But that's adding another step to the homework
es:@3240
@3255that you have to do that wasn't really part of the homework or wasn't part of the idea anyway.
es:@3255
So yeah, you can do it either way. OK. @3270The one object I haven't told you about that will make this possible ... Obviously there's a sequence of pitches there; I've shown you how to make repeating sequences. But this is even stupider than that. This is just random numbers.
es:@3270
@3285They are random numbers with a particular range, which you probably can't hear, but it's two octaves.
es:@3285
So how would you do that? This would be the moment @3300to just show you something. Here's a new patch ... font 16 point "OK" and we're going to save it, not here but back in the website since you'll see it. <<saving "2.08/3.random.pd"
es:@3300
@3315Randomness: So this is an aesthetic fault-line in computer music.
es:@3315
@3330The word "random" or the word "stochastic" has musical baggage when you use it. So we're going to forget all the musical baggage associated with randomness and just consider this as a technique rather than as a musical statement. So here's how randomness works: You just say
es:@3330
@3345"random" and then give it a range <<25 in this example>>.
es:@3345
And then every time you give it a bang in, which I'll just give myself a bang object to do now, out will @3360come a number which is between 0 and 24 inclusive, so that there are 25 possible values. Stupid. Usually
es:@3360
@3375that's all you do. Every once in a while you have to actually explicitly give it a seed, because you have two of them, and you want them to have exactly the same random sequence as each other.
es:@3375
Silly as that might sound, it does happen that you want to do that sometimes. So you can seed these things. @3390That's stuff that you can find out in the help window. But 99 times out of a 100, just the object itself is what you want. And now, for instance, just to make, first off, to
es:@3390
@3405make random pitches, do that and add some base pitch. <<"+ 60" in this example>> Oh, right, what does that do?
es:@3405
That gives us random numbers between 60 and 84, I think, @3420inclusive, right, 60, 85 -- but 84 really, because this only goes up to 24. And now that could be something that we feed to midi to frequency <<mtof>>, and then
es:@3420
@3435to an oscillator, and then to a output. And now we have Idiot's Delight: [sound of random notes with every click of the bang]
es:@3435
Student: @3450Why are there 24 values and you specified "25" to "random"?
es:@3450
Miller: Oh. These numbers coming out of here range from 0 to 24; there are 25 possible values when 0 is included. And why 25? @3465Because that's two octaves, including the two end points, if you're talking chromatic. Right, if you're talking all the keys, not just the white keys.
es:@3465
If you want to work harder, figure out how to make this work only with the keys in a @3480given scale, that would be something that I don't want to tell you how to do right now. You can use modular arithmetic to do it, but you'd have to actually think about music theory to get there. And that would be a thing.
es:@3480
@3495So there's randomness. -- Oh, and this is randomness the way it sounded in the 1960's: [sound plays]
es:@3495
And while we're here, @3510it's a good point to mention the existence of micro-tonality. That's the difference between this -- Oh, let me just make this be a musical fifth wide. OK, so now we have: [sound plays].
es:@3510
@3525Stuff like that? -- Let me make a nice metronome so you can hear this systematically.
es:@3525
@3540And that really wants a toggle to turn it on and off. ... I'm doing this so that I can compare it to another thing: [sound plays]
es:@3540
@3555OK, now if you could do it fast enough, you could play those pitches on a piano. Because they are all integers. But if you didn't
es:@3555
@3570want integers, if you really wanted to sound like an analog synthesizer, you could do this:
es:@3570
Now, random number generators in general make random numbers that are integers, even if it looks like @3585it's making something other than integers, the pseudo-random number generator in the computer is really making integers. So true to that, random really does only make integers. But we can say, "Why don't we have a random thing that goes
es:@3585
@3600from 0 to 700?"x And then we're going to divide by 100.
es:@3600
Or should I make it 800? @3615Let's do 800 just to be ... simpler. OK. So "random 800" and divided by 100
es:@3615
@3630is the same thing as random 8, except that here a perfectly good value would be 50, and that would turn into 0.5, which won't come out of this one. So this now is [sound plays] , the chromatic version, and this is going to be
es:@3630
@3645the micro-tonal version. [sound plays]
es:@3645
Can you hear the difference? That's the genuine, almost the continuous collection of possible pitches, @3660as opposed to this, which is [sound plays] ... which is cycling back and forth between the same eight pitches over and over again. OK? So that's
es:@3660
@3675randomness and a sort of a note about quantization that might inform how you would choose random numbers.
es:@3675
Another thing to think about, another thing that you might want to do here, now that you've got nice @3690random numbers, is use a table to have random numbers that are chosen from a set of possibilities that you might have pre-arranged. And that table you would set up in the same way as you set up the sequencer table from many weeks earlier.
es:@3690
And then you could choose randomly from a collection @3705of pitches that you chose, and could even change dynamically, if you want. So now you have easy way to make standard MIDI-art kinds of things. That's randomness, and that is only there so that you can know
es:@3705
@3720how to do this, because the only thing that you don't know how to do about this yet is generating all these pitches. [sound plays] ... And all it was was something like this. Yeah?
es:@3720
Student: My output box @3735comes out as a slider. How do I get it to come out as a number box?
es:@3735
Miller: Oh, you've got Pd extended. Someone wrote another kind of output~ thing. You have to go get this one. ... You know what, which is inside. @3750It's on the website. If you look at the sample patches from any time in the last week or two, there will be one of these. And if you put that in the same directory as the patch you're working on that will be read first and it will give you one of these instead of the one you're getting.
es:@3750
Student: @3765It's on the DVD, too.
es:@3765
Miller: Oh, and it's on the DVD, too. There's probably nothing wrong with the other one. It's probably better. @3780Alright, done that. Now I'm going to shift gears entirely and start talking about modulation. The first thing to know about modulation is this: this is something I've mentioned before, but not really
es:@3780
@3795made much out of. So we're going to make this "4.ring.modulation". Ring modulation is the following idea.
es:@3795
@3810This is really, really simple, except you can do a lot with it.
es:@3810
Take two oscillators and multiply them. @3825OK. So right now we're just re-creating something you've seen already once. So I'm going to make number boxes to set the frequencies. The first one will just be a reasonable frequency for listening to the pitch A; so it's going to be 440.
es:@3825
@3840The second one is whatever I give it, which will be a medium frequency to change the amplitude -- this is like from day one -- and then higher values make the sound split.[variety of sounds with different frequency settings]
es:@3840
@3855So there are several ways of thinking about this: One of them is that you know that if you have two different sinusoids at different frequencies that you hear they'll beat together, at least at the frequency they're close. So you can think of that
es:@3855
@3870as a sinusoid multiplied by another sinusoid. In fact, it's a trigonometric identity. But you can apply it backward. You can take this thing and make it beat by multiplying it by an oscillator.
es:@3870
What that is is it's mathematically equal to two other sinusoids, @3885one at 338 and one at 442. Then if you make this go faster they split further and further apart until you can hear them at two separate pitches. That's a good thing.
es:@3885
@3900The good thing about it is not that you can make two oscillators out of one because, of course, you could've done that by adding them, but that you can take anything you want to and do that to it. For instance,
es:@3900
@3915let's just do it live:
es:@3915
So now instead of the oscillator I'm just going to use the microphone. @3930Risky choice. ... Microphone, microphone ... OK.
es:@3930
@3945Does the microphone work? Oh boy does it work!
es:@3945
Hello. I'm talking into the microphone. Why do we hear that? Because I haven't turned this on. Hello, hello? @3960This is not good because I'm not going to be able to do anything else than have myself be heard. OK, there's probably a button here.
es:@3960
@3975There is a monitor switch; let's use it. Hello, hello? Good. It went away. Alright, so now let's turn this to zero. So nothing comes out because I'm sending sound to the computer,
es:@3975
@3990but it's not sending out. (I had my audio interface on "monitor" before.) Now we turn this on. OK, so this is my voice being amplified through the patch. So now I can do anything that I want to to it. In particular
es:@3990
@4005I can make it start beating. ... So now we have "tremolo" ... So if I make a nice long tone then you get that. OK.
es:@4005
So now the fun part is: @4020So now we've got nice monster voices from a sixties TV show. OK. What happened there is
es:@4020
@4035kind of cool. Whatever pitch I'm going at has not just itself but it has a bunch of harmonics in it. If it was just a sinusoid you would just hear two pitches split off, but, in fact,
es:@4035
@4050a harmonic tone is a bunch of sinusoids and each one of them is going to get split off, but they're going to get split off by a fixed frequency deviation.
es:@4050
Suppose I happen to be talking at 100 hertz, @4065which is a typical droning frequency for my voice right now. So this thing is going to turn that into 100 + 53 and 100 - 53.
es:@4065
@4080Then the first overtone or the second harmonic at 200 Hertz goes to 253 and 200 - 53, which is 147. So if I put 100 hertz in, the
es:@4080
@4095original overtones are 100, 200, 300, 400 and then what comes out is 47, then I get 147,
es:@4095
@4110then 153, then 247, then 253, and so on like that.
es:@4110
And I'm not sure if this is really 100 Hertz [voice changes in microphone] but it's, it's not going to be harmonic @4125it's going to be computer-music. [sings a tone] Oh, you know what, if I happen to hit twice 53 which is 106 then I get a nice harmonic sound again: [sings Aaaahhhh] ... which is an octave down from where I started. [stops singing]
es:@4125
@4140Which is cool but if I want to do that in a robust way I would have to figure out what the pitch was and constantly adjust the 53. You can do that; I can show you how to do that later. Student: On the right output, is that stereo?
es:@4140
Miller: @4155Yes. That's the other channel; I'm only running into the left channel on this mic so there is nothing coming out of it.
es:@4155
O.K. But then if I do a different pitch [sings tone] You just don't have things that line up in @4170harmonic series so you have something that would be more typical of a bell tone, except I can't make a bell sound because I would have to make my voice envelope like that and I don't think it's physiologically possible.
es:@4170
But it's a thing that's an inharmonic spectrum @4185as the spectrum of the bell might be. If I took that: [sings tone] and sampled it and then enveloped it I could make bellish sounds maybe. Or crude bellish sounds I should say.
es:@4185
@4200This is actually a very general and powerful technique even though it looks stupid. You just take anything that you want and multiply it by an oscillator and it takes the frequencies and slides them both to the left and right.
es:@4200
With very carefully designed @4215filters you can actually separate the part that slides to the left from the part that slides to the right. But that is stuff from Chapter 8; you don't get to see that just yet. As it is, it is already pretty powerful. ... Questions about this?
es:@4215
@4230So another example would be; lets make a very simple computer music instrument: So now I want to make, in the simplest possible way,
es:@4230
@4245a sound that has some interesting overtones that's just made out of an oscillator. So we're going to be doing all of this stuff again. Except I'm not going to do it to my voice; I'm going to do it to an instrument. So let's design
es:@4245
@4260the instrument first.The instrument is going to be... We'll take an oscillator and then just act stupid with it. We're just going to clip it between some
es:@4260
@4275decent negative value and some decent positive value. OK and now I'll just play this now so you can hear it:
es:@4275
@4290Whoa, nothing. [pause] Whoa look at that, that's not going to work. <<makes the missing connection from the "osc~" to the "clip~">> [oscillator works]
es:@4290
@4305Oh OK that's not so exciting is it? Let's drop this a little bit. There we go. Now what's happening, I showed you this before in a different context. All we're doing is were taking the oscillator
es:@4305
@4320which is a sinusoid and clipping the bottom and top. That's a very simple waveshaping kind of way to make a different kind of waveform. And that by the way -- that's a big topic which I will
es:@4320
@4335give you some mathematics about in the next couple of sessions. But right now I'm just going to do that and have it be a nice sound.
es:@4335
Alright. and now this sound that we have I want to take and "ring modulate". @4350So now we have the same sound but now [with additional frequencies] sound that's being modulated. That's not a very good choice of frequencies. [noise]
es:@4350
@4365So this is a very fast way of making inharmonic
es:@4365
@4380spectra out of harmonic ones. And this you know, it doesn't look like much but if you listen to electronic or especially computer music of the last -- especially actually the period 60's through 90's --
es:@4380
@4395This is going to suffuse everything because people got very excited about being able to make inharmonic spectra having been imprisoned largely to harmonic spectra plus an occasional bell for most of the history of music.
es:@4395
So people made music-theory @4410kinds of thoughts about how the inharmonic spectra could mix and whether there could be consonant or dissonant intervals between sounds that didn't have pitches but had just spectra like this:[sounds] And so that's a rich
es:@4410
@4425source of musical inspiration that was brought on by the electronic and the computer music eras. So this is the sort of general direction that we'll go in now. Having seen the multiple voice thing, the abstraction mechanism.
es:@4425
@4440The next thing is learning how to design sounds using the techniques of modulation and waveshaping. -- which are represented here by this multiplier and this clip~.