#### Previous topic

psychoacoustics module

distance module

# tuning module¶

class bregman.tuning.TuningSystem
```A class for generating tuning systems, scales, and intervals.

Usage examples:
T = TuningSystem()
print T.EQ # equal-temperament 12-tet frequency ratios
print T.PY # Pythagorean frequency ratios
print T.JI # just intonation frequency ratios
print T.BP # equal temperament Bohlen-Pierce 13-step tritave ratios
eq = T.to_scale_freqs(T.JI, f0=220) # realize the scale frequencies starting at 220Hz
x = T.to_scale_sound(T.EQ, f0=220, num_harmonics=6) # realize scale as sound
x = T.to_scale_intervals(T.PY, f0=220, interval=7, num_harmonics=6) # realize scale as intervals with p5
sound(x*0.05, 44100)

The methods equal_temperament(), Pythagorean(), and just_intonation(), can generate the scales
with different parameterizatoins, such as the order (number of tuning steps) to use.```
Bohlen_Pierce(frame_interval=3, num_steps=13)
`Defines 13-tet pitch classes in Bohlen-Pierce tritave as irrational numbers.`
Pythagorean(N=12)
```Generate 12 steps of Pythagorean tuning as rational numbers
from N cycles in P5 and P4 directions.```
equal_temperament(frame_interval=2, num_steps=12)
`Defines 12-tet pitch classes in Equal Temperament as irrational numbers.`
generalized_equal_temperament(frame_interval=2, num_steps=12)
`Defines 12-tet pitch classes in Equal Temperament as irrational numbers.`
just_intonation(N=25)
`Generate 12 steps of Just Intonation tuning from N harmonics`
sort_ratios(ratios)
```Sort and select tuning system ratios in ascending order by
proximity to equal tempered pitch classes.```
to_dissonance(tuning, f0=440.0, num_harmonics=6)
```Convert scale to dissonance values for num_harmonics harmonics.
Assume an exponentially decaying harmonic series.
Returns dissonance scores for each interval in given tuning system.```
to_scale_freqs(tuning, f0=440.0)
`Convert tuning system list to a scale frequencies at f0 [default=440.Hz]`
to_scale_intervals(tuning, interval=0, f0=440.0, num_harmonics=6, dur=0.5, sr=44100.0)
```Realize given tuning system as a series of intervals, with
scale degree interval=0 (tonic), starting at frequency
f0=440., using num_harmonics=6 complex tones with duration
dur=0.5 seconds, and default sample rate sr=44100Hz.```
to_scale_sound(tuning, f0=440.0, num_harmonics=6, dur=0.5, sr=44100.0)
```Realize given tuning system as a scale, starting at frequency
f0=440., using num_harmonics=6 complex tones with duration dur=0.5 seconds, and
default sample rate sr=44100Hz.```