-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
48 lines (38 loc) · 978 Bytes
/
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
package main
import (
_ "embed"
"flag"
"fmt"
"log"
"os"
"sektron/filesystem"
"sektron/midi"
"sektron/sequencer"
"sektron/ui"
tea "github.com/charmbracelet/bubbletea"
)
//go:embed VERSION
var AppVersion string
func main() {
configFile := flag.String("config", "config.json", "config file to load or create")
keyboard := flag.String("keyboard", "", "keyboard layout (qwerty, qwerty-mac, azerty, azerty-mac)")
patternsFile := flag.String("patterns", "patterns.json", "patterns file to load or create")
version := flag.Bool("version", false, "print current version")
flag.Parse()
if *version {
fmt.Print(AppVersion)
os.Exit(0)
}
midi, err := midi.New()
if err != nil {
log.Fatal(err)
}
defer midi.Close()
config := filesystem.NewConfiguration(*configFile, *keyboard)
bank := filesystem.NewBank(*patternsFile)
seq := sequencer.New(midi, bank)
p := tea.NewProgram(ui.New(config, seq))
if _, err := p.Run(); err != nil {
log.Fatal(err)
}
}