export PhysicalStrip, VirtualStrip types

export PhysicalBus, VirtualBus types
export VbanInstream, VbanOutStream types

These can now be used by consumer for type assertions.

Strip[i].Denoiser() now references a struct type.
This will be easier to extend if the api changes in future.
This commit is contained in:
onyx-and-iris 2022-12-08 19:44:06 +00:00
parent cd830abb78
commit 95963ead14
3 changed files with 110 additions and 92 deletions

20
bus.go
View File

@ -98,42 +98,42 @@ func (b *bus) FadeBy(change float32, time_ int) {
time.Sleep(time.Millisecond)
}
// physicalBus represents a single physical bus
type physicalBus struct {
// PhysicalBus represents a single physical bus
type PhysicalBus struct {
bus
}
// newPhysicalBus returns a physicalBus type cast to an iBus
// newPhysicalBus returns a PhysicalBus type cast to an iBus
func newPhysicalBus(i int, k *kind) iBus {
e := newEq(fmt.Sprintf("bus[%d].EQ", i), i)
b := newBusMode(i)
l := newBusLevels(i, k)
pb := physicalBus{bus{iRemote{fmt.Sprintf("bus[%d]", i), i}, e, b, l}}
pb := PhysicalBus{bus{iRemote{fmt.Sprintf("bus[%d]", i), i}, e, b, l}}
return &pb
}
// String implements the fmt.stringer interface
func (p *physicalBus) String() string {
func (p *PhysicalBus) String() string {
return fmt.Sprintf("PhysicalBus%d", p.index)
}
// virtualBus represents a single virtual bus
type virtualBus struct {
// VirtualBus represents a single virtual bus
type VirtualBus struct {
bus
}
// newVirtualBus returns a virtualBus type cast to an iBus
// newVirtualBus returns a VirtualBus type cast to an iBus
func newVirtualBus(i int, k *kind) iBus {
e := newEq(fmt.Sprintf("bus[%d].EQ", i), i)
b := newBusMode(i)
l := newBusLevels(i, k)
vb := virtualBus{bus{iRemote{fmt.Sprintf("bus[%d]", i), i}, e, b, l}}
vb := VirtualBus{bus{iRemote{fmt.Sprintf("bus[%d]", i), i}, e, b, l}}
return &vb
}
// String implements the fmt.stringer interface
func (v *virtualBus) String() string {
func (v *VirtualBus) String() string {
return fmt.Sprintf("VirtualBus%d", v.index)
}

126
strip.go
View File

@ -26,8 +26,6 @@ type iStrip interface {
SetMc(val bool)
Audibility() float64
SetAudibility(val float64)
Denoiser() float64
SetDenoiser(val float64)
PanX() float64
SetPanX(val float64)
PanY() float64
@ -47,6 +45,7 @@ type iStrip interface {
Eq() *eQ
Comp() *comp
Gate() *gate
Denoiser() *denoiser
GainLayer() []gainLayer
Levels() *levels
iOutputs
@ -59,6 +58,7 @@ type strip struct {
eQ *eQ
comp *comp
gate *gate
denoiser *denoiser
gainLayer []gainLayer
levels *levels
}
@ -123,16 +123,6 @@ func (s *strip) SetGain(val float64) {
s.setter_float("Gain", val)
}
// Denoiser returns the value of the Denoiser parameter
func (s *strip) Denoiser() float64 {
return s.getter_float("Denoiser")
}
// SetDenoiser sets the value of the Denoiser parameter
func (s *strip) SetDenoiser(val float64) {
s.setter_float("Denoiser", val)
}
// PanX returns the value of the Pan_X parameter
func (s *strip) PanX() float64 {
return s.getter_float("Pan_x")
@ -180,205 +170,217 @@ func (s *strip) FadeBy(change float64, time_ int) {
time.Sleep(time.Millisecond)
}
// physicalStrip represents a single physical strip
type physicalStrip struct {
// PhysicalStrip represents a single physical strip
type PhysicalStrip struct {
strip
}
// newPhysicalStrip returns a physicalStrip type cast to an iStrip
// newPhysicalStrip returns a PhysicalStrip type
func newPhysicalStrip(i int, k *kind) iStrip {
o := newOutputs(fmt.Sprintf("strip[%d]", i), i)
e := newEq(fmt.Sprintf("strip[%d].EQ", i), i)
c := newComp(i)
g := newGate(i)
d := newDenoiser(i)
gl := make([]gainLayer, 8)
for j := 0; j < 8; j++ {
gl[j] = newGainLayer(i, j)
}
l := newStripLevels(i, k)
ps := physicalStrip{strip{iRemote{fmt.Sprintf("strip[%d]", i), i}, o, e, c, g, gl, l}}
ps := PhysicalStrip{strip{iRemote{fmt.Sprintf("strip[%d]", i), i}, o, e, c, g, d, gl, l}}
return &ps
}
// String implements fmt.stringer interface
func (p *physicalStrip) String() string {
func (p *PhysicalStrip) String() string {
return fmt.Sprintf("PhysicalStrip%d", p.index)
}
// Audibility returns the value of the Audibility parameter
func (p *physicalStrip) Audibility() float64 {
func (p *PhysicalStrip) Audibility() float64 {
return p.getter_float("Audibility")
}
// SetAudibility sets the value of the Audibility parameter
func (p *physicalStrip) SetAudibility(val float64) {
func (p *PhysicalStrip) SetAudibility(val float64) {
p.setter_float("Audibility", val)
}
// Mc logs a warning reason invalid parameter
// it always returns zero value
func (p *physicalStrip) Mc() bool {
func (p *PhysicalStrip) Mc() bool {
log.Warn("invalid parameter MC for physicalStrip")
return false
}
// SetMc logs a warning reason invalid parameter
func (p *physicalStrip) SetMc(val bool) {
func (p *PhysicalStrip) SetMc(val bool) {
log.Warn("invalid parameter MC for physicalStrip")
}
// Comp returns the comp field
func (p *physicalStrip) Comp() *comp {
func (p *PhysicalStrip) Comp() *comp {
return p.comp
}
// Gate returns the gate field
func (p *physicalStrip) Gate() *gate {
func (p *PhysicalStrip) Gate() *gate {
return p.gate
}
// Denoiser returns the denoiser field
func (p *PhysicalStrip) Denoiser() *denoiser {
return p.denoiser
}
// ColorX returns the value of the Color_X parameter
func (p *physicalStrip) ColorX() float64 {
func (p *PhysicalStrip) ColorX() float64 {
return p.getter_float("Color_x")
}
// SetColorX sets the value of the Color_X parameter
func (p *physicalStrip) SetColorX(val float64) {
func (p *PhysicalStrip) SetColorX(val float64) {
p.setter_float("Color_x", val)
}
// ColorY returns the value of the Color_Y parameter
func (p *physicalStrip) ColorY() float64 {
func (p *PhysicalStrip) ColorY() float64 {
return p.getter_float("Color_y")
}
// SetColorY sets the value of the Color_Y parameter
func (p *physicalStrip) SetColorY(val float64) {
func (p *PhysicalStrip) SetColorY(val float64) {
p.setter_float("Color_y", val)
}
// FxX returns the value of the Color_X parameter
func (p *physicalStrip) FxX() float64 {
func (p *PhysicalStrip) FxX() float64 {
return p.getter_float("fx_x")
}
// SetFxX sets the value of the Color_X parameter
func (p *physicalStrip) SetFxX(val float64) {
func (p *PhysicalStrip) SetFxX(val float64) {
p.setter_float("fx_x", val)
}
// FxY returns the value of the Color_Y parameter
func (p *physicalStrip) FxY() float64 {
func (p *PhysicalStrip) FxY() float64 {
return p.getter_float("fx_y")
}
// SetFxY sets the value of the Color_Y parameter
func (p *physicalStrip) SetFxY(val float64) {
func (p *PhysicalStrip) SetFxY(val float64) {
p.setter_float("fx_y", val)
}
// virtualStrip represents a single virtual strip
type virtualStrip struct {
// VirtualStrip represents a single virtual strip
type VirtualStrip struct {
strip
}
// newVirtualStrip returns a virtualStrip type cast to an iStrip
// newVirtualStrip returns a VirtualStrip type
func newVirtualStrip(i int, k *kind) iStrip {
o := newOutputs(fmt.Sprintf("strip[%d]", i), i)
e := newEq(fmt.Sprintf("strip[%d].EQ", i), i)
c := newComp(i)
g := newGate(i)
d := newDenoiser(i)
gl := make([]gainLayer, 8)
for j := 0; j < 8; j++ {
gl[j] = newGainLayer(i, j)
}
l := newStripLevels(i, k)
vs := virtualStrip{strip{iRemote{fmt.Sprintf("strip[%d]", i), i}, o, e, c, g, gl, l}}
vs := VirtualStrip{strip{iRemote{fmt.Sprintf("strip[%d]", i), i}, o, e, c, g, d, gl, l}}
return &vs
}
// String implements fmt.stringer interface
func (v *virtualStrip) String() string {
func (v *VirtualStrip) String() string {
return fmt.Sprintf("VirtualStrip%d", v.index)
}
// Comp returns the comp field
func (v *virtualStrip) Comp() *comp {
func (v *VirtualStrip) Comp() *comp {
return v.comp
}
// Gate returns the gate field
func (v *virtualStrip) Gate() *gate {
func (v *VirtualStrip) Gate() *gate {
return v.gate
}
// Denoiser returns the denoiser field
func (v *VirtualStrip) Denoiser() *denoiser {
return v.denoiser
}
// Mc returns the value of the MC parameter
func (v *virtualStrip) Mc() bool {
func (v *VirtualStrip) Mc() bool {
return v.getter_bool("MC")
}
// SetMc sets the value of the MC parameter
func (v *virtualStrip) SetMc(val bool) {
func (v *VirtualStrip) SetMc(val bool) {
v.setter_bool("MC", val)
}
// ColorX logs a warning reason invalid parameter
// it always returns zero value
func (v *virtualStrip) ColorX() float64 {
func (v *VirtualStrip) ColorX() float64 {
log.Warn("invalid parameter ColorX for virtualStrip")
return 0
}
// SetColorX logs a warning reason invalid parameter
func (v *virtualStrip) SetColorX(val float64) {
func (v *VirtualStrip) SetColorX(val float64) {
log.Warn("invalid parameter ColorX for virtualStrip")
}
// ColorY logs a warning reason invalid parameter
// it always returns zero value
func (v *virtualStrip) ColorY() float64 {
func (v *VirtualStrip) ColorY() float64 {
log.Warn("invalid parameter ColorY for virtualStrip")
return 0
}
// SetColorY logs a warning reason invalid parameter
func (v *virtualStrip) SetColorY(val float64) {
func (v *VirtualStrip) SetColorY(val float64) {
log.Warn("invalid parameter ColorY for virtualStrip")
}
// FxX logs a warning reason invalid parameter
// it always returns zero value
func (v *virtualStrip) FxX() float64 {
func (v *VirtualStrip) FxX() float64 {
log.Warn("invalid parameter FxX for virtualStrip")
return 0
}
// SetFxX logs a warning reason invalid parameter
func (v *virtualStrip) SetFxX(val float64) {
func (v *VirtualStrip) SetFxX(val float64) {
log.Warn("invalid parameter SetFxX for virtualStrip")
}
// FxY logs a warning reason invalid parameter
// it always returns zero value
func (v *virtualStrip) FxY() float64 {
func (v *VirtualStrip) FxY() float64 {
log.Warn("invalid parameter FxY for virtualStrip")
return 0
}
// SetFxY logs a warning reason invalid parameter
func (v *virtualStrip) SetFxY(val float64) {
func (v *VirtualStrip) SetFxY(val float64) {
log.Warn("invalid parameter SetFxY for virtualStrip")
}
// Audibility logs a warning reason invalid parameter
// it always returns zero value
func (v *virtualStrip) Audibility() float64 {
func (v *VirtualStrip) Audibility() float64 {
log.Warn("invalid parameter Audibility for virtualStrip")
return 0
}
// SetAudibility logs a warning reason invalid parameter
func (v *virtualStrip) SetAudibility(val float64) {
func (v *VirtualStrip) SetAudibility(val float64) {
log.Warn("invalid parameter Audibility for virtualStrip")
}
@ -398,6 +400,22 @@ func (v *strip) AppMute(name string, val bool) {
v.setter_string("AppMute", fmt.Sprintf("(\"%s\", %f)", name, float64(value)))
}
type denoiser struct {
iRemote
}
func newDenoiser(i int) *denoiser {
return &denoiser{iRemote{fmt.Sprintf("strip[%d].denoiser", i), i}}
}
func (d *denoiser) Knob() float64 {
return d.getter_float("")
}
func (d *denoiser) SetKnob(val float64) {
d.setter_float("", val)
}
type comp struct {
iRemote
}
@ -510,12 +528,12 @@ func (g *gate) SetDamping(val float64) {
g.setter_float("Damping", val)
}
func (g *gate) BPSidechain() float64 {
return g.getter_float("BPSidechain")
func (g *gate) BPSidechain() int {
return g.getter_int("BPSidechain")
}
func (g *gate) SetBPSidechain(val float64) {
g.setter_float("BPSidechain", val)
func (g *gate) SetBPSidechain(val int) {
g.setter_int("BPSidechain", val)
}
func (g *gate) Attack() float64 {

56
vban.go
View File

@ -28,72 +28,72 @@ type iVban interface {
SetRoute(val int)
}
type vbanStream struct {
type stream struct {
iRemote
}
// On returns the value of the On parameter
func (v *vbanStream) On() bool {
func (v *stream) On() bool {
return v.getter_bool("On")
}
// SetOn sets the value of the On parameter
func (v *vbanStream) SetOn(val bool) {
func (v *stream) SetOn(val bool) {
v.setter_bool("On", val)
}
// Name returns the value of the Name parameter
func (v *vbanStream) Name() string {
func (v *stream) Name() string {
return v.getter_string("Name")
}
// SetLabel sets the value of the Name parameter
func (v *vbanStream) SetName(val string) {
func (v *stream) SetName(val string) {
v.setter_string("Name", val)
}
// Ip returns the value of the Ip parameter
func (v *vbanStream) Ip() string {
func (v *stream) Ip() string {
return v.getter_string("Ip")
}
// SetIp sets the value of the Ip parameter
func (v *vbanStream) SetIp(val string) {
func (v *stream) SetIp(val string) {
v.setter_string("Ip", val)
}
// Port returns the value of the Port parameter
func (v *vbanStream) Port() int {
func (v *stream) Port() int {
return v.getter_int("Port")
}
// SetPort sets the value of the Port parameter
func (v *vbanStream) SetPort(val int) {
func (v *stream) SetPort(val int) {
v.setter_int("Port", val)
}
// Sr returns the value of the Sr parameter
func (v *vbanStream) Sr() int {
func (v *stream) Sr() int {
return v.getter_int("Sr")
}
// SetSr sets the value of the Sr parameter
func (v *vbanStream) SetSr(val int) {
func (v *stream) SetSr(val int) {
v.setter_int("Sr", val)
}
// Channel returns the value of the Channel parameter
func (v *vbanStream) Channel() int {
func (v *stream) Channel() int {
return v.getter_int("Channel")
}
// SetChannel sets the value of the Channel parameter
func (v *vbanStream) SetChannel(val int) {
func (v *stream) SetChannel(val int) {
v.setter_int("Channel", val)
}
// Bit returns the value of the Bit parameter
func (v *vbanStream) Bit() int {
func (v *stream) Bit() int {
val := v.getter_int("Bit")
if val == 1 {
return 16
@ -102,7 +102,7 @@ func (v *vbanStream) Bit() int {
}
// SetBit sets the value of the Bit parameter
func (v *vbanStream) SetBit(val int) {
func (v *stream) SetBit(val int) {
switch val {
case 16:
val = 1
@ -116,55 +116,55 @@ func (v *vbanStream) SetBit(val int) {
}
// Quality returns the value of the Quality parameter
func (v *vbanStream) Quality() int {
func (v *stream) Quality() int {
return v.getter_int("Quality")
}
// SetQuality sets the value of the Quality parameter
func (v *vbanStream) SetQuality(val int) {
func (v *stream) SetQuality(val int) {
v.setter_int("Quality", val)
}
// Route returns the value of the Route parameter
func (v *vbanStream) Route() int {
func (v *stream) Route() int {
return v.getter_int("Route")
}
// SetRoute sets the value of the Route parameter
func (v *vbanStream) SetRoute(val int) {
func (v *stream) SetRoute(val int) {
v.setter_int("Route", val)
}
type vbanInStream struct {
vbanStream
type VbanInstream struct {
stream
}
func newVbanInStream(i int) iVban {
vbi := vbanInStream{vbanStream{iRemote{fmt.Sprintf("vban.instream[%d]", i), i}}}
vbi := VbanInstream{stream{iRemote{fmt.Sprintf("vban.instream[%d]", i), i}}}
return &vbi
}
// SetSr logs a warning reason read only
func (vbi *vbanInStream) SetSr(val int) {
func (vbi *VbanInstream) SetSr(val int) {
log.Warn("SR is readonly for vban instreams")
}
// SetChannel logs a warning reason read only
func (vbi *vbanInStream) SetChannel(val int) {
func (vbi *VbanInstream) SetChannel(val int) {
log.Warn("channel is readonly for vban instreams")
}
// SetBit logs a warning reason read only
func (vbi *vbanInStream) SetBit(val int) {
func (vbi *VbanInstream) SetBit(val int) {
log.Warn("bit is readonly for vban instreams")
}
type vbanOutStream struct {
vbanStream
type VbanOutStream struct {
stream
}
func newVbanOutStream(i int) iVban {
vbo := vbanOutStream{vbanStream{iRemote{fmt.Sprintf("vban.outstream[%d]", i), i}}}
vbo := VbanOutStream{stream{iRemote{fmt.Sprintf("vban.outstream[%d]", i), i}}}
return &vbo
}