/
07-06-ACA-Tonal-Chord.tex
432 lines (394 loc) · 18 KB
/
07-06-ACA-Tonal-Chord.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
% move all configuration stuff into includes file so we can focus on the content
\input{include}
\subtitle{module 7.6: chord detection}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
% generate title page
\input{include/titlepage}
\section[overview]{lecture overview}
\begin{frame}{introduction}{overview}
\begin{block}{corresponding textbook section}
%\href{http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=6331122}{Chapter 5~---~Tonal Analysis}: pp.~125--127
section~7.6
\end{block}
\begin{itemize}
\item \textbf{lecture content}
\begin{itemize}
\item musical chords and harmony
\item baseline chord detection
\item Hidden Markov Models (HMMs) and the Viterbi algorithm
\end{itemize}
\bigskip
\item<2-> \textbf{learning objectives}
\begin{itemize}
\item name basic chords and describe the concept of chord inversions
\item discuss commonalities and differences between chord \& key detection
\item discuss the usefulness of HMMs for chord detection
\item explain the Viterbi algorithm with an example
\end{itemize}
\end{itemize}
\inserticon{directions}
\end{frame}
\section{chords}
\begin{frame}{musical pitch}{chords}
\begin{itemize}
\item simultaneous use of several pitches $\Rightarrow$ \textbf{chords}
\item usually constructed of (major/minor) thirds
\begin{figure}[t]
\centering
\includegraphics[scale=.85]{graph/pitch_chords}
\end{figure}
\smallskip
\item<2-> note:
\begin{itemize}
\item chord type independent of pitch doubling, pitch order
\item same label for keys and chords
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}{musical pitch}{ chord inversion}
\begin{itemize}
\item most common: root note is lowest note
\item otherwise: chord inversion
\begin{figure}[t]
\centering
\includegraphics{graph/pitch_chordinversions}
\end{figure}
\end{itemize}
\end{frame}
\begin{frame}{musical pitch}{ harmony}
\begin{itemize}
\item key and tonal context define chord's \textit{harmonic function}
\smallskip
\item examples:
\begin{itemize}
\smallskip
\item \textbf{tonic}:\\ chord on 1st scale degree (tonal center)
\smallskip
\item \textbf{dominant}:\\ chord on 5th scale degree (often moves to tonic)
\smallskip
\item \textbf{subdominant}:\\ chord on 4th scale degree
\smallskip
\item \ldots
\end{itemize}
\end{itemize}
\end{frame}
\section{chord detection}
\begin{frame}{chord detection}{introduction: key vs.\ chord detection}
\begin{itemize}
\item \textbf{commonalities}
\begin{itemize}
\item<1-> chords are octave independent $\Rightarrow$ pitch chroma sufficient
\item<1-> process flow: pitch chroma extraction $+$ classification
\end{itemize}
\bigskip
\item<2-> \textbf{differences}
\begin{itemize}
\item time frame for pitch chroma calculation
\item templates
\item number of templates/chords
\item many results per song (time series)
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}{chord detection}{introduction: overview}
\begin{footnotesize}
\begin{picture}(112,48)
\setcounter{iXOffset}{0}
\setcounter{iYOffset}{32}
\setcounter{iXBlockSize}{32}
\setcounter{iXBlockSizeDiv2}{16}
\setcounter{iYBlockSize}{16}
\setcounter{iYBlockSizeDiv2}{8}
\setcounter{iDistance}{8}
\put(\value{iXOffset}, \value{iYOffset})
{\framebox(\value{iXBlockSize}, \value{iYBlockSize}) {{\shortstack[c]{Pitch Representation\\ Extraction}}}}
\addtocounter{iYOffset}{\value{iYBlockSizeDiv2}}
\addtocounter{iXOffset}{\value{iXBlockSize}}
\put(\value{iXOffset}, \value{iYOffset})
{\vector(1,0){\value{iDistance}}}
\addtocounter{iYOffset}{-\value{iYBlockSizeDiv2}}
\addtocounter{iXOffset}{\value{iDistance}}
\put(\value{iXOffset}, \value{iYOffset})
{\framebox(\value{iXBlockSize}, \value{iYBlockSize}) {{\shortstack[c]{Similarity\\ Computation}}}}
\addtocounter{iYOffset}{\value{iYBlockSizeDiv2}}
\addtocounter{iXOffset}{\value{iXBlockSize}}
\addtocounter{iXOffset}{\value{iDistance}}
\put(\value{iXOffset}, \value{iYOffset})
{\vector(-1,0){\value{iDistance}}}
\addtocounter{iYOffset}{-\value{iYBlockSizeDiv2}}
\put(\value{iXOffset}, \value{iYOffset})
{\framebox(\value{iXBlockSize}, \value{iYBlockSize}) {{\shortstack[c]{Chord Template\\ Definition}}}}
\addtocounter{iXOffset}{-\value{iXBlockSizeDiv2}}
\addtocounter{iXOffset}{-\value{iDistance}}
\put(\value{iXOffset}, \value{iYOffset})
{\vector(0,-1){\value{iDistance}}}
\addtocounter{iYOffset}{-\value{iDistance}}
\addtocounter{iYOffset}{-\value{iYBlockSize}}
\addtocounter{iXOffset}{-\value{iXBlockSizeDiv2}}
\put(\value{iXOffset}, \value{iYOffset})
{\framebox(\value{iXBlockSize}, \value{iYBlockSize}) {{\shortstack[c]{Time Sequence\\ Modeling}}}}
\addtocounter{iXOffset}{\value{iXBlockSizeDiv2}}
\put(\value{iXOffset}, \value{iYOffset})
{\vector(0,-1){\value{iDistance}}}
\addtocounter{iXOffset}{2}
\addtocounter{iYOffset}{-\value{iDistance}}
\addtocounter{iYOffset}{2}
\put(\value{iXOffset}, \value{iYOffset})
{\text{{\shortstack[c]{Chord Sequence}}}}
\addtocounter{iYOffset}{\value{iDistance}}
\addtocounter{iYOffset}{\value{iYBlockSize}}
\put(\value{iXOffset}, \value{iYOffset})
{\text{{\shortstack[c]{Chord Probabilities}}}}
\end{picture}
\end{footnotesize}
\end{frame}
\begin{frame}{pitch chroma}{introduction}
%\vspace{-3mm}
\begin{itemize}
\item pitch class distribution: 12-dimensional vector
\item map all pitch class bands in all octaves to one
\end{itemize}
{\visible<2>{\begin{flushright}{\includeaudio{sax_example}}\end{flushright}}}
\only<1>{\vspace{1mm}\figwithmatlab{PitchChromaGrouping}}
\only<2>{\vspace{4mm}\figwithmatlab{PitchChroma}}
\only<3->{
\bigskip
\bigskip
\begin{block}{pitch chroma properties}
\begin{itemize}
\item \textbf{no} octave information
\begin{itemize}
\item no differentiation between prime and octave
\item no info on inversion
\end{itemize}
\item robust, timbre-independent representation
\end{itemize}
\end{block}
}
\vspace{50mm}
%\inserticon{audio}
\end{frame}
\begin{frame}{chord detection}{chord template}
\vspace{-4mm}
\begin{columns}
\column{.4\linewidth}
\begin{itemize}
\item compare extracted pitch chroma with template
\begin{itemize}
\item simplest possible template and distance: linear transformation
example~---~C major: \[\Gamma(0,j) = [\nicefrac{1}{3},0,0,0,\nicefrac{1}{3},0,0,\nicefrac{1}{3},0,0,0,0]\]
\smallskip
\item[$\Rightarrow$] instantaneous chord likelihood:
\begin{equation*}
{\psi}(c,n) = \sum\limits_{j = 0}^{11}{\Gamma(c,j)\cdot \nu(j,n)}
\end{equation*}
\end{itemize}
\end{itemize}
\column{.6\linewidth}
\figwithmatlab{ChordTemplates}
\end{columns}
\end{frame}
\begin{frame}{chord detection}{chord progression 1/2}
apply \textbf{musical knowledge} to increase the result's robustness and accuracy:
\begin{itemize}
\item probabilities for different chord progressions (similar to key modulations), e.g.
\begin{itemize}
\item cadences: I-IV-V-I
\item sequences: circle progression
\end{itemize}
\end{itemize}
$\Rightarrow$ model for \textit{chord progression probabilities}
\begin{enumerate}
\smallskip
\item<2-> \textit{analytical model} based on music theory
\begin{itemize}
\item circle of fifths (?!)
\item key profile correlation (?!)
\end{itemize}
\smallskip
\item<3-> \textit{empirical model} based on data
\begin{itemize}
\item annotate audio
\item symbolic score
\end{itemize}
\end{enumerate}
\end{frame}
\begin{frame}{chord detection}{chord progression 2/2}
\question{what properties do chord progression probabilities depend on}
\begin{itemize}
\item musical key
\item larger musical context (model order)
\item style
\item tempo/length??
\end{itemize}
\end{frame}
\section[HMMs]{Hidden Markov Models \& Viterbi algorithm}
\begin{frame}{chord detection}{markov chain}
\begin{figure}
\centering
\includegraphics[scale=.1]{graph/MarkovChain}
\end{figure}
\addreference{from: \url{https://commons.wikimedia.org/wiki/File:Markovkate_01.svg}}
\begin{itemize}
\item two possible states E, A
\item transition probabilities to other state(s) and to self
\item sum of transition probabilities equals 1
\end{itemize}
\end{frame}
\begin{frame}{chord detection}{hidden markov model: variables}
\begin{itemize}
\item \textbf{states}:\\ unknown/hidden
\smallskip
\item \textbf{transition probability}:\\ probability of transitioning from one state to the other
\smallskip
\item \textbf{observations}:\\ measureable time series
\smallskip
\item \textbf{emission probability}:\\ probability of an observation given a state
\smallskip
\item \textbf{start probability}:\\ probability of the initial state
\end{itemize}
\end{frame}
\begin{frame}{chord detection}{hidden markov model: variables}
\vspace{-5mm}
\begin{figure}
\centering
\includegraphics[scale=.25]{graph/HiddenMarkovModel}
\end{figure}
\addreference{from \url{https://en.wikipedia.org/wiki/File:HiddenMarkovModel.svg}}
\vspace{-5mm}
\begin{footnotesize}
\begin{itemize}
\item X: states
\item y: possible observations
\item a: state transition probabilities
\item b: emission probabilities
\end{itemize}
\end{footnotesize}
\end{frame}
\begin{frame}{chord detection}{hidden markov model: example (WP) 1/2}
\begin{itemize}
\item \textbf{scenario}
\begin{itemize}
\item doctor diagnoses fever by how patients feel
\item patient may feel normal, dizzy, or cold
\item patient visits multiple days in a row
\end{itemize}
\end{itemize}
\question{what are the states and observations in this case}
\begin{itemize}
\item \textbf{states} %: \textit{healthy}, \textit{fever}
\begin{itemize}
\item \textit{healthy}
\item \textit{fever}
\end{itemize}
\item \textbf{observations}: %\textit{normal}, \textit{cold}, \textit{dizzy}
\begin{itemize}
\item \textit{normal}
\item \textit{cold}
\item \textit{dizzy}
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}{chord detection}{hidden markov model: example (WP) 2/2}
%\begin{columns}[T]
%\column{.6\textwidth}
\vspace{-3mm}
\only<1>{
\begin{itemize}
\item \textbf{start probabilities} (initial state assumption)
\begin{itemize}
\item \textit{healthy}: $ 0.6$
\item \textit{fever}: $0.4$
\end{itemize}
\bigskip
\item<1-> \textbf{emission probabilities} (prob of obs given state)
\begin{itemize}
\item \textit{healthy}: normal $0.5$, cold $0.4$, dizzy $0.1$
\item \textit{fever}: : normal $0.1$, cold $0.3$, dizzy $0.6$
\end{itemize}
\bigskip
\item<1-> \textbf{transition probabilities}
\begin{itemize}
\item \textit{healthy}: healthy $0.7$, fever $0.3$
\item \textit{fever}: : healthy $0.4$, fever $0.6$
\end{itemize}
\end{itemize}
}
\only<2>{
\begin{figure}
\includegraphics[scale=.6]{graph/viterbi_example}
\end{figure}
}
%\column{.4\textwidth}
%\only<4->{
%\includegraphics[scale=.35]{HmmExample}
%}
%\end{columns}
%\addreference{from: \url{https://en.wikipedia.org/wiki/File:An_example_of_HMM.png}}
\end{frame}
\begin{frame}{chord detection}{hidden markov model: example (WP) 2/2}
\begin{itemize}
\item[] \textbf{three observations}:\\ day 1 \textit{normal} $\rightarrow$ day 2 \textit{cold} $\rightarrow$ day 3 \textit{dizzy}
\end{itemize}
\setcounter{i}{0}
\whiledo{\value{i}<4}
{
\only<\value{beamerpauses}>
{
\begin{figure}
\centering
\includegraphics[scale=.5]{graph/viterbi_example_\arabic{i}}
\end{figure}
}
\ifthenelse{\equal{\value{i}}{3}}{}{\pause}
\stepcounter{i}
}
%\visible<1->{\addreference{from: \url{https://en.wikipedia.org/wiki/Viterbi_algorithm\#/media/File:Viterbi_animated_demo.gif}}}
\end{frame}
\begin{frame}{chord detection}{HMMs for chord detection}
\begin{itemize}
\item states $\rightarrow$ chords
\item observations $\rightarrow$ pitch chroma
\item emission probability $\rightarrow$ trained with pitch chroma
\item transition probability $\rightarrow$ trained from dataset
\item start probability $\rightarrow$ chord statistics (style dependent?)
\end{itemize}
\end{frame}
\begin{frame}{chord detection}{chord detection example}
{\flushright \includeaudio{chord_detection_example}}
\figwithmatlab{ChordDetection}
\end{frame}
\section{summary}
\begin{frame}{summary}{lecture content}
\begin{itemize}
\item \textbf{chords}
\begin{itemize}
\item combination of three or more pitches
\item usually stacked thirds
\item can be inverted
\end{itemize}
\smallskip
\item \textbf{chord detection}
\begin{itemize}
\item processing steps
\begin{itemize}
\item pitch chroma extraction
\item template matching
\item chord transition model
\end{itemize}
\end{itemize}
\smallskip
\item \textbf{Viterbi algorithm}
\begin{itemize}
\item find globally optimal path through state space
\item estimate state sequence with
\begin{itemize}
\item emission probabilities
\item transition probabilities
\end{itemize}
\end{itemize}
\end{itemize}
\inserticon{summary}
\end{frame}
\end{document}