WEBVTT

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

00:00:02.485 --> 00:00:03.976 align:middle line:90%
[RUSTLING]

00:00:03.976 --> 00:00:07.455 align:middle line:90%
[CLICKING]

00:00:07.455 --> 00:00:09.442 align:middle line:90%


00:00:09.442 --> 00:00:11.400 align:middle line:84%
MICHAEL SCOTT ASATO
CUTHBERT: Hello, everybody.

00:00:11.400 --> 00:00:13.442 align:middle line:84%
One of the great things
about making these videos

00:00:13.442 --> 00:00:16.010 align:middle line:84%
is that we can introduce
small concepts that otherwise

00:00:16.010 --> 00:00:17.460 align:middle line:90%
might fall through the cracks.

00:00:17.460 --> 00:00:20.060 align:middle line:84%
So I want to introduce
the concept of ties

00:00:20.060 --> 00:00:22.850 align:middle line:84%
and how we represent
them in music21

00:00:22.850 --> 00:00:26.010 align:middle line:84%
and how you might represent
them in your own projects.

00:00:26.010 --> 00:00:30.410 align:middle line:84%
So let's go ahead and import
from music21 note, stream,

00:00:30.410 --> 00:00:32.670 align:middle line:90%
and the new tie module.

00:00:32.670 --> 00:00:37.260 align:middle line:84%
And we can go ahead and
create a stream of a measure.

00:00:37.260 --> 00:00:40.040 align:middle line:90%
We'll call it m.

00:00:40.040 --> 00:00:43.400 align:middle line:90%
And let's create two notes.

00:00:43.400 --> 00:00:46.110 align:middle line:84%
And doesn't really matter
what you make them.

00:00:46.110 --> 00:00:51.440 align:middle line:84%
Just make sure that they're the
same pitch because otherwise we

00:00:51.440 --> 00:00:53.330 align:middle line:90%
can't tie them.

00:00:53.330 --> 00:00:54.750 align:middle line:90%
That's pretty good.

00:00:54.750 --> 00:01:01.130 align:middle line:84%
And we'll say we'll
create a time signature.

00:01:01.130 --> 00:01:12.680 align:middle line:84%
That's why I usually eventually
will import star but 2/4.

00:01:12.680 --> 00:01:22.790 align:middle line:84%
And let's put
m.append(ts), m.append(n1).

00:01:22.790 --> 00:01:26.180 align:middle line:84%
Actually, we can just put
more than one thing in,

00:01:26.180 --> 00:01:30.050 align:middle line:90%
and we'll show these two notes.

00:01:30.050 --> 00:01:35.310 align:middle line:84%
And now while it's doing that,
we'll go ahead and get n1's.

00:01:35.310 --> 00:01:40.260 align:middle line:84%
tie will be a new tie.tie
object, and it'll be a start.

00:01:40.260 --> 00:01:45.030 align:middle line:84%
n2's tie will be a tie.tie
object, and it will be stop.

00:01:45.030 --> 00:01:48.270 align:middle line:84%
And now when we
show the measure,

00:01:48.270 --> 00:01:54.140 align:middle line:84%
we have what we should have
written as a half note, right?

00:01:54.140 --> 00:01:58.910 align:middle line:84%
But we can go ahead, and
let's create another measure.

00:01:58.910 --> 00:02:05.530 align:middle line:84%
And here's, of course, where we
would be more likely to do this

00:02:05.530 --> 00:02:07.910 align:middle line:90%
at, make a quarter rest.

00:02:07.910 --> 00:02:10.449 align:middle line:84%
That's the default,
but just to show it.

00:02:10.449 --> 00:02:16.370 align:middle line:84%
And so we can, by the way, put
objects in more than one stream.

00:02:16.370 --> 00:02:21.730 align:middle line:84%
And so this is something that's
going to happen sometimes.

00:02:21.730 --> 00:02:26.680 align:middle line:84%
We'll put the first note in,
and now we'll create m3 is

00:02:26.680 --> 00:02:30.640 align:middle line:84%
a stream.measure
and m3.append(n2).

00:02:30.640 --> 00:02:36.160 align:middle line:90%


00:02:36.160 --> 00:02:42.760 align:middle line:84%
Oh, you know I really do care
about having all our measures

00:02:42.760 --> 00:02:47.170 align:middle line:90%
appear, and p is a stream.part.

00:02:47.170 --> 00:02:55.690 align:middle line:84%
We'll go ahead and put inside
the stream m2 and append(m3).

00:02:55.690 --> 00:02:59.460 align:middle line:84%
And let's go ahead
and show that.

00:02:59.460 --> 00:03:02.470 align:middle line:84%
Great, so this shows
how ties might work.

00:03:02.470 --> 00:03:03.430 align:middle line:90%
Now, here's the thing.

00:03:03.430 --> 00:03:10.230 align:middle line:84%
If we do for n in,
well, p.recurse.notes,

00:03:10.230 --> 00:03:16.020 align:middle line:84%
and we try to figure out
how many notes there are.

00:03:16.020 --> 00:03:17.980 align:middle line:84%
Well, it looks like
there's three of them.

00:03:17.980 --> 00:03:20.610 align:middle line:84%
But if we listen to this
piece, obviously we're

00:03:20.610 --> 00:03:22.300 align:middle line:90%
just going to hear two notes.

00:03:22.300 --> 00:03:23.710 align:middle line:90%
So what can we do?

00:03:23.710 --> 00:03:26.170 align:middle line:90%
Well, we can create a new part.

00:03:26.170 --> 00:03:29.550 align:middle line:84%
We'll say p2 equals
part.stripTies.

00:03:29.550 --> 00:03:32.640 align:middle line:90%


00:03:32.640 --> 00:03:35.860 align:middle line:90%
And now if we do for n--

00:03:35.860 --> 00:03:38.010 align:middle line:84%
well, actually, let's
show this, and we'll

00:03:38.010 --> 00:03:39.660 align:middle line:90%
show it as a text file.

00:03:39.660 --> 00:03:45.520 align:middle line:84%
We'll see here that we
only have two notes now.

00:03:45.520 --> 00:03:49.500 align:middle line:84%
But in this next
measure, this note,

00:03:49.500 --> 00:03:53.640 align:middle line:84%
the C only begins
one quarter note in.

00:03:53.640 --> 00:03:56.280 align:middle line:84%
So we've reduced--
what we've done

00:03:56.280 --> 00:04:00.300 align:middle line:84%
is we've taken these
two E's that are tied,

00:04:00.300 --> 00:04:03.850 align:middle line:84%
and we've replaced them
with one half note.

00:04:03.850 --> 00:04:07.920 align:middle line:90%
In fact, we can look at this.

00:04:07.920 --> 00:04:13.060 align:middle line:90%
That's our note and duration.

00:04:13.060 --> 00:04:14.360 align:middle line:90%
It's a half note.

00:04:14.360 --> 00:04:17.279 align:middle line:90%


00:04:17.279 --> 00:04:22.470 align:middle line:84%
When we strip ties, we
create things sometimes

00:04:22.470 --> 00:04:25.600 align:middle line:84%
that don't really
musically exist.

00:04:25.600 --> 00:04:29.790 align:middle line:84%
We have a measure that has
a time signature of 2/4,

00:04:29.790 --> 00:04:32.370 align:middle line:84%
has a quarter rest, and then
it has a half note in it.

00:04:32.370 --> 00:04:34.150 align:middle line:90%
That really can't work.

00:04:34.150 --> 00:04:39.120 align:middle line:84%
So you can't really
do p2.show and expect

00:04:39.120 --> 00:04:42.700 align:middle line:84%
something that looks right
because that just wouldn't work.

00:04:42.700 --> 00:04:49.330 align:middle line:84%
But instead, in terms of
iterating for n in p2.recurse,

00:04:49.330 --> 00:04:53.970 align:middle line:84%
we'll say,
.notesAndRests, [MUMBLES].

00:04:53.970 --> 00:05:01.320 align:middle line:84%
Let's print n's offset,
and we can see that.

00:05:01.320 --> 00:05:04.580 align:middle line:84%
And we can even do
measure Number ha.

00:05:04.580 --> 00:05:07.380 align:middle line:84%
This would totally have saved
you time on problem set 3,

00:05:07.380 --> 00:05:08.690 align:middle line:90%
wouldn't it have?

00:05:08.690 --> 00:05:14.678 align:middle line:84%
Oops, we'll go back and
call these number equals 1,

00:05:14.678 --> 00:05:15.803 align:middle line:90%
measures are auto numbered.

00:05:15.803 --> 00:05:19.280 align:middle line:90%


00:05:19.280 --> 00:05:23.120 align:middle line:84%
And now when we go
back here, we can

00:05:23.120 --> 00:05:26.630 align:middle line:90%
see the rest is in measure one.

00:05:26.630 --> 00:05:30.060 align:middle line:84%
Then note E is in
measure one at offset 1.

00:05:30.060 --> 00:05:33.160 align:middle line:90%
In fact, let's print it's--

00:05:33.160 --> 00:05:38.990 align:middle line:90%


00:05:38.990 --> 00:05:42.230 align:middle line:84%
we should see that E is
in measure 1 at offset 1

00:05:42.230 --> 00:05:46.370 align:middle line:84%
is half note, and the C is
in measure 2 at offset 1

00:05:46.370 --> 00:05:49.040 align:middle line:90%
is a quarter note.

00:05:49.040 --> 00:05:51.950 align:middle line:84%
I'd make this longer,
but that's basically

00:05:51.950 --> 00:05:53.490 align:middle line:90%
all there is to do with ties.

00:05:53.490 --> 00:05:55.780 align:middle line:90%
Thanks for listening.

00:05:55.780 --> 00:05:58.000 align:middle line:90%