music-dynamics-literal (empty) → 1.2
raw patch · 4 files changed
+134/−0 lines, 4 filesdep +basedep +randomdep +semigroupoidssetup-changed
Dependencies added: base, random, semigroupoids, semigroups, time, unix
Files
- COPYING +26/−0
- Setup.lhs +4/−0
- music-dynamics-literal.cabal +31/−0
- src/Music/Dynamics/Literal.hs +73/−0
+ COPYING view
@@ -0,0 +1,26 @@++Copyright (c) 2013, Hans Höglund+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:+ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.+ * Redistributions in binary form must reproduce the above copyright+ notice, this list of conditions and the following disclaimer in the+ documentation and/or other materials provided with the distribution.+ * Neither the name of the <organization> nor the+ names of its contributors may be used to endorse or promote products+ derived from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.+
+ Setup.lhs view
@@ -0,0 +1,4 @@+#! /usr/bin/env runhaskell++> import Distribution.Simple+> main = defaultMain
+ music-dynamics-literal.cabal view
@@ -0,0 +1,31 @@++name: music-dynamics-literal+version: 1.2+cabal-version: >= 1.3+author: Hans Hoglund+maintainer: Hans Hoglund+license: BSD3+license-file: COPYING+synopsis: Overloaded dynamics literals.+category: Music+tested-with: GHC+build-type: Simple++description: + This package allow you to write the dynamic marks of standard notation as expressions+ overloaded on result type. This works exactly like numeric literals.++ This library is part of the Haskell Music Suite, see <http://musicsuite.github.com>.++library + build-depends: + base >= 4 && < 5,+ unix,+ time,+ random,+ semigroups,+ semigroupoids++ hs-source-dirs: src+ exposed-modules:+ Music.Dynamics.Literal
+ src/Music/Dynamics/Literal.hs view
@@ -0,0 +1,73 @@++-------------------------------------------------------------------------------------+-- |+-- Copyright : (c) Hans Hoglund 2012+--+-- License : BSD-style+--+-- Maintainer : hans@hanshoglund.se+-- Stability : experimental+-- Portability : portable+--+-- Provides overloaded pitch literals.+--+-------------------------------------------------------------------------------------++module Music.Dynamics.Literal (+ DynamicsL(..),+ IsDynamics(..),++ pppppp, ppppp, pppp, ppp, pp, _p, + mp, mf, + _f, ff, fff, ffff, fffff, ffffff,+ + sffz, sfz, fz, rfz, fp+ ) where++-- | +-- Dynamics literal.+--+-- First value is start value, second is end value.+-- +-- * @(Just x, Nothing)@ is a constant dynamic of @x@+-- * @(Just x, Just y)@ is a dynamic varying from @x@ to @y@+-- * @(Nothing, Just y)@ is a dynamic varying from the previous level to @y@+-- * @(Nothing, Nothing)@ is a dynamic varying from the previous level to the next.+--+-- For levels, we use @-0.5@ for /mp/, @0.5@ for /mf/ and add or remove one for each level.+-- @0@ is an unspecified middle level dynamic.+--+newtype DynamicsL = DynamicsL { getDynamicsL :: (Maybe Double, Maybe Double) }++-- Like Num can be expressed using arabic numerals, instances+-- of IsDynamics can be expressed using Western pitch names (c, c sharp, c flat etc) +class IsDynamics a where+ fromDynamics :: DynamicsL -> a++instance IsDynamics DynamicsL where+ fromDynamics = id+++pppppp, ppppp, pppp, ppp, pp, _p, mp, mf, _f, ff, fff, ffff, fffff, ffffff :: IsDynamics a => a+sffz, sfz, fz, rfz, fp :: IsDynamics a => a++pppppp = fromDynamics $ DynamicsL (Just $ -6.5, Nothing)+ppppp = fromDynamics $ DynamicsL (Just $ -5.5, Nothing)+pppp = fromDynamics $ DynamicsL (Just $ -4.5, Nothing)+ppp = fromDynamics $ DynamicsL (Just $ -3.5, Nothing)+pp = fromDynamics $ DynamicsL (Just $ -2.5, Nothing)+_p = fromDynamics $ DynamicsL (Just $ -1.5, Nothing)+mp = fromDynamics $ DynamicsL (Just $ -0.5, Nothing)+mf = fromDynamics $ DynamicsL (Just $ 0.5, Nothing)+_f = fromDynamics $ DynamicsL (Just $ 1.5, Nothing)+ff = fromDynamics $ DynamicsL (Just $ 2.5, Nothing)+fff = fromDynamics $ DynamicsL (Just $ 3.5, Nothing)+ffff = fromDynamics $ DynamicsL (Just $ 4.5, Nothing)+fffff = fromDynamics $ DynamicsL (Just $ 5.5, Nothing)+ffffff = fromDynamics $ DynamicsL (Just $ 6.5, Nothing)++sffz = error "Not supported yet"+sfz = error "Not supported yet"+fz = error "Not supported yet"+rfz = error "Not supported yet"+fp = error "Not supported yet"