packages feed

music-pitch 1.3 → 1.3.1

raw patch · 3 files changed

+34/−25 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Music.Pitch.Relative.Pitch: instance HasOctaves Pitch
- Music.Pitch.Relative.Pitch: instance HasSemitones Pitch
- Music.Pitch.Relative.Pitch: instance HasSteps Pitch

Files

music-pitch.cabal view
@@ -1,7 +1,7 @@  name:               music-pitch-version:            1.3-cabal-version:      >= 1.2+version:            1.3.1+cabal-version:      >= 1.10 author:             Hans Hoglund maintainer:         Hans Hoglund license:            BSD3@@ -14,8 +14,12 @@ description:      Abstract representation of musical pitch.     -    This library is part of the Music Suite        , see <http://musicsuite.github.com>.+    This library is part of the Music Suite, see <http://musicsuite.github.com>. +source-repository head+  type:             git+  location:         git://github.com/hanshoglund/music-pitch.git+   library                         build-depends:          base >= 4 && < 5,@@ -28,6 +32,7 @@         vector-space      hs-source-dirs: src+    default-language: Haskell2010     exposed-modules:         Music.Pitch         Music.Pitch.Absolute
src/Music/Pitch/Relative/Interval.hs view
@@ -87,8 +87,8 @@ -- The scalar type of intervals are 'Integer', using '^*' to stack intervals -- of a certain type on top of each other. For example @_P5 ^* 2@ is a stack -- of 2 perfect fifths. The 'Num' instance works as expected for '+', 'negate'--- and 'abs', and arbitrarily uses octaves for multiplication. If you find--- yourself '*', or 'signum' on intervals, consider switching to '^*' or+-- and 'abs', and arbitrarily uses minor seconds for multiplication. If you+-- find yourself '*', or 'signum' on intervals, consider switching to '*^' or -- 'normalized'. -- -- Intervals are generally described in terms of 'Quality' and 'Number'. To@@ -111,10 +111,10 @@     (+)           = addInterval     negate        = negateInterval     abs a         = if isNegative a then negate a else a-    a * b         = fromIntegral (semitones a `div` 12) `stackInterval` b-    signum a      = if isNegative a then (-_P8) else _P8+    a * b         = fromIntegral (semitones a) `stackInterval` b+    signum a      = if isNegative a then (-m2) else (if isPositive a then m2 else _P1)     fromInteger 0 = _P1-    fromInteger _ = undefined+    fromInteger n = spell sharps (fromIntegral n :: Semitones)  instance Show Interval where     show a | isNegative a = "-" ++ show (quality a) ++ show (abs $ number a)@@ -154,9 +154,6 @@ instance HasSteps Interval where     steps a = fromIntegral $ semitones a `mod` 12 -intervalDiff :: Interval -> Int-intervalDiff (Interval (o, d, c)) = c - diatonicToChromatic d- -- | -- Creates an interval from a quality and number. --@@ -201,8 +198,8 @@ invertChromatic c = 12 - c  negateInterval :: Interval -> Interval-negateInterval (Interval (o, 0, 0))   = Interval (negate o, 0, 0)-negateInterval (Interval (oa, da,ca)) = Interval (negate (oa + 1), invertDiatonic da, invertChromatic ca)+negateInterval (Interval (o, 0, 0))    = Interval (negate o, 0, 0)+negateInterval (Interval (oa, da, ca)) = Interval (negate (oa + 1), invertDiatonic da, invertChromatic ca)  addInterval :: Interval -> Interval -> Interval addInterval (Interval (oa, da,ca)) (Interval (ob, db,cb))@@ -215,6 +212,9 @@ stackInterval :: Integer -> Interval -> Interval stackInterval n a | n >= 0    = mconcat $ replicate (fromIntegral n) a                   | otherwise = negate $ stackInterval (negate n) a++intervalDiff :: Interval -> Int+intervalDiff (Interval (o, d, c)) = c - diatonicToChromatic d  -- | -- Separate a compound interval into octaves and a simple interval.
src/Music/Pitch/Relative/Pitch.hs view
@@ -33,6 +33,10 @@ -- Intervals and pitches can be added using '.+^'. To get the interval between -- two pitches, use '.-.'. --+-- Pitches are normally entered using the following literals.+--+-- > c d e f g a b+-- -- Notes with accidentals can be written by adding the @s@ or @b@ suffices -- (or two for double sharps and flats). --@@ -83,7 +87,7 @@     Pitch a .+^ b       = Pitch (a ^+^ b)  instance Show Pitch where-    show p = show (name p) ++ showAccidental (accidental p) ++ showOctave (octaves p)+    show p = show (name p) ++ showAccidental (accidental p) ++ showOctave (octaves $ getPitch p)         where             showOctave n                 | n > 0     = replicate' n '\''@@ -106,7 +110,7 @@ -- Creates a pitch from name accidental. -- pitch :: Name -> Accidental -> Pitch-pitch = undefined+pitch name acc = Pitch $ interval' (fromIntegral acc) (fromEnum name + 1)  -- | -- Returns the name of a pitch.@@ -124,14 +128,14 @@ accidental :: Pitch -> Accidental accidental = fromIntegral . intervalDiff . simple . getPitch -instance HasOctaves Pitch where-    octaves = octaves . getPitch--instance HasSemitones Pitch where-    semitones = semitones . getPitch--instance HasSteps Pitch where-    steps = steps . getPitch+-- instance HasOctaves Pitch where+--     octaves = octaves . getPitch+-- +-- instance HasSemitones Pitch where+--     semitones = semitones . getPitch+-- +-- instance HasSteps Pitch where+--     steps = steps . getPitch   instance IsPitch Pitch where@@ -143,6 +147,6 @@             qual Nothing  = 0             qual (Just n) = round n -midiNumber :: Pitch -> Integer-midiNumber = fromIntegral . semitones . getPitch+-- midiNumber :: Pitch -> Integer+-- midiNumber = fromIntegral . semitones . getPitch