packages feed

hCsound-0.2: examples/test2.hs

module Main where

import Prelude
import Sound.Csound
import Sound.Csound.Interface
import Control.Monad.Error
import Data.Binary.Put
import Data.Word
import qualified Data.ByteString.Lazy as L
import Foreign.Marshal.Array (peekArray, pokeArray)

main :: IO ()
main = do
	runErrorT (runCsound "-W -o test2.wav test1.csd")
	return ()

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

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