Commit 01ab50 init

12 files Merged and Committed by Richard Marko 2 years ago
init

    
 1 @@ -0,0 +1,30 @@
 2 + Copyright Author name here (c) 2016
 3 + 
 4 + All rights reserved.
 5 + 
 6 + Redistribution and use in source and binary forms, with or without
 7 + modification, are permitted provided that the following conditions are met:
 8 + 
 9 +     * Redistributions of source code must retain the above copyright
10 +       notice, this list of conditions and the following disclaimer.
11 + 
12 +     * Redistributions in binary form must reproduce the above
13 +       copyright notice, this list of conditions and the following
14 +       disclaimer in the documentation and/or other materials provided
15 +       with the distribution.
16 + 
17 +     * Neither the name of Author name here nor the names of other
18 +       contributors may be used to endorse or promote products derived
19 +       from this software without specific prior written permission.
20 + 
21 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
32 \ No newline at end of file
1 @@ -0,0 +1,2 @@
2 + import Distribution.Simple
3 + main = defaultMain
1 @@ -0,0 +1,6 @@
2 + module Main where
3 + 
4 + import Lib
5 + 
6 + main :: IO ()
7 + main = someFunc
 1 @@ -0,0 +1,41 @@
 2 + name:                osc
 3 + version:             0.1.0.0
 4 + synopsis:            Initial project template from stack
 5 + description:         Please see README.md
 6 + homepage:            https://github.com/githubuser/osc#readme
 7 + license:             BSD3
 8 + license-file:        LICENSE
 9 + author:              Author name here
10 + maintainer:          example@example.com
11 + copyright:           2016 Author name here
12 + category:            Web
13 + build-type:          Simple
14 + -- extra-source-files:
15 + cabal-version:       >=1.10
16 + 
17 + library
18 +   hs-source-dirs:      src
19 +   exposed-modules:     Lib
20 +   build-depends:       base >= 4.7 && < 5
21 +   default-language:    Haskell2010
22 + 
23 + executable osc-exe
24 +   hs-source-dirs:      app
25 +   main-is:             Main.hs
26 +   ghc-options:         -threaded -rtsopts -with-rtsopts=-N
27 +   build-depends:       base
28 +                      , osc
29 +   default-language:    Haskell2010
30 + 
31 + test-suite osc-test
32 +   type:                exitcode-stdio-1.0
33 +   hs-source-dirs:      test
34 +   main-is:             Spec.hs
35 +   build-depends:       base
36 +                      , osc
37 +   ghc-options:         -threaded -rtsopts -with-rtsopts=-N
38 +   default-language:    Haskell2010
39 + 
40 + source-repository head
41 +   type:     git
42 +   location: https://github.com/githubuser/osc
 1 @@ -0,0 +1,56 @@
 2 + import Control.Concurrent
 3 + import Control.Monad
 4 + import Network.Socket
 5 + import Sound.OSC.FD
 6 + import Data.Time.Clock
 7 + import Control.Monad.State
 8 + 
 9 + wordsWhen     :: (Char -> Bool) -> String -> [String]
10 + wordsWhen p s =  case dropWhile p s of
11 +                       "" -> []
12 +                       s' -> w : wordsWhen p s''
13 +                             where (w, s'') = break p s'
14 + 
15 + 
16 + sourceHost = "127.0.0.1"
17 + sourcePort = 9000
18 + --targetHost = "172.17.2.32"
19 + --targetHost = "10.0.0.103"
20 + --targetPort = "2333"
21 + 
22 + connectAndSend msg targetHost targetPort = do
23 +   withSocketsDo $ do
24 +     (server:_) <- getAddrInfo Nothing (Just targetHost) (Just targetPort)
25 +     s <- socket (addrFamily server) Datagram defaultProtocol
26 +     connect s (addrAddress server)
27 +     send s msg
28 +     sClose s
29 + 
30 + go msg = do
31 +   print msg
32 +   connectAndSend msg "172.17.3.100" "2333"
33 +   --connectAndSend msg "10.0.0.102" "2333"
34 +   --connectAndSend msg "10.0.0.103" "2333"
35 +   --connectAndSend msg "10.0.0.113" "2333"
36 + 
37 + main = do
38 +   withTransport (t sourceHost sourcePort) f
39 +       where
40 +         f fd = forever $ do
41 +           mmsg <- recvMessage fd
42 +           -- time <- getCurrentTime
43 +           case mmsg of
44 +               Nothing -> return()
45 +               Just msg -> do
46 +                 let r = truncate $ (*255) $ d_float $ head $ messageDatum msg
47 +                 --["0","dmx","0"]
48 +                 let unp = wordsWhen (=='/') $ messageAddress msg
49 +                 let col = read $ unp !! 2
50 +                 let x = min 255 (r * 2)
51 +                 case col of
52 +                   0 -> go $ "go(" ++ (show x) ++ ", 0, 0)\n"
53 +                   1 -> go $ "go(0, " ++ (show x) ++ ", 0)\n"
54 +                   2 -> go $ "go(0, 0, " ++ (show x) ++ ")\n"
55 +                 print msg
56 + 
57 + t ip port = udpServer ip port
 1 @@ -0,0 +1,52 @@
 2 + import Control.Concurrent
 3 + import Control.Monad
 4 + import Network.Socket
 5 + import Sound.OSC.FD
 6 + import Data.Time.Clock
 7 + import Control.Monad.State
 8 + 
 9 + wordsWhen     :: (Char -> Bool) -> String -> [String]
10 + wordsWhen p s =  case dropWhile p s of
11 +                       "" -> []
12 +                       s' -> w : wordsWhen p s''
13 +                             where (w, s'') = break p s'
14 + 
15 + 
16 + sourceHost = "127.0.0.1"
17 + sourcePort = 9001
18 + --targetHost = "172.17.2.32"
19 + --targetHost = "10.0.0.103"
20 + --targetPort = "2333"
21 + 
22 + connectAndSend msg targetHost targetPort = do
23 +   withSocketsDo $ do
24 +     (server:_) <- getAddrInfo Nothing (Just targetHost) (Just targetPort)
25 +     s <- socket (addrFamily server) Datagram defaultProtocol
26 +     connect s (addrAddress server)
27 +     send s msg
28 +     sClose s
29 + 
30 + go msg = do
31 +   print msg
32 +   connectAndSend msg "10.0.0.102" "2333"
33 + 
34 + main = do
35 +   withTransport (t sourceHost sourcePort) f
36 +       where
37 +         f fd = forever $ do
38 +           mmsg <- recvMessage fd
39 +           -- time <- getCurrentTime
40 +           case mmsg of
41 +               Nothing -> return()
42 +               Just msg -> do
43 +                 let r = truncate $ (*255) $ d_float $ head $ messageDatum msg
44 +                 --["0","dmx","0"]
45 +                 let unp = wordsWhen (=='/') $ messageAddress msg
46 +                 let col = read $ unp !! 2
47 +                 case col of
48 +                   0 -> go $ "setr(" ++ (show r) ++ ")\n"
49 +                   1 -> go $ "setg(" ++ (show r) ++ ")\n"
50 +                   2 -> go $ "setb(" ++ (show r) ++ ")\n"
51 +                 print msg
52 + 
53 + t ip port = udpServer ip port
 1 @@ -0,0 +1,52 @@
 2 + import Control.Concurrent
 3 + import Control.Monad
 4 + import Network.Socket
 5 + import Sound.OSC.FD
 6 + import Data.Time.Clock
 7 + import Control.Monad.State
 8 + 
 9 + wordsWhen     :: (Char -> Bool) -> String -> [String]
10 + wordsWhen p s =  case dropWhile p s of
11 +                       "" -> []
12 +                       s' -> w : wordsWhen p s''
13 +                             where (w, s'') = break p s'
14 + 
15 + 
16 + sourceHost = "127.0.0.1"
17 + sourcePort = 9002
18 + --targetHost = "172.17.2.32"
19 + --targetHost = "10.0.0.103"
20 + --targetPort = "2333"
21 + 
22 + connectAndSend msg targetHost targetPort = do
23 +   withSocketsDo $ do
24 +     (server:_) <- getAddrInfo Nothing (Just targetHost) (Just targetPort)
25 +     s <- socket (addrFamily server) Datagram defaultProtocol
26 +     connect s (addrAddress server)
27 +     send s msg
28 +     sClose s
29 + 
30 + go msg = do
31 +   print msg
32 +   connectAndSend msg "10.0.0.100" "2333"
33 + 
34 + main = do
35 +   withTransport (t sourceHost sourcePort) f
36 +       where
37 +         f fd = forever $ do
38 +           mmsg <- recvMessage fd
39 +           -- time <- getCurrentTime
40 +           case mmsg of
41 +               Nothing -> return()
42 +               Just msg -> do
43 +                 let r = truncate $ (*255) $ d_float $ head $ messageDatum msg
44 +                 --["0","dmx","0"]
45 +                 let unp = wordsWhen (=='/') $ messageAddress msg
46 +                 let col = read $ unp !! 2
47 +                 case col of
48 +                   0 -> go $ "a(" ++ (show r) ++ ")\n"
49 +                   1 -> go $ "b(" ++ (show r) ++ ")\n"
50 +                   2 -> go $ "c(" ++ (show r) ++ ")\n"
51 +                 print msg
52 + 
53 + t ip port = udpServer ip port
 1 @@ -0,0 +1,38 @@
 2 + import Control.Concurrent
 3 + import Control.Monad
 4 + import Sound.OSC.FD
 5 + import System.Environment
 6 + import Data.Time.Clock
 7 + 
 8 + {-
 9 + main = 
10 +   let {f fd = forever (recvMessage fd >>= print)
11 +      ;t = udpServer "127.0.0.1" 57300}
12 +   in void (forkIO (withTransport t f))
13 + -}
14 + 
15 + getArgsIp args = 
16 +  if (length args) < 1 
17 +    then "127.0.0.1"
18 +    else (args !! 0)
19 + 
20 + getArgsPort args = 
21 +  if (length args) < 2 
22 +    then 9000
23 +    else (read (args !! 1))
24 + 
25 + main = do
26 +   args <- getArgs
27 +   if (length args) < 2
28 +     then do 
29 +       putStrLn "oscrecv requires 2 args:"
30 +       putStrLn "oscrecv <ip> <port>"
31 +     else do
32 +       withTransport (t (getArgsIp args) (getArgsPort args)) f
33 +       where
34 +         f fd = forever $ do 
35 +           msg <- recvMessage fd
36 +           time <- getCurrentTime
37 +           print $ show time
38 +           print msg
39 + t ip port = udpServer ip port 
 1 @@ -0,0 +1,54 @@
 2 + import Control.Concurrent
 3 + import Control.Monad
 4 + import Network.Socket
 5 + import Sound.OSC.FD
 6 + import Data.Time.Clock
 7 + import Control.Monad.State
 8 + 
 9 + wordsWhen     :: (Char -> Bool) -> String -> [String]
10 + wordsWhen p s =  case dropWhile p s of
11 +                       "" -> []
12 +                       s' -> w : wordsWhen p s''
13 +                             where (w, s'') = break p s'
14 + 
15 + 
16 + sourceHost = "127.0.0.1"
17 + sourcePort = 9001
18 + --targetHost = "172.17.2.32"
19 + --targetHost = "10.0.0.103"
20 + --targetPort = "2333"
21 + 
22 + connectAndSend msg targetHost targetPort = do
23 +   withSocketsDo $ do
24 +     (server:_) <- getAddrInfo Nothing (Just targetHost) (Just targetPort)
25 +     s <- socket (addrFamily server) Datagram defaultProtocol
26 +     connect s (addrAddress server)
27 +     send s msg
28 +     sClose s
29 + 
30 + go msg = do
31 +   print msg
32 +   connectAndSend msg "10.0.0.104" "2333"
33 + 
34 + main = do
35 +   withTransport (t sourceHost sourcePort) f
36 +       where
37 +         f fd = forever $ do
38 +           mmsg <- recvMessage fd
39 +           -- time <- getCurrentTime
40 +           case mmsg of
41 +               Nothing -> return()
42 +               Just msg -> do
43 +                 let r = truncate $ (*255) $ d_float $ head $ messageDatum msg
44 +                 --["0","dmx","0"]
45 +                 let unp = wordsWhen (=='/') $ messageAddress msg
46 +                 let col = read $ unp !! 2
47 +                 let x = min 255 (r * 2)
48 +                 case col of
49 +                   0 -> go $ "go(" ++ (show x) ++ ")\n"
50 +                   1 -> go $ "b = " ++ (show x) ++ "\n"
51 +                   2 -> go $ "g = " ++ (show x) ++ "\n"
52 +                   3 -> go $ "r = " ++ (show x) ++ "\n"
53 +                 print msg
54 + 
55 + t ip port = udpServer ip port
1 @@ -0,0 +1,6 @@
2 + module Lib
3 +     ( someFunc
4 +     ) where
5 + 
6 + someFunc :: IO ()
7 + someFunc = putStrLn "someFunc"
 1 @@ -0,0 +1,69 @@
 2 + # This file was automatically generated by 'stack init'
 3 + # 
 4 + # Some commonly used options have been documented as comments in this file.
 5 + # For advanced use and comprehensive documentation of the format, please see:
 6 + # http://docs.haskellstack.org/en/stable/yaml_configuration/
 7 + 
 8 + # Resolver to choose a 'specific' stackage snapshot or a compiler version.
 9 + # A snapshot resolver dictates the compiler version and the set of packages
10 + # to be used for project dependencies. For example:
11 + # 
12 + # resolver: lts-3.5
13 + # resolver: nightly-2015-09-21
14 + # resolver: ghc-7.10.2
15 + # resolver: ghcjs-0.1.0_ghc-7.10.2
16 + # resolver:
17 + #  name: custom-snapshot
18 + #  location: "./custom-snapshot.yaml"
19 + resolver: nightly-2016-07-13
20 + 
21 + # User packages to be built.
22 + # Various formats can be used as shown in the example below.
23 + # 
24 + # packages:
25 + # - some-directory
26 + # - https://example.com/foo/bar/baz-0.0.2.tar.gz
27 + # - location:
28 + #    git: https://github.com/commercialhaskell/stack.git
29 + #    commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
30 + # - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a
31 + #   extra-dep: true
32 + #  subdirs:
33 + #  - auto-update
34 + #  - wai
35 + # 
36 + # A package marked 'extra-dep: true' will only be built if demanded by a
37 + # non-dependency (i.e. a user package), and its test suites and benchmarks
38 + # will not be run. This is useful for tweaking upstream packages.
39 + packages:
40 + - '.'
41 +   #- pipes-process
42 +   #- pipes-shell-0.1.4
43 +   #- pipes-cliff-0.10.0.4
44 + # Dependency packages to be pulled from upstream that are not in the resolver
45 + # (e.g., acme-missiles-0.3)
46 + extra-deps: #[]
47 + 
48 + # Override default flag values for local packages and extra-deps
49 + flags: {}
50 + 
51 + # Extra package databases containing global packages
52 + extra-package-dbs: []
53 + 
54 + # Control whether we use the GHC we find on the path
55 + # system-ghc: true
56 + # 
57 + # Require a specific version of stack, using version ranges
58 + # require-stack-version: -any # Default
59 + # require-stack-version: ">=1.1"
60 + # 
61 + # Override the architecture used by stack, especially useful on Windows
62 + # arch: i386
63 + # arch: x86_64
64 + # 
65 + # Extra directories used by stack for building
66 + # extra-include-dirs: [/path/to/dir]
67 + # extra-lib-dirs: [/path/to/dir]
68 + # 
69 + # Allow a newer minor version of GHC than the snapshot specifies
70 + # compiler-check: newer-minor
1 @@ -0,0 +1,2 @@
2 + main :: IO ()
3 + main = putStrLn "Test suite not yet implemented"