mirror of
https://github.com/onyx-and-iris/xair-cli.git
synced 2026-03-03 10:39:12 +00:00
Compare commits
No commits in common. "e21fd59564ea43051b97e7c1a558066f4efb9475" and "1ad214ba4a7bc49203dd02de05434ee0ae9bc9b8" have entirely different histories.
e21fd59564
...
1ad214ba4a
@ -12,7 +12,7 @@ go install github.com/onyx-and-iris/xair-cli@latest
|
|||||||
|
|
||||||
- --host/-H: Host of the mixer.
|
- --host/-H: Host of the mixer.
|
||||||
- --port/-P: Port of the mixer.
|
- --port/-P: Port of the mixer.
|
||||||
- --kind/-k: The kind of mixer. May be one of (*xair*, *x32*).
|
- --kind/-k: The kind of mixer. May one of (*xair*, *x32*).
|
||||||
- Use this flag to connect to an x32 mixer.
|
- Use this flag to connect to an x32 mixer.
|
||||||
|
|
||||||
#### Environment Variables
|
#### Environment Variables
|
||||||
@ -25,7 +25,7 @@ Example .envrc:
|
|||||||
XAIR_CLI_HOST=mixer.local
|
XAIR_CLI_HOST=mixer.local
|
||||||
XAIR_CLI_PORT=10024
|
XAIR_CLI_PORT=10024
|
||||||
XAIR_CLI_KIND=xair
|
XAIR_CLI_KIND=xair
|
||||||
XAIR_CLI_TIMEOUT=100ms
|
XAIR_CLI_RAW_TIMEOUT=50ms
|
||||||
```
|
```
|
||||||
|
|
||||||
### Use
|
### Use
|
||||||
@ -40,8 +40,7 @@ Flags:
|
|||||||
-H, --host="mixer.local" The host of the X-Air device ($XAIR_CLI_HOST).
|
-H, --host="mixer.local" The host of the X-Air device ($XAIR_CLI_HOST).
|
||||||
-P, --port=10024 The port of the X-Air device ($XAIR_CLI_PORT).
|
-P, --port=10024 The port of the X-Air device ($XAIR_CLI_PORT).
|
||||||
-K, --kind="xair" The kind of the X-Air device ($XAIR_CLI_KIND).
|
-K, --kind="xair" The kind of the X-Air device ($XAIR_CLI_KIND).
|
||||||
-T, --timeout=100ms Timeout for OSC operations ($XAIR_CLI_TIMEOUT).
|
-v, --version Print gobs-cli version information and quit
|
||||||
-v, --version Print xair-cli version information and quit
|
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
completion (c) Generate shell completion scripts.
|
completion (c) Generate shell completion scripts.
|
||||||
|
|||||||
@ -26,11 +26,8 @@ func (b *Bus) Mute(bus int) (bool, error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := b.client.ReceiveMessage()
|
resp := <-b.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(int32)
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(int32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, fmt.Errorf("unexpected argument type for bus mute value")
|
return false, fmt.Errorf("unexpected argument type for bus mute value")
|
||||||
}
|
}
|
||||||
@ -55,11 +52,8 @@ func (b *Bus) Fader(bus int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := b.client.ReceiveMessage()
|
resp := <-b.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(float32)
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(float32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for bus fader value")
|
return 0, fmt.Errorf("unexpected argument type for bus fader value")
|
||||||
}
|
}
|
||||||
@ -81,11 +75,8 @@ func (b *Bus) Name(bus int) (string, error) {
|
|||||||
return "", fmt.Errorf("failed to send bus name request: %v", err)
|
return "", fmt.Errorf("failed to send bus name request: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := b.client.ReceiveMessage()
|
resp := <-b.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(string)
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(string)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", fmt.Errorf("unexpected argument type for bus name value")
|
return "", fmt.Errorf("unexpected argument type for bus name value")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,7 +41,6 @@ func NewClient(mixerIP string, mixerPort int, opts ...Option) (*Client, error) {
|
|||||||
|
|
||||||
e := &engine{
|
e := &engine{
|
||||||
Kind: KindXAir,
|
Kind: KindXAir,
|
||||||
timeout: 100 * time.Millisecond,
|
|
||||||
conn: conn,
|
conn: conn,
|
||||||
mixerAddr: mixerAddr,
|
mixerAddr: mixerAddr,
|
||||||
parser: newParser(),
|
parser: newParser(),
|
||||||
@ -86,35 +85,32 @@ func (c *Client) SendMessage(address string, args ...any) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ReceiveMessage receives an OSC message from the mixer
|
// ReceiveMessage receives an OSC message from the mixer
|
||||||
func (c *Client) ReceiveMessage() (*osc.Message, error) {
|
func (c *Client) ReceiveMessage(timeout time.Duration) (*osc.Message, error) {
|
||||||
t := time.Tick(c.engine.timeout)
|
t := time.Tick(timeout)
|
||||||
select {
|
select {
|
||||||
case <-t:
|
case <-t:
|
||||||
return nil, fmt.Errorf("timeout waiting for response")
|
return nil, nil
|
||||||
case msg := <-c.respChan:
|
case val := <-c.respChan:
|
||||||
if msg == nil {
|
if val == nil {
|
||||||
return nil, fmt.Errorf("no message received")
|
return nil, fmt.Errorf("no message received")
|
||||||
}
|
}
|
||||||
return msg, nil
|
return val, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RequestInfo requests mixer information
|
// RequestInfo requests mixer information
|
||||||
func (c *Client) RequestInfo() (InfoResponse, error) {
|
func (c *Client) RequestInfo() (InfoResponse, error) {
|
||||||
var info InfoResponse
|
|
||||||
err := c.SendMessage("/xinfo")
|
err := c.SendMessage("/xinfo")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return info, err
|
return InfoResponse{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := c.ReceiveMessage()
|
val := <-c.respChan
|
||||||
if err != nil {
|
var info InfoResponse
|
||||||
return info, err
|
if len(val.Arguments) >= 3 {
|
||||||
}
|
info.Host = val.Arguments[0].(string)
|
||||||
if len(msg.Arguments) >= 3 {
|
info.Name = val.Arguments[1].(string)
|
||||||
info.Host = msg.Arguments[0].(string)
|
info.Model = val.Arguments[2].(string)
|
||||||
info.Name = msg.Arguments[1].(string)
|
|
||||||
info.Model = msg.Arguments[2].(string)
|
|
||||||
}
|
}
|
||||||
return info, nil
|
return info, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,11 +31,8 @@ func (c *Comp) On(index int) (bool, error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := c.client.ReceiveMessage()
|
resp := <-c.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(int32)
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(int32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, fmt.Errorf("unexpected argument type for Compressor on value")
|
return false, fmt.Errorf("unexpected argument type for Compressor on value")
|
||||||
}
|
}
|
||||||
@ -62,11 +59,8 @@ func (c *Comp) Mode(index int) (string, error) {
|
|||||||
|
|
||||||
possibleModes := []string{"comp", "exp"}
|
possibleModes := []string{"comp", "exp"}
|
||||||
|
|
||||||
msg, err := c.client.ReceiveMessage()
|
resp := <-c.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(int32)
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(int32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", fmt.Errorf("unexpected argument type for Compressor mode value")
|
return "", fmt.Errorf("unexpected argument type for Compressor mode value")
|
||||||
}
|
}
|
||||||
@ -88,11 +82,8 @@ func (c *Comp) Threshold(index int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := c.client.ReceiveMessage()
|
resp := <-c.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(float32)
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(float32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for Compressor threshold value")
|
return 0, fmt.Errorf("unexpected argument type for Compressor threshold value")
|
||||||
}
|
}
|
||||||
@ -115,11 +106,8 @@ func (c *Comp) Ratio(index int) (float32, error) {
|
|||||||
|
|
||||||
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}
|
||||||
|
|
||||||
msg, err := c.client.ReceiveMessage()
|
resp := <-c.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(int32)
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(int32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for Compressor ratio value")
|
return 0, fmt.Errorf("unexpected argument type for Compressor ratio value")
|
||||||
}
|
}
|
||||||
@ -143,11 +131,8 @@ func (c *Comp) Attack(index int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := c.client.ReceiveMessage()
|
resp := <-c.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(float32)
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(float32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for Compressor attack value")
|
return 0, fmt.Errorf("unexpected argument type for Compressor attack value")
|
||||||
}
|
}
|
||||||
@ -168,11 +153,8 @@ func (c *Comp) Hold(index int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := c.client.ReceiveMessage()
|
resp := <-c.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(float32)
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(float32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for Compressor hold value")
|
return 0, fmt.Errorf("unexpected argument type for Compressor hold value")
|
||||||
}
|
}
|
||||||
@ -193,11 +175,8 @@ func (c *Comp) Release(index int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := c.client.ReceiveMessage()
|
resp := <-c.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(float32)
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(float32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for Compressor release value")
|
return 0, fmt.Errorf("unexpected argument type for Compressor release value")
|
||||||
}
|
}
|
||||||
@ -218,11 +197,8 @@ func (c *Comp) Makeup(index int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := c.client.ReceiveMessage()
|
resp := <-c.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(float32)
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(float32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for Compressor makeup gain value")
|
return 0, fmt.Errorf("unexpected argument type for Compressor makeup gain value")
|
||||||
}
|
}
|
||||||
@ -243,11 +219,8 @@ func (c *Comp) Mix(index int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := c.client.ReceiveMessage()
|
resp := <-c.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(float32)
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(float32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for Compressor mix value")
|
return 0, fmt.Errorf("unexpected argument type for Compressor mix value")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,6 @@ type parser interface {
|
|||||||
|
|
||||||
type engine struct {
|
type engine struct {
|
||||||
Kind MixerKind
|
Kind MixerKind
|
||||||
timeout time.Duration
|
|
||||||
conn *net.UDPConn
|
conn *net.UDPConn
|
||||||
mixerAddr *net.UDPAddr
|
mixerAddr *net.UDPAddr
|
||||||
|
|
||||||
@ -35,7 +34,7 @@ func (e *engine) receiveLoop() {
|
|||||||
case <-e.done:
|
case <-e.done:
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
// Set a short read deadline to prevent blocking indefinitely
|
// Set read timeout to avoid blocking forever
|
||||||
e.conn.SetReadDeadline(time.Now().Add(100 * time.Millisecond))
|
e.conn.SetReadDeadline(time.Now().Add(100 * time.Millisecond))
|
||||||
n, _, err := e.conn.ReadFromUDP(buffer)
|
n, _, err := e.conn.ReadFromUDP(buffer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -31,11 +31,8 @@ func (e *Eq) On(index int) (bool, error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := e.client.ReceiveMessage()
|
resp := <-e.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(int32)
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(int32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, fmt.Errorf("unexpected argument type for EQ on value")
|
return false, fmt.Errorf("unexpected argument type for EQ on value")
|
||||||
}
|
}
|
||||||
@ -61,11 +58,8 @@ func (e *Eq) Mode(index int) (string, error) {
|
|||||||
|
|
||||||
possibleModes := []string{"peq", "geq", "teq"}
|
possibleModes := []string{"peq", "geq", "teq"}
|
||||||
|
|
||||||
msg, err := e.client.ReceiveMessage()
|
resp := <-e.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(int32)
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(int32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", fmt.Errorf("unexpected argument type for EQ mode value")
|
return "", fmt.Errorf("unexpected argument type for EQ mode value")
|
||||||
}
|
}
|
||||||
@ -86,11 +80,8 @@ func (e *Eq) Gain(index int, band int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := e.client.ReceiveMessage()
|
resp := <-e.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(float32)
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(float32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for EQ gain value")
|
return 0, fmt.Errorf("unexpected argument type for EQ gain value")
|
||||||
}
|
}
|
||||||
@ -111,11 +102,8 @@ func (e *Eq) Frequency(index int, band int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := e.client.ReceiveMessage()
|
resp := <-e.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(float32)
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(float32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for EQ frequency value")
|
return 0, fmt.Errorf("unexpected argument type for EQ frequency value")
|
||||||
}
|
}
|
||||||
@ -136,11 +124,8 @@ func (e *Eq) Q(index int, band int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := e.client.ReceiveMessage()
|
resp := <-e.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(float32)
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(float32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for EQ Q value")
|
return 0, fmt.Errorf("unexpected argument type for EQ Q value")
|
||||||
}
|
}
|
||||||
@ -163,11 +148,8 @@ func (e *Eq) Type(index int, band int) (string, error) {
|
|||||||
|
|
||||||
possibleTypes := []string{"lcut", "lshv", "peq", "veq", "hshv", "hcut"}
|
possibleTypes := []string{"lcut", "lshv", "peq", "veq", "hshv", "hcut"}
|
||||||
|
|
||||||
msg, err := e.client.ReceiveMessage()
|
resp := <-e.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(int32)
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(int32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", fmt.Errorf("unexpected argument type for EQ type value")
|
return "", fmt.Errorf("unexpected argument type for EQ type value")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,11 +19,8 @@ func (g *Gate) On(index int) (bool, error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := g.client.ReceiveMessage()
|
resp := <-g.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(int32)
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(int32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, fmt.Errorf("unexpected argument type for Gate on value")
|
return false, fmt.Errorf("unexpected argument type for Gate on value")
|
||||||
}
|
}
|
||||||
@ -50,11 +47,8 @@ func (g *Gate) Mode(index int) (string, error) {
|
|||||||
|
|
||||||
possibleModes := []string{"exp2", "exp3", "exp4", "gate", "duck"}
|
possibleModes := []string{"exp2", "exp3", "exp4", "gate", "duck"}
|
||||||
|
|
||||||
msg, err := g.client.ReceiveMessage()
|
resp := <-g.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(int32)
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(int32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", fmt.Errorf("unexpected argument type for Gate mode value")
|
return "", fmt.Errorf("unexpected argument type for Gate mode value")
|
||||||
}
|
}
|
||||||
@ -77,11 +71,8 @@ func (g *Gate) Threshold(index int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := g.client.ReceiveMessage()
|
resp := <-g.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(float32)
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(float32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for Gate threshold value")
|
return 0, fmt.Errorf("unexpected argument type for Gate threshold value")
|
||||||
}
|
}
|
||||||
@ -102,11 +93,8 @@ func (g *Gate) Range(index int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := g.client.ReceiveMessage()
|
resp := <-g.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(float32)
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(float32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for Gate range value")
|
return 0, fmt.Errorf("unexpected argument type for Gate range value")
|
||||||
}
|
}
|
||||||
@ -127,11 +115,8 @@ func (g *Gate) Attack(index int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := g.client.ReceiveMessage()
|
resp := <-g.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(float32)
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(float32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for Gate attack value")
|
return 0, fmt.Errorf("unexpected argument type for Gate attack value")
|
||||||
}
|
}
|
||||||
@ -152,11 +137,8 @@ func (g *Gate) Hold(index int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := g.client.ReceiveMessage()
|
resp := <-g.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(float32)
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(float32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for Gate hold value")
|
return 0, fmt.Errorf("unexpected argument type for Gate hold value")
|
||||||
}
|
}
|
||||||
@ -177,11 +159,8 @@ func (g *Gate) Release(index int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := g.client.ReceiveMessage()
|
resp := <-g.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(float32)
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(float32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for Gate release value")
|
return 0, fmt.Errorf("unexpected argument type for Gate release value")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,11 +22,8 @@ func (h *HeadAmp) Gain(index int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := h.client.ReceiveMessage()
|
resp := <-h.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(float32)
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(float32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for headamp gain value")
|
return 0, fmt.Errorf("unexpected argument type for headamp gain value")
|
||||||
}
|
}
|
||||||
@ -48,11 +45,8 @@ func (h *HeadAmp) PhantomPower(index int) (bool, error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := h.client.ReceiveMessage()
|
resp := <-h.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(int32)
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(int32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, fmt.Errorf("unexpected argument type for phantom power value")
|
return false, fmt.Errorf("unexpected argument type for phantom power value")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,11 +31,8 @@ func (m *Main) Fader() (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := m.client.ReceiveMessage()
|
resp := <-m.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(float32)
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(float32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for main LR fader value")
|
return 0, fmt.Errorf("unexpected argument type for main LR fader value")
|
||||||
}
|
}
|
||||||
@ -56,11 +53,8 @@ func (m *Main) Mute() (bool, error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := m.client.ReceiveMessage()
|
resp := <-m.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(int32)
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(int32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, fmt.Errorf("unexpected argument type for main LR mute value")
|
return false, fmt.Errorf("unexpected argument type for main LR mute value")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
package xair
|
package xair
|
||||||
|
|
||||||
import "time"
|
|
||||||
|
|
||||||
type Option func(*engine)
|
type Option func(*engine)
|
||||||
|
|
||||||
func WithKind(kind string) Option {
|
func WithKind(kind string) Option {
|
||||||
@ -10,9 +8,3 @@ func WithKind(kind string) Option {
|
|||||||
e.addressMap = addressMapForMixerKind(e.Kind)
|
e.addressMap = addressMapForMixerKind(e.Kind)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithTimeout(timeout time.Duration) Option {
|
|
||||||
return func(e *engine) {
|
|
||||||
e.timeout = timeout
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -22,11 +22,8 @@ func (s *Snapshot) Name(index int) (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := s.client.ReceiveMessage()
|
resp := <-s.client.respChan
|
||||||
if err != nil {
|
name, ok := resp.Arguments[0].(string)
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
name, ok := msg.Arguments[0].(string)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", fmt.Errorf("unexpected argument type for snapshot name")
|
return "", fmt.Errorf("unexpected argument type for snapshot name")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,11 +28,8 @@ func (s *Strip) Mute(index int) (bool, error) {
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := s.client.ReceiveMessage()
|
resp := <-s.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(int32)
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(int32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, fmt.Errorf("unexpected argument type for strip mute value")
|
return false, fmt.Errorf("unexpected argument type for strip mute value")
|
||||||
}
|
}
|
||||||
@ -57,11 +54,8 @@ func (s *Strip) Fader(strip int) (float64, error) {
|
|||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := s.client.ReceiveMessage()
|
resp := <-s.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(float32)
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(float32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for fader value")
|
return 0, fmt.Errorf("unexpected argument type for fader value")
|
||||||
}
|
}
|
||||||
@ -83,11 +77,8 @@ func (s *Strip) Name(strip int) (string, error) {
|
|||||||
return "", fmt.Errorf("failed to send strip name request: %v", err)
|
return "", fmt.Errorf("failed to send strip name request: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := s.client.ReceiveMessage()
|
resp := <-s.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(string)
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(string)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", fmt.Errorf("unexpected argument type for strip name value")
|
return "", fmt.Errorf("unexpected argument type for strip name value")
|
||||||
}
|
}
|
||||||
@ -108,11 +99,8 @@ func (s *Strip) Color(strip int) (int32, error) {
|
|||||||
return 0, fmt.Errorf("failed to send strip color request: %v", err)
|
return 0, fmt.Errorf("failed to send strip color request: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := s.client.ReceiveMessage()
|
resp := <-s.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(int32)
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(int32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for strip color value")
|
return 0, fmt.Errorf("unexpected argument type for strip color value")
|
||||||
}
|
}
|
||||||
@ -133,11 +121,8 @@ func (s *Strip) SendLevel(strip int, bus int) (float64, error) {
|
|||||||
return 0, fmt.Errorf("failed to send strip send level request: %v", err)
|
return 0, fmt.Errorf("failed to send strip send level request: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := s.client.ReceiveMessage()
|
resp := <-s.client.respChan
|
||||||
if err != nil {
|
val, ok := resp.Arguments[0].(float32)
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
val, ok := msg.Arguments[0].(float32)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("unexpected argument type for strip send level value")
|
return 0, fmt.Errorf("unexpected argument type for strip send level value")
|
||||||
}
|
}
|
||||||
|
|||||||
9
main.go
9
main.go
@ -6,7 +6,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/alecthomas/kong"
|
"github.com/alecthomas/kong"
|
||||||
"github.com/charmbracelet/log"
|
"github.com/charmbracelet/log"
|
||||||
@ -36,7 +35,6 @@ type Config struct {
|
|||||||
Host string `default:"mixer.local" help:"The host of the X-Air device." env:"XAIR_CLI_HOST" short:"H"`
|
Host string `default:"mixer.local" help:"The host of the X-Air device." env:"XAIR_CLI_HOST" short:"H"`
|
||||||
Port int `default:"10024" help:"The port of the X-Air device." env:"XAIR_CLI_PORT" short:"P"`
|
Port int `default:"10024" help:"The port of the X-Air device." env:"XAIR_CLI_PORT" short:"P"`
|
||||||
Kind string `default:"xair" help:"The kind of the X-Air device." env:"XAIR_CLI_KIND" short:"K" enum:"xair,x32"`
|
Kind string `default:"xair" help:"The kind of the X-Air device." env:"XAIR_CLI_KIND" short:"K" enum:"xair,x32"`
|
||||||
Timeout time.Duration `default:"100ms" help:"Timeout for OSC operations." env:"XAIR_CLI_TIMEOUT" short:"T"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CLI is the main struct for the command-line interface.
|
// CLI is the main struct for the command-line interface.
|
||||||
@ -109,12 +107,7 @@ func run(ctx *kong.Context, config Config) error {
|
|||||||
|
|
||||||
// connect creates a new X-Air client based on the provided configuration.
|
// connect creates a new X-Air client based on the provided configuration.
|
||||||
func connect(config Config) (*xair.Client, error) {
|
func connect(config Config) (*xair.Client, error) {
|
||||||
client, err := xair.NewClient(
|
client, err := xair.NewClient(config.Host, config.Port, xair.WithKind(config.Kind))
|
||||||
config.Host,
|
|
||||||
config.Port,
|
|
||||||
xair.WithKind(config.Kind),
|
|
||||||
xair.WithTimeout(config.Timeout),
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
11
raw.go
11
raw.go
@ -2,12 +2,12 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
"github.com/charmbracelet/log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// RawCmd represents the command to send raw OSC messages to the mixer.
|
// RawCmd represents the command to send raw OSC messages to the mixer.
|
||||||
type RawCmd struct {
|
type RawCmd struct {
|
||||||
|
Timeout time.Duration `help:"Timeout for the OSC message send operation." default:"100ms" short:"t" env:"XAIR_CLI_RAW_TIMEOUT"`
|
||||||
Address string `help:"The OSC address to send the message to." arg:""`
|
Address string `help:"The OSC address to send the message to." arg:""`
|
||||||
Args []string `help:"The arguments to include in the OSC message." arg:"" optional:""`
|
Args []string `help:"The arguments to include in the OSC message." arg:"" optional:""`
|
||||||
}
|
}
|
||||||
@ -22,12 +22,7 @@ func (cmd *RawCmd) Run(ctx *context) error {
|
|||||||
return fmt.Errorf("failed to send raw OSC message: %w", err)
|
return fmt.Errorf("failed to send raw OSC message: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(params) > 0 {
|
msg, err := ctx.Client.ReceiveMessage(cmd.Timeout)
|
||||||
log.Debugf("Sent OSC message: %s with args: %v\n", cmd.Address, cmd.Args)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := ctx.Client.ReceiveMessage()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to receive response for raw OSC message: %w", err)
|
return fmt.Errorf("failed to receive response for raw OSC message: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user