forked from schollz/PIanoAI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
126 lines (115 loc) · 2.73 KB
/
main.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package main
import (
"fmt"
"os"
"time"
"github.com/schollz/pianoai/ai2"
"github.com/schollz/pianoai/player"
"github.com/urfave/cli"
)
var version string
func main() {
app := cli.NewApp()
app.Version = version
app.Compiled = time.Now()
app.Name = "pianoai"
app.Flags = []cli.Flag{
cli.IntFlag{
Name: "bpm",
Value: 120,
Usage: "BPM to use",
},
cli.IntFlag{
Name: "tick",
Value: 500,
Usage: "tick frequency in hertz",
},
cli.IntFlag{
Name: "hp",
Value: 65,
Usage: "high pass note threshold to use for leraning",
},
cli.IntFlag{
Name: "waits",
Value: 2,
Usage: "beats of silence before AI jumps in",
},
cli.IntFlag{
Name: "quantize",
Value: 64,
Usage: "1/quantize is shortest possible note",
},
cli.StringFlag{
Name: "file,f",
Value: "music_history.json",
Usage: "file save/load to when pressing bottom C",
},
cli.BoolFlag{
Name: "debug",
Usage: "debug mode",
},
cli.BoolFlag{
Name: "manual",
Usage: "AI is activated manually",
},
cli.IntFlag{
Name: "link",
Value: 3,
Usage: "AI LinkLength",
},
cli.BoolFlag{
Name: "jazzy",
Usage: "AI Jazziness",
},
cli.BoolFlag{
Name: "stacatto",
Usage: "AI Stacattoness",
},
cli.BoolFlag{
Name: "chords",
Usage: "AI Allow chords",
},
cli.BoolFlag{
Name: "follow",
Usage: "AI velocities follow the host",
},
}
app.Action = func(c *cli.Context) (err error) {
fmt.Println(`
______ _____ ___ _____
| ___ \_ _| / _ \|_ _|
| |_/ / | | __ _ _ __ ___ / /_\ \ | |
| __/ | | / _` + "`" + ` | '_ \ / _ \| _ | | |
| | _| || (_| | | | | (_) | | | |_| |_
\_| \___/\__,_|_| |_|\___/\_| |_/\___/
_______________________________________
| | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | |
| |_| |_| | |_| |_| |_| | |_| |_| |
| | | | | | | | | | |
| | | | | | | | | | |
|___|___|___|___|___|___|___|___|___|___|
Lets play some music!
`)
p, err := player.New(c.GlobalInt("bpm"), c.GlobalInt("tick"), c.GlobalBool("debug"))
if err != nil {
return
}
p.HighPassFilter = c.GlobalInt("hp")
p.AI = ai2.New(p.TicksPerBeat)
p.AI.HighPassFilter = c.GlobalInt("hp")
p.AI.LinkLength = c.GlobalInt("link")
p.AI.Jazzy = c.GlobalBool("jazzy")
p.AI.Stacatto = c.GlobalBool("stacatto")
p.AI.DisallowChords = !c.GlobalBool("chords")
p.ManualAI = c.GlobalBool("manual")
p.UseHostVelocity = c.GlobalBool("follow")
p.Start()
return nil
}
err := app.Run(os.Args)
if err != nil {
fmt.Print(err)
}
}