]> gitweb @ CieloNegro.org - EsounD.git/commitdiff
decided the Player type
authorPHO <pho@cielonegro.org>
Wed, 3 Nov 2010 06:31:14 +0000 (15:31 +0900)
committerPHO <pho@cielonegro.org>
Wed, 3 Nov 2010 06:31:14 +0000 (15:31 +0900)
EsounD.cabal
Sound/EsounD.hs [new file with mode: 0644]
Sound/EsounD.hsc [deleted file]

index cd06f1b5378f9dbd1fde7118dc457bf0274f19a3..60e1e5b745291a90d3e26e3b66881f54c13d952b 100644 (file)
@@ -22,10 +22,20 @@ Source-Repository head
 
 Library
     Build-Depends:
-        base               == 4.2.*,
-        bindings-EsounD    == 0.1.*,
-        regions            == 0.7.*,
-        storablevector     == 0.2.*
+        MonadCatchIO-transformers == 0.2.*,
+        base                      == 4.2.*,
+        bindings-EsounD           == 0.1.*,
+        network                   == 2.2.*,
+        regions                   == 0.7.*,
+        safer-file-handles        == 0.8.*,
+        storablevector            == 0.2.*
 
     Exposed-Modules:
         Sound.EsounD
+
+    Extensions:
+        KindSignatures
+        UnicodeSyntax
+
+    GHC-Options:
+        -Wall
diff --git a/Sound/EsounD.hs b/Sound/EsounD.hs
new file mode 100644 (file)
index 0000000..ba46305
--- /dev/null
@@ -0,0 +1,45 @@
+-- | Type-safe bindings to EsounD with monadic regions.
+module Sound.EsounD
+    ( Player
+    , openPlayer
+    )
+    where
+
+import Control.Monad.CatchIO
+import Control.Monad.Trans.Region
+import Network
+import System.IO.SaferFileHandles
+
+{-
+data Mono
+data Stereo
+
+data Recorder frame channels
+data Filter   frame channels
+data Sampler
+-}
+
+-- ^ An ESD handle for playing a stream.
+data Player frame channels (r ∷ * → *)
+    = Player {
+        plRate   ∷ Int
+      , plHandle ∷ RegionalFileHandle WriteMode r
+      }
+
+instance Dup (Player frame channels) where
+    dup pl
+        = do h' ← dup (plHandle pl)
+             return pl { plHandle = h' }
+
+-- ^ Open an ESD handle for playing a stream.
+openPlayer ∷ MonadCatchIO pr
+           ⇒ Int          -- ^ sample rate for the stream.
+           → HostName     -- ^ host to connect to.
+           → Maybe String -- ^ name used to identify this stream to
+                           --   ESD (if any).
+           → RegionT s pr (Player frame channels (RegionT s pr))
+openPlayer rate host name
+    = return Player {
+        plRate   = rate
+      , plHandle = error "FIXME: not implemented"
+      }
diff --git a/Sound/EsounD.hsc b/Sound/EsounD.hsc
deleted file mode 100644 (file)
index 2e86329..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-module Sound.EsounD
-    (
-    )
-    where
-
-{-
-data Mono
-data Stereo
-
-data Player   frame channels
-data Recorder frame channels
-data Filter   frame channels
-data Sampler
--}