2022-06-22 20:51:25 +01:00
|
|
|
package voicemeeter
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2022-07-10 23:08:14 +01:00
|
|
|
"time"
|
2022-06-22 20:51:25 +01:00
|
|
|
)
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// iBus defines the interface bus types must satisfy
|
|
|
|
type iBus interface {
|
2022-06-25 01:18:20 +01:00
|
|
|
String() string
|
2022-12-08 10:23:35 +00:00
|
|
|
Mute() bool
|
2022-06-23 10:42:11 +01:00
|
|
|
SetMute(val bool)
|
2022-12-08 10:23:35 +00:00
|
|
|
Mono() bool
|
2022-06-23 10:42:11 +01:00
|
|
|
SetMono(val bool)
|
2022-12-08 10:23:35 +00:00
|
|
|
Label() string
|
2022-06-23 10:42:11 +01:00
|
|
|
SetLabel(val string)
|
2022-12-08 10:23:35 +00:00
|
|
|
Gain() float64
|
2022-09-14 00:58:05 +01:00
|
|
|
SetGain(val float64)
|
2022-12-08 10:23:35 +00:00
|
|
|
Eq() *eQ
|
|
|
|
Mode() *busMode
|
2022-06-30 20:08:46 +01:00
|
|
|
Levels() *levels
|
2022-07-10 23:08:14 +01:00
|
|
|
FadeTo(target float32, time_ int)
|
|
|
|
FadeBy(change float32, time_ int)
|
2022-06-22 20:51:25 +01:00
|
|
|
}
|
|
|
|
|
2022-06-23 10:42:11 +01:00
|
|
|
// bus represents a bus channel
|
|
|
|
type bus struct {
|
2022-06-23 14:03:00 +01:00
|
|
|
iRemote
|
2022-12-08 10:23:35 +00:00
|
|
|
eQ *eQ
|
|
|
|
mode *busMode
|
2022-06-30 20:08:46 +01:00
|
|
|
levels
|
2022-06-22 20:51:25 +01:00
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// Mute returns the value of the Mute parameter
|
|
|
|
func (b *bus) Mute() bool {
|
2022-06-22 20:51:25 +01:00
|
|
|
return b.getter_bool("Mute")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetMute sets the value of the Mute parameter
|
|
|
|
func (b *bus) SetMute(val bool) {
|
|
|
|
b.setter_bool("Mute", val)
|
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// Mono returns the value of the Mute parameter
|
|
|
|
func (b *bus) Mono() bool {
|
2022-06-23 10:42:11 +01:00
|
|
|
return b.getter_bool("Mono")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetMono sets the value of the Mute parameter
|
|
|
|
func (b *bus) SetMono(val bool) {
|
|
|
|
b.setter_bool("Mono", val)
|
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// Label returns the value of the MC parameter
|
|
|
|
func (b *bus) Label() string {
|
2022-06-23 10:42:11 +01:00
|
|
|
return b.getter_string("Label")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetLabel sets the value of the MC parameter
|
|
|
|
func (b *bus) SetLabel(val string) {
|
|
|
|
b.setter_string("Label", val)
|
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// Gain returns the value of the Gain parameter
|
|
|
|
func (b *bus) Gain() float64 {
|
2022-06-23 10:42:11 +01:00
|
|
|
return b.getter_float("Gain")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetGain sets the value of the Gain parameter
|
2022-09-14 00:58:05 +01:00
|
|
|
func (b *bus) SetGain(val float64) {
|
2022-06-23 10:42:11 +01:00
|
|
|
b.setter_float("Gain", val)
|
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// Eq returns the eQ field
|
|
|
|
func (b *bus) Eq() *eQ {
|
|
|
|
return b.eQ
|
|
|
|
}
|
|
|
|
|
2022-06-28 17:32:03 +01:00
|
|
|
// Mode returns address of a busMode struct
|
2022-12-08 10:23:35 +00:00
|
|
|
func (b *bus) Mode() *busMode {
|
|
|
|
return b.mode
|
2022-06-28 17:32:03 +01:00
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// Levels returns the levels field
|
2022-06-30 20:08:46 +01:00
|
|
|
func (b *bus) Levels() *levels {
|
|
|
|
return &b.levels
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// 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)
|
|
|
|
}
|
|
|
|
|
2022-09-14 00:58:05 +01:00
|
|
|
// physicalBus represents a single physical bus
|
2022-06-23 10:42:11 +01:00
|
|
|
type physicalBus struct {
|
|
|
|
bus
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// newPhysicalBus returns a physicalBus type cast to an iBus
|
|
|
|
func newPhysicalBus(i int, k *kind) iBus {
|
2022-12-08 10:23:35 +00:00
|
|
|
e := newEq(fmt.Sprintf("bus[%d].EQ", i), i)
|
2022-06-30 20:08:46 +01:00
|
|
|
b := newBusMode(i)
|
|
|
|
l := newBusLevels(i, k)
|
2022-12-08 10:23:35 +00:00
|
|
|
pb := physicalBus{bus{iRemote{fmt.Sprintf("bus[%d]", i), i}, e, b, l}}
|
2022-06-30 20:08:46 +01:00
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
return &pb
|
2022-06-23 10:42:11 +01:00
|
|
|
}
|
|
|
|
|
2022-06-26 01:36:32 +01:00
|
|
|
// String implements the fmt.stringer interface
|
2022-06-25 01:18:20 +01:00
|
|
|
func (p *physicalBus) String() string {
|
|
|
|
return fmt.Sprintf("PhysicalBus%d", p.index)
|
|
|
|
}
|
|
|
|
|
2022-09-14 00:58:05 +01:00
|
|
|
// virtualBus represents a single virtual bus
|
2022-06-23 10:42:11 +01:00
|
|
|
type virtualBus struct {
|
|
|
|
bus
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// newVirtualBus returns a virtualBus type cast to an iBus
|
|
|
|
func newVirtualBus(i int, k *kind) iBus {
|
2022-12-08 10:23:35 +00:00
|
|
|
e := newEq(fmt.Sprintf("bus[%d].EQ", i), i)
|
2022-06-30 20:08:46 +01:00
|
|
|
b := newBusMode(i)
|
|
|
|
l := newBusLevels(i, k)
|
2022-12-08 10:23:35 +00:00
|
|
|
vb := virtualBus{bus{iRemote{fmt.Sprintf("bus[%d]", i), i}, e, b, l}}
|
|
|
|
return &vb
|
2022-06-23 10:42:11 +01:00
|
|
|
}
|
2022-06-25 01:18:20 +01:00
|
|
|
|
2022-06-26 01:36:32 +01:00
|
|
|
// String implements the fmt.stringer interface
|
2022-06-25 01:18:20 +01:00
|
|
|
func (v *virtualBus) String() string {
|
|
|
|
return fmt.Sprintf("VirtualBus%d", v.index)
|
|
|
|
}
|
2022-06-28 17:32:03 +01:00
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// busMode offers methods for getting/setting bus mode states
|
2022-06-28 17:32:03 +01:00
|
|
|
type busMode struct {
|
|
|
|
iRemote
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// newBusMode returns a busMode struct
|
2022-12-08 10:23:35 +00:00
|
|
|
func newBusMode(i int) *busMode {
|
|
|
|
return &busMode{iRemote{fmt.Sprintf("bus[%d].mode", i), i}}
|
2022-06-28 19:30:37 +01:00
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// Normal gets the value of the Mode.Normal parameter
|
|
|
|
func (bm *busMode) Normal() bool {
|
2022-06-28 17:32:03 +01:00
|
|
|
return bm.getter_bool("Normal")
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// SetNormal sets the value of the Mode.Normal parameter
|
|
|
|
func (bm *busMode) SetNormal(val bool) {
|
|
|
|
bm.setter_bool("Normal", val)
|
2022-06-28 17:32:03 +01:00
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// Amix gets the value of the Mode.Amix parameter
|
|
|
|
func (bm *busMode) Amix() bool {
|
2022-06-28 17:32:03 +01:00
|
|
|
return bm.getter_bool("Amix")
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// SetAmix sets the value of the Mode.Amix parameter
|
|
|
|
func (bm *busMode) SetAmix(val bool) {
|
|
|
|
bm.setter_bool("Amix", val)
|
2022-06-28 17:32:03 +01:00
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// Bmix gets the value of the Mode.Bmix parameter
|
|
|
|
func (bm *busMode) Bmix() bool {
|
2022-06-28 17:32:03 +01:00
|
|
|
return bm.getter_bool("Bmix")
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// SetBmix sets the value of the Mode.Bmix parameter
|
|
|
|
func (bm *busMode) SetBmix(val bool) {
|
|
|
|
bm.setter_bool("Bmix", val)
|
2022-06-28 17:32:03 +01:00
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// Repeat gets the value of the Mode.Repeat parameter
|
|
|
|
func (bm *busMode) Repeat() bool {
|
2022-06-28 17:32:03 +01:00
|
|
|
return bm.getter_bool("Repeat")
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// SetRepeat sets the value of the Mode.Repeat parameter
|
|
|
|
func (bm *busMode) SetRepeat(val bool) {
|
|
|
|
bm.setter_bool("Repeat", val)
|
2022-06-28 17:32:03 +01:00
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// Composite gets the value of the Mode.Composite parameter
|
|
|
|
func (bm *busMode) Composite() bool {
|
2022-06-28 17:32:03 +01:00
|
|
|
return bm.getter_bool("Composite")
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// SetComposite sets the value of the Mode.Composite parameter
|
|
|
|
func (bm *busMode) SetComposite(val bool) {
|
|
|
|
bm.setter_bool("Composite", val)
|
2022-06-28 17:32:03 +01:00
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// TvMix gets the value of the Mode.TvMix parameter
|
|
|
|
func (bm *busMode) TvMix() bool {
|
2022-06-28 17:32:03 +01:00
|
|
|
return bm.getter_bool("TvMix")
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// SetTvMix sets the value of the Mode.TvMix parameter
|
|
|
|
func (bm *busMode) SetTvMix(val bool) {
|
|
|
|
bm.setter_bool("TvMix", val)
|
2022-06-28 17:32:03 +01:00
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// UpMix21 gets the value of the Mode.UpMix21 parameter
|
|
|
|
func (bm *busMode) UpMix21() bool {
|
2022-06-28 17:32:03 +01:00
|
|
|
return bm.getter_bool("UpMix21")
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// SetUpMix21 sets the value of the Mode.UpMix21 parameter
|
|
|
|
func (bm *busMode) SetUpMix21(val bool) {
|
|
|
|
bm.setter_bool("UpMix21", val)
|
2022-06-28 17:32:03 +01:00
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// UpMix41 gets the value of the Mode.UpMix41 parameter
|
|
|
|
func (bm *busMode) UpMix41() bool {
|
2022-06-28 17:32:03 +01:00
|
|
|
return bm.getter_bool("UpMix41")
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// SetUpMix41 sets the value of the Mode.UpMix41 parameter
|
|
|
|
func (bm *busMode) SetUpMix41(val bool) {
|
|
|
|
bm.setter_bool("UpMix41", val)
|
2022-06-28 17:32:03 +01:00
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// UpMix61 gets the value of the Mode.UpMix61 parameter
|
|
|
|
func (bm *busMode) UpMix61() bool {
|
2022-06-28 17:32:03 +01:00
|
|
|
return bm.getter_bool("UpMix61")
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// SetUpMix61 sets the value of the Mode.UpMix61 parameter
|
|
|
|
func (bm *busMode) SetUpMix61(val bool) {
|
|
|
|
bm.setter_bool("UpMix61", val)
|
2022-06-28 17:32:03 +01:00
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// CenterOnly gets the value of the Mode.CenterOnly parameter
|
|
|
|
func (bm *busMode) CenterOnly() bool {
|
2022-06-28 17:32:03 +01:00
|
|
|
return bm.getter_bool("CenterOnly")
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// SetCenterOnly sets the value of the Mode.CenterOnly parameter
|
|
|
|
func (bm *busMode) SetCenterOnly(val bool) {
|
|
|
|
bm.setter_bool("CenterOnly", val)
|
2022-06-28 17:32:03 +01:00
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// LfeOnly gets the value of the Mode.LFE parameter
|
|
|
|
func (bm *busMode) LfeOnly() bool {
|
2022-06-28 17:32:03 +01:00
|
|
|
return bm.getter_bool("LfeOnly")
|
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// SetLfeOnly sets the value of the Mode.LFE parameter
|
|
|
|
func (bm *busMode) SetLfeOnly(val bool) {
|
|
|
|
bm.setter_bool("LfeOnly", val)
|
2022-06-28 17:32:03 +01:00
|
|
|
}
|
|
|
|
|
2022-12-08 10:23:35 +00:00
|
|
|
// RearOnly gets the value of the Mode.RearOnly parameter
|
|
|
|
func (bm *busMode) RearOnly() bool {
|
2022-06-28 17:32:03 +01:00
|
|
|
return bm.getter_bool("RearOnly")
|
|
|
|
}
|
2022-06-30 20:08:46 +01:00
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// SetRearOnly sets the value of the Mode.RearOnly parameter
|
|
|
|
func (bm *busMode) SetRearOnly(val bool) {
|
|
|
|
bm.setter_bool("RearOnly", val)
|
|
|
|
}
|
|
|
|
|
|
|
|
// newBusLevels represents the levels field for a channel
|
2022-06-30 20:08:46 +01:00
|
|
|
func newBusLevels(i int, k *kind) levels {
|
2022-06-30 23:09:26 +01:00
|
|
|
init := i * 8
|
2022-07-09 19:01:58 +01:00
|
|
|
return levels{iRemote{fmt.Sprintf("bus[%d]", i), i}, k, init, 8, "bus"}
|
2022-06-30 20:08:46 +01:00
|
|
|
}
|
|
|
|
|
2022-07-10 23:08:14 +01:00
|
|
|
// All returns the level values for a bus
|
2022-09-14 00:58:05 +01:00
|
|
|
func (l *levels) All() []float64 {
|
|
|
|
var levels []float64
|
2022-06-30 20:08:46 +01:00
|
|
|
for i := l.init; i < l.init+l.offset; i++ {
|
2022-07-10 23:08:14 +01:00
|
|
|
levels = append(levels, convertLevel(_levelCache.busLevels[i]))
|
2022-06-30 20:08:46 +01:00
|
|
|
}
|
|
|
|
return levels
|
|
|
|
}
|