Using sox to write files works without problems, so I did not try it with forkIO. But playback still stops after 414917 values. I will take a look at DirectSound now.

import Sound.Sox.Option.Format as Option
import Sound.Sox.Write
import Sound.Sox.Signal.List
import Data.Int
import qualified Data.StorableVector.Lazy as StorableVector

import Data.Monoid

main1 = simple Sound.Sox.Signal.List.put
               Option.none
               "out1.wav"
               44100
               (take 40000000 $ iterate (1000+) (0::Data.Int.Int16))

main2 = simple StorableVector.hPut
               Option.none
               "out2.wav"
               44100
               (StorableVector.take 40000000 $
                StorableVector.iterate (StorableVector.ChunkSize 10000)
                                       (1000+)
                                       (0::Data.Int.Int16))

main = main1 >> main2






Henning Thielemann schrieb:
Daniel van den Eijkel schrieb:

  
Using forkIO makes no difference. I tried the following code (and some
variations) but the program still hangs after ca. 40sec at a sampling
rate11025 and ca. 10 sec at 44100. Maybe I'm doing something wrong. But
now I need a break before the next attempt, can't hear this saw anymore :-)

extended write srcOpts dstOpts sampleRate stream = do
   mvar <- newEmptyMVar
   bracket
      (Proc.runInteractiveProcess "play"
          (Args.decons $ mconcat $
           OptPriv.toArguments
             (mconcat $
              srcOpts :
              Option.numberOfChannels
                 (Frame.withSignal Frame.numberOfChannels stream) :
              Option.sampleRate sampleRate :
              Option.format (Frame.withSignal Frame.format stream) :
              []) :
           Args.pipe :
           OptPriv.toArguments dstOpts :
           [])
          Nothing Nothing)
      (\(input,output,err,_proc) ->
          mapM_ IO.hClose [input, output, err])
      (\(input,_,_,proc) -> do
         -- hSetBuffering input (BlockBuffering Nothing)
         -- hSetBinaryMode input True
         forkIO $ do write input stream
                     xcode <- Proc.waitForProcess proc
                     putMVar mvar xcode
                     --putStrLn "done"
                     return ()
         readMVar mvar)
    

Hm, complicated. Did you try the Write module in the same way? Does it
also hang? Did you try to write a file with StorableVector.hPut directly?
  
_______________________________________________
haskell-art mailing list
[email protected]
http://lists.lurk.org/mailman/listinfo/haskell-art

Reply via email to