Skip to content

Map

This page details functions that apply linear maps to generic 2d vectors. Many of Meantonal’s built-in functions that operate on Pitch and Interval vectors are essentially performing these maps under the hood, but these generalised mapping operations are available in case something you need isn’t a built-in.

int map_to_1d(MapVec v, Map1d T);

This function allows an arbitrary Map1d matrix to multiply a MapVec, sending it to some integer. Allows things like:

map_to_1d((MapVec)p, ED31);

This would send any Pitch to a 31-tone equal temperament equivalent of MIDI numbering, such that:

0C10\rightarrow\sf{C}_{-1}

1D11\rightarrow\sf{D}\flat\flat_{-1}

2C12\rightarrow\sf{C}\sharp_{-1}

3D13\rightarrow\sf{D}\flat_{-1}

4C14\rightarrow\sf{C}\sharp\sharp_{-1}

5D15\rightarrow\sf{D}_{-1}

6E16\rightarrow\sf{E}\flat\flat_{-1}

and so on…

MappedVec map_to_2d(MapVec v, Map2d T);

This function allows an arbitrary Map2d matrix to multiply a MapVec. If it’s an invertible matrix, this essentially facilitates a change of basis. The returned vector is another MapVec.

This could be useful if working with generalised isomorphic keyboard layouts. For example, if reading numbers off a grid intended to represent a Wicki-Hayden layout, they could be parsed into Meantonal Pitch vectors simply:

typedef struct {
int x, y;
} WickiKey;
Pitch pitch_from_key(WickiKey k) {
return (Pitch) map_to_2d((MapVec) k, WICKI_FROM);
}