Dissonance curves are made by calculating the psychoacoustic roughness between two sets of partials, usually both sets coming from the same source. The partials are weighted against each other according to a critical band model of auditory roughness; this makes one point of the curve, the rest of the points are arrived at by transposing one of the sets. Once the dissonance curve is calculated, a PitchSet is formed out of the rationalized local minima. This makes it possible to compose with harmonic material derived from spectra.
This class uses the extensions to SimpleNumber, Integer and SequenceableCollection included as part of DissonanceLib and available in numberExtras. They contain formulas for harmonicity, unit conversion, rationalization, etc. There are other methods in plusSignal.sc handy for calculating dissonance curves from FFT data. See LiveDissonance.
Make a dissonance curve for the array of partials f with array of amplitudes a. A set of partials is measured against transpositions of itself, yielding a profile of its sensory dissonance behavior. The time of the calculations will slow down exponentially as the number of partials increases, 8-10 gives good results, depending on the source sound and the kind of application.
f |
An array of partials in Hz |
a |
Array of amplitudes. If the method |
start |
Start frequency factor for the transpositions of the analysis. It is usually set a little lower than the lowest interval of interest, e.g. 1 would correspond to unison, so its good to start a bit before, at 0.99 |
end |
End frequency factor for the transposition of the analysis. Here it ends a bit after and octave, e.g. 2.01 |
inc |
Increment of the frequency factor, default 0.01, a hundredth of an octave |
method |
Either |
max |
Either true or false. This is to tell the analysis which partial it should consider to be the fundamental of the spectrum. If true then the fundamental will be the partial with the highest amplitude, otherwise the first one in the frequency array |
A Dissonance object.
Example, execute line by line:
-> [1/2, 3/5, 2/3, 3/4, 4/5, 1/1, 5/4, 4/3, 3/2, 5/3, 2/1, 5/2, 3/1, 4/1]
plot the curve, x = interval, y = roughness:
d.plot;
listen to the scale
d.play;
Instance variables:
To make a dissonance curve between 2 different sets of partials (f and g with amplitudes a and b). All other arguments stay the same as in *make.
Makes a default dissonance object obtained from a sawtooth spectrum.
Loads a dissonance object from disk.
This is useful for reading arrays or dictionaries of dissonance objects saved with ZArchive.
the intervals (in frequency ratios) found by the dissonance analysis.
the partials that generated the curve (the input)
Roughness of all the intervals found by the analysis.
The dissonance curve itself
The fundamental. Can be either the lowest partial or the highest amplitude on depending on the max boolean argument in *make and *make2.
The scale in frequency ratios.
The scale in terms of an array of [p,q] ratios.
Harmonic metrics of the intervals found in the analysis.
Intervals in cents.
The Dissonance: -harmonicAnalysis method rationalizes, calculates harmonicities and creates a PitchSet with the intervals. This pitch set is held in this instance variable.
The metric with which it calculates the harmonicity instance variable.
A dictionary containing keys and values that describe when and how the dissonance curve was made.
To the intervals formed by the points of local minimum roughness in the dissonance curve, an additional harmonic analysis is done: first they are rationalized (see SequenceableCollection: -rationalize), then the harmonicities calculates (the metric depending on the metric
), and finally a PitchSet is created. It is a collection of HarmonicVector which partitions the intervals into harmonic and timbral sets among other things.
tolerance |
in cents |
metric |
|
type |
|
max |
Either a ratio or a prime number. |
unisonvector |
The unison matrix used to partition the intervals in harmonic space. See PitchSet. |
post |
If |
Saves the Dissonance object.
Play scale of the dissonance curve.
Plot the curve.
Allows to use the pitch set of the dissonance object in stochastic ways for harmonic fields. See the discussion in PitchSet
Likewise.