Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Euterpea
- import System.Random
- import Data.Map hiding (map,foldr,foldl)
- fisherYatesStep :: RandomGen g => (Map Int a, g) -> (Int, a) -> (Map Int a, g)
- fisherYatesStep (m, gen) (i, x) = ((insert j x . insert i (m ! j)) m, gen')
- where
- (j, gen') = randomR (0, i) gen
- fisherYates :: RandomGen g => g -> [a] -> ([a], g)
- fisherYates gen [] = ([], gen)
- fisherYates gen l =
- toElems $ foldl fisherYatesStep (initial (head l) gen) (numerate (tail l))
- where
- toElems (x, y) = (elems x, y)
- numerate = zip [1..]
- initial x gen = (singleton 0 x, gen)
- dMinor = d 4 wn :=: f 4 wn :=: a 4 wn
- gMajor = g 4 wn :=: b 4 wn :=: d 5 wn
- cMajor = c 4 bn :=: e 4 bn :=: g 4 bn
- t251 = dMinor :+: gMajor :+: cMajor
- notes = [c,d,e,f,g,a,b]
- l = map (\x -> x 4 hn) notes
- m = foldr (:+:) (rest hn) l
- main = do g <- getStdGen
- let (sf,bla) = fisherYates g [60..71]
- nnotes = map (\x -> note en $ pitch x) sf
- msc = foldr (:+:) (rest hn) nnotes
- playDev 2 $ msc
- playDev 2 $ msc
- print msc
- --main = playDev 2 $ c 4 wn
- --main = playDev 2 $ t251
- --main = playDev 2 m
Add Comment
Please, Sign In to add comment