Liam Staskawicz avatar Liam Staskawicz committed 9144fcc

more docs, and link to http://go.pkgdoc.org in ReadMe

Comments (0)

Files changed (3)

 
 Pure Go (http://golang.org) support for OSC (http://opensoundcontrol.org)
 
+Docs are available at [http://go.pkgdoc.org/bitbucket.org/liamstask/gosc](http://go.pkgdoc.org/bitbucket.org/liamstask/gosc)
 
 ## Install
 
 
 ## Example
     :::go
-        import (
-    	    "bitucket.org/liamstask/gosc"
-            "net"
-        )
+    import (
+	    "bitucket.org/liamstask/gosc"
+        "net"
+    )
 	
-        m := &osc.Message{Address: "/my/message"}
-        m.Args = append(m.Args, int32(12345))
-        m.Args = append(m.Args, "important")
+    m := &osc.Message{Address: "/my/message"}
+    m.Args = append(m.Args, int32(12345))
+    m.Args = append(m.Args, "important")
 	
-        // error checking omitted for brevity...
-    	addr, _ := net.ResolveUDPAddr("udp", "127.0.0.1:12000")
-    	conn, _ := net.DialUDP("udp", nil, addr)
-
-    	numbytes, err := m.WriteTo(conn)
-    	if err != nil {
-    		// handle error
-    	}
+    // error checking omitted for brevity...
+	addr, _ := net.ResolveUDPAddr("udp", "127.0.0.1:12000")
+	conn, _ := net.DialUDP("udp", nil, addr)
+
+	numbytes, err := m.WriteTo(conn)
+	if err != nil {
+		// handle error
+	}
 	
 See the tests for more detailed usage.
 
+// gosc provides a pure Go package for sending and receiving OpenSoundControl
+// messages.
+//
+// Sending messages is a matter of writing a Message to the appropriate
+// io.Writer (net/UDPConn is a common transport), and a simple UDPServer
+// is provided for receiving Messages.
+//
+// Address pattern matching is also supported.
+//
+// See the OSC spec at http://opensoundcontrol.org/spec-1_0 for more detail.
+//
 package osc
 
 import (
 	secondsFrom1900To1970 = 2208988800
 )
 
+// A single OSC message.
+// Args is a slice of arguments, each of which may be one of
+// the following types: int32, float32, string, bool, nil,
+// or []byte (ie, an OSC 'blob')
 type Message struct {
 	Address string
 	Args    []interface{}
 }
 
+// A collection of OSC Messages.
+// It's often more efficient to send multiple messages as a Bundle
+// as they can all be included in the same transmission to the receiver.
 type Bundle struct {
 	Timetag  time.Time
 	Messages []*Message
 }
 
-// WriteTo writes m to w.
+// WriteTo writes b to w.
 func (b *Bundle) WriteTo(w io.Writer) (n int, err error) {
 
 	writer := bufio.NewWriter(w)
 		return 0, err
 	}
 
-	n = 16
+	n = 16 // 8 bytes of "#bundle" and 8 bytes of timetag
 
 	// each message must be preceded by its int32 length
 	for _, m := range b.Messages {
 	return bndl, errors.New("packets must start with '/' or '#'")
 }
 
-// Equal returns a boolean reporting whether a == b.
+// Equal returns a boolean reporting whether a == b, by comparing
+// the Address and the contents of all Args
 func Equal(a, b *Message) bool {
 
 	if a.Address != b.Address {
 	"strings"
 )
 
+// Determines whether pattern (typically the Address of an
+// incoming Message) matches test (typically the Address of a registered
+// handler).
+//
+// Pattern matching semantics are described in the OSC spec
+// (http://opensoundcontrol.org/spec-1_0) in the section entitled
+// "OSC Message Dispatching and Pattern Matching".
+//
 func PatternMatch(pattern, test string) bool {
 
 	// indexes into our strings
 			itest++
 
 		case '{':
+			// implement me
 			return false
 
 		case '\\':
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.