WEBVTT

00:00:00.000 --> 00:00:00.956 align:middle line:90%
[SQUEAKING]

00:00:00.956 --> 00:00:03.824 align:middle line:90%
[RUSTLING]

00:00:03.824 --> 00:00:06.692 align:middle line:90%
[CLICKING]

00:00:06.692 --> 00:00:10.040 align:middle line:90%


00:00:10.040 --> 00:00:12.000 align:middle line:84%
PROFESSOR: Hi,
OpenCourseWare learners.

00:00:12.000 --> 00:00:14.090 align:middle line:84%
We've gotten to the part
of the first lecture

00:00:14.090 --> 00:00:16.309 align:middle line:84%
where the technical
difficulties made it

00:00:16.309 --> 00:00:19.110 align:middle line:84%
a little too hard to follow
what was happening there.

00:00:19.110 --> 00:00:23.000 align:middle line:84%
So I'm going to
rerecord what we all did

00:00:23.000 --> 00:00:25.400 align:middle line:90%
as the opening of the class.

00:00:25.400 --> 00:00:31.110 align:middle line:84%
To begin, go ahead and go to
the URL on the screen right now.

00:00:31.110 --> 00:00:33.920 align:middle line:84%
This is a project
from Google called

00:00:33.920 --> 00:00:39.110 align:middle line:84%
Colab that allows you to run
Python scripts, including

00:00:39.110 --> 00:00:44.300 align:middle line:84%
Music21, in your own browser,
without installing anything

00:00:44.300 --> 00:00:45.090 align:middle line:90%
on your computer.

00:00:45.090 --> 00:00:49.080 align:middle line:84%
So go ahead and click
this Play button.

00:00:49.080 --> 00:00:51.380 align:middle line:84%
You're going to see
a warning that Google

00:00:51.380 --> 00:00:52.770 align:middle line:90%
didn't write this notebook.

00:00:52.770 --> 00:00:54.230 align:middle line:90%
I did.

00:00:54.230 --> 00:00:56.940 align:middle line:90%
I think it's pretty safe.

00:00:56.940 --> 00:01:00.940 align:middle line:84%
What it does is it installs
the latest version of Music21,

00:01:00.940 --> 00:01:04.780 align:middle line:84%
and MuseScore, and some
other software needed

00:01:04.780 --> 00:01:08.800 align:middle line:84%
to run some of the tools
we're going to be using,

00:01:08.800 --> 00:01:12.040 align:middle line:84%
without installing
Python on your computer.

00:01:12.040 --> 00:01:14.930 align:middle line:84%
Google already has
a copy of Music21,

00:01:14.930 --> 00:01:20.800 align:middle line:84%
but this just brings you
to the latest version.

00:01:20.800 --> 00:01:24.580 align:middle line:84%
And go ahead and pause,
and we'll come back

00:01:24.580 --> 00:01:26.210 align:middle line:90%
after it's all installed.

00:01:26.210 --> 00:01:33.160 align:middle line:90%


00:01:33.160 --> 00:01:34.280 align:middle line:90%
Welcome back.

00:01:34.280 --> 00:01:38.420 align:middle line:84%
I hope that these cells
aren't running anymore.

00:01:38.420 --> 00:01:40.310 align:middle line:90%
So we can start coming in.

00:01:40.310 --> 00:01:42.580 align:middle line:84%
If you've never used
Jupyter Notebook

00:01:42.580 --> 00:01:44.930 align:middle line:84%
or another online
collaborative environment,

00:01:44.930 --> 00:01:47.050 align:middle line:84%
the important thing that
you're going to need

00:01:47.050 --> 00:01:49.100 align:middle line:84%
is to be clicking
into these cells.

00:01:49.100 --> 00:01:50.840 align:middle line:84%
The gray ones are
where you type.

00:01:50.840 --> 00:01:54.190 align:middle line:84%
And the ones with the
white or black background

00:01:54.190 --> 00:01:57.560 align:middle line:84%
are the ones where
output's coming out.

00:01:57.560 --> 00:02:02.440 align:middle line:84%
In order to run a cell, you
just type Shift and Return

00:02:02.440 --> 00:02:03.680 align:middle line:90%
or Shift and Enter.

00:02:03.680 --> 00:02:05.380 align:middle line:84%
So what we're going
to do is I'm just

00:02:05.380 --> 00:02:09.350 align:middle line:84%
going to click into this
cell and hit Shift Enter.

00:02:09.350 --> 00:02:12.800 align:middle line:84%
And this will make sure
that Music21 actually works.

00:02:12.800 --> 00:02:17.260 align:middle line:84%
Sometimes the first
time you show a score

00:02:17.260 --> 00:02:19.190 align:middle line:90%
it doesn't work as well.

00:02:19.190 --> 00:02:21.410 align:middle line:84%
And on some browsers,
this will work.

00:02:21.410 --> 00:02:23.470 align:middle line:90%
You can listen to a score.

00:02:23.470 --> 00:02:27.595 align:middle line:84%
And let's see if
this works or not.

00:02:27.595 --> 00:02:28.780 align:middle line:90%
[TONE]

00:02:28.780 --> 00:02:30.040 align:middle line:90%
There we go.

00:02:30.040 --> 00:02:32.850 align:middle line:84%
And now we're ready
to actually begin.

00:02:32.850 --> 00:02:34.600 align:middle line:84%
We're not going to
generate with AI today.

00:02:34.600 --> 00:02:37.570 align:middle line:90%
We'll write our own scores.

00:02:37.570 --> 00:02:39.610 align:middle line:84%
So if you're with
me, we're going

00:02:39.610 --> 00:02:42.820 align:middle line:84%
to start anything where
you're doing a Python

00:02:42.820 --> 00:02:46.190 align:middle line:84%
session by importing
the code that's useful.

00:02:46.190 --> 00:02:49.460 align:middle line:84%
And for this one, it's
the Music21 toolkit.

00:02:49.460 --> 00:02:51.860 align:middle line:84%
So we're going to import
everything from it.

00:02:51.860 --> 00:02:55.150 align:middle line:84%
If you're somebody who's
done a lot of Python

00:02:55.150 --> 00:02:58.520 align:middle line:84%
and cares about things like
polluting your namespace,

00:02:58.520 --> 00:03:00.400 align:middle line:90%
you can do individual modules.

00:03:00.400 --> 00:03:03.330 align:middle line:84%
But I'm always going to do it
as if we have all the parts

00:03:03.330 --> 00:03:08.370 align:middle line:90%
of Music21 at your fingertips.

00:03:08.370 --> 00:03:13.330 align:middle line:84%
So we're going to load a chorale
by Johann Sebastian Bach.

00:03:13.330 --> 00:03:17.260 align:middle line:84%
It's his shortest
chorale, called BWV66.6.

00:03:17.260 --> 00:03:19.720 align:middle line:84%
So first, I'll create a
variable, call it Bach.

00:03:19.720 --> 00:03:25.140 align:middle line:84%
And we'll use the corpus tool
from Music21 and its parse

00:03:25.140 --> 00:03:30.786 align:middle line:84%
function to load
in bach/bwv66.6.

00:03:30.786 --> 00:03:32.440 align:middle line:90%
And I'll hit Shift Enter.

00:03:32.440 --> 00:03:34.240 align:middle line:90%
And it's assigned to Bach.

00:03:34.240 --> 00:03:40.000 align:middle line:84%
And we can call the method show
on it to see the score of that.

00:03:40.000 --> 00:03:43.630 align:middle line:84%
Yep, looks like a
chorale by Bach.

00:03:43.630 --> 00:03:46.930 align:middle line:84%
And you can see that has
soprano, alto, tenor, bass.

00:03:46.930 --> 00:03:52.600 align:middle line:84%
And we can get the alto
part by saying bach.parts,

00:03:52.600 --> 00:03:55.780 align:middle line:90%
square brackets, open, alto.

00:03:55.780 --> 00:03:57.785 align:middle line:90%
And we'll just show that.

00:03:57.785 --> 00:04:01.840 align:middle line:90%


00:04:01.840 --> 00:04:02.500 align:middle line:90%
Yes.

00:04:02.500 --> 00:04:04.690 align:middle line:90%
Looks like the alto part.

00:04:04.690 --> 00:04:07.420 align:middle line:84%
Now let's get the soprano
part and assign it

00:04:07.420 --> 00:04:10.010 align:middle line:90%
to a variable sopr for soprano.

00:04:10.010 --> 00:04:11.440 align:middle line:90%
And we'll just do that.

00:04:11.440 --> 00:04:15.590 align:middle line:84%
Instead, this time we'll get
it by doing the part number.

00:04:15.590 --> 00:04:17.660 align:middle line:90%
And so it's the first part.

00:04:17.660 --> 00:04:21.950 align:middle line:84%
And so in Python, that
means it's part 0, parts 0.

00:04:21.950 --> 00:04:27.130 align:middle line:84%
And one of the things
that we do in Music21

00:04:27.130 --> 00:04:31.010 align:middle line:84%
is when something is
in a programmer's rule,

00:04:31.010 --> 00:04:35.080 align:middle line:84%
we follow the conventions
of programming,

00:04:35.080 --> 00:04:37.010 align:middle line:90%
where everything starts with 0.

00:04:37.010 --> 00:04:39.063 align:middle line:84%
And when we're in
musician space,

00:04:39.063 --> 00:04:40.480 align:middle line:84%
such as talking
about measures, we

00:04:40.480 --> 00:04:43.570 align:middle line:84%
don't subtract 1 from the
measure number or anything

00:04:43.570 --> 00:04:44.420 align:middle line:90%
like that.

00:04:44.420 --> 00:04:49.870 align:middle line:84%
So if we wanted to just see
measures 3 through 5, inclusive

00:04:49.870 --> 00:04:55.120 align:middle line:84%
of the soprano part, we
could do something like that.

00:04:55.120 --> 00:04:57.400 align:middle line:90%
Oops.

00:04:57.400 --> 00:05:01.410 align:middle line:84%
Or we could type the
word measures properly.

00:05:01.410 --> 00:05:04.520 align:middle line:90%
And then we'll get that measure.

00:05:04.520 --> 00:05:05.820 align:middle line:90%
Just gets a single measure.

00:05:05.820 --> 00:05:06.720 align:middle line:90%
This one got that.

00:05:06.720 --> 00:05:07.370 align:middle line:90%
Great.

00:05:07.370 --> 00:05:11.030 align:middle line:84%
And in fact, we'll use
the measure thing now.

00:05:11.030 --> 00:05:15.110 align:middle line:84%
And we'll get in measure five,
the zeroth, first, second note,

00:05:15.110 --> 00:05:16.860 align:middle line:90%
the one with the fermata on it.

00:05:16.860 --> 00:05:20.270 align:middle line:84%
And so we'll call it C
because it's a C. Actually,

00:05:20.270 --> 00:05:21.240 align:middle line:90%
it's a C sharp.

00:05:21.240 --> 00:05:24.600 align:middle line:90%
But we'll see why not.

00:05:24.600 --> 00:05:28.490 align:middle line:90%
And so we'll get notes number 2.

00:05:28.490 --> 00:05:31.850 align:middle line:84%
If we called it C sharp,
then everything after this

00:05:31.850 --> 00:05:32.665 align:middle line:90%
would be a comment.

00:05:32.665 --> 00:05:33.540 align:middle line:90%
So that doesn't work.

00:05:33.540 --> 00:05:36.290 align:middle line:84%
So we'll just call
it C. And now what

00:05:36.290 --> 00:05:40.760 align:middle line:84%
we can do is manipulate
it, change its style,

00:05:40.760 --> 00:05:43.580 align:middle line:90%
its color to red.

00:05:43.580 --> 00:05:48.050 align:middle line:84%
And now when I show the soprano
part, because they're all linked

00:05:48.050 --> 00:05:50.130 align:middle line:90%
to each other, we should see--

00:05:50.130 --> 00:05:52.195 align:middle line:84%
yep, there's a
note that's in red.

00:05:52.195 --> 00:05:55.940 align:middle line:90%


00:05:55.940 --> 00:05:58.820 align:middle line:84%
So that's how we can
manipulate a score.

00:05:58.820 --> 00:06:03.910 align:middle line:84%
And now let's see how we can
do some analytical functions

00:06:03.910 --> 00:06:04.610 align:middle line:90%
on things.

00:06:04.610 --> 00:06:06.860 align:middle line:90%
So let's do Bach to analyze.

00:06:06.860 --> 00:06:10.990 align:middle line:84%
And we'll analyze
the key of the piece.

00:06:10.990 --> 00:06:13.540 align:middle line:84%
And it says it returns
a key object that

00:06:13.540 --> 00:06:15.410 align:middle line:90%
says it's in F sharp minor.

00:06:15.410 --> 00:06:17.590 align:middle line:84%
And one of the things I
really want to emphasize

00:06:17.590 --> 00:06:20.450 align:middle line:84%
is always go back and
do the smell test.

00:06:20.450 --> 00:06:23.630 align:middle line:84%
Is this true, or does
it look like baloney?

00:06:23.630 --> 00:06:26.890 align:middle line:84%
And we can see,
well, begins on A,

00:06:26.890 --> 00:06:29.000 align:middle line:90%
but it does have three sharps.

00:06:29.000 --> 00:06:32.600 align:middle line:84%
And at the end, yep, there
is an F sharp in the bass.

00:06:32.600 --> 00:06:36.910 align:middle line:84%
Though, it looks kind
of like F major, but--

00:06:36.910 --> 00:06:38.650 align:middle line:90%
OK, here some F minor.

00:06:38.650 --> 00:06:41.770 align:middle line:84%
OK, it kind of passes
the smell tests.

00:06:41.770 --> 00:06:44.690 align:middle line:84%
And we'll see why that's so
important in just a little bit.

00:06:44.690 --> 00:06:48.080 align:middle line:84%
But it did seem like
it was beginning in A.

00:06:48.080 --> 00:06:50.660 align:middle line:84%
So we can just analyze
a portion of that.

00:06:50.660 --> 00:06:55.780 align:middle line:84%
So we'll do bach measures 0,
because we want the pickup

00:06:55.780 --> 00:06:57.640 align:middle line:90%
measure, and 2.

00:06:57.640 --> 00:07:01.745 align:middle line:84%
And we'll analyze the
key of just that passage.

00:07:01.745 --> 00:07:04.180 align:middle line:84%
Ah, does seem to
start in A major.

00:07:04.180 --> 00:07:07.280 align:middle line:90%


00:07:07.280 --> 00:07:09.150 align:middle line:84%
Let's do something that
seems pretty simple.

00:07:09.150 --> 00:07:11.510 align:middle line:84%
Let's count the number
of notes in the piece.

00:07:11.510 --> 00:07:15.300 align:middle line:84%
So we can just do
len bach.notes.

00:07:15.300 --> 00:07:17.750 align:middle line:84%
That just gets all the
notes of the piece.

00:07:17.750 --> 00:07:20.470 align:middle line:84%
In another language, it
would be bach.notes.length.

00:07:20.470 --> 00:07:24.765 align:middle line:90%


00:07:24.765 --> 00:07:26.640 align:middle line:84%
I don't know how many
notes are in the piece,

00:07:26.640 --> 00:07:29.040 align:middle line:84%
but I'm pretty sure
it's more than 0.

00:07:29.040 --> 00:07:33.110 align:middle line:84%
And the reason for
this is that Music21

00:07:33.110 --> 00:07:37.370 align:middle line:84%
and most ways of conceiving
music on the computer

00:07:37.370 --> 00:07:39.780 align:middle line:84%
don't think of the
score as having notes.

00:07:39.780 --> 00:07:41.370 align:middle line:90%
The score has parts.

00:07:41.370 --> 00:07:42.980 align:middle line:90%
The parts have measures.

00:07:42.980 --> 00:07:45.090 align:middle line:90%
And the measures have notes.

00:07:45.090 --> 00:07:49.730 align:middle line:84%
So what we could do is get
the length of bach parts

00:07:49.730 --> 00:07:55.770 align:middle line:84%
1, measure 2, dot
notes, and see, OK,

00:07:55.770 --> 00:07:57.660 align:middle line:90%
that passes the smell test.

00:07:57.660 --> 00:08:00.300 align:middle line:84%
So what we can do
instead is we can

00:08:00.300 --> 00:08:01.660 align:middle line:90%
use something called recurse.

00:08:01.660 --> 00:08:05.460 align:middle line:90%
So we'll get the bach.recurse.

00:08:05.460 --> 00:08:07.510 align:middle line:90%
That's a function, or a method.

00:08:07.510 --> 00:08:10.060 align:middle line:90%
And we get the notes on that.

00:08:10.060 --> 00:08:12.870 align:middle line:84%
And what recurse says
is, open up every box.

00:08:12.870 --> 00:08:14.140 align:middle line:90%
You get to a part.

00:08:14.140 --> 00:08:14.950 align:middle line:90%
Open it up.

00:08:14.950 --> 00:08:16.270 align:middle line:90%
Look inside for measures.

00:08:16.270 --> 00:08:20.070 align:middle line:84%
Open it up and keep going
until you find notes.

00:08:20.070 --> 00:08:21.880 align:middle line:90%
And 165 notes.

00:08:21.880 --> 00:08:26.310 align:middle line:84%
That seems to pass
the smell test to me.

00:08:26.310 --> 00:08:28.380 align:middle line:84%
Right now we've been
working with this

00:08:28.380 --> 00:08:32.200 align:middle line:84%
as a series of parts that are
not connected to each other.

00:08:32.200 --> 00:08:35.320 align:middle line:84%
But of course, there are
chords in there also.

00:08:35.320 --> 00:08:38.738 align:middle line:90%
But if we do bach.--

00:08:38.738 --> 00:08:41.980 align:middle line:84%
and here's another way
you can say recurse.

00:08:41.980 --> 00:08:45.060 align:middle line:84%
I want to recurse and get
everything that's a chord.

00:08:45.060 --> 00:08:47.380 align:middle line:84%
There are no chords
in this piece.

00:08:47.380 --> 00:08:51.700 align:middle line:84%
So we have to create some chords
using the chordify method.

00:08:51.700 --> 00:08:56.550 align:middle line:84%
So we'll say chor, for
chords, equals bach.chordify.

00:08:56.550 --> 00:08:59.470 align:middle line:90%


00:08:59.470 --> 00:09:06.635 align:middle line:84%
And now if we show
the chordify method--

00:09:06.635 --> 00:09:08.260 align:middle line:84%
And we can see that
some of these notes

00:09:08.260 --> 00:09:10.400 align:middle line:84%
are way too low to
be read properly.

00:09:10.400 --> 00:09:12.230 align:middle line:84%
And they have duplicated
notes and things.

00:09:12.230 --> 00:09:14.000 align:middle line:84%
And over the course
of the semester,

00:09:14.000 --> 00:09:19.070 align:middle line:84%
we'll find ways that we can make
this a lot more representable,

00:09:19.070 --> 00:09:22.000 align:middle line:84%
including things like
getting rid of passing

00:09:22.000 --> 00:09:25.850 align:middle line:84%
tones and other things that
disturb looking at the chords.

00:09:25.850 --> 00:09:31.330 align:middle line:84%
But for now, we can look at
chor for the chords, the number

00:09:31.330 --> 00:09:35.320 align:middle line:84%
of chords in that, and
see that, yep, that

00:09:35.320 --> 00:09:37.870 align:middle line:90%
looks like a reasonable number.

00:09:37.870 --> 00:09:40.570 align:middle line:84%
So I hope that gives
you a taste of some

00:09:40.570 --> 00:09:43.750 align:middle line:84%
of what we're going to be doing
over the course of the semester

00:09:43.750 --> 00:09:46.540 align:middle line:90%
of this class.

00:09:46.540 --> 00:09:50.360 align:middle line:84%
Now, we've gone very fast
through a bunch of things,

00:09:50.360 --> 00:09:52.030 align:middle line:84%
but don't worry,
because we're going

00:09:52.030 --> 00:09:53.870 align:middle line:90%
to lock all those things up.

00:09:53.870 --> 00:09:56.240 align:middle line:84%
Choridfy is going
to be locked up.

00:09:56.240 --> 00:09:58.860 align:middle line:84%
And now Analyze Key is
going to be locked up.

00:09:58.860 --> 00:10:00.060 align:middle line:90%
And what does that mean?

00:10:00.060 --> 00:10:03.470 align:middle line:84%
That means that it
won't be available to be

00:10:03.470 --> 00:10:07.590 align:middle line:84%
used in the rest of the class
until it's unlocked again.

00:10:07.590 --> 00:10:09.530 align:middle line:84%
The way this class
is going to work

00:10:09.530 --> 00:10:11.820 align:middle line:84%
is all of these
analytical tools,

00:10:11.820 --> 00:10:15.170 align:middle line:84%
all these ways of
conceiving a score,

00:10:15.170 --> 00:10:18.030 align:middle line:90%
will begin by being locked.

00:10:18.030 --> 00:10:22.910 align:middle line:84%
And then you'll do an assignment
either as a problem set

00:10:22.910 --> 00:10:27.680 align:middle line:84%
or as an in-class assignment,
where we'll figure out,

00:10:27.680 --> 00:10:29.160 align:middle line:90%
How does this work?

00:10:29.160 --> 00:10:31.020 align:middle line:90%
What are the ways of doing this?

00:10:31.020 --> 00:10:34.370 align:middle line:84%
And then once you've
designed your own algorithm

00:10:34.370 --> 00:10:37.100 align:middle line:84%
for doing these
things, you can either

00:10:37.100 --> 00:10:39.380 align:middle line:84%
continue to use
your own algorithm,

00:10:39.380 --> 00:10:43.400 align:middle line:84%
or you will have unlocked
the Music21 version

00:10:43.400 --> 00:10:44.190 align:middle line:90%
of the algorithm.

00:10:44.190 --> 00:10:46.898 align:middle line:84%
And from then on, you
can use that instead.

00:10:46.898 --> 00:10:48.440 align:middle line:84%
So we're going to
just be building up

00:10:48.440 --> 00:10:54.050 align:middle line:84%
knowledge little by little
until we have everything.

00:10:54.050 --> 00:10:57.550 align:middle line:84%
One of the things that as
an OpenCourseWare learner

00:10:57.550 --> 00:11:02.770 align:middle line:84%
you won't have access to is
the extremely valuable things

00:11:02.770 --> 00:11:04.850 align:middle line:90%
that happened outside of class.

00:11:04.850 --> 00:11:07.480 align:middle line:84%
Yes, coming to office
hours, but mostly

00:11:07.480 --> 00:11:10.070 align:middle line:84%
with students
helping each other,

00:11:10.070 --> 00:11:13.330 align:middle line:84%
giving each other inspiration
for projects they could do,

00:11:13.330 --> 00:11:16.210 align:middle line:84%
and helping them through some
of the more difficult parts

00:11:16.210 --> 00:11:17.300 align:middle line:90%
of the class.

00:11:17.300 --> 00:11:20.920 align:middle line:84%
So I encourage you, if
you can find somebody

00:11:20.920 --> 00:11:23.750 align:middle line:84%
else online who's also
taking the course,

00:11:23.750 --> 00:11:27.740 align:middle line:84%
or somebody who has taken it in
the past, and get to know them,

00:11:27.740 --> 00:11:30.310 align:middle line:84%
that will give you a lot
more of the experience

00:11:30.310 --> 00:11:32.980 align:middle line:84%
that the students had
at MIT when they were

00:11:32.980 --> 00:11:36.340 align:middle line:90%
taking the class in person.

00:11:36.340 --> 00:11:39.220 align:middle line:84%
I'm so glad that you've
chosen to take your time

00:11:39.220 --> 00:11:44.380 align:middle line:84%
to learn about the fascinating
world of music theory and music

00:11:44.380 --> 00:11:46.520 align:middle line:90%
analysis with a computer.

00:11:46.520 --> 00:11:48.790 align:middle line:84%
And I look forward to
seeing you again from time

00:11:48.790 --> 00:11:51.360 align:middle line:90%
to time in this course.

00:11:51.360 --> 00:11:57.000 align:middle line:90%