Re: [haskell-art] alsa-midi, midi, event-list, non-negative

2008-03-31 Thread Rohan Drape
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 0x]) -- 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
haskell-art@lists.lurk.org
http://lists.lurk.org/mailman/listinfo/haskell-art


Re: [haskell-art] alsa-midi, midi, event-list, non-negative

2008-03-31 Thread alex
On Thu, 2008-02-21 at 14:59 +0100, Henning Thielemann wrote:
> Last autumn I found the 'alsa-midi' package by Soenke Hahn for controlling
> digital music instruments over MIDI and I wanted to avoid duplicate MIDI
> definitions. Thus I started extracting MIDI code from the Haskore project.
> Months later I ended up with some more packages:
> 
> http://hackage.haskell.org/cgi-bin/hackage-scripts/package/alsa-midi
>   This is a simple interface to the sequencer part of ALSA
>   (Advanced Linux Sound Architecture)
>   It lets you control and communicate with external music synthesizers via 
> MIDI.
>   However with its release it becomes deprecated
>   because I recently became aware of the more complete approach
> http://code.haskell.org/alsa/
>   which we should merge with, I think.

Great stuff Henning, thanks!

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...

cheers

alex


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