-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
40 lines (31 loc) · 1.22 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
package main
import (
"flag"
"fmt"
"github.com/j14159/gocmc"
"net/http"
)
func main() {
bpm := flag.Int("bpm", 60, "beats per minute")
ppqn := flag.Int("ppqn", 24, "pulses per quarter note, default is 24 and that's probably what you want")
cycle := flag.Int("cycle", 24, "number of quarter notes before the cycle count resets, can affect sequence start/stop times")
host := flag.String("host", "localhost", "address to listen for HTTP")
port := flag.String("port", "4000", "port for HTTP requests")
flag.Parse()
stepLen := 60000 / *bpm / *ppqn
pulsesPerCycle := *ppqn * *cycle
listenAddress := *host + ":" + *port
fmt.Printf("bpm: %d\nppqn: %d\ncycle length: %d\n", *bpm, *ppqn, *cycle)
fmt.Printf("pulse length (ms): %d\npulse count per cycle: %d\n", stepLen, pulsesPerCycle)
fmt.Printf("listening for HTTP at: %s\n", listenAddress)
destinations := gocmc.GetDestinations()
fmt.Println("Destinations: ", destinations)
client := gocmc.MakeClient("goseq")
fmt.Println("Starting controller and handler")
con := NewController(pulsesPerCycle, stepLen)
StartSequenceHandler(con, client)
StartDestinationsHandler()
StartControlHandler(con)
fmt.Println("Starting server")
http.ListenAndServe(listenAddress, nil)
}