# Info

This tool has many operations, all of them defined in the contour literature (see the bibliography section). ContourMetrics has several features:
1. Calculator with multiple operations and functions
1. Normalization
2. Morris/Schultz/Sampaio reduction
3. Window reduction
4. Direction index
5. Oscillation index
6. Prime contour
7. Equivalent class
10. Inversion
11. Contour Plot
12. Output operations area
13. 9 contour memories
14. Similarity by multiple algorithms
2. Similarity algorithms benchmarking
1. Comparison between given contour and real contour from collections, with filters
2. Comparison among real contours from collections. For instance, all Bach Chorales bass phrases in C minor
3. Multiple statistics studies: central tendency and dispersion
4. Similarity value correlation between all algorithms
5. Similarity value distribution charts
6. Musical features filters: key, mode, time signature, voice
There are available contours from different song collections.

### Bach Chorales

Contour from the all voice phrases of 366 chorales, Riemenschneider edition.

### 500 canções brasileiras

Contour from Brazilian songs collection (incomplete).

### Folguedos e danças de Alagoas

Contour from Brazilian songs collection (incomplete).

### Bailes pastoris

Contour from Brazilian songs collection (incomplete). Contours can be represented in linear or combinatorial approach.

### Linear representation

The linear representation is a sequence of symbols (+ and -) representing the movement between adjacent points. For instance, the contour in the figure below is linearly represented as < - + + - - - >.

### Combinatorial representation

The combinatorial representation is a sequence of integer numbers representing the relations among all the contour points. For instance, the contour of the figure below is combinatorial represented as < 2 0 3 4 2 1 0 >.

### Profile

#### Normalization

The normalization operation consists in the contour renumeration with integer numbers from 0 to n-1 where n is the number of unique elements.

For instance, the normalization of the contour A < 3 2 5 9 > is < 1 0 2 3 > and of the contour B < 3 4 3 6 10 3 > is < 0 1 0 2 3 0 >.

#### Equivalent class

Contours that has the same relations between theirs points belongs to the same class such as their reflections (inversion, retrogradation and inverted-retrogradation). Each class has representative, given by Equivalence Contour Class Prime Form (Sampaio and Kroger 2016).

For instance, both contours A < 0 2 1 3 4 >, R(A) < 4 3 1 2 0 >, I(A) < 4 2 3 1 0 > and RI(A) < 0 1 3 2 4 > belongs to the same class, represented by < 0 1 3 2 4 >.

#### Reflection

Reflection is a geometry concept. In musical contour there are two reflection operations: inversion and retrogradation.
##### Inversion

The inversion I(P) of a contour P is given by the equation IP_n=(q-1-P_n), where q is the number of distinct contour points and n is the contour point position.

For instance, the contour A < 3 4 1 0 2 > inversion is I(A) < 1 0 3 4 2 >.

The contour retrogradation is the contour written backwards.

For instance, the contour A < 3 4 1 0 2 > retrogradation is R(A) < 2 0 1 4 3 >.

#### Similarity

The similarity is measured by different algorithms.
##### Oscillation Spectrum Correlation

The oscillation similarity is given by the correlation between the contours oscillation spectrum. The inverted Fourier Transform function is applied on the contour, that is considered as a wave sample. (Schmuckler 2010).

The AED similarity is based on the string edit distance between contour linear representations. The algorithm used is the Levenshtein's and the distance is divided by the contour size.

The AGP similarity is based on a Gestalt approach to string pattern matching. The linear representation of the contour is used as a string and compared with the Ratcliffand and Metzener algorithm.

#### Reduction

##### Morris/Schultz/Sampaio algorithm

The reduction to prime eliminates the contour secondary points and preserves the salient ones until reach the most simplified possible contour, the Prime one. This operation is based on the Morris/Schultz/Sampaio algorithm (Sampaio and Kroger 2016).

For instance, the prime of the contour A < 0 4 3 4 2 1 > is the contour < 0 4 1 >.

##### Window algorithm

The window reduction remove eliminates the contour secondary points and preserves the salient ones based on a 3 or 5 points window. The window slides right and each contour point is compared with its window neighbors. It is removed if is not the window highest or lowest cpoint.

The window-3 removes intermediary contour points in the same direction, such as {1,2} in the contour < 0 1 2 3 >. The window-5 removes zigzag contour points such as {1,2,3,4} in the contour < 0 2 1 4 3 5 >.

For instance, the window-3 reduction of the contour A < 0 1 2 3 2 3 4 5 3 4 5 6 > is the contour < 0 3 2 5 3 6 > and the window-5 reduction of the contour B < 0 2 1 4 3 6 5 7 6 1 > is the contour < 0 7 1 >.

### Features

#### Direction index

The direction index reveals ascent/descent movement trend of a contour. The operation returns a real number between 0 and 1 where 0 indicates the most descent contour and 1 the most ascent one.

For instance, the direction index of the contour A < 2 1 0 > is 0, of the contour B < 0 1 2 3 4 > is 1, and of the contour < 0 2 1 3 5 4 > is 0.867.

#### Oscillation index

The oscillation index refers to direction movement reversals. The operation returns a real number between 0 and 1 where 0 indicates that the contour doesn't have any direction reversal and 1, that the contour has the maximum number of reversals.

For instance, the oscillation index of the contour A < 0 1 2 3 > is 0, of the contour B < 0 1 2 4 3 > is 1, and of the contour < 0 2 1 3 5 4 6 > is 0.8.

### Central tendency

#### Mean

The average value of a data set. For instance, the average of data set S=\{3,4,5,4,6,50\} is \mu=12.

#### Median

The value that divides the data set in two sets. For instance, the average of data set S=\{3,4,5,4,6,50\} is m=4.5.

### Dispersion

#### Standard deviation

A measure that is used to quantify the amount of variation of a data set. It is like a variation mean. For instance, the standard deviation of the data set S=\{3,4,5,4,6,50\} is \sigma=18.64.

#### Frequency Distribution

A map that displays the frequency (or count) of occurrences of particular groups or intervals of a data set. For instance, the dataset S=\{0,4,1,1,2,2,3,5,4,4,5,2,6,3,7,5,8,7,9,2,1,0,7,1,1,8,1,2,8,1,3,5,1,4,4\} frequency distribution is given in the table below.

The frequency distribution is commonly represented graphically in a histogram chart, such below. The higher bars represents the value range with more occurrences.

#### Skew

Asymmetry measure. Reveals if a distribution is symmetric or is angled for the left or right or a normal distribution. A positive skew value represents concentration in the left side and the negative one, the concentration in the right side. For instance, the dataset S=\{0,4,1,1,2,2,3,5,4,4,5,2,6,3,7,5,8,7,9,2,1,0,7,1,1,8,1,2,8,1,3,5,1,4,4\} skew is 0.498. This distribution has a concentration in the left side (see the chart below).

#### Kurtosis

Flatness measure of the distribution. Reveals how flat a distribution is. A value equals to zero represents the same flatness of the normal distribution, a positive value represents a higher concentration in a small region, and a negative value represents a flattened distribution. For instance, the dataset S=\{0,4,1,1,2,2,3,5,4,4,5,2,6,3,7,5,8,7,9,2,1,0,7,1,1,8,1,2,8,1,3,5,1,4,4\} kurtosis is -0.89. This distribution is slightly flattened (see the chart below).

\

#### Coefficient of variation

The ratio between standard deviation to the mean. It is a standardized measure of dispersion of a frequency distribution. Its value is a real between 0 and 1 and is given by CV=\frac{\sigma}{\mu}.

For instance, the let the datasets S_1=\{0,4,1,1,2,2,3,5,4,4,5,2,6,3,7,5,8,7,9,2,1,0,7,1,1,8,1,2,8,1,3,5,1,4,4\} and S_2=\{1,2,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9\}. The dataset S_1 has a higher level of variability than the S_2. Its revealed by their coefficient of variation: CV(S_1)=0.71 and CV(S_2)=0.10.

#### Entropy

Shannon entropy, or Shannon index. It is a measure of the diversity of dataset.

For instance, the let the datasets S_1=\{0,4,1,1,2,2,3,5,4,4,5,2,6,3,7,5,8,7,9,2,1,0,7,1,1,8,1,2,8,1,3,5,1,4,4\} and S_2=\{1,2,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9\}. The dataset S_1 is more diverse than the S_2. Its revealed by their entropy: H(S_1)=3.52 and H(S_2)=0.63.

### Correlation

Any of a broad class of statistical relationships involving dependence (not necessarily causal). It is calculated with Pearson product-moment correlation coefficient. If this coefficient is near zero, the correlation is weak or inexistent, but if near 1 or -1, its strong.

Correlation can be graphically represented with a scatter plot.

For instance, the tables and charts belows represents two bi-dimensional datasets. Each element in the tables has two properties, V1 and V2. The correlation of these values is stronger in the second dataset than the first. Their correlation coefficients are -0.17 and 0.74, respectively.

1. Bor, Mustafa. 2009. “Contour Reduction Algorithms: A Theory of Pitch and Duration Hierarchies for Post-Tonal Music.” Phd Thesis. University of British Columbia.
2. Friedmann, Michael L. 1985. “A Methodology for the Discussion of Contour: Its Application to Schoenberg’s Music.” Journal of Music Theory 29 (2): 223–48.
3. Marvin, Elizabeth West. 1988. “A Generalized Theory of Musical Contour: Its Application to Melodic and Rhythmic Analysis of Non-Tonal Music and Its Perceptual and Pedagogical Implications.” PhD Thesis. University of Rochester.
4. Moraes, Tharcisio, and Marcos Sampaio. 2015. “Relações de Contornos Entre Elementos Sonoros E Visuais Do Jogo Super Mario Bros.” In Proceedings of SBGame 2015, 714–17. Teresina, PI.
5. Morris, Robert Daniel. 1987. Composition with Pitch-Classes: A Theory of Compositional Design. Yale University Press.
6. Morris, Robert Daniel. 1993. “New Directions in the Theory and Analysis of Musical Contour.” Music Theory Spectrum 15 (2): 205–28.
7. Sampaio, Marcos da Silva, and Alex Pochat. 2016. “Aplicação de Contornos Na Composição Musical.” In Perspectivas de Interpretação, Teoria E Composição Musical, edited by Heinz Karl Novaes Schwebel and José Maurício Valle Brandão, 13–28. Salvador, BA: EDUFBA.
8. Sampaio, Marcos da Silva, and Pedro Kroger. 2016. “Contour Algorithms Review.” MusMat - Brazilian Journal of Music and Mathematics 1 (1): 72–85.
9. Sampaio, Marcos da Silva. 2012. “A Teoria de Relações de Contornos Musicais: Inconsistências, Soluções E Ferramentas.” Tese de Doutorado. Universidade Federal da Bahia.
10. Sampaio, Marcos da Silva. 2008. “Em Torno Da Romã: Aplicações de Operações Com Contornos Na Composição.” Dissertação de Mestrado. Universidade Federal da Bahia.
11. Sampaio, Marcos da Silva, Pedro Kroger, Mara Pinheiro Menezes, Jean Menezes da Rocha, Natanael Ourives, and Dennis Queiroz de Carvalho. 2013. “The Implementation of a Contour Module for Music21.” ART Music Review 24.
12. Schmuckler, Mark A. 1999. “Testing Models of Melodic Contour Similarity.” Music Perception 16 (3): 295–326.
13. Schmuckler, Mark A. 2010. “Melodic Contour Similarity Using Folk Melodies.” Music Perception 28 (2): 169–194.
14. Triola, Mario F. 2013. Elementary Statistics. 10th ed. Boston: Pearson Addison Wesley.
15. Schultz, Rob D. 2016. “Normalizing Musical Contour Theory.” Journal of Music Theory 60 (1): 23–50.
16. Schultz, Rob D. 2009. “A Diachronic-Transformational Theory of Musical Contour Relations.” PhD Thesis University of Washington.