music-dynamics 1.3.1 → 1.6
raw patch · 7 files changed
+130/−41 lines, 7 filesdep +music-dynamics-literaldep −unix
Dependencies added: music-dynamics-literal
Dependencies removed: unix
Files
- COPYING +2/−2
- music-dynamics.cabal +7/−7
- src/Music/Dynamics.hs +31/−3
- src/Music/Dynamics/Absolute.hs +64/−4
- src/Music/Dynamics/Balance.hs +1/−0
- src/Music/Dynamics/Common.hs +25/−0
- src/Music/Dynamics/Relative.hs +0/−25
COPYING view
@@ -9,14 +9,14 @@ * 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+ * Neither the name of the Music Suite 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+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS 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
music-dynamics.cabal view
@@ -1,6 +1,6 @@ name: music-dynamics-version: 1.3.1+version: 1.6 cabal-version: >= 1.10 author: Hans Hoglund maintainer: Hans Hoglund@@ -14,27 +14,27 @@ description: Abstract representation of musical dynamic levels. - This library is part of the Music Suite, see <http://musicsuite.github.com>.+ This library is part of the Music Suite, see <http://music-suite.github.io>. source-repository head type: git- location: git://github.com/hanshoglund/music-dynamics.git+ location: git://github.com/music-suite/music-dynamics.git library build-depends: - base >= 4 && < 5,- unix,+ base >= 4 && < 5, time, random, semigroups,- semigroupoids+ semigroupoids,+ music-dynamics-literal == 1.6 hs-source-dirs: src default-language: Haskell2010 exposed-modules: Music.Dynamics Music.Dynamics.Absolute- Music.Dynamics.Relative+ Music.Dynamics.Common Music.Dynamics.Balance
src/Music/Dynamics.hs view
@@ -13,13 +13,41 @@ -- ------------------------------------------------------------------------------------- -module Music.Dynamics -- (--- )-where+module Music.Dynamics (+ module Music.Dynamics.Absolute,+ module Music.Dynamics.Common,+ module Music.Dynamics.Balance, + -- * Dynamic literals+ module Music.Dynamics.Literal, + ) where+ import Data.Maybe import Data.Either import Data.Semigroup import Control.Monad import Control.Applicative +import Music.Dynamics.Absolute+import Music.Dynamics.Common+import Music.Dynamics.Balance+import Music.Dynamics.Literal++{-+ ppp -42 -36+ pp -36 -36+ p -30 -24+ mp ? + mf -24 -18+ f -18 -12+ ff -18 -12++ + + + Midi velocities according to Apple:+ 16 32 48 64 80 96 112 127+ ppp pp p mp mf f ff fff++ Nakamura (1987) The communication of dynamics between musicians and listeners through musical performance+-}
src/Music/Dynamics/Absolute.hs view
@@ -1,4 +1,6 @@ +{-# LANGUAGE GeneralizedNewtypeDeriving #-}+ ------------------------------------------------------------------------------------- -- | -- Copyright : (c) Hans Hoglund 2012@@ -9,17 +11,75 @@ -- Stability : experimental -- Portability : portable ----- Provides overloaded pitch literals.+-- Absolute representation of loudness, or dynamics. --+-- The canonical loudness representation is 'Amplitude'. For conversion, see 'HasAmplitude'.+-- ------------------------------------------------------------------------------------- -module Music.Dynamics.Absolute -- (--- )-where+module Music.Dynamics.Absolute (+ Amplitude(..),+ Decibel,+ Bel,+ HasAmplitude(..),+ decibel,+ bel,+) where import Data.Maybe import Data.Either import Data.Semigroup import Control.Monad import Control.Applicative++-- |+-- Amplitude level, where @0@ is silent and @1@ is peak.+--+newtype Amplitude = Amplitude { getAmplitude :: Double }+ deriving (Read, Show, Eq, Enum, Num, Ord, Fractional, Floating, Real, RealFrac)++-- |+-- A logarithmic representation of amplitude such that+--+-- >+-- > x * 10 = amplitude (bel x + 1)+--+newtype Bel = Bel { getBel :: Amplitude }+ deriving (Read, Show, Eq, Enum, Num, Ord, Fractional, Floating, Real, RealFrac)++-- |+-- A logarithmic representation of amplitude such that+--+-- >+-- > x * 10 = amplitude (decibel x + 10)+--+newtype Decibel = Decibel { getDecibel :: Amplitude }+ deriving (Read, Show, Eq, Enum, Num, Ord, Fractional, Floating, Real, RealFrac)++instance Semigroup Amplitude where (<>) = (*)+instance Semigroup Decibel where (<>) = (+)+instance Semigroup Bel where (<>) = (+)++instance Monoid Amplitude where { mempty = 1 ; mappend = (*) }+instance Monoid Decibel where { mempty = 0 ; mappend = (+) }+instance Monoid Bel where { mempty = 0 ; mappend = (+) }++class HasAmplitude a where+ amplitude :: a -> Amplitude++instance HasAmplitude Amplitude where+ amplitude = id++instance HasAmplitude Decibel where+ amplitude (Decibel f) = (10/1) ** (f / 10)++instance HasAmplitude Bel where+ amplitude (Bel f) = (10/1) ** (f / 1)++decibel :: HasAmplitude a => a -> Decibel+decibel a = Decibel $ logBase (10/1) (amplitude a) * 10++bel :: HasAmplitude a => a -> Bel+bel a = Bel $ logBase (10/1) (amplitude a) * 1+
src/Music/Dynamics/Balance.hs view
@@ -23,3 +23,4 @@ import Control.Monad import Control.Applicative +-- http://smac2013.renconmusic.org/midi-calibration/
+ src/Music/Dynamics/Common.hs view
@@ -0,0 +1,25 @@++-------------------------------------------------------------------------------------+-- |+-- Copyright : (c) Hans Hoglund 2012+--+-- License : BSD-style+--+-- Maintainer : hans@hanshoglund.se+-- Stability : experimental+-- Portability : portable+--+-- Provides overloaded pitch literals.+--+-------------------------------------------------------------------------------------++module Music.Dynamics.Common -- (+-- )+where++import Data.Maybe+import Data.Either+import Data.Semigroup+import Control.Monad+import Control.Applicative+
− src/Music/Dynamics/Relative.hs
@@ -1,25 +0,0 @@------------------------------------------------------------------------------------------ |--- Copyright : (c) Hans Hoglund 2012------ License : BSD-style------ Maintainer : hans@hanshoglund.se--- Stability : experimental--- Portability : portable------ Provides overloaded pitch literals.-------------------------------------------------------------------------------------------module Music.Dynamics.Relative -- (--- )-where--import Data.Maybe-import Data.Either-import Data.Semigroup-import Control.Monad-import Control.Applicative-