PitchSet:
Filter:
Classes (extension) | DissonanceLib

PitchSet
ExtensionExtension

A collection of intervals represented as harmonic vectors in harmonic space.
Location: NOT INSTALLED!

Description

Pitch sets are designed for the handling of irregular, non octave-repeating interval collections like those produced by dissonance curves. Each interval they contain is represented as a HarmonicVector. The set is partitioned into harmonic and timbral subsets, according to whether they lie inside certain parallelepipeds in harmonic space. These 'periodicity blocks' are defined by matrices of so-called 'unison vectors'.

Pitch sets are also used to calculate stochastic harmonic fields by computing inter-interval matrices according to a HarmonicMetric. The probabilities for choosing interval are proportional their metric, which can be generated accordance with the field's 'strength' (from -1 to 1).

Dissonance objects represent their scales as PitchSets with the Dissonance: -harmonicAnalysis method. PitchSets can also be created directly from ratios. Visualization of the sets in harmonic space as well as the harmonic fields can be done with the aid of the GNUPlot quark. A few other niceties are possible with these objects. See below.

This is an implementation of Adriaan Fokkers 'Periodicity Blocks'. See Fokker, A, “Unison vectors and periodicity blocks in the three-dimensional (3-5-7-)harmonic lattice of notes”, Koninklijke Nederlandse Akademie van Wetenschappen - Amsterdam, Proceedings, Series B 72, No. 3, 1969 available at: http://www.huygens-fokker.org/docs/fokkerpb.html

Class Methods

.unisons

This are default unison vector matrixes used to determine how the pitch set is partitioned into timbral and harmonic subsets. They are accessed as a dictionary of dictionaries: the first key is the number of dimensions, either dim2 or dim3, corresponding to 5 and 7-limit harmonic lattices. There are also two a 4-dimensional unison matrices representing Harry Partch's 43 tone 11 limit scale (approximating it to 41 degrees instead of 43). The next key corresponds to an equal division per octave: et12, et19, et22, et31, et41 or et53. Here an the unison matrices are accesed. The first key is \num which contain the number of options, the following are numbers with an index (beginning from 1) that selects between different unison matrixes that divide harmonic space into those divisions. There are generally 2 options, each having a different center for the parallelepiped.

These dictionaries are fed when creating a pitch set. The default is 12ET in 3 dimensions (7-limit). The dictionary can be accesed in the class definition of PitchSet. Other options for matrices are possible.

Example:

.with

The main method for creating pitch sets from an array of [p,q] ratios.

Arguments:

array

something like [[1,2],[7,6],[7,5],[7,4]]

unisonvector

The unison matrix for partitioning. Defaults to PitchSet.unisons.dim3.et12[1]. See the class definition to look at the other options. The default corresponds to 7-limit approximations to 12 tone equal temperament.

Returns:

a PitchSet object.

This example is used to illustrate some of the instance methods below.

It posts:

Harmonic Set[ 8/7, 1/2, 7/5, 7/4 ]
Timbral Set[ 7/6 ]

Same intervals with other unison matrix:

The timbral and harmonic sets are different from the first PitchSet:

Harmonic Set[ 1/2, 7/5, 7/4 ]
Timbral Set[ 8/7, 7/6 ]

Inherited class methods

Instance Methods

.unisonvector

Instance variable with the current unison matrix.

.set

A set of intervals, each represented as a HarmonicVector.

.harmonicSet

The set of the harmonic intervals, the ones that fall inside the parallelepiped defined by the unison matrix.

.timbralSet

The set of 'timbral' intervals, the ones that fall outside the the parallelepiped defined by the unison matrix.

.setH

An array containing the harmonic set intervals in the form of an array of [p,q] ratios.

.setT

An array containing the timbral set intervals in the form of an array of [p,q] ratios.

.ratios

An array with all the ratios of the PitchSet.

.ratioM

The ratio matrix, not for direct access by the user.

.metricM

Metric matrix. Private.

.ranks

Likewise. The ranks of the intervals.

.weights

Private.

.invweights

Private.

.equweights

Private.

.currentRanks

Private.

.markov

The markov chain for the probability matrix. Not directly usable.

.markovStream

Likewise.

.metric

The pitch sets' metric. See HarmonicMetric.

.add

Add a ratio to the pitch set.

Arguments:

item

The [p,q] ratio.

.play

Plays the pitch set as a scale.

.playChord

Plays the set as a chord.

.partition

Partition the intervals into timbral and harmonic subsets. Normally this is done when creating a PitchSet or when adding a ratio to it.

Say we want to change the partitioning of our pitch set.

posting:

Harmonic Set[ 1/2, 7/4, 7/5 ]
Timbral Set[ 7/6, 8/7, 12/7 ]

.makeProbMatrix

Use this method to be able to play harmonic fields (choosing intervals from probabilities derived from their harmonic measures). It creates a inter-interval matrix with harmonicities between each pair of intervals.

The harmonicities are converted into probability weights by the formula: (rank + add)^pwr

Arguments:

pwr

The degree of differentiation between the harmonic measures. The default of 15 works well, higher values make the inharmonic intervals less probable.

add

Probably there is no need to change this parameter.

metric

The harmonic metric. Either \harmonicity, \harmonicDistance or \gradusSuavitatis. Harmonic fields have been used successfully with harmonicity, the other two metrics need some work to function properly. To do for the next version.

Returns:

does not return a value, just calculates the matrices that are held as instance variables.

.calcPolarity

Once the matrix has been calculated, this method permits the interpolation between the values matrices by means of the polarity argument. This value corresponds to the strength of the harmonic field. At 0 all intervals are equally probable (atonal), at 1 the most harmonic are more probable (tonal, where the contrast between harmonic and inharmonic intervals being defined by the pwr argument in makeProbMatrix), at -1 the most inharmonic are more probable (antitonal).

Arguments:

polarity

A float from -1 to 1.

filteredScale

If not given, all the ratios in the pitch set are used. If given (as an array of [p,q] ratios) then only those intervals are taken into account.

Returns:

an array of probabilities corresponding to each ratio of the pitch set. This array can used as an argument to wchoose or in a Pwrand pattern.

Example (first evaluate the code in the previous method):

.gradusSuavitatis

Euler's gradus function can give the total harmonicity for sets of intervals. This method calculates that for the whole pitch set as well as its partitions.

.asHarmonicSeries

Outputs the different partitions as harmonic series.

Posts:

complete: 1/2, 8/7, 7/6, 7/5, 12/7, 7/4

harmonic: 1/2, 7/5, 7/4

timbral: 8/7, 7/6, 12/7

Complete: [ 210, 480, 490, 588, 720, 735 ]
Harmonic: [ 10, 28, 35 ]
Timbral: [ 48, 49, 72 ]
Harmonic Set[ 1/2, 7/4, 7/5 ]
Timbral Set[ 7/6, 8/7, 12/7 ]

Returns:

The pitch set.

.reducedRatios

(describe method here)

Returns:

The complete pitch set expressed as a harmonic series.

.sort

Order the ratios of the complete pitch set according to a harmonic metric (default harmonicity).

Compare:

Returns:

an array of [p,q] ratios.

.asScale

Posts a lot of information regarding the pitch set. The complete and adjacency ratios, cent values, octave reduced ratio and adjacency ratios and notes.

Arguments:

ffreq

A frequency to anchor the ratios to some fundamental, default: 440.

.asETdegrees

A useful method to approximate the intervals in the pitch set to degrees of some equal division of the octave (default: 53). A highest prime argument can be used filter intervals containing higher prime factors than this threshold.

Returns:

an array of degrees corresponding to the harmonic and the timbral partitions.

Posts:

53-TET
Harmonic Ratios: 1/2, 7/5, 7/4
Harmonic Degrees: [ 0, 26, 43 ]
Timbral Ratios: 8/7, 7/6
Timbral Degrees: [ 10, 12 ]
[ [ 0, 26, 43 ], [ 10, 12 ] ]

Compare to:

Posts:

31-TET
Harmonic Ratios: 1/2, 7/5, 7/4
Harmonic Degrees: [ 0, 15, 25 ]
Timbral Ratios: 8/7, 7/6
Timbral Degrees: [ 6, 7 ]
[ [ 0, 15, 25 ], [ 6, 7 ] ]

.plotHarmonicField

Show the probability matrix in 3D using GNUPlot (requires the GNUPlot quark).

WARNING: GNUPlot is currently (July 2025, SC version 3.14) not working in Mac OS.

Arguments:

what

Can be \metric, \ranks, \weights, \currRanks to plot the different matrices that are created with the makeProbMatrix method. Defaults to \metric.

hollow

If true (default), it will hollow out the main diagonal in the plot (not in the matrix itself) so this diagonal doesen't get in the way of the visualization.

minval

The minimum value to plot against with.

title

A title for the plot.

.plotHarmonicSpace

Plot a 3D harmonic space with GNUPlot. If the pitch set has more than 3 dimensions (larger than 7-limit intervals) then the space will not correspond correctly to the pitch set. See makeMDSfile for those cases. The intervals are shown as little figures. It is complicated to print them out as proportions (though possible). Another drawback: couldn't find a way to plot the lattice axes between the intervals. This method shows a nice plot but is not very useful.

Arguments:

type

Defaults to \235. Does not work yet, but the intention is to choose which 3 the axes of hspace are plotted (for example \357 or \27e, e being 11).

.makeMDSfile

For pitch sets in more than 3 dimensions, a multidimensional scaling analysis can project their relative distances in harmonic space into a plane. I tried and almost succeeded in implementing the MDS 'smacof' algorithm in SC, but somehow it does not work (the class is included in the DissonanceLib though). This method writes a file that can be read by other visualization programs for rendering the MDS analysis. I use http://orange.biolab.si/

Arguments:

path

.selectPrime

Selects all the intervals in the pitch set containing the selected prime in their ratio.

Arguments:

prime

Defaults to 7

Returns:

an array of [p,q] ratios.

.rejectPrime

The negative of the previous method.

.separateIntoPrimes

Separates a pitch set into subsets based on the maximum prime numbers contained in their ratios. Useful for separating the 'colors' or fundamental intervals of a pitch set.

Returns:

an array of arrays, each with its own prime limit.

Inherited instance methods

Examples