packages feed

temporal-music-notation-0.1: examples/choral.hs

-- J.S. Bach - Choral prelude F-moll 'Ich ruf zu dir Herr Jesu Christ'

import Temporal.Music.Notation
import Temporal.Music.Notation.Local.Western

import CsoundExpr(headerMono, csd, play) 

import Orchestra(pipeOrgan')

-- alto dynamics

up :: Double -> [Tone N12] -> Score NoteW
up x = dynamicRel [x, x + accDiap] . line . map sn 

down :: Double -> [Tone N12] -> Score NoteW
down x = dynamicRel [x + accDiap, x] . line . map sn 

upDown :: Double -> [Tone N12] -> Score NoteW
upDown x = dynamicRel [x, x + accDiap, x] . line . map sn 

downUp :: Double -> [Tone N12] -> Score NoteW
downUp x = dynamicRel [x, x-accDiap, x] . line . map sn 

flat :: Double -> [Tone N12] -> Score NoteW
flat x = accent x . line . map sn

accDiap = 0.5

--------------------------------------------------
-- solo

-- Part I

solo0 = qn $ high c

solo1 = line [
-- 1 bar
    qn ab, qn bb, den ab, sn g, den f, sn g,
-- 2 bar
    dynamicRel [0, 0.2, 0] $ line [line $ map sn [ab, bb, ab, bb],
    trill 3 (accent 0.2 $ tn $ high c) (tn bb), tn ab, tn bb], 
    high $ line [accent 0.2 $ qn $ c, den c, sn db, 
-- 3 bar
    qn eb, tn db, stretch (1/4 - 3/32) $ wn c, 
    sn $ low bb, qn $ low ab, en $ low bb, en c] 
    ]

solo11 = high $ line [
    stretch (1/4 + 1/16) $ wn db, 
    line $ map tn [eb, f, eb, db], sn c, qn c, qn c]


solo12 = high $ line [
    qn db, sn db,
    line $ map tn [eb, f, eb, db],sn c,  qn c, qn eb]

    
soloI = line [solo0, reprise solo1 solo11 solo12]


-- Part II

solo21 = high $ line [
-- 1 bar
        qn f, en eb, tn db, tn c, sn db,
    low $ line $ map en [high c, bb, ab, bb],
-- 2 bar
        qn c, qn c, qn $ low bb, qn $ low ab,
-- 3 bar
        low $ line [hn g, hn f, 
-- 4 bar    
        qn ab, qn g, hn f]
    ]

solo22 = line [
-- 5 bar
        dhn eb, qn eb,
-- 6 bar
        qn ab, qn ab, qn bb, qn bb,
-- 7 bar   
    high $ line [dhn c, qn db],
-- 8 bar
    high $ qn c, qn bb, qn ab, den f, sn g,
-- 9 bar
    qn ab, qn g, qn f
    ]

soloII = solo21 +:+ solo22

solo = pedal (1/128) $ ppl $ soloI +:+ soloII

---------------------------------------------------
-- alto

-- Part I

alto0 = high $ up 0 [low ab, c, f, e] 

alto1 = line [
-- 1 bar
        high $ down 0.5 [f, c, low ab, low f], 
        upDown 0 [g, bb, high db, high c],
        upDown 0 [f, ab, high c, bb],
        downUp 0 [ab, f, ab, high c],

-- 2 bar
        high $ downUp 0.2 [f, e, f, ab],
        high $ down 0 [g, f, e, f],
        high $ downUp 0 [e, c, low g, low bb, low ab, c, f, ab],

-- 3 bar
        high $ flat 0 [g, eb, ab, g],
        high $ up 0 [ab, eb, f, gb, f, db, f, ab, g, db, c, gb]
     ] 

alto11 = high $ line [
        upDown 0 [f, low bb, db, f, bb, ab, g, ab, g, c, e, low bb],
        upDown 0 [low f, c, f, e]
    ]

alto12 = high $ line [
        upDown 0 [f, low bb, db, f, bb, ab, g, ab],
        down 0 [g, low bb, low ab, f, low g, db, low ab, c]
    ]

    
altoI = line [alto0, reprise alto1 alto11 alto12]

-- Part II

alto21 = high $ line [
-- 1 bar
        upDown 0 [
            low ab, c, low bb, db, low bb, db, ab, g, 
            ab, eb, db, g, c, f, ab, g],
-- 2 bar
        down (-accDiap) [
            ab,  eb, low ab, gb, f, low ab, low g, db, 
            c, low ab, c, eb, g, c, low bb, g,
-- 3 bar 
            db, f, g, f],
        up (-accDiap) [
                            e, low bb, db, c,
                low ab, c, f, e, f, c, low ab, low f],
-- 4 bar
        flat 0 [
            low bb, f, g, f, low bb, eb, f, eb,
            c, eb, f, eb, d, low g, low b, d
        ]
    ]

alto22 = high $ line [
-- 5 bar
        down (-accDiap) $ [
            low g, c, eb, db, low g, low bb, db, c] ++
            map low [eb, ab, high c, bb, high db, bb, c, high db,
-- 6 bar
                f, ab, high db, high c, f, ab, high c, bb, 
                f, ab, bb, ab, g, bb, high db, high c],

-- 7 bar
        up (-accDiap) [
            low ab, c, eb, ab, eb, bb, high c, bb,
            a, eb, gb, low a, low bb, g, low ab, f
            ],

-- 8 bar
        down (-accDiap) [
            low ab, eb, d, eb, low f, db, eb, db, 
            low eb, c, db, c, low bb, f, g, f,
-- 9 bar
            d, f, g, f,   e, db, low bb, low g, 
            low a, c]

    ]

alto23 = en $ high f

altoII = line [alto21, alto22, alto23]

alto = pedal (1/132) $ lower 3 $ pl $ line [altoI, altoII]


----------------------------------------------------------
-- bass 

-- Part I

bass0 = lower 1 $ line [en f, en f]

bass1 = (line $ map en [
-- 1 bar
        f, f, f, e, f, f, f, eb,
-- 2 bar
        db, db, db, db, c, c, f, f]) +:+
-- 3 bar
    (high $ line $ map en [c, c, c, c, c, c, low bb, low a])

bass11 = line $ map en [bb, ab, g, f, e, c, low f, low f]

bass12 = line $ map en [bb, ab, g, f, e, f, c, c]

bassI = line [bass0, reprise bass1 bass11 bass12]


-- Part II

bass21 = line $ map en [
-- 1 bar
        db, db, eb, eb, ab, eb, f, db,
-- 2 bar
        low f, low f, f, f, d, e, f, db,
-- 3 bar
        low bb, low g, c, c, db, db, db , db,
-- 4 bar
        d, d, d, d, low a, low a, low b, low b
    ] 
    
bass22 = low $ line $ map en [
-- 5 bar
        high c, high c, bb, bb, ab, ab, g, g,
-- 6 bar
        f, f, eb, eb, d, d, eb, eb, 
-- 7 bar
        ab, ab, gb, gb, f, f, bb, bb,
-- 8 bar
        bb, ab, ab, g, g, f, high db, high db,
-- 9 bar
        b, b, high c, high c
    ]

bass23 = qn $ low f

    
bassII = line [bass21, bass22, bass23]

bass = lower 3 $ line [bassI, bassII]

sco = delay (-4) $ bpm (lento $ -0.5) $ pipeOrgan' $ chord [solo, alto, bass]

file = "out.csd"
flags = "-d"

out = csd flags headerMono $ renderScore sco

main = writeFile file $ show out
--main = play "totem" "tmp" "new" out