mirror of
https://github.com/onyx-and-iris/xair-cli.git
synced 2026-04-08 18:03:37 +00:00
implement strip/bus gate/comp on commands
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
package xair
|
||||
|
||||
import "fmt"
|
||||
|
||||
type Comp struct {
|
||||
client *Client
|
||||
baseAddress string
|
||||
}
|
||||
|
||||
// Factory function to create Comp instance for Strip
|
||||
func newCompForStrip(c *Client) *Comp {
|
||||
return &Comp{
|
||||
client: c,
|
||||
@@ -12,9 +15,36 @@ func newCompForStrip(c *Client) *Comp {
|
||||
}
|
||||
}
|
||||
|
||||
// Factory function to create Comp instance for Bus
|
||||
func newCompForBus(c *Client) *Comp {
|
||||
return &Comp{
|
||||
client: c,
|
||||
baseAddress: c.addressMap["bus"],
|
||||
}
|
||||
}
|
||||
|
||||
// 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"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
resp := <-c.client.respChan
|
||||
val, ok := resp.Arguments[0].(int32)
|
||||
if !ok {
|
||||
return false, fmt.Errorf("unexpected argument type for Compressor on value")
|
||||
}
|
||||
return val != 0, nil
|
||||
}
|
||||
|
||||
// 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"
|
||||
var value int32
|
||||
if on {
|
||||
value = 1
|
||||
}
|
||||
return c.client.SendMessage(address, value)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ type Eq struct {
|
||||
baseAddress string
|
||||
}
|
||||
|
||||
// Helper function to create Eq instance for Strip
|
||||
// Factory function to create Eq instance for Strip
|
||||
func newEqForStrip(c *Client) *Eq {
|
||||
return &Eq{
|
||||
client: c,
|
||||
@@ -15,7 +15,7 @@ func newEqForStrip(c *Client) *Eq {
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to create Eq instance for Bus
|
||||
// Factory function to create Eq instance for Bus
|
||||
func newEqForBus(c *Client) *Eq {
|
||||
return &Eq{
|
||||
client: c,
|
||||
@@ -23,6 +23,7 @@ func newEqForBus(c *Client) *Eq {
|
||||
}
|
||||
}
|
||||
|
||||
// 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"
|
||||
err := e.client.SendMessage(address)
|
||||
@@ -38,6 +39,7 @@ func (e *Eq) On(index int) (bool, error) {
|
||||
return val != 0, nil
|
||||
}
|
||||
|
||||
// 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"
|
||||
var value int32
|
||||
|
||||
@@ -1,9 +1,38 @@
|
||||
package xair
|
||||
|
||||
import "fmt"
|
||||
|
||||
type Gate struct {
|
||||
client *Client
|
||||
client *Client
|
||||
baseAddress string
|
||||
}
|
||||
|
||||
func newGate(c *Client) *Gate {
|
||||
return &Gate{client: c}
|
||||
return &Gate{client: c, baseAddress: c.addressMap["strip"]}
|
||||
}
|
||||
|
||||
// On retrieves the on/off status of the Gate for a specific strip (1-based indexing).
|
||||
func (g *Gate) On(index int) (bool, error) {
|
||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/on"
|
||||
err := g.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
resp := <-g.client.respChan
|
||||
val, ok := resp.Arguments[0].(int32)
|
||||
if !ok {
|
||||
return false, fmt.Errorf("unexpected argument type for Gate on value")
|
||||
}
|
||||
return val != 0, nil
|
||||
}
|
||||
|
||||
// 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 {
|
||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/on"
|
||||
var value int32
|
||||
if on {
|
||||
value = 1
|
||||
}
|
||||
return g.client.SendMessage(address, value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user