boopadoop- Mathematically sound sound synthesis

Safe HaskellSafe



Tools for creating and manipulation Pitch Factor Diagrams, a tool for representing musical intervals and examining their relations.



semi :: Floating a => a Source #

12 tone equal temperament semitone ratio. Equal to 2 ** (1/12).

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 PitchFactorDiagrams with small factors in them, are generally consonant, and many interesting just intonation intervals can be written this way (see perfectFifth and majorThird).




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.

countPFDFuzzy :: Double -> PitchFactorDiagram Source #

Same as countPFD but makes an effort to simplify the ratio from a Double slightly to the simplest rational number within 0.0001.

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. intervalOf perfectFifth concertA is the just intonation E5.

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.