import Sound.Pd
import Control.Concurrent
import Control.Monad
import Linear.Extra

main :: IO ()
main = withPd $ \pd -> do
    p1 <- makePatch pd "test/world"

    forM_ (pdSources pd) $ \sourceID -> alSourcePosition sourceID ((V3 0 0 0) :: V3 Double)

    --_ <- forkIO $ forM_ [200,210..1500] $ \freq -> do
    --    send p1 "freq" $ Atom $ Float (freq)
    --    threadDelay 100000
    _ <- forkIO $ forM_ (map ((*2) . sin) [0,0.01..]) $ \pos -> do
        --print $ "Listener now at " ++ show pos
        --alListenerPosition ((V3 0 0 (pos*5)) :: V3 Double)
        alListenerPosition (V3 0 0 (pos*5) :: V3 Double)
        alListenerOrientation ((axisAngle (V3 0 1 0) 0) :: Quaternion Double)

        threadDelay 10000
    threadDelay 50000000
