module Sound.MIDI.ControllerPrivate where
import Data.Ix (Ix)
import Sound.MIDI.Utility (checkRange,
enumRandomR, boundedEnumRandom, chooseEnum, )
import Test.QuickCheck (Arbitrary(arbitrary), )
import System.Random (Random(random, randomR), )
newtype Controller = Controller {fromController :: Int} deriving (Show, Eq, Ord, Ix)
toController :: Int -> Controller
toController = checkRange "Controller" Controller
instance Random Controller where
random = boundedEnumRandom
randomR = enumRandomR
instance Arbitrary Controller where
arbitrary = chooseEnum
instance Enum Controller where
toEnum = toController
fromEnum = fromController
instance Bounded Controller where
minBound = Controller 0
maxBound = Controller 119