IntervalTable a class for classifying intervals that fall within a tuning tolerance
This class is used in Dissonance through the rationalize method of SequenceableCollection to find the intervals in an interval list which lie within a tolerance range to array of frequency ratios. This is done in Dissonance:harmonicAnalysis and replaces the intervals from the dissonance analysis with the ones in the list which have the highest harmonic intensity value.
There are two kinds of interval tables: one obtained from the Huygens-Fokker Foundation
(http://www.huygens-fokker.org/docs/intervals.html, consulted 03/10/07) which contains 356 intervals inside an octave. The second kind (which is the default) is a table generated with the Atari ST program JST written by Clarence Barlow (see http://www.musikwissenschaft.uni-mainz.de/Autobusk). There are several lists generated with JST, each with intervals filtered by a different minimum harmonicity value.
*loadTable is used to load the lists from files, with arguments \huygens or \JST. If \JST is the case, an additional argument for minimum harmonicity should be provided: \030, \035, \040, \045 or \050 (where for instance, \030 stands for a harmonicity of 0.03).
See also: Dissonance
Class Methods
No instances are created from this class. Its only use is through the following class methods.
*classify(centList, tolerance = 6)
Returns an Array of arrays of intervals, cents and names for all candidates falling within tolerance cents from centList.
// The result of *classify is not formatted for human viewing.
// This example shows how to use its results and print them nicely
(
i = [100, 150, 200, 450]; // some tempered intervals in cents, try with other values
t = 12; // tolerance, play around with this too
g = IntervalTable.classify(i, t);
i.do{|int, idx|
postf("The following intervals are close to % cents by +/- % cents:\n", int, t);
g[idx].do{|x|
postf("\t%/%,\t% cents,\t%\n",x[0][0],x[0][1],x[1].round(0.001),x[2]);
};
"".postln;
};
)
There is a method to SequenceableCollection that does this automatically:
centsToName(tolerance = 12, restore = true)
Practical to find out the closest rationalization for a list of cent distances.
Tolerance in cents. As this method changes the current table of IntervalTable to \huygens,
restore is a flag for resetting the class back the table it had before calling this method.
[100, 150, 200, 450].centsToName
ratioToName(tolerance = 12, restore = true)
Useful to find the closest ratios to a list of ratios. This method is just a minor conveniece.
[[531441,524288],[3,2],[5,4],[7,4],[11,8],[16,15]].ratioToName
*loadTable( type = \JST, min = \030, path )
This method is used to load a table from files included in the dissonance package of classes. The files are dictionaries saved as ZArchives with a .int extension. There are five such files: huygensList.int, and four JSTList0xx.int files, containing the different versions of the JST intervals. The class is initialized with the default file JSTList030.int. This method is thus only necessary when a different interval list is required.
The dissonance package should be installed inside the extensions directory which is located inside the user application support directory (see Platform). In case the interval table files are located elsewhere, the optional path argument should point to this directory. This is provided for non-standard cases.
Examples:
IntervalTable.loadTable(\huygens); // load the Huygens table
IntervalTable.loadTable(\JST, \045); // load a JST with a min harmonicity of 0.045
Class Variables
table
Contains a dictionary with the interval tables.
The data from the JST files contains the following keys:
t = IntervalTable.table;
t.ratios;
t.cents;
t.harmon; // their harmonicity
t.numIntervals; // total number of intervals
t.maxNum; // max numerator of intervals
t.maxDenom; // max denominator
t.range; // the total range of the list in cents
The data from the Huygens-Fokker table of intervals hast the following key:
IntervalTable.loadTable(\huygens); // first load the Huygens table
t = IntervalTable.table;
t.ratios;
t.cents;
t.names; // the names of the intevals
tableType
Either \JST or \huygens
(cc) 2008, jsl