mirror of
https://github.com/onyx-and-iris/voicemeeter.git
synced 2025-04-20 04:03:53 +01:00
Compare commits
No commits in common. "359c2d61b5724c2b6c39c6fbee40f1be71a5fa74" and "07018d17039a22a08de3e57a1f458943b720283c" have entirely different histories.
359c2d61b5
...
07018d1703
145
CHANGELOG.md
145
CHANGELOG.md
@ -9,20 +9,7 @@ Before any major/minor/patch bump all unit tests will be run to verify they pass
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
- [x]
|
||||
|
||||
## [2.1.0] - 2024-07-01
|
||||
|
||||
### Added
|
||||
|
||||
- Added a configurable login timeout in seconds (defaults to 2).
|
||||
- Option function added for overriding the type of Voicemeeter GUI runVoicemeeter() will launch.
|
||||
- Explanation of Option functions added to README.
|
||||
|
||||
### Changed
|
||||
|
||||
- runVoicemeeter() now launches x64 GUIs for all kinds if on a 64 bit system.
|
||||
- this can be overridden to force 32 bit GUI using voicemeeter.WithBits(32) Option function
|
||||
- [x]
|
||||
|
||||
## [2.0.0] - 2022-10-25
|
||||
|
||||
@ -30,150 +17,150 @@ V2 introduces some breaking changes.
|
||||
|
||||
### Changed
|
||||
|
||||
- Removed Get prefix from getters in Bus, Strip, Vban, Button and Output types.
|
||||
- Pooler now communicates event updates over a channel.
|
||||
- strip.comp now references comp struct type. (see readme for changes in setting comp parameters)
|
||||
- strip.gate now references gate struct type. (see readme for changes in setting gate parameters)
|
||||
- strip.eq, bus.eq now reference eQ struct type. (see readme for changes in setting eq parameters)
|
||||
- All examples and tests have been updated to reflect the changes.
|
||||
- Removed Get prefix from getters in Bus, Strip, Vban, Button and Output types.
|
||||
- Pooler now communicates event updates over a channel.
|
||||
- strip.comp now references comp struct type. (see readme for changes in setting comp parameters)
|
||||
- strip.gate now references gate struct type. (see readme for changes in setting gate parameters)
|
||||
- strip.eq, bus.eq now reference eQ struct type. (see readme for changes in setting eq parameters)
|
||||
- All examples and tests have been updated to reflect the changes.
|
||||
|
||||
### Added
|
||||
|
||||
- denoiser type to strip types.
|
||||
- XY parameters added to strip type
|
||||
- extra logging added to getters/setters in iRemote type.
|
||||
- InitPooler to Remote type in case the Pooler needs reinitiating. (perhaps the GUI closed unexpectedly)
|
||||
- denoiser type to strip types.
|
||||
- XY parameters added to strip type
|
||||
- extra logging added to getters/setters in iRemote type.
|
||||
- InitPooler to Remote type in case the Pooler needs reinitiating. (perhaps the GUI closed unexpectedly)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Functions that wrap CAPI calls in base.go now return correct error values.
|
||||
- Functions that wrap CAPI calls in base.go now return correct error values.
|
||||
|
||||
## [1.11.0] - 2022-10-10
|
||||
|
||||
### Fixed
|
||||
|
||||
- type error in getLevel
|
||||
- type error in getLevel
|
||||
|
||||
## [1.8.0] - 2022-09-17
|
||||
|
||||
### Added
|
||||
|
||||
- vm-cli example added + example README
|
||||
- Fade, App methods added to project README
|
||||
- vm-cli example added + example README
|
||||
- Fade, App methods added to project README
|
||||
|
||||
## [1.7.0] - 2022-09-14
|
||||
|
||||
### Added
|
||||
|
||||
- voicemeeter.NewRemote now accepts a delay int argument (milliseconds).
|
||||
- vm.Sync() can now be used to force the dirty parameters to clear.
|
||||
- voicemeeter.NewRemote now accepts a delay int argument (milliseconds).
|
||||
- vm.Sync() can now be used to force the dirty parameters to clear.
|
||||
|
||||
### Changed
|
||||
|
||||
- higher level methods/functions now accept/return float64
|
||||
- tests updated to reflect changes.
|
||||
- higher level methods/functions now accept/return float64
|
||||
- tests updated to reflect changes.
|
||||
|
||||
## [1.5.0] - 2022-09-07
|
||||
|
||||
### Changed
|
||||
|
||||
- changes to error handling.
|
||||
- functions that wrap capi calls now return error types.
|
||||
- higher level functions print error messages
|
||||
- changes to error handling.
|
||||
- functions that wrap capi calls now return error types.
|
||||
- higher level functions print error messages
|
||||
|
||||
## [1.4.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.
|
||||
- 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
|
||||
- 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
|
||||
- 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
|
||||
- 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.
|
||||
- Level updates implemented in Pooler struct. Runs in its own goroutine.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed bug with identifier in outputs struct.
|
||||
- Fixed bug with identifier in outputs struct.
|
||||
|
||||
### Changed
|
||||
|
||||
- Package files moved into root of repository.
|
||||
- Remote struct now exported type
|
||||
- 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
|
||||
- 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
|
||||
- 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
|
||||
- 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
|
||||
- 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
|
||||
- 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
|
||||
- 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
|
||||
|
24
README.md
24
README.md
@ -1,14 +1,16 @@
|
||||
[](https://pkg.go.dev/github.com/onyx-and-iris/voicemeeter/v2)
|
||||
|
||||
# A Go Wrapper for the Voicemeeter API
|
||||
# A Go Wrapper for Voicemeeter API
|
||||
|
||||
This package offers a Go interface for the Voicemeeter Remote C API.
|
||||
|
||||
For an outline of past/future changes refer to: [CHANGELOG](CHANGELOG.md)
|
||||
|
||||
## Tested against
|
||||
|
||||
- Basic 1.1.1.1
|
||||
- Banana 2.1.1.1
|
||||
- Potato 3.1.1.1
|
||||
- Basic 1.0.8.8
|
||||
- Banana 2.0.6.8
|
||||
- Potato 3.0.2.8
|
||||
|
||||
## Requirements
|
||||
|
||||
@ -65,7 +67,7 @@ func vmConnect() (*voicemeeter.Remote, error) {
|
||||
}
|
||||
```
|
||||
|
||||
## `voicemeeter.NewRemote(<kindId>, <delay>, opts ...Option)`
|
||||
## `voicemeeter.NewRemote(<kindId>, <delay>)`
|
||||
|
||||
### `kindId`
|
||||
|
||||
@ -81,18 +83,6 @@ Pass a delay in milliseconds to force the getters to wait for dirty parameters t
|
||||
|
||||
Useful if not listening for event updates.
|
||||
|
||||
### `voicemeeter.WithTimeout(timeout int)`
|
||||
|
||||
Set a login timeout, defaults to 2 seconds. For example to set it to 1s:
|
||||
|
||||
`voicemeeter.NewRemote("banana", 20, voicemeeter.WithTimeout(1))`
|
||||
|
||||
### `voicemeeter.WithBits(bits int)`
|
||||
|
||||
Override the type of Voicemeeter GUI to launch on 64 bit systems. For example, to force 32 bit GUI:
|
||||
|
||||
`voicemeeter.NewRemote("banana", 20, voicemeeter.WithBits(32))`
|
||||
|
||||
## `Remote Type`
|
||||
|
||||
#### `vm.Strip`
|
||||
|
34
base.go
34
base.go
@ -2,10 +2,8 @@ package voicemeeter
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"runtime"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
@ -47,29 +45,16 @@ var (
|
||||
// login logs into the API,
|
||||
// attempts to launch Voicemeeter if it's not running,
|
||||
// initializes dirty parameters.
|
||||
func login(kindId string, timeout, bits int) error {
|
||||
func login(kindId string) error {
|
||||
res, _, _ := vmLogin.Call()
|
||||
if res == 1 {
|
||||
runVoicemeeter(kindId, bits)
|
||||
runVoicemeeter(kindId)
|
||||
time.Sleep(time.Second)
|
||||
} else if res != 0 {
|
||||
err := fmt.Errorf("VBVMR_Login returned %d", res)
|
||||
return err
|
||||
}
|
||||
|
||||
var ver_s string
|
||||
start := time.Now()
|
||||
var err error
|
||||
for time.Since(start).Seconds() < float64(timeout) {
|
||||
time.Sleep(time.Duration(100) * time.Millisecond)
|
||||
if ver_s, err = getVersion(); err == nil {
|
||||
log.Infof("Logged into Voicemeeter %s v%s", kindMap[kindId], ver_s)
|
||||
log.Debugf("Log in time: %.2f", time.Since(start).Seconds())
|
||||
break
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return errors.New("timeout logging into the API")
|
||||
}
|
||||
log.Info("Logged into Voicemeeter ", kindId)
|
||||
clear()
|
||||
return nil
|
||||
}
|
||||
@ -83,22 +68,18 @@ func logout(kindId string) error {
|
||||
err := fmt.Errorf("VBVMR_Logout returned %d", int32(res))
|
||||
return err
|
||||
}
|
||||
log.Infof("Logged out of Voicemeeter %s", kindMap[kindId])
|
||||
log.Info("Logged out of Voicemeeter ", kindId)
|
||||
return nil
|
||||
}
|
||||
|
||||
// runVoicemeeter attempts to launch a Voicemeeter GUI of a kind.
|
||||
func runVoicemeeter(kindId string, bits int) error {
|
||||
func runVoicemeeter(kindId string) error {
|
||||
vals := map[string]uint64{
|
||||
"basic": 1,
|
||||
"banana": 2,
|
||||
"potato": 3,
|
||||
}
|
||||
val := vals[kindId]
|
||||
if strings.Contains(runtime.GOARCH, "64") && bits == 64 {
|
||||
val += 3
|
||||
}
|
||||
res, _, _ := vmRunvm.Call(uintptr(val))
|
||||
res, _, _ := vmRunvm.Call(uintptr(vals[kindId]))
|
||||
if int32(res) != 0 {
|
||||
err := fmt.Errorf("VBVMR_RunVoicemeeter returned %d", int32(res))
|
||||
return err
|
||||
@ -112,7 +93,6 @@ func getVersion() (string, error) {
|
||||
res, _, _ := vmGetvmVersion.Call(uintptr(unsafe.Pointer(&ver)))
|
||||
if int32(res) != 0 {
|
||||
err := fmt.Errorf("VBVMR_GetVoicemeeterVersion returned %d", int32(res))
|
||||
log.Error(err.Error())
|
||||
return "", err
|
||||
}
|
||||
v1 := (ver & 0xFF000000) >> 24
|
||||
|
69
remote.go
69
remote.go
@ -20,9 +20,7 @@ type Remote struct {
|
||||
Recorder *recorder
|
||||
Midi *midi_t
|
||||
|
||||
pooler *pooler
|
||||
timeout int
|
||||
bits int
|
||||
pooler *pooler
|
||||
}
|
||||
|
||||
// String implements the fmt.stringer interface
|
||||
@ -33,7 +31,7 @@ func (r *Remote) String() string {
|
||||
// Login logs into the API
|
||||
// then it intializes the pooler
|
||||
func (r *Remote) Login() error {
|
||||
err := login(r.Kind.Name, r.timeout, r.bits)
|
||||
err := login(r.Kind.Name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -59,10 +57,12 @@ func (r *Remote) InitPooler() {
|
||||
|
||||
// Run launches the Voicemeeter GUI for a kind.
|
||||
func (r *Remote) Run(kindId string) error {
|
||||
err := runVoicemeeter(kindId, r.bits)
|
||||
err := runVoicemeeter(kindId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
time.Sleep(time.Second)
|
||||
clear()
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -173,7 +173,6 @@ type remoteBuilder interface {
|
||||
makeDevice() remoteBuilder
|
||||
makeRecorder() remoteBuilder
|
||||
makeMidi() remoteBuilder
|
||||
setDefaults() remoteBuilder
|
||||
Build() remoteBuilder
|
||||
Get() *Remote
|
||||
}
|
||||
@ -213,7 +212,7 @@ func (b *genericBuilder) setKind() remoteBuilder {
|
||||
// makeStrip makes a strip slice and assigns it to remote.Strip
|
||||
// []iStrip comprises of both physical and virtual strip types
|
||||
func (b *genericBuilder) makeStrip() remoteBuilder {
|
||||
log.Debug("building strip")
|
||||
log.Info("building strip")
|
||||
strip := make([]iStrip, b.k.NumStrip())
|
||||
for i := 0; i < b.k.NumStrip(); i++ {
|
||||
if i < b.k.PhysIn {
|
||||
@ -229,7 +228,7 @@ func (b *genericBuilder) makeStrip() remoteBuilder {
|
||||
// makeBus makes a bus slice and assigns it to remote.Bus
|
||||
// []t_bus comprises of both physical and virtual bus types
|
||||
func (b *genericBuilder) makeBus() remoteBuilder {
|
||||
log.Debug("building bus")
|
||||
log.Info("building bus")
|
||||
bus := make([]iBus, b.k.NumBus())
|
||||
for i := 0; i < b.k.NumBus(); i++ {
|
||||
if i < b.k.PhysOut {
|
||||
@ -244,7 +243,7 @@ func (b *genericBuilder) makeBus() remoteBuilder {
|
||||
|
||||
// makeButton makes a button slice and assigns it to remote.Button
|
||||
func (b *genericBuilder) makeButton() remoteBuilder {
|
||||
log.Debug("building button")
|
||||
log.Info("building button")
|
||||
button := make([]button, 80)
|
||||
for i := 0; i < 80; i++ {
|
||||
button[i] = newButton(i)
|
||||
@ -255,46 +254,39 @@ func (b *genericBuilder) makeButton() remoteBuilder {
|
||||
|
||||
// makeCommand makes a command type and assigns it to remote.Command
|
||||
func (b *genericBuilder) makeCommand() remoteBuilder {
|
||||
log.Debug("building command")
|
||||
log.Info("building command")
|
||||
b.r.Command = newCommand()
|
||||
return b
|
||||
}
|
||||
|
||||
// makeVban makes a vban type and assigns it to remote.Vban
|
||||
func (b *genericBuilder) makeVban() remoteBuilder {
|
||||
log.Debug("building vban")
|
||||
log.Info("building vban")
|
||||
b.r.Vban = newVban(b.k)
|
||||
return b
|
||||
}
|
||||
|
||||
// makeDevice makes a device type and assigns it to remote.Device
|
||||
func (b *genericBuilder) makeDevice() remoteBuilder {
|
||||
log.Debug("building device")
|
||||
log.Info("building device")
|
||||
b.r.Device = newDevice()
|
||||
return b
|
||||
}
|
||||
|
||||
// makeRecorder makes a recorder type and assigns it to remote.Recorder
|
||||
func (b *genericBuilder) makeRecorder() remoteBuilder {
|
||||
log.Debug("building recorder")
|
||||
log.Info("building recorder")
|
||||
b.r.Recorder = newRecorder()
|
||||
return b
|
||||
}
|
||||
|
||||
// makeMidi makes a midi type and assigns it to remote.Midi
|
||||
func (b *genericBuilder) makeMidi() remoteBuilder {
|
||||
log.Debug("building midi")
|
||||
log.Info("building midi")
|
||||
b.r.Midi = newMidi()
|
||||
return b
|
||||
}
|
||||
|
||||
// setDefaults sets defaults for optional members
|
||||
func (b *genericBuilder) setDefaults() remoteBuilder {
|
||||
b.r.bits = 64
|
||||
b.r.timeout = 2
|
||||
return b
|
||||
}
|
||||
|
||||
// Get returns a fully constructed remote type for a kind
|
||||
func (b *genericBuilder) Get() *Remote {
|
||||
return &b.r
|
||||
@ -314,8 +306,7 @@ func (basb *genericBuilder) Build() remoteBuilder {
|
||||
makeCommand().
|
||||
makeVban().
|
||||
makeDevice().
|
||||
makeMidi().
|
||||
setDefaults()
|
||||
makeMidi()
|
||||
}
|
||||
|
||||
// bananaBuilder represents a builder specific to banana type
|
||||
@ -333,8 +324,7 @@ func (banb *bananaBuilder) Build() remoteBuilder {
|
||||
makeVban().
|
||||
makeDevice().
|
||||
makeRecorder().
|
||||
makeMidi().
|
||||
setDefaults()
|
||||
makeMidi()
|
||||
}
|
||||
|
||||
// potatoBuilder represents a builder specific to potato type
|
||||
@ -352,8 +342,7 @@ func (potb *potatoBuilder) Build() remoteBuilder {
|
||||
makeVban().
|
||||
makeDevice().
|
||||
makeRecorder().
|
||||
makeMidi().
|
||||
setDefaults()
|
||||
makeMidi()
|
||||
}
|
||||
|
||||
var (
|
||||
@ -361,22 +350,6 @@ var (
|
||||
vmdelay int
|
||||
)
|
||||
|
||||
type Option func(*Remote)
|
||||
|
||||
func WithTimeout(timeout int) Option {
|
||||
return func(r *Remote) {
|
||||
r.timeout = timeout
|
||||
}
|
||||
}
|
||||
|
||||
func WithBits(bits int) Option {
|
||||
return func(r *Remote) {
|
||||
if bits == 32 || bits == 64 {
|
||||
r.bits = bits
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
log.SetOutput(os.Stdout)
|
||||
log.SetLevel(log.WarnLevel)
|
||||
@ -384,7 +357,7 @@ func init() {
|
||||
|
||||
// NewRemote returns a Remote type for a kind
|
||||
// this is the interface entry point
|
||||
func NewRemote(kindId string, delay int, opts ...Option) (*Remote, error) {
|
||||
func NewRemote(kindId string, delay int) (*Remote, error) {
|
||||
kind, ok := kindMap[kindId]
|
||||
if !ok {
|
||||
err := fmt.Errorf("unknown Voicemeeter kind '%s'", kindId)
|
||||
@ -407,11 +380,5 @@ func NewRemote(kindId string, delay int, opts ...Option) (*Remote, error) {
|
||||
director.SetBuilder(&potatoBuilder{genericBuilder{kind, Remote{}}})
|
||||
}
|
||||
director.Construct()
|
||||
r := director.Get()
|
||||
|
||||
for _, opt := range opts {
|
||||
opt(r)
|
||||
}
|
||||
|
||||
return r, nil
|
||||
return director.Get(), nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user