mirror of
https://github.com/onyx-and-iris/voicemeeter.git
synced 2026-04-18 05:23:31 +00:00
Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
38973810d7 | ||
|
|
be6a49e3bc | ||
|
|
76ed3320d3 | ||
|
|
8f630d52e7 | ||
|
|
174db162c8 | ||
|
|
c7a265fb33 | ||
|
|
8bb8336599 | ||
|
|
5b3f10c4b8 | ||
|
|
7022c5dacf | ||
|
|
5bb7eb9668 | ||
|
|
5e5a82f198 | ||
|
|
d8de82b90e | ||
|
|
5b4592f484 | ||
|
|
b2dd96abc4 | ||
|
|
6605d6e62d | ||
|
|
3ab5daa61c | ||
|
|
0d06098af8 | ||
|
|
9df10d939d | ||
|
|
d82e6a39f5 | ||
|
|
10d7cea523 | ||
|
|
8a9b5f9a97 | ||
|
|
8a611e39aa | ||
|
|
ff56dd16f5 | ||
|
|
440c3b8eec | ||
|
|
a5f653f569 | ||
|
|
73893209a1 | ||
|
|
303f1a871c |
35
README.md
35
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
|
# A Go Wrapper for Voicemeeter API
|
||||||
|
|
||||||
@@ -19,13 +19,12 @@ For an outline of past/future changes refer to: [CHANGELOG](CHANGELOG.md)
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
#### GO GET
|
Initialize your own module then `go get`
|
||||||
|
|
||||||
Install voicemeeter-api-go package from your console to download the latest version.
|
```
|
||||||
|
go mod init github.com/x/y
|
||||||
`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.
|
|
||||||
|
|
||||||
## `Use`
|
## `Use`
|
||||||
|
|
||||||
@@ -38,7 +37,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/onyx-and-iris/voicemeeter-api-go"
|
"github.com/onyx-and-iris/voicemeeter"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -54,7 +53,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func vmConnect() (*voicemeeter.Remote, error) {
|
func vmConnect() (*voicemeeter.Remote, error) {
|
||||||
vm, err := voicemeeter.NewRemote("banana", 15)
|
vm, err := voicemeeter.NewRemote("banana", 20)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -148,19 +147,19 @@ sets many parameters in script format eg. ("Strip[0].Mute=1;Bus[3].Gain=3.6")
|
|||||||
|
|
||||||
#### `vm.Register(o observer)`
|
#### `vm.Register(o observer)`
|
||||||
|
|
||||||
register an object as an observer
|
register an observer type as an observer
|
||||||
|
|
||||||
#### `vm.Deregister(o observer)`
|
#### `vm.Deregister(o observer)`
|
||||||
|
|
||||||
deregister an object as an observer
|
deregister an observer type as an observer
|
||||||
|
|
||||||
#### `vm.EventAdd(<event>)`
|
#### `vm.EventAdd(<events>)`
|
||||||
|
|
||||||
adds an event to the pooler eg. vm.EventAdd("ldirty")
|
adds a single or multiple events to the pooler. Accepts a string or slice of strings.
|
||||||
|
|
||||||
#### `vm.EventRemove(<event>)`
|
#### `vm.EventRemove(<events>)`
|
||||||
|
|
||||||
removes an event to the pooler eg. vm.EventRemove("pdirty")
|
removes a single or multiple events from the pooler. Accepts a string or slice of strings.
|
||||||
|
|
||||||
#### `vm.Pdirty()`
|
#### `vm.Pdirty()`
|
||||||
|
|
||||||
@@ -482,9 +481,11 @@ By default level updates are disabled. Any event may be enabled or disabled. The
|
|||||||
example:
|
example:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
vm.EventAdd("ldirty")
|
events := []string{"ldirty", "mdirty", "pdirty"}
|
||||||
|
|
||||||
vm.EventRemove("pdirty")
|
vm.EventAdd(events...)
|
||||||
|
|
||||||
|
vm.EventRemove(events...)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Run tests
|
### Run tests
|
||||||
|
|||||||
10
base.go
10
base.go
@@ -8,6 +8,8 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -52,7 +54,7 @@ func login(kindId string) error {
|
|||||||
err := fmt.Errorf("VBVMR_Login returned %d", res)
|
err := fmt.Errorf("VBVMR_Login returned %d", res)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Printf("Logged into Voicemeeter %s\n", kindId)
|
log.Info("Logged into Voicemeeter ", kindId)
|
||||||
for pdirty() || mdirty() {
|
for pdirty() || mdirty() {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@@ -67,7 +69,7 @@ func logout(kindId string) error {
|
|||||||
err := fmt.Errorf("VBVMR_Logout returned %d", res)
|
err := fmt.Errorf("VBVMR_Logout returned %d", res)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Printf("Logged out of Voicemeeter %s\n", kindId)
|
log.Info("Logged out of Voicemeeter ", kindId)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,7 +315,7 @@ func getDeviceDescription(i int, dir string) (string, uint64, string, error) {
|
|||||||
|
|
||||||
// getLevel returns a single level value of type type_ for channel[i]
|
// getLevel returns a single level value of type type_ for channel[i]
|
||||||
func getLevel(type_, i int) (float64, error) {
|
func getLevel(type_, i int) (float64, error) {
|
||||||
var val float64
|
var val float32
|
||||||
res, _, _ := vmGetLevelFloat.Call(
|
res, _, _ := vmGetLevelFloat.Call(
|
||||||
uintptr(type_),
|
uintptr(type_),
|
||||||
uintptr(i),
|
uintptr(i),
|
||||||
@@ -323,7 +325,7 @@ func getLevel(type_, i int) (float64, error) {
|
|||||||
err := fmt.Errorf("VBVMR_GetLevel returned %d", res)
|
err := fmt.Errorf("VBVMR_GetLevel returned %d", res)
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
return val, nil
|
return float64(val), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// getMidiMessage gets midi channel, pitch and velocity for a single midi input
|
// getMidiMessage gets midi channel, pitch and velocity for a single midi input
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ go 1.19
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/eiannone/keyboard v0.0.0-20220611211555-0d226195f203
|
github.com/eiannone/keyboard v0.0.0-20220611211555-0d226195f203
|
||||||
github.com/onyx-and-iris/voicemeeter-api-go v1.7.0
|
github.com/onyx-and-iris/voicemeeter v1.10.1
|
||||||
|
github.com/sirupsen/logrus v1.9.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d // indirect
|
require golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
|
||||||
|
|||||||
@@ -1,10 +1,19 @@
|
|||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/eiannone/keyboard v0.0.0-20220611211555-0d226195f203 h1:XBBHcIb256gUJtLmY22n99HaZTz+r2Z51xUPi01m3wg=
|
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/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 v1.10.1 h1:kpPN/cTYe1JG2aLUD+/m/bMUbp7wXrqrk1fL+sV8yko=
|
||||||
github.com/onyx-and-iris/voicemeeter-api-go v1.7.0/go.mod h1:zAdBhHXQ9n37CUbLizbOPmAutyZI8Ncqeu5e9u1Fy14=
|
github.com/onyx-and-iris/voicemeeter v1.10.1/go.mod h1:LayUoN/MWSqKXSOGQ7AcLvwoefsL+zQ9CjncLs3WqsU=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
|
||||||
|
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
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-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
|
||||||
golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
|||||||
@@ -2,12 +2,17 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/eiannone/keyboard"
|
"github.com/eiannone/keyboard"
|
||||||
"github.com/onyx-and-iris/voicemeeter-api-go"
|
"github.com/onyx-and-iris/voicemeeter"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
log.SetLevel(log.InfoLevel)
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if err := keyboard.Open(); err != nil {
|
if err := keyboard.Open(); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ go 1.18
|
|||||||
require (
|
require (
|
||||||
github.com/BurntSushi/toml v1.2.0
|
github.com/BurntSushi/toml v1.2.0
|
||||||
github.com/andreykaipov/goobs v0.10.0
|
github.com/andreykaipov/goobs v0.10.0
|
||||||
github.com/onyx-and-iris/voicemeeter-api-go v1.7.0
|
github.com/onyx-and-iris/voicemeeter v1.10.1
|
||||||
|
github.com/sirupsen/logrus v1.9.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
@@ -13,5 +14,5 @@ require (
|
|||||||
github.com/gorilla/websocket v1.5.0 // indirect
|
github.com/gorilla/websocket v1.5.0 // indirect
|
||||||
github.com/hashicorp/logutils v1.0.0 // indirect
|
github.com/hashicorp/logutils v1.0.0 // indirect
|
||||||
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
|
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
|
||||||
golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d // indirect
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,17 +4,26 @@ github.com/andreykaipov/goobs v0.10.0 h1:wa4CxbYu/NqwUmx5E4/baDqYRYEmfHwg2T23RAg
|
|||||||
github.com/andreykaipov/goobs v0.10.0/go.mod h1:EqG73Uu/4npyhXIWWszgRelNkEeIz+d0slUT6NKWYs4=
|
github.com/andreykaipov/goobs v0.10.0/go.mod h1:EqG73Uu/4npyhXIWWszgRelNkEeIz+d0slUT6NKWYs4=
|
||||||
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
|
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
|
||||||
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||||
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=
|
github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=
|
||||||
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
|
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 h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ=
|
||||||
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U=
|
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U=
|
||||||
github.com/onyx-and-iris/voicemeeter-api-go v1.7.0 h1:WA1RGrfaWBOavgY2uoJltzy/rAgvs62PM3qzR+5/jt8=
|
github.com/onyx-and-iris/voicemeeter v1.10.1 h1:kpPN/cTYe1JG2aLUD+/m/bMUbp7wXrqrk1fL+sV8yko=
|
||||||
github.com/onyx-and-iris/voicemeeter-api-go v1.7.0/go.mod h1:zAdBhHXQ9n37CUbLizbOPmAutyZI8Ncqeu5e9u1Fy14=
|
github.com/onyx-and-iris/voicemeeter v1.10.1/go.mod h1:LayUoN/MWSqKXSOGQ7AcLvwoefsL+zQ9CjncLs3WqsU=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
|
||||||
|
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
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-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
|
||||||
golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
|||||||
@@ -2,11 +2,12 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"time"
|
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/onyx-and-iris/voicemeeter-api-go"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/onyx-and-iris/voicemeeter"
|
||||||
|
|
||||||
"github.com/andreykaipov/goobs"
|
"github.com/andreykaipov/goobs"
|
||||||
"github.com/andreykaipov/goobs/api/events"
|
"github.com/andreykaipov/goobs/api/events"
|
||||||
@@ -41,6 +42,10 @@ func onEnd(vm *voicemeeter.Remote) {
|
|||||||
vm.Vban.InStream[0].SetOn(false)
|
vm.Vban.InStream[0].SetOn(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
log.SetLevel(log.InfoLevel)
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
vm, err := vmConnect()
|
vm, err := vmConnect()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -92,12 +97,12 @@ func vmConnect() (*voicemeeter.Remote, error) {
|
|||||||
return vm, nil
|
return vm, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func obsConnect() (*goobs.Client, error) {
|
func obsConnect() (*goobs.Client, error) {
|
||||||
type (
|
type (
|
||||||
connection struct {
|
connection struct {
|
||||||
Host string
|
Host string
|
||||||
Port int
|
Port int
|
||||||
Password string
|
Password string
|
||||||
}
|
}
|
||||||
|
|
||||||
config struct {
|
config struct {
|
||||||
@@ -107,7 +112,8 @@ func obsConnect() (*goobs.Client, error) {
|
|||||||
|
|
||||||
f := "config.toml"
|
f := "config.toml"
|
||||||
if _, err := os.Stat(f); err != nil {
|
if _, err := os.Stat(f); err != nil {
|
||||||
f = "./config.toml"
|
err := fmt.Errorf("unable to locate %s", f)
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var c config
|
var c config
|
||||||
|
|||||||
@@ -2,10 +2,11 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/onyx-and-iris/voicemeeter-api-go"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/onyx-and-iris/voicemeeter"
|
||||||
)
|
)
|
||||||
|
|
||||||
// observer represents a single receiver of updates
|
// observer represents a single receiver of updates
|
||||||
@@ -41,19 +42,18 @@ func (o observer) OnUpdate(subject string) {
|
|||||||
var val = o.vm.Midi.Get(current)
|
var val = o.vm.Midi.Get(current)
|
||||||
fmt.Printf("Value of midi button %d: %d\n", current, val)
|
fmt.Printf("Value of midi button %d: %d\n", current, val)
|
||||||
} else if subject == "ldirty" {
|
} else if subject == "ldirty" {
|
||||||
fmt.Printf("%v %v %v %v %v %v %v %v\n",
|
for _, bus := range o.vm.Bus {
|
||||||
o.vm.Bus[0].Levels().IsDirty(),
|
if bus.Levels().IsDirty() {
|
||||||
o.vm.Bus[1].Levels().IsDirty(),
|
fmt.Println(bus, bus.Levels().All())
|
||||||
o.vm.Bus[2].Levels().IsDirty(),
|
}
|
||||||
o.vm.Bus[3].Levels().IsDirty(),
|
}
|
||||||
o.vm.Bus[4].Levels().IsDirty(),
|
|
||||||
o.vm.Bus[5].Levels().IsDirty(),
|
|
||||||
o.vm.Bus[6].Levels().IsDirty(),
|
|
||||||
o.vm.Bus[7].Levels().IsDirty(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
log.SetLevel(log.InfoLevel)
|
||||||
|
}
|
||||||
|
|
||||||
// main connects to Voiceemeter, registers observer for updates
|
// main connects to Voiceemeter, registers observer for updates
|
||||||
// runs updates for 30 seconds and then deregisters observer.
|
// runs updates for 30 seconds and then deregisters observer.
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
@@ -2,20 +2,28 @@
|
|||||||
|
|
||||||
A simple voicemeeter-cli program. Offers ability to toggle, get and set parameters.
|
A simple voicemeeter-cli program. Offers ability to toggle, get and set parameters.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
First build and install it with `go install` (skip this step if using binary from [Releases](https://github.com/onyx-and-iris/voicemeeter/releases))
|
||||||
|
|
||||||
## Use
|
## Use
|
||||||
|
|
||||||
Toggle with `!` prefix, get by excluding `=` and set by including `=`. Mix and match arguments.
|
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 15ms.
|
You may pass the following optional flags:
|
||||||
|
|
||||||
|
- -v: (-verbose) to toggle console output.
|
||||||
|
- -i: (-interactive) to toggle interactive mode.
|
||||||
|
- -k: (-kind) to set the kind of Voicemeeter. Defaults to banana.
|
||||||
|
- -d: (-delay) to set a delay on the getters. Defaults to 20ms.
|
||||||
|
|
||||||
for example:
|
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`
|
`vm-cli.exe -v -k=potato -d=25 strip[0].mute=0 strip[0].mute !strip[0].mute strip[0].mute bus[0].gain=-8.8 command.lock=1`
|
||||||
|
|
||||||
Expected output:
|
Expected output:
|
||||||
|
|
||||||
```
|
```
|
||||||
Logged into Voicemeeter potato
|
|
||||||
Running command strip[0].mute=0
|
Running command strip[0].mute=0
|
||||||
Value of strip[0].mute is: 0
|
Value of strip[0].mute is: 0
|
||||||
Toggling strip[0].mute
|
Toggling strip[0].mute
|
||||||
@@ -23,3 +31,5 @@ Value of strip[0].mute is: 1
|
|||||||
Running command bus[0].gain=-8.8
|
Running command bus[0].gain=-8.8
|
||||||
Running command command.lock=1
|
Running command command.lock=1
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If running in interactive mode enter `q`, `quit` or `<Enter>` to exit.
|
||||||
|
|||||||
@@ -1,33 +1,71 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/onyx-and-iris/voicemeeter-api-go"
|
"github.com/onyx-and-iris/voicemeeter"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
verbosePrinter struct {
|
||||||
|
verbose bool
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func newVerbosePrinter() *verbosePrinter {
|
||||||
|
return &verbosePrinter{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *verbosePrinter) printf(format string, a ...interface{}) {
|
||||||
|
if v.verbose {
|
||||||
|
fmt.Printf(format+"\n", a...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
vPrinter *verbosePrinter
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
vPrinter = newVerbosePrinter()
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
kindId := flag.String("kind", "banana", "kind of voicemeeter")
|
var (
|
||||||
delay := flag.Int("delay", 15, "delay between commands")
|
kind string
|
||||||
|
delay int
|
||||||
|
interactive bool
|
||||||
|
)
|
||||||
|
|
||||||
|
flag.StringVar(&kind, "kind", "banana", "kind of voicemeeter")
|
||||||
|
flag.StringVar(&kind, "k", "banana", "kind of voicemeeter (shorthand)")
|
||||||
|
flag.IntVar(&delay, "delay", 20, "delay between commands")
|
||||||
|
flag.IntVar(&delay, "d", 20, "delay between commands (shorthand)")
|
||||||
|
flag.BoolVar(&vPrinter.verbose, "verbose", false, "toggle console output")
|
||||||
|
flag.BoolVar(&vPrinter.verbose, "v", false, "toggle console output (shorthand)")
|
||||||
|
flag.BoolVar(&interactive, "interactive", false, "toggle interactive mode")
|
||||||
|
flag.BoolVar(&interactive, "i", false, "toggle interactive mode (shorthand)")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
vm, err := vmConnect(kindId, delay)
|
vm, err := vmConnect(kind, delay)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
defer vm.Logout()
|
defer vm.Logout()
|
||||||
|
|
||||||
err = run_commands(vm)
|
err = runCommands(vm, interactive)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func vmConnect(kindId *string, delay *int) (*voicemeeter.Remote, error) {
|
func vmConnect(kind string, delay int) (*voicemeeter.Remote, error) {
|
||||||
vm, err := voicemeeter.NewRemote(*kindId, *delay)
|
vm, err := voicemeeter.NewRemote(kind, delay)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -40,38 +78,99 @@ func vmConnect(kindId *string, delay *int) (*voicemeeter.Remote, error) {
|
|||||||
return vm, nil
|
return vm, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func run_commands(vm *voicemeeter.Remote) error {
|
func runCommands(vm *voicemeeter.Remote, interactive bool) error {
|
||||||
for _, arg := range flag.Args() {
|
if interactive {
|
||||||
if arg[0] == '!' {
|
return interactiveMode(vm)
|
||||||
val, err := vm.GetFloat(arg[1:])
|
}
|
||||||
|
args := flag.Args()
|
||||||
|
if len(args) == 0 {
|
||||||
|
err := fmt.Errorf("must provide some commands to run")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, arg := range args {
|
||||||
|
err := parse(vm, arg)
|
||||||
|
if err != nil {
|
||||||
|
vPrinter.printf(err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func interactiveMode(vm *voicemeeter.Remote) error {
|
||||||
|
vPrinter.printf("running in interactive mode... waiting for input")
|
||||||
|
scanner := bufio.NewScanner(os.Stdin)
|
||||||
|
for scanner.Scan() {
|
||||||
|
input := scanner.Text()
|
||||||
|
if input == "q" || input == "quit" || input == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
for _, cmd := range strings.Split(input, " ") {
|
||||||
|
err := parse(vm, cmd)
|
||||||
|
if err != nil {
|
||||||
|
vPrinter.printf(err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if scanner.Err() != nil {
|
||||||
|
return scanner.Err()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func parse(vm *voicemeeter.Remote, cmd string) error {
|
||||||
|
if cmd[0] == '!' {
|
||||||
|
err := toggleCmd(vm, cmd[1:])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if strings.Contains(cmd, "=") {
|
||||||
|
err := setCmd(vm, cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("unable to toggle %s", arg[1:])
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
vm.SetFloat(arg[1:], 1-val)
|
|
||||||
fmt.Println("Toggling", arg[1:])
|
|
||||||
} else {
|
} else {
|
||||||
if strings.Contains(arg, "=") {
|
err := getCmd(vm, cmd)
|
||||||
fmt.Println("Running command", arg)
|
if err != nil {
|
||||||
err := vm.SendText(arg)
|
return err
|
||||||
if err != nil {
|
|
||||||
err = fmt.Errorf("unable to set %s", arg)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
val_f, err := vm.GetFloat(arg)
|
|
||||||
if err != nil {
|
|
||||||
val_s, err := vm.GetString(arg)
|
|
||||||
if err != nil {
|
|
||||||
err = fmt.Errorf("unable to get %s", arg)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
fmt.Println("Value of", arg, "is:", val_s)
|
|
||||||
} else {
|
|
||||||
fmt.Println("Value of", arg, "is:", val_f)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func toggleCmd(vm *voicemeeter.Remote, cmd string) error {
|
||||||
|
val, err := vm.GetFloat(cmd)
|
||||||
|
if err != nil {
|
||||||
|
err = fmt.Errorf("unable to toggle %s", cmd)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
vm.SetFloat(cmd, 1-val)
|
||||||
|
vPrinter.printf("Toggling %s", cmd)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func setCmd(vm *voicemeeter.Remote, cmd string) error {
|
||||||
|
vPrinter.printf("Running command %s", cmd)
|
||||||
|
err := vm.SendText(cmd)
|
||||||
|
if err != nil {
|
||||||
|
err = fmt.Errorf("unable to set %s", cmd)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func getCmd(vm *voicemeeter.Remote, cmd string) error {
|
||||||
|
valF, err := vm.GetFloat(cmd)
|
||||||
|
if err != nil {
|
||||||
|
valS, err := vm.GetString(cmd)
|
||||||
|
if err != nil {
|
||||||
|
err = fmt.Errorf("unable to get %s", cmd)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
vPrinter.printf("Value of %s is: %s", cmd, valS)
|
||||||
|
} else {
|
||||||
|
vPrinter.printf("Value of %s is: %v", cmd, valF)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
11
go.mod
11
go.mod
@@ -1,15 +1,14 @@
|
|||||||
module github.com/onyx-and-iris/voicemeeter-api-go
|
module github.com/onyx-and-iris/voicemeeter
|
||||||
|
|
||||||
go 1.18
|
go 1.18
|
||||||
|
|
||||||
retract (
|
// package files moved into root of repository
|
||||||
// package files moved into root of repository
|
retract [v1.0.0, v1.1.0]
|
||||||
[v1.0.0, v1.1.0]
|
|
||||||
)
|
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/sirupsen/logrus v1.9.0
|
||||||
github.com/stretchr/testify v1.8.0
|
github.com/stretchr/testify v1.8.0
|
||||||
golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
|||||||
7
go.sum
7
go.sum
@@ -3,13 +3,16 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
|
|||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
|
||||||
|
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d h1:/m5NbqQelATgoSPVC2Z23sR4kVNokFwDDyWh/3rGY+I=
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
|
||||||
golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
|||||||
48
publisher.go
48
publisher.go
@@ -2,6 +2,8 @@ package voicemeeter
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// observer defines the interface any registered observers must satisfy
|
// observer defines the interface any registered observers must satisfy
|
||||||
@@ -51,29 +53,35 @@ func newEvent() *event {
|
|||||||
return &event{true, true, true, false}
|
return &event{true, true, true, false}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *event) Add(ev string) {
|
func (e *event) Add(events ...string) {
|
||||||
switch ev {
|
for _, event := range events {
|
||||||
case "pdirty":
|
switch event {
|
||||||
e.pdirty = true
|
case "pdirty":
|
||||||
case "mdirty":
|
e.pdirty = true
|
||||||
e.mdirty = true
|
case "mdirty":
|
||||||
case "midi":
|
e.mdirty = true
|
||||||
e.midi = true
|
case "midi":
|
||||||
case "ldirty":
|
e.midi = true
|
||||||
e.ldirty = true
|
case "ldirty":
|
||||||
|
e.ldirty = true
|
||||||
|
}
|
||||||
|
log.Info(event, " added to the pooler")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *event) Remove(ev string) {
|
func (e *event) Remove(events ...string) {
|
||||||
switch ev {
|
for _, event := range events {
|
||||||
case "pdirty":
|
switch event {
|
||||||
e.pdirty = false
|
case "pdirty":
|
||||||
case "mdirty":
|
e.pdirty = false
|
||||||
e.mdirty = false
|
case "mdirty":
|
||||||
case "midi":
|
e.mdirty = false
|
||||||
e.midi = false
|
case "midi":
|
||||||
case "ldirty":
|
e.midi = false
|
||||||
e.ldirty = false
|
case "ldirty":
|
||||||
|
e.ldirty = false
|
||||||
|
}
|
||||||
|
log.Info(event, " removed from the pooler")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
48
remote.go
48
remote.go
@@ -2,10 +2,13 @@ package voicemeeter
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// A Remote type represents the API for a kind
|
// Remote represents the API for a kind
|
||||||
type Remote struct {
|
type Remote struct {
|
||||||
Kind *kind
|
Kind *kind
|
||||||
Strip []iStrip
|
Strip []iStrip
|
||||||
@@ -82,7 +85,7 @@ func (r *Remote) Sync() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets a float parameter value
|
// GetFloat gets a float parameter value
|
||||||
func (r *Remote) GetFloat(name string) (float64, error) {
|
func (r *Remote) GetFloat(name string) (float64, error) {
|
||||||
val, err := getParameterFloat(name)
|
val, err := getParameterFloat(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -91,7 +94,7 @@ func (r *Remote) GetFloat(name string) (float64, error) {
|
|||||||
return val, nil
|
return val, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets a float paramter value
|
// SetFloat sets a float paramter value
|
||||||
func (r *Remote) SetFloat(name string, value float64) error {
|
func (r *Remote) SetFloat(name string, value float64) error {
|
||||||
err := setParameterFloat(name, value)
|
err := setParameterFloat(name, value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -100,7 +103,7 @@ func (r *Remote) SetFloat(name string, value float64) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets a string parameter value
|
// GetString gets a string parameter value
|
||||||
func (r *Remote) GetString(name string) (string, error) {
|
func (r *Remote) GetString(name string) (string, error) {
|
||||||
val, err := getParameterString(name)
|
val, err := getParameterString(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -109,7 +112,7 @@ func (r *Remote) GetString(name string) (string, error) {
|
|||||||
return val, nil
|
return val, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets a string paramter value
|
// SetString sets a string parameter value
|
||||||
func (r *Remote) SetString(name, value string) error {
|
func (r *Remote) SetString(name, value string) error {
|
||||||
err := setParameterString(name, value)
|
err := setParameterString(name, value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -137,14 +140,14 @@ func (r *Remote) Deregister(o observer) {
|
|||||||
r.pooler.Deregister(o)
|
r.pooler.Deregister(o)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EventAdd adds an event to the Pooler
|
// EventAdd adds events to the Pooler
|
||||||
func (r *Remote) EventAdd(event string) {
|
func (r *Remote) EventAdd(events ...string) {
|
||||||
r.pooler.event.Add(event)
|
r.pooler.event.Add(events...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EventRemove removes an event from the Pooler
|
// EventRemove removes events from the Pooler
|
||||||
func (r *Remote) EventRemove(event string) {
|
func (r *Remote) EventRemove(events ...string) {
|
||||||
r.pooler.event.Remove(event)
|
r.pooler.event.Remove(events...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// remoteBuilder defines the interface builder types must satisfy
|
// remoteBuilder defines the interface builder types must satisfy
|
||||||
@@ -162,7 +165,7 @@ type remoteBuilder interface {
|
|||||||
Get() *Remote
|
Get() *Remote
|
||||||
}
|
}
|
||||||
|
|
||||||
// directory is responsible for directing the genericBuilder
|
// director is responsible for directing the genericBuilder
|
||||||
type director struct {
|
type director struct {
|
||||||
builder remoteBuilder
|
builder remoteBuilder
|
||||||
}
|
}
|
||||||
@@ -197,7 +200,7 @@ func (b *genericBuilder) setKind() remoteBuilder {
|
|||||||
// makeStrip makes a strip slice and assigns it to remote.Strip
|
// makeStrip makes a strip slice and assigns it to remote.Strip
|
||||||
// []iStrip comprises of both physical and virtual strip types
|
// []iStrip comprises of both physical and virtual strip types
|
||||||
func (b *genericBuilder) makeStrip() remoteBuilder {
|
func (b *genericBuilder) makeStrip() remoteBuilder {
|
||||||
fmt.Println("building strip")
|
log.Info("building strip")
|
||||||
_strip := make([]iStrip, b.k.NumStrip())
|
_strip := make([]iStrip, b.k.NumStrip())
|
||||||
for i := 0; i < b.k.NumStrip(); i++ {
|
for i := 0; i < b.k.NumStrip(); i++ {
|
||||||
if i < b.k.PhysIn {
|
if i < b.k.PhysIn {
|
||||||
@@ -213,7 +216,7 @@ func (b *genericBuilder) makeStrip() remoteBuilder {
|
|||||||
// makeBus makes a bus slice and assigns it to remote.Bus
|
// makeBus makes a bus slice and assigns it to remote.Bus
|
||||||
// []t_bus comprises of both physical and virtual bus types
|
// []t_bus comprises of both physical and virtual bus types
|
||||||
func (b *genericBuilder) makeBus() remoteBuilder {
|
func (b *genericBuilder) makeBus() remoteBuilder {
|
||||||
fmt.Println("building bus")
|
log.Info("building bus")
|
||||||
_bus := make([]iBus, b.k.NumBus())
|
_bus := make([]iBus, b.k.NumBus())
|
||||||
for i := 0; i < b.k.NumBus(); i++ {
|
for i := 0; i < b.k.NumBus(); i++ {
|
||||||
if i < b.k.PhysOut {
|
if i < b.k.PhysOut {
|
||||||
@@ -228,7 +231,7 @@ func (b *genericBuilder) makeBus() remoteBuilder {
|
|||||||
|
|
||||||
// makeButton makes a button slice and assigns it to remote.Button
|
// makeButton makes a button slice and assigns it to remote.Button
|
||||||
func (b *genericBuilder) makeButton() remoteBuilder {
|
func (b *genericBuilder) makeButton() remoteBuilder {
|
||||||
fmt.Println("building button")
|
log.Info("building button")
|
||||||
_button := make([]button, 80)
|
_button := make([]button, 80)
|
||||||
for i := 0; i < 80; i++ {
|
for i := 0; i < 80; i++ {
|
||||||
_button[i] = newButton(i)
|
_button[i] = newButton(i)
|
||||||
@@ -239,35 +242,35 @@ func (b *genericBuilder) makeButton() remoteBuilder {
|
|||||||
|
|
||||||
// makeCommand makes a command type and assigns it to remote.Command
|
// makeCommand makes a command type and assigns it to remote.Command
|
||||||
func (b *genericBuilder) makeCommand() remoteBuilder {
|
func (b *genericBuilder) makeCommand() remoteBuilder {
|
||||||
fmt.Println("building command")
|
log.Info("building command")
|
||||||
b.r.Command = newCommand()
|
b.r.Command = newCommand()
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeVban makes a vban type and assigns it to remote.Vban
|
// makeVban makes a vban type and assigns it to remote.Vban
|
||||||
func (b *genericBuilder) makeVban() remoteBuilder {
|
func (b *genericBuilder) makeVban() remoteBuilder {
|
||||||
fmt.Println("building vban")
|
log.Info("building vban")
|
||||||
b.r.Vban = newVban(b.k)
|
b.r.Vban = newVban(b.k)
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeDevice makes a device type and assigns it to remote.Device
|
// makeDevice makes a device type and assigns it to remote.Device
|
||||||
func (b *genericBuilder) makeDevice() remoteBuilder {
|
func (b *genericBuilder) makeDevice() remoteBuilder {
|
||||||
fmt.Println("building device")
|
log.Info("building device")
|
||||||
b.r.Device = newDevice()
|
b.r.Device = newDevice()
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeRecorder makes a recorder type and assigns it to remote.Recorder
|
// makeRecorder makes a recorder type and assigns it to remote.Recorder
|
||||||
func (b *genericBuilder) makeRecorder() remoteBuilder {
|
func (b *genericBuilder) makeRecorder() remoteBuilder {
|
||||||
fmt.Println("building recorder")
|
log.Info("building recorder")
|
||||||
b.r.Recorder = newRecorder()
|
b.r.Recorder = newRecorder()
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeMidi makes a midi type and assigns it to remote.Midi
|
// makeMidi makes a midi type and assigns it to remote.Midi
|
||||||
func (b *genericBuilder) makeMidi() remoteBuilder {
|
func (b *genericBuilder) makeMidi() remoteBuilder {
|
||||||
fmt.Println("building midi")
|
log.Info("building midi")
|
||||||
b.r.Midi = newMidi()
|
b.r.Midi = newMidi()
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
@@ -335,6 +338,11 @@ var (
|
|||||||
vmdelay int
|
vmdelay int
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
log.SetOutput(os.Stdout)
|
||||||
|
log.SetLevel(log.WarnLevel)
|
||||||
|
}
|
||||||
|
|
||||||
// NewRemote returns a Remote type for a kind
|
// NewRemote returns a Remote type for a kind
|
||||||
// this is the interface entry point
|
// this is the interface entry point
|
||||||
func NewRemote(kindId string, delay int) (*Remote, error) {
|
func NewRemote(kindId string, delay int) (*Remote, error) {
|
||||||
|
|||||||
44
strip.go
44
strip.go
@@ -3,9 +3,11 @@ package voicemeeter
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// iStrip defines the interface bus types must satisfy
|
// iStrip defines the interface strip types must satisfy
|
||||||
type iStrip interface {
|
type iStrip interface {
|
||||||
String() string
|
String() string
|
||||||
GetMute() bool
|
GetMute() bool
|
||||||
@@ -179,14 +181,16 @@ func (p *physicalStrip) SetAudibility(val float64) {
|
|||||||
p.setter_float("Audibility", val)
|
p.setter_float("Audibility", val)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMc panics reason invalid parameter
|
// GetMc logs a warning reason invalid parameter
|
||||||
|
// it always returns zero value
|
||||||
func (p *physicalStrip) GetMc() bool {
|
func (p *physicalStrip) GetMc() bool {
|
||||||
panic("invalid parameter MC for physicalStrip")
|
log.Warn("invalid parameter MC for physicalStrip")
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetMc panics reason invalid parameter
|
// SetMc logs a warning reason invalid parameter
|
||||||
func (p *physicalStrip) SetMc(val bool) {
|
func (p *physicalStrip) SetMc(val bool) {
|
||||||
panic("invalid parameter MC for physicalStrip")
|
log.Warn("invalid parameter MC for physicalStrip")
|
||||||
}
|
}
|
||||||
|
|
||||||
// virtualStrip represents a single virtual strip
|
// virtualStrip represents a single virtual strip
|
||||||
@@ -221,34 +225,40 @@ func (v *virtualStrip) SetMc(val bool) {
|
|||||||
v.setter_bool("MC", val)
|
v.setter_bool("MC", val)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetComp panics reason invalid parameter
|
// GetComp logs a warning reason invalid parameter
|
||||||
|
// it always returns zero value
|
||||||
func (v *virtualStrip) GetComp() float64 {
|
func (v *virtualStrip) GetComp() float64 {
|
||||||
panic("invalid parameter Comp for virtualStrip")
|
log.Warn("invalid parameter Comp for virtualStrip")
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetComp panics reason invalid parameter
|
// SetComp logs a warning reason invalid parameter
|
||||||
func (v *virtualStrip) SetComp(val float64) {
|
func (v *virtualStrip) SetComp(val float64) {
|
||||||
panic("invalid parameter Comp for virtualStrip")
|
log.Warn("invalid parameter Comp for virtualStrip")
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetGate panics reason invalid parameter
|
// GetGate logs a warning reason invalid parameter
|
||||||
|
// it always returns zero value
|
||||||
func (v *virtualStrip) GetGate() float64 {
|
func (v *virtualStrip) GetGate() float64 {
|
||||||
panic("invalid parameter Gate for virtualStrip")
|
log.Warn("invalid parameter Gate for virtualStrip")
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetGate panics reason invalid parameter
|
// SetGate logs a warning reason invalid parameter
|
||||||
func (v *virtualStrip) SetGate(val float64) {
|
func (v *virtualStrip) SetGate(val float64) {
|
||||||
panic("invalid parameter Gate for virtualStrip")
|
log.Warn("invalid parameter Gate for virtualStrip")
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAudibility panics reason invalid parameter
|
// GetAudibility logs a warning reason invalid parameter
|
||||||
|
// it always returns zero value
|
||||||
func (v *virtualStrip) GetAudibility() float64 {
|
func (v *virtualStrip) GetAudibility() float64 {
|
||||||
panic("invalid parameter Audibility for virtualStrip")
|
log.Warn("invalid parameter Audibility for virtualStrip")
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAudibility panics reason invalid parameter
|
// SetAudibility logs a warning reason invalid parameter
|
||||||
func (v *virtualStrip) SetAudibility(val float64) {
|
func (v *virtualStrip) SetAudibility(val float64) {
|
||||||
panic("invalid parameter Audibility for virtualStrip")
|
log.Warn("invalid parameter Audibility for virtualStrip")
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppGain sets the gain in db by val for the app matching name.
|
// AppGain sets the gain in db by val for the app matching name.
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/onyx-and-iris/voicemeeter-api-go"
|
"github.com/onyx-and-iris/voicemeeter"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
4
util.go
4
util.go
@@ -28,8 +28,8 @@ func roundFloat(val float64, precision uint) float64 {
|
|||||||
// convertLevel performs the necessary math for a channel level
|
// convertLevel performs the necessary math for a channel level
|
||||||
func convertLevel(i float64) float64 {
|
func convertLevel(i float64) float64 {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
val := 20 * math.Log10(float64(i))
|
val := 20 * math.Log10(i)
|
||||||
return float64(roundFloat(float64(val), 1))
|
return roundFloat(val, 1)
|
||||||
}
|
}
|
||||||
return -200.0
|
return -200.0
|
||||||
}
|
}
|
||||||
|
|||||||
21
vban.go
21
vban.go
@@ -1,6 +1,10 @@
|
|||||||
package voicemeeter
|
package voicemeeter
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
// iVban defines the interface vban types must satisfy
|
// iVban defines the interface vban types must satisfy
|
||||||
type iVban interface {
|
type iVban interface {
|
||||||
@@ -105,7 +109,8 @@ func (v *vbanStream) SetBit(val int) {
|
|||||||
case 24:
|
case 24:
|
||||||
val = 2
|
val = 2
|
||||||
default:
|
default:
|
||||||
panic("expected value 16 or 24")
|
log.Warn("expected value 16 or 24")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
v.setter_int("Bit", val)
|
v.setter_int("Bit", val)
|
||||||
}
|
}
|
||||||
@@ -139,19 +144,19 @@ func newVbanInStream(i int) iVban {
|
|||||||
return iVban(&vbi)
|
return iVban(&vbi)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetSr panics reason read only
|
// SetSr logs a warning reason read only
|
||||||
func (vbi *vbanInStream) SetSr(val int) {
|
func (vbi *vbanInStream) SetSr(val int) {
|
||||||
panic("SR is readonly for vban instreams")
|
log.Warn("SR is readonly for vban instreams")
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetChannel panics reason read only
|
// SetChannel logs a warning reason read only
|
||||||
func (vbi *vbanInStream) SetChannel(val int) {
|
func (vbi *vbanInStream) SetChannel(val int) {
|
||||||
panic("channel is readonly for vban instreams")
|
log.Warn("channel is readonly for vban instreams")
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetBit panics reason read only
|
// SetBit logs a warning reason read only
|
||||||
func (vbi *vbanInStream) SetBit(val int) {
|
func (vbi *vbanInStream) SetBit(val int) {
|
||||||
panic("bit is readonly for vban instreams")
|
log.Warn("bit is readonly for vban instreams")
|
||||||
}
|
}
|
||||||
|
|
||||||
type vbanOutStream struct {
|
type vbanOutStream struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user