
On a separate thread
http://haskell.1045720.n5.nabble.com/How-to-send-a-string-somewhere-via-UDP-...,
Rohan Drape showed me how to send OSC. The following test, which simplifies
the old one and replaces printf with OSC, demonstrates timing as perfect as
my ears are able to distinguish.
import Control.Concurrent
import Control.Monad
import System.IO
import Sound.OSC
main = do
hSetBuffering stdout NoBuffering
mapM_ note (cycle [1,1,2])
withMax = withTransport (openUDP "127.0.0.1" 9000)
beat = 60000 -- 60 ms, measured in µs
note :: Int -> IO ()
note n = do
withMax (sendMessage (Message "sin0 frq 100" []))
-- set sine wave 0 to frequency 100
withMax (sendMessage (Message "sin0 amp 1" []))
-- set sine wave 0 to amplitude 1
threadDelay $ beat * n
withMax (sendMessage (Message "sin0 amp 0" []))
-- set sine wave 0 to amplitude 0
threadDelay $ beat * n
This means I can use Haskell instead of Python or SuperCollider. I am
beside myself with excitement.
Thanks again, everyone!
On Tue, Oct 21, 2014 at 2:24 AM, Brandon Allbery
On Tue, Oct 21, 2014 at 4:05 AM, Heinrich Apfelmus < apfelmus@quantentunnel.de> wrote:
I would be hesitant to attribute your problem to the scheduler. An alternative explanation could be the following: The sound file played by the terminal when it encounters the \BEL character is longer than 100ms. A new sound will be played only when the previous sound has finished playing,
On most systems I've used, this isn't true; they're either suppressed or they overlap, depending on system. (I've had to work around this.)
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe