-
Notifications
You must be signed in to change notification settings - Fork 4
/
synthesizer.hs
51 lines (43 loc) · 1.58 KB
/
synthesizer.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{- Command-line interface.
By convention program entry point is the symbol @main@ defined in the
module @Main@. Implicitly an unnamed module is Main.
-}
import System.Environment (getArgs)
import Sound
import Music
import SoundIO
{-|
We define various Constant Applicative Forms that can be used to
to generate music. Variables in Haskell are immutable and referentially
transparent: One can always replace the variable with the expression
it denotes. This implies that CAF and local variables value is memoized
upon its first evaluation.
-}
simplenote p = Note p 4 Crotchet
cMajor = Chord (map note [(C,4,Crotchet),
(E,4,Crotchet),
(G,4,Crotchet)]) Crotchet
cMinor = Chord (map note [(C,4,Crotchet),
(Ds,4,Crotchet),
(G,4,Crotchet)]) Crotchet
-- main = do
-- outputSound $ (interpret 60 cMajor) ++ (interpret 60 cMinor)
{-|
Main symbol has type @IO ()@: It is a computation in the IO monad with
no interesting result.
-}
main = do
prompt
commandLoop emptyStore
{-|
This version of @main@ demonstrates extraction of command-line arguments: We simply
invoke @getArgs@ which outputs a list of strings and we pattern match against the
expected number of arguments. In real-life situation, we would want to use a dedicated
utility such as @System.Console.GetOpt@ for handling arguments.
-}
-- main = do
-- [frequency,volume,duration] <- getArgs
-- let f = read frequency :: Int
-- let d = read duration :: Double
-- let a = read volume :: Double
-- outputSound $ computeSound f d a