-
Notifications
You must be signed in to change notification settings - Fork 0
/
stenome.go
56 lines (47 loc) · 975 Bytes
/
stenome.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
import (
"fmt"
"os"
"davidb.org/x/stenome/gen"
"davidb.org/x/stenome/learn"
"davidb.org/x/stenome/timelearn"
)
func main() {
if len(os.Args) != 3 {
fmt.Printf("Usage: stenome [run|gen] lesson.db\n")
return
}
if os.Args[1] == "gen" {
// If the file exists, open, otherwise create it.
_, err := os.Stat(os.Args[2])
var tl *timelearn.T
if err == nil {
tl, err = timelearn.Open(os.Args[2])
} else {
tl, err = timelearn.Create(os.Args[2], "midi")
}
if err != nil {
fmt.Printf("Error opening database: %q\n", err)
return
}
err = gen.GenScales(tl)
if err != nil {
fmt.Printf("Error generating scales: %q\n", err)
return
}
return
}
if os.Args[1] != "run" {
fmt.Printf("Unknown command\n")
return
}
tl, err := timelearn.Open(os.Args[2])
if err != nil {
fmt.Printf("Error with database: %q\n", err)
return
}
err = learn.Drill(tl)
if err != nil {
fmt.Printf("Error learning: %q\n", err)
}
}