remove OSC prefix from types

This commit is contained in:
Joel Wetzell
2026-09-10 08:30:59 -05:00
parent 303a782a74
commit 3f656a2349
10 changed files with 165 additions and 165 deletions
+13 -13
View File
@@ -52,11 +52,11 @@ func main() {
}
}
func argToTypedArg(rawArg string, oscType string) osc.OSCArg {
func argToTypedArg(rawArg string, oscType string) osc.Arg {
switch oscType {
case "s":
return osc.OSCArg{
return osc.Arg{
Value: rawArg,
Type: "s",
}
@@ -66,7 +66,7 @@ func argToTypedArg(rawArg string, oscType string) osc.OSCArg {
// ... handle error
panic(err)
}
return osc.OSCArg{
return osc.Arg{
Value: int32(number),
Type: "i",
}
@@ -76,7 +76,7 @@ func argToTypedArg(rawArg string, oscType string) osc.OSCArg {
// ... handle error
panic(err)
}
return osc.OSCArg{
return osc.Arg{
Value: float32(number),
Type: "f",
}
@@ -86,7 +86,7 @@ func argToTypedArg(rawArg string, oscType string) osc.OSCArg {
// ... handle error
panic(err)
}
return osc.OSCArg{
return osc.Arg{
Value: data,
Type: "b",
}
@@ -96,7 +96,7 @@ func argToTypedArg(rawArg string, oscType string) osc.OSCArg {
// ... handle error
panic(err)
}
return osc.OSCArg{
return osc.Arg{
Value: int64(number),
Type: "h",
}
@@ -106,29 +106,29 @@ func argToTypedArg(rawArg string, oscType string) osc.OSCArg {
// ... handle error
panic(err)
}
return osc.OSCArg{
return osc.Arg{
Value: float64(number),
Type: "d",
}
case "T":
return osc.OSCArg{
return osc.Arg{
Value: true,
Type: "T",
}
case "F":
return osc.OSCArg{
return osc.Arg{
Value: false,
Type: "F",
}
case "N":
return osc.OSCArg{
return osc.Arg{
Value: nil,
Type: "N",
}
default:
fmt.Printf("unsupported OSC arg type: %s\n", oscType)
// TODO(jwetzell): something better than this like actual nil, err thing
return osc.OSCArg{}
return osc.Arg{}
}
}
@@ -157,9 +157,9 @@ func slipEncode(bytes []byte) []byte {
func makeMsg(address string, args []string, types []string, slip bool) {
oscMessage := osc.OSCMessage{
oscMessage := osc.Message{
Address: address,
Args: []osc.OSCArg{},
Args: []osc.Arg{},
}
for index, arg := range args {
+7 -7
View File
@@ -102,7 +102,7 @@ func listenTCP(netAddress string, useSLIP bool, format string) {
type SLIP struct {
pendingBytes []byte
Packets chan osc.OSCPacket
Packets chan osc.Packet
}
func (s *SLIP) decode(bytes []byte) {
@@ -155,7 +155,7 @@ func handleSLIP(slip SLIP, format string) {
func handleTCPConnection(conn net.Conn, useSLIP bool, format string) {
slip := SLIP{
pendingBytes: []byte{},
Packets: make(chan osc.OSCPacket),
Packets: make(chan osc.Packet),
}
go handleSLIP(slip, format)
@@ -177,17 +177,17 @@ func handleTCPConnection(conn net.Conn, useSLIP bool, format string) {
}
}
func handlePacket(message osc.OSCPacket, format string) {
if bundle, ok := message.(*osc.OSCBundle); ok {
func handlePacket(message osc.Packet, format string) {
if bundle, ok := message.(*osc.Bundle); ok {
handleBundle(bundle, format)
} else if msg, ok := message.(*osc.OSCMessage); ok {
} else if msg, ok := message.(*osc.Message); ok {
handleMessage(msg, format)
} else {
fmt.Println("Received unknown OSC Packet type")
}
}
func handleMessage(message *osc.OSCMessage, format string) {
func handleMessage(message *osc.Message, format string) {
if format == "json" {
jsonData, _ := json.Marshal(message)
fmt.Println(string(jsonData))
@@ -196,7 +196,7 @@ func handleMessage(message *osc.OSCMessage, format string) {
}
}
func handleBundle(bundle *osc.OSCBundle, format string) {
func handleBundle(bundle *osc.Bundle, format string) {
for _, packet := range bundle.Contents {
handlePacket(packet, format)
}
+13 -13
View File
@@ -80,11 +80,11 @@ func main() {
}
}
func argToTypedArg(rawArg string, oscType string) osc.OSCArg {
func argToTypedArg(rawArg string, oscType string) osc.Arg {
switch oscType {
case "s":
return osc.OSCArg{
return osc.Arg{
Value: rawArg,
Type: "s",
}
@@ -94,7 +94,7 @@ func argToTypedArg(rawArg string, oscType string) osc.OSCArg {
// ... handle error
panic(err)
}
return osc.OSCArg{
return osc.Arg{
Value: int32(number),
Type: "i",
}
@@ -104,7 +104,7 @@ func argToTypedArg(rawArg string, oscType string) osc.OSCArg {
// ... handle error
panic(err)
}
return osc.OSCArg{
return osc.Arg{
Value: float32(number),
Type: "f",
}
@@ -114,7 +114,7 @@ func argToTypedArg(rawArg string, oscType string) osc.OSCArg {
// ... handle error
panic(err)
}
return osc.OSCArg{
return osc.Arg{
Value: data,
Type: "b",
}
@@ -124,7 +124,7 @@ func argToTypedArg(rawArg string, oscType string) osc.OSCArg {
// ... handle error
panic(err)
}
return osc.OSCArg{
return osc.Arg{
Value: int64(number),
Type: "h",
}
@@ -134,29 +134,29 @@ func argToTypedArg(rawArg string, oscType string) osc.OSCArg {
// ... handle error
panic(err)
}
return osc.OSCArg{
return osc.Arg{
Value: float64(number),
Type: "d",
}
case "T":
return osc.OSCArg{
return osc.Arg{
Value: true,
Type: "T",
}
case "F":
return osc.OSCArg{
return osc.Arg{
Value: false,
Type: "F",
}
case "N":
return osc.OSCArg{
return osc.Arg{
Value: nil,
Type: "N",
}
default:
fmt.Printf("unsupported OSC arg type: %s\n", oscType)
// TODO(jwetzell): something better than this like actual nil, err thing
return osc.OSCArg{}
return osc.Arg{}
}
}
@@ -185,9 +185,9 @@ func slipEncode(bytes []byte) []byte {
func send(host string, port int32, address string, args []string, types []string, protocol string, slip bool) {
oscMessage := osc.OSCMessage{
oscMessage := osc.Message{
Address: address,
Args: []osc.OSCArg{},
Args: []osc.Arg{},
}
for index, arg := range args {