hmt-0.16: Haskell Music Theory

Safe HaskellSafe
LanguageHaskell98

Music.Theory.Interval.Barlow_1987

Description

Clarence Barlow. "Two Essays on Theory". Computer Music Journal, 11(1):44-60, 1987. Translated by Henning Lohner.

Synopsis

Documentation

barlow :: (Integral a, Fractional b) => a -> b Source #

Barlow's indigestibility function for prime numbers.

map barlow [1,2,3,5,7,11,13] == [0,1,8/3,32/5,72/7,200/11,288/13]

factor :: Integral a => [a] -> a -> [a] Source #

Generate list of factors of n from x.

factor P.primes 315 == [3,3,5,7]
P.primeFactors 315 == [3,3,5,7]

prime_factors :: Integral a => a -> [a] Source #

factor n from primes.

map prime_factors [1,4,231,315] == [[],[2,2],[3,7,11],[3,3,5,7]]
map P.primeFactors [1,4,231,315] == [[],[2,2],[3,7,11],[3,3,5,7]]

multiplicities :: (Eq a, Integral n) => [a] -> [(a, n)] Source #

Collect number of occurences of each element of a sorted list.

multiplicities [1,1,1,2,2,3] == [(1,3),(2,2),(3,1)]

prime_factors_m :: Integral a => a -> [(a, a)] Source #

multiplicities . primeFactors.

prime_factors_m 315 == [(3,2),(5,1),(7,1)]

merge :: (Ord a, Num b, Eq b) => [(a, b)] -> [(a, b)] -> [(a, b)] Source #

Merging function for rational_prime_factors_m.

rational_prime_factors_m :: Integral b => (b, b) -> [(b, b)] Source #

Collect the prime factors in a rational number given as a numerator/ denominator pair (n,m). Prime factors are listed in ascending order with their positive or negative multiplicities, depending on whether the prime factor occurs in the numerator or the denominator (after cancelling out common factors).

rational_prime_factors_m (16,15) == [(2,4),(3,-1),(5,-1)]
rational_prime_factors_m (10,9) == [(2,1),(3,-2),(5,1)]
rational_prime_factors_m (81,64) == [(2,-6),(3,4)]
rational_prime_factors_m (27,16) == [(2,-4),(3,3)]
rational_prime_factors_m (12,7) == [(2,2),(3,1),(7,-1)]

rational_prime_factors_t :: Integral b => Int -> (b, b) -> [b] Source #

Variant of rational_prime_factors_m giving results in a table up to the nth prime.

rational_prime_factors_t 6 (12,7) == [2,1,0,-1,0,0]
rational_prime_factors_t 6 (32,9) == [5,-2,0,0,0,0]

disharmonicity :: (Integral a, Num b) => (a -> b) -> (a, a) -> b Source #

Compute the disharmonicity of the interval (p,q) using the prime valuation function pv.

map (disharmonicity barlow) [(9,10),(8,9)] ~= [12.733333,8.333333]

harmonicity :: (Integral a, Fractional b) => (a -> b) -> (a, a) -> b Source #

The reciprocal of disharmonicity.

map (harmonicity barlow) [(9,10),(8,9)] ~= [0.078534,0.120000]

harmonicity_r :: (Integral a, Fractional b) => (a -> b) -> Ratio a -> b Source #

Variant of harmonicity with Ratio input.

to_rational :: Integral a => (a, a) -> Ratio a Source #

from_rational :: Ratio t -> (t, t) Source #

Make numerator denominator pair of n.

type Table_2_Row = (Double, [Integer], Rational, Double) Source #

Set of 1. interval size (cents), 2. intervals as product of powers of primes, 3. frequency ratio and 4. harmonicity value.

table_2 :: Double -> [Table_2_Row] Source #

Table 2 (p.45)

length (table_2 0.06) == 24
length (table_2 0.04) == 66

table_2_pp :: Table_2_Row -> String Source #

Pretty printer for Table_2_Row values.

mapM_ (putStrLn . table_2_pp) (table_2 0.06)
   0.000 |  0  0  0  0  0  0 |  1:1  | Infinity
 111.731 |  4 -1 -1  0  0  0 | 15:16 | 0.076531
 182.404 |  1 -2  1  0  0  0 |  9:10 | 0.078534
 203.910 | -3  2  0  0  0  0 |  8:9  | 0.120000
 231.174 |  3  0  0 -1  0  0 |  7:8  | 0.075269
 266.871 | -1 -1  0  1  0  0 |  6:7  | 0.071672
 294.135 |  5 -3  0  0  0  0 | 27:32 | 0.076923
 315.641 |  1  1 -1  0  0  0 |  5:6  | 0.099338
 386.314 | -2  0  1  0  0  0 |  4:5  | 0.119048
 407.820 | -6  4  0  0  0  0 | 64:81 | 0.060000
 435.084 |  0  2  0 -1  0  0 |  7:9  | 0.064024
 498.045 |  2 -1  0  0  0  0 |  3:4  | 0.214286
 519.551 | -2  3 -1  0  0  0 | 20:27 | 0.060976
 701.955 | -1  1  0  0  0  0 |  2:3  | 0.272727
 764.916 |  1 -2  0  1  0  0 |  9:14 | 0.060172
 813.686 |  3  0 -1  0  0  0 |  5:8  | 0.106383
 884.359 |  0 -1  1  0  0  0 |  3:5  | 0.110294
 905.865 | -4  3  0  0  0  0 | 16:27 | 0.083333
 933.129 |  2  1  0 -1  0  0 |  7:12 | 0.066879
 968.826 | -2  0  0  1  0  0 |  4:7  | 0.081395
 996.090 |  4 -2  0  0  0  0 |  9:16 | 0.107143
1017.596 |  0  2 -1  0  0  0 |  5:9  | 0.085227
1088.269 | -3  1  1  0  0  0 |  8:15 | 0.082873
1200.000 |  1  0  0  0  0  0 |  1:2  | 1.000000