4 Commits

Author SHA1 Message Date
58866b794b implement info command
upd help mds
2026-02-11 21:47:56 +00:00
32a09db1a4 unexport client 2026-02-11 21:25:40 +00:00
106f896c45 upd strip send docstrings/help messages 2026-02-11 09:26:23 +00:00
6615eec466 mark eq/band index args as optional. this lets us differentiate between not set and zero.
add Validate method to SnapshotCmdGroup
2026-02-10 14:16:35 +00:00
28 changed files with 392 additions and 302 deletions

View File

@@ -172,7 +172,7 @@ type BusEqCmdGroup struct {
On BusEqOnCmd `help:"Get or set the EQ on/off state of the bus." cmd:"on"` On BusEqOnCmd `help:"Get or set the EQ on/off state of the bus." cmd:"on"`
Mode BusEqModeCmd `help:"Get or set the EQ mode of the bus (peq, geq or teq)." cmd:"mode"` Mode BusEqModeCmd `help:"Get or set the EQ mode of the bus (peq, geq or teq)." cmd:"mode"`
Band struct { Band struct {
Band int `arg:"" help:"The EQ band number."` Band *int `arg:"" help:"The EQ band number." optional:""`
Gain BusEqBandGainCmd `help:"Get or set the gain of the EQ band." cmd:"gain"` Gain BusEqBandGainCmd `help:"Get or set the gain of the EQ band." cmd:"gain"`
Freq BusEqBandFreqCmd `help:"Get or set the frequency of the EQ band." cmd:"freq"` Freq BusEqBandFreqCmd `help:"Get or set the frequency of the EQ band." cmd:"freq"`
Q BusEqBandQCmd `help:"Get or set the Q factor of the EQ band." cmd:"q"` Q BusEqBandQCmd `help:"Get or set the Q factor of the EQ band." cmd:"q"`
@@ -182,12 +182,12 @@ type BusEqCmdGroup struct {
// Validate checks that the provided EQ band number is within the valid range (1-6). // Validate checks that the provided EQ band number is within the valid range (1-6).
func (cmd *BusEqCmdGroup) Validate() error { func (cmd *BusEqCmdGroup) Validate() error {
if cmd.Band.Band == 0 { if cmd.Band.Band == nil {
return nil return nil
} }
if cmd.Band.Band < 1 || cmd.Band.Band > 6 { if *cmd.Band.Band < 1 || *cmd.Band.Band > 6 {
return fmt.Errorf("EQ band number must be between 1 and 6, got %d", cmd.Band.Band) return fmt.Errorf("EQ band number must be between 1 and 6, got %d", *cmd.Band.Band)
} }
return nil return nil
} }
@@ -246,18 +246,18 @@ type BusEqBandGainCmd struct {
// Run executes the BusEqBandGainCmd command, either retrieving the current gain of the specified EQ band of the bus or setting it based on the provided argument. // Run executes the BusEqBandGainCmd command, either retrieving the current gain of the specified EQ band of the bus or setting it based on the provided argument.
func (cmd *BusEqBandGainCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGroup) error { func (cmd *BusEqBandGainCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGroup) error {
if cmd.Gain == nil { if cmd.Gain == nil {
resp, err := ctx.Client.Bus.Eq.Gain(bus.Index.Index, busEq.Band.Band) resp, err := ctx.Client.Bus.Eq.Gain(bus.Index.Index, *busEq.Band.Band)
if err != nil { if err != nil {
return err return err
} }
fmt.Fprintf(ctx.Out, "Bus %d EQ band %d gain: %.2f dB\n", bus.Index.Index, busEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Bus %d EQ band %d gain: %.2f dB\n", bus.Index.Index, *busEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Bus.Eq.SetGain(bus.Index.Index, busEq.Band.Band, *cmd.Gain); err != nil { if err := ctx.Client.Bus.Eq.SetGain(bus.Index.Index, *busEq.Band.Band, *cmd.Gain); err != nil {
return err return err
} }
fmt.Fprintf(ctx.Out, "Bus %d EQ band %d gain set to: %.2f dB\n", bus.Index.Index, busEq.Band.Band, *cmd.Gain) fmt.Fprintf(ctx.Out, "Bus %d EQ band %d gain set to: %.2f dB\n", bus.Index.Index, *busEq.Band.Band, *cmd.Gain)
return nil return nil
} }
@@ -269,18 +269,18 @@ type BusEqBandFreqCmd struct {
// Run executes the BusEqBandFreqCmd command, either retrieving the current frequency of the specified EQ band of the bus or setting it based on the provided argument. // Run executes the BusEqBandFreqCmd command, either retrieving the current frequency of the specified EQ band of the bus or setting it based on the provided argument.
func (cmd *BusEqBandFreqCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGroup) error { func (cmd *BusEqBandFreqCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGroup) error {
if cmd.Freq == nil { if cmd.Freq == nil {
resp, err := ctx.Client.Bus.Eq.Frequency(bus.Index.Index, busEq.Band.Band) resp, err := ctx.Client.Bus.Eq.Frequency(bus.Index.Index, *busEq.Band.Band)
if err != nil { if err != nil {
return err return err
} }
fmt.Fprintf(ctx.Out, "Bus %d EQ band %d frequency: %.2f Hz\n", bus.Index.Index, busEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Bus %d EQ band %d frequency: %.2f Hz\n", bus.Index.Index, *busEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Bus.Eq.SetFrequency(bus.Index.Index, busEq.Band.Band, *cmd.Freq); err != nil { if err := ctx.Client.Bus.Eq.SetFrequency(bus.Index.Index, *busEq.Band.Band, *cmd.Freq); err != nil {
return err return err
} }
fmt.Fprintf(ctx.Out, "Bus %d EQ band %d frequency set to: %.2f Hz\n", bus.Index.Index, busEq.Band.Band, *cmd.Freq) fmt.Fprintf(ctx.Out, "Bus %d EQ band %d frequency set to: %.2f Hz\n", bus.Index.Index, *busEq.Band.Band, *cmd.Freq)
return nil return nil
} }
@@ -292,18 +292,18 @@ type BusEqBandQCmd struct {
// Run executes the BusEqBandQCmd command, either retrieving the current Q factor of the specified EQ band of the bus or setting it based on the provided argument. // Run executes the BusEqBandQCmd command, either retrieving the current Q factor of the specified EQ band of the bus or setting it based on the provided argument.
func (cmd *BusEqBandQCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGroup) error { func (cmd *BusEqBandQCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGroup) error {
if cmd.Q == nil { if cmd.Q == nil {
resp, err := ctx.Client.Bus.Eq.Q(bus.Index.Index, busEq.Band.Band) resp, err := ctx.Client.Bus.Eq.Q(bus.Index.Index, *busEq.Band.Band)
if err != nil { if err != nil {
return err return err
} }
fmt.Fprintf(ctx.Out, "Bus %d EQ band %d Q factor: %.2f\n", bus.Index.Index, busEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Bus %d EQ band %d Q factor: %.2f\n", bus.Index.Index, *busEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Bus.Eq.SetQ(bus.Index.Index, busEq.Band.Band, *cmd.Q); err != nil { if err := ctx.Client.Bus.Eq.SetQ(bus.Index.Index, *busEq.Band.Band, *cmd.Q); err != nil {
return err return err
} }
fmt.Fprintf(ctx.Out, "Bus %d EQ band %d Q factor set to: %.2f\n", bus.Index.Index, busEq.Band.Band, *cmd.Q) fmt.Fprintf(ctx.Out, "Bus %d EQ band %d Q factor set to: %.2f\n", bus.Index.Index, *busEq.Band.Band, *cmd.Q)
return nil return nil
} }
@@ -315,18 +315,18 @@ type BusEqBandTypeCmd struct {
// Run executes the BusEqBandTypeCmd command, either retrieving the current type of the specified EQ band of the bus or setting it based on the provided argument. // Run executes the BusEqBandTypeCmd command, either retrieving the current type of the specified EQ band of the bus or setting it based on the provided argument.
func (cmd *BusEqBandTypeCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGroup) error { func (cmd *BusEqBandTypeCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGroup) error {
if cmd.Type == nil { if cmd.Type == nil {
resp, err := ctx.Client.Bus.Eq.Type(bus.Index.Index, busEq.Band.Band) resp, err := ctx.Client.Bus.Eq.Type(bus.Index.Index, *busEq.Band.Band)
if err != nil { if err != nil {
return err return err
} }
fmt.Fprintf(ctx.Out, "Bus %d EQ band %d type: %s\n", bus.Index.Index, busEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Bus %d EQ band %d type: %s\n", bus.Index.Index, *busEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Bus.Eq.SetType(bus.Index.Index, busEq.Band.Band, *cmd.Type); err != nil { if err := ctx.Client.Bus.Eq.SetType(bus.Index.Index, *busEq.Band.Band, *cmd.Type); err != nil {
return err return err
} }
fmt.Fprintf(ctx.Out, "Bus %d EQ band %d type set to: %s\n", bus.Index.Index, busEq.Band.Band, *cmd.Type) fmt.Fprintf(ctx.Out, "Bus %d EQ band %d type set to: %s\n", bus.Index.Index, *busEq.Band.Band, *cmd.Type)
return nil return nil
} }

View File

@@ -46,9 +46,10 @@ type CLI struct {
Version VersionFlag `help:"Print x32-cli version information and quit" name:"version" short:"v"` Version VersionFlag `help:"Print x32-cli version information and quit" name:"version" short:"v"`
Completion kongcompletion.Completion `help:"Generate shell completion scripts." cmd:"" aliases:"c"` Completion kongcompletion.Completion `help:"Generate shell completion scripts." cmd:""`
Info InfoCmd `help:"Print mixer information." cmd:""`
Raw RawCmd `help:"Send raw OSC messages to the mixer." cmd:""`
Raw RawCmd `help:"Send raw OSC messages to the mixer." cmd:"" group:"Raw"`
Main MainCmdGroup `help:"Control the Main L/R output" cmd:"" group:"Main"` Main MainCmdGroup `help:"Control the Main L/R output" cmd:"" group:"Main"`
Mainmono MainMonoCmdGroup `help:"Control the Main Mono output" cmd:"" group:"MainMono"` Mainmono MainMonoCmdGroup `help:"Control the Main Mono output" cmd:"" group:"MainMono"`
Matrix MatrixCmdGroup `help:"Control the matrix outputs." cmd:"" group:"Matrix"` Matrix MatrixCmdGroup `help:"Control the matrix outputs." cmd:"" group:"Matrix"`

18
cmd/x32-cli/info.go Normal file
View File

@@ -0,0 +1,18 @@
package main
import "fmt"
type InfoCmd struct {
}
func (c *InfoCmd) Run(ctx *context) error {
fmt.Fprintf(
ctx.Out,
"Host: %s | Name: %s | Model: %s | Firmware: %s\n",
ctx.Client.Info.Host,
ctx.Client.Info.Name,
ctx.Client.Info.Model,
ctx.Client.Info.Firmware,
)
return nil
}

View File

@@ -135,7 +135,7 @@ func (cmd *MainFadeoutCmd) Run(ctx *context) error {
type MainEqCmdGroup struct { type MainEqCmdGroup struct {
On MainEqOnCmd `help:"Get or set the EQ on/off state of the Main L/R output." cmd:"on"` On MainEqOnCmd `help:"Get or set the EQ on/off state of the Main L/R output." cmd:"on"`
Band struct { Band struct {
Band int `arg:"" help:"The EQ band number."` Band *int `arg:"" help:"The EQ band number." optional:""`
Gain MainEqBandGainCmd `help:"Get or set the gain of the specified EQ band." cmd:"gain"` Gain MainEqBandGainCmd `help:"Get or set the gain of the specified EQ band." cmd:"gain"`
Freq MainEqBandFreqCmd `help:"Get or set the frequency of the specified EQ band." cmd:"freq"` Freq MainEqBandFreqCmd `help:"Get or set the frequency of the specified EQ band." cmd:"freq"`
Q MainEqBandQCmd `help:"Get or set the Q factor of the specified EQ band." cmd:"q"` Q MainEqBandQCmd `help:"Get or set the Q factor of the specified EQ band." cmd:"q"`
@@ -145,12 +145,12 @@ type MainEqCmdGroup struct {
// Validate checks if the provided EQ band number is within the valid range (1-6) for the Main L/R output. // Validate checks if the provided EQ band number is within the valid range (1-6) for the Main L/R output.
func (cmd *MainEqCmdGroup) Validate() error { func (cmd *MainEqCmdGroup) Validate() error {
if cmd.Band.Band == 0 { if cmd.Band.Band == nil {
return nil return nil
} }
if cmd.Band.Band < 1 || cmd.Band.Band > 6 { if *cmd.Band.Band < 1 || *cmd.Band.Band > 6 {
return fmt.Errorf("EQ band number must be between 1 and 6, got %d", cmd.Band.Band) return fmt.Errorf("EQ band number must be between 1 and 6, got %d", *cmd.Band.Band)
} }
return nil return nil
} }
@@ -186,18 +186,18 @@ type MainEqBandGainCmd struct {
// Run executes the MainEqBandGainCmd command, either retrieving the current gain of a specific EQ band on the Main L/R output or setting it based on the provided argument. // Run executes the MainEqBandGainCmd command, either retrieving the current gain of a specific EQ band on the Main L/R output or setting it based on the provided argument.
func (cmd *MainEqBandGainCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainEqCmdGroup) error { func (cmd *MainEqBandGainCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainEqCmdGroup) error {
if cmd.Level == nil { if cmd.Level == nil {
resp, err := ctx.Client.Main.Eq.Gain(0, mainEq.Band.Band) resp, err := ctx.Client.Main.Eq.Gain(0, *mainEq.Band.Band)
if err != nil { if err != nil {
return fmt.Errorf("failed to get Main L/R EQ band %d gain: %w", mainEq.Band.Band, err) return fmt.Errorf("failed to get Main L/R EQ band %d gain: %w", *mainEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d gain: %.2f dB\n", mainEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Main L/R EQ band %d gain: %.2f dB\n", *mainEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Main.Eq.SetGain(0, mainEq.Band.Band, *cmd.Level); err != nil { if err := ctx.Client.Main.Eq.SetGain(0, *mainEq.Band.Band, *cmd.Level); err != nil {
return fmt.Errorf("failed to set Main L/R EQ band %d gain: %w", mainEq.Band.Band, err) return fmt.Errorf("failed to set Main L/R EQ band %d gain: %w", *mainEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d gain set to: %.2f dB\n", mainEq.Band.Band, *cmd.Level) fmt.Fprintf(ctx.Out, "Main L/R EQ band %d gain set to: %.2f dB\n", *mainEq.Band.Band, *cmd.Level)
return nil return nil
} }
@@ -209,18 +209,18 @@ type MainEqBandFreqCmd struct {
// Run executes the MainEqBandFreqCmd command, either retrieving the current frequency of a specific EQ band on the Main L/R output or setting it based on the provided argument. // Run executes the MainEqBandFreqCmd command, either retrieving the current frequency of a specific EQ band on the Main L/R output or setting it based on the provided argument.
func (cmd *MainEqBandFreqCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainEqCmdGroup) error { func (cmd *MainEqBandFreqCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainEqCmdGroup) error {
if cmd.Frequency == nil { if cmd.Frequency == nil {
resp, err := ctx.Client.Main.Eq.Frequency(0, mainEq.Band.Band) resp, err := ctx.Client.Main.Eq.Frequency(0, *mainEq.Band.Band)
if err != nil { if err != nil {
return fmt.Errorf("failed to get Main L/R EQ band %d frequency: %w", mainEq.Band.Band, err) return fmt.Errorf("failed to get Main L/R EQ band %d frequency: %w", *mainEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d frequency: %.2f Hz\n", mainEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Main L/R EQ band %d frequency: %.2f Hz\n", *mainEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Main.Eq.SetFrequency(0, mainEq.Band.Band, *cmd.Frequency); err != nil { if err := ctx.Client.Main.Eq.SetFrequency(0, *mainEq.Band.Band, *cmd.Frequency); err != nil {
return fmt.Errorf("failed to set Main L/R EQ band %d frequency: %w", mainEq.Band.Band, err) return fmt.Errorf("failed to set Main L/R EQ band %d frequency: %w", *mainEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d frequency set to: %.2f Hz\n", mainEq.Band.Band, *cmd.Frequency) fmt.Fprintf(ctx.Out, "Main L/R EQ band %d frequency set to: %.2f Hz\n", *mainEq.Band.Band, *cmd.Frequency)
return nil return nil
} }
@@ -232,18 +232,18 @@ type MainEqBandQCmd struct {
// Run executes the MainEqBandQCmd command, either retrieving the current Q factor of a specific EQ band on the Main L/R output or setting it based on the provided argument. // Run executes the MainEqBandQCmd command, either retrieving the current Q factor of a specific EQ band on the Main L/R output or setting it based on the provided argument.
func (cmd *MainEqBandQCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainEqCmdGroup) error { func (cmd *MainEqBandQCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainEqCmdGroup) error {
if cmd.Q == nil { if cmd.Q == nil {
resp, err := ctx.Client.Main.Eq.Q(0, mainEq.Band.Band) resp, err := ctx.Client.Main.Eq.Q(0, *mainEq.Band.Band)
if err != nil { if err != nil {
return fmt.Errorf("failed to get Main L/R EQ band %d Q factor: %w", mainEq.Band.Band, err) return fmt.Errorf("failed to get Main L/R EQ band %d Q factor: %w", *mainEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d Q factor: %.2f\n", mainEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Main L/R EQ band %d Q factor: %.2f\n", *mainEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Main.Eq.SetQ(0, mainEq.Band.Band, *cmd.Q); err != nil { if err := ctx.Client.Main.Eq.SetQ(0, *mainEq.Band.Band, *cmd.Q); err != nil {
return fmt.Errorf("failed to set Main L/R EQ band %d Q factor: %w", mainEq.Band.Band, err) return fmt.Errorf("failed to set Main L/R EQ band %d Q factor: %w", *mainEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d Q factor set to: %.2f\n", mainEq.Band.Band, *cmd.Q) fmt.Fprintf(ctx.Out, "Main L/R EQ band %d Q factor set to: %.2f\n", *mainEq.Band.Band, *cmd.Q)
return nil return nil
} }
@@ -255,18 +255,18 @@ type MainEqBandTypeCmd struct {
// Run executes the MainEqBandTypeCmd command, either retrieving the current type of a specific EQ band on the Main L/R output or setting it based on the provided argument. // Run executes the MainEqBandTypeCmd command, either retrieving the current type of a specific EQ band on the Main L/R output or setting it based on the provided argument.
func (cmd *MainEqBandTypeCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainEqCmdGroup) error { func (cmd *MainEqBandTypeCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainEqCmdGroup) error {
if cmd.Type == nil { if cmd.Type == nil {
resp, err := ctx.Client.Main.Eq.Type(0, mainEq.Band.Band) resp, err := ctx.Client.Main.Eq.Type(0, *mainEq.Band.Band)
if err != nil { if err != nil {
return fmt.Errorf("failed to get Main L/R EQ band %d type: %w", mainEq.Band.Band, err) return fmt.Errorf("failed to get Main L/R EQ band %d type: %w", *mainEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d type: %s\n", mainEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Main L/R EQ band %d type: %s\n", *mainEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Main.Eq.SetType(0, mainEq.Band.Band, *cmd.Type); err != nil { if err := ctx.Client.Main.Eq.SetType(0, *mainEq.Band.Band, *cmd.Type); err != nil {
return fmt.Errorf("failed to set Main L/R EQ band %d type: %w", mainEq.Band.Band, err) return fmt.Errorf("failed to set Main L/R EQ band %d type: %w", *mainEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d type set to: %s\n", mainEq.Band.Band, *cmd.Type) fmt.Fprintf(ctx.Out, "Main L/R EQ band %d type set to: %s\n", *mainEq.Band.Band, *cmd.Type)
return nil return nil
} }

View File

@@ -135,7 +135,7 @@ func (cmd *MainMonoFadeoutCmd) Run(ctx *context) error {
type MainMonoEqCmdGroup struct { type MainMonoEqCmdGroup struct {
On MainMonoEqOnCmd `help:"Get or set the EQ on/off state of the Main Mono output." cmd:"on"` On MainMonoEqOnCmd `help:"Get or set the EQ on/off state of the Main Mono output." cmd:"on"`
Band struct { Band struct {
Band int `arg:"" help:"The EQ band number."` Band *int `arg:"" help:"The EQ band number." optional:""`
Gain MainMonoEqBandGainCmd `help:"Get or set the gain of the specified EQ band." cmd:"gain"` Gain MainMonoEqBandGainCmd `help:"Get or set the gain of the specified EQ band." cmd:"gain"`
Freq MainMonoEqBandFreqCmd `help:"Get or set the frequency of the specified EQ band." cmd:"freq"` Freq MainMonoEqBandFreqCmd `help:"Get or set the frequency of the specified EQ band." cmd:"freq"`
Q MainMonoEqBandQCmd `help:"Get or set the Q factor of the specified EQ band." cmd:"q"` Q MainMonoEqBandQCmd `help:"Get or set the Q factor of the specified EQ band." cmd:"q"`
@@ -145,12 +145,12 @@ type MainMonoEqCmdGroup struct {
// Validate checks if the provided EQ band number is within the valid range (1-6) for the Main Mono output. // Validate checks if the provided EQ band number is within the valid range (1-6) for the Main Mono output.
func (cmd *MainMonoEqCmdGroup) Validate() error { func (cmd *MainMonoEqCmdGroup) Validate() error {
if cmd.Band.Band == 0 { if cmd.Band.Band == nil {
return nil return nil
} }
if cmd.Band.Band < 1 || cmd.Band.Band > 6 { if *cmd.Band.Band < 1 || *cmd.Band.Band > 6 {
return fmt.Errorf("EQ band number must be between 1 and 6, got %d", cmd.Band.Band) return fmt.Errorf("EQ band number must be between 1 and 6, got %d", *cmd.Band.Band)
} }
return nil return nil
} }
@@ -186,18 +186,18 @@ type MainMonoEqBandGainCmd struct {
// Run executes the MainMonoEqBandGainCmd command, either retrieving the current gain of a specific EQ band on the Main Mono output or setting it based on the provided argument. // Run executes the MainMonoEqBandGainCmd command, either retrieving the current gain of a specific EQ band on the Main Mono output or setting it based on the provided argument.
func (cmd *MainMonoEqBandGainCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainMonoEqCmdGroup) error { func (cmd *MainMonoEqBandGainCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainMonoEqCmdGroup) error {
if cmd.Level == nil { if cmd.Level == nil {
resp, err := ctx.Client.MainMono.Eq.Gain(0, mainEq.Band.Band) resp, err := ctx.Client.MainMono.Eq.Gain(0, *mainEq.Band.Band)
if err != nil { if err != nil {
return fmt.Errorf("failed to get Main Mono EQ band %d gain: %w", mainEq.Band.Band, err) return fmt.Errorf("failed to get Main Mono EQ band %d gain: %w", *mainEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Main Mono EQ band %d gain: %.2f dB\n", mainEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Main Mono EQ band %d gain: %.2f dB\n", *mainEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.MainMono.Eq.SetGain(0, mainEq.Band.Band, *cmd.Level); err != nil { if err := ctx.Client.MainMono.Eq.SetGain(0, *mainEq.Band.Band, *cmd.Level); err != nil {
return fmt.Errorf("failed to set Main Mono EQ band %d gain: %w", mainEq.Band.Band, err) return fmt.Errorf("failed to set Main Mono EQ band %d gain: %w", *mainEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Main Mono EQ band %d gain set to: %.2f dB\n", mainEq.Band.Band, *cmd.Level) fmt.Fprintf(ctx.Out, "Main Mono EQ band %d gain set to: %.2f dB\n", *mainEq.Band.Band, *cmd.Level)
return nil return nil
} }
@@ -209,18 +209,18 @@ type MainMonoEqBandFreqCmd struct {
// Run executes the MainMonoEqBandFreqCmd command, either retrieving the current frequency of a specific EQ band on the Main Mono output or setting it based on the provided argument. // Run executes the MainMonoEqBandFreqCmd command, either retrieving the current frequency of a specific EQ band on the Main Mono output or setting it based on the provided argument.
func (cmd *MainMonoEqBandFreqCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainMonoEqCmdGroup) error { func (cmd *MainMonoEqBandFreqCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainMonoEqCmdGroup) error {
if cmd.Frequency == nil { if cmd.Frequency == nil {
resp, err := ctx.Client.MainMono.Eq.Frequency(0, mainEq.Band.Band) resp, err := ctx.Client.MainMono.Eq.Frequency(0, *mainEq.Band.Band)
if err != nil { if err != nil {
return fmt.Errorf("failed to get Main Mono EQ band %d frequency: %w", mainEq.Band.Band, err) return fmt.Errorf("failed to get Main Mono EQ band %d frequency: %w", *mainEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Main Mono EQ band %d frequency: %.2f Hz\n", mainEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Main Mono EQ band %d frequency: %.2f Hz\n", *mainEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.MainMono.Eq.SetFrequency(0, mainEq.Band.Band, *cmd.Frequency); err != nil { if err := ctx.Client.MainMono.Eq.SetFrequency(0, *mainEq.Band.Band, *cmd.Frequency); err != nil {
return fmt.Errorf("failed to set Main Mono EQ band %d frequency: %w", mainEq.Band.Band, err) return fmt.Errorf("failed to set Main Mono EQ band %d frequency: %w", *mainEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Main Mono EQ band %d frequency set to: %.2f Hz\n", mainEq.Band.Band, *cmd.Frequency) fmt.Fprintf(ctx.Out, "Main Mono EQ band %d frequency set to: %.2f Hz\n", *mainEq.Band.Band, *cmd.Frequency)
return nil return nil
} }
@@ -232,18 +232,18 @@ type MainMonoEqBandQCmd struct {
// Run executes the MainMonoEqBandQCmd command, either retrieving the current Q factor of a specific EQ band on the Main Mono output or setting it based on the provided argument. // Run executes the MainMonoEqBandQCmd command, either retrieving the current Q factor of a specific EQ band on the Main Mono output or setting it based on the provided argument.
func (cmd *MainMonoEqBandQCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainMonoEqCmdGroup) error { func (cmd *MainMonoEqBandQCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainMonoEqCmdGroup) error {
if cmd.Q == nil { if cmd.Q == nil {
resp, err := ctx.Client.MainMono.Eq.Q(0, mainEq.Band.Band) resp, err := ctx.Client.MainMono.Eq.Q(0, *mainEq.Band.Band)
if err != nil { if err != nil {
return fmt.Errorf("failed to get Main Mono EQ band %d Q factor: %w", mainEq.Band.Band, err) return fmt.Errorf("failed to get Main Mono EQ band %d Q factor: %w", *mainEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Main Mono EQ band %d Q factor: %.2f\n", mainEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Main Mono EQ band %d Q factor: %.2f\n", *mainEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.MainMono.Eq.SetQ(0, mainEq.Band.Band, *cmd.Q); err != nil { if err := ctx.Client.MainMono.Eq.SetQ(0, *mainEq.Band.Band, *cmd.Q); err != nil {
return fmt.Errorf("failed to set Main Mono EQ band %d Q factor: %w", mainEq.Band.Band, err) return fmt.Errorf("failed to set Main Mono EQ band %d Q factor: %w", *mainEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Main Mono EQ band %d Q factor set to: %.2f\n", mainEq.Band.Band, *cmd.Q) fmt.Fprintf(ctx.Out, "Main Mono EQ band %d Q factor set to: %.2f\n", *mainEq.Band.Band, *cmd.Q)
return nil return nil
} }
@@ -255,18 +255,18 @@ type MainMonoEqBandTypeCmd struct {
// Run executes the MainMonoEqBandTypeCmd command, either retrieving the current type of a specific EQ band on the Main Mono output or setting it based on the provided argument. // Run executes the MainMonoEqBandTypeCmd command, either retrieving the current type of a specific EQ band on the Main Mono output or setting it based on the provided argument.
func (cmd *MainMonoEqBandTypeCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainMonoEqCmdGroup) error { func (cmd *MainMonoEqBandTypeCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainMonoEqCmdGroup) error {
if cmd.Type == nil { if cmd.Type == nil {
resp, err := ctx.Client.MainMono.Eq.Type(0, mainEq.Band.Band) resp, err := ctx.Client.MainMono.Eq.Type(0, *mainEq.Band.Band)
if err != nil { if err != nil {
return fmt.Errorf("failed to get Main Mono EQ band %d type: %w", mainEq.Band.Band, err) return fmt.Errorf("failed to get Main Mono EQ band %d type: %w", *mainEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Main Mono EQ band %d type: %s\n", mainEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Main Mono EQ band %d type: %s\n", *mainEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.MainMono.Eq.SetType(0, mainEq.Band.Band, *cmd.Type); err != nil { if err := ctx.Client.MainMono.Eq.SetType(0, *mainEq.Band.Band, *cmd.Type); err != nil {
return fmt.Errorf("failed to set Main Mono EQ band %d type: %w", mainEq.Band.Band, err) return fmt.Errorf("failed to set Main Mono EQ band %d type: %w", *mainEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Main Mono EQ band %d type set to: %s\n", mainEq.Band.Band, *cmd.Type) fmt.Fprintf(ctx.Out, "Main Mono EQ band %d type set to: %s\n", *mainEq.Band.Band, *cmd.Type)
return nil return nil
} }

View File

@@ -145,7 +145,7 @@ func (cmd *MatrixFadeoutCmd) Run(ctx *context, matrix *MatrixCmdGroup) error {
type MatrixEqCmdGroup struct { type MatrixEqCmdGroup struct {
On MatrixEqOnCmd `help:"Get or set the EQ on/off state of the Matrix output." cmd:"on"` On MatrixEqOnCmd `help:"Get or set the EQ on/off state of the Matrix output." cmd:"on"`
Band struct { Band struct {
Band int `arg:"" help:"The EQ band number."` Band *int `arg:"" help:"The EQ band number." optional:""`
Gain MatrixEqBandGainCmd `help:"Get or set the gain of the specified EQ band." cmd:"gain"` Gain MatrixEqBandGainCmd `help:"Get or set the gain of the specified EQ band." cmd:"gain"`
Freq MatrixEqBandFreqCmd `help:"Get or set the frequency of the specified EQ band." cmd:"freq"` Freq MatrixEqBandFreqCmd `help:"Get or set the frequency of the specified EQ band." cmd:"freq"`
Q MatrixEqBandQCmd `help:"Get or set the Q factor of the specified EQ band." cmd:"q"` Q MatrixEqBandQCmd `help:"Get or set the Q factor of the specified EQ band." cmd:"q"`
@@ -155,12 +155,12 @@ type MatrixEqCmdGroup struct {
// Validate checks if the provided EQ band number is within the valid range (1-6) for the Matrix output. // Validate checks if the provided EQ band number is within the valid range (1-6) for the Matrix output.
func (cmd *MatrixEqCmdGroup) Validate() error { func (cmd *MatrixEqCmdGroup) Validate() error {
if cmd.Band.Band == 0 { if cmd.Band.Band == nil {
return nil return nil
} }
if cmd.Band.Band < 1 || cmd.Band.Band > 6 { if *cmd.Band.Band < 1 || *cmd.Band.Band > 6 {
return fmt.Errorf("EQ band number must be between 1 and 6, got %d", cmd.Band.Band) return fmt.Errorf("EQ band number must be between 1 and 6, got %d", *cmd.Band.Band)
} }
return nil return nil
} }
@@ -196,18 +196,18 @@ type MatrixEqBandGainCmd struct {
// Run executes the MatrixEqBandGainCmd command, either retrieving the current gain of a specific EQ band on the Matrix output or setting it based on the provided argument. // Run executes the MatrixEqBandGainCmd command, either retrieving the current gain of a specific EQ band on the Matrix output or setting it based on the provided argument.
func (cmd *MatrixEqBandGainCmd) Run(ctx *context, matrix *MatrixCmdGroup, matrixEq *MatrixEqCmdGroup) error { func (cmd *MatrixEqBandGainCmd) Run(ctx *context, matrix *MatrixCmdGroup, matrixEq *MatrixEqCmdGroup) error {
if cmd.Level == nil { if cmd.Level == nil {
resp, err := ctx.Client.Matrix.Eq.Gain(matrix.Index.Index, matrixEq.Band.Band) resp, err := ctx.Client.Matrix.Eq.Gain(matrix.Index.Index, *matrixEq.Band.Band)
if err != nil { if err != nil {
return fmt.Errorf("failed to get Matrix EQ band %d gain: %w", matrixEq.Band.Band, err) return fmt.Errorf("failed to get Matrix EQ band %d gain: %w", *matrixEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Matrix EQ band %d gain: %.2f dB\n", matrixEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Matrix EQ band %d gain: %.2f dB\n", *matrixEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Matrix.Eq.SetGain(matrix.Index.Index, matrixEq.Band.Band, *cmd.Level); err != nil { if err := ctx.Client.Matrix.Eq.SetGain(matrix.Index.Index, *matrixEq.Band.Band, *cmd.Level); err != nil {
return fmt.Errorf("failed to set Matrix EQ band %d gain: %w", matrixEq.Band.Band, err) return fmt.Errorf("failed to set Matrix EQ band %d gain: %w", *matrixEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Matrix EQ band %d gain set to: %.2f dB\n", matrixEq.Band.Band, *cmd.Level) fmt.Fprintf(ctx.Out, "Matrix EQ band %d gain set to: %.2f dB\n", *matrixEq.Band.Band, *cmd.Level)
return nil return nil
} }
@@ -219,18 +219,18 @@ type MatrixEqBandFreqCmd struct {
// Run executes the MatrixEqBandFreqCmd command, either retrieving the current frequency of a specific EQ band on the Matrix output or setting it based on the provided argument. // Run executes the MatrixEqBandFreqCmd command, either retrieving the current frequency of a specific EQ band on the Matrix output or setting it based on the provided argument.
func (cmd *MatrixEqBandFreqCmd) Run(ctx *context, matrix *MatrixCmdGroup, matrixEq *MatrixEqCmdGroup) error { func (cmd *MatrixEqBandFreqCmd) Run(ctx *context, matrix *MatrixCmdGroup, matrixEq *MatrixEqCmdGroup) error {
if cmd.Frequency == nil { if cmd.Frequency == nil {
resp, err := ctx.Client.Matrix.Eq.Frequency(matrix.Index.Index, matrixEq.Band.Band) resp, err := ctx.Client.Matrix.Eq.Frequency(matrix.Index.Index, *matrixEq.Band.Band)
if err != nil { if err != nil {
return fmt.Errorf("failed to get Matrix EQ band %d frequency: %w", matrixEq.Band.Band, err) return fmt.Errorf("failed to get Matrix EQ band %d frequency: %w", *matrixEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Matrix EQ band %d frequency: %.2f Hz\n", matrixEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Matrix EQ band %d frequency: %.2f Hz\n", *matrixEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Matrix.Eq.SetFrequency(matrix.Index.Index, matrixEq.Band.Band, *cmd.Frequency); err != nil { if err := ctx.Client.Matrix.Eq.SetFrequency(matrix.Index.Index, *matrixEq.Band.Band, *cmd.Frequency); err != nil {
return fmt.Errorf("failed to set Matrix EQ band %d frequency: %w", matrixEq.Band.Band, err) return fmt.Errorf("failed to set Matrix EQ band %d frequency: %w", *matrixEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Matrix EQ band %d frequency set to: %.2f Hz\n", matrixEq.Band.Band, *cmd.Frequency) fmt.Fprintf(ctx.Out, "Matrix EQ band %d frequency set to: %.2f Hz\n", *matrixEq.Band.Band, *cmd.Frequency)
return nil return nil
} }
@@ -242,18 +242,18 @@ type MatrixEqBandQCmd struct {
// Run executes the MatrixEqBandQCmd command, either retrieving the current Q factor of a specific EQ band on the Matrix output or setting it based on the provided argument. // Run executes the MatrixEqBandQCmd command, either retrieving the current Q factor of a specific EQ band on the Matrix output or setting it based on the provided argument.
func (cmd *MatrixEqBandQCmd) Run(ctx *context, matrix *MatrixCmdGroup, matrixEq *MatrixEqCmdGroup) error { func (cmd *MatrixEqBandQCmd) Run(ctx *context, matrix *MatrixCmdGroup, matrixEq *MatrixEqCmdGroup) error {
if cmd.Q == nil { if cmd.Q == nil {
resp, err := ctx.Client.Matrix.Eq.Q(matrix.Index.Index, matrixEq.Band.Band) resp, err := ctx.Client.Matrix.Eq.Q(matrix.Index.Index, *matrixEq.Band.Band)
if err != nil { if err != nil {
return fmt.Errorf("failed to get Matrix EQ band %d Q factor: %w", matrixEq.Band.Band, err) return fmt.Errorf("failed to get Matrix EQ band %d Q factor: %w", *matrixEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Matrix EQ band %d Q factor: %.2f\n", matrixEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Matrix EQ band %d Q factor: %.2f\n", *matrixEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Matrix.Eq.SetQ(matrix.Index.Index, matrixEq.Band.Band, *cmd.Q); err != nil { if err := ctx.Client.Matrix.Eq.SetQ(matrix.Index.Index, *matrixEq.Band.Band, *cmd.Q); err != nil {
return fmt.Errorf("failed to set Matrix EQ band %d Q factor: %w", matrixEq.Band.Band, err) return fmt.Errorf("failed to set Matrix EQ band %d Q factor: %w", *matrixEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Matrix EQ band %d Q factor set to: %.2f\n", matrixEq.Band.Band, *cmd.Q) fmt.Fprintf(ctx.Out, "Matrix EQ band %d Q factor set to: %.2f\n", *matrixEq.Band.Band, *cmd.Q)
return nil return nil
} }
@@ -265,18 +265,18 @@ type MatrixEqBandTypeCmd struct {
// Run executes the MatrixEqBandTypeCmd command, either retrieving the current type of a specific EQ band on the Matrix output or setting it based on the provided argument. // Run executes the MatrixEqBandTypeCmd command, either retrieving the current type of a specific EQ band on the Matrix output or setting it based on the provided argument.
func (cmd *MatrixEqBandTypeCmd) Run(ctx *context, matrix *MatrixCmdGroup, matrixEq *MatrixEqCmdGroup) error { func (cmd *MatrixEqBandTypeCmd) Run(ctx *context, matrix *MatrixCmdGroup, matrixEq *MatrixEqCmdGroup) error {
if cmd.Type == nil { if cmd.Type == nil {
resp, err := ctx.Client.Matrix.Eq.Type(matrix.Index.Index, matrixEq.Band.Band) resp, err := ctx.Client.Matrix.Eq.Type(matrix.Index.Index, *matrixEq.Band.Band)
if err != nil { if err != nil {
return fmt.Errorf("failed to get Matrix EQ band %d type: %w", matrixEq.Band.Band, err) return fmt.Errorf("failed to get Matrix EQ band %d type: %w", *matrixEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Matrix EQ band %d type: %s\n", matrixEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Matrix EQ band %d type: %s\n", *matrixEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Matrix.Eq.SetType(matrix.Index.Index, matrixEq.Band.Band, *cmd.Type); err != nil { if err := ctx.Client.Matrix.Eq.SetType(matrix.Index.Index, *matrixEq.Band.Band, *cmd.Type); err != nil {
return fmt.Errorf("failed to set Matrix EQ band %d type: %w", matrixEq.Band.Band, err) return fmt.Errorf("failed to set Matrix EQ band %d type: %w", *matrixEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Matrix EQ band %d type set to: %s\n", matrixEq.Band.Band, *cmd.Type) fmt.Fprintf(ctx.Out, "Matrix EQ band %d type set to: %s\n", *matrixEq.Band.Band, *cmd.Type)
return nil return nil
} }

View File

@@ -5,7 +5,7 @@ import "fmt"
type SnapshotCmdGroup struct { type SnapshotCmdGroup struct {
List ListCmd `help:"List all snapshots." cmd:"list"` List ListCmd `help:"List all snapshots." cmd:"list"`
Index struct { Index struct {
Index int `arg:"" help:"The index of the snapshot."` Index *int `arg:"" help:"The index of the snapshot." optional:""`
Name NameCmd `help:"Get or set the name of a snapshot." cmd:"name"` Name NameCmd `help:"Get or set the name of a snapshot." cmd:"name"`
Save SaveCmd `help:"Save the current mixer state to a snapshot." cmd:"save"` Save SaveCmd `help:"Save the current mixer state to a snapshot." cmd:"save"`
Load LoadCmd `help:"Load a mixer state from a snapshot." cmd:"load"` Load LoadCmd `help:"Load a mixer state from a snapshot." cmd:"load"`
@@ -13,6 +13,19 @@ type SnapshotCmdGroup struct {
} `help:"The index of the snapshot." arg:""` } `help:"The index of the snapshot." arg:""`
} }
// Validate checks if the provided snapshot index is within the valid range (1-64) when any of the subcommands that require an index are used.
func (c *SnapshotCmdGroup) Validate() error {
if c.Index.Index == nil {
return nil
}
if *c.Index.Index < 1 || *c.Index.Index > 64 {
return fmt.Errorf("snapshot index must be between 1 and 64")
}
return nil
}
type ListCmd struct { type ListCmd struct {
} }
@@ -36,7 +49,7 @@ type NameCmd struct {
func (c *NameCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error { func (c *NameCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error {
if c.Name == nil { if c.Name == nil {
name, err := ctx.Client.Snapshot.Name(snapshot.Index.Index) name, err := ctx.Client.Snapshot.Name(*snapshot.Index.Index)
if err != nil { if err != nil {
return err return err
} }
@@ -44,7 +57,7 @@ func (c *NameCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error {
return nil return nil
} }
return ctx.Client.Snapshot.SetName(snapshot.Index.Index, *c.Name) return ctx.Client.Snapshot.SetName(*snapshot.Index.Index, *c.Name)
} }
type SaveCmd struct { type SaveCmd struct {
@@ -57,19 +70,19 @@ func (c *SaveCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error {
return err return err
} }
return ctx.Client.Snapshot.CurrentSave(snapshot.Index.Index) return ctx.Client.Snapshot.CurrentSave(*snapshot.Index.Index)
} }
type LoadCmd struct { type LoadCmd struct {
} }
func (c *LoadCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error { func (c *LoadCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error {
return ctx.Client.Snapshot.CurrentLoad(snapshot.Index.Index) return ctx.Client.Snapshot.CurrentLoad(*snapshot.Index.Index)
} }
type DeleteCmd struct { type DeleteCmd struct {
} }
func (c *DeleteCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error { func (c *DeleteCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error {
return ctx.Client.Snapshot.CurrentDelete(snapshot.Index.Index) return ctx.Client.Snapshot.CurrentDelete(*snapshot.Index.Index)
} }

View File

@@ -140,27 +140,41 @@ func (cmd *StripFadeoutCmd) Run(ctx *context, strip *StripCmdGroup) error {
} }
} }
// StripSendCmd defines the command for getting or setting the send level for a specific bus on a strip, allowing users to control the level of the signal being sent from the strip to a particular bus. // StripSendCmd defines the command for getting or setting the auxiliary send level
// for a specific send destination (mix bus) on a strip.
type StripSendCmd struct { type StripSendCmd struct {
BusNum int `arg:"" help:"The bus number to get or set the send level for."` SendIndex int `arg:"" help:"The index of the send destination (mix bus). (1-based indexing)"`
Level *float64 `arg:"" help:"The send level to set (in dB)." optional:""` Level *float64 `arg:"" help:"The send level to set (in dB)." optional:""`
} }
// Run executes the StripSendCmd command, either retrieving the current send level for the specified bus on the strip or setting it based on the provided argument. // Run executes the StripSendCmd command, either retrieving the current send level for the specified send destination
// or setting it based on the provided argument.
func (cmd *StripSendCmd) Run(ctx *context, strip *StripCmdGroup) error { func (cmd *StripSendCmd) Run(ctx *context, strip *StripCmdGroup) error {
if cmd.Level == nil { if cmd.Level == nil {
resp, err := ctx.Client.Strip.SendLevel(strip.Index.Index, cmd.BusNum) resp, err := ctx.Client.Strip.SendLevel(strip.Index.Index, cmd.SendIndex)
if err != nil { if err != nil {
return fmt.Errorf("failed to get send level: %w", err) return fmt.Errorf("failed to get send level: %w", err)
} }
fmt.Fprintf(ctx.Out, "Strip %d send level for bus %d: %.2f dB\n", strip.Index.Index, cmd.BusNum, resp) fmt.Fprintf(
ctx.Out,
"Strip %d send %d level: %.2f dB\n",
strip.Index.Index,
cmd.SendIndex,
resp,
)
return nil return nil
} }
if err := ctx.Client.Strip.SetSendLevel(strip.Index.Index, cmd.BusNum, *cmd.Level); err != nil { if err := ctx.Client.Strip.SetSendLevel(strip.Index.Index, cmd.SendIndex, *cmd.Level); err != nil {
return fmt.Errorf("failed to set send level: %w", err) return fmt.Errorf("failed to set send level: %w", err)
} }
fmt.Fprintf(ctx.Out, "Strip %d send level for bus %d set to: %.2f dB\n", strip.Index.Index, cmd.BusNum, *cmd.Level) fmt.Fprintf(
ctx.Out,
"Strip %d send %d level set to: %.2f dB\n",
strip.Index.Index,
cmd.SendIndex,
*cmd.Level,
)
return nil return nil
} }
@@ -363,7 +377,7 @@ func (cmd *StripGateReleaseCmd) Run(ctx *context, strip *StripCmdGroup) error {
type StripEqCmdGroup struct { type StripEqCmdGroup struct {
On StripEqOnCmd `help:"Get or set the EQ on/off state of the strip." cmd:""` On StripEqOnCmd `help:"Get or set the EQ on/off state of the strip." cmd:""`
Band struct { Band struct {
Band int `arg:"" help:"The EQ band number."` Band *int `arg:"" help:"The EQ band number." optional:""`
Gain StripEqBandGainCmd `help:"Get or set the gain of the EQ band." cmd:""` Gain StripEqBandGainCmd `help:"Get or set the gain of the EQ band." cmd:""`
Freq StripEqBandFreqCmd `help:"Get or set the frequency of the EQ band." cmd:""` Freq StripEqBandFreqCmd `help:"Get or set the frequency of the EQ band." cmd:""`
Q StripEqBandQCmd `help:"Get or set the Q factor of the EQ band." cmd:""` Q StripEqBandQCmd `help:"Get or set the Q factor of the EQ band." cmd:""`
@@ -373,12 +387,12 @@ type StripEqCmdGroup struct {
// Validate checks if the provided EQ band number is valid (between 1 and 4) and returns an error if it is not. // Validate checks if the provided EQ band number is valid (between 1 and 4) and returns an error if it is not.
func (cmd *StripEqCmdGroup) Validate() error { func (cmd *StripEqCmdGroup) Validate() error {
if cmd.Band.Band == 0 { if cmd.Band.Band == nil {
return nil return nil
} }
if cmd.Band.Band < 1 || cmd.Band.Band > 4 { if *cmd.Band.Band < 1 || *cmd.Band.Band > 4 {
return fmt.Errorf("EQ band number must be between 1 and 4, got %d", cmd.Band.Band) return fmt.Errorf("EQ band number must be between 1 and 4, got %d", *cmd.Band.Band)
} }
return nil return nil
} }
@@ -414,18 +428,18 @@ type StripEqBandGainCmd struct {
// Run executes the StripEqBandGainCmd command, either retrieving the current gain of the specified EQ band on the strip or setting it based on the provided argument. // Run executes the StripEqBandGainCmd command, either retrieving the current gain of the specified EQ band on the strip or setting it based on the provided argument.
func (cmd *StripEqBandGainCmd) Run(ctx *context, strip *StripCmdGroup, stripEq *StripEqCmdGroup) error { func (cmd *StripEqBandGainCmd) Run(ctx *context, strip *StripCmdGroup, stripEq *StripEqCmdGroup) error {
if cmd.Gain == nil { if cmd.Gain == nil {
resp, err := ctx.Client.Strip.Eq.Gain(strip.Index.Index, stripEq.Band.Band) resp, err := ctx.Client.Strip.Eq.Gain(strip.Index.Index, *stripEq.Band.Band)
if err != nil { if err != nil {
return fmt.Errorf("failed to get EQ band gain: %w", err) return fmt.Errorf("failed to get EQ band gain: %w", err)
} }
fmt.Fprintf(ctx.Out, "Strip %d EQ band %d gain: %.2f\n", strip.Index.Index, stripEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Strip %d EQ band %d gain: %.2f\n", strip.Index.Index, *stripEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Strip.Eq.SetGain(strip.Index.Index, stripEq.Band.Band, *cmd.Gain); err != nil { if err := ctx.Client.Strip.Eq.SetGain(strip.Index.Index, *stripEq.Band.Band, *cmd.Gain); err != nil {
return fmt.Errorf("failed to set EQ band gain: %w", err) return fmt.Errorf("failed to set EQ band gain: %w", err)
} }
fmt.Fprintf(ctx.Out, "Strip %d EQ band %d gain set to: %.2f\n", strip.Index.Index, stripEq.Band.Band, *cmd.Gain) fmt.Fprintf(ctx.Out, "Strip %d EQ band %d gain set to: %.2f\n", strip.Index.Index, *stripEq.Band.Band, *cmd.Gain)
return nil return nil
} }
@@ -437,22 +451,22 @@ type StripEqBandFreqCmd struct {
// Run executes the StripEqBandFreqCmd command, either retrieving the current frequency of the specified EQ band on the strip or setting it based on the provided argument. // Run executes the StripEqBandFreqCmd command, either retrieving the current frequency of the specified EQ band on the strip or setting it based on the provided argument.
func (cmd *StripEqBandFreqCmd) Run(ctx *context, strip *StripCmdGroup, stripEq *StripEqCmdGroup) error { func (cmd *StripEqBandFreqCmd) Run(ctx *context, strip *StripCmdGroup, stripEq *StripEqCmdGroup) error {
if cmd.Freq == nil { if cmd.Freq == nil {
resp, err := ctx.Client.Strip.Eq.Frequency(strip.Index.Index, stripEq.Band.Band) resp, err := ctx.Client.Strip.Eq.Frequency(strip.Index.Index, *stripEq.Band.Band)
if err != nil { if err != nil {
return fmt.Errorf("failed to get EQ band frequency: %w", err) return fmt.Errorf("failed to get EQ band frequency: %w", err)
} }
fmt.Fprintf(ctx.Out, "Strip %d EQ band %d frequency: %.2f Hz\n", strip.Index.Index, stripEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Strip %d EQ band %d frequency: %.2f Hz\n", strip.Index.Index, *stripEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Strip.Eq.SetFrequency(strip.Index.Index, stripEq.Band.Band, *cmd.Freq); err != nil { if err := ctx.Client.Strip.Eq.SetFrequency(strip.Index.Index, *stripEq.Band.Band, *cmd.Freq); err != nil {
return fmt.Errorf("failed to set EQ band frequency: %w", err) return fmt.Errorf("failed to set EQ band frequency: %w", err)
} }
fmt.Fprintf( fmt.Fprintf(
ctx.Out, ctx.Out,
"Strip %d EQ band %d frequency set to: %.2f Hz\n", "Strip %d EQ band %d frequency set to: %.2f Hz\n",
strip.Index.Index, strip.Index.Index,
stripEq.Band.Band, *stripEq.Band.Band,
*cmd.Freq, *cmd.Freq,
) )
return nil return nil
@@ -466,18 +480,18 @@ type StripEqBandQCmd struct {
// Run executes the StripEqBandQCmd command, either retrieving the current Q factor of the specified EQ band on the strip or setting it based on the provided argument. // Run executes the StripEqBandQCmd command, either retrieving the current Q factor of the specified EQ band on the strip or setting it based on the provided argument.
func (cmd *StripEqBandQCmd) Run(ctx *context, strip *StripCmdGroup, stripEq *StripEqCmdGroup) error { func (cmd *StripEqBandQCmd) Run(ctx *context, strip *StripCmdGroup, stripEq *StripEqCmdGroup) error {
if cmd.Q == nil { if cmd.Q == nil {
resp, err := ctx.Client.Strip.Eq.Q(strip.Index.Index, stripEq.Band.Band) resp, err := ctx.Client.Strip.Eq.Q(strip.Index.Index, *stripEq.Band.Band)
if err != nil { if err != nil {
return fmt.Errorf("failed to get EQ band Q factor: %w", err) return fmt.Errorf("failed to get EQ band Q factor: %w", err)
} }
fmt.Fprintf(ctx.Out, "Strip %d EQ band %d Q factor: %.2f\n", strip.Index.Index, stripEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Strip %d EQ band %d Q factor: %.2f\n", strip.Index.Index, *stripEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Strip.Eq.SetQ(strip.Index.Index, stripEq.Band.Band, *cmd.Q); err != nil { if err := ctx.Client.Strip.Eq.SetQ(strip.Index.Index, *stripEq.Band.Band, *cmd.Q); err != nil {
return fmt.Errorf("failed to set EQ band Q factor: %w", err) return fmt.Errorf("failed to set EQ band Q factor: %w", err)
} }
fmt.Fprintf(ctx.Out, "Strip %d EQ band %d Q factor set to: %.2f\n", strip.Index.Index, stripEq.Band.Band, *cmd.Q) fmt.Fprintf(ctx.Out, "Strip %d EQ band %d Q factor set to: %.2f\n", strip.Index.Index, *stripEq.Band.Band, *cmd.Q)
return nil return nil
} }
@@ -489,18 +503,18 @@ type StripEqBandTypeCmd struct {
// Run executes the StripEqBandTypeCmd command, either retrieving the current type of the specified EQ band on the strip or setting it based on the provided argument. // Run executes the StripEqBandTypeCmd command, either retrieving the current type of the specified EQ band on the strip or setting it based on the provided argument.
func (cmd *StripEqBandTypeCmd) Run(ctx *context, strip *StripCmdGroup, stripEq *StripEqCmdGroup) error { func (cmd *StripEqBandTypeCmd) Run(ctx *context, strip *StripCmdGroup, stripEq *StripEqCmdGroup) error {
if cmd.Type == nil { if cmd.Type == nil {
resp, err := ctx.Client.Strip.Eq.Type(strip.Index.Index, stripEq.Band.Band) resp, err := ctx.Client.Strip.Eq.Type(strip.Index.Index, *stripEq.Band.Band)
if err != nil { if err != nil {
return fmt.Errorf("failed to get EQ band type: %w", err) return fmt.Errorf("failed to get EQ band type: %w", err)
} }
fmt.Fprintf(ctx.Out, "Strip %d EQ band %d type: %s\n", strip.Index.Index, stripEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Strip %d EQ band %d type: %s\n", strip.Index.Index, *stripEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Strip.Eq.SetType(strip.Index.Index, stripEq.Band.Band, *cmd.Type); err != nil { if err := ctx.Client.Strip.Eq.SetType(strip.Index.Index, *stripEq.Band.Band, *cmd.Type); err != nil {
return fmt.Errorf("failed to set EQ band type: %w", err) return fmt.Errorf("failed to set EQ band type: %w", err)
} }
fmt.Fprintf(ctx.Out, "Strip %d EQ band %d type set to: %s\n", strip.Index.Index, stripEq.Band.Band, *cmd.Type) fmt.Fprintf(ctx.Out, "Strip %d EQ band %d type set to: %s\n", strip.Index.Index, *stripEq.Band.Band, *cmd.Type)
return nil return nil
} }

View File

@@ -172,7 +172,7 @@ type BusEqCmdGroup struct {
On BusEqOnCmd `help:"Get or set the EQ on/off state of the bus." cmd:"on"` On BusEqOnCmd `help:"Get or set the EQ on/off state of the bus." cmd:"on"`
Mode BusEqModeCmd `help:"Get or set the EQ mode of the bus (peq, geq or teq)." cmd:"mode"` Mode BusEqModeCmd `help:"Get or set the EQ mode of the bus (peq, geq or teq)." cmd:"mode"`
Band struct { Band struct {
Band int `arg:"" help:"The EQ band number."` Band *int `arg:"" help:"The EQ band number." optional:""`
Gain BusEqBandGainCmd `help:"Get or set the gain of the EQ band." cmd:"gain"` Gain BusEqBandGainCmd `help:"Get or set the gain of the EQ band." cmd:"gain"`
Freq BusEqBandFreqCmd `help:"Get or set the frequency of the EQ band." cmd:"freq"` Freq BusEqBandFreqCmd `help:"Get or set the frequency of the EQ band." cmd:"freq"`
Q BusEqBandQCmd `help:"Get or set the Q factor of the EQ band." cmd:"q"` Q BusEqBandQCmd `help:"Get or set the Q factor of the EQ band." cmd:"q"`
@@ -181,14 +181,13 @@ type BusEqCmdGroup struct {
} }
// Validate checks that the provided EQ band number is within the valid range (1-6). // Validate checks that the provided EQ band number is within the valid range (1-6).
// Only validates when a band number is actually specified (non-zero).
func (cmd *BusEqCmdGroup) Validate() error { func (cmd *BusEqCmdGroup) Validate() error {
if cmd.Band.Band == 0 { if cmd.Band.Band == nil {
return nil return nil
} }
if cmd.Band.Band < 1 || cmd.Band.Band > 6 { if *cmd.Band.Band < 1 || *cmd.Band.Band > 6 {
return fmt.Errorf("EQ band number must be between 1 and 6, got %d", cmd.Band.Band) return fmt.Errorf("EQ band number must be between 1 and 6, got %d", *cmd.Band.Band)
} }
return nil return nil
} }
@@ -247,7 +246,7 @@ type BusEqBandGainCmd struct {
// Run executes the BusEqBandGainCmd command, either retrieving the current gain of the specified EQ band of the bus or setting it based on the provided argument. // Run executes the BusEqBandGainCmd command, either retrieving the current gain of the specified EQ band of the bus or setting it based on the provided argument.
func (cmd *BusEqBandGainCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGroup) error { func (cmd *BusEqBandGainCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGroup) error {
if cmd.Gain == nil { if cmd.Gain == nil {
resp, err := ctx.Client.Bus.Eq.Gain(bus.Index.Index, busEq.Band.Band) resp, err := ctx.Client.Bus.Eq.Gain(bus.Index.Index, *busEq.Band.Band)
if err != nil { if err != nil {
return err return err
} }
@@ -255,10 +254,10 @@ func (cmd *BusEqBandGainCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmd
return nil return nil
} }
if err := ctx.Client.Bus.Eq.SetGain(bus.Index.Index, busEq.Band.Band, *cmd.Gain); err != nil { if err := ctx.Client.Bus.Eq.SetGain(bus.Index.Index, *busEq.Band.Band, *cmd.Gain); err != nil {
return err return err
} }
fmt.Fprintf(ctx.Out, "Bus %d EQ band %d gain set to: %.2f dB\n", bus.Index.Index, busEq.Band.Band, *cmd.Gain) fmt.Fprintf(ctx.Out, "Bus %d EQ band %d gain set to: %.2f dB\n", bus.Index.Index, *busEq.Band.Band, *cmd.Gain)
return nil return nil
} }
@@ -270,18 +269,18 @@ type BusEqBandFreqCmd struct {
// Run executes the BusEqBandFreqCmd command, either retrieving the current frequency of the specified EQ band of the bus or setting it based on the provided argument. // Run executes the BusEqBandFreqCmd command, either retrieving the current frequency of the specified EQ band of the bus or setting it based on the provided argument.
func (cmd *BusEqBandFreqCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGroup) error { func (cmd *BusEqBandFreqCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGroup) error {
if cmd.Freq == nil { if cmd.Freq == nil {
resp, err := ctx.Client.Bus.Eq.Frequency(bus.Index.Index, busEq.Band.Band) resp, err := ctx.Client.Bus.Eq.Frequency(bus.Index.Index, *busEq.Band.Band)
if err != nil { if err != nil {
return err return err
} }
fmt.Fprintf(ctx.Out, "Bus %d EQ band %d frequency: %.2f Hz\n", bus.Index.Index, busEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Bus %d EQ band %d frequency: %.2f Hz\n", bus.Index.Index, *busEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Bus.Eq.SetFrequency(bus.Index.Index, busEq.Band.Band, *cmd.Freq); err != nil { if err := ctx.Client.Bus.Eq.SetFrequency(bus.Index.Index, *busEq.Band.Band, *cmd.Freq); err != nil {
return err return err
} }
fmt.Fprintf(ctx.Out, "Bus %d EQ band %d frequency set to: %.2f Hz\n", bus.Index.Index, busEq.Band.Band, *cmd.Freq) fmt.Fprintf(ctx.Out, "Bus %d EQ band %d frequency set to: %.2f Hz\n", bus.Index.Index, *busEq.Band.Band, *cmd.Freq)
return nil return nil
} }
@@ -293,18 +292,18 @@ type BusEqBandQCmd struct {
// Run executes the BusEqBandQCmd command, either retrieving the current Q factor of the specified EQ band of the bus or setting it based on the provided argument. // Run executes the BusEqBandQCmd command, either retrieving the current Q factor of the specified EQ band of the bus or setting it based on the provided argument.
func (cmd *BusEqBandQCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGroup) error { func (cmd *BusEqBandQCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGroup) error {
if cmd.Q == nil { if cmd.Q == nil {
resp, err := ctx.Client.Bus.Eq.Q(bus.Index.Index, busEq.Band.Band) resp, err := ctx.Client.Bus.Eq.Q(bus.Index.Index, *busEq.Band.Band)
if err != nil { if err != nil {
return err return err
} }
fmt.Fprintf(ctx.Out, "Bus %d EQ band %d Q factor: %.2f\n", bus.Index.Index, busEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Bus %d EQ band %d Q factor: %.2f\n", bus.Index.Index, *busEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Bus.Eq.SetQ(bus.Index.Index, busEq.Band.Band, *cmd.Q); err != nil { if err := ctx.Client.Bus.Eq.SetQ(bus.Index.Index, *busEq.Band.Band, *cmd.Q); err != nil {
return err return err
} }
fmt.Fprintf(ctx.Out, "Bus %d EQ band %d Q factor set to: %.2f\n", bus.Index.Index, busEq.Band.Band, *cmd.Q) fmt.Fprintf(ctx.Out, "Bus %d EQ band %d Q factor set to: %.2f\n", bus.Index.Index, *busEq.Band.Band, *cmd.Q)
return nil return nil
} }
@@ -316,18 +315,18 @@ type BusEqBandTypeCmd struct {
// Run executes the BusEqBandTypeCmd command, either retrieving the current type of the specified EQ band of the bus or setting it based on the provided argument. // Run executes the BusEqBandTypeCmd command, either retrieving the current type of the specified EQ band of the bus or setting it based on the provided argument.
func (cmd *BusEqBandTypeCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGroup) error { func (cmd *BusEqBandTypeCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGroup) error {
if cmd.Type == nil { if cmd.Type == nil {
resp, err := ctx.Client.Bus.Eq.Type(bus.Index.Index, busEq.Band.Band) resp, err := ctx.Client.Bus.Eq.Type(bus.Index.Index, *busEq.Band.Band)
if err != nil { if err != nil {
return err return err
} }
fmt.Fprintf(ctx.Out, "Bus %d EQ band %d type: %s\n", bus.Index.Index, busEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Bus %d EQ band %d type: %s\n", bus.Index.Index, *busEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Bus.Eq.SetType(bus.Index.Index, busEq.Band.Band, *cmd.Type); err != nil { if err := ctx.Client.Bus.Eq.SetType(bus.Index.Index, *busEq.Band.Band, *cmd.Type); err != nil {
return err return err
} }
fmt.Fprintf(ctx.Out, "Bus %d EQ band %d type set to: %s\n", bus.Index.Index, busEq.Band.Band, *cmd.Type) fmt.Fprintf(ctx.Out, "Bus %d EQ band %d type set to: %s\n", bus.Index.Index, *busEq.Band.Band, *cmd.Type)
return nil return nil
} }

View File

@@ -46,9 +46,10 @@ type CLI struct {
Version VersionFlag `help:"Print xair-cli version information and quit" name:"version" short:"v"` Version VersionFlag `help:"Print xair-cli version information and quit" name:"version" short:"v"`
Completion kongcompletion.Completion `help:"Generate shell completion scripts." cmd:"" aliases:"c"` Completion kongcompletion.Completion `help:"Generate shell completion scripts." cmd:""`
Info InfoCmd `help:"Print mixer information." cmd:""`
Raw RawCmd `help:"Send raw OSC messages to the mixer." cmd:""`
Raw RawCmd `help:"Send raw OSC messages to the mixer." cmd:"" group:"Raw"`
Main MainCmdGroup `help:"Control the Main L/R output" cmd:"" group:"Main"` Main MainCmdGroup `help:"Control the Main L/R output" cmd:"" group:"Main"`
Strip StripCmdGroup `help:"Control the strips." cmd:"" group:"Strip"` Strip StripCmdGroup `help:"Control the strips." cmd:"" group:"Strip"`
Bus BusCmdGroup `help:"Control the buses." cmd:"" group:"Bus"` Bus BusCmdGroup `help:"Control the buses." cmd:"" group:"Bus"`

18
cmd/xair-cli/info.go Normal file
View File

@@ -0,0 +1,18 @@
package main
import "fmt"
type InfoCmd struct {
}
func (c *InfoCmd) Run(ctx *context) error {
fmt.Fprintf(
ctx.Out,
"Host: %s | Name: %s | Model: %s | Firmware: %s\n",
ctx.Client.Info.Host,
ctx.Client.Info.Name,
ctx.Client.Info.Model,
ctx.Client.Info.Firmware,
)
return nil
}

View File

@@ -135,7 +135,7 @@ func (cmd *MainFadeoutCmd) Run(ctx *context) error {
type MainEqCmdGroup struct { type MainEqCmdGroup struct {
On MainEqOnCmd `help:"Get or set the EQ on/off state of the Main L/R output." cmd:"on"` On MainEqOnCmd `help:"Get or set the EQ on/off state of the Main L/R output." cmd:"on"`
Band struct { Band struct {
Band int `arg:"" help:"The EQ band number."` Band *int `arg:"" help:"The EQ band number." optional:""`
Gain MainEqBandGainCmd `help:"Get or set the gain of the specified EQ band." cmd:"gain"` Gain MainEqBandGainCmd `help:"Get or set the gain of the specified EQ band." cmd:"gain"`
Freq MainEqBandFreqCmd `help:"Get or set the frequency of the specified EQ band." cmd:"freq"` Freq MainEqBandFreqCmd `help:"Get or set the frequency of the specified EQ band." cmd:"freq"`
Q MainEqBandQCmd `help:"Get or set the Q factor of the specified EQ band." cmd:"q"` Q MainEqBandQCmd `help:"Get or set the Q factor of the specified EQ band." cmd:"q"`
@@ -145,12 +145,12 @@ type MainEqCmdGroup struct {
// Validate checks if the provided EQ band number is within the valid range (1-6) for the Main L/R output. // Validate checks if the provided EQ band number is within the valid range (1-6) for the Main L/R output.
func (cmd *MainEqCmdGroup) Validate() error { func (cmd *MainEqCmdGroup) Validate() error {
if cmd.Band.Band == 0 { if cmd.Band.Band == nil {
return nil return nil
} }
if cmd.Band.Band < 1 || cmd.Band.Band > 6 { if *cmd.Band.Band < 1 || *cmd.Band.Band > 6 {
return fmt.Errorf("EQ band number must be between 1 and 6, got %d", cmd.Band.Band) return fmt.Errorf("EQ band number must be between 1 and 6, got %d", *cmd.Band.Band)
} }
return nil return nil
} }
@@ -186,18 +186,18 @@ type MainEqBandGainCmd struct {
// Run executes the MainEqBandGainCmd command, either retrieving the current gain of a specific EQ band on the Main L/R output or setting it based on the provided argument. // Run executes the MainEqBandGainCmd command, either retrieving the current gain of a specific EQ band on the Main L/R output or setting it based on the provided argument.
func (cmd *MainEqBandGainCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainEqCmdGroup) error { func (cmd *MainEqBandGainCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainEqCmdGroup) error {
if cmd.Level == nil { if cmd.Level == nil {
resp, err := ctx.Client.Main.Eq.Gain(0, mainEq.Band.Band) resp, err := ctx.Client.Main.Eq.Gain(0, *mainEq.Band.Band)
if err != nil { if err != nil {
return fmt.Errorf("failed to get Main L/R EQ band %d gain: %w", mainEq.Band.Band, err) return fmt.Errorf("failed to get Main L/R EQ band %d gain: %w", *mainEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d gain: %.2f dB\n", mainEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Main L/R EQ band %d gain: %.2f dB\n", *mainEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Main.Eq.SetGain(0, mainEq.Band.Band, *cmd.Level); err != nil { if err := ctx.Client.Main.Eq.SetGain(0, *mainEq.Band.Band, *cmd.Level); err != nil {
return fmt.Errorf("failed to set Main L/R EQ band %d gain: %w", mainEq.Band.Band, err) return fmt.Errorf("failed to set Main L/R EQ band %d gain: %w", *mainEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d gain set to: %.2f dB\n", mainEq.Band.Band, *cmd.Level) fmt.Fprintf(ctx.Out, "Main L/R EQ band %d gain set to: %.2f dB\n", *mainEq.Band.Band, *cmd.Level)
return nil return nil
} }
@@ -209,18 +209,18 @@ type MainEqBandFreqCmd struct {
// Run executes the MainEqBandFreqCmd command, either retrieving the current frequency of a specific EQ band on the Main L/R output or setting it based on the provided argument. // Run executes the MainEqBandFreqCmd command, either retrieving the current frequency of a specific EQ band on the Main L/R output or setting it based on the provided argument.
func (cmd *MainEqBandFreqCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainEqCmdGroup) error { func (cmd *MainEqBandFreqCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainEqCmdGroup) error {
if cmd.Frequency == nil { if cmd.Frequency == nil {
resp, err := ctx.Client.Main.Eq.Frequency(0, mainEq.Band.Band) resp, err := ctx.Client.Main.Eq.Frequency(0, *mainEq.Band.Band)
if err != nil { if err != nil {
return fmt.Errorf("failed to get Main L/R EQ band %d frequency: %w", mainEq.Band.Band, err) return fmt.Errorf("failed to get Main L/R EQ band %d frequency: %w", *mainEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d frequency: %.2f Hz\n", mainEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Main L/R EQ band %d frequency: %.2f Hz\n", *mainEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Main.Eq.SetFrequency(0, mainEq.Band.Band, *cmd.Frequency); err != nil { if err := ctx.Client.Main.Eq.SetFrequency(0, *mainEq.Band.Band, *cmd.Frequency); err != nil {
return fmt.Errorf("failed to set Main L/R EQ band %d frequency: %w", mainEq.Band.Band, err) return fmt.Errorf("failed to set Main L/R EQ band %d frequency: %w", *mainEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d frequency set to: %.2f Hz\n", mainEq.Band.Band, *cmd.Frequency) fmt.Fprintf(ctx.Out, "Main L/R EQ band %d frequency set to: %.2f Hz\n", *mainEq.Band.Band, *cmd.Frequency)
return nil return nil
} }
@@ -232,18 +232,18 @@ type MainEqBandQCmd struct {
// Run executes the MainEqBandQCmd command, either retrieving the current Q factor of a specific EQ band on the Main L/R output or setting it based on the provided argument. // Run executes the MainEqBandQCmd command, either retrieving the current Q factor of a specific EQ band on the Main L/R output or setting it based on the provided argument.
func (cmd *MainEqBandQCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainEqCmdGroup) error { func (cmd *MainEqBandQCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainEqCmdGroup) error {
if cmd.Q == nil { if cmd.Q == nil {
resp, err := ctx.Client.Main.Eq.Q(0, mainEq.Band.Band) resp, err := ctx.Client.Main.Eq.Q(0, *mainEq.Band.Band)
if err != nil { if err != nil {
return fmt.Errorf("failed to get Main L/R EQ band %d Q factor: %w", mainEq.Band.Band, err) return fmt.Errorf("failed to get Main L/R EQ band %d Q factor: %w", *mainEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d Q factor: %.2f\n", mainEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Main L/R EQ band %d Q factor: %.2f\n", *mainEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Main.Eq.SetQ(0, mainEq.Band.Band, *cmd.Q); err != nil { if err := ctx.Client.Main.Eq.SetQ(0, *mainEq.Band.Band, *cmd.Q); err != nil {
return fmt.Errorf("failed to set Main L/R EQ band %d Q factor: %w", mainEq.Band.Band, err) return fmt.Errorf("failed to set Main L/R EQ band %d Q factor: %w", *mainEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d Q factor set to: %.2f\n", mainEq.Band.Band, *cmd.Q) fmt.Fprintf(ctx.Out, "Main L/R EQ band %d Q factor set to: %.2f\n", *mainEq.Band.Band, *cmd.Q)
return nil return nil
} }
@@ -255,18 +255,18 @@ type MainEqBandTypeCmd struct {
// Run executes the MainEqBandTypeCmd command, either retrieving the current type of a specific EQ band on the Main L/R output or setting it based on the provided argument. // Run executes the MainEqBandTypeCmd command, either retrieving the current type of a specific EQ band on the Main L/R output or setting it based on the provided argument.
func (cmd *MainEqBandTypeCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainEqCmdGroup) error { func (cmd *MainEqBandTypeCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainEqCmdGroup) error {
if cmd.Type == nil { if cmd.Type == nil {
resp, err := ctx.Client.Main.Eq.Type(0, mainEq.Band.Band) resp, err := ctx.Client.Main.Eq.Type(0, *mainEq.Band.Band)
if err != nil { if err != nil {
return fmt.Errorf("failed to get Main L/R EQ band %d type: %w", mainEq.Band.Band, err) return fmt.Errorf("failed to get Main L/R EQ band %d type: %w", *mainEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d type: %s\n", mainEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Main L/R EQ band %d type: %s\n", *mainEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Main.Eq.SetType(0, mainEq.Band.Band, *cmd.Type); err != nil { if err := ctx.Client.Main.Eq.SetType(0, *mainEq.Band.Band, *cmd.Type); err != nil {
return fmt.Errorf("failed to set Main L/R EQ band %d type: %w", mainEq.Band.Band, err) return fmt.Errorf("failed to set Main L/R EQ band %d type: %w", *mainEq.Band.Band, err)
} }
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d type set to: %s\n", mainEq.Band.Band, *cmd.Type) fmt.Fprintf(ctx.Out, "Main L/R EQ band %d type set to: %s\n", *mainEq.Band.Band, *cmd.Type)
return nil return nil
} }

View File

@@ -5,7 +5,7 @@ import "fmt"
type SnapshotCmdGroup struct { type SnapshotCmdGroup struct {
List ListCmd `help:"List all snapshots." cmd:"list"` List ListCmd `help:"List all snapshots." cmd:"list"`
Index struct { Index struct {
Index int `arg:"" help:"The index of the snapshot."` Index *int `arg:"" help:"The index of the snapshot." optional:""`
Name NameCmd `help:"Get or set the name of a snapshot." cmd:"name"` Name NameCmd `help:"Get or set the name of a snapshot." cmd:"name"`
Save SaveCmd `help:"Save the current mixer state to a snapshot." cmd:"save"` Save SaveCmd `help:"Save the current mixer state to a snapshot." cmd:"save"`
Load LoadCmd `help:"Load a mixer state from a snapshot." cmd:"load"` Load LoadCmd `help:"Load a mixer state from a snapshot." cmd:"load"`
@@ -13,6 +13,19 @@ type SnapshotCmdGroup struct {
} `help:"The index of the snapshot." arg:""` } `help:"The index of the snapshot." arg:""`
} }
// Validate checks if the provided snapshot index is within the valid range (1-64) when any of the subcommands that require an index are used.
func (c *SnapshotCmdGroup) Validate() error {
if c.Index.Index == nil {
return nil
}
if *c.Index.Index < 1 || *c.Index.Index > 64 {
return fmt.Errorf("snapshot index must be between 1 and 64")
}
return nil
}
type ListCmd struct { type ListCmd struct {
} }
@@ -36,7 +49,7 @@ type NameCmd struct {
func (c *NameCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error { func (c *NameCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error {
if c.Name == nil { if c.Name == nil {
name, err := ctx.Client.Snapshot.Name(snapshot.Index.Index) name, err := ctx.Client.Snapshot.Name(*snapshot.Index.Index)
if err != nil { if err != nil {
return err return err
} }
@@ -44,7 +57,7 @@ func (c *NameCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error {
return nil return nil
} }
return ctx.Client.Snapshot.SetName(snapshot.Index.Index, *c.Name) return ctx.Client.Snapshot.SetName(*snapshot.Index.Index, *c.Name)
} }
type SaveCmd struct { type SaveCmd struct {
@@ -57,19 +70,19 @@ func (c *SaveCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error {
return err return err
} }
return ctx.Client.Snapshot.CurrentSave(snapshot.Index.Index) return ctx.Client.Snapshot.CurrentSave(*snapshot.Index.Index)
} }
type LoadCmd struct { type LoadCmd struct {
} }
func (c *LoadCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error { func (c *LoadCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error {
return ctx.Client.Snapshot.CurrentLoad(snapshot.Index.Index) return ctx.Client.Snapshot.CurrentLoad(*snapshot.Index.Index)
} }
type DeleteCmd struct { type DeleteCmd struct {
} }
func (c *DeleteCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error { func (c *DeleteCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error {
return ctx.Client.Snapshot.CurrentDelete(snapshot.Index.Index) return ctx.Client.Snapshot.CurrentDelete(*snapshot.Index.Index)
} }

View File

@@ -140,27 +140,29 @@ func (cmd *StripFadeoutCmd) Run(ctx *context, strip *StripCmdGroup) error {
} }
} }
// StripSendCmd defines the command for getting or setting the send level for a specific bus on a strip, allowing users to control the level of the signal being sent from the strip to a particular bus. // StripSendCmd defines the command for getting or setting the auxiliary send level
// for a specific send destination (mix bus or effects channel) on a strip.
type StripSendCmd struct { type StripSendCmd struct {
BusNum int `arg:"" help:"The bus number to get or set the send level for."` SendIndex int `arg:"" help:"The index of the send destination (mix bus or effects channel). (1-based indexing)"`
Level *float64 `arg:"" help:"The send level to set (in dB)." optional:""` Level *float64 `arg:"" help:"The send level to set (in dB)." optional:""`
} }
// Run executes the StripSendCmd command, either retrieving the current send level for the specified bus on the strip or setting it based on the provided argument. // Run executes the StripSendCmd command, either retrieving the current send level for the specified destination
// or setting it based on the provided argument.
func (cmd *StripSendCmd) Run(ctx *context, strip *StripCmdGroup) error { func (cmd *StripSendCmd) Run(ctx *context, strip *StripCmdGroup) error {
if cmd.Level == nil { if cmd.Level == nil {
resp, err := ctx.Client.Strip.SendLevel(strip.Index.Index, cmd.BusNum) resp, err := ctx.Client.Strip.SendLevel(strip.Index.Index, cmd.SendIndex)
if err != nil { if err != nil {
return fmt.Errorf("failed to get send level: %w", err) return fmt.Errorf("failed to get send level: %w", err)
} }
fmt.Fprintf(ctx.Out, "Strip %d send level for bus %d: %.2f dB\n", strip.Index.Index, cmd.BusNum, resp) fmt.Fprintf(ctx.Out, "Strip %d send %d level: %.2f dB\n", strip.Index.Index, cmd.SendIndex, resp)
return nil return nil
} }
if err := ctx.Client.Strip.SetSendLevel(strip.Index.Index, cmd.BusNum, *cmd.Level); err != nil { if err := ctx.Client.Strip.SetSendLevel(strip.Index.Index, cmd.SendIndex, *cmd.Level); err != nil {
return fmt.Errorf("failed to set send level: %w", err) return fmt.Errorf("failed to set send level: %w", err)
} }
fmt.Fprintf(ctx.Out, "Strip %d send level for bus %d set to: %.2f dB\n", strip.Index.Index, cmd.BusNum, *cmd.Level) fmt.Fprintf(ctx.Out, "Strip %d send %d level set to: %.2f dB\n", strip.Index.Index, cmd.SendIndex, *cmd.Level)
return nil return nil
} }
@@ -363,7 +365,7 @@ func (cmd *StripGateReleaseCmd) Run(ctx *context, strip *StripCmdGroup) error {
type StripEqCmdGroup struct { type StripEqCmdGroup struct {
On StripEqOnCmd `help:"Get or set the EQ on/off state of the strip." cmd:""` On StripEqOnCmd `help:"Get or set the EQ on/off state of the strip." cmd:""`
Band struct { Band struct {
Band int `arg:"" help:"The EQ band number."` Band *int `arg:"" help:"The EQ band number." optional:""`
Gain StripEqBandGainCmd `help:"Get or set the gain of the EQ band." cmd:""` Gain StripEqBandGainCmd `help:"Get or set the gain of the EQ band." cmd:""`
Freq StripEqBandFreqCmd `help:"Get or set the frequency of the EQ band." cmd:""` Freq StripEqBandFreqCmd `help:"Get or set the frequency of the EQ band." cmd:""`
Q StripEqBandQCmd `help:"Get or set the Q factor of the EQ band." cmd:""` Q StripEqBandQCmd `help:"Get or set the Q factor of the EQ band." cmd:""`
@@ -373,12 +375,12 @@ type StripEqCmdGroup struct {
// Validate checks if the provided EQ band number is valid (between 1 and 4) and returns an error if it is not. // Validate checks if the provided EQ band number is valid (between 1 and 4) and returns an error if it is not.
func (cmd *StripEqCmdGroup) Validate() error { func (cmd *StripEqCmdGroup) Validate() error {
if cmd.Band.Band == 0 { if cmd.Band.Band == nil {
return nil return nil
} }
if cmd.Band.Band < 1 || cmd.Band.Band > 4 { if *cmd.Band.Band < 1 || *cmd.Band.Band > 4 {
return fmt.Errorf("EQ band number must be between 1 and 4, got %d", cmd.Band.Band) return fmt.Errorf("EQ band number must be between 1 and 4, got %d", *cmd.Band.Band)
} }
return nil return nil
} }
@@ -414,18 +416,18 @@ type StripEqBandGainCmd struct {
// Run executes the StripEqBandGainCmd command, either retrieving the current gain of the specified EQ band on the strip or setting it based on the provided argument. // Run executes the StripEqBandGainCmd command, either retrieving the current gain of the specified EQ band on the strip or setting it based on the provided argument.
func (cmd *StripEqBandGainCmd) Run(ctx *context, strip *StripCmdGroup, stripEq *StripEqCmdGroup) error { func (cmd *StripEqBandGainCmd) Run(ctx *context, strip *StripCmdGroup, stripEq *StripEqCmdGroup) error {
if cmd.Gain == nil { if cmd.Gain == nil {
resp, err := ctx.Client.Strip.Eq.Gain(strip.Index.Index, stripEq.Band.Band) resp, err := ctx.Client.Strip.Eq.Gain(strip.Index.Index, *stripEq.Band.Band)
if err != nil { if err != nil {
return fmt.Errorf("failed to get EQ band gain: %w", err) return fmt.Errorf("failed to get EQ band gain: %w", err)
} }
fmt.Fprintf(ctx.Out, "Strip %d EQ band %d gain: %.2f\n", strip.Index.Index, stripEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Strip %d EQ band %d gain: %.2f\n", strip.Index.Index, *stripEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Strip.Eq.SetGain(strip.Index.Index, stripEq.Band.Band, *cmd.Gain); err != nil { if err := ctx.Client.Strip.Eq.SetGain(strip.Index.Index, *stripEq.Band.Band, *cmd.Gain); err != nil {
return fmt.Errorf("failed to set EQ band gain: %w", err) return fmt.Errorf("failed to set EQ band gain: %w", err)
} }
fmt.Fprintf(ctx.Out, "Strip %d EQ band %d gain set to: %.2f\n", strip.Index.Index, stripEq.Band.Band, *cmd.Gain) fmt.Fprintf(ctx.Out, "Strip %d EQ band %d gain set to: %.2f\n", strip.Index.Index, *stripEq.Band.Band, *cmd.Gain)
return nil return nil
} }
@@ -437,22 +439,22 @@ type StripEqBandFreqCmd struct {
// Run executes the StripEqBandFreqCmd command, either retrieving the current frequency of the specified EQ band on the strip or setting it based on the provided argument. // Run executes the StripEqBandFreqCmd command, either retrieving the current frequency of the specified EQ band on the strip or setting it based on the provided argument.
func (cmd *StripEqBandFreqCmd) Run(ctx *context, strip *StripCmdGroup, stripEq *StripEqCmdGroup) error { func (cmd *StripEqBandFreqCmd) Run(ctx *context, strip *StripCmdGroup, stripEq *StripEqCmdGroup) error {
if cmd.Freq == nil { if cmd.Freq == nil {
resp, err := ctx.Client.Strip.Eq.Frequency(strip.Index.Index, stripEq.Band.Band) resp, err := ctx.Client.Strip.Eq.Frequency(strip.Index.Index, *stripEq.Band.Band)
if err != nil { if err != nil {
return fmt.Errorf("failed to get EQ band frequency: %w", err) return fmt.Errorf("failed to get EQ band frequency: %w", err)
} }
fmt.Fprintf(ctx.Out, "Strip %d EQ band %d frequency: %.2f Hz\n", strip.Index.Index, stripEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Strip %d EQ band %d frequency: %.2f Hz\n", strip.Index.Index, *stripEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Strip.Eq.SetFrequency(strip.Index.Index, stripEq.Band.Band, *cmd.Freq); err != nil { if err := ctx.Client.Strip.Eq.SetFrequency(strip.Index.Index, *stripEq.Band.Band, *cmd.Freq); err != nil {
return fmt.Errorf("failed to set EQ band frequency: %w", err) return fmt.Errorf("failed to set EQ band frequency: %w", err)
} }
fmt.Fprintf( fmt.Fprintf(
ctx.Out, ctx.Out,
"Strip %d EQ band %d frequency set to: %.2f Hz\n", "Strip %d EQ band %d frequency set to: %.2f Hz\n",
strip.Index.Index, strip.Index.Index,
stripEq.Band.Band, *stripEq.Band.Band,
*cmd.Freq, *cmd.Freq,
) )
return nil return nil
@@ -466,18 +468,18 @@ type StripEqBandQCmd struct {
// Run executes the StripEqBandQCmd command, either retrieving the current Q factor of the specified EQ band on the strip or setting it based on the provided argument. // Run executes the StripEqBandQCmd command, either retrieving the current Q factor of the specified EQ band on the strip or setting it based on the provided argument.
func (cmd *StripEqBandQCmd) Run(ctx *context, strip *StripCmdGroup, stripEq *StripEqCmdGroup) error { func (cmd *StripEqBandQCmd) Run(ctx *context, strip *StripCmdGroup, stripEq *StripEqCmdGroup) error {
if cmd.Q == nil { if cmd.Q == nil {
resp, err := ctx.Client.Strip.Eq.Q(strip.Index.Index, stripEq.Band.Band) resp, err := ctx.Client.Strip.Eq.Q(strip.Index.Index, *stripEq.Band.Band)
if err != nil { if err != nil {
return fmt.Errorf("failed to get EQ band Q factor: %w", err) return fmt.Errorf("failed to get EQ band Q factor: %w", err)
} }
fmt.Fprintf(ctx.Out, "Strip %d EQ band %d Q factor: %.2f\n", strip.Index.Index, stripEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Strip %d EQ band %d Q factor: %.2f\n", strip.Index.Index, *stripEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Strip.Eq.SetQ(strip.Index.Index, stripEq.Band.Band, *cmd.Q); err != nil { if err := ctx.Client.Strip.Eq.SetQ(strip.Index.Index, *stripEq.Band.Band, *cmd.Q); err != nil {
return fmt.Errorf("failed to set EQ band Q factor: %w", err) return fmt.Errorf("failed to set EQ band Q factor: %w", err)
} }
fmt.Fprintf(ctx.Out, "Strip %d EQ band %d Q factor set to: %.2f\n", strip.Index.Index, stripEq.Band.Band, *cmd.Q) fmt.Fprintf(ctx.Out, "Strip %d EQ band %d Q factor set to: %.2f\n", strip.Index.Index, *stripEq.Band.Band, *cmd.Q)
return nil return nil
} }
@@ -489,18 +491,18 @@ type StripEqBandTypeCmd struct {
// Run executes the StripEqBandTypeCmd command, either retrieving the current type of the specified EQ band on the strip or setting it based on the provided argument. // Run executes the StripEqBandTypeCmd command, either retrieving the current type of the specified EQ band on the strip or setting it based on the provided argument.
func (cmd *StripEqBandTypeCmd) Run(ctx *context, strip *StripCmdGroup, stripEq *StripEqCmdGroup) error { func (cmd *StripEqBandTypeCmd) Run(ctx *context, strip *StripCmdGroup, stripEq *StripEqCmdGroup) error {
if cmd.Type == nil { if cmd.Type == nil {
resp, err := ctx.Client.Strip.Eq.Type(strip.Index.Index, stripEq.Band.Band) resp, err := ctx.Client.Strip.Eq.Type(strip.Index.Index, *stripEq.Band.Band)
if err != nil { if err != nil {
return fmt.Errorf("failed to get EQ band type: %w", err) return fmt.Errorf("failed to get EQ band type: %w", err)
} }
fmt.Fprintf(ctx.Out, "Strip %d EQ band %d type: %s\n", strip.Index.Index, stripEq.Band.Band, resp) fmt.Fprintf(ctx.Out, "Strip %d EQ band %d type: %s\n", strip.Index.Index, *stripEq.Band.Band, resp)
return nil return nil
} }
if err := ctx.Client.Strip.Eq.SetType(strip.Index.Index, stripEq.Band.Band, *cmd.Type); err != nil { if err := ctx.Client.Strip.Eq.SetType(strip.Index.Index, *stripEq.Band.Band, *cmd.Type); err != nil {
return fmt.Errorf("failed to set EQ band type: %w", err) return fmt.Errorf("failed to set EQ band type: %w", err)
} }
fmt.Fprintf(ctx.Out, "Strip %d EQ band %d type set to: %s\n", strip.Index.Index, stripEq.Band.Band, *cmd.Type) fmt.Fprintf(ctx.Out, "Strip %d EQ band %d type set to: %s\n", strip.Index.Index, *stripEq.Band.Band, *cmd.Type)
return nil return nil
} }

View File

@@ -3,14 +3,14 @@ package xair
import "fmt" import "fmt"
type Bus struct { type Bus struct {
client *Client client *client
baseAddress string baseAddress string
Eq *Eq Eq *Eq
Comp *Comp Comp *Comp
} }
// newBus creates a new Bus instance // newBus creates a new Bus instance
func newBus(c *Client) *Bus { func newBus(c *client) *Bus {
return &Bus{ return &Bus{
client: c, client: c,
baseAddress: c.addressMap["bus"], baseAddress: c.addressMap["bus"],

View File

@@ -9,13 +9,9 @@ import (
"github.com/hypebeast/go-osc/osc" "github.com/hypebeast/go-osc/osc"
) )
type Client struct {
*engine
}
// XAirClient is a client for controlling XAir mixers // XAirClient is a client for controlling XAir mixers
type XAirClient struct { type XAirClient struct {
Client client
Main *Main Main *Main
Strip *Strip Strip *Strip
Bus *Bus Bus *Bus
@@ -24,9 +20,29 @@ type XAirClient struct {
DCA *DCA DCA *DCA
} }
// NewXAirClient creates a new XAirClient instance with optional engine configuration
func NewXAirClient(mixerIP string, mixerPort int, opts ...EngineOption) (*XAirClient, error) {
e, err := newEngine(mixerIP, mixerPort, kindXAir, opts...)
if err != nil {
return nil, err
}
c := &XAirClient{
client: client{e, InfoResponse{}},
}
c.Main = newMainStereo(&c.client)
c.Strip = newStrip(&c.client)
c.Bus = newBus(&c.client)
c.HeadAmp = newHeadAmp(&c.client)
c.Snapshot = newSnapshot(&c.client)
c.DCA = newDCA(&c.client)
return c, nil
}
// X32Client is a client for controlling X32 mixers // X32Client is a client for controlling X32 mixers
type X32Client struct { type X32Client struct {
Client client
Main *Main Main *Main
MainMono *Main MainMono *Main
Matrix *Matrix Matrix *Matrix
@@ -45,48 +61,33 @@ func NewX32Client(mixerIP string, mixerPort int, opts ...EngineOption) (*X32Clie
} }
c := &X32Client{ c := &X32Client{
Client: Client{e}, client: client{e, InfoResponse{}},
} }
c.Main = newMainStereo(&c.Client) c.Main = newMainStereo(&c.client)
c.MainMono = newMainMono(&c.Client) c.MainMono = newMainMono(&c.client)
c.Matrix = newMatrix(&c.Client) c.Matrix = newMatrix(&c.client)
c.Strip = newStrip(&c.Client) c.Strip = newStrip(&c.client)
c.Bus = newBus(&c.Client) c.Bus = newBus(&c.client)
c.HeadAmp = newHeadAmp(&c.Client) c.HeadAmp = newHeadAmp(&c.client)
c.Snapshot = newSnapshot(&c.Client) c.Snapshot = newSnapshot(&c.client)
c.DCA = newDCA(&c.Client) c.DCA = newDCA(&c.client)
return c, nil return c, nil
} }
// NewXAirClient creates a new XAirClient instance with optional engine configuration type client struct {
func NewXAirClient(mixerIP string, mixerPort int, opts ...EngineOption) (*XAirClient, error) { *engine
e, err := newEngine(mixerIP, mixerPort, kindXAir, opts...) Info InfoResponse
if err != nil {
return nil, err
}
c := &XAirClient{
Client: Client{e},
}
c.Main = newMainStereo(&c.Client)
c.Strip = newStrip(&c.Client)
c.Bus = newBus(&c.Client)
c.HeadAmp = newHeadAmp(&c.Client)
c.Snapshot = newSnapshot(&c.Client)
c.DCA = newDCA(&c.Client)
return c, nil
} }
// Start begins listening for messages in a goroutine // Start begins listening for messages in a goroutine
func (c *Client) StartListening() { func (c *client) StartListening() {
go c.engine.receiveLoop() go c.engine.receiveLoop()
log.Debugf("Started listening on %s...", c.engine.conn.LocalAddr().String()) log.Debugf("Started listening on %s...", c.engine.conn.LocalAddr().String())
} }
// Close stops the client and closes the connection // Close stops the client and closes the connection
func (c *Client) Close() { func (c *client) Close() {
close(c.engine.done) close(c.engine.done)
if c.engine.conn != nil { if c.engine.conn != nil {
c.engine.conn.Close() c.engine.conn.Close()
@@ -94,12 +95,12 @@ func (c *Client) Close() {
} }
// SendMessage sends an OSC message to the mixer using the unified connection // SendMessage sends an OSC message to the mixer using the unified connection
func (c *Client) SendMessage(address string, args ...any) error { func (c *client) SendMessage(address string, args ...any) error {
return c.engine.sendToAddress(c.mixerAddr, address, args...) return c.engine.sendToAddress(c.mixerAddr, address, args...)
} }
// 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() (*osc.Message, error) {
t := time.Tick(c.engine.timeout) t := time.Tick(c.engine.timeout)
select { select {
case <-t: case <-t:
@@ -113,7 +114,7 @@ func (c *Client) ReceiveMessage() (*osc.Message, error) {
} }
// RequestInfo requests mixer information // RequestInfo requests mixer information
func (c *Client) RequestInfo() (InfoResponse, error) { func (c *client) RequestInfo() (InfoResponse, error) {
var info InfoResponse var info InfoResponse
err := c.SendMessage("/xinfo") err := c.SendMessage("/xinfo")
if err != nil { if err != nil {
@@ -124,20 +125,31 @@ func (c *Client) RequestInfo() (InfoResponse, error) {
if err != nil { if err != nil {
return info, err return info, err
} }
if len(msg.Arguments) >= 3 { if len(msg.Arguments) == 4 {
info.Host = msg.Arguments[0].(string) if host, ok := msg.Arguments[0].(string); ok {
info.Name = msg.Arguments[1].(string) info.Host = host
info.Model = msg.Arguments[2].(string) }
if name, ok := msg.Arguments[1].(string); ok {
info.Name = name
}
if model, ok := msg.Arguments[2].(string); ok {
info.Model = model
}
if firmware, ok := msg.Arguments[3].(string); ok {
info.Firmware = firmware
}
} }
c.Info = info
return info, nil return info, nil
} }
// KeepAlive sends keep-alive message (required for multi-client usage) // KeepAlive sends keep-alive message (required for multi-client usage)
func (c *Client) KeepAlive() error { func (c *client) KeepAlive() error {
return c.SendMessage("/xremote") return c.SendMessage("/xremote")
} }
// RequestStatus requests mixer status // RequestStatus requests mixer status
func (c *Client) RequestStatus() error { func (c *client) RequestStatus() error {
return c.SendMessage("/status") return c.SendMessage("/status")
} }

View File

@@ -4,13 +4,13 @@ import "fmt"
// Comp represents the compressor parameters. // Comp represents the compressor parameters.
type Comp struct { type Comp struct {
client *Client client *client
baseAddress string baseAddress string
AddressFunc func(fmtString string, args ...any) string AddressFunc func(fmtString string, args ...any) string
} }
// Factory function to create Comp instance with optional configuration // Factory function to create Comp instance with optional configuration
func newComp(c *Client, baseAddress string, opts ...CompOption) *Comp { func newComp(c *client, baseAddress string, opts ...CompOption) *Comp {
comp := &Comp{ comp := &Comp{
client: c, client: c,
baseAddress: fmt.Sprintf("%s/dyn", baseAddress), baseAddress: fmt.Sprintf("%s/dyn", baseAddress),

View File

@@ -3,12 +3,12 @@ package xair
import "fmt" import "fmt"
type DCA struct { type DCA struct {
client *Client client *client
baseAddress string baseAddress string
} }
// newDCA creates a new DCA instance // newDCA creates a new DCA instance
func newDCA(c *Client) *DCA { func newDCA(c *client) *DCA {
return &DCA{ return &DCA{
client: c, client: c,
baseAddress: c.addressMap["dca"], baseAddress: c.addressMap["dca"],

View File

@@ -6,13 +6,13 @@ import (
// Eq represents the EQ parameters. // Eq represents the EQ parameters.
type Eq struct { type Eq struct {
client *Client client *client
baseAddress string baseAddress string
AddressFunc func(fmtString string, args ...any) string AddressFunc func(fmtString string, args ...any) string
} }
// Factory function to create Eq instance with optional configuration // Factory function to create Eq instance with optional configuration
func newEq(c *Client, baseAddress string, opts ...EqOption) *Eq { func newEq(c *client, baseAddress string, opts ...EqOption) *Eq {
eq := &Eq{ eq := &Eq{
client: c, client: c,
baseAddress: fmt.Sprintf("%s/eq", baseAddress), baseAddress: fmt.Sprintf("%s/eq", baseAddress),

View File

@@ -4,13 +4,13 @@ import "fmt"
// Gate represents the gate parameters. // Gate represents the gate parameters.
type Gate struct { type Gate struct {
client *Client client *client
baseAddress string baseAddress string
AddressFunc func(fmtString string, args ...any) string AddressFunc func(fmtString string, args ...any) string
} }
// Factory function to create Gate instance with optional configuration // Factory function to create Gate instance with optional configuration
func newGate(c *Client, baseAddress string, opts ...GateOption) *Gate { func newGate(c *client, baseAddress string, opts ...GateOption) *Gate {
gate := &Gate{ gate := &Gate{
client: c, client: c,
baseAddress: fmt.Sprintf("%s/gate", baseAddress), baseAddress: fmt.Sprintf("%s/gate", baseAddress),

View File

@@ -3,12 +3,12 @@ package xair
import "fmt" import "fmt"
type HeadAmp struct { type HeadAmp struct {
client *Client client *client
baseAddress string baseAddress string
} }
// newHeadAmp creates a new HeadAmp instance with the provided client. // newHeadAmp creates a new HeadAmp instance with the provided client.
func newHeadAmp(c *Client) *HeadAmp { func newHeadAmp(c *client) *HeadAmp {
return &HeadAmp{ return &HeadAmp{
client: c, client: c,
baseAddress: c.addressMap["headamp"], baseAddress: c.addressMap["headamp"],

View File

@@ -3,14 +3,14 @@ package xair
import "fmt" import "fmt"
type Main struct { type Main struct {
client *Client client *client
baseAddress string baseAddress string
Eq *Eq Eq *Eq
Comp *Comp Comp *Comp
} }
// newMainStereo creates a new Main instance for stereo main output // newMainStereo creates a new Main instance for stereo main output
func newMainStereo(c *Client) *Main { func newMainStereo(c *client) *Main {
addressFunc := func(fmtString string, args ...any) string { addressFunc := func(fmtString string, args ...any) string {
return fmtString return fmtString
} }
@@ -24,7 +24,7 @@ func newMainStereo(c *Client) *Main {
} }
// newMainMono creates a new MainMono instance for mono main output (X32 only) // newMainMono creates a new MainMono instance for mono main output (X32 only)
func newMainMono(c *Client) *Main { func newMainMono(c *client) *Main {
addressFunc := func(fmtString string, args ...any) string { addressFunc := func(fmtString string, args ...any) string {
return fmtString return fmtString
} }

View File

@@ -3,14 +3,14 @@ package xair
import "fmt" import "fmt"
type Matrix struct { type Matrix struct {
client *Client client *client
baseAddress string baseAddress string
Eq *Eq Eq *Eq
Comp *Comp Comp *Comp
} }
// newMatrix creates a new Matrix instance // newMatrix creates a new Matrix instance
func newMatrix(c *Client) *Matrix { func newMatrix(c *client) *Matrix {
return &Matrix{ return &Matrix{
client: c, client: c,
baseAddress: c.addressMap["matrix"], baseAddress: c.addressMap["matrix"],

View File

@@ -1,7 +1,8 @@
package xair package xair
type InfoResponse struct { type InfoResponse struct {
Host string Host string
Name string Name string
Model string Model string
Firmware string
} }

View File

@@ -3,12 +3,12 @@ package xair
import "fmt" import "fmt"
type Snapshot struct { type Snapshot struct {
client *Client client *client
baseAddress string baseAddress string
} }
// newSnapshot creates a new Snapshot instance // newSnapshot creates a new Snapshot instance
func newSnapshot(c *Client) *Snapshot { func newSnapshot(c *client) *Snapshot {
return &Snapshot{ return &Snapshot{
client: c, client: c,
baseAddress: c.addressMap["snapshot"], baseAddress: c.addressMap["snapshot"],

View File

@@ -3,7 +3,7 @@ package xair
import "fmt" import "fmt"
type Strip struct { type Strip struct {
client *Client client *client
baseAddress string baseAddress string
Gate *Gate Gate *Gate
Eq *Eq Eq *Eq
@@ -11,7 +11,7 @@ type Strip struct {
} }
// newStrip creates a new Strip instance // newStrip creates a new Strip instance
func newStrip(c *Client) *Strip { func newStrip(c *client) *Strip {
return &Strip{ return &Strip{
client: c, client: c,
baseAddress: c.addressMap["strip"], baseAddress: c.addressMap["strip"],
@@ -126,7 +126,7 @@ func (s *Strip) SetColor(strip int, color int32) error {
return s.client.SendMessage(address, color) return s.client.SendMessage(address, color)
} }
// SendLevel requests the sends level for a mixbus. // SendLevel requests auxiliary send level for a send destination.
func (s *Strip) SendLevel(strip int, bus int) (float64, error) { func (s *Strip) SendLevel(strip int, bus int) (float64, error) {
address := fmt.Sprintf(s.baseAddress, strip) + fmt.Sprintf("/mix/%02d/level", bus) address := fmt.Sprintf(s.baseAddress, strip) + fmt.Sprintf("/mix/%02d/level", bus)
err := s.client.SendMessage(address) err := s.client.SendMessage(address)
@@ -145,7 +145,7 @@ func (s *Strip) SendLevel(strip int, bus int) (float64, error) {
return mustDbFrom(float64(val)), nil return mustDbFrom(float64(val)), nil
} }
// SetSendLevel sets the sends level for a mixbus. // SetSendLevel sets the auxiliary send level for a send destination.
func (s *Strip) SetSendLevel(strip int, bus int, level float64) error { func (s *Strip) SetSendLevel(strip int, bus int, level float64) error {
address := fmt.Sprintf(s.baseAddress, strip) + fmt.Sprintf("/mix/%02d/level", bus) address := fmt.Sprintf(s.baseAddress, strip) + fmt.Sprintf("/mix/%02d/level", bus)
return s.client.SendMessage(address, float32(mustDbInto(level))) return s.client.SendMessage(address, float32(mustDbInto(level)))

View File

@@ -12,10 +12,9 @@ Flags:
-v, --version Print x32-cli version information and quit -v, --version Print x32-cli version information and quit
Commands: Commands:
completion (c) Generate shell completion scripts. completion Generate shell completion scripts.
info Print mixer information.
Raw raw Send raw OSC messages to the mixer.
raw Send raw OSC messages to the mixer.
Main Main
main mute Get or set the mute state of the Main L/R output. main mute Get or set the mute state of the Main L/R output.

View File

@@ -12,10 +12,9 @@ Flags:
-v, --version Print xair-cli version information and quit -v, --version Print xair-cli version information and quit
Commands: Commands:
completion (c) Generate shell completion scripts. completion Generate shell completion scripts.
info Print mixer information.
Raw raw Send raw OSC messages to the mixer.
raw Send raw OSC messages to the mixer.
Main Main
main mute Get or set the mute state of the Main L/R output. main mute Get or set the mute state of the Main L/R output.