Dissonance:
Filter:
DissonanceLib/Classes (extension) | DissonanceLib

Dissonance
ExtensionExtension

Generate dissonance curves from roughness analysis.

Description

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.

External methods required:

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.

Class Methods

.make

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.

Arguments:

f

An array of partials in Hz

a

Array of amplitudes. If the method \parncutt is used then they should be expressed as loudnesses in sones. See LoudnessModel

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 \parncutt or \sethares. This class was first made out of code from W. Sethares' book Tuning, Timbre, Spectrum, Scale. This model is based on frequency and amplitude. Later on, the algorithm was refined to use Richard Parncutt's model based on subjective units of barks and sones. This method gives more precise curves with more meaningful roughness measures and is also a bit faster, so there really is no need to use the \sethares setting.

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

Returns:

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:

.make2

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.

.default

Makes a default dissonance object obtained from a sawtooth spectrum.

.load

Loads a dissonance object from disk.

.readZArchive

This is useful for reading arrays or dictionaries of dissonance objects saved with ZArchive.

Instance Methods

.intervals

the intervals (in frequency ratios) found by the dissonance analysis.

.partials

the partials that generated the curve (the input)

.roughness

Roughness of all the intervals found by the analysis.

.dcurve

The dissonance curve itself

.fund

The fundamental. Can be either the lowest partial or the highest amplitude on depending on the max boolean argument in *make and *make2.

.scale

The scale in frequency ratios.

.ratios

The scale in terms of an array of [p,q] ratios.

.harmonicity

Harmonic metrics of the intervals found in the analysis.

.cents

Intervals in cents.

.pitchSet

The Dissonance: -harmonicAnalysis method rationalizes, calculates harmonicities and creates a PitchSet with the intervals. This pitch set is held in this instance variable.

.metric

The metric with which it calculates the harmonicity instance variable.

.info

A dictionary containing keys and values that describe when and how the dissonance curve was made.

.harmonicAnalysis

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.

Arguments:

tolerance

in cents

metric

\harmonicity or \harmonicDistance or \gradusSuavitatis

type

\size means that max will hold the highest ratio allowed in the rationalization. Instead it can be the highest \prime allowed.

max

Either a ratio or a prime number.

unisonvector

The unison matrix used to partition the intervals in harmonic space. See PitchSet.

post

If true then post info regarding the Dissonance object before and after the harmonic analysis.

.save

Saves the Dissonance object.

.play

Play scale of the dissonance curve.

.plot

Plot the curve.

.makeMatrix

Allows to use the pitch set of the dissonance object in stochastic ways for harmonic fields. See the discussion in PitchSet

.calcPolarity

Likewise.