Skip to content
This repository has been archived by the owner on Apr 29, 2020. It is now read-only.

Relax version bounds and remove non-breaking whitespace to build with nix #58

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
dist
dist-newstyle
.DS_Store
*.ly
*.pdf
.shelly
.hackette
.ackoptions
*sandbox.config
.stack-work/
.cabal.project.local
.cabal.project.local~
.envrc
.direnv
Empty file modified Setup.lhs
100755 → 100644
Empty file.
4 changes: 2 additions & 2 deletions music-pitch.cabal
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ library
containers,
lens >= 4.11 && < 5,
semigroups >= 0.13.0.1 && < 1,
data-interval >= 1.0.0 && < 2,
data-interval >= 1.0.0 && < 3,
vector-space >= 0.10.2 && < 1,
vector-space-points >= 0.2 && < 1,
nats,
positive >= 0.4 && < 1,
type-unary >= 0.2.16 && < 1.0,
aeson >= 0.7.0.6 && < 1
aeson >= 0.7.0.6 && < 2
exposed-modules: Music.Pitch
Music.Pitch.Absolute
Music.Pitch.Equal
Expand Down
2 changes: 1 addition & 1 deletion sketch/synopsis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ data Mode a = Mode [Diff a] (Diff a) -- intervals, repeat (usuall
data Scale a = Scale a (Mode a) -- root, mode
data Function a = Function [Diff a] (Diff a) -- intervals, repeat, repeat (usually octave)
data Chord a = Chord a (Function a) -- root, function
data Ambitus a = Ambitus a a | Ambitus a (Diff a) | Ambitus (Diff a) a
data Ambitus a = Ambitus a a | Ambitus a (Diff a) | Ambitus (Diff a) a

newtype ChromaticSteps = ChromaticSteps { getChromaticSteps :: Integer }
newtype DiatonicSteps = DiatonicSteps { getDiatonicSteps :: Integer }
Expand Down
2 changes: 1 addition & 1 deletion src/Music/Pitch.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

-- | Standard pitch representation.
-- | Standard pitch representation.
module Music.Pitch (
module Data.Semigroup,
module Data.VectorSpace,
Expand Down
6 changes: 3 additions & 3 deletions src/Music/Pitch/Absolute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ instance HasFrequency Fifths where
instance HasFrequency Cents where
frequency (Cents f) = (2/1) ** (f / 1200)

-- | Convert a frequency to octaves.
-- | Convert a frequency to octaves.
octaves :: HasFrequency a => a -> Octaves
octaves a = Octaves $ logBase (2/1) (frequency a)

-- | Convert a frequency to fifths.
-- | Convert a frequency to fifths.
fifths :: HasFrequency a => a -> Fifths
fifths a = Fifths $ logBase (3/2) (frequency a)

-- | Convert a frequency to cents.
-- | Convert a frequency to cents.
cents :: HasFrequency a => a -> Cents
cents a = Cents $ logBase (2/1) (frequency a) * 1200

4 changes: 2 additions & 2 deletions src/Music/Pitch/Ambitus.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ ambitus = iso toA unA . _Unwrapped
unA a = case (I.lowerBound a, I.upperBound a) of
(Finite m, Finite n) -> (m, n)
-- FIXME this can happen as empty span can be represented as PosInf..NegInf
-- _ -> error $ "Strange ambitus: " ++ show (I.lowerBound a, I.upperBound a)
_ -> error $ "Strange ambitus"
-- _ -> error $ "Strange ambitus: " ++ show (I.lowerBound a, I.upperBound a)
_ -> error $ "Strange ambitus"

-- ambitus' :: (Num a, Ord a) => Iso' (a, a) (Ambitus a)
-- ambitus' = ambitus
Expand Down
32 changes: 16 additions & 16 deletions src/Music/Pitch/Clef.hs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ instance Show Clef where
| x == altoClef = "altoClef"
| x == tenorClef = "tenorClef"
| x == baritoneClef = "baritoneClef"
| otherwise = show a
| otherwise = show a

-- | Return the English name of the given clef.
symbolName :: ClefSymbol -> String
Expand All @@ -77,7 +77,7 @@ symbolName FClef = "F clef"
symbolName PercClef = "Percussion clef"
symbolName NeutralClef = "Neutral clef"

-- | Return the pitch implied by the given clef at the middle space or line.
-- | Return the pitch implied by the given clef at the middle space or line.
symbolPitch :: ClefSymbol -> Maybe Pitch
symbolPitch GClef = Just b'
symbolPitch CClef = Just c
Expand Down Expand Up @@ -118,17 +118,17 @@ Map this to Pitch.Common

-- | Standard treble clef.
trebleClef :: Clef
-- | Standard bass clef.
-- | Standard bass clef.
bassClef :: Clef
-- | Standard soprano clef.
-- | Standard soprano clef.
sopranoClef :: Clef
-- | Standard mezzo soprano clef.
-- | Standard mezzo soprano clef.
mezzoSopranoClef :: Clef
-- | Standard alto clef.
-- | Standard alto clef.
altoClef :: Clef
-- | Standard tenor clef.
-- | Standard tenor clef.
tenorClef :: Clef
-- | Standard baritone clef.
-- | Standard baritone clef.
baritoneClef :: Clef
trebleClef = Clef (GClef, -1 :: ClefOctave, -1 :: ClefLine)
bassClef = Clef (FClef, 1 :: ClefOctave, -1 :: ClefLine)
Expand All @@ -140,20 +140,20 @@ baritoneClef = Clef (CClef, 0 :: ClefOctave, 2 :: ClefLine)

-- | Is this a clef used in contemporary notation?
isModernClef :: Clef -> Bool
isModernClef x | x == trebleClef = True
isModernClef x | x == bassClef = True
isModernClef x | x == altoClef = True
isModernClef x | x == tenorClef = True
isModernClef x | otherwise = False
isModernClef x | x == trebleClef = True
isModernClef x | x == bassClef = True
isModernClef x | x == altoClef = True
isModernClef x | x == tenorClef = True
isModernClef x | otherwise = False

-- | Is this an historical clef?
isHistoricalClef :: Clef -> Bool
isHistoricalClef _ = False

-- | Is this a traditional voice clef, i.e. a C clef on some staff.
isVoiceClef :: Clef -> Bool
isVoiceClef x | x == altoClef = True
isVoiceClef x | x == tenorClef = True
isVoiceClef x | otherwise = False
isVoiceClef x | x == altoClef = True
isVoiceClef x | x == tenorClef = True
isVoiceClef x | otherwise = False


2 changes: 1 addition & 1 deletion src/Music/Pitch/Common/Harmony.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import qualified Data.Set as Set
{-
TODO
Generalize simple like this:
> (number (asInterval (m9))-(fromIntegral $ signum (m9))) `mod` 7
> (number (asInterval (m9))-(fromIntegral $ signum (m9))) `mod` 7

-}

Expand Down
2 changes: 1 addition & 1 deletion src/Music/Pitch/Common/Interval.hs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ instance FromJSON ChromaticSteps where
parseJSON = fmap fromInteger . parseJSON

instance ToJSON Interval where
toJSON i = Data.Aeson.object [("steps", toJSON $ i^._steps), ("alteration", toJSON $ i^._alteration)]
toJSON i = Data.Aeson.object [("steps", toJSON $ i^._steps), ("alteration", toJSON $ i^._alteration)]

instance FromJSON Interval where
parseJSON (Data.Aeson.Object x) = liftA2 (curry (^.interval')) alteration steps
Expand Down
4 changes: 2 additions & 2 deletions src/Music/Pitch/Common/Names.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ showKey :: Language -> Pitch -> Mode -> String
showKey lang pitch mode = showPitch lang pitch ++ showSep lang ++ showMode lang mode

showPitch :: Language -> Pitch -> String
showPitch lang pitch = (!! (pitchToIndex + pitchNameOffset)) $ fromMaybe (error "showPitch: Bad lang") $ listToMaybe $ filter (\xs -> head xs == show lang) $ pitchNames
showPitch lang pitch = (!! (pitchToIndex + pitchNameOffset)) $ fromMaybe (error "showPitch: Bad lang") $ listToMaybe $ filter (\xs -> head xs == show lang) $ pitchNames
where
-- TODO normalize dbb etc.
pitchToIndex = fromMaybe (error "showPitch: Bad pitch") $ Data.List.findIndex (== pitch)
Expand All @@ -56,7 +56,7 @@ showPitch lang pitch = (!! (pitchToIndex + pitchNameOffset)) $ fromMaybe (error
pitchNameOffset = 3

showMode :: Language -> Mode -> String
showMode lang mode = (!! (modeToIndex + modeNameOffset)) $ fromMaybe (error "showMode: Bad lang") $ listToMaybe $ filter (\xs -> head xs == show lang) $ modeNames
showMode lang mode = (!! (modeToIndex + modeNameOffset)) $ fromMaybe (error "showMode: Bad lang") $ listToMaybe $ filter (\xs -> head xs == show lang) $ modeNames
where
modeToIndex = fromMaybe (error "showPitch: Bad mode") $ Data.List.findIndex (== mode)
[MajorMode,MinorMode]
Expand Down
2 changes: 1 addition & 1 deletion src/Music/Pitch/Common/Number.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

-- | Number component of intervals.
-- | Number component of intervals.
module Music.Pitch.Common.Number
(
Number,
Expand Down
4 changes: 2 additions & 2 deletions src/Music/Pitch/Common/Quality.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ invertQuality = go
go (Diminished n) = Augmented n


-- | 
-- |
-- The quality type expected for a given number, i.e. perfect for unisons, fourths,
-- fifths and their compounds; major/minor for everything else.
expectedQualityType :: Number -> QualityType
Expand All @@ -127,7 +127,7 @@ qualityTypes _ = [PerfectType, MajorMinorType]
isValidQualityNumber :: Quality -> Number -> Bool
isValidQualityNumber q n = expectedQualityType n `elem` qualityTypes q

data Direction = Upward | Downward
data Direction = Upward | Downward
deriving (Eq, Ord, Show)

-- |
Expand Down
6 changes: 3 additions & 3 deletions src/Music/Pitch/Common/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ Alternatively, we could do it as a recursive type

data Quality
= Major
| Minor
| Perfect
| Minor
| Perfect
| Augment Quality
| Diminish Quality
| Diminish Quality
-}

{-|
Expand Down
8 changes: 4 additions & 4 deletions src/Music/Pitch/Equal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import TypeUnary.Nat

-- Based on Data.Fixed

newtype Equal a = Equal { getEqual :: Int }
newtype Equal a = Equal { getEqual :: Int }

deriving instance Eq (Equal a)
deriving instance Ord (Equal a)
Expand Down Expand Up @@ -104,11 +104,11 @@ size = natToZ . getSize
-- This type implements limited values (useful for interval *steps*)
-- An ET-interval is just an int, with a type-level size (divMod is "separate")

-- -- | Create an equal-temperament value.
-- -- | Create an equal-temperament value.
-- toEqual :: IsNat a => Int -> Maybe (Equal a)
-- toEqual = checkSize . Equal
--
-- -- | Unsafely create an equal-temperament value.
-- -- | Unsafely create an equal-temperament value.
-- unsafeToEqual :: IsNat a => Int -> Equal a
-- unsafeToEqual n = case toEqual n of
-- Nothing -> error $ "Bad equal: " ++ show n
Expand All @@ -118,7 +118,7 @@ size = natToZ . getSize
-- checkSize x = if 0 <= fromEqual x && fromEqual x < size x then Just x else Nothing
--

-- | Create an equal-temperament value.
-- | Create an equal-temperament value.
toEqual :: IsNat a => Int -> Equal a
toEqual = Equal

Expand Down
2 changes: 1 addition & 1 deletion src/Music/Pitch/Intonation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ thirtyOneToneEqual = tetTune dddd3 where dddd3 = m3 ^-^ (4 *^ _A1)
fiftyThreeToneEqual :: Tuning Interval
fiftyThreeToneEqual = tetTune ddddddd6 where ddddddd6 = 31 *^ _P8 ^-^ 53 *^ _P5 -- (!)

-- | Modern standard intonation, i.e. 12-TET with @a = 440 Hz@.
-- | Modern standard intonation, i.e. 12-TET with @a = 440 Hz@.
standardIntonation :: Intonation Pitch
standardIntonation = intone (a, 440) twelveToneEqual

Expand Down
12 changes: 6 additions & 6 deletions src/Music/Pitch/Scale.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ import Music.Pitch.Literal
import Music.Pitch.Common hiding (Mode)


-- | A mode is a list of intervals and a characteristic repeating interval.
-- | A mode is a list of intervals and a characteristic repeating interval.
data Mode a = Mode [Diff a] (Diff a) -- intervals, repeat (usually octave)

-- |
Expand All @@ -98,7 +98,7 @@ modeIntervals f (Mode is r) = fmap (\is -> Mode is r) $ f is
modeRepeat :: Lens' (Mode a) (Diff a)
modeRepeat f (Mode is r) = fmap (\r -> Mode is r) $ f r

-- | A scale is a mode with a specified tonic.
-- | A scale is a mode with a specified tonic.
data Scale a = Scale a (Mode a) -- root, mode

modeToScale :: AffineSpace a => a -> Mode a -> Scale a
Expand All @@ -107,12 +107,12 @@ modeToScale = Scale
-- |
-- > Lens' (Scale Pitch) Pitch
scaleTonic :: Lens' (Scale a) a
scaleTonic f (Scale t xs) = fmap (\t -> Scale t xs) $ f t
scaleTonic f (Scale t xs) = fmap (\t -> Scale t xs) $ f t

-- |
-- > Lens' (Scale Pitch) (Mode Pitch)
scaleMode :: Lens' (Scale a) (Mode a)
scaleMode f (Scale t xs) = fmap (\xs -> Scale t xs) $ f xs
scaleMode f (Scale t xs) = fmap (\xs -> Scale t xs) $ f xs

-- |
--
Expand Down Expand Up @@ -168,12 +168,12 @@ functionToChord = Chord
-- |
-- > Lens' (Chord Pitch) Pitch
chordTonic :: Lens' (Chord a) a
chordTonic f (Chord t xs) = fmap (\t -> Chord t xs) $ f t
chordTonic f (Chord t xs) = fmap (\t -> Chord t xs) $ f t

-- |
-- > Lens' (Chord Pitch) (Function Pitch)
chordFunction :: Lens' (Chord a) (Function a)
chordFunction f (Chord t xs) = fmap (\xs -> Chord t xs) $ f xs
chordFunction f (Chord t xs) = fmap (\xs -> Chord t xs) $ f xs

-- |
--
Expand Down