Skip to content

Instantly share code, notes, and snippets.

@ZachMassia
Last active December 20, 2015 08:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZachMassia/6102466 to your computer and use it in GitHub Desktop.
Save ZachMassia/6102466 to your computer and use it in GitHub Desktop.
type Message struct {
type string
midiData [3]byte
sysexData[255]byte
sysexLen int
}
func NewBoard() *Board {
b := &Board{}
// Start the message loops
out := Read()
messages := Parse(out)
go HandleMessages(messages)
return b
}
func Read() <-chan byte {
buf := make([]byte, 1)
out := make(chan byte)
go func() {
for {
Read(buf)
out <- buf[0]
}
}()
return out
}
func Parse(in <-chan byte) <-chan Message {
out := make(chan Message)
go func() {
for inByte := range in {
// parse into message
out <- parseMsg
}
}()
return out
}
func HandleMessages(in <-chan Message) {
for {
// handle messages
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment