csound-expression-0.0.2: Csound combinator library




data CsoundFile Source

csound code


type Flags = StringSource

csound flags



:: Flags


-> Header

header section

-> EventList Dur SignalOut

score section

-> CsoundFile

csd file

Generate csound code

Csound code consists of flags, header section, instruments, ftables and score. Flags are represeted by String. See CsoundExpr.Base.Header for more details on header section. Instruments, ftables and score are generated from EventList Dur SignalOut. From list of SignalOut notes list of instruments is derived. Expression-tree structures of instruments are different from one another. An instrument can't be transformed into another one only with substitution of values in lists of expression-tree.

Example (d minor) :

import CsoundExpr
import CsoundExpr.Opcodes
import CsoundExpr.Base.Pitch
flags  = "-o dm.wav"

setup = instr0 [
        gSr     <=> 44100,
        gKr     <=> 4410,
        gKsmps  <=> 10,
        gNchnls <=> 1]

header = [setup]

sinWave = gen10 4096 [1]

instr :: Irate -> SignalOut
instr x = out $ oscilA [] (num 1000) (cpspch x) sinWave

sco = fmap instr $ line $ map (note 1) [d 0, f 0, a 0, d 1]

main = print $ csd flags header $ toList sco

play :: Player -> FilePath -> FileName -> CsoundFile -> IO ExitCodeSource

play writes CsoundFile to file in temporal direcory, executes csound on it, saves to .wav file, and invokes player

play "totem" "~/temp" "song" $ csd flags header $ toList scores