...
 
Commits (2)
package main
import (
"bufio"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"jacobvosmaer.nl/go/dx7"
)
const (
dataSize = 4096
voiceSize = 128
)
func main() {
data, err := ioutil.ReadAll(io.LimitReader(os.Stdin, dataSize+1))
if err != nil {
log.Fatal(err)
}
if len(data) > dataSize {
log.Fatalf("read more than %d bytes from stdin", dataSize)
}
if l := len(data); l%voiceSize != 0 {
log.Fatalf("number of input bytes %d not divisible by voice size %d", l, voiceSize)
}
for len(data) < dataSize {
data = append(data, dx7.InitVoice[:]...)
}
w := bufio.NewWriter(os.Stdout)
fmt.Fprintf(w, "\xf0\x43\x00\x09\x20\x00")
w.Write(data)
w.Write([]byte{dx7.Checksum(data), dx7.EOSysex})
if err := w.Flush(); err != nil {
log.Fatal(err)
}
}
......@@ -10,6 +10,7 @@ import (
const (
MinMessageLength = 4
EOSysex = 0xf7
)
func IsMk1(msg []byte) bool {
......@@ -47,7 +48,7 @@ func SplitMessages(r io.Reader) ([][]byte, error) {
var err error
for {
var msg []byte
msg, err = in.ReadBytes(0xf7)
msg, err = in.ReadBytes(EOSysex)
l := len(msg)
if err != nil || l == 0 {
break
......
package dx7
var InitVoice = [128]byte{
0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x00, 0x27, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x02, 0x00, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x00, 0x27, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x02, 0x00, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x00, 0x27, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x02, 0x00, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x00, 0x27, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x02, 0x00, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x00, 0x27, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x02, 0x00, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x00, 0x27, 0x00, 0x00, 0x00, 0x38, 0x00, 0x63, 0x02, 0x00, 0x63, 0x63, 0x63, 0x63, 0x32, 0x32, 0x32, 0x32, 0x00, 0x08, 0x23, 0x00, 0x00, 0x00, 0x31, 0x18, 0x49, 0x4e, 0x49, 0x54, 0x20, 0x56, 0x4f, 0x49, 0x43, 0x45,
}