This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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