13 Commits

Author SHA1 Message Date
onyx-and-iris
505b5969a2 go fmt all files.
add midi event toggle to the pooler
2022-08-23 14:03:07 +01:00
onyx-and-iris
7f992a1a87 only check subject once per update 2022-08-23 03:58:49 +01:00
onyx-and-iris
fa8e9f3e76 obs example added. 2022-08-23 03:53:51 +01:00
onyx-and-iris
7a79555cb8 use log.Fatal during setup procedures.
update readme example
2022-08-23 03:35:34 +01:00
onyx-and-iris
6fabc43998 return err from NewRemote\
pass Kind.Name to logout

update examples/tests to reflect changes
2022-08-23 03:16:43 +01:00
onyx-and-iris
3fd08ff606 fix deregister in observer example 2022-08-22 22:54:38 +01:00
onyx-and-iris
7744971a10 changelog updated to reflect changes
minor version bump
2022-08-22 22:40:08 +01:00
onyx-and-iris
82bbcd06b1 tested against version updated.
Get/Set Float/String, EventAdd() + EventRemote() added to README

Midi and Events sections added to README.
2022-08-22 22:39:35 +01:00
onyx-and-iris
cba2ac85ec observer example updated with midi event.
ldirty now enabled explicitly in observer example.
2022-08-22 22:34:32 +01:00
onyx-and-iris
dd895daffb float/string getter/setter tests added
test helper added
2022-08-22 22:34:03 +01:00
onyx-and-iris
87a05d81e4 getter/setter method forwarders added to Remote
EventAdd() and EventRemote() added to Remote

method chaining in builder types split across lines.
2022-08-22 22:33:22 +01:00
onyx-and-iris
3ea4aee863 event type added for toggline evet subscriptions.
level updates now disabled by default.

each event updater runs in its own goroutine.
2022-08-22 22:29:30 +01:00
onyx-and-iris
69476ffcd9 getMidiMessage implemented
midi type added.
2022-08-22 22:28:11 +01:00
14 changed files with 487 additions and 48 deletions

View File

@@ -11,6 +11,22 @@ Before any major/minor/patch bump all unit tests will be run to verify they pass
- [x]
## [1.3.0] - 2022-08-22
### Added
- midi type, supports midi devices
- midi updates added to the pooler
- event type, supports toggling event updates through EventAdd() and EventRemove() methods.
- Forwarder methods for get/set float/string parameters added to Remote type
- Midi, Events sections added to README.
### Changed
- macrobutton updates moved into its own goroutine
- observer example updated to include midi updates
- level updates are now disabled by default, should be enabled explicitly
## [1.2.0] - 2022-07-10
### Added

View File

@@ -8,9 +8,9 @@ For an outline of past/future changes refer to: [CHANGELOG](CHANGELOG.md)
## Tested against
- Basic 1.0.8.2
- Banana 2.0.6.2
- Potato 3.0.2.2
- Basic 1.0.8.4
- Banana 2.0.6.4
- Potato 3.0.2.4
## Requirements
@@ -42,21 +42,24 @@ package main
import (
"fmt"
"log"
"github.com/onyx-and-iris/voicemeeter-api-go"
)
func main() {
kindId := "banana"
vm := voicemeeter.NewRemote(kindId)
vm, err := voicemeeter.NewRemote(kindId)
if err != nil {
log.Fatal(err)
}
defer vm.Logout()
vm.Login()
vm.Strip[0].SetLabel("rode podmic")
vm.Strip[0].SetMute(true)
fmt.Printf("Strip 0 (%s) mute was set to %v\n", vm.Strip[0].GetLabel(), vm.Strip[0].GetMute())
vm.Logout()
}
```
@@ -98,6 +101,10 @@ pointer to device type, represents physical input/output hardware devices
pointer to recorder type, represents the recorder
#### `vm.Midi`
pointer to midi type, represents a connected midi device
#### `vm.Type()`
returns the type of Voicemeeter as a string
@@ -106,6 +113,22 @@ returns the type of Voicemeeter as a string
returns the version of Voicemeeter as a string
#### `vm.GetFloat(<param>)`
gets a float parameter value
#### `vm.SetFloat(<param>, <value>)`
sets a float parameter value eg. vm.SetFloat("strip[0].mute", 1)
#### `vm.GetString(<param>)`
gets a string parameter value
#### `vm.SetString(<param>, <value>)`
sets a string parameter value eg. vm.SetString("strip[0].label", "podmic")
#### `vm.SendText(<script>)`
sets many parameters in script format eg. ("Strip[0].Mute=1;Bus[3].Gain=3.6")
@@ -118,13 +141,21 @@ register an object as an observer
deregister an object as an observer
#### `vm.EventAdd(<event>)`
adds an event to the pooler eg. vm.EventAdd("ldirty")
#### `vm.EventRemove(<event>)`
removes an event to the pooler eg. vm.EventRemove("pdirty")
#### `vm.Pdirty()`
returns True iff a GUI parameter has changed
#### `vm.Mdirty()`
returns True iff a macrobutton paramter has changed
returns True iff a macrobutton parameter has changed
## `Available commands`
@@ -348,8 +379,8 @@ vm.Vban.OutStream[3].SetBit(24)
The following methods are available
- `Ins`
- `Outs`
- `Ins()`
- `Outs()`
- `Input(val int)`
- `Output(val int)`
@@ -386,6 +417,38 @@ vm.Recorder.Loop(true)
vm.Recorder.SetB2(false)
```
### Midi
The following methods are available
- `Channel()` returns the current midi channel
- `Current()` returns the most recently pressed midi button
- `Get(<button>)` returns the value in cache for the midi button
example:
```go
var current = vm.Midi.Current()
var val = vm.Midi.Get(current)
```
### Events
By default level updates are disabled. Any event may be enabled or disabled. The following events exist:
- `pdirty` parameter updates
- `mdirty` macrobutton updates
- `midi` midi updates
- `ldirty` level updates
example:
```go
vm.EventAdd("ldirty")
vm.EventRemove("pdirty")
```
### Run tests
To run all tests:

40
base.go
View File

@@ -37,6 +37,8 @@ var (
vmMdirty = mod.NewProc("VBVMR_MacroButton_IsDirty")
vmGetMacroStatus = mod.NewProc("VBVMR_MacroButton_GetStatus")
vmSetMacroStatus = mod.NewProc("VBVMR_MacroButton_SetStatus")
vmGetMidiMessage = mod.NewProc("VBVMR_GetMidiMessage")
)
// login logs into the API,
@@ -52,14 +54,14 @@ func login(kindId string) {
fmt.Println(err)
os.Exit(1)
}
fmt.Println("Logged into API")
fmt.Printf("Logged into Voicemeeter %s\n", kindId)
for pdirty() || mdirty() {
}
}
// logout logs out of the API,
// delayed for 100ms to allow final operation to complete.
func logout() {
func logout(kindId string) {
time.Sleep(100 * time.Millisecond)
res, _, _ := vmLogout.Call()
if res != 0 {
@@ -67,7 +69,7 @@ func logout() {
fmt.Println(err)
os.Exit(1)
}
fmt.Println("Logged out of API")
fmt.Printf("Logged out of Voicemeeter %s\n", kindId)
}
// runVoicemeeter attempts to launch a Voicemeeter GUI of a kind.
@@ -315,3 +317,35 @@ func getLevel(type_, i int) float32 {
}
return val
}
// getMidiMessage gets midi channel, pitch and velocity for a single midi input
func getMidiMessage() bool {
var midi = newMidi()
var b1 [1024]byte
res, _, _ := vmGetMidiMessage.Call(
uintptr(unsafe.Pointer(&b1[0])),
uintptr(1024),
)
x := int(res)
if x < 0 {
err := fmt.Errorf("VBVMR_GetMidiMessage returned %d", res)
fmt.Println(err)
os.Exit(1)
}
msg := bytes.Trim(b1[:], "\x00")
if len(msg) > 0 {
for i := 0; i < len(msg)%3; i++ {
msg = append(msg, 0)
}
for i := 0; i < len(msg); i += 3 {
var ch = int(msg[i])
var pitch = int(msg[i+1])
var vel = int(msg[i+2])
midi.channel = ch
midi.current = pitch
midi.cache[pitch] = vel
}
}
return len(msg) > 0
}

16
examples/obs/go.mod Normal file
View File

@@ -0,0 +1,16 @@
module main
go 1.18
require (
github.com/andreykaipov/goobs v0.10.0
github.com/onyx-and-iris/voicemeeter-api-go v1.4.1
)
require (
github.com/buger/jsonparser v1.1.1 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d // indirect
)

18
examples/obs/go.sum Normal file
View File

@@ -0,0 +1,18 @@
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=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
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/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=
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.4.1 h1:2vGaRGCPwN9PlWspbdkDelsfxWHHkZqxozkd6FOcl28=
github.com/onyx-and-iris/voicemeeter-api-go v1.4.1/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=

78
examples/obs/main.go Normal file
View File

@@ -0,0 +1,78 @@
package main
import (
"fmt"
"log"
"time"
"github.com/onyx-and-iris/voicemeeter-api-go"
"github.com/andreykaipov/goobs"
"github.com/andreykaipov/goobs/api/events"
)
func onStart(vm *voicemeeter.Remote) {
vm.Strip[0].SetMute(true)
vm.Strip[1].SetB1(true)
vm.Strip[2].SetB1(true)
}
func onBrb(vm *voicemeeter.Remote) {
vm.Strip[7].FadeTo(0, 500)
vm.Bus[0].SetMute(true)
}
func onLive(vm *voicemeeter.Remote) {
vm.Strip[0].SetMute(false)
vm.Strip[7].FadeTo(-6, 500)
vm.Strip[7].SetA3(true)
vm.Vban.InStream[0].SetOn(true)
}
func onEnd(vm *voicemeeter.Remote) {
vm.Strip[0].SetMute(true)
vm.Strip[1].SetMute(true)
vm.Strip[1].SetB1(false)
vm.Strip[2].SetMute(true)
vm.Strip[2].SetB1(false)
vm.Vban.InStream[0].SetOn(false)
}
func main() {
vm, err := voicemeeter.NewRemote("potato")
if err != nil {
log.Fatal(err)
}
defer vm.Logout()
vm.Login()
obs, err := goobs.New("localhost:4455", goobs.WithPassword("mystrongpass"))
if err != nil {
log.Fatal(err)
}
defer obs.Disconnect()
version, _ := obs.General.GetVersion()
fmt.Printf("OBS Studio version: %s\n", version.ObsVersion)
fmt.Printf("Websocket server version: %s\n", version.ObsWebSocketVersion)
go obs.Listen(func(event any) {
switch e := event.(type) {
case *events.CurrentProgramSceneChanged:
fmt.Printf("Switched to scene %s\n", e.SceneName)
switch e.SceneName {
case "START":
onStart(vm)
case "BRB":
onBrb(vm)
case "LIVE":
onLive(vm)
case "END":
onEnd(vm)
}
}
})
time.Sleep(30 * time.Second)
}

View File

@@ -2,7 +2,7 @@ package main
import (
"fmt"
"strings"
"log"
"time"
"github.com/onyx-and-iris/voicemeeter-api-go"
@@ -12,14 +12,24 @@ type observer struct {
vm *voicemeeter.Remote
}
func (o observer) Register() {
o.vm.Register(o)
}
func (o observer) Deregister() {
o.vm.Deregister(o)
}
func (o observer) OnUpdate(subject string) {
if strings.Compare(subject, "pdirty") == 0 {
if subject == "pdirty" {
fmt.Println("pdirty!")
}
if strings.Compare(subject, "mdirty") == 0 {
} else if subject == "mdirty" {
fmt.Println("mdirty!")
}
if strings.Compare(subject, "ldirty") == 0 {
} else if subject == "midi" {
var current = o.vm.Midi.Current()
var val = o.vm.Midi.Get(current)
fmt.Printf("Value of midi button %d: %d\n", current, val)
} else if subject == "ldirty" {
fmt.Printf("%v %v %v %v %v %v %v %v\n",
o.vm.Bus[0].Levels().IsDirty(),
o.vm.Bus[1].Levels().IsDirty(),
@@ -34,13 +44,18 @@ func (o observer) OnUpdate(subject string) {
}
func main() {
vm := voicemeeter.NewRemote("potato")
vm, err := voicemeeter.NewRemote("potato")
if err != nil {
log.Fatal(err)
}
defer vm.Logout()
vm.Login()
// enable level updates (disabled by default)
vm.EventAdd("ldirty")
o := observer{vm}
vm.Register(o)
o.Register()
time.Sleep(30 * time.Second)
vm.Deregister(o)
vm.Logout()
o.Deregister()
}

29
helper_test.go Normal file
View File

@@ -0,0 +1,29 @@
package voicemeeter
import (
"log"
"os"
"testing"
"time"
)
var (
vm, err = NewRemote("potato")
)
func TestMain(m *testing.M) {
if err != nil {
log.Fatal(err)
}
vm.Login()
code := m.Run()
vm.Logout()
os.Exit(code)
}
func sync() {
time.Sleep(30 * time.Millisecond)
for vm.Pdirty() || vm.Mdirty() {
}
}

28
midi.go Normal file
View File

@@ -0,0 +1,28 @@
package voicemeeter
var midi *midi_t
type midi_t struct {
channel int
current int
cache map[int]int
}
func newMidi() *midi_t {
if midi == nil {
midi = &midi_t{0, 0, map[int]int{}}
}
return midi
}
func (m *midi_t) Channel() int {
return m.channel
}
func (m *midi_t) Current() int {
return m.current
}
func (m *midi_t) Get(key int) int {
return m.cache[key]
}

View File

@@ -3,7 +3,7 @@ package voicemeeter
import (
"errors"
"fmt"
"os"
"log"
"path/filepath"
"runtime"
"strings"
@@ -49,8 +49,7 @@ func dllPath() (string, error) {
func getDllPath() string {
path, err := dllPath()
if err != nil {
fmt.Println(err)
os.Exit(1)
log.Fatal(err)
}
return path
}

View File

@@ -40,11 +40,49 @@ func (p *publisher) notify(subject string) {
}
}
type event struct {
pdirty bool
mdirty bool
midi bool
ldirty bool
}
func newEvent() *event {
return &event{true, true, true, false}
}
func (e *event) Add(ev string) {
switch ev {
case "pdirty":
e.pdirty = true
case "mdirty":
e.mdirty = true
case "midi":
e.midi = true
case "ldirty":
e.ldirty = true
}
}
func (e *event) Remove(ev string) {
switch ev {
case "pdirty":
e.pdirty = false
case "mdirty":
e.mdirty = false
case "midi":
e.midi = false
case "ldirty":
e.ldirty = false
}
}
// pooler continuously polls the dirty paramters
// it is expected to be run in a goroutine
type pooler struct {
k *kind
run bool
event *event
publisher
}
@@ -52,29 +90,47 @@ func newPooler(k *kind) *pooler {
p := &pooler{
k: k,
run: true,
event: newEvent(),
}
go p.runner()
go p.parameters()
go p.macrobuttons()
go p.midi()
go p.levels()
return p
}
func (p *pooler) runner() {
func (p *pooler) parameters() {
for p.run {
if pdirty() {
if p.event.pdirty && pdirty() {
p.notify("pdirty")
}
if mdirty() {
time.Sleep(33 * time.Millisecond)
}
}
func (p *pooler) macrobuttons() {
for p.run {
if p.event.mdirty && mdirty() {
p.notify("mdirty")
}
time.Sleep(33 * time.Millisecond)
}
}
func (p *pooler) midi() {
for p.run {
if p.event.midi && getMidiMessage() {
p.notify("midi")
}
time.Sleep(33 * time.Millisecond)
}
}
func (p *pooler) levels() {
_levelCache = newLevelCache(p.k)
for p.run {
if ldirty(p.k) {
if p.event.ldirty && ldirty(p.k) {
update(_levelCache.stripLevels, _levelCache.stripLevelsBuff, (2*p.k.PhysIn)+(8*p.k.VirtIn))
update(_levelCache.busLevels, _levelCache.busLevelsBuff, 8*p.k.NumBus())
p.notify("ldirty")

View File

@@ -2,7 +2,6 @@ package voicemeeter
import (
"fmt"
"os"
)
// A Remote type represents the API for a kind
@@ -15,6 +14,7 @@ type Remote struct {
Vban *vban
Device *device
Recorder *recorder
Midi *midi_t
pooler *pooler
}
@@ -35,7 +35,7 @@ func (r *Remote) Login() {
// it also terminates the pooler
func (r *Remote) Logout() {
r.pooler.run = false
logout()
logout(r.Kind.Name)
}
// Type returns the type of Voicemeeter (basic, banana, potato)
@@ -58,6 +58,26 @@ func (r *Remote) Mdirty() bool {
return mdirty()
}
// Gets a float parameter value
func (r *Remote) GetFloat(name string) float64 {
return getParameterFloat(name)
}
// Sets a float paramter value
func (r *Remote) SetFloat(name string, value float32) {
setParameterFloat(name, value)
}
// Gets a string parameter value
func (r *Remote) GetString(name string) string {
return getParameterString(name)
}
// Sets a string paramter value
func (r *Remote) SetString(name, value string) {
setParameterString(name, value)
}
// SendText sets multiple parameters by script
func (r *Remote) SendText(script string) {
setParametersMulti(script)
@@ -73,6 +93,16 @@ func (r *Remote) Deregister(o observer) {
r.pooler.Deregister(o)
}
// EventAdd adds an event to the Pooler
func (r *Remote) EventAdd(event string) {
r.pooler.event.Add(event)
}
// EventRemove removes an event from the Pooler
func (r *Remote) EventRemove(event string) {
r.pooler.event.Remove(event)
}
// remoteBuilder defines the interface builder types must satisfy
type remoteBuilder interface {
setKind() remoteBuilder
@@ -83,6 +113,7 @@ type remoteBuilder interface {
makeVban() remoteBuilder
makeDevice() remoteBuilder
makeRecorder() remoteBuilder
makeMidi() remoteBuilder
Build() remoteBuilder
Get() *Remote
}
@@ -190,6 +221,13 @@ func (b *genericBuilder) makeRecorder() remoteBuilder {
return b
}
// makeMidi makes a midi type and assigns it to remote.Midi
func (b *genericBuilder) makeMidi() remoteBuilder {
fmt.Println("building midi")
b.r.Midi = newMidi()
return b
}
// Get returns a fully constructed remote type for a kind
func (b *genericBuilder) Get() *Remote {
return &b.r
@@ -202,7 +240,14 @@ type basicBuilder struct {
// Build defines the steps required to build a basic type
func (basb *genericBuilder) Build() remoteBuilder {
return basb.setKind().makeStrip().makeBus().makeButton().makeCommand().makeVban().makeDevice()
return basb.setKind().
makeStrip().
makeBus().
makeButton().
makeCommand().
makeVban().
makeDevice().
makeMidi()
}
// bananaBuilder represents a builder specific to banana type
@@ -212,7 +257,15 @@ type bananaBuilder struct {
// Build defines the steps required to build a banana type
func (banb *bananaBuilder) Build() remoteBuilder {
return banb.setKind().makeStrip().makeBus().makeButton().makeCommand().makeVban().makeDevice().makeRecorder()
return banb.setKind().
makeStrip().
makeBus().
makeButton().
makeCommand().
makeVban().
makeDevice().
makeRecorder().
makeMidi()
}
// potatoBuilder represents a builder specific to potato type
@@ -222,17 +275,24 @@ type potatoBuilder struct {
// Build defines the steps required to build a potato type
func (potb *potatoBuilder) Build() remoteBuilder {
return potb.setKind().makeStrip().makeBus().makeButton().makeCommand().makeVban().makeDevice().makeRecorder()
return potb.setKind().
makeStrip().
makeBus().
makeButton().
makeCommand().
makeVban().
makeDevice().
makeRecorder().
makeMidi()
}
// NewRemote returns a Remote type for a kind
// this is the interface entry point
func NewRemote(kindId string) *Remote {
func NewRemote(kindId string) (*Remote, error) {
_kind, ok := kindMap[kindId]
if !ok {
err := fmt.Errorf("unknown Voicemeeter kind '%s'", kindId)
fmt.Println(err)
os.Exit(1)
return nil, err
}
director := director{}
@@ -245,5 +305,5 @@ func NewRemote(kindId string) *Remote {
director.SetBuilder(&potatoBuilder{genericBuilder{_kind, Remote{}}})
}
director.Construct()
return director.Get()
return director.Get(), nil
}

View File

@@ -8,7 +8,7 @@ import (
func TestGetBasicRemote(t *testing.T) {
//t.Skip("skipping test")
__rem := NewRemote("basic")
__rem, _ := NewRemote("basic")
t.Run("Should return a remote basic type", func(t *testing.T) {
assert.NotNil(t, __rem)
})
@@ -34,7 +34,7 @@ func TestGetBasicRemote(t *testing.T) {
func TestGetBananaRemote(t *testing.T) {
//t.Skip("skipping test")
__rem := NewRemote("banana")
__rem, _ := NewRemote("banana")
t.Run("Should return a remote banana type", func(t *testing.T) {
assert.NotNil(t, __rem)
})
@@ -60,7 +60,7 @@ func TestGetBananaRemote(t *testing.T) {
func TestGetPotatoRemote(t *testing.T) {
//t.Skip("skipping test")
__rem := NewRemote("potato")
__rem, _ := NewRemote("potato")
t.Run("Should return a remote basic type", func(t *testing.T) {
assert.NotNil(t, __rem)
})
@@ -83,3 +83,24 @@ func TestGetPotatoRemote(t *testing.T) {
assert.NotNil(t, __rem.Recorder)
})
}
func TestSetAndGetFloatParameter(t *testing.T) {
//t.Skip("skipping test")
var param = "strip[0].mute"
vm.SetFloat(param, 1)
sync()
t.Run("Should get a float parameter", func(t *testing.T) {
assert.Equal(t, float64(1), vm.GetFloat(param))
})
}
func TestSetAndGetStringParameter(t *testing.T) {
//t.Skip("skipping test")
var param = "strip[0].label"
var val = "test0"
vm.SetString(param, val)
sync()
t.Run("Should get a string parameter", func(t *testing.T) {
assert.Equal(t, val, vm.GetString(param))
})
}

View File

@@ -1,6 +1,7 @@
package voicemeeter_test
import (
"log"
"os"
"testing"
"time"
@@ -9,10 +10,15 @@ import (
)
var (
vm = voicemeeter.NewRemote("potato")
vm, err = voicemeeter.NewRemote("potato")
)
func TestMain(m *testing.M) {
if err != nil {
log.Fatal(err)
}
defer vm.Logout()
vm.Login()
code := m.Run()
vm.Logout()