mirror of
https://github.com/onyx-and-iris/voicemeeter.git
synced 2024-11-21 20:30:55 +00:00
parent
717c738583
commit
2129d44be3
@ -79,7 +79,7 @@ type physicalBus struct {
|
||||
}
|
||||
|
||||
func newPhysicalBus(i int) t_bus {
|
||||
pb := physicalBus{bus{iRemote{"bus", i}}}
|
||||
pb := physicalBus{bus{iRemote{fmt.Sprintf("bus[%d]", i), i}}}
|
||||
return t_bus(&pb)
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ type virtualBus struct {
|
||||
}
|
||||
|
||||
func newVirtualBus(i int) t_bus {
|
||||
vb := virtualBus{bus{iRemote{"bus", i}}}
|
||||
vb := virtualBus{bus{iRemote{fmt.Sprintf("bus[%d]", i), i}}}
|
||||
return t_bus(&vb)
|
||||
}
|
||||
|
||||
|
@ -1,38 +1,31 @@
|
||||
package voicemeeter
|
||||
|
||||
import "fmt"
|
||||
|
||||
type command struct {
|
||||
identifier string
|
||||
iRemote
|
||||
}
|
||||
|
||||
func newCommand() *command {
|
||||
return &command{"command"}
|
||||
}
|
||||
|
||||
func (c *command) setter(p string, v float32) {
|
||||
param := fmt.Sprintf("%s.%s", c.identifier, p)
|
||||
setParameterFloat(param, v)
|
||||
return &command{iRemote{"command", 0}}
|
||||
}
|
||||
|
||||
// Show shows the Voicemeete GUI if it's hidden
|
||||
func (c *command) Show() {
|
||||
c.setter("Show", 1)
|
||||
c.setter_float("Show", 1)
|
||||
}
|
||||
|
||||
// Hide hides the Voicemeete GUI if it's shown
|
||||
func (c *command) Hide() {
|
||||
c.setter("Show", 0)
|
||||
c.setter_float("Show", 0)
|
||||
}
|
||||
|
||||
// Shutdown shutdown the Voicemeeter GUI
|
||||
func (c *command) Shutdown() {
|
||||
c.setter("Shutdown", 1)
|
||||
c.setter_float("Shutdown", 1)
|
||||
}
|
||||
|
||||
// Restart restarts the Voicemeeter audio engine
|
||||
func (c *command) Restart() {
|
||||
c.setter("Restart", 1)
|
||||
c.setter_float("Restart", 1)
|
||||
}
|
||||
|
||||
// Lock locks or unlocks the Voiceemeter GUI
|
||||
@ -44,5 +37,5 @@ func (c *command) Lock(val bool) {
|
||||
} else {
|
||||
value = 0
|
||||
}
|
||||
c.setter("Lock", value)
|
||||
c.setter_float("Lock", value)
|
||||
}
|
||||
|
@ -10,19 +10,19 @@ type iRemote struct {
|
||||
index int
|
||||
}
|
||||
|
||||
func (c *iRemote) identifier() string {
|
||||
return c._identifier
|
||||
func (ir *iRemote) identifier() string {
|
||||
return ir._identifier
|
||||
}
|
||||
|
||||
// getter_bool returns the value of a boolean parameter
|
||||
func (c *iRemote) getter_bool(p string) bool {
|
||||
param := fmt.Sprintf("%s[%d].%s", c.identifier(), c.index, p)
|
||||
func (ir *iRemote) getter_bool(p string) bool {
|
||||
param := fmt.Sprintf("%s.%s", ir.identifier(), p)
|
||||
return getParameterFloat(param) == 1
|
||||
}
|
||||
|
||||
// setter_bool sets the value of a boolean parameter
|
||||
func (c *iRemote) setter_bool(p string, v bool) {
|
||||
param := fmt.Sprintf("%s[%d].%s", c.identifier(), c.index, p)
|
||||
func (ir *iRemote) setter_bool(p string, v bool) {
|
||||
param := fmt.Sprintf("%s.%s", ir.identifier(), p)
|
||||
var value float32
|
||||
if v {
|
||||
value = 1
|
||||
@ -33,37 +33,37 @@ func (c *iRemote) setter_bool(p string, v bool) {
|
||||
}
|
||||
|
||||
// getter_int returns the value of an int parameter p
|
||||
func (c *iRemote) getter_int(p string) int {
|
||||
param := fmt.Sprintf("%s[%d].%s", c.identifier(), c.index, p)
|
||||
func (ir *iRemote) getter_int(p string) int {
|
||||
param := fmt.Sprintf("%s.%s", ir.identifier(), p)
|
||||
return int(getParameterFloat(param))
|
||||
}
|
||||
|
||||
// setter_int sets the value v of an int parameter p
|
||||
func (c *iRemote) setter_int(p string, v int) {
|
||||
param := fmt.Sprintf("%s[%d].%s", c.identifier(), c.index, p)
|
||||
func (ir *iRemote) setter_int(p string, v int) {
|
||||
param := fmt.Sprintf("%s.%s", ir.identifier(), p)
|
||||
setParameterFloat(param, float32(v))
|
||||
}
|
||||
|
||||
// getter_float returns the value of an int parameter p
|
||||
func (c *iRemote) getter_float(p string) float64 {
|
||||
param := fmt.Sprintf("%s[%d].%s", c.identifier(), c.index, p)
|
||||
func (ir *iRemote) getter_float(p string) float64 {
|
||||
param := fmt.Sprintf("%s.%s", ir.identifier(), p)
|
||||
return getParameterFloat(param)
|
||||
}
|
||||
|
||||
// setter_float sets the value v of an int parameter p
|
||||
func (c *iRemote) setter_float(p string, v float32) {
|
||||
param := fmt.Sprintf("%s[%d].%s", c.identifier(), c.index, p)
|
||||
func (ir *iRemote) setter_float(p string, v float32) {
|
||||
param := fmt.Sprintf("%s.%s", ir.identifier(), p)
|
||||
setParameterFloat(param, float32(v))
|
||||
}
|
||||
|
||||
// getter_string returns the value of a string parameter p
|
||||
func (c *iRemote) getter_string(p string) string {
|
||||
param := fmt.Sprintf("%s[%d].%s", c.identifier(), c.index, p)
|
||||
func (ir *iRemote) getter_string(p string) string {
|
||||
param := fmt.Sprintf("%s.%s", ir.identifier(), p)
|
||||
return getParameterString(param)
|
||||
}
|
||||
|
||||
// setter_string sets the value v of a string parameter p
|
||||
func (c *iRemote) setter_string(p, v string) {
|
||||
param := fmt.Sprintf("%s[%d].%s", c.identifier(), c.index, p)
|
||||
func (ir *iRemote) setter_string(p, v string) {
|
||||
param := fmt.Sprintf("%s.%s", ir.identifier(), p)
|
||||
setParameterString(param, v)
|
||||
}
|
||||
|
44
voicemeeter/recorder.go
Normal file
44
voicemeeter/recorder.go
Normal file
@ -0,0 +1,44 @@
|
||||
package voicemeeter
|
||||
|
||||
type recorder struct {
|
||||
iRemote
|
||||
}
|
||||
|
||||
func newRecorder() *recorder {
|
||||
return &recorder{iRemote{"recorder", 0}}
|
||||
}
|
||||
|
||||
// Play plays the file currently loaded into the recorder
|
||||
func (r *recorder) Play() {
|
||||
r.setter_float("Play", 1)
|
||||
}
|
||||
|
||||
// Stop stops the file currently playing
|
||||
func (r *recorder) Stop() {
|
||||
r.setter_float("Stop", 0)
|
||||
}
|
||||
|
||||
// Pause pauses the file currently playing
|
||||
func (r *recorder) Pause() {
|
||||
r.setter_float("Pause", 1)
|
||||
}
|
||||
|
||||
// Restart restarts the Voicemeeter audio engine
|
||||
func (r *recorder) Replay() {
|
||||
r.setter_float("Replay", 1)
|
||||
}
|
||||
|
||||
// Record records the current track playing
|
||||
func (r *recorder) Record() {
|
||||
r.setter_float("Record", 1)
|
||||
}
|
||||
|
||||
// Ff fast forwards the recorder
|
||||
func (r *recorder) Ff() {
|
||||
r.setter_float("Ff", 1)
|
||||
}
|
||||
|
||||
// Rew rewinds the recorder
|
||||
func (r *recorder) Rew() {
|
||||
r.setter_float("Rew", 1)
|
||||
}
|
@ -8,12 +8,13 @@ import (
|
||||
// A remote type represents the API for a kind,
|
||||
// comprised of slices representing each member
|
||||
type remote struct {
|
||||
kind *kind
|
||||
Strip []t_strip
|
||||
Bus []t_bus
|
||||
Button []button
|
||||
Command *command
|
||||
Vban *vban
|
||||
kind *kind
|
||||
Strip []t_strip
|
||||
Bus []t_bus
|
||||
Button []button
|
||||
Command *command
|
||||
Vban *vban
|
||||
Recorder *recorder
|
||||
|
||||
pooler *pooler
|
||||
}
|
||||
@ -66,6 +67,8 @@ type remoteBuilder interface {
|
||||
makeButton() remoteBuilder
|
||||
makeCommand() remoteBuilder
|
||||
makeVban() remoteBuilder
|
||||
makeRecorder() remoteBuilder
|
||||
Build() remoteBuilder
|
||||
Get() *remote
|
||||
}
|
||||
|
||||
@ -79,9 +82,9 @@ func (d *director) SetBuilder(b remoteBuilder) {
|
||||
d.builder = b
|
||||
}
|
||||
|
||||
// Construct defines the steps required for building a remote type
|
||||
// Construct calls the build function for the specific builder
|
||||
func (d *director) Construct() {
|
||||
d.builder.setKind().makeStrip().makeBus().makeButton().makeCommand().makeVban()
|
||||
d.builder.Build()
|
||||
}
|
||||
|
||||
// Get forwards the Get method to the builder
|
||||
@ -156,6 +159,13 @@ func (b *genericBuilder) makeVban() remoteBuilder {
|
||||
return b
|
||||
}
|
||||
|
||||
// makeVban makes a Vban type and assignss it to remote.Vban
|
||||
func (b *genericBuilder) makeRecorder() remoteBuilder {
|
||||
fmt.Println("building recorder")
|
||||
b.r.Recorder = newRecorder()
|
||||
return b
|
||||
}
|
||||
|
||||
// Get returns a fully constructed remote type for a kind
|
||||
func (b *genericBuilder) Get() *remote {
|
||||
return &b.r
|
||||
@ -165,14 +175,29 @@ type basicBuilder struct {
|
||||
genericBuilder
|
||||
}
|
||||
|
||||
// Build defines the steps required to build a basic type
|
||||
func (basb *genericBuilder) Build() remoteBuilder {
|
||||
return basb.setKind().makeStrip().makeBus().makeButton().makeCommand().makeVban()
|
||||
}
|
||||
|
||||
type bananaBuilder struct {
|
||||
genericBuilder
|
||||
}
|
||||
|
||||
// Build defines the steps required to build a banana type
|
||||
func (banb *bananaBuilder) Build() remoteBuilder {
|
||||
return banb.setKind().makeStrip().makeBus().makeButton().makeCommand().makeVban().makeRecorder()
|
||||
}
|
||||
|
||||
type potatoBuilder struct {
|
||||
genericBuilder
|
||||
}
|
||||
|
||||
// Build defines the steps required to build a potato type
|
||||
func (potb *potatoBuilder) Build() remoteBuilder {
|
||||
return potb.setKind().makeStrip().makeBus().makeButton().makeCommand().makeVban().makeRecorder()
|
||||
}
|
||||
|
||||
// GetRemote returns a remote type for a kind
|
||||
// this is the interface entry point
|
||||
func GetRemote(kindId string) *remote {
|
||||
|
@ -21,6 +21,15 @@ func TestGetBasicRemote(t *testing.T) {
|
||||
t.Run("Should bus length equal 2", func(t *testing.T) {
|
||||
assert.Equal(t, 2, len(__rem.Bus))
|
||||
})
|
||||
t.Run("Should return a valid command pointer", func(t *testing.T) {
|
||||
assert.NotNil(t, __rem.Command)
|
||||
})
|
||||
t.Run("Should return a valid vban pointer", func(t *testing.T) {
|
||||
assert.NotNil(t, __rem.Vban)
|
||||
})
|
||||
t.Run("Should return nil recorder pointer", func(t *testing.T) {
|
||||
assert.Nil(t, __rem.Recorder)
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetBananaRemote(t *testing.T) {
|
||||
@ -38,6 +47,15 @@ func TestGetBananaRemote(t *testing.T) {
|
||||
t.Run("Should bus length equal 5", func(t *testing.T) {
|
||||
assert.Equal(t, 5, len(__rem.Bus))
|
||||
})
|
||||
t.Run("Should return a valid command pointer", func(t *testing.T) {
|
||||
assert.NotNil(t, __rem.Command)
|
||||
})
|
||||
t.Run("Should return a valid vban pointer", func(t *testing.T) {
|
||||
assert.NotNil(t, __rem.Vban)
|
||||
})
|
||||
t.Run("Should return a valid recorder", func(t *testing.T) {
|
||||
assert.NotNil(t, __rem.Recorder)
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetPotatoRemote(t *testing.T) {
|
||||
@ -55,4 +73,13 @@ func TestGetPotatoRemote(t *testing.T) {
|
||||
t.Run("Should bus length equal 8", func(t *testing.T) {
|
||||
assert.Equal(t, 8, len(__rem.Bus))
|
||||
})
|
||||
t.Run("Should return a valid command pointer", func(t *testing.T) {
|
||||
assert.NotNil(t, __rem.Command)
|
||||
})
|
||||
t.Run("Should return a valid vban pointer", func(t *testing.T) {
|
||||
assert.NotNil(t, __rem.Vban)
|
||||
})
|
||||
t.Run("Should return a valid recorder", func(t *testing.T) {
|
||||
assert.NotNil(t, __rem.Recorder)
|
||||
})
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ type physicalStrip struct {
|
||||
|
||||
func newPhysicalStrip(i int) t_strip {
|
||||
o := newOutputs("strip", i)
|
||||
ps := physicalStrip{strip{iRemote{"strip", i}, o}}
|
||||
ps := physicalStrip{strip{iRemote{fmt.Sprintf("strip[%d]", i), i}, o}}
|
||||
return t_strip(&ps)
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ type virtualStrip struct {
|
||||
|
||||
func newVirtualStrip(i int) t_strip {
|
||||
o := newOutputs("strip", i)
|
||||
vs := virtualStrip{strip{iRemote{"strip", i}, o}}
|
||||
vs := virtualStrip{strip{iRemote{fmt.Sprintf("strip[%d]", i), i}, o}}
|
||||
return t_strip(&vs)
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package voicemeeter
|
||||
|
||||
import "fmt"
|
||||
|
||||
type t_vban interface {
|
||||
GetOn() bool
|
||||
SetOn(val bool)
|
||||
@ -132,7 +134,7 @@ type vbanInStream struct {
|
||||
}
|
||||
|
||||
func newVbanInStream(i int) t_vban {
|
||||
vbi := vbanInStream{vbanStream{iRemote{"vban.instream", i}}}
|
||||
vbi := vbanInStream{vbanStream{iRemote{fmt.Sprintf("vban.instream[%d]", i), i}}}
|
||||
return t_vban(&vbi)
|
||||
}
|
||||
|
||||
@ -156,7 +158,7 @@ type vbanOutStream struct {
|
||||
}
|
||||
|
||||
func newVbanOutStream(i int) t_vban {
|
||||
vbo := vbanOutStream{vbanStream{iRemote{"vban.outstream", i}}}
|
||||
vbo := vbanOutStream{vbanStream{iRemote{fmt.Sprintf("vban.outstream[%d]", i), i}}}
|
||||
return t_vban(&vbo)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user