litn fixes

This commit is contained in:
onyx-and-iris 2026-02-15 12:00:00 +00:00
parent 19fda4daec
commit ac8f635263
30 changed files with 840 additions and 253 deletions

View File

@ -101,7 +101,12 @@ func (cmd *BusFadeinCmd) Run(ctx *context, bus *BusCmdGroup) error {
time.Sleep(stepDuration)
}
fmt.Fprintf(ctx.Out, "Bus %d fade-in complete. Final level: %.2f dB\n", bus.Index.Index, cmd.Target)
fmt.Fprintf(
ctx.Out,
"Bus %d fade-in complete. Final level: %.2f dB\n",
bus.Index.Index,
cmd.Target,
)
return nil
}
@ -140,7 +145,12 @@ func (cmd *BusFadeoutCmd) Run(ctx *context, bus *BusCmdGroup) error {
time.Sleep(stepDuration)
}
fmt.Fprintf(ctx.Out, "Bus %d fade-out complete. Final level: %.2f dB\n", bus.Index.Index, cmd.Target)
fmt.Fprintf(
ctx.Out,
"Bus %d fade-out complete. Final level: %.2f dB\n",
bus.Index.Index,
cmd.Target,
)
return nil
}
@ -250,14 +260,26 @@ func (cmd *BusEqBandGainCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmd
if err != nil {
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
}
if err := ctx.Client.Bus.Eq.SetGain(bus.Index.Index, *busEq.Band.Band, *cmd.Gain); err != nil {
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
}
@ -273,14 +295,30 @@ func (cmd *BusEqBandFreqCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmd
if err != nil {
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
}
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
}
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
}
@ -296,14 +334,26 @@ func (cmd *BusEqBandQCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGro
if err != nil {
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
}
if err := ctx.Client.Bus.Eq.SetQ(bus.Index.Index, *busEq.Band.Band, *cmd.Q); err != nil {
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
}
@ -319,14 +369,26 @@ func (cmd *BusEqBandTypeCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmd
if err != nil {
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
}
if err := ctx.Client.Bus.Eq.SetType(bus.Index.Index, *busEq.Band.Band, *cmd.Type); err != nil {
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
}
@ -408,7 +470,12 @@ func (cmd *BusCompThresholdCmd) Run(ctx *context, bus *BusCmdGroup) error {
if err := ctx.Client.Bus.Comp.SetThreshold(bus.Index.Index, *cmd.Threshold); err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d compressor threshold set to: %.2f dB\n", bus.Index.Index, *cmd.Threshold)
fmt.Fprintf(
ctx.Out,
"Bus %d compressor threshold set to: %.2f dB\n",
bus.Index.Index,
*cmd.Threshold,
)
return nil
}
@ -477,7 +544,12 @@ func (cmd *BusCompMakeupCmd) Run(ctx *context, bus *BusCmdGroup) error {
if err := ctx.Client.Bus.Comp.SetMakeup(bus.Index.Index, *cmd.Makeup); err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d compressor makeup gain set to: %.2f dB\n", bus.Index.Index, *cmd.Makeup)
fmt.Fprintf(
ctx.Out,
"Bus %d compressor makeup gain set to: %.2f dB\n",
bus.Index.Index,
*cmd.Makeup,
)
return nil
}
@ -500,7 +572,12 @@ func (cmd *BusCompAttackCmd) Run(ctx *context, bus *BusCmdGroup) error {
if err := ctx.Client.Bus.Comp.SetAttack(bus.Index.Index, *cmd.Attack); err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d compressor attack time set to: %.2f ms\n", bus.Index.Index, *cmd.Attack)
fmt.Fprintf(
ctx.Out,
"Bus %d compressor attack time set to: %.2f ms\n",
bus.Index.Index,
*cmd.Attack,
)
return nil
}
@ -523,7 +600,12 @@ func (cmd *BusCompHoldCmd) Run(ctx *context, bus *BusCmdGroup) error {
if err := ctx.Client.Bus.Comp.SetHold(bus.Index.Index, *cmd.Hold); err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d compressor hold time set to: %.2f ms\n", bus.Index.Index, *cmd.Hold)
fmt.Fprintf(
ctx.Out,
"Bus %d compressor hold time set to: %.2f ms\n",
bus.Index.Index,
*cmd.Hold,
)
return nil
}
@ -546,6 +628,11 @@ func (cmd *BusCompReleaseCmd) Run(ctx *context, bus *BusCmdGroup) error {
if err := ctx.Client.Bus.Comp.SetRelease(bus.Index.Index, *cmd.Release); err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d compressor release time set to: %.2f ms\n", bus.Index.Index, *cmd.Release)
fmt.Fprintf(
ctx.Out,
"Bus %d compressor release time set to: %.2f ms\n",
bus.Index.Index,
*cmd.Release,
)
return nil
}

View File

@ -11,6 +11,7 @@ import (
"github.com/alecthomas/kong"
"github.com/charmbracelet/log"
kongcompletion "github.com/jotaen/kong-completion"
"github.com/onyx-and-iris/xair-cli/internal/xair"
)

View File

@ -38,14 +38,20 @@ func (cmd *HeadampGainCmd) Run(ctx *context, headamp *HeadampCmdGroup) error {
return fmt.Errorf("failed to get current headamp gain: %w", err)
}
if err := gradualGainAdjust(ctx, headamp.Index.Index, currentGain, *cmd.Gain, cmd.Duration); err != nil {
if err := gradualGainAdjust(
ctx,
headamp.Index.Index,
currentGain,
*cmd.Gain,
cmd.Duration,
); err != nil {
return fmt.Errorf("failed to set headamp gain: %w", err)
}
fmt.Fprintf(ctx.Out, "Headamp %d gain set to: %.2f dB\n", headamp.Index.Index, *cmd.Gain)
return nil
}
// gradualGainAdjust gradually adjusts gain from current to target over specified duration
// gradualGainAdjust gradually adjusts gain from current to target over specified duration.
func gradualGainAdjust(
ctx *context,
index int,
@ -96,7 +102,7 @@ type HeadampPhantomCmd struct {
State *string `help:"The phantom power state of the headamp." arg:"" enum:"true,on,false,off" optional:""`
}
// Validate checks if the provided phantom power state is valid and normalizes it to "true" or "false".
// Validate checks if the provided phantom power state is valid and normalises it to "true" or "false".
func (cmd *HeadampPhantomCmd) Validate() error {
if cmd.State != nil {
switch *cmd.State {
@ -122,7 +128,10 @@ func (cmd *HeadampPhantomCmd) Run(ctx *context, headamp *HeadampCmdGroup) error
return nil
}
if err := ctx.Client.HeadAmp.SetPhantomPower(headamp.Index.Index, *cmd.State == "true"); err != nil {
if err := ctx.Client.HeadAmp.SetPhantomPower(
headamp.Index.Index,
*cmd.State == "true",
); err != nil {
return fmt.Errorf("failed to set headamp phantom power state: %w", err)
}
fmt.Fprintf(ctx.Out, "Headamp %d phantom power set to: %s\n", headamp.Index.Index, *cmd.State)

View File

@ -2,8 +2,7 @@ package main
import "fmt"
type InfoCmd struct {
}
type InfoCmd struct{}
func (c *InfoCmd) Run(ctx *context) error {
fmt.Fprintf(

View File

@ -13,7 +13,7 @@ type MainCmdGroup struct {
Fadein MainFadeinCmd `help:"Fade in the Main L/R output over a specified duration." cmd:""`
Fadeout MainFadeoutCmd `help:"Fade out the Main L/R output over a specified duration." cmd:""`
Eq MainEqCmdGroup `help:"Commands for controlling the equalizer settings of the Main L/R output." cmd:"eq"`
Eq MainEqCmdGroup `help:"Commands for controlling the equaliser settings of the Main L/R output." cmd:"eq"`
Comp MainCompCmdGroup `help:"Commands for controlling the compressor settings of the Main L/R output." cmd:"comp"`
}
@ -131,7 +131,7 @@ func (cmd *MainFadeoutCmd) Run(ctx *context) error {
return nil
}
// MainEqCmdGroup defines the command group for controlling the equalizer settings of the Main L/R output, including commands for getting or setting the EQ parameters.
// MainEqCmdGroup defines the command group for controlling the equaliser settings of the Main L/R output, including commands for getting or setting the EQ parameters.
type MainEqCmdGroup struct {
On MainEqOnCmd `help:"Get or set the EQ on/off state of the Main L/R output." cmd:"on"`
Band struct {
@ -197,7 +197,12 @@ func (cmd *MainEqBandGainCmd) Run(ctx *context, main *MainCmdGroup, mainEq *Main
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)
}
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
}
@ -211,7 +216,11 @@ func (cmd *MainEqBandFreqCmd) Run(ctx *context, main *MainCmdGroup, mainEq *Main
if cmd.Frequency == nil {
resp, err := ctx.Client.Main.Eq.Frequency(0, *mainEq.Band.Band)
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)
return nil
@ -220,7 +229,12 @@ func (cmd *MainEqBandFreqCmd) Run(ctx *context, main *MainCmdGroup, mainEq *Main
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)
}
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
}
@ -234,7 +248,11 @@ func (cmd *MainEqBandQCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainEqC
if cmd.Q == nil {
resp, err := ctx.Client.Main.Eq.Q(0, *mainEq.Band.Band)
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)
return nil

View File

@ -13,7 +13,7 @@ type MainMonoCmdGroup struct {
Fadein MainMonoFadeinCmd `help:"Fade in the Main Mono output over a specified duration." cmd:""`
Fadeout MainMonoFadeoutCmd `help:"Fade out the Main Mono output over a specified duration." cmd:""`
Eq MainMonoEqCmdGroup `help:"Commands for controlling the equalizer settings of the Main Mono output." cmd:"eq"`
Eq MainMonoEqCmdGroup `help:"Commands for controlling the equaliser settings of the Main Mono output." cmd:"eq"`
Comp MainMonoCompCmdGroup `help:"Commands for controlling the compressor settings of the Main Mono output." cmd:"comp"`
}
@ -131,7 +131,7 @@ func (cmd *MainMonoFadeoutCmd) Run(ctx *context) error {
return nil
}
// MainMonoEqCmdGroup defines the command group for controlling the equalizer settings of the Main Mono output, including commands for getting or setting the EQ parameters.
// MainMonoEqCmdGroup defines the command group for controlling the equaliser settings of the Main Mono output, including commands for getting or setting the EQ parameters.
type MainMonoEqCmdGroup struct {
On MainMonoEqOnCmd `help:"Get or set the EQ on/off state of the Main Mono output." cmd:"on"`
Band struct {
@ -184,7 +184,11 @@ 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.
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 {
resp, err := ctx.Client.MainMono.Eq.Gain(0, *mainEq.Band.Band)
if err != nil {
@ -197,7 +201,12 @@ func (cmd *MainMonoEqBandGainCmd) Run(ctx *context, main *MainCmdGroup, mainEq *
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)
}
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
}
@ -207,20 +216,41 @@ 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.
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 {
resp, err := ctx.Client.MainMono.Eq.Frequency(0, *mainEq.Band.Band)
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)
return 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)
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,
)
}
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
}
@ -230,11 +260,19 @@ 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.
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 {
resp, err := ctx.Client.MainMono.Eq.Q(0, *mainEq.Band.Band)
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)
return nil
@ -253,7 +291,11 @@ 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.
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 {
resp, err := ctx.Client.MainMono.Eq.Type(0, *mainEq.Band.Band)
if err != nil {

View File

@ -15,7 +15,7 @@ type MatrixCmdGroup struct {
Fadein MatrixFadeinCmd `help:"Fade in the Matrix output over a specified duration." cmd:""`
Fadeout MatrixFadeoutCmd `help:"Fade out the Matrix output over a specified duration." cmd:""`
Eq MatrixEqCmdGroup `help:"Commands for controlling the equalizer settings of the Matrix output." cmd:"eq"`
Eq MatrixEqCmdGroup `help:"Commands for controlling the equaliser settings of the Matrix output." cmd:"eq"`
Comp MatrixCompCmdGroup `help:"Commands for controlling the compressor settings of the Matrix output." cmd:"comp"`
} `help:"Commands for controlling individual Matrix outputs." arg:""`
}
@ -141,7 +141,7 @@ func (cmd *MatrixFadeoutCmd) Run(ctx *context, matrix *MatrixCmdGroup) error {
return nil
}
// MatrixEqCmdGroup defines the command group for controlling the equalizer settings of the Matrix output, including commands for getting or setting the EQ parameters.
// MatrixEqCmdGroup defines the command group for controlling the equaliser settings of the Matrix output, including commands for getting or setting the EQ parameters.
type MatrixEqCmdGroup struct {
On MatrixEqOnCmd `help:"Get or set the EQ on/off state of the Matrix output." cmd:"on"`
Band struct {
@ -194,7 +194,11 @@ 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.
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 {
resp, err := ctx.Client.Matrix.Eq.Gain(matrix.Index.Index, *matrixEq.Band.Band)
if err != nil {
@ -204,10 +208,19 @@ func (cmd *MatrixEqBandGainCmd) Run(ctx *context, matrix *MatrixCmdGroup, matrix
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)
}
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
}
@ -217,20 +230,37 @@ 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.
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 {
resp, err := ctx.Client.Matrix.Eq.Frequency(matrix.Index.Index, *matrixEq.Band.Band)
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)
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)
}
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
}
@ -240,17 +270,29 @@ 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.
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 {
resp, err := ctx.Client.Matrix.Eq.Q(matrix.Index.Index, *matrixEq.Band.Band)
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)
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)
}
fmt.Fprintf(ctx.Out, "Matrix EQ band %d Q factor set to: %.2f\n", *matrixEq.Band.Band, *cmd.Q)
@ -263,7 +305,11 @@ 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.
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 {
resp, err := ctx.Client.Matrix.Eq.Type(matrix.Index.Index, *matrixEq.Band.Band)
if err != nil {
@ -273,7 +319,11 @@ func (cmd *MatrixEqBandTypeCmd) Run(ctx *context, matrix *MatrixCmdGroup, matrix
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)
}
fmt.Fprintf(ctx.Out, "Matrix EQ band %d type set to: %s\n", *matrixEq.Band.Band, *cmd.Type)

View File

@ -26,8 +26,7 @@ func (c *SnapshotCmdGroup) Validate() error {
return nil
}
type ListCmd struct {
}
type ListCmd struct{}
func (c *ListCmd) Run(ctx *context) error {
for i := range 64 {
@ -73,15 +72,13 @@ func (c *SaveCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error {
return ctx.Client.Snapshot.CurrentSave(*snapshot.Index.Index)
}
type LoadCmd struct {
}
type LoadCmd struct{}
func (c *LoadCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error {
return ctx.Client.Snapshot.CurrentLoad(*snapshot.Index.Index)
}
type DeleteCmd struct {
}
type DeleteCmd struct{}
func (c *DeleteCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error {
return ctx.Client.Snapshot.CurrentDelete(*snapshot.Index.Index)

View File

@ -99,7 +99,12 @@ func (cmd *StripFadeinCmd) Run(ctx *context, strip *StripCmdGroup) error {
time.Sleep(stepDuration)
}
fmt.Fprintf(ctx.Out, "Strip %d fade-in complete. Final level: %.2f dB\n", strip.Index.Index, cmd.Target)
fmt.Fprintf(
ctx.Out,
"Strip %d fade-in complete. Final level: %.2f dB\n",
strip.Index.Index,
cmd.Target,
)
return nil
}
@ -135,7 +140,12 @@ func (cmd *StripFadeoutCmd) Run(ctx *context, strip *StripCmdGroup) error {
time.Sleep(stepDuration)
}
fmt.Fprintf(ctx.Out, "Strip %d fade-out complete. Final level: %.2f dB\n", strip.Index.Index, cmd.Target)
fmt.Fprintf(
ctx.Out,
"Strip %d fade-out complete. Final level: %.2f dB\n",
strip.Index.Index,
cmd.Target,
)
return nil
}
}
@ -165,7 +175,11 @@ func (cmd *StripSendCmd) Run(ctx *context, strip *StripCmdGroup) error {
return nil
}
if err := ctx.Client.Strip.SetSendLevel(strip.Index.Index, cmd.SendIndex, *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)
}
fmt.Fprintf(
@ -178,7 +192,7 @@ func (cmd *StripSendCmd) Run(ctx *context, strip *StripCmdGroup) error {
return nil
}
// StripNameCmd defines the command for getting or setting the name of a strip, allowing users to assign custom names to strips for easier identification and organization.
// StripNameCmd defines the command for getting or setting the name of a strip, allowing users to assign custom names to strips for easier identification and organisation.
type StripNameCmd struct {
Name *string `arg:"" help:"The name to set for the strip." optional:""`
}
@ -277,7 +291,12 @@ func (cmd *StripGateThresholdCmd) Run(ctx *context, strip *StripCmdGroup) error
if err := ctx.Client.Strip.Gate.SetThreshold(strip.Index.Index, *cmd.Threshold); err != nil {
return fmt.Errorf("failed to set gate threshold: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d gate threshold set to: %.2f\n", strip.Index.Index, *cmd.Threshold)
fmt.Fprintf(
ctx.Out,
"Strip %d gate threshold set to: %.2f\n",
strip.Index.Index,
*cmd.Threshold,
)
return nil
}
@ -323,7 +342,12 @@ func (cmd *StripGateAttackCmd) Run(ctx *context, strip *StripCmdGroup) error {
if err := ctx.Client.Strip.Gate.SetAttack(strip.Index.Index, *cmd.Attack); err != nil {
return fmt.Errorf("failed to set gate attack time: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d gate attack time set to: %.2f ms\n", strip.Index.Index, *cmd.Attack)
fmt.Fprintf(
ctx.Out,
"Strip %d gate attack time set to: %.2f ms\n",
strip.Index.Index,
*cmd.Attack,
)
return nil
}
@ -369,7 +393,12 @@ func (cmd *StripGateReleaseCmd) Run(ctx *context, strip *StripCmdGroup) error {
if err := ctx.Client.Strip.Gate.SetRelease(strip.Index.Index, *cmd.Release); err != nil {
return fmt.Errorf("failed to set gate release time: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d gate release time set to: %.2f ms\n", strip.Index.Index, *cmd.Release)
fmt.Fprintf(
ctx.Out,
"Strip %d gate release time set to: %.2f ms\n",
strip.Index.Index,
*cmd.Release,
)
return nil
}
@ -426,40 +455,74 @@ 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.
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 {
resp, err := ctx.Client.Strip.Eq.Gain(strip.Index.Index, *stripEq.Band.Band)
if err != nil {
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
}
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)
}
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
}
// StripEqBandFreqCmd defines the command for getting or setting the frequency of a specific EQ band on a strip, allowing users to adjust the center frequency of the band in hertz (Hz).
// StripEqBandFreqCmd defines the command for getting or setting the frequency of a specific EQ band on a strip, allowing users to adjust the centre frequency of the band in hertz (Hz).
type StripEqBandFreqCmd struct {
Freq *float64 `arg:"" help:"The frequency to set for the EQ band (in Hz)." optional:""`
}
// 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 {
resp, err := ctx.Client.Strip.Eq.Frequency(strip.Index.Index, *stripEq.Band.Band)
if err != nil {
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
}
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)
}
fmt.Fprintf(
@ -478,20 +541,36 @@ 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.
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 {
resp, err := ctx.Client.Strip.Eq.Q(strip.Index.Index, *stripEq.Band.Band)
if err != nil {
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
}
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)
}
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
}
@ -501,20 +580,40 @@ 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.
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 {
resp, err := ctx.Client.Strip.Eq.Type(strip.Index.Index, *stripEq.Band.Band)
if err != nil {
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
}
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)
}
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
}
@ -596,7 +695,12 @@ func (cmd *StripCompThresholdCmd) Run(ctx *context, strip *StripCmdGroup) error
if err := ctx.Client.Strip.Comp.SetThreshold(strip.Index.Index, *cmd.Threshold); err != nil {
return fmt.Errorf("failed to set compressor threshold: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d compressor threshold set to: %.2f\n", strip.Index.Index, *cmd.Threshold)
fmt.Fprintf(
ctx.Out,
"Strip %d compressor threshold set to: %.2f\n",
strip.Index.Index,
*cmd.Threshold,
)
return nil
}
@ -665,7 +769,12 @@ func (cmd *StripCompMakeupCmd) Run(ctx *context, strip *StripCmdGroup) error {
if err := ctx.Client.Strip.Comp.SetMakeup(strip.Index.Index, *cmd.Makeup); err != nil {
return fmt.Errorf("failed to set compressor makeup gain: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d compressor makeup gain set to: %.2f\n", strip.Index.Index, *cmd.Makeup)
fmt.Fprintf(
ctx.Out,
"Strip %d compressor makeup gain set to: %.2f\n",
strip.Index.Index,
*cmd.Makeup,
)
return nil
}
@ -688,7 +797,12 @@ func (cmd *StripCompAttackCmd) Run(ctx *context, strip *StripCmdGroup) error {
if err := ctx.Client.Strip.Comp.SetAttack(strip.Index.Index, *cmd.Attack); err != nil {
return fmt.Errorf("failed to set compressor attack time: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d compressor attack time set to: %.2f ms\n", strip.Index.Index, *cmd.Attack)
fmt.Fprintf(
ctx.Out,
"Strip %d compressor attack time set to: %.2f ms\n",
strip.Index.Index,
*cmd.Attack,
)
return nil
}
@ -711,7 +825,12 @@ func (cmd *StripCompHoldCmd) Run(ctx *context, strip *StripCmdGroup) error {
if err := ctx.Client.Strip.Comp.SetHold(strip.Index.Index, *cmd.Hold); err != nil {
return fmt.Errorf("failed to set compressor hold time: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d compressor hold time set to: %.2f ms\n", strip.Index.Index, *cmd.Hold)
fmt.Fprintf(
ctx.Out,
"Strip %d compressor hold time set to: %.2f ms\n",
strip.Index.Index,
*cmd.Hold,
)
return nil
}
@ -734,6 +853,11 @@ func (cmd *StripCompReleaseCmd) Run(ctx *context, strip *StripCmdGroup) error {
if err := ctx.Client.Strip.Comp.SetRelease(strip.Index.Index, *cmd.Release); err != nil {
return fmt.Errorf("failed to set compressor release time: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d compressor release time set to: %.2f ms\n", strip.Index.Index, *cmd.Release)
fmt.Fprintf(
ctx.Out,
"Strip %d compressor release time set to: %.2f ms\n",
strip.Index.Index,
*cmd.Release,
)
return nil
}

View File

@ -101,7 +101,12 @@ func (cmd *BusFadeinCmd) Run(ctx *context, bus *BusCmdGroup) error {
time.Sleep(stepDuration)
}
fmt.Fprintf(ctx.Out, "Bus %d fade-in complete. Final level: %.2f dB\n", bus.Index.Index, cmd.Target)
fmt.Fprintf(
ctx.Out,
"Bus %d fade-in complete. Final level: %.2f dB\n",
bus.Index.Index,
cmd.Target,
)
return nil
}
@ -140,7 +145,12 @@ func (cmd *BusFadeoutCmd) Run(ctx *context, bus *BusCmdGroup) error {
time.Sleep(stepDuration)
}
fmt.Fprintf(ctx.Out, "Bus %d fade-out complete. Final level: %.2f dB\n", bus.Index.Index, cmd.Target)
fmt.Fprintf(
ctx.Out,
"Bus %d fade-out complete. Final level: %.2f dB\n",
bus.Index.Index,
cmd.Target,
)
return nil
}
@ -250,14 +260,26 @@ func (cmd *BusEqBandGainCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmd
if err != nil {
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
}
if err := ctx.Client.Bus.Eq.SetGain(bus.Index.Index, *busEq.Band.Band, *cmd.Gain); err != nil {
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
}
@ -273,14 +295,30 @@ func (cmd *BusEqBandFreqCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmd
if err != nil {
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
}
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
}
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
}
@ -296,14 +334,26 @@ func (cmd *BusEqBandQCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGro
if err != nil {
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
}
if err := ctx.Client.Bus.Eq.SetQ(bus.Index.Index, *busEq.Band.Band, *cmd.Q); err != nil {
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
}
@ -319,14 +369,26 @@ func (cmd *BusEqBandTypeCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmd
if err != nil {
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
}
if err := ctx.Client.Bus.Eq.SetType(bus.Index.Index, *busEq.Band.Band, *cmd.Type); err != nil {
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
}
@ -408,7 +470,12 @@ func (cmd *BusCompThresholdCmd) Run(ctx *context, bus *BusCmdGroup) error {
if err := ctx.Client.Bus.Comp.SetThreshold(bus.Index.Index, *cmd.Threshold); err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d compressor threshold set to: %.2f dB\n", bus.Index.Index, *cmd.Threshold)
fmt.Fprintf(
ctx.Out,
"Bus %d compressor threshold set to: %.2f dB\n",
bus.Index.Index,
*cmd.Threshold,
)
return nil
}
@ -477,7 +544,12 @@ func (cmd *BusCompMakeupCmd) Run(ctx *context, bus *BusCmdGroup) error {
if err := ctx.Client.Bus.Comp.SetMakeup(bus.Index.Index, *cmd.Makeup); err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d compressor makeup gain set to: %.2f dB\n", bus.Index.Index, *cmd.Makeup)
fmt.Fprintf(
ctx.Out,
"Bus %d compressor makeup gain set to: %.2f dB\n",
bus.Index.Index,
*cmd.Makeup,
)
return nil
}
@ -500,7 +572,12 @@ func (cmd *BusCompAttackCmd) Run(ctx *context, bus *BusCmdGroup) error {
if err := ctx.Client.Bus.Comp.SetAttack(bus.Index.Index, *cmd.Attack); err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d compressor attack time set to: %.2f ms\n", bus.Index.Index, *cmd.Attack)
fmt.Fprintf(
ctx.Out,
"Bus %d compressor attack time set to: %.2f ms\n",
bus.Index.Index,
*cmd.Attack,
)
return nil
}
@ -523,7 +600,12 @@ func (cmd *BusCompHoldCmd) Run(ctx *context, bus *BusCmdGroup) error {
if err := ctx.Client.Bus.Comp.SetHold(bus.Index.Index, *cmd.Hold); err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d compressor hold time set to: %.2f ms\n", bus.Index.Index, *cmd.Hold)
fmt.Fprintf(
ctx.Out,
"Bus %d compressor hold time set to: %.2f ms\n",
bus.Index.Index,
*cmd.Hold,
)
return nil
}
@ -546,6 +628,11 @@ func (cmd *BusCompReleaseCmd) Run(ctx *context, bus *BusCmdGroup) error {
if err := ctx.Client.Bus.Comp.SetRelease(bus.Index.Index, *cmd.Release); err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d compressor release time set to: %.2f ms\n", bus.Index.Index, *cmd.Release)
fmt.Fprintf(
ctx.Out,
"Bus %d compressor release time set to: %.2f ms\n",
bus.Index.Index,
*cmd.Release,
)
return nil
}

View File

@ -11,6 +11,7 @@ import (
"github.com/alecthomas/kong"
"github.com/charmbracelet/log"
kongcompletion "github.com/jotaen/kong-completion"
"github.com/onyx-and-iris/xair-cli/internal/xair"
)

View File

@ -38,14 +38,20 @@ func (cmd *HeadampGainCmd) Run(ctx *context, headamp *HeadampCmdGroup) error {
return fmt.Errorf("failed to get current headamp gain: %w", err)
}
if err := gradualGainAdjust(ctx, headamp.Index.Index, currentGain, *cmd.Gain, cmd.Duration); err != nil {
if err := gradualGainAdjust(
ctx,
headamp.Index.Index,
currentGain,
*cmd.Gain,
cmd.Duration,
); err != nil {
return fmt.Errorf("failed to set headamp gain: %w", err)
}
fmt.Fprintf(ctx.Out, "Headamp %d gain set to: %.2f dB\n", headamp.Index.Index, *cmd.Gain)
return nil
}
// gradualGainAdjust gradually adjusts gain from current to target over specified duration
// gradualGainAdjust gradually adjusts gain from current to target over specified duration.
func gradualGainAdjust(
ctx *context,
index int,
@ -96,7 +102,7 @@ type HeadampPhantomCmd struct {
State *string `help:"The phantom power state of the headamp." arg:"" enum:"true,on,false,off" optional:""`
}
// Validate checks if the provided phantom power state is valid and normalizes it to "true" or "false".
// Validate checks if the provided phantom power state is valid and normalises it to "true" or "false".
func (cmd *HeadampPhantomCmd) Validate() error {
if cmd.State != nil {
switch *cmd.State {
@ -122,7 +128,10 @@ func (cmd *HeadampPhantomCmd) Run(ctx *context, headamp *HeadampCmdGroup) error
return nil
}
if err := ctx.Client.HeadAmp.SetPhantomPower(headamp.Index.Index, *cmd.State == "true"); err != nil {
if err := ctx.Client.HeadAmp.SetPhantomPower(
headamp.Index.Index,
*cmd.State == "true",
); err != nil {
return fmt.Errorf("failed to set headamp phantom power state: %w", err)
}
fmt.Fprintf(ctx.Out, "Headamp %d phantom power set to: %s\n", headamp.Index.Index, *cmd.State)

View File

@ -2,8 +2,7 @@ package main
import "fmt"
type InfoCmd struct {
}
type InfoCmd struct{}
func (c *InfoCmd) Run(ctx *context) error {
fmt.Fprintf(

View File

@ -13,7 +13,7 @@ type MainCmdGroup struct {
Fadein MainFadeinCmd `help:"Fade in the Main L/R output over a specified duration." cmd:""`
Fadeout MainFadeoutCmd `help:"Fade out the Main L/R output over a specified duration." cmd:""`
Eq MainEqCmdGroup `help:"Commands for controlling the equalizer settings of the Main L/R output." cmd:"eq"`
Eq MainEqCmdGroup `help:"Commands for controlling the equaliser settings of the Main L/R output." cmd:"eq"`
Comp MainCompCmdGroup `help:"Commands for controlling the compressor settings of the Main L/R output." cmd:"comp"`
}
@ -131,7 +131,7 @@ func (cmd *MainFadeoutCmd) Run(ctx *context) error {
return nil
}
// MainEqCmdGroup defines the command group for controlling the equalizer settings of the Main L/R output, including commands for getting or setting the EQ parameters.
// MainEqCmdGroup defines the command group for controlling the equaliser settings of the Main L/R output, including commands for getting or setting the EQ parameters.
type MainEqCmdGroup struct {
On MainEqOnCmd `help:"Get or set the EQ on/off state of the Main L/R output." cmd:"on"`
Band struct {
@ -197,7 +197,12 @@ func (cmd *MainEqBandGainCmd) Run(ctx *context, main *MainCmdGroup, mainEq *Main
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)
}
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
}
@ -211,7 +216,11 @@ func (cmd *MainEqBandFreqCmd) Run(ctx *context, main *MainCmdGroup, mainEq *Main
if cmd.Frequency == nil {
resp, err := ctx.Client.Main.Eq.Frequency(0, *mainEq.Band.Band)
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)
return nil
@ -220,7 +229,12 @@ func (cmd *MainEqBandFreqCmd) Run(ctx *context, main *MainCmdGroup, mainEq *Main
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)
}
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
}
@ -234,7 +248,11 @@ func (cmd *MainEqBandQCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainEqC
if cmd.Q == nil {
resp, err := ctx.Client.Main.Eq.Q(0, *mainEq.Band.Band)
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)
return nil

View File

@ -26,8 +26,7 @@ func (c *SnapshotCmdGroup) Validate() error {
return nil
}
type ListCmd struct {
}
type ListCmd struct{}
func (c *ListCmd) Run(ctx *context) error {
for i := range 64 {
@ -73,15 +72,13 @@ func (c *SaveCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error {
return ctx.Client.Snapshot.CurrentSave(*snapshot.Index.Index)
}
type LoadCmd struct {
}
type LoadCmd struct{}
func (c *LoadCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error {
return ctx.Client.Snapshot.CurrentLoad(*snapshot.Index.Index)
}
type DeleteCmd struct {
}
type DeleteCmd struct{}
func (c *DeleteCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error {
return ctx.Client.Snapshot.CurrentDelete(*snapshot.Index.Index)

View File

@ -99,7 +99,12 @@ func (cmd *StripFadeinCmd) Run(ctx *context, strip *StripCmdGroup) error {
time.Sleep(stepDuration)
}
fmt.Fprintf(ctx.Out, "Strip %d fade-in complete. Final level: %.2f dB\n", strip.Index.Index, cmd.Target)
fmt.Fprintf(
ctx.Out,
"Strip %d fade-in complete. Final level: %.2f dB\n",
strip.Index.Index,
cmd.Target,
)
return nil
}
@ -135,7 +140,12 @@ func (cmd *StripFadeoutCmd) Run(ctx *context, strip *StripCmdGroup) error {
time.Sleep(stepDuration)
}
fmt.Fprintf(ctx.Out, "Strip %d fade-out complete. Final level: %.2f dB\n", strip.Index.Index, cmd.Target)
fmt.Fprintf(
ctx.Out,
"Strip %d fade-out complete. Final level: %.2f dB\n",
strip.Index.Index,
cmd.Target,
)
return nil
}
}
@ -155,18 +165,34 @@ func (cmd *StripSendCmd) Run(ctx *context, strip *StripCmdGroup) error {
if err != nil {
return fmt.Errorf("failed to get send level: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d send %d level: %.2f dB\n", strip.Index.Index, cmd.SendIndex, resp)
fmt.Fprintf(
ctx.Out,
"Strip %d send %d level: %.2f dB\n",
strip.Index.Index,
cmd.SendIndex,
resp,
)
return nil
}
if err := ctx.Client.Strip.SetSendLevel(strip.Index.Index, cmd.SendIndex, *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)
}
fmt.Fprintf(ctx.Out, "Strip %d send %d level set to: %.2f dB\n", strip.Index.Index, cmd.SendIndex, *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
}
// StripNameCmd defines the command for getting or setting the name of a strip, allowing users to assign custom names to strips for easier identification and organization.
// StripNameCmd defines the command for getting or setting the name of a strip, allowing users to assign custom names to strips for easier identification and organisation.
type StripNameCmd struct {
Name *string `arg:"" help:"The name to set for the strip." optional:""`
}
@ -265,7 +291,12 @@ func (cmd *StripGateThresholdCmd) Run(ctx *context, strip *StripCmdGroup) error
if err := ctx.Client.Strip.Gate.SetThreshold(strip.Index.Index, *cmd.Threshold); err != nil {
return fmt.Errorf("failed to set gate threshold: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d gate threshold set to: %.2f\n", strip.Index.Index, *cmd.Threshold)
fmt.Fprintf(
ctx.Out,
"Strip %d gate threshold set to: %.2f\n",
strip.Index.Index,
*cmd.Threshold,
)
return nil
}
@ -311,7 +342,12 @@ func (cmd *StripGateAttackCmd) Run(ctx *context, strip *StripCmdGroup) error {
if err := ctx.Client.Strip.Gate.SetAttack(strip.Index.Index, *cmd.Attack); err != nil {
return fmt.Errorf("failed to set gate attack time: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d gate attack time set to: %.2f ms\n", strip.Index.Index, *cmd.Attack)
fmt.Fprintf(
ctx.Out,
"Strip %d gate attack time set to: %.2f ms\n",
strip.Index.Index,
*cmd.Attack,
)
return nil
}
@ -357,7 +393,12 @@ func (cmd *StripGateReleaseCmd) Run(ctx *context, strip *StripCmdGroup) error {
if err := ctx.Client.Strip.Gate.SetRelease(strip.Index.Index, *cmd.Release); err != nil {
return fmt.Errorf("failed to set gate release time: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d gate release time set to: %.2f ms\n", strip.Index.Index, *cmd.Release)
fmt.Fprintf(
ctx.Out,
"Strip %d gate release time set to: %.2f ms\n",
strip.Index.Index,
*cmd.Release,
)
return nil
}
@ -414,40 +455,74 @@ 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.
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 {
resp, err := ctx.Client.Strip.Eq.Gain(strip.Index.Index, *stripEq.Band.Band)
if err != nil {
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
}
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)
}
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
}
// StripEqBandFreqCmd defines the command for getting or setting the frequency of a specific EQ band on a strip, allowing users to adjust the center frequency of the band in hertz (Hz).
// StripEqBandFreqCmd defines the command for getting or setting the frequency of a specific EQ band on a strip, allowing users to adjust the centre frequency of the band in hertz (Hz).
type StripEqBandFreqCmd struct {
Freq *float64 `arg:"" help:"The frequency to set for the EQ band (in Hz)." optional:""`
}
// 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 {
resp, err := ctx.Client.Strip.Eq.Frequency(strip.Index.Index, *stripEq.Band.Band)
if err != nil {
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
}
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)
}
fmt.Fprintf(
@ -466,20 +541,36 @@ 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.
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 {
resp, err := ctx.Client.Strip.Eq.Q(strip.Index.Index, *stripEq.Band.Band)
if err != nil {
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
}
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)
}
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
}
@ -489,20 +580,40 @@ 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.
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 {
resp, err := ctx.Client.Strip.Eq.Type(strip.Index.Index, *stripEq.Band.Band)
if err != nil {
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
}
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)
}
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
}
@ -584,7 +695,12 @@ func (cmd *StripCompThresholdCmd) Run(ctx *context, strip *StripCmdGroup) error
if err := ctx.Client.Strip.Comp.SetThreshold(strip.Index.Index, *cmd.Threshold); err != nil {
return fmt.Errorf("failed to set compressor threshold: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d compressor threshold set to: %.2f\n", strip.Index.Index, *cmd.Threshold)
fmt.Fprintf(
ctx.Out,
"Strip %d compressor threshold set to: %.2f\n",
strip.Index.Index,
*cmd.Threshold,
)
return nil
}
@ -653,7 +769,12 @@ func (cmd *StripCompMakeupCmd) Run(ctx *context, strip *StripCmdGroup) error {
if err := ctx.Client.Strip.Comp.SetMakeup(strip.Index.Index, *cmd.Makeup); err != nil {
return fmt.Errorf("failed to set compressor makeup gain: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d compressor makeup gain set to: %.2f\n", strip.Index.Index, *cmd.Makeup)
fmt.Fprintf(
ctx.Out,
"Strip %d compressor makeup gain set to: %.2f\n",
strip.Index.Index,
*cmd.Makeup,
)
return nil
}
@ -676,7 +797,12 @@ func (cmd *StripCompAttackCmd) Run(ctx *context, strip *StripCmdGroup) error {
if err := ctx.Client.Strip.Comp.SetAttack(strip.Index.Index, *cmd.Attack); err != nil {
return fmt.Errorf("failed to set compressor attack time: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d compressor attack time set to: %.2f ms\n", strip.Index.Index, *cmd.Attack)
fmt.Fprintf(
ctx.Out,
"Strip %d compressor attack time set to: %.2f ms\n",
strip.Index.Index,
*cmd.Attack,
)
return nil
}
@ -699,7 +825,12 @@ func (cmd *StripCompHoldCmd) Run(ctx *context, strip *StripCmdGroup) error {
if err := ctx.Client.Strip.Comp.SetHold(strip.Index.Index, *cmd.Hold); err != nil {
return fmt.Errorf("failed to set compressor hold time: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d compressor hold time set to: %.2f ms\n", strip.Index.Index, *cmd.Hold)
fmt.Fprintf(
ctx.Out,
"Strip %d compressor hold time set to: %.2f ms\n",
strip.Index.Index,
*cmd.Hold,
)
return nil
}
@ -722,6 +853,11 @@ func (cmd *StripCompReleaseCmd) Run(ctx *context, strip *StripCmdGroup) error {
if err := ctx.Client.Strip.Comp.SetRelease(strip.Index.Index, *cmd.Release); err != nil {
return fmt.Errorf("failed to set compressor release time: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d compressor release time set to: %.2f ms\n", strip.Index.Index, *cmd.Release)
fmt.Fprintf(
ctx.Out,
"Strip %d compressor release time set to: %.2f ms\n",
strip.Index.Index,
*cmd.Release,
)
return nil
}

View File

@ -9,7 +9,7 @@ type Bus struct {
Comp *Comp
}
// newBus creates a new Bus instance
// newBus creates a new Bus instance.
func newBus(c *client) *Bus {
return &Bus{
client: c,
@ -19,7 +19,7 @@ func newBus(c *client) *Bus {
}
}
// Mute requests the current mute status for a bus
// Mute requests the current mute status for a bus.
func (b *Bus) Mute(bus int) (bool, error) {
address := fmt.Sprintf(b.baseAddress, bus) + "/mix/on"
err := b.client.SendMessage(address)
@ -38,7 +38,7 @@ func (b *Bus) Mute(bus int) (bool, error) {
return val == 0, nil
}
// SetMute sets the mute status for a specific bus (1-based indexing)
// SetMute sets the mute status for a specific bus (1-based indexing).
func (b *Bus) SetMute(bus int, muted bool) error {
address := fmt.Sprintf(b.baseAddress, bus) + "/mix/on"
var value int32
@ -48,7 +48,7 @@ func (b *Bus) SetMute(bus int, muted bool) error {
return b.client.SendMessage(address, value)
}
// Fader requests the current fader level for a bus
// Fader requests the current fader level for a bus.
func (b *Bus) Fader(bus int) (float64, error) {
address := fmt.Sprintf(b.baseAddress, bus) + "/mix/fader"
err := b.client.SendMessage(address)
@ -68,18 +68,18 @@ func (b *Bus) Fader(bus int) (float64, error) {
return mustDbFrom(float64(val)), nil
}
// SetFader sets the fader level for a specific bus (1-based indexing)
// SetFader sets the fader level for a specific bus (1-based indexing).
func (b *Bus) SetFader(bus int, level float64) error {
address := fmt.Sprintf(b.baseAddress, bus) + "/mix/fader"
return b.client.SendMessage(address, float32(mustDbInto(level)))
}
// Name requests the name for a specific bus
// Name requests the name for a specific bus.
func (b *Bus) Name(bus int) (string, error) {
address := fmt.Sprintf(b.baseAddress, bus) + "/config/name"
err := b.client.SendMessage(address)
if err != nil {
return "", fmt.Errorf("failed to send bus name request: %v", err)
return "", fmt.Errorf("failed to send bus name request: %w", err)
}
msg, err := b.client.ReceiveMessage()
@ -93,7 +93,7 @@ func (b *Bus) Name(bus int) (string, error) {
return val, nil
}
// SetName sets the name for a specific bus
// SetName sets the name for a specific bus.
func (b *Bus) SetName(bus int, name string) error {
address := fmt.Sprintf(b.baseAddress, bus) + "/config/name"
return b.client.SendMessage(address, name)

View File

@ -5,11 +5,10 @@ import (
"time"
"github.com/charmbracelet/log"
"github.com/hypebeast/go-osc/osc"
)
// XAirClient is a client for controlling XAir mixers
// XAirClient is a client for controlling XAir mixers.
type XAirClient struct {
client
Main *Main
@ -20,7 +19,7 @@ type XAirClient struct {
DCA *DCA
}
// NewXAirClient creates a new XAirClient instance with optional engine configuration
// 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 {
@ -40,7 +39,7 @@ func NewXAirClient(mixerIP string, mixerPort int, opts ...EngineOption) (*XAirCl
return c, nil
}
// X32Client is a client for controlling X32 mixers
// X32Client is a client for controlling X32 mixers.
type X32Client struct {
client
Main *Main
@ -53,7 +52,7 @@ type X32Client struct {
DCA *DCA
}
// NewX32Client creates a new X32Client instance with optional engine configuration
// NewX32Client creates a new X32Client instance with optional engine configuration.
func NewX32Client(mixerIP string, mixerPort int, opts ...EngineOption) (*X32Client, error) {
e, err := newEngine(mixerIP, mixerPort, kindX32, opts...)
if err != nil {
@ -80,28 +79,28 @@ type client struct {
Info InfoResponse
}
// Start begins listening for messages in a goroutine
// Start begins listening for messages in a goroutine.
func (c *client) StartListening() {
go c.engine.receiveLoop()
go c.receiveLoop()
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() {
close(c.engine.done)
if c.engine.conn != nil {
c.engine.conn.Close()
close(c.done)
if c.conn != nil {
c.conn.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 {
return c.engine.sendToAddress(c.mixerAddr, address, args...)
return c.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) {
t := time.Tick(c.engine.timeout)
t := time.Tick(c.timeout)
select {
case <-t:
return nil, fmt.Errorf("timeout waiting for response")
@ -113,7 +112,7 @@ func (c *client) ReceiveMessage() (*osc.Message, error) {
}
}
// RequestInfo requests mixer information
// RequestInfo requests mixer information.
func (c *client) RequestInfo() (InfoResponse, error) {
var info InfoResponse
err := c.SendMessage("/xinfo")
@ -144,12 +143,12 @@ func (c *client) RequestInfo() (InfoResponse, error) {
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 {
return c.SendMessage("/xremote")
}
// RequestStatus requests mixer status
// RequestStatus requests mixer status.
func (c *client) RequestStatus() error {
return c.SendMessage("/status")
}

View File

@ -9,7 +9,7 @@ type Comp struct {
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 {
comp := &Comp{
client: c,

View File

@ -69,9 +69,9 @@ func (d *DCA) SetName(group int, name string) error {
return d.client.SendMessage(address, name)
}
// Color requests the current color for a DCA group
func (d *DCA) Color(group int) (int32, error) {
address := fmt.Sprintf(d.baseAddress, group) + "/config/color"
// Colour requests the current colour for a DCA group
func (d *DCA) Colour(group int) (int32, error) {
address := fmt.Sprintf(d.baseAddress, group) + "/config/colour"
err := d.client.SendMessage(address)
if err != nil {
return 0, err
@ -81,15 +81,15 @@ func (d *DCA) Color(group int) (int32, error) {
if err != nil {
return 0, err
}
color, ok := msg.Arguments[0].(int32)
colour, ok := msg.Arguments[0].(int32)
if !ok {
return 0, fmt.Errorf("unexpected argument type for DCA color value")
return 0, fmt.Errorf("unexpected argument type for DCA colour value")
}
return color, nil
return colour, nil
}
// SetColor sets the color for a specific DCA group (1-based indexing)
func (d *DCA) SetColor(group int, color int32) error {
address := fmt.Sprintf(d.baseAddress, group) + "/config/color"
return d.client.SendMessage(address, color)
// SetColor sets the colour for a specific DCA group (1-based indexing)
func (d *DCA) SetColor(group int, colour int32) error {
address := fmt.Sprintf(d.baseAddress, group) + "/config/colour"
return d.client.SendMessage(address, colour)
}

View File

@ -1,6 +1,7 @@
package xair
import (
"errors"
"fmt"
"net"
"time"
@ -26,21 +27,26 @@ type engine struct {
respChan chan *osc.Message
}
func newEngine(mixerIP string, mixerPort int, kind mixerKind, opts ...EngineOption) (*engine, error) {
func newEngine(
mixerIP string,
mixerPort int,
kind mixerKind,
opts ...EngineOption,
) (*engine, error) {
localAddr, err := net.ResolveUDPAddr("udp", fmt.Sprintf(":%d", 0))
if err != nil {
return nil, fmt.Errorf("failed to resolve local address: %v", err)
return nil, fmt.Errorf("failed to resolve local address: %w", err)
}
conn, err := net.ListenUDP("udp", localAddr)
if err != nil {
return nil, fmt.Errorf("failed to create UDP connection: %v", err)
return nil, fmt.Errorf("failed to create UDP connection: %w", err)
}
mixerAddr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("%s:%d", mixerIP, mixerPort))
if err != nil {
conn.Close()
return nil, fmt.Errorf("failed to resolve mixer address: %v", err)
return nil, fmt.Errorf("failed to resolve mixer address: %w", err)
}
log.Debugf("Local UDP connection: %s ", conn.LocalAddr().String())
@ -62,7 +68,7 @@ func newEngine(mixerIP string, mixerPort int, kind mixerKind, opts ...EngineOpti
return e, nil
}
// receiveLoop handles incoming OSC messages
// receiveLoop handles incoming OSC messages.
func (e *engine) receiveLoop() {
buffer := make([]byte, 4096)
@ -75,7 +81,8 @@ func (e *engine) receiveLoop() {
e.conn.SetReadDeadline(time.Now().Add(100 * time.Millisecond))
n, _, err := e.conn.ReadFromUDP(buffer)
if err != nil {
if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
var netErr net.Error
if errors.As(err, &netErr) {
// Timeout is expected, continue loop
continue
}
@ -99,7 +106,7 @@ func (e *engine) receiveLoop() {
}
}
// parseOSCMessage parses raw bytes into an OSC message with improved error handling
// parseOSCMessage parses raw bytes into an OSC message with improved error handling.
func (e *engine) parseOSCMessage(data []byte) (*osc.Message, error) {
msg, err := e.parser.Parse(data)
if err != nil {
@ -109,7 +116,7 @@ func (e *engine) parseOSCMessage(data []byte) (*osc.Message, error) {
return msg, nil
}
// sendToAddress sends an OSC message to a specific address (enables replying to different ports)
// sendToAddress sends an OSC message to a specific address (enables replying to different ports).
func (e *engine) sendToAddress(addr *net.UDPAddr, oscAddress string, args ...any) error {
msg := osc.NewMessage(oscAddress)
for _, arg := range args {
@ -130,7 +137,7 @@ func (e *engine) sendToAddress(addr *net.UDPAddr, oscAddress string, args ...any
data, err := msg.MarshalBinary()
if err != nil {
return fmt.Errorf("failed to marshal message: %v", err)
return fmt.Errorf("failed to marshal message: %w", err)
}
_, err = e.conn.WriteToUDP(data, addr)

View File

@ -11,7 +11,7 @@ type Eq struct {
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 {
eq := &Eq{
client: c,
@ -82,7 +82,7 @@ func (e *Eq) SetMode(index int, mode string) error {
}
// Gain retrieves the gain for a specific EQ band on a strip or bus (1-based indexing).
func (e *Eq) Gain(index int, band int) (float64, error) {
func (e *Eq) Gain(index, band int) (float64, error) {
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/g", band)
err := e.client.SendMessage(address)
if err != nil {
@ -101,13 +101,13 @@ func (e *Eq) Gain(index int, band int) (float64, error) {
}
// SetGain sets the gain for a specific EQ band on a strip or bus (1-based indexing).
func (e *Eq) SetGain(index int, band int, gain float64) error {
func (e *Eq) SetGain(index, band int, gain float64) error {
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/g", band)
return e.client.SendMessage(address, float32(linSet(-15, 15, gain)))
}
// Frequency retrieves the frequency for a specific EQ band on a strip or bus (1-based indexing).
func (e *Eq) Frequency(index int, band int) (float64, error) {
func (e *Eq) Frequency(index, band int) (float64, error) {
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/f", band)
err := e.client.SendMessage(address)
if err != nil {
@ -126,13 +126,13 @@ func (e *Eq) Frequency(index int, band int) (float64, error) {
}
// SetFrequency sets the frequency for a specific EQ band on a strip or bus (1-based indexing).
func (e *Eq) SetFrequency(index int, band int, frequency float64) error {
func (e *Eq) SetFrequency(index, band int, frequency float64) error {
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/f", band)
return e.client.SendMessage(address, float32(logSet(20, 20000, frequency)))
}
// Q retrieves the Q factor for a specific EQ band on a strip or bus (1-based indexing).
func (e *Eq) Q(index int, band int) (float64, error) {
func (e *Eq) Q(index, band int) (float64, error) {
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/q", band)
err := e.client.SendMessage(address)
if err != nil {
@ -151,13 +151,13 @@ func (e *Eq) Q(index int, band int) (float64, error) {
}
// SetQ sets the Q factor for a specific EQ band on a strip or bus (1-based indexing).
func (e *Eq) SetQ(index int, band int, q float64) error {
func (e *Eq) SetQ(index, band int, q float64) error {
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/q", band)
return e.client.SendMessage(address, float32(1.0-logSet(0.3, 10, q)))
}
// Type retrieves the type for a specific EQ band on a strip or bus (1-based indexing).
func (e *Eq) Type(index int, band int) (string, error) {
func (e *Eq) Type(index, band int) (string, error) {
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/type", band)
err := e.client.SendMessage(address)
if err != nil {
@ -178,7 +178,7 @@ func (e *Eq) Type(index int, band int) (string, error) {
}
// SetType sets the type for a specific EQ band on a strip or bus (1-based indexing).
func (e *Eq) SetType(index int, band int, eqType string) error {
func (e *Eq) SetType(index, band int, eqType string) error {
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/type", band)
possibleTypes := []string{"lcut", "lshv", "peq", "veq", "hshv", "hcut"}
return e.client.SendMessage(address, int32(indexOf(possibleTypes, eqType)))

View File

@ -9,7 +9,7 @@ type Gate struct {
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 {
gate := &Gate{
client: c,

View File

@ -9,7 +9,7 @@ type Main struct {
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 {
addressFunc := func(fmtString string, args ...any) string {
return fmtString
@ -23,7 +23,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 {
addressFunc := func(fmtString string, args ...any) string {
return fmtString
@ -37,7 +37,7 @@ func newMainMono(c *client) *Main {
}
}
// Fader requests the current main L/R fader level
// Fader requests the current main L/R fader level.
func (m *Main) Fader() (float64, error) {
address := m.baseAddress + "/mix/fader"
err := m.client.SendMessage(address)
@ -56,13 +56,13 @@ func (m *Main) Fader() (float64, error) {
return mustDbFrom(float64(val)), nil
}
// SetFader sets the main L/R fader level
// SetFader sets the main L/R fader level.
func (m *Main) SetFader(level float64) error {
address := m.baseAddress + "/mix/fader"
return m.client.SendMessage(address, float32(mustDbInto(level)))
}
// Mute requests the current main L/R mute status
// Mute requests the current main L/R mute status.
func (m *Main) Mute() (bool, error) {
address := m.baseAddress + "/mix/on"
err := m.client.SendMessage(address)
@ -81,7 +81,7 @@ func (m *Main) Mute() (bool, error) {
return val == 0, nil
}
// SetMute sets the main L/R mute status
// SetMute sets the main L/R mute status.
func (m *Main) SetMute(muted bool) error {
address := m.baseAddress + "/mix/on"
var value int32

View File

@ -9,7 +9,7 @@ type Matrix struct {
Comp *Comp
}
// newMatrix creates a new Matrix instance
// newMatrix creates a new Matrix instance.
func newMatrix(c *client) *Matrix {
return &Matrix{
client: c,
@ -19,7 +19,7 @@ func newMatrix(c *client) *Matrix {
}
}
// Fader requests the current main L/R fader level
// Fader requests the current main L/R fader level.
func (m *Matrix) Fader(index int) (float64, error) {
address := fmt.Sprintf(m.baseAddress, index) + "/mix/fader"
err := m.client.SendMessage(address)
@ -38,13 +38,13 @@ func (m *Matrix) Fader(index int) (float64, error) {
return mustDbFrom(float64(val)), nil
}
// SetFader sets the matrix fader level
// SetFader sets the matrix fader level.
func (m *Matrix) SetFader(index int, level float64) error {
address := fmt.Sprintf(m.baseAddress, index) + "/mix/fader"
return m.client.SendMessage(address, float32(mustDbInto(level)))
}
// Mute requests the current matrix mute status
// Mute requests the current matrix mute status.
func (m *Matrix) Mute(index int) (bool, error) {
address := fmt.Sprintf(m.baseAddress, index) + "/mix/on"
err := m.client.SendMessage(address)
@ -63,7 +63,7 @@ func (m *Matrix) Mute(index int) (bool, error) {
return val == 0, nil
}
// SetMute sets the matrix mute status
// SetMute sets the matrix mute status.
func (m *Matrix) SetMute(index int, muted bool) error {
address := fmt.Sprintf(m.baseAddress, index) + "/mix/on"
var value int32

View File

@ -4,7 +4,7 @@ import "time"
type EngineOption func(*engine)
// WithTimeout sets the timeout duration for OSC message responses
// WithTimeout sets the timeout duration for OSC message responses.
func WithTimeout(timeout time.Duration) EngineOption {
return func(e *engine) {
e.timeout = timeout
@ -13,7 +13,7 @@ func WithTimeout(timeout time.Duration) EngineOption {
type CompOption func(*Comp)
// WithCompAddressFunc allows customization of the OSC address formatting for Comp parameters
// WithCompAddressFunc allows customization of the OSC address formatting for Comp parameters.
func WithCompAddressFunc(f func(fmtString string, args ...any) string) CompOption {
return func(c *Comp) {
c.AddressFunc = f
@ -22,7 +22,7 @@ func WithCompAddressFunc(f func(fmtString string, args ...any) string) CompOptio
type EqOption func(*Eq)
// WithEqAddressFunc allows customization of the OSC address formatting for Eq parameters
// WithEqAddressFunc allows customization of the OSC address formatting for Eq parameters.
func WithEqAddressFunc(f func(fmtString string, args ...any) string) EqOption {
return func(e *Eq) {
e.AddressFunc = f
@ -31,7 +31,7 @@ func WithEqAddressFunc(f func(fmtString string, args ...any) string) EqOption {
type GateOption func(*Gate)
// WithGateAddressFunc allows customization of the OSC address formatting for Gate parameters
// WithGateAddressFunc allows customization of the OSC address formatting for Gate parameters.
func WithGateAddressFunc(f func(fmtString string, args ...any) string) GateOption {
return func(g *Gate) {
g.AddressFunc = f

View File

@ -10,14 +10,13 @@ import (
"github.com/hypebeast/go-osc/osc"
)
type xairParser struct {
}
type xairParser struct{}
func newParser() *xairParser {
return &xairParser{}
}
// parseOSCMessage parses raw bytes into an OSC message with improved error handling
// parseOSCMessage parses raw bytes into an OSC message with improved error handling.
func (p *xairParser) Parse(data []byte) (*osc.Message, error) {
log.Debug("=== PARSING OSC MESSAGE BEGIN ===")
defer log.Debug("=== PARSING OSC MESSAGE END ===")
@ -47,7 +46,7 @@ func (p *xairParser) Parse(data []byte) (*osc.Message, error) {
return msg, nil
}
// validateOSCData performs basic validation on OSC message data
// validateOSCData performs basic validation on OSC message data.
func (p *xairParser) validateOSCData(data []byte) error {
if len(data) < 4 {
return fmt.Errorf("data too short for OSC message")
@ -58,7 +57,7 @@ func (p *xairParser) validateOSCData(data []byte) error {
return nil
}
// extractOSCAddress extracts the OSC address from the message data
// extractOSCAddress extracts the OSC address from the message data.
func (p *xairParser) extractOSCAddress(data []byte) (address string, nextPos int, err error) {
nullPos := bytes.IndexByte(data, 0)
if nullPos <= 0 {
@ -73,8 +72,11 @@ func (p *xairParser) extractOSCAddress(data []byte) (address string, nextPos int
return address, nextPos, nil
}
// extractOSCTypeTags extracts and validates OSC type tags
func (p *xairParser) extractOSCTypeTags(data []byte, start int) (typeTags string, nextPos int, err error) {
// extractOSCTypeTags extracts and validates OSC type tags.
func (p *xairParser) extractOSCTypeTags(
data []byte,
start int,
) (typeTags string, nextPos int, err error) {
if start >= len(data) {
return "", start, nil // No type tags available
}
@ -97,8 +99,13 @@ func (p *xairParser) extractOSCTypeTags(data []byte, start int) (typeTags string
return typeTags, nextPos, nil
}
// parseOSCArguments parses OSC arguments based on type tags
func (p *xairParser) parseOSCArguments(data []byte, argsStart int, typeTags string, msg *osc.Message) error {
// parseOSCArguments parses OSC arguments based on type tags.
func (p *xairParser) parseOSCArguments(
data []byte,
argsStart int,
typeTags string,
msg *osc.Message,
) error {
argData := data[argsStart:]
argNum := 0
@ -138,7 +145,7 @@ func (p *xairParser) parseOSCArguments(data []byte, argsStart int, typeTags stri
return nil
}
// parseStringArgument parses a string argument from OSC data
// parseStringArgument parses a string argument from OSC data.
func (p *xairParser) parseStringArgument(data []byte, msg *osc.Message, argNum int) (int, error) {
nullPos := bytes.IndexByte(data, 0)
if nullPos < 0 {
@ -153,7 +160,7 @@ func (p *xairParser) parseStringArgument(data []byte, msg *osc.Message, argNum i
return ((nullPos + 4) / 4) * 4, nil
}
// parseInt32Argument parses an int32 argument from OSC data
// parseInt32Argument parses an int32 argument from OSC data.
func (p *xairParser) parseInt32Argument(data []byte, msg *osc.Message, argNum int) (int, error) {
if len(data) < 4 {
return 0, fmt.Errorf("insufficient data for int32")
@ -166,7 +173,7 @@ func (p *xairParser) parseInt32Argument(data []byte, msg *osc.Message, argNum in
return 4, nil
}
// parseFloat32Argument parses a float32 argument from OSC data
// parseFloat32Argument parses a float32 argument from OSC data.
func (p *xairParser) parseFloat32Argument(data []byte, msg *osc.Message, argNum int) (int, error) {
if len(data) < 4 {
return 0, fmt.Errorf("insufficient data for float32")
@ -179,7 +186,7 @@ func (p *xairParser) parseFloat32Argument(data []byte, msg *osc.Message, argNum
return 4, nil
}
// parseBlobArgument parses a blob argument from OSC data
// parseBlobArgument parses a blob argument from OSC data.
func (p *xairParser) parseBlobArgument(data []byte, msg *osc.Message, argNum int) (int, error) {
if len(data) < 4 {
return 0, fmt.Errorf("insufficient data for blob size")
@ -203,7 +210,7 @@ func (p *xairParser) parseBlobArgument(data []byte, msg *osc.Message, argNum int
return ((4 + int(size) + 3) / 4) * 4, nil
}
// skipUnknownArgument skips an unknown argument type
// skipUnknownArgument skips an unknown argument type.
func (p *xairParser) skipUnknownArgument(data []byte) int {
// Skip unknown types by moving 4 bytes if available
if len(data) >= 4 {

View File

@ -7,7 +7,7 @@ type Snapshot struct {
baseAddress string
}
// newSnapshot creates a new Snapshot instance
// newSnapshot creates a new Snapshot instance.
func newSnapshot(c *client) *Snapshot {
return &Snapshot{
client: c,

View File

@ -81,7 +81,7 @@ func (s *Strip) Name(strip int) (string, error) {
address := fmt.Sprintf(s.baseAddress, strip) + "/config/name"
err := s.client.SendMessage(address)
if err != nil {
return "", fmt.Errorf("failed to send strip name request: %v", err)
return "", fmt.Errorf("failed to send strip name request: %w", err)
}
msg, err := s.client.ReceiveMessage()
@ -101,12 +101,12 @@ func (s *Strip) SetName(strip int, name string) error {
return s.client.SendMessage(address, name)
}
// Color requests the color for a specific strip
func (s *Strip) Color(strip int) (int32, error) {
address := fmt.Sprintf(s.baseAddress, strip) + "/config/color"
// Colour requests the colour for a specific strip
func (s *Strip) Colour(strip int) (int32, error) {
address := fmt.Sprintf(s.baseAddress, strip) + "/config/colour"
err := s.client.SendMessage(address)
if err != nil {
return 0, fmt.Errorf("failed to send strip color request: %v", err)
return 0, fmt.Errorf("failed to send strip colour request: %w", err)
}
msg, err := s.client.ReceiveMessage()
@ -115,23 +115,23 @@ func (s *Strip) Color(strip int) (int32, error) {
}
val, ok := msg.Arguments[0].(int32)
if !ok {
return 0, fmt.Errorf("unexpected argument type for strip color value")
return 0, fmt.Errorf("unexpected argument type for strip colour value")
}
return val, nil
}
// SetColor sets the color for a specific strip (0-15)
func (s *Strip) SetColor(strip int, color int32) error {
address := fmt.Sprintf(s.baseAddress, strip) + "/config/color"
return s.client.SendMessage(address, color)
// SetColor sets the colour for a specific strip (0-15)
func (s *Strip) SetColor(strip int, colour int32) error {
address := fmt.Sprintf(s.baseAddress, strip) + "/config/colour"
return s.client.SendMessage(address, colour)
}
// SendLevel requests auxiliary send level for a send destination.
func (s *Strip) SendLevel(strip int, bus int) (float64, error) {
func (s *Strip) SendLevel(strip, bus int) (float64, error) {
address := fmt.Sprintf(s.baseAddress, strip) + fmt.Sprintf("/mix/%02d/level", bus)
err := s.client.SendMessage(address)
if err != nil {
return 0, fmt.Errorf("failed to send strip send level request: %v", err)
return 0, fmt.Errorf("failed to send strip send level request: %w", err)
}
msg, err := s.client.ReceiveMessage()
@ -146,7 +146,7 @@ func (s *Strip) SendLevel(strip int, bus int) (float64, error) {
}
// 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, bus int, level float64) error {
address := fmt.Sprintf(s.baseAddress, strip) + fmt.Sprintf("/mix/%02d/level", bus)
return s.client.SendMessage(address, float32(mustDbInto(level)))
}

View File

@ -2,19 +2,19 @@ package xair
import "math"
func linGet(min float64, max float64, value float64) float64 {
func linGet(min, max, value float64) float64 {
return min + (max-min)*value
}
func linSet(min float64, max float64, value float64) float64 {
func linSet(min, max, value float64) float64 {
return (value - min) / (max - min)
}
func logGet(min float64, max float64, value float64) float64 {
func logGet(min, max, value float64) float64 {
return min * math.Exp(math.Log(max/min)*value)
}
func logSet(min float64, max float64, value float64) float64 {
func logSet(min, max, value float64) float64 {
return math.Log(value/min) / math.Log(max/min)
}