-- printer-jam.hs :set -package hosc :set -package bytestring :set -XOverloadedStrings :set prompt "" import qualified Data.ByteString.Char8 as ByteString.Char8 {- bytestring -} import Sound.Tidal.Context import Sound.Osc.Fd as O -- type Ascii = ByteString.Char8.ByteString -- :{ -- ascii_to_controlPattern :: O.Ascii -> ControlPattern -- ascii_to_controlPattern = -- :} import System.IO (hSetEncoding, stdout, utf8) hSetEncoding stdout utf8 :{ let printerTarget = Target {oName = "printer", -- A friendly name for the target oAddress = "192.168.1.171", -- The target's network address oPort = 10000, -- The network port the target is listening on oLatency = 0.2, -- smooth out network jitter oSchedule = Live, -- The scheduling method oWindow = Nothing, -- Not yet used oHandshake = False, -- SuperDirt specific oBusPort = Nothing -- Also SuperDirt specific } printerFormats = [OSC "/{device}/{motor}/{action}" $ ArgList [("action", Just $ VS "f")], OSC "/{device}/{motor}/speed" $ ArgList [("speed", Just $ VF 0)], OSC "/{device}/{action}" $ ArgList [("action", Just $ VS "f")], OSC "/{device}/mode" $ ArgList [("mode", Just $ VI 1)], OSC "/{device}/steps" $ ArgList [("steps", Just $ VF 0)], OSC "/{device}/rpm" $ ArgList [("rpm", Just $ VF 0)]] -- OSC "/stopall" $ ArgList [("stop", Just $ VS "printer")]] -- ("speed", Just $ VI 0), -- ("action", Just $ VS "r") action = pS "action" device = pS "device" motor = pS "motor" speed = pF "speed" mode = pI "mode" steps = pF "steps" rpm = pF "rpm" oscmap = [(printerTarget, printerFormats)] :} tidal <- startStream (defaultConfig {cCtrlAddr = "0.0.0.0", cCtrlPort = 6060}) oscmap :{ let p1 = streamReplace tidal 1 p2 = streamReplace tidal 2 p3 = streamReplace tidal 3 p4 = streamReplace tidal 4 :} :set prompt "tidal> " :set prompt-cont ""