Compare commits

..

No commits in common. "main" and "v0.11.0" have entirely different histories.

51 changed files with 696 additions and 5306 deletions

View File

@ -23,8 +23,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.6.0
args: --config .golangci.yml
- name: Install golangci-lint
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- name: Run golangci-lint
run: golangci-lint run ./...

1
.gitignore vendored
View File

@ -30,7 +30,6 @@ go.work.sum
# env file
.env
.envrc
# Editor/IDE
# .idea/

View File

@ -1,142 +1,54 @@
version: '2'
run:
# timeout for analysis, e.g. 30s, 3m, default is 1m
timeout: 3m
# exclude test files
tests: true
go: '1.24'
linters:
disable: [dupl]
enable:
# Default enabled linters
- errcheck # Check for unchecked errors
- govet # Go's built-in vetting tool
- ineffassign # Detect ineffectual assignments
- staticcheck # Advanced static analysis
- unused # Check for unused code
# Additional useful linters
- misspell # Detect common misspellings
- unparam # Check for unused function parameters
- gosec # Security checks
- asciicheck # Check for non-ASCII characters
- errname # Check error variable names
- godot # Check for missing periods in comments
- revive # Highly configurable linter for style and correctness
- gocritic # Detect code issues and suggest improvements
- gocyclo # Check for cyclomatic complexity
- dupl # Check for code duplication
- predeclared # Check for shadowing of predeclared identifiers
- copyloopvar # Check for loop variable capture in goroutines
- errorlint # Check for common mistakes in error handling
- goconst # Check for repeated strings that could be constants
- gosmopolitan # Check for non-portable code
# Set to true runs only fast linters.
# Good option for 'lint on save', pre-commit hook or CI.
fast: true
disable-all: true
enable:
- gosimple
- govet
- ineffassign
- staticcheck
- unused
- gofmt
- gofumpt
- misspell
- unparam
- gosec
- asciicheck
- errname
- gci
- godot
- goimports
- revive
linters-settings:
gofmt:
rewrite-rules:
- pattern: 'interface{}'
replacement: 'any'
- pattern: 'a[b:len(a)]'
replacement: 'a[b:]'
settings:
misspell:
locale: UK
errcheck:
check-type-assertions: true
check-blank: true
exclude-functions:
- fmt.Fprintf
- fmt.Fprintln
- fmt.Printf
- fmt.Println
- fmt.Errorf
revive:
severity: warning
rules:
# Code quality and style
- name: exported
arguments:
- 'checkPrivateReceivers'
- 'sayRepetitiveInsteadOfStutters'
- name: var-naming
- name: package-comments
- name: range-val-in-closure
- name: time-naming
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: empty-block
- name: error-return
- name: error-strings
- name: error-naming
- name: if-return
- name: increment-decrement
- name: indent-error-flow
- name: receiver-naming
- name: redefines-builtin-id
- name: superfluous-else
- name: unexported-return
- name: unreachable-code
- name: unused-parameter
- name: var-declaration
- name: blank-imports
- name: range
# Disabled rules (can be enabled if needed)
# - name: line-length-limit
# arguments: [120]
# - name: function-length
# arguments: [50, 0]
# - name: cyclomatic
# arguments: [10]
gosec:
excludes:
- G104 # Duplicated errcheck checks
- G115 # integer overflow conversion int -> uint32
exclusions:
warn-unused: false
rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- gocyclo
- errcheck
- dupl
- gosec
paths:
- vendor
# Formatters configuration
formatters:
# Enable specific formatters
enable:
- gofumpt # Stricter gofmt alternative
- goimports # Organizes imports
- gci # Controls import order/grouping
- golines # Enforces line length
# Formatter-specific settings
settings:
goimports:
local-prefixes: [github.com/onyx-and-iris/xair-cli]
gci:
# Define import sections order
sections:
- standard # Standard library
- default # Everything else
- prefix(github.com/onyx-and-iris/xair-cli) # Current module
gofumpt:
extra-rules: true # Enable additional formatting rules
exclusions:
warn-unused: true
paths:
- vendor
issues:
# Limit the number of same issues reported to avoid spam
max-same-issues: 50
# Limit the number of issues per linter to keep output manageable
max-issues-per-linter: 100
max-same-issues: 0
max-issues-per-linter: 0
exclude-use-default: false
exclude:
# gosec: Duplicated errcheck checks
- G104
# gosec: integer overflow conversion int -> uint32
- G115

View File

@ -8,9 +8,6 @@
version: 2
env:
- CGO_ENABLED=0
before:
hooks:
# You may remove this if you don't use go modules.
@ -19,19 +16,8 @@ before:
- go generate ./...
builds:
- main: ./cmd/x32-cli
id: 'x32-cli'
binary: x32-cli
goos:
- linux
- windows
- darwin
goarch:
- amd64
- main: ./cmd/xair-cli
id: 'xair-cli'
binary: xair-cli
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
@ -40,28 +26,10 @@ builds:
- amd64
archives:
- id: 'x32-cli-archive'
builds: ['x32-cli']
formats: ['tar.gz']
- formats: ['tar.gz']
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
x32-cli_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
formats: ['zip']
- id: 'xair-cli-archive'
builds: ['xair-cli']
formats: ['tar.gz']
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
xair-cli_
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386

View File

@ -1,8 +0,0 @@
repos:
- repo: local
hooks:
- id: update-readme
name: update-readme
entry: python update_readme.py
language: python
pass_filenames: false

168
README.md
View File

@ -2,15 +2,8 @@
### Installation
*xair-cli*
```console
go install github.com/onyx-and-iris/xair-cli/cmd/xair-cli@latest
```
*x32-cli*
```console
go install github.com/onyx-and-iris/xair-cli/cmd/x32-cli@latest
go install github.com/onyx-and-iris/xair-cli@latest
```
### Configuration
@ -19,49 +12,161 @@ go install github.com/onyx-and-iris/xair-cli/cmd/x32-cli@latest
- --host/-H: Host of the mixer.
- --port/-P: Port of the mixer.
- --timeout/-T: Timeout for OSC operations.
- --kind/-k: The kind of mixer. May be one of (*xair*, *x32*).
- Use this flag to connect to an x32 mixer.
- --loglevel/-L: The application's logging verbosity.
Pass `--host` and any other configuration as flags on the root commmand:
```console
xair-cli --host mixer.local --timeout 50ms --help
xair-cli --host mixer.local --kind xair --timeout 50ms --help
```
#### Environment Variables
Or you may load them from your environment:
Example xair .envrc:
Example .envrc:
```bash
#!/usr/bin/env bash
export XAIR_CLI_HOST=mixer.local
export XAIR_CLI_PORT=10024
export XAIR_CLI_TIMEOUT=100ms
export XAIR_CLI_LOGLEVEL=warn
XAIR_CLI_HOST=mixer.local
XAIR_CLI_PORT=10024
XAIR_CLI_KIND=xair
XAIR_CLI_TIMEOUT=100ms
XAIR_CLI_LOGLEVEL=warn
```
Example x32 .envrc:
```bash
#!/usr/bin/env bash
export X32_CLI_HOST=x32.local
export X32_CLI_PORT=10023
export X32_CLI_TIMEOUT=100ms
export X32_CLI_LOGLEVEL=warn
```
---
### Use
For each command/subcommand in the tree there exists a `--help` flag, use it to print usage information.
```console
Usage: xair-cli <command> [flags]
- [xair-cli](./xair-help.md)
- [x32-cli](./x32-help.md)
A CLI to control Behringer X-Air mixers.
Flags:
-h, --help Show context-sensitive help.
-H, --host="mixer.local" The host of the X-Air device ($XAIR_CLI_HOST).
-P, --port=10024 The port of the X-Air device ($XAIR_CLI_PORT).
-K, --kind="xair" The kind of the X-Air device ($XAIR_CLI_KIND).
-T, --timeout=100ms Timeout for OSC operations ($XAIR_CLI_TIMEOUT).
-L, --loglevel="warn" Log level for the CLI ($XAIR_CLI_LOGLEVEL).
-v, --version Print xair-cli version information and quit
Commands:
completion (c) Generate shell completion scripts.
Raw
raw Send raw OSC messages to the mixer.
Main
main mute Get or set the mute state of the Main L/R output.
main fader Get or set the fader level of the Main L/R output.
main fadein Fade in the Main L/R output over a specified duration.
main fadeout Fade out the Main L/R output over a specified duration.
main eq on Get or set the EQ on/off state of the Main L/R output.
main eq <band> gain Get or set the gain of the specified EQ band.
main eq <band> freq Get or set the frequency of the specified EQ band.
main eq <band> q Get or set the Q factor of the specified EQ band.
main eq <band> type Get or set the type of the specified EQ band.
main comp on Get or set the compressor on/off state of the Main L/R
output.
main comp mode Get or set the compressor mode of the Main L/R output.
main comp threshold Get or set the compressor threshold of the Main L/R
output.
main comp ratio Get or set the compressor ratio of the Main L/R output.
main comp mix Get or set the compressor mix level of the Main L/R
output.
main comp makeup Get or set the compressor makeup gain of the Main L/R
output.
main comp attack Get or set the compressor attack time of the Main L/R
output.
main comp hold Get or set the compressor hold time of the Main L/R
output.
main comp release Get or set the compressor release time of the Main L/R
output.
Strip
strip <index> mute Get or set the mute state of the strip.
strip <index> fader Get or set the fader level of the strip.
strip <index> fadein Fade in the strip over a specified duration.
strip <index> fadeout Fade out the strip over a specified duration.
strip <index> send Get or set the send level for a specific bus.
strip <index> name Get or set the name of the strip.
strip <index> gate on Get or set the gate on/off state of the strip.
strip <index> gate mode Get or set the gate mode of the strip.
strip <index> gate threshold Get or set the gate threshold of the strip.
strip <index> gate range Get or set the gate range of the strip.
strip <index> gate attack Get or set the gate attack time of the strip.
strip <index> gate hold Get or set the gate hold time of the strip.
strip <index> gate release Get or set the gate release time of the strip.
strip <index> eq on Get or set the EQ on/off state of the strip.
strip <index> eq <band> gain Get or set the gain of the EQ band.
strip <index> eq <band> freq Get or set the frequency of the EQ band.
strip <index> eq <band> q Get or set the Q factor of the EQ band.
strip <index> eq <band> type Get or set the type of the EQ band.
strip <index> comp on Get or set the compressor on/off state of the
strip.
strip <index> comp mode Get or set the compressor mode of the strip.
strip <index> comp threshold Get or set the compressor threshold of the
strip.
strip <index> comp ratio Get or set the compressor ratio of the strip.
strip <index> comp mix Get or set the compressor mix of the strip.
strip <index> comp makeup Get or set the compressor makeup gain of the
strip.
strip <index> comp attack Get or set the compressor attack time of the
strip.
strip <index> comp hold Get or set the compressor hold time of the
strip.
strip <index> comp release Get or set the compressor release time of the
strip.
Bus
bus <index> mute Get or set the mute state of the bus.
bus <index> fader Get or set the fader level of the bus.
bus <index> fadein Fade in the bus over a specified duration.
bus <index> fadeout Fade out the bus over a specified duration.
bus <index> name Get or set the name of the bus.
bus <index> eq on Get or set the EQ on/off state of the bus.
bus <index> eq mode Get or set the EQ mode of the bus (peq, geq or
teq).
bus <index> eq <band> gain Get or set the gain of the EQ band.
bus <index> eq <band> freq Get or set the frequency of the EQ band.
bus <index> eq <band> q Get or set the Q factor of the EQ band.
bus <index> eq <band> type Get or set the type of the EQ band (lcut, lshv,
peq, veq, hshv, hcut).
bus <index> comp on Get or set the compressor on/off state of the
bus.
bus <index> comp mode Get or set the compressor mode of the bus (comp,
exp).
bus <index> comp threshold Get or set the compressor threshold of the bus
(in dB).
bus <index> comp ratio Get or set the compressor ratio of the bus.
bus <index> comp mix Get or set the compressor mix level of the bus
(in %).
bus <index> comp makeup Get or set the compressor makeup gain of the bus
(in dB).
bus <index> comp attack Get or set the compressor attack time of the bus
(in ms).
bus <index> comp hold Get or set the compressor hold time of the bus
(in ms).
bus <index> comp release Get or set the compressor release time of the
bus (in ms).
Headamp
headamp <index> gain Get or set the gain of the headamp.
headamp <index> phantom Get or set the phantom power state of the headamp.
Snapshot
snapshot list List all snapshots.
snapshot <index> name Get or set the name of a snapshot.
snapshot <index> save Save the current mixer state to a snapshot.
snapshot <index> load Load a mixer state from a snapshot.
snapshot <index> delete Delete a snapshot.
Run "xair-cli <command> --help" for more information on a command.
```
### Examples
@ -111,7 +216,6 @@ xair-cli raw /ch/01/config/name
xair-cli snapshot 20 save 'twitch live'
```
---
### License

View File

@ -1,22 +0,0 @@
version: '3'
vars:
WINDOWS: '{{.BIN_DIR}}/{{.PROGRAM}}_windows_amd64.exe'
LINUX: '{{.BIN_DIR}}/{{.PROGRAM}}_linux_amd64'
MACOS: '{{.BIN_DIR}}/{{.PROGRAM}}_darwin_amd64'
tasks:
windows-amd64:
desc: Build the x32-cli project for Windows
cmds:
- GOOS=windows GOARCH=amd64 go build -o {{.WINDOWS}} -ldflags="-X main.version={{.VERSION}}" ./cmd/{{.PROGRAM}}
linux-amd64:
desc: Build the x32-cli project for Linux
cmds:
- GOOS=linux GOARCH=amd64 go build -o {{.LINUX}} -ldflags="-X main.version={{.VERSION}}" ./cmd/{{.PROGRAM}}
darwin-amd64:
desc: Build the x32-cli project for macOS
cmds:
- GOOS=darwin GOARCH=amd64 go build -o {{.MACOS}} -ldflags="-X main.version={{.VERSION}}" ./cmd/{{.PROGRAM}}

View File

@ -1,22 +0,0 @@
version: '3'
vars:
WINDOWS: '{{.BIN_DIR}}/{{.PROGRAM}}_windows_amd64.exe'
LINUX: '{{.BIN_DIR}}/{{.PROGRAM}}_linux_amd64'
MACOS: '{{.BIN_DIR}}/{{.PROGRAM}}_darwin_amd64'
tasks:
windows-amd64:
desc: Build the xair-cli project for Windows
cmds:
- GOOS=windows GOARCH=amd64 go build -o {{.WINDOWS}} -ldflags="-X main.version={{.VERSION}}" ./cmd/{{.PROGRAM}}
linux-amd64:
desc: Build the xair-cli project for Linux
cmds:
- GOOS=linux GOARCH=amd64 go build -o {{.LINUX}} -ldflags="-X main.version={{.VERSION}}" ./cmd/{{.PROGRAM}}
darwin-amd64:
desc: Build the xair-cli project for macOS
cmds:
- GOOS=darwin GOARCH=amd64 go build -o {{.MACOS}} -ldflags="-X main.version={{.VERSION}}" ./cmd/{{.PROGRAM}}

View File

@ -1,38 +1,29 @@
version: '3'
includes:
build-xair:
taskfile: ./Taskfile.build-xair.yml
internal: true
vars:
PROGRAM: xair-cli
build-x32:
taskfile: ./Taskfile.build-x32.yml
internal: true
vars:
PROGRAM: x32-cli
vars:
SHELL: '{{if eq .OS "Windows_NT"}}powershell{{end}}'
BIN_DIR: bin
VERSION:
sh: 'git describe --tags $(git rev-list --tags --max-count=1)'
WINDOWS: '{{.BIN_DIR}}/{{.PROGRAM}}_windows_amd64.exe'
LINUX: '{{.BIN_DIR}}/{{.PROGRAM}}_linux_amd64'
MACOS: '{{.BIN_DIR}}/{{.PROGRAM}}_darwin_amd64'
tasks:
default:
desc: Build the xair-cli and x32-cli projects for all platforms
desc: Build the xair-cli project
cmds:
- task: build
build:
desc: Build the xair-cli and x32-cli projects for all platforms
desc: Build the xair-cli project
deps: [vet]
cmds:
- for:
matrix:
PROGRAM: ['build-xair', 'build-x32']
TARGET: ['windows-amd64', 'linux-amd64', 'darwin-amd64']
task: '{{.ITEM.PROGRAM}}:{{.ITEM.TARGET}}'
- task: build-windows
- task: build-linux
- task: build-macos
vet:
desc: Vet the code
@ -45,6 +36,24 @@ tasks:
cmds:
- go fmt ./...
build-windows:
desc: Build the xair-cli project for Windows
cmds:
- GOOS=windows GOARCH=amd64 go build -o {{.WINDOWS}} -ldflags="-X main.version={{.VERSION}}"
internal: true
build-linux:
desc: Build the xair-cli project for Linux
cmds:
- GOOS=linux GOARCH=amd64 go build -o {{.LINUX}} -ldflags="-X main.version={{.VERSION}}"
internal: true
build-macos:
desc: Build the xair-cli project for macOS
cmds:
- GOOS=darwin GOARCH=amd64 go build -o {{.MACOS}} -ldflags="-X main.version={{.VERSION}}"
internal: true
test:
desc: Run tests
cmds:

View File

@ -3,6 +3,8 @@ package main
import (
"fmt"
"time"
"github.com/alecthomas/kong"
)
// BusCmdGroup defines the commands related to controlling the buses of the X-Air device.
@ -36,7 +38,7 @@ func (cmd *BusMuteCmd) Run(ctx *context, bus *BusCmdGroup) error {
return nil
}
if err := ctx.Client.Bus.SetMute(bus.Index.Index, *cmd.State == trueStr); err != nil {
if err := ctx.Client.Bus.SetMute(bus.Index.Index, *cmd.State == "true"); err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d mute state set to: %s\n", bus.Index.Index, *cmd.State)
@ -101,12 +103,7 @@ 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
}
@ -145,12 +142,7 @@ 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
}
@ -182,7 +174,7 @@ type BusEqCmdGroup struct {
On BusEqOnCmd `help:"Get or set the EQ on/off state of the bus." cmd:"on"`
Mode BusEqModeCmd `help:"Get or set the EQ mode of the bus (peq, geq or teq)." cmd:"mode"`
Band struct {
Band *int `arg:"" help:"The EQ band number." optional:""`
Band int `arg:"" help:"The EQ band number."`
Gain BusEqBandGainCmd `help:"Get or set the gain of the EQ band." cmd:"gain"`
Freq BusEqBandFreqCmd `help:"Get or set the frequency of the EQ band." cmd:"freq"`
Q BusEqBandQCmd `help:"Get or set the Q factor of the EQ band." cmd:"q"`
@ -191,13 +183,9 @@ type BusEqCmdGroup struct {
}
// Validate checks that the provided EQ band number is within the valid range (1-6).
func (cmd *BusEqCmdGroup) Validate() error {
if cmd.Band.Band == nil {
return nil
}
if *cmd.Band.Band < 1 || *cmd.Band.Band > 6 {
return fmt.Errorf("EQ band number must be between 1 and 6, got %d", *cmd.Band.Band)
func (cmd *BusEqCmdGroup) Validate(ctx kong.Context) error {
if cmd.Band.Band < 1 || cmd.Band.Band > 6 {
return fmt.Errorf("EQ band number must be between 1 and 6")
}
return nil
}
@ -218,7 +206,7 @@ func (cmd *BusEqOnCmd) Run(ctx *context, bus *BusCmdGroup) error {
return nil
}
if err := ctx.Client.Bus.Eq.SetOn(bus.Index.Index, *cmd.State == trueStr); err != nil {
if err := ctx.Client.Bus.Eq.SetOn(bus.Index.Index, *cmd.State == "true"); err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d EQ on state set to: %s\n", bus.Index.Index, *cmd.State)
@ -256,30 +244,18 @@ type BusEqBandGainCmd struct {
// Run executes the BusEqBandGainCmd command, either retrieving the current gain of the specified EQ band of the bus or setting it based on the provided argument.
func (cmd *BusEqBandGainCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGroup) error {
if cmd.Gain == nil {
resp, err := ctx.Client.Bus.Eq.Gain(bus.Index.Index, *busEq.Band.Band)
resp, err := ctx.Client.Bus.Eq.Gain(bus.Index.Index, busEq.Band.Band)
if err != nil {
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 {
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
}
@ -291,34 +267,18 @@ type BusEqBandFreqCmd struct {
// Run executes the BusEqBandFreqCmd command, either retrieving the current frequency of the specified EQ band of the bus or setting it based on the provided argument.
func (cmd *BusEqBandFreqCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGroup) error {
if cmd.Freq == nil {
resp, err := ctx.Client.Bus.Eq.Frequency(bus.Index.Index, *busEq.Band.Band)
resp, err := ctx.Client.Bus.Eq.Frequency(bus.Index.Index, busEq.Band.Band)
if err != nil {
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
}
@ -330,30 +290,18 @@ type BusEqBandQCmd struct {
// Run executes the BusEqBandQCmd command, either retrieving the current Q factor of the specified EQ band of the bus or setting it based on the provided argument.
func (cmd *BusEqBandQCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGroup) error {
if cmd.Q == nil {
resp, err := ctx.Client.Bus.Eq.Q(bus.Index.Index, *busEq.Band.Band)
resp, err := ctx.Client.Bus.Eq.Q(bus.Index.Index, busEq.Band.Band)
if err != nil {
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 {
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
}
@ -365,30 +313,18 @@ type BusEqBandTypeCmd struct {
// Run executes the BusEqBandTypeCmd command, either retrieving the current type of the specified EQ band of the bus or setting it based on the provided argument.
func (cmd *BusEqBandTypeCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGroup) error {
if cmd.Type == nil {
resp, err := ctx.Client.Bus.Eq.Type(bus.Index.Index, *busEq.Band.Band)
resp, err := ctx.Client.Bus.Eq.Type(bus.Index.Index, busEq.Band.Band)
if err != nil {
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 {
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
}
@ -421,7 +357,7 @@ func (cmd *BusCompOnCmd) Run(ctx *context, bus *BusCmdGroup) error {
return nil
}
if err := ctx.Client.Bus.Comp.SetOn(bus.Index.Index, *cmd.State == trueStr); err != nil {
if err := ctx.Client.Bus.Comp.SetOn(bus.Index.Index, *cmd.State == "true"); err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d compressor on state set to: %s\n", bus.Index.Index, *cmd.State)
@ -470,12 +406,7 @@ 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
}
@ -544,12 +475,7 @@ 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
}
@ -572,12 +498,7 @@ 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
}
@ -600,12 +521,7 @@ 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
}
@ -628,11 +544,6 @@ 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,15 +11,9 @@ import (
"github.com/alecthomas/kong"
"github.com/charmbracelet/log"
kongcompletion "github.com/jotaen/kong-completion"
"github.com/onyx-and-iris/xair-cli/internal/xair"
)
const (
trueStr = "true"
falseStr = "false"
)
var version string // Version of the CLI, set at build time.
// VersionFlag is a custom flag type that prints the version and exits.
@ -34,13 +28,14 @@ func (v VersionFlag) BeforeApply(app *kong.Kong, vars kong.Vars) error { // noli
}
type context struct {
Client *xair.XAirClient
Client *xair.Client
Out io.Writer
}
type Config struct {
Host string `default:"mixer.local" help:"The host of the X-Air device." env:"XAIR_CLI_HOST" short:"H"`
Port int `default:"10024" help:"The port of the X-Air device." env:"XAIR_CLI_PORT" short:"P"`
Kind string `default:"xair" help:"The kind of the X-Air device." env:"XAIR_CLI_KIND" short:"K" enum:"xair,x32"`
Timeout time.Duration `default:"100ms" help:"Timeout for OSC operations." env:"XAIR_CLI_TIMEOUT" short:"T"`
Loglevel string `default:"warn" help:"Log level for the CLI." env:"XAIR_CLI_LOGLEVEL" short:"L" enum:"debug,info,warn,error,fatal"`
}
@ -52,16 +47,14 @@ type CLI struct {
Version VersionFlag `help:"Print xair-cli version information and quit" name:"version" short:"v"`
Completion kongcompletion.Completion `help:"Generate shell completion scripts." cmd:""`
Info InfoCmd `help:"Print mixer information." cmd:""`
Raw RawCmd `help:"Send raw OSC messages to the mixer." cmd:""`
Completion kongcompletion.Completion `help:"Generate shell completion scripts." cmd:"" aliases:"c"`
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"`
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"`
Snapshot SnapshotCmdGroup `help:"Save and load mixer states." cmd:"" group:"Snapshot"`
Dca DCACmdGroup `help:"Control DCA groups." cmd:"" group:"DCA"`
}
func main() {
@ -77,15 +70,14 @@ func main() {
}),
kong.Vars{
"version": func() string {
if version != "" {
return version
}
if version == "" {
info, ok := debug.ReadBuildInfo()
if !ok {
return "(unable to read version)"
return "(unable to read build info)"
}
return strings.Split(info.Main.Version, "-")[0]
version = strings.Split(info.Main.Version, "-")[0]
}
return version
}(),
},
)
@ -106,11 +98,7 @@ func run(ctx *kong.Context, config Config) error {
if err != nil {
return fmt.Errorf("failed to connect to X-Air device: %w", err)
}
defer func() {
if err := client.Close(); err != nil {
log.Errorf("failed to close client connection: %v", err)
}
}()
defer client.Close()
client.StartListening()
resp, err := client.RequestInfo()
@ -128,14 +116,15 @@ func run(ctx *kong.Context, config Config) error {
}
// connect creates a new X-Air client based on the provided configuration.
func connect(config Config) (*xair.XAirClient, error) {
client, err := xair.NewXAirClient(
func connect(config Config) (*xair.Client, error) {
client, err := xair.NewClient(
config.Host,
config.Port,
xair.WithKind(config.Kind),
xair.WithTimeout(config.Timeout),
)
if err != nil {
return nil, fmt.Errorf("failed to create X-Air client: %w", err)
return nil, err
}
return client, nil

View File

@ -1,638 +0,0 @@
package main
import (
"fmt"
"time"
)
// BusCmdGroup defines the commands related to controlling the buses of the X-Air device.
type BusCmdGroup struct {
Index struct {
Index int `arg:"" help:"The index of the bus. (1-based indexing)"`
Mute BusMuteCmd ` help:"Get or set the mute state of the bus." cmd:""`
Fader BusFaderCmd ` help:"Get or set the fader level of the bus." cmd:""`
Fadein BusFadeinCmd ` help:"Fade in the bus over a specified duration." cmd:""`
Fadeout BusFadeoutCmd ` help:"Fade out the bus over a specified duration." cmd:""`
Name BusNameCmd ` help:"Get or set the name of the bus." cmd:""`
Eq BusEqCmdGroup ` help:"Commands related to the bus EQ." cmd:"eq"`
Comp BusCompCmdGroup ` help:"Commands related to the bus compressor." cmd:"comp"`
} `arg:"" help:"Control a specific bus by index."`
}
// BusMuteCmd defines the command for getting or setting the mute state of a bus.
type BusMuteCmd struct {
State *string `arg:"" help:"The mute state to set (true or false). If not provided, the current mute state will be returned." optional:"" enum:"true,false"`
}
// Run executes the BusMuteCmd command, either retrieving the current mute state or setting it based on the provided argument.
func (cmd *BusMuteCmd) Run(ctx *context, bus *BusCmdGroup) error {
if cmd.State == nil {
resp, err := ctx.Client.Bus.Mute(bus.Index.Index)
if err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d mute state: %t\n", bus.Index.Index, resp)
return nil
}
if err := ctx.Client.Bus.SetMute(bus.Index.Index, *cmd.State == trueStr); err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d mute state set to: %s\n", bus.Index.Index, *cmd.State)
return nil
}
// BusFaderCmd defines the command for getting or setting the fader level of a bus.
type BusFaderCmd struct {
Level *float64 `arg:"" help:"The fader level to set (in dB). If not provided, the current fader level will be returned." optional:""`
}
// Run executes the BusFaderCmd command, either retrieving the current fader level or setting it based on the provided argument.
func (cmd *BusFaderCmd) Run(ctx *context, bus *BusCmdGroup) error {
if cmd.Level == nil {
resp, err := ctx.Client.Bus.Fader(bus.Index.Index)
if err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d fader level: %.2f dB\n", bus.Index.Index, resp)
return nil
}
if err := ctx.Client.Bus.SetFader(bus.Index.Index, *cmd.Level); err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d fader level set to: %.2f dB\n", bus.Index.Index, *cmd.Level)
return nil
}
// BusFadeinCmd defines the command for fading in a bus over a specified duration to a target fader level.
type BusFadeinCmd struct {
Duration time.Duration `flag:"" help:"The duration of the fade-in effect." default:"5s"`
Target float64 ` help:"The target fader level (in dB)." default:"0.0" arg:""`
}
// Run executes the BusFadeinCmd command, gradually increasing the fader level of the bus from its current level to the target level over the specified duration.
func (cmd *BusFadeinCmd) Run(ctx *context, bus *BusCmdGroup) error {
currentLevel, err := ctx.Client.Bus.Fader(bus.Index.Index)
if err != nil {
return fmt.Errorf("failed to get current fader level: %w", err)
}
if currentLevel >= cmd.Target {
return fmt.Errorf(
"current fader level (%.2f dB) is already at or above the target level (%.2f dB)",
currentLevel,
cmd.Target,
)
}
totalSteps := float64(cmd.Target - currentLevel)
stepDuration := time.Duration(cmd.Duration.Seconds()*1000/totalSteps) * time.Millisecond
for currentLevel < cmd.Target {
currentLevel += totalSteps / float64(cmd.Duration.Seconds()*1000/stepDuration.Seconds())
if currentLevel > cmd.Target {
currentLevel = cmd.Target
}
if err := ctx.Client.Bus.SetFader(bus.Index.Index, currentLevel); err != nil {
return fmt.Errorf("failed to set fader level: %w", err)
}
time.Sleep(stepDuration)
}
fmt.Fprintf(
ctx.Out,
"Bus %d fade-in complete. Final level: %.2f dB\n",
bus.Index.Index,
cmd.Target,
)
return nil
}
// BusFadeoutCmd defines the command for fading out a bus over a specified duration to a target fader level.
type BusFadeoutCmd struct {
Duration time.Duration `flag:"" help:"The duration of the fade-out effect." default:"5s"`
Target float64 ` help:"The target fader level (in dB)." default:"-90.0" arg:""`
}
// Run executes the BusFadeoutCmd command, gradually decreasing the fader level of the bus from its current level to the target level over the specified duration.
func (cmd *BusFadeoutCmd) Run(ctx *context, bus *BusCmdGroup) error {
currentLevel, err := ctx.Client.Bus.Fader(bus.Index.Index)
if err != nil {
return fmt.Errorf("failed to get current fader level: %w", err)
}
if currentLevel <= cmd.Target {
return fmt.Errorf(
"current fader level (%.2f dB) is already at or below the target level (%.2f dB)",
currentLevel,
cmd.Target,
)
}
totalSteps := float64(currentLevel - cmd.Target)
stepDuration := time.Duration(cmd.Duration.Seconds()*1000/totalSteps) * time.Millisecond
for currentLevel > cmd.Target {
currentLevel -= totalSteps / float64(cmd.Duration.Seconds()*1000/stepDuration.Seconds())
if currentLevel < cmd.Target {
currentLevel = cmd.Target
}
if err := ctx.Client.Bus.SetFader(bus.Index.Index, currentLevel); err != nil {
return fmt.Errorf("failed to set fader level: %w", err)
}
time.Sleep(stepDuration)
}
fmt.Fprintf(
ctx.Out,
"Bus %d fade-out complete. Final level: %.2f dB\n",
bus.Index.Index,
cmd.Target,
)
return nil
}
// BusNameCmd defines the command for getting or setting the name of a bus.
type BusNameCmd struct {
Name *string `arg:"" help:"The name to set for the bus. If not provided, the current name will be returned." optional:""`
}
// Run executes the BusNameCmd command, either retrieving the current name of the bus or setting it based on the provided argument.
func (cmd *BusNameCmd) Run(ctx *context, bus *BusCmdGroup) error {
if cmd.Name == nil {
resp, err := ctx.Client.Bus.Name(bus.Index.Index)
if err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d name: %s\n", bus.Index.Index, resp)
return nil
}
if err := ctx.Client.Bus.SetName(bus.Index.Index, *cmd.Name); err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d name set to: %s\n", bus.Index.Index, *cmd.Name)
return nil
}
// BusEqCmdGroup defines the commands related to controlling the EQ of a bus.
type BusEqCmdGroup struct {
On BusEqOnCmd `help:"Get or set the EQ on/off state of the bus." cmd:"on"`
Mode BusEqModeCmd `help:"Get or set the EQ mode of the bus (peq, geq or teq)." cmd:"mode"`
Band struct {
Band *int `arg:"" help:"The EQ band number." optional:""`
Gain BusEqBandGainCmd `help:"Get or set the gain of the EQ band." cmd:"gain"`
Freq BusEqBandFreqCmd `help:"Get or set the frequency of the EQ band." cmd:"freq"`
Q BusEqBandQCmd `help:"Get or set the Q factor of the EQ band." cmd:"q"`
Type BusEqBandTypeCmd `help:"Get or set the type of the EQ band (lcut, lshv, peq, veq, hshv, hcut)." cmd:"type"`
} `help:"Commands for controlling a specific EQ band of the bus." arg:""`
}
// Validate checks that the provided EQ band number is within the valid range (1-6).
func (cmd *BusEqCmdGroup) Validate() error {
if cmd.Band.Band == nil {
return nil
}
if *cmd.Band.Band < 1 || *cmd.Band.Band > 6 {
return fmt.Errorf("EQ band number must be between 1 and 6, got %d", *cmd.Band.Band)
}
return nil
}
// BusCompCmdGroup defines the commands related to controlling the compressor of a bus.
type BusEqOnCmd struct {
State *string `arg:"" help:"The EQ on/off state to set (true or false). If not provided, the current EQ state will be returned." optional:"" enum:"true,false"`
}
// Run executes the BusEqOnCmd command, either retrieving the current EQ on/off state of the bus or setting it based on the provided argument.
func (cmd *BusEqOnCmd) Run(ctx *context, bus *BusCmdGroup) error {
if cmd.State == nil {
resp, err := ctx.Client.Bus.Eq.On(bus.Index.Index)
if err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d EQ on state: %t\n", bus.Index.Index, resp)
return nil
}
if err := ctx.Client.Bus.Eq.SetOn(bus.Index.Index, *cmd.State == trueStr); err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d EQ on state set to: %s\n", bus.Index.Index, *cmd.State)
return nil
}
// BusEqModeCmd defines the command for getting or setting the EQ mode of a bus.
type BusEqModeCmd struct {
Mode *string `arg:"" help:"The EQ mode to set (peq, geq or teq). If not provided, the current EQ mode will be returned." optional:"" enum:"peq,geq,teq"`
}
// Run executes the BusEqModeCmd command, either retrieving the current EQ mode of the bus or setting it based on the provided argument.
func (cmd *BusEqModeCmd) Run(ctx *context, bus *BusCmdGroup) error {
if cmd.Mode == nil {
resp, err := ctx.Client.Bus.Eq.Mode(bus.Index.Index)
if err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d EQ mode: %s\n", bus.Index.Index, resp)
return nil
}
if err := ctx.Client.Bus.Eq.SetMode(bus.Index.Index, *cmd.Mode); err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d EQ mode set to: %s\n", bus.Index.Index, *cmd.Mode)
return nil
}
// BusEqBandGainCmd defines the command for getting or setting the gain of a specific EQ band of a bus.
type BusEqBandGainCmd struct {
Gain *float64 `arg:"" help:"The gain to set for the EQ band (in dB). If not provided, the current gain will be returned." optional:""`
}
// Run executes the BusEqBandGainCmd command, either retrieving the current gain of the specified EQ band of the bus or setting it based on the provided argument.
func (cmd *BusEqBandGainCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGroup) error {
if cmd.Gain == nil {
resp, err := ctx.Client.Bus.Eq.Gain(bus.Index.Index, *busEq.Band.Band)
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,
)
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,
)
return nil
}
// BusEqBandFreqCmd defines the command for getting or setting the frequency of a specific EQ band of a bus.
type BusEqBandFreqCmd struct {
Freq *float64 `arg:"" help:"The frequency to set for the EQ band (in Hz). If not provided, the current frequency will be returned." optional:""`
}
// Run executes the BusEqBandFreqCmd command, either retrieving the current frequency of the specified EQ band of the bus or setting it based on the provided argument.
func (cmd *BusEqBandFreqCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGroup) error {
if cmd.Freq == nil {
resp, err := ctx.Client.Bus.Eq.Frequency(bus.Index.Index, *busEq.Band.Band)
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,
)
return 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,
)
return nil
}
// BusEqBandQCmd defines the command for getting or setting the Q factor of a specific EQ band of a bus.
type BusEqBandQCmd struct {
Q *float64 `arg:"" help:"The Q factor to set for the EQ band. If not provided, the current Q factor will be returned." optional:""`
}
// Run executes the BusEqBandQCmd command, either retrieving the current Q factor of the specified EQ band of the bus or setting it based on the provided argument.
func (cmd *BusEqBandQCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGroup) error {
if cmd.Q == nil {
resp, err := ctx.Client.Bus.Eq.Q(bus.Index.Index, *busEq.Band.Band)
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,
)
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,
)
return nil
}
// BusEqBandTypeCmd defines the command for getting or setting the type of a specific EQ band of a bus.
type BusEqBandTypeCmd struct {
Type *string `arg:"" help:"The type to set for the EQ band (lcut, lshv, peq, veq, hshv, hcut). If not provided, the current type will be returned." optional:"" enum:"lcut,lshv,peq,veq,hshv,hcut"`
}
// Run executes the BusEqBandTypeCmd command, either retrieving the current type of the specified EQ band of the bus or setting it based on the provided argument.
func (cmd *BusEqBandTypeCmd) Run(ctx *context, bus *BusCmdGroup, busEq *BusEqCmdGroup) error {
if cmd.Type == nil {
resp, err := ctx.Client.Bus.Eq.Type(bus.Index.Index, *busEq.Band.Band)
if err != nil {
return err
}
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,
)
return nil
}
// BusCompCmdGroup defines the commands related to controlling the compressor of a bus.
type BusCompCmdGroup struct {
On BusCompOnCmd `help:"Get or set the compressor on/off state of the bus." cmd:"on"`
Mode BusCompModeCmd `help:"Get or set the compressor mode of the bus (comp, exp)." cmd:"mode"`
Threshold BusCompThresholdCmd `help:"Get or set the compressor threshold of the bus (in dB)." cmd:"threshold"`
Ratio BusCompRatioCmd `help:"Get or set the compressor ratio of the bus." cmd:"ratio"`
Mix BusCompMixCmd `help:"Get or set the compressor mix level of the bus (in %)." cmd:"mix"`
Makeup BusCompMakeupCmd `help:"Get or set the compressor makeup gain of the bus (in dB)." cmd:"makeup"`
Attack BusCompAttackCmd `help:"Get or set the compressor attack time of the bus (in ms)." cmd:"attack"`
Hold BusCompHoldCmd `help:"Get or set the compressor hold time of the bus (in ms)." cmd:"hold"`
Release BusCompReleaseCmd `help:"Get or set the compressor release time of the bus (in ms)." cmd:"release"`
}
// BusCompOnCmd defines the command for getting or setting the compressor on/off state of a bus.
type BusCompOnCmd struct {
State *string `arg:"" help:"The compressor on/off state to set (true or false). If not provided, the current compressor state will be returned." optional:"" enum:"true,false"`
}
// Run executes the BusCompOnCmd command, either retrieving the current compressor on/off state of the bus or setting it based on the provided argument.
func (cmd *BusCompOnCmd) Run(ctx *context, bus *BusCmdGroup) error {
if cmd.State == nil {
resp, err := ctx.Client.Bus.Comp.On(bus.Index.Index)
if err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d compressor on state: %t\n", bus.Index.Index, resp)
return nil
}
if err := ctx.Client.Bus.Comp.SetOn(bus.Index.Index, *cmd.State == trueStr); err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d compressor on state set to: %s\n", bus.Index.Index, *cmd.State)
return nil
}
// BusCompModeCmd defines the command for getting or setting the compressor mode of a bus.
type BusCompModeCmd struct {
Mode *string `arg:"" help:"The compressor mode to set (comp, exp). If not provided, the current compressor mode will be returned." optional:"" enum:"comp,exp"`
}
// Run executes the BusCompModeCmd command, either retrieving the current compressor mode of the bus or setting it based on the provided argument.
func (cmd *BusCompModeCmd) Run(ctx *context, bus *BusCmdGroup) error {
if cmd.Mode == nil {
resp, err := ctx.Client.Bus.Comp.Mode(bus.Index.Index)
if err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d compressor mode: %s\n", bus.Index.Index, resp)
return nil
}
if err := ctx.Client.Bus.Comp.SetMode(bus.Index.Index, *cmd.Mode); err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d compressor mode set to: %s\n", bus.Index.Index, *cmd.Mode)
return nil
}
// BusCompThresholdCmd defines the command for getting or setting the compressor threshold of a bus.
type BusCompThresholdCmd struct {
Threshold *float64 `arg:"" help:"The compressor threshold to set (in dB). If not provided, the current compressor threshold will be returned." optional:""`
}
// Run executes the BusCompThresholdCmd command, either retrieving the current compressor threshold of the bus or setting it based on the provided argument.
func (cmd *BusCompThresholdCmd) Run(ctx *context, bus *BusCmdGroup) error {
if cmd.Threshold == nil {
resp, err := ctx.Client.Bus.Comp.Threshold(bus.Index.Index)
if err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d compressor threshold: %.2f dB\n", bus.Index.Index, resp)
return nil
}
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,
)
return nil
}
// BusCompRatioCmd defines the command for getting or setting the compressor ratio of a bus.
type BusCompRatioCmd struct {
Ratio *float64 `arg:"" help:"The compressor ratio to set. If not provided, the current compressor ratio will be returned." optional:""`
}
// Run executes the BusCompRatioCmd command, either retrieving the current compressor ratio of the bus or setting it based on the provided argument.
func (cmd *BusCompRatioCmd) Run(ctx *context, bus *BusCmdGroup) error {
if cmd.Ratio == nil {
resp, err := ctx.Client.Bus.Comp.Ratio(bus.Index.Index)
if err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d compressor ratio: %.2f\n", bus.Index.Index, resp)
return nil
}
if err := ctx.Client.Bus.Comp.SetRatio(bus.Index.Index, *cmd.Ratio); err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d compressor ratio set to: %.2f\n", bus.Index.Index, *cmd.Ratio)
return nil
}
// BusCompMixCmd defines the command for getting or setting the compressor mix level of a bus.
type BusCompMixCmd struct {
Mix *float64 `arg:"" help:"The compressor mix level to set (in %). If not provided, the current compressor mix level will be returned." optional:""`
}
// Run executes the BusCompMixCmd command, either retrieving the current compressor mix level of the bus or setting it based on the provided argument.
func (cmd *BusCompMixCmd) Run(ctx *context, bus *BusCmdGroup) error {
if cmd.Mix == nil {
resp, err := ctx.Client.Bus.Comp.Mix(bus.Index.Index)
if err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d compressor mix level: %.2f%%\n", bus.Index.Index, resp)
return nil
}
if err := ctx.Client.Bus.Comp.SetMix(bus.Index.Index, *cmd.Mix); err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d compressor mix level set to: %.2f%%\n", bus.Index.Index, *cmd.Mix)
return nil
}
// BusCompMakeupCmd defines the command for getting or setting the compressor makeup gain of a bus.
type BusCompMakeupCmd struct {
Makeup *float64 `arg:"" help:"The compressor makeup gain to set (in dB). If not provided, the current compressor makeup gain will be returned." optional:""`
}
// Run executes the BusCompMakeupCmd command, either retrieving the current compressor makeup gain of the bus or setting it based on the provided argument.
func (cmd *BusCompMakeupCmd) Run(ctx *context, bus *BusCmdGroup) error {
if cmd.Makeup == nil {
resp, err := ctx.Client.Bus.Comp.Makeup(bus.Index.Index)
if err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d compressor makeup gain: %.2f dB\n", bus.Index.Index, resp)
return nil
}
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,
)
return nil
}
// BusCompAttackCmd defines the command for getting or setting the compressor attack time of a bus.
type BusCompAttackCmd struct {
Attack *float64 `arg:"" help:"The compressor attack time to set (in ms). If not provided, the current compressor attack time will be returned." optional:""`
}
// Run executes the BusCompAttackCmd command, either retrieving the current compressor attack time of the bus or setting it based on the provided argument.
func (cmd *BusCompAttackCmd) Run(ctx *context, bus *BusCmdGroup) error {
if cmd.Attack == nil {
resp, err := ctx.Client.Bus.Comp.Attack(bus.Index.Index)
if err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d compressor attack time: %.2f ms\n", bus.Index.Index, resp)
return nil
}
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,
)
return nil
}
// BusCompHoldCmd defines the command for getting or setting the compressor hold time of a bus.
type BusCompHoldCmd struct {
Hold *float64 `arg:"" help:"The compressor hold time to set (in ms). If not provided, the current compressor hold time will be returned." optional:""`
}
// Run executes the BusCompHoldCmd command, either retrieving the current compressor hold time of the bus or setting it based on the provided argument.
func (cmd *BusCompHoldCmd) Run(ctx *context, bus *BusCmdGroup) error {
if cmd.Hold == nil {
resp, err := ctx.Client.Bus.Comp.Hold(bus.Index.Index)
if err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d compressor hold time: %.2f ms\n", bus.Index.Index, resp)
return nil
}
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,
)
return nil
}
// BusCompReleaseCmd defines the command for getting or setting the compressor release time of a bus.
type BusCompReleaseCmd struct {
Release *float64 `arg:"" help:"The compressor release time to set (in ms). If not provided, the current compressor release time will be returned." optional:""`
}
// Run executes the BusCompReleaseCmd command, either retrieving the current compressor release time of the bus or setting it based on the provided argument.
func (cmd *BusCompReleaseCmd) Run(ctx *context, bus *BusCmdGroup) error {
if cmd.Release == nil {
resp, err := ctx.Client.Bus.Comp.Release(bus.Index.Index)
if err != nil {
return err
}
fmt.Fprintf(ctx.Out, "Bus %d compressor release time: %.2f ms\n", bus.Index.Index, resp)
return nil
}
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,
)
return nil
}

View File

@ -1,144 +0,0 @@
package main
import (
"fmt"
"io"
"os"
"runtime/debug"
"strings"
"time"
"github.com/alecthomas/kong"
"github.com/charmbracelet/log"
kongcompletion "github.com/jotaen/kong-completion"
"github.com/onyx-and-iris/xair-cli/internal/xair"
)
const (
trueStr = "true"
falseStr = "false"
)
var version string // Version of the CLI, set at build time.
// VersionFlag is a custom flag type that prints the version and exits.
type VersionFlag string
func (v VersionFlag) Decode(_ *kong.DecodeContext) error { return nil } // nolint: revive
func (v VersionFlag) IsBool() bool { return true } // nolint: revive
func (v VersionFlag) BeforeApply(app *kong.Kong, vars kong.Vars) error { // nolint: revive, unparam
fmt.Printf("x32-cli version: %s\n", vars["version"])
app.Exit(0)
return nil
}
type context struct {
Client *xair.X32Client
Out io.Writer
}
type Config struct {
Host string `default:"mixer.local" help:"The host of the X32 device." env:"X32_CLI_HOST" short:"H"`
Port int `default:"10023" help:"The port of the X32 device." env:"X32_CLI_PORT" short:"P"`
Timeout time.Duration `default:"100ms" help:"Timeout for OSC operations." env:"X32_CLI_TIMEOUT" short:"T"`
Loglevel string `default:"warn" help:"Log level for the CLI." env:"X32_CLI_LOGLEVEL" short:"L" enum:"debug,info,warn,error,fatal"`
}
// CLI is the main struct for the command-line interface.
// It embeds the Config struct for global configuration and defines the available commands and flags.
type CLI struct {
Config `embed:"" prefix:"" help:"The configuration for the CLI."`
Version VersionFlag `help:"Print x32-cli version information and quit" name:"version" short:"v"`
Completion kongcompletion.Completion `help:"Generate shell completion scripts." cmd:""`
Info InfoCmd `help:"Print mixer information." cmd:""`
Raw RawCmd `help:"Send raw OSC messages to the mixer." cmd:""`
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"`
Snapshot SnapshotCmdGroup `help:"Save and load mixer states." cmd:"" group:"Snapshot"`
Dca DCACmdGroup `help:"Control DCA groups." cmd:"" group:"DCA"`
}
func main() {
var cli CLI
kongcompletion.Register(kong.Must(&cli))
ctx := kong.Parse(
&cli,
kong.Name("x32-cli"),
kong.Description("A CLI to control Behringer X32 mixers."),
kong.UsageOnError(),
kong.ConfigureHelp(kong.HelpOptions{
Compact: true,
}),
kong.Vars{
"version": func() string {
if version != "" {
return version
}
info, ok := debug.ReadBuildInfo()
if !ok {
return "(unable to read version)"
}
return strings.Split(info.Main.Version, "-")[0]
}(),
},
)
ctx.FatalIfErrorf(run(ctx, cli.Config))
}
// run is the main entry point for the CLI.
// It connects to the X32 device, retrieves mixer info, and then runs the command.
func run(ctx *kong.Context, config Config) error {
loglevel, err := log.ParseLevel(config.Loglevel)
if err != nil {
return fmt.Errorf("invalid log level: %w", err)
}
log.SetLevel(loglevel)
client, err := connect(config)
if err != nil {
return fmt.Errorf("failed to connect to X32 device: %w", err)
}
defer func() {
if err := client.Close(); err != nil {
log.Errorf("failed to close client connection: %v", err)
}
}()
client.StartListening()
resp, err := client.RequestInfo()
if err != nil {
return err
}
log.Infof("Received mixer info: %+v", resp)
ctx.Bind(&context{
Client: client,
Out: os.Stdout,
})
return ctx.Run()
}
// connect creates a new X32 client based on the provided configuration.
func connect(config Config) (*xair.X32Client, error) {
client, err := xair.NewX32Client(
config.Host,
config.Port,
xair.WithTimeout(config.Timeout),
)
if err != nil {
return nil, fmt.Errorf("failed to create X32 client: %w", err)
}
return client, nil
}

View File

@ -1,67 +0,0 @@
package main
import (
"fmt"
)
type DCACmdGroup struct {
Index struct {
Index int `arg:"" help:"The index of the DCA group (1-8)."`
Mute DCAMuteCmd `help:"Get or set the mute status of the DCA group." cmd:""`
Name DCANameCmd `help:"Get or set the name of the DCA group." cmd:""`
} `arg:"" help:"Control a specific DCA group by its index."`
}
// Validate checks if the provided index is within the valid range.
func (cmd *DCACmdGroup) Validate() error {
if cmd.Index.Index < 1 || cmd.Index.Index > 8 {
return fmt.Errorf("DCA group index must be between 1 and 8, got %d", cmd.Index.Index)
}
return nil
}
// DCAMuteCmd is the command to get or set the mute status of a DCA group.
type DCAMuteCmd struct {
State *string `arg:"" help:"Set the mute status of the DCA group." optional:"" enum:"true,false"`
}
// Run executes the DCAMuteCmd command.
func (cmd *DCAMuteCmd) Run(ctx *context, dca *DCACmdGroup) error {
if cmd.State == nil {
resp, err := ctx.Client.DCA.Mute(dca.Index.Index)
if err != nil {
return fmt.Errorf("failed to get DCA mute status: %w", err)
}
fmt.Fprintf(ctx.Out, "DCA Group %d mute state: %t\n", dca.Index.Index, resp)
return nil
}
if err := ctx.Client.DCA.SetMute(dca.Index.Index, *cmd.State == trueStr); err != nil {
return fmt.Errorf("failed to set DCA mute status: %w", err)
}
return nil
}
// DCANameCmd is the command to get or set the name of a DCA group.
type DCANameCmd struct {
Name *string `arg:"" help:"Set the name of the DCA group." optional:""`
}
// Run executes the DCANameCmd command.
func (cmd *DCANameCmd) Run(ctx *context, dca *DCACmdGroup) error {
if cmd.Name == nil {
resp, err := ctx.Client.DCA.Name(dca.Index.Index)
if err != nil {
return fmt.Errorf("failed to get DCA name: %w", err)
}
if resp == "" {
resp = fmt.Sprintf("DCA %d", dca.Index.Index)
}
fmt.Fprintf(ctx.Out, "DCA Group %d is named '%s'\n", dca.Index.Index, resp)
return nil
}
if err := ctx.Client.DCA.SetName(dca.Index.Index, *cmd.Name); err != nil {
return fmt.Errorf("failed to set DCA name: %w", err)
}
return nil
}

View File

@ -1,139 +0,0 @@
package main
import (
"fmt"
"time"
"github.com/charmbracelet/log"
)
// HeadampCmdGroup defines the command group for controlling input gain and phantom power of a headamp, allowing users to specify the index of the headamp they want to control.
type HeadampCmdGroup struct {
Index struct {
Index int `arg:"" help:"The index of the headamp."`
Gain HeadampGainCmd `help:"Get or set the gain of the headamp." cmd:""`
Phantom HeadampPhantomCmd `help:"Get or set the phantom power state of the headamp." cmd:""`
} `arg:"" help:"Control a specific headamp by index."`
}
// HeadampGainCmd defines the command for getting or setting the gain of a headamp, allowing users to specify the gain in dB and an optional duration for a gradual fade when setting the gain.
type HeadampGainCmd struct {
Duration time.Duration `help:"The duration of the fade in/out when setting the gain." default:"5s"`
Gain *float64 `help:"The gain of the headamp in dB." arg:"" optional:""`
}
// Run executes the HeadampGainCmd command, either retrieving the current gain of the headamp or setting it based on the provided argument, with an optional fade duration for smooth transitions.
func (cmd *HeadampGainCmd) Run(ctx *context, headamp *HeadampCmdGroup) error {
if cmd.Gain == nil {
resp, err := ctx.Client.HeadAmp.Gain(headamp.Index.Index)
if err != nil {
return fmt.Errorf("failed to get headamp gain: %w", err)
}
fmt.Fprintf(ctx.Out, "Headamp %d gain: %.2f dB\n", headamp.Index.Index, resp)
return nil
}
currentGain, err := ctx.Client.HeadAmp.Gain(headamp.Index.Index)
if err != nil {
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 {
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.
func gradualGainAdjust(
ctx *context,
index int,
currentGain, targetGain float64,
duration time.Duration,
) error {
gainDiff := targetGain - currentGain
stepInterval := 100 * time.Millisecond
totalSteps := int(duration / stepInterval)
if totalSteps < 1 {
totalSteps = 1
stepInterval = duration
}
stepIncrement := gainDiff / float64(totalSteps)
log.Debugf("Adjusting Headamp %d gain from %.2f dB to %.2f dB over %v...\n",
index, currentGain, targetGain, duration)
for step := 1; step <= totalSteps; step++ {
newGain := currentGain + (stepIncrement * float64(step))
if step == totalSteps {
newGain = targetGain
}
err := ctx.Client.HeadAmp.SetGain(index, newGain)
if err != nil {
return err
}
if step%10 == 0 || step == totalSteps {
log.Debugf(" Step %d/%d: %.2f dB\n", step, totalSteps, newGain)
}
if step < totalSteps {
time.Sleep(stepInterval)
}
}
return nil
}
// HeadampPhantomCmd defines the command for getting or setting the phantom power state of a headamp, allowing users to specify the desired state as "true"/"on" or "false"/"off".
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 normalises it to "true" or "false".
func (cmd *HeadampPhantomCmd) Validate() error {
if cmd.State != nil {
switch *cmd.State {
case trueStr, "on":
*cmd.State = trueStr
case falseStr, "off":
*cmd.State = falseStr
default:
return fmt.Errorf("invalid phantom power state: %s", *cmd.State)
}
}
return nil
}
// Run executes the HeadampPhantomCmd command, either retrieving the current phantom power state of the headamp or setting it based on the provided argument.
func (cmd *HeadampPhantomCmd) Run(ctx *context, headamp *HeadampCmdGroup) error {
if cmd.State == nil {
resp, err := ctx.Client.HeadAmp.PhantomPower(headamp.Index.Index)
if err != nil {
return fmt.Errorf("failed to get headamp phantom power state: %w", err)
}
fmt.Fprintf(ctx.Out, "Headamp %d phantom power: %t\n", headamp.Index.Index, resp)
return nil
}
if err := ctx.Client.HeadAmp.SetPhantomPower(
headamp.Index.Index,
*cmd.State == trueStr,
); 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)
return nil
}

View File

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

View File

@ -1,529 +0,0 @@
package main
import (
"fmt"
"time"
)
// MainMonoCmdGroup defines the command group for controlling the Main Mono output, including commands for mute state, fader level, and fade-in/fade-out times.
type MainMonoCmdGroup struct {
Mute MainMonoMuteCmd `help:"Get or set the mute state of the Main Mono output." cmd:""`
Fader MainMonoFaderCmd `help:"Get or set the fader level of the Main Mono output." cmd:""`
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 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"`
}
// MainMonoMuteCmd defines the command for getting or setting the mute state of the Main Mono output, allowing users to specify the desired state as "true"/"on" or "false"/"off".
type MainMonoMuteCmd 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 MainMonoMuteCmd command, either retrieving the current mute state of the Main Mono output or setting it based on the provided argument.
func (cmd *MainMonoMuteCmd) Run(ctx *context) error {
if cmd.Mute == nil {
resp, err := ctx.Client.MainMono.Mute()
if err != nil {
return fmt.Errorf("failed to get Main Mono mute state: %w", err)
}
fmt.Fprintf(ctx.Out, "Main Mono mute state: %t\n", resp)
return nil
}
if err := ctx.Client.MainMono.SetMute(*cmd.Mute == trueStr); err != nil {
return fmt.Errorf("failed to set Main Mono mute state: %w", err)
}
fmt.Fprintf(ctx.Out, "Main Mono mute state set to: %s\n", *cmd.Mute)
return nil
}
// MainMonoFaderCmd defines the command for getting or setting the fader level of the Main Mono output, allowing users to specify the desired level in dB.
type MainMonoFaderCmd struct {
Level *float64 `arg:"" help:"The fader level to set. If not provided, the current level will be printed." optional:""`
}
// Run executes the MainMonoFaderCmd command, either retrieving the current fader level of the Main Mono output or setting it based on the provided argument.
func (cmd *MainMonoFaderCmd) Run(ctx *context) error {
if cmd.Level == nil {
resp, err := ctx.Client.MainMono.Fader()
if err != nil {
return fmt.Errorf("failed to get Main Mono fader level: %w", err)
}
fmt.Fprintf(ctx.Out, "Main Mono fader level: %.2f\n", resp)
return nil
}
if err := ctx.Client.MainMono.SetFader(*cmd.Level); err != nil {
return fmt.Errorf("failed to set Main Mono fader level: %w", err)
}
fmt.Fprintf(ctx.Out, "Main Mono fader level set to: %.2f\n", *cmd.Level)
return nil
}
// MainMonoFadeinCmd defines the command for getting or setting the fade-in time of the Main Mono output, allowing users to specify the desired duration for the fade-in effect.
type MainMonoFadeinCmd 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 MainMonoFadeinCmd command, either retrieving the current fade-in time of the Main Mono output or setting it based on the provided argument, with an optional target level for the fade-in effect.
func (cmd *MainMonoFadeinCmd) Run(ctx *context) error {
currentLevel, err := ctx.Client.MainMono.Fader()
if err != nil {
return fmt.Errorf("failed to get Main Mono 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.MainMono.SetFader(currentLevel); err != nil {
return fmt.Errorf("failed to set Main Mono fader level: %w", err)
}
time.Sleep(stepDuration)
}
fmt.Fprintf(ctx.Out, "Main Mono fade-in completed. Final level: %.2f\n", currentLevel)
return nil
}
// MainMonoFadeoutCmd defines the command for getting or setting the fade-out time of the Main Mono output, allowing users to specify the desired duration for the fade-out effect and an optional target level to fade out to.
type MainMonoFadeoutCmd 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 MainMonoFadeoutCmd command, either retrieving the current fade-out time of the Main Mono output or setting it based on the provided argument, with an optional target level for the fade-out effect.
func (cmd *MainMonoFadeoutCmd) Run(ctx *context) error {
currentLevel, err := ctx.Client.MainMono.Fader()
if err != nil {
return fmt.Errorf("failed to get Main Mono 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.MainMono.SetFader(currentLevel); err != nil {
return fmt.Errorf("failed to set Main Mono fader level: %w", err)
}
time.Sleep(stepDuration)
}
fmt.Fprintf(ctx.Out, "Main Mono fade-out completed. Final level: %.2f\n", currentLevel)
return nil
}
// 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 {
Band *int `arg:"" help:"The EQ band number." optional:""`
Gain MainMonoEqBandGainCmd `help:"Get or set the gain of the specified EQ band." cmd:"gain"`
Freq MainMonoEqBandFreqCmd `help:"Get or set the frequency of the specified EQ band." cmd:"freq"`
Q MainMonoEqBandQCmd `help:"Get or set the Q factor of the specified EQ band." cmd:"q"`
Type MainMonoEqBandTypeCmd `help:"Get or set the type of the specified EQ band." cmd:"type"`
} `help:"Commands for controlling individual EQ bands of the Main Mono output." arg:""`
}
// Validate checks if the provided EQ band number is within the valid range (1-6) for the Main Mono output.
func (cmd *MainMonoEqCmdGroup) Validate() error {
if cmd.Band.Band == nil {
return nil
}
if *cmd.Band.Band < 1 || *cmd.Band.Band > 6 {
return fmt.Errorf("EQ band number must be between 1 and 6, got %d", *cmd.Band.Band)
}
return nil
}
// MainMonoEqOnCmd defines the command for getting or setting the EQ on/off state of the Main Mono output, allowing users to specify the desired state as "true"/"on" or "false"/"off".
type MainMonoEqOnCmd 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 MainMonoEqOnCmd command, either retrieving the current EQ on/off state of the Main Mono output or setting it based on the provided argument.
func (cmd *MainMonoEqOnCmd) Run(ctx *context) error {
if cmd.Enable == nil {
resp, err := ctx.Client.MainMono.Eq.On(0)
if err != nil {
return fmt.Errorf("failed to get Main Mono EQ on/off state: %w", err)
}
fmt.Fprintf(ctx.Out, "Main Mono EQ on/off state: %t\n", resp)
return nil
}
if err := ctx.Client.MainMono.Eq.SetOn(0, *cmd.Enable == trueStr); err != nil {
return fmt.Errorf("failed to set Main Mono EQ on/off state: %w", err)
}
fmt.Fprintf(ctx.Out, "Main Mono EQ on/off state set to: %t\n", *cmd.Enable == trueStr)
return nil
}
// MainMonoEqBandGainCmd defines the command for getting or setting the gain of a specific EQ band on the Main Mono output, allowing users to specify the desired gain in dB.
type MainMonoEqBandGainCmd 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 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,
mainEq *MainMonoEqCmdGroup,
) error {
if cmd.Level == nil {
resp, err := ctx.Client.MainMono.Eq.Gain(0, *mainEq.Band.Band)
if err != nil {
return fmt.Errorf("failed to get Main Mono EQ band %d gain: %w", *mainEq.Band.Band, err)
}
fmt.Fprintf(ctx.Out, "Main Mono EQ band %d gain: %.2f dB\n", *mainEq.Band.Band, resp)
return nil
}
if err := ctx.Client.MainMono.Eq.SetGain(0, *mainEq.Band.Band, *cmd.Level); err != nil {
return fmt.Errorf("failed to set Main Mono EQ band %d gain: %w", *mainEq.Band.Band, err)
}
fmt.Fprintf(
ctx.Out,
"Main Mono EQ band %d gain set to: %.2f dB\n",
*mainEq.Band.Band,
*cmd.Level,
)
return nil
}
// MainMonoEqBandFreqCmd defines the command for getting or setting the frequency of a specific EQ band on the Main Mono output, allowing users to specify the desired frequency in Hz.
type MainMonoEqBandFreqCmd 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 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,
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,
)
}
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,
)
}
fmt.Fprintf(
ctx.Out,
"Main Mono EQ band %d frequency set to: %.2f Hz\n",
*mainEq.Band.Band,
*cmd.Frequency,
)
return nil
}
// MainMonoEqBandQCmd defines the command for getting or setting the Q factor of a specific EQ band on the Main Mono output, allowing users to specify the desired Q factor.
type MainMonoEqBandQCmd 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 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,
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,
)
}
fmt.Fprintf(ctx.Out, "Main Mono EQ band %d Q factor: %.2f\n", *mainEq.Band.Band, resp)
return nil
}
if err := ctx.Client.MainMono.Eq.SetQ(0, *mainEq.Band.Band, *cmd.Q); err != nil {
return fmt.Errorf("failed to set Main Mono EQ band %d Q factor: %w", *mainEq.Band.Band, err)
}
fmt.Fprintf(ctx.Out, "Main Mono EQ band %d Q factor set to: %.2f\n", *mainEq.Band.Band, *cmd.Q)
return nil
}
// MainMonoEqBandTypeCmd defines the command for getting or setting the type of a specific EQ band on the Main Mono output, allowing users to specify the desired type as "peaking", "low_shelf", "high_shelf", "low_pass", or "high_pass".
type MainMonoEqBandTypeCmd 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 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,
mainEq *MainMonoEqCmdGroup,
) error {
if cmd.Type == nil {
resp, err := ctx.Client.MainMono.Eq.Type(0, *mainEq.Band.Band)
if err != nil {
return fmt.Errorf("failed to get Main Mono EQ band %d type: %w", *mainEq.Band.Band, err)
}
fmt.Fprintf(ctx.Out, "Main Mono EQ band %d type: %s\n", *mainEq.Band.Band, resp)
return nil
}
if err := ctx.Client.MainMono.Eq.SetType(0, *mainEq.Band.Band, *cmd.Type); err != nil {
return fmt.Errorf("failed to set Main Mono EQ band %d type: %w", *mainEq.Band.Band, err)
}
fmt.Fprintf(ctx.Out, "Main Mono EQ band %d type set to: %s\n", *mainEq.Band.Band, *cmd.Type)
return nil
}
// MainMonoCompCmdGroup defines the command group for controlling the compressor settings of the Main Mono output, including commands for getting or setting the compressor parameters.
type MainMonoCompCmdGroup struct {
On MainMonoCompOnCmd `help:"Get or set the compressor on/off state of the Main Mono output." cmd:"on"`
Mode MainMonoCompModeCmd `help:"Get or set the compressor mode of the Main Mono output." cmd:"mode"`
Threshold MainMonoCompThresholdCmd `help:"Get or set the compressor threshold of the Main Mono output." cmd:"threshold"`
Ratio MainMonoCompRatioCmd `help:"Get or set the compressor ratio of the Main Mono output." cmd:"ratio"`
Mix MainMonoCompMixCmd `help:"Get or set the compressor mix level of the Main Mono output." cmd:"mix"`
Makeup MainMonoCompMakeupCmd `help:"Get or set the compressor makeup gain of the Main Mono output." cmd:"makeup"`
Attack MainMonoCompAttackCmd `help:"Get or set the compressor attack time of the Main Mono output." cmd:"attack"`
Hold MainMonoCompHoldCmd `help:"Get or set the compressor hold time of the Main Mono output." cmd:"hold"`
Release MainMonoCompReleaseCmd `help:"Get or set the compressor release time of the Main Mono output." cmd:"release"`
}
// MainMonoCompOnCmd defines the command for getting or setting the compressor on/off state of the Main Mono output, allowing users to specify the desired state as "true"/"on" or "false"/"off".
type MainMonoCompOnCmd 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 MainMonoCompOnCmd command, either retrieving the current compressor on/off state of the Main Mono output or setting it based on the provided argument.
func (cmd *MainMonoCompOnCmd) Run(ctx *context) error {
if cmd.Enable == nil {
resp, err := ctx.Client.MainMono.Comp.On(0)
if err != nil {
return fmt.Errorf("failed to get Main Mono compressor on/off state: %w", err)
}
fmt.Fprintf(ctx.Out, "Main Mono compressor on/off state: %t\n", resp)
return nil
}
if err := ctx.Client.MainMono.Comp.SetOn(0, *cmd.Enable == trueStr); err != nil {
return fmt.Errorf("failed to set Main Mono compressor on/off state: %w", err)
}
fmt.Fprintf(ctx.Out, "Main Mono compressor on/off state set to: %t\n", *cmd.Enable == trueStr)
return nil
}
// MainMonoCompModeCmd defines the command for getting or setting the compressor mode of the Main Mono output, allowing users to specify the desired mode as "comp" or "exp".
type MainMonoCompModeCmd 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 MainMonoCompModeCmd command, either retrieving the current compressor mode of the Main Mono output or setting it based on the provided argument.
func (cmd *MainMonoCompModeCmd) Run(ctx *context) error {
if cmd.Mode == nil {
resp, err := ctx.Client.MainMono.Comp.Mode(0)
if err != nil {
return fmt.Errorf("failed to get Main Mono compressor mode: %w", err)
}
fmt.Fprintf(ctx.Out, "Main Mono compressor mode: %s\n", resp)
return nil
}
if err := ctx.Client.MainMono.Comp.SetMode(0, *cmd.Mode); err != nil {
return fmt.Errorf("failed to set Main Mono compressor mode: %w", err)
}
fmt.Fprintf(ctx.Out, "Main Mono compressor mode set to: %s\n", *cmd.Mode)
return nil
}
// MainMonoCompThresholdCmd defines the command for getting or setting the compressor threshold of the Main Mono output, allowing users to specify the desired threshold in dB.
type MainMonoCompThresholdCmd struct {
Threshold *float64 `arg:"" help:"The compressor threshold to set. If not provided, the current threshold will be printed." optional:""`
}
// Run executes the MainMonoCompThresholdCmd command, either retrieving the current compressor threshold of the Main Mono output or setting it based on the provided argument.
func (cmd *MainMonoCompThresholdCmd) Run(ctx *context) error {
if cmd.Threshold == nil {
resp, err := ctx.Client.MainMono.Comp.Threshold(0)
if err != nil {
return fmt.Errorf("failed to get Main Mono compressor threshold: %w", err)
}
fmt.Fprintf(ctx.Out, "Main Mono compressor threshold: %.2f dB\n", resp)
return nil
}
if err := ctx.Client.MainMono.Comp.SetThreshold(0, *cmd.Threshold); err != nil {
return fmt.Errorf("failed to set Main Mono compressor threshold: %w", err)
}
fmt.Fprintf(ctx.Out, "Main Mono compressor threshold set to: %.2f dB\n", *cmd.Threshold)
return nil
}
// MainMonoCompRatioCmd defines the command for getting or setting the compressor ratio of the Main Mono output, allowing users to specify the desired ratio.
type MainMonoCompRatioCmd struct {
Ratio *float64 `arg:"" help:"The compressor ratio to set. If not provided, the current ratio will be printed." optional:""`
}
// Run executes the MainMonoCompRatioCmd command, either retrieving the current compressor ratio of the Main Mono output or setting it based on the provided argument.
func (cmd *MainMonoCompRatioCmd) Run(ctx *context) error {
if cmd.Ratio == nil {
resp, err := ctx.Client.MainMono.Comp.Ratio(0)
if err != nil {
return fmt.Errorf("failed to get Main Mono compressor ratio: %w", err)
}
fmt.Fprintf(ctx.Out, "Main Mono compressor ratio: %.2f\n", resp)
return nil
}
if err := ctx.Client.MainMono.Comp.SetRatio(0, *cmd.Ratio); err != nil {
return fmt.Errorf("failed to set Main Mono compressor ratio: %w", err)
}
fmt.Fprintf(ctx.Out, "Main Mono compressor ratio set to: %.2f\n", *cmd.Ratio)
return nil
}
// MainMonoCompMixCmd defines the command for getting or setting the compressor mix level of the Main Mono output, allowing users to specify the desired mix level in percentage.
type MainMonoCompMixCmd 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 MainMonoCompMixCmd command, either retrieving the current compressor mix level of the Main Mono output or setting it based on the provided argument.
func (cmd *MainMonoCompMixCmd) Run(ctx *context) error {
if cmd.Mix == nil {
resp, err := ctx.Client.MainMono.Comp.Mix(0)
if err != nil {
return fmt.Errorf("failed to get Main Mono compressor mix level: %w", err)
}
fmt.Fprintf(ctx.Out, "Main Mono compressor mix level: %.2f%%\n", resp)
return nil
}
if err := ctx.Client.MainMono.Comp.SetMix(0, *cmd.Mix); err != nil {
return fmt.Errorf("failed to set Main Mono compressor mix level: %w", err)
}
fmt.Fprintf(ctx.Out, "Main Mono compressor mix level set to: %.2f%%\n", *cmd.Mix)
return nil
}
// MainMonoCompMakeupCmd defines the command for getting or setting the compressor makeup gain of the Main Mono output, allowing users to specify the desired makeup gain in dB.
type MainMonoCompMakeupCmd 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 MainMonoCompMakeupCmd command, either retrieving the current compressor makeup gain of the Main Mono output or setting it based on the provided argument.
func (cmd *MainMonoCompMakeupCmd) Run(ctx *context) error {
if cmd.Makeup == nil {
resp, err := ctx.Client.MainMono.Comp.Makeup(0)
if err != nil {
return fmt.Errorf("failed to get Main Mono compressor makeup gain: %w", err)
}
fmt.Fprintf(ctx.Out, "Main Mono compressor makeup gain: %.2f dB\n", resp)
return nil
}
if err := ctx.Client.MainMono.Comp.SetMakeup(0, *cmd.Makeup); err != nil {
return fmt.Errorf("failed to set Main Mono compressor makeup gain: %w", err)
}
fmt.Fprintf(ctx.Out, "Main Mono compressor makeup gain set to: %.2f dB\n", *cmd.Makeup)
return nil
}
// MainMonoCompAttackCmd defines the command for getting or setting the compressor attack time of the Main Mono output, allowing users to specify the desired attack time in milliseconds.
type MainMonoCompAttackCmd 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 MainMonoCompAttackCmd command, either retrieving the current compressor attack time of the Main Mono output or setting it based on the provided argument.
func (cmd *MainMonoCompAttackCmd) Run(ctx *context) error {
if cmd.Attack == nil {
resp, err := ctx.Client.MainMono.Comp.Attack(0)
if err != nil {
return fmt.Errorf("failed to get Main Mono compressor attack time: %w", err)
}
fmt.Fprintf(ctx.Out, "Main Mono compressor attack time: %.2f ms\n", resp)
return nil
}
if err := ctx.Client.MainMono.Comp.SetAttack(0, *cmd.Attack); err != nil {
return fmt.Errorf("failed to set Main Mono compressor attack time: %w", err)
}
fmt.Fprintf(ctx.Out, "Main Mono compressor attack time set to: %.2f ms\n", *cmd.Attack)
return nil
}
// MainMonoCompHoldCmd defines the command for getting or setting the compressor hold time of the Main Mono output, allowing users to specify the desired hold time in milliseconds.
type MainMonoCompHoldCmd 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 MainMonoCompHoldCmd command, either retrieving the current compressor hold time of the Main Mono output or setting it based on the provided argument.
func (cmd *MainMonoCompHoldCmd) Run(ctx *context) error {
if cmd.Hold == nil {
resp, err := ctx.Client.MainMono.Comp.Hold(0)
if err != nil {
return fmt.Errorf("failed to get Main Mono compressor hold time: %w", err)
}
fmt.Fprintf(ctx.Out, "Main Mono compressor hold time: %.2f ms\n", resp)
return nil
}
if err := ctx.Client.MainMono.Comp.SetHold(0, *cmd.Hold); err != nil {
return fmt.Errorf("failed to set Main Mono compressor hold time: %w", err)
}
fmt.Fprintf(ctx.Out, "Main Mono compressor hold time set to: %.2f ms\n", *cmd.Hold)
return nil
}
// MainMonoCompReleaseCmd defines the command for getting or setting the compressor release time of the Main Mono output, allowing users to specify the desired release time in milliseconds.
type MainMonoCompReleaseCmd 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 MainMonoCompReleaseCmd command, either retrieving the current compressor release time of the Main Mono output or setting it based on the provided argument.
func (cmd *MainMonoCompReleaseCmd) Run(ctx *context) error {
if cmd.Release == nil {
resp, err := ctx.Client.MainMono.Comp.Release(0)
if err != nil {
return fmt.Errorf("failed to get Main Mono compressor release time: %w", err)
}
fmt.Fprintf(ctx.Out, "Main Mono compressor release time: %.2f ms\n", resp)
return nil
}
if err := ctx.Client.MainMono.Comp.SetRelease(0, *cmd.Release); err != nil {
return fmt.Errorf("failed to set Main Mono compressor release time: %w", err)
}
fmt.Fprintf(ctx.Out, "Main Mono compressor release time set to: %.2f ms\n", *cmd.Release)
return nil
}

View File

@ -1,551 +0,0 @@
package main
import (
"fmt"
"time"
)
// 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 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:""`
}
func (cmd *MatrixCmdGroup) Validate() error {
if cmd.Index.Index < 1 || cmd.Index.Index > 6 {
return fmt.Errorf("matrix output index must be between 1 and 6, got %d", 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 == trueStr); 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 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 {
Band *int `arg:"" help:"The EQ band number." optional:""`
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() error {
if cmd.Band.Band == nil {
return nil
}
if *cmd.Band.Band < 1 || *cmd.Band.Band > 6 {
return fmt.Errorf("EQ band number must be between 1 and 6, got %d", *cmd.Band.Band)
}
return 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 == trueStr); 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 == trueStr)
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 == trueStr); 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 == trueStr)
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
}

View File

@ -1,85 +0,0 @@
package main
import "fmt"
type SnapshotCmdGroup struct {
List ListCmd `help:"List all snapshots." cmd:"list"`
Index struct {
Index *int `arg:"" help:"The index of the snapshot." optional:""`
Name NameCmd `help:"Get or set the name of a snapshot." cmd:"name"`
Save SaveCmd `help:"Save the current mixer state to a snapshot." cmd:"save"`
Load LoadCmd `help:"Load a mixer state from a snapshot." cmd:"load"`
Delete DeleteCmd `help:"Delete a snapshot." cmd:"delete"`
} `help:"The index of the snapshot." arg:""`
}
// Validate checks if the provided snapshot index is within the valid range (1-64) when any of the subcommands that require an index are used.
func (cmd *SnapshotCmdGroup) Validate() error {
if cmd.Index.Index == nil {
return nil
}
if *cmd.Index.Index < 1 || *cmd.Index.Index > 64 {
return fmt.Errorf("snapshot index must be between 1 and 64")
}
return nil
}
type ListCmd struct{}
func (cmd *ListCmd) Run(ctx *context) error {
for i := range 64 {
name, err := ctx.Client.Snapshot.Name(i + 1)
if err != nil {
return fmt.Errorf("failed to get name for snapshot %d: %w", i+1, err)
}
if name == "" {
continue
}
fmt.Fprintf(ctx.Out, "%d: %s\n", i+1, name)
}
return nil
}
type NameCmd struct {
Name *string `arg:"" help:"The name of the snapshot." optional:""`
}
func (cmd *NameCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error {
if cmd.Name == nil {
name, err := ctx.Client.Snapshot.Name(*snapshot.Index.Index)
if err != nil {
return err
}
fmt.Fprintln(ctx.Out, name)
return nil
}
return ctx.Client.Snapshot.SetName(*snapshot.Index.Index, *cmd.Name)
}
type SaveCmd struct {
Name string `arg:"" help:"The name of the snapshot."`
}
func (cmd *SaveCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error {
err := ctx.Client.Snapshot.CurrentName(cmd.Name)
if err != nil {
return err
}
return ctx.Client.Snapshot.CurrentSave(*snapshot.Index.Index)
}
type LoadCmd struct{}
func (cmd *LoadCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error {
return ctx.Client.Snapshot.CurrentLoad(*snapshot.Index.Index)
}
type DeleteCmd struct{}
func (cmd *DeleteCmd) Run(ctx *context, snapshot *SnapshotCmdGroup) error {
return ctx.Client.Snapshot.CurrentDelete(*snapshot.Index.Index)
}

View File

@ -1,68 +0,0 @@
package main
import (
"fmt"
)
// DCACmdGroup is the command group for controlling DCA groups.
type DCACmdGroup struct {
Index struct {
Index int `arg:"" help:"The index of the DCA group (1-4)."`
Mute DCAMuteCmd `help:"Get or set the mute status of the DCA group." cmd:""`
Name DCANameCmd `help:"Get or set the name of the DCA group." cmd:""`
} `arg:"" help:"Control a specific DCA group by its index."`
}
// Validate checks if the provided index is within the valid range.
func (cmd *DCACmdGroup) Validate() error {
if cmd.Index.Index < 1 || cmd.Index.Index > 4 {
return fmt.Errorf("DCA group index must be between 1 and 4, got %d", cmd.Index.Index)
}
return nil
}
// DCAMuteCmd is the command to get or set the mute status of a DCA group.
type DCAMuteCmd struct {
State *string `arg:"" help:"Set the mute status of the DCA group." optional:"" enum:"true,false"`
}
// Run executes the DCAMuteCmd command.
func (cmd *DCAMuteCmd) Run(ctx *context, dca *DCACmdGroup) error {
if cmd.State == nil {
resp, err := ctx.Client.DCA.Mute(dca.Index.Index)
if err != nil {
return fmt.Errorf("failed to get DCA mute status: %w", err)
}
fmt.Fprintf(ctx.Out, "DCA Group %d mute state: %t\n", dca.Index.Index, resp)
return nil
}
if err := ctx.Client.DCA.SetMute(dca.Index.Index, *cmd.State == trueStr); err != nil {
return fmt.Errorf("failed to set DCA mute status: %w", err)
}
return nil
}
// DCANameCmd is the command to get or set the name of a DCA group.
type DCANameCmd struct {
Name *string `arg:"" help:"Set the name of the DCA group." optional:""`
}
// Run executes the DCANameCmd command.
func (cmd *DCANameCmd) Run(ctx *context, dca *DCACmdGroup) error {
if cmd.Name == nil {
resp, err := ctx.Client.DCA.Name(dca.Index.Index)
if err != nil {
return fmt.Errorf("failed to get DCA name: %w", err)
}
if resp == "" {
resp = fmt.Sprintf("DCA %d", dca.Index.Index)
}
fmt.Fprintf(ctx.Out, "DCA Group %d is named '%s'\n", dca.Index.Index, resp)
return nil
}
if err := ctx.Client.DCA.SetName(dca.Index.Index, *cmd.Name); err != nil {
return fmt.Errorf("failed to set DCA name: %w", err)
}
return nil
}

View File

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

View File

@ -1,510 +0,0 @@
// Package main implements the command-line interface for controlling an XAir digital mixer.
package main
import (
"fmt"
"time"
)
// MainCmdGroup defines the command group for controlling the Main L/R output, including commands for mute state, fader level, and fade-in/fade-out times.
type MainCmdGroup struct {
Mute MainMuteCmd `help:"Get or set the mute state of the Main L/R output." cmd:""`
Fader MainFaderCmd `help:"Get or set the fader level of the Main L/R output." cmd:""`
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 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"`
}
// MainMuteCmd defines the command for getting or setting the mute state of the Main L/R output, allowing users to specify the desired state as "true"/"on" or "false"/"off".
type MainMuteCmd 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 MainMuteCmd command, either retrieving the current mute state of the Main L/R output or setting it based on the provided argument.
func (cmd *MainMuteCmd) Run(ctx *context) error {
if cmd.Mute == nil {
resp, err := ctx.Client.Main.Mute()
if err != nil {
return fmt.Errorf("failed to get Main L/R mute state: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R mute state: %t\n", resp)
return nil
}
if err := ctx.Client.Main.SetMute(*cmd.Mute == trueStr); err != nil {
return fmt.Errorf("failed to set Main L/R mute state: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R mute state set to: %s\n", *cmd.Mute)
return nil
}
// MainFaderCmd defines the command for getting or setting the fader level of the Main L/R output, allowing users to specify the desired level in dB.
type MainFaderCmd struct {
Level *float64 `arg:"" help:"The fader level to set. If not provided, the current level will be printed." optional:""`
}
// Run executes the MainFaderCmd command, either retrieving the current fader level of the Main L/R output or setting it based on the provided argument.
func (cmd *MainFaderCmd) Run(ctx *context) error {
if cmd.Level == nil {
resp, err := ctx.Client.Main.Fader()
if err != nil {
return fmt.Errorf("failed to get Main L/R fader level: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R fader level: %.2f\n", resp)
return nil
}
if err := ctx.Client.Main.SetFader(*cmd.Level); err != nil {
return fmt.Errorf("failed to set Main L/R fader level: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R fader level set to: %.2f\n", *cmd.Level)
return nil
}
// MainFadeinCmd defines the command for getting or setting the fade-in time of the Main L/R output, allowing users to specify the desired duration for the fade-in effect.
type MainFadeinCmd 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 MainFadeinCmd command, either retrieving the current fade-in time of the Main L/R output or setting it based on the provided argument, with an optional target level for the fade-in effect.
func (cmd *MainFadeinCmd) Run(ctx *context) error {
currentLevel, err := ctx.Client.Main.Fader()
if err != nil {
return fmt.Errorf("failed to get Main L/R 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.Main.SetFader(currentLevel); err != nil {
return fmt.Errorf("failed to set Main L/R fader level: %w", err)
}
time.Sleep(stepDuration)
}
fmt.Fprintf(ctx.Out, "Main L/R fade-in completed. Final level: %.2f\n", currentLevel)
return nil
}
// MainFadeoutCmd defines the command for getting or setting the fade-out time of the Main L/R output, allowing users to specify the desired duration for the fade-out effect and an optional target level to fade out to.
type MainFadeoutCmd 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 MainFadeoutCmd command, either retrieving the current fade-out time of the Main L/R output or setting it based on the provided argument, with an optional target level for the fade-out effect.
func (cmd *MainFadeoutCmd) Run(ctx *context) error {
currentLevel, err := ctx.Client.Main.Fader()
if err != nil {
return fmt.Errorf("failed to get Main L/R 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.Main.SetFader(currentLevel); err != nil {
return fmt.Errorf("failed to set Main L/R fader level: %w", err)
}
time.Sleep(stepDuration)
}
fmt.Fprintf(ctx.Out, "Main L/R fade-out completed. Final level: %.2f\n", currentLevel)
return nil
}
// 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 {
Band *int `arg:"" help:"The EQ band number." optional:""`
Gain MainEqBandGainCmd `help:"Get or set the gain of the specified EQ band." cmd:"gain"`
Freq MainEqBandFreqCmd `help:"Get or set the frequency of the specified EQ band." cmd:"freq"`
Q MainEqBandQCmd `help:"Get or set the Q factor of the specified EQ band." cmd:"q"`
Type MainEqBandTypeCmd `help:"Get or set the type of the specified EQ band." cmd:"type"`
} `help:"Commands for controlling individual EQ bands of the Main L/R output." arg:""`
}
// Validate checks if the provided EQ band number is within the valid range (1-6) for the Main L/R output.
func (cmd *MainEqCmdGroup) Validate() error {
if cmd.Band.Band == nil {
return nil
}
if *cmd.Band.Band < 1 || *cmd.Band.Band > 6 {
return fmt.Errorf("EQ band number must be between 1 and 6, got %d", *cmd.Band.Band)
}
return nil
}
// MainEqOnCmd defines the command for getting or setting the EQ on/off state of the Main L/R output, allowing users to specify the desired state as "true"/"on" or "false"/"off".
type MainEqOnCmd 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 MainEqOnCmd command, either retrieving the current EQ on/off state of the Main L/R output or setting it based on the provided argument.
func (cmd *MainEqOnCmd) Run(ctx *context) error {
if cmd.Enable == nil {
resp, err := ctx.Client.Main.Eq.On(0)
if err != nil {
return fmt.Errorf("failed to get Main L/R EQ on/off state: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R EQ on/off state: %t\n", resp)
return nil
}
if err := ctx.Client.Main.Eq.SetOn(0, *cmd.Enable == trueStr); err != nil {
return fmt.Errorf("failed to set Main L/R EQ on/off state: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R EQ on/off state set to: %t\n", *cmd.Enable == trueStr)
return nil
}
// MainEqBandGainCmd defines the command for getting or setting the gain of a specific EQ band on the Main L/R output, allowing users to specify the desired gain in dB.
type MainEqBandGainCmd 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 MainEqBandGainCmd command, either retrieving the current gain of a specific EQ band on the Main L/R output or setting it based on the provided argument.
func (cmd *MainEqBandGainCmd) Run(ctx *context, mainEq *MainEqCmdGroup) error {
if cmd.Level == nil {
resp, err := ctx.Client.Main.Eq.Gain(0, *mainEq.Band.Band)
if err != nil {
return fmt.Errorf("failed to get Main L/R EQ band %d gain: %w", *mainEq.Band.Band, err)
}
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d gain: %.2f dB\n", *mainEq.Band.Band, resp)
return nil
}
if err := ctx.Client.Main.Eq.SetGain(0, *mainEq.Band.Band, *cmd.Level); err != nil {
return fmt.Errorf("failed to set Main L/R EQ band %d gain: %w", *mainEq.Band.Band, err)
}
fmt.Fprintf(
ctx.Out,
"Main L/R EQ band %d gain set to: %.2f dB\n",
*mainEq.Band.Band,
*cmd.Level,
)
return nil
}
// MainEqBandFreqCmd defines the command for getting or setting the frequency of a specific EQ band on the Main L/R output, allowing users to specify the desired frequency in Hz.
type MainEqBandFreqCmd 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 MainEqBandFreqCmd command, either retrieving the current frequency of a specific EQ band on the Main L/R output or setting it based on the provided argument.
func (cmd *MainEqBandFreqCmd) Run(ctx *context, mainEq *MainEqCmdGroup) error {
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,
)
}
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d frequency: %.2f Hz\n", *mainEq.Band.Band, resp)
return nil
}
if err := ctx.Client.Main.Eq.SetFrequency(0, *mainEq.Band.Band, *cmd.Frequency); err != nil {
return fmt.Errorf("failed to set Main L/R EQ band %d frequency: %w", *mainEq.Band.Band, err)
}
fmt.Fprintf(
ctx.Out,
"Main L/R EQ band %d frequency set to: %.2f Hz\n",
*mainEq.Band.Band,
*cmd.Frequency,
)
return nil
}
// MainEqBandQCmd defines the command for getting or setting the Q factor of a specific EQ band on the Main L/R output, allowing users to specify the desired Q factor.
type MainEqBandQCmd 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 MainEqBandQCmd command, either retrieving the current Q factor of a specific EQ band on the Main L/R output or setting it based on the provided argument.
func (cmd *MainEqBandQCmd) Run(ctx *context, mainEq *MainEqCmdGroup) error {
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,
)
}
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d Q factor: %.2f\n", *mainEq.Band.Band, resp)
return nil
}
if err := ctx.Client.Main.Eq.SetQ(0, *mainEq.Band.Band, *cmd.Q); err != nil {
return fmt.Errorf("failed to set Main L/R EQ band %d Q factor: %w", *mainEq.Band.Band, err)
}
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d Q factor set to: %.2f\n", *mainEq.Band.Band, *cmd.Q)
return nil
}
// MainEqBandTypeCmd defines the command for getting or setting the type of a specific EQ band on the Main L/R output, allowing users to specify the desired type as "peaking", "low_shelf", "high_shelf", "low_pass", or "high_pass".
type MainEqBandTypeCmd 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 MainEqBandTypeCmd command, either retrieving the current type of a specific EQ band on the Main L/R output or setting it based on the provided argument.
func (cmd *MainEqBandTypeCmd) Run(ctx *context, mainEq *MainEqCmdGroup) error {
if cmd.Type == nil {
resp, err := ctx.Client.Main.Eq.Type(0, *mainEq.Band.Band)
if err != nil {
return fmt.Errorf("failed to get Main L/R EQ band %d type: %w", *mainEq.Band.Band, err)
}
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d type: %s\n", *mainEq.Band.Band, resp)
return nil
}
if err := ctx.Client.Main.Eq.SetType(0, *mainEq.Band.Band, *cmd.Type); err != nil {
return fmt.Errorf("failed to set Main L/R EQ band %d type: %w", *mainEq.Band.Band, err)
}
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d type set to: %s\n", *mainEq.Band.Band, *cmd.Type)
return nil
}
// MainCompCmdGroup defines the command group for controlling the compressor settings of the Main L/R output, including commands for getting or setting the compressor parameters.
type MainCompCmdGroup struct {
On MainCompOnCmd `help:"Get or set the compressor on/off state of the Main L/R output." cmd:"on"`
Mode MainCompModeCmd `help:"Get or set the compressor mode of the Main L/R output." cmd:"mode"`
Threshold MainCompThresholdCmd `help:"Get or set the compressor threshold of the Main L/R output." cmd:"threshold"`
Ratio MainCompRatioCmd `help:"Get or set the compressor ratio of the Main L/R output." cmd:"ratio"`
Mix MainCompMixCmd `help:"Get or set the compressor mix level of the Main L/R output." cmd:"mix"`
Makeup MainCompMakeupCmd `help:"Get or set the compressor makeup gain of the Main L/R output." cmd:"makeup"`
Attack MainCompAttackCmd `help:"Get or set the compressor attack time of the Main L/R output." cmd:"attack"`
Hold MainCompHoldCmd `help:"Get or set the compressor hold time of the Main L/R output." cmd:"hold"`
Release MainCompReleaseCmd `help:"Get or set the compressor release time of the Main L/R output." cmd:"release"`
}
// MainCompOnCmd defines the command for getting or setting the compressor on/off state of the Main L/R output, allowing users to specify the desired state as "true"/"on" or "false"/"off".
type MainCompOnCmd 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 MainCompOnCmd command, either retrieving the current compressor on/off state of the Main L/R output or setting it based on the provided argument.
func (cmd *MainCompOnCmd) Run(ctx *context) error {
if cmd.Enable == nil {
resp, err := ctx.Client.Main.Comp.On(0)
if err != nil {
return fmt.Errorf("failed to get Main L/R compressor on/off state: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R compressor on/off state: %t\n", resp)
return nil
}
if err := ctx.Client.Main.Comp.SetOn(0, *cmd.Enable == trueStr); err != nil {
return fmt.Errorf("failed to set Main L/R compressor on/off state: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R compressor on/off state set to: %t\n", *cmd.Enable == trueStr)
return nil
}
// MainCompModeCmd defines the command for getting or setting the compressor mode of the Main L/R output, allowing users to specify the desired mode as "comp" or "exp".
type MainCompModeCmd 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 MainCompModeCmd command, either retrieving the current compressor mode of the Main L/R output or setting it based on the provided argument.
func (cmd *MainCompModeCmd) Run(ctx *context) error {
if cmd.Mode == nil {
resp, err := ctx.Client.Main.Comp.Mode(0)
if err != nil {
return fmt.Errorf("failed to get Main L/R compressor mode: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R compressor mode: %s\n", resp)
return nil
}
if err := ctx.Client.Main.Comp.SetMode(0, *cmd.Mode); err != nil {
return fmt.Errorf("failed to set Main L/R compressor mode: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R compressor mode set to: %s\n", *cmd.Mode)
return nil
}
// MainCompThresholdCmd defines the command for getting or setting the compressor threshold of the Main L/R output, allowing users to specify the desired threshold in dB.
type MainCompThresholdCmd struct {
Threshold *float64 `arg:"" help:"The compressor threshold to set. If not provided, the current threshold will be printed." optional:""`
}
// Run executes the MainCompThresholdCmd command, either retrieving the current compressor threshold of the Main L/R output or setting it based on the provided argument.
func (cmd *MainCompThresholdCmd) Run(ctx *context) error {
if cmd.Threshold == nil {
resp, err := ctx.Client.Main.Comp.Threshold(0)
if err != nil {
return fmt.Errorf("failed to get Main L/R compressor threshold: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R compressor threshold: %.2f dB\n", resp)
return nil
}
if err := ctx.Client.Main.Comp.SetThreshold(0, *cmd.Threshold); err != nil {
return fmt.Errorf("failed to set Main L/R compressor threshold: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R compressor threshold set to: %.2f dB\n", *cmd.Threshold)
return nil
}
// MainCompRatioCmd defines the command for getting or setting the compressor ratio of the Main L/R output, allowing users to specify the desired ratio.
type MainCompRatioCmd struct {
Ratio *float64 `arg:"" help:"The compressor ratio to set. If not provided, the current ratio will be printed." optional:""`
}
// Run executes the MainCompRatioCmd command, either retrieving the current compressor ratio of the Main L/R output or setting it based on the provided argument.
func (cmd *MainCompRatioCmd) Run(ctx *context) error {
if cmd.Ratio == nil {
resp, err := ctx.Client.Main.Comp.Ratio(0)
if err != nil {
return fmt.Errorf("failed to get Main L/R compressor ratio: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R compressor ratio: %.2f\n", resp)
return nil
}
if err := ctx.Client.Main.Comp.SetRatio(0, *cmd.Ratio); err != nil {
return fmt.Errorf("failed to set Main L/R compressor ratio: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R compressor ratio set to: %.2f\n", *cmd.Ratio)
return nil
}
// MainCompMixCmd defines the command for getting or setting the compressor mix level of the Main L/R output, allowing users to specify the desired mix level in percentage.
type MainCompMixCmd 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 MainCompMixCmd command, either retrieving the current compressor mix level of the Main L/R output or setting it based on the provided argument.
func (cmd *MainCompMixCmd) Run(ctx *context) error {
if cmd.Mix == nil {
resp, err := ctx.Client.Main.Comp.Mix(0)
if err != nil {
return fmt.Errorf("failed to get Main L/R compressor mix level: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R compressor mix level: %.2f%%\n", resp)
return nil
}
if err := ctx.Client.Main.Comp.SetMix(0, *cmd.Mix); err != nil {
return fmt.Errorf("failed to set Main L/R compressor mix level: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R compressor mix level set to: %.2f%%\n", *cmd.Mix)
return nil
}
// MainCompMakeupCmd defines the command for getting or setting the compressor makeup gain of the Main L/R output, allowing users to specify the desired makeup gain in dB.
type MainCompMakeupCmd 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 MainCompMakeupCmd command, either retrieving the current compressor makeup gain of the Main L/R output or setting it based on the provided argument.
func (cmd *MainCompMakeupCmd) Run(ctx *context) error {
if cmd.Makeup == nil {
resp, err := ctx.Client.Main.Comp.Makeup(0)
if err != nil {
return fmt.Errorf("failed to get Main L/R compressor makeup gain: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R compressor makeup gain: %.2f dB\n", resp)
return nil
}
if err := ctx.Client.Main.Comp.SetMakeup(0, *cmd.Makeup); err != nil {
return fmt.Errorf("failed to set Main L/R compressor makeup gain: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R compressor makeup gain set to: %.2f dB\n", *cmd.Makeup)
return nil
}
// MainCompAttackCmd defines the command for getting or setting the compressor attack time of the Main L/R output, allowing users to specify the desired attack time in milliseconds.
type MainCompAttackCmd 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 MainCompAttackCmd command, either retrieving the current compressor attack time of the Main L/R output or setting it based on the provided argument.
func (cmd *MainCompAttackCmd) Run(ctx *context) error {
if cmd.Attack == nil {
resp, err := ctx.Client.Main.Comp.Attack(0)
if err != nil {
return fmt.Errorf("failed to get Main L/R compressor attack time: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R compressor attack time: %.2f ms\n", resp)
return nil
}
if err := ctx.Client.Main.Comp.SetAttack(0, *cmd.Attack); err != nil {
return fmt.Errorf("failed to set Main L/R compressor attack time: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R compressor attack time set to: %.2f ms\n", *cmd.Attack)
return nil
}
// MainCompHoldCmd defines the command for getting or setting the compressor hold time of the Main L/R output, allowing users to specify the desired hold time in milliseconds.
type MainCompHoldCmd 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 MainCompHoldCmd command, either retrieving the current compressor hold time of the Main L/R output or setting it based on the provided argument.
func (cmd *MainCompHoldCmd) Run(ctx *context) error {
if cmd.Hold == nil {
resp, err := ctx.Client.Main.Comp.Hold(0)
if err != nil {
return fmt.Errorf("failed to get Main L/R compressor hold time: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R compressor hold time: %.2f ms\n", resp)
return nil
}
if err := ctx.Client.Main.Comp.SetHold(0, *cmd.Hold); err != nil {
return fmt.Errorf("failed to set Main L/R compressor hold time: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R compressor hold time set to: %.2f ms\n", *cmd.Hold)
return nil
}
// MainCompReleaseCmd defines the command for getting or setting the compressor release time of the Main L/R output, allowing users to specify the desired release time in milliseconds.
type MainCompReleaseCmd 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 MainCompReleaseCmd command, either retrieving the current compressor release time of the Main L/R output or setting it based on the provided argument.
func (cmd *MainCompReleaseCmd) Run(ctx *context) error {
if cmd.Release == nil {
resp, err := ctx.Client.Main.Comp.Release(0)
if err != nil {
return fmt.Errorf("failed to get Main L/R compressor release time: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R compressor release time: %.2f ms\n", resp)
return nil
}
if err := ctx.Client.Main.Comp.SetRelease(0, *cmd.Release); err != nil {
return fmt.Errorf("failed to set Main L/R compressor release time: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R compressor release time set to: %.2f ms\n", *cmd.Release)
return nil
}

View File

@ -1,39 +0,0 @@
package main
import (
"fmt"
"github.com/charmbracelet/log"
)
// RawCmd represents the command to send raw OSC messages to the mixer.
type RawCmd struct {
Address string `help:"The OSC address to send the message to." arg:""`
Args []string `help:"The arguments to include in the OSC message." arg:"" optional:""`
}
// Run executes the RawCmd by sending the specified OSC message to the mixer and optionally waiting for a response.
func (cmd *RawCmd) Run(ctx *context) error {
params := make([]any, len(cmd.Args))
for i, arg := range cmd.Args {
params[i] = arg
}
if err := ctx.Client.SendMessage(cmd.Address, params...); err != nil {
return fmt.Errorf("failed to send raw OSC message: %w", err)
}
if len(params) > 0 {
log.Debugf("Sent OSC message: %s with args: %v\n", cmd.Address, cmd.Args)
return nil
}
msg, err := ctx.Client.ReceiveMessage()
if err != nil {
return fmt.Errorf("failed to receive response for raw OSC message: %w", err)
}
if msg != nil {
fmt.Fprintf(ctx.Out, "Received response: %s with args: %v\n", msg.Address, msg.Arguments)
}
return nil
}

View File

@ -1,863 +0,0 @@
package main
import (
"fmt"
"time"
)
// StripCmdGroup defines the command group for controlling the strips of the mixer, including commands for getting and setting various parameters such as mute state, fader level, send levels, and EQ settings.
type StripCmdGroup struct {
Index struct {
Index int `arg:"" help:"The index of the strip. (1-based indexing)"`
Mute StripMuteCmd ` help:"Get or set the mute state of the strip." cmd:""`
Fader StripFaderCmd ` help:"Get or set the fader level of the strip." cmd:""`
Fadein StripFadeinCmd ` help:"Fade in the strip over a specified duration." cmd:""`
Fadeout StripFadeoutCmd ` help:"Fade out the strip over a specified duration." cmd:""`
Send StripSendCmd ` help:"Get or set the send level for a specific bus." cmd:""`
Name StripNameCmd ` help:"Get or set the name of the strip." cmd:""`
Gate StripGateCmdGroup ` help:"Commands related to the strip gate." cmd:"gate"`
Eq StripEqCmdGroup ` help:"Commands related to the strip EQ." cmd:"eq"`
Comp StripCompCmdGroup ` help:"Commands related to the strip compressor." cmd:"comp"`
} `arg:"" help:"Control a specific strip by index."`
}
// StripMuteCmd defines the command for getting or setting the mute state of a strip.
type StripMuteCmd struct {
State *string `arg:"" help:"The mute state to set (true or false). If not provided, the current mute state will be returned." optional:"" enum:"true,false"`
}
// Run executes the StripMuteCmd command, either retrieving the current mute state of the strip or setting it based on the provided argument.
func (cmd *StripMuteCmd) Run(ctx *context, strip *StripCmdGroup) error {
if cmd.State == nil {
resp, err := ctx.Client.Strip.Mute(strip.Index.Index)
if err != nil {
return fmt.Errorf("failed to get mute state: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d mute state: %t\n", strip.Index.Index, resp)
return nil
}
if err := ctx.Client.Strip.SetMute(strip.Index.Index, *cmd.State == trueStr); err != nil {
return fmt.Errorf("failed to set mute state: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d mute state set to: %s\n", strip.Index.Index, *cmd.State)
return nil
}
// StripFaderCmd defines the command for getting or setting the fader level of a strip.
type StripFaderCmd struct {
Level *float64 `arg:"" help:"The fader level to set (in dB)." optional:""`
}
// Run executes the StripFaderCmd command, either retrieving the current fader level of the strip or setting it based on the provided argument.
func (cmd *StripFaderCmd) Run(ctx *context, strip *StripCmdGroup) error {
if cmd.Level == nil {
resp, err := ctx.Client.Strip.Fader(strip.Index.Index)
if err != nil {
return fmt.Errorf("failed to get fader level: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d fader level: %.2f dB\n", strip.Index.Index, resp)
return nil
}
if err := ctx.Client.Strip.SetFader(strip.Index.Index, *cmd.Level); err != nil {
return fmt.Errorf("failed to set fader level: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d fader level set to: %.2f dB\n", strip.Index.Index, *cmd.Level)
return nil
}
// StripFadeinCmd defines the command for fading in a strip over a specified duration, gradually increasing the fader level from its current value to a target value.
type StripFadeinCmd struct {
Duration time.Duration `flag:"" help:"The duration of the fade-in (in seconds)." default:"5s"`
Target float64 ` help:"The target fader level (in dB)." default:"0.0" arg:""`
}
// Run executes the StripFadeinCmd command, gradually increasing the fader level of the strip from its current value to the specified target value over the specified duration.
func (cmd *StripFadeinCmd) Run(ctx *context, strip *StripCmdGroup) error {
currentLevel, err := ctx.Client.Strip.Fader(strip.Index.Index)
if err != nil {
return fmt.Errorf("failed to get current fader level: %w", err)
}
if currentLevel >= cmd.Target {
return fmt.Errorf(
"current fader level (%.2f dB) is already at or above the target level (%.2f dB)",
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.Strip.SetFader(strip.Index.Index, currentLevel); err != nil {
return fmt.Errorf("failed to set fader level during fade-in: %w", err)
}
time.Sleep(stepDuration)
}
fmt.Fprintf(
ctx.Out,
"Strip %d fade-in complete. Final level: %.2f dB\n",
strip.Index.Index,
cmd.Target,
)
return nil
}
// StripFadeoutCmd defines the command for fading out a strip over a specified duration, gradually decreasing the fader level from its current value to a target value.
type StripFadeoutCmd struct {
Duration time.Duration `flag:"" help:"The duration of the fade-out (in seconds)." default:"5s"`
Target float64 ` help:"The target fader level (in dB)." default:"-90.0" arg:""`
}
// Run executes the StripFadeoutCmd command, gradually decreasing the fader level of the strip from its current value to the specified target value over the specified duration.
func (cmd *StripFadeoutCmd) Run(ctx *context, strip *StripCmdGroup) error {
{
currentLevel, err := ctx.Client.Strip.Fader(strip.Index.Index)
if err != nil {
return fmt.Errorf("failed to get current fader level: %w", err)
}
if currentLevel <= cmd.Target {
return fmt.Errorf(
"current fader level (%.2f dB) is already at or below the target level (%.2f dB)",
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.Strip.SetFader(strip.Index.Index, currentLevel); err != nil {
return fmt.Errorf("failed to set fader level during fade-out: %w", err)
}
time.Sleep(stepDuration)
}
fmt.Fprintf(
ctx.Out,
"Strip %d fade-out complete. Final level: %.2f dB\n",
strip.Index.Index,
cmd.Target,
)
return nil
}
}
// StripSendCmd defines the command for getting or setting the auxiliary send level
// for a specific send destination (mix bus or effects channel) on a strip.
type StripSendCmd struct {
SendIndex int `arg:"" help:"The index of the send destination (mix bus or effects channel). (1-based indexing)"`
Level *float64 `arg:"" help:"The send level to set (in dB)." optional:""`
}
// Run executes the StripSendCmd command, either retrieving the current send level for the specified destination
// or setting it based on the provided argument.
func (cmd *StripSendCmd) Run(ctx *context, strip *StripCmdGroup) error {
if cmd.Level == nil {
resp, err := ctx.Client.Strip.SendLevel(strip.Index.Index, cmd.SendIndex)
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,
)
return 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,
)
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 organisation.
type StripNameCmd struct {
Name *string `arg:"" help:"The name to set for the strip." optional:""`
}
// Run executes the StripNameCmd command, either retrieving the current name of the strip or setting it based on the provided argument.
func (cmd *StripNameCmd) Run(ctx *context, strip *StripCmdGroup) error {
if cmd.Name == nil {
resp, err := ctx.Client.Strip.Name(strip.Index.Index)
if err != nil {
return fmt.Errorf("failed to get strip name: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d name: %s\n", strip.Index.Index, resp)
return nil
}
if err := ctx.Client.Strip.SetName(strip.Index.Index, *cmd.Name); err != nil {
return fmt.Errorf("failed to set strip name: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d name set to: %s\n", strip.Index.Index, *cmd.Name)
return nil
}
// StripGateCmdGroup defines the command group for controlling the gate settings of a strip, including commands for getting and setting the gate on/off state, mode, threshold, range, attack time, hold time, and release time.
type StripGateCmdGroup struct {
On StripGateOnCmd `help:"Get or set the gate on/off state of the strip." cmd:""`
Mode StripGateModeCmd `help:"Get or set the gate mode of the strip." cmd:""`
Threshold StripGateThresholdCmd `help:"Get or set the gate threshold of the strip." cmd:""`
Range StripGateRangeCmd `help:"Get or set the gate range of the strip." cmd:""`
Attack StripGateAttackCmd `help:"Get or set the gate attack time of the strip." cmd:""`
Hold StripGateHoldCmd `help:"Get or set the gate hold time of the strip." cmd:""`
Release StripGateReleaseCmd `help:"Get or set the gate release time of the strip." cmd:""`
}
// StripGateOnCmd defines the command for getting or setting the gate on/off state of a strip, allowing users to enable or disable the gate effect on the strip.
type StripGateOnCmd struct {
Enable *string `arg:"" help:"Whether to enable or disable the gate." optional:"" enum:"true,false"`
}
// Run executes the StripGateOnCmd command, either retrieving the current gate on/off state of the strip or setting it based on the provided argument.
func (cmd *StripGateOnCmd) Run(ctx *context, strip *StripCmdGroup) error {
if cmd.Enable == nil {
resp, err := ctx.Client.Strip.Gate.On(strip.Index.Index)
if err != nil {
return fmt.Errorf("failed to get gate state: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d gate state: %t\n", strip.Index.Index, resp)
return nil
}
if err := ctx.Client.Strip.Gate.SetOn(strip.Index.Index, *cmd.Enable == trueStr); err != nil {
return fmt.Errorf("failed to set gate state: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d gate state set to: %s\n", strip.Index.Index, *cmd.Enable)
return nil
}
// StripGateModeCmd defines the command for getting or setting the gate mode of a strip, allowing users to choose from different gate modes such as exp2, exp3, exp4, gate, or duck.
type StripGateModeCmd struct {
Mode *string `arg:"" help:"The gate mode to set." optional:"" enum:"exp2,exp3,exp4,gate,duck"`
}
// Run executes the StripGateModeCmd command, either retrieving the current gate mode of the strip or setting it based on the provided argument.
func (cmd *StripGateModeCmd) Run(ctx *context, strip *StripCmdGroup) error {
if cmd.Mode == nil {
resp, err := ctx.Client.Strip.Gate.Mode(strip.Index.Index)
if err != nil {
return fmt.Errorf("failed to get gate mode: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d gate mode: %s\n", strip.Index.Index, resp)
return nil
}
if err := ctx.Client.Strip.Gate.SetMode(strip.Index.Index, *cmd.Mode); err != nil {
return fmt.Errorf("failed to set gate mode: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d gate mode set to: %s\n", strip.Index.Index, *cmd.Mode)
return nil
}
// StripGateThresholdCmd defines the command for getting or setting the gate threshold of a strip, allowing users to specify the threshold level at which the gate will start to attenuate the signal.
type StripGateThresholdCmd struct {
Threshold *float64 `arg:"" help:"The gate threshold to set (in dB)." optional:""`
}
// Run executes the StripGateThresholdCmd command, either retrieving the current gate threshold of the strip or setting it based on the provided argument.
func (cmd *StripGateThresholdCmd) Run(ctx *context, strip *StripCmdGroup) error {
if cmd.Threshold == nil {
resp, err := ctx.Client.Strip.Gate.Threshold(strip.Index.Index)
if err != nil {
return fmt.Errorf("failed to get gate threshold: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d gate threshold: %.2f\n", strip.Index.Index, resp)
return nil
}
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,
)
return nil
}
// StripGateRangeCmd defines the command for getting or setting the gate range of a strip, allowing users to specify the amount of attenuation applied by the gate when the signal falls below the threshold.
type StripGateRangeCmd struct {
Range *float64 `arg:"" help:"The gate range to set (in dB)." optional:""`
}
// Run executes the StripGateRangeCmd command, either retrieving the current gate range of the strip or setting it based on the provided argument.
func (cmd *StripGateRangeCmd) Run(ctx *context, strip *StripCmdGroup) error {
if cmd.Range == nil {
resp, err := ctx.Client.Strip.Gate.Range(strip.Index.Index)
if err != nil {
return fmt.Errorf("failed to get gate range: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d gate range: %.2f\n", strip.Index.Index, resp)
return nil
}
if err := ctx.Client.Strip.Gate.SetRange(strip.Index.Index, *cmd.Range); err != nil {
return fmt.Errorf("failed to set gate range: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d gate range set to: %.2f\n", strip.Index.Index, *cmd.Range)
return nil
}
// StripGateAttackCmd defines the command for getting or setting the gate attack time of a strip, allowing users to specify the time it takes for the gate to fully open after the signal exceeds the threshold.
type StripGateAttackCmd struct {
Attack *float64 `arg:"" help:"The gate attack time to set (in ms)." optional:""`
}
// Run executes the StripGateAttackCmd command, either retrieving the current gate attack time of the strip or setting it based on the provided argument.
func (cmd *StripGateAttackCmd) Run(ctx *context, strip *StripCmdGroup) error {
if cmd.Attack == nil {
resp, err := ctx.Client.Strip.Gate.Attack(strip.Index.Index)
if err != nil {
return fmt.Errorf("failed to get gate attack time: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d gate attack time: %.2f ms\n", strip.Index.Index, resp)
return nil
}
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,
)
return nil
}
// StripGateHoldCmd defines the command for getting or setting the gate hold time of a strip, allowing users to specify the time that the gate remains open after the signal falls below the threshold before it starts to close.
type StripGateHoldCmd struct {
Hold *float64 `arg:"" help:"The gate hold time to set (in ms)." optional:""`
}
// Run executes the StripGateHoldCmd command, either retrieving the current gate hold time of the strip or setting it based on the provided argument.
func (cmd *StripGateHoldCmd) Run(ctx *context, strip *StripCmdGroup) error {
if cmd.Hold == nil {
resp, err := ctx.Client.Strip.Gate.Hold(strip.Index.Index)
if err != nil {
return fmt.Errorf("failed to get gate hold time: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d gate hold time: %.2f ms\n", strip.Index.Index, resp)
return nil
}
if err := ctx.Client.Strip.Gate.SetHold(strip.Index.Index, *cmd.Hold); err != nil {
return fmt.Errorf("failed to set gate hold time: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d gate hold time set to: %.2f ms\n", strip.Index.Index, *cmd.Hold)
return nil
}
// StripGateReleaseCmd defines the command for getting or setting the gate release time of a strip, allowing users to specify the time it takes for the gate to fully close after the signal falls below the threshold and the hold time has elapsed.
type StripGateReleaseCmd struct {
Release *float64 `arg:"" help:"The gate release time to set (in ms)." optional:""`
}
// Run executes the StripGateReleaseCmd command, either retrieving the current gate release time of the strip or setting it based on the provided argument.
func (cmd *StripGateReleaseCmd) Run(ctx *context, strip *StripCmdGroup) error {
if cmd.Release == nil {
resp, err := ctx.Client.Strip.Gate.Release(strip.Index.Index)
if err != nil {
return fmt.Errorf("failed to get gate release time: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d gate release time: %.2f ms\n", strip.Index.Index, resp)
return nil
}
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,
)
return nil
}
// StripEqCmdGroup defines the command group for controlling the EQ settings of a strip, including commands for getting and setting the EQ on/off state and parameters for each EQ band such as gain, frequency, Q factor, and type.
type StripEqCmdGroup struct {
On StripEqOnCmd `help:"Get or set the EQ on/off state of the strip." cmd:""`
Band struct {
Band *int `arg:"" help:"The EQ band number." optional:""`
Gain StripEqBandGainCmd `help:"Get or set the gain of the EQ band." cmd:""`
Freq StripEqBandFreqCmd `help:"Get or set the frequency of the EQ band." cmd:""`
Q StripEqBandQCmd `help:"Get or set the Q factor of the EQ band." cmd:""`
Type StripEqBandTypeCmd `help:"Get or set the type of the EQ band." cmd:""`
} `help:"Commands for controlling a specific EQ band of the strip." arg:""`
}
// Validate checks if the provided EQ band number is valid (between 1 and 4) and returns an error if it is not.
func (cmd *StripEqCmdGroup) Validate() error {
if cmd.Band.Band == nil {
return nil
}
if *cmd.Band.Band < 1 || *cmd.Band.Band > 4 {
return fmt.Errorf("EQ band number must be between 1 and 4, got %d", *cmd.Band.Band)
}
return nil
}
// StripEqOnCmd defines the command for getting or setting the EQ on/off state of a strip, allowing users to enable or disable the EQ effect on the strip.
type StripEqOnCmd struct {
Enable *string `arg:"" help:"Whether to enable or disable the EQ." optional:"" enum:"true,false"`
}
// Run executes the StripEqOnCmd command, either retrieving the current EQ on/off state of the strip or setting it based on the provided argument.
func (cmd *StripEqOnCmd) Run(ctx *context, strip *StripCmdGroup) error {
if cmd.Enable == nil {
resp, err := ctx.Client.Strip.Eq.On(strip.Index.Index)
if err != nil {
return fmt.Errorf("failed to get EQ state: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d EQ state: %t\n", strip.Index.Index, resp)
return nil
}
if err := ctx.Client.Strip.Eq.SetOn(strip.Index.Index, *cmd.Enable == trueStr); err != nil {
return fmt.Errorf("failed to set EQ state: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d EQ state set to: %s\n", strip.Index.Index, *cmd.Enable)
return nil
}
// StripEqBandGainCmd defines the command for getting or setting the gain of a specific EQ band on a strip, allowing users to adjust the level of the signal for that band in decibels (dB).
type StripEqBandGainCmd struct {
Gain *float64 `arg:"" help:"The gain to set for the EQ band (in dB)." optional:""`
}
// 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 {
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,
)
return 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,
)
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 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 {
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,
)
return 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(
ctx.Out,
"Strip %d EQ band %d frequency set to: %.2f Hz\n",
strip.Index.Index,
*stripEq.Band.Band,
*cmd.Freq,
)
return nil
}
// StripEqBandQCmd defines the command for getting or setting the Q factor of a specific EQ band on a strip, allowing users to adjust the bandwidth of the band, which determines how wide or narrow the affected frequency range is.
type StripEqBandQCmd struct {
Q *float64 `arg:"" help:"The Q factor to set for the EQ band." optional:""`
}
// 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 {
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,
)
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,
)
return nil
}
// StripEqBandTypeCmd defines the command for getting or setting the type of a specific EQ band on a strip, allowing users to choose from different EQ types such as low cut (lcut), low shelf (lshv), parametric (peq), variable Q (veq), high shelf (hshv), or high cut (hcut).
type StripEqBandTypeCmd struct {
Type *string `arg:"" help:"The type to set for the EQ band." optional:"" enum:"lcut,lshv,peq,veq,hshv,hcut"`
}
// 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 {
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,
)
return 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,
)
return nil
}
// StripCompCmdGroup defines the command group for controlling the compressor settings of a strip, including commands for getting and setting the compressor on/off state, mode, threshold, ratio, mix, makeup gain, attack time, hold time, and release time.
type StripCompCmdGroup struct {
On StripCompOnCmd `help:"Get or set the compressor on/off state of the strip." cmd:""`
Mode StripCompModeCmd `help:"Get or set the compressor mode of the strip." cmd:""`
Threshold StripCompThresholdCmd `help:"Get or set the compressor threshold of the strip." cmd:""`
Ratio StripCompRatioCmd `help:"Get or set the compressor ratio of the strip." cmd:""`
Mix StripCompMixCmd `help:"Get or set the compressor mix of the strip." cmd:""`
Makeup StripCompMakeupCmd `help:"Get or set the compressor makeup gain of the strip." cmd:""`
Attack StripCompAttackCmd `help:"Get or set the compressor attack time of the strip." cmd:""`
Hold StripCompHoldCmd `help:"Get or set the compressor hold time of the strip." cmd:""`
Release StripCompReleaseCmd `help:"Get or set the compressor release time of the strip." cmd:""`
}
// StripCompOnCmd defines the command for getting or setting the compressor on/off state of a strip, allowing users to enable or disable the compressor effect on the strip.
type StripCompOnCmd struct {
Enable *string `arg:"" help:"Whether to enable or disable the compressor." optional:"" enum:"true,false"`
}
// Run executes the StripCompOnCmd command, either retrieving the current compressor on/off state of the strip or setting it based on the provided argument.
func (cmd *StripCompOnCmd) Run(ctx *context, strip *StripCmdGroup) error {
if cmd.Enable == nil {
resp, err := ctx.Client.Strip.Comp.On(strip.Index.Index)
if err != nil {
return fmt.Errorf("failed to get compressor state: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d compressor state: %t\n", strip.Index.Index, resp)
return nil
}
if err := ctx.Client.Strip.Comp.SetOn(strip.Index.Index, *cmd.Enable == trueStr); err != nil {
return fmt.Errorf("failed to set compressor state: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d compressor state set to: %s\n", strip.Index.Index, *cmd.Enable)
return nil
}
// StripCompModeCmd defines the command for getting or setting the compressor mode of a strip, allowing users to choose from different compressor modes such as comp (standard compression) or exp (expander).
type StripCompModeCmd struct {
Mode *string `arg:"" help:"The compressor mode to set." optional:"" enum:"comp,exp"`
}
// Run executes the StripCompModeCmd command, either retrieving the current compressor mode of the strip or setting it based on the provided argument.
func (cmd *StripCompModeCmd) Run(ctx *context, strip *StripCmdGroup) error {
if cmd.Mode == nil {
resp, err := ctx.Client.Strip.Comp.Mode(strip.Index.Index)
if err != nil {
return fmt.Errorf("failed to get compressor mode: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d compressor mode: %s\n", strip.Index.Index, resp)
return nil
}
if err := ctx.Client.Strip.Comp.SetMode(strip.Index.Index, *cmd.Mode); err != nil {
return fmt.Errorf("failed to set compressor mode: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d compressor mode set to: %s\n", strip.Index.Index, *cmd.Mode)
return nil
}
// StripCompThresholdCmd defines the command for getting or setting the compressor threshold of a strip, allowing users to specify the threshold level at which the compressor will start to reduce the signal level.
type StripCompThresholdCmd struct {
Threshold *float64 `arg:"" help:"The compressor threshold to set (in dB)." optional:""`
}
// Run executes the StripCompThresholdCmd command, either retrieving the current compressor threshold of the strip or setting it based on the provided argument.
func (cmd *StripCompThresholdCmd) Run(ctx *context, strip *StripCmdGroup) error {
if cmd.Threshold == nil {
resp, err := ctx.Client.Strip.Comp.Threshold(strip.Index.Index)
if err != nil {
return fmt.Errorf("failed to get compressor threshold: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d compressor threshold: %.2f\n", strip.Index.Index, resp)
return nil
}
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,
)
return nil
}
// StripCompRatioCmd defines the command for getting or setting the compressor ratio of a strip, allowing users to specify the amount of gain reduction applied by the compressor once the signal exceeds the threshold.
type StripCompRatioCmd struct {
Ratio *float64 `arg:"" help:"The compressor ratio to set." optional:""`
}
// Run executes the StripCompRatioCmd command, either retrieving the current compressor ratio of the strip or setting it based on the provided argument.
func (cmd *StripCompRatioCmd) Run(ctx *context, strip *StripCmdGroup) error {
if cmd.Ratio == nil {
resp, err := ctx.Client.Strip.Comp.Ratio(strip.Index.Index)
if err != nil {
return fmt.Errorf("failed to get compressor ratio: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d compressor ratio: %.2f\n", strip.Index.Index, resp)
return nil
}
if err := ctx.Client.Strip.Comp.SetRatio(strip.Index.Index, *cmd.Ratio); err != nil {
return fmt.Errorf("failed to set compressor ratio: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d compressor ratio set to: %.2f\n", strip.Index.Index, *cmd.Ratio)
return nil
}
// StripCompMixCmd defines the command for getting or setting the compressor mix of a strip, allowing users to specify the blend between the dry (unprocessed) signal and the wet (compressed) signal, typically expressed as a percentage.
type StripCompMixCmd struct {
Mix *float64 `arg:"" help:"The compressor mix to set (0-100%)." optional:""`
}
// Run executes the StripCompMixCmd command, either retrieving the current compressor mix of the strip or setting it based on the provided argument.
func (cmd *StripCompMixCmd) Run(ctx *context, strip *StripCmdGroup) error {
if cmd.Mix == nil {
resp, err := ctx.Client.Strip.Comp.Mix(strip.Index.Index)
if err != nil {
return fmt.Errorf("failed to get compressor mix: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d compressor mix: %.2f%%\n", strip.Index.Index, resp)
return nil
}
if err := ctx.Client.Strip.Comp.SetMix(strip.Index.Index, *cmd.Mix); err != nil {
return fmt.Errorf("failed to set compressor mix: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d compressor mix set to: %.2f%%\n", strip.Index.Index, *cmd.Mix)
return nil
}
// StripCompMakeupCmd defines the command for getting or setting the compressor makeup gain of a strip, allowing users to specify the amount of gain applied to the signal after compression to compensate for any reduction in level caused by the compressor.
type StripCompMakeupCmd struct {
Makeup *float64 `arg:"" help:"The compressor makeup gain to set (in dB)." optional:""`
}
// Run executes the StripCompMakeupCmd command, either retrieving the current compressor makeup gain of the strip or setting it based on the provided argument.
func (cmd *StripCompMakeupCmd) Run(ctx *context, strip *StripCmdGroup) error {
if cmd.Makeup == nil {
resp, err := ctx.Client.Strip.Comp.Makeup(strip.Index.Index)
if err != nil {
return fmt.Errorf("failed to get compressor makeup gain: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d compressor makeup gain: %.2f\n", strip.Index.Index, resp)
return nil
}
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,
)
return nil
}
// StripCompAttackCmd defines the command for getting or setting the compressor attack time of a strip, allowing users to specify the time it takes for the compressor to start reducing the signal level after the signal exceeds the threshold.
type StripCompAttackCmd struct {
Attack *float64 `arg:"" help:"The compressor attack time to set (in ms)." optional:""`
}
// Run executes the StripCompAttackCmd command, either retrieving the current compressor attack time of the strip or setting it based on the provided argument.
func (cmd *StripCompAttackCmd) Run(ctx *context, strip *StripCmdGroup) error {
if cmd.Attack == nil {
resp, err := ctx.Client.Strip.Comp.Attack(strip.Index.Index)
if err != nil {
return fmt.Errorf("failed to get compressor attack time: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d compressor attack time: %.2f ms\n", strip.Index.Index, resp)
return nil
}
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,
)
return nil
}
// StripCompHoldCmd defines the command for getting or setting the compressor hold time of a strip, allowing users to specify the time that the compressor continues to reduce the signal level after the signal falls below the threshold before it starts to release.
type StripCompHoldCmd struct {
Hold *float64 `arg:"" help:"The compressor hold time to set (in ms)." optional:""`
}
// Run executes the StripCompHoldCmd command, either retrieving the current compressor hold time of the strip or setting it based on the provided argument.
func (cmd *StripCompHoldCmd) Run(ctx *context, strip *StripCmdGroup) error {
if cmd.Hold == nil {
resp, err := ctx.Client.Strip.Comp.Hold(strip.Index.Index)
if err != nil {
return fmt.Errorf("failed to get compressor hold time: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d compressor hold time: %.2f ms\n", strip.Index.Index, resp)
return nil
}
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,
)
return nil
}
// StripCompReleaseCmd defines the command for getting or setting the compressor release time of a strip, allowing users to specify the time it takes for the compressor to stop reducing the signal level after the signal falls below the threshold and the hold time has elapsed.
type StripCompReleaseCmd struct {
Release *float64 `arg:"" help:"The compressor release time to set (in ms)." optional:""`
}
// Run executes the StripCompReleaseCmd command, either retrieving the current compressor release time of the strip or setting it based on the provided argument.
func (cmd *StripCompReleaseCmd) Run(ctx *context, strip *StripCmdGroup) error {
if cmd.Release == nil {
resp, err := ctx.Client.Strip.Comp.Release(strip.Index.Index)
if err != nil {
return fmt.Errorf("failed to get compressor release time: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d compressor release time: %.2f ms\n", strip.Index.Index, resp)
return nil
}
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,
)
return nil
}

23
go.mod
View File

@ -1,34 +1,35 @@
module github.com/onyx-and-iris/xair-cli
go 1.25.0
go 1.25
require (
github.com/alecthomas/kong v1.14.0
github.com/alecthomas/kong v1.13.0
github.com/charmbracelet/log v0.4.2
github.com/hypebeast/go-osc v0.0.0-20220308234300-cec5a8a1e5f5
github.com/jotaen/kong-completion v0.0.12
github.com/jotaen/kong-completion v0.0.11
)
require (
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/colorprofile v0.4.2 // indirect
github.com/charmbracelet/colorprofile v0.4.1 // indirect
github.com/charmbracelet/lipgloss v1.1.0 // indirect
github.com/charmbracelet/x/ansi v0.11.6 // indirect
github.com/charmbracelet/x/cellbuf v0.0.15 // indirect
github.com/charmbracelet/x/ansi v0.11.4 // indirect
github.com/charmbracelet/x/cellbuf v0.0.14 // indirect
github.com/charmbracelet/x/term v0.2.2 // indirect
github.com/clipperhouse/displaywidth v0.11.0 // indirect
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
github.com/clipperhouse/displaywidth v0.9.0 // indirect
github.com/clipperhouse/stringish v0.1.1 // indirect
github.com/clipperhouse/uax29/v2 v2.5.0 // indirect
github.com/go-logfmt/logfmt v0.6.1 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.19 // indirect
github.com/muesli/termenv v0.16.0 // indirect
github.com/posener/complete v1.2.3 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/riywo/loginshell v0.0.0-20200815045211-7d26008be1ab // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/exp v0.0.0-20260218203240-3dfff04db8fa // indirect
golang.org/x/sys v0.41.0 // indirect
golang.org/x/exp v0.0.0-20260112195511-716be5621a96 // indirect
golang.org/x/sys v0.40.0 // indirect
)

42
go.sum
View File

@ -1,27 +1,29 @@
github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0=
github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
github.com/alecthomas/kong v1.14.0 h1:gFgEUZWu2ZmZ+UhyZ1bDhuutbKN1nTtJTwh19Wsn21s=
github.com/alecthomas/kong v1.14.0/go.mod h1:wrlbXem1CWqUV5Vbmss5ISYhsVPkBb1Yo7YKJghju2I=
github.com/alecthomas/kong v1.13.0 h1:5e/7XC3ugvhP1DQBmTS+WuHtCbcv44hsohMgcvVxSrA=
github.com/alecthomas/kong v1.13.0/go.mod h1:wrlbXem1CWqUV5Vbmss5ISYhsVPkBb1Yo7YKJghju2I=
github.com/alecthomas/repr v0.5.2 h1:SU73FTI9D1P5UNtvseffFSGmdNci/O6RsqzeXJtP0Qs=
github.com/alecthomas/repr v0.5.2/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/charmbracelet/colorprofile v0.4.2 h1:BdSNuMjRbotnxHSfxy+PCSa4xAmz7szw70ktAtWRYrY=
github.com/charmbracelet/colorprofile v0.4.2/go.mod h1:0rTi81QpwDElInthtrQ6Ni7cG0sDtwAd4C4le060fT8=
github.com/charmbracelet/colorprofile v0.4.1 h1:a1lO03qTrSIRaK8c3JRxJDZOvhvIeSco3ej+ngLk1kk=
github.com/charmbracelet/colorprofile v0.4.1/go.mod h1:U1d9Dljmdf9DLegaJ0nGZNJvoXAhayhmidOdcBwAvKk=
github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
github.com/charmbracelet/log v0.4.2 h1:hYt8Qj6a8yLnvR+h7MwsJv/XvmBJXiueUcI3cIxsyig=
github.com/charmbracelet/log v0.4.2/go.mod h1:qifHGX/tc7eluv2R6pWIpyHDDrrb/AG71Pf2ysQu5nw=
github.com/charmbracelet/x/ansi v0.11.6 h1:GhV21SiDz/45W9AnV2R61xZMRri5NlLnl6CVF7ihZW8=
github.com/charmbracelet/x/ansi v0.11.6/go.mod h1:2JNYLgQUsyqaiLovhU2Rv/pb8r6ydXKS3NIttu3VGZQ=
github.com/charmbracelet/x/cellbuf v0.0.15 h1:ur3pZy0o6z/R7EylET877CBxaiE1Sp1GMxoFPAIztPI=
github.com/charmbracelet/x/cellbuf v0.0.15/go.mod h1:J1YVbR7MUuEGIFPCaaZ96KDl5NoS0DAWkskup+mOY+Q=
github.com/charmbracelet/x/ansi v0.11.4 h1:6G65PLu6HjmE858CnTUQY1LXT3ZUWwfvqEROLF8vqHI=
github.com/charmbracelet/x/ansi v0.11.4/go.mod h1:/5AZ+UfWExW3int5H5ugnsG/PWjNcSQcwYsHBlPFQN4=
github.com/charmbracelet/x/cellbuf v0.0.14 h1:iUEMryGyFTelKW3THW4+FfPgi4fkmKnnaLOXuc+/Kj4=
github.com/charmbracelet/x/cellbuf v0.0.14/go.mod h1:P447lJl49ywBbil/KjCk2HexGh4tEY9LH0/1QrZZ9rA=
github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk=
github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI=
github.com/clipperhouse/displaywidth v0.11.0 h1:lBc6kY44VFw+TDx4I8opi/EtL9m20WSEFgwIwO+UVM8=
github.com/clipperhouse/displaywidth v0.11.0/go.mod h1:bkrFNkf81G8HyVqmKGxsPufD3JhNl3dSqnGhOoSD/o0=
github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk=
github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
github.com/clipperhouse/displaywidth v0.9.0 h1:Qb4KOhYwRiN3viMv1v/3cTBlz3AcAZX3+y9OLhMtAtA=
github.com/clipperhouse/displaywidth v0.9.0/go.mod h1:aCAAqTlh4GIVkhQnJpbL0T/WfcrJXHcj8C0yjYcjOZA=
github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs=
github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA=
github.com/clipperhouse/uax29/v2 v2.5.0 h1:x7T0T4eTHDONxFJsL94uKNKPHrclyFI0lm7+w94cO8U=
github.com/clipperhouse/uax29/v2 v2.5.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@ -39,14 +41,14 @@ github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUq
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
github.com/hypebeast/go-osc v0.0.0-20220308234300-cec5a8a1e5f5 h1:fqwINudmUrvGCuw+e3tedZ2UJ0hklSw6t8UPomctKyQ=
github.com/hypebeast/go-osc v0.0.0-20220308234300-cec5a8a1e5f5/go.mod h1:lqMjoCs0y0GoRRujSPZRBaGb4c5ER6TfkFKSClxkMbY=
github.com/jotaen/kong-completion v0.0.12 h1:a9jmSaWgkdAUMQT583UxLIJrO9tfdSmYqcIxrBByjPc=
github.com/jotaen/kong-completion v0.0.12/go.mod h1:dyIG20e3qq128SUBtF8jzI7YtkfzjWMlgbqkAJd6xHQ=
github.com/jotaen/kong-completion v0.0.11 h1:ZRyQt+IwjcAObbiyxJZ3YR7r/o/f6HYidTK1+7YNtnE=
github.com/jotaen/kong-completion v0.0.11/go.mod h1:dyIG20e3qq128SUBtF8jzI7YtkfzjWMlgbqkAJd6xHQ=
github.com/lucasb-eyer/go-colorful v1.3.0 h1:2/yBRLdWBZKrf7gB40FoiKfAWYQ0lqNcbuQwVHXptag=
github.com/lucasb-eyer/go-colorful v1.3.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.20 h1:WcT52H91ZUAwy8+HUkdM3THM6gXqXuLJi9O3rjcQQaQ=
github.com/mattn/go-runewidth v0.0.20/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw=
github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@ -63,11 +65,11 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
golang.org/x/exp v0.0.0-20260218203240-3dfff04db8fa h1:Zt3DZoOFFYkKhDT3v7Lm9FDMEV06GpzjG2jrqW+QTE0=
golang.org/x/exp v0.0.0-20260218203240-3dfff04db8fa/go.mod h1:K79w1Vqn7PoiZn+TkNpx3BUWUQksGO3JcVX6qIjytmA=
golang.org/x/exp v0.0.0-20260112195511-716be5621a96 h1:Z/6YuSHTLOHfNFdb8zVZomZr7cqNgTJvA8+Qz75D8gU=
golang.org/x/exp v0.0.0-20260112195511-716be5621a96/go.mod h1:nzimsREAkjBCIEFtHiYkrJyT+2uy9YZJB7H1k68CXZU=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

View File

@ -38,20 +38,14 @@ 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,
@ -102,14 +96,14 @@ 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 normalises it to "true" or "false".
// Validate checks if the provided phantom power state is valid and normalizes it to "true" or "false".
func (cmd *HeadampPhantomCmd) Validate() error {
if cmd.State != nil {
switch *cmd.State {
case trueStr, "on":
*cmd.State = trueStr
case falseStr, "off":
*cmd.State = falseStr
case "true", "on":
*cmd.State = "true"
case "false", "off":
*cmd.State = "false"
default:
return fmt.Errorf("invalid phantom power state: %s", *cmd.State)
}
@ -128,10 +122,7 @@ func (cmd *HeadampPhantomCmd) Run(ctx *context, headamp *HeadampCmdGroup) error
return nil
}
if err := ctx.Client.HeadAmp.SetPhantomPower(
headamp.Index.Index,
*cmd.State == trueStr,
); 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

@ -3,26 +3,23 @@ package xair
var xairAddressMap = map[string]string{
"main": "/lr",
"strip": "/ch/%02d",
"bus": "/bus/%d",
"bus": "/bus/%01d",
"headamp": "/headamp/%02d",
"snapshot": "/-snap",
"dca": "/dca/%d",
}
var x32AddressMap = map[string]string{
"main": "/main/st",
"mainmono": "/main/m",
"matrix": "/mtx/%02d",
"mainmono": "/main/mono",
"strip": "/ch/%02d",
"bus": "/bus/%02d",
"headamp": "/headamp/%03d",
"snapshot": "/-snap",
"dca": "/dca/%d",
}
func addressMapFromMixerKind(kind mixerKind) map[string]string {
func addressMapForMixerKind(kind MixerKind) map[string]string {
switch kind {
case kindX32:
case KindX32:
return x32AddressMap
default:
return xairAddressMap

View File

@ -2,25 +2,23 @@ package xair
import "fmt"
// Bus represents the bus parameters of the mixer.
type Bus struct {
client *client
client *Client
baseAddress string
Eq *Eq
Comp *Comp
}
// newBus creates a new Bus instance.
func newBus(c *client) *Bus {
func newBus(c *Client) *Bus {
return &Bus{
client: c,
baseAddress: c.addressMap["bus"],
Eq: newEq(c, c.addressMap["bus"]),
Comp: newComp(c, c.addressMap["bus"]),
Eq: newEqForBus(c),
Comp: newCompForBus(c),
}
}
// 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)
@ -39,7 +37,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
@ -49,7 +47,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)
@ -69,18 +67,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: %w", err)
return "", fmt.Errorf("failed to send bus name request: %v", err)
}
msg, err := b.client.ReceiveMessage()
@ -94,7 +92,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

@ -1,110 +1,93 @@
// Package xair provides a client for controlling XAir and X32 mixers using OSC messages.
package xair
import (
"fmt"
"net"
"time"
"github.com/charmbracelet/log"
"github.com/hypebeast/go-osc/osc"
)
// XAirClient is a client for controlling XAir mixers.
type XAirClient struct { // nolint: revive
client
type Client struct {
engine
Main *Main
Strip *Strip
Bus *Bus
HeadAmp *HeadAmp
Snapshot *Snapshot
DCA *DCA
}
// NewXAirClient creates a new XAirClient instance with optional engine configuration.
func NewXAirClient(mixerIP string, mixerPort int, opts ...EngineOption) (*XAirClient, error) {
e, err := newEngine(mixerIP, mixerPort, kindXAir, opts...)
// NewClient creates a new XAirClient instance
func NewClient(mixerIP string, mixerPort int, opts ...Option) (*Client, error) {
localAddr, err := net.ResolveUDPAddr("udp", fmt.Sprintf(":%d", 0))
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to resolve local address: %v", err)
}
c := &XAirClient{
client: client{e, InfoResponse{}},
conn, err := net.ListenUDP("udp", localAddr)
if err != nil {
return nil, fmt.Errorf("failed to create UDP connection: %v", err)
}
c.Main = newMainStereo(&c.client)
c.Strip = newStrip(&c.client)
c.Bus = newBus(&c.client)
c.HeadAmp = newHeadAmp(&c.client)
c.Snapshot = newSnapshot(&c.client)
c.DCA = newDCA(&c.client)
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{
Kind: KindXAir,
timeout: 100 * time.Millisecond,
conn: conn,
mixerAddr: mixerAddr,
parser: newParser(),
addressMap: addressMapForMixerKind(KindXAir),
done: make(chan bool),
respChan: make(chan *osc.Message, 100),
}
for _, opt := range opts {
opt(e)
}
c := &Client{
engine: *e,
}
c.Main = newMainStereo(c)
c.Strip = newStrip(c)
c.Bus = newBus(c)
c.HeadAmp = newHeadAmp(c)
c.Snapshot = newSnapshot(c)
return c, nil
}
// X32Client is a client for controlling X32 mixers.
type X32Client struct { // nolint: revive
client
Main *Main
MainMono *Main
Matrix *Matrix
Strip *Strip
Bus *Bus
HeadAmp *HeadAmp
Snapshot *Snapshot
DCA *DCA
}
// 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, InfoResponse{}},
}
c.Main = newMainStereo(&c.client)
c.MainMono = newMainMono(&c.client)
c.Matrix = newMatrix(&c.client)
c.Strip = newStrip(&c.client)
c.Bus = newBus(&c.client)
c.HeadAmp = newHeadAmp(&c.client)
c.Snapshot = newSnapshot(&c.client)
c.DCA = newDCA(&c.client)
return c, nil
}
type client struct {
*engine
Info InfoResponse
}
// StartListening begins listening for messages in a goroutine.
func (c *client) StartListening() {
go c.receiveLoop()
// Start begins listening for messages in a goroutine
func (c *Client) StartListening() {
go c.engine.receiveLoop()
log.Debugf("Started listening on %s...", c.engine.conn.LocalAddr().String())
}
// Close stops the client and closes the connection.
func (c *client) Close() error {
close(c.done)
if c.conn != nil {
if err := c.conn.Close(); err != nil {
return fmt.Errorf("failed to close connection: %w", err)
// 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()
}
}
return nil
}
// SendMessage sends an OSC message to the mixer using the unified connection.
func (c *client) SendMessage(address string, args ...any) error {
return c.sendToAddress(c.mixerAddr, address, args...)
// 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...)
}
// ReceiveMessage receives an OSC message from the mixer.
func (c *client) ReceiveMessage() (*osc.Message, error) {
t := time.Tick(c.timeout)
// ReceiveMessage receives an OSC message from the mixer
func (c *Client) ReceiveMessage() (*osc.Message, error) {
t := time.Tick(c.engine.timeout)
select {
case <-t:
return nil, fmt.Errorf("timeout waiting for response")
@ -116,8 +99,8 @@ func (c *client) ReceiveMessage() (*osc.Message, error) {
}
}
// RequestInfo requests mixer information.
func (c *client) RequestInfo() (InfoResponse, error) {
// RequestInfo requests mixer information
func (c *Client) RequestInfo() (InfoResponse, error) {
var info InfoResponse
err := c.SendMessage("/xinfo")
if err != nil {
@ -128,31 +111,20 @@ func (c *client) RequestInfo() (InfoResponse, error) {
if err != nil {
return info, err
}
if len(msg.Arguments) == 4 {
if host, ok := msg.Arguments[0].(string); ok {
info.Host = host
if len(msg.Arguments) >= 3 {
info.Host = msg.Arguments[0].(string)
info.Name = msg.Arguments[1].(string)
info.Model = msg.Arguments[2].(string)
}
if name, ok := msg.Arguments[1].(string); ok {
info.Name = name
}
if model, ok := msg.Arguments[2].(string); ok {
info.Model = model
}
if firmware, ok := msg.Arguments[3].(string); ok {
info.Firmware = firmware
}
}
c.Info = info
return info, nil
}
// KeepAlive sends keep-alive message (required for multi-client usage).
func (c *client) KeepAlive() error {
// KeepAlive sends keep-alive message (required for multi-client usage)
func (c *Client) KeepAlive() error {
return c.SendMessage("/xremote")
}
// RequestStatus requests mixer status.
func (c *client) RequestStatus() error {
// RequestStatus requests mixer status
func (c *Client) RequestStatus() error {
return c.SendMessage("/status")
}

View File

@ -2,31 +2,48 @@ package xair
import "fmt"
// Comp represents the compressor parameters.
type Comp struct {
client *client
client *Client
baseAddress string
AddressFunc func(fmtString string, args ...any) string
}
// Factory function to create Comp instance with optional configuration.
func newComp(c *client, baseAddress string, opts ...CompOption) *Comp {
comp := &Comp{
// Factory function to create Comp instance for Main
func newCompForMain(c *Client) *Comp {
return &Comp{
client: c,
baseAddress: fmt.Sprintf("%s/dyn", baseAddress),
AddressFunc: fmt.Sprintf,
baseAddress: c.addressMap["main"],
AddressFunc: func(fmtString string, args ...any) string {
return fmtString
},
}
}
for _, opt := range opts {
opt(comp)
// Factory function to create Comp instance for Strip
func newCompForStrip(c *Client) *Comp {
return &Comp{
client: c,
baseAddress: c.addressMap["strip"],
AddressFunc: func(fmtString string, args ...any) string {
return fmt.Sprintf(fmtString, args...)
},
}
}
return comp
// Factory function to create Comp instance for Bus
func newCompForBus(c *Client) *Comp {
return &Comp{
client: c,
baseAddress: c.addressMap["bus"],
AddressFunc: func(fmtString string, args ...any) string {
return fmt.Sprintf(fmtString, args...)
},
}
}
// 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) + "/on"
address := c.AddressFunc(c.baseAddress, index) + "/dyn/on"
err := c.client.SendMessage(address)
if err != nil {
return false, err
@ -45,7 +62,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) + "/on"
address := c.AddressFunc(c.baseAddress, index) + "/dyn/on"
var value int32
if on {
value = 1
@ -55,7 +72,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) + "/mode"
address := c.AddressFunc(c.baseAddress, index) + "/dyn/mode"
err := c.client.SendMessage(address)
if err != nil {
return "", err
@ -76,14 +93,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) + "/mode"
address := c.AddressFunc(c.baseAddress, index) + "/dyn/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) + "/thr"
address := c.AddressFunc(c.baseAddress, index) + "/dyn/thr"
err := c.client.SendMessage(address)
if err != nil {
return 0, err
@ -102,13 +119,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) + "/thr"
address := c.AddressFunc(c.baseAddress, index) + "/dyn/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) + "/ratio"
address := c.AddressFunc(c.baseAddress, index) + "/dyn/ratio"
err := c.client.SendMessage(address)
if err != nil {
return 0, err
@ -130,7 +147,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) + "/ratio"
address := c.AddressFunc(c.baseAddress, index) + "/dyn/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))))
@ -138,7 +155,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) + "/attack"
address := c.AddressFunc(c.baseAddress, index) + "/dyn/attack"
err := c.client.SendMessage(address)
if err != nil {
return 0, err
@ -157,13 +174,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) + "/attack"
address := c.AddressFunc(c.baseAddress, index) + "/dyn/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) + "/hold"
address := c.AddressFunc(c.baseAddress, index) + "/dyn/hold"
err := c.client.SendMessage(address)
if err != nil {
return 0, err
@ -182,13 +199,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) + "/hold"
address := c.AddressFunc(c.baseAddress, index) + "/dyn/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) + "/release"
address := c.AddressFunc(c.baseAddress, index) + "/dyn/release"
err := c.client.SendMessage(address)
if err != nil {
return 0, err
@ -207,13 +224,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) + "/release"
address := c.AddressFunc(c.baseAddress, index) + "/dyn/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) + "/mgain"
address := c.AddressFunc(c.baseAddress, index) + "/dyn/mgain"
err := c.client.SendMessage(address)
if err != nil {
return 0, err
@ -232,13 +249,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) + "/mgain"
address := c.AddressFunc(c.baseAddress, index) + "/dyn/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) + "/mix"
address := c.AddressFunc(c.baseAddress, index) + "/dyn/mix"
err := c.client.SendMessage(address)
if err != nil {
return 0, err
@ -257,6 +274,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) + "/mix"
address := c.AddressFunc(c.baseAddress, index) + "/dyn/mix"
return c.client.SendMessage(address, float32(linSet(0, 100, mix)))
}

View File

@ -1,96 +0,0 @@
package xair
import "fmt"
// DCA represents the DCA group parameters of the mixer.
type DCA struct {
client *client
baseAddress string
}
// newDCA creates a new DCA instance.
func newDCA(c *client) *DCA {
return &DCA{
client: c,
baseAddress: c.addressMap["dca"],
}
}
// Mute requests the current mute status for a DCA group.
func (d *DCA) Mute(group int) (bool, error) {
address := fmt.Sprintf(d.baseAddress, group) + "/on"
err := d.client.SendMessage(address)
if err != nil {
return false, err
}
msg, err := d.client.ReceiveMessage()
if err != nil {
return false, err
}
val, ok := msg.Arguments[0].(int32)
if !ok {
return false, fmt.Errorf("unexpected argument type for DCA mute value")
}
return val == 0, nil
}
// SetMute sets the mute status for a specific DCA group (1-based indexing).
func (d *DCA) SetMute(group int, muted bool) error {
address := fmt.Sprintf(d.baseAddress, group) + "/on"
var value int32
if !muted {
value = 1
}
return d.client.SendMessage(address, value)
}
// Name requests the current name for a DCA group.
func (d *DCA) Name(group int) (string, error) {
address := fmt.Sprintf(d.baseAddress, group) + "/config/name"
err := d.client.SendMessage(address)
if err != nil {
return "", err
}
msg, err := d.client.ReceiveMessage()
if err != nil {
return "", err
}
name, ok := msg.Arguments[0].(string)
if !ok {
return "", fmt.Errorf("unexpected argument type for DCA name value")
}
return name, nil
}
// SetName sets the name for a specific DCA group (1-based indexing).
func (d *DCA) SetName(group int, name string) error {
address := fmt.Sprintf(d.baseAddress, group) + "/config/name"
return d.client.SendMessage(address, name)
}
// 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
}
msg, err := d.client.ReceiveMessage()
if err != nil {
return 0, err
}
colour, ok := msg.Arguments[0].(int32)
if !ok {
return 0, fmt.Errorf("unexpected argument type for DCA colour value")
}
return colour, nil
}
// 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,7 +1,6 @@
package xair
import (
"errors"
"fmt"
"net"
"time"
@ -15,7 +14,7 @@ type parser interface {
}
type engine struct {
Kind mixerKind
Kind MixerKind
timeout time.Duration
conn *net.UDPConn
mixerAddr *net.UDPAddr
@ -27,50 +26,7 @@ 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: %w", err)
}
conn, err := net.ListenUDP("udp", localAddr)
if err != nil {
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 {
if err := conn.Close(); err != nil {
log.Errorf("failed to close UDP connection: %v", err)
}
return nil, fmt.Errorf("failed to resolve mixer address: %w", 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.
// receiveLoop handles incoming OSC messages
func (e *engine) receiveLoop() {
buffer := make([]byte, 4096)
@ -80,14 +36,10 @@ func (e *engine) receiveLoop() {
return
default:
// Set a short read deadline to prevent blocking indefinitely
if err := e.conn.SetReadDeadline(time.Now().Add(100 * time.Millisecond)); err != nil {
log.Errorf("Failed to set read deadline: %v", err)
continue
}
e.conn.SetReadDeadline(time.Now().Add(100 * time.Millisecond))
n, _, err := e.conn.ReadFromUDP(buffer)
if err != nil {
var netErr net.Error
if errors.As(err, &netErr) {
if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
// Timeout is expected, continue loop
continue
}
@ -111,7 +63,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 {
@ -121,7 +73,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 {
@ -142,7 +94,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: %w", err)
return fmt.Errorf("failed to marshal message: %v", err)
}
_, err = e.conn.WriteToUDP(data, addr)

View File

@ -4,31 +4,48 @@ import (
"fmt"
)
// Eq represents the EQ parameters.
type Eq struct {
client *client
client *Client
baseAddress string
AddressFunc func(fmtString string, args ...any) string
}
// Factory function to create Eq instance with optional configuration.
func newEq(c *client, baseAddress string, opts ...EqOption) *Eq {
eq := &Eq{
// Factory function to create Eq instance for Main
func newEqForMain(c *Client) *Eq {
return &Eq{
client: c,
baseAddress: fmt.Sprintf("%s/eq", baseAddress),
AddressFunc: fmt.Sprintf,
baseAddress: c.addressMap["main"],
AddressFunc: func(fmtString string, args ...any) string {
return fmtString
},
}
}
for _, opt := range opts {
opt(eq)
// Factory function to create Eq instance for Strip
func newEqForStrip(c *Client) *Eq {
return &Eq{
client: c,
baseAddress: c.addressMap["strip"],
AddressFunc: func(fmtString string, args ...any) string {
return fmt.Sprintf(fmtString, args...)
},
}
}
return eq
// Factory function to create Eq instance for Bus
func newEqForBus(c *Client) *Eq {
return &Eq{
client: c,
baseAddress: c.addressMap["bus"],
AddressFunc: func(fmtString string, args ...any) string {
return fmt.Sprintf(fmtString, args...)
},
}
}
// 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) + "/on"
address := e.AddressFunc(e.baseAddress, index) + "/eq/on"
err := e.client.SendMessage(address)
if err != nil {
return false, err
@ -47,7 +64,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) + "/on"
address := e.AddressFunc(e.baseAddress, index) + "/eq/on"
var value int32
if on {
value = 1
@ -55,9 +72,8 @@ func (e *Eq) SetOn(index int, on bool) error {
return e.client.SendMessage(address, value)
}
// Mode retrieves the EQ mode for a specific strip or bus (1-based indexing).
func (e *Eq) Mode(index int) (string, error) {
address := e.AddressFunc(e.baseAddress, index) + "/mode"
address := e.AddressFunc(e.baseAddress, index) + "/eq/mode"
err := e.client.SendMessage(address)
if err != nil {
return "", err
@ -76,16 +92,15 @@ func (e *Eq) Mode(index int) (string, error) {
return possibleModes[val], nil
}
// SetMode sets the EQ mode for a specific strip or bus (1-based indexing).
func (e *Eq) SetMode(index int, mode string) error {
address := e.AddressFunc(e.baseAddress, index) + "/mode"
address := e.AddressFunc(e.baseAddress, index) + "/eq/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, band int) (float64, error) {
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/g", band)
func (e *Eq) Gain(index int, band int) (float64, error) {
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/g", band)
err := e.client.SendMessage(address)
if err != nil {
return 0, err
@ -103,14 +118,14 @@ func (e *Eq) Gain(index, 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, band int, gain float64) error {
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/g", band)
func (e *Eq) SetGain(index int, band int, gain float64) error {
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%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, band int) (float64, error) {
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/f", band)
func (e *Eq) Frequency(index int, band int) (float64, error) {
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/f", band)
err := e.client.SendMessage(address)
if err != nil {
return 0, err
@ -128,14 +143,14 @@ func (e *Eq) Frequency(index, 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, band int, frequency float64) error {
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/f", band)
func (e *Eq) SetFrequency(index int, band int, frequency float64) error {
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%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, band int) (float64, error) {
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/q", band)
func (e *Eq) Q(index int, band int) (float64, error) {
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/q", band)
err := e.client.SendMessage(address)
if err != nil {
return 0, err
@ -153,14 +168,14 @@ func (e *Eq) Q(index, 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, band int, q float64) error {
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/q", band)
func (e *Eq) SetQ(index int, band int, q float64) error {
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%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, band int) (string, error) {
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/type", band)
func (e *Eq) Type(index int, band int) (string, error) {
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/type", band)
err := e.client.SendMessage(address)
if err != nil {
return "", err
@ -180,8 +195,8 @@ func (e *Eq) Type(index, 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, band int, eqType string) error {
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/%d/type", band)
func (e *Eq) SetType(index int, band int, eqType string) error {
address := e.AddressFunc(e.baseAddress, index) + fmt.Sprintf("/eq/%d/type", band)
possibleTypes := []string{"lcut", "lshv", "peq", "veq", "hshv", "hcut"}
return e.client.SendMessage(address, int32(indexOf(possibleTypes, eqType)))
}

View File

@ -2,31 +2,22 @@ package xair
import "fmt"
// Gate represents the gate parameters.
type Gate struct {
client *client
client *Client
baseAddress string
AddressFunc func(fmtString string, args ...any) string
}
// Factory function to create Gate instance with optional configuration.
func newGate(c *client, baseAddress string, opts ...GateOption) *Gate {
gate := &Gate{
// Factory function to create Gate instance for Strip
func newGateForStrip(c *Client) *Gate {
return &Gate{
client: c,
baseAddress: fmt.Sprintf("%s/gate", baseAddress),
AddressFunc: fmt.Sprintf,
baseAddress: c.addressMap["strip"],
}
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 := g.AddressFunc(g.baseAddress, index) + "/on"
address := fmt.Sprintf(g.baseAddress, index) + "/gate/on"
err := g.client.SendMessage(address)
if err != nil {
return false, err
@ -45,7 +36,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 := g.AddressFunc(g.baseAddress, index) + "/on"
address := fmt.Sprintf(g.baseAddress, index) + "/gate/on"
var value int32
if on {
value = 1
@ -55,7 +46,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 := g.AddressFunc(g.baseAddress, index) + "/mode"
address := fmt.Sprintf(g.baseAddress, index) + "/gate/mode"
err := g.client.SendMessage(address)
if err != nil {
return "", err
@ -76,7 +67,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 := g.AddressFunc(g.baseAddress, index) + "/mode"
address := fmt.Sprintf(g.baseAddress, index) + "/gate/mode"
possibleModes := []string{"exp2", "exp3", "exp4", "gate", "duck"}
return g.client.SendMessage(address, int32(indexOf(possibleModes, mode)))
@ -84,7 +75,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 := g.AddressFunc(g.baseAddress, index) + "/thr"
address := fmt.Sprintf(g.baseAddress, index) + "/gate/thr"
err := g.client.SendMessage(address)
if err != nil {
return 0, err
@ -103,13 +94,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 := g.AddressFunc(g.baseAddress, index) + "/thr"
address := fmt.Sprintf(g.baseAddress, index) + "/gate/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 := g.AddressFunc(g.baseAddress, index) + "/range"
address := fmt.Sprintf(g.baseAddress, index) + "/gate/range"
err := g.client.SendMessage(address)
if err != nil {
return 0, err
@ -128,13 +119,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 := g.AddressFunc(g.baseAddress, index) + "/range"
address := fmt.Sprintf(g.baseAddress, index) + "/gate/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 := g.AddressFunc(g.baseAddress, index) + "/attack"
address := fmt.Sprintf(g.baseAddress, index) + "/gate/attack"
err := g.client.SendMessage(address)
if err != nil {
return 0, err
@ -153,13 +144,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 := g.AddressFunc(g.baseAddress, index) + "/attack"
address := fmt.Sprintf(g.baseAddress, index) + "/gate/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 := g.AddressFunc(g.baseAddress, index) + "/hold"
address := fmt.Sprintf(g.baseAddress, index) + "/gate/hold"
err := g.client.SendMessage(address)
if err != nil {
return 0, err
@ -178,13 +169,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 := g.AddressFunc(g.baseAddress, index) + "/hold"
address := fmt.Sprintf(g.baseAddress, index) + "/gate/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 := g.AddressFunc(g.baseAddress, index) + "/release"
address := fmt.Sprintf(g.baseAddress, index) + "/gate/release"
err := g.client.SendMessage(address)
if err != nil {
return 0, err
@ -203,6 +194,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 := g.AddressFunc(g.baseAddress, index) + "/release"
address := fmt.Sprintf(g.baseAddress, index) + "/gate/release"
return g.client.SendMessage(address, float32(logSet(5, 4000, release)))
}

View File

@ -2,14 +2,13 @@ package xair
import "fmt"
// HeadAmp represents the headphone amplifier parameters of the mixer.
type HeadAmp struct {
client *client
client *Client
baseAddress string
}
// newHeadAmp creates a new HeadAmp instance with the provided client.
func newHeadAmp(c *client) *HeadAmp {
func newHeadAmp(c *Client) *HeadAmp {
return &HeadAmp{
client: c,
baseAddress: c.addressMap["headamp"],

View File

@ -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"
)

View File

@ -2,43 +2,32 @@ package xair
import "fmt"
// Main represents the main output parameters of the mixer.
type Main struct {
client *client
client *Client
baseAddress string
Eq *Eq
Comp *Comp
}
// newMainStereo creates a new Main instance for stereo main output.
func newMainStereo(c *client) *Main {
addressFunc := func(fmtString string, _ ...any) string {
return fmtString
}
func newMainStereo(c *Client) *Main {
return &Main{
client: c,
baseAddress: c.addressMap["main"],
Eq: newEq(c, c.addressMap["main"], WithEqAddressFunc(addressFunc)),
Comp: newComp(c, c.addressMap["main"], WithCompAddressFunc(addressFunc)),
Eq: newEqForMain(c),
Comp: newCompForMain(c),
}
}
// newMainMono creates a new MainMono instance for mono main output (X32 only).
func newMainMono(c *client) *Main {
addressFunc := func(fmtString string, _ ...any) string {
return fmtString
}
/* Still considering the best way to implement main mono support.
func newMainMono(c *Client) *Main {
return &Main{
baseAddress: c.addressMap["mainmono"],
client: c,
Eq: newEq(c, c.addressMap["mainmono"], WithEqAddressFunc(addressFunc)),
Comp: newComp(c, c.addressMap["mainmono"], WithCompAddressFunc(addressFunc)),
}
}
*/
// 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)
@ -57,13 +46,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)
@ -82,7 +71,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

@ -1,75 +0,0 @@
package xair
import "fmt"
// Matrix represents the matrix parameters of the mixer.
type Matrix struct {
client *client
baseAddress string
Eq *Eq
Comp *Comp
}
// newMatrix creates a new Matrix instance.
func newMatrix(c *client) *Matrix {
return &Matrix{
client: c,
baseAddress: c.addressMap["matrix"],
Eq: newEq(c, c.addressMap["matrix"]),
Comp: newComp(c, c.addressMap["matrix"]),
}
}
// 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)
if err != nil {
return 0, err
}
msg, err := m.client.ReceiveMessage()
if err != nil {
return 0, err
}
val, ok := msg.Arguments[0].(float32)
if !ok {
return 0, fmt.Errorf("unexpected argument type for matrix fader value")
}
return mustDbFrom(float64(val)), nil
}
// 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.
func (m *Matrix) Mute(index int) (bool, error) {
address := fmt.Sprintf(m.baseAddress, index) + "/mix/on"
err := m.client.SendMessage(address)
if err != nil {
return false, err
}
msg, err := m.client.ReceiveMessage()
if err != nil {
return false, err
}
val, ok := msg.Arguments[0].(int32)
if !ok {
return false, fmt.Errorf("unexpected argument type for matrix mute value")
}
return val == 0, nil
}
// 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
if !muted {
value = 1
}
return m.client.SendMessage(address, value)
}

View File

@ -1,9 +1,7 @@
package xair
// InfoResponse represents the response from the /info OSC address, containing details about the X-Air device.
type InfoResponse struct {
Host string
Name string
Model string
Firmware string
}

View File

@ -2,42 +2,17 @@ package xair
import "time"
// EngineOption defines a functional option for configuring the engine.
type EngineOption func(*engine)
type Option func(*engine)
// WithTimeout sets the timeout duration for OSC message responses.
func WithTimeout(timeout time.Duration) EngineOption {
func WithKind(kind string) Option {
return func(e *engine) {
e.Kind = MixerKind(kind)
e.addressMap = addressMapForMixerKind(e.Kind)
}
}
func WithTimeout(timeout time.Duration) Option {
return func(e *engine) {
e.timeout = timeout
}
}
// CompOption defines a functional option for configuring Comp parameters.
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
}
}
// EqOption defines a functional option for configuring Eq parameters.
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
}
}
// GateOption defines a functional option for configuring Gate parameters.
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
}
}

View File

@ -10,13 +10,14 @@ import (
"github.com/hypebeast/go-osc/osc"
)
type xairParser struct{}
type xairParser struct {
}
func newParser() *xairParser {
return &xairParser{}
}
// Parse 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 ===")
@ -46,7 +47,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")
@ -57,7 +58,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 {
@ -72,11 +73,8 @@ 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) { // nolint: unparam
// 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
}
@ -99,13 +97,8 @@ func (p *xairParser) extractOSCTypeTags(
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 { // nolint: unparam
// 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
@ -145,7 +138,7 @@ func (p *xairParser) parseOSCArguments(
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 {
@ -160,7 +153,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")
@ -173,7 +166,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")
@ -186,7 +179,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")
@ -210,7 +203,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

@ -2,14 +2,12 @@ package xair
import "fmt"
// Snapshot represents a snapshot of the mixer's state, allowing for saving and recalling settings.
type Snapshot struct {
client *client
client *Client
baseAddress string
}
// newSnapshot creates a new Snapshot instance.
func newSnapshot(c *client) *Snapshot {
func newSnapshot(c *Client) *Snapshot {
return &Snapshot{
client: c,
baseAddress: c.addressMap["snapshot"],

View File

@ -2,23 +2,21 @@ package xair
import "fmt"
// Strip represents an input channel strip on the mixer.
type Strip struct {
client *client
client *Client
baseAddress string
Gate *Gate
Eq *Eq
Comp *Comp
}
// newStrip creates a new Strip instance.
func newStrip(c *client) *Strip {
func newStrip(c *Client) *Strip {
return &Strip{
client: c,
baseAddress: c.addressMap["strip"],
Gate: newGate(c, c.addressMap["strip"]),
Eq: newEq(c, c.addressMap["strip"]),
Comp: newComp(c, c.addressMap["strip"]),
Gate: newGateForStrip(c),
Eq: newEqForStrip(c),
Comp: newCompForStrip(c),
}
}
@ -44,7 +42,7 @@ func (s *Strip) Mute(index int) (bool, error) {
// SetMute sets the mute status of the specified strip (1-based indexing).
func (s *Strip) SetMute(strip int, muted bool) error {
address := fmt.Sprintf(s.baseAddress, strip) + "/mix/on"
var value int32
var value int32 = 0
if !muted {
value = 1
}
@ -77,12 +75,12 @@ func (s *Strip) SetFader(strip int, level float64) error {
return s.client.SendMessage(address, float32(mustDbInto(level)))
}
// Name requests the name for a specific strip.
// Name requests the name for a specific strip
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: %w", err)
return "", fmt.Errorf("failed to send strip name request: %v", err)
}
msg, err := s.client.ReceiveMessage()
@ -96,18 +94,18 @@ func (s *Strip) Name(strip int) (string, error) {
return val, nil
}
// SetName sets the name for a specific strip.
// SetName sets the name for a specific strip
func (s *Strip) SetName(strip int, name string) error {
address := fmt.Sprintf(s.baseAddress, strip) + "/config/name"
return s.client.SendMessage(address, name)
}
// Colour requests the colour for a specific strip.
func (s *Strip) Colour(strip int) (int32, error) {
address := fmt.Sprintf(s.baseAddress, strip) + "/config/colour"
// Color requests the color for a specific strip
func (s *Strip) Color(strip int) (int32, error) {
address := fmt.Sprintf(s.baseAddress, strip) + "/config/color"
err := s.client.SendMessage(address)
if err != nil {
return 0, fmt.Errorf("failed to send strip colour request: %w", err)
return 0, fmt.Errorf("failed to send strip color request: %v", err)
}
msg, err := s.client.ReceiveMessage()
@ -116,23 +114,23 @@ func (s *Strip) Colour(strip int) (int32, error) {
}
val, ok := msg.Arguments[0].(int32)
if !ok {
return 0, fmt.Errorf("unexpected argument type for strip colour value")
return 0, fmt.Errorf("unexpected argument type for strip color value")
}
return val, nil
}
// 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)
// 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)
}
// SendLevel requests auxiliary send level for a send destination.
func (s *Strip) SendLevel(strip, bus int) (float64, error) {
// Sends requests the sends level for a mixbus.
func (s *Strip) SendLevel(strip int, 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: %w", err)
return 0, fmt.Errorf("failed to send strip send level request: %v", err)
}
msg, err := s.client.ReceiveMessage()
@ -146,8 +144,8 @@ func (s *Strip) SendLevel(strip, bus int) (float64, error) {
return mustDbFrom(float64(val)), nil
}
// SetSendLevel sets the auxiliary send level for a send destination.
func (s *Strip) SetSendLevel(strip, bus int, level float64) error {
// SetSendLevel sets the sends level for a mixbus.
func (s *Strip) SetSendLevel(strip int, 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,20 +2,20 @@ package xair
import "math"
func linGet(minVal, maxVal, value float64) float64 {
return minVal + (maxVal-minVal)*value
func linGet(min float64, max float64, value float64) float64 {
return min + (max-min)*value
}
func linSet(minVal, maxVal, value float64) float64 {
return (value - minVal) / (maxVal - minVal)
func linSet(min float64, max float64, value float64) float64 {
return (value - min) / (max - min)
}
func logGet(minVal, maxVal, value float64) float64 {
return minVal * math.Exp(math.Log(maxVal/minVal)*value)
func logGet(min float64, max float64, value float64) float64 {
return min * math.Exp(math.Log(max/min)*value)
}
func logSet(minVal, maxVal, value float64) float64 {
return math.Log(value/minVal) / math.Log(maxVal/minVal)
func logSet(min float64, max float64, value float64) float64 {
return math.Log(value/min) / math.Log(max/min)
}
func mustDbInto(db float64) float64 {
@ -52,7 +52,7 @@ func mustDbFrom(level float64) float64 {
}
}
func toFixed(num float64, precision int) float64 { // nolint: unparam
func toFixed(num float64, precision int) float64 {
output := math.Pow(10, float64(precision))
return float64(math.Round(num*output)) / output
}

View File

@ -1,9 +1,10 @@
// Package main implements the command-line interface for controlling an X32 digital mixer.
package main
import (
"fmt"
"time"
"github.com/alecthomas/kong"
)
// MainCmdGroup defines the command group for controlling the Main L/R output, including commands for mute state, fader level, and fade-in/fade-out times.
@ -14,13 +15,13 @@ 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 equaliser settings of the Main L/R output." cmd:"eq"`
Eq MainEqCmdGroup `help:"Commands for controlling the equalizer 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"`
}
// MainMuteCmd defines the command for getting or setting the mute state of the Main L/R output, allowing users to specify the desired state as "true"/"on" or "false"/"off".
type MainMuteCmd struct {
Mute *string `arg:"" help:"The mute state to set. If not provided, the current state will be printed." optional:"" enum:"true,false"`
Mute *bool `arg:"" help:"The mute state to set. If not provided, the current state will be printed." optional:""`
}
// Run executes the MainMuteCmd command, either retrieving the current mute state of the Main L/R output or setting it based on the provided argument.
@ -34,10 +35,10 @@ func (cmd *MainMuteCmd) Run(ctx *context) error {
return nil
}
if err := ctx.Client.Main.SetMute(*cmd.Mute == trueStr); err != nil {
if err := ctx.Client.Main.SetMute(*cmd.Mute); err != nil {
return fmt.Errorf("failed to set Main L/R mute state: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R mute state set to: %s\n", *cmd.Mute)
fmt.Fprintf(ctx.Out, "Main L/R mute state set to: %t\n", *cmd.Mute)
return nil
}
@ -132,11 +133,11 @@ func (cmd *MainFadeoutCmd) Run(ctx *context) error {
return nil
}
// 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.
// 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.
type MainEqCmdGroup struct {
On MainEqOnCmd `help:"Get or set the EQ on/off state of the Main L/R output." cmd:"on"`
Band struct {
Band *int `arg:"" help:"The EQ band number." optional:""`
Band int `arg:"" help:"The EQ band number."`
Gain MainEqBandGainCmd `help:"Get or set the gain of the specified EQ band." cmd:"gain"`
Freq MainEqBandFreqCmd `help:"Get or set the frequency of the specified EQ band." cmd:"freq"`
Q MainEqBandQCmd `help:"Get or set the Q factor of the specified EQ band." cmd:"q"`
@ -145,13 +146,9 @@ type MainEqCmdGroup struct {
}
// Validate checks if the provided EQ band number is within the valid range (1-6) for the Main L/R output.
func (cmd *MainEqCmdGroup) Validate() error {
if cmd.Band.Band == nil {
return nil
}
if *cmd.Band.Band < 1 || *cmd.Band.Band > 6 {
return fmt.Errorf("EQ band number must be between 1 and 6, got %d", *cmd.Band.Band)
func (cmd *MainEqCmdGroup) 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
}
@ -162,7 +159,7 @@ type MainEqOnCmd struct {
}
// Run executes the MainEqOnCmd command, either retrieving the current EQ on/off state of the Main L/R output or setting it based on the provided argument.
func (cmd *MainEqOnCmd) Run(ctx *context) error {
func (cmd *MainEqOnCmd) Run(ctx *context, main *MainCmdGroup) error {
if cmd.Enable == nil {
resp, err := ctx.Client.Main.Eq.On(0)
if err != nil {
@ -172,10 +169,10 @@ func (cmd *MainEqOnCmd) Run(ctx *context) error {
return nil
}
if err := ctx.Client.Main.Eq.SetOn(0, *cmd.Enable == trueStr); err != nil {
if err := ctx.Client.Main.Eq.SetOn(0, *cmd.Enable == "true"); err != nil {
return fmt.Errorf("failed to set Main L/R EQ on/off state: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R EQ on/off state set to: %t\n", *cmd.Enable == trueStr)
fmt.Fprintf(ctx.Out, "Main L/R EQ on/off state set to: %t\n", *cmd.Enable == "true")
return nil
}
@ -185,25 +182,20 @@ type MainEqBandGainCmd struct {
}
// Run executes the MainEqBandGainCmd command, either retrieving the current gain of a specific EQ band on the Main L/R output or setting it based on the provided argument.
func (cmd *MainEqBandGainCmd) Run(ctx *context, mainEq *MainEqCmdGroup) error {
func (cmd *MainEqBandGainCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainEqCmdGroup) error {
if cmd.Level == nil {
resp, err := ctx.Client.Main.Eq.Gain(0, *mainEq.Band.Band)
resp, err := ctx.Client.Main.Eq.Gain(0, mainEq.Band.Band)
if err != nil {
return fmt.Errorf("failed to get Main L/R EQ band %d gain: %w", *mainEq.Band.Band, err)
return fmt.Errorf("failed to get Main L/R EQ band %d gain: %w", mainEq.Band.Band, err)
}
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d gain: %.2f dB\n", *mainEq.Band.Band, resp)
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d gain: %.2f dB\n", mainEq.Band.Band, resp)
return nil
}
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)
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
}
@ -213,29 +205,20 @@ type MainEqBandFreqCmd struct {
}
// Run executes the MainEqBandFreqCmd command, either retrieving the current frequency of a specific EQ band on the Main L/R output or setting it based on the provided argument.
func (cmd *MainEqBandFreqCmd) Run(ctx *context, mainEq *MainEqCmdGroup) error {
func (cmd *MainEqBandFreqCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainEqCmdGroup) error {
if cmd.Frequency == nil {
resp, err := ctx.Client.Main.Eq.Frequency(0, *mainEq.Band.Band)
resp, err := ctx.Client.Main.Eq.Frequency(0, mainEq.Band.Band)
if err != nil {
return fmt.Errorf(
"failed to get Main L/R EQ band %d frequency: %w",
*mainEq.Band.Band,
err,
)
return fmt.Errorf("failed to get Main L/R EQ band %d frequency: %w", mainEq.Band.Band, err)
}
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d frequency: %.2f Hz\n", *mainEq.Band.Band, resp)
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d frequency: %.2f Hz\n", mainEq.Band.Band, resp)
return nil
}
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)
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
}
@ -245,24 +228,20 @@ type MainEqBandQCmd struct {
}
// Run executes the MainEqBandQCmd command, either retrieving the current Q factor of a specific EQ band on the Main L/R output or setting it based on the provided argument.
func (cmd *MainEqBandQCmd) Run(ctx *context, mainEq *MainEqCmdGroup) error {
func (cmd *MainEqBandQCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainEqCmdGroup) error {
if cmd.Q == nil {
resp, err := ctx.Client.Main.Eq.Q(0, *mainEq.Band.Band)
resp, err := ctx.Client.Main.Eq.Q(0, mainEq.Band.Band)
if err != nil {
return fmt.Errorf(
"failed to get Main L/R EQ band %d Q factor: %w",
*mainEq.Band.Band,
err,
)
return fmt.Errorf("failed to get Main L/R EQ band %d Q factor: %w", mainEq.Band.Band, err)
}
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d Q factor: %.2f\n", *mainEq.Band.Band, resp)
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d Q factor: %.2f\n", mainEq.Band.Band, resp)
return nil
}
if err := ctx.Client.Main.Eq.SetQ(0, *mainEq.Band.Band, *cmd.Q); err != nil {
return fmt.Errorf("failed to set Main L/R EQ band %d Q factor: %w", *mainEq.Band.Band, err)
if err := ctx.Client.Main.Eq.SetQ(0, mainEq.Band.Band, *cmd.Q); err != nil {
return fmt.Errorf("failed to set Main L/R EQ band %d Q factor: %w", mainEq.Band.Band, err)
}
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d Q factor set to: %.2f\n", *mainEq.Band.Band, *cmd.Q)
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d Q factor set to: %.2f\n", mainEq.Band.Band, *cmd.Q)
return nil
}
@ -272,20 +251,20 @@ type MainEqBandTypeCmd struct {
}
// Run executes the MainEqBandTypeCmd command, either retrieving the current type of a specific EQ band on the Main L/R output or setting it based on the provided argument.
func (cmd *MainEqBandTypeCmd) Run(ctx *context, mainEq *MainEqCmdGroup) error {
func (cmd *MainEqBandTypeCmd) Run(ctx *context, main *MainCmdGroup, mainEq *MainEqCmdGroup) error {
if cmd.Type == nil {
resp, err := ctx.Client.Main.Eq.Type(0, *mainEq.Band.Band)
resp, err := ctx.Client.Main.Eq.Type(0, mainEq.Band.Band)
if err != nil {
return fmt.Errorf("failed to get Main L/R EQ band %d type: %w", *mainEq.Band.Band, err)
return fmt.Errorf("failed to get Main L/R EQ band %d type: %w", mainEq.Band.Band, err)
}
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d type: %s\n", *mainEq.Band.Band, resp)
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d type: %s\n", mainEq.Band.Band, resp)
return nil
}
if err := ctx.Client.Main.Eq.SetType(0, *mainEq.Band.Band, *cmd.Type); err != nil {
return fmt.Errorf("failed to set Main L/R EQ band %d type: %w", *mainEq.Band.Band, err)
if err := ctx.Client.Main.Eq.SetType(0, mainEq.Band.Band, *cmd.Type); err != nil {
return fmt.Errorf("failed to set Main L/R EQ band %d type: %w", mainEq.Band.Band, err)
}
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d type set to: %s\n", *mainEq.Band.Band, *cmd.Type)
fmt.Fprintf(ctx.Out, "Main L/R EQ band %d type set to: %s\n", mainEq.Band.Band, *cmd.Type)
return nil
}
@ -308,7 +287,7 @@ type MainCompOnCmd struct {
}
// Run executes the MainCompOnCmd command, either retrieving the current compressor on/off state of the Main L/R output or setting it based on the provided argument.
func (cmd *MainCompOnCmd) Run(ctx *context) error {
func (cmd *MainCompOnCmd) Run(ctx *context, main *MainCmdGroup) error {
if cmd.Enable == nil {
resp, err := ctx.Client.Main.Comp.On(0)
if err != nil {
@ -318,10 +297,10 @@ func (cmd *MainCompOnCmd) Run(ctx *context) error {
return nil
}
if err := ctx.Client.Main.Comp.SetOn(0, *cmd.Enable == trueStr); err != nil {
if err := ctx.Client.Main.Comp.SetOn(0, *cmd.Enable == "true"); err != nil {
return fmt.Errorf("failed to set Main L/R compressor on/off state: %w", err)
}
fmt.Fprintf(ctx.Out, "Main L/R compressor on/off state set to: %t\n", *cmd.Enable == trueStr)
fmt.Fprintf(ctx.Out, "Main L/R compressor on/off state set to: %t\n", *cmd.Enable == "true")
return nil
}
@ -331,7 +310,7 @@ type MainCompModeCmd struct {
}
// Run executes the MainCompModeCmd command, either retrieving the current compressor mode of the Main L/R output or setting it based on the provided argument.
func (cmd *MainCompModeCmd) Run(ctx *context) error {
func (cmd *MainCompModeCmd) Run(ctx *context, main *MainCmdGroup) error {
if cmd.Mode == nil {
resp, err := ctx.Client.Main.Comp.Mode(0)
if err != nil {
@ -354,7 +333,7 @@ type MainCompThresholdCmd struct {
}
// Run executes the MainCompThresholdCmd command, either retrieving the current compressor threshold of the Main L/R output or setting it based on the provided argument.
func (cmd *MainCompThresholdCmd) Run(ctx *context) error {
func (cmd *MainCompThresholdCmd) Run(ctx *context, main *MainCmdGroup) error {
if cmd.Threshold == nil {
resp, err := ctx.Client.Main.Comp.Threshold(0)
if err != nil {
@ -377,7 +356,7 @@ type MainCompRatioCmd struct {
}
// Run executes the MainCompRatioCmd command, either retrieving the current compressor ratio of the Main L/R output or setting it based on the provided argument.
func (cmd *MainCompRatioCmd) Run(ctx *context) error {
func (cmd *MainCompRatioCmd) Run(ctx *context, main *MainCmdGroup) error {
if cmd.Ratio == nil {
resp, err := ctx.Client.Main.Comp.Ratio(0)
if err != nil {
@ -400,7 +379,7 @@ type MainCompMixCmd struct {
}
// Run executes the MainCompMixCmd command, either retrieving the current compressor mix level of the Main L/R output or setting it based on the provided argument.
func (cmd *MainCompMixCmd) Run(ctx *context) error {
func (cmd *MainCompMixCmd) Run(ctx *context, main *MainCmdGroup) error {
if cmd.Mix == nil {
resp, err := ctx.Client.Main.Comp.Mix(0)
if err != nil {
@ -423,7 +402,7 @@ type MainCompMakeupCmd struct {
}
// Run executes the MainCompMakeupCmd command, either retrieving the current compressor makeup gain of the Main L/R output or setting it based on the provided argument.
func (cmd *MainCompMakeupCmd) Run(ctx *context) error {
func (cmd *MainCompMakeupCmd) Run(ctx *context, main *MainCmdGroup) error {
if cmd.Makeup == nil {
resp, err := ctx.Client.Main.Comp.Makeup(0)
if err != nil {
@ -446,7 +425,7 @@ type MainCompAttackCmd struct {
}
// Run executes the MainCompAttackCmd command, either retrieving the current compressor attack time of the Main L/R output or setting it based on the provided argument.
func (cmd *MainCompAttackCmd) Run(ctx *context) error {
func (cmd *MainCompAttackCmd) Run(ctx *context, main *MainCmdGroup) error {
if cmd.Attack == nil {
resp, err := ctx.Client.Main.Comp.Attack(0)
if err != nil {
@ -469,7 +448,7 @@ type MainCompHoldCmd struct {
}
// Run executes the MainCompHoldCmd command, either retrieving the current compressor hold time of the Main L/R output or setting it based on the provided argument.
func (cmd *MainCompHoldCmd) Run(ctx *context) error {
func (cmd *MainCompHoldCmd) Run(ctx *context, main *MainCmdGroup) error {
if cmd.Hold == nil {
resp, err := ctx.Client.Main.Comp.Hold(0)
if err != nil {
@ -492,7 +471,7 @@ type MainCompReleaseCmd struct {
}
// Run executes the MainCompReleaseCmd command, either retrieving the current compressor release time of the Main L/R output or setting it based on the provided argument.
func (cmd *MainCompReleaseCmd) Run(ctx *context) error {
func (cmd *MainCompReleaseCmd) Run(ctx *context, main *MainCmdGroup) error {
if cmd.Release == nil {
resp, err := ctx.Client.Main.Comp.Release(0)
if err != nil {

View File

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

View File

@ -3,6 +3,8 @@ package main
import (
"fmt"
"time"
"github.com/alecthomas/kong"
)
// StripCmdGroup defines the command group for controlling the strips of the mixer, including commands for getting and setting various parameters such as mute state, fader level, send levels, and EQ settings.
@ -38,7 +40,7 @@ func (cmd *StripMuteCmd) Run(ctx *context, strip *StripCmdGroup) error {
return nil
}
if err := ctx.Client.Strip.SetMute(strip.Index.Index, *cmd.State == trueStr); err != nil {
if err := ctx.Client.Strip.SetMute(strip.Index.Index, *cmd.State == "true"); err != nil {
return fmt.Errorf("failed to set mute state: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d mute state set to: %s\n", strip.Index.Index, *cmd.State)
@ -99,12 +101,7 @@ 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
}
@ -140,59 +137,36 @@ 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
}
}
// StripSendCmd defines the command for getting or setting the auxiliary send level
// for a specific send destination (mix bus) on a strip.
// StripSendCmd defines the command for getting or setting the send level for a specific bus on a strip, allowing users to control the level of the signal being sent from the strip to a particular bus.
type StripSendCmd struct {
SendIndex int `arg:"" help:"The index of the send destination (mix bus). (1-based indexing)"`
BusNum int `arg:"" help:"The bus number to get or set the send level for."`
Level *float64 `arg:"" help:"The send level to set (in dB)." optional:""`
}
// Run executes the StripSendCmd command, either retrieving the current send level for the specified send destination
// or setting it based on the provided argument.
// Run executes the StripSendCmd command, either retrieving the current send level for the specified bus on the strip or setting it based on the provided argument.
func (cmd *StripSendCmd) Run(ctx *context, strip *StripCmdGroup) error {
if cmd.Level == nil {
resp, err := ctx.Client.Strip.SendLevel(strip.Index.Index, cmd.SendIndex)
resp, err := ctx.Client.Strip.SendLevel(strip.Index.Index, cmd.BusNum)
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 level for bus %d: %.2f dB\n", strip.Index.Index, cmd.BusNum, 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.BusNum, *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 level for bus %d set to: %.2f dB\n", strip.Index.Index, cmd.BusNum, *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 organisation.
// 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.
type StripNameCmd struct {
Name *string `arg:"" help:"The name to set for the strip." optional:""`
}
@ -242,7 +216,7 @@ func (cmd *StripGateOnCmd) Run(ctx *context, strip *StripCmdGroup) error {
return nil
}
if err := ctx.Client.Strip.Gate.SetOn(strip.Index.Index, *cmd.Enable == trueStr); err != nil {
if err := ctx.Client.Strip.Gate.SetOn(strip.Index.Index, *cmd.Enable == "true"); err != nil {
return fmt.Errorf("failed to set gate state: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d gate state set to: %s\n", strip.Index.Index, *cmd.Enable)
@ -291,12 +265,7 @@ 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
}
@ -342,12 +311,7 @@ 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
}
@ -393,12 +357,7 @@ 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
}
@ -406,7 +365,7 @@ func (cmd *StripGateReleaseCmd) Run(ctx *context, strip *StripCmdGroup) error {
type StripEqCmdGroup struct {
On StripEqOnCmd `help:"Get or set the EQ on/off state of the strip." cmd:""`
Band struct {
Band *int `arg:"" help:"The EQ band number." optional:""`
Band int `arg:"" help:"The EQ band number."`
Gain StripEqBandGainCmd `help:"Get or set the gain of the EQ band." cmd:""`
Freq StripEqBandFreqCmd `help:"Get or set the frequency of the EQ band." cmd:""`
Q StripEqBandQCmd `help:"Get or set the Q factor of the EQ band." cmd:""`
@ -415,13 +374,9 @@ type StripEqCmdGroup struct {
}
// Validate checks if the provided EQ band number is valid (between 1 and 4) and returns an error if it is not.
func (cmd *StripEqCmdGroup) Validate() error {
if cmd.Band.Band == nil {
return nil
}
if *cmd.Band.Band < 1 || *cmd.Band.Band > 4 {
return fmt.Errorf("EQ band number must be between 1 and 4, got %d", *cmd.Band.Band)
func (cmd *StripEqCmdGroup) Validate(ctx kong.Context) error {
if cmd.Band.Band < 1 || cmd.Band.Band > 4 {
return fmt.Errorf("EQ band number must be between 1 and 4")
}
return nil
}
@ -442,7 +397,7 @@ func (cmd *StripEqOnCmd) Run(ctx *context, strip *StripCmdGroup) error {
return nil
}
if err := ctx.Client.Strip.Eq.SetOn(strip.Index.Index, *cmd.Enable == trueStr); err != nil {
if err := ctx.Client.Strip.Eq.SetOn(strip.Index.Index, *cmd.Enable == "true"); err != nil {
return fmt.Errorf("failed to set EQ state: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d EQ state set to: %s\n", strip.Index.Index, *cmd.Enable)
@ -455,81 +410,47 @@ 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)
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 centre 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 center 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)
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(
ctx.Out,
"Strip %d EQ band %d frequency set to: %.2f Hz\n",
strip.Index.Index,
*stripEq.Band.Band,
stripEq.Band.Band,
*cmd.Freq,
)
return nil
@ -541,36 +462,20 @@ 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)
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 {
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
}
@ -580,40 +485,20 @@ 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)
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
}
@ -646,7 +531,7 @@ func (cmd *StripCompOnCmd) Run(ctx *context, strip *StripCmdGroup) error {
return nil
}
if err := ctx.Client.Strip.Comp.SetOn(strip.Index.Index, *cmd.Enable == trueStr); err != nil {
if err := ctx.Client.Strip.Comp.SetOn(strip.Index.Index, *cmd.Enable == "true"); err != nil {
return fmt.Errorf("failed to set compressor state: %w", err)
}
fmt.Fprintf(ctx.Out, "Strip %d compressor state set to: %s\n", strip.Index.Index, *cmd.Enable)
@ -695,12 +580,7 @@ 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
}
@ -769,12 +649,7 @@ 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
}
@ -797,12 +672,7 @@ 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
}
@ -825,12 +695,7 @@ 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
}
@ -853,11 +718,6 @@ 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

@ -1,197 +0,0 @@
```console
Usage: x32-cli <command> [flags]
A CLI to control Behringer X32 mixers.
Flags:
-h, --help Show context-sensitive help.
-H, --host="mixer.local" The host of the X32 device ($X32_CLI_HOST).
-P, --port=10023 The port of the X32 device ($X32_CLI_PORT).
-T, --timeout=100ms Timeout for OSC operations ($X32_CLI_TIMEOUT).
-L, --loglevel="warn" Log level for the CLI ($X32_CLI_LOGLEVEL).
-v, --version Print x32-cli version information and quit
Commands:
completion Generate shell completion scripts.
info Print mixer information.
raw Send raw OSC messages to the mixer.
Main
main mute Get or set the mute state of the Main L/R output.
main fader Get or set the fader level of the Main L/R output.
main fadein Fade in the Main L/R output over a specified duration.
main fadeout Fade out the Main L/R output over a specified duration.
main eq on Get or set the EQ on/off state of the Main L/R output.
main eq <band> gain Get or set the gain of the specified EQ band.
main eq <band> freq Get or set the frequency of the specified EQ band.
main eq <band> q Get or set the Q factor of the specified EQ band.
main eq <band> type Get or set the type of the specified EQ band.
main comp on Get or set the compressor on/off state of the Main L/R
output.
main comp mode Get or set the compressor mode of the Main L/R output.
main comp threshold Get or set the compressor threshold of the Main L/R
output.
main comp ratio Get or set the compressor ratio of the Main L/R output.
main comp mix Get or set the compressor mix level of the Main L/R
output.
main comp makeup Get or set the compressor makeup gain of the Main L/R
output.
main comp attack Get or set the compressor attack time of the Main L/R
output.
main comp hold Get or set the compressor hold time of the Main L/R
output.
main comp release Get or set the compressor release time of the Main L/R
output.
MainMono
mainmono mute Get or set the mute state of the Main Mono output.
mainmono fader Get or set the fader level of the Main Mono output.
mainmono fadein Fade in the Main Mono output over a specified
duration.
mainmono fadeout Fade out the Main Mono output over a specified
duration.
mainmono eq on Get or set the EQ on/off state of the Main Mono
output.
mainmono eq <band> gain Get or set the gain of the specified EQ band.
mainmono eq <band> freq Get or set the frequency of the specified EQ band.
mainmono eq <band> q Get or set the Q factor of the specified EQ band.
mainmono eq <band> type Get or set the type of the specified EQ band.
mainmono comp on Get or set the compressor on/off state of the Main
Mono output.
mainmono comp mode Get or set the compressor mode of the Main Mono
output.
mainmono comp threshold Get or set the compressor threshold of the Main
Mono output.
mainmono comp ratio Get or set the compressor ratio of the Main Mono
output.
mainmono comp mix Get or set the compressor mix level of the Main
Mono output.
mainmono comp makeup Get or set the compressor makeup gain of the Main
Mono output.
mainmono comp attack Get or set the compressor attack time of the Main
Mono output.
mainmono comp hold Get or set the compressor hold time of the Main
Mono output.
mainmono comp release Get or set the compressor release time of the Main
Mono output.
Matrix
matrix <index> mute Get or set the mute state of the Matrix
output.
matrix <index> fader Get or set the fader level of the Matrix
output.
matrix <index> fadein Fade in the Matrix output over a specified
duration.
matrix <index> fadeout Fade out the Matrix output over a specified
duration.
matrix <index> eq on Get or set the EQ on/off state of the Matrix
output.
matrix <index> eq <band> gain Get or set the gain of the specified EQ band.
matrix <index> eq <band> freq Get or set the frequency of the specified EQ
band.
matrix <index> eq <band> q Get or set the Q factor of the specified EQ
band.
matrix <index> eq <band> type Get or set the type of the specified EQ band.
matrix <index> comp on Get or set the compressor on/off state of the
Matrix output.
matrix <index> comp mode Get or set the compressor mode of the Matrix
output.
matrix <index> comp threshold Get or set the compressor threshold of the
Matrix output.
matrix <index> comp ratio Get or set the compressor ratio of the Matrix
output.
matrix <index> comp mix Get or set the compressor mix level of the
Matrix output.
matrix <index> comp makeup Get or set the compressor makeup gain of the
Matrix output.
matrix <index> comp attack Get or set the compressor attack time of the
Matrix output.
matrix <index> comp hold Get or set the compressor hold time of the
Matrix output.
matrix <index> comp release Get or set the compressor release time of the
Matrix output.
Strip
strip <index> mute Get or set the mute state of the strip.
strip <index> fader Get or set the fader level of the strip.
strip <index> fadein Fade in the strip over a specified duration.
strip <index> fadeout Fade out the strip over a specified duration.
strip <index> send Get or set the send level for a specific bus.
strip <index> name Get or set the name of the strip.
strip <index> gate on Get or set the gate on/off state of the strip.
strip <index> gate mode Get or set the gate mode of the strip.
strip <index> gate threshold Get or set the gate threshold of the strip.
strip <index> gate range Get or set the gate range of the strip.
strip <index> gate attack Get or set the gate attack time of the strip.
strip <index> gate hold Get or set the gate hold time of the strip.
strip <index> gate release Get or set the gate release time of the strip.
strip <index> eq on Get or set the EQ on/off state of the strip.
strip <index> eq <band> gain Get or set the gain of the EQ band.
strip <index> eq <band> freq Get or set the frequency of the EQ band.
strip <index> eq <band> q Get or set the Q factor of the EQ band.
strip <index> eq <band> type Get or set the type of the EQ band.
strip <index> comp on Get or set the compressor on/off state of the
strip.
strip <index> comp mode Get or set the compressor mode of the strip.
strip <index> comp threshold Get or set the compressor threshold of the
strip.
strip <index> comp ratio Get or set the compressor ratio of the strip.
strip <index> comp mix Get or set the compressor mix of the strip.
strip <index> comp makeup Get or set the compressor makeup gain of the
strip.
strip <index> comp attack Get or set the compressor attack time of the
strip.
strip <index> comp hold Get or set the compressor hold time of the
strip.
strip <index> comp release Get or set the compressor release time of the
strip.
Bus
bus <index> mute Get or set the mute state of the bus.
bus <index> fader Get or set the fader level of the bus.
bus <index> fadein Fade in the bus over a specified duration.
bus <index> fadeout Fade out the bus over a specified duration.
bus <index> name Get or set the name of the bus.
bus <index> eq on Get or set the EQ on/off state of the bus.
bus <index> eq mode Get or set the EQ mode of the bus (peq, geq or
teq).
bus <index> eq <band> gain Get or set the gain of the EQ band.
bus <index> eq <band> freq Get or set the frequency of the EQ band.
bus <index> eq <band> q Get or set the Q factor of the EQ band.
bus <index> eq <band> type Get or set the type of the EQ band (lcut, lshv,
peq, veq, hshv, hcut).
bus <index> comp on Get or set the compressor on/off state of the
bus.
bus <index> comp mode Get or set the compressor mode of the bus (comp,
exp).
bus <index> comp threshold Get or set the compressor threshold of the bus
(in dB).
bus <index> comp ratio Get or set the compressor ratio of the bus.
bus <index> comp mix Get or set the compressor mix level of the bus
(in %).
bus <index> comp makeup Get or set the compressor makeup gain of the bus
(in dB).
bus <index> comp attack Get or set the compressor attack time of the bus
(in ms).
bus <index> comp hold Get or set the compressor hold time of the bus
(in ms).
bus <index> comp release Get or set the compressor release time of the
bus (in ms).
Headamp
headamp <index> gain Get or set the gain of the headamp.
headamp <index> phantom Get or set the phantom power state of the headamp.
Snapshot
snapshot list List all snapshots.
snapshot <index> name Get or set the name of a snapshot.
snapshot <index> save Save the current mixer state to a snapshot.
snapshot <index> load Load a mixer state from a snapshot.
snapshot <index> delete Delete a snapshot.
DCA
dca <index> mute Get or set the mute status of the DCA group.
dca <index> name Get or set the name of the DCA group.
Run "x32-cli <command> --help" for more information on a command.
```

View File

@ -1,129 +0,0 @@
```console
Usage: xair-cli <command> [flags]
A CLI to control Behringer X-Air mixers.
Flags:
-h, --help Show context-sensitive help.
-H, --host="mixer.local" The host of the X-Air device ($XAIR_CLI_HOST).
-P, --port=10024 The port of the X-Air device ($XAIR_CLI_PORT).
-T, --timeout=100ms Timeout for OSC operations ($XAIR_CLI_TIMEOUT).
-L, --loglevel="warn" Log level for the CLI ($XAIR_CLI_LOGLEVEL).
-v, --version Print xair-cli version information and quit
Commands:
completion Generate shell completion scripts.
info Print mixer information.
raw Send raw OSC messages to the mixer.
Main
main mute Get or set the mute state of the Main L/R output.
main fader Get or set the fader level of the Main L/R output.
main fadein Fade in the Main L/R output over a specified duration.
main fadeout Fade out the Main L/R output over a specified duration.
main eq on Get or set the EQ on/off state of the Main L/R output.
main eq <band> gain Get or set the gain of the specified EQ band.
main eq <band> freq Get or set the frequency of the specified EQ band.
main eq <band> q Get or set the Q factor of the specified EQ band.
main eq <band> type Get or set the type of the specified EQ band.
main comp on Get or set the compressor on/off state of the Main L/R
output.
main comp mode Get or set the compressor mode of the Main L/R output.
main comp threshold Get or set the compressor threshold of the Main L/R
output.
main comp ratio Get or set the compressor ratio of the Main L/R output.
main comp mix Get or set the compressor mix level of the Main L/R
output.
main comp makeup Get or set the compressor makeup gain of the Main L/R
output.
main comp attack Get or set the compressor attack time of the Main L/R
output.
main comp hold Get or set the compressor hold time of the Main L/R
output.
main comp release Get or set the compressor release time of the Main L/R
output.
Strip
strip <index> mute Get or set the mute state of the strip.
strip <index> fader Get or set the fader level of the strip.
strip <index> fadein Fade in the strip over a specified duration.
strip <index> fadeout Fade out the strip over a specified duration.
strip <index> send Get or set the send level for a specific bus.
strip <index> name Get or set the name of the strip.
strip <index> gate on Get or set the gate on/off state of the strip.
strip <index> gate mode Get or set the gate mode of the strip.
strip <index> gate threshold Get or set the gate threshold of the strip.
strip <index> gate range Get or set the gate range of the strip.
strip <index> gate attack Get or set the gate attack time of the strip.
strip <index> gate hold Get or set the gate hold time of the strip.
strip <index> gate release Get or set the gate release time of the strip.
strip <index> eq on Get or set the EQ on/off state of the strip.
strip <index> eq <band> gain Get or set the gain of the EQ band.
strip <index> eq <band> freq Get or set the frequency of the EQ band.
strip <index> eq <band> q Get or set the Q factor of the EQ band.
strip <index> eq <band> type Get or set the type of the EQ band.
strip <index> comp on Get or set the compressor on/off state of the
strip.
strip <index> comp mode Get or set the compressor mode of the strip.
strip <index> comp threshold Get or set the compressor threshold of the
strip.
strip <index> comp ratio Get or set the compressor ratio of the strip.
strip <index> comp mix Get or set the compressor mix of the strip.
strip <index> comp makeup Get or set the compressor makeup gain of the
strip.
strip <index> comp attack Get or set the compressor attack time of the
strip.
strip <index> comp hold Get or set the compressor hold time of the
strip.
strip <index> comp release Get or set the compressor release time of the
strip.
Bus
bus <index> mute Get or set the mute state of the bus.
bus <index> fader Get or set the fader level of the bus.
bus <index> fadein Fade in the bus over a specified duration.
bus <index> fadeout Fade out the bus over a specified duration.
bus <index> name Get or set the name of the bus.
bus <index> eq on Get or set the EQ on/off state of the bus.
bus <index> eq mode Get or set the EQ mode of the bus (peq, geq or
teq).
bus <index> eq <band> gain Get or set the gain of the EQ band.
bus <index> eq <band> freq Get or set the frequency of the EQ band.
bus <index> eq <band> q Get or set the Q factor of the EQ band.
bus <index> eq <band> type Get or set the type of the EQ band (lcut, lshv,
peq, veq, hshv, hcut).
bus <index> comp on Get or set the compressor on/off state of the
bus.
bus <index> comp mode Get or set the compressor mode of the bus (comp,
exp).
bus <index> comp threshold Get or set the compressor threshold of the bus
(in dB).
bus <index> comp ratio Get or set the compressor ratio of the bus.
bus <index> comp mix Get or set the compressor mix level of the bus
(in %).
bus <index> comp makeup Get or set the compressor makeup gain of the bus
(in dB).
bus <index> comp attack Get or set the compressor attack time of the bus
(in ms).
bus <index> comp hold Get or set the compressor hold time of the bus
(in ms).
bus <index> comp release Get or set the compressor release time of the
bus (in ms).
Headamp
headamp <index> gain Get or set the gain of the headamp.
headamp <index> phantom Get or set the phantom power state of the headamp.
Snapshot
snapshot list List all snapshots.
snapshot <index> name Get or set the name of a snapshot.
snapshot <index> save Save the current mixer state to a snapshot.
snapshot <index> load Load a mixer state from a snapshot.
snapshot <index> delete Delete a snapshot.
DCA
dca <index> mute Get or set the mute status of the DCA group.
dca <index> name Get or set the name of the DCA group.
Run "xair-cli <command> --help" for more information on a command.
```