packages feed

tidal-0.1: Neko.lhs

> module Neko where

> import Stream
> import Pattern
> import Control.Applicative
> import Proxy303
> import Control.Concurrent (forkIO)
> import System.Process

Define the OSC message.  Each datum has:
 
o An OSC type: S (string), F(float) or I (int)
o A unique name
o And a default value, prefixed by "Just" or if there is no default,
  "Nothing".

> nekobee :: OscShape
> nekobee = OscShape {path = "/trigger",
>                      params = [ I "note" (Just 0),
>                                 F "duration" (Just 0.2),
>                                 F "saw" (Just 0),
>                                 F "tuning" (Just 0.5),
>                                 F "cutoff" (Just 0),
>                                 F "resonance" (Just 0.6),
>                                 F "envmod" (Just 0),
>                                 F "decay" (Just 1),
>                                 F "accent" (Just 1),
>                                 F "velocity" (Just 0.9),
>                                 F "volume" (Just 1)
>                               ],
>                      timestamp = False
>                     }

> nekoProxy remote = do port <- Proxy303.start remote
>                       return port

Make some methods for setting particular parameters

> note      = makeI nekobee "note"
> duration  = makeF nekobee "duration"
> saw       = makeF nekobee "saw"
> tuning    = makeF nekobee "tuning"
> cutoff    = makeF nekobee "cutoff"
> resonance = makeF nekobee "resonance"
> envmod    = makeF nekobee "envmod"
> decay     = makeF nekobee "decay"
> accent    = makeF nekobee "accent"
> velocity  = makeF nekobee "velocity"
> volume    = makeF nekobee "volume"

> startNeko location = do output <- readProcess location [] ""
>                         return $ read output

> nekoStream client server name location 
>   = do nekoPort <- startNeko location
>        proxyPort <- nekoProxy nekoPort
>        stream client server name "127.0.0.1" proxyPort nekobee