Example #1
0
// TODO: Revise the client!
func main() {
	ip := "localhost"
	port := 8000
	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("# ")
	}
}
Example #2
0
func TestV01Parse(t *testing.T) {
	for _, tt := range []parseTest{
		{"thGain",
			"/venue/0.1/th/soundcheck/input/gain/1/3",
			[]interface{}{},
			&venue.Packet{
				Ctrl:   venue.CtrlInput,
				Cmd:    venue.CmdGain,
				Val:    venue.ValInteger,
				IntVal: -1,
			},
			true},
	} {
		msg := osc.NewMessage(tt.addr)
		for _, v := range tt.val {
			msg.Append(v)
		}

		pkt, err := parse(msg)
		if err != nil && tt.ok {
			t.Errorf("%s: unexpected error: %v", tt.name, err)
		}
		if err == nil && !tt.ok {
			t.Errorf("%s: expected error", tt.name)
		}
		if !tt.ok {
			continue
		}
		if !pkt.Equal(*tt.pkt) {
			t.Errorf("%s: packets not equal; got = %v, want = %v", tt.name, pkt, tt.pkt)
		}
	}
}
Example #3
0
func main() {
	flagInit()

	var msg *osc.Message

	client := osc.NewClient(host, port)

	msg = osc.NewMessage(base + "/output/select/1/1")
	msg.Append(float32(1))
	msg.Append(float32(0))
	client.Send(msg)
	msg = osc.NewMessage(base + "/output/pan")
	msg.Append(float32(10))
	client.Send(msg)

	msg = osc.NewMessage(base + "/output/select/1/2")
	msg.Append(float32(1))
	msg.Append(float32(0))
	client.Send(msg)
	msg = osc.NewMessage(base + "/output/pan")
	msg.Append(float32(-20))
	client.Send(msg)
}