File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ package sc
2
+
3
+ import (
4
+ "fmt"
5
+ "os/exec"
6
+ "strconv"
7
+ )
8
+
9
+ // Server represents a running instance of scsynth.
10
+ type Server struct {
11
+ * exec.Cmd
12
+
13
+ Network string
14
+ Port int
15
+ }
16
+
17
+ // args gets the command line args to scsynth
18
+ func (s * Server ) args () ([]string , error ) {
19
+ args := []string {}
20
+
21
+ var (
22
+ portArg = strconv .FormatInt (int64 (s .Port ), 10 )
23
+ )
24
+ switch s .Network {
25
+ default :
26
+ return nil , fmt .Errorf ("unrecognized network type: %s" , s .Network )
27
+ case "udp" :
28
+ args = append (args , "-u" , portArg )
29
+ case "tcp" :
30
+ args = append (args , "-t" , portArg )
31
+ }
32
+
33
+ return args , nil
34
+ }
35
+
36
+ // Start starts a new instance of scsynth.
37
+ func (s * Server ) Start () error {
38
+ args , err := s .args ()
39
+ if err != nil {
40
+ return err
41
+ }
42
+ s .Cmd = exec .Command (ServerPath , args ... )
43
+ return s .Cmd .Start ()
44
+ }
45
+
46
+ // Stop stops a running server.
47
+ func (s * Server ) Stop () error {
48
+ return s .Process .Kill ()
49
+ }
Original file line number Diff line number Diff line change
1
+ // +build darwin
2
+ package sc
3
+
4
+ const ServerPath = "/Applications/SuperCollider.app/Contents/Resources/scsynth"
You can’t perform that action at this time.
0 commit comments