How to use the commandline tool melfeature


The principal purpose of melfeature is to extract features, i.e., numerical or textual characteristics of melodies. Features can come in several formats, they can be inherent to the melody itself or based on external annotations. Very simple examples are the number of tones of a melody, which is numerical, internal feature, and the style of the solo, which is an external, annotated feature.

The use of feature extraction

Why would one want to extract features from melodies? The possible applications are manifold. First of all, objects are generally described using features, e.g., characteristics and properties of this objects. This happens already on a very general level in every day life, but is particular useful and necessary in science, where it is done more systematically and rigorously. Scientist wants to descern natural laws or at least theories or models of how things work. And for this things have to be described in a systematic and measurable way. Think of Newton’s laws where things are described basically by only one single feature: mass, which is an intrinsic property of every physical object. Another important “features” of object are their position in time and space as well as its velocity. This information can be regareded as external features. Often, external features are functions of internal features such as the position in time and space of a object is governed by the law of mechanics (or quantum mechanics or relativity theory for that matter.) Similar holds for melodies and other musical objects. If one wants to examine, for example, the question, why and how can music make people sad, the answer to this question must necessarily involve some description of music (e.g., its slow tempo or minor tonality) and some characteristics of people (or their minds). The first point in science is to identify the “right” or “best” descriptors for objects, i.e., features, in which terms models can be expressed. The set of optimal features are not a priori clear for music, and might even not exist in full generality; they have to be found empirically. The idea of a software like melfeature is to provide the scientist with a very general tool for melodic feature extraction, because the optimal feature set is neither known nor eternally determined, and might be different depending on the research question at hand. Unfortunately, there are no such unique and defining features such as “mass” or “electrical charge” for musical objects, though some descriptor be more fundamental or more important than others.

|MF| overview

melfeature allows a very general scheme for extracting a principally unlimited numbers of features. This is achieved by using special files, the Feature Definitions Files (FDF), which can be written by users to meet their particular needs. The MeloSpySuite comes already with a handy pre-defined set of 93 FDFs which contain over 500 features. Features are defined by process chains, which all start with some certain transformation (or abstraction) derived from the melody (and its annotations). The so-called “feature machine” provides a large set of processing modules that can be used to build features.

Moreover, melfeature offers the possibility of segmenting the melodies first, e.g., into melodic phrases, single bars or in chunks of fixed size. melfeature will then compute features for each segment of a melody separately.

Finally, all results are stored in a single CSV file, which is ready to be used in spread sheet software and more specialised statistical tools such as R, SPSS or MATLAB.


This tutorial on using melfeature will do so by running through sample configuration files as used in the demo batches that come along with the MeloSpySuite. We recommend trying the demos first. Usage and meaning of all commandline options to melfeature are not explained here, since they have all a corresponding part in the configuration files. For a complete reference see here.

Next Part: Demo batches.