module Music.Score.Tremolo (
HasTremolo(..),
TremoloT(..),
tremolo,
) where
import Control.Applicative
import Control.Comonad
import Control.Lens hiding (transform)
import Data.Foldable
import Data.Foldable
import Data.Functor.Couple
import Data.Ratio
import Data.Semigroup
import Data.Typeable
import Data.Word
import Music.Dynamics.Literal
import Music.Pitch.Alterable
import Music.Pitch.Augmentable
import Music.Pitch.Literal
import Music.Score.Part
import Music.Score.Phrases
import Music.Time
class HasTremolo a where
setTrem :: Int -> a -> a
instance HasTremolo a => HasTremolo (b, a) where
setTrem n = fmap (setTrem n)
instance HasTremolo a => HasTremolo (Couple b a) where
setTrem n = fmap (setTrem n)
instance HasTremolo a => HasTremolo [a] where
setTrem n = fmap (setTrem n)
instance HasTremolo a => HasTremolo (Score a) where
setTrem n = fmap (setTrem n)
newtype TremoloT a = TremoloT { getTremoloT :: Couple (Max Word) a }
deriving (Eq, Show, Ord, Functor, Foldable, Typeable, Applicative, Monad, Comonad)
instance Wrapped (TremoloT a) where
type Unwrapped (TremoloT a) = Couple (Max Word) a
_Wrapped' = iso getTremoloT TremoloT
instance Rewrapped (TremoloT a) (TremoloT b)
instance HasTremolo (TremoloT a) where
setTrem n = set (_Wrapped . _Wrapped . _1) (Max $ fromIntegral n)
deriving instance Num a => Num (TremoloT a)
deriving instance Fractional a => Fractional (TremoloT a)
deriving instance Floating a => Floating (TremoloT a)
deriving instance Enum a => Enum (TremoloT a)
deriving instance Bounded a => Bounded (TremoloT a)
deriving instance (Num a, Ord a, Real a) => Real (TremoloT a)
deriving instance (Real a, Enum a, Integral a) => Integral (TremoloT a)
tremolo :: HasTremolo a => Int -> a -> a
tremolo = setTrem