I'm just getting started with Euterpea / Haskell, and I am trying to write a simple script that randomizes the note durations.
I wrote this that works:
import Euterpea
playMyNote = play $ line [c 4 qn, c 4 qn, d 4 qn, e 4 qn, a 4 qn, a 4 qn, g 4 hn]
Then I read this: https://www.schoolofhaskell.com/school/starting-with-haskell/libraries-and-frameworks/randoms
Which shows a way of generating random numbers like this:
import System.Random
main = do
g <- getStdGen
print $ take 10 (randomRs ('a', 'z') g)
I am trying to combine them like below, but it's not complete (I don't know where to put z
for example.)
Can anyone advise me on the next step to replace the numbers representing duration with randomly defined numbers?
This is where I'm at currently:
import Euterpea
import System.Random
playRandomly = do
z <- newStdGen
play $ line [c 4 qn, c 4 qn, d 4 qn, e 4 qn, a 4 qn, a 4 qn, g 4 hn]
playMyNote = play $ line [c 4 qn, c 4 qn, d 4 qn, e 4 qn, a 4 qn, a 4 qn, g 4 hn]