mirror of
https://github.com/onyx-and-iris/xair-cli.git
synced 2026-04-08 18:03:37 +00:00
main comp/eq commands implemented
factory methods unexported lr.go renamed to main.go main.go renamed to cli.go
This commit is contained in:
@@ -3,16 +3,16 @@ package xair
|
||||
import "fmt"
|
||||
|
||||
type Bus struct {
|
||||
baseAddress string
|
||||
client *Client
|
||||
baseAddress string
|
||||
Eq *Eq
|
||||
Comp *Comp
|
||||
}
|
||||
|
||||
func NewBus(c *Client) *Bus {
|
||||
func newBus(c *Client) *Bus {
|
||||
return &Bus{
|
||||
baseAddress: c.addressMap["bus"],
|
||||
client: c,
|
||||
baseAddress: c.addressMap["bus"],
|
||||
Eq: newEqForBus(c),
|
||||
Comp: newCompForBus(c),
|
||||
}
|
||||
|
||||
@@ -58,10 +58,10 @@ func NewClient(mixerIP string, mixerPort int, opts ...Option) (*Client, error) {
|
||||
engine: *e,
|
||||
}
|
||||
c.Main = newMainStereo(c)
|
||||
c.Strip = NewStrip(c)
|
||||
c.Bus = NewBus(c)
|
||||
c.HeadAmp = NewHeadAmp(c)
|
||||
c.Snapshot = NewSnapshot(c)
|
||||
c.Strip = newStrip(c)
|
||||
c.Bus = newBus(c)
|
||||
c.HeadAmp = newHeadAmp(c)
|
||||
c.Snapshot = newSnapshot(c)
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
||||
@@ -5,6 +5,18 @@ import "fmt"
|
||||
type Comp struct {
|
||||
client *Client
|
||||
baseAddress string
|
||||
AddressFunc func(fmtString string, args ...any) string
|
||||
}
|
||||
|
||||
// Factory function to create Comp instance for Main
|
||||
func newCompForMain(c *Client) *Comp {
|
||||
return &Comp{
|
||||
client: c,
|
||||
baseAddress: c.addressMap["main"],
|
||||
AddressFunc: func(fmtString string, args ...any) string {
|
||||
return fmtString
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Factory function to create Comp instance for Strip
|
||||
@@ -12,6 +24,9 @@ func newCompForStrip(c *Client) *Comp {
|
||||
return &Comp{
|
||||
client: c,
|
||||
baseAddress: c.addressMap["strip"],
|
||||
AddressFunc: func(fmtString string, args ...any) string {
|
||||
return fmt.Sprintf(fmtString, args...)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +35,15 @@ func newCompForBus(c *Client) *Comp {
|
||||
return &Comp{
|
||||
client: c,
|
||||
baseAddress: c.addressMap["bus"],
|
||||
AddressFunc: func(fmtString string, args ...any) string {
|
||||
return fmt.Sprintf(fmtString, args...)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// On retrieves the on/off status of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) On(index int) (bool, error) {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/on"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/on"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -44,7 +62,7 @@ func (c *Comp) On(index int) (bool, error) {
|
||||
|
||||
// SetOn sets the on/off status of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) SetOn(index int, on bool) error {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/on"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/on"
|
||||
var value int32
|
||||
if on {
|
||||
value = 1
|
||||
@@ -54,7 +72,7 @@ func (c *Comp) SetOn(index int, on bool) error {
|
||||
|
||||
// Mode retrieves the current mode of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) Mode(index int) (string, error) {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/mode"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/mode"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -75,14 +93,14 @@ func (c *Comp) Mode(index int) (string, error) {
|
||||
|
||||
// SetMode sets the mode of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) SetMode(index int, mode string) error {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/mode"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/mode"
|
||||
possibleModes := []string{"comp", "exp"}
|
||||
return c.client.SendMessage(address, int32(indexOf(possibleModes, mode)))
|
||||
}
|
||||
|
||||
// Threshold retrieves the threshold value of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) Threshold(index int) (float64, error) {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/thr"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/thr"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -101,13 +119,13 @@ func (c *Comp) Threshold(index int) (float64, error) {
|
||||
|
||||
// SetThreshold sets the threshold value of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) SetThreshold(index int, threshold float64) error {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/thr"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/thr"
|
||||
return c.client.SendMessage(address, float32(linSet(-60, 0, threshold)))
|
||||
}
|
||||
|
||||
// Ratio retrieves the ratio value of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) Ratio(index int) (float32, error) {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/ratio"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/ratio"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -129,7 +147,7 @@ func (c *Comp) Ratio(index int) (float32, error) {
|
||||
|
||||
// SetRatio sets the ratio value of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) SetRatio(index int, ratio float64) error {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/ratio"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/ratio"
|
||||
possibleValues := []float32{1.1, 1.3, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 7.0, 10, 20, 100}
|
||||
|
||||
return c.client.SendMessage(address, int32(indexOf(possibleValues, float32(ratio))))
|
||||
@@ -137,7 +155,7 @@ func (c *Comp) SetRatio(index int, ratio float64) error {
|
||||
|
||||
// Attack retrieves the attack time of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) Attack(index int) (float64, error) {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/attack"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/attack"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -156,13 +174,13 @@ func (c *Comp) Attack(index int) (float64, error) {
|
||||
|
||||
// SetAttack sets the attack time of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) SetAttack(index int, attack float64) error {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/attack"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/attack"
|
||||
return c.client.SendMessage(address, float32(linSet(0, 120, attack)))
|
||||
}
|
||||
|
||||
// Hold retrieves the hold time of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) Hold(index int) (float64, error) {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/hold"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/hold"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -181,13 +199,13 @@ func (c *Comp) Hold(index int) (float64, error) {
|
||||
|
||||
// SetHold sets the hold time of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) SetHold(index int, hold float64) error {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/hold"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/hold"
|
||||
return c.client.SendMessage(address, float32(logSet(0.02, 2000, hold)))
|
||||
}
|
||||
|
||||
// Release retrieves the release time of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) Release(index int) (float64, error) {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/release"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/release"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -206,13 +224,13 @@ func (c *Comp) Release(index int) (float64, error) {
|
||||
|
||||
// SetRelease sets the release time of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) SetRelease(index int, release float64) error {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/release"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/release"
|
||||
return c.client.SendMessage(address, float32(logSet(4, 4000, release)))
|
||||
}
|
||||
|
||||
// Makeup retrieves the makeup gain of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) Makeup(index int) (float64, error) {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/mgain"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/mgain"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -231,13 +249,13 @@ func (c *Comp) Makeup(index int) (float64, error) {
|
||||
|
||||
// SetMakeup sets the makeup gain of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) SetMakeup(index int, makeup float64) error {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/mgain"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/mgain"
|
||||
return c.client.SendMessage(address, float32(linSet(0, 24, makeup)))
|
||||
}
|
||||
|
||||
// Mix retrieves the mix value of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) Mix(index int) (float64, error) {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/mix"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/mix"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -256,6 +274,6 @@ func (c *Comp) Mix(index int) (float64, error) {
|
||||
|
||||
// SetMix sets the mix value of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) SetMix(index int, mix float64) error {
|
||||
address := fmt.Sprintf(c.baseAddress, index) + "/dyn/mix"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/mix"
|
||||
return c.client.SendMessage(address, float32(linSet(0, 100, mix)))
|
||||
}
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
package xair
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Eq struct {
|
||||
client *Client
|
||||
baseAddress string
|
||||
AddressFunc func(fmtString string, args ...any) string
|
||||
}
|
||||
|
||||
// Factory function to create Eq instance for Main
|
||||
func newEqForMain(c *Client) *Eq {
|
||||
return &Eq{
|
||||
client: c,
|
||||
baseAddress: c.addressMap["main"],
|
||||
AddressFunc: func(fmtString string, args ...any) string {
|
||||
return fmtString
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Factory function to create Eq instance for Strip
|
||||
@@ -12,6 +26,9 @@ func newEqForStrip(c *Client) *Eq {
|
||||
return &Eq{
|
||||
client: c,
|
||||
baseAddress: c.addressMap["strip"],
|
||||
AddressFunc: func(fmtString string, args ...any) string {
|
||||
return fmt.Sprintf(fmtString, args...)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +37,15 @@ func newEqForBus(c *Client) *Eq {
|
||||
return &Eq{
|
||||
client: c,
|
||||
baseAddress: c.addressMap["bus"],
|
||||
AddressFunc: func(fmtString string, args ...any) string {
|
||||
return fmt.Sprintf(fmtString, args...)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// On retrieves the on/off status of the EQ for a specific strip or bus (1-based indexing).
|
||||
func (e *Eq) On(index int) (bool, error) {
|
||||
address := fmt.Sprintf(e.baseAddress, index) + "/eq/on"
|
||||
address := e.AddressFunc(e.baseAddress, index) + "/eq/on"
|
||||
err := e.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@@ -44,7 +64,7 @@ func (e *Eq) On(index int) (bool, error) {
|
||||
|
||||
// SetOn sets the on/off status of the EQ for a specific strip or bus (1-based indexing).
|
||||
func (e *Eq) SetOn(index int, on bool) error {
|
||||
address := fmt.Sprintf(e.baseAddress, index) + "/eq/on"
|
||||
address := e.AddressFunc(e.baseAddress, index) + "/eq/on"
|
||||
var value int32
|
||||
if on {
|
||||
value = 1
|
||||
@@ -53,7 +73,7 @@ func (e *Eq) SetOn(index int, on bool) error {
|
||||
}
|
||||
|
||||
func (e *Eq) Mode(index int) (string, error) {
|
||||
address := fmt.Sprintf(e.baseAddress, index) + "/eq/mode"
|
||||
address := e.AddressFunc(e.baseAddress, index) + "/eq/mode"
|
||||
err := e.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -73,14 +93,14 @@ func (e *Eq) Mode(index int) (string, error) {
|
||||
}
|
||||
|
||||
func (e *Eq) SetMode(index int, mode string) error {
|
||||
address := fmt.Sprintf(e.baseAddress, index) + "/eq/mode"
|
||||
address := e.AddressFunc(e.baseAddress, index) + "/eq/mode"
|
||||
possibleModes := []string{"peq", "geq", "teq"}
|
||||
return e.client.SendMessage(address, int32(indexOf(possibleModes, mode)))
|
||||
}
|
||||
|
||||
// Gain retrieves the gain for a specific EQ band on a strip or bus (1-based indexing).
|
||||
func (e *Eq) Gain(index int, band int) (float64, error) {
|
||||
address := fmt.Sprintf(e.baseAddress, index) + fmt.Sprintf("/eq/%d/g", band)
|
||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/g", band)
|
||||
err := e.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -99,13 +119,13 @@ func (e *Eq) Gain(index int, band int) (float64, error) {
|
||||
|
||||
// SetGain sets the gain for a specific EQ band on a strip or bus (1-based indexing).
|
||||
func (e *Eq) SetGain(index int, band int, gain float64) error {
|
||||
address := fmt.Sprintf(e.baseAddress, index) + fmt.Sprintf("/eq/%d/g", band)
|
||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/g", band)
|
||||
return e.client.SendMessage(address, float32(linSet(-15, 15, gain)))
|
||||
}
|
||||
|
||||
// Frequency retrieves the frequency for a specific EQ band on a strip or bus (1-based indexing).
|
||||
func (e *Eq) Frequency(index int, band int) (float64, error) {
|
||||
address := fmt.Sprintf(e.baseAddress, index) + fmt.Sprintf("/eq/%d/f", band)
|
||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/f", band)
|
||||
err := e.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -124,13 +144,13 @@ func (e *Eq) Frequency(index int, band int) (float64, error) {
|
||||
|
||||
// SetFrequency sets the frequency for a specific EQ band on a strip or bus (1-based indexing).
|
||||
func (e *Eq) SetFrequency(index int, band int, frequency float64) error {
|
||||
address := fmt.Sprintf(e.baseAddress, index) + fmt.Sprintf("/eq/%d/f", band)
|
||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/f", band)
|
||||
return e.client.SendMessage(address, float32(logSet(20, 20000, frequency)))
|
||||
}
|
||||
|
||||
// Q retrieves the Q factor for a specific EQ band on a strip or bus (1-based indexing).
|
||||
func (e *Eq) Q(index int, band int) (float64, error) {
|
||||
address := fmt.Sprintf(e.baseAddress, index) + fmt.Sprintf("/eq/%d/q", band)
|
||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/q", band)
|
||||
err := e.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -149,13 +169,13 @@ func (e *Eq) Q(index int, band int) (float64, error) {
|
||||
|
||||
// SetQ sets the Q factor for a specific EQ band on a strip or bus (1-based indexing).
|
||||
func (e *Eq) SetQ(index int, band int, q float64) error {
|
||||
address := fmt.Sprintf(e.baseAddress, index) + fmt.Sprintf("/eq/%d/q", band)
|
||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/q", band)
|
||||
return e.client.SendMessage(address, float32(1.0-logSet(0.3, 10, q)))
|
||||
}
|
||||
|
||||
// Type retrieves the type for a specific EQ band on a strip or bus (1-based indexing).
|
||||
func (e *Eq) Type(index int, band int) (string, error) {
|
||||
address := fmt.Sprintf(e.baseAddress, index) + fmt.Sprintf("/eq/%d/type", band)
|
||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/type", band)
|
||||
err := e.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -176,7 +196,7 @@ func (e *Eq) Type(index int, band int) (string, error) {
|
||||
|
||||
// SetType sets the type for a specific EQ band on a strip or bus (1-based indexing).
|
||||
func (e *Eq) SetType(index int, band int, eqType string) error {
|
||||
address := fmt.Sprintf(e.baseAddress, index) + fmt.Sprintf("/eq/%d/type", band)
|
||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/type", band)
|
||||
possibleTypes := []string{"lcut", "lshv", "peq", "veq", "hshv", "hcut"}
|
||||
return e.client.SendMessage(address, int32(indexOf(possibleTypes, eqType)))
|
||||
}
|
||||
|
||||
@@ -7,8 +7,12 @@ type Gate struct {
|
||||
baseAddress string
|
||||
}
|
||||
|
||||
func newGate(c *Client) *Gate {
|
||||
return &Gate{client: c, baseAddress: c.addressMap["strip"]}
|
||||
// Factory function to create Gate instance for Strip
|
||||
func newGateForStrip(c *Client) *Gate {
|
||||
return &Gate{
|
||||
client: c,
|
||||
baseAddress: c.addressMap["strip"],
|
||||
}
|
||||
}
|
||||
|
||||
// On retrieves the on/off status of the Gate for a specific strip (1-based indexing).
|
||||
|
||||
@@ -3,14 +3,15 @@ package xair
|
||||
import "fmt"
|
||||
|
||||
type HeadAmp struct {
|
||||
baseAddress string
|
||||
client *Client
|
||||
baseAddress string
|
||||
}
|
||||
|
||||
func NewHeadAmp(c *Client) *HeadAmp {
|
||||
// newHeadAmp creates a new HeadAmp instance with the provided client.
|
||||
func newHeadAmp(c *Client) *HeadAmp {
|
||||
return &HeadAmp{
|
||||
baseAddress: c.addressMap["headamp"],
|
||||
client: c,
|
||||
baseAddress: c.addressMap["headamp"],
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,14 +3,18 @@ package xair
|
||||
import "fmt"
|
||||
|
||||
type Main struct {
|
||||
baseAddress string
|
||||
client *Client
|
||||
baseAddress string
|
||||
Eq *Eq
|
||||
Comp *Comp
|
||||
}
|
||||
|
||||
func newMainStereo(c *Client) *Main {
|
||||
return &Main{
|
||||
baseAddress: c.addressMap["main"],
|
||||
client: c,
|
||||
baseAddress: c.addressMap["main"],
|
||||
Eq: newEqForMain(c),
|
||||
Comp: newCompForMain(c),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,14 +3,14 @@ package xair
|
||||
import "fmt"
|
||||
|
||||
type Snapshot struct {
|
||||
baseAddress string
|
||||
client *Client
|
||||
baseAddress string
|
||||
}
|
||||
|
||||
func NewSnapshot(c *Client) *Snapshot {
|
||||
func newSnapshot(c *Client) *Snapshot {
|
||||
return &Snapshot{
|
||||
baseAddress: c.addressMap["snapshot"],
|
||||
client: c,
|
||||
baseAddress: c.addressMap["snapshot"],
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,18 +3,18 @@ package xair
|
||||
import "fmt"
|
||||
|
||||
type Strip struct {
|
||||
baseAddress string
|
||||
client *Client
|
||||
baseAddress string
|
||||
Gate *Gate
|
||||
Eq *Eq
|
||||
Comp *Comp
|
||||
}
|
||||
|
||||
func NewStrip(c *Client) *Strip {
|
||||
func newStrip(c *Client) *Strip {
|
||||
return &Strip{
|
||||
baseAddress: c.addressMap["strip"],
|
||||
client: c,
|
||||
Gate: newGate(c),
|
||||
baseAddress: c.addressMap["strip"],
|
||||
Gate: newGateForStrip(c),
|
||||
Eq: newEqForStrip(c),
|
||||
Comp: newCompForStrip(c),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user