func TestDecodeFileWithError(t *testing.T) { _, err := drum.DecodeFile("no-such-file") if err == nil { t.Fatalf("no error from Decode: expected no-such-file error") } if !os.IsNotExist(err) { t.Fatalf("unexpected error; got %q; expected not-found error", err) } }
func TestDecodeFile(t *testing.T) { f, err := ioutil.TempFile("", "") if err != nil { t.Fatalf("cannot make temp file: %v", err) } defer f.Close() defer os.Remove(f.Name()) test := decodeTests[0] _, err = f.Write(undump(test.data)) if err != nil { t.Fatalf("cannot make temp file: %v", err) } p, err := drum.DecodeFile(f.Name()) if err != nil { t.Fatalf("cannot decode file: %v", err) } output := p.String() if output != test.expectOutput { t.Fatalf("unexpected output\nGot\n%s\nWant\n%s\n", output, test.expectOutput) } }
func main() { flag.Usage = func() { fmt.Fprint(os.Stderr, usage) flag.PrintDefaults() os.Exit(2) } flag.Parse() if flag.NArg() != 1 { flag.Usage() } p, err := drum.DecodeFile(flag.Arg(0)) if err != nil { log.Fatalf("cannot decode splice file: %v", err) } if *showInfo { fmt.Print(p) return } patches, err := readPatches(p, *sampleDir) if err != nil { log.Fatalf("cannot read sample patches: %v", err) } drumMod, err := drummachine.New(p, patches) if err != nil { log.Fatalf("cannot make new drum machine: %v", err) } portaudio.Initialize() defer portaudio.Terminate() portmidi.Initialize() defer portmidi.Terminate() e := audio.NewEngine() e.Input("in", drumMod) if err := e.Start(); err != nil { panic(err) } select {} }