mirror of
https://github.com/onyx-and-iris/xair-cli.git
synced 2026-02-26 00:09:11 +00:00
pass base addresses to factory methods
This commit is contained in:
parent
abfb1bf08d
commit
8a452c83b9
@ -13,8 +13,8 @@ func newBus(c *Client) *Bus {
|
|||||||
return &Bus{
|
return &Bus{
|
||||||
client: c,
|
client: c,
|
||||||
baseAddress: c.addressMap["bus"],
|
baseAddress: c.addressMap["bus"],
|
||||||
Eq: newEqForBus(c),
|
Eq: newEqForBus(c, c.addressMap["bus"]),
|
||||||
Comp: newCompForBus(c),
|
Comp: newCompForBus(c, c.addressMap["bus"]),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,10 +9,10 @@ type Comp struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Factory function to create Comp instance for Main
|
// Factory function to create Comp instance for Main
|
||||||
func newCompForMain(c *Client) *Comp {
|
func newCompForMain(c *Client, baseAddress string) *Comp {
|
||||||
return &Comp{
|
return &Comp{
|
||||||
client: c,
|
client: c,
|
||||||
baseAddress: c.addressMap["main"],
|
baseAddress: fmt.Sprintf("%s/dyn", baseAddress),
|
||||||
AddressFunc: func(fmtString string, args ...any) string {
|
AddressFunc: func(fmtString string, args ...any) string {
|
||||||
return fmtString
|
return fmtString
|
||||||
},
|
},
|
||||||
@ -20,35 +20,35 @@ func newCompForMain(c *Client) *Comp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Factory function to create Comp instance for Strip
|
// Factory function to create Comp instance for Strip
|
||||||
func newCompForStrip(c *Client) *Comp {
|
func newCompForStrip(c *Client, baseAddress string) *Comp {
|
||||||
return &Comp{
|
return &Comp{
|
||||||
client: c,
|
client: c,
|
||||||
baseAddress: c.addressMap["strip"],
|
baseAddress: fmt.Sprintf("%s/dyn", baseAddress),
|
||||||
AddressFunc: fmt.Sprintf,
|
AddressFunc: fmt.Sprintf,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Factory function to create Comp instance for Bus
|
// Factory function to create Comp instance for Bus
|
||||||
func newCompForBus(c *Client) *Comp {
|
func newCompForBus(c *Client, baseAddress string) *Comp {
|
||||||
return &Comp{
|
return &Comp{
|
||||||
client: c,
|
client: c,
|
||||||
baseAddress: c.addressMap["bus"],
|
baseAddress: fmt.Sprintf("%s/dyn", baseAddress),
|
||||||
AddressFunc: fmt.Sprintf,
|
AddressFunc: fmt.Sprintf,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Factory function to create Comp instance for Matrix
|
// Factory function to create Comp instance for Matrix
|
||||||
func newCompForMatrix(c *Client) *Comp {
|
func newCompForMatrix(c *Client, baseAddress string) *Comp {
|
||||||
return &Comp{
|
return &Comp{
|
||||||
client: c,
|
client: c,
|
||||||
baseAddress: c.addressMap["matrix"],
|
baseAddress: fmt.Sprintf("%s/dyn", baseAddress),
|
||||||
AddressFunc: fmt.Sprintf,
|
AddressFunc: fmt.Sprintf,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// On retrieves the on/off status of the Compressor for a specific strip or bus (1-based indexing).
|
// 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) {
|
func (c *Comp) On(index int) (bool, error) {
|
||||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/on"
|
address := c.AddressFunc(c.baseAddress, index) + "/on"
|
||||||
err := c.client.SendMessage(address)
|
err := c.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
@ -67,7 +67,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).
|
// 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 {
|
func (c *Comp) SetOn(index int, on bool) error {
|
||||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/on"
|
address := c.AddressFunc(c.baseAddress, index) + "/on"
|
||||||
var value int32
|
var value int32
|
||||||
if on {
|
if on {
|
||||||
value = 1
|
value = 1
|
||||||
@ -77,7 +77,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).
|
// 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) {
|
func (c *Comp) Mode(index int) (string, error) {
|
||||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/mode"
|
address := c.AddressFunc(c.baseAddress, index) + "/mode"
|
||||||
err := c.client.SendMessage(address)
|
err := c.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@ -98,14 +98,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).
|
// 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 {
|
func (c *Comp) SetMode(index int, mode string) error {
|
||||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/mode"
|
address := c.AddressFunc(c.baseAddress, index) + "/mode"
|
||||||
possibleModes := []string{"comp", "exp"}
|
possibleModes := []string{"comp", "exp"}
|
||||||
return c.client.SendMessage(address, int32(indexOf(possibleModes, mode)))
|
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).
|
// 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) {
|
func (c *Comp) Threshold(index int) (float64, error) {
|
||||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/thr"
|
address := c.AddressFunc(c.baseAddress, index) + "/thr"
|
||||||
err := c.client.SendMessage(address)
|
err := c.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@ -124,13 +124,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).
|
// 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 {
|
func (c *Comp) SetThreshold(index int, threshold float64) error {
|
||||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/thr"
|
address := c.AddressFunc(c.baseAddress, index) + "/thr"
|
||||||
return c.client.SendMessage(address, float32(linSet(-60, 0, threshold)))
|
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).
|
// 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) {
|
func (c *Comp) Ratio(index int) (float32, error) {
|
||||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/ratio"
|
address := c.AddressFunc(c.baseAddress, index) + "/ratio"
|
||||||
err := c.client.SendMessage(address)
|
err := c.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@ -152,7 +152,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).
|
// 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 {
|
func (c *Comp) SetRatio(index int, ratio float64) error {
|
||||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/ratio"
|
address := c.AddressFunc(c.baseAddress, index) + "/ratio"
|
||||||
possibleValues := []float32{1.1, 1.3, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 7.0, 10, 20, 100}
|
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))))
|
return c.client.SendMessage(address, int32(indexOf(possibleValues, float32(ratio))))
|
||||||
@ -160,7 +160,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).
|
// 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) {
|
func (c *Comp) Attack(index int) (float64, error) {
|
||||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/attack"
|
address := c.AddressFunc(c.baseAddress, index) + "/attack"
|
||||||
err := c.client.SendMessage(address)
|
err := c.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@ -179,13 +179,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).
|
// 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 {
|
func (c *Comp) SetAttack(index int, attack float64) error {
|
||||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/attack"
|
address := c.AddressFunc(c.baseAddress, index) + "/attack"
|
||||||
return c.client.SendMessage(address, float32(linSet(0, 120, 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).
|
// 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) {
|
func (c *Comp) Hold(index int) (float64, error) {
|
||||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/hold"
|
address := c.AddressFunc(c.baseAddress, index) + "/hold"
|
||||||
err := c.client.SendMessage(address)
|
err := c.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@ -204,13 +204,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).
|
// 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 {
|
func (c *Comp) SetHold(index int, hold float64) error {
|
||||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/hold"
|
address := c.AddressFunc(c.baseAddress, index) + "/hold"
|
||||||
return c.client.SendMessage(address, float32(logSet(0.02, 2000, 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).
|
// 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) {
|
func (c *Comp) Release(index int) (float64, error) {
|
||||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/release"
|
address := c.AddressFunc(c.baseAddress, index) + "/release"
|
||||||
err := c.client.SendMessage(address)
|
err := c.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@ -229,13 +229,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).
|
// 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 {
|
func (c *Comp) SetRelease(index int, release float64) error {
|
||||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/release"
|
address := c.AddressFunc(c.baseAddress, index) + "/release"
|
||||||
return c.client.SendMessage(address, float32(logSet(4, 4000, 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).
|
// 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) {
|
func (c *Comp) Makeup(index int) (float64, error) {
|
||||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/mgain"
|
address := c.AddressFunc(c.baseAddress, index) + "/mgain"
|
||||||
err := c.client.SendMessage(address)
|
err := c.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@ -254,13 +254,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).
|
// 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 {
|
func (c *Comp) SetMakeup(index int, makeup float64) error {
|
||||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/mgain"
|
address := c.AddressFunc(c.baseAddress, index) + "/mgain"
|
||||||
return c.client.SendMessage(address, float32(linSet(0, 24, makeup)))
|
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).
|
// 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) {
|
func (c *Comp) Mix(index int) (float64, error) {
|
||||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/mix"
|
address := c.AddressFunc(c.baseAddress, index) + "/mix"
|
||||||
err := c.client.SendMessage(address)
|
err := c.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@ -279,6 +279,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).
|
// 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 {
|
func (c *Comp) SetMix(index int, mix float64) error {
|
||||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/mix"
|
address := c.AddressFunc(c.baseAddress, index) + "/mix"
|
||||||
return c.client.SendMessage(address, float32(linSet(0, 100, mix)))
|
return c.client.SendMessage(address, float32(linSet(0, 100, mix)))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,10 +11,10 @@ type Eq struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Factory function to create Eq instance for Main
|
// Factory function to create Eq instance for Main
|
||||||
func newEqForMain(c *Client) *Eq {
|
func newEqForMain(c *Client, baseAddress string) *Eq {
|
||||||
return &Eq{
|
return &Eq{
|
||||||
client: c,
|
client: c,
|
||||||
baseAddress: c.addressMap["main"],
|
baseAddress: fmt.Sprintf("%s/eq", baseAddress),
|
||||||
AddressFunc: func(fmtString string, args ...any) string {
|
AddressFunc: func(fmtString string, args ...any) string {
|
||||||
return fmtString
|
return fmtString
|
||||||
},
|
},
|
||||||
@ -22,35 +22,35 @@ func newEqForMain(c *Client) *Eq {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Factory function to create Eq instance for Strip
|
// Factory function to create Eq instance for Strip
|
||||||
func newEqForStrip(c *Client) *Eq {
|
func newEqForStrip(c *Client, baseAddress string) *Eq {
|
||||||
return &Eq{
|
return &Eq{
|
||||||
client: c,
|
client: c,
|
||||||
baseAddress: c.addressMap["strip"],
|
baseAddress: fmt.Sprintf("%s/eq", baseAddress),
|
||||||
AddressFunc: fmt.Sprintf,
|
AddressFunc: fmt.Sprintf,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Factory function to create Eq instance for Bus
|
// Factory function to create Eq instance for Bus
|
||||||
func newEqForBus(c *Client) *Eq {
|
func newEqForBus(c *Client, baseAddress string) *Eq {
|
||||||
return &Eq{
|
return &Eq{
|
||||||
client: c,
|
client: c,
|
||||||
baseAddress: c.addressMap["bus"],
|
baseAddress: fmt.Sprintf("%s/eq", baseAddress),
|
||||||
AddressFunc: fmt.Sprintf,
|
AddressFunc: fmt.Sprintf,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Factory function to create Eq instance for Matrix
|
// Factory function to create Eq instance for Matrix
|
||||||
func newEqForMatrix(c *Client) *Eq {
|
func newEqForMatrix(c *Client, baseAddress string) *Eq {
|
||||||
return &Eq{
|
return &Eq{
|
||||||
client: c,
|
client: c,
|
||||||
baseAddress: c.addressMap["matrix"],
|
baseAddress: fmt.Sprintf("%s/eq", baseAddress),
|
||||||
AddressFunc: fmt.Sprintf,
|
AddressFunc: fmt.Sprintf,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// On retrieves the on/off status of the EQ for a specific strip or bus (1-based indexing).
|
// 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) {
|
func (e *Eq) On(index int) (bool, error) {
|
||||||
address := e.AddressFunc(e.baseAddress, index) + "/eq/on"
|
address := e.AddressFunc(e.baseAddress, index) + "/on"
|
||||||
err := e.client.SendMessage(address)
|
err := e.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
@ -69,7 +69,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).
|
// 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 {
|
func (e *Eq) SetOn(index int, on bool) error {
|
||||||
address := e.AddressFunc(e.baseAddress, index) + "/eq/on"
|
address := e.AddressFunc(e.baseAddress, index) + "/on"
|
||||||
var value int32
|
var value int32
|
||||||
if on {
|
if on {
|
||||||
value = 1
|
value = 1
|
||||||
@ -78,7 +78,7 @@ func (e *Eq) SetOn(index int, on bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *Eq) Mode(index int) (string, error) {
|
func (e *Eq) Mode(index int) (string, error) {
|
||||||
address := e.AddressFunc(e.baseAddress, index) + "/eq/mode"
|
address := e.AddressFunc(e.baseAddress, index) + "/mode"
|
||||||
err := e.client.SendMessage(address)
|
err := e.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@ -98,14 +98,14 @@ func (e *Eq) Mode(index int) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *Eq) SetMode(index int, mode string) error {
|
func (e *Eq) SetMode(index int, mode string) error {
|
||||||
address := e.AddressFunc(e.baseAddress, index) + "/eq/mode"
|
address := e.AddressFunc(e.baseAddress, index) + "/mode"
|
||||||
possibleModes := []string{"peq", "geq", "teq"}
|
possibleModes := []string{"peq", "geq", "teq"}
|
||||||
return e.client.SendMessage(address, int32(indexOf(possibleModes, mode)))
|
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).
|
// 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) {
|
func (e *Eq) Gain(index int, band int) (float64, error) {
|
||||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/g", band)
|
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/g", band)
|
||||||
err := e.client.SendMessage(address)
|
err := e.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@ -124,13 +124,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).
|
// 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 {
|
func (e *Eq) SetGain(index int, band int, gain float64) error {
|
||||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/g", band)
|
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/g", band)
|
||||||
return e.client.SendMessage(address, float32(linSet(-15, 15, gain)))
|
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).
|
// 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) {
|
func (e *Eq) Frequency(index int, band int) (float64, error) {
|
||||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/f", band)
|
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/f", band)
|
||||||
err := e.client.SendMessage(address)
|
err := e.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@ -149,13 +149,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).
|
// 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 {
|
func (e *Eq) SetFrequency(index int, band int, frequency float64) error {
|
||||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/f", band)
|
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/f", band)
|
||||||
return e.client.SendMessage(address, float32(logSet(20, 20000, frequency)))
|
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).
|
// 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) {
|
func (e *Eq) Q(index int, band int) (float64, error) {
|
||||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/q", band)
|
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/q", band)
|
||||||
err := e.client.SendMessage(address)
|
err := e.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@ -174,13 +174,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).
|
// 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 {
|
func (e *Eq) SetQ(index int, band int, q float64) error {
|
||||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/q", band)
|
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/q", band)
|
||||||
return e.client.SendMessage(address, float32(1.0-logSet(0.3, 10, q)))
|
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).
|
// 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) {
|
func (e *Eq) Type(index int, band int) (string, error) {
|
||||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/type", band)
|
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/type", band)
|
||||||
err := e.client.SendMessage(address)
|
err := e.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@ -201,7 +201,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).
|
// 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 {
|
func (e *Eq) SetType(index int, band int, eqType string) error {
|
||||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/type", band)
|
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/type", band)
|
||||||
possibleTypes := []string{"lcut", "lshv", "peq", "veq", "hshv", "hcut"}
|
possibleTypes := []string{"lcut", "lshv", "peq", "veq", "hshv", "hcut"}
|
||||||
return e.client.SendMessage(address, int32(indexOf(possibleTypes, eqType)))
|
return e.client.SendMessage(address, int32(indexOf(possibleTypes, eqType)))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,16 +8,16 @@ type Gate struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Factory function to create Gate instance for Strip
|
// Factory function to create Gate instance for Strip
|
||||||
func newGateForStrip(c *Client) *Gate {
|
func newGateForStrip(c *Client, baseAddress string) *Gate {
|
||||||
return &Gate{
|
return &Gate{
|
||||||
client: c,
|
client: c,
|
||||||
baseAddress: c.addressMap["strip"],
|
baseAddress: fmt.Sprintf("%s/gate", baseAddress),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// On retrieves the on/off status of the Gate for a specific strip (1-based indexing).
|
// On retrieves the on/off status of the Gate for a specific strip (1-based indexing).
|
||||||
func (g *Gate) On(index int) (bool, error) {
|
func (g *Gate) On(index int) (bool, error) {
|
||||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/on"
|
address := fmt.Sprintf(g.baseAddress, index) + "/on"
|
||||||
err := g.client.SendMessage(address)
|
err := g.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
@ -36,7 +36,7 @@ func (g *Gate) On(index int) (bool, error) {
|
|||||||
|
|
||||||
// SetOn sets the on/off status of the Gate for a specific strip (1-based indexing).
|
// SetOn sets the on/off status of the Gate for a specific strip (1-based indexing).
|
||||||
func (g *Gate) SetOn(index int, on bool) error {
|
func (g *Gate) SetOn(index int, on bool) error {
|
||||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/on"
|
address := fmt.Sprintf(g.baseAddress, index) + "/on"
|
||||||
var value int32
|
var value int32
|
||||||
if on {
|
if on {
|
||||||
value = 1
|
value = 1
|
||||||
@ -46,7 +46,7 @@ func (g *Gate) SetOn(index int, on bool) error {
|
|||||||
|
|
||||||
// Mode retrieves the current mode of the Gate for a specific strip (1-based indexing).
|
// Mode retrieves the current mode of the Gate for a specific strip (1-based indexing).
|
||||||
func (g *Gate) Mode(index int) (string, error) {
|
func (g *Gate) Mode(index int) (string, error) {
|
||||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/mode"
|
address := fmt.Sprintf(g.baseAddress, index) + "/mode"
|
||||||
err := g.client.SendMessage(address)
|
err := g.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@ -67,7 +67,7 @@ func (g *Gate) Mode(index int) (string, error) {
|
|||||||
|
|
||||||
// SetMode sets the mode of the Gate for a specific strip (1-based indexing).
|
// SetMode sets the mode of the Gate for a specific strip (1-based indexing).
|
||||||
func (g *Gate) SetMode(index int, mode string) error {
|
func (g *Gate) SetMode(index int, mode string) error {
|
||||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/mode"
|
address := fmt.Sprintf(g.baseAddress, index) + "/mode"
|
||||||
possibleModes := []string{"exp2", "exp3", "exp4", "gate", "duck"}
|
possibleModes := []string{"exp2", "exp3", "exp4", "gate", "duck"}
|
||||||
|
|
||||||
return g.client.SendMessage(address, int32(indexOf(possibleModes, mode)))
|
return g.client.SendMessage(address, int32(indexOf(possibleModes, mode)))
|
||||||
@ -75,7 +75,7 @@ func (g *Gate) SetMode(index int, mode string) error {
|
|||||||
|
|
||||||
// Threshold retrieves the threshold value of the Gate for a specific strip (1-based indexing).
|
// Threshold retrieves the threshold value of the Gate for a specific strip (1-based indexing).
|
||||||
func (g *Gate) Threshold(index int) (float64, error) {
|
func (g *Gate) Threshold(index int) (float64, error) {
|
||||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/thr"
|
address := fmt.Sprintf(g.baseAddress, index) + "/thr"
|
||||||
err := g.client.SendMessage(address)
|
err := g.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@ -94,13 +94,13 @@ func (g *Gate) Threshold(index int) (float64, error) {
|
|||||||
|
|
||||||
// SetThreshold sets the threshold value of the Gate for a specific strip (1-based indexing).
|
// SetThreshold sets the threshold value of the Gate for a specific strip (1-based indexing).
|
||||||
func (g *Gate) SetThreshold(index int, threshold float64) error {
|
func (g *Gate) SetThreshold(index int, threshold float64) error {
|
||||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/thr"
|
address := fmt.Sprintf(g.baseAddress, index) + "/thr"
|
||||||
return g.client.SendMessage(address, float32(linSet(-80, 0, threshold)))
|
return g.client.SendMessage(address, float32(linSet(-80, 0, threshold)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Range retrieves the range value of the Gate for a specific strip (1-based indexing).
|
// Range retrieves the range value of the Gate for a specific strip (1-based indexing).
|
||||||
func (g *Gate) Range(index int) (float64, error) {
|
func (g *Gate) Range(index int) (float64, error) {
|
||||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/range"
|
address := fmt.Sprintf(g.baseAddress, index) + "/range"
|
||||||
err := g.client.SendMessage(address)
|
err := g.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@ -119,13 +119,13 @@ func (g *Gate) Range(index int) (float64, error) {
|
|||||||
|
|
||||||
// SetRange sets the range value of the Gate for a specific strip (1-based indexing).
|
// SetRange sets the range value of the Gate for a specific strip (1-based indexing).
|
||||||
func (g *Gate) SetRange(index int, rangeVal float64) error {
|
func (g *Gate) SetRange(index int, rangeVal float64) error {
|
||||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/range"
|
address := fmt.Sprintf(g.baseAddress, index) + "/range"
|
||||||
return g.client.SendMessage(address, float32(linSet(3, 60, rangeVal)))
|
return g.client.SendMessage(address, float32(linSet(3, 60, rangeVal)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attack retrieves the attack time of the Gate for a specific strip (1-based indexing).
|
// Attack retrieves the attack time of the Gate for a specific strip (1-based indexing).
|
||||||
func (g *Gate) Attack(index int) (float64, error) {
|
func (g *Gate) Attack(index int) (float64, error) {
|
||||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/attack"
|
address := fmt.Sprintf(g.baseAddress, index) + "/attack"
|
||||||
err := g.client.SendMessage(address)
|
err := g.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@ -144,13 +144,13 @@ func (g *Gate) Attack(index int) (float64, error) {
|
|||||||
|
|
||||||
// SetAttack sets the attack time of the Gate for a specific strip (1-based indexing).
|
// SetAttack sets the attack time of the Gate for a specific strip (1-based indexing).
|
||||||
func (g *Gate) SetAttack(index int, attack float64) error {
|
func (g *Gate) SetAttack(index int, attack float64) error {
|
||||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/attack"
|
address := fmt.Sprintf(g.baseAddress, index) + "/attack"
|
||||||
return g.client.SendMessage(address, float32(linSet(0, 120, attack)))
|
return g.client.SendMessage(address, float32(linSet(0, 120, attack)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hold retrieves the hold time of the Gate for a specific strip (1-based indexing).
|
// Hold retrieves the hold time of the Gate for a specific strip (1-based indexing).
|
||||||
func (g *Gate) Hold(index int) (float64, error) {
|
func (g *Gate) Hold(index int) (float64, error) {
|
||||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/hold"
|
address := fmt.Sprintf(g.baseAddress, index) + "/hold"
|
||||||
err := g.client.SendMessage(address)
|
err := g.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@ -169,13 +169,13 @@ func (g *Gate) Hold(index int) (float64, error) {
|
|||||||
|
|
||||||
// SetHold sets the hold time of the Gate for a specific strip (1-based indexing).
|
// SetHold sets the hold time of the Gate for a specific strip (1-based indexing).
|
||||||
func (g *Gate) SetHold(index int, hold float64) error {
|
func (g *Gate) SetHold(index int, hold float64) error {
|
||||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/hold"
|
address := fmt.Sprintf(g.baseAddress, index) + "/hold"
|
||||||
return g.client.SendMessage(address, float32(logSet(0.02, 2000, hold)))
|
return g.client.SendMessage(address, float32(logSet(0.02, 2000, hold)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release retrieves the release time of the Gate for a specific strip (1-based indexing).
|
// Release retrieves the release time of the Gate for a specific strip (1-based indexing).
|
||||||
func (g *Gate) Release(index int) (float64, error) {
|
func (g *Gate) Release(index int) (float64, error) {
|
||||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/release"
|
address := fmt.Sprintf(g.baseAddress, index) + "/release"
|
||||||
err := g.client.SendMessage(address)
|
err := g.client.SendMessage(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@ -194,6 +194,6 @@ func (g *Gate) Release(index int) (float64, error) {
|
|||||||
|
|
||||||
// SetRelease sets the release time of the Gate for a specific strip (1-based indexing).
|
// SetRelease sets the release time of the Gate for a specific strip (1-based indexing).
|
||||||
func (g *Gate) SetRelease(index int, release float64) error {
|
func (g *Gate) SetRelease(index int, release float64) error {
|
||||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/release"
|
address := fmt.Sprintf(g.baseAddress, index) + "/release"
|
||||||
return g.client.SendMessage(address, float32(logSet(5, 4000, release)))
|
return g.client.SendMessage(address, float32(logSet(5, 4000, release)))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,8 +14,8 @@ func newMainStereo(c *Client) *Main {
|
|||||||
return &Main{
|
return &Main{
|
||||||
client: c,
|
client: c,
|
||||||
baseAddress: c.addressMap["main"],
|
baseAddress: c.addressMap["main"],
|
||||||
Eq: newEqForMain(c),
|
Eq: newEqForMain(c, c.addressMap["main"]),
|
||||||
Comp: newCompForMain(c),
|
Comp: newCompForMain(c, c.addressMap["main"]),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,6 +24,8 @@ func newMainMono(c *Client) *Main {
|
|||||||
return &Main{
|
return &Main{
|
||||||
baseAddress: c.addressMap["mainmono"],
|
baseAddress: c.addressMap["mainmono"],
|
||||||
client: c,
|
client: c,
|
||||||
|
Eq: newEqForMain(c, c.addressMap["mainmono"]),
|
||||||
|
Comp: newCompForMain(c, c.addressMap["mainmono"]),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,8 +14,8 @@ func newMatrix(c *Client) *Matrix {
|
|||||||
return &Matrix{
|
return &Matrix{
|
||||||
client: c,
|
client: c,
|
||||||
baseAddress: c.addressMap["matrix"],
|
baseAddress: c.addressMap["matrix"],
|
||||||
Eq: newEqForMatrix(c),
|
Eq: newEqForMatrix(c, c.addressMap["matrix"]),
|
||||||
Comp: newCompForMatrix(c),
|
Comp: newCompForMatrix(c, c.addressMap["matrix"]),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,9 +14,9 @@ func newStrip(c *Client) *Strip {
|
|||||||
return &Strip{
|
return &Strip{
|
||||||
client: c,
|
client: c,
|
||||||
baseAddress: c.addressMap["strip"],
|
baseAddress: c.addressMap["strip"],
|
||||||
Gate: newGateForStrip(c),
|
Gate: newGateForStrip(c, c.addressMap["strip"]),
|
||||||
Eq: newEqForStrip(c),
|
Eq: newEqForStrip(c, c.addressMap["strip"]),
|
||||||
Comp: newCompForStrip(c),
|
Comp: newCompForStrip(c, c.addressMap["strip"]),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user