Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Tools for creating and manipulation Pitch Factor Diagrams, a tool for representing musical intervals and examining their relations.
Synopsis
- semi :: Floating a => a
- allSemis :: Floating a => [a]
- takeFinAlignments :: Floating a => Int -> [[a]]
- newtype PitchFactorDiagram = Factors {
- getFactors :: [Integer]
- diagramToRatio :: Fractional a => PitchFactorDiagram -> a
- diagramToFloatyRatio :: PitchFactorDiagram -> Rational
- diagramToSemi :: Floating a => PitchFactorDiagram -> a
- normalizePFD :: PitchFactorDiagram -> PitchFactorDiagram
- countPFDFuzzy :: Double -> PitchFactorDiagram
- countPFD :: Rational -> PitchFactorDiagram
- intervalOf :: PitchFactorDiagram -> Double -> Double
- scalePFD :: Integer -> PitchFactorDiagram -> PitchFactorDiagram
- invertPFD :: PitchFactorDiagram -> PitchFactorDiagram
- addPFD :: PitchFactorDiagram -> PitchFactorDiagram -> PitchFactorDiagram
- printTheSequence :: Int -> IO ()
Documentation
allSemis :: Floating a => [a] Source #
12 tone equal temperament ratios for all semitones in an octave.
takeFinAlignments :: Floating a => Int -> [[a]] Source #
List multiples of the single octave semitone ratios upto a certain amount.
newtype PitchFactorDiagram Source #
A pitch factor diagram is a list of prime exponents that represents a rational number
via diagramToRatio
. These are useful because pitches with few prime factors, that is,
small PitchFactorDiagram
s with small factors in them, are generally consonant, and
many interesting just intonation intervals can be written this way (see perfectFifth
and majorThird
).
Factors | |
|
Instances
Show PitchFactorDiagram Source # | |
Defined in Boopadoop.Diagram showsPrec :: Int -> PitchFactorDiagram -> ShowS # show :: PitchFactorDiagram -> String # showList :: [PitchFactorDiagram] -> ShowS # | |
Semigroup PitchFactorDiagram Source # |
|
Defined in Boopadoop.Diagram (<>) :: PitchFactorDiagram -> PitchFactorDiagram -> PitchFactorDiagram # sconcat :: NonEmpty PitchFactorDiagram -> PitchFactorDiagram # stimes :: Integral b => b -> PitchFactorDiagram -> PitchFactorDiagram # | |
Monoid PitchFactorDiagram Source # |
|
Defined in Boopadoop.Diagram |
diagramToRatio :: Fractional a => PitchFactorDiagram -> a Source #
Convert a factor diagram to the underlying ratio by raising each prime (starting from two) to the power in the factor list. For instance, going up two perfect fifths and down three major thirds yields:
diagramToRatio (Factors [4,2,-3]) = (2 ^^ 4) * (3 ^^ 2) * (5 ^^ (-3)) = 144/125
diagramToFloatyRatio :: PitchFactorDiagram -> Rational Source #
Similar to diagramToRatio
, but simplifies the resulting ratio to the simplest ratio within 0.05
.
diagramToSemi :: Floating a => PitchFactorDiagram -> a Source #
Convert a PFD to its decimal number of semitones. Useful for approximating weird ratios in a twelvetone scale:
diagramToSemi (normalizePFD $ Factors [0,0,0,1]) = diagramToSemi (countPFD (7/4)) = 9.688259064691248
normalizePFD :: PitchFactorDiagram -> PitchFactorDiagram Source #
Normalize a PFD by raising or lowering it by octaves until its ratio lies between 1
(unison) and 2
(one octave up).
This operation is idempotent.
countPFD :: Rational -> PitchFactorDiagram Source #
Calculates the PitchFactorDiagram
corresponding to a given frequency ratio by finding prime factors of the numerator and denominator.
intervalOf :: PitchFactorDiagram -> Double -> Double Source #
Converts a PFD into an operation on frequencies.
is the just intonation E5.intervalOf
perfectFifth
concertA
scalePFD :: Integer -> PitchFactorDiagram -> PitchFactorDiagram Source #
Scale a PFD by raising the underlying ratio to the given power. scalePFD
2 perfectFifth
= addPFD
octave
majorSecond
addPFD :: PitchFactorDiagram -> PitchFactorDiagram -> PitchFactorDiagram Source #
Adds two PFDs together by multiplying their ratios. addPFD
minorThird majorThird
= perfectFifth
printTheSequence :: Int -> IO () Source #
Prints the natural numbers from the given value up to 128
, highlighting primes and powers of two.
Interesting musical intervals are build out of the relative distance of a prime between the two
nearest powers of two.