// TODO: Revise the client! func main() { ip := "localhost" port := 8765 client := osc.NewClient(ip, port) fmt.Println("### Welcome to go-osc transmitter demo") fmt.Println("Please, select the OSC packet type you would like to send:") fmt.Println("\tm: OSCMessage") fmt.Println("\tb: OSCBundle") fmt.Println("\tPress \"q\" to exit") fmt.Printf("# ") reader := bufio.NewReader(os.Stdin) for { line, err := reader.ReadBytes('\n') if err == io.EOF { break } if err != nil { fmt.Println("Error: " + err.Error()) os.Exit(1) } sline := strings.TrimRight(string(line), "\n") if sline == "m" { message := osc.NewMessage("/message/address") message.Append(int32(12345)) message.Append("teststring") message.Append(true) message.Append(false) client.Send(message) } else if sline == "b" { bundle := osc.NewBundle(time.Now()) message1 := osc.NewMessage("/bundle/message/1") message1.Append(int32(12345)) message1.Append("teststring") message1.Append(true) message1.Append(false) message2 := osc.NewMessage("/bundle/message/2") message2.Append(int32(3344)) message2.Append(float32(101.9)) message2.Append("string1") message2.Append("string2") message2.Append(true) bundle.Append(message1) bundle.Append(message2) client.Send(bundle) } else if sline == "q" { fmt.Println("Exit!") os.Exit(0) } fmt.Printf("# ") } }
func sendMelodyMessage(client *osc.Client, level int, pitch int, offbeat int, instrument string) { msg := osc.NewMessage("/instrument/" + instrument) msg.Append(int32(level)) msg.Append(int32(pitch)) msg.Append(int32(offbeat)) client.Send(msg) }
func sendMelodyMessage(client *osc.Client, level int, speed int, offbeat int, instrument string) { msg := osc.NewMessage("/instrument/" + instrument) fmt.Println("sending", level, ",", speed, ",", offbeat, "to", instrument) msg.Append(int32(level)) msg.Append(int32(speed)) client.Send(msg) }
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 main() { addr := "0.0.0.0:8765" server := &osc.Server{Addr: addr} server.Handle("/register", register) go server.ListenAndServe() for _ = range time.Tick(time.Second) { for _, c := range clients { msg := osc.NewMessage("/make-cube") msg.Append(true) c.Send(msg) } } }
func sendDelayMessage(client *osc.Client, value int) { msg := osc.NewMessage("/instrument/delay") msg.Append(int32(value)) //fmt.Println("sending delay", value) client.Send(msg) }
func testMessage(client *osc.Client) { msg := osc.NewMessage("/metro") client.Send(msg) }
func sendMessage(client *osc.Client, level int, offbeat int, instrument string) { fmt.Println("sending:", level, ",", offbeat, "to:", instrument) msg := osc.NewMessage("/instrument/" + instrument) msg.Append(int32(level)) client.Send(msg) }