-- radiohead - weird fishes (intro)
import CsoundExpr.Base(csd, play, headerMono)
import Temporal.Music.Western.P12
import Orchestra(guitar, ScoreN)
-- accent every fourth beat
beat = cycle [accent 0.5, id, id, id]
-- chords
guitarChord1, guitarChord2, guitarChord3 :: [ScoreN] -> ScoreN
-- guitar 1
guitarChord1 = line . zipWith ($) beat . map en . concat . replicate 10
wholeTone = 2
ch11 = [high d, g, e]
ch12 = map (step wholeTone) ch11
ch13 = [high a, a, high cs]
ch14 = [high fs, b, g]
chSeq1 = [ch11, ch12, ch13, ch14]
-- guitar 2
guitarChord2 =
line . zipWith ($) beat . map en .
concat . replicate 6 . arpeggi . map high
where arpeggi x = x ++ take 2 x
ch21 = [low g, d, e]
ch22 = map (step wholeTone) ch21
ch23 = [cs, e, a]
ch24 = [d, g, e]
chSeq2 = [ch21, ch22, ch23, ch24]
-- guitar 3
guitarChord3 =
line . zipWith ($) beat . map en .
concat . replicate 6 . arpeggi . map high
where arpeggi x = take 2 x ++ x
ch31 = [e, g, b]
ch32 = map (step wholeTone) ch31
ch33 = [fs, a, high cs]
ch34 = [high d, g, b]
chSeq3 = [ch31, ch32, ch33, ch34]
-- score
scoG1 = mf' $ line $ map guitarChord1 chSeq1
scoG2 = p' $ line $ map guitarChord2 chSeq2
scoG3 = ppp' $ line $ map guitarChord3 chSeq3
scoG2intro = clip (3*30/8) (4*30/8) scoG2
intro = chord [scoG1, scoG3, delay (3*30/8) scoG2intro]
chords = loop 3 $ chord [scoG1, scoG2, scoG3]
sco = bpm (presto 0.4) $ guitar $ intro +:+ chords
file = "out.csd"
flags = "-d"
out = csd flags headerMono sco
--main = writeFile file $ show out
main = play "totem" "tmp" "new" out