packages feed

csound-expression 3.1.0 → 3.1.1

raw patch · 4 files changed

+30/−17 lines, 4 filesdep ~csound-expression-typed

Dependency ranges changed: csound-expression-typed

Files

csound-expression.cabal view
@@ -1,5 +1,5 @@ Name:          csound-expression-Version:       3.1.0+Version:       3.1.1 Cabal-Version: >= 1.6 License:       BSD3 License-file:  LICENSE@@ -102,7 +102,7 @@   Ghc-Options:    -Wall   Build-Depends:         base >= 4, base < 5, process, data-default, Boolean >= 0.1.0,-        csound-expression-typed >= 0.0.1, csound-expression-opcodes+        csound-expression-typed >= 0.0.2, csound-expression-opcodes   Hs-Source-Dirs:      src/   Exposed-Modules:         Csound.Base
examples/DubBass.hs view
@@ -1,3 +1,6 @@+-- | Originally coded in Csound by Jacob Joaquin+--+-- http://codehop.com/2011/07/ module Main where  import Csound@@ -20,7 +23,7 @@ instr (coeff, cps) = return $ wobbly (sig spb) (sig coeff) (sig $ cpspch cps)  -main = dac $ mix $ str (dspb * 2) $ sco instr $ melMap temp $ +main = totem $ mix $ str (dspb * 2) $ sco instr $ melMap temp $      [ (2, 6.04)     , (1/3, 7.04)     , (2, 6.04)
examples/Tibetan.hs view
@@ -140,7 +140,7 @@     where initSt = fmap (St initRepeat initWait initSpan) $ fmap (randomRs (0, 1)) newStdGen     acts :: [Act]-acts = concat $ replicate 2 $ [1, 1, 5, 2, 5, 7, 5, 1, 1, 3, 5, 3, 1, 1, 1, 5, 1, 5, 6, 3, 2, 1, 1, 5, 1, 6, 4, 5, 1, 1]+acts = concat $ replicate 1 $ [1, 1, 5, 2, 5, 7, 5, 1, 1, 3, 5, 3, 1, 1, 5, 1 ]       note (start, dur, amp, cps, rise, dec) = del start $ str dur $ @@ -171,13 +171,13 @@  introBlurp = toStereo $ sco blurp $ introDur *| temp (0.7 * blurpVol) -blurpSco = toStereo $ mel [rest 100, cone 15 0.7, rest 120, cone 10 0.4]+blurpSco = toStereo $ mel [rest 100, cone 15 0.7, rest 60, cone 10 0.4]     where cone dt v = eff (\x -> return $ linen x (0.25 * idur) idur (0.25 * idur)) $ sco blurp $ dt *| temp (v * blurpVol)  ------------------------------------------------------------ -- stars -starLength      = 2.5 * 60+starLength      = 60 starParams      = zip4 starVolumes starLfos starHarms starSweeps  starVolume      = 0.3@@ -195,7 +195,7 @@ starSco = sco blue $     flip evalState starParams $ traverse addParam $      takeS starLength $ har $ zipWith3 phi starInitDelays starPeriods starChord-    where phi dt period note = del dt $ loop 200 $ har [4 *| temp (double $ id2cps 2 note), rest period] +    where phi dt period note = del dt $ loop 70 $ har [4 *| temp (double $ id2cps 2 note), rest period]             addParam cps = state $ \((amp, lfo, harm, sweep) : params) ->              ((amp, cps, lfo, harm, sweep), params) @@ -204,7 +204,7 @@  main = do     notes <- run acts-    dac $ mix $ har +    totem $ mix $ har          [ introBlurp         , del (introDur * 0.70) $ har              [ globalEffect $ har 
src/Csound/IO.hs view
@@ -37,7 +37,9 @@     csd, csdBy ) where -import System.Cmd(system)+import System.Process+import Control.Exception+ import Data.Default import Csound.Typed @@ -139,7 +141,7 @@ playCsdBy :: (RenderCsd a) => Options -> (String -> IO ()) -> String -> a -> IO () playCsdBy opt player file a = do     writeCsdBy opt fileCsd a-    _ <- system $ "csound -o " ++ fileWav ++ " " ++ fileCsd+    runWithUserInterrupt $ "csound -o " ++ fileWav ++ " " ++ fileCsd     player fileWav     return ()     where fileCsd = file ++ ".csd"@@ -148,9 +150,7 @@ simplePlayCsdBy :: (RenderCsd a) => Options -> String -> String -> a -> IO () simplePlayCsdBy opt player = playCsdBy opt phi     where phi file = do-            _ <- system $ player ++ " " ++ file-            return ()-            +            runWithUserInterrupt $ player ++ " " ++ file  -- | Renders csound code to file @tmp.csd@ and plays it with @-odac@ option -- (sound output goes to soundcard in real time).@@ -161,8 +161,7 @@ dacBy :: (RenderCsd a) => Options -> a -> IO () dacBy opt a = do     writeCsdBy opt "tmp.csd" a-    _ <- system $ "csound -odac " ++ "tmp.csd" -    return ()+    runWithUserInterrupt $ "csound -odac " ++ "tmp.csd"   -- | Output to dac with virtual midi keyboard. vdac :: (RenderCsd a) => a -> IO ()@@ -184,8 +183,7 @@ csdBy :: (RenderCsd a) => Options -> a -> IO () csdBy options a = do     writeCsdBy options "tmp.csd" a-    _ <- system $ "csound tmp.csd" -    return ()+    runWithUserInterrupt $ "csound tmp.csd"   ---------------------------------------------------------- -- players@@ -206,4 +204,16 @@ totemBy :: (RenderCsd a) => Options -> a -> IO () totemBy opt = simplePlayCsdBy opt "totem" "tmp" +----------------------------------------------------------+-- handle user interrupts++runWithUserInterrupt :: String -> IO ()+runWithUserInterrupt cmd = do+    pid <- runCommand cmd+    catch (waitForProcess pid >> return ()) (onUserInterrupt pid)+    where+        onUserInterrupt :: ProcessHandle -> AsyncException -> IO ()+        onUserInterrupt pid x = case x of +            UserInterrupt -> terminateProcess pid >> throw x+            e             -> throw e