csound-expression-5.1.0: 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

class RenderCsd a where Source #

Minimal complete definition

renderCsdBy

Methods

renderCsdBy :: Options -> a -> IO String Source #

Instances

RenderCsd Sig2 Source # 
RenderCsd Sig4 Source # 
RenderCsd Sig6 Source # 
RenderCsd Sig8 Source # 
RenderCsd Sig Source # 
RenderCsd (Source ()) Source # 
RenderCsd (Source (Sig2, Sig2)) Source # 
RenderCsd (Source (Sig2, Sig2, Sig2)) Source # 
RenderCsd (Source (Sig2, Sig2, Sig2, Sig2)) Source # 
RenderCsd (Source Sig2) Source # 
RenderCsd (Source Sig4) Source # 
RenderCsd (Source Sig6) Source # 
RenderCsd (Source Sig8) Source # 
RenderCsd (Source Sig) Source # 
RenderCsd (Source (SE ())) Source # 

Methods

renderCsdBy :: Options -> Source (SE ()) -> IO String Source #

RenderCsd (Source (SE (Sig2, Sig2))) Source # 
RenderCsd (Source (SE (Sig2, Sig2, Sig2))) Source # 
RenderCsd (Source (SE (Sig2, Sig2, Sig2, Sig2))) Source # 
RenderCsd (Source (SE Sig2)) Source # 
RenderCsd (Source (SE Sig4)) Source # 
RenderCsd (Source (SE Sig6)) Source # 
RenderCsd (Source (SE Sig8)) Source # 
RenderCsd (Source (SE Sig)) Source # 
RenderCsd (SE ()) Source # 

Methods

renderCsdBy :: Options -> SE () -> IO String Source #

RenderCsd (SE (Sig2, Sig2)) Source # 
RenderCsd (SE (Sig8, Sig8)) Source # 
RenderCsd (SE (Sig2, Sig2, Sig2)) Source # 
RenderCsd (SE (Sig2, Sig2, Sig2, Sig2)) Source # 
RenderCsd (SE (Sig8, Sig8, Sig8, Sig8)) Source # 
RenderCsd (SE Sig2) Source # 
RenderCsd (SE Sig4) Source # 
RenderCsd (SE Sig6) Source # 
RenderCsd (SE Sig8) Source # 
RenderCsd (SE Sig) Source # 
(Sigs a, Sigs b) => RenderCsd (a -> SE b) Source # 

Methods

renderCsdBy :: Options -> (a -> SE b) -> IO String Source #

Sigs a => RenderCsd (a -> (Sig8, Sig8, Sig8, Sig8)) Source # 

Methods

renderCsdBy :: Options -> (a -> (Sig8, Sig8, Sig8, Sig8)) -> IO String Source #

Sigs a => RenderCsd (a -> (Sig8, Sig8)) Source # 

Methods

renderCsdBy :: Options -> (a -> (Sig8, Sig8)) -> IO String Source #

Sigs a => RenderCsd (a -> (Sig2, Sig2, Sig2, Sig2)) Source # 

Methods

renderCsdBy :: Options -> (a -> (Sig2, Sig2, Sig2, Sig2)) -> IO String Source #

Sigs a => RenderCsd (a -> Sig8) Source # 

Methods

renderCsdBy :: Options -> (a -> Sig8) -> IO String Source #

Sigs a => RenderCsd (a -> (Sig2, Sig2, Sig2)) Source # 

Methods

renderCsdBy :: Options -> (a -> (Sig2, Sig2, Sig2)) -> IO String Source #

Sigs a => RenderCsd (a -> Sig6) Source # 

Methods

renderCsdBy :: Options -> (a -> Sig6) -> IO String Source #

Sigs a => RenderCsd (a -> (Sig2, Sig2)) Source # 

Methods

renderCsdBy :: Options -> (a -> (Sig2, Sig2)) -> IO String Source #

Sigs a => RenderCsd (a -> Sig4) Source # 

Methods

renderCsdBy :: Options -> (a -> Sig4) -> IO String Source #

Sigs a => RenderCsd (a -> Sig2) Source # 

Methods

renderCsdBy :: Options -> (a -> Sig2) -> IO String Source #

Sigs a => RenderCsd (a -> Sig) Source # 

Methods

renderCsdBy :: Options -> (a -> Sig) -> IO String Source #

RenderCsd (Sig2, Sig2) Source # 
RenderCsd (Sig8, Sig8) Source # 
RenderCsd (Sig2, Sig2, Sig2) Source # 
RenderCsd (Sig2, Sig2, Sig2, Sig2) Source # 
RenderCsd (Sig8, Sig8, Sig8, Sig8) Source # 

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.

Render and run with cabbage

runCabbage :: RenderCsd a => a -> IO () Source #

Runs the csound files with cabbage engine. It invokes the Cabbage command line utility and setts all default cabbage flags.

runCabbageBy :: RenderCsd a => Options -> a -> IO () Source #

Runs the csound files with cabbage engine with user defined options. It invokes the Cabbage command line utility and setts all default cabbage flags.