diff --git a/examples/hotkeys/go.mod b/examples/hotkeys/go.mod new file mode 100644 index 0000000..9934f40 --- /dev/null +++ b/examples/hotkeys/go.mod @@ -0,0 +1,10 @@ +module main + +go 1.19 + +require ( + github.com/eiannone/keyboard v0.0.0-20220611211555-0d226195f203 + github.com/onyx-and-iris/voicemeeter-api-go v1.7.0 +) + +require golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d // indirect diff --git a/examples/hotkeys/go.sum b/examples/hotkeys/go.sum new file mode 100644 index 0000000..1959cb3 --- /dev/null +++ b/examples/hotkeys/go.sum @@ -0,0 +1,10 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/eiannone/keyboard v0.0.0-20220611211555-0d226195f203 h1:XBBHcIb256gUJtLmY22n99HaZTz+r2Z51xUPi01m3wg= +github.com/eiannone/keyboard v0.0.0-20220611211555-0d226195f203/go.mod h1:E1jcSv8FaEny+OP/5k9UxZVw9YFWGj7eI4KR/iOBqCg= +github.com/onyx-and-iris/voicemeeter-api-go v1.7.0 h1:WA1RGrfaWBOavgY2uoJltzy/rAgvs62PM3qzR+5/jt8= +github.com/onyx-and-iris/voicemeeter-api-go v1.7.0/go.mod h1:zAdBhHXQ9n37CUbLizbOPmAutyZI8Ncqeu5e9u1Fy14= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d h1:/m5NbqQelATgoSPVC2Z23sR4kVNokFwDDyWh/3rGY+I= +golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/examples/hotkeys/main.go b/examples/hotkeys/main.go new file mode 100644 index 0000000..ebe5cdf --- /dev/null +++ b/examples/hotkeys/main.go @@ -0,0 +1,57 @@ +package main + +import ( + "fmt" + "log" + + "github.com/eiannone/keyboard" + "github.com/onyx-and-iris/voicemeeter-api-go" +) + +func main() { + if err := keyboard.Open(); err != nil { + panic(err) + } + defer func() { + _ = keyboard.Close() + }() + + vm, err := voicemeeter.NewRemote("potato", 0) + if err != nil { + log.Fatal(err) + } + + err = vm.Login() + if err != nil { + log.Fatal(err) + } + defer vm.Logout() + + fmt.Println("Press ESC to quit") + Loop: + for { + char, key, err := keyboard.GetKey() + if err != nil { + panic(err) + } + + switch char { + case '0': + fmt.Printf("Logged into Voicemeeter %s, version %s\n", vm.Type(), vm.Version()) + case '1': + vm.Strip[0].SetMute(!vm.Strip[0].GetMute()) + case '2': + if vm.Strip[3].GetGain() == -12.8 { + vm.Strip[3].FadeBy(-8.3, 500) + } else { + vm.Strip[3].FadeTo(-12.8, 500) + } + case '3': + vm.Strip[5].AppMute("Spotify", true) + default: + if key == keyboard.KeyEsc { + break Loop + } + } + } +}