mirror of
https://github.com/onyx-and-iris/voicemeeter.git
synced 2024-11-15 17:40:51 +00:00
add vm-cli example
This commit is contained in:
parent
0a7b8e0662
commit
915e3a9609
7
examples/vm-cli/go.mod
Normal file
7
examples/vm-cli/go.mod
Normal file
@ -0,0 +1,7 @@
|
||||
module main
|
||||
|
||||
go 1.19
|
||||
|
||||
require github.com/onyx-and-iris/voicemeeter-api-go v1.7.0
|
||||
|
||||
require golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d // indirect
|
8
examples/vm-cli/go.sum
Normal file
8
examples/vm-cli/go.sum
Normal file
@ -0,0 +1,8 @@
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
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=
|
53
examples/vm-cli/main.go
Normal file
53
examples/vm-cli/main.go
Normal file
@ -0,0 +1,53 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/onyx-and-iris/voicemeeter-api-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
vm, err := vmConnect()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer vm.Logout()
|
||||
|
||||
for _, arg := range os.Args[1:] {
|
||||
if arg[0] == '!' {
|
||||
vm.SetFloat(arg[1:], 1-vm.GetFloat(arg[1:]))
|
||||
fmt.Println("Toggling", arg[1:])
|
||||
} else {
|
||||
if strings.Contains(arg, "=") {
|
||||
fmt.Println("Running command", arg)
|
||||
vm.SendText(arg)
|
||||
} else {
|
||||
s := strings.Split(arg, ".")
|
||||
if strings.Contains(s[1], "label") {
|
||||
val := vm.GetString(arg)
|
||||
fmt.Println("Value of", arg, "is:", val)
|
||||
} else {
|
||||
val := vm.GetFloat(arg)
|
||||
fmt.Println("Value of", arg, "is:", val)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func vmConnect() (*voicemeeter.Remote, error) {
|
||||
vm, err := voicemeeter.NewRemote("banana", 15)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = vm.Login()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return vm, nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user