module Music.Pitch.Common.Harmony (
isDissonance,
isConsonance,
isPerfectConsonance,
isImperfectConsonance,
isMelodicDissonance,
isMelodicConsonance,
) where
import Music.Pitch.Common.Interval
import Music.Pitch.Common.Number
import Music.Pitch.Common.Quality
import Music.Pitch.Literal
import Data.Semigroup
import Data.Set (Set)
import qualified Data.Set as Set
isDissonance :: Interval -> Bool
isDissonance x = case number (simple x) of
2 -> True
7 -> True
_ -> False
isConsonance :: Interval -> Bool
isConsonance x = isPerfectConsonance x || isImperfectConsonance x
isPerfectConsonance :: Interval -> Bool
isPerfectConsonance x = case number (simple x) of
1 -> True
4 -> True
5 -> True
_ -> False
isImperfectConsonance :: Interval -> Bool
isImperfectConsonance x = case number (simple x) of
3 -> True
6 -> True
_ -> False
isMelodicDissonance :: Interval -> Bool
isMelodicDissonance x = not $ isMelodicConsonance x
isMelodicConsonance :: Interval -> Bool
isMelodicConsonance x = quality x `elem` [Perfect, Major, Minor]