Switched data format to Adnot
Getty Ritter
7 years ago
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
|
2 | 1 |
# 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
|
2 | 1 |
# 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 |
}
|
28 | 28 |
, lens-family-core
|
29 | 29 |
, lens-family-th
|
30 | 30 |
, text
|
| 31 |
, bytestring
|
31 | 32 |
, containers
|
32 | 33 |
, vty
|
33 | 34 |
, data-default
|
34 | |
, s-cargot
|
| 35 |
, adnot
|
35 | 36 |
default-language: Haskell2010
|
1 | 1 |
{-# LANGUAGE TemplateHaskell #-}
|
| 2 |
{-# LANGUAGE OverloadedLists #-}
|
| 3 |
{-# LANGUAGE GADTs #-}
|
2 | 4 |
|
3 | 5 |
module Hypsibius.Data where
|
4 | 6 |
|
| 7 |
import Data.Adnot
|
5 | 8 |
import Data.Sequence (Seq)
|
6 | 9 |
import Data.Text (Text)
|
7 | 10 |
import Data.Word (Word8)
|
|
39 | 42 |
data Note = Note
|
40 | 43 |
{ _noteCents :: Double
|
41 | 44 |
, _noteAppearance :: Text
|
| 45 |
, _noteColor :: Maybe Text
|
42 | 46 |
} 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)
|
43 | 58 |
|
44 | 59 |
$(makeLenses ''Note)
|
45 | 60 |
|
|
57 | 72 |
, _scaleTotalCents :: Double
|
58 | 73 |
, _scaleNotes :: Seq Note
|
59 | 74 |
} deriving (Eq, Show)
|
| 75 |
|
| 76 |
instance FromAdnot Scale where
|
| 77 |
parseAdnot = withProduct "Scale" $ \o ->
|
| 78 |
Scale <$> o .: "name"
|
| 79 |
<*> o .: "size"
|
| 80 |
<*> o .: "notes"
|
60 | 81 |
|
61 | 82 |
$(makeLenses ''Scale)
|
62 | 83 |
|
|
91 | 112 |
} deriving (Eq, Show)
|
92 | 113 |
|
93 | 114 |
|
94 | |
|
95 | 115 |
data Song = Song
|
96 | 116 |
{ _songScale :: Scale
|
97 | 117 |
, _songTracks :: Seq Track
|
1 | 1 |
{-# LANGUAGE ViewPatterns #-}
|
2 | 2 |
|
3 | |
module Hypsibius.Formats.Scale (parse) where
|
| 3 |
module Hypsibius.Formats.Scale where
|
4 | 4 |
|
5 | |
import Data.SCargot
|
6 | |
import Data.SCargot.Repr.Basic
|
| 5 |
import Data.Adnot
|
7 | 6 |
import Data.Sequence (Seq)
|
8 | 7 |
import qualified Data.Sequence as S
|
9 | |
import Data.Text (Text)
|
10 | |
-- import qualified Data.Text as T
|
11 | 8 |
|
12 | 9 |
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
|
26 | 10 |
|
27 | 11 |
{-
|
28 | 12 |
|
1 | 1 |
module Hypsibius.Formats where
|
2 | 2 |
|
| 3 |
import Data.Adnot
|
3 | 4 |
import Data.Sequence (Seq)
|
4 | |
import qualified Data.Text.IO as T
|
| 5 |
import qualified Data.ByteString as BS
|
5 | 6 |
|
6 | |
import qualified Hypsibius.Formats.Scale as Scale
|
7 | |
import Hypsibius.Data (Note)
|
| 7 |
import Hypsibius.Data
|
8 | 8 |
|
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
|