diff --git a/sclang-play/oscfun.go b/sclang-play/oscfun.go new file mode 100644 index 0000000..d0df19d --- /dev/null +++ b/sclang-play/oscfun.go @@ -0,0 +1,43 @@ +package main + +import ( + "fmt" + "net" + + "github.com/hypebeast/go-osc/osc" +) + +func main() { + // client := osc.NewClient("localhost", 9949) + msg := osc.NewMessage("/osc/address") + msg.Append(int32(111)) + msg.Append(true) + msg.Append("hello") + + fmt.Printf("Sending: %#v\n", msg) + // err := client.Send(msg) + err := sendTCP(msg) + if err != nil { + fmt.Printf("ERROR: %#v\n", err) + } +} + +func sendTCP(packet osc.Packet) error { + conn, err := net.Dial("tcp", "127.0.0.1:9949") + if err != nil { + return err + } + defer conn.Close() + + data, err := packet.ToByteArray() + if err != nil { + return err + } + + _, err = conn.Write(data) + if err != nil { + return err + } + + return nil +} diff --git a/sclang-play/oscfun.sc b/sclang-play/oscfun.sc new file mode 100644 index 0000000..4d7c5b8 --- /dev/null +++ b/sclang-play/oscfun.sc @@ -0,0 +1,40 @@ +( + n = NetAddr("127.0.0.1", 8765); + n.sendMsg("/good/news", "haaay"); +) + +( + f = { |msg, time, addr| + if((addr.port == 8765) && (msg[0] != '/status.reply'), { + "time: % sender: %\nmessage: %\n".postf(time, addr, msg); + }); + }; + thisProcess.addOSCRecvFunc(f); +) + +( + thisProcess.replaceOSCRecvFunc(f, f); +) + +( + thisProcess.removeOSCRecvFunc(f); +) + +( + thisProcess.openUDPPort(1121); +) + +( + thisProcess.stop; +) + +( + thisProcess.openPorts; +) + +( + // OSCFunc.trace(false); + s.quit; + s.boot; + // OSCFunc.trace(true); +) diff --git a/sclang-play/tutorial.sc b/sclang-play/tutorial.sc index f12b04b..8b34540 100644 --- a/sclang-play/tutorial.sc +++ b/sclang-play/tutorial.sc @@ -38,6 +38,12 @@ }.play; ) +( + { + Pan2.ar(SinOsc.ar(440, 0, 0.2), SinOsc.kr(0.5)); + }.play; +) + ( { Pan2.ar(PinkNoise.ar(0.2), -0.3); @@ -221,7 +227,7 @@ 1.wait; z = Synth("tutorial-args", ["freq", 880, "out", 1]); 1.wait; - x.free; y.free; z.free; + //x.free; y.free; z.free; }).play; ) @@ -240,6 +246,6 @@ 1.wait; x.set(\freq, 880, \out, 1); 1.wait; - x.free; + //x.free; }).play; )