Inner Metric Analysis code
 All Classes Namespaces Functions Variables Typedefs Pages
Overview

Introduction

The Inner Metric Analysis (IMA) library implements a method devised by Anja Volk for generating metric weight profiles for pieces of music. The input for the algorithms is a list of onsets, that is, points in time on which a note starts. The output is the metric weights associated with points in time.

Definitions

A local meter is a set of onsets with the following properties:

A local meter can be characterised by a start time s, a period p and a number of repeats r. That describes the set of onsets
s+i*p, for 0<=i<=r

Based on the local meter, there are two weighting methods defined by Anja Volk: metric weight and spectral weight. We have added two new ones: dieout weight and symmetric dieout weight.

The weight w that a local meter contributes is w=r^n, where r is the number of repeats and n is a parameter (by default 2). For metric weight, w is only added at the onsets that are part of the local meter. For spectral weight, w is added for every time s+i*p for all i (positive and negative), such that the time is between the first and last onset.

Dieout weight has an extra paramer d , the dieout factor. For symmetric dieout weight a local meter contributes weight on positions s+i*p:

i-range Weight
-d*p<i<0 (i+d*p)*w/(d*p)
0<=i<=k w
k<i<k+d*p (d*p+k-i)*w/(d*p)

For normal dieout weight we leave out the first row of the table above. That is, a local meter has no influence before it started, only afterwards.

Metric weight is the same as (symmetric) dieout weight with d =0. Spectral weight is the same as symmetric dieout with d =infinity.

Getting Started

Here we give an example of a basic use of the library.

#include "InnerMetricAnalysis.hpp"
#include <iostream>
namespace im = InnerMetricAnalysis;
int main()
{
int onsets[]={0,4,8,16,20,24,32};
im::Computer ima_comp(onsets, onsets+7);
std::vector<im::TimeWeight> tws=ima_comp.getMetricWeights2();
for (auto const &tw: tws) {
std::cout<<tw.time<<"\t"<<tw.weight<<"\n";
}
}

This program initializes an inner metric analysis computer with a range of 7 onsets. It then asks for the metric weights belonging to those onsets. It prints the results, which would generate the following output:

0   20
4   4
8   24
16  20
20  8
24  20
32  20

The code uses the for loop construct introduced in 2011 standard. Note that the onsets are strictly increasing. If that were not the case, the program would end with an uncaught exception.