mirror of
https://github.com/onyx-and-iris/voicemeeter.git
synced 2026-04-18 05:23:31 +00:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6fabc43998 | ||
|
|
3fd08ff606 | ||
|
|
7744971a10 | ||
|
|
82bbcd06b1 | ||
|
|
cba2ac85ec | ||
|
|
dd895daffb | ||
|
|
87a05d81e4 | ||
|
|
3ea4aee863 | ||
|
|
69476ffcd9 | ||
|
|
76e6d3cba7 | ||
|
|
1af67bb219 | ||
|
|
14264d0818 | ||
|
|
1efac19b12 | ||
|
|
36522cf80c | ||
|
|
119a996afd | ||
|
|
70d69f5599 | ||
|
|
f16bed893f | ||
|
|
e7061ce855 | ||
|
|
39411ab332 | ||
|
|
6148d45b76 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,5 +1,5 @@
|
|||||||
# quick tests
|
# quick tests
|
||||||
quick.go
|
quick
|
||||||
|
|
||||||
# Binaries for programs and plugins
|
# Binaries for programs and plugins
|
||||||
*.exe
|
*.exe
|
||||||
|
|||||||
97
CHANGELOG.md
97
CHANGELOG.md
@@ -10,3 +10,100 @@ Before any major/minor/patch bump all unit tests will be run to verify they pass
|
|||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
- [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
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- docstrings added to types, methods and functions
|
||||||
|
- version retractions added to go.mod
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Entry method renamed from GetRemote to NewRemote
|
||||||
|
- Readme updated to reflect latest changes
|
||||||
|
|
||||||
|
## [1.1.0] - 2022-06-30
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Level updates implemented in Pooler struct. Runs in its own goroutine.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed bug with identifier in outputs struct.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Package files moved into root of repository.
|
||||||
|
- Remote struct now exported type
|
||||||
|
|
||||||
|
## [1.0.0] - 2022-06-30
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- recorder, device structs implemented
|
||||||
|
- gainlayers field in strip struct implemented
|
||||||
|
- levels field in strip, bus structs implemented
|
||||||
|
- pooler ratelimit set at 33ms
|
||||||
|
|
||||||
|
## [0.0.3] - 2022-06-25
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- pre-commit.ps1 added for use with git hook
|
||||||
|
- unit tests for factory functions added
|
||||||
|
- vban parameter methods added
|
||||||
|
- support for observers added. publisher/observer structs defined
|
||||||
|
- Pooler struct added, pdirty, mdirty now updated continously in a goroutine
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- NewRemote factory method now uses director, builder types to create Remote types.
|
||||||
|
- cdll renamed to path
|
||||||
|
- test suite now using testify/assert
|
||||||
|
|
||||||
|
## [0.0.2] - 2022-06-23
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- physicalStrip, virtualStrip, physicalBus and virtualBus types defined.
|
||||||
|
- factory methods for strip, bus now cast return values to interface types.
|
||||||
|
- parameter methods added to strip, bus types.
|
||||||
|
- command struct implemented
|
||||||
|
- bus, vban unit tests added
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- strip, bus slices in remote type defined as interface slice types.
|
||||||
|
- bindings in base now prepended with vm.
|
||||||
|
- vban fields added to kind structs
|
||||||
|
|
||||||
|
## [0.0.1] - 2022-06-22
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- interface entry point defined in remote
|
||||||
|
- some base functions are exported through forwarding methods in Remote type (Login, Logout etc)
|
||||||
|
- wrapper around the CAPI defined in base
|
||||||
|
- path helper functions defined in cdll
|
||||||
|
- kind structs defined in kinds. These describe the layout for each version.
|
||||||
|
- channel, strip, bus structs getter/setter procedures defined.
|
||||||
|
- button struct fully implemented.
|
||||||
|
- initial test commit
|
||||||
|
|||||||
433
README.md
433
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
|
||||||
|
|
||||||
@@ -19,11 +19,17 @@ For an outline of past/future changes refer to: [CHANGELOG](CHANGELOG.md)
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
#### GO.MOD
|
||||||
|
|
||||||
Add to your `go.mod` file:
|
Add to your `go.mod` file:
|
||||||
|
|
||||||
`require github.com/onyx-and-iris/voicemeeter-api-go v1.0.0`
|
`require github.com/onyx-and-iris/voicemeeter-api-go vX.X.X`
|
||||||
|
|
||||||
Install voicemeeter-api-go package from your console
|
where `vX.X.X` is the version you require.
|
||||||
|
|
||||||
|
#### GO GET
|
||||||
|
|
||||||
|
Install voicemeeter-api-go package from your console to download the latest version.
|
||||||
|
|
||||||
`go get github.com/onyx-and-iris/voicemeeter-api-go`
|
`go get github.com/onyx-and-iris/voicemeeter-api-go`
|
||||||
|
|
||||||
@@ -37,24 +43,23 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/onyx-and-iris/voicemeeter-api-go/voicemeeter"
|
"github.com/onyx-and-iris/voicemeeter-api-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
kindId := "banana"
|
kindId := "banana"
|
||||||
vmRem := voicemeeter.GetRemote(kindId)
|
vm := voicemeeter.NewRemote(kindId)
|
||||||
|
|
||||||
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()
|
vm.Logout()
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## `kindId`
|
## `kindId`
|
||||||
|
|
||||||
Pass the kind of Voicemeeter as an argument. kindId may be:
|
Pass the kind of Voicemeeter as an argument. kindId may be:
|
||||||
@@ -64,235 +69,381 @@ Pass the kind of Voicemeeter as an argument. kindId may be:
|
|||||||
- `potato`
|
- `potato`
|
||||||
|
|
||||||
## `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()`
|
|
||||||
returns True iff a macrobutton paramter has changed
|
#### `vm.Mdirty()`
|
||||||
|
|
||||||
|
returns True iff a macrobutton parameter has changed
|
||||||
|
|
||||||
## `Available commands`
|
## `Available commands`
|
||||||
|
|
||||||
### Strip
|
### Strip
|
||||||
|
|
||||||
The following functions are available
|
The following methods are available
|
||||||
|
|
||||||
- `GetMute() bool`
|
- `GetMute() bool`
|
||||||
- `SetMute(val bool)`
|
- `SetMute(val bool)`
|
||||||
- `GetMono() bool`
|
- `GetMono() bool`
|
||||||
- `SetMono(val bool)`
|
- `SetMono(val bool)`
|
||||||
- `GetSolo() bool`
|
- `GetSolo() bool`
|
||||||
- `SetSolo(val bool)`
|
- `SetSolo(val bool)`
|
||||||
- `GetLimit() int`
|
- `GetLimit() int`
|
||||||
- `SetLimit(val int)` from -40 to 12
|
- `SetLimit(val int)` from -40 to 12
|
||||||
- `GetLabel() string`
|
- `GetLabel() string`
|
||||||
- `SetLabel(val string)`
|
- `SetLabel(val string)`
|
||||||
- `GetGain() float64`
|
- `GetGain() float64`
|
||||||
- `SetGain(val float32)` from -60.0 to 12.0
|
- `SetGain(val float32)` from -60.0 to 12.0
|
||||||
- `GetMc() bool`
|
- `GetMc() bool`
|
||||||
- `SetMc(val bool)`
|
- `SetMc(val bool)`
|
||||||
- `GetComp() float64`
|
- `GetComp() float64`
|
||||||
- `SetComp(val float32)` from 0.0 to 10.0
|
- `SetComp(val float32)` from 0.0 to 10.0
|
||||||
- `GetGate() float64`
|
- `GetGate() float64`
|
||||||
- `SetGate(val float32)` from 0.0 to 10.0
|
- `SetGate(val float32)` from 0.0 to 10.0
|
||||||
- `GetAudibility() float64`
|
- `GetAudibility() float64`
|
||||||
- `SetAudibility(val float32)` from 0.0 to 10.0
|
- `SetAudibility(val float32)` from 0.0 to 10.0
|
||||||
- `GetA1() bool - GetA5() bool`
|
- `GetA1() bool - GetA5() bool`
|
||||||
- `SetA1(val bool) - SetA5(val bool)`
|
- `SetA1(val bool) - SetA5(val bool)`
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
- `vm.Strip[i].GainLayer()[j]`
|
||||||
|
|
||||||
|
The following methods are available
|
||||||
|
|
||||||
|
- `Get() float64`
|
||||||
|
- `Set(val float32)`
|
||||||
|
|
||||||
|
example:
|
||||||
|
|
||||||
|
```go
|
||||||
|
vm.Strip[6].GainLayer()[3].Set(-13.6)
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Levels
|
||||||
|
|
||||||
|
- `vm.Strip[i].Levels()`
|
||||||
|
|
||||||
|
The following methods are available
|
||||||
|
|
||||||
|
- `PreFader() []float32`
|
||||||
|
- `PostFader() []float32`
|
||||||
|
- `PostMute() []float32`
|
||||||
|
|
||||||
|
example:
|
||||||
|
|
||||||
|
```go
|
||||||
|
fmt.Println(vm.Strip[5].Levels().PreFader())
|
||||||
```
|
```
|
||||||
|
|
||||||
### Bus
|
### Bus
|
||||||
|
|
||||||
The following functions are available
|
The following methods are available
|
||||||
|
|
||||||
- `String() string`
|
- `String() string`
|
||||||
- `GetMute() bool`
|
- `GetMute() bool`
|
||||||
- `SetMute(val bool)`
|
- `SetMute(val bool)`
|
||||||
- `GetEq() bool`
|
- `GetEq() bool`
|
||||||
- `SetEq(val bool)`
|
- `SetEq(val bool)`
|
||||||
- `GetMono() bool`
|
- `GetMono() bool`
|
||||||
- `SetMono(val bool)`
|
- `SetMono(val bool)`
|
||||||
- `GetLabel() string`
|
- `GetLabel() string`
|
||||||
- `SetLabel(val string)`
|
- `SetLabel(val string)`
|
||||||
- `GetGain() float64`
|
- `GetGain() float64`
|
||||||
- `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 functions are available
|
The following methods are available
|
||||||
|
|
||||||
- `normal`: boolean
|
- `SetNormal(val bool)`
|
||||||
- `amix`: boolean
|
- `GetNormal() bool`
|
||||||
- `bmix`: boolean
|
- `SetAmix(val bool)`
|
||||||
- `composite`: boolean
|
- `GetAmix() bool`
|
||||||
- `tvmix`: boolean
|
- `SetBmix(val bool)`
|
||||||
- `upmix21`: boolean
|
- `GetBmix() bool`
|
||||||
- `upmix41`: boolean
|
- `SetRepeat(val bool)`
|
||||||
- `upmix61`: boolean
|
- `GetRepeat() bool`
|
||||||
- `centeronly`: boolean
|
- `SetComposite(val bool)`
|
||||||
- `lfeonly`: boolean
|
- `GetComposite() bool`
|
||||||
- `rearonly`: boolean
|
- `SetTvMix(val bool)`
|
||||||
|
- `GetTvMix() bool`
|
||||||
|
- `SetUpMix21(val bool)`
|
||||||
|
- `GetUpMix21() bool`
|
||||||
|
- `SetUpMix41(val bool)`
|
||||||
|
- `GetUpMix41() bool`
|
||||||
|
- `SetUpMix61(val bool)`
|
||||||
|
- `GetUpMix61() bool`
|
||||||
|
- `SetCenterOnly(val bool)`
|
||||||
|
- `GetCenterOnly() bool`
|
||||||
|
- `SetLfeOnly(val bool)`
|
||||||
|
- `GetLfeOnly() bool`
|
||||||
|
- `SetRearOnly(val bool)`
|
||||||
|
- `GetRearOnly() bool`
|
||||||
|
|
||||||
example:
|
example:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
vmRem.Bus[3].Mode().SetAmix(true)
|
vm.Bus[3].Mode().SetAmix(true)
|
||||||
|
vm.Bus[4].Mode().SetCenterOnly(true)
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Levels
|
||||||
|
|
||||||
|
- `vm.Bus[i].Levels()`
|
||||||
|
|
||||||
|
The following methods are available
|
||||||
|
|
||||||
|
- `All() []float32`
|
||||||
|
|
||||||
|
example:
|
||||||
|
|
||||||
|
```go
|
||||||
|
fmt.Println(vm.Bus[1].Levels().All())
|
||||||
```
|
```
|
||||||
|
|
||||||
### Button
|
### Button
|
||||||
|
|
||||||
The following functions are available
|
The following methods are available
|
||||||
|
|
||||||
- `GetState() bool`
|
- `GetState() bool`
|
||||||
- `SetState(val bool)`
|
- `SetState(val bool)`
|
||||||
- `GetStateOnly() bool`
|
- `GetStateOnly() bool`
|
||||||
- `SetStateOnly(val bool)`
|
- `SetStateOnly(val bool)`
|
||||||
- `GetTrigger() bool`
|
- `GetTrigger() bool`
|
||||||
- `SetTrigger(val bool)`
|
- `SetTrigger(val bool)`
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
The following functions are available
|
The following methods are available
|
||||||
|
|
||||||
- `Show()` Show Voicemeeter GUI if it's hidden
|
- `Show()` Show Voicemeeter GUI if it's hidden
|
||||||
- `Hide()` Hide Voicemeeter GUI if it's shown
|
- `Hide()` Hide Voicemeeter GUI if it's shown
|
||||||
- `Shutdown()` Shuts down the GUI
|
- `Shutdown()` Shuts down the GUI
|
||||||
- `Restart()` Restart the audio engine
|
- `Restart()` Restart the audio engine
|
||||||
- `Lock(val bool)` Lock the Voicemeeter GUI
|
- `Lock(val bool)` Lock the Voicemeeter GUI
|
||||||
|
|
||||||
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 functions are available
|
The following methods are available
|
||||||
|
|
||||||
- `GetOn() bool`
|
- `GetOn() bool`
|
||||||
- `SetOn(val bool)`
|
- `SetOn(val bool)`
|
||||||
- `GetName() string`
|
- `GetName() string`
|
||||||
- `SetName(val string)`
|
- `SetName(val string)`
|
||||||
- `GetIp() string`
|
- `GetIp() string`
|
||||||
- `SetIp(val string)`
|
- `SetIp(val string)`
|
||||||
- `GetPort() int`
|
- `GetPort() int`
|
||||||
- `SetPort(val int)` from 1024 to 65535
|
- `SetPort(val int)` from 1024 to 65535
|
||||||
- `GetSr() int`
|
- `GetSr() int`
|
||||||
- `SetSr(val int)` (11025, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000)
|
- `SetSr(val int)` (11025, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000)
|
||||||
- `GetChannel() int`
|
- `GetChannel() int`
|
||||||
- `SetChannel(val int)` from 1 to 8
|
- `SetChannel(val int)` from 1 to 8
|
||||||
- `GetBit() int`
|
- `GetBit() int`
|
||||||
- `SetBit(val int)` 16 or 24
|
- `SetBit(val int)` 16 or 24
|
||||||
- `GetQuality() int`
|
- `GetQuality() int`
|
||||||
- `SetQuality(val int)` from 0 to 4
|
- `SetQuality(val int)` from 0 to 4
|
||||||
- `GetRoute() int`
|
- `GetRoute() int`
|
||||||
- `SetRoute(val int)` from 0 to 8
|
- `SetRoute(val int)` from 0 to 8
|
||||||
|
|
||||||
example:
|
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 functions 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))
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Recorder
|
### Recorder
|
||||||
|
|
||||||
The following functions are available
|
The following methods are available
|
||||||
|
|
||||||
- `Play()`
|
- `Play()`
|
||||||
- `Stop()`
|
- `Stop()`
|
||||||
- `Pause()`
|
- `Pause()`
|
||||||
- `Replay()`
|
- `Replay()`
|
||||||
- `Record()`
|
- `Record()`
|
||||||
- `Ff()`
|
- `Ff()`
|
||||||
- `Rew()`
|
- `Rew()`
|
||||||
|
|
||||||
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
|
||||||
@@ -300,7 +451,7 @@ vmRem.Recorder.SetB2(false)
|
|||||||
To run all tests:
|
To run all tests:
|
||||||
|
|
||||||
```
|
```
|
||||||
go run test ./...
|
go test ./...
|
||||||
```
|
```
|
||||||
|
|
||||||
### Official Documentation
|
### Official Documentation
|
||||||
|
|||||||
@@ -37,10 +37,13 @@ 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,
|
||||||
// then attempts to launch Voicemeeter if it's not running.
|
// attempts to launch Voicemeeter if it's not running,
|
||||||
|
// initializes dirty parameters.
|
||||||
func login(kindId string) {
|
func login(kindId string) {
|
||||||
res, _, _ := vmLogin.Call()
|
res, _, _ := vmLogin.Call()
|
||||||
if res == 1 {
|
if res == 1 {
|
||||||
@@ -51,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 {
|
||||||
@@ -66,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.
|
||||||
@@ -112,6 +115,22 @@ func mdirty() bool {
|
|||||||
return int(res) == 1
|
return int(res) == 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ldirty returns true iff a level value has changed
|
||||||
|
func ldirty(k *kind) bool {
|
||||||
|
_levelCache.stripLevelsBuff = make([]float32, (2*k.PhysIn)+(8*k.VirtIn))
|
||||||
|
_levelCache.busLevelsBuff = make([]float32, 8*k.NumBus())
|
||||||
|
|
||||||
|
for i := 0; i < (2*k.PhysIn)+(8*k.VirtIn); i++ {
|
||||||
|
_levelCache.stripLevelsBuff[i] = float32(getLevel(_levelCache.stripMode, i))
|
||||||
|
_levelCache.stripComp[i] = _levelCache.stripLevelsBuff[i] == _levelCache.stripLevels[i]
|
||||||
|
}
|
||||||
|
for i := 0; i < 8*k.NumBus(); i++ {
|
||||||
|
_levelCache.busLevelsBuff[i] = float32(getLevel(3, 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()))
|
||||||
|
}
|
||||||
|
|
||||||
// getVMType returns the type of Voicemeeter, as a string
|
// getVMType returns the type of Voicemeeter, as a string
|
||||||
func getVMType() string {
|
func getVMType() string {
|
||||||
var type_ uint64
|
var type_ uint64
|
||||||
@@ -237,7 +256,8 @@ func setMacroStatus(id, state, mode int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func get_num_devices(dir string) uint64 {
|
// getNumDevices returns the number of hardware input/output devices
|
||||||
|
func getNumDevices(dir string) uint64 {
|
||||||
if strings.Compare(dir, "in") == 0 {
|
if strings.Compare(dir, "in") == 0 {
|
||||||
res, _, _ := vmGetDevNumIn.Call()
|
res, _, _ := vmGetDevNumIn.Call()
|
||||||
return uint64(res)
|
return uint64(res)
|
||||||
@@ -247,7 +267,8 @@ func get_num_devices(dir string) uint64 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func get_device_description(i int, dir string) (string, uint64, string) {
|
// getDeviceDescription returns name, driver type and hwid for a given device
|
||||||
|
func getDeviceDescription(i int, dir string) (string, uint64, string) {
|
||||||
var t_ uint64
|
var t_ uint64
|
||||||
var b1 [512]byte
|
var b1 [512]byte
|
||||||
var b2 [512]byte
|
var b2 [512]byte
|
||||||
@@ -296,3 +317,34 @@ 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),
|
||||||
|
)
|
||||||
|
if int(res) < 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
|
||||||
|
}
|
||||||
@@ -2,9 +2,11 @@ package voicemeeter
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type t_bus interface {
|
// iBus defines the interface bus types must satisfy
|
||||||
|
type iBus interface {
|
||||||
String() string
|
String() string
|
||||||
GetMute() bool
|
GetMute() bool
|
||||||
SetMute(val bool)
|
SetMute(val bool)
|
||||||
@@ -16,8 +18,10 @@ type t_bus interface {
|
|||||||
SetLabel(val string)
|
SetLabel(val string)
|
||||||
GetGain() float64
|
GetGain() float64
|
||||||
SetGain(val float32)
|
SetGain(val float32)
|
||||||
Mode() t_busMode
|
Mode() iBusMode
|
||||||
Levels() *levels
|
Levels() *levels
|
||||||
|
FadeTo(target float32, time_ int)
|
||||||
|
FadeBy(change float32, time_ int)
|
||||||
}
|
}
|
||||||
|
|
||||||
// bus represents a bus channel
|
// bus represents a bus channel
|
||||||
@@ -78,25 +82,39 @@ func (b *bus) SetGain(val float32) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mode returns address of a busMode struct
|
// Mode returns address of a busMode struct
|
||||||
func (b *bus) Mode() t_busMode {
|
func (b *bus) Mode() iBusMode {
|
||||||
return &b.mode
|
return &b.mode
|
||||||
}
|
}
|
||||||
|
|
||||||
// Levels returns the gainlayer field
|
// Levels returns the levels field
|
||||||
func (b *bus) Levels() *levels {
|
func (b *bus) Levels() *levels {
|
||||||
return &b.levels
|
return &b.levels
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FadeTo sets the value of gain to target over at time interval of time_
|
||||||
|
func (b *bus) FadeTo(target float32, time_ int) {
|
||||||
|
b.setter_string("FadeTo", fmt.Sprintf("(\"%f\", %d)", target, time_))
|
||||||
|
time.Sleep(time.Millisecond)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FadeBy adjusts the value of gain by change over a time interval of time_
|
||||||
|
func (b *bus) FadeBy(change float32, time_ int) {
|
||||||
|
b.setter_string("FadeBy", fmt.Sprintf("(\"%f\", %d)", change, time_))
|
||||||
|
time.Sleep(time.Millisecond)
|
||||||
|
}
|
||||||
|
|
||||||
|
//physicalBus represents a single physical bus
|
||||||
type physicalBus struct {
|
type physicalBus struct {
|
||||||
bus
|
bus
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPhysicalBus(i int, k *kind) t_bus {
|
// newPhysicalBus returns a physicalBus type cast to an iBus
|
||||||
|
func newPhysicalBus(i int, k *kind) iBus {
|
||||||
b := newBusMode(i)
|
b := newBusMode(i)
|
||||||
l := newBusLevels(i, k)
|
l := newBusLevels(i, k)
|
||||||
pb := physicalBus{bus{iRemote{fmt.Sprintf("bus[%d]", i), i}, b, l}}
|
pb := physicalBus{bus{iRemote{fmt.Sprintf("bus[%d]", i), i}, b, l}}
|
||||||
|
|
||||||
return t_bus(&pb)
|
return iBus(&pb)
|
||||||
}
|
}
|
||||||
|
|
||||||
// String implements the fmt.stringer interface
|
// String implements the fmt.stringer interface
|
||||||
@@ -104,15 +122,17 @@ func (p *physicalBus) String() string {
|
|||||||
return fmt.Sprintf("PhysicalBus%d", p.index)
|
return fmt.Sprintf("PhysicalBus%d", p.index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//virtualBus represents a single virtual bus
|
||||||
type virtualBus struct {
|
type virtualBus struct {
|
||||||
bus
|
bus
|
||||||
}
|
}
|
||||||
|
|
||||||
func newVirtualBus(i int, k *kind) t_bus {
|
// newVirtualBus returns a virtualBus type cast to an iBus
|
||||||
|
func newVirtualBus(i int, k *kind) iBus {
|
||||||
b := newBusMode(i)
|
b := newBusMode(i)
|
||||||
l := newBusLevels(i, k)
|
l := newBusLevels(i, k)
|
||||||
vb := virtualBus{bus{iRemote{fmt.Sprintf("bus[%d]", i), i}, b, l}}
|
vb := virtualBus{bus{iRemote{fmt.Sprintf("bus[%d]", i), i}, b, l}}
|
||||||
return t_bus(&vb)
|
return iBus(&vb)
|
||||||
}
|
}
|
||||||
|
|
||||||
// String implements the fmt.stringer interface
|
// String implements the fmt.stringer interface
|
||||||
@@ -120,7 +140,8 @@ func (v *virtualBus) String() string {
|
|||||||
return fmt.Sprintf("VirtualBus%d", v.index)
|
return fmt.Sprintf("VirtualBus%d", v.index)
|
||||||
}
|
}
|
||||||
|
|
||||||
type t_busMode interface {
|
// iBusMode defines the interface busMode type must satisfy
|
||||||
|
type iBusMode interface {
|
||||||
SetNormal(val bool)
|
SetNormal(val bool)
|
||||||
GetNormal() bool
|
GetNormal() bool
|
||||||
SetAmix(val bool)
|
SetAmix(val bool)
|
||||||
@@ -147,119 +168,147 @@ type t_busMode interface {
|
|||||||
GetRearOnly() bool
|
GetRearOnly() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// busMode offers methods for getting/setting bus mode states
|
||||||
type busMode struct {
|
type busMode struct {
|
||||||
iRemote
|
iRemote
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// newBusMode returns a busMode struct
|
||||||
func newBusMode(i int) busMode {
|
func newBusMode(i int) busMode {
|
||||||
return busMode{iRemote{fmt.Sprintf("bus[%d].mode", i), i}}
|
return busMode{iRemote{fmt.Sprintf("bus[%d].mode", i), i}}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bm *busMode) SetNormal(val bool) {
|
// GetNormal gets the value of the Mode.Normal parameter
|
||||||
bm.setter_bool("Normal", val)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (bm *busMode) GetNormal() bool {
|
func (bm *busMode) GetNormal() bool {
|
||||||
return bm.getter_bool("Normal")
|
return bm.getter_bool("Normal")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bm *busMode) SetAmix(val bool) {
|
// SetNormal sets the value of the Mode.Normal parameter
|
||||||
bm.setter_bool("Amix", val)
|
func (bm *busMode) SetNormal(val bool) {
|
||||||
|
bm.setter_bool("Normal", val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetAmix gets the value of the Mode.Amix parameter
|
||||||
func (bm *busMode) GetAmix() bool {
|
func (bm *busMode) GetAmix() bool {
|
||||||
return bm.getter_bool("Amix")
|
return bm.getter_bool("Amix")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bm *busMode) SetBmix(val bool) {
|
// SetAmix sets the value of the Mode.Amix parameter
|
||||||
bm.setter_bool("Bmix", val)
|
func (bm *busMode) SetAmix(val bool) {
|
||||||
|
bm.setter_bool("Amix", val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetBmix gets the value of the Mode.Bmix parameter
|
||||||
func (bm *busMode) GetBmix() bool {
|
func (bm *busMode) GetBmix() bool {
|
||||||
return bm.getter_bool("Bmix")
|
return bm.getter_bool("Bmix")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bm *busMode) SetRepeat(val bool) {
|
// SetBmix sets the value of the Mode.Bmix parameter
|
||||||
bm.setter_bool("Repeat", val)
|
func (bm *busMode) SetBmix(val bool) {
|
||||||
|
bm.setter_bool("Bmix", val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRepeat gets the value of the Mode.Repeat parameter
|
||||||
func (bm *busMode) GetRepeat() bool {
|
func (bm *busMode) GetRepeat() bool {
|
||||||
return bm.getter_bool("Repeat")
|
return bm.getter_bool("Repeat")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bm *busMode) SetComposite(val bool) {
|
// SetRepeat sets the value of the Mode.Repeat parameter
|
||||||
bm.setter_bool("Composite", val)
|
func (bm *busMode) SetRepeat(val bool) {
|
||||||
|
bm.setter_bool("Repeat", val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetComposite gets the value of the Mode.Composite parameter
|
||||||
func (bm *busMode) GetComposite() bool {
|
func (bm *busMode) GetComposite() bool {
|
||||||
return bm.getter_bool("Composite")
|
return bm.getter_bool("Composite")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bm *busMode) SetTvMix(val bool) {
|
// SetComposite sets the value of the Mode.Composite parameter
|
||||||
bm.setter_bool("TvMix", val)
|
func (bm *busMode) SetComposite(val bool) {
|
||||||
|
bm.setter_bool("Composite", val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetTvMix gets the value of the Mode.TvMix parameter
|
||||||
func (bm *busMode) GetTvMix() bool {
|
func (bm *busMode) GetTvMix() bool {
|
||||||
return bm.getter_bool("TvMix")
|
return bm.getter_bool("TvMix")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bm *busMode) SetUpMix21(val bool) {
|
// SetTvMix sets the value of the Mode.TvMix parameter
|
||||||
bm.setter_bool("UpMix21", val)
|
func (bm *busMode) SetTvMix(val bool) {
|
||||||
|
bm.setter_bool("TvMix", val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetUpMix21 gets the value of the Mode.UpMix21 parameter
|
||||||
func (bm *busMode) GetUpMix21() bool {
|
func (bm *busMode) GetUpMix21() bool {
|
||||||
return bm.getter_bool("UpMix21")
|
return bm.getter_bool("UpMix21")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bm *busMode) SetUpMix41(val bool) {
|
// SetUpMix21 sets the value of the Mode.UpMix21 parameter
|
||||||
bm.setter_bool("UpMix41", val)
|
func (bm *busMode) SetUpMix21(val bool) {
|
||||||
|
bm.setter_bool("UpMix21", val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetUpMix41 gets the value of the Mode.UpMix41 parameter
|
||||||
func (bm *busMode) GetUpMix41() bool {
|
func (bm *busMode) GetUpMix41() bool {
|
||||||
return bm.getter_bool("UpMix41")
|
return bm.getter_bool("UpMix41")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bm *busMode) SetUpMix61(val bool) {
|
// SetUpMix41 sets the value of the Mode.UpMix41 parameter
|
||||||
bm.setter_bool("UpMix61", val)
|
func (bm *busMode) SetUpMix41(val bool) {
|
||||||
|
bm.setter_bool("UpMix41", val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetUpMix61 gets the value of the Mode.UpMix61 parameter
|
||||||
func (bm *busMode) GetUpMix61() bool {
|
func (bm *busMode) GetUpMix61() bool {
|
||||||
return bm.getter_bool("UpMix61")
|
return bm.getter_bool("UpMix61")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bm *busMode) SetCenterOnly(val bool) {
|
// SetUpMix61 sets the value of the Mode.UpMix61 parameter
|
||||||
bm.setter_bool("CenterOnly", val)
|
func (bm *busMode) SetUpMix61(val bool) {
|
||||||
|
bm.setter_bool("UpMix61", val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetCenterOnly gets the value of the Mode.CenterOnly parameter
|
||||||
func (bm *busMode) GetCenterOnly() bool {
|
func (bm *busMode) GetCenterOnly() bool {
|
||||||
return bm.getter_bool("CenterOnly")
|
return bm.getter_bool("CenterOnly")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bm *busMode) SetLfeOnly(val bool) {
|
// SetCenterOnly sets the value of the Mode.CenterOnly parameter
|
||||||
bm.setter_bool("LfeOnly", val)
|
func (bm *busMode) SetCenterOnly(val bool) {
|
||||||
|
bm.setter_bool("CenterOnly", val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetLfeOnly gets the value of the Mode.LFE parameter
|
||||||
func (bm *busMode) GetLfeOnly() bool {
|
func (bm *busMode) GetLfeOnly() bool {
|
||||||
return bm.getter_bool("LfeOnly")
|
return bm.getter_bool("LfeOnly")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bm *busMode) SetRearOnly(val bool) {
|
// SetLfeOnly sets the value of the Mode.LFE parameter
|
||||||
bm.setter_bool("RearOnly", val)
|
func (bm *busMode) SetLfeOnly(val bool) {
|
||||||
|
bm.setter_bool("LfeOnly", val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRearOnly gets the value of the Mode.RearOnly parameter
|
||||||
func (bm *busMode) GetRearOnly() bool {
|
func (bm *busMode) GetRearOnly() bool {
|
||||||
return bm.getter_bool("RearOnly")
|
return bm.getter_bool("RearOnly")
|
||||||
}
|
}
|
||||||
|
|
||||||
func newBusLevels(i int, k *kind) levels {
|
// SetRearOnly sets the value of the Mode.RearOnly parameter
|
||||||
init := i * 8
|
func (bm *busMode) SetRearOnly(val bool) {
|
||||||
return levels{iRemote{fmt.Sprintf("bus[%d]", i), i}, k, init, 8}
|
bm.setter_bool("RearOnly", val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// newBusLevels represents the levels field for a channel
|
||||||
|
func newBusLevels(i int, k *kind) levels {
|
||||||
|
init := i * 8
|
||||||
|
return levels{iRemote{fmt.Sprintf("bus[%d]", i), i}, k, init, 8, "bus"}
|
||||||
|
}
|
||||||
|
|
||||||
|
// All returns the level values for a bus
|
||||||
func (l *levels) All() []float32 {
|
func (l *levels) All() []float32 {
|
||||||
var levels []float32
|
var levels []float32
|
||||||
for i := l.init; i < l.init+l.offset; i++ {
|
for i := l.init; i < l.init+l.offset; i++ {
|
||||||
levels = append(levels, l.convertLevel(getLevel(3, i)))
|
levels = append(levels, convertLevel(_levelCache.busLevels[i]))
|
||||||
}
|
}
|
||||||
return levels
|
return levels
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@ package voicemeeter
|
|||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
// custom strip type, struct forwarding channel
|
// button represents a single macrobuttton
|
||||||
type button struct {
|
type button struct {
|
||||||
index int
|
index int
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
package voicemeeter
|
package voicemeeter
|
||||||
|
|
||||||
|
//command represents command (action) type parameters
|
||||||
type command struct {
|
type command struct {
|
||||||
iRemote
|
iRemote
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// newCommand returns a pointer to a command type
|
||||||
func newCommand() *command {
|
func newCommand() *command {
|
||||||
return &command{iRemote{"command", 0}}
|
return &command{iRemote{"command", 0}}
|
||||||
}
|
}
|
||||||
@@ -29,7 +31,6 @@ func (c *command) Restart() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lock locks or unlocks the Voiceemeter GUI
|
// Lock locks or unlocks the Voiceemeter GUI
|
||||||
// it accepts a boolean value
|
|
||||||
func (c *command) Lock(val bool) {
|
func (c *command) Lock(val bool) {
|
||||||
var value float32
|
var value float32
|
||||||
if val {
|
if val {
|
||||||
@@ -13,16 +13,16 @@ func newDevice() *device {
|
|||||||
|
|
||||||
// Ins returns the total number of physical input devices
|
// Ins returns the total number of physical input devices
|
||||||
func (d *device) Ins() int {
|
func (d *device) Ins() int {
|
||||||
return int(get_num_devices("in"))
|
return int(getNumDevices("in"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ins returns the total number of physical input devices
|
// Ins returns the total number of physical input devices
|
||||||
func (d *device) Outs() int {
|
func (d *device) Outs() int {
|
||||||
return int(get_num_devices("out"))
|
return int(getNumDevices("out"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *device) Input(i int) devDesc {
|
func (d *device) Input(i int) devDesc {
|
||||||
n, t_, id := get_device_description(i, "in")
|
n, t_, id := getDeviceDescription(i, "in")
|
||||||
vals := map[uint64]string{
|
vals := map[uint64]string{
|
||||||
1: "mme",
|
1: "mme",
|
||||||
3: "wdm",
|
3: "wdm",
|
||||||
@@ -33,7 +33,7 @@ func (d *device) Input(i int) devDesc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *device) Output(i int) devDesc {
|
func (d *device) Output(i int) devDesc {
|
||||||
n, t_, id := get_device_description(i, "out")
|
n, t_, id := getDeviceDescription(i, "out")
|
||||||
vals := map[uint64]string{
|
vals := map[uint64]string{
|
||||||
1: "mme",
|
1: "mme",
|
||||||
3: "wdm",
|
3: "wdm",
|
||||||
@@ -2,37 +2,64 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/onyx-and-iris/voicemeeter-api-go/voicemeeter"
|
"github.com/onyx-and-iris/voicemeeter-api-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
type observer struct {
|
type observer struct {
|
||||||
i int
|
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) {
|
||||||
fmt.Println(o.i, subject)
|
if subject == "pdirty" {
|
||||||
|
fmt.Println("pdirty!")
|
||||||
|
}
|
||||||
|
if subject == "mdirty" {
|
||||||
|
fmt.Println("mdirty!")
|
||||||
|
}
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
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(),
|
||||||
|
o.vm.Bus[2].Levels().IsDirty(),
|
||||||
|
o.vm.Bus[3].Levels().IsDirty(),
|
||||||
|
o.vm.Bus[4].Levels().IsDirty(),
|
||||||
|
o.vm.Bus[5].Levels().IsDirty(),
|
||||||
|
o.vm.Bus[6].Levels().IsDirty(),
|
||||||
|
o.vm.Bus[7].Levels().IsDirty(),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
vmRem := voicemeeter.GetRemote("banana")
|
vm, err := voicemeeter.NewRemote("potato")
|
||||||
vmRem.Login()
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
defer vm.Logout()
|
||||||
|
|
||||||
o := observer{1}
|
vm.Login()
|
||||||
o2 := observer{2}
|
// enable level updates (disabled by default)
|
||||||
o3 := observer{3}
|
vm.EventAdd("ldirty")
|
||||||
o4 := observer{4}
|
|
||||||
vmRem.Register(o)
|
|
||||||
vmRem.Register(o2)
|
|
||||||
vmRem.Register(o3)
|
|
||||||
vmRem.Register(o4)
|
|
||||||
|
|
||||||
time.Sleep(5 * time.Second)
|
o := observer{vm}
|
||||||
|
o.Register()
|
||||||
vmRem.Deregister(o2)
|
time.Sleep(30 * time.Second)
|
||||||
|
o.Deregister()
|
||||||
time.Sleep(5 * time.Second)
|
|
||||||
|
|
||||||
vmRem.Logout()
|
|
||||||
}
|
}
|
||||||
|
|||||||
9
go.mod
9
go.mod
@@ -2,9 +2,14 @@ module github.com/onyx-and-iris/voicemeeter-api-go
|
|||||||
|
|
||||||
go 1.18
|
go 1.18
|
||||||
|
|
||||||
|
retract (
|
||||||
|
// package files moved into root of repository
|
||||||
|
[v1.0.0, v1.1.0]
|
||||||
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/stretchr/testify v1.7.5
|
github.com/stretchr/testify v1.8.0
|
||||||
golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664
|
golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
|||||||
8
go.sum
8
go.sum
@@ -6,10 +6,10 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
|
|||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.5 h1:s5PTfem8p8EbKQOctVV53k6jCJt3UX4IEJzwh+C324Q=
|
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||||
github.com/stretchr/testify v1.7.5/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664 h1:wEZYwx+kK+KlZ0hpvP2Ls1Xr4+RWnlzGFwPP0aiDjIU=
|
golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d h1:/m5NbqQelATgoSPVC2Z23sR4kVNokFwDDyWh/3rGY+I=
|
||||||
golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220708085239-5a0f0661e09d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
|||||||
30
helper_test.go
Normal file
30
helper_test.go
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
package voicemeeter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
vm, err = NewRemote("potato")
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestMain(m *testing.M) {
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
vm.Login()
|
||||||
|
code := m.Run()
|
||||||
|
vm.Logout()
|
||||||
|
os.Exit(code)
|
||||||
|
}
|
||||||
|
|
||||||
|
func sync() {
|
||||||
|
time.Sleep(30 * time.Millisecond)
|
||||||
|
for vm.Pdirty() || vm.Mdirty() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,15 +2,16 @@ package voicemeeter
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// iRemote provides a set of common forwarding methods
|
// iRemote provides an interface between higher methods and lower functions
|
||||||
|
// expected to be embedded
|
||||||
type iRemote struct {
|
type iRemote struct {
|
||||||
_identifier string
|
_identifier string
|
||||||
index int
|
index int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// identifier returns a string identifier
|
||||||
func (ir *iRemote) identifier() string {
|
func (ir *iRemote) identifier() string {
|
||||||
return ir._identifier
|
return ir._identifier
|
||||||
}
|
}
|
||||||
@@ -68,18 +69,3 @@ func (ir *iRemote) setter_string(p, v string) {
|
|||||||
param := fmt.Sprintf("%s.%s", ir.identifier(), p)
|
param := fmt.Sprintf("%s.%s", ir.identifier(), p)
|
||||||
setParameterString(param, v)
|
setParameterString(param, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
type levels struct {
|
|
||||||
iRemote
|
|
||||||
k *kind
|
|
||||||
init int
|
|
||||||
offset int
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *levels) convertLevel(i float32) float32 {
|
|
||||||
if i > 0 {
|
|
||||||
val := 20 * math.Log10(float64(i))
|
|
||||||
return float32(val)
|
|
||||||
}
|
|
||||||
return -200.0
|
|
||||||
}
|
|
||||||
@@ -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
|
||||||
46
levels.go
Normal file
46
levels.go
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
package voicemeeter
|
||||||
|
|
||||||
|
// levels represents the levels field for a channel
|
||||||
|
type levels struct {
|
||||||
|
iRemote
|
||||||
|
k *kind
|
||||||
|
init int
|
||||||
|
offset int
|
||||||
|
id string
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns true if any levels value for a strip/bus have been updated
|
||||||
|
func (l *levels) IsDirty() bool {
|
||||||
|
var vals []bool
|
||||||
|
if l.id == "strip" {
|
||||||
|
vals = _levelCache.stripComp[l.init : l.init+l.offset]
|
||||||
|
} else if l.id == "bus" {
|
||||||
|
vals = _levelCache.busComp[l.init : l.init+l.offset]
|
||||||
|
}
|
||||||
|
return !allTrue(vals, l.offset)
|
||||||
|
}
|
||||||
|
|
||||||
|
var _levelCache *levelCache
|
||||||
|
|
||||||
|
// levelCache defines level slices used by the pooler to track updates
|
||||||
|
type levelCache struct {
|
||||||
|
stripMode int
|
||||||
|
stripLevels []float32
|
||||||
|
busLevels []float32
|
||||||
|
stripLevelsBuff []float32
|
||||||
|
busLevelsBuff []float32
|
||||||
|
stripComp []bool
|
||||||
|
busComp []bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// newLevelCache returns a levelCache struct address
|
||||||
|
func newLevelCache(k *kind) *levelCache {
|
||||||
|
stripLevels := make([]float32, (2*k.PhysIn)+(8*k.VirtIn))
|
||||||
|
busLevels := make([]float32, 8*k.NumBus())
|
||||||
|
stripComp := make([]bool, (2*k.PhysIn)+(8*k.VirtIn))
|
||||||
|
busComp := make([]bool, 8*k.NumBus())
|
||||||
|
if _levelCache == nil {
|
||||||
|
_levelCache = &levelCache{stripMode: 0, stripLevels: stripLevels, busLevels: busLevels, stripComp: stripComp, busComp: busComp}
|
||||||
|
}
|
||||||
|
return _levelCache
|
||||||
|
}
|
||||||
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]
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package voicemeeter
|
package voicemeeter
|
||||||
|
|
||||||
type t_outputs interface {
|
// iOutputs defines the interface outputs type must satisfy
|
||||||
|
type iOutputs interface {
|
||||||
GetA1() bool
|
GetA1() bool
|
||||||
SetA1(val bool)
|
SetA1(val bool)
|
||||||
GetA2() bool
|
GetA2() bool
|
||||||
@@ -19,10 +20,13 @@ type t_outputs interface {
|
|||||||
SetB3(val bool)
|
SetB3(val bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// outputs represents the outputs field (A1 - A5, B1 - B3)
|
||||||
|
// expected to be embedded
|
||||||
type outputs struct {
|
type outputs struct {
|
||||||
iRemote
|
iRemote
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// newOutputs returns an outputs type
|
||||||
func newOutputs(id string, i int) outputs {
|
func newOutputs(id string, i int) outputs {
|
||||||
o := outputs{iRemote{id, i}}
|
o := outputs{iRemote{id, i}}
|
||||||
return o
|
return o
|
||||||
140
publisher.go
Normal file
140
publisher.go
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
package voicemeeter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// observer defines the interface any registered observers must satisfy
|
||||||
|
type observer interface {
|
||||||
|
OnUpdate(subject string)
|
||||||
|
}
|
||||||
|
|
||||||
|
// publisher defines methods that support observers
|
||||||
|
type publisher struct {
|
||||||
|
observerList []observer
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register adds an observer to observerList
|
||||||
|
func (p *publisher) Register(o observer) {
|
||||||
|
p.observerList = append(p.observerList, o)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deregister removes an observer from observerList
|
||||||
|
func (p *publisher) Deregister(o observer) {
|
||||||
|
var indexToRemove int
|
||||||
|
|
||||||
|
for i, observer := range p.observerList {
|
||||||
|
if observer == o {
|
||||||
|
indexToRemove = i
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p.observerList = append(p.observerList[:indexToRemove], p.observerList[indexToRemove+1:]...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// notify updates observers of any changes
|
||||||
|
func (p *publisher) notify(subject string) {
|
||||||
|
for _, observer := range p.observerList {
|
||||||
|
observer.OnUpdate(subject)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func newPooler(k *kind) *pooler {
|
||||||
|
p := &pooler{
|
||||||
|
k: k,
|
||||||
|
run: true,
|
||||||
|
event: newEvent(),
|
||||||
|
}
|
||||||
|
go p.parameters()
|
||||||
|
go p.macrobuttons()
|
||||||
|
go p.midi()
|
||||||
|
go p.levels()
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *pooler) parameters() {
|
||||||
|
for p.run {
|
||||||
|
if p.event.pdirty && pdirty() {
|
||||||
|
p.notify("pdirty")
|
||||||
|
}
|
||||||
|
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 getMidiMessage() {
|
||||||
|
p.notify("midi")
|
||||||
|
}
|
||||||
|
time.Sleep(33 * time.Millisecond)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *pooler) levels() {
|
||||||
|
_levelCache = newLevelCache(p.k)
|
||||||
|
|
||||||
|
for p.run {
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
time.Sleep(33 * time.Millisecond)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
package voicemeeter
|
package voicemeeter
|
||||||
|
|
||||||
|
// recorder represents the recorder
|
||||||
type recorder struct {
|
type recorder struct {
|
||||||
iRemote
|
iRemote
|
||||||
outputs
|
outputs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// newRecorder returns an address to a recorder struct
|
||||||
func newRecorder() *recorder {
|
func newRecorder() *recorder {
|
||||||
o := newOutputs("recorder", 0)
|
o := newOutputs("recorder", 0)
|
||||||
return &recorder{iRemote{"recorder", 0}, o}
|
return &recorder{iRemote{"recorder", 0}, o}
|
||||||
@@ -2,75 +2,108 @@ 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
|
||||||
// comprised of slices representing each member
|
type Remote struct {
|
||||||
type remote struct {
|
Kind *kind
|
||||||
kind *kind
|
Strip []iStrip
|
||||||
Strip []t_strip
|
Bus []iBus
|
||||||
Bus []t_bus
|
|
||||||
Button []button
|
Button []button
|
||||||
Command *command
|
Command *command
|
||||||
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() {
|
||||||
r.pooler = newPooler()
|
login(r.Kind.Name)
|
||||||
login(r.kind.name)
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *remote) Type() string {
|
// Type returns the type of Voicemeeter (basic, banana, potato)
|
||||||
|
func (r *Remote) Type() string {
|
||||||
return getVMType()
|
return getVMType()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *remote) Version() string {
|
// Version returns the version of Voicemeeter as a string
|
||||||
|
func (r *Remote) Version() string {
|
||||||
return getVersion()
|
return getVersion()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pdirty returns true iff a parameter value has changed
|
// Pdirty returns true iff a parameter value has changed
|
||||||
func (r *remote) Pdirty() bool {
|
func (r *Remote) Pdirty() bool {
|
||||||
return pdirty()
|
return pdirty()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mdirty returns true iff a macrobutton value has changed
|
// Mdirty returns true iff a macrobutton value has changed
|
||||||
func (r *remote) Mdirty() bool {
|
func (r *Remote) Mdirty() bool {
|
||||||
return mdirty()
|
return mdirty()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *remote) SendText(script string) {
|
// 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)
|
setParametersMulti(script)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register forwards the register method to Pooler
|
// Register forwards the register method to Pooler
|
||||||
func (r *remote) Register(o observer) {
|
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
|
||||||
@@ -80,8 +113,9 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
// directory is responsible for directing the genericBuilder
|
// directory is responsible for directing the genericBuilder
|
||||||
@@ -100,27 +134,29 @@ func (d *director) Construct() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get forwards the Get method to the builder
|
// Get forwards the Get method to the builder
|
||||||
func (d *director) Get() *remote {
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeStrip makes a strip slice and assigns it to remote.Strip
|
// makeStrip makes a strip slice and assigns it to remote.Strip
|
||||||
// []t_strip 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([]t_strip, 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)
|
||||||
@@ -134,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([]t_bus, 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)
|
||||||
@@ -157,85 +193,117 @@ func (b *genericBuilder) makeButton() remoteBuilder {
|
|||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeCommand makes a Command type and assigns it to remote.Command
|
// makeCommand makes a command type and assigns it to remote.Command
|
||||||
func (b *genericBuilder) makeCommand() remoteBuilder {
|
func (b *genericBuilder) makeCommand() remoteBuilder {
|
||||||
fmt.Println("building command")
|
fmt.Println("building command")
|
||||||
b.r.Command = newCommand()
|
b.r.Command = newCommand()
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeVban makes a Vban type and assigns it to remote.Vban
|
// makeVban makes a vban type and assigns it to remote.Vban
|
||||||
func (b *genericBuilder) makeVban() remoteBuilder {
|
func (b *genericBuilder) makeVban() remoteBuilder {
|
||||||
fmt.Println("building vban")
|
fmt.Println("building vban")
|
||||||
b.r.Vban = newVban(b.k)
|
b.r.Vban = newVban(b.k)
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeVban makes a Vban type and assigns it to remote.Vban
|
// makeDevice makes a device type and assigns it to remote.Device
|
||||||
func (b *genericBuilder) makeDevice() remoteBuilder {
|
func (b *genericBuilder) makeDevice() remoteBuilder {
|
||||||
fmt.Println("building device")
|
fmt.Println("building device")
|
||||||
b.r.Device = newDevice()
|
b.r.Device = newDevice()
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeRecorder makes a recorder type and assigns it to remote.Vban
|
// makeRecorder makes a recorder type and assigns it to remote.Recorder
|
||||||
func (b *genericBuilder) makeRecorder() remoteBuilder {
|
func (b *genericBuilder) makeRecorder() remoteBuilder {
|
||||||
fmt.Println("building recorder")
|
fmt.Println("building recorder")
|
||||||
b.r.Recorder = newRecorder()
|
b.r.Recorder = newRecorder()
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// makeMidi makes a midi type and assigns it to remote.Midi
|
||||||
|
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()
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRemote 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 GetRemote(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":
|
||||||
director.SetBuilder(&bananaBuilder{genericBuilder{_kind, remote{}}})
|
director.SetBuilder(&bananaBuilder{genericBuilder{_kind, Remote{}}})
|
||||||
case "potato":
|
case "potato":
|
||||||
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 := GetRemote("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 := GetRemote("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 := GetRemote("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))
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -2,9 +2,11 @@ package voicemeeter
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type t_strip interface {
|
// iStrip defines the interface bus types must satisfy
|
||||||
|
type iStrip interface {
|
||||||
String() string
|
String() string
|
||||||
GetMute() bool
|
GetMute() bool
|
||||||
SetMute(val bool)
|
SetMute(val bool)
|
||||||
@@ -28,7 +30,11 @@ type t_strip interface {
|
|||||||
SetAudibility(val float32)
|
SetAudibility(val float32)
|
||||||
GainLayer() []gainLayer
|
GainLayer() []gainLayer
|
||||||
Levels() *levels
|
Levels() *levels
|
||||||
t_outputs
|
FadeTo(target float32, time_ int)
|
||||||
|
FadeBy(change float32, time_ int)
|
||||||
|
AppGain(name string, gain float32)
|
||||||
|
AppMute(name string, val bool)
|
||||||
|
iOutputs
|
||||||
}
|
}
|
||||||
|
|
||||||
// strip represents a strip channel
|
// strip represents a strip channel
|
||||||
@@ -104,16 +110,30 @@ func (s *strip) GainLayer() []gainLayer {
|
|||||||
return s.gainLayer
|
return s.gainLayer
|
||||||
}
|
}
|
||||||
|
|
||||||
// Levels returns the gainlayer field
|
// Levels returns the levels field
|
||||||
func (s *strip) Levels() *levels {
|
func (s *strip) Levels() *levels {
|
||||||
return &s.levels
|
return &s.levels
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FadeTo sets the value of gain to target over at time interval of time_
|
||||||
|
func (s *strip) FadeTo(target float32, time_ int) {
|
||||||
|
s.setter_string("FadeTo", fmt.Sprintf("(\"%f\", %d)", target, time_))
|
||||||
|
time.Sleep(time.Millisecond)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FadeBy adjusts the value of gain by change over a time interval of time_
|
||||||
|
func (s *strip) FadeBy(change float32, time_ int) {
|
||||||
|
s.setter_string("FadeBy", fmt.Sprintf("(\"%f\", %d)", change, time_))
|
||||||
|
time.Sleep(time.Millisecond)
|
||||||
|
}
|
||||||
|
|
||||||
|
//physicalStrip represents a single physical strip
|
||||||
type physicalStrip struct {
|
type physicalStrip struct {
|
||||||
strip
|
strip
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPhysicalStrip(i int, k *kind) t_strip {
|
// newPhysicalStrip returns a physicalStrip type cast to an iStrip
|
||||||
|
func newPhysicalStrip(i int, k *kind) iStrip {
|
||||||
o := newOutputs(fmt.Sprintf("strip[%d]", i), i)
|
o := newOutputs(fmt.Sprintf("strip[%d]", i), i)
|
||||||
gl := make([]gainLayer, 8)
|
gl := make([]gainLayer, 8)
|
||||||
for j := 0; j < 8; j++ {
|
for j := 0; j < 8; j++ {
|
||||||
@@ -121,10 +141,10 @@ func newPhysicalStrip(i int, k *kind) t_strip {
|
|||||||
}
|
}
|
||||||
l := newStripLevels(i, k)
|
l := newStripLevels(i, k)
|
||||||
ps := physicalStrip{strip{iRemote{fmt.Sprintf("strip[%d]", i), i}, o, gl, l}}
|
ps := physicalStrip{strip{iRemote{fmt.Sprintf("strip[%d]", i), i}, o, gl, l}}
|
||||||
return t_strip(&ps)
|
return iStrip(&ps)
|
||||||
}
|
}
|
||||||
|
|
||||||
// implement fmt.stringer interface in fmt
|
// String implements fmt.stringer interface
|
||||||
func (p *physicalStrip) String() string {
|
func (p *physicalStrip) String() string {
|
||||||
return fmt.Sprintf("PhysicalStrip%d", p.index)
|
return fmt.Sprintf("PhysicalStrip%d", p.index)
|
||||||
}
|
}
|
||||||
@@ -169,11 +189,13 @@ func (p *physicalStrip) SetMc(val bool) {
|
|||||||
panic("invalid parameter MC for physicalStrip")
|
panic("invalid parameter MC for physicalStrip")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//virtualStrip represents a single virtual strip
|
||||||
type virtualStrip struct {
|
type virtualStrip struct {
|
||||||
strip
|
strip
|
||||||
}
|
}
|
||||||
|
|
||||||
func newVirtualStrip(i int, k *kind) t_strip {
|
// newVirtualStrip returns a virtualStrip type cast to an iStrip
|
||||||
|
func newVirtualStrip(i int, k *kind) iStrip {
|
||||||
o := newOutputs(fmt.Sprintf("strip[%d]", i), i)
|
o := newOutputs(fmt.Sprintf("strip[%d]", i), i)
|
||||||
gl := make([]gainLayer, 8)
|
gl := make([]gainLayer, 8)
|
||||||
for j := 0; j < 8; j++ {
|
for j := 0; j < 8; j++ {
|
||||||
@@ -181,10 +203,10 @@ func newVirtualStrip(i int, k *kind) t_strip {
|
|||||||
}
|
}
|
||||||
l := newStripLevels(i, k)
|
l := newStripLevels(i, k)
|
||||||
vs := virtualStrip{strip{iRemote{fmt.Sprintf("strip[%d]", i), i}, o, gl, l}}
|
vs := virtualStrip{strip{iRemote{fmt.Sprintf("strip[%d]", i), i}, o, gl, l}}
|
||||||
return t_strip(&vs)
|
return iStrip(&vs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// implement fmt.stringer interface in fmt
|
// String implements fmt.stringer interface
|
||||||
func (v *virtualStrip) String() string {
|
func (v *virtualStrip) String() string {
|
||||||
return fmt.Sprintf("VirtualStrip%d", v.index)
|
return fmt.Sprintf("VirtualStrip%d", v.index)
|
||||||
}
|
}
|
||||||
@@ -229,56 +251,83 @@ func (v *virtualStrip) SetAudibility(val float32) {
|
|||||||
panic("invalid parameter Audibility for virtualStrip")
|
panic("invalid parameter Audibility for virtualStrip")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AppGain sets the gain in db by val for the app matching name.
|
||||||
|
func (v *strip) AppGain(name string, val float32) {
|
||||||
|
v.setter_string("AppGain", fmt.Sprintf("(\"%s\", %f)", name, val))
|
||||||
|
}
|
||||||
|
|
||||||
|
// AppMute sets mute state as val for the app matching name.
|
||||||
|
func (v *strip) AppMute(name string, val bool) {
|
||||||
|
var value int
|
||||||
|
if val {
|
||||||
|
value = 1
|
||||||
|
} else {
|
||||||
|
value = 0
|
||||||
|
}
|
||||||
|
v.setter_string("AppMute", fmt.Sprintf("(\"%s\", %f)", name, float32(value)))
|
||||||
|
}
|
||||||
|
|
||||||
|
// gainLayer represents the 8 gainlayers for a single strip
|
||||||
type gainLayer struct {
|
type gainLayer struct {
|
||||||
iRemote
|
iRemote
|
||||||
index int
|
index int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// newGainLayer returns a gainlayer struct
|
||||||
func newGainLayer(i, j int) gainLayer {
|
func newGainLayer(i, j int) gainLayer {
|
||||||
return gainLayer{iRemote{fmt.Sprintf("strip[%d]", i), i}, j}
|
return gainLayer{iRemote{fmt.Sprintf("strip[%d]", i), i}, j}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get gets the gain value for a single gainlayer
|
||||||
func (gl *gainLayer) Get() float64 {
|
func (gl *gainLayer) Get() float64 {
|
||||||
return gl.getter_float(fmt.Sprintf("gainlayer[%d]", gl.index))
|
return gl.getter_float(fmt.Sprintf("gainlayer[%d]", gl.index))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set sets the gain value for a single gainlayer
|
||||||
func (gl *gainLayer) Set(val float32) {
|
func (gl *gainLayer) Set(val float32) {
|
||||||
gl.setter_float(fmt.Sprintf("gainlayer[%d]", gl.index), val)
|
gl.setter_float(fmt.Sprintf("gainlayer[%d]", gl.index), val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// newStripLevels returns a levels struct
|
||||||
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}
|
return levels{iRemote{fmt.Sprintf("strip[%d]", i), i}, k, init, os, "strip"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PreFader returns the level values for this strip, PREFADER mode
|
||||||
func (l *levels) PreFader() []float32 {
|
func (l *levels) PreFader() []float32 {
|
||||||
|
_levelCache.stripMode = 0
|
||||||
var levels []float32
|
var levels []float32
|
||||||
for i := l.init; i < l.init+l.offset; i++ {
|
for i := l.init; i < l.init+l.offset; i++ {
|
||||||
levels = append(levels, l.convertLevel(getLevel(0, i)))
|
levels = append(levels, convertLevel(_levelCache.stripLevels[i]))
|
||||||
}
|
}
|
||||||
return levels
|
return levels
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PostFader returns the level values for this strip, POSTFADER mode
|
||||||
func (l *levels) PostFader() []float32 {
|
func (l *levels) PostFader() []float32 {
|
||||||
|
_levelCache.stripMode = 1
|
||||||
var levels []float32
|
var levels []float32
|
||||||
for i := l.init; i < l.init+l.offset; i++ {
|
for i := l.init; i < l.init+l.offset; i++ {
|
||||||
levels = append(levels, l.convertLevel(getLevel(1, i)))
|
levels = append(levels, convertLevel(_levelCache.stripLevels[i]))
|
||||||
}
|
}
|
||||||
return levels
|
return levels
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PostMute returns the level values for this strip, POSTMUTE mode
|
||||||
func (l *levels) PostMute() []float32 {
|
func (l *levels) PostMute() []float32 {
|
||||||
|
_levelCache.stripMode = 2
|
||||||
var levels []float32
|
var levels []float32
|
||||||
for i := l.init; i < l.init+l.offset; i++ {
|
for i := l.init; i < l.init+l.offset; i++ {
|
||||||
levels = append(levels, l.convertLevel(getLevel(2, i)))
|
levels = append(levels, convertLevel(_levelCache.stripLevels[i]))
|
||||||
}
|
}
|
||||||
return levels
|
return levels
|
||||||
}
|
}
|
||||||
@@ -1,26 +1,33 @@
|
|||||||
package voicemeeter_test
|
package voicemeeter_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/onyx-and-iris/voicemeeter-api-go/voicemeeter"
|
"github.com/onyx-and-iris/voicemeeter-api-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
vmRem = voicemeeter.GetRemote("potato")
|
vm, err = voicemeeter.NewRemote("potato")
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
vmRem.Login()
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
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)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Function RunTests {
|
Function RunTests {
|
||||||
|
$run_int_tests = "go clean -testcache; go test -v ."
|
||||||
$run_ext_tests = "go clean -testcache; go test -v .\tests\"
|
$run_ext_tests = "go clean -testcache; go test -v .\tests\"
|
||||||
$run_int_tests = "go clean -testcache; go test -v .\voicemeeter\"
|
|
||||||
|
|
||||||
Invoke-Expression $run_ext_tests
|
Invoke-Expression $run_ext_tests
|
||||||
Invoke-Expression $run_int_tests
|
Invoke-Expression $run_int_tests
|
||||||
|
|||||||
35
util.go
Normal file
35
util.go
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
package voicemeeter
|
||||||
|
|
||||||
|
import "math"
|
||||||
|
|
||||||
|
// allTrue accepts a boolean slice and evaluates if all elements are True
|
||||||
|
func allTrue(s []bool, sz int) bool {
|
||||||
|
for i := 0; i < sz; i++ {
|
||||||
|
if !s[i] {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// update copies the contents of one float slice into another
|
||||||
|
func update(s1 []float32, s2 []float32, sz int) {
|
||||||
|
for i := 0; i < sz; i++ {
|
||||||
|
s1[i] = s2[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// roundFloat rounds a float value to a given precision
|
||||||
|
func roundFloat(val float64, precision uint) float64 {
|
||||||
|
ratio := math.Pow(10, float64(precision))
|
||||||
|
return math.Round(val*ratio) / ratio
|
||||||
|
}
|
||||||
|
|
||||||
|
// convertLevel performs the necessary math for a channel level
|
||||||
|
func convertLevel(i float32) float32 {
|
||||||
|
if i > 0 {
|
||||||
|
val := 20 * math.Log10(float64(i))
|
||||||
|
return float32(roundFloat(float64(val), 1))
|
||||||
|
}
|
||||||
|
return -200.0
|
||||||
|
}
|
||||||
41
util_test.go
Normal file
41
util_test.go
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
package voicemeeter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestAllTrue(t *testing.T) {
|
||||||
|
//t.Skip("skipping test")
|
||||||
|
s := []bool{true, true, true, true, true, true}
|
||||||
|
t.Run("Should return true", func(t *testing.T) {
|
||||||
|
assert.True(t, allTrue(s, len(s)))
|
||||||
|
})
|
||||||
|
s = []bool{true, true, true, true, false, true}
|
||||||
|
t.Run("Should return false", func(t *testing.T) {
|
||||||
|
assert.False(t, allTrue(s, len(s)))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUpdate(t *testing.T) {
|
||||||
|
//t.Skip("skipping test")
|
||||||
|
s1 := []float32{3.6, 8.7, 1.8, 18.2}
|
||||||
|
s2 := make([]float32, len(s1))
|
||||||
|
update(s2, s1, len(s1))
|
||||||
|
t.Run("Should return true", func(t *testing.T) {
|
||||||
|
assert.Equal(t, s1, s2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestConvertLevel(t *testing.T) {
|
||||||
|
//t.Skip("skipping test")
|
||||||
|
res := convertLevel(0.02)
|
||||||
|
t.Run("Should be equal", func(t *testing.T) {
|
||||||
|
assert.Equal(t, float32(-34), res)
|
||||||
|
})
|
||||||
|
res = convertLevel(-0.02)
|
||||||
|
t.Run("Should be equal", func(t *testing.T) {
|
||||||
|
assert.Equal(t, float32(-200), res)
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -2,7 +2,8 @@ package voicemeeter
|
|||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
type t_vban interface {
|
// iVban defines the interface vban types must satisfy
|
||||||
|
type iVban interface {
|
||||||
GetOn() bool
|
GetOn() bool
|
||||||
SetOn(val bool)
|
SetOn(val bool)
|
||||||
GetName() string
|
GetName() string
|
||||||
@@ -133,9 +134,9 @@ type vbanInStream struct {
|
|||||||
vbanStream
|
vbanStream
|
||||||
}
|
}
|
||||||
|
|
||||||
func newVbanInStream(i int) t_vban {
|
func newVbanInStream(i int) iVban {
|
||||||
vbi := vbanInStream{vbanStream{iRemote{fmt.Sprintf("vban.instream[%d]", i), i}}}
|
vbi := vbanInStream{vbanStream{iRemote{fmt.Sprintf("vban.instream[%d]", i), i}}}
|
||||||
return t_vban(&vbi)
|
return iVban(&vbi)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetSr panics reason read only
|
// SetSr panics reason read only
|
||||||
@@ -157,23 +158,23 @@ type vbanOutStream struct {
|
|||||||
vbanStream
|
vbanStream
|
||||||
}
|
}
|
||||||
|
|
||||||
func newVbanOutStream(i int) t_vban {
|
func newVbanOutStream(i int) iVban {
|
||||||
vbo := vbanOutStream{vbanStream{iRemote{fmt.Sprintf("vban.outstream[%d]", i), i}}}
|
vbo := vbanOutStream{vbanStream{iRemote{fmt.Sprintf("vban.outstream[%d]", i), i}}}
|
||||||
return t_vban(&vbo)
|
return iVban(&vbo)
|
||||||
}
|
}
|
||||||
|
|
||||||
type vban struct {
|
type vban struct {
|
||||||
InStream []t_vban
|
InStream []iVban
|
||||||
OutStream []t_vban
|
OutStream []iVban
|
||||||
}
|
}
|
||||||
|
|
||||||
func newVban(k *kind) *vban {
|
func newVban(k *kind) *vban {
|
||||||
_vbanIn := make([]t_vban, 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([]t_vban, 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{
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
package voicemeeter
|
|
||||||
|
|
||||||
import (
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// observer defines the interface any registered observers must satisfy
|
|
||||||
type observer interface {
|
|
||||||
OnUpdate(subject string)
|
|
||||||
}
|
|
||||||
|
|
||||||
// publisher defines methods that support observers
|
|
||||||
type publisher struct {
|
|
||||||
observerList []observer
|
|
||||||
}
|
|
||||||
|
|
||||||
// Register adds an observer to observerList
|
|
||||||
func (p *publisher) Register(o observer) {
|
|
||||||
p.observerList = append(p.observerList, o)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deregister removes an observer from observerList
|
|
||||||
func (p *publisher) Deregister(o observer) {
|
|
||||||
var indexToRemove int
|
|
||||||
|
|
||||||
for i, observer := range p.observerList {
|
|
||||||
if observer == o {
|
|
||||||
indexToRemove = i
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
p.observerList = append(p.observerList[:indexToRemove], p.observerList[indexToRemove+1:]...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// notify updates observers of any changes
|
|
||||||
func (p *publisher) notify(subject string) {
|
|
||||||
for _, observer := range p.observerList {
|
|
||||||
observer.OnUpdate(subject)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// pooler continuously polls the dirty paramters
|
|
||||||
// it is expected to be run in a goroutine
|
|
||||||
type pooler struct {
|
|
||||||
run bool
|
|
||||||
publisher
|
|
||||||
}
|
|
||||||
|
|
||||||
func newPooler() *pooler {
|
|
||||||
p := &pooler{
|
|
||||||
run: true,
|
|
||||||
}
|
|
||||||
go p.runner()
|
|
||||||
return p
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *pooler) runner() {
|
|
||||||
for p.run {
|
|
||||||
if pdirty() {
|
|
||||||
p.notify("pdirty")
|
|
||||||
}
|
|
||||||
if mdirty() {
|
|
||||||
p.notify("mdirty")
|
|
||||||
}
|
|
||||||
time.Sleep(33 * time.Millisecond)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user