mirror of
https://github.com/onyx-and-iris/voicemeeter.git
synced 2026-04-18 05:23:31 +00:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
505b5969a2 | ||
|
|
7f992a1a87 | ||
|
|
fa8e9f3e76 | ||
|
|
7a79555cb8 | ||
|
|
6fabc43998 | ||
|
|
3fd08ff606 | ||
|
|
7744971a10 | ||
|
|
82bbcd06b1 | ||
|
|
cba2ac85ec | ||
|
|
dd895daffb | ||
|
|
87a05d81e4 | ||
|
|
3ea4aee863 | ||
|
|
69476ffcd9 | ||
|
|
76e6d3cba7 | ||
|
|
1af67bb219 | ||
|
|
14264d0818 |
16
CHANGELOG.md
16
CHANGELOG.md
@@ -11,6 +11,22 @@ Before any major/minor/patch bump all unit tests will be run to verify they pass
|
|||||||
|
|
||||||
- [x]
|
- [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
|
## [1.2.0] - 2022-07-10
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
175
README.md
175
README.md
@@ -8,9 +8,9 @@ For an outline of past/future changes refer to: [CHANGELOG](CHANGELOG.md)
|
|||||||
|
|
||||||
## Tested against
|
## Tested against
|
||||||
|
|
||||||
- Basic 1.0.8.2
|
- Basic 1.0.8.4
|
||||||
- Banana 2.0.6.2
|
- Banana 2.0.6.4
|
||||||
- Potato 3.0.2.2
|
- Potato 3.0.2.4
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
@@ -42,21 +42,24 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
"github.com/onyx-and-iris/voicemeeter-api-go"
|
"github.com/onyx-and-iris/voicemeeter-api-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
kindId := "banana"
|
kindId := "banana"
|
||||||
vmRem := voicemeeter.NewRemote(kindId)
|
vm, err := voicemeeter.NewRemote(kindId)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
defer vm.Logout()
|
||||||
|
|
||||||
vmRem.Login()
|
vm.Login()
|
||||||
|
|
||||||
vmRem.Strip[0].SetLabel("rode podmic")
|
vm.Strip[0].SetLabel("rode podmic")
|
||||||
vmRem.Strip[0].SetMute(true)
|
vm.Strip[0].SetMute(true)
|
||||||
fmt.Printf("Strip 0 (%s) mute was set to %v\n", vmRem.Strip[0].GetLabel(), vmRem.Strip[0].GetMute())
|
fmt.Printf("Strip 0 (%s) mute was set to %v\n", vm.Strip[0].GetLabel(), vm.Strip[0].GetMute())
|
||||||
|
|
||||||
vmRem.Logout()
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -70,61 +73,89 @@ Pass the kind of Voicemeeter as an argument. kindId may be:
|
|||||||
|
|
||||||
## `Remote Type`
|
## `Remote Type`
|
||||||
|
|
||||||
#### `vmRem.Strip`
|
#### `vm.Strip`
|
||||||
|
|
||||||
[]t_strip slice containing both physicalStrip and virtualStrip types
|
[]t_strip slice containing both physicalStrip and virtualStrip types
|
||||||
|
|
||||||
#### `vmRem.Bus`
|
#### `vm.Bus`
|
||||||
|
|
||||||
[]t_bus slice containing both physicalBus and virtualBus types
|
[]t_bus slice containing both physicalBus and virtualBus types
|
||||||
|
|
||||||
#### `vmRem.Button`
|
#### `vm.Button`
|
||||||
|
|
||||||
[]button slice containing button types, one for each macrobutton
|
[]button slice containing button types, one for each macrobutton
|
||||||
|
|
||||||
#### `vmRem.Command`
|
#### `vm.Command`
|
||||||
|
|
||||||
pointer to command type, represents action type functions
|
pointer to command type, represents action type functions
|
||||||
|
|
||||||
#### `vmRem.Vban`
|
#### `vm.Vban`
|
||||||
|
|
||||||
pointer to vban type, containing both vbanInStream and vbanOutStream slices
|
pointer to vban type, containing both vbanInStream and vbanOutStream slices
|
||||||
|
|
||||||
#### `vmRem.Device`
|
#### `vm.Device`
|
||||||
|
|
||||||
pointer to device type, represents physical input/output hardware devices
|
pointer to device type, represents physical input/output hardware devices
|
||||||
|
|
||||||
#### `vmRem.Recorder`
|
#### `vm.Recorder`
|
||||||
|
|
||||||
pointer to recorder type, represents the recorder
|
pointer to recorder type, represents the recorder
|
||||||
|
|
||||||
#### `vmRem.Type()`
|
#### `vm.Midi`
|
||||||
|
|
||||||
|
pointer to midi type, represents a connected midi device
|
||||||
|
|
||||||
|
#### `vm.Type()`
|
||||||
|
|
||||||
returns the type of Voicemeeter as a string
|
returns the type of Voicemeeter as a string
|
||||||
|
|
||||||
#### `vmRem.Version()`
|
#### `vm.Version()`
|
||||||
|
|
||||||
returns the version of Voicemeeter as a string
|
returns the version of Voicemeeter as a string
|
||||||
|
|
||||||
#### `vmRem.SendText(<script>)`
|
#### `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")
|
sets many parameters in script format eg. ("Strip[0].Mute=1;Bus[3].Gain=3.6")
|
||||||
|
|
||||||
#### `vmRem.Register(o observer)`
|
#### `vm.Register(o observer)`
|
||||||
|
|
||||||
register an object as an observer
|
register an object as an observer
|
||||||
|
|
||||||
#### `vmRem.Deregister(o observer)`
|
#### `vm.Deregister(o observer)`
|
||||||
|
|
||||||
deregister an object as an observer
|
deregister an object as an observer
|
||||||
|
|
||||||
#### `vmRem.Pdirty()`
|
#### `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
|
returns True iff a GUI parameter has changed
|
||||||
|
|
||||||
#### `vmRem.Mdirty()`
|
#### `vm.Mdirty()`
|
||||||
|
|
||||||
returns True iff a macrobutton paramter has changed
|
returns True iff a macrobutton parameter has changed
|
||||||
|
|
||||||
## `Available commands`
|
## `Available commands`
|
||||||
|
|
||||||
@@ -158,14 +189,14 @@ The following methods are available
|
|||||||
example:
|
example:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
vmRem.Strip[3].SetGain(3.7)
|
vm.Strip[3].SetGain(3.7)
|
||||||
fmt.Println(vmRem.Strip[0].GetLabel())
|
fmt.Println(vm.Strip[0].GetLabel())
|
||||||
vmRem.Strip[4].SetA1(true)
|
vm.Strip[4].SetA1(true)
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Gainlayers
|
##### Gainlayers
|
||||||
|
|
||||||
- `vmRem.Strip[i].GainLayer()[j]`
|
- `vm.Strip[i].GainLayer()[j]`
|
||||||
|
|
||||||
The following methods are available
|
The following methods are available
|
||||||
|
|
||||||
@@ -175,12 +206,12 @@ The following methods are available
|
|||||||
example:
|
example:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
vmRem.Strip[6].GainLayer()[3].Set(-13.6)
|
vm.Strip[6].GainLayer()[3].Set(-13.6)
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Levels
|
##### Levels
|
||||||
|
|
||||||
- `vmRem.Strip[i].Levels()`
|
- `vm.Strip[i].Levels()`
|
||||||
|
|
||||||
The following methods are available
|
The following methods are available
|
||||||
|
|
||||||
@@ -191,7 +222,7 @@ The following methods are available
|
|||||||
example:
|
example:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
fmt.Println(vmRem.Strip[5].Levels().PreFader())
|
fmt.Println(vm.Strip[5].Levels().PreFader())
|
||||||
```
|
```
|
||||||
|
|
||||||
### Bus
|
### Bus
|
||||||
@@ -211,13 +242,13 @@ The following methods are available
|
|||||||
- `SetGain(val float32)` from -60.0 to 12.0
|
- `SetGain(val float32)` from -60.0 to 12.0
|
||||||
|
|
||||||
```go
|
```go
|
||||||
vmRem.Bus[3].SetEq(true)
|
vm.Bus[3].SetEq(true)
|
||||||
fmt.Println(vmRem.Bus[0].GetLabel())
|
fmt.Println(vm.Bus[0].GetLabel())
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Modes
|
##### Modes
|
||||||
|
|
||||||
- `vmRem.Bus[i].Mode()`
|
- `vm.Bus[i].Mode()`
|
||||||
|
|
||||||
The following methods are available
|
The following methods are available
|
||||||
|
|
||||||
@@ -249,13 +280,13 @@ The following methods are available
|
|||||||
example:
|
example:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
vmRem.Bus[3].Mode().SetAmix(true)
|
vm.Bus[3].Mode().SetAmix(true)
|
||||||
vmRem.Bus[4].Mode().SetCenterOnly(true)
|
vm.Bus[4].Mode().SetCenterOnly(true)
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Levels
|
##### Levels
|
||||||
|
|
||||||
- `vmRem.Bus[i].Levels()`
|
- `vm.Bus[i].Levels()`
|
||||||
|
|
||||||
The following methods are available
|
The following methods are available
|
||||||
|
|
||||||
@@ -264,7 +295,7 @@ The following methods are available
|
|||||||
example:
|
example:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
fmt.Println(vmRem.Bus[1].Levels().All())
|
fmt.Println(vm.Bus[1].Levels().All())
|
||||||
```
|
```
|
||||||
|
|
||||||
### Button
|
### Button
|
||||||
@@ -281,8 +312,8 @@ The following methods are available
|
|||||||
example:
|
example:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
vmRem.Button[37].SetState(true)
|
vm.Button[37].SetState(true)
|
||||||
fmt.Println(vmRem.Button[64].GetStateOnly())
|
fmt.Println(vm.Button[64].GetStateOnly())
|
||||||
```
|
```
|
||||||
|
|
||||||
### Command
|
### Command
|
||||||
@@ -298,17 +329,17 @@ The following methods are available
|
|||||||
example:
|
example:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
vmRem.Command.Restart()
|
vm.Command.Restart()
|
||||||
vmRem.Command.Show()
|
vm.Command.Show()
|
||||||
```
|
```
|
||||||
|
|
||||||
### VBAN
|
### VBAN
|
||||||
|
|
||||||
- `vmRem.Vban.Enable()` `vmRem.Vban.Disable()` Turn VBAN on or off
|
- `vm.Vban.Enable()` `vm.Vban.Disable()` Turn VBAN on or off
|
||||||
|
|
||||||
##### Instream | Outstream
|
##### Instream | Outstream
|
||||||
|
|
||||||
- `vmRem.Vban.InStream` `vmRem.Vban.OutStream`
|
- `vm.Vban.InStream` `vm.Vban.OutStream`
|
||||||
|
|
||||||
The following methods are available
|
The following methods are available
|
||||||
|
|
||||||
@@ -335,29 +366,29 @@ example:
|
|||||||
|
|
||||||
```go
|
```go
|
||||||
# turn VBAN on
|
# turn VBAN on
|
||||||
vmRem.Vban.Enable()
|
vm.Vban.Enable()
|
||||||
|
|
||||||
// turn on vban instream 0
|
// turn on vban instream 0
|
||||||
vmRem.Vban.InStream[0].SetOn(true)
|
vm.Vban.InStream[0].SetOn(true)
|
||||||
|
|
||||||
// set bit property for outstream 3 to 24
|
// set bit property for outstream 3 to 24
|
||||||
vmRem.Vban.OutStream[3].SetBit(24)
|
vm.Vban.OutStream[3].SetBit(24)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Device
|
### Device
|
||||||
|
|
||||||
The following methods are available
|
The following methods are available
|
||||||
|
|
||||||
- `Ins`
|
- `Ins()`
|
||||||
- `Outs`
|
- `Outs()`
|
||||||
- `Input(val int)`
|
- `Input(val int)`
|
||||||
- `Output(val int)`
|
- `Output(val int)`
|
||||||
|
|
||||||
example:
|
example:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
for i := 0; i < int(vmRem.Device.Ins()); i++ {
|
for i := 0; i < int(vm.Device.Ins()); i++ {
|
||||||
fmt.Println(vmRem.Device.Input(i))
|
fmt.Println(vm.Device.Input(i))
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -376,14 +407,46 @@ The following methods are available
|
|||||||
example:
|
example:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
vmRem.Recorder.Play()
|
vm.Recorder.Play()
|
||||||
vmRem.Recorder.Stop()
|
vm.Recorder.Stop()
|
||||||
|
|
||||||
# Enable loop play
|
# Enable loop play
|
||||||
vmRem.Recorder.Loop(true)
|
vm.Recorder.Loop(true)
|
||||||
|
|
||||||
# Disable recorder out channel B2
|
# Disable recorder out channel B2
|
||||||
vmRem.Recorder.SetB2(false)
|
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
|
### Run tests
|
||||||
|
|||||||
50
base.go
50
base.go
@@ -37,6 +37,8 @@ var (
|
|||||||
vmMdirty = mod.NewProc("VBVMR_MacroButton_IsDirty")
|
vmMdirty = mod.NewProc("VBVMR_MacroButton_IsDirty")
|
||||||
vmGetMacroStatus = mod.NewProc("VBVMR_MacroButton_GetStatus")
|
vmGetMacroStatus = mod.NewProc("VBVMR_MacroButton_GetStatus")
|
||||||
vmSetMacroStatus = mod.NewProc("VBVMR_MacroButton_SetStatus")
|
vmSetMacroStatus = mod.NewProc("VBVMR_MacroButton_SetStatus")
|
||||||
|
|
||||||
|
vmGetMidiMessage = mod.NewProc("VBVMR_GetMidiMessage")
|
||||||
)
|
)
|
||||||
|
|
||||||
// login logs into the API,
|
// login logs into the API,
|
||||||
@@ -52,14 +54,14 @@ func login(kindId string) {
|
|||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
fmt.Println("Logged into API")
|
fmt.Printf("Logged into Voicemeeter %s\n", kindId)
|
||||||
for pdirty() || mdirty() {
|
for pdirty() || mdirty() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// logout logs out of the API,
|
// logout logs out of the API,
|
||||||
// delayed for 100ms to allow final operation to complete.
|
// delayed for 100ms to allow final operation to complete.
|
||||||
func logout() {
|
func logout(kindId string) {
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
res, _, _ := vmLogout.Call()
|
res, _, _ := vmLogout.Call()
|
||||||
if res != 0 {
|
if res != 0 {
|
||||||
@@ -67,7 +69,7 @@ func logout() {
|
|||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
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.
|
// runVoicemeeter attempts to launch a Voicemeeter GUI of a kind.
|
||||||
@@ -115,18 +117,18 @@ func mdirty() bool {
|
|||||||
|
|
||||||
// ldirty returns true iff a level value has changed
|
// ldirty returns true iff a level value has changed
|
||||||
func ldirty(k *kind) bool {
|
func ldirty(k *kind) bool {
|
||||||
_levelCache.stripLevelsBuff = make([]float32, (2*k.physIn)+(8*k.virtIn))
|
_levelCache.stripLevelsBuff = make([]float32, (2*k.PhysIn)+(8*k.VirtIn))
|
||||||
_levelCache.busLevelsBuff = make([]float32, 8*k.numBus())
|
_levelCache.busLevelsBuff = make([]float32, 8*k.NumBus())
|
||||||
|
|
||||||
for i := 0; i < (2*k.physIn)+(8*k.virtIn); i++ {
|
for i := 0; i < (2*k.PhysIn)+(8*k.VirtIn); i++ {
|
||||||
_levelCache.stripLevelsBuff[i] = float32(getLevel(_levelCache.stripMode, i))
|
_levelCache.stripLevelsBuff[i] = float32(getLevel(_levelCache.stripMode, i))
|
||||||
_levelCache.stripComp[i] = _levelCache.stripLevelsBuff[i] == _levelCache.stripLevels[i]
|
_levelCache.stripComp[i] = _levelCache.stripLevelsBuff[i] == _levelCache.stripLevels[i]
|
||||||
}
|
}
|
||||||
for i := 0; i < 8*k.numBus(); i++ {
|
for i := 0; i < 8*k.NumBus(); i++ {
|
||||||
_levelCache.busLevelsBuff[i] = float32(getLevel(3, i))
|
_levelCache.busLevelsBuff[i] = float32(getLevel(3, i))
|
||||||
_levelCache.busComp[i] = _levelCache.busLevelsBuff[i] == _levelCache.busLevels[i]
|
_levelCache.busComp[i] = _levelCache.busLevelsBuff[i] == _levelCache.busLevels[i]
|
||||||
}
|
}
|
||||||
return !(allTrue(_levelCache.stripComp, (2*k.physIn)+(8*k.virtIn)) && allTrue(_levelCache.busComp, 8*k.numBus()))
|
return !(allTrue(_levelCache.stripComp, (2*k.PhysIn)+(8*k.VirtIn)) && allTrue(_levelCache.busComp, 8*k.NumBus()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// getVMType returns the type of Voicemeeter, as a string
|
// getVMType returns the type of Voicemeeter, as a string
|
||||||
@@ -315,3 +317,35 @@ func getLevel(type_, i int) float32 {
|
|||||||
}
|
}
|
||||||
return val
|
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
16
examples/obs/go.mod
Normal 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
18
examples/obs/go.sum
Normal 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
78
examples/obs/main.go
Normal 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)
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/onyx-and-iris/voicemeeter-api-go"
|
"github.com/onyx-and-iris/voicemeeter-api-go"
|
||||||
@@ -12,14 +12,24 @@ type observer struct {
|
|||||||
vm *voicemeeter.Remote
|
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) {
|
func (o observer) OnUpdate(subject string) {
|
||||||
if strings.Compare(subject, "pdirty") == 0 {
|
if subject == "pdirty" {
|
||||||
fmt.Println("pdirty!")
|
fmt.Println("pdirty!")
|
||||||
}
|
} else if subject == "mdirty" {
|
||||||
if strings.Compare(subject, "mdirty") == 0 {
|
|
||||||
fmt.Println("mdirty!")
|
fmt.Println("mdirty!")
|
||||||
}
|
} else if subject == "midi" {
|
||||||
if strings.Compare(subject, "ldirty") == 0 {
|
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",
|
fmt.Printf("%v %v %v %v %v %v %v %v\n",
|
||||||
o.vm.Bus[0].Levels().IsDirty(),
|
o.vm.Bus[0].Levels().IsDirty(),
|
||||||
o.vm.Bus[1].Levels().IsDirty(),
|
o.vm.Bus[1].Levels().IsDirty(),
|
||||||
@@ -34,13 +44,18 @@ func (o observer) OnUpdate(subject string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
vmRem := voicemeeter.NewRemote("potato")
|
vm, err := voicemeeter.NewRemote("potato")
|
||||||
vmRem.Login()
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
defer vm.Logout()
|
||||||
|
|
||||||
o := observer{vmRem}
|
vm.Login()
|
||||||
vmRem.Register(o)
|
// enable level updates (disabled by default)
|
||||||
|
vm.EventAdd("ldirty")
|
||||||
|
|
||||||
|
o := observer{vm}
|
||||||
|
o.Register()
|
||||||
time.Sleep(30 * time.Second)
|
time.Sleep(30 * time.Second)
|
||||||
vmRem.Deregister(o)
|
o.Deregister()
|
||||||
|
|
||||||
vmRem.Logout()
|
|
||||||
}
|
}
|
||||||
29
helper_test.go
Normal file
29
helper_test.go
Normal 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() {
|
||||||
|
}
|
||||||
|
}
|
||||||
14
kinds.go
14
kinds.go
@@ -9,25 +9,25 @@ var basic, banana, potato *kind
|
|||||||
|
|
||||||
// A kind represents a Voicemeeter kinds layout
|
// A kind represents a Voicemeeter kinds layout
|
||||||
type kind struct {
|
type kind struct {
|
||||||
name string
|
Name string
|
||||||
physIn, virtIn, physOut, virtOut, vbanIn, vbanOut int
|
PhysIn, VirtIn, PhysOut, VirtOut, VbanIn, VbanOut int
|
||||||
}
|
}
|
||||||
|
|
||||||
// numStrip returns the total number of strips for a kind
|
// numStrip returns the total number of strips for a kind
|
||||||
func (k *kind) numStrip() int {
|
func (k *kind) NumStrip() int {
|
||||||
n := k.physIn + k.virtIn
|
n := k.PhysIn + k.VirtIn
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
// numBus returns the total number of buses for a kind
|
// numBus returns the total number of buses for a kind
|
||||||
func (k *kind) numBus() int {
|
func (k *kind) NumBus() int {
|
||||||
n := k.physOut + k.virtOut
|
n := k.PhysOut + k.VirtOut
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
// String implements the fmt.stringer interface
|
// String implements the fmt.stringer interface
|
||||||
func (k *kind) String() string {
|
func (k *kind) String() string {
|
||||||
return fmt.Sprintf("%s%s", strings.ToUpper(k.name[:1]), k.name[1:])
|
return fmt.Sprintf("%s%s", strings.ToUpper(k.Name[:1]), k.Name[1:])
|
||||||
}
|
}
|
||||||
|
|
||||||
// newBasicKind returns a basic kind struct address
|
// newBasicKind returns a basic kind struct address
|
||||||
|
|||||||
@@ -35,10 +35,10 @@ type levelCache struct {
|
|||||||
|
|
||||||
// newLevelCache returns a levelCache struct address
|
// newLevelCache returns a levelCache struct address
|
||||||
func newLevelCache(k *kind) *levelCache {
|
func newLevelCache(k *kind) *levelCache {
|
||||||
stripLevels := make([]float32, (2*k.physIn)+(8*k.virtIn))
|
stripLevels := make([]float32, (2*k.PhysIn)+(8*k.VirtIn))
|
||||||
busLevels := make([]float32, 8*k.numBus())
|
busLevels := make([]float32, 8*k.NumBus())
|
||||||
stripComp := make([]bool, (2*k.physIn)+(8*k.virtIn))
|
stripComp := make([]bool, (2*k.PhysIn)+(8*k.VirtIn))
|
||||||
busComp := make([]bool, 8*k.numBus())
|
busComp := make([]bool, 8*k.NumBus())
|
||||||
if _levelCache == nil {
|
if _levelCache == nil {
|
||||||
_levelCache = &levelCache{stripMode: 0, stripLevels: stripLevels, busLevels: busLevels, stripComp: stripComp, busComp: busComp}
|
_levelCache = &levelCache{stripMode: 0, stripLevels: stripLevels, busLevels: busLevels, stripComp: stripComp, busComp: busComp}
|
||||||
}
|
}
|
||||||
|
|||||||
28
midi.go
Normal file
28
midi.go
Normal 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]
|
||||||
|
}
|
||||||
5
path.go
5
path.go
@@ -3,7 +3,7 @@ package voicemeeter
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"log"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -49,8 +49,7 @@ func dllPath() (string, error) {
|
|||||||
func getDllPath() string {
|
func getDllPath() string {
|
||||||
path, err := dllPath()
|
path, err := dllPath()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
log.Fatal(err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
|||||||
70
publisher.go
70
publisher.go
@@ -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
|
// pooler continuously polls the dirty paramters
|
||||||
// it is expected to be run in a goroutine
|
// it is expected to be run in a goroutine
|
||||||
type pooler struct {
|
type pooler struct {
|
||||||
k *kind
|
k *kind
|
||||||
run bool
|
run bool
|
||||||
|
event *event
|
||||||
publisher
|
publisher
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,31 +90,49 @@ func newPooler(k *kind) *pooler {
|
|||||||
p := &pooler{
|
p := &pooler{
|
||||||
k: k,
|
k: k,
|
||||||
run: true,
|
run: true,
|
||||||
|
event: newEvent(),
|
||||||
}
|
}
|
||||||
go p.runner()
|
go p.parameters()
|
||||||
|
go p.macrobuttons()
|
||||||
|
go p.midi()
|
||||||
go p.levels()
|
go p.levels()
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *pooler) runner() {
|
func (p *pooler) parameters() {
|
||||||
for p.run {
|
for p.run {
|
||||||
if pdirty() {
|
if p.event.pdirty && pdirty() {
|
||||||
p.notify("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")
|
p.notify("mdirty")
|
||||||
}
|
}
|
||||||
time.Sleep(33 * time.Millisecond)
|
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() {
|
func (p *pooler) levels() {
|
||||||
_levelCache = newLevelCache(p.k)
|
_levelCache = newLevelCache(p.k)
|
||||||
|
|
||||||
for p.run {
|
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.stripLevels, _levelCache.stripLevelsBuff, (2*p.k.PhysIn)+(8*p.k.VirtIn))
|
||||||
update(_levelCache.busLevels, _levelCache.busLevelsBuff, 8*p.k.numBus())
|
update(_levelCache.busLevels, _levelCache.busLevelsBuff, 8*p.k.NumBus())
|
||||||
p.notify("ldirty")
|
p.notify("ldirty")
|
||||||
}
|
}
|
||||||
time.Sleep(33 * time.Millisecond)
|
time.Sleep(33 * time.Millisecond)
|
||||||
|
|||||||
113
remote.go
113
remote.go
@@ -2,12 +2,11 @@ package voicemeeter
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// A Remote type represents the API for a kind
|
// A Remote type represents the API for a kind
|
||||||
type Remote struct {
|
type Remote struct {
|
||||||
kind *kind
|
Kind *kind
|
||||||
Strip []iStrip
|
Strip []iStrip
|
||||||
Bus []iBus
|
Bus []iBus
|
||||||
Button []button
|
Button []button
|
||||||
@@ -15,33 +14,36 @@ type Remote struct {
|
|||||||
Vban *vban
|
Vban *vban
|
||||||
Device *device
|
Device *device
|
||||||
Recorder *recorder
|
Recorder *recorder
|
||||||
|
Midi *midi_t
|
||||||
|
|
||||||
pooler *pooler
|
pooler *pooler
|
||||||
}
|
}
|
||||||
|
|
||||||
// String implements the fmt.stringer interface
|
// String implements the fmt.stringer interface
|
||||||
func (r *Remote) String() string {
|
func (r *Remote) String() string {
|
||||||
return fmt.Sprintf("Voicemeeter %s", r.kind)
|
return fmt.Sprintf("Voicemeeter %s", r.Kind)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Login logs into the API
|
// Login logs into the API
|
||||||
// then it intializes the pooler
|
// then it intializes the pooler
|
||||||
func (r *Remote) Login() {
|
func (r *Remote) Login() {
|
||||||
login(r.kind.name)
|
login(r.Kind.Name)
|
||||||
r.pooler = newPooler(r.kind)
|
r.pooler = newPooler(r.Kind)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logout logs out of the API
|
// Logout logs out of the API
|
||||||
// it also terminates the pooler
|
// it also terminates the pooler
|
||||||
func (r *Remote) Logout() {
|
func (r *Remote) Logout() {
|
||||||
r.pooler.run = false
|
r.pooler.run = false
|
||||||
logout()
|
logout(r.Kind.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Type returns the type of Voicemeeter (basic, banana, potato)
|
||||||
func (r *Remote) Type() string {
|
func (r *Remote) Type() string {
|
||||||
return getVMType()
|
return getVMType()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Version returns the version of Voicemeeter as a string
|
||||||
func (r *Remote) Version() string {
|
func (r *Remote) Version() string {
|
||||||
return getVersion()
|
return getVersion()
|
||||||
}
|
}
|
||||||
@@ -56,6 +58,27 @@ func (r *Remote) Mdirty() bool {
|
|||||||
return mdirty()
|
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) {
|
func (r *Remote) SendText(script string) {
|
||||||
setParametersMulti(script)
|
setParametersMulti(script)
|
||||||
}
|
}
|
||||||
@@ -65,11 +88,22 @@ func (r *Remote) Register(o observer) {
|
|||||||
r.pooler.Register(o)
|
r.pooler.Register(o)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register forwards the deregister method to Pooler
|
// Deregister forwards the deregister method to Pooler
|
||||||
func (r *Remote) Deregister(o observer) {
|
func (r *Remote) Deregister(o observer) {
|
||||||
r.pooler.Deregister(o)
|
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 {
|
type remoteBuilder interface {
|
||||||
setKind() remoteBuilder
|
setKind() remoteBuilder
|
||||||
makeStrip() remoteBuilder
|
makeStrip() remoteBuilder
|
||||||
@@ -79,6 +113,7 @@ type remoteBuilder interface {
|
|||||||
makeVban() remoteBuilder
|
makeVban() remoteBuilder
|
||||||
makeDevice() remoteBuilder
|
makeDevice() remoteBuilder
|
||||||
makeRecorder() remoteBuilder
|
makeRecorder() remoteBuilder
|
||||||
|
makeMidi() remoteBuilder
|
||||||
Build() remoteBuilder
|
Build() remoteBuilder
|
||||||
Get() *Remote
|
Get() *Remote
|
||||||
}
|
}
|
||||||
@@ -103,13 +138,15 @@ func (d *director) Get() *Remote {
|
|||||||
return d.builder.Get()
|
return d.builder.Get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// genericBuilder represents a generic builder type
|
||||||
type genericBuilder struct {
|
type genericBuilder struct {
|
||||||
k *kind
|
k *kind
|
||||||
r Remote
|
r Remote
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setKind sets the kind for a builder of a kind
|
||||||
func (b *genericBuilder) setKind() remoteBuilder {
|
func (b *genericBuilder) setKind() remoteBuilder {
|
||||||
b.r.kind = b.k
|
b.r.Kind = b.k
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,9 +154,9 @@ func (b *genericBuilder) setKind() remoteBuilder {
|
|||||||
// []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")
|
fmt.Println("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 {
|
||||||
_strip[i] = newPhysicalStrip(i, b.k)
|
_strip[i] = newPhysicalStrip(i, b.k)
|
||||||
} else {
|
} else {
|
||||||
_strip[i] = newVirtualStrip(i, b.k)
|
_strip[i] = newVirtualStrip(i, b.k)
|
||||||
@@ -133,9 +170,9 @@ func (b *genericBuilder) makeStrip() remoteBuilder {
|
|||||||
// []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")
|
fmt.Println("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 {
|
||||||
_bus[i] = newPhysicalBus(i, b.k)
|
_bus[i] = newPhysicalBus(i, b.k)
|
||||||
} else {
|
} else {
|
||||||
_bus[i] = newVirtualBus(i, b.k)
|
_bus[i] = newVirtualBus(i, b.k)
|
||||||
@@ -184,50 +221,82 @@ func (b *genericBuilder) makeRecorder() remoteBuilder {
|
|||||||
return b
|
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
|
// Get returns a fully constructed remote type for a kind
|
||||||
func (b *genericBuilder) Get() *Remote {
|
func (b *genericBuilder) Get() *Remote {
|
||||||
return &b.r
|
return &b.r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// basicBuilder represents a builder specific to basic type
|
||||||
type basicBuilder struct {
|
type basicBuilder struct {
|
||||||
genericBuilder
|
genericBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build defines the steps required to build a basic type
|
// Build defines the steps required to build a basic type
|
||||||
func (basb *genericBuilder) Build() remoteBuilder {
|
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
|
||||||
type bananaBuilder struct {
|
type bananaBuilder struct {
|
||||||
genericBuilder
|
genericBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build defines the steps required to build a banana type
|
// Build defines the steps required to build a banana type
|
||||||
func (banb *bananaBuilder) Build() remoteBuilder {
|
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
|
||||||
type potatoBuilder struct {
|
type potatoBuilder struct {
|
||||||
genericBuilder
|
genericBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build defines the steps required to build a potato type
|
// Build defines the steps required to build a potato type
|
||||||
func (potb *potatoBuilder) Build() remoteBuilder {
|
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
|
// NewRemote returns a Remote type for a kind
|
||||||
// this is the interface entry point
|
// this is the interface entry point
|
||||||
func NewRemote(kindId string) *Remote {
|
func NewRemote(kindId string) (*Remote, error) {
|
||||||
_kind, ok := kindMap[kindId]
|
_kind, ok := kindMap[kindId]
|
||||||
if !ok {
|
if !ok {
|
||||||
err := fmt.Errorf("unknown Voicemeeter kind '%s'", kindId)
|
err := fmt.Errorf("unknown Voicemeeter kind '%s'", kindId)
|
||||||
fmt.Println(err)
|
return nil, err
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
director := director{}
|
director := director{}
|
||||||
switch _kind.name {
|
switch _kind.Name {
|
||||||
case "basic":
|
case "basic":
|
||||||
director.SetBuilder(&basicBuilder{genericBuilder{_kind, Remote{}}})
|
director.SetBuilder(&basicBuilder{genericBuilder{_kind, Remote{}}})
|
||||||
case "banana":
|
case "banana":
|
||||||
@@ -236,5 +305,5 @@ func NewRemote(kindId string) *Remote {
|
|||||||
director.SetBuilder(&potatoBuilder{genericBuilder{_kind, Remote{}}})
|
director.SetBuilder(&potatoBuilder{genericBuilder{_kind, Remote{}}})
|
||||||
}
|
}
|
||||||
director.Construct()
|
director.Construct()
|
||||||
return director.Get()
|
return director.Get(), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
func TestGetBasicRemote(t *testing.T) {
|
func TestGetBasicRemote(t *testing.T) {
|
||||||
//t.Skip("skipping test")
|
//t.Skip("skipping test")
|
||||||
__rem := NewRemote("basic")
|
__rem, _ := NewRemote("basic")
|
||||||
t.Run("Should return a remote basic type", func(t *testing.T) {
|
t.Run("Should return a remote basic type", func(t *testing.T) {
|
||||||
assert.NotNil(t, __rem)
|
assert.NotNil(t, __rem)
|
||||||
})
|
})
|
||||||
@@ -34,7 +34,7 @@ func TestGetBasicRemote(t *testing.T) {
|
|||||||
|
|
||||||
func TestGetBananaRemote(t *testing.T) {
|
func TestGetBananaRemote(t *testing.T) {
|
||||||
//t.Skip("skipping test")
|
//t.Skip("skipping test")
|
||||||
__rem := NewRemote("banana")
|
__rem, _ := NewRemote("banana")
|
||||||
t.Run("Should return a remote banana type", func(t *testing.T) {
|
t.Run("Should return a remote banana type", func(t *testing.T) {
|
||||||
assert.NotNil(t, __rem)
|
assert.NotNil(t, __rem)
|
||||||
})
|
})
|
||||||
@@ -60,7 +60,7 @@ func TestGetBananaRemote(t *testing.T) {
|
|||||||
|
|
||||||
func TestGetPotatoRemote(t *testing.T) {
|
func TestGetPotatoRemote(t *testing.T) {
|
||||||
//t.Skip("skipping test")
|
//t.Skip("skipping test")
|
||||||
__rem := NewRemote("potato")
|
__rem, _ := NewRemote("potato")
|
||||||
t.Run("Should return a remote basic type", func(t *testing.T) {
|
t.Run("Should return a remote basic type", func(t *testing.T) {
|
||||||
assert.NotNil(t, __rem)
|
assert.NotNil(t, __rem)
|
||||||
})
|
})
|
||||||
@@ -83,3 +83,24 @@ func TestGetPotatoRemote(t *testing.T) {
|
|||||||
assert.NotNil(t, __rem.Recorder)
|
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))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
10
strip.go
10
strip.go
@@ -292,17 +292,17 @@ func (gl *gainLayer) Set(val float32) {
|
|||||||
func newStripLevels(i int, k *kind) levels {
|
func newStripLevels(i int, k *kind) levels {
|
||||||
var init int
|
var init int
|
||||||
var os int
|
var os int
|
||||||
if i < k.physIn {
|
if i < k.PhysIn {
|
||||||
init = i * 2
|
init = i * 2
|
||||||
os = 2
|
os = 2
|
||||||
} else {
|
} else {
|
||||||
init = (k.physIn * 2) + ((i - k.physIn) * 8)
|
init = (k.PhysIn * 2) + ((i - k.PhysIn) * 8)
|
||||||
os = 8
|
os = 8
|
||||||
}
|
}
|
||||||
return levels{iRemote{fmt.Sprintf("strip[%d]", i), i}, k, init, os, "strip"}
|
return levels{iRemote{fmt.Sprintf("strip[%d]", i), i}, k, init, os, "strip"}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PreFader returns the level valuess for this strip, PREFADER mode
|
// PreFader returns the level values for this strip, PREFADER mode
|
||||||
func (l *levels) PreFader() []float32 {
|
func (l *levels) PreFader() []float32 {
|
||||||
_levelCache.stripMode = 0
|
_levelCache.stripMode = 0
|
||||||
var levels []float32
|
var levels []float32
|
||||||
@@ -312,7 +312,7 @@ func (l *levels) PreFader() []float32 {
|
|||||||
return levels
|
return levels
|
||||||
}
|
}
|
||||||
|
|
||||||
// PreFader returns the level valuess for this strip, POSTFADER mode
|
// PostFader returns the level values for this strip, POSTFADER mode
|
||||||
func (l *levels) PostFader() []float32 {
|
func (l *levels) PostFader() []float32 {
|
||||||
_levelCache.stripMode = 1
|
_levelCache.stripMode = 1
|
||||||
var levels []float32
|
var levels []float32
|
||||||
@@ -322,7 +322,7 @@ func (l *levels) PostFader() []float32 {
|
|||||||
return levels
|
return levels
|
||||||
}
|
}
|
||||||
|
|
||||||
// PreFader returns the level valuess for this strip, POSTMUTE mode
|
// PostMute returns the level values for this strip, POSTMUTE mode
|
||||||
func (l *levels) PostMute() []float32 {
|
func (l *levels) PostMute() []float32 {
|
||||||
_levelCache.stripMode = 2
|
_levelCache.stripMode = 2
|
||||||
var levels []float32
|
var levels []float32
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package voicemeeter_test
|
package voicemeeter_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@@ -9,18 +10,23 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
vmRem = voicemeeter.NewRemote("potato")
|
vm, err = voicemeeter.NewRemote("potato")
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
vmRem.Login()
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
defer vm.Logout()
|
||||||
|
|
||||||
|
vm.Login()
|
||||||
code := m.Run()
|
code := m.Run()
|
||||||
vmRem.Logout()
|
vm.Logout()
|
||||||
os.Exit(code)
|
os.Exit(code)
|
||||||
}
|
}
|
||||||
|
|
||||||
func sync() {
|
func sync() {
|
||||||
time.Sleep(30 * time.Millisecond)
|
time.Sleep(30 * time.Millisecond)
|
||||||
for vmRem.Pdirty() || vmRem.Mdirty() {
|
for vm.Pdirty() || vm.Mdirty() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,206 +8,206 @@ import (
|
|||||||
|
|
||||||
func TestStrip0Mute(t *testing.T) {
|
func TestStrip0Mute(t *testing.T) {
|
||||||
//t.Skip("skipping test")
|
//t.Skip("skipping test")
|
||||||
vmRem.Strip[0].SetMute(true)
|
vm.Strip[0].SetMute(true)
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return true when SetMute(true)", func(t *testing.T) {
|
t.Run("Should return true when SetMute(true)", func(t *testing.T) {
|
||||||
assert.True(t, vmRem.Strip[0].GetMute())
|
assert.True(t, vm.Strip[0].GetMute())
|
||||||
})
|
})
|
||||||
|
|
||||||
vmRem.Strip[0].SetMute(false)
|
vm.Strip[0].SetMute(false)
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return false when SetMute(false)", func(t *testing.T) {
|
t.Run("Should return false when SetMute(false)", func(t *testing.T) {
|
||||||
assert.False(t, vmRem.Strip[0].GetMute())
|
assert.False(t, vm.Strip[0].GetMute())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStrip3A1(t *testing.T) {
|
func TestStrip3A1(t *testing.T) {
|
||||||
//t.Skip("skipping test")
|
//t.Skip("skipping test")
|
||||||
vmRem.Strip[3].SetA1(true)
|
vm.Strip[3].SetA1(true)
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return true when SetA1(true)", func(t *testing.T) {
|
t.Run("Should return true when SetA1(true)", func(t *testing.T) {
|
||||||
assert.True(t, vmRem.Strip[3].GetA1())
|
assert.True(t, vm.Strip[3].GetA1())
|
||||||
})
|
})
|
||||||
|
|
||||||
vmRem.Strip[3].SetA1(false)
|
vm.Strip[3].SetA1(false)
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return false when SetA1(false)", func(t *testing.T) {
|
t.Run("Should return false when SetA1(false)", func(t *testing.T) {
|
||||||
assert.False(t, vmRem.Strip[3].GetA1())
|
assert.False(t, vm.Strip[3].GetA1())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStrip2Limit(t *testing.T) {
|
func TestStrip2Limit(t *testing.T) {
|
||||||
//t.Skip("skipping test")
|
//t.Skip("skipping test")
|
||||||
vmRem.Strip[2].SetLimit(-8)
|
vm.Strip[2].SetLimit(-8)
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return -8 when SetLimit(-8)", func(t *testing.T) {
|
t.Run("Should return -8 when SetLimit(-8)", func(t *testing.T) {
|
||||||
assert.Equal(t, vmRem.Strip[2].GetLimit(), -8)
|
assert.Equal(t, vm.Strip[2].GetLimit(), -8)
|
||||||
})
|
})
|
||||||
|
|
||||||
vmRem.Strip[2].SetLimit(-32)
|
vm.Strip[2].SetLimit(-32)
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return -32 when SetLimit(-8)", func(t *testing.T) {
|
t.Run("Should return -32 when SetLimit(-8)", func(t *testing.T) {
|
||||||
assert.Equal(t, vmRem.Strip[2].GetLimit(), -32)
|
assert.Equal(t, vm.Strip[2].GetLimit(), -32)
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStrip4Label(t *testing.T) {
|
func TestStrip4Label(t *testing.T) {
|
||||||
//t.Skip("skipping test")
|
//t.Skip("skipping test")
|
||||||
vmRem.Strip[4].SetLabel("test0")
|
vm.Strip[4].SetLabel("test0")
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return test0 when SetLimit('test0')", func(t *testing.T) {
|
t.Run("Should return test0 when SetLimit('test0')", func(t *testing.T) {
|
||||||
assert.Equal(t, "test0", vmRem.Strip[4].GetLabel())
|
assert.Equal(t, "test0", vm.Strip[4].GetLabel())
|
||||||
})
|
})
|
||||||
|
|
||||||
vmRem.Strip[4].SetLabel("test1")
|
vm.Strip[4].SetLabel("test1")
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return test1 when SetLimit('test1')", func(t *testing.T) {
|
t.Run("Should return test1 when SetLimit('test1')", func(t *testing.T) {
|
||||||
assert.Equal(t, "test1", vmRem.Strip[4].GetLabel())
|
assert.Equal(t, "test1", vm.Strip[4].GetLabel())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStrip5Gain(t *testing.T) {
|
func TestStrip5Gain(t *testing.T) {
|
||||||
//t.Skip("skipping test")
|
//t.Skip("skipping test")
|
||||||
vmRem.Strip[4].SetGain(-20.8)
|
vm.Strip[4].SetGain(-20.8)
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return -20.8 when SetGain(-20.8)", func(t *testing.T) {
|
t.Run("Should return -20.8 when SetGain(-20.8)", func(t *testing.T) {
|
||||||
assert.Equal(t, vmRem.Strip[4].GetGain(), -20.8)
|
assert.Equal(t, vm.Strip[4].GetGain(), -20.8)
|
||||||
})
|
})
|
||||||
|
|
||||||
vmRem.Strip[4].SetGain(-3.6)
|
vm.Strip[4].SetGain(-3.6)
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return -3.6 when SetGain(-3.6)", func(t *testing.T) {
|
t.Run("Should return -3.6 when SetGain(-3.6)", func(t *testing.T) {
|
||||||
assert.Equal(t, vmRem.Strip[4].GetGain(), -3.6)
|
assert.Equal(t, vm.Strip[4].GetGain(), -3.6)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStrip3Comp(t *testing.T) {
|
func TestStrip3Comp(t *testing.T) {
|
||||||
//t.Skip("skipping test")
|
//t.Skip("skipping test")
|
||||||
vmRem.Strip[4].SetComp(8.1)
|
vm.Strip[4].SetComp(8.1)
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return 8.1 when SetGain(8.1)", func(t *testing.T) {
|
t.Run("Should return 8.1 when SetGain(8.1)", func(t *testing.T) {
|
||||||
assert.Equal(t, vmRem.Strip[4].GetComp(), 8.1)
|
assert.Equal(t, vm.Strip[4].GetComp(), 8.1)
|
||||||
})
|
})
|
||||||
|
|
||||||
vmRem.Strip[4].SetComp(1.6)
|
vm.Strip[4].SetComp(1.6)
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return 1.6 when SetGain(1.6)", func(t *testing.T) {
|
t.Run("Should return 1.6 when SetGain(1.6)", func(t *testing.T) {
|
||||||
assert.Equal(t, vmRem.Strip[4].GetComp(), 1.6)
|
assert.Equal(t, vm.Strip[4].GetComp(), 1.6)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStrip5Mc(t *testing.T) {
|
func TestStrip5Mc(t *testing.T) {
|
||||||
//t.Skip("skipping test")
|
//t.Skip("skipping test")
|
||||||
vmRem.Strip[5].SetMc(true)
|
vm.Strip[5].SetMc(true)
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return true when SetMc(true)", func(t *testing.T) {
|
t.Run("Should return true when SetMc(true)", func(t *testing.T) {
|
||||||
assert.True(t, vmRem.Strip[5].GetMc())
|
assert.True(t, vm.Strip[5].GetMc())
|
||||||
})
|
})
|
||||||
|
|
||||||
vmRem.Strip[5].SetMc(false)
|
vm.Strip[5].SetMc(false)
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return false when SetMc(false)", func(t *testing.T) {
|
t.Run("Should return false when SetMc(false)", func(t *testing.T) {
|
||||||
assert.False(t, vmRem.Strip[5].GetMc())
|
assert.False(t, vm.Strip[5].GetMc())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStrip2GainLayer3(t *testing.T) {
|
func TestStrip2GainLayer3(t *testing.T) {
|
||||||
//t.Skip("skipping test")
|
//t.Skip("skipping test")
|
||||||
vmRem.Strip[2].GainLayer()[3].Set(-18.3)
|
vm.Strip[2].GainLayer()[3].Set(-18.3)
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return -18.3 when SetMc(true)", func(t *testing.T) {
|
t.Run("Should return -18.3 when SetMc(true)", func(t *testing.T) {
|
||||||
assert.Equal(t, vmRem.Strip[2].GainLayer()[3].Get(), -18.3)
|
assert.Equal(t, vm.Strip[2].GainLayer()[3].Get(), -18.3)
|
||||||
})
|
})
|
||||||
|
|
||||||
vmRem.Strip[2].GainLayer()[3].Set(-25.6)
|
vm.Strip[2].GainLayer()[3].Set(-25.6)
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return -25.6 when SetMc(true)", func(t *testing.T) {
|
t.Run("Should return -25.6 when SetMc(true)", func(t *testing.T) {
|
||||||
assert.Equal(t, vmRem.Strip[2].GainLayer()[3].Get(), -25.6)
|
assert.Equal(t, vm.Strip[2].GainLayer()[3].Get(), -25.6)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBus3Eq(t *testing.T) {
|
func TestBus3Eq(t *testing.T) {
|
||||||
//t.Skip("skipping test")
|
//t.Skip("skipping test")
|
||||||
vmRem.Bus[3].SetEq(true)
|
vm.Bus[3].SetEq(true)
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return true when SetEq(true)", func(t *testing.T) {
|
t.Run("Should return true when SetEq(true)", func(t *testing.T) {
|
||||||
assert.True(t, vmRem.Bus[3].GetEq())
|
assert.True(t, vm.Bus[3].GetEq())
|
||||||
})
|
})
|
||||||
|
|
||||||
vmRem.Bus[3].SetEq(false)
|
vm.Bus[3].SetEq(false)
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return false when SetEq(false)", func(t *testing.T) {
|
t.Run("Should return false when SetEq(false)", func(t *testing.T) {
|
||||||
assert.False(t, vmRem.Bus[3].GetEq())
|
assert.False(t, vm.Bus[3].GetEq())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBus4Label(t *testing.T) {
|
func TestBus4Label(t *testing.T) {
|
||||||
//t.Skip("skipping test")
|
//t.Skip("skipping test")
|
||||||
vmRem.Bus[4].SetLabel("test0")
|
vm.Bus[4].SetLabel("test0")
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return test0 when SetEq('test0')", func(t *testing.T) {
|
t.Run("Should return test0 when SetEq('test0')", func(t *testing.T) {
|
||||||
assert.Equal(t, "test0", vmRem.Bus[4].GetLabel())
|
assert.Equal(t, "test0", vm.Bus[4].GetLabel())
|
||||||
})
|
})
|
||||||
|
|
||||||
vmRem.Bus[4].SetLabel("test1")
|
vm.Bus[4].SetLabel("test1")
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return test1 when SetEq('test1')", func(t *testing.T) {
|
t.Run("Should return test1 when SetEq('test1')", func(t *testing.T) {
|
||||||
assert.Equal(t, "test1", vmRem.Bus[4].GetLabel())
|
assert.Equal(t, "test1", vm.Bus[4].GetLabel())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBus3ModeAmix(t *testing.T) {
|
func TestBus3ModeAmix(t *testing.T) {
|
||||||
//t.Skip("skipping test")
|
//t.Skip("skipping test")
|
||||||
vmRem.Bus[3].Mode().SetAmix(true)
|
vm.Bus[3].Mode().SetAmix(true)
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return true when Mode().SetAmix(true)", func(t *testing.T) {
|
t.Run("Should return true when Mode().SetAmix(true)", func(t *testing.T) {
|
||||||
assert.True(t, vmRem.Bus[3].Mode().GetAmix())
|
assert.True(t, vm.Bus[3].Mode().GetAmix())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestVbanInStream0On(t *testing.T) {
|
func TestVbanInStream0On(t *testing.T) {
|
||||||
//t.Skip("skipping test")
|
//t.Skip("skipping test")
|
||||||
vmRem.Vban.InStream[0].SetOn(true)
|
vm.Vban.InStream[0].SetOn(true)
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return true when SetOn(true)", func(t *testing.T) {
|
t.Run("Should return true when SetOn(true)", func(t *testing.T) {
|
||||||
assert.True(t, vmRem.Vban.InStream[0].GetOn())
|
assert.True(t, vm.Vban.InStream[0].GetOn())
|
||||||
})
|
})
|
||||||
|
|
||||||
vmRem.Vban.InStream[0].SetOn(false)
|
vm.Vban.InStream[0].SetOn(false)
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return false when SetOn(false)", func(t *testing.T) {
|
t.Run("Should return false when SetOn(false)", func(t *testing.T) {
|
||||||
assert.False(t, vmRem.Vban.InStream[0].GetOn())
|
assert.False(t, vm.Vban.InStream[0].GetOn())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestVbanOutStream6On(t *testing.T) {
|
func TestVbanOutStream6On(t *testing.T) {
|
||||||
//t.Skip("skipping test")
|
//t.Skip("skipping test")
|
||||||
vmRem.Vban.OutStream[6].SetOn(true)
|
vm.Vban.OutStream[6].SetOn(true)
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return true when SetOn(true)", func(t *testing.T) {
|
t.Run("Should return true when SetOn(true)", func(t *testing.T) {
|
||||||
assert.True(t, vmRem.Vban.OutStream[6].GetOn())
|
assert.True(t, vm.Vban.OutStream[6].GetOn())
|
||||||
})
|
})
|
||||||
|
|
||||||
vmRem.Vban.OutStream[6].SetOn(false)
|
vm.Vban.OutStream[6].SetOn(false)
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return false when SetOn(false)", func(t *testing.T) {
|
t.Run("Should return false when SetOn(false)", func(t *testing.T) {
|
||||||
assert.False(t, vmRem.Vban.OutStream[6].GetOn())
|
assert.False(t, vm.Vban.OutStream[6].GetOn())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestVbanOutStream3Name(t *testing.T) {
|
func TestVbanOutStream3Name(t *testing.T) {
|
||||||
t.Skip("skipping test")
|
t.Skip("skipping test")
|
||||||
vmRem.Vban.OutStream[3].SetName("test0")
|
vm.Vban.OutStream[3].SetName("test0")
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return test0 when SetName('test0')", func(t *testing.T) {
|
t.Run("Should return test0 when SetName('test0')", func(t *testing.T) {
|
||||||
assert.Equal(t, "test0", vmRem.Vban.OutStream[3].GetName())
|
assert.Equal(t, "test0", vm.Vban.OutStream[3].GetName())
|
||||||
})
|
})
|
||||||
|
|
||||||
vmRem.Vban.OutStream[3].SetName("test1")
|
vm.Vban.OutStream[3].SetName("test1")
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return test1 when SetName('test1')", func(t *testing.T) {
|
t.Run("Should return test1 when SetName('test1')", func(t *testing.T) {
|
||||||
assert.Equal(t, "test1", vmRem.Vban.OutStream[3].GetName())
|
assert.Equal(t, "test1", vm.Vban.OutStream[3].GetName())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,21 +219,21 @@ func TestVbanInStream4Bit(t *testing.T) {
|
|||||||
t.Error("expected panic")
|
t.Error("expected panic")
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
vmRem.Vban.InStream[4].SetBit(16)
|
vm.Vban.InStream[4].SetBit(16)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestVbanOutStream4Bit(t *testing.T) {
|
func TestVbanOutStream4Bit(t *testing.T) {
|
||||||
//t.Skip("skipping test")
|
//t.Skip("skipping test")
|
||||||
vmRem.Vban.OutStream[4].SetBit(16)
|
vm.Vban.OutStream[4].SetBit(16)
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return 16 when SetBit(16)", func(t *testing.T) {
|
t.Run("Should return 16 when SetBit(16)", func(t *testing.T) {
|
||||||
assert.Equal(t, vmRem.Vban.OutStream[4].GetBit(), 16)
|
assert.Equal(t, vm.Vban.OutStream[4].GetBit(), 16)
|
||||||
})
|
})
|
||||||
|
|
||||||
vmRem.Vban.OutStream[4].SetBit(24)
|
vm.Vban.OutStream[4].SetBit(24)
|
||||||
sync()
|
sync()
|
||||||
t.Run("Should return 24 when SetBit(24)", func(t *testing.T) {
|
t.Run("Should return 24 when SetBit(24)", func(t *testing.T) {
|
||||||
assert.Equal(t, vmRem.Vban.OutStream[4].GetBit(), 24)
|
assert.Equal(t, vm.Vban.OutStream[4].GetBit(), 24)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
8
vban.go
8
vban.go
@@ -169,12 +169,12 @@ type vban struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newVban(k *kind) *vban {
|
func newVban(k *kind) *vban {
|
||||||
_vbanIn := make([]iVban, k.vbanIn)
|
_vbanIn := make([]iVban, k.VbanIn)
|
||||||
for i := 0; i < k.vbanIn; i++ {
|
for i := 0; i < k.VbanIn; i++ {
|
||||||
_vbanIn[i] = newVbanInStream(i)
|
_vbanIn[i] = newVbanInStream(i)
|
||||||
}
|
}
|
||||||
_vbanOut := make([]iVban, k.vbanOut)
|
_vbanOut := make([]iVban, k.VbanOut)
|
||||||
for i := 0; i < k.vbanOut; i++ {
|
for i := 0; i < k.VbanOut; i++ {
|
||||||
_vbanOut[i] = newVbanOutStream(i)
|
_vbanOut[i] = newVbanOutStream(i)
|
||||||
}
|
}
|
||||||
return &vban{
|
return &vban{
|
||||||
|
|||||||
Reference in New Issue
Block a user