music-pitch (empty) → 1.2
raw patch · 7 files changed
+236/−0 lines, 7 filesdep +basedep +randomdep +semigroupoidssetup-changed
Dependencies added: base, random, semigroupoids, semigroups, time, unix
Files
- COPYING +26/−0
- Setup.lhs +4/−0
- music-pitch.cabal +33/−0
- src/Music/Pitch.hs +25/−0
- src/Music/Pitch/Absolute.hs +98/−0
- src/Music/Pitch/Intonation.hs +25/−0
- src/Music/Pitch/Relative.hs +25/−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-pitch.cabal view
@@ -0,0 +1,33 @@++name: music-pitch+version: 1.2+cabal-version: >= 1.2+author: Hans Hoglund+maintainer: Hans Hoglund+license: BSD3+license-file: COPYING+synopsis: Abstract representation of musical pitch.+category: Music+tested-with: GHC+build-type: Simple++description: + Abstract representation of musical pitch.+ + 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.Pitch+ Music.Pitch.Absolute+ Music.Pitch.Relative+ Music.Pitch.Intonation
+ src/Music/Pitch.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.Pitch -- (+-- )+where++import Data.Maybe+import Data.Either+import Data.Semigroup+import Control.Monad+import Control.Applicative+
+ src/Music/Pitch/Absolute.hs view
@@ -0,0 +1,98 @@++{-# LANGUAGE+ GeneralizedNewtypeDeriving #-}++-------------------------------------------------------------------------------------+-- |+-- Copyright : (c) Hans Hoglund 2012+--+-- License : BSD-style+--+-- Maintainer : hans@hanshoglund.se+-- Stability : experimental+-- Portability : portable+--+-- Provides overloaded pitch literals.+--+-------------------------------------------------------------------------------------++module Music.Pitch.Absolute -- (+-- )+where++import Data.Maybe+import Data.Either+import Data.Semigroup+import Control.Monad+import Control.Applicative++-- | Frequency in Hertz +newtype Frequency = Frequency { getFrequency :: Double }+ deriving ( Show, Eq, Enum, Num, Ord, Fractional, Floating )+++-- | Logarithmic pitch reprentation.+--+-- > convert (f * 2) = convert f + Octaves 1 +newtype Octaves = Octaves { getOctaves :: Frequency }+ deriving ( Show, Eq, Enum, Num, Ord, Fractional, Floating )++-- | Logarithmic pitch reprentation.+--+-- > convert (f * 2) = convert f + Octave 1 +newtype Fifths = Fifths { getFifths :: Frequency }+ deriving ( Show, Eq, Enum, Num, Ord, Fractional, Floating )++-- | Logarithmic pitch reprentation. +--+-- > convert (f * 2) = convert f + Cent 1200 +newtype Cents = Cents { getCents :: Frequency }+ deriving ( Show, Eq, Enum, Num, Ord, Fractional, Floating )++class HasFrequence a where+ frequency :: a -> Frequency++-- instance Convert Frequency Octave where+-- convert f = Octave (logBase 2 f)+-- reconvert (Octave f) = 2 ** f+-- +-- instance Convert Cent Octave where+-- convert (Cent f) = Octave (f / 1200)+-- reconvert (Octave f) = Cent (f * 1200)+-- +-- instance Convert Frequency Cent where+-- convert f = Cent (logBase 2 f * 1200)+-- reconvert (Cent f) = 2 ** (f / 1200)+-- +-- instance Convert Octave Frequency where+-- convert = reconvert+-- reconvert = convert+-- +-- instance Convert Octave Cent where+-- convert = reconvert+-- reconvert = convert+-- +-- instance Convert Cent Frequency where+-- convert = reconvert+-- reconvert = convert+ ++cents :: HasFrequence a => a -> Cents+cents = undefined ++fifths :: HasFrequence a => a -> Fifths+fifths = undefined ++octaves :: HasFrequence a => a -> Octaves+octaves = undefined ++-- unitFrequency :: Frequency+-- unitFrequency = 1++-- unitOctave :: Octave+-- unitOctave = Octave 0++-- unitCent :: Cent+-- unitCent = Cent 0++
+ src/Music/Pitch/Intonation.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.Pitch.Intonation -- (+-- )+where++import Data.Maybe+import Data.Either+import Data.Semigroup+import Control.Monad+import Control.Applicative+
+ src/Music/Pitch/Relative.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.Pitch.Relative -- (+-- )+where++import Data.Maybe+import Data.Either+import Data.Semigroup+import Control.Monad+import Control.Applicative+