alex, On Tue, Apr 1, 2008 at 1:41 AM, alex <[EMAIL PROTECTED]> wrote: > I'm planning on using a midi device in a performance on Friday, does > anyone already have some example code for using this to control > supercollider patchecs made with Rohan's HSC3, to save me a bit of time? > If not I'll play around and try to provide this myself...
afraid i don't, so would like to see what you come up with. i am still using an old kenton box via an old midi<-->osc bridge for getting 7-bit controller data into scsynth. in case all else fails some (away from desk so untested) example code below, it ought to be close as is extracted from trivial curses program that reads parameter names from a text file and shows controller state in a terminal. darcses at: http://slavepianos.org/rd/sw/midi.osc/ http://slavepianos.org/rd/sw/tctl/ (midi.osc just sends the midi packets as osc blobs, so pattern matching on the incoming packets is actually pretty elegant, if you can remember the midi constants, which i never can, the list i use is at http://slavepianos.org/rd/sw/rsc3-midi/src/constants.scm) regards, rohan ++ import Control.Monad import Sound.OpenSoundControl import Sound.SC3 repeatM_ :: (Monad m) => m a -> m () repeatM_ = sequence_ . repeat -- extract 7-bit controller data packets extract :: OSC -> Maybe (Int, Int) extract (Message "/midi" [Int _, Blob [0xb0, c, x]]) = Just (fromIntegral c, fromIntegral x) extract _ = Nothing -- send 7-bit controller as (0,1) value ctl :: Transport t => t -> (Int, Int) -> IO () ctl fd (i, x) = let { i_ = fromIntegral i ; x_ = fromIntegral x / 128.0 } in send fd (c_set1 i_ x_) main :: IO () main = do { m <- openUDP "127.0.0.1" 57150 -- midi.osc ; s <- openUDP "127.0.0.1" 57110 -- scsynth ; send m (message "/receive" [int 0xffff]) -- request notification ; repeatM_ (do { p <- recv m ; maybe (return ()) (ctl s) (extract p) }) {- let { c_in_l n (l, r) = linLin (lagIn 1 n 0.1) 0 1 l r ; c_in_x n (l, r) = linExp (lagIn 1 n 0.1) 0 1 l r ; f = c_in_x 0 (200, 600) ; a = c_in_l 1 (0, 0.1) ; l = c_in_l 2 (-1, 1) } in audition (out 0 (pan2 (sinOsc AR f 0) l a)) -} _______________________________________________ haskell-art mailing list [email protected] http://lists.lurk.org/mailman/listinfo/haskell-art
