midi 0.0.5 → 0.0.6
raw patch · 3 files changed
+41/−11 lines, 3 filesdep ~QuickCheckdep ~event-listdep ~mtl
Dependency ranges changed: QuickCheck, event-list, mtl, non-negative
Files
- midi.cabal +8/−5
- src/Sound/MIDI/General.hs +18/−6
- src/Sound/MIDI/Utility.hs +15/−0
midi.cabal view
@@ -1,10 +1,11 @@ Name: midi-Version: 0.0.5+Version: 0.0.6 License: GPL License-File: LICENSE Author: Henning Thielemann <haskell@henning-thielemann.de> Maintainer: Henning Thielemann <haskell@henning-thielemann.de>-Homepage: http://darcs.haskell.org/midi/+Homepage: http://www.haskell.org/haskellwiki/MIDI+Package-URL: http://darcs.haskell.org/midi/ Category: Sound Build-Type: Simple Synopsis: Handling of MIDI messages and files@@ -14,7 +15,7 @@ reading and writing MIDI files. It contains no sending and receiving of MIDI messages. Cf. alsa-midi package. For music composition with MIDI output, see Haskore.-Tested-With: GHC==6.4.1+Tested-With: GHC==6.4.1 && ==6.8.2 Cabal-Version: >=1.2 Build-Type: Simple @@ -22,10 +23,12 @@ description: Choose the new smaller, split-up base package. Library+ Build-Depends: event-list >=0.0.6 && < 0.1, non-negative>=0.0.1 && <0.1+ Build-Depends: mtl >=1 && <2, QuickCheck >=1 && <2 If flag(splitBase)- Build-Depends: base >= 2, event-list==0.0.6, non-negative==0.0.1, mtl, QuickCheck, random+ Build-Depends: base >= 2, random Else- Build-Depends: base >= 1.0 && < 2, event-list==0.0.6, non-negative==0.0.1, mtl, QuickCheck+ Build-Depends: base >= 1.0 && < 2 -- Instead of the full-blown Monad Template Library with multi-parameter type classes with functional dependencies -- we also be happy with the less expensive -- http://darcs.haskell.org/packages/mtl-split/Control/Monad/Trans/State.hs
src/Sound/MIDI/General.hs view
@@ -9,6 +9,9 @@ import qualified Sound.MIDI.Event as MidiEvent import Data.Ix(Ix) import qualified Data.List as List++import Sound.MIDI.Utility (mapFst, mapSnd, )+import Test.QuickCheck (Gen, Arbitrary(..), choose, ) import System.Random (Random(random,randomR), RandomGen) @@ -173,8 +176,12 @@ random = boundedEnumRandom randomR = enumRandomR +instance Arbitrary Instrument where+ arbitrary = chooseEnum+ coarbitrary = error "GeneralMIDI.Instrument.coarbitrary not implemented" + {- * Drum definitions -} @@ -218,13 +225,21 @@ | OpenTriangle -- Midi Key 82 deriving (Show, Eq, Ord, Ix, Enum, Bounded) +-- http://oxygen.cside6.com/gallery/ins_gm.html+ instance Random Drum where random = boundedEnumRandom randomR = enumRandomR --- http://oxygen.cside6.com/gallery/ins_gm.html+instance Arbitrary Drum where+ arbitrary = chooseEnum+ coarbitrary = error "GeneralMIDI.Drum.coarbitrary not implemented" +++-- auxiliary functions+ enumRandomR :: (Enum a, RandomGen g) => (a,a) -> g -> (a,g) enumRandomR (l,r) = mapFst toEnum . randomR (fromEnum l, fromEnum r)@@ -232,8 +247,5 @@ boundedEnumRandom :: (Enum a, Bounded a, RandomGen g) => g -> (a,g) boundedEnumRandom = enumRandomR (minBound, maxBound) -mapFst :: (a -> c) -> (a,b) -> (c,b)-mapFst f ~(x,y) = (f x, y)--mapSnd :: (b -> d) -> (a,b) -> (a,d)-mapSnd g ~(x,y) = (x, g y)+chooseEnum :: (Enum a, Bounded a, Random a) => Gen a+chooseEnum = choose (minBound, maxBound)
src/Sound/MIDI/Utility.hs view
@@ -1,17 +1,32 @@ module Sound.MIDI.Utility where ++{-# INLINE mapFst #-}+mapFst :: (a -> c) -> (a,b) -> (c,b)+mapFst f ~(x,y) = (f x, y)++{-# INLINE mapSnd #-}+mapSnd :: (b -> d) -> (a,b) -> (a,d)+mapSnd g ~(x,y) = (x, g y)+++{-# INLINE fst3 #-} fst3 :: (a,b,c) -> a fst3 (x,_,_) = x +{-# INLINE snd3 #-} snd3 :: (a,b,c) -> b snd3 (_,x,_) = x +{-# INLINE thd3 #-} thd3 :: (a,b,c) -> c thd3 (_,_,x) = x +{-# INLINE toMaybe #-} toMaybe :: Bool -> a -> Maybe a toMaybe False _ = Nothing toMaybe True x = Just x +{-# INLINE swap #-} swap :: (a,b) -> (b,a) swap (a,b) = (b,a)