mirror of
https://github.com/onyx-and-iris/xair-cli.git
synced 2026-03-03 10:39:12 +00:00
Compare commits
4 Commits
0dc097c49e
...
23422f9641
| Author | SHA1 | Date | |
|---|---|---|---|
| 23422f9641 | |||
| 3c47d12719 | |||
| 8a452c83b9 | |||
| abfb1bf08d |
@ -51,6 +51,7 @@ type CLI struct {
|
||||
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"`
|
||||
Mainmono MainMonoCmdGroup `help:"Control the Main Mono output" cmd:"" group:"MainMono"`
|
||||
Matrix MatrixCmdGroup `help:"Control the matrix outputs." cmd:"" group:"Matrix"`
|
||||
Strip StripCmdGroup `help:"Control the strips." cmd:"" group:"Strip"`
|
||||
Bus BusCmdGroup `help:"Control the buses." cmd:"" group:"Bus"`
|
||||
Headamp HeadampCmdGroup `help:"Control input gain and phantom power." cmd:"" group:"Headamp"`
|
||||
@ -120,7 +121,6 @@ func connect(config Config) (*xair.X32Client, error) {
|
||||
client, err := xair.NewX32Client(
|
||||
config.Host,
|
||||
config.Port,
|
||||
xair.WithKind("x32"),
|
||||
xair.WithTimeout(config.Timeout),
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
499
cmd/x32-cli/matrix.go
Normal file
499
cmd/x32-cli/matrix.go
Normal file
@ -0,0 +1,499 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/alecthomas/kong"
|
||||
)
|
||||
|
||||
// MatrixCmdGroup defines the command group for controlling the Matrix outputs, including commands for mute state, fader level, and fade-in/fade-out times.
|
||||
type MatrixCmdGroup struct {
|
||||
Index struct {
|
||||
Index int `arg:"" help:"The index of the Matrix output (1-6)."`
|
||||
Mute MatrixMuteCmd `help:"Get or set the mute state of the Matrix output." cmd:""`
|
||||
|
||||
Fader MatrixFaderCmd `help:"Get or set the fader level of the Matrix output." cmd:""`
|
||||
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"`
|
||||
Comp MatrixCompCmdGroup `help:"Commands for controlling the compressor settings of the Matrix output." cmd:"comp"`
|
||||
} `help:"Commands for controlling individual Matrix outputs." arg:""`
|
||||
}
|
||||
|
||||
func (cmd *MatrixCmdGroup) Validate(ctx kong.Context) error {
|
||||
if cmd.Index.Index < 1 || cmd.Index.Index > 6 {
|
||||
return fmt.Errorf("invalid Matrix output index: %d. Valid range is 1-6", cmd.Index.Index)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MatrixMuteCmd defines the command for getting or setting the mute state of the Matrix output, allowing users to specify the desired state as "true"/"on" or "false"/"off".
|
||||
type MatrixMuteCmd struct {
|
||||
Mute *string `arg:"" help:"The mute state to set. If not provided, the current state will be printed." optional:"" enum:"true,false"`
|
||||
}
|
||||
|
||||
// Run executes the MatrixMuteCmd command, either retrieving the current mute state of the Matrix output or setting it based on the provided argument.
|
||||
func (cmd *MatrixMuteCmd) Run(ctx *context, matrix *MatrixCmdGroup) error {
|
||||
if cmd.Mute == nil {
|
||||
resp, err := ctx.Client.Matrix.Mute(matrix.Index.Index)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get Matrix mute state: %w", err)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix mute state: %t\n", resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := ctx.Client.Matrix.SetMute(matrix.Index.Index, *cmd.Mute == "true"); err != nil {
|
||||
return fmt.Errorf("failed to set Matrix mute state: %w", err)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix mute state set to: %s\n", *cmd.Mute)
|
||||
return nil
|
||||
}
|
||||
|
||||
// MatrixFaderCmd defines the command for getting or setting the fader level of the Matrix output, allowing users to specify the desired level in dB.
|
||||
type MatrixFaderCmd struct {
|
||||
Level *float64 `arg:"" help:"The fader level to set. If not provided, the current level will be printed." optional:""`
|
||||
}
|
||||
|
||||
// Run executes the MatrixFaderCmd command, either retrieving the current fader level of the Matrix output or setting it based on the provided argument.
|
||||
func (cmd *MatrixFaderCmd) Run(ctx *context, matrix *MatrixCmdGroup) error {
|
||||
if cmd.Level == nil {
|
||||
resp, err := ctx.Client.Matrix.Fader(matrix.Index.Index)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get Matrix fader level: %w", err)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix fader level: %.2f\n", resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := ctx.Client.Matrix.SetFader(matrix.Index.Index, *cmd.Level); err != nil {
|
||||
return fmt.Errorf("failed to set Matrix fader level: %w", err)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix fader level set to: %.2f\n", *cmd.Level)
|
||||
return nil
|
||||
}
|
||||
|
||||
// MatrixFadeinCmd defines the command for getting or setting the fade-in time of the Matrix output, allowing users to specify the desired duration for the fade-in effect.
|
||||
type MatrixFadeinCmd struct {
|
||||
Duration time.Duration `flag:"" help:"The duration of the fade-in. (in seconds.)" default:"5s"`
|
||||
Target float64 ` help:"The target level for the fade-in. If not provided, the current target level will be printed." default:"0.0" arg:""`
|
||||
}
|
||||
|
||||
// Run executes the MatrixFadeinCmd command, either retrieving the current fade-in time of the Matrix output or setting it based on the provided argument, with an optional target level for the fade-in effect.
|
||||
func (cmd *MatrixFadeinCmd) Run(ctx *context, matrix *MatrixCmdGroup) error {
|
||||
currentLevel, err := ctx.Client.Matrix.Fader(matrix.Index.Index)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get Matrix fader level: %w", err)
|
||||
}
|
||||
|
||||
if currentLevel >= cmd.Target {
|
||||
return fmt.Errorf(
|
||||
"current fader level (%.2f) is already at or above the target level (%.2f)",
|
||||
currentLevel,
|
||||
cmd.Target,
|
||||
)
|
||||
}
|
||||
|
||||
totalSteps := float64(cmd.Target - currentLevel)
|
||||
stepDuration := time.Duration(cmd.Duration.Seconds()*1000/totalSteps) * time.Millisecond
|
||||
for currentLevel < cmd.Target {
|
||||
currentLevel++
|
||||
if err := ctx.Client.Matrix.SetFader(matrix.Index.Index, currentLevel); err != nil {
|
||||
return fmt.Errorf("failed to set Matrix fader level: %w", err)
|
||||
}
|
||||
time.Sleep(stepDuration)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix fade-in completed. Final level: %.2f\n", currentLevel)
|
||||
return nil
|
||||
}
|
||||
|
||||
// MatrixFadeoutCmd defines the command for getting or setting the fade-out time of the Matrix output, allowing users to specify the desired duration for the fade-out effect and an optional target level to fade out to.
|
||||
type MatrixFadeoutCmd struct {
|
||||
Duration time.Duration `flag:"" help:"The duration of the fade-out. (in seconds.)" default:"5s"`
|
||||
Target float64 ` help:"The target level for the fade-out. If not provided, the current target level will be printed." default:"-90.0" arg:""`
|
||||
}
|
||||
|
||||
// Run executes the MatrixFadeoutCmd command, either retrieving the current fade-out time of the Matrix output or setting it based on the provided argument, with an optional target level for the fade-out effect.
|
||||
func (cmd *MatrixFadeoutCmd) Run(ctx *context, matrix *MatrixCmdGroup) error {
|
||||
currentLevel, err := ctx.Client.Matrix.Fader(matrix.Index.Index)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get Matrix fader level: %w", err)
|
||||
}
|
||||
|
||||
if currentLevel <= cmd.Target {
|
||||
return fmt.Errorf(
|
||||
"current fader level (%.2f) is already at or below the target level (%.2f)",
|
||||
currentLevel,
|
||||
cmd.Target,
|
||||
)
|
||||
}
|
||||
|
||||
totalSteps := float64(currentLevel - cmd.Target)
|
||||
stepDuration := time.Duration(cmd.Duration.Seconds()*1000/totalSteps) * time.Millisecond
|
||||
for currentLevel > cmd.Target {
|
||||
currentLevel--
|
||||
if err := ctx.Client.Matrix.SetFader(matrix.Index.Index, currentLevel); err != nil {
|
||||
return fmt.Errorf("failed to set Matrix fader level: %w", err)
|
||||
}
|
||||
time.Sleep(stepDuration)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix fade-out completed. Final level: %.2f\n", currentLevel)
|
||||
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.
|
||||
type MatrixEqCmdGroup struct {
|
||||
On MatrixEqOnCmd `help:"Get or set the EQ on/off state of the Matrix output." cmd:"on"`
|
||||
Band struct {
|
||||
Band int `arg:"" help:"The EQ band number."`
|
||||
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"`
|
||||
Q MatrixEqBandQCmd `help:"Get or set the Q factor of the specified EQ band." cmd:"q"`
|
||||
Type MatrixEqBandTypeCmd `help:"Get or set the type of the specified EQ band." cmd:"type"`
|
||||
} `help:"Commands for controlling individual EQ bands of the Matrix output." arg:""`
|
||||
}
|
||||
|
||||
// Validate checks if the provided EQ band number is within the valid range (1-6) for the Matrix output.
|
||||
func (cmd *MatrixEqCmdGroup) Validate(ctx kong.Context) error {
|
||||
if cmd.Band.Band < 1 || cmd.Band.Band > 6 {
|
||||
return fmt.Errorf("invalid EQ band number: %d. Valid range is 1-6", cmd.Band.Band)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MatrixEqOnCmd defines the command for getting or setting the EQ on/off state of the Matrix output, allowing users to specify the desired state as "true"/"on" or "false"/"off".
|
||||
type MatrixEqOnCmd struct {
|
||||
Enable *string `arg:"" help:"The EQ on/off state to set. If not provided, the current state will be printed." optional:"" enum:"true,false"`
|
||||
}
|
||||
|
||||
// Run executes the MatrixEqOnCmd command, either retrieving the current EQ on/off state of the Matrix output or setting it based on the provided argument.
|
||||
func (cmd *MatrixEqOnCmd) Run(ctx *context, matrix *MatrixCmdGroup) error {
|
||||
if cmd.Enable == nil {
|
||||
resp, err := ctx.Client.Matrix.Eq.On(matrix.Index.Index)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get Matrix EQ on/off state: %w", err)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix EQ on/off state: %t\n", resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := ctx.Client.Matrix.Eq.SetOn(matrix.Index.Index, *cmd.Enable == "true"); err != nil {
|
||||
return fmt.Errorf("failed to set Matrix EQ on/off state: %w", err)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix EQ on/off state set to: %t\n", *cmd.Enable == "true")
|
||||
return nil
|
||||
}
|
||||
|
||||
// MatrixEqBandGainCmd defines the command for getting or setting the gain of a specific EQ band on the Matrix output, allowing users to specify the desired gain in dB.
|
||||
type MatrixEqBandGainCmd struct {
|
||||
Level *float64 `arg:"" help:"The gain level to set for the specified EQ band. If not provided, the current gain will be printed." optional:""`
|
||||
}
|
||||
|
||||
// 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 {
|
||||
if cmd.Level == nil {
|
||||
resp, err := ctx.Client.Matrix.Eq.Gain(matrix.Index.Index, matrixEq.Band.Band)
|
||||
if err != nil {
|
||||
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)
|
||||
return 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)
|
||||
return nil
|
||||
}
|
||||
|
||||
// MatrixEqBandFreqCmd defines the command for getting or setting the frequency of a specific EQ band on the Matrix output, allowing users to specify the desired frequency in Hz.
|
||||
type MatrixEqBandFreqCmd struct {
|
||||
Frequency *float64 `arg:"" help:"The frequency to set for the specified EQ band. If not provided, the current frequency will be printed." optional:""`
|
||||
}
|
||||
|
||||
// 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 {
|
||||
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)
|
||||
}
|
||||
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 {
|
||||
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)
|
||||
return nil
|
||||
}
|
||||
|
||||
// MatrixEqBandQCmd defines the command for getting or setting the Q factor of a specific EQ band on the Matrix output, allowing users to specify the desired Q factor.
|
||||
type MatrixEqBandQCmd struct {
|
||||
Q *float64 `arg:"" help:"The Q factor to set for the specified EQ band. If not provided, the current Q factor will be printed." optional:""`
|
||||
}
|
||||
|
||||
// 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 {
|
||||
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)
|
||||
}
|
||||
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 {
|
||||
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)
|
||||
return nil
|
||||
}
|
||||
|
||||
// MatrixEqBandTypeCmd defines the command for getting or setting the type of a specific EQ band on the Matrix output, allowing users to specify the desired type as "peaking", "low_shelf", "high_shelf", "low_pass", or "high_pass".
|
||||
type MatrixEqBandTypeCmd struct {
|
||||
Type *string `arg:"" help:"The type to set for the specified EQ band. If not provided, the current type will be printed." optional:"" enum:"peaking,low_shelf,high_shelf,low_pass,high_pass"`
|
||||
}
|
||||
|
||||
// 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 {
|
||||
if cmd.Type == nil {
|
||||
resp, err := ctx.Client.Matrix.Eq.Type(matrix.Index.Index, matrixEq.Band.Band)
|
||||
if err != nil {
|
||||
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)
|
||||
return 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)
|
||||
return nil
|
||||
}
|
||||
|
||||
// MatrixCompCmdGroup defines the command group for controlling the compressor settings of the Matrix output, including commands for getting or setting the compressor parameters.
|
||||
type MatrixCompCmdGroup struct {
|
||||
On MatrixCompOnCmd `help:"Get or set the compressor on/off state of the Matrix output." cmd:"on"`
|
||||
Mode MatrixCompModeCmd `help:"Get or set the compressor mode of the Matrix output." cmd:"mode"`
|
||||
Threshold MatrixCompThresholdCmd `help:"Get or set the compressor threshold of the Matrix output." cmd:"threshold"`
|
||||
Ratio MatrixCompRatioCmd `help:"Get or set the compressor ratio of the Matrix output." cmd:"ratio"`
|
||||
Mix MatrixCompMixCmd `help:"Get or set the compressor mix level of the Matrix output." cmd:"mix"`
|
||||
Makeup MatrixCompMakeupCmd `help:"Get or set the compressor makeup gain of the Matrix output." cmd:"makeup"`
|
||||
Attack MatrixCompAttackCmd `help:"Get or set the compressor attack time of the Matrix output." cmd:"attack"`
|
||||
Hold MatrixCompHoldCmd `help:"Get or set the compressor hold time of the Matrix output." cmd:"hold"`
|
||||
Release MatrixCompReleaseCmd `help:"Get or set the compressor release time of the Matrix output." cmd:"release"`
|
||||
}
|
||||
|
||||
// MatrixCompOnCmd defines the command for getting or setting the compressor on/off state of the Matrix output, allowing users to specify the desired state as "true"/"on" or "false"/"off".
|
||||
type MatrixCompOnCmd struct {
|
||||
Enable *string `arg:"" help:"The compressor on/off state to set. If not provided, the current state will be printed." optional:"" enum:"true,false"`
|
||||
}
|
||||
|
||||
// Run executes the MatrixCompOnCmd command, either retrieving the current compressor on/off state of the Matrix output or setting it based on the provided argument.
|
||||
func (cmd *MatrixCompOnCmd) Run(ctx *context, matrix *MatrixCmdGroup) error {
|
||||
if cmd.Enable == nil {
|
||||
resp, err := ctx.Client.Matrix.Comp.On(matrix.Index.Index)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get Matrix compressor on/off state: %w", err)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix compressor on/off state: %t\n", resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := ctx.Client.Matrix.Comp.SetOn(matrix.Index.Index, *cmd.Enable == "true"); err != nil {
|
||||
return fmt.Errorf("failed to set Matrix compressor on/off state: %w", err)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix compressor on/off state set to: %t\n", *cmd.Enable == "true")
|
||||
return nil
|
||||
}
|
||||
|
||||
// MatrixCompModeCmd defines the command for getting or setting the compressor mode of the Matrix output, allowing users to specify the desired mode as "comp" or "exp".
|
||||
type MatrixCompModeCmd struct {
|
||||
Mode *string `arg:"" help:"The compressor mode to set. If not provided, the current mode will be printed." optional:"" enum:"comp,exp"`
|
||||
}
|
||||
|
||||
// Run executes the MatrixCompModeCmd command, either retrieving the current compressor mode of the Matrix output or setting it based on the provided argument.
|
||||
func (cmd *MatrixCompModeCmd) Run(ctx *context, matrix *MatrixCmdGroup) error {
|
||||
if cmd.Mode == nil {
|
||||
resp, err := ctx.Client.Matrix.Comp.Mode(matrix.Index.Index)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get Matrix compressor mode: %w", err)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix compressor mode: %s\n", resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := ctx.Client.Matrix.Comp.SetMode(matrix.Index.Index, *cmd.Mode); err != nil {
|
||||
return fmt.Errorf("failed to set Matrix compressor mode: %w", err)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix compressor mode set to: %s\n", *cmd.Mode)
|
||||
return nil
|
||||
}
|
||||
|
||||
// MatrixCompThresholdCmd defines the command for getting or setting the compressor threshold of the Matrix output, allowing users to specify the desired threshold in dB.
|
||||
type MatrixCompThresholdCmd struct {
|
||||
Threshold *float64 `arg:"" help:"The compressor threshold to set. If not provided, the current threshold will be printed." optional:""`
|
||||
}
|
||||
|
||||
// Run executes the MatrixCompThresholdCmd command, either retrieving the current compressor threshold of the Matrix output or setting it based on the provided argument.
|
||||
func (cmd *MatrixCompThresholdCmd) Run(ctx *context, matrix *MatrixCmdGroup) error {
|
||||
if cmd.Threshold == nil {
|
||||
resp, err := ctx.Client.Matrix.Comp.Threshold(matrix.Index.Index)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get Matrix compressor threshold: %w", err)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix compressor threshold: %.2f dB\n", resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := ctx.Client.Matrix.Comp.SetThreshold(matrix.Index.Index, *cmd.Threshold); err != nil {
|
||||
return fmt.Errorf("failed to set Matrix compressor threshold: %w", err)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix compressor threshold set to: %.2f dB\n", *cmd.Threshold)
|
||||
return nil
|
||||
}
|
||||
|
||||
// MatrixCompRatioCmd defines the command for getting or setting the compressor ratio of the Matrix output, allowing users to specify the desired ratio.
|
||||
type MatrixCompRatioCmd struct {
|
||||
Ratio *float64 `arg:"" help:"The compressor ratio to set. If not provided, the current ratio will be printed." optional:""`
|
||||
}
|
||||
|
||||
// Run executes the MatrixCompRatioCmd command, either retrieving the current compressor ratio of the Matrix output or setting it based on the provided argument.
|
||||
func (cmd *MatrixCompRatioCmd) Run(ctx *context, matrix *MatrixCmdGroup) error {
|
||||
if cmd.Ratio == nil {
|
||||
resp, err := ctx.Client.Matrix.Comp.Ratio(matrix.Index.Index)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get Matrix compressor ratio: %w", err)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix compressor ratio: %.2f\n", resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := ctx.Client.Matrix.Comp.SetRatio(matrix.Index.Index, *cmd.Ratio); err != nil {
|
||||
return fmt.Errorf("failed to set Matrix compressor ratio: %w", err)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix compressor ratio set to: %.2f\n", *cmd.Ratio)
|
||||
return nil
|
||||
}
|
||||
|
||||
// MatrixCompMixCmd defines the command for getting or setting the compressor mix level of the Matrix output, allowing users to specify the desired mix level in percentage.
|
||||
type MatrixCompMixCmd struct {
|
||||
Mix *float64 `arg:"" help:"The compressor mix level to set. If not provided, the current mix level will be printed." optional:""`
|
||||
}
|
||||
|
||||
// Run executes the MatrixCompMixCmd command, either retrieving the current compressor mix level of the Matrix output or setting it based on the provided argument.
|
||||
func (cmd *MatrixCompMixCmd) Run(ctx *context, matrix *MatrixCmdGroup) error {
|
||||
if cmd.Mix == nil {
|
||||
resp, err := ctx.Client.Matrix.Comp.Mix(matrix.Index.Index)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get Matrix compressor mix level: %w", err)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix compressor mix level: %.2f%%\n", resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := ctx.Client.Matrix.Comp.SetMix(matrix.Index.Index, *cmd.Mix); err != nil {
|
||||
return fmt.Errorf("failed to set Matrix compressor mix level: %w", err)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix compressor mix level set to: %.2f%%\n", *cmd.Mix)
|
||||
return nil
|
||||
}
|
||||
|
||||
// MatrixCompMakeupCmd defines the command for getting or setting the compressor makeup gain of the Matrix output, allowing users to specify the desired makeup gain in dB.
|
||||
type MatrixCompMakeupCmd struct {
|
||||
Makeup *float64 `arg:"" help:"The compressor makeup gain to set. If not provided, the current makeup gain will be printed." optional:""`
|
||||
}
|
||||
|
||||
// Run executes the MatrixCompMakeupCmd command, either retrieving the current compressor makeup gain of the Matrix output or setting it based on the provided argument.
|
||||
func (cmd *MatrixCompMakeupCmd) Run(ctx *context, matrix *MatrixCmdGroup) error {
|
||||
if cmd.Makeup == nil {
|
||||
resp, err := ctx.Client.Matrix.Comp.Makeup(matrix.Index.Index)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get Matrix compressor makeup gain: %w", err)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix compressor makeup gain: %.2f dB\n", resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := ctx.Client.Matrix.Comp.SetMakeup(matrix.Index.Index, *cmd.Makeup); err != nil {
|
||||
return fmt.Errorf("failed to set Matrix compressor makeup gain: %w", err)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix compressor makeup gain set to: %.2f dB\n", *cmd.Makeup)
|
||||
return nil
|
||||
}
|
||||
|
||||
// MatrixCompAttackCmd defines the command for getting or setting the compressor attack time of the Matrix output, allowing users to specify the desired attack time in milliseconds.
|
||||
type MatrixCompAttackCmd struct {
|
||||
Attack *float64 `arg:"" help:"The compressor attack time to set. If not provided, the current attack time will be printed." optional:""`
|
||||
}
|
||||
|
||||
// Run executes the MatrixCompAttackCmd command, either retrieving the current compressor attack time of the Matrix output or setting it based on the provided argument.
|
||||
func (cmd *MatrixCompAttackCmd) Run(ctx *context, matrix *MatrixCmdGroup) error {
|
||||
if cmd.Attack == nil {
|
||||
resp, err := ctx.Client.Matrix.Comp.Attack(matrix.Index.Index)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get Matrix compressor attack time: %w", err)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix compressor attack time: %.2f ms\n", resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := ctx.Client.Matrix.Comp.SetAttack(matrix.Index.Index, *cmd.Attack); err != nil {
|
||||
return fmt.Errorf("failed to set Matrix compressor attack time: %w", err)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix compressor attack time set to: %.2f ms\n", *cmd.Attack)
|
||||
return nil
|
||||
}
|
||||
|
||||
// MatrixCompHoldCmd defines the command for getting or setting the compressor hold time of the Matrix output, allowing users to specify the desired hold time in milliseconds.
|
||||
type MatrixCompHoldCmd struct {
|
||||
Hold *float64 `arg:"" help:"The compressor hold time to set. If not provided, the current hold time will be printed." optional:""`
|
||||
}
|
||||
|
||||
// Run executes the MatrixCompHoldCmd command, either retrieving the current compressor hold time of the Matrix output or setting it based on the provided argument.
|
||||
func (cmd *MatrixCompHoldCmd) Run(ctx *context, matrix *MatrixCmdGroup) error {
|
||||
if cmd.Hold == nil {
|
||||
resp, err := ctx.Client.Matrix.Comp.Hold(matrix.Index.Index)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get Matrix compressor hold time: %w", err)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix compressor hold time: %.2f ms\n", resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := ctx.Client.Matrix.Comp.SetHold(matrix.Index.Index, *cmd.Hold); err != nil {
|
||||
return fmt.Errorf("failed to set Matrix compressor hold time: %w", err)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix compressor hold time set to: %.2f ms\n", *cmd.Hold)
|
||||
return nil
|
||||
}
|
||||
|
||||
// MatrixCompReleaseCmd defines the command for getting or setting the compressor release time of the Matrix output, allowing users to specify the desired release time in milliseconds.
|
||||
type MatrixCompReleaseCmd struct {
|
||||
Release *float64 `arg:"" help:"The compressor release time to set. If not provided, the current release time will be printed." optional:""`
|
||||
}
|
||||
|
||||
// Run executes the MatrixCompReleaseCmd command, either retrieving the current compressor release time of the Matrix output or setting it based on the provided argument.
|
||||
func (cmd *MatrixCompReleaseCmd) Run(ctx *context, matrix *MatrixCmdGroup) error {
|
||||
if cmd.Release == nil {
|
||||
resp, err := ctx.Client.Matrix.Comp.Release(matrix.Index.Index)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get Matrix compressor release time: %w", err)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix compressor release time: %.2f ms\n", resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := ctx.Client.Matrix.Comp.SetRelease(matrix.Index.Index, *cmd.Release); err != nil {
|
||||
return fmt.Errorf("failed to set Matrix compressor release time: %w", err)
|
||||
}
|
||||
fmt.Fprintf(ctx.Out, "Matrix compressor release time set to: %.2f ms\n", *cmd.Release)
|
||||
return nil
|
||||
}
|
||||
@ -119,7 +119,6 @@ func connect(config Config) (*xair.XAirClient, error) {
|
||||
client, err := xair.NewXAirClient(
|
||||
config.Host,
|
||||
config.Port,
|
||||
xair.WithKind("xair"),
|
||||
xair.WithTimeout(config.Timeout),
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
@ -18,9 +18,9 @@ var x32AddressMap = map[string]string{
|
||||
"snapshot": "/-snap",
|
||||
}
|
||||
|
||||
func addressMapForMixerKind(kind MixerKind) map[string]string {
|
||||
func addressMapFromMixerKind(kind mixerKind) map[string]string {
|
||||
switch kind {
|
||||
case KindX32:
|
||||
case kindX32:
|
||||
return x32AddressMap
|
||||
default:
|
||||
return xairAddressMap
|
||||
|
||||
@ -9,12 +9,13 @@ type Bus struct {
|
||||
Comp *Comp
|
||||
}
|
||||
|
||||
// newBus creates a new Bus instance
|
||||
func newBus(c *Client) *Bus {
|
||||
return &Bus{
|
||||
client: c,
|
||||
baseAddress: c.addressMap["bus"],
|
||||
Eq: newEqForBus(c),
|
||||
Comp: newCompForBus(c),
|
||||
Eq: newEq(c, c.addressMap["bus"]),
|
||||
Comp: newComp(c, c.addressMap["bus"]),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,6 @@ package xair
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/charmbracelet/log"
|
||||
@ -11,9 +10,10 @@ import (
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
engine
|
||||
*engine
|
||||
}
|
||||
|
||||
// XAirClient is a client for controlling XAir mixers
|
||||
type XAirClient struct {
|
||||
Client
|
||||
Main *Main
|
||||
@ -23,6 +23,7 @@ type XAirClient struct {
|
||||
Snapshot *Snapshot
|
||||
}
|
||||
|
||||
// X32Client is a client for controlling X32 mixers
|
||||
type X32Client struct {
|
||||
Client
|
||||
Main *Main
|
||||
@ -34,50 +35,15 @@ type X32Client struct {
|
||||
Snapshot *Snapshot
|
||||
}
|
||||
|
||||
func createEngine(mixerIP string, mixerPort int, opts ...Option) (*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)
|
||||
}
|
||||
|
||||
conn, err := net.ListenUDP("udp", localAddr)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create UDP connection: %v", 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)
|
||||
}
|
||||
|
||||
log.Debugf("Local UDP connection: %s ", conn.LocalAddr().String())
|
||||
|
||||
e := &engine{
|
||||
timeout: 100 * time.Millisecond,
|
||||
conn: conn,
|
||||
mixerAddr: mixerAddr,
|
||||
parser: newParser(),
|
||||
done: make(chan bool),
|
||||
respChan: make(chan *osc.Message, 100),
|
||||
}
|
||||
|
||||
for _, opt := range opts {
|
||||
opt(e)
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
||||
|
||||
// NewX32Client creates a new X32Client instance
|
||||
func NewX32Client(mixerIP string, mixerPort int, opts ...Option) (*X32Client, error) {
|
||||
e, err := createEngine(mixerIP, mixerPort, opts...)
|
||||
// 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 {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
c := &X32Client{
|
||||
Client: Client{*e},
|
||||
Client: Client{e},
|
||||
}
|
||||
c.Main = newMainStereo(&c.Client)
|
||||
c.MainMono = newMainMono(&c.Client)
|
||||
@ -90,15 +56,15 @@ func NewX32Client(mixerIP string, mixerPort int, opts ...Option) (*X32Client, er
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// NewXAirClient creates a new XAirClient instance
|
||||
func NewXAirClient(mixerIP string, mixerPort int, opts ...Option) (*XAirClient, error) {
|
||||
e, err := createEngine(mixerIP, mixerPort, opts...)
|
||||
// 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},
|
||||
Client: Client{e},
|
||||
}
|
||||
c.Main = newMainStereo(&c.Client)
|
||||
c.Strip = newStrip(&c.Client)
|
||||
|
||||
@ -2,53 +2,31 @@ package xair
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Comp represents the compressor parameters.
|
||||
type Comp struct {
|
||||
client *Client
|
||||
baseAddress string
|
||||
AddressFunc func(fmtString string, args ...any) string
|
||||
}
|
||||
|
||||
// Factory function to create Comp instance for Main
|
||||
func newCompForMain(c *Client) *Comp {
|
||||
return &Comp{
|
||||
// Factory function to create Comp instance with optional configuration
|
||||
func newComp(c *Client, baseAddress string, opts ...CompOption) *Comp {
|
||||
comp := &Comp{
|
||||
client: c,
|
||||
baseAddress: c.addressMap["main"],
|
||||
AddressFunc: func(fmtString string, args ...any) string {
|
||||
return fmtString
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Factory function to create Comp instance for Strip
|
||||
func newCompForStrip(c *Client) *Comp {
|
||||
return &Comp{
|
||||
client: c,
|
||||
baseAddress: c.addressMap["strip"],
|
||||
baseAddress: fmt.Sprintf("%s/dyn", baseAddress),
|
||||
AddressFunc: fmt.Sprintf,
|
||||
}
|
||||
|
||||
for _, opt := range opts {
|
||||
opt(comp)
|
||||
}
|
||||
|
||||
// Factory function to create Comp instance for Bus
|
||||
func newCompForBus(c *Client) *Comp {
|
||||
return &Comp{
|
||||
client: c,
|
||||
baseAddress: c.addressMap["bus"],
|
||||
AddressFunc: fmt.Sprintf,
|
||||
}
|
||||
}
|
||||
|
||||
// Factory function to create Comp instance for Matrix
|
||||
func newCompForMatrix(c *Client) *Comp {
|
||||
return &Comp{
|
||||
client: c,
|
||||
baseAddress: c.addressMap["matrix"],
|
||||
AddressFunc: fmt.Sprintf,
|
||||
}
|
||||
return comp
|
||||
}
|
||||
|
||||
// On retrieves the on/off status of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) On(index int) (bool, error) {
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/on"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/on"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@ -67,7 +45,7 @@ func (c *Comp) On(index int) (bool, error) {
|
||||
|
||||
// SetOn sets the on/off status of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) SetOn(index int, on bool) error {
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/on"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/on"
|
||||
var value int32
|
||||
if on {
|
||||
value = 1
|
||||
@ -77,7 +55,7 @@ func (c *Comp) SetOn(index int, on bool) error {
|
||||
|
||||
// Mode retrieves the current mode of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) Mode(index int) (string, error) {
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/mode"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/mode"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -98,14 +76,14 @@ func (c *Comp) Mode(index int) (string, error) {
|
||||
|
||||
// SetMode sets the mode of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) SetMode(index int, mode string) error {
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/mode"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/mode"
|
||||
possibleModes := []string{"comp", "exp"}
|
||||
return c.client.SendMessage(address, int32(indexOf(possibleModes, mode)))
|
||||
}
|
||||
|
||||
// Threshold retrieves the threshold value of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) Threshold(index int) (float64, error) {
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/thr"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/thr"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@ -124,13 +102,13 @@ func (c *Comp) Threshold(index int) (float64, error) {
|
||||
|
||||
// SetThreshold sets the threshold value of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) SetThreshold(index int, threshold float64) error {
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/thr"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/thr"
|
||||
return c.client.SendMessage(address, float32(linSet(-60, 0, threshold)))
|
||||
}
|
||||
|
||||
// Ratio retrieves the ratio value of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) Ratio(index int) (float32, error) {
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/ratio"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/ratio"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@ -152,7 +130,7 @@ func (c *Comp) Ratio(index int) (float32, error) {
|
||||
|
||||
// SetRatio sets the ratio value of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) SetRatio(index int, ratio float64) error {
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/ratio"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/ratio"
|
||||
possibleValues := []float32{1.1, 1.3, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 7.0, 10, 20, 100}
|
||||
|
||||
return c.client.SendMessage(address, int32(indexOf(possibleValues, float32(ratio))))
|
||||
@ -160,7 +138,7 @@ func (c *Comp) SetRatio(index int, ratio float64) error {
|
||||
|
||||
// Attack retrieves the attack time of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) Attack(index int) (float64, error) {
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/attack"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/attack"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@ -179,13 +157,13 @@ func (c *Comp) Attack(index int) (float64, error) {
|
||||
|
||||
// SetAttack sets the attack time of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) SetAttack(index int, attack float64) error {
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/attack"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/attack"
|
||||
return c.client.SendMessage(address, float32(linSet(0, 120, attack)))
|
||||
}
|
||||
|
||||
// Hold retrieves the hold time of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) Hold(index int) (float64, error) {
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/hold"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/hold"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@ -204,13 +182,13 @@ func (c *Comp) Hold(index int) (float64, error) {
|
||||
|
||||
// SetHold sets the hold time of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) SetHold(index int, hold float64) error {
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/hold"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/hold"
|
||||
return c.client.SendMessage(address, float32(logSet(0.02, 2000, hold)))
|
||||
}
|
||||
|
||||
// Release retrieves the release time of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) Release(index int) (float64, error) {
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/release"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/release"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@ -229,13 +207,13 @@ func (c *Comp) Release(index int) (float64, error) {
|
||||
|
||||
// SetRelease sets the release time of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) SetRelease(index int, release float64) error {
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/release"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/release"
|
||||
return c.client.SendMessage(address, float32(logSet(4, 4000, release)))
|
||||
}
|
||||
|
||||
// Makeup retrieves the makeup gain of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) Makeup(index int) (float64, error) {
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/mgain"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/mgain"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@ -254,13 +232,13 @@ func (c *Comp) Makeup(index int) (float64, error) {
|
||||
|
||||
// SetMakeup sets the makeup gain of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) SetMakeup(index int, makeup float64) error {
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/mgain"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/mgain"
|
||||
return c.client.SendMessage(address, float32(linSet(0, 24, makeup)))
|
||||
}
|
||||
|
||||
// Mix retrieves the mix value of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) Mix(index int) (float64, error) {
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/mix"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/mix"
|
||||
err := c.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@ -279,6 +257,6 @@ func (c *Comp) Mix(index int) (float64, error) {
|
||||
|
||||
// SetMix sets the mix value of the Compressor for a specific strip or bus (1-based indexing).
|
||||
func (c *Comp) SetMix(index int, mix float64) error {
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/dyn/mix"
|
||||
address := c.AddressFunc(c.baseAddress, index) + "/mix"
|
||||
return c.client.SendMessage(address, float32(linSet(0, 100, mix)))
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ type parser interface {
|
||||
}
|
||||
|
||||
type engine struct {
|
||||
Kind MixerKind
|
||||
Kind mixerKind
|
||||
timeout time.Duration
|
||||
conn *net.UDPConn
|
||||
mixerAddr *net.UDPAddr
|
||||
@ -26,6 +26,42 @@ type engine struct {
|
||||
respChan chan *osc.Message
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
conn, err := net.ListenUDP("udp", localAddr)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create UDP connection: %v", 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)
|
||||
}
|
||||
|
||||
log.Debugf("Local UDP connection: %s ", conn.LocalAddr().String())
|
||||
|
||||
e := &engine{
|
||||
timeout: 100 * time.Millisecond,
|
||||
conn: conn,
|
||||
mixerAddr: mixerAddr,
|
||||
parser: newParser(),
|
||||
addressMap: addressMapFromMixerKind(kind),
|
||||
done: make(chan bool),
|
||||
respChan: make(chan *osc.Message, 100),
|
||||
}
|
||||
|
||||
for _, opt := range opts {
|
||||
opt(e)
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
||||
|
||||
// receiveLoop handles incoming OSC messages
|
||||
func (e *engine) receiveLoop() {
|
||||
buffer := make([]byte, 4096)
|
||||
|
||||
@ -4,53 +4,31 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Eq represents the EQ parameters.
|
||||
type Eq struct {
|
||||
client *Client
|
||||
baseAddress string
|
||||
AddressFunc func(fmtString string, args ...any) string
|
||||
}
|
||||
|
||||
// Factory function to create Eq instance for Main
|
||||
func newEqForMain(c *Client) *Eq {
|
||||
return &Eq{
|
||||
// Factory function to create Eq instance with optional configuration
|
||||
func newEq(c *Client, baseAddress string, opts ...EqOption) *Eq {
|
||||
eq := &Eq{
|
||||
client: c,
|
||||
baseAddress: c.addressMap["main"],
|
||||
AddressFunc: func(fmtString string, args ...any) string {
|
||||
return fmtString
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Factory function to create Eq instance for Strip
|
||||
func newEqForStrip(c *Client) *Eq {
|
||||
return &Eq{
|
||||
client: c,
|
||||
baseAddress: c.addressMap["strip"],
|
||||
baseAddress: fmt.Sprintf("%s/eq", baseAddress),
|
||||
AddressFunc: fmt.Sprintf,
|
||||
}
|
||||
|
||||
for _, opt := range opts {
|
||||
opt(eq)
|
||||
}
|
||||
|
||||
// Factory function to create Eq instance for Bus
|
||||
func newEqForBus(c *Client) *Eq {
|
||||
return &Eq{
|
||||
client: c,
|
||||
baseAddress: c.addressMap["bus"],
|
||||
AddressFunc: fmt.Sprintf,
|
||||
}
|
||||
}
|
||||
|
||||
// Factory function to create Eq instance for Matrix
|
||||
func newEqForMatrix(c *Client) *Eq {
|
||||
return &Eq{
|
||||
client: c,
|
||||
baseAddress: c.addressMap["matrix"],
|
||||
AddressFunc: fmt.Sprintf,
|
||||
}
|
||||
return eq
|
||||
}
|
||||
|
||||
// On retrieves the on/off status of the EQ for a specific strip or bus (1-based indexing).
|
||||
func (e *Eq) On(index int) (bool, error) {
|
||||
address := e.AddressFunc(e.baseAddress, index) + "/eq/on"
|
||||
address := e.AddressFunc(e.baseAddress, index) + "/on"
|
||||
err := e.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@ -69,7 +47,7 @@ func (e *Eq) On(index int) (bool, error) {
|
||||
|
||||
// SetOn sets the on/off status of the EQ for a specific strip or bus (1-based indexing).
|
||||
func (e *Eq) SetOn(index int, on bool) error {
|
||||
address := e.AddressFunc(e.baseAddress, index) + "/eq/on"
|
||||
address := e.AddressFunc(e.baseAddress, index) + "/on"
|
||||
var value int32
|
||||
if on {
|
||||
value = 1
|
||||
@ -78,7 +56,7 @@ func (e *Eq) SetOn(index int, on bool) error {
|
||||
}
|
||||
|
||||
func (e *Eq) Mode(index int) (string, error) {
|
||||
address := e.AddressFunc(e.baseAddress, index) + "/eq/mode"
|
||||
address := e.AddressFunc(e.baseAddress, index) + "/mode"
|
||||
err := e.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -98,14 +76,14 @@ func (e *Eq) Mode(index int) (string, error) {
|
||||
}
|
||||
|
||||
func (e *Eq) SetMode(index int, mode string) error {
|
||||
address := e.AddressFunc(e.baseAddress, index) + "/eq/mode"
|
||||
address := e.AddressFunc(e.baseAddress, index) + "/mode"
|
||||
possibleModes := []string{"peq", "geq", "teq"}
|
||||
return e.client.SendMessage(address, int32(indexOf(possibleModes, mode)))
|
||||
}
|
||||
|
||||
// Gain retrieves the gain for a specific EQ band on a strip or bus (1-based indexing).
|
||||
func (e *Eq) Gain(index int, band int) (float64, error) {
|
||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/g", band)
|
||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/g", band)
|
||||
err := e.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@ -124,13 +102,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 {
|
||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/g", band)
|
||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/g", band)
|
||||
return e.client.SendMessage(address, float32(linSet(-15, 15, gain)))
|
||||
}
|
||||
|
||||
// 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) {
|
||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/f", band)
|
||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/f", band)
|
||||
err := e.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@ -149,13 +127,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 {
|
||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/f", band)
|
||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/f", band)
|
||||
return e.client.SendMessage(address, float32(logSet(20, 20000, frequency)))
|
||||
}
|
||||
|
||||
// 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) {
|
||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/q", band)
|
||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/q", band)
|
||||
err := e.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@ -174,13 +152,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 {
|
||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/q", band)
|
||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/q", band)
|
||||
return e.client.SendMessage(address, float32(1.0-logSet(0.3, 10, q)))
|
||||
}
|
||||
|
||||
// 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) {
|
||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/type", band)
|
||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/type", band)
|
||||
err := e.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -201,7 +179,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 {
|
||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/type", band)
|
||||
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/type", band)
|
||||
possibleTypes := []string{"lcut", "lshv", "peq", "veq", "hshv", "hcut"}
|
||||
return e.client.SendMessage(address, int32(indexOf(possibleTypes, eqType)))
|
||||
}
|
||||
|
||||
@ -2,22 +2,31 @@ package xair
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Gate represents the gate parameters.
|
||||
type Gate struct {
|
||||
client *Client
|
||||
baseAddress string
|
||||
AddressFunc func(fmtString string, args ...any) string
|
||||
}
|
||||
|
||||
// Factory function to create Gate instance for Strip
|
||||
func newGateForStrip(c *Client) *Gate {
|
||||
return &Gate{
|
||||
// Factory function to create Gate instance with optional configuration
|
||||
func newGate(c *Client, baseAddress string, opts ...GateOption) *Gate {
|
||||
gate := &Gate{
|
||||
client: c,
|
||||
baseAddress: c.addressMap["strip"],
|
||||
baseAddress: fmt.Sprintf("%s/gate", baseAddress),
|
||||
AddressFunc: fmt.Sprintf,
|
||||
}
|
||||
|
||||
for _, opt := range opts {
|
||||
opt(gate)
|
||||
}
|
||||
|
||||
return gate
|
||||
}
|
||||
|
||||
// On retrieves the on/off status of the Gate for a specific strip (1-based indexing).
|
||||
func (g *Gate) On(index int) (bool, error) {
|
||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/on"
|
||||
address := g.AddressFunc(g.baseAddress, index) + "/on"
|
||||
err := g.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return false, err
|
||||
@ -36,7 +45,7 @@ func (g *Gate) On(index int) (bool, error) {
|
||||
|
||||
// SetOn sets the on/off status of the Gate for a specific strip (1-based indexing).
|
||||
func (g *Gate) SetOn(index int, on bool) error {
|
||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/on"
|
||||
address := g.AddressFunc(g.baseAddress, index) + "/on"
|
||||
var value int32
|
||||
if on {
|
||||
value = 1
|
||||
@ -46,7 +55,7 @@ func (g *Gate) SetOn(index int, on bool) error {
|
||||
|
||||
// Mode retrieves the current mode of the Gate for a specific strip (1-based indexing).
|
||||
func (g *Gate) Mode(index int) (string, error) {
|
||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/mode"
|
||||
address := g.AddressFunc(g.baseAddress, index) + "/mode"
|
||||
err := g.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -67,7 +76,7 @@ func (g *Gate) Mode(index int) (string, error) {
|
||||
|
||||
// SetMode sets the mode of the Gate for a specific strip (1-based indexing).
|
||||
func (g *Gate) SetMode(index int, mode string) error {
|
||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/mode"
|
||||
address := g.AddressFunc(g.baseAddress, index) + "/mode"
|
||||
possibleModes := []string{"exp2", "exp3", "exp4", "gate", "duck"}
|
||||
|
||||
return g.client.SendMessage(address, int32(indexOf(possibleModes, mode)))
|
||||
@ -75,7 +84,7 @@ func (g *Gate) SetMode(index int, mode string) error {
|
||||
|
||||
// Threshold retrieves the threshold value of the Gate for a specific strip (1-based indexing).
|
||||
func (g *Gate) Threshold(index int) (float64, error) {
|
||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/thr"
|
||||
address := g.AddressFunc(g.baseAddress, index) + "/thr"
|
||||
err := g.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@ -94,13 +103,13 @@ func (g *Gate) Threshold(index int) (float64, error) {
|
||||
|
||||
// SetThreshold sets the threshold value of the Gate for a specific strip (1-based indexing).
|
||||
func (g *Gate) SetThreshold(index int, threshold float64) error {
|
||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/thr"
|
||||
address := g.AddressFunc(g.baseAddress, index) + "/thr"
|
||||
return g.client.SendMessage(address, float32(linSet(-80, 0, threshold)))
|
||||
}
|
||||
|
||||
// Range retrieves the range value of the Gate for a specific strip (1-based indexing).
|
||||
func (g *Gate) Range(index int) (float64, error) {
|
||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/range"
|
||||
address := g.AddressFunc(g.baseAddress, index) + "/range"
|
||||
err := g.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@ -119,13 +128,13 @@ func (g *Gate) Range(index int) (float64, error) {
|
||||
|
||||
// SetRange sets the range value of the Gate for a specific strip (1-based indexing).
|
||||
func (g *Gate) SetRange(index int, rangeVal float64) error {
|
||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/range"
|
||||
address := g.AddressFunc(g.baseAddress, index) + "/range"
|
||||
return g.client.SendMessage(address, float32(linSet(3, 60, rangeVal)))
|
||||
}
|
||||
|
||||
// Attack retrieves the attack time of the Gate for a specific strip (1-based indexing).
|
||||
func (g *Gate) Attack(index int) (float64, error) {
|
||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/attack"
|
||||
address := g.AddressFunc(g.baseAddress, index) + "/attack"
|
||||
err := g.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@ -144,13 +153,13 @@ func (g *Gate) Attack(index int) (float64, error) {
|
||||
|
||||
// SetAttack sets the attack time of the Gate for a specific strip (1-based indexing).
|
||||
func (g *Gate) SetAttack(index int, attack float64) error {
|
||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/attack"
|
||||
address := g.AddressFunc(g.baseAddress, index) + "/attack"
|
||||
return g.client.SendMessage(address, float32(linSet(0, 120, attack)))
|
||||
}
|
||||
|
||||
// Hold retrieves the hold time of the Gate for a specific strip (1-based indexing).
|
||||
func (g *Gate) Hold(index int) (float64, error) {
|
||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/hold"
|
||||
address := g.AddressFunc(g.baseAddress, index) + "/hold"
|
||||
err := g.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@ -169,13 +178,13 @@ func (g *Gate) Hold(index int) (float64, error) {
|
||||
|
||||
// SetHold sets the hold time of the Gate for a specific strip (1-based indexing).
|
||||
func (g *Gate) SetHold(index int, hold float64) error {
|
||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/hold"
|
||||
address := g.AddressFunc(g.baseAddress, index) + "/hold"
|
||||
return g.client.SendMessage(address, float32(logSet(0.02, 2000, hold)))
|
||||
}
|
||||
|
||||
// Release retrieves the release time of the Gate for a specific strip (1-based indexing).
|
||||
func (g *Gate) Release(index int) (float64, error) {
|
||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/release"
|
||||
address := g.AddressFunc(g.baseAddress, index) + "/release"
|
||||
err := g.client.SendMessage(address)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@ -194,6 +203,6 @@ func (g *Gate) Release(index int) (float64, error) {
|
||||
|
||||
// SetRelease sets the release time of the Gate for a specific strip (1-based indexing).
|
||||
func (g *Gate) SetRelease(index int, release float64) error {
|
||||
address := fmt.Sprintf(g.baseAddress, index) + "/gate/release"
|
||||
address := g.AddressFunc(g.baseAddress, index) + "/release"
|
||||
return g.client.SendMessage(address, float32(logSet(5, 4000, release)))
|
||||
}
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
package xair
|
||||
|
||||
type MixerKind string
|
||||
type mixerKind string
|
||||
|
||||
const (
|
||||
KindXAir MixerKind = "xair"
|
||||
KindX32 MixerKind = "x32"
|
||||
kindXAir mixerKind = "xair"
|
||||
kindX32 mixerKind = "x32"
|
||||
)
|
||||
|
||||
@ -11,19 +11,29 @@ type Main struct {
|
||||
|
||||
// newMainStereo creates a new Main instance for stereo main output
|
||||
func newMainStereo(c *Client) *Main {
|
||||
addressFunc := func(fmtString string, args ...any) string {
|
||||
return fmtString
|
||||
}
|
||||
|
||||
return &Main{
|
||||
client: c,
|
||||
baseAddress: c.addressMap["main"],
|
||||
Eq: newEqForMain(c),
|
||||
Comp: newCompForMain(c),
|
||||
Eq: newEq(c, c.addressMap["main"], WithEqAddressFunc(addressFunc)),
|
||||
Comp: newComp(c, c.addressMap["main"], WithCompAddressFunc(addressFunc)),
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
return &Main{
|
||||
baseAddress: c.addressMap["mainmono"],
|
||||
client: c,
|
||||
Eq: newEq(c, c.addressMap["mainmono"], WithEqAddressFunc(addressFunc)),
|
||||
Comp: newComp(c, c.addressMap["mainmono"], WithCompAddressFunc(addressFunc)),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -14,8 +14,8 @@ func newMatrix(c *Client) *Matrix {
|
||||
return &Matrix{
|
||||
client: c,
|
||||
baseAddress: c.addressMap["matrix"],
|
||||
Eq: newEqForMatrix(c),
|
||||
Comp: newCompForMatrix(c),
|
||||
Eq: newEq(c, c.addressMap["matrix"]),
|
||||
Comp: newComp(c, c.addressMap["matrix"]),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,17 +2,38 @@ package xair
|
||||
|
||||
import "time"
|
||||
|
||||
type Option func(*engine)
|
||||
type EngineOption func(*engine)
|
||||
|
||||
func WithKind(kind string) Option {
|
||||
return func(e *engine) {
|
||||
e.Kind = MixerKind(kind)
|
||||
e.addressMap = addressMapForMixerKind(e.Kind)
|
||||
}
|
||||
}
|
||||
|
||||
func WithTimeout(timeout time.Duration) Option {
|
||||
// WithTimeout sets the timeout duration for OSC message responses
|
||||
func WithTimeout(timeout time.Duration) EngineOption {
|
||||
return func(e *engine) {
|
||||
e.timeout = timeout
|
||||
}
|
||||
}
|
||||
|
||||
type CompOption func(*Comp)
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
|
||||
type EqOption func(*Eq)
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
|
||||
type GateOption func(*Gate)
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ type Snapshot struct {
|
||||
baseAddress string
|
||||
}
|
||||
|
||||
// newSnapshot creates a new Snapshot instance
|
||||
func newSnapshot(c *Client) *Snapshot {
|
||||
return &Snapshot{
|
||||
client: c,
|
||||
|
||||
@ -10,13 +10,14 @@ type Strip struct {
|
||||
Comp *Comp
|
||||
}
|
||||
|
||||
// newStrip creates a new Strip instance
|
||||
func newStrip(c *Client) *Strip {
|
||||
return &Strip{
|
||||
client: c,
|
||||
baseAddress: c.addressMap["strip"],
|
||||
Gate: newGateForStrip(c),
|
||||
Eq: newEqForStrip(c),
|
||||
Comp: newCompForStrip(c),
|
||||
Gate: newGate(c, c.addressMap["strip"]),
|
||||
Eq: newEq(c, c.addressMap["strip"]),
|
||||
Comp: newComp(c, c.addressMap["strip"]),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user