Skip to content

Commit

Permalink
LilyPitch module
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernardo Barros committed Jan 25, 2024
1 parent 403dba9 commit 43535b4
Show file tree
Hide file tree
Showing 4 changed files with 191 additions and 90 deletions.
3 changes: 2 additions & 1 deletion haskMus.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ build-type: Simple
-- extra-source-files: readme.md
-- changelog.md

tested-with: GHC ==9.4.* || ==9.6.*
tested-with: GHC ==9.4.8 || ==9.6.4

library
hs-source-dirs: src
exposed-modules:
Data.WAVE
Pitch.Accidental
Pitch.LilyPitch
Pitch.Parser
Pitch.Pitch
Pitch.QuasiQuoter
Expand Down
59 changes: 59 additions & 0 deletions src/Pitch/LilyPitch.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -Wno-orphans #-}

module Pitch.LilyPitch where

import qualified Data.Map as Map
import Data.Maybe (fromMaybe)
import Data.String (IsString, fromString)
import Pitch.Pitch

instance IsString Pitch where
fromString :: String -> Pitch
fromString str = fromMaybe (error $ "Invalid pitch: " <> str) (Map.lookup str pitchMap)

$(generatePitchVars (Map.keys pitchMap))

allPitches :: [Pitch]
allPitches =
[ "c",
"cis",
"ces",
"cisis",
"ceses",
"d",
"dis",
"des",
"dih___",
"deh'''",
"d__",
"e",
"ees",
"eis",
"eeh",
"feseh",
"eih",
"f"
]

allPitches2 :: [Pitch]
allPitches2 =
[ c,
cis,
ces,
cisis,
ceses,
d,
dis,
des,
dih___,
deh''',
d__,
e,
ees,
eis,
eeh,
feseh,
eih,
f
]
Loading

0 comments on commit 43535b4

Please sign in to comment.