gdritter repos hypsibius / eaaec43
Switched data format to Adnot Getty Ritter 7 years ago
7 changed file(s) with 89 addition(s) and 76 deletion(s). Collapse all Expand all
1 ;; this is a basic twelve-tone scale
2 (hypsibius-scale
3 :name "twelve-tone equal temperament"
4 :size 1200
5 (note "A" 0)
6 (note "A♯" 100 :color black)
7 (note "B" 200)
8 (note "C" 300)
9 (note "C♯" 400 :color black)
10 (note "D" 500)
11 (note "D♯" 600 :color black)
12 (note "E" 700)
13 (note "F" 800)
14 (note "F♯" 900 :color black)
15 (note "G" 1000)
16 (note "G♯" 1100 :color black))
1 # this is a basic twelve-tone scale
2 { name "twelve-tone equal temperament"
3 size 1200
4 notes [
5 (note "A" 0)
6 (note "A♯" 100 black)
7 (note "B" 200)
8 (note "C" 300)
9 (note "C♯" 400 black)
10 (note "D" 500)
11 (note "D♯" 600 black)
12 (note "E" 700)
13 (note "F" 800)
14 (note "F♯" 900 black)
15 (note "G" 1000)
16 (note "G♯" 1100 black)
17 ]
18 }
1 hypsibius scale
21 # nineteen-tone equal temperament
3
4 0 A
5 63 A♯
6 126 B♭
7 189 B
8 253 B♯
9 316 C
10 379 C♯
11 442 D♭
12 505 D
13 568 D♯
14 632 E♭
15 695 E
16 758 E♯
17 821 F
18 884 F♯
19 947 G♭
20 1011 G
21 1074 G♯
22 1137 A♭
2 { name "nineteen-tone equal temperament"
3 size 1200
4 notes [
5 (note "A" 0)
6 (note "A♯" 63)
7 (note "B♭" 126)
8 (note "B" 189)
9 (note "B♯" 253)
10 (note "C" 316)
11 (note "C♯" 379)
12 (note "D♭" 442)
13 (note "D" 505)
14 (note "D♯" 568)
15 (note "E♭" 632)
16 (note "E" 695)
17 (note "E♯" 758)
18 (note "F" 821)
19 (note "F♯" 884)
20 (note "G♭" 947)
21 (note "G" 1011)
22 (note "G♯" 1074)
23 (note "A♭" 1137)
24 ]
25 }
1 hypsibius scale
21 # the twelve-tone scale in just intonation
3
4 0.00 C
5 111.72 C♯
6 203.91 D
7 315.64 D♯
8 386.31 E
9 498.04 F
10 582.51 F♯
11 701.96 G
12 813.69 G♯
13 884.36 A
14 996.09 A♯
15 1088.27 B
2 { name "twelve-tone just intonation"
3 size 1200
4 notes [
5 (note "A" 0)
6 (note "A♯" 111.72 black)
7 (note "B" 203.91)
8 (note "C" 315.64)
9 (note "C♯" 386.31 black)
10 (note "D" 498.04)
11 (note "D♯" 582.51 black)
12 (note "E" 701.96)
13 (note "F" 813.69)
14 (note "F♯" 884.36 black)
15 (note "G" 996.09)
16 (note "G♯" 1088.27 black)
17 ]
18 }
2828 , lens-family-core
2929 , lens-family-th
3030 , text
31 , bytestring
3132 , containers
3233 , vty
3334 , data-default
34 , s-cargot
35 , adnot
3536 default-language: Haskell2010
11 {-# LANGUAGE TemplateHaskell #-}
2 {-# LANGUAGE OverloadedLists #-}
3 {-# LANGUAGE GADTs #-}
24
35 module Hypsibius.Data where
46
7 import Data.Adnot
58 import Data.Sequence (Seq)
69 import Data.Text (Text)
710 import Data.Word (Word8)
3942 data Note = Note
4043 { _noteCents :: Double
4144 , _noteAppearance :: Text
45 , _noteColor :: Maybe Text
4246 } deriving (Eq, Show)
47
48 instance FromAdnot Note where
49 parseAdnot = withSum "Note" go
50 where go "note" [name, cents] =
51 Note <$> parseAdnot cents <*> parseAdnot name <*> pure Nothing
52 go "note" [name, cents, color] =
53 Note <$> parseAdnot cents
54 <*> parseAdnot name
55 <*> (Just <$> parseAdnot color)
56 go "note" _ = fail "Unknown argument structure"
57 go c _ = fail ("Expected note, got " ++ show c)
4358
4459 $(makeLenses ''Note)
4560
5772 , _scaleTotalCents :: Double
5873 , _scaleNotes :: Seq Note
5974 } deriving (Eq, Show)
75
76 instance FromAdnot Scale where
77 parseAdnot = withProduct "Scale" $ \o ->
78 Scale <$> o .: "name"
79 <*> o .: "size"
80 <*> o .: "notes"
6081
6182 $(makeLenses ''Scale)
6283
91112 } deriving (Eq, Show)
92113
93114
94
95115 data Song = Song
96116 { _songScale :: Scale
97117 , _songTracks :: Seq Track
11 {-# LANGUAGE ViewPatterns #-}
22
3 module Hypsibius.Formats.Scale (parse) where
3 module Hypsibius.Formats.Scale where
44
5 import Data.SCargot
6 import Data.SCargot.Repr.Basic
5 import Data.Adnot
76 import Data.Sequence (Seq)
87 import qualified Data.Sequence as S
9 import Data.Text (Text)
10 -- import qualified Data.Text as T
118
129 import Hypsibius.Data (Note(..), Scale(..))
13
14 data Atom
15 = AIdent Text
16 | AString Text
17 | AInt Integer
18 | AFloat Double
19 | AKWord Text
20 deriving (Eq, Show)
21
22 parseScale :: Text -> Either String Scale
23 parseScale = undefined
24
25 parse = undefined
2610
2711 {-
2812
11 module Hypsibius.Formats where
22
3 import Data.Adnot
34 import Data.Sequence (Seq)
4 import qualified Data.Text.IO as T
5 import qualified Data.ByteString as BS
56
6 import qualified Hypsibius.Formats.Scale as Scale
7 import Hypsibius.Data (Note)
7 import Hypsibius.Data
88
9 readScale :: FilePath -> IO (Either String (Seq Note))
10 readScale = fmap Scale.parse . T.readFile
9 readScale :: FilePath -> IO (Either String Scale)
10 readScale = fmap decode . BS.readFile