DissonanceCurve:
Filter:
TuningLib/Classes (extension) | Tuning > TuningLib

DissonanceCurve
ExtensionExtension

Analyzes timbres in order to create tunings

Description

Uses Bill Seathares' Dissoncance Curve algorithm in order to compute tunings for a given timbre.

Class Methods

.new

Create a new curve based on arrays of data. This would mostly be used for additive synthesis.

Arguments:

freqs

An array of signficant frequencies of a timbre.

amps

An array of amplitudes for the given frequencies.

highInterval

The largest interval to compute in cents. For octave-based systems, you would usually use 1200. Default value is 1902.

.fm

Create a curve based on the timbre of a given FM specification

Arguments:

carrier

The carrier frequency in Hz

modulator

The modulation frequency in Hz

depth

The depth (or delta range) of the modulator, in Hz

highInterval

The largest interval to compute in cents. For octave-based systems, you would usually use 1200.

Discussion:

ex:

.fft

Create a curve based on the timbre of a given FFT buffer. THIS IS VERY SLOW and uses a lot of system resources

Arguments:

buffer

An FFT Buffer

size

The size of the Bufer in Frames

cutoff

The lower cutoff amplitude for a bin. Defaults to -60 dB

highInterval

The largest interval to compute in cents. For octave-based systems, you would usually use 1200.

action

A function to be evaluated once computing the curve is complete.

.spectrum

Create a curve based on a Spectrum

Arguments:

spectrum

a Spectrum

highInterval

The largest interval to compute in cents. For octave-based systems, you would usually use 1200.

Instance Methods

.tuning

Returns a Tuning based on the minima of the Dissonance Curve

.scale

Returns a Scale in which the Tuning is the minima of the curve.

Arguments:

size

The number of degrees of the scale. For size n, it pickes the n most consonant degrees. Defaults to inf, which makes a scale degree for every degree of the Tuning.

.plot

Plot the DissonanceCurve

.digestibleTuning

Deprecated. Use justTuning

.justTuning

Returns a Tuning Related to Sethares' algorithm, but calculated using a just tuning. This does a comparison of every partial at every tuning, but instead of looking at Plomp and Levit's ideas of local consonance, it compares the ratio relationships between the partials. The numerator and denominator of this ratio is summed and then multiplied by the amplitude of the quieter partial.

This algorythm just gives a list of the relative dissonance at all possible tunings. To figure out scale degrees, the most consonant tuning is picked from it's neighbors, given the window size.

The tuning generated by this way and by the Sethares / Plomp and Levit algorithms may have nothing to do with each other.

Arguments:

window

The idealized step size, in cents. To do normal-ish semitones, this would be set to 100

Returns:

.digestibleScale

Deprecated. Use justScale

.justScale

Returns a Scale based on the justTuning.

Arguments:

window

The window size used to compute the justTuning

size

The number of degrees of the scale. For size n, it pickes the n most consonant degrees. Defaults to inf, which makes a Scale degree for every degree of the Tuning.

Returns:

.limitedJustTuning

Uses the same calculation for dissonance as in justTuning, but picks scale degrees based on a given limit. Neither the numerator, nor the denominator may be greater than the limit. The higher the given limit, the more the resultant tuning will be based on the timbre. The lower the limit, the more it will resemble normal, non-timbral just intonation.

The tuning generated by this way and by the Sethares / Plomp and Levit algorithms may have nothing to do with each other.

Arguments:

limit

The largest allowed numerator or denominator. The higher this number, the greater the relationship between the scale and the timbre.

size

The number of ratios present in the tuning

Returns:

Discussion:

It it necessary to limit by size because the dissonance curve contains ALL of the just tunings. Returning all tunings under the limit would just return a normal lattice. By including a size, we can limit the resultant tuning to the most timbrally-consonant steps.

.limitedJustScale

Returns a Scale based on the limitedJustTuning.

Arguments:

limit

The largest allowed numerator or denominator used in computing the tuning

tuningSize

The number of ratios present in the tuning.

scaleSize

The numner of ratios present in the scale. If this is smaller than the number present in the tuning, it picks the most consonant steps.

Returns:

Discussion:

.postJust

Posts the ratios for the just tuning. You must compute the scale first, via either of the two just methods

Discussion:

+

Adds two DiscconanceCurves together in a meaningful way. This would be useful to figure out a scale that works for two different timbres.

Arguments:

other

a Spectrum or a DissonanceCurve

Returns:

a new DissonanceCurve

Examples

Plot a curve:

Get a scale:

To use with a Pbind, let's make a synthdef that uses some of the keywords from event, specifically freq and octave.

Our Pbind is very standard:

The pbind will generate a midinote based on the degree chosen and the scale. This will be a floating point number. When we use this number in the synthDef, it will give us a useful ratio and generate the correct notes.