Skip to content
/ go-osc Public
forked from hypebeast/go-osc

Open Sound Control (OSC) library for Golang. Implemented in pure Go.

License

Notifications You must be signed in to change notification settings

gpayer/go-osc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoOSC

This is a fork from github.com/hypebeast/go-osc to make sure my PR is directly usable.

GoDoc Go Report Card

Open Sound Control (OSC) library for Golang. Implemented in pure Go.

Features

  • OSC Bundles, including timetags
  • OSC Messages
  • OSC Client
  • OSC Server
  • Supports the following OSC argument types:
    • 'i' (Int32)
    • 'f' (Float32)
    • 's' (string)
    • 'b' (blob / binary data)
    • 'h' (Int64)
    • 't' (OSC timetag)
    • 'd' (Double/int64)
    • 'T' (True)
    • 'F' (False)
    • 'N' (Nil)
  • Support for OSC address pattern including '*', '?', '{,}' and '[]' wildcards

Install

go get github.com/gpayer/go-osc

Usage

Client

package main

import "github.com/gpayer/go-osc/osc"

func main() {
    client := osc.NewClient("localhost", 8765)
    defer client.Close()
    msg := osc.NewMessage("/osc/address")
    msg.Append(int32(111))
    msg.Append(true)
    msg.Append("hello")
    client.Send(msg)
}

Client with response handling

package main

import "github.com/gpayer/go-osc/osc"

func main() {
    finished := make(chan struct{})

    client := osc.NewClient("localhost", 8765)
    defer client.Close()
    
    d := osc.NewStandardDispatcher()
    d.AddMsgHandler("/reply", func(msg *osc.Message) {
        osc.PrintMessage(msg)
        finished <- struct{}{}
    })
    client.SetDispatcher(d)
    go client.ListenAndServe()

    msg := osc.NewMessage("/message/address")
    client.Send(msg)

    <-finished
}

Server

package main

import "github.com/gpayer/go-osc/osc"

func main() {
    var server *osc.Server
    addr := "127.0.0.1:8765"
    d := osc.NewStandardDispatcher()
    d.AddMsgHandler("/message/address", func(msg *osc.Message) {
        osc.PrintMessage(msg)
        server.SendTo(osc.NewMessage("/reply"), msg.SenderAddr())
    })

    server = &osc.Server{
        Addr: addr,
        Dispatcher:d,
    }
    server.ListenAndServe()
}

Tests

make test

About

Open Sound Control (OSC) library for Golang. Implemented in pure Go.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 98.1%
  • Makefile 1.9%