HarmonicMetric A class that abstracts different harmonic metrics in order to switch

between harmonic measures in rationalization and in classes such as 

Dissonance and PitchSet.


This class is used in Dissonance and PitchSet in order to classify and analyse the generated intervals according to different harmonic metrics. The ones included are the most useful (Tenney's Harmonic Distance, Barlow's Harmonicity and Euler's Gradus Suavitatis) but others can be added to the class. The three metrics are actually defined in the additions to simple number (see numberExtras). 


See also: Dissonance, PitchSet and HarmonicVector


Creation


*new (metric)

metric - A symbol. Can be \harmonicity, \harmonicDistance or \gradusSuavitatis. Default is \harmonicity.  

g = HarmonicMetric.new; // posts harmonicity

g.value([5,4]); // the harmonic intensity of 5/4



Instance Variable:

type

The current type of harmonic metric. Can be changed. 

g = HarmonicMetric(\gradusSuavitatis);

g.type = \harmonicDistance;

Doing stuff with HarmonicMetric:

value (ratios)

Give the values of the harmonic metric for an array of [p, q] ratios.

ratios - A collection of ratios or a single [p,q] ratio.

r = [ [1,1], [1,2], [3,2], [5,6], [11,8], [13,12] ];

g = HarmonicMetric.new(\harmonicDistance); 

g.value(r).round(0.001); 

g.type = \harmonicity;

g.value(r).round(0.001); // as can be seen, harmonicity decreases with harmonic dissonance

// while gradusSuavitatis and harmonicDistance increase

g.type = \gradusSuavitatis

g.value(r); // the gradus function returns integer values


mostHarmonic (ratios)

Returns the most harmonic ratio from the collection according to the current type of metric. 

ratios - A collection of ratios.

g = HarmonicMetric.new;

g.mostHarmonic([ [3,2], [4,3]]); // a fifth is more harmonic than a fourth



leastHarmonic (ratios)

Same as above but for the least harmonic of a ratio collection. 

ratios - A collection of ratios.

g = HarmonicMetric(\gradusSuavitatis);

g.leastHarmonic([ [7,4], [16,9]]); // a harmonic seventh is less harmonic than a minor 

// seventh according to gradusSuavitatis

g.type = \harmonicDistance;

g.leastHarmonic([ [7,4], [16,9]]); // but according to harmonic distance, 

// 16/9 is less harmonic than 7/4


order (ratios)

Order the collection of ratios according to the current harmonic metric type. 

// compare the 3 different results: 

g = HarmonicMetric.new; // default is harmonicity

g.order([[1,1],[9,8],[5,4],[4,3],[3,2],[5,3],[15,8],[2,1]])

g.type = \gradusSuavitatis; // change type and reorder

g.order([[1,1],[9,8],[5,4],[4,3],[3,2],[5,3],[15,8],[2,1]])

g.type = \harmonicDistance; // change type and reorder 

g.order([[1,1],[9,8],[5,4],[4,3],[3,2],[5,3],[15,8],[2,1]])




asString

This allows the representation of an instance object printout its type. It is not used on its own.

g = HarmonicMetric.new; // prints out its type

g.type = \gradusSuavitatis;