I have still no luck. I installed latest hosc and hsc3 from darcs repo,
tried the attached example program which uses the new function writeNRT,
and got the following output

$ ghci NonRealtime.hs
*Main> nonrealtime
Loading package fps-0.8 ... linking ... done.
Loading package binary-0.2 ... linking ... done.
Loading package parsec-1.0 ... linking ... done.
Loading package network-1.0 ... linking ... done.
Loading package hosc-0.1 ... linking ... done.
Loading package hsc3-0.1 ... linking ... done.
Using Altivec: no
*** ERROR: open directory failed 'synthdefs'
start time 0
*Main> :! ls -al tone.*
-rw-------  1 thielema users 182 2007-08-12 19:19 tone.aiff
-rw-------  1 thielema users 256 2007-08-12 19:19 tone.osc


See the attached OSC file in order to see if it matches the one you can
produce. If my OSC file matches yours then something with my SCSynth is
wrong, if it does not match, maybe ByteString or Binary is wrong.

Thanks for the help!
{-
This module tries to reproduce results of the real-time synthesizer
in scsynth's non-real-time mode.
-}

import Sound.OpenSoundControl(OSC(Bundle))
import Sound.OpenSoundControl.Byte (encode_i32)
import Sound.OpenSoundControl.Time(utc)
import Sound.OpenSoundControl.Transport(send)
import Sound.SC3
import Sound.SC3.Server.NRT (writeNRT)
import qualified Sound.SC3.Server.Play as Play

import qualified Data.ByteString.Lazy as B

import System.Cmd (rawSystem)


beep = out 0 (sinOsc AR 440 0)

name ="Beep"

installSound n = d_recv . graphdef n . graph

bundle start t = Bundle (start+t)

rootId =  0
homeId =  1
autoId = -1

latency = 0.1

msgs :: [(Double, [OSC])]
msgs =
   (0, g_freeAll [rootId] :
       g_new [(homeId, AddToTail, rootId)] :
       installSound name beep :
       s_new name autoId AddToTail homeId [] :
       []) :
   (1, g_freeAll [homeId] :
       []) :
   []

attachTimeStamps :: [(Double, [OSC])] -> IO [OSC]
attachTimeStamps ms =
   do now <- utc
      return (map (uncurry (bundle (now+latency))) ms)

realtime =
   Play.withSC3 $ \fd ->
      mapM (send fd) =<< attachTimeStamps msgs



oscFileName = "tone.osc"

nonrealtime =
   do let tsMsgs = map (uncurry Bundle) msgs
      writeNRT oscFileName tsMsgs
      rawSystem "scsynth"
         ["-o", "1", "-N", oscFileName, "_", "tone.aiff",
          "44100", "AIFF", "int16"]


main =
   realtime >>
   nonrealtime

Attachment: tone.osc
Description: Binary data

Attachment: tone.aiff
Description: audio/aiff

_______________________________________________
haskell-art mailing list
haskell-art@lists.lurk.org
http://lists.lurk.org/mailman/listinfo/haskell-art

Reply via email to