[frames] | no frames]

# Module tonalspace

source code

Tonal space manipulations and analysis.

Note that this module is only intended for formalism-independent tonal space manipulations. Functions should not rely on representations that are formalism-specific, like `TonalDenotation`. They may use things like coordinates, which could be produced from an formalism-specific semantics.

Author: Mark Granroth-Wilding <mark.granroth-wilding@ed.ac.uk>

 Functions
(x,y) coordinate
 nearest_neighbour(base_coord, root_number) Returns the coordinate of the point with the given root number that is closest to the given point base_coord. source code

 coordinates_to_roman_names(coords) Given a list of tonal space coordinates, return a list of strings giving the roman numeral names of the points. source code

 coordinate_to_roman_name(coord, sharp=`'``#``'`, flat=`'``b``'`, plus=`'``+``'`, minus=`'``-``'`, names=None, accidentals_after=False) Given a coordinate (x,y), returns the unique roman numeral name of that point in the space, assuming that I is at (0,0). source code

 coordinate_to_alpha_name_c(*args, **kwargs) Does the same as coordinate_to_roman_name, but generates alphabetic note names in the key of C (i.e. source code

 coordinate_key_region(coord) Given a tonal space coordinate, returns the 2D identifier of the key region that it lies in. source code

 coordinate_within_region(coord) Given a tonal space coordinate, returns the coordinate of this point relative to the bottom left corner of the local key region in which it lies (see coordinate_key_region). source code

 equate_ends(coords0, coords1) Translates the second list of coordinates so that it ends at the same point as the first and returns the result. source code

 coordinate_to_et(coord) Takes a point in the tonal space and returns the number of semitones above the origin's pitch that point would be in equal temperament. source code

 coordinate_to_et_2d(coord) 2-dimensional version of coordinate_to_et. source code

 cents_to_pitch_ratio(cents) Converts a number of cents (tuning theory unit of pitch ratio) into a floating point pitch multiplier. source code

 pitch_ratio_to_cents(ratio) Inverse of cents_to_pitch_ratio. source code

 tonal_space_pitch(coord) Given a 3D coordinate in the tonal space, returns the pitch ratio of that point from the origin's pitch. source code

 tonal_space_pitch_2d(coord) Given a 2D coordinate in the tonal space, returns the pitch ratio of that point from the origin's pitch assuming that the point is within one octave above the origin. source code

 tonal_space_et_pitch(coord) Given a (2D) point in the tonal space, returns the pitch ratio from the origin that it would have in the equal-temperament wrapped space. source code

 et_interval(st=1, oct=0) Frequency ratio corresponding to a number of ET semitones and octaves. source code

 add_z_coordinates(coords, center=`(`0`, `0`, `0`)`, pitch_range=1) Given a list of (x,y) coordinates, adds a z-coordinate to each such that the pitch of the notes is kept within a given number of octaves around the given center. source code

 root_to_et_coord(root) Given a ET root as an integer in the range 0 <= r < 12, returns the 2D ET coordinate in the range (0,0) <= (x,y) < (4,3) that that root has in the 4x3 ET space. source code
 Variables
et_semitone = `1.05946309436`
__package__ = `'jazzparser.utils'`
 Function Details

### nearest_neighbour(base_coord, root_number)

source code

Returns the coordinate of the point with the given root number that is closest to the given point base_coord. Coordinates are represented as (x,y) tuples. The root number is the semitone number of the root (0->I, 1->bII, etc). 0 is assumed to be the ET equivalence set including the central point (0,0).

Returns: (x,y) coordinate
the location of the point with the given ET root number that is closest to the base point.

### coordinates_to_roman_names(coords)

source code

Given a list of tonal space coordinates, return a list of strings giving the roman numeral names of the points. The name is the unambiguous unique specifier of the point (e.g. bbIII++).

### coordinate_to_alpha_name_c(*args, **kwargs)

source code

Does the same as coordinate_to_roman_name, but generates alphabetic note names in the key of C (i.e. (0,0)=C).

### coordinate_key_region(coord)

source code

Given a tonal space coordinate, returns the 2D identifier of the key region that it lies in. A key region is the not-quite-rectangular region of notes in a major scale. The central one contains IV (at (-1,0)), rightwards to II ((2,0)), and VI ((-1,1)), rightwards to VII ((1,0)). These regions are tessellated across the infinite space.

The coordinate returned identifies the region. (0,0) is the central region, with bottom left at point (-1,0). (1,0) is strictly to the right and down one, so has its bottom left at (-1,3).

### coordinate_within_region(coord)

source code

Given a tonal space coordinate, returns the coordinate of this point relative to the bottom left corner of the local key region in which it lies (see coordinate_key_region).

This coordinate will be among (0,0),...,(3,0),(0,1),...,(2,1).

### coordinate_to_et(coord)

source code

Takes a point in the tonal space and returns the number of semitones above the origin's pitch that point would be in equal temperament.

The coordinate is 3-dimensional.

### coordinate_to_et_2d(coord)

source code

2-dimensional version of coordinate_to_et. Returns an interval within one octave upwards ([0-12]).

### cents_to_pitch_ratio(cents)

source code

Converts a number of cents (tuning theory unit of pitch ratio) into a floating point pitch multiplier.

Parameters:
• `cents` (float) - number of cents

### pitch_ratio_to_cents(ratio)

source code

Inverse of cents_to_pitch_ratio. Given a pitch multiplier, returns the equivalent interval expressed in cents.

### tonal_space_pitch(coord)

source code

Given a 3D coordinate in the tonal space, returns the pitch ratio of that point from the origin's pitch. x: fifths y: thirds z: octaves

### add_z_coordinates(coords, center=`(`0`, `0`, `0`)`, pitch_range=1)

source code

Given a list of (x,y) coordinates, adds a z-coordinate to each such that the pitch of the notes is kept within a given number of octaves around the given center.

Parameters:
• `coords` (list of 2-tuples) - (x,y) coordinates
• `center` (3-tuple) - point that defines the center of the range of pitches within which the output coordinates will lie
• `pitch_range` (int) - width of the range of pitches, as an integer number of octaves.

### root_to_et_coord(root)

source code

Given a ET root as an integer in the range 0 <= r < 12, returns the 2D ET coordinate in the range (0,0) <= (x,y) < (4,3) that that root has in the 4x3 ET space.

If the root is not within that range, it will be taken mod 12.

 Generated by Epydoc 3.0.1 on Mon Nov 26 16:04:56 2012 http://epydoc.sourceforge.net