hsc3-plot 0.13 → 0.14
raw patch · 3 files changed
+47/−5 lines, 3 filesdep +directorydep +filepathdep +processdep ~hsc3PVP ok
version bump matches the API change (PVP)
Dependencies added: directory, filepath, process
Dependency ranges changed: hsc3
API changes (from Hackage documentation)
+ Sound.SC3.Plot: plotPath :: (Num t, Show t) => Path t -> IO ()
+ Sound.SC3.Plot: type Path x = [(x, x, x)]
Files
- README +1/−1
- Sound/SC3/Plot.hs +40/−1
- hsc3-plot.cabal +6/−3
README view
@@ -12,7 +12,7 @@ [sc3]: http://audiosynth.com/ [gnuplot]: http://www.gnuplot.info/ -© [rohan drape][rd], 2012, [gpl][gpl].+© [rohan drape][rd], 2013, [gpl][gpl]. [rd]: http://rd.slavepianos.org/ [gpl]: http://gnu.org/copyleft/
Sound/SC3/Plot.hs view
@@ -4,12 +4,16 @@ import qualified Graphics.Gnuplot.Value.Tuple as G import Sound.SC3.Plot.Histogram import Sound.SC3.UGen.Envelope {- hsc3 -}+import System.Directory {- directory -}+import System.FilePath {- filepath -}+import System.Process {- process -} eps :: G.Attribute eps = G.EPS "/tmp/plot.eps" -- | Plot 'Envelope' data. --+-- > import Sound.SC3 -- > plotEnvelope [envPerc 0.2 1,envSine 1 0.75] plotEnvelope :: (G.C t,Ord t, Floating t, Enum t) => [Envelope t] -> IO () plotEnvelope = G.plotLists [] . map (envelope_render 256)@@ -32,8 +36,43 @@ type Coord x = [(x,x)] --- > plotCoord [[(0,0),(0.15,0.35),(0.75,0.25),(0.35,0.15)]]+{--| Plot two-dimensional coordinates.++> let {t = [-pi,-pi + 0.01 .. pi]+> ;f r t = (r t * cos t,r t * sin t)}+> in plotCoord [zip (map cos t) (map sin t)+> ,zip (map cos t) (map (sin . (* 3)) t)+> ,map (f ((/ (2 * pi)) . (+ pi))) t]++-} plotCoord :: G.C t => [Coord t] -> IO () plotCoord = let s = G.defaultStyle {G.plotType = G.LinesPoints} in G.plotPathsStyle [] . zip (repeat s)++type Path x = [(x,x,x)]++{--| Three dimensional variant of 'plotCoord'.++> let {t = [-pi,-pi + 0.01 .. pi]+> ;f n d = map (sin . (+) d . (*) n) t+> ;(x,y,z) = (f 1 (pi/2),f 3 0,f 5 0)}+> in plotPath (zip3 x y z)++> let {t' = [-pi,-pi + 0.01 .. pi]+> ;e' = [0,0.005 .. pi]+> ;f a b r e t = ((a * t + r * sin e) * cos t+> ,(a * t + r * sin e) * sin t+> ,b * t + r * (1 - cos e))}+> in plotPath (zipWith (f 1 1 1) e' t')++-}+plotPath :: (Num t,Show t) => Path t -> IO ()+plotPath p = do+ tmp <- getTemporaryDirectory+ let nm = tmp </> "plotPath.data"+ cm = "splot '" ++ nm ++ "' with l"+ f (x,y,z) = unwords (map show [x,y,z])+ _ <- writeFile nm (unlines (map f p))+ _ <- rawSystem "gnuplot" ["-p","-e",cm]+ return ()
hsc3-plot.cabal view
@@ -1,10 +1,10 @@ Name: hsc3-plot-Version: 0.13+Version: 0.14 Synopsis: Haskell SuperCollider Plotting Description: Plotting functions for hsc3 License: GPL Category: Sound-Copyright: (c) Rohan Drape and others, 2012+Copyright: (c) Rohan Drape and others, 2013 Author: Rohan Drape Maintainer: rd@slavepianos.org Stability: Experimental@@ -17,8 +17,11 @@ Library Build-Depends: base == 4.*,- hsc3 == 0.13.*,+ directory,+ hsc3 == 0.14.*,+ filepath, gnuplot,+ process, statistics, vector GHC-Options: -Wall -fwarn-tabs