mirror of
https://github.com/onyx-and-iris/voicemeeter.git
synced 2026-04-18 05:23:31 +00:00
Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
10d7cea523 | ||
|
|
8a9b5f9a97 | ||
|
|
8a611e39aa | ||
|
|
ff56dd16f5 | ||
|
|
440c3b8eec | ||
|
|
a5f653f569 | ||
|
|
73893209a1 | ||
|
|
303f1a871c | ||
|
|
2c6baf20e4 | ||
|
|
c05bf500ee | ||
|
|
2533f1c162 | ||
|
|
21fb2ad597 | ||
|
|
1284c92680 | ||
|
|
a87c11099c | ||
|
|
00f66e8f9e | ||
|
|
e16a51c0da | ||
|
|
8a03904ab8 | ||
|
|
5fb7f5e4db | ||
|
|
915e3a9609 | ||
|
|
0a7b8e0662 | ||
|
|
c32e3995db | ||
|
|
07218472df |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,6 +1,9 @@
|
||||
# quick tests
|
||||
quick
|
||||
|
||||
#config
|
||||
config.toml
|
||||
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.exe~
|
||||
|
||||
48
README.md
48
README.md
@@ -1,4 +1,4 @@
|
||||
[](https://pkg.go.dev/github.com/onyx-and-iris/voicemeeter-api-go)
|
||||
[](https://pkg.go.dev/github.com/onyx-and-iris/voicemeeter)
|
||||
|
||||
# A Go Wrapper for Voicemeeter API
|
||||
|
||||
@@ -23,7 +23,7 @@ For an outline of past/future changes refer to: [CHANGELOG](CHANGELOG.md)
|
||||
|
||||
Install voicemeeter-api-go package from your console to download the latest version.
|
||||
|
||||
`go get github.com/onyx-and-iris/voicemeeter-api-go`
|
||||
`go get github.com/onyx-and-iris/voicemeeter`
|
||||
|
||||
or add it to your `go.mod` file.
|
||||
|
||||
@@ -38,16 +38,11 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/onyx-and-iris/voicemeeter-api-go"
|
||||
"github.com/onyx-and-iris/voicemeeter"
|
||||
)
|
||||
|
||||
func main() {
|
||||
vm, err := voicemeeter.NewRemote("banana", 15)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
err = vm.Login()
|
||||
vm, err := vmConnect()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@@ -57,6 +52,20 @@ func main() {
|
||||
vm.Strip[0].SetMute(true)
|
||||
fmt.Printf("Strip 0 (%s) mute was set to %v\n", vm.Strip[0].GetLabel(), vm.Strip[0].GetMute())
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
```
|
||||
|
||||
## `voicemeeter.NewRemote(<kindId>, <delay>)`
|
||||
@@ -193,6 +202,8 @@ The following methods are available
|
||||
- `SetAudibility(val float64)` from 0.0 to 10.0
|
||||
- `GetA1() bool - GetA5() bool`
|
||||
- `SetA1(val bool) - SetA5(val bool)`
|
||||
- `AppGain(name string, gain float64)`
|
||||
- `AppMute(name string, val bool)`
|
||||
|
||||
example:
|
||||
|
||||
@@ -200,6 +211,9 @@ example:
|
||||
vm.Strip[3].SetGain(3.7)
|
||||
fmt.Println(vm.Strip[0].GetLabel())
|
||||
vm.Strip[4].SetA1(true)
|
||||
|
||||
vm.Strip[5].AppGain("Spotify", 0.5)
|
||||
vm.Strip[5].AppMute("Spotify", true)
|
||||
```
|
||||
|
||||
##### Gainlayers
|
||||
@@ -306,6 +320,22 @@ example:
|
||||
fmt.Println(vm.Bus[1].Levels().All())
|
||||
```
|
||||
|
||||
### Strip | Bus
|
||||
|
||||
The following methods are available.
|
||||
|
||||
- `FadeTo(target float64, time_ int)`: float, int
|
||||
- `FadeBy(change float64, time_ int)`: float, int
|
||||
|
||||
Modify gain to or by the selected amount in db over a time interval in ms.
|
||||
|
||||
example:
|
||||
|
||||
```go
|
||||
vm.Strip[3].FadeBy(-8.3, 500)
|
||||
vm.Bus[3].FadeTo(-12.8, 500)
|
||||
```
|
||||
|
||||
### Button
|
||||
|
||||
The following methods are available
|
||||
|
||||
10
examples/hotkeys/go.mod
Normal file
10
examples/hotkeys/go.mod
Normal file
@@ -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.8.0
|
||||
)
|
||||
|
||||
require golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d // indirect
|
||||
10
examples/hotkeys/go.sum
Normal file
10
examples/hotkeys/go.sum
Normal file
@@ -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.8.0 h1:uVeKXG3+dnZUakJNZ0RjYFgVhFCzGPoiNnU32LqGR4Y=
|
||||
github.com/onyx-and-iris/voicemeeter-api-go v1.8.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=
|
||||
66
examples/hotkeys/main.go
Normal file
66
examples/hotkeys/main.go
Normal file
@@ -0,0 +1,66 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/eiannone/keyboard"
|
||||
"github.com/onyx-and-iris/voicemeeter"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := keyboard.Open(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer func() {
|
||||
_ = keyboard.Close()
|
||||
}()
|
||||
|
||||
vm, err := vmConnect()
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func vmConnect() (*voicemeeter.Remote, error) {
|
||||
vm, err := voicemeeter.NewRemote("potato", 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = vm.Login()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return vm, nil
|
||||
}
|
||||
19
examples/obs/README.md
Normal file
19
examples/obs/README.md
Normal file
@@ -0,0 +1,19 @@
|
||||
## Requirements
|
||||
|
||||
- [OBS Studio](https://obsproject.com/)
|
||||
- [GOOBS Go Client for Websocket v5](https://github.com/andreykaipov/goobs)
|
||||
|
||||
## About
|
||||
|
||||
A simple demonstration showing how to sync OBS scene switches to Voicemeeter states. The script assumes you have connection info saved in
|
||||
a config file named `config.toml` placed next to `main.go`. It also assumes you have scenes named `START` `BRB` `END` and `LIVE`.
|
||||
|
||||
A valid `config.toml` file might look like this:
|
||||
|
||||
```toml
|
||||
[connection]
|
||||
Host="localhost"
|
||||
Port=4455
|
||||
Password="mystrongpass"
|
||||
|
||||
```
|
||||
@@ -3,8 +3,9 @@ module main
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.2.0
|
||||
github.com/andreykaipov/goobs v0.10.0
|
||||
github.com/onyx-and-iris/voicemeeter-api-go v1.5.0
|
||||
github.com/onyx-and-iris/voicemeeter-api-go v1.8.0
|
||||
)
|
||||
|
||||
require (
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
|
||||
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/andreykaipov/goobs v0.10.0 h1:wa4CxbYu/NqwUmx5E4/baDqYRYEmfHwg2T23RAg3jlU=
|
||||
github.com/andreykaipov/goobs v0.10.0/go.mod h1:EqG73Uu/4npyhXIWWszgRelNkEeIz+d0slUT6NKWYs4=
|
||||
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
|
||||
@@ -9,8 +11,8 @@ github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI
|
||||
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
|
||||
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ=
|
||||
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U=
|
||||
github.com/onyx-and-iris/voicemeeter-api-go v1.5.0 h1:KaMrqM9l62hPXspLY2oPBI/4dhmzEMfFwijnFWuG9bA=
|
||||
github.com/onyx-and-iris/voicemeeter-api-go v1.5.0/go.mod h1:zAdBhHXQ9n37CUbLizbOPmAutyZI8Ncqeu5e9u1Fy14=
|
||||
github.com/onyx-and-iris/voicemeeter-api-go v1.8.0 h1:uVeKXG3+dnZUakJNZ0RjYFgVhFCzGPoiNnU32LqGR4Y=
|
||||
github.com/onyx-and-iris/voicemeeter-api-go v1.8.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=
|
||||
|
||||
@@ -3,12 +3,15 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/onyx-and-iris/voicemeeter-api-go"
|
||||
"github.com/onyx-and-iris/voicemeeter"
|
||||
|
||||
"github.com/andreykaipov/goobs"
|
||||
"github.com/andreykaipov/goobs/api/events"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
)
|
||||
|
||||
func onStart(vm *voicemeeter.Remote) {
|
||||
@@ -39,18 +42,13 @@ func onEnd(vm *voicemeeter.Remote) {
|
||||
}
|
||||
|
||||
func main() {
|
||||
vm, err := voicemeeter.NewRemote("potato")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
err = vm.Login()
|
||||
vm, err := vmConnect()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer vm.Logout()
|
||||
|
||||
obs, err := goobs.New("localhost:4455", goobs.WithPassword("mystrongpass"))
|
||||
obs, err := obsConnect()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@@ -79,3 +77,50 @@ func main() {
|
||||
|
||||
time.Sleep(30 * time.Second)
|
||||
}
|
||||
|
||||
func vmConnect() (*voicemeeter.Remote, error) {
|
||||
vm, err := voicemeeter.NewRemote("potato", 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = vm.Login()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return vm, nil
|
||||
}
|
||||
|
||||
func obsConnect() (*goobs.Client, error) {
|
||||
type (
|
||||
connection struct {
|
||||
Host string
|
||||
Port int
|
||||
Password string
|
||||
}
|
||||
|
||||
config struct {
|
||||
Connection map[string]connection
|
||||
}
|
||||
)
|
||||
|
||||
f := "config.toml"
|
||||
if _, err := os.Stat(f); err != nil {
|
||||
err := fmt.Errorf("unable to locate %s", f)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var c config
|
||||
_, err := toml.DecodeFile(f, &c.Connection)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
conn := c.Connection["connection"]
|
||||
|
||||
obs, err := goobs.New(fmt.Sprintf("%s:%d", conn.Host, conn.Port), goobs.WithPassword(conn.Password))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return obs, nil
|
||||
}
|
||||
|
||||
@@ -5,21 +5,32 @@ import (
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/onyx-and-iris/voicemeeter-api-go"
|
||||
"github.com/onyx-and-iris/voicemeeter"
|
||||
)
|
||||
|
||||
// observer represents a single receiver of updates
|
||||
type observer struct {
|
||||
vm *voicemeeter.Remote
|
||||
}
|
||||
|
||||
func (o observer) Register() {
|
||||
// newObserver add ldirty events to the eventlist and returns an observer type
|
||||
func newObserver(vm *voicemeeter.Remote) *observer {
|
||||
vm.EventAdd("ldirty")
|
||||
return &observer{vm}
|
||||
}
|
||||
|
||||
// register registers this observer to receive updates
|
||||
func (o observer) register() {
|
||||
o.vm.Register(o)
|
||||
}
|
||||
|
||||
func (o observer) Deregister() {
|
||||
// deregister deregisters this observer to receive updates
|
||||
func (o observer) deregister() {
|
||||
o.vm.Deregister(o)
|
||||
}
|
||||
|
||||
// OnUpdate satisfies the observer interface defined in publisher.go
|
||||
// for each event type an action is triggered when the event occurs.
|
||||
func (o observer) OnUpdate(subject string) {
|
||||
if subject == "pdirty" {
|
||||
fmt.Println("pdirty!")
|
||||
@@ -43,22 +54,32 @@ func (o observer) OnUpdate(subject string) {
|
||||
}
|
||||
}
|
||||
|
||||
// main connects to Voiceemeter, registers observer for updates
|
||||
// runs updates for 30 seconds and then deregisters observer.
|
||||
func main() {
|
||||
vm, err := voicemeeter.NewRemote("potato", 0)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
err = vm.Login()
|
||||
vm, err := vmConnect()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer vm.Logout()
|
||||
// enable level updates (disabled by default)
|
||||
vm.EventAdd("ldirty")
|
||||
|
||||
o := observer{vm}
|
||||
o.Register()
|
||||
o := newObserver(vm)
|
||||
o.register()
|
||||
time.Sleep(30 * time.Second)
|
||||
o.Deregister()
|
||||
o.deregister()
|
||||
}
|
||||
|
||||
// vmConnect connects to Voicemeeter potato and logs into the API
|
||||
func vmConnect() (*voicemeeter.Remote, error) {
|
||||
vm, err := voicemeeter.NewRemote("potato", 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = vm.Login()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return vm, nil
|
||||
}
|
||||
|
||||
27
examples/vm-cli/README.md
Normal file
27
examples/vm-cli/README.md
Normal file
@@ -0,0 +1,27 @@
|
||||
## About
|
||||
|
||||
A simple voicemeeter-cli program. Offers ability to toggle, get and set parameters.
|
||||
|
||||
## Use
|
||||
|
||||
Toggle with `!` prefix, get by excluding `=` and set by including `=`. Mix and match arguments.
|
||||
|
||||
You may pass an optional flag -kind to set the kind of Voicemeeter. Defaults to banana.
|
||||
|
||||
You may pass an optional flag -delay to set a delay on the getters. Defaults to 20ms.
|
||||
|
||||
for example:
|
||||
|
||||
`go run .\main.go -kind=potato -delay=18 strip[0].mute=0 strip[0].mute !strip[0].mute strip[0].mute bus[0].gain=-8.8 command.lock=1`
|
||||
|
||||
Expected output:
|
||||
|
||||
```
|
||||
Logged into Voicemeeter potato
|
||||
Running command strip[0].mute=0
|
||||
Value of strip[0].mute is: 0
|
||||
Toggling strip[0].mute
|
||||
Value of strip[0].mute is: 1
|
||||
Running command bus[0].gain=-8.8
|
||||
Running command command.lock=1
|
||||
```
|
||||
77
examples/vm-cli/main.go
Normal file
77
examples/vm-cli/main.go
Normal file
@@ -0,0 +1,77 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/onyx-and-iris/voicemeeter"
|
||||
)
|
||||
|
||||
func main() {
|
||||
kindId := flag.String("kind", "banana", "kind of voicemeeter")
|
||||
delay := flag.Int("delay", 20, "delay between commands")
|
||||
flag.Parse()
|
||||
|
||||
vm, err := vmConnect(kindId, delay)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer vm.Logout()
|
||||
|
||||
err = runCommands(vm)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
func vmConnect(kindId *string, delay *int) (*voicemeeter.Remote, error) {
|
||||
vm, err := voicemeeter.NewRemote(*kindId, *delay)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = vm.Login()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return vm, nil
|
||||
}
|
||||
|
||||
func runCommands(vm *voicemeeter.Remote) error {
|
||||
for _, arg := range flag.Args() {
|
||||
if arg[0] == '!' {
|
||||
val, err := vm.GetFloat(arg[1:])
|
||||
if err != nil {
|
||||
err = fmt.Errorf("unable to toggle %s", arg[1:])
|
||||
return err
|
||||
}
|
||||
vm.SetFloat(arg[1:], 1-val)
|
||||
fmt.Println("Toggling", arg[1:])
|
||||
} else {
|
||||
if strings.Contains(arg, "=") {
|
||||
fmt.Println("Running command", arg)
|
||||
err := vm.SendText(arg)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("unable to set %s", arg)
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
valF, err := vm.GetFloat(arg)
|
||||
if err != nil {
|
||||
valS, err := vm.GetString(arg)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("unable to get %s", arg)
|
||||
return err
|
||||
}
|
||||
fmt.Println("Value of", arg, "is:", valS)
|
||||
} else {
|
||||
fmt.Println("Value of", arg, "is:", valF)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
8
go.mod
8
go.mod
@@ -1,11 +1,9 @@
|
||||
module github.com/onyx-and-iris/voicemeeter-api-go
|
||||
module github.com/onyx-and-iris/voicemeeter
|
||||
|
||||
go 1.18
|
||||
|
||||
retract (
|
||||
// package files moved into root of repository
|
||||
[v1.0.0, v1.1.0]
|
||||
)
|
||||
// package files moved into root of repository
|
||||
retract [v1.0.0, v1.1.0]
|
||||
|
||||
require (
|
||||
github.com/stretchr/testify v1.8.0
|
||||
|
||||
36
remote.go
36
remote.go
@@ -83,36 +83,48 @@ func (r *Remote) Sync() {
|
||||
}
|
||||
|
||||
// Gets a float parameter value
|
||||
func (r *Remote) GetFloat(name string) float64 {
|
||||
func (r *Remote) GetFloat(name string) (float64, error) {
|
||||
val, err := getParameterFloat(name)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return 0, err
|
||||
}
|
||||
return val
|
||||
return val, nil
|
||||
}
|
||||
|
||||
// Sets a float paramter value
|
||||
func (r *Remote) SetFloat(name string, value float64) {
|
||||
setParameterFloat(name, value)
|
||||
func (r *Remote) SetFloat(name string, value float64) error {
|
||||
err := setParameterFloat(name, value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Gets a string parameter value
|
||||
func (r *Remote) GetString(name string) string {
|
||||
func (r *Remote) GetString(name string) (string, error) {
|
||||
val, err := getParameterString(name)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return "", err
|
||||
}
|
||||
return val
|
||||
return val, nil
|
||||
}
|
||||
|
||||
// Sets a string paramter value
|
||||
func (r *Remote) SetString(name, value string) {
|
||||
setParameterString(name, value)
|
||||
func (r *Remote) SetString(name, value string) error {
|
||||
err := setParameterString(name, value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SendText sets multiple parameters by script
|
||||
func (r *Remote) SendText(script string) {
|
||||
setParametersMulti(script)
|
||||
func (r *Remote) SendText(script string) error {
|
||||
err := setParametersMulti(script)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Register forwards the register method to Pooler
|
||||
|
||||
@@ -87,18 +87,21 @@ func TestGetPotatoRemote(t *testing.T) {
|
||||
func TestSetAndGetFloatParameter(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
var param = "strip[0].mute"
|
||||
var exp = float64(1)
|
||||
vm.SetFloat(param, 1)
|
||||
t.Run("Should get a float parameter", func(t *testing.T) {
|
||||
assert.Equal(t, float64(1), vm.GetFloat(param))
|
||||
val, _ := vm.GetFloat(param)
|
||||
assert.Equal(t, exp, val)
|
||||
})
|
||||
}
|
||||
|
||||
func TestSetAndGetStringParameter(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
var param = "strip[0].label"
|
||||
var val = "test0"
|
||||
vm.SetString(param, val)
|
||||
var exp = "test0"
|
||||
vm.SetString(param, exp)
|
||||
t.Run("Should get a string parameter", func(t *testing.T) {
|
||||
assert.Equal(t, val, vm.GetString(param))
|
||||
val, _ := vm.GetString(param)
|
||||
assert.Equal(t, exp, val)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"log"
|
||||
"testing"
|
||||
|
||||
"github.com/onyx-and-iris/voicemeeter-api-go"
|
||||
"github.com/onyx-and-iris/voicemeeter"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
Reference in New Issue
Block a user