-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrimal.hs
71 lines (56 loc) · 1.96 KB
/
Primal.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
module Primal where
import Euterpea
import HSoM.Examples.MoreMusic
import Control.Monad.List
primes :: [Int]
primes = sieve (2 : [3, 5..])
where
sieve (p:xs) = p : sieve [x | x <- xs, x `mod` p > 0]
listToMusic :: [Int] -> Int -> Music Pitch
listToMusic pitches n = line $ map (\x -> note en (pitch (x `mod` 12 + n))) pitches
primePitches = listToMusic (take 112 primes) 40
threetwo :: PercussionSound -> PercussionSound -> Music Pitch
threetwo ps1 ps2 =
let p1 = perc ps1 (1/2)
p2 = perc ps2 (1/3)
in instrument Percussion $
(p1 :+: p1)
:=: (p2 :+: p2 :+: p2)
fourthree :: PercussionSound -> PercussionSound -> Music Pitch
fourthree ins1 ins2 =
let ht = perc ins1 (1/3)
lt = perc ins2 (1/4)
in instrument Percussion $
(ht :+: ht :+: ht)
:=: (lt :+: lt :+: lt :+: lt)
--steadyNow ps1 ps2 =
-- let p1 = perc ps1 (1/4)
-- p2 = perc ps2 (1/4)
-- in instrument Percussion $
-- (p1 :+: p1 :+: p1 :+: p1) :=:
-- (p2 :+: p2 :+: p2 :+: p2)
goneWild :: PercussionSound -> PercussionSound -> PercussionSound -> Music (Pitch,Volume)
goneWild ps1 ps2 ps3 =
let p1 = perc ps1
p2 = perc ps2
p3 = perc ps3
in instrument Percussion $
(addVolume 75 (snr :+: p2 den :+: p2 den :+: p2 sn)) :=:
(addVolume 100 (p1 den :+: p1 sn :+: p1 den :+: p1 sn)) :=:
(addVolume 127 (times 2 $ p3 qn))
primal :: Music (Pitch,Volume)
primal =
let pt1 = times 2 $ threetwo RideBell AcousticBassDrum
pt2 = times 2 $ fourthree RideBell AcousticBassDrum
pt3 = times 2 $ threetwo AcousticBassDrum RideBell
pt4 = times 2 $ fourthree AcousticBassDrum RideBell
in
(addVolume 126 $ primePitches)
:=: (times 1 $
((addVolume 100 (pt1 :+: pt2 :+: pt3 :+: pt4))
:+:
(times 4 $ (goneWild RideBell ElectricSnare AcousticBassDrum))
:+: (addVolume 10 wnr) :+:
(times 4 $ (goneWild RideBell ElectricSnare AcousticBassDrum))
:+: (addVolume 10 wnr)
))