voicemeeter/README.md

500 lines
9.0 KiB
Markdown
Raw Permalink Normal View History

[![Go Reference](https://pkg.go.dev/badge/github.com/onyx-and-iris/voicemeeter.svg)](https://pkg.go.dev/github.com/onyx-and-iris/voicemeeter)
2022-06-23 10:45:26 +01:00
# 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.0.8.4
- Banana 2.0.6.4
- Potato 3.0.2.4
## Requirements
- [Voicemeeter](https://voicemeeter.com/)
- Go 1.18 or greater
## Installation
2022-09-29 18:04:13 +01:00
Initialize your own module then `go get`
```
go mod init github.com/x/y
go get github.com/onyx-and-iris/voicemeeter
```
## `Use`
#### `main.go`
```go
package main
import (
"fmt"
"log"
"github.com/onyx-and-iris/voicemeeter"
)
func main() {
2022-09-18 05:36:24 +01:00
vm, err := vmConnect()
if err != nil {
log.Fatal(err)
}
defer vm.Logout()
vm.Strip[0].SetLabel("rode podmic")
vm.Strip[0].SetMute(true)
fmt.Printf("Strip 0 (%s) mute was set to %v\n", vm.Strip[0].GetLabel(), vm.Strip[0].GetMute())
}
2022-09-18 05:36:24 +01:00
func vmConnect() (*voicemeeter.Remote, error) {
2022-09-29 18:04:13 +01:00
vm, err := voicemeeter.NewRemote("banana", 20)
2022-09-18 05:36:24 +01:00
if err != nil {
return nil, err
}
err = vm.Login()
if err != nil {
return nil, err
}
return vm, nil
}
```
2022-09-14 16:11:34 +01:00
## `voicemeeter.NewRemote(<kindId>, <delay>)`
### `kindId`
Pass the kind of Voicemeeter as an argument. kindId may be:
- `basic`
- `banana`
- `potato`
### `delay`
Pass a delay in milliseconds to force the getters to wait for dirty parameters to clear.
Useful if not running callbacks.
## `Remote Type`
2022-07-01 01:41:43 +01:00
#### `vm.Strip`
2022-07-01 01:41:43 +01:00
[]t_strip slice containing both physicalStrip and virtualStrip types
2022-07-01 01:41:43 +01:00
#### `vm.Bus`
2022-07-01 01:41:43 +01:00
[]t_bus slice containing both physicalBus and virtualBus types
2022-07-01 01:41:43 +01:00
#### `vm.Button`
2022-07-01 01:41:43 +01:00
[]button slice containing button types, one for each macrobutton
2022-07-01 01:41:43 +01:00
#### `vm.Command`
2022-07-01 01:41:43 +01:00
pointer to command type, represents action type functions
2022-07-01 01:41:43 +01:00
#### `vm.Vban`
2022-07-01 01:41:43 +01:00
pointer to vban type, containing both vbanInStream and vbanOutStream slices
2022-07-01 01:41:43 +01:00
#### `vm.Device`
2022-07-01 01:41:43 +01:00
pointer to device type, represents physical input/output hardware devices
2022-07-01 01:41:43 +01:00
#### `vm.Recorder`
2022-07-01 01:41:43 +01:00
pointer to recorder type, represents the recorder
#### `vm.Midi`
pointer to midi type, represents a connected midi device
#### `vm.Type()`
2022-07-01 01:41:43 +01:00
returns the type of Voicemeeter as a string
2022-07-01 01:41:43 +01:00
#### `vm.Version()`
2022-07-01 01:41:43 +01:00
returns the version of Voicemeeter as a string
2022-07-01 01:41:43 +01:00
#### `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>)`
2022-07-01 01:41:43 +01:00
sets many parameters in script format eg. ("Strip[0].Mute=1;Bus[3].Gain=3.6")
2022-07-01 01:41:43 +01:00
#### `vm.Register(o observer)`
2022-07-01 01:41:43 +01:00
register an object as an observer
2022-07-01 01:41:43 +01:00
#### `vm.Deregister(o observer)`
2022-07-01 01:41:43 +01:00
deregister an object as an observer
2022-07-01 01:41:43 +01:00
#### `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()`
2022-07-01 01:41:43 +01:00
returns True iff a GUI parameter has changed
2022-07-01 01:41:43 +01:00
#### `vm.Mdirty()`
2022-07-01 01:41:43 +01:00
returns True iff a macrobutton parameter has changed
#### `vm.Sync()`
2022-09-14 16:11:34 +01:00
Use this to force dirty parameters to clear after a delay in milliseconds.
## `Available commands`
### Strip
The following methods are available
2022-07-01 01:41:43 +01:00
- `GetMute() bool`
- `SetMute(val bool)`
- `GetMono() bool`
- `SetMono(val bool)`
- `GetSolo() bool`
- `SetSolo(val bool)`
- `GetLimit() int`
- `SetLimit(val int)` from -40 to 12
- `GetLabel() string`
- `SetLabel(val string)`
- `GetGain() float64`
- `SetGain(val float64)` from -60.0 to 12.0
2022-07-01 01:41:43 +01:00
- `GetMc() bool`
- `SetMc(val bool)`
- `GetComp() float64`
- `SetComp(val float64)` from 0.0 to 10.0
2022-07-01 01:41:43 +01:00
- `GetGate() float64`
- `SetGate(val float64)` from 0.0 to 10.0
2022-07-01 01:41:43 +01:00
- `GetAudibility() float64`
- `SetAudibility(val float64)` from 0.0 to 10.0
- `GetA1() bool - GetA5() bool`
- `SetA1(val bool) - SetA5(val bool)`
2022-09-17 03:47:54 +01:00
- `AppGain(name string, gain float64)`
- `AppMute(name string, val bool)`
example:
```go
vm.Strip[3].SetGain(3.7)
fmt.Println(vm.Strip[0].GetLabel())
vm.Strip[4].SetA1(true)
2022-09-17 03:47:54 +01:00
vm.Strip[5].AppGain("Spotify", 0.5)
vm.Strip[5].AppMute("Spotify", true)
```
##### Gainlayers
- `vm.Strip[i].GainLayer()[j]`
The following methods are available
- `Get() float64`
- `Set(val float64)`
example:
```go
vm.Strip[6].GainLayer()[3].Set(-13.6)
```
##### Levels
- `vm.Strip[i].Levels()`
The following methods are available
- `PreFader() []float64`
- `PostFader() []float64`
- `PostMute() []float64`
example:
```go
fmt.Println(vm.Strip[5].Levels().PreFader())
```
2022-06-30 23:09:45 +01:00
### Bus
The following methods are available
2022-06-30 23:09:45 +01:00
2022-07-01 01:41:43 +01:00
- `String() string`
- `GetMute() bool`
- `SetMute(val bool)`
- `GetEq() bool`
- `SetEq(val bool)`
- `GetMono() bool`
- `SetMono(val bool)`
- `GetLabel() string`
- `SetLabel(val string)`
- `GetGain() float64`
- `SetGain(val float64)` from -60.0 to 12.0
2022-06-30 23:09:45 +01:00
2022-07-01 01:38:34 +01:00
```go
vm.Bus[3].SetEq(true)
fmt.Println(vm.Bus[0].GetLabel())
2022-07-01 01:38:34 +01:00
```
##### Modes
- `vm.Bus[i].Mode()`
2022-07-01 01:38:34 +01:00
The following methods are available
2022-07-01 01:38:34 +01:00
- `SetNormal(val bool)`
- `GetNormal() bool`
- `SetAmix(val bool)`
- `GetAmix() bool`
- `SetBmix(val bool)`
- `GetBmix() bool`
- `SetRepeat(val bool)`
- `GetRepeat() bool`
- `SetComposite(val bool)`
- `GetComposite() bool`
- `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`
2022-07-01 01:38:34 +01:00
example:
```go
vm.Bus[3].Mode().SetAmix(true)
vm.Bus[4].Mode().SetCenterOnly(true)
```
##### Levels
- `vm.Bus[i].Levels()`
The following methods are available
- `All() []float64`
example:
```go
fmt.Println(vm.Bus[1].Levels().All())
2022-07-01 01:38:34 +01:00
```
2022-09-17 03:47:54 +01:00
### Strip | Bus
The following methods are available.
- `FadeTo(target float64, time_ int)`: float, int
- `FadeBy(change float64, time_ int)`: float, int
Modify gain to or by the selected amount in db over a time interval in ms.
example:
```go
vm.Strip[3].FadeBy(-8.3, 500)
vm.Bus[3].FadeTo(-12.8, 500)
```
2022-06-30 23:09:45 +01:00
### Button
The following methods are available
2022-06-30 23:09:45 +01:00
2022-07-01 01:41:43 +01:00
- `GetState() bool`
- `SetState(val bool)`
- `GetStateOnly() bool`
- `SetStateOnly(val bool)`
- `GetTrigger() bool`
- `SetTrigger(val bool)`
2022-06-30 23:09:45 +01:00
2022-07-01 01:38:34 +01:00
example:
```go
vm.Button[37].SetState(true)
fmt.Println(vm.Button[64].GetStateOnly())
2022-07-01 01:38:34 +01:00
```
2022-06-30 23:09:45 +01:00
### Command
The following methods are available
2022-06-30 23:09:45 +01:00
2022-07-01 01:41:43 +01:00
- `Show()` Show Voicemeeter GUI if it's hidden
- `Hide()` Hide Voicemeeter GUI if it's shown
- `Shutdown()` Shuts down the GUI
- `Restart()` Restart the audio engine
- `Lock(val bool)` Lock the Voicemeeter GUI
2022-07-01 01:38:34 +01:00
example:
```go
vm.Command.Restart()
vm.Command.Show()
2022-07-01 01:38:34 +01:00
```
2022-06-30 23:09:45 +01:00
### VBAN
- `vm.Vban.Enable()` `vm.Vban.Disable()` Turn VBAN on or off
2022-06-30 23:09:45 +01:00
##### Instream | Outstream
- `vm.Vban.InStream` `vm.Vban.OutStream`
2022-06-30 23:09:45 +01:00
The following methods are available
2022-06-30 23:09:45 +01:00
2022-07-01 01:41:43 +01:00
- `GetOn() bool`
- `SetOn(val bool)`
- `GetName() string`
- `SetName(val string)`
- `GetIp() string`
- `SetIp(val string)`
- `GetPort() int`
- `SetPort(val int)` from 1024 to 65535
- `GetSr() int`
- `SetSr(val int)` (11025, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000)
- `GetChannel() int`
- `SetChannel(val int)` from 1 to 8
- `GetBit() int`
- `SetBit(val int)` 16 or 24
- `GetQuality() int`
- `SetQuality(val int)` from 0 to 4
- `GetRoute() int`
- `SetRoute(val int)` from 0 to 8
2022-06-30 23:09:45 +01:00
2022-07-01 01:38:34 +01:00
example:
```go
# turn VBAN on
vm.Vban.Enable()
2022-07-01 01:38:34 +01:00
// turn on vban instream 0
vm.Vban.InStream[0].SetOn(true)
2022-07-01 01:38:34 +01:00
// set bit property for outstream 3 to 24
vm.Vban.OutStream[3].SetBit(24)
2022-07-01 01:38:34 +01:00
```
2022-06-30 23:09:45 +01:00
### Device
The following methods are available
2022-06-30 23:09:45 +01:00
- `Ins()`
- `Outs()`
2022-07-01 01:41:43 +01:00
- `Input(val int)`
- `Output(val int)`
2022-06-30 23:09:45 +01:00
2022-07-01 01:38:34 +01:00
example:
```go
for i := 0; i < int(vm.Device.Ins()); i++ {
fmt.Println(vm.Device.Input(i))
2022-07-01 01:38:34 +01:00
}
```
2022-06-30 23:09:45 +01:00
### Recorder
The following methods are available
2022-06-30 23:09:45 +01:00
2022-07-01 01:41:43 +01:00
- `Play()`
- `Stop()`
- `Pause()`
- `Replay()`
- `Record()`
- `Ff()`
- `Rew()`
2022-07-01 01:38:34 +01:00
example:
```go
vm.Recorder.Play()
vm.Recorder.Stop()
2022-07-01 01:38:34 +01:00
# Enable loop play
vm.Recorder.Loop(true)
2022-07-01 01:38:34 +01:00
# Disable recorder out channel B2
vm.Recorder.SetB2(false)
2022-07-01 01:38:34 +01:00
```
### Midi
The following methods are available
- `Channel()` returns the current midi channel
- `Current()` returns the most recently pressed midi button
- `Get(<button>)` returns the value in cache for the midi button
example:
```go
var current = vm.Midi.Current()
var val = vm.Midi.Get(current)
```
### Events
By default level updates are disabled. Any event may be enabled or disabled. The following events exist:
- `pdirty` parameter updates
- `mdirty` macrobutton updates
- `midi` midi updates
- `ldirty` level updates
example:
```go
vm.EventAdd("ldirty")
vm.EventRemove("pdirty")
```
### Run tests
To run all tests:
```
go test ./...
```
### Official Documentation
- [Voicemeeter Remote C API](https://github.com/onyx-and-iris/Voicemeeter-SDK/blob/main/VoicemeeterRemoteAPI.pdf)