mirror of
https://github.com/onyx-and-iris/voicemeeter.git
synced 2024-11-25 06:10:52 +00:00
export pdirty, mdirty through remote type
remote sync from setters. add sync to tests.
This commit is contained in:
parent
232f8561de
commit
a7abc43726
@ -3,6 +3,7 @@ package voicemeeter_test
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/onyx-and-iris/voicemeeter-api-go/voicemeeter"
|
||||
)
|
||||
@ -17,3 +18,9 @@ func TestMain(m *testing.M) {
|
||||
vmRem.Logout()
|
||||
os.Exit(code)
|
||||
}
|
||||
|
||||
func sync() {
|
||||
time.Sleep(30 * time.Millisecond)
|
||||
for vmRem.Pdirty() || vmRem.Mdirty() {
|
||||
}
|
||||
}
|
||||
|
@ -9,11 +9,13 @@ import (
|
||||
func TestStrip0Mute(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
vmRem.Strip[0].SetMute(true)
|
||||
sync()
|
||||
t.Run("Should return true when SetMute(true)", func(t *testing.T) {
|
||||
assert.True(t, vmRem.Strip[0].GetMute())
|
||||
})
|
||||
|
||||
vmRem.Strip[0].SetMute(false)
|
||||
sync()
|
||||
t.Run("Should return false when SetMute(false)", func(t *testing.T) {
|
||||
assert.False(t, vmRem.Strip[0].GetMute())
|
||||
})
|
||||
@ -22,11 +24,13 @@ func TestStrip0Mute(t *testing.T) {
|
||||
func TestStrip2Limit(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
vmRem.Strip[2].SetLimit(-8)
|
||||
sync()
|
||||
t.Run("Should return -8 when SetLimit(-8)", func(t *testing.T) {
|
||||
assert.Equal(t, vmRem.Strip[2].GetLimit(), -8)
|
||||
})
|
||||
|
||||
vmRem.Strip[2].SetLimit(-32)
|
||||
sync()
|
||||
t.Run("Should return -32 when SetLimit(-8)", func(t *testing.T) {
|
||||
assert.Equal(t, vmRem.Strip[2].GetLimit(), -32)
|
||||
})
|
||||
@ -36,11 +40,13 @@ func TestStrip2Limit(t *testing.T) {
|
||||
func TestStrip4Label(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
vmRem.Strip[4].SetLabel("test0")
|
||||
sync()
|
||||
t.Run("Should return test0 when SetLimit('test0')", func(t *testing.T) {
|
||||
assert.Equal(t, "test0", vmRem.Strip[4].GetLabel())
|
||||
})
|
||||
|
||||
vmRem.Strip[4].SetLabel("test1")
|
||||
sync()
|
||||
t.Run("Should return test1 when SetLimit('test1')", func(t *testing.T) {
|
||||
assert.Equal(t, "test1", vmRem.Strip[4].GetLabel())
|
||||
})
|
||||
@ -49,11 +55,13 @@ func TestStrip4Label(t *testing.T) {
|
||||
func TestStrip5Gain(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
vmRem.Strip[4].SetGain(-20.8)
|
||||
sync()
|
||||
t.Run("Should return -20.8 when SetGain(-20.8)", func(t *testing.T) {
|
||||
assert.Equal(t, vmRem.Strip[4].GetGain(), -20.8)
|
||||
})
|
||||
|
||||
vmRem.Strip[4].SetGain(-3.6)
|
||||
sync()
|
||||
t.Run("Should return -3.6 when SetGain(-3.6)", func(t *testing.T) {
|
||||
assert.Equal(t, vmRem.Strip[4].GetGain(), -3.6)
|
||||
})
|
||||
@ -62,11 +70,13 @@ func TestStrip5Gain(t *testing.T) {
|
||||
func TestStrip3Comp(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
vmRem.Strip[4].SetComp(8.1)
|
||||
sync()
|
||||
t.Run("Should return 8.1 when SetGain(8.1)", func(t *testing.T) {
|
||||
assert.Equal(t, vmRem.Strip[4].GetComp(), 8.1)
|
||||
})
|
||||
|
||||
vmRem.Strip[4].SetComp(1.6)
|
||||
sync()
|
||||
t.Run("Should return 1.6 when SetGain(1.6)", func(t *testing.T) {
|
||||
assert.Equal(t, vmRem.Strip[4].GetComp(), 1.6)
|
||||
})
|
||||
@ -75,11 +85,13 @@ func TestStrip3Comp(t *testing.T) {
|
||||
func TestStrip5Mc(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
vmRem.Strip[5].SetMc(true)
|
||||
sync()
|
||||
t.Run("Should return true when SetMc(true)", func(t *testing.T) {
|
||||
assert.True(t, vmRem.Strip[5].GetMc())
|
||||
})
|
||||
|
||||
vmRem.Strip[5].SetMc(false)
|
||||
sync()
|
||||
t.Run("Should return false when SetMc(false)", func(t *testing.T) {
|
||||
assert.False(t, vmRem.Strip[5].GetMc())
|
||||
})
|
||||
@ -88,11 +100,13 @@ func TestStrip5Mc(t *testing.T) {
|
||||
func TestStrip2GainLayer3(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
vmRem.Strip[2].GainLayer()[3].Set(-18.3)
|
||||
sync()
|
||||
t.Run("Should return -18.3 when SetMc(true)", func(t *testing.T) {
|
||||
assert.Equal(t, vmRem.Strip[2].GainLayer()[3].Get(), -18.3)
|
||||
})
|
||||
|
||||
vmRem.Strip[2].GainLayer()[3].Set(-25.6)
|
||||
sync()
|
||||
t.Run("Should return -25.6 when SetMc(true)", func(t *testing.T) {
|
||||
assert.Equal(t, vmRem.Strip[2].GainLayer()[3].Get(), -25.6)
|
||||
})
|
||||
@ -101,11 +115,13 @@ func TestStrip2GainLayer3(t *testing.T) {
|
||||
func TestBus3Eq(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
vmRem.Bus[3].SetEq(true)
|
||||
sync()
|
||||
t.Run("Should return true when SetEq(true)", func(t *testing.T) {
|
||||
assert.True(t, vmRem.Bus[3].GetEq())
|
||||
})
|
||||
|
||||
vmRem.Bus[3].SetEq(false)
|
||||
sync()
|
||||
t.Run("Should return false when SetEq(false)", func(t *testing.T) {
|
||||
assert.False(t, vmRem.Bus[3].GetEq())
|
||||
})
|
||||
@ -114,11 +130,13 @@ func TestBus3Eq(t *testing.T) {
|
||||
func TestBus4Label(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
vmRem.Bus[4].SetLabel("test0")
|
||||
sync()
|
||||
t.Run("Should return test0 when SetEq('test0')", func(t *testing.T) {
|
||||
assert.Equal(t, "test0", vmRem.Bus[4].GetLabel())
|
||||
})
|
||||
|
||||
vmRem.Bus[4].SetLabel("test1")
|
||||
sync()
|
||||
t.Run("Should return test1 when SetEq('test1')", func(t *testing.T) {
|
||||
assert.Equal(t, "test1", vmRem.Bus[4].GetLabel())
|
||||
})
|
||||
@ -127,6 +145,7 @@ func TestBus4Label(t *testing.T) {
|
||||
func TestBus3ModeAmix(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
vmRem.Bus[3].Mode().SetAmix(true)
|
||||
sync()
|
||||
t.Run("Should return true when Mode().SetAmix(true)", func(t *testing.T) {
|
||||
assert.True(t, vmRem.Bus[3].Mode().GetAmix())
|
||||
})
|
||||
@ -135,11 +154,13 @@ func TestBus3ModeAmix(t *testing.T) {
|
||||
func TestVbanInStream0On(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
vmRem.Vban.InStream[0].SetOn(true)
|
||||
sync()
|
||||
t.Run("Should return true when SetOn(true)", func(t *testing.T) {
|
||||
assert.True(t, vmRem.Vban.InStream[0].GetOn())
|
||||
})
|
||||
|
||||
vmRem.Vban.InStream[0].SetOn(false)
|
||||
sync()
|
||||
t.Run("Should return false when SetOn(false)", func(t *testing.T) {
|
||||
assert.False(t, vmRem.Vban.InStream[0].GetOn())
|
||||
})
|
||||
@ -148,11 +169,13 @@ func TestVbanInStream0On(t *testing.T) {
|
||||
func TestVbanOutStream6On(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
vmRem.Vban.OutStream[6].SetOn(true)
|
||||
sync()
|
||||
t.Run("Should return true when SetOn(true)", func(t *testing.T) {
|
||||
assert.True(t, vmRem.Vban.OutStream[6].GetOn())
|
||||
})
|
||||
|
||||
vmRem.Vban.OutStream[6].SetOn(false)
|
||||
sync()
|
||||
t.Run("Should return false when SetOn(false)", func(t *testing.T) {
|
||||
assert.False(t, vmRem.Vban.OutStream[6].GetOn())
|
||||
})
|
||||
@ -161,11 +184,13 @@ func TestVbanOutStream6On(t *testing.T) {
|
||||
func TestVbanOutStream3Name(t *testing.T) {
|
||||
t.Skip("skipping test")
|
||||
vmRem.Vban.OutStream[3].SetName("test0")
|
||||
sync()
|
||||
t.Run("Should return test0 when SetName('test0')", func(t *testing.T) {
|
||||
assert.Equal(t, "test0", vmRem.Vban.OutStream[3].GetName())
|
||||
})
|
||||
|
||||
vmRem.Vban.OutStream[3].SetName("test1")
|
||||
sync()
|
||||
t.Run("Should return test1 when SetName('test1')", func(t *testing.T) {
|
||||
assert.Equal(t, "test1", vmRem.Vban.OutStream[3].GetName())
|
||||
})
|
||||
@ -186,11 +211,13 @@ func TestVbanInStream4Bit(t *testing.T) {
|
||||
func TestVbanOutStream4Bit(t *testing.T) {
|
||||
//t.Skip("skipping test")
|
||||
vmRem.Vban.OutStream[4].SetBit(16)
|
||||
sync()
|
||||
t.Run("Should return 16 when SetBit(16)", func(t *testing.T) {
|
||||
assert.Equal(t, vmRem.Vban.OutStream[4].GetBit(), 16)
|
||||
})
|
||||
|
||||
vmRem.Vban.OutStream[4].SetBit(24)
|
||||
sync()
|
||||
t.Run("Should return 24 when SetBit(24)", func(t *testing.T) {
|
||||
assert.Equal(t, vmRem.Vban.OutStream[4].GetBit(), 24)
|
||||
})
|
||||
|
@ -52,7 +52,8 @@ func login(kindId string) {
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Println("Logged into API")
|
||||
sync()
|
||||
for pdirty() || mdirty() {
|
||||
}
|
||||
}
|
||||
|
||||
// logout logs out of the API,
|
||||
@ -111,12 +112,6 @@ func mdirty() bool {
|
||||
return int(res) == 1
|
||||
}
|
||||
|
||||
func sync() {
|
||||
time.Sleep(30 * time.Millisecond)
|
||||
for pdirty() || mdirty() {
|
||||
}
|
||||
}
|
||||
|
||||
// getVMType returns the type of Voicemeeter, as a string
|
||||
func getVMType() string {
|
||||
var type_ uint64
|
||||
@ -165,7 +160,6 @@ func setParameterFloat(name string, value float32) {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
sync()
|
||||
}
|
||||
|
||||
// getParameterString gets the value of a string parameter
|
||||
@ -198,7 +192,6 @@ func setParameterString(name, value string) {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
sync()
|
||||
}
|
||||
|
||||
// setParametersMulti sets multiple parameters with a script
|
||||
@ -242,8 +235,6 @@ func setMacroStatus(id, state, mode int) {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
time.Sleep(30 * time.Millisecond)
|
||||
sync()
|
||||
}
|
||||
|
||||
func get_num_devices(dir string) uint64 {
|
||||
|
@ -5,7 +5,7 @@ type observer interface {
|
||||
OnUpdate(subject string)
|
||||
}
|
||||
|
||||
// Publisher defines methods that support observers
|
||||
// publisher defines methods that support observers
|
||||
type publisher struct {
|
||||
observerList []observer
|
||||
}
|
||||
@ -36,7 +36,7 @@ func (p *publisher) notify(subject string) {
|
||||
}
|
||||
}
|
||||
|
||||
// Pooler continuously polls the dirty paramters
|
||||
// pooler continuously polls the dirty paramters
|
||||
// it is expected to be run in a goroutine
|
||||
type pooler struct {
|
||||
run bool
|
||||
|
@ -47,6 +47,16 @@ func (r *remote) Version() string {
|
||||
return getVersion()
|
||||
}
|
||||
|
||||
// Pdirty returns true iff a parameter value has changed
|
||||
func (r *remote) Pdirty() bool {
|
||||
return pdirty()
|
||||
}
|
||||
|
||||
// Mdirty returns true iff a macrobutton value has changed
|
||||
func (r *remote) Mdirty() bool {
|
||||
return mdirty()
|
||||
}
|
||||
|
||||
func (r *remote) SendText(script string) {
|
||||
setParametersMulti(script)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user