Safe Haskell | None |
---|---|
Language | Haskell98 |
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).
- class RenderCsd a where
- renderCsdBy :: Options -> a -> IO String
- renderCsd :: RenderCsd a => a -> IO String
- writeCsd :: RenderCsd a => String -> a -> IO ()
- writeCsdBy :: RenderCsd a => Options -> String -> a -> IO ()
- writeSnd :: RenderCsd a => String -> a -> IO ()
- writeSndBy :: RenderCsd a => Options -> String -> a -> IO ()
- playCsd :: RenderCsd a => (String -> IO ()) -> String -> a -> IO ()
- playCsdBy :: RenderCsd a => Options -> (String -> IO ()) -> String -> a -> IO ()
- mplayer :: RenderCsd a => a -> IO ()
- mplayerBy :: RenderCsd a => Options -> a -> IO ()
- totem :: RenderCsd a => a -> IO ()
- totemBy :: RenderCsd a => Options -> a -> IO ()
- dac :: RenderCsd a => a -> IO ()
- dacBy :: RenderCsd a => Options -> a -> IO ()
- vdac :: RenderCsd a => a -> IO ()
- vdacBy :: RenderCsd a => Options -> a -> IO ()
- csd :: RenderCsd a => a -> IO ()
- csdBy :: RenderCsd a => Options -> a -> IO ()
Rendering
class RenderCsd a where Source
renderCsdBy :: Options -> a -> IO String Source
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.
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).
vdacBy :: RenderCsd a => Options -> a -> IO () Source
Output to dac with virtual midi keyboard with specified options.