]> gitweb @ CieloNegro.org - EsounD.git/blobdiff - Sound/EsounD/Internals.hs
Give up using type families for stream muxing
[EsounD.git] / Sound / EsounD / Internals.hs
index 4c450361571e15fd54e7c14ce562f056c0d84b08..ef8c659ddd104d0646b9ca770800b6fcf2ab3f48 100644 (file)
@@ -2,7 +2,6 @@
     EmptyDataDecls
   , FlexibleInstances
   , MultiParamTypeClasses
-  , TypeFamilies
   , UnicodeSyntax
   #-}
 module Sound.EsounD.Internals
@@ -11,8 +10,7 @@ module Sound.EsounD.Internals
     , Channels(..)
     , Mono
     , Stereo
-
-    , Mux(..)
+    , interleave
 
     , wrapSocket
     , closeSocket
@@ -42,37 +40,26 @@ instance Frame Int16 where
 class Channels ch where
     channelFmt ∷ ch → C'esd_format_t
 
-class (Frame fr, Channels ch) ⇒ Mux (vec ∷ ★ → ★) fr ch where
-    type DemuxedVec vec fr ch
-    mux ∷ DemuxedVec vec fr ch → vec fr
-
 -- Mono
 data Mono
 
 instance Channels Mono where
     channelFmt _ = c'ESD_MONO
 
-instance Frame fr ⇒ Mux vec fr Mono where
-    type DemuxedVec vec fr Mono = vec fr
-    mux = id
-
 -- Stereo
 data Stereo
 
 instance Channels Stereo where
     channelFmt _ = c'ESD_STEREO
 
-instance Frame fr ⇒ Mux L.Vector fr Stereo where
-    type DemuxedVec L.Vector fr Stereo = (L.Vector fr, L.Vector fr)
-    mux (left, right) = loop left right
-        where
-          -- THINKME: consider using storablevector-streamfusion
-          loop l r
-              = let Just (lFr, l') = L.viewL l
-                    Just (rFr, r') = L.viewL r
-                    lr' = loop l' r'
-                in
-                  L.cons lFr (L.cons rFr lr')
+interleave ∷ Frame fr ⇒ L.Vector fr → L.Vector fr → L.Vector fr
+interleave l r
+    -- THINKME: consider using storablevector-streamfusion
+    = let Just (lFr, l') = L.viewL l
+          Just (rFr, r') = L.viewL r
+          lr' = interleave l' r'
+      in
+        L.cons lFr (L.cons rFr lr')
 
 -- Utility functions
 wrapSocket ∷ String → CInt → IO Handle