packages feed

hCsound-0.3.0: examples/test3.hs

module Main where

import Prelude
import Sound.Csound
import Sound.Csound.Interface
import Control.Monad.Error

main :: IO ()
main = (runErrorT $ runCsound "-W -otest3.wav test1.csd") >>= reportResult

runCsound :: String -> CsoundMonad ()
runCsound args = do
        ptr <- csoundCreate
        csoundPreCompile ptr
        liftIO $ csoundSetHostImplementedAudioIO ptr 1 512
        csoundCompile ptr args
        csoundPerformBufferIO ptr (\x y -> return $ replicate x 1) (\_ _ _ -> return ())
        csoundDestroy ptr

outFn l i b = putStrLn ("Buffer Length: " ++ (show l) ++ "Position: " ++ (show i))

reportResult :: Either String a -> IO ()
reportResult (Right _) = (putStrLn "Csound Ran! ")
reportResult (Left e) = putStrLn ("csound didn't run... " ++ (show e))