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.
map_to_1d
Section titled “map_to_1d”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:
and so on…
map_to_2d
Section titled “map_to_2d”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);}