csound-expression-5.0.1: library to make electronic music

Safe HaskellNone
LanguageHaskell98

Csound.IO

Contents

Description

Rendering of Csound files and playing the music in real time.

How are we going to get the sound out of Haskell code? Instruments are ready and we have written all the scores for them. Now, it's time to use the rendering functions. We can render haskell expressions to Csound code. A rendering function takes a value that represents a sound (it's a tuple of signals) and produces a string with Csound code. It can take a value that represents the flags for the csound compiler and global settings (Options). Then we can save this string to file and convert it to sound with csound compiler

csound -o music.wav music.csd

Or we can play it in real time with -odac flag. It sends the sound directly to soundcard. It's usefull when we are using midi or tweek the parameters in real time with sliders or knobs.

csound -odac music.csd

The main function of this module is renderCsdBy. Other function are nothing but wrappers that produce the Csound code and make something useful with it (saving to file, playing with specific player or in real time).

Synopsis

Rendering

renderCsd :: RenderCsd a => a -> IO String Source

Renders Csound file.

writeCsd :: RenderCsd a => String -> a -> IO () Source

Render Csound file and save it to the give file.

writeCsdBy :: RenderCsd a => Options -> String -> a -> IO () Source

Render Csound file with options and save it to the give file.

writeSnd :: RenderCsd a => String -> a -> IO () Source

Render Csound file and save result sound to the wav-file.

writeSndBy :: RenderCsd a => Options -> String -> a -> IO () Source

Render Csound file with options and save result sound to the wav-file.

Playing the sound

playCsd :: RenderCsd a => (String -> IO ()) -> String -> a -> IO () Source

Renders Csound file, saves it to the given file, renders with csound command and plays it with the given program.

playCsd program file csd 

Produces files file.csd (with renderCsd) and file.wav (with csound) and then invokes:

program "file.wav"

playCsdBy :: RenderCsd a => Options -> (String -> IO ()) -> String -> a -> IO () Source

Works just like playCsd but you can supply csound options.

mplayer :: RenderCsd a => a -> IO () Source

Renders to tmp.csd and tmp.wav and plays with mplayer.

mplayerBy :: RenderCsd a => Options -> a -> IO () Source

Renders to tmp.csd and tmp.wav and plays with mplayer.

totem :: RenderCsd a => a -> IO () Source

Renders to tmp.csd and tmp.wav and plays with totem player.

totemBy :: RenderCsd a => Options -> a -> IO () Source

Renders to tmp.csd and tmp.wav and plays with totem player.

Live performance

dac :: RenderCsd a => a -> IO () Source

Renders csound code to file tmp.csd with flags set to -odac and -Ma (sound output goes to soundcard in real time).

dacBy :: RenderCsd a => Options -> a -> IO () Source

dac with options.

vdac :: RenderCsd a => a -> IO () Source

Output to dac with virtual midi keyboard.

vdacBy :: RenderCsd a => Options -> a -> IO () Source

Output to dac with virtual midi keyboard with specified options.

Render and run

csd :: RenderCsd a => a -> IO () Source

Renders to file tmp.csd and invokes the csound on it.

csdBy :: RenderCsd a => Options -> a -> IO () Source

Renders to file tmp.csd and invokes the csound on it.