Aberrismic theory: Difference between revisions

Inthar (talk | contribs)
Inthar (talk | contribs)
m Code: Optimized the code.
Line 83: Line 83:
stepsOfEdoInCents :: Int -> Int -> Double
stepsOfEdoInCents :: Int -> Int -> Double
stepsOfEdoInCents k edo = 1200*fromIntegral k/fromIntegral edo
stepsOfEdoInCents k edo = 1200*fromIntegral k/fromIntegral edo
-- Generate all possible combinations of sizes of L, M, and s.
generateCombinations :: Int -> [(Int, Int, Int)]
generateCombinations edoBound = [(l, m, s) | l <- [3..edoBound], m <- [2..l-1], s <- [1..m-1]]
-- Filter the combinations based on the step signature and the aberrismic range.
filterCombinations :: Double -> Double -> Int -> Int -> Int -> [(Int, Int, Int)] -> [(Int, (Int, Int, Int))]
filterCombinations aberLower aberUpper countL countM countS combos =
    [(edo, (l, m, s)) | (l, m, s) <- combos,
                        let edo = countL*l + countM*m + countS*s,
                        let aberSize = stepsOfEdoInCents s edo,
                        aberLower <= aberSize && aberSize <= aberUpper]


{- Return a list of (edo, step ratio) tuples for the `(countL)L(countM)M(countS)s` aberrismic scale where `edo <= edoBound`,
{- Return a list of (edo, step ratio) tuples for the `(countL)L(countM)M(countS)s` aberrismic scale where `edo <= edoBound`,
Line 88: Line 100:
   Non-coprime step ratios are reduced. -}
   Non-coprime step ratios are reduced. -}
boundedEdosWithTernaryAberrismicScale :: Int -> Double -> Double -> Int -> Int -> Int -> [(Int, (Int, Int, Int))]
boundedEdosWithTernaryAberrismicScale :: Int -> Double -> Double -> Int -> Int -> Int -> [(Int, (Int, Int, Int))]
boundedEdosWithTernaryAberrismicScale edoBound aberLower aberUpper countL countM countS =  
boundedEdosWithTernaryAberrismicScale edoBound aberLower aberUpper countL countM countS =
  let
     sortBy (\x y -> compare (fst x) (fst y)) -- sort by the edo
    sizesOfS = [1..edoBound] -- smallest s possible in n-edo is 1\n
    $ filter (\x -> fst x <= edoBound) -- filter edos exceeding edoBound
    sizesOfM = [2..edoBound] -- smallest m possible in n-edo is 2\n
    $ filterCombinations aberLower aberUpper countL countM countS
     sizesOfL = [3..edoBound] -- smallest L possible in n-edo is 3\n
    $ generateCombinations edoBound
  in sortBy (\x y -> compare (fst x) (fst y)) -- sort the list, which is finite, by the edo
 
      $ filter (\x -> (fst x) <= edoBound) -- filter edos that exceed `edoBound`
      [ (edo, (x, y, z)) -- divide step sizes by gcd
      | x <- sizesOfL, y <- sizesOfM, z <- sizesOfS,
        let edo = countL*x + countM*y + countS*z,
        let aberSize = stepsOfEdoInCents z edo, -- compute aberrisma size in given tuning
        x > y && y > z && aberLower <= aberSize && aberSize <= aberUpper ]
{-  
{-  
`boundedEdosWithTernaryAberrismicScale 53 20.0 60.0 5 2 3` returns:
`boundedEdosWithTernaryAberrismicScale 53 20.0 60.0 5 2 3` returns:
`[(22,(3,2,1)),(27,(4,2,1)),(29,(4,3,1)),(32,(5,2,1)),(34,(5,3,1)),(36,(5,4,1)),(37,(6,2,1)),(39,(6,3,1)),(41,(6,4,1)),(42,(6,3,2)),(42,(7,2,1)),(43,(6,5,1)),(44,(6,4,2)),(44,(7,3,1)),(46,(6,5,2)),(46,(7,4,1)),(47,(7,3,2)),(47,(8,2,1)),(48,(7,5,1)),(49,(7,4,2)),(49,(8,3,1)),(50,(7,6,1)),(51,(7,5,2)),(51,(8,4,1)),(52,(8,3,2)),(52,(9,2,1)),(53,(7,6,2)),(53,(8,5,1))]`
`[(22,(3,2,1)),(27,(4,2,1)),(29,(4,3,1)),(32,(5,2,1)),(34,(5,3,1)),(36,(5,4,1)),(37,(6,2,1)),(39,(6,3,1)),(41,(6,4,1)),(42,(6,3,2)),(42,(7,2,1)),(43,(6,5,1)),(44,(6,4,2)),(44,(7,3,1)),(46,(6,5,2)),(46,(7,4,1)),(47,(7,3,2)),(47,(8,2,1)),(48,(7,5,1)),(49,(7,4,2)),(49,(8,3,1)),(50,(7,6,1)),(51,(7,5,2)),(51,(8,4,1)),(52,(8,3,2)),(52,(9,2,1)),(53,(7,6,2)),(53,(8,5,1))]`
-}
-}
</syntaxhighlight>
</syntaxhighlight>
[[Category:Terms]]
[[Category:Terms]]
[[Category:Aberrismic theory|*]]<!--Main article-->
[[Category:Aberrismic theory|*]]<!--Main article-->